diff --git a/README.md b/README.md index 4008d9f..bf8829e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Forms are promises – any `.init` function can return promise instead of `undef jQuery.my also incorporates simple template engine and modal dialog mechanics, which also behaves as promise. -See [jquerymy.com](http://jquerymy.com/) for more detailed API, examples and list of compatible controls. +Below API description is not complete, see [jquerymy.com](http://jquerymy.com/) for more detailed API, examples and list of compatible controls. See [cloudwall.me](http://cloudwall.me) as an example of web-app platform built on top of $.my. diff --git a/Release/1.1/jquerymy-1.1.6.js b/Release/1.1/jquerymy-1.1.6.js new file mode 100644 index 0000000..bb716d2 --- /dev/null +++ b/Release/1.1/jquerymy-1.1.6.js @@ -0,0 +1,4063 @@ +/* + * jQuery.my 1.1.6 + * Requires jQuery 1.11.0+, SugarJS 1.3.9-1.4.x + * + * — fixed a bug caused forever-pending init if a member of .files section is zero length base64 + * — fixed memoization of screen shield color for global modal, when global is tied to $control + * — fixed inability to close modal when $root no more exist + * + * More details at jquerymy.com + * + * (c) @ermouth, thanks @carpogoryanin, @ftescht + * 2015-06-16 + */ + +;(function ($) {var _version = "jQuery.my 1.1.6"; + + // Some shortcuts and constants + var lang = "en", + wURL = window.URL || window.webkitURL, + ie8 = !document.addEventListener, + 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\./, + + isA = Object.isArray, + isB = Object.isBoolean, + isS = Object.isString, + isO = Object.isObject, + isN = Object.isNumber, + isR = Object.isRegExp, + isF = Object.isFunction, + Keys = Object.keys, + isP = function (a) {/*is 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" + return (ref||"").split(".").reduce(function (a,b){ + if (null!=a && null!=a[b]) return a[b]; + else 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; + + + //path = id.split("."); + + 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) && 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,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= []; $c.each(function () { + var $x = $(this), xd = $x.data("my"); + if (xd) old.push(xd.data); + }); + + //fast compare + eq=false; + if (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); + 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
', + * + * // 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}/>', + "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%", 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")) { + 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}); + } + + 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(); + + 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.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.5)', + "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(30,65,100,0.8)' + }); + } + } + 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(30,65,100,0.8)'}); + } + }).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.6.min.js b/Release/1.1/jquerymy-1.1.6.min.js new file mode 100644 index 0000000..54813d8 --- /dev/null +++ b/Release/1.1/jquerymy-1.1.6.min.js @@ -0,0 +1,6 @@ +/* jQuery.my 1.1.6 + * 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||"").split(".").reduce(function(e,t){return null!=e&&null!=e[t]?e[t]:void 0},e)}function a(e,t){var r,i;if(Z(t))return t;if(Y(t)){if(r=n(e,t),null==r&&(r=Object.clone(R._src[t],!0)),null==r&&(r=n(R,t),Z(r)&&Z(r._self)?r=Object.clone(r._self,!0):Z(r)&&(r=Object.clone(r,!0))),null==r&&n(e,"params.cache")&&(i=n(e,"params.cache"),rt(i)?r=i(t):Z(i)&&(r=at(t,i)),Z(r)&&(Z(r._self)&&(r=Object.clone(r._self,!0)),Object.merge(r,{params:{cache:i}},!0))),null!=r&&Z(r))return i=i||n(e,"params.cache"),i&&Object.merge(r,{params:{cache:i}},!0),r;throw"Component "+t+" not found."}return rt(t)?t.apply(e,Array.prototype.slice.call(arguments,2)):null}function o(r,i){var a,o,l,c,u,d=i||R,f=r;if(!(Z(d)&&Z(f)&&Z(f.ui)&&Y(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),Y(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)),o=Object.keys(d._src).filter(function(e){return e.startsWith(l+".")}),o.sort(),o.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),E?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(Z(e.files)&&Object.size(e.files))for(t in e.files){if(r=e.files[t],!Z(r)||!Y(r.data)||r.url)return"Non-object member "+t+" in files section.";if(M)try{lt.base642blob(r.data,function(e){r.blob=e,r.url=M.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){Z(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&&rt(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 Y(t)?/[\/]/.test(t)?(n=I(!0,{},k,{ref:r,ajax:{url:t}}),K.test(r)&&(n.ajax.dataType="json")):t.length&&(n=I(!0,{},k,{ref:r,ajax:t})):Z(t)&&(n=I(!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=nt(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=Y(i.ajax)?j.loader:ot,o(i.ajax).then(function(e,r){K.test(r.ref)&&(null!=e?I(!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 K.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=I(!0,{ajaxTimeout:1e4,loader:st.params.loader},r||{}),k={ref:null,ajax:{type:"GET",async:!0,timeout:j.ajaxTimeout}};if(Z(t))if(X(t.require)){for(m=t.require,u=0;ui)return n=l,void(i=o);c==H&&r(e,l,o+1)}U!=t[""]&&typeof t[""]!=H&&o>i&&(n=t[""],i=o)}var n=U,i=0,a="";return r(e,t,1),n}function f(e,t,r,n){var i,a,o,s=[],l=r.bind,c=P(l);if(c==W)return l.call(h(n).manifest,e,t,n);if(c===Q||c===B){if(c===Q&&!/\./.test(l))return t!=U?e[l]=t:void 0===e[l]&&(e[l]=U),e[l];for(c===Q&&(s=l.split(".").each(function(e,t){this[t]=e+""})),c===B&&(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,st.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!=U){if(l=F(r)?r:u(g,f(a,U,o,g)),U!=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{U!=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==U?l:r;if(o.css)for(c in o.css)d=o.css[c],tt(d)?p(d.test(_),g,c):rt(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(V),m.history[o.last()]}if(!isNaN(e)||e===U){if(l=parseInt(e)||0,0>l)return U;if(o=nt(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(O.list)?s=O.list:c=O.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:v,delay:(O.delay||k.delay||10)/1.3,template:s,selector:c,parent:z,bind:O.bind,hash:rt(O.hash)?O.hash.bind(z):f(O.hash),id:rt(O.id)?O.id.bind(z):f(O.id),ext:!(!O.id&&!O.hash),stamp:0},i.on("insert.my",function(t,r){t.stopPropagation();var n={what:void 0,where:0};null==r?n.where=1e6:Z(r)?Object.merge(n,r):(Y(r)||et(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(z,v),Z(o)?o:void 0)}catch(h){u("$.my subform init of "+l+" failed: "+h.message,h.stack)}}it(t)?t.then(m,function(e,t){u("Init of subform "+l+" failed with error: "+e,t)}):m()}function u(e,r){t(e,r),C&&C.reject(e,r)}function f(e){var t=P(e).to(3);return e?"str"===t?n.fill(void 0,e):"arr"===t?lt.mask.fill(void 0,e):null:null}function m(){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=O.events||d(n,st.events),n.is(".my-form")?I(n.data("my"),{dui:O,root:o,selector:l,dparams:k,devents:t,ddata:j.data,container:k.container(n),derrors:j.errors}):(n.data("my",{events:t,selector:l,initial:p,previous:p,root:o,container:k.container(n),id:j.id,ui:O,data:j.data,params:k,errors:j.errors}),s._update=O.delay?y.debounce(O.delay):U,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"),I(n.data("my"),{container:k.container(n)});var f,m=function(e){n.val(e).trigger(V)},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 v=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(v.html())}),e("body").on("click","div.cleditorPopup",function(){m(v.html())})}}else if(n.is("div.redactor_box textarea")){var w,C="my-redactor-9";try{w=n.getEditor(),C="my-redactor-8"}catch(q){w=n.redactor("getEditor")}w&&(n.addClass(C),w.bind("input.my keyup.my blur.my",function(e){e.trigger("redactor")}.fill(n)))}else n.is(".ace_editor")?ace.edit(i[0]).on(V,function(e){e.trigger("ace")}.fill(n)):r&&r.on(V,function(e){e.trigger("codemirror")}.fill(n));n.my()._changed=b.debounce(g),n.my()._recalc=x.debounce(g),n.bind(t,function(e){e.type==V&&e.stopPropagation(),a&&(j.locktill=Date.now()+s.delay),n.my()._changed(n,o,s,k)}),/check(\.my)?/.test(t+"")||n.on("check.my",function(){return n.my()._changed(n,o,s,k,!0),!1}),n.on("recalc.my, redraw.my",function(e){e.stopPropagation(),n.my()._recalc(n,o,s,k)})}),C&&C.resolve()}var h,p,v,g,j=o.my(),k=(j||{}).params,O=s,C=null,q=0,z=j.manifest;return j?(g=s.delay,i.size()?(O.init!=U&&(h=w(z,O.init,i,j)),it(h)?(q+=1,C=e.Deferred(),h.then(c,function(e,t){u("Init of "+l+" failed: "+e,t)})):c()):r("Not found "+l+" selector.",o),C):(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?U:u(s,U),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):U,r.recalcDepth||i.recalcDepth)}}function w(e,t,r,i){var a;if(Y(t)){if(a=n(e,t),void 0===a)return r.html(t.assign(i.data)),null}else a=t;if(rt(a))return a.apply(e,Array.prototype.slice.call(arguments,2));if(X(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="";(n||!/^(data|files|require)$/.test(e))&&(i=r[e],s=P(i),/^(ob|ar)/.test(s)?j(i):"string"===s&&/^(function\s*\(|new\sRegExp)/.test(i)&&((a=i.match(/^function\s*\(([^\)]*)\)\s*\{([\s\S]*)\}[\s\n\r\t]*$/))&&3===a.length?(o=O(a[1],a[2]),"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 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){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=Z(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&&(Y(a.recalc)?c=a.recalc.split(d):X(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(Y(a.watch)?u=a.watch.split(d):X(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+"}"))),X(f)&&f.length)for(l=0;le?"0"+e:e}function t(e,i,a){var o,s,l,c,u=0,d=i||0,f=r;switch(a&&Y(a)&&(u=String(a).length,f=String(a).repeat(10)),(typeof e).substr(0,3)){case"str":return n(e);case"num":return isFinite(e)?""+String(e):"null";case"boo":case"nul":return String(e);case"fun":return n(e.toString().replace(/^(function)([^\(]*)(\([^\)]*)([\n\t][^)]*)(\).*)/,"$1 $3$5").replace(/(})([^}]*$)/,"$1"));case"obj":if(!e)return"null";if(typeof e.toJSON===W)return t(e.toJSON(),d+(a?1:0),a);if(o=[],X(e)){for(s=0;sl;l++)s[l]=i.charCodeAt(l);return n=new Blob([s],{type:r||"application/octet-stream"}),rt(t)?void t(n):n},base64:function(t,r,n){var i=(P(t),null),a=Y(t)?t:e.my.tojson(t),o=Y(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 S,T="jQuery.my 1.1.6",M=window.URL||window.webkitURL,E=!document.addEventListener,R=n(e,"my.f.repo")?e.my.f.repo():{_src:{},_name:"Default manifest cache"},$=n(e,"my.f.restyles")?e.my.f.restyles():{},I=e.extend,P=e.type,U=null,F=function(e){return null!==e&&void 0!==e},L="{yyyy}-{MM}-{dd}",A="{HH}:{mm}",H="object",J="data",B="array",Q="string",W="function",V="change",K=/^this\./,X=Object.isArray,G=Object.isBoolean,Y=Object.isString,Z=Object.isObject,et=Object.isNumber,tt=Object.isRegExp,rt=Object.isFunction,nt=Object.keys,it=function(e){return!!(null!=e&&(Z(e)||e.jquery)&&rt(e.then)&&rt(e.fail)&&rt(e.state))},at=function(e,t){var r,i;return Y(e)?(r=e,i=n(Z(t)?t:R,r),"exist"===t?Z(i):i?Object.clone(i,!0):null):Z(e)?(i=o(e,t),Z(i)?i:null):void 0===e?R._src:null===e?Object.reject(R,/^_/):null},ot=e.ajax,st={vals:{".my-form":function(e,t){if(e&&e.my){var r=e.my(J);return Object.equal(r,t)?r:e.my(J,t,!0)}return t||U},".hasDatepicker":function(e,t){F(t)&&e.datepicker("setDate",""==t?t:Date.create(t));var r=e.datepicker("getDate");return r?r.format(L):""},".my-tags":function(e,t){return F(t)&&(Y(t)||et(t)?e.tags(J,[t+""]):X(t)&&e.tags(J,t)),e.tags(J)},".ui-draggable":function(e,t){if(F(t)&&Z(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||lt.sdbmCode,x=p.id||lt.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(F(r)&&X(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(F(r)&&X(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==U&&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(F(t))return r=""!=t?Date.create(t).format(L):"",Y(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(L):""},"input[type=time]":function(e,t){if(F(t))return r=""!=t?Date.create(t).format(A):"",Y(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(A):""},input:{"[type='text'],[type='number'],[type='search'],[type='hidden'],[type='password'],[type='button'],[type='range'],:not([type])":{".ui-slider-input":function(e,t){F(t)&&e.val(t).slider("refresh")},".tagstrip input.value":function(e,t){F(t)&&e.val(t).trigger("update")},"div.select2-container+input":function(e,t){return F(t)&&JSON.stringify(t)!==JSON.stringify(e.select2("val"))&&e.select2("val",X(t)?t:[t]),e.select2("val")},"":function(e,t){F(t)&&e.val(t+"")}},":radio":function(t,r){var n=-1;if(F(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:S},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 d(e,st.containers)(e)},change:U,recalcDepth:2,delay:0,strict:!1,restyle:-1,locale:S=(navigator.language||navigator.userLanguage||"en").substr(0,2),messages:Object.map(st.msg,function(e,t){return t[S]||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=N(),ct={init:function(i,a,o){function c(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)||Y(l[t])?I(!0,P,lt.unmask(s,Y(l[t])?l[t]:t)):e[t]=s))}function d(){var e,r;for(var e in G)for(r in E[e].listen)G[e].addClass("my-listen-"+lt.sdbmCode(r));V.radio&&dt.on("radio.my",function(e,r){var n,i;if(Z(r)&&r.channel&&r.message&&rt(V.radio[r.channel])){n=V.radio[r.channel];try{i=n.call(V,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(P,!0),V=I(!0,V,Object.reject(P,["data"])),E=q(I(!0,{},P.ui||{}),V,R),V.radio&&(V.radio=z(V.radio)),V.expose&&(V.expose=D(V.expose)),N=Number.random(268435456,4294967295).toString(16),C=P.id||"my"+N,S=lt.sdbmCode(C),V.id=C,R.form=dt,P.params&&P.params.depth&&(R.recalcDepth=P.params.depth);for(F in V)rt(V[F])&&(V[F]=V[F].bind(V));P.error&&(Y(P.error)?nt=function(e,t){return P.error.assign(I({message:e+"",err:t+""},P))}:rt(P.error)&&(nt=function(e,t){T=null;try{T=P.error(e,t)}catch(r){T=R.messages.initFailed}return T})),I(dt.data("my"),{id:C,cid:N,mid:S,errors:Object.extended(),ui:Object.extended(E),disabled:!1,manifest:V,locFiles:[],modals:{},radio:{}}),dt.addClass("my-form"),A="my-manifest-"+S,H="my-form-"+N,dt.addClass(H+" "+A)}function h(t){function r(e,t){return'"}V.style&&(L=_(dt,V,A,H),L&&L[0].length&&!t&&(B=e("style#"+A),B.size()||(B=e(r(L[0],A)).appendTo(e("body"))),B.data("count",1*B.data("count")+1),dt.data("my").style=B),L&&L[1].length&&(Q=e("style#"+H),Q.size()?t&&(e(r(L[1],H)).replaceAll(Q),Q=e("style#"+H)):(Q=e(r(L[1],H)).appendTo(e("body")),R.restyle>-1&&!$[N]&&($[N]=function(){h(!0)}.debounce(R.restyle)),dt.data("my").restyle=h.fill(!0).debounce(0)),dt.data("my").localStyle=Q))}function p(){var t,r,n=e.Deferred();if(r=s(V),Y(r))x("Error decoding base64 to local Blob/URL",r),n.reject();else{if(M)for(t=0;t*").clone();try{W=w(V,P.init,dt,P)}catch(t){return x(Y(t)?t:t.message,t.stack),dt}}if(it(W)?W.then(function(){v()},function(e,t){x(e,t)}):v(),!tt){if(!dt.my())return x("Internal error initializing controls",""),dt;dt.data("my").initial=I(!0,{},K),e.mobile&&e.mobile.changePage(e.mobile.activePage)}}function v(){function e(e){tt||(t[e]=u(dt.find(e),U),r-=1,.5>r&&b(t))}var t={},r=Object.size(E);dt.addClass(ot),Object.each(E,function(t){if(!tt){var r=dt.find(t),n=g(r,dt,E[t],t);it(n)?n.then(e.fill(t)).fail(function(e,r){x("Error building "+t+", "+e,r)}):tt||e(t)}})}function b(e){var r,n,i;for(var a in E){if(tt)return;if(r=E[a],i=dt.find(a),i.size()){r.listen&&(G[a]=i.eq(0));try{n=f(K,U,r,i),n==U&&e[a]!=U&&void 0!==n&&f(K,e[a],r,i)}catch(o){t("Transient fail linking "+a+" of form $('.my-form-"+N+"')",o.message,o.stack)}try{n!=U&&u(i,n),i.eq(0).trigger("check.my")}catch(o){x("Error linking "+a,o.message,o.stack)}}}dt.removeClass(ot),ut=null,et.resolve(K)}function x(e,r){var n;if(tt=!0,t("Form "+C+" failed to initialize",e,r),dt.removeClass(ot),n=nt(e,r),Y(n)||Z(n)&&n.jquery?dt.html(n):n===!0&&dt.html(ut),R.silent)et.resolve(K);else{if(!dt.my().ddata){if(dt.removeData("my"),dt.removeClass("my-form"),B)if("1"==B.data("count"))try{B.remove()}catch(i){}else B.data("count",B.data("count")-1);if(Q)try{delete $[N],Q.remove()}catch(i){}}et.reject("Form "+C+" failed to initialize: "+e,r)}}var k,O,C,N,S,T,E,R,P,F,L,A,H,B,Q,W,V={},K={},X=[],G={},et=e.Deferred(),tt=!1,nt=function(){},ot="my-form-init",ct="std",ut="";if(Y(i)){if(k=at(i),!k)return et.reject("No manifest with id "+i+" found in repo."),et.promise();Z(o)&&Z(a)?(k=I(k,a),O=o):O=a,ct="repo"}else k=i,O=a;if(!k)return this;P=Z(O)&&"repo"!=ct?I(!0,{},k):k;var dt=this.eq(0),ft=dt.my();return Z(ft)&&ft.id&&ft.ui?(r("jQuery.my is already bind.",dt),dt.my("ui",P.ui),dt.my(J,P.data),et.resolve(dt.my(J)).promise()):(R=P.params||{},R.strict||(R=I(!0,{},R),j(R)),R=I(!0,{},st.params,R),et.fail(function(){dt.removeClass(H+" "+A)}),I(dt,et.promise()),Z(O)?(K=lt.patch(O,P.data||{}),P.data=K):K=P.data||{},V.data=K,dt.data("my",{data:K,params:R,promise:et.promise(),locktill:0}),dt.addClass(ot),P.inherit&&c(P),lt.require(P,R).then(function(){m(),p().then(function(){h(),y()})}).fail(function(e){m(),x("Linker of ‘require’ property failed.",e)}),et.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?U: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(V)),r},data:function(e,t){var r=this;return Z(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]&&Y(t[n])&&(r[n]=t[n]),Z(t[n])&&nt(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]&&Y(t[n])?r++:Z(t[n])&&nt(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(Y(e))return at(e,t);var r=this.my();return r&&r.id?r.id:U},remove:function(e){var t,r,n,i,a,o,s,l,c=this;if(!this.my())return U;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"),Z(n)&&n.manifest&&rt(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 $[s],r.remove()}catch(u){}if(window.URL&&(i=n.locFiles)&&i.length)for(var f=0;fo?U:(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&&(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 U;I(!0,{},n.ui);if(!Z(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}/>',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%",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(30,65,100,0.8)"})):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.5)","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(30,65,100,0.8)"})}.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")&&(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()),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); diff --git a/Release/jquery.my.last.js b/Release/jquery.my.last.js index 4a045e8..54813d8 100644 --- a/Release/jquery.my.last.js +++ b/Release/jquery.my.last.js @@ -1,6 +1,6 @@ -/* jQuery.my 1.1.4 +/* jQuery.my 1.1.6 * Requires jQuery 1.11.0+, SugarJS 1.3.9-1.4.x * More details at jquerymy.com */ -!function(e){function t(){console.error.apply(console,arguments)}function r(e,t){return(t||"").split(".").reduce(function(e,t){return null!=e&&null!=e[t]?e[t]:void 0},e)}function n(e,t){var n,i;if(Y(t))return t;if(X(t)){if(n=r(e,t),null==n&&(n=Object.clone(E._src[t],!0)),null==n&&(n=r(E,t),Y(n)&&Y(n._self)?n=Object.clone(n._self,!0):Y(n)&&(n=Object.clone(n,!0))),null==n&&r(e,"params.cache")&&(i=r(e,"params.cache"),tt(i)?n=i(t):Y(i)&&(n=it(t,i)),Y(n)&&(Y(n._self)&&(n=Object.clone(n._self,!0)),Object.merge(n,{params:{cache:i}},!0))),null!=n&&Y(n))return i=i||r(e,"params.cache"),i&&Object.merge(n,{params:{cache:i}},!0),n;throw"Component "+t+" not found"}return tt(t)?t.apply(e,Array.prototype.slice.call(arguments,2)):null}function a(n,i){var a,s,l,c,u,d=i||E,f=n;if(!(Y(d)&&Y(f)&&Y(f.ui)&&X(f.id)))return"Invalid arguments.";d.hasOwnProperty("_src")||(d._src={}),l=f.id;try{f=Object.clone(n,!0)}catch(m){return"Can’t mount circular-referencing obj."}try{(!f.params||f.params&&!f.params.strict)&&w(f,!0)}catch(m){return"Invalid manifest, parse error."}if(a=o(f),X(a))return t(a),a;if(Object.merge(f,{params:{strict:!0}},!0),d._src[l]=f,c=st.mask(d,l)){if(c.params&&c.params.protect)return"Can’t mount on protected.";c._self&&delete c._self,e.extend(!0,d,st.unmask("",l))}return e.extend(!0,d,st.unmask(f,l)),s=Object.keys(d._src).filter(function(e){return e.startsWith(l+".")}),s.sort(),s.forEach(function(t){var r;(r=st.mask(d,t))&&(r._self&&delete r._self,e.extend(!0,d,st.unmask("",t))),e.extend(!0,d,st.unmask(d._src[t],t))}),u=r(d,l),M?u._self=d._src[l]:Object.defineProperty(u,"_self",{get:function(){return d._src[l]},set:function(){throw"Can not change repo."},enumerable:!1,configurable:!0}),u}function o(e){var t,r,n=[];if(Y(e.files)&&Object.size(e.files))for(t in e.files)if(r=e.files[t],Y(r)&&r.data&&!r.url)if(T)try{st.base642blob(r.data,function(e){r.blob=e,r.url=T.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){Y(n)&&n.channel&&n.message&&r.find(".my-listen-"+st.sdbmCode(n.channel)).each(function(){var r,i=e(this),a=i.data("my"),o=void 0;if(a&&a.ui.listen&&tt(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,n){function i(t,r){var n;return X(t)?/[\/]/.test(t)?(n=R(!0,{},k,{ref:r,ajax:{url:t}}),V.test(r)&&(n.ajax.dataType="json")):t.length&&(n=R(!0,{},k,{ref:r,ajax:t})):Y(t)&&(n=R(!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=rt(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=X(i.ajax)?j.loader:at,o(i.ajax).then(function(e,r){V.test(r.ref)&&(null!=e?R(!0,t,st.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 n=!1;return V.test(e)?null!=r(t,e.from(5))&&(n=!0):null!=r(window,e)&&(n=!0),n}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=R(!0,{ajaxTimeout:1e4,loader:ot.params.loader},n||{}),k={ref:null,ajax:{type:"GET",async:!0,timeout:j.ajaxTimeout}};if(Y(t))if(G(t.require)){for(m=t.require,u=0;ui)return n=l,void(i=o);c==A&&r(e,l,o+1)}P!=t[""]&&typeof t[""]!=A&&o>i&&(n=t[""],i=o)}var n=P,i=0,a="";return r(e,t,1),n}function d(e,t,r,n){var i,a,o,s=[],l=r.bind,c=$(l);if(c==Q)return l.call(m(n).manifest,e,t,n);if(c===B||c===J){if(c===B&&!/\./.test(l))return t!=P?e[l]=t:void 0===e[l]&&(e[l]=P),e[l];for(c===B&&(s=l.split(".").each(function(e,t){this[t]=e+""})),c===J&&(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,ot.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=!1,w=!1,j=e,k=j.my(),O="";if(k){if(y=k.selector,v=k.root,v.hasClass("my-form-init"))return{};if(g=v.find(y),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!=P){if(l=U(r)?r:c(g,d(a,P,o,g)),P!=o.check){O="Unknown error";try{O=f(a,l,o,g)}catch(C){t("Error "+C.message+" in .check validatir for "+y,v,C.stack)}}var q=s.errorCss,z="ui-state-error";try{P!=r&&(l=c(g,d(a,r,o,g)))}catch(C){O=s.messages.formError||"Error"}if(""===O)x?k.derrors[y]="":k.errors[y]="",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[y]=O;else if(w)k.errors[y]=O;else{i.addClass(q),k.errors[y]=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==P?l:r;if(o.css)for(u in o.css)m=o.css[u],et(m)?h(m.test(_),g,u):tt(m)&&h(m.call(v.my().manifest,a,_,g),g,u);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(W),m.history[o.last()]}if(!isNaN(e)||e===P){if(l=parseInt(e)||0,0>l)return P;if(o=rt(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(k.list)?l=k.list:u=k.list||u,!l){var m=i.find(u);l="
",m.size()&&(l=e(l).append(m.eq(0).clone(!0)).html(),m.eq(0).remove())}i.data("formlist")||i.data("formlist",{}),i.data("formlist").generator={manifest:y,delay:(k.delay||j.delay||10)/1.3,template:l,selector:u,parent:q,bind:k.bind,hash:tt(k.hash)?k.hash.bind(q):d(k.hash),id:tt(k.id)?k.id.bind(q):d(k.id),ext:!(!k.id&&!k.hash),stamp:0},i.on("insert.my",function(t,r){t.stopPropagation();var n={what:void 0,where:0};null==r?n.where=1e6:Y(r)?Object.merge(n,r):(X(r)||Z(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(n(q,y),Y(o)?o:void 0)}catch(h){c("$.my subform init of "+s+" failed: "+h.message,h.stack)}}nt(t)?t.then(f,function(e,t){c("Init of subform "+s+" failed with error: "+e,t)}):f()}function c(e,r){t(e,r),O&&O.reject(e,r)}function d(e){var t=$(e).to(3);return e?"str"===t?r.fill(void 0,e):"arr"===t?st.mask.fill(void 0,e):null:null}function f(){i.each(function(){var t,r,n=e(this),l=!1,c=n[0].nextSibling;if(r=c&&c.CodeMirror?c.CodeMirror:null,r&&n.addClass("my-codemirror"),t=k.events||u(n,ot.events),n.is(".my-form")?R(n.data("my"),{dui:k,root:a,selector:s,dparams:j,devents:t,ddata:w.data,container:j.container(n),derrors:w.errors}):(n.data("my",{events:t,selector:s,initial:h,previous:h,root:a,container:j.container(n),id:w.id,ui:k,data:w.data,params:j,errors:w.errors}),o._update=k.delay?p.debounce(k.delay):P,l=!0),l)if(n.cleditor&&n.parent().is(".cleditorMain")){var d=n.cleditor()[0];if(d&&d.$frame&&d.$frame[0]){n.addClass("my-cleditor"),R(n.data("my"),{container:j.container(n)});var f,m=function(e){n.val(e).trigger(W)},y=Number.random(1e5,1e6-1);e(d.$frame[0]).attr("id","cleditCool"+y),f=document.frames?document.frames["cleditCool"+y].document:e("#cleditCool"+y)[0].contentWindow.document;var x=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(x.html())}),e("body").on("click","div.cleditorPopup",function(){m(x.html())})}}else if(n.is("div.redactor_box textarea")){var O,C="my-redactor-9";try{O=n.getEditor(),C="my-redactor-8"}catch(q){O=n.redactor("getEditor")}O&&(n.addClass(C),O.bind("input.my keyup.my blur.my",function(e){e.trigger("redactor")}.fill(n)))}else n.is(".ace_editor")?ace.edit(i[0]).on(W,function(e){e.trigger("ace")}.fill(n)):r&&r.on(W,function(e){e.trigger("codemirror")}.fill(n));n.my()._changed=g.debounce(v),n.my()._recalc=b.debounce(v),n.bind(t,function(e){e.type==W&&e.stopPropagation(),l&&(w.locktill=Date.now()+o.delay),n.my()._changed(n,a,o,j)}),/check(\.my)?/.test(t+"")||n.on("check.my",function(){return n.my()._changed(n,a,o,j,!0),!1}),n.on("recalc.my, redraw.my",function(e){e.stopPropagation(),n.my()._recalc(n,a,o,j)})}),O&&O.resolve()}var m,h,y,v,w=a.my(),j=(w||{}).params,k=o,O=null,C=0,q=w.manifest;return w?(v=o.delay,i.size()?(k.init!=P&&(m=x(q,k.init,i,w)),nt(m)?(C+=1,O=e.Deferred(),m.then(l,function(e,t){c("Init of "+s+" failed: "+e,t)})):l()):st.con("Not found "+s+" selector.",a),O):(t("Failed to find $root building "+s+" 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?P:c(s,P),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,n,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")?r(o.my().data,o.data("formlist").generator.bind):P,n.recalcDepth||i.recalcDepth)}}function x(e,t,n,i){var a;if(X(t)){if(a=r(e,t),void 0===a)return n.html(t.assign(i.data)),null}else a=t;if(tt(a))return a.apply(e,Array.prototype.slice.call(arguments,2));if(G(a))try{n.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="";(n||!/^(data|files|require)$/.test(e))&&(i=r[e],s=$(i),/^(ob|ar)/.test(s)?w(i):"string"===s&&/^(function\s*\(|new\sRegExp)/.test(i)&&((a=i.match(/^function\s*\(([^\)]*)\)\s*\{([\s\S]*)\}[\s\n\r\t]*$/))&&3===a.length?(o=k(a[1],a[2]),"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=O(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){var r;try{r=new RegExp(e,t)}catch(n){r={message:n.message,stack:n.stack}}return r}function C(e,t,n){var i=Y(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&&(X(a.recalc)?c=a.recalc.split(d):G(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=q(a.listen),a.listen=Object.size(f)?f:void 0),a.watch)for(X(a.watch)?u=a.watch.split(d):G(a.watch)&&(u=a.watch.slice(0)),u=u.compact(!0).unique(),l=0;l2?f=st.css2json(f):o.push(a+(/\{/.test(f)?f:"{"+f+"}"))),G(f)&&f.length)for(l=0;le?"0"+e:e}function t(e,i,a){var o,s,l,c,u=0,d=i||0,f=r;switch(a&&X(a)&&(u=String(a).length,f=String(a).repeat(10)),(typeof e).substr(0,3)){case"str":return n(e);case"num":return isFinite(e)?""+String(e):"null";case"boo":case"nul":return String(e);case"fun":return n(e.toString().replace(/^(function)([^\(]*)(\([^\)]*)([\n\t][^)]*)(\).*)/,"$1 $3$5").replace(/(})([^}]*$)/,"$1"));case"obj":if(!e)return"null";if(typeof e.toJSON===Q)return t(e.toJSON(),d+(a?1:0),a);if(o=[],G(e)){for(s=0;sl;l++)s[l]=i.charCodeAt(l);return n=new Blob([s],{type:r||"application/octet-stream"}),tt(t)?void t(n):n},base64:function(t,r,n){var i=($(t),null),a=X(t)?t:e.my.tojson(t),o=X(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 N,S="jQuery.my 1.1.4",T=window.URL||window.webkitURL,M=!document.addEventListener,E=r(e,"my.f.repo")?e.my.f.repo():{_src:{},_name:"Global manifest cache"},I=r(e,"my.f.restyles")?e.my.f.restyles():{},R=e.extend,$=e.type,P=null,U=function(e){return null!==e&&void 0!==e},F="{yyyy}-{MM}-{dd}",L="{HH}:{mm}",A="object",H="data",J="array",B="string",Q="function",W="change",V=/^this\./,G=Object.isArray,K=Object.isBoolean,X=Object.isString,Y=Object.isObject,Z=Object.isNumber,et=Object.isRegExp,tt=Object.isFunction,rt=Object.keys,nt=function(e){return!!(null!=e&&(Y(e)||e.jquery)&&tt(e.then)&&tt(e.fail)&&tt(e.state))},it=function(e,t){var n,i;return X(e)?(n=e,i=r(Y(t)?t:E,n),"exist"===t?Y(i):i?Object.clone(i,!0):null):Y(e)?(i=a(e,t),Y(i)?i:null):void 0===e?E._src:null===e?Object.reject(E,/^_/):null},at=e.ajax,ot={vals:{".my-form":function(e,t){if(e&&e.my){var r=e.my(H);return Object.equal(r,t)?r:e.my(H,t,!0)}return t||P},".hasDatepicker":function(e,t){U(t)&&e.datepicker("setDate",""==t?t:Date.create(t));var r=e.datepicker("getDate");return r?r.format(F):""},".my-tags":function(e,t){return U(t)&&(X(t)||Z(t)?e.tags(H,[t+""]):G(t)&&e.tags(H,t)),e.tags(H)},".ui-draggable":function(e,t){if(U(t)&&Y(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 i(){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 a(e){e.data("my").locktill+j/1.3.my-form",v=p.template||"
",g=/\{/.test(v),b=p.hash||st.sdbmCode,x=p.id||st.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(U(r)&&G(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(U(r)&&G(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[st.sdbmCode(st.extval(e(this)))]=e(this)});for(var d=u.length-1;d>=0;d--){var f=st.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(st.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==P&&s.each(function(){i.push(st.extval(e(this)))})):(s=t.find(t.sortable("option","items")).filter(":visible:not(:disabled, .ui-state-disabled)"),s.each(function(){i.push(st.extval(e(this)))}))}return i},"input[type=date]":function(e,t){if(U(t))return r=""!=t?Date.create(t).format(F):"",X(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(F):""},"input[type=time]":function(e,t){if(U(t))return r=""!=t?Date.create(t).format(L):"",X(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(L):""},input:{"[type='text'],[type='number'],[type='search'],[type='hidden'],[type='password'],[type='button'],[type='range'],:not([type])":{".ui-slider-input":function(e,t){U(t)&&e.val(t).slider("refresh")},".tagstrip input.value":function(e,t){U(t)&&e.val(t).trigger("update")},"div.select2-container+input":function(e,t){return U(t)&&JSON.stringify(t)!==JSON.stringify(e.select2("val"))&&e.select2("val",G(t)?t:[t]),e.select2("val")},"":function(e,t){U(t)&&e.val(t+"")}},":radio":function(t,r){var n=-1;if(U(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:N},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){st.jquix(t,"selectable",e)},".ui-slider":function(e,t){st.jquix(t,"slider",e)},".ui-draggable":function(e,t){st.jquix(t,"draggable",e)},".ui-buttonset":function(e,t){st.jquix(t,"buttonset",e)},".hasDatepicker":function(e,t){st.jquix(t,"datepicker",e)},".my-form":function(e,t){t.my("disabled",!!e)},"div.select2-container+input,div.select2-container+select":function(e,t){st.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") -}}}};ot.params={container:function(e){return u(e,ot.containers)(e)},change:P,recalcDepth:2,delay:0,strict:!1,restyle:-1,locale:N=(navigator.language||navigator.userLanguage||"en").substr(0,2),messages:Object.map(ot.msg,function(e,t){return t[N]||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=it(t+"");return n?r.resolve(n):r.reject(null),r.promise()},ajaxTimeout:1e4};var st=_(),lt={init:function(n,i,a){function l(e){var t,n,i,a,o,s,l={},c=!0,u=e.inherit;if(l=z(u),!Object.size(l))return null;if(a=ut.parents(".my-form").eq(0),!a.size())return null;if(o=a.data("my"),!o||!o.manifest)return null;i=o.manifest,n=i.expose,c=!n;for(t in l)(c||n[t])&&(s=r(i,t),null!=s&&(/\./.test(t)||X(l[t])?R(!0,$,st.unmask(s,X(l[t])?l[t]:t)):e[t]=s))}function u(){var e,r;for(var e in K)for(r in M[e].listen)K[e].addClass("my-listen-"+st.sdbmCode(r));W.radio&&ut.on("radio.my",function(e,r){var n,i;if(Y(r)&&r.channel&&r.message&&tt(W.radio[r.channel])){n=W.radio[r.channel];try{i=n.call(W,e,r)}catch(a){t("Radio handler for form "+N+"failed",a.message,a.stack)}void 0!==i&&(e.stopPropagation(),i&&s(ut,r))}})}function f(){E.strict||w($,!0),W=R(!0,W,Object.reject($,["data"])),M=C(R(!0,{},$.ui||{}),W,E),W.radio&&(W.radio=q(W.radio)),W.expose&&(W.expose=z(W.expose)),_=Number.random(268435456,4294967295).toString(16),O=$.id||"my"+_,N=st.sdbmCode(O),W.id=O,E.form=ut,$.params&&$.params.depth&&(E.recalcDepth=$.params.depth);for(U in W)tt(W[U])&&(W[U]=W[U].bind(W));$.error&&(X($.error)?rt=function(e,t){return $.error.assign(R({message:e+"",err:t+""},$))}:tt($.error)&&(rt=function(e,t){S=null;try{S=$.error(e,t)}catch(r){S=E.messages.initFailed}return S})),R(ut.data("my"),{id:O,cid:_,mid:N,errors:Object.extended(),ui:Object.extended(M),disabled:!1,manifest:W,locFiles:[],modals:{},radio:{}}),ut.addClass("my-form"),L="my-manifest-"+N,A="my-form-"+_,ut.addClass(A+" "+L)}function m(t){function r(e,t){return'"}W.style&&(F=D(ut,W,L,A),F&&F[0].length&&!t&&(J=e("style#"+L),J.size()||(J=e(r(F[0],L)).appendTo(e("body"))),J.data("count",1*J.data("count")+1),ut.data("my").style=J),F&&F[1].length&&(B=e("style#"+A),B.size()?t&&(e(r(F[1],A)).replaceAll(B),B=e("style#"+A)):(B=e(r(F[1],A)).appendTo(e("body")),E.restyle>-1&&!I[_]&&(I[_]=function(){m(!0)}.debounce(E.restyle)),ut.data("my").restyle=m.fill(!0).debounce(0)),ut.data("my").localStyle=B))}function h(){var t,r,n=e.Deferred();if(r=o(W),X(r))b("Error decoding base64 to local Blob/URL",r),n.reject();else{if(T)for(t=0;t*").clone();try{Q=x(W,$.init,ut,$)}catch(t){return b(X(t)?t:t.message,t.stack),ut}}if(nt(Q)?Q.then(function(){y()},function(e,t){b(e,t)}):y(),!et){if(!ut.my())return b("Internal error initializing controls",""),ut;ut.data("my").initial=R(!0,{},V),e.mobile&&e.mobile.changePage(e.mobile.activePage)}}function y(){function e(e){et||(t[e]=c(ut.find(e),P),r-=1,.5>r&&g(t))}var t={},r=Object.size(M);ut.addClass(at),Object.each(M,function(t){if(!et){var r=ut.find(t),n=v(r,ut,M[t],t);nt(n)?n.then(e.fill(t)).fail(function(e,r){b("Error building "+t+", "+e,r)}):et||e(t)}})}function g(e){var t,r,n;for(var i in M){if(et)return;if(t=M[i],n=ut.find(i),n.size()){t.listen&&(K[i]=n.eq(0));try{r=d(V,P,t,n),r==P&&e[i]!=P&&void 0!==r&&d(V,e[i],t,n)}catch(a){st.con("Transient fail linking "+i+" of form $('.my-form-"+_+"')",a.message,a.stack)}try{r!=P&&c(n,r),n.eq(0).trigger("check.my")}catch(a){b("Error linking "+i,a.message,a.stack)}}}ut.removeClass(at),ct=null,Z.resolve(V)}function b(e,r){var n;if(et=!0,t("Form "+O+" failed to initialize",e,r),ut.removeClass(at),n=rt(e,r),X(n)||Y(n)&&n.jquery?ut.html(n):n===!0&&ut.html(ct),E.silent)Z.resolve(V);else{if(!ut.my().ddata){if(ut.removeData("my"),ut.removeClass("my-form"),J)if("1"==J.data("count"))try{J.remove()}catch(i){}else J.data("count",J.data("count")-1);if(B)try{delete I[_],B.remove()}catch(i){}}Z.reject("Form "+O+" failed to initialize: "+e,r)}}var j,k,O,_,N,S,M,E,$,U,F,L,A,J,B,Q,W={},V={},G=[],K={},Z=e.Deferred(),et=!1,rt=function(){},at="my-form-init",lt="std",ct="";if(X(n)){if(j=it(n),!j)return Z.reject("No manifest with id "+n+" found in repo."),Z.promise();Y(a)&&Y(i)?(j=R(j,i),k=a):k=i,lt="repo"}else j=n,k=i;if(!j)return this;$=Y(k)&&"repo"!=lt?R(!0,{},j):j;var ut=this.eq(0),dt=ut.my();return Y(dt)&&dt.id&&dt.ui?(st.con("jQuery.my is already bind.",ut),ut.my("ui",$.ui),ut.my(H,$.data),Z.resolve(ut.my(H)).promise()):(E=$.params||{},E.strict||(E=R(!0,{},E),w(E)),E=R(!0,{},ot.params,E),Z.fail(function(){ut.removeClass(A+" "+L)}),R(ut,Z.promise()),Y(k)?(V=st.patch(k,$.data||{}),$.data=V):V=$.data||{},W.data=V,ut.data("my",{data:V,params:E,promise:Z.promise(),locktill:0}),ut.addClass(at),$.inherit&&l($),st.require($,E).then(function(){f(),h().then(function(){m(),p()})}).fail(function(e){f(),b("Linker of ‘require’ property failed.",e)}),Z.then(u),ut)},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?P: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(W)),r},data:function(e,t){var r=this;return Y(e)&&(r.my().data=st.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]&&X(t[n])&&(r[n]=t[n]),Y(t[n])&&rt(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]&&X(t[n])?r++:Y(t[n])&&rt(t[n]).length&&r++;return!r},reset:function(){try{st.kickoff(this.my().data,this.my().initial),this.my("redraw")}catch(e){return!1}return!0},id:function(e,t){if(X(e))return it(e,t);var r=this.my();return r&&r.id?r.id:P},remove:function(e){var t,r,n,i,a,o,s,l,c=this;if(!this.my())return P;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"),Y(n)&&n.manifest&&tt(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 I[s],r.remove()}catch(d){}if(window.URL&&(i=n.locFiles)&&i.length)for(var f=0;fo?P:(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&&(st.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 P;R(!0,{},n.ui);if(!Y(e))return n.ui;for(t in e)i.push(t);for(n.ui=C(st.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}/>',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%",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(30,65,100,0.8)"})):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.5)","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){}w.data("modals")[M.cid]=null,x.parent().unbind(".my").remove(),j.off(".my"+M.cid),M.screen&&function(e){e&&a||j.hide()}.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){}v(),D.removeData("modal"),s[M.cid]&&s[M.cid].reject("Cancelled"),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")&&(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()),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); +!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||"").split(".").reduce(function(e,t){return null!=e&&null!=e[t]?e[t]:void 0},e)}function a(e,t){var r,i;if(Z(t))return t;if(Y(t)){if(r=n(e,t),null==r&&(r=Object.clone(R._src[t],!0)),null==r&&(r=n(R,t),Z(r)&&Z(r._self)?r=Object.clone(r._self,!0):Z(r)&&(r=Object.clone(r,!0))),null==r&&n(e,"params.cache")&&(i=n(e,"params.cache"),rt(i)?r=i(t):Z(i)&&(r=at(t,i)),Z(r)&&(Z(r._self)&&(r=Object.clone(r._self,!0)),Object.merge(r,{params:{cache:i}},!0))),null!=r&&Z(r))return i=i||n(e,"params.cache"),i&&Object.merge(r,{params:{cache:i}},!0),r;throw"Component "+t+" not found."}return rt(t)?t.apply(e,Array.prototype.slice.call(arguments,2)):null}function o(r,i){var a,o,l,c,u,d=i||R,f=r;if(!(Z(d)&&Z(f)&&Z(f.ui)&&Y(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),Y(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)),o=Object.keys(d._src).filter(function(e){return e.startsWith(l+".")}),o.sort(),o.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),E?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(Z(e.files)&&Object.size(e.files))for(t in e.files){if(r=e.files[t],!Z(r)||!Y(r.data)||r.url)return"Non-object member "+t+" in files section.";if(M)try{lt.base642blob(r.data,function(e){r.blob=e,r.url=M.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){Z(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&&rt(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 Y(t)?/[\/]/.test(t)?(n=I(!0,{},k,{ref:r,ajax:{url:t}}),K.test(r)&&(n.ajax.dataType="json")):t.length&&(n=I(!0,{},k,{ref:r,ajax:t})):Z(t)&&(n=I(!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=nt(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=Y(i.ajax)?j.loader:ot,o(i.ajax).then(function(e,r){K.test(r.ref)&&(null!=e?I(!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 K.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=I(!0,{ajaxTimeout:1e4,loader:st.params.loader},r||{}),k={ref:null,ajax:{type:"GET",async:!0,timeout:j.ajaxTimeout}};if(Z(t))if(X(t.require)){for(m=t.require,u=0;ui)return n=l,void(i=o);c==H&&r(e,l,o+1)}U!=t[""]&&typeof t[""]!=H&&o>i&&(n=t[""],i=o)}var n=U,i=0,a="";return r(e,t,1),n}function f(e,t,r,n){var i,a,o,s=[],l=r.bind,c=P(l);if(c==W)return l.call(h(n).manifest,e,t,n);if(c===Q||c===B){if(c===Q&&!/\./.test(l))return t!=U?e[l]=t:void 0===e[l]&&(e[l]=U),e[l];for(c===Q&&(s=l.split(".").each(function(e,t){this[t]=e+""})),c===B&&(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,st.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!=U){if(l=F(r)?r:u(g,f(a,U,o,g)),U!=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{U!=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==U?l:r;if(o.css)for(c in o.css)d=o.css[c],tt(d)?p(d.test(_),g,c):rt(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(V),m.history[o.last()]}if(!isNaN(e)||e===U){if(l=parseInt(e)||0,0>l)return U;if(o=nt(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(O.list)?s=O.list:c=O.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:v,delay:(O.delay||k.delay||10)/1.3,template:s,selector:c,parent:z,bind:O.bind,hash:rt(O.hash)?O.hash.bind(z):f(O.hash),id:rt(O.id)?O.id.bind(z):f(O.id),ext:!(!O.id&&!O.hash),stamp:0},i.on("insert.my",function(t,r){t.stopPropagation();var n={what:void 0,where:0};null==r?n.where=1e6:Z(r)?Object.merge(n,r):(Y(r)||et(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(z,v),Z(o)?o:void 0)}catch(h){u("$.my subform init of "+l+" failed: "+h.message,h.stack)}}it(t)?t.then(m,function(e,t){u("Init of subform "+l+" failed with error: "+e,t)}):m()}function u(e,r){t(e,r),C&&C.reject(e,r)}function f(e){var t=P(e).to(3);return e?"str"===t?n.fill(void 0,e):"arr"===t?lt.mask.fill(void 0,e):null:null}function m(){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=O.events||d(n,st.events),n.is(".my-form")?I(n.data("my"),{dui:O,root:o,selector:l,dparams:k,devents:t,ddata:j.data,container:k.container(n),derrors:j.errors}):(n.data("my",{events:t,selector:l,initial:p,previous:p,root:o,container:k.container(n),id:j.id,ui:O,data:j.data,params:k,errors:j.errors}),s._update=O.delay?y.debounce(O.delay):U,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"),I(n.data("my"),{container:k.container(n)});var f,m=function(e){n.val(e).trigger(V)},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 v=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(v.html())}),e("body").on("click","div.cleditorPopup",function(){m(v.html())})}}else if(n.is("div.redactor_box textarea")){var w,C="my-redactor-9";try{w=n.getEditor(),C="my-redactor-8"}catch(q){w=n.redactor("getEditor")}w&&(n.addClass(C),w.bind("input.my keyup.my blur.my",function(e){e.trigger("redactor")}.fill(n)))}else n.is(".ace_editor")?ace.edit(i[0]).on(V,function(e){e.trigger("ace")}.fill(n)):r&&r.on(V,function(e){e.trigger("codemirror")}.fill(n));n.my()._changed=b.debounce(g),n.my()._recalc=x.debounce(g),n.bind(t,function(e){e.type==V&&e.stopPropagation(),a&&(j.locktill=Date.now()+s.delay),n.my()._changed(n,o,s,k)}),/check(\.my)?/.test(t+"")||n.on("check.my",function(){return n.my()._changed(n,o,s,k,!0),!1}),n.on("recalc.my, redraw.my",function(e){e.stopPropagation(),n.my()._recalc(n,o,s,k)})}),C&&C.resolve()}var h,p,v,g,j=o.my(),k=(j||{}).params,O=s,C=null,q=0,z=j.manifest;return j?(g=s.delay,i.size()?(O.init!=U&&(h=w(z,O.init,i,j)),it(h)?(q+=1,C=e.Deferred(),h.then(c,function(e,t){u("Init of "+l+" failed: "+e,t)})):c()):r("Not found "+l+" selector.",o),C):(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?U:u(s,U),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):U,r.recalcDepth||i.recalcDepth)}}function w(e,t,r,i){var a;if(Y(t)){if(a=n(e,t),void 0===a)return r.html(t.assign(i.data)),null}else a=t;if(rt(a))return a.apply(e,Array.prototype.slice.call(arguments,2));if(X(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="";(n||!/^(data|files|require)$/.test(e))&&(i=r[e],s=P(i),/^(ob|ar)/.test(s)?j(i):"string"===s&&/^(function\s*\(|new\sRegExp)/.test(i)&&((a=i.match(/^function\s*\(([^\)]*)\)\s*\{([\s\S]*)\}[\s\n\r\t]*$/))&&3===a.length?(o=O(a[1],a[2]),"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 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){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=Z(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&&(Y(a.recalc)?c=a.recalc.split(d):X(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(Y(a.watch)?u=a.watch.split(d):X(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+"}"))),X(f)&&f.length)for(l=0;le?"0"+e:e}function t(e,i,a){var o,s,l,c,u=0,d=i||0,f=r;switch(a&&Y(a)&&(u=String(a).length,f=String(a).repeat(10)),(typeof e).substr(0,3)){case"str":return n(e);case"num":return isFinite(e)?""+String(e):"null";case"boo":case"nul":return String(e);case"fun":return n(e.toString().replace(/^(function)([^\(]*)(\([^\)]*)([\n\t][^)]*)(\).*)/,"$1 $3$5").replace(/(})([^}]*$)/,"$1"));case"obj":if(!e)return"null";if(typeof e.toJSON===W)return t(e.toJSON(),d+(a?1:0),a);if(o=[],X(e)){for(s=0;sl;l++)s[l]=i.charCodeAt(l);return n=new Blob([s],{type:r||"application/octet-stream"}),rt(t)?void t(n):n},base64:function(t,r,n){var i=(P(t),null),a=Y(t)?t:e.my.tojson(t),o=Y(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 S,T="jQuery.my 1.1.6",M=window.URL||window.webkitURL,E=!document.addEventListener,R=n(e,"my.f.repo")?e.my.f.repo():{_src:{},_name:"Default manifest cache"},$=n(e,"my.f.restyles")?e.my.f.restyles():{},I=e.extend,P=e.type,U=null,F=function(e){return null!==e&&void 0!==e},L="{yyyy}-{MM}-{dd}",A="{HH}:{mm}",H="object",J="data",B="array",Q="string",W="function",V="change",K=/^this\./,X=Object.isArray,G=Object.isBoolean,Y=Object.isString,Z=Object.isObject,et=Object.isNumber,tt=Object.isRegExp,rt=Object.isFunction,nt=Object.keys,it=function(e){return!!(null!=e&&(Z(e)||e.jquery)&&rt(e.then)&&rt(e.fail)&&rt(e.state))},at=function(e,t){var r,i;return Y(e)?(r=e,i=n(Z(t)?t:R,r),"exist"===t?Z(i):i?Object.clone(i,!0):null):Z(e)?(i=o(e,t),Z(i)?i:null):void 0===e?R._src:null===e?Object.reject(R,/^_/):null},ot=e.ajax,st={vals:{".my-form":function(e,t){if(e&&e.my){var r=e.my(J);return Object.equal(r,t)?r:e.my(J,t,!0)}return t||U},".hasDatepicker":function(e,t){F(t)&&e.datepicker("setDate",""==t?t:Date.create(t));var r=e.datepicker("getDate");return r?r.format(L):""},".my-tags":function(e,t){return F(t)&&(Y(t)||et(t)?e.tags(J,[t+""]):X(t)&&e.tags(J,t)),e.tags(J)},".ui-draggable":function(e,t){if(F(t)&&Z(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||lt.sdbmCode,x=p.id||lt.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(F(r)&&X(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(F(r)&&X(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==U&&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(F(t))return r=""!=t?Date.create(t).format(L):"",Y(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(L):""},"input[type=time]":function(e,t){if(F(t))return r=""!=t?Date.create(t).format(A):"",Y(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(A):""},input:{"[type='text'],[type='number'],[type='search'],[type='hidden'],[type='password'],[type='button'],[type='range'],:not([type])":{".ui-slider-input":function(e,t){F(t)&&e.val(t).slider("refresh")},".tagstrip input.value":function(e,t){F(t)&&e.val(t).trigger("update")},"div.select2-container+input":function(e,t){return F(t)&&JSON.stringify(t)!==JSON.stringify(e.select2("val"))&&e.select2("val",X(t)?t:[t]),e.select2("val")},"":function(e,t){F(t)&&e.val(t+"")}},":radio":function(t,r){var n=-1;if(F(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:S},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 d(e,st.containers)(e)},change:U,recalcDepth:2,delay:0,strict:!1,restyle:-1,locale:S=(navigator.language||navigator.userLanguage||"en").substr(0,2),messages:Object.map(st.msg,function(e,t){return t[S]||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=N(),ct={init:function(i,a,o){function c(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)||Y(l[t])?I(!0,P,lt.unmask(s,Y(l[t])?l[t]:t)):e[t]=s))}function d(){var e,r;for(var e in G)for(r in E[e].listen)G[e].addClass("my-listen-"+lt.sdbmCode(r));V.radio&&dt.on("radio.my",function(e,r){var n,i;if(Z(r)&&r.channel&&r.message&&rt(V.radio[r.channel])){n=V.radio[r.channel];try{i=n.call(V,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(P,!0),V=I(!0,V,Object.reject(P,["data"])),E=q(I(!0,{},P.ui||{}),V,R),V.radio&&(V.radio=z(V.radio)),V.expose&&(V.expose=D(V.expose)),N=Number.random(268435456,4294967295).toString(16),C=P.id||"my"+N,S=lt.sdbmCode(C),V.id=C,R.form=dt,P.params&&P.params.depth&&(R.recalcDepth=P.params.depth);for(F in V)rt(V[F])&&(V[F]=V[F].bind(V));P.error&&(Y(P.error)?nt=function(e,t){return P.error.assign(I({message:e+"",err:t+""},P))}:rt(P.error)&&(nt=function(e,t){T=null;try{T=P.error(e,t)}catch(r){T=R.messages.initFailed}return T})),I(dt.data("my"),{id:C,cid:N,mid:S,errors:Object.extended(),ui:Object.extended(E),disabled:!1,manifest:V,locFiles:[],modals:{},radio:{}}),dt.addClass("my-form"),A="my-manifest-"+S,H="my-form-"+N,dt.addClass(H+" "+A)}function h(t){function r(e,t){return'"}V.style&&(L=_(dt,V,A,H),L&&L[0].length&&!t&&(B=e("style#"+A),B.size()||(B=e(r(L[0],A)).appendTo(e("body"))),B.data("count",1*B.data("count")+1),dt.data("my").style=B),L&&L[1].length&&(Q=e("style#"+H),Q.size()?t&&(e(r(L[1],H)).replaceAll(Q),Q=e("style#"+H)):(Q=e(r(L[1],H)).appendTo(e("body")),R.restyle>-1&&!$[N]&&($[N]=function(){h(!0)}.debounce(R.restyle)),dt.data("my").restyle=h.fill(!0).debounce(0)),dt.data("my").localStyle=Q))}function p(){var t,r,n=e.Deferred();if(r=s(V),Y(r))x("Error decoding base64 to local Blob/URL",r),n.reject();else{if(M)for(t=0;t*").clone();try{W=w(V,P.init,dt,P)}catch(t){return x(Y(t)?t:t.message,t.stack),dt}}if(it(W)?W.then(function(){v()},function(e,t){x(e,t)}):v(),!tt){if(!dt.my())return x("Internal error initializing controls",""),dt;dt.data("my").initial=I(!0,{},K),e.mobile&&e.mobile.changePage(e.mobile.activePage)}}function v(){function e(e){tt||(t[e]=u(dt.find(e),U),r-=1,.5>r&&b(t))}var t={},r=Object.size(E);dt.addClass(ot),Object.each(E,function(t){if(!tt){var r=dt.find(t),n=g(r,dt,E[t],t);it(n)?n.then(e.fill(t)).fail(function(e,r){x("Error building "+t+", "+e,r)}):tt||e(t)}})}function b(e){var r,n,i;for(var a in E){if(tt)return;if(r=E[a],i=dt.find(a),i.size()){r.listen&&(G[a]=i.eq(0));try{n=f(K,U,r,i),n==U&&e[a]!=U&&void 0!==n&&f(K,e[a],r,i)}catch(o){t("Transient fail linking "+a+" of form $('.my-form-"+N+"')",o.message,o.stack)}try{n!=U&&u(i,n),i.eq(0).trigger("check.my")}catch(o){x("Error linking "+a,o.message,o.stack)}}}dt.removeClass(ot),ut=null,et.resolve(K)}function x(e,r){var n;if(tt=!0,t("Form "+C+" failed to initialize",e,r),dt.removeClass(ot),n=nt(e,r),Y(n)||Z(n)&&n.jquery?dt.html(n):n===!0&&dt.html(ut),R.silent)et.resolve(K);else{if(!dt.my().ddata){if(dt.removeData("my"),dt.removeClass("my-form"),B)if("1"==B.data("count"))try{B.remove()}catch(i){}else B.data("count",B.data("count")-1);if(Q)try{delete $[N],Q.remove()}catch(i){}}et.reject("Form "+C+" failed to initialize: "+e,r)}}var k,O,C,N,S,T,E,R,P,F,L,A,H,B,Q,W,V={},K={},X=[],G={},et=e.Deferred(),tt=!1,nt=function(){},ot="my-form-init",ct="std",ut="";if(Y(i)){if(k=at(i),!k)return et.reject("No manifest with id "+i+" found in repo."),et.promise();Z(o)&&Z(a)?(k=I(k,a),O=o):O=a,ct="repo"}else k=i,O=a;if(!k)return this;P=Z(O)&&"repo"!=ct?I(!0,{},k):k;var dt=this.eq(0),ft=dt.my();return Z(ft)&&ft.id&&ft.ui?(r("jQuery.my is already bind.",dt),dt.my("ui",P.ui),dt.my(J,P.data),et.resolve(dt.my(J)).promise()):(R=P.params||{},R.strict||(R=I(!0,{},R),j(R)),R=I(!0,{},st.params,R),et.fail(function(){dt.removeClass(H+" "+A)}),I(dt,et.promise()),Z(O)?(K=lt.patch(O,P.data||{}),P.data=K):K=P.data||{},V.data=K,dt.data("my",{data:K,params:R,promise:et.promise(),locktill:0}),dt.addClass(ot),P.inherit&&c(P),lt.require(P,R).then(function(){m(),p().then(function(){h(),y()})}).fail(function(e){m(),x("Linker of ‘require’ property failed.",e)}),et.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?U: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(V)),r},data:function(e,t){var r=this;return Z(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]&&Y(t[n])&&(r[n]=t[n]),Z(t[n])&&nt(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]&&Y(t[n])?r++:Z(t[n])&&nt(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(Y(e))return at(e,t);var r=this.my();return r&&r.id?r.id:U},remove:function(e){var t,r,n,i,a,o,s,l,c=this;if(!this.my())return U;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"),Z(n)&&n.manifest&&rt(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 $[s],r.remove()}catch(u){}if(window.URL&&(i=n.locFiles)&&i.length)for(var f=0;fo?U:(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&&(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 U;I(!0,{},n.ui);if(!Z(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}/>',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%",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(30,65,100,0.8)"})):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.5)","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(30,65,100,0.8)"})}.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")&&(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()),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); diff --git a/bower.json b/bower.json index 56c13ff..41d6534 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquerymy", - "version": "1.1.4", + "version": "1.1.6", "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 a470705..bb716d2 100644 --- a/jquerymy.js +++ b/jquerymy.js @@ -1,24 +1,24 @@ /* - * jQuery.my 1.1.4 + * jQuery.my 1.1.6 * Requires jQuery 1.11.0+, SugarJS 1.3.9-1.4.x - * - * — Optimized try/catch for v8 hydrogen - * — Console now prints arguments as list, not array - * — Minor bug fixes for select.uiSelectmenu plugin + * + * — fixed a bug caused forever-pending init if a member of .files section is zero length base64 + * — fixed memoization of screen shield color for global modal, when global is tied to $control + * — fixed inability to close modal when $root no more exist * * More details at jquerymy.com * - * @ermouth, thanks @carpogoryanin, @ftescht - * 2015-05-09 + * (c) @ermouth, thanks @carpogoryanin, @ftescht + * 2015-06-16 */ -;(function ($) {var _version = "jQuery.my 1.1.4"; +;(function ($) {var _version = "jQuery.my 1.1.6"; // Some shortcuts and constants var lang = "en", wURL = window.URL || window.webkitURL, ie8 = !document.addEventListener, - forms = _getref($,"my.f.repo")? $.my.f.repo():{_src:{}, _name:"Global manifest cache"}, + 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, @@ -37,7 +37,11 @@ isF = Object.isFunction, Keys = Object.keys, isP = function (a) {/*is 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 @@ -71,10 +75,6 @@ // - - - - - - - - - - - - - - - - - - - - var _ajax = $.ajax; - - // - - - - - - - - - - - - - - - - - - - - - - function _ERR () { console.error.apply(console, arguments); } // - - - - - - - - - - - - - - - - - - - - @@ -126,7 +126,7 @@ if (ext) Object.merge(t, {params:{cache:ext}}, true); return t; } - else throw "Component "+ref+" not found"; + else throw "Component "+ref+" not found."; } else if (isF(ref)) { return ref.apply(manifest, Array.prototype.slice.call(arguments, 2)); @@ -147,7 +147,7 @@ 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 "Invalid arguments."; + return "Can’t save manifest into cache, invalid arguments."; if (!root.hasOwnProperty("_src")) root._src={}; @@ -157,7 +157,7 @@ //path = id.split("."); try {obj=Object.clone(obj0, true);} - catch (e) {return "Can’t mount circular-referencing obj.";} + 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);} @@ -179,7 +179,7 @@ if (prev=f.mask(root, id)) { - if (prev.params && prev.params.protect) return "Can’t mount on protected."; + 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; @@ -214,7 +214,7 @@ if (ie8) res["_self"] = root._src[id]; else Object.defineProperty(res, "_self", { get: function () { return root._src[id]; }, - set: function () { throw "Can not change repo.";}, + set: function () { throw "Can’t change manifest cache entry directly.";}, enumerable : false, configurable : true }); @@ -233,7 +233,7 @@ //blobify files for (i in obj.files) { file = obj.files[i]; - if (isO(file) && file.data && !file.url) { + if (isO(file) && isS(file.data) && !file.url) { if (wURL) { try { f.base642blob(file.data,function(res){ @@ -250,6 +250,7 @@ flist.push(i); } } + else return "Non-object member "+i+" in files section." } } return flist; @@ -269,20 +270,20 @@ vals : { - /**/ ".my-form": function ($o, v) { + ".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) { + ".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) { + ".my-tags": function ($o,v) { //object is jQ tags control if (n(v)) { if (isS(v) || isN(v)) $o.tags(Da,[v+""]); @@ -291,7 +292,7 @@ return $o.tags(Da); }, - /**/ ".ui-draggable": function ($o,v) { + ".ui-draggable": function ($o,v) { //object is jQ UI draggable if (n(v) && isO(v)) { var c = {}; @@ -306,7 +307,7 @@ }; }, - /**/ ".my-form-list": function ($o,list) { + ".my-form-list": function ($o,list) { //object is list of forms var i,old,mod,eq,ctr = 0, sP = "ui-sortable", sPlc= "."+sP+"-placeholder", @@ -469,7 +470,7 @@ } }, - /**/ ".ui-sortable": function ($o, list) { + ".ui-sortable": function ($o, list) { //jQ UI sortable var a = [], sP = "ui-sortable", @@ -520,7 +521,7 @@ return a; }, - /**/ "input[type=date]":function ($o,v) { + "input[type=date]":function ($o,v) { //object is date input if(n(v)) { if (v!="") d = Date.create(v).format(d8); else d = ""; @@ -531,7 +532,7 @@ return (d!=""?Date.create(d).format(d8):""); }, - /**/ "input[type=time]":function ($o,v) { + "input[type=time]":function ($o,v) { //object is time input if(n(v)) { if (v!="") d = Date.create(v).format(h24); else d = ""; @@ -543,7 +544,7 @@ }, - /**/ "input":{ + "input":{ "[type='text'],[type='number'],[type='search'],[type='hidden'],[type='password'],[type='button'],[type='range'],:not([type])":{ //nearly all main input types and button @@ -619,7 +620,7 @@ } }, - /**/ "select": { + "select": { ".ui-slider-switch": function ($o,v) { //on-off in jQ Mobile if (n(v)) { @@ -648,32 +649,23 @@ if (n(v)) { $o.val(v+""); if ($o.selectmenu && ($o.data("uiSelectmenu") || $o.data("selectmenu"))) $o.selectmenu("refresh",true); - /*if ($o.selectmenu) { - //now ditinguish between jQ selectmenu plugin and jQ Mobile - if ($o.data("uiSelectmenu")) $o.selectmenu("refresh",true); - else if ($o.data("selectmenu")) { - $o.find("option").each(function (i){ - if (f.extval($(this)) == v) $o.selectmenu("value",i); - }); - } - }*/ } } }, - /**/ "textarea": { + "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(); + 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)) { @@ -685,7 +677,7 @@ "":function ($o,v) {if(n(v)) $o.val(v+"");} }, - /**/ "fieldset,form,section,footer,aside,.my-container": function ($o, 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(), @@ -703,7 +695,7 @@ return clist; }, - /**/ "div,span,a,p,li,td,th,h1,h2,h3,h4,h5,h6":{ + "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); @@ -737,15 +729,15 @@ return $o.html(); } }, - /**/ "pre,code":function ($o,v) { + "pre,code":function ($o,v) { if(n(v)) $o.html(v); return $o.html(); }, - /**/ "img":function ($o,v) { + "img":function ($o,v) { if (n(v)) $o.attr("src",v); return $o.attr("src")||""; }, - /**/ "":function ($o,v) { + "":function ($o,v) { if (n(v)) $o.html(v); return $o.html()||$o.text()||String($o.val())||""; } @@ -852,7 +844,7 @@ $o.find(">.my-form").each(function () { $(this).my("remove"); }); - $o.removeClass("my-form-list"); + $o.removeClass("my-form-list"); $o.sortable("destroy"); }, "":function ($o){$o.sortable("destroy");} @@ -865,18 +857,18 @@ }, ".ui-draggable":function ($o){$o.draggable("destroy");}, ".my-redactor-8":function ($o){ - $o.destroyEditor(); - $o.removeClass("my-redactor-8"); - }, + $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") - } - } + "textarea": { + ".my-codemirror": function ($o) { + $o[0].nextSibling.CodeMirror.toTextArea(); + $o.removeClass("my-codemirror") + } + } } }; @@ -917,7 +909,6 @@ - //########## SYSTEM FUNCTIONS ########## //======================================= @@ -1256,9 +1247,9 @@ switch(T(pat).to(1)){ case "f": /*return pat.call(_form($formNode).manifest, data, val, $formNode);*/{ - ret = pat.call(_form($formNode).manifest, data, val, $formNode); - return (ret === null || ret === undefined) ? "" : ret; - } + ret = pat.call(_form($formNode).manifest, data, val, $formNode); + return (ret === null || ret === undefined) ? "" : ret; + } case "r": return ( (pat.test(String(val))) ? "":err0 ); case "a": return ( (pat.indexOf(val)>-1)?"":err0); case "s": return (val==pat?"":err0); @@ -1361,7 +1352,7 @@ if (N != oui.check) { err="Unknown error"; try { err = _validate(d, val, oui, $we); } - catch (e) { _ERR ("Error "+ e.message+" in .check validatir for "+selector, $root, e.stack); } + catch (e) { _ERR ("Error "+ e.message+" in .check validator for "+selector, $root, e.stack); } } var ec = p.errorCss; @@ -1518,7 +1509,7 @@ _fail("Init of "+selector+" failed: "+msg,obj); }); } else _subform(); - } else f.con ("Not found "+selector+" selector.", $root); + } else _CON ("Not found "+selector+" selector.", $root); return pi; @@ -1793,7 +1784,7 @@ } } -//======================================= + //======================================= function _recalc ($o,$root,uiNode,p) { // called when control must update @@ -1812,16 +1803,16 @@ function _prepare (that, init0, $o, d) { // prepares init, applies data if its string template, - // dereferences it if it is pointer, + // dereferences it if it is pointer, // and calls function or formgen - var init; + var init; if (isS(init0)) { - init = _getref(that, init0); - if (undefined === init) { - $o.html(init0.assign(d.data)); - return null; - } - } else init = init0; + init = _getref(that, init0); + if (undefined === init) { + $o.html(init0.assign(d.data)); + return null; + } + } else init = init0; if (isF(init)) return init.apply(that, Array.prototype.slice.call(arguments,2)); else if (isA(init)) { try {$o.formgen(init);} @@ -1910,7 +1901,7 @@ } // unfold 'watch' and extend appropriate 'recalc' - if (v.watch) { + if (v.hasOwnProperty("watch")) { if (isS(v.watch)) watch = v.watch.split(re); else if (isA(v.watch)) watch = v.watch.slice(0); watch = watch.compact(true).unique(); @@ -2061,7 +2052,7 @@ var $root = this.eq(0), rd=$root.my(); if (isO(rd) && rd.id && rd.ui) { - f.con ("jQuery.my is already bind.",$root); + _CON ("jQuery.my is already bind.", $root); $root.my("ui",data.ui); $root.my(Da,data.data); return pi.resolve($root.my(Da)).promise(); @@ -2152,7 +2143,6 @@ else $E(true,data,f.unmask(obj,isS(r[i])?r[i]:i)); } } - } } @@ -2185,7 +2175,6 @@ } }); } - //$listeners=null; } @@ -2409,7 +2398,7 @@ _bind(d, formState[selector], uiNode, $o); } catch (e) { - f.con("Transient fail linking " +selector + _ERR ("Transient fail linking " +selector +" of form $('.my-form-"+cid+"')", e.message, e.stack ); @@ -2543,20 +2532,15 @@ locFiles, d, ui, cid, mid; - if (!this.my()) return N; + if (!this.my()) return N; //child elt requests form removal if (this.my().root && !this.my().ddata) $o = this.my().root; - m = $o.my(); + m = $o.my(); d = m.data; - cid = m.cid; - mid = m.mid; - - - // close modals if any - // if ($o.data("modals")) {} - + cid = m.cid; + mid = m.mid; // stop event listeners $o.unbind(".my"); @@ -2632,9 +2616,10 @@ .removeClass("my-form"); } - $o.removeClass("my-form-"+cid+" my-manifest-"+mid); + $o.removeClass("my-form-"+cid+" my-manifest-"+mid); - return d;//returns data collected by removed instance + //returns data collected by removed instance + return d; }, //###### UNDO ###### @@ -2779,48 +2764,49 @@ }, version: function () {return _version;}, ajax: function(A1){ + // if arg is function, redefines internal ajax if (isF(A1)) return _ajax = A1; else return _ajax.apply(this, Array.prototype.slice.call(arguments)); } }); - // Chain runner - - $.my.chain = (function(){ - var delay = 1, timeout = 1000, - chain = [], - state = false, - put = function (def, d, t) { - chain.push([def, d || delay, t || timeout]); - next(); - }; - put.delay = function (d) { - if (!isNaN(d)) delay = (d-0).clamp(0,1e6); - return delay; - }; - put.timeout = function (d) { - if (!isNaN(d)) timeout = (d-0).clamp(1,1e6); - return timeout; - }; - put.start = function () { state = true; next(); }; - put.stop = function () { state = false; }; - - return put; - - function next (){ - if (chain.length && state) { - var f = chain.shift(), - res, - go = function () { next.delay(f[1]); }.once(); - try { res = f[0](); } - catch (e) { go(); } - if (isP(res)) { - res.then(go, go); - go.delay(f[1]); - } else go(); - } - } - })(); + // Chain runner + + $.my.chain = (function(){ + var delay = 1, timeout = 1000, + chain = [], + state = false, + put = function (def, d, t) { + chain.push([def, d || delay, t || timeout]); + next(); + }; + put.delay = function (d) { + if (!isNaN(d)) delay = (d-0).clamp(0,1e6); + return delay; + }; + put.timeout = function (d) { + if (!isNaN(d)) timeout = (d-0).clamp(1,1e6); + return timeout; + }; + put.start = function () { state = true; next(); }; + put.stop = function () { state = false; }; + + return put; + + function next (){ + if (chain.length && state) { + var f = chain.shift(), + res, + go = function () { next.delay(f[1]); }.once(); + try { res = f[0](); } + catch (e) { go(); } + if (isP(res)) { + res.then(go, go); + go.delay(f[1]); + } else go(); + } + } + })(); // Mount everything over jQuery @@ -2855,15 +2841,13 @@ return; - // # # # # # # # # # # # # # # # # # # # # # # # # # END $.MY PLUGIN INIT # # # # # # # # # # # # # # # # # # # # # # # # # - - + // # # # # # # # # # # # # # # # # # # # # # # # # # END $.MY PLUGIN INIT # # # # # # # # # # # # # # # # # # # # # # # # # - //### Helpers builder + // Helpers builder function _getHelpersLib() { return { - "con": function () {try { console.log.apply (console, arguments); } catch (e) {}}, + "con": _CON, "clone": function (o) {return o.clone?o.clone():o;}, "extval": function ($x) { var d = $x.my(); if (d&&d.data) return d.data; @@ -2910,9 +2894,9 @@ }, "sdbmCode":function (s0){ //very fast hash used in Berkeley DB - for (var s = JSON.stringify(s0), hash=0,i=0;i' - +b+' '; + +'onclick="$(this).parents(\'.my-row\')' + +'.find(\'input,textarea\').val($(this).text()).trigger(\'blur\')">' + +b+' '; }," "); return ('{txt}').assign(p0); }, @@ -3320,10 +3304,11 @@ //############################################################################################# -/* jQuery.my.modal 1.1.0 +/* jQuery.my.modal 1.1.1 * Requires Sugar 1.4.~, jQuery 1.11+, $.my 1.0.0+ * - * Modal dialog constructor/manager. Singleton, allows only one instance of popup. + * Modal dialog constructor/manager. + * * Returns promise, which is resolved on dialog normal close or rejected if modal fails to init. * After content is succesfully initialized promise progress receives notification "Ready". * @@ -3585,7 +3570,11 @@ try {done(null, null);} catch(e){} _remove(); $o.removeData("modal"); - if (M[m.cid]) M[m.cid].reject("Cancelled"); + if (M[m.cid]) { + try { + M[m.cid].reject("Cancelled"); + } catch (e) {} + } delete M[m.cid]; m=null; } @@ -3622,7 +3611,8 @@ // ##### NEW MODAL ########## m=$E({ - type:"DOM", source:"manifest", + type:"DOM", + source:"manifest", form:null, // $obj of the form modal:null, // $obj of the modal wrapper root:null, // $obj, modal is appended to @@ -3694,7 +3684,6 @@ // calculate z-index - _measure(); // ##### Create modal DOM wrapper ##### @@ -3724,9 +3713,7 @@ $bg = m.bgroot.find(">.my-modal-screen"); if (m.screen) { if (!$bg.size()) { - $bg = $('') - .prependTo(m.root); - + $bg = $('').prependTo(m.root); } if (m.esc) $bg.on("click.my"+ m.cid, function () { $o.modal(true); }); @@ -4043,12 +4030,19 @@ function _remove(){ try { $f.my("remove"); } catch(e){} - $r.data("modals")[m.cid] = null; + 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(30,65,100,0.8)'}); + } }).delay(50, m.global); // curry m.global } if (m.global) { diff --git a/jquerymy.min.js b/jquerymy.min.js index 4a045e8..54813d8 100644 --- a/jquerymy.min.js +++ b/jquerymy.min.js @@ -1,6 +1,6 @@ -/* jQuery.my 1.1.4 +/* jQuery.my 1.1.6 * Requires jQuery 1.11.0+, SugarJS 1.3.9-1.4.x * More details at jquerymy.com */ -!function(e){function t(){console.error.apply(console,arguments)}function r(e,t){return(t||"").split(".").reduce(function(e,t){return null!=e&&null!=e[t]?e[t]:void 0},e)}function n(e,t){var n,i;if(Y(t))return t;if(X(t)){if(n=r(e,t),null==n&&(n=Object.clone(E._src[t],!0)),null==n&&(n=r(E,t),Y(n)&&Y(n._self)?n=Object.clone(n._self,!0):Y(n)&&(n=Object.clone(n,!0))),null==n&&r(e,"params.cache")&&(i=r(e,"params.cache"),tt(i)?n=i(t):Y(i)&&(n=it(t,i)),Y(n)&&(Y(n._self)&&(n=Object.clone(n._self,!0)),Object.merge(n,{params:{cache:i}},!0))),null!=n&&Y(n))return i=i||r(e,"params.cache"),i&&Object.merge(n,{params:{cache:i}},!0),n;throw"Component "+t+" not found"}return tt(t)?t.apply(e,Array.prototype.slice.call(arguments,2)):null}function a(n,i){var a,s,l,c,u,d=i||E,f=n;if(!(Y(d)&&Y(f)&&Y(f.ui)&&X(f.id)))return"Invalid arguments.";d.hasOwnProperty("_src")||(d._src={}),l=f.id;try{f=Object.clone(n,!0)}catch(m){return"Can’t mount circular-referencing obj."}try{(!f.params||f.params&&!f.params.strict)&&w(f,!0)}catch(m){return"Invalid manifest, parse error."}if(a=o(f),X(a))return t(a),a;if(Object.merge(f,{params:{strict:!0}},!0),d._src[l]=f,c=st.mask(d,l)){if(c.params&&c.params.protect)return"Can’t mount on protected.";c._self&&delete c._self,e.extend(!0,d,st.unmask("",l))}return e.extend(!0,d,st.unmask(f,l)),s=Object.keys(d._src).filter(function(e){return e.startsWith(l+".")}),s.sort(),s.forEach(function(t){var r;(r=st.mask(d,t))&&(r._self&&delete r._self,e.extend(!0,d,st.unmask("",t))),e.extend(!0,d,st.unmask(d._src[t],t))}),u=r(d,l),M?u._self=d._src[l]:Object.defineProperty(u,"_self",{get:function(){return d._src[l]},set:function(){throw"Can not change repo."},enumerable:!1,configurable:!0}),u}function o(e){var t,r,n=[];if(Y(e.files)&&Object.size(e.files))for(t in e.files)if(r=e.files[t],Y(r)&&r.data&&!r.url)if(T)try{st.base642blob(r.data,function(e){r.blob=e,r.url=T.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){Y(n)&&n.channel&&n.message&&r.find(".my-listen-"+st.sdbmCode(n.channel)).each(function(){var r,i=e(this),a=i.data("my"),o=void 0;if(a&&a.ui.listen&&tt(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,n){function i(t,r){var n;return X(t)?/[\/]/.test(t)?(n=R(!0,{},k,{ref:r,ajax:{url:t}}),V.test(r)&&(n.ajax.dataType="json")):t.length&&(n=R(!0,{},k,{ref:r,ajax:t})):Y(t)&&(n=R(!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=rt(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=X(i.ajax)?j.loader:at,o(i.ajax).then(function(e,r){V.test(r.ref)&&(null!=e?R(!0,t,st.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 n=!1;return V.test(e)?null!=r(t,e.from(5))&&(n=!0):null!=r(window,e)&&(n=!0),n}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=R(!0,{ajaxTimeout:1e4,loader:ot.params.loader},n||{}),k={ref:null,ajax:{type:"GET",async:!0,timeout:j.ajaxTimeout}};if(Y(t))if(G(t.require)){for(m=t.require,u=0;ui)return n=l,void(i=o);c==A&&r(e,l,o+1)}P!=t[""]&&typeof t[""]!=A&&o>i&&(n=t[""],i=o)}var n=P,i=0,a="";return r(e,t,1),n}function d(e,t,r,n){var i,a,o,s=[],l=r.bind,c=$(l);if(c==Q)return l.call(m(n).manifest,e,t,n);if(c===B||c===J){if(c===B&&!/\./.test(l))return t!=P?e[l]=t:void 0===e[l]&&(e[l]=P),e[l];for(c===B&&(s=l.split(".").each(function(e,t){this[t]=e+""})),c===J&&(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,ot.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=!1,w=!1,j=e,k=j.my(),O="";if(k){if(y=k.selector,v=k.root,v.hasClass("my-form-init"))return{};if(g=v.find(y),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!=P){if(l=U(r)?r:c(g,d(a,P,o,g)),P!=o.check){O="Unknown error";try{O=f(a,l,o,g)}catch(C){t("Error "+C.message+" in .check validatir for "+y,v,C.stack)}}var q=s.errorCss,z="ui-state-error";try{P!=r&&(l=c(g,d(a,r,o,g)))}catch(C){O=s.messages.formError||"Error"}if(""===O)x?k.derrors[y]="":k.errors[y]="",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[y]=O;else if(w)k.errors[y]=O;else{i.addClass(q),k.errors[y]=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==P?l:r;if(o.css)for(u in o.css)m=o.css[u],et(m)?h(m.test(_),g,u):tt(m)&&h(m.call(v.my().manifest,a,_,g),g,u);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(W),m.history[o.last()]}if(!isNaN(e)||e===P){if(l=parseInt(e)||0,0>l)return P;if(o=rt(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(k.list)?l=k.list:u=k.list||u,!l){var m=i.find(u);l="
",m.size()&&(l=e(l).append(m.eq(0).clone(!0)).html(),m.eq(0).remove())}i.data("formlist")||i.data("formlist",{}),i.data("formlist").generator={manifest:y,delay:(k.delay||j.delay||10)/1.3,template:l,selector:u,parent:q,bind:k.bind,hash:tt(k.hash)?k.hash.bind(q):d(k.hash),id:tt(k.id)?k.id.bind(q):d(k.id),ext:!(!k.id&&!k.hash),stamp:0},i.on("insert.my",function(t,r){t.stopPropagation();var n={what:void 0,where:0};null==r?n.where=1e6:Y(r)?Object.merge(n,r):(X(r)||Z(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(n(q,y),Y(o)?o:void 0)}catch(h){c("$.my subform init of "+s+" failed: "+h.message,h.stack)}}nt(t)?t.then(f,function(e,t){c("Init of subform "+s+" failed with error: "+e,t)}):f()}function c(e,r){t(e,r),O&&O.reject(e,r)}function d(e){var t=$(e).to(3);return e?"str"===t?r.fill(void 0,e):"arr"===t?st.mask.fill(void 0,e):null:null}function f(){i.each(function(){var t,r,n=e(this),l=!1,c=n[0].nextSibling;if(r=c&&c.CodeMirror?c.CodeMirror:null,r&&n.addClass("my-codemirror"),t=k.events||u(n,ot.events),n.is(".my-form")?R(n.data("my"),{dui:k,root:a,selector:s,dparams:j,devents:t,ddata:w.data,container:j.container(n),derrors:w.errors}):(n.data("my",{events:t,selector:s,initial:h,previous:h,root:a,container:j.container(n),id:w.id,ui:k,data:w.data,params:j,errors:w.errors}),o._update=k.delay?p.debounce(k.delay):P,l=!0),l)if(n.cleditor&&n.parent().is(".cleditorMain")){var d=n.cleditor()[0];if(d&&d.$frame&&d.$frame[0]){n.addClass("my-cleditor"),R(n.data("my"),{container:j.container(n)});var f,m=function(e){n.val(e).trigger(W)},y=Number.random(1e5,1e6-1);e(d.$frame[0]).attr("id","cleditCool"+y),f=document.frames?document.frames["cleditCool"+y].document:e("#cleditCool"+y)[0].contentWindow.document;var x=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(x.html())}),e("body").on("click","div.cleditorPopup",function(){m(x.html())})}}else if(n.is("div.redactor_box textarea")){var O,C="my-redactor-9";try{O=n.getEditor(),C="my-redactor-8"}catch(q){O=n.redactor("getEditor")}O&&(n.addClass(C),O.bind("input.my keyup.my blur.my",function(e){e.trigger("redactor")}.fill(n)))}else n.is(".ace_editor")?ace.edit(i[0]).on(W,function(e){e.trigger("ace")}.fill(n)):r&&r.on(W,function(e){e.trigger("codemirror")}.fill(n));n.my()._changed=g.debounce(v),n.my()._recalc=b.debounce(v),n.bind(t,function(e){e.type==W&&e.stopPropagation(),l&&(w.locktill=Date.now()+o.delay),n.my()._changed(n,a,o,j)}),/check(\.my)?/.test(t+"")||n.on("check.my",function(){return n.my()._changed(n,a,o,j,!0),!1}),n.on("recalc.my, redraw.my",function(e){e.stopPropagation(),n.my()._recalc(n,a,o,j)})}),O&&O.resolve()}var m,h,y,v,w=a.my(),j=(w||{}).params,k=o,O=null,C=0,q=w.manifest;return w?(v=o.delay,i.size()?(k.init!=P&&(m=x(q,k.init,i,w)),nt(m)?(C+=1,O=e.Deferred(),m.then(l,function(e,t){c("Init of "+s+" failed: "+e,t)})):l()):st.con("Not found "+s+" selector.",a),O):(t("Failed to find $root building "+s+" 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?P:c(s,P),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,n,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")?r(o.my().data,o.data("formlist").generator.bind):P,n.recalcDepth||i.recalcDepth)}}function x(e,t,n,i){var a;if(X(t)){if(a=r(e,t),void 0===a)return n.html(t.assign(i.data)),null}else a=t;if(tt(a))return a.apply(e,Array.prototype.slice.call(arguments,2));if(G(a))try{n.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="";(n||!/^(data|files|require)$/.test(e))&&(i=r[e],s=$(i),/^(ob|ar)/.test(s)?w(i):"string"===s&&/^(function\s*\(|new\sRegExp)/.test(i)&&((a=i.match(/^function\s*\(([^\)]*)\)\s*\{([\s\S]*)\}[\s\n\r\t]*$/))&&3===a.length?(o=k(a[1],a[2]),"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=O(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){var r;try{r=new RegExp(e,t)}catch(n){r={message:n.message,stack:n.stack}}return r}function C(e,t,n){var i=Y(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&&(X(a.recalc)?c=a.recalc.split(d):G(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=q(a.listen),a.listen=Object.size(f)?f:void 0),a.watch)for(X(a.watch)?u=a.watch.split(d):G(a.watch)&&(u=a.watch.slice(0)),u=u.compact(!0).unique(),l=0;l2?f=st.css2json(f):o.push(a+(/\{/.test(f)?f:"{"+f+"}"))),G(f)&&f.length)for(l=0;le?"0"+e:e}function t(e,i,a){var o,s,l,c,u=0,d=i||0,f=r;switch(a&&X(a)&&(u=String(a).length,f=String(a).repeat(10)),(typeof e).substr(0,3)){case"str":return n(e);case"num":return isFinite(e)?""+String(e):"null";case"boo":case"nul":return String(e);case"fun":return n(e.toString().replace(/^(function)([^\(]*)(\([^\)]*)([\n\t][^)]*)(\).*)/,"$1 $3$5").replace(/(})([^}]*$)/,"$1"));case"obj":if(!e)return"null";if(typeof e.toJSON===Q)return t(e.toJSON(),d+(a?1:0),a);if(o=[],G(e)){for(s=0;sl;l++)s[l]=i.charCodeAt(l);return n=new Blob([s],{type:r||"application/octet-stream"}),tt(t)?void t(n):n},base64:function(t,r,n){var i=($(t),null),a=X(t)?t:e.my.tojson(t),o=X(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 N,S="jQuery.my 1.1.4",T=window.URL||window.webkitURL,M=!document.addEventListener,E=r(e,"my.f.repo")?e.my.f.repo():{_src:{},_name:"Global manifest cache"},I=r(e,"my.f.restyles")?e.my.f.restyles():{},R=e.extend,$=e.type,P=null,U=function(e){return null!==e&&void 0!==e},F="{yyyy}-{MM}-{dd}",L="{HH}:{mm}",A="object",H="data",J="array",B="string",Q="function",W="change",V=/^this\./,G=Object.isArray,K=Object.isBoolean,X=Object.isString,Y=Object.isObject,Z=Object.isNumber,et=Object.isRegExp,tt=Object.isFunction,rt=Object.keys,nt=function(e){return!!(null!=e&&(Y(e)||e.jquery)&&tt(e.then)&&tt(e.fail)&&tt(e.state))},it=function(e,t){var n,i;return X(e)?(n=e,i=r(Y(t)?t:E,n),"exist"===t?Y(i):i?Object.clone(i,!0):null):Y(e)?(i=a(e,t),Y(i)?i:null):void 0===e?E._src:null===e?Object.reject(E,/^_/):null},at=e.ajax,ot={vals:{".my-form":function(e,t){if(e&&e.my){var r=e.my(H);return Object.equal(r,t)?r:e.my(H,t,!0)}return t||P},".hasDatepicker":function(e,t){U(t)&&e.datepicker("setDate",""==t?t:Date.create(t));var r=e.datepicker("getDate");return r?r.format(F):""},".my-tags":function(e,t){return U(t)&&(X(t)||Z(t)?e.tags(H,[t+""]):G(t)&&e.tags(H,t)),e.tags(H)},".ui-draggable":function(e,t){if(U(t)&&Y(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 i(){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 a(e){e.data("my").locktill+j/1.3.my-form",v=p.template||"
",g=/\{/.test(v),b=p.hash||st.sdbmCode,x=p.id||st.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(U(r)&&G(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(U(r)&&G(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[st.sdbmCode(st.extval(e(this)))]=e(this)});for(var d=u.length-1;d>=0;d--){var f=st.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(st.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==P&&s.each(function(){i.push(st.extval(e(this)))})):(s=t.find(t.sortable("option","items")).filter(":visible:not(:disabled, .ui-state-disabled)"),s.each(function(){i.push(st.extval(e(this)))}))}return i},"input[type=date]":function(e,t){if(U(t))return r=""!=t?Date.create(t).format(F):"",X(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(F):""},"input[type=time]":function(e,t){if(U(t))return r=""!=t?Date.create(t).format(L):"",X(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(L):""},input:{"[type='text'],[type='number'],[type='search'],[type='hidden'],[type='password'],[type='button'],[type='range'],:not([type])":{".ui-slider-input":function(e,t){U(t)&&e.val(t).slider("refresh")},".tagstrip input.value":function(e,t){U(t)&&e.val(t).trigger("update")},"div.select2-container+input":function(e,t){return U(t)&&JSON.stringify(t)!==JSON.stringify(e.select2("val"))&&e.select2("val",G(t)?t:[t]),e.select2("val")},"":function(e,t){U(t)&&e.val(t+"")}},":radio":function(t,r){var n=-1;if(U(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:N},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){st.jquix(t,"selectable",e)},".ui-slider":function(e,t){st.jquix(t,"slider",e)},".ui-draggable":function(e,t){st.jquix(t,"draggable",e)},".ui-buttonset":function(e,t){st.jquix(t,"buttonset",e)},".hasDatepicker":function(e,t){st.jquix(t,"datepicker",e)},".my-form":function(e,t){t.my("disabled",!!e)},"div.select2-container+input,div.select2-container+select":function(e,t){st.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") -}}}};ot.params={container:function(e){return u(e,ot.containers)(e)},change:P,recalcDepth:2,delay:0,strict:!1,restyle:-1,locale:N=(navigator.language||navigator.userLanguage||"en").substr(0,2),messages:Object.map(ot.msg,function(e,t){return t[N]||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=it(t+"");return n?r.resolve(n):r.reject(null),r.promise()},ajaxTimeout:1e4};var st=_(),lt={init:function(n,i,a){function l(e){var t,n,i,a,o,s,l={},c=!0,u=e.inherit;if(l=z(u),!Object.size(l))return null;if(a=ut.parents(".my-form").eq(0),!a.size())return null;if(o=a.data("my"),!o||!o.manifest)return null;i=o.manifest,n=i.expose,c=!n;for(t in l)(c||n[t])&&(s=r(i,t),null!=s&&(/\./.test(t)||X(l[t])?R(!0,$,st.unmask(s,X(l[t])?l[t]:t)):e[t]=s))}function u(){var e,r;for(var e in K)for(r in M[e].listen)K[e].addClass("my-listen-"+st.sdbmCode(r));W.radio&&ut.on("radio.my",function(e,r){var n,i;if(Y(r)&&r.channel&&r.message&&tt(W.radio[r.channel])){n=W.radio[r.channel];try{i=n.call(W,e,r)}catch(a){t("Radio handler for form "+N+"failed",a.message,a.stack)}void 0!==i&&(e.stopPropagation(),i&&s(ut,r))}})}function f(){E.strict||w($,!0),W=R(!0,W,Object.reject($,["data"])),M=C(R(!0,{},$.ui||{}),W,E),W.radio&&(W.radio=q(W.radio)),W.expose&&(W.expose=z(W.expose)),_=Number.random(268435456,4294967295).toString(16),O=$.id||"my"+_,N=st.sdbmCode(O),W.id=O,E.form=ut,$.params&&$.params.depth&&(E.recalcDepth=$.params.depth);for(U in W)tt(W[U])&&(W[U]=W[U].bind(W));$.error&&(X($.error)?rt=function(e,t){return $.error.assign(R({message:e+"",err:t+""},$))}:tt($.error)&&(rt=function(e,t){S=null;try{S=$.error(e,t)}catch(r){S=E.messages.initFailed}return S})),R(ut.data("my"),{id:O,cid:_,mid:N,errors:Object.extended(),ui:Object.extended(M),disabled:!1,manifest:W,locFiles:[],modals:{},radio:{}}),ut.addClass("my-form"),L="my-manifest-"+N,A="my-form-"+_,ut.addClass(A+" "+L)}function m(t){function r(e,t){return'"}W.style&&(F=D(ut,W,L,A),F&&F[0].length&&!t&&(J=e("style#"+L),J.size()||(J=e(r(F[0],L)).appendTo(e("body"))),J.data("count",1*J.data("count")+1),ut.data("my").style=J),F&&F[1].length&&(B=e("style#"+A),B.size()?t&&(e(r(F[1],A)).replaceAll(B),B=e("style#"+A)):(B=e(r(F[1],A)).appendTo(e("body")),E.restyle>-1&&!I[_]&&(I[_]=function(){m(!0)}.debounce(E.restyle)),ut.data("my").restyle=m.fill(!0).debounce(0)),ut.data("my").localStyle=B))}function h(){var t,r,n=e.Deferred();if(r=o(W),X(r))b("Error decoding base64 to local Blob/URL",r),n.reject();else{if(T)for(t=0;t*").clone();try{Q=x(W,$.init,ut,$)}catch(t){return b(X(t)?t:t.message,t.stack),ut}}if(nt(Q)?Q.then(function(){y()},function(e,t){b(e,t)}):y(),!et){if(!ut.my())return b("Internal error initializing controls",""),ut;ut.data("my").initial=R(!0,{},V),e.mobile&&e.mobile.changePage(e.mobile.activePage)}}function y(){function e(e){et||(t[e]=c(ut.find(e),P),r-=1,.5>r&&g(t))}var t={},r=Object.size(M);ut.addClass(at),Object.each(M,function(t){if(!et){var r=ut.find(t),n=v(r,ut,M[t],t);nt(n)?n.then(e.fill(t)).fail(function(e,r){b("Error building "+t+", "+e,r)}):et||e(t)}})}function g(e){var t,r,n;for(var i in M){if(et)return;if(t=M[i],n=ut.find(i),n.size()){t.listen&&(K[i]=n.eq(0));try{r=d(V,P,t,n),r==P&&e[i]!=P&&void 0!==r&&d(V,e[i],t,n)}catch(a){st.con("Transient fail linking "+i+" of form $('.my-form-"+_+"')",a.message,a.stack)}try{r!=P&&c(n,r),n.eq(0).trigger("check.my")}catch(a){b("Error linking "+i,a.message,a.stack)}}}ut.removeClass(at),ct=null,Z.resolve(V)}function b(e,r){var n;if(et=!0,t("Form "+O+" failed to initialize",e,r),ut.removeClass(at),n=rt(e,r),X(n)||Y(n)&&n.jquery?ut.html(n):n===!0&&ut.html(ct),E.silent)Z.resolve(V);else{if(!ut.my().ddata){if(ut.removeData("my"),ut.removeClass("my-form"),J)if("1"==J.data("count"))try{J.remove()}catch(i){}else J.data("count",J.data("count")-1);if(B)try{delete I[_],B.remove()}catch(i){}}Z.reject("Form "+O+" failed to initialize: "+e,r)}}var j,k,O,_,N,S,M,E,$,U,F,L,A,J,B,Q,W={},V={},G=[],K={},Z=e.Deferred(),et=!1,rt=function(){},at="my-form-init",lt="std",ct="";if(X(n)){if(j=it(n),!j)return Z.reject("No manifest with id "+n+" found in repo."),Z.promise();Y(a)&&Y(i)?(j=R(j,i),k=a):k=i,lt="repo"}else j=n,k=i;if(!j)return this;$=Y(k)&&"repo"!=lt?R(!0,{},j):j;var ut=this.eq(0),dt=ut.my();return Y(dt)&&dt.id&&dt.ui?(st.con("jQuery.my is already bind.",ut),ut.my("ui",$.ui),ut.my(H,$.data),Z.resolve(ut.my(H)).promise()):(E=$.params||{},E.strict||(E=R(!0,{},E),w(E)),E=R(!0,{},ot.params,E),Z.fail(function(){ut.removeClass(A+" "+L)}),R(ut,Z.promise()),Y(k)?(V=st.patch(k,$.data||{}),$.data=V):V=$.data||{},W.data=V,ut.data("my",{data:V,params:E,promise:Z.promise(),locktill:0}),ut.addClass(at),$.inherit&&l($),st.require($,E).then(function(){f(),h().then(function(){m(),p()})}).fail(function(e){f(),b("Linker of ‘require’ property failed.",e)}),Z.then(u),ut)},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?P: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(W)),r},data:function(e,t){var r=this;return Y(e)&&(r.my().data=st.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]&&X(t[n])&&(r[n]=t[n]),Y(t[n])&&rt(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]&&X(t[n])?r++:Y(t[n])&&rt(t[n]).length&&r++;return!r},reset:function(){try{st.kickoff(this.my().data,this.my().initial),this.my("redraw")}catch(e){return!1}return!0},id:function(e,t){if(X(e))return it(e,t);var r=this.my();return r&&r.id?r.id:P},remove:function(e){var t,r,n,i,a,o,s,l,c=this;if(!this.my())return P;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"),Y(n)&&n.manifest&&tt(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 I[s],r.remove()}catch(d){}if(window.URL&&(i=n.locFiles)&&i.length)for(var f=0;fo?P:(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&&(st.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 P;R(!0,{},n.ui);if(!Y(e))return n.ui;for(t in e)i.push(t);for(n.ui=C(st.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}/>',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%",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(30,65,100,0.8)"})):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.5)","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){}w.data("modals")[M.cid]=null,x.parent().unbind(".my").remove(),j.off(".my"+M.cid),M.screen&&function(e){e&&a||j.hide()}.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){}v(),D.removeData("modal"),s[M.cid]&&s[M.cid].reject("Cancelled"),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")&&(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()),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); +!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||"").split(".").reduce(function(e,t){return null!=e&&null!=e[t]?e[t]:void 0},e)}function a(e,t){var r,i;if(Z(t))return t;if(Y(t)){if(r=n(e,t),null==r&&(r=Object.clone(R._src[t],!0)),null==r&&(r=n(R,t),Z(r)&&Z(r._self)?r=Object.clone(r._self,!0):Z(r)&&(r=Object.clone(r,!0))),null==r&&n(e,"params.cache")&&(i=n(e,"params.cache"),rt(i)?r=i(t):Z(i)&&(r=at(t,i)),Z(r)&&(Z(r._self)&&(r=Object.clone(r._self,!0)),Object.merge(r,{params:{cache:i}},!0))),null!=r&&Z(r))return i=i||n(e,"params.cache"),i&&Object.merge(r,{params:{cache:i}},!0),r;throw"Component "+t+" not found."}return rt(t)?t.apply(e,Array.prototype.slice.call(arguments,2)):null}function o(r,i){var a,o,l,c,u,d=i||R,f=r;if(!(Z(d)&&Z(f)&&Z(f.ui)&&Y(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),Y(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)),o=Object.keys(d._src).filter(function(e){return e.startsWith(l+".")}),o.sort(),o.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),E?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(Z(e.files)&&Object.size(e.files))for(t in e.files){if(r=e.files[t],!Z(r)||!Y(r.data)||r.url)return"Non-object member "+t+" in files section.";if(M)try{lt.base642blob(r.data,function(e){r.blob=e,r.url=M.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){Z(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&&rt(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 Y(t)?/[\/]/.test(t)?(n=I(!0,{},k,{ref:r,ajax:{url:t}}),K.test(r)&&(n.ajax.dataType="json")):t.length&&(n=I(!0,{},k,{ref:r,ajax:t})):Z(t)&&(n=I(!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=nt(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=Y(i.ajax)?j.loader:ot,o(i.ajax).then(function(e,r){K.test(r.ref)&&(null!=e?I(!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 K.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=I(!0,{ajaxTimeout:1e4,loader:st.params.loader},r||{}),k={ref:null,ajax:{type:"GET",async:!0,timeout:j.ajaxTimeout}};if(Z(t))if(X(t.require)){for(m=t.require,u=0;ui)return n=l,void(i=o);c==H&&r(e,l,o+1)}U!=t[""]&&typeof t[""]!=H&&o>i&&(n=t[""],i=o)}var n=U,i=0,a="";return r(e,t,1),n}function f(e,t,r,n){var i,a,o,s=[],l=r.bind,c=P(l);if(c==W)return l.call(h(n).manifest,e,t,n);if(c===Q||c===B){if(c===Q&&!/\./.test(l))return t!=U?e[l]=t:void 0===e[l]&&(e[l]=U),e[l];for(c===Q&&(s=l.split(".").each(function(e,t){this[t]=e+""})),c===B&&(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,st.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!=U){if(l=F(r)?r:u(g,f(a,U,o,g)),U!=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{U!=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==U?l:r;if(o.css)for(c in o.css)d=o.css[c],tt(d)?p(d.test(_),g,c):rt(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(V),m.history[o.last()]}if(!isNaN(e)||e===U){if(l=parseInt(e)||0,0>l)return U;if(o=nt(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(O.list)?s=O.list:c=O.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:v,delay:(O.delay||k.delay||10)/1.3,template:s,selector:c,parent:z,bind:O.bind,hash:rt(O.hash)?O.hash.bind(z):f(O.hash),id:rt(O.id)?O.id.bind(z):f(O.id),ext:!(!O.id&&!O.hash),stamp:0},i.on("insert.my",function(t,r){t.stopPropagation();var n={what:void 0,where:0};null==r?n.where=1e6:Z(r)?Object.merge(n,r):(Y(r)||et(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(z,v),Z(o)?o:void 0)}catch(h){u("$.my subform init of "+l+" failed: "+h.message,h.stack)}}it(t)?t.then(m,function(e,t){u("Init of subform "+l+" failed with error: "+e,t)}):m()}function u(e,r){t(e,r),C&&C.reject(e,r)}function f(e){var t=P(e).to(3);return e?"str"===t?n.fill(void 0,e):"arr"===t?lt.mask.fill(void 0,e):null:null}function m(){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=O.events||d(n,st.events),n.is(".my-form")?I(n.data("my"),{dui:O,root:o,selector:l,dparams:k,devents:t,ddata:j.data,container:k.container(n),derrors:j.errors}):(n.data("my",{events:t,selector:l,initial:p,previous:p,root:o,container:k.container(n),id:j.id,ui:O,data:j.data,params:k,errors:j.errors}),s._update=O.delay?y.debounce(O.delay):U,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"),I(n.data("my"),{container:k.container(n)});var f,m=function(e){n.val(e).trigger(V)},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 v=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(v.html())}),e("body").on("click","div.cleditorPopup",function(){m(v.html())})}}else if(n.is("div.redactor_box textarea")){var w,C="my-redactor-9";try{w=n.getEditor(),C="my-redactor-8"}catch(q){w=n.redactor("getEditor")}w&&(n.addClass(C),w.bind("input.my keyup.my blur.my",function(e){e.trigger("redactor")}.fill(n)))}else n.is(".ace_editor")?ace.edit(i[0]).on(V,function(e){e.trigger("ace")}.fill(n)):r&&r.on(V,function(e){e.trigger("codemirror")}.fill(n));n.my()._changed=b.debounce(g),n.my()._recalc=x.debounce(g),n.bind(t,function(e){e.type==V&&e.stopPropagation(),a&&(j.locktill=Date.now()+s.delay),n.my()._changed(n,o,s,k)}),/check(\.my)?/.test(t+"")||n.on("check.my",function(){return n.my()._changed(n,o,s,k,!0),!1}),n.on("recalc.my, redraw.my",function(e){e.stopPropagation(),n.my()._recalc(n,o,s,k)})}),C&&C.resolve()}var h,p,v,g,j=o.my(),k=(j||{}).params,O=s,C=null,q=0,z=j.manifest;return j?(g=s.delay,i.size()?(O.init!=U&&(h=w(z,O.init,i,j)),it(h)?(q+=1,C=e.Deferred(),h.then(c,function(e,t){u("Init of "+l+" failed: "+e,t)})):c()):r("Not found "+l+" selector.",o),C):(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?U:u(s,U),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):U,r.recalcDepth||i.recalcDepth)}}function w(e,t,r,i){var a;if(Y(t)){if(a=n(e,t),void 0===a)return r.html(t.assign(i.data)),null}else a=t;if(rt(a))return a.apply(e,Array.prototype.slice.call(arguments,2));if(X(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="";(n||!/^(data|files|require)$/.test(e))&&(i=r[e],s=P(i),/^(ob|ar)/.test(s)?j(i):"string"===s&&/^(function\s*\(|new\sRegExp)/.test(i)&&((a=i.match(/^function\s*\(([^\)]*)\)\s*\{([\s\S]*)\}[\s\n\r\t]*$/))&&3===a.length?(o=O(a[1],a[2]),"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 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){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=Z(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&&(Y(a.recalc)?c=a.recalc.split(d):X(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(Y(a.watch)?u=a.watch.split(d):X(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+"}"))),X(f)&&f.length)for(l=0;le?"0"+e:e}function t(e,i,a){var o,s,l,c,u=0,d=i||0,f=r;switch(a&&Y(a)&&(u=String(a).length,f=String(a).repeat(10)),(typeof e).substr(0,3)){case"str":return n(e);case"num":return isFinite(e)?""+String(e):"null";case"boo":case"nul":return String(e);case"fun":return n(e.toString().replace(/^(function)([^\(]*)(\([^\)]*)([\n\t][^)]*)(\).*)/,"$1 $3$5").replace(/(})([^}]*$)/,"$1"));case"obj":if(!e)return"null";if(typeof e.toJSON===W)return t(e.toJSON(),d+(a?1:0),a);if(o=[],X(e)){for(s=0;sl;l++)s[l]=i.charCodeAt(l);return n=new Blob([s],{type:r||"application/octet-stream"}),rt(t)?void t(n):n},base64:function(t,r,n){var i=(P(t),null),a=Y(t)?t:e.my.tojson(t),o=Y(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 S,T="jQuery.my 1.1.6",M=window.URL||window.webkitURL,E=!document.addEventListener,R=n(e,"my.f.repo")?e.my.f.repo():{_src:{},_name:"Default manifest cache"},$=n(e,"my.f.restyles")?e.my.f.restyles():{},I=e.extend,P=e.type,U=null,F=function(e){return null!==e&&void 0!==e},L="{yyyy}-{MM}-{dd}",A="{HH}:{mm}",H="object",J="data",B="array",Q="string",W="function",V="change",K=/^this\./,X=Object.isArray,G=Object.isBoolean,Y=Object.isString,Z=Object.isObject,et=Object.isNumber,tt=Object.isRegExp,rt=Object.isFunction,nt=Object.keys,it=function(e){return!!(null!=e&&(Z(e)||e.jquery)&&rt(e.then)&&rt(e.fail)&&rt(e.state))},at=function(e,t){var r,i;return Y(e)?(r=e,i=n(Z(t)?t:R,r),"exist"===t?Z(i):i?Object.clone(i,!0):null):Z(e)?(i=o(e,t),Z(i)?i:null):void 0===e?R._src:null===e?Object.reject(R,/^_/):null},ot=e.ajax,st={vals:{".my-form":function(e,t){if(e&&e.my){var r=e.my(J);return Object.equal(r,t)?r:e.my(J,t,!0)}return t||U},".hasDatepicker":function(e,t){F(t)&&e.datepicker("setDate",""==t?t:Date.create(t));var r=e.datepicker("getDate");return r?r.format(L):""},".my-tags":function(e,t){return F(t)&&(Y(t)||et(t)?e.tags(J,[t+""]):X(t)&&e.tags(J,t)),e.tags(J)},".ui-draggable":function(e,t){if(F(t)&&Z(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||lt.sdbmCode,x=p.id||lt.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(F(r)&&X(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(F(r)&&X(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==U&&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(F(t))return r=""!=t?Date.create(t).format(L):"",Y(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(L):""},"input[type=time]":function(e,t){if(F(t))return r=""!=t?Date.create(t).format(A):"",Y(r)&&!/Invalid/.test(r)&&e.val(r),r;var r=e.val();return""!=r?Date.create(r).format(A):""},input:{"[type='text'],[type='number'],[type='search'],[type='hidden'],[type='password'],[type='button'],[type='range'],:not([type])":{".ui-slider-input":function(e,t){F(t)&&e.val(t).slider("refresh")},".tagstrip input.value":function(e,t){F(t)&&e.val(t).trigger("update")},"div.select2-container+input":function(e,t){return F(t)&&JSON.stringify(t)!==JSON.stringify(e.select2("val"))&&e.select2("val",X(t)?t:[t]),e.select2("val")},"":function(e,t){F(t)&&e.val(t+"")}},":radio":function(t,r){var n=-1;if(F(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:S},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 d(e,st.containers)(e)},change:U,recalcDepth:2,delay:0,strict:!1,restyle:-1,locale:S=(navigator.language||navigator.userLanguage||"en").substr(0,2),messages:Object.map(st.msg,function(e,t){return t[S]||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=N(),ct={init:function(i,a,o){function c(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)||Y(l[t])?I(!0,P,lt.unmask(s,Y(l[t])?l[t]:t)):e[t]=s))}function d(){var e,r;for(var e in G)for(r in E[e].listen)G[e].addClass("my-listen-"+lt.sdbmCode(r));V.radio&&dt.on("radio.my",function(e,r){var n,i;if(Z(r)&&r.channel&&r.message&&rt(V.radio[r.channel])){n=V.radio[r.channel];try{i=n.call(V,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(P,!0),V=I(!0,V,Object.reject(P,["data"])),E=q(I(!0,{},P.ui||{}),V,R),V.radio&&(V.radio=z(V.radio)),V.expose&&(V.expose=D(V.expose)),N=Number.random(268435456,4294967295).toString(16),C=P.id||"my"+N,S=lt.sdbmCode(C),V.id=C,R.form=dt,P.params&&P.params.depth&&(R.recalcDepth=P.params.depth);for(F in V)rt(V[F])&&(V[F]=V[F].bind(V));P.error&&(Y(P.error)?nt=function(e,t){return P.error.assign(I({message:e+"",err:t+""},P))}:rt(P.error)&&(nt=function(e,t){T=null;try{T=P.error(e,t)}catch(r){T=R.messages.initFailed}return T})),I(dt.data("my"),{id:C,cid:N,mid:S,errors:Object.extended(),ui:Object.extended(E),disabled:!1,manifest:V,locFiles:[],modals:{},radio:{}}),dt.addClass("my-form"),A="my-manifest-"+S,H="my-form-"+N,dt.addClass(H+" "+A)}function h(t){function r(e,t){return'"}V.style&&(L=_(dt,V,A,H),L&&L[0].length&&!t&&(B=e("style#"+A),B.size()||(B=e(r(L[0],A)).appendTo(e("body"))),B.data("count",1*B.data("count")+1),dt.data("my").style=B),L&&L[1].length&&(Q=e("style#"+H),Q.size()?t&&(e(r(L[1],H)).replaceAll(Q),Q=e("style#"+H)):(Q=e(r(L[1],H)).appendTo(e("body")),R.restyle>-1&&!$[N]&&($[N]=function(){h(!0)}.debounce(R.restyle)),dt.data("my").restyle=h.fill(!0).debounce(0)),dt.data("my").localStyle=Q))}function p(){var t,r,n=e.Deferred();if(r=s(V),Y(r))x("Error decoding base64 to local Blob/URL",r),n.reject();else{if(M)for(t=0;t*").clone();try{W=w(V,P.init,dt,P)}catch(t){return x(Y(t)?t:t.message,t.stack),dt}}if(it(W)?W.then(function(){v()},function(e,t){x(e,t)}):v(),!tt){if(!dt.my())return x("Internal error initializing controls",""),dt;dt.data("my").initial=I(!0,{},K),e.mobile&&e.mobile.changePage(e.mobile.activePage)}}function v(){function e(e){tt||(t[e]=u(dt.find(e),U),r-=1,.5>r&&b(t))}var t={},r=Object.size(E);dt.addClass(ot),Object.each(E,function(t){if(!tt){var r=dt.find(t),n=g(r,dt,E[t],t);it(n)?n.then(e.fill(t)).fail(function(e,r){x("Error building "+t+", "+e,r)}):tt||e(t)}})}function b(e){var r,n,i;for(var a in E){if(tt)return;if(r=E[a],i=dt.find(a),i.size()){r.listen&&(G[a]=i.eq(0));try{n=f(K,U,r,i),n==U&&e[a]!=U&&void 0!==n&&f(K,e[a],r,i)}catch(o){t("Transient fail linking "+a+" of form $('.my-form-"+N+"')",o.message,o.stack)}try{n!=U&&u(i,n),i.eq(0).trigger("check.my")}catch(o){x("Error linking "+a,o.message,o.stack)}}}dt.removeClass(ot),ut=null,et.resolve(K)}function x(e,r){var n;if(tt=!0,t("Form "+C+" failed to initialize",e,r),dt.removeClass(ot),n=nt(e,r),Y(n)||Z(n)&&n.jquery?dt.html(n):n===!0&&dt.html(ut),R.silent)et.resolve(K);else{if(!dt.my().ddata){if(dt.removeData("my"),dt.removeClass("my-form"),B)if("1"==B.data("count"))try{B.remove()}catch(i){}else B.data("count",B.data("count")-1);if(Q)try{delete $[N],Q.remove()}catch(i){}}et.reject("Form "+C+" failed to initialize: "+e,r)}}var k,O,C,N,S,T,E,R,P,F,L,A,H,B,Q,W,V={},K={},X=[],G={},et=e.Deferred(),tt=!1,nt=function(){},ot="my-form-init",ct="std",ut="";if(Y(i)){if(k=at(i),!k)return et.reject("No manifest with id "+i+" found in repo."),et.promise();Z(o)&&Z(a)?(k=I(k,a),O=o):O=a,ct="repo"}else k=i,O=a;if(!k)return this;P=Z(O)&&"repo"!=ct?I(!0,{},k):k;var dt=this.eq(0),ft=dt.my();return Z(ft)&&ft.id&&ft.ui?(r("jQuery.my is already bind.",dt),dt.my("ui",P.ui),dt.my(J,P.data),et.resolve(dt.my(J)).promise()):(R=P.params||{},R.strict||(R=I(!0,{},R),j(R)),R=I(!0,{},st.params,R),et.fail(function(){dt.removeClass(H+" "+A)}),I(dt,et.promise()),Z(O)?(K=lt.patch(O,P.data||{}),P.data=K):K=P.data||{},V.data=K,dt.data("my",{data:K,params:R,promise:et.promise(),locktill:0}),dt.addClass(ot),P.inherit&&c(P),lt.require(P,R).then(function(){m(),p().then(function(){h(),y()})}).fail(function(e){m(),x("Linker of ‘require’ property failed.",e)}),et.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?U: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(V)),r},data:function(e,t){var r=this;return Z(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]&&Y(t[n])&&(r[n]=t[n]),Z(t[n])&&nt(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]&&Y(t[n])?r++:Z(t[n])&&nt(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(Y(e))return at(e,t);var r=this.my();return r&&r.id?r.id:U},remove:function(e){var t,r,n,i,a,o,s,l,c=this;if(!this.my())return U;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"),Z(n)&&n.manifest&&rt(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 $[s],r.remove()}catch(u){}if(window.URL&&(i=n.locFiles)&&i.length)for(var f=0;fo?U:(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&&(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 U;I(!0,{},n.ui);if(!Z(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}/>',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%",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(30,65,100,0.8)"})):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.5)","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(30,65,100,0.8)"})}.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")&&(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()),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); diff --git a/my.jquery.json b/my.jquery.json index 16540f9..2bc35f9 100644 --- a/my.jquery.json +++ b/my.jquery.json @@ -5,7 +5,7 @@ "keywords": [ "MVVM", "framework", "ui", "form", "validation", "data binding" ], - "version": "1.1.4", + "version": "1.1.6", "author": { "name": "ermouth", "url": "https://github.com/ermouth" diff --git a/package.json b/package.json index 733788b..eaecaa1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquerymy", - "version": "1.1.4", + "version": "1.1.6", "description": "A lightweight jQuery plugin for complex two-way data binding in real time.", "homepage": "http://jquerymy.com/", "author": "ermouth ",