diff --git a/lib/editor/atto/plugins/backcolor/lang/en/atto_backcolor.php b/lib/editor/atto/plugins/backcolor/lang/en/atto_backcolor.php new file mode 100644 index 0000000000000..382ce6219f280 --- /dev/null +++ b/lib/editor/atto/plugins/backcolor/lang/en/atto_backcolor.php @@ -0,0 +1,25 @@ +. + +/** + * Strings for component 'atto_backcolor', language 'en'. + * + * @package atto_backcolor + * @copyright 2014 Rossiani Wijaya + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Background color'; diff --git a/lib/editor/atto/plugins/backcolor/version.php b/lib/editor/atto/plugins/backcolor/version.php new file mode 100644 index 0000000000000..64f5dbd09050c --- /dev/null +++ b/lib/editor/atto/plugins/backcolor/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_backcolor + * @copyright 2014 Rossiani Wijaya + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2014020600; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013110500; // Requires this Moodle version. +$plugin->component = 'atto_backcolor'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/backcolor/yui/build/moodle-atto_backcolor-button/moodle-atto_backcolor-button-debug.js b/lib/editor/atto/plugins/backcolor/yui/build/moodle-atto_backcolor-button/moodle-atto_backcolor-button-debug.js new file mode 100644 index 0000000000000..91eb04b7ba777 --- /dev/null +++ b/lib/editor/atto/plugins/backcolor/yui/build/moodle-atto_backcolor-button/moodle-atto_backcolor-button-debug.js @@ -0,0 +1,134 @@ +YUI.add('moodle-atto_backcolor-button', function (Y, NAME) { + +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Atto text editor background color plugin. + * + * @package editor-atto + * @copyright 2014 Rossiani Wijaya + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_backcolor = M.atto_backcolor || { + init : function(params) { + var plugin = 'backcolor'; + + var rgb_white = '#FFFFFF', + rgb_red = '#EF4540', + rgb_yellow = '#FFCF35', + rgb_green = '#98CA3E', + rgb_blue = '#7D9FD3', + rgb_black = '#333333'; + + var click_white = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_white); + }; + var click_red = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_red); + }; + var click_yellow = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_yellow); + }; + var click_green = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_green); + }; + var click_blue = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_blue); + }; + var click_black = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_black); + }; + + var buttoncss = 'width: 20px; height: 20px; border: 1px solid #CCC; background-color: '; + var white = '
'; + var red = '
'; + var yellow = '
'; + var green = '
'; + var blue = '
'; + var black = '
'; + + var iconurl = M.util.image_url('e/text_highlight', 'core'); + + M.editor_atto.add_toolbar_menu(params.elementid, + plugin, + iconurl, + params.group, + [ + {'text' : white, 'handler' : click_white}, + {'text' : red, 'handler' : click_red}, + {'text' : yellow, 'handler' : click_yellow}, + {'text' : green, 'handler' : click_green}, + {'text' : blue, 'handler' : click_blue}, + {'text' : black, 'handler' : click_black} + ], + '4'); + }, + + /** + * Handle to change the background color. + * @param event e - The event that triggered this. + * @param string elementid - the elemen id of menu icon. + * @param string color - The color for the background. + */ + change_color : function(e, elementid, color) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + + if (window.getSelection) { + // Test for IE9 and non-IE browsers. + try { + if (!document.execCommand("BackColor", false, color)) { + M.atto_backcolor.set_back_color(color); + } + } catch (ex) { + M.atto_backcolor.set_back_color(color); + } + } else if (document.selection && document.selection.createRange) { + // Test for IE8 or less. + range = document.selection.createRange(); + range.execCommand("BackColor", false, color); + } + + // Clean the YUI ids from the HTML. + M.editor_atto.text_updated(elementid); + }, + /** + * Change the background color. + * This function is an alternative use for IE broswers. + * @param string color - The color for the background. + */ + set_back_color : function (color) { + var selection = window.getSelection(); + var range = null; + if (selection.rangeCount && selection.getRangeAt) { + range = selection.getRangeAt(0); + } + document.designMode = "on"; + if (range) { + selection.removeAllRanges(); + selection.addRange(range); + } + + if (!document.execCommand("HiliteColor", false, color)) { + document.execCommand("BackColor", false, color); + } + document.designMode = "off"; + } +}; + +}, '@VERSION@'); diff --git a/lib/editor/atto/plugins/backcolor/yui/build/moodle-atto_backcolor-button/moodle-atto_backcolor-button-min.js b/lib/editor/atto/plugins/backcolor/yui/build/moodle-atto_backcolor-button/moodle-atto_backcolor-button-min.js new file mode 100644 index 0000000000000..2489cd56dcffc --- /dev/null +++ b/lib/editor/atto/plugins/backcolor/yui/build/moodle-atto_backcolor-button/moodle-atto_backcolor-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_backcolor-button",function(e,t){M.atto_backcolor=M.atto_backcolor||{init:function(e){var t="backcolor",n="#FFFFFF",r="#EF4540",i="#FFCF35",s="#98CA3E",o="#7D9FD3",u="#333333",a=function(e,t){M.atto_backcolor.change_color(e,t,n)},f=function(e,t){M.atto_backcolor.change_color(e,t,r)},l=function(e,t){M.atto_backcolor.change_color(e,t,i)},c=function(e,t){M.atto_backcolor.change_color(e,t,s)},h=function(e,t){M.atto_backcolor.change_color(e,t,o)},p=function(e,t){M.atto_backcolor.change_color(e,t,u)},d="width: 20px; height: 20px; border: 1px solid #CCC; background-color: ",v='
',m='
',g='
',y='
',b='
',w='
',E=M.util.image_url("e/text_highlight","core");M.editor_atto.add_toolbar_menu(e.elementid,t,E,e.group,[{text:v,handler:a},{text:m,handler:f},{text:g,handler:l},{text:y,handler:c},{text:b,handler:h},{text:w,handler:p}],"4")},change_color:function(e,t,n){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t);if(window.getSelection)try{document.execCommand("BackColor",!1,n)||M.atto_backcolor.set_back_color(n)}catch(r){M.atto_backcolor.set_back_color(n)}else document.selection&&document.selection.createRange&&(range=document.selection.createRange(),range.execCommand("BackColor",!1,n));M.editor_atto.text_updated(t)},set_back_color:function(e){var t=window.getSelection(),n=null;t.rangeCount&&t.getRangeAt&&(n=t.getRangeAt(0)),document.designMode="on",n&&(t.removeAllRanges(),t.addRange(n)),document.execCommand("HiliteColor",!1,e)||document.execCommand("BackColor",!1,e),document.designMode="off"}}},"@VERSION@"); diff --git a/lib/editor/atto/plugins/backcolor/yui/build/moodle-atto_backcolor-button/moodle-atto_backcolor-button.js b/lib/editor/atto/plugins/backcolor/yui/build/moodle-atto_backcolor-button/moodle-atto_backcolor-button.js new file mode 100644 index 0000000000000..91eb04b7ba777 --- /dev/null +++ b/lib/editor/atto/plugins/backcolor/yui/build/moodle-atto_backcolor-button/moodle-atto_backcolor-button.js @@ -0,0 +1,134 @@ +YUI.add('moodle-atto_backcolor-button', function (Y, NAME) { + +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Atto text editor background color plugin. + * + * @package editor-atto + * @copyright 2014 Rossiani Wijaya + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_backcolor = M.atto_backcolor || { + init : function(params) { + var plugin = 'backcolor'; + + var rgb_white = '#FFFFFF', + rgb_red = '#EF4540', + rgb_yellow = '#FFCF35', + rgb_green = '#98CA3E', + rgb_blue = '#7D9FD3', + rgb_black = '#333333'; + + var click_white = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_white); + }; + var click_red = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_red); + }; + var click_yellow = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_yellow); + }; + var click_green = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_green); + }; + var click_blue = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_blue); + }; + var click_black = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_black); + }; + + var buttoncss = 'width: 20px; height: 20px; border: 1px solid #CCC; background-color: '; + var white = '
'; + var red = '
'; + var yellow = '
'; + var green = '
'; + var blue = '
'; + var black = '
'; + + var iconurl = M.util.image_url('e/text_highlight', 'core'); + + M.editor_atto.add_toolbar_menu(params.elementid, + plugin, + iconurl, + params.group, + [ + {'text' : white, 'handler' : click_white}, + {'text' : red, 'handler' : click_red}, + {'text' : yellow, 'handler' : click_yellow}, + {'text' : green, 'handler' : click_green}, + {'text' : blue, 'handler' : click_blue}, + {'text' : black, 'handler' : click_black} + ], + '4'); + }, + + /** + * Handle to change the background color. + * @param event e - The event that triggered this. + * @param string elementid - the elemen id of menu icon. + * @param string color - The color for the background. + */ + change_color : function(e, elementid, color) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + + if (window.getSelection) { + // Test for IE9 and non-IE browsers. + try { + if (!document.execCommand("BackColor", false, color)) { + M.atto_backcolor.set_back_color(color); + } + } catch (ex) { + M.atto_backcolor.set_back_color(color); + } + } else if (document.selection && document.selection.createRange) { + // Test for IE8 or less. + range = document.selection.createRange(); + range.execCommand("BackColor", false, color); + } + + // Clean the YUI ids from the HTML. + M.editor_atto.text_updated(elementid); + }, + /** + * Change the background color. + * This function is an alternative use for IE broswers. + * @param string color - The color for the background. + */ + set_back_color : function (color) { + var selection = window.getSelection(); + var range = null; + if (selection.rangeCount && selection.getRangeAt) { + range = selection.getRangeAt(0); + } + document.designMode = "on"; + if (range) { + selection.removeAllRanges(); + selection.addRange(range); + } + + if (!document.execCommand("HiliteColor", false, color)) { + document.execCommand("BackColor", false, color); + } + document.designMode = "off"; + } +}; + +}, '@VERSION@'); diff --git a/lib/editor/atto/plugins/backcolor/yui/src/button/build.json b/lib/editor/atto/plugins/backcolor/yui/src/button/build.json new file mode 100644 index 0000000000000..ab856c03ba1c8 --- /dev/null +++ b/lib/editor/atto/plugins/backcolor/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_backcolor-button", + "builds": { + "moodle-atto_backcolor-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/backcolor/yui/src/button/js/button.js b/lib/editor/atto/plugins/backcolor/yui/src/button/js/button.js new file mode 100644 index 0000000000000..af1ff33431299 --- /dev/null +++ b/lib/editor/atto/plugins/backcolor/yui/src/button/js/button.js @@ -0,0 +1,130 @@ +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Atto text editor background color plugin. + * + * @package editor-atto + * @copyright 2014 Rossiani Wijaya + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_backcolor = M.atto_backcolor || { + init : function(params) { + var plugin = 'backcolor'; + + var rgb_white = '#FFFFFF', + rgb_red = '#EF4540', + rgb_yellow = '#FFCF35', + rgb_green = '#98CA3E', + rgb_blue = '#7D9FD3', + rgb_black = '#333333'; + + var click_white = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_white); + }; + var click_red = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_red); + }; + var click_yellow = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_yellow); + }; + var click_green = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_green); + }; + var click_blue = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_blue); + }; + var click_black = function(e, elementid) { + M.atto_backcolor.change_color(e, elementid, rgb_black); + }; + + var buttoncss = 'width: 20px; height: 20px; border: 1px solid #CCC; background-color: '; + var white = '
'; + var red = '
'; + var yellow = '
'; + var green = '
'; + var blue = '
'; + var black = '
'; + + var iconurl = M.util.image_url('e/text_highlight', 'core'); + + M.editor_atto.add_toolbar_menu(params.elementid, + plugin, + iconurl, + params.group, + [ + {'text' : white, 'handler' : click_white}, + {'text' : red, 'handler' : click_red}, + {'text' : yellow, 'handler' : click_yellow}, + {'text' : green, 'handler' : click_green}, + {'text' : blue, 'handler' : click_blue}, + {'text' : black, 'handler' : click_black} + ], + '4'); + }, + + /** + * Handle to change the background color. + * @param event e - The event that triggered this. + * @param string elementid - the elemen id of menu icon. + * @param string color - The color for the background. + */ + change_color : function(e, elementid, color) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + + if (window.getSelection) { + // Test for IE9 and non-IE browsers. + try { + if (!document.execCommand("BackColor", false, color)) { + M.atto_backcolor.set_back_color(color); + } + } catch (ex) { + M.atto_backcolor.set_back_color(color); + } + } else if (document.selection && document.selection.createRange) { + // Test for IE8 or less. + range = document.selection.createRange(); + range.execCommand("BackColor", false, color); + } + + // Clean the YUI ids from the HTML. + M.editor_atto.text_updated(elementid); + }, + /** + * Change the background color. + * This function is an alternative use for IE broswers. + * @param string color - The color for the background. + */ + set_back_color : function (color) { + var selection = window.getSelection(); + var range = null; + if (selection.rangeCount && selection.getRangeAt) { + range = selection.getRangeAt(0); + } + document.designMode = "on"; + if (range) { + selection.removeAllRanges(); + selection.addRange(range); + } + + if (!document.execCommand("HiliteColor", false, color)) { + document.execCommand("BackColor", false, color); + } + document.designMode = "off"; + } +}; \ No newline at end of file diff --git a/lib/editor/atto/plugins/backcolor/yui/src/button/meta/editor.js b/lib/editor/atto/plugins/backcolor/yui/src/button/meta/editor.js new file mode 100644 index 0000000000000..d6cb6235e1a3c --- /dev/null +++ b/lib/editor/atto/plugins/backcolor/yui/src/button/meta/editor.js @@ -0,0 +1,5 @@ +{ + "moodle-atto_backcolor-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/plugins/fontcolor/lang/en/atto_fontcolor.php b/lib/editor/atto/plugins/fontcolor/lang/en/atto_fontcolor.php new file mode 100644 index 0000000000000..c55415c0c1d8a --- /dev/null +++ b/lib/editor/atto/plugins/fontcolor/lang/en/atto_fontcolor.php @@ -0,0 +1,25 @@ +. + +/** + * Strings for component 'atto_fontcolor', language 'en'. + * + * @package atto_fontcolor + * @copyright 2014 Rossiani Wijaya + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Font color'; diff --git a/lib/editor/atto/plugins/fontcolor/version.php b/lib/editor/atto/plugins/fontcolor/version.php new file mode 100644 index 0000000000000..f7e0da7e2d47e --- /dev/null +++ b/lib/editor/atto/plugins/fontcolor/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_fontcolor + * @copyright 2014 Rossiani Wijaya + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2014020600; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013110500; // Requires this Moodle version. +$plugin->component = 'atto_fontcolor'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/fontcolor/yui/build/moodle-atto_fontcolor-button/moodle-atto_fontcolor-button-debug.js b/lib/editor/atto/plugins/fontcolor/yui/build/moodle-atto_fontcolor-button/moodle-atto_fontcolor-button-debug.js new file mode 100644 index 0000000000000..56ef173268334 --- /dev/null +++ b/lib/editor/atto/plugins/fontcolor/yui/build/moodle-atto_fontcolor-button/moodle-atto_fontcolor-button-debug.js @@ -0,0 +1,99 @@ +YUI.add('moodle-atto_fontcolor-button', function (Y, NAME) { + +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Atto text editor font color plugin. + * + * @package editor-atto + * @copyright 2014 Rossiani Wijaya + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_fontcolor = M.atto_fontcolor || { + dialogue : null, + init : function(params) { + var plugin = 'fontcolor'; + + var rgb_white = '#FFFFFF', + rgb_red = '#EF4540', + rgb_yellow = '#FFCF35', + rgb_green = '#98CA3E', + rgb_blue = '#7D9FD3', + rgb_black = '#333333'; + + var click_white = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, 'transparent'); + }; + var click_red = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_red); + }; + var click_yellow = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_yellow); + }; + var click_green = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_green); + }; + var click_blue = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_blue); + }; + var click_black = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_black); + }; + + var buttoncss = 'width: 20px; height: 20px; border: 1px solid #CCC; background-color: '; + var white = '
'; + var red = '
'; + var yellow = '
'; + var green = '
'; + var blue = '
'; + var black = '
'; + + var iconurl = M.util.image_url('e/text_color', 'core'); + + M.editor_atto.add_toolbar_menu(params.elementid, + plugin, + iconurl, + params.group, + [ + {'text' : white, 'handler' : click_white}, + {'text' : red, 'handler' : click_red}, + {'text' : yellow, 'handler' : click_yellow}, + {'text' : green, 'handler' : click_green}, + {'text' : blue, 'handler' : click_blue}, + {'text' : black, 'handler' : click_black} + ], + '4', + '#333333'); + }, + + /** + * Handle to change the editor font color. + * @param event e - The event that triggered this. + * @param string elementid - the elemen id of menu icon. + * @param string color - The color for the background. + */ + change_color : function(e, elementid, color) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('foreColor', 0, color); + // Clean the YUI ids from the HTML. + M.editor_atto.text_updated(elementid); + } +}; + +}, '@VERSION@'); diff --git a/lib/editor/atto/plugins/fontcolor/yui/build/moodle-atto_fontcolor-button/moodle-atto_fontcolor-button-min.js b/lib/editor/atto/plugins/fontcolor/yui/build/moodle-atto_fontcolor-button/moodle-atto_fontcolor-button-min.js new file mode 100644 index 0000000000000..9a7702c1737d9 --- /dev/null +++ b/lib/editor/atto/plugins/fontcolor/yui/build/moodle-atto_fontcolor-button/moodle-atto_fontcolor-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_fontcolor-button",function(e,t){M.atto_fontcolor=M.atto_fontcolor||{dialogue:null,init:function(e){var t="fontcolor",n="#FFFFFF",r="#EF4540",i="#FFCF35",s="#98CA3E",o="#7D9FD3",u="#333333",a=function(e,t){M.atto_fontcolor.change_color(e,t,"transparent")},f=function(e,t){M.atto_fontcolor.change_color(e,t,r)},l=function(e,t){M.atto_fontcolor.change_color(e,t,i)},c=function(e,t){M.atto_fontcolor.change_color(e,t,s)},h=function(e,t){M.atto_fontcolor.change_color(e,t,o)},p=function(e,t){M.atto_fontcolor.change_color(e,t,u)},d="width: 20px; height: 20px; border: 1px solid #CCC; background-color: ",v='
',m='
',g='
',y='
',b='
',w='
',E=M.util.image_url("e/text_color","core");M.editor_atto.add_toolbar_menu(e.elementid,t,E,e.group,[{text:v,handler:a},{text:m,handler:f},{text:g,handler:l},{text:y,handler:c},{text:b,handler:h},{text:w,handler:p}],"4","#333333")},change_color:function(e,t,n){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("foreColor",0,n),M.editor_atto.text_updated(t)}}},"@VERSION@"); diff --git a/lib/editor/atto/plugins/fontcolor/yui/build/moodle-atto_fontcolor-button/moodle-atto_fontcolor-button.js b/lib/editor/atto/plugins/fontcolor/yui/build/moodle-atto_fontcolor-button/moodle-atto_fontcolor-button.js new file mode 100644 index 0000000000000..56ef173268334 --- /dev/null +++ b/lib/editor/atto/plugins/fontcolor/yui/build/moodle-atto_fontcolor-button/moodle-atto_fontcolor-button.js @@ -0,0 +1,99 @@ +YUI.add('moodle-atto_fontcolor-button', function (Y, NAME) { + +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Atto text editor font color plugin. + * + * @package editor-atto + * @copyright 2014 Rossiani Wijaya + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_fontcolor = M.atto_fontcolor || { + dialogue : null, + init : function(params) { + var plugin = 'fontcolor'; + + var rgb_white = '#FFFFFF', + rgb_red = '#EF4540', + rgb_yellow = '#FFCF35', + rgb_green = '#98CA3E', + rgb_blue = '#7D9FD3', + rgb_black = '#333333'; + + var click_white = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, 'transparent'); + }; + var click_red = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_red); + }; + var click_yellow = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_yellow); + }; + var click_green = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_green); + }; + var click_blue = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_blue); + }; + var click_black = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_black); + }; + + var buttoncss = 'width: 20px; height: 20px; border: 1px solid #CCC; background-color: '; + var white = '
'; + var red = '
'; + var yellow = '
'; + var green = '
'; + var blue = '
'; + var black = '
'; + + var iconurl = M.util.image_url('e/text_color', 'core'); + + M.editor_atto.add_toolbar_menu(params.elementid, + plugin, + iconurl, + params.group, + [ + {'text' : white, 'handler' : click_white}, + {'text' : red, 'handler' : click_red}, + {'text' : yellow, 'handler' : click_yellow}, + {'text' : green, 'handler' : click_green}, + {'text' : blue, 'handler' : click_blue}, + {'text' : black, 'handler' : click_black} + ], + '4', + '#333333'); + }, + + /** + * Handle to change the editor font color. + * @param event e - The event that triggered this. + * @param string elementid - the elemen id of menu icon. + * @param string color - The color for the background. + */ + change_color : function(e, elementid, color) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('foreColor', 0, color); + // Clean the YUI ids from the HTML. + M.editor_atto.text_updated(elementid); + } +}; + +}, '@VERSION@'); diff --git a/lib/editor/atto/plugins/fontcolor/yui/src/button/build.json b/lib/editor/atto/plugins/fontcolor/yui/src/button/build.json new file mode 100644 index 0000000000000..9357f86112c61 --- /dev/null +++ b/lib/editor/atto/plugins/fontcolor/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_fontcolor-button", + "builds": { + "moodle-atto_fontcolor-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/fontcolor/yui/src/button/js/button.js b/lib/editor/atto/plugins/fontcolor/yui/src/button/js/button.js new file mode 100644 index 0000000000000..f48acf8d59a2d --- /dev/null +++ b/lib/editor/atto/plugins/fontcolor/yui/src/button/js/button.js @@ -0,0 +1,95 @@ +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Atto text editor font color plugin. + * + * @package editor-atto + * @copyright 2014 Rossiani Wijaya + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_fontcolor = M.atto_fontcolor || { + dialogue : null, + init : function(params) { + var plugin = 'fontcolor'; + + var rgb_white = '#FFFFFF', + rgb_red = '#EF4540', + rgb_yellow = '#FFCF35', + rgb_green = '#98CA3E', + rgb_blue = '#7D9FD3', + rgb_black = '#333333'; + + var click_white = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, 'transparent'); + }; + var click_red = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_red); + }; + var click_yellow = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_yellow); + }; + var click_green = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_green); + }; + var click_blue = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_blue); + }; + var click_black = function(e, elementid) { + M.atto_fontcolor.change_color(e, elementid, rgb_black); + }; + + var buttoncss = 'width: 20px; height: 20px; border: 1px solid #CCC; background-color: '; + var white = '
'; + var red = '
'; + var yellow = '
'; + var green = '
'; + var blue = '
'; + var black = '
'; + + var iconurl = M.util.image_url('e/text_color', 'core'); + + M.editor_atto.add_toolbar_menu(params.elementid, + plugin, + iconurl, + params.group, + [ + {'text' : white, 'handler' : click_white}, + {'text' : red, 'handler' : click_red}, + {'text' : yellow, 'handler' : click_yellow}, + {'text' : green, 'handler' : click_green}, + {'text' : blue, 'handler' : click_blue}, + {'text' : black, 'handler' : click_black} + ], + '4', + '#333333'); + }, + + /** + * Handle to change the editor font color. + * @param event e - The event that triggered this. + * @param string elementid - the elemen id of menu icon. + * @param string color - The color for the background. + */ + change_color : function(e, elementid, color) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('foreColor', 0, color); + // Clean the YUI ids from the HTML. + M.editor_atto.text_updated(elementid); + } +}; \ No newline at end of file diff --git a/lib/editor/atto/plugins/fontcolor/yui/src/button/meta/editor.js b/lib/editor/atto/plugins/fontcolor/yui/src/button/meta/editor.js new file mode 100644 index 0000000000000..ebbc79e20daf2 --- /dev/null +++ b/lib/editor/atto/plugins/fontcolor/yui/src/button/meta/editor.js @@ -0,0 +1,5 @@ +{ + "moodle-atto_fontcolor-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/styles.css b/lib/editor/atto/styles.css index e71092dff9aa3..341dfafd7dc1e 100644 --- a/lib/editor/atto/styles.css +++ b/lib/editor/atto/styles.css @@ -59,9 +59,9 @@ div.editor_atto_toolbar button[disabled] { div.editor_atto_toolbar button img { padding: 1px; + margin: 1px 0; } - div.editor_atto_toolbar div.atto_group { display: inline-block; border: 1px solid #CCC; @@ -81,7 +81,6 @@ div.editor_atto_toolbar div.atto_group { } .atto_menu { - min-width: 12em; background: white; padding: 1px; } @@ -154,7 +153,7 @@ div.editor_atto_content:hover .atto_control { .editor_atto_controlmenu li { list-style-type: none; padding: 0px; - margin; 0px; + margin: 0px; } .editor_atto_controlmenu ul { padding: 0px; diff --git a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js index ced059099d030..a12206dc99bd7 100644 --- a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js +++ b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js @@ -234,14 +234,23 @@ M.editor_atto = M.editor_atto || { * @param string icon - the html used for the content of the button * @param string groupname - the group the button should be appended to. * @param array entries - List of menu entries with the string (entry.text) and the handlers (entry.handler). + * @param int overlaywidth - the overlay width size. + * @param string menucolor - menu icon background color */ - add_toolbar_menu : function(elementid, plugin, iconurl, groupname, entries) { + add_toolbar_menu : function(elementid, plugin, iconurl, groupname, entries, overlaywidth, menucolor) { var toolbar = M.editor_atto.get_toolbar_node(elementid), group = toolbar.one('.atto_group.' + groupname + '_group'), currentfocus, button, expimgurl; + if ((typeof overlaywidth) === 'undefined') { + overlaywidth = '14'; + } + if ((typeof menucolor) === 'undefined') { + menucolor = 'transparent'; + } + if (!group) { group = Y.Node.create('
'); toolbar.append(group); @@ -253,7 +262,8 @@ M.editor_atto = M.editor_atto || { 'type="button" ' + 'data-menu="' + plugin + '_' + elementid + '" ' + 'title="' + Y.Escape.html(M.util.get_string('pluginname', 'atto_' + plugin)) + '">' + - '' + + '' + '' + ''); @@ -269,7 +279,9 @@ M.editor_atto = M.editor_atto || { M.editor_atto.widgets[plugin] = plugin; var menu = Y.Node.create('
'); + ' atto_menu" data-editor="' + Y.Escape.html(elementid) + '"' + + ' style="min-width:' + (overlaywidth-2) + 'em"' + + '">'); var i = 0, entry = {}; for (i = 0; i < entries.length; i++) { @@ -298,7 +310,7 @@ M.editor_atto = M.editor_atto || { var overlay = new M.core.dialogue({ bodyContent : menu, visible : false, - width: '14em', + width: overlaywidth + 'em', zindex: 100, lightbox: false, closeButton: false, diff --git a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js index a08eb2597bb41..f6713e12e53d7 100644 --- a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js +++ b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-editor_atto-editor",function(e,t){function i(){var e=this.getHTML(),t=[{regex://gi,replace:""},{regex:/<\\?\?xml[^>]*>/gi,replace:""},{regex:/<\/?\w+:[^>]*>/gi,replace:""},{regex:/\s*MSO[-:][^;"']*;?/gi,replace:""},{regex:/]*>( |\s)*<\/span>/gi,replace:""},{regex:/class="Mso[^"]*"/gi,replace:""},{regex:/<(\/?title|\/?meta|\/?style|\/?st\d|\/?head|\/?font|\/?html|\/?body|!\[)[^>]*?>/gi,replace:""},{regex:new RegExp(String.fromCharCode(8220),"gi"),replace:'"'},{regex:new RegExp(String.fromCharCode(8216),"gi"),replace:"'"},{regex:new RegExp(String.fromCharCode(8217),"gi"),replace:"'"},{regex:new RegExp(String.fromCharCode(8211),"gi"),replace:"-"},{regex:new RegExp(String.fromCharCode(8212),"gi"),replace:"--"},{regex:new RegExp(String.fromCharCode(189),"gi"),replace:"1/2"},{regex:new RegExp(String.fromCharCode(188),"gi"),replace:"1/4"},{regex:new RegExp(String.fromCharCode(190),"gi"),replace:"3/4"},{regex:new RegExp(String.fromCharCode(169),"gi"),replace:"(c)"},{regex:new RegExp(String.fromCharCode(174),"gi"),replace:"(r)"},{regex:new RegExp(String.fromCharCode(8230),"gi"),replace:"..."}],n=0,r;for(n=0;n'),o.append(u)),l=M.util.image_url("t/expanded","moodle"),f=e.Node.create('"),u.append(f),a=o.getAttribute("aria-activedescendant"),a||(f.setAttribute("tabindex","0"),o.setAttribute("aria-activedescendant",f.generateID())),M.editor_atto.widgets[n]=n;var c=e.Node.create('
'),h=0,p={};for(h=0;h'+p.text+""+"")),M.editor_atto.buttonhandlers[n+"_action_"+h]||(e.one("body").delegate("click",M.editor_atto.buttonclicked_handler,".atto_"+n+"_action_"+h),e.one("body").delegate("key",M.editor_atto.buttonclicked_handler,"space,enter",".atto_"+n+"_action_"+h),M.editor_atto.buttonhandlers[n+"_action_"+h]=p.handler);M.editor_atto.buttonhandlers[n]||(e.one("body").delegate("click",M.editor_atto.showhide_menu_handler,".atto_"+n+"_button"),M.editor_atto.buttonhandlers[n]=!0);var d=new M.core.dialogue({bodyContent:c,visible:!1,width:"14em",zindex:100,lightbox:!1,closeButton:!1,center:!1});M.editor_atto.menus[n+"_"+t]=d,d.render(),d.align(f,[e.WidgetPositionAlign.TL,e.WidgetPositionAlign.BL]),d.hide(),d.headerNode.hide()},add_toolbar_button:function(t,n,r,i,s){var o=M.editor_atto.get_toolbar_node(t),u=o.one(".atto_group."+i+"_group"),a,f;u||(u=e.Node.create('
'),o.append(u)),a=e.Node.create('"),u.append(a),f=o.getAttribute("aria-activedescendant"),f||(a.setAttribute("tabindex","0"),o.setAttribute("aria-activedescendant",a.generateID())),M.editor_atto.buttonhandlers[n]||(e.one("body").delegate("click",M.editor_atto.buttonclicked_handler,".atto_"+n+"_button"),M.editor_atto.buttonhandlers[n]=s),M.editor_atto -.widgets[n]=n},is_active:function(t){var n=M.editor_atto.get_selection();n.length&&(n=n.pop());var r=null;return n.parentElement?r=e.one(n.parentElement()):r=e.one(n.startContainer),r&&r.ancestor("#"+t+"editable")!==null},focus:function(e){M.editor_atto.get_editable_node(e).focus()},init:function(t){var n=e.Node.create('
'),r=e.Node.create('
'),i="",s=e.Node.create('")),M.editor_atto.buttonhandlers[n+"_action_"+d]||(e.one("body").delegate("click",M.editor_atto.buttonclicked_handler,".atto_"+n+"_action_"+d),e.one("body").delegate("key",M.editor_atto.buttonclicked_handler,"space,enter",".atto_"+n+"_action_"+d),M.editor_atto.buttonhandlers[n+"_action_"+d]=v.handler);M.editor_atto.buttonhandlers[n]||(e.one("body").delegate("click",M.editor_atto.showhide_menu_handler,".atto_"+n+"_button"),M.editor_atto.buttonhandlers[n]=!0);var m=new M.core.dialogue({bodyContent:p,visible:!1,width:o+"em",zindex:100,lightbox:!1,closeButton:!1,center:!1});M.editor_atto.menus[n+"_"+t]=m,m.render(),m.align(c,[e.WidgetPositionAlign.TL,e.WidgetPositionAlign.BL]),m.hide(),m.headerNode.hide()},add_toolbar_button:function(t,n,r,i,s){var o=M.editor_atto.get_toolbar_node(t),u=o.one(".atto_group."+i+"_group"),a,f;u||(u=e.Node.create('
'),o.append(u)),a=e.Node.create('"),u.append(a),f=o.getAttribute("aria-activedescendant"),f||(a.setAttribute("tabindex","0"),o.setAttribute("aria-activedescendant",a.generateID())),M.editor_atto.buttonhandlers +[n]||(e.one("body").delegate("click",M.editor_atto.buttonclicked_handler,".atto_"+n+"_button"),M.editor_atto.buttonhandlers[n]=s),M.editor_atto.widgets[n]=n},is_active:function(t){var n=M.editor_atto.get_selection();n.length&&(n=n.pop());var r=null;return n.parentElement?r=e.one(n.parentElement()):r=e.one(n.startContainer),r&&r.ancestor("#"+t+"editable")!==null},focus:function(e){M.editor_atto.get_editable_node(e).focus()},init:function(t){var n=e.Node.create('
'),r=e.Node.create('
'),i="",s=e.Node.create(''); var i = 0, entry = {}; for (i = 0; i < entries.length; i++) { @@ -296,7 +308,7 @@ M.editor_atto = M.editor_atto || { var overlay = new M.core.dialogue({ bodyContent : menu, visible : false, - width: '14em', + width: overlaywidth + 'em', zindex: 100, lightbox: false, closeButton: false,