From c1b56599cf94e020be6a5d1366e26422539b833b Mon Sep 17 00:00:00 2001 From: tumbochka Date: Thu, 17 Sep 2015 14:17:43 +0300 Subject: [PATCH 1/2] fixing the issue with incorect menu placement --- .../public/js/modules/fselectmenu.js | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/lib/FSelectMenu/Bundle/Resources/public/js/modules/fselectmenu.js b/lib/FSelectMenu/Bundle/Resources/public/js/modules/fselectmenu.js index ca03dcb..2d7c11e 100644 --- a/lib/FSelectMenu/Bundle/Resources/public/js/modules/fselectmenu.js +++ b/lib/FSelectMenu/Bundle/Resources/public/js/modules/fselectmenu.js @@ -1,13 +1,23 @@ -/** - * - init() has to be called only one time for the life of the page; - * newly inserted select menus will automatically be handled without - * having to call init() again. - * - init() is very lightweight, it only set up a few event handlers - * - script can work directly with the native element for most things (e.g. - * getting and changing the value) - */ -define(function() { + + +(function( root,factory ) { + if ( typeof define === "function" && define.amd ) { + + // AMD. Register as an anonymous module. + define([], factory ); + + + } else if (typeof exports === "object") { + // Node/CommonJS: + factory(); + + } else { + + // Browser globals + root.FSelectMenu = factory( ); + } +}(this, function() { var namespace = 'fselectmenu'; @@ -42,6 +52,7 @@ define(function() { selectOption: function($elem) { // .data() tries to convert the value to number this._input.val($elem.attr('data-value')).change(); + $('.fselectmenu-label').html($elem.html()); } , disabled: function() { if (this._input.prop('disabled')) { @@ -133,8 +144,10 @@ define(function() { var root = this._root , offset = root.offset() - , height = root.outerHeight() - , width = root.outerWidth(); + , height = root.outerHeight().height() + , width = root.outerWidth().width(); + + this._options.css({ 'minWidth': width+'px' @@ -358,4 +371,4 @@ define(function() { return { init: init }; -}); +})); From b99d28c2f7a41750e8d2dbd9ad64c77cd0de4a7f Mon Sep 17 00:00:00 2001 From: tumbochka Date: Tue, 22 Sep 2015 14:36:14 +0300 Subject: [PATCH 2/2] Updating fselectmenu.js to work with all jquery versions --- .../Resources/public/js/modules/fselectmenu.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/FSelectMenu/Bundle/Resources/public/js/modules/fselectmenu.js b/lib/FSelectMenu/Bundle/Resources/public/js/modules/fselectmenu.js index 2d7c11e..ad24032 100644 --- a/lib/FSelectMenu/Bundle/Resources/public/js/modules/fselectmenu.js +++ b/lib/FSelectMenu/Bundle/Resources/public/js/modules/fselectmenu.js @@ -144,10 +144,16 @@ var root = this._root , offset = root.offset() - , height = root.outerHeight().height() - , width = root.outerWidth().width(); - + , height = root.outerHeight() + , width = root.outerWidth() + if (typeof height != "number") { + height = height.height(); + } + if (typeof width != "number") { + width = width.width(); + } + this._options.css({ 'minWidth': width+'px' @@ -372,3 +378,4 @@ init: init }; })); +