mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-29 03:35:25 +08:00
6 lines
59 KiB
JavaScript
6 lines
59 KiB
JavaScript
/* Licensed under the MIT license
|
||
* jQuery.my 1.2.14, (c) 2017 ermouth
|
||
* Requires jQuery 2.0+, SugarJS 1.3.9-1.4.x
|
||
* More details at jquerymy.com */
|
||
!function(a){function b(){window.console&&console.error.apply(console,arguments)}function c(){window.console&&console.log.apply(console,arguments)}function d(a,b){return"hasOwnProperty"!=b?a.hasOwnProperty(b):!!("hasOwnProperty"in a)}function e(b){return a.contains(document.documentElement,b[0])}function f(a,b){return Array.prototype.slice.call(a,b||0)}function g(a,b,c){var d=0,e=a.length,f=!0;if(a===b)return"===";if("==="==c)return"";if(e!=b.length)return"";for(;e>d&&f;d++)f=a[d]===b[d];if(f)return"==";if("=="==c)return"";for(f=!0;e>d&&f;d++)f=Object.equal(a[d],b[d]);return f?"=":""}function h(a,b){return(ib(b)?b.split("."):gb(b)?b:[""]).reduce(function(a,b){if(null!=a){if(/=/.test(b)){var c=b.split("=",2);return jb(a)?Object.values(a).find(function(a){return jb(a)||gb(a)?a[c[0]]==c[1]:!1}):gb(a)?a.find(function(a){return jb(a)||gb(a)?a[c[0]]==c[1]:!1}):void 0}if(null!=a&&null!=a[b])return a[b]}return void 0},a)}function i(a){var b=a.my();return b?b.root?b.root.my():b:null}function j(a){var b,c={},d=function(){return null};if(ib(a))a.split(/[,\s]+/).compact(!0).unique().map(function(a){c[a]=d});else if(gb(a))a.compact(!0).unique().map(function(a){c[a]=d});else if(jb(a))for(b in a)c[b]=mb(a[b])?a[b]:function(){return a[b]};return c}function k(a){var b,c=a,d={};if(ib(c)&&(c=c.split(/[,\s]+/)),gb(c)){for(c=c.compact(!0),b=0;b<c.length;b++)d[c[b]]=!0;return d}return jb(c)?a:null}function l(a){for(var b=JSON.stringify(a),c=0,d=0;d<b.length;d++)c=b.charCodeAt(d)+(c<<6)+(c<<16)-c;return(1e11+c).toString(36)}function m(a,b){for(var c in b)d(b,c)&&(jb(b[c])?d(a,c)?m(a[c],b[c]):a[c]=rb(b[c],!0):d(a,c)||(a[c]=gb(b[c])?b[c].clone(!0):b[c]));return a}function n(a,b){function c(a,b,d){return void 0===d||null===d?b:jb(d)?qb(b,d,!1,c):d}return a?b?qb(a,b,!1,c):a:{}}function o(a,b){return sb(a).forEach(function(b){delete a[b]}),"object"==typeof b&&qb(a,b,!0),a}function p(b,c,d){return/^[#\.][a-z0-9_\-]{1,31}$/i.test(c)?a(d?b[0].querySelectorAll(c):b[0].querySelector(c)):d||/:/.test(c)||/^[a-z]{1,31}[\[\.\#][a-z]/i.test(c)?b.find(c):b.find(c).eq(0)}function q(a,b){var c,d;return ib(a)?(c=a,d=h(jb(b)?b:ob,c),"exist"===b?jb(d):d?rb(d,!0):null):jb(a)?(d=s(a,b),jb(d)?d:null):void 0===a?ob._src:null===a?Object.reject(ob,/^_/):null}function r(a,b){var c,d;if(jb(b))return b;if(ib(b)){if(c=h(a,b),null==c&&(c=rb(ob._src[b],!0)),null==c&&(c=h(ob,b),jb(c)&&jb(c._self)?c=rb(c._self,!0):jb(c)&&(c=rb(c,!0))),null==c&&h(a,"params.cache")&&(d=h(a,"params.cache"),mb(d)?c=d(b):jb(d)&&(c=zb(b,d)),jb(c)&&(jb(c._self)&&(c=rb(c._self,!0)),qb(c,{params:{cache:d}},!0))),null!=c&&jb(c))return d=d||h(a,"params.cache"),d&&qb(c,{params:{cache:d}},!0),c;throw"Component "+b+" not found."}return mb(b)?b.apply(a,f(arguments,2)):null}function s(c,e){var f,g,i,j,k,l=e||ob,m=c;if(!(jb(l)&&jb(m)&&jb(m.ui)&&ib(m.id)))return"Can’t save manifest into cache, invalid arguments.";d(l,"_src")||(l._src={}),i=m.id;try{m=rb(c,!0)}catch(n){return"Can’t save circular-referencing object into cache."}try{(!m.params||m.params&&!m.params.strict)&&P(m,!0)}catch(n){return"Invalid manifest, parse error."}if(f=t(m),ib(f))return b(f),f;if(qb(m,{params:{strict:!0}},!0),l._src[i]=m,j=D(l,i)){if(j.params&&j.params.protect)return"Can’t save manifest into cache over protected one.";j._self&&delete j._self,a.extend(!0,l,E("",i))}return a.extend(!0,l,E(m,i)),g=Object.keys(l._src).filter(function(a){return a.startsWith(i+".")}),g.sort(),g.forEach(function(b){var c;(c=D(l,b))&&(c._self&&delete c._self,a.extend(!0,l,E("",b))),a.extend(!0,l,E(l._src[b],b))}),k=h(l,i),X?k._self=l._src[i]:Object.defineProperty(k,"_self",{get:function(){return l._src[i]},set:function(){throw"Can’t change manifest cache entry directly."},enumerable:!1,configurable:!0}),k}function t(a){var b,c,d=[];if(jb(a.files)&&Object.size(a.files))for(b in a.files){if(c=a.files[b],!jb(c))return"Non-object member "+b+" in files section.";if(ib(c.data)&&!c.url)if(W)try{Db.base642blob(c.data,function(a){c.blob=a,c.url=W.createObjectURL(c.blob)},c.content_type||c.mime),d.push(b)}catch(e){return"Invalid base64 data in files/"+b+"."}else c.url="data:"+(c.content_type||c.mime)+";base64,"+c.data,d.push(b)}return d}function u(a,b,c,d){var e,f=[],g=c.bind,h=vb(g);return h==db?g.call(i(d).manifest,a,b,d):h===cb||h===bb?h!==cb||/\./.test(g)?(f=h===cb?g.split("."):g,"this"===f[0]?(e=i(d).manifest,f.shift()):e=a,F(e,b,f,!0)):(b!=wb?a[g]=b:void 0===a[g]&&(a[g]=wb),a[g]):wb}function v(d,e,f,g){function i(){var b=null,c=y.manifest;if(mb(c)||jb(c)&&jb(c.ui)?t=c:ib(c)&&(t=r(B,c.replace(fb,""))),t&&ib(y.bind)){var e=h(fb.test(y.bind)?B:v.data,y.bind.replace(fb,""));if(null===z&&(z=ub()),gb(e)||y.list){d.addClass("my-form-list");var f="",i=">*";if(/^<.+>$/.test(y.list)?f=y.list:i=y.list||i,!f){var l=">*"==i?a(d[0].children):p(d,i,!0);f="<div></div>",l.length&&(f=a(f).append(l.eq(0).clone(!0)).html(),l.eq(0).remove())}d.data("formlist")||d.data("formlist",{}),d.data("formlist").generator={manifest:t,delay:(y.delay||w.delay||10)/1.3,template:f,selector:i,parent:B,bind:y.bind,merge:mb(y.merge)?y.merge.bind(B):y.merge?n:!1,hash:mb(y.hash)?y.hash.bind(B):ib(y.hash)?k.fill(void 0,y.hash):gb(y.hash)?m.fill(void 0,y.hash.slice(0)):null,id:mb(y.id)?y.id.bind(B):ib(y.id)?k.fill(void 0,y.id):gb(y.id)?m.fill(void 0,y.id.slice(0)):null,ext:!(!y.id&&!y.hash),stamp:0},d.on("insert.my",function(b,c){b.stopPropagation();var d={what:void 0,where:0};null==c?d.where=1e6:jb(c)?qb(d,c):(ib(c)||kb(c))&&(d.where=c),a(b.target).my("insert",d.where,d.what)}),d.on("remove.my",function(b){b.stopPropagation(),a(b.target).my("remove")})}else try{b=K.call(d,r(B,t),jb(e)?e:void 0)}catch(q){j("$.my subform init of "+g+" failed: "+q.message,q.stack)}}nb(b)?b.then(o,function(a,b){j("Init of subform "+g+" failed with error: "+a,b)}):o()}function j(a,c){b(a,c),z&&z.reject(a,c)}function k(a,b){var c=h(a,b)||"";return"string"==typeof c?c:l(c)}function m(a,b){return l(D(a,b))}function o(){d.each(function(){var b,c,h,i=a(this),j=i[0].nodeName,k=!1;if("TEXTAREA"==j&&(h=i[0].nextSibling,c=h&&h.CodeMirror?h.CodeMirror:null,c&&i.addClass("my-codemirror")),b=y.events||N(i,Cb.events),i.hasClass("my-form")?tb(i.data("my"),{dui:y,root:e,selector:g,dparams:w,devents:b,ddata:v.data,container:w.container(i),derrors:v.errors,single:!0}):(i.data("my",{events:b,selector:g,initial:s,previous:s,root:e,container:w.container(i),id:v.id,ui:y,data:v.data,params:w,errors:v.errors,single:1==C}),f._update=y.delay?O.debounce(y.delay):wb,k=!0),k)if(i.cleditor&&i.parent().hasClass("cleditorMain")){var l=i.cleditor()[0];if(l&&l.$frame&&l.$frame[0]){i.addClass("my-cleditor"),tb(i.data("my"),{container:w.container(i)});var m,n=function(a){i.val(a).trigger(eb)},o=Number.random(1e5,1e6-1);a(l.$frame[0]).attr("id","cleditCool"+o),m=document.frames?document.frames["cleditCool"+o].document:a("#cleditCool"+o)[0].contentWindow.document;var p=a(m).find("body");a(m).on("keyup.my",function(){n(a(this).find("body").html())}),i.parent().find("div.cleditorToolbar").on("click.my mouseup.my",function(){n(p.html())}),a("body").on("click","div.cleditorPopup",function(){n(p.html())})}}else if("TEXTAREA"==j&&i.parent().hasClass("redactor_box")){var q,r="my-redactor-9";try{q=i.getEditor(),r="my-redactor-8"}catch(t){q=i.redactor("getEditor")}q&&(i.addClass(r),q.on("input.my keyup.my blur.my",function(a){a.trigger("redactor")}.fill(i)))}else i.hasClass("ace_editor")?ace.edit(d[0]).on(eb,function(a){a.trigger("ace")}.fill(i)):c&&c.on(eb,function(a){a.trigger("codemirror")}.fill(i));i.my()._changed=x.debounce(u),i.my()._recalc=I.debounce(u),i.on(b,function(a){a.type==eb&&a.stopPropagation(),k&&(v.locktill=Ab()+f.delay),i.my()._changed(i,e,f,w)}),/check(\.my)?/.test(b+"")||i.on("check.my",function(){return i.my()._changed(i,e,f,w,!0),!1}),k||i.off("redraw.my"),i.on("recalc.my, redraw.my",function(a){a.stopPropagation(),i.my()._recalc(i,e,f,w)})}),z&&z.resolve()}var q,s,t,u,v=e.my(),w=(v||{}).params,y=f,z=null,A=0,B=v.manifest,C=0|d.length;return v?(u=f.delay,C?(y.init!=wb&&(q=H(B,y.init,d,v)),nb(q)?(A+=1,z=ub(),q.then(i,function(a,b){j("Init of "+g+" failed: "+a,b)})):i()):c("Not found "+g+" selector.",e),z):(b("Failed to find $root building "+g+" selector."),null)}function w(c,d){jb(d)&&d.channel&&d.message&&p(c,".my-listen-"+l(d.channel),!0).each(function(){var c,e=a(this),f=e.data("my"),g=void 0;if(f&&f.ui.listen&&mb(f.ui.listen[d.channel])){c=f.ui.listen[d.channel];try{g=c.call(f.manifest||f.root.my().manifest,f.data,d.message,e)}catch(h){b("Listener failed",h.message,h.stack)}void 0!==g&&(null===g?e.trigger("check"):g&&e.trigger("recalc"))}})}function x(a,b,c,d,e){{var f,g=a.data("my");b.data("my")}g&&(g.disabled?g.ddata||O(a,wb,c.recalcDepth||d.recalcDepth):(B(g.ddata||g.data,g.dparams||g.params),e||(f=g.single?a:p(b,g.selector)),O(a,e?wb:A(f,wb),c.recalcDepth||d.recalcDepth),d.change&&d.change.call(a)))}function y(b,c,d){var e=d.compact(),f=e.replace(/:disabled/g,""),g=f!==e,h="self:"===f.to(5);return h&&(f=f.replace(/^self:/g,"")),c.each(function(){var d=a(this),e=d.my(),i=!h&&e?e.container:d;i.toggleClass(f,!!b),g&&void 0!==e&&!!b!=!!e.disabled&&(d.my().disabled=!!b,e._disable||(d.my()._disable=N(c,Cb.offon).fill(void 0,c)),e._disable(!!b))}),c}function z(a,b,c){return a[b](c?"disable":"enable")}function A(a,b){var c,d,e=a.data("myval");return e||(d=N(a,Cb.vals),mb(d)&&(c=d(a,wb),void 0===c?a.data("myval",function(a,b){return wb!=b&&d(a,b),a.val()}.fill(a,void 0)):a.data("myval",d.fill(a,void 0))),e=a.data("myval")),mb(e)?(c=e(),(c!==b&&(0==b||0==c)||c!=b||jb(b))&&(c=e(b)),c):wb}function B(a,b,c,d){var e,f,g,h,i,j,k,l,m,n=b;if(!jb(n)||isNaN(h=n.remember)||!jb(e=n.history))return wb;if(jb(a)&&h){if(j=rb(a,!0),k=Ab(),g=sb(e).sort(),g.length&&(k-g.last()<n.historyDelay||Object.equal(e[g.last()],j)))return wb;if(n.history[k]=j,g.push(k),g.length>=2*h){for(m={},f=h;2*h>f;f++)m[g[f]]=e[g[f]];b.history=m}return d||n.form.trigger(eb),n.history[g.last()]}if(!isNaN(a)||a===wb){if(i=parseInt(a)||0,0>i)return wb;if(g=sb(e).sort(),i>=g.length&&(i=g.length-1),l=rb(n.history[g[g.length-i-1]],!0),c){for(m={},f=0;f<g.length-i-1;f++)m[g[f]]=e[g[f]];b.history=m}return d||n.form.trigger(eb),l}return d||n.form.trigger(eb),wb}function C(a,b){function c(a,b,c){var e;g[a]||a.length<3&&a.to(1).toLowerCase()==a.to(1)||(mb(f[c][a])?(e=f[c][a].bind(d),f[a]=e,f[a].toString=e,f[a].assign=function(){for(var a=[],b=0,c="";b<arguments.length;b++)a.push(arguments[b]);return c=e.apply(null,a),ib(c)?c.assign.apply(c,a):c}):f[a]=f[c][a],g[a]=!0)}if(!jb(a))return!1;var d=a,e=ib(b)?b:Y,f=d.lang,g={};return f&&jb(f.en)?f._LANG==e?!0:(e=jb(f[e])?e:"en",f._LANG=e,Object.keys(f[e]).forEach(c.fill(void 0,void 0,e,g)),"en"!=e&&Object.keys(f.en).forEach(c.fill(void 0,void 0,"en",g)),!0):!1}function D(a,b){function c(a,b){if(!jb(b))return{};var e={};for(var f in b)!jb(b[f])&&d(a,f)?e[f]=rb(a[f],!0):d(a,f)&&(e[f]=jb(a[f])?c(a[f],b[f]):rb(a[f],!0));return e}if(!jb(a))return null;var e,f=b;if(ib(f))return h(a,f);if(gb(f)){e=[];for(var g=0;g<f.length;g++)e[g]=ib(f[g])?h(a,f[g])||null:null;return e}return jb(f)?c(a,f):void 0}function E(a,b,c){var d,e,f;if(null==c?(d={},e=a,f=b):(d=a,e=b,f=c),jb(e)&&jb(f))return D(e,f);if(ib(f)&&(f=[f],e=[e]),!gb(f)||!gb(d)&&!jb(d))return null;if(jb(e)&&(e=f.reduce(function(a,b){return a.push(h(e,b)),a},[])),gb(e)&&gb(f)){for(var g=0;g<f.length;g++)null!=e[g]&&F(d,e[g],f[g]);return d}return null}function F(a,b,c,d){var e,f,g,h,i=0;if(ib(c)&&!/\./.test(c))null!=b&&(a[c]=b);else for(f=gb(c)?c:(c+"").split("."),e=a,h=f.length-1;h>=i;i++)if(i===h){if(d)return wb!=b?e[f[i]]=b:void 0===e[f[i]]&&(e[f[i]]=wb),e[f[i]];e[f[i]]=b}else 0===i?(e=a[f[0]],g=a):(g=g[f[i-1]],e=e[f[i]]),(null==e||!jb(e)&&(gb(e)&&!isNaN(f[i+1])&&+f[i]>-1))&&(e=g[f[i]]={});return a}function G(a,b,c){var e=jb(b)?b:null;return Object.each(a,function(b,c){var d=typeof c;/^str|^fu/.test(d)&&(a[b]={bind:c})}),Object.each(a,function(b,f){var g,i,k,l=[],m=[],n=/\s?[,;]\s?/;f.recalc&&(ib(f.recalc)?l=f.recalc.split(n):gb(f.recalc)&&(l=f.recalc),l=l.compact(!0).unique()),l.length&&(a[b].recalc=l),null==f.bind&&(f.bind=function(){});var o;if(f.listen&&(o=j(f.listen),f.listen=Object.size(o)?o:void 0),d(f,"events")&&(f.events=(f.events+"").replace(/,\s*|\s+/g," ")),d(f,"watch"))for(ib(f.watch)?m=f.watch.split(n):gb(f.watch)&&(m=f.watch.slice(0)),m=m.compact(!0).unique(),k=0;k<m.length;k++)(g=a[m[k]])&&(i=g.recalc,i?ib(i)?g.recalc+=","+b:gb(i)&&-1==i.indexOf(b)&&g.recalc.push(b):g.recalc=[b]);null!==e&&["css","check","manifest","list","hash","id"].each(function(a){if(f.hasOwnProperty(a)&&"string"==typeof f[a]){var b=h(e,f[a].replace(fb,""));null==b||ib(b)||(f[a]=b)}}),f.delay=isNaN(f.delay)?c.delay:f.delay-0}),a}function H(a,b,c,d){var e;if(ib(b)){if(e=h(a,b),void 0===e)return c.html(b.assign(d.data)),null}else e=b;if(mb(e))return e.apply(a,f(arguments,2));if(gb(e))try{c.formgen(e)}catch(g){}return null}function I(a,b,c,d){var e=a.my();if(e&&!e.disabled){var f=p(b,e.selector);f.hasClass("my-form")?f.my("redraw"):O(a,f.hasClass("my-form-list")?h(f.my().data,f.data("formlist").generator.bind):wb,c.recalcDepth||d.recalcDepth)}}function J(b,c){function d(b,c){var d;return ib(b)?/[\/]/.test(b)?(d=tb(!0,{},x,{ref:c,ajax:{url:b}}),fb.test(c)&&(d.ajax.dataType="json")):b.length&&(d=tb(!0,{},x,{ref:c,ajax:b})):jb(b)&&(d=tb(!0,{},x,{ref:c,ajax:a.extend(!0,{},Object.select(b,["accepts","async","cache","data","dataType","xhrFields","password","timeout","type","url","username","headers"]))}),d.ajax.url||(d=null)),d}function e(){s.reject(v)}function f(){y+=1;var a=t[y];if(a)g(a).then(f).fail(e);else{var c=j(u),d=sb(Object.findAll(c,function(a,b){return!b}));d.length&&v.push((1===d.length?"Key "+d[0]+" is":"Keys "+d.join(", ")+" are")+" not present after all."),v.length?e():s.resolve(b)}}function g(a){function c(){i-=1,g?h.reject():.5>i&&h.resolve()}var d,e,f,g=!1,h=ub(),i=a.length;for(e=0;i>e;e++)d=a[e],f=ib(d.ajax)?w.loader:yb,f(d.ajax).then(function(a,d){fb.test(d.ref)&&(null!=a?tb(!0,b,E(a,d.ref.from(5))):(g=!0,v.push("Invalid data for ‘"+d.ref+"’ resource."))),c()}.fill(void 0,d)).fail(function(a,b){v.push("Failed to load ‘"+b.ref+"’ resource."),g=!0,c()}.fill(void 0,d));return h.promise()}function i(a){var c=!1;return fb.test(a)?null!=h(b,a.from(5))&&(c=!0):null!=h(window,a)&&(c=!0),c}function j(a){for(var b in a)a[b]===!1&&(a[b]=i(b));return a}var k,l,m,n,o,p,q,r,s=ub(),t=[],u={},v=[],w=tb(!0,{ajaxTimeout:1e4,loader:Cb.params.loader},c||{}),x={ref:null,ajax:{type:"GET",async:!0,timeout:w.ajaxTimeout}};if(jb(b))if(gb(b.require)){for(n=b.require,k=0;k<n.length;k++)if(o=n[k],ib(o))u[o]=i(o);else if(jb(o)){r=[];for(l in o){if(p=null,o[l]===!0)u[l]=i(l);else if(ib(o[l])||jb(o[l]))p=d(o[l],l);else if(gb(o[l])){for(p=[],m=0;m<o[l].length;m++)(ib(o[l][m])||jb(o[l][m]))&&(q=d(o[l][m],l),q&&p.push(q));p.length||(p=null)}p&&!(u[l]=i(l))&&r.add(p)}r.length&&t.push(r)}var y=-1;f()}else s.resolve(b);else s.reject(["Invalid manifest."]);return s.promise()}function K(d,e,f){function g(){var a=!0;o(),_.files&&(a=r()),a&&(q(),s())}function i(a){var b,c,d,e,f,g,i={},j=!0,l=a.inherit;if(i=k(l),!Object.size(i))return null;if(e=sb.parents(".my-form").eq(0),!e.length)return null;if(f=e.data("my"),!f||!f.manifest)return null;d=f.manifest,c=d.expose,j=!c;for(b in i)(j||c[b])&&(g=h(d,b),null!=g&&(/\./.test(b)||ib(i[b])?tb(!0,R,E(g,ib(i[b])?i[b]:b)):a[b]=g))}function n(){var a,c;for(a in eb)for(c in O[a].listen)eb[a].addClass("my-listen-"+l(c));_.radio&&sb.on("radio.my",function(a,c){var d,e;if(jb(c)&&c.channel&&c.message&&mb(_.radio[c.channel])){d=_.radio[c.channel];try{e=d.call(_,a,c)}catch(f){b("Radio handler for form "+K+" failed",f.message,f.stack)}void 0!==e&&(a.stopPropagation(),e&&w(sb,c))}})}function o(){Q.strict||mb(R.init)||P(R,!0),_=tb(!0,_,Object.reject(R,["data"])),O=G(tb(!0,{},R.ui||{}),_,Q),_.radio&&(_.radio=j(_.radio)),_.expose&&(_.expose=k(_.expose)),J=Number.random(268435456,4294967295).toString(16),I=R.id||"my"+J,K=l(I),_.id=I,Q.form=sb,R.params&&R.params.depth&&(Q.recalcDepth=R.params.depth),Object.keys(_).forEach(function(a){"function"==typeof _[a]&&(_[a]=_[a].bind(_))}),X?_.my=M(sb):Object.defineProperty(_,"my",{get:function(){return null==cb&&(cb=M(sb)),cb},enumerable:!1}),R.error&&(ib(_.error)?kb=function(a,b){return _.error.assign(tb({message:a+"",err:b+""},_))}:mb(R.error)&&(kb=function(a,b){N=null;try{N=R.error.call(_,a,b)}catch(c){N=Q.messages.initFailed}return N})),_.lang&&C(_,Q.locale||Y),tb(sb.data("my"),{id:I,cid:J,mid:K,errors:Object.extended(),ui:Object.extended(O),disabled:!1,manifest:_,locFiles:[],modals:{},radio:{}}),sb.addClass("my-form"),T="my-manifest-"+K,U="my-form-"+J,sb.addClass(U+" "+T)}function q(b){function c(a,b){var c="\n",d=/@keyframes/,e=!1,f=c+a.map(function(a){return/^\s*@/.test(a)||"}"==a?(d.test(a)?e=!0:"}"==a&&(e=!1),a):((e?"":"."+b)+a).replace(/\s+/g," ")}).join(c)+c;return'<style id="'+b+'" data-count="0">'+f+"</style>"}!_.style||b&&!sb.is(":visible")||(S=L(sb,_),S&&S[0].length&&!b&&(V=a("style#"+T),V.length||(V=a(c(S[0],T)).appendTo(a("body"))),V.data("count",1*V.data("count")+1),sb.data("my").style=V),S&&S[1].length&&(Z=a("style#"+U),Z.length?b&&(a(c(S[1],U)).replaceAll(Z),Z=a("style#"+U)):(Z=a(c(S[1],U)).appendTo(a("body")),Q.restyle>-1&&!pb[J]&&(pb[J]=function(){q(!0)}.debounce(Q.restyle)),sb.data("my").restyle=q.fill(!0).debounce(0)),sb.data("my").localStyle=Z,b||sb.addClass("my-restyle")))}function r(){var a,b,c=!0;if(b=t(_),ib(b))B("Error decoding base64 to local Blob/URL",b),c=!1;else{if(W)for(a=0;a<b.length;a++)db.push(_.files[b[a]].url);db.length&&(sb.data("my").locFiles=db)}return c}function s(){if(R.init!=wb){qb=sb.find(">*").clone();try{$=H(_,R.init,sb,R)}catch(b){return B(ib(b)?b:b.message,b.stack),sb}}if(nb($)?$.then(function(){x()},function(a,b){B(a,b)}):x(),!hb){if(!sb.my())return B("Internal error initializing controls.",""),sb;sb.data("my").initial=tb(!0,{},bb),a.mobile&&a.mobile.changePage(a.mobile.activePage)}}function x(){function a(a){hb||(b[a]=A(p(sb,a),wb),d-=1,.5>d&&y(b))}var b={},c=Object.keys(O),d=c.length;0===d?z():(sb.addClass(lb),c.forEach(function(b){if(!hb){var c=p(sb,b),d=v(c,sb,O[b],b);rb[b]=c,nb(d)?d.then(a.fill(b)).fail(function(a,c){B("Error building "+b+", "+a,c)}):hb||a(b)}}))}function y(a){var c,d,e,f,g;for(g in O){if(hb)return;if(c=O[g],e=rb[g],f=e.length){c.listen&&(eb[g]=e.eq(0));try{d=u(bb,wb,c,e),d==wb&&a[g]!=wb&&void 0!==d&&u(bb,a[g],c,e)}catch(h){b("Transient fail linking "+g+" of form $('.my-form-"+J+"')",h.message,h.stack)}try{d!=wb&&A(e,d),e.eq(0).trigger("check.my")}catch(h){B("Error linking "+g,h.message,h.stack)}}}z()}function z(){sb.removeClass(lb),sb.on("recalc.my, redraw.my",function(a){a.stopPropagation(),sb.my("redraw")}),qb=null,fb.resolve(bb)}function B(a,c){var d;if(hb=!0,b("Form "+I+" failed to initialize.",a,c),Object.keys(rb).forEach(function(a){delete rb[a]}),sb.removeClass(lb),d=kb(a,c),ib(d)||jb(d)&&d.jquery?sb.html(d):d===!0&&sb.html(qb),Q.silent)fb.resolve(bb);else{if(!sb.my().ddata){if(sb.removeData("my"),sb.removeClass("my-form"),V)if("1"==V.data("count"))try{V.remove()}catch(e){}else V.data("count",V.data("count")-1);if(Z)try{delete pb[J],Z.remove()}catch(e){}}fb.reject("Form "+I+" failed to initialize: "+a,c)}}var D,F,I,J,K,N,O,Q,R,S,T,U,V,Z,$,_={},bb={},cb=null,db=[],eb={},fb=ub(),hb=!1,kb=function(){},lb="my-form-init",ob="std",qb="",rb={};if(ib(d)){if(D=zb(d),!D)return fb.reject("No manifest with id "+d+" found in repo."),fb.promise();jb(f)&&jb(e)?(D=tb(D,e),F=f):F=e,ob="repo"}else D=d,F=e;if(!D)return this;R=jb(F)&&"repo"!=ob?tb(!0,{},D):D;var sb=this.eq(0),vb=sb.my();return jb(vb)&&vb.id&&vb.ui?(c("jQuery.my is already bound.",sb),sb.my("ui",R.ui),sb.my(ab,R.data),fb.resolve(sb.my(ab)).promise()):(Q=R.params||{},Q.strict||mb(R.init)||(Q=tb(!0,{},Q),P(Q)),Q=tb(!0,{},Cb.params,Q),fb.fail(function(){sb.removeClass(U+" "+T)}),tb(sb,fb.promise()),jb(F)?(bb=m(F,R.data||{}),R.data=bb):bb=R.data||{},_.data=bb,sb.data("my",{data:bb,params:Q,promise:fb.promise(),locktill:0}),sb.addClass(lb),R.inherit&&i(R),gb(R.require)?Bb(R,Q).then(g).fail(function(a){o(),B("Linker of the ‘require’ property failed.",a)}):g(),fb.then(n),sb)}function L(a,b){function c(e,f,g,h){var i,j,k,l,m,n=e,o=/@/.test(f),p=f.split("@")[0],q=mb(n);if(o&&(q?h:g).push("@"+f.split("@")[1].trim()+" {"),ib(n)&&(/[\r\n]/.test(n)||n.split("}",3).length>2?n=Db.css2json(n):g.push(p+(/\{/.test(n)?n:"{"+n+"}"))),gb(n)&&n.length)for(i=0;i<n.length;i++)c(n[i],p,g,h);else if(jb(n))for(k=sb(n),i=0;i<k.length;i++)for(m=d(p,k[i]),j=0;j<m.length;j++)c(n[k[i]],m[j],g,h);else if(mb(n))try{l=n.call(b,a,b),c(l,p,h,h)}catch(r){}o&&(q?h:g).push("}")}function d(a,b){var c,d="",e=b+"";return(" "===e.to(1)||/^[a-z]/i.test(e))&&(d=" "),c=e.split(/\s*,\s{0,}/).compact(!0),c.length||c.push(""),c.map(function(b){return a+d+b})}var e=[],f=[],g=b;return jb(g)&&jb(g.style)?(c(b.style,"",e,f),[e,f]):""}function M(b){function c(c,d,f){var g=c?ib(c)?p(b,c):a(c):b;return e(g)?g.trigger(d,f):void 0}var d={ajax:function(){return yb.apply(this,f(arguments))},cancel:c.fill(void 0,"cancel"),check:c.fill(void 0,"check"),commit:c.fill(void 0,"commit"),insert:function(a,b,d){var e="insert",f=!0;if(jb(d)?c(a,e,{where:b,what:d}):ib(a)?null==b&&null==d?c(b,e):jb(b)?c(a,e,{where:1e6,what:b}):f=!1:jb(a)&&(a.where&&a.what?c(null,e,a):c(null,e,{where:1e6,what:a})),!f)throw"Invalid insert"},modal:function(a,c){var d,e;return ib(a)?(d=p(b,a),e=c,e.root||(e.root=b)):(d=b,e=a),d.modal(e)},now:Ab,parent:function(){var a=b.parents(".my-form");return a.length?a.eq(0).my("manifest"):null},recalc:c.fill(void 0,"recalc"),root:function(){return b},trigger:c,val:function(a){return Eb.val.apply(p(b,a),f(arguments,1))}};return Fb.forEach(function(a){"init"==a||d[a]||(d[a]=Eb[a].bind(b))}),d}function N(a,b){function c(a,b,g){for(var h in b)if(""!=h&&a.is(h)){f=f+(f?" ### ":"")+h;var i=b[h],j=vb(i);if(!/^(nul|un|ob)/.test(j)&&g>e)return d=i,e=g,void 0;j==_&&c(a,i,g+1)}wb!=b[""]&&typeof b[""]!=_&&g>e&&(d=b[""],e=g)}var d=wb,e=0,f="";return c(a,b,1),d}function O(a,c,d){var e,f,g,h,i,j,k,l,m,n,o,q,r=!1,s=!1,t=a,v=t.my(),w="";if(v){if(m=v.selector,n=v.root,n.hasClass("my-form-init"))return{};if(o=p(n,m),q=n.my().ui,r=a.hasClass("my-form"),r?(f=a,g=v.ddata,h=v.dui,i=v.dparams):(f=v.container,g=v.data,h=v.ui,i=v.params),h.bind!=wb){if(j=xb(c)?c:A(o,u(g,wb,h,o)),wb!=h.check){w="Unknown error";try{w=U(g,j,h,o)}catch(x){b("Error "+x.message+" in .check validator for "+m,n,x.stack)}}var z=i.errorCss,B="ui-state-error";try{wb!=c&&(j=A(o,u(g,c,h,o)))}catch(x){w=i.messages.formError||"Error"}if(wb!=h.check)if(s=a.hasClass("my-form-list"),""==w&&(r||f.hasClass(z)))r?v.derrors[m]="":v.errors[m]="",f.removeClass(z),f.attr("title")&&f.attr("title",""),r||s||i.effect(p(f,i.errorTip),!1,i.animate/2),t.removeClass(B),p(t,".ui-widget").removeClass(B);else if(w){if(r)v.derrors[m]=w;else if(s)v.errors[m]=w;else{f.addClass(z),v.errors[m]=w;var C=p(f,i.errorTip);C.length?i.effect(C.addClass(z).html(ib(w)?w:"Error"),!0,i.animate):f.attr("title",(ib(w)?w:"Error").stripTags())}t.hasClass("hasDatepicker")&&(t.is("input")?t.addClass(B):p(t,".ui-widget").addClass(B)),t.hasClass("ui-slider")&&t.addClass(B)}}var D=c==wb?j:c;if(h.css)for(k in h.css)l=h.css[k],lb(l)?y(l.test(D),o,k):mb(l)&&y(l.call(n.my().manifest,g,D,o),o,k);var e,E,F=h.recalc,G=[],H={};if(d&&h.recalc&&n.my()){for(q=n.my().ui,e=0;e<F.length;e++)F[e]&&ib(F[e])&&(E=F[e].compact())&&q[E]&&(q[E].recalc?-1===G.indexOf(E)&&G.push(E):H[E]=!0);for(e=0;e<G.length;e++)H=tb(!0,H,O(p(n,G[e]),wb,d-1));if(c!==wb){for(e in H)H[e]===!0&&e!=m&&(q[e].delay&&!q[e].recalc?q[e]._update(p(n,e),wb,d-1):O(p(n,e),wb,d-1));return{}}}return H||{}}}function P(a,b){var c,e=!b;for(c in a)d(a,c)&&Q(c,a,e)}function Q(a,c,d){var e,f,g,h,i="";(d||!/^(data|files|require)$/.test(a))&&(e=c[a],i=vb(e),/^(ob|ar)/.test(i)?P(e):"string"===i&&/^(function(\(|[\s\n\t]+)|new\sRegExp)/.test(e)&&((f=e.match(/^function([\s\n\t]+[\w_$][\w\d_$]*)?[\s\n\t]*\(([^\)]*)\)\s*\{([\s\S]*)\}[\s\n\r\t]*$/))&&4===f.length?(h=f[1]?f[1].replace(/[\s\n\t]/g,""):"",g=h.length?S(h,f[2],f[3]):R(f[2],f[3]),"function"==typeof g?c[a]=g:b("Invalid function in XJSON, skipped",g.message,g.stack,e)):(f=e.match(/^new\sRegExp\s*\(\/([\s\S]+)\/([a-z]*)\)$/))&&3===f.length&&(g=T(f[1],f[2]),"function"==typeof g.test?c[a]=g:b("Invalid RegExp in XJSON, skipped",g.message,g.stack,e))))}function R(a,b){var c;try{c=new Function(a,b)}catch(d){c={message:d.message,stack:d.stack}}return c}function S(a,b,c){var d;try{d=new Function("","return (function "+a+"("+b+"){"+c+"});")()}catch(e){d={message:e.message,stack:e.stack}}return d}function T(a,b){var c;try{c=new RegExp(a,b)}catch(d){c={message:d.message,stack:d.stack}}return c}function U(b,c,d,e){var f,g,h,j,k=d.check,l=0;if(k!=wb){var m=i(e).params.messages,n=d.error,o=n||m.patternMismatch||m[""]||"Error";if(e.length&&Object.prototype.hasOwnProperty.call(e[0],"validity")&&!e[0].validity.valid){var q=e[0].validationMessage+"";if(""!==q)return q.substr(0,1).toUpperCase()+q.substr(1);g=e[0].validity;for(f in g)""===q&&"valid"!=f&&hb(g[f])&&g[f]&&m[f]&&(q=m[f]);return q||n}switch(vb(k).substr(0,1)){case"f":return j=k.call(i(e).manifest,b,c,e),null===j||void 0===j?"":j;case"r":return k.test(String(c))?"":o;case"a":return k.indexOf(c)>-1?"":o;case"s":return c==k?"":o;case"o":return k[c]?"":o;case"b":return e.hasClass("my-form-list")?(h=e.data("listSrc")||e.data("my").listSrc||">*",j={},l=0,(">*"==h?a(e[0].children):p(e,h,!0)).each(function(){var b=a(this);b.hasClass("ui-sortable-placeholder")||(b.data("my")&&!b.my("valid")&&(j[l]=b.my("errors")),l+=1)}),j):e.hasClass("my-form")&&k?e.my("valid")?"":e.my("errors"):""}return m.formError||"Error"}return""}var V="1.2.14",W=window.URL||window.webkitURL,X=!document.addEventListener,Y=((window.navigator.language||window.navigator.userLanguage||"en")+"").split("-")[0].toLowerCase(),Z="{yyyy}-{MM}-{dd}",$="{HH}:{mm}",_="object",ab="data",bb="array",cb="string",db="function",eb="change",fb=/^this\./,gb=Object.isArray,hb=Object.isBoolean,ib=Object.isString,jb=Object.isObject,kb=Object.isNumber,lb=Object.isRegExp,mb=Object.isFunction,nb=function(a){return null!=a&&typeof a==_&&mb(a.then)},ob=h(a,"my.f.repo")?a.my.f.repo():{_src:{},_name:"Default manifest cache"},pb=h(a,"my.f.restyles")?a.my.f.restyles():{},qb=Object.merge,rb=Object.clone,sb=Object.keys,tb=a.extend,ub=a.Deferred,vb=a.type,wb=null,xb=function(a){return null!==a&&void 0!==a},yb=a.ajax,zb=q,Ab=Date.now,Bb=J,Cb={vals:{".my-form":function(a,b){if(a&&a.my){var c=a.my(ab);return Object.equal(c,b)?c:a.my(ab,b,!0)}return b||wb},".hasDatepicker":function(a,b){xb(b)&&a.datepicker("setDate",""==b?b:Date.create(b));var c=a.datepicker("getDate");return c?c.format(Z):""},".my-tags":function(a,b){return xb(b)&&(ib(b)||kb(b)?a.tags(ab,[b+""]):gb(b)&&a.tags(ab,b)),a.tags(ab)},".ui-draggable":function(a,b){if(xb(b)&&jb(b)){var c={};isNaN(b.left)||(c.left=Number(b.left).ceil(2)+"px"),isNaN(b.top)||(c.top=Number(b.top).ceil(2)+"px"),(c.left||c.top)&&a.css(c)}var d=a.position();return{left:b&&!isNaN(b.left)?(1*b.left).ceil(2):d.left.ceil(2),top:b&&!isNaN(b.top)?(1*b.top).ceil(2):d.top.ceil(2)}},".my-form-list":function(b,c){function e(){var c,d,e=a(this),f=e.data("my");f&&(c=e.data("formlist"),d=c.index,c.hash=w(f.data,d)+"",c.oid=x!==w?x(f.data,d)+"":c.hash),b.trigger("check.my")}function f(a){a.data("my").locktill+z/1.3<G&&a.my("redraw")}var h,i,j,k,m,n,o,p=b.data("formlist")||{},q=p.generator||{},s=q.selector||">.my-form",t=!!q.merge,u=q.template||"<div></div>",v=/\{/.test(u),w=q.hash||l,x=q.id||l,y=q.ext,z=q.delay||50,A="ui-sortable",B="."+A+"-placeholder",C=b.is("."+A),D=!!b.children(B).length,E=[],F=[],G=Ab(),H=b.find(C?b.sortable("option","items"):s);if(xb(c)&&gb(c)){if(D)return c;if(i=[],j={},H.each(function(){var b,c=a(this),d=c.data("my");d&&(i.push(d.data),!t&&(b=c.data("formlist"))&&(j[b.oid]=d.data))}),m=g(i,c,"=="),!m){var I=[],J=[],L={},M={};for(F=[],h=0;h<c.length;h++)J[h]=x(c[h],h)+"",L[J[h]]=h,I[h]=(x!==w?w(c[h],h):J[h])+"";for(H.each(function(){var b=a(this),e=b.data("formlist")||{},f=e.oid;f&&d(L,f)&&(t||c[L[f]]===j[f])?M[f]=a(this):b.hasClass("my-form")?b.my("remove",!0):b.remove()}),h=0;h<c.length;h++)d(M,J[h])?(n=M[J[h]].detach().appendTo(b),E.push(n.my("data")),I[h]!==(n.data("formlist")||{}).hash&&(t&&E.last()!==c[h]&&q.merge(E.last(),c[h]),F.push(n))):(n=a(v?u.assign(c[h]):u).appendTo(b),n.data("formlist",{list:c[h],index:h,hash:I[h],oid:J[h]}),K.call(n,r(q.parent,q.manifest,c[h],h,c,b),c[h]).then(function(a){a.on("change.my",e.debounce(z/1.3))}.fill(n)),E.push(n.my("data")));if(F.length&&y){for(h=0;h<F.length;h++)f(F[h]);F=[]}return i=j=k=null,E}return j=k=null,i}if(H.length){if(G-q.stamp>1.4*z||G-q.stamp>100||!q.stashed||q.stashed.length!==H.length-(D?1:0)){D&&(o=b.find(">."+A+"-helper"));var N=0;for(H.each(function(b,c){var d,e,f,g=a(c),h=!1;D&&g.hasClass(A+"-helper")||(D&&g.hasClass(A+"-placeholder")&&(g=o),d=g.data("my"),e=g.data("formlist"),d&&e&&(E.push(d.data),N!=e.index&&(e.index=N,h=!0),y&&(f=w(d.data,N)+"",f!==e.hash&&(e.hash=f,h=!0)),N+=1,h&&F.push(g)))}),h=0;h<F.length;h++)f(F[h]);F=[],q.stamp=G,q.stashed=E}else E=q.stashed.slice(0);return E}return c||[]},"input[type=date]":function(a,b){if(xb(b))return c=""!=b?Date.create(b).format(Z):"",ib(c)&&!/Invalid/.test(c)&&a.val(c),c;var c=a.val();return""!=c?Date.create(c).format(Z):""},"input[type=time]":function(a,b){if(xb(b))return c=""!=b?Date.create(b).format($):"",ib(c)&&!/Invalid/.test(c)&&a.val(c),c;var c=a.val();return""!=c?Date.create(c).format($):""},input:{"[type='text'],[type='number'],[type='button'],[type='range'],[type='hidden'],:not([type])":{".ui-slider-input":function(a,b){xb(b)&&a.val(b).slider("refresh")},"div.select2-container+input":function(a,b){return xb(b)&&JSON.stringify(b)!==JSON.stringify(a.select2("val"))&&a.select2("val",gb(b)?b:[b]),a.select2("val")},"":function(a,b){xb(b)&&a.val(b+"")}},"[type='password'],[type='tel'],[type='email'],[type='search']":function(a,b){xb(b)&&a.val(b+"")},":radio":function(b,c){var d=-1;if(xb(c)){b.each(function(b){var e=a(this).val();c+""==e+""&&(d=b)});var e=b.eq(0).checkboxradio;if(e&&b.each(function(b){var c=a(this);d!=b&&c.is(":checked")&&c.prop("checked",!1).checkboxradio("refresh")}),d>-1){var f=b.eq(d);f.is(":checked")||(f.prop("checked",!0),e&&f.checkboxradio("refresh"))}else e||b.each(function(){a(this).prop("checked",!1)})}if(-1==d)for(var g=0;g<b.length;g++)b.eq(g).is(":checked")&&(d=g);return-1!=d?b.eq(d).val():""},":checkbox":function(b,c){var d=c,e=[];if(xb(d)){gb(d)||(d=[c]);var f=!!b.eq(0).checkboxradio;b.each(function(){var b=a(this),c=b.val(),g=b.is(":checked");-1!=d.indexOf(c)?(e.push(c),g||b.prop("checked",!0)):g&&b.prop("checked",!1),f&&b.checkboxradio("refresh")})}else b.each(function(){var b=a(this);b.is(":checked")&&e.push(b.val())});return e}},select:{".ui-slider-switch":function(a,b){xb(b)&&(a.val(b+""),a.slider("refresh"))},"div.select2-container+select":{"[multiple]":function(a,b){return xb(b)&&a.select2("val",gb(b)?b:[b]),a.select2("val")},"":function(a,b){return xb(b)&&a.select2("val",b+""),a.select2("val")}},"[multiple]":function(a,b){return xb(b)&&(a.val(b,[]),a.selectmenu&&(a.data("uiSelectmenu")||a.data("selectmenu"))&&a.selectmenu("refresh",!0)),a.val()||[]},"":function(a,b){xb(b)&&(a.val(b+""),a.selectmenu&&(a.data("uiSelectmenu")||a.data("selectmenu"))&&a.selectmenu("refresh",!0))}},textarea:{".my-cleditor":function(a,b){return xb(b)&&a.val(b).cleditor()[0].updateFrame(),a.val()},"div.redactor_box textarea,.redactor":function(a,b){var c=a.hasClass("my-redactor-9");return xb(b)?(c?a.redactor("set",b):a.setCode(b,!1),b):c?a.redactor("get"):a.getCode()},".my-codemirror":function(a,b){return xb(b)?(a[0].nextSibling.CodeMirror.setValue(b),b):a[0].nextSibling.CodeMirror.getValue()},"":function(a,b){xb(b)&&a.val(b+"")}},"fieldset,form,section,footer,aside,.my-container":function(a,b){var c=f(a[0],0).sort(),d=b;return xb(b)&&(ib(b)&&(d=b.split(/[,\s]+/).compact(!0)),gb(d)&&(d.sort(),d.join(" ")!==c.join(" ")&&(a.atrr("css",d.join(" ")),c=d))),c
|
||
},"div,span":{".ui-slider":function(a,b){return xb(b)&&a.slider("option",a.slider("option","values")?"values":"value",Db.clone(b)),Db.clone(a.slider("option","values")||a.slider("option","value")||0)},".ui-buttonset":function(b,c){if(xb(c)){if(""!=c){var d=wb;if(b.find(":radio").each(function(){d=(a(this).val()||a(this).button("option","label"))==c?a(this):d}),d)return d.attr("checked",!0),b.buttonset("refresh"),c}}else{var e=b.find(":radio:checked");if(e.length&&e.button)return e.val()||e.button("option","label")}return b.find(":radio:checked").attr("checked",!1),b.buttonset("refresh"),""},".ace_editor":function(a,b){return xb(b)&&ace.edit(a[0]).setValue(b),ace.edit(a[0]).getValue(b)},"":function(a,b){return xb(b)&&a.html(b),a.html()}},"a,p,li,td,th,h1,h2,h3,h4,h5,h6,pre,code":function(a,b){return xb(b)&&a.html(b),a.html()},img:function(a,b){return xb(b)&&a.attr("src",b),a.attr("src")||""},"":function(a,b){return xb(b)&&a.html(b),a.html()||a.text()||String(a.val())||""}},msg:{"":{en:"Invalid input",ru:"Ðеверное значение"},formError:{en:"Form error",ru:"Ошибка формы"},initFailed:{en:'<p class="my-error">Form init failed</p>',ru:'<p class="my-error">Ошибка инициализации формы</p>'},badInput:{en:"Invalid input",ru:"Ðеверное значение"},patternMismatch:{en:"Pattern mismatch",ru:"Ðе ÑоответÑтвует шаблону"},rangeOverflow:{en:"Over maximum",ru:"Больше макÑимума"},rangeUnderflow:{en:"Under minimum",ru:"Меньше минимума"},stepMismatch:{en:"Step mismatch",ru:"Ðе кратно шагу"},tooLong:{en:"Too long",ru:"Слишком длинно"},typeMismatch:{en:"Invalid type",ru:"Ðеверный тип"},valueMissing:{en:"Required",ru:"ОбÑзательное поле"}},events:{".hasDatepicker":"change.my check.my",".my-form,.my-tags":"change.my check.my",".ui-slider":"slide.my check.my","div.redactor_box textarea":"redactor.my check.my",".my-codemirror":"codemirror.my check.my",".ace_editor":"ace.my check.my",".my-form-list":"sortupdate.my check.my",".ui-sortable":"sortchange.my sortupdate.my check.my",".ui-draggable":"drag.my dragstop.my check.my","a, .pseudolink, input[type=button], button":"click.my","img, :radio, :checkbox":"click.my check.my","div.select2-container+input,div.select2-container+select":"change.my check.my input.my",".ui-buttonset,input, select, textarea":"blur.my change.my check.my"+("Micro"===navigator.appName.to(5)?" keyup.my":" input.my"),"":"check.my"},containers:{"*[data-role='fieldcontain'] *":{"input,textarea,select,button,:radio":function(a){return a.parents('[data-role="fieldcontain"]').eq(0)}},"div.redactor_box textarea":function(a){return a.parents("div.redactor_box").eq(0).parent()},".my-tags,.hasDatepicker,.ui-widget,input,textarea,select,button":{".my-cleditor":function(a){return a.parents("div.cleditorMain").eq(0).parent()},"":function(b){var c=b[0].parentNode,d=c.nodeName;return/^(div|span|a|p|form|fieldset|li|ul|td|th|h\d)$/i.test(d)?a(c):b.parents("div,span,a,p,form,fieldset,li,ul,td,th,h1,h2,h3,h4,h5,h6").eq(0)}},"":function(a){return a}},offon:{".ace_editor":function(a,b){ace.edit(b[0]).setReadOnly(a)},".ui-selectable":function(a,b){z(b,"selectable",a)},".ui-slider":function(a,b){z(b,"slider",a)},".ui-draggable":function(a,b){z(b,"draggable",a)},".ui-buttonset":function(a,b){z(b,"buttonset",a)},".hasDatepicker":function(a,b){z(b,"datepicker",a)},".my-form":function(a,b){b.my("disabled",!!a)},"div.select2-container+input,div.select2-container+select":function(a,b){z(b,"select2",a)},".my-cleditor":function(a,b){b.cleditor()[0].disable(!!a)},"":function(a,b){b.attr("disabled",!!a)}},destroy:{".hasDatepicker":function(a){a.datepicker("destroy")},".ui-slider":function(a){a.slider("destroy")},".ui-sortable":{".my-form-list":function(b){b.find(">.my-form").each(function(){a(this).my("remove")}),b.removeClass("my-form-list"),b.sortable("destroy")},"":function(a){a.sortable("destroy")}},".my-form-list":function(b){b.find(">.my-form").each(function(){a(this).my("remove")})},".ui-draggable":function(a){a.draggable("destroy")},".my-redactor-8":function(a){a.destroyEditor(),a.removeClass("my-redactor-8")},"div.select2-container+input,div.select2-container+select":function(a){a.select2("destroy")},".my-form":function(a){a.my("remove")},textarea:{".my-codemirror":function(a){a[0].nextSibling.CodeMirror.toTextArea(),a.removeClass("my-codemirror")}}}};Cb.params={container:function(a){return N(a,Cb.containers)(a)},change:wb,recalcDepth:2,delay:0,strict:!1,restyle:-1,locale:Y,messages:Object.map(Cb.msg,function(a,b){return b[Y]||b.en}),errorTip:".my-error-tip",errorCss:"my-error",animate:0,effect:function(a,b,c){return b?a.fadeIn(c):(a.fadeOut(c),void 0)},remember:0,silent:!1,history:{},historyDelay:100,loader:function(a){var b=ub(),c=zb(a+"");return c?b.resolve(c):b.reject(null),b.promise()},ajaxTimeout:1e4};var Db={con:c,clone:function(a){return a.clone?a.clone():a},indom:e,jquix:z,overlap:n,patch:m,kickoff:o,sdbmCode:l,tojson:function(){function a(a){return 10>a?"0"+a:a}function b(a,f,g){var h,i,j,k,l=0,m=f||0,n=d;switch(g&&ib(g)&&(l=String(g).length,n=String(g).repeat(10)),(typeof a).substr(0,3)){case"str":return e(a).replace(/<\/scri/gi,"<\\u002fscri");case"num":return isFinite(a)?""+String(a):"null";case"boo":case"nul":return String(a);case"fun":return e(c(a.toString()).replace(/<\/scri/gi,"<\\u002fscri"));case"obj":if(!a)return"null";if(typeof a.toJSON===db)return b(a.toJSON(),m+(g?1:0),g);if(h=[],gb(a)){for(i=0;i<a.length;i+=1)h.push(b(a[i],m+(g?1:0),g)||"null");return"["+h.join(","+(g?"\n"+n.to(m*l+l):""))+"]"}if(a+""=="[object Object]")for(j in a)a.hasOwnProperty(j)&&(k=b(a[j],m+(g?1:0),g),k&&h.push((g?"\n"+n.to(m*l+l):"")+b(j,m+(g?1:0),g)+": "+k));return"{"+h.join(",")+(g?"\n"+n.to(m*l):"")+"}"}}function c(a){var b=/\)([\s\n\r\t]+?|\/{1,10}.*?\*\/|\/\/[^\n\r]{0,200}[\n\r]){0,20}?\{/,c=a.split(b,1),d=c[0].from(8).replace(/[\s\n\r\t]+?|\/{1,10}.*?\*\/|\/\/[^\n\r]{0,200}[\n\r]/g,"")+")",e="{"+a.from(c[0].length).replace(b,"").replace(/}[^}]+$/,"}");return("function "+d).replace(/^function\sanonymous/,"function ")+" "+e}Date.prototype.toJSON=function(){var b=this;return b.getUTCFullYear()+"-"+a(b.getUTCMonth()+1)+"-"+a(b.getUTCDate())+"T"+a(b.getUTCHours())+":"+a(b.getUTCMinutes())+":"+a(b.getUTCSeconds())+"Z"},RegExp.prototype.toJSON=function(){return"new RegExp("+this.toString()+")"};var d=" ".repeat(10),e=JSON.stringify;return b.fill(void 0,0,void 0)}(),fromjson:function(a){var b=JSON.parse(a);return P(b),b},mask:D,unmask:E,getref:h,repo:function(){return ob},restyles:function(){return pb},unjson:function(a){return P(a),a},blob2base64:function(a,b,c){var d=new FileReader;d.onload=function(){b(c?d.result:d.result.split(",")[1])},d.readAsDataURL(a)},base642blob:function(a,b,c){for(var d,e=atob(a),f=e.length,g=new ArrayBuffer(f),h=new Uint8Array(g),i=0;f>i;i++)h[i]=e.charCodeAt(i);return d=new Blob([h],{type:c||"application/octet-stream"}),mb(b)?(b(d),void 0):d},base64:function(b,c,d){var e=null,f=ib(b)?b:a.my.tojson(b),g=ib(d)?"data:"+d+";base64,":"";if(c){try{e=decodeURIComponent(escape(window.atob(f)))}catch(h){e=null}if(null!==e&&/(^".*"$)|(^\[.*\]$)|(^\{.*\}$)/.test(e))try{e=Db.fromjson(e)}catch(h){e=null}return e}return g+window.btoa((d===!0?"":"")+unescape(encodeURIComponent(f)))},_s2css:L,css2json:function(a){var b="",c=(a+"").replace(/\/\*[\s\S]+\*\//gm,"").replace(/@charset[^;]+;/gim,"").replace(/[\n\t\s]+/g," ").replace(/\s*@media[^{]*\{/g,function(a){return a.to(-1).trim()+"á´¥"}).replace(/\}/g,"}á´¥").replace(/^\n+/g,"").replace(/[\n\s]+$/g,"").split("á´¥").compact(!0).reduce(function(a,c){var d,e,f,g=c.trim();return"}"==g?b="":/^[^{]+\{[^\}]+\}$/.test(g)?(d=g.to(-1).split("{"),e=" "+d[0].trim(),f=d[1].trim(),";"!=f.last()&&(f+=";"),b?a[b][e]=(a[b][e]||"")+f:a[e]=(a[e]||"")+f):/^@media/.test(g)&&(a[g]={},b=g),a},{});return c}},Eb={container:function(a){return N(a,Cb.containers)(a)},data:function(a,b){var c=this;return jb(a)&&(c.my().data=n(c.my().data,a),this.my("redraw",b)),c.my().data},disabled:function(a){var b,c,d,e,f=this,g=f.my();if(!g)return void 0;if(a==wb)return g.disabled;if(a){for(c in g.ui)b=p(f,c),d=b.my(),d&&(d.predisabled=d.disabled),y(!0,b,":disabled");f.addClass("my-disabled")}else{for(c in g.ui)b=p(f,c),d=b.my(),e=!1,d&&d.predisabled&&(e=!0),y(e,b,":disabled");f.removeClass("my-disabled"),f.my("redraw")}},errors:function(){var b=a(this).my().errors,c={};for(var d in b)b[d]&&ib(b[d])&&(c[d]=b[d]),jb(b[d])&&sb(b[d]).length&&(c[d]=b[d]);return c},find:function(a){var b=this,c=b.my();return c&&c.root&&(b=c.root),b.find(a)},history:function(a,b){return B(a,this.my().params,b)},id:function(a,b){if(ib(a))return zb(a,b);var c=this.my();return c&&c.id?c.id:wb},index:function(){var a=this.my().root&&!this.my().ddata?this.my().root:this;return(a.data("formlist")||{}).index},indom:function(){return e(this)},init:K,insert:function(a,b){var c,d,e=this.hasClass("my-form-list")?this:this.my().root||this,f=e.hasClass("my-form-list")?e:e.parent(".my-form-list"),g=(e.data("formlist")||{}).index,i=b,j=f.data("formlist").generator;if(null==g&&(g=0),c=fb.test(j.bind)?h(f.my().manifest,j.bind.replace(fb,"")):h(f.my().data,j.bind),!jb(i))if(jb(j.manifest))i=rb(j.manifest.data,!0)||{};else{if(f===e)throw"No data to insert, cannot guess when manifest is a function.";i=rb(e.my().manifest.data,!0)}if("before"===a)d=g;else if("after"===a)d=g+1;else{if(isNaN(a))throw"Invalid position for insertion";d=(1*a).clamp(0,c.length)}c.add(i,d),f.trigger("redraw")},manifest:function(a){return"json"==a?Db.tojson(this.my().manifest):this.my().manifest},promise:function(a){return mb(a)&&this.my().promise.then(a),this.my().promise},radio:function(a,b){this.trigger("radio",ib(a)?{channel:a,message:b}:a)},redraw:function(a,b){var c=this,d=c.my(),e=2;return d&&jb(d.ui)&&(e=d.params.recalcDepth,Object.keys(d.ui).forEach(function(b){var d=p(c,b);O(d,a?wb:void 0,e),a||(d.hasClass("my-form")&&d.my("redraw"),d.trigger(d.hasClass("my-form-list")?"redraw":"check.my"))}),!b&&a&&c.trigger(eb)),c},remove:function(a){var b,c,d,e,f,g,h,i,j=this;if(!this.my())return wb;if(this.my().root&&!this.my().ddata&&(j=this.my().root),d=j.my(),f=d.data,h=d.cid,i=d.mid,j.unbind(".my"),jb(d)&&d.manifest&&mb(d.manifest.die))try{d.manifest.die.call(d.manifest,j,d.manifest)}catch(k){}if(b=d.style)if("1"==b.data("count"))try{b.remove()}catch(k){}else b.data("count",b.data("count")-1);if(c=d.localStyle)try{delete pb[h],c.remove()}catch(k){}if(window.URL&&(e=d.locFiles)&&e.length)for(var l=0;l<e.length;l++)try{URL.revokeObjectURL(e[l])}catch(k){}if(g=(d||{}).ui,g&&g.each(function(a){var b,c,d,e=p(j,a);if((c=e.data("modal"))&&(c.cancel(),e.removeData("modal")),c=e.data("modals"))for(d in c)c[d]&&c[d].cancel();e.unbind(".my");try{b=N(e,Cb.destroy),mb(b)&&b(e)}catch(f){}e.removeData("formlist").removeData("myval").removeData("my")}),a&&j.hasClass("my-form"))j.remove();else if(j.data("formlist")&&j.hasClass("my-form")){var m=j.parents(".my-form-list").eq(0);j.remove(),m.trigger("check")}else j.removeData("formlist").removeData("myval").removeData("my").removeClass("my-form");return j.removeClass("my-form-"+h+" my-manifest-"+i),f},reset:function(){try{o(this.my().data,this.my().initial),this.my("redraw")}catch(a){return!1}return!0},restyle:function(b){var c,d,e=[],f=this.hasClass("my-form")?this:this.parents(".my-form").eq(0);if(f.length&&f.is(":visible")){for(d=(f.data("my")||{}).cid,d&&e.push(d),b||p(f,".my-restyle",!0).each(function(){var b=a(this),c=(b.data("my")||{}).cid;c&&e.push(c)}),c=0;c<e.length;c++)if(pb[e[c]])try{pb[e[c]]()}catch(g){}return!!e.length}return!1},ui:function(a){var b,c=this,d=c.my(),e=[];if(!d)return wb;tb(!0,{},d.ui);if(!jb(a))return d.ui;for(b in a)e.push(b);for(d.ui=G(n(d.ui,a)),b=0;b<e.length;b++)v(p(c,e[b],!0),c,d.ui[e[b]],e[b]);for(b in a)p(c,b).trigger("check");return d.ui},undo:function(a){var b,c=this,d=c.my(),e=d.params.history,f=sb(e).sort(),g=1*(parseInt(a)||0);return!f.length||0>g?wb:(d.params.errors&&d.params.errors.values().compact(!0).length?Object.equal(d.data,d.lastCorrect)||(g+=1):Object.equal(e[f.last()],d.data)&&(g+=1),b=B(g,d.params,!0),b&&(o(c.my().data,b),c.my("redraw")),c.my().data)},val:function(a){return A(this,a)},valid:function(){var b=a(this).my().errors,c=0;for(var d in b)b[d]&&ib(b[d])?c++:jb(b[d])&&sb(b[d]).length&&c++;return!c},version:function(){return V}},Fb=Object.keys(Eb);a.my||(a.my={}),tb(a.my,{f:a.extend({},Db),tojson:Db.tojson,fromjson:Db.fromjson,radio:function(b,c){w(a(document),ib(b)?{channel:b,message:c}:b)},rules:Cb,locale:function(a){return ib(a)?(Y=a.toLowerCase(),Cb.params.locale=Y,void 0):Y},ajax:function(a){return mb(a)?yb=a:yb.apply(this,f(arguments,0))},cache:function(a,b){return mb(a)?zb=a:zb(a,b)},now:function(a){return mb(a)?(Ab=a,void 0):Ab()},require:function(a){return mb(a)?Bb=a:Bb.apply(this,f(arguments,0))},chain:function(){function a(){if(d.length&&e){var b,c=d.shift(),f=function(){a.delay(c[1])}.once();try{b=c[0]()}catch(g){f()}nb(b)?(b.then(f,f),f.delay(c[1])):f()}}var b=1,c=1e3,d=[],e=!1,f=function(e,f,g){d.push([e,f||b,g||c]),a()};return f.delay=function(a){return isNaN(a)||(b=(a-0).clamp(0,1e6)),b},f.timeout=function(a){return isNaN(a)||(c=(a-0).clamp(1,1e6)),c},f.start=function(){e=!0,a()},f.stop=function(){e=!1},f}(),version:function(){return V}}),a.my.version.toString=function(){return V},a.fn.my=function(b){var c;if(void 0===b)return this.data("my");if(ib(b)&&"{"==b.substr(0,1)){try{c=JSON.parse(b)}catch(d){}if(c)return Eb.init.apply(this,[c].add(f(arguments,1)))}return ib(b)&&Eb[b]?Eb[b].apply(this,f(arguments,1)):ib(b)&&zb(b,"exist")?Eb.init.apply(this,arguments):typeof b!==_&&b?(a.error("Method "+b+" does not exist on jQuery.my"),void 0):Eb.init.apply(this,arguments)},a(window).off(".my").on("radio.my",function(b,c){b.stopPropagation(),w(a(document),c)}).on("resize.my",function(){for(var a in pb)try{pb[a]()}catch(b){}}.debounce(67))}(jQuery),function(a){function b(a,b,c){if(i(b))return a+b;if(j(b))return c=e(!0,c,b),a;if(h(b)&&b.length>1&&i(b[1])){for(var d,k,m,n,o,p,q,r,s=b[0],t="",u=1;u<b.length;){if(i(b[u]))if(n=b[u].replace(/\s/g,""),m=n.split(/[\.#]/i),k=c.alias[m[0]]||m[0],d=n.substr(m[0].length),/^[a-z0-9]+(#[a-z0-9\-_]+)?(\.[a-z0-9\-_]+)*$/i.test(n)){q=l.tmpl[k]||l.tmpl[""],p={style:"","class":"",txt:""},r="";var v=j(b[u+1]);if(v){u+=1;for(o in b[u])""!==l.attnames[o]&&(p[l.attnames[o]||o]=b[u][o])}p.style||p["class"]||!c.styles[k]||(p.style=c.styles[k]),p.id||"#"!=d.to(1)||(p.id=d.from(1).split(".")[0]),!p["class"]&&/\./.test(d)&&(p["class"]=("#"==d.to(1)?d.substr(p.id.length+1):d).split(".").compact(!0).join(" "));for(o in p)r+=o+'="'+p[o]+'" ';if(v)for(o in b[u])""===l.attnames[o]&&(p[o]=b[u][o]);p.ext=r,!p.txt&&l.txt[k]&&(p.txt=l.txt[k](p)),p._tag=k,t+=typeof q==g?q(p)||"":typeof q==f?q.assign(p):""}else t+=b[u];u+=1}return t&&(t="<"+c.rowTag+' class="'+c.rowCss+'" '+(c.row?'style="width:'+c.row+"; ":"")+(c.label&&s?"padding-left:"+c.label+"; ":"")+'">'+(s?"<"+c.labelTag+' class="'+c.labelCss+'" '+(c.label?'style="display:inline-block;width:'+c.label+";margin-left:-"+c.label+'" ':"")+">"+s+"</"+c.labelTag+">":"")+t+"</"+c.rowTag+">"),a+t}return a}function c(a){var b=a;if(i(b)&&(b=b.split(/[\s,]/).compact(!0)),h(b)){for(var c={},d=0;d<b.length;d++){var e=b[d];if(j(e)){var f=Object.keys(e);1==f.length?c[f[0]]=e[f[0]]+"":c[e.id||e.key||e.name||""]=e.text||e.value||e.title||""}else c[e]=e+""}b=c}return j(b)?b:{}}function d(c,d){var f={},g=i(c)?c.lines().map(function(a){return a.replace(/^[\t\s]*/,"")}):c;return h(g)?(e(!0,f,l.params,d||{}),g.length?g.reduce(b.fill(void 0,void 0,f),""):""):j(g)?(a.extend(l,g),void 0):""}var e=a.extend,f="string",g="function",h=Object.isArray,i=(Object.isBoolean,Object.isString),j=Object.isObject,k=(Object.isNumber,Object.isRegExp,Object.isFunction,'<input type="'),l={tmpl:{num:k+'number" {ext}/>',inp:k+'text" {ext}/>',sli:k+'range" {ext}/>',dat:k+'date" {ext}/>',btn:k+'button" {ext}/>',pwd:k+'password" {ext}/>',but:"<button {ext}>{txt}</button>",div:"<div {ext}>{txt}</div>",spn:"<span {ext}>{txt}</span>",sel:"<select {ext}>{txt}</select>",mul:'<select {ext} multiple="multiple">{txt}</select>',txt:"<textarea {ext}>{txt}</textarea>",err:' <span class="my-error-tip {class}" style="{style}">{txt}</span>',msg:'<div class="my-error-tip {class}" style="{style}">{txt}</div>',val:function(a){if(!h(a.vals))return"";var b=e({style:"",css:""},a);return b.txt=a.vals.reduce(function(a,b){return a+"<span class=\"my-shortcut\" onclick=\"$(this).parents('.my-row').find('input,textarea').val($(this).text()).trigger('blur')\">"+b+"</span> "}," "),'<span class="my-shortcuts {css}" style="{style}">{txt}</span>'.assign(b)},"":"<{_tag} {ext}>{txt}</{_tag}>"},txt:{sel:function(a){if(!a.vals)return"";var b=c(a.vals);return Object.keys(b).reduce(function(a,c){return a+'<option value="'+c+'">'+b[c]+"</option>"},"")}},params:{styles:{num:"width:30%;",dat:"width:30%;",inp:"width:100%",pwd:"width:100%",but:"width:30%",txt:"width:100%;max-width:100%;min-height:1px;word-break:break-word;",err:"display:none",msg:"display:none"},alias:{number:"num",date:"dat",slider:"sli",textarea:"txt",input:"inp",span:"spn",select:"select",vals:"val"},row:"",rowTag:"div",rowCss:"my-row",label:"",labelTag:"span",labelCss:"my-label"},defaults:{id:"","class":"",style:"",placeholder:"",value:"",rows:1},attnames:{css:"class",plc:"placeholder",val:"value",txt:"",vals:"",tip:"title"}},m={init:function(b,c){return a(this).html(d(b,c))}};a.my||(a.my={}),a.my.formgen=d,a.fn.formgen=function(b){return i(b)&&m[b]?m[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?(a.error("Method "+b+" does not exist on jQuery.formgen"),void 0):m.init.apply(this,arguments)}}(jQuery),function(a){function b(b,c,d,e){var f,g,i,j,k,n,o;if("object"==typeof c&&c.jquery)c.is("img")&&(n=c,k=c.attr("alt")||c.attr("title")||c.data("text")||"",g=n[0].naturalWidth||n[0].width,f=n[0].naturalHeight||n[0].height,1>f&&(f=1),1>g&&(g=1),j=a(window).width()-90,i=a(window).height()-90,f>i&&(g=g*(i/f)|0,f=i),g>j&&(g=j,f=f*(j/g)|0),o=300>g?300:g,h(b,{source:"image",manifest:{init:function(a){a.html(this.HTML),a.on("click.my","img:eq(0)",function(){a.trigger("cancel")})},HTML:'<img src="" class="db" style="max-width:'+g+"px;max-height:"+f+'px"><h4 class="mt10"></h4>',ui:{"img:eq(0)":"img",h4:{bind:"text",css:{hide:function(a,b){return!b}}}}},data:{img:n.attr("src"),text:k},esc:!0,screen:!0,width:e||o,focus:!1,global:!0,z:"1995"},d));else if(m(c)&&c.manifest)h(b,c,d);else{if(!l(c))return null;h(b,{source:"html",manifest:{init:function(a){a.html(this.HTML)},HTML:c,ui:{"div:eq(0)":function(){}}},data:{},esc:!0,focus:!1,width:e},d)}return b}var c,d,e={},f="body",g=!1,h=a.extend,i={},j=a.my.f.indom,k=(Object.isArray,Object.isBoolean),l=Object.isString,m=Object.isObject,n=Object.isNumber,o=(Object.isRegExp,Object.isFunction);if(a.fn.modal&&o(a().emulateTransitionEnd)&&(d=a.fn.modal),a(document).off(".modal"),a(document).on("keydown.modal",function(a){var b,c,d=a.keyCode;if(!1!==g&&(13===d||27===d)){if(c=g.data("modal"),b=c.form,27==d&&(c.esc||Object.equal(b.data("my").initial,b.my("data"))))return g.modal(!0),!1;if(13==d&&c.enter)return function(a){a.modal()}.fill(g).delay(50),!1}}),o(a.my.f.getref(a,"my.modal.parent"))){var p=a.my.f.getref(a,"my.modal.parent")().attr("id");p&&(f="#"+p)}e.modal=function(c,d,e){var h,i={},j=a(f),l=j.find(">.my-modal-proxy"),m={global:!0,screen:!0,done:o(d)?d:void 0,z:"1995"};return k(c)||null==c?l.modal(c):(h=a.Deferred(),b(i,c,m,e)?g?h.reject("Locked").promise():(l.length||(l=a('<div class="my-modal-proxy"></div>').prependTo(j),l.css({position:"absolute",top:"0",left:"0",margin:"0",padding:"0",width:"1px",height:"0"})),l.modal(i)):h.reject("Invalid data").promise())},e.modal.loading=function(b){a(f).find(">.my-modal").toggleClass("my-modal-loading",!!b)},e.modal.parent=function(b){return b&&a(b).length?(f=b,void 0):a(f)},e.modal.parentBack=function(b){return b&&a(b).length?(c=b,void 0):a(c||f)},e.modal.visible=function(){return!!g},a.my||(a.my={}),a.my.modal=e.modal,a.fn.modal=function(e,p,q){function r(a){if(x=K.form,z=K.bg,y=K.root,I=K.done,B=x.my("data"),C=!1,a){try{I.call(x.my("manifest"),null,null)}catch(b){}try{j(x)?u():""}catch(b){}if(j(F)&&F.removeData("modal"),i[K.cid])try{i[K.cid].reject("Cancelled")}catch(b){}delete i[K.cid],K=null}else{try{C=I.call(x.my("manifest"),x.my("valid")?null:x.my("errors"),B)}catch(b){}if(!C){try{j(x)?u():""}catch(b){}j(F)&&F.removeData("modal"),function(){if(i[K.cid])try{i[K.cid].resolve(B)}catch(a){}delete i[K.cid],K=null}.delay(0)}}}function s(){var b,c,d=window,e=!!K.global,f=y.offset(),g=F.offset(),h=y.scrollTop();K.pos={px:f.left,py:f.top,pw:y.outerWidth(),ph:y.outerHeight(),ox:g.left,oy:g.top,ow:F.outerWidth(),oh:F.outerHeight(),ww:c,wh:b};var i=1*(K.x.match(/\-?\d+(\.\d+)?/)||[0])[0],j=1*(K.y.match(/\-?\d+(\.\d+)?/)||[0])[0],k=K.x.has("left")?-1:K.x.has("right")?1:0,l=K.y.has("top")?-1:K.y.has("bottom")?1:0,m=K.pos.ox+K.pos.ow/2-K.pos.px,o=K.pos.oy+K.pos.oh/2-K.pos.py;if(e&&(K.pos.wh=b=d.innerHeight||a(d).height(),K.pos.ww=c=d.innerWidth||a(d).width(),m=c/2,o=b/2.5),i=K.x.has("%")?K.pos.ow/100*i:i,j=K.y.has("%")?K.pos.oh/100*j:j,K.pos.pix=m,K.pos.piy=o,m=m+k*(K.pos.ow/2)+i*(k>0?-1:1)-(K.width+G)*(k+1)/2,e?(o=(b-K.height-20)/3,10>o&&(o=10)):o=o+l*(K.pos.oh/2)+j*(l>0?-1:1)-(K.height||0)*(l+1)/2,m=m.round(1),o=(o+h).round(1),K.pos.vx=m,K.pos.vy=o,K.bound!==!1&&!K.global){var p=(n(K.bound)?K.bound:0).clamp(-100,100);K.pos.pw-2*p<K.width+G?K.pos.vx=-(K.width+G-K.pos.pw)/2:K.pos.vx+K.width+G>K.pos.pw-p?K.pos.vx=K.pos.pw-p-K.width-G:K.pos.vx<p&&(K.pos.vx=p),K.pos.ph-2*p<K.height?(K.pos.vy=p,K.height=K.pos.ph-2*p):K.pos.vy+K.height>K.pos.ph-p?K.pos.vy=K.pos.ph-p-K.height:K.pos.vy<p&&(K.pos.vy=p)}}function t(b){if(b||(K.height=w.outerHeight(),"manifest"!==K.source&&(K.width=w.width()),s()),w.css({width:K.width+G+"px",display:"block"}),K.global)w.css({left:"50%","margin-left":"-"+((K.width+G)/2).round(0)+"px"});else if(w.css({left:K.pos.vx+"px"}),K.nose){a("style#my-modal-style-"+K.cid).length||w.append('<style id="my-modal-style-'+K.cid+'"></style>');var c="",d=a("style#my-modal-style-"+K.cid);"top"==K.nose||"bottom"==K.nose?(c+="div.my-modal-"+K.cid+".nose-"+K.nose+":before {left:"+(K.pos.ox-K.pos.px+K.pos.ow/2-K.pos.vx)+"px!important;}",d.text(c)):("left"==K.nose||"right"==K.nose)&&(c+="div.my-modal-"+K.cid+".nose-"+K.nose+":before {top:"+(K.pos.oy-K.pos.py+K.pos.oh/2-K.pos.vy)+"px!important;}",d.text(c))}K.screen?K.global?(z.css({top:0,left:0,width:"100%",height:"100%",display:"block",position:"fixed","z-index":K.z-1}),z.css(l(K.screen)?{background:K.screen?K.screen:"rgba(18,41,72,0.88)"}:{background:K.screen?"rgba(18,41,72,0.88)":""})):z.css({top:0,left:0,position:"absolute",width:z.parent().outerWidth()+"px",height:z.parent().outerHeight()+"px",display:"block",background:l(K.screen)?K.screen:"rgba(255,255,255,0.6)","z-index":K.z-1}):z.length&&z.hide(),K.height>K.pos.wh?(w.height(K.pos.wh-30),x.css({"overflow-y":"scroll"})):x.css({"overflow-y":""}),w.animate({top:K.pos.vy+"px",opacity:"1"},K.animate)}function u(){try{x.my("remove")}catch(b){}try{y.data("modals")[K.cid]=null}catch(b){}x.parent().off(".my").remove(),j(z)&&z.off(".my"+K.cid),K.screen&&j(z)&&function(a){a&&g||z.hide(),a&&!g&&z.css({background:"rgba(18,41,72,0.88)"})}.delay(50,K.global),K.global&&(g=!1,a(document.body).css({overflow:""}))}function v(a){try{I(null,null)}catch(b){}(function(){D.reject(a)}).delay(0)}if(d){if(void 0===e&&void 0===p&&void 0===q)return d.call(this);if(m(e)&&(e.hasOwnProperty("backdrop")||e.hasOwnProperty("keyborad")||e.hasOwnProperty("show")))return d.call(this,e,p);if(l(e)&&/^(toggle|show|hide|handleUpdate)$/.test(e))return d.call(this,e,p)}var w,x,y,z,A,B,C,D=a.Deferred(),E={},F=this,G=0,H=0,I=o(p)?p:function(){return!1},J=m(e)?e:{},K=F.data("modal");if(h(F,D.promise()),K){if(null==e||k(e))return r(e),F;if(J)return v("Locked"),F}return F.is(":visible")?(J=b(E,e,{}))?J.global&&g?(v("Locked"),F):(K=h({type:"DOM",source:"manifest",form:null,modal:null,root:null,bgroot:null,caller:F,manifest:{},data:{},global:!1,screen:!1,drag:!1,focus:!0,close:!0,silent:!0,esc:!1,enter:!1,bound:!1,hardClose:!0,nose:"",width:q||300,height:null,x:"0",y:"0",z:"1901",background:"white",css:"",animate:200},J,{promise:D.promise(),cid:Number.random(268435456,4294967295).toString(16)}),K.done=o(K.done)?K.done:I,l(K.align)&&K.align&&(K.x=(K.align.match(/(left|right):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0],K.y=(K.align.match(/(top|bottom):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0]),K.width=1*(a.my.f.getref(l(K.manifest)?a.my.cache(K.manifest):K.manifest,"params.width")||K.width),K.type="DOM",F.hasClass("my-form")?(K.type="form",K.root=K.root||F):F.data("my")?(K.type="control",K.root=K.root||F.my().root):(K.root=K.root||F.parents(".my-form").eq(0),K.root.length||(K.root=a(f))),K.global?(K.root=a(f),K.bgroot=a(c||f)):K.bgroot=K.bgroot?a(K.bgroot):K.root,y=K.root,y.data("modals")||y.data("modals",{}),s(),w=a('<div class="my-modal my-modal-init my-modal-'+(K.global?"fullscreen ":"overlay ")+K.css+(K.nose?" nose-"+K.nose:"")+'"></div>'),K.root.find(">.my-modal").length?w.insertAfter(K.root.find(">.my-modal").last()):w.prependTo(K.root),w.addClass("my-modal-"+K.cid),G=w.outerWidth(),H=w.outerHeight(),w.hide(),w.html('<div class="my-modal-form"></div>'),x=w.find(".my-modal-form"),K.close&&(A=a(l(K.close)?K.close:'<div class="my-modal-close" title="Close">×</div>').prependTo(w).on("click.my",function(){r(K.hardClose)}),A.css({"z-index":("+"===(K.z+"").to(1)?"+":"")+(1*K.z+1)})),z=K.bgroot.find(">.my-modal-screen"),K.screen&&(z.length||(z=a('<div class="my-modal-screen" style="display:none;"></div>').prependTo(K.bgroot)),K.esc&&z.on("click.my"+K.cid,function(){F.modal(!0)}),z.toggleClass("my-modal-screen-global",!!K.global)),F.data("modal",K),K.silent&&w.on("change.my",function(){return!1}),w.css({display:"block",height:"none",opacity:"0.005","z-index":K.z,width:"auto"}),w.css(K.global?{position:"fixed",left:"50%",top:K.pos.vy+"px",display:"block",height:"none",opacity:"0.005","z-index":K.z,width:"auto","margin-left":"-"+((K.width+G)/2).round(0)+"px"}:{position:"absolute",left:K.pos.vx+"px",top:K.pos.vy+"px",display:"block",height:"none",opacity:"0.005","z-index":K.z,width:"auto"}),x.my(K.manifest,K.data).then(function(){var b,c,d,e,f;if(h(K,{form:x,bg:z,cancel:function(){r(!0)},commit:function(){r()}}),w.data("modal",K),K.height=w.outerHeight(),"manifest"!==K.source&&(K.width=w.width()),s(),w.css({top:K.pos.vy+"px"}),t(!0),w.removeClass("my-modal-init"),y.data("modals")[K.cid]=K,i[K.cid]=D,x.on("commit.my",function(){return K.commit.delay(30),!1}).on("cancel.my",function(){return K.cancel.delay(30),!1}),w.on("layout.my",function(){t()}.debounce(30)),K.global&&(g=F,a(document.body).css({overflow:"hidden"})),K.global||!K.esc&&!K.enter||x.on("keydown.my",function(b){var c=b.keyCode;return 27==c&&K.esc?(K.cancel(),!1):13==c&&K.enter&&!a(b.target).is("textarea")?(K.commit.delay(50),!1):void 0}),K.focus===!0){e=!1,f=K.manifest.ui;for(d in f)e||(c=x.find(d),c.length&&c.is("input, textarea","button")&&(e=!0,c.focus()))}else l(K.focus)&&x.find(K.focus).focus();if(b=x.find("img").filter(function(){return""!=a(this).attr("src")}),b.length){var j=function(){"manifest"!==K.source&&w.css({width:"auto"}),t()}.after(b.length);b.each(function(){a(this).bind("load",j)})}K.drag&&a.fn.draggable&&(l(K.drag)?w.draggable({handle:K.drag}):w.draggable(),K.nose&&w.on("dragstart.my",function(){w.removeClass("nose-"+K.nose)})),w.on("mousedown.my",function(b){var c,d=[],e=a(b.currentTarget),f=e.parent(),g=+e.css("z-index"),h=g;f.length&&(c=f.find(">.my-modal").each(function(c,e){var f=+a(e).css("z-index");e!=b.currentTarget&&f>=g&&d.push([f,a(e)]),f>h&&(h=f)}),d.forEach(function(a){a[1].css("z-index",a[0]-1+"")}),e.css("z-index",h+""))}),D.notify("Ready")}).fail(function(a){try{u()}catch(b){}F.data("modal",null),D.reject(a)}),F):(v("Invalid data"),F):(v("Object must be visible"),F)}}(jQuery);
|