ax5ui-dialog
Advanced tools
Comparing version 0.6.7 to 0.6.8
{ | ||
"name": "ax5ui-dialog", | ||
"version": "0.6.7", | ||
"version": "0.6.8", | ||
"authors": [ | ||
@@ -5,0 +5,0 @@ "ThomasJ <tom@axisj.com>" |
@@ -41,122 +41,173 @@ 'use strict'; | ||
var onStateChanged = function onStateChanged(opts, that) { | ||
if (opts && opts.onStateChanged) { | ||
opts.onStateChanged.call(that, that); | ||
} else if (this.onStateChanged) { | ||
this.onStateChanged.call(that, that); | ||
} | ||
if (opts && opts.onStateChanged) { | ||
opts.onStateChanged.call(that, that); | ||
} else if (this.onStateChanged) { | ||
this.onStateChanged.call(that, that); | ||
} | ||
that = null; | ||
return true; | ||
}, | ||
that = null; | ||
return true; | ||
}, | ||
getContentTmpl = function getContentTmpl() { | ||
return '\n <div id="{{dialogId}}" data-ax5-ui="dialog" class="ax5-ui-dialog {{theme}}">\n <div class="ax-dialog-heading">\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 '; | ||
}, | ||
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 '; | ||
}, | ||
getContent = function getContent(dialogId, opts) { | ||
var data = { | ||
dialogId: dialogId, | ||
title: opts.title || cfg.title || "", | ||
msg: (opts.msg || cfg.msg || "").replace(/\n/g, "<br/>"), | ||
input: opts.input, | ||
btns: opts.btns, | ||
'_crlf': function _crlf() { | ||
return this.replace(/\n/g, "<br/>"); | ||
} | ||
}; | ||
var data = { | ||
dialogId: dialogId, | ||
title: opts.title || cfg.title || "", | ||
msg: (opts.msg || cfg.msg || "").replace(/\n/g, "<br/>"), | ||
input: opts.input, | ||
btns: opts.btns, | ||
'_crlf': function _crlf() { | ||
return this.replace(/\n/g, "<br/>"); | ||
} | ||
}; | ||
try { | ||
return ax5.mustache.render(getContentTmpl(), data); | ||
} finally { | ||
data = null; | ||
} | ||
}, | ||
try { | ||
return ax5.mustache.render(getContentTmpl(), data); | ||
} finally { | ||
data = null; | ||
} | ||
}, | ||
open = function open(opts, callBack) { | ||
var pos = {}, | ||
box; | ||
var pos = {}, | ||
box; | ||
opts.id = opts.id || cfg.id; | ||
opts.id = opts.id || cfg.id; | ||
box = { | ||
width: opts.width | ||
}; | ||
jQuery(document.body).append(getContent.call(this, opts.id, opts)); | ||
box = { | ||
width: opts.width | ||
}; | ||
jQuery(document.body).append(getContent.call(this, opts.id, opts)); | ||
this.activeDialog = jQuery('#' + opts.id); | ||
this.activeDialog.css({width: box.width}); | ||
this.activeDialog = jQuery('#' + opts.id); | ||
this.activeDialog.css({ width: box.width }); | ||
// dialog 높이 구하기 - 너비가 정해지면 높이가 변경 될 것. | ||
opts.height = box.height = this.activeDialog.height(); | ||
// dialog 높이 구하기 - 너비가 정해지면 높이가 변경 될 것. | ||
opts.height = box.height = this.activeDialog.height(); | ||
//- position 정렬 | ||
if (typeof opts.position === "undefined" || opts.position === "center") { | ||
pos.top = jQuery(window).height() / 2 - box.height / 2; | ||
pos.left = jQuery(window).width() / 2 - box.width / 2; | ||
} else { | ||
pos.left = opts.position.left || 0; | ||
pos.top = opts.position.top || 0; | ||
} | ||
this.activeDialog.css(pos); | ||
//- position 정렬 | ||
if (typeof opts.position === "undefined" || opts.position === "center") { | ||
pos.top = jQuery(window).height() / 2 - box.height / 2; | ||
pos.left = jQuery(window).width() / 2 - box.width / 2; | ||
} else { | ||
pos.left = opts.position.left || 0; | ||
pos.top = opts.position.top || 0; | ||
} | ||
this.activeDialog.css(pos); | ||
// bind button event | ||
if (opts.dialogType === "prompt") { | ||
this.activeDialog.find("[data-dialog-prompt]").get(0).focus(); | ||
} else { | ||
this.activeDialog.find("[data-dialog-btn]").get(0).focus(); | ||
} | ||
// bind button event | ||
if (opts.dialogType === "prompt") { | ||
this.activeDialog.find("[data-dialog-prompt]").get(0).focus(); | ||
} else { | ||
this.activeDialog.find("[data-dialog-btn]").get(0).focus(); | ||
} | ||
this.activeDialog.find("[data-dialog-btn]").on(cfg.clickEventName, function (e) { | ||
btnOnClick.call(this, e || window.event, opts, callBack); | ||
}.bind(this)); | ||
this.activeDialog.find("[data-dialog-btn]").on(cfg.clickEventName, function (e) { | ||
btnOnClick.call(this, e || window.event, opts, callBack); | ||
}.bind(this)); | ||
// bind key event | ||
jQuery(window).bind("keydown.ax5dialog", function (e) { | ||
onKeyup.call(this, e || window.event, opts, callBack); | ||
}.bind(this)); | ||
// bind key event | ||
jQuery(window).bind("keydown.ax5dialog", function (e) { | ||
onKeyup.call(this, e || window.event, opts, callBack); | ||
}.bind(this)); | ||
jQuery(window).bind("resize.ax5dialog", function (e) { | ||
align.call(this, e || window.event); | ||
}.bind(this)); | ||
jQuery(window).bind("resize.ax5dialog", function (e) { | ||
align.call(this, e || window.event); | ||
}.bind(this)); | ||
onStateChanged.call(this, opts, { | ||
self: this, | ||
state: "open" | ||
}); | ||
onStateChanged.call(this, opts, { | ||
self: this, | ||
state: "open" | ||
}); | ||
pos = null; | ||
box = null; | ||
}, | ||
pos = null; | ||
box = null; | ||
}, | ||
align = function align(e) { | ||
if (!this.activeDialog) return this; | ||
var opts = self.dialogConfig, | ||
box = { | ||
width: opts.width, | ||
height: opts.height | ||
}; | ||
//- position 정렬 | ||
if (typeof opts.position === "undefined" || opts.position === "center") { | ||
box.top = window.innerHeight / 2 - box.height / 2; | ||
box.left = window.innerWidth / 2 - box.width / 2; | ||
} else { | ||
box.left = opts.position.left || 0; | ||
box.top = opts.position.top || 0; | ||
} | ||
this.activeDialog.css(box); | ||
if (!this.activeDialog) return this; | ||
var opts = self.dialogConfig, | ||
box = { | ||
width: opts.width, | ||
height: opts.height | ||
}; | ||
//- position 정렬 | ||
if (typeof opts.position === "undefined" || opts.position === "center") { | ||
box.top = window.innerHeight / 2 - box.height / 2; | ||
box.left = window.innerWidth / 2 - box.width / 2; | ||
} else { | ||
box.left = opts.position.left || 0; | ||
box.top = opts.position.top || 0; | ||
} | ||
this.activeDialog.css(box); | ||
opts = null; | ||
box = null; | ||
opts = null; | ||
box = null; | ||
return this; | ||
}, | ||
return this; | ||
}, | ||
btnOnClick = function btnOnClick(e, opts, callBack, target, k) { | ||
var that; | ||
if (e.srcElement) e.target = e.srcElement; | ||
var that; | ||
if (e.srcElement) e.target = e.srcElement; | ||
target = U.findParentNode(e.target, function (target) { | ||
if (target.getAttribute("data-dialog-btn")) { | ||
return true; | ||
target = U.findParentNode(e.target, function (target) { | ||
if (target.getAttribute("data-dialog-btn")) { | ||
return true; | ||
} | ||
}); | ||
if (target) { | ||
k = target.getAttribute("data-dialog-btn"); | ||
that = { | ||
self: this, | ||
key: k, value: opts.btns[k], | ||
dialogId: opts.id, | ||
btnTarget: target | ||
}; | ||
if (opts.dialogType === "prompt") { | ||
var emptyKey = null; | ||
for (var oi in opts.input) { | ||
that[oi] = this.activeDialog.find('[data-dialog-prompt=' + oi + ']').val(); | ||
if (that[oi] == "" || that[oi] == null) { | ||
emptyKey = oi; | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
if (opts.btns[k].onClick) { | ||
opts.btns[k].onClick.call(that, k); | ||
} else if (opts.dialogType === "alert") { | ||
if (callBack) callBack.call(that, k); | ||
this.close(); | ||
} else if (opts.dialogType === "confirm") { | ||
if (callBack) callBack.call(that, k); | ||
this.close(); | ||
} else if (opts.dialogType === "prompt") { | ||
if (k === 'ok') { | ||
if (emptyKey) { | ||
this.activeDialog.find('[data-dialog-prompt="' + emptyKey + '"]').get(0).focus(); | ||
return false; | ||
} | ||
} | ||
if (callBack) callBack.call(that, k); | ||
this.close(); | ||
} | ||
} | ||
if (target) { | ||
k = target.getAttribute("data-dialog-btn"); | ||
that = null; | ||
opts = null; | ||
callBack = null; | ||
target = null; | ||
k = null; | ||
}, | ||
onKeyup = function onKeyup(e, opts, callBack, target, k) { | ||
var that, | ||
emptyKey = null; | ||
if (e.keyCode == ax5.info.eventKeys.ESC) { | ||
this.close(); | ||
} | ||
if (opts.dialogType === "prompt") { | ||
if (e.keyCode == ax5.info.eventKeys.RETURN) { | ||
that = { | ||
@@ -168,79 +219,28 @@ self: this, | ||
}; | ||
if (opts.dialogType === "prompt") { | ||
var emptyKey = null; | ||
for (var oi in opts.input) { | ||
that[oi] = this.activeDialog.find('[data-dialog-prompt=' + oi + ']').val(); | ||
if (that[oi] == "" || that[oi] == null) { | ||
emptyKey = oi; | ||
break; | ||
} | ||
for (var oi in opts.input) { | ||
that[oi] = this.activeDialog.find('[data-dialog-prompt=' + oi + ']').val(); | ||
if (that[oi] == "" || that[oi] == null) { | ||
emptyKey = oi; | ||
break; | ||
} | ||
} | ||
if (opts.btns[k].onClick) { | ||
opts.btns[k].onClick.call(that, k); | ||
} else if (opts.dialogType === "alert") { | ||
if (callBack) callBack.call(that, k); | ||
this.close(); | ||
} else if (opts.dialogType === "confirm") { | ||
if (callBack) callBack.call(that, k); | ||
this.close(); | ||
} else if (opts.dialogType === "prompt") { | ||
if (k === 'ok') { | ||
if (emptyKey) { | ||
this.activeDialog.find('[data-dialog-prompt="' + emptyKey + '"]').get(0).focus(); | ||
return false; | ||
} | ||
} | ||
if (callBack) callBack.call(that, k); | ||
this.close(); | ||
if (emptyKey) { | ||
that = null; | ||
emptyKey = null; | ||
return false; | ||
} | ||
} | ||
that = null; | ||
opts = null; | ||
callBack = null; | ||
target = null; | ||
k = null; | ||
}, | ||
onKeyup = function onKeyup(e, opts, callBack, target, k) { | ||
var that, | ||
emptyKey = null; | ||
if (e.keyCode == ax5.info.eventKeys.ESC) { | ||
if (callBack) callBack.call(that, k); | ||
this.close(); | ||
} | ||
if (opts.dialogType === "prompt") { | ||
if (e.keyCode == ax5.info.eventKeys.RETURN) { | ||
that = { | ||
self: this, | ||
key: k, value: opts.btns[k], | ||
dialogId: opts.id, | ||
btnTarget: target | ||
}; | ||
} | ||
for (var oi in opts.input) { | ||
that[oi] = this.activeDialog.find('[data-dialog-prompt=' + oi + ']').val(); | ||
if (that[oi] == "" || that[oi] == null) { | ||
emptyKey = oi; | ||
break; | ||
} | ||
} | ||
if (emptyKey) { | ||
that = null; | ||
emptyKey = null; | ||
return false; | ||
} | ||
if (callBack) callBack.call(that, k); | ||
this.close(); | ||
} | ||
} | ||
that = null; | ||
emptyKey = null; | ||
opts = null; | ||
callBack = null; | ||
target = null; | ||
k = null; | ||
}; | ||
that = null; | ||
emptyKey = null; | ||
opts = null; | ||
callBack = null; | ||
target = null; | ||
k = null; | ||
}; | ||
/** | ||
@@ -296,3 +296,3 @@ * Preferences of dialog UI | ||
opts.btns = { | ||
ok: {label: cfg.lang["ok"], theme: opts.theme} | ||
ok: { label: cfg.lang["ok"], theme: opts.theme } | ||
}; | ||
@@ -342,4 +342,4 @@ } | ||
opts.btns = { | ||
ok: {label: cfg.lang["ok"], theme: opts.theme}, | ||
cancel: {label: cfg.lang["cancel"]} | ||
ok: { label: cfg.lang["ok"], theme: opts.theme }, | ||
cancel: { label: cfg.lang["cancel"] } | ||
}; | ||
@@ -390,3 +390,3 @@ } | ||
opts.input = { | ||
value: {label: ""} | ||
value: { label: "" } | ||
}; | ||
@@ -396,4 +396,4 @@ } | ||
opts.btns = { | ||
ok: {label: cfg.lang["ok"], theme: opts.theme}, | ||
cancel: {label: cfg.lang["cancel"]} | ||
ok: { label: cfg.lang["ok"], theme: opts.theme }, | ||
cancel: { label: cfg.lang["cancel"] } | ||
}; | ||
@@ -400,0 +400,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-heading">\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(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); |
{ | ||
"name": "ax5ui-dialog", | ||
"version": "0.6.7", | ||
"version": "0.6.8", | ||
"description": "A dialog plugin that works with Bootstrap & jQuery", | ||
@@ -5,0 +5,0 @@ "license": "LGPLv3", |
@@ -23,2 +23,15 @@ [![axisj-contributed](https://img.shields.io/badge/AXISJ.com-Contributed-green.svg)](https://github.com/axisj) | ||
### Install by npm | ||
If you do not use the bower, it can be downloaded by using the npm as second best. | ||
In npm, so pile on the package manager for the front end, you need to solve the problem of plug-in dependencies. | ||
```sh | ||
npm install jquery | ||
npm install ax5core | ||
npm install ax5ui-dialog | ||
``` | ||
After you download the file in npm install, you will need to copy to the location where you want to use as a resource for the project. | ||
If the inconvenience in the process that you want to copy the file and can be easily copied by using a `gulp` or `grunt`. | ||
### Download code | ||
@@ -34,18 +47,10 @@ - [ax5core Github releases](https://github.com/ax5ui/ax5core/releases) | ||
```html | ||
<html> | ||
<head> | ||
<link rel="stylesheet" type="text/css" href="bower_components/ax5ui-dialog/dist/ax5dialog.css" /> | ||
<script type="text/javascript" src="bower_components/jquery/dist/jquery.min.js"></script> | ||
<script type="text/javascript" src="bower_components/ax5core/dist/ax5core.min.js"></script> | ||
<script type="text/javascript" src="bower_components/ax5ui-dialog/dist/ax5dialog.min.js"></script> | ||
</head> | ||
<body> | ||
.... | ||
</body> | ||
</html> | ||
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/ax5ui/ax5ui-dialog/master/dist/ax5dialog.css" /> | ||
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.3.min.js"></script> | ||
<script type="text/javascript" src="https://cdn.rawgit.com/ax5ui/ax5core/master/dist/ax5core.min.js"></script> | ||
<script type="text/javascript" src="https://cdn.rawgit.com/ax5ui/ax5ui-dialog/master/dist/ax5dialog.min.js"></script> | ||
``` | ||
### USE CDN | ||
**CDN urls** | ||
It is CDN url of ax5ui-select. ax5ui offers the CDN services through the rawgit. | ||
``` | ||
@@ -76,18 +81,4 @@ https://cdn.rawgit.com/ax5ui/ax5ui-dialog/master/dist/ax5dialog.css | ||
*** | ||
* * * | ||
### Install by npm | ||
If you do not use the bower, it can be downloaded by using the npm as second best. | ||
In npm, so pile on the package manager for the front end, you need to solve the problem of plug-in dependencies. | ||
```sh | ||
npm install jquery | ||
npm install ax5core | ||
npm install ax5ui-dialog | ||
``` | ||
After you download the file in npm install, you will need to copy to the location where you want to use as a resource for the project. | ||
If the inconvenience in the process that you want to copy the file and can be easily copied by using a `gulp` or `grunt`. | ||
*** | ||
### Preview | ||
@@ -94,0 +85,0 @@ - [See Demostration](http://ax5.io/ax5ui-dialog/demo/index.html) |
@@ -54,3 +54,3 @@ // ax5.ui.dialog | ||
<div id="{{dialogId}}" data-ax5-ui="dialog" class="ax5-ui-dialog {{theme}}"> | ||
<div class="ax-dialog-heading"> | ||
<div class="ax-dialog-header"> | ||
{{{title}}} | ||
@@ -57,0 +57,0 @@ </div> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
64261
84