ax5ui-dialog
Advanced tools
Comparing version 0.6.8 to 0.6.9
{ | ||
"name": "ax5ui-dialog", | ||
"version": "0.6.8", | ||
"version": "0.6.9", | ||
"authors": [ | ||
@@ -5,0 +5,0 @@ "ThomasJ <tom@axisj.com>" |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @classdesc | ||
* @version 0.6.7 | ||
* @version 0.6.9 | ||
* @author tom@axisj.com | ||
@@ -441,2 +441,6 @@ * @example | ||
this.main = function () { | ||
root.dialog_instance = root.dialog_instance || []; | ||
root.dialog_instance.push(this); | ||
if (arguments && U.isObject(arguments[0])) { | ||
@@ -443,0 +447,0 @@ this.setConfig(arguments[0]); |
@@ -1,1 +0,1 @@ | ||
"use strict";!function(t,i){var e=ax5.util,n=function(){var t,n=this;i&&i.call(this),this.activeDialog=null,this.config={clickEventName:"click",theme:"default",width:300,title:"",msg:"",lang:{ok:"ok",cancel:"cancel"},animateTime:250},t=this.config,t.id="ax5-dialog-"+ax5.getGuid();var l=function(t,i){return t&&t.onStateChanged?t.onStateChanged.call(i,i):this.onStateChanged&&this.onStateChanged.call(i,i),i=null,!0},a=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 '},o=function(i,e){var n={dialogId:i,title:e.title||t.title||"",msg:(e.msg||t.msg||"").replace(/\n/g,"<br/>"),input:e.input,btns:e.btns,_crlf:function(){return this.replace(/\n/g,"<br/>")}};try{return ax5.mustache.render(a(),n)}finally{n=null}},s=function(i,e){var n,a={};i.id=i.id||t.id,n={width:i.width},jQuery(document.body).append(o.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?(a.top=jQuery(window).height()/2-n.height/2,a.left=jQuery(window).width()/2-n.width/2):(a.left=i.position.left||0,a.top=i.position.top||0),this.activeDialog.css(a),"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(t.clickEventName,function(t){g.call(this,t||window.event,i,e)}.bind(this)),jQuery(window).bind("keydown.ax5dialog",function(t){u.call(this,t||window.event,i,e)}.bind(this)),jQuery(window).bind("resize.ax5dialog",function(t){d.call(this,t||window.event)}.bind(this)),l.call(this,i,{self:this,state:"open"}),a=null,n=null},d=function(t){if(!this.activeDialog)return this;var i=n.dialogConfig,e={width:i.width,height:i.height};return"undefined"==typeof i.position||"center"===i.position?(e.top=window.innerHeight/2-e.height/2,e.left=window.innerWidth/2-e.width/2):(e.left=i.position.left||0,e.top=i.position.top||0),this.activeDialog.css(e),i=null,e=null,this},g=function(t,i,n,l,a){var o;if(t.srcElement&&(t.target=t.srcElement),l=e.findParentNode(t.target,function(t){return t.getAttribute("data-dialog-btn")?!0:void 0})){if(a=l.getAttribute("data-dialog-btn"),o={self:this,key:a,value:i.btns[a],dialogId:i.id,btnTarget:l},"prompt"===i.dialogType){var s=null;for(var d in i.input)if(o[d]=this.activeDialog.find("[data-dialog-prompt="+d+"]").val(),""==o[d]||null==o[d]){s=d;break}}if(i.btns[a].onClick)i.btns[a].onClick.call(o,a);else if("alert"===i.dialogType)n&&n.call(o,a),this.close();else if("confirm"===i.dialogType)n&&n.call(o,a),this.close();else if("prompt"===i.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,i=null,n=null,l=null,a=null},u=function(t,i,e,n,l){var a,o=null;if(t.keyCode==ax5.info.eventKeys.ESC&&this.close(),"prompt"===i.dialogType&&t.keyCode==ax5.info.eventKeys.RETURN){a={self:this,key:l,value:i.btns[l],dialogId:i.id,btnTarget:n};for(var s in i.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,i=null,e=null,n=null,l=null};this.init=function(){this.onStateChanged=t.onStateChanged},this.alert=function(i,l){return e.isString(i)&&(i={title:t.title,msg:i}),this.activeDialog?(console.log(ax5.info.getError("ax5dialog","501","alert")),this):(n.dialogConfig={},jQuery.extend(!0,n.dialogConfig,t,i),i=n.dialogConfig,i.dialogType="alert","undefined"==typeof i.btns&&(i.btns={ok:{label:t.lang.ok,theme:i.theme}}),s.call(this,i,l),i=null,l=null,this)},this.confirm=function(i,l){return e.isString(i)&&(i={title:t.title,msg:i}),this.activeDialog?(console.log(ax5.info.getError("ax5dialog","501","confirm")),this):(n.dialogConfig={},jQuery.extend(!0,n.dialogConfig,t,i),i=n.dialogConfig,i.dialogType="confirm",i.theme=i.theme||t.theme||"","undefined"==typeof i.btns&&(i.btns={ok:{label:t.lang.ok,theme:i.theme},cancel:{label:t.lang.cancel}}),s.call(this,i,l),i=null,l=null,this)},this.prompt=function(i,l){return e.isString(i)&&(i={title:t.title,msg:i}),this.activeDialog?(console.log(ax5.info.getError("ax5dialog","501","prompt")),this):(n.dialogConfig={},jQuery.extend(!0,n.dialogConfig,t,i),i=n.dialogConfig,i.dialogType="prompt",i.theme=i.theme||t.theme||"","undefined"==typeof i.input&&(i.input={value:{label:""}}),"undefined"==typeof i.btns&&(i.btns={ok:{label:t.lang.ok,theme:i.theme},cancel:{label:t.lang.cancel}}),s.call(this,i,l),i=null,l=null,this)},this.close=function(i,e){return this.activeDialog&&(i=n.dialogConfig,this.activeDialog.addClass("destroy"),jQuery(window).unbind("keydown.ax5dialog"),jQuery(window).unbind("resize.ax5dialog"),setTimeout(function(){this.activeDialog.remove(),this.activeDialog=null,e={self:this,state:"close"},i&&i.onStateChanged?i.onStateChanged.call(e,e):this.onStateChanged&&this.onStateChanged.call(e,e),i=null,e=null}.bind(this),t.animateTime)),this},this.main=function(){arguments&&e.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)};t.dialog=function(){return e.isFunction(i)&&(n.prototype=new i),n}()}(ax5.ui,ax5.ui.root); | ||
"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); |
{ | ||
"name": "ax5ui-dialog", | ||
"version": "0.6.8", | ||
"version": "0.6.9", | ||
"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.7 | ||
* @version 0.6.9 | ||
* @author tom@axisj.com | ||
@@ -491,2 +491,6 @@ * @example | ||
this.main = (function () { | ||
root.dialog_instance = root.dialog_instance || []; | ||
root.dialog_instance.push(this); | ||
if (arguments && U.isObject(arguments[0])) { | ||
@@ -493,0 +497,0 @@ this.setConfig(arguments[0]); |
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
64551
904