From 9cc35e21c433a04ad82428f87a62bbd213fda389 Mon Sep 17 00:00:00 2001 From: Matt Mullenweg Date: Tue, 30 Aug 2005 01:25:19 +0000 Subject: [PATCH] More and nextpage, from ringmaster. Fixes #1564 git-svn-id: https://develop.svn.wordpress.org/trunk@2820 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/admin-header.php | 4 +- .../plugins/wordpress/editor_plugin.js | 210 ++++++++++++++++++ .../plugins/wordpress/editor_plugin_src.js | 210 ++++++++++++++++++ .../tinymce/plugins/wordpress/images/more.gif | Bin 0 -> 108 bytes .../plugins/wordpress/images/more_bug.gif | Bin 0 -> 146 bytes .../tinymce/plugins/wordpress/images/page.gif | Bin 0 -> 108 bytes .../plugins/wordpress/images/page_bug.gif | Bin 0 -> 180 bytes .../js/tinymce/plugins/wordpress/langs/en.js | 6 + .../tinymce/plugins/wordpress/wordpress.css | 21 ++ 9 files changed, 449 insertions(+), 2 deletions(-) create mode 100644 wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js create mode 100644 wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js create mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/more.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/more_bug.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/page.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/page_bug.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/langs/en.js create mode 100644 wp-includes/js/tinymce/plugins/wordpress/wordpress.css diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index cfd6e5d3a7..8db3a9d0d5 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -85,7 +85,7 @@ tinyMCE.init({ textarea_trigger : "title", width : "100%", theme : "advanced", - theme_advanced_buttons1 : "bold,italic,strikethrough,separator,bullist,numlist,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,image,emotions,separator,undo,redo,code", + theme_advanced_buttons1 : "bold,italic,strikethrough,separator,bullist,numlist,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,image,emotions,separator,undo,redo,wordpress,code", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", @@ -95,7 +95,7 @@ tinyMCE.init({ theme_advanced_resize_horizontal : false, entity_encoding : "raw", extended_valid_elements : "a[id|href|title|onclick],img[class|src|alt|title|width|height|align]", - plugins : "emotions" + plugins : "emotions,wordpress" }); diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js new file mode 100644 index 0000000000..0547fb0229 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js @@ -0,0 +1,210 @@ +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('wordpress', ''); + +function TinyMCE_wordpress_initInstance(inst) { + if (!tinyMCE.settings['wordpress_skip_plugin_css']) + tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/wordpress/wordpress.css"); +} + +function TinyMCE_wordpress_getControlHTML(control_name) { + switch (control_name) { + case "wordpress": + return ''; + } + + return ""; +} + +function TinyMCE_wordpress_parseAttributes(attribute_string) { + var attributeName = ""; + var attributeValue = ""; + var withInName; + var withInValue; + var attributes = new Array(); + var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g'); + + if (attribute_string == null || attribute_string.length < 2) + return null; + + withInName = withInValue = false; + + for (var i=0; i'; + tinyMCE.execCommand("mceInsertContent",true,html); + tinyMCE.selectedInstance.repaint(); + return true; + case "mcewordpresspage": + var name = ""; + var template = new Array(); + var inst = tinyMCE.getInstanceById(editor_id); + var focusElm = inst.getFocusElement(); + + // Is selection a image + if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { + name = getAttrib(focusElm, 'name'); + + if (name != 'mce_plugin_wordpress_page') // Not a wordpress + return true; + + action = "update"; + } + + html = '' + + ''; + tinyMCE.execCommand("mceInsertContent",true,html); + tinyMCE.selectedInstance.repaint(); + return true; + } + + // Pass to next handler in chain + return false; +} + +function TinyMCE_wordpress_cleanup(type, content) { + switch (type) { + + case "insert_to_editor": + var startPos = 0; + + // Parse all tags and replace them with images + while ((startPos = content.indexOf('', startPos)) != -1) { + // Insert image + var contentAfter = content.substring(startPos + 11); + content = content.substring(0, startPos); + content += ' tags and replace them with images + while ((startPos = content.indexOf('', startPos)) != -1) { + // Insert image + var contentAfter = content.substring(startPos + 15); + content = content.substring(0, startPos); + content += ' + var startPos = -1; + while ((startPos = content.indexOf('', startPos); + var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos)); + + if (attribs['name'] == "mce_plugin_wordpress_more") { + endPos += 2; + + var embedHTML = ''; + + // Insert embed/object chunk + chunkBefore = content.substring(0, startPos); + chunkAfter = content.substring(endPos); + content = chunkBefore + embedHTML + chunkAfter; + } + if (attribs['name'] == "mce_plugin_wordpress_page") { + endPos += 2; + + var embedHTML = ''; + + // Insert embed/object chunk + chunkBefore = content.substring(0, startPos); + chunkAfter = content.substring(endPos); + content = chunkBefore + embedHTML + chunkAfter; + } + } + break; + } + + // Pass through to next handler in chain + return content; +} + +function TinyMCE_wordpress_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { + function getAttrib(elm, name) { + return elm.getAttribute(name) ? elm.getAttribute(name) : ""; + } + + tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonNormal'); + + if (node == null) + return; + + do { + if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_more') == 0) + tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected'); + if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_page') == 0) + tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected'); + } while ((node = node.parentNode)); + + return true; +} diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js new file mode 100644 index 0000000000..0547fb0229 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js @@ -0,0 +1,210 @@ +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('wordpress', ''); + +function TinyMCE_wordpress_initInstance(inst) { + if (!tinyMCE.settings['wordpress_skip_plugin_css']) + tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/wordpress/wordpress.css"); +} + +function TinyMCE_wordpress_getControlHTML(control_name) { + switch (control_name) { + case "wordpress": + return ''; + } + + return ""; +} + +function TinyMCE_wordpress_parseAttributes(attribute_string) { + var attributeName = ""; + var attributeValue = ""; + var withInName; + var withInValue; + var attributes = new Array(); + var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g'); + + if (attribute_string == null || attribute_string.length < 2) + return null; + + withInName = withInValue = false; + + for (var i=0; i'; + tinyMCE.execCommand("mceInsertContent",true,html); + tinyMCE.selectedInstance.repaint(); + return true; + case "mcewordpresspage": + var name = ""; + var template = new Array(); + var inst = tinyMCE.getInstanceById(editor_id); + var focusElm = inst.getFocusElement(); + + // Is selection a image + if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { + name = getAttrib(focusElm, 'name'); + + if (name != 'mce_plugin_wordpress_page') // Not a wordpress + return true; + + action = "update"; + } + + html = '' + + ''; + tinyMCE.execCommand("mceInsertContent",true,html); + tinyMCE.selectedInstance.repaint(); + return true; + } + + // Pass to next handler in chain + return false; +} + +function TinyMCE_wordpress_cleanup(type, content) { + switch (type) { + + case "insert_to_editor": + var startPos = 0; + + // Parse all tags and replace them with images + while ((startPos = content.indexOf('', startPos)) != -1) { + // Insert image + var contentAfter = content.substring(startPos + 11); + content = content.substring(0, startPos); + content += ' tags and replace them with images + while ((startPos = content.indexOf('', startPos)) != -1) { + // Insert image + var contentAfter = content.substring(startPos + 15); + content = content.substring(0, startPos); + content += ' + var startPos = -1; + while ((startPos = content.indexOf('', startPos); + var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos)); + + if (attribs['name'] == "mce_plugin_wordpress_more") { + endPos += 2; + + var embedHTML = ''; + + // Insert embed/object chunk + chunkBefore = content.substring(0, startPos); + chunkAfter = content.substring(endPos); + content = chunkBefore + embedHTML + chunkAfter; + } + if (attribs['name'] == "mce_plugin_wordpress_page") { + endPos += 2; + + var embedHTML = ''; + + // Insert embed/object chunk + chunkBefore = content.substring(0, startPos); + chunkAfter = content.substring(endPos); + content = chunkBefore + embedHTML + chunkAfter; + } + } + break; + } + + // Pass through to next handler in chain + return content; +} + +function TinyMCE_wordpress_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { + function getAttrib(elm, name) { + return elm.getAttribute(name) ? elm.getAttribute(name) : ""; + } + + tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonNormal'); + + if (node == null) + return; + + do { + if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_more') == 0) + tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected'); + if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_page') == 0) + tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected'); + } while ((node = node.parentNode)); + + return true; +} diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/more.gif b/wp-includes/js/tinymce/plugins/wordpress/images/more.gif new file mode 100644 index 0000000000000000000000000000000000000000..4ff564d5896823d5a6d9378781ddfb5e1b1d6f65 GIT binary patch literal 108 zcmZ?wbhEHb6k!lyn8?78mX`Ma|No|?CxE2lPZm}Y24)5w1|R^*GceiC>0inGmY$|5$M0 zt?teHoPP1QDTOjRB;>8S*7=URUZrZ;>)5Ry&wbv^x#dQa!qmTeBx%IiC| x%Jg81-FAytUstD0Yf)F{jnZS^^Wa-vTX*rDFY_MsoqzrPPwij+A3+QZ)&OEJL(2dF literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/page.gif b/wp-includes/js/tinymce/plugins/wordpress/images/page.gif new file mode 100644 index 0000000000000000000000000000000000000000..1cea78ac2ba02c5e429b4128c2cdf0ecc4058b20 GIT binary patch literal 108 zcmZ?wbhEHb6k!lyn8?78mX`Ma|No|?CxE2lPZm}Y24)5w1|R^*GceiS5m>o9p>2lG zyQ3$yjs(fivz1>_A)d+f>eRMJ+{c>?&J^c9{x18yfV(8pL-itOic(O|DTkn+DsF*3 KD;6>^SOWl#7%CV5 literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/page_bug.gif b/wp-includes/js/tinymce/plugins/wordpress/images/page_bug.gif new file mode 100644 index 0000000000000000000000000000000000000000..9ea3565692f721dea7425f0050d27e299e869be9 GIT binary patch literal 180 zcmV;l089TzNk%w1VTAw+0FeLy0002r=<&?V%>V!YA^8La6aWJNEC2ui0EGYw0007o zoR6u??Ja_wwAzcazT){0hDf9VlDS#Hil$p9#&S$%YtY&in!6Z03knxC%&o;r;%*b= zlE-9efWxY=crit#Ox%v5Zi( literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js new file mode 100644 index 0000000000..2d3358dc28 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js @@ -0,0 +1,6 @@ +// UK lang variables + +/* Remember to namespace the language parameters lang__ */ + +tinyMCELang['lang_template_title'] = 'This is just a template popup'; +tinyMCELang['lang_template_desc'] = 'This is just a template button'; diff --git a/wp-includes/js/tinymce/plugins/wordpress/wordpress.css b/wp-includes/js/tinymce/plugins/wordpress/wordpress.css new file mode 100644 index 0000000000..b51a098482 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wordpress/wordpress.css @@ -0,0 +1,21 @@ +.mce_plugin_wordpress_more { + border: 0px; + border-top: 1px dotted #cccccc; + display:block; + background-color: #ffffff; + margin-top:15px; + background-image: url(images/more_bug.gif); + background-repeat: no-repeat; + background-position: right top; +} + +.mce_plugin_wordpress_page { + border: 0px; + border-top: 1px dotted #cccccc; + display:block; + background-color: #ffffff; + margin-top:15px; + background-image: url(images/page_bug.gif); + background-repeat: no-repeat; + background-position: right top; +}