_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q14300 | determineWMSAbstract | train | function determineWMSAbstract(json, version) {
var ret = '';
if (version == '1.3.0') {
if (json.WMS_Capabilities.Service) {
if (json.WMS_Capabilities.Service[0]) {
if (json.WMS_Capabilities.Service[0].Abstract) {
if (json.WMS_Capabilities.Service[0].Abstract[0]) {
ret = json.WMS_Capabilities.Serv... | javascript | {
"resource": ""
} |
q14301 | Client | train | function Client(host, port, path, service, transport, protocol) {
if (!service.hasOwnProperty('Client')) {
throw new Error('Thrift Service must have a Client');
}
/**
* The host of the thrift server
*
* @type {string}
*/
this.host = host;
/**
* The port of the thrift server
*
* @typ... | javascript | {
"resource": ""
} |
q14302 | createChunk | train | function createChunk(type, data) {
const length = typeof data != 'undefined' ? data.length : 0;
const chunk = Buffer.alloc(4 + 4 + length + 4);
chunk.writeUInt32BE(length, 0); | javascript | {
"resource": ""
} |
q14303 | train | function ( n, buffer, bytes ) {
var s = ( n % k ) * slen
// how many bytes to read/consume from the input buffer [1 to 4]
, rbytes = bytes >>> 0 ? abs( bytes ) % 5 : ibytes
, blen = buffer.length - rbytes
, bruint = null
... | javascript | {
"resource": ""
} | |
q14304 | promiseMiddleware | train | function promiseMiddleware (request, response, middleware) {
return new promiseMiddleware.Promise(function (resolve, reject) {
middleware(request, response, | javascript | {
"resource": ""
} |
q14305 | paddLeft | train | function paddLeft(str, length, what) {
if (length <= str.length) {
return str.substring(0, length);
}
what = what || | javascript | {
"resource": ""
} |
q14306 | paddRight | train | function paddRight(str, length, what) {
if (length <= str.length) {
return str.substring(0, length);
}
what = what | javascript | {
"resource": ""
} |
q14307 | precBase | train | function precBase(base, value, precision) {
const val = value.toString(base);
const floatingPoint = val.indexOf('.');
if (precision === 0 && floatingPoint > -1) {
return val.substring(0, floatingPoint);//Node version > 0.10.*
}
if (floatingPoint === -1) | javascript | {
"resource": ""
} |
q14308 | ParserContent | train | function ParserContent () {
// Parser reference
var self = this
// Current row
var data = []
// Define the parser rules
var eol = ['\n','\r\n']
var sep = options.separator || ','
// Handlers are used instead of events
atok
// Ignore comments
.ignore(true) // On rule match, do not do anything, skip t... | javascript | {
"resource": ""
} |
q14309 | _sessionData | train | function _sessionData(variable, value, parameter) {
if (this.session === undefined) throw Error('req.sessionData() requires sessions');
var values = this.session.sessionData = this.session.sessionData || {};
if (variable && value) {
// Special handling for configuration
if (parameter=='setup') {
d... | javascript | {
"resource": ""
} |
q14310 | train | function (server) {
// Retrieve the configured handler.
if (handler) {
handler = require(require('path').resolve() + '/' + handler);
} else {
console.log('No handler defined for websocket server, not starting websocket.');
return;
}
// Attach websockets server to ... | javascript | {
"resource": ""
} | |
q14311 | transform | train | function transform() {
var stack = [];
var inside = false;
var out = false;
var writable = combiner(split(), through2(function(line, encoding, done) {
line = line.toString();
if(out) {
// Comment with a white space below are ignored
if(line.trim() != '') {
readable.write(p... | javascript | {
"resource": ""
} |
q14312 | TaskClauseFormatter | train | function TaskClauseFormatter(o) {
var params=[];
if (!o.nodefaultparam) {
params.push('p');
}
var expects='',locals=[];//$unused=this';
if (o.expects && o.as) fail("SAI compile: cannot have both EXPECTS and AS in a function declaration");
if (o.expects && o.expe... | javascript | {
"resource": ""
} |
q14313 | handleFieldValidated | train | function handleFieldValidated( isValid, msg ) {
var input = this.getInputElement();
if ( input )
isValid ? input.removeAttribute( 'aria-invalid' ) : input.setAttribute( 'aria-invalid', true );
if ( !isValid ) {
if ( | javascript | {
"resource": ""
} |
q14314 | train | function( func ) {
var contents = me._.contents,
stop = false;
for ( var i in contents ) {
for ( var j in contents[ i ] ) {
| javascript | {
"resource": ""
} | |
q14315 | setupFocus | train | function setupFocus() {
var focusList = me._.focusList;
focusList.sort( function( a, b ) {
// Mimics browser tab order logics;
if ( a.tabIndex != b.tabIndex )
return b.tabIndex - a.tabIndex;
// Sort is not stable in some browsers,
// fall-back the comparator to 'focusIndex';
else... | javascript | {
"resource": ""
} |
q14316 | Focusable | train | function Focusable( dialog, element, index ) {
this.element = element;
this.focusIndex = index;
// TODO: support tabIndex for focusables.
this.tabIndex = 0;
this.isFocusable = function() {
return !element.getAttribute( 'disabled' ) && element.isVisible();
};
this.focus = function() {
dialog... | javascript | {
"resource": ""
} |
q14317 | resizeWithWindow | train | function resizeWithWindow( dialog ) {
var win = CKEDITOR.document.getWindow();
function resizeHandler() { dialog.layout(); }
win.on( 'resize', resizeHandler );
| javascript | {
"resource": ""
} |
q14318 | train | function() {
var element = this._.element.getFirst();
| javascript | {
"resource": ""
} | |
q14319 | train | function() {
var el = this.parts.dialog;
var dialogSize = this.getSize();
var win = CKEDITOR.document.getWindow(),
viewSize = win.getViewPaneSize();
var posX = ( viewSize.width - dialogSize.width ) / 2,
posY = ( viewSize.height - dialogSize.height ) / 2;
// Switch to absolute position... | javascript | {
"resource": ""
} | |
q14320 | train | function( fn ) {
for ( var i in this._.contents ) {
for ( var j in this._.contents[ i ] )
| javascript | {
"resource": ""
} | |
q14321 | train | function() {
if ( !this.parts.dialog.isVisible() )
return;
this.fire( 'hide', {} );
this._.editor.fire( 'dialogHide', this );
// Reset the tab page.
this.selectPage( this._.tabIdList[ 0 ] );
var element = this._.element;
element.setStyle( 'display', 'none' );
this.parts.dialog.set... | javascript | {
"resource": ""
} | |
q14322 | train | function( id ) {
if ( this._.currentTabId == id )
return;
if ( this._.tabs[ id ][ 0 ].hasClass( 'cke_dialog_tab_disabled' ) )
return;
// If event was canceled - do nothing.
if ( this.fire( 'selectPage', { page: id, currentPage: this._.currentTabId } ) === false )
return;
// Hide... | javascript | {
"resource": ""
} | |
q14323 | train | function( id ) {
var tab = this._.tabs[ id ] && this._.tabs[ id ][ 0 ];
if ( !tab || this._.pageCount == 1 || !tab.isVisible() )
return;
// Switch to other tab first when we're hiding the active tab.
else if ( id | javascript | {
"resource": ""
} | |
q14324 | train | function( id ) {
var tab = this._.tabs[ id ] && this._.tabs[ id ][ 0 ];
if ( !tab )
return;
tab.show();
| javascript | {
"resource": ""
} | |
q14325 | train | function( element, index ) {
if ( typeof index == 'undefined' ) {
index = this._.focusList.length;
this._.focusList.push( new Focusable( this, element, index ) );
} else {
this._.focusList.splice( index, 0, new | javascript | {
"resource": ""
} | |
q14326 | train | function( name, dialogDefinition ) {
// Avoid path registration from multiple instances override definition.
if ( !this._.dialogDefinitions[ name ] || | javascript | {
"resource": ""
} | |
q14327 | train | function( array, id, recurse ) {
for ( var i = 0, item;
( item = array[ i ] ); i++ ) {
if ( item.id == id )
return item;
if ( recurse && item[ recurse ] ) {
| javascript | {
"resource": ""
} | |
q14328 | train | function( array, newItem, nextSiblingId, recurse, nullIfNotFound ) {
if ( nextSiblingId ) {
for ( var i = 0, item;
( item = array[ i ] ); i++ ) {
if ( item.id == nextSiblingId ) {
array.splice( i, 0, newItem );
return newItem;
}
if ( recurse && item[ recurse ] ) {
| javascript | {
"resource": ""
} | |
q14329 | train | function( array, id, recurse ) {
for ( var i = 0, item;
( item = array[ i ] ); i++ ) {
if ( item.id == id )
return array.splice( i, 1 );
if ( recurse && item[ recurse ] ) {
| javascript | {
"resource": ""
} | |
q14330 | train | function( dialog, dialogDefinition ) {
// TODO : Check if needed.
this.dialog = dialog;
// Transform the contents entries in contentObjects.
var contents = dialogDefinition.contents;
for ( var i = 0, content;
( content | javascript | {
"resource": ""
} | |
q14331 | contentObject | train | function contentObject( dialog, contentDefinition ) {
this._ = {
dialog: dialog
| javascript | {
"resource": ""
} |
q14332 | train | function( dialog, childObjList, childHtmlList, htmlList, elementDefinition ) {
if ( arguments.length < 4 )
return;
this._ || ( this._ = {} );
var children = this._.children = childObjList,
widths = elementDefinition && elementDefinition.widths || null,
height = elementDefinition && ... | javascript | {
"resource": ""
} | |
q14333 | train | function( dialog, childObjList, childHtmlList, htmlList, elementDefinition ) {
if ( arguments.length < 3 )
return;
this._ || ( this._ = {} );
var children = this._.children = childObjList,
width = elementDefinition && elementDefinition.width || null,
heights = elementDefinition && e... | javascript | {
"resource": ""
} | |
q14334 | train | function( indices ) {
// If no arguments, return a clone of the children array.
if ( arguments.length < 1 )
return this._.children.concat();
// If indices isn't array, make it one.
if ( !indices.splice )
indices = [ indices ];
// Retrieve the child element according to tree position.
... | javascript | {
"resource": ""
} | |
q14335 | train | function( dialogName, callback ) {
var dialog = null, dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ];
if ( CKEDITOR.dialog._.currentTop === null )
showCover( this );
// If the dialogDefinition is already loaded, open it immediately.
if ( typeof dialogDefinitions == 'funct... | javascript | {
"resource": ""
} | |
q14336 | getWidgetsFromXml | train | async function getWidgetsFromXml(target) {
const $ = await parseFile(target)
const widgets = []
let widget
$('node').each((i, elem) => {
const node = $(elem)
widget = new Widget()
widget.text = node.attr('text')
widget.resourceId = node.attr('resource-id')
widget.className = node.attr('clas... | javascript | {
"resource": ""
} |
q14337 | threshold | train | function threshold(element) {
var rects = element.getBoundingClientRect();
var upperThreshold = (threshold._viewport.height - rects.top) / rects.height;
var bottomThreshold = rects.bottom / rects.height;
var leftThreshold = (threshold._viewport.width - rects.left) / rects.width;
var rightThreshold = rects.r... | javascript | {
"resource": ""
} |
q14338 | updateViewport | train | function updateViewport() {
threshold._viewport.height = window.innerHeight;
| javascript | {
"resource": ""
} |
q14339 | all | train | function all(func) {
return function() {
var params = getParams(arguments);
var length = params.length;
for (var i = 0; i < length; i++) {
| javascript | {
"resource": ""
} |
q14340 | compareVersion | train | function compareVersion(version, range) {
var string = (range + '');
var n = +(string.match(/\d+/) || NaN);
var op = string.match(/^[<>]=?|/)[0];
| javascript | {
"resource": ""
} |
q14341 | getParams | train | function getParams(args) {
var params = slice.call(args);
var length = params.length;
if (length === 1 && is.array(params[0])) { | javascript | {
"resource": ""
} |
q14342 | merge | train | function merge (a, b) {
for | javascript | {
"resource": ""
} |
q14343 | CrossStyle | train | function CrossStyle(input) {
var uInput = UFirst(input);
return [
"webkit" + uInput
, "moz" | javascript | {
"resource": ""
} |
q14344 | IMFClass | train | function IMFClass(opts) {
if (!(this instanceof IMFClass)) {
return new IMFClass(opts);
}
opts = opts || {};
this.defaultNamespace = opts.defaultNamespace || '';
this.defaultSeparator = opts.defaultSeparator === undefined ? '.' : opts.defaultSeparator;
this.basePath = opts.basePath || 'locales/';
thi... | javascript | {
"resource": ""
} |
q14345 | users | train | function users() {
var seminarjs = this;
var exports = {};
exports.list = [];
/**
* Add a user
* @param {string} name User name
* @param {Object} attributes List of attributes to be added to the user
*/
exports.add = function (name, attributes) {
if (exports.find(name)) {
return false;
} e... | javascript | {
"resource": ""
} |
q14346 | train | function (parts, indent, prefix) {
var lines = [];
var line = [];
var lineLength = !!prefix ? prefix.length - 1: indent.length - 1;
parts.forEach(function (part) {
if (lineLength + 1 + part.length > textWidth) {
lines.push(indent + line.join(' '));
lin... | javascript | {
"resource": ""
} | |
q14347 | train | function(cfg){
var self = this;
var route_opts;
patsy.scripture.print('[Patsy]'.yellow + ': Here\'s the proxy my King!\n');
var _getHeaders = function(path, local_headers){
var global_headers = {};
if(typeof cfg.proxy.options.headers !== 'undefined' && typeof cfg.proxy.opti... | javascript | {
"resource": ""
} | |
q14348 | put | train | function put(argv, callback) {
if (!argv[2]) {
console.error("url is required");
console.error("Usage : put <url> <data>");
process.exit(-1);
}
if (!argv[3]) {
console.error("data is required");
console.error("Usage : put <url> <data>");
| javascript | {
"resource": ""
} |
q14349 | init | train | function init() {
// Locate config if we dont have one {{{
if (_.isUndefined(appConfig)) {
appConfigLocations.forEach(function(key) {
if (_.has(global, key)) {
appConfig = _.get(global, key);
return false;
}
});
if (_.isUndefined(appConfig)) throw new Error('Cannot find email config in', appConfig... | javascript | {
"resource": ""
} |
q14350 | parseOptions | train | function parseOptions(nopt, optlist){
var params = getParams(optlist);
var parsedOptions = nopt(params.known, params.aliases, process.argv, | javascript | {
"resource": ""
} |
q14351 | resetOptions | train | function resetOptions(grunt, parsedOptions){
for (var i in parsedOptions){ | javascript | {
"resource": ""
} |
q14352 | getParams | train | function getParams(optlist){
var aliases = {};
var known = {};
Object.keys(optlist).forEach(function(key) {
var short = optlist[key].short;
if (short) {
aliases[short] = '--' + key;
| javascript | {
"resource": ""
} |
q14353 | initArrays | train | function initArrays(optlist, parsedOptions){
Object.keys(optlist).forEach(function(key) {
if (optlist[key].type === Array && !(key | javascript | {
"resource": ""
} |
q14354 | train | function (fn) {
/**
* Chain function.
*
* @function
* @memberof! funcs
* @alias funcs.maxTimesChain
* @private
* @param {Number} times - The max times the provided function will be invoked
* @returns {function} The new wrapper function
... | javascript | {
"resource": ""
} | |
q14355 | nonCharactersBoundary | train | function nonCharactersBoundary( node ) {
return !( node.type == CKEDITOR.NODE_ELEMENT | javascript | {
"resource": ""
} |
q14356 | train | function() {
return {
textNode: this.textNode,
offset: this.offset,
character: | javascript | {
"resource": ""
} | |
q14357 | syncFieldsBetweenTabs | train | function syncFieldsBetweenTabs( currentPageId ) {
var sourceIndex, targetIndex, sourceField, targetField;
sourceIndex = currentPageId === 'find' ? 1 : 0;
targetIndex = 1 - sourceIndex;
var i,
l = fieldsMapping.length;
| javascript | {
"resource": ""
} |
q14358 | train | function( range, matchWord ) {
var self = this;
var walker = new CKEDITOR.dom.walker( range );
walker.guard = matchWord ? nonCharactersBoundary : function( node ) {
!nonCharactersBoundary( node ) && ( self._.matchBoundary = true );
};
walker[ 'evaluator' ] = findEvaluator;
wal... | javascript | {
"resource": ""
} | |
q14359 | train | function( characterWalker, rangeLength ) {
this._ = {
walker: characterWalker,
| javascript | {
"resource": ""
} | |
q14360 | train | function( domRange ) {
var cursor,
walker = new characterWalker( domRange );
this._.cursors = [];
do {
cursor = walker.next();
if ( cursor.character | javascript | {
"resource": ""
} | |
q14361 | train | function() {
// Do not apply if nothing is found.
if ( this._.cursors.length < 1 )
return;
// Remove the previous highlight if there's one.
if ( this._.highlightRange )
this.removeHighlight();
// Apply the highlight.
var range = this.toDomRange(),
bookmark = ... | javascript | {
"resource": ""
} | |
q14362 | train | function() {
if ( !this._.highlightRange )
return;
var bookmark = this._.highlightRange.createBookmark();
highlightStyle.removeFromRange( this._.highlightRange, editor );
this._.highlightRange.moveToBookmark( | javascript | {
"resource": ""
} | |
q14363 | getRangeAfterCursor | train | function getRangeAfterCursor( cursor, inclusive ) {
var range = editor.createRange();
range.setStart( cursor.textNode, | javascript | {
"resource": ""
} |
q14364 | getRangeBeforeCursor | train | function getRangeBeforeCursor( cursor ) {
var range = editor.createRange();
range.setStartAt( | javascript | {
"resource": ""
} |
q14365 | train | function( pattern, ignoreCase ) {
var overlap = [ -1 ];
if ( ignoreCase )
pattern = pattern.toLowerCase();
for ( var i = 0; i < pattern.length; i++ ) {
overlap.push( overlap[ i ] + 1 );
while ( overlap[ i + 1 ] > 0 && pattern.charAt( i ) != pattern.charAt( overlap[ i + 1 ] - 1 ) )... | javascript | {
"resource": ""
} | |
q14366 | train | function(query, scope) {
return Array.prototype.slice.call((scope | javascript | {
"resource": ""
} | |
q14367 | ES6ImportsRenamer | train | function ES6ImportsRenamer(config, callback) {
config = config || {};
this._basePath = config.basePath;
this._renameDependencies = config.renameDependencies;
this._renameFn = config.renameFn;
this._callback = | javascript | {
"resource": ""
} |
q14368 | createRequireFunc | train | function createRequireFunc(customResolver) {
return function (requestedPath) {
var resolvedPath = null;
try {
resolvedPath = | javascript | {
"resource": ""
} |
q14369 | runNextRequest | train | function runNextRequest(){
var self = this;
var req = parser.read()
if (req){
var res = new Response(req);
res.assignSocket(socket)
//No matter how the response object gets closed this
//will trigger the | javascript | {
"resource": ""
} |
q14370 | rand16Num | train | function rand16Num(len) {
let result = [];
for (let i = 0; i < len; i++) {
| javascript | {
"resource": ""
} |
q14371 | ClassBuilder | train | function ClassBuilder(InstanceBuilder, Parent, Constructor, props) {
// Last input argument is an object of properties for a new class
props = arguments[arguments.length - 1];
// Second last input argument is a constructor function
Constructor = arguments[arguments.length - 2];
// Set default Parent class if it ... | javascript | {
"resource": ""
} |
q14372 | train | function() {
var block = this.emptyBlock(0);
while ('eos' != this.peek().type) {
if ('newline' == this.peek().type) {
this.advance();
} else if ('text-html' == this.peek().type) {
block.nodes = block.nodes.concat(this.parseTextHtml());
| javascript | {
"resource": ""
} | |
q14373 | train | function() {
var tok = this.expect('filter');
var block,
attrs = [];
if (this.peek().type === 'start-attributes') {
attrs = this.attrs();
}
if (this.peek().type === 'text') {
var textToken = this.advance();
block = this.initBlock(textToken.line, [
{
type: ... | javascript | {
"resource": ""
} | |
q14374 | train | function() {
var tok = this.expect('block');
var node = 'indent' == this.peek().type
? this.block()
: this.emptyBlock(tok.line);
node.type = 'NamedBlock';
| javascript | {
"resource": ""
} | |
q14375 | Stringme | train | function Stringme(val, opt) {
if (val === undefined) {
val = '"undefined"';
} else if (val === null) {
val = '"null"';
} else {
var replace = opt && opt.replace ? opt.replace : null;
var space = opt && opt.space ? opt.space : null;
val = JSON.stringify(val, replace, ... | javascript | {
"resource": ""
} |
q14376 | ucFirst | train | function ucFirst( str ) {
str += '';
var f = str.charAt( 0 | javascript | {
"resource": ""
} |
q14377 | browseServer | train | function browseServer( evt ) {
var dialog = this.getDialog();
var editor = dialog.getParentEditor();
editor._.filebrowserSe = this;
var width = editor.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowWidth' ] || editor.config.filebrowserWindowWidth || '80%';
var height = editor.config[ 'f... | javascript | {
"resource": ""
} |
q14378 | uploadFile | train | function uploadFile( evt ) {
var dialog = this.getDialog();
var editor = dialog.getParentEditor();
editor._.filebrowserSe = this;
// If user didn't select the file, stop the upload.
if ( !dialog.getContentElement( this[ 'for' ][ 0 ], this[ 'for' ][ 1 ] | javascript | {
"resource": ""
} |
q14379 | setupFileElement | train | function setupFileElement( editor, fileInput, filebrowser ) {
var params = filebrowser.params || {};
params.CKEditor = editor.name;
params.CKEditorFuncNum = editor._.filebrowserFn;
if ( !params.langCode )
| javascript | {
"resource": ""
} |
q14380 | attachFileBrowser | train | function attachFileBrowser( editor, dialogName, definition, elements ) {
if ( !elements || !elements.length )
return;
var element, fileInput;
for ( var i = elements.length; i--; ) {
element = elements[ i ];
if ( element.type == 'hbox' || element.type == 'vbox' || element.type == 'fieldset' )
... | javascript | {
"resource": ""
} |
q14381 | isConfigured | train | function isConfigured( definition, tabId, elementId ) {
if ( elementId.indexOf( ";" ) !== -1 ) {
var ids = elementId.split( ";" );
for ( var i = 0; i < ids.length; i++ ) {
if ( isConfigured( definition, tabId, ids[ i ] ) )
return true;
}
return false;
}
| javascript | {
"resource": ""
} |
q14382 | findDirRec | train | function findDirRec(dir, callback) {
var result = path.resolve(dir, dirmod);
fs.stat(result, function stat(err, stat) {
if (err || !stat.isDirectory()) {
if (lastResult == result) {
callback(new Error('No configuration directory found.'));
return;
| javascript | {
"resource": ""
} |
q14383 | train | function(obj) {
_.forEach(obj, function(val, key) {
if (_.isString(val)) {
if (Mixins.isObjectId(val)) {
obj[key] = Mixins.newObjectId(val);
} else if (Mixins.isValidISO8601String(val)) {
| javascript | {
"resource": ""
} | |
q14384 | train | function(obj) {
_.forEach(obj, function(val, key) {
if (val && _.isFunction(val.toHexString)) {
obj[key] = val.toHexString();
} else if (_.isDate(val)) {
obj[key] = val;
} else if (_.isObject(val)) {
if (val['$oid']) {
| javascript | {
"resource": ""
} | |
q14385 | train | function (requestURL, filename, fileType) {
if (gc.coreFunctions.getReqestExtension(filename) == '.ipa'){
// The template of an entry as well as the indicator variable for a file or dir.
// This is used for IPA files that need to be installed on iOS devices so .manifest is appended to search fo... | javascript | {
"resource": ""
} | |
q14386 | Class | train | function Class(superCtor, props){
let cls = function (...args) {
if (!(this instanceof cls)) {
throw new Error('Class constructors cannot be invoked without \'new\'');
}
//extend prototype data to instance
//avoid instance change data to pullte prototype
cls.extend(cls.__props__, this);
... | javascript | {
"resource": ""
} |
q14387 | TypedArray | train | function TypedArray (config) {
const array = this;
// validate min items
if (config.hasOwnProperty('minItems') && (!util.isInteger(config.minItems) || config.minItems < 0)) {
throw Error('Invalid configuration value for property: minItems. Must be an integer that is greater than or equal to zero. R... | javascript | {
"resource": ""
} |
q14388 | registerOptionsObserver | train | function registerOptionsObserver(instance) {
if (!instance._mounted || !instance._options) {
return
}
instance._observer.observe(instance._options, {
childList: true,
attributes: true,
| javascript | {
"resource": ""
} |
q14389 | addEventListeners | train | function addEventListeners(instance) {
if (!instance._mounted || !instance._options) {
return
}
instance._options.addEventListener('change', instance._onSelectionChange)
instance._root.addEventListener('mouseover', instance._onItemHovered)
instance._root.addEventListener('mousedown', | javascript | {
"resource": ""
} |
q14390 | removeEventListeners | train | function removeEventListeners(instance) {
if (instance._options) {
instance._options.removeEventListener('change', instance._onSelectionChange)
}
instance._root.removeEventListener('mouseover', instance._onItemHovered)
instance._root.removeEventListener('mousedown', instance._onItemSelectionStart)... | javascript | {
"resource": ""
} |
q14391 | onItemHovered | train | function onItemHovered(instance, itemUi) {
if (instance._options.disabled || !isEnabledOptionUi(itemUi)) {
return
}
if (instance._options.multiple) {
if (instance._dragSelectionStartOption) {
updateMultiSelection(instance, itemUi)
| javascript | {
"resource": ""
} |
q14392 | onItemClicked | train | function onItemClicked(instance, itemUi) {
if (instance._dragSelectionStartOption) { // multi-select
instance._dragSelectionStartOption = null
return
}
if (instance._options.disabled || !isEnabledOptionUi(itemUi)) {
return
}
| javascript | {
"resource": ""
} |
q14393 | onItemSelectionStart | train | function onItemSelectionStart(instance, itemUi, event) {
if (instance._options.disabled || !instance._options.multiple || !isEnabledOptionUi(itemUi)) {
return
}
const options = instance._options.options
if (event.shiftKey && instance._previousSelectionStartIndex > -1) {
instance._dragSelect... | javascript | {
"resource": ""
} |
q14394 | scrollToSelection | train | function scrollToSelection(instance, selectionStartIndex, selectionEndIndex) {
const lastSelectionIndexes = instance._lastSelectionIndexes
if (
selectionStartIndex !== -1 &&
(selectionStartIndex !== lastSelectionIndexes.start || selectionEndIndex !== lastSelectionIndexes.end)
) {
const cha... | javascript | {
"resource": ""
} |
q14395 | scrollToOption | train | function scrollToOption(instance, optionIndex) {
const ui = instance._root
if (ui.clientHeight >= ui.scrollHeight) {
return
}
const uiBounds = ui.getBoundingClientRect()
const options = instance._root.querySelectorAll('[data-szn-options--option]')
const optionBounds = options[optionIndex]... | javascript | {
"resource": ""
} |
q14396 | updateMultiSelection | train | function updateMultiSelection(instance, lastHoveredItem) {
const startIndex = instance._dragSelectionStartOption.index
const lastIndex = lastHoveredItem._option.index
const minIndex = Math.min(startIndex, lastIndex)
const maxIndex = Math.max(startIndex, lastIndex)
const options = instance._options.o... | javascript | {
"resource": ""
} |
q14397 | updateUi | train | function updateUi(instance) {
if (!instance._options) {
return
}
if (instance._options.disabled) {
instance._root.setAttribute('disabled', '')
} else {
instance._root.removeAttribute('disabled')
}
if (instance._options.multiple) {
instance._root.setAttribute('data-szn-op... | javascript | {
"resource": ""
} |
q14398 | updateGroupUi | train | function updateGroupUi(uiContainer, optionsGroup) {
removeRemovedItems(uiContainer, optionsGroup)
| javascript | {
"resource": ""
} |
q14399 | removeRemovedItems | train | function removeRemovedItems(uiContainer, optionsGroup) {
const options = Array.prototype.slice.call(optionsGroup.children)
let currentItemUi = uiContainer.firstElementChild
while (currentItemUi) {
if (options.indexOf(currentItemUi._option) > -1) {
currentItemUi = currentItemUi.nextElementSibli... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.