omi/dist/omi.min.js

7 lines
39 KiB
JavaScript
Raw Normal View History

2017-02-27 12:55:57 +08:00
/*!
2017-07-01 09:56:39 +08:00
* Omi v1.7.4 By dntzhang
2017-02-27 12:55:57 +08:00
* Github: https://github.com/AlloyTeam/omi
* MIT Licensed.
*/
2017-07-01 09:56:39 +08:00
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Omi=t():e.Omi=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}var i=n(1),o=r(i),a=n(11),s=r(a),l=n(5),u=r(l),c=n(10),d=r(c);s["default"].prefix("o"),o["default"].template=s["default"],o["default"].Store=d["default"],o["default"].Component=u["default"],window.Omi?e.exports=window.Omi:(window.Omi=o["default"],e.exports=o["default"])},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":a(t))&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":a(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function o(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push({key:n,value:e[n]});return t}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s={};s.instances={},s._instanceId=0,s.getInstanceId=function(){return s._instanceId++},s.customTags=[],s.mapping={},s.STYLEPREFIX="omi_style_",s.STYLESCOPEDPREFIX="omi_scoped_",s.style={},s.componentConstructor={},"function"!=typeof Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");e=Object(e);for(var t=1;t<arguments.length;t++){var n=arguments[t];if(null!=n)for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}),function(){var e=Array.prototype.slice;try{e.call(document.documentElement)}catch(t){Array.prototype.slice=function(t,n){if(n="undefined"!=typeof n?n:this.length,"[object Array]"===Object.prototype.toString.call(this))return e.call(this,t,n);var r,i,o=[],a=this.length,s=t||0;s=s>=0?s:a+s;var l=n?n:a;if(n<0&&(l=a+n),i=l-s,i>0)if(o=new Array(i),this.charAt)for(r=0;r<i;r++)o[r]=this.charAt(s+r);else for(r=0;r<i;r++)o[r]=this[s+r];return o}}}();var l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();s.create=function(e,t,a){var u=t,c=s.Component;return arguments.length>2&&(u=a,c=t),s.componentConstructor[e]=function(t){function a(t,i){return n(this,a),this.___omi_constructor_name=e,r(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,t,i))}return i(a,t),l(a,o(u)),a}(c),s.customTags.push(e),s.componentConstructor[e]},s.createStore=function(e){var t=function(t){function a(t,i){return n(this,a),this.data=t,e.methods.install&&e.methods.install.call(this),r(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,t,i))}return i(a,t),l(a,o(e.methods)),a}(s.Store);return new t(e.data,!0)},s.mixIndex=function(e,t){for(var n=e.length,r=t||"index",i=0;i<n;i++){var o=e[i];"object"===("undefined"==typeof o?"undefined":a(o))?o[r]=i:(e[i]={value:o},e[i][r]=i)}return e},s.$=function(e,t){return t?t.querySelector(e):document.querySelector(e)},s.$$=function(e,t){return t?Array.prototype.slice.call(t.querySelectorAll(e)):Array.prototype.slice.call(document.querySelectorAll(e))},s.getClassFromString=function(e){if(e.indexOf(".")!==-1){for(var t=e.split("."),n=t.length,r=window[t[0]],i=1;i<n;i++)r=r[t[i]];return r}return s.componentConstructor[e]},s.makeH
}},{key:"addView",value:function(e){for(var t=!1,n=0,r=this.instances.length;n<r;n++)if(this.instances[n].id===e.id){t=!0;break}t||this.instances.push(e)}},{key:"beReady",value:function(){this.isReady=!0,this.readyHandlers.forEach(function(e){return e()})}},{key:"update",value:function(){this._mergeInstances(),this._mergeSelfInstances(),this.instances.forEach(function(e){return e.update()}),this.updateSelfInstances.forEach(function(e){return e.updateSelf()})}},{key:"_mergeSelfInstances",value:function(){var e=this,t=[];this.updateSelfInstances.forEach(function(n){e._checkSelfUpdateInstance(n)||t.push(n)}),this.updateSelfInstances=t}},{key:"_mergeInstances",value:function(){var e=this,t=[];this.idArr=[],this.instances.forEach(function(t){e.idArr.push(t.id)}),this.instances.forEach(function(n){n.parent?e._isSubInstance(n)||t.push(n):t.push(n)}),this.instances=t}},{key:"_checkSelfUpdateInstance",value:function(e){return this.idArr.indexOf(e.id)!==-1||(e.parent?this._checkSelfUpdateInstance(e.parent):void 0)}},{key:"_isSubInstance",value:function(e){return this.idArr.indexOf(e.parent.id)!==-1||(e.parent.parent?this._isSubInstance(e.parent):void 0)}}]),e}();t["default"]=i},function(e,t,n){var r,i;(function(e){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(){Array.prototype.map||(Array.prototype.map=function(e){for(var t=[],n=0;n<this.length;n++){var r=this[n];[].push(e&&e.call(r,r,n))}return t}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s*|\s*$/g,"")});var o=function(e){for(var t=[],n=0;n<e.length;n++)t.push(e[n]);return t},a=/\{\{([^\}]*)\}\}/g,s="soda",l=new RegExp("^"+s+"-"),u=function(e){return new RegExp("(^|\\s+)"+e+"(\\s+|$)","g")},c=function(e,t){return e.className?void(e.className.match(u(t))||(e.className+=" "+t)):void(e.className=t)},d=function(e){return null!==e&&void 0!==e&&""!==e&&"undefined"!=typeof e},f=function(e,t){k.lastIndex=0;var n=t.replace(k,function(t){return"undefined"==typeof e[t]?t:e[t]});if("true"===t)return!0;if("false"===t)return!1;var r=function i(t,r){var o=r.indexOf(".");if(o>-1){var a=r.substr(0,o);if(r=r.substr(o+1),"undefined"!=typeof e[a]&&C.test(a)&&(a=e[a]),"undefined"!=typeof t[a])return i(t[a],r);var s={name:n,data:e};return L("nullvalue",{type:"nullattr",data:s},s),""}"undefined"!=typeof e[r]&&C.test(r)&&(r=e[r]);var l;if("undefined"!=typeof t[r])l=t[r];else{var s={name:n,data:e};L("nullvalue",{type:"nullvalue",data:s},s),l=""}return l};return r(e,t)},h=/"([^"]*)"|'([^']*)'/g,p=/[a-zA-Z_\$]+[\w\$]*(?:\s*\.\s*(?:[a-zA-Z_\$]+[\w\$]*|\d+))*/g,_=/[a-zA-Z_\$]+[\w\$]*(?:\s*\.\s*(?:[a-zA-Z_\$]+[\w\$]*|\d+))*/,m=/\[([^\[\]]*)\]/g,v=/\[([^\[\]]*)\]/,y=/\|\|/g,g="OR_OPERATOR",b=function(){return"$$"+~~(1e6*Math.random())},S="_$C$_",C=/^_\$C\$_/,k=/_\$C\$_[^\.]+/g,x=function(){return S+~~(1e6*Math.random())},T=function H(e,t){e=e.replace(y,g).split("|");for(var n=0;n<e.length;n++)e[n]=(e[n].replace(new RegExp(g,"g"),"||")||"").trim();var r=e[0]||"",i=e.slice(1);for(r=r.replace(h,function(e,n,r){var i=b();return t[i]=n||r,i});v.test(r);)m.lastIndex=0,r=r.replace(m,function(e,n){var r=x(),i=H(n,t);return t[r]=i,"."+r});r=r.replace(p,function(e){return"getValue(scope,'"+e.trim()+"')"});var o=function s(){var e=i.shift();if(e){for(var e=e.split(":"),t=e.slice(1)||[],n=e[0]||"",o=0;o<t.length;o++)_.test(t[o])&&(t[o]="getValue(scope,'"+t[o]+"')");w[n]&&(t.unshift(r),t=t.join(","),r="sodaFilterMap['"+n+"']("+t+")"),s()}};o();var a=new Function("getValue","sodaFilterMap","return function sodaExp(scope){ return "+r+"}")(f,w);return a(t)},E=function P(e,t){3===e.nodeType&&(e.nodeValue=e.nodeValue.replace(a,function(e,n){return T(n,t)})),e.attributes&&(D.map(function(n){var r=n.name,i=n.opt;e.getAttribute(r)&&e.parentNode&&i.link(t,e,e.attributes)}),[].map.call(e.attributes,function(n){if(!A[n.name])if(l.test(n.name)){var r=n.name.replace(l,"");if(r&&n.value){var i=n.value.replace(a,fun