-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbinding.min.js
1 lines (1 loc) · 5.1 KB
/
binding.min.js
1
function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,n){if(e){if("string"==typeof e)return _arrayLikeToArray(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,n):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function _defineProperty(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}!function(e){"use strict";var n=function(){var e,n,t,r,o="__iqdb",a="model",i="bindings",c="watchers",u="el",f="attrs",d="changer",l="value",p={dataset:"^data-",variable:"([^{}]+)",obj:"{ *?([^{}]+) *?}"},y={bindIncomplete:{cc:"iqBindIncomplete",dash:"data-iq-bind-incomplete"},bindTo:{cc:"iqBindTo",dash:"data-iq-bind-to"},bind:{cc:"iqBind",dash:"data-iq-bind"},bindComplete:{cc:"iqBindComplete",dash:"data-iq-bind-complete"}},s={"input:not([type=checkbox])":(e={},_defineProperty(e,d,["change","input"]),_defineProperty(e,l,"value"),e),"input[type=checkbox]":(n={},_defineProperty(n,d,["change","input"]),_defineProperty(n,l,"checked"),n),textarea:(t={},_defineProperty(t,d,["change","input"]),_defineProperty(t,l,"value"),t),"[contenteditable]":(r={},_defineProperty(r,d,["change","input"]),_defineProperty(r,l,"textContent"),r)},b=function(e){return e.filter((function(e){return e}))},h=function(e){return"string"==typeof e||"boolean"==typeof e?e:JSON.stringify(e,null,2)},m={};function v(e,n){try{Object.defineProperty(e,n,{get:function(){return e[o][n][a]},set:function(t){var r=_(e,n);!function(e,n,t){e[o][n][a]=t}(e,n,t),A(e,n,t),function(e,n,t,r){t!==r&&e[o][n][c].forEach((function(e){e(t,r)}))}(e,n,t,r)}})}catch(e){}}function _(e,n){return e[o][n][a]}function A(e,n,t){null==t&&(t=""),e[o][n][i].forEach((function(e){e[f].forEach((function(n){var r=e[u];if(new RegExp(p.dataset).test(n)){var o=n.replace(new RegExp(p.dataset),"");r.dataset[o]!==t&&(r.dataset[o]=h(t))}else r[n]!==t&&(r[n]=h(t))}))}))}function g(e){var n=new RegExp(p.obj,"g"),t=e.innerHTML;t=t.replace(n,(function(n){var t=function(e,n){return Array.from(n.querySelectorAll("*")).find((function(n){return!n.firstElementChild&&n.textContent===e}))||n}(n,e);return y.bindIncomplete.cc in t.dataset?n:"<span ".concat(y.bindIncomplete.dash,">").concat(n,"</span>")})),e.innerHTML!==t&&(e.innerHTML=t)}function P(e,n){var t,r,i=new RegExp(n,"g").exec(e)[1].trim().split("."),c=(t=i.shift(),m[t]),u=c;return void 0!==c&&i.forEach((function(e,n){n<i.length-1?u=u[e]||u[o][e][a]:r=e})),{obj:u,prop:r}}function T(e,n,t,r){t=Array.isArray(t)?t:b([t]),r=Array.isArray(r)?r:b([r]),function(e){e.hasOwnProperty(o)||(e[o]={})}(e),function(e,n){var t;e[o].hasOwnProperty(n)||(e[o][n]=(_defineProperty(t={},a,e[n]),_defineProperty(t,i,[]),_defineProperty(t,c,[]),t))}(e,n),function(e,n,t){var r=e[o][n];t.forEach((function(t){var o=r[i].find((function(e){return e[u]===t[u]}));if(o){var a;t[f]=t[f].filter((function(e){return!~o[f].indexOf(e)})),(a=o[f]).push.apply(a,_toConsumableArray(t[f]))}else{r[i]=r[i].concat(t);var c=Object.keys(s).find((function(e){return Array.from(document.querySelectorAll(e)).some((function(e){return e===t[u]}))}));c&&s[c][d].forEach((function(r){t[u].addEventListener(r,(function(){e[n]=t[u][s[c][l]]}))}))}}))}(e,n,t),function(e,n,t){var r,a=e[o][n];a[c]=(r=a[c]).concat.apply(r,_toConsumableArray(t))}(e,n,r),v(e,n),A(e,n,_(e,n))}return{bind:T,watch:function(e,n,t){T(e,n,null,t)},model:function(e){Object.keys(e).forEach((function(n){var t,r;t=n,r=e[n],m[t]=r})),"undefined"!=typeof document&&setTimeout((function(){var e;e=document.querySelectorAll("[".concat(y.bindTo.dash,"]")),Array.from(e).forEach((function(e){e.dataset[y.bindTo.cc].split(";").forEach((function(n){var t,r=n.split(":"),o=r[0].split(",");o=o.map((function(e){return e.trim()}));var a=P(r[1],p.variable),i=a.obj,c=a.prop;(i||c)&&T(i,c,(_defineProperty(t={},u,e),_defineProperty(t,f,o),t))}))})),function(){var e=document.querySelectorAll("[".concat(y.bind.dash,"]:not([").concat(y.bindComplete.dash,"])")),n=function(e,n,t){var r;(e||n)&&(T(e,n,(_defineProperty(r={},u,t),_defineProperty(r,f,["innerHTML"]),r)),delete t.dataset[y.bindIncomplete.cc])};Array.from(e).forEach((function(e){if(g(e),""!==e.dataset[y.bind.cc]){var t=P(e.dataset[y.bind.cc],p.variable),r=t.obj,o=t.prop;n(r,o,e)}e.dataset[y.bindComplete.cc]="true"})),e=document.querySelectorAll("[".concat(y.bindIncomplete.dash,"]")),Array.from(e).forEach((function(e){var t=P(e.innerHTML,p.obj),r=t.obj,o=t.prop;n(r,o,e)}))}()}))}}}();e.binding=n}(this.iqwerty=this.iqwerty||{});