diff --git a/lib/editor/atto/lang/en/editor_atto.php b/lib/editor/atto/lang/en/editor_atto.php index b9e84548959..6ae1cc52f9d 100644 --- a/lib/editor/atto/lang/en/editor_atto.php +++ b/lib/editor/atto/lang/en/editor_atto.php @@ -22,6 +22,9 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +$string['cancel'] = 'Cancel'; +$string['confirm'] = 'Confirm'; +$string['confirmrecover'] = 'A previously unsaved version of the text for field "{$a->label}" was found. Do you want to recover it?'; $string['errorcannotparseline'] = 'The line \'{$a}\' is not in the correct format.'; $string['errorgroupisusedtwice'] = 'The group \'{$a}\' is defined twice; group names must be unique.'; $string['errornopluginsorgroupsfound'] = 'No plugins or groups found; please add some groups and plugins.'; @@ -36,9 +39,7 @@ $string['toolbarconfig_desc'] = 'The list of plugins and the order they are disp $string['editor_command_keycode'] = 'Cmd + {$a}'; $string['editor_control_keycode'] = 'Ctrl + {$a}'; $string['plugin_title_shortcut'] = '{$a->title} [{$a->shortcut}]'; -$string['confirm'] = 'Confirm'; -$string['cancel'] = 'Cancel'; $string['recover'] = 'Recover'; $string['infostatus'] = 'Information'; $string['warningstatus'] = 'Warning'; -$string['confirmrecover'] = 'A previously unsaved version of the text for field "{$a->label}" was found. Do you want to recover it?'; +$string['autosavefailed'] = 'Could not connect to the server. If you submit this page now, your changes may be lost.'; diff --git a/lib/editor/atto/lib.php b/lib/editor/atto/lib.php index 4353457b2f5..955f35dd959 100644 --- a/lib/editor/atto/lib.php +++ b/lib/editor/atto/lib.php @@ -128,8 +128,13 @@ class atto_texteditor extends texteditor { 'confirm', 'recover', 'cancel', - 'confirmrecover' + 'confirmrecover', + 'autosavefailed' ), 'editor_atto'); + $PAGE->requires->strings_for_js(array( + 'warning', + 'info' + ), 'moodle'); $PAGE->requires->yui_module($modules, 'Y.M.editor_atto.Editor.init', array($this->get_init_params($elementid, $options, $fpoptions, $jsplugins))); 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 12d38b4189e..3e30f358c79 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 @@ -239,6 +239,8 @@ Y.extend(Editor, Y.Base, { // Initialize the auto-save timer. this.setupAutosave(); + // Preload the icons for the notifications. + this.setupNotifications(); }, /** @@ -493,10 +495,6 @@ function EditorNotify() {} EditorNotify.ATTRS= { }; -// There is no error type here - because you should make errors more obvious. -var NOTIFY_WARNING = 'atto_warning', - NOTIFY_INFO = 'atto_info'; - EditorNotify.prototype = { /** @@ -507,13 +505,40 @@ EditorNotify.prototype = { */ messageOverlay: null, + /** + * A single timer object that can be used to cancel the hiding behaviour. + * + * @property hideTimer + * @type {timer} + */ + hideTimer: null, + + /** + * Initialize the notifications. + * + * @method setupNotifications + * @chainable + */ + setupNotifications: function() { + var preload1 = new Image(), + preload2 = new Image(); + + preload1.src = M.util.image_url('i/warning', 'moodle'); + preload2.src = M.util.image_url('i/info', 'moodle'); + + return this; + }, + /** * Show a notification in a floaty overlay somewhere in the atto editor text area. * * @method showMessage + * @param {String} message - The translated message (use get_string) + * @param {String} type - Must be either "info" or "warning" + * @param {Integer} timeout - Time in milliseconds to show this message for. * @chainable */ - showMessage: function(message, type) { + showMessage: function(message, type, timeout) { if (this.messageOverlay === null) { this.messageOverlay = Y.Node.create('
'); @@ -524,20 +549,34 @@ EditorNotify.prototype = { this.messageOverlay.on('click', function() { this.messageOverlay.hide(); }, this); + } + if (this.hideTimer !== null) { + this.hideTimer.cancel(); } var messageTypeIcon = ''; - if (type === NOTIFY_WARNING) { + if (type === "warning") { messageTypeIcon = '' + M.util.get_string('warning', 'moodle') + ''; - } else if (type === NOTIFY_INFO) { + } else if (type === "info") { messageTypeIcon = '' + M.util.get_string('info', 'moodle') + ''; + } else { + Y.log('Invalid message type specified: ' + type + '. Must be either "info" or "warning".', 'debug'); } + // Parse the timeout value. + var inttimeout = parseInt(timeout, 10); + if (inttimeout <= 0) { + inttimeout = 60000; + } + + // Convert class to atto_info (for example). + type = 'atto_' + type; + var bodyContent = Y.Node.create('