PopMan
๐ฌ
Index
1. Getting Started
1-1. How to load?
- Browser
<script src="https://cdn.jsdelivr.net/npm/@sj-js/crossman/dist/js/crossman.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@sj-js/popman/dist/js/popman.min.js"></script>
<script>
var popman = new PopMan();
</script>
- ES6+
npm i @sj-js/popman
const PopMan = require('@sj-js/popman');
const popman = new PopMan();
1-2. Simple Example
For convenience, 1-1 code, which loads and creates a Library in the example, is omitted.
Exapmle - popman.pop() with script
popman.new({OPTIONS})
๋ก POP Element๋ฅผ ๋ฑ๋กํฉ๋๋ค.
popman.new({
id:'pop-test', //Pop Element ID
exp:'50%/90%', //Width and Height
content: 'This is contents.'
});
popman.pop('Element ID')
๋ก POP Element๋ฅผ ํธ์ถํฉ๋๋ค.
popman.pop('pop-test');
๐จโ๐ป
<body>
Hello Popman
<button onclick="popman.pop('pop-test');">POP</button>
<div id="tester">TEST</div>
</body>
<script>
popman.setup({modeTest:true});
popman.new({
id:'pop-test',
exp:'50%/90%',
closebyesc:true,
content:'This is contents. <br/><br/>',
modeAuto:true, //Open automatically
add:function(data){
document.getElementById('tester').innerHTML = 'When add';
},
pop:function(data){
document.getElementById('tester').innerHTML = 'When pop';
},
close:function(data){
document.getElementById('tester').innerHTML = 'When close';
}
});
</script>
Exapmle - popman.pop() with template
- Pop Element์
data-pop
์์ฑ์ ์ค์ ํฉ๋๋ค. <div id="pop-test" data-pop data-exp="300/200" >
Pop contents with template
</div>
popman.detect()
๋ฅผ ์ฌ์ฉํ๋ฉด data-pop ์์ฑ์ ๊ฐ์ง element๊ฐ ๋ฑ๋ก๋ฉ๋๋ค. popman.detect();
popman.pop('ID')
๋ฅผ ํธ์ถํ๋ฉด ํ๋ฉด์ ํ์๋ฉ๋๋ค. popman.pop('pop-test');
๐จโ๐ป
<script>
popman.setup({modeTest:true}).detect();
</script>
<body>
<button onclick="popman.pop('pop-test');">POP</button>
<div id="pop-test" data-pop data-exp="300/200" data-closebyclickin data-mode-auto>
<br/>
<div id="divAlertMsg" style="font-size:35px; color:white; border:2px solid; background:#F08047;">
TEST
</div>
<div id="divAlert1stMsg">
TEST
</div>
</div>
</body>
Exapmle - popman.alert()
- ๐จโ๐ป
<body>
Hello Popman - Alert
<button onclick="alertSomething();">ALERT</button>
</body>
<script>
popman.setup({modeTest:true, alertExp:'200/100'});
function alertSomething(){
popman.alert('Alert Something', function(){
alert('Alert! Ok!');
return true;
});
}
alertSomething();
</script>
Exapmle - popman.confirm()
- ๐จโ๐ป
<body>
Hello PopMan - Confirm
<button onclick="confirmSomething();">CONFIRM</button>
</body>
<script>
popman.setup({modeTest:true, confirmExp:'300/150'});
function confirmSomething(){
popman.confirm('Confirm Something',
function(){
alert('OK!');
return true;
},
function(){
alert('Cancel!');
return true;
}
);
}
confirmSomething();
</script>
Exapmle - popman.loading()
- ๐จโ๐ป
<body>
Hello Popman- Loading
<button onclick="loadSomething();">LOAD</button>
</body>
<script>
popman.setup({modeTest:true, loadingExp:'80%/100'});
function loadSomething(){
popman.loading('LOADING.. Something..', function(resolve, reject){
setTimeout(function(){
resolve();
}, 2000);
});
}
loadSomething();
</script>