_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q26200 | extractPropertiesFromSource | train | function extractPropertiesFromSource(source, offset) {
offset = offset || 0;
source = source.replace(reSpaceEnd, '');
var out = [];
if (!source) {
return out;
}
var tokens = cssParser.parse(source);
var it = tokenIterator.create(tokens);
var property;
while ((property = consumeSingleProperty(it,... | javascript | {
"resource": ""
} |
q26201 | train | function(name, value, pos) {
var list = this.list();
var start = this._positions.contentStart;
var styles = utils.pick(this.options, 'styleBefore', 'styleSeparator');
if (typeof pos === 'undefined') {
pos = list.length;
}
/** @type CSSEditProperty */
var donor = list[pos];
if (donor)... | javascript | {
"resource": ""
} | |
q26202 | train | function(isAbsolute) {
var parts = findParts(this.value());
if (isAbsolute) {
var offset = this.valuePosition(true);
parts.forEach(function(p) {
p.shift(offset);
});
}
return parts;
} | javascript | {
"resource": ""
} | |
q26203 | train | function(val) {
var isUpdating = typeof val !== 'undefined';
var allItems = this.parent.list();
if (isUpdating && this.isIncomplete()) {
var self = this;
var donor = utils.find(allItems, function(item) {
return item !== self && !item.isIncomplete();
});
this.styleSeparator = donor
?... | javascript | {
"resource": ""
} | |
q26204 | train | function(css, pos) {
var cssProp = null;
/** @type EditContainer */
var cssRule = typeof css === 'string' ? this.parseFromPosition(css, pos, true) : css;
if (cssRule) {
cssProp = cssRule.itemFromPosition(pos, true);
if (!cssProp) {
// in case user just started writing CSS property
// and d... | javascript | {
"resource": ""
} | |
q26205 | train | function(range) {
if (this.overlap(range)) {
var start = Math.max(range.start, this.start);
var end = Math.min(range.end, this.end);
return new Range(start, end - start);
}
return null;
} | javascript | {
"resource": ""
} | |
q26206 | train | function(loc, left, right) {
var a, b;
if (loc instanceof Range) {
a = loc.start;
b = loc.end;
} else {
a = b = loc;
}
return cmp(this.start, a, left || '<=') && cmp(this.end, b, right || '>');
} | javascript | {
"resource": ""
} | |
q26207 | train | function(strings) {
var lengths = strings.map(function(s) {
return typeof s === 'string' ? s.length : +s;
});
var max = lengths.reduce(function(prev, cur) {
return typeof prev === 'undefined' ? cur : Math.max(prev, cur);
});
return lengths.map(function(l) {
var pad = max - l;
return p... | javascript | {
"resource": ""
} | |
q26208 | train | function(text, pad) {
var result = [];
var lines = this.splitByLines(text);
var nl = '\n';
result.push(lines[0]);
for (var j = 1; j < lines.length; j++)
result.push(nl + pad + lines[j]);
return result.join('');
} | javascript | {
"resource": ""
} | |
q26209 | train | function(str, pad) {
var padding = '';
var il = str.length;
while (pad > il++) padding += '0';
return padding + str;
} | javascript | {
"resource": ""
} | |
q26210 | train | function(text, pad) {
var lines = this.splitByLines(text);
var pl = pad.length;
for (var i = 0, il = lines.length, line; i < il; i++) {
line = lines[i];
if (line.substr(0, pl) === pad) {
lines[i] = line.substr(pl);
}
}
return lines.join('\n');
} | javascript | {
"resource": ""
} | |
q26211 | train | function(content, ranges, ch, noRepeat) {
if (ranges.length) {
var offset = 0, fragments = [];
ranges.forEach(function(r) {
var repl = noRepeat ? ch : this.repeatString(ch, r[1] - r[0]);
fragments.push(content.substring(offset, r[0]), repl);
offset = r[1];
}, this);
content = fragment... | javascript | {
"resource": ""
} | |
q26212 | train | function(text, start, end) {
var rng = range.create(start, end);
var reSpace = /[\s\n\r\u00a0]/;
// narrow down selection until first non-space character
while (rng.start < rng.end) {
if (!reSpace.test(text.charAt(rng.start)))
break;
rng.start++;
}
while (rng.end > rng.start... | javascript | {
"resource": ""
} | |
q26213 | train | function(node, offset) {
var maxNum = 0;
var options = {
tabstop: function(data) {
var group = parseInt(data.group, 10);
if (group > maxNum) maxNum = group;
if (data.placeholder)
return '${' + (group + offset) + ':' + data.placeholder + '}';
else
return '${' + (group + o... | javascript | {
"resource": ""
} | |
q26214 | train | function(text, node, type) {
var maxNum = 0;
var that = this;
var tsOptions = {
tabstop: function(data) {
var group = parseInt(data.group, 10);
if (group === 0)
return '${0}';
if (group > maxNum) maxNum = group;
if (data.placeholder) {
// respect nested placeholder... | javascript | {
"resource": ""
} | |
q26215 | makeAttributesString | train | function makeAttributesString(node, profile) {
var attrQuote = profile.attributeQuote();
var cursor = profile.cursor();
return node.attributeList().map(function(a) {
var isBoolean = profile.isBoolean(a.name, a.value);
var attrName = profile.attributeName(a.name);
var attrValue = isBoolean ? attrName :... | javascript | {
"resource": ""
} |
q26216 | train | function(str) {
var curOffset = str.length;
var startIndex = -1;
var groupCount = 0;
var braceCount = 0;
var textCount = 0;
while (true) {
curOffset--;
if (curOffset < 0) {
// moved to the beginning of the line
startIndex = 0;
break;
}
var ch = str.charAt(curOff... | javascript | {
"resource": ""
} | |
q26217 | train | function(stream) {
var pngMagicNum = "\211PNG\r\n\032\n",
jpgMagicNum = "\377\330",
gifMagicNum = "GIF8",
pos = 0,
nextByte = function() {
return stream.charCodeAt(pos++);
};
if (stream.substr(0, 8) === pngMagicNum) {
// PNG. Easy peasy.
pos = stream.indexOf('IHDR') + 4;
... | javascript | {
"resource": ""
} | |
q26218 | train | function(editor, pos) {
var allowedSyntaxes = {'html': 1, 'xml': 1, 'xsl': 1, 'jsx': 1};
var syntax = editor.getSyntax();
if (syntax in allowedSyntaxes) {
var content = editor.getContent();
if (typeof pos === 'undefined') {
pos = editor.getCaretPos();
}
var tag = htmlMatcher.find(content,... | javascript | {
"resource": ""
} | |
q26219 | tokener | train | function tokener(value, type) {
session.tokens.push({
value: value,
type: type || value,
start: null,
end: null
});
} | javascript | {
"resource": ""
} |
q26220 | tokenize | train | function tokenize() {
var ch = walker.ch;
if (ch === " " || ch === "\t") {
return white();
}
if (ch === '/') {
return comment();
}
if (ch === '"' || ch === "'") {
return str();
}
if (ch === '(') {
return brace();
}
if (ch === '-' || ch === '.' || isDigit(ch)) { // tricky - char... | javascript | {
"resource": ""
} |
q26221 | train | function (source) {
walker.init(source);
session.tokens = [];
// for empty source, return single space token
if (!source) {
session.tokens.push(this.white());
} else {
while (walker.ch !== '') {
tokenize();
}
}
var tokens = session.tokens;
session.tokens = null;
return toke... | javascript | {
"resource": ""
} | |
q26222 | paragraph | train | function paragraph(lang, wordCount, startWithCommon) {
var data = langs[lang];
if (!data) {
return '';
}
var result = [];
var totalWords = 0;
var words;
wordCount = parseInt(wordCount, 10);
if (startWithCommon && data.common) {
words = data.common.slice(0, wordCount);
if (words.length > ... | javascript | {
"resource": ""
} |
q26223 | train | function(lang, data) {
if (typeof data === 'string') {
data = {
words: data.split(' ').filter(function(item) {
return !!item;
})
};
} else if (Array.isArray(data)) {
data = {words: data};
}
langs[lang] = data;
} | javascript | {
"resource": ""
} | |
q26224 | train | function(path, size, callback) {
var params = this._parseParams(arguments);
this._read(params, function(err, buf) {
params.callback(err, err ? '' : bts(buf));
});
} | javascript | {
"resource": ""
} | |
q26225 | train | function(editor) {
var info = editorUtils.outputInfo(editor);
var caretPos = editor.getCaretPos();
var nl = '\n';
var pad = '\t';
if (~xmlSyntaxes.indexOf(info.syntax)) {
// let's see if we're breaking newly created tag
var tag = htmlMatcher.tag(info.content, caretPos);
if (tag && !tag.in... | javascript | {
"resource": ""
} | |
q26226 | EditContainer | train | function EditContainer(source, options) {
this.options = utils.extend({offset: 0}, options);
/**
* Source code of edited structure. All changes in the structure are
* immediately reflected into this property
*/
this.source = source;
/**
* List of all editable children
* @private
*/
thi... | javascript | {
"resource": ""
} |
q26227 | train | function(value, start, end) {
// create modification range
var r = range.create(start, typeof end === 'undefined' ? 0 : end - start);
var delta = value.length - r.length();
var update = function(obj) {
Object.keys(obj).forEach(function(k) {
if (obj[k] >= r.end) {
obj[k] += delta;
}
... | javascript | {
"resource": ""
} | |
q26228 | train | function(items) {
items.forEach(function(item) {
update(item._positions);
if (item.type == 'container') {
recursiveUpdate(item.list());
}
});
} | javascript | {
"resource": ""
} | |
q26229 | train | function(name, value, pos) {
// this is abstract implementation
var item = new EditElement(name, value);
this._children.push(item);
return item;
} | javascript | {
"resource": ""
} | |
q26230 | train | function(name) {
if (typeof name === 'number') {
return this.list()[name];
}
if (typeof name === 'string') {
return utils.find(this.list(), function(prop) {
return prop.name() === name;
});
}
return name;
} | javascript | {
"resource": ""
} | |
q26231 | train | function(name) {
if (!Array.isArray(name))
name = [name];
// split names and indexes
var names = [], indexes = [];
name.forEach(function(item) {
if (typeof item === 'string') {
names.push(item);
} else if (typeof item === 'number') {
indexes.push(item);
}
});
return t... | javascript | {
"resource": ""
} | |
q26232 | train | function(name) {
var element = this.get(name);
if (element) {
this._updateSource('', element.fullRange());
var ix = this._children.indexOf(element);
if (~ix) {
this._children.splice(ix, 1);
}
}
} | javascript | {
"resource": ""
} | |
q26233 | train | function(name, value, pos) {
var element = this.get(name);
if (element)
return element.value(value);
if (typeof value !== 'undefined') {
// no such element — create it
return this.add(name, value, pos);
}
} | javascript | {
"resource": ""
} | |
q26234 | train | function(val) {
if (typeof val !== 'undefined' && this._name !== (val = String(val))) {
this._updateSource(val, this._positions.name, this._positions.name + this._name.length);
this._name = val;
}
return this._name;
} | javascript | {
"resource": ""
} | |
q26235 | train | function(pos, isAbsolute) {
return utils.find(this.list(), function(elem) {
return elem.range(isAbsolute).inside(pos);
});
} | javascript | {
"resource": ""
} | |
q26236 | train | function(val) {
if (typeof val !== 'undefined' && this._value !== (val = String(val))) {
this.parent._updateSource(val, this.valueRange());
this._value = val;
}
return this._value;
} | javascript | {
"resource": ""
} | |
q26237 | train | function(val) {
if (typeof val !== 'undefined' && this._name !== (val = String(val))) {
this.parent._updateSource(val, this.nameRange());
this._name = val;
}
return this._name;
} | javascript | {
"resource": ""
} | |
q26238 | train | function(colorStop) {
colorStop = normalizeSpace(colorStop);
// find color declaration
// first, try complex color declaration, like rgb(0,0,0)
var color = null;
colorStop = colorStop.replace(/^(\w+\(.+?\))\s*/, function(str, c) {
color = c;
return '';
});
if (!color) {
// try s... | javascript | {
"resource": ""
} | |
q26239 | train | function(colorStops) {
var from = 0;
colorStops.forEach(function(cs, i) {
// make sure that first and last positions are defined
if (!i) {
return cs.position = cs.position || 0;
}
if (i == colorStops.length - 1 && !('position' in cs)) {
cs.position = 1;
}
if ('posit... | javascript | {
"resource": ""
} | |
q26240 | resolveDirection | train | function resolveDirection(dir) {
if (typeof dir == 'number') {
return dir;
}
dir = normalizeSpace(dir).toLowerCase();
if (reDeg.test(dir)) {
return +RegExp.$1;
}
var prefix = /^to\s/.test(dir) ? 'to ' : '';
var left = ~dir.indexOf('left') && 'left';
var right = ~dir.indexOf('right') && 'ri... | javascript | {
"resource": ""
} |
q26241 | stringifyDirection | train | function stringifyDirection(dir, oldStyle) {
var reNewStyle = /^to\s/;
var keys = Object.keys(directions).filter(function(k) {
var hasPrefix = reNewStyle.test(k);
return oldStyle ? !hasPrefix : hasPrefix;
});
for (var i = 0; i < keys.length; i++) {
if (directions[keys[i]] == dir) {
return keys[i];... | javascript | {
"resource": ""
} |
q26242 | train | function(gradient) {
// cut out all redundant data
if (this.isLinearGradient(gradient)) {
gradient = gradient.replace(/^\s*[\-a-z]+\s*\(|\)\s*$/ig, '');
} else {
throw 'Invalid linear gradient definition:\n' + gradient;
}
return new LinearGradient(gradient);
} | javascript | {
"resource": ""
} | |
q26243 | parseAbbreviation | train | function parseAbbreviation(key, value) {
key = utils.trim(key);
var m;
if ((m = reTag.exec(value))) {
return elements.create('element', m[1], m[2], m[4] == '/');
} else {
// assume it's reference to another abbreviation
return elements.create('reference', value);
}
} | javascript | {
"resource": ""
} |
q26244 | train | function(data, type) {
cache = {};
// sections like "snippets" and "abbreviations" could have
// definitions like `"f|fs": "fieldset"` which is the same as distinct
// "f" and "fs" keys both equals to "fieldset".
// We should parse these definitions first
var voc = {};
each(data, function(section,... | javascript | {
"resource": ""
} | |
q26245 | train | function(name, value){
var voc = this.getVocabulary('user') || {};
if (!('variables' in voc))
voc.variables = {};
voc.variables[name] = value;
this.setVocabulary(voc, 'user');
} | javascript | {
"resource": ""
} | |
q26246 | train | function(name) {
if (!name)
return null;
if (!(name in cache)) {
cache[name] = utils.deepMerge({}, systemSettings[name], userSettings[name]);
}
var data = cache[name], subsections = utils.toArray(arguments, 1), key;
while (data && (key = subsections.shift())) {
if (key in data) {
data ... | javascript | {
"resource": ""
} | |
q26247 | train | function(syntax, name, minScore) {
var result = this.fuzzyFindMatches(syntax, name, minScore)[0];
if (result) {
return result.value.parsedValue;
}
} | javascript | {
"resource": ""
} | |
q26248 | train | function(syntax) {
var cacheKey = 'all-' + syntax;
if (!cache[cacheKey]) {
var stack = [], sectionKey = syntax;
var memo = [];
do {
var section = this.getSection(sectionKey);
if (!section)
break;
['snippets', 'abbreviations'].forEach(function(sectionName) {
var stackItem =... | javascript | {
"resource": ""
} | |
q26249 | findAbbreviation | train | function findAbbreviation(editor) {
var r = range(editor.getSelectionRange());
var content = String(editor.getContent());
if (r.length()) {
// abbreviation is selected by user
return r.substring(content);
}
// search for new abbreviation from current caret position
var curLine = editor.getCurrentLi... | javascript | {
"resource": ""
} |
q26250 | train | function(html, caretPos) {
var reTag = /^<\/?\w[\w\:\-]*.*?>/;
// search left to find opening brace
var pos = caretPos;
while (pos > -1) {
if (html.charAt(pos) == '<')
break;
pos--;
}
if (pos != -1) {
var m = reTag.exec(html.substring(pos));
if (m && caretPos > pos && car... | javascript | {
"resource": ""
} | |
q26251 | train | function(editor, syntax, profile) {
// most of this code makes sense for Java/Rhino environment
// because string that comes from Java are not actually JS string
// but Java String object so the have to be explicitly converted
// to native string
profile = profile || editor.getProfileName();
return {... | javascript | {
"resource": ""
} | |
q26252 | getReflectedCSSName | train | function getReflectedCSSName(name) {
name = cssEditTree.baseName(name);
var vendorPrefix = '^(?:\\-\\w+\\-)?', m;
if ((name == 'opacity' || name == 'filter') && prefs.get('css.reflect.oldIEOpacity')) {
return new RegExp(vendorPrefix + '(?:opacity|filter)$');
} else if ((m = name.match(/^border-radius-(top... | javascript | {
"resource": ""
} |
q26253 | findNewEditPoint | train | function findNewEditPoint(editor, inc, offset) {
inc = inc || 1;
offset = offset || 0;
var curPoint = editor.getCaretPos() + offset;
var content = String(editor.getContent());
var maxLen = content.length;
var nextPoint = -1;
var reEmptyLine = /^\s+$/;
function getLine(ix) {
var start = ix;
w... | javascript | {
"resource": ""
} |
q26254 | train | function(editor, syntax, profile) {
var curPos = editor.getCaretPos();
var newPoint = findNewEditPoint(editor, -1);
if (newPoint == curPos)
// we're still in the same point, try searching from the other place
newPoint = findNewEditPoint(editor, -1, -2);
if (newPoint != -1) {
editor.setC... | javascript | {
"resource": ""
} | |
q26255 | train | function(editor, syntax, profile) {
var newPoint = findNewEditPoint(editor, 1);
if (newPoint != -1) {
editor.setCaretPos(newPoint);
return true;
}
return false;
} | javascript | {
"resource": ""
} | |
q26256 | makeAttributesString | train | function makeAttributesString(tag, profile) {
var attrs = '';
var otherAttrs = [];
var attrQuote = profile.attributeQuote();
var cursor = profile.cursor();
tag.attributeList().forEach(function(a) {
var attrName = profile.attributeName(a.name);
switch (attrName.toLowerCase()) {
// use short notati... | javascript | {
"resource": ""
} |
q26257 | updateImageSizeHTML | train | function updateImageSizeHTML(editor) {
var offset = editor.getCaretPos();
// find tag from current caret position
var info = editorUtils.outputInfo(editor);
var xmlElem = xmlEditTree.parseFromPosition(info.content, offset, true);
if (xmlElem && (xmlElem.name() || '').toLowerCase() == 'img') {
getImageSize... | javascript | {
"resource": ""
} |
q26258 | getImageSizeForSource | train | function getImageSizeForSource(editor, src, callback) {
var fileContent;
if (src) {
// check if it is data:url
if (/^data:/.test(src)) {
fileContent = base64.decode( src.replace(/^data\:.+?;.+?,/, '') );
return callback(actionUtils.getImageSize(fileContent));
}
var filePath = editor.getFilePath... | javascript | {
"resource": ""
} |
q26259 | train | function(tree, filters, profileName) {
profileName = profile.get(profileName);
list(filters).forEach(function(filter) {
var name = utils.trim(filter.toLowerCase());
if (name && name in registeredFilters) {
tree = registeredFilters[name](tree, profileName);
}
});
return tree;
} | javascript | {
"resource": ""
} | |
q26260 | train | function(syntax, profileName, additionalFilters) {
profileName = profile.get(profileName);
var filters = list(profileName.filters || resources.findItem(syntax, 'filters') || basicFilters);
if (profileName.extraFilters) {
filters = filters.concat(list(profileName.extraFilters));
}
if (additio... | javascript | {
"resource": ""
} | |
q26261 | train | function(abbr) {
var filters = '';
abbr = abbr.replace(/\|([\w\|\-]+)$/, function(str, p1){
filters = p1;
return '';
});
return [abbr, list(filters)];
} | javascript | {
"resource": ""
} | |
q26262 | train | function(i) {
var key = 'p' + i;
if (!(key in memo)) {
memo[key] = false;
if (text.charAt(i) == '<') {
var substr = text.slice(i);
if ((m = substr.match(reOpenTag))) {
memo[key] = openTag(i, m);
} else if ((m = substr.match(reCloseTag))) {
memo[key] = closeTag(i, m... | javascript | {
"resource": ""
} | |
q26263 | findClosingPair | train | function findClosingPair(open, matcher) {
var stack = [], tag = null;
var text = matcher.text();
for (var pos = open.range.end, len = text.length; pos < len; pos++) {
if (matches(text, pos, '<!--')) {
// skip to end of comment
for (var j = pos; j < len; j++) {
if (matches(text, j, '-->')) {
... | javascript | {
"resource": ""
} |
q26264 | train | function(child, position) {
child = child || new AbbreviationNode();
child.parent = this;
if (typeof position === 'undefined') {
this.children.push(child);
} else {
this.children.splice(position, 0, child);
}
return child;
} | javascript | {
"resource": ""
} | |
q26265 | train | function() {
var node = new AbbreviationNode();
var attrs = ['abbreviation', 'counter', '_name', '_text', 'repeatCount', 'hasImplicitRepeat', 'start', 'end', 'content', 'padding'];
attrs.forEach(function(a) {
node[a] = this[a];
}, this);
// clone attributes
node._attributes = this._attributes.... | javascript | {
"resource": ""
} | |
q26266 | train | function(name, value) {
if (arguments.length == 2) {
if (value === null) {
// remove attribute
var vals = this._attributes.filter(function(attr) {
return attr.name === name;
});
var that = this;
vals.forEach(function(attr) {
var ix = that._attributes.indexOf(attr);
if ... | javascript | {
"resource": ""
} | |
q26267 | train | function(abbr) {
abbr = abbr || '';
var that = this;
// find multiplier
abbr = abbr.replace(/\*(\d+)?$/, function(str, repeatCount) {
that._setRepeat(repeatCount);
return '';
});
this.abbreviation = abbr;
var abbrText = extractText(abbr);
if (abbrText) {
abbr = abbrTe... | javascript | {
"resource": ""
} | |
q26268 | train | function() {
var start = this.start;
var end = this.end;
var content = this.content;
// apply output processors
var node = this;
outputProcessors.forEach(function(fn) {
start = fn(start, node, 'start');
content = fn(content, node, 'content');
end = fn(end, node, 'end');
});
... | javascript | {
"resource": ""
} | |
q26269 | train | function() {
if (!this.children.length)
return null;
var deepestChild = this;
while (deepestChild.children.length) {
deepestChild = deepestChild.children[deepestChild.children.length - 1];
}
return deepestChild;
} | javascript | {
"resource": ""
} | |
q26270 | splitAttributes | train | function splitAttributes(attrSet) {
attrSet = utils.trim(attrSet);
var parts = [];
// split attribute set by spaces
var stream = stringStream(attrSet), ch;
while ((ch = stream.next())) {
if (ch == ' ') {
parts.push(utils.trim(stream.current()));
// skip spaces
while (stream.peek() == ' ') {
... | javascript | {
"resource": ""
} |
q26271 | unquote | train | function unquote(str) {
var ch = str.charAt(0);
if (ch == '"' || ch == "'") {
str = str.substr(1);
var last = str.charAt(str.length - 1);
if (last === ch) {
str = str.substr(0, str.length - 1);
}
}
return str;
} | javascript | {
"resource": ""
} |
q26272 | train | function(abbr, options) {
if (!abbr) return '';
if (typeof options == 'string') {
throw new Error('Deprecated use of `expand` method: `options` must be object');
}
options = options || {};
if (!options.syntax) {
options.syntax = utils.defaultSyntax();
}
var p = profile.get(options.profil... | javascript | {
"resource": ""
} | |
q26273 | findItem | train | function findItem(editor, isBackward, extractFn, rangeFn) {
var content = editorUtils.outputInfo(editor).content;
var contentLength = content.length;
var itemRange, rng;
/** @type Range */
var prevRange = range(-1, 0);
/** @type Range */
var sel = range(editor.getSelectionRange());
var searchPos =... | javascript | {
"resource": ""
} |
q26274 | findNextHTMLItem | train | function findNextHTMLItem(editor) {
var isFirst = true;
return findItem(editor, false, function(content, searchPos){
if (isFirst) {
isFirst = false;
return findOpeningTagFromPosition(content, searchPos);
} else {
return getOpeningTagFromPosition(content, searchPos);
}
}, function(tag, offset,... | javascript | {
"resource": ""
} |
q26275 | findPrevHTMLItem | train | function findPrevHTMLItem(editor) {
return findItem(editor, true, getOpeningTagFromPosition, function (tag, offset, selRange) {
return getRangeForHTMLItem(tag, offset, selRange, true);
});
} | javascript | {
"resource": ""
} |
q26276 | makePossibleRangesHTML | train | function makePossibleRangesHTML(source, tokens, offset) {
offset = offset || 0;
var result = [];
var attrStart = -1, attrName = '', attrValue = '', attrValueRange, tagName;
tokens.forEach(function(tok) {
switch (tok.type) {
case 'tag':
tagName = source.substring(tok.start, tok.end);
if (/^<[\w\... | javascript | {
"resource": ""
} |
q26277 | getRangeForHTMLItem | train | function getRangeForHTMLItem(tag, offset, selRange, isBackward) {
var ranges = makePossibleRangesHTML(tag, xmlParser.parse(tag), offset);
if (isBackward)
ranges.reverse();
// try to find selected range
var curRange = utils.find(ranges, function(r) {
return r.equal(selRange);
});
if (curRange)... | javascript | {
"resource": ""
} |
q26278 | findOpeningTagFromPosition | train | function findOpeningTagFromPosition(html, pos) {
var tag;
while (pos >= 0) {
if ((tag = getOpeningTagFromPosition(html, pos)))
return tag;
pos--;
}
return null;
} | javascript | {
"resource": ""
} |
q26279 | findInnerRanges | train | function findInnerRanges(rule) {
// rule selector
var ranges = [rule.nameRange(true)];
// find nested sections, keep selectors only
var nestedSections = cssSections.nestedSectionsInRule(rule);
nestedSections.forEach(function(section) {
ranges.push(range.create2(section.start, section._selectorEnd));
});... | javascript | {
"resource": ""
} |
q26280 | matchedRangeForCSSProperty | train | function matchedRangeForCSSProperty(rule, selRange, isBackward) {
var ranges = findInnerRanges(rule);
if (isBackward) {
ranges.reverse();
}
// return next to selected range, if possible
var r = utils.find(ranges, function(item) {
return item.equal(selRange);
});
if (r) {
return ranges[ranges.... | javascript | {
"resource": ""
} |
q26281 | train | function(editor, abbr) {
abbr = abbr || editor.prompt("Enter abbreviation");
if (!abbr) {
return false;
}
var content = editor.getContent();
var ctx = actionUtils.captureContext(editor);
var tag = this.getUpdatedTag(abbr, ctx, content);
if (!tag) {
// nothing to update
return false;
... | javascript | {
"resource": ""
} | |
q26282 | train | function(abbr, ctx, content, options) {
if (!ctx) {
// nothing to update
return null;
}
var tree = parser.parse(abbr, options || {});
// for this action some characters in abbreviation has special
// meaning. For example, `.-c2` means “remove `c2` class from
// element” and `.+c3` means “app... | javascript | {
"resource": ""
} | |
q26283 | encodeToBase64 | train | function encodeToBase64(editor, imgPath, pos) {
var editorFile = editor.getFilePath();
var defaultMimeType = 'application/octet-stream';
if (editorFile === null) {
throw "You should save your file before using this action";
}
// locate real image path
file.locateFile(editorFile, imgPath, function(realI... | javascript | {
"resource": ""
} |
q26284 | decodeFromBase64 | train | function decodeFromBase64(editor, filePath, data, pos) {
// ask user to enter path to file
filePath = filePath || String(editor.prompt('Enter path to file (absolute or relative)'));
if (!filePath) {
return false;
}
var editorFile = editor.getFilePath();
file.createPath(editorFile, filePath, function(err... | javascript | {
"resource": ""
} |
q26285 | getCSSRanges | train | function getCSSRanges(content, pos) {
var rule;
if (typeof content === 'string') {
var ruleRange = cssSections.matchEnclosingRule(content, pos);
if (ruleRange) {
rule = cssEditTree.parse(ruleRange.substring(content), {
offset: ruleRange.start
});
}
} else {
// passed parsed CSS rule
ru... | javascript | {
"resource": ""
} |
q26286 | train | function(editor, direction) {
direction = String((direction || 'out').toLowerCase());
var info = editorUtils.outputInfo(editor);
if (actionUtils.isSupportedCSS(info.syntax)) {
return balanceCSS(editor, direction);
}
return balanceHTML(editor, direction);
} | javascript | {
"resource": ""
} | |
q26287 | getGradientPrefixes | train | function getGradientPrefixes(type) {
var prefixes = cssResolver.vendorPrefixes(type);
if (!prefixes) {
// disabled Can I Use, fallback to property list
prefixes = prefs.getArray('css.gradient.prefixes');
}
return prefixes || [];
} | javascript | {
"resource": ""
} |
q26288 | getPropertiesForGradient | train | function getPropertiesForGradient(gradients, property) {
var props = [];
var propertyName = property.name();
var omitDir = prefs.get('css.gradient.omitDefaultDirection');
if (prefs.get('css.gradient.fallback') && ~propertyName.toLowerCase().indexOf('background')) {
props.push({
name: 'background-color... | javascript | {
"resource": ""
} |
q26289 | insertGradientsIntoCSSValue | train | function insertGradientsIntoCSSValue(gradients, value, options) {
// gradients *should* passed in order they actually appear in CSS property
// iterate over it in backward direction to preserve gradient locations
options = options || {};
gradients = utils.clone(gradients);
gradients.reverse().forEach(function... | javascript | {
"resource": ""
} |
q26290 | pasteGradient | train | function pasteGradient(property, gradients) {
var rule = property.parent;
var alignVendor = prefs.get('css.alignVendor');
var omitDir = prefs.get('css.gradient.omitDefaultDirection');
// we may have aligned gradient definitions: find the smallest value
// separator
var sep = property.styleSeparator;
va... | javascript | {
"resource": ""
} |
q26291 | train | function(cssProp) {
var value = cssProp.value();
var gradients = [];
var that = this;
cssProp.valueParts().forEach(function(part) {
var partValue = part.substring(value);
if (linearGradient.isLinearGradient(partValue)) {
var gradient = linearGradient.parse(partValue);
if (gradient) {
... | javascript | {
"resource": ""
} | |
q26292 | train | function(editor, syntax) {
var propertyName = prefs.get('css.gradient.defaultProperty');
var omitDir = prefs.get('css.gradient.omitDefaultDirection');
if (!propertyName) {
return false;
}
// assuming that gradient definition is written on new line,
// do a simplified parsing
var content... | javascript | {
"resource": ""
} | |
q26293 | train | function(fn, options) {
// TODO hack for stable sort, remove after fixing `list()`
var order = this._list.length;
if (options && 'order' in options) {
order = options.order * 10000;
}
this._list.push(utils.extend({}, options, {order: order, fn: fn}));
} | javascript | {
"resource": ""
} | |
q26294 | train | function(fn) {
var item = utils.find(this._list, function(item) {
return item.fn === fn;
});
if (item) {
this._list.splice(this._list.indexOf(item), 1);
}
} | javascript | {
"resource": ""
} | |
q26295 | getFileName | train | function getFileName(path) {
var re = /([\w\.\-]+)$/i;
var m = re.exec(path);
return m ? m[1] : '';
} | javascript | {
"resource": ""
} |
q26296 | train | function(abbr, syntax, profile, contextNode) {
return parser.expand(abbr, {
syntax: syntax,
profile: profile,
contextNode: contextNode
});
} | javascript | {
"resource": ""
} | |
q26297 | train | function(profiles) {
profiles = utils.parseJSON(profiles);
var snippets = {};
Object.keys(profiles).forEach(function(syntax) {
var options = profiles[syntax];
if (!(syntax in snippets)) {
snippets[syntax] = {};
}
snippets[syntax].profile = normalizeProfile(options);
});
this.loadSni... | javascript | {
"resource": ""
} | |
q26298 | train | function(profiles) {
profiles = utils.parseJSON(profiles);
Object.keys(profiles).forEach(function(name) {
profile.create(name, normalizeProfile(profiles[name]));
});
} | javascript | {
"resource": ""
} | |
q26299 | train | function(node) {
return (this.hasTagsInContent(node) && this.isBlock(node))
|| node.children.some(function(child) {
return this.isBlock(child);
}, this);
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.