From 75bee64b1d63455b9369d70c3f0d79c7062fa521 Mon Sep 17 00:00:00 2001 From: Yanick Rochon Date: Fri, 7 Feb 2014 23:00:18 -0500 Subject: [PATCH] Draft to resolve issue #41 and may affect #86 as well. --- css/jquery.uix.multiselect.css | 14 +- index.html | 8 +- js/jquery.uix.multiselect.js | 271 +++++++++++++++++++++++++++------ 3 files changed, 240 insertions(+), 53 deletions(-) diff --git a/css/jquery.uix.multiselect.css b/css/jquery.uix.multiselect.css index df2354f..9f1c972 100644 --- a/css/jquery.uix.multiselect.css +++ b/css/jquery.uix.multiselect.css @@ -1,15 +1,16 @@ -.uix-multiselect-original { position: absolute; left:-999999px; } -.uix-multiselect { position: relative; float:left; } -.uix-multiselect .multiselect-selected-list, .uix-multiselect .multiselect-available-list { position:absolute; overflow:hidden; } +.uix-multiselect-original { position: absolute; left:999999px; } +.uix-multiselect { position: relative; display:inline-block; } +.uix-multiselect .uix-selected-list, +.uix-multiselect .uix-available-list { position:absolute; overflow:hidden; } .uix-multiselect .ui-widget-header { overflow:hidden; white-space:nowrap; padding:2px 4px; } .uix-multiselect .ui-widget-header div.header-text { white-space: nowrap; } .uix-multiselect .ui-widget-header .uix-control-right, .uix-multiselect .ui-widget-header .uix-control-left { width:16px; height:16px; } .uix-multiselect .ui-widget-header .uix-control-right { float:right; } .uix-multiselect .ui-widget-header .uix-control-left { float:left; } .uix-multiselect .ui-widget-header .uix-search { float:right; height:14px; font-size:80%; } -.uix-multiselect .uix-list-container { position:relative; overflow:auto; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } +.uix-multiselect .uix-list-container { position:relative; height:100%; overflow:auto; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .uix-multiselect .uix-list-container .ui-priority-secondary { padding-right:0; } .uix-multiselect .group-element { position:relative; padding-left:0; white-space:nowrap; overflow:hidden; } .uix-multiselect .group-element-collapsable { padding-left:16px; } @@ -22,3 +23,8 @@ .dragged-grouped-element { padding-left:16px; } .uix-multiselect .grouped-option { position:relative; padding-left:16px } .uix-multiselect .grouped-option .ui-icon { position:absolute; left:0; } + +.uix-multiselect .uix-table { width:100%; height:100%; table-layout:fixed; } +.uix-multiselect .uix-table tr { vertical-align:top; } +.uix-multiselect .uix-table tbody td { position:relative; } +.uix-multiselect .uix-table td.uix-table-row { border:none; margin:0; padding:0; } diff --git a/index.html b/index.html index 5dec98d..95e4cff 100644 --- a/index.html +++ b/index.html @@ -157,7 +157,7 @@

Welcome to the jQuery Multiselect 2.0 Widget !

Simple usage

-
+
@@ -527,7 +527,7 @@

Disabled options

Group related options

-
+
diff --git a/js/jquery.uix.multiselect.js b/js/jquery.uix.multiselect.js index 9530f06..2f0217f 100644 --- a/js/jquery.uix.multiselect.js +++ b/js/jquery.uix.multiselect.js @@ -76,9 +76,10 @@ this.element.addClass('uix-multiselect-original'); this._elementWrapper = $('
').addClass('uix-multiselect ui-widget') + /* .css({ - width: this.element.css('width'), - height: this.element.css('height') + width: this.element[0].style.width || this.element.css('width'), + height: this.element[0].style.height || this.element.css('height') }) .append( $('
').addClass('multiselect-selected-list') @@ -109,9 +110,11 @@ ) .append( avListContent = $('
').addClass('uix-list-container ui-widget-content') ) ) + */ .insertAfter(this.element) ; + /* this._buttons = { 'selectAll': btnSelectAll, 'deselectAll': btnDeselectAll @@ -124,12 +127,16 @@ 'selected': selListContent.attr('id', this.scope+'_selListContent'), 'available': avListContent.attr('id', this.scope+'_avListContent') }; + */ + this._lists = { + 'selected': this._initList(this.scope+'_selListContent', 'deselectAll', 'selected', false), + 'available': this._initList(this.scope+'_avListContent', 'selectAll', 'available', true), + 'buttonSearch': this._initSearchable() + }; this.optionCache = new OptionCache(this); this._searchDelayed = new SearchDelayed(this); - this._initSearchable(); - this._applyListDroppable(); this.refresh(this.options.created); @@ -150,7 +157,7 @@ * @param callback function a callback function called when the refresh is complete */ refresh: function(callback) { - this._resize(); // just make sure we display the widget right without delay + this._doLayout(); // just make sure we display the widget right without delay asyncFunction(function() { this.optionCache.cleanup(); @@ -201,7 +208,8 @@ } if ((options.toggleInput != false) && !this._searchField.is(':visible')) { - this._buttons.search.trigger('click'); + //this._buttons.search.trigger('click'); + this._lists.buttonSearch.trigger('click'); } this._search(options.text, !!options.silent); @@ -226,8 +234,8 @@ _destroy: function() { this.optionCache.reset(true); - this._lists['selected'].empty().remove(); - this._lists['available'].empty().remove(); + this._lists['selected'].listContent.empty().remove(); + this._lists['available'].listContent.empty().remove(); this._elementWrapper.empty().remove(); delete this.optionCache; @@ -244,44 +252,100 @@ * *************************************** */ + _initList: function(id, key, side, selectAll) { + var that = this; + var obj = {}; + + obj.listHeader = $('
').addClass('ui-widget-header') + .append( obj.buttonApplyAll = $('', { + 'type': 'button', + 'data-localekey': key, + 'title': this._t(key) + }).addClass('uix-control-right') + .button({icons:{primary:'ui-icon-arrowthickstop-2-e-w'}, text:false}) + .click(function(e) { e.preventDefault(); e.stopPropagation(); that.optionCache.setSelectedAll(selectAll); return false; }) + [('both,'+side).indexOf(this.options.selectAll)>=0 ? 'show' : 'hide']() + ) + .append( obj.labelHeader = $('
').addClass('header-text') ) + ; + obj.listContent = $('
', { id: id }).addClass('uix-list-container uix-' + side + '-list ui-widget-content'); + + return obj; + }, + _initSearchable: function() { + /* var isToggle = ('toggle' === this.options.searchField); - var searchHeader = this.options.searchHeader; + //var searchHeader = this.options.searchHeader; if (isToggle) { var that = this; - this._buttons['search'] = $('