1 line
No EOL
11 KiB
JavaScript
1 line
No EOL
11 KiB
JavaScript
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(self,(function(){return function(){var t={9526:function(){!function(t){"use strict";var e=function(t){return t},n=function(e){return t.isArray(e)},r=function(t){return!n(t)&&t instanceof Object},i=function(e,n){return t.inArray(n,e)},u=function(t,e){for(var n in t)t.hasOwnProperty(n)&&e(t[n],n,t)},a=function(t){return t[t.length-1]},c=function(t,e,r){return n(t)?function(t,e){var n=[];return u(t,(function(t,r,i){n.push(e(t,r,i))})),n}(t,e):function(t,e,n){var r={};return u(t,(function(t,i,u){i=n?n(i,t):i,r[i]=e(t,i,u)})),r}(t,e,r)},o=function(t,e,n){return c(t,(function(t,r){return t[e].apply(t,n||[])}))};!function(t){var e=function(t,e){var n,r,a,c=(r={},(n=n||{}).publish=function(t,e){u(r[t],(function(t){t(e)}))},n.subscribe=function(t,e){r[t]=r[t]||[],r[t].push(e)},n.unsubscribe=function(t){u(r,(function(e){var n=i(e,t);-1!==n&&e.splice(n,1)}))},n),o=t.$;return c.getType=function(){throw'implement me (return type. "text", "radio", etc.)'},c.$=function(t){return t?o.find(t):o},c.disable=function(){c.$().prop("disabled",!0),c.publish("isEnabled",!1)},c.enable=function(){c.$().prop("disabled",!1),c.publish("isEnabled",!0)},e.equalTo=function(t,e){return t===e},e.publishChange=function(t,n){var r=c.get();e.equalTo(r,a)||c.publish("change",{e:t,domElement:n}),a=r},c},c=function(t,n){var r=e(t,n);return r.get=function(){return r.$().val()},r.set=function(t){r.$().val(t)},r.clear=function(){r.set("")},n.buildSetter=function(t){return function(e){t.call(r,e)}},r},f=function(t,e){t=n(t)?t:[t],e=n(e)?e:[e];var r=!0;return t.length!==e.length?r=!1:u(t,(function(t){(function(t,e){return-1!==i(t,e)})(e,t)||(r=!1)})),r},s=function(t){var e={},n=c(t,e);return n.getType=function(){return"button"},n.$().on("change",(function(t){e.publishChange(t,this)})),n},p=function(e){var r={},i=c(e,r);return i.getType=function(){return"checkbox"},i.get=function(){var e=[];return i.$().filter(":checked").each((function(){e.push(t(this).val())})),e},i.set=function(e){e=n(e)?e:[e],i.$().each((function(){t(this).prop("checked",!1)})),u(e,(function(t){i.$().filter('[value="'+t+'"]').prop("checked",!0)}))},r.equalTo=f,i.$().change((function(t){r.publishChange(t,this)})),i},l=function(t){var e=x(t,{});return e.getType=function(){return"email"},e},h=function(n){var r={},i=e(n,r);return i.getType=function(){return"file"},i.get=function(){return a(i.$().val().split("\\"))},i.clear=function(){this.$().each((function(){t(this).wrap("<form>").closest("form").get(0).reset(),t(this).unwrap()}))},i.$().change((function(t){r.publishChange(t,this)})),i},d=function(t){var e={},n=c(t,e);return n.getType=function(){return"hidden"},n.$().change((function(t){e.publishChange(t,this)})),n},v=function(n){var r={},i=e(n,r);return i.getType=function(){return"file[multiple]"},i.get=function(){var t,e=i.$().get(0).files||[],n=[];for(t=0;t<(e.length||0);t+=1)n.push(e[t].name);return n},i.clear=function(){this.$().each((function(){t(this).wrap("<form>").closest("form").get(0).reset(),t(this).unwrap()}))},i.$().change((function(t){r.publishChange(t,this)})),i},m=function(t){var e={},r=c(t,e);return r.getType=function(){return"select[multiple]"},r.get=function(){return r.$().val()||[]},r.set=function(t){r.$().val(""===t?[]:n(t)?t:[t])},e.equalTo=f,r.$().change((function(t){e.publishChange(t,this)})),r},g=function(t){var e=x(t,{});return e.getType=function(){return"password"},e},y=function(e){var n={},r=c(e,n);return r.getType=function(){return"radio"},r.get=function(){return r.$().filter(":checked").val()||null},r.set=function(e){e?r.$().filter('[value="'+e+'"]').prop("checked",!0):r.$().each((function(){t(this).prop("checked",!1)}))},r.$().change((function(t){n.publishChange(t,this)})),r},b=function(t){var e={},n=c(t,e);return n.getType=function(){return"range"},n.$().change((function(t){e.publishChange(t,this)})),n},$=function(t){var e={},n=c(t,e);return n.getType=function(){return"select"},n.$().change((function(t){e.publishChange(t,this)})),n},x=function(t){var e={},n=c(t,e);return n.getType=function(){return"text"},n.$().on("change keyup keydown",(function(t){e.publishChange(t,this)})),n},k=function(t){var e={},n=c(t,e);return n.getType=function(){return"textarea"},n.$().on("change keyup keydown",(function(t){e.publishChange(t,this)})),n},T=function(t){var e=x(t,{});return e.getType=function(){return"url"},e},w=function(e){var n={},a=e.$,c=e.constructorOverride||{button:s,text:x,url:T,email:l,password:g,range:b,textarea:k,select:$,"select[multiple]":m,radio:y,checkbox:p,file:h,"file[multiple]":v,hidden:d},o=function(e,i){(r(i)?i:a.find(i)).each((function(){var r=t(this).attr("name");n[r]=c[e]({$:t(this)})}))},f=function(e,o){var f=[],s=r(o)?o:a.find(o);r(o)?n[s.attr("name")]=c[e]({$:s}):(s.each((function(){-1===i(f,t(this).attr("name"))&&f.push(t(this).attr("name"))})),u(f,(function(t){n[t]=c[e]({$:a.find('input[name="'+t+'"]')})})))};return a.is("input, select, textarea")?a.is('input[type="button"], button, input[type="submit"]')?o("button",a):a.is("textarea")?o("textarea",a):a.is('input[type="text"]')||a.is("input")&&!a.attr("type")?o("text",a):a.is('input[type="password"]')?o("password",a):a.is('input[type="email"]')?o("email",a):a.is('input[type="url"]')?o("url",a):a.is('input[type="range"]')?o("range",a):a.is("select")?a.is("[multiple]")?o("select[multiple]",a):o("select",a):a.is('input[type="file"]')?a.is("[multiple]")?o("file[multiple]",a):o("file",a):a.is('input[type="hidden"]')?o("hidden",a):a.is('input[type="radio"]')?f("radio",a):a.is('input[type="checkbox"]')?f("checkbox",a):o("text",a):(o("button",'input[type="button"], button, input[type="submit"]'),o("text",'input[type="text"]'),o("password",'input[type="password"]'),o("email",'input[type="email"]'),o("url",'input[type="url"]'),o("range",'input[type="range"]'),o("textarea","textarea"),o("select","select:not([multiple])"),o("select[multiple]","select[multiple]"),o("file",'input[type="file"]:not([multiple])'),o("file[multiple]",'input[type="file"][multiple]'),o("hidden",'input[type="hidden"]'),f("radio",'input[type="radio"]'),f("checkbox",'input[type="checkbox"]')),n};t.fn.inputVal=function(e){var n=t(this),r=w({$:n});return n.is("input, textarea, select")?void 0===e?r[n.attr("name")].get():(r[n.attr("name")].set(e),n):void 0===e?o(r,"get"):(u(e,(function(t,e){r[e].set(t)})),n)},t.fn.inputOnChange=function(e){var n=t(this),r=w({$:n});return u(r,(function(t){t.subscribe("change",(function(t){e.call(t.domElement,t.e)}))})),n},t.fn.inputDisable=function(){var e=t(this);return o(w({$:e}),"disable"),e},t.fn.inputEnable=function(){var e=t(this);return o(w({$:e}),"enable"),e},t.fn.inputClear=function(){var e=t(this);return o(w({$:e}),"clear"),e}}(jQuery),t.fn.repeaterVal=function(){var e,n,r=function(t){if(1===t.length&&(0===t[0].key.length||1===t[0].key.length&&!t[0].key[0]))return t[0].val;u(t,(function(t){t.head=t.key.shift()}));var e,n=function(){var e={};return u(t,(function(t){e[t.head]||(e[t.head]=[]),e[t.head].push(t)})),e}();return/^[0-9]+$/.test(t[0].head)?(e=[],u(n,(function(t){e.push(r(t))}))):(e={},u(n,(function(t,n){e[n]=r(t)}))),e};return r((e=t(this).inputVal(),n=[],u(e,(function(t,e){var r=[];"undefined"!==e&&(r.push(e.match(/^[^\[]*/)[0]),r=r.concat(c(e.match(/\[[^\]]*\]/g),(function(t){return t.replace(/[\[\]]/g,"")}))),n.push({val:t,key:r}))})),n))},t.fn.repeater=function(r){var i;return r=r||{},t(this).each((function(){var o=t(this),f=r.show||function(){t(this).show()},s=r.hide||function(t){t()},p=o.find("[data-repeater-list]").first(),l=function(e,n){return e.filter((function(){return!n||0===t(this).closest((e=n,"selector",c(e,(function(t){return t.selector}))).join(",")).length;var e}))},h=function(){return l(p.find("[data-repeater-item]"),r.repeaters)},d=p.find("[data-repeater-item]").first().clone().hide(),v=l(l(t(this).find("[data-repeater-item]"),r.repeaters).first().find("[data-repeater-delete]"),r.repeaters);r.isFirstItemUndeletable&&v&&v.remove();var m=function(){var t=p.data("repeater-list");return r.$parent?r.$parent.data("item-name")+"["+t+"]":t},g=function(e){r.repeaters&&e.each((function(){var e=t(this);u(r.repeaters,(function(t){e.find(t.selector).repeater(function(){var t,e={};return u((t=arguments,Array.prototype.slice.call(t)),(function(t){u(t,(function(t,n){e[n]=t}))})),e}(t,{$parent:e}))}))}))},y=function(t,e,n){t&&u(t,(function(t){n.call(e.find(t.selector)[0],t)}))},b=function(e,n,r){e.each((function(e){var i=t(this);i.data("item-name",n+"["+e+"]"),l(i.find("[name]"),r).each((function(){var u=t(this),c=u.attr("name").match(/\[[^\]]+\]/g),o=c?a(c).replace(/\[|\]/g,""):u.attr("name"),f=n+"["+e+"]["+o+"]"+(u.is(":checkbox")||u.attr("multiple")?"[]":"");u.attr("name",f),y(r,i,(function(r){var i=t(this);b(l(i.find("[data-repeater-item]"),r.repeaters||[]),n+"["+e+"]["+i.find("[data-repeater-list]").first().data("repeater-list")+"]",r.repeaters)}))}))})),p.find("input[name][checked]").removeAttr("checked").prop("checked",!0)};b(h(),m(),r.repeaters),g(h()),r.initEmpty&&h().remove(),r.ready&&r.ready((function(){b(h(),m(),r.repeaters)}));var $,x=($=function(i,a,o){if(a||r.defaultValues){var f={};l(i.find("[name]"),o).each((function(){var e=t(this).attr("name").match(/\[([^\]]*)(\]|\]\[\])$/)[1];f[e]=t(this).attr("name")})),i.inputVal(c((s=a||r.defaultValues,p=function(t,e){return f[e]},n(s)?(h=[],u(s,(function(t,e,n){p(0,e)&&h.push(t)}))):(h={},u(s,(function(t,e,n){p(0,e)&&(h[e]=t)}))),h),e,(function(t){return f[t]})))}var s,p,h;y(o,i,(function(e){var n=t(this);l(n.find("[data-repeater-item]"),e.repeaters).each((function(){var r=n.find("[data-repeater-list]").data("repeater-list");if(a&&a[r]){var i=t(this).clone();n.find("[data-repeater-item]").remove(),u(a[r],(function(t){var r=i.clone();$(r,t,e.repeaters||[]),n.find("[data-repeater-list]").append(r)}))}else $(t(this),e.defaultValues,e.repeaters||[])}))}))},function(e,n){p.append(e),b(h(),m(),r.repeaters),e.find("[name]").each((function(){t(this).inputClear()})),$(e,n||r.defaultValues,r.repeaters)}),k=function(t){var e=d.clone();x(e,t),r.repeaters&&g(e),f.call(e.get(0))};i=function(t){h().remove(),u(t,k)},l(o.find("[data-repeater-create]"),r.repeaters).click((function(){k()})),p.on("click","[data-repeater-delete]",(function(){var e=t(this).closest("[data-repeater-item]").get(0);s.call(e,(function(){t(e).remove(),b(h(),m(),r.repeaters)}))}))})),this.setList=i,this}}(jQuery)}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var u=e[r]={exports:{}};return t[r](u,u.exports,n),u.exports}n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return function(){"use strict";n.r(r),n(9526)}(),r}()})); |