ax5ui-dialog
Advanced tools
Comparing version 0.6.9 to 0.7.0
{ | ||
"name": "ax5ui-dialog", | ||
"version": "0.6.9", | ||
"version": "0.7.0", | ||
"authors": [ | ||
@@ -5,0 +5,0 @@ "ThomasJ <tom@axisj.com>" |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @classdesc | ||
* @version 0.6.9 | ||
* @version 0.7.0 | ||
* @author tom@axisj.com | ||
@@ -275,3 +275,3 @@ * @example | ||
*/ | ||
this.alert = function (opts, callBack) { | ||
this.alert = function (opts, callBack, tryCount) { | ||
if (U.isString(opts)) { | ||
@@ -285,3 +285,11 @@ opts = { | ||
if (this.activeDialog) { | ||
console.log(ax5.info.getError("ax5dialog", "501", "alert")); | ||
// try one more | ||
if (!tryCount) { | ||
console.log("111"); | ||
setTimeout(function () { | ||
this.alert(opts, callBack, 1); | ||
}.bind(this), Number(cfg.animateTime) + 100); | ||
} else { | ||
console.log(ax5.info.getError("ax5dialog", "501", "alert")); | ||
} | ||
return this; | ||
@@ -321,3 +329,3 @@ } | ||
*/ | ||
this.confirm = function (opts, callBack) { | ||
this.confirm = function (opts, callBack, tryCount) { | ||
if (U.isString(opts)) { | ||
@@ -331,3 +339,10 @@ opts = { | ||
if (this.activeDialog) { | ||
console.log(ax5.info.getError("ax5dialog", "501", "confirm")); | ||
// try one more | ||
if (!tryCount) { | ||
setTimeout(function () { | ||
this.confirm(opts, callBack, 1); | ||
}.bind(this), Number(cfg.animateTime) + 100); | ||
} else { | ||
console.log(ax5.info.getError("ax5dialog", "501", "confirm")); | ||
} | ||
return this; | ||
@@ -369,3 +384,3 @@ } | ||
*/ | ||
this.prompt = function (opts, callBack) { | ||
this.prompt = function (opts, callBack, tryCount) { | ||
if (U.isString(opts)) { | ||
@@ -379,3 +394,10 @@ opts = { | ||
if (this.activeDialog) { | ||
console.log(ax5.info.getError("ax5dialog", "501", "prompt")); | ||
// try one more | ||
if (!tryCount) { | ||
setTimeout(function () { | ||
this.prompt(opts, callBack, 1); | ||
}.bind(this), Number(cfg.animateTime) + 100); | ||
} else { | ||
console.log(ax5.info.getError("ax5dialog", "501", "prompt")); | ||
} | ||
return this; | ||
@@ -428,2 +450,3 @@ } | ||
this.activeDialog = null; | ||
that = { | ||
@@ -430,0 +453,0 @@ self: this, |
@@ -1,1 +0,1 @@ | ||
"use strict";!function(i,t){var n=ax5.util,e=function(){var e,l=this;t&&t.call(this),this.activeDialog=null,this.config={clickEventName:"click",theme:"default",width:300,title:"",msg:"",lang:{ok:"ok",cancel:"cancel"},animateTime:250},e=this.config,e.id="ax5-dialog-"+ax5.getGuid();var a=function(i,t){return i&&i.onStateChanged?i.onStateChanged.call(t,t):this.onStateChanged&&this.onStateChanged.call(t,t),t=null,!0},o=function(){return'\n <div id="{{dialogId}}" data-ax5-ui="dialog" class="ax5-ui-dialog {{theme}}">\n <div class="ax-dialog-header">\n {{{title}}}\n </div>\n <div class="ax-dialog-body">\n <div class="ax-dialog-msg">{{{msg}}}</div>\n \n {{#input}}\n <div class="ax-dialog-prompt">\n {{#@each}}\n <div class="form-group">\n {{#@value.label}}\n <label>{{#_crlf}}{{{.}}}{{/_crlf}}</label>\n {{/@value.label}}\n <input type="{{@value.type}}" placeholder="{{@value.placeholder}}" class="form-control {{@value.theme}}" data-dialog-prompt="{{@key}}" style="width:100%;" value="{{@value.value}}" />\n {{#@value.help}}\n <p class="help-block">{{#_crlf}}{{.}}{{/_crlf}}</p>\n {{/@value.help}}\n </div>\n {{/@each}}\n </div>\n {{/input}}\n \n <div class="ax-dialog-buttons">\n <div class="ax-button-wrap">\n {{#btns}}\n {{#@each}}\n <button type="button" data-dialog-btn="{{@key}}" class="btn btn-{{@value.theme}}">{{@value.label}}</button>\n {{/@each}}\n {{/btns}}\n </div>\n </div>\n </div>\n </div> \n '},s=function(i,t){var n={dialogId:i,title:t.title||e.title||"",msg:(t.msg||e.msg||"").replace(/\n/g,"<br/>"),input:t.input,btns:t.btns,_crlf:function(){return this.replace(/\n/g,"<br/>")}};try{return ax5.mustache.render(o(),n)}finally{n=null}},d=function(i,t){var n,l={};i.id=i.id||e.id,n={width:i.width},jQuery(document.body).append(s.call(this,i.id,i)),this.activeDialog=jQuery("#"+i.id),this.activeDialog.css({width:n.width}),i.height=n.height=this.activeDialog.height(),"undefined"==typeof i.position||"center"===i.position?(l.top=jQuery(window).height()/2-n.height/2,l.left=jQuery(window).width()/2-n.width/2):(l.left=i.position.left||0,l.top=i.position.top||0),this.activeDialog.css(l),"prompt"===i.dialogType?this.activeDialog.find("[data-dialog-prompt]").get(0).focus():this.activeDialog.find("[data-dialog-btn]").get(0).focus(),this.activeDialog.find("[data-dialog-btn]").on(e.clickEventName,function(n){c.call(this,n||window.event,i,t)}.bind(this)),jQuery(window).bind("keydown.ax5dialog",function(n){u.call(this,n||window.event,i,t)}.bind(this)),jQuery(window).bind("resize.ax5dialog",function(i){g.call(this,i||window.event)}.bind(this)),a.call(this,i,{self:this,state:"open"}),l=null,n=null},g=function(i){if(!this.activeDialog)return this;var t=l.dialogConfig,n={width:t.width,height:t.height};return"undefined"==typeof t.position||"center"===t.position?(n.top=window.innerHeight/2-n.height/2,n.left=window.innerWidth/2-n.width/2):(n.left=t.position.left||0,n.top=t.position.top||0),this.activeDialog.css(n),t=null,n=null,this},c=function(i,t,e,l,a){var o;if(i.srcElement&&(i.target=i.srcElement),l=n.findParentNode(i.target,function(i){return i.getAttribute("data-dialog-btn")?!0:void 0})){if(a=l.getAttribute("data-dialog-btn"),o={self:this,key:a,value:t.btns[a],dialogId:t.id,btnTarget:l},"prompt"===t.dialogType){var s=null;for(var d in t.input)if(o[d]=this.activeDialog.find("[data-dialog-prompt="+d+"]").val(),""==o[d]||null==o[d]){s=d;break}}if(t.btns[a].onClick)t.btns[a].onClick.call(o,a);else if("alert"===t.dialogType)e&&e.call(o,a),this.close();else if("confirm"===t.dialogType)e&&e.call(o,a),this.close();else if("prompt"===t.dialogType){if("ok"===a&&s)return this.activeDialog.find('[data-dialog-prompt="'+s+'"]').get(0).focus(),!1;e&&e.call(o,a),this.close()}}o=null,t=null,e=null,l=null,a=null},u=function(i,t,n,e,l){var a,o=null;if(i.keyCode==ax5.info.eventKeys.ESC&&this.close(),"prompt"===t.dialogType&&i.keyCode==ax5.info.eventKeys.RETURN){a={self:this,key:l,value:t.btns[l],dialogId:t.id,btnTarget:e};for(var s in t.input)if(a[s]=this.activeDialog.find("[data-dialog-prompt="+s+"]").val(),""==a[s]||null==a[s]){o=s;break}if(o)return a=null,o=null,!1;n&&n.call(a,l),this.close()}a=null,o=null,t=null,n=null,e=null,l=null};this.init=function(){this.onStateChanged=e.onStateChanged},this.alert=function(i,t){return n.isString(i)&&(i={title:e.title,msg:i}),this.activeDialog?(console.log(ax5.info.getError("ax5dialog","501","alert")),this):(l.dialogConfig={},jQuery.extend(!0,l.dialogConfig,e,i),i=l.dialogConfig,i.dialogType="alert","undefined"==typeof i.btns&&(i.btns={ok:{label:e.lang.ok,theme:i.theme}}),d.call(this,i,t),i=null,t=null,this)},this.confirm=function(i,t){return n.isString(i)&&(i={title:e.title,msg:i}),this.activeDialog?(console.log(ax5.info.getError("ax5dialog","501","confirm")),this):(l.dialogConfig={},jQuery.extend(!0,l.dialogConfig,e,i),i=l.dialogConfig,i.dialogType="confirm",i.theme=i.theme||e.theme||"","undefined"==typeof i.btns&&(i.btns={ok:{label:e.lang.ok,theme:i.theme},cancel:{label:e.lang.cancel}}),d.call(this,i,t),i=null,t=null,this)},this.prompt=function(i,t){return n.isString(i)&&(i={title:e.title,msg:i}),this.activeDialog?(console.log(ax5.info.getError("ax5dialog","501","prompt")),this):(l.dialogConfig={},jQuery.extend(!0,l.dialogConfig,e,i),i=l.dialogConfig,i.dialogType="prompt",i.theme=i.theme||e.theme||"","undefined"==typeof i.input&&(i.input={value:{label:""}}),"undefined"==typeof i.btns&&(i.btns={ok:{label:e.lang.ok,theme:i.theme},cancel:{label:e.lang.cancel}}),d.call(this,i,t),i=null,t=null,this)},this.close=function(i,t){return this.activeDialog&&(i=l.dialogConfig,this.activeDialog.addClass("destroy"),jQuery(window).unbind("keydown.ax5dialog"),jQuery(window).unbind("resize.ax5dialog"),setTimeout(function(){this.activeDialog.remove(),this.activeDialog=null,t={self:this,state:"close"},i&&i.onStateChanged?i.onStateChanged.call(t,t):this.onStateChanged&&this.onStateChanged.call(t,t),i=null,t=null}.bind(this),e.animateTime)),this},this.main=function(){i.dialog_instance=i.dialog_instance||[],i.dialog_instance.push(this),arguments&&n.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)};i.dialog=function(){return n.isFunction(t)&&(e.prototype=new t),e}()}(ax5.ui,ax5.ui.root); | ||
"use strict";!function(i,t){var e=ax5.util,n=function(){var n,l=this;t&&t.call(this),this.activeDialog=null,this.config={clickEventName:"click",theme:"default",width:300,title:"",msg:"",lang:{ok:"ok",cancel:"cancel"},animateTime:250},n=this.config,n.id="ax5-dialog-"+ax5.getGuid();var a=function(i,t){return i&&i.onStateChanged?i.onStateChanged.call(t,t):this.onStateChanged&&this.onStateChanged.call(t,t),t=null,!0},o=function(){return'\n <div id="{{dialogId}}" data-ax5-ui="dialog" class="ax5-ui-dialog {{theme}}">\n <div class="ax-dialog-header">\n {{{title}}}\n </div>\n <div class="ax-dialog-body">\n <div class="ax-dialog-msg">{{{msg}}}</div>\n \n {{#input}}\n <div class="ax-dialog-prompt">\n {{#@each}}\n <div class="form-group">\n {{#@value.label}}\n <label>{{#_crlf}}{{{.}}}{{/_crlf}}</label>\n {{/@value.label}}\n <input type="{{@value.type}}" placeholder="{{@value.placeholder}}" class="form-control {{@value.theme}}" data-dialog-prompt="{{@key}}" style="width:100%;" value="{{@value.value}}" />\n {{#@value.help}}\n <p class="help-block">{{#_crlf}}{{.}}{{/_crlf}}</p>\n {{/@value.help}}\n </div>\n {{/@each}}\n </div>\n {{/input}}\n \n <div class="ax-dialog-buttons">\n <div class="ax-button-wrap">\n {{#btns}}\n {{#@each}}\n <button type="button" data-dialog-btn="{{@key}}" class="btn btn-{{@value.theme}}">{{@value.label}}</button>\n {{/@each}}\n {{/btns}}\n </div>\n </div>\n </div>\n </div> \n '},s=function(i,t){var e={dialogId:i,title:t.title||n.title||"",msg:(t.msg||n.msg||"").replace(/\n/g,"<br/>"),input:t.input,btns:t.btns,_crlf:function(){return this.replace(/\n/g,"<br/>")}};try{return ax5.mustache.render(o(),e)}finally{e=null}},d=function(i,t){var e,l={};i.id=i.id||n.id,e={width:i.width},jQuery(document.body).append(s.call(this,i.id,i)),this.activeDialog=jQuery("#"+i.id),this.activeDialog.css({width:e.width}),i.height=e.height=this.activeDialog.height(),"undefined"==typeof i.position||"center"===i.position?(l.top=jQuery(window).height()/2-e.height/2,l.left=jQuery(window).width()/2-e.width/2):(l.left=i.position.left||0,l.top=i.position.top||0),this.activeDialog.css(l),"prompt"===i.dialogType?this.activeDialog.find("[data-dialog-prompt]").get(0).focus():this.activeDialog.find("[data-dialog-btn]").get(0).focus(),this.activeDialog.find("[data-dialog-btn]").on(n.clickEventName,function(e){g.call(this,e||window.event,i,t)}.bind(this)),jQuery(window).bind("keydown.ax5dialog",function(e){c.call(this,e||window.event,i,t)}.bind(this)),jQuery(window).bind("resize.ax5dialog",function(i){u.call(this,i||window.event)}.bind(this)),a.call(this,i,{self:this,state:"open"}),l=null,e=null},u=function(i){if(!this.activeDialog)return this;var t=l.dialogConfig,e={width:t.width,height:t.height};return"undefined"==typeof t.position||"center"===t.position?(e.top=window.innerHeight/2-e.height/2,e.left=window.innerWidth/2-e.width/2):(e.left=t.position.left||0,e.top=t.position.top||0),this.activeDialog.css(e),t=null,e=null,this},g=function(i,t,n,l,a){var o;if(i.srcElement&&(i.target=i.srcElement),l=e.findParentNode(i.target,function(i){return i.getAttribute("data-dialog-btn")?!0:void 0})){if(a=l.getAttribute("data-dialog-btn"),o={self:this,key:a,value:t.btns[a],dialogId:t.id,btnTarget:l},"prompt"===t.dialogType){var s=null;for(var d in t.input)if(o[d]=this.activeDialog.find("[data-dialog-prompt="+d+"]").val(),""==o[d]||null==o[d]){s=d;break}}if(t.btns[a].onClick)t.btns[a].onClick.call(o,a);else if("alert"===t.dialogType)n&&n.call(o,a),this.close();else if("confirm"===t.dialogType)n&&n.call(o,a),this.close();else if("prompt"===t.dialogType){if("ok"===a&&s)return this.activeDialog.find('[data-dialog-prompt="'+s+'"]').get(0).focus(),!1;n&&n.call(o,a),this.close()}}o=null,t=null,n=null,l=null,a=null},c=function(i,t,e,n,l){var a,o=null;if(i.keyCode==ax5.info.eventKeys.ESC&&this.close(),"prompt"===t.dialogType&&i.keyCode==ax5.info.eventKeys.RETURN){a={self:this,key:l,value:t.btns[l],dialogId:t.id,btnTarget:n};for(var s in t.input)if(a[s]=this.activeDialog.find("[data-dialog-prompt="+s+"]").val(),""==a[s]||null==a[s]){o=s;break}if(o)return a=null,o=null,!1;e&&e.call(a,l),this.close()}a=null,o=null,t=null,e=null,n=null,l=null};this.init=function(){this.onStateChanged=n.onStateChanged},this.alert=function(i,t,a){return e.isString(i)&&(i={title:n.title,msg:i}),this.activeDialog?(a?console.log(ax5.info.getError("ax5dialog","501","alert")):(console.log("111"),setTimeout(function(){this.alert(i,t,1)}.bind(this),Number(n.animateTime)+100)),this):(l.dialogConfig={},jQuery.extend(!0,l.dialogConfig,n,i),i=l.dialogConfig,i.dialogType="alert","undefined"==typeof i.btns&&(i.btns={ok:{label:n.lang.ok,theme:i.theme}}),d.call(this,i,t),i=null,t=null,this)},this.confirm=function(i,t,a){return e.isString(i)&&(i={title:n.title,msg:i}),this.activeDialog?(a?console.log(ax5.info.getError("ax5dialog","501","confirm")):setTimeout(function(){this.confirm(i,t,1)}.bind(this),Number(n.animateTime)+100),this):(l.dialogConfig={},jQuery.extend(!0,l.dialogConfig,n,i),i=l.dialogConfig,i.dialogType="confirm",i.theme=i.theme||n.theme||"","undefined"==typeof i.btns&&(i.btns={ok:{label:n.lang.ok,theme:i.theme},cancel:{label:n.lang.cancel}}),d.call(this,i,t),i=null,t=null,this)},this.prompt=function(i,t,a){return e.isString(i)&&(i={title:n.title,msg:i}),this.activeDialog?(a?console.log(ax5.info.getError("ax5dialog","501","prompt")):setTimeout(function(){this.prompt(i,t,1)}.bind(this),Number(n.animateTime)+100),this):(l.dialogConfig={},jQuery.extend(!0,l.dialogConfig,n,i),i=l.dialogConfig,i.dialogType="prompt",i.theme=i.theme||n.theme||"","undefined"==typeof i.input&&(i.input={value:{label:""}}),"undefined"==typeof i.btns&&(i.btns={ok:{label:n.lang.ok,theme:i.theme},cancel:{label:n.lang.cancel}}),d.call(this,i,t),i=null,t=null,this)},this.close=function(i,t){return this.activeDialog&&(i=l.dialogConfig,this.activeDialog.addClass("destroy"),jQuery(window).unbind("keydown.ax5dialog"),jQuery(window).unbind("resize.ax5dialog"),setTimeout(function(){this.activeDialog.remove(),this.activeDialog=null,t={self:this,state:"close"},i&&i.onStateChanged?i.onStateChanged.call(t,t):this.onStateChanged&&this.onStateChanged.call(t,t),i=null,t=null}.bind(this),n.animateTime)),this},this.main=function(){i.dialog_instance=i.dialog_instance||[],i.dialog_instance.push(this),arguments&&e.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)};i.dialog=function(){return e.isFunction(t)&&(n.prototype=new t),n}()}(ax5.ui,ax5.ui.root); |
{ | ||
"name": "ax5ui-dialog", | ||
"version": "0.6.9", | ||
"version": "0.7.0", | ||
"description": "A dialog plugin that works with Bootstrap & jQuery", | ||
@@ -5,0 +5,0 @@ "license": "LGPLv3", |
@@ -7,3 +7,3 @@ // ax5.ui.dialog | ||
* @classdesc | ||
* @version 0.6.9 | ||
* @version 0.7.0 | ||
* @author tom@axisj.com | ||
@@ -275,3 +275,3 @@ * @example | ||
} | ||
if (emptyKey){ | ||
if (emptyKey) { | ||
that = null; | ||
@@ -325,3 +325,3 @@ emptyKey = null; | ||
*/ | ||
this.alert = function (opts, callBack) { | ||
this.alert = function (opts, callBack, tryCount) { | ||
if (U.isString(opts)) { | ||
@@ -335,3 +335,11 @@ opts = { | ||
if (this.activeDialog) { | ||
console.log(ax5.info.getError("ax5dialog", "501", "alert")); | ||
// try one more | ||
if (!tryCount) { | ||
console.log("111"); | ||
setTimeout((function () { | ||
this.alert(opts, callBack, 1); | ||
}).bind(this), Number(cfg.animateTime) + 100); | ||
} else { | ||
console.log(ax5.info.getError("ax5dialog", "501", "alert")); | ||
} | ||
return this; | ||
@@ -371,3 +379,3 @@ } | ||
*/ | ||
this.confirm = function (opts, callBack) { | ||
this.confirm = function (opts, callBack, tryCount) { | ||
if (U.isString(opts)) { | ||
@@ -381,3 +389,10 @@ opts = { | ||
if (this.activeDialog) { | ||
console.log(ax5.info.getError("ax5dialog", "501", "confirm")); | ||
// try one more | ||
if (!tryCount) { | ||
setTimeout((function () { | ||
this.confirm(opts, callBack, 1); | ||
}).bind(this), Number(cfg.animateTime) + 100); | ||
} else { | ||
console.log(ax5.info.getError("ax5dialog", "501", "confirm")); | ||
} | ||
return this; | ||
@@ -419,3 +434,3 @@ } | ||
*/ | ||
this.prompt = function (opts, callBack) { | ||
this.prompt = function (opts, callBack, tryCount) { | ||
if (U.isString(opts)) { | ||
@@ -429,3 +444,10 @@ opts = { | ||
if (this.activeDialog) { | ||
console.log(ax5.info.getError("ax5dialog", "501", "prompt")); | ||
// try one more | ||
if (!tryCount) { | ||
setTimeout((function () { | ||
this.prompt(opts, callBack, 1); | ||
}).bind(this), Number(cfg.animateTime) + 100); | ||
} else { | ||
console.log(ax5.info.getError("ax5dialog", "501", "prompt")); | ||
} | ||
return this; | ||
@@ -478,2 +500,3 @@ } | ||
this.activeDialog = null; | ||
that = { | ||
@@ -480,0 +503,0 @@ self: this, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66893
948