From f44cdb5f1e87ec5696b6ba7c67911e73053ae4af Mon Sep 17 00:00:00 2001 From: ThomasJ Date: Tue, 19 Jan 2016 00:31:00 +0900 Subject: [PATCH] ax5modal 95% --- dist/ax5toast.js | 15 ++++++++++----- dist/ax5toast.min.js | 2 +- src/ax5toast.js | 15 ++++++++++----- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/dist/ax5toast.js b/dist/ax5toast.js index d2efefd..6d56849 100755 --- a/dist/ax5toast.js +++ b/dist/ax5toast.js @@ -58,13 +58,17 @@ this.init = function () { // after set_config(); self.containerId = ax5.getGuid(); + var styles = []; + if(cfg.zIndex){ + styles.push("z-index:" + cfg.zIndex); + } jQuery(document.body).append('
'); + '' + self.containerId + '" style="' + styles.join(";") + '">'); this.toastContainer = jQuery('[data-toast-container="' + self.containerId + '"]'); }; this.push = function (opts, callBack) { - if(!self.containerId){ + if (!self.containerId) { this.init(); } if (U.isString(opts)) { @@ -85,7 +89,7 @@ }; this.confirm = function (opts, callBack) { - if(!self.containerId){ + if (!self.containerId) { this.init(); } if (U.isString(opts)) { @@ -149,9 +153,10 @@ width: opts.width }; - if(U.left(cfg.containerPosition, '-') == 'bottom'){ + if (U.left(cfg.containerPosition, '-') == 'bottom') { this.toastContainer.append(this.getContent(opts.id, opts)); - }else{ + } + else { this.toastContainer.prepend(this.getContent(opts.id, opts)); } diff --git a/dist/ax5toast.min.js b/dist/ax5toast.min.js index d20444c..6889e2d 100755 --- a/dist/ax5toast.min.js +++ b/dist/ax5toast.min.js @@ -1 +1 @@ -!function(t,i){var n=ax5.util,e=function(){var t,e=this;this.main=function(){i&&i.call(this),this.config={clickEventName:"click",theme:"default",width:300,icon:"",closeIcon:"",msg:"",lang:{ok:"ok",cancel:"cancel"},displayTime:3e3,animateTime:250,containerPosition:"bottom-left"}}.apply(this,arguments),this.toastContainer=null,this.queue=[],t=this.config,this.init=function(){e.containerId=ax5.getGuid(),jQuery(document.body).append('
'),this.toastContainer=jQuery('[data-toast-container="'+e.containerId+'"]')},this.push=function(i,o){return e.containerId||this.init(),n.isString(i)&&(i={title:t.title,msg:i}),i.toastType="push",e.dialogConfig={},jQuery.extend(!0,e.dialogConfig,t),jQuery.extend(!0,e.dialogConfig,i),i=e.dialogConfig,this.open(i,o),this},this.confirm=function(i,o){return e.containerId||this.init(),n.isString(i)&&(i={title:t.title,msg:i}),i.toastType="confirm",e.dialogConfig={},jQuery.extend(!0,e.dialogConfig,t),jQuery.extend(!0,e.dialogConfig,i),i=e.dialogConfig,"undefined"==typeof i.btns&&(i.btns={ok:{label:t.lang.ok,theme:i.theme}}),this.open(i,o),this},this.getContent=function(t,i){var e=[];return e.push('
'),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('
'),n.each(i.btns,function(t,i){e.push('")}),e.push("
"),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;this.main=function(){i&&i.call(this),this.config={clickEventName:"click",theme:"default",width:300,icon:"",closeIcon:"",msg:"",lang:{ok:"ok",cancel:"cancel"},displayTime:3e3,animateTime:250,containerPosition:"bottom-left"}}.apply(this,arguments),this.toastContainer=null,this.queue=[],t=this.config,this.init=function(){e.containerId=ax5.getGuid();var i=[];t.zIndex&&i.push("z-index:"+t.zIndex),jQuery(document.body).append('
'),this.toastContainer=jQuery('[data-toast-container="'+e.containerId+'"]')},this.push=function(i,o){return e.containerId||this.init(),n.isString(i)&&(i={title:t.title,msg:i}),i.toastType="push",e.dialogConfig={},jQuery.extend(!0,e.dialogConfig,t),jQuery.extend(!0,e.dialogConfig,i),i=e.dialogConfig,this.open(i,o),this},this.confirm=function(i,o){return e.containerId||this.init(),n.isString(i)&&(i={title:t.title,msg:i}),i.toastType="confirm",e.dialogConfig={},jQuery.extend(!0,e.dialogConfig,t),jQuery.extend(!0,e.dialogConfig,i),i=e.dialogConfig,"undefined"==typeof i.btns&&(i.btns={ok:{label:t.lang.ok,theme:i.theme}}),this.open(i,o),this},this.getContent=function(t,i){var e=[];return e.push('
'),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('
'),n.each(i.btns,function(t,i){e.push('")}),e.push("
"),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 diff --git a/src/ax5toast.js b/src/ax5toast.js index d2efefd..6d56849 100755 --- a/src/ax5toast.js +++ b/src/ax5toast.js @@ -58,13 +58,17 @@ this.init = function () { // after set_config(); self.containerId = ax5.getGuid(); + var styles = []; + if(cfg.zIndex){ + styles.push("z-index:" + cfg.zIndex); + } jQuery(document.body).append('
'); + '' + self.containerId + '" style="' + styles.join(";") + '">'); this.toastContainer = jQuery('[data-toast-container="' + self.containerId + '"]'); }; this.push = function (opts, callBack) { - if(!self.containerId){ + if (!self.containerId) { this.init(); } if (U.isString(opts)) { @@ -85,7 +89,7 @@ }; this.confirm = function (opts, callBack) { - if(!self.containerId){ + if (!self.containerId) { this.init(); } if (U.isString(opts)) { @@ -149,9 +153,10 @@ width: opts.width }; - if(U.left(cfg.containerPosition, '-') == 'bottom'){ + if (U.left(cfg.containerPosition, '-') == 'bottom') { this.toastContainer.append(this.getContent(opts.id, opts)); - }else{ + } + else { this.toastContainer.prepend(this.getContent(opts.id, opts)); }