// pre-select labels
if ($.getLength(selectedLabelIDs)) {
for (var $groupID in selectedLabelIDs) {
- this._groups[$groupID].find('.dropdownMenu > li').each($.proxy(function(index, label) {
+ WCF.Dropdown.getDropdownMenu(this._groups[$groupID].wcfIdentify()).children('li').each($.proxy(function(index, label) {
var $label = $(label);
var $labelID = $label.data('labelID') || 0;
if ($labelID && selectedLabelIDs[$groupID] == $labelID) {
if (!this._groups[$groupID]) {
this._groups[$groupID] = $group;
- var $dropdownMenu = $group.find('.dropdownMenu');
- $dropdownMenu.find('li').click($.proxy(this._click, this));
+ var $dropdownMenu = WCF.Dropdown.getDropdownMenu($group.wcfIdentify());
+ $dropdownMenu.children('li').data('groupID', $groupID).click($.proxy(this._click, this));
if (!$group.data('forceSelection') || this._showWithoutSelection) {
$('<li class="dropdownDivider" />').appendTo($dropdownMenu);
}
if (this._showWithoutSelection) {
- $('<li data-label-id="-1"><span><span class="badge label">' + WCF.Language.get('wcf.label.withoutSelection') + '</span></span></li>').appendTo($dropdownMenu).click($.proxy(this._click, this));
+ $('<li data-label-id="-1"><span><span class="badge label">' + WCF.Language.get('wcf.label.withoutSelection') + '</span></span></li>').data('groupID', $groupID).appendTo($dropdownMenu).click($.proxy(this._click, this));
}
if (!$group.data('forceSelection')) {
- var $buttonEmpty = $('<li data-label-id="0"><span><span class="badge label">' + WCF.Language.get('wcf.label.none') + '</span></span></li>').appendTo($dropdownMenu);
+ var $buttonEmpty = $('<li data-label-id="0"><span><span class="badge label">' + WCF.Language.get('wcf.label.none') + '</span></span></li>').data('groupID', $groupID).appendTo($dropdownMenu);
$buttonEmpty.click($.proxy(this._click, this));
}
}
* @param boolean onInit
*/
_selectLabel: function(label, onInit) {
- var $group = label.parents('.dropdown');
+ var $group = this._groups[label.data('groupID')];
// already initialized, ignore
if (onInit && $group.data('labelID') !== undefined) {
/**
* Forces message options to stay visible if toggling dropdown menu.
*
- * @param jQuery dropdown
+ * @param string containerID
* @param string action
*/
- _toggleDropdown: function(dropdown, action) {
- dropdown.parents('.messageOptions').toggleClass('forceOpen');
+ _toggleDropdown: function(containerID, action) {
+ WCF.Dropdown.getDropdown(containerID).parents('.messageOptions').toggleClass('forceOpen');
},
/**
}
},
+ /**
+ * Initializes a dropdown fragment which behaves like a usual dropdown
+ * but is not controlled by a trigger element.
+ *
+ * @param jQuery dropdown
+ * @param jQuery dropdownMenu
+ */
+ initDropdownFragment: function(dropdown, dropdownMenu) {
+ var $containerID = dropdown.wcfIdentify();
+ if (this._dropdowns[$containerID]) {
+ console.debug("[WCF.Dropdown] Cannot register dropdown identified by '" + $containerID + "' as a fragement.");
+ return;
+ }
+
+ this._dropdowns[$containerID] = dropdown;
+ this._menus[$containerID] = dropdownMenu.detach().appendTo(this._menuContainer);
+ },
+
/**
* Registers a callback notified upon dropdown state change.
*
}
}
- event.stopPropagation();
- return false;
+ if (event !== null) {
+ event.stopPropagation();
+ return false;
+ }
},
/**
}
this._searchInput.blur($.proxy(this._blur, this));
+
+ WCF.Dropdown.initDropdownFragment(this._searchInput.parent(), this._list);
},
/**