From c90641facbd5746f5fb0da496d4efefaf3066020 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Fri, 9 Aug 2013 14:32:28 +0800 Subject: [PATCH] MDL-41098 Atto Text editor: Add new text editor to core This is an alternative to the TinyMCE text editor that is based on HTML5 content editable regions. It has been designed to "gel" with Moodle and uses YUI for javascript, Moodle standard dialogs and standard moodle buttons. It has also been designed to work well on mobile devices and can collapse down to a narrow column if required. Imported from the plugins database here: https://moodle.org/plugins/view.php?plugin=editor_contenteditable Original git repository here: https://github.com/damyon/contenteditable --- lib/editor/atto/db/subplugins.php | 27 ++ lib/editor/atto/lang/en/editor_atto.php | 25 ++ lib/editor/atto/lib.php | 128 ++++++ .../atto/plugins/bold/lang/en/atto_bold.php | 26 ++ lib/editor/atto/plugins/bold/lib.php | 49 +++ lib/editor/atto/plugins/bold/pix/bold.png | Bin 0 -> 446 bytes lib/editor/atto/plugins/bold/pix/bold.svg | 68 +++ lib/editor/atto/plugins/bold/version.php | 29 ++ .../moodle-atto_bold-button-debug.js | 40 ++ .../moodle-atto_bold-button-min.js | 1 + .../moodle-atto_bold-button.js | 40 ++ .../plugins/bold/yui/src/button/build.json | 10 + .../plugins/bold/yui/src/button/js/button.js | 35 ++ .../bold/yui/src/button/meta/editor.json | 5 + .../atto/plugins/clear/lang/en/atto_clear.php | 26 ++ lib/editor/atto/plugins/clear/lib.php | 52 +++ lib/editor/atto/plugins/clear/pix/clear.png | Bin 0 -> 468 bytes lib/editor/atto/plugins/clear/pix/clear.svg | 85 ++++ lib/editor/atto/plugins/clear/version.php | 29 ++ .../moodle-atto_clear-button-debug.js | 40 ++ .../moodle-atto_clear-button-min.js | 1 + .../moodle-atto_clear-button.js | 40 ++ .../plugins/clear/yui/src/button/build.json | 10 + .../plugins/clear/yui/src/button/js/button.js | 35 ++ .../clear/yui/src/button/meta/editor.json | 5 + .../atto/plugins/html/lang/en/atto_html.php | 26 ++ lib/editor/atto/plugins/html/lib.php | 49 +++ lib/editor/atto/plugins/html/pix/html.png | Bin 0 -> 466 bytes lib/editor/atto/plugins/html/pix/html.svg | 69 +++ lib/editor/atto/plugins/html/version.php | 29 ++ .../moodle-atto_html-button-debug.js | 59 +++ .../moodle-atto_html-button-min.js | 1 + .../moodle-atto_html-button.js | 59 +++ .../plugins/html/yui/src/button/build.json | 10 + .../plugins/html/yui/src/button/js/button.js | 54 +++ .../html/yui/src/button/meta/editor.json | 7 + .../atto/plugins/image/lang/en/atto_image.php | 34 ++ lib/editor/atto/plugins/image/lib.php | 60 +++ lib/editor/atto/plugins/image/pix/image.png | Bin 0 -> 506 bytes lib/editor/atto/plugins/image/pix/image.svg | 77 ++++ lib/editor/atto/plugins/image/version.php | 29 ++ .../moodle-atto_image-button-debug.js | 184 ++++++++ .../moodle-atto_image-button-min.js | 1 + .../moodle-atto_image-button.js | 184 ++++++++ .../plugins/image/yui/src/button/build.json | 10 + .../plugins/image/yui/src/button/js/button.js | 179 ++++++++ .../image/yui/src/button/meta/editor.json | 8 + .../plugins/indent/lang/en/atto_indent.php | 26 ++ lib/editor/atto/plugins/indent/lib.php | 52 +++ lib/editor/atto/plugins/indent/pix/indent.png | Bin 0 -> 439 bytes lib/editor/atto/plugins/indent/pix/indent.svg | 68 +++ lib/editor/atto/plugins/indent/version.php | 29 ++ .../moodle-atto_indent-button-debug.js | 40 ++ .../moodle-atto_indent-button-min.js | 1 + .../moodle-atto_indent-button.js | 40 ++ .../plugins/indent/yui/src/button/build.json | 10 + .../indent/yui/src/button/js/button.js | 35 ++ .../indent/yui/src/button/meta/editor.json | 5 + .../plugins/italic/lang/en/atto_italic.php | 26 ++ lib/editor/atto/plugins/italic/lib.php | 52 +++ lib/editor/atto/plugins/italic/pix/italic.png | Bin 0 -> 418 bytes lib/editor/atto/plugins/italic/pix/italic.svg | 68 +++ lib/editor/atto/plugins/italic/version.php | 29 ++ .../moodle-atto_italic-button-debug.js | 40 ++ .../moodle-atto_italic-button-min.js | 1 + .../moodle-atto_italic-button.js | 40 ++ .../plugins/italic/yui/src/button/build.json | 10 + .../italic/yui/src/button/js/button.js | 35 ++ .../italic/yui/src/button/meta/editor.json | 5 + .../atto/plugins/link/lang/en/atto_link.php | 30 ++ lib/editor/atto/plugins/link/lib.php | 58 +++ lib/editor/atto/plugins/link/pix/link.png | Bin 0 -> 471 bytes lib/editor/atto/plugins/link/pix/link.svg | 80 ++++ lib/editor/atto/plugins/link/version.php | 29 ++ .../moodle-atto_link-button-debug.js | 132 ++++++ .../moodle-atto_link-button-min.js | 1 + .../moodle-atto_link-button.js | 132 ++++++ .../plugins/link/yui/src/button/build.json | 10 + .../plugins/link/yui/src/button/js/button.js | 127 ++++++ .../link/yui/src/button/meta/editor.json | 8 + .../atto/plugins/media/lang/en/atto_media.php | 33 ++ lib/editor/atto/plugins/media/lib.php | 56 +++ lib/editor/atto/plugins/media/pix/media.png | Bin 0 -> 489 bytes lib/editor/atto/plugins/media/pix/media.svg | 105 +++++ lib/editor/atto/plugins/media/version.php | 29 ++ .../moodle-atto_media-button-debug.js | 119 +++++ .../moodle-atto_media-button-min.js | 1 + .../moodle-atto_media-button.js | 119 +++++ .../plugins/media/yui/src/button/build.json | 10 + .../plugins/media/yui/src/button/js/button.js | 114 +++++ .../media/yui/src/button/meta/editor.json | 8 + .../orderedlist/lang/en/atto_orderedlist.php | 26 ++ lib/editor/atto/plugins/orderedlist/lib.php | 52 +++ .../plugins/orderedlist/pix/orderedlist.png | Bin 0 -> 465 bytes .../plugins/orderedlist/pix/orderedlist.svg | 80 ++++ .../atto/plugins/orderedlist/version.php | 29 ++ .../moodle-atto_orderedlist-button-debug.js | 40 ++ .../moodle-atto_orderedlist-button-min.js | 1 + .../moodle-atto_orderedlist-button.js | 40 ++ .../orderedlist/yui/src/button/build.json | 10 + .../orderedlist/yui/src/button/js/button.js | 35 ++ .../yui/src/button/meta/editor.json | 5 + .../plugins/outdent/lang/en/atto_outdent.php | 26 ++ lib/editor/atto/plugins/outdent/lib.php | 50 +++ .../atto/plugins/outdent/pix/outdent.png | Bin 0 -> 440 bytes .../atto/plugins/outdent/pix/outdent.svg | 68 +++ lib/editor/atto/plugins/outdent/version.php | 29 ++ .../moodle-atto_outdent-button-debug.js | 40 ++ .../moodle-atto_outdent-button-min.js | 1 + .../moodle-atto_outdent-button.js | 40 ++ .../plugins/outdent/yui/src/button/build.json | 10 + .../outdent/yui/src/button/js/button.js | 35 ++ .../outdent/yui/src/button/meta/editor.json | 5 + .../plugins/strike/lang/en/atto_strike.php | 26 ++ lib/editor/atto/plugins/strike/lib.php | 52 +++ lib/editor/atto/plugins/strike/pix/strike.png | Bin 0 -> 479 bytes lib/editor/atto/plugins/strike/pix/strike.svg | 77 ++++ lib/editor/atto/plugins/strike/version.php | 29 ++ .../moodle-atto_strike-button-debug.js | 40 ++ .../moodle-atto_strike-button-min.js | 1 + .../moodle-atto_strike-button.js | 40 ++ .../plugins/strike/yui/src/button/build.json | 10 + .../strike/yui/src/button/js/button.js | 35 ++ .../strike/yui/src/button/meta/editor.json | 5 + .../atto/plugins/title/lang/en/atto_title.php | 30 ++ lib/editor/atto/plugins/title/lib.php | 56 +++ lib/editor/atto/plugins/title/pix/title.png | Bin 0 -> 550 bytes lib/editor/atto/plugins/title/pix/title.svg | 87 ++++ lib/editor/atto/plugins/title/version.php | 29 ++ .../moodle-atto_title-button-debug.js | 74 ++++ .../moodle-atto_title-button-min.js | 1 + .../moodle-atto_title-button.js | 74 ++++ .../plugins/title/yui/src/button/build.json | 10 + .../plugins/title/yui/src/button/js/button.js | 69 +++ .../title/yui/src/button/meta/editor.json | 5 + .../underline/lang/en/atto_underline.php | 26 ++ lib/editor/atto/plugins/underline/lib.php | 52 +++ .../atto/plugins/underline/pix/underline.png | Bin 0 -> 430 bytes .../atto/plugins/underline/pix/underline.svg | 73 ++++ lib/editor/atto/plugins/underline/version.php | 29 ++ .../moodle-atto_underline-button-debug.js | 40 ++ .../moodle-atto_underline-button-min.js | 1 + .../moodle-atto_underline-button.js | 40 ++ .../underline/yui/src/button/build.json | 10 + .../underline/yui/src/button/js/button.js | 35 ++ .../underline/yui/src/button/meta/editor.json | 5 + .../plugins/unlink/lang/en/atto_unlink.php | 26 ++ lib/editor/atto/plugins/unlink/lib.php | 50 +++ lib/editor/atto/plugins/unlink/pix/unlink.png | Bin 0 -> 534 bytes lib/editor/atto/plugins/unlink/pix/unlink.svg | 92 ++++ lib/editor/atto/plugins/unlink/version.php | 29 ++ .../moodle-atto_unlink-button-debug.js | 40 ++ .../moodle-atto_unlink-button-min.js | 1 + .../moodle-atto_unlink-button.js | 40 ++ .../plugins/unlink/yui/src/button/build.json | 10 + .../unlink/yui/src/button/js/button.js | 35 ++ .../unlink/yui/src/button/meta/editor.json | 5 + .../lang/en/atto_unorderedlist.php | 26 ++ lib/editor/atto/plugins/unorderedlist/lib.php | 50 +++ .../unorderedlist/pix/unorderedlist.png | Bin 0 -> 441 bytes .../unorderedlist/pix/unorderedlist.svg | 111 +++++ .../atto/plugins/unorderedlist/version.php | 29 ++ .../moodle-atto_unorderedlist-button-debug.js | 40 ++ .../moodle-atto_unorderedlist-button-min.js | 1 + .../moodle-atto_unorderedlist-button.js | 40 ++ .../unorderedlist/yui/src/button/build.json | 10 + .../unorderedlist/yui/src/button/js/button.js | 35 ++ .../yui/src/button/meta/editor.json | 5 + lib/editor/atto/styles.css | 71 +++ lib/editor/atto/version.php | 29 ++ .../moodle-editor_atto-editor-debug.js | 412 ++++++++++++++++++ .../moodle-editor_atto-editor-min.js | 1 + .../moodle-editor_atto-editor.js | 412 ++++++++++++++++++ lib/editor/atto/yui/src/editor/build.json | 10 + lib/editor/atto/yui/src/editor/js/editor.js | 407 +++++++++++++++++ .../atto/yui/src/editor/meta/editor.json | 11 + lib/editorlib.php | 2 +- lib/pluginlib.php | 8 +- 178 files changed, 7467 insertions(+), 2 deletions(-) create mode 100644 lib/editor/atto/db/subplugins.php create mode 100644 lib/editor/atto/lang/en/editor_atto.php create mode 100644 lib/editor/atto/lib.php create mode 100644 lib/editor/atto/plugins/bold/lang/en/atto_bold.php create mode 100644 lib/editor/atto/plugins/bold/lib.php create mode 100644 lib/editor/atto/plugins/bold/pix/bold.png create mode 100644 lib/editor/atto/plugins/bold/pix/bold.svg create mode 100644 lib/editor/atto/plugins/bold/version.php create mode 100644 lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button-debug.js create mode 100644 lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button-min.js create mode 100644 lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button.js create mode 100644 lib/editor/atto/plugins/bold/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/bold/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/bold/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/clear/lang/en/atto_clear.php create mode 100644 lib/editor/atto/plugins/clear/lib.php create mode 100644 lib/editor/atto/plugins/clear/pix/clear.png create mode 100644 lib/editor/atto/plugins/clear/pix/clear.svg create mode 100644 lib/editor/atto/plugins/clear/version.php create mode 100644 lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button-debug.js create mode 100644 lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button-min.js create mode 100644 lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button.js create mode 100644 lib/editor/atto/plugins/clear/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/clear/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/clear/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/html/lang/en/atto_html.php create mode 100644 lib/editor/atto/plugins/html/lib.php create mode 100644 lib/editor/atto/plugins/html/pix/html.png create mode 100644 lib/editor/atto/plugins/html/pix/html.svg create mode 100644 lib/editor/atto/plugins/html/version.php create mode 100644 lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-debug.js create mode 100644 lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-min.js create mode 100644 lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button.js create mode 100644 lib/editor/atto/plugins/html/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/html/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/html/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/image/lang/en/atto_image.php create mode 100644 lib/editor/atto/plugins/image/lib.php create mode 100644 lib/editor/atto/plugins/image/pix/image.png create mode 100644 lib/editor/atto/plugins/image/pix/image.svg create mode 100644 lib/editor/atto/plugins/image/version.php create mode 100644 lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-debug.js create mode 100644 lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-min.js create mode 100644 lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button.js create mode 100644 lib/editor/atto/plugins/image/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/image/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/image/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/indent/lang/en/atto_indent.php create mode 100644 lib/editor/atto/plugins/indent/lib.php create mode 100644 lib/editor/atto/plugins/indent/pix/indent.png create mode 100644 lib/editor/atto/plugins/indent/pix/indent.svg create mode 100644 lib/editor/atto/plugins/indent/version.php create mode 100644 lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-debug.js create mode 100644 lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-min.js create mode 100644 lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button.js create mode 100644 lib/editor/atto/plugins/indent/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/indent/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/indent/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/italic/lang/en/atto_italic.php create mode 100644 lib/editor/atto/plugins/italic/lib.php create mode 100644 lib/editor/atto/plugins/italic/pix/italic.png create mode 100644 lib/editor/atto/plugins/italic/pix/italic.svg create mode 100644 lib/editor/atto/plugins/italic/version.php create mode 100644 lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-debug.js create mode 100644 lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-min.js create mode 100644 lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button.js create mode 100644 lib/editor/atto/plugins/italic/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/italic/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/italic/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/link/lang/en/atto_link.php create mode 100644 lib/editor/atto/plugins/link/lib.php create mode 100644 lib/editor/atto/plugins/link/pix/link.png create mode 100644 lib/editor/atto/plugins/link/pix/link.svg create mode 100644 lib/editor/atto/plugins/link/version.php create mode 100644 lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-debug.js create mode 100644 lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-min.js create mode 100644 lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button.js create mode 100644 lib/editor/atto/plugins/link/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/link/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/link/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/media/lang/en/atto_media.php create mode 100644 lib/editor/atto/plugins/media/lib.php create mode 100644 lib/editor/atto/plugins/media/pix/media.png create mode 100644 lib/editor/atto/plugins/media/pix/media.svg create mode 100644 lib/editor/atto/plugins/media/version.php create mode 100644 lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button-debug.js create mode 100644 lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button-min.js create mode 100644 lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button.js create mode 100644 lib/editor/atto/plugins/media/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/media/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/media/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/orderedlist/lang/en/atto_orderedlist.php create mode 100644 lib/editor/atto/plugins/orderedlist/lib.php create mode 100644 lib/editor/atto/plugins/orderedlist/pix/orderedlist.png create mode 100644 lib/editor/atto/plugins/orderedlist/pix/orderedlist.svg create mode 100644 lib/editor/atto/plugins/orderedlist/version.php create mode 100644 lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button-debug.js create mode 100644 lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button-min.js create mode 100644 lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button.js create mode 100644 lib/editor/atto/plugins/orderedlist/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/orderedlist/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/orderedlist/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/outdent/lang/en/atto_outdent.php create mode 100644 lib/editor/atto/plugins/outdent/lib.php create mode 100644 lib/editor/atto/plugins/outdent/pix/outdent.png create mode 100644 lib/editor/atto/plugins/outdent/pix/outdent.svg create mode 100644 lib/editor/atto/plugins/outdent/version.php create mode 100644 lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button-debug.js create mode 100644 lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button-min.js create mode 100644 lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button.js create mode 100644 lib/editor/atto/plugins/outdent/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/outdent/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/outdent/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/strike/lang/en/atto_strike.php create mode 100644 lib/editor/atto/plugins/strike/lib.php create mode 100644 lib/editor/atto/plugins/strike/pix/strike.png create mode 100644 lib/editor/atto/plugins/strike/pix/strike.svg create mode 100644 lib/editor/atto/plugins/strike/version.php create mode 100644 lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button-debug.js create mode 100644 lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button-min.js create mode 100644 lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button.js create mode 100644 lib/editor/atto/plugins/strike/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/strike/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/strike/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/title/lang/en/atto_title.php create mode 100644 lib/editor/atto/plugins/title/lib.php create mode 100644 lib/editor/atto/plugins/title/pix/title.png create mode 100644 lib/editor/atto/plugins/title/pix/title.svg create mode 100644 lib/editor/atto/plugins/title/version.php create mode 100644 lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button-debug.js create mode 100644 lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button-min.js create mode 100644 lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button.js create mode 100644 lib/editor/atto/plugins/title/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/title/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/title/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/underline/lang/en/atto_underline.php create mode 100644 lib/editor/atto/plugins/underline/lib.php create mode 100644 lib/editor/atto/plugins/underline/pix/underline.png create mode 100644 lib/editor/atto/plugins/underline/pix/underline.svg create mode 100644 lib/editor/atto/plugins/underline/version.php create mode 100644 lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button-debug.js create mode 100644 lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button-min.js create mode 100644 lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button.js create mode 100644 lib/editor/atto/plugins/underline/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/underline/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/underline/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/unlink/lang/en/atto_unlink.php create mode 100644 lib/editor/atto/plugins/unlink/lib.php create mode 100644 lib/editor/atto/plugins/unlink/pix/unlink.png create mode 100644 lib/editor/atto/plugins/unlink/pix/unlink.svg create mode 100644 lib/editor/atto/plugins/unlink/version.php create mode 100644 lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button-debug.js create mode 100644 lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button-min.js create mode 100644 lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button.js create mode 100644 lib/editor/atto/plugins/unlink/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/unlink/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/unlink/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/plugins/unorderedlist/lang/en/atto_unorderedlist.php create mode 100644 lib/editor/atto/plugins/unorderedlist/lib.php create mode 100644 lib/editor/atto/plugins/unorderedlist/pix/unorderedlist.png create mode 100644 lib/editor/atto/plugins/unorderedlist/pix/unorderedlist.svg create mode 100644 lib/editor/atto/plugins/unorderedlist/version.php create mode 100644 lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button-debug.js create mode 100644 lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button-min.js create mode 100644 lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button.js create mode 100644 lib/editor/atto/plugins/unorderedlist/yui/src/button/build.json create mode 100644 lib/editor/atto/plugins/unorderedlist/yui/src/button/js/button.js create mode 100644 lib/editor/atto/plugins/unorderedlist/yui/src/button/meta/editor.json create mode 100644 lib/editor/atto/styles.css create mode 100644 lib/editor/atto/version.php create mode 100644 lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js create mode 100644 lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js create mode 100644 lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor.js create mode 100644 lib/editor/atto/yui/src/editor/build.json create mode 100644 lib/editor/atto/yui/src/editor/js/editor.js create mode 100644 lib/editor/atto/yui/src/editor/meta/editor.json diff --git a/lib/editor/atto/db/subplugins.php b/lib/editor/atto/db/subplugins.php new file mode 100644 index 00000000000..de0b440b77c --- /dev/null +++ b/lib/editor/atto/db/subplugins.php @@ -0,0 +1,27 @@ +. + +/** + * Yui Editor + * + * @package editor_atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$subplugins = array('atto' => 'lib/editor/atto/plugins'); diff --git a/lib/editor/atto/lang/en/editor_atto.php b/lib/editor/atto/lang/en/editor_atto.php new file mode 100644 index 00000000000..3ade27d86ca --- /dev/null +++ b/lib/editor/atto/lang/en/editor_atto.php @@ -0,0 +1,25 @@ +. + +/** + * Strings for component 'editor_atto', language 'en'. + * + * @package editor_atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Atto HTML editor'; diff --git a/lib/editor/atto/lib.php b/lib/editor/atto/lib.php new file mode 100644 index 00000000000..f2ec963c1aa --- /dev/null +++ b/lib/editor/atto/lib.php @@ -0,0 +1,128 @@ +. + +/** + * YUI text editor integration. + * + * @package editor_atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * This is the texteditor implementation. + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class atto_texteditor extends texteditor { + + /** + * Is the current browser supported by this editor? + * + * Of course! + * @return bool + */ + public function supported_by_browser() { + return true; + } + + /** + * Returns array of supported text formats. + * @return array + */ + public function get_supported_formats() { + // FORMAT_MOODLE is not supported here, sorry. + return array(FORMAT_HTML => FORMAT_HTML); + } + + /** + * Returns text format preferred by this editor. + * @return int + */ + public function get_preferred_format() { + return FORMAT_HTML; + } + + /** + * Does this editor support picking from repositories? + * @return bool + */ + public function supports_repositories() { + return true; + } + + /** + * Use this editor for give element. + * + * @param string $elementid + * @param array $options + * @param null $fpoptions + */ + public function use_editor($elementid, array $options=null, $fpoptions=null) { + global $PAGE, $CFG; + $PAGE->requires->yui_module('moodle-editor_atto-editor', + 'M.editor_atto.init', + array($this->get_init_params($elementid, $options, $fpoptions)), true); + require_once($CFG->libdir . '/pluginlib.php'); + + $pluginman = plugin_manager::instance(); + $plugins = $pluginman->get_subplugins_of_plugin('editor_atto'); + + $sortedplugins = array(); + + foreach ($plugins as $id => $plugin) { + $sortorder = component_callback($plugin->type . '_' . $plugin->name, 'sort_order', array($elementid)); + $sortedplugins[$sortorder] = $plugin; + } + + ksort($sortedplugins); + foreach ($sortedplugins as $plugin) { + component_callback($plugin->type . '_' . $plugin->name, 'init_editor', array($elementid)); + } + + } + + /** + * Create a params array to init the editor. + * + * @param string $elementid + * @param array $options + * @param array $fpoptions + */ + protected function get_init_params($elementid, array $options=null, array $fpoptions=null) { + global $PAGE; + + $directionality = get_string('thisdirection', 'langconfig'); + $strtime = get_string('strftimetime'); + $strdate = get_string('strftimedaydate'); + $lang = current_language(); + $contentcss = $PAGE->theme->editor_css_url()->out(false); + + $params = array( + 'elementid' => $elementid, + 'content_css' => $contentcss, + 'language' => $lang, + 'directionality' => $directionality, + 'filepickeroptions' => array() + ); + if ($fpoptions) { + $params['filepickeroptions'] = $fpoptions; + } + return $params; + } +} diff --git a/lib/editor/atto/plugins/bold/lang/en/atto_bold.php b/lib/editor/atto/plugins/bold/lang/en/atto_bold.php new file mode 100644 index 00000000000..7c92bdfc521 --- /dev/null +++ b/lib/editor/atto/plugins/bold/lang/en/atto_bold.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'atto_bold', language 'en'. + * + * @package atto_bold + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Bold'; +$string['bold'] = 'Bold'; diff --git a/lib/editor/atto/plugins/bold/lib.php b/lib/editor/atto/plugins/bold/lib.php new file mode 100644 index 00000000000..35d97c80b09 --- /dev/null +++ b/lib/editor/atto/plugins/bold/lib.php @@ -0,0 +1,49 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_bold + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_bold_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('bold', get_string('bold', 'atto_bold'), 'atto_bold', array('class'=>'icon')); + + $PAGE->requires->yui_module('moodle-atto_bold-button', + 'M.atto_bold.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_bold_sort_order() { + return 0; +} diff --git a/lib/editor/atto/plugins/bold/pix/bold.png b/lib/editor/atto/plugins/bold/pix/bold.png new file mode 100644 index 0000000000000000000000000000000000000000..57ee78ee4badfb75b1e33b9d85255d8f8cb767b7 GIT binary patch literal 446 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWP1JzX3_G|un6sL0jeAi@&xzMjcF;=kUSCY^|@k62R-rFxPKW|^H7Z+_do z=)n?BeIB19=ACj)0u76PFjlNTIb+>!hK{wl(Q6wM1st17Q|F~0uoQf9^Wrw$#vr8) z-&kBevFUJsHepQFWLnxWYgSN#jB7w>ZGMm1`};K?8Q;j;-;T6PvHJ*gh-!&zL`h0w zNvc(HQ7VvPFfuSS)-^EIH8c(}GPE)^vobK&Hn6ZVFi7Y4d>chWZhlH;S|x4`VxivY zKn>*}8;Z-)t&$RpQ*}#=G8xh`b5gDJ_4PCIb5r$G5_2o_^YnA`^HXwCi}f?}N>bB{ z5=%1k^Wt+8i%U|Api=rdnMwMoDVZhtMf%D4Kvh5l + + + + + + + + + image/svg+xml + + + + + + + b + + diff --git a/lib/editor/atto/plugins/bold/version.php b/lib/editor/atto/plugins/bold/version.php new file mode 100644 index 00000000000..d25795b7310 --- /dev/null +++ b/lib/editor/atto/plugins/bold/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_bold + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_bold'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button-debug.js b/lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button-debug.js new file mode 100644 index 00000000000..210bb078c8e --- /dev/null +++ b/lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button-debug.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_bold-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 bold plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_bold = M.atto_bold || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('bold', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'bold', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button-min.js b/lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button-min.js new file mode 100644 index 00000000000..e843f39d8f3 --- /dev/null +++ b/lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_bold-button",function(e,t){M.atto_bold=M.atto_bold||{init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("bold",!1,null)};M.editor_atto.add_toolbar_button(e.elementid,"bold",e.icon,t)}}},"@VERSION@",{requires:["node"]}); diff --git a/lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button.js b/lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button.js new file mode 100644 index 00000000000..210bb078c8e --- /dev/null +++ b/lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_bold-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 bold plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_bold = M.atto_bold || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('bold', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'bold', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/bold/yui/src/button/build.json b/lib/editor/atto/plugins/bold/yui/src/button/build.json new file mode 100644 index 00000000000..112075088a9 --- /dev/null +++ b/lib/editor/atto/plugins/bold/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_bold-button", + "builds": { + "moodle-atto_bold-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/bold/yui/src/button/js/button.js b/lib/editor/atto/plugins/bold/yui/src/button/js/button.js new file mode 100644 index 00000000000..5648d91eb6e --- /dev/null +++ b/lib/editor/atto/plugins/bold/yui/src/button/js/button.js @@ -0,0 +1,35 @@ +// 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 bold plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_bold = M.atto_bold || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('bold', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'bold', params.icon, click); + } +}; diff --git a/lib/editor/atto/plugins/bold/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/bold/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..e668c0ffbdd --- /dev/null +++ b/lib/editor/atto/plugins/bold/yui/src/button/meta/editor.json @@ -0,0 +1,5 @@ +{ + "moodle-atto_bold-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/plugins/clear/lang/en/atto_clear.php b/lib/editor/atto/plugins/clear/lang/en/atto_clear.php new file mode 100644 index 00000000000..4f14b919b7d --- /dev/null +++ b/lib/editor/atto/plugins/clear/lang/en/atto_clear.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'atto_clear', language 'en'. + * + * @package atto_clear + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Clear formatting'; +$string['clear'] = 'Clear formatting'; diff --git a/lib/editor/atto/plugins/clear/lib.php b/lib/editor/atto/plugins/clear/lib.php new file mode 100644 index 00000000000..0e2081c427b --- /dev/null +++ b/lib/editor/atto/plugins/clear/lib.php @@ -0,0 +1,52 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_clear + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_clear_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('clear', + get_string('clear', 'atto_clear'), + 'atto_clear', + array('class'=>'icon')); + + $PAGE->requires->yui_module('moodle-atto_clear-button', + 'M.atto_clear.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_clear_sort_order() { + return 10; +} diff --git a/lib/editor/atto/plugins/clear/pix/clear.png b/lib/editor/atto/plugins/clear/pix/clear.png new file mode 100644 index 0000000000000000000000000000000000000000..7f5815b42bb54340cac110febd3da17687bf2dfe GIT binary patch literal 468 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWOIdb&7fr9fAM?1gI9#|FXl^M>dg-@nS znF2xuLPZ!?WFJ{BzGw=ggge_Q?u1!P32&QaPd}gOXmTlv?Wf#DPK)a%OT%y1*10< + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/lib/editor/atto/plugins/clear/version.php b/lib/editor/atto/plugins/clear/version.php new file mode 100644 index 00000000000..63868eed264 --- /dev/null +++ b/lib/editor/atto/plugins/clear/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_clear + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_clear'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button-debug.js b/lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button-debug.js new file mode 100644 index 00000000000..bcfb7042794 --- /dev/null +++ b/lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button-debug.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_clear-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 clear plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_clear = M.atto_clear || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('removeFormat', false); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'clear', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button-min.js b/lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button-min.js new file mode 100644 index 00000000000..7716f7bf93b --- /dev/null +++ b/lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_clear-button",function(e,t){M.atto_clear=M.atto_clear||{init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("removeFormat",!1)};M.editor_atto.add_toolbar_button(e.elementid,"clear",e.icon,t)}}},"@VERSION@",{requires:["node"]}); diff --git a/lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button.js b/lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button.js new file mode 100644 index 00000000000..bcfb7042794 --- /dev/null +++ b/lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_clear-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 clear plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_clear = M.atto_clear || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('removeFormat', false); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'clear', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/clear/yui/src/button/build.json b/lib/editor/atto/plugins/clear/yui/src/button/build.json new file mode 100644 index 00000000000..aeee2de6040 --- /dev/null +++ b/lib/editor/atto/plugins/clear/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_clear-button", + "builds": { + "moodle-atto_clear-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/clear/yui/src/button/js/button.js b/lib/editor/atto/plugins/clear/yui/src/button/js/button.js new file mode 100644 index 00000000000..0430f8b07f0 --- /dev/null +++ b/lib/editor/atto/plugins/clear/yui/src/button/js/button.js @@ -0,0 +1,35 @@ +// 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 clear plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_clear = M.atto_clear || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('removeFormat', false); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'clear', params.icon, click); + } +}; diff --git a/lib/editor/atto/plugins/clear/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/clear/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..39aab1ce8c8 --- /dev/null +++ b/lib/editor/atto/plugins/clear/yui/src/button/meta/editor.json @@ -0,0 +1,5 @@ +{ + "moodle-atto_clear-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/plugins/html/lang/en/atto_html.php b/lib/editor/atto/plugins/html/lang/en/atto_html.php new file mode 100644 index 00000000000..2f76ccf161d --- /dev/null +++ b/lib/editor/atto/plugins/html/lang/en/atto_html.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'atto_html', language 'en'. + * + * @package atto_html + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'HTML'; +$string['html'] = 'HTML'; diff --git a/lib/editor/atto/plugins/html/lib.php b/lib/editor/atto/plugins/html/lib.php new file mode 100644 index 00000000000..f97ed33a837 --- /dev/null +++ b/lib/editor/atto/plugins/html/lib.php @@ -0,0 +1,49 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_html + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_html_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('html', get_string('html', 'atto_html'), 'atto_html', array('class'=>'icon')); + + $PAGE->requires->yui_module('moodle-atto_html-button', + 'M.atto_html.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_html_sort_order() { + return 15; +} diff --git a/lib/editor/atto/plugins/html/pix/html.png b/lib/editor/atto/plugins/html/pix/html.png new file mode 100644 index 0000000000000000000000000000000000000000..0623bd748d738f6d8912be3b239a979352405590 GIT binary patch literal 466 zcmV;@0WJQCP)OR)obh+kEfc zEv;I7MM2BL(%!vuEZc;^ioqhTS}cNfU@)0{Kfac2JavjV&;zHO?>QgN`N9#Bm?YFh z(|-oA*4BRw2!ddp + + + + + + + + + media/svg+xml + + + + + + + </> + + diff --git a/lib/editor/atto/plugins/html/version.php b/lib/editor/atto/plugins/html/version.php new file mode 100644 index 00000000000..6058df1cbf7 --- /dev/null +++ b/lib/editor/atto/plugins/html/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_html + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_html'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-debug.js b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-debug.js new file mode 100644 index 00000000000..8b32aadd636 --- /dev/null +++ b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-debug.js @@ -0,0 +1,59 @@ +YUI.add('moodle-atto_html-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 html plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_html = M.atto_html || { + /** + * Are we in html editing mode or not? + */ + ishtml : false, + + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + var textarea = Y.one('#' + elementid); + var atto = Y.one('#' + elementid + 'editable'); + + if (M.atto_html.ishtml) { + M.editor_atto.enable_all_widgets(elementid); + atto.setHTML(''); + atto.append(textarea.get('value')); + textarea.hide(); + atto.show(); + } else { + M.editor_atto.disable_all_widgets(elementid); + M.editor_atto.enable_widget(elementid, 'html'); + textarea.set('value', atto.getHTML()); + atto.hide(); + textarea.show(); + } + + M.atto_html.ishtml = !M.atto_html.ishtml; + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'html', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-min.js b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-min.js new file mode 100644 index 00000000000..bf8e2cc7de3 --- /dev/null +++ b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_html-button",function(e,t){M.atto_html=M.atto_html||{ishtml:!1,init:function(t){var n=function(t,n){t.preventDefault();var r=e.one("#"+n),i=e.one("#"+n+"editable");M.atto_html.ishtml?(M.editor_atto.enable_all_widgets(n),i.setHTML(""),i.append(r.get("value")),r.hide(),i.show()):(M.editor_atto.disable_all_widgets(n),M.editor_atto.enable_widget(n,"html"),r.set("value",i.getHTML()),i.hide(),r.show()),M.atto_html.ishtml=!M.atto_html.ishtml};M.editor_atto.add_toolbar_button(t.elementid,"html",t.icon,n)}}},"@VERSION@",{requires:["node"]}); diff --git a/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button.js b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button.js new file mode 100644 index 00000000000..8b32aadd636 --- /dev/null +++ b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button.js @@ -0,0 +1,59 @@ +YUI.add('moodle-atto_html-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 html plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_html = M.atto_html || { + /** + * Are we in html editing mode or not? + */ + ishtml : false, + + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + var textarea = Y.one('#' + elementid); + var atto = Y.one('#' + elementid + 'editable'); + + if (M.atto_html.ishtml) { + M.editor_atto.enable_all_widgets(elementid); + atto.setHTML(''); + atto.append(textarea.get('value')); + textarea.hide(); + atto.show(); + } else { + M.editor_atto.disable_all_widgets(elementid); + M.editor_atto.enable_widget(elementid, 'html'); + textarea.set('value', atto.getHTML()); + atto.hide(); + textarea.show(); + } + + M.atto_html.ishtml = !M.atto_html.ishtml; + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'html', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/html/yui/src/button/build.json b/lib/editor/atto/plugins/html/yui/src/button/build.json new file mode 100644 index 00000000000..96489619d7b --- /dev/null +++ b/lib/editor/atto/plugins/html/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_html-button", + "builds": { + "moodle-atto_html-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/html/yui/src/button/js/button.js b/lib/editor/atto/plugins/html/yui/src/button/js/button.js new file mode 100644 index 00000000000..18520ed679d --- /dev/null +++ b/lib/editor/atto/plugins/html/yui/src/button/js/button.js @@ -0,0 +1,54 @@ +// 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 html plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_html = M.atto_html || { + /** + * Are we in html editing mode or not? + */ + ishtml : false, + + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + var textarea = Y.one('#' + elementid); + var atto = Y.one('#' + elementid + 'editable'); + + if (M.atto_html.ishtml) { + M.editor_atto.enable_all_widgets(elementid); + atto.setHTML(''); + atto.append(textarea.get('value')); + textarea.hide(); + atto.show(); + } else { + M.editor_atto.disable_all_widgets(elementid); + M.editor_atto.enable_widget(elementid, 'html'); + textarea.set('value', atto.getHTML()); + atto.hide(); + textarea.show(); + } + + M.atto_html.ishtml = !M.atto_html.ishtml; + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'html', params.icon, click); + } +}; diff --git a/lib/editor/atto/plugins/html/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/html/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..e498f307486 --- /dev/null +++ b/lib/editor/atto/plugins/html/yui/src/button/meta/editor.json @@ -0,0 +1,7 @@ +{ + "moodle-atto_html-button": { + "requires": [ + "node" + ] + } +} diff --git a/lib/editor/atto/plugins/image/lang/en/atto_image.php b/lib/editor/atto/plugins/image/lang/en/atto_image.php new file mode 100644 index 00000000000..4e164c38ff2 --- /dev/null +++ b/lib/editor/atto/plugins/image/lang/en/atto_image.php @@ -0,0 +1,34 @@ +. + +/** + * Strings for component 'atto_image', language 'en'. + * + * @package atto_image + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Image'; +$string['image'] = 'Image'; +$string['createimage'] = 'Insert image'; +$string['enterurl'] = 'Enter URL'; +$string['enteralt'] = 'Enter alternative text'; +$string['browserepositories'] = 'Browse repositories...'; +$string['accessibilityhint'] = '

Web content accessibility guidelines (WCAG):

'; +$string['width'] = 'Width'; +$string['height'] = 'Height'; +$string['preview'] = 'Preview'; diff --git a/lib/editor/atto/plugins/image/lib.php b/lib/editor/atto/plugins/image/lib.php new file mode 100644 index 00000000000..ed4a2b96eb0 --- /dev/null +++ b/lib/editor/atto/plugins/image/lib.php @@ -0,0 +1,60 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_image + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_image_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('image', + get_string('image', 'atto_image'), + 'atto_image', + array('class'=>'icon')); + + $PAGE->requires->strings_for_js(array('createimage', + 'enterurl', + 'enteralt', + 'preview', + 'browserepositories', + 'accessibilityhint', + 'width', + 'height'), 'atto_image'); + $PAGE->requires->yui_module('moodle-atto_image-button', + 'M.atto_image.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_image_sort_order() { + return 13; +} diff --git a/lib/editor/atto/plugins/image/pix/image.png b/lib/editor/atto/plugins/image/pix/image.png new file mode 100644 index 0000000000000000000000000000000000000000..b5644b233976bc48c08fd84ba65f9b90a26c4673 GIT binary patch literal 506 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWP@d%8G=Xq@jo=g95iAabDa{(s>a$7Z{3Tso)VMsBz!-wD?#lcWn{ivp9c zc|~h)-u=IP&i&WD2O{pUxfr-bD@0y1+3P6s z)RN(s$Dv)){Kp26cSWt`p?+osKm~waf)dZPwmO?tlt)^XVvwEx|(jj z1oVPxiEBhjN@7W>RdP`(kYX@0Ff`URFx53O3^6jaGB&U>G0`@#ure?ZFJbpV(U6;; zl9^VCTSJ=W{trM6l^`36%hIiq5{pxHON%lY(lT>Wt@QQvGxBp&^-~gaEA#X8bMy04 za#D-+GxJJP(~A;IGV}A|a}$e8Qj4Hc`Z<|N`l%_ICHY1A$@xH4Km_C^Cgr5+7vz+t kXXXJl=O(5Dd6^XumLAYndsY@hpd%POUHx3vIVCg!00`r-?f?J) literal 0 HcmV?d00001 diff --git a/lib/editor/atto/plugins/image/pix/image.svg b/lib/editor/atto/plugins/image/pix/image.svg new file mode 100644 index 00000000000..bce2c83c5cd --- /dev/null +++ b/lib/editor/atto/plugins/image/pix/image.svg @@ -0,0 +1,77 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/lib/editor/atto/plugins/image/version.php b/lib/editor/atto/plugins/image/version.php new file mode 100644 index 00000000000..f8320ebf68d --- /dev/null +++ b/lib/editor/atto/plugins/image/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_image + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_image'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-debug.js b/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-debug.js new file mode 100644 index 00000000000..2658d79173d --- /dev/null +++ b/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-debug.js @@ -0,0 +1,184 @@ +YUI.add('moodle-atto_image-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 image plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_image = M.atto_image || { + dialogue : null, + selection : null, + init : function(params) { + var display_chooser = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + M.atto_image.selection = M.editor_atto.get_selection(); + if (M.atto_image.selection !== false) { + var dialogue; + if (!M.atto_image.dialogue) { + dialogue = new M.core.dialogue({ + visible: false, + modal: true, + close: true, + draggable: true + }); + } else { + dialogue = M.atto_image.dialogue; + } + + dialogue.set('bodyContent', M.atto_image.get_form_content(elementid)); + dialogue.set('headerContent', M.util.get_string('createimage', 'atto_image')); + dialogue.render(); + dialogue.centerDialogue(); + M.atto_image.dialogue = dialogue; + + var selectedText = M.editor_atto.get_selection_text(); + var i = 0; + + var images = []; + for (i = 0; i < selectedText.childNodes.length; i++) { + var child = selectedText.childNodes[0]; + if (images.length === 0) { + if (child.nodeName.toLowerCase() === 'img') { + images[0] = child; + } else { + if (child.getElementsByTagName) { + images = child.getElementsByTagName('img'); + } + } + } + } + + if (images.length > 0) { + var image = Y.one(images[0]); + var width = image.getAttribute('width'); + var height = image.getAttribute('height'); + if (width > 0) { + Y.one('#atto_image_widthentry').set('value', width); + } + if (height > 0) { + Y.one('#atto_image_heightentry').set('value', height); + } + Y.one('#atto_image_preview').set('src', image.get('src')); + Y.one('#atto_image_preview').setStyle('display', 'inline'); + Y.one('#atto_image_altentry').set('value', image.get('alt')); + Y.one('#atto_image_urlentry').set('value', image.get('src')); + } + dialogue.show(); + } + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'image', params.icon, display_chooser, this); + }, + open_filepicker : function(e) { + var elementid = this.getAttribute('data-editor'); + e.preventDefault(); + + M.editor_atto.show_filepicker(elementid, 'image', M.atto_image.filepicker_callback); + }, + filepicker_callback : function(params) { + if (params.url !== '') { + var input = Y.one('#atto_image_urlentry'); + input.set('value', params.url); + input = Y.one('#atto_image_altentry'); + input.set('value', params.file); + + // Auto set the width and height. + var image = new Image(); + image.onload = function() { + Y.one('#atto_image_widthentry').set('value', this.width); + Y.one('#atto_image_heightentry').set('value', this.height); + Y.one('#atto_image_preview').set('src', this.src); + Y.one('#atto_image_preview').setStyle('display', 'inline'); + }; + image.src = params.url; + } + }, + set_image : function(e) { + e.preventDefault(); + M.atto_image.dialogue.hide(); + + var input = e.currentTarget.get('parentNode').one('#atto_image_urlentry'); + + var url = input.get('value'); + input = e.currentTarget.get('parentNode').one('#atto_image_altentry'); + var alt = input.get('value'); + input = e.currentTarget.get('parentNode').one('#atto_image_widthentry'); + var width = input.get('value'); + input = e.currentTarget.get('parentNode').one('#atto_image_heightentry'); + var height = input.get('value'); + if (url !== '' && alt !== '') { + M.editor_atto.set_selection(M.atto_image.selection); + var imagehtml = '' + Y.Escape.html(alt) + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + + '' + + '' + + '' + + '' + + '
' + + '' + + '
' + + '' + + '' + + '
' + M.util.get_string('accessibilityhint', 'atto_image')); + + content.one('#atto_image_urlentrysubmit').on('click', M.atto_image.set_image); + content.one('#openimagebrowser').on('click', M.atto_image.open_filepicker); + return content; + } +}; + + +}, '@VERSION@', {"requires": ["node", "escape"]}); diff --git a/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-min.js b/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-min.js new file mode 100644 index 00000000000..6fed538488b --- /dev/null +++ b/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_image-button",function(e,t){M.atto_image=M.atto_image||{dialogue:null,selection:null,init:function(t){var n=function(t,n){t.preventDefault(),M.editor_atto.is_active(n)||M.editor_atto.focus(n),M.atto_image.selection=M.editor_atto.get_selection();if(M.atto_image.selection!==!1){var r;M.atto_image.dialogue?r=M.atto_image.dialogue:r=new M.core.dialogue({visible:!1,modal:!0,close:!0,draggable:!0}),r.set("bodyContent",M.atto_image.get_form_content(n)),r.set("headerContent",M.util.get_string("createimage","atto_image")),r.render(),r.centerDialogue(),M.atto_image.dialogue=r;var i=M.editor_atto.get_selection_text(),s=0,o=[];for(s=0;s0){var a=e.one(o[0]),f=a.getAttribute("width"),l=a.getAttribute("height");f>0&&e.one("#atto_image_widthentry").set("value",f),l>0&&e.one("#atto_image_heightentry").set("value",l),e.one("#atto_image_preview").set("src",a.get("src")),e.one("#atto_image_preview").setStyle("display","inline"),e.one("#atto_image_altentry").set("value",a.get("alt")),e.one("#atto_image_urlentry").set("value",a.get("src"))}r.show()}};M.editor_atto.add_toolbar_button(t.elementid,"image",t.icon,n,this)},open_filepicker:function(e){var t=this.getAttribute("data-editor");e.preventDefault(),M.editor_atto.show_filepicker(t,"image",M.atto_image.filepicker_callback)},filepicker_callback:function(t){if(t.url!==""){var n=e.one("#atto_image_urlentry");n.set("value",t.url),n=e.one("#atto_image_altentry"),n.set("value",t.file);var r=new Image;r.onload=function(){e.one("#atto_image_widthentry").set("value",this.width),e.one("#atto_image_heightentry").set("value",this.height),e.one("#atto_image_preview").set("src",this.src),e.one("#atto_image_preview").setStyle("display","inline")},r.src=t.url}},set_image:function(t){t.preventDefault(),M.atto_image.dialogue.hide();var n=t.currentTarget.get("parentNode").one("#atto_image_urlentry"),r=n.get("value");n=t.currentTarget.get("parentNode").one("#atto_image_altentry");var i=n.get("value");n=t.currentTarget.get("parentNode").one("#atto_image_widthentry");var s=n.get("value");n=t.currentTarget.get("parentNode").one("#atto_image_heightentry");var o=n.get("value");if(r!==""&&i!==""){M.editor_atto.set_selection(M.atto_image.selection);var u=''+e.Escape.html(i)+'"+''+'"+''+'"+''+"
"+'"+''+'"+''+"
"+'"+"
"+'"+""+"
"+M.util.get_string("accessibilityhint","atto_image"));return n.one("#atto_image_urlentrysubmit").on("click",M.atto_image.set_image),n.one("#openimagebrowser").on("click",M.atto_image.open_filepicker),n}}},"@VERSION@",{requires:["node","escape"]}); diff --git a/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button.js b/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button.js new file mode 100644 index 00000000000..2658d79173d --- /dev/null +++ b/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button.js @@ -0,0 +1,184 @@ +YUI.add('moodle-atto_image-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 image plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_image = M.atto_image || { + dialogue : null, + selection : null, + init : function(params) { + var display_chooser = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + M.atto_image.selection = M.editor_atto.get_selection(); + if (M.atto_image.selection !== false) { + var dialogue; + if (!M.atto_image.dialogue) { + dialogue = new M.core.dialogue({ + visible: false, + modal: true, + close: true, + draggable: true + }); + } else { + dialogue = M.atto_image.dialogue; + } + + dialogue.set('bodyContent', M.atto_image.get_form_content(elementid)); + dialogue.set('headerContent', M.util.get_string('createimage', 'atto_image')); + dialogue.render(); + dialogue.centerDialogue(); + M.atto_image.dialogue = dialogue; + + var selectedText = M.editor_atto.get_selection_text(); + var i = 0; + + var images = []; + for (i = 0; i < selectedText.childNodes.length; i++) { + var child = selectedText.childNodes[0]; + if (images.length === 0) { + if (child.nodeName.toLowerCase() === 'img') { + images[0] = child; + } else { + if (child.getElementsByTagName) { + images = child.getElementsByTagName('img'); + } + } + } + } + + if (images.length > 0) { + var image = Y.one(images[0]); + var width = image.getAttribute('width'); + var height = image.getAttribute('height'); + if (width > 0) { + Y.one('#atto_image_widthentry').set('value', width); + } + if (height > 0) { + Y.one('#atto_image_heightentry').set('value', height); + } + Y.one('#atto_image_preview').set('src', image.get('src')); + Y.one('#atto_image_preview').setStyle('display', 'inline'); + Y.one('#atto_image_altentry').set('value', image.get('alt')); + Y.one('#atto_image_urlentry').set('value', image.get('src')); + } + dialogue.show(); + } + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'image', params.icon, display_chooser, this); + }, + open_filepicker : function(e) { + var elementid = this.getAttribute('data-editor'); + e.preventDefault(); + + M.editor_atto.show_filepicker(elementid, 'image', M.atto_image.filepicker_callback); + }, + filepicker_callback : function(params) { + if (params.url !== '') { + var input = Y.one('#atto_image_urlentry'); + input.set('value', params.url); + input = Y.one('#atto_image_altentry'); + input.set('value', params.file); + + // Auto set the width and height. + var image = new Image(); + image.onload = function() { + Y.one('#atto_image_widthentry').set('value', this.width); + Y.one('#atto_image_heightentry').set('value', this.height); + Y.one('#atto_image_preview').set('src', this.src); + Y.one('#atto_image_preview').setStyle('display', 'inline'); + }; + image.src = params.url; + } + }, + set_image : function(e) { + e.preventDefault(); + M.atto_image.dialogue.hide(); + + var input = e.currentTarget.get('parentNode').one('#atto_image_urlentry'); + + var url = input.get('value'); + input = e.currentTarget.get('parentNode').one('#atto_image_altentry'); + var alt = input.get('value'); + input = e.currentTarget.get('parentNode').one('#atto_image_widthentry'); + var width = input.get('value'); + input = e.currentTarget.get('parentNode').one('#atto_image_heightentry'); + var height = input.get('value'); + if (url !== '' && alt !== '') { + M.editor_atto.set_selection(M.atto_image.selection); + var imagehtml = '' + Y.Escape.html(alt) + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + + '' + + '' + + '' + + '' + + '
' + + '' + + '
' + + '' + + '' + + '
' + M.util.get_string('accessibilityhint', 'atto_image')); + + content.one('#atto_image_urlentrysubmit').on('click', M.atto_image.set_image); + content.one('#openimagebrowser').on('click', M.atto_image.open_filepicker); + return content; + } +}; + + +}, '@VERSION@', {"requires": ["node", "escape"]}); diff --git a/lib/editor/atto/plugins/image/yui/src/button/build.json b/lib/editor/atto/plugins/image/yui/src/button/build.json new file mode 100644 index 00000000000..15fda37bfd5 --- /dev/null +++ b/lib/editor/atto/plugins/image/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_image-button", + "builds": { + "moodle-atto_image-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/image/yui/src/button/js/button.js b/lib/editor/atto/plugins/image/yui/src/button/js/button.js new file mode 100644 index 00000000000..ee7989b7ecd --- /dev/null +++ b/lib/editor/atto/plugins/image/yui/src/button/js/button.js @@ -0,0 +1,179 @@ +// 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 image plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_image = M.atto_image || { + dialogue : null, + selection : null, + init : function(params) { + var display_chooser = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + M.atto_image.selection = M.editor_atto.get_selection(); + if (M.atto_image.selection !== false) { + var dialogue; + if (!M.atto_image.dialogue) { + dialogue = new M.core.dialogue({ + visible: false, + modal: true, + close: true, + draggable: true + }); + } else { + dialogue = M.atto_image.dialogue; + } + + dialogue.set('bodyContent', M.atto_image.get_form_content(elementid)); + dialogue.set('headerContent', M.util.get_string('createimage', 'atto_image')); + dialogue.render(); + dialogue.centerDialogue(); + M.atto_image.dialogue = dialogue; + + var selectedText = M.editor_atto.get_selection_text(); + var i = 0; + + var images = []; + for (i = 0; i < selectedText.childNodes.length; i++) { + var child = selectedText.childNodes[0]; + if (images.length === 0) { + if (child.nodeName.toLowerCase() === 'img') { + images[0] = child; + } else { + if (child.getElementsByTagName) { + images = child.getElementsByTagName('img'); + } + } + } + } + + if (images.length > 0) { + var image = Y.one(images[0]); + var width = image.getAttribute('width'); + var height = image.getAttribute('height'); + if (width > 0) { + Y.one('#atto_image_widthentry').set('value', width); + } + if (height > 0) { + Y.one('#atto_image_heightentry').set('value', height); + } + Y.one('#atto_image_preview').set('src', image.get('src')); + Y.one('#atto_image_preview').setStyle('display', 'inline'); + Y.one('#atto_image_altentry').set('value', image.get('alt')); + Y.one('#atto_image_urlentry').set('value', image.get('src')); + } + dialogue.show(); + } + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'image', params.icon, display_chooser, this); + }, + open_filepicker : function(e) { + var elementid = this.getAttribute('data-editor'); + e.preventDefault(); + + M.editor_atto.show_filepicker(elementid, 'image', M.atto_image.filepicker_callback); + }, + filepicker_callback : function(params) { + if (params.url !== '') { + var input = Y.one('#atto_image_urlentry'); + input.set('value', params.url); + input = Y.one('#atto_image_altentry'); + input.set('value', params.file); + + // Auto set the width and height. + var image = new Image(); + image.onload = function() { + Y.one('#atto_image_widthentry').set('value', this.width); + Y.one('#atto_image_heightentry').set('value', this.height); + Y.one('#atto_image_preview').set('src', this.src); + Y.one('#atto_image_preview').setStyle('display', 'inline'); + }; + image.src = params.url; + } + }, + set_image : function(e) { + e.preventDefault(); + M.atto_image.dialogue.hide(); + + var input = e.currentTarget.get('parentNode').one('#atto_image_urlentry'); + + var url = input.get('value'); + input = e.currentTarget.get('parentNode').one('#atto_image_altentry'); + var alt = input.get('value'); + input = e.currentTarget.get('parentNode').one('#atto_image_widthentry'); + var width = input.get('value'); + input = e.currentTarget.get('parentNode').one('#atto_image_heightentry'); + var height = input.get('value'); + if (url !== '' && alt !== '') { + M.editor_atto.set_selection(M.atto_image.selection); + var imagehtml = '' + Y.Escape.html(alt) + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + + '' + + '' + + '' + + '' + + '
' + + '' + + '
' + + '' + + '' + + '
' + M.util.get_string('accessibilityhint', 'atto_image')); + + content.one('#atto_image_urlentrysubmit').on('click', M.atto_image.set_image); + content.one('#openimagebrowser').on('click', M.atto_image.open_filepicker); + return content; + } +}; diff --git a/lib/editor/atto/plugins/image/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/image/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..3a97310a174 --- /dev/null +++ b/lib/editor/atto/plugins/image/yui/src/button/meta/editor.json @@ -0,0 +1,8 @@ +{ + "moodle-atto_image-button": { + "requires": [ + "node", + "escape" + ] + } +} diff --git a/lib/editor/atto/plugins/indent/lang/en/atto_indent.php b/lib/editor/atto/plugins/indent/lang/en/atto_indent.php new file mode 100644 index 00000000000..492b4b1204e --- /dev/null +++ b/lib/editor/atto/plugins/indent/lang/en/atto_indent.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'atto_indent', language 'en'. + * + * @package atto_indent + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Indent'; +$string['indent'] = 'Indent'; diff --git a/lib/editor/atto/plugins/indent/lib.php b/lib/editor/atto/plugins/indent/lib.php new file mode 100644 index 00000000000..eb31579626d --- /dev/null +++ b/lib/editor/atto/plugins/indent/lib.php @@ -0,0 +1,52 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_indent + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_indent_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('indent', + get_string('indent', 'atto_indent'), + 'atto_indent', + array('class'=>'icon')); + + $PAGE->requires->yui_module('moodle-atto_indent-button', + 'M.atto_indent.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_indent_sort_order() { + return 5; +} diff --git a/lib/editor/atto/plugins/indent/pix/indent.png b/lib/editor/atto/plugins/indent/pix/indent.png new file mode 100644 index 0000000000000000000000000000000000000000..227ddd68032358c81eab17339211675440a0a648 GIT binary patch literal 439 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWPXJY5_^G|ngg@Mkc%;Ct}&^y=?>>U!M|ZqMIcc5c?r%Fm14E7tt@^76*U z%Hr^~y9yt_kDrtGq zw~}VXznXu4CadqSJNmMFzJ2{)sTT{5@iOpRepFfcT~r)syK0GRL`h0wNvc(HQ7VvP zFfuSS)-^EIH8c(}GPE+aurf8#Hn6ZVF!<8;xd}x>ZhlH;S|x4`t+%~F{;LMrP+XR7 zm6TYVs#{u=$&i+rlWL`}ub+{ho2s9Zm|K~jr=OdjpOTYWte=@zlA2zWSdy8a7oVG0 zT#{M@mD112OwvzH$t=k)(ofC@ssbV)FEJ@6RlgvoG(9s9q&WpBtY45>0cGj|?M->} R@eI%z44$rjF6*2UngH4kr)mHI literal 0 HcmV?d00001 diff --git a/lib/editor/atto/plugins/indent/pix/indent.svg b/lib/editor/atto/plugins/indent/pix/indent.svg new file mode 100644 index 00000000000..af8a0467a84 --- /dev/null +++ b/lib/editor/atto/plugins/indent/pix/indent.svg @@ -0,0 +1,68 @@ + + + + + + + + + + image/svg+xml + + + + + + + > + + diff --git a/lib/editor/atto/plugins/indent/version.php b/lib/editor/atto/plugins/indent/version.php new file mode 100644 index 00000000000..1ae0fda20dc --- /dev/null +++ b/lib/editor/atto/plugins/indent/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_indent + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_indent'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-debug.js b/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-debug.js new file mode 100644 index 00000000000..0a98a2b86d7 --- /dev/null +++ b/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-debug.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_indent-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 indent plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_indent = M.atto_indent || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('indent', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'indent', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-min.js b/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-min.js new file mode 100644 index 00000000000..3079b97f5da --- /dev/null +++ b/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_indent-button",function(e,t){M.atto_indent=M.atto_indent||{init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("indent",!1,null)};M.editor_atto.add_toolbar_button(e.elementid,"indent",e.icon,t)}}},"@VERSION@",{requires:["node"]}); diff --git a/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button.js b/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button.js new file mode 100644 index 00000000000..0a98a2b86d7 --- /dev/null +++ b/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_indent-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 indent plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_indent = M.atto_indent || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('indent', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'indent', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/indent/yui/src/button/build.json b/lib/editor/atto/plugins/indent/yui/src/button/build.json new file mode 100644 index 00000000000..29b8001d1d0 --- /dev/null +++ b/lib/editor/atto/plugins/indent/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_indent-button", + "builds": { + "moodle-atto_indent-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/indent/yui/src/button/js/button.js b/lib/editor/atto/plugins/indent/yui/src/button/js/button.js new file mode 100644 index 00000000000..05593e3d12e --- /dev/null +++ b/lib/editor/atto/plugins/indent/yui/src/button/js/button.js @@ -0,0 +1,35 @@ +// 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 indent plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_indent = M.atto_indent || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('indent', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'indent', params.icon, click); + } +}; diff --git a/lib/editor/atto/plugins/indent/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/indent/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..812a3bc7858 --- /dev/null +++ b/lib/editor/atto/plugins/indent/yui/src/button/meta/editor.json @@ -0,0 +1,5 @@ +{ + "moodle-atto_indent-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/plugins/italic/lang/en/atto_italic.php b/lib/editor/atto/plugins/italic/lang/en/atto_italic.php new file mode 100644 index 00000000000..177ebaa5c0d --- /dev/null +++ b/lib/editor/atto/plugins/italic/lang/en/atto_italic.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'atto_italic', language 'en'. + * + * @package atto_italic + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Italic'; +$string['italic'] = 'Italic'; diff --git a/lib/editor/atto/plugins/italic/lib.php b/lib/editor/atto/plugins/italic/lib.php new file mode 100644 index 00000000000..fb12b861192 --- /dev/null +++ b/lib/editor/atto/plugins/italic/lib.php @@ -0,0 +1,52 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_italic + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_italic_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('italic', + get_string('italic', 'atto_italic'), + 'atto_italic', + array('class'=>'icon')); + + $PAGE->requires->yui_module('moodle-atto_italic-button', + 'M.atto_italic.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_italic_sort_order() { + return 1; +} diff --git a/lib/editor/atto/plugins/italic/pix/italic.png b/lib/editor/atto/plugins/italic/pix/italic.png new file mode 100644 index 0000000000000000000000000000000000000000..0efebc23b3bc356ede32397b0ea937725dfd9bc1 GIT binary patch literal 418 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWO^JzX3_G|ngg@MkcXu;#&shkL6(XzeI{{W92VO~wDZXJ_8u|ERH}w)&*d z9<@0Z84;`^SMFo}NB4bH3ffzz-iD{`pz4xANPYWxXti8WS8Q zE@WWHKJ;Z>w475l&?40m*NBpo#FA929tzUHx3vIVCg!0Pbv*ivR!s literal 0 HcmV?d00001 diff --git a/lib/editor/atto/plugins/italic/pix/italic.svg b/lib/editor/atto/plugins/italic/pix/italic.svg new file mode 100644 index 00000000000..848e67ee7c5 --- /dev/null +++ b/lib/editor/atto/plugins/italic/pix/italic.svg @@ -0,0 +1,68 @@ + + + + + + + + + + image/svg+xml + + + + + + + i + + diff --git a/lib/editor/atto/plugins/italic/version.php b/lib/editor/atto/plugins/italic/version.php new file mode 100644 index 00000000000..e5c8fe9017f --- /dev/null +++ b/lib/editor/atto/plugins/italic/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_italic + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_italic'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-debug.js b/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-debug.js new file mode 100644 index 00000000000..78285fc89a1 --- /dev/null +++ b/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-debug.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_italic-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 italic plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_italic = M.atto_italic || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('italic', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'italic', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-min.js b/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-min.js new file mode 100644 index 00000000000..568d6df8814 --- /dev/null +++ b/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_italic-button",function(e,t){M.atto_italic=M.atto_italic||{init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("italic",!1,null)};M.editor_atto.add_toolbar_button(e.elementid,"italic",e.icon,t)}}},"@VERSION@",{requires:["node"]}); diff --git a/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button.js b/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button.js new file mode 100644 index 00000000000..78285fc89a1 --- /dev/null +++ b/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_italic-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 italic plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_italic = M.atto_italic || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('italic', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'italic', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/italic/yui/src/button/build.json b/lib/editor/atto/plugins/italic/yui/src/button/build.json new file mode 100644 index 00000000000..d7df4fc2ee0 --- /dev/null +++ b/lib/editor/atto/plugins/italic/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_italic-button", + "builds": { + "moodle-atto_italic-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/italic/yui/src/button/js/button.js b/lib/editor/atto/plugins/italic/yui/src/button/js/button.js new file mode 100644 index 00000000000..c22dcce318e --- /dev/null +++ b/lib/editor/atto/plugins/italic/yui/src/button/js/button.js @@ -0,0 +1,35 @@ +// 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 italic plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_italic = M.atto_italic || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('italic', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'italic', params.icon, click); + } +}; diff --git a/lib/editor/atto/plugins/italic/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/italic/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..4109b10ce61 --- /dev/null +++ b/lib/editor/atto/plugins/italic/yui/src/button/meta/editor.json @@ -0,0 +1,5 @@ +{ + "moodle-atto_italic-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/plugins/link/lang/en/atto_link.php b/lib/editor/atto/plugins/link/lang/en/atto_link.php new file mode 100644 index 00000000000..97357885b97 --- /dev/null +++ b/lib/editor/atto/plugins/link/lang/en/atto_link.php @@ -0,0 +1,30 @@ +. + +/** + * Strings for component 'atto_link', language 'en'. + * + * @package atto_link + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Link'; +$string['link'] = 'Link'; +$string['createlink'] = 'Create link'; +$string['enterurl'] = 'Enter a URL'; +$string['browserepositories'] = 'Browse repositories...'; +$string['accessibilityhint'] = '

Web content accessibility guidelines (WCAG):

'; diff --git a/lib/editor/atto/plugins/link/lib.php b/lib/editor/atto/plugins/link/lib.php new file mode 100644 index 00000000000..56067e7d230 --- /dev/null +++ b/lib/editor/atto/plugins/link/lib.php @@ -0,0 +1,58 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_link + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_link_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('link', + get_string('link', 'atto_link'), + 'atto_link', + array('class'=>'icon')); + + $PAGE->requires->strings_for_js(array('createlink', + 'enterurl', + 'browserepositories', + 'accessibilityhint'), + 'atto_link'); + + $PAGE->requires->yui_module('moodle-atto_link-button', + 'M.atto_link.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_link_sort_order() { + return 11; +} diff --git a/lib/editor/atto/plugins/link/pix/link.png b/lib/editor/atto/plugins/link/pix/link.png new file mode 100644 index 0000000000000000000000000000000000000000..5a0ac7f4a681845dd5d67cbc54bb0f2517010a8b GIT binary patch literal 471 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWPzdAc};Xq->};m=?Yur7g7MklW3tCq)$S67dA3oha@o_L^%^?yUcL8cT# z5mw{$f2>R)f*Yjo?YA#Tco!p3e*N6t-Hu=G?EL+GZxw6#lV!ce8yiGVKjhk$cXV08 z*Q^aq@(v%Ko&A{n`FSIYzl?pMjLZ4i)o*Tmey(77sL$o&vziU&&lhV%?Bn5^ewZoi zXHkoW=%c0yObjLm=5-6+di)6JLe&!2h?11Vl2ohYqEsNoU}RuutZQJZYiJo_Xli9@ zW@T!uZD3(#V36L-aSug9ZhlH;S|x4`V)r&A0X39^Y$z^Ew@OMZPSq_f%4A5(%t^J< z*VoU;&rQ`&NzARx&(qJ%&riuoE!NM>D@jc+N-W9D&x_AZEG|hcf=cPY0X literal 0 HcmV?d00001 diff --git a/lib/editor/atto/plugins/link/pix/link.svg b/lib/editor/atto/plugins/link/pix/link.svg new file mode 100644 index 00000000000..54b80dbb575 --- /dev/null +++ b/lib/editor/atto/plugins/link/pix/link.svg @@ -0,0 +1,80 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/lib/editor/atto/plugins/link/version.php b/lib/editor/atto/plugins/link/version.php new file mode 100644 index 00000000000..e2739eb6ee8 --- /dev/null +++ b/lib/editor/atto/plugins/link/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_link + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_link'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-debug.js b/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-debug.js new file mode 100644 index 00000000000..c352f07b7fe --- /dev/null +++ b/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-debug.js @@ -0,0 +1,132 @@ +YUI.add('moodle-atto_link-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 link plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_link = M.atto_link || { + dialogue : null, + selection : null, + init : function(params) { + var display_chooser = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + M.atto_link.selection = M.editor_atto.get_selection(); + if (M.atto_link.selection !== false && (!M.atto_link.selection.collapsed)) { + var dialogue; + if (!M.atto_link.dialogue) { + dialogue = new M.core.dialogue({ + visible: false, + modal: true, + close: true, + draggable: true + }); + } else { + dialogue = M.atto_link.dialogue; + } + + dialogue.render(); + dialogue.set('bodyContent', M.atto_link.get_form_content(elementid)); + dialogue.set('headerContent', M.util.get_string('createlink', 'atto_link')); + + M.atto_link.resolve_anchors(); + + dialogue.show(); + M.atto_link.dialogue = dialogue; + } + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'link', params.icon, display_chooser, this); + }, + resolve_anchors : function() { + // Find the first anchor tag in the selection. + var selectednode = M.editor_atto.get_selection_parent_node(), + anchornode, + url; + + // Note this is a document fragment and YUI doesn't like them. + if (!selectednode) { + return; + } + + anchornode = Y.one(selectednode).ancestor('a'); + + if (anchornode) { + url = anchornode.getAttribute('href'); + if (url !== '') { + M.atto_link.selection = M.editor_atto.get_selection_from_node(anchornode); + Y.one('#atto_link_urlentry').set('value', url); + } + } + }, + open_filepicker : function(e) { + var elementid = this.getAttribute('data-editor'); + e.preventDefault(); + + M.editor_atto.show_filepicker(elementid, 'link', M.atto_link.filepicker_callback); + }, + filepicker_callback : function(params) { + M.atto_link.dialogue.hide(); + if (params.url !== '') { + M.editor_atto.set_selection(M.atto_link.selection); + document.execCommand('unlink', false, null); + document.execCommand('createLink', false, params.url); + } + }, + set_link : function(e) { + e.preventDefault(); + M.atto_link.dialogue.hide(); + + var input = e.currentTarget.get('parentNode').one('input'); + + var value = input.get('value'); + if (value !== '') { + M.editor_atto.set_selection(M.atto_link.selection); + document.execCommand('unlink', false, null); + document.execCommand('createLink', false, value); + } + }, + get_form_content : function(elementid) { + var content = Y.Node.create('
' + + '
' + + '' + + '
' + + '' + + '
' + + '' + + '
' + + '
' + M.util.get_string('accessibilityhint', 'atto_link')); + + content.one('#atto_link_urlentrysubmit').on('click', M.atto_link.set_link); + content.one('#openlinkbrowser').on('click', M.atto_link.open_filepicker); + return content; + } +}; + + +}, '@VERSION@', {"requires": ["node", "escape"]}); diff --git a/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-min.js b/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-min.js new file mode 100644 index 00000000000..64546785d78 --- /dev/null +++ b/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_link-button",function(e,t){M.atto_link=M.atto_link||{dialogue:null,selection:null,init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),M.atto_link.selection=M.editor_atto.get_selection();if(M.atto_link.selection!==!1&&!M.atto_link.selection.collapsed){var n;M.atto_link.dialogue?n=M.atto_link.dialogue:n=new M.core.dialogue({visible:!1,modal:!0,close:!0,draggable:!0}),n.render(),n.set("bodyContent",M.atto_link.get_form_content(t)),n.set("headerContent",M.util.get_string("createlink","atto_link")),M.atto_link.resolve_anchors(),n.show(),M.atto_link.dialogue=n}};M.editor_atto.add_toolbar_button(e.elementid,"link",e.icon,t,this)},resolve_anchors:function(){var t=M.editor_atto.get_selection_parent_node(),n,r;if(!t)return;n=e.one(t).ancestor("a"),n&&(r=n.getAttribute("href"),r!==""&&(M.atto_link.selection=M.editor_atto.get_selection_from_node(n),e.one("#atto_link_urlentry").set("value",r)))},open_filepicker:function(e){var t=this.getAttribute("data-editor");e.preventDefault(),M.editor_atto.show_filepicker(t,"link",M.atto_link.filepicker_callback)},filepicker_callback:function(e){M.atto_link.dialogue.hide(),e.url!==""&&(M.editor_atto.set_selection(M.atto_link.selection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,e.url))},set_link:function(e){e.preventDefault(),M.atto_link.dialogue.hide();var t=e.currentTarget.get("parentNode").one("input"),n=t.get("value");n!==""&&(M.editor_atto.set_selection(M.atto_link.selection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,n))},get_form_content:function(t){var n=e.Node.create('

"+''+"
"+'"+"
"+'"+"
"+"
"+M.util.get_string("accessibilityhint","atto_link"));return n.one("#atto_link_urlentrysubmit").on("click",M.atto_link.set_link),n.one("#openlinkbrowser").on("click",M.atto_link.open_filepicker),n}}},"@VERSION@",{requires:["node","escape"]}); diff --git a/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button.js b/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button.js new file mode 100644 index 00000000000..c352f07b7fe --- /dev/null +++ b/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button.js @@ -0,0 +1,132 @@ +YUI.add('moodle-atto_link-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 link plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_link = M.atto_link || { + dialogue : null, + selection : null, + init : function(params) { + var display_chooser = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + M.atto_link.selection = M.editor_atto.get_selection(); + if (M.atto_link.selection !== false && (!M.atto_link.selection.collapsed)) { + var dialogue; + if (!M.atto_link.dialogue) { + dialogue = new M.core.dialogue({ + visible: false, + modal: true, + close: true, + draggable: true + }); + } else { + dialogue = M.atto_link.dialogue; + } + + dialogue.render(); + dialogue.set('bodyContent', M.atto_link.get_form_content(elementid)); + dialogue.set('headerContent', M.util.get_string('createlink', 'atto_link')); + + M.atto_link.resolve_anchors(); + + dialogue.show(); + M.atto_link.dialogue = dialogue; + } + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'link', params.icon, display_chooser, this); + }, + resolve_anchors : function() { + // Find the first anchor tag in the selection. + var selectednode = M.editor_atto.get_selection_parent_node(), + anchornode, + url; + + // Note this is a document fragment and YUI doesn't like them. + if (!selectednode) { + return; + } + + anchornode = Y.one(selectednode).ancestor('a'); + + if (anchornode) { + url = anchornode.getAttribute('href'); + if (url !== '') { + M.atto_link.selection = M.editor_atto.get_selection_from_node(anchornode); + Y.one('#atto_link_urlentry').set('value', url); + } + } + }, + open_filepicker : function(e) { + var elementid = this.getAttribute('data-editor'); + e.preventDefault(); + + M.editor_atto.show_filepicker(elementid, 'link', M.atto_link.filepicker_callback); + }, + filepicker_callback : function(params) { + M.atto_link.dialogue.hide(); + if (params.url !== '') { + M.editor_atto.set_selection(M.atto_link.selection); + document.execCommand('unlink', false, null); + document.execCommand('createLink', false, params.url); + } + }, + set_link : function(e) { + e.preventDefault(); + M.atto_link.dialogue.hide(); + + var input = e.currentTarget.get('parentNode').one('input'); + + var value = input.get('value'); + if (value !== '') { + M.editor_atto.set_selection(M.atto_link.selection); + document.execCommand('unlink', false, null); + document.execCommand('createLink', false, value); + } + }, + get_form_content : function(elementid) { + var content = Y.Node.create('
' + + '
' + + '' + + '
' + + '' + + '
' + + '' + + '
' + + '
' + M.util.get_string('accessibilityhint', 'atto_link')); + + content.one('#atto_link_urlentrysubmit').on('click', M.atto_link.set_link); + content.one('#openlinkbrowser').on('click', M.atto_link.open_filepicker); + return content; + } +}; + + +}, '@VERSION@', {"requires": ["node", "escape"]}); diff --git a/lib/editor/atto/plugins/link/yui/src/button/build.json b/lib/editor/atto/plugins/link/yui/src/button/build.json new file mode 100644 index 00000000000..0f84aad113e --- /dev/null +++ b/lib/editor/atto/plugins/link/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_link-button", + "builds": { + "moodle-atto_link-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/link/yui/src/button/js/button.js b/lib/editor/atto/plugins/link/yui/src/button/js/button.js new file mode 100644 index 00000000000..b719e9a92b5 --- /dev/null +++ b/lib/editor/atto/plugins/link/yui/src/button/js/button.js @@ -0,0 +1,127 @@ +// 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 link plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_link = M.atto_link || { + dialogue : null, + selection : null, + init : function(params) { + var display_chooser = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + M.atto_link.selection = M.editor_atto.get_selection(); + if (M.atto_link.selection !== false && (!M.atto_link.selection.collapsed)) { + var dialogue; + if (!M.atto_link.dialogue) { + dialogue = new M.core.dialogue({ + visible: false, + modal: true, + close: true, + draggable: true + }); + } else { + dialogue = M.atto_link.dialogue; + } + + dialogue.render(); + dialogue.set('bodyContent', M.atto_link.get_form_content(elementid)); + dialogue.set('headerContent', M.util.get_string('createlink', 'atto_link')); + + M.atto_link.resolve_anchors(); + + dialogue.show(); + M.atto_link.dialogue = dialogue; + } + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'link', params.icon, display_chooser, this); + }, + resolve_anchors : function() { + // Find the first anchor tag in the selection. + var selectednode = M.editor_atto.get_selection_parent_node(), + anchornode, + url; + + // Note this is a document fragment and YUI doesn't like them. + if (!selectednode) { + return; + } + + anchornode = Y.one(selectednode).ancestor('a'); + + if (anchornode) { + url = anchornode.getAttribute('href'); + if (url !== '') { + M.atto_link.selection = M.editor_atto.get_selection_from_node(anchornode); + Y.one('#atto_link_urlentry').set('value', url); + } + } + }, + open_filepicker : function(e) { + var elementid = this.getAttribute('data-editor'); + e.preventDefault(); + + M.editor_atto.show_filepicker(elementid, 'link', M.atto_link.filepicker_callback); + }, + filepicker_callback : function(params) { + M.atto_link.dialogue.hide(); + if (params.url !== '') { + M.editor_atto.set_selection(M.atto_link.selection); + document.execCommand('unlink', false, null); + document.execCommand('createLink', false, params.url); + } + }, + set_link : function(e) { + e.preventDefault(); + M.atto_link.dialogue.hide(); + + var input = e.currentTarget.get('parentNode').one('input'); + + var value = input.get('value'); + if (value !== '') { + M.editor_atto.set_selection(M.atto_link.selection); + document.execCommand('unlink', false, null); + document.execCommand('createLink', false, value); + } + }, + get_form_content : function(elementid) { + var content = Y.Node.create('
' + + '
' + + '' + + '
' + + '' + + '
' + + '' + + '
' + + '
' + M.util.get_string('accessibilityhint', 'atto_link')); + + content.one('#atto_link_urlentrysubmit').on('click', M.atto_link.set_link); + content.one('#openlinkbrowser').on('click', M.atto_link.open_filepicker); + return content; + } +}; diff --git a/lib/editor/atto/plugins/link/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/link/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..41593ed2074 --- /dev/null +++ b/lib/editor/atto/plugins/link/yui/src/button/meta/editor.json @@ -0,0 +1,8 @@ +{ + "moodle-atto_link-button": { + "requires": [ + "node", + "escape" + ] + } +} diff --git a/lib/editor/atto/plugins/media/lang/en/atto_media.php b/lib/editor/atto/plugins/media/lang/en/atto_media.php new file mode 100644 index 00000000000..913f579dadb --- /dev/null +++ b/lib/editor/atto/plugins/media/lang/en/atto_media.php @@ -0,0 +1,33 @@ +. + +/** + * Strings for component 'atto_media', language 'en'. + * + * @package atto_media + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Media'; +$string['media'] = 'Media'; +$string['createmedia'] = 'Insert media'; +$string['enterurl'] = 'Enter URL'; +$string['entername'] = 'Enter name'; +$string['browserepositories'] = 'Browse repositories...'; +$string['accessibilityhint'] = '

Web content accessibility guidelines (WCAG):

'; +$string['width'] = 'Width'; +$string['height'] = 'Height'; diff --git a/lib/editor/atto/plugins/media/lib.php b/lib/editor/atto/plugins/media/lib.php new file mode 100644 index 00000000000..d0a4428191c --- /dev/null +++ b/lib/editor/atto/plugins/media/lib.php @@ -0,0 +1,56 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_media + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_media_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('media', + get_string('media', 'atto_media'), + 'atto_media', + array('class'=>'icon')); + + $PAGE->requires->strings_for_js(array('createmedia', + 'enterurl', + 'entername', + 'browserepositories', + 'accessibilityhint'), + 'atto_media'); + $PAGE->requires->yui_module('moodle-atto_media-button', + 'M.atto_media.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_media_sort_order() { + return 14; +} diff --git a/lib/editor/atto/plugins/media/pix/media.png b/lib/editor/atto/plugins/media/pix/media.png new file mode 100644 index 0000000000000000000000000000000000000000..36b2828d1e878314dbb1c7406a0fc6e4412c9a20 GIT binary patch literal 489 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWPjdAc};Xq=yVVK-N^fk?x{J^!VT=qX)Y6m6|~iBD6K<>J8#Nf(y_z9X)J zrdQXloWAY9NT!SABwHuZPvSueYE)qPNQmtkIefW$J*rFv;=UfVTvFASQtbuE)Y(7{dI zg$#doCRQ-Jehhi^=YGExLm?0UB9RmNdl}4ruiVP7e3KpMV$~AYh?11Vl2ohYqEsNo zU}RuutZQJZYh)Z^WN2k-Y-MDqZD3(#V8G5;>W`u!H$NpatrE9}vY4}Hb>+5Ia=cekXB<5D;=jrF>=cnYP7VBr`m87N@C6;97=f&qH z7MG+JL8bI_GL!UEQ!-2Pi}aK8fvSKA$V*JhN!2gNDNWDJE7s2iiX`e6WL7{}dO%xy Tu2-1?9l_w~>gTe~DWM4fwJEBl literal 0 HcmV?d00001 diff --git a/lib/editor/atto/plugins/media/pix/media.svg b/lib/editor/atto/plugins/media/pix/media.svg new file mode 100644 index 00000000000..13a714794cb --- /dev/null +++ b/lib/editor/atto/plugins/media/pix/media.svg @@ -0,0 +1,105 @@ + + + + + + + + + + media/svg+xml + + + + + + + + + + + + + + + diff --git a/lib/editor/atto/plugins/media/version.php b/lib/editor/atto/plugins/media/version.php new file mode 100644 index 00000000000..104b5d5cb8e --- /dev/null +++ b/lib/editor/atto/plugins/media/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_media + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_media'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button-debug.js b/lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button-debug.js new file mode 100644 index 00000000000..587b48280b1 --- /dev/null +++ b/lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button-debug.js @@ -0,0 +1,119 @@ +YUI.add('moodle-atto_media-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 media plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_media = M.atto_media || { + dialogue : null, + selection : null, + init : function(params) { + var display_chooser = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + M.atto_media.selection = M.editor_atto.get_selection(); + if (M.atto_media.selection !== false) { + var dialogue; + if (!M.atto_media.dialogue) { + dialogue = new M.core.dialogue({ + visible: false, + modal: true, + close: true, + draggable: true + }); + } else { + dialogue = M.atto_media.dialogue; + } + + dialogue.render(); + dialogue.set('bodyContent', M.atto_media.get_form_content(elementid)); + dialogue.set('headerContent', M.util.get_string('createmedia', 'atto_media')); + dialogue.centerDialogue(); + dialogue.show(); + M.atto_media.dialogue = dialogue; + } + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'media', params.icon, display_chooser, this); + }, + open_browser : function(e) { + var elementid = this.getAttribute('data-editor'); + e.preventDefault(); + + M.editor_atto.show_filepicker(elementid, 'media', M.atto_media.filepicker_callback); + }, + filepicker_callback : function(params) { + if (params.url !== '') { + var input = Y.one('#atto_media_urlentry'); + input.set('value', params.url); + input = Y.one('#atto_media_nameentry'); + input.set('value', params.file); + } + }, + set_media : function(e) { + e.preventDefault(); + M.atto_media.dialogue.hide(); + + var input = e.currentTarget.get('parentNode').one('#atto_media_urlentry'); + var url = input.get('value'); + input = e.currentTarget.get('parentNode').one('#atto_media_nameentry'); + var name = input.get('value'); + + if (url !== '' && name !== '') { + M.editor_atto.set_selection(M.atto_media.selection); + var mediahtml = '' + name + ''; + + if (document.selection && document.selection.createRange().pasteHTML) { + document.selection.createRange().pasteHTML(mediahtml); + } else { + document.execCommand('insertHTML', false, mediahtml); + } + } + }, + get_form_content : function(elementid) { + var content = Y.Node.create('
' + + '' + + '' + + '' + + '' + + '
' + + '' + + '
' + + '' + + '
' + + '
' + M.util.get_string('accessibilityhint', 'atto_media')); + + content.one('#atto_media_urlentrysubmit').on('click', M.atto_media.set_media); + content.one('#openmediabrowser').on('click', M.atto_media.open_browser); + return content; + } +}; + + +}, '@VERSION@', {"requires": ["node", "escape"]}); diff --git a/lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button-min.js b/lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button-min.js new file mode 100644 index 00000000000..207fa8fa358 --- /dev/null +++ b/lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_media-button",function(e,t){M.atto_media=M.atto_media||{dialogue:null,selection:null,init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),M.atto_media.selection=M.editor_atto.get_selection();if(M.atto_media.selection!==!1){var n;M.atto_media.dialogue?n=M.atto_media.dialogue:n=new M.core.dialogue({visible:!1,modal:!0,close:!0,draggable:!0}),n.render(),n.set("bodyContent",M.atto_media.get_form_content(t)),n.set("headerContent",M.util.get_string("createmedia","atto_media")),n.centerDialogue(),n.show(),M.atto_media.dialogue=n}};M.editor_atto.add_toolbar_button(e.elementid,"media",e.icon,t,this)},open_browser:function(e){var t=this.getAttribute("data-editor");e.preventDefault(),M.editor_atto.show_filepicker(t,"media",M.atto_media.filepicker_callback)},filepicker_callback:function(t){if(t.url!==""){var n=e.one("#atto_media_urlentry");n.set("value",t.url),n=e.one("#atto_media_nameentry"),n.set("value",t.file)}},set_media:function(t){t.preventDefault(),M.atto_media.dialogue.hide();var n=t.currentTarget.get("parentNode").one("#atto_media_urlentry"),r=n.get("value");n=t.currentTarget.get("parentNode").one("#atto_media_nameentry");var i=n.get("value");if(r!==""&&i!==""){M.editor_atto.set_selection(M.atto_media.selection);var s=''+i+"";document.selection&&document.selection.createRange().pasteHTML?document.selection.createRange().pasteHTML(s):document.execCommand("insertHTML",!1,s)}},get_form_content:function(t){var n=e.Node.create('
"+''+'"+''+"
"+'"+"
"+'"+"
"+"
"+M.util.get_string("accessibilityhint","atto_media"));return n.one("#atto_media_urlentrysubmit").on("click",M.atto_media.set_media),n.one("#openmediabrowser").on("click",M.atto_media.open_browser),n}}},"@VERSION@",{requires:["node","escape"]}); diff --git a/lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button.js b/lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button.js new file mode 100644 index 00000000000..587b48280b1 --- /dev/null +++ b/lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button.js @@ -0,0 +1,119 @@ +YUI.add('moodle-atto_media-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 media plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_media = M.atto_media || { + dialogue : null, + selection : null, + init : function(params) { + var display_chooser = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + M.atto_media.selection = M.editor_atto.get_selection(); + if (M.atto_media.selection !== false) { + var dialogue; + if (!M.atto_media.dialogue) { + dialogue = new M.core.dialogue({ + visible: false, + modal: true, + close: true, + draggable: true + }); + } else { + dialogue = M.atto_media.dialogue; + } + + dialogue.render(); + dialogue.set('bodyContent', M.atto_media.get_form_content(elementid)); + dialogue.set('headerContent', M.util.get_string('createmedia', 'atto_media')); + dialogue.centerDialogue(); + dialogue.show(); + M.atto_media.dialogue = dialogue; + } + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'media', params.icon, display_chooser, this); + }, + open_browser : function(e) { + var elementid = this.getAttribute('data-editor'); + e.preventDefault(); + + M.editor_atto.show_filepicker(elementid, 'media', M.atto_media.filepicker_callback); + }, + filepicker_callback : function(params) { + if (params.url !== '') { + var input = Y.one('#atto_media_urlentry'); + input.set('value', params.url); + input = Y.one('#atto_media_nameentry'); + input.set('value', params.file); + } + }, + set_media : function(e) { + e.preventDefault(); + M.atto_media.dialogue.hide(); + + var input = e.currentTarget.get('parentNode').one('#atto_media_urlentry'); + var url = input.get('value'); + input = e.currentTarget.get('parentNode').one('#atto_media_nameentry'); + var name = input.get('value'); + + if (url !== '' && name !== '') { + M.editor_atto.set_selection(M.atto_media.selection); + var mediahtml = '' + name + ''; + + if (document.selection && document.selection.createRange().pasteHTML) { + document.selection.createRange().pasteHTML(mediahtml); + } else { + document.execCommand('insertHTML', false, mediahtml); + } + } + }, + get_form_content : function(elementid) { + var content = Y.Node.create('
' + + '' + + '' + + '' + + '' + + '
' + + '' + + '
' + + '' + + '
' + + '
' + M.util.get_string('accessibilityhint', 'atto_media')); + + content.one('#atto_media_urlentrysubmit').on('click', M.atto_media.set_media); + content.one('#openmediabrowser').on('click', M.atto_media.open_browser); + return content; + } +}; + + +}, '@VERSION@', {"requires": ["node", "escape"]}); diff --git a/lib/editor/atto/plugins/media/yui/src/button/build.json b/lib/editor/atto/plugins/media/yui/src/button/build.json new file mode 100644 index 00000000000..b20a6f5c438 --- /dev/null +++ b/lib/editor/atto/plugins/media/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_media-button", + "builds": { + "moodle-atto_media-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/media/yui/src/button/js/button.js b/lib/editor/atto/plugins/media/yui/src/button/js/button.js new file mode 100644 index 00000000000..ccbbbb5c292 --- /dev/null +++ b/lib/editor/atto/plugins/media/yui/src/button/js/button.js @@ -0,0 +1,114 @@ +// 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 media plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_media = M.atto_media || { + dialogue : null, + selection : null, + init : function(params) { + var display_chooser = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + M.atto_media.selection = M.editor_atto.get_selection(); + if (M.atto_media.selection !== false) { + var dialogue; + if (!M.atto_media.dialogue) { + dialogue = new M.core.dialogue({ + visible: false, + modal: true, + close: true, + draggable: true + }); + } else { + dialogue = M.atto_media.dialogue; + } + + dialogue.render(); + dialogue.set('bodyContent', M.atto_media.get_form_content(elementid)); + dialogue.set('headerContent', M.util.get_string('createmedia', 'atto_media')); + dialogue.centerDialogue(); + dialogue.show(); + M.atto_media.dialogue = dialogue; + } + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'media', params.icon, display_chooser, this); + }, + open_browser : function(e) { + var elementid = this.getAttribute('data-editor'); + e.preventDefault(); + + M.editor_atto.show_filepicker(elementid, 'media', M.atto_media.filepicker_callback); + }, + filepicker_callback : function(params) { + if (params.url !== '') { + var input = Y.one('#atto_media_urlentry'); + input.set('value', params.url); + input = Y.one('#atto_media_nameentry'); + input.set('value', params.file); + } + }, + set_media : function(e) { + e.preventDefault(); + M.atto_media.dialogue.hide(); + + var input = e.currentTarget.get('parentNode').one('#atto_media_urlentry'); + var url = input.get('value'); + input = e.currentTarget.get('parentNode').one('#atto_media_nameentry'); + var name = input.get('value'); + + if (url !== '' && name !== '') { + M.editor_atto.set_selection(M.atto_media.selection); + var mediahtml = '' + name + ''; + + if (document.selection && document.selection.createRange().pasteHTML) { + document.selection.createRange().pasteHTML(mediahtml); + } else { + document.execCommand('insertHTML', false, mediahtml); + } + } + }, + get_form_content : function(elementid) { + var content = Y.Node.create('
' + + '' + + '' + + '' + + '' + + '
' + + '' + + '
' + + '' + + '
' + + '
' + M.util.get_string('accessibilityhint', 'atto_media')); + + content.one('#atto_media_urlentrysubmit').on('click', M.atto_media.set_media); + content.one('#openmediabrowser').on('click', M.atto_media.open_browser); + return content; + } +}; diff --git a/lib/editor/atto/plugins/media/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/media/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..3632bf78635 --- /dev/null +++ b/lib/editor/atto/plugins/media/yui/src/button/meta/editor.json @@ -0,0 +1,8 @@ +{ + "moodle-atto_media-button": { + "requires": [ + "node", + "escape" + ] + } +} diff --git a/lib/editor/atto/plugins/orderedlist/lang/en/atto_orderedlist.php b/lib/editor/atto/plugins/orderedlist/lang/en/atto_orderedlist.php new file mode 100644 index 00000000000..8070eb593e0 --- /dev/null +++ b/lib/editor/atto/plugins/orderedlist/lang/en/atto_orderedlist.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'atto_orderedlist', language 'en'. + * + * @package atto_orderedlist + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Ordered list'; +$string['orderedlist'] = 'Ordered list'; diff --git a/lib/editor/atto/plugins/orderedlist/lib.php b/lib/editor/atto/plugins/orderedlist/lib.php new file mode 100644 index 00000000000..524202c1f2c --- /dev/null +++ b/lib/editor/atto/plugins/orderedlist/lib.php @@ -0,0 +1,52 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_orderedlist + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_orderedlist_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('orderedlist', + get_string('orderedlist', 'atto_orderedlist'), + 'atto_orderedlist', + array('class'=>'icon')); + + $PAGE->requires->yui_module('moodle-atto_orderedlist-button', + 'M.atto_orderedlist.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_orderedlist_sort_order() { + return 6; +} diff --git a/lib/editor/atto/plugins/orderedlist/pix/orderedlist.png b/lib/editor/atto/plugins/orderedlist/pix/orderedlist.png new file mode 100644 index 0000000000000000000000000000000000000000..33fbb6308053088f0166b061104475053b08f284 GIT binary patch literal 465 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWPnJY5_^G|n%bV94)aAkg~v|NTI=E30O|&{=uGWyUVkjhzx17EKppTk>~4 zJ$-uj^Mk&DC9*aTV%5(x&llKscE&0tVTL%aptglm>V-HMAB#MTs@XwUl|-$E>pDnV*C8u!ltc-CVemX4o^_I>{2r^wdW)ATKhK}m<`2V|1wkZ(E_?g zwZt`|BqgyV)hf9t6-Y4{85kPt8kp)D8iyDeS(zAF8JlSvSXdbtoD(?l8bw2HeoAIq zC2kG-eG9^Y8d^a%6qlu2B_$T8>XsH|GNfhZq+03g>u2QWrs}68=2qtC>F4I>r{ts- z>u2Vbq^1`omSpDV#pfm#m!uX!rSx+$lk`(lGE4G{^po>}s(=W{OH9g1)i1~?P0!3L q*3U0WNi9lE$;m7((J#oXK<4WKU9dWF)ia=j7(8A5T-G@yGywouAfwa( literal 0 HcmV?d00001 diff --git a/lib/editor/atto/plugins/orderedlist/pix/orderedlist.svg b/lib/editor/atto/plugins/orderedlist/pix/orderedlist.svg new file mode 100644 index 00000000000..1172fd5866c --- /dev/null +++ b/lib/editor/atto/plugins/orderedlist/pix/orderedlist.svg @@ -0,0 +1,80 @@ + + + + + + + + + + image/svg+xml + + + + + + + 1- + 2- + + diff --git a/lib/editor/atto/plugins/orderedlist/version.php b/lib/editor/atto/plugins/orderedlist/version.php new file mode 100644 index 00000000000..e48cc604620 --- /dev/null +++ b/lib/editor/atto/plugins/orderedlist/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_orderedlist + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_orderedlist'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button-debug.js b/lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button-debug.js new file mode 100644 index 00000000000..c1a07064680 --- /dev/null +++ b/lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button-debug.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_orderedlist-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 orderedlist plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_orderedlist = M.atto_orderedlist || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('insertOrderedList', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'orderedlist', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button-min.js b/lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button-min.js new file mode 100644 index 00000000000..d606ba09c67 --- /dev/null +++ b/lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_orderedlist-button",function(e,t){M.atto_orderedlist=M.atto_orderedlist||{init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("insertOrderedList",!1,null)};M.editor_atto.add_toolbar_button(e.elementid,"orderedlist",e.icon,t)}}},"@VERSION@",{requires:["node"]}); diff --git a/lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button.js b/lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button.js new file mode 100644 index 00000000000..c1a07064680 --- /dev/null +++ b/lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_orderedlist-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 orderedlist plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_orderedlist = M.atto_orderedlist || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('insertOrderedList', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'orderedlist', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/orderedlist/yui/src/button/build.json b/lib/editor/atto/plugins/orderedlist/yui/src/button/build.json new file mode 100644 index 00000000000..2326ff6dcb1 --- /dev/null +++ b/lib/editor/atto/plugins/orderedlist/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_orderedlist-button", + "builds": { + "moodle-atto_orderedlist-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/orderedlist/yui/src/button/js/button.js b/lib/editor/atto/plugins/orderedlist/yui/src/button/js/button.js new file mode 100644 index 00000000000..8f549432b58 --- /dev/null +++ b/lib/editor/atto/plugins/orderedlist/yui/src/button/js/button.js @@ -0,0 +1,35 @@ +// 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 orderedlist plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_orderedlist = M.atto_orderedlist || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('insertOrderedList', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'orderedlist', params.icon, click); + } +}; diff --git a/lib/editor/atto/plugins/orderedlist/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/orderedlist/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..08ed48a0e44 --- /dev/null +++ b/lib/editor/atto/plugins/orderedlist/yui/src/button/meta/editor.json @@ -0,0 +1,5 @@ +{ + "moodle-atto_orderedlist-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/plugins/outdent/lang/en/atto_outdent.php b/lib/editor/atto/plugins/outdent/lang/en/atto_outdent.php new file mode 100644 index 00000000000..ee5f5f2d6b8 --- /dev/null +++ b/lib/editor/atto/plugins/outdent/lang/en/atto_outdent.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'atto_outdent', language 'en'. + * + * @package atto_outdent + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Outdent'; +$string['outdent'] = 'Outdent'; diff --git a/lib/editor/atto/plugins/outdent/lib.php b/lib/editor/atto/plugins/outdent/lib.php new file mode 100644 index 00000000000..29cca4ce587 --- /dev/null +++ b/lib/editor/atto/plugins/outdent/lib.php @@ -0,0 +1,50 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_outdent + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_outdent_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('outdent', + get_string('outdent', 'atto_outdent'), + 'atto_outdent', + array('class'=>'icon')); + + $PAGE->requires->yui_module('moodle-atto_outdent-button', + 'M.atto_outdent.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_outdent_sort_order() { + return 4; +} diff --git a/lib/editor/atto/plugins/outdent/pix/outdent.png b/lib/editor/atto/plugins/outdent/pix/outdent.png new file mode 100644 index 0000000000000000000000000000000000000000..2c708fa7b9613e25f72405a65f1f1cd8a36bef48 GIT binary patch literal 440 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWN>JzX3_G|ngg@MkdKX=w7F-zT@Xl)JrYx_uU{>-*o^!)tub9QDwzrNn$?uWm>8~+xk<=_4F!%)t>?r+tjAAc%WhsEyy_nhA^ z{?DJvhleJqUSIc+w|#&8#JffUj=g*g@{>Pmo|SkW4zygg#5JNMC9x#cD!C{XNHG{0 z7#iyunCcoDhZq@I85mg^nra(ZSQ!}bvMlRF(U6;;l9^VCTSHBxoGDO4Ey#xAvUIDY z#Nt%l(xOa;w9K4TD}82Cg+{EIN z)FP;qeokhRerif)Nq&)jaz0QM5CM6KNja(d1v#bZnR&(f`K2W(Kym$o%nBG=4`}mh T!@d834q@bP0l+XkK*?OUi literal 0 HcmV?d00001 diff --git a/lib/editor/atto/plugins/outdent/pix/outdent.svg b/lib/editor/atto/plugins/outdent/pix/outdent.svg new file mode 100644 index 00000000000..a2be28a0719 --- /dev/null +++ b/lib/editor/atto/plugins/outdent/pix/outdent.svg @@ -0,0 +1,68 @@ + + + + + + + + + + image/svg+xml + + + + + + + < + + diff --git a/lib/editor/atto/plugins/outdent/version.php b/lib/editor/atto/plugins/outdent/version.php new file mode 100644 index 00000000000..535850c875e --- /dev/null +++ b/lib/editor/atto/plugins/outdent/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_outdent + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_outdent'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button-debug.js b/lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button-debug.js new file mode 100644 index 00000000000..cd8bd527ec6 --- /dev/null +++ b/lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button-debug.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_outdent-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 outdent plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_outdent = M.atto_outdent || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('outdent', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'outdent', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button-min.js b/lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button-min.js new file mode 100644 index 00000000000..4d14a825599 --- /dev/null +++ b/lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_outdent-button",function(e,t){M.atto_outdent=M.atto_outdent||{init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("outdent",!1,null)};M.editor_atto.add_toolbar_button(e.elementid,"outdent",e.icon,t)}}},"@VERSION@",{requires:["node"]}); diff --git a/lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button.js b/lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button.js new file mode 100644 index 00000000000..cd8bd527ec6 --- /dev/null +++ b/lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_outdent-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 outdent plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_outdent = M.atto_outdent || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('outdent', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'outdent', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/outdent/yui/src/button/build.json b/lib/editor/atto/plugins/outdent/yui/src/button/build.json new file mode 100644 index 00000000000..177e1c7f1d4 --- /dev/null +++ b/lib/editor/atto/plugins/outdent/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_outdent-button", + "builds": { + "moodle-atto_outdent-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/outdent/yui/src/button/js/button.js b/lib/editor/atto/plugins/outdent/yui/src/button/js/button.js new file mode 100644 index 00000000000..2f7eebc3f9e --- /dev/null +++ b/lib/editor/atto/plugins/outdent/yui/src/button/js/button.js @@ -0,0 +1,35 @@ +// 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 outdent plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_outdent = M.atto_outdent || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('outdent', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'outdent', params.icon, click); + } +}; diff --git a/lib/editor/atto/plugins/outdent/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/outdent/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..5c46b6c399e --- /dev/null +++ b/lib/editor/atto/plugins/outdent/yui/src/button/meta/editor.json @@ -0,0 +1,5 @@ +{ + "moodle-atto_outdent-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/plugins/strike/lang/en/atto_strike.php b/lib/editor/atto/plugins/strike/lang/en/atto_strike.php new file mode 100644 index 00000000000..f25ee27403b --- /dev/null +++ b/lib/editor/atto/plugins/strike/lang/en/atto_strike.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'atto_strike', language 'en'. + * + * @package atto_strike + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Strike through'; +$string['strike'] = 'Strike through'; diff --git a/lib/editor/atto/plugins/strike/lib.php b/lib/editor/atto/plugins/strike/lib.php new file mode 100644 index 00000000000..000bb44d737 --- /dev/null +++ b/lib/editor/atto/plugins/strike/lib.php @@ -0,0 +1,52 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_strike + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_strike_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('strike', + get_string('strike', 'atto_strike'), + 'atto_strike', + array('class'=>'icon')); + + $PAGE->requires->yui_module('moodle-atto_strike-button', + 'M.atto_strike.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_strike_sort_order() { + return 3; +} diff --git a/lib/editor/atto/plugins/strike/pix/strike.png b/lib/editor/atto/plugins/strike/pix/strike.png new file mode 100644 index 0000000000000000000000000000000000000000..c5c3a6182093de462669480ce7b4202224d0f644 GIT binary patch literal 479 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWO|dAc};Xq-PfVK-N^gMjPb|MnMZSzI>vKDu^N{)X-vB_$=E9cD^hQ>}93 zLMODAoXpHCesE9neBHs{8v{hH&zPjbSitr8gvNnQPb|}azZ2N??$Gj+Q7#RSEjYbA zXQs~iX}7p=%Cb)?yU8!2)8c~vxSdwa$T$Bo=7>o=Ijdcx7bq$R} zj0~+zOs$NJwGAw+3=H_EOh`r1kei>9nO2EgL)}S@n?McKARCIy(yfvbi&J$=i!vF~ zGILU`^!4>K@^e%5QxbD4^Yip`^Yc@3Qj7I7^GZ_FixNvR^Yh|!6N^hyi=a~aIhjfN zsVSKy`9=E4`9M`b1mqq$o2R$jz*PGWCG=@)`J<1D(O(>FVdQ I&MBb@06@X6?*IS* literal 0 HcmV?d00001 diff --git a/lib/editor/atto/plugins/strike/pix/strike.svg b/lib/editor/atto/plugins/strike/pix/strike.svg new file mode 100644 index 00000000000..5633651b3b4 --- /dev/null +++ b/lib/editor/atto/plugins/strike/pix/strike.svg @@ -0,0 +1,77 @@ + + + + + + + + + + image/svg+xml + + + + + + + + s + + + + diff --git a/lib/editor/atto/plugins/strike/version.php b/lib/editor/atto/plugins/strike/version.php new file mode 100644 index 00000000000..9cca900a64d --- /dev/null +++ b/lib/editor/atto/plugins/strike/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_strike + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_strike'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button-debug.js b/lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button-debug.js new file mode 100644 index 00000000000..34f2908e848 --- /dev/null +++ b/lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button-debug.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_strike-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 strike plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_strike = M.atto_strike || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('strikeThrough', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'strike', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button-min.js b/lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button-min.js new file mode 100644 index 00000000000..d37fd84168a --- /dev/null +++ b/lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_strike-button",function(e,t){M.atto_strike=M.atto_strike||{init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("strikeThrough",!1,null)};M.editor_atto.add_toolbar_button(e.elementid,"strike",e.icon,t)}}},"@VERSION@",{requires:["node"]}); diff --git a/lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button.js b/lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button.js new file mode 100644 index 00000000000..34f2908e848 --- /dev/null +++ b/lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_strike-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 strike plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_strike = M.atto_strike || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('strikeThrough', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'strike', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/strike/yui/src/button/build.json b/lib/editor/atto/plugins/strike/yui/src/button/build.json new file mode 100644 index 00000000000..b24dfb52af7 --- /dev/null +++ b/lib/editor/atto/plugins/strike/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_strike-button", + "builds": { + "moodle-atto_strike-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/strike/yui/src/button/js/button.js b/lib/editor/atto/plugins/strike/yui/src/button/js/button.js new file mode 100644 index 00000000000..06b0629502d --- /dev/null +++ b/lib/editor/atto/plugins/strike/yui/src/button/js/button.js @@ -0,0 +1,35 @@ +// 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 strike plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_strike = M.atto_strike || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('strikeThrough', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'strike', params.icon, click); + } +}; diff --git a/lib/editor/atto/plugins/strike/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/strike/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..71772d22ca9 --- /dev/null +++ b/lib/editor/atto/plugins/strike/yui/src/button/meta/editor.json @@ -0,0 +1,5 @@ +{ + "moodle-atto_strike-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/plugins/title/lang/en/atto_title.php b/lib/editor/atto/plugins/title/lang/en/atto_title.php new file mode 100644 index 00000000000..fd66aed9bdb --- /dev/null +++ b/lib/editor/atto/plugins/title/lang/en/atto_title.php @@ -0,0 +1,30 @@ +. + +/** + * Strings for component 'atto_title', language 'en'. + * + * @package atto_title + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Paragraph styles'; +$string['title'] = 'Paragraph styles'; +$string['h1'] = 'Title'; +$string['h2'] = 'Heading'; +$string['blockquote'] = 'Quoted'; +$string['p'] = 'Plain'; diff --git a/lib/editor/atto/plugins/title/lib.php b/lib/editor/atto/plugins/title/lib.php new file mode 100644 index 00000000000..5480467485a --- /dev/null +++ b/lib/editor/atto/plugins/title/lib.php @@ -0,0 +1,56 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_title + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_title_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('title', + get_string('title', 'atto_title'), + 'atto_title', + array('class'=>'icon')); + + $PAGE->requires->strings_for_js(array('h1', + 'h2', + 'blockquote', + 'p'), 'atto_title'); + $PAGE->requires->yui_module('moodle-atto_title-button', + 'M.atto_title.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_title_sort_order() { + return 9; +} diff --git a/lib/editor/atto/plugins/title/pix/title.png b/lib/editor/atto/plugins/title/pix/title.png new file mode 100644 index 0000000000000000000000000000000000000000..9a587fb14404f64c4c5082c5484abecb26ca9624 GIT binary patch literal 550 zcmV+>0@?kEP)*mgZp>!0+m7Q1)s*?Z{{hg7{!+1z?$297KCT?Y=WwZUZp%zQrI5s_PI zn(jnVR8(n7l4NVKSfs$E0h}z$1XxsE{#U<%s?T+<%;})t?>8HbMyt&1IL@@&?T+eL zycVF@Y`Us?^CT9Ld%!nUeG5<&MS9V|!C-JzM7(viJkMug82&B=u-5(r9-YK-9Nz)n z1wrt*!etl^hr6EVy`toKj4>a9yQgzbmBCfz`~D{pd8w+`fbEs@-SfONpSD&2fXQUC zFCuSN(|MjhY_(cnHx3X*QDKa^54;CZ)gQpKUaxn!&R;tKK)c;Oc3t-Y@L5F0*4n3K z-i-hNbUK|cz@D|XeV%V)007q7ql-L_F=h!|Ns?r1wJ0JX@O(9&W!Vj2SqG%3Dsdb? o0S^A5Z>g$b5Cku30r;Q#1Hx>L##2ONV*mgE07*qoM6N<$f>S*0)Bpeg literal 0 HcmV?d00001 diff --git a/lib/editor/atto/plugins/title/pix/title.svg b/lib/editor/atto/plugins/title/pix/title.svg new file mode 100644 index 00000000000..fc86cca72f8 --- /dev/null +++ b/lib/editor/atto/plugins/title/pix/title.svg @@ -0,0 +1,87 @@ + + + + + + + + + + image/svg+xml + + + + + + + T + + + + diff --git a/lib/editor/atto/plugins/title/version.php b/lib/editor/atto/plugins/title/version.php new file mode 100644 index 00000000000..a6542af9cc2 --- /dev/null +++ b/lib/editor/atto/plugins/title/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_title + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_title'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button-debug.js b/lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button-debug.js new file mode 100644 index 00000000000..f99197fcceb --- /dev/null +++ b/lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button-debug.js @@ -0,0 +1,74 @@ +YUI.add('moodle-atto_title-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 title plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_title = M.atto_title || { + init : function(params) { + var click_h1 = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('formatBlock', false, '

'); + }; + var click_h2 = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('formatBlock', false, '

'); + }; + var click_blockquote = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('formatBlock', false, '
'); + }; + var click_p = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('formatBlock', false, '

'); + }; + + var h1 = '

' + M.util.get_string('h1', 'atto_title') + '

'; + var h2 = '

' + M.util.get_string('h2', 'atto_title') + '

'; + var blockquote = '

    ' + M.util.get_string('blockquote', 'atto_title') + '

'; + var p = '

' + M.util.get_string('p', 'atto_title') + '

'; + + M.editor_atto.add_toolbar_menu(params.elementid, + 'title', + params.icon, + [ + {'text' : h1, 'handler' : click_h1}, + {'text' : h2, 'handler' : click_h2}, + {'text' : blockquote, 'handler' : click_blockquote}, + {'text' : p, 'handler' : click_p} + ]); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button-min.js b/lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button-min.js new file mode 100644 index 00000000000..94806e639ca --- /dev/null +++ b/lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_title-button",function(e,t){M.atto_title=M.atto_title||{init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("formatBlock",!1,"

")},n=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("formatBlock",!1,"

")},r=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("formatBlock",!1,"
")},i=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("formatBlock",!1,"

")},s="

"+M.util.get_string("h1","atto_title")+"

",o="

"+M.util.get_string("h2","atto_title")+"

",u="

    "+M.util.get_string("blockquote","atto_title")+"

",a="

"+M.util.get_string("p","atto_title")+"

";M.editor_atto.add_toolbar_menu(e.elementid,"title",e.icon,[{text:s,handler:t},{text:o,handler:n},{text:u,handler:r},{text:a,handler:i}])}}},"@VERSION@",{requires:["node"]}); diff --git a/lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button.js b/lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button.js new file mode 100644 index 00000000000..f99197fcceb --- /dev/null +++ b/lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button.js @@ -0,0 +1,74 @@ +YUI.add('moodle-atto_title-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 title plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_title = M.atto_title || { + init : function(params) { + var click_h1 = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('formatBlock', false, '

'); + }; + var click_h2 = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('formatBlock', false, '

'); + }; + var click_blockquote = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('formatBlock', false, '
'); + }; + var click_p = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('formatBlock', false, '

'); + }; + + var h1 = '

' + M.util.get_string('h1', 'atto_title') + '

'; + var h2 = '

' + M.util.get_string('h2', 'atto_title') + '

'; + var blockquote = '

    ' + M.util.get_string('blockquote', 'atto_title') + '

'; + var p = '

' + M.util.get_string('p', 'atto_title') + '

'; + + M.editor_atto.add_toolbar_menu(params.elementid, + 'title', + params.icon, + [ + {'text' : h1, 'handler' : click_h1}, + {'text' : h2, 'handler' : click_h2}, + {'text' : blockquote, 'handler' : click_blockquote}, + {'text' : p, 'handler' : click_p} + ]); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/title/yui/src/button/build.json b/lib/editor/atto/plugins/title/yui/src/button/build.json new file mode 100644 index 00000000000..8ee3ce0e4b8 --- /dev/null +++ b/lib/editor/atto/plugins/title/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_title-button", + "builds": { + "moodle-atto_title-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/title/yui/src/button/js/button.js b/lib/editor/atto/plugins/title/yui/src/button/js/button.js new file mode 100644 index 00000000000..aaa1c20938e --- /dev/null +++ b/lib/editor/atto/plugins/title/yui/src/button/js/button.js @@ -0,0 +1,69 @@ +// 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 title plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_title = M.atto_title || { + init : function(params) { + var click_h1 = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('formatBlock', false, '

'); + }; + var click_h2 = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('formatBlock', false, '

'); + }; + var click_blockquote = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('formatBlock', false, '
'); + }; + var click_p = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('formatBlock', false, '

'); + }; + + var h1 = '

' + M.util.get_string('h1', 'atto_title') + '

'; + var h2 = '

' + M.util.get_string('h2', 'atto_title') + '

'; + var blockquote = '

    ' + M.util.get_string('blockquote', 'atto_title') + '

'; + var p = '

' + M.util.get_string('p', 'atto_title') + '

'; + + M.editor_atto.add_toolbar_menu(params.elementid, + 'title', + params.icon, + [ + {'text' : h1, 'handler' : click_h1}, + {'text' : h2, 'handler' : click_h2}, + {'text' : blockquote, 'handler' : click_blockquote}, + {'text' : p, 'handler' : click_p} + ]); + } +}; diff --git a/lib/editor/atto/plugins/title/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/title/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..c073041342e --- /dev/null +++ b/lib/editor/atto/plugins/title/yui/src/button/meta/editor.json @@ -0,0 +1,5 @@ +{ + "moodle-atto_title-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/plugins/underline/lang/en/atto_underline.php b/lib/editor/atto/plugins/underline/lang/en/atto_underline.php new file mode 100644 index 00000000000..53c93deb8e7 --- /dev/null +++ b/lib/editor/atto/plugins/underline/lang/en/atto_underline.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'atto_underline', language 'en'. + * + * @package atto_underline + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Underline'; +$string['underline'] = 'Underline'; diff --git a/lib/editor/atto/plugins/underline/lib.php b/lib/editor/atto/plugins/underline/lib.php new file mode 100644 index 00000000000..bde1f90be8a --- /dev/null +++ b/lib/editor/atto/plugins/underline/lib.php @@ -0,0 +1,52 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_underline + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_underline_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('underline', + get_string('underline', 'atto_underline'), + 'atto_underline', + array('class'=>'icon')); + + $PAGE->requires->yui_module('moodle-atto_underline-button', + 'M.atto_underline.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_underline_sort_order() { + return 2; +} diff --git a/lib/editor/atto/plugins/underline/pix/underline.png b/lib/editor/atto/plugins/underline/pix/underline.png new file mode 100644 index 0000000000000000000000000000000000000000..329e4970db0925622cc175057a469c5dccbceabe GIT binary patch literal 430 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWPfJzX3_G|ngg@Mkax@IN?R-#ESQ7fVv?o*i|69kea#K`>#I;5u6uiTcQNj(aSZzK=Vv0% zhlk8lA2W$FF#L^pqJI6CU>(pp)e_f;l9a@fRIB8oR3OD*WMF8lYhbEtXdGf>Xk}_> zWnidnU}0roAmshC8%0BIeoAIqC2kGLVvgoO4UHfhip$cik`jwkbxVsf8PYOyQmyp$ z^)vEwQ}t64b1U=n^mFs`Q*u&^^)vHIQqzkPOEUBG;&T&=OHzxVQu;ZWN&2ZNnI-u} z`pNk~RX_yfB_`#h>KEjcrf23A>zC%Gq!#65<^e@AD-b+ApzU%iZTW$YVeoYIb6Mw< G&;$U+;h3WU literal 0 HcmV?d00001 diff --git a/lib/editor/atto/plugins/underline/pix/underline.svg b/lib/editor/atto/plugins/underline/pix/underline.svg new file mode 100644 index 00000000000..001012e2926 --- /dev/null +++ b/lib/editor/atto/plugins/underline/pix/underline.svg @@ -0,0 +1,73 @@ + + + + + + + + + + image/svg+xml + + + + + + + u + + + diff --git a/lib/editor/atto/plugins/underline/version.php b/lib/editor/atto/plugins/underline/version.php new file mode 100644 index 00000000000..4938a10f70a --- /dev/null +++ b/lib/editor/atto/plugins/underline/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_underline + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_underline'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button-debug.js b/lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button-debug.js new file mode 100644 index 00000000000..caa347e4017 --- /dev/null +++ b/lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button-debug.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_underline-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 underline plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_underline = M.atto_underline || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('underline', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'underline', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button-min.js b/lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button-min.js new file mode 100644 index 00000000000..6954ce22235 --- /dev/null +++ b/lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_underline-button",function(e,t){M.atto_underline=M.atto_underline||{init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("underline",!1,null)};M.editor_atto.add_toolbar_button(e.elementid,"underline",e.icon,t)}}},"@VERSION@",{requires:["node"]}); diff --git a/lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button.js b/lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button.js new file mode 100644 index 00000000000..caa347e4017 --- /dev/null +++ b/lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_underline-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 underline plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_underline = M.atto_underline || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('underline', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'underline', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/underline/yui/src/button/build.json b/lib/editor/atto/plugins/underline/yui/src/button/build.json new file mode 100644 index 00000000000..761727315e1 --- /dev/null +++ b/lib/editor/atto/plugins/underline/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_underline-button", + "builds": { + "moodle-atto_underline-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/underline/yui/src/button/js/button.js b/lib/editor/atto/plugins/underline/yui/src/button/js/button.js new file mode 100644 index 00000000000..f4ac98f8806 --- /dev/null +++ b/lib/editor/atto/plugins/underline/yui/src/button/js/button.js @@ -0,0 +1,35 @@ +// 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 underline plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_underline = M.atto_underline || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('underline', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'underline', params.icon, click); + } +}; diff --git a/lib/editor/atto/plugins/underline/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/underline/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..e96b89bcddb --- /dev/null +++ b/lib/editor/atto/plugins/underline/yui/src/button/meta/editor.json @@ -0,0 +1,5 @@ +{ + "moodle-atto_underline-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/plugins/unlink/lang/en/atto_unlink.php b/lib/editor/atto/plugins/unlink/lang/en/atto_unlink.php new file mode 100644 index 00000000000..2ab5b16d5da --- /dev/null +++ b/lib/editor/atto/plugins/unlink/lang/en/atto_unlink.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'atto_unlink', language 'en'. + * + * @package atto_unlink + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Unlink'; +$string['unlink'] = 'Unlink'; diff --git a/lib/editor/atto/plugins/unlink/lib.php b/lib/editor/atto/plugins/unlink/lib.php new file mode 100644 index 00000000000..eef044961ac --- /dev/null +++ b/lib/editor/atto/plugins/unlink/lib.php @@ -0,0 +1,50 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_unlink + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_unlink_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('unlink', + get_string('unlink', 'atto_unlink'), + 'atto_unlink', + array('class'=>'icon')); + + $PAGE->requires->yui_module('moodle-atto_unlink-button', + 'M.atto_unlink.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_unlink_sort_order() { + return 12; +} diff --git a/lib/editor/atto/plugins/unlink/pix/unlink.png b/lib/editor/atto/plugins/unlink/pix/unlink.png new file mode 100644 index 0000000000000000000000000000000000000000..1dbbb9ccd0c17919789f8f19ab45c91cce842fdf GIT binary patch literal 534 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWOQdb&7= zsZJXn3GU~!?w)*e?w(%7ABG?C4ekYVp0DM2z$39e*MIrS$0{eC7!(z!=yFm}zVbu0A*>`j9U!GN`O!8&<7PFrB zXARsUu}LHDuX*jdRrBw=-i{bs)Hk0?_BdQP>(HKHUXu_VKa;x7@As{np>HeX&YEr85oFN_PL3oAvZrIGp!Q0hV;HKsXz_YARCIy(yfvbi&J$= zi!vF~GILU`^!4>K@^e%5QxbD4^Yip`^Yc@3Qj7I7^GZ_FixNvR^Yh|!6N^hyi=a~a zIhjfNsVSKy`9=E4`9M`b1mq6$` literal 0 HcmV?d00001 diff --git a/lib/editor/atto/plugins/unlink/pix/unlink.svg b/lib/editor/atto/plugins/unlink/pix/unlink.svg new file mode 100644 index 00000000000..114b77bfd3d --- /dev/null +++ b/lib/editor/atto/plugins/unlink/pix/unlink.svg @@ -0,0 +1,92 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/lib/editor/atto/plugins/unlink/version.php b/lib/editor/atto/plugins/unlink/version.php new file mode 100644 index 00000000000..4b9e76e4884 --- /dev/null +++ b/lib/editor/atto/plugins/unlink/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_unlink + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_unlink'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button-debug.js b/lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button-debug.js new file mode 100644 index 00000000000..365a993c350 --- /dev/null +++ b/lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button-debug.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_unlink-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 unlink plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_unlink = M.atto_unlink || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('unlink', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'unlink', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button-min.js b/lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button-min.js new file mode 100644 index 00000000000..4f412d02606 --- /dev/null +++ b/lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_unlink-button",function(e,t){M.atto_unlink=M.atto_unlink||{init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("unlink",!1,null)};M.editor_atto.add_toolbar_button(e.elementid,"unlink",e.icon,t)}}},"@VERSION@",{requires:["node"]}); diff --git a/lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button.js b/lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button.js new file mode 100644 index 00000000000..365a993c350 --- /dev/null +++ b/lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_unlink-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 unlink plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_unlink = M.atto_unlink || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('unlink', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'unlink', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/unlink/yui/src/button/build.json b/lib/editor/atto/plugins/unlink/yui/src/button/build.json new file mode 100644 index 00000000000..57ceaa51efb --- /dev/null +++ b/lib/editor/atto/plugins/unlink/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_unlink-button", + "builds": { + "moodle-atto_unlink-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/unlink/yui/src/button/js/button.js b/lib/editor/atto/plugins/unlink/yui/src/button/js/button.js new file mode 100644 index 00000000000..fd19d81ea2a --- /dev/null +++ b/lib/editor/atto/plugins/unlink/yui/src/button/js/button.js @@ -0,0 +1,35 @@ +// 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 unlink plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_unlink = M.atto_unlink || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('unlink', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'unlink', params.icon, click); + } +}; diff --git a/lib/editor/atto/plugins/unlink/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/unlink/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..448646904ac --- /dev/null +++ b/lib/editor/atto/plugins/unlink/yui/src/button/meta/editor.json @@ -0,0 +1,5 @@ +{ + "moodle-atto_unlink-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/plugins/unorderedlist/lang/en/atto_unorderedlist.php b/lib/editor/atto/plugins/unorderedlist/lang/en/atto_unorderedlist.php new file mode 100644 index 00000000000..34285088dd7 --- /dev/null +++ b/lib/editor/atto/plugins/unorderedlist/lang/en/atto_unorderedlist.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'atto_unorderedlist', language 'en'. + * + * @package atto_unorderedlist + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Unordered list'; +$string['unorderedlist'] = 'Unordered list'; diff --git a/lib/editor/atto/plugins/unorderedlist/lib.php b/lib/editor/atto/plugins/unorderedlist/lib.php new file mode 100644 index 00000000000..6224f905bab --- /dev/null +++ b/lib/editor/atto/plugins/unorderedlist/lib.php @@ -0,0 +1,50 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_unorderedlist + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * Initialise this plugin + * @param string $elementid + */ +function atto_unorderedlist_init_editor($elementid) { + global $PAGE, $OUTPUT; + + $icon = $OUTPUT->pix_icon('unorderedlist', + get_string('unorderedlist', 'atto_unorderedlist'), + 'atto_unorderedlist', + array('class'=>'icon')); + + $PAGE->requires->yui_module('moodle-atto_unorderedlist-button', + 'M.atto_unorderedlist.init', + array(array('elementid'=>$elementid, 'icon'=>$icon)), + true); + +} + +/** + * Return the order this plugin should be displayed in the toolbar + * @return int + */ +function atto_unorderedlist_sort_order() { + return 7; +} diff --git a/lib/editor/atto/plugins/unorderedlist/pix/unorderedlist.png b/lib/editor/atto/plugins/unorderedlist/pix/unorderedlist.png new file mode 100644 index 0000000000000000000000000000000000000000..95b9d12d5487fd9d10f45a82c11384e801edbc82 GIT binary patch literal 441 zcmeAS@N?(olHy`uVBq!ia0vp^0w4?`7_vBO{sAebByV?@|Nli+8=eL7I14-?i-EKU z7`vU!wgWQKJY5_^G|ngg@MkbMAo2S8{`&slgL|vp``5(Rzr6JDu)@9f_wOHk@IHP= zlmGm4^XHou|Nf@#@33dFds@@M)6+e|-rOyIb>-61`F4#r?)FK#IZ0z|dINz*N`JIK;@v z%EZ{p*izfT!pgwl`mD<~C>nC}Q!>*kacfw1Ji7s?p%Y|7aap=mQettcZfQ{_Lt17| zs+GRJenx(7s(wmhZe@O+er|q#N=|CAer8@tYI;#(NoIatd~RZKNoo;PN + + + + + + + + + image/svg+xml + + + + + + + + * + - + + + * + - + + + diff --git a/lib/editor/atto/plugins/unorderedlist/version.php b/lib/editor/atto/plugins/unorderedlist/version.php new file mode 100644 index 00000000000..ec5600dd604 --- /dev/null +++ b/lib/editor/atto/plugins/unorderedlist/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package atto_unorderedlist + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'atto_unorderedlist'; // Full name of the plugin (used for diagnostics). diff --git a/lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button-debug.js b/lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button-debug.js new file mode 100644 index 00000000000..4915b2e40d7 --- /dev/null +++ b/lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button-debug.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_unorderedlist-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 unorderedlist plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_unorderedlist = M.atto_unorderedlist || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('insertUnorderedList', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'unorderedlist', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button-min.js b/lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button-min.js new file mode 100644 index 00000000000..5694eae1bf4 --- /dev/null +++ b/lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button-min.js @@ -0,0 +1 @@ +YUI.add("moodle-atto_unorderedlist-button",function(e,t){M.atto_unorderedlist=M.atto_unorderedlist||{init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("insertUnorderedList",!1,null)};M.editor_atto.add_toolbar_button(e.elementid,"unorderedlist",e.icon,t)}}},"@VERSION@",{requires:["node"]}); diff --git a/lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button.js b/lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button.js new file mode 100644 index 00000000000..4915b2e40d7 --- /dev/null +++ b/lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button.js @@ -0,0 +1,40 @@ +YUI.add('moodle-atto_unorderedlist-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 unorderedlist plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_unorderedlist = M.atto_unorderedlist || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('insertUnorderedList', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'unorderedlist', params.icon, click); + } +}; + + +}, '@VERSION@', {"requires": ["node"]}); diff --git a/lib/editor/atto/plugins/unorderedlist/yui/src/button/build.json b/lib/editor/atto/plugins/unorderedlist/yui/src/button/build.json new file mode 100644 index 00000000000..eced221fea8 --- /dev/null +++ b/lib/editor/atto/plugins/unorderedlist/yui/src/button/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-atto_unorderedlist-button", + "builds": { + "moodle-atto_unorderedlist-button": { + "jsfiles": [ + "button.js" + ] + } + } +} diff --git a/lib/editor/atto/plugins/unorderedlist/yui/src/button/js/button.js b/lib/editor/atto/plugins/unorderedlist/yui/src/button/js/button.js new file mode 100644 index 00000000000..e86e3e9f84f --- /dev/null +++ b/lib/editor/atto/plugins/unorderedlist/yui/src/button/js/button.js @@ -0,0 +1,35 @@ +// 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 unorderedlist plugin. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.atto_unorderedlist = M.atto_unorderedlist || { + init : function(params) { + var click = function(e, elementid) { + e.preventDefault(); + if (!M.editor_atto.is_active(elementid)) { + M.editor_atto.focus(elementid); + } + document.execCommand('insertUnorderedList', false, null); + }; + + M.editor_atto.add_toolbar_button(params.elementid, 'unorderedlist', params.icon, click); + } +}; diff --git a/lib/editor/atto/plugins/unorderedlist/yui/src/button/meta/editor.json b/lib/editor/atto/plugins/unorderedlist/yui/src/button/meta/editor.json new file mode 100644 index 00000000000..58307eb3208 --- /dev/null +++ b/lib/editor/atto/plugins/unorderedlist/yui/src/button/meta/editor.json @@ -0,0 +1,5 @@ +{ + "moodle-atto_unorderedlist-button": { + "requires": ["node"] + } +} diff --git a/lib/editor/atto/styles.css b/lib/editor/atto/styles.css new file mode 100644 index 00000000000..437ae34ecc8 --- /dev/null +++ b/lib/editor/atto/styles.css @@ -0,0 +1,71 @@ +div.editor_atto { + background-color: white; + border: 1px solid #444; +} + +div.editor_atto_toolbar { + display: block; +} + +div.editor_atto_toolbar button { + padding: 1px; + padding: 3px; +} +div.editor_atto_toolbar button img { + padding: 1px; +} + +div.editor_atto_toolbar button.atto_strike_button, +div.editor_atto_toolbar button.atto_unorderedlist_button, +div.editor_atto_toolbar button.atto_clear_button, +div.editor_atto_toolbar button.atto_indent_button { + margin-right: 1em; +} +body.dir-rtl div.editor_atto_toolbar button.atto_strike_button, +body.dir-rtl div.editor_atto_toolbar button.atto_unorderedlist_button, +body.dir-rtl div.editor_atto_toolbar button.atto_clear_button, +body.dir-rtl div.editor_atto_toolbar button.atto_indent_button { + margin-right: 0px; + margin-left: 1em; +} + +.atto_hasmenu .icon { + width: 32px; +} + +.editor_atto img { + resize: both; overflow: auto; +} +.atto_menuentry { + clear: left; +} +.atto_menuentry img { + width: 16px; + height: 16px; +} + +.atto_menu { + min-width: 12em; + background: white; + padding: 1px; +} + +.atto_menu a { + color: black; +} +.atto_menuentry { + border-bottom: 1px solid #eee; + padding: 2px; +} + +.atto_menuentry h1, +.atto_menuentry h2, +.atto_menuentry p { + margin: 4px; +} + + +.atto_form label { + display: block; + margin: 5px; +} diff --git a/lib/editor/atto/version.php b/lib/editor/atto/version.php new file mode 100644 index 00000000000..90d5388b1e4 --- /dev/null +++ b/lib/editor/atto/version.php @@ -0,0 +1,29 @@ +. + +/** + * Atto text editor integration version file. + * + * @package editor_atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2013050100; // Requires this Moodle version. +$plugin->component = 'editor_atto'; // Full name of the plugin (used for diagnostics). 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 new file mode 100644 index 00000000000..82a3d4731b1 --- /dev/null +++ b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js @@ -0,0 +1,412 @@ +YUI.add('moodle-editor_atto-editor', 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 editor main class. + * Common functions required by editor plugins. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.editor_atto = M.editor_atto || { + /** + * List of attached button handlers to prevent duplicates. + */ + buttonhandlers : {}, + + /** + * List of YUI overlays for custom menus. + */ + menus : {}, + + /** + * List of attached menu handlers to prevent duplicates. + */ + menuhandlers : {}, + + /** + * List of file picker options for specific editor instances. + */ + filepickeroptions : {}, + + /** + * List of buttons and menus that have been added to the toolbar. + */ + widgets : {}, + + /** + * Toggle a menu. + * @param event e + */ + showhide_menu_handler : function(e) { + e.preventDefault(); + var disabled = this.getAttribute('disabled'); + var overlayid = this.getAttribute('data-menu'); + var overlay = M.editor_atto.menus[overlayid]; + + if (overlay.get('visible') || disabled) { + overlay.hide(); + } else { + overlay.show(); + } + + }, + + /** + * Handle clicks on editor buttons. + * @param event e + */ + buttonclicked_handler : function(e) { + var elementid = this.getAttribute('data-editor'); + var plugin = this.getAttribute('data-plugin'); + var handler = this.getAttribute('data-handler'); + var overlay = M.editor_atto.menus[plugin + '_' + elementid]; + + if (overlay) { + overlay.hide(); + } + + if (M.editor_atto.is_enabled(elementid, plugin)) { + // Pass it on. + handler = M.editor_atto.buttonhandlers[handler]; + return handler(e, elementid); + } + }, + + /** + * Determine if the specified toolbar button/menu is enabled. + * @param string elementid, the element id of this editor. + * @param string plugin, the plugin that created the button/menu. + */ + is_enabled : function(elementid, plugin) { + var element = Y.one('#' + elementid + '_toolbar .atto_' + plugin + '_button'); + + return !element.hasAttribute('disabled'); + }, + /** + * Disable all buttons and menus in the toolbar. + * @param string elementid, the element id of this editor. + */ + disable_all_widgets : function(elementid) { + var plugin, element; + for (plugin in M.editor_atto.widgets) { + element = Y.one('#' + elementid + '_toolbar .atto_' + plugin + '_button'); + + if (element) { + element.setAttribute('disabled', 'true'); + } + } + }, + + /** + * Enable a single widget in the toolbar. + * @param string elementid, the element id of this editor. + * @param string plugin, the name of the plugin that created the widget. + */ + enable_widget : function(elementid, plugin) { + var element = Y.one('#' + elementid + '_toolbar .atto_' + plugin + '_button'); + + if (element) { + element.removeAttribute('disabled'); + } + }, + + /** + * Enable all buttons and menus in the toolbar. + * @param string elementid, the element id of this editor. + */ + enable_all_widgets : function(elementid) { + var plugin, element; + for (plugin in M.editor_atto.widgets) { + element = Y.one('#' + elementid + '_toolbar .atto_' + plugin + '_button'); + + if (element) { + element.removeAttribute('disabled'); + } + } + }, + + /** + * Add a button to the toolbar belonging to the editor for element with id "elementid". + * @param string elementid - the id of the textarea we created this editor from. + * @param string plugin - the plugin defining the button + * @param string icon - the html used for the content of the button + * @handler function handler- A function to call when the button is clicked. + */ + add_toolbar_menu : function(elementid, plugin, icon, entries) { + var toolbar = Y.one('#' + elementid + '_toolbar'); + var button = Y.Node.create(''); + + toolbar.append(button); + + // Save the name of the plugin. + M.editor_atto.widgets[plugin] = plugin; + + var menu = Y.Node.create('
'); + + var i = 0, entry = {}; + + for (i = 0; i < entries.length; i++) { + entry = entries[i]; + + menu.append(Y.Node.create('')); + if (!M.editor_atto.buttonhandlers[plugin + '_action_' + i]) { + Y.one('body').delegate('click', M.editor_atto.buttonclicked_handler, '.atto_' + plugin + '_action_' + i); + M.editor_atto.buttonhandlers[plugin + '_action_' + i] = entry.handler; + } + } + + if (!M.editor_atto.buttonhandlers[plugin]) { + Y.one('body').delegate('click', M.editor_atto.showhide_menu_handler, '.atto_' + plugin + '_button'); + M.editor_atto.buttonhandlers[plugin] = true; + } + + var overlay = new M.core.dialogue({ + bodyContent : menu, + visible : false, + width: '14em', + zindex: 100, + lightbox: false, + closeButton: false, + align: {node: button, points: [Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.BL]} + }); + + M.editor_atto.menus[plugin + '_' + elementid] = overlay; + overlay.render(); + overlay.hide(); + overlay.headerNode.hide(); + }, + + /** + * Add a button to the toolbar belonging to the editor for element with id "elementid". + * @param string elementid - the id of the textarea we created this editor from. + * @param string plugin - the plugin defining the button + * @param string icon - the html used for the content of the button + * @handler function handler- A function to call when the button is clicked. + */ + add_toolbar_button : function(elementid, plugin, icon, handler) { + var toolbar = Y.one('#' + elementid + '_toolbar'); + var button = Y.Node.create(''); + + toolbar.append(button); + + // We only need to attach this once. + if (!M.editor_atto.buttonhandlers[plugin]) { + Y.one('body').delegate('click', M.editor_atto.buttonclicked_handler, '.atto_' + plugin + '_button'); + M.editor_atto.buttonhandlers[plugin] = handler; + } + + // Save the name of the plugin. + M.editor_atto.widgets[plugin] = plugin; + + }, + + /** + * Work out if the cursor is in the editable area for this editor instance. + * @param string elementid of this editor + * @return bool + */ + is_active : function(elementid) { + var selection = M.editor_atto.get_selection(); + + if (selection.length) { + selection = selection.pop(); + } + + var node = null; + if (selection.parentElement) { + node = Y.one(selection.parentElement()); + } else { + node = Y.one(selection.startContainer); + } + + return node && node.ancestor('#' + elementid + 'editable') !== null; + }, + + /** + * Focus on the editable area for this editor. + * @param string elementid of this editor + */ + focus : function(elementid) { + Y.one('#' + elementid + 'editable').focus(); + }, + + /** + * Initialise the editor + * @param object params for this editor instance. + */ + init : function(params) { + var textarea = Y.one('#' +params.elementid); + var atto = Y.Node.create('
'); + var cssfont = ''; + var toolbar = Y.Node.create('
'); + + // Bleh - why are we sent a url and not the css to apply directly? + var css = Y.io(params.content_css, { sync: true }); + var pos = css.responseText.indexOf('font:'); + if (pos) { + cssfont = css.responseText.substring(pos + 'font:'.length, css.responseText.length - 1); + atto.setStyle('font', cssfont); + } + atto.setStyle('min-height', (1.2 * (textarea.getAttribute('rows') - 1)) + 'em'); + + // Copy text to editable div. + atto.append(textarea.get('value')); + + // Add the toolbar to the page. + textarea.get('parentNode').insert(toolbar, textarea); + // Add the editable div to the page. + textarea.get('parentNode').insert(atto, textarea); + // Hide the old textarea. + textarea.hide(); + + // Copy the current value back to the textarea when focus leaves us. + atto.on('blur', function() { + textarea.set('value', atto.getHTML()); + }); + + // Save the file picker options for later. + M.editor_atto.filepickeroptions[params.elementid] = params.filepickeroptions; + }, + + /** + * Show the filepicker. + * @param string elementid for this editor instance. + * @param string type The media type for the file picker + * @param function callback + */ + show_filepicker : function(elementid, type, callback) { + Y.use('core_filepicker', function (Y) { + var options = M.editor_atto.filepickeroptions[elementid][type]; + + options.formcallback = callback; + options.editor_target = Y.one(elementid); + + M.core_filepicker.show(Y, options); + }); + }, + + /** + * Create a cross browser selection object that represents a yui node. + * @param Node yui node for the selection + * @return range (browser dependent) + */ + get_selection_from_node: function(node) { + var range; + + if (window.getSelection) { + range = document.createRange(); + + range.setStartBefore(node.getDOMNode()); + range.setEndAfter(node.getDOMNode()); + return [range]; + } else if (document.selection) { + range = document.body.createTextRange(); + range.moveToElementText(node.getDOMNode()); + return range; + } + return false; + }, + + /** + * Get the selection object that can be passed back to set_selection. + * @return range (browser dependent) + */ + get_selection : function() { + if (window.getSelection) { + var sel = window.getSelection(); + var ranges = [], i = 0; + for (i = 0; i < sel.rangeCount; i++) { + ranges.push(sel.getRangeAt(i)); + } + return ranges; + } else if (document.selection) { + // IE < 9 + if (document.selection.createRange) { + return document.selection.createRange(); + } + } + return false; + }, + + /** + * Get the dom node representing the common anscestor of the selection nodes. + * @return DOMNode + */ + get_selection_parent_node : function() { + var selection = M.editor_atto.get_selection(); + if (selection.length > 0) { + return selection[0].commonAncestorContainer; + } + }, + + /** + * Get the list of child nodes of the selection. + * @return DOMNode[] + */ + get_selection_text : function() { + var selection = M.editor_atto.get_selection(); + if (selection.length > 0 && selection[0].cloneContents) { + return selection[0].cloneContents(); + } + }, + + /** + * Set the current selection. Used to restore a selection. + */ + set_selection : function(selection) { + var sel, i; + + if (window.getSelection) { + sel = window.getSelection(); + sel.removeAllRanges(); + for (i = 0; i < selection.length; i++) { + sel.addRange(selection[i]); + } + } else if (document.selection) { + // IE < 9 + if (selection.select) { + selection.select(); + } + } + } + +}; + + +}, '@VERSION@', {"requires": ["node", "io", "overlay", "escape", "moodle-core-notification"]}); 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 new file mode 100644 index 00000000000..8c038dad66e --- /dev/null +++ b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js @@ -0,0 +1 @@ +YUI.add("moodle-editor_atto-editor",function(e,t){M.editor_atto=M.editor_atto||{buttonhandlers:{},menus:{},menuhandlers:{},filepickeroptions:{},widgets:{},showhide_menu_handler:function(e){e.preventDefault();var t=this.getAttribute("disabled"),n=this.getAttribute("data-menu"),r=M.editor_atto.menus[n];r.get("visible")||t?r.hide():r.show()},buttonclicked_handler:function(e){var t=this.getAttribute("data-editor"),n=this.getAttribute("data-plugin"),r=this.getAttribute("data-handler"),i=M.editor_atto.menus[n+"_"+t];i&&i.hide();if(M.editor_atto.is_enabled(t,n))return r=M.editor_atto.buttonhandlers[r],r(e,t)},is_enabled:function(t,n){var r=e.one("#"+t+"_toolbar .atto_"+n+"_button");return!r.hasAttribute("disabled")},disable_all_widgets:function(t){var n,r;for(n in M.editor_atto.widgets)r=e.one("#"+t+"_toolbar .atto_"+n+"_button"),r&&r.setAttribute("disabled","true")},enable_widget:function(t,n){var r=e.one("#"+t+"_toolbar .atto_"+n+"_button");r&&r.removeAttribute("disabled")},enable_all_widgets:function(t){var n,r;for(n in M.editor_atto.widgets)r=e.one("#"+t+"_toolbar .atto_"+n+"_button"),r&&r.removeAttribute("disabled")},add_toolbar_menu:function(t,n,r,i){var s=e.one("#"+t+"_toolbar"),o=e.Node.create('");s.append(o),M.editor_atto.widgets[n]=n;var u=e.Node.create('
'),a=0,f={};for(a=0;a'+f.text+""+"
")),M.editor_atto.buttonhandlers[n+"_action_"+a]||(e.one("body").delegate("click",M.editor_atto.buttonclicked_handler,".atto_"+n+"_action_"+a),M.editor_atto.buttonhandlers[n+"_action_"+a]=f.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 l=new M.core.dialogue({bodyContent:u,visible:!1,width:"14em",zindex:100,lightbox:!1,closeButton:!1,align:{node:o,points:[e.WidgetPositionAlign.TL,e.WidgetPositionAlign.BL]}});M.editor_atto.menus[n+"_"+t]=l,l.render(),l.hide(),l.headerNode.hide()},add_toolbar_button:function(t,n,r,i){var s=e.one("#"+t+"_toolbar"),o=e.Node.create('");s.append(o),M.editor_atto.buttonhandlers[n]||(e.one("body").delegate("click",M.editor_atto.buttonclicked_handler,".atto_"+n+"_button"),M.editor_atto.buttonhandlers[n]=i),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(t){e.one("#"+t+"editable").focus()},init:function(t){var n=e.one("#"+t.elementid),r=e.Node.create('
'),i="",s=e.Node.create('
'),o=e.io(t.content_css,{sync:!0}),u=o.responseText.indexOf("font:");u&&(i=o.responseText.substring(u+"font:".length,o.responseText.length-1),r.setStyle("font",i)),r.setStyle("min-height",1.2*(n.getAttribute("rows")-1)+"em"),r.append(n.get("value")),n.get("parentNode").insert(s,n),n.get("parentNode").insert(r,n),n.hide(),r.on("blur",function(){n.set("value",r.getHTML())}),M.editor_atto.filepickeroptions[t.elementid]=t.filepickeroptions},show_filepicker:function(t,n,r){e.use("core_filepicker",function(e){var i=M.editor_atto.filepickeroptions[t][n];i.formcallback=r,i.editor_target=e.one(t),M.core_filepicker.show(e,i)})},get_selection_from_node:function(e){var t;return window.getSelection?(t=document.createRange(),t.setStartBefore(e.getDOMNode()),t.setEndAfter(e.getDOMNode()),[t]):document.selection?(t=document.body.createTextRange(),t.moveToElementText(e.getDOMNode()),t):!1},get_selection:function(){if(window.getSelection){var e=window.getSelection(),t=[],n=0;for(n=0;n0)return e[0].commonAncestorContainer},get_selection_text:function(){var e=M.editor_atto.get_selection();if(e.length>0&&e[0].cloneContents)return e[0].cloneContents()},set_selection:function(e){var t,n;if(window.getSelection){t=window.getSelection(),t.removeAllRanges();for(n=0;n. + +/** + * Atto editor main class. + * Common functions required by editor plugins. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.editor_atto = M.editor_atto || { + /** + * List of attached button handlers to prevent duplicates. + */ + buttonhandlers : {}, + + /** + * List of YUI overlays for custom menus. + */ + menus : {}, + + /** + * List of attached menu handlers to prevent duplicates. + */ + menuhandlers : {}, + + /** + * List of file picker options for specific editor instances. + */ + filepickeroptions : {}, + + /** + * List of buttons and menus that have been added to the toolbar. + */ + widgets : {}, + + /** + * Toggle a menu. + * @param event e + */ + showhide_menu_handler : function(e) { + e.preventDefault(); + var disabled = this.getAttribute('disabled'); + var overlayid = this.getAttribute('data-menu'); + var overlay = M.editor_atto.menus[overlayid]; + + if (overlay.get('visible') || disabled) { + overlay.hide(); + } else { + overlay.show(); + } + + }, + + /** + * Handle clicks on editor buttons. + * @param event e + */ + buttonclicked_handler : function(e) { + var elementid = this.getAttribute('data-editor'); + var plugin = this.getAttribute('data-plugin'); + var handler = this.getAttribute('data-handler'); + var overlay = M.editor_atto.menus[plugin + '_' + elementid]; + + if (overlay) { + overlay.hide(); + } + + if (M.editor_atto.is_enabled(elementid, plugin)) { + // Pass it on. + handler = M.editor_atto.buttonhandlers[handler]; + return handler(e, elementid); + } + }, + + /** + * Determine if the specified toolbar button/menu is enabled. + * @param string elementid, the element id of this editor. + * @param string plugin, the plugin that created the button/menu. + */ + is_enabled : function(elementid, plugin) { + var element = Y.one('#' + elementid + '_toolbar .atto_' + plugin + '_button'); + + return !element.hasAttribute('disabled'); + }, + /** + * Disable all buttons and menus in the toolbar. + * @param string elementid, the element id of this editor. + */ + disable_all_widgets : function(elementid) { + var plugin, element; + for (plugin in M.editor_atto.widgets) { + element = Y.one('#' + elementid + '_toolbar .atto_' + plugin + '_button'); + + if (element) { + element.setAttribute('disabled', 'true'); + } + } + }, + + /** + * Enable a single widget in the toolbar. + * @param string elementid, the element id of this editor. + * @param string plugin, the name of the plugin that created the widget. + */ + enable_widget : function(elementid, plugin) { + var element = Y.one('#' + elementid + '_toolbar .atto_' + plugin + '_button'); + + if (element) { + element.removeAttribute('disabled'); + } + }, + + /** + * Enable all buttons and menus in the toolbar. + * @param string elementid, the element id of this editor. + */ + enable_all_widgets : function(elementid) { + var plugin, element; + for (plugin in M.editor_atto.widgets) { + element = Y.one('#' + elementid + '_toolbar .atto_' + plugin + '_button'); + + if (element) { + element.removeAttribute('disabled'); + } + } + }, + + /** + * Add a button to the toolbar belonging to the editor for element with id "elementid". + * @param string elementid - the id of the textarea we created this editor from. + * @param string plugin - the plugin defining the button + * @param string icon - the html used for the content of the button + * @handler function handler- A function to call when the button is clicked. + */ + add_toolbar_menu : function(elementid, plugin, icon, entries) { + var toolbar = Y.one('#' + elementid + '_toolbar'); + var button = Y.Node.create(''); + + toolbar.append(button); + + // Save the name of the plugin. + M.editor_atto.widgets[plugin] = plugin; + + var menu = Y.Node.create('
'); + + var i = 0, entry = {}; + + for (i = 0; i < entries.length; i++) { + entry = entries[i]; + + menu.append(Y.Node.create('')); + if (!M.editor_atto.buttonhandlers[plugin + '_action_' + i]) { + Y.one('body').delegate('click', M.editor_atto.buttonclicked_handler, '.atto_' + plugin + '_action_' + i); + M.editor_atto.buttonhandlers[plugin + '_action_' + i] = entry.handler; + } + } + + if (!M.editor_atto.buttonhandlers[plugin]) { + Y.one('body').delegate('click', M.editor_atto.showhide_menu_handler, '.atto_' + plugin + '_button'); + M.editor_atto.buttonhandlers[plugin] = true; + } + + var overlay = new M.core.dialogue({ + bodyContent : menu, + visible : false, + width: '14em', + zindex: 100, + lightbox: false, + closeButton: false, + align: {node: button, points: [Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.BL]} + }); + + M.editor_atto.menus[plugin + '_' + elementid] = overlay; + overlay.render(); + overlay.hide(); + overlay.headerNode.hide(); + }, + + /** + * Add a button to the toolbar belonging to the editor for element with id "elementid". + * @param string elementid - the id of the textarea we created this editor from. + * @param string plugin - the plugin defining the button + * @param string icon - the html used for the content of the button + * @handler function handler- A function to call when the button is clicked. + */ + add_toolbar_button : function(elementid, plugin, icon, handler) { + var toolbar = Y.one('#' + elementid + '_toolbar'); + var button = Y.Node.create(''); + + toolbar.append(button); + + // We only need to attach this once. + if (!M.editor_atto.buttonhandlers[plugin]) { + Y.one('body').delegate('click', M.editor_atto.buttonclicked_handler, '.atto_' + plugin + '_button'); + M.editor_atto.buttonhandlers[plugin] = handler; + } + + // Save the name of the plugin. + M.editor_atto.widgets[plugin] = plugin; + + }, + + /** + * Work out if the cursor is in the editable area for this editor instance. + * @param string elementid of this editor + * @return bool + */ + is_active : function(elementid) { + var selection = M.editor_atto.get_selection(); + + if (selection.length) { + selection = selection.pop(); + } + + var node = null; + if (selection.parentElement) { + node = Y.one(selection.parentElement()); + } else { + node = Y.one(selection.startContainer); + } + + return node && node.ancestor('#' + elementid + 'editable') !== null; + }, + + /** + * Focus on the editable area for this editor. + * @param string elementid of this editor + */ + focus : function(elementid) { + Y.one('#' + elementid + 'editable').focus(); + }, + + /** + * Initialise the editor + * @param object params for this editor instance. + */ + init : function(params) { + var textarea = Y.one('#' +params.elementid); + var atto = Y.Node.create('
'); + var cssfont = ''; + var toolbar = Y.Node.create('
'); + + // Bleh - why are we sent a url and not the css to apply directly? + var css = Y.io(params.content_css, { sync: true }); + var pos = css.responseText.indexOf('font:'); + if (pos) { + cssfont = css.responseText.substring(pos + 'font:'.length, css.responseText.length - 1); + atto.setStyle('font', cssfont); + } + atto.setStyle('min-height', (1.2 * (textarea.getAttribute('rows') - 1)) + 'em'); + + // Copy text to editable div. + atto.append(textarea.get('value')); + + // Add the toolbar to the page. + textarea.get('parentNode').insert(toolbar, textarea); + // Add the editable div to the page. + textarea.get('parentNode').insert(atto, textarea); + // Hide the old textarea. + textarea.hide(); + + // Copy the current value back to the textarea when focus leaves us. + atto.on('blur', function() { + textarea.set('value', atto.getHTML()); + }); + + // Save the file picker options for later. + M.editor_atto.filepickeroptions[params.elementid] = params.filepickeroptions; + }, + + /** + * Show the filepicker. + * @param string elementid for this editor instance. + * @param string type The media type for the file picker + * @param function callback + */ + show_filepicker : function(elementid, type, callback) { + Y.use('core_filepicker', function (Y) { + var options = M.editor_atto.filepickeroptions[elementid][type]; + + options.formcallback = callback; + options.editor_target = Y.one(elementid); + + M.core_filepicker.show(Y, options); + }); + }, + + /** + * Create a cross browser selection object that represents a yui node. + * @param Node yui node for the selection + * @return range (browser dependent) + */ + get_selection_from_node: function(node) { + var range; + + if (window.getSelection) { + range = document.createRange(); + + range.setStartBefore(node.getDOMNode()); + range.setEndAfter(node.getDOMNode()); + return [range]; + } else if (document.selection) { + range = document.body.createTextRange(); + range.moveToElementText(node.getDOMNode()); + return range; + } + return false; + }, + + /** + * Get the selection object that can be passed back to set_selection. + * @return range (browser dependent) + */ + get_selection : function() { + if (window.getSelection) { + var sel = window.getSelection(); + var ranges = [], i = 0; + for (i = 0; i < sel.rangeCount; i++) { + ranges.push(sel.getRangeAt(i)); + } + return ranges; + } else if (document.selection) { + // IE < 9 + if (document.selection.createRange) { + return document.selection.createRange(); + } + } + return false; + }, + + /** + * Get the dom node representing the common anscestor of the selection nodes. + * @return DOMNode + */ + get_selection_parent_node : function() { + var selection = M.editor_atto.get_selection(); + if (selection.length > 0) { + return selection[0].commonAncestorContainer; + } + }, + + /** + * Get the list of child nodes of the selection. + * @return DOMNode[] + */ + get_selection_text : function() { + var selection = M.editor_atto.get_selection(); + if (selection.length > 0 && selection[0].cloneContents) { + return selection[0].cloneContents(); + } + }, + + /** + * Set the current selection. Used to restore a selection. + */ + set_selection : function(selection) { + var sel, i; + + if (window.getSelection) { + sel = window.getSelection(); + sel.removeAllRanges(); + for (i = 0; i < selection.length; i++) { + sel.addRange(selection[i]); + } + } else if (document.selection) { + // IE < 9 + if (selection.select) { + selection.select(); + } + } + } + +}; + + +}, '@VERSION@', {"requires": ["node", "io", "overlay", "escape", "moodle-core-notification"]}); diff --git a/lib/editor/atto/yui/src/editor/build.json b/lib/editor/atto/yui/src/editor/build.json new file mode 100644 index 00000000000..88718f4f4a1 --- /dev/null +++ b/lib/editor/atto/yui/src/editor/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-editor_atto-editor", + "builds": { + "moodle-editor_atto-editor": { + "jsfiles": [ + "editor.js" + ] + } + } +} diff --git a/lib/editor/atto/yui/src/editor/js/editor.js b/lib/editor/atto/yui/src/editor/js/editor.js new file mode 100644 index 00000000000..a2d967de141 --- /dev/null +++ b/lib/editor/atto/yui/src/editor/js/editor.js @@ -0,0 +1,407 @@ +// 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 editor main class. + * Common functions required by editor plugins. + * + * @package editor-atto + * @copyright 2013 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +M.editor_atto = M.editor_atto || { + /** + * List of attached button handlers to prevent duplicates. + */ + buttonhandlers : {}, + + /** + * List of YUI overlays for custom menus. + */ + menus : {}, + + /** + * List of attached menu handlers to prevent duplicates. + */ + menuhandlers : {}, + + /** + * List of file picker options for specific editor instances. + */ + filepickeroptions : {}, + + /** + * List of buttons and menus that have been added to the toolbar. + */ + widgets : {}, + + /** + * Toggle a menu. + * @param event e + */ + showhide_menu_handler : function(e) { + e.preventDefault(); + var disabled = this.getAttribute('disabled'); + var overlayid = this.getAttribute('data-menu'); + var overlay = M.editor_atto.menus[overlayid]; + + if (overlay.get('visible') || disabled) { + overlay.hide(); + } else { + overlay.show(); + } + + }, + + /** + * Handle clicks on editor buttons. + * @param event e + */ + buttonclicked_handler : function(e) { + var elementid = this.getAttribute('data-editor'); + var plugin = this.getAttribute('data-plugin'); + var handler = this.getAttribute('data-handler'); + var overlay = M.editor_atto.menus[plugin + '_' + elementid]; + + if (overlay) { + overlay.hide(); + } + + if (M.editor_atto.is_enabled(elementid, plugin)) { + // Pass it on. + handler = M.editor_atto.buttonhandlers[handler]; + return handler(e, elementid); + } + }, + + /** + * Determine if the specified toolbar button/menu is enabled. + * @param string elementid, the element id of this editor. + * @param string plugin, the plugin that created the button/menu. + */ + is_enabled : function(elementid, plugin) { + var element = Y.one('#' + elementid + '_toolbar .atto_' + plugin + '_button'); + + return !element.hasAttribute('disabled'); + }, + /** + * Disable all buttons and menus in the toolbar. + * @param string elementid, the element id of this editor. + */ + disable_all_widgets : function(elementid) { + var plugin, element; + for (plugin in M.editor_atto.widgets) { + element = Y.one('#' + elementid + '_toolbar .atto_' + plugin + '_button'); + + if (element) { + element.setAttribute('disabled', 'true'); + } + } + }, + + /** + * Enable a single widget in the toolbar. + * @param string elementid, the element id of this editor. + * @param string plugin, the name of the plugin that created the widget. + */ + enable_widget : function(elementid, plugin) { + var element = Y.one('#' + elementid + '_toolbar .atto_' + plugin + '_button'); + + if (element) { + element.removeAttribute('disabled'); + } + }, + + /** + * Enable all buttons and menus in the toolbar. + * @param string elementid, the element id of this editor. + */ + enable_all_widgets : function(elementid) { + var plugin, element; + for (plugin in M.editor_atto.widgets) { + element = Y.one('#' + elementid + '_toolbar .atto_' + plugin + '_button'); + + if (element) { + element.removeAttribute('disabled'); + } + } + }, + + /** + * Add a button to the toolbar belonging to the editor for element with id "elementid". + * @param string elementid - the id of the textarea we created this editor from. + * @param string plugin - the plugin defining the button + * @param string icon - the html used for the content of the button + * @handler function handler- A function to call when the button is clicked. + */ + add_toolbar_menu : function(elementid, plugin, icon, entries) { + var toolbar = Y.one('#' + elementid + '_toolbar'); + var button = Y.Node.create(''); + + toolbar.append(button); + + // Save the name of the plugin. + M.editor_atto.widgets[plugin] = plugin; + + var menu = Y.Node.create('
'); + + var i = 0, entry = {}; + + for (i = 0; i < entries.length; i++) { + entry = entries[i]; + + menu.append(Y.Node.create('')); + if (!M.editor_atto.buttonhandlers[plugin + '_action_' + i]) { + Y.one('body').delegate('click', M.editor_atto.buttonclicked_handler, '.atto_' + plugin + '_action_' + i); + M.editor_atto.buttonhandlers[plugin + '_action_' + i] = entry.handler; + } + } + + if (!M.editor_atto.buttonhandlers[plugin]) { + Y.one('body').delegate('click', M.editor_atto.showhide_menu_handler, '.atto_' + plugin + '_button'); + M.editor_atto.buttonhandlers[plugin] = true; + } + + var overlay = new M.core.dialogue({ + bodyContent : menu, + visible : false, + width: '14em', + zindex: 100, + lightbox: false, + closeButton: false, + align: {node: button, points: [Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.BL]} + }); + + M.editor_atto.menus[plugin + '_' + elementid] = overlay; + overlay.render(); + overlay.hide(); + overlay.headerNode.hide(); + }, + + /** + * Add a button to the toolbar belonging to the editor for element with id "elementid". + * @param string elementid - the id of the textarea we created this editor from. + * @param string plugin - the plugin defining the button + * @param string icon - the html used for the content of the button + * @handler function handler- A function to call when the button is clicked. + */ + add_toolbar_button : function(elementid, plugin, icon, handler) { + var toolbar = Y.one('#' + elementid + '_toolbar'); + var button = Y.Node.create(''); + + toolbar.append(button); + + // We only need to attach this once. + if (!M.editor_atto.buttonhandlers[plugin]) { + Y.one('body').delegate('click', M.editor_atto.buttonclicked_handler, '.atto_' + plugin + '_button'); + M.editor_atto.buttonhandlers[plugin] = handler; + } + + // Save the name of the plugin. + M.editor_atto.widgets[plugin] = plugin; + + }, + + /** + * Work out if the cursor is in the editable area for this editor instance. + * @param string elementid of this editor + * @return bool + */ + is_active : function(elementid) { + var selection = M.editor_atto.get_selection(); + + if (selection.length) { + selection = selection.pop(); + } + + var node = null; + if (selection.parentElement) { + node = Y.one(selection.parentElement()); + } else { + node = Y.one(selection.startContainer); + } + + return node && node.ancestor('#' + elementid + 'editable') !== null; + }, + + /** + * Focus on the editable area for this editor. + * @param string elementid of this editor + */ + focus : function(elementid) { + Y.one('#' + elementid + 'editable').focus(); + }, + + /** + * Initialise the editor + * @param object params for this editor instance. + */ + init : function(params) { + var textarea = Y.one('#' +params.elementid); + var atto = Y.Node.create('
'); + var cssfont = ''; + var toolbar = Y.Node.create('
'); + + // Bleh - why are we sent a url and not the css to apply directly? + var css = Y.io(params.content_css, { sync: true }); + var pos = css.responseText.indexOf('font:'); + if (pos) { + cssfont = css.responseText.substring(pos + 'font:'.length, css.responseText.length - 1); + atto.setStyle('font', cssfont); + } + atto.setStyle('min-height', (1.2 * (textarea.getAttribute('rows') - 1)) + 'em'); + + // Copy text to editable div. + atto.append(textarea.get('value')); + + // Add the toolbar to the page. + textarea.get('parentNode').insert(toolbar, textarea); + // Add the editable div to the page. + textarea.get('parentNode').insert(atto, textarea); + // Hide the old textarea. + textarea.hide(); + + // Copy the current value back to the textarea when focus leaves us. + atto.on('blur', function() { + textarea.set('value', atto.getHTML()); + }); + + // Save the file picker options for later. + M.editor_atto.filepickeroptions[params.elementid] = params.filepickeroptions; + }, + + /** + * Show the filepicker. + * @param string elementid for this editor instance. + * @param string type The media type for the file picker + * @param function callback + */ + show_filepicker : function(elementid, type, callback) { + Y.use('core_filepicker', function (Y) { + var options = M.editor_atto.filepickeroptions[elementid][type]; + + options.formcallback = callback; + options.editor_target = Y.one(elementid); + + M.core_filepicker.show(Y, options); + }); + }, + + /** + * Create a cross browser selection object that represents a yui node. + * @param Node yui node for the selection + * @return range (browser dependent) + */ + get_selection_from_node: function(node) { + var range; + + if (window.getSelection) { + range = document.createRange(); + + range.setStartBefore(node.getDOMNode()); + range.setEndAfter(node.getDOMNode()); + return [range]; + } else if (document.selection) { + range = document.body.createTextRange(); + range.moveToElementText(node.getDOMNode()); + return range; + } + return false; + }, + + /** + * Get the selection object that can be passed back to set_selection. + * @return range (browser dependent) + */ + get_selection : function() { + if (window.getSelection) { + var sel = window.getSelection(); + var ranges = [], i = 0; + for (i = 0; i < sel.rangeCount; i++) { + ranges.push(sel.getRangeAt(i)); + } + return ranges; + } else if (document.selection) { + // IE < 9 + if (document.selection.createRange) { + return document.selection.createRange(); + } + } + return false; + }, + + /** + * Get the dom node representing the common anscestor of the selection nodes. + * @return DOMNode + */ + get_selection_parent_node : function() { + var selection = M.editor_atto.get_selection(); + if (selection.length > 0) { + return selection[0].commonAncestorContainer; + } + }, + + /** + * Get the list of child nodes of the selection. + * @return DOMNode[] + */ + get_selection_text : function() { + var selection = M.editor_atto.get_selection(); + if (selection.length > 0 && selection[0].cloneContents) { + return selection[0].cloneContents(); + } + }, + + /** + * Set the current selection. Used to restore a selection. + */ + set_selection : function(selection) { + var sel, i; + + if (window.getSelection) { + sel = window.getSelection(); + sel.removeAllRanges(); + for (i = 0; i < selection.length; i++) { + sel.addRange(selection[i]); + } + } else if (document.selection) { + // IE < 9 + if (selection.select) { + selection.select(); + } + } + } + +}; diff --git a/lib/editor/atto/yui/src/editor/meta/editor.json b/lib/editor/atto/yui/src/editor/meta/editor.json new file mode 100644 index 00000000000..9e6959c169e --- /dev/null +++ b/lib/editor/atto/yui/src/editor/meta/editor.json @@ -0,0 +1,11 @@ +{ + "moodle-editor_atto-editor": { + "requires": [ + "node", + "io", + "overlay", + "escape", + "moodle-core-notification" + ] + } +} diff --git a/lib/editorlib.php b/lib/editorlib.php index 8080d804d42..15f667b278b 100644 --- a/lib/editorlib.php +++ b/lib/editorlib.php @@ -114,7 +114,7 @@ function editors_get_enabled() { global $CFG; if (empty($CFG->texteditors)) { - $CFG->texteditors = 'tinymce,textarea'; + $CFG->texteditors = 'tinymce,atto,textarea'; } $active = array(); foreach(explode(',', $CFG->texteditors) as $e) { diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 6e83947f1a7..b3199582109 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -666,6 +666,12 @@ class plugin_manager { 'comments', 'file', 'offline' ), + 'atto' => array( + 'bold', 'clear', 'html', 'image', 'indent', 'italic', 'link', + 'media', 'orderedlist', 'outdent', 'strike', 'title', + 'underline', 'unlink', 'unorderedlist' + ), + 'auth' => array( 'cas', 'db', 'email', 'fc', 'imap', 'ldap', 'manual', 'mnet', 'nntp', 'nologin', 'none', 'pam', 'pop3', 'radius', @@ -712,7 +718,7 @@ class plugin_manager { ), 'editor' => array( - 'textarea', 'tinymce' + 'textarea', 'tinymce', 'atto' ), 'enrol' => array(