# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/lib/javascript-static.js
--- moodle/lib/javascript-static.js Base (1.142)
+++ moodle/lib/javascript-static.js Locally Modified (Based On 1.142)
@@ -170,67 +170,6 @@
 M.util.CollapsibleRegion.prototype.icon = null;
 
 /**
- * Finds all help icons on the page and initiates YUI tooltips for
- * each of them, which load a truncated version of the help's content
- * on-the-fly asynchronously
- */
-M.util.init_help_icons = function(Y) {
-    Y.use('io', 'yui2-dom', 'yui2-container', function(Y) {
-        // remove all titles, they would obscure the YUI tooltip
-        Y.all('span.helplink a').each(function(node) {
-            node.set('title', '');
-        });
-
-        var iconspans = YAHOO.util.Dom.getElementsByClassName('helplink', 'span');
-        var tooltip = new YAHOO.widget.Tooltip('help_icon_tooltip', {
-            context: iconspans,
-            showdelay: 1000,
-            hidedelay: 150,
-            autodismissdelay: 50000,
-            underlay: 'none',
-            zIndex: '1000'
-        });
-
-        tooltip.contextTriggerEvent.subscribe(
-            function(type, args) {
-                // Fetch help page contents asynchronously
-                // Load spinner icon while content is loading
-                var spinner = document.createElement('img');
-                spinner.src = M.cfg.loadingicon;
-
-                this.cfg.setProperty('text', spinner);
-
-                var context = args[0];
-
-                var link = context.getElementsByTagName('a')[0];
-                var thistooltip = this;
-                var ajaxurl = link.href + '&ajax=1';
-
-
-                var cfg = {
-                    method: 'get',
-                    on: {
-                        success: function(id, o, args) {
-                            thistooltip.cfg.setProperty('text', o.responseText);
-                        },
-                        failure: function(id, o, args) {
-                            var debuginfo = o.statusText;
-                            if (M.cfg.developerdebug) {
-                                o.statusText += ' (' + ajaxurl + ')';
-                            }
-                            thistooltip.cfg.setProperty('text', debuginfo);
-                        }
-                    }
-                };
-
-                var conn = Y.io(ajaxurl, cfg);
-            }
-        );
-    });
-};
-
-
-/**
  * Makes a best effort to connect back to Moodle to update a user preference,
  * however, there is no mechanism for finding out if the update succeeded.
  *
@@ -1219,12 +1158,10 @@
 
 function openpopup(event, args) {
 
+    if (event) {
     YAHOO.util.Event.preventDefault(event);
+    }
    
-    if (M.help_content.instance !== null) {       
-        var id = '#' + args.id;        
-        M.help_content.instance.load_from_openpopup(event, args);
-    } else {        
         var fullurl = args.url;
         if (!args.url.match(/https?:\/\//)) {
             fullurl = M.cfg.wwwroot + args.url;
@@ -1238,9 +1175,9 @@
             windowobj.resizeTo(screen.availWidth,screen.availHeight);
         }
         windowobj.focus();
+    
         return false;
     }
-}
 
 /* This is only used on a few help pages. */
 emoticons_help = {
@@ -1466,121 +1403,86 @@
     }
 }
 
-M.help_content = {
+M.util.help_icon = {
+    Y : null,
     instance : null,
-    init : function(Y) {                
-        Y.use('overlay', 'io', 'event-mouseenter', 'node', "*", function(Y) {
-
+    add : function(Y, properties) {
+        this.Y = Y;
+        Y.one('#'+properties.id).on('click', this.display, this, properties);
+    },
+    display : function(event, args) {
+        event.preventDefault();
+        if (M.util.help_icon.instance === null) {
+            var Y = M.util.help_icon.Y;
+            Y.use('overlay', 'io', 'event-mouseenter', 'node', function(Y) {
             var help_content_overlay = {
                 overlay : null,
                 init : function() {
-                    var xy = Y.one('#helpcontent').getXY(); 
 
+                        var closebtn = Y.Node.create('<img src="'+M.util.image_url('t/delete', 'moodle')+'" />');
+
                     // Create an overlay from markup
                     this.overlay = new Y.Overlay({
-                        srcNode : "#helpcontent",
-                        contentBox: '#helpcontent',
+                            headerContent: closebtn,
+                            bodyContent: '',
                         width:'400px',
-                        xy:[xy[0] + 200, xy[1] + 300]
+                            visible : false,
+                            constrain : true
                     });
-                    this.overlay.render();
-                    this.overlay.hide();
+                        this.overlay.render(Y.one(document.body));
 
-                    Y.on("click", Y.bind(this.overlay.show, this.overlay), "#show");
-                    Y.on("click", Y.bind(this.overlay.hide, this.overlay), "#hide");
+                        closebtn.on('click', this.overlay.hide, this.overlay);
                     
-                    var menuButton = Y.one(".helplink"),
-                    overlaycontent = this;
-
                     var boundingBox = this.overlay.get("boundingBox");
+                        boundingBox.addClass('helppopup');
 
                     //  Hide the menu if the user clicks outside of its content 
                     boundingBox.get("ownerDocument").on("mousedown", function (event) {
                         var oTarget = event.target;
+                            var menuButton = Y.one("#"+args.id);
 
                         if (!oTarget.compareTo(menuButton) &&
                             !menuButton.contains(oTarget) &&
                             !oTarget.compareTo(boundingBox) &&
                             !boundingBox.contains(oTarget)) {
-                            overlaycontent.overlay.hide();
+                                this.overlay.hide();
                         }
-                    });                    
+                        }, this);
                 },
                 
-                load_from_openpopup : function(event, node) {
-                    var spinner = document.createElement('img');
-                    spinner.src = M.cfg.loadingicon;
-                    this.overlay.set('bodyContent', spinner);
+                    display : function(event, args) {
+                        this.overlay.set('bodyContent', Y.Node.create('<img src="'+M.cfg.loadingicon+'" class="spinner" />'));
+                        this.overlay.set("align", {node:"#" + args.id, points:[Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.RC]});
 
-                    var positionX = 0;
-                    var positionY = 0;
-
-                    if (event.pageX && !Y.UA.chrome) {
-                        positionX = event.pageX;
-                        positionY = event.pageY;
-                    } else if (event.pageX && !Y.UA.chrome) {
-                        positionX = document.getElementById(node['id']).offsetLeft + 200;
-                        positionY = document.getElementById(node['id']).offsetTop + 500;
-                    } else { //chrome browser
-                        positionX = event.clientX + document.body.scrollLeft ;
-                        positionY = document.body.scrollTop;
-                        if (event.clientX > document.body.scrollTop) {
-                            positionY += event.clientY;
+                        var fullurl = args.url;
+                        if (!args.url.match(/https?:\/\//)) {
+                            fullurl = M.cfg.wwwroot + args.url;
                         }
-                    }
 
-                    if (Y.UA.chrome) {
-                        positionX = event.clientX + document.body.scrollLeft ;
-                        positionY = document.body.scrollTop;
-                        if (event.clientX > document.body.scrollTop) {
-                            positionY += event.clientY;
-                        }                        
-                    }
-
-                    var contentwidth = parseInt(this.overlay.get('width'));
-                    var overlayalign = 'right';
-                    if (document.getElementById('page').offsetWidth <= (positionX + contentwidth )) {
-                        overlayalign = 'left';                        
-                    }
-
-                    var WidgetPositionAlign = Y.WidgetPositionAlign;
-                    if (overlayalign == 'right') {
-                        this.overlay.set("align", {node:"#" + node['id'],
-                          points:[WidgetPositionAlign.TL, WidgetPositionAlign.RC]});
-                    } else {
-                        this.overlay.set("align", {node:"#" + node['id'],
-                          points:[WidgetPositionAlign.TR, WidgetPositionAlign.LC]});
-                    }
-                    
-                    var fullurl = node.url;
-                    if (!node.url.match(/https?:\/\//)) {
-                        fullurl = M.cfg.wwwroot + node.url;
-                    }
-                    
                     var ajaxurl = fullurl + '&ajax=1';
-                    thishelpcontent = this;
                     
                     var cfg = {
                         method: 'get',
+                            context : this,
                         on: {
                             success: function(id, o, node) {
-                                thishelpcontent.load_from_openpopup_callback(o.responseText);                                
+                                    this.display_callback(o.responseText);
                             },
                             failure: function(id, o, node) {
                                 var debuginfo = o.statusText;
                                 if (M.cfg.developerdebug) {
                                     o.statusText += ' (' + ajaxurl + ')';
                                 }                                
-                                thishelpcontent.load_from_openpopup_callback('bodyContent',debuginfo);
+                                    this.display_callback('bodyContent',debuginfo);
                             }
                         }
                     };
                     
-                    var conn = Y.io(ajaxurl, cfg);
+                        Y.io(ajaxurl, cfg);
                     this.overlay.show();
                 },
                 
-                load_from_openpopup_callback : function(content) {                                                            
+                    display_callback : function(content) {
                     this.overlay.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
                 },
                 
@@ -1590,8 +1492,14 @@
                 }                
             }
             help_content_overlay.init();
-            M.help_content.instance = help_content_overlay;
-            
+                M.util.help_icon.instance = help_content_overlay;
+                M.util.help_icon.instance.display(event, args);
         });
+        } else {
+            M.util.help_icon.instance.display(event, args);
     }
+    },
+    init : function(Y) {                
+        this.Y = Y;
 }
+}
Index: moodle/lib/outputactions.php
--- moodle/lib/outputactions.php Base (1.11)
+++ moodle/lib/outputactions.php Locally Modified (Based On 1.11)
@@ -96,6 +96,9 @@
  * @since     Moodle 2.0
  */
 class popup_action extends component_action {
+
+    public $jsfunction = 'openpopup';
+
     /**
      * @var array $params An array of parameters that will be passed to the openpopup JS function
      */
@@ -145,11 +148,8 @@
         }
         
         $attributes = array('url' => $url->out(false), 'name' => $name, 'options' => $this->get_js_options($params));
-        if (array_key_exists('id', $params)) {
-            $attributes['id'] = $params['id'];
+        parent::__construct($event, $this->jsfunction, $attributes);
         }
-        parent::__construct($event, 'openpopup', $attributes);
-    }
 
     /**
      * Returns a string of concatenated option->value pairs used by JS to call the popup window,
@@ -173,4 +173,3 @@
         return $jsoptions;
     }
 }
-
Index: moodle/lib/outputrenderers.php
--- moodle/lib/outputrenderers.php Base (1.188)
+++ moodle/lib/outputrenderers.php Locally Modified (Based On 1.188)
@@ -623,10 +623,6 @@
 
         $output = $this->container_end_all(true);
 
-        $helpcontent_body = html_writer::tag('div',  '<button class="closehelpbutton" type="button" id="hide"><img src="'.$this->pix_url('t/delete').'" alt="close" /></button>', array('class'=>'helpcontent_body'));
-        $output .= html_writer::tag('div', $helpcontent_body, array('id'=>'helpcontent', 'class'=>'yui3-overlay-loading'));       
-        $this->page->requires->js_init_call('M.help_content.init');
-        
         $footer = $this->opencontainers->pop('header/footer');
 
         if (debugging() and $DB and $DB->is_transaction_started()) {
@@ -650,7 +646,6 @@
 
         $this->page->set_state(moodle_page::STATE_DONE);
       
-
         return $output . $footer;
     }
 
@@ -1527,9 +1522,10 @@
         $attributes = array('href'=>$url, 'title'=>$title);
         $id = html_writer::random_id('helpicon');
         $attributes['id'] = $id;
-        $this->add_action_handler(new popup_action('click', $url, 'popup', array('id'=>$id)), $id);
         $output = html_writer::tag('a', $output, $attributes);
 
+        $this->page->requires->js_init_call('M.util.help_icon.add', array(array('id'=>$id, 'url'=>$url->out(false))));
+
         // and finally span
         return html_writer::tag('span', $output, array('class' => 'helplink'));
     }
Index: moodle/lib/outputrequirementslib.php
--- moodle/lib/outputrequirementslib.php Base (1.24)
+++ moodle/lib/outputrequirementslib.php Locally Modified (Based On 1.24)
Index: moodle/theme/base/style/core.css
--- moodle/theme/base/style/core.css Base (1.22)
+++ moodle/theme/base/style/core.css Locally Modified (Based On 1.22)
@@ -538,10 +538,8 @@
 /**
  * Help Content (pop-up)
  */
-#helpcontent { background-color: #FFE691; border: 1px solid #848484; z-index: 10; }
-#show { margin-left:5px; padding:0; }
-#hide { float: right; }
-.closehelpbutton { border: none; background: none; }
-.yui3-js-enabled .yui3-overlay-loading { top:-1000em; left:-1000em; position:absolute; display: none; }
-.yui3-widget-bd { float: none; clear: both; margin: 1em;}
-#helpcontent .helpheading {font-size: 1em;}
+ .helppopup {background-color: #FFE691; border: 1px solid #848484;}
+ .helppopup .yui3-widget-hd {float:right;margin:3px 3px 0 0;}
+ .helppopup .yui3-widget-bd {margin:0 1em 1em 1em;border-top:1px solid #FFE691;}
+ .helppopup .helpheading {font-size: 1em;}
+ .helppopup .spinner {margin:1em;}
