_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q42200
promisify
train
function promisify(original, self = null) { if (typeof original !== 'function') { throw new TypeError('original must be a function') } /** * Wrapped original function. * @typedef {function} wrapper * @param {...*} args - Arguments to apply to the original function. * @returns {Promise.<*>} - Prom...
javascript
{ "resource": "" }
q42201
generateCardDocument
train
function generateCardDocument(options, callback) { var DB = require('../index').db, elementId = Cuid(); // defaults options = _.defaultsDeep(options, { directory: '.', css: true, js: false, clientStateSupport: false, clientProxySupport: false, clientAnalyticsSupport: false, viewMo...
javascript
{ "resource": "" }
q42202
train
function (packName, cardName, inputValues, callback) { var DB = require('../index').db; // Go through the input values and base64 them if they aren't already. var allBase64 = true; _.each(_.keys(inputValues), function (key) { if (!/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za...
javascript
{ "resource": "" }
q42203
train
function (cb) { // card key var url = options.url.replace(/light=true/i, ''), params = { legacyCardKey: Utils.getLegacyCardKey(url, process.env.CARD_SECRET), cardKey: Utils.getCardKey(url, process.env.CARD_SECRET) ...
javascript
{ "resource": "" }
q42204
train
function (params, cb) { // validate input requirements vs what came back in params var errorMessage = null; _.forEach(Card.inputs, function (input, key) { if (input.required && !params[key]) { if (!errorMessage) { ...
javascript
{ "resource": "" }
q42205
train
function (err, params) { if (!err) { callback && callback(null, params); } else { callback && callback(err.message || err); } }
javascript
{ "resource": "" }
q42206
train
function (params, cb) { DB.getCardState(params.cardKey, params.legacyCardKey, function (err, state) { cb(null, params, state); }); }
javascript
{ "resource": "" }
q42207
train
function (params, state, cb) { state = state || {}; if (Card.getCardData) { Card.getCardData(params, state, function (err, viewModel, clientLocals) { cb(err, params, state, viewModel, clientLocals); }); ...
javascript
{ "resource": "" }
q42208
train
function (params, state, viewModel, clientLocals, cb) { // don't save if nothing came back, just forward the call if (!_.isEmpty(state)) { DB.saveCardState(params.cardKey, state, function (err) { cb(err, params, viewModel, clientLocals); ...
javascript
{ "resource": "" }
q42209
train
function (params, viewModel, clientLocals, cb) { viewModel = viewModel || {}; clientLocals = clientLocals || {}; var generateOptions = { directory: options.directory, packName: options.packName, cardName: ...
javascript
{ "resource": "" }
q42210
train
function (err, html) { if (!err) { callback && callback(null, html); } else { console.log('CARD: Error rendering HashDo card ' + options.packName + '-' + options.cardName + '.', err); callback && callback(err.message |...
javascript
{ "resource": "" }
q42211
train
function (options, callback) { if (!options) { throw new Error('You must provide an options object to .'); } if (!options.packName) { throw new Error('You must provide a pack name the card belongs to.'); } if (!options.cardName) { throw new Error('You must provide a card ...
javascript
{ "resource": "" }
q42212
nextTick
train
function nextTick (next, err) { return process.nextTick(function () { try { next(err) } catch (e) { // istanbul ignore next next(e) } }) }
javascript
{ "resource": "" }
q42213
compose
train
function compose () { // the function required by the server function middlewareF (req, res, end) { var index = 0 // inject stats middleware if (middlewareF.options && middlewareF.options.stats) { middlewareF.stack = middlewareF.stack.map(function (mw) { var fn if (typeof mw === '...
javascript
{ "resource": "" }
q42214
middlewareF
train
function middlewareF (req, res, end) { var index = 0 // inject stats middleware if (middlewareF.options && middlewareF.options.stats) { middlewareF.stack = middlewareF.stack.map(function (mw) { var fn if (typeof mw === 'object') { var key = Object.keys(mw)[0] if (!...
javascript
{ "resource": "" }
q42215
_write
train
function _write(dest, source, callback) { var itemPath = path.join(dest, source.name); // switch according to type of the current root item switch(source.type) { case TYPE_FILE: if (source.data instanceof stream.Readable) { // stream data => pipe it to destination stream source.data.pipe...
javascript
{ "resource": "" }
q42216
_folderWritten
train
function _folderWritten(dest, source, callback, err) { if (err) return callback(err); async.each(source.children, _write.bind(null, dest), callback); }
javascript
{ "resource": "" }
q42217
_read
train
function _read(stat, source, callback) { stat(source, _pathStated.bind(null, {}, stat, source, callback)); }
javascript
{ "resource": "" }
q42218
_pathStated
train
function _pathStated(item, stat, stated, callback, err, stats) { if (err) return callback(err); item.name = path.basename(stated); if (stats.isFile()) { item.type = TYPE_FILE; // TODO set encoding according to the read file content or user preferences return fs.readFile(stated, {encoding: 'utf8'}, _...
javascript
{ "resource": "" }
q42219
_fileRead
train
function _fileRead(item, callback, err, data) { if (err) return callback(err); item.data = data; callback(null, item); }
javascript
{ "resource": "" }
q42220
_folderRead
train
function _folderRead(item, stat, dirpath, callback, err, files) { if (err) return callback(err); async.map( files, _readChild.bind(null, stat, dirpath), _childrenRead.bind(null, item, callback) ); }
javascript
{ "resource": "" }
q42221
_readChild
train
function _readChild(stat, dirpath, name, callback) { _read(stat, path.join(dirpath, name), callback); }
javascript
{ "resource": "" }
q42222
_aliasRead
train
function _aliasRead(item, callback, err, orig) { if (err) return callback(err); item.orig = orig; callback(null, item); }
javascript
{ "resource": "" }
q42223
_store
train
function _store(dest, source, callback) { fs.writeFile(dest, JSON.stringify(source), callback); }
javascript
{ "resource": "" }
q42224
_load
train
function _load(source, callback) { fs.readFile(source, {encoding: 'utf8'}, _jsonLoaded.bind(null, callback)); }
javascript
{ "resource": "" }
q42225
_jsonLoaded
train
function _jsonLoaded(callback, err, data) { if (err) return callback(err); var parsed; try { parsed = JSON.parse(data); } catch(jerr) { return callback(jerr); } callback(null, parsed); }
javascript
{ "resource": "" }
q42226
_load2write
train
function _load2write(dest, source, callback) { _load(source, _pipe.bind(null, _write.bind(null, dest), callback)); }
javascript
{ "resource": "" }
q42227
_read2store
train
function _read2store(stat, dest, source, callback) { _read(stat, source, _pipe.bind(null, _store.bind(null, dest), callback)); }
javascript
{ "resource": "" }
q42228
_pipe
train
function _pipe(out, callback, err, iresult) { if (err) return callback(err); out(iresult, callback); }
javascript
{ "resource": "" }
q42229
_handleConvert
train
function _handleConvert(stat, dest, source, callback) { // "dest" arg is optional if (typeof source === 'function') { callback = source; source = dest; dest = null; } // assert input params assert.ok( dest === null || typeof dest === 'string', 'Invalid type of argument "dest", expected "n...
javascript
{ "resource": "" }
q42230
Entity
train
function Entity(param) { EventEmitter2.apply(this, arguments); Entity.prototype.init.apply(this, arguments); }
javascript
{ "resource": "" }
q42231
validator
train
function validator (data, schema) { const result = Object.assign({}, data) Object.keys(schema).map(key => { let value = schema[key] const type = typeof value if (type !== 'object') { value = { transform: value } } validate(value, result, key) }) return result }
javascript
{ "resource": "" }
q42232
coerce
train
function coerce (type, field, value) { let result if (type === 'string') { result = String(value).trim() } else if (type === 'number') { result = Number(value) if (isNaN(result)) throw new Error(`field ${field} can not be converted to a number`) } else if (type === 'array') { result = [].concat(...
javascript
{ "resource": "" }
q42233
SplitLine
train
function SplitLine (options) { if (!(this instanceof SplitLine)) { return new SplitLine(options) } this.options = options || {} Transform.call(this, _omit(this.options, ['matcher', 'chomp'])) this.offset = 0 this.options.matcher = (typeof this.options.matcher === 'string' ? this.options.matcher.ch...
javascript
{ "resource": "" }
q42234
lookup
train
function lookup(version, migrations) { var regex = RegExp('^' + version + '.*$'); for (var m in migrations) if (migrations.hasOwnProperty(m) && m.match(regex)) return m; return null; }
javascript
{ "resource": "" }
q42235
relative
train
function relative(path){ var startX = 0 var startY = 0 var x = 0 var y = 0 return path.map(function(seg){ seg = seg.slice() var type = seg[0] var command = type.toLowerCase() // is absolute if (type != command) { seg[0] = command switch (type) { case 'A': se...
javascript
{ "resource": "" }
q42236
postGetTags
train
function postGetTags(id, cb) { var q = 'SELECT * FROM tags t ' + 'JOIN posts_tags pt ON t.id = pt.tag_id AND pt.post_id = $1'; db.getClient(function(err, client, done) { client.query(q, [id], function(err, r) { if(err) { cb(err); done(err); } else { cb(null, r.row...
javascript
{ "resource": "" }
q42237
postSetTags
train
function postSetTags(post_id, tags, cb) { var ids = _.pluck(tags, 'id') , q1 = 'DELETE FROM posts_tags WHERE post_id = $1' , q2 = 'INSERT INTO posts_tags (post_id, tag_id) VALUES ' + ids.map(function(id) { return '(' + post_id + ',' + id + ')'; }).join(', '); db.getClient(function(err, client...
javascript
{ "resource": "" }
q42238
checkMouse
train
function checkMouse( mouse ) { that.debug.groupStart( 'CheckMouse' ); // %REMOVE_LINE% that.debug.startTimer(); // %REMOVE_LINE% that.mouse = mouse; that.trigger = null; checkMouseTimer = null; updateWindowSize( that ); if ( checkMouseTimeoutPending // -> There must be a...
javascript
{ "resource": "" }
q42239
boxTrigger
train
function boxTrigger( triggerSetup ) { this.upper = triggerSetup[ 0 ]; this.lower = triggerSetup[ 1 ]; this.set.apply( this, triggerSetup.slice( 2 ) ); }
javascript
{ "resource": "" }
q42240
getAscendantTrigger
train
function getAscendantTrigger( that ) { var node = that.element, trigger; if ( node && isHtml( node ) ) { trigger = node.getAscendant( that.triggers, true ); // If trigger is an element, neither editable nor editable's ascendant. if ( trigger && that.editable.contains( trigger ) ) { // Che...
javascript
{ "resource": "" }
q42241
train
function() { that.debug.groupStart( 'mouseNear' ); // %REMOVE_LINE% updateSize( that, this ); var offset = that.holdDistance, size = this.size; // Determine neighborhood by element dimensions and offsets. if ( size && inBetween( that.mouse.y, size.top - offset, size.bottom + offset ) ...
javascript
{ "resource": "" }
q42242
isChildBetweenPointerAndEdge
train
function isChildBetweenPointerAndEdge( that, parent, edgeBottom ) { var edgeChild = parent[ edgeBottom ? 'getLast' : 'getFirst' ]( function( node ) { return that.isRelevant( node ) && !node.is( DTD_TABLECONTENT ); } ); if ( !edgeChild ) return false; updateSize( that, edgeChild ); return ed...
javascript
{ "resource": "" }
q42243
expandSelector
train
function expandSelector( that, node ) { return !( isTextNode( node ) || isComment( node ) || isFlowBreaker( node ) || isLine( that, node ) || ( node.type == CKEDITOR.NODE_ELEMENT && node.$ && node.is( 'br' ) ) ); }
javascript
{ "resource": "" }
q42244
expandFilter
train
function expandFilter( that, trigger ) { that.debug.groupStart( 'expandFilter' ); // %REMOVE_LINE% var upper = trigger.upper, lower = trigger.lower; if ( !upper || !lower // NOT: EDGE_MIDDLE trigger ALWAYS has two elements. || isFlowBreaker( lower ) || isFlowBreaker( upper ) // NO...
javascript
{ "resource": "" }
q42245
verticalSearch
train
function verticalSearch( that, stopCondition, selectCriterion, startElement ) { var upper = startElement, lower = startElement, mouseStep = 0, upperFound = false, lowerFound = false, viewPaneHeight = that.view.pane.height, mouse = that.mouse; while ( mouse.y + mouseStep < viewPaneHeight ...
javascript
{ "resource": "" }
q42246
addListener
train
function addListener(event, callback) { checkEventValid(event); if (listeners[event]) { listeners[event].push(callback); } else { listeners[event] = [callback]; } }
javascript
{ "resource": "" }
q42247
removeListener
train
function removeListener(event, eventHandler) { checkEventValid(event); if (listeners[event] && listeners[event].length) { var indexOfListener = listeners[event].indexOf(eventHandler); if (indexOfListener > -1) { listeners[event].splice(indexOfListener, 1); } } }
javascript
{ "resource": "" }
q42248
processSize
train
function processSize(targetSize, origSize) { var match = (targetSize.match(r_percentage) || [])[1]; if (match /= 100) { return { width: origSize.width * match, height: 0 }; } else { return { width: (targetSize.match(r_width) || [])[1] || 0, height: (targetSize.match(r_height) || [])[1] |...
javascript
{ "resource": "" }
q42249
convertSizes
train
function convertSizes(sizes) { var tmp = []; for (var size in sizes) { tmp.push({ size: size, settings: _.extend({suffix: '', prefix: ''}, sizes[size]) }); } return tmp; }
javascript
{ "resource": "" }
q42250
getPhantomExitCb
train
function getPhantomExitCb (specId, allSpecs, cfg, done) { var spawnCb = function (error, result, code) { if (error) { ok = false; if (cfg.debug) { console.log("PhantomJS exited with code " + code); } } var n...
javascript
{ "resource": "" }
q42251
startPhantom
train
function startPhantom (specPath, cfg, cb) { var args = [specPath]; if (cfg.verbose) { args.push("--verbose"); // custom, to be handled by spec runner } if (cfg.debug) { args.push("--debug"); // custom, to be handled by spec runner } if (cfg.color) ...
javascript
{ "resource": "" }
q42252
startSpec
train
function startSpec (n, allSpecs, cfg, done) { var printId = n + 1; var specPath = allSpecs[n]; var nSpecs = allSpecs.length; var msg = "Running spec file " + specPath + " [" + printId + "/" + nSpecs + "]"; var bar = Array(process.stdout.columns).join("*"); console.log("\...
javascript
{ "resource": "" }
q42253
train
function(inSender, e) { // if a scroll event originated here, pass it to our strategy to handle if (this.$.strategy.domScroll && e.originator == this) { this.$.strategy.scroll(inSender, e); } this.doScroll(e); return true; }
javascript
{ "resource": "" }
q42254
train
function() { var fileIndex; if (stop_loop) { return false; } // Check to see if are in queue mode if (opts.queuefiles > 0 && processingQueue.length >= opts.queuefiles) { return pause(opts.queuewait); } else { // Take first thing off work q...
javascript
{ "resource": "" }
q42255
ratio
train
function ratio(options) { const { width, height } = options; if ((width || height) && !(width && height)) { if (width) { options.height = width; } if (height) { options.width = height; } } return options; }
javascript
{ "resource": "" }
q42256
loginRequired
train
function loginRequired(fn) { return function(req, res, next) { if(isLoggedIn(req)) { fn(req, res, next); } else { next(new exceptions.PermissionRequired()); } } }
javascript
{ "resource": "" }
q42257
settingsPercentage
train
function settingsPercentage(projectJshintSettings) { verify.object(projectJshintSettings, 'expected jshint object'); //console.log('looking at jshint settings\n' + // JSON.stringify(projectJshintSettings, null, 2)); var allSettings = getAllSettings(); verify.object(allSettings, 'could not get all jshint se...
javascript
{ "resource": "" }
q42258
train
function() { var ret = Backbone.Collection.prototype.set.apply(this, arguments); this.each(function(model) { // Assign `db` to all models in the collection if (this.db) { model.db = this.db; } // Assign `user` to all models in the collection if (this.user) { model...
javascript
{ "resource": "" }
q42259
writeJSON
train
function writeJSON(filename, obj) { return new Promise(function (resolve, reject) { if (!Object.is(obj)) resolve(new Error('writeJSON requires the second argument to be an object')); _fs2['default'].writeFile(filename, JSON.stringify(obj, null, 2) + '\n', function (err) { if (err) reject(err)...
javascript
{ "resource": "" }
q42260
encode
train
function encode(position_array){ if(!_.isArray(position_array) || position_array.length<=0){ throw new Error('Array of tree positions required'); } var left_position_array = _.map(position_array, function(v){return v;}); var right_position_array = _.map(position_array, function(v){return v;}); // le...
javascript
{ "resource": "" }
q42261
get_parsed_encodings
train
function get_parsed_encodings(data){ return { numerator:data.numerator, denominator:data.denominator, encoding:get_big_division(data.numerator, data.denominator) }; }
javascript
{ "resource": "" }
q42262
calculate_encoding_from_tree_position
train
function calculate_encoding_from_tree_position(position_array){ // if we have only one position then it means we have a root element (i.e. one at the top of the tree) // and this is an easy fraction to calculate (i.e. x / 1) if(position_array.length==1){ return get_parsed_encodings({ // the numera...
javascript
{ "resource": "" }
q42263
builder
train
function builder() { // make the arguments one string var args = stringify.apply(null, arguments); // make the final styles object builder._curStyles.forEach(function (thisStyle) { objectAssign(builder._curStyle, thisStyle); }); loggerInstance._inputsBuffer.push({ arg: args, ...
javascript
{ "resource": "" }
q42264
trimToMaxWidth
train
function trimToMaxWidth (width, text) { var truncated = text.split('\n').map(function (line) { return line.substring(0, width); }); return truncated.join('\n'); }
javascript
{ "resource": "" }
q42265
getContainer
train
function getContainer() { if (container) { return container; } body.insertAdjacentHTML('afterbegin', mustache.render(containerTemplate)); container = document.querySelector('.js-feedback-queue'); return container; }
javascript
{ "resource": "" }
q42266
train
function (store, type, record, addId) { var json; type = this._parseModelOrType(store, type); json = record.serialize({includeId: true}); if (!json.id && addId) { json.id = this.generateId(store, type); } type.eachRelationship(function (key, meta) { var records; if (!meta.async...
javascript
{ "resource": "" }
q42267
train
function (store, type/*, record*/) { var key, counters; key = dasherize(this._parseModelOrType(store, type).typeKey); counters = this.get('_generatedCounterId'); if (!counters[key]) { counters[key] = 1; } return 'fixture-' + key + '-' + (counters[key]++); }
javascript
{ "resource": "" }
q42268
train
function (store, type, id) { id = coerceId(id); return this.fixturesForType(store, type).find(function (record) { return coerceId(record.id) === id; }); }
javascript
{ "resource": "" }
q42269
train
function (response, statusCode, statusText) { var adapter = this, responseFunction, isOk, shouldCopy, isInvalid; statusCode = statusCode || 200; statusText = statusText || HTTP_STATUS_MESSAGES[statusCode]; isOk = Math.round(statusCode / 100) === 2; if (typeof response === 'function') { shouldC...
javascript
{ "resource": "" }
q42270
train
function (store, json) { var handledRecords = [], key, records, handleRecord, Model; handleRecord = function (record) { this.completeJsonForRecord(store, record, Model, json, handledRecords); }; for (key in json) { if (json.hasOwnProperty(key)) { records = json[key]; Model = ...
javascript
{ "resource": "" }
q42271
train
function (store, record, Model, json, handledRecords) { if (handledRecords.indexOf(record) === -1) { handledRecords.push(record); Model.eachRelationship(function (name, meta) { var related, fixtures, relatedTypeKey, ids; if (!meta.async && record[name]) { fixtures = Ember.A(thi...
javascript
{ "resource": "" }
q42272
train
function (store, type, records) { var json = {}; type = this._parseModelOrType(store, type); json[pluralize(type.typeKey)] = records; this._injectFixturesInResponse.apply(this, [store, json].concat(slice.call(arguments, 3))); return this.completeJsonResponse(store, json); }
javascript
{ "resource": "" }
q42273
train
function (errors) { if (typeof errors === 'string' || errors instanceof Error) { errors = {'*': '' + errors}; } else if (errors == null) { errors = {'*': 'Unknown error'}; } return new DS.InvalidError(errors); }
javascript
{ "resource": "" }
q42274
train
function (store, type, fixtureRecord) { var fixture; if (fixtureRecord.id) { type = this._parseModelOrType(store, type); // lookup for a fixture fixture = this.fixtureForId(store, type, fixtureRecord.id); if (fixture) { Ember.merge(fixture, fixtureRecord); this._touchDate...
javascript
{ "resource": "" }
q42275
train
function (store, type, fixtureRecord) { var fixture = fixtureRecord || {}; type = this._parseModelOrType(store, type); if (!fixtureRecord.id) { fixtureRecord.id = this.generateId(store, type); } if (this.fixtureForId(store, type, fixture.id)) { throw new Error('Fixture `' + type.typeKey ...
javascript
{ "resource": "" }
q42276
train
function (store, type, fixtureRecord) { var fixture, fixturesArray; if (fixtureRecord.id) { fixture = this.fixtureForId(store, type, fixtureRecord.id); if (fixture) { fixturesArray = this.fixturesForType(store, type); fixturesArray.splice(fixturesArray.indexOf(fixtureRecord), 1); ...
javascript
{ "resource": "" }
q42277
train
function (store, json) { var i, args = slice.call(arguments, 2), len = args.length, records, typeKey; for (i = 0; i < len; i += 2) { records = args[i + 1]; records = records ? (isArray(records) ? records.slice() : [records]) : []; typeKey = pluralize(this._parseModelOrType(store, args[i]).type...
javascript
{ "resource": "" }
q42278
artery
train
function artery(pw, iv, meds) { if (!iv.artery) iv.artery = new Artery(); plet.props(iv.artery, sprops, meds || iv, true); iv.artery.count = iv.count; iv.artery.data = iv.data; iv.artery.passes = iv.passes; iv.artery.pass = iv.pass; return iv.artery; }
javascript
{ "resource": "" }
q42279
Pulse
train
function Pulse(pw, iv, drip) { var pulse = this; plet.merge(pulse, drip.pulse); pulse.count = drip.cbCount + 1; pulse.event = drip.pulse.event; }
javascript
{ "resource": "" }
q42280
assertlet
train
function assertlet(obj, other, objName, otherName) { plet.props(obj, sprops, other, false, false, objName || '1st', otherName || '2nd'); }
javascript
{ "resource": "" }
q42281
pulselet
train
function pulselet(artery, event, endEvent) { return (new Drip(null, artery, event, endEvent)).pulse; }
javascript
{ "resource": "" }
q42282
emits
train
function emits(pw, iv, i) { for (var ci = i, a; iv[ci] && (ci === i || iv[ci].cbCount < iv[ci].repeat); ci++) iv[ci].emit(pw, iv); }
javascript
{ "resource": "" }
q42283
Drip
train
function Drip(pw, iv, evt, endEvent, emit) { var ieo = typeof evt === 'object', eo = ieo ? evt : null, pulse = { event: ieo ? evt.event : evt }; if (!pulse.event) throw new Error('Event is required'); if (eo && eo.id) pulse.id = eo.id; // IDs are not inherited because iv/pulse IDs are non-transferable t...
javascript
{ "resource": "" }
q42284
inlet
train
function inlet(pw, iv, drip) { var ib = drip ? drip.pulse.inbound : iv.inbound; if (!ib) return true; var tgs = ib.selector && typeof iv.target.querySelectorAll === 'function' ? iv.target.querySelectorAll(ib.selector) : [iv.target]; var ttl = tgs.length; var fn = function inboundListener() { ...
javascript
{ "resource": "" }
q42285
commonErrorHandler
train
function commonErrorHandler(err, req, res, next) { // jshint ignore:line debug(err); // if we got here without an error, it's a 404 case if (!err) { err = new NotFoundError(); } // here we've got an error, it could be a different one than // the one we've constructed, so provide defaults to be safe ...
javascript
{ "resource": "" }
q42286
train
function( newRules, featureName, overrideCustom ) { // Check arguments and constraints. Clear cache. if ( !beforeAddingRule( this, newRules, overrideCustom ) ) return false; var i, ret; if ( typeof newRules == 'string' ) newRules = parseRulesString( newRules ); else if ( newRules instanceof CKE...
javascript
{ "resource": "" }
q42287
train
function( newRules ) { // Check arguments and constraints. Clear cache. // Note: we pass true in the 3rd argument, because disallow() should never // be blocked by custom configuration. if ( !beforeAddingRule( this, newRules, true ) ) return false; if ( typeof newRules == 'string' ) newRules = p...
javascript
{ "resource": "" }
q42288
train
function( feature ) { if ( this.disabled ) return true; if ( !feature ) return true; // Some features may want to register other features. // E.g. a button may return a command bound to it. if ( feature.toFeature ) feature = feature.toFeature( this.editor ); // If default configuration ...
javascript
{ "resource": "" }
q42289
train
function( transformations ) { if ( this.disabled ) return; if ( !transformations ) return; var optimized = this._.transformations, group, i; for ( i = 0; i < transformations.length; ++i ) { group = optimizeTransformationsGroup( transformations[ i ] ); if ( !optimized[ group.name ] ) ...
javascript
{ "resource": "" }
q42290
train
function( test, applyTransformations, strictCheck ) { if ( this.disabled ) return true; // If rules are an array, expand it and return the logical OR value of // the rules. if ( CKEDITOR.tools.isArray( test ) ) { for ( var i = test.length ; i-- ; ) { if ( this.check( test[ i ], applyTransforma...
javascript
{ "resource": "" }
q42291
applyAllowedRule
train
function applyAllowedRule( rule, element, status, skipRequired ) { // This rule doesn't match this element - skip it. if ( rule.match && !rule.match( element ) ) return; // If element doesn't have all required styles/attrs/classes // this rule doesn't match it. if ( !skipRequired && !hasAllRequired( rule,...
javascript
{ "resource": "" }
q42292
applyDisallowedRule
train
function applyDisallowedRule( rule, element, status ) { // This rule doesn't match this element - skip it. if ( rule.match && !rule.match( element ) ) return; // No properties - it's an element only rule so it disallows entire element. // Early return is handled in filterElement. if ( rule.noProperties ) ...
javascript
{ "resource": "" }
q42293
convertStyleToRules
train
function convertStyleToRules( style ) { var styleDef = style.getDefinition(), rules = {}, rule, attrs = styleDef.attributes; rules[ styleDef.element ] = rule = { styles: styleDef.styles, requiredStyles: styleDef.styles && CKEDITOR.tools.objectKeys( styleDef.styles ) }; if ( attrs ) { attrs =...
javascript
{ "resource": "" }
q42294
filterElement
train
function filterElement( that, element, opts ) { var name = element.name, privObj = that._, allowedRules = privObj.allowedRules.elements[ name ], genericAllowedRules = privObj.allowedRules.generic, disallowedRules = privObj.disallowedRules.elements[ name ], genericDisallowedRules = privObj.disallowedRul...
javascript
{ "resource": "" }
q42295
mockElementFromString
train
function mockElementFromString( str ) { var element = parseRulesString( str ).$1, styles = element.styles, classes = element.classes; element.name = element.elements; element.classes = classes = ( classes ? classes.split( /\s*,\s*/ ) : [] ); element.styles = mockHash( styles ); element.attributes = moc...
javascript
{ "resource": "" }
q42296
mockElementFromStyle
train
function mockElementFromStyle( style ) { var styleDef = style.getDefinition(), styles = styleDef.styles, attrs = styleDef.attributes || {}; if ( styles ) { styles = copy( styles ); attrs.style = CKEDITOR.tools.writeCssText( styles, true ); } else { styles = {}; } var el = { name: styleDef....
javascript
{ "resource": "" }
q42297
optimizeRule
train
function optimizeRule( rule ) { var validatorName, requiredProperties, i; for ( validatorName in validators ) rule[ validatorName ] = validatorFunction( rule[ validatorName ] ); var nothingRequired = true; for ( i in validatorsRequired ) { validatorName = validatorsRequired[ i ]; requiredProper...
javascript
{ "resource": "" }
q42298
optimizeRules
train
function optimizeRules( optimizedRules, rules ) { var elementsRules = optimizedRules.elements, genericRules = optimizedRules.generic, i, l, rule, element, priority; for ( i = 0, l = rules.length; i < l; ++i ) { // Shallow copy. Do not modify original rule. rule = copy( rules[ i ] ); priority = rule....
javascript
{ "resource": "" }
q42299
processProtectedElement
train
function processProtectedElement( that, comment, protectedRegexs, filterOpts ) { var source = decodeURIComponent( comment.value.replace( /^\{cke_protected\}/, '' ) ), protectedFrag, toBeRemoved = [], node, i, match; // Protected element's and protected source's comments look exactly the same. // Check i...
javascript
{ "resource": "" }