MDL-41237 Atto - Adjusting the text styles for the editor

This commit is contained in:
Jason Fowler 2013-08-30 14:50:51 +08:00 committed by Damyon Wiese
parent 3b46f8dfe1
commit 2b6361305d
7 changed files with 103 additions and 90 deletions

View File

@ -24,7 +24,9 @@
$string['pluginname'] = 'Paragraph styles';
$string['title'] = 'Paragraph styles';
$string['h1'] = 'Title';
$string['h2'] = 'Heading';
$string['h3'] = 'Heading 1';
$string['h4'] = 'Heading 2';
$string['h5'] = 'Heading 3';
$string['blockquote'] = 'Quoted';
$string['p'] = 'Plain';
$string['pre'] = 'Pre-formatted';

View File

@ -36,9 +36,11 @@ function atto_title_init_editor($elementid) {
'atto_title',
array('class'=>'icon'));
$PAGE->requires->strings_for_js(array('h1',
'h2',
$PAGE->requires->strings_for_js(array('h3',
'h4',
'h5',
'blockquote',
'pre',
'p'), 'atto_title');
$PAGE->requires->yui_module('moodle-atto_title-button',
'M.atto_title.init',

View File

@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2013080900; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2013083000; // 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).

View File

@ -24,51 +24,54 @@ YUI.add('moodle-atto_title-button', function (Y, NAME) {
*/
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, '<h1>');
var click_h3 = function(e, elementid) {
M.atto_title.change_title(e, elementid, '<h3>');
};
var click_h2 = function(e, elementid) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
document.execCommand('formatBlock', false, '<h2>');
var click_h4 = function(e, elementid) {
M.atto_title.change_title(e, elementid, '<h4>');
};
var click_h5 = function(e, elementid) {
M.atto_title.change_title(e, elementid, '<h5>');
};
var click_pre = function(e, elementid) {
M.atto_title.change_title(e, elementid, '<pre>');
};
var click_blockquote = function(e, elementid) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
document.execCommand('formatBlock', false, '<blockquote>');
M.atto_title.change_title(e, elementid, '<blockquote>');
};
var click_p = function(e, elementid) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
document.execCommand('formatBlock', false, '<p>');
M.atto_title.change_title(e, elementid, '<p>');
};
var h1 = '<h1>' + M.util.get_string('h1', 'atto_title') + '</h1>';
var h2 = '<h2>' + M.util.get_string('h2', 'atto_title') + '</h2>';
var blockquote = '<p>&nbsp;&nbsp;&nbsp;&nbsp;' + M.util.get_string('blockquote', 'atto_title') + '</p>';
var p = '<p>' + M.util.get_string('p', 'atto_title') + '</p>';
var h3 = '<h3>' + M.util.get_string('h3', 'atto_title') + '</h3>';
var h4 = '<h4>' + M.util.get_string('h4', 'atto_title') + '</h4>';
var h5 = '<h5>' + M.util.get_string('h5', 'atto_title') + '</h5>';
var pre = '<pre>' + M.util.get_string('pre', 'atto_title') + '</pre>';
var blockquote = '<p>&nbsp;&nbsp;&nbsp;&nbsp;' + M.util.get_string('blockquote', 'atto_title') + '</p>';
var p = '<p>' + M.util.get_string('p', 'atto_title') + '</p>';
M.editor_atto.add_toolbar_menu(params.elementid,
'title',
params.icon,
[
{'text' : h1, 'handler' : click_h1},
{'text' : h2, 'handler' : click_h2},
{'text' : h3, 'handler' : click_h3},
{'text' : h4, 'handler' : click_h4},
{'text' : h5, 'handler' : click_h5},
{'text' : pre, 'handler' : click_pre},
{'text' : blockquote, 'handler' : click_blockquote},
{'text' : p, 'handler' : click_p}
]);
},
change_title : function(e, elementid, node) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
document.execCommand('formatBlock', false, node);
}
};
}, '@VERSION@', {"requires": ["node"]});

View File

@ -1 +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,"<h1>")},n=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("formatBlock",!1,"<h2>")},r=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("formatBlock",!1,"<blockquote>")},i=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("formatBlock",!1,"<p>")},s="<h1>"+M.util.get_string("h1","atto_title")+"</h1>",o="<h2>"+M.util.get_string("h2","atto_title")+"</h2>",u="<p>&nbsp;&nbsp;&nbsp;&nbsp;"+M.util.get_string("blockquote","atto_title")+"</p>",a="<p>"+M.util.get_string("p","atto_title")+"</p>";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"]});
YUI.add("moodle-atto_title-button",function(e,t){M.atto_title=M.atto_title||{init:function(e){var t=function(e,t){M.atto_title.change_title(e,t,"<h3>")},n=function(e,t){M.atto_title.change_title(e,t,"<h4>")},r=function(e,t){M.atto_title.change_title(e,t,"<h5>")},i=function(e,t){M.atto_title.change_title(e,t,"<pre>")},s=function(e,t){M.atto_title.change_title(e,t,"<blockquote>")},o=function(e,t){M.atto_title.change_title(e,t,"<p>")},u="<h3>"+M.util.get_string("h3","atto_title")+"</h3>",a="<h4>"+M.util.get_string("h4","atto_title")+"</h4>",f="<h5>"+M.util.get_string("h5","atto_title")+"</h5>",l="<pre>"+M.util.get_string("pre","atto_title")+"</pre>",c="<p>&nbsp;&nbsp;&nbsp;&nbsp;"+M.util.get_string("blockquote","atto_title")+"</p>",h="<p>"+M.util.get_string("p","atto_title")+"</p>";M.editor_atto.add_toolbar_menu(e.elementid,"title",e.icon,[{text:u,handler:t},{text:a,handler:n},{text:f,handler:r},{text:l,handler:i},{text:c,handler:s},{text:h,handler:o}])},change_title:function(e,t,n){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("formatBlock",!1,n)}}},"@VERSION@",{requires:["node"]});

View File

@ -24,51 +24,54 @@ YUI.add('moodle-atto_title-button', function (Y, NAME) {
*/
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, '<h1>');
var click_h3 = function(e, elementid) {
M.atto_title.change_title(e, elementid, '<h3>');
};
var click_h2 = function(e, elementid) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
document.execCommand('formatBlock', false, '<h2>');
var click_h4 = function(e, elementid) {
M.atto_title.change_title(e, elementid, '<h4>');
};
var click_h5 = function(e, elementid) {
M.atto_title.change_title(e, elementid, '<h5>');
};
var click_pre = function(e, elementid) {
M.atto_title.change_title(e, elementid, '<pre>');
};
var click_blockquote = function(e, elementid) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
document.execCommand('formatBlock', false, '<blockquote>');
M.atto_title.change_title(e, elementid, '<blockquote>');
};
var click_p = function(e, elementid) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
document.execCommand('formatBlock', false, '<p>');
M.atto_title.change_title(e, elementid, '<p>');
};
var h1 = '<h1>' + M.util.get_string('h1', 'atto_title') + '</h1>';
var h2 = '<h2>' + M.util.get_string('h2', 'atto_title') + '</h2>';
var blockquote = '<p>&nbsp;&nbsp;&nbsp;&nbsp;' + M.util.get_string('blockquote', 'atto_title') + '</p>';
var p = '<p>' + M.util.get_string('p', 'atto_title') + '</p>';
var h3 = '<h3>' + M.util.get_string('h3', 'atto_title') + '</h3>';
var h4 = '<h4>' + M.util.get_string('h4', 'atto_title') + '</h4>';
var h5 = '<h5>' + M.util.get_string('h5', 'atto_title') + '</h5>';
var pre = '<pre>' + M.util.get_string('pre', 'atto_title') + '</pre>';
var blockquote = '<p>&nbsp;&nbsp;&nbsp;&nbsp;' + M.util.get_string('blockquote', 'atto_title') + '</p>';
var p = '<p>' + M.util.get_string('p', 'atto_title') + '</p>';
M.editor_atto.add_toolbar_menu(params.elementid,
'title',
params.icon,
[
{'text' : h1, 'handler' : click_h1},
{'text' : h2, 'handler' : click_h2},
{'text' : h3, 'handler' : click_h3},
{'text' : h4, 'handler' : click_h4},
{'text' : h5, 'handler' : click_h5},
{'text' : pre, 'handler' : click_pre},
{'text' : blockquote, 'handler' : click_blockquote},
{'text' : p, 'handler' : click_p}
]);
},
change_title : function(e, elementid, node) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
document.execCommand('formatBlock', false, node);
}
};
}, '@VERSION@', {"requires": ["node"]});

View File

@ -22,48 +22,51 @@
*/
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, '<h1>');
var click_h3 = function(e, elementid) {
M.atto_title.change_title(e, elementid, '<h3>');
};
var click_h2 = function(e, elementid) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
document.execCommand('formatBlock', false, '<h2>');
var click_h4 = function(e, elementid) {
M.atto_title.change_title(e, elementid, '<h4>');
};
var click_h5 = function(e, elementid) {
M.atto_title.change_title(e, elementid, '<h5>');
};
var click_pre = function(e, elementid) {
M.atto_title.change_title(e, elementid, '<pre>');
};
var click_blockquote = function(e, elementid) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
document.execCommand('formatBlock', false, '<blockquote>');
M.atto_title.change_title(e, elementid, '<blockquote>');
};
var click_p = function(e, elementid) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
document.execCommand('formatBlock', false, '<p>');
M.atto_title.change_title(e, elementid, '<p>');
};
var h1 = '<h1>' + M.util.get_string('h1', 'atto_title') + '</h1>';
var h2 = '<h2>' + M.util.get_string('h2', 'atto_title') + '</h2>';
var blockquote = '<p>&nbsp;&nbsp;&nbsp;&nbsp;' + M.util.get_string('blockquote', 'atto_title') + '</p>';
var p = '<p>' + M.util.get_string('p', 'atto_title') + '</p>';
var h3 = '<h3>' + M.util.get_string('h3', 'atto_title') + '</h3>';
var h4 = '<h4>' + M.util.get_string('h4', 'atto_title') + '</h4>';
var h5 = '<h5>' + M.util.get_string('h5', 'atto_title') + '</h5>';
var pre = '<pre>' + M.util.get_string('pre', 'atto_title') + '</pre>';
var blockquote = '<p>&nbsp;&nbsp;&nbsp;&nbsp;' + M.util.get_string('blockquote', 'atto_title') + '</p>';
var p = '<p>' + M.util.get_string('p', 'atto_title') + '</p>';
M.editor_atto.add_toolbar_menu(params.elementid,
'title',
params.icon,
[
{'text' : h1, 'handler' : click_h1},
{'text' : h2, 'handler' : click_h2},
{'text' : h3, 'handler' : click_h3},
{'text' : h4, 'handler' : click_h4},
{'text' : h5, 'handler' : click_h5},
{'text' : pre, 'handler' : click_pre},
{'text' : blockquote, 'handler' : click_blockquote},
{'text' : p, 'handler' : click_p}
]);
},
change_title : function(e, elementid, node) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
document.execCommand('formatBlock', false, node);
}
};