# 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/blocks/community/forms.php
--- moodle/blocks/community/forms.php Base (1.5)
+++ moodle/blocks/community/forms.php Locally Modified (Based On 1.5)
@@ -97,10 +97,11 @@
             }
         }
         $options = array_merge (array('all' => get_string('any')),$options);
-        $mform->addElement('select', 'subject', get_string('subject', 'hub'), $options);
+        $mform->addElement('select', 'subject', get_string('subject', 'hub'), $options, array('id'=>'communitysubject'));
         $mform->setDefault('subject', 'all');
         unset($options);
         $mform->addHelpButton('subject', 'subject', 'hub');
+        $this->init_javascript_enchancement('subject', 'smartselect', array('selectablecategories' => false));
 
         require_once($CFG->dirroot."/lib/licenselib.php");
         $licensemanager = new license_manager();
Index: moodle/lib/formslib.php
--- moodle/lib/formslib.php Base (1.208)
+++ moodle/lib/formslib.php Locally Modified (Based On 1.208)
@@ -94,7 +94,7 @@
     /**
      * quickform object definition
      *
-     * @var object MoodleQuickForm
+     * @var MoodleQuickForm MoodleQuickForm
      */
     protected $_form;
     /**
@@ -992,7 +992,38 @@
             $mform->closeHeaderBefore('submitbutton');
         }
     }
+
+    /**
+     * Adds an initialisation call for a standard JavaScript enchancement.
+     *
+     * This function is designed to add an initialisation call for a JavaScript
+     * enhancment that should exist within javascript-static M.form.init_{enhancementname}.
+     *
+     * Current options:
+     *  - Selectboxes
+     *      - smartselect:  Turns a nbsp indented select box into a custom drop down
+     *                      control that supports multilevel and category selection.
+     *                      $enhancement = 'smartselect';
+     *                      $options = array('selectablecategories' => true|false)
+     *
+     * @since 2.0
+     * @param string|element $element
+     * @param string $enhancement
+     * @param array $options
+     */
+    function init_javascript_enchancement($element, $enhancement, $options) {
+        global $PAGE;
+
+        if (is_string($element)) {
+            $element = $this->_form->getElement($element);
 }
+        if (is_object($element)) {
+            $element->_generateId();
+            $elementid = $element->getAttribute('id');
+            $PAGE->requires->js_init_call('M.form.init_'.$enhancement, array($elementid, $options));
+        }
+    }
+}
 
 /**
  * You never extend this class directly. The class methods of this class are available from
Index: moodle/lib/javascript-static.js
--- moodle/lib/javascript-static.js Base (1.150)
+++ moodle/lib/javascript-static.js Locally Modified (Based On 1.150)
@@ -1543,3 +1543,149 @@
         }
     }
 }
+
+/**
+ * Used to store form manipulation methods and enhancments
+ */
+M.form = M.form || {};
+
+/**
+ * Converts a nbsp indented select box into a multi drop down custom control much
+ * like the custom menu. It also selectable categories on or off.
+ *
+ * $form->init_javascript_enhancement('elementname','smartselect', array('selectablecategories'=>true|false));
+ *
+ * @param {YUI} Y
+ * @param {string} id
+ * @param {Array} options
+ */
+M.form.init_smartselect = function(Y, id, options) {
+    var loading = Y.Node.create('<div class="smartselect_loading"><div>Loading...</div></div>');
+    var select = Y.one('select#id_'+id);
+    if (!select) {
+        return false;
+    }
+    loading.setStyle('width', select.get('offsetWidth')+'px');
+    select.addClass('smartselect_disappear');
+    select.ancestor().insert(loading, select);
+    Y.use('node-menunav','event-delegate',function(){
+        var smartselect = {
+            Y: null,
+            id : null,
+            structure : [],
+            options : [],
+            submenucount : 0,
+            currentvalue : 'any',
+            currenttext : 'Any',
+            cfg : {
+                selectablecategories : true
+            },
+            nodes : {
+                select : null,
+                loading : null,
+                menu : null
+            },
+            init : function(Y, id, args, nodes) {
+
+                if (typeof(args)=='object') {
+                    for (var i in this.cfg) {
+                        if (args[i] || args[i]===false) {
+                            this.cfg[i] = args[i];
+                        }
+                    }
+                }
+
+                this.Y = Y;
+                this.id = id;
+
+                // Display a loading message first up
+                this.nodes.loading = nodes.loading;
+                this.nodes.select = nodes.select;
+
+                this.currentvalue = this.nodes.select.get('selectedIndex');
+                this.currenttext = this.nodes.select.all('option').item(this.currentvalue).get('innerHTML');
+
+                var options = Array();
+                options[''] = {text:this.currenttext,value:'',depth:0,children:[]}
+                this.nodes.select.all('option').each(function(option, index) {
+                    var rawtext = option.get('innerHTML');
+                    var text = rawtext.replace(/^(&nbsp;)*/, '');
+                    var depth = ((rawtext.length - text.length )/12)+1;
+                    option.set('innerHTML', text);
+                    options['i'+index] = {text:text,depth:depth,index:index,children:[]};
+                }, this);
+
+                this.structure = [];
+                for (var i in options) {
+                    var o = options[i];
+                    if (o.depth == 0) {
+                        this.structure.push(o);
+                    } else {
+                        var d = o.depth;
+                        var current = this.structure[this.structure.length-1];
+                        for (var j = 0; j < o.depth-1;j++) {
+                            current = current.children[current.children.length-1];
+                        }
+                        if (current && current.children) {
+                            current.children.push(o);
+                        }
+                    }
+                }
+                this.nodes.menu = Y.Node.create(this.parse());
+                this.nodes.menu.one('.selectimitation').setStyle('width', this.nodes.select.get('offsetWidth')+'px');
+                this.nodes.loading.replace(this.nodes.menu);
+                this.nodes.menu.all('.selectable').on("click", this.check_click, this);
+                this.nodes.menu.one('#'+this.id+'_smartselect_menu').plug(Y.Plugin.NodeMenuNav, { autoSubmenuDisplay: false, mouseOutHideDelay: 0 });
+            },
+            parse : function() {
+                var content = '<div id="'+this.id+'_smartselect" class="smartselect">';
+                content += '<div id="'+this.id+'_smartselect_menu" class="yui3-menu yui3-menu-horizontal"><div class="yui3-menucontent"><ul>';
+                content += this.parse_submenu(this.structure[0], true);
+                content += '</ul></div></div></div>';
+                return content;
+            },
+            parse_submenu : function(item, rootelement) {
+                this.submenucount++;
+                var content = '';
+                if (item.children.length > 0) {
+                    content += '<li>';
+                    if (rootelement) {
+                        content += '<a class="yui3-menu-label smartselect_label" href="#ss_submenu'+this.submenucount+'" id="'+this.id+'_smartselect_label"><div class="selectimitation"><span class="text">'+item.text+'</span></div></a>';
+                        content += '<div id="ss_submenu'+this.submenucount+'" class="yui3-menu smartselect_rootmenu">';
+                    } else {
+                        var categoryclass = (this.cfg.selectablecategories)?'selectable':'notselectable';
+                        content += '<a class="yui3-menu-label '+categoryclass+'" href="#ss_submenu'+this.submenucount+'" value="'+item.index+'">'+item.text+'</a>';
+                        content += '<div id="ss_submenu'+this.submenucount+'" class="yui3-menu">';
+                    }
+                    content += '<div class="yui3-menu-content">';
+                    content += '<ul>';
+                    for (var i in item.children) {
+                        content += this.parse_submenu(item.children[i],false);
+                    }
+                    content += '</ul>';
+                    content += '</div>';
+                    content += '</div>';
+                    content += '</li>';
+                } else {
+                    content += '<li class="yui3-menuitem">';
+                    content += '<a class="yui3-menuitem-content selectable" href="#" value="'+item.index+'">'+item.text+'</a>';
+                    content += '</li>';
+                }
+                return content;
+            },
+            check_click : function(e) {
+                var t = e.target;
+                if (t.hasClass('selectable')) {
+                    e.preventDefault();
+                    this.currenttext = t.get('innerHTML');
+                    this.currentvalue = t.getAttribute('value');
+                    this.nodes.menu.one('#'+this.id+'_smartselect_label .selectimitation .text').replace(this.Y.Node.create('<span class="text">'+this.currenttext+'</text>'));
+                    var menu = this.nodes.menu.one('#'+this.id+'_smartselect_menu');
+                    menu.menuNav._hideAllSubmenus(menu);
+                    this.nodes.select.set('selectedIndex', this.currentvalue);
+                }
+            }
+        }
+        smartselect.init(Y, id, options, {loading:loading,select:select});
+    });
+}
Index: moodle/pix/i/smartselect.gif
MIME: application/octet-stream; encoding: Base64; length: 110
R0lGODlhEQASAMIHAAAAAAoKCTU0MWBdWNLPytnSx/n49v///yH5BAEKAAcA
LAAAAAARABIAAAMzeLrcasVJVcyU9bqsGe+UBYYLMDAD4IkHYSopsTKuIATy
TANArtO+H+gzZBVHjwhyqUgAADs=
Index: moodle/theme/base/style/core.css
--- moodle/theme/base/style/core.css Base (1.27)
+++ moodle/theme/base/style/core.css Locally Modified (Based On 1.27)
@@ -556,3 +556,5 @@
 #custommenu .yui3-menu-horizontal.javascript-disabled>.yui3-menu-content>ul:after {content:"";display:block;clear:both;line-height:0;font-size:0;visibility:hidden;}
 #custommenu .yui3-menu-horizontal.javascript-disabled .yui3-menu-content {font-size:93%;line-height:2;padding:0;}
 #custommenu .yui3-menu-horizontal.javascript-disabled .yui3-menu-content .yui3-menu-content {font-size:100%;}
+
+.smartselect_disappear {position:absolute;visibility: hidden;top:0;right:10000px;}
Index: moodle/theme/standard/style/core.css
--- moodle/theme/standard/style/core.css Base (1.6)
+++ moodle/theme/standard/style/core.css Locally Modified (Based On 1.6)
@@ -410,3 +410,17 @@
 #custommenu .yui3-menu .yui3-menuitem-active {background-color:#e1e1df;}
 #custommenu .yui3-menu-horizontal.javascript-disabled a {color:inherit;}
 #custommenu .yui3-menu-horizontal.javascript-disabled a:hover {color:blue;text-decoration:none;}
+
+/**
+ * Smart select element
+ */
+.smartselect_loading {background-image:url([[pix:theme|hgradient]]);margin:0;}
+.smartselect_loading div {border:1px solid #988f83;padding:1px 20px 1px 5px;}
+.smartselect .yui3-menu-horizontal .yui3-menu-label.smartselect_label {padding:0;border-width:1px;}
+.smartselect .yui3-menu-horizontal .yui3-menu-label.smartselect_label {background-image:url([[pix:theme|hgradient]]);margin:0;}
+.smartselect .selectimitation {border:0px solid #988f83;padding:1px 20px 1px 5px;margin:0;background-image: url([[pix:moodle|i/smartselect]]);background-repeat:no-repeat;background-position: 100% 100%;}
+.smartselect .yui3-menu-horizontal .yui3-menu-label.notselectable {color:#555;}
+.gecko .smartselect .yui3-menu-horizontal .yui3-menu-label.smartselect_label {border:1px solid #ded7cd;}
+.gecko .smartselect .selectimitation {border-width:1px;}
+.gecko .smartselect_loading {border:1px solid #ded7cd;}
+.safari .smartselect {margin:2px;}
Index: moodle/theme/standard/style/css3.css
--- moodle/theme/standard/style/css3.css Base (1.2)
+++ moodle/theme/standard/style/css3.css Locally Modified (Based On 1.2)
@@ -237,3 +237,8 @@
     -webkit-border-radius: 0.2em;
     border-radius: 0.2em;
 }
+
+.smartselect .yui3-menu-horizontal .yui3-menu-label.smartselect_label,
+.smartselect .selectimitation,
+.smartselect_loading,
+.smartselect_loading div {-webkit-border-radius: 3px;-moz-border-radius:4px;}
