cmui-gearbox
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -1,2 +0,2 @@ | ||
/*! Gearbox | MIT | https://github.com/CMUI/gearbox */ | ||
/*! Gearbox | MIT License | https://github.com/CMUI/gearbox */ | ||
!function (window, undefined) { | ||
@@ -26,7 +26,2 @@ // check conflict | ||
/** | ||
* bind a set of apis to a key of `_` as namespace | ||
* @param moduleName {string} | ||
* @param apiSet {object} | ||
*/ | ||
gearbox.__defineModule = function (moduleName, apiSet) { | ||
@@ -49,2 +44,3 @@ if (!moduleName || !_.isString(moduleName) || !apiSet || !_.isObject(apiSet)) return | ||
; | ||
@@ -161,12 +157,2 @@ //////////////////// str //////////////////// | ||
// array of string | ||
str.uniq = str.unique = function (arr) { | ||
if (!_.isArray(arr)) return false | ||
var obj = {} | ||
_.each(arr, function (str) { | ||
obj[String(str)] = null | ||
}) | ||
return _.keys(obj) | ||
} | ||
// more `toNumber` methods | ||
@@ -185,2 +171,3 @@ str.toFloat = function (str) {return parseFloat(str)} | ||
; | ||
@@ -209,2 +196,3 @@ //////////////////// root //////////////////// | ||
; | ||
@@ -372,2 +360,3 @@ //////////////////// ua //////////////////// | ||
; | ||
@@ -460,2 +449,3 @@ //////////////////// url //////////////////// | ||
; | ||
@@ -492,2 +482,3 @@ //////////////////// dom //////////////////// | ||
; | ||
@@ -630,2 +621,3 @@ //////////////////// action //////////////////// | ||
}(window, gearbox) | ||
; | ||
@@ -632,0 +624,0 @@ //////////////////// template //////////////////// |
@@ -1,2 +0,2 @@ | ||
/*! Gearbox | MIT | https://github.com/CMUI/gearbox */ | ||
!function(e,t){if(e.gearbox)return!1;var n=e._,r=e.Zepto||e.jQuery||e.$;if(!n||!r)return!1;var i={},o=e.document;void function(e,t){"use strict";t.__defineModule=function(e,r){e&&n.isString(e)&&r&&n.isObject(r)&&("root"===e?n.each(r,function(e,n){t[n]=e}):t[e]=r)}}(e,i),void function(e,t){"use strict";function r(e){return null==e?"":""+e}function i(e){return 0>e?0:+e||0}function o(e){return null==e?"\\s":e.source?e.source:"["+s.escapeRegExp(e)+"]"}var s={},u=String.prototype.trim,a=String.prototype.trimRight,c=String.prototype.trimLeft;s.escapeRegExp=function(e){return null==e?"":r(e).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")},s.trim=function(e,t){return null==e?"":!t&&u?u.call(e):(t=o(t),r(e).replace(new RegExp("^"+t+"+|"+t+"+$","g"),""))},s.ltrim=function(e,t){return null==e?"":!t&&c?c.call(e):(t=o(t),r(e).replace(new RegExp("^"+t+"+"),""))},s.rtrim=function(e,t){return null==e?"":!t&&a?a.call(e):(t=o(t),r(e).replace(new RegExp(t+"+$"),""))},s.includes=function(e,t,n){return""===t?!0:(n=null==n?0:Math.min(i(n),e.length),-1!==r(e).slice(n).indexOf(t))},s.startsWith=function(e,t,n){return e=r(e),t=""+t,n=null==n?0:Math.min(i(n),e.length),e.lastIndexOf(t,n)===n},s.endsWith=function(e,t,n){return e=r(e),t=""+t,n="undefined"==typeof n?e.length-t.length:Math.min(i(n),e.length)-t.length,n>=0&&e.indexOf(t,n)===n},s.contains=s.includes,s.include=s.includes,s.CNY=s.RMB="¥",s.FULL_WIDTH_CNY=s.FULL_WIDTH_RMB="¥",s.RE_EMAIL=/^(?:[a-z\d]+[_\-\+\.]?)*[a-z\d]+@(?:([a-z\d]+\-?)*[a-z\d]+\.)+([a-z]{2,})+$/i,s.RE_MOBILE=/^1[34578]\d{9}$/,s.RE_POSTCODE=/^\d{6}$/,s.isHash=function(e){return e=t.str.trim(e),t.str.startsWith(e,"#")},s.stripHash=function(e){return e=t.str.trim(e),e=t.str.ltrim(e,"#"),t.str.startsWith(e,"!")&&(e=e.slice(1)),e},s.uniq=s.unique=function(e){if(!n.isArray(e))return!1;var t={};return n.each(e,function(e){t[String(e)]=null}),n.keys(t)},s.toFloat=function(e){return parseFloat(e)},s.toInt=function(e){var t=parseFloat(e);return 0>t?Math.ceil(t):Math.floor(t)},s.toFixed=function(e,n){return t.str.toFloat(t.str.toFloat(e).toFixed(n||0))},t.__defineModule("str",s)}(e,i),void function(e,t){"use strict";var i={$:function(e){var i;return i=n.isElement(e)?e.__$__=e.__$__||r(e):t.dom.is$Element(e)?e:r(e)}};t.__defineModule("root",i)}(e,i),void function(e,t){"use strict";function r(e){var n=e.str.toLowerCase(),r=t.str.includes;if(e.isSafari=/\bapple\b/i.test(navigator.vendor)&&/\bsafari\b/i.test(n),e.isChrome=r(n,"chrome")||r(n,"crios"),e.osVersion="",e.isIOS=/\(i(?:phone|pod|pad)\b/.test(n)||/\bios \d+\./.test(n),e.isIOS)e.isIPad=/\(ipad\b/.test(n),e.isIPod=/\(ipod\b/.test(n),e.isIPhone=/\(iphone\b/.test(n),e.osVersion=(/[\/; i]os[\/: _](\d+(?:[\._]\d+)?)[\._; ]/.exec(n)||[0,""])[1].replace("_",".");else{var o=r(n,"android"),s=/\badr\b/.test(n)&&/\blinux;\s*u;/.test(n),u=/juc\s*\(linux;\s*u;\s*\d+\.\d+/.test(n);e.isAndroid=o||s||u,e.osVersion=s||u?(/\badr[\/: ]?(\d+\.\d)\d*\b/.exec(n)||/\blinux;\s*u;\s*(\d+\.\d)\d*\b/.exec(n)||[0,""])[1]:(/\bandroid(?:_os)?[\/: ]?(\d+\.\d)\d*\b/.exec(n)||[0,""])[1]}r(n,"windows phone")&&(e.isIOS=e.isAndroid=!1,e.osVersion=""),e.osVersion&&!r(e.osVersion,".")&&(e.osVersion+=".0"),e.isMobileDevice=!(!e.isIOS&&!e.isAndroid);var a="";r(n,"micromessenger")?a="wechat":r(n,"ucbrowser")||r(n,"ucweb")||r(n," uc applewebkit")?a="uc":r(n,"baiduhd")||r(n,"baiduboxapp")?a="baidu-app":r(n,"baidubrowser")?a="baidu-browser":r(n,"mqqbrowser")?a="m-qq-browser":r(n,"miuibrowser")?a="miui":r(n,"_weibo_")||r(n," weibo ")?a="weibo":r(n,"firefox")?a="firefox":r(n,"opera")?a="opera":r(n," edge/")?a="edge":r(n,"iemobile")?a="ie-mobile":e.isChrome?(a="chrome",e.isAndroid&&/\bwv\b/.test(n)&&(a="chrome-webview")):e.isSafari&&(a="safari"),"chrome"!==a&&(e.isChrome=!1),"safari"!==a&&(e.isSafari=!1);var c="",d="",l=/chrome[^\d]*([\.\d]*)[ ;\/]/.exec(n);if(l)c="chrome",d=i(l[1]);else{var f=/webkit[^\d]*([\.\d]*)\+*[ ;\/]/.exec(n);f&&(c="webkit",d=i(f[1]))}return c||(r(n,"webkit")?c="webkit":e.isIOS?c="webkit":e.isAndroid&&"m-qq-browser"===a&&(c="webkit"),"firefox"!==a||e.isIOS||(c="gecko"),"opera"===a&&!e.isIOS&&r(n,"presto")&&(c="presto")),"edge"===a?(c="edge",d=""):"ie-mobile"===a&&(c=d=""),e.browser=a,e.engine=c,e.engineVersion=d,e}function i(e,t){var r=e.split(".");return r.length=t||2,n.compact(r).join(".")}var o={};o.isTouchDevice="ontouchstart"in e&&"ontouchmove"in e&&"ontouchend"in e,o.str=navigator.userAgent,r(o),t.__defineModule("ua",o)}(e,i),void function(e,t){"use strict";function i(){return s.search.slice(1)}var o={},s=e.location;o.parseQuery=function(e){var t={};if(e&&n.isString(e)){var r,i,o,s=e.split("&");n.each(s,function(e){r=e.split("="),i=r[0],o=r[1]||"",i&&(t[decodeURIComponent(i).toLowerCase()]=decodeURIComponent(o))})}return t};var u,a=null;o.getParam=function(e){if(!e||!n.isString(e))return!1;if("undefined"==typeof u)u=i();else{var t=i();t!==u&&(a=null,u=t)}return a||(a=this.parseQuery(u)),a[e.toLowerCase()]},o.appendParam=function(e,i){var o="";return e=n.isString(e)?e:"",e=t.url.removeHashFromUrl(e),r.isPlainObject(i)?i=r.param(i):n.isString(i)?(t.str.startsWith(i,"&")||t.str.startsWith(i,"?"))&&(i=i.slice(1)):i=null,o=i?e+(t.str.includes(e,"?")?"&":"?")+i:o,o||!1},o.removeHashFromUrl=function(e){return arguments.length?String(e).split("#")[0]:""},o.getHashFromUrl=function(e){var t=String(e).split("#");return t[0]="",t.join("#")},o.isHash=t.str.isHash,o.stripHash=t.str.stripHash,t.__defineModule("url",o)}(e,i),void function(e,t){"use strict";var i={};i.$win=r(e),i.$root=r(o.documentElement),i.$body=r(o.body),i.is$Element=function(e){if(!e||!n.isObject(e))return!1;var t=!1;if("__proto__"in e)t=e.__proto__===r.fn;else{var i=r.zepto&&r.zepto.Z||r;t=e instanceof i}return t},t.__defineModule("dom",i)}(e,i),void function(e,t){"use strict";var n=function(){function t(e){var t=e.attr("data-action")||"";if(!t){var i=r.trim(e.attr("href"));i&&0===i.indexOf("#")&&(t=i)}return n(t)}function n(e){return e?r.trim(String(e).replace(/^[#!\s]+/,"")):""}function i(){var e=r(o.body||o.documentElement);e.on("click",d,function(e){e.preventDefault();var n=r(this),i=t(n);s(i,this)})}function s(t,n){if(t){var i=l[t];return i&&r.isFunction(i)?i.call(n||e):void 0}}function u(e){r.isPlainObject(e)&&r.each(e,function(e,t){var i=n(e);i&&r.isFunction(t)&&(l[i]=t)})}function a(e,t){return s(n(e),t)}var c={},d="[data-action]",l={};return i(),c.add=u,c.trigger=a,c}();t.__defineModule("action",n)}(e,i),void function(e,t){"use strict";var r=function(){function e(e){return e.replace(/^\s+|\s+$/g,"")}function t(e,t){return e.length>t.length?0===e.indexOf(t):!1}function r(t){return t=t&&n.isString(t)?e(t).replace(/^[#!]+/,""):"",e(t).replace(d,"")}function i(r){return r=r&&n.isString(r)?e(r):"",t(r,d)?r:d+r}function s(t){if(!t)return!1;var n="",r=i(String(t)),s=o.getElementById(r);return s&&(n=e(s.innerHTML)),n}function u(e,t){var n=!1;if(arguments.length<2)return n;if(t){var i=r(e);f[i]&&(f[i]=null),l[i]=String(t),n=!0}return n}function a(e,t){var i="";if(arguments.length<2)return i;var o=r(e),u=f[o],a=l[o];return n.isFunction(u)?i=u(t):a?(u=n.template(a),f[o]=u,i=u(t),l[o]=null):(a=s(o),a&&(u=n.template(a),f[o]=u,i=u(t))),i||""}var c={},d="template-",l={},f={};return c.add=u,c.render=a,c}();t.__defineModule("template",r)}(e,i),e.gearbox=i}(window); | ||
/*! Gearbox | MIT License | https://github.com/CMUI/gearbox */ | ||
!function(e,t){if(e.gearbox)return!1;var r=e._,n=e.Zepto||e.jQuery||e.$;if(!r||!n)return!1;var i={},o=e.document;void function(e,t){"use strict";t.__defineModule=function(e,n){e&&r.isString(e)&&n&&r.isObject(n)&&("root"===e?r.each(n,function(e,r){t[r]=e}):t[e]=n)}}(e,i),void function(e,t){"use strict";function r(e){return null==e?"":""+e}function n(e){return e<0?0:+e||0}function i(e){return null==e?"\\s":e.source?e.source:"["+o.escapeRegExp(e)+"]"}var o={},s=String.prototype.trim,u=String.prototype.trimRight,a=String.prototype.trimLeft;o.escapeRegExp=function(e){return null==e?"":r(e).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")},o.trim=function(e,t){return null==e?"":!t&&s?s.call(e):(t=i(t),r(e).replace(new RegExp("^"+t+"+|"+t+"+$","g"),""))},o.ltrim=function(e,t){return null==e?"":!t&&a?a.call(e):(t=i(t),r(e).replace(new RegExp("^"+t+"+"),""))},o.rtrim=function(e,t){return null==e?"":!t&&u?u.call(e):(t=i(t),r(e).replace(new RegExp(t+"+$"),""))},o.includes=function(e,t,i){return""===t||(i=null==i?0:Math.min(n(i),e.length),r(e).slice(i).indexOf(t)!==-1)},o.startsWith=function(e,t,i){return e=r(e),t=""+t,i=null==i?0:Math.min(n(i),e.length),e.lastIndexOf(t,i)===i},o.endsWith=function(e,t,i){return e=r(e),t=""+t,i="undefined"==typeof i?e.length-t.length:Math.min(n(i),e.length)-t.length,i>=0&&e.indexOf(t,i)===i},o.contains=o.includes,o.include=o.includes,o.CNY=o.RMB="¥",o.FULL_WIDTH_CNY=o.FULL_WIDTH_RMB="¥",o.RE_EMAIL=/^(?:[a-z\d]+[_\-\+\.]?)*[a-z\d]+@(?:([a-z\d]+\-?)*[a-z\d]+\.)+([a-z]{2,})+$/i,o.RE_MOBILE=/^1[34578]\d{9}$/,o.RE_POSTCODE=/^\d{6}$/,o.isHash=function(e){return e=t.str.trim(e),t.str.startsWith(e,"#")},o.stripHash=function(e){return e=t.str.trim(e),e=t.str.ltrim(e,"#"),t.str.startsWith(e,"!")&&(e=e.slice(1)),e},o.toFloat=function(e){return parseFloat(e)},o.toInt=function(e){var t=parseFloat(e);return t<0?Math.ceil(t):Math.floor(t)},o.toFixed=function(e,r){return t.str.toFloat(t.str.toFloat(e).toFixed(r||0))},t.__defineModule("str",o)}(e,i),void function(e,t){"use strict";var i={$:function(e){var i;return i=r.isElement(e)?e.__$__=e.__$__||n(e):t.dom.is$Element(e)?e:n(e)}};t.__defineModule("root",i)}(e,i),void function(e,t){"use strict";function n(e){var r=e.str.toLowerCase(),n=t.str.includes;if(e.isSafari=/\bapple\b/i.test(navigator.vendor)&&/\bsafari\b/i.test(r),e.isChrome=n(r,"chrome")||n(r,"crios"),e.osVersion="",e.isIOS=/\(i(?:phone|pod|pad)\b/.test(r)||/\bios \d+\./.test(r),e.isIOS)e.isIPad=/\(ipad\b/.test(r),e.isIPod=/\(ipod\b/.test(r),e.isIPhone=/\(iphone\b/.test(r),e.osVersion=(/[\/; i]os[\/: _](\d+(?:[\._]\d+)?)[\._; ]/.exec(r)||[0,""])[1].replace("_",".");else{var o=n(r,"android"),s=/\badr\b/.test(r)&&/\blinux;\s*u;/.test(r),u=/juc\s*\(linux;\s*u;\s*\d+\.\d+/.test(r);e.isAndroid=o||s||u,s||u?e.osVersion=(/\badr[\/: ]?(\d+\.\d)\d*\b/.exec(r)||/\blinux;\s*u;\s*(\d+\.\d)\d*\b/.exec(r)||[0,""])[1]:e.osVersion=(/\bandroid(?:_os)?[\/: ]?(\d+\.\d)\d*\b/.exec(r)||[0,""])[1]}n(r,"windows phone")&&(e.isIOS=e.isAndroid=!1,e.osVersion=""),e.osVersion&&!n(e.osVersion,".")&&(e.osVersion+=".0"),e.isMobileDevice=!(!e.isIOS&&!e.isAndroid);var a="";n(r,"micromessenger")?a="wechat":n(r,"ucbrowser")||n(r,"ucweb")||n(r," uc applewebkit")?a="uc":n(r,"baiduhd")||n(r,"baiduboxapp")?a="baidu-app":n(r,"baidubrowser")?a="baidu-browser":n(r,"mqqbrowser")?a="m-qq-browser":n(r,"miuibrowser")?a="miui":n(r,"_weibo_")||n(r," weibo ")?a="weibo":n(r,"firefox")?a="firefox":n(r,"opera")?a="opera":n(r," edge/")?a="edge":n(r,"iemobile")?a="ie-mobile":e.isChrome?(a="chrome",e.isAndroid&&/\bwv\b/.test(r)&&(a="chrome-webview")):e.isSafari&&(a="safari"),"chrome"!==a&&(e.isChrome=!1),"safari"!==a&&(e.isSafari=!1);var c="",d="",l=/chrome[^\d]*([\.\d]*)[ ;\/]/.exec(r);if(l)c="chrome",d=i(l[1]);else{var f=/webkit[^\d]*([\.\d]*)\+*[ ;\/]/.exec(r);f&&(c="webkit",d=i(f[1]))}return c||(n(r,"webkit")?c="webkit":e.isIOS?c="webkit":e.isAndroid&&"m-qq-browser"===a&&(c="webkit"),"firefox"!==a||e.isIOS||(c="gecko"),"opera"===a&&!e.isIOS&&n(r,"presto")&&(c="presto")),"edge"===a?(c="edge",d=""):"ie-mobile"===a&&(c=d=""),e.browser=a,e.engine=c,e.engineVersion=d,e}function i(e,t){var n=e.split(".");return n.length=t||2,r.compact(n).join(".")}var o={};o.isTouchDevice="ontouchstart"in e&&"ontouchmove"in e&&"ontouchend"in e,o.str=navigator.userAgent,n(o),t.__defineModule("ua",o)}(e,i),void function(e,t){"use strict";function i(){return s.search.slice(1)}var o={},s=e.location;o.parseQuery=function(e){var t={};if(e&&r.isString(e)){var n,i,o,s=e.split("&");r.each(s,function(e){n=e.split("="),i=n[0],o=n[1]||"",i&&(t[decodeURIComponent(i).toLowerCase()]=decodeURIComponent(o))})}return t};var u,a=null;o.getParam=function(e){if(!e||!r.isString(e))return!1;if("undefined"==typeof u)u=i();else{var t=i();t!==u&&(a=null,u=t)}return a||(a=this.parseQuery(u)),a[e.toLowerCase()]},o.appendParam=function(e,i){var o="";return e=r.isString(e)?e:"",e=t.url.removeHashFromUrl(e),n.isPlainObject(i)?i=n.param(i):r.isString(i)?(t.str.startsWith(i,"&")||t.str.startsWith(i,"?"))&&(i=i.slice(1)):i=null,o=i?e+(t.str.includes(e,"?")?"&":"?")+i:o,o||!1},o.removeHashFromUrl=function(e){return arguments.length?String(e).split("#")[0]:""},o.getHashFromUrl=function(e){var t=String(e).split("#");return t[0]="",t.join("#")},o.isHash=t.str.isHash,o.stripHash=t.str.stripHash,t.__defineModule("url",o)}(e,i),void function(e,t){"use strict";var i={};i.$win=n(e),i.$root=n(o.documentElement),i.$body=n(o.body),i.is$Element=function(e){if(!e||!r.isObject(e))return!1;var t=!1;if("__proto__"in e)t=e.__proto__===n.fn;else{var i=n.zepto&&n.zepto.Z||n;t=e instanceof i}return t},t.__defineModule("dom",i)}(e,i),void function(e,t){"use strict";var r=function(){function t(e){var t=e.attr("data-action")||"";if(!t){var i=n.trim(e.attr("href"));i&&0===i.indexOf("#")&&(t=i)}return r(t)}function r(e){return e?n.trim(String(e).replace(/^[#!\s]+/,"")):""}function i(){var e=n(o.body||o.documentElement);e.on("click",d,function(e){e.preventDefault();var r=n(this),i=t(r);s(i,this)})}function s(t,r){if(t){var i=l[t];return i&&n.isFunction(i)?i.call(r||e):void 0}}function u(e){n.isPlainObject(e)&&n.each(e,function(e,t){var i=r(e);i&&n.isFunction(t)&&(l[i]=t)})}function a(e,t){return s(r(e),t)}var c={},d="[data-action]",l={};return i(),c.add=u,c.trigger=a,c}();t.__defineModule("action",r)}(e,i),void function(e,t){"use strict";var n=function(){function e(e){return e.replace(/^\s+|\s+$/g,"")}function t(e,t){return e.length>t.length&&0===e.indexOf(t)}function n(t){return t=t&&r.isString(t)?e(t).replace(/^[#!]+/,""):"",e(t).replace(d,"")}function i(n){return n=n&&r.isString(n)?e(n):"",t(n,d)?n:d+n}function s(t){if(!t)return!1;var r="",n=i(String(t)),s=o.getElementById(n);return s&&(r=e(s.innerHTML)),r}function u(e,t){var r=!1;if(arguments.length<2)return r;if(t){var i=n(e);f[i]&&(f[i]=null),l[i]=String(t),r=!0}return r}function a(e,t){var i="";if(arguments.length<2)return i;var o=n(e),u=f[o],a=l[o];return r.isFunction(u)?i=u(t):a?(u=r.template(a),f[o]=u,i=u(t),l[o]=null):(a=s(o),a&&(u=r.template(a),f[o]=u,i=u(t))),i||""}var c={},d="template-",l={},f={};return c.add=u,c.render=a,c}();t.__defineModule("template",n)}(e,i),e.gearbox=i}(window); |
{ | ||
"name": "cmui-gearbox", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"homepage": "https://github.com/CMUI/gearbox", | ||
@@ -15,3 +15,4 @@ "author": "cssmagic <cssmagic.cn@gmail.com>", | ||
"scripts": { | ||
"dist": "gulp prepare-module && gulp", | ||
"dist": "gulp", | ||
"prepublish": "npm run dist", | ||
"test": "echo \"See README.md to run tests in browsers.\" && exit 1" | ||
@@ -24,11 +25,6 @@ }, | ||
"devDependencies": { | ||
"gulp": "3.*", | ||
"del": "1.*", | ||
"gulp-stylus": "2.*", | ||
"gulp-concat": "2.*", | ||
"gulp-rename": "1.*", | ||
"gulp-wrap": "^0.11.0", | ||
"gulp-replace": "^0.5.3", | ||
"gulp-uglify": "1.*" | ||
"gulp": "github:gulpjs/gulp#4.0", | ||
"gulp-stream-to-promise": "^0.1.0", | ||
"gulpfiles": "^0.3.0" | ||
} | ||
} |
@@ -62,4 +62,4 @@ # Gearbox | ||
* `_.action` - [Action](https://github.com/cssmagic/action) | ||
* `_.template` - [Underscore-template](https://github.com/cssmagic/underscore-template) | ||
* `gearbox.action` - [Action](https://github.com/cssmagic/action) | ||
* `gearbox.template` - [Underscore-template](https://github.com/cssmagic/underscore-template) | ||
@@ -66,0 +66,0 @@ #### 构建 |
33485
3
6
731