'),i.icon&&(e.push('
'),e.push(i.icon||""),e.push("
")),e.push('
'),e.push((i.msg||"").replace(/\n/g,"
")),e.push("
"),i.btns?(e.push('
")):e.push('
'+(i.closeIcon||"")+""),e.push('
'),e.push("
"),e.join("")},this.open=function(i,o){var a;if(i.id="ax5-toast-"+e.containerId+"-"+this.queue.length,box={width:i.width},"bottom"==n.left(t.containerPosition,"-")?this.toastContainer.append(this.getContent(i.id,i)):this.toastContainer.prepend(this.getContent(i.id,i)),a=jQuery("#"+i.id),a.css({width:box.width}),i.toastBox=a,this.queue.push(i),i&&i.onStateChanged){var s={state:"open",toastId:i.id};i.onStateChanged.call(s,s)}"push"===i.toastType?(setTimeout(function(){this.close(i,a,o)}.bind(this),t.displayTime),a.find("[data-ax-toast-btn]").on(t.clickEventName,function(t){this.btnOnClick(t||window.event,i,a,o)}.bind(this))):"confirm"===i.toastType&&a.find("[data-ax-toast-btn]").on(t.clickEventName,function(t){this.btnOnClick(t||window.event,i,a,o)}.bind(this))},this.btnOnClick=function(t,i,e,o,a,s){if(a=n.findParentNode(t.target,function(t){return t.getAttribute("data-ax-toast-btn")?!0:void 0})){s=a.getAttribute("data-ax-toast-btn");var d={key:s,value:i.btns?i.btns[s]:s,toastId:i.id,btn_target:a};i.btns&&i.btns[s].onClick?i.btns[s].onClick.call(d,s):"push"===i.toastType?(o&&o.call(d,s),this.close(i,e)):"confirm"===i.toastType&&(o&&o.call(d,s),this.close(i,e))}},this.onKeyup=function(t,i,n,e,o){t.keyCode==ax5.info.eventKeys.ESC&&this.queue.length>0&&this.close()},this.close=function(i,e,o){return"undefined"==typeof e&&(i=n.last(this.queue),e=i.toastBox),e.addClass("push"==i.toastType?"removed":"destroy"),this.queue=n.filter(this.queue,function(){return i.id!=this.id}),setTimeout(function(){var t={toastId:i.id};e.remove(),o&&o.call(t),i&&i.onStateChanged&&(t={state:"close",toastId:i.id},i.onStateChanged.call(t,t))},t.animateTime),this}};n.isFunction(i)&&(e.prototype=new i),t.toast=e}(ax5.ui,ax5.ui.root);
\ No newline at end of file
+!function(t,i){var n=ax5.util,e=function(){var t,e=this;i&&i.call(this),this.toastContainer=null,this.queue=[],this.config={clickEventName:"click",theme:"default",width:300,icon:"",closeIcon:"",msg:"",lang:{ok:"ok",cancel:"cancel"},displayTime:3e3,animateTime:250,containerPosition:"bottom-left"},t=this.config,this.init=function(){e.containerId=ax5.getGuid();var i=[];t.zIndex&&i.push("z-index:"+t.zIndex),jQuery(document.body).append(''),i.icon&&(e.push('
'),e.push(i.icon||""),e.push("
")),e.push('
'),e.push((i.msg||"").replace(/\n/g,"
")),e.push("
"),i.btns?(e.push('
")):e.push('
'+(i.closeIcon||"")+""),e.push('
'),e.push("
"),e.join("")},this.open=function(i,o){var s;if(i.id="ax5-toast-"+e.containerId+"-"+this.queue.length,box={width:i.width},"bottom"==n.left(t.containerPosition,"-")?this.toastContainer.append(this.getContent(i.id,i)):this.toastContainer.prepend(this.getContent(i.id,i)),s=jQuery("#"+i.id),s.css({width:box.width}),i.toastBox=s,this.queue.push(i),i&&i.onStateChanged){var a={state:"open",toastId:i.id};i.onStateChanged.call(a,a)}"push"===i.toastType?(setTimeout(function(){this.close(i,s,o)}.bind(this),t.displayTime),s.find("[data-ax-toast-btn]").on(t.clickEventName,function(t){this.btnOnClick(t||window.event,i,s,o)}.bind(this))):"confirm"===i.toastType&&s.find("[data-ax-toast-btn]").on(t.clickEventName,function(t){this.btnOnClick(t||window.event,i,s,o)}.bind(this))},this.btnOnClick=function(t,i,e,o,s,a){if(s=n.findParentNode(t.target,function(t){return t.getAttribute("data-ax-toast-btn")?!0:void 0})){a=s.getAttribute("data-ax-toast-btn");var d={key:a,value:i.btns?i.btns[a]:a,toastId:i.id,btn_target:s};i.btns&&i.btns[a].onClick?i.btns[a].onClick.call(d,a):"push"===i.toastType?(o&&o.call(d,a),this.close(i,e)):"confirm"===i.toastType&&(o&&o.call(d,a),this.close(i,e))}},this.onKeyup=function(t,i,n,e,o){t.keyCode==ax5.info.eventKeys.ESC&&this.queue.length>0&&this.close()},this.close=function(i,e,o){return"undefined"==typeof e&&(i=n.last(this.queue),e=i.toastBox),e.addClass("push"==i.toastType?"removed":"destroy"),this.queue=n.filter(this.queue,function(){return i.id!=this.id}),setTimeout(function(){var t={toastId:i.id};e.remove(),o&&o.call(t),i&&i.onStateChanged&&(t={state:"close",toastId:i.id},i.onStateChanged.call(t,t))},t.animateTime),this},this.main=function(){arguments&&n.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)};n.isFunction(i)&&(e.prototype=new i),t.toast=e}(ax5.ui,ax5.ui.root);
\ No newline at end of file
diff --git a/package.json b/package.json
index accd8ce..b96712a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "bootstrap-ax5toast",
- "version": "0.1.0",
+ "version": "0.2.0",
"description": "A toast plugin that works with Bootstrap & jQuery",
"license": "MIT",
"repository": {
diff --git a/src/ax5toast.js b/src/ax5toast.js
index 6d56849..5f8368b 100755
--- a/src/ax5toast.js
+++ b/src/ax5toast.js
@@ -21,28 +21,24 @@
var
self = this,
cfg;
-
- // 클래스 생성자
- this.main = (function () {
- if (_SUPER_) _SUPER_.call(this); // 부모호출
- this.config = {
- clickEventName: "click", //(('ontouchstart' in document.documentElement) ? "touchstart" : "click"),
- theme: 'default',
- width: 300,
- icon: '',
- closeIcon: '',
- msg: '',
- lang: {
- "ok": "ok", "cancel": "cancel"
- },
- displayTime: 3000,
- animateTime: 250,
- containerPosition: "bottom-left"
- };
- }).apply(this, arguments);
-
+
+ if (_SUPER_) _SUPER_.call(this); // 부모호출
this.toastContainer = null;
this.queue = [];
+ this.config = {
+ clickEventName: "click", //(('ontouchstart' in document.documentElement) ? "touchstart" : "click"),
+ theme: 'default',
+ width: 300,
+ icon: '',
+ closeIcon: '',
+ msg: '',
+ lang: {
+ "ok": "ok", "cancel": "cancel"
+ },
+ displayTime: 3000,
+ animateTime: 250,
+ containerPosition: "bottom-left"
+ };
cfg = this.config;
/**
@@ -265,7 +261,14 @@
}
}, cfg.animateTime);
return this;
- }
+ };
+
+ // 클래스 생성자
+ this.main = (function () {
+ if(arguments && U.isObject(arguments[0])) {
+ this.setConfig(arguments[0]);
+ }
+ }).apply(this, arguments);
};
//== UI Class