MDL-43854 Atto: Add collapse toolbar plugin

This commit is contained in:
Damyon Wiese 2014-02-03 10:55:44 +08:00
parent 4c37c1f416
commit fcb5b5c473
18 changed files with 739 additions and 20 deletions

View File

@ -29,7 +29,48 @@ defined('MOODLE_INTERNAL') || die();
class atto extends base {
/**
* Yes you can uninstall these plugins if you want.
* @return moodle_url
*/
public function is_uninstall_allowed() {
return true;
}
/**
* Return URL used for management of plugins of this type.
* @return moodle_url
*/
public static function get_manage_url() {
return new moodle_url('/admin/settings.php', array('section'=>'editorsettingsatto'));
}
/**
* Include the settings.php file from sub plugins if they provide it.
* This is a copy of very similar implementations from various other subplugin areas.
*
* @return moodle_url
*/
public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them.
$ADMIN = $adminroot; // May be used in settings.php.
$plugininfo = $this; // Also can be used inside settings.php.
if (!$this->is_installed_and_upgraded()) {
return;
}
if (!$hassiteconfig or !file_exists($this->full_path('settings.php'))) {
return;
}
$section = $this->get_settings_section_name();
$settings = new \admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false);
include($this->full_path('settings.php')); // This may also set $settings to null.
if ($settings) {
$ADMIN->add($parentnodename, $settings);
}
}
}

View File

@ -0,0 +1,30 @@
<?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 component 'atto_collapse', language 'en'.
*
* @package atto_collapse
* @copyright 2013 Damyon Wiese <damyon@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Show/hide advanced buttons';
$string['showmore'] = 'Show more buttons';
$string['showless'] = 'Show less buttons';
$string['settings'] = 'Collapse toolbar settings';
$string['showgroups'] = 'Show (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.';

View File

@ -0,0 +1,44 @@
<?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/>.
/**
* Atto text editor integration version file.
*
* @package atto_collapse
* @copyright 2013 Damyon Wiese <damyon@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Initialise the js strings required for this module.
*/
function atto_collapse_strings_for_js() {
global $PAGE;
$PAGE->requires->strings_for_js(array('showmore', 'showless'), 'atto_collapse');
}
/**
* Set params for this plugin
* @param string $elementid
*/
function atto_collapse_params_for_js($elementid, $options, $fpoptions) {
// Pass the number of visible groups as a param.
$params = array('showgroups' => get_config('atto_collapse', 'showgroups'));
return $params;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg2"
version="1.1"
inkscape:version="0.48.3.1 r9886"
width="16"
height="16"
sodipodi:docname="icon.svg">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview4"
showgrid="true"
inkscape:zoom="14.75"
inkscape:cx="8"
inkscape:cy="8"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="0"
inkscape:current-layer="svg2">
<inkscape:grid
type="xygrid"
id="grid3033"
empspacing="5"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<g
id="g3027"
transform="translate(-9.9661016,-5.4237289)">
<path
style="fill:#ffffff"
d="m 10.966102,16.923729 0,-3.5 7,0 7,0 0,3.5 0,3.5 -7,0 -7,0 0,-3.5 z m 5,1.5 c 0,-0.55 -0.9,-1 -2,-1 -1.1,0 -2,0.45 -2,1 0,0.55 0.9,1 2,1 1.1,0 2,-0.45 2,-1 z m 3,0 c 0,-0.55 -0.45,-1 -1,-1 -0.55,0 -1,0.45 -1,1 0,0.55 0.45,1 1,1 0.55,0 1,-0.45 1,-1 z m 5,0 c 0,-0.55 -0.45,-1 -1,-1 -0.55,0 -1,0.45 -1,1 0,0.55 0.45,1 1,1 0.55,0 1,-0.45 1,-1 z m -10,-3 c 0,-0.55 -0.45,-1 -1,-1 -0.55,0 -1,0.45 -1,1 0,0.55 0.45,1 1,1 0.55,0 1,-0.45 1,-1 z m 3,0 c 0,-0.55 -0.45,-1 -1,-1 -0.55,0 -1,0.45 -1,1 0,0.55 0.45,1 1,1 0.55,0 1,-0.45 1,-1 z m 3,0 c 0,-0.55 -0.45,-1 -1,-1 -0.55,0 -1,0.45 -1,1 0,0.55 0.45,1 1,1 0.55,0 1,-0.45 1,-1 z m 4,0 c 0,-0.55 -0.675,-1 -1.5,-1 -0.825,0 -1.5,0.45 -1.5,1 0,0.55 0.675,1 1.5,1 0.825,0 1.5,-0.45 1.5,-1 z m -10.25,-3.732205 c 2.3375,-0.210535 6.1625,-0.210535 8.5,0 2.3375,0.210535 0.425,0.382791 -4.25,0.382791 -4.675,0 -6.5875,-0.172256 -4.25,-0.382791 z m -2.75,-3.2677951 c 0,-1.8095238 0.666666,-2 7,-2 6.333333,0 7,0.1904762 7,2 0,1.8095241 -0.666667,2.0000001 -7,2.0000001 -6.333334,0 -7,-0.190476 -7,-2.0000001 z m 3,0 c 0,-0.55 -0.45,-1 -1,-1 -0.55,0 -1,0.45 -1,1 0,0.55 0.45,1 1,1 0.55,0 1,-0.45 1,-1 z m 3,0 c 0,-0.55 -0.45,-1 -1,-1 -0.55,0 -1,0.45 -1,1 0,0.55 0.45,1 1,1 0.55,0 1,-0.45 1,-1 z m 3,0 c 0,-0.55 -0.45,-1 -1,-1 -0.55,0 -1,0.45 -1,1 0,0.55 0.45,1 1,1 0.55,0 1,-0.45 1,-1 z m 4,0 c 0,-0.55 -0.675,-1 -1.5,-1 -0.825,0 -1.5,0.45 -1.5,1 0,0.55 0.675,1 1.5,1 0.825,0 1.5,-0.45 1.5,-1 z"
id="path3031"
inkscape:connector-curvature="0" />
<path
style="fill:#999999"
d="m 9.9661016,16.923729 0,-4.5 8.0000004,0 8,0 0,4.5 0,4.5 -8,0 -8.0000004,0 0,-4.5 z m 15.0000004,0 0,-3.5 -7,0 -7,0 0,3.5 0,3.5 7,0 7,0 0,-3.5 z m -13,1.5 c 0,-0.55 0.9,-1 2,-1 1.1,0 2,0.45 2,1 0,0.55 -0.9,1 -2,1 -1.1,0 -2,-0.45 -2,-1 z m 5,0 c 0,-0.55 0.45,-1 1,-1 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 -0.55,0 -1,-0.45 -1,-1 z m 5,0 c 0,-0.55 0.45,-1 1,-1 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 -0.55,0 -1,-0.45 -1,-1 z m -10,-3 c 0,-0.55 0.45,-1 1,-1 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 -0.55,0 -1,-0.45 -1,-1 z m 3,0 c 0,-0.55 0.45,-1 1,-1 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 -0.55,0 -1,-0.45 -1,-1 z m 3,0 c 0,-0.55 0.45,-1 1,-1 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 -0.55,0 -1,-0.45 -1,-1 z m 3,0 c 0,-0.55 0.675,-1 1.5,-1 0.825,0 1.5,0.45 1.5,1 0,0.55 -0.675,1 -1.5,1 -0.825,0 -1.5,-0.45 -1.5,-1 z M 9.9661016,8.4237289 l 0,-3 8.0000004,0 8,0 0,3 0,3.0000001 -8,0 -8.0000004,0 0,-3.0000001 z m 15.0000004,0 c 0,-1.8095238 -0.666667,-2 -7,-2 -6.333334,0 -7,0.1904762 -7,2 0,1.8095241 0.666666,2.0000001 7,2.0000001 6.333333,0 7,-0.190476 7,-2.0000001 z m -13,0 c 0,-0.55 0.45,-1 1,-1 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 -0.55,0 -1,-0.45 -1,-1 z m 3,0 c 0,-0.55 0.45,-1 1,-1 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 -0.55,0 -1,-0.45 -1,-1 z m 3,0 c 0,-0.55 0.45,-1 1,-1 0.55,0 1,0.45 1,1 0,0.55 -0.45,1 -1,1 -0.55,0 -1,-0.45 -1,-1 z m 3,0 c 0,-0.55 0.675,-1 1.5,-1 0.825,0 1.5,0.45 1.5,1 0,0.55 -0.675,1 -1.5,1 -0.825,0 -1.5,-0.45 -1.5,-1 z"
id="path3029"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -0,0 +1,43 @@
<?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/>.
/**
* Settings that allow configuration of the list of tex examples in the equation editor.
*
* @package atto_collapse
* @copyright 2013 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$ADMIN->add('editoratto', new admin_category('atto_collapse', new lang_string('pluginname', 'atto_collapse')));
$settings = new admin_settingpage('atto_collapse_settings', new lang_string('settings', 'atto_collapse'));
if ($ADMIN->fulltree) {
// Number of groups to show when collapsed.
$name = new lang_string('showgroups', 'atto_collapse');
$desc = new lang_string('showgroups_desc', 'atto_collapse');
$default = 3;
$options = array_combine(range(1, 10), range(1, 10));
$setting = new admin_setting_configselect('atto_collapse/showgroups',
$name,
$desc,
$default,
$options);
$settings->add($setting);
}

View File

@ -0,0 +1,29 @@
<?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/>.
/**
* Atto text editor integration version file.
*
* @package atto_collapse
* @copyright 2013 Damyon Wiese <damyon@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2014012800; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2013110500; // Requires this Moodle version.
$plugin->component = 'atto_collapse'; // Full name of the plugin (used for diagnostics).

View File

@ -0,0 +1,110 @@
YUI.add('moodle-atto_collapse-button', function (Y, NAME) {
// 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/>.
/**
* CSS Selectors
*
* @type {Object}
*/
var SELECTORS = {
GROUPS: '.atto_group',
BUTTON: '.atto_collapse_button'
};
/**
* Atto text editor collapse plugin.
*
* @package atto_collapse
* @copyright 2013 Damyon Wiese <damyon@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
M.atto_collapse = M.atto_collapse || {
/**
* How many groups to show when collapsed.
*
* @property showgroups
* @type {Integer}
* @default 3
*/
showgroups : 3,
/**
* Init.
*
* @param {Object} params
*
* @return {Void}
*/
init : function(params) {
var click = function(e, elementid) {
e.preventDefault();
M.atto_collapse.toggle(elementid);
};
this.showgroups = params.showgroups;
var iconurl = M.util.image_url('icon', 'atto_collapse');
// Add the button to the toolbar.
M.editor_atto.add_toolbar_button(params.elementid, 'collapse', iconurl, params.group, click);
},
/**
* Either hide or show the extra groups in the toolbar.
*
* @param {String} elementid
*
* @return {Void}
*/
toggle : function(elementid) {
var toolbar = M.editor_atto.get_toolbar_node(elementid);
var button = toolbar.one(SELECTORS.BUTTON);
var groups = toolbar.all(SELECTORS.GROUPS).slice(this.showgroups);
if (button.getData('collapsed')) {
button.set('title', M.util.get_string('showmore', 'atto_collapse'));
groups.show();
button.setData('collapsed', false);
} else {
button.set('title', M.util.get_string('showless', 'atto_collapse'));
groups.hide();
button.setData('collapsed', true);
}
},
/**
* After init function called after all plugins init() has been run.
*
* @param {Object} params
*
* @return {Void}
*/
after_init : function(params) {
var toolbar = M.editor_atto.get_toolbar_node(params.elementid);
var button = toolbar.one(SELECTORS.BUTTON);
// Set the state to "not collapsed" (which is the state when the page loads).
button.setData('collapsed', false);
// Call toggle to change the state when the page loads to "collapsed".
M.atto_collapse.toggle(params.elementid);
}
};
}, '@VERSION@', {"requires": ["node"]});

View File

@ -0,0 +1 @@
YUI.add("moodle-atto_collapse-button",function(e,t){var n={GROUPS:".atto_group",BUTTON:".atto_collapse_button"};M.atto_collapse=M.atto_collapse||{showgroups:3,init:function(e){var t=function(e,t){e.preventDefault(),M.atto_collapse.toggle(t)};this.showgroups=e.showgroups;var n=M.util.image_url("icon","atto_collapse");M.editor_atto.add_toolbar_button(e.elementid,"collapse",n,e.group,t)},toggle:function(e){var t=M.editor_atto.get_toolbar_node(e),r=t.one(n.BUTTON),i=t.all(n.GROUPS).slice(this.showgroups);r.getData("collapsed")?(r.set("title",M.util.get_string("showmore","atto_collapse")),i.show(),r.setData("collapsed",!1)):(r.set("title",M.util.get_string("showless","atto_collapse")),i.hide(),r.setData("collapsed",!0))},after_init:function(e){var t=M.editor_atto.get_toolbar_node(e.elementid),r=t.one(n.BUTTON);r.setData("collapsed",!1),M.atto_collapse.toggle(e.elementid)}}},"@VERSION@",{requires:["node"]});

View File

@ -0,0 +1,110 @@
YUI.add('moodle-atto_collapse-button', function (Y, NAME) {
// 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/>.
/**
* CSS Selectors
*
* @type {Object}
*/
var SELECTORS = {
GROUPS: '.atto_group',
BUTTON: '.atto_collapse_button'
};
/**
* Atto text editor collapse plugin.
*
* @package atto_collapse
* @copyright 2013 Damyon Wiese <damyon@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
M.atto_collapse = M.atto_collapse || {
/**
* How many groups to show when collapsed.
*
* @property showgroups
* @type {Integer}
* @default 3
*/
showgroups : 3,
/**
* Init.
*
* @param {Object} params
*
* @return {Void}
*/
init : function(params) {
var click = function(e, elementid) {
e.preventDefault();
M.atto_collapse.toggle(elementid);
};
this.showgroups = params.showgroups;
var iconurl = M.util.image_url('icon', 'atto_collapse');
// Add the button to the toolbar.
M.editor_atto.add_toolbar_button(params.elementid, 'collapse', iconurl, params.group, click);
},
/**
* Either hide or show the extra groups in the toolbar.
*
* @param {String} elementid
*
* @return {Void}
*/
toggle : function(elementid) {
var toolbar = M.editor_atto.get_toolbar_node(elementid);
var button = toolbar.one(SELECTORS.BUTTON);
var groups = toolbar.all(SELECTORS.GROUPS).slice(this.showgroups);
if (button.getData('collapsed')) {
button.set('title', M.util.get_string('showmore', 'atto_collapse'));
groups.show();
button.setData('collapsed', false);
} else {
button.set('title', M.util.get_string('showless', 'atto_collapse'));
groups.hide();
button.setData('collapsed', true);
}
},
/**
* After init function called after all plugins init() has been run.
*
* @param {Object} params
*
* @return {Void}
*/
after_init : function(params) {
var toolbar = M.editor_atto.get_toolbar_node(params.elementid);
var button = toolbar.one(SELECTORS.BUTTON);
// Set the state to "not collapsed" (which is the state when the page loads).
button.setData('collapsed', false);
// Call toggle to change the state when the page loads to "collapsed".
M.atto_collapse.toggle(params.elementid);
}
};
}, '@VERSION@', {"requires": ["node"]});

View File

@ -0,0 +1,10 @@
{
"name": "moodle-atto_collapse-button",
"builds": {
"moodle-atto_collapse-button": {
"jsfiles": [
"button.js"
]
}
}
}

View File

@ -0,0 +1,105 @@
// 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/>.
/**
* CSS Selectors
*
* @type {Object}
*/
var SELECTORS = {
GROUPS: '.atto_group',
BUTTON: '.atto_collapse_button'
};
/**
* Atto text editor collapse plugin.
*
* @package atto_collapse
* @copyright 2013 Damyon Wiese <damyon@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
M.atto_collapse = M.atto_collapse || {
/**
* How many groups to show when collapsed.
*
* @property showgroups
* @type {Integer}
* @default 3
*/
showgroups : 3,
/**
* Init.
*
* @param {Object} params
*
* @return {Void}
*/
init : function(params) {
var click = function(e, elementid) {
e.preventDefault();
M.atto_collapse.toggle(elementid);
};
this.showgroups = params.showgroups;
var iconurl = M.util.image_url('icon', 'atto_collapse');
// Add the button to the toolbar.
M.editor_atto.add_toolbar_button(params.elementid, 'collapse', iconurl, params.group, click);
},
/**
* Either hide or show the extra groups in the toolbar.
*
* @param {String} elementid
*
* @return {Void}
*/
toggle : function(elementid) {
var toolbar = M.editor_atto.get_toolbar_node(elementid);
var button = toolbar.one(SELECTORS.BUTTON);
var groups = toolbar.all(SELECTORS.GROUPS).slice(this.showgroups);
if (button.getData('collapsed')) {
button.set('title', M.util.get_string('showmore', 'atto_collapse'));
groups.show();
button.setData('collapsed', false);
} else {
button.set('title', M.util.get_string('showless', 'atto_collapse'));
groups.hide();
button.setData('collapsed', true);
}
},
/**
* After init function called after all plugins init() has been run.
*
* @param {Object} params
*
* @return {Void}
*/
after_init : function(params) {
var toolbar = M.editor_atto.get_toolbar_node(params.elementid);
var button = toolbar.one(SELECTORS.BUTTON);
// Set the state to "not collapsed" (which is the state when the page loads).
button.setData('collapsed', false);
// Call toggle to change the state when the page loads to "collapsed".
M.atto_collapse.toggle(params.elementid);
}
};

View File

@ -0,0 +1,5 @@
{
"moodle-atto_collapse-button": {
"requires": ["node"]
}
}

View File

@ -30,7 +30,8 @@ $settings = new admin_settingpage('editorsettingsatto', new lang_string('setting
if ($ADMIN->fulltree) {
$name = new lang_string('toolbarconfig', 'editor_atto');
$desc = new lang_string('toolbarconfig_desc', 'editor_atto');
$default = 'style = bold, italic, underline, strike, clear, title' . "\n" .
$default = 'collapse = collapse' . "\n" .
'style = bold, italic, underline, strike, clear, title' . "\n" .
'paragraph = subscript, superscript, indent, outdent, orderedlist, unorderedlist' . "\n" .
'links = link, unlink' . "\n" .
'insert = table, image, media, managefiles, charmap, emoticon' . "\n" .
@ -44,10 +45,12 @@ if ($ADMIN->fulltree) {
}
$ADMIN->add('editoratto', $settings);
unset($settings);
foreach (core_plugin_manager::instance()->get_plugins_of_type('atto') as $plugin) {
/** @var \editor_atto\plugininfo\atto $plugin */
$plugin->load_settings($ADMIN, 'editoratto', $hassiteconfig);
}
// Required or the editor plugininfo will add this section twice.
unset($settings);
$settings = null;

View File

@ -161,6 +161,18 @@ M.editor_atto = M.editor_atto || {
var plugin = this.getAttribute('data-plugin');
var handler = this.getAttribute('data-handler');
var overlay = M.editor_atto.menus[plugin + '_' + elementid];
var toolbar = M.editor_atto.get_toolbar_node(elementid);
var currentid = toolbar.getAttribute('aria-activedescendant');
// Right now, currentid is the id of the previously selected button.
if (currentid) {
current = Y.one('#' + currentid);
// We only ever want one button with a tabindex of 0 at any one time.
current.setAttribute('tabindex', '-1');
}
this.setAttribute('tabindex', 0);
// And update the activedescendant to point at the currently selected button.
toolbar.setAttribute('aria-activedescendant', this.generateID());
if (overlay) {
overlay.hide();
@ -323,6 +335,7 @@ M.editor_atto = M.editor_atto || {
currentfocus = toolbar.getAttribute('aria-activedescendant');
if (!currentfocus) {
// Initially set the first button in the toolbar to be the default on keyboard focus.
button.setAttribute('tabindex', '0');
toolbar.setAttribute('aria-activedescendant', button.generateID());
}
@ -406,6 +419,7 @@ M.editor_atto = M.editor_atto || {
currentfocus = toolbar.getAttribute('aria-activedescendant');
if (!currentfocus) {
// Initially set the first button in the toolbar to be the default on keyboard focus.
button.setAttribute('tabindex', '0');
toolbar.setAttribute('aria-activedescendant', button.generateID());
}
@ -540,17 +554,31 @@ M.editor_atto = M.editor_atto || {
M.editor_atto.filepickeroptions[params.elementid] = params.filepickeroptions;
// Init each of the plugins
var i, j;
var i, j, group, plugin;
for (i = 0; i < params.plugins.length; i++) {
var group = params.plugins[i].group;
group = params.plugins[i].group;
for (j = 0; j < params.plugins[i].plugins.length; j++) {
var plugin = params.plugins[i].plugins[j];
plugin = params.plugins[i].plugins[j];
plugin.params.elementid = params.elementid;
plugin.params.group = group;
M['atto_' + plugin.name].init(plugin.params);
}
}
// Let the plugins run some init code once all plugins are in the page.
for (i = 0; i < params.plugins.length; i++) {
group = params.plugins[i].group;
for (j = 0; j < params.plugins[i].plugins.length; j++) {
plugin = params.plugins[i].plugins[j];
plugin.params.elementid = params.elementid;
plugin.params.group = group;
if (typeof M['atto_' + plugin.name].after_init !== 'undefined') {
M['atto_' + plugin.name].after_init(plugin.params);
}
}
}
},
/**
@ -613,11 +641,21 @@ M.editor_atto = M.editor_atto || {
e.preventDefault();
buttons = toolbar.all('button');
// This workaround is because we cannot do ".atto_group:not([hidden]) button" in ie8 (even with selector-css3).
// Create an empty NodeList.
buttons = toolbar.all('empty');
toolbar.all('.atto_group').each(function(group) {
if (!group.hasAttribute('hidden')) {
// Append the visible buttons to the buttons list.
buttons = buttons.concat(group.all('button'));
}
});
// The currentid is the id of the previously selected button.
currentid = toolbar.getAttribute('aria-activedescendant');
if (!currentid) {
return;
}
// We only ever want one button with a tabindex of 0.
current = Y.one('#' + currentid);
current.setAttribute('tabindex', '-1');
@ -636,7 +674,7 @@ M.editor_atto = M.editor_atto || {
currentindex = 0;
}
}
// Currentindex has been updated to point to the new button.
current = buttons.item(currentindex);
current.setAttribute('tabindex', '0');
current.focus();

File diff suppressed because one or more lines are too long

View File

@ -161,6 +161,18 @@ M.editor_atto = M.editor_atto || {
var plugin = this.getAttribute('data-plugin');
var handler = this.getAttribute('data-handler');
var overlay = M.editor_atto.menus[plugin + '_' + elementid];
var toolbar = M.editor_atto.get_toolbar_node(elementid);
var currentid = toolbar.getAttribute('aria-activedescendant');
// Right now, currentid is the id of the previously selected button.
if (currentid) {
current = Y.one('#' + currentid);
// We only ever want one button with a tabindex of 0 at any one time.
current.setAttribute('tabindex', '-1');
}
this.setAttribute('tabindex', 0);
// And update the activedescendant to point at the currently selected button.
toolbar.setAttribute('aria-activedescendant', this.generateID());
if (overlay) {
overlay.hide();
@ -323,6 +335,7 @@ M.editor_atto = M.editor_atto || {
currentfocus = toolbar.getAttribute('aria-activedescendant');
if (!currentfocus) {
// Initially set the first button in the toolbar to be the default on keyboard focus.
button.setAttribute('tabindex', '0');
toolbar.setAttribute('aria-activedescendant', button.generateID());
}
@ -406,6 +419,7 @@ M.editor_atto = M.editor_atto || {
currentfocus = toolbar.getAttribute('aria-activedescendant');
if (!currentfocus) {
// Initially set the first button in the toolbar to be the default on keyboard focus.
button.setAttribute('tabindex', '0');
toolbar.setAttribute('aria-activedescendant', button.generateID());
}
@ -540,17 +554,31 @@ M.editor_atto = M.editor_atto || {
M.editor_atto.filepickeroptions[params.elementid] = params.filepickeroptions;
// Init each of the plugins
var i, j;
var i, j, group, plugin;
for (i = 0; i < params.plugins.length; i++) {
var group = params.plugins[i].group;
group = params.plugins[i].group;
for (j = 0; j < params.plugins[i].plugins.length; j++) {
var plugin = params.plugins[i].plugins[j];
plugin = params.plugins[i].plugins[j];
plugin.params.elementid = params.elementid;
plugin.params.group = group;
M['atto_' + plugin.name].init(plugin.params);
}
}
// Let the plugins run some init code once all plugins are in the page.
for (i = 0; i < params.plugins.length; i++) {
group = params.plugins[i].group;
for (j = 0; j < params.plugins[i].plugins.length; j++) {
plugin = params.plugins[i].plugins[j];
plugin.params.elementid = params.elementid;
plugin.params.group = group;
if (typeof M['atto_' + plugin.name].after_init !== 'undefined') {
M['atto_' + plugin.name].after_init(plugin.params);
}
}
}
},
/**
@ -613,11 +641,21 @@ M.editor_atto = M.editor_atto || {
e.preventDefault();
buttons = toolbar.all('button');
// This workaround is because we cannot do ".atto_group:not([hidden]) button" in ie8 (even with selector-css3).
// Create an empty NodeList.
buttons = toolbar.all('empty');
toolbar.all('.atto_group').each(function(group) {
if (!group.hasAttribute('hidden')) {
// Append the visible buttons to the buttons list.
buttons = buttons.concat(group.all('button'));
}
});
// The currentid is the id of the previously selected button.
currentid = toolbar.getAttribute('aria-activedescendant');
if (!currentid) {
return;
}
// We only ever want one button with a tabindex of 0.
current = Y.one('#' + currentid);
current.setAttribute('tabindex', '-1');
@ -636,7 +674,7 @@ M.editor_atto = M.editor_atto || {
currentindex = 0;
}
}
// Currentindex has been updated to point to the new button.
current = buttons.item(currentindex);
current.setAttribute('tabindex', '0');
current.focus();

View File

@ -159,6 +159,18 @@ M.editor_atto = M.editor_atto || {
var plugin = this.getAttribute('data-plugin');
var handler = this.getAttribute('data-handler');
var overlay = M.editor_atto.menus[plugin + '_' + elementid];
var toolbar = M.editor_atto.get_toolbar_node(elementid);
var currentid = toolbar.getAttribute('aria-activedescendant');
// Right now, currentid is the id of the previously selected button.
if (currentid) {
current = Y.one('#' + currentid);
// We only ever want one button with a tabindex of 0 at any one time.
current.setAttribute('tabindex', '-1');
}
this.setAttribute('tabindex', 0);
// And update the activedescendant to point at the currently selected button.
toolbar.setAttribute('aria-activedescendant', this.generateID());
if (overlay) {
overlay.hide();
@ -321,6 +333,7 @@ M.editor_atto = M.editor_atto || {
currentfocus = toolbar.getAttribute('aria-activedescendant');
if (!currentfocus) {
// Initially set the first button in the toolbar to be the default on keyboard focus.
button.setAttribute('tabindex', '0');
toolbar.setAttribute('aria-activedescendant', button.generateID());
}
@ -404,6 +417,7 @@ M.editor_atto = M.editor_atto || {
currentfocus = toolbar.getAttribute('aria-activedescendant');
if (!currentfocus) {
// Initially set the first button in the toolbar to be the default on keyboard focus.
button.setAttribute('tabindex', '0');
toolbar.setAttribute('aria-activedescendant', button.generateID());
}
@ -538,17 +552,31 @@ M.editor_atto = M.editor_atto || {
M.editor_atto.filepickeroptions[params.elementid] = params.filepickeroptions;
// Init each of the plugins
var i, j;
var i, j, group, plugin;
for (i = 0; i < params.plugins.length; i++) {
var group = params.plugins[i].group;
group = params.plugins[i].group;
for (j = 0; j < params.plugins[i].plugins.length; j++) {
var plugin = params.plugins[i].plugins[j];
plugin = params.plugins[i].plugins[j];
plugin.params.elementid = params.elementid;
plugin.params.group = group;
M['atto_' + plugin.name].init(plugin.params);
}
}
// Let the plugins run some init code once all plugins are in the page.
for (i = 0; i < params.plugins.length; i++) {
group = params.plugins[i].group;
for (j = 0; j < params.plugins[i].plugins.length; j++) {
plugin = params.plugins[i].plugins[j];
plugin.params.elementid = params.elementid;
plugin.params.group = group;
if (typeof M['atto_' + plugin.name].after_init !== 'undefined') {
M['atto_' + plugin.name].after_init(plugin.params);
}
}
}
},
/**
@ -611,11 +639,21 @@ M.editor_atto = M.editor_atto || {
e.preventDefault();
buttons = toolbar.all('button');
// This workaround is because we cannot do ".atto_group:not([hidden]) button" in ie8 (even with selector-css3).
// Create an empty NodeList.
buttons = toolbar.all('empty');
toolbar.all('.atto_group').each(function(group) {
if (!group.hasAttribute('hidden')) {
// Append the visible buttons to the buttons list.
buttons = buttons.concat(group.all('button'));
}
});
// The currentid is the id of the previously selected button.
currentid = toolbar.getAttribute('aria-activedescendant');
if (!currentid) {
return;
}
// We only ever want one button with a tabindex of 0.
current = Y.one('#' + currentid);
current.setAttribute('tabindex', '-1');
@ -634,7 +672,7 @@ M.editor_atto = M.editor_atto || {
currentindex = 0;
}
}
// Currentindex has been updated to point to the new button.
current = buttons.item(currentindex);
current.setAttribute('tabindex', '0');
current.focus();