Merge branch 'MDL-23646-master' of git://github.com/damyon/moodle

This commit is contained in:
Marina Glancy 2013-07-09 15:55:51 +10:00
commit 8bed37619e
14 changed files with 278 additions and 16 deletions

View file

@ -69,5 +69,58 @@ fontselect,fontsizeselect,code,search,replace,|,cleanup,removeformat,pastetext,p
upgrade_plugin_savepoint(true, 2013061400, 'editor', 'tinymce');
}
if ($oldversion < 2013070500) {
// Insert wrap plugin to nicely wrap the toolbars on small screens.
$oldorder = "formatselect,bold,italic,|,bullist,numlist,|,link,unlink,|,image
undo,redo,|,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,|,outdent,indent,|,forecolor,backcolor,|,ltr,rtl,|,nonbreaking,charmap,table
fontselect,fontsizeselect,code,search,replace,|,cleanup,removeformat,pastetext,pasteword,|,fullscreen";
$neworder = "formatselect,bold,italic,wrap,bullist,numlist,|,link,unlink,|,image
undo,redo,|,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,wrap,outdent,indent,|,forecolor,backcolor,|,ltr,rtl,|,nonbreaking,charmap,table
fontselect,fontsizeselect,wrap,code,search,replace,|,cleanup,removeformat,pastetext,pasteword,|,fullscreen";
$currentorder = get_config('editor_tinymce', 'customtoolbar');
if ($currentorder == $oldorder) {
unset_config('customtoolbar', 'editor_tinymce');
set_config('customtoolbar', $neworder, 'editor_tinymce');
} else {
// Simple auto conversion algorithm.
$toolbars = explode("\n", $oldorder);
$newtoolbars = array();
foreach ($toolbars as $toolbar) {
$sepcount = substr_count($toolbar, '|');
if ($sepcount > 0) {
// We assume the middle separator (rounding down).
$divisionindex = round($sepcount / 2, 0, PHP_ROUND_HALF_DOWN);
$buttons = explode(',', $toolbar);
$index = 0;
foreach ($buttons as $key => $button) {
if ($button === "|") {
if ($index == $divisionindex) {
$buttons[$key] = 'wrap';
break;
} else {
$index += 1;
}
}
}
$toolbar = implode(',', $buttons);
}
array_push($newtoolbars, $toolbar);
}
$neworder = implode("\n", $newtoolbars);
// Set the new config.
unset_config('customtoolbar', 'editor_tinymce');
set_config('customtoolbar', $neworder, 'editor_tinymce');
}
upgrade_plugin_savepoint(true, 2013070500, 'editor', 'tinymce');
}
return true;
}

View file

@ -52,6 +52,9 @@ class tinymce_texteditor extends texteditor {
if (check_browser_version('Safari iOS', 534)) {
return true;
}
if (check_browser_version('WebKit', 534)) {
return true;
}
return false;
}

View file

@ -11,3 +11,5 @@ Upgrade procedure:
1/ extract standard PDW package into lib/editor/tinymce/plugins/pdw/tinymce/
2/ bump up version.php
3/ update lib/thirdpartylibs.xml
4/ reimplement patch in MDL-23646
5/ reminify the js manually (I used uglifyjs)

View file

@ -22,7 +22,4 @@
* THE SOFTWARE.
* Based on TinyMCE Wordpress plugin (Kitchen Sink)
*/
(function(){var d=tinymce.DOM;tinymce.PluginManager.requireLangPack("pdw");tinymce.create("tinymce.plugins.pdw",{init:function(a,h){var e=this,i=[],j=[],c;j=a.settings.pdw_toggle_toolbars.split(",");for(c=0;c<j.length;c++)i[c]=a.getParam("","toolbar"+j[c].replace(" ",""));a.addCommand("mcePDWToggleToolbars",function(){var f=a.controlManager,b,g,l=tinymce.util.Cookie,k,m=l.getHash("TinyMCE_toggle")||{};for(g=0;g<i.length;g++){obj=a.controlManager.get(i[g]);if(typeof obj!="undefined"){b=obj.id;if(d.isHidden(b)){k=
0;d.show(b);e._resizeIframe(a,i[g],-26)}else{k=1;d.hide(b);e._resizeIframe(a,i[g],26)}}}f.setActive("pdw_toggle",k);a.settings.pdw_toggle_on=k;m[a.id]=k;l.setHash("TinyMCE_toggle",m)});a.addButton("pdw_toggle",{title:a.getLang("pdw.desc",0),cmd:"mcePDWToggleToolbars",image:h+"/img/toolbars.gif"});a.onPostRender.add(function(){var f=tinymce.util.Cookie.getHash("TinyMCE_toggle")||{},b=false;if(f[a.id]==null)b=a.settings.pdw_toggle_on==1?true:false;else if(f[a.id]==1)b=true;if(b){f=a.controlManager;
for(c=0;c<j.length;c++){tbId=a.getParam("","toolbar"+j[c].replace(" ",""));b=a.controlManager.get(tbId).id;f.setActive("pdw_toggle",1);d.hide(b);e._resizeIframe(a,tbId,26)}}})},_resizeIframe:function(a,h,e){h=a.getContentAreaContainer().firstChild;d.setStyle(h,"height",d.getSize(h).h+e);a.theme.deltaHeight+=e},getInfo:function(){return{longname:"PDW Toggle Toolbars",author:"Guido Neele",authorurl:"http://www.neele.name/",infourl:"http://www.neele.name/pdw_toggle_toolbars",version:"1.2"}}});tinymce.PluginManager.add("pdw",
tinymce.plugins.pdw)})();
!function(){var DOM=tinymce.DOM;tinymce.PluginManager.requireLangPack("pdw");tinymce.create("tinymce.plugins.pdw",{init:function(ed,url){var t=this,tbIds=new Array,toolbars=new Array,i;toolbars=ed.settings.pdw_toggle_toolbars.split(",");for(i=0;i<toolbars.length;i++){tbIds[i]=ed.getParam("","toolbar"+toolbars[i].replace(" ",""))}ed.addCommand("mcePDWToggleToolbars",function(){var cm=ed.controlManager,id,j,Cookie=tinymce.util.Cookie,Toggle_PDW,Toggle=Cookie.getHash("TinyMCE_toggle")||new Object;for(j=0;j<tbIds.length;j++){obj=ed.controlManager.get(tbIds[j]);if(typeof obj=="undefined"){continue}id=obj.id;if(DOM.isHidden(id)){Toggle_PDW=0;var e=document.getElementById(id);if(e){e.style.display="table";t._resizeIframe(ed,tbIds[j],-26)}}else{Toggle_PDW=1;var e=document.getElementById(id);if(e){e.style.display="none"}t._resizeIframe(ed,tbIds[j],26)}}cm.setActive("pdw_toggle",Toggle_PDW);ed.settings.pdw_toggle_on=Toggle_PDW;Toggle[ed.id]=Toggle_PDW;Cookie.setHash("TinyMCE_toggle",Toggle)});ed.addButton("pdw_toggle",{title:ed.getLang("pdw.desc",0),cmd:"mcePDWToggleToolbars",image:url+"/img/toolbars.gif"});ed.onPostRender.add(function(){var toggle=tinymce.util.Cookie.getHash("TinyMCE_toggle")||new Object;var run=false;if(toggle[ed.id]==null){run=ed.settings.pdw_toggle_on==1?true:false}else if(toggle[ed.id]==1){run=true}if(run){var cm=ed.controlManager,tdId,id;for(i=0;i<toolbars.length;i++){tbId=ed.getParam("","toolbar"+toolbars[i].replace(" ",""));id=ed.controlManager.get(tbId).id;cm.setActive("pdw_toggle",1);DOM.hide(id);t._resizeIframe(ed,tbId,26)}}})},_resizeIframe:function(ed,tb_id,dy){var ifr=ed.getContentAreaContainer().firstChild;DOM.setStyle(ifr,"height",DOM.getSize(ifr).h+dy);ed.theme.deltaHeight+=dy},getInfo:function(){return{longname:"PDW Toggle Toolbars",author:"Guido Neele",authorurl:"http://www.neele.name/",infourl:"http://www.neele.name/pdw_toggle_toolbars",version:"1.2"}}});tinymce.PluginManager.add("pdw",tinymce.plugins.pdw)}();

View file

@ -97,12 +97,18 @@
if (DOM.isHidden(id)) {
Toggle_PDW = 0;
DOM.show(id);
t._resizeIframe(ed, tbIds[j], -26);
var e = document.getElementById(id);
if (e) {
e.style.display = 'table';
t._resizeIframe(ed, tbIds[j], -26);
}
} else {
Toggle_PDW = 1;
DOM.hide(id);
var e = document.getElementById(id);
if (e) {
e.style.display = 'none';
}
t._resizeIframe(ed, tbIds[j], 26);
}
}
@ -173,4 +179,4 @@
// Register plugin
tinymce.PluginManager.add('pdw', tinymce.plugins.pdw);
})();
})();

View file

@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
// The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2013061400;
$plugin->version = 2013070500;
// Required Moodle version.
$plugin->requires = 2013050100;
// Full name of the plugin (used for diagnostics).

View 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';

View 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);
}
}

View 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") {
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);
})();

View 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';

View file

@ -31,11 +31,11 @@ if ($ADMIN->fulltree) {
require_once(__DIR__.'/adminlib.php');
$settings->add(new tiynce_subplugins_settings());
$settings->add(new admin_setting_heading('tinymcegeneralheader', new lang_string('settings'), ''));
$default = "formatselect,bold,italic,|,bullist,numlist,|,link,unlink,|,image
$default = "formatselect,bold,italic,wrap,bullist,numlist,|,link,unlink,|,image
undo,redo,|,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,|,outdent,indent,|,forecolor,backcolor,|,ltr,rtl,|,nonbreaking,charmap,table
undo,redo,|,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,wrap,outdent,indent,|,forecolor,backcolor,|,ltr,rtl,|,nonbreaking,charmap,table
fontselect,fontsizeselect,code,search,replace,|,cleanup,removeformat,pastetext,pasteword,|,fullscreen";
fontselect,fontsizeselect,wrap,code,search,replace,|,cleanup,removeformat,pastetext,pasteword,|,fullscreen";
$settings->add(new admin_setting_configtextarea('editor_tinymce/customtoolbar',
get_string('customtoolbar', 'editor_tinymce'), get_string('customtoolbar_desc', 'editor_tinymce', 'http://www.tinymce.com/wiki.php/Buttons/controls'), $default, PARAM_RAW, 100, 8));
$settings->add(new admin_setting_configtextarea('editor_tinymce/fontselectlist',

View file

@ -13,7 +13,22 @@
color: red;
cursor: pointer;
}
.mform .felement.feditor .mceStatusbar,
.mform .felement.feditor iframe {
min-width: 35em;
@media (max-width: 480px) {
.mceToolbar td {
float: left;
display: inline-block;
}
.mceToolbar .mceWrap {
clear: left;
}
.o2k7Skin tr.mceLast .mceToolbar tr td.mceWrap,
.o2k7Skin tr.mceFirst .mceToolbar tr td.mceWrap {
margin-left: -3px;
}
.dir-rtl .o2k7Skin tr.mceLast .mceToolbar tr td.mceWrap,
.dir-rtl .o2k7Skin tr.mceFirst .mceToolbar tr td.mceWrap {
margin-left: 0px;
}
}

View file

@ -5,6 +5,8 @@ information provided here is intended especially for developers.
=== 2.6 ===
* added a new plugin to toggle the 2nd and 3rd toolbars
* added a new plugin to wrap the toolbars on small screens.
This plugin will be automatically added to existing toolbars by replacing the middle occurrence of | with "wrap".
=== 2.5 ===

View file

@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2013061400; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2013070500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2013050100; // Requires this Moodle version
$plugin->component = 'editor_tinymce'; // Full name of the plugin (used for diagnostics)
$plugin->release = '3.5.8'; // This is NOT a directory name, see lib.php if you need to know where is the editor code!