Merge branch 'MDL-44131-master' of git://github.com/FMCorz/moodle
authorDamyon Wiese <damyon@moodle.com>
Tue, 8 Apr 2014 06:18:50 +0000 (14:18 +0800)
committerDamyon Wiese <damyon@moodle.com>
Tue, 8 Apr 2014 06:18:50 +0000 (14:18 +0800)
Conflicts:
lib/editor/atto/plugins/equation/yui/build/moodle-atto_equation-button/moodle-atto_equation-button-debug.js
lib/editor/atto/plugins/equation/yui/build/moodle-atto_equation-button/moodle-atto_equation-button-min.js
lib/editor/atto/plugins/equation/yui/build/moodle-atto_equation-button/moodle-atto_equation-button.js
lib/editor/atto/plugins/equation/yui/src/button/js/button.js

1  2 
lib/editor/atto/plugins/equation/yui/build/moodle-atto_equation-button/moodle-atto_equation-button-debug.js
lib/editor/atto/plugins/equation/yui/build/moodle-atto_equation-button/moodle-atto_equation-button-min.js
lib/editor/atto/plugins/equation/yui/build/moodle-atto_equation-button/moodle-atto_equation-button.js
lib/editor/atto/plugins/equation/yui/src/button/js/button.js

@@@ -67,15 -66,19 +70,21 @@@ var COMPONENTNAME = 'atto_equation'
              '<div class="{{CSS.LIBRARY}}">' +
                  '<ul>' +
                      '{{#each library}}' +
-                         '<li><a href="#{{elementid}}_{{../CSS.LIBRARY_GROUP_PREFIX}}{{@key}}">{{get_string groupname ../component}}</a></li>' +
+                         '<li><a href="#{{../elementid}}_{{../CSS.LIBRARY_GROUP_PREFIX}}_{{@key}}">' +
+                             '{{get_string groupname ../component}}' +
+                         '</a></li>' +
                      '{{/each}}' +
                  '</ul>' +
-                 '<div>' +
+                 '<div class="{{CSS.LIBRARY_GROUPS}}">' +
                      '{{#each library}}' +
-                         '<div id="{{elementid}}_{{../CSS.LIBRARY_GROUP_PREFIX}}{{@key}}">' +
-                         '{{#split "\n" elements}}' +
-                             '<button data-tex="{{this}}" title="{{this}}">{{../../DELIMITERS.START}}{{this}}{{../../DELIMITERS.END}}</button>' +
-                         '{{/split}}' +
+                         '<div id="{{../elementid}}_{{../CSS.LIBRARY_GROUP_PREFIX}}_{{@key}}">' +
+                             '<div role="toolbar">' +
+                             '{{#split "\n" elements}}' +
 -                                '<button tabindex="-1" data-tex="{{this}}" aria-label="{{this}}" title="{{this}}">$${{this}}$$</button>' +
++                                '<button tabindex="-1" data-tex="{{this}}" aria-label="{{this}}" title="{{this}}">' +
++                                    '{{../../DELIMITERS.START}}{{this}}{{../../DELIMITERS.END}}' +
++                                '</button>' +
+                             '{{/split}}' +
+                             '</div>' +
                          '</div>' +
                      '{{/each}}' +
                  '</div>' +
@@@ -113,17 -116,19 +122,30 @@@ Y.namespace('M.atto_equation').Button 
       */
      _content: null,
  
 +    /**
 +     * The source equation we are editing in the text.
 +     *
 +     * @property _sourceEquation
 +     * @type String
 +     * @private
 +     */
 +    _sourceEquation: '',
 +
+     /**
+      * A reference to the tab focus set on each group.
+      *
+      * The keys are the IDs of the group, the value is the Node on which the focus is set.
+      *
+      * @property _groupFocus
+      * @type Object
+      * @private
+      */
+     _groupFocus: null,
      initializer: function() {
+         this._groupFocus = {};
++
 +        // If there is a tex filter active - enable this button.
          if (this.get('texfilteractive')) {
              // Add the button to the toolbar.
              this.addButton({
              CSS: CSS
          }));
  
+         // Sets the default focus.
+         this._content.all(SELECTORS.LIBRARY_GROUP).each(function(group) {
+             // The first button gets the focus.
+             this._setGroupTabFocus(group, group.one('button'));
+             // Sometimes the filter adds an anchor in the button, no tabindex on that.
+             group.all('button a').setAttribute('tabindex', '-1');
+         }, this);
+         // Keyboard navigation in groups.
+         this._content.delegate('key', this._groupNavigation, 'down:37,39', SELECTORS.LIBRARY_BUTTON, this);
          this._content.one(SELECTORS.SUBMIT).on('click', this._setEquation, this);
 -        this._content.one(SELECTORS.EQUATION_TEXT).on('valuechange', this._updatePreview, this);
 -        this._content.one(SELECTORS.EQUATION_TEXT).on('mouseup', this._updatePreview, this);
 -        this._content.one(SELECTORS.EQUATION_TEXT).on('keyup', this._updatePreview, this);
 +        this._content.one(SELECTORS.EQUATION_TEXT).on('valuechange', this._throttle(this._updatePreview, 500), this);
 +        this._content.one(SELECTORS.EQUATION_TEXT).on('mouseup', this._throttle(this._updatePreview, 500), this);
 +        this._content.one(SELECTORS.EQUATION_TEXT).on('keyup', this._throttle(this._updatePreview, 500), this);
          this._content.delegate('click', this._selectLibraryItem, SELECTORS.LIBRARY_BUTTON, this);
  
          return this._content;