[xwiki-commits] r4015 - in xwiki-platform: core/trunk/src/main/java/com/xpn/xwiki/render/macro web/trunk/standard/src/main/webapp/tiny_mce/themes/wikieditor web/trunk/standard/src/main/webapp/tiny_mce/themes/wikieditor/images web/trunk/standard/src/main/webapp/wiki_editor web/trunk/standard/src/main/webapp/wiki_editor/plugins web/trunk/standard/src/main/webapp/wiki_editor/themes
Vincent Massol
vincent at massol.net
Wed Jul 25 17:37:28 CEST 2007
Hi Nam,
You've modified the style macro to add a new align parameter. For
this you need:
1) A separate JIRA issue!
2) To update the documentation on http://www.xwiki.org/xwiki/bin/view/
Code/StyleMacro
Can you please implement both?
Thanks
-Vincent
On Jul 24, 2007, at 1:25 PM, Phung Hai Nam wrote:
> Author: namphunghai
> Date: 2007-07-24 13:25:45 +0200 (Tue, 24 Jul 2007)
> New Revision: 4015
>
> Added:
> xwiki-platform/web/trunk/standard/src/main/webapp/tiny_mce/
> themes/wikieditor/images/justifycenter.gif
> xwiki-platform/web/trunk/standard/src/main/webapp/tiny_mce/
> themes/wikieditor/images/justifyfull.gif
> xwiki-platform/web/trunk/standard/src/main/webapp/tiny_mce/
> themes/wikieditor/images/justifyleft.gif
> xwiki-platform/web/trunk/standard/src/main/webapp/tiny_mce/
> themes/wikieditor/images/justifyright.gif
> Modified:
> xwiki-platform/core/trunk/src/main/java/com/xpn/xwiki/render/
> macro/StyleMacro.java
> xwiki-platform/web/trunk/standard/src/main/webapp/tiny_mce/
> themes/wikieditor/editor_template.js
> xwiki-platform/web/trunk/standard/src/main/webapp/wiki_editor/
> plugins/core.js
> xwiki-platform/web/trunk/standard/src/main/webapp/wiki_editor/
> themes/default.js
> xwiki-platform/web/trunk/standard/src/main/webapp/wiki_editor/
> wiki_editor.js
> Log:
> Fixed XWIKI 370 : to be able to justify text left center right full
>
> Modified: xwiki-platform/core/trunk/src/main/java/com/xpn/xwiki/
> render/macro/StyleMacro.java
> ===================================================================
> --- xwiki-platform/core/trunk/src/main/java/com/xpn/xwiki/render/
> macro/StyleMacro.java 2007-07-24 07:42:22 UTC (rev 4014)
> +++ xwiki-platform/core/trunk/src/main/java/com/xpn/xwiki/render/
> macro/StyleMacro.java 2007-07-24 11:25:45 UTC (rev 4015)
> @@ -50,6 +50,7 @@
> String type = params.get("type");
> String id = params.get("id");
> String classes = params.get("class");
> + String align = params.get("align");
> String name = params.get("name");
> String size = params.get("font-size");
> String font = params.get("font-family");
> @@ -117,6 +118,9 @@
> if ((!"none".equals(name)) && (name != null) && (!"".equals
> (name.trim()))) {
> str.append("name=\"" + name.trim() + "\" ");
> }
> + if ((!"none".equals(align)) && (align != null) &&
> (!"".equals(align.trim()))) {
> + str.append("align=\"" + align.trim() + "\" ");
> + }
>
> str.append("style=\"");
>
>
> Modified: xwiki-platform/web/trunk/standard/src/main/webapp/
> tiny_mce/themes/wikieditor/editor_template.js
> ===================================================================
> --- xwiki-platform/web/trunk/standard/src/main/webapp/tiny_mce/
> themes/wikieditor/editor_template.js 2007-07-24 07:42:22 UTC (rev
> 4014)
> +++ xwiki-platform/web/trunk/standard/src/main/webapp/tiny_mce/
> themes/wikieditor/editor_template.js 2007-07-24 11:25:45 UTC (rev
> 4015)
> @@ -258,8 +258,59 @@
> template['height'] = 250;
>
> tinyMCE.openWindow(template, {editor_id : editor_id, inline :
> "yes"});
> - return true;
> + return true;
>
> + case "JustifyLeft":
> + var focusElm =
> tinyMCE.selectedInstance.getFocusElement();
> + if (focusElm && (focusElm.nodeName == "P")) {
> + tinyMCE.execInstanceCommand(editor_id,
> "FormatBlock", false, "<div>");
> + var selectedElm =
> tinyMCE.selectedInstance.selection.getFocusElement();
> + selectedElm.setAttribute('align', 'left');
> + } else {
> + return wikiEditor.execCommand(editor_id,
> element, "justifyLeft", user_interface, value);
> + }
> + tinyMCE.triggerNodeChange();
> + return true;
> +
> + case "JustifyCenter":
> +
> + var focusElm =
> tinyMCE.selectedInstance.getFocusElement();
> + if (focusElm && (focusElm.nodeName == "P")) {
> + tinyMCE.execInstanceCommand(editor_id,
> "FormatBlock", false, "<div>");
> + var selectedElm =
> tinyMCE.selectedInstance.selection.getFocusElement();
> + selectedElm.setAttribute('align', 'center');
> + } else {
> + return wikiEditor.execCommand(editor_id,
> element, "justifyCenter", user_interface, value);
> + }
> + tinyMCE.triggerNodeChange();
> + return true;
> +
> + case "JustifyRight":
> +
> + var focusElm =
> tinyMCE.selectedInstance.getFocusElement();
> + if (focusElm && (focusElm.nodeName == "P")) {
> + tinyMCE.execInstanceCommand(editor_id,
> "FormatBlock", false, "<div>");
> + var selectedElm =
> tinyMCE.selectedInstance.selection.getFocusElement();
> + selectedElm.setAttribute('align', 'right');
> + } else {
> + return wikiEditor.execCommand(editor_id,
> element, "justifyRight", user_interface, value);
> + }
> + tinyMCE.triggerNodeChange();
> + return true;
> +
> + case "JustifyFull":
> +
> + var focusElm =
> tinyMCE.selectedInstance.getFocusElement();
> + if (focusElm && (focusElm.nodeName == "P")) {
> + tinyMCE.execInstanceCommand(editor_id,
> "FormatBlock", false, "<div>");
> + var selectedElm =
> tinyMCE.selectedInstance.selection.getFocusElement();
> + selectedElm.setAttribute('align', 'justify');
> + } else {
> + return wikiEditor.execCommand(editor_id,
> element, "justifyFull", user_interface, value);
> + }
> + tinyMCE.triggerNodeChange();
> + return true;
> +
> default :
> return wikiEditor.execCommand(editor_id, element,
> command, user_interface, value);
> }
>
> Added: xwiki-platform/web/trunk/standard/src/main/webapp/tiny_mce/
> themes/wikieditor/images/justifycenter.gif
> ===================================================================
> (Binary files differ)
>
>
> Property changes on: xwiki-platform/web/trunk/standard/src/main/
> webapp/tiny_mce/themes/wikieditor/images/justifycenter.gif
> ___________________________________________________________________
> Name: svn:mime-type
> + application/octet-stream
>
> Added: xwiki-platform/web/trunk/standard/src/main/webapp/tiny_mce/
> themes/wikieditor/images/justifyfull.gif
> ===================================================================
> (Binary files differ)
>
>
> Property changes on: xwiki-platform/web/trunk/standard/src/main/
> webapp/tiny_mce/themes/wikieditor/images/justifyfull.gif
> ___________________________________________________________________
> Name: svn:mime-type
> + application/octet-stream
>
> Added: xwiki-platform/web/trunk/standard/src/main/webapp/tiny_mce/
> themes/wikieditor/images/justifyleft.gif
> ===================================================================
> (Binary files differ)
>
>
> Property changes on: xwiki-platform/web/trunk/standard/src/main/
> webapp/tiny_mce/themes/wikieditor/images/justifyleft.gif
> ___________________________________________________________________
> Name: svn:mime-type
> + application/octet-stream
>
> Added: xwiki-platform/web/trunk/standard/src/main/webapp/tiny_mce/
> themes/wikieditor/images/justifyright.gif
> ===================================================================
> (Binary files differ)
>
>
> Property changes on: xwiki-platform/web/trunk/standard/src/main/
> webapp/tiny_mce/themes/wikieditor/images/justifyright.gif
> ___________________________________________________________________
> Name: svn:mime-type
> + application/octet-stream
>
> Modified: xwiki-platform/web/trunk/standard/src/main/webapp/
> wiki_editor/plugins/core.js
> ===================================================================
> --- xwiki-platform/web/trunk/standard/src/main/webapp/wiki_editor/
> plugins/core.js 2007-07-24 07:42:22 UTC (rev 4014)
> +++ xwiki-platform/web/trunk/standard/src/main/webapp/wiki_editor/
> plugins/core.js 2007-07-24 11:25:45 UTC (rev 4015)
> @@ -80,6 +80,7 @@
> this.addToolbarHandler('handleHorizontalRuleButtons');
> this.addToolbarHandler('handleSupAndSubButons');
> this.addToolbarHandler('handleTableButtons');
> + this.addToolbarHandler('handleAlignButtons');
>
> // Add Comands and Fix Commands(workarounds)
> this.addCommand('Title', 'titleCommand');
> @@ -392,6 +393,47 @@
> tinyMCE.switchClass(editor_id + '_table', 'mceButtonNormal',
> false);
> }
>
> +WikiEditor.prototype.handleAlignButtons = function(editor_id,
> node, undo_index, undo_levels, visual_aid, any_selection) {
> + tinyMCE.switchClass(editor_id + '_justifyleft',
> 'mceButtonNormal');
> + tinyMCE.switchClass(editor_id + '_justifyright',
> 'mceButtonNormal');
> + tinyMCE.switchClass(editor_id + '_justifycenter',
> 'mceButtonNormal');
> + tinyMCE.switchClass(editor_id + '_justifyfull',
> 'mceButtonNormal');
> +
> + var alignNode = node;
> + var breakOut = false;
> + do {
> + if (!alignNode.getAttribute || !alignNode.getAttribute
> ('align'))
> + continue;
> +
> + switch (alignNode.getAttribute('align').toLowerCase()) {
> + case "left":
> + tinyMCE.switchClass(editor_id + '_justifyleft',
> 'mceButtonSelected');
> + breakOut = true;
> + break;
> +
> + case "right":
> + tinyMCE.switchClass(editor_id + '_justifyright',
> 'mceButtonSelected');
> + breakOut = true;
> + break;
> +
> + case "middle":
> + case "center":
> + tinyMCE.switchClass(editor_id + '_justifycenter',
> 'mceButtonSelected');
> + breakOut = true;
> + break;
> +
> + case "justify":
> + tinyMCE.switchClass(editor_id + '_justifyfull',
> 'mceButtonSelected');
> + breakOut = true;
> + break;
> + }
> + } while (!breakOut && (alignNode = alignNode.parentNode) !=
> null);
> +
> + var div = tinyMCE.getParentElement(node, "div");
> + if (div && div.style.textAlign == "center")
> + tinyMCE.switchClass(editor_id + '_justifycenter',
> 'mceButtonSelected');
> +}
> +
> WikiEditor.prototype.handleTitlesList = function(editor_id, node,
> undo_index, undo_levels, visual_aid, any_selection) {
> var list = document.getElementById(editor_id + "_titleSelect");
> if(list) {
> @@ -578,6 +620,29 @@
> return str;
> }
>
> +WikiEditor.prototype.getJustifyToolbar = function() {
> + return this.getJustifyControls('justifyleft') +
> this.getJustifyControls('justifycenter') + this.getJustifyControls
> ('justifyright') + this.getJustifyControls('justifyfull');
> +}
> +
> +WikiEditor.prototype.getJustifyControls = function(button_name) {
> + var str = "";
> + switch (button_name) {
> + case 'justifyleft':
> + str = this.createButtonHTML('justifyleft',
> 'justifyleft.gif', 'lang_justifyleft_desc', 'JustifyLeft');
> + break;
> + case 'justifycenter':
> + str = this.createButtonHTML('justifycenter',
> 'justifycenter.gif', 'lang_justifycenter_desc', 'JustifyCenter');
> + break;
> + case 'justifyright' :
> + str = this.createButtonHTML('justifyright',
> 'justifyright.gif', 'lang_justifyright_desc', 'JustifyRight');
> + break;
> + case 'justifyfull' :
> + str = this.createButtonHTML('justifyfull',
> 'justifyfull.gif', 'lang_justifyfull_desc', 'JustifyFull');
> + break;
> + }
> + return str;
> +}
> +
> WikiEditor.prototype.getSupAndSubToolbar = function() {
> return this.getSupAndSubControls('sup') +
> this.getSupAndSubControls('sub');
> }
> @@ -705,6 +770,7 @@
> '<option value="3">{$lang_wiki_title_3}</option>' +
> '<option value="4">{$lang_wiki_title_4}</option>' +
> '<option value="5">{$lang_wiki_title_5}</option>' +
> + '<option value="6">{$lang_wiki_title_6}</option>' +
> '</select>';
> }
>
> @@ -1130,7 +1196,7 @@
> WikiEditor.prototype.convertStyleExternal = function(regexp,
> result, content) {
> var str = "";
> var atts = result[1].split("|");
> - var tag = "font", style = "", myclass = "", id = "", name =
> "", doc = "";
> + var tag = "font", style = "", myclass = "", id = "", name =
> "", doc = "", align = "";
> var hasIcon = false;
> for (var i=0; i < atts.length; i++) {
> var att = this.trimString(atts[i].substring(0, atts
> [i].indexOf("=")));
> @@ -1147,6 +1213,9 @@
> else if (att == "type") {
> tag = value;
> }
> + else if (att == "align") {
> + align = value;
> + }
> else if (att == "icon") {
> style += "background-image: url(" + value + ");";
> hasIcon = true;
> @@ -1166,6 +1235,9 @@
> if (name != "") {
> str += " name=\"" + name + "\"";
> }
> + if (align != "") {
> + str += " align=\"" + align + "\"";
> + }
> if (style != "") {
> str += " style=\"" + style + "\"";
> }
> @@ -1193,6 +1265,9 @@
> if (attributes["id"]) {
> str += "|id=" + attributes["id"] ;
> }
> + if (attributes["align"]) {
> + str += "|align=" + attributes["align"] ;
> + }
> if (attributes["class"] && attributes["class"] !=
> "stylemacro") {
> str += "|class=" + attributes["class"] ;
> }
>
> Modified: xwiki-platform/web/trunk/standard/src/main/webapp/
> wiki_editor/themes/default.js
> ===================================================================
> --- xwiki-platform/web/trunk/standard/src/main/webapp/wiki_editor/
> themes/default.js 2007-07-24 07:42:22 UTC (rev 4014)
> +++ xwiki-platform/web/trunk/standard/src/main/webapp/wiki_editor/
> themes/default.js 2007-07-24 11:25:45 UTC (rev 4015)
> @@ -21,6 +21,9 @@
> case "texttoolbar":
> str += this.getTextToolbar();
> break;
> + case "justifytoolbar":
> + str += this.TOOLBAR_SPACER + this.getJustifyToolbar
> ();
> + break;
> case "listtoolbar":
> str += this.TOOLBAR_SPACER + this.getListToolbar();
> break;
>
> Modified: xwiki-platform/web/trunk/standard/src/main/webapp/
> wiki_editor/wiki_editor.js
> ===================================================================
> --- xwiki-platform/web/trunk/standard/src/main/webapp/wiki_editor/
> wiki_editor.js 2007-07-24 07:42:22 UTC (rev 4014)
> +++ xwiki-platform/web/trunk/standard/src/main/webapp/wiki_editor/
> wiki_editor.js 2007-07-24 11:25:45 UTC (rev 4015)
> @@ -76,7 +76,7 @@
> params["use_linkeditor_tabs"] = "wiki_tab, web_tab,
> attachments_tab, email_tab, file_tab";
> }
> if((params["wiki_editor_toolbar"] == null) || (params
> ["wiki_editor_toolbar"].toString() == "")) {
> - params["wiki_editor_toolbar"] = "texttoolbar, listtoolbar,
> indenttoolbar, undotoolbar, titletoolbar, styletoolbar, "
> + params["wiki_editor_toolbar"] = "texttoolbar,
> justifytoolbar, listtoolbar, indenttoolbar, undotoolbar,
> titletoolbar, styletoolbar, "
> + "horizontaltoolbar,
> symboltoolbar, attachmenttoolbar, macrostoolbar, tabletoolbar, "
> + "tablerowtoolbar,
> tablecoltoolbar, linktoolbar";
> }
>
>
>
> --
> You receive this message as a subscriber of the xwiki-
> commits at objectweb.org mailing list.
> To unsubscribe: mailto:xwiki-commits-unsubscribe at objectweb.org
> For general help: mailto:sympa at objectweb.org?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/
> wws
More information about the devs
mailing list