mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 02:46:40 +02:00
MDL-23646 tinymce: Add plugin to wrap toolbar on small screens
This commit is contained in:
parent
3b62cd64d7
commit
05e9c136e6
11 changed files with 261 additions and 8 deletions
28
lib/editor/tinymce/plugins/wrap/lang/en/tinymce_wrap.php
Normal file
28
lib/editor/tinymce/plugins/wrap/lang/en/tinymce_wrap.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for 'wrap' plugin.
|
||||
*
|
||||
* @package tinymce_wrap
|
||||
* @copyright 2013 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['pluginname'] = 'Wrap';
|
||||
|
||||
/* All lang strings used from TinyMCE JavaScript code must be named 'pluginname:stringname', no need to create langs/en_dlg.js */
|
||||
$string['moodlewrap:desc'] = 'Wrap';
|
36
lib/editor/tinymce/plugins/wrap/lib.php
Normal file
36
lib/editor/tinymce/plugins/wrap/lib.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Plugin for Moodle 'wrap' button.
|
||||
*
|
||||
* @package tinymce_wrap
|
||||
* @copyright 2013 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tinymce_wrap extends editor_tinymce_plugin {
|
||||
/** @var array list of buttons defined by this plugin */
|
||||
protected $buttons = array('wrap');
|
||||
|
||||
protected function update_init_params(array &$params, context $context,
|
||||
array $options = null) {
|
||||
|
||||
// Add JS file, which uses default name.
|
||||
$this->add_js_plugin($params);
|
||||
}
|
||||
}
|
BIN
lib/editor/tinymce/plugins/wrap/pix/icon.png
Normal file
BIN
lib/editor/tinymce/plugins/wrap/pix/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 314 B |
88
lib/editor/tinymce/plugins/wrap/tinymce/editor_plugin.js
Normal file
88
lib/editor/tinymce/plugins/wrap/tinymce/editor_plugin.js
Normal file
|
@ -0,0 +1,88 @@
|
|||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Plugin for Moodle 'wrap' button.
|
||||
*
|
||||
* @package tinymce_wrap
|
||||
* @copyright 2013 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
(function() {
|
||||
tinymce.create('tinymce.ui.Wrap:tinymce.ui.Control', {
|
||||
/**
|
||||
* Constructor for the tinymce.Wrap class.
|
||||
*/
|
||||
Wrap : function(id, s) {
|
||||
this.parent(id, s);
|
||||
this.groupEndClass = 'mceToolbarEnd';
|
||||
this.groupStartClass = 'mceToolbarStart';
|
||||
this.wrapClass = 'mceWrap';
|
||||
this.setDisabled(true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the HTML for this control. This control actually ends the current td
|
||||
* container and opens a new one so that the containers can be styled with CSS
|
||||
* to wrap at certain screen widths.
|
||||
* @return string HTML
|
||||
*/
|
||||
renderHTML : function() {
|
||||
var separator = tinymce.DOM.createHTML('span', {role : 'separator',
|
||||
'aria-orientation' : 'vertical',
|
||||
tabindex : '-1'});
|
||||
return '</td>' +
|
||||
'<td style="position: relative" class="' + this.groupEndClass + '">' + separator + '</td>' +
|
||||
'<td style="position: relative" class="' + this.groupStartClass + ' ' + this.wrapClass + '">' + separator + '</td>';
|
||||
},
|
||||
|
||||
|
||||
});
|
||||
|
||||
tinymce.create('tinymce.plugins.wrapPlugin', {
|
||||
/**
|
||||
* Returns a new instance of this control, in this case a custom Wrap class.
|
||||
*
|
||||
* @param string name - The name of the control to create. Return false if we can't create this control type.
|
||||
* @param tinymce.ControlManager cc - Tinymce control manager class.
|
||||
* @return mixed - false or the new control
|
||||
*/
|
||||
createControl : function(name, cc) {
|
||||
if (name === "wrap" || name === "!") {
|
||||
return new tinymce.ui.Wrap();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns information about the plugin as a name/value array.
|
||||
* The current keys are longname, author, authorurl, infourl and version.
|
||||
*
|
||||
* @return {Object} Name/value array containing information about the plugin.
|
||||
*/
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'wrap plugin',
|
||||
author : 'Damyon Wiese',
|
||||
authorurl : 'http://moodle.com/hq',
|
||||
infourl : 'http://docs.moodle.org/en/TinyMCE',
|
||||
version : "1.0"
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin.
|
||||
tinymce.PluginManager.add('wrap', tinymce.plugins.wrapPlugin);
|
||||
})();
|
BIN
lib/editor/tinymce/plugins/wrap/tinymce/img/ed_wrap.gif
Normal file
BIN
lib/editor/tinymce/plugins/wrap/tinymce/img/ed_wrap.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 180 B |
32
lib/editor/tinymce/plugins/wrap/version.php
Normal file
32
lib/editor/tinymce/plugins/wrap/version.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* TinyMCE toolbar wrapping break
|
||||
*
|
||||
* @package tinymce_wrap
|
||||
* @copyright 2013 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
// The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2013061900;
|
||||
// Required Moodle version.
|
||||
$plugin->requires = 2013050100;
|
||||
// Full name of the plugin (used for diagnostics).
|
||||
$plugin->component = 'tinymce_wrap';
|
Loading…
Add table
Add a link
Reference in a new issue