--- /dev/null
+<?php
+// 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 <http://www.gnu.org/licenses/>.
+
+/**
+ * Strings for component 'atto_rtl', language 'en'.
+ *
+ * @package atto_rtl
+ * @copyright 2014 Jerome Mouneyrac
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['pluginname'] = 'RTL/LTR';
+$string['rtl'] = 'Right to left';
+$string['ltr'] = 'Left to right';
--- /dev/null
+<?php
+// 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 <http://www.gnu.org/licenses/>.
+
+/**
+ * Atto text editor rtl plugin lib.
+ *
+ * @package atto_rtl
+ * @copyright 2014 Jerome Mouneyrac
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Initialise the strings required for JS.
+ *
+ * @return void
+ */
+function atto_rtl_strings_for_js() {
+ global $PAGE;
+
+ // In order to prevent extra strings to be imported, comment/uncomment the characters
+ // which are enabled in the JavaScript part of this plugin.
+ $PAGE->requires->strings_for_js(
+ array(
+ 'rtl',
+ 'ltr'
+ ),
+ 'atto_rtl'
+ );
+}
--- /dev/null
+<?php
+// 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 <http://www.gnu.org/licenses/>.
+
+/**
+ * Atto text editor integration version file.
+ *
+ * @package atto_rtl
+ * @copyright 2014 Jerome Mouneyrac
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2014012800; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2013110500; // Requires this Moodle version.
+$plugin->component = 'atto_rtl'; // Full name of the plugin (used for diagnostics).
--- /dev/null
+{
+ "name": "moodle-atto_rtl-button",
+ "builds": {
+ "moodle-atto_rtl-button": {
+ "jsfiles": [
+ "button.js"
+ ]
+ }
+ }
+}
--- /dev/null
+// 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 <http://www.gnu.org/licenses/>.
+
+/**
+ * Atto text editor rtl plugin.
+ *
+ * @package editor_atto
+ * @copyright 2014 Jerome Mouneyrac
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+M.atto_rtl = M.atto_rtl || {
+ init : function(params) {
+ var click = function(e, elementid, direction) {
+ e.preventDefault();
+ if (!M.editor_atto.is_active(elementid)) {
+ M.editor_atto.focus(elementid);
+ }
+
+ M.atto_rtl.selection = M.editor_atto.get_selection();
+ if (M.atto_rtl.selection !== false) {
+
+ // Format the selection to be sure it has a tag parent (not the contenteditable).
+ var parentnode = M.editor_atto.format_selection_block(elementid);
+ parentnodeelement = parentnode.getDOMNode();
+
+ var currentdirection = parentnodeelement.getAttribute("dir");
+ if (currentdirection === direction) {
+ parentnodeelement.removeAttribute("dir");
+ } else {
+ parentnodeelement.setAttribute("dir", direction);
+ }
+ }
+
+ // Clean the YUI ids from the HTML.
+ M.editor_atto.text_updated(elementid);
+ };
+
+ var rtlclick = function(e, elementid) {
+ click(e, elementid, 'rtl');
+ };
+
+ var ltrclick = function(e, elementid) {
+ click(e, elementid, 'ltr');
+ };
+
+ var iconurl = M.util.image_url('e/left_to_right', 'core');
+ M.editor_atto.add_toolbar_button(params.elementid, 'ltr', iconurl, params.group, ltrclick, M.util.get_string('ltr', 'atto_rtl'));
+
+ iconurl = M.util.image_url('e/right_to_left', 'core');
+ M.editor_atto.add_toolbar_button(params.elementid, 'rtl', iconurl, params.group, rtlclick, M.util.get_string('rtl', 'atto_rtl'));
+ }
+};
--- /dev/null
+{
+ "moodle-atto_rtl-button": {
+ "requires": ["node"]
+ }
+}
* @param string plugin - the plugin defining the button.
* @param string icon - the url to the image for the icon
* @param string groupname - the group the button should be appended to.
+ * @param string title - button title. If null, then the title is the 'pluginname' string.
* @handler function handler- A function to call when the button is clicked.
*/
- add_toolbar_button : function(elementid, plugin, iconurl, groupname, handler) {
+ add_toolbar_button : function(elementid, plugin, iconurl, groupname, handler, title) {
var toolbar = M.editor_atto.get_toolbar_node(elementid),
group = toolbar.one('.atto_group.' + groupname + '_group'),
button,
currentfocus;
+ if (!title) {
+ title = M.util.get_string('pluginname', 'atto_' + plugin);
+ }
+
if (!group) {
group = Y.Node.create('<div class="atto_group ' + groupname +'_group"></div>');
toolbar.append(group);
'data-plugin="' + Y.Escape.html(plugin) + '" ' +
'tabindex="-1" ' +
'data-handler="' + Y.Escape.html(plugin) + '" ' +
- 'title="' + Y.Escape.html(M.util.get_string('pluginname', 'atto_' + plugin)) + '">' +
+ 'title="' + Y.Escape.html(title) + '">' +
'<img class="icon" aria-hidden="true" role="presentation" width="16" height="16" src="' + iconurl + '"/>' +
'</button>');