Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions lib/FSelectMenu/Bundle/Resources/public/js/modules/fselectmenu.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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')) {
Expand Down Expand Up @@ -133,8 +144,16 @@ define(function() {

var root = this._root
, offset = root.offset()
, height = root.outerHeight()
, width = root.outerWidth();
, 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'
Expand Down Expand Up @@ -358,4 +377,5 @@ define(function() {
return {
init: init
};
});
}));