code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); }
Decodes a base64 string. @param {String} input The string to decode.
safe_add
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
function rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); }
Decodes a base64 string. @param {String} input The string to decode.
rol
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
function str2binb(str) { var bin = []; var mask = 255; for (var i = 0; i < str.length * 8; i += 8) { bin[i>>5] |= (str.charCodeAt(i / 8) & mask) << (24 - i%32); } return bin; }
Decodes a base64 string. @param {String} input The string to decode.
str2binb
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
function binb2str(bin) { var str = ""; var mask = 255; for (var i = 0; i < bin.length * 32; i += 8) { str += String.fromCharCode((bin[i>>5] >>> (24 - i%32)) & mask); } return str; }
Decodes a base64 string. @param {String} input The string to decode.
binb2str
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
function binb2b64(binarray) { var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var str = ""; var triplet, j; for (var i = 0; i < binarray.length * 4; i += 3) { triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16) | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 ) | ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF); for (j = 0; j < 4; j++) { if (i * 8 + j * 6 > binarray.length * 32) { str += "="; } else { str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); } } } return str; }
Decodes a base64 string. @param {String} input The string to decode.
binb2b64
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
safe_add = function (x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); }
Decodes a base64 string. @param {String} input The string to decode.
safe_add
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
bit_rol = function (num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); }
Decodes a base64 string. @param {String} input The string to decode.
bit_rol
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
str2binl = function (str) { var bin = []; for(var i = 0; i < str.length * 8; i += 8) { bin[i>>5] |= (str.charCodeAt(i / 8) & 255) << (i%32); } return bin; }
Decodes a base64 string. @param {String} input The string to decode.
str2binl
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
binl2str = function (bin) { var str = ""; for(var i = 0; i < bin.length * 32; i += 8) { str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & 255); } return str; }
Decodes a base64 string. @param {String} input The string to decode.
binl2str
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
binl2hex = function (binarray) { var hex_tab = "0123456789abcdef"; var str = ""; for(var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); } return str; }
Decodes a base64 string. @param {String} input The string to decode.
binl2hex
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
md5_cmn = function (q, a, b, x, s, t) { return safe_add(bit_rol(safe_add(safe_add(a, q),safe_add(x, t)), s),b); }
Decodes a base64 string. @param {String} input The string to decode.
md5_cmn
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
md5_ff = function (a, b, c, d, x, s, t) { return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); }
Decodes a base64 string. @param {String} input The string to decode.
md5_ff
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
md5_gg = function (a, b, c, d, x, s, t) { return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); }
Decodes a base64 string. @param {String} input The string to decode.
md5_gg
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
md5_hh = function (a, b, c, d, x, s, t) { return md5_cmn(b ^ c ^ d, a, b, x, s, t); }
Decodes a base64 string. @param {String} input The string to decode.
md5_hh
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
md5_ii = function (a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); }
Decodes a base64 string. @param {String} input The string to decode.
md5_ii
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
core_md5 = function (x, len) { /* append padding */ x[len >> 5] |= 0x80 << ((len) % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; var olda, oldb, oldc, oldd; for (var i = 0; i < x.length; i += 16) { olda = a; oldb = b; oldc = c; oldd = d; a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = md5_ff(c, d, a, b, x[i+10], 17, -42063); b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); } return [a, b, c, d]; }
Decodes a base64 string. @param {String} input The string to decode.
core_md5
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
wrapper = function(handlers, elem) { while (handlers.length) { this.deleteHandler(handlers.pop()); } this._sasl_auth1_cb.bind(this)(elem); return false; }
PrivateFunction: _sasl_success_cb _Private_ handler for succesful SASL authentication. Parameters: (XMLElement) elem - The matching stanza. Returns: false to remove the handler.
wrapper
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
sendFunc = function () { req.date = new Date(); if (self._conn.options.customHeaders){ var headers = self._conn.options.customHeaders; for (var header in headers) { if (headers.hasOwnProperty(header)) { req.xhr.setRequestHeader(header, headers[header]); } } } req.xhr.send(req.data); }
PrivateFunction: _processRequest _Private_ function to process a request in the queue. This function takes requests off the queue and sends them and restarts dead requests. Parameters: (Integer) i - The index of the request in the queue.
sendFunc
javascript
dcloudio/mui
examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js
MIT
filterFn = function(fn) { return fn.type === event; }
mui delegate events @param {type} event @param {type} selector @param {type} callback @returns {undefined}
filterFn
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
function update(fn) { return function(value) { var classes = self.className.split(/\s+/), index = classes.indexOf(value); fn(classes, index, value); self.className = classes.join(" "); }; }
mui fixed classList @param {type} document @returns {undefined}
update
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
getDistance = function(p1, p2, props) { if (!props) { props = ['x', 'y']; } var x = p2[props[0]] - p1[props[0]]; var y = p2[props[1]] - p1[props[1]]; return sqrt((x * x) + (y * y)); }
angle @param {type} p1 @param {type} p2 @returns {Number}
getDistance
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
getAngle = function(p1, p2, props) { if (!props) { props = ['x', 'y']; } var x = p2[props[0]] - p1[props[0]]; var y = p2[props[1]] - p1[props[1]]; return atan2(y, x) * 180 / Math.PI; }
rotation @param {Object} start @param {Object} end
getAngle
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
getDirection = function(x, y) { if (x === y) { return ''; } if (abs(x) >= abs(y)) { return x > 0 ? 'left' : 'right'; } return y > 0 ? 'up' : 'down'; }
detect gestures @param {type} event @param {type} touch @returns {undefined}
getDirection
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
getRotation = function(start, end) { var props = ['pageX', 'pageY']; return getAngle(end[1], end[0], props) - getAngle(start[1], start[0], props); }
detect gestures @param {type} event @param {type} touch @returns {undefined}
getRotation
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
handle = function(event, touch) { var session = $.gestures.session; var options = this.options; var now = $.now(); switch (event.type) { case $.EVENT_MOVE: if (now - flickStartTime > 300) { flickStartTime = now; session.flickStart = touch.center; } break; case $.EVENT_END: case $.EVENT_CANCEL: touch.flick = false; if (session.flickStart && options.flickMaxTime > (now - flickStartTime) && touch.distance > options.flickMinDistince) { touch.flick = true; touch.flickTime = now - flickStartTime; touch.flickDistanceX = touch.center.x - session.flickStart.x; touch.flickDistanceY = touch.center.y - session.flickStart.y; $.trigger(session.target, name, touch); $.trigger(session.target, name + touch.direction, touch); } break; } }
mui gesture flick[left|right|up|down] @param {type} $ @param {type} name @returns {undefined}
handle
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
handle = function(event, touch) { var session = $.gestures.session; var options = this.options; switch (event.type) { case $.EVENT_END: if (!touch.isFinal) { return; } var target = session.target; if (!target || (target.disabled || (target.classList && target.classList.contains('mui-disabled')))) { return; } if (touch.distance < options.tapMaxDistance && touch.deltaTime < options.tapMaxTime) { if ($.options.gestureConfig.doubletap && lastTarget && (lastTarget === target)) { //same target if (lastTapTime && (touch.timestamp - lastTapTime) < options.tapMaxInterval) { $.trigger(target, 'doubletap', touch); lastTapTime = $.now(); lastTarget = target; return; } } $.trigger(target, name, touch); lastTapTime = $.now(); lastTarget = target; } break; } }
mui gesture tap and doubleTap @param {type} $ @param {type} name @returns {undefined}
handle
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
handle = function(event, touch) { var session = $.gestures.session; var options = this.options; switch (event.type) { case $.EVENT_START: clearTimeout(timer); timer = setTimeout(function() { $.trigger(session.target, name, touch); }, options.holdTimeout); break; case $.EVENT_MOVE: if (touch.distance > options.holdThreshold) { clearTimeout(timer); } break; case $.EVENT_END: case $.EVENT_CANCEL: clearTimeout(timer); break; } }
mui gesture hold @param {type} $ @param {type} name @returns {undefined}
handle
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
handle = function(event, touch) { var session = $.gestures.session; var options = this.options; switch (event.type) { case $.EVENT_START: if ($.options.gestureConfig.hold) { timer && clearTimeout(timer); timer = setTimeout(function() { touch.hold = true; $.trigger(session.target, name, touch); }, options.holdTimeout); } break; case $.EVENT_MOVE: break; case $.EVENT_END: case $.EVENT_CANCEL: if (timer) { clearTimeout(timer) && (timer = null); $.trigger(session.target, 'release', touch); } break; } }
mui gesture pinch @param {type} $ @param {type} name @returns {undefined}
handle
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
ajaxBeforeSend = function(xhr, settings) { var context = settings.context if(settings.beforeSend.call(context, xhr, settings) === false) { return false; } }
mui ajax @param {type} $ @returns {undefined}
ajaxBeforeSend
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
ajaxSuccess = function(data, xhr, settings) { settings.success.call(settings.context, data, 'success', xhr); ajaxComplete('success', xhr, settings); }
mui ajax @param {type} $ @returns {undefined}
ajaxSuccess
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
ajaxError = function(error, type, xhr, settings) { settings.error.call(settings.context, xhr, type, error); ajaxComplete(type, xhr, settings); }
mui ajax @param {type} $ @returns {undefined}
ajaxError
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
ajaxComplete = function(status, xhr, settings) { settings.complete.call(settings.context, xhr, status); }
mui ajax @param {type} $ @returns {undefined}
ajaxComplete
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
serialize = function(params, obj, traditional, scope) { var type, array = $.isArray(obj), hash = $.isPlainObject(obj); $.each(obj, function(key, value) { type = $.type(value); if(scope) { key = traditional ? scope : scope + '[' + (hash || type === 'object' || type === 'array' ? key : '') + ']'; } // handle data in serializeArray() format if(!scope && array) { params.add(value.name, value.value); } // recurse into nested objects else if(type === "array" || (!traditional && type === "object")) { serialize(params, value, traditional, key); } else { params.add(key, value); } }); }
mui ajax @param {type} $ @returns {undefined}
serialize
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
serializeData = function(options) { if(options.processData && options.data && typeof options.data !== "string") { var contentType = options.contentType; if(!contentType && options.headers) { contentType = options.headers['Content-Type']; } if(contentType && ~contentType.indexOf(jsonType)) { //application/json options.data = JSON.stringify(options.data); } else { options.data = $.param(options.data, options.traditional); } } if(options.data && (!options.type || options.type.toUpperCase() === 'GET')) { options.url = appendQuery(options.url, options.data); options.data = undefined; } }
mui ajax @param {type} $ @returns {undefined}
serializeData
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
appendQuery = function(url, query) { if(query === '') { return url; } return(url + '&' + query).replace(/[&?]{1,2}/, '?'); }
mui ajax @param {type} $ @returns {undefined}
appendQuery
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
mimeToDataType = function(mime) { if(mime) { mime = mime.split(';', 2)[0]; } return mime && (mime === htmlType ? 'html' : mime === jsonType ? 'json' : scriptTypeRE.test(mime) ? 'script' : xmlTypeRE.test(mime) && 'xml') || 'text'; }
mui ajax @param {type} $ @returns {undefined}
mimeToDataType
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
parseArguments = function(url, data, success, dataType) { if($.isFunction(data)) { dataType = success, success = data, data = undefined; } if(!$.isFunction(success)) { dataType = success, success = undefined; } return { url: url, data: data, success: success, dataType: dataType }; }
mui ajax @param {type} $ @returns {undefined}
parseArguments
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
setHeader = function(name, value) { headers[name.toLowerCase()] = [name, value]; }
mui ajax @param {type} $ @returns {undefined}
setHeader
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
findOffCanvasContainer = function(target) { parentNode = target.parentNode; if (parentNode) { if (parentNode.classList.contains(CLASS_OFF_CANVAS_WRAP)) { return parentNode; } else { parentNode = parentNode.parentNode; if (parentNode.classList.contains(CLASS_OFF_CANVAS_WRAP)) { return parentNode; } } } }
Popovers @param {type} $ @param {type} window @param {type} document @param {type} name @param {type} undefined @returns {undefined}
findOffCanvasContainer
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
handle = function(event, target) { if (target.tagName === 'A' && target.hash) { var offcanvas = document.getElementById(target.hash.replace('#', '')); if (offcanvas) { var container = findOffCanvasContainer(offcanvas); if (container) { $.targets._container = container; return offcanvas; } } } return false; }
Popovers @param {type} $ @param {type} window @param {type} document @param {type} name @param {type} undefined @returns {undefined}
handle
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
handle = function(event, target) { var className = target.className || ''; if (typeof className !== 'string') { //svg className(SVGAnimatedString) className = ''; } if (className && ~className.indexOf(CLASS_ACTION)) { if (target.classList.contains('mui-action-back')) { event.preventDefault(); } return target; } return false; }
Popovers @param {type} $ @param {type} window @param {type} document @param {type} name @param {type} undefined @returns {undefined}
handle
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
handle = function(event, target) { if (target.tagName === 'A' && target.hash) { var modal = document.getElementById(target.hash.replace('#', '')); if (modal && modal.classList.contains(CLASS_MODAL)) { return modal; } } return false; }
Popovers @param {type} $ @param {type} window @param {type} document @param {type} name @param {type} undefined @returns {undefined}
handle
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
handle = function(event, target) { if (target.tagName === 'A' && target.hash) { $.targets._popover = document.getElementById(target.hash.replace('#', '')); if ($.targets._popover && $.targets._popover.classList.contains(CLASS_POPOVER)) { return target; } else { $.targets._popover = null; } } return false; }
Popovers @param {type} $ @param {type} window @param {type} document @param {type} name @param {type} undefined @returns {undefined}
handle
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
onPopoverShown = function(e) { this.removeEventListener('webkitTransitionEnd', onPopoverShown); this.addEventListener($.EVENT_MOVE, $.preventDefault); $.trigger(this, 'shown', this); }
Popovers @param {type} $ @param {type} window @param {type} document @param {type} name @param {type} undefined @returns {undefined}
onPopoverShown
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
onPopoverHidden = function(e) { setStyle(this, 'none'); this.removeEventListener('webkitTransitionEnd', onPopoverHidden); this.removeEventListener($.EVENT_MOVE, $.preventDefault); $.trigger(this, 'hidden', this); }
Popovers @param {type} $ @param {type} window @param {type} document @param {type} name @param {type} undefined @returns {undefined}
onPopoverHidden
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
removeBackdrop = function(popover) { backdrop.setAttribute('style', 'opacity:0'); $.targets.popover = $.targets._popover = null; //reset removeBackdropTimer = $.later(function() { if (!popover.classList.contains(CLASS_ACTIVE) && backdrop.parentNode && backdrop.parentNode === document.body) { document.body.removeChild(backdrop); } }, 350); }
Popovers @param {type} $ @param {type} window @param {type} document @param {type} name @param {type} undefined @returns {undefined}
removeBackdrop
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
setStyle = function(popover, display, top, left) { var style = popover.style; if (typeof display !== 'undefined') style.display = display; if (typeof top !== 'undefined') style.top = top + 'px'; if (typeof left !== 'undefined') style.left = left + 'px'; }
segmented-controllers @param {type} $ @param {type} window @param {type} document @param {type} undefined @returns {undefined}
setStyle
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
calPosition = function(popover, anchor, isActionSheet) { if (!popover || !anchor) { return; } if (isActionSheet) { //actionsheet setStyle(popover, 'block') return; } var wWidth = window.innerWidth; var wHeight = window.innerHeight; var pWidth = popover.offsetWidth; var pHeight = popover.offsetHeight; var aWidth = anchor.offsetWidth; var aHeight = anchor.offsetHeight; var offset = $.offset(anchor); var arrow = popover.querySelector('.' + CLASS_POPOVER_ARROW); if (!arrow) { arrow = document.createElement('div'); arrow.className = CLASS_POPOVER_ARROW; popover.appendChild(arrow); } var arrowSize = arrow && arrow.offsetWidth / 2 || 0; var pTop = 0; var pLeft = 0; var diff = 0; var arrowLeft = 0; var defaultPadding = popover.classList.contains(CLASS_ACTION_POPOVER) ? 0 : 5; var position = 'top'; if ((pHeight + arrowSize) < (offset.top - window.pageYOffset)) { //top pTop = offset.top - pHeight - arrowSize; } else if ((pHeight + arrowSize) < (wHeight - (offset.top - window.pageYOffset) - aHeight)) { //bottom position = 'bottom'; pTop = offset.top + aHeight + arrowSize; } else { //middle position = 'middle'; pTop = Math.max((wHeight - pHeight) / 2 + window.pageYOffset, 0); pLeft = Math.max((wWidth - pWidth) / 2 + window.pageXOffset, 0); } if (position === 'top' || position === 'bottom') { pLeft = aWidth / 2 + offset.left - pWidth / 2; diff = pLeft; if (pLeft < defaultPadding) pLeft = defaultPadding; if (pLeft + pWidth > wWidth) pLeft = wWidth - pWidth - defaultPadding; if (arrow) { if (position === 'top') { arrow.classList.add(CLASS_BOTTOM); } else { arrow.classList.remove(CLASS_BOTTOM); } diff = diff - pLeft; arrowLeft = (pWidth / 2 - arrowSize / 2 + diff); arrowLeft = Math.max(Math.min(arrowLeft, pWidth - arrowSize * 2 - 6), 6); arrow.setAttribute('style', 'left:' + arrowLeft + 'px'); } } else if (position === 'middle') { arrow.setAttribute('style', 'display:none'); } setStyle(popover, 'block', pTop, pLeft); }
segmented-controllers @param {type} $ @param {type} window @param {type} document @param {type} undefined @returns {undefined}
calPosition
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
handle = function(event, target) { if (target.classList && target.classList.contains(CLASS_SWITCH)) { return target; } return false; }
Tableviews @param {type} $ @param {type} window @param {type} document @returns {undefined}
handle
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
Toggle = function(element) { this.element = element; this.classList = this.element.classList; this.handle = this.element.querySelector(SELECTOR_SWITCH_HANDLE); this.init(); this.initEvent(); }
Tableviews @param {type} $ @param {type} window @param {type} document @returns {undefined}
Toggle
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
toggleActive = function(isActive) { if (isActive) { if (a) { a.classList.add(CLASS_ACTIVE); } else if (cell) { cell.classList.add(CLASS_ACTIVE); } } else { timer && timer.cancel(); if (a) { a.classList.remove(CLASS_ACTIVE); } else if (cell) { cell.classList.remove(CLASS_ACTIVE); } } }
Tableviews @param {type} $ @param {type} window @param {type} document @returns {undefined}
toggleActive
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
updateTranslate = function() { if (translateX !== lastTranslateX) { if (buttonsRight && buttonsRight.length > 0) { progress = translateX / sliderActionRightWidth; if (translateX < -sliderActionRightWidth) { translateX = -sliderActionRightWidth - Math.pow(-translateX - sliderActionRightWidth, overFactor); } for (var i = 0, len = buttonsRight.length; i < len; i++) { var buttonRight = buttonsRight[i]; if (typeof buttonRight._buttonOffset === 'undefined') { buttonRight._buttonOffset = buttonRight.offsetLeft; } buttonOffset = buttonRight._buttonOffset; setTranslate(buttonRight, (translateX - buttonOffset * (1 + Math.max(progress, -1)))); } } if (buttonsLeft && buttonsLeft.length > 0) { progress = translateX / sliderActionLeftWidth; if (translateX > sliderActionLeftWidth) { translateX = sliderActionLeftWidth + Math.pow(translateX - sliderActionLeftWidth, overFactor); } for (var i = 0, len = buttonsLeft.length; i < len; i++) { var buttonLeft = buttonsLeft[i]; if (typeof buttonLeft._buttonOffset === 'undefined') { buttonLeft._buttonOffset = sliderActionLeftWidth - buttonLeft.offsetLeft - buttonLeft.offsetWidth; } buttonOffset = buttonLeft._buttonOffset; if (buttonsLeft.length > 1) { buttonLeft.style.zIndex = buttonsLeft.length - i; } setTranslate(buttonLeft, (translateX + buttonOffset * (1 - Math.min(progress, 1)))); } } setTranslate(sliderHandle, translateX); lastTranslateX = translateX; } sliderRequestAnimationFrame = requestAnimationFrame(function() { updateTranslate(); }); }
Tableviews @param {type} $ @param {type} window @param {type} document @returns {undefined}
updateTranslate
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
setTranslate = function(element, x) { if (element) { element.style.webkitTransform = 'translate(' + x + 'px,0)'; } }
Tableviews @param {type} $ @param {type} window @param {type} document @returns {undefined}
setTranslate
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
radioOrCheckboxClick = function(event) { var type = event.target && event.target.type || ''; if (type === 'radio' || type === 'checkbox') { return; } var classList = cell.classList; if (classList.contains('mui-radio')) { var input = cell.querySelector('input[type=radio]'); if (input) { // input.click(); if (!input.disabled && !input.readOnly) { input.checked = !input.checked; $.trigger(input, 'change'); } } } else if (classList.contains('mui-checkbox')) { var input = cell.querySelector('input[type=checkbox]'); if (input) { // input.click(); if (!input.disabled && !input.readOnly) { input.checked = !input.checked; $.trigger(input, 'change'); } } } }
Popup(alert,confirm,prompt) @param {Object} $ @param {Object} window @param {Object} document
radioOrCheckboxClick
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
createInput = function(placeholder) { return '<div class="' + CLASS_POPUP_INPUT + '"><input type="text" autofocus placeholder="' + (placeholder || '') + '"/></div>'; }
Popup(alert,confirm,prompt) @param {Object} $ @param {Object} window @param {Object} document
createInput
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
createInner = function(message, title, extra) { return '<div class="' + CLASS_POPUP_INNER + '"><div class="' + CLASS_POPUP_TITLE + '">' + title + '</div><div class="' + CLASS_POPUP_TEXT + '">' + message.replace(/\r\n/g, "<br/>").replace(/\n/g, "<br/>") + '</div>' + (extra || '') + '</div>'; }
Popup(alert,confirm,prompt) @param {Object} $ @param {Object} window @param {Object} document
createInner
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
createButtons = function(btnArray) { var length = btnArray.length; var btns = []; for (var i = 0; i < length; i++) { btns.push('<span class="' + CLASS_POPUP_BUTTON + (i === length - 1 ? (' ' + CLASS_POPUP_BUTTON_BOLD) : '') + '">' + btnArray[i] + '</span>'); } return '<div class="' + CLASS_POPUP_BUTTONS + '">' + btns.join('') + '</div>'; }
Popup(alert,confirm,prompt) @param {Object} $ @param {Object} window @param {Object} document
createButtons
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
removePopupElement = function() { popupElement.parentNode && popupElement.parentNode.removeChild(popupElement); popupElement = null; }
Popup(alert,confirm,prompt) @param {Object} $ @param {Object} window @param {Object} document
removePopupElement
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
closePopup = function() { if (popupStack.length) { popupStack[popupStack.length - 1]['close'](); return true; } else { return false; } }
Input(TODO resize) @param {type} $ @param {type} window @param {type} document @returns {undefined}
closePopup
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
closePopups = function() { while (popupStack.length) { popupStack[popupStack.length - 1]['close'](); } }
Input(TODO resize) @param {type} $ @param {type} window @param {type} document @returns {undefined}
closePopups
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
_findProgressbar = function(container) { container = $(container || 'body'); if (container.length === 0) return; container = container[0]; if (container.classList.contains(CLASS_PROGRESSBAR)) { return container; } var progressbars = container.querySelectorAll(SELECTOR_PROGRESSBAR); if (progressbars) { for (var i = 0, len = progressbars.length; i < len; i++) { var progressbar = progressbars[i]; if (progressbar.parentNode === container) { return progressbar; } } } }
Input(TODO resize) @param {type} $ @param {type} window @param {type} document @returns {undefined}
_findProgressbar
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
showProgressbar = function(container, progress, color) { if (typeof container === 'number') { color = progress; progress = container; container = 'body'; } container = $(container || 'body'); if (container.length === 0) return; container = container[0]; var progressbar; if (container.classList.contains(CLASS_PROGRESSBAR)) { progressbar = container; } else { var progressbars = container.querySelectorAll(SELECTOR_PROGRESSBAR + ':not(.' + CLASS_PROGRESSBAR_OUT + ')'); if (progressbars) { for (var i = 0, len = progressbars.length; i < len; i++) { var _progressbar = progressbars[i]; if (_progressbar.parentNode === container) { progressbar = _progressbar; break; } } } if (!progressbar) { progressbar = document.createElement('span'); progressbar.className = CLASS_PROGRESSBAR + ' ' + CLASS_PROGRESSBAR_IN + (typeof progress !== 'undefined' ? '' : (' ' + CLASS_PROGRESSBAR_INFINITE)) + (color ? (' ' + CLASS_PROGRESSBAR + '-' + color) : ''); if (typeof progress !== 'undefined') { progressbar.innerHTML = '<span></span>'; } container.appendChild(progressbar); } else { progressbar.classList.add(CLASS_PROGRESSBAR_IN); } } if (progress) setProgressbar(container, progress); return progressbar; }
Input(TODO resize) @param {type} $ @param {type} window @param {type} document @returns {undefined}
showProgressbar
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
hideProgressbar = function(container) { var progressbar = _findProgressbar(container); if (!progressbar) { return; } var classList = progressbar.classList; if (!classList.contains(CLASS_PROGRESSBAR_IN) || classList.contains(CLASS_PROGRESSBAR_OUT)) { return; } classList.remove(CLASS_PROGRESSBAR_IN); classList.add(CLASS_PROGRESSBAR_OUT); progressbar.addEventListener('webkitAnimationEnd', function() { progressbar.parentNode && progressbar.parentNode.removeChild(progressbar); progressbar = null; }); return; }
Input(TODO resize) @param {type} $ @param {type} window @param {type} document @returns {undefined}
hideProgressbar
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
setProgressbar = function(container, progress, speed) { if (typeof container === 'number') { speed = progress; progress = container; container = false; } var progressbar = _findProgressbar(container); if (!progressbar || progressbar.classList.contains(CLASS_PROGRESSBAR_INFINITE)) { return; } if (progress) progress = Math.min(Math.max(progress, 0), 100); progressbar.offsetHeight; var span = progressbar.querySelector('span'); if (span) { var style = span.style; style.webkitTransform = 'translate3d(' + (-100 + progress) + '%,0,0)'; if (typeof speed !== 'undefined') { style.webkitTransitionDuration = speed + 'ms'; } else { style.webkitTransitionDuration = ''; } } return progressbar; }
Input(TODO resize) @param {type} $ @param {type} window @param {type} document @returns {undefined}
setProgressbar
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
findRow = function(target) { for (; target && target !== document; target = target.parentNode) { if (target.classList && target.classList.contains(CLASS_INPUT_ROW)) { return target; } } return null; }
Input(TODO resize) @param {type} $ @param {type} window @param {type} document @returns {undefined}
findRow
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
Input = function(element, options) { this.element = element; this.options = options || { actions: 'clear' }; if (~this.options.actions.indexOf('slider')) { //slider this.sliderActionClass = CLASS_TOOLTIP + ' ' + CLASS_HIDDEN; this.sliderActionSelector = SELECTOR_TOOLTIP; } else { //clear,speech,search if (~this.options.actions.indexOf('clear')) { this.clearActionClass = CLASS_ICON + ' ' + CLASS_ICON_CLEAR + ' ' + CLASS_HIDDEN; this.clearActionSelector = SELECTOR_ICON_CLOSE; } if (~this.options.actions.indexOf('speech')) { //only for 5+ this.speechActionClass = CLASS_ICON + ' ' + CLASS_ICON_SPEECH; this.speechActionSelector = SELECTOR_ICON_SPEECH; } if (~this.options.actions.indexOf('search')) { this.searchActionClass = CLASS_PLACEHOLDER; this.searchActionSelector = SELECTOR_PLACEHOLDER; } if (~this.options.actions.indexOf('password')) { this.passwordActionClass = CLASS_ICON + ' ' + CLASS_ICON_PASSWORD; this.passwordActionSelector = SELECTOR_ICON_PASSWORD; } } this.init(); }
Input(TODO resize) @param {type} $ @param {type} window @param {type} document @returns {undefined}
Input
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
Button = function(element, options) { this.element = element; this.options = $.extend({}, defaultOptions, options); if (!this.options.loadingText) { this.options.loadingText = defaultOptions.loadingText; } if (this.options.loadingIcon === null) { this.options.loadingIcon = 'mui-spinner'; if ($.getStyles(this.element, 'color') === 'rgb(255, 255, 255)') { this.options.loadingIcon += ' ' + 'mui-spinner-white'; } } this.isInput = this.element.tagName === 'INPUT'; this.resetHTML = this.isInput ? this.element.value : this.element.innerHTML; this.state = ''; }
Button @param {type} $ @param {type} window @param {type} document @returns {undefined}
Button
javascript
dcloudio/mui
examples/nativeTab/js/mui.js
https://github.com/dcloudio/mui/blob/master/examples/nativeTab/js/mui.js
MIT
handle = function(event, target) { var className = target.className || ''; if (typeof className !== 'string') { //svg className(SVGAnimatedString) className = ''; } if (className && ~className.indexOf(CLASS_ACTION)) { if (target.classList.contains($.className('action-back'))) { event.preventDefault(); } return target; } return false; }
actions @param {type} $ @param {type} name @returns {undefined}
handle
javascript
dcloudio/mui
js/actions.js
https://github.com/dcloudio/mui/blob/master/js/actions.js
MIT
findRow = function(target) { for (; target && target !== document; target = target.parentNode) { if (target.classList && target.classList.contains(CLASS_INPUT_ROW)) { return target; } } return null; }
Input(TODO resize) @param {type} $ @param {type} window @param {type} document @returns {undefined}
findRow
javascript
dcloudio/mui
js/input.plugin.js
https://github.com/dcloudio/mui/blob/master/js/input.plugin.js
MIT
Input = function(element, options) { this.element = element; this.options = options || { actions: 'clear' }; if (~this.options.actions.indexOf('slider')) { //slider this.sliderActionClass = CLASS_TOOLTIP + ' ' + CLASS_HIDDEN; this.sliderActionSelector = SELECTOR_TOOLTIP; } else { //clear,speech,search if (~this.options.actions.indexOf('clear')) { this.clearActionClass = CLASS_ICON + ' ' + CLASS_ICON_CLEAR + ' ' + CLASS_HIDDEN; this.clearActionSelector = SELECTOR_ICON_CLOSE; } if (~this.options.actions.indexOf('speech')) { //only for 5+ this.speechActionClass = CLASS_ICON + ' ' + CLASS_ICON_SPEECH; this.speechActionSelector = SELECTOR_ICON_SPEECH; } if (~this.options.actions.indexOf('search')) { this.searchActionClass = CLASS_PLACEHOLDER; this.searchActionSelector = SELECTOR_PLACEHOLDER; } if (~this.options.actions.indexOf('password')) { this.passwordActionClass = CLASS_ICON + ' ' + CLASS_ICON_PASSWORD; this.passwordActionSelector = SELECTOR_ICON_PASSWORD; } } this.init(); }
Input(TODO resize) @param {type} $ @param {type} window @param {type} document @returns {undefined}
Input
javascript
dcloudio/mui
js/input.plugin.js
https://github.com/dcloudio/mui/blob/master/js/input.plugin.js
MIT
handle = function(event, target) { if (target.tagName === 'A' && target.hash) { var modal = document.getElementById(target.hash.replace('#', '')); if (modal && modal.classList.contains(CLASS_MODAL)) { return modal; } } return false; }
Modals @param {type} $ @param {type} window @param {type} document @param {type} name @returns {undefined}
handle
javascript
dcloudio/mui
js/modals.js
https://github.com/dcloudio/mui/blob/master/js/modals.js
MIT
ajaxBeforeSend = function(xhr, settings) { var context = settings.context if(settings.beforeSend.call(context, xhr, settings) === false) { return false; } }
mui ajax @param {type} $ @returns {undefined}
ajaxBeforeSend
javascript
dcloudio/mui
js/mui.ajax.js
https://github.com/dcloudio/mui/blob/master/js/mui.ajax.js
MIT
ajaxSuccess = function(data, xhr, settings) { settings.success.call(settings.context, data, 'success', xhr); ajaxComplete('success', xhr, settings); }
mui ajax @param {type} $ @returns {undefined}
ajaxSuccess
javascript
dcloudio/mui
js/mui.ajax.js
https://github.com/dcloudio/mui/blob/master/js/mui.ajax.js
MIT
ajaxError = function(error, type, xhr, settings) { settings.error.call(settings.context, xhr, type, error); ajaxComplete(type, xhr, settings); }
mui ajax @param {type} $ @returns {undefined}
ajaxError
javascript
dcloudio/mui
js/mui.ajax.js
https://github.com/dcloudio/mui/blob/master/js/mui.ajax.js
MIT
ajaxComplete = function(status, xhr, settings) { settings.complete.call(settings.context, xhr, status); }
mui ajax @param {type} $ @returns {undefined}
ajaxComplete
javascript
dcloudio/mui
js/mui.ajax.js
https://github.com/dcloudio/mui/blob/master/js/mui.ajax.js
MIT
serialize = function(params, obj, traditional, scope) { var type, array = $.isArray(obj), hash = $.isPlainObject(obj); $.each(obj, function(key, value) { type = $.type(value); if(scope) { key = traditional ? scope : scope + '[' + (hash || type === 'object' || type === 'array' ? key : '') + ']'; } // handle data in serializeArray() format if(!scope && array) { params.add(value.name, value.value); } // recurse into nested objects else if(type === "array" || (!traditional && type === "object")) { serialize(params, value, traditional, key); } else { params.add(key, value); } }); }
mui ajax @param {type} $ @returns {undefined}
serialize
javascript
dcloudio/mui
js/mui.ajax.js
https://github.com/dcloudio/mui/blob/master/js/mui.ajax.js
MIT
serializeData = function(options) { if(options.processData && options.data && typeof options.data !== "string") { var contentType = options.contentType; if(!contentType && options.headers) { contentType = options.headers['Content-Type']; } if(contentType && ~contentType.indexOf(jsonType)) { //application/json options.data = JSON.stringify(options.data); } else { options.data = $.param(options.data, options.traditional); } } if(options.data && (!options.type || options.type.toUpperCase() === 'GET')) { options.url = appendQuery(options.url, options.data); options.data = undefined; } }
mui ajax @param {type} $ @returns {undefined}
serializeData
javascript
dcloudio/mui
js/mui.ajax.js
https://github.com/dcloudio/mui/blob/master/js/mui.ajax.js
MIT
appendQuery = function(url, query) { if(query === '') { return url; } return(url + '&' + query).replace(/[&?]{1,2}/, '?'); }
mui ajax @param {type} $ @returns {undefined}
appendQuery
javascript
dcloudio/mui
js/mui.ajax.js
https://github.com/dcloudio/mui/blob/master/js/mui.ajax.js
MIT
mimeToDataType = function(mime) { if(mime) { mime = mime.split(';', 2)[0]; } return mime && (mime === htmlType ? 'html' : mime === jsonType ? 'json' : scriptTypeRE.test(mime) ? 'script' : xmlTypeRE.test(mime) && 'xml') || 'text'; }
mui ajax @param {type} $ @returns {undefined}
mimeToDataType
javascript
dcloudio/mui
js/mui.ajax.js
https://github.com/dcloudio/mui/blob/master/js/mui.ajax.js
MIT
parseArguments = function(url, data, success, dataType) { if($.isFunction(data)) { dataType = success, success = data, data = undefined; } if(!$.isFunction(success)) { dataType = success, success = undefined; } return { url: url, data: data, success: success, dataType: dataType }; }
mui ajax @param {type} $ @returns {undefined}
parseArguments
javascript
dcloudio/mui
js/mui.ajax.js
https://github.com/dcloudio/mui/blob/master/js/mui.ajax.js
MIT
setHeader = function(name, value) { headers[name.toLowerCase()] = [name, value]; }
mui ajax @param {type} $ @returns {undefined}
setHeader
javascript
dcloudio/mui
js/mui.ajax.js
https://github.com/dcloudio/mui/blob/master/js/mui.ajax.js
MIT
Button = function(element, options) { this.element = element; this.options = $.extend({}, defaultOptions, options); if (!this.options.loadingText) { this.options.loadingText = defaultOptions.loadingText; } if (this.options.loadingIcon === null) { this.options.loadingIcon = $.className('spinner'); if ($.getStyles(this.element, 'color') === 'rgb(255, 255, 255)') { this.options.loadingIcon += ' ' + $.className('spinner-white'); } } this.isInput = this.element.tagName === 'INPUT'; this.resetHTML = this.isInput ? this.element.value : this.element.innerHTML; this.state = ''; }
Button @param {type} $ @param {type} window @param {type} document @returns {undefined}
Button
javascript
dcloudio/mui
js/mui.button.js
https://github.com/dcloudio/mui/blob/master/js/mui.button.js
MIT
function update(fn) { return function(value) { var classes = self.className.split(/\s+/), index = classes.indexOf(value); fn(classes, index, value); self.className = classes.join(" "); }; }
mui fixed classList @param {type} document @returns {undefined}
update
javascript
dcloudio/mui
js/mui.fixed.classlist.js
https://github.com/dcloudio/mui/blob/master/js/mui.fixed.classlist.js
MIT
handle = function(event, touch) { var session = $.gestures.session; var options = this.options; var now = $.now(); switch (event.type) { case $.EVENT_MOVE: if (now - flickStartTime > 300) { flickStartTime = now; session.flickStart = touch.center; } break; case $.EVENT_END: case $.EVENT_CANCEL: touch.flick = false; if (session.flickStart && options.flickMaxTime > (now - flickStartTime) && touch.distance > options.flickMinDistince) { touch.flick = true; touch.flickTime = now - flickStartTime; touch.flickDistanceX = touch.center.x - session.flickStart.x; touch.flickDistanceY = touch.center.y - session.flickStart.y; $.trigger(session.target, name, touch); $.trigger(session.target, name + touch.direction, touch); } break; } }
mui gesture flick[left|right|up|down] @param {type} $ @param {type} name @returns {undefined}
handle
javascript
dcloudio/mui
js/mui.gestures.flick.js
https://github.com/dcloudio/mui/blob/master/js/mui.gestures.flick.js
MIT
handle = function(event, touch) { var session = $.gestures.session; var options = this.options; switch (event.type) { case $.EVENT_START: if ($.options.gestureConfig.hold) { timer && clearTimeout(timer); timer = setTimeout(function() { touch.hold = true; $.trigger(session.target, name, touch); }, options.holdTimeout); } break; case $.EVENT_MOVE: break; case $.EVENT_END: case $.EVENT_CANCEL: if (timer) { clearTimeout(timer) && (timer = null); $.trigger(session.target, 'release', touch); } break; } }
mui gesture hold @param {type} $ @param {type} name @returns {undefined}
handle
javascript
dcloudio/mui
js/mui.gestures.hold.js
https://github.com/dcloudio/mui/blob/master/js/mui.gestures.hold.js
MIT
getDistance = function(p1, p2, props) { if(!props) { props = ['x', 'y']; } var x = p2[props[0]] - p1[props[0]]; var y = p2[props[1]] - p1[props[1]]; return sqrt((x * x) + (y * y)); }
distance @param {type} p1 @param {type} p2 @returns {Number}
getDistance
javascript
dcloudio/mui
js/mui.gestures.js
https://github.com/dcloudio/mui/blob/master/js/mui.gestures.js
MIT
getScale = function(starts, moves) { if(starts.length >= 2 && moves.length >= 2) { var props = ['pageX', 'pageY']; return getDistance(moves[1], moves[0], props) / getDistance(starts[1], starts[0], props); } return 1; }
scale @param {Object} starts @param {Object} moves
getScale
javascript
dcloudio/mui
js/mui.gestures.js
https://github.com/dcloudio/mui/blob/master/js/mui.gestures.js
MIT
getAngle = function(p1, p2, props) { if(!props) { props = ['x', 'y']; } var x = p2[props[0]] - p1[props[0]]; var y = p2[props[1]] - p1[props[1]]; return atan2(y, x) * 180 / Math.PI; }
angle @param {type} p1 @param {type} p2 @returns {Number}
getAngle
javascript
dcloudio/mui
js/mui.gestures.js
https://github.com/dcloudio/mui/blob/master/js/mui.gestures.js
MIT
getRotation = function(start, end) { var props = ['pageX', 'pageY']; return getAngle(end[1], end[0], props) - getAngle(start[1], start[0], props); }
rotation @param {Object} start @param {Object} end
getRotation
javascript
dcloudio/mui
js/mui.gestures.js
https://github.com/dcloudio/mui/blob/master/js/mui.gestures.js
MIT
getVelocity = function(deltaTime, x, y) { return { x: x / deltaTime || 0, y: y / deltaTime || 0 }; }
px per ms @param {Object} deltaTime @param {Object} x @param {Object} y
getVelocity
javascript
dcloudio/mui
js/mui.gestures.js
https://github.com/dcloudio/mui/blob/master/js/mui.gestures.js
MIT
detect = function(event, touch) { if($.gestures.stoped) { return; } $.doAction('gestures', function(index, gesture) { if(!$.gestures.stoped) { if($.options.gestureConfig[gesture.name] !== false) { gesture.handle(event, touch); } } }); }
detect gestures @param {type} event @param {type} touch @returns {undefined}
detect
javascript
dcloudio/mui
js/mui.gestures.js
https://github.com/dcloudio/mui/blob/master/js/mui.gestures.js
MIT
handle = function(event, touch) { var session = $.gestures.session; var options = this.options; switch (event.type) { case $.EVENT_START: clearTimeout(timer); timer = setTimeout(function() { $.trigger(session.target, name, touch); }, options.holdTimeout); break; case $.EVENT_MOVE: if (touch.distance > options.holdThreshold) { clearTimeout(timer); } break; case $.EVENT_END: case $.EVENT_CANCEL: clearTimeout(timer); break; } }
mui gesture longtap @param {type} $ @param {type} name @returns {undefined}
handle
javascript
dcloudio/mui
js/mui.gestures.longtap.js
https://github.com/dcloudio/mui/blob/master/js/mui.gestures.longtap.js
MIT
handle = function(event, touch) { var session = $.gestures.session; var options = this.options; switch (event.type) { case $.EVENT_END: if (!touch.isFinal) { return; } var target = session.target; if (!target || (target.disabled || (target.classList && target.classList.contains($.className('disabled'))))) { return; } if (touch.distance < options.tapMaxDistance && touch.deltaTime < options.tapMaxTime) { if ($.options.gestureConfig.doubletap && lastTarget && (lastTarget === target)) { //same target if (lastTapTime && (touch.timestamp - lastTapTime) < options.tapMaxInterval) { $.trigger(target, 'doubletap', touch); lastTapTime = $.now(); lastTarget = target; return; } } $.trigger(target, name, touch); lastTapTime = $.now(); lastTarget = target; } break; } }
mui gesture tap and doubleTap @param {type} $ @param {type} name @returns {undefined}
handle
javascript
dcloudio/mui
js/mui.gestures.tap.js
https://github.com/dcloudio/mui/blob/master/js/mui.gestures.tap.js
MIT
createCallbackName = function() { return 'mui_jsonp_callback_' + (callbackIndex++); }
MUI JSONP varstion 1.0.0 by Houfeng [email protected]
createCallbackName
javascript
dcloudio/mui
js/mui.jsonp.js
https://github.com/dcloudio/mui/blob/master/js/mui.jsonp.js
MIT
importScript = function(url) { var element = doc.createElement('script'); element.src = url; element.async = true; element.defer = true; container.appendChild(element); return element; }
MUI JSONP varstion 1.0.0 by Houfeng [email protected]
importScript
javascript
dcloudio/mui
js/mui.jsonp.js
https://github.com/dcloudio/mui/blob/master/js/mui.jsonp.js
MIT
convertUrl = function(url, data, jsonpParam, callbacnName) { if (jsonpParam) { url = url.replace(jsonpParam + '=?', jsonpParam + '=' + callbacnName); } else { data['callback'] = callbacnName; } var buffer = []; for (var key in data) { buffer.push(key + '=' + encodeURIComponent(data[key])); } return url + (url.indexOf('?') > -1 ? '&' : '?') + buffer.join('&'); }
MUI JSONP varstion 1.0.0 by Houfeng [email protected]
convertUrl
javascript
dcloudio/mui
js/mui.jsonp.js
https://github.com/dcloudio/mui/blob/master/js/mui.jsonp.js
MIT
getQueryString = function(url) { url = url || location.search; var splitIndex = url.indexOf('?'); var queryString = url.substr(splitIndex + 1); var paramArray = queryString.split('&'); var result = {}; for (var i in paramArray) { var params = paramArray[i].split('='); result[params[0]] = params[1]; } return result; }
MUI JSONP varstion 1.0.0 by Houfeng [email protected]
getQueryString
javascript
dcloudio/mui
js/mui.jsonp.js
https://github.com/dcloudio/mui/blob/master/js/mui.jsonp.js
MIT
getJSONPParam = function(url) { var query = getQueryString(url); for (var name in query) { if (query[name] === '?') { return name; } } return null; }
MUI JSONP varstion 1.0.0 by Houfeng [email protected]
getJSONPParam
javascript
dcloudio/mui
js/mui.jsonp.js
https://github.com/dcloudio/mui/blob/master/js/mui.jsonp.js
MIT
findOffCanvasContainer = function(target) { parentNode = target.parentNode; if (parentNode) { if (parentNode.classList.contains(CLASS_OFF_CANVAS_WRAP)) { return parentNode; } else { parentNode = parentNode.parentNode; if (parentNode.classList.contains(CLASS_OFF_CANVAS_WRAP)) { return parentNode; } } } }
off-canvas @param {type} $ @param {type} window @param {type} document @param {type} action @returns {undefined}
findOffCanvasContainer
javascript
dcloudio/mui
js/mui.offcanvas.js
https://github.com/dcloudio/mui/blob/master/js/mui.offcanvas.js
MIT
handle = function(event, target) { if (target.tagName === 'A' && target.hash) { var offcanvas = document.getElementById(target.hash.replace('#', '')); if (offcanvas) { var container = findOffCanvasContainer(offcanvas); if (container) { $.targets._container = container; return offcanvas; } } } return false; }
off-canvas @param {type} $ @param {type} window @param {type} document @param {type} action @returns {undefined}
handle
javascript
dcloudio/mui
js/mui.offcanvas.js
https://github.com/dcloudio/mui/blob/master/js/mui.offcanvas.js
MIT