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 uniqueId() {
return _uniqueId++;
} | get a unique id
@returns {number} uniqueId | uniqueId | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getWindowForElement(element) {
var doc = element.ownerDocument || element;
return (doc.defaultView || doc.parentWindow || window);
} | get the window object of an element
@param {HTMLElement} element
@returns {DocumentView|Window} | getWindowForElement | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function Input(manager, callback) {
var self = this;
this.manager = manager;
this.callback = callback;
this.element = manager.element;
this.target = manager.options.inputTarget;
// smaller wrapper around the handler, for the scope and the enabled state of the manager,
// so when disabled the input... | create new input type manager
@param {Manager} manager
@param {Function} callback
@returns {Input}
@constructor | Input | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function createInputInstance(manager) {
var Type;
var inputClass = manager.options.inputClass;
if (inputClass) {
Type = inputClass;
} else if (SUPPORT_POINTER_EVENTS) {
Type = PointerEventInput;
} else if (SUPPORT_ONLY_TOUCH) {
Type = TouchInput;
} else if (!SUPPORT_TOUCH) {
Type ... | create new input type manager
called by the Manager constructor
@param {Hammer} manager
@returns {Input} | createInputInstance | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function inputHandler(manager, eventType, input) {
var pointersLen = input.pointers.length;
var changedPointersLen = input.changedPointers.length;
var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
var isFinal = (eventType & (INPUT_END | INPUT_CANCEL) && (pointersLen - chan... | handle input events
@param {Manager} manager
@param {String} eventType
@param {Object} input | inputHandler | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function computeInputData(manager, input) {
var session = manager.session;
var pointers = input.pointers;
var pointersLength = pointers.length;
// store the first input to calculate the distance and direction
if (!session.firstInput) {
session.firstInput = simpleCloneInputData(input);
}
// t... | extend the data with some usable properties like scale, rotate, velocity etc
@param {Object} manager
@param {Object} input | computeInputData | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function computeDeltaXY(session, input) {
var center = input.center;
var offset = session.offsetDelta || {};
var prevDelta = session.prevDelta || {};
var prevInput = session.prevInput || {};
if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
prevDelta = session.prevDelta = ... | extend the data with some usable properties like scale, rotate, velocity etc
@param {Object} manager
@param {Object} input | computeDeltaXY | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function computeIntervalInputData(session, input) {
var last = session.lastInterval || input,
deltaTime = input.timeStamp - last.timeStamp,
velocity, velocityX, velocityY, direction;
if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
var deltaX ... | velocity is calculated every x ms
@param {Object} session
@param {Object} input | computeIntervalInputData | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function simpleCloneInputData(input) {
// make a simple copy of the pointers because we will get a reference if we don't
// we only need clientXY for the calculations
var pointers = [];
var i = 0;
while (i < input.pointers.length) {
pointers[i] = {
clientX: round(input.pointers[i].clientX),
... | create a simple clone from the input used for storage of firstInput and firstMultiple
@param {Object} input
@returns {Object} clonedInputData | simpleCloneInputData | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getCenter(pointers) {
var pointersLength = pointers.length;
// no need to loop when only one touch
if (pointersLength === 1) {
return {
x: round(pointers[0].clientX),
y: round(pointers[0].clientY)
};
}
var x = 0, y = 0, i = 0;
while (i < pointersLength) {
x += p... | get the center of all the pointers
@param {Array} pointers
@return {Object} center contains `x` and `y` properties | getCenter | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getVelocity(deltaTime, x, y) {
return {
x: x / deltaTime || 0,
y: y / deltaTime || 0
};
} | calculate the velocity between two points. unit is in px per ms.
@param {Number} deltaTime
@param {Number} x
@param {Number} y
@return {Object} velocity `x` and `y` | getVelocity | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getDirection(x, y) {
if (x === y) {
return DIRECTION_NONE;
}
if (abs(x) >= abs(y)) {
return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
} | get the direction between two points
@param {Number} x
@param {Number} y
@return {Number} direction | getDirection | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getDistance(p1, p2, props) {
if (!props) {
props = PROPS_XY;
}
var x = p2[props[0]] - p1[props[0]],
y = p2[props[1]] - p1[props[1]];
return Math.sqrt((x * x) + (y * y));
} | calculate the absolute distance between two points
@param {Object} p1 {x, y}
@param {Object} p2 {x, y}
@param {Array} [props] containing x and y keys
@return {Number} distance | getDistance | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getAngle(p1, p2, props) {
if (!props) {
props = PROPS_XY;
}
var x = p2[props[0]] - p1[props[0]],
y = p2[props[1]] - p1[props[1]];
return Math.atan2(y, x) * 180 / Math.PI;
} | calculate the angle between two coordinates
@param {Object} p1
@param {Object} p2
@param {Array} [props] containing x and y keys
@return {Number} angle | getAngle | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getRotation(start, end) {
return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
} | calculate the rotation degrees between two pointersets
@param {Array} start array of pointers
@param {Array} end array of pointers
@return {Number} rotation | getRotation | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getScale(start, end) {
return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
} | calculate the scale factor between two pointersets
no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
@param {Array} start array of pointers
@param {Array} end array of pointers
@return {Number} scale | getScale | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function MouseInput() {
this.evEl = MOUSE_ELEMENT_EVENTS;
this.evWin = MOUSE_WINDOW_EVENTS;
this.pressed = false; // mousedown state
Input.apply(this, arguments);
} | Mouse events input
@constructor
@extends Input | MouseInput | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function PointerEventInput() {
this.evEl = POINTER_ELEMENT_EVENTS;
this.evWin = POINTER_WINDOW_EVENTS;
Input.apply(this, arguments);
this.store = (this.manager.session.pointerEvents = []);
} | Pointer events input
@constructor
@extends Input | PointerEventInput | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function SingleTouchInput() {
this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
this.started = false;
Input.apply(this, arguments);
} | Touch events input
@constructor
@extends Input | SingleTouchInput | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function normalizeSingleTouches(ev, type) {
var all = toArray(ev.touches);
var changed = toArray(ev.changedTouches);
if (type & (INPUT_END | INPUT_CANCEL)) {
all = uniqueArray(all.concat(changed), 'identifier', true);
}
return [all, changed];
} | @this {TouchInput}
@param {Object} ev
@param {Number} type flag
@returns {undefined|Array} [all, changed] | normalizeSingleTouches | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function TouchInput() {
this.evTarget = TOUCH_TARGET_EVENTS;
this.targetIds = {};
Input.apply(this, arguments);
} | Multi-user touch events input
@constructor
@extends Input | TouchInput | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getTouches(ev, type) {
var allTouches = toArray(ev.touches);
var targetIds = this.targetIds;
// when there is only one touch, the process can be simplified
if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
targetIds[allTouches[0].identifier] = true;
return [allTouches, ... | @this {TouchInput}
@param {Object} ev
@param {Number} type flag
@returns {undefined|Array} [all, changed] | getTouches | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function TouchAction(manager, value) {
this.manager = manager;
this.set(value);
} | Touch Action
sets the touchAction property or uses the js alternative
@param {Manager} manager
@param {String} value
@constructor | TouchAction | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function cleanTouchActions(actions) {
// none
if (inStr(actions, TOUCH_ACTION_NONE)) {
return TOUCH_ACTION_NONE;
}
var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
// if both pan-x and pan-y are set (different recognizers
// for different di... | when the touchActions are collected they are not a valid value, so we need to clean things up. *
@param {String} actions
@returns {*} | cleanTouchActions | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getTouchActionProps() {
if (!NATIVE_TOUCH_ACTION) {
return false;
}
var touchMap = {};
var cssSupports = window.CSS && window.CSS.supports;
['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function(val) {
// If css.supports is not supported but there is native... | when the touchActions are collected they are not a valid value, so we need to clean things up. *
@param {String} actions
@returns {*} | getTouchActionProps | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function Recognizer(options) {
this.options = assign({}, this.defaults, options || {});
this.id = uniqueId();
this.manager = null;
// default is enable true
this.options.enable = ifUndefined(this.options.enable, true);
this.state = STATE_POSSIBLE;
this.simultaneous = {};
this.requireFail = ... | Recognizer
Every recognizer needs to extend from this class.
@constructor
@param {Object} options | Recognizer | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function stateStr(state) {
if (state & STATE_CANCELLED) {
return 'cancel';
} else if (state & STATE_ENDED) {
return 'end';
} else if (state & STATE_CHANGED) {
return 'move';
} else if (state & STATE_BEGAN) {
return 'start';
}
return '';
} | get a usable string, used as event postfix
@param {Const} state
@returns {String} state | stateStr | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function directionStr(direction) {
if (direction == DIRECTION_DOWN) {
return 'down';
} else if (direction == DIRECTION_UP) {
return 'up';
} else if (direction == DIRECTION_LEFT) {
return 'left';
} else if (direction == DIRECTION_RIGHT) {
return 'right';
}
return '';
} | direction cons to string
@param {Const} direction
@returns {String} | directionStr | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
var manager = recognizer.manager;
if (manager) {
return manager.get(otherRecognizer);
}
return otherRecognizer;
} | get a recognizer by name if it is bound to a manager
@param {Recognizer|String} otherRecognizer
@param {Recognizer} recognizer
@returns {Recognizer} | getRecognizerByNameIfManager | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function AttrRecognizer() {
Recognizer.apply(this, arguments);
} | This recognizer is just used as a base for the simple attribute recognizers.
@constructor
@extends Recognizer | AttrRecognizer | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function PanRecognizer() {
AttrRecognizer.apply(this, arguments);
this.pX = null;
this.pY = null;
} | Pan
Recognized when the pointer is down and moved in the allowed direction.
@constructor
@extends AttrRecognizer | PanRecognizer | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function PinchRecognizer() {
AttrRecognizer.apply(this, arguments);
} | Pinch
Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
@constructor
@extends AttrRecognizer | PinchRecognizer | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function PressRecognizer() {
Recognizer.apply(this, arguments);
this._timer = null;
this._input = null;
} | Press
Recognized when the pointer is down for x ms without any movement.
@constructor
@extends Recognizer | PressRecognizer | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function RotateRecognizer() {
AttrRecognizer.apply(this, arguments);
} | Rotate
Recognized when two or more pointer are moving in a circular motion.
@constructor
@extends AttrRecognizer | RotateRecognizer | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function SwipeRecognizer() {
AttrRecognizer.apply(this, arguments);
} | Swipe
Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
@constructor
@extends AttrRecognizer | SwipeRecognizer | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function Hammer(element, options) {
options = options || {};
options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
return new Manager(element, options);
} | Simple way to create a manager with a default set of recognizers.
@param {HTMLElement} element
@param {Object} [options]
@constructor | Hammer | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function Manager(element, options) {
this.options = assign({}, Hammer.defaults, options || {});
this.options.inputTarget = this.options.inputTarget || element;
this.handlers = {};
this.session = {};
this.recognizers = [];
this.oldCssProps = {};
this.element = element;
this.input = createInput... | Manager
@param {HTMLElement} element
@param {Object} [options]
@constructor | Manager | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function toggleCssProps(manager, add) {
var element = manager.element;
if (!element.style) {
return;
}
var prop;
each(manager.options.cssProps, function(value, name) {
prop = prefixed(element.style, name);
if (add) {
manager.oldCssProps[prop] = element.style[prop];
element.st... | add/remove the css properties as defined in manager.options.cssProps
@param {Manager} manager
@param {Boolean} add | toggleCssProps | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function triggerDomEvent(event, data) {
var gestureEvent = document.createEvent('Event');
gestureEvent.initEvent(event, true, true);
gestureEvent.gesture = data;
data.target.dispatchEvent(gestureEvent);
} | trigger dom event
@param {String} event
@param {Object} data | triggerDomEvent | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function hammerify(el, options) {
var $el = $(el);
if (!$el.data('hammer')) {
$el.data('hammer', new Hammer($el[0], options));
}
} | trigger dom event
@param {String} event
@param {Object} data | hammerify | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
definePinchZoom = function($) {
/**
* Pinch zoom using jQuery
* @version 0.0.2
* @author Manuel Stofer <mst@rtp.ch>
* @param el
* @param options
* @constructor
*/
var PinchZoom = function(el, options) {
this.el = $(el);
this.zoomFactor = 1;
this.lastScale = 1;
... | Pinch zoom using jQuery
@version 0.0.2
@author Manuel Stofer <mst@rtp.ch>
@param el
@param options
@constructor | definePinchZoom | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
PinchZoom = function(el, options) {
this.el = $(el);
this.zoomFactor = 1;
this.lastScale = 1;
this.offset = {
x: 0,
y: 0
};
this.options = $.extend({}, this.defaults, options);
this.setupMarkup();
this.bindEvents();
this.update();
/... | Pinch zoom using jQuery
@version 0.0.2
@author Manuel Stofer <mst@rtp.ch>
@param el
@param options
@constructor | PinchZoom | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
sum = function(a, b) {
return a + b;
} | Pinch zoom using jQuery
@version 0.0.2
@author Manuel Stofer <mst@rtp.ch>
@param el
@param options
@constructor | sum | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
isCloseTo = function(value, expected) {
return value > expected - 0.01 && value < expected + 0.01;
} | Event handler for 'dragstart'
@param event | isCloseTo | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
work = function() {
setTimeout(function() {
if (!NProgress.status) return;
NProgress.trickle();
work();
}, Settings.trickleSpeed);
} | Hides the progress bar.
This is the *sort of* the same as setting the status to 100%, with the
difference being `done()` makes some placebo effect of some realistic motion.
NProgress.done();
If `true` is passed, it will show the progress bar even if its hidden.
NProgress.done(true); | work | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function clamp(n, min, max) {
if (n < min) return min;
if (n > max) return max;
return n;
} | (Internal) returns the correct CSS for changing the bar's
position given an n percentage, and speed and ease from Settings | clamp | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function toBarPerc(n) {
return (-1 + n) * 100;
} | (Internal) returns the correct CSS for changing the bar's
position given an n percentage, and speed and ease from Settings | toBarPerc | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function barPositionCSS(n, speed, ease) {
var barCSS;
if (Settings.positionUsing === 'translate3d') {
barCSS = { transform: 'translate3d('+toBarPerc(n)+'%,0,0)' };
} else if (Settings.positionUsing === 'translate') {
barCSS = { transform: 'translate('+toBarPerc(n)+'%,0)' };
} else {
... | (Internal) Queues a function to be executed. | barPositionCSS | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function next() {
var fn = pending.shift();
if (fn) {
fn(next);
}
} | (Internal) Applies css properties to an element, similar to the jQuery
css method.
While this helper does assist with vendor prefixed property names, it
does not perform any manipulation of values prior to setting styles. | next | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function camelCase(string) {
return string.replace(/^-ms-/, 'ms-').replace(/-([\da-z])/gi, function(match, letter) {
return letter.toUpperCase();
});
} | (Internal) Applies css properties to an element, similar to the jQuery
css method.
While this helper does assist with vendor prefixed property names, it
does not perform any manipulation of values prior to setting styles. | camelCase | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getVendorProp(name) {
var style = document.body.style;
if (name in style) return name;
var i = cssPrefixes.length,
capName = name.charAt(0).toUpperCase() + name.slice(1),
vendorName;
while (i--) {
vendorName = cssPrefixes[i] + capName;
if (vendor... | (Internal) Applies css properties to an element, similar to the jQuery
css method.
While this helper does assist with vendor prefixed property names, it
does not perform any manipulation of values prior to setting styles. | getVendorProp | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function getStyleProp(name) {
name = camelCase(name);
return cssProps[name] || (cssProps[name] = getVendorProp(name));
} | (Internal) Applies css properties to an element, similar to the jQuery
css method.
While this helper does assist with vendor prefixed property names, it
does not perform any manipulation of values prior to setting styles. | getStyleProp | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function applyCss(element, prop, value) {
prop = getStyleProp(prop);
element.style[prop] = value;
} | (Internal) Determines if an element or space separated list of class names contains a class name. | applyCss | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function hasClass(element, name) {
var list = typeof element == 'string' ? element : classList(element);
return list.indexOf(' ' + name + ' ') >= 0;
} | (Internal) Removes a class from an element. | hasClass | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function addClass(element, name) {
var oldList = classList(element),
newList = oldList + name;
if (hasClass(oldList, name)) return;
// Trim the opening space.
element.className = newList.substring(1);
} | (Internal) Removes a class from an element. | addClass | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function removeClass(element, name) {
var oldList = classList(element),
newList;
if (!hasClass(element, name)) return;
// Replace the class name.
newList = oldList.replace(' ' + name + ' ', ' ');
// Trim the opening and closing spaces.
element.className = newList.substring(1, new... | (Internal) Gets a space separated list of the class names on the element.
The list is wrapped with a single space on each end to facilitate finding
matches within the list. | removeClass | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function removeElement(element) {
element && element.parentNode && element.parentNode.removeChild(element);
} | PureView
@desc Image browser for Mobile
@param element
@param options
@constructor | removeElement | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
PureView = function(element, options) {
this.$element = $(element);
this.$body = $(document.body);
this.options = $.extend({}, PureView.DEFAULTS, options);
this.$pureview = $(this.options.tpl).attr('id',
UI.utils.generateGUID('am-pureview'));
this.$slides = null;
this.transitioning = null;
th... | PureView
@desc Image browser for Mobile
@param element
@param options
@constructor | PureView | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function resetBody() {
this.$pureview.hide();
this.$body.removeClass(options.className.activeBody);
this.resetScrollbar();
} | PureView
@desc Image browser for Mobile
@param element
@param options
@constructor | resetBody | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
SmoothScroll = function(element, options) {
options = options || {};
var $this = $(element);
var targetY = parseInt(options.position) || SmoothScroll.DEFAULTS.position;
var initialY = $this.scrollTop();
var lastY = initialY;
var delta = targetY - initialY;
// duration in ms, make it a bit shorter ... | Smooth Scroll
@param position
@via http://mir.aculo.us/2014/01/19/scrolling-dom-elements-to-the-top-a-zepto-plugin/ | SmoothScroll | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function smooth(pos) {
if ((pos /= 0.5) < 1) {
return 0.5 * Math.pow(pos, 5);
}
return 0.5 * (Math.pow((pos - 2), 5) + 2);
} | Smooth Scroll
@param position
@via http://mir.aculo.us/2014/01/19/scrolling-dom-elements-to-the-top-a-zepto-plugin/ | smooth | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function abort() {
$this.off('touchstart.smoothscroll.amui', cancelScroll);
smoothScrollInProgress = false;
} | Smooth Scroll
@param position
@via http://mir.aculo.us/2014/01/19/scrolling-dom-elements-to-the-top-a-zepto-plugin/ | abort | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function render(now) {
if (!smoothScrollInProgress) {
return;
}
if (!start) {
start = now;
}
// calculate t, position of animation in [0..1]
t = Math.min(1, Math.max((now - start) / speed, 0));
// calculate the new scrollTop position (don't forget to smooth)
y = Ma... | Smooth Scroll
@param position
@via http://mir.aculo.us/2014/01/19/scrolling-dom-elements-to-the-top-a-zepto-plugin/ | render | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
Tabs = function(element, options) {
this.$element = $(element);
this.options = $.extend({}, Tabs.DEFAULTS, options || {});
this.transitioning = this.activeIndex = null;
this.refresh();
this.init();
} | Open $nav tab
@param {jQuery|HTMLElement|Number} $nav
@returns {Tabs} | Tabs | javascript | gongfuxiang/shopxo | public/static/common/lib/assets/js/amazeui.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js | MIT |
function resolve$1(object) {
/*jshint validthis:true */
var Constructor = this;
if (object && typeof object === 'object' && object.constructor === Constructor) {
return object;
}
var promise = new Constructor(noop);
resolve(promise, object);
return pro... | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | resolve$1 | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function selfFulfillment() {
return new TypeError("You cannot resolve a promise with itself");
} | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | selfFulfillment | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function cannotReturnOwn() {
return new TypeError('A promises callback cannot return that same promise.');
} | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | cannotReturnOwn | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {
try {
then$$1.call(value, fulfillmentHandler, rejectionHandler);
}
catch (e) {
return e;
}
} | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | tryThen | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function handleForeignThenable(promise, thenable, then$$1) {
asap(function (promise) {
var sealed = false;
var error = tryThen(then$$1, thenable, function (value) {
if (sealed) {
return;
}
sealed = true;
... | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | handleForeignThenable | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function handleOwnThenable(promise, thenable) {
if (thenable._state === FULFILLED) {
fulfill(promise, thenable._result);
}
else if (thenable._state === REJECTED) {
reject(promise, thenable._result);
}
else {
subscribe(thenable, undefined, funct... | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | handleOwnThenable | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function handleMaybeThenable(promise, maybeThenable, then$$1) {
if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) {
handleOwnThenable(promise, maybeThenable);
}
else {
if (then$$1 === undefined) {... | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | handleMaybeThenable | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function resolve(promise, value) {
if (promise === value) {
reject(promise, selfFulfillment());
}
else if (objectOrFunction(value)) {
var then$$1 = void 0;
try {
then$$1 = value.then;
}
catch (error) {
re... | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | resolve | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function publishRejection(promise) {
if (promise._onerror) {
promise._onerror(promise._result);
}
publish(promise);
} | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | publishRejection | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function fulfill(promise, value) {
if (promise._state !== PENDING) {
return;
}
promise._result = value;
promise._state = FULFILLED;
if (promise._subscribers.length !== 0) {
asap(publish, promise);
}
} | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | fulfill | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function reject(promise, reason) {
if (promise._state !== PENDING) {
return;
}
promise._state = REJECTED;
promise._result = reason;
asap(publishRejection, promise);
} | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | reject | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function subscribe(parent, child, onFulfillment, onRejection) {
var _subscribers = parent._subscribers;
var length = _subscribers.length;
parent._onerror = null;
_subscribers[length] = child;
_subscribers[length + FULFILLED] = onFulfillment;
_subscribers[length + REJECTED... | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | subscribe | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function publish(promise) {
var subscribers = promise._subscribers;
var settled = promise._state;
if (subscribers.length === 0) {
return;
}
var child = void 0, callback = void 0, detail = promise._result;
for (var i = 0; i < subscribers.length; i += 3) {
... | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | publish | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function invokeCallback(settled, promise, callback, detail) {
var hasCallback = isFunction(callback), value = void 0, error = void 0, succeeded = true;
if (hasCallback) {
try {
value = callback(detail);
}
catch (e) {
succeeded = false;
... | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | invokeCallback | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function initializePromise(promise, resolver) {
try {
resolver(function resolvePromise(value) {
resolve(promise, value);
}, function rejectPromise(reason) {
reject(promise, reason);
});
}
catch (e) {
reject(promise, ... | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | initializePromise | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function nextId() {
return id++;
} | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | nextId | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function makePromise(promise) {
promise[PROMISE_ID] = id++;
promise._state = undefined;
promise._result = undefined;
promise._subscribers = [];
} | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | makePromise | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function validationError() {
return new Error('Array Methods must be provided an Array');
} | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | validationError | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function Enumerator(Constructor, input) {
this._instanceConstructor = Constructor;
this.promise = new Constructor(noop);
if (!this.promise[PROMISE_ID]) {
makePromise(this.promise);
}
if (isArray(input)) {
this.length = input.len... | `Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
... | Enumerator | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function all(entries) {
return new Enumerator(this, entries).promise;
} | `Promise.all` accepts an array of promises, and returns a new promise which
is fulfilled with an array of fulfillment values for the passed promises, or
rejected with the reason of the first passed promise to be rejected. It casts all
elements of the passed iterable to promises as it runs this algorit... | all | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function race(entries) {
/*jshint validthis:true */
var Constructor = this;
if (!isArray(entries)) {
return new Constructor(function (_, reject) {
return reject(new TypeError('You must pass an array to race.'));
});
}
else {
ret... | `Promise.race` returns a new promise which is settled in the same way as the
first passed promise to settle.
Example:
```javascript
let promise1 = new Promise(function(resolve, reject){
setTimeout(function(){
resolve('promise 1');
}, 200);
});
... | race | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function reject$1(reason) {
/*jshint validthis:true */
var Constructor = this;
var promise = new Constructor(noop);
reject(promise, reason);
return promise;
} | `Promise.reject` returns a promise rejected with the passed `reason`.
It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
reject(new Error('WHOOPS'));
});
promise.then(function(value){
// Code here doesn't run beca... | reject$1 | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function needsResolver() {
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
} | `Promise.reject` returns a promise rejected with the passed `reason`.
It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
reject(new Error('WHOOPS'));
});
promise.then(function(value){
// Code here doesn't run beca... | needsResolver | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function needsNew() {
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
} | `Promise.reject` returns a promise rejected with the passed `reason`.
It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
reject(new Error('WHOOPS'));
});
promise.then(function(value){
// Code here doesn't run beca... | needsNew | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function polyfill() {
var local = void 0;
if (typeof __webpack_require__.g !== 'undefined') {
local = __webpack_require__.g;
}
else if (typeof self !== 'undefined') {
local = self;
}
else {
try {
local = Function('return... | `finally` will be invoked regardless of the promise's fate just as native
try/catch/finally behaves
Synchronous example:
```js
findAuthor() {
if (Math.random() > 0.5) {
throw new Error();
}
return new Author();
... | polyfill | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/flv.js/flv.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/flv.js/flv.js | MIT |
function comparativeDistance(x, y) {
return (
Math.pow(x[0] - y[0], 2) +
Math.pow(x[1] - y[1], 2) +
Math.pow(x[2] - y[2], 2)
);
} | See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance | comparativeDistance | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/hls.js/hls-demo.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/hls.js/hls-demo.js | MIT |
function buildGraph() {
var graph = {};
// https://jsperf.com/object-keys-vs-for-in-with-closure/3
var models = Object.keys(conversions);
for (var len = models.length, i = 0; i < len; i++) {
graph[models[i]] = {
// http://jsperf.com/1-vs-infinity
// micro-opt, but this is simple.
distance: -1,
parent... | See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance | buildGraph | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/hls.js/hls-demo.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/hls.js/hls-demo.js | MIT |
function deriveBFS(fromModel) {
var graph = buildGraph();
var queue = [fromModel]; // unshift -> queue -> pop
graph[fromModel].distance = 0;
while (queue.length) {
var current = queue.pop();
var adjacents = Object.keys(conversions[current]);
for (var len = adjacents.length, i = 0; i < len; i++) {
var ad... | See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance | deriveBFS | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/hls.js/hls-demo.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/hls.js/hls-demo.js | MIT |
function link(from, to) {
return function (args) {
return to(from(args));
};
} | See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance | link | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/hls.js/hls-demo.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/hls.js/hls-demo.js | MIT |
function wrapConversion(toModel, graph) {
var path = [graph[toModel].parent, toModel];
var fn = conversions[graph[toModel].parent][toModel];
var cur = graph[toModel].parent;
while (graph[cur].parent) {
path.unshift(graph[cur].parent);
fn = link(conversions[graph[cur].parent][cur], fn);
cur = graph[cur].paren... | See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance | wrapConversion | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/hls.js/hls-demo.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/hls.js/hls-demo.js | MIT |
route = function (fromModel) {
var graph = deriveBFS(fromModel);
var conversion = {};
var models = Object.keys(graph);
for (var len = models.length, i = 0; i < len; i++) {
var toModel = models[i];
var node = graph[toModel];
if (node.parent === null) {
// no possible conversion, or this node is the source... | See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance | route | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/hls.js/hls-demo.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/hls.js/hls-demo.js | MIT |
function wrapRaw(fn) {
var wrappedFn = function (args) {
if (args === undefined || args === null) {
return args;
}
if (arguments.length > 1) {
args = Array.prototype.slice.call(arguments);
}
return fn(args);
};
// preserve .conversion property if there is one
if ('conversion' in fn) {
wrappedFn... | See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance | wrapRaw | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/hls.js/hls-demo.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/hls.js/hls-demo.js | MIT |
wrappedFn = function (args) {
if (args === undefined || args === null) {
return args;
}
if (arguments.length > 1) {
args = Array.prototype.slice.call(arguments);
}
return fn(args);
} | See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance | wrappedFn | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/hls.js/hls-demo.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/hls.js/hls-demo.js | MIT |
function wrapRounded(fn) {
var wrappedFn = function (args) {
if (args === undefined || args === null) {
return args;
}
if (arguments.length > 1) {
args = Array.prototype.slice.call(arguments);
}
var result = fn(args);
// we're assuming the result is an array here.
// see notice in conversions.js... | See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance | wrapRounded | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/hls.js/hls-demo.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/hls.js/hls-demo.js | MIT |
wrappedFn = function (args) {
if (args === undefined || args === null) {
return args;
}
if (arguments.length > 1) {
args = Array.prototype.slice.call(arguments);
}
var result = fn(args);
// we're assuming the result is an array here.
// see notice in conversions.js; don't use box types
// in co... | See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance | wrappedFn | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/hls.js/hls-demo.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/hls.js/hls-demo.js | MIT |
function getRgba(string) {
if (!string) {
return;
}
var abbr = /^#([a-fA-F0-9]{3,4})$/i,
hex = /^#([a-fA-F0-9]{6}([a-fA-F0-9]{2})?)$/i,
rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i,
per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?... | See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance | getRgba | javascript | gongfuxiang/shopxo | public/static/common/lib/ckplayer/hls.js/hls-demo.js | https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/ckplayer/hls.js/hls-demo.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.