Skip to content

Commit

Permalink
MDL-41237 Atto - Adjusting the text styles for the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnfwlr authored and Damyon Wiese committed Sep 10, 2013
1 parent 3b46f8d commit 2b63613
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 90 deletions.
6 changes: 4 additions & 2 deletions lib/editor/atto/plugins/title/lang/en/atto_title.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
6 changes: 4 additions & 2 deletions lib/editor/atto/plugins/title/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion lib/editor/atto/plugins/title/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Original file line number Diff line number Diff line change
Expand Up @@ -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"]});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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"]});
59 changes: 31 additions & 28 deletions lib/editor/atto/plugins/title/yui/src/button/js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

0 comments on commit 2b63613

Please sign in to comment.