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,300 | sadiqhabib/tinymce-dist | tinymce.full.js | selectionChange | function selectionChange(e) {
var pointRng;
// Check if the button is down or not
if (e.button) {
// Create range from mouse position
pointRng = rngFromPoint(e.x, e.y);
if (pointRng) {
// Check if pointRange is before/after selection then change the endPoint
if (pointRng.compareEndPoints('StartToStart', startRng) > 0) {
pointRng.setEndPoint('StartToStart', startRng);
} else {
pointRng.setEndPoint('EndToEnd', startRng);
}
pointRng.select();
}
} else {
endSelection();
}
} | javascript | function selectionChange(e) {
var pointRng;
// Check if the button is down or not
if (e.button) {
// Create range from mouse position
pointRng = rngFromPoint(e.x, e.y);
if (pointRng) {
// Check if pointRange is before/after selection then change the endPoint
if (pointRng.compareEndPoints('StartToStart', startRng) > 0) {
pointRng.setEndPoint('StartToStart', startRng);
} else {
pointRng.setEndPoint('EndToEnd', startRng);
}
pointRng.select();
}
} else {
endSelection();
}
} | [
"function",
"selectionChange",
"(",
"e",
")",
"{",
"var",
"pointRng",
";",
"// Check if the button is down or not",
"if",
"(",
"e",
".",
"button",
")",
"{",
"// Create range from mouse position",
"pointRng",
"=",
"rngFromPoint",
"(",
"e",
".",
"x",
",",
"e",
".",
"y",
")",
";",
"if",
"(",
"pointRng",
")",
"{",
"// Check if pointRange is before/after selection then change the endPoint",
"if",
"(",
"pointRng",
".",
"compareEndPoints",
"(",
"'StartToStart'",
",",
"startRng",
")",
">",
"0",
")",
"{",
"pointRng",
".",
"setEndPoint",
"(",
"'StartToStart'",
",",
"startRng",
")",
";",
"}",
"else",
"{",
"pointRng",
".",
"setEndPoint",
"(",
"'EndToEnd'",
",",
"startRng",
")",
";",
"}",
"pointRng",
".",
"select",
"(",
")",
";",
"}",
"}",
"else",
"{",
"endSelection",
"(",
")",
";",
"}",
"}"
] | Fires while the selection is changing | [
"Fires",
"while",
"the",
"selection",
"is",
"changing"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L34828-L34849 |
48,301 | sadiqhabib/tinymce-dist | tinymce.full.js | restoreFocusOnKeyDown | function restoreFocusOnKeyDown() {
if (!editor.inline) {
editor.on('keydown', function () {
if (document.activeElement == document.body) {
editor.getWin().focus();
}
});
}
} | javascript | function restoreFocusOnKeyDown() {
if (!editor.inline) {
editor.on('keydown', function () {
if (document.activeElement == document.body) {
editor.getWin().focus();
}
});
}
} | [
"function",
"restoreFocusOnKeyDown",
"(",
")",
"{",
"if",
"(",
"!",
"editor",
".",
"inline",
")",
"{",
"editor",
".",
"on",
"(",
"'keydown'",
",",
"function",
"(",
")",
"{",
"if",
"(",
"document",
".",
"activeElement",
"==",
"document",
".",
"body",
")",
"{",
"editor",
".",
"getWin",
"(",
")",
".",
"focus",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] | iOS has a bug where it's impossible to type if the document has a touchstart event
bound and the user touches the document while having the on screen keyboard visible.
The touch event moves the focus to the parent document while having the caret inside the iframe
this fix moves the focus back into the iframe document. | [
"iOS",
"has",
"a",
"bug",
"where",
"it",
"s",
"impossible",
"to",
"type",
"if",
"the",
"document",
"has",
"a",
"touchstart",
"event",
"bound",
"and",
"the",
"user",
"touches",
"the",
"document",
"while",
"having",
"the",
"on",
"screen",
"keyboard",
"visible",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L34929-L34937 |
48,302 | sadiqhabib/tinymce-dist | tinymce.full.js | blockCmdArrowNavigation | function blockCmdArrowNavigation() {
if (Env.mac) {
editor.on('keydown', function (e) {
if (VK.metaKeyPressed(e) && !e.shiftKey && (e.keyCode == 37 || e.keyCode == 39)) {
e.preventDefault();
editor.selection.getSel().modify('move', e.keyCode == 37 ? 'backward' : 'forward', 'lineboundary');
}
});
}
} | javascript | function blockCmdArrowNavigation() {
if (Env.mac) {
editor.on('keydown', function (e) {
if (VK.metaKeyPressed(e) && !e.shiftKey && (e.keyCode == 37 || e.keyCode == 39)) {
e.preventDefault();
editor.selection.getSel().modify('move', e.keyCode == 37 ? 'backward' : 'forward', 'lineboundary');
}
});
}
} | [
"function",
"blockCmdArrowNavigation",
"(",
")",
"{",
"if",
"(",
"Env",
".",
"mac",
")",
"{",
"editor",
".",
"on",
"(",
"'keydown'",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"VK",
".",
"metaKeyPressed",
"(",
"e",
")",
"&&",
"!",
"e",
".",
"shiftKey",
"&&",
"(",
"e",
".",
"keyCode",
"==",
"37",
"||",
"e",
".",
"keyCode",
"==",
"39",
")",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"editor",
".",
"selection",
".",
"getSel",
"(",
")",
".",
"modify",
"(",
"'move'",
",",
"e",
".",
"keyCode",
"==",
"37",
"?",
"'backward'",
":",
"'forward'",
",",
"'lineboundary'",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] | Firefox on Mac OS will move the browser back to the previous page if you press CMD+Left arrow.
You might then loose all your work so we need to block that behavior and replace it with our own. | [
"Firefox",
"on",
"Mac",
"OS",
"will",
"move",
"the",
"browser",
"back",
"to",
"the",
"previous",
"page",
"if",
"you",
"press",
"CMD",
"+",
"Left",
"arrow",
".",
"You",
"might",
"then",
"loose",
"all",
"your",
"work",
"so",
"we",
"need",
"to",
"block",
"that",
"behavior",
"and",
"replace",
"it",
"with",
"our",
"own",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L34977-L34986 |
48,303 | sadiqhabib/tinymce-dist | tinymce.full.js | replaceString | function replaceString(content, search, replace) {
var index = 0;
do {
index = content.indexOf(search, index);
if (index !== -1) {
content = content.substring(0, index) + replace + content.substr(index + search.length);
index += replace.length - search.length + 1;
}
} while (index !== -1);
return content;
} | javascript | function replaceString(content, search, replace) {
var index = 0;
do {
index = content.indexOf(search, index);
if (index !== -1) {
content = content.substring(0, index) + replace + content.substr(index + search.length);
index += replace.length - search.length + 1;
}
} while (index !== -1);
return content;
} | [
"function",
"replaceString",
"(",
"content",
",",
"search",
",",
"replace",
")",
"{",
"var",
"index",
"=",
"0",
";",
"do",
"{",
"index",
"=",
"content",
".",
"indexOf",
"(",
"search",
",",
"index",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"content",
"=",
"content",
".",
"substring",
"(",
"0",
",",
"index",
")",
"+",
"replace",
"+",
"content",
".",
"substr",
"(",
"index",
"+",
"search",
".",
"length",
")",
";",
"index",
"+=",
"replace",
".",
"length",
"-",
"search",
".",
"length",
"+",
"1",
";",
"}",
"}",
"while",
"(",
"index",
"!==",
"-",
"1",
")",
";",
"return",
"content",
";",
"}"
] | Replaces strings without regexps to avoid FF regexp to big issue | [
"Replaces",
"strings",
"without",
"regexps",
"to",
"avoid",
"FF",
"regexp",
"to",
"big",
"issue"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L36153-L36166 |
48,304 | sadiqhabib/tinymce-dist | tinymce.full.js | function (selection) {
var rng = selection.getSel().getRangeAt(0);
var startContainer = rng.startContainer;
return startContainer.nodeType === 3 ? startContainer.parentNode : startContainer;
} | javascript | function (selection) {
var rng = selection.getSel().getRangeAt(0);
var startContainer = rng.startContainer;
return startContainer.nodeType === 3 ? startContainer.parentNode : startContainer;
} | [
"function",
"(",
"selection",
")",
"{",
"var",
"rng",
"=",
"selection",
".",
"getSel",
"(",
")",
".",
"getRangeAt",
"(",
"0",
")",
";",
"var",
"startContainer",
"=",
"rng",
".",
"startContainer",
";",
"return",
"startContainer",
".",
"nodeType",
"===",
"3",
"?",
"startContainer",
".",
"parentNode",
":",
"startContainer",
";",
"}"
] | Returns the raw element instead of the fake cE=false element | [
"Returns",
"the",
"raw",
"element",
"instead",
"of",
"the",
"fake",
"cE",
"=",
"false",
"element"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L37199-L37203 |
|
48,305 | sadiqhabib/tinymce-dist | tinymce.full.js | function (targetNode, caretNode) {
var targetBlock = editor.dom.getParent(targetNode, editor.dom.isBlock);
var caretBlock = editor.dom.getParent(caretNode, editor.dom.isBlock);
return targetBlock && !isInSameBlock(targetBlock, caretBlock) && hasNormalCaretPosition(targetBlock);
} | javascript | function (targetNode, caretNode) {
var targetBlock = editor.dom.getParent(targetNode, editor.dom.isBlock);
var caretBlock = editor.dom.getParent(caretNode, editor.dom.isBlock);
return targetBlock && !isInSameBlock(targetBlock, caretBlock) && hasNormalCaretPosition(targetBlock);
} | [
"function",
"(",
"targetNode",
",",
"caretNode",
")",
"{",
"var",
"targetBlock",
"=",
"editor",
".",
"dom",
".",
"getParent",
"(",
"targetNode",
",",
"editor",
".",
"dom",
".",
"isBlock",
")",
";",
"var",
"caretBlock",
"=",
"editor",
".",
"dom",
".",
"getParent",
"(",
"caretNode",
",",
"editor",
".",
"dom",
".",
"isBlock",
")",
";",
"return",
"targetBlock",
"&&",
"!",
"isInSameBlock",
"(",
"targetBlock",
",",
"caretBlock",
")",
"&&",
"hasNormalCaretPosition",
"(",
"targetBlock",
")",
";",
"}"
] | Checks if the target node is in a block and if that block has a caret position better than the suggested caretNode this is to prevent the caret from being sucked in towards a cE=false block if they are adjacent on the vertical axis | [
"Checks",
"if",
"the",
"target",
"node",
"is",
"in",
"a",
"block",
"and",
"if",
"that",
"block",
"has",
"a",
"caret",
"position",
"better",
"than",
"the",
"suggested",
"caretNode",
"this",
"is",
"to",
"prevent",
"the",
"caret",
"from",
"being",
"sucked",
"in",
"towards",
"a",
"cE",
"=",
"false",
"block",
"if",
"they",
"are",
"adjacent",
"on",
"the",
"vertical",
"axis"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L37939-L37944 |
|
48,306 | sadiqhabib/tinymce-dist | tinymce.full.js | Editor | function Editor(id, settings, editorManager) {
var self = this, documentBaseUrl, baseUri, defaultSettings;
documentBaseUrl = self.documentBaseUrl = editorManager.documentBaseURL;
baseUri = editorManager.baseURI;
defaultSettings = editorManager.defaultSettings;
/**
* Name/value collection with editor settings.
*
* @property settings
* @type Object
* @example
* // Get the value of the theme setting
* tinymce.activeEditor.windowManager.alert("You are using the " + tinymce.activeEditor.settings.theme + " theme");
*/
settings = extend({
id: id,
theme: 'modern',
delta_width: 0,
delta_height: 0,
popup_css: '',
plugins: '',
document_base_url: documentBaseUrl,
add_form_submit_trigger: true,
submit_patch: true,
add_unload_trigger: true,
convert_urls: true,
relative_urls: true,
remove_script_host: true,
object_resizing: true,
doctype: '<!DOCTYPE html>',
visual: true,
font_size_style_values: 'xx-small,x-small,small,medium,large,x-large,xx-large',
// See: http://www.w3.org/TR/CSS2/fonts.html#propdef-font-size
font_size_legacy_values: 'xx-small,small,medium,large,x-large,xx-large,300%',
forced_root_block: 'p',
hidden_input: true,
padd_empty_editor: true,
render_ui: true,
indentation: '30px',
inline_styles: true,
convert_fonts_to_spans: true,
indent: 'simple',
indent_before: 'p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,' +
'tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist',
indent_after: 'p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,' +
'tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist',
validate: true,
entity_encoding: 'named',
url_converter: self.convertURL,
url_converter_scope: self,
ie7_compat: true
}, defaultSettings, settings);
// Merge external_plugins
if (defaultSettings && defaultSettings.external_plugins && settings.external_plugins) {
settings.external_plugins = extend({}, defaultSettings.external_plugins, settings.external_plugins);
}
self.settings = settings;
AddOnManager.language = settings.language || 'en';
AddOnManager.languageLoad = settings.language_load;
AddOnManager.baseURL = editorManager.baseURL;
/**
* Editor instance id, normally the same as the div/textarea that was replaced.
*
* @property id
* @type String
*/
self.id = settings.id = id;
/**
* State to force the editor to return false on a isDirty call.
*
* @property isNotDirty
* @type Boolean
* @deprecated Use editor.setDirty instead.
*/
self.setDirty(false);
/**
* Name/Value object containing plugin instances.
*
* @property plugins
* @type Object
* @example
* // Execute a method inside a plugin directly
* tinymce.activeEditor.plugins.someplugin.someMethod();
*/
self.plugins = {};
/**
* URI object to document configured for the TinyMCE instance.
*
* @property documentBaseURI
* @type tinymce.util.URI
* @example
* // Get relative URL from the location of document_base_url
* tinymce.activeEditor.documentBaseURI.toRelative('/somedir/somefile.htm');
*
* // Get absolute URL from the location of document_base_url
* tinymce.activeEditor.documentBaseURI.toAbsolute('somefile.htm');
*/
self.documentBaseURI = new URI(settings.document_base_url || documentBaseUrl, {
base_uri: baseUri
});
/**
* URI object to current document that holds the TinyMCE editor instance.
*
* @property baseURI
* @type tinymce.util.URI
* @example
* // Get relative URL from the location of the API
* tinymce.activeEditor.baseURI.toRelative('/somedir/somefile.htm');
*
* // Get absolute URL from the location of the API
* tinymce.activeEditor.baseURI.toAbsolute('somefile.htm');
*/
self.baseURI = baseUri;
/**
* Array with CSS files to load into the iframe.
*
* @property contentCSS
* @type Array
*/
self.contentCSS = [];
/**
* Array of CSS styles to add to head of document when the editor loads.
*
* @property contentStyles
* @type Array
*/
self.contentStyles = [];
// Creates all events like onClick, onSetContent etc see Editor.Events.js for the actual logic
self.shortcuts = new Shortcuts(self);
self.loadedCSS = {};
self.editorCommands = new EditorCommands(self);
self.suffix = editorManager.suffix;
self.editorManager = editorManager;
self.inline = settings.inline;
self.settings.content_editable = self.inline;
if (settings.cache_suffix) {
Env.cacheSuffix = settings.cache_suffix.replace(/^[\?\&]+/, '');
}
if (settings.override_viewport === false) {
Env.overrideViewPort = false;
}
// Call setup
editorManager.fire('SetupEditor', self);
self.execCallback('setup', self);
/**
* Dom query instance with default scope to the editor document and default element is the body of the editor.
*
* @property $
* @type tinymce.dom.DomQuery
* @example
* tinymce.activeEditor.$('p').css('color', 'red');
* tinymce.activeEditor.$().append('<p>new</p>');
*/
self.$ = DomQuery.overrideDefaults(function () {
return {
context: self.inline ? self.getBody() : self.getDoc(),
element: self.getBody()
};
});
} | javascript | function Editor(id, settings, editorManager) {
var self = this, documentBaseUrl, baseUri, defaultSettings;
documentBaseUrl = self.documentBaseUrl = editorManager.documentBaseURL;
baseUri = editorManager.baseURI;
defaultSettings = editorManager.defaultSettings;
/**
* Name/value collection with editor settings.
*
* @property settings
* @type Object
* @example
* // Get the value of the theme setting
* tinymce.activeEditor.windowManager.alert("You are using the " + tinymce.activeEditor.settings.theme + " theme");
*/
settings = extend({
id: id,
theme: 'modern',
delta_width: 0,
delta_height: 0,
popup_css: '',
plugins: '',
document_base_url: documentBaseUrl,
add_form_submit_trigger: true,
submit_patch: true,
add_unload_trigger: true,
convert_urls: true,
relative_urls: true,
remove_script_host: true,
object_resizing: true,
doctype: '<!DOCTYPE html>',
visual: true,
font_size_style_values: 'xx-small,x-small,small,medium,large,x-large,xx-large',
// See: http://www.w3.org/TR/CSS2/fonts.html#propdef-font-size
font_size_legacy_values: 'xx-small,small,medium,large,x-large,xx-large,300%',
forced_root_block: 'p',
hidden_input: true,
padd_empty_editor: true,
render_ui: true,
indentation: '30px',
inline_styles: true,
convert_fonts_to_spans: true,
indent: 'simple',
indent_before: 'p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,' +
'tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist',
indent_after: 'p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,' +
'tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist',
validate: true,
entity_encoding: 'named',
url_converter: self.convertURL,
url_converter_scope: self,
ie7_compat: true
}, defaultSettings, settings);
// Merge external_plugins
if (defaultSettings && defaultSettings.external_plugins && settings.external_plugins) {
settings.external_plugins = extend({}, defaultSettings.external_plugins, settings.external_plugins);
}
self.settings = settings;
AddOnManager.language = settings.language || 'en';
AddOnManager.languageLoad = settings.language_load;
AddOnManager.baseURL = editorManager.baseURL;
/**
* Editor instance id, normally the same as the div/textarea that was replaced.
*
* @property id
* @type String
*/
self.id = settings.id = id;
/**
* State to force the editor to return false on a isDirty call.
*
* @property isNotDirty
* @type Boolean
* @deprecated Use editor.setDirty instead.
*/
self.setDirty(false);
/**
* Name/Value object containing plugin instances.
*
* @property plugins
* @type Object
* @example
* // Execute a method inside a plugin directly
* tinymce.activeEditor.plugins.someplugin.someMethod();
*/
self.plugins = {};
/**
* URI object to document configured for the TinyMCE instance.
*
* @property documentBaseURI
* @type tinymce.util.URI
* @example
* // Get relative URL from the location of document_base_url
* tinymce.activeEditor.documentBaseURI.toRelative('/somedir/somefile.htm');
*
* // Get absolute URL from the location of document_base_url
* tinymce.activeEditor.documentBaseURI.toAbsolute('somefile.htm');
*/
self.documentBaseURI = new URI(settings.document_base_url || documentBaseUrl, {
base_uri: baseUri
});
/**
* URI object to current document that holds the TinyMCE editor instance.
*
* @property baseURI
* @type tinymce.util.URI
* @example
* // Get relative URL from the location of the API
* tinymce.activeEditor.baseURI.toRelative('/somedir/somefile.htm');
*
* // Get absolute URL from the location of the API
* tinymce.activeEditor.baseURI.toAbsolute('somefile.htm');
*/
self.baseURI = baseUri;
/**
* Array with CSS files to load into the iframe.
*
* @property contentCSS
* @type Array
*/
self.contentCSS = [];
/**
* Array of CSS styles to add to head of document when the editor loads.
*
* @property contentStyles
* @type Array
*/
self.contentStyles = [];
// Creates all events like onClick, onSetContent etc see Editor.Events.js for the actual logic
self.shortcuts = new Shortcuts(self);
self.loadedCSS = {};
self.editorCommands = new EditorCommands(self);
self.suffix = editorManager.suffix;
self.editorManager = editorManager;
self.inline = settings.inline;
self.settings.content_editable = self.inline;
if (settings.cache_suffix) {
Env.cacheSuffix = settings.cache_suffix.replace(/^[\?\&]+/, '');
}
if (settings.override_viewport === false) {
Env.overrideViewPort = false;
}
// Call setup
editorManager.fire('SetupEditor', self);
self.execCallback('setup', self);
/**
* Dom query instance with default scope to the editor document and default element is the body of the editor.
*
* @property $
* @type tinymce.dom.DomQuery
* @example
* tinymce.activeEditor.$('p').css('color', 'red');
* tinymce.activeEditor.$().append('<p>new</p>');
*/
self.$ = DomQuery.overrideDefaults(function () {
return {
context: self.inline ? self.getBody() : self.getDoc(),
element: self.getBody()
};
});
} | [
"function",
"Editor",
"(",
"id",
",",
"settings",
",",
"editorManager",
")",
"{",
"var",
"self",
"=",
"this",
",",
"documentBaseUrl",
",",
"baseUri",
",",
"defaultSettings",
";",
"documentBaseUrl",
"=",
"self",
".",
"documentBaseUrl",
"=",
"editorManager",
".",
"documentBaseURL",
";",
"baseUri",
"=",
"editorManager",
".",
"baseURI",
";",
"defaultSettings",
"=",
"editorManager",
".",
"defaultSettings",
";",
"/**\n * Name/value collection with editor settings.\n *\n * @property settings\n * @type Object\n * @example\n * // Get the value of the theme setting\n * tinymce.activeEditor.windowManager.alert(\"You are using the \" + tinymce.activeEditor.settings.theme + \" theme\");\n */",
"settings",
"=",
"extend",
"(",
"{",
"id",
":",
"id",
",",
"theme",
":",
"'modern'",
",",
"delta_width",
":",
"0",
",",
"delta_height",
":",
"0",
",",
"popup_css",
":",
"''",
",",
"plugins",
":",
"''",
",",
"document_base_url",
":",
"documentBaseUrl",
",",
"add_form_submit_trigger",
":",
"true",
",",
"submit_patch",
":",
"true",
",",
"add_unload_trigger",
":",
"true",
",",
"convert_urls",
":",
"true",
",",
"relative_urls",
":",
"true",
",",
"remove_script_host",
":",
"true",
",",
"object_resizing",
":",
"true",
",",
"doctype",
":",
"'<!DOCTYPE html>'",
",",
"visual",
":",
"true",
",",
"font_size_style_values",
":",
"'xx-small,x-small,small,medium,large,x-large,xx-large'",
",",
"// See: http://www.w3.org/TR/CSS2/fonts.html#propdef-font-size",
"font_size_legacy_values",
":",
"'xx-small,small,medium,large,x-large,xx-large,300%'",
",",
"forced_root_block",
":",
"'p'",
",",
"hidden_input",
":",
"true",
",",
"padd_empty_editor",
":",
"true",
",",
"render_ui",
":",
"true",
",",
"indentation",
":",
"'30px'",
",",
"inline_styles",
":",
"true",
",",
"convert_fonts_to_spans",
":",
"true",
",",
"indent",
":",
"'simple'",
",",
"indent_before",
":",
"'p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,'",
"+",
"'tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist'",
",",
"indent_after",
":",
"'p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,'",
"+",
"'tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist'",
",",
"validate",
":",
"true",
",",
"entity_encoding",
":",
"'named'",
",",
"url_converter",
":",
"self",
".",
"convertURL",
",",
"url_converter_scope",
":",
"self",
",",
"ie7_compat",
":",
"true",
"}",
",",
"defaultSettings",
",",
"settings",
")",
";",
"// Merge external_plugins",
"if",
"(",
"defaultSettings",
"&&",
"defaultSettings",
".",
"external_plugins",
"&&",
"settings",
".",
"external_plugins",
")",
"{",
"settings",
".",
"external_plugins",
"=",
"extend",
"(",
"{",
"}",
",",
"defaultSettings",
".",
"external_plugins",
",",
"settings",
".",
"external_plugins",
")",
";",
"}",
"self",
".",
"settings",
"=",
"settings",
";",
"AddOnManager",
".",
"language",
"=",
"settings",
".",
"language",
"||",
"'en'",
";",
"AddOnManager",
".",
"languageLoad",
"=",
"settings",
".",
"language_load",
";",
"AddOnManager",
".",
"baseURL",
"=",
"editorManager",
".",
"baseURL",
";",
"/**\n * Editor instance id, normally the same as the div/textarea that was replaced.\n *\n * @property id\n * @type String\n */",
"self",
".",
"id",
"=",
"settings",
".",
"id",
"=",
"id",
";",
"/**\n * State to force the editor to return false on a isDirty call.\n *\n * @property isNotDirty\n * @type Boolean\n * @deprecated Use editor.setDirty instead.\n */",
"self",
".",
"setDirty",
"(",
"false",
")",
";",
"/**\n * Name/Value object containing plugin instances.\n *\n * @property plugins\n * @type Object\n * @example\n * // Execute a method inside a plugin directly\n * tinymce.activeEditor.plugins.someplugin.someMethod();\n */",
"self",
".",
"plugins",
"=",
"{",
"}",
";",
"/**\n * URI object to document configured for the TinyMCE instance.\n *\n * @property documentBaseURI\n * @type tinymce.util.URI\n * @example\n * // Get relative URL from the location of document_base_url\n * tinymce.activeEditor.documentBaseURI.toRelative('/somedir/somefile.htm');\n *\n * // Get absolute URL from the location of document_base_url\n * tinymce.activeEditor.documentBaseURI.toAbsolute('somefile.htm');\n */",
"self",
".",
"documentBaseURI",
"=",
"new",
"URI",
"(",
"settings",
".",
"document_base_url",
"||",
"documentBaseUrl",
",",
"{",
"base_uri",
":",
"baseUri",
"}",
")",
";",
"/**\n * URI object to current document that holds the TinyMCE editor instance.\n *\n * @property baseURI\n * @type tinymce.util.URI\n * @example\n * // Get relative URL from the location of the API\n * tinymce.activeEditor.baseURI.toRelative('/somedir/somefile.htm');\n *\n * // Get absolute URL from the location of the API\n * tinymce.activeEditor.baseURI.toAbsolute('somefile.htm');\n */",
"self",
".",
"baseURI",
"=",
"baseUri",
";",
"/**\n * Array with CSS files to load into the iframe.\n *\n * @property contentCSS\n * @type Array\n */",
"self",
".",
"contentCSS",
"=",
"[",
"]",
";",
"/**\n * Array of CSS styles to add to head of document when the editor loads.\n *\n * @property contentStyles\n * @type Array\n */",
"self",
".",
"contentStyles",
"=",
"[",
"]",
";",
"// Creates all events like onClick, onSetContent etc see Editor.Events.js for the actual logic",
"self",
".",
"shortcuts",
"=",
"new",
"Shortcuts",
"(",
"self",
")",
";",
"self",
".",
"loadedCSS",
"=",
"{",
"}",
";",
"self",
".",
"editorCommands",
"=",
"new",
"EditorCommands",
"(",
"self",
")",
";",
"self",
".",
"suffix",
"=",
"editorManager",
".",
"suffix",
";",
"self",
".",
"editorManager",
"=",
"editorManager",
";",
"self",
".",
"inline",
"=",
"settings",
".",
"inline",
";",
"self",
".",
"settings",
".",
"content_editable",
"=",
"self",
".",
"inline",
";",
"if",
"(",
"settings",
".",
"cache_suffix",
")",
"{",
"Env",
".",
"cacheSuffix",
"=",
"settings",
".",
"cache_suffix",
".",
"replace",
"(",
"/",
"^[\\?\\&]+",
"/",
",",
"''",
")",
";",
"}",
"if",
"(",
"settings",
".",
"override_viewport",
"===",
"false",
")",
"{",
"Env",
".",
"overrideViewPort",
"=",
"false",
";",
"}",
"// Call setup",
"editorManager",
".",
"fire",
"(",
"'SetupEditor'",
",",
"self",
")",
";",
"self",
".",
"execCallback",
"(",
"'setup'",
",",
"self",
")",
";",
"/**\n * Dom query instance with default scope to the editor document and default element is the body of the editor.\n *\n * @property $\n * @type tinymce.dom.DomQuery\n * @example\n * tinymce.activeEditor.$('p').css('color', 'red');\n * tinymce.activeEditor.$().append('<p>new</p>');\n */",
"self",
".",
"$",
"=",
"DomQuery",
".",
"overrideDefaults",
"(",
"function",
"(",
")",
"{",
"return",
"{",
"context",
":",
"self",
".",
"inline",
"?",
"self",
".",
"getBody",
"(",
")",
":",
"self",
".",
"getDoc",
"(",
")",
",",
"element",
":",
"self",
".",
"getBody",
"(",
")",
"}",
";",
"}",
")",
";",
"}"
] | Include documentation for all the events.
@include ../../../../../tools/docs/tinymce.Editor.js
Constructs a editor instance by id.
@constructor
@method Editor
@param {String} id Unique id for the editor.
@param {Object} settings Settings for the editor.
@param {tinymce.EditorManager} editorManager EditorManager instance. | [
"Include",
"documentation",
"for",
"all",
"the",
"events",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L38475-L38651 |
48,307 | sadiqhabib/tinymce-dist | tinymce.full.js | function (name) {
var self = this, callback = self.settings[name], scope;
if (!callback) {
return;
}
// Look through lookup
if (self.callbackLookup && (scope = self.callbackLookup[name])) {
callback = scope.func;
scope = scope.scope;
}
if (typeof callback === 'string') {
scope = callback.replace(/\.\w+$/, '');
scope = scope ? resolve(scope) : 0;
callback = resolve(callback);
self.callbackLookup = self.callbackLookup || {};
self.callbackLookup[name] = { func: callback, scope: scope };
}
return callback.apply(scope || self, Array.prototype.slice.call(arguments, 1));
} | javascript | function (name) {
var self = this, callback = self.settings[name], scope;
if (!callback) {
return;
}
// Look through lookup
if (self.callbackLookup && (scope = self.callbackLookup[name])) {
callback = scope.func;
scope = scope.scope;
}
if (typeof callback === 'string') {
scope = callback.replace(/\.\w+$/, '');
scope = scope ? resolve(scope) : 0;
callback = resolve(callback);
self.callbackLookup = self.callbackLookup || {};
self.callbackLookup[name] = { func: callback, scope: scope };
}
return callback.apply(scope || self, Array.prototype.slice.call(arguments, 1));
} | [
"function",
"(",
"name",
")",
"{",
"var",
"self",
"=",
"this",
",",
"callback",
"=",
"self",
".",
"settings",
"[",
"name",
"]",
",",
"scope",
";",
"if",
"(",
"!",
"callback",
")",
"{",
"return",
";",
"}",
"// Look through lookup",
"if",
"(",
"self",
".",
"callbackLookup",
"&&",
"(",
"scope",
"=",
"self",
".",
"callbackLookup",
"[",
"name",
"]",
")",
")",
"{",
"callback",
"=",
"scope",
".",
"func",
";",
"scope",
"=",
"scope",
".",
"scope",
";",
"}",
"if",
"(",
"typeof",
"callback",
"===",
"'string'",
")",
"{",
"scope",
"=",
"callback",
".",
"replace",
"(",
"/",
"\\.\\w+$",
"/",
",",
"''",
")",
";",
"scope",
"=",
"scope",
"?",
"resolve",
"(",
"scope",
")",
":",
"0",
";",
"callback",
"=",
"resolve",
"(",
"callback",
")",
";",
"self",
".",
"callbackLookup",
"=",
"self",
".",
"callbackLookup",
"||",
"{",
"}",
";",
"self",
".",
"callbackLookup",
"[",
"name",
"]",
"=",
"{",
"func",
":",
"callback",
",",
"scope",
":",
"scope",
"}",
";",
"}",
"return",
"callback",
".",
"apply",
"(",
"scope",
"||",
"self",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
")",
";",
"}"
] | Executes a legacy callback. This method is useful to call old 2.x option callbacks.
There new event model is a better way to add callback so this method might be removed in the future.
@method execCallback
@param {String} name Name of the callback to execute.
@return {Object} Return value passed from callback function. | [
"Executes",
"a",
"legacy",
"callback",
".",
"This",
"method",
"is",
"useful",
"to",
"call",
"old",
"2",
".",
"x",
"option",
"callbacks",
".",
"There",
"new",
"event",
"model",
"is",
"a",
"better",
"way",
"to",
"add",
"callback",
"so",
"this",
"method",
"might",
"be",
"removed",
"in",
"the",
"future",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L39532-L39554 |
|
48,308 | sadiqhabib/tinymce-dist | tinymce.full.js | function (name, defaultVal, type) {
var value = name in this.settings ? this.settings[name] : defaultVal, output;
if (type === 'hash') {
output = {};
if (typeof value === 'string') {
each(value.indexOf('=') > 0 ? value.split(/[;,](?![^=;,]*(?:[;,]|$))/) : value.split(','), function (value) {
value = value.split('=');
if (value.length > 1) {
output[trim(value[0])] = trim(value[1]);
} else {
output[trim(value[0])] = trim(value);
}
});
} else {
output = value;
}
return output;
}
return value;
} | javascript | function (name, defaultVal, type) {
var value = name in this.settings ? this.settings[name] : defaultVal, output;
if (type === 'hash') {
output = {};
if (typeof value === 'string') {
each(value.indexOf('=') > 0 ? value.split(/[;,](?![^=;,]*(?:[;,]|$))/) : value.split(','), function (value) {
value = value.split('=');
if (value.length > 1) {
output[trim(value[0])] = trim(value[1]);
} else {
output[trim(value[0])] = trim(value);
}
});
} else {
output = value;
}
return output;
}
return value;
} | [
"function",
"(",
"name",
",",
"defaultVal",
",",
"type",
")",
"{",
"var",
"value",
"=",
"name",
"in",
"this",
".",
"settings",
"?",
"this",
".",
"settings",
"[",
"name",
"]",
":",
"defaultVal",
",",
"output",
";",
"if",
"(",
"type",
"===",
"'hash'",
")",
"{",
"output",
"=",
"{",
"}",
";",
"if",
"(",
"typeof",
"value",
"===",
"'string'",
")",
"{",
"each",
"(",
"value",
".",
"indexOf",
"(",
"'='",
")",
">",
"0",
"?",
"value",
".",
"split",
"(",
"/",
"[;,](?![^=;,]*(?:[;,]|$))",
"/",
")",
":",
"value",
".",
"split",
"(",
"','",
")",
",",
"function",
"(",
"value",
")",
"{",
"value",
"=",
"value",
".",
"split",
"(",
"'='",
")",
";",
"if",
"(",
"value",
".",
"length",
">",
"1",
")",
"{",
"output",
"[",
"trim",
"(",
"value",
"[",
"0",
"]",
")",
"]",
"=",
"trim",
"(",
"value",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"output",
"[",
"trim",
"(",
"value",
"[",
"0",
"]",
")",
"]",
"=",
"trim",
"(",
"value",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"output",
"=",
"value",
";",
"}",
"return",
"output",
";",
"}",
"return",
"value",
";",
"}"
] | Returns a configuration parameter by name.
@method getParam
@param {String} name Configruation parameter to retrieve.
@param {String} defaultVal Optional default value to return.
@param {String} type Optional type parameter.
@return {String} Configuration parameter value or default value.
@example
// Returns a specific config value from the currently active editor
var someval = tinymce.activeEditor.getParam('myvalue');
// Returns a specific config value from a specific editor instance by id
var someval2 = tinymce.get('my_editor').getParam('myvalue'); | [
"Returns",
"a",
"configuration",
"parameter",
"by",
"name",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L39607-L39631 |
|
48,309 | sadiqhabib/tinymce-dist | tinymce.full.js | function (name, settings) {
var self = this;
if (settings.cmd) {
settings.onclick = function () {
self.execCommand(settings.cmd);
};
}
if (!settings.text && !settings.icon) {
settings.icon = name;
}
self.buttons = self.buttons || {};
settings.tooltip = settings.tooltip || settings.title;
self.buttons[name] = settings;
} | javascript | function (name, settings) {
var self = this;
if (settings.cmd) {
settings.onclick = function () {
self.execCommand(settings.cmd);
};
}
if (!settings.text && !settings.icon) {
settings.icon = name;
}
self.buttons = self.buttons || {};
settings.tooltip = settings.tooltip || settings.title;
self.buttons[name] = settings;
} | [
"function",
"(",
"name",
",",
"settings",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"settings",
".",
"cmd",
")",
"{",
"settings",
".",
"onclick",
"=",
"function",
"(",
")",
"{",
"self",
".",
"execCommand",
"(",
"settings",
".",
"cmd",
")",
";",
"}",
";",
"}",
"if",
"(",
"!",
"settings",
".",
"text",
"&&",
"!",
"settings",
".",
"icon",
")",
"{",
"settings",
".",
"icon",
"=",
"name",
";",
"}",
"self",
".",
"buttons",
"=",
"self",
".",
"buttons",
"||",
"{",
"}",
";",
"settings",
".",
"tooltip",
"=",
"settings",
".",
"tooltip",
"||",
"settings",
".",
"title",
";",
"self",
".",
"buttons",
"[",
"name",
"]",
"=",
"settings",
";",
"}"
] | Adds a button that later gets created by the theme in the editors toolbars.
@method addButton
@param {String} name Button name to add.
@param {Object} settings Settings object with title, cmd etc.
@example
// Adds a custom button to the editor that inserts contents when clicked
tinymce.init({
...
toolbar: 'example'
setup: function(ed) {
ed.addButton('example', {
title: 'My title',
image: '../js/tinymce/plugins/example/img/example.gif',
onclick: function() {
ed.insertContent('Hello world!!');
}
});
}
}); | [
"Adds",
"a",
"button",
"that",
"later",
"gets",
"created",
"by",
"the",
"theme",
"in",
"the",
"editors",
"toolbars",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L39668-L39684 |
|
48,310 | sadiqhabib/tinymce-dist | tinymce.full.js | function (name, settings) {
var self = this;
if (settings.cmd) {
settings.onclick = function () {
self.execCommand(settings.cmd);
};
}
self.menuItems = self.menuItems || {};
self.menuItems[name] = settings;
} | javascript | function (name, settings) {
var self = this;
if (settings.cmd) {
settings.onclick = function () {
self.execCommand(settings.cmd);
};
}
self.menuItems = self.menuItems || {};
self.menuItems[name] = settings;
} | [
"function",
"(",
"name",
",",
"settings",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"settings",
".",
"cmd",
")",
"{",
"settings",
".",
"onclick",
"=",
"function",
"(",
")",
"{",
"self",
".",
"execCommand",
"(",
"settings",
".",
"cmd",
")",
";",
"}",
";",
"}",
"self",
".",
"menuItems",
"=",
"self",
".",
"menuItems",
"||",
"{",
"}",
";",
"self",
".",
"menuItems",
"[",
"name",
"]",
"=",
"settings",
";",
"}"
] | Adds a menu item to be used in the menus of the theme. There might be multiple instances
of this menu item for example it might be used in the main menus of the theme but also in
the context menu so make sure that it's self contained and supports multiple instances.
@method addMenuItem
@param {String} name Menu item name to add.
@param {Object} settings Settings object with title, cmd etc.
@example
// Adds a custom menu item to the editor that inserts contents when clicked
// The context option allows you to add the menu item to an existing default menu
tinymce.init({
...
setup: function(ed) {
ed.addMenuItem('example', {
text: 'My menu item',
context: 'tools',
onclick: function() {
ed.insertContent('Hello world!!');
}
});
}
}); | [
"Adds",
"a",
"menu",
"item",
"to",
"be",
"used",
"in",
"the",
"menus",
"of",
"the",
"theme",
".",
"There",
"might",
"be",
"multiple",
"instances",
"of",
"this",
"menu",
"item",
"for",
"example",
"it",
"might",
"be",
"used",
"in",
"the",
"main",
"menus",
"of",
"the",
"theme",
"but",
"also",
"in",
"the",
"context",
"menu",
"so",
"make",
"sure",
"that",
"it",
"s",
"self",
"contained",
"and",
"supports",
"multiple",
"instances",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L39736-L39747 |
|
48,311 | sadiqhabib/tinymce-dist | tinymce.full.js | function (predicate, items) {
var self = this, selector;
self.contextToolbars = self.contextToolbars || [];
// Convert selector to predicate
if (typeof predicate == "string") {
selector = predicate;
predicate = function (elm) {
return self.dom.is(elm, selector);
};
}
self.contextToolbars.push({
id: Uuid.uuid('mcet'),
predicate: predicate,
items: items
});
} | javascript | function (predicate, items) {
var self = this, selector;
self.contextToolbars = self.contextToolbars || [];
// Convert selector to predicate
if (typeof predicate == "string") {
selector = predicate;
predicate = function (elm) {
return self.dom.is(elm, selector);
};
}
self.contextToolbars.push({
id: Uuid.uuid('mcet'),
predicate: predicate,
items: items
});
} | [
"function",
"(",
"predicate",
",",
"items",
")",
"{",
"var",
"self",
"=",
"this",
",",
"selector",
";",
"self",
".",
"contextToolbars",
"=",
"self",
".",
"contextToolbars",
"||",
"[",
"]",
";",
"// Convert selector to predicate",
"if",
"(",
"typeof",
"predicate",
"==",
"\"string\"",
")",
"{",
"selector",
"=",
"predicate",
";",
"predicate",
"=",
"function",
"(",
"elm",
")",
"{",
"return",
"self",
".",
"dom",
".",
"is",
"(",
"elm",
",",
"selector",
")",
";",
"}",
";",
"}",
"self",
".",
"contextToolbars",
".",
"push",
"(",
"{",
"id",
":",
"Uuid",
".",
"uuid",
"(",
"'mcet'",
")",
",",
"predicate",
":",
"predicate",
",",
"items",
":",
"items",
"}",
")",
";",
"}"
] | Adds a contextual toolbar to be rendered when the selector matches.
@method addContextToolbar
@param {function/string} predicate Predicate that needs to return true if provided strings get converted into CSS predicates.
@param {String/Array} items String or array with items to add to the context toolbar. | [
"Adds",
"a",
"contextual",
"toolbar",
"to",
"be",
"rendered",
"when",
"the",
"selector",
"matches",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L39756-L39774 |
|
48,312 | sadiqhabib/tinymce-dist | tinymce.full.js | function (pattern, desc, cmdFunc, scope) {
this.shortcuts.add(pattern, desc, cmdFunc, scope);
} | javascript | function (pattern, desc, cmdFunc, scope) {
this.shortcuts.add(pattern, desc, cmdFunc, scope);
} | [
"function",
"(",
"pattern",
",",
"desc",
",",
"cmdFunc",
",",
"scope",
")",
"{",
"this",
".",
"shortcuts",
".",
"add",
"(",
"pattern",
",",
"desc",
",",
"cmdFunc",
",",
"scope",
")",
";",
"}"
] | Adds a keyboard shortcut for some command or function.
@method addShortcut
@param {String} pattern Shortcut pattern. Like for example: ctrl+alt+o.
@param {String} desc Text description for the command.
@param {String/Function} cmdFunc Command name string or function to execute when the key is pressed.
@param {Object} sc Optional scope to execute the function in.
@return {Boolean} true/false state if the shortcut was added or not. | [
"Adds",
"a",
"keyboard",
"shortcut",
"for",
"some",
"command",
"or",
"function",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L39857-L39859 |
|
48,313 | sadiqhabib/tinymce-dist | tinymce.full.js | function (cmd, ui, value, args) {
return this.editorCommands.execCommand(cmd, ui, value, args);
} | javascript | function (cmd, ui, value, args) {
return this.editorCommands.execCommand(cmd, ui, value, args);
} | [
"function",
"(",
"cmd",
",",
"ui",
",",
"value",
",",
"args",
")",
"{",
"return",
"this",
".",
"editorCommands",
".",
"execCommand",
"(",
"cmd",
",",
"ui",
",",
"value",
",",
"args",
")",
";",
"}"
] | Executes a command on the current instance. These commands can be TinyMCE internal commands prefixed with "mce" or
they can be build in browser commands such as "Bold". A compleate list of browser commands is available on MSDN or Mozilla.org.
This function will dispatch the execCommand function on each plugin, theme or the execcommand_callback option if none of these
return true it will handle the command as a internal browser command.
@method execCommand
@param {String} cmd Command name to execute, for example mceLink or Bold.
@param {Boolean} ui True/false state if a UI (dialog) should be presented or not.
@param {mixed} value Optional command value, this can be anything.
@param {Object} args Optional arguments object. | [
"Executes",
"a",
"command",
"on",
"the",
"current",
"instance",
".",
"These",
"commands",
"can",
"be",
"TinyMCE",
"internal",
"commands",
"prefixed",
"with",
"mce",
"or",
"they",
"can",
"be",
"build",
"in",
"browser",
"commands",
"such",
"as",
"Bold",
".",
"A",
"compleate",
"list",
"of",
"browser",
"commands",
"is",
"available",
"on",
"MSDN",
"or",
"Mozilla",
".",
"org",
".",
"This",
"function",
"will",
"dispatch",
"the",
"execCommand",
"function",
"on",
"each",
"plugin",
"theme",
"or",
"the",
"execcommand_callback",
"option",
"if",
"none",
"of",
"these",
"return",
"true",
"it",
"will",
"handle",
"the",
"command",
"as",
"a",
"internal",
"browser",
"command",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L39873-L39875 |
|
48,314 | sadiqhabib/tinymce-dist | tinymce.full.js | function (args) {
var self = this, elm = self.getElement(), html;
if (elm) {
args = args || {};
args.load = true;
html = self.setContent(elm.value !== undefined ? elm.value : elm.innerHTML, args);
args.element = elm;
if (!args.no_events) {
self.fire('LoadContent', args);
}
args.element = elm = null;
return html;
}
} | javascript | function (args) {
var self = this, elm = self.getElement(), html;
if (elm) {
args = args || {};
args.load = true;
html = self.setContent(elm.value !== undefined ? elm.value : elm.innerHTML, args);
args.element = elm;
if (!args.no_events) {
self.fire('LoadContent', args);
}
args.element = elm = null;
return html;
}
} | [
"function",
"(",
"args",
")",
"{",
"var",
"self",
"=",
"this",
",",
"elm",
"=",
"self",
".",
"getElement",
"(",
")",
",",
"html",
";",
"if",
"(",
"elm",
")",
"{",
"args",
"=",
"args",
"||",
"{",
"}",
";",
"args",
".",
"load",
"=",
"true",
";",
"html",
"=",
"self",
".",
"setContent",
"(",
"elm",
".",
"value",
"!==",
"undefined",
"?",
"elm",
".",
"value",
":",
"elm",
".",
"innerHTML",
",",
"args",
")",
";",
"args",
".",
"element",
"=",
"elm",
";",
"if",
"(",
"!",
"args",
".",
"no_events",
")",
"{",
"self",
".",
"fire",
"(",
"'LoadContent'",
",",
"args",
")",
";",
"}",
"args",
".",
"element",
"=",
"elm",
"=",
"null",
";",
"return",
"html",
";",
"}",
"}"
] | Loads contents from the textarea or div element that got converted into an editor instance.
This method will move the contents from that textarea or div into the editor by using setContent
so all events etc that method has will get dispatched as well.
@method load
@param {Object} args Optional content object, this gets passed around through the whole load process.
@return {String} HTML string that got set into the editor. | [
"Loads",
"contents",
"from",
"the",
"textarea",
"or",
"div",
"element",
"that",
"got",
"converted",
"into",
"an",
"editor",
"instance",
".",
"This",
"method",
"will",
"move",
"the",
"contents",
"from",
"that",
"textarea",
"or",
"div",
"into",
"the",
"editor",
"by",
"using",
"setContent",
"so",
"all",
"events",
"etc",
"that",
"method",
"has",
"will",
"get",
"dispatched",
"as",
"well",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L40008-L40026 |
|
48,315 | sadiqhabib/tinymce-dist | tinymce.full.js | function (args) {
var self = this, elm = self.getElement(), html, form;
if (!elm || !self.initialized) {
return;
}
args = args || {};
args.save = true;
args.element = elm;
html = args.content = self.getContent(args);
if (!args.no_events) {
self.fire('SaveContent', args);
}
// Always run this internal event
if (args.format == 'raw') {
self.fire('RawSaveContent', args);
}
html = args.content;
if (!/TEXTAREA|INPUT/i.test(elm.nodeName)) {
// Update DIV element when not in inline mode
if (!self.inline) {
elm.innerHTML = html;
}
// Update hidden form element
if ((form = DOM.getParent(self.id, 'form'))) {
each(form.elements, function (elm) {
if (elm.name == self.id) {
elm.value = html;
return false;
}
});
}
} else {
elm.value = html;
}
args.element = elm = null;
if (args.set_dirty !== false) {
self.setDirty(false);
}
return html;
} | javascript | function (args) {
var self = this, elm = self.getElement(), html, form;
if (!elm || !self.initialized) {
return;
}
args = args || {};
args.save = true;
args.element = elm;
html = args.content = self.getContent(args);
if (!args.no_events) {
self.fire('SaveContent', args);
}
// Always run this internal event
if (args.format == 'raw') {
self.fire('RawSaveContent', args);
}
html = args.content;
if (!/TEXTAREA|INPUT/i.test(elm.nodeName)) {
// Update DIV element when not in inline mode
if (!self.inline) {
elm.innerHTML = html;
}
// Update hidden form element
if ((form = DOM.getParent(self.id, 'form'))) {
each(form.elements, function (elm) {
if (elm.name == self.id) {
elm.value = html;
return false;
}
});
}
} else {
elm.value = html;
}
args.element = elm = null;
if (args.set_dirty !== false) {
self.setDirty(false);
}
return html;
} | [
"function",
"(",
"args",
")",
"{",
"var",
"self",
"=",
"this",
",",
"elm",
"=",
"self",
".",
"getElement",
"(",
")",
",",
"html",
",",
"form",
";",
"if",
"(",
"!",
"elm",
"||",
"!",
"self",
".",
"initialized",
")",
"{",
"return",
";",
"}",
"args",
"=",
"args",
"||",
"{",
"}",
";",
"args",
".",
"save",
"=",
"true",
";",
"args",
".",
"element",
"=",
"elm",
";",
"html",
"=",
"args",
".",
"content",
"=",
"self",
".",
"getContent",
"(",
"args",
")",
";",
"if",
"(",
"!",
"args",
".",
"no_events",
")",
"{",
"self",
".",
"fire",
"(",
"'SaveContent'",
",",
"args",
")",
";",
"}",
"// Always run this internal event",
"if",
"(",
"args",
".",
"format",
"==",
"'raw'",
")",
"{",
"self",
".",
"fire",
"(",
"'RawSaveContent'",
",",
"args",
")",
";",
"}",
"html",
"=",
"args",
".",
"content",
";",
"if",
"(",
"!",
"/",
"TEXTAREA|INPUT",
"/",
"i",
".",
"test",
"(",
"elm",
".",
"nodeName",
")",
")",
"{",
"// Update DIV element when not in inline mode",
"if",
"(",
"!",
"self",
".",
"inline",
")",
"{",
"elm",
".",
"innerHTML",
"=",
"html",
";",
"}",
"// Update hidden form element",
"if",
"(",
"(",
"form",
"=",
"DOM",
".",
"getParent",
"(",
"self",
".",
"id",
",",
"'form'",
")",
")",
")",
"{",
"each",
"(",
"form",
".",
"elements",
",",
"function",
"(",
"elm",
")",
"{",
"if",
"(",
"elm",
".",
"name",
"==",
"self",
".",
"id",
")",
"{",
"elm",
".",
"value",
"=",
"html",
";",
"return",
"false",
";",
"}",
"}",
")",
";",
"}",
"}",
"else",
"{",
"elm",
".",
"value",
"=",
"html",
";",
"}",
"args",
".",
"element",
"=",
"elm",
"=",
"null",
";",
"if",
"(",
"args",
".",
"set_dirty",
"!==",
"false",
")",
"{",
"self",
".",
"setDirty",
"(",
"false",
")",
";",
"}",
"return",
"html",
";",
"}"
] | Saves the contents from a editor out to the textarea or div element that got converted into an editor instance.
This method will move the HTML contents from the editor into that textarea or div by getContent
so all events etc that method has will get dispatched as well.
@method save
@param {Object} args Optional content object, this gets passed around through the whole save process.
@return {String} HTML string that got set into the textarea/div. | [
"Saves",
"the",
"contents",
"from",
"a",
"editor",
"out",
"to",
"the",
"textarea",
"or",
"div",
"element",
"that",
"got",
"converted",
"into",
"an",
"editor",
"instance",
".",
"This",
"method",
"will",
"move",
"the",
"HTML",
"contents",
"from",
"the",
"editor",
"into",
"that",
"textarea",
"or",
"div",
"by",
"getContent",
"so",
"all",
"events",
"etc",
"that",
"method",
"has",
"will",
"get",
"dispatched",
"as",
"well",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L40037-L40087 |
|
48,316 | sadiqhabib/tinymce-dist | tinymce.full.js | function (content, args) {
var self = this, body = self.getBody(), forcedRootBlockName, padd;
// Setup args object
args = args || {};
args.format = args.format || 'html';
args.set = true;
args.content = content;
// Do preprocessing
if (!args.no_events) {
self.fire('BeforeSetContent', args);
}
content = args.content;
// Padd empty content in Gecko and Safari. Commands will otherwise fail on the content
// It will also be impossible to place the caret in the editor unless there is a BR element present
if (content.length === 0 || /^\s+$/.test(content)) {
padd = ie && ie < 11 ? '' : '<br data-mce-bogus="1">';
// Todo: There is a lot more root elements that need special padding
// so separate this and add all of them at some point.
if (body.nodeName == 'TABLE') {
content = '<tr><td>' + padd + '</td></tr>';
} else if (/^(UL|OL)$/.test(body.nodeName)) {
content = '<li>' + padd + '</li>';
}
forcedRootBlockName = self.settings.forced_root_block;
// Check if forcedRootBlock is configured and that the block is a valid child of the body
if (forcedRootBlockName && self.schema.isValidChild(body.nodeName.toLowerCase(), forcedRootBlockName.toLowerCase())) {
// Padd with bogus BR elements on modern browsers and IE 7 and 8 since they don't render empty P tags properly
content = padd;
content = self.dom.createHTML(forcedRootBlockName, self.settings.forced_root_block_attrs, content);
} else if (!ie && !content) {
// We need to add a BR when forced_root_block is disabled on non IE browsers to place the caret
content = '<br data-mce-bogus="1">';
}
self.dom.setHTML(body, content);
self.fire('SetContent', args);
} else {
// Parse and serialize the html
if (args.format !== 'raw') {
content = new Serializer({
validate: self.validate
}, self.schema).serialize(
self.parser.parse(content, { isRootContent: true })
);
}
// Set the new cleaned contents to the editor
args.content = trim(content);
self.dom.setHTML(body, args.content);
// Do post processing
if (!args.no_events) {
self.fire('SetContent', args);
}
// Don't normalize selection if the focused element isn't the body in
// content editable mode since it will steal focus otherwise
/*if (!self.settings.content_editable || document.activeElement === self.getBody()) {
self.selection.normalize();
}*/
}
return args.content;
} | javascript | function (content, args) {
var self = this, body = self.getBody(), forcedRootBlockName, padd;
// Setup args object
args = args || {};
args.format = args.format || 'html';
args.set = true;
args.content = content;
// Do preprocessing
if (!args.no_events) {
self.fire('BeforeSetContent', args);
}
content = args.content;
// Padd empty content in Gecko and Safari. Commands will otherwise fail on the content
// It will also be impossible to place the caret in the editor unless there is a BR element present
if (content.length === 0 || /^\s+$/.test(content)) {
padd = ie && ie < 11 ? '' : '<br data-mce-bogus="1">';
// Todo: There is a lot more root elements that need special padding
// so separate this and add all of them at some point.
if (body.nodeName == 'TABLE') {
content = '<tr><td>' + padd + '</td></tr>';
} else if (/^(UL|OL)$/.test(body.nodeName)) {
content = '<li>' + padd + '</li>';
}
forcedRootBlockName = self.settings.forced_root_block;
// Check if forcedRootBlock is configured and that the block is a valid child of the body
if (forcedRootBlockName && self.schema.isValidChild(body.nodeName.toLowerCase(), forcedRootBlockName.toLowerCase())) {
// Padd with bogus BR elements on modern browsers and IE 7 and 8 since they don't render empty P tags properly
content = padd;
content = self.dom.createHTML(forcedRootBlockName, self.settings.forced_root_block_attrs, content);
} else if (!ie && !content) {
// We need to add a BR when forced_root_block is disabled on non IE browsers to place the caret
content = '<br data-mce-bogus="1">';
}
self.dom.setHTML(body, content);
self.fire('SetContent', args);
} else {
// Parse and serialize the html
if (args.format !== 'raw') {
content = new Serializer({
validate: self.validate
}, self.schema).serialize(
self.parser.parse(content, { isRootContent: true })
);
}
// Set the new cleaned contents to the editor
args.content = trim(content);
self.dom.setHTML(body, args.content);
// Do post processing
if (!args.no_events) {
self.fire('SetContent', args);
}
// Don't normalize selection if the focused element isn't the body in
// content editable mode since it will steal focus otherwise
/*if (!self.settings.content_editable || document.activeElement === self.getBody()) {
self.selection.normalize();
}*/
}
return args.content;
} | [
"function",
"(",
"content",
",",
"args",
")",
"{",
"var",
"self",
"=",
"this",
",",
"body",
"=",
"self",
".",
"getBody",
"(",
")",
",",
"forcedRootBlockName",
",",
"padd",
";",
"// Setup args object",
"args",
"=",
"args",
"||",
"{",
"}",
";",
"args",
".",
"format",
"=",
"args",
".",
"format",
"||",
"'html'",
";",
"args",
".",
"set",
"=",
"true",
";",
"args",
".",
"content",
"=",
"content",
";",
"// Do preprocessing",
"if",
"(",
"!",
"args",
".",
"no_events",
")",
"{",
"self",
".",
"fire",
"(",
"'BeforeSetContent'",
",",
"args",
")",
";",
"}",
"content",
"=",
"args",
".",
"content",
";",
"// Padd empty content in Gecko and Safari. Commands will otherwise fail on the content",
"// It will also be impossible to place the caret in the editor unless there is a BR element present",
"if",
"(",
"content",
".",
"length",
"===",
"0",
"||",
"/",
"^\\s+$",
"/",
".",
"test",
"(",
"content",
")",
")",
"{",
"padd",
"=",
"ie",
"&&",
"ie",
"<",
"11",
"?",
"''",
":",
"'<br data-mce-bogus=\"1\">'",
";",
"// Todo: There is a lot more root elements that need special padding",
"// so separate this and add all of them at some point.",
"if",
"(",
"body",
".",
"nodeName",
"==",
"'TABLE'",
")",
"{",
"content",
"=",
"'<tr><td>'",
"+",
"padd",
"+",
"'</td></tr>'",
";",
"}",
"else",
"if",
"(",
"/",
"^(UL|OL)$",
"/",
".",
"test",
"(",
"body",
".",
"nodeName",
")",
")",
"{",
"content",
"=",
"'<li>'",
"+",
"padd",
"+",
"'</li>'",
";",
"}",
"forcedRootBlockName",
"=",
"self",
".",
"settings",
".",
"forced_root_block",
";",
"// Check if forcedRootBlock is configured and that the block is a valid child of the body",
"if",
"(",
"forcedRootBlockName",
"&&",
"self",
".",
"schema",
".",
"isValidChild",
"(",
"body",
".",
"nodeName",
".",
"toLowerCase",
"(",
")",
",",
"forcedRootBlockName",
".",
"toLowerCase",
"(",
")",
")",
")",
"{",
"// Padd with bogus BR elements on modern browsers and IE 7 and 8 since they don't render empty P tags properly",
"content",
"=",
"padd",
";",
"content",
"=",
"self",
".",
"dom",
".",
"createHTML",
"(",
"forcedRootBlockName",
",",
"self",
".",
"settings",
".",
"forced_root_block_attrs",
",",
"content",
")",
";",
"}",
"else",
"if",
"(",
"!",
"ie",
"&&",
"!",
"content",
")",
"{",
"// We need to add a BR when forced_root_block is disabled on non IE browsers to place the caret",
"content",
"=",
"'<br data-mce-bogus=\"1\">'",
";",
"}",
"self",
".",
"dom",
".",
"setHTML",
"(",
"body",
",",
"content",
")",
";",
"self",
".",
"fire",
"(",
"'SetContent'",
",",
"args",
")",
";",
"}",
"else",
"{",
"// Parse and serialize the html",
"if",
"(",
"args",
".",
"format",
"!==",
"'raw'",
")",
"{",
"content",
"=",
"new",
"Serializer",
"(",
"{",
"validate",
":",
"self",
".",
"validate",
"}",
",",
"self",
".",
"schema",
")",
".",
"serialize",
"(",
"self",
".",
"parser",
".",
"parse",
"(",
"content",
",",
"{",
"isRootContent",
":",
"true",
"}",
")",
")",
";",
"}",
"// Set the new cleaned contents to the editor",
"args",
".",
"content",
"=",
"trim",
"(",
"content",
")",
";",
"self",
".",
"dom",
".",
"setHTML",
"(",
"body",
",",
"args",
".",
"content",
")",
";",
"// Do post processing",
"if",
"(",
"!",
"args",
".",
"no_events",
")",
"{",
"self",
".",
"fire",
"(",
"'SetContent'",
",",
"args",
")",
";",
"}",
"// Don't normalize selection if the focused element isn't the body in",
"// content editable mode since it will steal focus otherwise",
"/*if (!self.settings.content_editable || document.activeElement === self.getBody()) {\n self.selection.normalize();\n }*/",
"}",
"return",
"args",
".",
"content",
";",
"}"
] | Sets the specified content to the editor instance, this will cleanup the content before it gets set using
the different cleanup rules options.
@method setContent
@param {String} content Content to set to editor, normally HTML contents but can be other formats as well.
@param {Object} args Optional content object, this gets passed around through the whole set process.
@return {String} HTML string that got set into the editor.
@example
// Sets the HTML contents of the activeEditor editor
tinymce.activeEditor.setContent('<span>some</span> html');
// Sets the raw contents of the activeEditor editor
tinymce.activeEditor.setContent('<span>some</span> html', {format: 'raw'});
// Sets the content of a specific editor (my_editor in this example)
tinymce.get('my_editor').setContent(data);
// Sets the bbcode contents of the activeEditor editor if the bbcode plugin was added
tinymce.activeEditor.setContent('[b]some[/b] html', {format: 'bbcode'}); | [
"Sets",
"the",
"specified",
"content",
"to",
"the",
"editor",
"instance",
"this",
"will",
"cleanup",
"the",
"content",
"before",
"it",
"gets",
"set",
"using",
"the",
"different",
"cleanup",
"rules",
"options",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L40110-L40181 |
|
48,317 | sadiqhabib/tinymce-dist | tinymce.full.js | function (content, args) {
if (args) {
content = extend({ content: content }, args);
}
this.execCommand('mceInsertContent', false, content);
} | javascript | function (content, args) {
if (args) {
content = extend({ content: content }, args);
}
this.execCommand('mceInsertContent', false, content);
} | [
"function",
"(",
"content",
",",
"args",
")",
"{",
"if",
"(",
"args",
")",
"{",
"content",
"=",
"extend",
"(",
"{",
"content",
":",
"content",
"}",
",",
"args",
")",
";",
"}",
"this",
".",
"execCommand",
"(",
"'mceInsertContent'",
",",
"false",
",",
"content",
")",
";",
"}"
] | Inserts content at caret position.
@method insertContent
@param {String} content Content to insert.
@param {Object} args Optional args to pass to insert call. | [
"Inserts",
"content",
"at",
"caret",
"position",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L40245-L40251 |
|
48,318 | sadiqhabib/tinymce-dist | tinymce.full.js | function () {
var self = this, elm;
if (!self.contentWindow) {
elm = self.iframeElement;
if (elm) {
self.contentWindow = elm.contentWindow;
}
}
return self.contentWindow;
} | javascript | function () {
var self = this, elm;
if (!self.contentWindow) {
elm = self.iframeElement;
if (elm) {
self.contentWindow = elm.contentWindow;
}
}
return self.contentWindow;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"elm",
";",
"if",
"(",
"!",
"self",
".",
"contentWindow",
")",
"{",
"elm",
"=",
"self",
".",
"iframeElement",
";",
"if",
"(",
"elm",
")",
"{",
"self",
".",
"contentWindow",
"=",
"elm",
".",
"contentWindow",
";",
"}",
"}",
"return",
"self",
".",
"contentWindow",
";",
"}"
] | Returns the iframes window object.
@method getWin
@return {Window} Iframe DOM window object. | [
"Returns",
"the",
"iframes",
"window",
"object",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L40354-L40366 |
|
48,319 | sadiqhabib/tinymce-dist | tinymce.full.js | function (url, name, elm) {
var self = this, settings = self.settings;
// Use callback instead
if (settings.urlconverter_callback) {
return self.execCallback('urlconverter_callback', url, elm, true, name);
}
// Don't convert link href since thats the CSS files that gets loaded into the editor also skip local file URLs
if (!settings.convert_urls || (elm && elm.nodeName == 'LINK') || url.indexOf('file:') === 0 || url.length === 0) {
return url;
}
// Convert to relative
if (settings.relative_urls) {
return self.documentBaseURI.toRelative(url);
}
// Convert to absolute
url = self.documentBaseURI.toAbsolute(url, settings.remove_script_host);
return url;
} | javascript | function (url, name, elm) {
var self = this, settings = self.settings;
// Use callback instead
if (settings.urlconverter_callback) {
return self.execCallback('urlconverter_callback', url, elm, true, name);
}
// Don't convert link href since thats the CSS files that gets loaded into the editor also skip local file URLs
if (!settings.convert_urls || (elm && elm.nodeName == 'LINK') || url.indexOf('file:') === 0 || url.length === 0) {
return url;
}
// Convert to relative
if (settings.relative_urls) {
return self.documentBaseURI.toRelative(url);
}
// Convert to absolute
url = self.documentBaseURI.toAbsolute(url, settings.remove_script_host);
return url;
} | [
"function",
"(",
"url",
",",
"name",
",",
"elm",
")",
"{",
"var",
"self",
"=",
"this",
",",
"settings",
"=",
"self",
".",
"settings",
";",
"// Use callback instead",
"if",
"(",
"settings",
".",
"urlconverter_callback",
")",
"{",
"return",
"self",
".",
"execCallback",
"(",
"'urlconverter_callback'",
",",
"url",
",",
"elm",
",",
"true",
",",
"name",
")",
";",
"}",
"// Don't convert link href since thats the CSS files that gets loaded into the editor also skip local file URLs",
"if",
"(",
"!",
"settings",
".",
"convert_urls",
"||",
"(",
"elm",
"&&",
"elm",
".",
"nodeName",
"==",
"'LINK'",
")",
"||",
"url",
".",
"indexOf",
"(",
"'file:'",
")",
"===",
"0",
"||",
"url",
".",
"length",
"===",
"0",
")",
"{",
"return",
"url",
";",
"}",
"// Convert to relative",
"if",
"(",
"settings",
".",
"relative_urls",
")",
"{",
"return",
"self",
".",
"documentBaseURI",
".",
"toRelative",
"(",
"url",
")",
";",
"}",
"// Convert to absolute",
"url",
"=",
"self",
".",
"documentBaseURI",
".",
"toAbsolute",
"(",
"url",
",",
"settings",
".",
"remove_script_host",
")",
";",
"return",
"url",
";",
"}"
] | URL converter function this gets executed each time a user adds an img, a or
any other element that has a URL in it. This will be called both by the DOM and HTML
manipulation functions.
@method convertURL
@param {string} url URL to convert.
@param {string} name Attribute name src, href etc.
@param {string/HTMLElement} elm Tag name or HTML DOM element depending on HTML or DOM insert.
@return {string} Converted URL string. | [
"URL",
"converter",
"function",
"this",
"gets",
"executed",
"each",
"time",
"a",
"user",
"adds",
"an",
"img",
"a",
"or",
"any",
"other",
"element",
"that",
"has",
"a",
"URL",
"in",
"it",
".",
"This",
"will",
"be",
"called",
"both",
"by",
"the",
"DOM",
"and",
"HTML",
"manipulation",
"functions",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L40411-L40433 |
|
48,320 | sadiqhabib/tinymce-dist | tinymce.full.js | function (elm) {
var self = this, settings = self.settings, dom = self.dom, cls;
elm = elm || self.getBody();
if (self.hasVisual === undefined) {
self.hasVisual = settings.visual;
}
each(dom.select('table,a', elm), function (elm) {
var value;
switch (elm.nodeName) {
case 'TABLE':
cls = settings.visual_table_class || 'mce-item-table';
value = dom.getAttrib(elm, 'border');
if ((!value || value == '0') && self.hasVisual) {
dom.addClass(elm, cls);
} else {
dom.removeClass(elm, cls);
}
return;
case 'A':
if (!dom.getAttrib(elm, 'href', false)) {
value = dom.getAttrib(elm, 'name') || elm.id;
cls = settings.visual_anchor_class || 'mce-item-anchor';
if (value && self.hasVisual) {
dom.addClass(elm, cls);
} else {
dom.removeClass(elm, cls);
}
}
return;
}
});
self.fire('VisualAid', { element: elm, hasVisual: self.hasVisual });
} | javascript | function (elm) {
var self = this, settings = self.settings, dom = self.dom, cls;
elm = elm || self.getBody();
if (self.hasVisual === undefined) {
self.hasVisual = settings.visual;
}
each(dom.select('table,a', elm), function (elm) {
var value;
switch (elm.nodeName) {
case 'TABLE':
cls = settings.visual_table_class || 'mce-item-table';
value = dom.getAttrib(elm, 'border');
if ((!value || value == '0') && self.hasVisual) {
dom.addClass(elm, cls);
} else {
dom.removeClass(elm, cls);
}
return;
case 'A':
if (!dom.getAttrib(elm, 'href', false)) {
value = dom.getAttrib(elm, 'name') || elm.id;
cls = settings.visual_anchor_class || 'mce-item-anchor';
if (value && self.hasVisual) {
dom.addClass(elm, cls);
} else {
dom.removeClass(elm, cls);
}
}
return;
}
});
self.fire('VisualAid', { element: elm, hasVisual: self.hasVisual });
} | [
"function",
"(",
"elm",
")",
"{",
"var",
"self",
"=",
"this",
",",
"settings",
"=",
"self",
".",
"settings",
",",
"dom",
"=",
"self",
".",
"dom",
",",
"cls",
";",
"elm",
"=",
"elm",
"||",
"self",
".",
"getBody",
"(",
")",
";",
"if",
"(",
"self",
".",
"hasVisual",
"===",
"undefined",
")",
"{",
"self",
".",
"hasVisual",
"=",
"settings",
".",
"visual",
";",
"}",
"each",
"(",
"dom",
".",
"select",
"(",
"'table,a'",
",",
"elm",
")",
",",
"function",
"(",
"elm",
")",
"{",
"var",
"value",
";",
"switch",
"(",
"elm",
".",
"nodeName",
")",
"{",
"case",
"'TABLE'",
":",
"cls",
"=",
"settings",
".",
"visual_table_class",
"||",
"'mce-item-table'",
";",
"value",
"=",
"dom",
".",
"getAttrib",
"(",
"elm",
",",
"'border'",
")",
";",
"if",
"(",
"(",
"!",
"value",
"||",
"value",
"==",
"'0'",
")",
"&&",
"self",
".",
"hasVisual",
")",
"{",
"dom",
".",
"addClass",
"(",
"elm",
",",
"cls",
")",
";",
"}",
"else",
"{",
"dom",
".",
"removeClass",
"(",
"elm",
",",
"cls",
")",
";",
"}",
"return",
";",
"case",
"'A'",
":",
"if",
"(",
"!",
"dom",
".",
"getAttrib",
"(",
"elm",
",",
"'href'",
",",
"false",
")",
")",
"{",
"value",
"=",
"dom",
".",
"getAttrib",
"(",
"elm",
",",
"'name'",
")",
"||",
"elm",
".",
"id",
";",
"cls",
"=",
"settings",
".",
"visual_anchor_class",
"||",
"'mce-item-anchor'",
";",
"if",
"(",
"value",
"&&",
"self",
".",
"hasVisual",
")",
"{",
"dom",
".",
"addClass",
"(",
"elm",
",",
"cls",
")",
";",
"}",
"else",
"{",
"dom",
".",
"removeClass",
"(",
"elm",
",",
"cls",
")",
";",
"}",
"}",
"return",
";",
"}",
"}",
")",
";",
"self",
".",
"fire",
"(",
"'VisualAid'",
",",
"{",
"element",
":",
"elm",
",",
"hasVisual",
":",
"self",
".",
"hasVisual",
"}",
")",
";",
"}"
] | Adds visual aid for tables, anchors etc so they can be more easily edited inside the editor.
@method addVisual
@param {Element} elm Optional root element to loop though to find tables etc that needs the visual aid. | [
"Adds",
"visual",
"aid",
"for",
"tables",
"anchors",
"etc",
"so",
"they",
"can",
"be",
"more",
"easily",
"edited",
"inside",
"the",
"editor",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L40441-L40483 |
|
48,321 | sadiqhabib/tinymce-dist | tinymce.full.js | function () {
var self = this;
if (!self.removed) {
self.save();
self.removed = 1;
self.unbindAllNativeEvents();
// Remove any hidden input
if (self.hasHiddenInput) {
DOM.remove(self.getElement().nextSibling);
}
if (!self.inline) {
// IE 9 has a bug where the selection stops working if you place the
// caret inside the editor then remove the iframe
if (ie && ie < 10) {
self.getDoc().execCommand('SelectAll', false, null);
}
DOM.setStyle(self.id, 'display', self.orgDisplay);
self.getBody().onload = null; // Prevent #6816
}
self.fire('remove');
self.editorManager.remove(self);
DOM.remove(self.getContainer());
self._selectionOverrides.destroy();
self.editorUpload.destroy();
self.destroy();
}
} | javascript | function () {
var self = this;
if (!self.removed) {
self.save();
self.removed = 1;
self.unbindAllNativeEvents();
// Remove any hidden input
if (self.hasHiddenInput) {
DOM.remove(self.getElement().nextSibling);
}
if (!self.inline) {
// IE 9 has a bug where the selection stops working if you place the
// caret inside the editor then remove the iframe
if (ie && ie < 10) {
self.getDoc().execCommand('SelectAll', false, null);
}
DOM.setStyle(self.id, 'display', self.orgDisplay);
self.getBody().onload = null; // Prevent #6816
}
self.fire('remove');
self.editorManager.remove(self);
DOM.remove(self.getContainer());
self._selectionOverrides.destroy();
self.editorUpload.destroy();
self.destroy();
}
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"self",
".",
"removed",
")",
"{",
"self",
".",
"save",
"(",
")",
";",
"self",
".",
"removed",
"=",
"1",
";",
"self",
".",
"unbindAllNativeEvents",
"(",
")",
";",
"// Remove any hidden input",
"if",
"(",
"self",
".",
"hasHiddenInput",
")",
"{",
"DOM",
".",
"remove",
"(",
"self",
".",
"getElement",
"(",
")",
".",
"nextSibling",
")",
";",
"}",
"if",
"(",
"!",
"self",
".",
"inline",
")",
"{",
"// IE 9 has a bug where the selection stops working if you place the",
"// caret inside the editor then remove the iframe",
"if",
"(",
"ie",
"&&",
"ie",
"<",
"10",
")",
"{",
"self",
".",
"getDoc",
"(",
")",
".",
"execCommand",
"(",
"'SelectAll'",
",",
"false",
",",
"null",
")",
";",
"}",
"DOM",
".",
"setStyle",
"(",
"self",
".",
"id",
",",
"'display'",
",",
"self",
".",
"orgDisplay",
")",
";",
"self",
".",
"getBody",
"(",
")",
".",
"onload",
"=",
"null",
";",
"// Prevent #6816",
"}",
"self",
".",
"fire",
"(",
"'remove'",
")",
";",
"self",
".",
"editorManager",
".",
"remove",
"(",
"self",
")",
";",
"DOM",
".",
"remove",
"(",
"self",
".",
"getContainer",
"(",
")",
")",
";",
"self",
".",
"_selectionOverrides",
".",
"destroy",
"(",
")",
";",
"self",
".",
"editorUpload",
".",
"destroy",
"(",
")",
";",
"self",
".",
"destroy",
"(",
")",
";",
"}",
"}"
] | Removes the editor from the dom and tinymce collection.
@method remove | [
"Removes",
"the",
"editor",
"from",
"the",
"dom",
"and",
"tinymce",
"collection",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L40490-L40522 |
|
48,322 | sadiqhabib/tinymce-dist | tinymce.full.js | function (automatic) {
var self = this, form;
// One time is enough
if (self.destroyed) {
return;
}
// If user manually calls destroy and not remove
// Users seems to have logic that calls destroy instead of remove
if (!automatic && !self.removed) {
self.remove();
return;
}
if (!automatic) {
self.editorManager.off('beforeunload', self._beforeUnload);
// Manual destroy
if (self.theme && self.theme.destroy) {
self.theme.destroy();
}
// Destroy controls, selection and dom
self.selection.destroy();
self.dom.destroy();
}
form = self.formElement;
if (form) {
if (form._mceOldSubmit) {
form.submit = form._mceOldSubmit;
form._mceOldSubmit = null;
}
DOM.unbind(form, 'submit reset', self.formEventDelegate);
}
self.contentAreaContainer = self.formElement = self.container = self.editorContainer = null;
self.bodyElement = self.contentDocument = self.contentWindow = null;
self.iframeElement = self.targetElm = null;
if (self.selection) {
self.selection = self.selection.win = self.selection.dom = self.selection.dom.doc = null;
}
self.destroyed = 1;
} | javascript | function (automatic) {
var self = this, form;
// One time is enough
if (self.destroyed) {
return;
}
// If user manually calls destroy and not remove
// Users seems to have logic that calls destroy instead of remove
if (!automatic && !self.removed) {
self.remove();
return;
}
if (!automatic) {
self.editorManager.off('beforeunload', self._beforeUnload);
// Manual destroy
if (self.theme && self.theme.destroy) {
self.theme.destroy();
}
// Destroy controls, selection and dom
self.selection.destroy();
self.dom.destroy();
}
form = self.formElement;
if (form) {
if (form._mceOldSubmit) {
form.submit = form._mceOldSubmit;
form._mceOldSubmit = null;
}
DOM.unbind(form, 'submit reset', self.formEventDelegate);
}
self.contentAreaContainer = self.formElement = self.container = self.editorContainer = null;
self.bodyElement = self.contentDocument = self.contentWindow = null;
self.iframeElement = self.targetElm = null;
if (self.selection) {
self.selection = self.selection.win = self.selection.dom = self.selection.dom.doc = null;
}
self.destroyed = 1;
} | [
"function",
"(",
"automatic",
")",
"{",
"var",
"self",
"=",
"this",
",",
"form",
";",
"// One time is enough",
"if",
"(",
"self",
".",
"destroyed",
")",
"{",
"return",
";",
"}",
"// If user manually calls destroy and not remove",
"// Users seems to have logic that calls destroy instead of remove",
"if",
"(",
"!",
"automatic",
"&&",
"!",
"self",
".",
"removed",
")",
"{",
"self",
".",
"remove",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"automatic",
")",
"{",
"self",
".",
"editorManager",
".",
"off",
"(",
"'beforeunload'",
",",
"self",
".",
"_beforeUnload",
")",
";",
"// Manual destroy",
"if",
"(",
"self",
".",
"theme",
"&&",
"self",
".",
"theme",
".",
"destroy",
")",
"{",
"self",
".",
"theme",
".",
"destroy",
"(",
")",
";",
"}",
"// Destroy controls, selection and dom",
"self",
".",
"selection",
".",
"destroy",
"(",
")",
";",
"self",
".",
"dom",
".",
"destroy",
"(",
")",
";",
"}",
"form",
"=",
"self",
".",
"formElement",
";",
"if",
"(",
"form",
")",
"{",
"if",
"(",
"form",
".",
"_mceOldSubmit",
")",
"{",
"form",
".",
"submit",
"=",
"form",
".",
"_mceOldSubmit",
";",
"form",
".",
"_mceOldSubmit",
"=",
"null",
";",
"}",
"DOM",
".",
"unbind",
"(",
"form",
",",
"'submit reset'",
",",
"self",
".",
"formEventDelegate",
")",
";",
"}",
"self",
".",
"contentAreaContainer",
"=",
"self",
".",
"formElement",
"=",
"self",
".",
"container",
"=",
"self",
".",
"editorContainer",
"=",
"null",
";",
"self",
".",
"bodyElement",
"=",
"self",
".",
"contentDocument",
"=",
"self",
".",
"contentWindow",
"=",
"null",
";",
"self",
".",
"iframeElement",
"=",
"self",
".",
"targetElm",
"=",
"null",
";",
"if",
"(",
"self",
".",
"selection",
")",
"{",
"self",
".",
"selection",
"=",
"self",
".",
"selection",
".",
"win",
"=",
"self",
".",
"selection",
".",
"dom",
"=",
"self",
".",
"selection",
".",
"dom",
".",
"doc",
"=",
"null",
";",
"}",
"self",
".",
"destroyed",
"=",
"1",
";",
"}"
] | Destroys the editor instance by removing all events, element references or other resources
that could leak memory. This method will be called automatically when the page is unloaded
but you can also call it directly if you know what you are doing.
@method destroy
@param {Boolean} automatic Optional state if the destroy is an automatic destroy or user called one. | [
"Destroys",
"the",
"editor",
"instance",
"by",
"removing",
"all",
"events",
"element",
"references",
"or",
"other",
"resources",
"that",
"could",
"leak",
"memory",
".",
"This",
"method",
"will",
"be",
"called",
"automatically",
"when",
"the",
"page",
"is",
"unloaded",
"but",
"you",
"can",
"also",
"call",
"it",
"directly",
"if",
"you",
"know",
"what",
"you",
"are",
"doing",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L40532-L40579 |
|
48,323 | sadiqhabib/tinymce-dist | tinymce.full.js | function (newCode) {
if (newCode) {
code = newCode;
this.rtl = this.data[newCode] ? this.data[newCode]._dir === 'rtl' : false;
}
} | javascript | function (newCode) {
if (newCode) {
code = newCode;
this.rtl = this.data[newCode] ? this.data[newCode]._dir === 'rtl' : false;
}
} | [
"function",
"(",
"newCode",
")",
"{",
"if",
"(",
"newCode",
")",
"{",
"code",
"=",
"newCode",
";",
"this",
".",
"rtl",
"=",
"this",
".",
"data",
"[",
"newCode",
"]",
"?",
"this",
".",
"data",
"[",
"newCode",
"]",
".",
"_dir",
"===",
"'rtl'",
":",
"false",
";",
"}",
"}"
] | Sets the current language code.
@method setCode
@param {String} newCode Current language code. | [
"Sets",
"the",
"current",
"language",
"code",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L40638-L40643 |
|
48,324 | sadiqhabib/tinymce-dist | tinymce.full.js | function (code, items) {
var langData = data[code];
if (!langData) {
data[code] = langData = {};
}
for (var name in items) {
langData[name] = items[name];
}
this.setCode(code);
} | javascript | function (code, items) {
var langData = data[code];
if (!langData) {
data[code] = langData = {};
}
for (var name in items) {
langData[name] = items[name];
}
this.setCode(code);
} | [
"function",
"(",
"code",
",",
"items",
")",
"{",
"var",
"langData",
"=",
"data",
"[",
"code",
"]",
";",
"if",
"(",
"!",
"langData",
")",
"{",
"data",
"[",
"code",
"]",
"=",
"langData",
"=",
"{",
"}",
";",
"}",
"for",
"(",
"var",
"name",
"in",
"items",
")",
"{",
"langData",
"[",
"name",
"]",
"=",
"items",
"[",
"name",
"]",
";",
"}",
"this",
".",
"setCode",
"(",
"code",
")",
";",
"}"
] | Adds translations for a specific language code.
@method add
@param {String} code Language code like sv_SE.
@param {Array} items Name/value array with English en_US to sv_SE. | [
"Adds",
"translations",
"for",
"a",
"specific",
"language",
"code",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L40670-L40682 |
|
48,325 | sadiqhabib/tinymce-dist | tinymce.full.js | function (text) {
var langData = data[code] || {};
/**
* number - string
* null, undefined and empty string - empty string
* array - comma-delimited string
* object - in [object Object]
* function - in [object Function]
*
* @param obj
* @returns {string}
*/
function toString(obj) {
if (Tools.is(obj, 'function')) {
return Object.prototype.toString.call(obj);
}
return !isEmpty(obj) ? '' + obj : '';
}
function isEmpty(text) {
return text === '' || text === null || Tools.is(text, 'undefined');
}
function getLangData(text) {
// make sure we work on a string and return a string
text = toString(text);
return Tools.hasOwn(langData, text) ? toString(langData[text]) : text;
}
if (isEmpty(text)) {
return '';
}
if (Tools.is(text, 'object') && Tools.hasOwn(text, 'raw')) {
return toString(text.raw);
}
if (Tools.is(text, 'array')) {
var values = text.slice(1);
text = getLangData(text[0]).replace(/\{([0-9]+)\}/g, function ($1, $2) {
return Tools.hasOwn(values, $2) ? toString(values[$2]) : $1;
});
}
return getLangData(text).replace(/{context:\w+}$/, '');
} | javascript | function (text) {
var langData = data[code] || {};
/**
* number - string
* null, undefined and empty string - empty string
* array - comma-delimited string
* object - in [object Object]
* function - in [object Function]
*
* @param obj
* @returns {string}
*/
function toString(obj) {
if (Tools.is(obj, 'function')) {
return Object.prototype.toString.call(obj);
}
return !isEmpty(obj) ? '' + obj : '';
}
function isEmpty(text) {
return text === '' || text === null || Tools.is(text, 'undefined');
}
function getLangData(text) {
// make sure we work on a string and return a string
text = toString(text);
return Tools.hasOwn(langData, text) ? toString(langData[text]) : text;
}
if (isEmpty(text)) {
return '';
}
if (Tools.is(text, 'object') && Tools.hasOwn(text, 'raw')) {
return toString(text.raw);
}
if (Tools.is(text, 'array')) {
var values = text.slice(1);
text = getLangData(text[0]).replace(/\{([0-9]+)\}/g, function ($1, $2) {
return Tools.hasOwn(values, $2) ? toString(values[$2]) : $1;
});
}
return getLangData(text).replace(/{context:\w+}$/, '');
} | [
"function",
"(",
"text",
")",
"{",
"var",
"langData",
"=",
"data",
"[",
"code",
"]",
"||",
"{",
"}",
";",
"/**\n * number - string\n * null, undefined and empty string - empty string\n * array - comma-delimited string\n * object - in [object Object]\n * function - in [object Function]\n *\n * @param obj\n * @returns {string}\n */",
"function",
"toString",
"(",
"obj",
")",
"{",
"if",
"(",
"Tools",
".",
"is",
"(",
"obj",
",",
"'function'",
")",
")",
"{",
"return",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"obj",
")",
";",
"}",
"return",
"!",
"isEmpty",
"(",
"obj",
")",
"?",
"''",
"+",
"obj",
":",
"''",
";",
"}",
"function",
"isEmpty",
"(",
"text",
")",
"{",
"return",
"text",
"===",
"''",
"||",
"text",
"===",
"null",
"||",
"Tools",
".",
"is",
"(",
"text",
",",
"'undefined'",
")",
";",
"}",
"function",
"getLangData",
"(",
"text",
")",
"{",
"// make sure we work on a string and return a string",
"text",
"=",
"toString",
"(",
"text",
")",
";",
"return",
"Tools",
".",
"hasOwn",
"(",
"langData",
",",
"text",
")",
"?",
"toString",
"(",
"langData",
"[",
"text",
"]",
")",
":",
"text",
";",
"}",
"if",
"(",
"isEmpty",
"(",
"text",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"Tools",
".",
"is",
"(",
"text",
",",
"'object'",
")",
"&&",
"Tools",
".",
"hasOwn",
"(",
"text",
",",
"'raw'",
")",
")",
"{",
"return",
"toString",
"(",
"text",
".",
"raw",
")",
";",
"}",
"if",
"(",
"Tools",
".",
"is",
"(",
"text",
",",
"'array'",
")",
")",
"{",
"var",
"values",
"=",
"text",
".",
"slice",
"(",
"1",
")",
";",
"text",
"=",
"getLangData",
"(",
"text",
"[",
"0",
"]",
")",
".",
"replace",
"(",
"/",
"\\{([0-9]+)\\}",
"/",
"g",
",",
"function",
"(",
"$1",
",",
"$2",
")",
"{",
"return",
"Tools",
".",
"hasOwn",
"(",
"values",
",",
"$2",
")",
"?",
"toString",
"(",
"values",
"[",
"$2",
"]",
")",
":",
"$1",
";",
"}",
")",
";",
"}",
"return",
"getLangData",
"(",
"text",
")",
".",
"replace",
"(",
"/",
"{context:\\w+}$",
"/",
",",
"''",
")",
";",
"}"
] | Translates the specified text.
It has a few formats:
I18n.translate("Text");
I18n.translate(["Text {0}/{1}", 0, 1]);
I18n.translate({raw: "Raw string"});
@method translate
@param {String/Object/Array} text Text to translate.
@return {String} String that got translated. | [
"Translates",
"the",
"specified",
"text",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L40696-L40743 |
|
48,326 | sadiqhabib/tinymce-dist | tinymce.full.js | function (defaultSettings) {
var baseUrl, suffix;
baseUrl = defaultSettings.base_url;
if (baseUrl) {
this.baseURL = new URI(this.documentBaseURL).toAbsolute(baseUrl.replace(/\/+$/, ''));
this.baseURI = new URI(this.baseURL);
}
suffix = defaultSettings.suffix;
if (defaultSettings.suffix) {
this.suffix = suffix;
}
this.defaultSettings = defaultSettings;
var pluginBaseUrls = defaultSettings.plugin_base_urls;
for (var name in pluginBaseUrls) {
AddOnManager.PluginManager.urls[name] = pluginBaseUrls[name];
}
} | javascript | function (defaultSettings) {
var baseUrl, suffix;
baseUrl = defaultSettings.base_url;
if (baseUrl) {
this.baseURL = new URI(this.documentBaseURL).toAbsolute(baseUrl.replace(/\/+$/, ''));
this.baseURI = new URI(this.baseURL);
}
suffix = defaultSettings.suffix;
if (defaultSettings.suffix) {
this.suffix = suffix;
}
this.defaultSettings = defaultSettings;
var pluginBaseUrls = defaultSettings.plugin_base_urls;
for (var name in pluginBaseUrls) {
AddOnManager.PluginManager.urls[name] = pluginBaseUrls[name];
}
} | [
"function",
"(",
"defaultSettings",
")",
"{",
"var",
"baseUrl",
",",
"suffix",
";",
"baseUrl",
"=",
"defaultSettings",
".",
"base_url",
";",
"if",
"(",
"baseUrl",
")",
"{",
"this",
".",
"baseURL",
"=",
"new",
"URI",
"(",
"this",
".",
"documentBaseURL",
")",
".",
"toAbsolute",
"(",
"baseUrl",
".",
"replace",
"(",
"/",
"\\/+$",
"/",
",",
"''",
")",
")",
";",
"this",
".",
"baseURI",
"=",
"new",
"URI",
"(",
"this",
".",
"baseURL",
")",
";",
"}",
"suffix",
"=",
"defaultSettings",
".",
"suffix",
";",
"if",
"(",
"defaultSettings",
".",
"suffix",
")",
"{",
"this",
".",
"suffix",
"=",
"suffix",
";",
"}",
"this",
".",
"defaultSettings",
"=",
"defaultSettings",
";",
"var",
"pluginBaseUrls",
"=",
"defaultSettings",
".",
"plugin_base_urls",
";",
"for",
"(",
"var",
"name",
"in",
"pluginBaseUrls",
")",
"{",
"AddOnManager",
".",
"PluginManager",
".",
"urls",
"[",
"name",
"]",
"=",
"pluginBaseUrls",
"[",
"name",
"]",
";",
"}",
"}"
] | Overrides the default settings for editor instances.
@method overrideDefaults
@param {Object} defaultSettings Defaults settings object. | [
"Overrides",
"the",
"default",
"settings",
"for",
"editor",
"instances",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L41383-L41403 |
|
48,327 | sadiqhabib/tinymce-dist | tinymce.full.js | function (editor) {
var self = this, editors = self.editors;
// Add named and index editor instance
editors[editor.id] = editor;
editors.push(editor);
toggleGlobalEvents(editors, true);
// Doesn't call setActive method since we don't want
// to fire a bunch of activate/deactivate calls while initializing
self.activeEditor = editor;
self.fire('AddEditor', { editor: editor });
if (!beforeUnloadDelegate) {
beforeUnloadDelegate = function () {
self.fire('BeforeUnload');
};
DOM.bind(window, 'beforeunload', beforeUnloadDelegate);
}
return editor;
} | javascript | function (editor) {
var self = this, editors = self.editors;
// Add named and index editor instance
editors[editor.id] = editor;
editors.push(editor);
toggleGlobalEvents(editors, true);
// Doesn't call setActive method since we don't want
// to fire a bunch of activate/deactivate calls while initializing
self.activeEditor = editor;
self.fire('AddEditor', { editor: editor });
if (!beforeUnloadDelegate) {
beforeUnloadDelegate = function () {
self.fire('BeforeUnload');
};
DOM.bind(window, 'beforeunload', beforeUnloadDelegate);
}
return editor;
} | [
"function",
"(",
"editor",
")",
"{",
"var",
"self",
"=",
"this",
",",
"editors",
"=",
"self",
".",
"editors",
";",
"// Add named and index editor instance",
"editors",
"[",
"editor",
".",
"id",
"]",
"=",
"editor",
";",
"editors",
".",
"push",
"(",
"editor",
")",
";",
"toggleGlobalEvents",
"(",
"editors",
",",
"true",
")",
";",
"// Doesn't call setActive method since we don't want",
"// to fire a bunch of activate/deactivate calls while initializing",
"self",
".",
"activeEditor",
"=",
"editor",
";",
"self",
".",
"fire",
"(",
"'AddEditor'",
",",
"{",
"editor",
":",
"editor",
"}",
")",
";",
"if",
"(",
"!",
"beforeUnloadDelegate",
")",
"{",
"beforeUnloadDelegate",
"=",
"function",
"(",
")",
"{",
"self",
".",
"fire",
"(",
"'BeforeUnload'",
")",
";",
"}",
";",
"DOM",
".",
"bind",
"(",
"window",
",",
"'beforeunload'",
",",
"beforeUnloadDelegate",
")",
";",
"}",
"return",
"editor",
";",
"}"
] | Adds an editor instance to the editor collection. This will also set it as the active editor.
@method add
@param {tinymce.Editor} editor Editor instance to add to the collection.
@return {tinymce.Editor} The same instance that got passed in. | [
"Adds",
"an",
"editor",
"instance",
"to",
"the",
"editor",
"collection",
".",
"This",
"will",
"also",
"set",
"it",
"as",
"the",
"active",
"editor",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L41642-L41666 |
|
48,328 | sadiqhabib/tinymce-dist | tinymce.full.js | function (selector) {
var self = this, i, editors = self.editors, editor;
// Remove all editors
if (!selector) {
for (i = editors.length - 1; i >= 0; i--) {
self.remove(editors[i]);
}
return;
}
// Remove editors by selector
if (typeof selector == "string") {
selector = selector.selector || selector;
each(DOM.select(selector), function (elm) {
editor = editors[elm.id];
if (editor) {
self.remove(editor);
}
});
return;
}
// Remove specific editor
editor = selector;
// Not in the collection
if (!editors[editor.id]) {
return null;
}
if (removeEditorFromList(editor)) {
self.fire('RemoveEditor', { editor: editor });
}
if (!editors.length) {
DOM.unbind(window, 'beforeunload', beforeUnloadDelegate);
}
editor.remove();
toggleGlobalEvents(editors, editors.length > 0);
return editor;
} | javascript | function (selector) {
var self = this, i, editors = self.editors, editor;
// Remove all editors
if (!selector) {
for (i = editors.length - 1; i >= 0; i--) {
self.remove(editors[i]);
}
return;
}
// Remove editors by selector
if (typeof selector == "string") {
selector = selector.selector || selector;
each(DOM.select(selector), function (elm) {
editor = editors[elm.id];
if (editor) {
self.remove(editor);
}
});
return;
}
// Remove specific editor
editor = selector;
// Not in the collection
if (!editors[editor.id]) {
return null;
}
if (removeEditorFromList(editor)) {
self.fire('RemoveEditor', { editor: editor });
}
if (!editors.length) {
DOM.unbind(window, 'beforeunload', beforeUnloadDelegate);
}
editor.remove();
toggleGlobalEvents(editors, editors.length > 0);
return editor;
} | [
"function",
"(",
"selector",
")",
"{",
"var",
"self",
"=",
"this",
",",
"i",
",",
"editors",
"=",
"self",
".",
"editors",
",",
"editor",
";",
"// Remove all editors",
"if",
"(",
"!",
"selector",
")",
"{",
"for",
"(",
"i",
"=",
"editors",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"self",
".",
"remove",
"(",
"editors",
"[",
"i",
"]",
")",
";",
"}",
"return",
";",
"}",
"// Remove editors by selector",
"if",
"(",
"typeof",
"selector",
"==",
"\"string\"",
")",
"{",
"selector",
"=",
"selector",
".",
"selector",
"||",
"selector",
";",
"each",
"(",
"DOM",
".",
"select",
"(",
"selector",
")",
",",
"function",
"(",
"elm",
")",
"{",
"editor",
"=",
"editors",
"[",
"elm",
".",
"id",
"]",
";",
"if",
"(",
"editor",
")",
"{",
"self",
".",
"remove",
"(",
"editor",
")",
";",
"}",
"}",
")",
";",
"return",
";",
"}",
"// Remove specific editor",
"editor",
"=",
"selector",
";",
"// Not in the collection",
"if",
"(",
"!",
"editors",
"[",
"editor",
".",
"id",
"]",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"removeEditorFromList",
"(",
"editor",
")",
")",
"{",
"self",
".",
"fire",
"(",
"'RemoveEditor'",
",",
"{",
"editor",
":",
"editor",
"}",
")",
";",
"}",
"if",
"(",
"!",
"editors",
".",
"length",
")",
"{",
"DOM",
".",
"unbind",
"(",
"window",
",",
"'beforeunload'",
",",
"beforeUnloadDelegate",
")",
";",
"}",
"editor",
".",
"remove",
"(",
")",
";",
"toggleGlobalEvents",
"(",
"editors",
",",
"editors",
".",
"length",
">",
"0",
")",
";",
"return",
"editor",
";",
"}"
] | Removes a editor or editors form page.
@example
// Remove all editors bound to divs
tinymce.remove('div');
// Remove all editors bound to textareas
tinymce.remove('textarea');
// Remove all editors
tinymce.remove();
// Remove specific instance by id
tinymce.remove('#id');
@method remove
@param {tinymce.Editor/String/Object} [selector] CSS selector or editor instance to remove.
@return {tinymce.Editor} The editor that got passed in will be return if it was found otherwise null. | [
"Removes",
"a",
"editor",
"or",
"editors",
"form",
"page",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L41700-L41748 |
|
48,329 | sadiqhabib/tinymce-dist | tinymce.full.js | function (cmd, ui, value) {
var self = this, editor = self.get(value);
// Manager commands
switch (cmd) {
case "mceAddEditor":
if (!self.get(value)) {
new Editor(value, self.settings, self).render();
}
return true;
case "mceRemoveEditor":
if (editor) {
editor.remove();
}
return true;
case 'mceToggleEditor':
if (!editor) {
self.execCommand('mceAddEditor', 0, value);
return true;
}
if (editor.isHidden()) {
editor.show();
} else {
editor.hide();
}
return true;
}
// Run command on active editor
if (self.activeEditor) {
return self.activeEditor.execCommand(cmd, ui, value);
}
return false;
} | javascript | function (cmd, ui, value) {
var self = this, editor = self.get(value);
// Manager commands
switch (cmd) {
case "mceAddEditor":
if (!self.get(value)) {
new Editor(value, self.settings, self).render();
}
return true;
case "mceRemoveEditor":
if (editor) {
editor.remove();
}
return true;
case 'mceToggleEditor':
if (!editor) {
self.execCommand('mceAddEditor', 0, value);
return true;
}
if (editor.isHidden()) {
editor.show();
} else {
editor.hide();
}
return true;
}
// Run command on active editor
if (self.activeEditor) {
return self.activeEditor.execCommand(cmd, ui, value);
}
return false;
} | [
"function",
"(",
"cmd",
",",
"ui",
",",
"value",
")",
"{",
"var",
"self",
"=",
"this",
",",
"editor",
"=",
"self",
".",
"get",
"(",
"value",
")",
";",
"// Manager commands",
"switch",
"(",
"cmd",
")",
"{",
"case",
"\"mceAddEditor\"",
":",
"if",
"(",
"!",
"self",
".",
"get",
"(",
"value",
")",
")",
"{",
"new",
"Editor",
"(",
"value",
",",
"self",
".",
"settings",
",",
"self",
")",
".",
"render",
"(",
")",
";",
"}",
"return",
"true",
";",
"case",
"\"mceRemoveEditor\"",
":",
"if",
"(",
"editor",
")",
"{",
"editor",
".",
"remove",
"(",
")",
";",
"}",
"return",
"true",
";",
"case",
"'mceToggleEditor'",
":",
"if",
"(",
"!",
"editor",
")",
"{",
"self",
".",
"execCommand",
"(",
"'mceAddEditor'",
",",
"0",
",",
"value",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"editor",
".",
"isHidden",
"(",
")",
")",
"{",
"editor",
".",
"show",
"(",
")",
";",
"}",
"else",
"{",
"editor",
".",
"hide",
"(",
")",
";",
"}",
"return",
"true",
";",
"}",
"// Run command on active editor",
"if",
"(",
"self",
".",
"activeEditor",
")",
"{",
"return",
"self",
".",
"activeEditor",
".",
"execCommand",
"(",
"cmd",
",",
"ui",
",",
"value",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Executes a specific command on the currently active editor.
@method execCommand
@param {String} cmd Command to perform for example Bold.
@param {Boolean} ui Optional boolean state if a UI should be presented for the command or not.
@param {String} value Optional value parameter like for example an URL to a link.
@return {Boolean} true/false if the command was executed or not. | [
"Executes",
"a",
"specific",
"command",
"on",
"the",
"currently",
"active",
"editor",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L41759-L41799 |
|
48,330 | sadiqhabib/tinymce-dist | tinymce.full.js | load | function load() {
var key, data, value, pos = 0;
items = {};
// localStorage can be disabled on WebKit/Gecko so make a dummy storage
if (!hasOldIEDataSupport) {
return;
}
function next(end) {
var value, nextPos;
nextPos = end !== undefined ? pos + end : data.indexOf(',', pos);
if (nextPos === -1 || nextPos > data.length) {
return null;
}
value = data.substring(pos, nextPos);
pos = nextPos + 1;
return value;
}
storageElm.load(userDataKey);
data = storageElm.getAttribute(userDataKey) || '';
do {
var offset = next();
if (offset === null) {
break;
}
key = next(parseInt(offset, 32) || 0);
if (key !== null) {
offset = next();
if (offset === null) {
break;
}
value = next(parseInt(offset, 32) || 0);
if (key) {
items[key] = value;
}
}
} while (key !== null);
updateKeys();
} | javascript | function load() {
var key, data, value, pos = 0;
items = {};
// localStorage can be disabled on WebKit/Gecko so make a dummy storage
if (!hasOldIEDataSupport) {
return;
}
function next(end) {
var value, nextPos;
nextPos = end !== undefined ? pos + end : data.indexOf(',', pos);
if (nextPos === -1 || nextPos > data.length) {
return null;
}
value = data.substring(pos, nextPos);
pos = nextPos + 1;
return value;
}
storageElm.load(userDataKey);
data = storageElm.getAttribute(userDataKey) || '';
do {
var offset = next();
if (offset === null) {
break;
}
key = next(parseInt(offset, 32) || 0);
if (key !== null) {
offset = next();
if (offset === null) {
break;
}
value = next(parseInt(offset, 32) || 0);
if (key) {
items[key] = value;
}
}
} while (key !== null);
updateKeys();
} | [
"function",
"load",
"(",
")",
"{",
"var",
"key",
",",
"data",
",",
"value",
",",
"pos",
"=",
"0",
";",
"items",
"=",
"{",
"}",
";",
"// localStorage can be disabled on WebKit/Gecko so make a dummy storage",
"if",
"(",
"!",
"hasOldIEDataSupport",
")",
"{",
"return",
";",
"}",
"function",
"next",
"(",
"end",
")",
"{",
"var",
"value",
",",
"nextPos",
";",
"nextPos",
"=",
"end",
"!==",
"undefined",
"?",
"pos",
"+",
"end",
":",
"data",
".",
"indexOf",
"(",
"','",
",",
"pos",
")",
";",
"if",
"(",
"nextPos",
"===",
"-",
"1",
"||",
"nextPos",
">",
"data",
".",
"length",
")",
"{",
"return",
"null",
";",
"}",
"value",
"=",
"data",
".",
"substring",
"(",
"pos",
",",
"nextPos",
")",
";",
"pos",
"=",
"nextPos",
"+",
"1",
";",
"return",
"value",
";",
"}",
"storageElm",
".",
"load",
"(",
"userDataKey",
")",
";",
"data",
"=",
"storageElm",
".",
"getAttribute",
"(",
"userDataKey",
")",
"||",
"''",
";",
"do",
"{",
"var",
"offset",
"=",
"next",
"(",
")",
";",
"if",
"(",
"offset",
"===",
"null",
")",
"{",
"break",
";",
"}",
"key",
"=",
"next",
"(",
"parseInt",
"(",
"offset",
",",
"32",
")",
"||",
"0",
")",
";",
"if",
"(",
"key",
"!==",
"null",
")",
"{",
"offset",
"=",
"next",
"(",
")",
";",
"if",
"(",
"offset",
"===",
"null",
")",
"{",
"break",
";",
"}",
"value",
"=",
"next",
"(",
"parseInt",
"(",
"offset",
",",
"32",
")",
"||",
"0",
")",
";",
"if",
"(",
"key",
")",
"{",
"items",
"[",
"key",
"]",
"=",
"value",
";",
"}",
"}",
"}",
"while",
"(",
"key",
"!==",
"null",
")",
";",
"updateKeys",
"(",
")",
";",
"}"
] | Loads the userData string and parses it into the items structure. | [
"Loads",
"the",
"userData",
"string",
"and",
"parses",
"it",
"into",
"the",
"items",
"structure",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L42323-L42372 |
48,331 | sadiqhabib/tinymce-dist | tinymce.full.js | save | function save() {
var value, data = '';
// localStorage can be disabled on WebKit/Gecko so make a dummy storage
if (!hasOldIEDataSupport) {
return;
}
for (var key in items) {
value = items[key];
data += (data ? ',' : '') + key.length.toString(32) + ',' + key + ',' + value.length.toString(32) + ',' + value;
}
storageElm.setAttribute(userDataKey, data);
try {
storageElm.save(userDataKey);
} catch (ex) {
// Ignore disk full
}
updateKeys();
} | javascript | function save() {
var value, data = '';
// localStorage can be disabled on WebKit/Gecko so make a dummy storage
if (!hasOldIEDataSupport) {
return;
}
for (var key in items) {
value = items[key];
data += (data ? ',' : '') + key.length.toString(32) + ',' + key + ',' + value.length.toString(32) + ',' + value;
}
storageElm.setAttribute(userDataKey, data);
try {
storageElm.save(userDataKey);
} catch (ex) {
// Ignore disk full
}
updateKeys();
} | [
"function",
"save",
"(",
")",
"{",
"var",
"value",
",",
"data",
"=",
"''",
";",
"// localStorage can be disabled on WebKit/Gecko so make a dummy storage",
"if",
"(",
"!",
"hasOldIEDataSupport",
")",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"key",
"in",
"items",
")",
"{",
"value",
"=",
"items",
"[",
"key",
"]",
";",
"data",
"+=",
"(",
"data",
"?",
"','",
":",
"''",
")",
"+",
"key",
".",
"length",
".",
"toString",
"(",
"32",
")",
"+",
"','",
"+",
"key",
"+",
"','",
"+",
"value",
".",
"length",
".",
"toString",
"(",
"32",
")",
"+",
"','",
"+",
"value",
";",
"}",
"storageElm",
".",
"setAttribute",
"(",
"userDataKey",
",",
"data",
")",
";",
"try",
"{",
"storageElm",
".",
"save",
"(",
"userDataKey",
")",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"// Ignore disk full",
"}",
"updateKeys",
"(",
")",
";",
"}"
] | Saves the items structure into a the userData format. | [
"Saves",
"the",
"items",
"structure",
"into",
"a",
"the",
"userData",
"format",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L42377-L42399 |
48,332 | sadiqhabib/tinymce-dist | tinymce.full.js | function (items) {
var self = this, settings = self.settings, firstClass, lastClass, firstItem, lastItem;
firstClass = settings.firstControlClass;
lastClass = settings.lastControlClass;
items.each(function (item) {
item.classes.remove(firstClass).remove(lastClass).add(settings.controlClass);
if (item.visible()) {
if (!firstItem) {
firstItem = item;
}
lastItem = item;
}
});
if (firstItem) {
firstItem.classes.add(firstClass);
}
if (lastItem) {
lastItem.classes.add(lastClass);
}
} | javascript | function (items) {
var self = this, settings = self.settings, firstClass, lastClass, firstItem, lastItem;
firstClass = settings.firstControlClass;
lastClass = settings.lastControlClass;
items.each(function (item) {
item.classes.remove(firstClass).remove(lastClass).add(settings.controlClass);
if (item.visible()) {
if (!firstItem) {
firstItem = item;
}
lastItem = item;
}
});
if (firstItem) {
firstItem.classes.add(firstClass);
}
if (lastItem) {
lastItem.classes.add(lastClass);
}
} | [
"function",
"(",
"items",
")",
"{",
"var",
"self",
"=",
"this",
",",
"settings",
"=",
"self",
".",
"settings",
",",
"firstClass",
",",
"lastClass",
",",
"firstItem",
",",
"lastItem",
";",
"firstClass",
"=",
"settings",
".",
"firstControlClass",
";",
"lastClass",
"=",
"settings",
".",
"lastControlClass",
";",
"items",
".",
"each",
"(",
"function",
"(",
"item",
")",
"{",
"item",
".",
"classes",
".",
"remove",
"(",
"firstClass",
")",
".",
"remove",
"(",
"lastClass",
")",
".",
"add",
"(",
"settings",
".",
"controlClass",
")",
";",
"if",
"(",
"item",
".",
"visible",
"(",
")",
")",
"{",
"if",
"(",
"!",
"firstItem",
")",
"{",
"firstItem",
"=",
"item",
";",
"}",
"lastItem",
"=",
"item",
";",
"}",
"}",
")",
";",
"if",
"(",
"firstItem",
")",
"{",
"firstItem",
".",
"classes",
".",
"add",
"(",
"firstClass",
")",
";",
"}",
"if",
"(",
"lastItem",
")",
"{",
"lastItem",
".",
"classes",
".",
"add",
"(",
"lastClass",
")",
";",
"}",
"}"
] | Applies layout classes to the container.
@private | [
"Applies",
"layout",
"classes",
"to",
"the",
"container",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L42869-L42894 |
|
48,333 | sadiqhabib/tinymce-dist | tinymce.full.js | function (container) {
var self = this, html = '';
self.applyClasses(container.items());
container.items().each(function (item) {
html += item.renderHtml();
});
return html;
} | javascript | function (container) {
var self = this, html = '';
self.applyClasses(container.items());
container.items().each(function (item) {
html += item.renderHtml();
});
return html;
} | [
"function",
"(",
"container",
")",
"{",
"var",
"self",
"=",
"this",
",",
"html",
"=",
"''",
";",
"self",
".",
"applyClasses",
"(",
"container",
".",
"items",
"(",
")",
")",
";",
"container",
".",
"items",
"(",
")",
".",
"each",
"(",
"function",
"(",
"item",
")",
"{",
"html",
"+=",
"item",
".",
"renderHtml",
"(",
")",
";",
"}",
")",
";",
"return",
"html",
";",
"}"
] | Renders the specified container and any layout specific HTML.
@method renderHtml
@param {tinymce.ui.Container} container Container to render HTML for. | [
"Renders",
"the",
"specified",
"container",
"and",
"any",
"layout",
"specific",
"HTML",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L42902-L42912 |
|
48,334 | sadiqhabib/tinymce-dist | tinymce.full.js | function (settings) {
var self = this, size;
self._super(settings);
settings = self.settings;
size = self.settings.size;
self.on('click mousedown', function (e) {
e.preventDefault();
});
self.on('touchstart', function (e) {
self.fire('click', e);
e.preventDefault();
});
if (settings.subtype) {
self.classes.add(settings.subtype);
}
if (size) {
self.classes.add('btn-' + size);
}
if (settings.icon) {
self.icon(settings.icon);
}
} | javascript | function (settings) {
var self = this, size;
self._super(settings);
settings = self.settings;
size = self.settings.size;
self.on('click mousedown', function (e) {
e.preventDefault();
});
self.on('touchstart', function (e) {
self.fire('click', e);
e.preventDefault();
});
if (settings.subtype) {
self.classes.add(settings.subtype);
}
if (size) {
self.classes.add('btn-' + size);
}
if (settings.icon) {
self.icon(settings.icon);
}
} | [
"function",
"(",
"settings",
")",
"{",
"var",
"self",
"=",
"this",
",",
"size",
";",
"self",
".",
"_super",
"(",
"settings",
")",
";",
"settings",
"=",
"self",
".",
"settings",
";",
"size",
"=",
"self",
".",
"settings",
".",
"size",
";",
"self",
".",
"on",
"(",
"'click mousedown'",
",",
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"}",
")",
";",
"self",
".",
"on",
"(",
"'touchstart'",
",",
"function",
"(",
"e",
")",
"{",
"self",
".",
"fire",
"(",
"'click'",
",",
"e",
")",
";",
"e",
".",
"preventDefault",
"(",
")",
";",
"}",
")",
";",
"if",
"(",
"settings",
".",
"subtype",
")",
"{",
"self",
".",
"classes",
".",
"add",
"(",
"settings",
".",
"subtype",
")",
";",
"}",
"if",
"(",
"size",
")",
"{",
"self",
".",
"classes",
".",
"add",
"(",
"'btn-'",
"+",
"size",
")",
";",
"}",
"if",
"(",
"settings",
".",
"icon",
")",
"{",
"self",
".",
"icon",
"(",
"settings",
".",
"icon",
")",
";",
"}",
"}"
] | Constructs a new button instance with the specified settings.
@constructor
@param {Object} settings Name/value object with settings.
@setting {String} size Size of the button small|medium|large.
@setting {String} image Image to use for icon.
@setting {String} icon Icon to use for button. | [
"Constructs",
"a",
"new",
"button",
"instance",
"with",
"the",
"specified",
"settings",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L43052-L43080 |
|
48,335 | sadiqhabib/tinymce-dist | tinymce.full.js | function () {
var btnElm = this.getEl().firstChild,
btnStyle;
if (btnElm) {
btnStyle = btnElm.style;
btnStyle.width = btnStyle.height = "100%";
}
this._super();
} | javascript | function () {
var btnElm = this.getEl().firstChild,
btnStyle;
if (btnElm) {
btnStyle = btnElm.style;
btnStyle.width = btnStyle.height = "100%";
}
this._super();
} | [
"function",
"(",
")",
"{",
"var",
"btnElm",
"=",
"this",
".",
"getEl",
"(",
")",
".",
"firstChild",
",",
"btnStyle",
";",
"if",
"(",
"btnElm",
")",
"{",
"btnStyle",
"=",
"btnElm",
".",
"style",
";",
"btnStyle",
".",
"width",
"=",
"btnStyle",
".",
"height",
"=",
"\"100%\"",
";",
"}",
"this",
".",
"_super",
"(",
")",
";",
"}"
] | Repaints the button for example after it's been resizes by a layout engine.
@method repaint | [
"Repaints",
"the",
"button",
"for",
"example",
"after",
"it",
"s",
"been",
"resizes",
"by",
"a",
"layout",
"engine",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L43104-L43114 |
|
48,336 | sadiqhabib/tinymce-dist | tinymce.full.js | function (settings) {
var self = this;
self._super(settings);
self.on('click mousedown', function (e) {
e.preventDefault();
});
self.on('click', function (e) {
e.preventDefault();
if (!self.disabled()) {
self.checked(!self.checked());
}
});
self.checked(self.settings.checked);
} | javascript | function (settings) {
var self = this;
self._super(settings);
self.on('click mousedown', function (e) {
e.preventDefault();
});
self.on('click', function (e) {
e.preventDefault();
if (!self.disabled()) {
self.checked(!self.checked());
}
});
self.checked(self.settings.checked);
} | [
"function",
"(",
"settings",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"_super",
"(",
"settings",
")",
";",
"self",
".",
"on",
"(",
"'click mousedown'",
",",
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"}",
")",
";",
"self",
".",
"on",
"(",
"'click'",
",",
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"if",
"(",
"!",
"self",
".",
"disabled",
"(",
")",
")",
"{",
"self",
".",
"checked",
"(",
"!",
"self",
".",
"checked",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"self",
".",
"checked",
"(",
"self",
".",
"settings",
".",
"checked",
")",
";",
"}"
] | Constructs a new Checkbox instance with the specified settings.
@constructor
@param {Object} settings Name/value object with settings.
@setting {Boolean} checked True if the checkbox should be checked by default. | [
"Constructs",
"a",
"new",
"Checkbox",
"instance",
"with",
"the",
"specified",
"settings",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L43322-L43340 |
|
48,337 | sadiqhabib/tinymce-dist | tinymce.full.js | function () {
var self = this, settings = self.settings;
self.active(true);
if (!self.panel) {
var panelSettings = settings.panel;
// Wrap panel in grid layout if type if specified
// This makes it possible to add forms or other containers directly in the panel option
if (panelSettings.type) {
panelSettings = {
layout: 'grid',
items: panelSettings
};
}
panelSettings.role = panelSettings.role || 'dialog';
panelSettings.popover = true;
panelSettings.autohide = true;
panelSettings.ariaRoot = true;
self.panel = new FloatPanel(panelSettings).on('hide', function () {
self.active(false);
}).on('cancel', function (e) {
e.stopPropagation();
self.focus();
self.hidePanel();
}).parent(self).renderTo(self.getContainerElm());
self.panel.fire('show');
self.panel.reflow();
} else {
self.panel.show();
}
self.panel.moveRel(self.getEl(), settings.popoverAlign || (self.isRtl() ? ['bc-tr', 'bc-tc'] : ['bc-tl', 'bc-tc']));
} | javascript | function () {
var self = this, settings = self.settings;
self.active(true);
if (!self.panel) {
var panelSettings = settings.panel;
// Wrap panel in grid layout if type if specified
// This makes it possible to add forms or other containers directly in the panel option
if (panelSettings.type) {
panelSettings = {
layout: 'grid',
items: panelSettings
};
}
panelSettings.role = panelSettings.role || 'dialog';
panelSettings.popover = true;
panelSettings.autohide = true;
panelSettings.ariaRoot = true;
self.panel = new FloatPanel(panelSettings).on('hide', function () {
self.active(false);
}).on('cancel', function (e) {
e.stopPropagation();
self.focus();
self.hidePanel();
}).parent(self).renderTo(self.getContainerElm());
self.panel.fire('show');
self.panel.reflow();
} else {
self.panel.show();
}
self.panel.moveRel(self.getEl(), settings.popoverAlign || (self.isRtl() ? ['bc-tr', 'bc-tc'] : ['bc-tl', 'bc-tc']));
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"settings",
"=",
"self",
".",
"settings",
";",
"self",
".",
"active",
"(",
"true",
")",
";",
"if",
"(",
"!",
"self",
".",
"panel",
")",
"{",
"var",
"panelSettings",
"=",
"settings",
".",
"panel",
";",
"// Wrap panel in grid layout if type if specified",
"// This makes it possible to add forms or other containers directly in the panel option",
"if",
"(",
"panelSettings",
".",
"type",
")",
"{",
"panelSettings",
"=",
"{",
"layout",
":",
"'grid'",
",",
"items",
":",
"panelSettings",
"}",
";",
"}",
"panelSettings",
".",
"role",
"=",
"panelSettings",
".",
"role",
"||",
"'dialog'",
";",
"panelSettings",
".",
"popover",
"=",
"true",
";",
"panelSettings",
".",
"autohide",
"=",
"true",
";",
"panelSettings",
".",
"ariaRoot",
"=",
"true",
";",
"self",
".",
"panel",
"=",
"new",
"FloatPanel",
"(",
"panelSettings",
")",
".",
"on",
"(",
"'hide'",
",",
"function",
"(",
")",
"{",
"self",
".",
"active",
"(",
"false",
")",
";",
"}",
")",
".",
"on",
"(",
"'cancel'",
",",
"function",
"(",
"e",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"self",
".",
"focus",
"(",
")",
";",
"self",
".",
"hidePanel",
"(",
")",
";",
"}",
")",
".",
"parent",
"(",
"self",
")",
".",
"renderTo",
"(",
"self",
".",
"getContainerElm",
"(",
")",
")",
";",
"self",
".",
"panel",
".",
"fire",
"(",
"'show'",
")",
";",
"self",
".",
"panel",
".",
"reflow",
"(",
")",
";",
"}",
"else",
"{",
"self",
".",
"panel",
".",
"show",
"(",
")",
";",
"}",
"self",
".",
"panel",
".",
"moveRel",
"(",
"self",
".",
"getEl",
"(",
")",
",",
"settings",
".",
"popoverAlign",
"||",
"(",
"self",
".",
"isRtl",
"(",
")",
"?",
"[",
"'bc-tr'",
",",
"'bc-tc'",
"]",
":",
"[",
"'bc-tl'",
",",
"'bc-tc'",
"]",
")",
")",
";",
"}"
] | Shows the panel for the button.
@method showPanel | [
"Shows",
"the",
"panel",
"for",
"the",
"button",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L44020-L44057 |
|
48,338 | sadiqhabib/tinymce-dist | tinymce.full.js | function () {
var self = this, items = self.items();
if (!self.settings.formItemDefaults) {
self.settings.formItemDefaults = {
layout: 'flex',
autoResize: "overflow",
defaults: { flex: 1 }
};
}
// Wrap any labeled items in FormItems
items.each(function (ctrl) {
var formItem, label = ctrl.settings.label;
if (label) {
formItem = new FormItem(Tools.extend({
items: {
type: 'label',
id: ctrl._id + '-l',
text: label,
flex: 0,
forId: ctrl._id,
disabled: ctrl.disabled()
}
}, self.settings.formItemDefaults));
formItem.type = 'formitem';
ctrl.aria('labelledby', ctrl._id + '-l');
if (typeof ctrl.settings.flex == "undefined") {
ctrl.settings.flex = 1;
}
self.replace(ctrl, formItem);
formItem.add(ctrl);
}
});
} | javascript | function () {
var self = this, items = self.items();
if (!self.settings.formItemDefaults) {
self.settings.formItemDefaults = {
layout: 'flex',
autoResize: "overflow",
defaults: { flex: 1 }
};
}
// Wrap any labeled items in FormItems
items.each(function (ctrl) {
var formItem, label = ctrl.settings.label;
if (label) {
formItem = new FormItem(Tools.extend({
items: {
type: 'label',
id: ctrl._id + '-l',
text: label,
flex: 0,
forId: ctrl._id,
disabled: ctrl.disabled()
}
}, self.settings.formItemDefaults));
formItem.type = 'formitem';
ctrl.aria('labelledby', ctrl._id + '-l');
if (typeof ctrl.settings.flex == "undefined") {
ctrl.settings.flex = 1;
}
self.replace(ctrl, formItem);
formItem.add(ctrl);
}
});
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"items",
"=",
"self",
".",
"items",
"(",
")",
";",
"if",
"(",
"!",
"self",
".",
"settings",
".",
"formItemDefaults",
")",
"{",
"self",
".",
"settings",
".",
"formItemDefaults",
"=",
"{",
"layout",
":",
"'flex'",
",",
"autoResize",
":",
"\"overflow\"",
",",
"defaults",
":",
"{",
"flex",
":",
"1",
"}",
"}",
";",
"}",
"// Wrap any labeled items in FormItems",
"items",
".",
"each",
"(",
"function",
"(",
"ctrl",
")",
"{",
"var",
"formItem",
",",
"label",
"=",
"ctrl",
".",
"settings",
".",
"label",
";",
"if",
"(",
"label",
")",
"{",
"formItem",
"=",
"new",
"FormItem",
"(",
"Tools",
".",
"extend",
"(",
"{",
"items",
":",
"{",
"type",
":",
"'label'",
",",
"id",
":",
"ctrl",
".",
"_id",
"+",
"'-l'",
",",
"text",
":",
"label",
",",
"flex",
":",
"0",
",",
"forId",
":",
"ctrl",
".",
"_id",
",",
"disabled",
":",
"ctrl",
".",
"disabled",
"(",
")",
"}",
"}",
",",
"self",
".",
"settings",
".",
"formItemDefaults",
")",
")",
";",
"formItem",
".",
"type",
"=",
"'formitem'",
";",
"ctrl",
".",
"aria",
"(",
"'labelledby'",
",",
"ctrl",
".",
"_id",
"+",
"'-l'",
")",
";",
"if",
"(",
"typeof",
"ctrl",
".",
"settings",
".",
"flex",
"==",
"\"undefined\"",
")",
"{",
"ctrl",
".",
"settings",
".",
"flex",
"=",
"1",
";",
"}",
"self",
".",
"replace",
"(",
"ctrl",
",",
"formItem",
")",
";",
"formItem",
".",
"add",
"(",
"ctrl",
")",
";",
"}",
"}",
")",
";",
"}"
] | This method gets invoked before the control is rendered.
@method preRender | [
"This",
"method",
"gets",
"invoked",
"before",
"the",
"control",
"is",
"rendered",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L44779-L44817 |
|
48,339 | sadiqhabib/tinymce-dist | tinymce.full.js | function (html, callback) {
var self = this, body = this.getEl().contentWindow.document.body;
// Wait for iframe to initialize IE 10 takes time
if (!body) {
Delay.setTimeout(function () {
self.html(html);
});
} else {
body.innerHTML = html;
if (callback) {
callback();
}
}
return this;
} | javascript | function (html, callback) {
var self = this, body = this.getEl().contentWindow.document.body;
// Wait for iframe to initialize IE 10 takes time
if (!body) {
Delay.setTimeout(function () {
self.html(html);
});
} else {
body.innerHTML = html;
if (callback) {
callback();
}
}
return this;
} | [
"function",
"(",
"html",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"body",
"=",
"this",
".",
"getEl",
"(",
")",
".",
"contentWindow",
".",
"document",
".",
"body",
";",
"// Wait for iframe to initialize IE 10 takes time",
"if",
"(",
"!",
"body",
")",
"{",
"Delay",
".",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"self",
".",
"html",
"(",
"html",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"body",
".",
"innerHTML",
"=",
"html",
";",
"if",
"(",
"callback",
")",
"{",
"callback",
"(",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | Inner HTML for the iframe.
@method html
@param {String} html HTML string to set as HTML inside the iframe.
@param {function} callback Optional callback to execute when the iframe body is filled with contents.
@return {tinymce.ui.Iframe} Current iframe control. | [
"Inner",
"HTML",
"for",
"the",
"iframe",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L46877-L46894 |
|
48,340 | sadiqhabib/tinymce-dist | tinymce.full.js | function (toggle) {
var self = this, menu;
if (self.menu && self.menu.visible() && toggle !== false) {
return self.hideMenu();
}
if (!self.menu) {
menu = self.state.get('menu') || [];
// Is menu array then auto constuct menu control
if (menu.length) {
menu = {
type: 'menu',
items: menu
};
} else {
menu.type = menu.type || 'menu';
}
if (!menu.renderTo) {
self.menu = Factory.create(menu).parent(self).renderTo();
} else {
self.menu = menu.parent(self).show().renderTo();
}
self.fire('createmenu');
self.menu.reflow();
self.menu.on('cancel', function (e) {
if (e.control.parent() === self.menu) {
e.stopPropagation();
self.focus();
self.hideMenu();
}
});
// Move focus to button when a menu item is selected/clicked
self.menu.on('select', function () {
self.focus();
});
self.menu.on('show hide', function (e) {
if (e.control == self.menu) {
self.activeMenu(e.type == 'show');
}
self.aria('expanded', e.type == 'show');
}).fire('show');
}
self.menu.show();
self.menu.layoutRect({ w: self.layoutRect().w });
self.menu.moveRel(self.getEl(), self.isRtl() ? ['br-tr', 'tr-br'] : ['bl-tl', 'tl-bl']);
self.fire('showmenu');
} | javascript | function (toggle) {
var self = this, menu;
if (self.menu && self.menu.visible() && toggle !== false) {
return self.hideMenu();
}
if (!self.menu) {
menu = self.state.get('menu') || [];
// Is menu array then auto constuct menu control
if (menu.length) {
menu = {
type: 'menu',
items: menu
};
} else {
menu.type = menu.type || 'menu';
}
if (!menu.renderTo) {
self.menu = Factory.create(menu).parent(self).renderTo();
} else {
self.menu = menu.parent(self).show().renderTo();
}
self.fire('createmenu');
self.menu.reflow();
self.menu.on('cancel', function (e) {
if (e.control.parent() === self.menu) {
e.stopPropagation();
self.focus();
self.hideMenu();
}
});
// Move focus to button when a menu item is selected/clicked
self.menu.on('select', function () {
self.focus();
});
self.menu.on('show hide', function (e) {
if (e.control == self.menu) {
self.activeMenu(e.type == 'show');
}
self.aria('expanded', e.type == 'show');
}).fire('show');
}
self.menu.show();
self.menu.layoutRect({ w: self.layoutRect().w });
self.menu.moveRel(self.getEl(), self.isRtl() ? ['br-tr', 'tr-br'] : ['bl-tl', 'tl-bl']);
self.fire('showmenu');
} | [
"function",
"(",
"toggle",
")",
"{",
"var",
"self",
"=",
"this",
",",
"menu",
";",
"if",
"(",
"self",
".",
"menu",
"&&",
"self",
".",
"menu",
".",
"visible",
"(",
")",
"&&",
"toggle",
"!==",
"false",
")",
"{",
"return",
"self",
".",
"hideMenu",
"(",
")",
";",
"}",
"if",
"(",
"!",
"self",
".",
"menu",
")",
"{",
"menu",
"=",
"self",
".",
"state",
".",
"get",
"(",
"'menu'",
")",
"||",
"[",
"]",
";",
"// Is menu array then auto constuct menu control",
"if",
"(",
"menu",
".",
"length",
")",
"{",
"menu",
"=",
"{",
"type",
":",
"'menu'",
",",
"items",
":",
"menu",
"}",
";",
"}",
"else",
"{",
"menu",
".",
"type",
"=",
"menu",
".",
"type",
"||",
"'menu'",
";",
"}",
"if",
"(",
"!",
"menu",
".",
"renderTo",
")",
"{",
"self",
".",
"menu",
"=",
"Factory",
".",
"create",
"(",
"menu",
")",
".",
"parent",
"(",
"self",
")",
".",
"renderTo",
"(",
")",
";",
"}",
"else",
"{",
"self",
".",
"menu",
"=",
"menu",
".",
"parent",
"(",
"self",
")",
".",
"show",
"(",
")",
".",
"renderTo",
"(",
")",
";",
"}",
"self",
".",
"fire",
"(",
"'createmenu'",
")",
";",
"self",
".",
"menu",
".",
"reflow",
"(",
")",
";",
"self",
".",
"menu",
".",
"on",
"(",
"'cancel'",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"control",
".",
"parent",
"(",
")",
"===",
"self",
".",
"menu",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"self",
".",
"focus",
"(",
")",
";",
"self",
".",
"hideMenu",
"(",
")",
";",
"}",
"}",
")",
";",
"// Move focus to button when a menu item is selected/clicked",
"self",
".",
"menu",
".",
"on",
"(",
"'select'",
",",
"function",
"(",
")",
"{",
"self",
".",
"focus",
"(",
")",
";",
"}",
")",
";",
"self",
".",
"menu",
".",
"on",
"(",
"'show hide'",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"control",
"==",
"self",
".",
"menu",
")",
"{",
"self",
".",
"activeMenu",
"(",
"e",
".",
"type",
"==",
"'show'",
")",
";",
"}",
"self",
".",
"aria",
"(",
"'expanded'",
",",
"e",
".",
"type",
"==",
"'show'",
")",
";",
"}",
")",
".",
"fire",
"(",
"'show'",
")",
";",
"}",
"self",
".",
"menu",
".",
"show",
"(",
")",
";",
"self",
".",
"menu",
".",
"layoutRect",
"(",
"{",
"w",
":",
"self",
".",
"layoutRect",
"(",
")",
".",
"w",
"}",
")",
";",
"self",
".",
"menu",
".",
"moveRel",
"(",
"self",
".",
"getEl",
"(",
")",
",",
"self",
".",
"isRtl",
"(",
")",
"?",
"[",
"'br-tr'",
",",
"'tr-br'",
"]",
":",
"[",
"'bl-tl'",
",",
"'tl-bl'",
"]",
")",
";",
"self",
".",
"fire",
"(",
"'showmenu'",
")",
";",
"}"
] | Shows the menu for the button.
@method showMenu | [
"Shows",
"the",
"menu",
"for",
"the",
"button",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L47314-L47368 |
|
48,341 | sadiqhabib/tinymce-dist | tinymce.full.js | function () {
var self = this;
if (self.menu) {
self.menu.items().each(function (item) {
if (item.hideMenu) {
item.hideMenu();
}
});
self.menu.hide();
}
} | javascript | function () {
var self = this;
if (self.menu) {
self.menu.items().each(function (item) {
if (item.hideMenu) {
item.hideMenu();
}
});
self.menu.hide();
}
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"self",
".",
"menu",
")",
"{",
"self",
".",
"menu",
".",
"items",
"(",
")",
".",
"each",
"(",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"item",
".",
"hideMenu",
")",
"{",
"item",
".",
"hideMenu",
"(",
")",
";",
"}",
"}",
")",
";",
"self",
".",
"menu",
".",
"hide",
"(",
")",
";",
"}",
"}"
] | Hides the menu for the button.
@method hideMenu | [
"Hides",
"the",
"menu",
"for",
"the",
"button",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L47375-L47387 |
|
48,342 | sadiqhabib/tinymce-dist | tinymce.full.js | function () {
var self = this, settings = self.settings, menu, parent = self.parent();
parent.items().each(function (ctrl) {
if (ctrl !== self) {
ctrl.hideMenu();
}
});
if (settings.menu) {
menu = self.menu;
if (!menu) {
menu = settings.menu;
// Is menu array then auto constuct menu control
if (menu.length) {
menu = {
type: 'menu',
items: menu
};
} else {
menu.type = menu.type || 'menu';
}
if (parent.settings.itemDefaults) {
menu.itemDefaults = parent.settings.itemDefaults;
}
menu = self.menu = Factory.create(menu).parent(self).renderTo();
menu.reflow();
menu.on('cancel', function (e) {
e.stopPropagation();
self.focus();
menu.hide();
});
menu.on('show hide', function (e) {
if (e.control.items) {
e.control.items().each(function (ctrl) {
ctrl.active(ctrl.settings.selected);
});
}
}).fire('show');
menu.on('hide', function (e) {
if (e.control === menu) {
self.classes.remove('selected');
}
});
menu.submenu = true;
} else {
menu.show();
}
menu._parentMenu = parent;
menu.classes.add('menu-sub');
var rel = menu.testMoveRel(
self.getEl(),
self.isRtl() ? ['tl-tr', 'bl-br', 'tr-tl', 'br-bl'] : ['tr-tl', 'br-bl', 'tl-tr', 'bl-br']
);
menu.moveRel(self.getEl(), rel);
menu.rel = rel;
rel = 'menu-sub-' + rel;
menu.classes.remove(menu._lastRel).add(rel);
menu._lastRel = rel;
self.classes.add('selected');
self.aria('expanded', true);
}
} | javascript | function () {
var self = this, settings = self.settings, menu, parent = self.parent();
parent.items().each(function (ctrl) {
if (ctrl !== self) {
ctrl.hideMenu();
}
});
if (settings.menu) {
menu = self.menu;
if (!menu) {
menu = settings.menu;
// Is menu array then auto constuct menu control
if (menu.length) {
menu = {
type: 'menu',
items: menu
};
} else {
menu.type = menu.type || 'menu';
}
if (parent.settings.itemDefaults) {
menu.itemDefaults = parent.settings.itemDefaults;
}
menu = self.menu = Factory.create(menu).parent(self).renderTo();
menu.reflow();
menu.on('cancel', function (e) {
e.stopPropagation();
self.focus();
menu.hide();
});
menu.on('show hide', function (e) {
if (e.control.items) {
e.control.items().each(function (ctrl) {
ctrl.active(ctrl.settings.selected);
});
}
}).fire('show');
menu.on('hide', function (e) {
if (e.control === menu) {
self.classes.remove('selected');
}
});
menu.submenu = true;
} else {
menu.show();
}
menu._parentMenu = parent;
menu.classes.add('menu-sub');
var rel = menu.testMoveRel(
self.getEl(),
self.isRtl() ? ['tl-tr', 'bl-br', 'tr-tl', 'br-bl'] : ['tr-tl', 'br-bl', 'tl-tr', 'bl-br']
);
menu.moveRel(self.getEl(), rel);
menu.rel = rel;
rel = 'menu-sub-' + rel;
menu.classes.remove(menu._lastRel).add(rel);
menu._lastRel = rel;
self.classes.add('selected');
self.aria('expanded', true);
}
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"settings",
"=",
"self",
".",
"settings",
",",
"menu",
",",
"parent",
"=",
"self",
".",
"parent",
"(",
")",
";",
"parent",
".",
"items",
"(",
")",
".",
"each",
"(",
"function",
"(",
"ctrl",
")",
"{",
"if",
"(",
"ctrl",
"!==",
"self",
")",
"{",
"ctrl",
".",
"hideMenu",
"(",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"settings",
".",
"menu",
")",
"{",
"menu",
"=",
"self",
".",
"menu",
";",
"if",
"(",
"!",
"menu",
")",
"{",
"menu",
"=",
"settings",
".",
"menu",
";",
"// Is menu array then auto constuct menu control",
"if",
"(",
"menu",
".",
"length",
")",
"{",
"menu",
"=",
"{",
"type",
":",
"'menu'",
",",
"items",
":",
"menu",
"}",
";",
"}",
"else",
"{",
"menu",
".",
"type",
"=",
"menu",
".",
"type",
"||",
"'menu'",
";",
"}",
"if",
"(",
"parent",
".",
"settings",
".",
"itemDefaults",
")",
"{",
"menu",
".",
"itemDefaults",
"=",
"parent",
".",
"settings",
".",
"itemDefaults",
";",
"}",
"menu",
"=",
"self",
".",
"menu",
"=",
"Factory",
".",
"create",
"(",
"menu",
")",
".",
"parent",
"(",
"self",
")",
".",
"renderTo",
"(",
")",
";",
"menu",
".",
"reflow",
"(",
")",
";",
"menu",
".",
"on",
"(",
"'cancel'",
",",
"function",
"(",
"e",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"self",
".",
"focus",
"(",
")",
";",
"menu",
".",
"hide",
"(",
")",
";",
"}",
")",
";",
"menu",
".",
"on",
"(",
"'show hide'",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"control",
".",
"items",
")",
"{",
"e",
".",
"control",
".",
"items",
"(",
")",
".",
"each",
"(",
"function",
"(",
"ctrl",
")",
"{",
"ctrl",
".",
"active",
"(",
"ctrl",
".",
"settings",
".",
"selected",
")",
";",
"}",
")",
";",
"}",
"}",
")",
".",
"fire",
"(",
"'show'",
")",
";",
"menu",
".",
"on",
"(",
"'hide'",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"control",
"===",
"menu",
")",
"{",
"self",
".",
"classes",
".",
"remove",
"(",
"'selected'",
")",
";",
"}",
"}",
")",
";",
"menu",
".",
"submenu",
"=",
"true",
";",
"}",
"else",
"{",
"menu",
".",
"show",
"(",
")",
";",
"}",
"menu",
".",
"_parentMenu",
"=",
"parent",
";",
"menu",
".",
"classes",
".",
"add",
"(",
"'menu-sub'",
")",
";",
"var",
"rel",
"=",
"menu",
".",
"testMoveRel",
"(",
"self",
".",
"getEl",
"(",
")",
",",
"self",
".",
"isRtl",
"(",
")",
"?",
"[",
"'tl-tr'",
",",
"'bl-br'",
",",
"'tr-tl'",
",",
"'br-bl'",
"]",
":",
"[",
"'tr-tl'",
",",
"'br-bl'",
",",
"'tl-tr'",
",",
"'bl-br'",
"]",
")",
";",
"menu",
".",
"moveRel",
"(",
"self",
".",
"getEl",
"(",
")",
",",
"rel",
")",
";",
"menu",
".",
"rel",
"=",
"rel",
";",
"rel",
"=",
"'menu-sub-'",
"+",
"rel",
";",
"menu",
".",
"classes",
".",
"remove",
"(",
"menu",
".",
"_lastRel",
")",
".",
"add",
"(",
"rel",
")",
";",
"menu",
".",
"_lastRel",
"=",
"rel",
";",
"self",
".",
"classes",
".",
"add",
"(",
"'selected'",
")",
";",
"self",
".",
"aria",
"(",
"'expanded'",
",",
"true",
")",
";",
"}",
"}"
] | Shows the menu for the menu item.
@method showMenu | [
"Shows",
"the",
"menu",
"for",
"the",
"menu",
"item",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L47619-L47693 |
|
48,343 | sadiqhabib/tinymce-dist | tinymce.full.js | function () {
var self = this;
if (self.menu) {
self.menu.items().each(function (item) {
if (item.hideMenu) {
item.hideMenu();
}
});
self.menu.hide();
self.aria('expanded', false);
}
return self;
} | javascript | function () {
var self = this;
if (self.menu) {
self.menu.items().each(function (item) {
if (item.hideMenu) {
item.hideMenu();
}
});
self.menu.hide();
self.aria('expanded', false);
}
return self;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"self",
".",
"menu",
")",
"{",
"self",
".",
"menu",
".",
"items",
"(",
")",
".",
"each",
"(",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"item",
".",
"hideMenu",
")",
"{",
"item",
".",
"hideMenu",
"(",
")",
";",
"}",
"}",
")",
";",
"self",
".",
"menu",
".",
"hide",
"(",
")",
";",
"self",
".",
"aria",
"(",
"'expanded'",
",",
"false",
")",
";",
"}",
"return",
"self",
";",
"}"
] | Hides the menu for the menu item.
@method hideMenu | [
"Hides",
"the",
"menu",
"for",
"the",
"menu",
"item",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L47700-L47715 |
|
48,344 | sadiqhabib/tinymce-dist | tinymce.full.js | function () {
var self = this, time, factory;
function hideThrobber() {
if (self.throbber) {
self.throbber.hide();
self.throbber = null;
}
}
factory = self.settings.itemsFactory;
if (!factory) {
return;
}
if (!self.throbber) {
self.throbber = new Throbber(self.getEl('body'), true);
if (self.items().length === 0) {
self.throbber.show();
self.fire('loading');
} else {
self.throbber.show(100, function () {
self.items().remove();
self.fire('loading');
});
}
self.on('hide close', hideThrobber);
}
self.requestTime = time = new Date().getTime();
self.settings.itemsFactory(function (items) {
if (items.length === 0) {
self.hide();
return;
}
if (self.requestTime !== time) {
return;
}
self.getEl().style.width = '';
self.getEl('body').style.width = '';
hideThrobber();
self.items().remove();
self.getEl('body').innerHTML = '';
self.add(items);
self.renderNew();
self.fire('loaded');
});
} | javascript | function () {
var self = this, time, factory;
function hideThrobber() {
if (self.throbber) {
self.throbber.hide();
self.throbber = null;
}
}
factory = self.settings.itemsFactory;
if (!factory) {
return;
}
if (!self.throbber) {
self.throbber = new Throbber(self.getEl('body'), true);
if (self.items().length === 0) {
self.throbber.show();
self.fire('loading');
} else {
self.throbber.show(100, function () {
self.items().remove();
self.fire('loading');
});
}
self.on('hide close', hideThrobber);
}
self.requestTime = time = new Date().getTime();
self.settings.itemsFactory(function (items) {
if (items.length === 0) {
self.hide();
return;
}
if (self.requestTime !== time) {
return;
}
self.getEl().style.width = '';
self.getEl('body').style.width = '';
hideThrobber();
self.items().remove();
self.getEl('body').innerHTML = '';
self.add(items);
self.renderNew();
self.fire('loaded');
});
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"time",
",",
"factory",
";",
"function",
"hideThrobber",
"(",
")",
"{",
"if",
"(",
"self",
".",
"throbber",
")",
"{",
"self",
".",
"throbber",
".",
"hide",
"(",
")",
";",
"self",
".",
"throbber",
"=",
"null",
";",
"}",
"}",
"factory",
"=",
"self",
".",
"settings",
".",
"itemsFactory",
";",
"if",
"(",
"!",
"factory",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"self",
".",
"throbber",
")",
"{",
"self",
".",
"throbber",
"=",
"new",
"Throbber",
"(",
"self",
".",
"getEl",
"(",
"'body'",
")",
",",
"true",
")",
";",
"if",
"(",
"self",
".",
"items",
"(",
")",
".",
"length",
"===",
"0",
")",
"{",
"self",
".",
"throbber",
".",
"show",
"(",
")",
";",
"self",
".",
"fire",
"(",
"'loading'",
")",
";",
"}",
"else",
"{",
"self",
".",
"throbber",
".",
"show",
"(",
"100",
",",
"function",
"(",
")",
"{",
"self",
".",
"items",
"(",
")",
".",
"remove",
"(",
")",
";",
"self",
".",
"fire",
"(",
"'loading'",
")",
";",
"}",
")",
";",
"}",
"self",
".",
"on",
"(",
"'hide close'",
",",
"hideThrobber",
")",
";",
"}",
"self",
".",
"requestTime",
"=",
"time",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
";",
"self",
".",
"settings",
".",
"itemsFactory",
"(",
"function",
"(",
"items",
")",
"{",
"if",
"(",
"items",
".",
"length",
"===",
"0",
")",
"{",
"self",
".",
"hide",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"self",
".",
"requestTime",
"!==",
"time",
")",
"{",
"return",
";",
"}",
"self",
".",
"getEl",
"(",
")",
".",
"style",
".",
"width",
"=",
"''",
";",
"self",
".",
"getEl",
"(",
"'body'",
")",
".",
"style",
".",
"width",
"=",
"''",
";",
"hideThrobber",
"(",
")",
";",
"self",
".",
"items",
"(",
")",
".",
"remove",
"(",
")",
";",
"self",
".",
"getEl",
"(",
"'body'",
")",
".",
"innerHTML",
"=",
"''",
";",
"self",
".",
"add",
"(",
"items",
")",
";",
"self",
".",
"renderNew",
"(",
")",
";",
"self",
".",
"fire",
"(",
"'loaded'",
")",
";",
"}",
")",
";",
"}"
] | Loads new items from the factory items function.
@method load | [
"Loads",
"new",
"items",
"from",
"the",
"factory",
"items",
"function",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L48078-L48132 |
|
48,345 | sadiqhabib/tinymce-dist | tinymce.full.js | function () {
var self = this;
self.items().each(function (ctrl) {
var settings = ctrl.settings;
if (settings.icon || settings.image || settings.selectable) {
self._hasIcons = true;
return false;
}
});
if (self.settings.itemsFactory) {
self.on('postrender', function () {
if (self.settings.itemsFactory) {
self.load();
}
});
}
return self._super();
} | javascript | function () {
var self = this;
self.items().each(function (ctrl) {
var settings = ctrl.settings;
if (settings.icon || settings.image || settings.selectable) {
self._hasIcons = true;
return false;
}
});
if (self.settings.itemsFactory) {
self.on('postrender', function () {
if (self.settings.itemsFactory) {
self.load();
}
});
}
return self._super();
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"items",
"(",
")",
".",
"each",
"(",
"function",
"(",
"ctrl",
")",
"{",
"var",
"settings",
"=",
"ctrl",
".",
"settings",
";",
"if",
"(",
"settings",
".",
"icon",
"||",
"settings",
".",
"image",
"||",
"settings",
".",
"selectable",
")",
"{",
"self",
".",
"_hasIcons",
"=",
"true",
";",
"return",
"false",
";",
"}",
"}",
")",
";",
"if",
"(",
"self",
".",
"settings",
".",
"itemsFactory",
")",
"{",
"self",
".",
"on",
"(",
"'postrender'",
",",
"function",
"(",
")",
"{",
"if",
"(",
"self",
".",
"settings",
".",
"itemsFactory",
")",
"{",
"self",
".",
"load",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"return",
"self",
".",
"_super",
"(",
")",
";",
"}"
] | Invoked before the menu is rendered.
@method preRender | [
"Invoked",
"before",
"the",
"menu",
"is",
"rendered",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L48152-L48173 |
|
48,346 | sadiqhabib/tinymce-dist | tinymce.full.js | function (idx) {
var activeTabElm;
if (this.activeTabId) {
activeTabElm = this.getEl(this.activeTabId);
$(activeTabElm).removeClass(this.classPrefix + 'active');
activeTabElm.setAttribute('aria-selected', "false");
}
this.activeTabId = 't' + idx;
activeTabElm = this.getEl('t' + idx);
activeTabElm.setAttribute('aria-selected', "true");
$(activeTabElm).addClass(this.classPrefix + 'active');
this.items()[idx].show().fire('showtab');
this.reflow();
this.items().each(function (item, i) {
if (idx != i) {
item.hide();
}
});
} | javascript | function (idx) {
var activeTabElm;
if (this.activeTabId) {
activeTabElm = this.getEl(this.activeTabId);
$(activeTabElm).removeClass(this.classPrefix + 'active');
activeTabElm.setAttribute('aria-selected', "false");
}
this.activeTabId = 't' + idx;
activeTabElm = this.getEl('t' + idx);
activeTabElm.setAttribute('aria-selected', "true");
$(activeTabElm).addClass(this.classPrefix + 'active');
this.items()[idx].show().fire('showtab');
this.reflow();
this.items().each(function (item, i) {
if (idx != i) {
item.hide();
}
});
} | [
"function",
"(",
"idx",
")",
"{",
"var",
"activeTabElm",
";",
"if",
"(",
"this",
".",
"activeTabId",
")",
"{",
"activeTabElm",
"=",
"this",
".",
"getEl",
"(",
"this",
".",
"activeTabId",
")",
";",
"$",
"(",
"activeTabElm",
")",
".",
"removeClass",
"(",
"this",
".",
"classPrefix",
"+",
"'active'",
")",
";",
"activeTabElm",
".",
"setAttribute",
"(",
"'aria-selected'",
",",
"\"false\"",
")",
";",
"}",
"this",
".",
"activeTabId",
"=",
"'t'",
"+",
"idx",
";",
"activeTabElm",
"=",
"this",
".",
"getEl",
"(",
"'t'",
"+",
"idx",
")",
";",
"activeTabElm",
".",
"setAttribute",
"(",
"'aria-selected'",
",",
"\"true\"",
")",
";",
"$",
"(",
"activeTabElm",
")",
".",
"addClass",
"(",
"this",
".",
"classPrefix",
"+",
"'active'",
")",
";",
"this",
".",
"items",
"(",
")",
"[",
"idx",
"]",
".",
"show",
"(",
")",
".",
"fire",
"(",
"'showtab'",
")",
";",
"this",
".",
"reflow",
"(",
")",
";",
"this",
".",
"items",
"(",
")",
".",
"each",
"(",
"function",
"(",
"item",
",",
"i",
")",
"{",
"if",
"(",
"idx",
"!=",
"i",
")",
"{",
"item",
".",
"hide",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Activates the specified tab by index.
@method activateTab
@param {Number} idx Index of the tab to activate. | [
"Activates",
"the",
"specified",
"tab",
"by",
"index",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L49079-L49102 |
|
48,347 | sadiqhabib/tinymce-dist | tinymce.full.js | function (editor, size) {
var toolbars = [], settings = editor.settings;
var addToolbar = function (items) {
if (items) {
toolbars.push(createToolbar(editor, items, size));
return true;
}
};
// Convert toolbar array to multiple options
if (Tools.isArray(settings.toolbar)) {
// Empty toolbar array is the same as a disabled toolbar
if (settings.toolbar.length === 0) {
return;
}
Tools.each(settings.toolbar, function (toolbar, i) {
settings["toolbar" + (i + 1)] = toolbar;
});
delete settings.toolbar;
}
// Generate toolbar<n>
for (var i = 1; i < 10; i++) {
if (!addToolbar(settings["toolbar" + i])) {
break;
}
}
// Generate toolbar or default toolbar unless it's disabled
if (!toolbars.length && settings.toolbar !== false) {
addToolbar(settings.toolbar || defaultToolbar);
}
if (toolbars.length) {
return {
type: 'panel',
layout: 'stack',
classes: "toolbar-grp",
ariaRoot: true,
ariaRemember: true,
items: toolbars
};
}
} | javascript | function (editor, size) {
var toolbars = [], settings = editor.settings;
var addToolbar = function (items) {
if (items) {
toolbars.push(createToolbar(editor, items, size));
return true;
}
};
// Convert toolbar array to multiple options
if (Tools.isArray(settings.toolbar)) {
// Empty toolbar array is the same as a disabled toolbar
if (settings.toolbar.length === 0) {
return;
}
Tools.each(settings.toolbar, function (toolbar, i) {
settings["toolbar" + (i + 1)] = toolbar;
});
delete settings.toolbar;
}
// Generate toolbar<n>
for (var i = 1; i < 10; i++) {
if (!addToolbar(settings["toolbar" + i])) {
break;
}
}
// Generate toolbar or default toolbar unless it's disabled
if (!toolbars.length && settings.toolbar !== false) {
addToolbar(settings.toolbar || defaultToolbar);
}
if (toolbars.length) {
return {
type: 'panel',
layout: 'stack',
classes: "toolbar-grp",
ariaRoot: true,
ariaRemember: true,
items: toolbars
};
}
} | [
"function",
"(",
"editor",
",",
"size",
")",
"{",
"var",
"toolbars",
"=",
"[",
"]",
",",
"settings",
"=",
"editor",
".",
"settings",
";",
"var",
"addToolbar",
"=",
"function",
"(",
"items",
")",
"{",
"if",
"(",
"items",
")",
"{",
"toolbars",
".",
"push",
"(",
"createToolbar",
"(",
"editor",
",",
"items",
",",
"size",
")",
")",
";",
"return",
"true",
";",
"}",
"}",
";",
"// Convert toolbar array to multiple options",
"if",
"(",
"Tools",
".",
"isArray",
"(",
"settings",
".",
"toolbar",
")",
")",
"{",
"// Empty toolbar array is the same as a disabled toolbar",
"if",
"(",
"settings",
".",
"toolbar",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"Tools",
".",
"each",
"(",
"settings",
".",
"toolbar",
",",
"function",
"(",
"toolbar",
",",
"i",
")",
"{",
"settings",
"[",
"\"toolbar\"",
"+",
"(",
"i",
"+",
"1",
")",
"]",
"=",
"toolbar",
";",
"}",
")",
";",
"delete",
"settings",
".",
"toolbar",
";",
"}",
"// Generate toolbar<n>",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"addToolbar",
"(",
"settings",
"[",
"\"toolbar\"",
"+",
"i",
"]",
")",
")",
"{",
"break",
";",
"}",
"}",
"// Generate toolbar or default toolbar unless it's disabled",
"if",
"(",
"!",
"toolbars",
".",
"length",
"&&",
"settings",
".",
"toolbar",
"!==",
"false",
")",
"{",
"addToolbar",
"(",
"settings",
".",
"toolbar",
"||",
"defaultToolbar",
")",
";",
"}",
"if",
"(",
"toolbars",
".",
"length",
")",
"{",
"return",
"{",
"type",
":",
"'panel'",
",",
"layout",
":",
"'stack'",
",",
"classes",
":",
"\"toolbar-grp\"",
",",
"ariaRoot",
":",
"true",
",",
"ariaRemember",
":",
"true",
",",
"items",
":",
"toolbars",
"}",
";",
"}",
"}"
] | Creates the toolbars from config and returns a toolbar array.
@param {String} size Optional toolbar item size.
@return {Array} Array with toolbars. | [
"Creates",
"the",
"toolbars",
"from",
"config",
"and",
"returns",
"a",
"toolbar",
"array",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L50142-L50188 |
|
48,348 | sadiqhabib/tinymce-dist | tinymce.full.js | function (rng) {
var bookmark = {};
var setupEndPoint = function (start) {
var offsetNode, container, offset;
container = rng[start ? 'startContainer' : 'endContainer'];
offset = rng[start ? 'startOffset' : 'endOffset'];
if (container.nodeType === 1) {
offsetNode = DOM.create('span', { 'data-mce-type': 'bookmark' });
if (container.hasChildNodes()) {
offset = Math.min(offset, container.childNodes.length - 1);
if (start) {
container.insertBefore(offsetNode, container.childNodes[offset]);
} else {
DOM.insertAfter(offsetNode, container.childNodes[offset]);
}
} else {
container.appendChild(offsetNode);
}
container = offsetNode;
offset = 0;
}
bookmark[start ? 'startContainer' : 'endContainer'] = container;
bookmark[start ? 'startOffset' : 'endOffset'] = offset;
};
setupEndPoint(true);
if (!rng.collapsed) {
setupEndPoint();
}
return bookmark;
} | javascript | function (rng) {
var bookmark = {};
var setupEndPoint = function (start) {
var offsetNode, container, offset;
container = rng[start ? 'startContainer' : 'endContainer'];
offset = rng[start ? 'startOffset' : 'endOffset'];
if (container.nodeType === 1) {
offsetNode = DOM.create('span', { 'data-mce-type': 'bookmark' });
if (container.hasChildNodes()) {
offset = Math.min(offset, container.childNodes.length - 1);
if (start) {
container.insertBefore(offsetNode, container.childNodes[offset]);
} else {
DOM.insertAfter(offsetNode, container.childNodes[offset]);
}
} else {
container.appendChild(offsetNode);
}
container = offsetNode;
offset = 0;
}
bookmark[start ? 'startContainer' : 'endContainer'] = container;
bookmark[start ? 'startOffset' : 'endOffset'] = offset;
};
setupEndPoint(true);
if (!rng.collapsed) {
setupEndPoint();
}
return bookmark;
} | [
"function",
"(",
"rng",
")",
"{",
"var",
"bookmark",
"=",
"{",
"}",
";",
"var",
"setupEndPoint",
"=",
"function",
"(",
"start",
")",
"{",
"var",
"offsetNode",
",",
"container",
",",
"offset",
";",
"container",
"=",
"rng",
"[",
"start",
"?",
"'startContainer'",
":",
"'endContainer'",
"]",
";",
"offset",
"=",
"rng",
"[",
"start",
"?",
"'startOffset'",
":",
"'endOffset'",
"]",
";",
"if",
"(",
"container",
".",
"nodeType",
"===",
"1",
")",
"{",
"offsetNode",
"=",
"DOM",
".",
"create",
"(",
"'span'",
",",
"{",
"'data-mce-type'",
":",
"'bookmark'",
"}",
")",
";",
"if",
"(",
"container",
".",
"hasChildNodes",
"(",
")",
")",
"{",
"offset",
"=",
"Math",
".",
"min",
"(",
"offset",
",",
"container",
".",
"childNodes",
".",
"length",
"-",
"1",
")",
";",
"if",
"(",
"start",
")",
"{",
"container",
".",
"insertBefore",
"(",
"offsetNode",
",",
"container",
".",
"childNodes",
"[",
"offset",
"]",
")",
";",
"}",
"else",
"{",
"DOM",
".",
"insertAfter",
"(",
"offsetNode",
",",
"container",
".",
"childNodes",
"[",
"offset",
"]",
")",
";",
"}",
"}",
"else",
"{",
"container",
".",
"appendChild",
"(",
"offsetNode",
")",
";",
"}",
"container",
"=",
"offsetNode",
";",
"offset",
"=",
"0",
";",
"}",
"bookmark",
"[",
"start",
"?",
"'startContainer'",
":",
"'endContainer'",
"]",
"=",
"container",
";",
"bookmark",
"[",
"start",
"?",
"'startOffset'",
":",
"'endOffset'",
"]",
"=",
"offset",
";",
"}",
";",
"setupEndPoint",
"(",
"true",
")",
";",
"if",
"(",
"!",
"rng",
".",
"collapsed",
")",
"{",
"setupEndPoint",
"(",
")",
";",
"}",
"return",
"bookmark",
";",
"}"
] | Returns a range bookmark. This will convert indexed bookmarks into temporary span elements with
index 0 so that they can be restored properly after the DOM has been modified. Text bookmarks will not have spans
added to them since they can be restored after a dom operation.
So this: <p><b>|</b><b>|</b></p>
becomes: <p><b><span data-mce-type="bookmark">|</span></b><b data-mce-type="bookmark">|</span></b></p>
@param {DOMRange} rng DOM Range to get bookmark on.
@return {Object} Bookmark object. | [
"Returns",
"a",
"range",
"bookmark",
".",
"This",
"will",
"convert",
"indexed",
"bookmarks",
"into",
"temporary",
"span",
"elements",
"with",
"index",
"0",
"so",
"that",
"they",
"can",
"be",
"restored",
"properly",
"after",
"the",
"DOM",
"has",
"been",
"modified",
".",
"Text",
"bookmarks",
"will",
"not",
"have",
"spans",
"added",
"to",
"them",
"since",
"they",
"can",
"be",
"restored",
"after",
"a",
"dom",
"operation",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L52414-L52453 |
|
48,349 | sadiqhabib/tinymce-dist | tinymce.full.js | genReplacer | function genReplacer(nodeName) {
var makeReplacementNode;
if (typeof nodeName != 'function') {
var stencilNode = nodeName.nodeType ? nodeName : doc.createElement(nodeName);
makeReplacementNode = function (fill, matchIndex) {
var clone = stencilNode.cloneNode(false);
clone.setAttribute('data-mce-index', matchIndex);
if (fill) {
clone.appendChild(doc.createTextNode(fill));
}
return clone;
};
} else {
makeReplacementNode = nodeName;
}
return function (range) {
var before, after, parentNode, startNode = range.startNode,
endNode = range.endNode, matchIndex = range.matchIndex;
if (startNode === endNode) {
var node = startNode;
parentNode = node.parentNode;
if (range.startNodeIndex > 0) {
// Add `before` text node (before the match)
before = doc.createTextNode(node.data.substring(0, range.startNodeIndex));
parentNode.insertBefore(before, node);
}
// Create the replacement node:
var el = makeReplacementNode(range.match[0], matchIndex);
parentNode.insertBefore(el, node);
if (range.endNodeIndex < node.length) {
// Add `after` text node (after the match)
after = doc.createTextNode(node.data.substring(range.endNodeIndex));
parentNode.insertBefore(after, node);
}
node.parentNode.removeChild(node);
return el;
}
// Replace startNode -> [innerNodes...] -> endNode (in that order)
before = doc.createTextNode(startNode.data.substring(0, range.startNodeIndex));
after = doc.createTextNode(endNode.data.substring(range.endNodeIndex));
var elA = makeReplacementNode(startNode.data.substring(range.startNodeIndex), matchIndex);
var innerEls = [];
for (var i = 0, l = range.innerNodes.length; i < l; ++i) {
var innerNode = range.innerNodes[i];
var innerEl = makeReplacementNode(innerNode.data, matchIndex);
innerNode.parentNode.replaceChild(innerEl, innerNode);
innerEls.push(innerEl);
}
var elB = makeReplacementNode(endNode.data.substring(0, range.endNodeIndex), matchIndex);
parentNode = startNode.parentNode;
parentNode.insertBefore(before, startNode);
parentNode.insertBefore(elA, startNode);
parentNode.removeChild(startNode);
parentNode = endNode.parentNode;
parentNode.insertBefore(elB, endNode);
parentNode.insertBefore(after, endNode);
parentNode.removeChild(endNode);
return elB;
};
} | javascript | function genReplacer(nodeName) {
var makeReplacementNode;
if (typeof nodeName != 'function') {
var stencilNode = nodeName.nodeType ? nodeName : doc.createElement(nodeName);
makeReplacementNode = function (fill, matchIndex) {
var clone = stencilNode.cloneNode(false);
clone.setAttribute('data-mce-index', matchIndex);
if (fill) {
clone.appendChild(doc.createTextNode(fill));
}
return clone;
};
} else {
makeReplacementNode = nodeName;
}
return function (range) {
var before, after, parentNode, startNode = range.startNode,
endNode = range.endNode, matchIndex = range.matchIndex;
if (startNode === endNode) {
var node = startNode;
parentNode = node.parentNode;
if (range.startNodeIndex > 0) {
// Add `before` text node (before the match)
before = doc.createTextNode(node.data.substring(0, range.startNodeIndex));
parentNode.insertBefore(before, node);
}
// Create the replacement node:
var el = makeReplacementNode(range.match[0], matchIndex);
parentNode.insertBefore(el, node);
if (range.endNodeIndex < node.length) {
// Add `after` text node (after the match)
after = doc.createTextNode(node.data.substring(range.endNodeIndex));
parentNode.insertBefore(after, node);
}
node.parentNode.removeChild(node);
return el;
}
// Replace startNode -> [innerNodes...] -> endNode (in that order)
before = doc.createTextNode(startNode.data.substring(0, range.startNodeIndex));
after = doc.createTextNode(endNode.data.substring(range.endNodeIndex));
var elA = makeReplacementNode(startNode.data.substring(range.startNodeIndex), matchIndex);
var innerEls = [];
for (var i = 0, l = range.innerNodes.length; i < l; ++i) {
var innerNode = range.innerNodes[i];
var innerEl = makeReplacementNode(innerNode.data, matchIndex);
innerNode.parentNode.replaceChild(innerEl, innerNode);
innerEls.push(innerEl);
}
var elB = makeReplacementNode(endNode.data.substring(0, range.endNodeIndex), matchIndex);
parentNode = startNode.parentNode;
parentNode.insertBefore(before, startNode);
parentNode.insertBefore(elA, startNode);
parentNode.removeChild(startNode);
parentNode = endNode.parentNode;
parentNode.insertBefore(elB, endNode);
parentNode.insertBefore(after, endNode);
parentNode.removeChild(endNode);
return elB;
};
} | [
"function",
"genReplacer",
"(",
"nodeName",
")",
"{",
"var",
"makeReplacementNode",
";",
"if",
"(",
"typeof",
"nodeName",
"!=",
"'function'",
")",
"{",
"var",
"stencilNode",
"=",
"nodeName",
".",
"nodeType",
"?",
"nodeName",
":",
"doc",
".",
"createElement",
"(",
"nodeName",
")",
";",
"makeReplacementNode",
"=",
"function",
"(",
"fill",
",",
"matchIndex",
")",
"{",
"var",
"clone",
"=",
"stencilNode",
".",
"cloneNode",
"(",
"false",
")",
";",
"clone",
".",
"setAttribute",
"(",
"'data-mce-index'",
",",
"matchIndex",
")",
";",
"if",
"(",
"fill",
")",
"{",
"clone",
".",
"appendChild",
"(",
"doc",
".",
"createTextNode",
"(",
"fill",
")",
")",
";",
"}",
"return",
"clone",
";",
"}",
";",
"}",
"else",
"{",
"makeReplacementNode",
"=",
"nodeName",
";",
"}",
"return",
"function",
"(",
"range",
")",
"{",
"var",
"before",
",",
"after",
",",
"parentNode",
",",
"startNode",
"=",
"range",
".",
"startNode",
",",
"endNode",
"=",
"range",
".",
"endNode",
",",
"matchIndex",
"=",
"range",
".",
"matchIndex",
";",
"if",
"(",
"startNode",
"===",
"endNode",
")",
"{",
"var",
"node",
"=",
"startNode",
";",
"parentNode",
"=",
"node",
".",
"parentNode",
";",
"if",
"(",
"range",
".",
"startNodeIndex",
">",
"0",
")",
"{",
"// Add `before` text node (before the match)",
"before",
"=",
"doc",
".",
"createTextNode",
"(",
"node",
".",
"data",
".",
"substring",
"(",
"0",
",",
"range",
".",
"startNodeIndex",
")",
")",
";",
"parentNode",
".",
"insertBefore",
"(",
"before",
",",
"node",
")",
";",
"}",
"// Create the replacement node:",
"var",
"el",
"=",
"makeReplacementNode",
"(",
"range",
".",
"match",
"[",
"0",
"]",
",",
"matchIndex",
")",
";",
"parentNode",
".",
"insertBefore",
"(",
"el",
",",
"node",
")",
";",
"if",
"(",
"range",
".",
"endNodeIndex",
"<",
"node",
".",
"length",
")",
"{",
"// Add `after` text node (after the match)",
"after",
"=",
"doc",
".",
"createTextNode",
"(",
"node",
".",
"data",
".",
"substring",
"(",
"range",
".",
"endNodeIndex",
")",
")",
";",
"parentNode",
".",
"insertBefore",
"(",
"after",
",",
"node",
")",
";",
"}",
"node",
".",
"parentNode",
".",
"removeChild",
"(",
"node",
")",
";",
"return",
"el",
";",
"}",
"// Replace startNode -> [innerNodes...] -> endNode (in that order)",
"before",
"=",
"doc",
".",
"createTextNode",
"(",
"startNode",
".",
"data",
".",
"substring",
"(",
"0",
",",
"range",
".",
"startNodeIndex",
")",
")",
";",
"after",
"=",
"doc",
".",
"createTextNode",
"(",
"endNode",
".",
"data",
".",
"substring",
"(",
"range",
".",
"endNodeIndex",
")",
")",
";",
"var",
"elA",
"=",
"makeReplacementNode",
"(",
"startNode",
".",
"data",
".",
"substring",
"(",
"range",
".",
"startNodeIndex",
")",
",",
"matchIndex",
")",
";",
"var",
"innerEls",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"range",
".",
"innerNodes",
".",
"length",
";",
"i",
"<",
"l",
";",
"++",
"i",
")",
"{",
"var",
"innerNode",
"=",
"range",
".",
"innerNodes",
"[",
"i",
"]",
";",
"var",
"innerEl",
"=",
"makeReplacementNode",
"(",
"innerNode",
".",
"data",
",",
"matchIndex",
")",
";",
"innerNode",
".",
"parentNode",
".",
"replaceChild",
"(",
"innerEl",
",",
"innerNode",
")",
";",
"innerEls",
".",
"push",
"(",
"innerEl",
")",
";",
"}",
"var",
"elB",
"=",
"makeReplacementNode",
"(",
"endNode",
".",
"data",
".",
"substring",
"(",
"0",
",",
"range",
".",
"endNodeIndex",
")",
",",
"matchIndex",
")",
";",
"parentNode",
"=",
"startNode",
".",
"parentNode",
";",
"parentNode",
".",
"insertBefore",
"(",
"before",
",",
"startNode",
")",
";",
"parentNode",
".",
"insertBefore",
"(",
"elA",
",",
"startNode",
")",
";",
"parentNode",
".",
"removeChild",
"(",
"startNode",
")",
";",
"parentNode",
"=",
"endNode",
".",
"parentNode",
";",
"parentNode",
".",
"insertBefore",
"(",
"elB",
",",
"endNode",
")",
";",
"parentNode",
".",
"insertBefore",
"(",
"after",
",",
"endNode",
")",
";",
"parentNode",
".",
"removeChild",
"(",
"endNode",
")",
";",
"return",
"elB",
";",
"}",
";",
"}"
] | Generates the actual replaceFn which splits up text nodes
and inserts the replacement element. | [
"Generates",
"the",
"actual",
"replaceFn",
"which",
"splits",
"up",
"text",
"nodes",
"and",
"inserts",
"the",
"replacement",
"element",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L57398-L57474 |
48,350 | sadiqhabib/tinymce-dist | tinymce.full.js | function(xs, f) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
f(x, i, xs);
}
} | javascript | function(xs, f) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
f(x, i, xs);
}
} | [
"function",
"(",
"xs",
",",
"f",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"xs",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"x",
"=",
"xs",
"[",
"i",
"]",
";",
"f",
"(",
"x",
",",
"i",
",",
"xs",
")",
";",
"}",
"}"
] | Unwound implementing other functions in terms of each. The code size is roughly the same, and it should allow for better optimisation. | [
"Unwound",
"implementing",
"other",
"functions",
"in",
"terms",
"of",
"each",
".",
"The",
"code",
"size",
"is",
"roughly",
"the",
"same",
"and",
"it",
"should",
"allow",
"for",
"better",
"optimisation",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L59208-L59213 |
|
48,351 | sadiqhabib/tinymce-dist | tinymce.full.js | function (scope, predicate) {
var result = [];
var dom = scope.dom();
var children = Arr.map(dom.childNodes, Element.fromDom);
Arr.each(children, function (x) {
if (predicate(x)) {
result = result.concat([ x ]);
}
result = result.concat(filterDescendants(x, predicate));
});
return result;
} | javascript | function (scope, predicate) {
var result = [];
var dom = scope.dom();
var children = Arr.map(dom.childNodes, Element.fromDom);
Arr.each(children, function (x) {
if (predicate(x)) {
result = result.concat([ x ]);
}
result = result.concat(filterDescendants(x, predicate));
});
return result;
} | [
"function",
"(",
"scope",
",",
"predicate",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"dom",
"=",
"scope",
".",
"dom",
"(",
")",
";",
"var",
"children",
"=",
"Arr",
".",
"map",
"(",
"dom",
".",
"childNodes",
",",
"Element",
".",
"fromDom",
")",
";",
"Arr",
".",
"each",
"(",
"children",
",",
"function",
"(",
"x",
")",
"{",
"if",
"(",
"predicate",
"(",
"x",
")",
")",
"{",
"result",
"=",
"result",
".",
"concat",
"(",
"[",
"x",
"]",
")",
";",
"}",
"result",
"=",
"result",
".",
"concat",
"(",
"filterDescendants",
"(",
"x",
",",
"predicate",
")",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] | inlined sugars PredicateFilter.descendants for file size | [
"inlined",
"sugars",
"PredicateFilter",
".",
"descendants",
"for",
"file",
"size"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L59643-L59655 |
|
48,352 | sadiqhabib/tinymce-dist | tinymce.full.js | fixTableCaretPos | function fixTableCaretPos() {
editor.on('KeyDown SetContent VisualAid', function () {
var last;
// Skip empty text nodes from the end
for (last = editor.getBody().lastChild; last; last = last.previousSibling) {
if (last.nodeType == 3) {
if (last.nodeValue.length > 0) {
break;
}
} else if (last.nodeType == 1 && (last.tagName == 'BR' || !last.getAttribute('data-mce-bogus'))) {
break;
}
}
if (last && last.nodeName == 'TABLE') {
if (editor.settings.forced_root_block) {
editor.dom.add(
editor.getBody(),
editor.settings.forced_root_block,
editor.settings.forced_root_block_attrs,
Env.ie && Env.ie < 10 ? ' ' : '<br data-mce-bogus="1" />'
);
} else {
editor.dom.add(editor.getBody(), 'br', { 'data-mce-bogus': '1' });
}
}
});
editor.on('PreProcess', function (o) {
var last = o.node.lastChild;
if (last && (last.nodeName == "BR" || (last.childNodes.length == 1 &&
(last.firstChild.nodeName == 'BR' || last.firstChild.nodeValue == '\u00a0'))) &&
last.previousSibling && last.previousSibling.nodeName == "TABLE") {
editor.dom.remove(last);
}
});
} | javascript | function fixTableCaretPos() {
editor.on('KeyDown SetContent VisualAid', function () {
var last;
// Skip empty text nodes from the end
for (last = editor.getBody().lastChild; last; last = last.previousSibling) {
if (last.nodeType == 3) {
if (last.nodeValue.length > 0) {
break;
}
} else if (last.nodeType == 1 && (last.tagName == 'BR' || !last.getAttribute('data-mce-bogus'))) {
break;
}
}
if (last && last.nodeName == 'TABLE') {
if (editor.settings.forced_root_block) {
editor.dom.add(
editor.getBody(),
editor.settings.forced_root_block,
editor.settings.forced_root_block_attrs,
Env.ie && Env.ie < 10 ? ' ' : '<br data-mce-bogus="1" />'
);
} else {
editor.dom.add(editor.getBody(), 'br', { 'data-mce-bogus': '1' });
}
}
});
editor.on('PreProcess', function (o) {
var last = o.node.lastChild;
if (last && (last.nodeName == "BR" || (last.childNodes.length == 1 &&
(last.firstChild.nodeName == 'BR' || last.firstChild.nodeValue == '\u00a0'))) &&
last.previousSibling && last.previousSibling.nodeName == "TABLE") {
editor.dom.remove(last);
}
});
} | [
"function",
"fixTableCaretPos",
"(",
")",
"{",
"editor",
".",
"on",
"(",
"'KeyDown SetContent VisualAid'",
",",
"function",
"(",
")",
"{",
"var",
"last",
";",
"// Skip empty text nodes from the end",
"for",
"(",
"last",
"=",
"editor",
".",
"getBody",
"(",
")",
".",
"lastChild",
";",
"last",
";",
"last",
"=",
"last",
".",
"previousSibling",
")",
"{",
"if",
"(",
"last",
".",
"nodeType",
"==",
"3",
")",
"{",
"if",
"(",
"last",
".",
"nodeValue",
".",
"length",
">",
"0",
")",
"{",
"break",
";",
"}",
"}",
"else",
"if",
"(",
"last",
".",
"nodeType",
"==",
"1",
"&&",
"(",
"last",
".",
"tagName",
"==",
"'BR'",
"||",
"!",
"last",
".",
"getAttribute",
"(",
"'data-mce-bogus'",
")",
")",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"last",
"&&",
"last",
".",
"nodeName",
"==",
"'TABLE'",
")",
"{",
"if",
"(",
"editor",
".",
"settings",
".",
"forced_root_block",
")",
"{",
"editor",
".",
"dom",
".",
"add",
"(",
"editor",
".",
"getBody",
"(",
")",
",",
"editor",
".",
"settings",
".",
"forced_root_block",
",",
"editor",
".",
"settings",
".",
"forced_root_block_attrs",
",",
"Env",
".",
"ie",
"&&",
"Env",
".",
"ie",
"<",
"10",
"?",
"' '",
":",
"'<br data-mce-bogus=\"1\" />'",
")",
";",
"}",
"else",
"{",
"editor",
".",
"dom",
".",
"add",
"(",
"editor",
".",
"getBody",
"(",
")",
",",
"'br'",
",",
"{",
"'data-mce-bogus'",
":",
"'1'",
"}",
")",
";",
"}",
"}",
"}",
")",
";",
"editor",
".",
"on",
"(",
"'PreProcess'",
",",
"function",
"(",
"o",
")",
"{",
"var",
"last",
"=",
"o",
".",
"node",
".",
"lastChild",
";",
"if",
"(",
"last",
"&&",
"(",
"last",
".",
"nodeName",
"==",
"\"BR\"",
"||",
"(",
"last",
".",
"childNodes",
".",
"length",
"==",
"1",
"&&",
"(",
"last",
".",
"firstChild",
".",
"nodeName",
"==",
"'BR'",
"||",
"last",
".",
"firstChild",
".",
"nodeValue",
"==",
"'\\u00a0'",
")",
")",
")",
"&&",
"last",
".",
"previousSibling",
"&&",
"last",
".",
"previousSibling",
".",
"nodeName",
"==",
"\"TABLE\"",
")",
"{",
"editor",
".",
"dom",
".",
"remove",
"(",
"last",
")",
";",
"}",
"}",
")",
";",
"}"
] | Fixes an issue on Gecko where it's impossible to place the caret behind a table This fix will force a paragraph element after the table but only when the forced_root_block setting is enabled | [
"Fixes",
"an",
"issue",
"on",
"Gecko",
"where",
"it",
"s",
"impossible",
"to",
"place",
"the",
"caret",
"behind",
"a",
"table",
"This",
"fix",
"will",
"force",
"a",
"paragraph",
"element",
"after",
"the",
"table",
"but",
"only",
"when",
"the",
"forced_root_block",
"setting",
"is",
"enabled"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L64545-L64583 |
48,353 | sadiqhabib/tinymce-dist | tinymce.full.js | fixTableCellSelection | function fixTableCellSelection() {
function tableCellSelected(ed, rng, n, currentCell) {
// The decision of when a table cell is selected is somewhat involved. The fact that this code is
// required is actually a pointer to the root cause of this bug. A cell is selected when the start
// and end offsets are 0, the start container is a text, and the selection node is either a TR (most cases)
// or the parent of the table (in the case of the selection containing the last cell of a table).
var TEXT_NODE = 3, table = ed.dom.getParent(rng.startContainer, 'TABLE');
var tableParent, allOfCellSelected, tableCellSelection;
if (table) {
tableParent = table.parentNode;
}
allOfCellSelected = rng.startContainer.nodeType == TEXT_NODE &&
rng.startOffset === 0 &&
rng.endOffset === 0 &&
currentCell &&
(n.nodeName == "TR" || n == tableParent);
tableCellSelection = (n.nodeName == "TD" || n.nodeName == "TH") && !currentCell;
return allOfCellSelected || tableCellSelection;
}
function fixSelection() {
var rng = editor.selection.getRng();
var n = editor.selection.getNode();
var currentCell = editor.dom.getParent(rng.startContainer, 'TD,TH');
if (!tableCellSelected(editor, rng, n, currentCell)) {
return;
}
if (!currentCell) {
currentCell = n;
}
// Get the very last node inside the table cell
var end = currentCell.lastChild;
while (end.lastChild) {
end = end.lastChild;
}
// Select the entire table cell. Nothing outside of the table cell should be selected.
if (end.nodeType == 3) {
rng.setEnd(end, end.data.length);
editor.selection.setRng(rng);
}
}
editor.on('KeyDown', function () {
fixSelection();
});
editor.on('MouseDown', function (e) {
if (e.button != 2) {
fixSelection();
}
});
} | javascript | function fixTableCellSelection() {
function tableCellSelected(ed, rng, n, currentCell) {
// The decision of when a table cell is selected is somewhat involved. The fact that this code is
// required is actually a pointer to the root cause of this bug. A cell is selected when the start
// and end offsets are 0, the start container is a text, and the selection node is either a TR (most cases)
// or the parent of the table (in the case of the selection containing the last cell of a table).
var TEXT_NODE = 3, table = ed.dom.getParent(rng.startContainer, 'TABLE');
var tableParent, allOfCellSelected, tableCellSelection;
if (table) {
tableParent = table.parentNode;
}
allOfCellSelected = rng.startContainer.nodeType == TEXT_NODE &&
rng.startOffset === 0 &&
rng.endOffset === 0 &&
currentCell &&
(n.nodeName == "TR" || n == tableParent);
tableCellSelection = (n.nodeName == "TD" || n.nodeName == "TH") && !currentCell;
return allOfCellSelected || tableCellSelection;
}
function fixSelection() {
var rng = editor.selection.getRng();
var n = editor.selection.getNode();
var currentCell = editor.dom.getParent(rng.startContainer, 'TD,TH');
if (!tableCellSelected(editor, rng, n, currentCell)) {
return;
}
if (!currentCell) {
currentCell = n;
}
// Get the very last node inside the table cell
var end = currentCell.lastChild;
while (end.lastChild) {
end = end.lastChild;
}
// Select the entire table cell. Nothing outside of the table cell should be selected.
if (end.nodeType == 3) {
rng.setEnd(end, end.data.length);
editor.selection.setRng(rng);
}
}
editor.on('KeyDown', function () {
fixSelection();
});
editor.on('MouseDown', function (e) {
if (e.button != 2) {
fixSelection();
}
});
} | [
"function",
"fixTableCellSelection",
"(",
")",
"{",
"function",
"tableCellSelected",
"(",
"ed",
",",
"rng",
",",
"n",
",",
"currentCell",
")",
"{",
"// The decision of when a table cell is selected is somewhat involved. The fact that this code is",
"// required is actually a pointer to the root cause of this bug. A cell is selected when the start",
"// and end offsets are 0, the start container is a text, and the selection node is either a TR (most cases)",
"// or the parent of the table (in the case of the selection containing the last cell of a table).",
"var",
"TEXT_NODE",
"=",
"3",
",",
"table",
"=",
"ed",
".",
"dom",
".",
"getParent",
"(",
"rng",
".",
"startContainer",
",",
"'TABLE'",
")",
";",
"var",
"tableParent",
",",
"allOfCellSelected",
",",
"tableCellSelection",
";",
"if",
"(",
"table",
")",
"{",
"tableParent",
"=",
"table",
".",
"parentNode",
";",
"}",
"allOfCellSelected",
"=",
"rng",
".",
"startContainer",
".",
"nodeType",
"==",
"TEXT_NODE",
"&&",
"rng",
".",
"startOffset",
"===",
"0",
"&&",
"rng",
".",
"endOffset",
"===",
"0",
"&&",
"currentCell",
"&&",
"(",
"n",
".",
"nodeName",
"==",
"\"TR\"",
"||",
"n",
"==",
"tableParent",
")",
";",
"tableCellSelection",
"=",
"(",
"n",
".",
"nodeName",
"==",
"\"TD\"",
"||",
"n",
".",
"nodeName",
"==",
"\"TH\"",
")",
"&&",
"!",
"currentCell",
";",
"return",
"allOfCellSelected",
"||",
"tableCellSelection",
";",
"}",
"function",
"fixSelection",
"(",
")",
"{",
"var",
"rng",
"=",
"editor",
".",
"selection",
".",
"getRng",
"(",
")",
";",
"var",
"n",
"=",
"editor",
".",
"selection",
".",
"getNode",
"(",
")",
";",
"var",
"currentCell",
"=",
"editor",
".",
"dom",
".",
"getParent",
"(",
"rng",
".",
"startContainer",
",",
"'TD,TH'",
")",
";",
"if",
"(",
"!",
"tableCellSelected",
"(",
"editor",
",",
"rng",
",",
"n",
",",
"currentCell",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"currentCell",
")",
"{",
"currentCell",
"=",
"n",
";",
"}",
"// Get the very last node inside the table cell",
"var",
"end",
"=",
"currentCell",
".",
"lastChild",
";",
"while",
"(",
"end",
".",
"lastChild",
")",
"{",
"end",
"=",
"end",
".",
"lastChild",
";",
"}",
"// Select the entire table cell. Nothing outside of the table cell should be selected.",
"if",
"(",
"end",
".",
"nodeType",
"==",
"3",
")",
"{",
"rng",
".",
"setEnd",
"(",
"end",
",",
"end",
".",
"data",
".",
"length",
")",
";",
"editor",
".",
"selection",
".",
"setRng",
"(",
"rng",
")",
";",
"}",
"}",
"editor",
".",
"on",
"(",
"'KeyDown'",
",",
"function",
"(",
")",
"{",
"fixSelection",
"(",
")",
";",
"}",
")",
";",
"editor",
".",
"on",
"(",
"'MouseDown'",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"button",
"!=",
"2",
")",
"{",
"fixSelection",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | this nasty hack is here to work around some WebKit selection bugs. | [
"this",
"nasty",
"hack",
"is",
"here",
"to",
"work",
"around",
"some",
"WebKit",
"selection",
"bugs",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L64586-L64645 |
48,354 | sadiqhabib/tinymce-dist | tinymce.full.js | deleteTable | function deleteTable() {
function placeCaretInCell(cell) {
editor.selection.select(cell, true);
editor.selection.collapse(true);
}
function clearCell(cell) {
editor.$(cell).empty();
Utils.paddCell(cell);
}
editor.on('keydown', function (e) {
if ((e.keyCode == VK.DELETE || e.keyCode == VK.BACKSPACE) && !e.isDefaultPrevented()) {
var table, tableCells, selectedTableCells, cell;
table = editor.dom.getParent(editor.selection.getStart(), 'table');
if (table) {
tableCells = editor.dom.select('td,th', table);
selectedTableCells = Tools.grep(tableCells, function (cell) {
return !!editor.dom.getAttrib(cell, 'data-mce-selected');
});
if (selectedTableCells.length === 0) {
// If caret is within an empty table cell then empty it for real
cell = editor.dom.getParent(editor.selection.getStart(), 'td,th');
if (editor.selection.isCollapsed() && cell && editor.dom.isEmpty(cell)) {
e.preventDefault();
clearCell(cell);
placeCaretInCell(cell);
}
return;
}
e.preventDefault();
editor.undoManager.transact(function () {
if (tableCells.length == selectedTableCells.length) {
editor.execCommand('mceTableDelete');
} else {
Tools.each(selectedTableCells, clearCell);
placeCaretInCell(selectedTableCells[0]);
}
});
}
}
});
} | javascript | function deleteTable() {
function placeCaretInCell(cell) {
editor.selection.select(cell, true);
editor.selection.collapse(true);
}
function clearCell(cell) {
editor.$(cell).empty();
Utils.paddCell(cell);
}
editor.on('keydown', function (e) {
if ((e.keyCode == VK.DELETE || e.keyCode == VK.BACKSPACE) && !e.isDefaultPrevented()) {
var table, tableCells, selectedTableCells, cell;
table = editor.dom.getParent(editor.selection.getStart(), 'table');
if (table) {
tableCells = editor.dom.select('td,th', table);
selectedTableCells = Tools.grep(tableCells, function (cell) {
return !!editor.dom.getAttrib(cell, 'data-mce-selected');
});
if (selectedTableCells.length === 0) {
// If caret is within an empty table cell then empty it for real
cell = editor.dom.getParent(editor.selection.getStart(), 'td,th');
if (editor.selection.isCollapsed() && cell && editor.dom.isEmpty(cell)) {
e.preventDefault();
clearCell(cell);
placeCaretInCell(cell);
}
return;
}
e.preventDefault();
editor.undoManager.transact(function () {
if (tableCells.length == selectedTableCells.length) {
editor.execCommand('mceTableDelete');
} else {
Tools.each(selectedTableCells, clearCell);
placeCaretInCell(selectedTableCells[0]);
}
});
}
}
});
} | [
"function",
"deleteTable",
"(",
")",
"{",
"function",
"placeCaretInCell",
"(",
"cell",
")",
"{",
"editor",
".",
"selection",
".",
"select",
"(",
"cell",
",",
"true",
")",
";",
"editor",
".",
"selection",
".",
"collapse",
"(",
"true",
")",
";",
"}",
"function",
"clearCell",
"(",
"cell",
")",
"{",
"editor",
".",
"$",
"(",
"cell",
")",
".",
"empty",
"(",
")",
";",
"Utils",
".",
"paddCell",
"(",
"cell",
")",
";",
"}",
"editor",
".",
"on",
"(",
"'keydown'",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"(",
"e",
".",
"keyCode",
"==",
"VK",
".",
"DELETE",
"||",
"e",
".",
"keyCode",
"==",
"VK",
".",
"BACKSPACE",
")",
"&&",
"!",
"e",
".",
"isDefaultPrevented",
"(",
")",
")",
"{",
"var",
"table",
",",
"tableCells",
",",
"selectedTableCells",
",",
"cell",
";",
"table",
"=",
"editor",
".",
"dom",
".",
"getParent",
"(",
"editor",
".",
"selection",
".",
"getStart",
"(",
")",
",",
"'table'",
")",
";",
"if",
"(",
"table",
")",
"{",
"tableCells",
"=",
"editor",
".",
"dom",
".",
"select",
"(",
"'td,th'",
",",
"table",
")",
";",
"selectedTableCells",
"=",
"Tools",
".",
"grep",
"(",
"tableCells",
",",
"function",
"(",
"cell",
")",
"{",
"return",
"!",
"!",
"editor",
".",
"dom",
".",
"getAttrib",
"(",
"cell",
",",
"'data-mce-selected'",
")",
";",
"}",
")",
";",
"if",
"(",
"selectedTableCells",
".",
"length",
"===",
"0",
")",
"{",
"// If caret is within an empty table cell then empty it for real",
"cell",
"=",
"editor",
".",
"dom",
".",
"getParent",
"(",
"editor",
".",
"selection",
".",
"getStart",
"(",
")",
",",
"'td,th'",
")",
";",
"if",
"(",
"editor",
".",
"selection",
".",
"isCollapsed",
"(",
")",
"&&",
"cell",
"&&",
"editor",
".",
"dom",
".",
"isEmpty",
"(",
"cell",
")",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"clearCell",
"(",
"cell",
")",
";",
"placeCaretInCell",
"(",
"cell",
")",
";",
"}",
"return",
";",
"}",
"e",
".",
"preventDefault",
"(",
")",
";",
"editor",
".",
"undoManager",
".",
"transact",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"tableCells",
".",
"length",
"==",
"selectedTableCells",
".",
"length",
")",
"{",
"editor",
".",
"execCommand",
"(",
"'mceTableDelete'",
")",
";",
"}",
"else",
"{",
"Tools",
".",
"each",
"(",
"selectedTableCells",
",",
"clearCell",
")",
";",
"placeCaretInCell",
"(",
"selectedTableCells",
"[",
"0",
"]",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Delete table if all cells are selected. | [
"Delete",
"table",
"if",
"all",
"cells",
"are",
"selected",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L64650-L64697 |
48,355 | sadiqhabib/tinymce-dist | tinymce.full.js | styleTDTH | function styleTDTH(elm, name, value) {
if (elm.tagName === "TD" || elm.tagName === "TH") {
dom.setStyle(elm, name, value);
} else {
if (elm.children) {
for (var i = 0; i < elm.children.length; i++) {
styleTDTH(elm.children[i], name, value);
}
}
}
} | javascript | function styleTDTH(elm, name, value) {
if (elm.tagName === "TD" || elm.tagName === "TH") {
dom.setStyle(elm, name, value);
} else {
if (elm.children) {
for (var i = 0; i < elm.children.length; i++) {
styleTDTH(elm.children[i], name, value);
}
}
}
} | [
"function",
"styleTDTH",
"(",
"elm",
",",
"name",
",",
"value",
")",
"{",
"if",
"(",
"elm",
".",
"tagName",
"===",
"\"TD\"",
"||",
"elm",
".",
"tagName",
"===",
"\"TH\"",
")",
"{",
"dom",
".",
"setStyle",
"(",
"elm",
",",
"name",
",",
"value",
")",
";",
"}",
"else",
"{",
"if",
"(",
"elm",
".",
"children",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"elm",
".",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"styleTDTH",
"(",
"elm",
".",
"children",
"[",
"i",
"]",
",",
"name",
",",
"value",
")",
";",
"}",
"}",
"}",
"}"
] | Explore the layers of the table till we find the first layer of tds or ths | [
"Explore",
"the",
"layers",
"of",
"the",
"table",
"till",
"we",
"find",
"the",
"first",
"layer",
"of",
"tds",
"or",
"ths"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L65261-L65271 |
48,356 | sadiqhabib/tinymce-dist | tinymce.full.js | getTopEdge | function getTopEdge(index, row) {
return {
index: index,
y: editor.dom.getPos(row).y
};
} | javascript | function getTopEdge(index, row) {
return {
index: index,
y: editor.dom.getPos(row).y
};
} | [
"function",
"getTopEdge",
"(",
"index",
",",
"row",
")",
"{",
"return",
"{",
"index",
":",
"index",
",",
"y",
":",
"editor",
".",
"dom",
".",
"getPos",
"(",
"row",
")",
".",
"y",
"}",
";",
"}"
] | Get the absolute position's top edge. | [
"Get",
"the",
"absolute",
"position",
"s",
"top",
"edge",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L65987-L65992 |
48,357 | sadiqhabib/tinymce-dist | tinymce.full.js | getBottomEdge | function getBottomEdge(index, row) {
return {
index: index,
y: editor.dom.getPos(row).y + row.offsetHeight
};
} | javascript | function getBottomEdge(index, row) {
return {
index: index,
y: editor.dom.getPos(row).y + row.offsetHeight
};
} | [
"function",
"getBottomEdge",
"(",
"index",
",",
"row",
")",
"{",
"return",
"{",
"index",
":",
"index",
",",
"y",
":",
"editor",
".",
"dom",
".",
"getPos",
"(",
"row",
")",
".",
"y",
"+",
"row",
".",
"offsetHeight",
"}",
";",
"}"
] | Get the absolute position's bottom edge. | [
"Get",
"the",
"absolute",
"position",
"s",
"bottom",
"edge",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L65995-L66000 |
48,358 | sadiqhabib/tinymce-dist | tinymce.full.js | getLeftEdge | function getLeftEdge(index, cell) {
return {
index: index,
x: editor.dom.getPos(cell).x
};
} | javascript | function getLeftEdge(index, cell) {
return {
index: index,
x: editor.dom.getPos(cell).x
};
} | [
"function",
"getLeftEdge",
"(",
"index",
",",
"cell",
")",
"{",
"return",
"{",
"index",
":",
"index",
",",
"x",
":",
"editor",
".",
"dom",
".",
"getPos",
"(",
"cell",
")",
".",
"x",
"}",
";",
"}"
] | Get the absolute position's left edge. | [
"Get",
"the",
"absolute",
"position",
"s",
"left",
"edge",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66003-L66008 |
48,359 | sadiqhabib/tinymce-dist | tinymce.full.js | getRightEdge | function getRightEdge(index, cell) {
return {
index: index,
x: editor.dom.getPos(cell).x + cell.offsetWidth
};
} | javascript | function getRightEdge(index, cell) {
return {
index: index,
x: editor.dom.getPos(cell).x + cell.offsetWidth
};
} | [
"function",
"getRightEdge",
"(",
"index",
",",
"cell",
")",
"{",
"return",
"{",
"index",
":",
"index",
",",
"x",
":",
"editor",
".",
"dom",
".",
"getPos",
"(",
"cell",
")",
".",
"x",
"+",
"cell",
".",
"offsetWidth",
"}",
";",
"}"
] | Get the absolute position's right edge. | [
"Get",
"the",
"absolute",
"position",
"s",
"right",
"edge",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66011-L66016 |
48,360 | sadiqhabib/tinymce-dist | tinymce.full.js | clearBars | function clearBars() {
var bars = editor.dom.select('.' + RESIZE_BAR_CLASS, getBody());
Tools.each(bars, function (bar) {
editor.dom.remove(bar);
});
} | javascript | function clearBars() {
var bars = editor.dom.select('.' + RESIZE_BAR_CLASS, getBody());
Tools.each(bars, function (bar) {
editor.dom.remove(bar);
});
} | [
"function",
"clearBars",
"(",
")",
"{",
"var",
"bars",
"=",
"editor",
".",
"dom",
".",
"select",
"(",
"'.'",
"+",
"RESIZE_BAR_CLASS",
",",
"getBody",
"(",
")",
")",
";",
"Tools",
".",
"each",
"(",
"bars",
",",
"function",
"(",
"bar",
")",
"{",
"editor",
".",
"dom",
".",
"remove",
"(",
"bar",
")",
";",
"}",
")",
";",
"}"
] | Clear the bars. | [
"Clear",
"the",
"bars",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66086-L66091 |
48,361 | sadiqhabib/tinymce-dist | tinymce.full.js | generateBar | function generateBar(classToAdd, cursor, left, top, height, width, indexAttr, index) {
var bar = {
'data-mce-bogus': 'all',
'class': RESIZE_BAR_CLASS + ' ' + classToAdd,
'unselectable': 'on',
'data-mce-resize': false,
style: 'cursor: ' + cursor + '; ' +
'margin: 0; ' +
'padding: 0; ' +
'position: absolute; ' +
'left: ' + left + 'px; ' +
'top: ' + top + 'px; ' +
'height: ' + height + 'px; ' +
'width: ' + width + 'px; '
};
bar[indexAttr] = index;
return bar;
} | javascript | function generateBar(classToAdd, cursor, left, top, height, width, indexAttr, index) {
var bar = {
'data-mce-bogus': 'all',
'class': RESIZE_BAR_CLASS + ' ' + classToAdd,
'unselectable': 'on',
'data-mce-resize': false,
style: 'cursor: ' + cursor + '; ' +
'margin: 0; ' +
'padding: 0; ' +
'position: absolute; ' +
'left: ' + left + 'px; ' +
'top: ' + top + 'px; ' +
'height: ' + height + 'px; ' +
'width: ' + width + 'px; '
};
bar[indexAttr] = index;
return bar;
} | [
"function",
"generateBar",
"(",
"classToAdd",
",",
"cursor",
",",
"left",
",",
"top",
",",
"height",
",",
"width",
",",
"indexAttr",
",",
"index",
")",
"{",
"var",
"bar",
"=",
"{",
"'data-mce-bogus'",
":",
"'all'",
",",
"'class'",
":",
"RESIZE_BAR_CLASS",
"+",
"' '",
"+",
"classToAdd",
",",
"'unselectable'",
":",
"'on'",
",",
"'data-mce-resize'",
":",
"false",
",",
"style",
":",
"'cursor: '",
"+",
"cursor",
"+",
"'; '",
"+",
"'margin: 0; '",
"+",
"'padding: 0; '",
"+",
"'position: absolute; '",
"+",
"'left: '",
"+",
"left",
"+",
"'px; '",
"+",
"'top: '",
"+",
"top",
"+",
"'px; '",
"+",
"'height: '",
"+",
"height",
"+",
"'px; '",
"+",
"'width: '",
"+",
"width",
"+",
"'px; '",
"}",
";",
"bar",
"[",
"indexAttr",
"]",
"=",
"index",
";",
"return",
"bar",
";",
"}"
] | Generates a resize bar object for the editor to add. | [
"Generates",
"a",
"resize",
"bar",
"object",
"for",
"the",
"editor",
"to",
"add",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66100-L66119 |
48,362 | sadiqhabib/tinymce-dist | tinymce.full.js | drawRows | function drawRows(rowPositions, tableWidth, tablePosition) {
Tools.each(rowPositions, function (rowPosition) {
var left = tablePosition.x,
top = rowPosition.y - RESIZE_BAR_THICKNESS / 2,
height = RESIZE_BAR_THICKNESS,
width = tableWidth;
editor.dom.add(getBody(), 'div',
generateBar(RESIZE_BAR_ROW_CLASS, RESIZE_BAR_ROW_CURSOR_STYLE,
left, top, height, width, RESIZE_BAR_ROW_DATA_ATTRIBUTE, rowPosition.index));
});
} | javascript | function drawRows(rowPositions, tableWidth, tablePosition) {
Tools.each(rowPositions, function (rowPosition) {
var left = tablePosition.x,
top = rowPosition.y - RESIZE_BAR_THICKNESS / 2,
height = RESIZE_BAR_THICKNESS,
width = tableWidth;
editor.dom.add(getBody(), 'div',
generateBar(RESIZE_BAR_ROW_CLASS, RESIZE_BAR_ROW_CURSOR_STYLE,
left, top, height, width, RESIZE_BAR_ROW_DATA_ATTRIBUTE, rowPosition.index));
});
} | [
"function",
"drawRows",
"(",
"rowPositions",
",",
"tableWidth",
",",
"tablePosition",
")",
"{",
"Tools",
".",
"each",
"(",
"rowPositions",
",",
"function",
"(",
"rowPosition",
")",
"{",
"var",
"left",
"=",
"tablePosition",
".",
"x",
",",
"top",
"=",
"rowPosition",
".",
"y",
"-",
"RESIZE_BAR_THICKNESS",
"/",
"2",
",",
"height",
"=",
"RESIZE_BAR_THICKNESS",
",",
"width",
"=",
"tableWidth",
";",
"editor",
".",
"dom",
".",
"add",
"(",
"getBody",
"(",
")",
",",
"'div'",
",",
"generateBar",
"(",
"RESIZE_BAR_ROW_CLASS",
",",
"RESIZE_BAR_ROW_CURSOR_STYLE",
",",
"left",
",",
"top",
",",
"height",
",",
"width",
",",
"RESIZE_BAR_ROW_DATA_ATTRIBUTE",
",",
"rowPosition",
".",
"index",
")",
")",
";",
"}",
")",
";",
"}"
] | Draw the row bars over the row borders. | [
"Draw",
"the",
"row",
"bars",
"over",
"the",
"row",
"borders",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66122-L66133 |
48,363 | sadiqhabib/tinymce-dist | tinymce.full.js | drawCols | function drawCols(cellPositions, tableHeight, tablePosition) {
Tools.each(cellPositions, function (cellPosition) {
var left = cellPosition.x - RESIZE_BAR_THICKNESS / 2,
top = tablePosition.y,
height = tableHeight,
width = RESIZE_BAR_THICKNESS;
editor.dom.add(getBody(), 'div',
generateBar(RESIZE_BAR_COL_CLASS, RESIZE_BAR_COL_CURSOR_STYLE,
left, top, height, width, RESIZE_BAR_COL_DATA_ATTRIBUTE, cellPosition.index));
});
} | javascript | function drawCols(cellPositions, tableHeight, tablePosition) {
Tools.each(cellPositions, function (cellPosition) {
var left = cellPosition.x - RESIZE_BAR_THICKNESS / 2,
top = tablePosition.y,
height = tableHeight,
width = RESIZE_BAR_THICKNESS;
editor.dom.add(getBody(), 'div',
generateBar(RESIZE_BAR_COL_CLASS, RESIZE_BAR_COL_CURSOR_STYLE,
left, top, height, width, RESIZE_BAR_COL_DATA_ATTRIBUTE, cellPosition.index));
});
} | [
"function",
"drawCols",
"(",
"cellPositions",
",",
"tableHeight",
",",
"tablePosition",
")",
"{",
"Tools",
".",
"each",
"(",
"cellPositions",
",",
"function",
"(",
"cellPosition",
")",
"{",
"var",
"left",
"=",
"cellPosition",
".",
"x",
"-",
"RESIZE_BAR_THICKNESS",
"/",
"2",
",",
"top",
"=",
"tablePosition",
".",
"y",
",",
"height",
"=",
"tableHeight",
",",
"width",
"=",
"RESIZE_BAR_THICKNESS",
";",
"editor",
".",
"dom",
".",
"add",
"(",
"getBody",
"(",
")",
",",
"'div'",
",",
"generateBar",
"(",
"RESIZE_BAR_COL_CLASS",
",",
"RESIZE_BAR_COL_CURSOR_STYLE",
",",
"left",
",",
"top",
",",
"height",
",",
"width",
",",
"RESIZE_BAR_COL_DATA_ATTRIBUTE",
",",
"cellPosition",
".",
"index",
")",
")",
";",
"}",
")",
";",
"}"
] | Draw the column bars over the column borders. | [
"Draw",
"the",
"column",
"bars",
"over",
"the",
"column",
"borders",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66136-L66147 |
48,364 | sadiqhabib/tinymce-dist | tinymce.full.js | getTableDetails | function getTableDetails(table) {
return Tools.map(table.rows, function (row) {
var cells = Tools.map(row.cells, function (cell) {
var rowspan = cell.hasAttribute('rowspan') ? parseInt(cell.getAttribute('rowspan'), 10) : 1;
var colspan = cell.hasAttribute('colspan') ? parseInt(cell.getAttribute('colspan'), 10) : 1;
return {
element: cell,
rowspan: rowspan,
colspan: colspan
};
});
return {
element: row,
cells: cells
};
});
} | javascript | function getTableDetails(table) {
return Tools.map(table.rows, function (row) {
var cells = Tools.map(row.cells, function (cell) {
var rowspan = cell.hasAttribute('rowspan') ? parseInt(cell.getAttribute('rowspan'), 10) : 1;
var colspan = cell.hasAttribute('colspan') ? parseInt(cell.getAttribute('colspan'), 10) : 1;
return {
element: cell,
rowspan: rowspan,
colspan: colspan
};
});
return {
element: row,
cells: cells
};
});
} | [
"function",
"getTableDetails",
"(",
"table",
")",
"{",
"return",
"Tools",
".",
"map",
"(",
"table",
".",
"rows",
",",
"function",
"(",
"row",
")",
"{",
"var",
"cells",
"=",
"Tools",
".",
"map",
"(",
"row",
".",
"cells",
",",
"function",
"(",
"cell",
")",
"{",
"var",
"rowspan",
"=",
"cell",
".",
"hasAttribute",
"(",
"'rowspan'",
")",
"?",
"parseInt",
"(",
"cell",
".",
"getAttribute",
"(",
"'rowspan'",
")",
",",
"10",
")",
":",
"1",
";",
"var",
"colspan",
"=",
"cell",
".",
"hasAttribute",
"(",
"'colspan'",
")",
"?",
"parseInt",
"(",
"cell",
".",
"getAttribute",
"(",
"'colspan'",
")",
",",
"10",
")",
":",
"1",
";",
"return",
"{",
"element",
":",
"cell",
",",
"rowspan",
":",
"rowspan",
",",
"colspan",
":",
"colspan",
"}",
";",
"}",
")",
";",
"return",
"{",
"element",
":",
"row",
",",
"cells",
":",
"cells",
"}",
";",
"}",
")",
";",
"}"
] | Get a matrix of the cells in each row and the rows in the table. | [
"Get",
"a",
"matrix",
"of",
"the",
"cells",
"in",
"each",
"row",
"and",
"the",
"rows",
"in",
"the",
"table",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66150-L66172 |
48,365 | sadiqhabib/tinymce-dist | tinymce.full.js | getTableGrid | function getTableGrid(tableDetails) {
function key(rowIndex, colIndex) {
return rowIndex + ',' + colIndex;
}
function getAt(rowIndex, colIndex) {
return access[key(rowIndex, colIndex)];
}
function getAllCells() {
var allCells = [];
Tools.each(rows, function (row) {
allCells = allCells.concat(row.cells);
});
return allCells;
}
function getAllRows() {
return rows;
}
var access = {};
var rows = [];
var maxRows = 0;
var maxCols = 0;
Tools.each(tableDetails, function (row, rowIndex) {
var currentRow = [];
Tools.each(row.cells, function (cell) {
var start = 0;
while (access[key(rowIndex, start)] !== undefined) {
start++;
}
var current = {
element: cell.element,
colspan: cell.colspan,
rowspan: cell.rowspan,
rowIndex: rowIndex,
colIndex: start
};
for (var i = 0; i < cell.colspan; i++) {
for (var j = 0; j < cell.rowspan; j++) {
var cr = rowIndex + j;
var cc = start + i;
access[key(cr, cc)] = current;
maxRows = Math.max(maxRows, cr + 1);
maxCols = Math.max(maxCols, cc + 1);
}
}
currentRow.push(current);
});
rows.push({
element: row.element,
cells: currentRow
});
});
return {
grid: {
maxRows: maxRows,
maxCols: maxCols
},
getAt: getAt,
getAllCells: getAllCells,
getAllRows: getAllRows
};
} | javascript | function getTableGrid(tableDetails) {
function key(rowIndex, colIndex) {
return rowIndex + ',' + colIndex;
}
function getAt(rowIndex, colIndex) {
return access[key(rowIndex, colIndex)];
}
function getAllCells() {
var allCells = [];
Tools.each(rows, function (row) {
allCells = allCells.concat(row.cells);
});
return allCells;
}
function getAllRows() {
return rows;
}
var access = {};
var rows = [];
var maxRows = 0;
var maxCols = 0;
Tools.each(tableDetails, function (row, rowIndex) {
var currentRow = [];
Tools.each(row.cells, function (cell) {
var start = 0;
while (access[key(rowIndex, start)] !== undefined) {
start++;
}
var current = {
element: cell.element,
colspan: cell.colspan,
rowspan: cell.rowspan,
rowIndex: rowIndex,
colIndex: start
};
for (var i = 0; i < cell.colspan; i++) {
for (var j = 0; j < cell.rowspan; j++) {
var cr = rowIndex + j;
var cc = start + i;
access[key(cr, cc)] = current;
maxRows = Math.max(maxRows, cr + 1);
maxCols = Math.max(maxCols, cc + 1);
}
}
currentRow.push(current);
});
rows.push({
element: row.element,
cells: currentRow
});
});
return {
grid: {
maxRows: maxRows,
maxCols: maxCols
},
getAt: getAt,
getAllCells: getAllCells,
getAllRows: getAllRows
};
} | [
"function",
"getTableGrid",
"(",
"tableDetails",
")",
"{",
"function",
"key",
"(",
"rowIndex",
",",
"colIndex",
")",
"{",
"return",
"rowIndex",
"+",
"','",
"+",
"colIndex",
";",
"}",
"function",
"getAt",
"(",
"rowIndex",
",",
"colIndex",
")",
"{",
"return",
"access",
"[",
"key",
"(",
"rowIndex",
",",
"colIndex",
")",
"]",
";",
"}",
"function",
"getAllCells",
"(",
")",
"{",
"var",
"allCells",
"=",
"[",
"]",
";",
"Tools",
".",
"each",
"(",
"rows",
",",
"function",
"(",
"row",
")",
"{",
"allCells",
"=",
"allCells",
".",
"concat",
"(",
"row",
".",
"cells",
")",
";",
"}",
")",
";",
"return",
"allCells",
";",
"}",
"function",
"getAllRows",
"(",
")",
"{",
"return",
"rows",
";",
"}",
"var",
"access",
"=",
"{",
"}",
";",
"var",
"rows",
"=",
"[",
"]",
";",
"var",
"maxRows",
"=",
"0",
";",
"var",
"maxCols",
"=",
"0",
";",
"Tools",
".",
"each",
"(",
"tableDetails",
",",
"function",
"(",
"row",
",",
"rowIndex",
")",
"{",
"var",
"currentRow",
"=",
"[",
"]",
";",
"Tools",
".",
"each",
"(",
"row",
".",
"cells",
",",
"function",
"(",
"cell",
")",
"{",
"var",
"start",
"=",
"0",
";",
"while",
"(",
"access",
"[",
"key",
"(",
"rowIndex",
",",
"start",
")",
"]",
"!==",
"undefined",
")",
"{",
"start",
"++",
";",
"}",
"var",
"current",
"=",
"{",
"element",
":",
"cell",
".",
"element",
",",
"colspan",
":",
"cell",
".",
"colspan",
",",
"rowspan",
":",
"cell",
".",
"rowspan",
",",
"rowIndex",
":",
"rowIndex",
",",
"colIndex",
":",
"start",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cell",
".",
"colspan",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"cell",
".",
"rowspan",
";",
"j",
"++",
")",
"{",
"var",
"cr",
"=",
"rowIndex",
"+",
"j",
";",
"var",
"cc",
"=",
"start",
"+",
"i",
";",
"access",
"[",
"key",
"(",
"cr",
",",
"cc",
")",
"]",
"=",
"current",
";",
"maxRows",
"=",
"Math",
".",
"max",
"(",
"maxRows",
",",
"cr",
"+",
"1",
")",
";",
"maxCols",
"=",
"Math",
".",
"max",
"(",
"maxCols",
",",
"cc",
"+",
"1",
")",
";",
"}",
"}",
"currentRow",
".",
"push",
"(",
"current",
")",
";",
"}",
")",
";",
"rows",
".",
"push",
"(",
"{",
"element",
":",
"row",
".",
"element",
",",
"cells",
":",
"currentRow",
"}",
")",
";",
"}",
")",
";",
"return",
"{",
"grid",
":",
"{",
"maxRows",
":",
"maxRows",
",",
"maxCols",
":",
"maxCols",
"}",
",",
"getAt",
":",
"getAt",
",",
"getAllCells",
":",
"getAllCells",
",",
"getAllRows",
":",
"getAllRows",
"}",
";",
"}"
] | Get a grid model of the table. | [
"Get",
"a",
"grid",
"model",
"of",
"the",
"table",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66175-L66249 |
48,366 | sadiqhabib/tinymce-dist | tinymce.full.js | getColumnBlocks | function getColumnBlocks(tableGrid) {
var cols = range(0, tableGrid.grid.maxCols);
var rows = range(0, tableGrid.grid.maxRows);
return Tools.map(cols, function (col) {
function getBlock() {
var details = [];
for (var i = 0; i < rows.length; i++) {
var detail = tableGrid.getAt(i, col);
if (detail && detail.colIndex === col) {
details.push(detail);
}
}
return details;
}
function isSingle(detail) {
return detail.colspan === 1;
}
function getFallback() {
var item;
for (var i = 0; i < rows.length; i++) {
item = tableGrid.getAt(i, col);
if (item) {
return item;
}
}
return null;
}
return decide(getBlock, isSingle, getFallback);
});
} | javascript | function getColumnBlocks(tableGrid) {
var cols = range(0, tableGrid.grid.maxCols);
var rows = range(0, tableGrid.grid.maxRows);
return Tools.map(cols, function (col) {
function getBlock() {
var details = [];
for (var i = 0; i < rows.length; i++) {
var detail = tableGrid.getAt(i, col);
if (detail && detail.colIndex === col) {
details.push(detail);
}
}
return details;
}
function isSingle(detail) {
return detail.colspan === 1;
}
function getFallback() {
var item;
for (var i = 0; i < rows.length; i++) {
item = tableGrid.getAt(i, col);
if (item) {
return item;
}
}
return null;
}
return decide(getBlock, isSingle, getFallback);
});
} | [
"function",
"getColumnBlocks",
"(",
"tableGrid",
")",
"{",
"var",
"cols",
"=",
"range",
"(",
"0",
",",
"tableGrid",
".",
"grid",
".",
"maxCols",
")",
";",
"var",
"rows",
"=",
"range",
"(",
"0",
",",
"tableGrid",
".",
"grid",
".",
"maxRows",
")",
";",
"return",
"Tools",
".",
"map",
"(",
"cols",
",",
"function",
"(",
"col",
")",
"{",
"function",
"getBlock",
"(",
")",
"{",
"var",
"details",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"rows",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"detail",
"=",
"tableGrid",
".",
"getAt",
"(",
"i",
",",
"col",
")",
";",
"if",
"(",
"detail",
"&&",
"detail",
".",
"colIndex",
"===",
"col",
")",
"{",
"details",
".",
"push",
"(",
"detail",
")",
";",
"}",
"}",
"return",
"details",
";",
"}",
"function",
"isSingle",
"(",
"detail",
")",
"{",
"return",
"detail",
".",
"colspan",
"===",
"1",
";",
"}",
"function",
"getFallback",
"(",
")",
"{",
"var",
"item",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"rows",
".",
"length",
";",
"i",
"++",
")",
"{",
"item",
"=",
"tableGrid",
".",
"getAt",
"(",
"i",
",",
"col",
")",
";",
"if",
"(",
"item",
")",
"{",
"return",
"item",
";",
"}",
"}",
"return",
"null",
";",
"}",
"return",
"decide",
"(",
"getBlock",
",",
"isSingle",
",",
"getFallback",
")",
";",
"}",
")",
";",
"}"
] | Attempt to get representative blocks for the width of each column. | [
"Attempt",
"to",
"get",
"representative",
"blocks",
"for",
"the",
"width",
"of",
"each",
"column",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66277-L66313 |
48,367 | sadiqhabib/tinymce-dist | tinymce.full.js | getRowBlocks | function getRowBlocks(tableGrid) {
var cols = range(0, tableGrid.grid.maxCols);
var rows = range(0, tableGrid.grid.maxRows);
return Tools.map(rows, function (row) {
function getBlock() {
var details = [];
for (var i = 0; i < cols.length; i++) {
var detail = tableGrid.getAt(row, i);
if (detail && detail.rowIndex === row) {
details.push(detail);
}
}
return details;
}
function isSingle(detail) {
return detail.rowspan === 1;
}
function getFallback() {
return tableGrid.getAt(row, 0);
}
return decide(getBlock, isSingle, getFallback);
});
} | javascript | function getRowBlocks(tableGrid) {
var cols = range(0, tableGrid.grid.maxCols);
var rows = range(0, tableGrid.grid.maxRows);
return Tools.map(rows, function (row) {
function getBlock() {
var details = [];
for (var i = 0; i < cols.length; i++) {
var detail = tableGrid.getAt(row, i);
if (detail && detail.rowIndex === row) {
details.push(detail);
}
}
return details;
}
function isSingle(detail) {
return detail.rowspan === 1;
}
function getFallback() {
return tableGrid.getAt(row, 0);
}
return decide(getBlock, isSingle, getFallback);
});
} | [
"function",
"getRowBlocks",
"(",
"tableGrid",
")",
"{",
"var",
"cols",
"=",
"range",
"(",
"0",
",",
"tableGrid",
".",
"grid",
".",
"maxCols",
")",
";",
"var",
"rows",
"=",
"range",
"(",
"0",
",",
"tableGrid",
".",
"grid",
".",
"maxRows",
")",
";",
"return",
"Tools",
".",
"map",
"(",
"rows",
",",
"function",
"(",
"row",
")",
"{",
"function",
"getBlock",
"(",
")",
"{",
"var",
"details",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cols",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"detail",
"=",
"tableGrid",
".",
"getAt",
"(",
"row",
",",
"i",
")",
";",
"if",
"(",
"detail",
"&&",
"detail",
".",
"rowIndex",
"===",
"row",
")",
"{",
"details",
".",
"push",
"(",
"detail",
")",
";",
"}",
"}",
"return",
"details",
";",
"}",
"function",
"isSingle",
"(",
"detail",
")",
"{",
"return",
"detail",
".",
"rowspan",
"===",
"1",
";",
"}",
"function",
"getFallback",
"(",
")",
"{",
"return",
"tableGrid",
".",
"getAt",
"(",
"row",
",",
"0",
")",
";",
"}",
"return",
"decide",
"(",
"getBlock",
",",
"isSingle",
",",
"getFallback",
")",
";",
"}",
")",
";",
"}"
] | Attempt to get representative blocks for the height of each row. | [
"Attempt",
"to",
"get",
"representative",
"blocks",
"for",
"the",
"height",
"of",
"each",
"row",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66316-L66342 |
48,368 | sadiqhabib/tinymce-dist | tinymce.full.js | getWidths | function getWidths(tableGrid, isPercentageBased, table) {
var cols = getColumnBlocks(tableGrid);
var backups = Tools.map(cols, function (col) {
return getInnerEdge(col.colIndex, col.element).x;
});
var widths = [];
for (var i = 0; i < cols.length; i++) {
var span = cols[i].element.hasAttribute('colspan') ? parseInt(cols[i].element.getAttribute('colspan'), 10) : 1;
// Deduce if the column has colspan of more than 1
var width = span > 1 ? deduceSize(backups, i) : getWidth(cols[i].element, isPercentageBased, table);
// If everything's failed and we still don't have a width
width = width ? width : RESIZE_MINIMUM_WIDTH;
widths.push(width);
}
return widths;
} | javascript | function getWidths(tableGrid, isPercentageBased, table) {
var cols = getColumnBlocks(tableGrid);
var backups = Tools.map(cols, function (col) {
return getInnerEdge(col.colIndex, col.element).x;
});
var widths = [];
for (var i = 0; i < cols.length; i++) {
var span = cols[i].element.hasAttribute('colspan') ? parseInt(cols[i].element.getAttribute('colspan'), 10) : 1;
// Deduce if the column has colspan of more than 1
var width = span > 1 ? deduceSize(backups, i) : getWidth(cols[i].element, isPercentageBased, table);
// If everything's failed and we still don't have a width
width = width ? width : RESIZE_MINIMUM_WIDTH;
widths.push(width);
}
return widths;
} | [
"function",
"getWidths",
"(",
"tableGrid",
",",
"isPercentageBased",
",",
"table",
")",
"{",
"var",
"cols",
"=",
"getColumnBlocks",
"(",
"tableGrid",
")",
";",
"var",
"backups",
"=",
"Tools",
".",
"map",
"(",
"cols",
",",
"function",
"(",
"col",
")",
"{",
"return",
"getInnerEdge",
"(",
"col",
".",
"colIndex",
",",
"col",
".",
"element",
")",
".",
"x",
";",
"}",
")",
";",
"var",
"widths",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cols",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"span",
"=",
"cols",
"[",
"i",
"]",
".",
"element",
".",
"hasAttribute",
"(",
"'colspan'",
")",
"?",
"parseInt",
"(",
"cols",
"[",
"i",
"]",
".",
"element",
".",
"getAttribute",
"(",
"'colspan'",
")",
",",
"10",
")",
":",
"1",
";",
"// Deduce if the column has colspan of more than 1",
"var",
"width",
"=",
"span",
">",
"1",
"?",
"deduceSize",
"(",
"backups",
",",
"i",
")",
":",
"getWidth",
"(",
"cols",
"[",
"i",
"]",
".",
"element",
",",
"isPercentageBased",
",",
"table",
")",
";",
"// If everything's failed and we still don't have a width",
"width",
"=",
"width",
"?",
"width",
":",
"RESIZE_MINIMUM_WIDTH",
";",
"widths",
".",
"push",
"(",
"width",
")",
";",
"}",
"return",
"widths",
";",
"}"
] | Attempt to get the css width from column representative cells. | [
"Attempt",
"to",
"get",
"the",
"css",
"width",
"from",
"column",
"representative",
"cells",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66442-L66462 |
48,369 | sadiqhabib/tinymce-dist | tinymce.full.js | getPixelHeight | function getPixelHeight(element) {
var heightString = getStyleOrAttrib(element, 'height');
var heightNumber = parseInt(heightString, 10);
if (isPercentageBasedSize(heightString)) {
heightNumber = 0;
}
return !isNaN(heightNumber) && heightNumber > 0 ?
heightNumber : getComputedStyleSize(element, 'height');
} | javascript | function getPixelHeight(element) {
var heightString = getStyleOrAttrib(element, 'height');
var heightNumber = parseInt(heightString, 10);
if (isPercentageBasedSize(heightString)) {
heightNumber = 0;
}
return !isNaN(heightNumber) && heightNumber > 0 ?
heightNumber : getComputedStyleSize(element, 'height');
} | [
"function",
"getPixelHeight",
"(",
"element",
")",
"{",
"var",
"heightString",
"=",
"getStyleOrAttrib",
"(",
"element",
",",
"'height'",
")",
";",
"var",
"heightNumber",
"=",
"parseInt",
"(",
"heightString",
",",
"10",
")",
";",
"if",
"(",
"isPercentageBasedSize",
"(",
"heightString",
")",
")",
"{",
"heightNumber",
"=",
"0",
";",
"}",
"return",
"!",
"isNaN",
"(",
"heightNumber",
")",
"&&",
"heightNumber",
">",
"0",
"?",
"heightNumber",
":",
"getComputedStyleSize",
"(",
"element",
",",
"'height'",
")",
";",
"}"
] | Attempt to get the pixel height from a cell. | [
"Attempt",
"to",
"get",
"the",
"pixel",
"height",
"from",
"a",
"cell",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66465-L66477 |
48,370 | sadiqhabib/tinymce-dist | tinymce.full.js | getPixelHeights | function getPixelHeights(tableGrid) {
var rows = getRowBlocks(tableGrid);
var backups = Tools.map(rows, function (row) {
return getTopEdge(row.rowIndex, row.element).y;
});
var heights = [];
for (var i = 0; i < rows.length; i++) {
var span = rows[i].element.hasAttribute('rowspan') ? parseInt(rows[i].element.getAttribute('rowspan'), 10) : 1;
var height = span > 1 ? deduceSize(backups, i) : getPixelHeight(rows[i].element);
height = height ? height : RESIZE_MINIMUM_HEIGHT;
heights.push(height);
}
return heights;
} | javascript | function getPixelHeights(tableGrid) {
var rows = getRowBlocks(tableGrid);
var backups = Tools.map(rows, function (row) {
return getTopEdge(row.rowIndex, row.element).y;
});
var heights = [];
for (var i = 0; i < rows.length; i++) {
var span = rows[i].element.hasAttribute('rowspan') ? parseInt(rows[i].element.getAttribute('rowspan'), 10) : 1;
var height = span > 1 ? deduceSize(backups, i) : getPixelHeight(rows[i].element);
height = height ? height : RESIZE_MINIMUM_HEIGHT;
heights.push(height);
}
return heights;
} | [
"function",
"getPixelHeights",
"(",
"tableGrid",
")",
"{",
"var",
"rows",
"=",
"getRowBlocks",
"(",
"tableGrid",
")",
";",
"var",
"backups",
"=",
"Tools",
".",
"map",
"(",
"rows",
",",
"function",
"(",
"row",
")",
"{",
"return",
"getTopEdge",
"(",
"row",
".",
"rowIndex",
",",
"row",
".",
"element",
")",
".",
"y",
";",
"}",
")",
";",
"var",
"heights",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"rows",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"span",
"=",
"rows",
"[",
"i",
"]",
".",
"element",
".",
"hasAttribute",
"(",
"'rowspan'",
")",
"?",
"parseInt",
"(",
"rows",
"[",
"i",
"]",
".",
"element",
".",
"getAttribute",
"(",
"'rowspan'",
")",
",",
"10",
")",
":",
"1",
";",
"var",
"height",
"=",
"span",
">",
"1",
"?",
"deduceSize",
"(",
"backups",
",",
"i",
")",
":",
"getPixelHeight",
"(",
"rows",
"[",
"i",
"]",
".",
"element",
")",
";",
"height",
"=",
"height",
"?",
"height",
":",
"RESIZE_MINIMUM_HEIGHT",
";",
"heights",
".",
"push",
"(",
"height",
")",
";",
"}",
"return",
"heights",
";",
"}"
] | Attempt to get the css height from row representative cells. | [
"Attempt",
"to",
"get",
"the",
"css",
"height",
"from",
"row",
"representative",
"cells",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66480-L66500 |
48,371 | sadiqhabib/tinymce-dist | tinymce.full.js | determineDeltas | function determineDeltas(sizes, column, step, min, isPercentageBased) {
var result = sizes.slice(0);
function generateZeros(array) {
return Tools.map(array, function () {
return 0;
});
}
function onOneColumn() {
var deltas;
if (isPercentageBased) {
// If we have one column in a percent based table, that column should be 100% of the width of the table.
deltas = [100 - result[0]];
} else {
var newNext = Math.max(min, result[0] + step);
deltas = [newNext - result[0]];
}
return deltas;
}
function onLeftOrMiddle(index, next) {
var startZeros = generateZeros(result.slice(0, index));
var endZeros = generateZeros(result.slice(next + 1));
var deltas;
if (step >= 0) {
var newNext = Math.max(min, result[next] - step);
deltas = startZeros.concat([step, newNext - result[next]]).concat(endZeros);
} else {
var newThis = Math.max(min, result[index] + step);
var diffx = result[index] - newThis;
deltas = startZeros.concat([newThis - result[index], diffx]).concat(endZeros);
}
return deltas;
}
function onRight(previous, index) {
var startZeros = generateZeros(result.slice(0, index));
var deltas;
if (step >= 0) {
deltas = startZeros.concat([step]);
} else {
var size = Math.max(min, result[index] + step);
deltas = startZeros.concat([size - result[index]]);
}
return deltas;
}
var deltas;
if (sizes.length === 0) { // No Columns
deltas = [];
} else if (sizes.length === 1) { // One Column
deltas = onOneColumn();
} else if (column === 0) { // Left Column
deltas = onLeftOrMiddle(0, 1);
} else if (column > 0 && column < sizes.length - 1) { // Middle Column
deltas = onLeftOrMiddle(column, column + 1);
} else if (column === sizes.length - 1) { // Right Column
deltas = onRight(column - 1, column);
} else {
deltas = [];
}
return deltas;
} | javascript | function determineDeltas(sizes, column, step, min, isPercentageBased) {
var result = sizes.slice(0);
function generateZeros(array) {
return Tools.map(array, function () {
return 0;
});
}
function onOneColumn() {
var deltas;
if (isPercentageBased) {
// If we have one column in a percent based table, that column should be 100% of the width of the table.
deltas = [100 - result[0]];
} else {
var newNext = Math.max(min, result[0] + step);
deltas = [newNext - result[0]];
}
return deltas;
}
function onLeftOrMiddle(index, next) {
var startZeros = generateZeros(result.slice(0, index));
var endZeros = generateZeros(result.slice(next + 1));
var deltas;
if (step >= 0) {
var newNext = Math.max(min, result[next] - step);
deltas = startZeros.concat([step, newNext - result[next]]).concat(endZeros);
} else {
var newThis = Math.max(min, result[index] + step);
var diffx = result[index] - newThis;
deltas = startZeros.concat([newThis - result[index], diffx]).concat(endZeros);
}
return deltas;
}
function onRight(previous, index) {
var startZeros = generateZeros(result.slice(0, index));
var deltas;
if (step >= 0) {
deltas = startZeros.concat([step]);
} else {
var size = Math.max(min, result[index] + step);
deltas = startZeros.concat([size - result[index]]);
}
return deltas;
}
var deltas;
if (sizes.length === 0) { // No Columns
deltas = [];
} else if (sizes.length === 1) { // One Column
deltas = onOneColumn();
} else if (column === 0) { // Left Column
deltas = onLeftOrMiddle(0, 1);
} else if (column > 0 && column < sizes.length - 1) { // Middle Column
deltas = onLeftOrMiddle(column, column + 1);
} else if (column === sizes.length - 1) { // Right Column
deltas = onRight(column - 1, column);
} else {
deltas = [];
}
return deltas;
} | [
"function",
"determineDeltas",
"(",
"sizes",
",",
"column",
",",
"step",
",",
"min",
",",
"isPercentageBased",
")",
"{",
"var",
"result",
"=",
"sizes",
".",
"slice",
"(",
"0",
")",
";",
"function",
"generateZeros",
"(",
"array",
")",
"{",
"return",
"Tools",
".",
"map",
"(",
"array",
",",
"function",
"(",
")",
"{",
"return",
"0",
";",
"}",
")",
";",
"}",
"function",
"onOneColumn",
"(",
")",
"{",
"var",
"deltas",
";",
"if",
"(",
"isPercentageBased",
")",
"{",
"// If we have one column in a percent based table, that column should be 100% of the width of the table.",
"deltas",
"=",
"[",
"100",
"-",
"result",
"[",
"0",
"]",
"]",
";",
"}",
"else",
"{",
"var",
"newNext",
"=",
"Math",
".",
"max",
"(",
"min",
",",
"result",
"[",
"0",
"]",
"+",
"step",
")",
";",
"deltas",
"=",
"[",
"newNext",
"-",
"result",
"[",
"0",
"]",
"]",
";",
"}",
"return",
"deltas",
";",
"}",
"function",
"onLeftOrMiddle",
"(",
"index",
",",
"next",
")",
"{",
"var",
"startZeros",
"=",
"generateZeros",
"(",
"result",
".",
"slice",
"(",
"0",
",",
"index",
")",
")",
";",
"var",
"endZeros",
"=",
"generateZeros",
"(",
"result",
".",
"slice",
"(",
"next",
"+",
"1",
")",
")",
";",
"var",
"deltas",
";",
"if",
"(",
"step",
">=",
"0",
")",
"{",
"var",
"newNext",
"=",
"Math",
".",
"max",
"(",
"min",
",",
"result",
"[",
"next",
"]",
"-",
"step",
")",
";",
"deltas",
"=",
"startZeros",
".",
"concat",
"(",
"[",
"step",
",",
"newNext",
"-",
"result",
"[",
"next",
"]",
"]",
")",
".",
"concat",
"(",
"endZeros",
")",
";",
"}",
"else",
"{",
"var",
"newThis",
"=",
"Math",
".",
"max",
"(",
"min",
",",
"result",
"[",
"index",
"]",
"+",
"step",
")",
";",
"var",
"diffx",
"=",
"result",
"[",
"index",
"]",
"-",
"newThis",
";",
"deltas",
"=",
"startZeros",
".",
"concat",
"(",
"[",
"newThis",
"-",
"result",
"[",
"index",
"]",
",",
"diffx",
"]",
")",
".",
"concat",
"(",
"endZeros",
")",
";",
"}",
"return",
"deltas",
";",
"}",
"function",
"onRight",
"(",
"previous",
",",
"index",
")",
"{",
"var",
"startZeros",
"=",
"generateZeros",
"(",
"result",
".",
"slice",
"(",
"0",
",",
"index",
")",
")",
";",
"var",
"deltas",
";",
"if",
"(",
"step",
">=",
"0",
")",
"{",
"deltas",
"=",
"startZeros",
".",
"concat",
"(",
"[",
"step",
"]",
")",
";",
"}",
"else",
"{",
"var",
"size",
"=",
"Math",
".",
"max",
"(",
"min",
",",
"result",
"[",
"index",
"]",
"+",
"step",
")",
";",
"deltas",
"=",
"startZeros",
".",
"concat",
"(",
"[",
"size",
"-",
"result",
"[",
"index",
"]",
"]",
")",
";",
"}",
"return",
"deltas",
";",
"}",
"var",
"deltas",
";",
"if",
"(",
"sizes",
".",
"length",
"===",
"0",
")",
"{",
"// No Columns",
"deltas",
"=",
"[",
"]",
";",
"}",
"else",
"if",
"(",
"sizes",
".",
"length",
"===",
"1",
")",
"{",
"// One Column",
"deltas",
"=",
"onOneColumn",
"(",
")",
";",
"}",
"else",
"if",
"(",
"column",
"===",
"0",
")",
"{",
"// Left Column",
"deltas",
"=",
"onLeftOrMiddle",
"(",
"0",
",",
"1",
")",
";",
"}",
"else",
"if",
"(",
"column",
">",
"0",
"&&",
"column",
"<",
"sizes",
".",
"length",
"-",
"1",
")",
"{",
"// Middle Column",
"deltas",
"=",
"onLeftOrMiddle",
"(",
"column",
",",
"column",
"+",
"1",
")",
";",
"}",
"else",
"if",
"(",
"column",
"===",
"sizes",
".",
"length",
"-",
"1",
")",
"{",
"// Right Column",
"deltas",
"=",
"onRight",
"(",
"column",
"-",
"1",
",",
"column",
")",
";",
"}",
"else",
"{",
"deltas",
"=",
"[",
"]",
";",
"}",
"return",
"deltas",
";",
"}"
] | Determine how much each column's css width will need to change. Sizes = result = pixels widths OR percentage based widths | [
"Determine",
"how",
"much",
"each",
"column",
"s",
"css",
"width",
"will",
"need",
"to",
"change",
".",
"Sizes",
"=",
"result",
"=",
"pixels",
"widths",
"OR",
"percentage",
"based",
"widths"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66504-L66576 |
48,372 | sadiqhabib/tinymce-dist | tinymce.full.js | recalculateWidths | function recalculateWidths(tableGrid, widths) {
var allCells = tableGrid.getAllCells();
return Tools.map(allCells, function (cell) {
var width = total(cell.colIndex, cell.colIndex + cell.colspan, widths);
return {
element: cell.element,
width: width,
colspan: cell.colspan
};
});
} | javascript | function recalculateWidths(tableGrid, widths) {
var allCells = tableGrid.getAllCells();
return Tools.map(allCells, function (cell) {
var width = total(cell.colIndex, cell.colIndex + cell.colspan, widths);
return {
element: cell.element,
width: width,
colspan: cell.colspan
};
});
} | [
"function",
"recalculateWidths",
"(",
"tableGrid",
",",
"widths",
")",
"{",
"var",
"allCells",
"=",
"tableGrid",
".",
"getAllCells",
"(",
")",
";",
"return",
"Tools",
".",
"map",
"(",
"allCells",
",",
"function",
"(",
"cell",
")",
"{",
"var",
"width",
"=",
"total",
"(",
"cell",
".",
"colIndex",
",",
"cell",
".",
"colIndex",
"+",
"cell",
".",
"colspan",
",",
"widths",
")",
";",
"return",
"{",
"element",
":",
"cell",
".",
"element",
",",
"width",
":",
"width",
",",
"colspan",
":",
"cell",
".",
"colspan",
"}",
";",
"}",
")",
";",
"}"
] | Combine cell's css widths to determine widths of colspan'd cells. | [
"Combine",
"cell",
"s",
"css",
"widths",
"to",
"determine",
"widths",
"of",
"colspan",
"d",
"cells",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66587-L66597 |
48,373 | sadiqhabib/tinymce-dist | tinymce.full.js | recalculateCellHeights | function recalculateCellHeights(tableGrid, heights) {
var allCells = tableGrid.getAllCells();
return Tools.map(allCells, function (cell) {
var height = total(cell.rowIndex, cell.rowIndex + cell.rowspan, heights);
return {
element: cell.element,
height: height,
rowspan: cell.rowspan
};
});
} | javascript | function recalculateCellHeights(tableGrid, heights) {
var allCells = tableGrid.getAllCells();
return Tools.map(allCells, function (cell) {
var height = total(cell.rowIndex, cell.rowIndex + cell.rowspan, heights);
return {
element: cell.element,
height: height,
rowspan: cell.rowspan
};
});
} | [
"function",
"recalculateCellHeights",
"(",
"tableGrid",
",",
"heights",
")",
"{",
"var",
"allCells",
"=",
"tableGrid",
".",
"getAllCells",
"(",
")",
";",
"return",
"Tools",
".",
"map",
"(",
"allCells",
",",
"function",
"(",
"cell",
")",
"{",
"var",
"height",
"=",
"total",
"(",
"cell",
".",
"rowIndex",
",",
"cell",
".",
"rowIndex",
"+",
"cell",
".",
"rowspan",
",",
"heights",
")",
";",
"return",
"{",
"element",
":",
"cell",
".",
"element",
",",
"height",
":",
"height",
",",
"rowspan",
":",
"cell",
".",
"rowspan",
"}",
";",
"}",
")",
";",
"}"
] | Combine cell's css heights to determine heights of rowspan'd cells. | [
"Combine",
"cell",
"s",
"css",
"heights",
"to",
"determine",
"heights",
"of",
"rowspan",
"d",
"cells",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66600-L66610 |
48,374 | sadiqhabib/tinymce-dist | tinymce.full.js | recalculateRowHeights | function recalculateRowHeights(tableGrid, heights) {
var allRows = tableGrid.getAllRows();
return Tools.map(allRows, function (row, i) {
return {
element: row.element,
height: heights[i]
};
});
} | javascript | function recalculateRowHeights(tableGrid, heights) {
var allRows = tableGrid.getAllRows();
return Tools.map(allRows, function (row, i) {
return {
element: row.element,
height: heights[i]
};
});
} | [
"function",
"recalculateRowHeights",
"(",
"tableGrid",
",",
"heights",
")",
"{",
"var",
"allRows",
"=",
"tableGrid",
".",
"getAllRows",
"(",
")",
";",
"return",
"Tools",
".",
"map",
"(",
"allRows",
",",
"function",
"(",
"row",
",",
"i",
")",
"{",
"return",
"{",
"element",
":",
"row",
".",
"element",
",",
"height",
":",
"heights",
"[",
"i",
"]",
"}",
";",
"}",
")",
";",
"}"
] | Calculate row heights. | [
"Calculate",
"row",
"heights",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66613-L66621 |
48,375 | sadiqhabib/tinymce-dist | tinymce.full.js | adjustWidth | function adjustWidth(table, delta, index) {
var tableDetails = getTableDetails(table);
var tableGrid = getTableGrid(tableDetails);
function setSizes(newSizes, styleExtension) {
Tools.each(newSizes, function (cell) {
editor.dom.setStyle(cell.element, 'width', cell.width + styleExtension);
editor.dom.setAttrib(cell.element, 'width', null);
});
}
function getNewTablePercentWidth() {
return index < tableGrid.grid.maxCols - 1 ? getCurrentTablePercentWidth(table) :
getCurrentTablePercentWidth(table) + getTablePercentDelta(table, delta);
}
function getNewTablePixelWidth() {
return index < tableGrid.grid.maxCols - 1 ? getComputedStyleSize(table, 'width') :
getComputedStyleSize(table, 'width') + delta;
}
function setTableSize(newTableWidth, styleExtension, isPercentBased) {
if (index == tableGrid.grid.maxCols - 1 || !isPercentBased) {
editor.dom.setStyle(table, 'width', newTableWidth + styleExtension);
editor.dom.setAttrib(table, 'width', null);
}
}
var percentageBased = isPercentageBasedSize(table.width) ||
isPercentageBasedSize(table.style.width);
var widths = getWidths(tableGrid, percentageBased, table);
var step = percentageBased ? getCellPercentDelta(table, delta) : delta;
// TODO: change the min for percentage maybe?
var deltas = determineDeltas(widths, index, step, RESIZE_MINIMUM_WIDTH, percentageBased, table);
var newWidths = [];
for (var i = 0; i < deltas.length; i++) {
newWidths.push(deltas[i] + widths[i]);
}
var newSizes = recalculateWidths(tableGrid, newWidths);
var styleExtension = percentageBased ? '%' : 'px';
var newTableWidth = percentageBased ? getNewTablePercentWidth() :
getNewTablePixelWidth();
editor.undoManager.transact(function () {
setSizes(newSizes, styleExtension);
setTableSize(newTableWidth, styleExtension, percentageBased);
});
} | javascript | function adjustWidth(table, delta, index) {
var tableDetails = getTableDetails(table);
var tableGrid = getTableGrid(tableDetails);
function setSizes(newSizes, styleExtension) {
Tools.each(newSizes, function (cell) {
editor.dom.setStyle(cell.element, 'width', cell.width + styleExtension);
editor.dom.setAttrib(cell.element, 'width', null);
});
}
function getNewTablePercentWidth() {
return index < tableGrid.grid.maxCols - 1 ? getCurrentTablePercentWidth(table) :
getCurrentTablePercentWidth(table) + getTablePercentDelta(table, delta);
}
function getNewTablePixelWidth() {
return index < tableGrid.grid.maxCols - 1 ? getComputedStyleSize(table, 'width') :
getComputedStyleSize(table, 'width') + delta;
}
function setTableSize(newTableWidth, styleExtension, isPercentBased) {
if (index == tableGrid.grid.maxCols - 1 || !isPercentBased) {
editor.dom.setStyle(table, 'width', newTableWidth + styleExtension);
editor.dom.setAttrib(table, 'width', null);
}
}
var percentageBased = isPercentageBasedSize(table.width) ||
isPercentageBasedSize(table.style.width);
var widths = getWidths(tableGrid, percentageBased, table);
var step = percentageBased ? getCellPercentDelta(table, delta) : delta;
// TODO: change the min for percentage maybe?
var deltas = determineDeltas(widths, index, step, RESIZE_MINIMUM_WIDTH, percentageBased, table);
var newWidths = [];
for (var i = 0; i < deltas.length; i++) {
newWidths.push(deltas[i] + widths[i]);
}
var newSizes = recalculateWidths(tableGrid, newWidths);
var styleExtension = percentageBased ? '%' : 'px';
var newTableWidth = percentageBased ? getNewTablePercentWidth() :
getNewTablePixelWidth();
editor.undoManager.transact(function () {
setSizes(newSizes, styleExtension);
setTableSize(newTableWidth, styleExtension, percentageBased);
});
} | [
"function",
"adjustWidth",
"(",
"table",
",",
"delta",
",",
"index",
")",
"{",
"var",
"tableDetails",
"=",
"getTableDetails",
"(",
"table",
")",
";",
"var",
"tableGrid",
"=",
"getTableGrid",
"(",
"tableDetails",
")",
";",
"function",
"setSizes",
"(",
"newSizes",
",",
"styleExtension",
")",
"{",
"Tools",
".",
"each",
"(",
"newSizes",
",",
"function",
"(",
"cell",
")",
"{",
"editor",
".",
"dom",
".",
"setStyle",
"(",
"cell",
".",
"element",
",",
"'width'",
",",
"cell",
".",
"width",
"+",
"styleExtension",
")",
";",
"editor",
".",
"dom",
".",
"setAttrib",
"(",
"cell",
".",
"element",
",",
"'width'",
",",
"null",
")",
";",
"}",
")",
";",
"}",
"function",
"getNewTablePercentWidth",
"(",
")",
"{",
"return",
"index",
"<",
"tableGrid",
".",
"grid",
".",
"maxCols",
"-",
"1",
"?",
"getCurrentTablePercentWidth",
"(",
"table",
")",
":",
"getCurrentTablePercentWidth",
"(",
"table",
")",
"+",
"getTablePercentDelta",
"(",
"table",
",",
"delta",
")",
";",
"}",
"function",
"getNewTablePixelWidth",
"(",
")",
"{",
"return",
"index",
"<",
"tableGrid",
".",
"grid",
".",
"maxCols",
"-",
"1",
"?",
"getComputedStyleSize",
"(",
"table",
",",
"'width'",
")",
":",
"getComputedStyleSize",
"(",
"table",
",",
"'width'",
")",
"+",
"delta",
";",
"}",
"function",
"setTableSize",
"(",
"newTableWidth",
",",
"styleExtension",
",",
"isPercentBased",
")",
"{",
"if",
"(",
"index",
"==",
"tableGrid",
".",
"grid",
".",
"maxCols",
"-",
"1",
"||",
"!",
"isPercentBased",
")",
"{",
"editor",
".",
"dom",
".",
"setStyle",
"(",
"table",
",",
"'width'",
",",
"newTableWidth",
"+",
"styleExtension",
")",
";",
"editor",
".",
"dom",
".",
"setAttrib",
"(",
"table",
",",
"'width'",
",",
"null",
")",
";",
"}",
"}",
"var",
"percentageBased",
"=",
"isPercentageBasedSize",
"(",
"table",
".",
"width",
")",
"||",
"isPercentageBasedSize",
"(",
"table",
".",
"style",
".",
"width",
")",
";",
"var",
"widths",
"=",
"getWidths",
"(",
"tableGrid",
",",
"percentageBased",
",",
"table",
")",
";",
"var",
"step",
"=",
"percentageBased",
"?",
"getCellPercentDelta",
"(",
"table",
",",
"delta",
")",
":",
"delta",
";",
"// TODO: change the min for percentage maybe?",
"var",
"deltas",
"=",
"determineDeltas",
"(",
"widths",
",",
"index",
",",
"step",
",",
"RESIZE_MINIMUM_WIDTH",
",",
"percentageBased",
",",
"table",
")",
";",
"var",
"newWidths",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"deltas",
".",
"length",
";",
"i",
"++",
")",
"{",
"newWidths",
".",
"push",
"(",
"deltas",
"[",
"i",
"]",
"+",
"widths",
"[",
"i",
"]",
")",
";",
"}",
"var",
"newSizes",
"=",
"recalculateWidths",
"(",
"tableGrid",
",",
"newWidths",
")",
";",
"var",
"styleExtension",
"=",
"percentageBased",
"?",
"'%'",
":",
"'px'",
";",
"var",
"newTableWidth",
"=",
"percentageBased",
"?",
"getNewTablePercentWidth",
"(",
")",
":",
"getNewTablePixelWidth",
"(",
")",
";",
"editor",
".",
"undoManager",
".",
"transact",
"(",
"function",
"(",
")",
"{",
"setSizes",
"(",
"newSizes",
",",
"styleExtension",
")",
";",
"setTableSize",
"(",
"newTableWidth",
",",
"styleExtension",
",",
"percentageBased",
")",
";",
"}",
")",
";",
"}"
] | Adjust the width of the column of table at index, with delta. | [
"Adjust",
"the",
"width",
"of",
"the",
"column",
"of",
"table",
"at",
"index",
"with",
"delta",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66632-L66683 |
48,376 | sadiqhabib/tinymce-dist | tinymce.full.js | adjustHeight | function adjustHeight(table, delta, index) {
var tableDetails = getTableDetails(table);
var tableGrid = getTableGrid(tableDetails);
var heights = getPixelHeights(tableGrid);
var newHeights = [], newTotalHeight = 0;
for (var i = 0; i < heights.length; i++) {
newHeights.push(i === index ? delta + heights[i] : heights[i]);
newTotalHeight += newTotalHeight[i];
}
var newCellSizes = recalculateCellHeights(tableGrid, newHeights);
var newRowSizes = recalculateRowHeights(tableGrid, newHeights);
editor.undoManager.transact(function () {
Tools.each(newRowSizes, function (row) {
editor.dom.setStyle(row.element, 'height', row.height + 'px');
editor.dom.setAttrib(row.element, 'height', null);
});
Tools.each(newCellSizes, function (cell) {
editor.dom.setStyle(cell.element, 'height', cell.height + 'px');
editor.dom.setAttrib(cell.element, 'height', null);
});
editor.dom.setStyle(table, 'height', newTotalHeight + 'px');
editor.dom.setAttrib(table, 'height', null);
});
} | javascript | function adjustHeight(table, delta, index) {
var tableDetails = getTableDetails(table);
var tableGrid = getTableGrid(tableDetails);
var heights = getPixelHeights(tableGrid);
var newHeights = [], newTotalHeight = 0;
for (var i = 0; i < heights.length; i++) {
newHeights.push(i === index ? delta + heights[i] : heights[i]);
newTotalHeight += newTotalHeight[i];
}
var newCellSizes = recalculateCellHeights(tableGrid, newHeights);
var newRowSizes = recalculateRowHeights(tableGrid, newHeights);
editor.undoManager.transact(function () {
Tools.each(newRowSizes, function (row) {
editor.dom.setStyle(row.element, 'height', row.height + 'px');
editor.dom.setAttrib(row.element, 'height', null);
});
Tools.each(newCellSizes, function (cell) {
editor.dom.setStyle(cell.element, 'height', cell.height + 'px');
editor.dom.setAttrib(cell.element, 'height', null);
});
editor.dom.setStyle(table, 'height', newTotalHeight + 'px');
editor.dom.setAttrib(table, 'height', null);
});
} | [
"function",
"adjustHeight",
"(",
"table",
",",
"delta",
",",
"index",
")",
"{",
"var",
"tableDetails",
"=",
"getTableDetails",
"(",
"table",
")",
";",
"var",
"tableGrid",
"=",
"getTableGrid",
"(",
"tableDetails",
")",
";",
"var",
"heights",
"=",
"getPixelHeights",
"(",
"tableGrid",
")",
";",
"var",
"newHeights",
"=",
"[",
"]",
",",
"newTotalHeight",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"heights",
".",
"length",
";",
"i",
"++",
")",
"{",
"newHeights",
".",
"push",
"(",
"i",
"===",
"index",
"?",
"delta",
"+",
"heights",
"[",
"i",
"]",
":",
"heights",
"[",
"i",
"]",
")",
";",
"newTotalHeight",
"+=",
"newTotalHeight",
"[",
"i",
"]",
";",
"}",
"var",
"newCellSizes",
"=",
"recalculateCellHeights",
"(",
"tableGrid",
",",
"newHeights",
")",
";",
"var",
"newRowSizes",
"=",
"recalculateRowHeights",
"(",
"tableGrid",
",",
"newHeights",
")",
";",
"editor",
".",
"undoManager",
".",
"transact",
"(",
"function",
"(",
")",
"{",
"Tools",
".",
"each",
"(",
"newRowSizes",
",",
"function",
"(",
"row",
")",
"{",
"editor",
".",
"dom",
".",
"setStyle",
"(",
"row",
".",
"element",
",",
"'height'",
",",
"row",
".",
"height",
"+",
"'px'",
")",
";",
"editor",
".",
"dom",
".",
"setAttrib",
"(",
"row",
".",
"element",
",",
"'height'",
",",
"null",
")",
";",
"}",
")",
";",
"Tools",
".",
"each",
"(",
"newCellSizes",
",",
"function",
"(",
"cell",
")",
"{",
"editor",
".",
"dom",
".",
"setStyle",
"(",
"cell",
".",
"element",
",",
"'height'",
",",
"cell",
".",
"height",
"+",
"'px'",
")",
";",
"editor",
".",
"dom",
".",
"setAttrib",
"(",
"cell",
".",
"element",
",",
"'height'",
",",
"null",
")",
";",
"}",
")",
";",
"editor",
".",
"dom",
".",
"setStyle",
"(",
"table",
",",
"'height'",
",",
"newTotalHeight",
"+",
"'px'",
")",
";",
"editor",
".",
"dom",
".",
"setAttrib",
"(",
"table",
",",
"'height'",
",",
"null",
")",
";",
"}",
")",
";",
"}"
] | Adjust the height of the row of table at index, with delta. | [
"Adjust",
"the",
"height",
"of",
"the",
"row",
"of",
"table",
"at",
"index",
"with",
"delta",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66686-L66717 |
48,377 | sadiqhabib/tinymce-dist | tinymce.full.js | innerText | function innerText(html) {
var schema = new Schema(), domParser = new DomParser({}, schema), text = '';
var shortEndedElements = schema.getShortEndedElements();
var ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' ');
var blockElements = schema.getBlockElements();
function walk(node) {
var name = node.name, currentNode = node;
if (name === 'br') {
text += '\n';
return;
}
// img/input/hr
if (shortEndedElements[name]) {
text += ' ';
}
// Ingore script, video contents
if (ignoreElements[name]) {
text += ' ';
return;
}
if (node.type == 3) {
text += node.value;
}
// Walk all children
if (!node.shortEnded) {
if ((node = node.firstChild)) {
do {
walk(node);
} while ((node = node.next));
}
}
// Add \n or \n\n for blocks or P
if (blockElements[name] && currentNode.next) {
text += '\n';
if (name == 'p') {
text += '\n';
}
}
}
html = filter(html, [
/<!\[[^\]]+\]>/g // Conditional comments
]);
walk(domParser.parse(html));
return text;
} | javascript | function innerText(html) {
var schema = new Schema(), domParser = new DomParser({}, schema), text = '';
var shortEndedElements = schema.getShortEndedElements();
var ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' ');
var blockElements = schema.getBlockElements();
function walk(node) {
var name = node.name, currentNode = node;
if (name === 'br') {
text += '\n';
return;
}
// img/input/hr
if (shortEndedElements[name]) {
text += ' ';
}
// Ingore script, video contents
if (ignoreElements[name]) {
text += ' ';
return;
}
if (node.type == 3) {
text += node.value;
}
// Walk all children
if (!node.shortEnded) {
if ((node = node.firstChild)) {
do {
walk(node);
} while ((node = node.next));
}
}
// Add \n or \n\n for blocks or P
if (blockElements[name] && currentNode.next) {
text += '\n';
if (name == 'p') {
text += '\n';
}
}
}
html = filter(html, [
/<!\[[^\]]+\]>/g // Conditional comments
]);
walk(domParser.parse(html));
return text;
} | [
"function",
"innerText",
"(",
"html",
")",
"{",
"var",
"schema",
"=",
"new",
"Schema",
"(",
")",
",",
"domParser",
"=",
"new",
"DomParser",
"(",
"{",
"}",
",",
"schema",
")",
",",
"text",
"=",
"''",
";",
"var",
"shortEndedElements",
"=",
"schema",
".",
"getShortEndedElements",
"(",
")",
";",
"var",
"ignoreElements",
"=",
"Tools",
".",
"makeMap",
"(",
"'script noscript style textarea video audio iframe object'",
",",
"' '",
")",
";",
"var",
"blockElements",
"=",
"schema",
".",
"getBlockElements",
"(",
")",
";",
"function",
"walk",
"(",
"node",
")",
"{",
"var",
"name",
"=",
"node",
".",
"name",
",",
"currentNode",
"=",
"node",
";",
"if",
"(",
"name",
"===",
"'br'",
")",
"{",
"text",
"+=",
"'\\n'",
";",
"return",
";",
"}",
"// img/input/hr",
"if",
"(",
"shortEndedElements",
"[",
"name",
"]",
")",
"{",
"text",
"+=",
"' '",
";",
"}",
"// Ingore script, video contents",
"if",
"(",
"ignoreElements",
"[",
"name",
"]",
")",
"{",
"text",
"+=",
"' '",
";",
"return",
";",
"}",
"if",
"(",
"node",
".",
"type",
"==",
"3",
")",
"{",
"text",
"+=",
"node",
".",
"value",
";",
"}",
"// Walk all children",
"if",
"(",
"!",
"node",
".",
"shortEnded",
")",
"{",
"if",
"(",
"(",
"node",
"=",
"node",
".",
"firstChild",
")",
")",
"{",
"do",
"{",
"walk",
"(",
"node",
")",
";",
"}",
"while",
"(",
"(",
"node",
"=",
"node",
".",
"next",
")",
")",
";",
"}",
"}",
"// Add \\n or \\n\\n for blocks or P",
"if",
"(",
"blockElements",
"[",
"name",
"]",
"&&",
"currentNode",
".",
"next",
")",
"{",
"text",
"+=",
"'\\n'",
";",
"if",
"(",
"name",
"==",
"'p'",
")",
"{",
"text",
"+=",
"'\\n'",
";",
"}",
"}",
"}",
"html",
"=",
"filter",
"(",
"html",
",",
"[",
"/",
"<!\\[[^\\]]+\\]>",
"/",
"g",
"// Conditional comments",
"]",
")",
";",
"walk",
"(",
"domParser",
".",
"parse",
"(",
"html",
")",
")",
";",
"return",
"text",
";",
"}"
] | Gets the innerText of the specified element. It will handle edge cases
and works better than textContent on Gecko.
@param {String} html HTML string to get text from.
@return {String} String of text with line feeds. | [
"Gets",
"the",
"innerText",
"of",
"the",
"specified",
"element",
".",
"It",
"will",
"handle",
"edge",
"cases",
"and",
"works",
"better",
"than",
"textContent",
"on",
"Gecko",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69341-L69396 |
48,378 | sadiqhabib/tinymce-dist | tinymce.full.js | pasteHtml | function pasteHtml(html, internalFlag) {
var args, dom = editor.dom, internal;
internal = internalFlag || InternalHtml.isMarked(html);
html = InternalHtml.unmark(html);
args = editor.fire('BeforePastePreProcess', { content: html, internal: internal }); // Internal event used by Quirks
args = editor.fire('PastePreProcess', args);
html = args.content;
if (!args.isDefaultPrevented()) {
// User has bound PastePostProcess events then we need to pass it through a DOM node
// This is not ideal but we don't want to let the browser mess up the HTML for example
// some browsers add to P tags etc
if (editor.hasEventListeners('PastePostProcess') && !args.isDefaultPrevented()) {
// We need to attach the element to the DOM so Sizzle selectors work on the contents
var tempBody = dom.add(editor.getBody(), 'div', { style: 'display:none' }, html);
args = editor.fire('PastePostProcess', { node: tempBody, internal: internal });
dom.remove(tempBody);
html = args.node.innerHTML;
}
if (!args.isDefaultPrevented()) {
SmartPaste.insertContent(editor, html);
}
}
} | javascript | function pasteHtml(html, internalFlag) {
var args, dom = editor.dom, internal;
internal = internalFlag || InternalHtml.isMarked(html);
html = InternalHtml.unmark(html);
args = editor.fire('BeforePastePreProcess', { content: html, internal: internal }); // Internal event used by Quirks
args = editor.fire('PastePreProcess', args);
html = args.content;
if (!args.isDefaultPrevented()) {
// User has bound PastePostProcess events then we need to pass it through a DOM node
// This is not ideal but we don't want to let the browser mess up the HTML for example
// some browsers add to P tags etc
if (editor.hasEventListeners('PastePostProcess') && !args.isDefaultPrevented()) {
// We need to attach the element to the DOM so Sizzle selectors work on the contents
var tempBody = dom.add(editor.getBody(), 'div', { style: 'display:none' }, html);
args = editor.fire('PastePostProcess', { node: tempBody, internal: internal });
dom.remove(tempBody);
html = args.node.innerHTML;
}
if (!args.isDefaultPrevented()) {
SmartPaste.insertContent(editor, html);
}
}
} | [
"function",
"pasteHtml",
"(",
"html",
",",
"internalFlag",
")",
"{",
"var",
"args",
",",
"dom",
"=",
"editor",
".",
"dom",
",",
"internal",
";",
"internal",
"=",
"internalFlag",
"||",
"InternalHtml",
".",
"isMarked",
"(",
"html",
")",
";",
"html",
"=",
"InternalHtml",
".",
"unmark",
"(",
"html",
")",
";",
"args",
"=",
"editor",
".",
"fire",
"(",
"'BeforePastePreProcess'",
",",
"{",
"content",
":",
"html",
",",
"internal",
":",
"internal",
"}",
")",
";",
"// Internal event used by Quirks",
"args",
"=",
"editor",
".",
"fire",
"(",
"'PastePreProcess'",
",",
"args",
")",
";",
"html",
"=",
"args",
".",
"content",
";",
"if",
"(",
"!",
"args",
".",
"isDefaultPrevented",
"(",
")",
")",
"{",
"// User has bound PastePostProcess events then we need to pass it through a DOM node",
"// This is not ideal but we don't want to let the browser mess up the HTML for example",
"// some browsers add to P tags etc",
"if",
"(",
"editor",
".",
"hasEventListeners",
"(",
"'PastePostProcess'",
")",
"&&",
"!",
"args",
".",
"isDefaultPrevented",
"(",
")",
")",
"{",
"// We need to attach the element to the DOM so Sizzle selectors work on the contents",
"var",
"tempBody",
"=",
"dom",
".",
"add",
"(",
"editor",
".",
"getBody",
"(",
")",
",",
"'div'",
",",
"{",
"style",
":",
"'display:none'",
"}",
",",
"html",
")",
";",
"args",
"=",
"editor",
".",
"fire",
"(",
"'PastePostProcess'",
",",
"{",
"node",
":",
"tempBody",
",",
"internal",
":",
"internal",
"}",
")",
";",
"dom",
".",
"remove",
"(",
"tempBody",
")",
";",
"html",
"=",
"args",
".",
"node",
".",
"innerHTML",
";",
"}",
"if",
"(",
"!",
"args",
".",
"isDefaultPrevented",
"(",
")",
")",
"{",
"SmartPaste",
".",
"insertContent",
"(",
"editor",
",",
"html",
")",
";",
"}",
"}",
"}"
] | Pastes the specified HTML. This means that the HTML is filtered and then
inserted at the current selection in the editor. It will also fire paste events
for custom user filtering.
@param {String} html HTML code to paste into the current selection.
@param {Boolean?} internalFlag Optional true/false flag if the contents is internal or external. | [
"Pastes",
"the",
"specified",
"HTML",
".",
"This",
"means",
"that",
"the",
"HTML",
"is",
"filtered",
"and",
"then",
"inserted",
"at",
"the",
"current",
"selection",
"in",
"the",
"editor",
".",
"It",
"will",
"also",
"fire",
"paste",
"events",
"for",
"custom",
"user",
"filtering",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69500-L69526 |
48,379 | sadiqhabib/tinymce-dist | tinymce.full.js | createPasteBin | function createPasteBin() {
var dom = editor.dom, body = editor.getBody();
var viewport = editor.dom.getViewPort(editor.getWin()), scrollTop = viewport.y, top = 20;
var scrollContainer;
lastRng = editor.selection.getRng();
if (editor.inline) {
scrollContainer = editor.selection.getScrollContainer();
// Can't always rely on scrollTop returning a useful value.
// It returns 0 if the browser doesn't support scrollTop for the element or is non-scrollable
if (scrollContainer && scrollContainer.scrollTop > 0) {
scrollTop = scrollContainer.scrollTop;
}
}
/**
* Returns the rect of the current caret if the caret is in an empty block before a
* BR we insert a temporary invisible character that we get the rect this way we always get a proper rect.
*
* TODO: This might be useful in core.
*/
function getCaretRect(rng) {
var rects, textNode, node, container = rng.startContainer;
rects = rng.getClientRects();
if (rects.length) {
return rects[0];
}
if (!rng.collapsed || container.nodeType != 1) {
return;
}
node = container.childNodes[lastRng.startOffset];
// Skip empty whitespace nodes
while (node && node.nodeType == 3 && !node.data.length) {
node = node.nextSibling;
}
if (!node) {
return;
}
// Check if the location is |<br>
// TODO: Might need to expand this to say |<table>
if (node.tagName == 'BR') {
textNode = dom.doc.createTextNode('\uFEFF');
node.parentNode.insertBefore(textNode, node);
rng = dom.createRng();
rng.setStartBefore(textNode);
rng.setEndAfter(textNode);
rects = rng.getClientRects();
dom.remove(textNode);
}
if (rects.length) {
return rects[0];
}
}
// Calculate top cordinate this is needed to avoid scrolling to top of document
// We want the paste bin to be as close to the caret as possible to avoid scrolling
if (lastRng.getClientRects) {
var rect = getCaretRect(lastRng);
if (rect) {
// Client rects gets us closes to the actual
// caret location in for example a wrapped paragraph block
top = scrollTop + (rect.top - dom.getPos(body).y);
} else {
top = scrollTop;
// Check if we can find a closer location by checking the range element
var container = lastRng.startContainer;
if (container) {
if (container.nodeType == 3 && container.parentNode != body) {
container = container.parentNode;
}
if (container.nodeType == 1) {
top = dom.getPos(container, scrollContainer || body).y;
}
}
}
}
// Create a pastebin
pasteBinElm = dom.add(editor.getBody(), 'div', {
id: "mcepastebin",
contentEditable: true,
"data-mce-bogus": "all",
style: 'position: absolute; top: ' + top + 'px;' +
'width: 10px; height: 10px; overflow: hidden; opacity: 0'
}, pasteBinDefaultContent);
// Move paste bin out of sight since the controlSelection rect gets displayed otherwise on IE and Gecko
if (Env.ie || Env.gecko) {
dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) == 'rtl' ? 0xFFFF : -0xFFFF);
}
// Prevent focus events from bubbeling fixed FocusManager issues
dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function (e) {
e.stopPropagation();
});
pasteBinElm.focus();
editor.selection.select(pasteBinElm, true);
} | javascript | function createPasteBin() {
var dom = editor.dom, body = editor.getBody();
var viewport = editor.dom.getViewPort(editor.getWin()), scrollTop = viewport.y, top = 20;
var scrollContainer;
lastRng = editor.selection.getRng();
if (editor.inline) {
scrollContainer = editor.selection.getScrollContainer();
// Can't always rely on scrollTop returning a useful value.
// It returns 0 if the browser doesn't support scrollTop for the element or is non-scrollable
if (scrollContainer && scrollContainer.scrollTop > 0) {
scrollTop = scrollContainer.scrollTop;
}
}
/**
* Returns the rect of the current caret if the caret is in an empty block before a
* BR we insert a temporary invisible character that we get the rect this way we always get a proper rect.
*
* TODO: This might be useful in core.
*/
function getCaretRect(rng) {
var rects, textNode, node, container = rng.startContainer;
rects = rng.getClientRects();
if (rects.length) {
return rects[0];
}
if (!rng.collapsed || container.nodeType != 1) {
return;
}
node = container.childNodes[lastRng.startOffset];
// Skip empty whitespace nodes
while (node && node.nodeType == 3 && !node.data.length) {
node = node.nextSibling;
}
if (!node) {
return;
}
// Check if the location is |<br>
// TODO: Might need to expand this to say |<table>
if (node.tagName == 'BR') {
textNode = dom.doc.createTextNode('\uFEFF');
node.parentNode.insertBefore(textNode, node);
rng = dom.createRng();
rng.setStartBefore(textNode);
rng.setEndAfter(textNode);
rects = rng.getClientRects();
dom.remove(textNode);
}
if (rects.length) {
return rects[0];
}
}
// Calculate top cordinate this is needed to avoid scrolling to top of document
// We want the paste bin to be as close to the caret as possible to avoid scrolling
if (lastRng.getClientRects) {
var rect = getCaretRect(lastRng);
if (rect) {
// Client rects gets us closes to the actual
// caret location in for example a wrapped paragraph block
top = scrollTop + (rect.top - dom.getPos(body).y);
} else {
top = scrollTop;
// Check if we can find a closer location by checking the range element
var container = lastRng.startContainer;
if (container) {
if (container.nodeType == 3 && container.parentNode != body) {
container = container.parentNode;
}
if (container.nodeType == 1) {
top = dom.getPos(container, scrollContainer || body).y;
}
}
}
}
// Create a pastebin
pasteBinElm = dom.add(editor.getBody(), 'div', {
id: "mcepastebin",
contentEditable: true,
"data-mce-bogus": "all",
style: 'position: absolute; top: ' + top + 'px;' +
'width: 10px; height: 10px; overflow: hidden; opacity: 0'
}, pasteBinDefaultContent);
// Move paste bin out of sight since the controlSelection rect gets displayed otherwise on IE and Gecko
if (Env.ie || Env.gecko) {
dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) == 'rtl' ? 0xFFFF : -0xFFFF);
}
// Prevent focus events from bubbeling fixed FocusManager issues
dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function (e) {
e.stopPropagation();
});
pasteBinElm.focus();
editor.selection.select(pasteBinElm, true);
} | [
"function",
"createPasteBin",
"(",
")",
"{",
"var",
"dom",
"=",
"editor",
".",
"dom",
",",
"body",
"=",
"editor",
".",
"getBody",
"(",
")",
";",
"var",
"viewport",
"=",
"editor",
".",
"dom",
".",
"getViewPort",
"(",
"editor",
".",
"getWin",
"(",
")",
")",
",",
"scrollTop",
"=",
"viewport",
".",
"y",
",",
"top",
"=",
"20",
";",
"var",
"scrollContainer",
";",
"lastRng",
"=",
"editor",
".",
"selection",
".",
"getRng",
"(",
")",
";",
"if",
"(",
"editor",
".",
"inline",
")",
"{",
"scrollContainer",
"=",
"editor",
".",
"selection",
".",
"getScrollContainer",
"(",
")",
";",
"// Can't always rely on scrollTop returning a useful value.",
"// It returns 0 if the browser doesn't support scrollTop for the element or is non-scrollable",
"if",
"(",
"scrollContainer",
"&&",
"scrollContainer",
".",
"scrollTop",
">",
"0",
")",
"{",
"scrollTop",
"=",
"scrollContainer",
".",
"scrollTop",
";",
"}",
"}",
"/**\n * Returns the rect of the current caret if the caret is in an empty block before a\n * BR we insert a temporary invisible character that we get the rect this way we always get a proper rect.\n *\n * TODO: This might be useful in core.\n */",
"function",
"getCaretRect",
"(",
"rng",
")",
"{",
"var",
"rects",
",",
"textNode",
",",
"node",
",",
"container",
"=",
"rng",
".",
"startContainer",
";",
"rects",
"=",
"rng",
".",
"getClientRects",
"(",
")",
";",
"if",
"(",
"rects",
".",
"length",
")",
"{",
"return",
"rects",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"!",
"rng",
".",
"collapsed",
"||",
"container",
".",
"nodeType",
"!=",
"1",
")",
"{",
"return",
";",
"}",
"node",
"=",
"container",
".",
"childNodes",
"[",
"lastRng",
".",
"startOffset",
"]",
";",
"// Skip empty whitespace nodes",
"while",
"(",
"node",
"&&",
"node",
".",
"nodeType",
"==",
"3",
"&&",
"!",
"node",
".",
"data",
".",
"length",
")",
"{",
"node",
"=",
"node",
".",
"nextSibling",
";",
"}",
"if",
"(",
"!",
"node",
")",
"{",
"return",
";",
"}",
"// Check if the location is |<br>",
"// TODO: Might need to expand this to say |<table>",
"if",
"(",
"node",
".",
"tagName",
"==",
"'BR'",
")",
"{",
"textNode",
"=",
"dom",
".",
"doc",
".",
"createTextNode",
"(",
"'\\uFEFF'",
")",
";",
"node",
".",
"parentNode",
".",
"insertBefore",
"(",
"textNode",
",",
"node",
")",
";",
"rng",
"=",
"dom",
".",
"createRng",
"(",
")",
";",
"rng",
".",
"setStartBefore",
"(",
"textNode",
")",
";",
"rng",
".",
"setEndAfter",
"(",
"textNode",
")",
";",
"rects",
"=",
"rng",
".",
"getClientRects",
"(",
")",
";",
"dom",
".",
"remove",
"(",
"textNode",
")",
";",
"}",
"if",
"(",
"rects",
".",
"length",
")",
"{",
"return",
"rects",
"[",
"0",
"]",
";",
"}",
"}",
"// Calculate top cordinate this is needed to avoid scrolling to top of document",
"// We want the paste bin to be as close to the caret as possible to avoid scrolling",
"if",
"(",
"lastRng",
".",
"getClientRects",
")",
"{",
"var",
"rect",
"=",
"getCaretRect",
"(",
"lastRng",
")",
";",
"if",
"(",
"rect",
")",
"{",
"// Client rects gets us closes to the actual",
"// caret location in for example a wrapped paragraph block",
"top",
"=",
"scrollTop",
"+",
"(",
"rect",
".",
"top",
"-",
"dom",
".",
"getPos",
"(",
"body",
")",
".",
"y",
")",
";",
"}",
"else",
"{",
"top",
"=",
"scrollTop",
";",
"// Check if we can find a closer location by checking the range element",
"var",
"container",
"=",
"lastRng",
".",
"startContainer",
";",
"if",
"(",
"container",
")",
"{",
"if",
"(",
"container",
".",
"nodeType",
"==",
"3",
"&&",
"container",
".",
"parentNode",
"!=",
"body",
")",
"{",
"container",
"=",
"container",
".",
"parentNode",
";",
"}",
"if",
"(",
"container",
".",
"nodeType",
"==",
"1",
")",
"{",
"top",
"=",
"dom",
".",
"getPos",
"(",
"container",
",",
"scrollContainer",
"||",
"body",
")",
".",
"y",
";",
"}",
"}",
"}",
"}",
"// Create a pastebin",
"pasteBinElm",
"=",
"dom",
".",
"add",
"(",
"editor",
".",
"getBody",
"(",
")",
",",
"'div'",
",",
"{",
"id",
":",
"\"mcepastebin\"",
",",
"contentEditable",
":",
"true",
",",
"\"data-mce-bogus\"",
":",
"\"all\"",
",",
"style",
":",
"'position: absolute; top: '",
"+",
"top",
"+",
"'px;'",
"+",
"'width: 10px; height: 10px; overflow: hidden; opacity: 0'",
"}",
",",
"pasteBinDefaultContent",
")",
";",
"// Move paste bin out of sight since the controlSelection rect gets displayed otherwise on IE and Gecko",
"if",
"(",
"Env",
".",
"ie",
"||",
"Env",
".",
"gecko",
")",
"{",
"dom",
".",
"setStyle",
"(",
"pasteBinElm",
",",
"'left'",
",",
"dom",
".",
"getStyle",
"(",
"body",
",",
"'direction'",
",",
"true",
")",
"==",
"'rtl'",
"?",
"0xFFFF",
":",
"-",
"0xFFFF",
")",
";",
"}",
"// Prevent focus events from bubbeling fixed FocusManager issues",
"dom",
".",
"bind",
"(",
"pasteBinElm",
",",
"'beforedeactivate focusin focusout'",
",",
"function",
"(",
"e",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"}",
")",
";",
"pasteBinElm",
".",
"focus",
"(",
")",
";",
"editor",
".",
"selection",
".",
"select",
"(",
"pasteBinElm",
",",
"true",
")",
";",
"}"
] | Creates a paste bin element as close as possible to the current caret location and places the focus inside that element
so that when the real paste event occurs the contents gets inserted into this element
instead of the current editor selection element. | [
"Creates",
"a",
"paste",
"bin",
"element",
"as",
"close",
"as",
"possible",
"to",
"the",
"current",
"caret",
"location",
"and",
"places",
"the",
"focus",
"inside",
"that",
"element",
"so",
"that",
"when",
"the",
"real",
"paste",
"event",
"occurs",
"the",
"contents",
"gets",
"inserted",
"into",
"this",
"element",
"instead",
"of",
"the",
"current",
"editor",
"selection",
"element",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69571-L69683 |
48,380 | sadiqhabib/tinymce-dist | tinymce.full.js | getCaretRect | function getCaretRect(rng) {
var rects, textNode, node, container = rng.startContainer;
rects = rng.getClientRects();
if (rects.length) {
return rects[0];
}
if (!rng.collapsed || container.nodeType != 1) {
return;
}
node = container.childNodes[lastRng.startOffset];
// Skip empty whitespace nodes
while (node && node.nodeType == 3 && !node.data.length) {
node = node.nextSibling;
}
if (!node) {
return;
}
// Check if the location is |<br>
// TODO: Might need to expand this to say |<table>
if (node.tagName == 'BR') {
textNode = dom.doc.createTextNode('\uFEFF');
node.parentNode.insertBefore(textNode, node);
rng = dom.createRng();
rng.setStartBefore(textNode);
rng.setEndAfter(textNode);
rects = rng.getClientRects();
dom.remove(textNode);
}
if (rects.length) {
return rects[0];
}
} | javascript | function getCaretRect(rng) {
var rects, textNode, node, container = rng.startContainer;
rects = rng.getClientRects();
if (rects.length) {
return rects[0];
}
if (!rng.collapsed || container.nodeType != 1) {
return;
}
node = container.childNodes[lastRng.startOffset];
// Skip empty whitespace nodes
while (node && node.nodeType == 3 && !node.data.length) {
node = node.nextSibling;
}
if (!node) {
return;
}
// Check if the location is |<br>
// TODO: Might need to expand this to say |<table>
if (node.tagName == 'BR') {
textNode = dom.doc.createTextNode('\uFEFF');
node.parentNode.insertBefore(textNode, node);
rng = dom.createRng();
rng.setStartBefore(textNode);
rng.setEndAfter(textNode);
rects = rng.getClientRects();
dom.remove(textNode);
}
if (rects.length) {
return rects[0];
}
} | [
"function",
"getCaretRect",
"(",
"rng",
")",
"{",
"var",
"rects",
",",
"textNode",
",",
"node",
",",
"container",
"=",
"rng",
".",
"startContainer",
";",
"rects",
"=",
"rng",
".",
"getClientRects",
"(",
")",
";",
"if",
"(",
"rects",
".",
"length",
")",
"{",
"return",
"rects",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"!",
"rng",
".",
"collapsed",
"||",
"container",
".",
"nodeType",
"!=",
"1",
")",
"{",
"return",
";",
"}",
"node",
"=",
"container",
".",
"childNodes",
"[",
"lastRng",
".",
"startOffset",
"]",
";",
"// Skip empty whitespace nodes",
"while",
"(",
"node",
"&&",
"node",
".",
"nodeType",
"==",
"3",
"&&",
"!",
"node",
".",
"data",
".",
"length",
")",
"{",
"node",
"=",
"node",
".",
"nextSibling",
";",
"}",
"if",
"(",
"!",
"node",
")",
"{",
"return",
";",
"}",
"// Check if the location is |<br>",
"// TODO: Might need to expand this to say |<table>",
"if",
"(",
"node",
".",
"tagName",
"==",
"'BR'",
")",
"{",
"textNode",
"=",
"dom",
".",
"doc",
".",
"createTextNode",
"(",
"'\\uFEFF'",
")",
";",
"node",
".",
"parentNode",
".",
"insertBefore",
"(",
"textNode",
",",
"node",
")",
";",
"rng",
"=",
"dom",
".",
"createRng",
"(",
")",
";",
"rng",
".",
"setStartBefore",
"(",
"textNode",
")",
";",
"rng",
".",
"setEndAfter",
"(",
"textNode",
")",
";",
"rects",
"=",
"rng",
".",
"getClientRects",
"(",
")",
";",
"dom",
".",
"remove",
"(",
"textNode",
")",
";",
"}",
"if",
"(",
"rects",
".",
"length",
")",
"{",
"return",
"rects",
"[",
"0",
"]",
";",
"}",
"}"
] | Returns the rect of the current caret if the caret is in an empty block before a
BR we insert a temporary invisible character that we get the rect this way we always get a proper rect.
TODO: This might be useful in core. | [
"Returns",
"the",
"rect",
"of",
"the",
"current",
"caret",
"if",
"the",
"caret",
"is",
"in",
"an",
"empty",
"block",
"before",
"a",
"BR",
"we",
"insert",
"a",
"temporary",
"invisible",
"character",
"that",
"we",
"get",
"the",
"rect",
"this",
"way",
"we",
"always",
"get",
"a",
"proper",
"rect",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69594-L69634 |
48,381 | sadiqhabib/tinymce-dist | tinymce.full.js | removePasteBin | function removePasteBin() {
if (pasteBinElm) {
var pasteBinClone;
// WebKit/Blink might clone the div so
// lets make sure we remove all clones
// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!
while ((pasteBinClone = editor.dom.get('mcepastebin'))) {
editor.dom.remove(pasteBinClone);
editor.dom.unbind(pasteBinClone);
}
if (lastRng) {
editor.selection.setRng(lastRng);
}
}
pasteBinElm = lastRng = null;
} | javascript | function removePasteBin() {
if (pasteBinElm) {
var pasteBinClone;
// WebKit/Blink might clone the div so
// lets make sure we remove all clones
// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!
while ((pasteBinClone = editor.dom.get('mcepastebin'))) {
editor.dom.remove(pasteBinClone);
editor.dom.unbind(pasteBinClone);
}
if (lastRng) {
editor.selection.setRng(lastRng);
}
}
pasteBinElm = lastRng = null;
} | [
"function",
"removePasteBin",
"(",
")",
"{",
"if",
"(",
"pasteBinElm",
")",
"{",
"var",
"pasteBinClone",
";",
"// WebKit/Blink might clone the div so",
"// lets make sure we remove all clones",
"// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!",
"while",
"(",
"(",
"pasteBinClone",
"=",
"editor",
".",
"dom",
".",
"get",
"(",
"'mcepastebin'",
")",
")",
")",
"{",
"editor",
".",
"dom",
".",
"remove",
"(",
"pasteBinClone",
")",
";",
"editor",
".",
"dom",
".",
"unbind",
"(",
"pasteBinClone",
")",
";",
"}",
"if",
"(",
"lastRng",
")",
"{",
"editor",
".",
"selection",
".",
"setRng",
"(",
"lastRng",
")",
";",
"}",
"}",
"pasteBinElm",
"=",
"lastRng",
"=",
"null",
";",
"}"
] | Removes the paste bin if it exists. | [
"Removes",
"the",
"paste",
"bin",
"if",
"it",
"exists",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69688-L69706 |
48,382 | sadiqhabib/tinymce-dist | tinymce.full.js | getPasteBinHtml | function getPasteBinHtml() {
var html = '', pasteBinClones, i, clone, cloneHtml;
// Since WebKit/Chrome might clone the paste bin when pasting
// for example: <img style="float: right"> we need to check if any of them contains some useful html.
// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!
pasteBinClones = editor.dom.select('div[id=mcepastebin]');
for (i = 0; i < pasteBinClones.length; i++) {
clone = pasteBinClones[i];
// Pasting plain text produces pastebins in pastebinds makes sence right!?
if (clone.firstChild && clone.firstChild.id == 'mcepastebin') {
clone = clone.firstChild;
}
cloneHtml = clone.innerHTML;
if (html != pasteBinDefaultContent) {
html += cloneHtml;
}
}
return html;
} | javascript | function getPasteBinHtml() {
var html = '', pasteBinClones, i, clone, cloneHtml;
// Since WebKit/Chrome might clone the paste bin when pasting
// for example: <img style="float: right"> we need to check if any of them contains some useful html.
// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!
pasteBinClones = editor.dom.select('div[id=mcepastebin]');
for (i = 0; i < pasteBinClones.length; i++) {
clone = pasteBinClones[i];
// Pasting plain text produces pastebins in pastebinds makes sence right!?
if (clone.firstChild && clone.firstChild.id == 'mcepastebin') {
clone = clone.firstChild;
}
cloneHtml = clone.innerHTML;
if (html != pasteBinDefaultContent) {
html += cloneHtml;
}
}
return html;
} | [
"function",
"getPasteBinHtml",
"(",
")",
"{",
"var",
"html",
"=",
"''",
",",
"pasteBinClones",
",",
"i",
",",
"clone",
",",
"cloneHtml",
";",
"// Since WebKit/Chrome might clone the paste bin when pasting",
"// for example: <img style=\"float: right\"> we need to check if any of them contains some useful html.",
"// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!",
"pasteBinClones",
"=",
"editor",
".",
"dom",
".",
"select",
"(",
"'div[id=mcepastebin]'",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"pasteBinClones",
".",
"length",
";",
"i",
"++",
")",
"{",
"clone",
"=",
"pasteBinClones",
"[",
"i",
"]",
";",
"// Pasting plain text produces pastebins in pastebinds makes sence right!?",
"if",
"(",
"clone",
".",
"firstChild",
"&&",
"clone",
".",
"firstChild",
".",
"id",
"==",
"'mcepastebin'",
")",
"{",
"clone",
"=",
"clone",
".",
"firstChild",
";",
"}",
"cloneHtml",
"=",
"clone",
".",
"innerHTML",
";",
"if",
"(",
"html",
"!=",
"pasteBinDefaultContent",
")",
"{",
"html",
"+=",
"cloneHtml",
";",
"}",
"}",
"return",
"html",
";",
"}"
] | Returns the contents of the paste bin as a HTML string.
@return {String} Get the contents of the paste bin. | [
"Returns",
"the",
"contents",
"of",
"the",
"paste",
"bin",
"as",
"a",
"HTML",
"string",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69713-L69735 |
48,383 | sadiqhabib/tinymce-dist | tinymce.full.js | pasteImageData | function pasteImageData(e, rng) {
var dataTransfer = e.clipboardData || e.dataTransfer;
function processItems(items) {
var i, item, reader, hadImage = false;
if (items) {
for (i = 0; i < items.length; i++) {
item = items[i];
if (/^image\/(jpeg|png|gif|bmp)$/.test(item.type)) {
var blob = item.getAsFile ? item.getAsFile() : item;
reader = new FileReader();
reader.onload = pasteImage.bind(null, rng, reader, blob);
reader.readAsDataURL(blob);
e.preventDefault();
hadImage = true;
}
}
}
return hadImage;
}
if (editor.settings.paste_data_images && dataTransfer) {
return processItems(dataTransfer.items) || processItems(dataTransfer.files);
}
} | javascript | function pasteImageData(e, rng) {
var dataTransfer = e.clipboardData || e.dataTransfer;
function processItems(items) {
var i, item, reader, hadImage = false;
if (items) {
for (i = 0; i < items.length; i++) {
item = items[i];
if (/^image\/(jpeg|png|gif|bmp)$/.test(item.type)) {
var blob = item.getAsFile ? item.getAsFile() : item;
reader = new FileReader();
reader.onload = pasteImage.bind(null, rng, reader, blob);
reader.readAsDataURL(blob);
e.preventDefault();
hadImage = true;
}
}
}
return hadImage;
}
if (editor.settings.paste_data_images && dataTransfer) {
return processItems(dataTransfer.items) || processItems(dataTransfer.files);
}
} | [
"function",
"pasteImageData",
"(",
"e",
",",
"rng",
")",
"{",
"var",
"dataTransfer",
"=",
"e",
".",
"clipboardData",
"||",
"e",
".",
"dataTransfer",
";",
"function",
"processItems",
"(",
"items",
")",
"{",
"var",
"i",
",",
"item",
",",
"reader",
",",
"hadImage",
"=",
"false",
";",
"if",
"(",
"items",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"items",
".",
"length",
";",
"i",
"++",
")",
"{",
"item",
"=",
"items",
"[",
"i",
"]",
";",
"if",
"(",
"/",
"^image\\/(jpeg|png|gif|bmp)$",
"/",
".",
"test",
"(",
"item",
".",
"type",
")",
")",
"{",
"var",
"blob",
"=",
"item",
".",
"getAsFile",
"?",
"item",
".",
"getAsFile",
"(",
")",
":",
"item",
";",
"reader",
"=",
"new",
"FileReader",
"(",
")",
";",
"reader",
".",
"onload",
"=",
"pasteImage",
".",
"bind",
"(",
"null",
",",
"rng",
",",
"reader",
",",
"blob",
")",
";",
"reader",
".",
"readAsDataURL",
"(",
"blob",
")",
";",
"e",
".",
"preventDefault",
"(",
")",
";",
"hadImage",
"=",
"true",
";",
"}",
"}",
"}",
"return",
"hadImage",
";",
"}",
"if",
"(",
"editor",
".",
"settings",
".",
"paste_data_images",
"&&",
"dataTransfer",
")",
"{",
"return",
"processItems",
"(",
"dataTransfer",
".",
"items",
")",
"||",
"processItems",
"(",
"dataTransfer",
".",
"files",
")",
";",
"}",
"}"
] | Checks if the clipboard contains image data if it does it will take that data
and convert it into a data url image and paste that image at the caret location.
@param {ClipboardEvent} e Paste/drop event object.
@param {DOMRange} rng Rng object to move selection to.
@return {Boolean} true/false if the image data was found or not. | [
"Checks",
"if",
"the",
"clipboard",
"contains",
"image",
"data",
"if",
"it",
"does",
"it",
"will",
"take",
"that",
"data",
"and",
"convert",
"it",
"into",
"a",
"data",
"url",
"image",
"and",
"paste",
"that",
"image",
"at",
"the",
"caret",
"location",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69840-L69869 |
48,384 | sadiqhabib/tinymce-dist | tinymce.full.js | isBrokenAndroidClipboardEvent | function isBrokenAndroidClipboardEvent(e) {
var clipboardData = e.clipboardData;
return navigator.userAgent.indexOf('Android') != -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
} | javascript | function isBrokenAndroidClipboardEvent(e) {
var clipboardData = e.clipboardData;
return navigator.userAgent.indexOf('Android') != -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
} | [
"function",
"isBrokenAndroidClipboardEvent",
"(",
"e",
")",
"{",
"var",
"clipboardData",
"=",
"e",
".",
"clipboardData",
";",
"return",
"navigator",
".",
"userAgent",
".",
"indexOf",
"(",
"'Android'",
")",
"!=",
"-",
"1",
"&&",
"clipboardData",
"&&",
"clipboardData",
".",
"items",
"&&",
"clipboardData",
".",
"items",
".",
"length",
"===",
"0",
";",
"}"
] | Chrome on Android doesn't support proper clipboard access so we have no choice but to allow the browser default behavior.
@param {Event} e Paste event object to check if it contains any data.
@return {Boolean} true/false if the clipboard is empty or not. | [
"Chrome",
"on",
"Android",
"doesn",
"t",
"support",
"proper",
"clipboard",
"access",
"so",
"we",
"have",
"no",
"choice",
"but",
"to",
"allow",
"the",
"browser",
"default",
"behavior",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69877-L69881 |
48,385 | sadiqhabib/tinymce-dist | tinymce.full.js | isNumericList | function isNumericList(text) {
var found, patterns;
patterns = [
/^[IVXLMCD]{1,2}\.[ \u00a0]/, // Roman upper case
/^[ivxlmcd]{1,2}\.[ \u00a0]/, // Roman lower case
/^[a-z]{1,2}[\.\)][ \u00a0]/, // Alphabetical a-z
/^[A-Z]{1,2}[\.\)][ \u00a0]/, // Alphabetical A-Z
/^[0-9]+\.[ \u00a0]/, // Numeric lists
/^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/, // Japanese
/^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/ // Chinese
];
text = text.replace(/^[\u00a0 ]+/, '');
Tools.each(patterns, function (pattern) {
if (pattern.test(text)) {
found = true;
return false;
}
});
return found;
} | javascript | function isNumericList(text) {
var found, patterns;
patterns = [
/^[IVXLMCD]{1,2}\.[ \u00a0]/, // Roman upper case
/^[ivxlmcd]{1,2}\.[ \u00a0]/, // Roman lower case
/^[a-z]{1,2}[\.\)][ \u00a0]/, // Alphabetical a-z
/^[A-Z]{1,2}[\.\)][ \u00a0]/, // Alphabetical A-Z
/^[0-9]+\.[ \u00a0]/, // Numeric lists
/^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/, // Japanese
/^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/ // Chinese
];
text = text.replace(/^[\u00a0 ]+/, '');
Tools.each(patterns, function (pattern) {
if (pattern.test(text)) {
found = true;
return false;
}
});
return found;
} | [
"function",
"isNumericList",
"(",
"text",
")",
"{",
"var",
"found",
",",
"patterns",
";",
"patterns",
"=",
"[",
"/",
"^[IVXLMCD]{1,2}\\.[ \\u00a0]",
"/",
",",
"// Roman upper case",
"/",
"^[ivxlmcd]{1,2}\\.[ \\u00a0]",
"/",
",",
"// Roman lower case",
"/",
"^[a-z]{1,2}[\\.\\)][ \\u00a0]",
"/",
",",
"// Alphabetical a-z",
"/",
"^[A-Z]{1,2}[\\.\\)][ \\u00a0]",
"/",
",",
"// Alphabetical A-Z",
"/",
"^[0-9]+\\.[ \\u00a0]",
"/",
",",
"// Numeric lists",
"/",
"^[\\u3007\\u4e00\\u4e8c\\u4e09\\u56db\\u4e94\\u516d\\u4e03\\u516b\\u4e5d]+\\.[ \\u00a0]",
"/",
",",
"// Japanese",
"/",
"^[\\u58f1\\u5f10\\u53c2\\u56db\\u4f0d\\u516d\\u4e03\\u516b\\u4e5d\\u62fe]+\\.[ \\u00a0]",
"/",
"// Chinese",
"]",
";",
"text",
"=",
"text",
".",
"replace",
"(",
"/",
"^[\\u00a0 ]+",
"/",
",",
"''",
")",
";",
"Tools",
".",
"each",
"(",
"patterns",
",",
"function",
"(",
"pattern",
")",
"{",
"if",
"(",
"pattern",
".",
"test",
"(",
"text",
")",
")",
"{",
"found",
"=",
"true",
";",
"return",
"false",
";",
"}",
"}",
")",
";",
"return",
"found",
";",
"}"
] | Checks if the specified text starts with "1. " or "a. " etc. | [
"Checks",
"if",
"the",
"specified",
"text",
"starts",
"with",
"1",
".",
"or",
"a",
".",
"etc",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L70245-L70268 |
48,386 | sadiqhabib/tinymce-dist | tinymce.full.js | removeExplorerBrElementsAfterBlocks | function removeExplorerBrElementsAfterBlocks(html) {
// Only filter word specific content
if (!WordFilter.isWordContent(html)) {
return html;
}
// Produce block regexp based on the block elements in schema
var blockElements = [];
Tools.each(editor.schema.getBlockElements(), function (block, blockName) {
blockElements.push(blockName);
});
var explorerBlocksRegExp = new RegExp(
'(?:<br> [\\s\\r\\n]+|<br>)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:<br> [\\s\\r\\n]+|<br>)*',
'g'
);
// Remove BR:s from: <BLOCK>X</BLOCK><BR>
html = Utils.filter(html, [
[explorerBlocksRegExp, '$1']
]);
// IE9 also adds an extra BR element for each soft-linefeed and it also adds a BR for each word wrap break
html = Utils.filter(html, [
[/<br><br>/g, '<BR><BR>'], // Replace multiple BR elements with uppercase BR to keep them intact
[/<br>/g, ' '], // Replace single br elements with space since they are word wrap BR:s
[/<BR><BR>/g, '<br>'] // Replace back the double brs but into a single BR
]);
return html;
} | javascript | function removeExplorerBrElementsAfterBlocks(html) {
// Only filter word specific content
if (!WordFilter.isWordContent(html)) {
return html;
}
// Produce block regexp based on the block elements in schema
var blockElements = [];
Tools.each(editor.schema.getBlockElements(), function (block, blockName) {
blockElements.push(blockName);
});
var explorerBlocksRegExp = new RegExp(
'(?:<br> [\\s\\r\\n]+|<br>)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:<br> [\\s\\r\\n]+|<br>)*',
'g'
);
// Remove BR:s from: <BLOCK>X</BLOCK><BR>
html = Utils.filter(html, [
[explorerBlocksRegExp, '$1']
]);
// IE9 also adds an extra BR element for each soft-linefeed and it also adds a BR for each word wrap break
html = Utils.filter(html, [
[/<br><br>/g, '<BR><BR>'], // Replace multiple BR elements with uppercase BR to keep them intact
[/<br>/g, ' '], // Replace single br elements with space since they are word wrap BR:s
[/<BR><BR>/g, '<br>'] // Replace back the double brs but into a single BR
]);
return html;
} | [
"function",
"removeExplorerBrElementsAfterBlocks",
"(",
"html",
")",
"{",
"// Only filter word specific content",
"if",
"(",
"!",
"WordFilter",
".",
"isWordContent",
"(",
"html",
")",
")",
"{",
"return",
"html",
";",
"}",
"// Produce block regexp based on the block elements in schema",
"var",
"blockElements",
"=",
"[",
"]",
";",
"Tools",
".",
"each",
"(",
"editor",
".",
"schema",
".",
"getBlockElements",
"(",
")",
",",
"function",
"(",
"block",
",",
"blockName",
")",
"{",
"blockElements",
".",
"push",
"(",
"blockName",
")",
";",
"}",
")",
";",
"var",
"explorerBlocksRegExp",
"=",
"new",
"RegExp",
"(",
"'(?:<br> [\\\\s\\\\r\\\\n]+|<br>)*(<\\\\/?('",
"+",
"blockElements",
".",
"join",
"(",
"'|'",
")",
"+",
"')[^>]*>)(?:<br> [\\\\s\\\\r\\\\n]+|<br>)*'",
",",
"'g'",
")",
";",
"// Remove BR:s from: <BLOCK>X</BLOCK><BR>",
"html",
"=",
"Utils",
".",
"filter",
"(",
"html",
",",
"[",
"[",
"explorerBlocksRegExp",
",",
"'$1'",
"]",
"]",
")",
";",
"// IE9 also adds an extra BR element for each soft-linefeed and it also adds a BR for each word wrap break",
"html",
"=",
"Utils",
".",
"filter",
"(",
"html",
",",
"[",
"[",
"/",
"<br><br>",
"/",
"g",
",",
"'<BR><BR>'",
"]",
",",
"// Replace multiple BR elements with uppercase BR to keep them intact",
"[",
"/",
"<br>",
"/",
"g",
",",
"' '",
"]",
",",
"// Replace single br elements with space since they are word wrap BR:s",
"[",
"/",
"<BR><BR>",
"/",
"g",
",",
"'<br>'",
"]",
"// Replace back the double brs but into a single BR",
"]",
")",
";",
"return",
"html",
";",
"}"
] | Removes BR elements after block elements. IE9 has a nasty bug where it puts a BR element after each
block element when pasting from word. This removes those elements.
This:
<p>a</p><br><p>b</p>
Becomes:
<p>a</p><p>b</p> | [
"Removes",
"BR",
"elements",
"after",
"block",
"elements",
".",
"IE9",
"has",
"a",
"nasty",
"bug",
"where",
"it",
"puts",
"a",
"BR",
"element",
"after",
"each",
"block",
"element",
"when",
"pasting",
"from",
"word",
".",
"This",
"removes",
"those",
"elements",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L70761-L70792 |
48,387 | sadiqhabib/tinymce-dist | tinymce.full.js | getPatterns | function getPatterns() {
if (isPatternsDirty) {
patterns.sort(function (a, b) {
if (a.start.length > b.start.length) {
return -1;
}
if (a.start.length < b.start.length) {
return 1;
}
return 0;
});
isPatternsDirty = false;
}
return patterns;
} | javascript | function getPatterns() {
if (isPatternsDirty) {
patterns.sort(function (a, b) {
if (a.start.length > b.start.length) {
return -1;
}
if (a.start.length < b.start.length) {
return 1;
}
return 0;
});
isPatternsDirty = false;
}
return patterns;
} | [
"function",
"getPatterns",
"(",
")",
"{",
"if",
"(",
"isPatternsDirty",
")",
"{",
"patterns",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"a",
".",
"start",
".",
"length",
">",
"b",
".",
"start",
".",
"length",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"a",
".",
"start",
".",
"length",
"<",
"b",
".",
"start",
".",
"length",
")",
"{",
"return",
"1",
";",
"}",
"return",
"0",
";",
"}",
")",
";",
"isPatternsDirty",
"=",
"false",
";",
"}",
"return",
"patterns",
";",
"}"
] | Returns a sorted patterns list, ordered descending by start length | [
"Returns",
"a",
"sorted",
"patterns",
"list",
"ordered",
"descending",
"by",
"start",
"length"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L71984-L72002 |
48,388 | sadiqhabib/tinymce-dist | tinymce.full.js | findPattern | function findPattern(text) {
var patterns = getPatterns();
for (var i = 0; i < patterns.length; i++) {
if (text.indexOf(patterns[i].start) !== 0) {
continue;
}
if (patterns[i].end && text.lastIndexOf(patterns[i].end) != text.length - patterns[i].end.length) {
continue;
}
return patterns[i];
}
} | javascript | function findPattern(text) {
var patterns = getPatterns();
for (var i = 0; i < patterns.length; i++) {
if (text.indexOf(patterns[i].start) !== 0) {
continue;
}
if (patterns[i].end && text.lastIndexOf(patterns[i].end) != text.length - patterns[i].end.length) {
continue;
}
return patterns[i];
}
} | [
"function",
"findPattern",
"(",
"text",
")",
"{",
"var",
"patterns",
"=",
"getPatterns",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"patterns",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"text",
".",
"indexOf",
"(",
"patterns",
"[",
"i",
"]",
".",
"start",
")",
"!==",
"0",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"patterns",
"[",
"i",
"]",
".",
"end",
"&&",
"text",
".",
"lastIndexOf",
"(",
"patterns",
"[",
"i",
"]",
".",
"end",
")",
"!=",
"text",
".",
"length",
"-",
"patterns",
"[",
"i",
"]",
".",
"end",
".",
"length",
")",
"{",
"continue",
";",
"}",
"return",
"patterns",
"[",
"i",
"]",
";",
"}",
"}"
] | Finds a matching pattern to the specified text | [
"Finds",
"a",
"matching",
"pattern",
"to",
"the",
"specified",
"text"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L72005-L72019 |
48,389 | sadiqhabib/tinymce-dist | tinymce.full.js | findEndPattern | function findEndPattern(text, offset, delta) {
var patterns, pattern, i;
// Find best matching end
patterns = getPatterns();
for (i = 0; i < patterns.length; i++) {
pattern = patterns[i];
if (pattern.end && text.substr(offset - pattern.end.length - delta, pattern.end.length) == pattern.end) {
return pattern;
}
}
} | javascript | function findEndPattern(text, offset, delta) {
var patterns, pattern, i;
// Find best matching end
patterns = getPatterns();
for (i = 0; i < patterns.length; i++) {
pattern = patterns[i];
if (pattern.end && text.substr(offset - pattern.end.length - delta, pattern.end.length) == pattern.end) {
return pattern;
}
}
} | [
"function",
"findEndPattern",
"(",
"text",
",",
"offset",
",",
"delta",
")",
"{",
"var",
"patterns",
",",
"pattern",
",",
"i",
";",
"// Find best matching end",
"patterns",
"=",
"getPatterns",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"patterns",
".",
"length",
";",
"i",
"++",
")",
"{",
"pattern",
"=",
"patterns",
"[",
"i",
"]",
";",
"if",
"(",
"pattern",
".",
"end",
"&&",
"text",
".",
"substr",
"(",
"offset",
"-",
"pattern",
".",
"end",
".",
"length",
"-",
"delta",
",",
"pattern",
".",
"end",
".",
"length",
")",
"==",
"pattern",
".",
"end",
")",
"{",
"return",
"pattern",
";",
"}",
"}",
"}"
] | Finds the best matching end pattern | [
"Finds",
"the",
"best",
"matching",
"end",
"pattern"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L72022-L72033 |
48,390 | tenorviol/xjs | lib/xjs.js | interpret | function interpret(source) {
var tree = parser.parse(source);
var js = [
'module.exports = function (out, globals) {',
' var end = false;',
' if (Object.getPrototypeOf(out) !== module.xjs.XjsStream.prototype) {',
' out = new module.xjs.XjsStream(out);',
' end = true;',
' }',
' if (globals && typeof globals.length === "number" && typeof globals !== "string") {',
' var callee = arguments.callee;',
' for (var i in globals) {',
' callee.call(this, out, globals[i]);',
' }',
' return;',
' }',
' globals = globals || {};',
' with (globals) {'
];
interpretChildren(js, tree, ' ');
js.push(
' }',
' if (end) {',
' out.end();',
' }',
'}'
);
js = js.join('\n');
return js;
} | javascript | function interpret(source) {
var tree = parser.parse(source);
var js = [
'module.exports = function (out, globals) {',
' var end = false;',
' if (Object.getPrototypeOf(out) !== module.xjs.XjsStream.prototype) {',
' out = new module.xjs.XjsStream(out);',
' end = true;',
' }',
' if (globals && typeof globals.length === "number" && typeof globals !== "string") {',
' var callee = arguments.callee;',
' for (var i in globals) {',
' callee.call(this, out, globals[i]);',
' }',
' return;',
' }',
' globals = globals || {};',
' with (globals) {'
];
interpretChildren(js, tree, ' ');
js.push(
' }',
' if (end) {',
' out.end();',
' }',
'}'
);
js = js.join('\n');
return js;
} | [
"function",
"interpret",
"(",
"source",
")",
"{",
"var",
"tree",
"=",
"parser",
".",
"parse",
"(",
"source",
")",
";",
"var",
"js",
"=",
"[",
"'module.exports = function (out, globals) {'",
",",
"' var end = false;'",
",",
"' if (Object.getPrototypeOf(out) !== module.xjs.XjsStream.prototype) {'",
",",
"' out = new module.xjs.XjsStream(out);'",
",",
"' end = true;'",
",",
"' }'",
",",
"' if (globals && typeof globals.length === \"number\" && typeof globals !== \"string\") {'",
",",
"' var callee = arguments.callee;'",
",",
"' for (var i in globals) {'",
",",
"' callee.call(this, out, globals[i]);'",
",",
"' }'",
",",
"' return;'",
",",
"' }'",
",",
"' globals = globals || {};'",
",",
"' with (globals) {'",
"]",
";",
"interpretChildren",
"(",
"js",
",",
"tree",
",",
"' '",
")",
";",
"js",
".",
"push",
"(",
"' }'",
",",
"' if (end) {'",
",",
"' out.end();'",
",",
"' }'",
",",
"'}'",
")",
";",
"js",
"=",
"js",
".",
"join",
"(",
"'\\n'",
")",
";",
"return",
"js",
";",
"}"
] | Convert xjs source into javascript. | [
"Convert",
"xjs",
"source",
"into",
"javascript",
"."
] | 1f0744354b311066d6e58d11f9f5c602dae926af | https://github.com/tenorviol/xjs/blob/1f0744354b311066d6e58d11f9f5c602dae926af/lib/xjs.js#L51-L80 |
48,391 | princed/grunt-csswring | tasks/csswring.js | getMapOption | function getMapOption(from) {
if (typeof options.map === 'string') {
var mapPath = options.map + path.basename(from) + '.map';
if (grunt.file.exists(mapPath)) {
return grunt.file.read(mapPath);
}
}
return options.map;
} | javascript | function getMapOption(from) {
if (typeof options.map === 'string') {
var mapPath = options.map + path.basename(from) + '.map';
if (grunt.file.exists(mapPath)) {
return grunt.file.read(mapPath);
}
}
return options.map;
} | [
"function",
"getMapOption",
"(",
"from",
")",
"{",
"if",
"(",
"typeof",
"options",
".",
"map",
"===",
"'string'",
")",
"{",
"var",
"mapPath",
"=",
"options",
".",
"map",
"+",
"path",
".",
"basename",
"(",
"from",
")",
"+",
"'.map'",
";",
"if",
"(",
"grunt",
".",
"file",
".",
"exists",
"(",
"mapPath",
")",
")",
"{",
"return",
"grunt",
".",
"file",
".",
"read",
"(",
"mapPath",
")",
";",
"}",
"}",
"return",
"options",
".",
"map",
";",
"}"
] | Returns an input source map if a map path was specified
or options.map value otherwise
@param {string} from
@returns {string|boolean|undefined} | [
"Returns",
"an",
"input",
"source",
"map",
"if",
"a",
"map",
"path",
"was",
"specified",
"or",
"options",
".",
"map",
"value",
"otherwise"
] | db199bde5b23b3abc6c3b43f4fe83e65fd765ac5 | https://github.com/princed/grunt-csswring/blob/db199bde5b23b3abc6c3b43f4fe83e65fd765ac5/tasks/csswring.js#L20-L30 |
48,392 | princed/grunt-csswring | tasks/csswring.js | setBanner | function setBanner(text) {
return function(css) {
css.prepend(postcss.comment({ text: text }));
// New line after banner
if (css.rules[1]) {
css.rules[1].before = '\n';
}
};
} | javascript | function setBanner(text) {
return function(css) {
css.prepend(postcss.comment({ text: text }));
// New line after banner
if (css.rules[1]) {
css.rules[1].before = '\n';
}
};
} | [
"function",
"setBanner",
"(",
"text",
")",
"{",
"return",
"function",
"(",
"css",
")",
"{",
"css",
".",
"prepend",
"(",
"postcss",
".",
"comment",
"(",
"{",
"text",
":",
"text",
"}",
")",
")",
";",
"// New line after banner",
"if",
"(",
"css",
".",
"rules",
"[",
"1",
"]",
")",
"{",
"css",
".",
"rules",
"[",
"1",
"]",
".",
"before",
"=",
"'\\n'",
";",
"}",
"}",
";",
"}"
] | Setup banner processor
@param {string} text
@returns {Function} | [
"Setup",
"banner",
"processor"
] | db199bde5b23b3abc6c3b43f4fe83e65fd765ac5 | https://github.com/princed/grunt-csswring/blob/db199bde5b23b3abc6c3b43f4fe83e65fd765ac5/tasks/csswring.js#L37-L46 |
48,393 | anyfs/anyfs | lib/plugins/core/move.js | move | function move(fs, a, b, method, cb) {
var parentA = path.dirname(a);
var parentB = path.dirname(b);
var nameA = path.basename(a);
var nameB = path.basename(b)
fs.metadata(a)
.then(function(metadata) {
return this.metadata(b)
.then(function(metadata) {
throw fs.error('EEXIST', 'Cannot move because target path already exist: ' + b);
}, function(err) {
if (err.code === 'ENOENT') {
return this.mkdir(parentB);
} else {
throw err;
}
});
})
.then(function() {
return this._promise(method, a, b);
})
.done(function() {
cb();
}, function(err) {
cb(err);
});
} | javascript | function move(fs, a, b, method, cb) {
var parentA = path.dirname(a);
var parentB = path.dirname(b);
var nameA = path.basename(a);
var nameB = path.basename(b)
fs.metadata(a)
.then(function(metadata) {
return this.metadata(b)
.then(function(metadata) {
throw fs.error('EEXIST', 'Cannot move because target path already exist: ' + b);
}, function(err) {
if (err.code === 'ENOENT') {
return this.mkdir(parentB);
} else {
throw err;
}
});
})
.then(function() {
return this._promise(method, a, b);
})
.done(function() {
cb();
}, function(err) {
cb(err);
});
} | [
"function",
"move",
"(",
"fs",
",",
"a",
",",
"b",
",",
"method",
",",
"cb",
")",
"{",
"var",
"parentA",
"=",
"path",
".",
"dirname",
"(",
"a",
")",
";",
"var",
"parentB",
"=",
"path",
".",
"dirname",
"(",
"b",
")",
";",
"var",
"nameA",
"=",
"path",
".",
"basename",
"(",
"a",
")",
";",
"var",
"nameB",
"=",
"path",
".",
"basename",
"(",
"b",
")",
"fs",
".",
"metadata",
"(",
"a",
")",
".",
"then",
"(",
"function",
"(",
"metadata",
")",
"{",
"return",
"this",
".",
"metadata",
"(",
"b",
")",
".",
"then",
"(",
"function",
"(",
"metadata",
")",
"{",
"throw",
"fs",
".",
"error",
"(",
"'EEXIST'",
",",
"'Cannot move because target path already exist: '",
"+",
"b",
")",
";",
"}",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
".",
"code",
"===",
"'ENOENT'",
")",
"{",
"return",
"this",
".",
"mkdir",
"(",
"parentB",
")",
";",
"}",
"else",
"{",
"throw",
"err",
";",
"}",
"}",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"this",
".",
"_promise",
"(",
"method",
",",
"a",
",",
"b",
")",
";",
"}",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"cb",
"(",
")",
";",
"}",
",",
"function",
"(",
"err",
")",
"{",
"cb",
"(",
"err",
")",
";",
"}",
")",
";",
"}"
] | move file or directory - expensive way. | [
"move",
"file",
"or",
"directory",
"-",
"expensive",
"way",
"."
] | bbaec164fd74cbc977245af45b0b1e3d0772b6ff | https://github.com/anyfs/anyfs/blob/bbaec164fd74cbc977245af45b0b1e3d0772b6ff/lib/plugins/core/move.js#L7-L34 |
48,394 | caridy/es6-module-transpiler-system-formatter | lib/replacement.js | Replacement | function Replacement(nodePath, nodes) {
this.queue = [];
if (nodePath && nodes) {
this.queue.push([nodePath, nodes]);
}
} | javascript | function Replacement(nodePath, nodes) {
this.queue = [];
if (nodePath && nodes) {
this.queue.push([nodePath, nodes]);
}
} | [
"function",
"Replacement",
"(",
"nodePath",
",",
"nodes",
")",
"{",
"this",
".",
"queue",
"=",
"[",
"]",
";",
"if",
"(",
"nodePath",
"&&",
"nodes",
")",
"{",
"this",
".",
"queue",
".",
"push",
"(",
"[",
"nodePath",
",",
"nodes",
"]",
")",
";",
"}",
"}"
] | Represents a replacement of a node path with zero or more nodes.
@constructor
@param {ast-types.NodePath} nodePath
@param {Array.<ast-types.Node>} nodes | [
"Represents",
"a",
"replacement",
"of",
"a",
"node",
"path",
"with",
"zero",
"or",
"more",
"nodes",
"."
] | c6da4fb8319c057e52188b0dc2bd2dd648dcef05 | https://github.com/caridy/es6-module-transpiler-system-formatter/blob/c6da4fb8319c057e52188b0dc2bd2dd648dcef05/lib/replacement.js#L11-L16 |
48,395 | rtm/upward | src/Tst.js | consoleReporter | function consoleReporter(reports, options = {}) {
var hide = options.hide || {};
(function _consoleReporter(reports) {
reports.forEach(
({children, desc, status, counts, time, code, error}) => {
let countStr = makeCounts(counts);
let color = statusInfo[status].color;
let colorStr = `color: ${color}`;
if (children) {
let msg = desc;
let collapse = hide.children || hide.passed && status === 'pass';
if (!hide.counts) { msg = `${msg} (${countStr})`; }
console[collapse ? 'groupCollapsed' : 'group']('%c' + msg, colorStr);
_consoleReporter(children);
console.groupEnd();
} else {
if (error) console.log('%c %s (%O)', colorStr, desc, error);
else console.log('%c %s', colorStr, desc);
}
}
);
})(reports);
} | javascript | function consoleReporter(reports, options = {}) {
var hide = options.hide || {};
(function _consoleReporter(reports) {
reports.forEach(
({children, desc, status, counts, time, code, error}) => {
let countStr = makeCounts(counts);
let color = statusInfo[status].color;
let colorStr = `color: ${color}`;
if (children) {
let msg = desc;
let collapse = hide.children || hide.passed && status === 'pass';
if (!hide.counts) { msg = `${msg} (${countStr})`; }
console[collapse ? 'groupCollapsed' : 'group']('%c' + msg, colorStr);
_consoleReporter(children);
console.groupEnd();
} else {
if (error) console.log('%c %s (%O)', colorStr, desc, error);
else console.log('%c %s', colorStr, desc);
}
}
);
})(reports);
} | [
"function",
"consoleReporter",
"(",
"reports",
",",
"options",
"=",
"{",
"}",
")",
"{",
"var",
"hide",
"=",
"options",
".",
"hide",
"||",
"{",
"}",
";",
"(",
"function",
"_consoleReporter",
"(",
"reports",
")",
"{",
"reports",
".",
"forEach",
"(",
"(",
"{",
"children",
",",
"desc",
",",
"status",
",",
"counts",
",",
"time",
",",
"code",
",",
"error",
"}",
")",
"=>",
"{",
"let",
"countStr",
"=",
"makeCounts",
"(",
"counts",
")",
";",
"let",
"color",
"=",
"statusInfo",
"[",
"status",
"]",
".",
"color",
";",
"let",
"colorStr",
"=",
"`",
"${",
"color",
"}",
"`",
";",
"if",
"(",
"children",
")",
"{",
"let",
"msg",
"=",
"desc",
";",
"let",
"collapse",
"=",
"hide",
".",
"children",
"||",
"hide",
".",
"passed",
"&&",
"status",
"===",
"'pass'",
";",
"if",
"(",
"!",
"hide",
".",
"counts",
")",
"{",
"msg",
"=",
"`",
"${",
"msg",
"}",
"${",
"countStr",
"}",
"`",
";",
"}",
"console",
"[",
"collapse",
"?",
"'groupCollapsed'",
":",
"'group'",
"]",
"(",
"'%c'",
"+",
"msg",
",",
"colorStr",
")",
";",
"_consoleReporter",
"(",
"children",
")",
";",
"console",
".",
"groupEnd",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"error",
")",
"console",
".",
"log",
"(",
"'%c %s (%O)'",
",",
"colorStr",
",",
"desc",
",",
"error",
")",
";",
"else",
"console",
".",
"log",
"(",
"'%c %s'",
",",
"colorStr",
",",
"desc",
")",
";",
"}",
"}",
")",
";",
"}",
")",
"(",
"reports",
")",
";",
"}"
] | Console reporter, which reports results on the console. | [
"Console",
"reporter",
"which",
"reports",
"results",
"on",
"the",
"console",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Tst.js#L51-L73 |
48,396 | rtm/upward | src/Tst.js | htmlReporter | function htmlReporter(reports, options = {}) {
var {hide} = options;
hide = hide || {};
function htmlReporterOne({children, desc, status, counts, time, code}) {
var text = T(desc);
var attrs = {class: {[status]: true}};
if (children) {
return E('details') .
has([
E('summary') . has([text, !hide.counts && T(` (${makeCounts(counts)})`)]) . is(attrs),
E('div') . has(htmlReporter(children, options))
]) .
is(hide.children ? {} : {open: true});
} else {
return E('div') . has(text) . is(attrs);
}
}
return M(reports, htmlReporterOne);
} | javascript | function htmlReporter(reports, options = {}) {
var {hide} = options;
hide = hide || {};
function htmlReporterOne({children, desc, status, counts, time, code}) {
var text = T(desc);
var attrs = {class: {[status]: true}};
if (children) {
return E('details') .
has([
E('summary') . has([text, !hide.counts && T(` (${makeCounts(counts)})`)]) . is(attrs),
E('div') . has(htmlReporter(children, options))
]) .
is(hide.children ? {} : {open: true});
} else {
return E('div') . has(text) . is(attrs);
}
}
return M(reports, htmlReporterOne);
} | [
"function",
"htmlReporter",
"(",
"reports",
",",
"options",
"=",
"{",
"}",
")",
"{",
"var",
"{",
"hide",
"}",
"=",
"options",
";",
"hide",
"=",
"hide",
"||",
"{",
"}",
";",
"function",
"htmlReporterOne",
"(",
"{",
"children",
",",
"desc",
",",
"status",
",",
"counts",
",",
"time",
",",
"code",
"}",
")",
"{",
"var",
"text",
"=",
"T",
"(",
"desc",
")",
";",
"var",
"attrs",
"=",
"{",
"class",
":",
"{",
"[",
"status",
"]",
":",
"true",
"}",
"}",
";",
"if",
"(",
"children",
")",
"{",
"return",
"E",
"(",
"'details'",
")",
".",
"has",
"(",
"[",
"E",
"(",
"'summary'",
")",
".",
"has",
"(",
"[",
"text",
",",
"!",
"hide",
".",
"counts",
"&&",
"T",
"(",
"`",
"${",
"makeCounts",
"(",
"counts",
")",
"}",
"`",
")",
"]",
")",
".",
"is",
"(",
"attrs",
")",
",",
"E",
"(",
"'div'",
")",
".",
"has",
"(",
"htmlReporter",
"(",
"children",
",",
"options",
")",
")",
"]",
")",
".",
"is",
"(",
"hide",
".",
"children",
"?",
"{",
"}",
":",
"{",
"open",
":",
"true",
"}",
")",
";",
"}",
"else",
"{",
"return",
"E",
"(",
"'div'",
")",
".",
"has",
"(",
"text",
")",
".",
"is",
"(",
"attrs",
")",
";",
"}",
"}",
"return",
"M",
"(",
"reports",
",",
"htmlReporterOne",
")",
";",
"}"
] | HTML reporter; returns an Array of DOM nodes. | [
"HTML",
"reporter",
";",
"returns",
"an",
"Array",
"of",
"DOM",
"nodes",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Tst.js#L76-L96 |
48,397 | pghalliday/multiplex-stream | src/MultiplexStream.js | emitEvent | function emitEvent(emitter, event, data) {
process.nextTick(function() {
emitter.emit(event, data);
});
} | javascript | function emitEvent(emitter, event, data) {
process.nextTick(function() {
emitter.emit(event, data);
});
} | [
"function",
"emitEvent",
"(",
"emitter",
",",
"event",
",",
"data",
")",
"{",
"process",
".",
"nextTick",
"(",
"function",
"(",
")",
"{",
"emitter",
".",
"emit",
"(",
"event",
",",
"data",
")",
";",
"}",
")",
";",
"}"
] | force all events to be asynchronous | [
"force",
"all",
"events",
"to",
"be",
"asynchronous"
] | 5d425a5c5409d6fe3c1f98ea496e7a039c495920 | https://github.com/pghalliday/multiplex-stream/blob/5d425a5c5409d6fe3c1f98ea496e7a039c495920/src/MultiplexStream.js#L14-L18 |
48,398 | stayradiated/onepasswordjs | libs/sjcl.js | function (arr) {
var out = [], bl = sjcl.bitArray.bitLength(arr), i, tmp;
for (i=0; i<bl/8; i++) {
if ((i&3) === 0) {
tmp = arr[i/4];
}
out.push(tmp >>> 24);
tmp <<= 8;
}
return out;
} | javascript | function (arr) {
var out = [], bl = sjcl.bitArray.bitLength(arr), i, tmp;
for (i=0; i<bl/8; i++) {
if ((i&3) === 0) {
tmp = arr[i/4];
}
out.push(tmp >>> 24);
tmp <<= 8;
}
return out;
} | [
"function",
"(",
"arr",
")",
"{",
"var",
"out",
"=",
"[",
"]",
",",
"bl",
"=",
"sjcl",
".",
"bitArray",
".",
"bitLength",
"(",
"arr",
")",
",",
"i",
",",
"tmp",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"bl",
"/",
"8",
";",
"i",
"++",
")",
"{",
"if",
"(",
"(",
"i",
"&",
"3",
")",
"===",
"0",
")",
"{",
"tmp",
"=",
"arr",
"[",
"i",
"/",
"4",
"]",
";",
"}",
"out",
".",
"push",
"(",
"tmp",
">>>",
"24",
")",
";",
"tmp",
"<<=",
"8",
";",
"}",
"return",
"out",
";",
"}"
] | Convert from a bitArray to an array of bytes. | [
"Convert",
"from",
"a",
"bitArray",
"to",
"an",
"array",
"of",
"bytes",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/libs/sjcl.js#L58-L68 |
|
48,399 | stayradiated/onepasswordjs | libs/sjcl.js | function (bytes) {
var out = [], i, tmp=0;
for (i=0; i<bytes.length; i++) {
tmp = tmp << 8 | bytes[i];
if ((i&3) === 3) {
out.push(tmp);
tmp = 0;
}
}
if (i&3) {
out.push(sjcl.bitArray.partial(8*(i&3), tmp));
}
return out;
} | javascript | function (bytes) {
var out = [], i, tmp=0;
for (i=0; i<bytes.length; i++) {
tmp = tmp << 8 | bytes[i];
if ((i&3) === 3) {
out.push(tmp);
tmp = 0;
}
}
if (i&3) {
out.push(sjcl.bitArray.partial(8*(i&3), tmp));
}
return out;
} | [
"function",
"(",
"bytes",
")",
"{",
"var",
"out",
"=",
"[",
"]",
",",
"i",
",",
"tmp",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"bytes",
".",
"length",
";",
"i",
"++",
")",
"{",
"tmp",
"=",
"tmp",
"<<",
"8",
"|",
"bytes",
"[",
"i",
"]",
";",
"if",
"(",
"(",
"i",
"&",
"3",
")",
"===",
"3",
")",
"{",
"out",
".",
"push",
"(",
"tmp",
")",
";",
"tmp",
"=",
"0",
";",
"}",
"}",
"if",
"(",
"i",
"&",
"3",
")",
"{",
"out",
".",
"push",
"(",
"sjcl",
".",
"bitArray",
".",
"partial",
"(",
"8",
"*",
"(",
"i",
"&",
"3",
")",
",",
"tmp",
")",
")",
";",
"}",
"return",
"out",
";",
"}"
] | Convert from an array of bytes to a bitArray. | [
"Convert",
"from",
"an",
"array",
"of",
"bytes",
"to",
"a",
"bitArray",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/libs/sjcl.js#L70-L83 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.