_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q21500
make
train
function make(move) { var _this = this; if (!Glide.disabled) { Glide.disable(); this.move = move; Events.emit('run.before', this.move); this.calculate(); Events.emit('run', this.move); Components.Transition.after(function () { if (_this.isStart()) { Events.emit('run.start', _this.move); } if (_this.isEnd()) { Events.emit('run.end', _this.move); } if (_this.isOffset('<') || _this.isOffset('>')) { _this._o = false; Events.emit('run.offset', _this.move); } Events.emit('run.after', _this.move); Glide.enable(); }); } }
javascript
{ "resource": "" }
q21501
calculate
train
function calculate() { var move = this.move, length = this.length; var steps = move.steps, direction = move.direction; var countableSteps = isNumber(toInt(steps)) && toInt(steps) !== 0; switch (direction) { case '>': if (steps === '>') { Glide.index = length; } else if (this.isEnd()) { if (!(Glide.isType('slider') && !Glide.settings.rewind)) { this._o = true; Glide.index = 0; } } else if (countableSteps) { Glide.index += Math.min(length - Glide.index, -toInt(steps)); } else { Glide.index++; } break; case '<': if (steps === '<') { Glide.index = 0; } else if (this.isStart()) { if (!(Glide.isType('slider') && !Glide.settings.rewind)) { this._o = true; Glide.index = length; } } else if (countableSteps) { Glide.index -= Math.min(Glide.index, toInt(steps)); } else { Glide.index--; } break; case '=': Glide.index = steps; break; default: warn('Invalid direction pattern [' + direction + steps + '] has been used'); break; } }
javascript
{ "resource": "" }
q21502
set
train
function set(value) { var step = value.substr(1); this._m = { direction: value.substr(0, 1), steps: step ? toInt(step) ? toInt(step) : step : 0 }; }
javascript
{ "resource": "" }
q21503
get
train
function get() { var settings = Glide.settings; var length = Components.Html.slides.length; // If the `bound` option is acitve, a maximum running distance should be // reduced by `perView` and `focusAt` settings. Running distance // should end before creating an empty space after instance. if (Glide.isType('slider') && settings.focusAt !== 'center' && settings.bound) { return length - 1 - (toInt(settings.perView) - 1) + toInt(settings.focusAt); } return length - 1; }
javascript
{ "resource": "" }
q21504
apply
train
function apply(slides) { for (var i = 0, len = slides.length; i < len; i++) { var style = slides[i].style; var direction = Components.Direction.value; if (i !== 0) { style[MARGIN_TYPE[direction][0]] = this.value / 2 + 'px'; } else { style[MARGIN_TYPE[direction][0]] = ''; } if (i !== slides.length - 1) { style[MARGIN_TYPE[direction][1]] = this.value / 2 + 'px'; } else { style[MARGIN_TYPE[direction][1]] = ''; } } }
javascript
{ "resource": "" }
q21505
remove
train
function remove(slides) { for (var i = 0, len = slides.length; i < len; i++) { var style = slides[i].style; style.marginLeft = ''; style.marginRight = ''; } }
javascript
{ "resource": "" }
q21506
siblings
train
function siblings(node) { if (node && node.parentNode) { var n = node.parentNode.firstChild; var matched = []; for (; n; n = n.nextSibling) { if (n.nodeType === 1 && n !== node) { matched.push(n); } } return matched; } return []; }
javascript
{ "resource": "" }
q21507
mount
train
function mount() { this.root = Glide.selector; this.track = this.root.querySelector(TRACK_SELECTOR); this.slides = Array.prototype.slice.call(this.wrapper.children).filter(function (slide) { return !slide.classList.contains(Glide.settings.classes.cloneSlide); }); }
javascript
{ "resource": "" }
q21508
set
train
function set(r) { if (isString(r)) { r = document.querySelector(r); } if (exist(r)) { Html._r = r; } else { warn('Root element must be a existing Html node'); } }
javascript
{ "resource": "" }
q21509
set
train
function set(value) { if (isObject(value)) { value.before = toInt(value.before); value.after = toInt(value.after); } else { value = toInt(value); } Peek._v = value; }
javascript
{ "resource": "" }
q21510
get
train
function get() { var value = Peek.value; var perView = Glide.settings.perView; if (isObject(value)) { return value.before / perView + value.after / perView; } return value * 2 / perView; }
javascript
{ "resource": "" }
q21511
make
train
function make() { var _this = this; var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; this.offset = offset; Events.emit('move', { movement: this.value }); Components.Transition.after(function () { Events.emit('move.after', { movement: _this.value }); }); }
javascript
{ "resource": "" }
q21512
get
train
function get() { var offset = this.offset; var translate = this.translate; if (Components.Direction.is('rtl')) { return translate + offset; } return translate - offset; }
javascript
{ "resource": "" }
q21513
setupSlides
train
function setupSlides() { var width = this.slideWidth + 'px'; var slides = Components.Html.slides; for (var i = 0; i < slides.length; i++) { slides[i].style.width = width; } }
javascript
{ "resource": "" }
q21514
remove
train
function remove() { var slides = Components.Html.slides; for (var i = 0; i < slides.length; i++) { slides[i].style.width = ''; } Components.Html.wrapper.style.width = ''; }
javascript
{ "resource": "" }
q21515
get
train
function get() { return Sizes.slideWidth * Sizes.length + Components.Gaps.grow + Components.Clones.grow; }
javascript
{ "resource": "" }
q21516
get
train
function get() { return Sizes.width / Glide.settings.perView - Components.Peek.reductor - Components.Gaps.reductor; }
javascript
{ "resource": "" }
q21517
typeClass
train
function typeClass() { Components.Html.root.classList.add(Glide.settings.classes[Glide.settings.type]); }
javascript
{ "resource": "" }
q21518
removeClasses
train
function removeClasses() { var classes = Glide.settings.classes; Components.Html.root.classList.remove(classes[Glide.settings.type]); Components.Html.slides.forEach(function (sibling) { sibling.classList.remove(classes.activeSlide); }); }
javascript
{ "resource": "" }
q21519
collect
train
function collect() { var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var slides = Components.Html.slides; var _Glide$settings = Glide.settings, perView = _Glide$settings.perView, classes = _Glide$settings.classes; var peekIncrementer = +!!Glide.settings.peek; var part = perView + peekIncrementer; var start = slides.slice(0, part); var end = slides.slice(-part); for (var r = 0; r < Math.max(1, Math.floor(perView / slides.length)); r++) { for (var i = 0; i < start.length; i++) { var clone = start[i].cloneNode(true); clone.classList.add(classes.cloneSlide); items.push(clone); } for (var _i = 0; _i < end.length; _i++) { var _clone = end[_i].cloneNode(true); _clone.classList.add(classes.cloneSlide); items.unshift(_clone); } } return items; }
javascript
{ "resource": "" }
q21520
append
train
function append() { var items = this.items; var _Components$Html = Components.Html, wrapper = _Components$Html.wrapper, slides = _Components$Html.slides; var half = Math.floor(items.length / 2); var prepend = items.slice(0, half).reverse(); var append = items.slice(half, items.length); var width = Components.Sizes.slideWidth + 'px'; for (var i = 0; i < append.length; i++) { wrapper.appendChild(append[i]); } for (var _i2 = 0; _i2 < prepend.length; _i2++) { wrapper.insertBefore(prepend[_i2], slides[0]); } for (var _i3 = 0; _i3 < items.length; _i3++) { items[_i3].style.width = width; } }
javascript
{ "resource": "" }
q21521
remove
train
function remove() { var items = this.items; for (var i = 0; i < items.length; i++) { Components.Html.wrapper.removeChild(items[i]); } }
javascript
{ "resource": "" }
q21522
get
train
function get() { return (Components.Sizes.slideWidth + Components.Gaps.value) * Clones.items.length; }
javascript
{ "resource": "" }
q21523
EventsBinder
train
function EventsBinder() { var listeners = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; classCallCheck(this, EventsBinder); this.listeners = listeners; }
javascript
{ "resource": "" }
q21524
bind
train
function bind() { Binder.on('resize', window, throttle(function () { Events.emit('resize'); }, Glide.settings.throttle)); }
javascript
{ "resource": "" }
q21525
resolve
train
function resolve(pattern) { var token = pattern.slice(0, 1); if (this.is('rtl')) { return pattern.split(token).join(FLIPED_MOVEMENTS[token]); } return pattern; }
javascript
{ "resource": "" }
q21526
addClass
train
function addClass() { Components.Html.root.classList.add(Glide.settings.classes.direction[this.value]); }
javascript
{ "resource": "" }
q21527
removeClass
train
function removeClass() { Components.Html.root.classList.remove(Glide.settings.classes.direction[this.value]); }
javascript
{ "resource": "" }
q21528
Rtl
train
function Rtl (Glide, Components) { return { /** * Negates the passed translate if glide is in RTL option. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { if (Components.Direction.is('rtl')) { return -translate; } return translate; } }; }
javascript
{ "resource": "" }
q21529
Gap
train
function Gap (Glide, Components) { return { /** * Modifies passed translate value with number in the `gap` settings. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { return translate + Components.Gaps.value * Glide.index; } }; }
javascript
{ "resource": "" }
q21530
Grow
train
function Grow (Glide, Components) { return { /** * Adds to the passed translate width of the half of clones. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { return translate + Components.Clones.grow / 2; } }; }
javascript
{ "resource": "" }
q21531
modify
train
function modify(translate) { if (Glide.settings.focusAt >= 0) { var peek = Components.Peek.value; if (isObject(peek)) { return translate - peek.before; } return translate - peek; } return translate; }
javascript
{ "resource": "" }
q21532
Focusing
train
function Focusing (Glide, Components) { return { /** * Modifies passed translate value with index in the `focusAt` setting. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { var gap = Components.Gaps.value; var width = Components.Sizes.width; var focusAt = Glide.settings.focusAt; var slideWidth = Components.Sizes.slideWidth; if (focusAt === 'center') { return translate - (width / 2 - slideWidth / 2); } return translate - slideWidth * focusAt - gap * focusAt; } }; }
javascript
{ "resource": "" }
q21533
mutator
train
function mutator (Glide, Components, Events) { /** * Merge instance transformers with collection of default transformers. * It's important that the Rtl component be last on the list, * so it reflects all previous transformations. * * @type {Array} */ var TRANSFORMERS = [Gap, Grow, Peeking, Focusing].concat(Glide._t, [Rtl]); return { /** * Piplines translate value with registered transformers. * * @param {Number} translate * @return {Number} */ mutate: function mutate(translate) { for (var i = 0; i < TRANSFORMERS.length; i++) { var transformer = TRANSFORMERS[i]; if (isFunction(transformer) && isFunction(transformer().modify)) { translate = transformer(Glide, Components, Events).modify(translate); } else { warn('Transformer should be a function that returns an object with `modify()` method'); } } return translate; } }; }
javascript
{ "resource": "" }
q21534
mutate
train
function mutate(translate) { for (var i = 0; i < TRANSFORMERS.length; i++) { var transformer = TRANSFORMERS[i]; if (isFunction(transformer) && isFunction(transformer().modify)) { translate = transformer(Glide, Components, Events).modify(translate); } else { warn('Transformer should be a function that returns an object with `modify()` method'); } } return translate; }
javascript
{ "resource": "" }
q21535
set
train
function set(value) { var transform = mutator(Glide, Components).mutate(value); Components.Html.wrapper.style.transform = 'translate3d(' + -1 * transform + 'px, 0px, 0px)'; }
javascript
{ "resource": "" }
q21536
compose
train
function compose(property) { var settings = Glide.settings; if (!disabled) { return property + ' ' + this.duration + 'ms ' + settings.animationTimingFunc; } return property + ' 0ms ' + settings.animationTimingFunc; }
javascript
{ "resource": "" }
q21537
set
train
function set() { var property = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'transform'; Components.Html.wrapper.style.transition = this.compose(property); }
javascript
{ "resource": "" }
q21538
get
train
function get() { var settings = Glide.settings; if (Glide.isType('slider') && Components.Run.offset) { return settings.rewindDuration; } return settings.animationDuration; }
javascript
{ "resource": "" }
q21539
start
train
function start(event) { if (!disabled && !Glide.disabled) { this.disable(); var swipe = this.touches(event); swipeSin = null; swipeStartX = toInt(swipe.pageX); swipeStartY = toInt(swipe.pageY); this.bindSwipeMove(); this.bindSwipeEnd(); Events.emit('swipe.start'); } }
javascript
{ "resource": "" }
q21540
move
train
function move(event) { if (!Glide.disabled) { var _Glide$settings = Glide.settings, touchAngle = _Glide$settings.touchAngle, touchRatio = _Glide$settings.touchRatio, classes = _Glide$settings.classes; var swipe = this.touches(event); var subExSx = toInt(swipe.pageX) - swipeStartX; var subEySy = toInt(swipe.pageY) - swipeStartY; var powEX = Math.abs(subExSx << 2); var powEY = Math.abs(subEySy << 2); var swipeHypotenuse = Math.sqrt(powEX + powEY); var swipeCathetus = Math.sqrt(powEY); swipeSin = Math.asin(swipeCathetus / swipeHypotenuse); if (swipeSin * 180 / Math.PI < touchAngle) { event.stopPropagation(); Components.Move.make(subExSx * toFloat(touchRatio)); Components.Html.root.classList.add(classes.dragging); Events.emit('swipe.move'); } else { return false; } } }
javascript
{ "resource": "" }
q21541
end
train
function end(event) { if (!Glide.disabled) { var settings = Glide.settings; var swipe = this.touches(event); var threshold = this.threshold(event); var swipeDistance = swipe.pageX - swipeStartX; var swipeDeg = swipeSin * 180 / Math.PI; var steps = Math.round(swipeDistance / Components.Sizes.slideWidth); this.enable(); if (swipeDistance > threshold && swipeDeg < settings.touchAngle) { // While swipe is positive and greater than threshold move backward. if (settings.perTouch) { steps = Math.min(steps, toInt(settings.perTouch)); } if (Components.Direction.is('rtl')) { steps = -steps; } Components.Run.make(Components.Direction.resolve('<' + steps)); } else if (swipeDistance < -threshold && swipeDeg < settings.touchAngle) { // While swipe is negative and lower than negative threshold move forward. if (settings.perTouch) { steps = Math.max(steps, -toInt(settings.perTouch)); } if (Components.Direction.is('rtl')) { steps = -steps; } Components.Run.make(Components.Direction.resolve('>' + steps)); } else { // While swipe don't reach distance apply previous transform. Components.Move.make(); } Components.Html.root.classList.remove(settings.classes.dragging); this.unbindSwipeMove(); this.unbindSwipeEnd(); Events.emit('swipe.end'); } }
javascript
{ "resource": "" }
q21542
bindSwipeStart
train
function bindSwipeStart() { var _this = this; var settings = Glide.settings; if (settings.swipeThreshold) { Binder.on(START_EVENTS[0], Components.Html.wrapper, function (event) { _this.start(event); }, capture); } if (settings.dragThreshold) { Binder.on(START_EVENTS[1], Components.Html.wrapper, function (event) { _this.start(event); }, capture); } }
javascript
{ "resource": "" }
q21543
unbindSwipeStart
train
function unbindSwipeStart() { Binder.off(START_EVENTS[0], Components.Html.wrapper, capture); Binder.off(START_EVENTS[1], Components.Html.wrapper, capture); }
javascript
{ "resource": "" }
q21544
bindSwipeMove
train
function bindSwipeMove() { var _this2 = this; Binder.on(MOVE_EVENTS, Components.Html.wrapper, throttle(function (event) { _this2.move(event); }, Glide.settings.throttle), capture); }
javascript
{ "resource": "" }
q21545
bindSwipeEnd
train
function bindSwipeEnd() { var _this3 = this; Binder.on(END_EVENTS, Components.Html.wrapper, function (event) { _this3.end(event); }); }
javascript
{ "resource": "" }
q21546
touches
train
function touches(event) { if (MOUSE_EVENTS.indexOf(event.type) > -1) { return event; } return event.touches[0] || event.changedTouches[0]; }
javascript
{ "resource": "" }
q21547
threshold
train
function threshold(event) { var settings = Glide.settings; if (MOUSE_EVENTS.indexOf(event.type) > -1) { return settings.dragThreshold; } return settings.swipeThreshold; }
javascript
{ "resource": "" }
q21548
detach
train
function detach() { prevented = true; if (!detached) { for (var i = 0; i < this.items.length; i++) { this.items[i].draggable = false; this.items[i].setAttribute('data-href', this.items[i].getAttribute('href')); this.items[i].removeAttribute('href'); } detached = true; } return this; }
javascript
{ "resource": "" }
q21549
attach
train
function attach() { prevented = false; if (detached) { for (var i = 0; i < this.items.length; i++) { this.items[i].draggable = true; this.items[i].setAttribute('href', this.items[i].getAttribute('data-href')); } detached = false; } return this; }
javascript
{ "resource": "" }
q21550
mount
train
function mount() { /** * Collection of navigation HTML elements. * * @private * @type {HTMLCollection} */ this._n = Components.Html.root.querySelectorAll(NAV_SELECTOR); /** * Collection of controls HTML elements. * * @private * @type {HTMLCollection} */ this._c = Components.Html.root.querySelectorAll(CONTROLS_SELECTOR); this.addBindings(); }
javascript
{ "resource": "" }
q21551
removeActive
train
function removeActive() { for (var i = 0; i < this._n.length; i++) { this.removeClass(this._n[i].children); } }
javascript
{ "resource": "" }
q21552
addClass
train
function addClass(controls) { var settings = Glide.settings; var item = controls[Glide.index]; if (item) { item.classList.add(settings.classes.activeNav); siblings(item).forEach(function (sibling) { sibling.classList.remove(settings.classes.activeNav); }); } }
javascript
{ "resource": "" }
q21553
removeClass
train
function removeClass(controls) { var item = controls[Glide.index]; if (item) { item.classList.remove(Glide.settings.classes.activeNav); } }
javascript
{ "resource": "" }
q21554
addBindings
train
function addBindings() { for (var i = 0; i < this._c.length; i++) { this.bind(this._c[i].children); } }
javascript
{ "resource": "" }
q21555
removeBindings
train
function removeBindings() { for (var i = 0; i < this._c.length; i++) { this.unbind(this._c[i].children); } }
javascript
{ "resource": "" }
q21556
bind
train
function bind(elements) { for (var i = 0; i < elements.length; i++) { Binder.on('click', elements[i], this.click); Binder.on('touchstart', elements[i], this.click, capture); } }
javascript
{ "resource": "" }
q21557
unbind
train
function unbind(elements) { for (var i = 0; i < elements.length; i++) { Binder.off(['click', 'touchstart'], elements[i]); } }
javascript
{ "resource": "" }
q21558
click
train
function click(event) { event.preventDefault(); Components.Run.make(Components.Direction.resolve(event.currentTarget.getAttribute('data-glide-dir'))); }
javascript
{ "resource": "" }
q21559
press
train
function press(event) { if (event.keyCode === 39) { Components.Run.make(Components.Direction.resolve('>')); } if (event.keyCode === 37) { Components.Run.make(Components.Direction.resolve('<')); } }
javascript
{ "resource": "" }
q21560
start
train
function start() { var _this = this; if (Glide.settings.autoplay) { if (isUndefined(this._i)) { this._i = setInterval(function () { _this.stop(); Components.Run.make('>'); _this.start(); }, this.time); } } }
javascript
{ "resource": "" }
q21561
bind
train
function bind() { var _this2 = this; Binder.on('mouseover', Components.Html.root, function () { _this2.stop(); }); Binder.on('mouseout', Components.Html.root, function () { _this2.start(); }); }
javascript
{ "resource": "" }
q21562
get
train
function get() { var autoplay = Components.Html.slides[Glide.index].getAttribute('data-glide-autoplay'); if (autoplay) { return toInt(autoplay); } return toInt(Glide.settings.autoplay); }
javascript
{ "resource": "" }
q21563
match
train
function match(points) { if (typeof window.matchMedia !== 'undefined') { for (var point in points) { if (points.hasOwnProperty(point)) { if (window.matchMedia('(max-width: ' + point + 'px)').matches) { return points[point]; } } } } return defaults; }
javascript
{ "resource": "" }
q21564
createCallback
train
function createCallback(element,callback) { var fn = function(originalEvent) { !originalEvent && ( originalEvent = window.event ); // create a normalized event object var event = { // keep a ref to the original event object originalEvent: originalEvent, target: originalEvent.target || originalEvent.srcElement, type: "wheel", deltaMode: originalEvent.type == "MozMousePixelScroll" ? 0 : 1, deltaX: 0, delatZ: 0, preventDefault: function() { originalEvent.preventDefault ? originalEvent.preventDefault() : originalEvent.returnValue = false; } }; // calculate deltaY (and deltaX) according to the event if ( support == "mousewheel" ) { event.deltaY = - 1/40 * originalEvent.wheelDelta; // Webkit also support wheelDeltaX originalEvent.wheelDeltaX && ( event.deltaX = - 1/40 * originalEvent.wheelDeltaX ); } else { event.deltaY = originalEvent.detail; } // it's time to fire the callback return callback( event ); }; fns.push({ element: element, fn: fn, }); return fn; }
javascript
{ "resource": "" }
q21565
subclass$
train
function subclass$(obj,sup) { for (var k in sup) { if (sup.hasOwnProperty(k)) obj[k] = sup[k]; }; // obj.__super__ = sup; obj.prototype = Object.create(sup.prototype); obj.__super__ = obj.prototype.__super__ = sup.prototype; obj.prototype.initialize = obj.prototype.constructor = obj; }
javascript
{ "resource": "" }
q21566
Parens
train
function Parens(value,open,close){ this.setup(); this._open = open; this._close = close; this._value = this.load(value); }
javascript
{ "resource": "" }
q21567
Param
train
function Param(name,defaults,typ){ // could have introduced bugs by moving back to identifier here this._traversed = false; this._name = name; this._defaults = defaults; this._typ = typ; this._variable = null; }
javascript
{ "resource": "" }
q21568
Root
train
function Root(body,opts){ this._traversed = false; this._body = AST.blk(body); this._scope = new RootScope(this,null); this._options = {}; }
javascript
{ "resource": "" }
q21569
Literal
train
function Literal(v){ this._traversed = false; this._expression = true; this._cache = null; this._raw = null; this._value = this.load(v); }
javascript
{ "resource": "" }
q21570
Str
train
function Str(v){ this._traversed = false; this._expression = true; this._cache = null; this._value = v; // should grab the actual value immediately? }
javascript
{ "resource": "" }
q21571
InterpolatedString
train
function InterpolatedString(nodes,o){ if(o === undefined) o = {}; this._nodes = nodes; this._options = o; this; }
javascript
{ "resource": "" }
q21572
Identifier
train
function Identifier(value){ this._value = this.load(value); this._symbol = null; this._setter = null; if (("" + value).indexOf("?") >= 0) { this._safechain = true; }; // @safechain = ("" + value).indexOf("?") >= 0 this; }
javascript
{ "resource": "" }
q21573
For
train
function For(o){ if(o === undefined) o = {}; this._traversed = false; this._options = o; this._scope = new ForScope(this); this._catcher = null; }
javascript
{ "resource": "" }
q21574
TagTree
train
function TagTree(owner,list,options){ if(options === undefined) options = {}; this._owner = owner; this._nodes = this.load(list); this._options = options; this._conditions = []; this._blocks = [this]; this._counter = 0; this; }
javascript
{ "resource": "" }
q21575
RootScope
train
function RootScope(){ RootScope.prototype.__super__.constructor.apply(this,arguments); this.register('global',this,{type: 'global'}); this.register('module',this,{type: 'global'}); this.register('window',this,{type: 'global'}); this.register('document',this,{type: 'global'}); this.register('exports',this,{type: 'global'}); this.register('console',this,{type: 'global'}); this.register('process',this,{type: 'global'}); this.register('parseInt',this,{type: 'global'}); this.register('parseFloat',this,{type: 'global'}); this.register('setTimeout',this,{type: 'global'}); this.register('setInterval',this,{type: 'global'}); this.register('setImmediate',this,{type: 'global'}); this.register('clearTimeout',this,{type: 'global'}); this.register('clearInterval',this,{type: 'global'}); this.register('clearImmediate',this,{type: 'global'}); this.register('isNaN',this,{type: 'global'}); this.register('isFinite',this,{type: 'global'}); this.register('__dirname',this,{type: 'global'}); this.register('__filename',this,{type: 'global'}); this.register('_',this,{type: 'global'}); // preregister global special variables here this._requires = {}; this._warnings = []; this._scopes = []; this._helpers = []; this._selfless = false; this._entities = new Entities(this); this._object = Obj.wrap({}); this._head = [this._vars]; }
javascript
{ "resource": "" }
q21576
train
function(root,node,before) { if (node instanceof Array) { var i = 0; var c = node.taglen; var k = (c != null) ? ((node.domlen = c)) : node.length; while (i < k){ insertNestedBefore(root,node[i++],before); }; } else if (node && node._dom) { root.insertBefore(node,before); } else if (node != null && node !== false) { root.insertBefore(Imba.createTextNode(node),before); }; return before; }
javascript
{ "resource": "" }
q21577
train
function(root,new$,old,caret) { var nl = new$.length; var ol = old.length; var cl = new$.cache.i$; // cache-length var i = 0,d = nl - ol; // TODO support caret // find the first index that is different while (i < ol && i < nl && new$[i] === old[i]){ i++; }; // conditionally prune cache if (cl > 1000 && (cl - nl) > 500) { new$.cache.$prune(new$); }; if (d > 0 && i == ol) { // added at end while (i < nl){ root.appendChild(new$[i++]); }; return; } else if (d > 0) { var i1 = nl; while (i1 > i && new$[i1 - 1] === old[i1 - 1 - d]){ i1--; }; if (d == (i1 - i)) { var before = old[i]._slot_; while (i < i1){ root.insertBefore(new$[i++],before); }; return; }; } else if (d < 0 && i == nl) { // removed at end while (i < ol){ root.removeChild(old[i++]); }; return; } else if (d < 0) { var i11 = ol; while (i11 > i && new$[i11 - 1 + d] === old[i11 - 1]){ i11--; }; if (d == (i - i11)) { while (i < i11){ root.removeChild(old[i++]); }; return; }; } else if (i == nl) { return; }; return reconcileCollectionChanges(root,new$,old,caret); }
javascript
{ "resource": "" }
q21578
train
function(root,new$,old,caret) { // var skipnew = new == null or new === false or new === true var newIsNull = new$ == null || new$ === false; var oldIsNull = old == null || old === false; if (new$ === old) { // remember that the caret must be an actual dom element // we should instead move the actual caret? - trust if (newIsNull) { return caret; } else if (new$._slot_) { return new$._slot_; } else if ((new$ instanceof Array) && new$.taglen != null) { return reconcileIndexedArray(root,new$,old,caret); } else { return caret ? caret.nextSibling : root._dom.firstChild; }; } else if (new$ instanceof Array) { if (old instanceof Array) { // look for slot instead? var typ = new$.static; if (typ || old.static) { // if the static is not nested - we could get a hint from compiler // and just skip it if (typ == old.static) { // should also include a reference? for (var i = 0, items = iter$(new$), len = items.length; i < len; i++) { // this is where we could do the triple equal directly caret = reconcileNested(root,items[i],old[i],caret); }; return caret; } else { removeNested(root,old,caret); }; // if they are not the same we continue through to the default } else { // Could use optimized loop if we know that it only consists of nodes return reconcileCollection(root,new$,old,caret); }; } else if (!oldIsNull) { if (old._slot_) { root.removeChild(old); } else { // old was a string-like object? root.removeChild(caret ? caret.nextSibling : root._dom.firstChild); }; }; return self.insertNestedAfter(root,new$,caret); // remove old } else if (!newIsNull && new$._slot_) { if (!oldIsNull) { removeNested(root,old,caret) }; return self.insertNestedAfter(root,new$,caret); } else if (newIsNull) { if (!oldIsNull) { removeNested(root,old,caret) }; return caret; } else { // if old did not exist we need to add a new directly var nextNode; // if old was array or imbatag we need to remove it and then add if (old instanceof Array) { removeNested(root,old,caret); } else if (old && old._slot_) { root.removeChild(old); } else if (!oldIsNull) { // ... nextNode = caret ? caret.nextSibling : root._dom.firstChild; if ((nextNode instanceof Text) && nextNode.textContent != new$) { nextNode.textContent = new$; return nextNode; }; }; // now add the textnode return self.insertNestedAfter(root,new$,caret); }; }
javascript
{ "resource": "" }
q21579
train
function(token,i,tokens) { var type = token._type; if (!seenSingle && token.fromThen) { return true; }; var ifelse = type == 'IF' || type == 'UNLESS' || type == 'ELSE'; if (ifelse || type === 'CATCH') { seenSingle = true; }; if (ifelse || type === 'SWITCH' || type == 'TRY') { seenControl = true; }; var prev = self.tokenType(i - 1); if ((type == '.' || type == '?.' || type == '::') && prev === OUTDENT) { return true; }; if (endCallAtTerminator && (type === INDENT || type === TERMINATOR)) { return true; }; if ((type == 'WHEN' || type == 'BY') && !seenFor) { // console.log "dont close implicit call outside for" return false; }; var post = (tokens.length > (i + 1)) ? tokens[i + 1] : null; var postTyp = post && post._type; if (token.generated || prev === ',') { return false; }; var cond1 = (IMPLICIT_END_MAP[type] || (type == INDENT && !seenControl) || (type == 'DOS' && prev != '=')); if (!cond1) { return false; }; if (type !== INDENT) { return true; }; if (!IMPLICIT_BLOCK_MAP[prev] && self.tokenType(i - 2) != 'CLASS' && !(post && ((post.generated && postTyp == '{') || IMPLICIT_CALL_MAP[postTyp]))) { return true; }; return false; }
javascript
{ "resource": "" }
q21580
processOperators
train
function processOperators (ops) { if (!ops) return {}; var operators = {}; for (var i=0,k,prec;prec=ops[i]; i++) { for (k=1;k < prec.length;k++) { operators[prec[k]] = {precedence: i+1, assoc: prec[0]}; } } return operators; }
javascript
{ "resource": "" }
q21581
addSymbol
train
function addSymbol (s) { if (s && !symbols_[s]) { symbols_[s] = ++symbolId; symbols.push(s); } }
javascript
{ "resource": "" }
q21582
tokenStackLex
train
function tokenStackLex() { var token; token = tstack.pop() || lexer.lex() || EOF; // if token isn't its numeric value, convert if (typeof token !== 'number') { if (token instanceof Array) { tstack = token; token = tstack.pop(); } token = self.symbols_[token] || token; } return token; }
javascript
{ "resource": "" }
q21583
createVariable
train
function createVariable() { var id = nextVariableId++; var name = '$V'; do { name += variableTokens[id % variableTokensLength]; id = ~~(id / variableTokensLength); } while (id !== 0); return name; }
javascript
{ "resource": "" }
q21584
locateNearestErrorRecoveryRule
train
function locateNearestErrorRecoveryRule(state) { var stack_probe = stack.length - 1; var depth = 0; // try to recover from error for(;;) { // check for error recovery rule in this state if ((TERROR.toString()) in table[state]) { return depth; } if (state === 0 || stack_probe < 2) { return false; // No suitable error recovery rule available. } stack_probe -= 2; // popStack(1): [symbol, action] state = stack[stack_probe]; ++depth; } }
javascript
{ "resource": "" }
q21585
LALR_buildNewGrammar
train
function LALR_buildNewGrammar () { var self = this, newg = this.newg; this.states.forEach(function (state, i) { state.forEach(function (item) { if (item.dotPosition === 0) { // new symbols are a combination of state and transition symbol var symbol = i+":"+item.production.symbol; self.terms_[symbol] = item.production.symbol; newg.nterms_[symbol] = i; if (!newg.nonterminals[symbol]) newg.nonterminals[symbol] = new Nonterminal(symbol); var pathInfo = self.goPath(i, item.production.handle); var p = new Production(symbol, pathInfo.path, newg.productions.length); newg.productions.push(p); newg.nonterminals[symbol].productions.push(p); // store the transition that get's 'backed up to' after reduction on path var handle = item.production.handle.join(' '); var goes = self.states.item(pathInfo.endState).goes; if (!goes[handle]) goes[handle] = []; goes[handle].push(symbol); //self.trace('new production:',p); } }); if (state.inadequate) self.inadequateStates.push(i); }); }
javascript
{ "resource": "" }
q21586
focusTab
train
function focusTab(tabId) { var updateProperties = { "active": true }; chrome.tabs.update(tabId, updateProperties, function (tab) { }); }
javascript
{ "resource": "" }
q21587
save_options
train
function save_options() { var showChangeLog = document.getElementById('show_changelog').checked; chrome.storage.sync.set({ showChangeLog: showChangeLog }, function () { // Update status to let user know options were saved. var status = document.getElementById('status'); status.textContent = 'Options saved.'; setTimeout(function () { status.textContent = ''; }, 750); }); }
javascript
{ "resource": "" }
q21588
restore_options
train
function restore_options() { // Use default value showChangeLog = true. chrome.storage.sync.get({ showChangeLog: true }, function (items) { document.getElementById('show_changelog').checked = items.showChangeLog; }); }
javascript
{ "resource": "" }
q21589
style
train
function style (s, t) { if (!t) return (text) => style(s, text) return cli.color[styles[s] || s](t) }
javascript
{ "resource": "" }
q21590
buildReporter
train
function buildReporter(methods) { return { supports: methods.supports, begin: buildReporterMethod(methods.begin), results: buildReporterMethod(methods.results), log: { debug: buildReporterMethod(methods.debug), error: buildReporterMethod(methods.error, 'error'), info: buildReporterMethod(methods.info) } }; }
javascript
{ "resource": "" }
q21591
buildReporterMethod
train
function buildReporterMethod(method, consoleMethod = 'log') { if (typeof method !== 'function') { method = () => {}; } return async input => { const output = await method(input); if (output) { console[consoleMethod](output); } }; }
javascript
{ "resource": "" }
q21592
isValidAction
train
function isValidAction(actionString) { return module.exports.actions.some(foundAction => { return foundAction.match.test(actionString); }); }
javascript
{ "resource": "" }
q21593
pa11y
train
async function pa11y(url, options = {}, callback) { const state = {}; /* eslint-disable prefer-rest-params */ // Check for presence of a callback function if (typeof arguments[arguments.length - 1] === 'function') { callback = arguments[arguments.length - 1]; } else { callback = undefined; } /* eslint-enable prefer-rest-params */ try { // Switch parameters if only an options object is provided, // and default the options if (typeof url !== 'string') { options = url; url = options.url; } url = sanitizeUrl(url); options = defaultOptions(options); // Verify that the given options are valid verifyOptions(options); // Call the actual Pa11y test runner with // a timeout if it takes too long const results = await promiseTimeout( runPa11yTest(url, options, state), options.timeout, `Pa11y timed out (${options.timeout}ms)` ); // Run callback if present, and resolve with results if (callback) { return callback(null, results); } return results; } catch (error) { if (state.browser && state.autoClose) { state.browser.close(); } else if (state.page && state.autoClosePage) { state.page.close(); } // Run callback if present, and reject with error if (callback) { return callback(error); } throw error; } }
javascript
{ "resource": "" }
q21594
defaultOptions
train
function defaultOptions(options) { options = extend({}, pa11y.defaults, options); options.ignore = options.ignore.map(ignored => ignored.toLowerCase()); if (!options.includeNotices) { options.ignore.push('notice'); } if (!options.includeWarnings) { options.ignore.push('warning'); } return options; }
javascript
{ "resource": "" }
q21595
verifyOptions
train
function verifyOptions(options) { if (!pa11y.allowedStandards.includes(options.standard)) { throw new Error(`Standard must be one of ${pa11y.allowedStandards.join(', ')}`); } if (options.page && !options.browser) { throw new Error('The page option must only be set alongside the browser option'); } }
javascript
{ "resource": "" }
q21596
configureHtmlCodeSniffer
train
function configureHtmlCodeSniffer() { if (options.rules.length && options.standard !== 'Section508') { for (const rule of options.rules) { if (window.HTMLCS_WCAG2AAA.sniffs.includes(rule)) { window[`HTMLCS_${options.standard}`].sniffs[0].include.push(rule); } else { throw new Error(`${rule} is not a valid WCAG 2.0 rule`); } } } }
javascript
{ "resource": "" }
q21597
runHtmlCodeSniffer
train
function runHtmlCodeSniffer() { return new Promise((resolve, reject) => { window.HTMLCS.process(options.standard, window.document, error => { if (error) { return reject(error); } resolve(window.HTMLCS.getMessages()); }); }); }
javascript
{ "resource": "" }
q21598
processIssues
train
function processIssues(issues) { if (options.rootElement) { issues = issues.filter(isIssueInTestArea); } if (options.hideElements) { issues = issues.filter(isElementOutsideHiddenArea); } return issues.map(processIssue).filter(isIssueNotIgnored); }
javascript
{ "resource": "" }
q21599
processIssue
train
function processIssue(issue) { return { code: issue.code, context: processIssueHtml(issue.element), message: issue.msg, type: issueTypeMap[issue.type] || 'unknown', typeCode: issue.type, selector: getCssSelectorForElement(issue.element) }; }
javascript
{ "resource": "" }