From 00b6c4061e938f8fbfbec66f47fc394615ec91bc Mon Sep 17 00:00:00 2001 From: ermouth Date: Fri, 11 Sep 2015 00:36:14 +0300 Subject: [PATCH] 1.1.9 Minor bug fix --- Release/1.1/jquerymy-1.1.9.js | 4206 +++++++++++++++++++++++++++++ Release/1.1/jquerymy-1.1.9.min.js | 5 + Release/jquery.my.last.js | 7 +- bower.json | 2 +- jquerymy.js | 179 +- jquerymy.min.js | 7 +- my.jquery.json | 2 +- package.json | 2 +- 8 files changed, 4330 insertions(+), 80 deletions(-) create mode 100644 Release/1.1/jquerymy-1.1.9.js create mode 100644 Release/1.1/jquerymy-1.1.9.min.js diff --git a/Release/1.1/jquerymy-1.1.9.js b/Release/1.1/jquerymy-1.1.9.js new file mode 100644 index 0000000..d27af56 --- /dev/null +++ b/Release/1.1/jquerymy-1.1.9.js @@ -0,0 +1,4206 @@ +/* + * jQuery.my 1.1.9 + * Requires jQuery 1.11.0+, SugarJS 1.3.9-1.4.x + * + * — js2txt removes 'anonymous' name from functions + * — $.my.f.unmask receives 3 args as well as 2 + * — modal positioned correctly in scrollable container + * — lists redrawn are rebuild to be bound with objects newly passed + * — ... it means undo works on lists without bugs. + * + * More details at jquerymy.com + * + * (c) @ermouth, thanks @carpogoryanin, @ftescht + * 2015-09-10 + */ + +;(function ($) {var _version = "jQuery.my 1.1.9"; + + // Some shortcuts and constants + var lang = "en", + wURL = window.URL || window.webkitURL, + ie8 = !document.addEventListener, + + isA = Object.isArray, + isB = Object.isBoolean, + isS = Object.isString, + isO = Object.isObject, + isN = Object.isNumber, + isR = Object.isRegExp, + isF = Object.isFunction, + Keys = Object.keys, + + forms = _getref($,"my.f.repo")? $.my.f.repo():{_src:{}, _name:"Default manifest cache"}, + restyles = _getref($,"my.f.restyles")? $.my.f.restyles():{}, + + $E = $.extend, T = $.type, N = null, TMP, + n = function (o) {return o!==null && o!==undefined;}, + d8 = "{yyyy}-{MM}-{dd}", h24="{HH}:{mm}", + Ob = "object", Da = "data", Ar = "array", + St = "string", Fu = "function", Ch = "change", + rthis = /^this\./, + + isP = function (a) { + // detects promise + return !!(null!=a&&(isO(a)||a.jquery)&&isF(a.then)&&isF(a.fail)&&isF(a.state)); + }; + + //======================================= + + function _ERR () { if (window.console) console.error.apply (console, arguments); } + function _CON () { if (window.console) console.log.apply (console, arguments); } + + //======================================= + // Manifest repo getter/setter and helpers + + var _cache = function _localCache (A1, A2) { + // ( no args ) – returns all forms obj container + // ({manifest}, {container}) – caches form in container, id must be defined, return form or null + // ({manifest}) – caches form in local container, id must be defined + // ("form.Id", "exist") – true/false + // ("form.Id", {container}) – get from container + // ("form.Id") – get from local cache + var ref, obj; + if (isS(A1)) { + ref=A1; + obj = _getref(isO(A2)?A2:forms, ref); + if ("exist"===A2) return isO(obj); + return !obj?null:Object.clone(obj,true); + } else if (isO(A1)){ + obj = _putmanifest (A1, A2); + if (!isO(obj)) { + return null; + } + return obj; + } else if (undefined===A1) { + return forms._src; + } else if (null===A1) { + return Object.reject(forms,/^_/); + }else return null; + }; + + // - - - - - - - - - - - - - - - - - - - - + + var _ajax = $.ajax; + + // - - - - - - - - - - - - - - - - - - - - + + function _getref (obj, ref) { + // Gets branch of obj by string ref like "data.list.items.1" + // or array ref like ["data","list","items","1"] + return (isS(ref) ?ref.split("."):isA(ref)?ref:[""]) + .reduce(function (a,b) { + if (null != a) { + if (/=/.test(b)) { + var q = b.split("=",2); + if (isO(a)) { + return Object.values(a).find(function(elt){ + if (!isO(elt) && !isA(elt)) return false; + return (elt[q[0]] == q[1]); + }); + } else if (isA(a)) { + return a.find(function(elt){ + if (!isO(elt) && !isA(elt)) return false; + return (elt[q[0]] == q[1]); + }); + } else return undefined; + } + else if (null != a && null != a[b]) { + return a[b]; + } + } + return undefined; + }, obj); + } + + // - - - - - - - - - - - - - - - - - - - - + + function _manifest (manifest, ref) { + // Dereferences pointer to form component, + // manifest is caller manifest obj, + // internal function + var t, ext; + if (isO(ref)) return ref; + else if (isS(ref)) { + + //try to find it on manifest + t = _getref(manifest, ref); + + //then in local repo as original + if (null==t) t = Object.clone(forms._src[ref],true); + + //then in local repo as part of component + if (null==t) { + t = _getref(forms, ref); + if (isO(t) && isO(t._self)) t=Object.clone(t._self,true); + else if (isO(t)) t = Object.clone(t,true); + } + + //then in ext repo as part of component + if (null==t && _getref(manifest,"params.cache")) { + ext = _getref(manifest,"params.cache"); + if (isF(ext)) t = ext(ref); + else if (isO(ext)) t = _cache(ref, ext); + + if (isO(t)){ + if (isO(t._self)) t=Object.clone(t._self,true); + Object.merge(t, {params:{cache:ext}}, true); + } + } + + if (null!=t && isO(t)) { + ext = ext||_getref(manifest,"params.cache"); + if (ext) Object.merge(t, {params:{cache:ext}}, true); + return t; + } + else throw "Component "+ref+" not found."; + + } else if (isF(ref)) { + return ref.apply(manifest, Array.prototype.slice.call(arguments, 2)); + } else return null; + } + + // - - - - - - - - - - - - - - - - - - - - + + function _putmanifest (obj0, root0) { + // Mounts obj to root in a branch, defined in + // obj.id property. If id =="x.y.z", root will be + // deep extended with {x:{y:{z:obj}}}. + // obj also is unjsonned and extended with _self ref, + // which point to original version of obj. + + //Returns direct link to entire branch obj or string error. + + var i, j, keys, file, root=root0||forms, obj=obj0, path, id, prev, res; + + if (!(isO(root) && isO(obj) && isO(obj.ui) && isS(obj.id))) + return "Can’t save manifest into cache, invalid arguments."; + + if (!root.hasOwnProperty("_src")) root._src={}; + + id = obj.id; + + try { + obj=Object.clone(obj0, true); + } + catch (e) { + return "Can’t save circular-referencing object into cache."; + } + + //unwind string defs of functions + try { + if (!obj.params || (obj.params && !obj.params.strict)) _unjson(obj, true); + } + catch (e) { + return "Invalid manifest, parse error."; + } + + //blobify files + i = _files2urls (obj); + if (isS(i)) { + _ERR(i); + return i; + } + + //mark manifest as unjsonned + Object.merge(obj,{params:{strict:true}}, true); + // save it + root._src[id] = obj; + + + if (prev = f.mask(root, id)) { + if (prev.params && prev.params.protect) return "Can’t save manifest into cache over protected one."; + else { + // Remove prev version + if (prev._self) delete prev._self; + $.extend(!0, root, f.unmask("",id)); + } + } + + // Mount new version + $.extend (!0, root, f.unmask(obj, id)); + + // Re-mount sub-manifests if any + keys = Object + .keys(root._src) + .filter(function(e){ + return e.startsWith(id+'.'); + }); + keys.sort(); + keys.forEach(function(id){ + var prev; + if (prev=f.mask(root, id)) { + // Remove subform if any + if (prev._self) delete prev._self; + $.extend (!0, root, f.unmask("",id)); + } + // Re-mount version from repo + $.extend (!0, root, f.unmask(root._src[id], id)); + }); + + // Mount _self link to uncompiled manifest + res = _getref(root,id); + + if (ie8) res["_self"] = root._src[id]; + else Object.defineProperty(res, "_self", { + get: function () { return root._src[id]; }, + set: function () { throw "Can’t change manifest cache entry directly.";}, + enumerable : false, + configurable : true + }); + + // End manifest + + return res; + } + + + function _files2urls (obj) { + // Unwinds base64 representations of attached binaries + // into Blobs and objectURLs + var i, flist = [], file; + if (isO(obj.files) && Object.size(obj.files)) { + //blobify files + for (i in obj.files) { + file = obj.files[i]; + if (isO(file)) { + if (isS(file.data) && !file.url) { + if (wURL) { + try { + f.base642blob(file.data,function(res){ + file.blob = res; + file.url = wURL.createObjectURL(file.blob); + },(file.content_type||file.mime)); + flist.push(i); + } catch(e) { + return "Invalid base64 data in files/"+i+"."; + } + } else { + //ie8-9 fallback + file.url = 'data:'+(file.content_type||file.mime)+';base64,'+file.data; + flist.push(i); + } + } + } + else return "Non-object member "+i+" in files section."; + } + } + return flist; + } + + + + //######################################################## + // Storage of rules defined by cascading selectors + // very similar to css. Leafs are processors + // or processing rules for this type of node + + var MY = { + + + //getter and setter functions for different types of nodes + + vals : { + + ".my-form": function ($o, v) { + //object is jQuery.my instance + if ($o && $o.my ) {var d = $o.my(Da); return Object.equal(d,v)?d:$o.my(Da, v, true);} + else return v||N; + }, + + ".hasDatepicker":function ($o,v) { + //object has jQ UI datepicker + if(n(v)) $o.datepicker("setDate", ((v=="")?v:Date.create(v))); + var date = $o.datepicker("getDate"); + return (date?date.format(d8):""); + }, + + ".my-tags": function ($o,v) { + //object is jQ tags control + if (n(v)) { + if (isS(v) || isN(v)) $o.tags(Da,[v+""]); + else if (isA(v)) $o.tags(Da,v); + } + return $o.tags(Da); + }, + + ".ui-draggable": function ($o,v) { + //object is jQ UI draggable + if (n(v) && isO(v)) { + var c = {}; + if (!isNaN(v.left)) c.left = Number(v.left).ceil(2)+"px"; + if (!isNaN(v.top)) c.top = Number(v.top).ceil(2)+"px"; + if (c.left || c.top) $o.css(c); + } + var p = $o.position(); + return { + left:((v&&!isNaN(v.left))?(v.left*1).ceil(2):p.left.ceil(2)), + top:((v&&!isNaN(v.top))?(v.top*1).ceil(2):p.top.ceil(2)) + }; + }, + + ".my-form-list": function ($o,list) { + //object is list of forms + var i,old,xold,mod,eq,ctr = 0, + sP = "ui-sortable", sPlc= "."+sP+"-placeholder", + od = $o.data("formlist")||{}, + gen = od.generator||{}, + itemSel = gen.selector||">.my-form", + tmpl = gen.template||"
", + tmplIsVar = /\{/.test(tmpl), + hasher = gen.hash|| f.sdbmCode, + ider = gen.id|| f.sdbmCode, + extHasher = gen.ext, + delay = gen.delay||50, + sortable = $o.is("."+sP), + sorting = !!$o.children(sPlc).size(), + result=[], redraw = [], + $n, $drag, now = Date.now(); + var $c = sortable?$o.find($o.sortable("option","items")):$o.find(itemSel); + + if (n(list) && isA(list)) { + //return list passed if dragging taking place + if (sorting) return list; + // first we must estimate + // if putting new data over old + // changes anything + old= []; xold={}; + $c.each(function (i) { + var $x = $(this), xd = $x.data("my"), dd; + if (xd) { + old.push(xd.data); + if (dd = $x.data("formlist")) { + xold[dd.oid] = xd.data; + } + } + }); + + //fast compare + eq=false; + if (old && old.length===list.length) for (eq=true, i=0;i idx and hashes + for (i=0;i1.4*delay) + || now-gen.stamp > 100 + || !gen.stashed + || (gen.stashed.length !== $c.size()-(sorting?1:0)) + ) { + + if (sorting) $drag = $o.find('>.'+sP+'-helper'); + var ri=0; + $c.each(function (idx, elt) { + var $x = $(elt), xd, xf, chash, dirty = false; + if (!sorting || !$x.hasClass(sP+'-helper')) { + if (sorting && $x.hasClass(sP + '-placeholder')) $x = $drag; + xd = $x.data("my"); + xf = $x.data("formlist"); + if (xd && xf) { + result.push(xd.data); + if (ri != xf.index) { + xf.index = ri; + dirty = !0; + } + if (extHasher) { + chash = hasher(xd.data, ri)+""; + if (chash !== xf.hash) { + xf.hash = chash; + dirty = !0; + } + } + ri += 1; + if (dirty) redraw.push($x); + } + } + }); + for (i=0;i=0; i--) { + var j = f.sdbmCode(v[i]); + if (w[j]) { + w[j].prependTo($o).show();z[j]=true; + if (a.indexOf(v[i])==-1) a.push(v[i]); + } + } + a=a.reverse(); + for (i in w) if (!z[i]) w[i].hide(); + } else { + var $p = $o.find(sPlaceholder), $q = $o.eq(0); + if ($p.size()!=0) { + + //if placeholder state changed saving new data + if ($q.my()[sP] != $p.position().left+""+$p.position().top) { + $c = $c.filter(":visible:not(:disabled, .ui-state-disabled, .ui-sortable-helper)"); + $m = $o.find($o.sortable("option","items")).filter(".ui-sortable-helper"); + $c.each(function () { + var $x = $(this); + if ($x.is(".ui-sortable-placeholder")) {a.push(f.extval($m));} + else a.push(f.extval($x)); + }); + //caching placeholder state and data retrieved + $q.my()[sP] = $p.position().left+""+$p.position().top; + $q.my()[sP+"1"] = a; + } else a = $q.my()[sP+"1"]; + if (a==N) $c.each(function () {a.push(f.extval($(this)));}); + } else { + $c = $o.find($o.sortable("option","items")) + .filter(":visible:not(:disabled, .ui-state-disabled)"); + $c.each(function () {a.push(f.extval($(this)));}); + } + } + return a; + }, + + "input[type=date]":function ($o,v) { + //object is date input + if(n(v)) { + if (v!="") d = Date.create(v).format(d8); else d = ""; + if (isS(d) && !/Invalid/.test(d)) $o.val(d); + return d; + } + var d = $o.val(); + return (d!=""?Date.create(d).format(d8):""); + }, + + "input[type=time]":function ($o,v) { + //object is time input + if(n(v)) { + if (v!="") d = Date.create(v).format(h24); else d = ""; + if (isS(d) && !/Invalid/.test(d)) $o.val(d); + return d; + } + var d = $o.val(); + return (d!=""?Date.create(d).format(h24):""); + }, + + + "input":{ + "[type='text'],[type='number'],[type='search'],[type='hidden'],[type='password'],[type='button'],[type='range'],:not([type])":{ + //nearly all main input types and button + + ".ui-slider-input": function ($o,v) { + //input with jQ UI slider() applied + if (n(v)) $o.val(v).slider("refresh"); + }, + + ".tagstrip input.value": function ($o,v) { + //input of tagstrip() applied + if (n(v)) $o.val(v).trigger("update"); + }, + + "div.select2-container+input": function ($o, v) { + //select2 + if (n(v) && JSON.stringify(v)!== JSON.stringify($o.select2("val"))) + $o.select2("val", (isA(v)?v:[v])); + return $o.select2("val"); + }, + + "": function ($o,v) {if(n(v)) $o.val(v+"");} + }, + + ":radio":function ($o,v) { + //radio buttons + var pos = -1; + if (n(v)) { + $o.each(function (ind) { + var val = $(this).val(); + if ((v+"")===(val+"")) pos=ind; + }); + var jqcheck = $o.eq(0).checkboxradio; + if (jqcheck) $o.each(function (ind){ + var $x = $(this); + if (pos!=ind && $x.is(":checked")) + $x.prop("checked",false).checkboxradio("refresh"); + }); + if (pos>-1) { + var $x = $o.eq(pos); + if (!$x.is(":checked")) { + $x.prop("checked",true); + if (jqcheck) $x.checkboxradio("refresh"); + } + } else if (!jqcheck) $o.each(function () { $(this).prop("checked",false); }); + } + if (pos==-1) for (var ind=0; ind<$o.size(); ind++) { + if ($o.eq(ind).is(":checked")) pos=ind; + } + return pos!=-1?$o.eq(pos).val():""; + }, + + ":checkbox": function ($o, v0) { + //checkbox + var pos = -1, v = v0, a = []; + if (n(v)) { + if (!isA(v)) v = [v0]; + var jqcheck = !!$o.eq(0).checkboxradio; + $o.each(function (ind) { + var $x = $(this), val = $x.val(), on = $x.is(":checked"); + if (v.indexOf(val)!=-1) { + a.push(val); + if (!on) $x.prop("checked", true); + } else if (on) $x.prop("checked", false); + if (jqcheck) $x.checkboxradio("refresh"); + }); + } else { + $o.each(function () { + var $x = $(this); + if ($x.is(":checked")) a.push($x.val()); + }); + } + return a; + } + }, + + "select": { + ".ui-slider-switch": function ($o,v) { + //on-off in jQ Mobile + if (n(v)) { + $o.val(v+""); + $o.slider("refresh"); + } + }, + "div.select2-container+select":{ + "[multiple]": function ($o, v) { + if (n(v)) $o.select2("val", (isA(v)?v:[v])); + return $o.select2("val"); + }, + "":function ($o, v) { + if (n(v)) $o.select2("val", v+""); + return $o.select2("val"); + } + }, + "[multiple]": function ($o,v) { + if (n(v)) { + $o.val(v,[]); + if ($o.selectmenu && ($o.data("uiSelectmenu") || $o.data("selectmenu"))) $o.selectmenu("refresh",true); + //the only way to check if we have jQ UI selectmenu() attached + } + }, + "": function ($o,v) { + if (n(v)) { + $o.val(v+""); + if ($o.selectmenu && ($o.data("uiSelectmenu") || $o.data("selectmenu"))) $o.selectmenu("refresh",true); + } + } + }, + + "textarea": { + ".my-cleditor":function ($o,v) { + if(n(v)) $o.val(v).cleditor()[0].updateFrame(); + return $o.val(); + }, + "div.redactor_box textarea,.redactor": function ($o,v) { + var r9 = $o.hasClass('my-redactor-9'); + if(n(v)) { + if(r9) $o.redactor('set', v); + else $o.setCode(v, false); + return v; + } + return r9 ? $o.redactor('get') : $o.getCode(); + }, + ".my-codemirror":function ($o,v){ + if (n(v)) { + $o[0].nextSibling.CodeMirror.setValue(v); + return v; + } + return $o[0].nextSibling.CodeMirror.getValue(); + }, + "":function ($o,v) {if(n(v)) $o.val(v+"");} + }, + + "fieldset,form,section,footer,aside,.my-container": function ($o, v) { + //object is class-manageable container, + //value is an array of css rules + var clist = Array.prototype.slice.call($o[0],0).sort(), + list = v; + if (n(v)) { + if (isS(v)) list = v.split(/[,\s]+/).compact(true); + if (isA(list)) { + list.sort(); + if (list.join(" ")!==clist.join(" ")) { + $o.atrr("css", list.join(" ")); + clist = list; + } + } + } + return clist; + }, + + "div,span,a,p,li,td,th,h1,h2,h3,h4,h5,h6":{ + ".ui-slider":function ($o, v){ + if(n(v)) $o.slider("option",$o.slider("option","values")?"values":"value", f.clone(v)); + return f.clone($o.slider("option","values")||$o.slider("option","value")||0); + }, + ".ui-buttonset": function ($o,v) { + //jQ UI buttonset () + if (!n(v)) { + var jor = $o.find(":radio:checked"); + if (jor.size() && jor.button) return jor.val()||jor.button("option", "label") ; + } else if (v!="") { + var jon = N; + $o.find(":radio").each(function () { + jon=( ($(this).val()||$(this).button("option", "label"))==v?$(this):jon ); + }); + if (jon) { + jon.attr("checked",true); + $o.buttonset("refresh"); + return v; + } + } + $o.find(":radio:checked").attr("checked",false); + $o.buttonset("refresh"); + return ""; + }, + ".ace_editor":function ($o,v) { + if(n(v)) ace.edit($o[0]).setValue(v); + return ace.edit($o[0]).getValue(v); + }, + "": function ($o,v) { + if(n(v)) $o.html(v); + return $o.html(); + } + }, + "pre,code":function ($o,v) { + if(n(v)) $o.html(v); + return $o.html(); + }, + "img":function ($o,v) { + if (n(v)) $o.attr("src",v); + return $o.attr("src")||""; + }, + "":function ($o,v) { + if (n(v)) $o.html(v); + return $o.html()||$o.text()||String($o.val())||""; + } + }, + + + //messages + //######################################################## + + msg:{ + "":{en:"Invalid input", ru:(TMP="Неверное значение")}, + + formError:{en:"Form error",ru:"Ошибка формы"}, + initFailed:{ + en:'

Form init failed

', + ru:'

Ошибка инициализации формы

' + }, + + badInput:{en:"Invalid input", ru:TMP}, + 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:"Обязательное поле"} + }, + + + // Different controls’ events to watch for + // ######################################################## + + 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"+(navigator.appName.to(5)==="Micro"?" keyup.my":" input.my"), + "":"check.my" + }, + + // Functions retrieving container for different controls + // ######################################################## + + containers: { + "*[data-role='fieldcontain'] *":{ //jQuery Mobile + "input,textarea,select,button,:radio": function ($o) { + return $o.parents('[data-role="fieldcontain"]').eq(0); + } + }, + ".tagstrip *.value": function ($o){ //$.tagstrip() + return $o.parents('.tagstrip').eq(0); + }, + "div.redactor_box textarea":function ($o){ + return $o.parents('div.redactor_box').eq(0).parent(); + }, + ".my-tags,.hasDatepicker,.ui-widget,input,textarea,select,button" :{ + ".my-cleditor": function ($o) { + return $o.parents('div.cleditorMain').eq(0).parent(); + }, + "": function ($o) { + var p = $o[0].parentNode, t = p.nodeName; + if (/^(div|span|a|p|form|fieldset|li|ul|td|th|h\d)$/i.test(t)) return $(p); + else return $o.parents('div,span,a,p,form,fieldset,li,ul,td,th,h1,h2,h3,h4,h5,h6').eq(0); + } + }, + "": function ($o) {return $o;} + + }, + + // Disablers and enablers + // ######################################################## + + offon: { //if x==true disables control else enables + ".ace_editor": function (x,$o) {ace.edit($o[0]).setReadOnly(x);}, + ".ui-selectable": function (x,$o) {f.jquix($o,"selectable",x);}, + ".ui-slider": function (x,$o) {f.jquix($o,"slider",x);}, + ".ui-draggable": function (x,$o) {f.jquix($o,"draggable",x);}, + ".ui-buttonset": function (x,$o) {f.jquix($o,"buttonset",x);}, + ".hasDatepicker": function (x,$o) {f.jquix($o,"datepicker",x);}, + ".my-form":function (x,$o){$o.my("disabled", !!x);}, + "div.select2-container+input,div.select2-container+select": + function (x,$o) {f.jquix($o,"select2",x);}, + ".my-cleditor": function (x,$o) { $o.cleditor()[0].disable(!!x);}, + "": function (x, $o) {$o.attr("disabled", !!x);} + }, + + // Destructors + // ######################################################## + destroy:{ + ".hasDatepicker":function ($o){$o.datepicker("destroy");}, + ".ui-slider":function ($o){$o.slider("destroy");}, + ".ui-sortable":{ + ".my-form-list":function ($o){ + $o.find(">.my-form").each(function () { + $(this).my("remove"); + }); + $o.removeClass("my-form-list"); + $o.sortable("destroy"); + }, + "":function ($o){$o.sortable("destroy");} + }, + ".my-form-list":function ($o){ + $o.find(">.my-form").each(function () { + $(this).my("remove"); + }); + + }, + ".ui-draggable":function ($o){$o.draggable("destroy");}, + ".my-redactor-8":function ($o){ + $o.destroyEditor(); + $o.removeClass("my-redactor-8"); + }, + "div.select2-container+input,div.select2-container+select": + function ($o){$o.select2('destroy');}, + ".my-form": function ($o) {$o.my("remove");}, + "textarea": { + ".my-codemirror": function ($o) { + $o[0].nextSibling.CodeMirror.toTextArea(); + $o.removeClass("my-codemirror"); + } + } + } + }; + + // Default values for .params section of manifest + // ######################################################## + + MY.params = { + container:function ($o) { // container getter + return _traverse($o, MY.containers)($o); + }, + change:N, + recalcDepth:2, // depth of dependencies resolver tree + delay:0, // default delay of bind invocation + strict:false, // if true form assumed unjsonned + restyle:-1, // delay of '); + } + } + + //----------------------------------------------------- + + // prepare files section + function _files () { + var i, pi = $.Deferred(), flist; + + flist = _files2urls (manifest); + if (isS(flist)) { + _f("Error decoding base64 to local Blob/URL", flist); + pi.reject(); + } + else { + if (wURL) for(i=0;i*").clone(); + try { + tracker = _prepare(manifest, data.init, $root, data); + } catch (e) { + _f(isS(e)?e:e.message, e.stack); + return $root; + } + } + // init returned promise? + if (isP(tracker)) { + tracker.then(function () {_controls();}, function (err,obj){_f(err, obj);}); + } else _controls(); + + if (!_fail) { + if (!$root.my()) return _f("Internal error initializing controls.",""), $root; + + //save initial data for $.my("reset") + $root.data("my").initial = $E(true,{},d); + + //init $.mobile if any + if ($.mobile) $.mobile.changePage($.mobile.activePage); + } + } + + + //----------------------------------------------------- + + //build and init controls + function _controls (){ + var formState={}, ctr=Object.size(ui); + + $root.addClass(initCss); + + // build controls (init and premount) + Object.each(ui, function (selector) { + if (_fail) return; + var $o = $root.find(selector), + built = _build($o, $root, ui[selector], selector); + + if (isP(built)) { + //we've got promise + built.then( + countdown.fill(selector) + ).fail(function (msg, obj){ + _f("Error building "+selector+", "+msg, obj); + }); + } + else if (!_fail) countdown(selector); + }); + + function countdown(selector){ + if (!_fail) { + formState[selector]=_field($root.find(selector),N); + ctr-=1; if (ctr<.5) _values(formState); + } + } + + } + + //----------------------------------------------------- + + //apply values to controls + function _values (formState) { + var uiNode, v, $o; + for (var selector in ui) { + if (_fail) return; + uiNode = ui[selector]; + $o = $root.find(selector); + if ($o.size()) { + if (uiNode.listen) $listeners[selector] = $o.eq(0); + try { + v = _bind(d, N, uiNode, $o); + if (v==N && formState[selector]!=N && v!==undefined) + _bind(d, formState[selector], uiNode, $o); + } + catch (e) { + _ERR ("Transient fail linking " +selector + +" of form $('.my-form-"+cid+"')", + e.message, e.stack + ); + } + try { + if (v!=N) _field($o,v); + $o.eq(0).trigger("check.my"); + } catch (e) { + _f("Error linking "+selector, e.message, e.stack); + } + } + } + $root.removeClass(initCss); + $root.on("recalc.my, redraw.my", function (evt) { + evt.stopPropagation(); + $root.my("redraw"); + }); + backup=null; + pi.resolve(d); + } + + //----------------------------------------------------- + + // Fail handler + function _f (msg, obj) { + var html; + _fail=true; + _ERR("Form "+myid+" failed to initialize.", msg, obj); + $root.removeClass(initCss); + html = ehandler(msg, obj); + if (isS(html) || (isO(html) && html.jquery)) $root.html(html); + else if (html===true) $root.html(backup); + if (!p.silent) { + if(!$root.my().ddata) { + $root.removeData("my"); + $root.removeClass("my-form"); + if ($style) { + if ($style.data("count")=="1") { + try{$style.remove();}catch(e){} + } + else $style.data("count", $style.data("count")-1); + } + if ($locstyle) { + try{ + delete restyles[cid]; + $locstyle.remove(); + }catch(e){} + } + } + pi.reject("Form "+myid+" failed to initialize: "+msg, obj); + } else pi.resolve(d); + } + }, //end init + + + + //###### REDRAW ###### + + "redraw": function ( noRecalc, silent) { + var $x = this, d = $x.my(); + if (d && d.ui) { + d.ui.each(function (key) { + var $n = $x.find(key); + _update($n, noRecalc?N:undefined , d.params.recalcDepth); + if (!noRecalc) { + if ($n.is(".my-form")) $n.my("redraw"); + if ($n.is(".my-form-list")) $n.trigger("redraw"); + else $n.trigger("check.my"); + } + }); + if (!silent && noRecalc) $x.trigger(Ch); + } + return $x; + }, + + //###### SET OR RETRIEVE DATA ###### + + "data": function (data, noRecalc) { + var $x = this; + if (isO(data)) { + $x.my().data = f.overlap($x.my().data, data); + this.my("redraw", noRecalc); + } + return $x.my().data; + }, + + //###### RETURNS ERRORS ###### + + "errors": function () { + var e0 = $(this).my().errors, e = {}; + for (var i in e0) { + if (e0[i] && isS(e0[i])) e[i]=e0[i]; + if (isO(e0[i]) && Keys(e0[i]).length) e[i]=e0[i]; + } + return e; + }, + + //###### RETURNS true IF FORM VALID ###### + + "valid": function () { + var e = $(this).my().errors, ctr=0; + for (var i in e) { + if (e[i] && isS(e[i])) ctr++; + else if (isO(e[i]) && Keys(e[i]).length) ctr++; + } + return !ctr; + }, + + //###### RESET INITIAL VALUES ###### + + "reset": function () { + try { + f.kickoff(this.my().data, this.my().initial); + this.my("redraw"); + } catch (e) {return false;} + return true; + }, + + //###### GET id OR SEARCH BY id ###### + + "id": function (id, obj) { + if (isS(id)) return _cache(id, obj); + else { + var d = this.my(); + return (d && d.id)?d.id:N; + } + }, + + //###### UNMOUNT jQuery.my INSTANCE FROM THE DOM ###### + + "remove": function (fromDOM){ + var $o = this, + $style, + $locstyle, m, + locFiles, + d, ui, cid, mid; + + if (!this.my()) return N; + + //child elt requests form removal + if (this.my().root && !this.my().ddata) $o = this.my().root; + + m = $o.my(); + d = m.data; + cid = m.cid; + mid = m.mid; + + // stop event listeners + $o.unbind(".my"); + + // exec done + if (isO(m) && m.manifest && isF(m.manifest.die)) { + try { + m.manifest.die.call(m.manifest, $o, m.manifest); + } catch(e){} + } + + // remove stylesheets + if ($style=m.style) { + if ($style.data("count")=="1") { + try{$style.remove();}catch(e){} + } + else $style.data("count", $style.data("count")-1); + } + if ($locstyle=m.localStyle) { + try{ + delete restyles[cid]; + $locstyle.remove(); + }catch(e){} + } + + // revoke data urls + if (window.URL && (locFiles = m.locFiles) && locFiles.length) { + for (var i=0;i< locFiles.length; i++) { + try { URL.revokeObjectURL(locFiles[i]); } catch(e) {} + } + } + + // remove $.my from ui entries + ui = (m||{}).ui; + if (ui) { + ui.each(function (key){ + var $we = $o.find(key), f, mw, i; + + // close dependent modal + if (mw = $we.data("modal")) { + mw.cancel(); + $we.removeData("modal"); + } + + //close child modals + if (mw = $we.data("modals")) { + for (i in mw) if (mw[i]) mw[i].cancel(); + } + + $we.unbind(".my"); + try{ + f = _traverse($we, MY.destroy); + if (isF(f)) f($we); + }catch(e){} + $we .removeData("formlist") + .removeData("myval") + .removeData("my"); + }); + } + + if (fromDOM && $o.is(".my-form")){ + $o.remove(); + } + else if ($o.data("formlist") && $o.is(".my-form")) { + var $p = $o.parents(".my-form-list").eq(0); + $o.remove(); + $p.trigger("check"); + } + else { + $o.removeData("formlist") + .removeData("myval") + .removeData("my") + .removeClass("my-form"); + } + + $o.removeClass("my-form-"+cid+" my-manifest-"+mid); + + //returns data collected by removed instance + return d; + }, + + //###### UNDO ###### + + "undo": function (steps){ + var $this = this, + d = $this.my(), + h = d.params.history, + k = Keys(h).sort(), + diff = 1*(parseInt(steps)||0), + state; + if (!k.length || diff<0) return N; + if (!d.params.errors || !d.params.errors.values().compact(true).length) { + if ( Object.equal(h[k.last()], d.data)) diff+=1; + } else if (!Object.equal(d.data, d.lastCorrect)) diff+=1; + + state = _history(diff, d.params, true); + + if (state) { + f.kickoff($this.my().data, state); + $this.my("redraw"); + } + return $this.my().data; + }, + + //###### UI RUNTIME GETTER-SETTER ###### + + "ui": function (u) { + var $x = this, d = $x.my(), a=[], i; + if (!d) return N; + var ui = $E(true, {}, d.ui); + if (!isO(u)) return d.ui; + for (i in u) if (true || !ui[i]) a.push(i); //controls to (re)init + d.ui = _normalize(f.overlap(d.ui,u)); + for (i=0;i>{x:1,y:{w:2,a:[1,2],z:3}}. + // Returns mutated a. + for (var i in b) { + if (b.hasOwnProperty(i)) { + if (isO(b[i])) { + if (!a.hasOwnProperty(i)) a[i]=Object.clone(b[i],true); + else patcher (a[i],b[i]); + } else if (!a.hasOwnProperty(i)) { + if (isA(b[i])) a[i]=b[i].clone(true); + else a[i]=b[i]; + } + } + } + return a; + }, + "kickoff": function (a,b) { + //replaces a content with b content; + var def = b && typeof b == "object" ? Object.clone(b, true) : {}, i; + for (i in a) if (a.hasOwnProperty(i)) { + delete a[i]; + if (def[i] !== undefined) a[i] = def[i]; + } + }, + "sdbmCode":function (s0){ + //very fast hash used in Berkeley DB + for (var s = JSON.stringify(s0), hash=0,i=0;i {x:1, m:{n:{z:5}, y:{z:3}}}, + // unmask ([1,2,3],["x","a.b","a.c"]) => {x:1, a:{b:2, c:3}} + // modifies dest + + var dest, src, mask; + + if (null==A3) dest = {}, src = A1, mask = A2; + else dest = A1, src = A2, mask = A3; + + if (isO(src) && isO(mask)) return f.mask(src,mask); + + if (isS(mask)) { mask = [mask]; src= [src]; } + + if (!isA(mask) || !(isA(dest) || isO(dest))) return null; + + if (isO(src)) { + src = mask.reduce(function(vals, path){ + vals.push(_getref(src,path)); + return vals; + },[]); + } + + if (isA(src) && isA(mask)) { + for (var i=0;i-1) + ) + ) ptr = preptr[path[i]] = {}; + } + } + } + return data; + } + }, + "getref":_getref, + "require":_require, + "repo": function(){return forms;}, + "restyles":function(){return restyles;}, + "unjson":function (obj) { + _unjson(obj); + return obj; + }, + "blob2base64": function(blob, done, nosplit) { + var reader = new FileReader(); + reader.onload = function() {done(nosplit?reader.result:reader.result.split(',')[1]);}; + reader.readAsDataURL(blob); + }, + "base642blob": function(base64, done, mime) { + var binary = atob(base64), + len = binary.length, + buffer = new ArrayBuffer(len), + view = new Uint8Array(buffer), + blob; + for (var i = 0; i < len; i++) view[i] = binary.charCodeAt(i); + blob = new Blob([view], {type:mime||"application/octet-stream"}); + if (isF(done)) done(blob); + else return blob; + }, + "base64": function (s0, decode, prefix0) { + // If s0 is not string it's stringified + // If decode is true, decodes base64, else encodes + // If prefix===true, utf-8 BOM is added, + // If prefix is a string, it’s assumed mime, + // and added to encoded data + var st=T(s0), r=null, + s= (isS(s0)?s0:$.my.tojson(s0)), + prefix = isS(prefix0)?'data:'+prefix0+';base64,':""; + if(decode) { + try {r = decodeURIComponent(escape(window.atob(s)));}catch(e) {r=null;} + if (null!==r && /(^".*"$)|(^\[.*\]$)|(^\{.*\}$)/.test(r)) { + try {r = $.my.fromjson(r);}catch(e) {r=null;} + } + return r; + } + return prefix + window.btoa( + (prefix0===true?"\xEF\xBB\xBF":"") + +unescape(encodeURIComponent(s)) + ); + }, + "css2json": function(css){ + var res = + ((css+"") + .replace(/\/\*[\s\S]+\*\//gm,"") + .replace(/@charset[^;]+;/gim,'') + .replace(/[\n\t\s]+/g,' ') + .replace(/\}/g,'}ᴥ') + .replace(/^\n+/g,"").replace(/[\n\s]+$/g,"") + .split('ᴥ') + .compact(true) + .reduce(function(a,b){ + var t = b.trim(), p, k, v; + if (/^[^{]+\{[^\}]+\}$/.test(t)) { + p = t.to(-1).split("{"); + k = " "+p[0].trim(); + v = p[1].trim(); + if (v.last()!=";") v+=";"; + if (!a[k]) a[k]=""; + a[k]+=v; + } + return a; + },{})); + return res; + } + }; + } //### end helpers + + +})(jQuery); // end $.my + + + +//############################################################################################# + +/* jQuery.formgen 0.4.1 + * Generates forms markup for $.my from lean-syntax DSL. + * Returns html string. + * + * $(somediv).formgen("[ + * // Redefines params for subsequent rows, can be partial + * { row:"400px", label:"100px", rowCss:"rowClass", labelCss:"", labelTag:""}, + * + * // First row + * ["Text4label", "inp#Name.person-name",{placeholder:"Your name"}], + * + * // Some free HTML + * '
', + * + * // Row with several controls and HTML, no label + * ["", "num#age",{style:"width:50px"}, "years ", "num#year", {style:"width:100px"}, " born"], + * + * // Select with opts, understands many formats + * ["Choose one", "sel#mychoice", + * {vals:[ + * "Fish", + * "Meat", + * {id:"Poultry", text:"Chicken"}, + * {"Ice Tea":"Tea1"} + * ]}] + * + * //and so on. Shortcuts for controls are below in the code. + * ]") + * + * */ + +(function ($){ + //Some shortcuts and constants + var $E = $.extend, n = function (o) {return o!==null && o!==undefined;}, N = null, + Ob="object", Da="data", Ar = "array", St = "string", Fu="function", Ch = "change", + isA = Object.isArray, isB = Object.isBoolean, isS = Object.isString, isO = Object.isObject, + isN = Object.isNumber, isR = Object.isRegExp, isF = Object.isFunction; + var iHead = '', + "inp" :iHead+'text" {ext}/>', + "sli" :iHead+'range" {ext}/>', + "dat" :iHead+'date" {ext}/>', + "btn" :iHead+'button" {ext}/>', + "pwd" :iHead+'password" {ext}/>', + "but" :'', + "div" :'
{txt}
', + "spn" :'{txt}', + "sel" :'', + "mul" :'', + "txt" :'', + "err" :' {txt}', + "msg" :'
{txt}
', + "val" :function (p) { + if (!isA(p.vals)) return ""; + var p0=$E({style:"",css:""},p); + p0.txt=p.vals.reduce(function (a,b){ + return a+'' + +b+' '; + }," "); + return ('{txt}').assign(p0); + }, + "" :'<{_tag} {ext}>{txt}' + }, + txt:{ + sel:function (p) { + if (!p.vals) return ""; + var obj = decrypt(p.vals); + return Object.keys(obj).reduce(function (a,b){ + return a+''; + },''); + } + }, + 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"} + }; + + + function chain(a,b,sys) { + if (isS(b)) return a+b; + if (isO(b)) { + sys = $E(true,sys, b); + return a; + } else if (isA(b) && b.length>1 && isS(b[1])) { + + var lbl = b[0],html="",key,type,a0,b0,i=1,j,p,tmpl,ext; + + //iterate through row's inside items + while (i' + +(lbl?( + '<'+sys.labelTag+' class="'+sys.labelCss+'" ' + +(sys.label?'style="display:inline-block;width:'+sys.label+';margin-left:-'+sys.label+'" ':"") + +'>'+lbl+'' + ):"") + +html+''; + } + return a+html; + } + return a; + } + + function decrypt (elt0) { + //translates different forms like [val, val val] + //{id:"",text:""} {key:"",value:""} and so on + // into object {key1:val1, key2:val2, ...} + var elt = elt0; + if (isS(elt)) { + elt = elt.split(/[\s,]/).compact(true); + } + if (isA(elt)) { + var obj={}; + for (var i=0;i> null or + * promise [resolve(formData or true), reject (errMessage, errStack)] + * + * Obj is one of following types: + * 1. jQuery image – will raise modal with the image and text from title or data-text attributes + * 2. HTML string – will raise modal with html content + * 3. Object of type + * { + * manifest: formManifest Object, + * data: initialData Object or none, + * width: formWidth Number or none, + * done: callback Function (formErrors, data) or none, + * esc: false, enables/disables close on escape keypress, + * enter: false, enables commit on Enter keypress + * nose:"", left|right|top|bottom – where to put nose + * global: false, force global modal + * screen: false, show/hide screen div + * drag: false, allows drag of modal if $ ui draggable plugin installed + * align:"top|bottom:NUM%|px;left|right:NUM%|px", + * bound: false or number, defines if modal must lay inside root, + * background:"white" background color in CSS format + * } + * will raise modal with $.my form inside. Form must call $obj.modal(false) or emit + * "commit" event on itself to close with sendind data. Calling $obj.modal(true) or + * emitting "cancel" event on form will close modal sending null as data with no error. + * + * Callback in obj overlaps done provided as second arg, same for width. + * + * Callback is called prior promise and unlike promise receives 2 arguments, + * not one, even when form succeded. If callback returns true, dialog remains + * opened and promise – pending. + * + * 4. null, undefined or false – close dialog and calls done(formErrors, data), + * if done return false or null promise is resoved with data, + * else modal stays open + * 5. true (strict boolean) – close dialog and calls done (null, null), + * then promise is rejected with "Cancelled" string + * + * If modal on $obj is already open, invoking $obj.modal return promise that is + * immediatly rejected with error "Locked", done is called with (null, null). + * + * $.my.modal.visible() >> Boolean + * Indicates if global modal is opened. + * + * $.my.modal.parent (selector or null) >> jQuery object + * Sets or gets parent DOM node, where all $.my.modal stuff is prepended. + * To work good must be called prior to 1st $.my.modal call. +*/ + +(function ($){ + + var root={}, parent = "body", parentBack, isOpen = false, + $E = $.extend, M = {}, + isA = Object.isArray, isB = Object.isBoolean, isS = Object.isString, isO = Object.isObject, + isN = Object.isNumber, isR = Object.isRegExp, isF = Object.isFunction; + + + //Close modal on escape + + $(document).keydown(function (e) { + var code = e.keyCode, $f, m; + if (false!==isOpen && (code ===13 || code === 27)) { + m = isOpen.data("modal"); + $f = m.form; + if (code == 27 && ( m.esc || Object.equal($f.data("my").initial, $f.my("data")) ) ) { + isOpen.modal(true); + return false; + } + else if (code == 13 && m.enter ) { + (function($f){ + $f.modal(); + }).fill(isOpen).delay(50); + return false; + } + } + + }); + + // - - - - - - - - - - - - - - - - - - + + function _convert (o, obj, ovl, width0) { + var h, w,h0,w0,text,$i,width; + // $ image + if (typeof obj == "object" && obj.jquery) { + if (obj.is("img")) { + $i = obj; + text = obj.attr("alt") || obj.attr("title") || obj.data("text")||""; + w = $i[0].naturalWidth || $i[0].width; + h = $i[0].naturalHeight || $i[0].height; + if (h<1) h=1; + if (w<1) w=1; + w0=$(window).width()-90; + h0=$(window).height()-90; + if (h0' + +'

', + ui:{ + "img:eq(0)":"img", + "h4":{ + bind:"text", + css:{hide:function(d,v){return !v;}} + } + } + }, + data:{img:$i.attr("src"),text:text}, + esc:true, + screen:true, + width:width0||width, + focus:false, + global:true, + z:"1995" + }, ovl); + } + } + + // $.my form + else if (isO(obj) && obj.manifest) { + $E(o, obj, ovl); + } + + //plain html + else if (isS(obj)) { + $E(o, { + source:"html", + manifest:{ + init: function($o){ $o.html(this.HTML); }, + HTML:obj, + ui:{ "div:eq(0)":function(){} } + }, + data:{}, + esc:true, + focus:false, + width:width0 + }, ovl); + } + + else return null; + + return o; + } + + + // - - - - - - - - - - - - - - - - - - + + root.modal = function modal (obj, done0, w0) { + var o = {}, + $r = $(parent), pi, + $o=$r.find(">.my-modal-proxy"), + ovl = { + global:true, + screen:true, + done:isF(done0)?done0:undefined, + z:"1995" + }; + if (!isB(obj) && null!=obj) { + pi = $.Deferred(); + + if (!_convert(o, obj, ovl, w0)) { + return pi.reject("Invalid data").promise(); + } + + if (isOpen) { return pi.reject("Locked").promise(); } + else { + if (!$o.size()) { + $o = $('
').prependTo($r); + $o.css({position:"absolute",top:"0",left:"0",margin:"0",padding:"0",width:"1px",height:"0"}); + } + + return $o.modal(o); + } + + } else { + return $o.modal(obj); + } + }; + + // - - - - - - - - - - - - - - - - - - + + + root.modal.loading = function (onoff) { + $(parent).find(">.my-modal").toggleClass("my-modal-loading",!!onoff); + }; + + root.modal.parent = function (s) { + // sets parent DOM node selector for $.my.modal + if (!s || !$(s).size()) return $(parent); + parent = s; + }; + + root.modal.parentBack = function (s) { + // sets parent DOM node selector for $.my.modal background + if (!s || !$(s).size()) return $(parentBack||parent); + parentBack = s; + }; + + root.modal.visible = function () {return !!isOpen;}; + + if (!$.my) $.my={}; + $.my.modal = root.modal; + + + // ############################### + // Extend jQuery with modal plugin + + $.fn.modal = function (obj0, done0, width0) { + var pi = $.Deferred(), o={}, + $m, $f, $o = this, $r, $bg, $cl, $nose, padx=0, pady=0, + done = isF(done0)?done0:function(){ return false; }, + obj = isO(obj0)?obj0:{}, + m = $o.data("modal"), + md, stop; + + $E($o, pi.promise()); + + // check if this already has modal + + if (m) { + if (obj0==null || isB(obj0)) { + + // ##### CLOSE MODAL ########## + + $f = m.form; + $bg = m.bg; $r = m.root; done = m.done; + md = $f.my("data"); + stop = false; + + if (!obj0) { + // check if we can close + try{ + stop = done ($f.my("valid")?null:$f.my("errors"), md); + }catch(e){} + if (!stop) { + _remove(); + $o.removeData("modal"); + // async resolve + (function () { + if (M[m.cid]) M[m.cid].resolve(md); + delete M[m.cid]; + m=null; + }).delay(0); + } + } else { + // force close + try {done(null, null);} catch(e){} + _remove(); + $o.removeData("modal"); + if (M[m.cid]) { + try { + M[m.cid].reject("Cancelled"); + } catch (e) {} + } + delete M[m.cid]; + m=null; + } + + return $o; + + + } else if (obj) { + // reinit is not allowed + _f("Locked"); + return $o; + } + } + + // check if $o is visble + if (!$o.is(":visible")) { + _f("Object must be visible"); + return $o; + } + + // convert + if (!(obj = _convert(o, obj0, {}))) { + _f("Invalid data"); + return $o; + } + + // check if fullscreen opened + if (obj.global && isOpen) { + _f("Locked"); + return $o; + } + + + // ##### NEW MODAL ########## + + m=$E({ + type:"DOM", + source:"manifest", + form:null, // $obj of the form + modal:null, // $obj of the modal wrapper + root:null, // $obj, modal is appended to + bgroot:null, // $obj, root for bg + caller:$o, // $obj modal is linked with + + manifest:{}, + data:{}, + + global:false, + screen: false, + drag:false, + focus:true, + close:true, + silent:true, + esc: false, + enter: false, + bound:false, + + nose: "", + width:width0||300, height:null, + x:"0", y:"0", z:"1901", + background:"white", + css:"", + animate:200 + }, obj, { + promise: pi.promise(), + cid:Number.random(268435456,4294967295).toString(16) + }); + m.done = isF(m.done)? m.done:done; + + //parse align + if (isS(m.align) && m.align) { + m.x = (m.align.match(/(left|right):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0]; + m.y = (m.align.match(/(top|bottom):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0]; + } + + //refine width + m.width=1*($.my.f.getref( + isS(m.manifest)?$.my.cache(m.manifest):m.manifest, + "params.width" + ) || m.width ); + + // guess if $o is ctrl, form or just dom node + // find parent container + + m.type = "DOM"; + if ($o.hasClass("my-form")) { + m.type = "form"; + m.root = m.root || $o; //itself + } + else if ($o.data("my")) { + m.type = "control"; + m.root = m.root || $o.my().root; // parent form + } + else { + m.root = m.root || $o.parents(".my-form").eq(0); + if (!m.root.size()) m.root = $(parent); // global parent + } + + if (m.global) { + m.root = $(parent); + m.bgroot = $(parentBack||parent); + } else m.bgroot = m.root; + + $r = m.root; + if (!$r.data("modals")) $r.data("modals",{}); + + + // calculate z-index + + _measure(); + + // ##### Create modal DOM wrapper ##### + + // create wrappers if none defined + $m= $('
').prependTo(m.root); + $m.addClass("my-modal-"+ m.cid); + + padx=$m.outerWidth(); + pady = $m.outerHeight(); + $m.hide(); + + //rebuild modal form obj + $m.html('
'); + $f = $m.find(".my-modal-form"); + + // close btn + if (m.close) { + $cl = $(isS(m.close)? m.close:'
×
') + .prependTo($m).on("click.my",function () {$o.modal(true);}); + $cl.css({"z-index":((m.z+"").to(1)==="+"?"+":"")+(m.z*1+1)}); + } + + + $bg = m.bgroot.find(">.my-modal-screen"); + if (m.screen) { + if (!$bg.size()) { + $bg = $('').prependTo(m.root); + } + + if (m.esc) $bg.on("click.my"+ m.cid, function () { $o.modal(true); }); + } + + // mount data + $o.data("modal", m); + + // silent + if (m.silent) $m.on("change.my", function(){ return false; }); + + // position + $m.css({ + display:"block", + height:"none", + opacity:"0.005", + "z-index": m.z, + width:"auto" + }); + + if (!m.global) $m.css({ + position: "absolute", + left: m.pos.vx+"px", + top: m.pos.vy+"px", + display:"block", + height:"none", + opacity:"0.005", + "z-index": m.z, + width:"auto" + }); + else $m.css({ + position: "fixed", + left:"50%", + top: m.pos.vy+"px", + display:"block", + height:"none", + opacity:"0.005", + "z-index": m.z, + width:"auto", + "margin-left":"-"+((m.width+padx)/2).round(0)+"px" + }); + + // try to init form + + $f.my(m.manifest, m.data).then(function () { + var $img, $i, i, focus, ui; + //success + $E(m,{ + form: $f, + bg:$bg, + cancel: function(){$o.modal(true);}, + commit: function(){$o.modal();} + }); + $m.data("modal",m); + + // adjust form + m.height = $m.outerHeight(); + if (m.source !== "manifest") m.width = $m.width(); + _measure(); + $m.css({top:m.pos.vy+"px"}); + _adjust(true); + + // remember cid in parent form root + $r.data("modals")[m.cid] = m; + + // memoize modal promise + M[m.cid] = pi; + + // bind event listeners + $f.bind("commit.my", function(){ + m.commit.delay(50); + return false; + }).bind("cancel.my", function(){ + m.cancel.delay(50); + return false; + }); + + $m.bind("layout.my", function(){ + _adjust(); + }.debounce(50)); + + // fullscreen tuneups + if (m.global) { + isOpen = $o; + $("body").css({overflow:"hidden"}); + } + + // esc and enter monitors + if (!m.global && (m.esc || m.enter)) { + $f.bind("keydown.my", function(e) { + var code = e.keyCode; + if (code == 27 && m.esc) { + m.cancel(); + return false; + } + else if (code == 13 && m.enter && !($(e.target).is("textarea"))){ + m.commit.delay(50); + return false; + } + }); + } + + // autofocus + if (m.focus===true) { + focus = false; + ui = m.manifest.ui; + for (i in ui) { + if (!focus) { + $i = $f.find(i); + if ($i.size() && $i.is("input, textarea","button")) { + focus = true; $i.focus(); + } + } + } + } + else if (isS(m.focus)) $f.find(m.focus).focus(); + + //If we have images, count them and reheight on load + $img = $f.find("img").filter(function () {return $(this).attr("src")!="";}); + if ($img.size()) { + var _imgdone = function(){ + if (m.source !== "manifest") $m.css({width:"auto"}); + _adjust(); + }.after($img.size()); + $img.each(function () {$(this).bind("load", _imgdone);}); + } + + // Draggable + if (m.drag && $.fn.draggable) { + if (!isS(m.drag)) $m.draggable(); + else $m.draggable({handle: m.drag}); + if (m.nose) $m.on("dragstart.my", function(){$m.removeClass("nose-"+m.nose)}); + } + + pi.notify("Ready"); + }) + .fail(function (err){ + _remove(); + $o.data("modal", null); + pi.reject(err); + }); + + return $o; + + + //### Helpers + + function _measure(){ + // measure $o, its pos + // and modal offsets rel to container + + var W = window, h, w, + isfs = !!m.global, + ro = $r.offset(), + oo = $o.offset(), + rs = $r.scrollTop(); + + m.pos = { + px: ro.left, py: ro.top, + pw: $r.outerWidth(), ph: $r.outerHeight(), + + ox: oo.left, oy: oo.top, + ow: $o.outerWidth(), oh: $o.outerHeight(), + + ww:w, wh:h + }; + //if (m.width> m.pos.pw) m.width= m.pos.pw; + + // calculate offsets + var dx = (m.x.match(/\-?\d+(\.\d+)?/)||[0])[0]* 1, + dy = (m.y.match(/\-?\d+(\.\d+)?/)||[0])[0]* 1, + sx = m.x.has("left")?-1: m.x.has("right")?1: 0, + sy = m.y.has("top")?-1: m.y.has("bottom")?1: 0, + vx = m.pos.ox + m.pos.ow/2 - m.pos.px, + vy = m.pos.oy + m.pos.oh/2 - m.pos.py; + + if (isfs) { + m.pos.wh = h = W.innerHeight || $(W).height(); + m.pos.ww = w = W.innerWidth || $(W).width(); + vx = w/2; + vy = h/2.5; + } + dx = m.x.has("%")? m.pos.ow/100*dx:dx; + dy = m.y.has("%")? m.pos.oh/100*dy:dy; + + m.pos.pix = vx; m.pos.piy = vy; + + + vx = vx + sx*(m.pos.ow/2) + + dx*(sx>0?-1:1) + - (m.width+padx)*(sx+1)/2; + + if (isfs) { + vy = (h - m.height-20)/3; + if (vy<10) vy=10; + } else { + vy = vy + sy*(m.pos.oh/2) + + dy*(sy>0?-1:1) + - ((m.height||0)/*+pady*/)*(sy+1)/2; + } + + vx = vx.round(1); vy = (vy+rs).round(1); + + m.pos.vx = vx; m.pos.vy = vy; + + if (m.bound!==false && !m.global) { + var mb = (isN(m.bound)?m.bound:0).clamp(-100,100); + + //width + + if (m.pos.pw - 2*mb < m.width+padx) { + // we are wider + m.pos.vx = -(m.width+padx-m.pos.pw)/2; + } + else if (m.pos.vx+m.width+padx > m.pos.pw-mb) { + // we went over right + m.pos.vx = m.pos.pw-mb - m.width-padx; + } else if (m.pos.vx m.pos.ph-mb) { + // we went over bottom + m.pos.vy = m.pos.ph-mb - m.height; + } else if (m.pos.vy'); + } + var h = "", $s = $("style#my-modal-style-"+m.cid); + if (m.nose=="top" || m.nose=="bottom") { + h+='div.my-modal-'+m.cid+'.nose-'+m.nose+':before {left:' + + (m.pos.ox - m.pos.px + m.pos.ow/2 - m.pos.vx) + +'px!important;}'; + $s.text(h); + } + if (m.nose=="left" || m.nose=="right") { + h+='div.my-modal-'+m.cid+'.nose-'+m.nose+':before {top:' + + (m.pos.oy - m.pos.py + m.pos.oh/2 - m.pos.vy) + +'px!important;}'; + $s.text(h); + } + } + } + else $m.css({ + left:"50%", + "margin-left":"-"+((m.width+padx)/2).round(0)+"px" + }); + + + if (m.screen) { + if (!m.global) $bg.css({ + top:0, left:0, position:"absolute", + width: m.pos.pw+"px", + height: m.pos.ph+"px", + display:"block", + background:isS(m.screen)? m.screen:'rgba(40,80,120,0.6)', + "z-index":m.z-1 + }); + else { + $bg.css({ + top:0, left:0, + width:(m.pos.ww*2)+"px", + height:(m.pos.wh*2)+"px", + display:"block", + position:"fixed", + "z-index":m.z-1 + }); + if (isS(m.screen)) $bg.css({ + background:m.screen? m.screen:'rgba(25, 39, 59, 0.88)' + }); + } + } + else if ($bg.size()) $bg.hide(); + + if (m.height> m.pos.wh) { + $m.height(m.pos.wh-30); + $f.css({"overflow-y":$.browser.webkit?"overlay":"scroll"}); + } else { + $f.css({"overflow-y":"none"}); + } + + $m.animate({top: m.pos.vy+"px", opacity:"1"}, m.animate); + } + + // - - - - - - - - - - - - - - - - - - + + function _remove(){ + try { $f.my("remove"); } catch(e){} + try { + // root may not exist + $r.data("modals")[m.cid] = null; + } catch(e){} + $f.parent().unbind(".my").remove(); + $bg.off(".my"+ m.cid); + if (m.screen) { + (function(g){ + if (!g || !isOpen) $bg.hide(); + if (!!g && !isOpen) { + // repair screen color + $bg.css({background:'rgba(25, 39, 59, 0.88)'}); + } + }).delay(50, m.global); // curry m.global + } + if (m.global) { + isOpen = false; + $("body").css({overflow:"auto"}); + } + } + + // - - - - - - - - - - - - - - - - - - + + function _f(msg) { + try { done(null, null); } catch(e) {} + (function () { pi.reject(msg); }).delay(0); + } + + }; + +})(jQuery); diff --git a/Release/1.1/jquerymy-1.1.9.min.js b/Release/1.1/jquerymy-1.1.9.min.js new file mode 100644 index 0000000..942c16a --- /dev/null +++ b/Release/1.1/jquerymy-1.1.9.min.js @@ -0,0 +1,5 @@ +/* jQuery.my 1.1.9 + * Requires jQuery 1.11.0+, SugarJS 1.3.9-1.4.x + * More details at jquerymy.com */ +!function(e){function t(){window.console&&console.error.apply(console,arguments)}function r(){window.console&&console.log.apply(console,arguments)}function n(e,t){return(P(t)?t.split("."):R(t)?t:[""]).reduce(function(e,t){if(null!=e){if(/=/.test(t)){var r=t.split("=",2);return $(e)?Object.values(e).find(function(e){return $(e)||R(e)?e[r[0]]==r[1]:!1}):R(e)?e.find(function(e){return $(e)||R(e)?e[r[0]]==r[1]:!1}):void 0}if(null!=e&&null!=e[t])return e[t]}return void 0},e)}function i(e,t){var r,i;if($(t))return t;if(P(t)){if(r=n(e,t),null==r&&(r=Object.clone(H._src[t],!0)),null==r&&(r=n(H,t),$(r)&&$(r._self)?r=Object.clone(r._self,!0):$(r)&&(r=Object.clone(r,!0))),null==r&&n(e,"params.cache")&&(i=n(e,"params.cache"),A(i)?r=i(t):$(i)&&(r=at(t,i)),$(r)&&($(r._self)&&(r=Object.clone(r._self,!0)),Object.merge(r,{params:{cache:i}},!0))),null!=r&&$(r))return i=i||n(e,"params.cache"),i&&Object.merge(r,{params:{cache:i}},!0),r;throw"Component "+t+" not found."}return A(t)?t.apply(e,Array.prototype.slice.call(arguments,2)):null}function a(r,i){var a,s,l,c,u,d=i||H,f=r;if(!($(d)&&$(f)&&$(f.ui)&&P(f.id)))return"Can’t save manifest into cache, invalid arguments.";d.hasOwnProperty("_src")||(d._src={}),l=f.id;try{f=Object.clone(r,!0)}catch(m){return"Can’t save circular-referencing object into cache."}try{(!f.params||f.params&&!f.params.strict)&&w(f,!0)}catch(m){return"Invalid manifest, parse error."}if(a=o(f),P(a))return t(a),a;if(Object.merge(f,{params:{strict:!0}},!0),d._src[l]=f,c=lt.mask(d,l)){if(c.params&&c.params.protect)return"Can’t save manifest into cache over protected one.";c._self&&delete c._self,e.extend(!0,d,lt.unmask("",l))}return e.extend(!0,d,lt.unmask(f,l)),s=Object.keys(d._src).filter(function(e){return e.startsWith(l+".")}),s.sort(),s.forEach(function(t){var r;(r=lt.mask(d,t))&&(r._self&&delete r._self,e.extend(!0,d,lt.unmask("",t))),e.extend(!0,d,lt.unmask(d._src[t],t))}),u=n(d,l),M?u._self=d._src[l]:Object.defineProperty(u,"_self",{get:function(){return d._src[l]},set:function(){throw"Can’t change manifest cache entry directly."},enumerable:!1,configurable:!0}),u}function o(e){var t,r,n=[];if($(e.files)&&Object.size(e.files))for(t in e.files){if(r=e.files[t],!$(r))return"Non-object member "+t+" in files section.";if(P(r.data)&&!r.url)if(E)try{lt.base642blob(r.data,function(e){r.blob=e,r.url=E.createObjectURL(r.blob)},r.content_type||r.mime),n.push(t)}catch(i){return"Invalid base64 data in files/"+t+"."}else r.url="data:"+(r.content_type||r.mime)+";base64,"+r.data,n.push(t)}return n}function s(r,n){$(n)&&n.channel&&n.message&&r.find(".my-listen-"+lt.sdbmCode(n.channel)).each(function(){var r,i=e(this),a=i.data("my"),o=void 0;if(a&&a.ui.listen&&A(a.ui.listen[n.channel])){r=a.ui.listen[n.channel];try{o=r.call(a.manifest||a.root.my().manifest,a.data,n.message,i)}catch(s){t("Listener failed",s.message,s.stack)}void 0!==o&&(null===o?i.trigger("check"):o&&i.trigger("recalc"))}})}function l(t,r){function i(t,r){var n;return P(t)?/[\/]/.test(t)?(n=B(!0,{},k,{ref:r,ajax:{url:t}}),nt.test(r)&&(n.ajax.dataType="json")):t.length&&(n=B(!0,{},k,{ref:r,ajax:t})):$(t)&&(n=B(!0,{},k,{ref:r,ajax:e.extend(!0,{},Object.select(t,["accepts","async","cache","data","dataType","xhrFields","password","timeout","type","url","username","headers"]))}),n.ajax.url||(n=null)),n}function a(){g.reject(w)}function o(){O+=1;var e=b[O];if(e)s(e).then(o).fail(a);else{var r=c(x),n=L(Object.findAll(r,function(e,t){return!t}));n.length&&w.push((1===n.length?"Key "+n[0]+" is":"Keys "+n.join(", ")+" are")+" not present after all."),w.length?a():g.resolve(t)}}function s(r){function n(){c-=1,s?l.reject():.5>c&&l.resolve()}var i,a,o,s=!1,l=e.Deferred(),c=r.length;for(a=0;c>a;a++)i=r[a],o=P(i.ajax)?j.loader:ot,o(i.ajax).then(function(e,r){nt.test(r.ref)&&(null!=e?B(!0,t,lt.unmask(e,r.ref.from(5))):(s=!0,w.push("Invalid data for ‘"+r.ref+"’ resource."))),n()}.fill(void 0,i)).fail(function(e,t){w.push("Failed to load ‘"+t.ref+"’ resource."),s=!0,n()}.fill(void 0,i));return l.promise()}function l(e){var r=!1;return nt.test(e)?null!=n(t,e.from(5))&&(r=!0):null!=n(window,e)&&(r=!0),r}function c(e){for(var t in e)e[t]===!1&&(e[t]=l(t));return e}var u,d,f,m,h,p,y,v,g=e.Deferred(),b=[],x={},w=[],j=B(!0,{ajaxTimeout:1e4,loader:st.params.loader},r||{}),k={ref:null,ajax:{type:"GET",async:!0,timeout:j.ajaxTimeout}};if($(t))if(R(t.require)){for(m=t.require,u=0;ui)return n=l,void(i=o);c==G&&r(e,l,o+1)}W!=t[""]&&typeof t[""]!=G&&o>i&&(n=t[""],i=o)}var n=W,i=0,a="";return r(e,t,1),n}function d(e,t,r,n){var i,a,o,s=[],l=r.bind,c=Q(l);if(c==tt)return l.call(m(n).manifest,e,t,n);if(c===et||c===Z){if(c===et&&!/\./.test(l))return t!=W?e[l]=t:void 0===e[l]&&(e[l]=W),e[l];for(c===et&&(s=l.split(".").each(function(e,t){this[t]=e+""})),c===Z&&(s=l.slice(0).each(function(e,t){this[t]=e+""})),"this"===s[0]?(a=m(n).manifest,s.shift()):a=e,i=0;i-1?"":u;case"s":return r==s?"":u;case"o":return s[r]?"":u;case"b":if(i.is(".my-form-list,.ui-sortable")){var f=i.data("listSrc")||i.data("my").listSrc||">*",h={};return i.find(f).filter("*:not(.ui-sortable-placeholder)").each(function(t){var r=e(this);r.data("my")&&!r.my("valid")&&(h[t]=r.my("errors"))}),h}return i.hasClass("my-form")&&s?i.my("valid")?"":i.my("errors"):""}return l.formError||"Error"}return""}function m(e){var t=e.my();return t?t.root?t.root.my():t:null}function h(t,r,n){var i=n.compact(),a=i.replace(/:disabled/g,""),o=a!==i,s="self:"===a.to(5);return s&&(a=a.replace(/^self:/g,"")),r.each(function(){var n=e(this),i=n.my(),l=!s&&i?i.container:n;l.toggleClass(a,!!t),o&&void 0!==i&&!!t!=!!i.disabled&&(n.my().disabled=!!t,i._disable||(n.my()._disable=u(r,st.offon).fill(void 0,r)),i._disable(!!t))}),r}function p(e,r,n){var i,a,o,s,l,u,m,y,v,g,b,x,w=!1,j=!1,k=e,O=k.my(),C="";if(O){if(v=O.selector,g=O.root,g.hasClass("my-form-init"))return{};if(b=g.find(v),x=g.my().ui,w=e.hasClass("my-form"),j=e.hasClass("my-form-list"),w?(a=e,o=O.ddata,s=O.dui,l=O.dparams):(a=O.container,o=O.data,s=O.ui,l=O.params),s.bind!=W){if(u=V(r)?r:c(b,d(o,W,s,b)),W!=s.check){C="Unknown error";try{C=f(o,u,s,b)}catch(q){t("Error "+q.message+" in .check validator for "+v,g,q.stack)}}var z=l.errorCss,D="ui-state-error";try{W!=r&&(u=c(b,d(o,r,s,b)))}catch(q){C=l.messages.formError||"Error"}if(""===C)w?O.derrors[v]="":O.errors[v]="",a.removeClass(z),a.attr("title")&&a.attr("title",""),w||j||l.effect(a.find(l.errorTip),!1,l.animate/2),k.removeClass(D),k.find(".ui-widget").removeClass(D);else{if(w)O.derrors[v]=C;else if(j)O.errors[v]=C;else{a.addClass(z),O.errors[v]=C;var N=a.find(l.errorTip).eq(0);N.size()?l.effect(N.addClass(z).html(C),!0,l.animate):a.attr("title",(C||"").stripTags())}k.is(".hasDatepicker")&&(k.is("input")?k.addClass(D):k.find(".ui-widget").addClass(D)),k.is(".ui-slider")&&k.addClass(D)}}var _=r==W?u:r;if(s.css)for(m in s.css)y=s.css[m],U(y)?h(y.test(_),b,m):A(y)&&h(y.call(g.my().manifest,o,_,b),b,m);var i,T,S=s.recalc,E=[],M={};if(n&&s.recalc&&g.my()){for(x=g.my().ui,i=0;i=2*s){for(f={},a=s;2*s>a;a++)f[o[a]]=i[o[a]];t.history=f}return n||m.form.trigger(rt),m.history[o.last()]}if(!isNaN(e)||e===W){if(l=parseInt(e)||0,0>l)return W;if(o=L(i).sort(),l>=o.length&&(l=o.length-1),d=Object.clone(m.history[o[o.length-l-1]],!0),r){for(f={},a=0;a$/.test(C.list)?s=C.list:c=C.list||c,!s){var u=a.find(c);s="
",u.size()&&(s=e(s).append(u.eq(0).clone(!0)).html(),u.eq(0).remove())}a.data("formlist")||a.data("formlist",{}),a.data("formlist").generator={manifest:w,delay:(C.delay||O.delay||10)/1.3,template:s,selector:c,parent:D,bind:C.bind,hash:A(C.hash)?C.hash.bind(D):P(C.hash)?f.fill(void 0,C.hash):R(C.hash)?m.fill(void 0,C.hash.slice(0)):null,id:A(C.id)?C.id.bind(D):P(C.id)?f.fill(void 0,C.id):R(C.id)?m.fill(void 0,C.id.slice(0)):null,ext:!(!C.id&&!C.hash),stamp:0},a.on("insert.my",function(t,r){t.stopPropagation();var n={what:void 0,where:0};null==r?n.where=1e6:$(r)?Object.merge(n,r):(P(r)||F(r))&&(n.where=r),e(t.target).my("insert",n.where,n.what)}),a.on("remove.my",function(t){t.stopPropagation(),e(t.target).my("remove")})}else try{t=a.my(i(D,w),$(o)?o:void 0)}catch(p){d("$.my subform init of "+l+" failed: "+p.message,p.stack)}}it(t)?t.then(h,function(e,t){d("Init of subform "+l+" failed with error: "+e,t)}):h()}function d(e,r){t(e,r),q&&q.reject(e,r)}function f(e,t){var r=n(e,t)||"";return"string"==typeof r?r:lt.sdbmCode(r)}function m(e,t){return lt.sdbmCode(lt.mask(e,t))}function h(){a.each(function(){var t,r,n,i=e(this),c=!1;if("TEXTAREA"==i[0].nodeName&&(n=i[0].nextSibling,r=n&&n.CodeMirror?n.CodeMirror:null,r&&i.addClass("my-codemirror")),t=C.events||u(i,st.events),i.is(".my-form")?B(i.data("my"),{dui:C,root:o,selector:l,dparams:O,devents:t,ddata:k.data,container:O.container(i),derrors:k.errors}):(i.data("my",{events:t,selector:l,initial:v,previous:v,root:o,container:O.container(i),id:k.id,ui:C,data:k.data,params:O,errors:k.errors}),s._update=C.delay?p.debounce(C.delay):W,c=!0),c)if(i.cleditor&&i.parent().is(".cleditorMain")){var d=i.cleditor()[0];if(d&&d.$frame&&d.$frame[0]){i.addClass("my-cleditor"),B(i.data("my"),{container:O.container(i)});var f,m=function(e){i.val(e).trigger(rt)},h=Number.random(1e5,1e6-1);e(d.$frame[0]).attr("id","cleditCool"+h),f=document.frames?document.frames["cleditCool"+h].document:e("#cleditCool"+h)[0].contentWindow.document;var y=e(f).find("body");e(f).bind("keyup.my",function(){m(e(this).find("body").html())}),i.parent().find("div.cleditorToolbar").bind("click.my mouseup.my",function(){m(y.html())}),e("body").on("click","div.cleditorPopup",function(){m(y.html())})}}else if(i.is("div.redactor_box textarea")){var x,w="my-redactor-9";try{x=i.getEditor(),w="my-redactor-8"}catch(q){x=i.redactor("getEditor")}x&&(i.addClass(w),x.bind("input.my keyup.my blur.my",function(e){e.trigger("redactor")}.fill(i)))}else i.is(".ace_editor")?ace.edit(a[0]).on(rt,function(e){e.trigger("ace")}.fill(i)):r&&r.on(rt,function(e){e.trigger("codemirror")}.fill(i));i.my()._changed=g.debounce(j),i.my()._recalc=b.debounce(j),i.bind(t,function(e){e.type==rt&&e.stopPropagation(),c&&(k.locktill=Date.now()+s.delay),i.my()._changed(i,o,s,O)}),/check(\.my)?/.test(t+"")||i.on("check.my",function(){return i.my()._changed(i,o,s,O,!0),!1}),c||i.off("redraw.my"),i.on("recalc.my, redraw.my",function(e){e.stopPropagation(),i.my()._recalc(i,o,s,O)})}),q&&q.resolve()}var y,v,w,j,k=o.my(),O=(k||{}).params,C=s,q=null,z=0,D=k.manifest;return k?(j=s.delay,a.size()?(C.init!=W&&(y=x(D,C.init,a,k)),it(y)?(z+=1,q=e.Deferred(),y.then(c,function(e,t){d("Init of "+l+" failed: "+e,t)})):c()):r("Not found "+l+" selector.",o),q):(t("Failed to find $root building "+l+" selector."),null)}function g(e,t,r,n,i){var a=e.data("my"),o=t.data("my");if(a&&!a.disabled){y(a.ddata||a.data,a.dparams||a.params);var s=t.find(a.selector);p(e,i?W:c(s,W),r.recalcDepth||n.recalcDepth),void 0===o.orphan&&a.root.parent().hasClass("ui-sortable")&&(o.orphan=!a.root.parent().hasClass("my-form-list")),o.orphan&&a.root.parent().trigger("check"),n.change&&n.change.call(e)}}function b(e,t,r,i){var a=e.my();if(a&&!a.disabled){var o=t.find(a.selector);o.is(".my-form")?o.my("redraw"):p(e,o.is(".my-form-list")?n(o.my().data,o.data("formlist").generator.bind):W,r.recalcDepth||i.recalcDepth)}}function x(e,t,r,i){var a;if(P(t)){if(a=n(e,t),void 0===a)return r.html(t.assign(i.data)),null}else a=t;if(A(a))return a.apply(e,Array.prototype.slice.call(arguments,2));if(R(a))try{r.formgen(a)}catch(o){}return null}function w(e,t){var r,n=!t;for(r in e)e.hasOwnProperty(r)&&j(r,e,n)}function j(e,r,n){var i,a,o,s,l="";(n||!/^(data|files|require)$/.test(e))&&(i=r[e],l=Q(i),/^(ob|ar)/.test(l)?w(i):"string"===l&&/^(function[\s\n\t]+|new\sRegExp)/.test(i)&&((a=i.match(/^function([\s\n\t]+[\w_$][\w\d_$]*)?[\s\n\t]*\(([^\)]*)\)\s*\{([\s\S]*)\}[\s\n\r\t]*$/))&&4===a.length?(s=a[1]?a[1].replace(/[\s\n\t]/g,""):"",o=s.length?O(s,a[2],a[3]):k(a[2],a[3]),"function"==typeof o?r[e]=o:t("Invalid function in XJSON, skipped",o.message,o.stack,i)):(a=i.match(/^new\sRegExp\s*\(\/([\s\S]+)\/([a-z]*)\)$/))&&3===a.length&&(o=C(a[1],a[2]),"function"==typeof o.test?r[e]=o:t("Invalid RegExp in XJSON, skipped",o.message,o.stack,i))))}function k(e,t){var r;try{r=new Function(e,t)}catch(n){r={message:n.message,stack:n.stack}}return r}function O(e,t,r){var n;try{n=new Function("","return (function "+e+"("+t+"){"+r+"});")()}catch(i){n={message:i.message,stack:i.stack}}return n}function C(e,t){var r;try{r=new RegExp(e,t)}catch(n){r={message:n.message,stack:n.stack}}return r}function q(e,t,r){var i=$(t)?t:null;return Object.each(e,function(t,r){var n=typeof r;/^str|^fu/.test(n)&&(e[t]={bind:r})}),Object.each(e,function(t,a){var o,s,l,c=[],u=[],d=/\s?[,;]\s?/;a.recalc&&(P(a.recalc)?c=a.recalc.split(d):R(a.recalc)&&(c=a.recalc),c=c.compact(!0).unique()),c.length&&(e[t].recalc=c),null==a.bind&&(a.bind=function(){});var f;if(a.listen&&(f=z(a.listen),a.listen=Object.size(f)?f:void 0),a.hasOwnProperty("watch"))for(P(a.watch)?u=a.watch.split(d):R(a.watch)&&(u=a.watch.slice(0)),u=u.compact(!0).unique(),l=0;l2?f=lt.css2json(f):o.push(a+(/\{/.test(f)?f:"{"+f+"}"))),R(f)&&f.length)for(l=0;le?"0"+e:e}function t(e,a,o){var s,l,c,u,d=0,f=a||0,m=n;switch(o&&P(o)&&(d=String(o).length,m=String(o).repeat(10)),(typeof e).substr(0,3)){case"str":return i(e);case"num":return isFinite(e)?""+String(e):"null";case"boo":case"nul":return String(e);case"fun":return i(r(e.toString()));case"obj":if(!e)return"null";if(typeof e.toJSON===tt)return t(e.toJSON(),f+(o?1:0),o);if(s=[],R(e)){for(l=0;l-1))&&(n=a[i[o]]={}));else null!=t&&(e[r]=t);return e}var a,o,s;if(null==r?(a={},o=e,s=t):(a=e,o=t,s=r),$(o)&&$(s))return lt.mask(o,s);if(P(s)&&(s=[s],o=[o]),!R(s)||!R(a)&&!$(a))return null;if($(o)&&(o=s.reduce(function(e,t){return e.push(n(o,t)),e},[])),R(o)&&R(s)){for(var l=0;ll;l++)s[l]=i.charCodeAt(l);return n=new Blob([s],{type:r||"application/octet-stream"}),A(t)?void t(n):n},base64:function(t,r,n){var i=(Q(t),null),a=P(t)?t:e.my.tojson(t),o=P(n)?"data:"+n+";base64,":"";if(r){try{i=decodeURIComponent(escape(window.atob(a)))}catch(s){i=null}if(null!==i&&/(^".*"$)|(^\[.*\]$)|(^\{.*\}$)/.test(i))try{i=e.my.fromjson(i)}catch(s){i=null}return i}return o+window.btoa((n===!0?"":"")+unescape(encodeURIComponent(a)))},css2json:function(e){var t=(e+"").replace(/\/\*[\s\S]+\*\//gm,"").replace(/@charset[^;]+;/gim,"").replace(/[\n\t\s]+/g," ").replace(/\}/g,"}ᴥ").replace(/^\n+/g,"").replace(/[\n\s]+$/g,"").split("ᴥ").compact(!0).reduce(function(e,t){var r,n,i,a=t.trim();return/^[^{]+\{[^\}]+\}$/.test(a)&&(r=a.to(-1).split("{"),n=" "+r[0].trim(),i=r[1].trim(),";"!=i.last()&&(i+=";"),e[n]||(e[n]=""),e[n]+=i),e},{});return t}}}var T,S="jQuery.my 1.1.9",E=window.URL||window.webkitURL,M=!document.addEventListener,R=Object.isArray,I=Object.isBoolean,P=Object.isString,$=Object.isObject,F=Object.isNumber,U=Object.isRegExp,A=Object.isFunction,L=Object.keys,H=n(e,"my.f.repo")?e.my.f.repo():{_src:{},_name:"Default manifest cache"},J=n(e,"my.f.restyles")?e.my.f.restyles():{},B=e.extend,Q=e.type,W=null,V=function(e){return null!==e&&void 0!==e},X="{yyyy}-{MM}-{dd}",K="{HH}:{mm}",G="object",Y="data",Z="array",et="string",tt="function",rt="change",nt=/^this\./,it=function(e){return!!(null!=e&&($(e)||e.jquery)&&A(e.then)&&A(e.fail)&&A(e.state))},at=function(e,t){var r,i;return P(e)?(r=e,i=n($(t)?t:H,r),"exist"===t?$(i):i?Object.clone(i,!0):null):$(e)?(i=a(e,t),$(i)?i:null):void 0===e?H._src:null===e?Object.reject(H,/^_/):null},ot=e.ajax,st={vals:{".my-form":function(e,t){if(e&&e.my){var r=e.my(Y);return Object.equal(r,t)?r:e.my(Y,t,!0)}return t||W},".hasDatepicker":function(e,t){V(t)&&e.datepicker("setDate",""==t?t:Date.create(t));var r=e.datepicker("getDate");return r?r.format(X):""},".my-tags":function(e,t){return V(t)&&(P(t)||F(t)?e.tags(Y,[t+""]):R(t)&&e.tags(Y,t)),e.tags(Y)},".ui-draggable":function(e,t){if(V(t)&&$(t)){var r={};isNaN(t.left)||(r.left=Number(t.left).ceil(2)+"px"),isNaN(t.top)||(r.top=Number(t.top).ceil(2)+"px"),(r.left||r.top)&&e.css(r)}var n=e.position();return{left:t&&!isNaN(t.left)?(1*t.left).ceil(2):n.left.ceil(2),top:t&&!isNaN(t.top)?(1*t.top).ceil(2):n.top.ceil(2)}},".my-form-list":function(t,r){function n(){var r,n,i=e(this),a=i.data("my");a&&(r=i.data("formlist"),n=r.index,r.hash=x(a.data,n)+"",r.oid=w!==x?w(a.data,n)+"":r.hash),t.trigger("check.my")}function a(e){e.data("my").locktill+k/1.3.my-form",g=y.template||"
",b=/\{/.test(g),x=y.hash||lt.sdbmCode,w=y.id||lt.sdbmCode,j=y.ext,k=y.delay||50,O=t.is("."+m),C=!!t.children(h).size(),q=[],z=[],D=Date.now(),N=t.find(O?t.sortable("option","items"):v);if(V(r)&&R(r)){if(C)return r;if(s=[],l={},N.each(function(){var t,r=e(this),n=r.data("my");n&&(s.push(n.data),(t=r.data("formlist"))&&(l[t.oid]=n.data))}),u=!1,s&&s.length===r.length)for(u=!0,o=0;o1.4*k||D-y.stamp>100||!y.stashed||y.stashed.length!==N.size()-(C?1:0)){C&&(f=t.find(">."+m+"-helper"));var M=0;for(N.each(function(t,r){var n,i,a,o=e(r),s=!1;C&&o.hasClass(m+"-helper")||(C&&o.hasClass(m+"-placeholder")&&(o=f),n=o.data("my"),i=o.data("formlist"),n&&i&&(q.push(n.data),M!=i.index&&(i.index=M,s=!0),j&&(a=x(n.data,M)+"",a!==i.hash&&(i.hash=a,s=!0)),M+=1,s&&z.push(o)))}),o=0;o."+a+"-placeholder",s=t.find(t.sortable("option","items"));if(V(r)&&R(r)){var l={},c={},u=r.unique();if(t.find("input:focus:eq(0),textarea:focus:eq(0)").size()||t.find(o).size())return u;s.each(function(){l[lt.sdbmCode(lt.extval(e(this)))]=e(this)});for(var d=u.length-1;d>=0;d--){var f=lt.sdbmCode(u[d]);l[f]&&(l[f].prependTo(t).show(),c[f]=!0,-1==i.indexOf(u[d])&&i.push(u[d]))}i=i.reverse();for(d in l)c[d]||l[d].hide()}else{var m=t.find(o),h=t.eq(0);0!=m.size()?(h.my()[a]!=m.position().left+""+m.position().top?(s=s.filter(":visible:not(:disabled, .ui-state-disabled, .ui-sortable-helper)"),n=t.find(t.sortable("option","items")).filter(".ui-sortable-helper"),s.each(function(){var t=e(this);i.push(lt.extval(t.is(".ui-sortable-placeholder")?n:t))}),h.my()[a]=m.position().left+""+m.position().top,h.my()[a+"1"]=i):i=h.my()[a+"1"],i==W&&s.each(function(){i.push(lt.extval(e(this)))})):(s=t.find(t.sortable("option","items")).filter(":visible:not(:disabled, .ui-state-disabled)"),s.each(function(){i.push(lt.extval(e(this)))}))}return i},"input[type=date]":function(e,t){if(V(t))return r=""!=t?Date.create(t).format(X):"",P(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(X):""},"input[type=time]":function(e,t){if(V(t))return r=""!=t?Date.create(t).format(K):"",P(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(K):""},input:{"[type='text'],[type='number'],[type='search'],[type='hidden'],[type='password'],[type='button'],[type='range'],:not([type])":{".ui-slider-input":function(e,t){V(t)&&e.val(t).slider("refresh")},".tagstrip input.value":function(e,t){V(t)&&e.val(t).trigger("update")},"div.select2-container+input":function(e,t){return V(t)&&JSON.stringify(t)!==JSON.stringify(e.select2("val"))&&e.select2("val",R(t)?t:[t]),e.select2("val")},"":function(e,t){V(t)&&e.val(t+"")}},":radio":function(t,r){var n=-1;if(V(r)){t.each(function(t){var i=e(this).val();r+""==i+""&&(n=t)});var i=t.eq(0).checkboxradio;if(i&&t.each(function(t){var r=e(this);n!=t&&r.is(":checked")&&r.prop("checked",!1).checkboxradio("refresh")}),n>-1){var a=t.eq(n);a.is(":checked")||(a.prop("checked",!0),i&&a.checkboxradio("refresh"))}else i||t.each(function(){e(this).prop("checked",!1)})}if(-1==n)for(var o=0;oForm init failed

',ru:'

Ошибка инициализации формы

'},badInput:{en:"Invalid input",ru:T},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(e){return e.parents('[data-role="fieldcontain"]').eq(0)}},".tagstrip *.value":function(e){return e.parents(".tagstrip").eq(0)},"div.redactor_box textarea":function(e){return e.parents("div.redactor_box").eq(0).parent()},".my-tags,.hasDatepicker,.ui-widget,input,textarea,select,button":{".my-cleditor":function(e){return e.parents("div.cleditorMain").eq(0).parent()},"":function(t){var r=t[0].parentNode,n=r.nodeName;return/^(div|span|a|p|form|fieldset|li|ul|td|th|h\d)$/i.test(n)?e(r):t.parents("div,span,a,p,form,fieldset,li,ul,td,th,h1,h2,h3,h4,h5,h6").eq(0)}},"":function(e){return e}},offon:{".ace_editor":function(e,t){ace.edit(t[0]).setReadOnly(e) +},".ui-selectable":function(e,t){lt.jquix(t,"selectable",e)},".ui-slider":function(e,t){lt.jquix(t,"slider",e)},".ui-draggable":function(e,t){lt.jquix(t,"draggable",e)},".ui-buttonset":function(e,t){lt.jquix(t,"buttonset",e)},".hasDatepicker":function(e,t){lt.jquix(t,"datepicker",e)},".my-form":function(e,t){t.my("disabled",!!e)},"div.select2-container+input,div.select2-container+select":function(e,t){lt.jquix(t,"select2",e)},".my-cleditor":function(e,t){t.cleditor()[0].disable(!!e)},"":function(e,t){t.attr("disabled",!!e)}},destroy:{".hasDatepicker":function(e){e.datepicker("destroy")},".ui-slider":function(e){e.slider("destroy")},".ui-sortable":{".my-form-list":function(t){t.find(">.my-form").each(function(){e(this).my("remove")}),t.removeClass("my-form-list"),t.sortable("destroy")},"":function(e){e.sortable("destroy")}},".my-form-list":function(t){t.find(">.my-form").each(function(){e(this).my("remove")})},".ui-draggable":function(e){e.draggable("destroy")},".my-redactor-8":function(e){e.destroyEditor(),e.removeClass("my-redactor-8")},"div.select2-container+input,div.select2-container+select":function(e){e.select2("destroy")},".my-form":function(e){e.my("remove")},textarea:{".my-codemirror":function(e){e[0].nextSibling.CodeMirror.toTextArea(),e.removeClass("my-codemirror")}}}};st.params={container:function(e){return u(e,st.containers)(e)},change:W,recalcDepth:2,delay:0,strict:!1,restyle:-1,locale:T=(navigator.language||navigator.userLanguage||"en").substr(0,2),messages:Object.map(st.msg,function(e,t){return t[T]||t.en}),errorTip:".my-error-tip",errorCss:"my-error",animate:0,effect:function(e,t,r){return t?e.fadeIn(r):void e.fadeOut(r)},remember:0,silent:!1,history:{},historyDelay:100,loader:function(t){var r=e.Deferred(),n=at(t+"");return n?r.resolve(n):r.reject(null),r.promise()},ajaxTimeout:1e4};var lt=_(),ct={init:function(i,a,l){function u(e){var t,r,i,a,o,s,l={},c=!0,u=e.inherit;if(l=D(u),!Object.size(l))return null;if(a=dt.parents(".my-form").eq(0),!a.size())return null;if(o=a.data("my"),!o||!o.manifest)return null;i=o.manifest,r=i.expose,c=!r;for(t in l)(c||r[t])&&(s=n(i,t),null!=s&&(/\./.test(t)||P(l[t])?B(!0,I,lt.unmask(s,P(l[t])?l[t]:t)):e[t]=s))}function f(){var e,r;for(var e in et)for(r in M[e].listen)et[e].addClass("my-listen-"+lt.sdbmCode(r));K.radio&&dt.on("radio.my",function(e,r){var n,i;if($(r)&&r.channel&&r.message&&A(K.radio[r.channel])){n=K.radio[r.channel];try{i=n.call(K,e,r)}catch(a){t("Radio handler for form "+T+"failed",a.message,a.stack)}void 0!==i&&(e.stopPropagation(),i&&s(dt,r))}})}function m(){R.strict||w(I,!0),K=B(!0,K,Object.reject(I,["data"])),M=q(B(!0,{},I.ui||{}),K,R),K.radio&&(K.radio=z(K.radio)),K.expose&&(K.expose=D(K.expose)),_=Number.random(268435456,4294967295).toString(16),C=I.id||"my"+_,T=lt.sdbmCode(C),K.id=C,R.form=dt,I.params&&I.params.depth&&(R.recalcDepth=I.params.depth);for(F in K)A(K[F])&&(K[F]=K[F].bind(K));I.error&&(P(K.error)?nt=function(e,t){return K.error.assign(B({message:e+"",err:t+""},K))}:A(I.error)&&(nt=function(e,t){S=null;try{S=I.error(e,t)}catch(r){S=R.messages.initFailed}return S})),B(dt.data("my"),{id:C,cid:_,mid:T,errors:Object.extended(),ui:Object.extended(M),disabled:!1,manifest:K,locFiles:[],modals:{},radio:{}}),dt.addClass("my-form"),L="my-manifest-"+T,H="my-form-"+_,dt.addClass(H+" "+L)}function h(t){function r(e,t){return'"}!K.style||t&&!dt.is(":visible")||(U=N(dt,K,L,H),U&&U[0].length&&!t&&(Q=e("style#"+L),Q.size()||(Q=e(r(U[0],L)).appendTo(e("body"))),Q.data("count",1*Q.data("count")+1),dt.data("my").style=Q),U&&U[1].length&&(V=e("style#"+H),V.size()?t&&(e(r(U[1],H)).replaceAll(V),V=e("style#"+H)):(V=e(r(U[1],H)).appendTo(e("body")),R.restyle>-1&&!J[_]&&(J[_]=function(){h(!0)}.debounce(R.restyle)),dt.data("my").restyle=h.fill(!0).debounce(0)),dt.data("my").localStyle=V,t||dt.addClass("my-restyle")))}function p(){var t,r,n=e.Deferred();if(r=o(K),P(r))j("Error decoding base64 to local Blob/URL",r),n.reject();else{if(E)for(t=0;t*").clone();try{X=x(K,I.init,dt,I)}catch(t){return j(P(t)?t:t.message,t.stack),dt}}if(it(X)?X.then(function(){g()},function(e,t){j(e,t)}):g(),!rt){if(!dt.my())return j("Internal error initializing controls.",""),dt;dt.data("my").initial=B(!0,{},G),e.mobile&&e.mobile.changePage(e.mobile.activePage)}}function g(){function e(e){rt||(t[e]=c(dt.find(e),W),r-=1,.5>r&&b(t))}var t={},r=Object.size(M);dt.addClass(ot),Object.each(M,function(t){if(!rt){var r=dt.find(t),n=v(r,dt,M[t],t);it(n)?n.then(e.fill(t)).fail(function(e,r){j("Error building "+t+", "+e,r)}):rt||e(t)}})}function b(e){var r,n,i;for(var a in M){if(rt)return;if(r=M[a],i=dt.find(a),i.size()){r.listen&&(et[a]=i.eq(0));try{n=d(G,W,r,i),n==W&&e[a]!=W&&void 0!==n&&d(G,e[a],r,i)}catch(o){t("Transient fail linking "+a+" of form $('.my-form-"+_+"')",o.message,o.stack)}try{n!=W&&c(i,n),i.eq(0).trigger("check.my")}catch(o){j("Error linking "+a,o.message,o.stack)}}}dt.removeClass(ot),dt.on("recalc.my, redraw.my",function(e){e.stopPropagation(),dt.my("redraw")}),ut=null,tt.resolve(G)}function j(e,r){var n;if(rt=!0,t("Form "+C+" failed to initialize.",e,r),dt.removeClass(ot),n=nt(e,r),P(n)||$(n)&&n.jquery?dt.html(n):n===!0&&dt.html(ut),R.silent)tt.resolve(G);else{if(!dt.my().ddata){if(dt.removeData("my"),dt.removeClass("my-form"),Q)if("1"==Q.data("count"))try{Q.remove()}catch(i){}else Q.data("count",Q.data("count")-1);if(V)try{delete J[_],V.remove()}catch(i){}}tt.reject("Form "+C+" failed to initialize: "+e,r)}}var k,O,C,_,T,S,M,R,I,F,U,L,H,Q,V,X,K={},G={},Z=[],et={},tt=e.Deferred(),rt=!1,nt=function(){},ot="my-form-init",ct="std",ut="";if(P(i)){if(k=at(i),!k)return tt.reject("No manifest with id "+i+" found in repo."),tt.promise();$(l)&&$(a)?(k=B(k,a),O=l):O=a,ct="repo"}else k=i,O=a;if(!k)return this;I=$(O)&&"repo"!=ct?B(!0,{},k):k;var dt=this.eq(0),ft=dt.my();return $(ft)&&ft.id&&ft.ui?(r("jQuery.my is already bound.",dt),dt.my("ui",I.ui),dt.my(Y,I.data),tt.resolve(dt.my(Y)).promise()):(R=I.params||{},R.strict||(R=B(!0,{},R),w(R)),R=B(!0,{},st.params,R),tt.fail(function(){dt.removeClass(H+" "+L)}),B(dt,tt.promise()),$(O)?(G=lt.patch(O,I.data||{}),I.data=G):G=I.data||{},K.data=G,dt.data("my",{data:G,params:R,promise:tt.promise(),locktill:0}),dt.addClass(ot),I.inherit&&u(I),lt.require(I,R).then(function(){m(),p().then(function(){h(),y()})}).fail(function(e){m(),j("Linker of ‘require’ property failed.",e)}),tt.then(f),dt)},redraw:function(e,t){var r=this,n=r.my();return n&&n.ui&&(n.ui.each(function(t){var i=r.find(t);p(i,e?W:void 0,n.params.recalcDepth),e||(i.is(".my-form")&&i.my("redraw"),i.trigger(i.is(".my-form-list")?"redraw":"check.my"))}),!t&&e&&r.trigger(rt)),r},data:function(e,t){var r=this;return $(e)&&(r.my().data=lt.overlap(r.my().data,e),this.my("redraw",t)),r.my().data},errors:function(){var t=e(this).my().errors,r={};for(var n in t)t[n]&&P(t[n])&&(r[n]=t[n]),$(t[n])&&L(t[n]).length&&(r[n]=t[n]);return r},valid:function(){var t=e(this).my().errors,r=0;for(var n in t)t[n]&&P(t[n])?r++:$(t[n])&&L(t[n]).length&&r++;return!r},reset:function(){try{lt.kickoff(this.my().data,this.my().initial),this.my("redraw")}catch(e){return!1}return!0},id:function(e,t){if(P(e))return at(e,t);var r=this.my();return r&&r.id?r.id:W},remove:function(e){var t,r,n,i,a,o,s,l,c=this;if(!this.my())return W;if(this.my().root&&!this.my().ddata&&(c=this.my().root),n=c.my(),a=n.data,s=n.cid,l=n.mid,c.unbind(".my"),$(n)&&n.manifest&&A(n.manifest.die))try{n.manifest.die.call(n.manifest,c,n.manifest)}catch(d){}if(t=n.style)if("1"==t.data("count"))try{t.remove()}catch(d){}else t.data("count",t.data("count")-1);if(r=n.localStyle)try{delete J[s],r.remove()}catch(d){}if(window.URL&&(i=n.locFiles)&&i.length)for(var f=0;fo?W:(n.params.errors&&n.params.errors.values().compact(!0).length?Object.equal(n.data,n.lastCorrect)||(o+=1):Object.equal(i[a.last()],n.data)&&(o+=1),t=y(o,n.params,!0),t&&(lt.kickoff(r.my().data,t),r.my("redraw")),r.my().data)},ui:function(e){var t,r=this,n=r.my(),i=[];if(!n)return W;B(!0,{},n.ui);if(!$(e))return n.ui;for(t in e)i.push(t);for(n.ui=q(lt.overlap(n.ui,e)),t=0;t1&&l(t[1])){for(var n,u,f,m,h,p,y,v,g=t[0],b="",x=1;x'+(g?"<"+r.labelTag+' class="'+r.labelCss+'" '+(r.label?'style="display:inline-block;width:'+r.label+";margin-left:-"+r.label+'" ':"")+">"+g+"":"")+b+""),e+b}return e}function r(e){var t=e;if(l(t)&&(t=t.split(/[\s,]/).compact(!0)),s(t)){for(var r={},n=0;n',inp:u+'text" {ext}/>',sli:u+'range" {ext}/>',dat:u+'date" {ext}/>',btn:u+'button" {ext}/>',pwd:u+'password" {ext}/>',but:"",div:"
{txt}
",spn:"{txt}",sel:"",mul:'',txt:"",err:' {txt}',msg:'
{txt}
',val:function(e){if(!s(e.vals))return"";var t=i({style:"",css:""},e);return t.txt=e.vals.reduce(function(e,t){return e+""+t+" "}," "),'{txt}'.assign(t)},"":"<{_tag} {ext}>{txt}"},txt:{sel:function(e){if(!e.vals)return"";var t=r(e.vals);return Object.keys(t).reduce(function(e,r){return e+'"},"")}},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"}},f={init:function(t,r){return e(this).html(n(t,r))}};e.my||(e.my={}),e.my.formgen=n,e.fn.formgen=function(t){return l(t)&&f[t]?f[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void e.error("Method "+t+" does not exist on jQuery.formgen"):f.init.apply(this,arguments)}}(jQuery),function(e){function t(t,r,n,i){var a,s,l,d,f,m,h;if("object"==typeof r&&r.jquery)r.is("img")&&(m=r,f=r.attr("alt")||r.attr("title")||r.data("text")||"",s=m[0].naturalWidth||m[0].width,a=m[0].naturalHeight||m[0].height,1>a&&(a=1),1>s&&(s=1),d=e(window).width()-90,l=e(window).height()-90,a>l&&(s=s*(l/a)|0,a=l),s>d&&(s=d,a=a*(d/s)|0),h=300>s?300:s,o(t,{source:"image",manifest:{init:function(e){e.html(this.HTML),e.on("click.my","img:eq(0)",function(){e.trigger("cancel")})},HTML:'

',ui:{"img:eq(0)":"img",h4:{bind:"text",css:{hide:function(e,t){return!t}}}}},data:{img:m.attr("src"),text:f},esc:!0,screen:!0,width:i||h,focus:!1,global:!0,z:"1995"},n));else if(u(r)&&r.manifest)o(t,r,n);else{if(!c(r))return null;o(t,{source:"html",manifest:{init:function(e){e.html(this.HTML)},HTML:r,ui:{"div:eq(0)":function(){}}},data:{},esc:!0,focus:!1,width:i},n)}return t}var r,n={},i="body",a=!1,o=e.extend,s={},l=(Object.isArray,Object.isBoolean),c=Object.isString,u=Object.isObject,d=Object.isNumber,f=(Object.isRegExp,Object.isFunction);e(document).keydown(function(e){var t,r,n=e.keyCode;if(!1!==a&&(13===n||27===n)){if(r=a.data("modal"),t=r.form,27==n&&(r.esc||Object.equal(t.data("my").initial,t.my("data"))))return a.modal(!0),!1;if(13==n&&r.enter)return function(e){e.modal()}.fill(a).delay(50),!1}}),n.modal=function(r,n,o){var s,c={},u=e(i),d=u.find(">.my-modal-proxy"),m={global:!0,screen:!0,done:f(n)?n:void 0,z:"1995"};return l(r)||null==r?d.modal(r):(s=e.Deferred(),t(c,r,m,o)?a?s.reject("Locked").promise():(d.size()||(d=e('
').prependTo(u),d.css({position:"absolute",top:"0",left:"0",margin:"0",padding:"0",width:"1px",height:"0"})),d.modal(c)):s.reject("Invalid data").promise())},n.modal.loading=function(t){e(i).find(">.my-modal").toggleClass("my-modal-loading",!!t)},n.modal.parent=function(t){return t&&e(t).size()?void(i=t):e(i)},n.modal.parentBack=function(t){return t&&e(t).size()?void(r=t):e(r||i)},n.modal.visible=function(){return!!a},e.my||(e.my={}),e.my.modal=n.modal,e.fn.modal=function(n,m,h){function p(){var t,r,n=window,i=!!E.global,a=w.offset(),o=D.offset(),s=w.scrollTop();E.pos={px:a.left,py:a.top,pw:w.outerWidth(),ph:w.outerHeight(),ox:o.left,oy:o.top,ow:D.outerWidth(),oh:D.outerHeight(),ww:r,wh:t};var l=1*(E.x.match(/\-?\d+(\.\d+)?/)||[0])[0],c=1*(E.y.match(/\-?\d+(\.\d+)?/)||[0])[0],u=E.x.has("left")?-1:E.x.has("right")?1:0,f=E.y.has("top")?-1:E.y.has("bottom")?1:0,m=E.pos.ox+E.pos.ow/2-E.pos.px,h=E.pos.oy+E.pos.oh/2-E.pos.py;if(i&&(E.pos.wh=t=n.innerHeight||e(n).height(),E.pos.ww=r=n.innerWidth||e(n).width(),m=r/2,h=t/2.5),l=E.x.has("%")?E.pos.ow/100*l:l,c=E.y.has("%")?E.pos.oh/100*c:c,E.pos.pix=m,E.pos.piy=h,m=m+u*(E.pos.ow/2)+l*(u>0?-1:1)-(E.width+N)*(u+1)/2,i?(h=(t-E.height-20)/3,10>h&&(h=10)):h=h+f*(E.pos.oh/2)+c*(f>0?-1:1)-(E.height||0)*(f+1)/2,m=m.round(1),h=(h+s).round(1),E.pos.vx=m,E.pos.vy=h,E.bound!==!1&&!E.global){var p=(d(E.bound)?E.bound:0).clamp(-100,100);E.pos.pw-2*pE.pos.pw-p?E.pos.vx=E.pos.pw-p-E.width-N:E.pos.vxE.pos.ph-p?E.pos.vy=E.pos.ph-p-E.height:E.pos.vy');var r="",n=e("style#my-modal-style-"+E.cid);("top"==E.nose||"bottom"==E.nose)&&(r+="div.my-modal-"+E.cid+".nose-"+E.nose+":before {left:"+(E.pos.ox-E.pos.px+E.pos.ow/2-E.pos.vx)+"px!important;}",n.text(r)),("left"==E.nose||"right"==E.nose)&&(r+="div.my-modal-"+E.cid+".nose-"+E.nose+":before {top:"+(E.pos.oy-E.pos.py+E.pos.oh/2-E.pos.vy)+"px!important;}",n.text(r))}E.screen?E.global?(j.css({top:0,left:0,width:2*E.pos.ww+"px",height:2*E.pos.wh+"px",display:"block",position:"fixed","z-index":E.z-1}),c(E.screen)&&j.css({background:E.screen?E.screen:"rgba(25, 39, 59, 0.88)"})):j.css({top:0,left:0,position:"absolute",width:E.pos.pw+"px",height:E.pos.ph+"px",display:"block",background:c(E.screen)?E.screen:"rgba(40,80,120,0.6)","z-index":E.z-1}):j.size()&&j.hide(),E.height>E.pos.wh?(b.height(E.pos.wh-30),x.css({"overflow-y":e.browser.webkit?"overlay":"scroll"})):x.css({"overflow-y":"none"}),b.animate({top:E.pos.vy+"px",opacity:"1"},E.animate)}function v(){try{x.my("remove")}catch(t){}try{w.data("modals")[E.cid]=null}catch(t){}x.parent().unbind(".my").remove(),j.off(".my"+E.cid),E.screen&&function(e){e&&a||j.hide(),e&&!a&&j.css({background:"rgba(25, 39, 59, 0.88)"})}.delay(50,E.global),E.global&&(a=!1,e("body").css({overflow:"auto"}))}function g(e){try{T(null,null)}catch(t){}(function(){q.reject(e)}).delay(0)}var b,x,w,j,k,O,C,q=e.Deferred(),z={},D=this,N=0,_=0,T=f(m)?m:function(){return!1},S=u(n)?n:{},E=D.data("modal");if(o(D,q.promise()),E){if(null==n||l(n)){if(x=E.form,j=E.bg,w=E.root,T=E.done,O=x.my("data"),C=!1,n){try{T(null,null)}catch(M){}if(v(),D.removeData("modal"),s[E.cid])try{s[E.cid].reject("Cancelled")}catch(M){}delete s[E.cid],E=null}else{try{C=T(x.my("valid")?null:x.my("errors"),O)}catch(M){}C||(v(),D.removeData("modal"),function(){s[E.cid]&&s[E.cid].resolve(O),delete s[E.cid],E=null}.delay(0))}return D}if(S)return g("Locked"),D}return D.is(":visible")?(S=t(z,n,{}))?S.global&&a?(g("Locked"),D):(E=o({type:"DOM",source:"manifest",form:null,modal:null,root:null,bgroot:null,caller:D,manifest:{},data:{},global:!1,screen:!1,drag:!1,focus:!0,close:!0,silent:!0,esc:!1,enter:!1,bound:!1,nose:"",width:h||300,height:null,x:"0",y:"0",z:"1901",background:"white",css:"",animate:200},S,{promise:q.promise(),cid:Number.random(268435456,4294967295).toString(16)}),E.done=f(E.done)?E.done:T,c(E.align)&&E.align&&(E.x=(E.align.match(/(left|right):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0],E.y=(E.align.match(/(top|bottom):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0]),E.width=1*(e.my.f.getref(c(E.manifest)?e.my.cache(E.manifest):E.manifest,"params.width")||E.width),E.type="DOM",D.hasClass("my-form")?(E.type="form",E.root=E.root||D):D.data("my")?(E.type="control",E.root=E.root||D.my().root):(E.root=E.root||D.parents(".my-form").eq(0),E.root.size()||(E.root=e(i))),E.global?(E.root=e(i),E.bgroot=e(r||i)):E.bgroot=E.root,w=E.root,w.data("modals")||w.data("modals",{}),p(),b=e('
').prependTo(E.root),b.addClass("my-modal-"+E.cid),N=b.outerWidth(),_=b.outerHeight(),b.hide(),b.html('
'),x=b.find(".my-modal-form"),E.close&&(k=e(c(E.close)?E.close:'
×
').prependTo(b).on("click.my",function(){D.modal(!0)}),k.css({"z-index":("+"===(E.z+"").to(1)?"+":"")+(1*E.z+1)})),j=E.bgroot.find(">.my-modal-screen"),E.screen&&(j.size()||(j=e('').prependTo(E.root)),E.esc&&j.on("click.my"+E.cid,function(){D.modal(!0)})),D.data("modal",E),E.silent&&b.on("change.my",function(){return!1}),b.css({display:"block",height:"none",opacity:"0.005","z-index":E.z,width:"auto"}),b.css(E.global?{position:"fixed",left:"50%",top:E.pos.vy+"px",display:"block",height:"none",opacity:"0.005","z-index":E.z,width:"auto","margin-left":"-"+((E.width+N)/2).round(0)+"px"}:{position:"absolute",left:E.pos.vx+"px",top:E.pos.vy+"px",display:"block",height:"none",opacity:"0.005","z-index":E.z,width:"auto"}),x.my(E.manifest,E.data).then(function(){var t,r,n,i,l;if(o(E,{form:x,bg:j,cancel:function(){D.modal(!0)},commit:function(){D.modal()}}),b.data("modal",E),E.height=b.outerHeight(),"manifest"!==E.source&&(E.width=b.width()),p(),b.css({top:E.pos.vy+"px"}),y(!0),w.data("modals")[E.cid]=E,s[E.cid]=q,x.bind("commit.my",function(){return E.commit.delay(50),!1}).bind("cancel.my",function(){return E.cancel.delay(50),!1}),b.bind("layout.my",function(){y()}.debounce(50)),E.global&&(a=D,e("body").css({overflow:"hidden"})),E.global||!E.esc&&!E.enter||x.bind("keydown.my",function(t){var r=t.keyCode;return 27==r&&E.esc?(E.cancel(),!1):13==r&&E.enter&&!e(t.target).is("textarea")?(E.commit.delay(50),!1):void 0}),E.focus===!0){i=!1,l=E.manifest.ui;for(n in l)i||(r=x.find(n),r.size()&&r.is("input, textarea","button")&&(i=!0,r.focus()))}else c(E.focus)&&x.find(E.focus).focus();if(t=x.find("img").filter(function(){return""!=e(this).attr("src")}),t.size()){var u=function(){"manifest"!==E.source&&b.css({width:"auto"}),y()}.after(t.size());t.each(function(){e(this).bind("load",u)})}E.drag&&e.fn.draggable&&(c(E.drag)?b.draggable({handle:E.drag}):b.draggable(),E.nose&&b.on("dragstart.my",function(){b.removeClass("nose-"+E.nose)})),q.notify("Ready")}).fail(function(e){v(),D.data("modal",null),q.reject(e)}),D):(g("Invalid data"),D):(g("Object must be visible"),D)}}(jQuery); \ No newline at end of file diff --git a/Release/jquery.my.last.js b/Release/jquery.my.last.js index 7f8d383..942c16a 100644 --- a/Release/jquery.my.last.js +++ b/Release/jquery.my.last.js @@ -1,6 +1,5 @@ -/* jQuery.my 1.1.8 +/* jQuery.my 1.1.9 * Requires jQuery 1.11.0+, SugarJS 1.3.9-1.4.x * More details at jquerymy.com */ - -!function(e){function t(){window.console&&console.error.apply(console,arguments)}function r(){window.console&&console.log.apply(console,arguments)}function n(e,t){return($(t)?t.split("."):I(t)?t:[""]).reduce(function(e,t){if(null!=e){if(/=/.test(t)){var r=t.split("=",2);return F(e)?Object.values(e).find(function(e){return F(e)||I(e)?e[r[0]]==r[1]:!1}):I(e)?e.find(function(e){return F(e)||I(e)?e[r[0]]==r[1]:!1}):void 0}if(null!=e&&null!=e[t])return e[t]}return void 0},e)}function a(e,t){var r,i;if(F(t))return t;if($(t)){if(r=n(e,t),null==r&&(r=Object.clone(J._src[t],!0)),null==r&&(r=n(J,t),F(r)&&F(r._self)?r=Object.clone(r._self,!0):F(r)&&(r=Object.clone(r,!0))),null==r&&n(e,"params.cache")&&(i=n(e,"params.cache"),A(i)?r=i(t):F(i)&&(r=ot(t,i)),F(r)&&(F(r._self)&&(r=Object.clone(r._self,!0)),Object.merge(r,{params:{cache:i}},!0))),null!=r&&F(r))return i=i||n(e,"params.cache"),i&&Object.merge(r,{params:{cache:i}},!0),r;throw"Component "+t+" not found."}return A(t)?t.apply(e,Array.prototype.slice.call(arguments,2)):null}function o(r,i){var a,o,l,c,u,d=i||J,f=r;if(!(F(d)&&F(f)&&F(f.ui)&&$(f.id)))return"Can’t save manifest into cache, invalid arguments.";d.hasOwnProperty("_src")||(d._src={}),l=f.id;try{f=Object.clone(r,!0)}catch(m){return"Can’t save circular-referencing object into cache."}try{(!f.params||f.params&&!f.params.strict)&&j(f,!0)}catch(m){return"Invalid manifest, parse error."}if(a=s(f),$(a))return t(a),a;if(Object.merge(f,{params:{strict:!0}},!0),d._src[l]=f,c=ct.mask(d,l)){if(c.params&&c.params.protect)return"Can’t save manifest into cache over protected one.";c._self&&delete c._self,e.extend(!0,d,ct.unmask("",l))}return e.extend(!0,d,ct.unmask(f,l)),o=Object.keys(d._src).filter(function(e){return e.startsWith(l+".")}),o.sort(),o.forEach(function(t){var r;(r=ct.mask(d,t))&&(r._self&&delete r._self,e.extend(!0,d,ct.unmask("",t))),e.extend(!0,d,ct.unmask(d._src[t],t))}),u=n(d,l),R?u._self=d._src[l]:Object.defineProperty(u,"_self",{get:function(){return d._src[l]},set:function(){throw"Can’t change manifest cache entry directly."},enumerable:!1,configurable:!0}),u}function s(e){var t,r,n=[];if(F(e.files)&&Object.size(e.files))for(t in e.files){if(r=e.files[t],!F(r))return"Non-object member "+t+" in files section.";if($(r.data)&&!r.url)if(E)try{ct.base642blob(r.data,function(e){r.blob=e,r.url=E.createObjectURL(r.blob)},r.content_type||r.mime),n.push(t)}catch(i){return"Invalid base64 data in files/"+t+"."}else r.url="data:"+(r.content_type||r.mime)+";base64,"+r.data,n.push(t)}return n}function l(r,n){F(n)&&n.channel&&n.message&&r.find(".my-listen-"+ct.sdbmCode(n.channel)).each(function(){var r,i=e(this),a=i.data("my"),o=void 0;if(a&&a.ui.listen&&A(a.ui.listen[n.channel])){r=a.ui.listen[n.channel];try{o=r.call(a.manifest||a.root.my().manifest,a.data,n.message,i)}catch(s){t("Listener failed",s.message,s.stack)}void 0!==o&&(null===o?i.trigger("check"):o&&i.trigger("recalc"))}})}function c(t,r){function i(t,r){var n;return $(t)?/[\/]/.test(t)?(n=Q(!0,{},k,{ref:r,ajax:{url:t}}),it.test(r)&&(n.ajax.dataType="json")):t.length&&(n=Q(!0,{},k,{ref:r,ajax:t})):F(t)&&(n=Q(!0,{},k,{ref:r,ajax:e.extend(!0,{},Object.select(t,["accepts","async","cache","data","dataType","xhrFields","password","timeout","type","url","username","headers"]))}),n.ajax.url||(n=null)),n}function a(){g.reject(w)}function o(){O+=1;var e=b[O];if(e)s(e).then(o).fail(a);else{var r=c(x),n=H(Object.findAll(r,function(e,t){return!t}));n.length&&w.push((1===n.length?"Key "+n[0]+" is":"Keys "+n.join(", ")+" are")+" not present after all."),w.length?a():g.resolve(t)}}function s(r){function n(){c-=1,s?l.reject():.5>c&&l.resolve()}var i,a,o,s=!1,l=e.Deferred(),c=r.length;for(a=0;c>a;a++)i=r[a],o=$(i.ajax)?j.loader:st,o(i.ajax).then(function(e,r){it.test(r.ref)&&(null!=e?Q(!0,t,ct.unmask(e,r.ref.from(5))):(s=!0,w.push("Invalid data for ‘"+r.ref+"’ resource."))),n()}.fill(void 0,i)).fail(function(e,t){w.push("Failed to load ‘"+t.ref+"’ resource."),s=!0,n()}.fill(void 0,i));return l.promise()}function l(e){var r=!1;return it.test(e)?null!=n(t,e.from(5))&&(r=!0):null!=n(window,e)&&(r=!0),r}function c(e){for(var t in e)e[t]===!1&&(e[t]=l(t));return e}var u,d,f,m,h,p,y,v,g=e.Deferred(),b=[],x={},w=[],j=Q(!0,{ajaxTimeout:1e4,loader:lt.params.loader},r||{}),k={ref:null,ajax:{type:"GET",async:!0,timeout:j.ajaxTimeout}};if(F(t))if(I(t.require)){for(m=t.require,u=0;ui)return n=l,void(i=o);c==Y&&r(e,l,o+1)}V!=t[""]&&typeof t[""]!=Y&&o>i&&(n=t[""],i=o)}var n=V,i=0,a="";return r(e,t,1),n}function f(e,t,r,n){var i,a,o,s=[],l=r.bind,c=W(l);if(c==rt)return l.call(h(n).manifest,e,t,n);if(c===tt||c===et){if(c===tt&&!/\./.test(l))return t!=V?e[l]=t:void 0===e[l]&&(e[l]=V),e[l];for(c===tt&&(s=l.split(".").each(function(e,t){this[t]=e+""})),c===et&&(s=l.slice(0).each(function(e,t){this[t]=e+""})),"this"===s[0]?(a=h(n).manifest,s.shift()):a=e,i=0;i-1?"":u;case"s":return r==s?"":u;case"o":return s[r]?"":u;case"b":if(i.is(".my-form-list,.ui-sortable")){var f=i.data("listSrc")||i.data("my").listSrc||">*",m={};return i.find(f).filter("*:not(.ui-sortable-placeholder)").each(function(t){var r=e(this);r.data("my")&&!r.my("valid")&&(m[t]=r.my("errors"))}),m}return i.hasClass("my-form")&&s?i.my("valid")?"":i.my("errors"):""}return l.formError||"Error"}return""}function h(e){var t=e.my();return t?t.root?t.root.my():t:null}function p(t,r,n){var i=n.compact(),a=i.replace(/:disabled/g,""),o=a!==i,s="self:"===a.to(5);return s&&(a=a.replace(/^self:/g,"")),r.each(function(){var n=e(this),i=n.my(),l=!s&&i?i.container:n;l.toggleClass(a,!!t),o&&void 0!==i&&!!t!=!!i.disabled&&(n.my().disabled=!!t,i._disable||(n.my()._disable=d(r,lt.offon).fill(void 0,r)),i._disable(!!t))}),r}function y(e,r,n){var i,a,o,s,l,c,d,h,v,g,b,x=!1,w=!1,j=e,k=j.my(),O="";if(k){if(h=k.selector,v=k.root,v.hasClass("my-form-init"))return{};if(g=v.find(h),b=v.my().ui,x=e.hasClass("my-form"),w=e.hasClass("my-form-list"),x?(i=e,a=k.ddata,o=k.dui,s=k.dparams):(i=k.container,a=k.data,o=k.ui,s=k.params),o.bind!=V){if(l=K(r)?r:u(g,f(a,V,o,g)),V!=o.check){O="Unknown error";try{O=m(a,l,o,g)}catch(C){t("Error "+C.message+" in .check validator for "+h,v,C.stack)}}var q=s.errorCss,z="ui-state-error";try{V!=r&&(l=u(g,f(a,r,o,g)))}catch(C){O=s.messages.formError||"Error"}if(""===O)x?k.derrors[h]="":k.errors[h]="",i.removeClass(q),i.attr("title")&&i.attr("title",""),x||w||s.effect(i.find(s.errorTip),!1,s.animate/2),j.removeClass(z),j.find(".ui-widget").removeClass(z);else{if(x)k.derrors[h]=O;else if(w)k.errors[h]=O;else{i.addClass(q),k.errors[h]=O;var D=i.find(s.errorTip).eq(0);D.size()?s.effect(D.addClass(q).html(O),!0,s.animate):i.attr("title",(O||"").stripTags())}j.is(".hasDatepicker")&&(j.is("input")?j.addClass(z):j.find(".ui-widget").addClass(z)),j.is(".ui-slider")&&j.addClass(z)}}var _=r==V?l:r;if(o.css)for(c in o.css)d=o.css[c],L(d)?p(d.test(_),g,c):A(d)&&p(d.call(v.my().manifest,a,_,g),g,c);var N,S,T=o.recalc,M=[],E={};if(n&&o.recalc&&v.my()){for(b=v.my().ui,N=0;N=2*s){for(f={},a=s;2*s>a;a++)f[o[a]]=i[o[a]];t.history=f}return n||m.form.trigger(nt),m.history[o.last()]}if(!isNaN(e)||e===V){if(l=parseInt(e)||0,0>l)return V;if(o=H(i).sort(),l>=o.length&&(l=o.length-1),d=Object.clone(m.history[o[o.length-l-1]],!0),r){for(f={},a=0;a$/.test(C.list)?s=C.list:c=C.list||c,!s){var d=i.find(c);s="
",d.size()&&(s=e(s).append(d.eq(0).clone(!0)).html(),d.eq(0).remove())}i.data("formlist")||i.data("formlist",{}),i.data("formlist").generator={manifest:g,delay:(C.delay||O.delay||10)/1.3,template:s,selector:c,parent:D,bind:C.bind,hash:A(C.hash)?C.hash.bind(D):$(C.hash)?f.fill(void 0,C.hash):I(C.hash)?m.fill(void 0,C.hash.slice(0)):null,id:A(C.id)?C.id.bind(D):$(C.id)?f.fill(void 0,C.id):I(C.id)?m.fill(void 0,C.id.slice(0)):null,ext:!(!C.id&&!C.hash),stamp:0},i.on("insert.my",function(t,r){t.stopPropagation();var n={what:void 0,where:0};null==r?n.where=1e6:F(r)?Object.merge(n,r):($(r)||U(r))&&(n.where=r),e(t.target).my("insert",n.where,n.what)}),i.on("remove.my",function(t){t.stopPropagation(),e(t.target).my("remove")})}else try{t=i.my(a(D,g),F(o)?o:void 0)}catch(p){u("$.my subform init of "+l+" failed: "+p.message,p.stack)}}at(t)?t.then(h,function(e,t){u("Init of subform "+l+" failed with error: "+e,t)}):h()}function u(e,r){t(e,r),q&&q.reject(e,r)}function f(e,t){var r=n(e,t)||"";return"string"==typeof r?r:ct.sdbmCode(r)}function m(e,t){return ct.sdbmCode(ct.mask(e,t))}function h(){i.each(function(){var t,r,n=e(this),a=!1,c=n[0].nextSibling;if(r=c&&c.CodeMirror?c.CodeMirror:null,r&&n.addClass("my-codemirror"),t=C.events||d(n,lt.events),n.is(".my-form")?Q(n.data("my"),{dui:C,root:o,selector:l,dparams:O,devents:t,ddata:k.data,container:O.container(n),derrors:k.errors}):(n.data("my",{events:t,selector:l,initial:v,previous:v,root:o,container:O.container(n),id:k.id,ui:C,data:k.data,params:O,errors:k.errors}),s._update=C.delay?y.debounce(C.delay):V,a=!0),a)if(n.cleditor&&n.parent().is(".cleditorMain")){var u=n.cleditor()[0];if(u&&u.$frame&&u.$frame[0]){n.addClass("my-cleditor"),Q(n.data("my"),{container:O.container(n)});var f,m=function(e){n.val(e).trigger(nt)},h=Number.random(1e5,1e6-1);e(u.$frame[0]).attr("id","cleditCool"+h),f=document.frames?document.frames["cleditCool"+h].document:e("#cleditCool"+h)[0].contentWindow.document;var p=e(f).find("body");e(f).bind("keyup.my",function(){m(e(this).find("body").html())}),n.parent().find("div.cleditorToolbar").bind("click.my mouseup.my",function(){m(p.html())}),e("body").on("click","div.cleditorPopup",function(){m(p.html())})}}else if(n.is("div.redactor_box textarea")){var g,w="my-redactor-9";try{g=n.getEditor(),w="my-redactor-8"}catch(q){g=n.redactor("getEditor")}g&&(n.addClass(w),g.bind("input.my keyup.my blur.my",function(e){e.trigger("redactor")}.fill(n)))}else n.is(".ace_editor")?ace.edit(i[0]).on(nt,function(e){e.trigger("ace")}.fill(n)):r&&r.on(nt,function(e){e.trigger("codemirror")}.fill(n));n.my()._changed=b.debounce(j),n.my()._recalc=x.debounce(j),n.bind(t,function(e){e.type==nt&&e.stopPropagation(),a&&(k.locktill=Date.now()+s.delay),n.my()._changed(n,o,s,O)}),/check(\.my)?/.test(t+"")||n.on("check.my",function(){return n.my()._changed(n,o,s,O,!0),!1}),n.on("recalc.my, redraw.my",function(e){e.stopPropagation(),n.my()._recalc(n,o,s,O)})}),q&&q.resolve()}var p,v,g,j,k=o.my(),O=(k||{}).params,C=s,q=null,z=0,D=k.manifest;return k?(j=s.delay,i.size()?(C.init!=V&&(p=w(D,C.init,i,k)),at(p)?(z+=1,q=e.Deferred(),p.then(c,function(e,t){u("Init of "+l+" failed: "+e,t)})):c()):r("Not found "+l+" selector.",o),q):(t("Failed to find $root building "+l+" selector."),null)}function b(e,t,r,n,i){var a=e.data("my"),o=t.data("my");if(a&&!a.disabled){v(a.ddata||a.data,a.dparams||a.params);var s=t.find(a.selector);y(e,i?V:u(s,V),r.recalcDepth||n.recalcDepth),void 0===o.orphan&&a.root.parent().hasClass("ui-sortable")&&(o.orphan=!a.root.parent().hasClass("my-form-list")),o.orphan&&a.root.parent().trigger("check"),n.change&&n.change.call(e)}}function x(e,t,r,i){var a=e.my();if(a&&!a.disabled){var o=t.find(a.selector);o.is(".my-form")?o.my("redraw"):y(e,o.is(".my-form-list")?n(o.my().data,o.data("formlist").generator.bind):V,r.recalcDepth||i.recalcDepth)}}function w(e,t,r,i){var a;if($(t)){if(a=n(e,t),void 0===a)return r.html(t.assign(i.data)),null}else a=t;if(A(a))return a.apply(e,Array.prototype.slice.call(arguments,2));if(I(a))try{r.formgen(a)}catch(o){}return null}function j(e,t){var r,n=!t;for(r in e)e.hasOwnProperty(r)&&k(r,e,n)}function k(e,r,n){var i,a,o,s,l="";(n||!/^(data|files|require)$/.test(e))&&(i=r[e],l=W(i),/^(ob|ar)/.test(l)?j(i):"string"===l&&/^(function[\s\n\t]+|new\sRegExp)/.test(i)&&((a=i.match(/^function([\s\n\t]+[\w_$][\w\d_$]*)?[\s\n\t]*\(([^\)]*)\)\s*\{([\s\S]*)\}[\s\n\r\t]*$/))&&4===a.length?(s=a[1]?a[1].replace(/[\s\n\t]/g,""):"",o=s.length?C(s,a[2],a[3]):O(a[2],a[3]),"function"==typeof o?r[e]=o:t("Invalid function in XJSON, skipped",o.message,o.stack,i)):(a=i.match(/^new\sRegExp\s*\(\/([\s\S]+)\/([a-z]*)\)$/))&&3===a.length&&(o=q(a[1],a[2]),"function"==typeof o.test?r[e]=o:t("Invalid RegExp in XJSON, skipped",o.message,o.stack,i))))}function O(e,t){var r;try{r=new Function(e,t)}catch(n){r={message:n.message,stack:n.stack}}return r}function C(e,t,r){var n;try{n=new Function("","return (function "+e+"("+t+"){"+r+"});")()}catch(i){n={message:i.message,stack:i.stack}}return n}function q(e,t){var r;try{r=new RegExp(e,t)}catch(n){r={message:n.message,stack:n.stack}}return r}function z(e,t,r){var i=F(t)?t:null;return Object.each(e,function(t,r){var n=typeof r;/^str|^fu/.test(n)&&(e[t]={bind:r})}),Object.each(e,function(t,a){var o,s,l,c=[],u=[],d=/\s?[,;]\s?/;a.recalc&&($(a.recalc)?c=a.recalc.split(d):I(a.recalc)&&(c=a.recalc),c=c.compact(!0).unique()),c.length&&(e[t].recalc=c),null==a.bind&&(a.bind=function(){});var f;if(a.listen&&(f=D(a.listen),a.listen=Object.size(f)?f:void 0),a.hasOwnProperty("watch"))for($(a.watch)?u=a.watch.split(d):I(a.watch)&&(u=a.watch.slice(0)),u=u.compact(!0).unique(),l=0;l2?f=ct.css2json(f):o.push(a+(/\{/.test(f)?f:"{"+f+"}"))),I(f)&&f.length)for(l=0;le?"0"+e:e}function t(e,a,o){var s,l,c,u,d=0,f=a||0,m=n;switch(o&&$(o)&&(d=String(o).length,m=String(o).repeat(10)),(typeof e).substr(0,3)){case"str":return i(e);case"num":return isFinite(e)?""+String(e):"null";case"boo":case"nul":return String(e);case"fun":return i(r(e.toString()));case"obj":if(!e)return"null";if(typeof e.toJSON===rt)return t(e.toJSON(),f+(o?1:0),o);if(s=[],I(e)){for(l=0;ll;l++)s[l]=i.charCodeAt(l);return n=new Blob([s],{type:r||"application/octet-stream"}),A(t)?void t(n):n},base64:function(t,r,n){var i=(W(t),null),a=$(t)?t:e.my.tojson(t),o=$(n)?"data:"+n+";base64,":"";if(r){try{i=decodeURIComponent(escape(window.atob(a)))}catch(s){i=null}if(null!==i&&/(^".*"$)|(^\[.*\]$)|(^\{.*\}$)/.test(i))try{i=e.my.fromjson(i)}catch(s){i=null}return i}return o+window.btoa((n===!0?"":"")+unescape(encodeURIComponent(a)))},css2json:function(e){var t=(e+"").replace(/\/\*[\s\S]+\*\//gm,"").replace(/@charset[^;]+;/gim,"").replace(/[\n\t\s]+/g," ").replace(/\}/g,"}ᴥ").replace(/^\n+/g,"").replace(/[\n\s]+$/g,"").split("ᴥ").compact(!0).reduce(function(e,t){var r,n,i,a=t.trim();return/^[^{]+\{[^\}]+\}$/.test(a)&&(r=a.to(-1).split("{"),n=" "+r[0].trim(),i=r[1].trim(),";"!=i.last()&&(i+=";"),e[n]||(e[n]=""),e[n]+=i),e},{});return t}}}var T,M="jQuery.my 1.1.8",E=window.URL||window.webkitURL,R=!document.addEventListener,I=Object.isArray,P=Object.isBoolean,$=Object.isString,F=Object.isObject,U=Object.isNumber,L=Object.isRegExp,A=Object.isFunction,H=Object.keys,J=n(e,"my.f.repo")?e.my.f.repo():{_src:{},_name:"Default manifest cache"},B=n(e,"my.f.restyles")?e.my.f.restyles():{},Q=e.extend,W=e.type,V=null,K=function(e){return null!==e&&void 0!==e},X="{yyyy}-{MM}-{dd}",G="{HH}:{mm}",Y="object",Z="data",et="array",tt="string",rt="function",nt="change",it=/^this\./,at=function(e){return!!(null!=e&&(F(e)||e.jquery)&&A(e.then)&&A(e.fail)&&A(e.state))},ot=function(e,t){var r,i;return $(e)?(r=e,i=n(F(t)?t:J,r),"exist"===t?F(i):i?Object.clone(i,!0):null):F(e)?(i=o(e,t),F(i)?i:null):void 0===e?J._src:null===e?Object.reject(J,/^_/):null},st=e.ajax,lt={vals:{".my-form":function(e,t){if(e&&e.my){var r=e.my(Z);return Object.equal(r,t)?r:e.my(Z,t,!0)}return t||V},".hasDatepicker":function(e,t){K(t)&&e.datepicker("setDate",""==t?t:Date.create(t));var r=e.datepicker("getDate");return r?r.format(X):""},".my-tags":function(e,t){return K(t)&&($(t)||U(t)?e.tags(Z,[t+""]):I(t)&&e.tags(Z,t)),e.tags(Z)},".ui-draggable":function(e,t){if(K(t)&&F(t)){var r={};isNaN(t.left)||(r.left=Number(t.left).ceil(2)+"px"),isNaN(t.top)||(r.top=Number(t.top).ceil(2)+"px"),(r.left||r.top)&&e.css(r)}var n=e.position();return{left:t&&!isNaN(t.left)?(1*t.left).ceil(2):n.left.ceil(2),top:t&&!isNaN(t.top)?(1*t.top).ceil(2):n.top.ceil(2)}},".my-form-list":function(t,r){function n(){var r,n,i=e(this),a=i.data("my");a&&(r=i.data("formlist"),n=r.index,r.hash=b(a.data,n)+"",r.oid=x!==b?x(a.data,n)+"":r.hash),t.trigger("check.my")}function i(e){e.data("my").locktill+j/1.3.my-form",v=p.template||"
",g=/\{/.test(v),b=p.hash||ct.sdbmCode,x=p.id||ct.sdbmCode,w=p.ext,j=p.delay||50,k=t.is("."+f),O=!!t.children(m).size(),C=[],q=[],z=Date.now(),D=t.find(k?t.sortable("option","items"):y);if(K(r)&&I(r)){if(O)return r;if(s=[],D.each(function(){var t=e(this),r=t.data("my");r&&s.push(r.data)}),c=!1,s.length===r.length)for(c=!0,o=0;o1.4*j||z-p.stamp>100||!p.stashed||p.stashed.length!==D.size()-(O?1:0)){O&&(d=t.find(">."+f+"-helper"));var M=0;for(D.each(function(t,r){var n,i,a,o=e(r),s=!1;O&&o.hasClass(f+"-helper")||(O&&o.hasClass(f+"-placeholder")&&(o=d),n=o.data("my"),i=o.data("formlist"),n&&i&&(C.push(n.data),M!=i.index&&(i.index=M,s=!0),w&&(a=b(n.data,M)+"",a!==i.hash&&(i.hash=a,s=!0)),M+=1,s&&q.push(o)))}),o=0;o."+a+"-placeholder",s=t.find(t.sortable("option","items"));if(K(r)&&I(r)){var l={},c={},u=r.unique();if(t.find("input:focus:eq(0),textarea:focus:eq(0)").size()||t.find(o).size())return u;s.each(function(){l[ct.sdbmCode(ct.extval(e(this)))]=e(this)});for(var d=u.length-1;d>=0;d--){var f=ct.sdbmCode(u[d]);l[f]&&(l[f].prependTo(t).show(),c[f]=!0,-1==i.indexOf(u[d])&&i.push(u[d]))}i=i.reverse();for(d in l)c[d]||l[d].hide()}else{var m=t.find(o),h=t.eq(0);0!=m.size()?(h.my()[a]!=m.position().left+""+m.position().top?(s=s.filter(":visible:not(:disabled, .ui-state-disabled, .ui-sortable-helper)"),n=t.find(t.sortable("option","items")).filter(".ui-sortable-helper"),s.each(function(){var t=e(this);i.push(ct.extval(t.is(".ui-sortable-placeholder")?n:t))}),h.my()[a]=m.position().left+""+m.position().top,h.my()[a+"1"]=i):i=h.my()[a+"1"],i==V&&s.each(function(){i.push(ct.extval(e(this)))})):(s=t.find(t.sortable("option","items")).filter(":visible:not(:disabled, .ui-state-disabled)"),s.each(function(){i.push(ct.extval(e(this)))}))}return i},"input[type=date]":function(e,t){if(K(t))return r=""!=t?Date.create(t).format(X):"",$(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(X):""},"input[type=time]":function(e,t){if(K(t))return r=""!=t?Date.create(t).format(G):"",$(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(G):""},input:{"[type='text'],[type='number'],[type='search'],[type='hidden'],[type='password'],[type='button'],[type='range'],:not([type])":{".ui-slider-input":function(e,t){K(t)&&e.val(t).slider("refresh")},".tagstrip input.value":function(e,t){K(t)&&e.val(t).trigger("update")},"div.select2-container+input":function(e,t){return K(t)&&JSON.stringify(t)!==JSON.stringify(e.select2("val"))&&e.select2("val",I(t)?t:[t]),e.select2("val")},"":function(e,t){K(t)&&e.val(t+"")}},":radio":function(t,r){var n=-1;if(K(r)){t.each(function(t){var i=e(this).val();r+""==i+""&&(n=t)});var i=t.eq(0).checkboxradio;if(i&&t.each(function(t){var r=e(this);n!=t&&r.is(":checked")&&r.prop("checked",!1).checkboxradio("refresh")}),n>-1){var a=t.eq(n);a.is(":checked")||(a.prop("checked",!0),i&&a.checkboxradio("refresh"))}else i||t.each(function(){e(this).prop("checked",!1)})}if(-1==n)for(var o=0;oForm init failed

',ru:'

Ошибка инициализации формы

'},badInput:{en:"Invalid input",ru:T},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(e){return e.parents('[data-role="fieldcontain"]').eq(0)}},".tagstrip *.value":function(e){return e.parents(".tagstrip").eq(0)},"div.redactor_box textarea":function(e){return e.parents("div.redactor_box").eq(0).parent()},".my-tags,.hasDatepicker,.ui-widget,input,textarea,select,button":{".my-cleditor":function(e){return e.parents("div.cleditorMain").eq(0).parent()},"":function(t){var r=t[0].parentNode,n=r.nodeName;return/^(div|span|a|p|form|fieldset|li|ul|td|th|h\d)$/i.test(n)?e(r):t.parents("div,span,a,p,form,fieldset,li,ul,td,th,h1,h2,h3,h4,h5,h6").eq(0)}},"":function(e){return e}},offon:{".ace_editor":function(e,t){ace.edit(t[0]).setReadOnly(e)},".ui-selectable":function(e,t){ct.jquix(t,"selectable",e)},".ui-slider":function(e,t){ct.jquix(t,"slider",e)},".ui-draggable":function(e,t){ct.jquix(t,"draggable",e)},".ui-buttonset":function(e,t){ct.jquix(t,"buttonset",e)},".hasDatepicker":function(e,t){ct.jquix(t,"datepicker",e)},".my-form":function(e,t){t.my("disabled",!!e)},"div.select2-container+input,div.select2-container+select":function(e,t){ct.jquix(t,"select2",e) -},".my-cleditor":function(e,t){t.cleditor()[0].disable(!!e)},"":function(e,t){t.attr("disabled",!!e)}},destroy:{".hasDatepicker":function(e){e.datepicker("destroy")},".ui-slider":function(e){e.slider("destroy")},".ui-sortable":{".my-form-list":function(t){t.find(">.my-form").each(function(){e(this).my("remove")}),t.removeClass("my-form-list"),t.sortable("destroy")},"":function(e){e.sortable("destroy")}},".my-form-list":function(t){t.find(">.my-form").each(function(){e(this).my("remove")})},".ui-draggable":function(e){e.draggable("destroy")},".my-redactor-8":function(e){e.destroyEditor(),e.removeClass("my-redactor-8")},"div.select2-container+input,div.select2-container+select":function(e){e.select2("destroy")},".my-form":function(e){e.my("remove")},textarea:{".my-codemirror":function(e){e[0].nextSibling.CodeMirror.toTextArea(),e.removeClass("my-codemirror")}}}};lt.params={container:function(e){return d(e,lt.containers)(e)},change:V,recalcDepth:2,delay:0,strict:!1,restyle:-1,locale:T=(navigator.language||navigator.userLanguage||"en").substr(0,2),messages:Object.map(lt.msg,function(e,t){return t[T]||t.en}),errorTip:".my-error-tip",errorCss:"my-error",animate:0,effect:function(e,t,r){return t?e.fadeIn(r):void e.fadeOut(r)},remember:0,silent:!1,history:{},historyDelay:100,loader:function(t){var r=e.Deferred(),n=ot(t+"");return n?r.resolve(n):r.reject(null),r.promise()},ajaxTimeout:1e4};var ct=S(),ut={init:function(i,a,o){function c(e){var t,r,i,a,o,s,l={},c=!0,u=e.inherit;if(l=_(u),!Object.size(l))return null;if(a=dt.parents(".my-form").eq(0),!a.size())return null;if(o=a.data("my"),!o||!o.manifest)return null;i=o.manifest,r=i.expose,c=!r;for(t in l)(c||r[t])&&(s=n(i,t),null!=s&&(/\./.test(t)||$(l[t])?Q(!0,I,ct.unmask(s,$(l[t])?l[t]:t)):e[t]=s))}function d(){var e,r;for(var e in et)for(r in M[e].listen)et[e].addClass("my-listen-"+ct.sdbmCode(r));X.radio&&dt.on("radio.my",function(e,r){var n,i;if(F(r)&&r.channel&&r.message&&A(X.radio[r.channel])){n=X.radio[r.channel];try{i=n.call(X,e,r)}catch(a){t("Radio handler for form "+S+"failed",a.message,a.stack)}void 0!==i&&(e.stopPropagation(),i&&l(dt,r))}})}function m(){R.strict||j(I,!0),X=Q(!0,X,Object.reject(I,["data"])),M=z(Q(!0,{},I.ui||{}),X,R),X.radio&&(X.radio=D(X.radio)),X.expose&&(X.expose=_(X.expose)),q=Number.random(268435456,4294967295).toString(16),C=I.id||"my"+q,S=ct.sdbmCode(C),X.id=C,R.form=dt,I.params&&I.params.depth&&(R.recalcDepth=I.params.depth);for(P in X)A(X[P])&&(X[P]=X[P].bind(X));I.error&&($(X.error)?nt=function(e,t){return X.error.assign(Q({message:e+"",err:t+""},X))}:A(I.error)&&(nt=function(e,t){T=null;try{T=I.error(e,t)}catch(r){T=R.messages.initFailed}return T})),Q(dt.data("my"),{id:C,cid:q,mid:S,errors:Object.extended(),ui:Object.extended(M),disabled:!1,manifest:X,locFiles:[],modals:{},radio:{}}),dt.addClass("my-form"),L="my-manifest-"+S,H="my-form-"+q,dt.addClass(H+" "+L)}function h(t){function r(e,t){return'"}!X.style||t&&!dt.is(":visible")||(U=N(dt,X,L,H),U&&U[0].length&&!t&&(J=e("style#"+L),J.size()||(J=e(r(U[0],L)).appendTo(e("body"))),J.data("count",1*J.data("count")+1),dt.data("my").style=J),U&&U[1].length&&(W=e("style#"+H),W.size()?t&&(e(r(U[1],H)).replaceAll(W),W=e("style#"+H)):(W=e(r(U[1],H)).appendTo(e("body")),R.restyle>-1&&!B[q]&&(B[q]=function(){h(!0)}.debounce(R.restyle)),dt.data("my").restyle=h.fill(!0).debounce(0)),dt.data("my").localStyle=W,t||dt.addClass("my-restyle")))}function p(){var t,r,n=e.Deferred();if(r=s(X),$(r))x("Error decoding base64 to local Blob/URL",r),n.reject();else{if(E)for(t=0;t*").clone();try{K=w(X,I.init,dt,I)}catch(t){return x($(t)?t:t.message,t.stack),dt}}if(at(K)?K.then(function(){v()},function(e,t){x(e,t)}):v(),!rt){if(!dt.my())return x("Internal error initializing controls.",""),dt;dt.data("my").initial=Q(!0,{},G),e.mobile&&e.mobile.changePage(e.mobile.activePage)}}function v(){function e(e){rt||(t[e]=u(dt.find(e),V),r-=1,.5>r&&b(t))}var t={},r=Object.size(M);dt.addClass(it),Object.each(M,function(t){if(!rt){var r=dt.find(t),n=g(r,dt,M[t],t);at(n)?n.then(e.fill(t)).fail(function(e,r){x("Error building "+t+", "+e,r)}):rt||e(t)}})}function b(e){var r,n,i;for(var a in M){if(rt)return;if(r=M[a],i=dt.find(a),i.size()){r.listen&&(et[a]=i.eq(0));try{n=f(G,V,r,i),n==V&&e[a]!=V&&void 0!==n&&f(G,e[a],r,i)}catch(o){t("Transient fail linking "+a+" of form $('.my-form-"+q+"')",o.message,o.stack)}try{n!=V&&u(i,n),i.eq(0).trigger("check.my")}catch(o){x("Error linking "+a,o.message,o.stack)}}}dt.removeClass(it),ut=null,tt.resolve(G)}function x(e,r){var n;if(rt=!0,t("Form "+C+" failed to initialize.",e,r),dt.removeClass(it),n=nt(e,r),$(n)||F(n)&&n.jquery?dt.html(n):n===!0&&dt.html(ut),R.silent)tt.resolve(G);else{if(!dt.my().ddata){if(dt.removeData("my"),dt.removeClass("my-form"),J)if("1"==J.data("count"))try{J.remove()}catch(i){}else J.data("count",J.data("count")-1);if(W)try{delete B[q],W.remove()}catch(i){}}tt.reject("Form "+C+" failed to initialize: "+e,r)}}var k,O,C,q,S,T,M,R,I,P,U,L,H,J,W,K,X={},G={},Y=[],et={},tt=e.Deferred(),rt=!1,nt=function(){},it="my-form-init",st="std",ut="";if($(i)){if(k=ot(i),!k)return tt.reject("No manifest with id "+i+" found in repo."),tt.promise();F(o)&&F(a)?(k=Q(k,a),O=o):O=a,st="repo"}else k=i,O=a;if(!k)return this;I=F(O)&&"repo"!=st?Q(!0,{},k):k;var dt=this.eq(0),ft=dt.my();return F(ft)&&ft.id&&ft.ui?(r("jQuery.my is already bound.",dt),dt.my("ui",I.ui),dt.my(Z,I.data),tt.resolve(dt.my(Z)).promise()):(R=I.params||{},R.strict||(R=Q(!0,{},R),j(R)),R=Q(!0,{},lt.params,R),tt.fail(function(){dt.removeClass(H+" "+L)}),Q(dt,tt.promise()),F(O)?(G=ct.patch(O,I.data||{}),I.data=G):G=I.data||{},X.data=G,dt.data("my",{data:G,params:R,promise:tt.promise(),locktill:0}),dt.addClass(it),I.inherit&&c(I),ct.require(I,R).then(function(){m(),p().then(function(){h(),y()})}).fail(function(e){m(),x("Linker of ‘require’ property failed.",e)}),tt.then(d),dt)},redraw:function(e,t){var r=this,n=r.my();return n&&n.ui&&(n.ui.each(function(t){var i=r.find(t);y(i,e?V:void 0,n.params.recalcDepth),e||(i.is(".my-form")&&i.my("redraw"),i.trigger(i.is(".my-form-list")?"redraw":"check.my"))}),!t&&e&&r.trigger(nt)),r},data:function(e,t){var r=this;return F(e)&&(r.my().data=ct.overlap(r.my().data,e),this.my("redraw",t)),r.my().data},errors:function(){var t=e(this).my().errors,r={};for(var n in t)t[n]&&$(t[n])&&(r[n]=t[n]),F(t[n])&&H(t[n]).length&&(r[n]=t[n]);return r},valid:function(){var t=e(this).my().errors,r=0;for(var n in t)t[n]&&$(t[n])?r++:F(t[n])&&H(t[n]).length&&r++;return!r},reset:function(){try{ct.kickoff(this.my().data,this.my().initial),this.my("redraw")}catch(e){return!1}return!0},id:function(e,t){if($(e))return ot(e,t);var r=this.my();return r&&r.id?r.id:V},remove:function(e){var t,r,n,i,a,o,s,l,c=this;if(!this.my())return V;if(this.my().root&&!this.my().ddata&&(c=this.my().root),n=c.my(),a=n.data,s=n.cid,l=n.mid,c.unbind(".my"),F(n)&&n.manifest&&A(n.manifest.die))try{n.manifest.die.call(n.manifest,c,n.manifest)}catch(u){}if(t=n.style)if("1"==t.data("count"))try{t.remove()}catch(u){}else t.data("count",t.data("count")-1);if(r=n.localStyle)try{delete B[s],r.remove()}catch(u){}if(window.URL&&(i=n.locFiles)&&i.length)for(var f=0;fo?V:(n.params.errors&&n.params.errors.values().compact(!0).length?Object.equal(n.data,n.lastCorrect)||(o+=1):Object.equal(i[a.last()],n.data)&&(o+=1),t=v(o,n.params,!0),t&&(ct.kickoff(r.my().data,t),r.my("redraw")),r.my().data)},ui:function(e){var t,r=this,n=r.my(),i=[];if(!n)return V;Q(!0,{},n.ui);if(!F(e))return n.ui;for(t in e)i.push(t);for(n.ui=z(ct.overlap(n.ui,e)),t=0;t1&&l(t[1])){for(var n,u,f,m,h,p,y,v,g=t[0],b="",x=1;x'+(g?"<"+r.labelTag+' class="'+r.labelCss+'" '+(r.label?'style="display:inline-block;width:'+r.label+";margin-left:-"+r.label+'" ':"")+">"+g+"":"")+b+""),e+b}return e}function r(e){var t=e;if(l(t)&&(t=t.split(/[\s,]/).compact(!0)),s(t)){for(var r={},n=0;n',inp:u+'text" {ext}/>',sli:u+'range" {ext}/>',dat:u+'date" {ext}/>',btn:u+'button" {ext}/>',pwd:u+'password" {ext}/>',but:"",div:"
{txt}
",spn:"{txt}",sel:"",mul:'',txt:"",err:' {txt}',msg:'
{txt}
',val:function(e){if(!s(e.vals))return"";var t=i({style:"",css:""},e);return t.txt=e.vals.reduce(function(e,t){return e+""+t+" "}," "),'{txt}'.assign(t)},"":"<{_tag} {ext}>{txt}"},txt:{sel:function(e){if(!e.vals)return"";var t=r(e.vals);return Object.keys(t).reduce(function(e,r){return e+'"},"")}},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"}},f={init:function(t,r){return e(this).html(n(t,r))}};e.my||(e.my={}),e.my.formgen=n,e.fn.formgen=function(t){return l(t)&&f[t]?f[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void e.error("Method "+t+" does not exist on jQuery.formgen"):f.init.apply(this,arguments)}}(jQuery),function(e){function t(t,r,n,i){var a,s,l,d,f,m,h;if("object"==typeof r&&r.jquery)r.is("img")&&(m=r,f=r.attr("alt")||r.attr("title")||r.data("text")||"",s=m[0].naturalWidth||m[0].width,a=m[0].naturalHeight||m[0].height,1>a&&(a=1),1>s&&(s=1),d=e(window).width()-90,l=e(window).height()-90,a>l&&(s=s*(l/a)|0,a=l),s>d&&(s=d,a=a*(d/s)|0),h=300>s?300:s,o(t,{source:"image",manifest:{init:function(e){e.html(this.HTML),e.on("click.my","img:eq(0)",function(){e.trigger("cancel")})},HTML:'

',ui:{"img:eq(0)":"img",h4:{bind:"text",css:{hide:function(e,t){return!t}}}}},data:{img:m.attr("src"),text:f},esc:!0,screen:!0,width:i||h,focus:!1,global:!0,z:"1995"},n));else if(u(r)&&r.manifest)o(t,r,n);else{if(!c(r))return null;o(t,{source:"html",manifest:{init:function(e){e.html(this.HTML)},HTML:r,ui:{"div:eq(0)":function(){}}},data:{},esc:!0,focus:!1,width:i},n)}return t}var r,n={},i="body",a=!1,o=e.extend,s={},l=(Object.isArray,Object.isBoolean),c=Object.isString,u=Object.isObject,d=Object.isNumber,f=(Object.isRegExp,Object.isFunction);e(document).keydown(function(e){var t,r,n=e.keyCode;if(!1!==a&&(13===n||27===n)){if(r=a.data("modal"),t=r.form,27==n&&(r.esc||Object.equal(t.data("my").initial,t.my("data"))))return a.modal(!0),!1;if(13==n&&r.enter)return function(e){e.modal()}.fill(a).delay(50),!1}}),n.modal=function(r,n,o){var s,c={},u=e(i),d=u.find(">.my-modal-proxy"),m={global:!0,screen:!0,done:f(n)?n:void 0,z:"1995"};return l(r)||null==r?d.modal(r):(s=e.Deferred(),t(c,r,m,o)?a?s.reject("Locked").promise():(d.size()||(d=e('
').prependTo(u),d.css({position:"absolute",top:"0",left:"0",margin:"0",padding:"0",width:"1px",height:"0"})),d.modal(c)):s.reject("Invalid data").promise())},n.modal.loading=function(t){e(i).find(">.my-modal").toggleClass("my-modal-loading",!!t)},n.modal.parent=function(t){return t&&e(t).size()?void(i=t):e(i)},n.modal.parentBack=function(t){return t&&e(t).size()?void(r=t):e(r||i)},n.modal.visible=function(){return!!a},e.my||(e.my={}),e.my.modal=n.modal,e.fn.modal=function(n,m,h){function p(){var t,r,n=window,i=!!M.global,a=w.offset(),o=D.offset();M.pos={px:a.left,py:a.top,pw:w.outerWidth(),ph:w.outerHeight(),ox:o.left,oy:o.top,ow:D.outerWidth(),oh:D.outerHeight(),ww:r,wh:t};var s=1*(M.x.match(/\-?\d+(\.\d+)?/)||[0])[0],l=1*(M.y.match(/\-?\d+(\.\d+)?/)||[0])[0],c=M.x.has("left")?-1:M.x.has("right")?1:0,u=M.y.has("top")?-1:M.y.has("bottom")?1:0,f=M.pos.ox+M.pos.ow/2-M.pos.px,m=M.pos.oy+M.pos.oh/2-M.pos.py;if(i&&(M.pos.wh=t=n.innerHeight||e(n).height(),M.pos.ww=r=n.innerWidth||e(n).width(),f=r/2,m=t/2.5),s=M.x.has("%")?M.pos.ow/100*s:s,l=M.y.has("%")?M.pos.oh/100*l:l,M.pos.pix=f,M.pos.piy=m,f=f+c*(M.pos.ow/2)+s*(c>0?-1:1)-(M.width+_)*(c+1)/2,i?(m=(t-M.height-20)/3,10>m&&(m=10)):m=m+u*(M.pos.oh/2)+l*(u>0?-1:1)-(M.height||0)*(u+1)/2,f=f.round(1),m=m.round(1),M.pos.vx=f,M.pos.vy=m,M.bound!==!1&&!M.global){var h=(d(M.bound)?M.bound:0).clamp(-100,100);M.pos.pw-2*hM.pos.pw-h?M.pos.vx=M.pos.pw-h-M.width-_:M.pos.vxM.pos.ph-h?M.pos.vy=M.pos.ph-h-M.height:M.pos.vy');var r="",n=e("style#my-modal-style-"+M.cid);("top"==M.nose||"bottom"==M.nose)&&(r+="div.my-modal-"+M.cid+".nose-"+M.nose+":before {left:"+(M.pos.ox-M.pos.px+M.pos.ow/2-M.pos.vx)+"px!important;}",n.text(r)),("left"==M.nose||"right"==M.nose)&&(r+="div.my-modal-"+M.cid+".nose-"+M.nose+":before {top:"+(M.pos.oy-M.pos.py+M.pos.oh/2-M.pos.vy)+"px!important;}",n.text(r))}M.screen?M.global?(j.css({top:0,left:0,width:2*M.pos.ww+"px",height:2*M.pos.wh+"px",display:"block",position:"fixed","z-index":M.z-1}),c(M.screen)&&j.css({background:M.screen?M.screen:"rgba(25, 39, 59, 0.88)"})):j.css({top:0,left:0,position:"absolute",width:M.pos.pw+"px",height:M.pos.ph+"px",display:"block",background:c(M.screen)?M.screen:"rgba(40,80,120,0.6)","z-index":M.z-1}):j.size()&&j.hide(),M.height>M.pos.wh?(b.height(M.pos.wh-30),x.css({"overflow-y":e.browser.webkit?"overlay":"scroll"})):x.css({"overflow-y":"none"}),b.animate({top:M.pos.vy+"px",opacity:"1"},M.animate)}function v(){try{x.my("remove")}catch(t){}try{w.data("modals")[M.cid]=null}catch(t){}x.parent().unbind(".my").remove(),j.off(".my"+M.cid),M.screen&&function(e){e&&a||j.hide(),e&&!a&&j.css({background:"rgba(25, 39, 59, 0.88)"})}.delay(50,M.global),M.global&&(a=!1,e("body").css({overflow:"auto"}))}function g(e){try{S(null,null)}catch(t){}(function(){q.reject(e)}).delay(0)}var b,x,w,j,k,O,C,q=e.Deferred(),z={},D=this,_=0,N=0,S=f(m)?m:function(){return!1},T=u(n)?n:{},M=D.data("modal");if(o(D,q.promise()),M){if(null==n||l(n)){if(x=M.form,j=M.bg,w=M.root,S=M.done,O=x.my("data"),C=!1,n){try{S(null,null)}catch(E){}if(v(),D.removeData("modal"),s[M.cid])try{s[M.cid].reject("Cancelled")}catch(E){}delete s[M.cid],M=null}else{try{C=S(x.my("valid")?null:x.my("errors"),O)}catch(E){}C||(v(),D.removeData("modal"),function(){s[M.cid]&&s[M.cid].resolve(O),delete s[M.cid],M=null}.delay(0))}return D}if(T)return g("Locked"),D}return D.is(":visible")?(T=t(z,n,{}))?T.global&&a?(g("Locked"),D):(M=o({type:"DOM",source:"manifest",form:null,modal:null,root:null,bgroot:null,caller:D,manifest:{},data:{},global:!1,screen:!1,drag:!1,focus:!0,close:!0,silent:!0,esc:!1,enter:!1,bound:!1,nose:"",width:h||300,height:null,x:"0",y:"0",z:"1901",background:"white",css:"",animate:200},T,{promise:q.promise(),cid:Number.random(268435456,4294967295).toString(16)}),M.done=f(M.done)?M.done:S,c(M.align)&&M.align&&(M.x=(M.align.match(/(left|right):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0],M.y=(M.align.match(/(top|bottom):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0]),M.width=1*(e.my.f.getref(c(M.manifest)?e.my.cache(M.manifest):M.manifest,"params.width")||M.width),M.type="DOM",D.hasClass("my-form")?(M.type="form",M.root=M.root||D):D.data("my")?(M.type="control",M.root=M.root||D.my().root):(M.root=M.root||D.parents(".my-form").eq(0),M.root.size()||(M.root=e(i))),M.global?(M.root=e(i),M.bgroot=e(r||i)):M.bgroot=M.root,w=M.root,w.data("modals")||w.data("modals",{}),p(),b=e('
').prependTo(M.root),b.addClass("my-modal-"+M.cid),_=b.outerWidth(),N=b.outerHeight(),b.hide(),b.html('
'),x=b.find(".my-modal-form"),M.close&&(k=e(c(M.close)?M.close:'
×
').prependTo(b).on("click.my",function(){D.modal(!0)}),k.css({"z-index":("+"===(M.z+"").to(1)?"+":"")+(1*M.z+1)})),j=M.bgroot.find(">.my-modal-screen"),M.screen&&(j.size()||(j=e('').prependTo(M.root)),M.esc&&j.on("click.my"+M.cid,function(){D.modal(!0)})),D.data("modal",M),M.silent&&b.on("change.my",function(){return!1}),b.css({display:"block",height:"none",opacity:"0.005","z-index":M.z,width:"auto"}),b.css(M.global?{position:"fixed",left:"50%",top:M.pos.vy+"px",display:"block",height:"none",opacity:"0.005","z-index":M.z,width:"auto","margin-left":"-"+((M.width+_)/2).round(0)+"px"}:{position:"absolute",left:M.pos.vx+"px",top:M.pos.vy+"px",display:"block",height:"none",opacity:"0.005","z-index":M.z,width:"auto"}),x.my(M.manifest,M.data).then(function(){var t,r,n,i,l;if(o(M,{form:x,bg:j,cancel:function(){D.modal(!0)},commit:function(){D.modal()}}),b.data("modal",M),M.height=b.outerHeight(),"manifest"!==M.source&&(M.width=b.width()),p(),b.css({top:M.pos.vy+"px"}),y(!0),w.data("modals")[M.cid]=M,s[M.cid]=q,x.bind("commit.my",function(){return M.commit.delay(50),!1}).bind("cancel.my",function(){return M.cancel.delay(50),!1}),b.bind("layout.my",function(){y()}.debounce(50)),M.global&&(a=D,e("body").css({overflow:"hidden"})),M.global||!M.esc&&!M.enter||x.bind("keydown.my",function(t){var r=t.keyCode;return 27==r&&M.esc?(M.cancel(),!1):13==r&&M.enter&&!e(t.target).is("textarea")?(M.commit.delay(50),!1):void 0}),M.focus===!0){i=!1,l=M.manifest.ui;for(n in l)i||(r=x.find(n),r.size()&&r.is("input, textarea","button")&&(i=!0,r.focus()))}else c(M.focus)&&x.find(M.focus).focus();if(t=x.find("img").filter(function(){return""!=e(this).attr("src")}),t.size()){var u=function(){"manifest"!==M.source&&b.css({width:"auto"}),y()}.after(t.size());t.each(function(){e(this).bind("load",u)})}M.drag&&e.fn.draggable&&(c(M.drag)?b.draggable({handle:M.drag}):b.draggable(),M.nose&&b.on("dragstart.my",function(){b.removeClass("nose-"+M.nose)})),q.notify("Ready")}).fail(function(e){v(),D.data("modal",null),q.reject(e)}),D):(g("Invalid data"),D):(g("Object must be visible"),D)}}(jQuery); \ No newline at end of file +!function(e){function t(){window.console&&console.error.apply(console,arguments)}function r(){window.console&&console.log.apply(console,arguments)}function n(e,t){return(P(t)?t.split("."):R(t)?t:[""]).reduce(function(e,t){if(null!=e){if(/=/.test(t)){var r=t.split("=",2);return $(e)?Object.values(e).find(function(e){return $(e)||R(e)?e[r[0]]==r[1]:!1}):R(e)?e.find(function(e){return $(e)||R(e)?e[r[0]]==r[1]:!1}):void 0}if(null!=e&&null!=e[t])return e[t]}return void 0},e)}function i(e,t){var r,i;if($(t))return t;if(P(t)){if(r=n(e,t),null==r&&(r=Object.clone(H._src[t],!0)),null==r&&(r=n(H,t),$(r)&&$(r._self)?r=Object.clone(r._self,!0):$(r)&&(r=Object.clone(r,!0))),null==r&&n(e,"params.cache")&&(i=n(e,"params.cache"),A(i)?r=i(t):$(i)&&(r=at(t,i)),$(r)&&($(r._self)&&(r=Object.clone(r._self,!0)),Object.merge(r,{params:{cache:i}},!0))),null!=r&&$(r))return i=i||n(e,"params.cache"),i&&Object.merge(r,{params:{cache:i}},!0),r;throw"Component "+t+" not found."}return A(t)?t.apply(e,Array.prototype.slice.call(arguments,2)):null}function a(r,i){var a,s,l,c,u,d=i||H,f=r;if(!($(d)&&$(f)&&$(f.ui)&&P(f.id)))return"Can’t save manifest into cache, invalid arguments.";d.hasOwnProperty("_src")||(d._src={}),l=f.id;try{f=Object.clone(r,!0)}catch(m){return"Can’t save circular-referencing object into cache."}try{(!f.params||f.params&&!f.params.strict)&&w(f,!0)}catch(m){return"Invalid manifest, parse error."}if(a=o(f),P(a))return t(a),a;if(Object.merge(f,{params:{strict:!0}},!0),d._src[l]=f,c=lt.mask(d,l)){if(c.params&&c.params.protect)return"Can’t save manifest into cache over protected one.";c._self&&delete c._self,e.extend(!0,d,lt.unmask("",l))}return e.extend(!0,d,lt.unmask(f,l)),s=Object.keys(d._src).filter(function(e){return e.startsWith(l+".")}),s.sort(),s.forEach(function(t){var r;(r=lt.mask(d,t))&&(r._self&&delete r._self,e.extend(!0,d,lt.unmask("",t))),e.extend(!0,d,lt.unmask(d._src[t],t))}),u=n(d,l),M?u._self=d._src[l]:Object.defineProperty(u,"_self",{get:function(){return d._src[l]},set:function(){throw"Can’t change manifest cache entry directly."},enumerable:!1,configurable:!0}),u}function o(e){var t,r,n=[];if($(e.files)&&Object.size(e.files))for(t in e.files){if(r=e.files[t],!$(r))return"Non-object member "+t+" in files section.";if(P(r.data)&&!r.url)if(E)try{lt.base642blob(r.data,function(e){r.blob=e,r.url=E.createObjectURL(r.blob)},r.content_type||r.mime),n.push(t)}catch(i){return"Invalid base64 data in files/"+t+"."}else r.url="data:"+(r.content_type||r.mime)+";base64,"+r.data,n.push(t)}return n}function s(r,n){$(n)&&n.channel&&n.message&&r.find(".my-listen-"+lt.sdbmCode(n.channel)).each(function(){var r,i=e(this),a=i.data("my"),o=void 0;if(a&&a.ui.listen&&A(a.ui.listen[n.channel])){r=a.ui.listen[n.channel];try{o=r.call(a.manifest||a.root.my().manifest,a.data,n.message,i)}catch(s){t("Listener failed",s.message,s.stack)}void 0!==o&&(null===o?i.trigger("check"):o&&i.trigger("recalc"))}})}function l(t,r){function i(t,r){var n;return P(t)?/[\/]/.test(t)?(n=B(!0,{},k,{ref:r,ajax:{url:t}}),nt.test(r)&&(n.ajax.dataType="json")):t.length&&(n=B(!0,{},k,{ref:r,ajax:t})):$(t)&&(n=B(!0,{},k,{ref:r,ajax:e.extend(!0,{},Object.select(t,["accepts","async","cache","data","dataType","xhrFields","password","timeout","type","url","username","headers"]))}),n.ajax.url||(n=null)),n}function a(){g.reject(w)}function o(){O+=1;var e=b[O];if(e)s(e).then(o).fail(a);else{var r=c(x),n=L(Object.findAll(r,function(e,t){return!t}));n.length&&w.push((1===n.length?"Key "+n[0]+" is":"Keys "+n.join(", ")+" are")+" not present after all."),w.length?a():g.resolve(t)}}function s(r){function n(){c-=1,s?l.reject():.5>c&&l.resolve()}var i,a,o,s=!1,l=e.Deferred(),c=r.length;for(a=0;c>a;a++)i=r[a],o=P(i.ajax)?j.loader:ot,o(i.ajax).then(function(e,r){nt.test(r.ref)&&(null!=e?B(!0,t,lt.unmask(e,r.ref.from(5))):(s=!0,w.push("Invalid data for ‘"+r.ref+"’ resource."))),n()}.fill(void 0,i)).fail(function(e,t){w.push("Failed to load ‘"+t.ref+"’ resource."),s=!0,n()}.fill(void 0,i));return l.promise()}function l(e){var r=!1;return nt.test(e)?null!=n(t,e.from(5))&&(r=!0):null!=n(window,e)&&(r=!0),r}function c(e){for(var t in e)e[t]===!1&&(e[t]=l(t));return e}var u,d,f,m,h,p,y,v,g=e.Deferred(),b=[],x={},w=[],j=B(!0,{ajaxTimeout:1e4,loader:st.params.loader},r||{}),k={ref:null,ajax:{type:"GET",async:!0,timeout:j.ajaxTimeout}};if($(t))if(R(t.require)){for(m=t.require,u=0;ui)return n=l,void(i=o);c==G&&r(e,l,o+1)}W!=t[""]&&typeof t[""]!=G&&o>i&&(n=t[""],i=o)}var n=W,i=0,a="";return r(e,t,1),n}function d(e,t,r,n){var i,a,o,s=[],l=r.bind,c=Q(l);if(c==tt)return l.call(m(n).manifest,e,t,n);if(c===et||c===Z){if(c===et&&!/\./.test(l))return t!=W?e[l]=t:void 0===e[l]&&(e[l]=W),e[l];for(c===et&&(s=l.split(".").each(function(e,t){this[t]=e+""})),c===Z&&(s=l.slice(0).each(function(e,t){this[t]=e+""})),"this"===s[0]?(a=m(n).manifest,s.shift()):a=e,i=0;i-1?"":u;case"s":return r==s?"":u;case"o":return s[r]?"":u;case"b":if(i.is(".my-form-list,.ui-sortable")){var f=i.data("listSrc")||i.data("my").listSrc||">*",h={};return i.find(f).filter("*:not(.ui-sortable-placeholder)").each(function(t){var r=e(this);r.data("my")&&!r.my("valid")&&(h[t]=r.my("errors"))}),h}return i.hasClass("my-form")&&s?i.my("valid")?"":i.my("errors"):""}return l.formError||"Error"}return""}function m(e){var t=e.my();return t?t.root?t.root.my():t:null}function h(t,r,n){var i=n.compact(),a=i.replace(/:disabled/g,""),o=a!==i,s="self:"===a.to(5);return s&&(a=a.replace(/^self:/g,"")),r.each(function(){var n=e(this),i=n.my(),l=!s&&i?i.container:n;l.toggleClass(a,!!t),o&&void 0!==i&&!!t!=!!i.disabled&&(n.my().disabled=!!t,i._disable||(n.my()._disable=u(r,st.offon).fill(void 0,r)),i._disable(!!t))}),r}function p(e,r,n){var i,a,o,s,l,u,m,y,v,g,b,x,w=!1,j=!1,k=e,O=k.my(),C="";if(O){if(v=O.selector,g=O.root,g.hasClass("my-form-init"))return{};if(b=g.find(v),x=g.my().ui,w=e.hasClass("my-form"),j=e.hasClass("my-form-list"),w?(a=e,o=O.ddata,s=O.dui,l=O.dparams):(a=O.container,o=O.data,s=O.ui,l=O.params),s.bind!=W){if(u=V(r)?r:c(b,d(o,W,s,b)),W!=s.check){C="Unknown error";try{C=f(o,u,s,b)}catch(q){t("Error "+q.message+" in .check validator for "+v,g,q.stack)}}var z=l.errorCss,D="ui-state-error";try{W!=r&&(u=c(b,d(o,r,s,b)))}catch(q){C=l.messages.formError||"Error"}if(""===C)w?O.derrors[v]="":O.errors[v]="",a.removeClass(z),a.attr("title")&&a.attr("title",""),w||j||l.effect(a.find(l.errorTip),!1,l.animate/2),k.removeClass(D),k.find(".ui-widget").removeClass(D);else{if(w)O.derrors[v]=C;else if(j)O.errors[v]=C;else{a.addClass(z),O.errors[v]=C;var N=a.find(l.errorTip).eq(0);N.size()?l.effect(N.addClass(z).html(C),!0,l.animate):a.attr("title",(C||"").stripTags())}k.is(".hasDatepicker")&&(k.is("input")?k.addClass(D):k.find(".ui-widget").addClass(D)),k.is(".ui-slider")&&k.addClass(D)}}var _=r==W?u:r;if(s.css)for(m in s.css)y=s.css[m],U(y)?h(y.test(_),b,m):A(y)&&h(y.call(g.my().manifest,o,_,b),b,m);var i,T,S=s.recalc,E=[],M={};if(n&&s.recalc&&g.my()){for(x=g.my().ui,i=0;i=2*s){for(f={},a=s;2*s>a;a++)f[o[a]]=i[o[a]];t.history=f}return n||m.form.trigger(rt),m.history[o.last()]}if(!isNaN(e)||e===W){if(l=parseInt(e)||0,0>l)return W;if(o=L(i).sort(),l>=o.length&&(l=o.length-1),d=Object.clone(m.history[o[o.length-l-1]],!0),r){for(f={},a=0;a$/.test(C.list)?s=C.list:c=C.list||c,!s){var u=a.find(c);s="
",u.size()&&(s=e(s).append(u.eq(0).clone(!0)).html(),u.eq(0).remove())}a.data("formlist")||a.data("formlist",{}),a.data("formlist").generator={manifest:w,delay:(C.delay||O.delay||10)/1.3,template:s,selector:c,parent:D,bind:C.bind,hash:A(C.hash)?C.hash.bind(D):P(C.hash)?f.fill(void 0,C.hash):R(C.hash)?m.fill(void 0,C.hash.slice(0)):null,id:A(C.id)?C.id.bind(D):P(C.id)?f.fill(void 0,C.id):R(C.id)?m.fill(void 0,C.id.slice(0)):null,ext:!(!C.id&&!C.hash),stamp:0},a.on("insert.my",function(t,r){t.stopPropagation();var n={what:void 0,where:0};null==r?n.where=1e6:$(r)?Object.merge(n,r):(P(r)||F(r))&&(n.where=r),e(t.target).my("insert",n.where,n.what)}),a.on("remove.my",function(t){t.stopPropagation(),e(t.target).my("remove")})}else try{t=a.my(i(D,w),$(o)?o:void 0)}catch(p){d("$.my subform init of "+l+" failed: "+p.message,p.stack)}}it(t)?t.then(h,function(e,t){d("Init of subform "+l+" failed with error: "+e,t)}):h()}function d(e,r){t(e,r),q&&q.reject(e,r)}function f(e,t){var r=n(e,t)||"";return"string"==typeof r?r:lt.sdbmCode(r)}function m(e,t){return lt.sdbmCode(lt.mask(e,t))}function h(){a.each(function(){var t,r,n,i=e(this),c=!1;if("TEXTAREA"==i[0].nodeName&&(n=i[0].nextSibling,r=n&&n.CodeMirror?n.CodeMirror:null,r&&i.addClass("my-codemirror")),t=C.events||u(i,st.events),i.is(".my-form")?B(i.data("my"),{dui:C,root:o,selector:l,dparams:O,devents:t,ddata:k.data,container:O.container(i),derrors:k.errors}):(i.data("my",{events:t,selector:l,initial:v,previous:v,root:o,container:O.container(i),id:k.id,ui:C,data:k.data,params:O,errors:k.errors}),s._update=C.delay?p.debounce(C.delay):W,c=!0),c)if(i.cleditor&&i.parent().is(".cleditorMain")){var d=i.cleditor()[0];if(d&&d.$frame&&d.$frame[0]){i.addClass("my-cleditor"),B(i.data("my"),{container:O.container(i)});var f,m=function(e){i.val(e).trigger(rt)},h=Number.random(1e5,1e6-1);e(d.$frame[0]).attr("id","cleditCool"+h),f=document.frames?document.frames["cleditCool"+h].document:e("#cleditCool"+h)[0].contentWindow.document;var y=e(f).find("body");e(f).bind("keyup.my",function(){m(e(this).find("body").html())}),i.parent().find("div.cleditorToolbar").bind("click.my mouseup.my",function(){m(y.html())}),e("body").on("click","div.cleditorPopup",function(){m(y.html())})}}else if(i.is("div.redactor_box textarea")){var x,w="my-redactor-9";try{x=i.getEditor(),w="my-redactor-8"}catch(q){x=i.redactor("getEditor")}x&&(i.addClass(w),x.bind("input.my keyup.my blur.my",function(e){e.trigger("redactor")}.fill(i)))}else i.is(".ace_editor")?ace.edit(a[0]).on(rt,function(e){e.trigger("ace")}.fill(i)):r&&r.on(rt,function(e){e.trigger("codemirror")}.fill(i));i.my()._changed=g.debounce(j),i.my()._recalc=b.debounce(j),i.bind(t,function(e){e.type==rt&&e.stopPropagation(),c&&(k.locktill=Date.now()+s.delay),i.my()._changed(i,o,s,O)}),/check(\.my)?/.test(t+"")||i.on("check.my",function(){return i.my()._changed(i,o,s,O,!0),!1}),c||i.off("redraw.my"),i.on("recalc.my, redraw.my",function(e){e.stopPropagation(),i.my()._recalc(i,o,s,O)})}),q&&q.resolve()}var y,v,w,j,k=o.my(),O=(k||{}).params,C=s,q=null,z=0,D=k.manifest;return k?(j=s.delay,a.size()?(C.init!=W&&(y=x(D,C.init,a,k)),it(y)?(z+=1,q=e.Deferred(),y.then(c,function(e,t){d("Init of "+l+" failed: "+e,t)})):c()):r("Not found "+l+" selector.",o),q):(t("Failed to find $root building "+l+" selector."),null)}function g(e,t,r,n,i){var a=e.data("my"),o=t.data("my");if(a&&!a.disabled){y(a.ddata||a.data,a.dparams||a.params);var s=t.find(a.selector);p(e,i?W:c(s,W),r.recalcDepth||n.recalcDepth),void 0===o.orphan&&a.root.parent().hasClass("ui-sortable")&&(o.orphan=!a.root.parent().hasClass("my-form-list")),o.orphan&&a.root.parent().trigger("check"),n.change&&n.change.call(e)}}function b(e,t,r,i){var a=e.my();if(a&&!a.disabled){var o=t.find(a.selector);o.is(".my-form")?o.my("redraw"):p(e,o.is(".my-form-list")?n(o.my().data,o.data("formlist").generator.bind):W,r.recalcDepth||i.recalcDepth)}}function x(e,t,r,i){var a;if(P(t)){if(a=n(e,t),void 0===a)return r.html(t.assign(i.data)),null}else a=t;if(A(a))return a.apply(e,Array.prototype.slice.call(arguments,2));if(R(a))try{r.formgen(a)}catch(o){}return null}function w(e,t){var r,n=!t;for(r in e)e.hasOwnProperty(r)&&j(r,e,n)}function j(e,r,n){var i,a,o,s,l="";(n||!/^(data|files|require)$/.test(e))&&(i=r[e],l=Q(i),/^(ob|ar)/.test(l)?w(i):"string"===l&&/^(function[\s\n\t]+|new\sRegExp)/.test(i)&&((a=i.match(/^function([\s\n\t]+[\w_$][\w\d_$]*)?[\s\n\t]*\(([^\)]*)\)\s*\{([\s\S]*)\}[\s\n\r\t]*$/))&&4===a.length?(s=a[1]?a[1].replace(/[\s\n\t]/g,""):"",o=s.length?O(s,a[2],a[3]):k(a[2],a[3]),"function"==typeof o?r[e]=o:t("Invalid function in XJSON, skipped",o.message,o.stack,i)):(a=i.match(/^new\sRegExp\s*\(\/([\s\S]+)\/([a-z]*)\)$/))&&3===a.length&&(o=C(a[1],a[2]),"function"==typeof o.test?r[e]=o:t("Invalid RegExp in XJSON, skipped",o.message,o.stack,i))))}function k(e,t){var r;try{r=new Function(e,t)}catch(n){r={message:n.message,stack:n.stack}}return r}function O(e,t,r){var n;try{n=new Function("","return (function "+e+"("+t+"){"+r+"});")()}catch(i){n={message:i.message,stack:i.stack}}return n}function C(e,t){var r;try{r=new RegExp(e,t)}catch(n){r={message:n.message,stack:n.stack}}return r}function q(e,t,r){var i=$(t)?t:null;return Object.each(e,function(t,r){var n=typeof r;/^str|^fu/.test(n)&&(e[t]={bind:r})}),Object.each(e,function(t,a){var o,s,l,c=[],u=[],d=/\s?[,;]\s?/;a.recalc&&(P(a.recalc)?c=a.recalc.split(d):R(a.recalc)&&(c=a.recalc),c=c.compact(!0).unique()),c.length&&(e[t].recalc=c),null==a.bind&&(a.bind=function(){});var f;if(a.listen&&(f=z(a.listen),a.listen=Object.size(f)?f:void 0),a.hasOwnProperty("watch"))for(P(a.watch)?u=a.watch.split(d):R(a.watch)&&(u=a.watch.slice(0)),u=u.compact(!0).unique(),l=0;l2?f=lt.css2json(f):o.push(a+(/\{/.test(f)?f:"{"+f+"}"))),R(f)&&f.length)for(l=0;le?"0"+e:e}function t(e,a,o){var s,l,c,u,d=0,f=a||0,m=n;switch(o&&P(o)&&(d=String(o).length,m=String(o).repeat(10)),(typeof e).substr(0,3)){case"str":return i(e);case"num":return isFinite(e)?""+String(e):"null";case"boo":case"nul":return String(e);case"fun":return i(r(e.toString()));case"obj":if(!e)return"null";if(typeof e.toJSON===tt)return t(e.toJSON(),f+(o?1:0),o);if(s=[],R(e)){for(l=0;l-1))&&(n=a[i[o]]={}));else null!=t&&(e[r]=t);return e}var a,o,s;if(null==r?(a={},o=e,s=t):(a=e,o=t,s=r),$(o)&&$(s))return lt.mask(o,s);if(P(s)&&(s=[s],o=[o]),!R(s)||!R(a)&&!$(a))return null;if($(o)&&(o=s.reduce(function(e,t){return e.push(n(o,t)),e},[])),R(o)&&R(s)){for(var l=0;ll;l++)s[l]=i.charCodeAt(l);return n=new Blob([s],{type:r||"application/octet-stream"}),A(t)?void t(n):n},base64:function(t,r,n){var i=(Q(t),null),a=P(t)?t:e.my.tojson(t),o=P(n)?"data:"+n+";base64,":"";if(r){try{i=decodeURIComponent(escape(window.atob(a)))}catch(s){i=null}if(null!==i&&/(^".*"$)|(^\[.*\]$)|(^\{.*\}$)/.test(i))try{i=e.my.fromjson(i)}catch(s){i=null}return i}return o+window.btoa((n===!0?"":"")+unescape(encodeURIComponent(a)))},css2json:function(e){var t=(e+"").replace(/\/\*[\s\S]+\*\//gm,"").replace(/@charset[^;]+;/gim,"").replace(/[\n\t\s]+/g," ").replace(/\}/g,"}ᴥ").replace(/^\n+/g,"").replace(/[\n\s]+$/g,"").split("ᴥ").compact(!0).reduce(function(e,t){var r,n,i,a=t.trim();return/^[^{]+\{[^\}]+\}$/.test(a)&&(r=a.to(-1).split("{"),n=" "+r[0].trim(),i=r[1].trim(),";"!=i.last()&&(i+=";"),e[n]||(e[n]=""),e[n]+=i),e},{});return t}}}var T,S="jQuery.my 1.1.9",E=window.URL||window.webkitURL,M=!document.addEventListener,R=Object.isArray,I=Object.isBoolean,P=Object.isString,$=Object.isObject,F=Object.isNumber,U=Object.isRegExp,A=Object.isFunction,L=Object.keys,H=n(e,"my.f.repo")?e.my.f.repo():{_src:{},_name:"Default manifest cache"},J=n(e,"my.f.restyles")?e.my.f.restyles():{},B=e.extend,Q=e.type,W=null,V=function(e){return null!==e&&void 0!==e},X="{yyyy}-{MM}-{dd}",K="{HH}:{mm}",G="object",Y="data",Z="array",et="string",tt="function",rt="change",nt=/^this\./,it=function(e){return!!(null!=e&&($(e)||e.jquery)&&A(e.then)&&A(e.fail)&&A(e.state))},at=function(e,t){var r,i;return P(e)?(r=e,i=n($(t)?t:H,r),"exist"===t?$(i):i?Object.clone(i,!0):null):$(e)?(i=a(e,t),$(i)?i:null):void 0===e?H._src:null===e?Object.reject(H,/^_/):null},ot=e.ajax,st={vals:{".my-form":function(e,t){if(e&&e.my){var r=e.my(Y);return Object.equal(r,t)?r:e.my(Y,t,!0)}return t||W},".hasDatepicker":function(e,t){V(t)&&e.datepicker("setDate",""==t?t:Date.create(t));var r=e.datepicker("getDate");return r?r.format(X):""},".my-tags":function(e,t){return V(t)&&(P(t)||F(t)?e.tags(Y,[t+""]):R(t)&&e.tags(Y,t)),e.tags(Y)},".ui-draggable":function(e,t){if(V(t)&&$(t)){var r={};isNaN(t.left)||(r.left=Number(t.left).ceil(2)+"px"),isNaN(t.top)||(r.top=Number(t.top).ceil(2)+"px"),(r.left||r.top)&&e.css(r)}var n=e.position();return{left:t&&!isNaN(t.left)?(1*t.left).ceil(2):n.left.ceil(2),top:t&&!isNaN(t.top)?(1*t.top).ceil(2):n.top.ceil(2)}},".my-form-list":function(t,r){function n(){var r,n,i=e(this),a=i.data("my");a&&(r=i.data("formlist"),n=r.index,r.hash=x(a.data,n)+"",r.oid=w!==x?w(a.data,n)+"":r.hash),t.trigger("check.my")}function a(e){e.data("my").locktill+k/1.3.my-form",g=y.template||"
",b=/\{/.test(g),x=y.hash||lt.sdbmCode,w=y.id||lt.sdbmCode,j=y.ext,k=y.delay||50,O=t.is("."+m),C=!!t.children(h).size(),q=[],z=[],D=Date.now(),N=t.find(O?t.sortable("option","items"):v);if(V(r)&&R(r)){if(C)return r;if(s=[],l={},N.each(function(){var t,r=e(this),n=r.data("my");n&&(s.push(n.data),(t=r.data("formlist"))&&(l[t.oid]=n.data))}),u=!1,s&&s.length===r.length)for(u=!0,o=0;o1.4*k||D-y.stamp>100||!y.stashed||y.stashed.length!==N.size()-(C?1:0)){C&&(f=t.find(">."+m+"-helper"));var M=0;for(N.each(function(t,r){var n,i,a,o=e(r),s=!1;C&&o.hasClass(m+"-helper")||(C&&o.hasClass(m+"-placeholder")&&(o=f),n=o.data("my"),i=o.data("formlist"),n&&i&&(q.push(n.data),M!=i.index&&(i.index=M,s=!0),j&&(a=x(n.data,M)+"",a!==i.hash&&(i.hash=a,s=!0)),M+=1,s&&z.push(o)))}),o=0;o."+a+"-placeholder",s=t.find(t.sortable("option","items"));if(V(r)&&R(r)){var l={},c={},u=r.unique();if(t.find("input:focus:eq(0),textarea:focus:eq(0)").size()||t.find(o).size())return u;s.each(function(){l[lt.sdbmCode(lt.extval(e(this)))]=e(this)});for(var d=u.length-1;d>=0;d--){var f=lt.sdbmCode(u[d]);l[f]&&(l[f].prependTo(t).show(),c[f]=!0,-1==i.indexOf(u[d])&&i.push(u[d]))}i=i.reverse();for(d in l)c[d]||l[d].hide()}else{var m=t.find(o),h=t.eq(0);0!=m.size()?(h.my()[a]!=m.position().left+""+m.position().top?(s=s.filter(":visible:not(:disabled, .ui-state-disabled, .ui-sortable-helper)"),n=t.find(t.sortable("option","items")).filter(".ui-sortable-helper"),s.each(function(){var t=e(this);i.push(lt.extval(t.is(".ui-sortable-placeholder")?n:t))}),h.my()[a]=m.position().left+""+m.position().top,h.my()[a+"1"]=i):i=h.my()[a+"1"],i==W&&s.each(function(){i.push(lt.extval(e(this)))})):(s=t.find(t.sortable("option","items")).filter(":visible:not(:disabled, .ui-state-disabled)"),s.each(function(){i.push(lt.extval(e(this)))}))}return i},"input[type=date]":function(e,t){if(V(t))return r=""!=t?Date.create(t).format(X):"",P(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(X):""},"input[type=time]":function(e,t){if(V(t))return r=""!=t?Date.create(t).format(K):"",P(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(K):""},input:{"[type='text'],[type='number'],[type='search'],[type='hidden'],[type='password'],[type='button'],[type='range'],:not([type])":{".ui-slider-input":function(e,t){V(t)&&e.val(t).slider("refresh")},".tagstrip input.value":function(e,t){V(t)&&e.val(t).trigger("update")},"div.select2-container+input":function(e,t){return V(t)&&JSON.stringify(t)!==JSON.stringify(e.select2("val"))&&e.select2("val",R(t)?t:[t]),e.select2("val")},"":function(e,t){V(t)&&e.val(t+"")}},":radio":function(t,r){var n=-1;if(V(r)){t.each(function(t){var i=e(this).val();r+""==i+""&&(n=t)});var i=t.eq(0).checkboxradio;if(i&&t.each(function(t){var r=e(this);n!=t&&r.is(":checked")&&r.prop("checked",!1).checkboxradio("refresh")}),n>-1){var a=t.eq(n);a.is(":checked")||(a.prop("checked",!0),i&&a.checkboxradio("refresh"))}else i||t.each(function(){e(this).prop("checked",!1)})}if(-1==n)for(var o=0;oForm init failed

',ru:'

Ошибка инициализации формы

'},badInput:{en:"Invalid input",ru:T},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(e){return e.parents('[data-role="fieldcontain"]').eq(0)}},".tagstrip *.value":function(e){return e.parents(".tagstrip").eq(0)},"div.redactor_box textarea":function(e){return e.parents("div.redactor_box").eq(0).parent()},".my-tags,.hasDatepicker,.ui-widget,input,textarea,select,button":{".my-cleditor":function(e){return e.parents("div.cleditorMain").eq(0).parent()},"":function(t){var r=t[0].parentNode,n=r.nodeName;return/^(div|span|a|p|form|fieldset|li|ul|td|th|h\d)$/i.test(n)?e(r):t.parents("div,span,a,p,form,fieldset,li,ul,td,th,h1,h2,h3,h4,h5,h6").eq(0)}},"":function(e){return e}},offon:{".ace_editor":function(e,t){ace.edit(t[0]).setReadOnly(e) +},".ui-selectable":function(e,t){lt.jquix(t,"selectable",e)},".ui-slider":function(e,t){lt.jquix(t,"slider",e)},".ui-draggable":function(e,t){lt.jquix(t,"draggable",e)},".ui-buttonset":function(e,t){lt.jquix(t,"buttonset",e)},".hasDatepicker":function(e,t){lt.jquix(t,"datepicker",e)},".my-form":function(e,t){t.my("disabled",!!e)},"div.select2-container+input,div.select2-container+select":function(e,t){lt.jquix(t,"select2",e)},".my-cleditor":function(e,t){t.cleditor()[0].disable(!!e)},"":function(e,t){t.attr("disabled",!!e)}},destroy:{".hasDatepicker":function(e){e.datepicker("destroy")},".ui-slider":function(e){e.slider("destroy")},".ui-sortable":{".my-form-list":function(t){t.find(">.my-form").each(function(){e(this).my("remove")}),t.removeClass("my-form-list"),t.sortable("destroy")},"":function(e){e.sortable("destroy")}},".my-form-list":function(t){t.find(">.my-form").each(function(){e(this).my("remove")})},".ui-draggable":function(e){e.draggable("destroy")},".my-redactor-8":function(e){e.destroyEditor(),e.removeClass("my-redactor-8")},"div.select2-container+input,div.select2-container+select":function(e){e.select2("destroy")},".my-form":function(e){e.my("remove")},textarea:{".my-codemirror":function(e){e[0].nextSibling.CodeMirror.toTextArea(),e.removeClass("my-codemirror")}}}};st.params={container:function(e){return u(e,st.containers)(e)},change:W,recalcDepth:2,delay:0,strict:!1,restyle:-1,locale:T=(navigator.language||navigator.userLanguage||"en").substr(0,2),messages:Object.map(st.msg,function(e,t){return t[T]||t.en}),errorTip:".my-error-tip",errorCss:"my-error",animate:0,effect:function(e,t,r){return t?e.fadeIn(r):void e.fadeOut(r)},remember:0,silent:!1,history:{},historyDelay:100,loader:function(t){var r=e.Deferred(),n=at(t+"");return n?r.resolve(n):r.reject(null),r.promise()},ajaxTimeout:1e4};var lt=_(),ct={init:function(i,a,l){function u(e){var t,r,i,a,o,s,l={},c=!0,u=e.inherit;if(l=D(u),!Object.size(l))return null;if(a=dt.parents(".my-form").eq(0),!a.size())return null;if(o=a.data("my"),!o||!o.manifest)return null;i=o.manifest,r=i.expose,c=!r;for(t in l)(c||r[t])&&(s=n(i,t),null!=s&&(/\./.test(t)||P(l[t])?B(!0,I,lt.unmask(s,P(l[t])?l[t]:t)):e[t]=s))}function f(){var e,r;for(var e in et)for(r in M[e].listen)et[e].addClass("my-listen-"+lt.sdbmCode(r));K.radio&&dt.on("radio.my",function(e,r){var n,i;if($(r)&&r.channel&&r.message&&A(K.radio[r.channel])){n=K.radio[r.channel];try{i=n.call(K,e,r)}catch(a){t("Radio handler for form "+T+"failed",a.message,a.stack)}void 0!==i&&(e.stopPropagation(),i&&s(dt,r))}})}function m(){R.strict||w(I,!0),K=B(!0,K,Object.reject(I,["data"])),M=q(B(!0,{},I.ui||{}),K,R),K.radio&&(K.radio=z(K.radio)),K.expose&&(K.expose=D(K.expose)),_=Number.random(268435456,4294967295).toString(16),C=I.id||"my"+_,T=lt.sdbmCode(C),K.id=C,R.form=dt,I.params&&I.params.depth&&(R.recalcDepth=I.params.depth);for(F in K)A(K[F])&&(K[F]=K[F].bind(K));I.error&&(P(K.error)?nt=function(e,t){return K.error.assign(B({message:e+"",err:t+""},K))}:A(I.error)&&(nt=function(e,t){S=null;try{S=I.error(e,t)}catch(r){S=R.messages.initFailed}return S})),B(dt.data("my"),{id:C,cid:_,mid:T,errors:Object.extended(),ui:Object.extended(M),disabled:!1,manifest:K,locFiles:[],modals:{},radio:{}}),dt.addClass("my-form"),L="my-manifest-"+T,H="my-form-"+_,dt.addClass(H+" "+L)}function h(t){function r(e,t){return'"}!K.style||t&&!dt.is(":visible")||(U=N(dt,K,L,H),U&&U[0].length&&!t&&(Q=e("style#"+L),Q.size()||(Q=e(r(U[0],L)).appendTo(e("body"))),Q.data("count",1*Q.data("count")+1),dt.data("my").style=Q),U&&U[1].length&&(V=e("style#"+H),V.size()?t&&(e(r(U[1],H)).replaceAll(V),V=e("style#"+H)):(V=e(r(U[1],H)).appendTo(e("body")),R.restyle>-1&&!J[_]&&(J[_]=function(){h(!0)}.debounce(R.restyle)),dt.data("my").restyle=h.fill(!0).debounce(0)),dt.data("my").localStyle=V,t||dt.addClass("my-restyle")))}function p(){var t,r,n=e.Deferred();if(r=o(K),P(r))j("Error decoding base64 to local Blob/URL",r),n.reject();else{if(E)for(t=0;t*").clone();try{X=x(K,I.init,dt,I)}catch(t){return j(P(t)?t:t.message,t.stack),dt}}if(it(X)?X.then(function(){g()},function(e,t){j(e,t)}):g(),!rt){if(!dt.my())return j("Internal error initializing controls.",""),dt;dt.data("my").initial=B(!0,{},G),e.mobile&&e.mobile.changePage(e.mobile.activePage)}}function g(){function e(e){rt||(t[e]=c(dt.find(e),W),r-=1,.5>r&&b(t))}var t={},r=Object.size(M);dt.addClass(ot),Object.each(M,function(t){if(!rt){var r=dt.find(t),n=v(r,dt,M[t],t);it(n)?n.then(e.fill(t)).fail(function(e,r){j("Error building "+t+", "+e,r)}):rt||e(t)}})}function b(e){var r,n,i;for(var a in M){if(rt)return;if(r=M[a],i=dt.find(a),i.size()){r.listen&&(et[a]=i.eq(0));try{n=d(G,W,r,i),n==W&&e[a]!=W&&void 0!==n&&d(G,e[a],r,i)}catch(o){t("Transient fail linking "+a+" of form $('.my-form-"+_+"')",o.message,o.stack)}try{n!=W&&c(i,n),i.eq(0).trigger("check.my")}catch(o){j("Error linking "+a,o.message,o.stack)}}}dt.removeClass(ot),dt.on("recalc.my, redraw.my",function(e){e.stopPropagation(),dt.my("redraw")}),ut=null,tt.resolve(G)}function j(e,r){var n;if(rt=!0,t("Form "+C+" failed to initialize.",e,r),dt.removeClass(ot),n=nt(e,r),P(n)||$(n)&&n.jquery?dt.html(n):n===!0&&dt.html(ut),R.silent)tt.resolve(G);else{if(!dt.my().ddata){if(dt.removeData("my"),dt.removeClass("my-form"),Q)if("1"==Q.data("count"))try{Q.remove()}catch(i){}else Q.data("count",Q.data("count")-1);if(V)try{delete J[_],V.remove()}catch(i){}}tt.reject("Form "+C+" failed to initialize: "+e,r)}}var k,O,C,_,T,S,M,R,I,F,U,L,H,Q,V,X,K={},G={},Z=[],et={},tt=e.Deferred(),rt=!1,nt=function(){},ot="my-form-init",ct="std",ut="";if(P(i)){if(k=at(i),!k)return tt.reject("No manifest with id "+i+" found in repo."),tt.promise();$(l)&&$(a)?(k=B(k,a),O=l):O=a,ct="repo"}else k=i,O=a;if(!k)return this;I=$(O)&&"repo"!=ct?B(!0,{},k):k;var dt=this.eq(0),ft=dt.my();return $(ft)&&ft.id&&ft.ui?(r("jQuery.my is already bound.",dt),dt.my("ui",I.ui),dt.my(Y,I.data),tt.resolve(dt.my(Y)).promise()):(R=I.params||{},R.strict||(R=B(!0,{},R),w(R)),R=B(!0,{},st.params,R),tt.fail(function(){dt.removeClass(H+" "+L)}),B(dt,tt.promise()),$(O)?(G=lt.patch(O,I.data||{}),I.data=G):G=I.data||{},K.data=G,dt.data("my",{data:G,params:R,promise:tt.promise(),locktill:0}),dt.addClass(ot),I.inherit&&u(I),lt.require(I,R).then(function(){m(),p().then(function(){h(),y()})}).fail(function(e){m(),j("Linker of ‘require’ property failed.",e)}),tt.then(f),dt)},redraw:function(e,t){var r=this,n=r.my();return n&&n.ui&&(n.ui.each(function(t){var i=r.find(t);p(i,e?W:void 0,n.params.recalcDepth),e||(i.is(".my-form")&&i.my("redraw"),i.trigger(i.is(".my-form-list")?"redraw":"check.my"))}),!t&&e&&r.trigger(rt)),r},data:function(e,t){var r=this;return $(e)&&(r.my().data=lt.overlap(r.my().data,e),this.my("redraw",t)),r.my().data},errors:function(){var t=e(this).my().errors,r={};for(var n in t)t[n]&&P(t[n])&&(r[n]=t[n]),$(t[n])&&L(t[n]).length&&(r[n]=t[n]);return r},valid:function(){var t=e(this).my().errors,r=0;for(var n in t)t[n]&&P(t[n])?r++:$(t[n])&&L(t[n]).length&&r++;return!r},reset:function(){try{lt.kickoff(this.my().data,this.my().initial),this.my("redraw")}catch(e){return!1}return!0},id:function(e,t){if(P(e))return at(e,t);var r=this.my();return r&&r.id?r.id:W},remove:function(e){var t,r,n,i,a,o,s,l,c=this;if(!this.my())return W;if(this.my().root&&!this.my().ddata&&(c=this.my().root),n=c.my(),a=n.data,s=n.cid,l=n.mid,c.unbind(".my"),$(n)&&n.manifest&&A(n.manifest.die))try{n.manifest.die.call(n.manifest,c,n.manifest)}catch(d){}if(t=n.style)if("1"==t.data("count"))try{t.remove()}catch(d){}else t.data("count",t.data("count")-1);if(r=n.localStyle)try{delete J[s],r.remove()}catch(d){}if(window.URL&&(i=n.locFiles)&&i.length)for(var f=0;fo?W:(n.params.errors&&n.params.errors.values().compact(!0).length?Object.equal(n.data,n.lastCorrect)||(o+=1):Object.equal(i[a.last()],n.data)&&(o+=1),t=y(o,n.params,!0),t&&(lt.kickoff(r.my().data,t),r.my("redraw")),r.my().data)},ui:function(e){var t,r=this,n=r.my(),i=[];if(!n)return W;B(!0,{},n.ui);if(!$(e))return n.ui;for(t in e)i.push(t);for(n.ui=q(lt.overlap(n.ui,e)),t=0;t1&&l(t[1])){for(var n,u,f,m,h,p,y,v,g=t[0],b="",x=1;x'+(g?"<"+r.labelTag+' class="'+r.labelCss+'" '+(r.label?'style="display:inline-block;width:'+r.label+";margin-left:-"+r.label+'" ':"")+">"+g+"":"")+b+""),e+b}return e}function r(e){var t=e;if(l(t)&&(t=t.split(/[\s,]/).compact(!0)),s(t)){for(var r={},n=0;n',inp:u+'text" {ext}/>',sli:u+'range" {ext}/>',dat:u+'date" {ext}/>',btn:u+'button" {ext}/>',pwd:u+'password" {ext}/>',but:"",div:"
{txt}
",spn:"{txt}",sel:"",mul:'',txt:"",err:' {txt}',msg:'
{txt}
',val:function(e){if(!s(e.vals))return"";var t=i({style:"",css:""},e);return t.txt=e.vals.reduce(function(e,t){return e+""+t+" "}," "),'{txt}'.assign(t)},"":"<{_tag} {ext}>{txt}"},txt:{sel:function(e){if(!e.vals)return"";var t=r(e.vals);return Object.keys(t).reduce(function(e,r){return e+'"},"")}},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"}},f={init:function(t,r){return e(this).html(n(t,r))}};e.my||(e.my={}),e.my.formgen=n,e.fn.formgen=function(t){return l(t)&&f[t]?f[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void e.error("Method "+t+" does not exist on jQuery.formgen"):f.init.apply(this,arguments)}}(jQuery),function(e){function t(t,r,n,i){var a,s,l,d,f,m,h;if("object"==typeof r&&r.jquery)r.is("img")&&(m=r,f=r.attr("alt")||r.attr("title")||r.data("text")||"",s=m[0].naturalWidth||m[0].width,a=m[0].naturalHeight||m[0].height,1>a&&(a=1),1>s&&(s=1),d=e(window).width()-90,l=e(window).height()-90,a>l&&(s=s*(l/a)|0,a=l),s>d&&(s=d,a=a*(d/s)|0),h=300>s?300:s,o(t,{source:"image",manifest:{init:function(e){e.html(this.HTML),e.on("click.my","img:eq(0)",function(){e.trigger("cancel")})},HTML:'

',ui:{"img:eq(0)":"img",h4:{bind:"text",css:{hide:function(e,t){return!t}}}}},data:{img:m.attr("src"),text:f},esc:!0,screen:!0,width:i||h,focus:!1,global:!0,z:"1995"},n));else if(u(r)&&r.manifest)o(t,r,n);else{if(!c(r))return null;o(t,{source:"html",manifest:{init:function(e){e.html(this.HTML)},HTML:r,ui:{"div:eq(0)":function(){}}},data:{},esc:!0,focus:!1,width:i},n)}return t}var r,n={},i="body",a=!1,o=e.extend,s={},l=(Object.isArray,Object.isBoolean),c=Object.isString,u=Object.isObject,d=Object.isNumber,f=(Object.isRegExp,Object.isFunction);e(document).keydown(function(e){var t,r,n=e.keyCode;if(!1!==a&&(13===n||27===n)){if(r=a.data("modal"),t=r.form,27==n&&(r.esc||Object.equal(t.data("my").initial,t.my("data"))))return a.modal(!0),!1;if(13==n&&r.enter)return function(e){e.modal()}.fill(a).delay(50),!1}}),n.modal=function(r,n,o){var s,c={},u=e(i),d=u.find(">.my-modal-proxy"),m={global:!0,screen:!0,done:f(n)?n:void 0,z:"1995"};return l(r)||null==r?d.modal(r):(s=e.Deferred(),t(c,r,m,o)?a?s.reject("Locked").promise():(d.size()||(d=e('
').prependTo(u),d.css({position:"absolute",top:"0",left:"0",margin:"0",padding:"0",width:"1px",height:"0"})),d.modal(c)):s.reject("Invalid data").promise())},n.modal.loading=function(t){e(i).find(">.my-modal").toggleClass("my-modal-loading",!!t)},n.modal.parent=function(t){return t&&e(t).size()?void(i=t):e(i)},n.modal.parentBack=function(t){return t&&e(t).size()?void(r=t):e(r||i)},n.modal.visible=function(){return!!a},e.my||(e.my={}),e.my.modal=n.modal,e.fn.modal=function(n,m,h){function p(){var t,r,n=window,i=!!E.global,a=w.offset(),o=D.offset(),s=w.scrollTop();E.pos={px:a.left,py:a.top,pw:w.outerWidth(),ph:w.outerHeight(),ox:o.left,oy:o.top,ow:D.outerWidth(),oh:D.outerHeight(),ww:r,wh:t};var l=1*(E.x.match(/\-?\d+(\.\d+)?/)||[0])[0],c=1*(E.y.match(/\-?\d+(\.\d+)?/)||[0])[0],u=E.x.has("left")?-1:E.x.has("right")?1:0,f=E.y.has("top")?-1:E.y.has("bottom")?1:0,m=E.pos.ox+E.pos.ow/2-E.pos.px,h=E.pos.oy+E.pos.oh/2-E.pos.py;if(i&&(E.pos.wh=t=n.innerHeight||e(n).height(),E.pos.ww=r=n.innerWidth||e(n).width(),m=r/2,h=t/2.5),l=E.x.has("%")?E.pos.ow/100*l:l,c=E.y.has("%")?E.pos.oh/100*c:c,E.pos.pix=m,E.pos.piy=h,m=m+u*(E.pos.ow/2)+l*(u>0?-1:1)-(E.width+N)*(u+1)/2,i?(h=(t-E.height-20)/3,10>h&&(h=10)):h=h+f*(E.pos.oh/2)+c*(f>0?-1:1)-(E.height||0)*(f+1)/2,m=m.round(1),h=(h+s).round(1),E.pos.vx=m,E.pos.vy=h,E.bound!==!1&&!E.global){var p=(d(E.bound)?E.bound:0).clamp(-100,100);E.pos.pw-2*pE.pos.pw-p?E.pos.vx=E.pos.pw-p-E.width-N:E.pos.vxE.pos.ph-p?E.pos.vy=E.pos.ph-p-E.height:E.pos.vy');var r="",n=e("style#my-modal-style-"+E.cid);("top"==E.nose||"bottom"==E.nose)&&(r+="div.my-modal-"+E.cid+".nose-"+E.nose+":before {left:"+(E.pos.ox-E.pos.px+E.pos.ow/2-E.pos.vx)+"px!important;}",n.text(r)),("left"==E.nose||"right"==E.nose)&&(r+="div.my-modal-"+E.cid+".nose-"+E.nose+":before {top:"+(E.pos.oy-E.pos.py+E.pos.oh/2-E.pos.vy)+"px!important;}",n.text(r))}E.screen?E.global?(j.css({top:0,left:0,width:2*E.pos.ww+"px",height:2*E.pos.wh+"px",display:"block",position:"fixed","z-index":E.z-1}),c(E.screen)&&j.css({background:E.screen?E.screen:"rgba(25, 39, 59, 0.88)"})):j.css({top:0,left:0,position:"absolute",width:E.pos.pw+"px",height:E.pos.ph+"px",display:"block",background:c(E.screen)?E.screen:"rgba(40,80,120,0.6)","z-index":E.z-1}):j.size()&&j.hide(),E.height>E.pos.wh?(b.height(E.pos.wh-30),x.css({"overflow-y":e.browser.webkit?"overlay":"scroll"})):x.css({"overflow-y":"none"}),b.animate({top:E.pos.vy+"px",opacity:"1"},E.animate)}function v(){try{x.my("remove")}catch(t){}try{w.data("modals")[E.cid]=null}catch(t){}x.parent().unbind(".my").remove(),j.off(".my"+E.cid),E.screen&&function(e){e&&a||j.hide(),e&&!a&&j.css({background:"rgba(25, 39, 59, 0.88)"})}.delay(50,E.global),E.global&&(a=!1,e("body").css({overflow:"auto"}))}function g(e){try{T(null,null)}catch(t){}(function(){q.reject(e)}).delay(0)}var b,x,w,j,k,O,C,q=e.Deferred(),z={},D=this,N=0,_=0,T=f(m)?m:function(){return!1},S=u(n)?n:{},E=D.data("modal");if(o(D,q.promise()),E){if(null==n||l(n)){if(x=E.form,j=E.bg,w=E.root,T=E.done,O=x.my("data"),C=!1,n){try{T(null,null)}catch(M){}if(v(),D.removeData("modal"),s[E.cid])try{s[E.cid].reject("Cancelled")}catch(M){}delete s[E.cid],E=null}else{try{C=T(x.my("valid")?null:x.my("errors"),O)}catch(M){}C||(v(),D.removeData("modal"),function(){s[E.cid]&&s[E.cid].resolve(O),delete s[E.cid],E=null}.delay(0))}return D}if(S)return g("Locked"),D}return D.is(":visible")?(S=t(z,n,{}))?S.global&&a?(g("Locked"),D):(E=o({type:"DOM",source:"manifest",form:null,modal:null,root:null,bgroot:null,caller:D,manifest:{},data:{},global:!1,screen:!1,drag:!1,focus:!0,close:!0,silent:!0,esc:!1,enter:!1,bound:!1,nose:"",width:h||300,height:null,x:"0",y:"0",z:"1901",background:"white",css:"",animate:200},S,{promise:q.promise(),cid:Number.random(268435456,4294967295).toString(16)}),E.done=f(E.done)?E.done:T,c(E.align)&&E.align&&(E.x=(E.align.match(/(left|right):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0],E.y=(E.align.match(/(top|bottom):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0]),E.width=1*(e.my.f.getref(c(E.manifest)?e.my.cache(E.manifest):E.manifest,"params.width")||E.width),E.type="DOM",D.hasClass("my-form")?(E.type="form",E.root=E.root||D):D.data("my")?(E.type="control",E.root=E.root||D.my().root):(E.root=E.root||D.parents(".my-form").eq(0),E.root.size()||(E.root=e(i))),E.global?(E.root=e(i),E.bgroot=e(r||i)):E.bgroot=E.root,w=E.root,w.data("modals")||w.data("modals",{}),p(),b=e('
').prependTo(E.root),b.addClass("my-modal-"+E.cid),N=b.outerWidth(),_=b.outerHeight(),b.hide(),b.html('
'),x=b.find(".my-modal-form"),E.close&&(k=e(c(E.close)?E.close:'
×
').prependTo(b).on("click.my",function(){D.modal(!0)}),k.css({"z-index":("+"===(E.z+"").to(1)?"+":"")+(1*E.z+1)})),j=E.bgroot.find(">.my-modal-screen"),E.screen&&(j.size()||(j=e('').prependTo(E.root)),E.esc&&j.on("click.my"+E.cid,function(){D.modal(!0)})),D.data("modal",E),E.silent&&b.on("change.my",function(){return!1}),b.css({display:"block",height:"none",opacity:"0.005","z-index":E.z,width:"auto"}),b.css(E.global?{position:"fixed",left:"50%",top:E.pos.vy+"px",display:"block",height:"none",opacity:"0.005","z-index":E.z,width:"auto","margin-left":"-"+((E.width+N)/2).round(0)+"px"}:{position:"absolute",left:E.pos.vx+"px",top:E.pos.vy+"px",display:"block",height:"none",opacity:"0.005","z-index":E.z,width:"auto"}),x.my(E.manifest,E.data).then(function(){var t,r,n,i,l;if(o(E,{form:x,bg:j,cancel:function(){D.modal(!0)},commit:function(){D.modal()}}),b.data("modal",E),E.height=b.outerHeight(),"manifest"!==E.source&&(E.width=b.width()),p(),b.css({top:E.pos.vy+"px"}),y(!0),w.data("modals")[E.cid]=E,s[E.cid]=q,x.bind("commit.my",function(){return E.commit.delay(50),!1}).bind("cancel.my",function(){return E.cancel.delay(50),!1}),b.bind("layout.my",function(){y()}.debounce(50)),E.global&&(a=D,e("body").css({overflow:"hidden"})),E.global||!E.esc&&!E.enter||x.bind("keydown.my",function(t){var r=t.keyCode;return 27==r&&E.esc?(E.cancel(),!1):13==r&&E.enter&&!e(t.target).is("textarea")?(E.commit.delay(50),!1):void 0}),E.focus===!0){i=!1,l=E.manifest.ui;for(n in l)i||(r=x.find(n),r.size()&&r.is("input, textarea","button")&&(i=!0,r.focus()))}else c(E.focus)&&x.find(E.focus).focus();if(t=x.find("img").filter(function(){return""!=e(this).attr("src")}),t.size()){var u=function(){"manifest"!==E.source&&b.css({width:"auto"}),y()}.after(t.size());t.each(function(){e(this).bind("load",u)})}E.drag&&e.fn.draggable&&(c(E.drag)?b.draggable({handle:E.drag}):b.draggable(),E.nose&&b.on("dragstart.my",function(){b.removeClass("nose-"+E.nose)})),q.notify("Ready")}).fail(function(e){v(),D.data("modal",null),q.reject(e)}),D):(g("Invalid data"),D):(g("Object must be visible"),D)}}(jQuery); \ No newline at end of file diff --git a/bower.json b/bower.json index dcabb4b..abb429e 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquerymy", - "version": "1.1.8", + "version": "1.1.9", "description": "A lightweight jQuery plugin for complex two-way data binding in real time.", "main": "./jquerymy.js", "authors": [ diff --git a/jquerymy.js b/jquerymy.js index 093e4e7..d27af56 100644 --- a/jquerymy.js +++ b/jquerymy.js @@ -1,33 +1,20 @@ /* - * jQuery.my 1.1.8 + * jQuery.my 1.1.9 * Requires jQuery 1.11.0+, SugarJS 1.3.9-1.4.x * - * — Form can change own .error prop at runtime if it‘s a string in manifest - * - * — .tojson update – named functions and functions with comments in arg - * list or between () and {} body are jsonned correctly - * - * — .unjson update – named function strings now supported, - * they are parsed to functions that retain original names - * - * — _getref now can receive array as a path, - * also items.id=123.data queries are now supported - * - * — Auto-recalc of styles on window resize only - * touches visible forms - * - * — Implemented forced restyle of a form and all its - * childs, $o.my("restyle", skipChilds) - * - * — Modal starting drag deletes its nose, if it was any + * — js2txt removes 'anonymous' name from functions + * — $.my.f.unmask receives 3 args as well as 2 + * — modal positioned correctly in scrollable container + * — lists redrawn are rebuild to be bound with objects newly passed + * — ... it means undo works on lists without bugs. * * More details at jquerymy.com * * (c) @ermouth, thanks @carpogoryanin, @ftescht - * 2015-07-17 + * 2015-09-10 */ -;(function ($) {var _version = "jQuery.my 1.1.8"; +;(function ($) {var _version = "jQuery.my 1.1.9"; // Some shortcuts and constants var lang = "en", @@ -193,14 +180,17 @@ id = obj.id; - - //path = id.split("."); - - try {obj=Object.clone(obj0, true);} - catch (e) {return "Can’t save circular-referencing object into cache.";} + try { + obj=Object.clone(obj0, true); + } + catch (e) { + return "Can’t save circular-referencing object into cache."; + } //unwind string defs of functions - try {if (!obj.params || (obj.params && !obj.params.strict)) _unjson(obj, true);} + try { + if (!obj.params || (obj.params && !obj.params.strict)) _unjson(obj, true); + } catch (e) { return "Invalid manifest, parse error."; } @@ -218,7 +208,7 @@ root._src[id] = obj; - if (prev=f.mask(root, id)) { + if (prev = f.mask(root, id)) { if (prev.params && prev.params.protect) return "Can’t save manifest into cache over protected one."; else { // Remove prev version @@ -351,7 +341,7 @@ ".my-form-list": function ($o,list) { //object is list of forms - var i,old,mod,eq,ctr = 0, + var i,old,xold,mod,eq,ctr = 0, sP = "ui-sortable", sPlc= "."+sP+"-placeholder", od = $o.data("formlist")||{}, gen = od.generator||{}, @@ -374,14 +364,20 @@ // first we must estimate // if putting new data over old // changes anything - old= []; $c.each(function () { - var $x = $(this), xd = $x.data("my"); - if (xd) old.push(xd.data); + old= []; xold={}; + $c.each(function (i) { + var $x = $(this), xd = $x.data("my"), dd; + if (xd) { + old.push(xd.data); + if (dd = $x.data("formlist")) { + xold[dd.oid] = xd.data; + } + } }); //fast compare eq=false; - if (old.length===list.length) for (eq=true, i=0;i {x:1, m:{n:{z:5}, y:{z:3}}}, + // unmask ([1,2,3],["x","a.b","a.c"]) => {x:1, a:{b:2, c:3}} + // modifies dest + + var dest, src, mask; + + if (null==A3) dest = {}, src = A1, mask = A2; + else dest = A1, src = A2, mask = A3; + if (isO(src) && isO(mask)) return f.mask(src,mask); - else if (isA(src) && isA(mask)) { + + if (isS(mask)) { mask = [mask]; src= [src]; } + + if (!isA(mask) || !(isA(dest) || isO(dest))) return null; + + if (isO(src)) { + src = mask.reduce(function(vals, path){ + vals.push(_getref(src,path)); + return vals; + },[]); + } + + if (isA(src) && isA(mask)) { for (var i=0;i-1) + ) + ) ptr = preptr[path[i]] = {}; + } } } return data; @@ -3405,7 +3444,7 @@ //############################################################################################# -/* jQuery.my.modal 1.1.2 +/* jQuery.my.modal 1.1.3 * Requires Sugar 1.4.~, jQuery 1.11+, $.my 1.0.0+ * * Modal dialog constructor/manager. @@ -3968,7 +4007,9 @@ var W = window, h, w, isfs = !!m.global, - ro = $r.offset(), oo = $o.offset(); + ro = $r.offset(), + oo = $o.offset(), + rs = $r.scrollTop(); m.pos = { px: ro.left, py: ro.top, @@ -4014,7 +4055,7 @@ - ((m.height||0)/*+pady*/)*(sy+1)/2; } - vx = vx.round(1); vy = vy.round(1); + vx = vx.round(1); vy = (vy+rs).round(1); m.pos.vx = vx; m.pos.vy = vy; diff --git a/jquerymy.min.js b/jquerymy.min.js index 7f8d383..942c16a 100644 --- a/jquerymy.min.js +++ b/jquerymy.min.js @@ -1,6 +1,5 @@ -/* jQuery.my 1.1.8 +/* jQuery.my 1.1.9 * Requires jQuery 1.11.0+, SugarJS 1.3.9-1.4.x * More details at jquerymy.com */ - -!function(e){function t(){window.console&&console.error.apply(console,arguments)}function r(){window.console&&console.log.apply(console,arguments)}function n(e,t){return($(t)?t.split("."):I(t)?t:[""]).reduce(function(e,t){if(null!=e){if(/=/.test(t)){var r=t.split("=",2);return F(e)?Object.values(e).find(function(e){return F(e)||I(e)?e[r[0]]==r[1]:!1}):I(e)?e.find(function(e){return F(e)||I(e)?e[r[0]]==r[1]:!1}):void 0}if(null!=e&&null!=e[t])return e[t]}return void 0},e)}function a(e,t){var r,i;if(F(t))return t;if($(t)){if(r=n(e,t),null==r&&(r=Object.clone(J._src[t],!0)),null==r&&(r=n(J,t),F(r)&&F(r._self)?r=Object.clone(r._self,!0):F(r)&&(r=Object.clone(r,!0))),null==r&&n(e,"params.cache")&&(i=n(e,"params.cache"),A(i)?r=i(t):F(i)&&(r=ot(t,i)),F(r)&&(F(r._self)&&(r=Object.clone(r._self,!0)),Object.merge(r,{params:{cache:i}},!0))),null!=r&&F(r))return i=i||n(e,"params.cache"),i&&Object.merge(r,{params:{cache:i}},!0),r;throw"Component "+t+" not found."}return A(t)?t.apply(e,Array.prototype.slice.call(arguments,2)):null}function o(r,i){var a,o,l,c,u,d=i||J,f=r;if(!(F(d)&&F(f)&&F(f.ui)&&$(f.id)))return"Can’t save manifest into cache, invalid arguments.";d.hasOwnProperty("_src")||(d._src={}),l=f.id;try{f=Object.clone(r,!0)}catch(m){return"Can’t save circular-referencing object into cache."}try{(!f.params||f.params&&!f.params.strict)&&j(f,!0)}catch(m){return"Invalid manifest, parse error."}if(a=s(f),$(a))return t(a),a;if(Object.merge(f,{params:{strict:!0}},!0),d._src[l]=f,c=ct.mask(d,l)){if(c.params&&c.params.protect)return"Can’t save manifest into cache over protected one.";c._self&&delete c._self,e.extend(!0,d,ct.unmask("",l))}return e.extend(!0,d,ct.unmask(f,l)),o=Object.keys(d._src).filter(function(e){return e.startsWith(l+".")}),o.sort(),o.forEach(function(t){var r;(r=ct.mask(d,t))&&(r._self&&delete r._self,e.extend(!0,d,ct.unmask("",t))),e.extend(!0,d,ct.unmask(d._src[t],t))}),u=n(d,l),R?u._self=d._src[l]:Object.defineProperty(u,"_self",{get:function(){return d._src[l]},set:function(){throw"Can’t change manifest cache entry directly."},enumerable:!1,configurable:!0}),u}function s(e){var t,r,n=[];if(F(e.files)&&Object.size(e.files))for(t in e.files){if(r=e.files[t],!F(r))return"Non-object member "+t+" in files section.";if($(r.data)&&!r.url)if(E)try{ct.base642blob(r.data,function(e){r.blob=e,r.url=E.createObjectURL(r.blob)},r.content_type||r.mime),n.push(t)}catch(i){return"Invalid base64 data in files/"+t+"."}else r.url="data:"+(r.content_type||r.mime)+";base64,"+r.data,n.push(t)}return n}function l(r,n){F(n)&&n.channel&&n.message&&r.find(".my-listen-"+ct.sdbmCode(n.channel)).each(function(){var r,i=e(this),a=i.data("my"),o=void 0;if(a&&a.ui.listen&&A(a.ui.listen[n.channel])){r=a.ui.listen[n.channel];try{o=r.call(a.manifest||a.root.my().manifest,a.data,n.message,i)}catch(s){t("Listener failed",s.message,s.stack)}void 0!==o&&(null===o?i.trigger("check"):o&&i.trigger("recalc"))}})}function c(t,r){function i(t,r){var n;return $(t)?/[\/]/.test(t)?(n=Q(!0,{},k,{ref:r,ajax:{url:t}}),it.test(r)&&(n.ajax.dataType="json")):t.length&&(n=Q(!0,{},k,{ref:r,ajax:t})):F(t)&&(n=Q(!0,{},k,{ref:r,ajax:e.extend(!0,{},Object.select(t,["accepts","async","cache","data","dataType","xhrFields","password","timeout","type","url","username","headers"]))}),n.ajax.url||(n=null)),n}function a(){g.reject(w)}function o(){O+=1;var e=b[O];if(e)s(e).then(o).fail(a);else{var r=c(x),n=H(Object.findAll(r,function(e,t){return!t}));n.length&&w.push((1===n.length?"Key "+n[0]+" is":"Keys "+n.join(", ")+" are")+" not present after all."),w.length?a():g.resolve(t)}}function s(r){function n(){c-=1,s?l.reject():.5>c&&l.resolve()}var i,a,o,s=!1,l=e.Deferred(),c=r.length;for(a=0;c>a;a++)i=r[a],o=$(i.ajax)?j.loader:st,o(i.ajax).then(function(e,r){it.test(r.ref)&&(null!=e?Q(!0,t,ct.unmask(e,r.ref.from(5))):(s=!0,w.push("Invalid data for ‘"+r.ref+"’ resource."))),n()}.fill(void 0,i)).fail(function(e,t){w.push("Failed to load ‘"+t.ref+"’ resource."),s=!0,n()}.fill(void 0,i));return l.promise()}function l(e){var r=!1;return it.test(e)?null!=n(t,e.from(5))&&(r=!0):null!=n(window,e)&&(r=!0),r}function c(e){for(var t in e)e[t]===!1&&(e[t]=l(t));return e}var u,d,f,m,h,p,y,v,g=e.Deferred(),b=[],x={},w=[],j=Q(!0,{ajaxTimeout:1e4,loader:lt.params.loader},r||{}),k={ref:null,ajax:{type:"GET",async:!0,timeout:j.ajaxTimeout}};if(F(t))if(I(t.require)){for(m=t.require,u=0;ui)return n=l,void(i=o);c==Y&&r(e,l,o+1)}V!=t[""]&&typeof t[""]!=Y&&o>i&&(n=t[""],i=o)}var n=V,i=0,a="";return r(e,t,1),n}function f(e,t,r,n){var i,a,o,s=[],l=r.bind,c=W(l);if(c==rt)return l.call(h(n).manifest,e,t,n);if(c===tt||c===et){if(c===tt&&!/\./.test(l))return t!=V?e[l]=t:void 0===e[l]&&(e[l]=V),e[l];for(c===tt&&(s=l.split(".").each(function(e,t){this[t]=e+""})),c===et&&(s=l.slice(0).each(function(e,t){this[t]=e+""})),"this"===s[0]?(a=h(n).manifest,s.shift()):a=e,i=0;i-1?"":u;case"s":return r==s?"":u;case"o":return s[r]?"":u;case"b":if(i.is(".my-form-list,.ui-sortable")){var f=i.data("listSrc")||i.data("my").listSrc||">*",m={};return i.find(f).filter("*:not(.ui-sortable-placeholder)").each(function(t){var r=e(this);r.data("my")&&!r.my("valid")&&(m[t]=r.my("errors"))}),m}return i.hasClass("my-form")&&s?i.my("valid")?"":i.my("errors"):""}return l.formError||"Error"}return""}function h(e){var t=e.my();return t?t.root?t.root.my():t:null}function p(t,r,n){var i=n.compact(),a=i.replace(/:disabled/g,""),o=a!==i,s="self:"===a.to(5);return s&&(a=a.replace(/^self:/g,"")),r.each(function(){var n=e(this),i=n.my(),l=!s&&i?i.container:n;l.toggleClass(a,!!t),o&&void 0!==i&&!!t!=!!i.disabled&&(n.my().disabled=!!t,i._disable||(n.my()._disable=d(r,lt.offon).fill(void 0,r)),i._disable(!!t))}),r}function y(e,r,n){var i,a,o,s,l,c,d,h,v,g,b,x=!1,w=!1,j=e,k=j.my(),O="";if(k){if(h=k.selector,v=k.root,v.hasClass("my-form-init"))return{};if(g=v.find(h),b=v.my().ui,x=e.hasClass("my-form"),w=e.hasClass("my-form-list"),x?(i=e,a=k.ddata,o=k.dui,s=k.dparams):(i=k.container,a=k.data,o=k.ui,s=k.params),o.bind!=V){if(l=K(r)?r:u(g,f(a,V,o,g)),V!=o.check){O="Unknown error";try{O=m(a,l,o,g)}catch(C){t("Error "+C.message+" in .check validator for "+h,v,C.stack)}}var q=s.errorCss,z="ui-state-error";try{V!=r&&(l=u(g,f(a,r,o,g)))}catch(C){O=s.messages.formError||"Error"}if(""===O)x?k.derrors[h]="":k.errors[h]="",i.removeClass(q),i.attr("title")&&i.attr("title",""),x||w||s.effect(i.find(s.errorTip),!1,s.animate/2),j.removeClass(z),j.find(".ui-widget").removeClass(z);else{if(x)k.derrors[h]=O;else if(w)k.errors[h]=O;else{i.addClass(q),k.errors[h]=O;var D=i.find(s.errorTip).eq(0);D.size()?s.effect(D.addClass(q).html(O),!0,s.animate):i.attr("title",(O||"").stripTags())}j.is(".hasDatepicker")&&(j.is("input")?j.addClass(z):j.find(".ui-widget").addClass(z)),j.is(".ui-slider")&&j.addClass(z)}}var _=r==V?l:r;if(o.css)for(c in o.css)d=o.css[c],L(d)?p(d.test(_),g,c):A(d)&&p(d.call(v.my().manifest,a,_,g),g,c);var N,S,T=o.recalc,M=[],E={};if(n&&o.recalc&&v.my()){for(b=v.my().ui,N=0;N=2*s){for(f={},a=s;2*s>a;a++)f[o[a]]=i[o[a]];t.history=f}return n||m.form.trigger(nt),m.history[o.last()]}if(!isNaN(e)||e===V){if(l=parseInt(e)||0,0>l)return V;if(o=H(i).sort(),l>=o.length&&(l=o.length-1),d=Object.clone(m.history[o[o.length-l-1]],!0),r){for(f={},a=0;a$/.test(C.list)?s=C.list:c=C.list||c,!s){var d=i.find(c);s="
",d.size()&&(s=e(s).append(d.eq(0).clone(!0)).html(),d.eq(0).remove())}i.data("formlist")||i.data("formlist",{}),i.data("formlist").generator={manifest:g,delay:(C.delay||O.delay||10)/1.3,template:s,selector:c,parent:D,bind:C.bind,hash:A(C.hash)?C.hash.bind(D):$(C.hash)?f.fill(void 0,C.hash):I(C.hash)?m.fill(void 0,C.hash.slice(0)):null,id:A(C.id)?C.id.bind(D):$(C.id)?f.fill(void 0,C.id):I(C.id)?m.fill(void 0,C.id.slice(0)):null,ext:!(!C.id&&!C.hash),stamp:0},i.on("insert.my",function(t,r){t.stopPropagation();var n={what:void 0,where:0};null==r?n.where=1e6:F(r)?Object.merge(n,r):($(r)||U(r))&&(n.where=r),e(t.target).my("insert",n.where,n.what)}),i.on("remove.my",function(t){t.stopPropagation(),e(t.target).my("remove")})}else try{t=i.my(a(D,g),F(o)?o:void 0)}catch(p){u("$.my subform init of "+l+" failed: "+p.message,p.stack)}}at(t)?t.then(h,function(e,t){u("Init of subform "+l+" failed with error: "+e,t)}):h()}function u(e,r){t(e,r),q&&q.reject(e,r)}function f(e,t){var r=n(e,t)||"";return"string"==typeof r?r:ct.sdbmCode(r)}function m(e,t){return ct.sdbmCode(ct.mask(e,t))}function h(){i.each(function(){var t,r,n=e(this),a=!1,c=n[0].nextSibling;if(r=c&&c.CodeMirror?c.CodeMirror:null,r&&n.addClass("my-codemirror"),t=C.events||d(n,lt.events),n.is(".my-form")?Q(n.data("my"),{dui:C,root:o,selector:l,dparams:O,devents:t,ddata:k.data,container:O.container(n),derrors:k.errors}):(n.data("my",{events:t,selector:l,initial:v,previous:v,root:o,container:O.container(n),id:k.id,ui:C,data:k.data,params:O,errors:k.errors}),s._update=C.delay?y.debounce(C.delay):V,a=!0),a)if(n.cleditor&&n.parent().is(".cleditorMain")){var u=n.cleditor()[0];if(u&&u.$frame&&u.$frame[0]){n.addClass("my-cleditor"),Q(n.data("my"),{container:O.container(n)});var f,m=function(e){n.val(e).trigger(nt)},h=Number.random(1e5,1e6-1);e(u.$frame[0]).attr("id","cleditCool"+h),f=document.frames?document.frames["cleditCool"+h].document:e("#cleditCool"+h)[0].contentWindow.document;var p=e(f).find("body");e(f).bind("keyup.my",function(){m(e(this).find("body").html())}),n.parent().find("div.cleditorToolbar").bind("click.my mouseup.my",function(){m(p.html())}),e("body").on("click","div.cleditorPopup",function(){m(p.html())})}}else if(n.is("div.redactor_box textarea")){var g,w="my-redactor-9";try{g=n.getEditor(),w="my-redactor-8"}catch(q){g=n.redactor("getEditor")}g&&(n.addClass(w),g.bind("input.my keyup.my blur.my",function(e){e.trigger("redactor")}.fill(n)))}else n.is(".ace_editor")?ace.edit(i[0]).on(nt,function(e){e.trigger("ace")}.fill(n)):r&&r.on(nt,function(e){e.trigger("codemirror")}.fill(n));n.my()._changed=b.debounce(j),n.my()._recalc=x.debounce(j),n.bind(t,function(e){e.type==nt&&e.stopPropagation(),a&&(k.locktill=Date.now()+s.delay),n.my()._changed(n,o,s,O)}),/check(\.my)?/.test(t+"")||n.on("check.my",function(){return n.my()._changed(n,o,s,O,!0),!1}),n.on("recalc.my, redraw.my",function(e){e.stopPropagation(),n.my()._recalc(n,o,s,O)})}),q&&q.resolve()}var p,v,g,j,k=o.my(),O=(k||{}).params,C=s,q=null,z=0,D=k.manifest;return k?(j=s.delay,i.size()?(C.init!=V&&(p=w(D,C.init,i,k)),at(p)?(z+=1,q=e.Deferred(),p.then(c,function(e,t){u("Init of "+l+" failed: "+e,t)})):c()):r("Not found "+l+" selector.",o),q):(t("Failed to find $root building "+l+" selector."),null)}function b(e,t,r,n,i){var a=e.data("my"),o=t.data("my");if(a&&!a.disabled){v(a.ddata||a.data,a.dparams||a.params);var s=t.find(a.selector);y(e,i?V:u(s,V),r.recalcDepth||n.recalcDepth),void 0===o.orphan&&a.root.parent().hasClass("ui-sortable")&&(o.orphan=!a.root.parent().hasClass("my-form-list")),o.orphan&&a.root.parent().trigger("check"),n.change&&n.change.call(e)}}function x(e,t,r,i){var a=e.my();if(a&&!a.disabled){var o=t.find(a.selector);o.is(".my-form")?o.my("redraw"):y(e,o.is(".my-form-list")?n(o.my().data,o.data("formlist").generator.bind):V,r.recalcDepth||i.recalcDepth)}}function w(e,t,r,i){var a;if($(t)){if(a=n(e,t),void 0===a)return r.html(t.assign(i.data)),null}else a=t;if(A(a))return a.apply(e,Array.prototype.slice.call(arguments,2));if(I(a))try{r.formgen(a)}catch(o){}return null}function j(e,t){var r,n=!t;for(r in e)e.hasOwnProperty(r)&&k(r,e,n)}function k(e,r,n){var i,a,o,s,l="";(n||!/^(data|files|require)$/.test(e))&&(i=r[e],l=W(i),/^(ob|ar)/.test(l)?j(i):"string"===l&&/^(function[\s\n\t]+|new\sRegExp)/.test(i)&&((a=i.match(/^function([\s\n\t]+[\w_$][\w\d_$]*)?[\s\n\t]*\(([^\)]*)\)\s*\{([\s\S]*)\}[\s\n\r\t]*$/))&&4===a.length?(s=a[1]?a[1].replace(/[\s\n\t]/g,""):"",o=s.length?C(s,a[2],a[3]):O(a[2],a[3]),"function"==typeof o?r[e]=o:t("Invalid function in XJSON, skipped",o.message,o.stack,i)):(a=i.match(/^new\sRegExp\s*\(\/([\s\S]+)\/([a-z]*)\)$/))&&3===a.length&&(o=q(a[1],a[2]),"function"==typeof o.test?r[e]=o:t("Invalid RegExp in XJSON, skipped",o.message,o.stack,i))))}function O(e,t){var r;try{r=new Function(e,t)}catch(n){r={message:n.message,stack:n.stack}}return r}function C(e,t,r){var n;try{n=new Function("","return (function "+e+"("+t+"){"+r+"});")()}catch(i){n={message:i.message,stack:i.stack}}return n}function q(e,t){var r;try{r=new RegExp(e,t)}catch(n){r={message:n.message,stack:n.stack}}return r}function z(e,t,r){var i=F(t)?t:null;return Object.each(e,function(t,r){var n=typeof r;/^str|^fu/.test(n)&&(e[t]={bind:r})}),Object.each(e,function(t,a){var o,s,l,c=[],u=[],d=/\s?[,;]\s?/;a.recalc&&($(a.recalc)?c=a.recalc.split(d):I(a.recalc)&&(c=a.recalc),c=c.compact(!0).unique()),c.length&&(e[t].recalc=c),null==a.bind&&(a.bind=function(){});var f;if(a.listen&&(f=D(a.listen),a.listen=Object.size(f)?f:void 0),a.hasOwnProperty("watch"))for($(a.watch)?u=a.watch.split(d):I(a.watch)&&(u=a.watch.slice(0)),u=u.compact(!0).unique(),l=0;l2?f=ct.css2json(f):o.push(a+(/\{/.test(f)?f:"{"+f+"}"))),I(f)&&f.length)for(l=0;le?"0"+e:e}function t(e,a,o){var s,l,c,u,d=0,f=a||0,m=n;switch(o&&$(o)&&(d=String(o).length,m=String(o).repeat(10)),(typeof e).substr(0,3)){case"str":return i(e);case"num":return isFinite(e)?""+String(e):"null";case"boo":case"nul":return String(e);case"fun":return i(r(e.toString()));case"obj":if(!e)return"null";if(typeof e.toJSON===rt)return t(e.toJSON(),f+(o?1:0),o);if(s=[],I(e)){for(l=0;ll;l++)s[l]=i.charCodeAt(l);return n=new Blob([s],{type:r||"application/octet-stream"}),A(t)?void t(n):n},base64:function(t,r,n){var i=(W(t),null),a=$(t)?t:e.my.tojson(t),o=$(n)?"data:"+n+";base64,":"";if(r){try{i=decodeURIComponent(escape(window.atob(a)))}catch(s){i=null}if(null!==i&&/(^".*"$)|(^\[.*\]$)|(^\{.*\}$)/.test(i))try{i=e.my.fromjson(i)}catch(s){i=null}return i}return o+window.btoa((n===!0?"":"")+unescape(encodeURIComponent(a)))},css2json:function(e){var t=(e+"").replace(/\/\*[\s\S]+\*\//gm,"").replace(/@charset[^;]+;/gim,"").replace(/[\n\t\s]+/g," ").replace(/\}/g,"}ᴥ").replace(/^\n+/g,"").replace(/[\n\s]+$/g,"").split("ᴥ").compact(!0).reduce(function(e,t){var r,n,i,a=t.trim();return/^[^{]+\{[^\}]+\}$/.test(a)&&(r=a.to(-1).split("{"),n=" "+r[0].trim(),i=r[1].trim(),";"!=i.last()&&(i+=";"),e[n]||(e[n]=""),e[n]+=i),e},{});return t}}}var T,M="jQuery.my 1.1.8",E=window.URL||window.webkitURL,R=!document.addEventListener,I=Object.isArray,P=Object.isBoolean,$=Object.isString,F=Object.isObject,U=Object.isNumber,L=Object.isRegExp,A=Object.isFunction,H=Object.keys,J=n(e,"my.f.repo")?e.my.f.repo():{_src:{},_name:"Default manifest cache"},B=n(e,"my.f.restyles")?e.my.f.restyles():{},Q=e.extend,W=e.type,V=null,K=function(e){return null!==e&&void 0!==e},X="{yyyy}-{MM}-{dd}",G="{HH}:{mm}",Y="object",Z="data",et="array",tt="string",rt="function",nt="change",it=/^this\./,at=function(e){return!!(null!=e&&(F(e)||e.jquery)&&A(e.then)&&A(e.fail)&&A(e.state))},ot=function(e,t){var r,i;return $(e)?(r=e,i=n(F(t)?t:J,r),"exist"===t?F(i):i?Object.clone(i,!0):null):F(e)?(i=o(e,t),F(i)?i:null):void 0===e?J._src:null===e?Object.reject(J,/^_/):null},st=e.ajax,lt={vals:{".my-form":function(e,t){if(e&&e.my){var r=e.my(Z);return Object.equal(r,t)?r:e.my(Z,t,!0)}return t||V},".hasDatepicker":function(e,t){K(t)&&e.datepicker("setDate",""==t?t:Date.create(t));var r=e.datepicker("getDate");return r?r.format(X):""},".my-tags":function(e,t){return K(t)&&($(t)||U(t)?e.tags(Z,[t+""]):I(t)&&e.tags(Z,t)),e.tags(Z)},".ui-draggable":function(e,t){if(K(t)&&F(t)){var r={};isNaN(t.left)||(r.left=Number(t.left).ceil(2)+"px"),isNaN(t.top)||(r.top=Number(t.top).ceil(2)+"px"),(r.left||r.top)&&e.css(r)}var n=e.position();return{left:t&&!isNaN(t.left)?(1*t.left).ceil(2):n.left.ceil(2),top:t&&!isNaN(t.top)?(1*t.top).ceil(2):n.top.ceil(2)}},".my-form-list":function(t,r){function n(){var r,n,i=e(this),a=i.data("my");a&&(r=i.data("formlist"),n=r.index,r.hash=b(a.data,n)+"",r.oid=x!==b?x(a.data,n)+"":r.hash),t.trigger("check.my")}function i(e){e.data("my").locktill+j/1.3.my-form",v=p.template||"
",g=/\{/.test(v),b=p.hash||ct.sdbmCode,x=p.id||ct.sdbmCode,w=p.ext,j=p.delay||50,k=t.is("."+f),O=!!t.children(m).size(),C=[],q=[],z=Date.now(),D=t.find(k?t.sortable("option","items"):y);if(K(r)&&I(r)){if(O)return r;if(s=[],D.each(function(){var t=e(this),r=t.data("my");r&&s.push(r.data)}),c=!1,s.length===r.length)for(c=!0,o=0;o1.4*j||z-p.stamp>100||!p.stashed||p.stashed.length!==D.size()-(O?1:0)){O&&(d=t.find(">."+f+"-helper"));var M=0;for(D.each(function(t,r){var n,i,a,o=e(r),s=!1;O&&o.hasClass(f+"-helper")||(O&&o.hasClass(f+"-placeholder")&&(o=d),n=o.data("my"),i=o.data("formlist"),n&&i&&(C.push(n.data),M!=i.index&&(i.index=M,s=!0),w&&(a=b(n.data,M)+"",a!==i.hash&&(i.hash=a,s=!0)),M+=1,s&&q.push(o)))}),o=0;o."+a+"-placeholder",s=t.find(t.sortable("option","items"));if(K(r)&&I(r)){var l={},c={},u=r.unique();if(t.find("input:focus:eq(0),textarea:focus:eq(0)").size()||t.find(o).size())return u;s.each(function(){l[ct.sdbmCode(ct.extval(e(this)))]=e(this)});for(var d=u.length-1;d>=0;d--){var f=ct.sdbmCode(u[d]);l[f]&&(l[f].prependTo(t).show(),c[f]=!0,-1==i.indexOf(u[d])&&i.push(u[d]))}i=i.reverse();for(d in l)c[d]||l[d].hide()}else{var m=t.find(o),h=t.eq(0);0!=m.size()?(h.my()[a]!=m.position().left+""+m.position().top?(s=s.filter(":visible:not(:disabled, .ui-state-disabled, .ui-sortable-helper)"),n=t.find(t.sortable("option","items")).filter(".ui-sortable-helper"),s.each(function(){var t=e(this);i.push(ct.extval(t.is(".ui-sortable-placeholder")?n:t))}),h.my()[a]=m.position().left+""+m.position().top,h.my()[a+"1"]=i):i=h.my()[a+"1"],i==V&&s.each(function(){i.push(ct.extval(e(this)))})):(s=t.find(t.sortable("option","items")).filter(":visible:not(:disabled, .ui-state-disabled)"),s.each(function(){i.push(ct.extval(e(this)))}))}return i},"input[type=date]":function(e,t){if(K(t))return r=""!=t?Date.create(t).format(X):"",$(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(X):""},"input[type=time]":function(e,t){if(K(t))return r=""!=t?Date.create(t).format(G):"",$(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(G):""},input:{"[type='text'],[type='number'],[type='search'],[type='hidden'],[type='password'],[type='button'],[type='range'],:not([type])":{".ui-slider-input":function(e,t){K(t)&&e.val(t).slider("refresh")},".tagstrip input.value":function(e,t){K(t)&&e.val(t).trigger("update")},"div.select2-container+input":function(e,t){return K(t)&&JSON.stringify(t)!==JSON.stringify(e.select2("val"))&&e.select2("val",I(t)?t:[t]),e.select2("val")},"":function(e,t){K(t)&&e.val(t+"")}},":radio":function(t,r){var n=-1;if(K(r)){t.each(function(t){var i=e(this).val();r+""==i+""&&(n=t)});var i=t.eq(0).checkboxradio;if(i&&t.each(function(t){var r=e(this);n!=t&&r.is(":checked")&&r.prop("checked",!1).checkboxradio("refresh")}),n>-1){var a=t.eq(n);a.is(":checked")||(a.prop("checked",!0),i&&a.checkboxradio("refresh"))}else i||t.each(function(){e(this).prop("checked",!1)})}if(-1==n)for(var o=0;oForm init failed

',ru:'

Ошибка инициализации формы

'},badInput:{en:"Invalid input",ru:T},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(e){return e.parents('[data-role="fieldcontain"]').eq(0)}},".tagstrip *.value":function(e){return e.parents(".tagstrip").eq(0)},"div.redactor_box textarea":function(e){return e.parents("div.redactor_box").eq(0).parent()},".my-tags,.hasDatepicker,.ui-widget,input,textarea,select,button":{".my-cleditor":function(e){return e.parents("div.cleditorMain").eq(0).parent()},"":function(t){var r=t[0].parentNode,n=r.nodeName;return/^(div|span|a|p|form|fieldset|li|ul|td|th|h\d)$/i.test(n)?e(r):t.parents("div,span,a,p,form,fieldset,li,ul,td,th,h1,h2,h3,h4,h5,h6").eq(0)}},"":function(e){return e}},offon:{".ace_editor":function(e,t){ace.edit(t[0]).setReadOnly(e)},".ui-selectable":function(e,t){ct.jquix(t,"selectable",e)},".ui-slider":function(e,t){ct.jquix(t,"slider",e)},".ui-draggable":function(e,t){ct.jquix(t,"draggable",e)},".ui-buttonset":function(e,t){ct.jquix(t,"buttonset",e)},".hasDatepicker":function(e,t){ct.jquix(t,"datepicker",e)},".my-form":function(e,t){t.my("disabled",!!e)},"div.select2-container+input,div.select2-container+select":function(e,t){ct.jquix(t,"select2",e) -},".my-cleditor":function(e,t){t.cleditor()[0].disable(!!e)},"":function(e,t){t.attr("disabled",!!e)}},destroy:{".hasDatepicker":function(e){e.datepicker("destroy")},".ui-slider":function(e){e.slider("destroy")},".ui-sortable":{".my-form-list":function(t){t.find(">.my-form").each(function(){e(this).my("remove")}),t.removeClass("my-form-list"),t.sortable("destroy")},"":function(e){e.sortable("destroy")}},".my-form-list":function(t){t.find(">.my-form").each(function(){e(this).my("remove")})},".ui-draggable":function(e){e.draggable("destroy")},".my-redactor-8":function(e){e.destroyEditor(),e.removeClass("my-redactor-8")},"div.select2-container+input,div.select2-container+select":function(e){e.select2("destroy")},".my-form":function(e){e.my("remove")},textarea:{".my-codemirror":function(e){e[0].nextSibling.CodeMirror.toTextArea(),e.removeClass("my-codemirror")}}}};lt.params={container:function(e){return d(e,lt.containers)(e)},change:V,recalcDepth:2,delay:0,strict:!1,restyle:-1,locale:T=(navigator.language||navigator.userLanguage||"en").substr(0,2),messages:Object.map(lt.msg,function(e,t){return t[T]||t.en}),errorTip:".my-error-tip",errorCss:"my-error",animate:0,effect:function(e,t,r){return t?e.fadeIn(r):void e.fadeOut(r)},remember:0,silent:!1,history:{},historyDelay:100,loader:function(t){var r=e.Deferred(),n=ot(t+"");return n?r.resolve(n):r.reject(null),r.promise()},ajaxTimeout:1e4};var ct=S(),ut={init:function(i,a,o){function c(e){var t,r,i,a,o,s,l={},c=!0,u=e.inherit;if(l=_(u),!Object.size(l))return null;if(a=dt.parents(".my-form").eq(0),!a.size())return null;if(o=a.data("my"),!o||!o.manifest)return null;i=o.manifest,r=i.expose,c=!r;for(t in l)(c||r[t])&&(s=n(i,t),null!=s&&(/\./.test(t)||$(l[t])?Q(!0,I,ct.unmask(s,$(l[t])?l[t]:t)):e[t]=s))}function d(){var e,r;for(var e in et)for(r in M[e].listen)et[e].addClass("my-listen-"+ct.sdbmCode(r));X.radio&&dt.on("radio.my",function(e,r){var n,i;if(F(r)&&r.channel&&r.message&&A(X.radio[r.channel])){n=X.radio[r.channel];try{i=n.call(X,e,r)}catch(a){t("Radio handler for form "+S+"failed",a.message,a.stack)}void 0!==i&&(e.stopPropagation(),i&&l(dt,r))}})}function m(){R.strict||j(I,!0),X=Q(!0,X,Object.reject(I,["data"])),M=z(Q(!0,{},I.ui||{}),X,R),X.radio&&(X.radio=D(X.radio)),X.expose&&(X.expose=_(X.expose)),q=Number.random(268435456,4294967295).toString(16),C=I.id||"my"+q,S=ct.sdbmCode(C),X.id=C,R.form=dt,I.params&&I.params.depth&&(R.recalcDepth=I.params.depth);for(P in X)A(X[P])&&(X[P]=X[P].bind(X));I.error&&($(X.error)?nt=function(e,t){return X.error.assign(Q({message:e+"",err:t+""},X))}:A(I.error)&&(nt=function(e,t){T=null;try{T=I.error(e,t)}catch(r){T=R.messages.initFailed}return T})),Q(dt.data("my"),{id:C,cid:q,mid:S,errors:Object.extended(),ui:Object.extended(M),disabled:!1,manifest:X,locFiles:[],modals:{},radio:{}}),dt.addClass("my-form"),L="my-manifest-"+S,H="my-form-"+q,dt.addClass(H+" "+L)}function h(t){function r(e,t){return'"}!X.style||t&&!dt.is(":visible")||(U=N(dt,X,L,H),U&&U[0].length&&!t&&(J=e("style#"+L),J.size()||(J=e(r(U[0],L)).appendTo(e("body"))),J.data("count",1*J.data("count")+1),dt.data("my").style=J),U&&U[1].length&&(W=e("style#"+H),W.size()?t&&(e(r(U[1],H)).replaceAll(W),W=e("style#"+H)):(W=e(r(U[1],H)).appendTo(e("body")),R.restyle>-1&&!B[q]&&(B[q]=function(){h(!0)}.debounce(R.restyle)),dt.data("my").restyle=h.fill(!0).debounce(0)),dt.data("my").localStyle=W,t||dt.addClass("my-restyle")))}function p(){var t,r,n=e.Deferred();if(r=s(X),$(r))x("Error decoding base64 to local Blob/URL",r),n.reject();else{if(E)for(t=0;t*").clone();try{K=w(X,I.init,dt,I)}catch(t){return x($(t)?t:t.message,t.stack),dt}}if(at(K)?K.then(function(){v()},function(e,t){x(e,t)}):v(),!rt){if(!dt.my())return x("Internal error initializing controls.",""),dt;dt.data("my").initial=Q(!0,{},G),e.mobile&&e.mobile.changePage(e.mobile.activePage)}}function v(){function e(e){rt||(t[e]=u(dt.find(e),V),r-=1,.5>r&&b(t))}var t={},r=Object.size(M);dt.addClass(it),Object.each(M,function(t){if(!rt){var r=dt.find(t),n=g(r,dt,M[t],t);at(n)?n.then(e.fill(t)).fail(function(e,r){x("Error building "+t+", "+e,r)}):rt||e(t)}})}function b(e){var r,n,i;for(var a in M){if(rt)return;if(r=M[a],i=dt.find(a),i.size()){r.listen&&(et[a]=i.eq(0));try{n=f(G,V,r,i),n==V&&e[a]!=V&&void 0!==n&&f(G,e[a],r,i)}catch(o){t("Transient fail linking "+a+" of form $('.my-form-"+q+"')",o.message,o.stack)}try{n!=V&&u(i,n),i.eq(0).trigger("check.my")}catch(o){x("Error linking "+a,o.message,o.stack)}}}dt.removeClass(it),ut=null,tt.resolve(G)}function x(e,r){var n;if(rt=!0,t("Form "+C+" failed to initialize.",e,r),dt.removeClass(it),n=nt(e,r),$(n)||F(n)&&n.jquery?dt.html(n):n===!0&&dt.html(ut),R.silent)tt.resolve(G);else{if(!dt.my().ddata){if(dt.removeData("my"),dt.removeClass("my-form"),J)if("1"==J.data("count"))try{J.remove()}catch(i){}else J.data("count",J.data("count")-1);if(W)try{delete B[q],W.remove()}catch(i){}}tt.reject("Form "+C+" failed to initialize: "+e,r)}}var k,O,C,q,S,T,M,R,I,P,U,L,H,J,W,K,X={},G={},Y=[],et={},tt=e.Deferred(),rt=!1,nt=function(){},it="my-form-init",st="std",ut="";if($(i)){if(k=ot(i),!k)return tt.reject("No manifest with id "+i+" found in repo."),tt.promise();F(o)&&F(a)?(k=Q(k,a),O=o):O=a,st="repo"}else k=i,O=a;if(!k)return this;I=F(O)&&"repo"!=st?Q(!0,{},k):k;var dt=this.eq(0),ft=dt.my();return F(ft)&&ft.id&&ft.ui?(r("jQuery.my is already bound.",dt),dt.my("ui",I.ui),dt.my(Z,I.data),tt.resolve(dt.my(Z)).promise()):(R=I.params||{},R.strict||(R=Q(!0,{},R),j(R)),R=Q(!0,{},lt.params,R),tt.fail(function(){dt.removeClass(H+" "+L)}),Q(dt,tt.promise()),F(O)?(G=ct.patch(O,I.data||{}),I.data=G):G=I.data||{},X.data=G,dt.data("my",{data:G,params:R,promise:tt.promise(),locktill:0}),dt.addClass(it),I.inherit&&c(I),ct.require(I,R).then(function(){m(),p().then(function(){h(),y()})}).fail(function(e){m(),x("Linker of ‘require’ property failed.",e)}),tt.then(d),dt)},redraw:function(e,t){var r=this,n=r.my();return n&&n.ui&&(n.ui.each(function(t){var i=r.find(t);y(i,e?V:void 0,n.params.recalcDepth),e||(i.is(".my-form")&&i.my("redraw"),i.trigger(i.is(".my-form-list")?"redraw":"check.my"))}),!t&&e&&r.trigger(nt)),r},data:function(e,t){var r=this;return F(e)&&(r.my().data=ct.overlap(r.my().data,e),this.my("redraw",t)),r.my().data},errors:function(){var t=e(this).my().errors,r={};for(var n in t)t[n]&&$(t[n])&&(r[n]=t[n]),F(t[n])&&H(t[n]).length&&(r[n]=t[n]);return r},valid:function(){var t=e(this).my().errors,r=0;for(var n in t)t[n]&&$(t[n])?r++:F(t[n])&&H(t[n]).length&&r++;return!r},reset:function(){try{ct.kickoff(this.my().data,this.my().initial),this.my("redraw")}catch(e){return!1}return!0},id:function(e,t){if($(e))return ot(e,t);var r=this.my();return r&&r.id?r.id:V},remove:function(e){var t,r,n,i,a,o,s,l,c=this;if(!this.my())return V;if(this.my().root&&!this.my().ddata&&(c=this.my().root),n=c.my(),a=n.data,s=n.cid,l=n.mid,c.unbind(".my"),F(n)&&n.manifest&&A(n.manifest.die))try{n.manifest.die.call(n.manifest,c,n.manifest)}catch(u){}if(t=n.style)if("1"==t.data("count"))try{t.remove()}catch(u){}else t.data("count",t.data("count")-1);if(r=n.localStyle)try{delete B[s],r.remove()}catch(u){}if(window.URL&&(i=n.locFiles)&&i.length)for(var f=0;fo?V:(n.params.errors&&n.params.errors.values().compact(!0).length?Object.equal(n.data,n.lastCorrect)||(o+=1):Object.equal(i[a.last()],n.data)&&(o+=1),t=v(o,n.params,!0),t&&(ct.kickoff(r.my().data,t),r.my("redraw")),r.my().data)},ui:function(e){var t,r=this,n=r.my(),i=[];if(!n)return V;Q(!0,{},n.ui);if(!F(e))return n.ui;for(t in e)i.push(t);for(n.ui=z(ct.overlap(n.ui,e)),t=0;t1&&l(t[1])){for(var n,u,f,m,h,p,y,v,g=t[0],b="",x=1;x'+(g?"<"+r.labelTag+' class="'+r.labelCss+'" '+(r.label?'style="display:inline-block;width:'+r.label+";margin-left:-"+r.label+'" ':"")+">"+g+"":"")+b+""),e+b}return e}function r(e){var t=e;if(l(t)&&(t=t.split(/[\s,]/).compact(!0)),s(t)){for(var r={},n=0;n',inp:u+'text" {ext}/>',sli:u+'range" {ext}/>',dat:u+'date" {ext}/>',btn:u+'button" {ext}/>',pwd:u+'password" {ext}/>',but:"",div:"
{txt}
",spn:"{txt}",sel:"",mul:'',txt:"",err:' {txt}',msg:'
{txt}
',val:function(e){if(!s(e.vals))return"";var t=i({style:"",css:""},e);return t.txt=e.vals.reduce(function(e,t){return e+""+t+" "}," "),'{txt}'.assign(t)},"":"<{_tag} {ext}>{txt}"},txt:{sel:function(e){if(!e.vals)return"";var t=r(e.vals);return Object.keys(t).reduce(function(e,r){return e+'"},"")}},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"}},f={init:function(t,r){return e(this).html(n(t,r))}};e.my||(e.my={}),e.my.formgen=n,e.fn.formgen=function(t){return l(t)&&f[t]?f[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void e.error("Method "+t+" does not exist on jQuery.formgen"):f.init.apply(this,arguments)}}(jQuery),function(e){function t(t,r,n,i){var a,s,l,d,f,m,h;if("object"==typeof r&&r.jquery)r.is("img")&&(m=r,f=r.attr("alt")||r.attr("title")||r.data("text")||"",s=m[0].naturalWidth||m[0].width,a=m[0].naturalHeight||m[0].height,1>a&&(a=1),1>s&&(s=1),d=e(window).width()-90,l=e(window).height()-90,a>l&&(s=s*(l/a)|0,a=l),s>d&&(s=d,a=a*(d/s)|0),h=300>s?300:s,o(t,{source:"image",manifest:{init:function(e){e.html(this.HTML),e.on("click.my","img:eq(0)",function(){e.trigger("cancel")})},HTML:'

',ui:{"img:eq(0)":"img",h4:{bind:"text",css:{hide:function(e,t){return!t}}}}},data:{img:m.attr("src"),text:f},esc:!0,screen:!0,width:i||h,focus:!1,global:!0,z:"1995"},n));else if(u(r)&&r.manifest)o(t,r,n);else{if(!c(r))return null;o(t,{source:"html",manifest:{init:function(e){e.html(this.HTML)},HTML:r,ui:{"div:eq(0)":function(){}}},data:{},esc:!0,focus:!1,width:i},n)}return t}var r,n={},i="body",a=!1,o=e.extend,s={},l=(Object.isArray,Object.isBoolean),c=Object.isString,u=Object.isObject,d=Object.isNumber,f=(Object.isRegExp,Object.isFunction);e(document).keydown(function(e){var t,r,n=e.keyCode;if(!1!==a&&(13===n||27===n)){if(r=a.data("modal"),t=r.form,27==n&&(r.esc||Object.equal(t.data("my").initial,t.my("data"))))return a.modal(!0),!1;if(13==n&&r.enter)return function(e){e.modal()}.fill(a).delay(50),!1}}),n.modal=function(r,n,o){var s,c={},u=e(i),d=u.find(">.my-modal-proxy"),m={global:!0,screen:!0,done:f(n)?n:void 0,z:"1995"};return l(r)||null==r?d.modal(r):(s=e.Deferred(),t(c,r,m,o)?a?s.reject("Locked").promise():(d.size()||(d=e('
').prependTo(u),d.css({position:"absolute",top:"0",left:"0",margin:"0",padding:"0",width:"1px",height:"0"})),d.modal(c)):s.reject("Invalid data").promise())},n.modal.loading=function(t){e(i).find(">.my-modal").toggleClass("my-modal-loading",!!t)},n.modal.parent=function(t){return t&&e(t).size()?void(i=t):e(i)},n.modal.parentBack=function(t){return t&&e(t).size()?void(r=t):e(r||i)},n.modal.visible=function(){return!!a},e.my||(e.my={}),e.my.modal=n.modal,e.fn.modal=function(n,m,h){function p(){var t,r,n=window,i=!!M.global,a=w.offset(),o=D.offset();M.pos={px:a.left,py:a.top,pw:w.outerWidth(),ph:w.outerHeight(),ox:o.left,oy:o.top,ow:D.outerWidth(),oh:D.outerHeight(),ww:r,wh:t};var s=1*(M.x.match(/\-?\d+(\.\d+)?/)||[0])[0],l=1*(M.y.match(/\-?\d+(\.\d+)?/)||[0])[0],c=M.x.has("left")?-1:M.x.has("right")?1:0,u=M.y.has("top")?-1:M.y.has("bottom")?1:0,f=M.pos.ox+M.pos.ow/2-M.pos.px,m=M.pos.oy+M.pos.oh/2-M.pos.py;if(i&&(M.pos.wh=t=n.innerHeight||e(n).height(),M.pos.ww=r=n.innerWidth||e(n).width(),f=r/2,m=t/2.5),s=M.x.has("%")?M.pos.ow/100*s:s,l=M.y.has("%")?M.pos.oh/100*l:l,M.pos.pix=f,M.pos.piy=m,f=f+c*(M.pos.ow/2)+s*(c>0?-1:1)-(M.width+_)*(c+1)/2,i?(m=(t-M.height-20)/3,10>m&&(m=10)):m=m+u*(M.pos.oh/2)+l*(u>0?-1:1)-(M.height||0)*(u+1)/2,f=f.round(1),m=m.round(1),M.pos.vx=f,M.pos.vy=m,M.bound!==!1&&!M.global){var h=(d(M.bound)?M.bound:0).clamp(-100,100);M.pos.pw-2*hM.pos.pw-h?M.pos.vx=M.pos.pw-h-M.width-_:M.pos.vxM.pos.ph-h?M.pos.vy=M.pos.ph-h-M.height:M.pos.vy');var r="",n=e("style#my-modal-style-"+M.cid);("top"==M.nose||"bottom"==M.nose)&&(r+="div.my-modal-"+M.cid+".nose-"+M.nose+":before {left:"+(M.pos.ox-M.pos.px+M.pos.ow/2-M.pos.vx)+"px!important;}",n.text(r)),("left"==M.nose||"right"==M.nose)&&(r+="div.my-modal-"+M.cid+".nose-"+M.nose+":before {top:"+(M.pos.oy-M.pos.py+M.pos.oh/2-M.pos.vy)+"px!important;}",n.text(r))}M.screen?M.global?(j.css({top:0,left:0,width:2*M.pos.ww+"px",height:2*M.pos.wh+"px",display:"block",position:"fixed","z-index":M.z-1}),c(M.screen)&&j.css({background:M.screen?M.screen:"rgba(25, 39, 59, 0.88)"})):j.css({top:0,left:0,position:"absolute",width:M.pos.pw+"px",height:M.pos.ph+"px",display:"block",background:c(M.screen)?M.screen:"rgba(40,80,120,0.6)","z-index":M.z-1}):j.size()&&j.hide(),M.height>M.pos.wh?(b.height(M.pos.wh-30),x.css({"overflow-y":e.browser.webkit?"overlay":"scroll"})):x.css({"overflow-y":"none"}),b.animate({top:M.pos.vy+"px",opacity:"1"},M.animate)}function v(){try{x.my("remove")}catch(t){}try{w.data("modals")[M.cid]=null}catch(t){}x.parent().unbind(".my").remove(),j.off(".my"+M.cid),M.screen&&function(e){e&&a||j.hide(),e&&!a&&j.css({background:"rgba(25, 39, 59, 0.88)"})}.delay(50,M.global),M.global&&(a=!1,e("body").css({overflow:"auto"}))}function g(e){try{S(null,null)}catch(t){}(function(){q.reject(e)}).delay(0)}var b,x,w,j,k,O,C,q=e.Deferred(),z={},D=this,_=0,N=0,S=f(m)?m:function(){return!1},T=u(n)?n:{},M=D.data("modal");if(o(D,q.promise()),M){if(null==n||l(n)){if(x=M.form,j=M.bg,w=M.root,S=M.done,O=x.my("data"),C=!1,n){try{S(null,null)}catch(E){}if(v(),D.removeData("modal"),s[M.cid])try{s[M.cid].reject("Cancelled")}catch(E){}delete s[M.cid],M=null}else{try{C=S(x.my("valid")?null:x.my("errors"),O)}catch(E){}C||(v(),D.removeData("modal"),function(){s[M.cid]&&s[M.cid].resolve(O),delete s[M.cid],M=null}.delay(0))}return D}if(T)return g("Locked"),D}return D.is(":visible")?(T=t(z,n,{}))?T.global&&a?(g("Locked"),D):(M=o({type:"DOM",source:"manifest",form:null,modal:null,root:null,bgroot:null,caller:D,manifest:{},data:{},global:!1,screen:!1,drag:!1,focus:!0,close:!0,silent:!0,esc:!1,enter:!1,bound:!1,nose:"",width:h||300,height:null,x:"0",y:"0",z:"1901",background:"white",css:"",animate:200},T,{promise:q.promise(),cid:Number.random(268435456,4294967295).toString(16)}),M.done=f(M.done)?M.done:S,c(M.align)&&M.align&&(M.x=(M.align.match(/(left|right):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0],M.y=(M.align.match(/(top|bottom):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0]),M.width=1*(e.my.f.getref(c(M.manifest)?e.my.cache(M.manifest):M.manifest,"params.width")||M.width),M.type="DOM",D.hasClass("my-form")?(M.type="form",M.root=M.root||D):D.data("my")?(M.type="control",M.root=M.root||D.my().root):(M.root=M.root||D.parents(".my-form").eq(0),M.root.size()||(M.root=e(i))),M.global?(M.root=e(i),M.bgroot=e(r||i)):M.bgroot=M.root,w=M.root,w.data("modals")||w.data("modals",{}),p(),b=e('
').prependTo(M.root),b.addClass("my-modal-"+M.cid),_=b.outerWidth(),N=b.outerHeight(),b.hide(),b.html('
'),x=b.find(".my-modal-form"),M.close&&(k=e(c(M.close)?M.close:'
×
').prependTo(b).on("click.my",function(){D.modal(!0)}),k.css({"z-index":("+"===(M.z+"").to(1)?"+":"")+(1*M.z+1)})),j=M.bgroot.find(">.my-modal-screen"),M.screen&&(j.size()||(j=e('').prependTo(M.root)),M.esc&&j.on("click.my"+M.cid,function(){D.modal(!0)})),D.data("modal",M),M.silent&&b.on("change.my",function(){return!1}),b.css({display:"block",height:"none",opacity:"0.005","z-index":M.z,width:"auto"}),b.css(M.global?{position:"fixed",left:"50%",top:M.pos.vy+"px",display:"block",height:"none",opacity:"0.005","z-index":M.z,width:"auto","margin-left":"-"+((M.width+_)/2).round(0)+"px"}:{position:"absolute",left:M.pos.vx+"px",top:M.pos.vy+"px",display:"block",height:"none",opacity:"0.005","z-index":M.z,width:"auto"}),x.my(M.manifest,M.data).then(function(){var t,r,n,i,l;if(o(M,{form:x,bg:j,cancel:function(){D.modal(!0)},commit:function(){D.modal()}}),b.data("modal",M),M.height=b.outerHeight(),"manifest"!==M.source&&(M.width=b.width()),p(),b.css({top:M.pos.vy+"px"}),y(!0),w.data("modals")[M.cid]=M,s[M.cid]=q,x.bind("commit.my",function(){return M.commit.delay(50),!1}).bind("cancel.my",function(){return M.cancel.delay(50),!1}),b.bind("layout.my",function(){y()}.debounce(50)),M.global&&(a=D,e("body").css({overflow:"hidden"})),M.global||!M.esc&&!M.enter||x.bind("keydown.my",function(t){var r=t.keyCode;return 27==r&&M.esc?(M.cancel(),!1):13==r&&M.enter&&!e(t.target).is("textarea")?(M.commit.delay(50),!1):void 0}),M.focus===!0){i=!1,l=M.manifest.ui;for(n in l)i||(r=x.find(n),r.size()&&r.is("input, textarea","button")&&(i=!0,r.focus()))}else c(M.focus)&&x.find(M.focus).focus();if(t=x.find("img").filter(function(){return""!=e(this).attr("src")}),t.size()){var u=function(){"manifest"!==M.source&&b.css({width:"auto"}),y()}.after(t.size());t.each(function(){e(this).bind("load",u)})}M.drag&&e.fn.draggable&&(c(M.drag)?b.draggable({handle:M.drag}):b.draggable(),M.nose&&b.on("dragstart.my",function(){b.removeClass("nose-"+M.nose)})),q.notify("Ready")}).fail(function(e){v(),D.data("modal",null),q.reject(e)}),D):(g("Invalid data"),D):(g("Object must be visible"),D)}}(jQuery); \ No newline at end of file +!function(e){function t(){window.console&&console.error.apply(console,arguments)}function r(){window.console&&console.log.apply(console,arguments)}function n(e,t){return(P(t)?t.split("."):R(t)?t:[""]).reduce(function(e,t){if(null!=e){if(/=/.test(t)){var r=t.split("=",2);return $(e)?Object.values(e).find(function(e){return $(e)||R(e)?e[r[0]]==r[1]:!1}):R(e)?e.find(function(e){return $(e)||R(e)?e[r[0]]==r[1]:!1}):void 0}if(null!=e&&null!=e[t])return e[t]}return void 0},e)}function i(e,t){var r,i;if($(t))return t;if(P(t)){if(r=n(e,t),null==r&&(r=Object.clone(H._src[t],!0)),null==r&&(r=n(H,t),$(r)&&$(r._self)?r=Object.clone(r._self,!0):$(r)&&(r=Object.clone(r,!0))),null==r&&n(e,"params.cache")&&(i=n(e,"params.cache"),A(i)?r=i(t):$(i)&&(r=at(t,i)),$(r)&&($(r._self)&&(r=Object.clone(r._self,!0)),Object.merge(r,{params:{cache:i}},!0))),null!=r&&$(r))return i=i||n(e,"params.cache"),i&&Object.merge(r,{params:{cache:i}},!0),r;throw"Component "+t+" not found."}return A(t)?t.apply(e,Array.prototype.slice.call(arguments,2)):null}function a(r,i){var a,s,l,c,u,d=i||H,f=r;if(!($(d)&&$(f)&&$(f.ui)&&P(f.id)))return"Can’t save manifest into cache, invalid arguments.";d.hasOwnProperty("_src")||(d._src={}),l=f.id;try{f=Object.clone(r,!0)}catch(m){return"Can’t save circular-referencing object into cache."}try{(!f.params||f.params&&!f.params.strict)&&w(f,!0)}catch(m){return"Invalid manifest, parse error."}if(a=o(f),P(a))return t(a),a;if(Object.merge(f,{params:{strict:!0}},!0),d._src[l]=f,c=lt.mask(d,l)){if(c.params&&c.params.protect)return"Can’t save manifest into cache over protected one.";c._self&&delete c._self,e.extend(!0,d,lt.unmask("",l))}return e.extend(!0,d,lt.unmask(f,l)),s=Object.keys(d._src).filter(function(e){return e.startsWith(l+".")}),s.sort(),s.forEach(function(t){var r;(r=lt.mask(d,t))&&(r._self&&delete r._self,e.extend(!0,d,lt.unmask("",t))),e.extend(!0,d,lt.unmask(d._src[t],t))}),u=n(d,l),M?u._self=d._src[l]:Object.defineProperty(u,"_self",{get:function(){return d._src[l]},set:function(){throw"Can’t change manifest cache entry directly."},enumerable:!1,configurable:!0}),u}function o(e){var t,r,n=[];if($(e.files)&&Object.size(e.files))for(t in e.files){if(r=e.files[t],!$(r))return"Non-object member "+t+" in files section.";if(P(r.data)&&!r.url)if(E)try{lt.base642blob(r.data,function(e){r.blob=e,r.url=E.createObjectURL(r.blob)},r.content_type||r.mime),n.push(t)}catch(i){return"Invalid base64 data in files/"+t+"."}else r.url="data:"+(r.content_type||r.mime)+";base64,"+r.data,n.push(t)}return n}function s(r,n){$(n)&&n.channel&&n.message&&r.find(".my-listen-"+lt.sdbmCode(n.channel)).each(function(){var r,i=e(this),a=i.data("my"),o=void 0;if(a&&a.ui.listen&&A(a.ui.listen[n.channel])){r=a.ui.listen[n.channel];try{o=r.call(a.manifest||a.root.my().manifest,a.data,n.message,i)}catch(s){t("Listener failed",s.message,s.stack)}void 0!==o&&(null===o?i.trigger("check"):o&&i.trigger("recalc"))}})}function l(t,r){function i(t,r){var n;return P(t)?/[\/]/.test(t)?(n=B(!0,{},k,{ref:r,ajax:{url:t}}),nt.test(r)&&(n.ajax.dataType="json")):t.length&&(n=B(!0,{},k,{ref:r,ajax:t})):$(t)&&(n=B(!0,{},k,{ref:r,ajax:e.extend(!0,{},Object.select(t,["accepts","async","cache","data","dataType","xhrFields","password","timeout","type","url","username","headers"]))}),n.ajax.url||(n=null)),n}function a(){g.reject(w)}function o(){O+=1;var e=b[O];if(e)s(e).then(o).fail(a);else{var r=c(x),n=L(Object.findAll(r,function(e,t){return!t}));n.length&&w.push((1===n.length?"Key "+n[0]+" is":"Keys "+n.join(", ")+" are")+" not present after all."),w.length?a():g.resolve(t)}}function s(r){function n(){c-=1,s?l.reject():.5>c&&l.resolve()}var i,a,o,s=!1,l=e.Deferred(),c=r.length;for(a=0;c>a;a++)i=r[a],o=P(i.ajax)?j.loader:ot,o(i.ajax).then(function(e,r){nt.test(r.ref)&&(null!=e?B(!0,t,lt.unmask(e,r.ref.from(5))):(s=!0,w.push("Invalid data for ‘"+r.ref+"’ resource."))),n()}.fill(void 0,i)).fail(function(e,t){w.push("Failed to load ‘"+t.ref+"’ resource."),s=!0,n()}.fill(void 0,i));return l.promise()}function l(e){var r=!1;return nt.test(e)?null!=n(t,e.from(5))&&(r=!0):null!=n(window,e)&&(r=!0),r}function c(e){for(var t in e)e[t]===!1&&(e[t]=l(t));return e}var u,d,f,m,h,p,y,v,g=e.Deferred(),b=[],x={},w=[],j=B(!0,{ajaxTimeout:1e4,loader:st.params.loader},r||{}),k={ref:null,ajax:{type:"GET",async:!0,timeout:j.ajaxTimeout}};if($(t))if(R(t.require)){for(m=t.require,u=0;ui)return n=l,void(i=o);c==G&&r(e,l,o+1)}W!=t[""]&&typeof t[""]!=G&&o>i&&(n=t[""],i=o)}var n=W,i=0,a="";return r(e,t,1),n}function d(e,t,r,n){var i,a,o,s=[],l=r.bind,c=Q(l);if(c==tt)return l.call(m(n).manifest,e,t,n);if(c===et||c===Z){if(c===et&&!/\./.test(l))return t!=W?e[l]=t:void 0===e[l]&&(e[l]=W),e[l];for(c===et&&(s=l.split(".").each(function(e,t){this[t]=e+""})),c===Z&&(s=l.slice(0).each(function(e,t){this[t]=e+""})),"this"===s[0]?(a=m(n).manifest,s.shift()):a=e,i=0;i-1?"":u;case"s":return r==s?"":u;case"o":return s[r]?"":u;case"b":if(i.is(".my-form-list,.ui-sortable")){var f=i.data("listSrc")||i.data("my").listSrc||">*",h={};return i.find(f).filter("*:not(.ui-sortable-placeholder)").each(function(t){var r=e(this);r.data("my")&&!r.my("valid")&&(h[t]=r.my("errors"))}),h}return i.hasClass("my-form")&&s?i.my("valid")?"":i.my("errors"):""}return l.formError||"Error"}return""}function m(e){var t=e.my();return t?t.root?t.root.my():t:null}function h(t,r,n){var i=n.compact(),a=i.replace(/:disabled/g,""),o=a!==i,s="self:"===a.to(5);return s&&(a=a.replace(/^self:/g,"")),r.each(function(){var n=e(this),i=n.my(),l=!s&&i?i.container:n;l.toggleClass(a,!!t),o&&void 0!==i&&!!t!=!!i.disabled&&(n.my().disabled=!!t,i._disable||(n.my()._disable=u(r,st.offon).fill(void 0,r)),i._disable(!!t))}),r}function p(e,r,n){var i,a,o,s,l,u,m,y,v,g,b,x,w=!1,j=!1,k=e,O=k.my(),C="";if(O){if(v=O.selector,g=O.root,g.hasClass("my-form-init"))return{};if(b=g.find(v),x=g.my().ui,w=e.hasClass("my-form"),j=e.hasClass("my-form-list"),w?(a=e,o=O.ddata,s=O.dui,l=O.dparams):(a=O.container,o=O.data,s=O.ui,l=O.params),s.bind!=W){if(u=V(r)?r:c(b,d(o,W,s,b)),W!=s.check){C="Unknown error";try{C=f(o,u,s,b)}catch(q){t("Error "+q.message+" in .check validator for "+v,g,q.stack)}}var z=l.errorCss,D="ui-state-error";try{W!=r&&(u=c(b,d(o,r,s,b)))}catch(q){C=l.messages.formError||"Error"}if(""===C)w?O.derrors[v]="":O.errors[v]="",a.removeClass(z),a.attr("title")&&a.attr("title",""),w||j||l.effect(a.find(l.errorTip),!1,l.animate/2),k.removeClass(D),k.find(".ui-widget").removeClass(D);else{if(w)O.derrors[v]=C;else if(j)O.errors[v]=C;else{a.addClass(z),O.errors[v]=C;var N=a.find(l.errorTip).eq(0);N.size()?l.effect(N.addClass(z).html(C),!0,l.animate):a.attr("title",(C||"").stripTags())}k.is(".hasDatepicker")&&(k.is("input")?k.addClass(D):k.find(".ui-widget").addClass(D)),k.is(".ui-slider")&&k.addClass(D)}}var _=r==W?u:r;if(s.css)for(m in s.css)y=s.css[m],U(y)?h(y.test(_),b,m):A(y)&&h(y.call(g.my().manifest,o,_,b),b,m);var i,T,S=s.recalc,E=[],M={};if(n&&s.recalc&&g.my()){for(x=g.my().ui,i=0;i=2*s){for(f={},a=s;2*s>a;a++)f[o[a]]=i[o[a]];t.history=f}return n||m.form.trigger(rt),m.history[o.last()]}if(!isNaN(e)||e===W){if(l=parseInt(e)||0,0>l)return W;if(o=L(i).sort(),l>=o.length&&(l=o.length-1),d=Object.clone(m.history[o[o.length-l-1]],!0),r){for(f={},a=0;a$/.test(C.list)?s=C.list:c=C.list||c,!s){var u=a.find(c);s="
",u.size()&&(s=e(s).append(u.eq(0).clone(!0)).html(),u.eq(0).remove())}a.data("formlist")||a.data("formlist",{}),a.data("formlist").generator={manifest:w,delay:(C.delay||O.delay||10)/1.3,template:s,selector:c,parent:D,bind:C.bind,hash:A(C.hash)?C.hash.bind(D):P(C.hash)?f.fill(void 0,C.hash):R(C.hash)?m.fill(void 0,C.hash.slice(0)):null,id:A(C.id)?C.id.bind(D):P(C.id)?f.fill(void 0,C.id):R(C.id)?m.fill(void 0,C.id.slice(0)):null,ext:!(!C.id&&!C.hash),stamp:0},a.on("insert.my",function(t,r){t.stopPropagation();var n={what:void 0,where:0};null==r?n.where=1e6:$(r)?Object.merge(n,r):(P(r)||F(r))&&(n.where=r),e(t.target).my("insert",n.where,n.what)}),a.on("remove.my",function(t){t.stopPropagation(),e(t.target).my("remove")})}else try{t=a.my(i(D,w),$(o)?o:void 0)}catch(p){d("$.my subform init of "+l+" failed: "+p.message,p.stack)}}it(t)?t.then(h,function(e,t){d("Init of subform "+l+" failed with error: "+e,t)}):h()}function d(e,r){t(e,r),q&&q.reject(e,r)}function f(e,t){var r=n(e,t)||"";return"string"==typeof r?r:lt.sdbmCode(r)}function m(e,t){return lt.sdbmCode(lt.mask(e,t))}function h(){a.each(function(){var t,r,n,i=e(this),c=!1;if("TEXTAREA"==i[0].nodeName&&(n=i[0].nextSibling,r=n&&n.CodeMirror?n.CodeMirror:null,r&&i.addClass("my-codemirror")),t=C.events||u(i,st.events),i.is(".my-form")?B(i.data("my"),{dui:C,root:o,selector:l,dparams:O,devents:t,ddata:k.data,container:O.container(i),derrors:k.errors}):(i.data("my",{events:t,selector:l,initial:v,previous:v,root:o,container:O.container(i),id:k.id,ui:C,data:k.data,params:O,errors:k.errors}),s._update=C.delay?p.debounce(C.delay):W,c=!0),c)if(i.cleditor&&i.parent().is(".cleditorMain")){var d=i.cleditor()[0];if(d&&d.$frame&&d.$frame[0]){i.addClass("my-cleditor"),B(i.data("my"),{container:O.container(i)});var f,m=function(e){i.val(e).trigger(rt)},h=Number.random(1e5,1e6-1);e(d.$frame[0]).attr("id","cleditCool"+h),f=document.frames?document.frames["cleditCool"+h].document:e("#cleditCool"+h)[0].contentWindow.document;var y=e(f).find("body");e(f).bind("keyup.my",function(){m(e(this).find("body").html())}),i.parent().find("div.cleditorToolbar").bind("click.my mouseup.my",function(){m(y.html())}),e("body").on("click","div.cleditorPopup",function(){m(y.html())})}}else if(i.is("div.redactor_box textarea")){var x,w="my-redactor-9";try{x=i.getEditor(),w="my-redactor-8"}catch(q){x=i.redactor("getEditor")}x&&(i.addClass(w),x.bind("input.my keyup.my blur.my",function(e){e.trigger("redactor")}.fill(i)))}else i.is(".ace_editor")?ace.edit(a[0]).on(rt,function(e){e.trigger("ace")}.fill(i)):r&&r.on(rt,function(e){e.trigger("codemirror")}.fill(i));i.my()._changed=g.debounce(j),i.my()._recalc=b.debounce(j),i.bind(t,function(e){e.type==rt&&e.stopPropagation(),c&&(k.locktill=Date.now()+s.delay),i.my()._changed(i,o,s,O)}),/check(\.my)?/.test(t+"")||i.on("check.my",function(){return i.my()._changed(i,o,s,O,!0),!1}),c||i.off("redraw.my"),i.on("recalc.my, redraw.my",function(e){e.stopPropagation(),i.my()._recalc(i,o,s,O)})}),q&&q.resolve()}var y,v,w,j,k=o.my(),O=(k||{}).params,C=s,q=null,z=0,D=k.manifest;return k?(j=s.delay,a.size()?(C.init!=W&&(y=x(D,C.init,a,k)),it(y)?(z+=1,q=e.Deferred(),y.then(c,function(e,t){d("Init of "+l+" failed: "+e,t)})):c()):r("Not found "+l+" selector.",o),q):(t("Failed to find $root building "+l+" selector."),null)}function g(e,t,r,n,i){var a=e.data("my"),o=t.data("my");if(a&&!a.disabled){y(a.ddata||a.data,a.dparams||a.params);var s=t.find(a.selector);p(e,i?W:c(s,W),r.recalcDepth||n.recalcDepth),void 0===o.orphan&&a.root.parent().hasClass("ui-sortable")&&(o.orphan=!a.root.parent().hasClass("my-form-list")),o.orphan&&a.root.parent().trigger("check"),n.change&&n.change.call(e)}}function b(e,t,r,i){var a=e.my();if(a&&!a.disabled){var o=t.find(a.selector);o.is(".my-form")?o.my("redraw"):p(e,o.is(".my-form-list")?n(o.my().data,o.data("formlist").generator.bind):W,r.recalcDepth||i.recalcDepth)}}function x(e,t,r,i){var a;if(P(t)){if(a=n(e,t),void 0===a)return r.html(t.assign(i.data)),null}else a=t;if(A(a))return a.apply(e,Array.prototype.slice.call(arguments,2));if(R(a))try{r.formgen(a)}catch(o){}return null}function w(e,t){var r,n=!t;for(r in e)e.hasOwnProperty(r)&&j(r,e,n)}function j(e,r,n){var i,a,o,s,l="";(n||!/^(data|files|require)$/.test(e))&&(i=r[e],l=Q(i),/^(ob|ar)/.test(l)?w(i):"string"===l&&/^(function[\s\n\t]+|new\sRegExp)/.test(i)&&((a=i.match(/^function([\s\n\t]+[\w_$][\w\d_$]*)?[\s\n\t]*\(([^\)]*)\)\s*\{([\s\S]*)\}[\s\n\r\t]*$/))&&4===a.length?(s=a[1]?a[1].replace(/[\s\n\t]/g,""):"",o=s.length?O(s,a[2],a[3]):k(a[2],a[3]),"function"==typeof o?r[e]=o:t("Invalid function in XJSON, skipped",o.message,o.stack,i)):(a=i.match(/^new\sRegExp\s*\(\/([\s\S]+)\/([a-z]*)\)$/))&&3===a.length&&(o=C(a[1],a[2]),"function"==typeof o.test?r[e]=o:t("Invalid RegExp in XJSON, skipped",o.message,o.stack,i))))}function k(e,t){var r;try{r=new Function(e,t)}catch(n){r={message:n.message,stack:n.stack}}return r}function O(e,t,r){var n;try{n=new Function("","return (function "+e+"("+t+"){"+r+"});")()}catch(i){n={message:i.message,stack:i.stack}}return n}function C(e,t){var r;try{r=new RegExp(e,t)}catch(n){r={message:n.message,stack:n.stack}}return r}function q(e,t,r){var i=$(t)?t:null;return Object.each(e,function(t,r){var n=typeof r;/^str|^fu/.test(n)&&(e[t]={bind:r})}),Object.each(e,function(t,a){var o,s,l,c=[],u=[],d=/\s?[,;]\s?/;a.recalc&&(P(a.recalc)?c=a.recalc.split(d):R(a.recalc)&&(c=a.recalc),c=c.compact(!0).unique()),c.length&&(e[t].recalc=c),null==a.bind&&(a.bind=function(){});var f;if(a.listen&&(f=z(a.listen),a.listen=Object.size(f)?f:void 0),a.hasOwnProperty("watch"))for(P(a.watch)?u=a.watch.split(d):R(a.watch)&&(u=a.watch.slice(0)),u=u.compact(!0).unique(),l=0;l2?f=lt.css2json(f):o.push(a+(/\{/.test(f)?f:"{"+f+"}"))),R(f)&&f.length)for(l=0;le?"0"+e:e}function t(e,a,o){var s,l,c,u,d=0,f=a||0,m=n;switch(o&&P(o)&&(d=String(o).length,m=String(o).repeat(10)),(typeof e).substr(0,3)){case"str":return i(e);case"num":return isFinite(e)?""+String(e):"null";case"boo":case"nul":return String(e);case"fun":return i(r(e.toString()));case"obj":if(!e)return"null";if(typeof e.toJSON===tt)return t(e.toJSON(),f+(o?1:0),o);if(s=[],R(e)){for(l=0;l-1))&&(n=a[i[o]]={}));else null!=t&&(e[r]=t);return e}var a,o,s;if(null==r?(a={},o=e,s=t):(a=e,o=t,s=r),$(o)&&$(s))return lt.mask(o,s);if(P(s)&&(s=[s],o=[o]),!R(s)||!R(a)&&!$(a))return null;if($(o)&&(o=s.reduce(function(e,t){return e.push(n(o,t)),e},[])),R(o)&&R(s)){for(var l=0;ll;l++)s[l]=i.charCodeAt(l);return n=new Blob([s],{type:r||"application/octet-stream"}),A(t)?void t(n):n},base64:function(t,r,n){var i=(Q(t),null),a=P(t)?t:e.my.tojson(t),o=P(n)?"data:"+n+";base64,":"";if(r){try{i=decodeURIComponent(escape(window.atob(a)))}catch(s){i=null}if(null!==i&&/(^".*"$)|(^\[.*\]$)|(^\{.*\}$)/.test(i))try{i=e.my.fromjson(i)}catch(s){i=null}return i}return o+window.btoa((n===!0?"":"")+unescape(encodeURIComponent(a)))},css2json:function(e){var t=(e+"").replace(/\/\*[\s\S]+\*\//gm,"").replace(/@charset[^;]+;/gim,"").replace(/[\n\t\s]+/g," ").replace(/\}/g,"}ᴥ").replace(/^\n+/g,"").replace(/[\n\s]+$/g,"").split("ᴥ").compact(!0).reduce(function(e,t){var r,n,i,a=t.trim();return/^[^{]+\{[^\}]+\}$/.test(a)&&(r=a.to(-1).split("{"),n=" "+r[0].trim(),i=r[1].trim(),";"!=i.last()&&(i+=";"),e[n]||(e[n]=""),e[n]+=i),e},{});return t}}}var T,S="jQuery.my 1.1.9",E=window.URL||window.webkitURL,M=!document.addEventListener,R=Object.isArray,I=Object.isBoolean,P=Object.isString,$=Object.isObject,F=Object.isNumber,U=Object.isRegExp,A=Object.isFunction,L=Object.keys,H=n(e,"my.f.repo")?e.my.f.repo():{_src:{},_name:"Default manifest cache"},J=n(e,"my.f.restyles")?e.my.f.restyles():{},B=e.extend,Q=e.type,W=null,V=function(e){return null!==e&&void 0!==e},X="{yyyy}-{MM}-{dd}",K="{HH}:{mm}",G="object",Y="data",Z="array",et="string",tt="function",rt="change",nt=/^this\./,it=function(e){return!!(null!=e&&($(e)||e.jquery)&&A(e.then)&&A(e.fail)&&A(e.state))},at=function(e,t){var r,i;return P(e)?(r=e,i=n($(t)?t:H,r),"exist"===t?$(i):i?Object.clone(i,!0):null):$(e)?(i=a(e,t),$(i)?i:null):void 0===e?H._src:null===e?Object.reject(H,/^_/):null},ot=e.ajax,st={vals:{".my-form":function(e,t){if(e&&e.my){var r=e.my(Y);return Object.equal(r,t)?r:e.my(Y,t,!0)}return t||W},".hasDatepicker":function(e,t){V(t)&&e.datepicker("setDate",""==t?t:Date.create(t));var r=e.datepicker("getDate");return r?r.format(X):""},".my-tags":function(e,t){return V(t)&&(P(t)||F(t)?e.tags(Y,[t+""]):R(t)&&e.tags(Y,t)),e.tags(Y)},".ui-draggable":function(e,t){if(V(t)&&$(t)){var r={};isNaN(t.left)||(r.left=Number(t.left).ceil(2)+"px"),isNaN(t.top)||(r.top=Number(t.top).ceil(2)+"px"),(r.left||r.top)&&e.css(r)}var n=e.position();return{left:t&&!isNaN(t.left)?(1*t.left).ceil(2):n.left.ceil(2),top:t&&!isNaN(t.top)?(1*t.top).ceil(2):n.top.ceil(2)}},".my-form-list":function(t,r){function n(){var r,n,i=e(this),a=i.data("my");a&&(r=i.data("formlist"),n=r.index,r.hash=x(a.data,n)+"",r.oid=w!==x?w(a.data,n)+"":r.hash),t.trigger("check.my")}function a(e){e.data("my").locktill+k/1.3.my-form",g=y.template||"
",b=/\{/.test(g),x=y.hash||lt.sdbmCode,w=y.id||lt.sdbmCode,j=y.ext,k=y.delay||50,O=t.is("."+m),C=!!t.children(h).size(),q=[],z=[],D=Date.now(),N=t.find(O?t.sortable("option","items"):v);if(V(r)&&R(r)){if(C)return r;if(s=[],l={},N.each(function(){var t,r=e(this),n=r.data("my");n&&(s.push(n.data),(t=r.data("formlist"))&&(l[t.oid]=n.data))}),u=!1,s&&s.length===r.length)for(u=!0,o=0;o1.4*k||D-y.stamp>100||!y.stashed||y.stashed.length!==N.size()-(C?1:0)){C&&(f=t.find(">."+m+"-helper"));var M=0;for(N.each(function(t,r){var n,i,a,o=e(r),s=!1;C&&o.hasClass(m+"-helper")||(C&&o.hasClass(m+"-placeholder")&&(o=f),n=o.data("my"),i=o.data("formlist"),n&&i&&(q.push(n.data),M!=i.index&&(i.index=M,s=!0),j&&(a=x(n.data,M)+"",a!==i.hash&&(i.hash=a,s=!0)),M+=1,s&&z.push(o)))}),o=0;o."+a+"-placeholder",s=t.find(t.sortable("option","items"));if(V(r)&&R(r)){var l={},c={},u=r.unique();if(t.find("input:focus:eq(0),textarea:focus:eq(0)").size()||t.find(o).size())return u;s.each(function(){l[lt.sdbmCode(lt.extval(e(this)))]=e(this)});for(var d=u.length-1;d>=0;d--){var f=lt.sdbmCode(u[d]);l[f]&&(l[f].prependTo(t).show(),c[f]=!0,-1==i.indexOf(u[d])&&i.push(u[d]))}i=i.reverse();for(d in l)c[d]||l[d].hide()}else{var m=t.find(o),h=t.eq(0);0!=m.size()?(h.my()[a]!=m.position().left+""+m.position().top?(s=s.filter(":visible:not(:disabled, .ui-state-disabled, .ui-sortable-helper)"),n=t.find(t.sortable("option","items")).filter(".ui-sortable-helper"),s.each(function(){var t=e(this);i.push(lt.extval(t.is(".ui-sortable-placeholder")?n:t))}),h.my()[a]=m.position().left+""+m.position().top,h.my()[a+"1"]=i):i=h.my()[a+"1"],i==W&&s.each(function(){i.push(lt.extval(e(this)))})):(s=t.find(t.sortable("option","items")).filter(":visible:not(:disabled, .ui-state-disabled)"),s.each(function(){i.push(lt.extval(e(this)))}))}return i},"input[type=date]":function(e,t){if(V(t))return r=""!=t?Date.create(t).format(X):"",P(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(X):""},"input[type=time]":function(e,t){if(V(t))return r=""!=t?Date.create(t).format(K):"",P(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(K):""},input:{"[type='text'],[type='number'],[type='search'],[type='hidden'],[type='password'],[type='button'],[type='range'],:not([type])":{".ui-slider-input":function(e,t){V(t)&&e.val(t).slider("refresh")},".tagstrip input.value":function(e,t){V(t)&&e.val(t).trigger("update")},"div.select2-container+input":function(e,t){return V(t)&&JSON.stringify(t)!==JSON.stringify(e.select2("val"))&&e.select2("val",R(t)?t:[t]),e.select2("val")},"":function(e,t){V(t)&&e.val(t+"")}},":radio":function(t,r){var n=-1;if(V(r)){t.each(function(t){var i=e(this).val();r+""==i+""&&(n=t)});var i=t.eq(0).checkboxradio;if(i&&t.each(function(t){var r=e(this);n!=t&&r.is(":checked")&&r.prop("checked",!1).checkboxradio("refresh")}),n>-1){var a=t.eq(n);a.is(":checked")||(a.prop("checked",!0),i&&a.checkboxradio("refresh"))}else i||t.each(function(){e(this).prop("checked",!1)})}if(-1==n)for(var o=0;oForm init failed

',ru:'

Ошибка инициализации формы

'},badInput:{en:"Invalid input",ru:T},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(e){return e.parents('[data-role="fieldcontain"]').eq(0)}},".tagstrip *.value":function(e){return e.parents(".tagstrip").eq(0)},"div.redactor_box textarea":function(e){return e.parents("div.redactor_box").eq(0).parent()},".my-tags,.hasDatepicker,.ui-widget,input,textarea,select,button":{".my-cleditor":function(e){return e.parents("div.cleditorMain").eq(0).parent()},"":function(t){var r=t[0].parentNode,n=r.nodeName;return/^(div|span|a|p|form|fieldset|li|ul|td|th|h\d)$/i.test(n)?e(r):t.parents("div,span,a,p,form,fieldset,li,ul,td,th,h1,h2,h3,h4,h5,h6").eq(0)}},"":function(e){return e}},offon:{".ace_editor":function(e,t){ace.edit(t[0]).setReadOnly(e) +},".ui-selectable":function(e,t){lt.jquix(t,"selectable",e)},".ui-slider":function(e,t){lt.jquix(t,"slider",e)},".ui-draggable":function(e,t){lt.jquix(t,"draggable",e)},".ui-buttonset":function(e,t){lt.jquix(t,"buttonset",e)},".hasDatepicker":function(e,t){lt.jquix(t,"datepicker",e)},".my-form":function(e,t){t.my("disabled",!!e)},"div.select2-container+input,div.select2-container+select":function(e,t){lt.jquix(t,"select2",e)},".my-cleditor":function(e,t){t.cleditor()[0].disable(!!e)},"":function(e,t){t.attr("disabled",!!e)}},destroy:{".hasDatepicker":function(e){e.datepicker("destroy")},".ui-slider":function(e){e.slider("destroy")},".ui-sortable":{".my-form-list":function(t){t.find(">.my-form").each(function(){e(this).my("remove")}),t.removeClass("my-form-list"),t.sortable("destroy")},"":function(e){e.sortable("destroy")}},".my-form-list":function(t){t.find(">.my-form").each(function(){e(this).my("remove")})},".ui-draggable":function(e){e.draggable("destroy")},".my-redactor-8":function(e){e.destroyEditor(),e.removeClass("my-redactor-8")},"div.select2-container+input,div.select2-container+select":function(e){e.select2("destroy")},".my-form":function(e){e.my("remove")},textarea:{".my-codemirror":function(e){e[0].nextSibling.CodeMirror.toTextArea(),e.removeClass("my-codemirror")}}}};st.params={container:function(e){return u(e,st.containers)(e)},change:W,recalcDepth:2,delay:0,strict:!1,restyle:-1,locale:T=(navigator.language||navigator.userLanguage||"en").substr(0,2),messages:Object.map(st.msg,function(e,t){return t[T]||t.en}),errorTip:".my-error-tip",errorCss:"my-error",animate:0,effect:function(e,t,r){return t?e.fadeIn(r):void e.fadeOut(r)},remember:0,silent:!1,history:{},historyDelay:100,loader:function(t){var r=e.Deferred(),n=at(t+"");return n?r.resolve(n):r.reject(null),r.promise()},ajaxTimeout:1e4};var lt=_(),ct={init:function(i,a,l){function u(e){var t,r,i,a,o,s,l={},c=!0,u=e.inherit;if(l=D(u),!Object.size(l))return null;if(a=dt.parents(".my-form").eq(0),!a.size())return null;if(o=a.data("my"),!o||!o.manifest)return null;i=o.manifest,r=i.expose,c=!r;for(t in l)(c||r[t])&&(s=n(i,t),null!=s&&(/\./.test(t)||P(l[t])?B(!0,I,lt.unmask(s,P(l[t])?l[t]:t)):e[t]=s))}function f(){var e,r;for(var e in et)for(r in M[e].listen)et[e].addClass("my-listen-"+lt.sdbmCode(r));K.radio&&dt.on("radio.my",function(e,r){var n,i;if($(r)&&r.channel&&r.message&&A(K.radio[r.channel])){n=K.radio[r.channel];try{i=n.call(K,e,r)}catch(a){t("Radio handler for form "+T+"failed",a.message,a.stack)}void 0!==i&&(e.stopPropagation(),i&&s(dt,r))}})}function m(){R.strict||w(I,!0),K=B(!0,K,Object.reject(I,["data"])),M=q(B(!0,{},I.ui||{}),K,R),K.radio&&(K.radio=z(K.radio)),K.expose&&(K.expose=D(K.expose)),_=Number.random(268435456,4294967295).toString(16),C=I.id||"my"+_,T=lt.sdbmCode(C),K.id=C,R.form=dt,I.params&&I.params.depth&&(R.recalcDepth=I.params.depth);for(F in K)A(K[F])&&(K[F]=K[F].bind(K));I.error&&(P(K.error)?nt=function(e,t){return K.error.assign(B({message:e+"",err:t+""},K))}:A(I.error)&&(nt=function(e,t){S=null;try{S=I.error(e,t)}catch(r){S=R.messages.initFailed}return S})),B(dt.data("my"),{id:C,cid:_,mid:T,errors:Object.extended(),ui:Object.extended(M),disabled:!1,manifest:K,locFiles:[],modals:{},radio:{}}),dt.addClass("my-form"),L="my-manifest-"+T,H="my-form-"+_,dt.addClass(H+" "+L)}function h(t){function r(e,t){return'"}!K.style||t&&!dt.is(":visible")||(U=N(dt,K,L,H),U&&U[0].length&&!t&&(Q=e("style#"+L),Q.size()||(Q=e(r(U[0],L)).appendTo(e("body"))),Q.data("count",1*Q.data("count")+1),dt.data("my").style=Q),U&&U[1].length&&(V=e("style#"+H),V.size()?t&&(e(r(U[1],H)).replaceAll(V),V=e("style#"+H)):(V=e(r(U[1],H)).appendTo(e("body")),R.restyle>-1&&!J[_]&&(J[_]=function(){h(!0)}.debounce(R.restyle)),dt.data("my").restyle=h.fill(!0).debounce(0)),dt.data("my").localStyle=V,t||dt.addClass("my-restyle")))}function p(){var t,r,n=e.Deferred();if(r=o(K),P(r))j("Error decoding base64 to local Blob/URL",r),n.reject();else{if(E)for(t=0;t*").clone();try{X=x(K,I.init,dt,I)}catch(t){return j(P(t)?t:t.message,t.stack),dt}}if(it(X)?X.then(function(){g()},function(e,t){j(e,t)}):g(),!rt){if(!dt.my())return j("Internal error initializing controls.",""),dt;dt.data("my").initial=B(!0,{},G),e.mobile&&e.mobile.changePage(e.mobile.activePage)}}function g(){function e(e){rt||(t[e]=c(dt.find(e),W),r-=1,.5>r&&b(t))}var t={},r=Object.size(M);dt.addClass(ot),Object.each(M,function(t){if(!rt){var r=dt.find(t),n=v(r,dt,M[t],t);it(n)?n.then(e.fill(t)).fail(function(e,r){j("Error building "+t+", "+e,r)}):rt||e(t)}})}function b(e){var r,n,i;for(var a in M){if(rt)return;if(r=M[a],i=dt.find(a),i.size()){r.listen&&(et[a]=i.eq(0));try{n=d(G,W,r,i),n==W&&e[a]!=W&&void 0!==n&&d(G,e[a],r,i)}catch(o){t("Transient fail linking "+a+" of form $('.my-form-"+_+"')",o.message,o.stack)}try{n!=W&&c(i,n),i.eq(0).trigger("check.my")}catch(o){j("Error linking "+a,o.message,o.stack)}}}dt.removeClass(ot),dt.on("recalc.my, redraw.my",function(e){e.stopPropagation(),dt.my("redraw")}),ut=null,tt.resolve(G)}function j(e,r){var n;if(rt=!0,t("Form "+C+" failed to initialize.",e,r),dt.removeClass(ot),n=nt(e,r),P(n)||$(n)&&n.jquery?dt.html(n):n===!0&&dt.html(ut),R.silent)tt.resolve(G);else{if(!dt.my().ddata){if(dt.removeData("my"),dt.removeClass("my-form"),Q)if("1"==Q.data("count"))try{Q.remove()}catch(i){}else Q.data("count",Q.data("count")-1);if(V)try{delete J[_],V.remove()}catch(i){}}tt.reject("Form "+C+" failed to initialize: "+e,r)}}var k,O,C,_,T,S,M,R,I,F,U,L,H,Q,V,X,K={},G={},Z=[],et={},tt=e.Deferred(),rt=!1,nt=function(){},ot="my-form-init",ct="std",ut="";if(P(i)){if(k=at(i),!k)return tt.reject("No manifest with id "+i+" found in repo."),tt.promise();$(l)&&$(a)?(k=B(k,a),O=l):O=a,ct="repo"}else k=i,O=a;if(!k)return this;I=$(O)&&"repo"!=ct?B(!0,{},k):k;var dt=this.eq(0),ft=dt.my();return $(ft)&&ft.id&&ft.ui?(r("jQuery.my is already bound.",dt),dt.my("ui",I.ui),dt.my(Y,I.data),tt.resolve(dt.my(Y)).promise()):(R=I.params||{},R.strict||(R=B(!0,{},R),w(R)),R=B(!0,{},st.params,R),tt.fail(function(){dt.removeClass(H+" "+L)}),B(dt,tt.promise()),$(O)?(G=lt.patch(O,I.data||{}),I.data=G):G=I.data||{},K.data=G,dt.data("my",{data:G,params:R,promise:tt.promise(),locktill:0}),dt.addClass(ot),I.inherit&&u(I),lt.require(I,R).then(function(){m(),p().then(function(){h(),y()})}).fail(function(e){m(),j("Linker of ‘require’ property failed.",e)}),tt.then(f),dt)},redraw:function(e,t){var r=this,n=r.my();return n&&n.ui&&(n.ui.each(function(t){var i=r.find(t);p(i,e?W:void 0,n.params.recalcDepth),e||(i.is(".my-form")&&i.my("redraw"),i.trigger(i.is(".my-form-list")?"redraw":"check.my"))}),!t&&e&&r.trigger(rt)),r},data:function(e,t){var r=this;return $(e)&&(r.my().data=lt.overlap(r.my().data,e),this.my("redraw",t)),r.my().data},errors:function(){var t=e(this).my().errors,r={};for(var n in t)t[n]&&P(t[n])&&(r[n]=t[n]),$(t[n])&&L(t[n]).length&&(r[n]=t[n]);return r},valid:function(){var t=e(this).my().errors,r=0;for(var n in t)t[n]&&P(t[n])?r++:$(t[n])&&L(t[n]).length&&r++;return!r},reset:function(){try{lt.kickoff(this.my().data,this.my().initial),this.my("redraw")}catch(e){return!1}return!0},id:function(e,t){if(P(e))return at(e,t);var r=this.my();return r&&r.id?r.id:W},remove:function(e){var t,r,n,i,a,o,s,l,c=this;if(!this.my())return W;if(this.my().root&&!this.my().ddata&&(c=this.my().root),n=c.my(),a=n.data,s=n.cid,l=n.mid,c.unbind(".my"),$(n)&&n.manifest&&A(n.manifest.die))try{n.manifest.die.call(n.manifest,c,n.manifest)}catch(d){}if(t=n.style)if("1"==t.data("count"))try{t.remove()}catch(d){}else t.data("count",t.data("count")-1);if(r=n.localStyle)try{delete J[s],r.remove()}catch(d){}if(window.URL&&(i=n.locFiles)&&i.length)for(var f=0;fo?W:(n.params.errors&&n.params.errors.values().compact(!0).length?Object.equal(n.data,n.lastCorrect)||(o+=1):Object.equal(i[a.last()],n.data)&&(o+=1),t=y(o,n.params,!0),t&&(lt.kickoff(r.my().data,t),r.my("redraw")),r.my().data)},ui:function(e){var t,r=this,n=r.my(),i=[];if(!n)return W;B(!0,{},n.ui);if(!$(e))return n.ui;for(t in e)i.push(t);for(n.ui=q(lt.overlap(n.ui,e)),t=0;t1&&l(t[1])){for(var n,u,f,m,h,p,y,v,g=t[0],b="",x=1;x'+(g?"<"+r.labelTag+' class="'+r.labelCss+'" '+(r.label?'style="display:inline-block;width:'+r.label+";margin-left:-"+r.label+'" ':"")+">"+g+"":"")+b+""),e+b}return e}function r(e){var t=e;if(l(t)&&(t=t.split(/[\s,]/).compact(!0)),s(t)){for(var r={},n=0;n',inp:u+'text" {ext}/>',sli:u+'range" {ext}/>',dat:u+'date" {ext}/>',btn:u+'button" {ext}/>',pwd:u+'password" {ext}/>',but:"",div:"
{txt}
",spn:"{txt}",sel:"",mul:'',txt:"",err:' {txt}',msg:'
{txt}
',val:function(e){if(!s(e.vals))return"";var t=i({style:"",css:""},e);return t.txt=e.vals.reduce(function(e,t){return e+""+t+" "}," "),'{txt}'.assign(t)},"":"<{_tag} {ext}>{txt}"},txt:{sel:function(e){if(!e.vals)return"";var t=r(e.vals);return Object.keys(t).reduce(function(e,r){return e+'"},"")}},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"}},f={init:function(t,r){return e(this).html(n(t,r))}};e.my||(e.my={}),e.my.formgen=n,e.fn.formgen=function(t){return l(t)&&f[t]?f[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void e.error("Method "+t+" does not exist on jQuery.formgen"):f.init.apply(this,arguments)}}(jQuery),function(e){function t(t,r,n,i){var a,s,l,d,f,m,h;if("object"==typeof r&&r.jquery)r.is("img")&&(m=r,f=r.attr("alt")||r.attr("title")||r.data("text")||"",s=m[0].naturalWidth||m[0].width,a=m[0].naturalHeight||m[0].height,1>a&&(a=1),1>s&&(s=1),d=e(window).width()-90,l=e(window).height()-90,a>l&&(s=s*(l/a)|0,a=l),s>d&&(s=d,a=a*(d/s)|0),h=300>s?300:s,o(t,{source:"image",manifest:{init:function(e){e.html(this.HTML),e.on("click.my","img:eq(0)",function(){e.trigger("cancel")})},HTML:'

',ui:{"img:eq(0)":"img",h4:{bind:"text",css:{hide:function(e,t){return!t}}}}},data:{img:m.attr("src"),text:f},esc:!0,screen:!0,width:i||h,focus:!1,global:!0,z:"1995"},n));else if(u(r)&&r.manifest)o(t,r,n);else{if(!c(r))return null;o(t,{source:"html",manifest:{init:function(e){e.html(this.HTML)},HTML:r,ui:{"div:eq(0)":function(){}}},data:{},esc:!0,focus:!1,width:i},n)}return t}var r,n={},i="body",a=!1,o=e.extend,s={},l=(Object.isArray,Object.isBoolean),c=Object.isString,u=Object.isObject,d=Object.isNumber,f=(Object.isRegExp,Object.isFunction);e(document).keydown(function(e){var t,r,n=e.keyCode;if(!1!==a&&(13===n||27===n)){if(r=a.data("modal"),t=r.form,27==n&&(r.esc||Object.equal(t.data("my").initial,t.my("data"))))return a.modal(!0),!1;if(13==n&&r.enter)return function(e){e.modal()}.fill(a).delay(50),!1}}),n.modal=function(r,n,o){var s,c={},u=e(i),d=u.find(">.my-modal-proxy"),m={global:!0,screen:!0,done:f(n)?n:void 0,z:"1995"};return l(r)||null==r?d.modal(r):(s=e.Deferred(),t(c,r,m,o)?a?s.reject("Locked").promise():(d.size()||(d=e('
').prependTo(u),d.css({position:"absolute",top:"0",left:"0",margin:"0",padding:"0",width:"1px",height:"0"})),d.modal(c)):s.reject("Invalid data").promise())},n.modal.loading=function(t){e(i).find(">.my-modal").toggleClass("my-modal-loading",!!t)},n.modal.parent=function(t){return t&&e(t).size()?void(i=t):e(i)},n.modal.parentBack=function(t){return t&&e(t).size()?void(r=t):e(r||i)},n.modal.visible=function(){return!!a},e.my||(e.my={}),e.my.modal=n.modal,e.fn.modal=function(n,m,h){function p(){var t,r,n=window,i=!!E.global,a=w.offset(),o=D.offset(),s=w.scrollTop();E.pos={px:a.left,py:a.top,pw:w.outerWidth(),ph:w.outerHeight(),ox:o.left,oy:o.top,ow:D.outerWidth(),oh:D.outerHeight(),ww:r,wh:t};var l=1*(E.x.match(/\-?\d+(\.\d+)?/)||[0])[0],c=1*(E.y.match(/\-?\d+(\.\d+)?/)||[0])[0],u=E.x.has("left")?-1:E.x.has("right")?1:0,f=E.y.has("top")?-1:E.y.has("bottom")?1:0,m=E.pos.ox+E.pos.ow/2-E.pos.px,h=E.pos.oy+E.pos.oh/2-E.pos.py;if(i&&(E.pos.wh=t=n.innerHeight||e(n).height(),E.pos.ww=r=n.innerWidth||e(n).width(),m=r/2,h=t/2.5),l=E.x.has("%")?E.pos.ow/100*l:l,c=E.y.has("%")?E.pos.oh/100*c:c,E.pos.pix=m,E.pos.piy=h,m=m+u*(E.pos.ow/2)+l*(u>0?-1:1)-(E.width+N)*(u+1)/2,i?(h=(t-E.height-20)/3,10>h&&(h=10)):h=h+f*(E.pos.oh/2)+c*(f>0?-1:1)-(E.height||0)*(f+1)/2,m=m.round(1),h=(h+s).round(1),E.pos.vx=m,E.pos.vy=h,E.bound!==!1&&!E.global){var p=(d(E.bound)?E.bound:0).clamp(-100,100);E.pos.pw-2*pE.pos.pw-p?E.pos.vx=E.pos.pw-p-E.width-N:E.pos.vxE.pos.ph-p?E.pos.vy=E.pos.ph-p-E.height:E.pos.vy');var r="",n=e("style#my-modal-style-"+E.cid);("top"==E.nose||"bottom"==E.nose)&&(r+="div.my-modal-"+E.cid+".nose-"+E.nose+":before {left:"+(E.pos.ox-E.pos.px+E.pos.ow/2-E.pos.vx)+"px!important;}",n.text(r)),("left"==E.nose||"right"==E.nose)&&(r+="div.my-modal-"+E.cid+".nose-"+E.nose+":before {top:"+(E.pos.oy-E.pos.py+E.pos.oh/2-E.pos.vy)+"px!important;}",n.text(r))}E.screen?E.global?(j.css({top:0,left:0,width:2*E.pos.ww+"px",height:2*E.pos.wh+"px",display:"block",position:"fixed","z-index":E.z-1}),c(E.screen)&&j.css({background:E.screen?E.screen:"rgba(25, 39, 59, 0.88)"})):j.css({top:0,left:0,position:"absolute",width:E.pos.pw+"px",height:E.pos.ph+"px",display:"block",background:c(E.screen)?E.screen:"rgba(40,80,120,0.6)","z-index":E.z-1}):j.size()&&j.hide(),E.height>E.pos.wh?(b.height(E.pos.wh-30),x.css({"overflow-y":e.browser.webkit?"overlay":"scroll"})):x.css({"overflow-y":"none"}),b.animate({top:E.pos.vy+"px",opacity:"1"},E.animate)}function v(){try{x.my("remove")}catch(t){}try{w.data("modals")[E.cid]=null}catch(t){}x.parent().unbind(".my").remove(),j.off(".my"+E.cid),E.screen&&function(e){e&&a||j.hide(),e&&!a&&j.css({background:"rgba(25, 39, 59, 0.88)"})}.delay(50,E.global),E.global&&(a=!1,e("body").css({overflow:"auto"}))}function g(e){try{T(null,null)}catch(t){}(function(){q.reject(e)}).delay(0)}var b,x,w,j,k,O,C,q=e.Deferred(),z={},D=this,N=0,_=0,T=f(m)?m:function(){return!1},S=u(n)?n:{},E=D.data("modal");if(o(D,q.promise()),E){if(null==n||l(n)){if(x=E.form,j=E.bg,w=E.root,T=E.done,O=x.my("data"),C=!1,n){try{T(null,null)}catch(M){}if(v(),D.removeData("modal"),s[E.cid])try{s[E.cid].reject("Cancelled")}catch(M){}delete s[E.cid],E=null}else{try{C=T(x.my("valid")?null:x.my("errors"),O)}catch(M){}C||(v(),D.removeData("modal"),function(){s[E.cid]&&s[E.cid].resolve(O),delete s[E.cid],E=null}.delay(0))}return D}if(S)return g("Locked"),D}return D.is(":visible")?(S=t(z,n,{}))?S.global&&a?(g("Locked"),D):(E=o({type:"DOM",source:"manifest",form:null,modal:null,root:null,bgroot:null,caller:D,manifest:{},data:{},global:!1,screen:!1,drag:!1,focus:!0,close:!0,silent:!0,esc:!1,enter:!1,bound:!1,nose:"",width:h||300,height:null,x:"0",y:"0",z:"1901",background:"white",css:"",animate:200},S,{promise:q.promise(),cid:Number.random(268435456,4294967295).toString(16)}),E.done=f(E.done)?E.done:T,c(E.align)&&E.align&&(E.x=(E.align.match(/(left|right):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0],E.y=(E.align.match(/(top|bottom):\-?\d+(\.\d+)?(%|px)?/g)||["0"])[0]),E.width=1*(e.my.f.getref(c(E.manifest)?e.my.cache(E.manifest):E.manifest,"params.width")||E.width),E.type="DOM",D.hasClass("my-form")?(E.type="form",E.root=E.root||D):D.data("my")?(E.type="control",E.root=E.root||D.my().root):(E.root=E.root||D.parents(".my-form").eq(0),E.root.size()||(E.root=e(i))),E.global?(E.root=e(i),E.bgroot=e(r||i)):E.bgroot=E.root,w=E.root,w.data("modals")||w.data("modals",{}),p(),b=e('
').prependTo(E.root),b.addClass("my-modal-"+E.cid),N=b.outerWidth(),_=b.outerHeight(),b.hide(),b.html('
'),x=b.find(".my-modal-form"),E.close&&(k=e(c(E.close)?E.close:'
×
').prependTo(b).on("click.my",function(){D.modal(!0)}),k.css({"z-index":("+"===(E.z+"").to(1)?"+":"")+(1*E.z+1)})),j=E.bgroot.find(">.my-modal-screen"),E.screen&&(j.size()||(j=e('').prependTo(E.root)),E.esc&&j.on("click.my"+E.cid,function(){D.modal(!0)})),D.data("modal",E),E.silent&&b.on("change.my",function(){return!1}),b.css({display:"block",height:"none",opacity:"0.005","z-index":E.z,width:"auto"}),b.css(E.global?{position:"fixed",left:"50%",top:E.pos.vy+"px",display:"block",height:"none",opacity:"0.005","z-index":E.z,width:"auto","margin-left":"-"+((E.width+N)/2).round(0)+"px"}:{position:"absolute",left:E.pos.vx+"px",top:E.pos.vy+"px",display:"block",height:"none",opacity:"0.005","z-index":E.z,width:"auto"}),x.my(E.manifest,E.data).then(function(){var t,r,n,i,l;if(o(E,{form:x,bg:j,cancel:function(){D.modal(!0)},commit:function(){D.modal()}}),b.data("modal",E),E.height=b.outerHeight(),"manifest"!==E.source&&(E.width=b.width()),p(),b.css({top:E.pos.vy+"px"}),y(!0),w.data("modals")[E.cid]=E,s[E.cid]=q,x.bind("commit.my",function(){return E.commit.delay(50),!1}).bind("cancel.my",function(){return E.cancel.delay(50),!1}),b.bind("layout.my",function(){y()}.debounce(50)),E.global&&(a=D,e("body").css({overflow:"hidden"})),E.global||!E.esc&&!E.enter||x.bind("keydown.my",function(t){var r=t.keyCode;return 27==r&&E.esc?(E.cancel(),!1):13==r&&E.enter&&!e(t.target).is("textarea")?(E.commit.delay(50),!1):void 0}),E.focus===!0){i=!1,l=E.manifest.ui;for(n in l)i||(r=x.find(n),r.size()&&r.is("input, textarea","button")&&(i=!0,r.focus()))}else c(E.focus)&&x.find(E.focus).focus();if(t=x.find("img").filter(function(){return""!=e(this).attr("src")}),t.size()){var u=function(){"manifest"!==E.source&&b.css({width:"auto"}),y()}.after(t.size());t.each(function(){e(this).bind("load",u)})}E.drag&&e.fn.draggable&&(c(E.drag)?b.draggable({handle:E.drag}):b.draggable(),E.nose&&b.on("dragstart.my",function(){b.removeClass("nose-"+E.nose)})),q.notify("Ready")}).fail(function(e){v(),D.data("modal",null),q.reject(e)}),D):(g("Invalid data"),D):(g("Object must be visible"),D)}}(jQuery); \ No newline at end of file diff --git a/my.jquery.json b/my.jquery.json index 456fa5a..95f48cf 100644 --- a/my.jquery.json +++ b/my.jquery.json @@ -5,7 +5,7 @@ "keywords": [ "MVVM", "framework", "ui", "form", "validation", "data binding" ], - "version": "1.1.8", + "version": "1.1.9", "author": { "name": "ermouth", "url": "https://github.com/ermouth" diff --git a/package.json b/package.json index 8c275d4..d339d8b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquerymy", - "version": "1.1.8", + "version": "1.1.9", "description": "A lightweight jQuery plugin for complex two-way data binding in real time.", "homepage": "http://jquerymy.com/", "author": "ermouth ",