From 1b8002bccdc43bcbe3de7ce8293f48781f871928 Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Mon, 26 Nov 2018 10:55:38 -0200 Subject: [PATCH 01/14] Update jquery.bootstrap-duallistbox.js --- src/jquery.bootstrap-duallistbox.js | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/jquery.bootstrap-duallistbox.js b/src/jquery.bootstrap-duallistbox.js index 10b64a1..a1f083a 100644 --- a/src/jquery.bootstrap-duallistbox.js +++ b/src/jquery.bootstrap-duallistbox.js @@ -50,7 +50,8 @@ btnMoveText: '>', // string, sets the text for the "Move" button btnRemoveText: '<', // string, sets the text for the "Remove" button btnMoveAllText: '>>', // string, sets the text for the "Move All" button - btnRemoveAllText: '<<' // string, sets the text for the "Remove All" button + btnRemoveAllText: '<<', // string, sets the text for the "Remove All" button + reversedBoxes: false // boolean, puts box1(non-selecetd) on the right and box2(selected) on the left }, // Selections are invisible on android if the containing select is styled with CSS // http://code.google.com/p/android/issues/detail?id=16922 @@ -468,6 +469,7 @@ this.setNonSelectedListLabel(this.settings.nonSelectedListLabel); this.setHelperSelectNamePostfix(this.settings.helperSelectNamePostfix); this.setSelectOrMinimalHeight(this.settings.selectorMinimalHeight); + this.setReversedBoxes(this.settings.reversedBoxes); updateSelectionStates(this); @@ -811,6 +813,32 @@ } return this.element; }, + setReversedBoxes: function(value,refresh){ + this.settings.reversedBoxes = value; + if (value){ + if(!$(this.elements.box2).after().hasClass('box1')){ + $(this.elements.box2).insertBefore($(this.elements.box1)); + $(this.elements.box2).find('.remove').insertAfter($(this.elements.box2).find('.removeall')); + $(this.elements.box2).find('.glyphicon-arrow-left').removeClass('glyphicon-arrow-left').addClass('glyphicon-arrow-right'); + $(this.elements.box1).find('.move').insertBefore($(this.elements.box1).find('.moveall')); + $(this.elements.box1).find('.glyphicon-arrow-right').removeClass('glyphicon-arrow-right').addClass('glyphicon-arrow-left'); + } + } + else{ + if(!$(this.elements.box2).before().hasClass('box1')){ + $(this.elements.box1).insertBefore($(this.elements.box2)); + $(this.elements.box2).find('.removeall').insertAfter($(this.elements.box2).find('.remove')); + $(this.elements.box2).find('.glyphicon-arrow-right').removeClass('glyphicon-arrow-right').addClass('glyphicon-arrow-left'); + $(this.elements.box1).find('.moveall').insertBefore($(this.elements.box1).find('.move')); + $(this.elements.box1).find('.glyphicon-arrow-left').removeClass('glyphicon-arrow-left').addClass('glyphicon-arrow-right'); + } + } + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + getContainer: function() { return this.container; }, From efba17fac6ecd4e515779e39e7913922841268e8 Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Tue, 11 Dec 2018 10:39:54 -0200 Subject: [PATCH 02/14] changed version of node.js to current --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 20fd86b..d75e42b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,3 @@ language: node_js node_js: - - 0.10 + - 11.4.0 From 3e71d86fd90c1df3ec9867803d845a517b5d593b Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Tue, 11 Dec 2018 10:45:30 -0200 Subject: [PATCH 03/14] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 20fd86b..d75e42b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,3 @@ language: node_js node_js: - - 0.10 + - 11.4.0 From 16fdc517ff75c0e0e24bf0ea29f5df1bfac2be79 Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Tue, 11 Dec 2018 11:19:56 -0200 Subject: [PATCH 04/14] Update jquery.bootstrap-duallistbox.js --- src/jquery.bootstrap-duallistbox.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/jquery.bootstrap-duallistbox.js b/src/jquery.bootstrap-duallistbox.js index a1f083a..475b58e 100644 --- a/src/jquery.bootstrap-duallistbox.js +++ b/src/jquery.bootstrap-duallistbox.js @@ -817,20 +817,24 @@ this.settings.reversedBoxes = value; if (value){ if(!$(this.elements.box2).after().hasClass('box1')){ + classbox1 = $(this.elements.box1).find('.move i').attr('class'); + classbox2 = $(this.elements.box2).find('.remove i').attr('class'); $(this.elements.box2).insertBefore($(this.elements.box1)); $(this.elements.box2).find('.remove').insertAfter($(this.elements.box2).find('.removeall')); - $(this.elements.box2).find('.glyphicon-arrow-left').removeClass('glyphicon-arrow-left').addClass('glyphicon-arrow-right'); + $(this.elements.box2).find('.remove i, .removeall i').removeClass(classbox2).addClass(classbox1); $(this.elements.box1).find('.move').insertBefore($(this.elements.box1).find('.moveall')); - $(this.elements.box1).find('.glyphicon-arrow-right').removeClass('glyphicon-arrow-right').addClass('glyphicon-arrow-left'); + $(this.elements.box1).find('.move i, moveall i').removeClass(classbox1).addClass(classbox2); } } else{ + classbox1 = $(this.elements.box1).find('.move i').attr('class'); + classbox2 = $(this.elements.box2).find('.remove i').attr('class'); if(!$(this.elements.box2).before().hasClass('box1')){ $(this.elements.box1).insertBefore($(this.elements.box2)); $(this.elements.box2).find('.removeall').insertAfter($(this.elements.box2).find('.remove')); - $(this.elements.box2).find('.glyphicon-arrow-right').removeClass('glyphicon-arrow-right').addClass('glyphicon-arrow-left'); + $(this.elements.box2).find('.remove i, removeall i').removeClass(classbox1).addClass(classbox2); $(this.elements.box1).find('.moveall').insertBefore($(this.elements.box1).find('.move')); - $(this.elements.box1).find('.glyphicon-arrow-left').removeClass('glyphicon-arrow-left').addClass('glyphicon-arrow-right'); + $(this.elements.box1).find('.remove i, removeall i').removeClass(classbox2).addClass(classbox1); } } if (refresh) { From 8108ab14b55faa0ab7f6ba8e727644cf731c7130 Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Wed, 23 Jan 2019 08:52:38 -0200 Subject: [PATCH 05/14] Provided the examples on the index page --- demo/index.html | 8 ++- desktop.ini | 4 ++ src/jquery.bootstrap-duallistbox.js | 97 ++++++++++++++++++++--------- 3 files changed, 80 insertions(+), 29 deletions(-) create mode 100644 desktop.ini diff --git a/demo/index.html b/demo/index.html index 4771101..322e73e 100644 --- a/demo/index.html +++ b/demo/index.html @@ -101,7 +101,13 @@

Example with custom settings

selectedListLabel: 'Selected', preserveSelectionOnMove: 'moved', moveOnSelect: false, - nonSelectedFilter: 'ion ([7-9]|[1][0-2])' + nonSelectedFilter: 'ion ([7-9]|[1][0-2])', + callbackMove: function(items){ + alert("Moved items: " + $.map(items,function(i){return i.text})); + }, + callbackRemove: function(items){ + alert("Removed items:" + $.map(items,function(i){return i.text})); + } }); diff --git a/desktop.ini b/desktop.ini new file mode 100644 index 0000000..ab17096 --- /dev/null +++ b/desktop.ini @@ -0,0 +1,4 @@ +[ViewState] +Mode= +Vid= +FolderType=Documents diff --git a/src/jquery.bootstrap-duallistbox.js b/src/jquery.bootstrap-duallistbox.js index 2d45e8b..0cac4b6 100644 --- a/src/jquery.bootstrap-duallistbox.js +++ b/src/jquery.bootstrap-duallistbox.js @@ -51,7 +51,9 @@ btnRemoveText: '<', // string, sets the text for the "Remove" button btnMoveAllText: '>>', // string, sets the text for the "Move All" button btnRemoveAllText: '<<', // string, sets the text for the "Remove All" button - reversedBoxes: false // boolean, puts box1(non-selecetd) on the right and box2(selected) on the left + reversedBoxes: false, // boolean, puts box1(non-selecetd) on the right and box2(selected) on the left + callbackMove: null, // function, execute a funtion on move a selection as selected. Uses the selected options to move as the last parameter + callbackRemove: null // function, execute a funtion on remove a selection as selected. Uses the selected options to remove as the last parameter }, // Selections are invisible on android if the containing select is styled with CSS // http://code.google.com/p/android/issues/detail?id=16922 @@ -102,7 +104,7 @@ } function formatString(s, args) { - console.log(s, args); + //console.log(s, args); return s.replace(/{(\d+)}/g, function(match, number) { return typeof args[number] !== 'undefined' ? args[number] : match; }); @@ -251,6 +253,7 @@ saveSelections(dualListbox, 1); } + var itemsToMove = dualListbox.elements.select1.find('option:selected'); dualListbox.elements.select1.find('option:selected').each(function(index, item) { var $item = $(item); if (!$item.data('filtered1')) { @@ -265,6 +268,10 @@ } else { sortOptions(dualListbox.elements.select2); } + + if (typeof(dualListbox.settings.callbackMove)=='function'){ + dualListbox.settings.callbackMove(itemsToMove); + } } function remove(dualListbox) { @@ -275,6 +282,7 @@ saveSelections(dualListbox, 2); } + var itemsToRemove = dualListbox.elements.select2.find('option:selected'); dualListbox.elements.select2.find('option:selected').each(function(index, item) { var $item = $(item); if (!$item.data('filtered2')) { @@ -288,6 +296,11 @@ if(dualListbox.settings.sortByInputOrder){ sortOptionsByInputOrder(dualListbox.elements.select2); } + + if (typeof(dualListbox.settings.callbackRemove) == 'function'){ + dualListbox.settings.callbackRemove(itemsToRemove) + } + } function moveAll(dualListbox) { @@ -298,6 +311,7 @@ saveSelections(dualListbox, 1); } + var itemsToMove = dualListbox.element.find('option'); dualListbox.element.find('option').each(function(index, item) { var $item = $(item); if (!$item.data('filtered1')) { @@ -309,6 +323,9 @@ refreshSelects(dualListbox); triggerChangeEvent(dualListbox); + if (typeof(dualListbox.settings.callbackMove)=='function'){ + dualListbox.settings.callbackMove(itemsToMove); + } } function removeAll(dualListbox) { @@ -319,6 +336,8 @@ saveSelections(dualListbox, 2); } + var itemsToReove = dualListbox.element.find('option'); + dualListbox.element.find('option').each(function(index, item) { var $item = $(item); if (!$item.data('filtered2')) { @@ -329,6 +348,9 @@ refreshSelects(dualListbox); triggerChangeEvent(dualListbox); + if (typeof(dualListbox.settings.callbackRemove)=='function'){ + dualListbox.settings.callbackRemove(itemsToRemove); + } } function bindEvents(dualListbox) { @@ -490,6 +512,9 @@ this.setBtnRemoveText(this.settings.btnRemoveText); this.setBtnMoveAllText(this.settings.btnMoveAllText); this.setBtnRemoveAllText(this.settings.btnRemoveAllText); + this.setCallbackMove(this.settings.callbackMove); + this.setCallbackRemove(this.settings.callbackRemove); + // Hide the original select this.element.hide(); @@ -814,36 +839,52 @@ return this.element; }, setReversedBoxes: function(value,refresh){ - this.settings.reversedBoxes = value; + this.settings.reversedBoxes = value; - if (value){ - if(!$(this.elements.box2).after().hasClass('box1')){ + if (value){ + if(!$(this.elements.box2).after().hasClass('box1')){ + classbox1 = $(this.elements.box1).find('.move i').attr('class'); + classbox2 = $(this.elements.box2).find('.remove i').attr('class'); + $(this.elements.box2).insertBefore($(this.elements.box1)); + $(this.elements.box2).find('.remove').insertAfter($(this.elements.box2).find('.removeall')); + $(this.elements.box2).find('.remove i, .removeall i').removeClass(classbox2).addClass(classbox1); + $(this.elements.box1).find('.move').insertBefore($(this.elements.box1).find('.moveall')); + $(this.elements.box1).find('.move i, moveall i').removeClass(classbox1).addClass(classbox2); + } + } + else{ classbox1 = $(this.elements.box1).find('.move i').attr('class'); classbox2 = $(this.elements.box2).find('.remove i').attr('class'); - $(this.elements.box2).insertBefore($(this.elements.box1)); - $(this.elements.box2).find('.remove').insertAfter($(this.elements.box2).find('.removeall')); - $(this.elements.box2).find('.remove i, .removeall i').removeClass(classbox2).addClass(classbox1); - $(this.elements.box1).find('.move').insertBefore($(this.elements.box1).find('.moveall')); - $(this.elements.box1).find('.move i, moveall i').removeClass(classbox1).addClass(classbox2); - } - } - else{ - classbox1 = $(this.elements.box1).find('.move i').attr('class'); - classbox2 = $(this.elements.box2).find('.remove i').attr('class'); - if(!$(this.elements.box2).before().hasClass('box1')){ - $(this.elements.box1).insertBefore($(this.elements.box2)); - $(this.elements.box2).find('.removeall').insertAfter($(this.elements.box2).find('.remove')); - $(this.elements.box2).find('.remove i, removeall i').removeClass(classbox1).addClass(classbox2); - $(this.elements.box1).find('.moveall').insertBefore($(this.elements.box1).find('.move')); - $(this.elements.box1).find('.remove i, removeall i').removeClass(classbox2).addClass(classbox1); - } - } - if (refresh) { - refreshSelects(this); + if(!$(this.elements.box2).before().hasClass('box1')){ + $(this.elements.box1).insertBefore($(this.elements.box2)); + $(this.elements.box2).find('.removeall').insertAfter($(this.elements.box2).find('.remove')); + $(this.elements.box2).find('.remove i, removeall i').removeClass(classbox1).addClass(classbox2); + $(this.elements.box1).find('.moveall').insertBefore($(this.elements.box1).find('.move')); + $(this.elements.box1).find('.remove i, removeall i').removeClass(classbox2).addClass(classbox1); } - return this.element; - }, - + } + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + + setCallbackMove: function(value,refresh){ + this.settings.callbackMove = value; + if (refresh){ + refreshSelects(this); + } + return this.element; + }, + + setCallbackRemove: function(value,refresh){ + this.settings.callbackRemove = value; + if (refresh){ + refreshSelects(this); + } + return this.element; + }, + getContainer: function() { return this.container; }, From 686cf4d39614871c490f58742aa151a99dc48adc Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Mon, 4 Feb 2019 17:36:28 -0200 Subject: [PATCH 06/14] =?UTF-8?q?Corre=C3=A7=C3=A3o=20de=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jquery.bootstrap-duallistbox.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/jquery.bootstrap-duallistbox.js b/src/jquery.bootstrap-duallistbox.js index 656451a..19a0fcd 100644 --- a/src/jquery.bootstrap-duallistbox.js +++ b/src/jquery.bootstrap-duallistbox.js @@ -862,21 +862,6 @@ $(this.elements.box1).find('.remove i, removeall i').removeClass(classbox2).addClass(classbox1); } } - if (refresh) { - refreshSelects(this); - } - } - else{ - classbox1 = $(this.elements.box1).find('.move i').attr('class'); - classbox2 = $(this.elements.box2).find('.remove i').attr('class'); - if(!$(this.elements.box2).before().hasClass('box1')){ - $(this.elements.box1).insertBefore($(this.elements.box2)); - $(this.elements.box2).find('.removeall').insertAfter($(this.elements.box2).find('.remove')); - $(this.elements.box2).find('.remove i, removeall i').removeClass(classbox1).addClass(classbox2); - $(this.elements.box1).find('.moveall').insertBefore($(this.elements.box1).find('.move')); - $(this.elements.box1).find('.remove i, removeall i').removeClass(classbox2).addClass(classbox1); - } - } if (refresh) { refreshSelects(this); } From bd13103cc71d834c34a69fff5137b9699db2ecab Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Tue, 5 Feb 2019 09:02:57 -0200 Subject: [PATCH 07/14] Update README.md --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cd54f62..f7baf86 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,9 @@ When calling `$("#element").bootstrapDualListbox()` you can pass a parameters ob - `iconsPrefix`, defaults to `oi`, set it to whichever prefix your icon family uses. - `iconMove`, defaults to `oi-arrow-thick-right`, sets the class for the move icon. - `iconRemove`, defaults to `oi-arrow-thick-left`, sets the class for the remove icon. +- `callbackMove`, defaults to null, set it to execute a function when moving(selecting) a option. Ex: function(items){ alert("Moved items: " + $.map(items,function(i){return i.text}));} +- `callbackRemove`, defaults to null, set it to execute a function when removing(selecting) a option. Ex: function(items){ alert("Removed items: " + $.map(items,function(i){return i.text}));} +- `reversedBoxes`, defaults to false, set it to true to swap the position of the boxes ### Methods @@ -103,7 +106,9 @@ Here are the available methods: - `setInfoTextFiltered(value, refresh)` to change the `infoTextFiltered` parameter. - `setInfoTextEmpty(value, refresh)` to change the `infoTextEmpty` parameter. - `setFilterOnValues(value, refresh)` to change the `filterOnValues` parameter. - +- `setCallbackMove(function)` to execute a function when moving options as selected. +- `setCallbackReove(function)` to execute a function when removing options as non-selected. +- `setReversedBoxes(true/false)` to swap the position of the boxes (selected to Left). Furthermore, you can call: - `refresh()` or `trigger` the `bootstrapDualListbox.refresh` event to update the plugin element UI. @@ -242,4 +247,4 @@ Check [Release](https://github.com/istvan-ujjmeszaros/bootstrap-duallistbox/rele WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -``` \ No newline at end of file +``` From df1f7eaaeac269828d64c70e9ae961d6b3f39094 Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Wed, 6 Feb 2019 15:12:28 -0200 Subject: [PATCH 08/14] Changed a bug to moveAll and removeAll returning all the options of both selects --- src/jquery.bootstrap-duallistbox.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jquery.bootstrap-duallistbox.js b/src/jquery.bootstrap-duallistbox.js index 19a0fcd..94c112f 100644 --- a/src/jquery.bootstrap-duallistbox.js +++ b/src/jquery.bootstrap-duallistbox.js @@ -311,7 +311,7 @@ saveSelections(dualListbox, 1); } - var itemsToMove = dualListbox.element.find('option'); + var itemsToMove = dualListbox.elements.find('option'); dualListbox.element.find('option').each(function(index, item) { var $item = $(item); if (!$item.data('filtered1')) { @@ -336,7 +336,7 @@ saveSelections(dualListbox, 2); } - var itemsToReove = dualListbox.element.find('option'); + var itemsToRemove = dualListbox.elements.select2.find('option'); dualListbox.element.find('option').each(function(index, item) { var $item = $(item); From 12d3809400573a575d0b2432a9f45fb0926cbafe Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Wed, 6 Feb 2019 15:16:06 -0200 Subject: [PATCH 09/14] Fixed Moving all returning all the options on callbackMove --- src/jquery.bootstrap-duallistbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jquery.bootstrap-duallistbox.js b/src/jquery.bootstrap-duallistbox.js index 94c112f..3b952b3 100644 --- a/src/jquery.bootstrap-duallistbox.js +++ b/src/jquery.bootstrap-duallistbox.js @@ -311,7 +311,7 @@ saveSelections(dualListbox, 1); } - var itemsToMove = dualListbox.elements.find('option'); + var itemsToMove = dualListbox.elements.select1.find('option'); dualListbox.element.find('option').each(function(index, item) { var $item = $(item); if (!$item.data('filtered1')) { From 6911df9944849b8e120bc3c21711425321745ee8 Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Wed, 6 Feb 2019 15:58:05 -0200 Subject: [PATCH 10/14] Corrections to pass the travis build --- src/jquery.bootstrap-duallistbox.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/jquery.bootstrap-duallistbox.js b/src/jquery.bootstrap-duallistbox.js index 3b952b3..40fc4e9 100644 --- a/src/jquery.bootstrap-duallistbox.js +++ b/src/jquery.bootstrap-duallistbox.js @@ -269,7 +269,7 @@ sortOptions(dualListbox.elements.select2); } - if (typeof(dualListbox.settings.callbackMove)=='function'){ + if (typeof(dualListbox.settings.callbackMove)==='function'){ dualListbox.settings.callbackMove(itemsToMove); } } @@ -297,7 +297,7 @@ sortOptionsByInputOrder(dualListbox.elements.select2); } - if (typeof(dualListbox.settings.callbackRemove) == 'function'){ + if (typeof(dualListbox.settings.callbackRemove) === 'function'){ dualListbox.settings.callbackRemove(itemsToRemove) } @@ -323,7 +323,7 @@ refreshSelects(dualListbox); triggerChangeEvent(dualListbox); - if (typeof(dualListbox.settings.callbackMove)=='function'){ + if (typeof(dualListbox.settings.callbackMove)==='function'){ dualListbox.settings.callbackMove(itemsToMove); } } @@ -348,7 +348,7 @@ refreshSelects(dualListbox); triggerChangeEvent(dualListbox); - if (typeof(dualListbox.settings.callbackRemove)=='function'){ + if (typeof(dualListbox.settings.callbackRemove)==='function'){ dualListbox.settings.callbackRemove(itemsToRemove); } } From f2a81babd5872db1e8646a1de5196070d186ee52 Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Wed, 6 Feb 2019 16:01:00 -0200 Subject: [PATCH 11/14] Corrections to pass the Travis build --- src/jquery.bootstrap-duallistbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jquery.bootstrap-duallistbox.js b/src/jquery.bootstrap-duallistbox.js index 40fc4e9..7a053e8 100644 --- a/src/jquery.bootstrap-duallistbox.js +++ b/src/jquery.bootstrap-duallistbox.js @@ -298,7 +298,7 @@ } if (typeof(dualListbox.settings.callbackRemove) === 'function'){ - dualListbox.settings.callbackRemove(itemsToRemove) + dualListbox.settings.callbackRemove(itemsToRemove); } } From 18d32a2e889bdfdc9685a6d279156fbcd767f03b Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Thu, 7 Feb 2019 10:34:50 -0200 Subject: [PATCH 12/14] Added the options to disable all the options or only moving/removing --- demo/index.html | 62 +++++++++++++++++- src/jquery.bootstrap-duallistbox.js | 97 ++++++++++++++++++++++------- 2 files changed, 134 insertions(+), 25 deletions(-) diff --git a/demo/index.html b/demo/index.html index 322e73e..c8490cb 100644 --- a/demo/index.html +++ b/demo/index.html @@ -69,7 +69,7 @@

Example with custom settings

selectedListLabel: 'Selected', preserveSelectionOnMove: 'moved', moveOnSelect: false, - nonSelectedFilter: 'ion ([7-9]|[1][0-2])' + nonSelectedFilter: 'ion ([7-9]|[1][0-2])', });
@@ -289,6 +289,42 @@

Settings

removeall event. + + reversedBoxes + false: set this to true to swap the positions of the selected boxes. + + + + callbackMove + null: set this to function(item) to execute a callback function after + moving options. The item attribute is a array collection of the moved options + + + + callbackRemove + null: set this to function(item) to execute a callback function after + removing options. The item attribute is a array collection of the moved options + + + + disabled + null: set this to true to avoid the options to be moved/removed. Set this to + false to enable it again. + This also disables the associated select and overrides the disabledMove and disabledRemove options when setted to true or false. + + + + disabledMove + null: set this to true to avoid the options to be moved. Set this to + false to enable it again. + + + + disabledRemove + null: set this to true to avoid the options to be removed. Set this to + false to enable it again. + + @@ -426,5 +462,29 @@

Methods

setEventRemoveAllOverride(value, refresh) change the eventRemoveAllOverride parameter. + + setReversedBoxes + change the reversedBoxes parameter. + + + setCallbackMove + change the callbackMove parameter. + + + setCallbackRemove + change the callbackRemove parameter. + + + setDisabled + change the disabled parameter. + + + setDisabledMove + change the disabledMove parameter. + + + setDisabledRemove + change the disabledRemove parameter. + diff --git a/src/jquery.bootstrap-duallistbox.js b/src/jquery.bootstrap-duallistbox.js index 7a053e8..2b60d63 100644 --- a/src/jquery.bootstrap-duallistbox.js +++ b/src/jquery.bootstrap-duallistbox.js @@ -53,7 +53,10 @@ btnRemoveAllText: '<<', // string, sets the text for the "Remove All" button reversedBoxes: false, // boolean, puts box1(non-selecetd) on the right and box2(selected) on the left callbackMove: null, // function, execute a funtion on move a selection as selected. Uses the selected options to move as the last parameter - callbackRemove: null // function, execute a funtion on remove a selection as selected. Uses the selected options to remove as the last parameter + callbackRemove: null, // function, execute a funtion on remove a selection as selected. Uses the selected options to remove as the last parameter + disabled: null, // boolean or null, if true disable all the options to be changed, if false enable all selects (override disableMove and disableRemove) + disabledMove: null, // boolean or null, if true disable only not selected options to be selected + disabledRemove: null // boolean or null, if true disable only selected options to be not selected }, // Selections are invisible on android if the containing select is styled with CSS // http://code.google.com/p/android/issues/detail?id=16922 @@ -492,6 +495,9 @@ this.setHelperSelectNamePostfix(this.settings.helperSelectNamePostfix); this.setSelectOrMinimalHeight(this.settings.selectorMinimalHeight); this.setReversedBoxes(this.settings.reversedBoxes); + this.setDisabledMove(this.settings.disabledMove); + this.setDisabledRemove(this.settings.disabledRemove); + this.setDisabled(this.settings.disabled); updateSelectionStates(this); @@ -839,34 +845,77 @@ return this.element; }, setReversedBoxes: function(value,refresh){ - this.settings.reversedBoxes = value; - if (value){ - if(!$(this.elements.box2).after().hasClass('box1')){ + this.settings.reversedBoxes = value; + if (value){ + if(!$(this.elements.box2).after().hasClass('box1')){ + classbox1 = $(this.elements.box1).find('.move i').attr('class'); + classbox2 = $(this.elements.box2).find('.remove i').attr('class'); + $(this.elements.box2).insertBefore($(this.elements.box1)); + $(this.elements.box2).find('.remove').insertAfter($(this.elements.box2).find('.removeall')); + $(this.elements.box2).find('.remove i, .removeall i').removeClass(classbox2).addClass(classbox1); + $(this.elements.box1).find('.move').insertBefore($(this.elements.box1).find('.moveall')); + $(this.elements.box1).find('.move i, moveall i').removeClass(classbox1).addClass(classbox2); + } + } + else{ classbox1 = $(this.elements.box1).find('.move i').attr('class'); classbox2 = $(this.elements.box2).find('.remove i').attr('class'); - $(this.elements.box2).insertBefore($(this.elements.box1)); - $(this.elements.box2).find('.remove').insertAfter($(this.elements.box2).find('.removeall')); - $(this.elements.box2).find('.remove i, .removeall i').removeClass(classbox2).addClass(classbox1); - $(this.elements.box1).find('.move').insertBefore($(this.elements.box1).find('.moveall')); - $(this.elements.box1).find('.move i, moveall i').removeClass(classbox1).addClass(classbox2); - } - } - else{ - classbox1 = $(this.elements.box1).find('.move i').attr('class'); - classbox2 = $(this.elements.box2).find('.remove i').attr('class'); - if(!$(this.elements.box2).before().hasClass('box1')){ - $(this.elements.box1).insertBefore($(this.elements.box2)); - $(this.elements.box2).find('.removeall').insertAfter($(this.elements.box2).find('.remove')); - $(this.elements.box2).find('.remove i, removeall i').removeClass(classbox1).addClass(classbox2); - $(this.elements.box1).find('.moveall').insertBefore($(this.elements.box1).find('.move')); - $(this.elements.box1).find('.remove i, removeall i').removeClass(classbox2).addClass(classbox1); - } - } + if(!$(this.elements.box2).before().hasClass('box1')){ + $(this.elements.box1).insertBefore($(this.elements.box2)); + $(this.elements.box2).find('.removeall').insertAfter($(this.elements.box2).find('.remove')); + $(this.elements.box2).find('.remove i, removeall i').removeClass(classbox1).addClass(classbox2); + $(this.elements.box1).find('.moveall').insertBefore($(this.elements.box1).find('.move')); + $(this.elements.box1).find('.remove i, removeall i').removeClass(classbox2).addClass(classbox1); + } + } + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + + setDisabled: function(value, refresh){ + if(value === true){ + $(this.elements.box1).attr('disabled','disabled').find('button,select').attr('disabled','disabled'); + $(this.elements.box2).attr('disabled','disabled').find('button,select').attr('disabled','disabled'); + $(this.elements.originalSelect).attr("disabled","disabled"); + } + if (value === false){ + $(this.elements.box1).removeAttr('disabled').find('button,select').removeAttr('disabled'); + $(this.elements.box2).removeAttr('disabled').find('button,select').removeAttr('disabled'); + $(this.elements.originalSelect).removeAttr("disabled","disabled"); + } if (refresh) { - refreshSelects(this); + refreshSelects(this); } return this.element; - }, + }, + + setDisabledMove: function(value, refresh){ + if(value === true){ + $(this.elements.box1).attr('disabled','disabled').find('button,select').attr('disabled','disabled'); + } + if(value === false){ + $(this.elements.box1).removeAttr('disabled').find('button,select').removeAttr('disabled'); + } + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + + setDisabledRemove: function(value, refresh){ + if(value === true){ + $(this.elements.box2).attr('disabled','disabled').find('button,select').attr('disabled','disabled'); + } + if(value === false){ + $(this.elements.box2).removeAttr('disabled').find('button,select').removeAttr('disabled'); + } + if (refresh) { + refreshSelects(this); + } + return this.element; + }, setCallbackMove: function(value,refresh){ this.settings.callbackMove = value; From 01679fd23d94004f3030efac5d58bc77cb1b307a Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Thu, 7 Feb 2019 10:39:01 -0200 Subject: [PATCH 13/14] correction of double quote on string --- src/jquery.bootstrap-duallistbox.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jquery.bootstrap-duallistbox.js b/src/jquery.bootstrap-duallistbox.js index 2b60d63..d6ff605 100644 --- a/src/jquery.bootstrap-duallistbox.js +++ b/src/jquery.bootstrap-duallistbox.js @@ -878,12 +878,12 @@ if(value === true){ $(this.elements.box1).attr('disabled','disabled').find('button,select').attr('disabled','disabled'); $(this.elements.box2).attr('disabled','disabled').find('button,select').attr('disabled','disabled'); - $(this.elements.originalSelect).attr("disabled","disabled"); + $(this.elements.originalSelect).attr('disabled','disabled'); } if (value === false){ $(this.elements.box1).removeAttr('disabled').find('button,select').removeAttr('disabled'); $(this.elements.box2).removeAttr('disabled').find('button,select').removeAttr('disabled'); - $(this.elements.originalSelect).removeAttr("disabled","disabled"); + $(this.elements.originalSelect).removeAttr('disabled','disabled'); } if (refresh) { refreshSelects(this); From 7c164cf0009351031f19a87d7bf4efd05f4ff410 Mon Sep 17 00:00:00 2001 From: jeffersoil Date: Thu, 7 Feb 2019 16:21:51 -0200 Subject: [PATCH 14/14] Changed the readme --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f7baf86..29c6ca2 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,10 @@ When calling `$("#element").bootstrapDualListbox()` you can pass a parameters ob - `iconRemove`, defaults to `oi-arrow-thick-left`, sets the class for the remove icon. - `callbackMove`, defaults to null, set it to execute a function when moving(selecting) a option. Ex: function(items){ alert("Moved items: " + $.map(items,function(i){return i.text}));} - `callbackRemove`, defaults to null, set it to execute a function when removing(selecting) a option. Ex: function(items){ alert("Removed items: " + $.map(items,function(i){return i.text}));} -- `reversedBoxes`, defaults to false, set it to true to swap the position of the boxes +- `reversedBoxes`, defaults to false, set it to true to swap the position of the boxes. +- `disabledMove(null/true/false)` use true to disable the checkbox or false to enable. It overrides the disabledMove or disabledRemove and this also disables the native select element. +- `disabledRemove(null/true/false)` use true to disable removing the options or false to enable. +- `disabled(null/true/false)` use true to disable the checkbox or false to enable. ### Methods @@ -107,8 +110,11 @@ Here are the available methods: - `setInfoTextEmpty(value, refresh)` to change the `infoTextEmpty` parameter. - `setFilterOnValues(value, refresh)` to change the `filterOnValues` parameter. - `setCallbackMove(function)` to execute a function when moving options as selected. -- `setCallbackReove(function)` to execute a function when removing options as non-selected. +- `setCallbackRemove(function)` to execute a function when removing options as non-selected. - `setReversedBoxes(true/false)` to swap the position of the boxes (selected to Left). +- `setDisabledMove(null/true/false)` use true to disable the checkbox or false to enable. This also add the attribute "disabled" on the native select element. +- `setDisabledRemove(null/true/false)` use true to disable removing the options or false to enable. +- `setDisabled(null/true/false)` use true to disable the checkbox or false to enable. Furthermore, you can call: - `refresh()` or `trigger` the `bootstrapDualListbox.refresh` event to update the plugin element UI.