id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
48,100
alexindigo/batcher
lib/run_function.js
runSync
function runSync(context, func, callback) { var result , requiresContext = isArrowFunction(func) ; try { if (requiresContext) { result = func.call(null, context); } else { result = func.call(context); } } catch (ex) { // pass error as error-first callback callback(ex); return; } // everything went well callback(null, result); }
javascript
function runSync(context, func, callback) { var result , requiresContext = isArrowFunction(func) ; try { if (requiresContext) { result = func.call(null, context); } else { result = func.call(context); } } catch (ex) { // pass error as error-first callback callback(ex); return; } // everything went well callback(null, result); }
[ "function", "runSync", "(", "context", ",", "func", ",", "callback", ")", "{", "var", "result", ",", "requiresContext", "=", "isArrowFunction", "(", "func", ")", ";", "try", "{", "if", "(", "requiresContext", ")", "{", "result", "=", "func", ".", "call", "(", "null", ",", "context", ")", ";", "}", "else", "{", "result", "=", "func", ".", "call", "(", "context", ")", ";", "}", "}", "catch", "(", "ex", ")", "{", "// pass error as error-first callback", "callback", "(", "ex", ")", ";", "return", ";", "}", "// everything went well", "callback", "(", "null", ",", "result", ")", ";", "}" ]
Wraps synchronous function with common interface @param {object} context - context to invoke within @param {function} func - function to execute @param {Function} callback - invoke after function is finished executing @returns {void}
[ "Wraps", "synchronous", "function", "with", "common", "interface" ]
73d9c8c994f915688db0627ea3b4854ead771138
https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/lib/run_function.js#L55-L81
48,101
alexindigo/batcher
lib/run_function.js
runAsync
function runAsync(context, func, callback) { var result , requiresContext = isArrowFunction(func) ; if (requiresContext) { result = func.call(null, context, callback); } else { result = func.call(context, callback); } return result; }
javascript
function runAsync(context, func, callback) { var result , requiresContext = isArrowFunction(func) ; if (requiresContext) { result = func.call(null, context, callback); } else { result = func.call(context, callback); } return result; }
[ "function", "runAsync", "(", "context", ",", "func", ",", "callback", ")", "{", "var", "result", ",", "requiresContext", "=", "isArrowFunction", "(", "func", ")", ";", "if", "(", "requiresContext", ")", "{", "result", "=", "func", ".", "call", "(", "null", ",", "context", ",", "callback", ")", ";", "}", "else", "{", "result", "=", "func", ".", "call", "(", "context", ",", "callback", ")", ";", "}", "return", "result", ";", "}" ]
Wraps asynchronous function with common interface @param {object} context - context to invoke within @param {function} func - function to execute @param {Function} callback - invoke after function is finished executing @returns {void}
[ "Wraps", "asynchronous", "function", "with", "common", "interface" ]
73d9c8c994f915688db0627ea3b4854ead771138
https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/lib/run_function.js#L91-L107
48,102
alexindigo/batcher
lib/run_function.js
async
function async(func) { function wrapper() { var context = this; var args = arguments; process.nextTick(function() { func.apply(context, args); }); } return wrapper; }
javascript
function async(func) { function wrapper() { var context = this; var args = arguments; process.nextTick(function() { func.apply(context, args); }); } return wrapper; }
[ "function", "async", "(", "func", ")", "{", "function", "wrapper", "(", ")", "{", "var", "context", "=", "this", ";", "var", "args", "=", "arguments", ";", "process", ".", "nextTick", "(", "function", "(", ")", "{", "func", ".", "apply", "(", "context", ",", "args", ")", ";", "}", ")", ";", "}", "return", "wrapper", ";", "}" ]
Makes sure provided function invoked in real async way @param {function} func - function to invoke wrap @returns {function} - async-supplemented callback function
[ "Makes", "sure", "provided", "function", "invoked", "in", "real", "async", "way" ]
73d9c8c994f915688db0627ea3b4854ead771138
https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/lib/run_function.js#L115-L128
48,103
noflo/noflo-seriously
vendor/seriously.js
traceSources
function traceSources(node, original) { var i, source, sources; if (!(node instanceof EffectNode) && !(node instanceof TransformNode)) { return false; } sources = node.sources; for (i in sources) { if (sources.hasOwnProperty(i)) { source = sources[i]; if (source === original || traceSources(source, original)) { return true; } } } return false; }
javascript
function traceSources(node, original) { var i, source, sources; if (!(node instanceof EffectNode) && !(node instanceof TransformNode)) { return false; } sources = node.sources; for (i in sources) { if (sources.hasOwnProperty(i)) { source = sources[i]; if (source === original || traceSources(source, original)) { return true; } } } return false; }
[ "function", "traceSources", "(", "node", ",", "original", ")", "{", "var", "i", ",", "source", ",", "sources", ";", "if", "(", "!", "(", "node", "instanceof", "EffectNode", ")", "&&", "!", "(", "node", "instanceof", "TransformNode", ")", ")", "{", "return", "false", ";", "}", "sources", "=", "node", ".", "sources", ";", "for", "(", "i", "in", "sources", ")", "{", "if", "(", "sources", ".", "hasOwnProperty", "(", "i", ")", ")", "{", "source", "=", "sources", "[", "i", "]", ";", "if", "(", "source", "===", "original", "||", "traceSources", "(", "source", ",", "original", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
trace back all sources to make sure we're not making a cyclical connection
[ "trace", "back", "all", "sources", "to", "make", "sure", "we", "re", "not", "making", "a", "cyclical", "connection" ]
51ce8ab5237a144bb433c8118db2371886135ff1
https://github.com/noflo/noflo-seriously/blob/51ce8ab5237a144bb433c8118db2371886135ff1/vendor/seriously.js#L1178-L1200
48,104
noflo/noflo-seriously
vendor/seriously.js
makePolygonsArray
function makePolygonsArray(poly) { if (!poly || !poly.length || !Array.isArray(poly)) { return []; } if (!Array.isArray(poly[0])) { return [poly]; } if (Array.isArray(poly[0]) && !isNaN(poly[0][0])) { return [poly]; } return poly; }
javascript
function makePolygonsArray(poly) { if (!poly || !poly.length || !Array.isArray(poly)) { return []; } if (!Array.isArray(poly[0])) { return [poly]; } if (Array.isArray(poly[0]) && !isNaN(poly[0][0])) { return [poly]; } return poly; }
[ "function", "makePolygonsArray", "(", "poly", ")", "{", "if", "(", "!", "poly", "||", "!", "poly", ".", "length", "||", "!", "Array", ".", "isArray", "(", "poly", ")", ")", "{", "return", "[", "]", ";", "}", "if", "(", "!", "Array", ".", "isArray", "(", "poly", "[", "0", "]", ")", ")", "{", "return", "[", "poly", "]", ";", "}", "if", "(", "Array", ".", "isArray", "(", "poly", "[", "0", "]", ")", "&&", "!", "isNaN", "(", "poly", "[", "0", "]", "[", "0", "]", ")", ")", "{", "return", "[", "poly", "]", ";", "}", "return", "poly", ";", "}" ]
detect whether it's multiple polygons or what
[ "detect", "whether", "it", "s", "multiple", "polygons", "or", "what" ]
51ce8ab5237a144bb433c8118db2371886135ff1
https://github.com/noflo/noflo-seriously/blob/51ce8ab5237a144bb433c8118db2371886135ff1/vendor/seriously.js#L1918-L1932
48,105
mikesamuel/module-keys
lib/relpath.js
longestCommonPathPrefix
function longestCommonPathPrefix(stra, strb) { const minlen = min(stra.length, strb.length); let common = 0; let lastSep = -1; for (; common < minlen; ++common) { const chr = stra[common]; if (chr !== strb[common]) { break; } if (chr === sep) { lastSep = common; } } if (common === minlen && (stra.length === minlen ? strb.length === minlen || strb[minlen] === sep : stra[minlen] === sep)) { return minlen + 1; } return lastSep + 1; }
javascript
function longestCommonPathPrefix(stra, strb) { const minlen = min(stra.length, strb.length); let common = 0; let lastSep = -1; for (; common < minlen; ++common) { const chr = stra[common]; if (chr !== strb[common]) { break; } if (chr === sep) { lastSep = common; } } if (common === minlen && (stra.length === minlen ? strb.length === minlen || strb[minlen] === sep : stra[minlen] === sep)) { return minlen + 1; } return lastSep + 1; }
[ "function", "longestCommonPathPrefix", "(", "stra", ",", "strb", ")", "{", "const", "minlen", "=", "min", "(", "stra", ".", "length", ",", "strb", ".", "length", ")", ";", "let", "common", "=", "0", ";", "let", "lastSep", "=", "-", "1", ";", "for", "(", ";", "common", "<", "minlen", ";", "++", "common", ")", "{", "const", "chr", "=", "stra", "[", "common", "]", ";", "if", "(", "chr", "!==", "strb", "[", "common", "]", ")", "{", "break", ";", "}", "if", "(", "chr", "===", "sep", ")", "{", "lastSep", "=", "common", ";", "}", "}", "if", "(", "common", "===", "minlen", "&&", "(", "stra", ".", "length", "===", "minlen", "?", "strb", ".", "length", "===", "minlen", "||", "strb", "[", "minlen", "]", "===", "sep", ":", "stra", "[", "minlen", "]", "===", "sep", ")", ")", "{", "return", "minlen", "+", "1", ";", "}", "return", "lastSep", "+", "1", ";", "}" ]
Longest common prefix that ends on a path element boundary. Each input is assumed to end with an implicit path separator.
[ "Longest", "common", "prefix", "that", "ends", "on", "a", "path", "element", "boundary", ".", "Each", "input", "is", "assumed", "to", "end", "with", "an", "implicit", "path", "separator", "." ]
39100b07d143af3f77a0bec519a92634d5173dd6
https://github.com/mikesamuel/module-keys/blob/39100b07d143af3f77a0bec519a92634d5173dd6/lib/relpath.js#L94-L114
48,106
mikesamuel/module-keys
lib/relpath.js
relpath
function relpath(basePath, absPath) { let base = dedot(basePath); let abs = dedot(absPath); // Find the longest common prefix that ends with a separator. const commonPrefix = longestCommonPathPrefix(base, abs); // Remove the common path elements. base = apply(substring, base, [ commonPrefix ]); abs = apply(substring, abs, [ commonPrefix ]); // For each path element in base, output "/..". let rel = '.'; if (base) { rel = '..'; for (let i = 0; (i = apply(indexOf, base, [ sep, i ])) >= 0; ++i) { rel = `${ rel }/..`; } } // Append abs. if (abs) { rel += sep + abs; } return rel; }
javascript
function relpath(basePath, absPath) { let base = dedot(basePath); let abs = dedot(absPath); // Find the longest common prefix that ends with a separator. const commonPrefix = longestCommonPathPrefix(base, abs); // Remove the common path elements. base = apply(substring, base, [ commonPrefix ]); abs = apply(substring, abs, [ commonPrefix ]); // For each path element in base, output "/..". let rel = '.'; if (base) { rel = '..'; for (let i = 0; (i = apply(indexOf, base, [ sep, i ])) >= 0; ++i) { rel = `${ rel }/..`; } } // Append abs. if (abs) { rel += sep + abs; } return rel; }
[ "function", "relpath", "(", "basePath", ",", "absPath", ")", "{", "let", "base", "=", "dedot", "(", "basePath", ")", ";", "let", "abs", "=", "dedot", "(", "absPath", ")", ";", "// Find the longest common prefix that ends with a separator.", "const", "commonPrefix", "=", "longestCommonPathPrefix", "(", "base", ",", "abs", ")", ";", "// Remove the common path elements.", "base", "=", "apply", "(", "substring", ",", "base", ",", "[", "commonPrefix", "]", ")", ";", "abs", "=", "apply", "(", "substring", ",", "abs", ",", "[", "commonPrefix", "]", ")", ";", "// For each path element in base, output \"/..\".", "let", "rel", "=", "'.'", ";", "if", "(", "base", ")", "{", "rel", "=", "'..'", ";", "for", "(", "let", "i", "=", "0", ";", "(", "i", "=", "apply", "(", "indexOf", ",", "base", ",", "[", "sep", ",", "i", "]", ")", ")", ">=", "0", ";", "++", "i", ")", "{", "rel", "=", "`", "${", "rel", "}", "`", ";", "}", "}", "// Append abs.", "if", "(", "abs", ")", "{", "rel", "+=", "sep", "+", "abs", ";", "}", "return", "rel", ";", "}" ]
A path to absFile relative to base. This is a string transform so is independent of the symlink and hardlink structure of the file-system. @param {string} base an absolute path @param {string} absPath an absolute path @return {string} a relative path that starts with '.' such that {@code path.join(base, output) === absPath} modulo dot path segments in absPath.
[ "A", "path", "to", "absFile", "relative", "to", "base", ".", "This", "is", "a", "string", "transform", "so", "is", "independent", "of", "the", "symlink", "and", "hardlink", "structure", "of", "the", "file", "-", "system", "." ]
39100b07d143af3f77a0bec519a92634d5173dd6
https://github.com/mikesamuel/module-keys/blob/39100b07d143af3f77a0bec519a92634d5173dd6/lib/relpath.js#L127-L148
48,107
nicktindall/cyclon.p2p-rtc-client
lib/SocketFactory.js
createOptionsForServerSpec
function createOptionsForServerSpec(serverSpec) { var options = { forceNew: true, // Make a new connection each time reconnection: false // Don't try and reconnect automatically }; // If the server spec contains a socketResource setting we use // that otherwise leave the default ('/socket.io/') if(serverSpec.socket.socketResource) { options.resource = serverSpec.socket.socketResource; } return options; }
javascript
function createOptionsForServerSpec(serverSpec) { var options = { forceNew: true, // Make a new connection each time reconnection: false // Don't try and reconnect automatically }; // If the server spec contains a socketResource setting we use // that otherwise leave the default ('/socket.io/') if(serverSpec.socket.socketResource) { options.resource = serverSpec.socket.socketResource; } return options; }
[ "function", "createOptionsForServerSpec", "(", "serverSpec", ")", "{", "var", "options", "=", "{", "forceNew", ":", "true", ",", "// Make a new connection each time", "reconnection", ":", "false", "// Don't try and reconnect automatically", "}", ";", "// If the server spec contains a socketResource setting we use", "// that otherwise leave the default ('/socket.io/')", "if", "(", "serverSpec", ".", "socket", ".", "socketResource", ")", "{", "options", ".", "resource", "=", "serverSpec", ".", "socket", ".", "socketResource", ";", "}", "return", "options", ";", "}" ]
Create the socket.io options for the specified server
[ "Create", "the", "socket", ".", "io", "options", "for", "the", "specified", "server" ]
eb586ce288a6ad7e1b221280825037e855b03904
https://github.com/nicktindall/cyclon.p2p-rtc-client/blob/eb586ce288a6ad7e1b221280825037e855b03904/lib/SocketFactory.js#L20-L32
48,108
reelyactive/chickadee
lib/chickadee.js
Chickadee
function Chickadee(options) { var self = this; options = options || {}; self.associations = options.associationManager || new associationManager(options); self.routes = { "/associations": require('./routes/associations'), "/contextat": require('./routes/contextat'), "/contextnear": require('./routes/contextnear'), "/": express.static(path.resolve(__dirname + '/../web')) }; console.log("reelyActive Chickadee instance is curious to associate metadata in an open IoT"); }
javascript
function Chickadee(options) { var self = this; options = options || {}; self.associations = options.associationManager || new associationManager(options); self.routes = { "/associations": require('./routes/associations'), "/contextat": require('./routes/contextat'), "/contextnear": require('./routes/contextnear'), "/": express.static(path.resolve(__dirname + '/../web')) }; console.log("reelyActive Chickadee instance is curious to associate metadata in an open IoT"); }
[ "function", "Chickadee", "(", "options", ")", "{", "var", "self", "=", "this", ";", "options", "=", "options", "||", "{", "}", ";", "self", ".", "associations", "=", "options", ".", "associationManager", "||", "new", "associationManager", "(", "options", ")", ";", "self", ".", "routes", "=", "{", "\"/associations\"", ":", "require", "(", "'./routes/associations'", ")", ",", "\"/contextat\"", ":", "require", "(", "'./routes/contextat'", ")", ",", "\"/contextnear\"", ":", "require", "(", "'./routes/contextnear'", ")", ",", "\"/\"", ":", "express", ".", "static", "(", "path", ".", "resolve", "(", "__dirname", "+", "'/../web'", ")", ")", "}", ";", "console", ".", "log", "(", "\"reelyActive Chickadee instance is curious to associate metadata in an open IoT\"", ")", ";", "}" ]
Chickadee Class Hyperlocal context associations store and API. @param {Object} options The options as a JSON object. @constructor
[ "Chickadee", "Class", "Hyperlocal", "context", "associations", "store", "and", "API", "." ]
1f65c2d369694d93796aae63318fa76326275120
https://github.com/reelyactive/chickadee/blob/1f65c2d369694d93796aae63318fa76326275120/lib/chickadee.js#L20-L35
48,109
reelyactive/chickadee
lib/chickadee.js
convertOptionsParamsToIds
function convertOptionsParamsToIds(req, instance, options, callback) { var err; if(options.id) { var isValidID = reelib.identifier.isValid(options.id); if(!isValidID) { err = 'Invalid id'; } options.ids = [options.id]; delete options.id; callback(err); } else if(options.directory) { instance.associations.retrieveIdsByParams(req, options.directory, null, function(ids) { options.ids = ids; delete options.directory; callback(err); }); } else if(options.tags) { instance.associations.retrieveIdsByParams(req, null, options.tags, function(ids) { options.ids = ids; delete options.tags; callback(err); }); } }
javascript
function convertOptionsParamsToIds(req, instance, options, callback) { var err; if(options.id) { var isValidID = reelib.identifier.isValid(options.id); if(!isValidID) { err = 'Invalid id'; } options.ids = [options.id]; delete options.id; callback(err); } else if(options.directory) { instance.associations.retrieveIdsByParams(req, options.directory, null, function(ids) { options.ids = ids; delete options.directory; callback(err); }); } else if(options.tags) { instance.associations.retrieveIdsByParams(req, null, options.tags, function(ids) { options.ids = ids; delete options.tags; callback(err); }); } }
[ "function", "convertOptionsParamsToIds", "(", "req", ",", "instance", ",", "options", ",", "callback", ")", "{", "var", "err", ";", "if", "(", "options", ".", "id", ")", "{", "var", "isValidID", "=", "reelib", ".", "identifier", ".", "isValid", "(", "options", ".", "id", ")", ";", "if", "(", "!", "isValidID", ")", "{", "err", "=", "'Invalid id'", ";", "}", "options", ".", "ids", "=", "[", "options", ".", "id", "]", ";", "delete", "options", ".", "id", ";", "callback", "(", "err", ")", ";", "}", "else", "if", "(", "options", ".", "directory", ")", "{", "instance", ".", "associations", ".", "retrieveIdsByParams", "(", "req", ",", "options", ".", "directory", ",", "null", ",", "function", "(", "ids", ")", "{", "options", ".", "ids", "=", "ids", ";", "delete", "options", ".", "directory", ";", "callback", "(", "err", ")", ";", "}", ")", ";", "}", "else", "if", "(", "options", ".", "tags", ")", "{", "instance", ".", "associations", ".", "retrieveIdsByParams", "(", "req", ",", "null", ",", "options", ".", "tags", ",", "function", "(", "ids", ")", "{", "options", ".", "ids", "=", "ids", ";", "delete", "options", ".", "tags", ";", "callback", "(", "err", ")", ";", "}", ")", ";", "}", "}" ]
Convert the id, directory or tags within options to ids. @param {Object} req The request which originated this function call. @param {Chickadee} instance The given chickadee instance. @param {Object} options The given options. @param {callback} callback Function to call on completion.
[ "Convert", "the", "id", "directory", "or", "tags", "within", "options", "to", "ids", "." ]
1f65c2d369694d93796aae63318fa76326275120
https://github.com/reelyactive/chickadee/blob/1f65c2d369694d93796aae63318fa76326275120/lib/chickadee.js#L274-L302
48,110
zbjornson/gcloud-trace
src/trace.js
hex
function hex(n) { return crypto.randomBytes(Math.ceil(n / 2)).toString('hex').slice(0, n); }
javascript
function hex(n) { return crypto.randomBytes(Math.ceil(n / 2)).toString('hex').slice(0, n); }
[ "function", "hex", "(", "n", ")", "{", "return", "crypto", ".", "randomBytes", "(", "Math", ".", "ceil", "(", "n", "/", "2", ")", ")", ".", "toString", "(", "'hex'", ")", ".", "slice", "(", "0", ",", "n", ")", ";", "}" ]
Generates a random hex string of the provided length.
[ "Generates", "a", "random", "hex", "string", "of", "the", "provided", "length", "." ]
aa1224316d4f675a59552ae4eb50a9bd69200ba4
https://github.com/zbjornson/gcloud-trace/blob/aa1224316d4f675a59552ae4eb50a9bd69200ba4/src/trace.js#L62-L64
48,111
gallactic/gallactickeys
lib/gallactickeys.js
exportKs
function exportKs (password, privateKey, salt, iv, type, option = {}) { if (!password || !privateKey || !type) { throw new Error('Missing parameter! Make sure password, privateKey and type provided') } if (!crypto.isPrivateKey(privateKey)) { throw new Error('given Private Key is not a valid Private Key string'); } salt = salt || util.bytesToHexUpperString(crypto.generateSalt()); iv = iv || util.bytesToHexUpperString(crypto.generateIv()) return crypto.marshal( crypto.deriveKey(password, salt, option), privateKey, util.strToBuffer(salt), util.strToBuffer(iv), type, option ); }
javascript
function exportKs (password, privateKey, salt, iv, type, option = {}) { if (!password || !privateKey || !type) { throw new Error('Missing parameter! Make sure password, privateKey and type provided') } if (!crypto.isPrivateKey(privateKey)) { throw new Error('given Private Key is not a valid Private Key string'); } salt = salt || util.bytesToHexUpperString(crypto.generateSalt()); iv = iv || util.bytesToHexUpperString(crypto.generateIv()) return crypto.marshal( crypto.deriveKey(password, salt, option), privateKey, util.strToBuffer(salt), util.strToBuffer(iv), type, option ); }
[ "function", "exportKs", "(", "password", ",", "privateKey", ",", "salt", ",", "iv", ",", "type", ",", "option", "=", "{", "}", ")", "{", "if", "(", "!", "password", "||", "!", "privateKey", "||", "!", "type", ")", "{", "throw", "new", "Error", "(", "'Missing parameter! Make sure password, privateKey and type provided'", ")", "}", "if", "(", "!", "crypto", ".", "isPrivateKey", "(", "privateKey", ")", ")", "{", "throw", "new", "Error", "(", "'given Private Key is not a valid Private Key string'", ")", ";", "}", "salt", "=", "salt", "||", "util", ".", "bytesToHexUpperString", "(", "crypto", ".", "generateSalt", "(", ")", ")", ";", "iv", "=", "iv", "||", "util", ".", "bytesToHexUpperString", "(", "crypto", ".", "generateIv", "(", ")", ")", "return", "crypto", ".", "marshal", "(", "crypto", ".", "deriveKey", "(", "password", ",", "salt", ",", "option", ")", ",", "privateKey", ",", "util", ".", "strToBuffer", "(", "salt", ")", ",", "util", ".", "strToBuffer", "(", "iv", ")", ",", "type", ",", "option", ")", ";", "}" ]
PRIVATE METHODS helper function to export keystore
[ "PRIVATE", "METHODS", "helper", "function", "to", "export", "keystore" ]
51a61ca29583e17b5f3325a3d73f1d7e09e4b758
https://github.com/gallactic/gallactickeys/blob/51a61ca29583e17b5f3325a3d73f1d7e09e4b758/lib/gallactickeys.js#L148-L164
48,112
gallactic/gallactickeys
lib/gallactickeys.js
verifyAndDecrypt
function verifyAndDecrypt(derivedKey, iv, ciphertext, algo, mac) { if (typeof algo !== 'string') { throw new Error('Cipher method is invalid. Unable to proceed') } var key; if (crypto.createMac(derivedKey, ciphertext) !== mac) { throw new Error('message authentication code mismatch'); } key = derivedKey.slice(0, 16); return crypto.bs58Encode(util.bytesToHexUpperString(crypto.decrypt(ciphertext, key, iv, algo)), 3); }
javascript
function verifyAndDecrypt(derivedKey, iv, ciphertext, algo, mac) { if (typeof algo !== 'string') { throw new Error('Cipher method is invalid. Unable to proceed') } var key; if (crypto.createMac(derivedKey, ciphertext) !== mac) { throw new Error('message authentication code mismatch'); } key = derivedKey.slice(0, 16); return crypto.bs58Encode(util.bytesToHexUpperString(crypto.decrypt(ciphertext, key, iv, algo)), 3); }
[ "function", "verifyAndDecrypt", "(", "derivedKey", ",", "iv", ",", "ciphertext", ",", "algo", ",", "mac", ")", "{", "if", "(", "typeof", "algo", "!==", "'string'", ")", "{", "throw", "new", "Error", "(", "'Cipher method is invalid. Unable to proceed'", ")", "}", "var", "key", ";", "if", "(", "crypto", ".", "createMac", "(", "derivedKey", ",", "ciphertext", ")", "!==", "mac", ")", "{", "throw", "new", "Error", "(", "'message authentication code mismatch'", ")", ";", "}", "key", "=", "derivedKey", ".", "slice", "(", "0", ",", "16", ")", ";", "return", "crypto", ".", "bs58Encode", "(", "util", ".", "bytesToHexUpperString", "(", "crypto", ".", "decrypt", "(", "ciphertext", ",", "key", ",", "iv", ",", "algo", ")", ")", ",", "3", ")", ";", "}" ]
verify that message authentication codes match, then decrypt
[ "verify", "that", "message", "authentication", "codes", "match", "then", "decrypt" ]
51a61ca29583e17b5f3325a3d73f1d7e09e4b758
https://github.com/gallactic/gallactickeys/blob/51a61ca29583e17b5f3325a3d73f1d7e09e4b758/lib/gallactickeys.js#L167-L179
48,113
oliversalzburg/absync
gulpfile.js
buildJs
function buildJs() { // Construct a stream for the JS sources of our plugin, don't read file contents when compiling TypeScript. var sourceStream = gulp.src( config.Sources.Scripts, { cwd : config.WorkingDirectory, read : true } ); return sourceStream .pipe( jscs() ) .pipe( jscs.reporter() ) .pipe( jsValidate() ) .pipe( order() ) // Only pass through files that have changed since the last build iteration (relevant during "watch"). .pipe( cached( path.join( config.Output.Production, config.Output.DirectoryNames.Scripts ) ) ) // Generate sourcemaps .pipe( sourcemaps.init() ) .pipe( wrapper( { header : "(function() {\n\"use strict\";\n", footer : "}());" } ) ) .pipe( jsValidate() ) .pipe( jshint() ) .pipe( jshint.reporter( stylish ) ) // Put Angular dependency injection annotation where needed. .pipe( ngAnnotate() ) // Pull out files which haven't changed since our last build iteration and put them back into the stream. .pipe( remember() ) // Place the results in the development output directory. .pipe( gulp.dest( path.join( config.Output.Development, config.Output.DirectoryNames.Scripts ) ) ) // Concatenate all files into a single one. .pipe( concat( slug( application.name ) + ".concat.js", { newLine : ";" } ) ) // Put that file into the development output as well. .pipe( gulp.dest( path.join( config.Output.Development, config.Output.DirectoryNames.Scripts ) ) ) // Minify the file. .pipe( uglify() ) // Rename it to indicate minification. .pipe( rename( { extname : ".min.js" } ) ) // Write out sourcemaps .pipe( sourcemaps.write( "maps" ) ) // Write the file to the production output directory. .pipe( gulp.dest( path.join( config.Output.Production, config.Output.DirectoryNames.Scripts ) ) ); }
javascript
function buildJs() { // Construct a stream for the JS sources of our plugin, don't read file contents when compiling TypeScript. var sourceStream = gulp.src( config.Sources.Scripts, { cwd : config.WorkingDirectory, read : true } ); return sourceStream .pipe( jscs() ) .pipe( jscs.reporter() ) .pipe( jsValidate() ) .pipe( order() ) // Only pass through files that have changed since the last build iteration (relevant during "watch"). .pipe( cached( path.join( config.Output.Production, config.Output.DirectoryNames.Scripts ) ) ) // Generate sourcemaps .pipe( sourcemaps.init() ) .pipe( wrapper( { header : "(function() {\n\"use strict\";\n", footer : "}());" } ) ) .pipe( jsValidate() ) .pipe( jshint() ) .pipe( jshint.reporter( stylish ) ) // Put Angular dependency injection annotation where needed. .pipe( ngAnnotate() ) // Pull out files which haven't changed since our last build iteration and put them back into the stream. .pipe( remember() ) // Place the results in the development output directory. .pipe( gulp.dest( path.join( config.Output.Development, config.Output.DirectoryNames.Scripts ) ) ) // Concatenate all files into a single one. .pipe( concat( slug( application.name ) + ".concat.js", { newLine : ";" } ) ) // Put that file into the development output as well. .pipe( gulp.dest( path.join( config.Output.Development, config.Output.DirectoryNames.Scripts ) ) ) // Minify the file. .pipe( uglify() ) // Rename it to indicate minification. .pipe( rename( { extname : ".min.js" } ) ) // Write out sourcemaps .pipe( sourcemaps.write( "maps" ) ) // Write the file to the production output directory. .pipe( gulp.dest( path.join( config.Output.Production, config.Output.DirectoryNames.Scripts ) ) ); }
[ "function", "buildJs", "(", ")", "{", "// Construct a stream for the JS sources of our plugin, don't read file contents when compiling TypeScript.", "var", "sourceStream", "=", "gulp", ".", "src", "(", "config", ".", "Sources", ".", "Scripts", ",", "{", "cwd", ":", "config", ".", "WorkingDirectory", ",", "read", ":", "true", "}", ")", ";", "return", "sourceStream", ".", "pipe", "(", "jscs", "(", ")", ")", ".", "pipe", "(", "jscs", ".", "reporter", "(", ")", ")", ".", "pipe", "(", "jsValidate", "(", ")", ")", ".", "pipe", "(", "order", "(", ")", ")", "// Only pass through files that have changed since the last build iteration (relevant during \"watch\").", ".", "pipe", "(", "cached", "(", "path", ".", "join", "(", "config", ".", "Output", ".", "Production", ",", "config", ".", "Output", ".", "DirectoryNames", ".", "Scripts", ")", ")", ")", "// Generate sourcemaps", ".", "pipe", "(", "sourcemaps", ".", "init", "(", ")", ")", ".", "pipe", "(", "wrapper", "(", "{", "header", ":", "\"(function() {\\n\\\"use strict\\\";\\n\"", ",", "footer", ":", "\"}());\"", "}", ")", ")", ".", "pipe", "(", "jsValidate", "(", ")", ")", ".", "pipe", "(", "jshint", "(", ")", ")", ".", "pipe", "(", "jshint", ".", "reporter", "(", "stylish", ")", ")", "// Put Angular dependency injection annotation where needed.", ".", "pipe", "(", "ngAnnotate", "(", ")", ")", "// Pull out files which haven't changed since our last build iteration and put them back into the stream.", ".", "pipe", "(", "remember", "(", ")", ")", "// Place the results in the development output directory.", ".", "pipe", "(", "gulp", ".", "dest", "(", "path", ".", "join", "(", "config", ".", "Output", ".", "Development", ",", "config", ".", "Output", ".", "DirectoryNames", ".", "Scripts", ")", ")", ")", "// Concatenate all files into a single one.", ".", "pipe", "(", "concat", "(", "slug", "(", "application", ".", "name", ")", "+", "\".concat.js\"", ",", "{", "newLine", ":", "\";\"", "}", ")", ")", "// Put that file into the development output as well.", ".", "pipe", "(", "gulp", ".", "dest", "(", "path", ".", "join", "(", "config", ".", "Output", ".", "Development", ",", "config", ".", "Output", ".", "DirectoryNames", ".", "Scripts", ")", ")", ")", "// Minify the file.", ".", "pipe", "(", "uglify", "(", ")", ")", "// Rename it to indicate minification.", ".", "pipe", "(", "rename", "(", "{", "extname", ":", "\".min.js\"", "}", ")", ")", "// Write out sourcemaps", ".", "pipe", "(", "sourcemaps", ".", "write", "(", "\"maps\"", ")", ")", "// Write the file to the production output directory.", ".", "pipe", "(", "gulp", ".", "dest", "(", "path", ".", "join", "(", "config", ".", "Output", ".", "Production", ",", "config", ".", "Output", ".", "DirectoryNames", ".", "Scripts", ")", ")", ")", ";", "}" ]
Core JS resource builder.
[ "Core", "JS", "resource", "builder", "." ]
13807648d513c77008951446cfa1b334a2ab2ccf
https://github.com/oliversalzburg/absync/blob/13807648d513c77008951446cfa1b334a2ab2ccf/gulpfile.js#L37-L82
48,114
pdehaan/fetch-subreddit
index.js
_fetchSubreddit
function _fetchSubreddit(subreddit) { const reducer = (prev, {data: {url}}) => prev.push(url) && prev; const jsonUri = `https://www.reddit.com/r/${subreddit}/.json`; return fetch(jsonUri) .then((res) => res.json()) .then((res) => res.data.children.reduce(reducer, [])) .then((urls) => ({subreddit, urls})); }
javascript
function _fetchSubreddit(subreddit) { const reducer = (prev, {data: {url}}) => prev.push(url) && prev; const jsonUri = `https://www.reddit.com/r/${subreddit}/.json`; return fetch(jsonUri) .then((res) => res.json()) .then((res) => res.data.children.reduce(reducer, [])) .then((urls) => ({subreddit, urls})); }
[ "function", "_fetchSubreddit", "(", "subreddit", ")", "{", "const", "reducer", "=", "(", "prev", ",", "{", "data", ":", "{", "url", "}", "}", ")", "=>", "prev", ".", "push", "(", "url", ")", "&&", "prev", ";", "const", "jsonUri", "=", "`", "${", "subreddit", "}", "`", ";", "return", "fetch", "(", "jsonUri", ")", ".", "then", "(", "(", "res", ")", "=>", "res", ".", "json", "(", ")", ")", ".", "then", "(", "(", "res", ")", "=>", "res", ".", "data", ".", "children", ".", "reduce", "(", "reducer", ",", "[", "]", ")", ")", ".", "then", "(", "(", "urls", ")", "=>", "(", "{", "subreddit", ",", "urls", "}", ")", ")", ";", "}" ]
Internal method to fetch the JSON feed and extract the URLs. @private @param {String} subreddit Subreddit name to fetch JSON feed for. @return {Object} An object containing the subreddit name as a key, and links as a nested array.
[ "Internal", "method", "to", "fetch", "the", "JSON", "feed", "and", "extract", "the", "URLs", "." ]
1a34d5b4bc7015f5a1c3f0d3403b7c88d67e8b74
https://github.com/pdehaan/fetch-subreddit/blob/1a34d5b4bc7015f5a1c3f0d3403b7c88d67e8b74/index.js#L31-L38
48,115
pdehaan/fetch-subreddit
index.js
_fetchRandomSubreddit
function _fetchRandomSubreddit(count=1, subreddit='random', fetchOpts={}) { const _fetchSubredditUrl = (subreddit, fetchOpts) => { return fetch(`https://www.reddit.com/r/${subreddit}`, fetchOpts) .then(({url}) => { return { json: `${url}.json`, name: getSubredditName(url), url }; }); }; const promises = [...Array(count)] .map(() => _fetchSubredditUrl(subreddit, fetchOpts)); return Promise.all(promises); }
javascript
function _fetchRandomSubreddit(count=1, subreddit='random', fetchOpts={}) { const _fetchSubredditUrl = (subreddit, fetchOpts) => { return fetch(`https://www.reddit.com/r/${subreddit}`, fetchOpts) .then(({url}) => { return { json: `${url}.json`, name: getSubredditName(url), url }; }); }; const promises = [...Array(count)] .map(() => _fetchSubredditUrl(subreddit, fetchOpts)); return Promise.all(promises); }
[ "function", "_fetchRandomSubreddit", "(", "count", "=", "1", ",", "subreddit", "=", "'random'", ",", "fetchOpts", "=", "{", "}", ")", "{", "const", "_fetchSubredditUrl", "=", "(", "subreddit", ",", "fetchOpts", ")", "=>", "{", "return", "fetch", "(", "`", "${", "subreddit", "}", "`", ",", "fetchOpts", ")", ".", "then", "(", "(", "{", "url", "}", ")", "=>", "{", "return", "{", "json", ":", "`", "${", "url", "}", "`", ",", "name", ":", "getSubredditName", "(", "url", ")", ",", "url", "}", ";", "}", ")", ";", "}", ";", "const", "promises", "=", "[", "...", "Array", "(", "count", ")", "]", ".", "map", "(", "(", ")", "=>", "_fetchSubredditUrl", "(", "subreddit", ",", "fetchOpts", ")", ")", ";", "return", "Promise", ".", "all", "(", "promises", ")", ";", "}" ]
Proxy method that creates an array of subreddit promises to fetch. @private @param {Number} count The number of random subreddits to fetch. Default: 1 @param {String} subreddit Random subreddit generator. Either "random' or "randnsfw" (depending on if yuo want NSFW results). Default: "random" (safe for work) @param {Object} fetchOpts Options to pass to the `fetch()` method. Default: `{}` @return {Array} Array of subreddit `name` and `url`s.
[ "Proxy", "method", "that", "creates", "an", "array", "of", "subreddit", "promises", "to", "fetch", "." ]
1a34d5b4bc7015f5a1c3f0d3403b7c88d67e8b74
https://github.com/pdehaan/fetch-subreddit/blob/1a34d5b4bc7015f5a1c3f0d3403b7c88d67e8b74/index.js#L87-L102
48,116
pdehaan/fetch-subreddit
index.js
getSubredditName
function getSubredditName(url) { try { // This will throw a `TypeError: Cannot read property 'Symbol(Symbol.iterator)' of null` if the RegExp fails. const [input, name] = new RegExp('^https?://(?:www.)?reddit.com/r/(.*?)/?$').exec(url); return name; } catch (err) { return null; } }
javascript
function getSubredditName(url) { try { // This will throw a `TypeError: Cannot read property 'Symbol(Symbol.iterator)' of null` if the RegExp fails. const [input, name] = new RegExp('^https?://(?:www.)?reddit.com/r/(.*?)/?$').exec(url); return name; } catch (err) { return null; } }
[ "function", "getSubredditName", "(", "url", ")", "{", "try", "{", "// This will throw a `TypeError: Cannot read property 'Symbol(Symbol.iterator)' of null` if the RegExp fails.", "const", "[", "input", ",", "name", "]", "=", "new", "RegExp", "(", "'^https?://(?:www.)?reddit.com/r/(.*?)/?$'", ")", ".", "exec", "(", "url", ")", ";", "return", "name", ";", "}", "catch", "(", "err", ")", "{", "return", "null", ";", "}", "}" ]
Extracts a subreddit name from a URL using sketchy RegExp. @param {String} url A fully qualified URL. @return {String} The name of a subreddit. For example: "knitting"
[ "Extracts", "a", "subreddit", "name", "from", "a", "URL", "using", "sketchy", "RegExp", "." ]
1a34d5b4bc7015f5a1c3f0d3403b7c88d67e8b74
https://github.com/pdehaan/fetch-subreddit/blob/1a34d5b4bc7015f5a1c3f0d3403b7c88d67e8b74/index.js#L110-L118
48,117
sadiqhabib/tinymce-dist
tinymce.full.js
relativePosition
function relativePosition(rect, targetRect, rel) { var x, y, w, h, targetW, targetH; x = targetRect.x; y = targetRect.y; w = rect.w; h = rect.h; targetW = targetRect.w; targetH = targetRect.h; rel = (rel || '').split(''); if (rel[0] === 'b') { y += targetH; } if (rel[1] === 'r') { x += targetW; } if (rel[0] === 'c') { y += round(targetH / 2); } if (rel[1] === 'c') { x += round(targetW / 2); } if (rel[3] === 'b') { y -= h; } if (rel[4] === 'r') { x -= w; } if (rel[3] === 'c') { y -= round(h / 2); } if (rel[4] === 'c') { x -= round(w / 2); } return create(x, y, w, h); }
javascript
function relativePosition(rect, targetRect, rel) { var x, y, w, h, targetW, targetH; x = targetRect.x; y = targetRect.y; w = rect.w; h = rect.h; targetW = targetRect.w; targetH = targetRect.h; rel = (rel || '').split(''); if (rel[0] === 'b') { y += targetH; } if (rel[1] === 'r') { x += targetW; } if (rel[0] === 'c') { y += round(targetH / 2); } if (rel[1] === 'c') { x += round(targetW / 2); } if (rel[3] === 'b') { y -= h; } if (rel[4] === 'r') { x -= w; } if (rel[3] === 'c') { y -= round(h / 2); } if (rel[4] === 'c') { x -= round(w / 2); } return create(x, y, w, h); }
[ "function", "relativePosition", "(", "rect", ",", "targetRect", ",", "rel", ")", "{", "var", "x", ",", "y", ",", "w", ",", "h", ",", "targetW", ",", "targetH", ";", "x", "=", "targetRect", ".", "x", ";", "y", "=", "targetRect", ".", "y", ";", "w", "=", "rect", ".", "w", ";", "h", "=", "rect", ".", "h", ";", "targetW", "=", "targetRect", ".", "w", ";", "targetH", "=", "targetRect", ".", "h", ";", "rel", "=", "(", "rel", "||", "''", ")", ".", "split", "(", "''", ")", ";", "if", "(", "rel", "[", "0", "]", "===", "'b'", ")", "{", "y", "+=", "targetH", ";", "}", "if", "(", "rel", "[", "1", "]", "===", "'r'", ")", "{", "x", "+=", "targetW", ";", "}", "if", "(", "rel", "[", "0", "]", "===", "'c'", ")", "{", "y", "+=", "round", "(", "targetH", "/", "2", ")", ";", "}", "if", "(", "rel", "[", "1", "]", "===", "'c'", ")", "{", "x", "+=", "round", "(", "targetW", "/", "2", ")", ";", "}", "if", "(", "rel", "[", "3", "]", "===", "'b'", ")", "{", "y", "-=", "h", ";", "}", "if", "(", "rel", "[", "4", "]", "===", "'r'", ")", "{", "x", "-=", "w", ";", "}", "if", "(", "rel", "[", "3", "]", "===", "'c'", ")", "{", "y", "-=", "round", "(", "h", "/", "2", ")", ";", "}", "if", "(", "rel", "[", "4", "]", "===", "'c'", ")", "{", "x", "-=", "round", "(", "w", "/", "2", ")", ";", "}", "return", "create", "(", "x", ",", "y", ",", "w", ",", "h", ")", ";", "}" ]
Returns the rect positioned based on the relative position name to the target rect. @method relativePosition @param {Rect} rect Source rect to modify into a new rect. @param {Rect} targetRect Rect to move relative to based on the rel option. @param {String} rel Relative position. For example: tr-bl.
[ "Returns", "the", "rect", "positioned", "based", "on", "the", "relative", "position", "name", "to", "the", "target", "rect", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L119-L164
48,118
sadiqhabib/tinymce-dist
tinymce.full.js
inflate
function inflate(rect, w, h) { return create(rect.x - w, rect.y - h, rect.w + w * 2, rect.h + h * 2); }
javascript
function inflate(rect, w, h) { return create(rect.x - w, rect.y - h, rect.w + w * 2, rect.h + h * 2); }
[ "function", "inflate", "(", "rect", ",", "w", ",", "h", ")", "{", "return", "create", "(", "rect", ".", "x", "-", "w", ",", "rect", ".", "y", "-", "h", ",", "rect", ".", "w", "+", "w", "*", "2", ",", "rect", ".", "h", "+", "h", "*", "2", ")", ";", "}" ]
Inflates the rect in all directions. @method inflate @param {Rect} rect Rect to expand. @param {Number} w Relative width to expand by. @param {Number} h Relative height to expand by. @return {Rect} New expanded rect.
[ "Inflates", "the", "rect", "in", "all", "directions", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L199-L201
48,119
sadiqhabib/tinymce-dist
tinymce.full.js
intersect
function intersect(rect, cropRect) { var x1, y1, x2, y2; x1 = max(rect.x, cropRect.x); y1 = max(rect.y, cropRect.y); x2 = min(rect.x + rect.w, cropRect.x + cropRect.w); y2 = min(rect.y + rect.h, cropRect.y + cropRect.h); if (x2 - x1 < 0 || y2 - y1 < 0) { return null; } return create(x1, y1, x2 - x1, y2 - y1); }
javascript
function intersect(rect, cropRect) { var x1, y1, x2, y2; x1 = max(rect.x, cropRect.x); y1 = max(rect.y, cropRect.y); x2 = min(rect.x + rect.w, cropRect.x + cropRect.w); y2 = min(rect.y + rect.h, cropRect.y + cropRect.h); if (x2 - x1 < 0 || y2 - y1 < 0) { return null; } return create(x1, y1, x2 - x1, y2 - y1); }
[ "function", "intersect", "(", "rect", ",", "cropRect", ")", "{", "var", "x1", ",", "y1", ",", "x2", ",", "y2", ";", "x1", "=", "max", "(", "rect", ".", "x", ",", "cropRect", ".", "x", ")", ";", "y1", "=", "max", "(", "rect", ".", "y", ",", "cropRect", ".", "y", ")", ";", "x2", "=", "min", "(", "rect", ".", "x", "+", "rect", ".", "w", ",", "cropRect", ".", "x", "+", "cropRect", ".", "w", ")", ";", "y2", "=", "min", "(", "rect", ".", "y", "+", "rect", ".", "h", ",", "cropRect", ".", "y", "+", "cropRect", ".", "h", ")", ";", "if", "(", "x2", "-", "x1", "<", "0", "||", "y2", "-", "y1", "<", "0", ")", "{", "return", "null", ";", "}", "return", "create", "(", "x1", ",", "y1", ",", "x2", "-", "x1", ",", "y2", "-", "y1", ")", ";", "}" ]
Returns the intersection of the specified rectangles. @method intersect @param {Rect} rect The first rectangle to compare. @param {Rect} cropRect The second rectangle to compare. @return {Rect} The intersection of the two rectangles or null if they don't intersect.
[ "Returns", "the", "intersection", "of", "the", "specified", "rectangles", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L211-L224
48,120
sadiqhabib/tinymce-dist
tinymce.full.js
clamp
function clamp(rect, clampRect, fixedSize) { var underflowX1, underflowY1, overflowX2, overflowY2, x1, y1, x2, y2, cx2, cy2; x1 = rect.x; y1 = rect.y; x2 = rect.x + rect.w; y2 = rect.y + rect.h; cx2 = clampRect.x + clampRect.w; cy2 = clampRect.y + clampRect.h; underflowX1 = max(0, clampRect.x - x1); underflowY1 = max(0, clampRect.y - y1); overflowX2 = max(0, x2 - cx2); overflowY2 = max(0, y2 - cy2); x1 += underflowX1; y1 += underflowY1; if (fixedSize) { x2 += underflowX1; y2 += underflowY1; x1 -= overflowX2; y1 -= overflowY2; } x2 -= overflowX2; y2 -= overflowY2; return create(x1, y1, x2 - x1, y2 - y1); }
javascript
function clamp(rect, clampRect, fixedSize) { var underflowX1, underflowY1, overflowX2, overflowY2, x1, y1, x2, y2, cx2, cy2; x1 = rect.x; y1 = rect.y; x2 = rect.x + rect.w; y2 = rect.y + rect.h; cx2 = clampRect.x + clampRect.w; cy2 = clampRect.y + clampRect.h; underflowX1 = max(0, clampRect.x - x1); underflowY1 = max(0, clampRect.y - y1); overflowX2 = max(0, x2 - cx2); overflowY2 = max(0, y2 - cy2); x1 += underflowX1; y1 += underflowY1; if (fixedSize) { x2 += underflowX1; y2 += underflowY1; x1 -= overflowX2; y1 -= overflowY2; } x2 -= overflowX2; y2 -= overflowY2; return create(x1, y1, x2 - x1, y2 - y1); }
[ "function", "clamp", "(", "rect", ",", "clampRect", ",", "fixedSize", ")", "{", "var", "underflowX1", ",", "underflowY1", ",", "overflowX2", ",", "overflowY2", ",", "x1", ",", "y1", ",", "x2", ",", "y2", ",", "cx2", ",", "cy2", ";", "x1", "=", "rect", ".", "x", ";", "y1", "=", "rect", ".", "y", ";", "x2", "=", "rect", ".", "x", "+", "rect", ".", "w", ";", "y2", "=", "rect", ".", "y", "+", "rect", ".", "h", ";", "cx2", "=", "clampRect", ".", "x", "+", "clampRect", ".", "w", ";", "cy2", "=", "clampRect", ".", "y", "+", "clampRect", ".", "h", ";", "underflowX1", "=", "max", "(", "0", ",", "clampRect", ".", "x", "-", "x1", ")", ";", "underflowY1", "=", "max", "(", "0", ",", "clampRect", ".", "y", "-", "y1", ")", ";", "overflowX2", "=", "max", "(", "0", ",", "x2", "-", "cx2", ")", ";", "overflowY2", "=", "max", "(", "0", ",", "y2", "-", "cy2", ")", ";", "x1", "+=", "underflowX1", ";", "y1", "+=", "underflowY1", ";", "if", "(", "fixedSize", ")", "{", "x2", "+=", "underflowX1", ";", "y2", "+=", "underflowY1", ";", "x1", "-=", "overflowX2", ";", "y1", "-=", "overflowY2", ";", "}", "x2", "-=", "overflowX2", ";", "y2", "-=", "overflowY2", ";", "return", "create", "(", "x1", ",", "y1", ",", "x2", "-", "x1", ",", "y2", "-", "y1", ")", ";", "}" ]
Returns a rect clamped within the specified clamp rect. This forces the rect to be inside the clamp rect. @method clamp @param {Rect} rect Rectangle to force within clamp rect. @param {Rect} clampRect Rectable to force within. @param {Boolean} fixedSize True/false if size should be fixed. @return {Rect} Clamped rect.
[ "Returns", "a", "rect", "clamped", "within", "the", "specified", "clamp", "rect", ".", "This", "forces", "the", "rect", "to", "be", "inside", "the", "clamp", "rect", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L236-L266
48,121
sadiqhabib/tinymce-dist
tinymce.full.js
fromClientRect
function fromClientRect(clientRect) { return create(clientRect.left, clientRect.top, clientRect.width, clientRect.height); }
javascript
function fromClientRect(clientRect) { return create(clientRect.left, clientRect.top, clientRect.width, clientRect.height); }
[ "function", "fromClientRect", "(", "clientRect", ")", "{", "return", "create", "(", "clientRect", ".", "left", ",", "clientRect", ".", "top", ",", "clientRect", ".", "width", ",", "clientRect", ".", "height", ")", ";", "}" ]
Creates a new rectangle object form a clientRects object. @method fromClientRect @param {ClientRect} clientRect DOM ClientRect object. @return {Rect} New rectangle object.
[ "Creates", "a", "new", "rectangle", "object", "form", "a", "clientRects", "object", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L289-L291
48,122
sadiqhabib/tinymce-dist
tinymce.full.js
function (callback, element) { if (requestAnimationFramePromise) { requestAnimationFramePromise.then(callback); return; } requestAnimationFramePromise = new Promise(function (resolve) { if (!element) { element = document.body; } requestAnimationFrame(resolve, element); }).then(callback); }
javascript
function (callback, element) { if (requestAnimationFramePromise) { requestAnimationFramePromise.then(callback); return; } requestAnimationFramePromise = new Promise(function (resolve) { if (!element) { element = document.body; } requestAnimationFrame(resolve, element); }).then(callback); }
[ "function", "(", "callback", ",", "element", ")", "{", "if", "(", "requestAnimationFramePromise", ")", "{", "requestAnimationFramePromise", ".", "then", "(", "callback", ")", ";", "return", ";", "}", "requestAnimationFramePromise", "=", "new", "Promise", "(", "function", "(", "resolve", ")", "{", "if", "(", "!", "element", ")", "{", "element", "=", "document", ".", "body", ";", "}", "requestAnimationFrame", "(", "resolve", ",", "element", ")", ";", "}", ")", ".", "then", "(", "callback", ")", ";", "}" ]
Requests an animation frame and fallbacks to a timeout on older browsers. @method requestAnimationFrame @param {function} callback Callback to execute when a new frame is available. @param {DOMElement} element Optional element to scope it to.
[ "Requests", "an", "animation", "frame", "and", "fallbacks", "to", "a", "timeout", "on", "older", "browsers", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L602-L615
48,123
sadiqhabib/tinymce-dist
tinymce.full.js
function (editor, callback, time) { var timer; timer = wrappedSetInterval(function () { if (!editor.removed) { callback(); } else { clearInterval(timer); } }, time); return timer; }
javascript
function (editor, callback, time) { var timer; timer = wrappedSetInterval(function () { if (!editor.removed) { callback(); } else { clearInterval(timer); } }, time); return timer; }
[ "function", "(", "editor", ",", "callback", ",", "time", ")", "{", "var", "timer", ";", "timer", "=", "wrappedSetInterval", "(", "function", "(", ")", "{", "if", "(", "!", "editor", ".", "removed", ")", "{", "callback", "(", ")", ";", "}", "else", "{", "clearInterval", "(", "timer", ")", ";", "}", "}", ",", "time", ")", ";", "return", "timer", ";", "}" ]
Sets an interval timer it's similar to setInterval except that it checks if the editor instance is still alive when the callback gets executed. @method setEditorInterval @param {function} callback Callback to execute when interval time runs out. @param {Number} time Optional time to wait before the callback is executed, defaults to 0. @return {Number} Timeout id number.
[ "Sets", "an", "interval", "timer", "it", "s", "similar", "to", "setInterval", "except", "that", "it", "checks", "if", "the", "editor", "instance", "is", "still", "alive", "when", "the", "callback", "gets", "executed", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L664-L676
48,124
sadiqhabib/tinymce-dist
tinymce.full.js
addEvent
function addEvent(target, name, callback, capture) { if (target.addEventListener) { target.addEventListener(name, callback, capture || false); } else if (target.attachEvent) { target.attachEvent('on' + name, callback); } }
javascript
function addEvent(target, name, callback, capture) { if (target.addEventListener) { target.addEventListener(name, callback, capture || false); } else if (target.attachEvent) { target.attachEvent('on' + name, callback); } }
[ "function", "addEvent", "(", "target", ",", "name", ",", "callback", ",", "capture", ")", "{", "if", "(", "target", ".", "addEventListener", ")", "{", "target", ".", "addEventListener", "(", "name", ",", "callback", ",", "capture", "||", "false", ")", ";", "}", "else", "if", "(", "target", ".", "attachEvent", ")", "{", "target", ".", "attachEvent", "(", "'on'", "+", "name", ",", "callback", ")", ";", "}", "}" ]
Binds a native event to a callback on the speified target.
[ "Binds", "a", "native", "event", "to", "a", "callback", "on", "the", "speified", "target", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L935-L941
48,125
sadiqhabib/tinymce-dist
tinymce.full.js
removeEvent
function removeEvent(target, name, callback, capture) { if (target.removeEventListener) { target.removeEventListener(name, callback, capture || false); } else if (target.detachEvent) { target.detachEvent('on' + name, callback); } }
javascript
function removeEvent(target, name, callback, capture) { if (target.removeEventListener) { target.removeEventListener(name, callback, capture || false); } else if (target.detachEvent) { target.detachEvent('on' + name, callback); } }
[ "function", "removeEvent", "(", "target", ",", "name", ",", "callback", ",", "capture", ")", "{", "if", "(", "target", ".", "removeEventListener", ")", "{", "target", ".", "removeEventListener", "(", "name", ",", "callback", ",", "capture", "||", "false", ")", ";", "}", "else", "if", "(", "target", ".", "detachEvent", ")", "{", "target", ".", "detachEvent", "(", "'on'", "+", "name", ",", "callback", ")", ";", "}", "}" ]
Unbinds a native event callback on the specified target.
[ "Unbinds", "a", "native", "event", "callback", "on", "the", "specified", "target", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L946-L952
48,126
sadiqhabib/tinymce-dist
tinymce.full.js
getTargetFromShadowDom
function getTargetFromShadowDom(event, defaultTarget) { var path, target = defaultTarget; // When target element is inside Shadow DOM we need to take first element from path // otherwise we'll get Shadow Root parent, not actual target element // Normalize target for WebComponents v0 implementation (in Chrome) path = event.path; if (path && path.length > 0) { target = path[0]; } // Normalize target for WebComponents v1 implementation (standard) if (event.deepPath) { path = event.deepPath(); if (path && path.length > 0) { target = path[0]; } } return target; }
javascript
function getTargetFromShadowDom(event, defaultTarget) { var path, target = defaultTarget; // When target element is inside Shadow DOM we need to take first element from path // otherwise we'll get Shadow Root parent, not actual target element // Normalize target for WebComponents v0 implementation (in Chrome) path = event.path; if (path && path.length > 0) { target = path[0]; } // Normalize target for WebComponents v1 implementation (standard) if (event.deepPath) { path = event.deepPath(); if (path && path.length > 0) { target = path[0]; } } return target; }
[ "function", "getTargetFromShadowDom", "(", "event", ",", "defaultTarget", ")", "{", "var", "path", ",", "target", "=", "defaultTarget", ";", "// When target element is inside Shadow DOM we need to take first element from path", "// otherwise we'll get Shadow Root parent, not actual target element", "// Normalize target for WebComponents v0 implementation (in Chrome)", "path", "=", "event", ".", "path", ";", "if", "(", "path", "&&", "path", ".", "length", ">", "0", ")", "{", "target", "=", "path", "[", "0", "]", ";", "}", "// Normalize target for WebComponents v1 implementation (standard)", "if", "(", "event", ".", "deepPath", ")", "{", "path", "=", "event", ".", "deepPath", "(", ")", ";", "if", "(", "path", "&&", "path", ".", "length", ">", "0", ")", "{", "target", "=", "path", "[", "0", "]", ";", "}", "}", "return", "target", ";", "}" ]
Gets the event target based on shadow dom properties like path and deepPath.
[ "Gets", "the", "event", "target", "based", "on", "shadow", "dom", "properties", "like", "path", "and", "deepPath", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L957-L978
48,127
sadiqhabib/tinymce-dist
tinymce.full.js
fix
function fix(originalEvent, data) { var name, event = data || {}, undef; // Dummy function that gets replaced on the delegation state functions function returnFalse() { return false; } // Dummy function that gets replaced on the delegation state functions function returnTrue() { return true; } // Copy all properties from the original event for (name in originalEvent) { // layerX/layerY is deprecated in Chrome and produces a warning if (!deprecated[name]) { event[name] = originalEvent[name]; } } // Normalize target IE uses srcElement if (!event.target) { event.target = event.srcElement || document; } // Experimental shadow dom support if (Env.experimentalShadowDom) { event.target = getTargetFromShadowDom(originalEvent, event.target); } // Calculate pageX/Y if missing and clientX/Y available if (originalEvent && mouseEventRe.test(originalEvent.type) && originalEvent.pageX === undef && originalEvent.clientX !== undef) { var eventDoc = event.target.ownerDocument || document; var doc = eventDoc.documentElement; var body = eventDoc.body; event.pageX = originalEvent.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); event.pageY = originalEvent.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); } // Add preventDefault method event.preventDefault = function () { event.isDefaultPrevented = returnTrue; // Execute preventDefault on the original event object if (originalEvent) { if (originalEvent.preventDefault) { originalEvent.preventDefault(); } else { originalEvent.returnValue = false; // IE } } }; // Add stopPropagation event.stopPropagation = function () { event.isPropagationStopped = returnTrue; // Execute stopPropagation on the original event object if (originalEvent) { if (originalEvent.stopPropagation) { originalEvent.stopPropagation(); } else { originalEvent.cancelBubble = true; // IE } } }; // Add stopImmediatePropagation event.stopImmediatePropagation = function () { event.isImmediatePropagationStopped = returnTrue; event.stopPropagation(); }; // Add event delegation states if (!event.isDefaultPrevented) { event.isDefaultPrevented = returnFalse; event.isPropagationStopped = returnFalse; event.isImmediatePropagationStopped = returnFalse; } // Add missing metaKey for IE 8 if (typeof event.metaKey == 'undefined') { event.metaKey = false; } return event; }
javascript
function fix(originalEvent, data) { var name, event = data || {}, undef; // Dummy function that gets replaced on the delegation state functions function returnFalse() { return false; } // Dummy function that gets replaced on the delegation state functions function returnTrue() { return true; } // Copy all properties from the original event for (name in originalEvent) { // layerX/layerY is deprecated in Chrome and produces a warning if (!deprecated[name]) { event[name] = originalEvent[name]; } } // Normalize target IE uses srcElement if (!event.target) { event.target = event.srcElement || document; } // Experimental shadow dom support if (Env.experimentalShadowDom) { event.target = getTargetFromShadowDom(originalEvent, event.target); } // Calculate pageX/Y if missing and clientX/Y available if (originalEvent && mouseEventRe.test(originalEvent.type) && originalEvent.pageX === undef && originalEvent.clientX !== undef) { var eventDoc = event.target.ownerDocument || document; var doc = eventDoc.documentElement; var body = eventDoc.body; event.pageX = originalEvent.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); event.pageY = originalEvent.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); } // Add preventDefault method event.preventDefault = function () { event.isDefaultPrevented = returnTrue; // Execute preventDefault on the original event object if (originalEvent) { if (originalEvent.preventDefault) { originalEvent.preventDefault(); } else { originalEvent.returnValue = false; // IE } } }; // Add stopPropagation event.stopPropagation = function () { event.isPropagationStopped = returnTrue; // Execute stopPropagation on the original event object if (originalEvent) { if (originalEvent.stopPropagation) { originalEvent.stopPropagation(); } else { originalEvent.cancelBubble = true; // IE } } }; // Add stopImmediatePropagation event.stopImmediatePropagation = function () { event.isImmediatePropagationStopped = returnTrue; event.stopPropagation(); }; // Add event delegation states if (!event.isDefaultPrevented) { event.isDefaultPrevented = returnFalse; event.isPropagationStopped = returnFalse; event.isImmediatePropagationStopped = returnFalse; } // Add missing metaKey for IE 8 if (typeof event.metaKey == 'undefined') { event.metaKey = false; } return event; }
[ "function", "fix", "(", "originalEvent", ",", "data", ")", "{", "var", "name", ",", "event", "=", "data", "||", "{", "}", ",", "undef", ";", "// Dummy function that gets replaced on the delegation state functions", "function", "returnFalse", "(", ")", "{", "return", "false", ";", "}", "// Dummy function that gets replaced on the delegation state functions", "function", "returnTrue", "(", ")", "{", "return", "true", ";", "}", "// Copy all properties from the original event", "for", "(", "name", "in", "originalEvent", ")", "{", "// layerX/layerY is deprecated in Chrome and produces a warning", "if", "(", "!", "deprecated", "[", "name", "]", ")", "{", "event", "[", "name", "]", "=", "originalEvent", "[", "name", "]", ";", "}", "}", "// Normalize target IE uses srcElement", "if", "(", "!", "event", ".", "target", ")", "{", "event", ".", "target", "=", "event", ".", "srcElement", "||", "document", ";", "}", "// Experimental shadow dom support", "if", "(", "Env", ".", "experimentalShadowDom", ")", "{", "event", ".", "target", "=", "getTargetFromShadowDom", "(", "originalEvent", ",", "event", ".", "target", ")", ";", "}", "// Calculate pageX/Y if missing and clientX/Y available", "if", "(", "originalEvent", "&&", "mouseEventRe", ".", "test", "(", "originalEvent", ".", "type", ")", "&&", "originalEvent", ".", "pageX", "===", "undef", "&&", "originalEvent", ".", "clientX", "!==", "undef", ")", "{", "var", "eventDoc", "=", "event", ".", "target", ".", "ownerDocument", "||", "document", ";", "var", "doc", "=", "eventDoc", ".", "documentElement", ";", "var", "body", "=", "eventDoc", ".", "body", ";", "event", ".", "pageX", "=", "originalEvent", ".", "clientX", "+", "(", "doc", "&&", "doc", ".", "scrollLeft", "||", "body", "&&", "body", ".", "scrollLeft", "||", "0", ")", "-", "(", "doc", "&&", "doc", ".", "clientLeft", "||", "body", "&&", "body", ".", "clientLeft", "||", "0", ")", ";", "event", ".", "pageY", "=", "originalEvent", ".", "clientY", "+", "(", "doc", "&&", "doc", ".", "scrollTop", "||", "body", "&&", "body", ".", "scrollTop", "||", "0", ")", "-", "(", "doc", "&&", "doc", ".", "clientTop", "||", "body", "&&", "body", ".", "clientTop", "||", "0", ")", ";", "}", "// Add preventDefault method", "event", ".", "preventDefault", "=", "function", "(", ")", "{", "event", ".", "isDefaultPrevented", "=", "returnTrue", ";", "// Execute preventDefault on the original event object", "if", "(", "originalEvent", ")", "{", "if", "(", "originalEvent", ".", "preventDefault", ")", "{", "originalEvent", ".", "preventDefault", "(", ")", ";", "}", "else", "{", "originalEvent", ".", "returnValue", "=", "false", ";", "// IE", "}", "}", "}", ";", "// Add stopPropagation", "event", ".", "stopPropagation", "=", "function", "(", ")", "{", "event", ".", "isPropagationStopped", "=", "returnTrue", ";", "// Execute stopPropagation on the original event object", "if", "(", "originalEvent", ")", "{", "if", "(", "originalEvent", ".", "stopPropagation", ")", "{", "originalEvent", ".", "stopPropagation", "(", ")", ";", "}", "else", "{", "originalEvent", ".", "cancelBubble", "=", "true", ";", "// IE", "}", "}", "}", ";", "// Add stopImmediatePropagation", "event", ".", "stopImmediatePropagation", "=", "function", "(", ")", "{", "event", ".", "isImmediatePropagationStopped", "=", "returnTrue", ";", "event", ".", "stopPropagation", "(", ")", ";", "}", ";", "// Add event delegation states", "if", "(", "!", "event", ".", "isDefaultPrevented", ")", "{", "event", ".", "isDefaultPrevented", "=", "returnFalse", ";", "event", ".", "isPropagationStopped", "=", "returnFalse", ";", "event", ".", "isImmediatePropagationStopped", "=", "returnFalse", ";", "}", "// Add missing metaKey for IE 8", "if", "(", "typeof", "event", ".", "metaKey", "==", "'undefined'", ")", "{", "event", ".", "metaKey", "=", "false", ";", "}", "return", "event", ";", "}" ]
Normalizes a native event object or just adds the event specific methods on a custom event.
[ "Normalizes", "a", "native", "event", "object", "or", "just", "adds", "the", "event", "specific", "methods", "on", "a", "custom", "event", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L983-L1074
48,128
sadiqhabib/tinymce-dist
tinymce.full.js
is
function is(obj, type) { if (!type) { return obj !== undefined; } if (type == 'array' && Arr.isArray(obj)) { return true; } return typeof obj == type; }
javascript
function is(obj, type) { if (!type) { return obj !== undefined; } if (type == 'array' && Arr.isArray(obj)) { return true; } return typeof obj == type; }
[ "function", "is", "(", "obj", ",", "type", ")", "{", "if", "(", "!", "type", ")", "{", "return", "obj", "!==", "undefined", ";", "}", "if", "(", "type", "==", "'array'", "&&", "Arr", ".", "isArray", "(", "obj", ")", ")", "{", "return", "true", ";", "}", "return", "typeof", "obj", "==", "type", ";", "}" ]
Checks if a object is of a specific type for example an array. @method is @param {Object} obj Object to check type of. @param {string} type Optional type to check for. @return {Boolean} true/false if the object is of the specified type.
[ "Checks", "if", "a", "object", "is", "of", "a", "specific", "type", "for", "example", "an", "array", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L3767-L3777
48,129
sadiqhabib/tinymce-dist
tinymce.full.js
create
function create(s, p, root) { var self = this, sp, ns, cn, scn, c, de = 0; // Parse : <prefix> <class>:<super class> s = /^((static) )?([\w.]+)(:([\w.]+))?/.exec(s); cn = s[3].match(/(^|\.)(\w+)$/i)[2]; // Class name // Create namespace for new class ns = self.createNS(s[3].replace(/\.\w+$/, ''), root); // Class already exists if (ns[cn]) { return; } // Make pure static class if (s[2] == 'static') { ns[cn] = p; if (this.onCreate) { this.onCreate(s[2], s[3], ns[cn]); } return; } // Create default constructor if (!p[cn]) { p[cn] = function () { }; de = 1; } // Add constructor and methods ns[cn] = p[cn]; self.extend(ns[cn].prototype, p); // Extend if (s[5]) { sp = self.resolve(s[5]).prototype; scn = s[5].match(/\.(\w+)$/i)[1]; // Class name // Extend constructor c = ns[cn]; if (de) { // Add passthrough constructor ns[cn] = function () { return sp[scn].apply(this, arguments); }; } else { // Add inherit constructor ns[cn] = function () { this.parent = sp[scn]; return c.apply(this, arguments); }; } ns[cn].prototype[cn] = ns[cn]; // Add super methods self.each(sp, function (f, n) { ns[cn].prototype[n] = sp[n]; }); // Add overridden methods self.each(p, function (f, n) { // Extend methods if needed if (sp[n]) { ns[cn].prototype[n] = function () { this.parent = sp[n]; return f.apply(this, arguments); }; } else { if (n != cn) { ns[cn].prototype[n] = f; } } }); } // Add static methods /*jshint sub:true*/ /*eslint dot-notation:0*/ self.each(p['static'], function (f, n) { ns[cn][n] = f; }); }
javascript
function create(s, p, root) { var self = this, sp, ns, cn, scn, c, de = 0; // Parse : <prefix> <class>:<super class> s = /^((static) )?([\w.]+)(:([\w.]+))?/.exec(s); cn = s[3].match(/(^|\.)(\w+)$/i)[2]; // Class name // Create namespace for new class ns = self.createNS(s[3].replace(/\.\w+$/, ''), root); // Class already exists if (ns[cn]) { return; } // Make pure static class if (s[2] == 'static') { ns[cn] = p; if (this.onCreate) { this.onCreate(s[2], s[3], ns[cn]); } return; } // Create default constructor if (!p[cn]) { p[cn] = function () { }; de = 1; } // Add constructor and methods ns[cn] = p[cn]; self.extend(ns[cn].prototype, p); // Extend if (s[5]) { sp = self.resolve(s[5]).prototype; scn = s[5].match(/\.(\w+)$/i)[1]; // Class name // Extend constructor c = ns[cn]; if (de) { // Add passthrough constructor ns[cn] = function () { return sp[scn].apply(this, arguments); }; } else { // Add inherit constructor ns[cn] = function () { this.parent = sp[scn]; return c.apply(this, arguments); }; } ns[cn].prototype[cn] = ns[cn]; // Add super methods self.each(sp, function (f, n) { ns[cn].prototype[n] = sp[n]; }); // Add overridden methods self.each(p, function (f, n) { // Extend methods if needed if (sp[n]) { ns[cn].prototype[n] = function () { this.parent = sp[n]; return f.apply(this, arguments); }; } else { if (n != cn) { ns[cn].prototype[n] = f; } } }); } // Add static methods /*jshint sub:true*/ /*eslint dot-notation:0*/ self.each(p['static'], function (f, n) { ns[cn][n] = f; }); }
[ "function", "create", "(", "s", ",", "p", ",", "root", ")", "{", "var", "self", "=", "this", ",", "sp", ",", "ns", ",", "cn", ",", "scn", ",", "c", ",", "de", "=", "0", ";", "// Parse : <prefix> <class>:<super class>", "s", "=", "/", "^((static) )?([\\w.]+)(:([\\w.]+))?", "/", ".", "exec", "(", "s", ")", ";", "cn", "=", "s", "[", "3", "]", ".", "match", "(", "/", "(^|\\.)(\\w+)$", "/", "i", ")", "[", "2", "]", ";", "// Class name", "// Create namespace for new class", "ns", "=", "self", ".", "createNS", "(", "s", "[", "3", "]", ".", "replace", "(", "/", "\\.\\w+$", "/", ",", "''", ")", ",", "root", ")", ";", "// Class already exists", "if", "(", "ns", "[", "cn", "]", ")", "{", "return", ";", "}", "// Make pure static class", "if", "(", "s", "[", "2", "]", "==", "'static'", ")", "{", "ns", "[", "cn", "]", "=", "p", ";", "if", "(", "this", ".", "onCreate", ")", "{", "this", ".", "onCreate", "(", "s", "[", "2", "]", ",", "s", "[", "3", "]", ",", "ns", "[", "cn", "]", ")", ";", "}", "return", ";", "}", "// Create default constructor", "if", "(", "!", "p", "[", "cn", "]", ")", "{", "p", "[", "cn", "]", "=", "function", "(", ")", "{", "}", ";", "de", "=", "1", ";", "}", "// Add constructor and methods", "ns", "[", "cn", "]", "=", "p", "[", "cn", "]", ";", "self", ".", "extend", "(", "ns", "[", "cn", "]", ".", "prototype", ",", "p", ")", ";", "// Extend", "if", "(", "s", "[", "5", "]", ")", "{", "sp", "=", "self", ".", "resolve", "(", "s", "[", "5", "]", ")", ".", "prototype", ";", "scn", "=", "s", "[", "5", "]", ".", "match", "(", "/", "\\.(\\w+)$", "/", "i", ")", "[", "1", "]", ";", "// Class name", "// Extend constructor", "c", "=", "ns", "[", "cn", "]", ";", "if", "(", "de", ")", "{", "// Add passthrough constructor", "ns", "[", "cn", "]", "=", "function", "(", ")", "{", "return", "sp", "[", "scn", "]", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "}", "else", "{", "// Add inherit constructor", "ns", "[", "cn", "]", "=", "function", "(", ")", "{", "this", ".", "parent", "=", "sp", "[", "scn", "]", ";", "return", "c", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "}", "ns", "[", "cn", "]", ".", "prototype", "[", "cn", "]", "=", "ns", "[", "cn", "]", ";", "// Add super methods", "self", ".", "each", "(", "sp", ",", "function", "(", "f", ",", "n", ")", "{", "ns", "[", "cn", "]", ".", "prototype", "[", "n", "]", "=", "sp", "[", "n", "]", ";", "}", ")", ";", "// Add overridden methods", "self", ".", "each", "(", "p", ",", "function", "(", "f", ",", "n", ")", "{", "// Extend methods if needed", "if", "(", "sp", "[", "n", "]", ")", "{", "ns", "[", "cn", "]", ".", "prototype", "[", "n", "]", "=", "function", "(", ")", "{", "this", ".", "parent", "=", "sp", "[", "n", "]", ";", "return", "f", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "}", "else", "{", "if", "(", "n", "!=", "cn", ")", "{", "ns", "[", "cn", "]", ".", "prototype", "[", "n", "]", "=", "f", ";", "}", "}", "}", ")", ";", "}", "// Add static methods", "/*jshint sub:true*/", "/*eslint dot-notation:0*/", "self", ".", "each", "(", "p", "[", "'static'", "]", ",", "function", "(", "f", ",", "n", ")", "{", "ns", "[", "cn", "]", "[", "n", "]", "=", "f", ";", "}", ")", ";", "}" ]
Creates a class, subclass or static singleton. More details on this method can be found in the Wiki. @method create @param {String} s Class name, inheritance and prefix. @param {Object} p Collection of methods to add to the class. @param {Object} root Optional root object defaults to the global window object. @example // Creates a basic class tinymce.create('tinymce.somepackage.SomeClass', { SomeClass: function() { // Class constructor }, method: function() { // Some method } }); // Creates a basic subclass class tinymce.create('tinymce.somepackage.SomeSubClass:tinymce.somepackage.SomeClass', { SomeSubClass: function() { // Class constructor this.parent(); // Call parent constructor }, method: function() { // Some method this.parent(); // Call parent method }, 'static': { staticMethod: function() { // Static method } } }); // Creates a singleton/static class tinymce.create('static tinymce.somepackage.SomeSingletonClass', { method: function() { // Some method } });
[ "Creates", "a", "class", "subclass", "or", "static", "singleton", ".", "More", "details", "on", "this", "method", "can", "be", "found", "in", "the", "Wiki", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L3866-L3950
48,130
sadiqhabib/tinymce-dist
tinymce.full.js
walk
function walk(o, f, n, s) { s = s || this; if (o) { if (n) { o = o[n]; } Arr.each(o, function (o, i) { if (f.call(s, o, i, n) === false) { return false; } walk(o, f, n, s); }); } }
javascript
function walk(o, f, n, s) { s = s || this; if (o) { if (n) { o = o[n]; } Arr.each(o, function (o, i) { if (f.call(s, o, i, n) === false) { return false; } walk(o, f, n, s); }); } }
[ "function", "walk", "(", "o", ",", "f", ",", "n", ",", "s", ")", "{", "s", "=", "s", "||", "this", ";", "if", "(", "o", ")", "{", "if", "(", "n", ")", "{", "o", "=", "o", "[", "n", "]", ";", "}", "Arr", ".", "each", "(", "o", ",", "function", "(", "o", ",", "i", ")", "{", "if", "(", "f", ".", "call", "(", "s", ",", "o", ",", "i", ",", "n", ")", "===", "false", ")", "{", "return", "false", ";", "}", "walk", "(", "o", ",", "f", ",", "n", ",", "s", ")", ";", "}", ")", ";", "}", "}" ]
Executed the specified function for each item in a object tree. @method walk @param {Object} o Object tree to walk though. @param {function} f Function to call for each item. @param {String} n Optional name of collection inside the objects to walk for example childNodes. @param {String} s Optional scope to execute the function in.
[ "Executed", "the", "specified", "function", "for", "each", "item", "in", "a", "object", "tree", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L3980-L3996
48,131
sadiqhabib/tinymce-dist
tinymce.full.js
createNS
function createNS(n, o) { var i, v; o = o || window; n = n.split('.'); for (i = 0; i < n.length; i++) { v = n[i]; if (!o[v]) { o[v] = {}; } o = o[v]; } return o; }
javascript
function createNS(n, o) { var i, v; o = o || window; n = n.split('.'); for (i = 0; i < n.length; i++) { v = n[i]; if (!o[v]) { o[v] = {}; } o = o[v]; } return o; }
[ "function", "createNS", "(", "n", ",", "o", ")", "{", "var", "i", ",", "v", ";", "o", "=", "o", "||", "window", ";", "n", "=", "n", ".", "split", "(", "'.'", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "n", ".", "length", ";", "i", "++", ")", "{", "v", "=", "n", "[", "i", "]", ";", "if", "(", "!", "o", "[", "v", "]", ")", "{", "o", "[", "v", "]", "=", "{", "}", ";", "}", "o", "=", "o", "[", "v", "]", ";", "}", "return", "o", ";", "}" ]
Creates a namespace on a specific object. @method createNS @param {String} n Namespace to create for example a.b.c.d. @param {Object} o Optional object to add namespace to, defaults to window. @return {Object} New namespace object the last item in path. @example // Create some namespace tinymce.createNS('tinymce.somepackage.subpackage'); // Add a singleton var tinymce.somepackage.subpackage.SomeSingleton = { method: function() { // Some method } };
[ "Creates", "a", "namespace", "on", "a", "specific", "object", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L4016-L4033
48,132
sadiqhabib/tinymce-dist
tinymce.full.js
resolve
function resolve(n, o) { var i, l; o = o || window; n = n.split('.'); for (i = 0, l = n.length; i < l; i++) { o = o[n[i]]; if (!o) { break; } } return o; }
javascript
function resolve(n, o) { var i, l; o = o || window; n = n.split('.'); for (i = 0, l = n.length; i < l; i++) { o = o[n[i]]; if (!o) { break; } } return o; }
[ "function", "resolve", "(", "n", ",", "o", ")", "{", "var", "i", ",", "l", ";", "o", "=", "o", "||", "window", ";", "n", "=", "n", ".", "split", "(", "'.'", ")", ";", "for", "(", "i", "=", "0", ",", "l", "=", "n", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "o", "=", "o", "[", "n", "[", "i", "]", "]", ";", "if", "(", "!", "o", ")", "{", "break", ";", "}", "}", "return", "o", ";", "}" ]
Resolves a string and returns the object from a specific structure. @method resolve @param {String} n Path to resolve for example a.b.c.d. @param {Object} o Optional object to search though, defaults to window. @return {Object} Last object in path or null if it couldn't be resolved. @example // Resolve a path into an object reference var obj = tinymce.resolve('a.b.c.d');
[ "Resolves", "a", "string", "and", "returns", "the", "object", "from", "a", "specific", "structure", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L4046-L4061
48,133
sadiqhabib/tinymce-dist
tinymce.full.js
function (selector, context) { var self = this, match, node; if (!selector) { return self; } if (selector.nodeType) { self.context = self[0] = selector; self.length = 1; return self; } if (context && context.nodeType) { self.context = context; } else { if (context) { return DomQuery(selector).attr(context); } self.context = context = document; } if (isString(selector)) { self.selector = selector; if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">" && selector.length >= 3) { match = [null, selector, null]; } else { match = rquickExpr.exec(selector); } if (match) { if (match[1]) { node = createFragment(selector, getElementDocument(context)).firstChild; while (node) { push.call(self, node); node = node.nextSibling; } } else { node = getElementDocument(context).getElementById(match[2]); if (!node) { return self; } if (node.id !== match[2]) { return self.find(selector); } self.length = 1; self[0] = node; } } else { return DomQuery(context).find(selector); } } else { this.add(selector, false); } return self; }
javascript
function (selector, context) { var self = this, match, node; if (!selector) { return self; } if (selector.nodeType) { self.context = self[0] = selector; self.length = 1; return self; } if (context && context.nodeType) { self.context = context; } else { if (context) { return DomQuery(selector).attr(context); } self.context = context = document; } if (isString(selector)) { self.selector = selector; if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">" && selector.length >= 3) { match = [null, selector, null]; } else { match = rquickExpr.exec(selector); } if (match) { if (match[1]) { node = createFragment(selector, getElementDocument(context)).firstChild; while (node) { push.call(self, node); node = node.nextSibling; } } else { node = getElementDocument(context).getElementById(match[2]); if (!node) { return self; } if (node.id !== match[2]) { return self.find(selector); } self.length = 1; self[0] = node; } } else { return DomQuery(context).find(selector); } } else { this.add(selector, false); } return self; }
[ "function", "(", "selector", ",", "context", ")", "{", "var", "self", "=", "this", ",", "match", ",", "node", ";", "if", "(", "!", "selector", ")", "{", "return", "self", ";", "}", "if", "(", "selector", ".", "nodeType", ")", "{", "self", ".", "context", "=", "self", "[", "0", "]", "=", "selector", ";", "self", ".", "length", "=", "1", ";", "return", "self", ";", "}", "if", "(", "context", "&&", "context", ".", "nodeType", ")", "{", "self", ".", "context", "=", "context", ";", "}", "else", "{", "if", "(", "context", ")", "{", "return", "DomQuery", "(", "selector", ")", ".", "attr", "(", "context", ")", ";", "}", "self", ".", "context", "=", "context", "=", "document", ";", "}", "if", "(", "isString", "(", "selector", ")", ")", "{", "self", ".", "selector", "=", "selector", ";", "if", "(", "selector", ".", "charAt", "(", "0", ")", "===", "\"<\"", "&&", "selector", ".", "charAt", "(", "selector", ".", "length", "-", "1", ")", "===", "\">\"", "&&", "selector", ".", "length", ">=", "3", ")", "{", "match", "=", "[", "null", ",", "selector", ",", "null", "]", ";", "}", "else", "{", "match", "=", "rquickExpr", ".", "exec", "(", "selector", ")", ";", "}", "if", "(", "match", ")", "{", "if", "(", "match", "[", "1", "]", ")", "{", "node", "=", "createFragment", "(", "selector", ",", "getElementDocument", "(", "context", ")", ")", ".", "firstChild", ";", "while", "(", "node", ")", "{", "push", ".", "call", "(", "self", ",", "node", ")", ";", "node", "=", "node", ".", "nextSibling", ";", "}", "}", "else", "{", "node", "=", "getElementDocument", "(", "context", ")", ".", "getElementById", "(", "match", "[", "2", "]", ")", ";", "if", "(", "!", "node", ")", "{", "return", "self", ";", "}", "if", "(", "node", ".", "id", "!==", "match", "[", "2", "]", ")", "{", "return", "self", ".", "find", "(", "selector", ")", ";", "}", "self", ".", "length", "=", "1", ";", "self", "[", "0", "]", "=", "node", ";", "}", "}", "else", "{", "return", "DomQuery", "(", "context", ")", ".", "find", "(", "selector", ")", ";", "}", "}", "else", "{", "this", ".", "add", "(", "selector", ",", "false", ")", ";", "}", "return", "self", ";", "}" ]
Constructs a new DomQuery instance with the specified selector or context. @constructor @method init @param {String/Array/DomQuery} selector Optional CSS selector/Array or array like object or HTML string. @param {Document/Element} context Optional context to search in.
[ "Constructs", "a", "new", "DomQuery", "instance", "with", "the", "specified", "selector", "or", "context", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L4442-L4505
48,134
sadiqhabib/tinymce-dist
tinymce.full.js
function (items, sort) { var self = this, nodes, i; if (isString(items)) { return self.add(DomQuery(items)); } if (sort !== false) { nodes = DomQuery.unique(self.toArray().concat(DomQuery.makeArray(items))); self.length = nodes.length; for (i = 0; i < nodes.length; i++) { self[i] = nodes[i]; } } else { push.apply(self, DomQuery.makeArray(items)); } return self; }
javascript
function (items, sort) { var self = this, nodes, i; if (isString(items)) { return self.add(DomQuery(items)); } if (sort !== false) { nodes = DomQuery.unique(self.toArray().concat(DomQuery.makeArray(items))); self.length = nodes.length; for (i = 0; i < nodes.length; i++) { self[i] = nodes[i]; } } else { push.apply(self, DomQuery.makeArray(items)); } return self; }
[ "function", "(", "items", ",", "sort", ")", "{", "var", "self", "=", "this", ",", "nodes", ",", "i", ";", "if", "(", "isString", "(", "items", ")", ")", "{", "return", "self", ".", "add", "(", "DomQuery", "(", "items", ")", ")", ";", "}", "if", "(", "sort", "!==", "false", ")", "{", "nodes", "=", "DomQuery", ".", "unique", "(", "self", ".", "toArray", "(", ")", ".", "concat", "(", "DomQuery", ".", "makeArray", "(", "items", ")", ")", ")", ";", "self", ".", "length", "=", "nodes", ".", "length", ";", "for", "(", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "self", "[", "i", "]", "=", "nodes", "[", "i", "]", ";", "}", "}", "else", "{", "push", ".", "apply", "(", "self", ",", "DomQuery", ".", "makeArray", "(", "items", ")", ")", ";", "}", "return", "self", ";", "}" ]
Adds new nodes to the set. @method add @param {Array/tinymce.core.dom.DomQuery} items Array of all nodes to add to set. @param {Boolean} sort Optional sort flag that enables sorting of elements. @return {tinymce.dom.DomQuery} New instance with nodes added.
[ "Adds", "new", "nodes", "to", "the", "set", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L4525-L4543
48,135
sadiqhabib/tinymce-dist
tinymce.full.js
function () { var self = this, node, i = this.length; while (i--) { node = self[i]; Event.clean(node); if (node.parentNode) { node.parentNode.removeChild(node); } } return this; }
javascript
function () { var self = this, node, i = this.length; while (i--) { node = self[i]; Event.clean(node); if (node.parentNode) { node.parentNode.removeChild(node); } } return this; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ",", "node", ",", "i", "=", "this", ".", "length", ";", "while", "(", "i", "--", ")", "{", "node", "=", "self", "[", "i", "]", ";", "Event", ".", "clean", "(", "node", ")", ";", "if", "(", "node", ".", "parentNode", ")", "{", "node", ".", "parentNode", ".", "removeChild", "(", "node", ")", ";", "}", "}", "return", "this", ";", "}" ]
Removes all nodes in set from the document. @method remove @return {tinymce.dom.DomQuery} Current set with the removed nodes.
[ "Removes", "all", "nodes", "in", "set", "from", "the", "document", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L4735-L4748
48,136
sadiqhabib/tinymce-dist
tinymce.full.js
function () { var self = this, node, i = this.length; while (i--) { node = self[i]; while (node.firstChild) { node.removeChild(node.firstChild); } } return this; }
javascript
function () { var self = this, node, i = this.length; while (i--) { node = self[i]; while (node.firstChild) { node.removeChild(node.firstChild); } } return this; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ",", "node", ",", "i", "=", "this", ".", "length", ";", "while", "(", "i", "--", ")", "{", "node", "=", "self", "[", "i", "]", ";", "while", "(", "node", ".", "firstChild", ")", "{", "node", ".", "removeChild", "(", "node", ".", "firstChild", ")", ";", "}", "}", "return", "this", ";", "}" ]
Empties all elements in set. @method empty @return {tinymce.dom.DomQuery} Current set with the empty nodes.
[ "Empties", "all", "elements", "in", "set", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L4756-L4767
48,137
sadiqhabib/tinymce-dist
tinymce.full.js
function (value) { var self = this, i; if (isDefined(value)) { i = self.length; try { while (i--) { self[i].innerHTML = value; } } catch (ex) { // Workaround for "Unknown runtime error" when DIV is added to P on IE DomQuery(self[i]).empty().append(value); } return self; } return self[0] ? self[0].innerHTML : ''; }
javascript
function (value) { var self = this, i; if (isDefined(value)) { i = self.length; try { while (i--) { self[i].innerHTML = value; } } catch (ex) { // Workaround for "Unknown runtime error" when DIV is added to P on IE DomQuery(self[i]).empty().append(value); } return self; } return self[0] ? self[0].innerHTML : ''; }
[ "function", "(", "value", ")", "{", "var", "self", "=", "this", ",", "i", ";", "if", "(", "isDefined", "(", "value", ")", ")", "{", "i", "=", "self", ".", "length", ";", "try", "{", "while", "(", "i", "--", ")", "{", "self", "[", "i", "]", ".", "innerHTML", "=", "value", ";", "}", "}", "catch", "(", "ex", ")", "{", "// Workaround for \"Unknown runtime error\" when DIV is added to P on IE", "DomQuery", "(", "self", "[", "i", "]", ")", ".", "empty", "(", ")", ".", "append", "(", "value", ")", ";", "}", "return", "self", ";", "}", "return", "self", "[", "0", "]", "?", "self", "[", "0", "]", ".", "innerHTML", ":", "''", ";", "}" ]
Sets or gets the HTML of the current set or first set node. @method html @param {String} value Optional innerHTML value to set on each element. @return {tinymce.dom.DomQuery/String} Current set or the innerHTML of the first element.
[ "Sets", "or", "gets", "the", "HTML", "of", "the", "current", "set", "or", "first", "set", "node", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L4776-L4795
48,138
sadiqhabib/tinymce-dist
tinymce.full.js
function (value) { var self = this, i; if (isDefined(value)) { i = self.length; while (i--) { if ("innerText" in self[i]) { self[i].innerText = value; } else { self[0].textContent = value; } } return self; } return self[0] ? (self[0].innerText || self[0].textContent) : ''; }
javascript
function (value) { var self = this, i; if (isDefined(value)) { i = self.length; while (i--) { if ("innerText" in self[i]) { self[i].innerText = value; } else { self[0].textContent = value; } } return self; } return self[0] ? (self[0].innerText || self[0].textContent) : ''; }
[ "function", "(", "value", ")", "{", "var", "self", "=", "this", ",", "i", ";", "if", "(", "isDefined", "(", "value", ")", ")", "{", "i", "=", "self", ".", "length", ";", "while", "(", "i", "--", ")", "{", "if", "(", "\"innerText\"", "in", "self", "[", "i", "]", ")", "{", "self", "[", "i", "]", ".", "innerText", "=", "value", ";", "}", "else", "{", "self", "[", "0", "]", ".", "textContent", "=", "value", ";", "}", "}", "return", "self", ";", "}", "return", "self", "[", "0", "]", "?", "(", "self", "[", "0", "]", ".", "innerText", "||", "self", "[", "0", "]", ".", "textContent", ")", ":", "''", ";", "}" ]
Sets or gets the text of the current set or first set node. @method text @param {String} value Optional innerText value to set on each element. @return {tinymce.dom.DomQuery/String} Current set or the innerText of the first element.
[ "Sets", "or", "gets", "the", "text", "of", "the", "current", "set", "or", "first", "set", "node", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L4804-L4821
48,139
sadiqhabib/tinymce-dist
tinymce.full.js
function () { var self = this; if (self[0] && self[0].parentNode) { return domManipulate(self, arguments, function (node) { this.parentNode.insertBefore(node, this); }); } return self; }
javascript
function () { var self = this; if (self[0] && self[0].parentNode) { return domManipulate(self, arguments, function (node) { this.parentNode.insertBefore(node, this); }); } return self; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "self", "[", "0", "]", "&&", "self", "[", "0", "]", ".", "parentNode", ")", "{", "return", "domManipulate", "(", "self", ",", "arguments", ",", "function", "(", "node", ")", "{", "this", ".", "parentNode", ".", "insertBefore", "(", "node", ",", "this", ")", ";", "}", ")", ";", "}", "return", "self", ";", "}" ]
Adds the specified elements before current set nodes. @method before @param {String/Element/Array/tinymce.dom.DomQuery} content Content to add before to each element in set. @return {tinymce.dom.DomQuery} Current set.
[ "Adds", "the", "specified", "elements", "before", "current", "set", "nodes", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L4862-L4872
48,140
sadiqhabib/tinymce-dist
tinymce.full.js
function () { var self = this; if (self[0] && self[0].parentNode) { return domManipulate(self, arguments, function (node) { this.parentNode.insertBefore(node, this.nextSibling); }, true); } return self; }
javascript
function () { var self = this; if (self[0] && self[0].parentNode) { return domManipulate(self, arguments, function (node) { this.parentNode.insertBefore(node, this.nextSibling); }, true); } return self; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "self", "[", "0", "]", "&&", "self", "[", "0", "]", ".", "parentNode", ")", "{", "return", "domManipulate", "(", "self", ",", "arguments", ",", "function", "(", "node", ")", "{", "this", ".", "parentNode", ".", "insertBefore", "(", "node", ",", "this", ".", "nextSibling", ")", ";", "}", ",", "true", ")", ";", "}", "return", "self", ";", "}" ]
Adds the specified elements after current set nodes. @method after @param {String/Element/Array/tinymce.dom.DomQuery} content Content to add after to each element in set. @return {tinymce.dom.DomQuery} Current set.
[ "Adds", "the", "specified", "elements", "after", "current", "set", "nodes", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L4881-L4891
48,141
sadiqhabib/tinymce-dist
tinymce.full.js
function (className, state) { var self = this; // Functions are not supported if (typeof className != 'string') { return self; } if (className.indexOf(' ') !== -1) { each(className.split(' '), function () { self.toggleClass(this, state); }); } else { self.each(function (index, node) { var existingClassName, classState; classState = hasClass(node, className); if (classState !== state) { existingClassName = node.className; if (classState) { node.className = trim((" " + existingClassName + " ").replace(' ' + className + ' ', ' ')); } else { node.className += existingClassName ? ' ' + className : className; } } }); } return self; }
javascript
function (className, state) { var self = this; // Functions are not supported if (typeof className != 'string') { return self; } if (className.indexOf(' ') !== -1) { each(className.split(' '), function () { self.toggleClass(this, state); }); } else { self.each(function (index, node) { var existingClassName, classState; classState = hasClass(node, className); if (classState !== state) { existingClassName = node.className; if (classState) { node.className = trim((" " + existingClassName + " ").replace(' ' + className + ' ', ' ')); } else { node.className += existingClassName ? ' ' + className : className; } } }); } return self; }
[ "function", "(", "className", ",", "state", ")", "{", "var", "self", "=", "this", ";", "// Functions are not supported", "if", "(", "typeof", "className", "!=", "'string'", ")", "{", "return", "self", ";", "}", "if", "(", "className", ".", "indexOf", "(", "' '", ")", "!==", "-", "1", ")", "{", "each", "(", "className", ".", "split", "(", "' '", ")", ",", "function", "(", ")", "{", "self", ".", "toggleClass", "(", "this", ",", "state", ")", ";", "}", ")", ";", "}", "else", "{", "self", ".", "each", "(", "function", "(", "index", ",", "node", ")", "{", "var", "existingClassName", ",", "classState", ";", "classState", "=", "hasClass", "(", "node", ",", "className", ")", ";", "if", "(", "classState", "!==", "state", ")", "{", "existingClassName", "=", "node", ".", "className", ";", "if", "(", "classState", ")", "{", "node", ".", "className", "=", "trim", "(", "(", "\" \"", "+", "existingClassName", "+", "\" \"", ")", ".", "replace", "(", "' '", "+", "className", "+", "' '", ",", "' '", ")", ")", ";", "}", "else", "{", "node", ".", "className", "+=", "existingClassName", "?", "' '", "+", "className", ":", "className", ";", "}", "}", "}", ")", ";", "}", "return", "self", ";", "}" ]
Toggles the specified class name on the current set elements. @method toggleClass @param {String} className Class name to add/remove. @param {Boolean} state Optional state to toggle on/off. @return {tinymce.dom.DomQuery} Current set.
[ "Toggles", "the", "specified", "class", "name", "on", "the", "current", "set", "elements", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L5026-L5056
48,142
sadiqhabib/tinymce-dist
tinymce.full.js
function (name) { return this.each(function () { if (typeof name == 'object') { Event.fire(this, name.type, name); } else { Event.fire(this, name); } }); }
javascript
function (name) { return this.each(function () { if (typeof name == 'object') { Event.fire(this, name.type, name); } else { Event.fire(this, name); } }); }
[ "function", "(", "name", ")", "{", "return", "this", ".", "each", "(", "function", "(", ")", "{", "if", "(", "typeof", "name", "==", "'object'", ")", "{", "Event", ".", "fire", "(", "this", ",", "name", ".", "type", ",", "name", ")", ";", "}", "else", "{", "Event", ".", "fire", "(", "this", ",", "name", ")", ";", "}", "}", ")", ";", "}" ]
Triggers the specified event by name or event object. @method trigger @param {String/Object} name Name of the event to trigger or event object. @return {tinymce.dom.DomQuery} Current set.
[ "Triggers", "the", "specified", "event", "by", "name", "or", "event", "object", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L5116-L5124
48,143
sadiqhabib/tinymce-dist
tinymce.full.js
function (selector) { var i, l, ret = []; for (i = 0, l = this.length; i < l; i++) { DomQuery.find(selector, this[i], ret); } return DomQuery(ret); }
javascript
function (selector) { var i, l, ret = []; for (i = 0, l = this.length; i < l; i++) { DomQuery.find(selector, this[i], ret); } return DomQuery(ret); }
[ "function", "(", "selector", ")", "{", "var", "i", ",", "l", ",", "ret", "=", "[", "]", ";", "for", "(", "i", "=", "0", ",", "l", "=", "this", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "DomQuery", ".", "find", "(", "selector", ",", "this", "[", "i", "]", ",", "ret", ")", ";", "}", "return", "DomQuery", "(", "ret", ")", ";", "}" ]
Finds elements by the specified selector for each element in set. @method find @param {String} selector Selector to find elements by. @return {tinymce.dom.DomQuery} Set with matches elements.
[ "Finds", "elements", "by", "the", "specified", "selector", "for", "each", "element", "in", "set", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L5196-L5204
48,144
sadiqhabib/tinymce-dist
tinymce.full.js
function (selector) { if (typeof selector == 'function') { return DomQuery(grep(this.toArray(), function (item, i) { return selector(i, item); })); } return DomQuery(DomQuery.filter(selector, this.toArray())); }
javascript
function (selector) { if (typeof selector == 'function') { return DomQuery(grep(this.toArray(), function (item, i) { return selector(i, item); })); } return DomQuery(DomQuery.filter(selector, this.toArray())); }
[ "function", "(", "selector", ")", "{", "if", "(", "typeof", "selector", "==", "'function'", ")", "{", "return", "DomQuery", "(", "grep", "(", "this", ".", "toArray", "(", ")", ",", "function", "(", "item", ",", "i", ")", "{", "return", "selector", "(", "i", ",", "item", ")", ";", "}", ")", ")", ";", "}", "return", "DomQuery", "(", "DomQuery", ".", "filter", "(", "selector", ",", "this", ".", "toArray", "(", ")", ")", ")", ";", "}" ]
Filters the current set with the specified selector. @method filter @param {String/function} selector Selector to filter elements by. @return {tinymce.dom.DomQuery} Set with filtered elements.
[ "Filters", "the", "current", "set", "with", "the", "specified", "selector", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L5213-L5221
48,145
sadiqhabib/tinymce-dist
tinymce.full.js
function (selector) { var result = []; if (selector instanceof DomQuery) { selector = selector[0]; } this.each(function (i, node) { while (node) { if (typeof selector == 'string' && DomQuery(node).is(selector)) { result.push(node); break; } else if (node == selector) { result.push(node); break; } node = node.parentNode; } }); return DomQuery(result); }
javascript
function (selector) { var result = []; if (selector instanceof DomQuery) { selector = selector[0]; } this.each(function (i, node) { while (node) { if (typeof selector == 'string' && DomQuery(node).is(selector)) { result.push(node); break; } else if (node == selector) { result.push(node); break; } node = node.parentNode; } }); return DomQuery(result); }
[ "function", "(", "selector", ")", "{", "var", "result", "=", "[", "]", ";", "if", "(", "selector", "instanceof", "DomQuery", ")", "{", "selector", "=", "selector", "[", "0", "]", ";", "}", "this", ".", "each", "(", "function", "(", "i", ",", "node", ")", "{", "while", "(", "node", ")", "{", "if", "(", "typeof", "selector", "==", "'string'", "&&", "DomQuery", "(", "node", ")", ".", "is", "(", "selector", ")", ")", "{", "result", ".", "push", "(", "node", ")", ";", "break", ";", "}", "else", "if", "(", "node", "==", "selector", ")", "{", "result", ".", "push", "(", "node", ")", ";", "break", ";", "}", "node", "=", "node", ".", "parentNode", ";", "}", "}", ")", ";", "return", "DomQuery", "(", "result", ")", ";", "}" ]
Gets the current node or any parent matching the specified selector. @method closest @param {String/Element/tinymce.dom.DomQuery} selector Selector or element to find. @return {tinymce.dom.DomQuery} Set with closest elements.
[ "Gets", "the", "current", "node", "or", "any", "parent", "matching", "the", "specified", "selector", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L5230-L5252
48,146
sadiqhabib/tinymce-dist
tinymce.full.js
function (node) { return Tools.toArray((node.nodeName === "iframe" ? node.contentDocument || node.contentWindow.document : node).childNodes); }
javascript
function (node) { return Tools.toArray((node.nodeName === "iframe" ? node.contentDocument || node.contentWindow.document : node).childNodes); }
[ "function", "(", "node", ")", "{", "return", "Tools", ".", "toArray", "(", "(", "node", ".", "nodeName", "===", "\"iframe\"", "?", "node", ".", "contentDocument", "||", "node", ".", "contentWindow", ".", "document", ":", "node", ")", ".", "childNodes", ")", ";", "}" ]
Returns all child nodes matching the optional selector. @method contents @param {Element/tinymce.dom.DomQuery} node Node to get the contents of. @return {tinymce.dom.DomQuery} New DomQuery instance with all matching elements.
[ "Returns", "all", "child", "nodes", "matching", "the", "optional", "selector", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L5539-L5541
48,147
sadiqhabib/tinymce-dist
tinymce.full.js
nativeDecode
function nativeDecode(text) { var elm; elm = document.createElement("div"); elm.innerHTML = text; return elm.textContent || elm.innerText || text; }
javascript
function nativeDecode(text) { var elm; elm = document.createElement("div"); elm.innerHTML = text; return elm.textContent || elm.innerText || text; }
[ "function", "nativeDecode", "(", "text", ")", "{", "var", "elm", ";", "elm", "=", "document", ".", "createElement", "(", "\"div\"", ")", ";", "elm", ".", "innerHTML", "=", "text", ";", "return", "elm", ".", "textContent", "||", "elm", ".", "innerText", "||", "text", ";", "}" ]
Decodes text by using the browser
[ "Decodes", "text", "by", "using", "the", "browser" ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L6339-L6346
48,148
sadiqhabib/tinymce-dist
tinymce.full.js
function (text, attr) { return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function (chr) { // Multi byte sequence convert it to a single entity if (chr.length > 1) { return '&#' + (((chr.charCodeAt(0) - 0xD800) * 0x400) + (chr.charCodeAt(1) - 0xDC00) + 0x10000) + ';'; } return baseEntities[chr] || '&#' + chr.charCodeAt(0) + ';'; }); }
javascript
function (text, attr) { return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function (chr) { // Multi byte sequence convert it to a single entity if (chr.length > 1) { return '&#' + (((chr.charCodeAt(0) - 0xD800) * 0x400) + (chr.charCodeAt(1) - 0xDC00) + 0x10000) + ';'; } return baseEntities[chr] || '&#' + chr.charCodeAt(0) + ';'; }); }
[ "function", "(", "text", ",", "attr", ")", "{", "return", "text", ".", "replace", "(", "attr", "?", "attrsCharsRegExp", ":", "textCharsRegExp", ",", "function", "(", "chr", ")", "{", "// Multi byte sequence convert it to a single entity", "if", "(", "chr", ".", "length", ">", "1", ")", "{", "return", "'&#'", "+", "(", "(", "(", "chr", ".", "charCodeAt", "(", "0", ")", "-", "0xD800", ")", "*", "0x400", ")", "+", "(", "chr", ".", "charCodeAt", "(", "1", ")", "-", "0xDC00", ")", "+", "0x10000", ")", "+", "';'", ";", "}", "return", "baseEntities", "[", "chr", "]", "||", "'&#'", "+", "chr", ".", "charCodeAt", "(", "0", ")", "+", "';'", ";", "}", ")", ";", "}" ]
Encodes the specified string using numeric entities. The core entities will be encoded as named ones but all non lower ascii characters will be encoded into numeric entities. @method encodeNumeric @param {String} text Text to encode. @param {Boolean} attr Optional flag to specify if the text is attribute contents. @return {String} Entity encoded text.
[ "Encodes", "the", "specified", "string", "using", "numeric", "entities", ".", "The", "core", "entities", "will", "be", "encoded", "as", "named", "ones", "but", "all", "non", "lower", "ascii", "characters", "will", "be", "encoded", "into", "numeric", "entities", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L6439-L6448
48,149
sadiqhabib/tinymce-dist
tinymce.full.js
function (text) { return text.replace(entityRegExp, function (all, numeric) { if (numeric) { if (numeric.charAt(0).toLowerCase() === 'x') { numeric = parseInt(numeric.substr(1), 16); } else { numeric = parseInt(numeric, 10); } // Support upper UTF if (numeric > 0xFFFF) { numeric -= 0x10000; return String.fromCharCode(0xD800 + (numeric >> 10), 0xDC00 + (numeric & 0x3FF)); } return asciiMap[numeric] || String.fromCharCode(numeric); } return reverseEntities[all] || namedEntities[all] || nativeDecode(all); }); }
javascript
function (text) { return text.replace(entityRegExp, function (all, numeric) { if (numeric) { if (numeric.charAt(0).toLowerCase() === 'x') { numeric = parseInt(numeric.substr(1), 16); } else { numeric = parseInt(numeric, 10); } // Support upper UTF if (numeric > 0xFFFF) { numeric -= 0x10000; return String.fromCharCode(0xD800 + (numeric >> 10), 0xDC00 + (numeric & 0x3FF)); } return asciiMap[numeric] || String.fromCharCode(numeric); } return reverseEntities[all] || namedEntities[all] || nativeDecode(all); }); }
[ "function", "(", "text", ")", "{", "return", "text", ".", "replace", "(", "entityRegExp", ",", "function", "(", "all", ",", "numeric", ")", "{", "if", "(", "numeric", ")", "{", "if", "(", "numeric", ".", "charAt", "(", "0", ")", ".", "toLowerCase", "(", ")", "===", "'x'", ")", "{", "numeric", "=", "parseInt", "(", "numeric", ".", "substr", "(", "1", ")", ",", "16", ")", ";", "}", "else", "{", "numeric", "=", "parseInt", "(", "numeric", ",", "10", ")", ";", "}", "// Support upper UTF", "if", "(", "numeric", ">", "0xFFFF", ")", "{", "numeric", "-=", "0x10000", ";", "return", "String", ".", "fromCharCode", "(", "0xD800", "+", "(", "numeric", ">>", "10", ")", ",", "0xDC00", "+", "(", "numeric", "&", "0x3FF", ")", ")", ";", "}", "return", "asciiMap", "[", "numeric", "]", "||", "String", ".", "fromCharCode", "(", "numeric", ")", ";", "}", "return", "reverseEntities", "[", "all", "]", "||", "namedEntities", "[", "all", "]", "||", "nativeDecode", "(", "all", ")", ";", "}", ")", ";", "}" ]
Decodes the specified string, this will replace entities with raw UTF characters. @method decode @param {String} text Text to entity decode. @return {String} Entity decoded string.
[ "Decodes", "the", "specified", "string", "this", "will", "replace", "entities", "with", "raw", "UTF", "characters", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L6523-L6544
48,150
sadiqhabib/tinymce-dist
tinymce.full.js
wait
function wait(testCallback, waitCallback) { if (!testCallback()) { // Wait for timeout if ((new Date().getTime()) - startTime < maxLoadTime) { Delay.setTimeout(waitCallback); } else { failed(); } } }
javascript
function wait(testCallback, waitCallback) { if (!testCallback()) { // Wait for timeout if ((new Date().getTime()) - startTime < maxLoadTime) { Delay.setTimeout(waitCallback); } else { failed(); } } }
[ "function", "wait", "(", "testCallback", ",", "waitCallback", ")", "{", "if", "(", "!", "testCallback", "(", ")", ")", "{", "// Wait for timeout", "if", "(", "(", "new", "Date", "(", ")", ".", "getTime", "(", ")", ")", "-", "startTime", "<", "maxLoadTime", ")", "{", "Delay", ".", "setTimeout", "(", "waitCallback", ")", ";", "}", "else", "{", "failed", "(", ")", ";", "}", "}", "}" ]
Calls the waitCallback until the test returns true or the timeout occurs
[ "Calls", "the", "waitCallback", "until", "the", "test", "returns", "true", "or", "the", "timeout", "occurs" ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L7418-L7427
48,151
sadiqhabib/tinymce-dist
tinymce.full.js
waitForGeckoLinkLoaded
function waitForGeckoLinkLoaded() { wait(function () { try { // Accessing the cssRules will throw an exception until the CSS file is loaded var cssRules = style.sheet.cssRules; passed(); return !!cssRules; } catch (ex) { // Ignore } }, waitForGeckoLinkLoaded); }
javascript
function waitForGeckoLinkLoaded() { wait(function () { try { // Accessing the cssRules will throw an exception until the CSS file is loaded var cssRules = style.sheet.cssRules; passed(); return !!cssRules; } catch (ex) { // Ignore } }, waitForGeckoLinkLoaded); }
[ "function", "waitForGeckoLinkLoaded", "(", ")", "{", "wait", "(", "function", "(", ")", "{", "try", "{", "// Accessing the cssRules will throw an exception until the CSS file is loaded", "var", "cssRules", "=", "style", ".", "sheet", ".", "cssRules", ";", "passed", "(", ")", ";", "return", "!", "!", "cssRules", ";", "}", "catch", "(", "ex", ")", "{", "// Ignore", "}", "}", ",", "waitForGeckoLinkLoaded", ")", ";", "}" ]
Workaround for older Geckos that doesn't have any onload event for StyleSheets
[ "Workaround", "for", "older", "Geckos", "that", "doesn", "t", "have", "any", "onload", "event", "for", "StyleSheets" ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L7447-L7458
48,152
sadiqhabib/tinymce-dist
tinymce.full.js
DOMUtils
function DOMUtils(doc, settings) { var self = this, blockElementsMap; self.doc = doc; self.win = window; self.files = {}; self.counter = 0; self.stdMode = !isIE || doc.documentMode >= 8; self.boxModel = !isIE || doc.compatMode == "CSS1Compat" || self.stdMode; self.styleSheetLoader = new StyleSheetLoader(doc); self.boundEvents = []; self.settings = settings = settings || {}; self.schema = settings.schema; self.styles = new Styles({ url_converter: settings.url_converter, url_converter_scope: settings.url_converter_scope }, settings.schema); self.fixDoc(doc); self.events = settings.ownEvents ? new EventUtils(settings.proxy) : EventUtils.Event; self.attrHooks = setupAttrHooks(self, settings); blockElementsMap = settings.schema ? settings.schema.getBlockElements() : {}; self.$ = $.overrideDefaults(function () { return { context: doc, element: self.getRoot() }; }); /** * Returns true/false if the specified element is a block element or not. * * @method isBlock * @param {Node/String} node Element/Node to check. * @return {Boolean} True/False state if the node is a block element or not. */ self.isBlock = function (node) { // Fix for #5446 if (!node) { return false; } // This function is called in module pattern style since it might be executed with the wrong this scope var type = node.nodeType; // If it's a node then check the type and use the nodeName if (type) { return !!(type === 1 && blockElementsMap[node.nodeName]); } return !!blockElementsMap[node]; }; }
javascript
function DOMUtils(doc, settings) { var self = this, blockElementsMap; self.doc = doc; self.win = window; self.files = {}; self.counter = 0; self.stdMode = !isIE || doc.documentMode >= 8; self.boxModel = !isIE || doc.compatMode == "CSS1Compat" || self.stdMode; self.styleSheetLoader = new StyleSheetLoader(doc); self.boundEvents = []; self.settings = settings = settings || {}; self.schema = settings.schema; self.styles = new Styles({ url_converter: settings.url_converter, url_converter_scope: settings.url_converter_scope }, settings.schema); self.fixDoc(doc); self.events = settings.ownEvents ? new EventUtils(settings.proxy) : EventUtils.Event; self.attrHooks = setupAttrHooks(self, settings); blockElementsMap = settings.schema ? settings.schema.getBlockElements() : {}; self.$ = $.overrideDefaults(function () { return { context: doc, element: self.getRoot() }; }); /** * Returns true/false if the specified element is a block element or not. * * @method isBlock * @param {Node/String} node Element/Node to check. * @return {Boolean} True/False state if the node is a block element or not. */ self.isBlock = function (node) { // Fix for #5446 if (!node) { return false; } // This function is called in module pattern style since it might be executed with the wrong this scope var type = node.nodeType; // If it's a node then check the type and use the nodeName if (type) { return !!(type === 1 && blockElementsMap[node.nodeName]); } return !!blockElementsMap[node]; }; }
[ "function", "DOMUtils", "(", "doc", ",", "settings", ")", "{", "var", "self", "=", "this", ",", "blockElementsMap", ";", "self", ".", "doc", "=", "doc", ";", "self", ".", "win", "=", "window", ";", "self", ".", "files", "=", "{", "}", ";", "self", ".", "counter", "=", "0", ";", "self", ".", "stdMode", "=", "!", "isIE", "||", "doc", ".", "documentMode", ">=", "8", ";", "self", ".", "boxModel", "=", "!", "isIE", "||", "doc", ".", "compatMode", "==", "\"CSS1Compat\"", "||", "self", ".", "stdMode", ";", "self", ".", "styleSheetLoader", "=", "new", "StyleSheetLoader", "(", "doc", ")", ";", "self", ".", "boundEvents", "=", "[", "]", ";", "self", ".", "settings", "=", "settings", "=", "settings", "||", "{", "}", ";", "self", ".", "schema", "=", "settings", ".", "schema", ";", "self", ".", "styles", "=", "new", "Styles", "(", "{", "url_converter", ":", "settings", ".", "url_converter", ",", "url_converter_scope", ":", "settings", ".", "url_converter_scope", "}", ",", "settings", ".", "schema", ")", ";", "self", ".", "fixDoc", "(", "doc", ")", ";", "self", ".", "events", "=", "settings", ".", "ownEvents", "?", "new", "EventUtils", "(", "settings", ".", "proxy", ")", ":", "EventUtils", ".", "Event", ";", "self", ".", "attrHooks", "=", "setupAttrHooks", "(", "self", ",", "settings", ")", ";", "blockElementsMap", "=", "settings", ".", "schema", "?", "settings", ".", "schema", ".", "getBlockElements", "(", ")", ":", "{", "}", ";", "self", ".", "$", "=", "$", ".", "overrideDefaults", "(", "function", "(", ")", "{", "return", "{", "context", ":", "doc", ",", "element", ":", "self", ".", "getRoot", "(", ")", "}", ";", "}", ")", ";", "/**\n * Returns true/false if the specified element is a block element or not.\n *\n * @method isBlock\n * @param {Node/String} node Element/Node to check.\n * @return {Boolean} True/False state if the node is a block element or not.\n */", "self", ".", "isBlock", "=", "function", "(", "node", ")", "{", "// Fix for #5446", "if", "(", "!", "node", ")", "{", "return", "false", ";", "}", "// This function is called in module pattern style since it might be executed with the wrong this scope", "var", "type", "=", "node", ".", "nodeType", ";", "// If it's a node then check the type and use the nodeName", "if", "(", "type", ")", "{", "return", "!", "!", "(", "type", "===", "1", "&&", "blockElementsMap", "[", "node", ".", "nodeName", "]", ")", ";", "}", "return", "!", "!", "blockElementsMap", "[", "node", "]", ";", "}", ";", "}" ]
Constructs a new DOMUtils instance. Consult the Wiki for more details on settings etc for this class. @constructor @method DOMUtils @param {Document} doc Document reference to bind the utility class to. @param {settings} settings Optional settings collection.
[ "Constructs", "a", "new", "DOMUtils", "instance", ".", "Consult", "the", "Wiki", "for", "more", "details", "on", "settings", "etc", "for", "this", "class", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L7668-L7720
48,153
sadiqhabib/tinymce-dist
tinymce.full.js
function (win) { var doc, rootElm; win = !win ? this.win : win; doc = win.document; rootElm = this.boxModel ? doc.documentElement : doc.body; // Returns viewport size excluding scrollbars return { x: win.pageXOffset || rootElm.scrollLeft, y: win.pageYOffset || rootElm.scrollTop, w: win.innerWidth || rootElm.clientWidth, h: win.innerHeight || rootElm.clientHeight }; }
javascript
function (win) { var doc, rootElm; win = !win ? this.win : win; doc = win.document; rootElm = this.boxModel ? doc.documentElement : doc.body; // Returns viewport size excluding scrollbars return { x: win.pageXOffset || rootElm.scrollLeft, y: win.pageYOffset || rootElm.scrollTop, w: win.innerWidth || rootElm.clientWidth, h: win.innerHeight || rootElm.clientHeight }; }
[ "function", "(", "win", ")", "{", "var", "doc", ",", "rootElm", ";", "win", "=", "!", "win", "?", "this", ".", "win", ":", "win", ";", "doc", "=", "win", ".", "document", ";", "rootElm", "=", "this", ".", "boxModel", "?", "doc", ".", "documentElement", ":", "doc", ".", "body", ";", "// Returns viewport size excluding scrollbars", "return", "{", "x", ":", "win", ".", "pageXOffset", "||", "rootElm", ".", "scrollLeft", ",", "y", ":", "win", ".", "pageYOffset", "||", "rootElm", ".", "scrollTop", ",", "w", ":", "win", ".", "innerWidth", "||", "rootElm", ".", "clientWidth", ",", "h", ":", "win", ".", "innerHeight", "||", "rootElm", ".", "clientHeight", "}", ";", "}" ]
Returns the viewport of the window. @method getViewPort @param {Window} win Optional window to get viewport of. @return {Object} Viewport object with fields x, y, w and h.
[ "Returns", "the", "viewport", "of", "the", "window", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L7798-L7812
48,154
sadiqhabib/tinymce-dist
tinymce.full.js
function (elm) { var self = this, pos, size; elm = self.get(elm); pos = self.getPos(elm); size = self.getSize(elm); return { x: pos.x, y: pos.y, w: size.w, h: size.h }; }
javascript
function (elm) { var self = this, pos, size; elm = self.get(elm); pos = self.getPos(elm); size = self.getSize(elm); return { x: pos.x, y: pos.y, w: size.w, h: size.h }; }
[ "function", "(", "elm", ")", "{", "var", "self", "=", "this", ",", "pos", ",", "size", ";", "elm", "=", "self", ".", "get", "(", "elm", ")", ";", "pos", "=", "self", ".", "getPos", "(", "elm", ")", ";", "size", "=", "self", ".", "getSize", "(", "elm", ")", ";", "return", "{", "x", ":", "pos", ".", "x", ",", "y", ":", "pos", ".", "y", ",", "w", ":", "size", ".", "w", ",", "h", ":", "size", ".", "h", "}", ";", "}" ]
Returns the rectangle for a specific element. @method getRect @param {Element/String} elm Element object or element ID to get rectangle from. @return {object} Rectangle for specified element object with x, y, w, h fields.
[ "Returns", "the", "rectangle", "for", "a", "specific", "element", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L7821-L7832
48,155
sadiqhabib/tinymce-dist
tinymce.full.js
function (elm) { var self = this, w, h; elm = self.get(elm); w = self.getStyle(elm, 'width'); h = self.getStyle(elm, 'height'); // Non pixel value, then force offset/clientWidth if (w.indexOf('px') === -1) { w = 0; } // Non pixel value, then force offset/clientWidth if (h.indexOf('px') === -1) { h = 0; } return { w: parseInt(w, 10) || elm.offsetWidth || elm.clientWidth, h: parseInt(h, 10) || elm.offsetHeight || elm.clientHeight }; }
javascript
function (elm) { var self = this, w, h; elm = self.get(elm); w = self.getStyle(elm, 'width'); h = self.getStyle(elm, 'height'); // Non pixel value, then force offset/clientWidth if (w.indexOf('px') === -1) { w = 0; } // Non pixel value, then force offset/clientWidth if (h.indexOf('px') === -1) { h = 0; } return { w: parseInt(w, 10) || elm.offsetWidth || elm.clientWidth, h: parseInt(h, 10) || elm.offsetHeight || elm.clientHeight }; }
[ "function", "(", "elm", ")", "{", "var", "self", "=", "this", ",", "w", ",", "h", ";", "elm", "=", "self", ".", "get", "(", "elm", ")", ";", "w", "=", "self", ".", "getStyle", "(", "elm", ",", "'width'", ")", ";", "h", "=", "self", ".", "getStyle", "(", "elm", ",", "'height'", ")", ";", "// Non pixel value, then force offset/clientWidth", "if", "(", "w", ".", "indexOf", "(", "'px'", ")", "===", "-", "1", ")", "{", "w", "=", "0", ";", "}", "// Non pixel value, then force offset/clientWidth", "if", "(", "h", ".", "indexOf", "(", "'px'", ")", "===", "-", "1", ")", "{", "h", "=", "0", ";", "}", "return", "{", "w", ":", "parseInt", "(", "w", ",", "10", ")", "||", "elm", ".", "offsetWidth", "||", "elm", ".", "clientWidth", ",", "h", ":", "parseInt", "(", "h", ",", "10", ")", "||", "elm", ".", "offsetHeight", "||", "elm", ".", "clientHeight", "}", ";", "}" ]
Returns the size dimensions of the specified element. @method getSize @param {Element/String} elm Element object or element ID to get rectangle from. @return {object} Rectangle for specified element object with w, h fields.
[ "Returns", "the", "size", "dimensions", "of", "the", "specified", "element", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L7841-L7862
48,156
sadiqhabib/tinymce-dist
tinymce.full.js
function (node, selector, root, collect) { var self = this, selectorVal, result = []; node = self.get(node); collect = collect === undefined; // Default root on inline mode root = root || (self.getRoot().nodeName != 'BODY' ? self.getRoot().parentNode : null); // Wrap node name as func if (is(selector, 'string')) { selectorVal = selector; if (selector === '*') { selector = function (node) { return node.nodeType == 1; }; } else { selector = function (node) { return self.is(node, selectorVal); }; } } while (node) { if (node == root || !node.nodeType || node.nodeType === 9) { break; } if (!selector || selector(node)) { if (collect) { result.push(node); } else { return node; } } node = node.parentNode; } return collect ? result : null; }
javascript
function (node, selector, root, collect) { var self = this, selectorVal, result = []; node = self.get(node); collect = collect === undefined; // Default root on inline mode root = root || (self.getRoot().nodeName != 'BODY' ? self.getRoot().parentNode : null); // Wrap node name as func if (is(selector, 'string')) { selectorVal = selector; if (selector === '*') { selector = function (node) { return node.nodeType == 1; }; } else { selector = function (node) { return self.is(node, selectorVal); }; } } while (node) { if (node == root || !node.nodeType || node.nodeType === 9) { break; } if (!selector || selector(node)) { if (collect) { result.push(node); } else { return node; } } node = node.parentNode; } return collect ? result : null; }
[ "function", "(", "node", ",", "selector", ",", "root", ",", "collect", ")", "{", "var", "self", "=", "this", ",", "selectorVal", ",", "result", "=", "[", "]", ";", "node", "=", "self", ".", "get", "(", "node", ")", ";", "collect", "=", "collect", "===", "undefined", ";", "// Default root on inline mode", "root", "=", "root", "||", "(", "self", ".", "getRoot", "(", ")", ".", "nodeName", "!=", "'BODY'", "?", "self", ".", "getRoot", "(", ")", ".", "parentNode", ":", "null", ")", ";", "// Wrap node name as func", "if", "(", "is", "(", "selector", ",", "'string'", ")", ")", "{", "selectorVal", "=", "selector", ";", "if", "(", "selector", "===", "'*'", ")", "{", "selector", "=", "function", "(", "node", ")", "{", "return", "node", ".", "nodeType", "==", "1", ";", "}", ";", "}", "else", "{", "selector", "=", "function", "(", "node", ")", "{", "return", "self", ".", "is", "(", "node", ",", "selectorVal", ")", ";", "}", ";", "}", "}", "while", "(", "node", ")", "{", "if", "(", "node", "==", "root", "||", "!", "node", ".", "nodeType", "||", "node", ".", "nodeType", "===", "9", ")", "{", "break", ";", "}", "if", "(", "!", "selector", "||", "selector", "(", "node", ")", ")", "{", "if", "(", "collect", ")", "{", "result", ".", "push", "(", "node", ")", ";", "}", "else", "{", "return", "node", ";", "}", "}", "node", "=", "node", ".", "parentNode", ";", "}", "return", "collect", "?", "result", ":", "null", ";", "}" ]
Returns a node list of all parents matching the specified selector function or pattern. If the function then returns true indicating that it has found what it was looking for and that node will be collected. @method getParents @param {Node/String} node DOM node to search parents on or ID string. @param {function} selector Selection function to execute on each node or CSS pattern. @param {Node} root Optional root element, never go beyond this point. @return {Array} Array of nodes or null if it wasn't found.
[ "Returns", "a", "node", "list", "of", "all", "parents", "matching", "the", "specified", "selector", "function", "or", "pattern", ".", "If", "the", "function", "then", "returns", "true", "indicating", "that", "it", "has", "found", "what", "it", "was", "looking", "for", "and", "that", "node", "will", "be", "collected", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L7890-L7931
48,157
sadiqhabib/tinymce-dist
tinymce.full.js
function (elm) { var name; if (elm && this.doc && typeof elm == 'string') { name = elm; elm = this.doc.getElementById(elm); // IE and Opera returns meta elements when they match the specified input ID, but getElementsByName seems to do the trick if (elm && elm.id !== name) { return this.doc.getElementsByName(name)[1]; } } return elm; }
javascript
function (elm) { var name; if (elm && this.doc && typeof elm == 'string') { name = elm; elm = this.doc.getElementById(elm); // IE and Opera returns meta elements when they match the specified input ID, but getElementsByName seems to do the trick if (elm && elm.id !== name) { return this.doc.getElementsByName(name)[1]; } } return elm; }
[ "function", "(", "elm", ")", "{", "var", "name", ";", "if", "(", "elm", "&&", "this", ".", "doc", "&&", "typeof", "elm", "==", "'string'", ")", "{", "name", "=", "elm", ";", "elm", "=", "this", ".", "doc", ".", "getElementById", "(", "elm", ")", ";", "// IE and Opera returns meta elements when they match the specified input ID, but getElementsByName seems to do the trick", "if", "(", "elm", "&&", "elm", ".", "id", "!==", "name", ")", "{", "return", "this", ".", "doc", ".", "getElementsByName", "(", "name", ")", "[", "1", "]", ";", "}", "}", "return", "elm", ";", "}" ]
Returns the specified element by ID or the input element if it isn't a string. @method get @param {String/Element} n Element id to look for or element to just pass though. @return {Element} Element matching the specified id or null if it wasn't found.
[ "Returns", "the", "specified", "element", "by", "ID", "or", "the", "input", "element", "if", "it", "isn", "t", "a", "string", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L7940-L7954
48,158
sadiqhabib/tinymce-dist
tinymce.full.js
function (name, attrs, html) { return this.add(this.doc.createElement(name), name, attrs, html, 1); }
javascript
function (name, attrs, html) { return this.add(this.doc.createElement(name), name, attrs, html, 1); }
[ "function", "(", "name", ",", "attrs", ",", "html", ")", "{", "return", "this", ".", "add", "(", "this", ".", "doc", ".", "createElement", "(", "name", ")", ",", "name", ",", "attrs", ",", "html", ",", "1", ")", ";", "}" ]
Creates a new element. @method create @param {String} name Name of new element. @param {Object} attrs Optional object name/value collection with element attributes. @param {String} html Optional HTML string to set as inner HTML of the element. @return {Element} HTML DOM node element that got created. @example // Adds an element where the caret/selection is in the active editor var el = tinymce.activeEditor.dom.create('div', {id: 'test', 'class': 'myclass'}, 'some content'); tinymce.activeEditor.selection.setNode(el);
[ "Creates", "a", "new", "element", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8099-L8101
48,159
sadiqhabib/tinymce-dist
tinymce.full.js
function (name, attrs, html) { var outHtml = '', key; outHtml += '<' + name; for (key in attrs) { if (attrs.hasOwnProperty(key) && attrs[key] !== null && typeof attrs[key] != 'undefined') { outHtml += ' ' + key + '="' + this.encode(attrs[key]) + '"'; } } // A call to tinymce.is doesn't work for some odd reason on IE9 possible bug inside their JS runtime if (typeof html != "undefined") { return outHtml + '>' + html + '</' + name + '>'; } return outHtml + ' />'; }
javascript
function (name, attrs, html) { var outHtml = '', key; outHtml += '<' + name; for (key in attrs) { if (attrs.hasOwnProperty(key) && attrs[key] !== null && typeof attrs[key] != 'undefined') { outHtml += ' ' + key + '="' + this.encode(attrs[key]) + '"'; } } // A call to tinymce.is doesn't work for some odd reason on IE9 possible bug inside their JS runtime if (typeof html != "undefined") { return outHtml + '>' + html + '</' + name + '>'; } return outHtml + ' />'; }
[ "function", "(", "name", ",", "attrs", ",", "html", ")", "{", "var", "outHtml", "=", "''", ",", "key", ";", "outHtml", "+=", "'<'", "+", "name", ";", "for", "(", "key", "in", "attrs", ")", "{", "if", "(", "attrs", ".", "hasOwnProperty", "(", "key", ")", "&&", "attrs", "[", "key", "]", "!==", "null", "&&", "typeof", "attrs", "[", "key", "]", "!=", "'undefined'", ")", "{", "outHtml", "+=", "' '", "+", "key", "+", "'=\"'", "+", "this", ".", "encode", "(", "attrs", "[", "key", "]", ")", "+", "'\"'", ";", "}", "}", "// A call to tinymce.is doesn't work for some odd reason on IE9 possible bug inside their JS runtime", "if", "(", "typeof", "html", "!=", "\"undefined\"", ")", "{", "return", "outHtml", "+", "'>'", "+", "html", "+", "'</'", "+", "name", "+", "'>'", ";", "}", "return", "outHtml", "+", "' />'", ";", "}" ]
Creates HTML string for element. The element will be closed unless an empty inner HTML string is passed in. @method createHTML @param {String} name Name of new element. @param {Object} attrs Optional object name/value collection with element attributes. @param {String} html Optional HTML string to set as inner HTML of the element. @return {String} String with new HTML element, for example: <a href="#">test</a>. @example // Creates a html chunk and inserts it at the current selection/caret location tinymce.activeEditor.selection.setContent(tinymce.activeEditor.dom.createHTML('a', {href: 'test.html'}, 'some line'));
[ "Creates", "HTML", "string", "for", "element", ".", "The", "element", "will", "be", "closed", "unless", "an", "empty", "inner", "HTML", "string", "is", "passed", "in", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8115-L8132
48,160
sadiqhabib/tinymce-dist
tinymce.full.js
function (elm, name, value) { elm = this.$$(elm).css(name, value); if (this.settings.update_styles) { updateInternalStyleAttr(this, elm); } }
javascript
function (elm, name, value) { elm = this.$$(elm).css(name, value); if (this.settings.update_styles) { updateInternalStyleAttr(this, elm); } }
[ "function", "(", "elm", ",", "name", ",", "value", ")", "{", "elm", "=", "this", ".", "$$", "(", "elm", ")", ".", "css", "(", "name", ",", "value", ")", ";", "if", "(", "this", ".", "settings", ".", "update_styles", ")", "{", "updateInternalStyleAttr", "(", "this", ",", "elm", ")", ";", "}", "}" ]
Sets the CSS style value on a HTML element. The name can be a camelcase string or the CSS style name like background-color. @method setStyle @param {String/Element/Array} elm HTML element/Array of elements to set CSS style value on. @param {String} name Name of the style value to set. @param {String} value Value to set on the style. @example // Sets a style value on all paragraphs in the currently active editor tinymce.activeEditor.dom.setStyle(tinymce.activeEditor.dom.select('p'), 'background-color', 'red'); // Sets a style value to an element by id in the current document tinymce.DOM.setStyle('mydiv', 'background-color', 'red');
[ "Sets", "the", "CSS", "style", "value", "on", "a", "HTML", "element", ".", "The", "name", "can", "be", "a", "camelcase", "string", "or", "the", "CSS", "style", "name", "like", "background", "-", "color", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8211-L8217
48,161
sadiqhabib/tinymce-dist
tinymce.full.js
function (e) { return this.run(e, function (e) { var i, attrs = e.attributes; for (i = attrs.length - 1; i >= 0; i--) { e.removeAttributeNode(attrs.item(i)); } }); }
javascript
function (e) { return this.run(e, function (e) { var i, attrs = e.attributes; for (i = attrs.length - 1; i >= 0; i--) { e.removeAttributeNode(attrs.item(i)); } }); }
[ "function", "(", "e", ")", "{", "return", "this", ".", "run", "(", "e", ",", "function", "(", "e", ")", "{", "var", "i", ",", "attrs", "=", "e", ".", "attributes", ";", "for", "(", "i", "=", "attrs", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "e", ".", "removeAttributeNode", "(", "attrs", ".", "item", "(", "i", ")", ")", ";", "}", "}", ")", ";", "}" ]
Removes all attributes from an element or elements. @method removeAllAttribs @param {Element/String/Array} e DOM element, element id string or array of elements/ids to remove attributes from.
[ "Removes", "all", "attributes", "from", "an", "element", "or", "elements", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8274-L8281
48,162
sadiqhabib/tinymce-dist
tinymce.full.js
function (elm, name, value) { var self = this, originalValue, hook, settings = self.settings; if (value === '') { value = null; } elm = self.$$(elm); originalValue = elm.attr(name); if (!elm.length) { return; } hook = self.attrHooks[name]; if (hook && hook.set) { hook.set(elm, value, name); } else { elm.attr(name, value); } if (originalValue != value && settings.onSetAttrib) { settings.onSetAttrib({ attrElm: elm, attrName: name, attrValue: value }); } }
javascript
function (elm, name, value) { var self = this, originalValue, hook, settings = self.settings; if (value === '') { value = null; } elm = self.$$(elm); originalValue = elm.attr(name); if (!elm.length) { return; } hook = self.attrHooks[name]; if (hook && hook.set) { hook.set(elm, value, name); } else { elm.attr(name, value); } if (originalValue != value && settings.onSetAttrib) { settings.onSetAttrib({ attrElm: elm, attrName: name, attrValue: value }); } }
[ "function", "(", "elm", ",", "name", ",", "value", ")", "{", "var", "self", "=", "this", ",", "originalValue", ",", "hook", ",", "settings", "=", "self", ".", "settings", ";", "if", "(", "value", "===", "''", ")", "{", "value", "=", "null", ";", "}", "elm", "=", "self", ".", "$$", "(", "elm", ")", ";", "originalValue", "=", "elm", ".", "attr", "(", "name", ")", ";", "if", "(", "!", "elm", ".", "length", ")", "{", "return", ";", "}", "hook", "=", "self", ".", "attrHooks", "[", "name", "]", ";", "if", "(", "hook", "&&", "hook", ".", "set", ")", "{", "hook", ".", "set", "(", "elm", ",", "value", ",", "name", ")", ";", "}", "else", "{", "elm", ".", "attr", "(", "name", ",", "value", ")", ";", "}", "if", "(", "originalValue", "!=", "value", "&&", "settings", ".", "onSetAttrib", ")", "{", "settings", ".", "onSetAttrib", "(", "{", "attrElm", ":", "elm", ",", "attrName", ":", "name", ",", "attrValue", ":", "value", "}", ")", ";", "}", "}" ]
Sets the specified attribute of an element or elements. @method setAttrib @param {Element/String/Array} elm DOM element, element id string or array of elements/ids to set attribute on. @param {String} name Name of attribute to set. @param {String} value Value to set on the attribute - if this value is falsy like null, 0 or '' it will remove the attribute instead. @example // Sets class attribute on all paragraphs in the active editor tinymce.activeEditor.dom.setAttrib(tinymce.activeEditor.dom.select('p'), 'class', 'myclass'); // Sets class attribute on a specific element in the current page tinymce.dom.setAttrib('mydiv', 'class', 'myclass');
[ "Sets", "the", "specified", "attribute", "of", "an", "element", "or", "elements", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8298-L8326
48,163
sadiqhabib/tinymce-dist
tinymce.full.js
function (elm, attrs) { var self = this; self.$$(elm).each(function (i, node) { each(attrs, function (value, name) { self.setAttrib(node, name, value); }); }); }
javascript
function (elm, attrs) { var self = this; self.$$(elm).each(function (i, node) { each(attrs, function (value, name) { self.setAttrib(node, name, value); }); }); }
[ "function", "(", "elm", ",", "attrs", ")", "{", "var", "self", "=", "this", ";", "self", ".", "$$", "(", "elm", ")", ".", "each", "(", "function", "(", "i", ",", "node", ")", "{", "each", "(", "attrs", ",", "function", "(", "value", ",", "name", ")", "{", "self", ".", "setAttrib", "(", "node", ",", "name", ",", "value", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Sets two or more specified attributes of an element or elements. @method setAttribs @param {Element/String/Array} elm DOM element, element id string or array of elements/ids to set attributes on. @param {Object} attrs Name/Value collection of attribute items to add to the element(s). @example // Sets class and title attributes on all paragraphs in the active editor tinymce.activeEditor.dom.setAttribs(tinymce.activeEditor.dom.select('p'), {'class': 'myclass', title: 'some title'}); // Sets class and title attributes on a specific element in the current page tinymce.DOM.setAttribs('mydiv', {'class': 'myclass', title: 'some title'});
[ "Sets", "two", "or", "more", "specified", "attributes", "of", "an", "element", "or", "elements", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8341-L8349
48,164
sadiqhabib/tinymce-dist
tinymce.full.js
function (elm, name, defaultVal) { var self = this, hook, value; elm = self.$$(elm); if (elm.length) { hook = self.attrHooks[name]; if (hook && hook.get) { value = hook.get(elm, name); } else { value = elm.attr(name); } } if (typeof value == 'undefined') { value = defaultVal || ''; } return value; }
javascript
function (elm, name, defaultVal) { var self = this, hook, value; elm = self.$$(elm); if (elm.length) { hook = self.attrHooks[name]; if (hook && hook.get) { value = hook.get(elm, name); } else { value = elm.attr(name); } } if (typeof value == 'undefined') { value = defaultVal || ''; } return value; }
[ "function", "(", "elm", ",", "name", ",", "defaultVal", ")", "{", "var", "self", "=", "this", ",", "hook", ",", "value", ";", "elm", "=", "self", ".", "$$", "(", "elm", ")", ";", "if", "(", "elm", ".", "length", ")", "{", "hook", "=", "self", ".", "attrHooks", "[", "name", "]", ";", "if", "(", "hook", "&&", "hook", ".", "get", ")", "{", "value", "=", "hook", ".", "get", "(", "elm", ",", "name", ")", ";", "}", "else", "{", "value", "=", "elm", ".", "attr", "(", "name", ")", ";", "}", "}", "if", "(", "typeof", "value", "==", "'undefined'", ")", "{", "value", "=", "defaultVal", "||", "''", ";", "}", "return", "value", ";", "}" ]
Returns the specified attribute by name. @method getAttrib @param {String/Element} elm Element string id or DOM element to get attribute from. @param {String} name Name of attribute to get. @param {String} defaultVal Optional default value to return if the attribute didn't exist. @return {String} Attribute value string, default value or null if the attribute wasn't found.
[ "Returns", "the", "specified", "attribute", "by", "name", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8360-L8380
48,165
sadiqhabib/tinymce-dist
tinymce.full.js
function (cssText) { var self = this, doc = self.doc, head, styleElm; // Prevent inline from loading the same styles twice if (self !== DOMUtils.DOM && doc === document) { var addedStyles = DOMUtils.DOM.addedStyles; addedStyles = addedStyles || []; if (addedStyles[cssText]) { return; } addedStyles[cssText] = true; DOMUtils.DOM.addedStyles = addedStyles; } // Create style element if needed styleElm = doc.getElementById('mceDefaultStyles'); if (!styleElm) { styleElm = doc.createElement('style'); styleElm.id = 'mceDefaultStyles'; styleElm.type = 'text/css'; head = doc.getElementsByTagName('head')[0]; if (head.firstChild) { head.insertBefore(styleElm, head.firstChild); } else { head.appendChild(styleElm); } } // Append style data to old or new style element if (styleElm.styleSheet) { styleElm.styleSheet.cssText += cssText; } else { styleElm.appendChild(doc.createTextNode(cssText)); } }
javascript
function (cssText) { var self = this, doc = self.doc, head, styleElm; // Prevent inline from loading the same styles twice if (self !== DOMUtils.DOM && doc === document) { var addedStyles = DOMUtils.DOM.addedStyles; addedStyles = addedStyles || []; if (addedStyles[cssText]) { return; } addedStyles[cssText] = true; DOMUtils.DOM.addedStyles = addedStyles; } // Create style element if needed styleElm = doc.getElementById('mceDefaultStyles'); if (!styleElm) { styleElm = doc.createElement('style'); styleElm.id = 'mceDefaultStyles'; styleElm.type = 'text/css'; head = doc.getElementsByTagName('head')[0]; if (head.firstChild) { head.insertBefore(styleElm, head.firstChild); } else { head.appendChild(styleElm); } } // Append style data to old or new style element if (styleElm.styleSheet) { styleElm.styleSheet.cssText += cssText; } else { styleElm.appendChild(doc.createTextNode(cssText)); } }
[ "function", "(", "cssText", ")", "{", "var", "self", "=", "this", ",", "doc", "=", "self", ".", "doc", ",", "head", ",", "styleElm", ";", "// Prevent inline from loading the same styles twice", "if", "(", "self", "!==", "DOMUtils", ".", "DOM", "&&", "doc", "===", "document", ")", "{", "var", "addedStyles", "=", "DOMUtils", ".", "DOM", ".", "addedStyles", ";", "addedStyles", "=", "addedStyles", "||", "[", "]", ";", "if", "(", "addedStyles", "[", "cssText", "]", ")", "{", "return", ";", "}", "addedStyles", "[", "cssText", "]", "=", "true", ";", "DOMUtils", ".", "DOM", ".", "addedStyles", "=", "addedStyles", ";", "}", "// Create style element if needed", "styleElm", "=", "doc", ".", "getElementById", "(", "'mceDefaultStyles'", ")", ";", "if", "(", "!", "styleElm", ")", "{", "styleElm", "=", "doc", ".", "createElement", "(", "'style'", ")", ";", "styleElm", ".", "id", "=", "'mceDefaultStyles'", ";", "styleElm", ".", "type", "=", "'text/css'", ";", "head", "=", "doc", ".", "getElementsByTagName", "(", "'head'", ")", "[", "0", "]", ";", "if", "(", "head", ".", "firstChild", ")", "{", "head", ".", "insertBefore", "(", "styleElm", ",", "head", ".", "firstChild", ")", ";", "}", "else", "{", "head", ".", "appendChild", "(", "styleElm", ")", ";", "}", "}", "// Append style data to old or new style element", "if", "(", "styleElm", ".", "styleSheet", ")", "{", "styleElm", ".", "styleSheet", ".", "cssText", "+=", "cssText", ";", "}", "else", "{", "styleElm", ".", "appendChild", "(", "doc", ".", "createTextNode", "(", "cssText", ")", ")", ";", "}", "}" ]
Adds a style element at the top of the document with the specified cssText content. @method addStyle @param {String} cssText CSS Text style to add to top of head of document.
[ "Adds", "a", "style", "element", "at", "the", "top", "of", "the", "document", "with", "the", "specified", "cssText", "content", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8460-L8497
48,166
sadiqhabib/tinymce-dist
tinymce.full.js
function (elm, html) { elm = this.$$(elm); if (isIE) { elm.each(function (i, target) { if (target.canHaveHTML === false) { return; } // Remove all child nodes, IE keeps empty text nodes in DOM while (target.firstChild) { target.removeChild(target.firstChild); } try { // IE will remove comments from the beginning // unless you padd the contents with something target.innerHTML = '<br>' + html; target.removeChild(target.firstChild); } catch (ex) { // IE sometimes produces an unknown runtime error on innerHTML if it's a div inside a p $('<div></div>').html('<br>' + html).contents().slice(1).appendTo(target); } return html; }); } else { elm.html(html); } }
javascript
function (elm, html) { elm = this.$$(elm); if (isIE) { elm.each(function (i, target) { if (target.canHaveHTML === false) { return; } // Remove all child nodes, IE keeps empty text nodes in DOM while (target.firstChild) { target.removeChild(target.firstChild); } try { // IE will remove comments from the beginning // unless you padd the contents with something target.innerHTML = '<br>' + html; target.removeChild(target.firstChild); } catch (ex) { // IE sometimes produces an unknown runtime error on innerHTML if it's a div inside a p $('<div></div>').html('<br>' + html).contents().slice(1).appendTo(target); } return html; }); } else { elm.html(html); } }
[ "function", "(", "elm", ",", "html", ")", "{", "elm", "=", "this", ".", "$$", "(", "elm", ")", ";", "if", "(", "isIE", ")", "{", "elm", ".", "each", "(", "function", "(", "i", ",", "target", ")", "{", "if", "(", "target", ".", "canHaveHTML", "===", "false", ")", "{", "return", ";", "}", "// Remove all child nodes, IE keeps empty text nodes in DOM", "while", "(", "target", ".", "firstChild", ")", "{", "target", ".", "removeChild", "(", "target", ".", "firstChild", ")", ";", "}", "try", "{", "// IE will remove comments from the beginning", "// unless you padd the contents with something", "target", ".", "innerHTML", "=", "'<br>'", "+", "html", ";", "target", ".", "removeChild", "(", "target", ".", "firstChild", ")", ";", "}", "catch", "(", "ex", ")", "{", "// IE sometimes produces an unknown runtime error on innerHTML if it's a div inside a p", "$", "(", "'<div></div>'", ")", ".", "html", "(", "'<br>'", "+", "html", ")", ".", "contents", "(", ")", ".", "slice", "(", "1", ")", ".", "appendTo", "(", "target", ")", ";", "}", "return", "html", ";", "}", ")", ";", "}", "else", "{", "elm", ".", "html", "(", "html", ")", ";", "}", "}" ]
Sets the specified HTML content inside the element or elements. The HTML will first be processed. This means URLs will get converted, hex color values fixed etc. Check processHTML for details. @method setHTML @param {Element/String/Array} elm DOM element, element id string or array of elements/ids to set HTML inside of. @param {String} html HTML content to set as inner HTML of the element. @example // Sets the inner HTML of all paragraphs in the active editor tinymce.activeEditor.dom.setHTML(tinymce.activeEditor.dom.select('p'), 'some inner html'); // Sets the inner HTML of an element by id in the document tinymce.DOM.setHTML('mydiv', 'some inner html');
[ "Sets", "the", "specified", "HTML", "content", "inside", "the", "element", "or", "elements", ".", "The", "HTML", "will", "first", "be", "processed", ".", "This", "means", "URLs", "will", "get", "converted", "hex", "color", "values", "fixed", "etc", ".", "Check", "processHTML", "for", "details", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8686-L8715
48,167
sadiqhabib/tinymce-dist
tinymce.full.js
function (elm) { elm = this.get(elm); // Older FF doesn't have outerHTML 3.6 is still used by some orgaizations return elm.nodeType == 1 && "outerHTML" in elm ? elm.outerHTML : $('<div></div>').append($(elm).clone()).html(); }
javascript
function (elm) { elm = this.get(elm); // Older FF doesn't have outerHTML 3.6 is still used by some orgaizations return elm.nodeType == 1 && "outerHTML" in elm ? elm.outerHTML : $('<div></div>').append($(elm).clone()).html(); }
[ "function", "(", "elm", ")", "{", "elm", "=", "this", ".", "get", "(", "elm", ")", ";", "// Older FF doesn't have outerHTML 3.6 is still used by some orgaizations", "return", "elm", ".", "nodeType", "==", "1", "&&", "\"outerHTML\"", "in", "elm", "?", "elm", ".", "outerHTML", ":", "$", "(", "'<div></div>'", ")", ".", "append", "(", "$", "(", "elm", ")", ".", "clone", "(", ")", ")", ".", "html", "(", ")", ";", "}" ]
Returns the outer HTML of an element. @method getOuterHTML @param {String/Element} elm Element ID or element object to get outer HTML from. @return {String} Outer HTML string. @example tinymce.DOM.getOuterHTML(editorElement); tinymce.activeEditor.getOuterHTML(tinymce.activeEditor.getBody());
[ "Returns", "the", "outer", "HTML", "of", "an", "element", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8727-L8732
48,168
sadiqhabib/tinymce-dist
tinymce.full.js
function (elm, html) { var self = this; self.$$(elm).each(function () { try { // Older FF doesn't have outerHTML 3.6 is still used by some organizations if ("outerHTML" in this) { this.outerHTML = html; return; } } catch (ex) { // Ignore } // OuterHTML for IE it sometimes produces an "unknown runtime error" self.remove($(this).html(html), true); }); }
javascript
function (elm, html) { var self = this; self.$$(elm).each(function () { try { // Older FF doesn't have outerHTML 3.6 is still used by some organizations if ("outerHTML" in this) { this.outerHTML = html; return; } } catch (ex) { // Ignore } // OuterHTML for IE it sometimes produces an "unknown runtime error" self.remove($(this).html(html), true); }); }
[ "function", "(", "elm", ",", "html", ")", "{", "var", "self", "=", "this", ";", "self", ".", "$$", "(", "elm", ")", ".", "each", "(", "function", "(", ")", "{", "try", "{", "// Older FF doesn't have outerHTML 3.6 is still used by some organizations", "if", "(", "\"outerHTML\"", "in", "this", ")", "{", "this", ".", "outerHTML", "=", "html", ";", "return", ";", "}", "}", "catch", "(", "ex", ")", "{", "// Ignore", "}", "// OuterHTML for IE it sometimes produces an \"unknown runtime error\"", "self", ".", "remove", "(", "$", "(", "this", ")", ".", "html", "(", "html", ")", ",", "true", ")", ";", "}", ")", ";", "}" ]
Sets the specified outer HTML on an element or elements. @method setOuterHTML @param {Element/String/Array} elm DOM element, element id string or array of elements/ids to set outer HTML on. @param {Object} html HTML code to set as outer value for the element. @example // Sets the outer HTML of all paragraphs in the active editor tinymce.activeEditor.dom.setOuterHTML(tinymce.activeEditor.dom.select('p'), '<div>some html</div>'); // Sets the outer HTML of an element by id in the document tinymce.DOM.setOuterHTML('mydiv', '<div>some html</div>');
[ "Sets", "the", "specified", "outer", "HTML", "on", "an", "element", "or", "elements", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8747-L8764
48,169
sadiqhabib/tinymce-dist
tinymce.full.js
function (node, referenceNode) { referenceNode = this.get(referenceNode); return this.run(node, function (node) { var parent, nextSibling; parent = referenceNode.parentNode; nextSibling = referenceNode.nextSibling; if (nextSibling) { parent.insertBefore(node, nextSibling); } else { parent.appendChild(node); } return node; }); }
javascript
function (node, referenceNode) { referenceNode = this.get(referenceNode); return this.run(node, function (node) { var parent, nextSibling; parent = referenceNode.parentNode; nextSibling = referenceNode.nextSibling; if (nextSibling) { parent.insertBefore(node, nextSibling); } else { parent.appendChild(node); } return node; }); }
[ "function", "(", "node", ",", "referenceNode", ")", "{", "referenceNode", "=", "this", ".", "get", "(", "referenceNode", ")", ";", "return", "this", ".", "run", "(", "node", ",", "function", "(", "node", ")", "{", "var", "parent", ",", "nextSibling", ";", "parent", "=", "referenceNode", ".", "parentNode", ";", "nextSibling", "=", "referenceNode", ".", "nextSibling", ";", "if", "(", "nextSibling", ")", "{", "parent", ".", "insertBefore", "(", "node", ",", "nextSibling", ")", ";", "}", "else", "{", "parent", ".", "appendChild", "(", "node", ")", ";", "}", "return", "node", ";", "}", ")", ";", "}" ]
Inserts an element after the reference element. @method insertAfter @param {Element} node Element to insert after the reference. @param {Element/String/Array} referenceNode Reference element, element id or array of elements to insert after. @return {Element/Array} Element that got added or an array with elements.
[ "Inserts", "an", "element", "after", "the", "reference", "element", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8792-L8809
48,170
sadiqhabib/tinymce-dist
tinymce.full.js
function (elm, name) { var self = this, newElm; if (elm.nodeName != name.toUpperCase()) { // Rename block element newElm = self.create(name); // Copy attribs to new block each(self.getAttribs(elm), function (attrNode) { self.setAttrib(newElm, attrNode.nodeName, self.getAttrib(elm, attrNode.nodeName)); }); // Replace block self.replace(newElm, elm, 1); } return newElm || elm; }
javascript
function (elm, name) { var self = this, newElm; if (elm.nodeName != name.toUpperCase()) { // Rename block element newElm = self.create(name); // Copy attribs to new block each(self.getAttribs(elm), function (attrNode) { self.setAttrib(newElm, attrNode.nodeName, self.getAttrib(elm, attrNode.nodeName)); }); // Replace block self.replace(newElm, elm, 1); } return newElm || elm; }
[ "function", "(", "elm", ",", "name", ")", "{", "var", "self", "=", "this", ",", "newElm", ";", "if", "(", "elm", ".", "nodeName", "!=", "name", ".", "toUpperCase", "(", ")", ")", "{", "// Rename block element", "newElm", "=", "self", ".", "create", "(", "name", ")", ";", "// Copy attribs to new block", "each", "(", "self", ".", "getAttribs", "(", "elm", ")", ",", "function", "(", "attrNode", ")", "{", "self", ".", "setAttrib", "(", "newElm", ",", "attrNode", ".", "nodeName", ",", "self", ".", "getAttrib", "(", "elm", ",", "attrNode", ".", "nodeName", ")", ")", ";", "}", ")", ";", "// Replace block", "self", ".", "replace", "(", "newElm", ",", "elm", ",", "1", ")", ";", "}", "return", "newElm", "||", "elm", ";", "}" ]
Renames the specified element and keeps its attributes and children. @method rename @param {Element} elm Element to rename. @param {String} name Name of the new element. @return {Element} New element or the old element if it needed renaming.
[ "Renames", "the", "specified", "element", "and", "keeps", "its", "attributes", "and", "children", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8847-L8864
48,171
sadiqhabib/tinymce-dist
tinymce.full.js
function (a, b) { var ps = a, pe; while (ps) { pe = b; while (pe && ps != pe) { pe = pe.parentNode; } if (ps == pe) { break; } ps = ps.parentNode; } if (!ps && a.ownerDocument) { return a.ownerDocument.documentElement; } return ps; }
javascript
function (a, b) { var ps = a, pe; while (ps) { pe = b; while (pe && ps != pe) { pe = pe.parentNode; } if (ps == pe) { break; } ps = ps.parentNode; } if (!ps && a.ownerDocument) { return a.ownerDocument.documentElement; } return ps; }
[ "function", "(", "a", ",", "b", ")", "{", "var", "ps", "=", "a", ",", "pe", ";", "while", "(", "ps", ")", "{", "pe", "=", "b", ";", "while", "(", "pe", "&&", "ps", "!=", "pe", ")", "{", "pe", "=", "pe", ".", "parentNode", ";", "}", "if", "(", "ps", "==", "pe", ")", "{", "break", ";", "}", "ps", "=", "ps", ".", "parentNode", ";", "}", "if", "(", "!", "ps", "&&", "a", ".", "ownerDocument", ")", "{", "return", "a", ".", "ownerDocument", ".", "documentElement", ";", "}", "return", "ps", ";", "}" ]
Find the common ancestor of two elements. This is a shorter method than using the DOM Range logic. @method findCommonAncestor @param {Element} a Element to find common ancestor of. @param {Element} b Element to find common ancestor of. @return {Element} Common ancestor element of the two input elements.
[ "Find", "the", "common", "ancestor", "of", "two", "elements", ".", "This", "is", "a", "shorter", "method", "than", "using", "the", "DOM", "Range", "logic", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8874-L8896
48,172
sadiqhabib/tinymce-dist
tinymce.full.js
function (elm) { var attrs; elm = this.get(elm); if (!elm) { return []; } if (isIE) { attrs = []; // Object will throw exception in IE if (elm.nodeName == 'OBJECT') { return elm.attributes; } // IE doesn't keep the selected attribute if you clone option elements if (elm.nodeName === 'OPTION' && this.getAttrib(elm, 'selected')) { attrs.push({ specified: 1, nodeName: 'selected' }); } // It's crazy that this is faster in IE but it's because it returns all attributes all the time var attrRegExp = /<\/?[\w:\-]+ ?|=[\"][^\"]+\"|=\'[^\']+\'|=[\w\-]+|>/gi; elm.cloneNode(false).outerHTML.replace(attrRegExp, '').replace(/[\w:\-]+/gi, function (a) { attrs.push({ specified: 1, nodeName: a }); }); return attrs; } return elm.attributes; }
javascript
function (elm) { var attrs; elm = this.get(elm); if (!elm) { return []; } if (isIE) { attrs = []; // Object will throw exception in IE if (elm.nodeName == 'OBJECT') { return elm.attributes; } // IE doesn't keep the selected attribute if you clone option elements if (elm.nodeName === 'OPTION' && this.getAttrib(elm, 'selected')) { attrs.push({ specified: 1, nodeName: 'selected' }); } // It's crazy that this is faster in IE but it's because it returns all attributes all the time var attrRegExp = /<\/?[\w:\-]+ ?|=[\"][^\"]+\"|=\'[^\']+\'|=[\w\-]+|>/gi; elm.cloneNode(false).outerHTML.replace(attrRegExp, '').replace(/[\w:\-]+/gi, function (a) { attrs.push({ specified: 1, nodeName: a }); }); return attrs; } return elm.attributes; }
[ "function", "(", "elm", ")", "{", "var", "attrs", ";", "elm", "=", "this", ".", "get", "(", "elm", ")", ";", "if", "(", "!", "elm", ")", "{", "return", "[", "]", ";", "}", "if", "(", "isIE", ")", "{", "attrs", "=", "[", "]", ";", "// Object will throw exception in IE", "if", "(", "elm", ".", "nodeName", "==", "'OBJECT'", ")", "{", "return", "elm", ".", "attributes", ";", "}", "// IE doesn't keep the selected attribute if you clone option elements", "if", "(", "elm", ".", "nodeName", "===", "'OPTION'", "&&", "this", ".", "getAttrib", "(", "elm", ",", "'selected'", ")", ")", "{", "attrs", ".", "push", "(", "{", "specified", ":", "1", ",", "nodeName", ":", "'selected'", "}", ")", ";", "}", "// It's crazy that this is faster in IE but it's because it returns all attributes all the time", "var", "attrRegExp", "=", "/", "<\\/?[\\w:\\-]+ ?|=[\\\"][^\\\"]+\\\"|=\\'[^\\']+\\'|=[\\w\\-]+|>", "/", "gi", ";", "elm", ".", "cloneNode", "(", "false", ")", ".", "outerHTML", ".", "replace", "(", "attrRegExp", ",", "''", ")", ".", "replace", "(", "/", "[\\w:\\-]+", "/", "gi", ",", "function", "(", "a", ")", "{", "attrs", ".", "push", "(", "{", "specified", ":", "1", ",", "nodeName", ":", "a", "}", ")", ";", "}", ")", ";", "return", "attrs", ";", "}", "return", "elm", ".", "attributes", ";", "}" ]
Returns a NodeList with attributes for the element. @method getAttribs @param {HTMLElement/string} elm Element node or string id to get attributes from. @return {NodeList} NodeList with attributes.
[ "Returns", "a", "NodeList", "with", "attributes", "for", "the", "element", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L8956-L8988
48,173
sadiqhabib/tinymce-dist
tinymce.full.js
function (target, name, func, scope) { var self = this; if (Tools.isArray(target)) { var i = target.length; while (i--) { target[i] = self.bind(target[i], name, func, scope); } return target; } // Collect all window/document events bound by editor instance if (self.settings.collect && (target === self.doc || target === self.win)) { self.boundEvents.push([target, name, func, scope]); } return self.events.bind(target, name, func, scope || self); }
javascript
function (target, name, func, scope) { var self = this; if (Tools.isArray(target)) { var i = target.length; while (i--) { target[i] = self.bind(target[i], name, func, scope); } return target; } // Collect all window/document events bound by editor instance if (self.settings.collect && (target === self.doc || target === self.win)) { self.boundEvents.push([target, name, func, scope]); } return self.events.bind(target, name, func, scope || self); }
[ "function", "(", "target", ",", "name", ",", "func", ",", "scope", ")", "{", "var", "self", "=", "this", ";", "if", "(", "Tools", ".", "isArray", "(", "target", ")", ")", "{", "var", "i", "=", "target", ".", "length", ";", "while", "(", "i", "--", ")", "{", "target", "[", "i", "]", "=", "self", ".", "bind", "(", "target", "[", "i", "]", ",", "name", ",", "func", ",", "scope", ")", ";", "}", "return", "target", ";", "}", "// Collect all window/document events bound by editor instance", "if", "(", "self", ".", "settings", ".", "collect", "&&", "(", "target", "===", "self", ".", "doc", "||", "target", "===", "self", ".", "win", ")", ")", "{", "self", ".", "boundEvents", ".", "push", "(", "[", "target", ",", "name", ",", "func", ",", "scope", "]", ")", ";", "}", "return", "self", ".", "events", ".", "bind", "(", "target", ",", "name", ",", "func", ",", "scope", "||", "self", ")", ";", "}" ]
Adds an event handler to the specified object. @method bind @param {Element/Document/Window/Array} target Target element to bind events to. handler to or an array of elements/ids/documents. @param {String} name Name of event handler to add, for example: click. @param {function} func Function to execute when the event occurs. @param {Object} scope Optional scope to execute the function in. @return {function} Function callback handler the same as the one passed in.
[ "Adds", "an", "event", "handler", "to", "the", "specified", "object", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L9205-L9224
48,174
sadiqhabib/tinymce-dist
tinymce.full.js
function (target, name, func) { var self = this, i; if (Tools.isArray(target)) { i = target.length; while (i--) { target[i] = self.unbind(target[i], name, func); } return target; } // Remove any bound events matching the input if (self.boundEvents && (target === self.doc || target === self.win)) { i = self.boundEvents.length; while (i--) { var item = self.boundEvents[i]; if (target == item[0] && (!name || name == item[1]) && (!func || func == item[2])) { this.events.unbind(item[0], item[1], item[2]); } } } return this.events.unbind(target, name, func); }
javascript
function (target, name, func) { var self = this, i; if (Tools.isArray(target)) { i = target.length; while (i--) { target[i] = self.unbind(target[i], name, func); } return target; } // Remove any bound events matching the input if (self.boundEvents && (target === self.doc || target === self.win)) { i = self.boundEvents.length; while (i--) { var item = self.boundEvents[i]; if (target == item[0] && (!name || name == item[1]) && (!func || func == item[2])) { this.events.unbind(item[0], item[1], item[2]); } } } return this.events.unbind(target, name, func); }
[ "function", "(", "target", ",", "name", ",", "func", ")", "{", "var", "self", "=", "this", ",", "i", ";", "if", "(", "Tools", ".", "isArray", "(", "target", ")", ")", "{", "i", "=", "target", ".", "length", ";", "while", "(", "i", "--", ")", "{", "target", "[", "i", "]", "=", "self", ".", "unbind", "(", "target", "[", "i", "]", ",", "name", ",", "func", ")", ";", "}", "return", "target", ";", "}", "// Remove any bound events matching the input", "if", "(", "self", ".", "boundEvents", "&&", "(", "target", "===", "self", ".", "doc", "||", "target", "===", "self", ".", "win", ")", ")", "{", "i", "=", "self", ".", "boundEvents", ".", "length", ";", "while", "(", "i", "--", ")", "{", "var", "item", "=", "self", ".", "boundEvents", "[", "i", "]", ";", "if", "(", "target", "==", "item", "[", "0", "]", "&&", "(", "!", "name", "||", "name", "==", "item", "[", "1", "]", ")", "&&", "(", "!", "func", "||", "func", "==", "item", "[", "2", "]", ")", ")", "{", "this", ".", "events", ".", "unbind", "(", "item", "[", "0", "]", ",", "item", "[", "1", "]", ",", "item", "[", "2", "]", ")", ";", "}", "}", "}", "return", "this", ".", "events", ".", "unbind", "(", "target", ",", "name", ",", "func", ")", ";", "}" ]
Removes the specified event handler by name and function from an element or collection of elements. @method unbind @param {Element/Document/Window/Array} target Target element to unbind events on. @param {String} name Event handler name, for example: "click" @param {function} func Function to remove. @return {bool/Array} Bool state of true if the handler was removed, or an array of states if multiple input elements were passed in.
[ "Removes", "the", "specified", "event", "handler", "by", "name", "and", "function", "from", "an", "element", "or", "collection", "of", "elements", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L9236-L9263
48,175
sadiqhabib/tinymce-dist
tinymce.full.js
function () { var self = this; // Unbind all events bound to window/document by editor instance if (self.boundEvents) { var i = self.boundEvents.length; while (i--) { var item = self.boundEvents[i]; this.events.unbind(item[0], item[1], item[2]); } self.boundEvents = null; } // Restore sizzle document to window.document // Since the current document might be removed producing "Permission denied" on IE see #6325 if (Sizzle.setDocument) { Sizzle.setDocument(); } self.win = self.doc = self.root = self.events = self.frag = null; }
javascript
function () { var self = this; // Unbind all events bound to window/document by editor instance if (self.boundEvents) { var i = self.boundEvents.length; while (i--) { var item = self.boundEvents[i]; this.events.unbind(item[0], item[1], item[2]); } self.boundEvents = null; } // Restore sizzle document to window.document // Since the current document might be removed producing "Permission denied" on IE see #6325 if (Sizzle.setDocument) { Sizzle.setDocument(); } self.win = self.doc = self.root = self.events = self.frag = null; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "// Unbind all events bound to window/document by editor instance", "if", "(", "self", ".", "boundEvents", ")", "{", "var", "i", "=", "self", ".", "boundEvents", ".", "length", ";", "while", "(", "i", "--", ")", "{", "var", "item", "=", "self", ".", "boundEvents", "[", "i", "]", ";", "this", ".", "events", ".", "unbind", "(", "item", "[", "0", "]", ",", "item", "[", "1", "]", ",", "item", "[", "2", "]", ")", ";", "}", "self", ".", "boundEvents", "=", "null", ";", "}", "// Restore sizzle document to window.document", "// Since the current document might be removed producing \"Permission denied\" on IE see #6325", "if", "(", "Sizzle", ".", "setDocument", ")", "{", "Sizzle", ".", "setDocument", "(", ")", ";", "}", "self", ".", "win", "=", "self", ".", "doc", "=", "self", ".", "root", "=", "self", ".", "events", "=", "self", ".", "frag", "=", "null", ";", "}" ]
Destroys all internal references to the DOM to solve IE leak issues. @method destroy
[ "Destroys", "all", "internal", "references", "to", "the", "DOM", "to", "solve", "IE", "leak", "issues", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L9316-L9338
48,176
sadiqhabib/tinymce-dist
tinymce.full.js
loadScript
function loadScript(url, success, failure) { var dom = DOM, elm, id; // Execute callback when script is loaded function done() { dom.remove(id); if (elm) { elm.onreadystatechange = elm.onload = elm = null; } success(); } function error() { /*eslint no-console:0 */ // We can't mark it as done if there is a load error since // A) We don't want to produce 404 errors on the server and // B) the onerror event won't fire on all browsers. // done(); if (isFunction(failure)) { failure(); } else { // Report the error so it's easier for people to spot loading errors if (typeof console !== "undefined" && console.log) { console.log("Failed to load script: " + url); } } } id = dom.uniqueId(); // Create new script element elm = document.createElement('script'); elm.id = id; elm.type = 'text/javascript'; elm.src = Tools._addCacheSuffix(url); // Seems that onreadystatechange works better on IE 10 onload seems to fire incorrectly if ("onreadystatechange" in elm) { elm.onreadystatechange = function () { if (/loaded|complete/.test(elm.readyState)) { done(); } }; } else { elm.onload = done; } // Add onerror event will get fired on some browsers but not all of them elm.onerror = error; // Add script to document (document.getElementsByTagName('head')[0] || document.body).appendChild(elm); }
javascript
function loadScript(url, success, failure) { var dom = DOM, elm, id; // Execute callback when script is loaded function done() { dom.remove(id); if (elm) { elm.onreadystatechange = elm.onload = elm = null; } success(); } function error() { /*eslint no-console:0 */ // We can't mark it as done if there is a load error since // A) We don't want to produce 404 errors on the server and // B) the onerror event won't fire on all browsers. // done(); if (isFunction(failure)) { failure(); } else { // Report the error so it's easier for people to spot loading errors if (typeof console !== "undefined" && console.log) { console.log("Failed to load script: " + url); } } } id = dom.uniqueId(); // Create new script element elm = document.createElement('script'); elm.id = id; elm.type = 'text/javascript'; elm.src = Tools._addCacheSuffix(url); // Seems that onreadystatechange works better on IE 10 onload seems to fire incorrectly if ("onreadystatechange" in elm) { elm.onreadystatechange = function () { if (/loaded|complete/.test(elm.readyState)) { done(); } }; } else { elm.onload = done; } // Add onerror event will get fired on some browsers but not all of them elm.onerror = error; // Add script to document (document.getElementsByTagName('head')[0] || document.body).appendChild(elm); }
[ "function", "loadScript", "(", "url", ",", "success", ",", "failure", ")", "{", "var", "dom", "=", "DOM", ",", "elm", ",", "id", ";", "// Execute callback when script is loaded", "function", "done", "(", ")", "{", "dom", ".", "remove", "(", "id", ")", ";", "if", "(", "elm", ")", "{", "elm", ".", "onreadystatechange", "=", "elm", ".", "onload", "=", "elm", "=", "null", ";", "}", "success", "(", ")", ";", "}", "function", "error", "(", ")", "{", "/*eslint no-console:0 */", "// We can't mark it as done if there is a load error since", "// A) We don't want to produce 404 errors on the server and", "// B) the onerror event won't fire on all browsers.", "// done();", "if", "(", "isFunction", "(", "failure", ")", ")", "{", "failure", "(", ")", ";", "}", "else", "{", "// Report the error so it's easier for people to spot loading errors", "if", "(", "typeof", "console", "!==", "\"undefined\"", "&&", "console", ".", "log", ")", "{", "console", ".", "log", "(", "\"Failed to load script: \"", "+", "url", ")", ";", "}", "}", "}", "id", "=", "dom", ".", "uniqueId", "(", ")", ";", "// Create new script element", "elm", "=", "document", ".", "createElement", "(", "'script'", ")", ";", "elm", ".", "id", "=", "id", ";", "elm", ".", "type", "=", "'text/javascript'", ";", "elm", ".", "src", "=", "Tools", ".", "_addCacheSuffix", "(", "url", ")", ";", "// Seems that onreadystatechange works better on IE 10 onload seems to fire incorrectly", "if", "(", "\"onreadystatechange\"", "in", "elm", ")", "{", "elm", ".", "onreadystatechange", "=", "function", "(", ")", "{", "if", "(", "/", "loaded|complete", "/", ".", "test", "(", "elm", ".", "readyState", ")", ")", "{", "done", "(", ")", ";", "}", "}", ";", "}", "else", "{", "elm", ".", "onload", "=", "done", ";", "}", "// Add onerror event will get fired on some browsers but not all of them", "elm", ".", "onerror", "=", "error", ";", "// Add script to document", "(", "document", ".", "getElementsByTagName", "(", "'head'", ")", "[", "0", "]", "||", "document", ".", "body", ")", ".", "appendChild", "(", "elm", ")", ";", "}" ]
Loads a specific script directly without adding it to the load queue. @method load @param {String} url Absolute URL to script to add. @param {function} callback Optional success callback function when the script loaded successfully. @param {function} callback Optional failure callback function when the script failed to load.
[ "Loads", "a", "specific", "script", "directly", "without", "adding", "it", "to", "the", "load", "queue", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L9476-L9532
48,177
sadiqhabib/tinymce-dist
tinymce.full.js
function (name, languages) { var language = AddOnManager.language; if (language && AddOnManager.languageLoad !== false) { if (languages) { languages = ',' + languages + ','; // Load short form sv.js or long form sv_SE.js if (languages.indexOf(',' + language.substr(0, 2) + ',') != -1) { language = language.substr(0, 2); } else if (languages.indexOf(',' + language + ',') == -1) { return; } } ScriptLoader.ScriptLoader.add(this.urls[name] + '/langs/' + language + '.js'); } }
javascript
function (name, languages) { var language = AddOnManager.language; if (language && AddOnManager.languageLoad !== false) { if (languages) { languages = ',' + languages + ','; // Load short form sv.js or long form sv_SE.js if (languages.indexOf(',' + language.substr(0, 2) + ',') != -1) { language = language.substr(0, 2); } else if (languages.indexOf(',' + language + ',') == -1) { return; } } ScriptLoader.ScriptLoader.add(this.urls[name] + '/langs/' + language + '.js'); } }
[ "function", "(", "name", ",", "languages", ")", "{", "var", "language", "=", "AddOnManager", ".", "language", ";", "if", "(", "language", "&&", "AddOnManager", ".", "languageLoad", "!==", "false", ")", "{", "if", "(", "languages", ")", "{", "languages", "=", "','", "+", "languages", "+", "','", ";", "// Load short form sv.js or long form sv_SE.js", "if", "(", "languages", ".", "indexOf", "(", "','", "+", "language", ".", "substr", "(", "0", ",", "2", ")", "+", "','", ")", "!=", "-", "1", ")", "{", "language", "=", "language", ".", "substr", "(", "0", ",", "2", ")", ";", "}", "else", "if", "(", "languages", ".", "indexOf", "(", "','", "+", "language", "+", "','", ")", "==", "-", "1", ")", "{", "return", ";", "}", "}", "ScriptLoader", ".", "ScriptLoader", ".", "add", "(", "this", ".", "urls", "[", "name", "]", "+", "'/langs/'", "+", "language", "+", "'.js'", ")", ";", "}", "}" ]
Loads a language pack for the specified add-on. @method requireLangPack @param {String} name Short name of the add-on. @param {String} languages Optional comma or space separated list of languages to check if it matches the name.
[ "Loads", "a", "language", "pack", "for", "the", "specified", "add", "-", "on", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L9773-L9790
48,178
sadiqhabib/tinymce-dist
tinymce.full.js
function (id, addOn, dependencies) { this.items.push(addOn); this.lookup[id] = { instance: addOn, dependencies: dependencies }; return addOn; }
javascript
function (id, addOn, dependencies) { this.items.push(addOn); this.lookup[id] = { instance: addOn, dependencies: dependencies }; return addOn; }
[ "function", "(", "id", ",", "addOn", ",", "dependencies", ")", "{", "this", ".", "items", ".", "push", "(", "addOn", ")", ";", "this", ".", "lookup", "[", "id", "]", "=", "{", "instance", ":", "addOn", ",", "dependencies", ":", "dependencies", "}", ";", "return", "addOn", ";", "}" ]
Adds a instance of the add-on by it's short name. @method add @param {String} id Short name/id for the add-on. @param {tinymce.Theme/tinymce.Plugin} addOn Theme or plugin to add. @return {tinymce.Theme/tinymce.Plugin} The same theme or plugin instance that got passed in. @example // Create a simple plugin tinymce.create('tinymce.plugins.TestPlugin', { TestPlugin: function(ed, url) { ed.on('click', function(e) { ed.windowManager.alert('Hello World!'); }); } }); // Register plugin using the add method tinymce.PluginManager.add('test', tinymce.plugins.TestPlugin); // Initialize TinyMCE tinymce.init({ ... plugins: '-test' // Init the plugin but don't try to load it });
[ "Adds", "a", "instance", "of", "the", "add", "-", "on", "by", "it", "s", "short", "name", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L9818-L9823
48,179
sadiqhabib/tinymce-dist
tinymce.full.js
function (name, addOnUrl, success, scope, failure) { var self = this, url = addOnUrl; function loadDependencies() { var dependencies = self.dependencies(name); each(dependencies, function (dep) { var newUrl = self.createUrl(addOnUrl, dep); self.load(newUrl.resource, newUrl, undefined, undefined); }); if (success) { if (scope) { success.call(scope); } else { success.call(ScriptLoader); } } } if (self.urls[name]) { return; } if (typeof addOnUrl === "object") { url = addOnUrl.prefix + addOnUrl.resource + addOnUrl.suffix; } if (url.indexOf('/') !== 0 && url.indexOf('://') == -1) { url = AddOnManager.baseURL + '/' + url; } self.urls[name] = url.substring(0, url.lastIndexOf('/')); if (self.lookup[name]) { loadDependencies(); } else { ScriptLoader.ScriptLoader.add(url, loadDependencies, scope, failure); } }
javascript
function (name, addOnUrl, success, scope, failure) { var self = this, url = addOnUrl; function loadDependencies() { var dependencies = self.dependencies(name); each(dependencies, function (dep) { var newUrl = self.createUrl(addOnUrl, dep); self.load(newUrl.resource, newUrl, undefined, undefined); }); if (success) { if (scope) { success.call(scope); } else { success.call(ScriptLoader); } } } if (self.urls[name]) { return; } if (typeof addOnUrl === "object") { url = addOnUrl.prefix + addOnUrl.resource + addOnUrl.suffix; } if (url.indexOf('/') !== 0 && url.indexOf('://') == -1) { url = AddOnManager.baseURL + '/' + url; } self.urls[name] = url.substring(0, url.lastIndexOf('/')); if (self.lookup[name]) { loadDependencies(); } else { ScriptLoader.ScriptLoader.add(url, loadDependencies, scope, failure); } }
[ "function", "(", "name", ",", "addOnUrl", ",", "success", ",", "scope", ",", "failure", ")", "{", "var", "self", "=", "this", ",", "url", "=", "addOnUrl", ";", "function", "loadDependencies", "(", ")", "{", "var", "dependencies", "=", "self", ".", "dependencies", "(", "name", ")", ";", "each", "(", "dependencies", ",", "function", "(", "dep", ")", "{", "var", "newUrl", "=", "self", ".", "createUrl", "(", "addOnUrl", ",", "dep", ")", ";", "self", ".", "load", "(", "newUrl", ".", "resource", ",", "newUrl", ",", "undefined", ",", "undefined", ")", ";", "}", ")", ";", "if", "(", "success", ")", "{", "if", "(", "scope", ")", "{", "success", ".", "call", "(", "scope", ")", ";", "}", "else", "{", "success", ".", "call", "(", "ScriptLoader", ")", ";", "}", "}", "}", "if", "(", "self", ".", "urls", "[", "name", "]", ")", "{", "return", ";", "}", "if", "(", "typeof", "addOnUrl", "===", "\"object\"", ")", "{", "url", "=", "addOnUrl", ".", "prefix", "+", "addOnUrl", ".", "resource", "+", "addOnUrl", ".", "suffix", ";", "}", "if", "(", "url", ".", "indexOf", "(", "'/'", ")", "!==", "0", "&&", "url", ".", "indexOf", "(", "'://'", ")", "==", "-", "1", ")", "{", "url", "=", "AddOnManager", ".", "baseURL", "+", "'/'", "+", "url", ";", "}", "self", ".", "urls", "[", "name", "]", "=", "url", ".", "substring", "(", "0", ",", "url", ".", "lastIndexOf", "(", "'/'", ")", ")", ";", "if", "(", "self", ".", "lookup", "[", "name", "]", ")", "{", "loadDependencies", "(", ")", ";", "}", "else", "{", "ScriptLoader", ".", "ScriptLoader", ".", "add", "(", "url", ",", "loadDependencies", ",", "scope", ",", "failure", ")", ";", "}", "}" ]
Loads an add-on from a specific url. @method load @param {String} name Short name of the add-on that gets loaded. @param {String} addOnUrl URL to the add-on that will get loaded. @param {function} success Optional success callback to execute when an add-on is loaded. @param {Object} scope Optional scope to execute the callback in. @param {function} failure Optional failure callback to execute when an add-on failed to load. @example // Loads a plugin from an external URL tinymce.PluginManager.load('myplugin', '/some/dir/someplugin/plugin.js'); // Initialize TinyMCE tinymce.init({ ... plugins: '-myplugin' // Don't try to load it again });
[ "Loads", "an", "add", "-", "on", "from", "a", "specific", "url", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L9874-L9914
48,180
sadiqhabib/tinymce-dist
tinymce.full.js
findClosestIeRange
function findClosestIeRange(clientX, clientY, doc) { var element, rng, rects; element = doc.elementFromPoint(clientX, clientY); rng = doc.body.createTextRange(); if (!element || element.tagName == 'HTML') { element = doc.body; } rng.moveToElementText(element); rects = Tools.toArray(rng.getClientRects()); rects = rects.sort(function (a, b) { a = Math.abs(Math.max(a.top - clientY, a.bottom - clientY)); b = Math.abs(Math.max(b.top - clientY, b.bottom - clientY)); return a - b; }); if (rects.length > 0) { clientY = (rects[0].bottom + rects[0].top) / 2; try { rng.moveToPoint(clientX, clientY); rng.collapse(true); return rng; } catch (ex) { // At least we tried } } return null; }
javascript
function findClosestIeRange(clientX, clientY, doc) { var element, rng, rects; element = doc.elementFromPoint(clientX, clientY); rng = doc.body.createTextRange(); if (!element || element.tagName == 'HTML') { element = doc.body; } rng.moveToElementText(element); rects = Tools.toArray(rng.getClientRects()); rects = rects.sort(function (a, b) { a = Math.abs(Math.max(a.top - clientY, a.bottom - clientY)); b = Math.abs(Math.max(b.top - clientY, b.bottom - clientY)); return a - b; }); if (rects.length > 0) { clientY = (rects[0].bottom + rects[0].top) / 2; try { rng.moveToPoint(clientX, clientY); rng.collapse(true); return rng; } catch (ex) { // At least we tried } } return null; }
[ "function", "findClosestIeRange", "(", "clientX", ",", "clientY", ",", "doc", ")", "{", "var", "element", ",", "rng", ",", "rects", ";", "element", "=", "doc", ".", "elementFromPoint", "(", "clientX", ",", "clientY", ")", ";", "rng", "=", "doc", ".", "body", ".", "createTextRange", "(", ")", ";", "if", "(", "!", "element", "||", "element", ".", "tagName", "==", "'HTML'", ")", "{", "element", "=", "doc", ".", "body", ";", "}", "rng", ".", "moveToElementText", "(", "element", ")", ";", "rects", "=", "Tools", ".", "toArray", "(", "rng", ".", "getClientRects", "(", ")", ")", ";", "rects", "=", "rects", ".", "sort", "(", "function", "(", "a", ",", "b", ")", "{", "a", "=", "Math", ".", "abs", "(", "Math", ".", "max", "(", "a", ".", "top", "-", "clientY", ",", "a", ".", "bottom", "-", "clientY", ")", ")", ";", "b", "=", "Math", ".", "abs", "(", "Math", ".", "max", "(", "b", ".", "top", "-", "clientY", ",", "b", ".", "bottom", "-", "clientY", ")", ")", ";", "return", "a", "-", "b", ";", "}", ")", ";", "if", "(", "rects", ".", "length", ">", "0", ")", "{", "clientY", "=", "(", "rects", "[", "0", "]", ".", "bottom", "+", "rects", "[", "0", "]", ".", "top", ")", "/", "2", ";", "try", "{", "rng", ".", "moveToPoint", "(", "clientX", ",", "clientY", ")", ";", "rng", ".", "collapse", "(", "true", ")", ";", "return", "rng", ";", "}", "catch", "(", "ex", ")", "{", "// At least we tried", "}", "}", "return", "null", ";", "}" ]
Finds the closest selection rect tries to get the range from that.
[ "Finds", "the", "closest", "selection", "rect", "tries", "to", "get", "the", "range", "from", "that", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L10913-L10947
48,181
sadiqhabib/tinymce-dist
tinymce.full.js
Node
function Node(name, type) { this.name = name; this.type = type; if (type === 1) { this.attributes = []; this.attributes.map = {}; } }
javascript
function Node(name, type) { this.name = name; this.type = type; if (type === 1) { this.attributes = []; this.attributes.map = {}; } }
[ "function", "Node", "(", "name", ",", "type", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "type", "=", "type", ";", "if", "(", "type", "===", "1", ")", "{", "this", ".", "attributes", "=", "[", "]", ";", "this", ".", "attributes", ".", "map", "=", "{", "}", ";", "}", "}" ]
Constructs a new Node instance. @constructor @method Node @param {String} name Name of the node type. @param {Number} type Numeric type representing the node.
[ "Constructs", "a", "new", "Node", "instance", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L11088-L11096
48,182
sadiqhabib/tinymce-dist
tinymce.full.js
function (node, refNode, before) { var parent; if (node.parent) { node.remove(); } parent = refNode.parent || this; if (before) { if (refNode === parent.firstChild) { parent.firstChild = node; } else { refNode.prev.next = node; } node.prev = refNode.prev; node.next = refNode; refNode.prev = node; } else { if (refNode === parent.lastChild) { parent.lastChild = node; } else { refNode.next.prev = node; } node.next = refNode.next; node.prev = refNode; refNode.next = node; } node.parent = parent; return node; }
javascript
function (node, refNode, before) { var parent; if (node.parent) { node.remove(); } parent = refNode.parent || this; if (before) { if (refNode === parent.firstChild) { parent.firstChild = node; } else { refNode.prev.next = node; } node.prev = refNode.prev; node.next = refNode; refNode.prev = node; } else { if (refNode === parent.lastChild) { parent.lastChild = node; } else { refNode.next.prev = node; } node.next = refNode.next; node.prev = refNode; refNode.next = node; } node.parent = parent; return node; }
[ "function", "(", "node", ",", "refNode", ",", "before", ")", "{", "var", "parent", ";", "if", "(", "node", ".", "parent", ")", "{", "node", ".", "remove", "(", ")", ";", "}", "parent", "=", "refNode", ".", "parent", "||", "this", ";", "if", "(", "before", ")", "{", "if", "(", "refNode", "===", "parent", ".", "firstChild", ")", "{", "parent", ".", "firstChild", "=", "node", ";", "}", "else", "{", "refNode", ".", "prev", ".", "next", "=", "node", ";", "}", "node", ".", "prev", "=", "refNode", ".", "prev", ";", "node", ".", "next", "=", "refNode", ";", "refNode", ".", "prev", "=", "node", ";", "}", "else", "{", "if", "(", "refNode", "===", "parent", ".", "lastChild", ")", "{", "parent", ".", "lastChild", "=", "node", ";", "}", "else", "{", "refNode", ".", "next", ".", "prev", "=", "node", ";", "}", "node", ".", "next", "=", "refNode", ".", "next", ";", "node", ".", "prev", "=", "refNode", ";", "refNode", ".", "next", "=", "node", ";", "}", "node", ".", "parent", "=", "parent", ";", "return", "node", ";", "}" ]
Inserts a node at a specific position as a child of the current node. @example parentNode.insert(newChildNode, oldChildNode); @method insert @param {tinymce.html.Node} node Node to insert as a child of the current node. @param {tinymce.html.Node} refNode Reference node to set node before/after. @param {Boolean} before Optional state to insert the node before the reference node. @return {tinymce.html.Node} The node that got inserted.
[ "Inserts", "a", "node", "at", "a", "specific", "position", "as", "a", "child", "of", "the", "current", "node", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L11344-L11378
48,183
sadiqhabib/tinymce-dist
tinymce.full.js
addCustomElements
function addCustomElements(customElements) { var customElementRegExp = /^(~)?(.+)$/; if (customElements) { // Flush cached items since we are altering the default maps mapCache.text_block_elements = mapCache.block_elements = null; each(split(customElements, ','), function (rule) { var matches = customElementRegExp.exec(rule), inline = matches[1] === '~', cloneName = inline ? 'span' : 'div', name = matches[2]; children[name] = children[cloneName]; customElementsMap[name] = cloneName; // If it's not marked as inline then add it to valid block elements if (!inline) { blockElementsMap[name.toUpperCase()] = {}; blockElementsMap[name] = {}; } // Add elements clone if needed if (!elements[name]) { var customRule = elements[cloneName]; customRule = extend({}, customRule); delete customRule.removeEmptyAttrs; delete customRule.removeEmpty; elements[name] = customRule; } // Add custom elements at span/div positions each(children, function (element, elmName) { if (element[cloneName]) { children[elmName] = element = extend({}, children[elmName]); element[name] = element[cloneName]; } }); }); } }
javascript
function addCustomElements(customElements) { var customElementRegExp = /^(~)?(.+)$/; if (customElements) { // Flush cached items since we are altering the default maps mapCache.text_block_elements = mapCache.block_elements = null; each(split(customElements, ','), function (rule) { var matches = customElementRegExp.exec(rule), inline = matches[1] === '~', cloneName = inline ? 'span' : 'div', name = matches[2]; children[name] = children[cloneName]; customElementsMap[name] = cloneName; // If it's not marked as inline then add it to valid block elements if (!inline) { blockElementsMap[name.toUpperCase()] = {}; blockElementsMap[name] = {}; } // Add elements clone if needed if (!elements[name]) { var customRule = elements[cloneName]; customRule = extend({}, customRule); delete customRule.removeEmptyAttrs; delete customRule.removeEmpty; elements[name] = customRule; } // Add custom elements at span/div positions each(children, function (element, elmName) { if (element[cloneName]) { children[elmName] = element = extend({}, children[elmName]); element[name] = element[cloneName]; } }); }); } }
[ "function", "addCustomElements", "(", "customElements", ")", "{", "var", "customElementRegExp", "=", "/", "^(~)?(.+)$", "/", ";", "if", "(", "customElements", ")", "{", "// Flush cached items since we are altering the default maps", "mapCache", ".", "text_block_elements", "=", "mapCache", ".", "block_elements", "=", "null", ";", "each", "(", "split", "(", "customElements", ",", "','", ")", ",", "function", "(", "rule", ")", "{", "var", "matches", "=", "customElementRegExp", ".", "exec", "(", "rule", ")", ",", "inline", "=", "matches", "[", "1", "]", "===", "'~'", ",", "cloneName", "=", "inline", "?", "'span'", ":", "'div'", ",", "name", "=", "matches", "[", "2", "]", ";", "children", "[", "name", "]", "=", "children", "[", "cloneName", "]", ";", "customElementsMap", "[", "name", "]", "=", "cloneName", ";", "// If it's not marked as inline then add it to valid block elements", "if", "(", "!", "inline", ")", "{", "blockElementsMap", "[", "name", ".", "toUpperCase", "(", ")", "]", "=", "{", "}", ";", "blockElementsMap", "[", "name", "]", "=", "{", "}", ";", "}", "// Add elements clone if needed", "if", "(", "!", "elements", "[", "name", "]", ")", "{", "var", "customRule", "=", "elements", "[", "cloneName", "]", ";", "customRule", "=", "extend", "(", "{", "}", ",", "customRule", ")", ";", "delete", "customRule", ".", "removeEmptyAttrs", ";", "delete", "customRule", ".", "removeEmpty", ";", "elements", "[", "name", "]", "=", "customRule", ";", "}", "// Add custom elements at span/div positions", "each", "(", "children", ",", "function", "(", "element", ",", "elmName", ")", "{", "if", "(", "element", "[", "cloneName", "]", ")", "{", "children", "[", "elmName", "]", "=", "element", "=", "extend", "(", "{", "}", ",", "children", "[", "elmName", "]", ")", ";", "element", "[", "name", "]", "=", "element", "[", "cloneName", "]", ";", "}", "}", ")", ";", "}", ")", ";", "}", "}" ]
Adds custom non HTML elements to the schema
[ "Adds", "custom", "non", "HTML", "elements", "to", "the", "schema" ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L12107-L12149
48,184
sadiqhabib/tinymce-dist
tinymce.full.js
findEndTag
function findEndTag(schema, html, startIndex) { var count = 1, index, matches, tokenRegExp, shortEndedElements; shortEndedElements = schema.getShortEndedElements(); tokenRegExp = /<([!?\/])?([A-Za-z0-9\-_\:\.]+)((?:\s+[^"\'>]+(?:(?:"[^"]*")|(?:\'[^\']*\')|[^>]*))*|\/|\s+)>/g; tokenRegExp.lastIndex = index = startIndex; while ((matches = tokenRegExp.exec(html))) { index = tokenRegExp.lastIndex; if (matches[1] === '/') { // End element count--; } else if (!matches[1]) { // Start element if (matches[2] in shortEndedElements) { continue; } count++; } if (count === 0) { break; } } return index; }
javascript
function findEndTag(schema, html, startIndex) { var count = 1, index, matches, tokenRegExp, shortEndedElements; shortEndedElements = schema.getShortEndedElements(); tokenRegExp = /<([!?\/])?([A-Za-z0-9\-_\:\.]+)((?:\s+[^"\'>]+(?:(?:"[^"]*")|(?:\'[^\']*\')|[^>]*))*|\/|\s+)>/g; tokenRegExp.lastIndex = index = startIndex; while ((matches = tokenRegExp.exec(html))) { index = tokenRegExp.lastIndex; if (matches[1] === '/') { // End element count--; } else if (!matches[1]) { // Start element if (matches[2] in shortEndedElements) { continue; } count++; } if (count === 0) { break; } } return index; }
[ "function", "findEndTag", "(", "schema", ",", "html", ",", "startIndex", ")", "{", "var", "count", "=", "1", ",", "index", ",", "matches", ",", "tokenRegExp", ",", "shortEndedElements", ";", "shortEndedElements", "=", "schema", ".", "getShortEndedElements", "(", ")", ";", "tokenRegExp", "=", "/", "<([!?\\/])?([A-Za-z0-9\\-_\\:\\.]+)((?:\\s+[^\"\\'>]+(?:(?:\"[^\"]*\")|(?:\\'[^\\']*\\')|[^>]*))*|\\/|\\s+)>", "/", "g", ";", "tokenRegExp", ".", "lastIndex", "=", "index", "=", "startIndex", ";", "while", "(", "(", "matches", "=", "tokenRegExp", ".", "exec", "(", "html", ")", ")", ")", "{", "index", "=", "tokenRegExp", ".", "lastIndex", ";", "if", "(", "matches", "[", "1", "]", "===", "'/'", ")", "{", "// End element", "count", "--", ";", "}", "else", "if", "(", "!", "matches", "[", "1", "]", ")", "{", "// Start element", "if", "(", "matches", "[", "2", "]", "in", "shortEndedElements", ")", "{", "continue", ";", "}", "count", "++", ";", "}", "if", "(", "count", "===", "0", ")", "{", "break", ";", "}", "}", "return", "index", ";", "}" ]
Returns the index of the end tag for a specific start tag. This can be used to skip all children of a parent element from being processed. @private @method findEndTag @param {tinymce.html.Schema} schema Schema instance to use to match short ended elements. @param {String} html HTML string to find the end tag in. @param {Number} startIndex Indext to start searching at should be after the start tag. @return {Number} Index of the end tag.
[ "Returns", "the", "index", "of", "the", "end", "tag", "for", "a", "specific", "start", "tag", ".", "This", "can", "be", "used", "to", "skip", "all", "children", "of", "a", "parent", "element", "from", "being", "processed", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L12631-L12657
48,185
sadiqhabib/tinymce-dist
tinymce.full.js
getBrClientRect
function getBrClientRect(brNode) { var doc = brNode.ownerDocument, rng = createRange(doc), nbsp = doc.createTextNode('\u00a0'), parentNode = brNode.parentNode, clientRect; parentNode.insertBefore(nbsp, brNode); rng.setStart(nbsp, 0); rng.setEnd(nbsp, 1); clientRect = ClientRect.clone(rng.getBoundingClientRect()); parentNode.removeChild(nbsp); return clientRect; }
javascript
function getBrClientRect(brNode) { var doc = brNode.ownerDocument, rng = createRange(doc), nbsp = doc.createTextNode('\u00a0'), parentNode = brNode.parentNode, clientRect; parentNode.insertBefore(nbsp, brNode); rng.setStart(nbsp, 0); rng.setEnd(nbsp, 1); clientRect = ClientRect.clone(rng.getBoundingClientRect()); parentNode.removeChild(nbsp); return clientRect; }
[ "function", "getBrClientRect", "(", "brNode", ")", "{", "var", "doc", "=", "brNode", ".", "ownerDocument", ",", "rng", "=", "createRange", "(", "doc", ")", ",", "nbsp", "=", "doc", ".", "createTextNode", "(", "'\\u00a0'", ")", ",", "parentNode", "=", "brNode", ".", "parentNode", ",", "clientRect", ";", "parentNode", ".", "insertBefore", "(", "nbsp", ",", "brNode", ")", ";", "rng", ".", "setStart", "(", "nbsp", ",", "0", ")", ";", "rng", ".", "setEnd", "(", "nbsp", ",", "1", ")", ";", "clientRect", "=", "ClientRect", ".", "clone", "(", "rng", ".", "getBoundingClientRect", "(", ")", ")", ";", "parentNode", ".", "removeChild", "(", "nbsp", ")", ";", "return", "clientRect", ";", "}" ]
Hack for older WebKit versions that doesn't support getBoundingClientRect on BR elements
[ "Hack", "for", "older", "WebKit", "versions", "that", "doesn", "t", "support", "getBoundingClientRect", "on", "BR", "elements" ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L15952-L15966
48,186
sadiqhabib/tinymce-dist
tinymce.full.js
CaretPosition
function CaretPosition(container, offset, clientRects) { function isAtStart() { if (isText(container)) { return offset === 0; } return offset === 0; } function isAtEnd() { if (isText(container)) { return offset >= container.data.length; } return offset >= container.childNodes.length; } function toRange() { var range; range = createRange(container.ownerDocument); range.setStart(container, offset); range.setEnd(container, offset); return range; } function getClientRects() { if (!clientRects) { clientRects = getCaretPositionClientRects(new CaretPosition(container, offset)); } return clientRects; } function isVisible() { return getClientRects().length > 0; } function isEqual(caretPosition) { return caretPosition && container === caretPosition.container() && offset === caretPosition.offset(); } function getNode(before) { return resolveIndex(container, before ? offset - 1 : offset); } return { /** * Returns the container node. * * @method container * @return {Node} Container node. */ container: Fun.constant(container), /** * Returns the offset within the container node. * * @method offset * @return {Number} Offset within the container node. */ offset: Fun.constant(offset), /** * Returns a range out of a the caret position. * * @method toRange * @return {DOMRange} range for the caret position. */ toRange: toRange, /** * Returns the client rects for the caret position. Might be multiple rects between * block elements. * * @method getClientRects * @return {Array} Array of client rects. */ getClientRects: getClientRects, /** * Returns true if the caret location is visible/displayed on screen. * * @method isVisible * @return {Boolean} true/false if the position is visible or not. */ isVisible: isVisible, /** * Returns true if the caret location is at the beginning of text node or container. * * @method isVisible * @return {Boolean} true/false if the position is at the beginning. */ isAtStart: isAtStart, /** * Returns true if the caret location is at the end of text node or container. * * @method isVisible * @return {Boolean} true/false if the position is at the end. */ isAtEnd: isAtEnd, /** * Compares the caret position to another caret position. This will only compare the * container and offset not it's visual position. * * @method isEqual * @param {tinymce.caret.CaretPosition} caretPosition Caret position to compare with. * @return {Boolean} true if the caret positions are equal. */ isEqual: isEqual, /** * Returns the closest resolved node from a node index. That means if you have an offset after the * last node in a container it will return that last node. * * @method getNode * @return {Node} Node that is closest to the index. */ getNode: getNode }; }
javascript
function CaretPosition(container, offset, clientRects) { function isAtStart() { if (isText(container)) { return offset === 0; } return offset === 0; } function isAtEnd() { if (isText(container)) { return offset >= container.data.length; } return offset >= container.childNodes.length; } function toRange() { var range; range = createRange(container.ownerDocument); range.setStart(container, offset); range.setEnd(container, offset); return range; } function getClientRects() { if (!clientRects) { clientRects = getCaretPositionClientRects(new CaretPosition(container, offset)); } return clientRects; } function isVisible() { return getClientRects().length > 0; } function isEqual(caretPosition) { return caretPosition && container === caretPosition.container() && offset === caretPosition.offset(); } function getNode(before) { return resolveIndex(container, before ? offset - 1 : offset); } return { /** * Returns the container node. * * @method container * @return {Node} Container node. */ container: Fun.constant(container), /** * Returns the offset within the container node. * * @method offset * @return {Number} Offset within the container node. */ offset: Fun.constant(offset), /** * Returns a range out of a the caret position. * * @method toRange * @return {DOMRange} range for the caret position. */ toRange: toRange, /** * Returns the client rects for the caret position. Might be multiple rects between * block elements. * * @method getClientRects * @return {Array} Array of client rects. */ getClientRects: getClientRects, /** * Returns true if the caret location is visible/displayed on screen. * * @method isVisible * @return {Boolean} true/false if the position is visible or not. */ isVisible: isVisible, /** * Returns true if the caret location is at the beginning of text node or container. * * @method isVisible * @return {Boolean} true/false if the position is at the beginning. */ isAtStart: isAtStart, /** * Returns true if the caret location is at the end of text node or container. * * @method isVisible * @return {Boolean} true/false if the position is at the end. */ isAtEnd: isAtEnd, /** * Compares the caret position to another caret position. This will only compare the * container and offset not it's visual position. * * @method isEqual * @param {tinymce.caret.CaretPosition} caretPosition Caret position to compare with. * @return {Boolean} true if the caret positions are equal. */ isEqual: isEqual, /** * Returns the closest resolved node from a node index. That means if you have an offset after the * last node in a container it will return that last node. * * @method getNode * @return {Node} Node that is closest to the index. */ getNode: getNode }; }
[ "function", "CaretPosition", "(", "container", ",", "offset", ",", "clientRects", ")", "{", "function", "isAtStart", "(", ")", "{", "if", "(", "isText", "(", "container", ")", ")", "{", "return", "offset", "===", "0", ";", "}", "return", "offset", "===", "0", ";", "}", "function", "isAtEnd", "(", ")", "{", "if", "(", "isText", "(", "container", ")", ")", "{", "return", "offset", ">=", "container", ".", "data", ".", "length", ";", "}", "return", "offset", ">=", "container", ".", "childNodes", ".", "length", ";", "}", "function", "toRange", "(", ")", "{", "var", "range", ";", "range", "=", "createRange", "(", "container", ".", "ownerDocument", ")", ";", "range", ".", "setStart", "(", "container", ",", "offset", ")", ";", "range", ".", "setEnd", "(", "container", ",", "offset", ")", ";", "return", "range", ";", "}", "function", "getClientRects", "(", ")", "{", "if", "(", "!", "clientRects", ")", "{", "clientRects", "=", "getCaretPositionClientRects", "(", "new", "CaretPosition", "(", "container", ",", "offset", ")", ")", ";", "}", "return", "clientRects", ";", "}", "function", "isVisible", "(", ")", "{", "return", "getClientRects", "(", ")", ".", "length", ">", "0", ";", "}", "function", "isEqual", "(", "caretPosition", ")", "{", "return", "caretPosition", "&&", "container", "===", "caretPosition", ".", "container", "(", ")", "&&", "offset", "===", "caretPosition", ".", "offset", "(", ")", ";", "}", "function", "getNode", "(", "before", ")", "{", "return", "resolveIndex", "(", "container", ",", "before", "?", "offset", "-", "1", ":", "offset", ")", ";", "}", "return", "{", "/**\n * Returns the container node.\n *\n * @method container\n * @return {Node} Container node.\n */", "container", ":", "Fun", ".", "constant", "(", "container", ")", ",", "/**\n * Returns the offset within the container node.\n *\n * @method offset\n * @return {Number} Offset within the container node.\n */", "offset", ":", "Fun", ".", "constant", "(", "offset", ")", ",", "/**\n * Returns a range out of a the caret position.\n *\n * @method toRange\n * @return {DOMRange} range for the caret position.\n */", "toRange", ":", "toRange", ",", "/**\n * Returns the client rects for the caret position. Might be multiple rects between\n * block elements.\n *\n * @method getClientRects\n * @return {Array} Array of client rects.\n */", "getClientRects", ":", "getClientRects", ",", "/**\n * Returns true if the caret location is visible/displayed on screen.\n *\n * @method isVisible\n * @return {Boolean} true/false if the position is visible or not.\n */", "isVisible", ":", "isVisible", ",", "/**\n * Returns true if the caret location is at the beginning of text node or container.\n *\n * @method isVisible\n * @return {Boolean} true/false if the position is at the beginning.\n */", "isAtStart", ":", "isAtStart", ",", "/**\n * Returns true if the caret location is at the end of text node or container.\n *\n * @method isVisible\n * @return {Boolean} true/false if the position is at the end.\n */", "isAtEnd", ":", "isAtEnd", ",", "/**\n * Compares the caret position to another caret position. This will only compare the\n * container and offset not it's visual position.\n *\n * @method isEqual\n * @param {tinymce.caret.CaretPosition} caretPosition Caret position to compare with.\n * @return {Boolean} true if the caret positions are equal.\n */", "isEqual", ":", "isEqual", ",", "/**\n * Returns the closest resolved node from a node index. That means if you have an offset after the\n * last node in a container it will return that last node.\n *\n * @method getNode\n * @return {Node} Node that is closest to the index.\n */", "getNode", ":", "getNode", "}", ";", "}" ]
Represents a location within the document by a container and an offset. @constructor @param {Node} container Container node. @param {Number} offset Offset within that container node. @param {Array} clientRects Optional client rects array for the position.
[ "Represents", "a", "location", "within", "the", "document", "by", "a", "container", "and", "an", "offset", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L16097-L16221
48,187
sadiqhabib/tinymce-dist
tinymce.full.js
Selection
function Selection(dom, win, serializer, editor) { var self = this; self.dom = dom; self.win = win; self.serializer = serializer; self.editor = editor; self.bookmarkManager = new BookmarkManager(self); self.controlSelection = new ControlSelection(self, editor); // No W3C Range support if (!self.win.getSelection) { self.tridentSel = new TridentSelection(self); } }
javascript
function Selection(dom, win, serializer, editor) { var self = this; self.dom = dom; self.win = win; self.serializer = serializer; self.editor = editor; self.bookmarkManager = new BookmarkManager(self); self.controlSelection = new ControlSelection(self, editor); // No W3C Range support if (!self.win.getSelection) { self.tridentSel = new TridentSelection(self); } }
[ "function", "Selection", "(", "dom", ",", "win", ",", "serializer", ",", "editor", ")", "{", "var", "self", "=", "this", ";", "self", ".", "dom", "=", "dom", ";", "self", ".", "win", "=", "win", ";", "self", ".", "serializer", "=", "serializer", ";", "self", ".", "editor", "=", "editor", ";", "self", ".", "bookmarkManager", "=", "new", "BookmarkManager", "(", "self", ")", ";", "self", ".", "controlSelection", "=", "new", "ControlSelection", "(", "self", ",", "editor", ")", ";", "// No W3C Range support", "if", "(", "!", "self", ".", "win", ".", "getSelection", ")", "{", "self", ".", "tridentSel", "=", "new", "TridentSelection", "(", "self", ")", ";", "}", "}" ]
Constructs a new selection instance. @constructor @method Selection @param {tinymce.dom.DOMUtils} dom DOMUtils object reference. @param {Window} win Window to bind the selection object to. @param {tinymce.Editor} editor Editor instance of the selection. @param {tinymce.dom.Serializer} serializer DOM serialization class to use for getContent.
[ "Constructs", "a", "new", "selection", "instance", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L17565-L17579
48,188
sadiqhabib/tinymce-dist
tinymce.full.js
function (node, offset) { var self = this, rng = self.dom.createRng(); if (!node) { self._moveEndPoint(rng, self.editor.getBody(), true); self.setRng(rng); } else { rng.setStart(node, offset); rng.setEnd(node, offset); self.setRng(rng); self.collapse(false); } }
javascript
function (node, offset) { var self = this, rng = self.dom.createRng(); if (!node) { self._moveEndPoint(rng, self.editor.getBody(), true); self.setRng(rng); } else { rng.setStart(node, offset); rng.setEnd(node, offset); self.setRng(rng); self.collapse(false); } }
[ "function", "(", "node", ",", "offset", ")", "{", "var", "self", "=", "this", ",", "rng", "=", "self", ".", "dom", ".", "createRng", "(", ")", ";", "if", "(", "!", "node", ")", "{", "self", ".", "_moveEndPoint", "(", "rng", ",", "self", ".", "editor", ".", "getBody", "(", ")", ",", "true", ")", ";", "self", ".", "setRng", "(", "rng", ")", ";", "}", "else", "{", "rng", ".", "setStart", "(", "node", ",", "offset", ")", ";", "rng", ".", "setEnd", "(", "node", ",", "offset", ")", ";", "self", ".", "setRng", "(", "rng", ")", ";", "self", ".", "collapse", "(", "false", ")", ";", "}", "}" ]
Move the selection cursor range to the specified node and offset. If there is no node specified it will move it to the first suitable location within the body. @method setCursorLocation @param {Node} node Optional node to put the cursor in. @param {Number} offset Optional offset from the start of the node to put the cursor at.
[ "Move", "the", "selection", "cursor", "range", "to", "the", "specified", "node", "and", "offset", ".", "If", "there", "is", "no", "node", "specified", "it", "will", "move", "it", "to", "the", "first", "suitable", "location", "within", "the", "body", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L17590-L17602
48,189
sadiqhabib/tinymce-dist
tinymce.full.js
function (node, content) { var self = this, dom = self.dom, rng = dom.createRng(), idx; // Clear stored range set by FocusManager self.lastFocusBookmark = null; if (node) { if (!content && self.controlSelection.controlSelect(node)) { return; } idx = dom.nodeIndex(node); rng.setStart(node.parentNode, idx); rng.setEnd(node.parentNode, idx + 1); // Find first/last text node or BR element if (content) { self._moveEndPoint(rng, node, true); self._moveEndPoint(rng, node); } self.setRng(rng); } return node; }
javascript
function (node, content) { var self = this, dom = self.dom, rng = dom.createRng(), idx; // Clear stored range set by FocusManager self.lastFocusBookmark = null; if (node) { if (!content && self.controlSelection.controlSelect(node)) { return; } idx = dom.nodeIndex(node); rng.setStart(node.parentNode, idx); rng.setEnd(node.parentNode, idx + 1); // Find first/last text node or BR element if (content) { self._moveEndPoint(rng, node, true); self._moveEndPoint(rng, node); } self.setRng(rng); } return node; }
[ "function", "(", "node", ",", "content", ")", "{", "var", "self", "=", "this", ",", "dom", "=", "self", ".", "dom", ",", "rng", "=", "dom", ".", "createRng", "(", ")", ",", "idx", ";", "// Clear stored range set by FocusManager", "self", ".", "lastFocusBookmark", "=", "null", ";", "if", "(", "node", ")", "{", "if", "(", "!", "content", "&&", "self", ".", "controlSelection", ".", "controlSelect", "(", "node", ")", ")", "{", "return", ";", "}", "idx", "=", "dom", ".", "nodeIndex", "(", "node", ")", ";", "rng", ".", "setStart", "(", "node", ".", "parentNode", ",", "idx", ")", ";", "rng", ".", "setEnd", "(", "node", ".", "parentNode", ",", "idx", "+", "1", ")", ";", "// Find first/last text node or BR element", "if", "(", "content", ")", "{", "self", ".", "_moveEndPoint", "(", "rng", ",", "node", ",", "true", ")", ";", "self", ".", "_moveEndPoint", "(", "rng", ",", "node", ")", ";", "}", "self", ".", "setRng", "(", "rng", ")", ";", "}", "return", "node", ";", "}" ]
Selects the specified element. This will place the start and end of the selection range around the element. @method select @param {Element} node HTML DOM element to select. @param {Boolean} content Optional bool state if the contents should be selected or not on non IE browser. @return {Element} Selected element the same element as the one that got passed in. @example // Select the first paragraph in the active editor tinymce.activeEditor.selection.select(tinymce.activeEditor.dom.select('p')[0]);
[ "Selects", "the", "specified", "element", ".", "This", "will", "place", "the", "start", "and", "end", "of", "the", "selection", "range", "around", "the", "element", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L17911-L17936
48,190
sadiqhabib/tinymce-dist
tinymce.full.js
function (toStart) { var self = this, rng = self.getRng(), node; // Control range on IE if (rng.item) { node = rng.item(0); rng = self.win.document.body.createTextRange(); rng.moveToElementText(node); } rng.collapse(!!toStart); self.setRng(rng); }
javascript
function (toStart) { var self = this, rng = self.getRng(), node; // Control range on IE if (rng.item) { node = rng.item(0); rng = self.win.document.body.createTextRange(); rng.moveToElementText(node); } rng.collapse(!!toStart); self.setRng(rng); }
[ "function", "(", "toStart", ")", "{", "var", "self", "=", "this", ",", "rng", "=", "self", ".", "getRng", "(", ")", ",", "node", ";", "// Control range on IE", "if", "(", "rng", ".", "item", ")", "{", "node", "=", "rng", ".", "item", "(", "0", ")", ";", "rng", "=", "self", ".", "win", ".", "document", ".", "body", ".", "createTextRange", "(", ")", ";", "rng", ".", "moveToElementText", "(", "node", ")", ";", "}", "rng", ".", "collapse", "(", "!", "!", "toStart", ")", ";", "self", ".", "setRng", "(", "rng", ")", ";", "}" ]
Collapse the selection to start or end of range. @method collapse @param {Boolean} toStart Optional boolean state if to collapse to end or not. Defaults to false.
[ "Collapse", "the", "selection", "to", "start", "or", "end", "of", "range", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L17965-L17977
48,191
sadiqhabib/tinymce-dist
tinymce.full.js
function (w3c) { var self = this, selection, rng, elm, doc, ieRng, evt; function tryCompareBoundaryPoints(how, sourceRange, destinationRange) { try { return sourceRange.compareBoundaryPoints(how, destinationRange); } catch (ex) { // Gecko throws wrong document exception if the range points // to nodes that where removed from the dom #6690 // Browsers should mutate existing DOMRange instances so that they always point // to something in the document this is not the case in Gecko works fine in IE/WebKit/Blink // For performance reasons just return -1 return -1; } } if (!self.win) { return null; } doc = self.win.document; if (typeof doc === 'undefined' || doc === null) { return null; } // Use last rng passed from FocusManager if it's available this enables // calls to editor.selection.getStart() to work when caret focus is lost on IE if (!w3c && self.lastFocusBookmark) { var bookmark = self.lastFocusBookmark; // Convert bookmark to range IE 11 fix if (bookmark.startContainer) { rng = doc.createRange(); rng.setStart(bookmark.startContainer, bookmark.startOffset); rng.setEnd(bookmark.endContainer, bookmark.endOffset); } else { rng = bookmark; } return rng; } // Found tridentSel object then we need to use that one if (w3c && self.tridentSel) { return self.tridentSel.getRangeAt(0); } try { if ((selection = self.getSel())) { if (selection.rangeCount > 0) { rng = selection.getRangeAt(0); } else { rng = selection.createRange ? selection.createRange() : doc.createRange(); } } } catch (ex) { // IE throws unspecified error here if TinyMCE is placed in a frame/iframe } evt = self.editor.fire('GetSelectionRange', { range: rng }); if (evt.range !== rng) { return evt.range; } // We have W3C ranges and it's IE then fake control selection since IE9 doesn't handle that correctly yet // IE 11 doesn't support the selection object so we check for that as well if (isIE && rng && rng.setStart && doc.selection) { try { // IE will sometimes throw an exception here ieRng = doc.selection.createRange(); } catch (ex) { // Ignore } if (ieRng && ieRng.item) { elm = ieRng.item(0); rng = doc.createRange(); rng.setStartBefore(elm); rng.setEndAfter(elm); } } // No range found then create an empty one // This can occur when the editor is placed in a hidden container element on Gecko // Or on IE when there was an exception if (!rng) { rng = doc.createRange ? doc.createRange() : doc.body.createTextRange(); } // If range is at start of document then move it to start of body if (rng.setStart && rng.startContainer.nodeType === 9 && rng.collapsed) { elm = self.dom.getRoot(); rng.setStart(elm, 0); rng.setEnd(elm, 0); } if (self.selectedRange && self.explicitRange) { if (tryCompareBoundaryPoints(rng.START_TO_START, rng, self.selectedRange) === 0 && tryCompareBoundaryPoints(rng.END_TO_END, rng, self.selectedRange) === 0) { // Safari, Opera and Chrome only ever select text which causes the range to change. // This lets us use the originally set range if the selection hasn't been changed by the user. rng = self.explicitRange; } else { self.selectedRange = null; self.explicitRange = null; } } return rng; }
javascript
function (w3c) { var self = this, selection, rng, elm, doc, ieRng, evt; function tryCompareBoundaryPoints(how, sourceRange, destinationRange) { try { return sourceRange.compareBoundaryPoints(how, destinationRange); } catch (ex) { // Gecko throws wrong document exception if the range points // to nodes that where removed from the dom #6690 // Browsers should mutate existing DOMRange instances so that they always point // to something in the document this is not the case in Gecko works fine in IE/WebKit/Blink // For performance reasons just return -1 return -1; } } if (!self.win) { return null; } doc = self.win.document; if (typeof doc === 'undefined' || doc === null) { return null; } // Use last rng passed from FocusManager if it's available this enables // calls to editor.selection.getStart() to work when caret focus is lost on IE if (!w3c && self.lastFocusBookmark) { var bookmark = self.lastFocusBookmark; // Convert bookmark to range IE 11 fix if (bookmark.startContainer) { rng = doc.createRange(); rng.setStart(bookmark.startContainer, bookmark.startOffset); rng.setEnd(bookmark.endContainer, bookmark.endOffset); } else { rng = bookmark; } return rng; } // Found tridentSel object then we need to use that one if (w3c && self.tridentSel) { return self.tridentSel.getRangeAt(0); } try { if ((selection = self.getSel())) { if (selection.rangeCount > 0) { rng = selection.getRangeAt(0); } else { rng = selection.createRange ? selection.createRange() : doc.createRange(); } } } catch (ex) { // IE throws unspecified error here if TinyMCE is placed in a frame/iframe } evt = self.editor.fire('GetSelectionRange', { range: rng }); if (evt.range !== rng) { return evt.range; } // We have W3C ranges and it's IE then fake control selection since IE9 doesn't handle that correctly yet // IE 11 doesn't support the selection object so we check for that as well if (isIE && rng && rng.setStart && doc.selection) { try { // IE will sometimes throw an exception here ieRng = doc.selection.createRange(); } catch (ex) { // Ignore } if (ieRng && ieRng.item) { elm = ieRng.item(0); rng = doc.createRange(); rng.setStartBefore(elm); rng.setEndAfter(elm); } } // No range found then create an empty one // This can occur when the editor is placed in a hidden container element on Gecko // Or on IE when there was an exception if (!rng) { rng = doc.createRange ? doc.createRange() : doc.body.createTextRange(); } // If range is at start of document then move it to start of body if (rng.setStart && rng.startContainer.nodeType === 9 && rng.collapsed) { elm = self.dom.getRoot(); rng.setStart(elm, 0); rng.setEnd(elm, 0); } if (self.selectedRange && self.explicitRange) { if (tryCompareBoundaryPoints(rng.START_TO_START, rng, self.selectedRange) === 0 && tryCompareBoundaryPoints(rng.END_TO_END, rng, self.selectedRange) === 0) { // Safari, Opera and Chrome only ever select text which causes the range to change. // This lets us use the originally set range if the selection hasn't been changed by the user. rng = self.explicitRange; } else { self.selectedRange = null; self.explicitRange = null; } } return rng; }
[ "function", "(", "w3c", ")", "{", "var", "self", "=", "this", ",", "selection", ",", "rng", ",", "elm", ",", "doc", ",", "ieRng", ",", "evt", ";", "function", "tryCompareBoundaryPoints", "(", "how", ",", "sourceRange", ",", "destinationRange", ")", "{", "try", "{", "return", "sourceRange", ".", "compareBoundaryPoints", "(", "how", ",", "destinationRange", ")", ";", "}", "catch", "(", "ex", ")", "{", "// Gecko throws wrong document exception if the range points", "// to nodes that where removed from the dom #6690", "// Browsers should mutate existing DOMRange instances so that they always point", "// to something in the document this is not the case in Gecko works fine in IE/WebKit/Blink", "// For performance reasons just return -1", "return", "-", "1", ";", "}", "}", "if", "(", "!", "self", ".", "win", ")", "{", "return", "null", ";", "}", "doc", "=", "self", ".", "win", ".", "document", ";", "if", "(", "typeof", "doc", "===", "'undefined'", "||", "doc", "===", "null", ")", "{", "return", "null", ";", "}", "// Use last rng passed from FocusManager if it's available this enables", "// calls to editor.selection.getStart() to work when caret focus is lost on IE", "if", "(", "!", "w3c", "&&", "self", ".", "lastFocusBookmark", ")", "{", "var", "bookmark", "=", "self", ".", "lastFocusBookmark", ";", "// Convert bookmark to range IE 11 fix", "if", "(", "bookmark", ".", "startContainer", ")", "{", "rng", "=", "doc", ".", "createRange", "(", ")", ";", "rng", ".", "setStart", "(", "bookmark", ".", "startContainer", ",", "bookmark", ".", "startOffset", ")", ";", "rng", ".", "setEnd", "(", "bookmark", ".", "endContainer", ",", "bookmark", ".", "endOffset", ")", ";", "}", "else", "{", "rng", "=", "bookmark", ";", "}", "return", "rng", ";", "}", "// Found tridentSel object then we need to use that one", "if", "(", "w3c", "&&", "self", ".", "tridentSel", ")", "{", "return", "self", ".", "tridentSel", ".", "getRangeAt", "(", "0", ")", ";", "}", "try", "{", "if", "(", "(", "selection", "=", "self", ".", "getSel", "(", ")", ")", ")", "{", "if", "(", "selection", ".", "rangeCount", ">", "0", ")", "{", "rng", "=", "selection", ".", "getRangeAt", "(", "0", ")", ";", "}", "else", "{", "rng", "=", "selection", ".", "createRange", "?", "selection", ".", "createRange", "(", ")", ":", "doc", ".", "createRange", "(", ")", ";", "}", "}", "}", "catch", "(", "ex", ")", "{", "// IE throws unspecified error here if TinyMCE is placed in a frame/iframe", "}", "evt", "=", "self", ".", "editor", ".", "fire", "(", "'GetSelectionRange'", ",", "{", "range", ":", "rng", "}", ")", ";", "if", "(", "evt", ".", "range", "!==", "rng", ")", "{", "return", "evt", ".", "range", ";", "}", "// We have W3C ranges and it's IE then fake control selection since IE9 doesn't handle that correctly yet", "// IE 11 doesn't support the selection object so we check for that as well", "if", "(", "isIE", "&&", "rng", "&&", "rng", ".", "setStart", "&&", "doc", ".", "selection", ")", "{", "try", "{", "// IE will sometimes throw an exception here", "ieRng", "=", "doc", ".", "selection", ".", "createRange", "(", ")", ";", "}", "catch", "(", "ex", ")", "{", "// Ignore", "}", "if", "(", "ieRng", "&&", "ieRng", ".", "item", ")", "{", "elm", "=", "ieRng", ".", "item", "(", "0", ")", ";", "rng", "=", "doc", ".", "createRange", "(", ")", ";", "rng", ".", "setStartBefore", "(", "elm", ")", ";", "rng", ".", "setEndAfter", "(", "elm", ")", ";", "}", "}", "// No range found then create an empty one", "// This can occur when the editor is placed in a hidden container element on Gecko", "// Or on IE when there was an exception", "if", "(", "!", "rng", ")", "{", "rng", "=", "doc", ".", "createRange", "?", "doc", ".", "createRange", "(", ")", ":", "doc", ".", "body", ".", "createTextRange", "(", ")", ";", "}", "// If range is at start of document then move it to start of body", "if", "(", "rng", ".", "setStart", "&&", "rng", ".", "startContainer", ".", "nodeType", "===", "9", "&&", "rng", ".", "collapsed", ")", "{", "elm", "=", "self", ".", "dom", ".", "getRoot", "(", ")", ";", "rng", ".", "setStart", "(", "elm", ",", "0", ")", ";", "rng", ".", "setEnd", "(", "elm", ",", "0", ")", ";", "}", "if", "(", "self", ".", "selectedRange", "&&", "self", ".", "explicitRange", ")", "{", "if", "(", "tryCompareBoundaryPoints", "(", "rng", ".", "START_TO_START", ",", "rng", ",", "self", ".", "selectedRange", ")", "===", "0", "&&", "tryCompareBoundaryPoints", "(", "rng", ".", "END_TO_END", ",", "rng", ",", "self", ".", "selectedRange", ")", "===", "0", ")", "{", "// Safari, Opera and Chrome only ever select text which causes the range to change.", "// This lets us use the originally set range if the selection hasn't been changed by the user.", "rng", "=", "self", ".", "explicitRange", ";", "}", "else", "{", "self", ".", "selectedRange", "=", "null", ";", "self", ".", "explicitRange", "=", "null", ";", "}", "}", "return", "rng", ";", "}" ]
Returns the browsers internal range object. @method getRng @param {Boolean} w3c Forces a compatible W3C range on IE. @return {Range} Internal browser range object. @see http://www.quirksmode.org/dom/range_intro.html @see http://www.dotvoid.com/2001/03/using-the-range-object-in-mozilla/
[ "Returns", "the", "browsers", "internal", "range", "object", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L18000-L18110
48,192
sadiqhabib/tinymce-dist
tinymce.full.js
function () { var self = this, rng = self.getRng(), elm; var startContainer, endContainer, startOffset, endOffset, root = self.dom.getRoot(); function skipEmptyTextNodes(node, forwards) { var orig = node; while (node && node.nodeType === 3 && node.length === 0) { node = forwards ? node.nextSibling : node.previousSibling; } return node || orig; } // Range maybe lost after the editor is made visible again if (!rng) { return root; } startContainer = rng.startContainer; endContainer = rng.endContainer; startOffset = rng.startOffset; endOffset = rng.endOffset; if (rng.setStart) { elm = rng.commonAncestorContainer; // Handle selection a image or other control like element such as anchors if (!rng.collapsed) { if (startContainer == endContainer) { if (endOffset - startOffset < 2) { if (startContainer.hasChildNodes()) { elm = startContainer.childNodes[startOffset]; } } } // If the anchor node is a element instead of a text node then return this element //if (tinymce.isWebKit && sel.anchorNode && sel.anchorNode.nodeType == 1) // return sel.anchorNode.childNodes[sel.anchorOffset]; // Handle cases where the selection is immediately wrapped around a node and return that node instead of it's parent. // This happens when you double click an underlined word in FireFox. if (startContainer.nodeType === 3 && endContainer.nodeType === 3) { if (startContainer.length === startOffset) { startContainer = skipEmptyTextNodes(startContainer.nextSibling, true); } else { startContainer = startContainer.parentNode; } if (endOffset === 0) { endContainer = skipEmptyTextNodes(endContainer.previousSibling, false); } else { endContainer = endContainer.parentNode; } if (startContainer && startContainer === endContainer) { return startContainer; } } } if (elm && elm.nodeType == 3) { return elm.parentNode; } return elm; } elm = rng.item ? rng.item(0) : rng.parentElement(); // IE 7 might return elements outside the iframe if (elm.ownerDocument !== self.win.document) { elm = root; } return elm; }
javascript
function () { var self = this, rng = self.getRng(), elm; var startContainer, endContainer, startOffset, endOffset, root = self.dom.getRoot(); function skipEmptyTextNodes(node, forwards) { var orig = node; while (node && node.nodeType === 3 && node.length === 0) { node = forwards ? node.nextSibling : node.previousSibling; } return node || orig; } // Range maybe lost after the editor is made visible again if (!rng) { return root; } startContainer = rng.startContainer; endContainer = rng.endContainer; startOffset = rng.startOffset; endOffset = rng.endOffset; if (rng.setStart) { elm = rng.commonAncestorContainer; // Handle selection a image or other control like element such as anchors if (!rng.collapsed) { if (startContainer == endContainer) { if (endOffset - startOffset < 2) { if (startContainer.hasChildNodes()) { elm = startContainer.childNodes[startOffset]; } } } // If the anchor node is a element instead of a text node then return this element //if (tinymce.isWebKit && sel.anchorNode && sel.anchorNode.nodeType == 1) // return sel.anchorNode.childNodes[sel.anchorOffset]; // Handle cases where the selection is immediately wrapped around a node and return that node instead of it's parent. // This happens when you double click an underlined word in FireFox. if (startContainer.nodeType === 3 && endContainer.nodeType === 3) { if (startContainer.length === startOffset) { startContainer = skipEmptyTextNodes(startContainer.nextSibling, true); } else { startContainer = startContainer.parentNode; } if (endOffset === 0) { endContainer = skipEmptyTextNodes(endContainer.previousSibling, false); } else { endContainer = endContainer.parentNode; } if (startContainer && startContainer === endContainer) { return startContainer; } } } if (elm && elm.nodeType == 3) { return elm.parentNode; } return elm; } elm = rng.item ? rng.item(0) : rng.parentElement(); // IE 7 might return elements outside the iframe if (elm.ownerDocument !== self.win.document) { elm = root; } return elm; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ",", "rng", "=", "self", ".", "getRng", "(", ")", ",", "elm", ";", "var", "startContainer", ",", "endContainer", ",", "startOffset", ",", "endOffset", ",", "root", "=", "self", ".", "dom", ".", "getRoot", "(", ")", ";", "function", "skipEmptyTextNodes", "(", "node", ",", "forwards", ")", "{", "var", "orig", "=", "node", ";", "while", "(", "node", "&&", "node", ".", "nodeType", "===", "3", "&&", "node", ".", "length", "===", "0", ")", "{", "node", "=", "forwards", "?", "node", ".", "nextSibling", ":", "node", ".", "previousSibling", ";", "}", "return", "node", "||", "orig", ";", "}", "// Range maybe lost after the editor is made visible again", "if", "(", "!", "rng", ")", "{", "return", "root", ";", "}", "startContainer", "=", "rng", ".", "startContainer", ";", "endContainer", "=", "rng", ".", "endContainer", ";", "startOffset", "=", "rng", ".", "startOffset", ";", "endOffset", "=", "rng", ".", "endOffset", ";", "if", "(", "rng", ".", "setStart", ")", "{", "elm", "=", "rng", ".", "commonAncestorContainer", ";", "// Handle selection a image or other control like element such as anchors", "if", "(", "!", "rng", ".", "collapsed", ")", "{", "if", "(", "startContainer", "==", "endContainer", ")", "{", "if", "(", "endOffset", "-", "startOffset", "<", "2", ")", "{", "if", "(", "startContainer", ".", "hasChildNodes", "(", ")", ")", "{", "elm", "=", "startContainer", ".", "childNodes", "[", "startOffset", "]", ";", "}", "}", "}", "// If the anchor node is a element instead of a text node then return this element", "//if (tinymce.isWebKit && sel.anchorNode && sel.anchorNode.nodeType == 1)", "// return sel.anchorNode.childNodes[sel.anchorOffset];", "// Handle cases where the selection is immediately wrapped around a node and return that node instead of it's parent.", "// This happens when you double click an underlined word in FireFox.", "if", "(", "startContainer", ".", "nodeType", "===", "3", "&&", "endContainer", ".", "nodeType", "===", "3", ")", "{", "if", "(", "startContainer", ".", "length", "===", "startOffset", ")", "{", "startContainer", "=", "skipEmptyTextNodes", "(", "startContainer", ".", "nextSibling", ",", "true", ")", ";", "}", "else", "{", "startContainer", "=", "startContainer", ".", "parentNode", ";", "}", "if", "(", "endOffset", "===", "0", ")", "{", "endContainer", "=", "skipEmptyTextNodes", "(", "endContainer", ".", "previousSibling", ",", "false", ")", ";", "}", "else", "{", "endContainer", "=", "endContainer", ".", "parentNode", ";", "}", "if", "(", "startContainer", "&&", "startContainer", "===", "endContainer", ")", "{", "return", "startContainer", ";", "}", "}", "}", "if", "(", "elm", "&&", "elm", ".", "nodeType", "==", "3", ")", "{", "return", "elm", ".", "parentNode", ";", "}", "return", "elm", ";", "}", "elm", "=", "rng", ".", "item", "?", "rng", ".", "item", "(", "0", ")", ":", "rng", ".", "parentElement", "(", ")", ";", "// IE 7 might return elements outside the iframe", "if", "(", "elm", ".", "ownerDocument", "!==", "self", ".", "win", ".", "document", ")", "{", "elm", "=", "root", ";", "}", "return", "elm", ";", "}" ]
Returns the currently selected element or the common ancestor element for both start and end of the selection. @method getNode @return {Element} Currently selected element or common ancestor element. @example // Alerts the currently selected elements node name alert(tinymce.activeEditor.selection.getNode().nodeName);
[ "Returns", "the", "currently", "selected", "element", "or", "the", "common", "ancestor", "element", "for", "both", "start", "and", "end", "of", "the", "selection", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L18230-L18307
48,193
sadiqhabib/tinymce-dist
tinymce.full.js
getAttribs
function getAttribs(node) { var attribs = {}; each(dom.getAttribs(node), function (attr) { var name = attr.nodeName.toLowerCase(); // Don't compare internal attributes or style if (name.indexOf('_') !== 0 && name !== 'style' && name.indexOf('data-') !== 0) { attribs[name] = dom.getAttrib(node, name); } }); return attribs; }
javascript
function getAttribs(node) { var attribs = {}; each(dom.getAttribs(node), function (attr) { var name = attr.nodeName.toLowerCase(); // Don't compare internal attributes or style if (name.indexOf('_') !== 0 && name !== 'style' && name.indexOf('data-') !== 0) { attribs[name] = dom.getAttrib(node, name); } }); return attribs; }
[ "function", "getAttribs", "(", "node", ")", "{", "var", "attribs", "=", "{", "}", ";", "each", "(", "dom", ".", "getAttribs", "(", "node", ")", ",", "function", "(", "attr", ")", "{", "var", "name", "=", "attr", ".", "nodeName", ".", "toLowerCase", "(", ")", ";", "// Don't compare internal attributes or style", "if", "(", "name", ".", "indexOf", "(", "'_'", ")", "!==", "0", "&&", "name", "!==", "'style'", "&&", "name", ".", "indexOf", "(", "'data-'", ")", "!==", "0", ")", "{", "attribs", "[", "name", "]", "=", "dom", ".", "getAttrib", "(", "node", ",", "name", ")", ";", "}", "}", ")", ";", "return", "attribs", ";", "}" ]
Returns all the nodes attributes excluding internal ones, styles and classes. @private @param {Node} node Node to get attributes from. @return {Object} Name/value object with attributes and attribute values.
[ "Returns", "all", "the", "nodes", "attributes", "excluding", "internal", "ones", "styles", "and", "classes", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L18609-L18622
48,194
sadiqhabib/tinymce-dist
tinymce.full.js
compareObjects
function compareObjects(obj1, obj2) { var value, name; for (name in obj1) { // Obj1 has item obj2 doesn't have if (obj1.hasOwnProperty(name)) { value = obj2[name]; // Obj2 doesn't have obj1 item if (typeof value == "undefined") { return false; } // Obj2 item has a different value if (obj1[name] != value) { return false; } // Delete similar value delete obj2[name]; } } // Check if obj 2 has something obj 1 doesn't have for (name in obj2) { // Obj2 has item obj1 doesn't have if (obj2.hasOwnProperty(name)) { return false; } } return true; }
javascript
function compareObjects(obj1, obj2) { var value, name; for (name in obj1) { // Obj1 has item obj2 doesn't have if (obj1.hasOwnProperty(name)) { value = obj2[name]; // Obj2 doesn't have obj1 item if (typeof value == "undefined") { return false; } // Obj2 item has a different value if (obj1[name] != value) { return false; } // Delete similar value delete obj2[name]; } } // Check if obj 2 has something obj 1 doesn't have for (name in obj2) { // Obj2 has item obj1 doesn't have if (obj2.hasOwnProperty(name)) { return false; } } return true; }
[ "function", "compareObjects", "(", "obj1", ",", "obj2", ")", "{", "var", "value", ",", "name", ";", "for", "(", "name", "in", "obj1", ")", "{", "// Obj1 has item obj2 doesn't have", "if", "(", "obj1", ".", "hasOwnProperty", "(", "name", ")", ")", "{", "value", "=", "obj2", "[", "name", "]", ";", "// Obj2 doesn't have obj1 item", "if", "(", "typeof", "value", "==", "\"undefined\"", ")", "{", "return", "false", ";", "}", "// Obj2 item has a different value", "if", "(", "obj1", "[", "name", "]", "!=", "value", ")", "{", "return", "false", ";", "}", "// Delete similar value", "delete", "obj2", "[", "name", "]", ";", "}", "}", "// Check if obj 2 has something obj 1 doesn't have", "for", "(", "name", "in", "obj2", ")", "{", "// Obj2 has item obj1 doesn't have", "if", "(", "obj2", ".", "hasOwnProperty", "(", "name", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Compares two objects checks if it's key + value exists in the other one. @private @param {Object} obj1 First object to compare. @param {Object} obj2 Second object to compare. @return {boolean} True/false if the objects matches or not.
[ "Compares", "two", "objects", "checks", "if", "it", "s", "key", "+", "value", "exists", "in", "the", "other", "one", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L18632-L18664
48,195
sadiqhabib/tinymce-dist
tinymce.full.js
process
function process(node) { var children, i, l, lastContentEditable, hasContentEditableState; // Node has a contentEditable value if (node.nodeType === 1 && getContentEditable(node)) { lastContentEditable = contentEditable; contentEditable = getContentEditable(node) === "true"; hasContentEditableState = true; // We don't want to wrap the container only it's children } // Grab the children first since the nodelist might be changed children = grep(node.childNodes); // Process current node if (contentEditable && !hasContentEditableState) { for (i = 0, l = formatList.length; i < l; i++) { if (removeFormat(formatList[i], vars, node, node)) { break; } } } // Process the children if (format.deep) { if (children.length) { for (i = 0, l = children.length; i < l; i++) { process(children[i]); } if (hasContentEditableState) { contentEditable = lastContentEditable; // Restore last contentEditable state from stack } } } }
javascript
function process(node) { var children, i, l, lastContentEditable, hasContentEditableState; // Node has a contentEditable value if (node.nodeType === 1 && getContentEditable(node)) { lastContentEditable = contentEditable; contentEditable = getContentEditable(node) === "true"; hasContentEditableState = true; // We don't want to wrap the container only it's children } // Grab the children first since the nodelist might be changed children = grep(node.childNodes); // Process current node if (contentEditable && !hasContentEditableState) { for (i = 0, l = formatList.length; i < l; i++) { if (removeFormat(formatList[i], vars, node, node)) { break; } } } // Process the children if (format.deep) { if (children.length) { for (i = 0, l = children.length; i < l; i++) { process(children[i]); } if (hasContentEditableState) { contentEditable = lastContentEditable; // Restore last contentEditable state from stack } } } }
[ "function", "process", "(", "node", ")", "{", "var", "children", ",", "i", ",", "l", ",", "lastContentEditable", ",", "hasContentEditableState", ";", "// Node has a contentEditable value", "if", "(", "node", ".", "nodeType", "===", "1", "&&", "getContentEditable", "(", "node", ")", ")", "{", "lastContentEditable", "=", "contentEditable", ";", "contentEditable", "=", "getContentEditable", "(", "node", ")", "===", "\"true\"", ";", "hasContentEditableState", "=", "true", ";", "// We don't want to wrap the container only it's children", "}", "// Grab the children first since the nodelist might be changed", "children", "=", "grep", "(", "node", ".", "childNodes", ")", ";", "// Process current node", "if", "(", "contentEditable", "&&", "!", "hasContentEditableState", ")", "{", "for", "(", "i", "=", "0", ",", "l", "=", "formatList", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "if", "(", "removeFormat", "(", "formatList", "[", "i", "]", ",", "vars", ",", "node", ",", "node", ")", ")", "{", "break", ";", "}", "}", "}", "// Process the children", "if", "(", "format", ".", "deep", ")", "{", "if", "(", "children", ".", "length", ")", "{", "for", "(", "i", "=", "0", ",", "l", "=", "children", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "process", "(", "children", "[", "i", "]", ")", ";", "}", "if", "(", "hasContentEditableState", ")", "{", "contentEditable", "=", "lastContentEditable", ";", "// Restore last contentEditable state from stack", "}", "}", "}", "}" ]
Merges the styles for each node
[ "Merges", "the", "styles", "for", "each", "node" ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L19936-L19970
48,196
sadiqhabib/tinymce-dist
tinymce.full.js
match
function match(name, vars, node) { var startNode; function matchParents(node) { var root = dom.getRoot(); if (node === root) { return false; } // Find first node with similar format settings node = dom.getParent(node, function (node) { if (matchesUnInheritedFormatSelector(node, name)) { return true; } return node.parentNode === root || !!matchNode(node, name, vars, true); }); // Do an exact check on the similar format element return matchNode(node, name, vars); } // Check specified node if (node) { return matchParents(node); } // Check selected node node = selection.getNode(); if (matchParents(node)) { return TRUE; } // Check start node if it's different startNode = selection.getStart(); if (startNode != node) { if (matchParents(startNode)) { return TRUE; } } return FALSE; }
javascript
function match(name, vars, node) { var startNode; function matchParents(node) { var root = dom.getRoot(); if (node === root) { return false; } // Find first node with similar format settings node = dom.getParent(node, function (node) { if (matchesUnInheritedFormatSelector(node, name)) { return true; } return node.parentNode === root || !!matchNode(node, name, vars, true); }); // Do an exact check on the similar format element return matchNode(node, name, vars); } // Check specified node if (node) { return matchParents(node); } // Check selected node node = selection.getNode(); if (matchParents(node)) { return TRUE; } // Check start node if it's different startNode = selection.getStart(); if (startNode != node) { if (matchParents(startNode)) { return TRUE; } } return FALSE; }
[ "function", "match", "(", "name", ",", "vars", ",", "node", ")", "{", "var", "startNode", ";", "function", "matchParents", "(", "node", ")", "{", "var", "root", "=", "dom", ".", "getRoot", "(", ")", ";", "if", "(", "node", "===", "root", ")", "{", "return", "false", ";", "}", "// Find first node with similar format settings", "node", "=", "dom", ".", "getParent", "(", "node", ",", "function", "(", "node", ")", "{", "if", "(", "matchesUnInheritedFormatSelector", "(", "node", ",", "name", ")", ")", "{", "return", "true", ";", "}", "return", "node", ".", "parentNode", "===", "root", "||", "!", "!", "matchNode", "(", "node", ",", "name", ",", "vars", ",", "true", ")", ";", "}", ")", ";", "// Do an exact check on the similar format element", "return", "matchNode", "(", "node", ",", "name", ",", "vars", ")", ";", "}", "// Check specified node", "if", "(", "node", ")", "{", "return", "matchParents", "(", "node", ")", ";", "}", "// Check selected node", "node", "=", "selection", ".", "getNode", "(", ")", ";", "if", "(", "matchParents", "(", "node", ")", ")", "{", "return", "TRUE", ";", "}", "// Check start node if it's different", "startNode", "=", "selection", ".", "getStart", "(", ")", ";", "if", "(", "startNode", "!=", "node", ")", "{", "if", "(", "matchParents", "(", "startNode", ")", ")", "{", "return", "TRUE", ";", "}", "}", "return", "FALSE", ";", "}" ]
Matches the current selection or specified node against the specified format name. @method match @param {String} name Name of format to match. @param {Object} vars Optional list of variables to replace before checking it. @param {Node} node Optional node to check. @return {boolean} true/false if the specified selection/node matches the format.
[ "Matches", "the", "current", "selection", "or", "specified", "node", "against", "the", "specified", "format", "name", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L20291-L20334
48,197
sadiqhabib/tinymce-dist
tinymce.full.js
formatChanged
function formatChanged(formats, callback, similar) { var currentFormats; // Setup format node change logic if (!formatChangeData) { formatChangeData = {}; currentFormats = {}; ed.on('NodeChange', function (e) { var parents = getParents(e.element), matchedFormats = {}; // Ignore bogus nodes like the <a> tag created by moveStart() parents = Tools.grep(parents, function (node) { return node.nodeType == 1 && !node.getAttribute('data-mce-bogus'); }); // Check for new formats each(formatChangeData, function (callbacks, format) { each(parents, function (node) { if (matchNode(node, format, {}, callbacks.similar)) { if (!currentFormats[format]) { // Execute callbacks each(callbacks, function (callback) { callback(true, { node: node, format: format, parents: parents }); }); currentFormats[format] = callbacks; } matchedFormats[format] = callbacks; return false; } if (matchesUnInheritedFormatSelector(node, format)) { return false; } }); }); // Check if current formats still match each(currentFormats, function (callbacks, format) { if (!matchedFormats[format]) { delete currentFormats[format]; each(callbacks, function (callback) { callback(false, { node: e.element, format: format, parents: parents }); }); } }); }); } // Add format listeners each(formats.split(','), function (format) { if (!formatChangeData[format]) { formatChangeData[format] = []; formatChangeData[format].similar = similar; } formatChangeData[format].push(callback); }); return this; }
javascript
function formatChanged(formats, callback, similar) { var currentFormats; // Setup format node change logic if (!formatChangeData) { formatChangeData = {}; currentFormats = {}; ed.on('NodeChange', function (e) { var parents = getParents(e.element), matchedFormats = {}; // Ignore bogus nodes like the <a> tag created by moveStart() parents = Tools.grep(parents, function (node) { return node.nodeType == 1 && !node.getAttribute('data-mce-bogus'); }); // Check for new formats each(formatChangeData, function (callbacks, format) { each(parents, function (node) { if (matchNode(node, format, {}, callbacks.similar)) { if (!currentFormats[format]) { // Execute callbacks each(callbacks, function (callback) { callback(true, { node: node, format: format, parents: parents }); }); currentFormats[format] = callbacks; } matchedFormats[format] = callbacks; return false; } if (matchesUnInheritedFormatSelector(node, format)) { return false; } }); }); // Check if current formats still match each(currentFormats, function (callbacks, format) { if (!matchedFormats[format]) { delete currentFormats[format]; each(callbacks, function (callback) { callback(false, { node: e.element, format: format, parents: parents }); }); } }); }); } // Add format listeners each(formats.split(','), function (format) { if (!formatChangeData[format]) { formatChangeData[format] = []; formatChangeData[format].similar = similar; } formatChangeData[format].push(callback); }); return this; }
[ "function", "formatChanged", "(", "formats", ",", "callback", ",", "similar", ")", "{", "var", "currentFormats", ";", "// Setup format node change logic", "if", "(", "!", "formatChangeData", ")", "{", "formatChangeData", "=", "{", "}", ";", "currentFormats", "=", "{", "}", ";", "ed", ".", "on", "(", "'NodeChange'", ",", "function", "(", "e", ")", "{", "var", "parents", "=", "getParents", "(", "e", ".", "element", ")", ",", "matchedFormats", "=", "{", "}", ";", "// Ignore bogus nodes like the <a> tag created by moveStart()", "parents", "=", "Tools", ".", "grep", "(", "parents", ",", "function", "(", "node", ")", "{", "return", "node", ".", "nodeType", "==", "1", "&&", "!", "node", ".", "getAttribute", "(", "'data-mce-bogus'", ")", ";", "}", ")", ";", "// Check for new formats", "each", "(", "formatChangeData", ",", "function", "(", "callbacks", ",", "format", ")", "{", "each", "(", "parents", ",", "function", "(", "node", ")", "{", "if", "(", "matchNode", "(", "node", ",", "format", ",", "{", "}", ",", "callbacks", ".", "similar", ")", ")", "{", "if", "(", "!", "currentFormats", "[", "format", "]", ")", "{", "// Execute callbacks", "each", "(", "callbacks", ",", "function", "(", "callback", ")", "{", "callback", "(", "true", ",", "{", "node", ":", "node", ",", "format", ":", "format", ",", "parents", ":", "parents", "}", ")", ";", "}", ")", ";", "currentFormats", "[", "format", "]", "=", "callbacks", ";", "}", "matchedFormats", "[", "format", "]", "=", "callbacks", ";", "return", "false", ";", "}", "if", "(", "matchesUnInheritedFormatSelector", "(", "node", ",", "format", ")", ")", "{", "return", "false", ";", "}", "}", ")", ";", "}", ")", ";", "// Check if current formats still match", "each", "(", "currentFormats", ",", "function", "(", "callbacks", ",", "format", ")", "{", "if", "(", "!", "matchedFormats", "[", "format", "]", ")", "{", "delete", "currentFormats", "[", "format", "]", ";", "each", "(", "callbacks", ",", "function", "(", "callback", ")", "{", "callback", "(", "false", ",", "{", "node", ":", "e", ".", "element", ",", "format", ":", "format", ",", "parents", ":", "parents", "}", ")", ";", "}", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}", "// Add format listeners", "each", "(", "formats", ".", "split", "(", "','", ")", ",", "function", "(", "format", ")", "{", "if", "(", "!", "formatChangeData", "[", "format", "]", ")", "{", "formatChangeData", "[", "format", "]", "=", "[", "]", ";", "formatChangeData", "[", "format", "]", ".", "similar", "=", "similar", ";", "}", "formatChangeData", "[", "format", "]", ".", "push", "(", "callback", ")", ";", "}", ")", ";", "return", "this", ";", "}" ]
Executes the specified callback when the current selection matches the formats or not. @method formatChanged @param {String} formats Comma separated list of formats to check for. @param {function} callback Callback with state and args when the format is changed/toggled on/off. @param {Boolean} similar True/false state if the match should handle similar or exact formats.
[ "Executes", "the", "specified", "callback", "when", "the", "current", "selection", "matches", "the", "formats", "or", "not", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L20408-L20471
48,198
sadiqhabib/tinymce-dist
tinymce.full.js
replaceVars
function replaceVars(value, vars) { if (typeof value != "string") { value = value(vars); } else if (vars) { value = value.replace(/%(\w+)/g, function (str, name) { return vars[name] || str; }); } return value; }
javascript
function replaceVars(value, vars) { if (typeof value != "string") { value = value(vars); } else if (vars) { value = value.replace(/%(\w+)/g, function (str, name) { return vars[name] || str; }); } return value; }
[ "function", "replaceVars", "(", "value", ",", "vars", ")", "{", "if", "(", "typeof", "value", "!=", "\"string\"", ")", "{", "value", "=", "value", "(", "vars", ")", ";", "}", "else", "if", "(", "vars", ")", "{", "value", "=", "value", ".", "replace", "(", "/", "%(\\w+)", "/", "g", ",", "function", "(", "str", ",", "name", ")", "{", "return", "vars", "[", "name", "]", "||", "str", ";", "}", ")", ";", "}", "return", "value", ";", "}" ]
Replaces variables in the value. The variable format is %var. @private @param {String} value Value to replace variables in. @param {Object} vars Name/value array with variables to replace. @return {String} New value with replaced variables.
[ "Replaces", "variables", "in", "the", "value", ".", "The", "variable", "format", "is", "%var", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L20640-L20650
48,199
sadiqhabib/tinymce-dist
tinymce.full.js
removeFormat
function removeFormat(format, vars, node, compareNode) { var i, attrs, stylesModified; // Check if node matches format if (!matchName(node, format) && !isColorFormatAndAnchor(node, format)) { return FALSE; } // Should we compare with format attribs and styles if (format.remove != 'all') { // Remove styles each(format.styles, function (value, name) { value = normalizeStyleValue(replaceVars(value, vars), name); // Indexed array if (typeof name === 'number') { name = value; compareNode = 0; } if (format.remove_similar || (!compareNode || isEq(getStyle(compareNode, name), value))) { dom.setStyle(node, name, ''); } stylesModified = 1; }); // Remove style attribute if it's empty if (stylesModified && dom.getAttrib(node, 'style') === '') { node.removeAttribute('style'); node.removeAttribute('data-mce-style'); } // Remove attributes each(format.attributes, function (value, name) { var valueOut; value = replaceVars(value, vars); // Indexed array if (typeof name === 'number') { name = value; compareNode = 0; } if (!compareNode || isEq(dom.getAttrib(compareNode, name), value)) { // Keep internal classes if (name == 'class') { value = dom.getAttrib(node, name); if (value) { // Build new class value where everything is removed except the internal prefixed classes valueOut = ''; each(value.split(/\s+/), function (cls) { if (/mce\-\w+/.test(cls)) { valueOut += (valueOut ? ' ' : '') + cls; } }); // We got some internal classes left if (valueOut) { dom.setAttrib(node, name, valueOut); return; } } } // IE6 has a bug where the attribute doesn't get removed correctly if (name == "class") { node.removeAttribute('className'); } // Remove mce prefixed attributes if (MCE_ATTR_RE.test(name)) { node.removeAttribute('data-mce-' + name); } node.removeAttribute(name); } }); // Remove classes each(format.classes, function (value) { value = replaceVars(value, vars); if (!compareNode || dom.hasClass(compareNode, value)) { dom.removeClass(node, value); } }); // Check for non internal attributes attrs = dom.getAttribs(node); for (i = 0; i < attrs.length; i++) { var attrName = attrs[i].nodeName; if (attrName.indexOf('_') !== 0 && attrName.indexOf('data-') !== 0) { return FALSE; } } } // Remove the inline child if it's empty for example <b> or <span> if (format.remove != 'none') { removeNode(node, format); return TRUE; } }
javascript
function removeFormat(format, vars, node, compareNode) { var i, attrs, stylesModified; // Check if node matches format if (!matchName(node, format) && !isColorFormatAndAnchor(node, format)) { return FALSE; } // Should we compare with format attribs and styles if (format.remove != 'all') { // Remove styles each(format.styles, function (value, name) { value = normalizeStyleValue(replaceVars(value, vars), name); // Indexed array if (typeof name === 'number') { name = value; compareNode = 0; } if (format.remove_similar || (!compareNode || isEq(getStyle(compareNode, name), value))) { dom.setStyle(node, name, ''); } stylesModified = 1; }); // Remove style attribute if it's empty if (stylesModified && dom.getAttrib(node, 'style') === '') { node.removeAttribute('style'); node.removeAttribute('data-mce-style'); } // Remove attributes each(format.attributes, function (value, name) { var valueOut; value = replaceVars(value, vars); // Indexed array if (typeof name === 'number') { name = value; compareNode = 0; } if (!compareNode || isEq(dom.getAttrib(compareNode, name), value)) { // Keep internal classes if (name == 'class') { value = dom.getAttrib(node, name); if (value) { // Build new class value where everything is removed except the internal prefixed classes valueOut = ''; each(value.split(/\s+/), function (cls) { if (/mce\-\w+/.test(cls)) { valueOut += (valueOut ? ' ' : '') + cls; } }); // We got some internal classes left if (valueOut) { dom.setAttrib(node, name, valueOut); return; } } } // IE6 has a bug where the attribute doesn't get removed correctly if (name == "class") { node.removeAttribute('className'); } // Remove mce prefixed attributes if (MCE_ATTR_RE.test(name)) { node.removeAttribute('data-mce-' + name); } node.removeAttribute(name); } }); // Remove classes each(format.classes, function (value) { value = replaceVars(value, vars); if (!compareNode || dom.hasClass(compareNode, value)) { dom.removeClass(node, value); } }); // Check for non internal attributes attrs = dom.getAttribs(node); for (i = 0; i < attrs.length; i++) { var attrName = attrs[i].nodeName; if (attrName.indexOf('_') !== 0 && attrName.indexOf('data-') !== 0) { return FALSE; } } } // Remove the inline child if it's empty for example <b> or <span> if (format.remove != 'none') { removeNode(node, format); return TRUE; } }
[ "function", "removeFormat", "(", "format", ",", "vars", ",", "node", ",", "compareNode", ")", "{", "var", "i", ",", "attrs", ",", "stylesModified", ";", "// Check if node matches format", "if", "(", "!", "matchName", "(", "node", ",", "format", ")", "&&", "!", "isColorFormatAndAnchor", "(", "node", ",", "format", ")", ")", "{", "return", "FALSE", ";", "}", "// Should we compare with format attribs and styles", "if", "(", "format", ".", "remove", "!=", "'all'", ")", "{", "// Remove styles", "each", "(", "format", ".", "styles", ",", "function", "(", "value", ",", "name", ")", "{", "value", "=", "normalizeStyleValue", "(", "replaceVars", "(", "value", ",", "vars", ")", ",", "name", ")", ";", "// Indexed array", "if", "(", "typeof", "name", "===", "'number'", ")", "{", "name", "=", "value", ";", "compareNode", "=", "0", ";", "}", "if", "(", "format", ".", "remove_similar", "||", "(", "!", "compareNode", "||", "isEq", "(", "getStyle", "(", "compareNode", ",", "name", ")", ",", "value", ")", ")", ")", "{", "dom", ".", "setStyle", "(", "node", ",", "name", ",", "''", ")", ";", "}", "stylesModified", "=", "1", ";", "}", ")", ";", "// Remove style attribute if it's empty", "if", "(", "stylesModified", "&&", "dom", ".", "getAttrib", "(", "node", ",", "'style'", ")", "===", "''", ")", "{", "node", ".", "removeAttribute", "(", "'style'", ")", ";", "node", ".", "removeAttribute", "(", "'data-mce-style'", ")", ";", "}", "// Remove attributes", "each", "(", "format", ".", "attributes", ",", "function", "(", "value", ",", "name", ")", "{", "var", "valueOut", ";", "value", "=", "replaceVars", "(", "value", ",", "vars", ")", ";", "// Indexed array", "if", "(", "typeof", "name", "===", "'number'", ")", "{", "name", "=", "value", ";", "compareNode", "=", "0", ";", "}", "if", "(", "!", "compareNode", "||", "isEq", "(", "dom", ".", "getAttrib", "(", "compareNode", ",", "name", ")", ",", "value", ")", ")", "{", "// Keep internal classes", "if", "(", "name", "==", "'class'", ")", "{", "value", "=", "dom", ".", "getAttrib", "(", "node", ",", "name", ")", ";", "if", "(", "value", ")", "{", "// Build new class value where everything is removed except the internal prefixed classes", "valueOut", "=", "''", ";", "each", "(", "value", ".", "split", "(", "/", "\\s+", "/", ")", ",", "function", "(", "cls", ")", "{", "if", "(", "/", "mce\\-\\w+", "/", ".", "test", "(", "cls", ")", ")", "{", "valueOut", "+=", "(", "valueOut", "?", "' '", ":", "''", ")", "+", "cls", ";", "}", "}", ")", ";", "// We got some internal classes left", "if", "(", "valueOut", ")", "{", "dom", ".", "setAttrib", "(", "node", ",", "name", ",", "valueOut", ")", ";", "return", ";", "}", "}", "}", "// IE6 has a bug where the attribute doesn't get removed correctly", "if", "(", "name", "==", "\"class\"", ")", "{", "node", ".", "removeAttribute", "(", "'className'", ")", ";", "}", "// Remove mce prefixed attributes", "if", "(", "MCE_ATTR_RE", ".", "test", "(", "name", ")", ")", "{", "node", ".", "removeAttribute", "(", "'data-mce-'", "+", "name", ")", ";", "}", "node", ".", "removeAttribute", "(", "name", ")", ";", "}", "}", ")", ";", "// Remove classes", "each", "(", "format", ".", "classes", ",", "function", "(", "value", ")", "{", "value", "=", "replaceVars", "(", "value", ",", "vars", ")", ";", "if", "(", "!", "compareNode", "||", "dom", ".", "hasClass", "(", "compareNode", ",", "value", ")", ")", "{", "dom", ".", "removeClass", "(", "node", ",", "value", ")", ";", "}", "}", ")", ";", "// Check for non internal attributes", "attrs", "=", "dom", ".", "getAttribs", "(", "node", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "attrs", ".", "length", ";", "i", "++", ")", "{", "var", "attrName", "=", "attrs", "[", "i", "]", ".", "nodeName", ";", "if", "(", "attrName", ".", "indexOf", "(", "'_'", ")", "!==", "0", "&&", "attrName", ".", "indexOf", "(", "'data-'", ")", "!==", "0", ")", "{", "return", "FALSE", ";", "}", "}", "}", "// Remove the inline child if it's empty for example <b> or <span>", "if", "(", "format", ".", "remove", "!=", "'none'", ")", "{", "removeNode", "(", "node", ",", "format", ")", ";", "return", "TRUE", ";", "}", "}" ]
Removes the specified format for the specified node. It will also remove the node if it doesn't have any attributes if the format specifies it to do so. @private @param {Object} format Format object with items to remove from node. @param {Object} vars Name/value object with variables to apply to format. @param {Node} node Node to remove the format styles on. @param {Node} compareNode Optional compare node, if specified the styles will be compared to that node. @return {Boolean} True/false if the node was removed or not.
[ "Removes", "the", "specified", "format", "for", "the", "specified", "node", ".", "It", "will", "also", "remove", "the", "node", "if", "it", "doesn", "t", "have", "any", "attributes", "if", "the", "format", "specifies", "it", "to", "do", "so", "." ]
3acf1e4fe83a541988fdca20f2aaf4e6dce72512
https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L21042-L21146