Permalink
Browse files

Fixed up dropdown menu

  • Loading branch information...
1 parent cea6251 commit 11aa2c99f49116a255ebbc5fd38d497c6b9bc8e1 @hofmeister committed Feb 15, 2014
Showing with 12 additions and 17 deletions.
  1. +2 −2 js/lib/core.js
  2. +10 −15 js/lib/widget.js
View
@@ -1443,7 +1443,7 @@ if (!$wbConfig.noCSS) {
* @param callback receives value as first argument and key as second (if this is a map)
* @return {mixed) returns true or the first value returned from callback (which stops it)¡
*/
- $wb.each = function(obj,callback) {
+ $wb.each = function(obj,callback, includeFunctions) {
var i,key,result;
if (!obj) {
return undefined;
@@ -1475,7 +1475,7 @@ if (!$wbConfig.noCSS) {
for(key in obj) {
if (obj.hasOwnProperty(key)
- && typeof obj[key] !== 'function') {
+ && (includeFunctions || typeof obj[key] !== 'function')) {
result = callback(obj[key],key);
if (result !== undefined) {
return result;
View
@@ -2162,35 +2162,30 @@ $wb.ui.DropdownMenu = $wb.Class('DropdownMenu', {
vertical: true
},
_element: null,
+ _boundHide: null,
__construct: function (opts) {
opts = this.getDefaults(opts);
this.__super(opts);
- $wb.ui.ContextMenu.init();
-
this.bind('detach', function () {
- if (this._element) {
- this._element.unbind('click', $wb.ui.ContextMenu.hide);
- this._element.removeClass('wb-active');
+ if (this._element && this._boundHide) {
+ this._element.unbind('click', this._boundHide);
}
});
+
},
render: function (element) {
- if (!element) throw _("ContextMenu requires first argument to render to be an event");
+ if (!element) throw _("Dropdown menu requires first argument for render to be an element");
this._element = element;
- $wb.ui.ContextMenu.hide();
+
var elm = this.elm();
- elm.addClass($wb.ui.ContextMenu.id);
- element.addClass('wb-active');
+
$('body').append(elm);
elm.html('');
- //elm.bindOnce('click',$wb.ui.ContextMenu.hide);
-
- if (this._element) {
- this._element.bindOnce('click', $wb.ui.ContextMenu.hide);
- }
-
+ this._boundHide = this.detach.bind(this);
+ this._element.bindOnce('click', this._boundHide);
+ element.addClass('wb-active');
var out = this.__super();
var css = element.offset();

0 comments on commit 11aa2c9

Please sign in to comment.