language
stringclasses
6 values
original_string
stringlengths
25
887k
text
stringlengths
25
887k
JavaScript
function render (device) { if (!this._dataBound && this._dataSource && this._itemFormatter) { this._createDataBoundItems(); } if (!this.outputElement && (this._renderMode === List.RENDER_MODE_LIST)) { this.outputElement = device.createList(this.id, this.getClasses()); } return render.base.call(this, device); }
function render (device) { if (!this._dataBound && this._dataSource && this._itemFormatter) { this._createDataBoundItems(); } if (!this.outputElement && (this._renderMode === List.RENDER_MODE_LIST)) { this.outputElement = device.createList(this.id, this.getClasses()); } return render.base.call(this, device); }
JavaScript
function _createDataBoundItems () { this._dataBound = true; var self = this; function processDataCallback(data) { self.removeChildWidgets(); var iterator = (data instanceof Iterator) ? data : new Iterator(data); while (iterator.hasNext()) { var i = iterator._currentIndex; var w = self._itemFormatter.format(iterator); w._listIndex = i; if (self._dataBindingOrder === List.DATA_BIND_FORWARD) { self.appendChildWidget(w); } else if (self._dataBindingOrder === List.DATA_BIND_REVERSE) { self.insertChildWidget(0, w); } } self._totalDataItems = iterator._currentIndex; self.bubbleEvent(new DataBoundEvent('databound', self, iterator)); } function processDataError(response) { self.removeChildWidgets(); self.bubbleEvent(new DataBoundEvent('databindingerror', self, null, response)); } self.bubbleEvent(new DataBoundEvent('beforedatabind', self)); if (!this._dataSource || (this._dataSource instanceof Array)) { processDataCallback(this._dataSource); } else { this._dataSource.load({ onSuccess: processDataCallback, onError: processDataError }); } }
function _createDataBoundItems () { this._dataBound = true; var self = this; function processDataCallback(data) { self.removeChildWidgets(); var iterator = (data instanceof Iterator) ? data : new Iterator(data); while (iterator.hasNext()) { var i = iterator._currentIndex; var w = self._itemFormatter.format(iterator); w._listIndex = i; if (self._dataBindingOrder === List.DATA_BIND_FORWARD) { self.appendChildWidget(w); } else if (self._dataBindingOrder === List.DATA_BIND_REVERSE) { self.insertChildWidget(0, w); } } self._totalDataItems = iterator._currentIndex; self.bubbleEvent(new DataBoundEvent('databound', self, iterator)); } function processDataError(response) { self.removeChildWidgets(); self.bubbleEvent(new DataBoundEvent('databindingerror', self, null, response)); } self.bubbleEvent(new DataBoundEvent('beforedatabind', self)); if (!this._dataSource || (this._dataSource instanceof Array)) { processDataCallback(this._dataSource); } else { this._dataSource.load({ onSuccess: processDataCallback, onError: processDataError }); } }
JavaScript
function bindProgressIndicator (widget, formatterCallback) { var self = this; this._updateProgressHandler = function (evt) { if (evt.target !== self) { return; } if (evt.type === 'beforedatabind') { widget.setText(''); return; } // TODO: This is a bit of a hack - if more data items were iterated over to populate the list // TODO: than there are items in the list, we assume some list items contain more than one // TODO: data item, therefore we have to use their position within the data source, rather than // TODO: their position within the rendered list widget. var ignore = self._childWidgetOrder.length - self._totalDataItems; if (ignore < 0) { ignore = 0; } var activeWidget = self.getActiveChildWidget(); var index = (self._dataBound && activeWidget && (activeWidget._listIndex !== undefined)) ? activeWidget._listIndex : self._selectedIndex - ignore; var total = self._childWidgetOrder.length - ignore; var p; if (index < 0) { p = 0; } else { p = index / (total - 1); if (p < 0) { p = 0; } } if (formatterCallback) { var val = formatterCallback(index + 1, total); if (typeof(val) === 'string') { widget.setText(val); } else { widget.setText(val.text); p = val.pos; } } //if the formatter function has moved the position indicator, we don't change it widget.setValue(p); }; this.addEventListener('selecteditemchange', this._updateProgressHandler); this.addEventListener('focus', this._updateProgressHandler); this.addEventListener('blur', this._updateProgressHandler); this.addEventListener('beforedatabind', this._updateProgressHandler); this.addEventListener('databound', this._updateProgressHandler); }
function bindProgressIndicator (widget, formatterCallback) { var self = this; this._updateProgressHandler = function (evt) { if (evt.target !== self) { return; } if (evt.type === 'beforedatabind') { widget.setText(''); return; } // TODO: This is a bit of a hack - if more data items were iterated over to populate the list // TODO: than there are items in the list, we assume some list items contain more than one // TODO: data item, therefore we have to use their position within the data source, rather than // TODO: their position within the rendered list widget. var ignore = self._childWidgetOrder.length - self._totalDataItems; if (ignore < 0) { ignore = 0; } var activeWidget = self.getActiveChildWidget(); var index = (self._dataBound && activeWidget && (activeWidget._listIndex !== undefined)) ? activeWidget._listIndex : self._selectedIndex - ignore; var total = self._childWidgetOrder.length - ignore; var p; if (index < 0) { p = 0; } else { p = index / (total - 1); if (p < 0) { p = 0; } } if (formatterCallback) { var val = formatterCallback(index + 1, total); if (typeof(val) === 'string') { widget.setText(val); } else { widget.setText(val.text); p = val.pos; } } //if the formatter function has moved the position indicator, we don't change it widget.setValue(p); }; this.addEventListener('selecteditemchange', this._updateProgressHandler); this.addEventListener('focus', this._updateProgressHandler); this.addEventListener('blur', this._updateProgressHandler); this.addEventListener('beforedatabind', this._updateProgressHandler); this.addEventListener('databound', this._updateProgressHandler); }
JavaScript
function unbindProgressIndicator () { if (this._updateProgressHandler) { this.removeEventListener('selecteditemchange', this._updateProgressHandler); this.removeEventListener('focus', this._updateProgressHandler); this.removeEventListener('blur', this._updateProgressHandler); this.removeEventListener('databound', this._updateProgressHandler); } }
function unbindProgressIndicator () { if (this._updateProgressHandler) { this.removeEventListener('selecteditemchange', this._updateProgressHandler); this.removeEventListener('focus', this._updateProgressHandler); this.removeEventListener('blur', this._updateProgressHandler); this.removeEventListener('databound', this._updateProgressHandler); } }
JavaScript
function init (transDef, endPoints, element) { var combinedTransitions, shouldSkip; this._endPoints = endPoints; this._completed = false; this._transEl = new TransitionElement(element); this._ownTransitions = transDef; this._endFn = this._genTransEndFn(); shouldSkip = this._isTransitionInstant(); if(shouldSkip) { this._ownTransitions = new SkipAnimTransitionDefinition(this._ownTransitions); } combinedTransitions = new ExisitingTransitionDefinition(this._transEl); combinedTransitions.addIn(this._ownTransitions); this._setInitialValues(); this._forceUpdate(); this._transEl.applyDefinition(combinedTransitions); this._transEl.setCallback(this._endFn); this._forceUpdate(); this._doTransition(); if(shouldSkip) { this.stop(true); } }
function init (transDef, endPoints, element) { var combinedTransitions, shouldSkip; this._endPoints = endPoints; this._completed = false; this._transEl = new TransitionElement(element); this._ownTransitions = transDef; this._endFn = this._genTransEndFn(); shouldSkip = this._isTransitionInstant(); if(shouldSkip) { this._ownTransitions = new SkipAnimTransitionDefinition(this._ownTransitions); } combinedTransitions = new ExisitingTransitionDefinition(this._transEl); combinedTransitions.addIn(this._ownTransitions); this._setInitialValues(); this._forceUpdate(); this._transEl.applyDefinition(combinedTransitions); this._transEl.setCallback(this._endFn); this._forceUpdate(); this._doTransition(); if(shouldSkip) { this.stop(true); } }
JavaScript
function _forceUpdate () { var transitionTargets; transitionTargets = this._ownTransitions.getProperties(); if(transitionTargets.length > 0) { this._transEl.forceUpdate(transitionTargets[0]); } }
function _forceUpdate () { var transitionTargets; transitionTargets = this._ownTransitions.getProperties(); if(transitionTargets.length > 0) { this._transEl.forceUpdate(transitionTargets[0]); } }
JavaScript
function _loadComponentCallback (module, componentClass, args, keepHistory, state) { if (!this.getCurrentApplication()) { // Application has been destroyed, abort return; } var newComponent = new componentClass(); // Add the component to our table of known components. _knownComponents[module] = newComponent; // set the parent widget so the next event bubbles correctly through the tree newComponent.parentWidget = this; newComponent.bubbleEvent(new ComponentEvent('load', this, _knownComponents[module], args)); // clear the parent widget again newComponent.parentWidget = null; // Show the component. this.show(module, args, keepHistory, state); }
function _loadComponentCallback (module, componentClass, args, keepHistory, state) { if (!this.getCurrentApplication()) { // Application has been destroyed, abort return; } var newComponent = new componentClass(); // Add the component to our table of known components. _knownComponents[module] = newComponent; // set the parent widget so the next event bubbles correctly through the tree newComponent.parentWidget = this; newComponent.bubbleEvent(new ComponentEvent('load', this, _knownComponents[module], args)); // clear the parent widget again newComponent.parentWidget = null; // Show the component. this.show(module, args, keepHistory, state); }
JavaScript
function show (module, args, keepHistory, state, fromBack, focus) { this._loadingModule = module; this._loadingIndex++; var loadingIndex = this._loadingIndex; var self; if (_knownComponents[module]) { var device = this.getCurrentApplication().getDevice(); var _focus = this.getCurrentApplication().getFocussedWidget(); if (this._currentComponent) { this.hide(null, args, keepHistory, state, fromBack); } this._currentModule = module; this._currentComponent = _knownComponents[module]; this._currentArgs = args; if (!fromBack) { this._previousFocus = _focus; } if (!this._isFocussed) { // We don't have focus, so any of our children shouldn't // (_isFocussed state can be set to true if focussed widget is in a unloaded component) var p = this._currentComponent; while (p) { p.removeFocus(); p = p._activeChildWidget; } } // set the parent widget so the next event bubbles correctly through the tree this._currentComponent.parentWidget = this; this._currentComponent.bubbleEvent(new ComponentEvent('beforerender', this, this._currentComponent, args, state, fromBack)); this._currentComponent.render(device); // and clear it again this._currentComponent.parentWidget = null; device.hideElement({ el: this._currentComponent.outputElement, skipAnim: true }); this.appendChildWidget(this._currentComponent); var evt = new ComponentEvent('beforeshow', this, this._currentComponent, args, state, fromBack); this._currentComponent.bubbleEvent(evt); if (focus) { focus.focus(); } self = this; if (!evt.isDefaultPrevented()) { var config = device.getConfig(); var animate = !config.widgets || !config.widgets.componentcontainer || (config.widgets.componentcontainer.fade !== false); device.showElement({ el: this._currentComponent.outputElement, skipAnim: !animate }); } self._currentComponent.bubbleEvent(new ComponentEvent('aftershow', self, self._currentComponent, args, state, fromBack)); var focusRemoved = self.setActiveChildWidget(self._currentComponent); if (!focusRemoved) { self._activeChildWidget = self._currentComponent; self.getCurrentApplication().getDevice().getLogger().warn('active component is not currently focusable', self._activeChildWidget); } } else { // hook into requirejs to load the component from the module and call us again self = this; require([module], function (componentClass) { // Check we've not navigated elsewhere whilst requirejs has been loading the module if (self._loadingModule === module && self._loadingIndex === loadingIndex) { self._loadComponentCallback(module, componentClass, args, keepHistory, state, fromBack, focus); } }); } }
function show (module, args, keepHistory, state, fromBack, focus) { this._loadingModule = module; this._loadingIndex++; var loadingIndex = this._loadingIndex; var self; if (_knownComponents[module]) { var device = this.getCurrentApplication().getDevice(); var _focus = this.getCurrentApplication().getFocussedWidget(); if (this._currentComponent) { this.hide(null, args, keepHistory, state, fromBack); } this._currentModule = module; this._currentComponent = _knownComponents[module]; this._currentArgs = args; if (!fromBack) { this._previousFocus = _focus; } if (!this._isFocussed) { // We don't have focus, so any of our children shouldn't // (_isFocussed state can be set to true if focussed widget is in a unloaded component) var p = this._currentComponent; while (p) { p.removeFocus(); p = p._activeChildWidget; } } // set the parent widget so the next event bubbles correctly through the tree this._currentComponent.parentWidget = this; this._currentComponent.bubbleEvent(new ComponentEvent('beforerender', this, this._currentComponent, args, state, fromBack)); this._currentComponent.render(device); // and clear it again this._currentComponent.parentWidget = null; device.hideElement({ el: this._currentComponent.outputElement, skipAnim: true }); this.appendChildWidget(this._currentComponent); var evt = new ComponentEvent('beforeshow', this, this._currentComponent, args, state, fromBack); this._currentComponent.bubbleEvent(evt); if (focus) { focus.focus(); } self = this; if (!evt.isDefaultPrevented()) { var config = device.getConfig(); var animate = !config.widgets || !config.widgets.componentcontainer || (config.widgets.componentcontainer.fade !== false); device.showElement({ el: this._currentComponent.outputElement, skipAnim: !animate }); } self._currentComponent.bubbleEvent(new ComponentEvent('aftershow', self, self._currentComponent, args, state, fromBack)); var focusRemoved = self.setActiveChildWidget(self._currentComponent); if (!focusRemoved) { self._activeChildWidget = self._currentComponent; self.getCurrentApplication().getDevice().getLogger().warn('active component is not currently focusable', self._activeChildWidget); } } else { // hook into requirejs to load the component from the module and call us again self = this; require([module], function (componentClass) { // Check we've not navigated elsewhere whilst requirejs has been loading the module if (self._loadingModule === module && self._loadingIndex === loadingIndex) { self._loadComponentCallback(module, componentClass, args, keepHistory, state, fromBack, focus); } }); } }
JavaScript
function back () { var _focus = this._currentComponent.getIsModal() ? this._previousFocus : null; var _lastComponent = this._historyStack.pop(); if (_lastComponent) { this._previousFocus = _lastComponent.previousFocus; this.show(_lastComponent.module, _lastComponent.args, true, _lastComponent.state, true, _focus); } else { this.hide(null, null, false, null, false); } }
function back () { var _focus = this._currentComponent.getIsModal() ? this._previousFocus : null; var _lastComponent = this._historyStack.pop(); if (_lastComponent) { this._previousFocus = _lastComponent.previousFocus; this.show(_lastComponent.module, _lastComponent.args, true, _lastComponent.state, true, _focus); } else { this.hide(null, null, false, null, false); } }
JavaScript
function hide (focusToComponent, args, keepHistory, state, fromBack) { if (this._currentComponent) { var evt = new ComponentEvent('beforehide', this, this._currentComponent, args, state, fromBack); this._currentComponent.bubbleEvent(evt); var _state = keepHistory ? this._currentComponent.getCurrentState() : null; // remove the child widget, but if default event is prevented, keep the output element in the DOM this.removeChildWidget(this._currentComponent, evt.isDefaultPrevented()); var _component = this._currentComponent; this._currentComponent = null; // set the parent widget so the next event bubbles correctly through the tree _component.parentWidget = this; _component.bubbleEvent(new ComponentEvent('afterhide', this, _component, args, state, fromBack)); // and clear it again _component.parentWidget = null; if (keepHistory) { if (!fromBack) { this._historyStack.push({ module: this._currentModule, args: this._currentArgs, state: _state, previousFocus: this._previousFocus }); } } else { // Reset the history stack when a component is shown in this container without explicitly // enabling history. if (_component.getIsModal() && !fromBack) { if (this._historyStack.length > 0) { this._historyStack[0].previousFocus.focus(); } else if (this._previousFocus) { this._previousFocus.focus(); } } this._historyStack = []; } } if (this._isFocussed && focusToComponent) { this.parentWidget.setActiveChildWidget(this.parentWidget._childWidgets[focusToComponent]); } }
function hide (focusToComponent, args, keepHistory, state, fromBack) { if (this._currentComponent) { var evt = new ComponentEvent('beforehide', this, this._currentComponent, args, state, fromBack); this._currentComponent.bubbleEvent(evt); var _state = keepHistory ? this._currentComponent.getCurrentState() : null; // remove the child widget, but if default event is prevented, keep the output element in the DOM this.removeChildWidget(this._currentComponent, evt.isDefaultPrevented()); var _component = this._currentComponent; this._currentComponent = null; // set the parent widget so the next event bubbles correctly through the tree _component.parentWidget = this; _component.bubbleEvent(new ComponentEvent('afterhide', this, _component, args, state, fromBack)); // and clear it again _component.parentWidget = null; if (keepHistory) { if (!fromBack) { this._historyStack.push({ module: this._currentModule, args: this._currentArgs, state: _state, previousFocus: this._previousFocus }); } } else { // Reset the history stack when a component is shown in this container without explicitly // enabling history. if (_component.getIsModal() && !fromBack) { if (this._historyStack.length > 0) { this._historyStack[0].previousFocus.focus(); } else if (this._previousFocus) { this._previousFocus.focus(); } } this._historyStack = []; } } if (this._isFocussed && focusToComponent) { this.parentWidget.setActiveChildWidget(this.parentWidget._childWidgets[focusToComponent]); } }
JavaScript
function render (device) { if (!this.outputElement) { this.outputElement = device.createContainer(this.id, this.getClasses()); } else { device.clearElement(this.outputElement); } var rowElement; for (var row = 0; row < this._rows; row++) { rowElement = device.createContainer(this.id + '_row_' + row, ['row']); for (var col = 0; col < this._cols; col++) { var widget = this.getWidgetAt(col, row); if (widget) { if (col === 0) { widget.addClass('firstcol'); } else if (col === this._cols - 1) { widget.addClass('lastcol'); } device.appendChildElement(rowElement, this.getWidgetAt(col, row).render(device)); } else { var classes = ['spacer']; if (col === 0) { classes.push('firstcol'); } else if (col === this._cols - 1) { classes.push('lastcol'); } device.appendChildElement(rowElement, device.createContainer(this.id + '_' + col + '_' + row, classes)); } } device.appendChildElement(this.outputElement, rowElement); } return this.outputElement; }
function render (device) { if (!this.outputElement) { this.outputElement = device.createContainer(this.id, this.getClasses()); } else { device.clearElement(this.outputElement); } var rowElement; for (var row = 0; row < this._rows; row++) { rowElement = device.createContainer(this.id + '_row_' + row, ['row']); for (var col = 0; col < this._cols; col++) { var widget = this.getWidgetAt(col, row); if (widget) { if (col === 0) { widget.addClass('firstcol'); } else if (col === this._cols - 1) { widget.addClass('lastcol'); } device.appendChildElement(rowElement, this.getWidgetAt(col, row).render(device)); } else { var classes = ['spacer']; if (col === 0) { classes.push('firstcol'); } else if (col === this._cols - 1) { classes.push('lastcol'); } device.appendChildElement(rowElement, device.createContainer(this.id + '_' + col + '_' + row, classes)); } } device.appendChildElement(this.outputElement, rowElement); } return this.outputElement; }
JavaScript
function broadcastEvent (evt) { this.fireEvent(evt); if (!evt.isPropagationStopped()) { for (var i = 0; i < this._childWidgetOrder.length; i++) { // Grids are the only type of container that may contain // null entries in the _childWidgetOrder array if (this._childWidgetOrder[i]) { this._childWidgetOrder[i].broadcastEvent(evt); } } } }
function broadcastEvent (evt) { this.fireEvent(evt); if (!evt.isPropagationStopped()) { for (var i = 0; i < this._childWidgetOrder.length; i++) { // Grids are the only type of container that may contain // null entries in the _childWidgetOrder array if (this._childWidgetOrder[i]) { this._childWidgetOrder[i].broadcastEvent(evt); } } } }
JavaScript
function render (device) { if(!this.outputElement) { this.outputElement = device.createListItem(this.id, this.getClasses()); } return render.base.call(this, device); }
function render (device) { if(!this.outputElement) { this.outputElement = device.createListItem(this.id, this.getClasses()); } return render.base.call(this, device); }
JavaScript
function render (device) { this._imageElement = device.createImage(this.id + '_img', null, this._src, this._size); if(this._renderMode === Image.RENDER_MODE_CONTAINER) { this.outputElement = render.base.call(this, device); if(this._size) { device.setElementSize(this.outputElement, this._size); } device.prependChildElement(this.outputElement, this._imageElement); } else { this.outputElement = this._imageElement; device.setElementClasses(this.outputElement, this.getClasses()); } return this.outputElement; }
function render (device) { this._imageElement = device.createImage(this.id + '_img', null, this._src, this._size); if(this._renderMode === Image.RENDER_MODE_CONTAINER) { this.outputElement = render.base.call(this, device); if(this._size) { device.setElementSize(this.outputElement, this._size); } device.prependChildElement(this.outputElement, this._imageElement); } else { this.outputElement = this._imageElement; device.setElementClasses(this.outputElement, this.getClasses()); } return this.outputElement; }
JavaScript
function abort () { if(this._request) { this._request.abort(); } }
function abort () { if(this._request) { this._request.abort(); } }
JavaScript
function inherit(original) { function Inherited() {} Inherited.prototype = original; return new Inherited(); }
function inherit(original) { function Inherited() {} Inherited.prototype = original; return new Inherited(); }
JavaScript
function addTweenToQueue(options, tweenValues) { // A separate queue exists for each framerate. Get or create the appropriate queue. var queueKey = 'fps' + options.fps; var frameIntervalMs = 1000 / options.fps; var queue = animQueues[queueKey]; // Create a new queue if one doesn't already exist (implemented as an array). if (!queue) { queue = []; animQueues[queueKey] = queue; } // Start processing the queue periodically if we're not already. // Wait half a frame before starting the first cycle - gives other animation updates at // the same frame rate a chance to come in. if (!queue.isProcessing) { queue.isProcessing = true; setTimeout(function() { startIntervalTimer(queue, frameIntervalMs); }, frameIntervalMs / 2); // First tween in a cycle should be applied immediately. It contains initial values. step(options, tweenValues); } else { // Queue is already being processed. Add the new entry to the queue. queue.push({options: options, values: tweenValues}); } }
function addTweenToQueue(options, tweenValues) { // A separate queue exists for each framerate. Get or create the appropriate queue. var queueKey = 'fps' + options.fps; var frameIntervalMs = 1000 / options.fps; var queue = animQueues[queueKey]; // Create a new queue if one doesn't already exist (implemented as an array). if (!queue) { queue = []; animQueues[queueKey] = queue; } // Start processing the queue periodically if we're not already. // Wait half a frame before starting the first cycle - gives other animation updates at // the same frame rate a chance to come in. if (!queue.isProcessing) { queue.isProcessing = true; setTimeout(function() { startIntervalTimer(queue, frameIntervalMs); }, frameIntervalMs / 2); // First tween in a cycle should be applied immediately. It contains initial values. step(options, tweenValues); } else { // Queue is already being processed. Add the new entry to the queue. queue.push({options: options, values: tweenValues}); } }
JavaScript
function drainTweensFromQueue(options) { var queue, i, q; queue = animQueues['fps' + options.fps]; if (queue) { for (i = 0; i < queue.length; i++) { q = queue[i]; if (q.options === options) { step(q.options, q.values); queue.splice(i, 1); i--; } } } }
function drainTweensFromQueue(options) { var queue, i, q; queue = animQueues['fps' + options.fps]; if (queue) { for (i = 0; i < queue.length; i++) { q = queue[i]; if (q.options === options) { step(q.options, q.values); queue.splice(i, 1); i--; } } } }
JavaScript
function startIntervalTimer(queue, period) { // Store timer ID with the queue to allow it to be stopped later. queue.intervalId = setInterval(function() { processQueue(queue); }, period); }
function startIntervalTimer(queue, period) { // Store timer ID with the queue to allow it to be stopped later. queue.intervalId = setInterval(function() { processQueue(queue); }, period); }
JavaScript
function processQueue(queue) { // Is the queue still empty after it was last cleared? Stop the timer - the animations have // probably finished and will not provide any further updates. if (queue.length === 0) { clearInterval(queue.intervalId); queue.isProcessing = false; queue.intervalId = null; } else { // We have some DOM updates to do. Do each one in sequence, then clear the queue ready for the next round. try { for (var i = 0; i < queue.length; i++) { var q = queue[i]; step(q.options, q.values); } } finally { // Truncating the array length to zero clears it. queue.length = 0; } } }
function processQueue(queue) { // Is the queue still empty after it was last cleared? Stop the timer - the animations have // probably finished and will not provide any further updates. if (queue.length === 0) { clearInterval(queue.intervalId); queue.isProcessing = false; queue.intervalId = null; } else { // We have some DOM updates to do. Do each one in sequence, then clear the queue ready for the next round. try { for (var i = 0; i < queue.length; i++) { var q = queue[i]; step(q.options, q.values); } } finally { // Truncating the array length to zero clears it. queue.length = 0; } } }
JavaScript
function step(options, tweenValues) { for (var p in options.to) { if (tweenValues[p] !== null && tweenValues[p] !== undefined) { if (/scroll/.test(p)) { options.el[p] = tweenValues[p]; } else { options.el.style[p] = tweenValues[p]; } } } }
function step(options, tweenValues) { for (var p in options.to) { if (tweenValues[p] !== null && tweenValues[p] !== undefined) { if (/scroll/.test(p)) { options.el[p] = tweenValues[p]; } else { options.el.style[p] = tweenValues[p]; } } } }
JavaScript
function _appendCharacter (letter) { // allow no more characters to be appended if a maximum length has been reached if((this._maximumLength !== null) && (this._currentText.length >= this._maximumLength)) { return false; } if( (this._capitalisation !== Keyboard.CAPITALISATION_LOWER) && ( (this._capitalisation === Keyboard.CAPITALISATION_UPPER) || this._currentText.length === 0 || this._currentText[this._currentText.length-1] === ' ' )) { letter = letter.toUpperCase(); } else { letter = letter.toLowerCase(); } this._currentText += letter; this._correctTitleCase(); return true; }
function _appendCharacter (letter) { // allow no more characters to be appended if a maximum length has been reached if((this._maximumLength !== null) && (this._currentText.length >= this._maximumLength)) { return false; } if( (this._capitalisation !== Keyboard.CAPITALISATION_LOWER) && ( (this._capitalisation === Keyboard.CAPITALISATION_UPPER) || this._currentText.length === 0 || this._currentText[this._currentText.length-1] === ' ' )) { letter = letter.toUpperCase(); } else { letter = letter.toLowerCase(); } this._currentText += letter; this._correctTitleCase(); return true; }
JavaScript
function next () { if(this.hasNext()) { return this._array[this._currentIndex++]; } else { return undefined; } }
function next () { if(this.hasNext()) { return this._array[this._currentIndex++]; } else { return undefined; } }
JavaScript
function render (device) { var i; if (!this.outputElement) { this.outputElement = device.createContainer(this.id, this.getClasses()); } else { device.clearElement(this.outputElement); } for (i = 0; i !== this._elements.length; i++) { device.appendChildElement(this.outputElement, this._elements[i]); } return this.outputElement; }
function render (device) { var i; if (!this.outputElement) { this.outputElement = device.createContainer(this.id, this.getClasses()); } else { device.clearElement(this.outputElement); } for (i = 0; i !== this._elements.length; i++) { device.appendChildElement(this.outputElement, this._elements[i]); } return this.outputElement; }
JavaScript
function autoCalculate (on) { if (typeof on === 'boolean') { this._autoCalculate = on; } }
function autoCalculate (on) { if (typeof on === 'boolean') { this._autoCalculate = on; } }
JavaScript
function lengthOfWidgetAtIndex (index) { var providedLength; providedLength = this._lengthOfWidgetAtIndexUsingSuppliedValues(index); if (typeof providedLength === 'number') { return providedLength; } return this._getElementLength(this._elements[index + this._elementIndexOffset]); }
function lengthOfWidgetAtIndex (index) { var providedLength; providedLength = this._lengthOfWidgetAtIndexUsingSuppliedValues(index); if (typeof providedLength === 'number') { return providedLength; } return this._getElementLength(this._elements[index + this._elementIndexOffset]); }
JavaScript
function render (device) { var s = this._text; if(!this.outputElement) { this.outputElement = device.createContainer(this.id, this.getClasses()); this.innerElement = device.createContainer(this.id + '_inner'); this.outputElement.appendChild(this.innerElement); } device.setElementContent(this.innerElement, s, this._enableHTML); return this.outputElement; }
function render (device) { var s = this._text; if(!this.outputElement) { this.outputElement = device.createContainer(this.id, this.getClasses()); this.innerElement = device.createContainer(this.id + '_inner'); this.outputElement.appendChild(this.innerElement); } device.setElementContent(this.innerElement, s, this._enableHTML); return this.outputElement; }
JavaScript
function back () { var recent, remaining, fragmentSeparator, self; self = this; function findRecentAndRemaining() { var history = self._historyArray; if (history.length > 0) { recent = history[0].split(Historian.HISTORY_TOKEN)[1]; remaining = history.slice(1, history.length).join(''); } else { recent = remaining = ''; } } function processRoute() { if(recent.indexOf(Historian.ROUTE_TOKEN) !== -1) { fragmentSeparator = ''; recent = recent.replace(Historian.ROUTE_TOKEN, '#'); } } function buildBackUrl() { if(remaining) { return recent + fragmentSeparator + remaining; } return recent; } fragmentSeparator = '#'; findRecentAndRemaining(); processRoute(); return buildBackUrl(); }
function back () { var recent, remaining, fragmentSeparator, self; self = this; function findRecentAndRemaining() { var history = self._historyArray; if (history.length > 0) { recent = history[0].split(Historian.HISTORY_TOKEN)[1]; remaining = history.slice(1, history.length).join(''); } else { recent = remaining = ''; } } function processRoute() { if(recent.indexOf(Historian.ROUTE_TOKEN) !== -1) { fragmentSeparator = ''; recent = recent.replace(Historian.ROUTE_TOKEN, '#'); } } function buildBackUrl() { if(remaining) { return recent + fragmentSeparator + remaining; } return recent; } fragmentSeparator = '#'; findRecentAndRemaining(); processRoute(); return buildBackUrl(); }
JavaScript
function forward (destinationUrl) { var fragmentSeparator, self; self = this; function isRouteInDestination() { return (destinationUrl.indexOf('#') !== -1); } function replaceRouteInSource() { if (self._currentUrl.indexOf('#') !== -1) { self._currentUrl = self._currentUrl.replace('#', Historian.ROUTE_TOKEN); } } function addCurrentUrlToHistory() { self._historyArray.unshift(Historian.HISTORY_TOKEN + self._currentUrl); } // Some devices have a de facto URL length limit of around 1000 characters, so trim URL by dropping history elements. // Keep the oldest history entry - drop oldest items from the middle. function trimUrlHistoryToLength() { while (self._historyArray.length > 1 && self.toString().length + destinationUrl.length > 999) { self._historyArray.splice(-2, 1); } } if (this._currentUrl === '') { return destinationUrl; } replaceRouteInSource(); addCurrentUrlToHistory(); trimUrlHistoryToLength(); fragmentSeparator = isRouteInDestination() ? '' : '#'; return destinationUrl + fragmentSeparator + this.toString(); }
function forward (destinationUrl) { var fragmentSeparator, self; self = this; function isRouteInDestination() { return (destinationUrl.indexOf('#') !== -1); } function replaceRouteInSource() { if (self._currentUrl.indexOf('#') !== -1) { self._currentUrl = self._currentUrl.replace('#', Historian.ROUTE_TOKEN); } } function addCurrentUrlToHistory() { self._historyArray.unshift(Historian.HISTORY_TOKEN + self._currentUrl); } // Some devices have a de facto URL length limit of around 1000 characters, so trim URL by dropping history elements. // Keep the oldest history entry - drop oldest items from the middle. function trimUrlHistoryToLength() { while (self._historyArray.length > 1 && self.toString().length + destinationUrl.length > 999) { self._historyArray.splice(-2, 1); } } if (this._currentUrl === '') { return destinationUrl; } replaceRouteInSource(); addCurrentUrlToHistory(); trimUrlHistoryToLength(); fragmentSeparator = isRouteInDestination() ? '' : '#'; return destinationUrl + fragmentSeparator + this.toString(); }
JavaScript
function trimUrlHistoryToLength() { while (self._historyArray.length > 1 && self.toString().length + destinationUrl.length > 999) { self._historyArray.splice(-2, 1); } }
function trimUrlHistoryToLength() { while (self._historyArray.length > 1 && self.toString().length + destinationUrl.length > 999) { self._historyArray.splice(-2, 1); } }
JavaScript
function render (device) { // keep the element hidden until data is bound and items created if (!this._maskElement) { this._maskElement = device.createContainer(this.id + '_mask', ['horizontallistmask', 'notscrolling']); } else { device.clearElement(this._maskElement); this._childWidgetsInDocument = []; } if (this._viewportMode !== HorizontalCarousel.VIEWPORT_MODE_DOM) { device.appendChildElement(this._maskElement, render.base.call(this, device)); } else { if (!this._dataBound && this._dataSource && this._itemFormatter) { this._createDataBoundItems(device); } if (!this.outputElement) { if (this._renderMode === List.RENDER_MODE_LIST) { this.outputElement = device.createList(this.id, this.getClasses()); } else { this.outputElement = device.createContainer(this.id, this.getClasses()); } } device.appendChildElement(this._maskElement, this.outputElement); } // Don't hide if we're never going to databind (or it'll never be shown); if (this._dataSource) { device.hideElement({ el: this._maskElement, skipAnim: true }); } else { var self = this; var config = device.getConfig(); var delay = 100; if (config.widgets && config.widgets.horizontalcarousel && config.widgets.horizontalcarousel.bindDelay) { delay = config.widgets.horizontalcarousel.bindDelay; } setTimeout(function () { self._onDataBound(); }, delay); } return this._maskElement; }
function render (device) { // keep the element hidden until data is bound and items created if (!this._maskElement) { this._maskElement = device.createContainer(this.id + '_mask', ['horizontallistmask', 'notscrolling']); } else { device.clearElement(this._maskElement); this._childWidgetsInDocument = []; } if (this._viewportMode !== HorizontalCarousel.VIEWPORT_MODE_DOM) { device.appendChildElement(this._maskElement, render.base.call(this, device)); } else { if (!this._dataBound && this._dataSource && this._itemFormatter) { this._createDataBoundItems(device); } if (!this.outputElement) { if (this._renderMode === List.RENDER_MODE_LIST) { this.outputElement = device.createList(this.id, this.getClasses()); } else { this.outputElement = device.createContainer(this.id, this.getClasses()); } } device.appendChildElement(this._maskElement, this.outputElement); } // Don't hide if we're never going to databind (or it'll never be shown); if (this._dataSource) { device.hideElement({ el: this._maskElement, skipAnim: true }); } else { var self = this; var config = device.getConfig(); var delay = 100; if (config.widgets && config.widgets.horizontalcarousel && config.widgets.horizontalcarousel.bindDelay) { delay = config.widgets.horizontalcarousel.bindDelay; } setTimeout(function () { self._onDataBound(); }, delay); } return this._maskElement; }
JavaScript
function _onKeyDown (evt) { // This event handler is already bound (int HorizontalList), we override it to add wrapping logic // Block all movement if the carousel is scrolling if (this._scrollHandle && ( evt.keyCode === KeyEvent.VK_LEFT || evt.keyCode === KeyEvent.VK_RIGHT || evt.keyCode === KeyEvent.VK_UP || evt.keyCode === KeyEvent.VK_DOWN )) { evt.stopPropagation(); return; } switch (evt.keyCode) { case KeyEvent.VK_LEFT: if (this.selectPreviousChildWidget()) { evt.stopPropagation(); } break; case KeyEvent.VK_RIGHT: if (this.selectNextChildWidget()) { evt.stopPropagation(); } break; } }
function _onKeyDown (evt) { // This event handler is already bound (int HorizontalList), we override it to add wrapping logic // Block all movement if the carousel is scrolling if (this._scrollHandle && ( evt.keyCode === KeyEvent.VK_LEFT || evt.keyCode === KeyEvent.VK_RIGHT || evt.keyCode === KeyEvent.VK_UP || evt.keyCode === KeyEvent.VK_DOWN )) { evt.stopPropagation(); return; } switch (evt.keyCode) { case KeyEvent.VK_LEFT: if (this.selectPreviousChildWidget()) { evt.stopPropagation(); } break; case KeyEvent.VK_RIGHT: if (this.selectNextChildWidget()) { evt.stopPropagation(); } break; } }
JavaScript
function _moveChildWidgetSelection (direction) { var device = this.getCurrentApplication().getDevice(); if (this._scrollHandle) { device.stopAnimation(this._scrollHandle); } var _newIndex = this._selectedIndex; var _nodeIndex = this._selectedIndex + this._prefixClones; var _oldSelectedWidget = this._activeChildWidget; var _newSelectedWidget = null; var _centerElement = null; var _wrapped = false; do { if (direction === HorizontalCarousel.SELECTION_DIRECTION_LEFT) { _nodeIndex--; if (_newIndex > 0) { _newIndex--; } else if (this._wrapMode && this._childWidgetOrder.length > 3) { /* Only wrap when more than 3 items */ _newIndex = this._childWidgetOrder.length - 1; _wrapped = true; } else { break; } } else if (direction === HorizontalCarousel.SELECTION_DIRECTION_RIGHT) { _nodeIndex++; if (_newIndex < this._childWidgetOrder.length - 1) { _newIndex++; } else if (this._wrapMode && this._childWidgetOrder.length > 3) { /* Only wrap when more than 3 items */ _newIndex = 0; _wrapped = true; } else { break; } } var _widget = this._childWidgetOrder[_newIndex]; if (_widget.isFocusable()) { _newSelectedWidget = _widget; break; } } while (true); // Centre on a cloned carousel item if we're wrapping to the other end. // Otherwise, just go to the new selected item. if (_wrapped && this._wrapMode === HorizontalCarousel.WRAP_MODE_VISUAL) { _centerElement = this._getWrappedElement(direction, _oldSelectedWidget.outputElement); } else if (_newSelectedWidget) { _centerElement = _newSelectedWidget.outputElement; } if (_newSelectedWidget && _centerElement) { var self = this; this.bubbleEvent(new BeforeSelectedItemChangeEvent(this, _newSelectedWidget, _newIndex)); var scrollDone = function () { if (!self._activateThenScroll) { self.setActiveChildWidget(_newSelectedWidget); self._selectedIndex = _newIndex; } // If we've just moved to the fake item off the end of the wrapped carousel, // snap to the real item at the opposite end when the animation completes. if (_wrapped && self._wrapMode === HorizontalCarousel.WRAP_MODE_VISUAL) { self._alignToElement(self._activeChildWidget.outputElement, true); } // Allow the carousel to move again. self.refreshViewport(); self._scrollHandle = null; }; if (this._activateThenScroll) { this.setActiveChildWidget(_newSelectedWidget); this._selectedIndex = _newIndex; } // If the offset is zero it means the element is not in the DOM, i.e. the other end of the carousel, scroll to 1 pixel // otherwise in CSS3 the scrollDone event will never be called var elpos = device.getElementOffset(_centerElement); if (elpos.left === 0) { elpos.left = 1; } var config = device.getConfig(); var animate = !config.widgets || !config.widgets.horizontalcarousel || (config.widgets.horizontalcarousel.animate !== false); this._scrollHandle = this._alignToElement(_centerElement, this._isAnimationOverridden(animate), scrollDone); return true; } else { return false; } }
function _moveChildWidgetSelection (direction) { var device = this.getCurrentApplication().getDevice(); if (this._scrollHandle) { device.stopAnimation(this._scrollHandle); } var _newIndex = this._selectedIndex; var _nodeIndex = this._selectedIndex + this._prefixClones; var _oldSelectedWidget = this._activeChildWidget; var _newSelectedWidget = null; var _centerElement = null; var _wrapped = false; do { if (direction === HorizontalCarousel.SELECTION_DIRECTION_LEFT) { _nodeIndex--; if (_newIndex > 0) { _newIndex--; } else if (this._wrapMode && this._childWidgetOrder.length > 3) { /* Only wrap when more than 3 items */ _newIndex = this._childWidgetOrder.length - 1; _wrapped = true; } else { break; } } else if (direction === HorizontalCarousel.SELECTION_DIRECTION_RIGHT) { _nodeIndex++; if (_newIndex < this._childWidgetOrder.length - 1) { _newIndex++; } else if (this._wrapMode && this._childWidgetOrder.length > 3) { /* Only wrap when more than 3 items */ _newIndex = 0; _wrapped = true; } else { break; } } var _widget = this._childWidgetOrder[_newIndex]; if (_widget.isFocusable()) { _newSelectedWidget = _widget; break; } } while (true); // Centre on a cloned carousel item if we're wrapping to the other end. // Otherwise, just go to the new selected item. if (_wrapped && this._wrapMode === HorizontalCarousel.WRAP_MODE_VISUAL) { _centerElement = this._getWrappedElement(direction, _oldSelectedWidget.outputElement); } else if (_newSelectedWidget) { _centerElement = _newSelectedWidget.outputElement; } if (_newSelectedWidget && _centerElement) { var self = this; this.bubbleEvent(new BeforeSelectedItemChangeEvent(this, _newSelectedWidget, _newIndex)); var scrollDone = function () { if (!self._activateThenScroll) { self.setActiveChildWidget(_newSelectedWidget); self._selectedIndex = _newIndex; } // If we've just moved to the fake item off the end of the wrapped carousel, // snap to the real item at the opposite end when the animation completes. if (_wrapped && self._wrapMode === HorizontalCarousel.WRAP_MODE_VISUAL) { self._alignToElement(self._activeChildWidget.outputElement, true); } // Allow the carousel to move again. self.refreshViewport(); self._scrollHandle = null; }; if (this._activateThenScroll) { this.setActiveChildWidget(_newSelectedWidget); this._selectedIndex = _newIndex; } // If the offset is zero it means the element is not in the DOM, i.e. the other end of the carousel, scroll to 1 pixel // otherwise in CSS3 the scrollDone event will never be called var elpos = device.getElementOffset(_centerElement); if (elpos.left === 0) { elpos.left = 1; } var config = device.getConfig(); var animate = !config.widgets || !config.widgets.horizontalcarousel || (config.widgets.horizontalcarousel.animate !== false); this._scrollHandle = this._alignToElement(_centerElement, this._isAnimationOverridden(animate), scrollDone); return true; } else { return false; } }
JavaScript
function loadScript (url, callbackFunctionRegExp, callbacks, timeout, callbackSuffix) { var self = this; var script = null; var funcName = '_antie_callback_' + (callbackSuffix || ((new Date() * 1) + '_' + Math.floor(Math.random() * 10000000))); if (window[funcName]) { throw 'A request with the name ' + funcName + ' is already in flight'; } var timeoutHandle = window.setTimeout(function () { if (window[funcName]) { if (script) { self.removeElement(script); } delete window[funcName]; if (callbacks && callbacks.onError) { callbacks.onError('timeout'); } } }, timeout || 5000); window[funcName] = function (obj) { if (timeout) { window.clearTimeout(timeoutHandle); } if (callbacks && callbacks.onSuccess) { callbacks.onSuccess(obj); } self.removeElement(script); delete window[funcName]; }; script = this._createElement('script'); script.src = url.replace(callbackFunctionRegExp, funcName); var head = document.getElementsByTagName('head')[0]; head.appendChild(script); return script; }
function loadScript (url, callbackFunctionRegExp, callbacks, timeout, callbackSuffix) { var self = this; var script = null; var funcName = '_antie_callback_' + (callbackSuffix || ((new Date() * 1) + '_' + Math.floor(Math.random() * 10000000))); if (window[funcName]) { throw 'A request with the name ' + funcName + ' is already in flight'; } var timeoutHandle = window.setTimeout(function () { if (window[funcName]) { if (script) { self.removeElement(script); } delete window[funcName]; if (callbacks && callbacks.onError) { callbacks.onError('timeout'); } } }, timeout || 5000); window[funcName] = function (obj) { if (timeout) { window.clearTimeout(timeoutHandle); } if (callbacks && callbacks.onSuccess) { callbacks.onSuccess(obj); } self.removeElement(script); delete window[funcName]; }; script = this._createElement('script'); script.src = url.replace(callbackFunctionRegExp, funcName); var head = document.getElementsByTagName('head')[0]; head.appendChild(script); return script; }
JavaScript
function loadURL (url, opts) { var xhr = this._newXMLHttpRequest(); if (opts.timeout) { xhr.timeout = opts.timeout; } xhr.onreadystatechange = function () { if (xhr.readyState === 4) { xhr.onreadystatechange = null; if (xhr.status >= 200 && xhr.status < 300) { if (opts.onLoad) { opts.onLoad(xhr.responseText, xhr.status); } } else { if (opts.onError) { opts.onError(xhr.responseText, xhr.status); } } } }; try { xhr.open(opts.method || 'GET', url, true); // TODO The opts protection in the following expression is redundant as there are lots of other places an undefined opts will cause TypeError to be thrown if (opts && opts.headers) { for (var header in opts.headers) { if (opts.headers.hasOwnProperty(header)) { xhr.setRequestHeader(header, opts.headers[header]); } } } xhr.send(opts.data || null); } catch (ex) { if (opts.onError) { opts.onError(ex); } } return xhr; }
function loadURL (url, opts) { var xhr = this._newXMLHttpRequest(); if (opts.timeout) { xhr.timeout = opts.timeout; } xhr.onreadystatechange = function () { if (xhr.readyState === 4) { xhr.onreadystatechange = null; if (xhr.status >= 200 && xhr.status < 300) { if (opts.onLoad) { opts.onLoad(xhr.responseText, xhr.status); } } else { if (opts.onError) { opts.onError(xhr.responseText, xhr.status); } } } }; try { xhr.open(opts.method || 'GET', url, true); // TODO The opts protection in the following expression is redundant as there are lots of other places an undefined opts will cause TypeError to be thrown if (opts && opts.headers) { for (var header in opts.headers) { if (opts.headers.hasOwnProperty(header)) { xhr.setRequestHeader(header, opts.headers[header]); } } } xhr.send(opts.data || null); } catch (ex) { if (opts.onError) { opts.onError(ex); } } return xhr; }
JavaScript
function crossDomainPost (url, data, opts) { var iframe, form; var postRequestHasBeenSent = false; var blankPageToLoad = opts.blankUrl || 'blank.html'; var timeoutHandle; function iframeLoadTimeoutCallback() { iframe.onload = null; if (opts.onError) { opts.onError('timeout'); } } function iframeLoadedCallback() { var urlLoadedIntoInvisibleIFrame, errorGettingIFrameLocation; try { urlLoadedIntoInvisibleIFrame = iframe.contentWindow.location.href; } catch (exception) { errorGettingIFrameLocation = exception; } if (errorGettingIFrameLocation || !urlLoadedIntoInvisibleIFrame) { // we didn't load the page - give the browser a second chance to load the iframe setTimeout(function () { iframe.src = blankPageToLoad + '#2'; }, 500); return; } if (postRequestHasBeenSent === false) { postRequestHasBeenSent = true; createForm(); for (var name in data) { if(data.hasOwnProperty(name)){ createField(name, data[name]); } } form.submit(); } else { if (timeoutHandle) { clearTimeout(timeoutHandle); } iframe.onload = null; try { var responseData = iframe.contentWindow.name; iframe.parentNode.removeChild(iframe); if (opts.onLoad) { opts.onLoad(responseData); } } catch (exception) { if (opts.onError) { opts.onError(exception); } } } } function createForm() { var doc = iframe.contentWindow.document; form = doc.createElement('form'); form.method = 'POST'; form.action = url; doc.body.appendChild(form); } function createField(name, value) { var input = document.createElement('input'); input.type = 'hidden'; input.name = name; input.value = value; form.appendChild(input); } function createIframe() { iframe = document.createElement('iframe'); iframe.style.width = '0'; iframe.style.height = '0'; iframe.src = blankPageToLoad + '#1'; iframe.onload = iframeLoadedCallback; document.body.appendChild(iframe); } timeoutHandle = setTimeout(iframeLoadTimeoutCallback, (opts.timeout || 10) * 1000); /* 10 second default */ createIframe(); }
function crossDomainPost (url, data, opts) { var iframe, form; var postRequestHasBeenSent = false; var blankPageToLoad = opts.blankUrl || 'blank.html'; var timeoutHandle; function iframeLoadTimeoutCallback() { iframe.onload = null; if (opts.onError) { opts.onError('timeout'); } } function iframeLoadedCallback() { var urlLoadedIntoInvisibleIFrame, errorGettingIFrameLocation; try { urlLoadedIntoInvisibleIFrame = iframe.contentWindow.location.href; } catch (exception) { errorGettingIFrameLocation = exception; } if (errorGettingIFrameLocation || !urlLoadedIntoInvisibleIFrame) { // we didn't load the page - give the browser a second chance to load the iframe setTimeout(function () { iframe.src = blankPageToLoad + '#2'; }, 500); return; } if (postRequestHasBeenSent === false) { postRequestHasBeenSent = true; createForm(); for (var name in data) { if(data.hasOwnProperty(name)){ createField(name, data[name]); } } form.submit(); } else { if (timeoutHandle) { clearTimeout(timeoutHandle); } iframe.onload = null; try { var responseData = iframe.contentWindow.name; iframe.parentNode.removeChild(iframe); if (opts.onLoad) { opts.onLoad(responseData); } } catch (exception) { if (opts.onError) { opts.onError(exception); } } } } function createForm() { var doc = iframe.contentWindow.document; form = doc.createElement('form'); form.method = 'POST'; form.action = url; doc.body.appendChild(form); } function createField(name, value) { var input = document.createElement('input'); input.type = 'hidden'; input.name = name; input.value = value; form.appendChild(input); } function createIframe() { iframe = document.createElement('iframe'); iframe.style.width = '0'; iframe.style.height = '0'; iframe.src = blankPageToLoad + '#1'; iframe.onload = iframeLoadedCallback; document.body.appendChild(iframe); } timeoutHandle = setTimeout(iframeLoadTimeoutCallback, (opts.timeout || 10) * 1000); /* 10 second default */ createIframe(); }
JavaScript
function executeCrossDomainGet (url, opts, jsonpOptions) { var callbackKey, callbackQuery, modifiedOpts; jsonpOptions = jsonpOptions || {}; if (configSupportsCORS(this.getConfig())) { modifiedOpts = { onLoad: function onLoad (jsonResponse) { var json = jsonResponse ? JSON.parse(jsonResponse) : {}; opts.onSuccess(json); }, onError: opts.onError }; if (opts.bearerToken) { modifiedOpts.headers = { Authorization: 'Bearer ' + opts.bearerToken }; } if (opts.timeout) { modifiedOpts.timeout = opts.timeout; } this.loadURL(url, modifiedOpts); } else { callbackKey = jsonpOptions.callbackKey || 'callback'; callbackQuery = '?' + callbackKey + '=%callback%'; if (url.indexOf('?') === -1) { url = url + callbackQuery; } else { url = url.replace('?', callbackQuery + '&'); } if (opts.bearerToken) { url = url + '&bearerToken=' + opts.bearerToken; } this.loadScript(url, /%callback%/, opts, jsonpOptions.timeout, jsonpOptions.id); } }
function executeCrossDomainGet (url, opts, jsonpOptions) { var callbackKey, callbackQuery, modifiedOpts; jsonpOptions = jsonpOptions || {}; if (configSupportsCORS(this.getConfig())) { modifiedOpts = { onLoad: function onLoad (jsonResponse) { var json = jsonResponse ? JSON.parse(jsonResponse) : {}; opts.onSuccess(json); }, onError: opts.onError }; if (opts.bearerToken) { modifiedOpts.headers = { Authorization: 'Bearer ' + opts.bearerToken }; } if (opts.timeout) { modifiedOpts.timeout = opts.timeout; } this.loadURL(url, modifiedOpts); } else { callbackKey = jsonpOptions.callbackKey || 'callback'; callbackQuery = '?' + callbackKey + '=%callback%'; if (url.indexOf('?') === -1) { url = url + callbackQuery; } else { url = url.replace('?', callbackQuery + '&'); } if (opts.bearerToken) { url = url + '&bearerToken=' + opts.bearerToken; } this.loadScript(url, /%callback%/, opts, jsonpOptions.timeout, jsonpOptions.id); } }
JavaScript
function executeCrossDomainPost (url, data, opts) { var payload, modifiedOpts, formData; payload = JSON.stringify(data); if (configSupportsCORS(this.getConfig())) { modifiedOpts = { onLoad: opts.onLoad, onError: opts.onError, headers: { 'Content-Type': 'application/json' }, data: payload, method: 'POST' }; if (opts.bearerToken) { modifiedOpts.headers.Authorization = 'Bearer ' + opts.bearerToken; } this.loadURL(url, modifiedOpts); } else { formData = {}; formData[opts.fieldName] = payload; if (opts.bearerToken) { formData.bearerToken = opts.bearerToken; } this.crossDomainPost(url, formData, { onLoad: opts.onLoad, onError: opts.onError, blankUrl: opts.blankUrl }); } }
function executeCrossDomainPost (url, data, opts) { var payload, modifiedOpts, formData; payload = JSON.stringify(data); if (configSupportsCORS(this.getConfig())) { modifiedOpts = { onLoad: opts.onLoad, onError: opts.onError, headers: { 'Content-Type': 'application/json' }, data: payload, method: 'POST' }; if (opts.bearerToken) { modifiedOpts.headers.Authorization = 'Bearer ' + opts.bearerToken; } this.loadURL(url, modifiedOpts); } else { formData = {}; formData[opts.fieldName] = payload; if (opts.bearerToken) { formData.bearerToken = opts.bearerToken; } this.crossDomainPost(url, formData, { onLoad: opts.onLoad, onError: opts.onError, blankUrl: opts.blankUrl }); } }
JavaScript
function render (device) { this.outputElement = render.base.call(this, device); this._buffer = device.createButton(this.id+'_buffer'); device.addClassToElement(this._buffer, 'scrubbarbuffer'); device.prependChildElement(this.outputElement, this._buffer); return this.outputElement; }
function render (device) { this.outputElement = render.base.call(this, device); this._buffer = device.createButton(this.id+'_buffer'); device.addClassToElement(this._buffer, 'scrubbarbuffer'); device.prependChildElement(this.outputElement, this._buffer); return this.outputElement; }
JavaScript
function indicesVisibleWhenAlignedToIndex (index) { var maskLength, visibleIndices; maskLength = this.getLength(); visibleIndices = this._visibleIndixesBefore(index, maskLength).concat( this._visibleIndicesFrom(index, maskLength) ); return visibleIndices; }
function indicesVisibleWhenAlignedToIndex (index) { var maskLength, visibleIndices; maskLength = this.getLength(); visibleIndices = this._visibleIndixesBefore(index, maskLength).concat( this._visibleIndicesFrom(index, maskLength) ); return visibleIndices; }
JavaScript
function remove (widget, retainElement) { if (this.hasChildWidget(widget.id)) { widget.removeClass('carouselItem'); return this._widgetStrip.remove(widget, retainElement); } }
function remove (widget, retainElement) { if (this.hasChildWidget(widget.id)) { widget.removeClass('carouselItem'); return this._widgetStrip.remove(widget, retainElement); } }
JavaScript
function render (device) { this.outputElement = device.createContainer(this.id, this.getClasses()); this._leftElement = device.createContainer(this.id + '_left'); this._innerElement = device.createContainer(this.id + '_inner'); device.appendChildElement(this._leftElement, this._innerElement); device.appendChildElement(this.outputElement, this._leftElement); if (this._label) { device.appendChildElement(this.outputElement, this._label.render(device)); } this._moveInner(); return this.outputElement; }
function render (device) { this.outputElement = device.createContainer(this.id, this.getClasses()); this._leftElement = device.createContainer(this.id + '_left'); this._innerElement = device.createContainer(this.id + '_inner'); device.appendChildElement(this._leftElement, this._innerElement); device.appendChildElement(this.outputElement, this._leftElement); if (this._label) { device.appendChildElement(this.outputElement, this._label.render(device)); } this._moveInner(); return this.outputElement; }
JavaScript
function _moveInner () { var device = this.getCurrentApplication().getDevice(); var elsize = device.getElementSize(this._leftElement); var handleSize = device.getElementSize(this._innerElement); var left = Math.floor(this._value * (elsize.width - handleSize.width)); if (left !== this._lastLeft) { this._lastLeft = left; if (this._moveHandle) { device.stopAnimation(this._moveHandle); } var config = device.getConfig(); var animate = !config.widgets || !config.widgets.horizontalprogress || (config.widgets.horizontalprogress.animate !== false); this._moveHandle = device.moveElementTo({ el: this._innerElement, to: { left: left }, skipAnim: !animate }); } }
function _moveInner () { var device = this.getCurrentApplication().getDevice(); var elsize = device.getElementSize(this._leftElement); var handleSize = device.getElementSize(this._innerElement); var left = Math.floor(this._value * (elsize.width - handleSize.width)); if (left !== this._lastLeft) { this._lastLeft = left; if (this._moveHandle) { device.stopAnimation(this._moveHandle); } var config = device.getConfig(); var animate = !config.widgets || !config.widgets.horizontalprogress || (config.widgets.horizontalprogress.animate !== false); this._moveHandle = device.moveElementTo({ el: this._innerElement, to: { left: left }, skipAnim: !animate }); } }
JavaScript
function render (device) { // TODO: is there a more efficient way of doing this? var s = this.getTextAsRendered(device); if(!this.outputElement) { this.outputElement = device.createLabel(this.id, this.getClasses(), s, this._enableHTML); } else { device.setElementContent(this.outputElement, s, this._enableHTML); } return this.outputElement; }
function render (device) { // TODO: is there a more efficient way of doing this? var s = this.getTextAsRendered(device); if(!this.outputElement) { this.outputElement = device.createLabel(this.id, this.getClasses(), s, this._enableHTML); } else { device.setElementContent(this.outputElement, s, this._enableHTML); } return this.outputElement; }
JavaScript
function add (index, options) { var self = this; var alignFunction = createAlignFunction(self, index, options); this._queue.push(alignFunction); }
function add (index, options) { var self = this; var alignFunction = createAlignFunction(self, index, options); this._queue.push(alignFunction); }
JavaScript
function start () { if (!this._started) { this._runFirstInQueue(); } }
function start () { if (!this._started) { this._runFirstInQueue(); } }
JavaScript
function complete () { if (this._started) { this._setSkip(true); this._mask.stopAnimation(); } }
function complete () { if (this._started) { this._setSkip(true); this._mask.stopAnimation(); } }
JavaScript
function _onKeyDown (evt) { if(evt.keyCode !== KeyEvent.VK_UP && evt.keyCode !== KeyEvent.VK_DOWN) { return; } var _newSelectedIndex = this._selectedIndex; var _newSelectedWidget = null; do { if(evt.keyCode === KeyEvent.VK_UP) { _newSelectedIndex--; } else if(evt.keyCode === KeyEvent.VK_DOWN) { _newSelectedIndex++; } if(_newSelectedIndex < 0 || _newSelectedIndex >= this._childWidgetOrder.length) { break; } var _widget = this._childWidgetOrder[_newSelectedIndex]; if(_widget.isFocusable()) { _newSelectedWidget = _widget; break; } } while(true); if(_newSelectedWidget) { this.setActiveChildWidget(_newSelectedWidget); evt.stopPropagation(); } }
function _onKeyDown (evt) { if(evt.keyCode !== KeyEvent.VK_UP && evt.keyCode !== KeyEvent.VK_DOWN) { return; } var _newSelectedIndex = this._selectedIndex; var _newSelectedWidget = null; do { if(evt.keyCode === KeyEvent.VK_UP) { _newSelectedIndex--; } else if(evt.keyCode === KeyEvent.VK_DOWN) { _newSelectedIndex++; } if(_newSelectedIndex < 0 || _newSelectedIndex >= this._childWidgetOrder.length) { break; } var _widget = this._childWidgetOrder[_newSelectedIndex]; if(_widget.isFocusable()) { _newSelectedWidget = _widget; break; } } while(true); if(_newSelectedWidget) { this.setActiveChildWidget(_newSelectedWidget); evt.stopPropagation(); } }
JavaScript
function attach (carousel) { this._carousel = carousel; this._addKeyListeners(); this._addAlignmentListeners(); }
function attach (carousel) { this._carousel = carousel; this._addKeyListeners(); this._addAlignmentListeners(); }
JavaScript
function moveContentsTo (relativePixels, animOptions) { var moveElementOptions; moveElementOptions = this._getOptions(animOptions, relativePixels); this.stopAnimation(); this._animating = true; this._currentAnimation = this._device.moveElementTo(moveElementOptions); }
function moveContentsTo (relativePixels, animOptions) { var moveElementOptions; moveElementOptions = this._getOptions(animOptions, relativePixels); this.stopAnimation(); this._animating = true; this._currentAnimation = this._device.moveElementTo(moveElementOptions); }
JavaScript
function stopAnimation () { if (this._animating) { this._device.stopAnimation(this._currentAnimation); this._clearAnimating(); } }
function stopAnimation () { if (this._animating) { this._device.stopAnimation(this._currentAnimation); this._clearAnimating(); } }
JavaScript
function init (options, config) { var property, timeEasing; config = config || {}; init.base.call(this); for(property in options.to) { if(options.to.hasOwnProperty(property)) { timeEasing = options.easing || config.easing; this.setProperty(property, { duration: options.duration || config.duration, delay: options.delay, timingFn: timeEasing ? TransitionDefinition.easingLookup[timeEasing] : undefined }); } } }
function init (options, config) { var property, timeEasing; config = config || {}; init.base.call(this); for(property in options.to) { if(options.to.hasOwnProperty(property)) { timeEasing = options.easing || config.easing; this.setProperty(property, { duration: options.duration || config.duration, delay: options.delay, timingFn: timeEasing ? TransitionDefinition.easingLookup[timeEasing] : undefined }); } } }
JavaScript
function appendAllTo (widget) { this._bindAll( widget, this._appendItem, this._disableAutoCalc, this._enableAutoCalc ); }
function appendAllTo (widget) { this._bindAll( widget, this._appendItem, this._disableAutoCalc, this._enableAutoCalc ); }
JavaScript
function loadStyleSheet (url, callback) { var self = this; function supportsCssRules() { var style = self._createElement('style'); style.type = 'text/css'; style.innerHTML = 'body {};'; style.className = 'added-by-antie'; document.getElementsByTagName('head')[0].appendChild(style); try { style.sheet.cssRules; return true; } catch(e) { } finally { style.parentNode.removeChild(style); } return false; } if (callback && supportsCssRules()) { var style = this._createElement('style'); style.type = 'text/css'; style.innerHTML = '@import url(\'' + url + '\');'; style.className = 'added-by-antie'; document.getElementsByTagName('head')[0].appendChild(style); var interval = window.setInterval(function() { try { style.sheet.cssRules; window.clearInterval(interval); } catch(ex) { return; } callback(url); }, 200); } else { var link = this._createElement('link'); link.type = 'text/css'; link.rel = 'stylesheet'; link.href = url; link.className = 'added-by-antie'; document.getElementsByTagName('head')[0].appendChild(link); // Onload trickery from: // http://www.backalleycoder.com/2011/03/20/link-tag-css-stylesheet-load-event/ if (callback) { var img = this._createElement('img'); var done = function() { img.onerror = function() {}; callback(url); img.parentNode.removeChild(img); }; img.onerror = done; this.getTopLevelElement().appendChild(img); img.src = url; } } return style; }
function loadStyleSheet (url, callback) { var self = this; function supportsCssRules() { var style = self._createElement('style'); style.type = 'text/css'; style.innerHTML = 'body {};'; style.className = 'added-by-antie'; document.getElementsByTagName('head')[0].appendChild(style); try { style.sheet.cssRules; return true; } catch(e) { } finally { style.parentNode.removeChild(style); } return false; } if (callback && supportsCssRules()) { var style = this._createElement('style'); style.type = 'text/css'; style.innerHTML = '@import url(\'' + url + '\');'; style.className = 'added-by-antie'; document.getElementsByTagName('head')[0].appendChild(style); var interval = window.setInterval(function() { try { style.sheet.cssRules; window.clearInterval(interval); } catch(ex) { return; } callback(url); }, 200); } else { var link = this._createElement('link'); link.type = 'text/css'; link.rel = 'stylesheet'; link.href = url; link.className = 'added-by-antie'; document.getElementsByTagName('head')[0].appendChild(link); // Onload trickery from: // http://www.backalleycoder.com/2011/03/20/link-tag-css-stylesheet-load-event/ if (callback) { var img = this._createElement('img'); var done = function() { img.onerror = function() {}; callback(url); img.parentNode.removeChild(img); }; img.onerror = done; this.getTopLevelElement().appendChild(img); img.src = url; } } return style; }
JavaScript
function prependChildElement (to, el) { if (to.childNodes.length > 0) { to.insertBefore(el, to.childNodes[0]); } else { to.appendChild(el); } }
function prependChildElement (to, el) { if (to.childNodes.length > 0) { to.insertBefore(el, to.childNodes[0]); } else { to.appendChild(el); } }
JavaScript
function insertChildElementAt (to, el, index) { if (index >= to.childNodes.length) { to.appendChild(el); } else { to.insertBefore(el, to.childNodes[index]); } }
function insertChildElementAt (to, el, index) { if (index >= to.childNodes.length) { to.appendChild(el); } else { to.insertBefore(el, to.childNodes[index]); } }
JavaScript
function removeElement (el) { if (el.parentNode) { el.parentNode.removeChild(el); } }
function removeElement (el) { if (el.parentNode) { el.parentNode.removeChild(el); } }
JavaScript
function clearElement (el) { for (var i = el.childNodes.length - 1; i >= 0; i--) { el.removeChild(el.childNodes[i]); } }
function clearElement (el) { for (var i = el.childNodes.length - 1; i >= 0; i--) { el.removeChild(el.childNodes[i]); } }
JavaScript
function removeClassFromElement (el, className, deep) { if (new RegExp(' ' + className + ' ').test(' ' + el.className + ' ')) { el.className = trim((' ' + el.className + ' ').replace(' ' + className + ' ', ' ')); } if (deep) { for (var i = 0; i < el.childNodes.length; i++) { this.removeClassFromElement(el.childNodes[i], className, true); } } }
function removeClassFromElement (el, className, deep) { if (new RegExp(' ' + className + ' ').test(' ' + el.className + ' ')) { el.className = trim((' ' + el.className + ' ').replace(' ' + className + ' ', ' ')); } if (deep) { for (var i = 0; i < el.childNodes.length; i++) { this.removeClassFromElement(el.childNodes[i], className, true); } } }
JavaScript
function addKeyEventListener () { var self = this; var _keyMap = this.getKeyMap(); var _pressed = {}; // We need to normalise these events on so that for every key pressed there's // one keydown event, followed by multiple keypress events whilst the key is // held down, followed by a single keyup event. document.onkeydown = function(e) { e = e || window.event; var _keyCode = _keyMap[e.keyCode.toString()]; if (_keyCode) { if (!_pressed[e.keyCode.toString()]) { self._application.bubbleEvent(new KeyEvent('keydown', _keyCode)); _pressed[e.keyCode.toString()] = true; } else { self._application.bubbleEvent(new KeyEvent('keypress', _keyCode)); } e.preventDefault(); } }; document.onkeyup = function(e) { e = e || window.event; var _keyCode = _keyMap[e.keyCode.toString()]; if (_keyCode) { delete _pressed[e.keyCode.toString()]; self._application.bubbleEvent(new KeyEvent('keyup', _keyCode)); e.preventDefault(); } }; document.onkeypress = function(e) { e = e || window.event; var _keyCode = _keyMap[e.keyCode.toString()]; if (_keyCode) { self._application.bubbleEvent(new KeyEvent('keypress', _keyCode)); e.preventDefault(); } }; }
function addKeyEventListener () { var self = this; var _keyMap = this.getKeyMap(); var _pressed = {}; // We need to normalise these events on so that for every key pressed there's // one keydown event, followed by multiple keypress events whilst the key is // held down, followed by a single keyup event. document.onkeydown = function(e) { e = e || window.event; var _keyCode = _keyMap[e.keyCode.toString()]; if (_keyCode) { if (!_pressed[e.keyCode.toString()]) { self._application.bubbleEvent(new KeyEvent('keydown', _keyCode)); _pressed[e.keyCode.toString()] = true; } else { self._application.bubbleEvent(new KeyEvent('keypress', _keyCode)); } e.preventDefault(); } }; document.onkeyup = function(e) { e = e || window.event; var _keyCode = _keyMap[e.keyCode.toString()]; if (_keyCode) { delete _pressed[e.keyCode.toString()]; self._application.bubbleEvent(new KeyEvent('keyup', _keyCode)); e.preventDefault(); } }; document.onkeypress = function(e) { e = e || window.event; var _keyCode = _keyMap[e.keyCode.toString()]; if (_keyCode) { self._application.bubbleEvent(new KeyEvent('keypress', _keyCode)); e.preventDefault(); } }; }
JavaScript
function addClass (className) { if (!this._classNames[className]) { this._classNames[className] = true; if (this.outputElement) { var device = this.getCurrentApplication().getDevice(); device.setElementClasses(this.outputElement, this.getClasses()); } } }
function addClass (className) { if (!this._classNames[className]) { this._classNames[className] = true; if (this.outputElement) { var device = this.getCurrentApplication().getDevice(); device.setElementClasses(this.outputElement, this.getClasses()); } } }
JavaScript
function removeClass (className) { if (this._classNames[className]) { delete(this._classNames[className]); if (this.outputElement) { var device = this.getCurrentApplication().getDevice(); device.setElementClasses(this.outputElement, this.getClasses()); } } }
function removeClass (className) { if (this._classNames[className]) { delete(this._classNames[className]); if (this.outputElement) { var device = this.getCurrentApplication().getDevice(); device.setElementClasses(this.outputElement, this.getClasses()); } } }
JavaScript
function addEventListener (ev, func) { var listeners = this._eventListeners[ev]; if (typeof listeners === 'undefined') { listeners = []; this._eventListeners[ev] = listeners; } if (!~listeners.indexOf(func)) { listeners.push(func); } }
function addEventListener (ev, func) { var listeners = this._eventListeners[ev]; if (typeof listeners === 'undefined') { listeners = []; this._eventListeners[ev] = listeners; } if (!~listeners.indexOf(func)) { listeners.push(func); } }
JavaScript
function removeEventListener (ev, func) { var listeners = this._eventListeners[ev], listener; if (!listeners) { RuntimeContext.getDevice().getLogger().error('Attempting to remove non-existent event listener'); return false; } listener = listeners.indexOf(func); if (~listener) { listeners.splice(listener, 1); } }
function removeEventListener (ev, func) { var listeners = this._eventListeners[ev], listener; if (!listeners) { RuntimeContext.getDevice().getLogger().error('Attempting to remove non-existent event listener'); return false; } listener = listeners.indexOf(func); if (~listener) { listeners.splice(listener, 1); } }
JavaScript
function fireEvent (ev) { var listeners = this._eventListeners[ev.type]; if (listeners) { for (var func in listeners) { if(listeners.hasOwnProperty(func)) { try { listeners[func](ev); } catch (exception) { var logger = this.getCurrentApplication().getDevice().getLogger(); logger.error('Error in ' + ev.type + ' event listener on widget ' + this.id + ': ' + exception.message, exception, listeners[func]); } } } } }
function fireEvent (ev) { var listeners = this._eventListeners[ev.type]; if (listeners) { for (var func in listeners) { if(listeners.hasOwnProperty(func)) { try { listeners[func](ev); } catch (exception) { var logger = this.getCurrentApplication().getDevice().getLogger(); logger.error('Error in ' + ev.type + ' event listener on widget ' + this.id + ': ' + exception.message, exception, listeners[func]); } } } } }
JavaScript
function bubbleEvent (ev) { this.fireEvent(ev); if (!ev.isPropagationStopped()) { if (this.parentWidget) { this.parentWidget.bubbleEvent(ev); } else { ev.stopPropagation(); } } }
function bubbleEvent (ev) { this.fireEvent(ev); if (!ev.isPropagationStopped()) { if (this.parentWidget) { this.parentWidget.bubbleEvent(ev); } else { ev.stopPropagation(); } } }
JavaScript
function isFocusable () { // a widget can receive focus if any of it's children or children-of-children are Buttons // We're not a button and we have no children, so we're not. return false; }
function isFocusable () { // a widget can receive focus if any of it's children or children-of-children are Buttons // We're not a button and we have no children, so we're not. return false; }
JavaScript
function lengthOfWidgetAtIndex (index) { if (this._lengths[index] !== undefined) { return this._lengths[index]; } else { this._throwNoLengthError(); } }
function lengthOfWidgetAtIndex (index) { if (this._lengths[index] !== undefined) { return this._lengths[index]; } else { this._throwNoLengthError(); } }
JavaScript
function hasChildWidget (id) { if (id === this._mask.id) { return hasChildWidget.base.call(this, id); } else { return this._widgetStrip.hasChildWidget(id); } }
function hasChildWidget (id) { if (id === this._mask.id) { return hasChildWidget.base.call(this, id); } else { return this._widgetStrip.hasChildWidget(id); } }
JavaScript
function addClass (className) { if (this._widgetStrip) { return this._widgetStrip.addClass(className); } }
function addClass (className) { if (this._widgetStrip) { return this._widgetStrip.addClass(className); } }
JavaScript
function hasClass (className) { if (this._widgetStrip) { return this._widgetStrip.hasClass(className); } else { return false; } }
function hasClass (className) { if (this._widgetStrip) { return this._widgetStrip.hasClass(className); } else { return false; } }
JavaScript
function removeClass (className) { if (this._widgetStrip) { return this._widgetStrip.removeClass(className); } }
function removeClass (className) { if (this._widgetStrip) { return this._widgetStrip.removeClass(className); } }
JavaScript
function resolveLocale(masterName, bundle, locale, context) { //Break apart the locale to get the parts. var i, parts, toLoad, nlsw, loc, val, bestLoc = "root"; parts = locale.split("-"); //Now see what bundles exist for each country/locale. //Want to walk up the chain, so if locale is en-us-foo, //look for en-us-foo, en-us, en, then root. toLoad = []; nlsw = getWaiting(masterName, context); for (i = parts.length; i > -1; i--) { loc = i ? parts.slice(0, i).join("-") : "root"; val = bundle[loc]; if (val) { //Store which bundle to use for the default bundle definition. if (locale === context.config.locale && !nlsw._match) { nlsw._match = loc; } //Store the best match for the target locale if (bestLoc === "root") { bestLoc = loc; } //Track that the locale needs to be resolved with its parts. //Mark what locale should be used when resolving. nlsw[loc] = loc; //If locale value is true, it means it is a resource that //needs to be loaded. Track it to load if it has not already //been asked for. if (val === true) { //split off the bundl name from master name and insert the //locale before the bundle name. So, if masterName is //some/path/nls/colors, then the locale fr-fr's bundle name should //be some/path/nls/fr-fr/colors val = masterName.split("/"); val.splice(-1, 0, loc); val = val.join("/"); if (!context.specified[val] && !(val in context.loaded) && !context.defined[val]) { context.defPlugin[val] = 'i18n'; toLoad.push(val); } } } } //If locale was not an exact match, store the closest match for it. if (bestLoc !== locale) { if (context.defined[bestLoc]) { //Already got it. Easy peasy lemon squeezy. context.defined[locale] = context.defined[bestLoc]; } else { //Need to wait for things to load then define it. nlsw[locale] = bestLoc; } } //Load any bundles that are still needed. if (toLoad.length) { require(toLoad, context.contextName); } }
function resolveLocale(masterName, bundle, locale, context) { //Break apart the locale to get the parts. var i, parts, toLoad, nlsw, loc, val, bestLoc = "root"; parts = locale.split("-"); //Now see what bundles exist for each country/locale. //Want to walk up the chain, so if locale is en-us-foo, //look for en-us-foo, en-us, en, then root. toLoad = []; nlsw = getWaiting(masterName, context); for (i = parts.length; i > -1; i--) { loc = i ? parts.slice(0, i).join("-") : "root"; val = bundle[loc]; if (val) { //Store which bundle to use for the default bundle definition. if (locale === context.config.locale && !nlsw._match) { nlsw._match = loc; } //Store the best match for the target locale if (bestLoc === "root") { bestLoc = loc; } //Track that the locale needs to be resolved with its parts. //Mark what locale should be used when resolving. nlsw[loc] = loc; //If locale value is true, it means it is a resource that //needs to be loaded. Track it to load if it has not already //been asked for. if (val === true) { //split off the bundl name from master name and insert the //locale before the bundle name. So, if masterName is //some/path/nls/colors, then the locale fr-fr's bundle name should //be some/path/nls/fr-fr/colors val = masterName.split("/"); val.splice(-1, 0, loc); val = val.join("/"); if (!context.specified[val] && !(val in context.loaded) && !context.defined[val]) { context.defPlugin[val] = 'i18n'; toLoad.push(val); } } } } //If locale was not an exact match, store the closest match for it. if (bestLoc !== locale) { if (context.defined[bestLoc]) { //Already got it. Easy peasy lemon squeezy. context.defined[locale] = context.defined[bestLoc]; } else { //Need to wait for things to load then define it. nlsw[locale] = bestLoc; } } //Load any bundles that are still needed. if (toLoad.length) { require(toLoad, context.contextName); } }
JavaScript
function indexAfter (index) { var potentialIndex; potentialIndex = indexAfter.base.call(this, index); return this._validateIndex(index, potentialIndex); }
function indexAfter (index) { var potentialIndex; potentialIndex = indexAfter.base.call(this, index); return this._validateIndex(index, potentialIndex); }
JavaScript
function indexBefore (index) { var potentialIndex; potentialIndex = indexBefore.base.call(this, index); return this._validateIndex(index, potentialIndex); }
function indexBefore (index) { var potentialIndex; potentialIndex = indexBefore.base.call(this, index); return this._validateIndex(index, potentialIndex); }
JavaScript
function render (device) { this.outputElement = device.createButton(this.id, this.getClasses(), '#'); for(var i=0; i<this._childWidgetOrder.length; i++) { device.appendChildElement(this.outputElement, this._childWidgetOrder[i].render(device)); } return this.outputElement; }
function render (device) { this.outputElement = device.createButton(this.id, this.getClasses(), '#'); for(var i=0; i<this._childWidgetOrder.length; i++) { device.appendChildElement(this.outputElement, this._childWidgetOrder[i].render(device)); } return this.outputElement; }
JavaScript
function focus (force) { var origDisabled = this._disabled; if(force) { this._disabled = false; } var focusChanged = true; var w = this; while(w.parentWidget) { if(!w.parentWidget.setActiveChildWidget(w)) { focusChanged = false; } w = w.parentWidget; } this._disabled = origDisabled; return focusChanged; }
function focus (force) { var origDisabled = this._disabled; if(force) { this._disabled = false; } var focusChanged = true; var w = this; while(w.parentWidget) { if(!w.parentWidget.setActiveChildWidget(w)) { focusChanged = false; } w = w.parentWidget; } this._disabled = origDisabled; return focusChanged; }
JavaScript
function _setActiveChildFocussed (focus) { if(this._focusDelayHandle) { clearTimeout(this._focusDelayHandle); } if(focus) { this.removeClass('buttonBlurred'); this.addClass('buttonFocussed'); var self = this; // Fire a focus delay event if this button has had focus for more than x-seconds. this._focusDelayHandle = setTimeout(function() { self.bubbleEvent(new FocusDelayEvent(self)); }, this._focusDelayTimeout); this.getCurrentApplication()._setFocussedWidget(this); } else { this.removeClass('buttonFocussed'); this.addClass('buttonBlurred'); } }
function _setActiveChildFocussed (focus) { if(this._focusDelayHandle) { clearTimeout(this._focusDelayHandle); } if(focus) { this.removeClass('buttonBlurred'); this.addClass('buttonFocussed'); var self = this; // Fire a focus delay event if this button has had focus for more than x-seconds. this._focusDelayHandle = setTimeout(function() { self.bubbleEvent(new FocusDelayEvent(self)); }, this._focusDelayTimeout); this.getCurrentApplication()._setFocussedWidget(this); } else { this.removeClass('buttonFocussed'); this.addClass('buttonBlurred'); } }
JavaScript
function stopPropagation () { this._propagationStopped = true; eventCount--; if (!eventCount) { this.fireEvent('emptyStack'); } }
function stopPropagation () { this._propagationStopped = true; eventCount--; if (!eventCount) { this.fireEvent('emptyStack'); } }
JavaScript
function removeEventListener (ev, func) { var listeners = eventListeners[ev], listener; if (!listeners) { RuntimeContext.getDevice().getLogger().error('Attempting to remove non-existent event listener'); return false; } listener = listeners.indexOf(func); if (~listener) { listeners.splice(listener, 1); } }
function removeEventListener (ev, func) { var listeners = eventListeners[ev], listener; if (!listeners) { RuntimeContext.getDevice().getLogger().error('Attempting to remove non-existent event listener'); return false; } listener = listeners.indexOf(func); if (~listener) { listeners.splice(listener, 1); } }
JavaScript
function fireEvent (ev) { var listeners = eventListeners[ev]; if(listeners) { for(var func in listeners) { if(listeners.hasOwnProperty(func)) { listeners[func](); } } } }
function fireEvent (ev) { var listeners = eventListeners[ev]; if(listeners) { for(var func in listeners) { if(listeners.hasOwnProperty(func)) { listeners[func](); } } } }
JavaScript
function indexAfter (index) { var potentialIndex; potentialIndex = indexAfter.base.call(this, index); return this._validateIndex(potentialIndex); }
function indexAfter (index) { var potentialIndex; potentialIndex = indexAfter.base.call(this, index); return this._validateIndex(potentialIndex); }
JavaScript
function indexBefore (index) { var potentialIndex; potentialIndex = indexBefore.base.call(this, index); return this._validateIndex(potentialIndex); }
function indexBefore (index) { var potentialIndex; potentialIndex = indexBefore.base.call(this, index); return this._validateIndex(potentialIndex); }
JavaScript
function _emitEvent (eventType, eventLabels) { var event = { type: eventType, currentTime: this.getCurrentTime(), seekableRange: this.getSeekableRange(), duration: this.getDuration(), url: this.getSource(), mimeType: this.getMimeType(), state: this.getState() }; if (eventLabels) { for (var key in eventLabels) { if(eventLabels.hasOwnProperty(key)) { event[key] = eventLabels[key]; } } } this._callbackManager.callAll(event); }
function _emitEvent (eventType, eventLabels) { var event = { type: eventType, currentTime: this.getCurrentTime(), seekableRange: this.getSeekableRange(), duration: this.getDuration(), url: this.getSource(), mimeType: this.getMimeType(), state: this.getState() }; if (eventLabels) { for (var key in eventLabels) { if(eventLabels.hasOwnProperty(key)) { event[key] = eventLabels[key]; } } } this._callbackManager.callAll(event); }
JavaScript
function _getClampedTime (seconds) { var range = this.getSeekableRange(); var offsetFromEnd = this._getClampOffsetFromConfig(); var nearToEnd = Math.max(range.end - offsetFromEnd, range.start); if (seconds < range.start) { return range.start; } else if (seconds > nearToEnd) { return nearToEnd; } else { return seconds; } }
function _getClampedTime (seconds) { var range = this.getSeekableRange(); var offsetFromEnd = this._getClampOffsetFromConfig(); var nearToEnd = Math.max(range.end - offsetFromEnd, range.start); if (seconds < range.start) { return range.start; } else if (seconds > nearToEnd) { return nearToEnd; } else { return seconds; } }
JavaScript
function _isNearToCurrentTime (seconds) { var currentTime = this.getCurrentTime(); var targetTime = this._getClampedTime(seconds); return Math.abs(currentTime - targetTime) <= this.CURRENT_TIME_TOLERANCE; }
function _isNearToCurrentTime (seconds) { var currentTime = this.getCurrentTime(); var targetTime = this._getClampedTime(seconds); return Math.abs(currentTime - targetTime) <= this.CURRENT_TIME_TOLERANCE; }
JavaScript
function ready () { if (this._onReadyHandler) { var self = this; // Run this after the current execution path is complete window.setTimeout(function () { self._onReadyHandler(self); }, 0); } }
function ready () { if (this._onReadyHandler) { var self = this; // Run this after the current execution path is complete window.setTimeout(function () { self._onReadyHandler(self); }, 0); } }
JavaScript
function addComponentContainer (id, module, args) { var container = new ComponentContainer(id); this._rootWidget.appendChildWidget(container); if (module) { this.showComponent(id, module, args); } return container; }
function addComponentContainer (id, module, args) { var container = new ComponentContainer(id); this._rootWidget.appendChildWidget(container); if (module) { this.showComponent(id, module, args); } return container; }
JavaScript
function bubbleEvent (evt) { if (this._focussedWidget) { this._focussedWidget.bubbleEvent(evt); } }
function bubbleEvent (evt) { if (this._focussedWidget) { this._focussedWidget.bubbleEvent(evt); } }
JavaScript
function broadcastEvent (evt) { if (evt.sentDown) { return; } evt.sentDown = 1; this._rootWidget.broadcastEvent(evt); }
function broadcastEvent (evt) { if (evt.sentDown) { return; } evt.sentDown = 1; this._rootWidget.broadcastEvent(evt); }
JavaScript
function _setFocussedWidget (widget) { // Check to see the widget is a Button and itself has correct focus state before recording // it as the focussed widget. if ((widget instanceof Button) && widget.isFocussed()) { this._focussedWidget = widget; } }
function _setFocussedWidget (widget) { // Check to see the widget is a Button and itself has correct focus state before recording // it as the focussed widget. if ((widget instanceof Button) && widget.isFocussed()) { this._focussedWidget = widget; } }
JavaScript
function launchAppFromURL (url, data, route, overwrite) { var query = ''; var hash = ''; var key; var completeUrl = ''; // Get existing query data, or start a brand new object if applicable. var mergedData = overwrite ? {} : this.getCurrentAppURLParameters(); // Merge in the query data passed to this function, which takes precedence over anything existing. if (data) { for (key in data) { if (data.hasOwnProperty(key)) { mergedData[key] = data[key]; // No need to escape here... } } } // Construct a query string out of the merged data. for (key in mergedData) { if (mergedData.hasOwnProperty(key)) { // Keys with values get 'key=value' syntax, valueless keys just get 'key' if (mergedData[key] === undefined || mergedData[key] === null) { query += window.encodeURIComponent(key) + '&'; } else { query += window.encodeURIComponent(key) + '=' + window.encodeURIComponent(mergedData[key]) + '&'; } } } // Trim the last & off, add a leading ? if (query.length > 0) { query = '?' + query.slice(0, -1); } // Construct the route string. if (route && route.length > 0) { hash = '#' + route.join('/'); } completeUrl = this.getDevice().getHistorian().forward(url + query + hash); // Send the browser to the final URL this.getDevice().setWindowLocationUrl(completeUrl); }
function launchAppFromURL (url, data, route, overwrite) { var query = ''; var hash = ''; var key; var completeUrl = ''; // Get existing query data, or start a brand new object if applicable. var mergedData = overwrite ? {} : this.getCurrentAppURLParameters(); // Merge in the query data passed to this function, which takes precedence over anything existing. if (data) { for (key in data) { if (data.hasOwnProperty(key)) { mergedData[key] = data[key]; // No need to escape here... } } } // Construct a query string out of the merged data. for (key in mergedData) { if (mergedData.hasOwnProperty(key)) { // Keys with values get 'key=value' syntax, valueless keys just get 'key' if (mergedData[key] === undefined || mergedData[key] === null) { query += window.encodeURIComponent(key) + '&'; } else { query += window.encodeURIComponent(key) + '=' + window.encodeURIComponent(mergedData[key]) + '&'; } } } // Trim the last & off, add a leading ? if (query.length > 0) { query = '?' + query.slice(0, -1); } // Construct the route string. if (route && route.length > 0) { hash = '#' + route.join('/'); } completeUrl = this.getDevice().getHistorian().forward(url + query + hash); // Send the browser to the final URL this.getDevice().setWindowLocationUrl(completeUrl); }
JavaScript
function back () { var historian = this.getDevice().getHistorian(); if (historian.hasHistory()) { this.getDevice().setWindowLocationUrl(historian.back()); } else { this.exit(); } }
function back () { var historian = this.getDevice().getHistorian(); if (historian.hasHistory()) { this.getDevice().setWindowLocationUrl(historian.back()); } else { this.exit(); } }
JavaScript
function exit () { if (this.hasBroadcastOrigin()) { this.getDevice().exitToBroadcast(); } else { this.getDevice().exit(); } }
function exit () { if (this.hasBroadcastOrigin()) { this.getDevice().exitToBroadcast(); } else { this.getDevice().exit(); } }
JavaScript
function each(obj, func) { var prop; for (prop in obj) { if (obj.hasOwnProperty(prop)) { func(obj, prop); } } }
function each(obj, func) { var prop; for (prop in obj) { if (obj.hasOwnProperty(prop)) { func(obj, prop); } } }
JavaScript
function simpleCopy(targetObj, srcObj) { each(srcObj, function (srcObj, prop) { targetObj[prop] = srcObj[prop]; }); return targetObj; }
function simpleCopy(targetObj, srcObj) { each(srcObj, function (srcObj, prop) { targetObj[prop] = srcObj[prop]; }); return targetObj; }
JavaScript
function tweenProps(currentPosition, params, state) { var prop, normalizedPosition; normalizedPosition = (currentPosition - params.timestamp) / params.duration; for (prop in state.current) { if (state.current.hasOwnProperty(prop) && params.to.hasOwnProperty(prop)) { state.current[prop] = tweenProp(params.originalState[prop], params.to[prop], params.easingFunc, normalizedPosition); } } return state.current; }
function tweenProps(currentPosition, params, state) { var prop, normalizedPosition; normalizedPosition = (currentPosition - params.timestamp) / params.duration; for (prop in state.current) { if (state.current.hasOwnProperty(prop) && params.to.hasOwnProperty(prop)) { state.current[prop] = tweenProp(params.originalState[prop], params.to[prop], params.easingFunc, normalizedPosition); } } return state.current; }
JavaScript
function invokeHook(hookName, hooks, applyTo, args) { var i; for (i = 0; i < hooks[hookName].length; i++) { hooks[hookName][i].apply(applyTo, args); } }
function invokeHook(hookName, hooks, applyTo, args) { var i; for (i = 0; i < hooks[hookName].length; i++) { hooks[hookName][i].apply(applyTo, args); } }
JavaScript
function applyFilter(filterName, applyTo, args) { // each(global.Tweenable.prototype.filter, function (filters, name) { each(Tweenable.prototype.filter, function (filters, name) { if (filters[name][filterName]) { filters[name][filterName].apply(applyTo, args); } }); }
function applyFilter(filterName, applyTo, args) { // each(global.Tweenable.prototype.filter, function (filters, name) { each(Tweenable.prototype.filter, function (filters, name) { if (filters[name][filterName]) { filters[name][filterName].apply(applyTo, args); } }); }
JavaScript
function timeoutHandler(params, state) { var currentTime; function doStep(time) { applyFilter('beforeTween', params.owner, [state.current, params.originalState, params.to]); tweenProps(time, params, state); applyFilter('afterTween', params.owner, [state.current, params.originalState, params.to]); if (params.hook.step) { invokeHook('step', params.hook, params.owner, [state.current]); } params.step.call(state.current); } currentTime = now(); if (currentTime < params.timestamp + params.duration && state.isAnimating) { // The tween is still running, schedule an update state.loopId = scheduleUpdate(function () { timeoutHandler(params, state); }, params.owner.fps); doStep(currentTime); } else { // The duration of the tween has expired doStep(params.timestamp + params.duration); params.owner.stop(true); } }
function timeoutHandler(params, state) { var currentTime; function doStep(time) { applyFilter('beforeTween', params.owner, [state.current, params.originalState, params.to]); tweenProps(time, params, state); applyFilter('afterTween', params.owner, [state.current, params.originalState, params.to]); if (params.hook.step) { invokeHook('step', params.hook, params.owner, [state.current]); } params.step.call(state.current); } currentTime = now(); if (currentTime < params.timestamp + params.duration && state.isAnimating) { // The tween is still running, schedule an update state.loopId = scheduleUpdate(function () { timeoutHandler(params, state); }, params.owner.fps); doStep(currentTime); } else { // The duration of the tween has expired doStep(params.timestamp + params.duration); params.owner.stop(true); } }