Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-34741

switch to YUI2 to 2in3

    XMLWordPrintable

Details

    • MOODLE_23_STABLE
    • MOODLE_24_STABLE
    • w33_MDL-34741_m24_yui2in3
    • Hide

      For developers:
      1/ purge all caches and enable debug console in your brower
      2/ try slasharguments on and off, yui-combo-loading on and off, external yui on and off
      3/ go through each commit and test affected area:

      • mod_folder
      • private files block
      • file picker
      • date selector form element
      • mod_imscp
      • some user TreeView
      • mod_wiki
      • mod_assignment
      • mod_assign
      • mod_lti
      • mod_forum
      • mod_scorm
      • gradebook
      • groups UI
      • forms
      • tags
      • report_progress
      • report_completion
      • portfolio download
      • question bank
      • mod_quiz
      • comments
      • mod_chat
      • mod_survey
      Show
      For developers: 1/ purge all caches and enable debug console in your brower 2/ try slasharguments on and off, yui-combo-loading on and off, external yui on and off 3/ go through each commit and test affected area: mod_folder private files block file picker date selector form element mod_imscp some user TreeView mod_wiki mod_assignment mod_assign mod_lti mod_forum mod_scorm gradebook groups UI forms tags report_progress report_completion portfolio download question bank mod_quiz comments mod_chat mod_survey

    Description

      At present we have a homegrown YUI2 legacy support that loads YUI2 classes into the global scope (which means that YUI2 is available via global YAHOO object). The official recommended way is to use 2in3 http://yuilibrary.com/yui/docs/yui/yui-yui2.html which loads slightly modified YUI2 directly into the YUI3 instance property Y.YUI2.

      This patch replaces our non-standard YUI2 hack with officially supported YUI 2in3.

      Benefits:
      1/ YUI2 Javascript classes and CSS are not loaded on each page - performance
      2/ YUI2 files are loaded asynchronously - performance
      3/ cleaner coding style with fewer bugs

      Necessary code changes:
      1/ YUI3 code using YUI2 widgets needs to use Y.YUI2.* instead of previous YAHOO.
      2/ rewrite old legacy code that is still using deprecated $PAGE->requires->yui2_lib('xx') to use new moodle JS modules
      3/ in the worst case wrap old code with YUI3 block and use yui2-* modules as dependencies

      Example of YUI3 module using TreeView widget:

      YUI.add('mod-mymodule-tree', function(Y) {
        // ...
        var tree = new Y.YUI2.widget.TreeView("elemid");
        // ...
      }, '@VERSION@', {requires:['base', 'node', 'yui2-treeview']});

      Sample modification of YUI3 code without changing module dependencies:

      YUI().use(function(Y) {
        // Old code
        // ...
        Y().use('yui2-treeview', function(Y) {
          var tree = new Y.YUI2.widget.TreeView("elemid");
          // ...
        });
        // ...

      Example of backwards compatibility hack in global scope:

      YUI().use('yui2-dom', 'yui2-event', '...', function(Y) {
        var YAHOO = Y.YUI2;
        // Old code here
        // ...
       
      });

      Attachments

        Issue Links

          Activity

            People

              skodak Petr Skoda
              skodak Petr Skoda
              Dan Poltawski Dan Poltawski
              Nobody Nobody
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Sara Arjona (@sarjona)
              Votes:
              8 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                3/Dec/12