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 |
---|---|---|---|---|---|---|---|
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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/js/mui.js | MIT |
setHeader = function(name, value) {
headers[name.toLowerCase()] = [name, value];
} | mui ajax
@param {type} $
@returns {undefined} | setHeader | javascript | dcloudio/mui | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/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 | dist/js/mui.js | https://github.com/dcloudio/mui/blob/master/dist/js/mui.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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/js/mui.js | MIT |
setHeader = function(name, value) {
headers[name.toLowerCase()] = [name, value];
} | mui ajax
@param {type} $
@returns {undefined} | setHeader | javascript | dcloudio/mui | examples/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/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/hello-mui/js/mui.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/js/mui.js | MIT |
webviewGroupContext = function(id, webviewOptions, groupContext) {
this.id = id;
this.url = webviewOptions.url;
this.options = webviewOptions;
this.groupContext = groupContext;
this.webview = false;
this.inited = false;
} | @param {Object} id
@param {Object} webviewOptions | webviewGroupContext | javascript | dcloudio/mui | examples/hello-mui/js/webviewGroup.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/js/webviewGroup.js | MIT |
titleUpdate = function() {
setTimeout(function() {
self.webview.endPullToRefresh();
}.bind(this), 1000);
self.webview.removeEventListener('titleUpdate', titleUpdate);
} | @param {Object} id
@param {Object} webviewOptions | titleUpdate | javascript | dcloudio/mui | examples/hello-mui/js/webviewGroup.js | https://github.com/dcloudio/mui/blob/master/examples/hello-mui/js/webviewGroup.js | MIT |
createStandardXHR = function () {
try {
return new window.XMLHttpRequest();
} catch( e ) {
return false;
}
} | Decodes a base64 string.
@param {String}
input The string to decode. | createStandardXHR | javascript | dcloudio/mui | examples/login/libs/easymob-webim-sdk/easemob.im-1.0.5.js | https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/easemob.im-1.0.5.js | MIT |
createActiveXHR = function () {
try {
return new window.ActiveXObject( "Microsoft.XMLHTTP" );
} catch( e ) {
return false;
}
} | Decodes a base64 string.
@param {String}
input The string to decode. | createActiveXHR | javascript | dcloudio/mui | examples/login/libs/easymob-webim-sdk/easemob.im-1.0.5.js | https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/easemob.im-1.0.5.js | MIT |
xmlrequest = function (crossDomain){
crossDomain = crossDomain || true;
var temp = createStandardXHR () || createActiveXHR();
if ("withCredentials" in temp) {
return temp;
}
if(!crossDomain){
return temp;
}
if(window.XDomainRequest===undefined){
return temp;
}
var xhr = new XDomainRequest();
xhr.readyState = 0;
xhr.status = 100;
xhr.onreadystatechange = emptyFn;
xhr.onload = function () {
xhr.readyState = 4;
xhr.status = 200;
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(xhr.responseText);
xhr.responseXML = xmlDoc;
xhr.response = xhr.responseText;
xhr.onreadystatechange();
};
xhr.ontimeout = xhr.onerror = function(){
xhr.readyState = 4;
xhr.status = 500;
xhr.onreadystatechange();
};
return xhr;
} | Decodes a base64 string.
@param {String}
input The string to decode. | xmlrequest | javascript | dcloudio/mui | examples/login/libs/easymob-webim-sdk/easemob.im-1.0.5.js | https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/easemob.im-1.0.5.js | MIT |
function getIEVersion(){
var ua = navigator.userAgent,matches,tridentMap={'4':8,'5':9,'6':10,'7':11};
matches = ua.match(/MSIE (\d+)/i);
if(matches&&matches[1])
{
return +matches[1];
}
matches = ua.match(/Trident\/(\d+)/i);
if(matches&&matches[1])
{
return tridentMap[matches[1]]||null;
}
return null;
} | Decodes a base64 string.
@param {String}
input The string to decode. | getIEVersion | javascript | dcloudio/mui | examples/login/libs/easymob-webim-sdk/easemob.im-1.0.5.js | https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/easemob.im-1.0.5.js | MIT |
getFileUrlFn = function(fileInputId) {
var uri = {
url : '',
filename : '',
filetype : ''
};
if (window.URL && window.URL.createObjectURL) {
var fileItems = document.getElementById(fileInputId).files;
if (fileItems.length > 0) {
var u = fileItems.item(0);
uri.url = window.URL.createObjectURL(u);
uri.filename = u.name || '';
}
} else { // IE
var u = document.getElementById(fileInputId).value;
uri.url = u;
var pos1 = u.lastIndexOf('/');
var pos2 = u.lastIndexOf('\\');
var pos = Math.max(pos1, pos2)
if (pos < 0)
uri.filename = u;
else
uri.filename = u.substring(pos + 1);
}
var index = uri.filename.lastIndexOf(".");
if (index != -1) {
uri.filetype = uri.filename.substring(index+1).toLowerCase();
}
return uri;
} | Decodes a base64 string.
@param {String}
input The string to decode. | getFileUrlFn | javascript | dcloudio/mui | examples/login/libs/easymob-webim-sdk/easemob.im-1.0.5.js | https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/easemob.im-1.0.5.js | MIT |
getFileSizeFn = function(fileInputId){
var file = document.getElementById(fileInputId)
var fileSize = 0;
if(file){
if(file.files){
if(file.files.length>0){
fileSize = file.files[0].size;
}
} else if(isIe){
file.select();
var fileobject = new ActiveXObject ("Scripting.FileSystemObject");
var file = fileobject.GetFile (file.value);
fileSize = file.Size;
}
}
return fileSize;
} | Decodes a base64 string.
@param {String}
input The string to decode. | getFileSizeFn | javascript | dcloudio/mui | examples/login/libs/easymob-webim-sdk/easemob.im-1.0.5.js | https://github.com/dcloudio/mui/blob/master/examples/login/libs/easymob-webim-sdk/easemob.im-1.0.5.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.