Merge branch 'MDL-73383-master' of https://github.com/rezaies/moodle

This commit is contained in:
Jun Pataleta 2022-03-18 12:00:23 +08:00
commit cd2225a71b
6 changed files with 18 additions and 11 deletions

View file

@ -23,9 +23,10 @@
*/
$string['pluginname'] = 'Show/hide advanced buttons';
$string['showmore'] = 'Show more buttons';
$string['showfewer'] = 'Show fewer buttons';
$string['privacy:metadata'] = 'The atto_collapse plugin does not store any personal data.';
$string['settings'] = 'Collapse toolbar settings';
$string['showfewer'] = 'Show fewer buttons';
$string['showgroups'] = 'Show first (n) groups when collapsed.';
$string['showgroups_desc'] = 'When the toolbar is collapsed (it is by default) only this many groups will be displayed at once.';
$string['privacy:metadata'] = 'The atto_collapse plugin does not store any personal data.';
$string['showmore'] = 'Show more buttons';
$string['youareonsecondrow'] = 'You are now on another row of the editor\'s toolbar, where there are more buttons.';

View file

@ -30,7 +30,7 @@ defined('MOODLE_INTERNAL') || die();
function atto_collapse_strings_for_js() {
global $PAGE;
$PAGE->requires->strings_for_js(array('showmore', 'showfewer'), 'atto_collapse');
$PAGE->requires->strings_for_js(array('showmore', 'showfewer', 'youareonsecondrow'), 'atto_collapse');
}
/**

View file

@ -65,8 +65,10 @@ Y.namespace('M.atto_collapse').Button = Y.Base.create('button', Y.M.editor_atto.
this.get('host').on('pluginsloaded', function(e, button) {
// Add 2 rows in the toolbar.
var toolbarRows = [
Y.Node.create('<div class="atto_toolbar_row"></div>'),
Y.Node.create('<div class="atto_toolbar_row" tabindex="-1"></div>'),
Y.Node.create('<div class="atto_toolbar_row" role="group"></div>'),
Y.Node.create('<div class="atto_toolbar_row" role="group" aria-label="' +
M.util.get_string('youareonsecondrow', PLUGINNAME) +
'" tabindex="-1"></div>'),
];
this.toolbar.appendChild(toolbarRows[0]).insert(toolbarRows[1], 'after');

View file

@ -1 +1 @@
YUI.add("moodle-atto_collapse-button",function(s,t){var o="atto_collapse",a="showgroups",i="collapse",l="collapsed",n=".atto_group",r=".atto_toolbar_row";s.namespace("M.atto_collapse").Button=s.Base.create("button",s.M.editor_atto.EditorPlugin,[],{initializer:function(){var t=s.Object.size(this.get("host").get("plugins"));t<=1+parseInt(this.get(a),10)||this.toolbar.all(n).size()>this.get(a)||(t=this.addButton({icon:"icon",iconComponent:o,callback:this._toggle}),this.get("host").on("pluginsloaded",function(t,i){var e,o=[s.Node.create('<div class="atto_toolbar_row"></div>'),s.Node.create('<div class="atto_toolbar_row" tabindex="-1"></div>')];this.toolbar.appendChild(o[0]).insert(o[1],"after"),(e=this.toolbar.all(n)).slice(0,this.get(a)).each(function(t){o[0].appendChild(t)}),e.slice(this.get(a)).each(function(t){o[1].appendChild(t)}),this._setVisibility(i),i.setAttribute("aria-expanded","false")},this,t))},_toggle:function(t){t.preventDefault();t=this.buttons[i];t.getData(l)?(this.highlightButtons(i),this._setVisibility(t,!0),this.toolbar.all(r).item(1).focus()):(this.unHighlightButtons(i),this._setVisibility(t),this.buttons[this.name].focus())},_setVisibility:function(t,i){var e=this.toolbar.all(r).item(1);i?(t.set("title",M.util.get_string("showfewer",o)),e.show(),t.setData(l,!1),t.setAttribute("aria-expanded","true")):(t.set("title",M.util.get_string("showmore",o)),e.hide(),t.setData(l,!0),t.setAttribute("aria-expanded","false")),t.removeAttribute("aria-pressed")}},{ATTRS:{showgroups:{value:3}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});
YUI.add("moodle-atto_collapse-button",function(s,t){var a="atto_collapse",l="showgroups",e="collapse",o="collapsed",r=".atto_group",n=".atto_toolbar_row";s.namespace("M.atto_collapse").Button=s.Base.create("button",s.M.editor_atto.EditorPlugin,[],{initializer:function(){var t=s.Object.size(this.get("host").get("plugins"));t<=1+parseInt(this.get(l),10)||this.toolbar.all(r).size()>this.get(l)||(t=this.addButton({icon:"icon",iconComponent:a,callback:this._toggle}),this.get("host").on("pluginsloaded",function(t,e){var i,o=[s.Node.create('<div class="atto_toolbar_row" role="group"></div>'),s.Node.create('<div class="atto_toolbar_row" role="group" aria-label="'+M.util.get_string("youareonsecondrow",a)+'" tabindex="-1"></div>')];this.toolbar.appendChild(o[0]).insert(o[1],"after"),(i=this.toolbar.all(r)).slice(0,this.get(l)).each(function(t){o[0].appendChild(t)}),i.slice(this.get(l)).each(function(t){o[1].appendChild(t)}),this._setVisibility(e),e.setAttribute("aria-expanded","false")},this,t))},_toggle:function(t){t.preventDefault();t=this.buttons[e];t.getData(o)?(this.highlightButtons(e),this._setVisibility(t,!0),this.toolbar.all(n).item(1).focus()):(this.unHighlightButtons(e),this._setVisibility(t),this.buttons[this.name].focus())},_setVisibility:function(t,e){var i=this.toolbar.all(n).item(1);e?(t.set("title",M.util.get_string("showfewer",a)),i.show(),t.setData(o,!1),t.setAttribute("aria-expanded","true")):(t.set("title",M.util.get_string("showmore",a)),i.hide(),t.setData(o,!0),t.setAttribute("aria-expanded","false")),t.removeAttribute("aria-pressed")}},{ATTRS:{showgroups:{value:3}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});

View file

@ -61,8 +61,10 @@ Y.namespace('M.atto_collapse').Button = Y.Base.create('button', Y.M.editor_atto.
this.get('host').on('pluginsloaded', function(e, button) {
// Add 2 rows in the toolbar.
var toolbarRows = [
Y.Node.create('<div class="atto_toolbar_row"></div>'),
Y.Node.create('<div class="atto_toolbar_row" tabindex="-1"></div>'),
Y.Node.create('<div class="atto_toolbar_row" role="group"></div>'),
Y.Node.create('<div class="atto_toolbar_row" role="group" aria-label="' +
M.util.get_string('youareonsecondrow', PLUGINNAME) +
'" tabindex="-1"></div>'),
];
this.toolbar.appendChild(toolbarRows[0]).insert(toolbarRows[1], 'after');

View file

@ -63,8 +63,10 @@ Y.namespace('M.atto_collapse').Button = Y.Base.create('button', Y.M.editor_atto.
this.get('host').on('pluginsloaded', function(e, button) {
// Add 2 rows in the toolbar.
var toolbarRows = [
Y.Node.create('<div class="atto_toolbar_row"></div>'),
Y.Node.create('<div class="atto_toolbar_row" tabindex="-1"></div>'),
Y.Node.create('<div class="atto_toolbar_row" role="group"></div>'),
Y.Node.create('<div class="atto_toolbar_row" role="group" aria-label="' +
M.util.get_string('youareonsecondrow', PLUGINNAME) +
'" tabindex="-1"></div>'),
];
this.toolbar.appendChild(toolbarRows[0]).insert(toolbarRows[1], 'after');