_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3 values | text stringlengths 52 373k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q29700 | setAllHeights | train | function setAllHeights(elements, height) {
for (let i = elements.length - 1; i >= 0; i--) {
elements[i].style.height = height;
}
} | javascript | {
"resource": ""
} |
q29701 | train | function (table) {
var finalLine = '+';
for (var i = 0; i < table.maxWidth.length; i++) {
finalLine += Array(table.maxWidth[i] + 3).join('-') + '+';
}
return finalLine;
} | javascript | {
"resource": ""
} | |
q29702 | train | function ( a, b) {
if (typeof reverse === 'boolean' && reverse === true) {
if (a[colindex] < b[colindex]) {
return 1;
}
else if (a[colindex] > b[colindex]) {
return -1;
}
else {
return 0;
}
}
else {
if (a[colindex] < b[colindex]) {
return -1;
}
else if (a[colindex] > b[colindex]) {
return 1;
}
else {
return 0;
}
}
} | javascript | {
"resource": ""
} | |
q29703 | paths | train | function paths (object, test) {
var p = []
if(test(object)) return []
for(var key in object) {
var value = object[key]
if(test(value)) p.push(key)
else if(isObject(value))
p = p.concat(paths(value, test).map(function (path) {
return [key].concat(path)
}))
}
return p
} | javascript | {
"resource": ""
} |
q29704 | collect | train | function collect(cells) {
var key, i, t, v;
for (key in cells) {
t = cells[key].tuple;
for (i=0; i<n; ++i) {
vals[i][(v = t[dims[i]])] = v;
}
}
} | javascript | {
"resource": ""
} |
q29705 | generate | train | function generate(base, tuple, index) {
var name = dims[index],
v = vals[index++],
k, key;
for (k in v) {
tuple[name] = v[k];
key = base ? base + '|' + k : k;
if (index < n) generate(key, tuple, index);
else if (!curr[key]) aggr.cell(key, tuple);
}
} | javascript | {
"resource": ""
} |
q29706 | Tap | train | function Tap(element, fn, preventEventDefault) {
classCallCheck(this, Tap);
this.element = element;
this.fn = fn;
this.preventEventDefault = preventEventDefault;
this.pointer = new OdoPointer(element, {
preventEventDefault: preventEventDefault
});
this._listen();
} | javascript | {
"resource": ""
} |
q29707 | getVelocity | train | function getVelocity(deltaTime, deltaX, deltaY) {
return new Coordinate(
finiteOrZero(deltaX / deltaTime),
finiteOrZero(deltaY / deltaTime),
);
} | javascript | {
"resource": ""
} |
q29708 | getDirection | train | function getDirection(coord1, coord2) {
if (Math.abs(coord1.x - coord2.x) >= Math.abs(coord1.y - coord2.y)) {
return getTheDirection(
coord1.x, coord2.x, Direction.LEFT,
Direction.RIGHT, Direction.NONE,
);
}
return getTheDirection(
coord1.y, coord2.y, Direction.UP,
Direction.DOWN, Direction.NONE,
);
} | javascript | {
"resource": ""
} |
q29709 | update | train | function update(t) {
var p, idx;
if (res.length < num) {
res.push(t);
} else {
idx = ~~((cnt + 1) * random());
if (idx < res.length && idx >= cap) {
p = res[idx];
if (map[tupleid(p)]) out.rem.push(p); // eviction
res[idx] = t;
}
}
++cnt;
} | javascript | {
"resource": ""
} |
q29710 | toPascalCase | train | function toPascalCase(name) {
return name.charAt(0).toUpperCase() + name.replace(/-(.)?/g, (match, c) => c.toUpperCase()).slice(1);
} | javascript | {
"resource": ""
} |
q29711 | TabsEvent | train | function TabsEvent(type, index) {
classCallCheck(this, TabsEvent);
this.type = type;
/** @type {number} */
this.index = index;
/** @type {boolean} Whether `preventDefault` has been called. */
this.defaultPrevented = false;
} | javascript | {
"resource": ""
} |
q29712 | Tabs | train | function Tabs(element) {
classCallCheck(this, Tabs);
/** @type {Element} */
var _this = possibleConstructorReturn(this, _TinyEmitter.call(this));
_this.element = element;
/** @private {number} */
_this._selectedIndex = -1;
/**
* List items, children of the tabs list.
* @type {Array.<Element>}
*/
_this.tabs = Array.from(_this.element.children);
/**
* Anchor elements inside the tab.
* @type {Array.<HTMLAnchorElement>}
*/
_this.anchors = _this.tabs.map(function (tab) {
return tab.querySelector('a');
});
/**
* Tab pane elements.
* @type {Array.<HTMLElement>}
*/
_this.panes = _this.anchors.map(function (anchor) {
return document.getElementById(anchor.getAttribute('href').substring(1));
});
/**
* Wrapper for the panes.
* @type {HTMLElement}
*/
_this.panesContainer = _this.panes[0].parentElement;
/**
* Get an array of [possible] hashes.
* @type {Array.<?string>}
*/
_this.hashes = _this.anchors.map(function (anchor) {
return anchor.getAttribute('data-hash');
});
_this.init();
return _this;
} | javascript | {
"resource": ""
} |
q29713 | initializeAll | train | function initializeAll() {
var elements = Array.from(document.querySelectorAll('[' + Settings.Attribute.TRIGGER + ']'));
var singleInstances = [];
var groupInstances = [];
var groupIds = [];
elements.forEach(function (item) {
var groupId = item.getAttribute(Settings.Attribute.GROUP);
if (groupId) {
if (!groupIds.includes(groupId)) {
var group = elements.filter(function (el) {
return el.getAttribute(Settings.Attribute.GROUP) === groupId;
});
var isAnimated = group.some(function (el) {
return el.hasAttribute(Settings.Attribute.ANIMATED);
});
groupInstances.push(isAnimated ? new ExpandableAccordion(group) : new ExpandableGroup(group));
groupIds.push(groupId);
}
} else {
singleInstances.push(new ExpandableItem(item.getAttribute(Settings.Attribute.TRIGGER)));
}
});
return singleInstances.concat(groupInstances);
} | javascript | {
"resource": ""
} |
q29714 | getSelector | train | function getSelector(Module, selector) {
// Verify that a base selector is defined.
if (typeof selector === 'undefined') {
if (Module.Selectors && Module.Selectors.BASE) {
return Module.Selectors.BASE;
}
// Support both `ClassName` and `Classes` enumerations.
const classes = Module.ClassName || Module.Classes;
if (classes && classes.BASE) {
return '.' + classes.BASE;
}
throw new TypeError('A base selector for this module must be specified.');
}
return selector;
} | javascript | {
"resource": ""
} |
q29715 | validate | train | function validate(Module, selector) {
// Verify that the Module is an Object or Class.
const type = Object.prototype.toString.call(Module);
const isObject = type === '[object Object]';
const isFunction = type === '[object Function]';
if (!(isObject || isFunction)) {
throw new TypeError(`Module must be an Function (class) or Object. Got "${Object.prototype.toString.call(Module)}".`);
}
// Verify that the module has not yet been registered.
if (store.has(selector)) {
throw new TypeError('The base selector for this module has already been registered. Please use a unique base selector.');
}
} | javascript | {
"resource": ""
} |
q29716 | register | train | function register(Module, selector) {
const _selector = getSelector(Module, selector);
validate(Module, _selector);
const methods = OdoModuleMethods(Module, _selector);
// Apply OdoModule static methods.
Object.keys(methods).forEach((method) => {
Module[method] = methods[method];
});
// Apply the OdoModule static property.
Module.Instances = new Map();
// Internally register the module.
store.set(_selector, Module);
return Module;
} | javascript | {
"resource": ""
} |
q29717 | DualViewer | train | function DualViewer(el, opts) {
classCallCheck(this, DualViewer);
var _this = possibleConstructorReturn(this, _TinyEmitter.call(this));
_this.element = el;
_this.options = Object.assign({}, DualViewer.Defaults, opts);
_this._isVertical = _this.options.isVertical;
/** @private {Element} */
_this._scrubberEl = null;
/** @private {Element} */
_this._overlayEl = null;
/** @private {Element} */
_this._underlayEl = null;
/** @private {Element} */
_this._overlayObjectEl = null;
/**
* Dragger component
* @type {OdoDraggable}
* @private
*/
_this._draggable = null;
/**
* Boundary for the scrubber.
* @type {Rect}
* @private
*/
_this._scrubberLimits = null;
/**
* The axis to drag depends on the carousel direction.
* @type {OdoPointer.Axis}
* @private
*/
_this._dragAxis = _this._isVertical ? 'y' : 'x';
/**
* Height or width.
* @type {string}
* @private
*/
_this._dimensionAttr = _this._isVertical ? 'height' : 'width';
/**
* Previous percentage revealed. Needed for window resizes to reset back to
* correct position.
* @type {number}
* @private
*/
_this._previousPercent = _this.options.startPosition;
/**
* Current position of the dual viewer.
* @type {number}
* @private
*/
_this._position = DualViewer.Position.CENTER;
/** @private {boolean} */
_this._isResting = true;
_this.decorate();
return _this;
} | javascript | {
"resource": ""
} |
q29718 | arrayify | train | function arrayify(thing) {
if (Array.isArray(thing)) {
return thing;
}
if (thing && typeof thing.length === 'number') {
return Array.from(thing);
}
return [thing];
} | javascript | {
"resource": ""
} |
q29719 | scrollToIndex | train | function scrollToIndex(index) {
var duration = 400;
var start = window.pageYOffset;
var end = index * window.innerHeight;
var amount = end - start;
var startTime = +new Date();
var easing = function easing(k) {
return -0.5 * (Math.cos(Math.PI * k) - 1);
};
var step = function step(value /* , percent */) {
window.scrollTo(0, value);
};
var complete = function complete() {
isScrolling = false;
};
var looper = function looper() {
var now = +new Date();
var remainingTime = startTime + duration - now;
var percent = 1 - (remainingTime / duration || 0);
// Abort if already past 100%.
if (percent >= 1) {
// Make sure it always finishes with 1.
step(end, 1);
complete();
return;
}
// Apply easing.
percent = easing(percent);
// Tick.
step(start + amount * percent, percent);
// Request animation frame.
requestAnimationFrame(looper);
};
isScrolling = true;
requestAnimationFrame(looper);
} | javascript | {
"resource": ""
} |
q29720 | getHueDifference | train | function getHueDifference(value) {
return hues.reduce(function (min, hue) {
var diff = Math.abs(hue - value);
if (diff < min) {
return diff;
}
return min;
}, Infinity);
} | javascript | {
"resource": ""
} |
q29721 | adjustRange | train | function adjustRange(w, bisect) {
var r0 = w.i0,
r1 = w.i1 - 1,
c = w.compare,
d = w.data,
n = d.length - 1;
if (r0 > 0 && !c(d[r0], d[r0-1])) w.i0 = bisect.left(d, d[r0]);
if (r1 < n && !c(d[r1], d[r1+1])) w.i1 = bisect.right(d, d[r1]);
} | javascript | {
"resource": ""
} |
q29722 | makePlusMinus | train | function makePlusMinus(formatter) {
return function plusMinusWrapped(value) {
if (value != null && value > 0) {
return '+' + formatter(value);
}
return formatter(value);
};
} | javascript | {
"resource": ""
} |
q29723 | makePercent | train | function makePercent(formatter) {
return function percentWrapped(value) {
if (value != null) {
return formatter(value * 100) + '%';
}
return formatter(value);
};
} | javascript | {
"resource": ""
} |
q29724 | train | function(options) {
events.EventEmitter.call(this); // inherit from EventEmitter
TRACE = options.log;
IDX = options.idx;
STATUS = options.status;
HOST = options.host;
REQUEST = options.request;
this.domoMQTT = this.connect(HOST);
} | javascript | {
"resource": ""
} | |
q29725 | train | function () {
var c = this.findCollapsibleItem();
if (c) {
//apply movedClass is needed
if(this.movedClass && this.movedClass.length > 0 && !c.hasClass(this.movedClass)) {
c.addClass(this.movedClass);
}
// passing null to add child to the front of the control list
this.$.menu.addChild(c, null);
var p = this.$.menu.hasNode();
if (p && c.hasNode()) {
c.insertNodeInParent(p);
}
return true;
}
} | javascript | {
"resource": ""
} | |
q29726 | train | function () {
var c$ = this.$.menu.children;
var c = c$[0];
if (c) {
//remove any applied movedClass
if (this.movedClass && this.movedClass.length > 0 && c.hasClass(this.movedClass)) {
c.removeClass(this.movedClass);
}
this.$.client.addChild(c);
var p = this.$.client.hasNode();
if (p && c.hasNode()) {
var nextChild;
var currIndex;
for (var i = 0; i < this.$.client.children.length; i++) {
var curr = this.$.client.children[i];
if(curr.toolbarIndex !== undefined && curr.toolbarIndex != i) {
nextChild = curr;
currIndex = i;
break;
}
}
if (nextChild && nextChild.hasNode()) {
c.insertNodeInParent(p, nextChild.node);
var newChild = this.$.client.children.pop();
this.$.client.children.splice(currIndex, 0, newChild);
} else {
c.appendNodeToParent(p);
}
}
return true;
}
} | javascript | {
"resource": ""
} | |
q29727 | train | function () {
if (this.$.client.hasNode()) {
var c$ = this.$.client.children;
var n = c$.length && c$[c$.length-1].hasNode();
if (n) {
this.$.client.reflow();
//Workaround: scrollWidth value not working in Firefox, so manually compute
//return (this.$.client.node.scrollWidth > this.$.client.node.clientWidth);
return ((n.offsetLeft + n.offsetWidth) > this.$.client.node.clientWidth);
}
}
} | javascript | {
"resource": ""
} | |
q29728 | tdStyle | train | function tdStyle(cellData, { columnSummary, column, rowData, isBottomData }) {
let domain;
let backgroundScale;
let colorScale;
let colorShift;
let colorScheme;
let reverseColors;
let includeBottomData;
// read in from plugin options
if (column.plugins && column.plugins.heatmap) {
domain = column.plugins.heatmap.domain;
backgroundScale = column.plugins.heatmap.backgroundScale;
colorScale = column.plugins.heatmap.colorScale;
colorShift = column.plugins.heatmap.colorShift;
colorScheme = column.plugins.heatmap.colorScheme;
reverseColors = column.plugins.heatmap.reverseColors;
includeBottomData = column.plugins.heatmap.includeBottomData;
}
// skip in bottom data area unless this column explicitly says to include it
if (isBottomData && !includeBottomData) {
return undefined;
}
// compute the sort value
const sortValue = Utils.getSortValueFromCellData(cellData, column, rowData);
// do not heatmap null or undefined values
if (sortValue == null) {
return undefined;
}
// default domain if not provided comes from columnSummary
if (!domain) {
// if we didn't get a min/max, just use [0, 1]
const colMin = columnSummary.min == null ? 0 : columnSummary.min;
const colMax = columnSummary.max == null ? 1 : columnSummary.max;
domain = [colMin, colMax];
}
// reverse the domain if specified to get the color scheme inverted
if (reverseColors) {
domain = domain.slice().reverse();
}
const domainScale = d3.scaleLinear().domain(domain)
.range([0, 1])
.clamp(true);
// if a background scale is provided, use it
let backgroundColor;
if (backgroundScale) {
if (backgroundScale.domain) {
backgroundScale.domain(domain);
}
backgroundColor = backgroundScale(sortValue);
}
// if a color scale is provided, use it
let color;
if (colorScale) {
if (colorScale.domain) {
colorScale.domain(domain);
}
color = colorScale(sortValue);
// if a color shift is defined, shift the background color by this amount (0, 1)
} else if (backgroundScale && colorShift) {
const shiftedValue = domainScale.invert((domainScale(sortValue) + colorShift) % 1);
color = backgroundScale(shiftedValue);
}
// if no background scale and color scale provided, use default - magma
if (backgroundScale == null) {
colorScheme = colorScheme || defaultColorScheme;
backgroundColor = d3[`interpolate${colorScheme}`](domainScale(sortValue));
if (!colorScale) {
colorShift = colorShift || 0.5;
color = d3[`interpolate${colorScheme}`]((domainScale(sortValue) + colorShift) % 1);
}
}
return {
backgroundColor,
color,
};
} | javascript | {
"resource": ""
} |
q29729 | minMaxClassName | train | function minMaxClassName(cellData, _ref) {
var columnSummary = _ref.columnSummary;
var column = _ref.column;
var rowData = _ref.rowData;
var sortValue = Utils.getSortValueFromCellData(cellData, column, rowData);
if (sortValue === columnSummary.min) {
return 'highlight-min-max highlight-min';
} else if (sortValue === columnSummary.max) {
return 'highlight-min-max highlight-max';
}
return undefined;
} | javascript | {
"resource": ""
} |
q29730 | minClassName | train | function minClassName(cellData, _ref2) {
var columnSummary = _ref2.columnSummary;
var column = _ref2.column;
var rowData = _ref2.rowData;
var sortValue = Utils.getSortValueFromCellData(cellData, column, rowData);
if (sortValue === columnSummary.min) {
return 'highlight-min';
}
return undefined;
} | javascript | {
"resource": ""
} |
q29731 | maxClassName | train | function maxClassName(cellData, _ref3) {
var columnSummary = _ref3.columnSummary;
var column = _ref3.column;
var rowData = _ref3.rowData;
var sortValue = Utils.getSortValueFromCellData(cellData, column, rowData);
if (sortValue === columnSummary.max) {
return 'highlight-max';
}
return undefined;
} | javascript | {
"resource": ""
} |
q29732 | getCellData | train | function getCellData(column, rowData, rowNumber, tableData, columns, isBottomData) {
var value = column.value;
var id = column.id;
// if it is bottom data, just use the value directly.
if (isBottomData) {
return rowData[id];
}
// call value as a function
if (typeof value === 'function') {
return value(rowData, { rowNumber: rowNumber, tableData: tableData, columns: columns });
// interpret value as a key
} else if (value != null) {
return rowData[value];
}
// otherwise, use the ID as a key
return rowData[id];
} | javascript | {
"resource": ""
} |
q29733 | getSortValueFromCellData | train | function getSortValueFromCellData(cellData, column, rowData) {
var sortValue = column.sortValue;
if (sortValue) {
return sortValue(cellData, rowData);
}
return cellData;
} | javascript | {
"resource": ""
} |
q29734 | getSortValue | train | function getSortValue(column, rowData, rowNumber, tableData, columns) {
var cellData = getCellData(column, rowData, rowNumber, tableData, columns);
return getSortValueFromCellData(cellData, column, rowData);
} | javascript | {
"resource": ""
} |
q29735 | sortData | train | function sortData(data, columnId, sortDirection, columns) {
var column = getColumnById(columns, columnId);
if (!column) {
if (process.env.NODE_ENV !== 'production') {
console.warn('No column found by ID', columnId, columns);
}
return data;
}
// read the type from `sortType` property if defined, otherwise use `type`
var sortType = column.sortType == null ? column.type : column.sortType;
var comparator = getSortComparator(sortType);
var dataToSort = data.map(function (rowData, index) {
return {
rowData: rowData,
index: index,
sortValue: getSortValue(column, rowData, index, data, columns)
};
});
// check if already sorted, and if so, just reverse
var sortedData = void 0;
// if already sorted in the opposite order, just reverse it
if (alreadySorted(!sortDirection, dataToSort, comparator)) {
sortedData = dataToSort.reverse();
// if not sorted, stable sort it
} else {
sortedData = (0, _stable2.default)(dataToSort, comparator);
if (sortDirection === _SortDirection2.default.Descending) {
sortedData.reverse();
}
}
sortedData = sortedData.map(function (sortItem) {
return sortItem.rowData;
});
return sortedData;
} | javascript | {
"resource": ""
} |
q29736 | renderCell | train | function renderCell(cellData, column, rowData, rowNumber, tableData, columns, isBottomData, columnSummary) {
var renderer = column.renderer;
var renderOnNull = column.renderOnNull;
// render if not bottom data-- bottomData's cellData is already rendered.
if (!isBottomData) {
// do not render if value is null and `renderOnNull` is not explicitly set to true
if (cellData == null && renderOnNull !== true) {
return null;
// render normally if a renderer is provided
} else if (renderer != null) {
return renderer(cellData, { column: column, rowData: rowData, rowNumber: rowNumber, tableData: tableData, columns: columns, columnSummary: columnSummary });
}
}
// otherwise, render the raw cell data
return cellData;
} | javascript | {
"resource": ""
} |
q29737 | validateColumns | train | function validateColumns(columns) {
if (!columns) {
return;
}
// check IDs
var ids = {};
columns.forEach(function (column, i) {
var id = column.id;
if (!ids[id]) {
ids[id] = [i];
} else {
ids[id].push(i);
}
});
Object.keys(ids).forEach(function (id) {
if (ids[id].length > 1) {
console.warn('Column ID \'' + id + '\' used in multiple columns ' + ids[id].join(', '), ids[id].map(function (index) {
return columns[index];
}));
}
});
} | javascript | {
"resource": ""
} |
q29738 | forEach | train | function forEach(obj, fn) {
// Don't bother if no value provided
if (obj === null || typeof obj === 'undefined') {
return;
}
// Force an array if not already something iterable
if (typeof obj !== 'object') {
/* eslint no-param-reassign:0 */
obj = [obj];
}
if (Array.isArray(obj)) {
// Iterate over array values
for (let i = 0, l = obj.length; i < l; i += 1) {
fn.call(null, obj[i], i, obj);
}
} else {
// Iterate over object keys
Object.entries(obj).forEach(([key, val]) => {
fn.call(null, val, key, obj);
});
}
} | javascript | {
"resource": ""
} |
q29739 | watchInputs | train | function watchInputs() {
var state;
state = pfio.read_input();
if (state !== prev_state) {
EventBus.emit('pfio.inputs.changed', state, prev_state);
prev_state = state;
}
setTimeout(watchInputs, 10);
} | javascript | {
"resource": ""
} |
q29740 | meanSummarizer | train | function meanSummarizer(column, tableData, columns) {
var stats = tableData.reduce(function (stats, rowData, rowNumber) {
var sortValue = Utils.getSortValue(column, rowData, rowNumber, tableData, columns);
if (sortValue) {
if (stats.sum === null) {
stats.sum = sortValue;
} else {
stats.sum += sortValue;
}
}
return stats;
}, { sum: null, count: tableData.length, mean: null });
if (stats.sum !== null) {
stats.mean = stats.sum / stats.count;
}
return stats;
} | javascript | {
"resource": ""
} |
q29741 | frequencySummarizer | train | function frequencySummarizer(column, tableData, columns) {
var mostFrequent = void 0;
var counts = tableData.reduce(function (counts, rowData, rowNumber) {
var cellData = Utils.getCellData(column, rowData, rowNumber, tableData, columns);
if (!counts[cellData]) {
counts[cellData] = 1;
} else {
counts[cellData] += 1;
}
if (mostFrequent == null || counts[cellData] > counts[mostFrequent]) {
mostFrequent = cellData;
}
return counts;
}, {});
return { counts: counts, mostFrequent: mostFrequent };
} | javascript | {
"resource": ""
} |
q29742 | isRuleScopable | train | function isRuleScopable(rule){
if(rule.parent.type !== 'root') {
if (rule.parent.type === 'atrule' && conditionalGroupRules.indexOf(rule.parent.name) > -1){
return true;
}
else {
return false;
}
}
else {
return true;
}
} | javascript | {
"resource": ""
} |
q29743 | atlasPack | train | function atlasPack(img) {
var node = atlas.pack(img);
if (node === false) {
atlas = atlas.expand(img);
//atlas.tilepad = true;
}
} | javascript | {
"resource": ""
} |
q29744 | CompositeDisposable | train | function CompositeDisposable () {
var args = [], i, len;
if (Array.isArray(arguments[0])) {
args = arguments[0];
len = args.length;
} else {
len = arguments.length;
args = new Array(len);
for(i = 0; i < len; i++) { args[i] = arguments[i]; }
}
this._disposables = args;
this.isDisposed = false;
this.length = args.length;
} | javascript | {
"resource": ""
} |
q29745 | train | function (inControl) {
var c = inControl.caption || ('Tab ' + this.lastIndex);
this.selectedId = this.lastIndex++ ;
var t = this.$.tabs.createComponent(
{
content: c,
userData: inControl.data || { },
tooltipMsg: inControl.tooltipMsg, //may be null
userId: inControl.userId, // may be null
tabIndex: this.selectedId,
addBefore: this.$.line
}
);
t.render();
this.resetWidth();
t.raise();
t.setActive(true);
return t;
} | javascript | {
"resource": ""
} | |
q29746 | train | function (target) {
var tab = this.resolveTab(target,'removeTab');
var tabData = {
index: tab.tabIndex,
caption: tab.content,
tooltipMsg: tab.tooltipMsg,
userId: tab.userId,
data: tab.userData
} ;
var that = this ;
if (tab) {
tabData.next = function (err) {
if (err) { throw new Error(err); }
else { that.removeTab(target); }
} ;
this.doTabRemoveRequested( tabData ) ;
}
} | javascript | {
"resource": ""
} | |
q29747 | train | function () {
var result = 0;
utils.forEach(
this.$.tabs.getControls(),
function (tab){
var w = tab.origWidth() ;
// must add margin and padding of inner button and outer tab-item
result += w + 18 ;
}
);
return result;
} | javascript | {
"resource": ""
} | |
q29748 | train | function (inSender, inEvent) {
var that = this ;
var popup = this.$.popup;
for (var name in popup.$) {
if (popup.$.hasOwnProperty(name) && /menuItem/.test(name)) {
popup.$[name].destroy();
}
}
//popup.render();
utils.forEach(
this.$.tabs.getControls(),
function (tab) {
that.$.popup.createComponent({
content: tab.content,
value: tab.tabIndex
}) ;
}
);
popup.maxHeightChanged();
popup.showAtPosition({top: 30, right:30});
this.render();
this.resize(); // required for IE10 to work correctly
return ;
} | javascript | {
"resource": ""
} | |
q29749 | bufferReviver | train | function bufferReviver(k, v) {
if (
v !== null &&
typeof v === 'object' &&
'type' in v &&
v.type === 'Buffer' &&
'data' in v &&
Array.isArray(v.data)) {
return new Buffer(v.data);
}
return v;
} | javascript | {
"resource": ""
} |
q29750 | MetaData | train | function MetaData() {
// the key for the storing
this.key = null;
// data to store
this.value = null;
// temporary filename for the cached file because filenames cannot represend urls completely
this.filename = null;
// expirydate of the entry
this.expires = null;
// size of the current entry
this.size = null;
} | javascript | {
"resource": ""
} |
q29751 | DiskStore | train | function DiskStore(options) {
options = options || {};
this.options = extend({
path: 'cache/',
ttl: 60,
maxsize: 0,
zip: false
}, options);
// check storage directory for existence (or create it)
if (!fs.existsSync(this.options.path)) {
fs.mkdirSync(this.options.path);
}
this.name = 'diskstore';
// current size of the cache
this.currentsize = 0;
// internal array for informations about the cached files - resists in memory
this.collection = {};
// fill the cache on startup with already existing files
if (!options.preventfill) {
this.intializefill(options.fillcallback);
}
} | javascript | {
"resource": ""
} |
q29752 | train | function (value) {
this.$.animator.play({
startValue: this.value,
endValue: value,
node: this.hasNode()
});
this.setValue(value);
} | javascript | {
"resource": ""
} | |
q29753 | DashDocsetTheme | train | function DashDocsetTheme(renderer, basePath) {
_super.call(this, renderer, basePath);
renderer.on(output.Renderer.EVENT_BEGIN, this.onRendererBegin, this, 1024);
this.dashIndexPlugin = new DashIndexPlugin(renderer);
this.dashAssetsPlugin = new DashAssetsPlugin(renderer);
this.infoPlistPlugin = new InfoPlistPlugin(renderer);
} | javascript | {
"resource": ""
} |
q29754 | containsExternals | train | function containsExternals(modules) {
for (var index = 0, length = modules.length; index < length; index++) {
if (modules[index].flags.isExternal)
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q29755 | sortReflections | train | function sortReflections(modules) {
modules.sort(function (a, b) {
if (a.flags.isExternal && !b.flags.isExternal)
return 1;
if (!a.flags.isExternal && b.flags.isExternal)
return -1;
return a.getFullName() < b.getFullName() ? -1 : 1;
});
} | javascript | {
"resource": ""
} |
q29756 | includeDedicatedUrls | train | function includeDedicatedUrls(reflection, item) {
(function walk(reflection) {
for (var key in reflection.children) {
var child = reflection.children[key];
if (child.hasOwnDocument && !child.kindOf(td.models.ReflectionKind.SomeModule)) {
if (!item.dedicatedUrls)
item.dedicatedUrls = [];
item.dedicatedUrls.push(child.url);
walk(child);
}
}
})(reflection);
} | javascript | {
"resource": ""
} |
q29757 | buildChildren | train | function buildChildren(reflection, parent) {
var modules = reflection.getChildrenByKind(td.models.ReflectionKind.SomeModule);
modules.sort(function (a, b) {
return a.getFullName() < b.getFullName() ? -1 : 1;
});
modules.forEach(function (reflection) {
var item = output.NavigationItem.create(reflection, parent);
includeDedicatedUrls(reflection, item);
buildChildren(reflection, item);
});
} | javascript | {
"resource": ""
} |
q29758 | buildGroups | train | function buildGroups(reflections, parent, callback) {
var state = -1;
var hasExternals = containsExternals(reflections);
sortReflections(reflections);
reflections.forEach(function (reflection) {
if (hasExternals && !reflection.flags.isExternal && state != 1) {
new output.NavigationItem('Internals', null, parent, "tsd-is-external");
state = 1;
}
else if (hasExternals && reflection.flags.isExternal && state != 2) {
new output.NavigationItem('Externals', null, parent, "tsd-is-external");
state = 2;
}
var item = output.NavigationItem.create(reflection, parent);
includeDedicatedUrls(reflection, item);
if (callback)
callback(reflection, item);
});
} | javascript | {
"resource": ""
} |
q29759 | build | train | function build(hasSeparateGlobals) {
var root = new output.NavigationItem('Index', 'index.html');
if (entryPoint == project) {
var globals = new output.NavigationItem('Globals', hasSeparateGlobals ? 'globals.html' : 'index.html', root);
globals.isGlobals = true;
}
var modules = [];
project.getReflectionsByKind(td.models.ReflectionKind.SomeModule).forEach(function (someModule) {
var target = someModule.parent;
var inScope = (someModule == entryPoint);
while (target) {
if (target.kindOf(td.models.ReflectionKind.ExternalModule))
return;
if (entryPoint == target)
inScope = true;
target = target.parent;
}
if (inScope) {
modules.push(someModule);
}
});
if (modules.length < 10) {
buildGroups(modules, root);
}
else {
buildGroups(entryPoint.getChildrenByKind(td.models.ReflectionKind.SomeModule), root, buildChildren);
}
return root;
} | javascript | {
"resource": ""
} |
q29760 | jobDone | train | function jobDone(err, data) {
// TODO: check if function was already called before
// check if we close the connection after this (to prevent memory leaks)
var closing = totalRequests > REQUESTS_BEFORE_WORKER_RESTART ? true : false;
var msg = {};
if (err) {
msg.errMessage = err.message;
msg.status = 'fail';
closing = true; // always close the worker if any error happens
} else {
msg.status = 'success';
}
msg.data = data;
msg.closing = closing;
// send our data back to the master
res.statusCode = 200;
res.write(JSON.stringify(msg));
res.close();
// close this worker if necessary
if (closing) {
phantom.exit();
}
} | javascript | {
"resource": ""
} |
q29761 | train | function (rect) {
var s = '';
for (var n in rect) {
s += (n + ':' + rect[n] + (isNaN(rect[n]) ? '; ' : 'px; '));
}
this.addStyles(s);
} | javascript | {
"resource": ""
} | |
q29762 | train | function (node) {
var r = this.getBoundingRect(node);
var pageYOffset = (window.pageYOffset === undefined) ? document.documentElement.scrollTop : window.pageYOffset;
var pageXOffset = (window.pageXOffset === undefined) ? document.documentElement.scrollLeft : window.pageXOffset;
var rHeight = (r.height === undefined) ? (r.bottom - r.top) : r.height;
var rWidth = (r.width === undefined) ? (r.right - r.left) : r.width;
return {top: r.top + pageYOffset, left: r.left + pageXOffset, height: rHeight, width: rWidth};
} | javascript | {
"resource": ""
} | |
q29763 | train | function () {
if (this.showing && this.hasNode() && this.activator) {
this.resetPositioning();
this.activatorOffset = this.getPageOffset(this.activator);
var innerWidth = this.getViewWidth();
var innerHeight = this.getViewHeight();
//These are the view "flush boundaries"
var topFlushPt = this.vertFlushMargin;
var bottomFlushPt = innerHeight - this.vertFlushMargin;
var leftFlushPt = this.horizFlushMargin;
var rightFlushPt = innerWidth - this.horizFlushMargin;
//Rule 1 - Activator Location based positioning
//if the activator is in the top or bottom edges of the view, check if the popup needs flush positioning
if ((this.activatorOffset.top + this.activatorOffset.height) < topFlushPt || this.activatorOffset.top > bottomFlushPt) {
//check/try vertical flush positioning (rule 1.a.i)
if (this.applyVerticalFlushPositioning(leftFlushPt, rightFlushPt)) {
return;
}
//if vertical doesn't fit then check/try horizontal flush (rule 1.a.ii)
if (this.applyHorizontalFlushPositioning(leftFlushPt, rightFlushPt)) {
return;
}
//if flush positioning didn't work then try just positioning vertically (rule 1.b.i & rule 1.b.ii)
if (this.applyVerticalPositioning()){
return;
}
//otherwise check if the activator is in the left or right edges of the view & if so try horizontal positioning
} else if ((this.activatorOffset.left + this.activatorOffset.width) < leftFlushPt || this.activatorOffset.left > rightFlushPt) {
//if flush positioning didn't work then try just positioning horizontally (rule 1.b.iii & rule 1.b.iv)
if (this.applyHorizontalPositioning()){
return;
}
}
//Rule 2 - no specific logic below for this rule since it is inheritent to the positioning functions, ie we attempt to never
//position a popup where there isn't enough room for it.
//Rule 3 - Popup Size based positioning
var clientRect = this.getBoundingRect(this.node);
//if the popup is wide then use vertical positioning
if (clientRect.width > this.widePopup) {
if (this.applyVerticalPositioning()){
return;
}
}
//if the popup is long then use horizontal positioning
else if (clientRect.height > this.longPopup) {
if (this.applyHorizontalPositioning()){
return;
}
}
//Rule 4 - Favor top or bottom positioning
if (this.applyVerticalPositioning()) {
return;
}
//but if thats not possible try horizontal
else if (this.applyHorizontalPositioning()){
return;
}
//Rule 5 - no specific logic below for this rule since it is built into the vertical position functions, ie we attempt to
// use a bottom position for the popup as much possible.
}
} | javascript | {
"resource": ""
} | |
q29764 | train | function () {
this.resetPositioning();
this.addClass('vertical');
var clientRect = this.getBoundingRect(this.node);
var innerHeight = this.getViewHeight();
if (this.floating){
if (this.activatorOffset.top < (innerHeight / 2)) {
this.applyPosition({top: this.activatorOffset.top + this.activatorOffset.height, bottom: 'auto'});
this.addClass('below');
} else {
this.applyPosition({top: this.activatorOffset.top - clientRect.height, bottom: 'auto'});
this.addClass('above');
}
} else {
//if the popup's bottom goes off the screen then put it on the top of the invoking control
if ((clientRect.top + clientRect.height > innerHeight) && ((innerHeight - clientRect.bottom) < (clientRect.top - clientRect.height))){
this.addClass('above');
} else {
this.addClass('below');
}
}
//if moving the popup above or below the activator puts it past the edge of the screen then vertical doesn't work
clientRect = this.getBoundingRect(this.node);
if ((clientRect.top + clientRect.height) > innerHeight || clientRect.top < 0){
return false;
}
return true;
} | javascript | {
"resource": ""
} | |
q29765 | tryPhantomjsInLib | train | function tryPhantomjsInLib() {
return Q.fcall(function () {
return findValidPhantomJsBinary(path.resolve(__dirname, './lib/location.js'))
}).then(function (binaryLocation) {
if (binaryLocation) {
console.log('PhantomJS is previously installed at', binaryLocation)
exit(0)
}
}).fail(function () {
// silently swallow any errors
})
} | javascript | {
"resource": ""
} |
q29766 | tryPhantomjsOnPath | train | function tryPhantomjsOnPath() {
if (getTargetPlatform() != process.platform || getTargetArch() != process.arch) {
console.log('Building for target platform ' + getTargetPlatform() + '/' + getTargetArch() +
'. Skipping PATH search')
return Q.resolve(false)
}
return Q.nfcall(which, 'phantomjs')
.then(function (result) {
phantomPath = result
console.log('Considering PhantomJS found at', phantomPath)
// Horrible hack to avoid problems during global install. We check to see if
// the file `which` found is our own bin script.
if (phantomPath.indexOf(path.join('npm', 'phantomjs')) !== -1) {
console.log('Looks like an `npm install -g` on windows; skipping installed version.')
return
}
var contents = fs.readFileSync(phantomPath, 'utf8')
if (/NPM_INSTALL_MARKER/.test(contents)) {
console.log('Looks like an `npm install -g`')
var phantomLibPath = path.resolve(fs.realpathSync(phantomPath), '../../lib/location')
return findValidPhantomJsBinary(phantomLibPath)
.then(function (binaryLocation) {
if (binaryLocation) {
writeLocationFile(binaryLocation)
console.log('PhantomJS linked at', phantomLibPath)
exit(0)
}
console.log('Could not link global install, skipping...')
})
} else {
return checkPhantomjsVersion(phantomPath).then(function (matches) {
if (matches) {
writeLocationFile(phantomPath)
console.log('PhantomJS is already installed on PATH at', phantomPath)
exit(0)
}
})
}
}, function () {
console.log('PhantomJS not found on PATH')
})
.fail(function (err) {
console.error('Error checking path, continuing', err)
return false
})
} | javascript | {
"resource": ""
} |
q29767 | downloadPhantomjs | train | function downloadPhantomjs() {
var downloadSpec = getDownloadSpec()
if (!downloadSpec) {
console.error(
'Unexpected platform or architecture: ' + getTargetPlatform() + '/' + getTargetArch() + '\n' +
'It seems there is no binary available for your platform/architecture\n' +
'Try to install PhantomJS globally')
exit(1)
}
var downloadUrl = downloadSpec.url
var downloadedFile
return Q.fcall(function () {
// Can't use a global version so start a download.
var tmpPath = findSuitableTempDirectory()
var fileName = downloadUrl.split('/').pop()
downloadedFile = path.join(tmpPath, fileName)
if (fs.existsSync(downloadedFile)) {
console.log('Download already available at', downloadedFile)
return verifyChecksum(downloadedFile, downloadSpec.checksum)
}
return false
}).then(function (verified) {
if (verified) {
return downloadedFile
}
// Start the install.
console.log('Downloading', downloadUrl)
console.log('Saving to', downloadedFile)
return requestBinary(getRequestOptions(), downloadedFile)
})
} | javascript | {
"resource": ""
} |
q29768 | train | function()
{
//kill the Flash Player instance
if(this._swf)
{
var container = YAHOO.util.Dom.get(this._containerID);
container.removeChild(this._swf);
}
var instanceName = this._id;
//null out properties
for(var prop in this)
{
if(YAHOO.lang.hasOwnProperty(this, prop))
{
this[prop] = null;
}
}
} | javascript | {
"resource": ""
} | |
q29769 | train | function(swfURL, containerID, swfID, version, backgroundColor, expressInstall, wmode, buttonSkin)
{
//standard SWFObject embed
var swfObj = new YAHOO.deconcept.SWFObject(swfURL, swfID, "100%", "100%", version, backgroundColor);
if(expressInstall)
{
swfObj.useExpressInstall(expressInstall);
}
//make sure we can communicate with ExternalInterface
swfObj.addParam("allowScriptAccess", "always");
if(wmode)
{
swfObj.addParam("wmode", wmode);
}
swfObj.addParam("menu", "false");
//again, a useful ExternalInterface trick
swfObj.addVariable("allowedDomain", document.location.hostname);
//tell the SWF which HTML element it is in
swfObj.addVariable("YUISwfId", swfID);
// set the name of the function to call when the swf has an event
swfObj.addVariable("YUIBridgeCallback", "YAHOO.widget.FlashAdapter.eventHandler");
if (buttonSkin) {
swfObj.addVariable("buttonSkin", buttonSkin);
}
var container = YAHOO.util.Dom.get(containerID);
var result = swfObj.write(container);
if(result)
{
this._swf = YAHOO.util.Dom.get(swfID);
YAHOO.widget.FlashAdapter.owners[swfID] = this;
}
else
{
}
} | javascript | {
"resource": ""
} | |
q29770 | train | function()
{
this._initialized = false;
this._initAttributes(this._attributes);
this.setAttributes(this._attributes, true);
this._initialized = true;
this.fireEvent("contentReady");
} | javascript | {
"resource": ""
} | |
q29771 | train | function(fileID, uploadScriptPath, method, vars, fieldName)
{
this._swf.upload(fileID, uploadScriptPath, method, vars, fieldName);
} | javascript | {
"resource": ""
} | |
q29772 | train | function(fileIDs, uploadScriptPath, method, vars, fieldName)
{
this._swf.uploadThese(fileIDs, uploadScriptPath, method, vars, fieldName);
} | javascript | {
"resource": ""
} | |
q29773 | train | function(uploadScriptPath, method, vars, fieldName)
{
this._swf.uploadAll(uploadScriptPath, method, vars, fieldName);
} | javascript | {
"resource": ""
} | |
q29774 | train | function() {
var value = this.getValue();
if(value.name === "") {
this.alert("Please choose a name");
return;
}
this.tempSavedWiring = {name: value.name, working: value.working, language: this.options.languageName };
this.adapter.saveWiring(this.tempSavedWiring, {
success: this.saveModuleSuccess,
failure: this.saveModuleFailure,
scope: this
});
} | javascript | {
"resource": ""
} | |
q29775 | train | function() {
webhookit.WiringEditor.superclass.renderButtons.call(this);
var toolbar = YAHOO.util.Dom.get('toolbar');
var editTemplateButton = new YAHOO.widget.Button({ label:"Edit template", id:"WiringEditor-templateButton", container: toolbar });
editTemplateButton.on("click", webhookit.editTemplateButton, webhookit, true);
// "Run" button
var runButton = new YAHOO.widget.Button({ label:"Run", id:"WiringEditor-runButton", container: toolbar });
runButton.on("click", webhookit.run, webhookit, true);
} | javascript | {
"resource": ""
} | |
q29776 | train | function(method, formOpts, callback) {
var options = null;
if(YAHOO.lang.isObject(formOpts) && YAHOO.lang.isArray(formOpts.fields) ) {
options = formOpts;
}
// create the form directly from the method params
else {
options = inputEx.RPC.formForMethod(method);
// Add user options from formOpts
YAHOO.lang.augmentObject(options, formOpts, true);
}
// Add buttons to launch the service
options.type = "form";
if(!options.buttons) {
options.buttons = [
{type: 'submit', value: method.name, onClick: function(e) {
YAHOO.util.Event.stopEvent(e);
form.showMask();
method(form.getValue(), {
success: function(results) {
form.hideMask();
if(YAHOO.lang.isObject(callback) && YAHOO.lang.isFunction(callback.success)) {
callback.success.call(callback.scope || this, results);
}
},
failure: function() {
form.hideMask();
}
});
return false; // do NOT send the browser submit event
}}
];
}
var form = inputEx(options);
return form;
} | javascript | {
"resource": ""
} | |
q29777 | train | function(method) {
// convert the method parameters into a json-schema :
var schemaIdentifierMap = {};
schemaIdentifierMap[method.name] = {
id: method.name,
type:'object',
properties:{}
};
for(var i = 0 ; i < method._parameters.length ; i++) {
var p = method._parameters[i];
schemaIdentifierMap[method.name].properties[p.name] = p;
}
// Use the builder to build an inputEx form from the json-schema
var builder = new inputEx.JsonSchema.Builder({
'schemaIdentifierMap': schemaIdentifierMap,
'defaultOptions':{
'showMsg':true
}
});
var options = builder.schemaToInputEx(schemaIdentifierMap[method.name]);
return options;
} | javascript | {
"resource": ""
} | |
q29778 | train | function(serviceName, method) {
if(this[method]){
throw new Error("WARNING: "+ serviceName+ " already exists for service. Unable to generate function");
}
method.name = serviceName;
var self = this;
var func = function(data, opts) {
var envelope = rpc.Envelope[method.envelope || self._smd.envelope];
var callback = {
success: function(o) {
var results = envelope.deserialize(o);
opts.success.call(opts.scope || self, results);
},
failure: function(o) {
if(lang.isFunction(opts.failure) ) {
var results = envelope.deserialize(o);
opts.failure.call(opts.scope || self, results);
}
},
scope: self
};
var params = {};
if(self._smd.additionalParameters && lang.isArray(self._smd.parameters) ) {
for(var i = 0 ; i < self._smd.parameters.length ; i++) {
var p = self._smd.parameters[i];
params[p.name] = p["default"];
}
}
lang.augmentObject(params, data, true);
var url = method.target || self._smd.target;
var urlRegexp = /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/i;
if(!url.match(urlRegexp) && url != self._smd.target) {
url = self._smd.target+url;
}
if( !!this.smdUrl && !url.match(urlRegexp) ) {
// URL is still relative !
var a=this.smdUrl.split('/');
a[a.length-1]="";
url = a.join("/")+url;
}
var r = {
target: url,
callback: callback,
data: params,
origData: data,
opts: opts,
callbackParamName: method.callbackParamName || self._smd.callbackParamName,
transport: method.transport || self._smd.transport
};
var serialized = envelope.serialize(self._smd, method, params);
lang.augmentObject(r, serialized, true);
rpc.Transport[r.transport].call(self, r );
};
func.name = serviceName;
func.description = method.description;
func._parameters = method.parameters;
return func;
} | javascript | {
"resource": ""
} | |
q29779 | train | function(callback) {
var serviceDefs = this._smd.services;
// Generate the methods to this object
for(var serviceName in serviceDefs){
if( serviceDefs.hasOwnProperty(serviceName) ) {
// Get the object that will contain the method.
// handles "namespaced" services by breaking apart by '.'
var current = this;
var pieces = serviceName.split(".");
for(var i=0; i< pieces.length-1; i++){
current = current[pieces[i]] || (current[pieces[i]] = {});
}
current[pieces[pieces.length-1]] = this._generateService(serviceName, serviceDefs[serviceName]);
}
}
// call the success handler
if(lang.isObject(callback) && lang.isFunction(callback.success)) {
callback.success.call(callback.scope || this);
}
} | javascript | {
"resource": ""
} | |
q29780 | train | function(url, callback) {
// TODO: if url is not in the same domain, we should use jsonp !
util.Connect.asyncRequest('GET', url, {
success: function(o) {
try {
this._smd = lang.JSON.parse(o.responseText);
this.process(callback);
}
catch(ex) {
if(lang.isObject(console) && lang.isFunction(console.log))
console.log(ex);
if( lang.isFunction(callback.failure) ) {
callback.failure.call(callback.scope || this, {error: ex});
}
}
},
failure: function(o) {
if( lang.isFunction(callback.failure) ) {
callback.failure.call(callback.scope || this, {error: "unable to fetch url "+url});
}
},
scope: this
});
} | javascript | {
"resource": ""
} | |
q29781 | train | function(r) {
return util.Connect.asyncRequest('POST', r.target, r.callback, r.data );
} | javascript | {
"resource": ""
} | |
q29782 | train | function(smd, method, data) {
var eURI = encodeURIComponent;
var params = [];
for(var name in data){
if(data.hasOwnProperty(name)){
var value = data[name];
if(lang.isArray(value)){
for(var i=0; i < value.length; i++){
params.push(eURI(name)+"="+eURI(value[i]));
}
}else{
params.push(eURI(name)+"="+eURI(value));
}
}
}
return {
data: params.join("&")
};
} | javascript | {
"resource": ""
} | |
q29783 | train | function (owner) {
this.owner = owner;
this.configChangedEvent =
this.createEvent(Config.CONFIG_CHANGED_EVENT);
this.configChangedEvent.signature = CustomEvent.LIST;
this.queueInProgress = false;
this.config = {};
this.initialConfig = {};
this.eventQueue = [];
} | javascript | {
"resource": ""
} | |
q29784 | train | function ( key, propertyObject ) {
key = key.toLowerCase();
this.config[key] = propertyObject;
propertyObject.event = this.createEvent(key, { scope: this.owner });
propertyObject.event.signature = CustomEvent.LIST;
propertyObject.key = key;
if (propertyObject.handler) {
propertyObject.event.subscribe(propertyObject.handler,
this.owner);
}
this.setProperty(key, propertyObject.value, true);
if (! propertyObject.suppressEvent) {
this.queueProperty(key, propertyObject.value);
}
} | javascript | {
"resource": ""
} | |
q29785 | train | function () {
var cfg = {},
currCfg = this.config,
prop,
property;
for (prop in currCfg) {
if (Lang.hasOwnProperty(currCfg, prop)) {
property = currCfg[prop];
if (property && property.event) {
cfg[prop] = property.value;
}
}
}
return cfg;
} | javascript | {
"resource": ""
} | |
q29786 | train | function (key) {
var property = this.config[key.toLowerCase()];
if (property && property.event) {
return property.value;
} else {
return undefined;
}
} | javascript | {
"resource": ""
} | |
q29787 | train | function (key) {
key = key.toLowerCase();
var property = this.config[key];
if (property && property.event) {
if (this.initialConfig[key] &&
!Lang.isUndefined(this.initialConfig[key])) {
this.setProperty(key, this.initialConfig[key]);
return true;
}
} else {
return false;
}
} | javascript | {
"resource": ""
} | |
q29788 | train | function (key) {
key = key.toLowerCase();
var property = this.config[key];
if (property && property.event &&
!Lang.isUndefined(property.value)) {
if (this.queueInProgress) {
this.queueProperty(key);
} else {
this.fireEvent(key, property.value);
}
}
} | javascript | {
"resource": ""
} | |
q29789 | train | function () {
var i,
queueItem,
key,
value,
property;
this.queueInProgress = true;
for (i = 0;i < this.eventQueue.length; i++) {
queueItem = this.eventQueue[i];
if (queueItem) {
key = queueItem[0];
value = queueItem[1];
property = this.config[key];
property.value = value;
// Clear out queue entry, to avoid it being
// re-added to the queue by any queueProperty/supercedes
// calls which are invoked during fireEvent
this.eventQueue[i] = null;
this.fireEvent(key,value);
}
}
this.queueInProgress = false;
this.eventQueue = [];
} | javascript | {
"resource": ""
} | |
q29790 | train | function (key, handler, obj, overrideContext) {
var property = this.config[key.toLowerCase()];
if (property && property.event) {
if (!Config.alreadySubscribed(property.event, handler, obj)) {
property.event.subscribe(handler, obj, overrideContext);
}
return true;
} else {
return false;
}
} | javascript | {
"resource": ""
} | |
q29791 | train | function (key, handler, obj) {
var property = this.config[key.toLowerCase()];
if (property && property.event) {
return property.event.unsubscribe(handler, obj);
} else {
return false;
}
} | javascript | {
"resource": ""
} | |
q29792 | train | function () {
var output = "",
queueItem,
q,
nQueue = this.eventQueue.length;
for (q = 0; q < nQueue; q++) {
queueItem = this.eventQueue[q];
if (queueItem) {
output += queueItem[0] + "=" + queueItem[1] + ", ";
}
}
return output;
} | javascript | {
"resource": ""
} | |
q29793 | train | function () {
var oConfig = this.config,
sProperty,
oProperty;
for (sProperty in oConfig) {
if (Lang.hasOwnProperty(oConfig, sProperty)) {
oProperty = oConfig[sProperty];
oProperty.event.unsubscribeAll();
oProperty.event = null;
}
}
this.configChangedEvent.unsubscribeAll();
this.configChangedEvent = null;
this.owner = null;
this.config = null;
this.initialConfig = null;
this.eventQueue = null;
} | javascript | {
"resource": ""
} | |
q29794 | train | function () {
var isGeckoWin = (UA.gecko && this.platform == "windows");
if (isGeckoWin) {
// Help prevent spinning loading icon which
// started with FireFox 2.0.0.8/Win
var self = this;
setTimeout(function(){self._initResizeMonitor();}, 0);
} else {
this._initResizeMonitor();
}
} | javascript | {
"resource": ""
} | |
q29795 | train | function() {
var oDoc,
oIFrame,
sHTML;
function fireTextResize() {
Module.textResizeEvent.fire();
}
if (!UA.opera) {
oIFrame = Dom.get("_yuiResizeMonitor");
var supportsCWResize = this._supportsCWResize();
if (!oIFrame) {
oIFrame = document.createElement("iframe");
if (this.isSecure && Module.RESIZE_MONITOR_SECURE_URL && UA.ie) {
oIFrame.src = Module.RESIZE_MONITOR_SECURE_URL;
}
if (!supportsCWResize) {
// Can't monitor on contentWindow, so fire from inside iframe
sHTML = ["<html><head><script ",
"type=\"text/javascript\">",
"window.onresize=function(){window.parent.",
"YAHOO.widget.Module.textResizeEvent.",
"fire();};<",
"\/script></head>",
"<body></body></html>"].join('');
oIFrame.src = "data:text/html;charset=utf-8," + encodeURIComponent(sHTML);
}
oIFrame.id = "_yuiResizeMonitor";
oIFrame.title = "Text Resize Monitor";
/*
Need to set "position" property before inserting the
iframe into the document or Safari's status bar will
forever indicate the iframe is loading
(See YUILibrary bug #1723064)
*/
oIFrame.style.position = "absolute";
oIFrame.style.visibility = "hidden";
var db = document.body,
fc = db.firstChild;
if (fc) {
db.insertBefore(oIFrame, fc);
} else {
db.appendChild(oIFrame);
}
// Setting the background color fixes an issue with IE6/IE7, where
// elements in the DOM, with -ve margin-top which positioned them
// offscreen (so they would be overlapped by the iframe and its -ve top
// setting), would have their -ve margin-top ignored, when the iframe
// was added.
oIFrame.style.backgroundColor = "transparent";
oIFrame.style.borderWidth = "0";
oIFrame.style.width = "2em";
oIFrame.style.height = "2em";
oIFrame.style.left = "0";
oIFrame.style.top = (-1 * (oIFrame.offsetHeight + Module.RESIZE_MONITOR_BUFFER)) + "px";
oIFrame.style.visibility = "visible";
/*
Don't open/close the document for Gecko like we used to, since it
leads to duplicate cookies. (See YUILibrary bug #1721755)
*/
if (UA.webkit) {
oDoc = oIFrame.contentWindow.document;
oDoc.open();
oDoc.close();
}
}
if (oIFrame && oIFrame.contentWindow) {
Module.textResizeEvent.subscribe(this.onDomResize, this, true);
if (!Module.textResizeInitialized) {
if (supportsCWResize) {
if (!Event.on(oIFrame.contentWindow, "resize", fireTextResize)) {
/*
This will fail in IE if document.domain has
changed, so we must change the listener to
use the oIFrame element instead
*/
Event.on(oIFrame, "resize", fireTextResize);
}
}
Module.textResizeInitialized = true;
}
this.resizeMonitor = oIFrame;
}
}
} | javascript | {
"resource": ""
} | |
q29796 | train | function (headerContent) {
var oHeader = this.header || (this.header = createHeader());
if (headerContent.nodeName) {
oHeader.innerHTML = "";
oHeader.appendChild(headerContent);
} else {
oHeader.innerHTML = headerContent;
}
if (this._rendered) {
this._renderHeader();
}
this.changeHeaderEvent.fire(headerContent);
this.changeContentEvent.fire();
} | javascript | {
"resource": ""
} | |
q29797 | train | function (element) {
var oHeader = this.header || (this.header = createHeader());
oHeader.appendChild(element);
this.changeHeaderEvent.fire(element);
this.changeContentEvent.fire();
} | javascript | {
"resource": ""
} | |
q29798 | train | function (bodyContent) {
var oBody = this.body || (this.body = createBody());
if (bodyContent.nodeName) {
oBody.innerHTML = "";
oBody.appendChild(bodyContent);
} else {
oBody.innerHTML = bodyContent;
}
if (this._rendered) {
this._renderBody();
}
this.changeBodyEvent.fire(bodyContent);
this.changeContentEvent.fire();
} | javascript | {
"resource": ""
} | |
q29799 | train | function (footerContent) {
var oFooter = this.footer || (this.footer = createFooter());
if (footerContent.nodeName) {
oFooter.innerHTML = "";
oFooter.appendChild(footerContent);
} else {
oFooter.innerHTML = footerContent;
}
if (this._rendered) {
this._renderFooter();
}
this.changeFooterEvent.fire(footerContent);
this.changeContentEvent.fire();
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.