X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=js%2Fjquery.multiselect2side.js;h=e47a35fac051ce361b8dac00ea4a282e935b495f;hb=0aa55515f3c2cdce122dda325f48c9a3cb6a600a;hp=928a3ce0492a1321c4a8f01826760beba7079a76;hpb=f09ed6e1d77eb113db14e8f4a00afc09531a43d8;p=kivitendo-erp.git
diff --git a/js/jquery.multiselect2side.js b/js/jquery.multiselect2side.js
index 928a3ce04..e47a35fac 100644
--- a/js/jquery.multiselect2side.js
+++ b/js/jquery.multiselect2side.js
@@ -22,19 +22,30 @@
labelSort: 'Sort',
labelsx: 'Available',
labeldx: 'Selected',
- maxSelected: -1
+ maxSelected: -1,
+ leftSel: null,
+ rightSel: null,
+
+ sortOptions: function() {
+ o.leftSel.sortOptions();
+ o.rightSel.sortOptions();
+ }
}, o);
return this.each(function () {
var el = $(this);
+ var hiddenName = $(this).attr("name");
var originalName = $(this).attr("name");
if (originalName.indexOf('[') != -1)
originalName = originalName.substring(0, originalName.indexOf('['));
- var nameDx = originalName + "ms2side__dx";
- var nameSx = originalName + "ms2side__sx";
- var size = $(this).attr("size");
+ var nameDx = originalName + "ms2side__dx";
+ var idDx = originalName + "ms2side__dx";
+ var nameSx = originalName + "ms2side__sx";
+ var hiddenId = originalName + "ms2side_hidden";
+ var size = $(this).attr("size");
+ $(this).attr("name", originalName + "ms2side__orig");
// SIZE MIN
if (size < 6) {
$(this).attr("size", "6");
@@ -75,11 +86,13 @@
"" +
"
" +
(o.labeldx ? ("") : "") +
- "" +
+ "" +
"
" +
+ "" +
((o.selectedPosition == 'right' && o.moveOptions) ? divUpDown : "") +
"";
$(this).after(htmlToAdd).hide();
+ $("#" + hiddenId).hide();
// ELEMENTS
var allSel = $(this).next().find("select");
@@ -87,6 +100,8 @@
var rightSel = (o.selectedPosition == 'right') ? allSel.eq(1) : allSel.eq(0);
// HEIGHT DIV
var heightDiv = $(".ms2side__select").eq(0).height();
+ o.leftSel = leftSel;
+ o.rightSel = rightSel;
// CENTER MOVE OPTIONS AND UPDOWN OPTIONS
$(this).next().find('.ms2side__options, .ms2side__updown').each(function(){
@@ -99,9 +114,8 @@
$(this).find("option:selected").clone().appendTo(rightSel);
$(this).find("option:not(:selected)").clone().appendTo(leftSel);
- // SELECT FIRST LEFT ITEM
- if (!($.browser.msie && $.browser.version == '6.0'))
- leftSel.find("option").eq(0).attr("selected", true);
+ // Mark all unselected.
+ rightSel.find("option").attr("selected", false);
// ON CHANGE REFRESH ALL BUTTON STATUS
allSel.change(function() {
@@ -110,6 +124,7 @@
var selectDx = rightSel.children();
var selectedSx = leftSel.find("option:selected");
var selectedDx = rightSel.find("option:selected");
+ var hiddenCont = $("#" + hiddenId);
if (selectedSx.size() == 0 || (o.maxSelected >= 0 && (selectedSx.size() + selectDx.size()) > o.maxSelected))
div.find(".AddOne").addClass('ms2side__hide');
@@ -141,8 +156,11 @@
else
div.find(".RemoveAll").removeClass('ms2side__hide');
- leftSel.sortOptions();
- rightSel.sortOptions();
+ // Rebuild hidden inputs...
+ hiddenCont.empty();
+ rightSel.find("option").each(function(idx, option) {
+ $('').attr("name", hiddenName).attr("value", $(option).attr("value")).appendTo(hiddenCont);
+ });
});
// DOUBLE CLICK ON LEFT SELECT OPTION
@@ -155,6 +173,7 @@
}
});
$(this).trigger('change');
+ o.sortOptions();
});
// DOUBLE CLICK ON RIGHT SELECT OPTION
@@ -164,6 +183,7 @@
el.find("[value=" + $(selected).val() + "]").attr("selected", false).remove().appendTo(el);
});
$(this).trigger('change');
+ o.sortOptions();
});
// CLICK ON OPTION
@@ -174,24 +194,28 @@
$(this).remove().appendTo(rightSel);
el.find("[value=" + $(selected).val() + "]").attr("selected", true).remove().appendTo(el);
});
+ o.sortOptions();
} else if ($(this).hasClass("AddAll")) { // ALL SELECTED
leftSel.children().appendTo(rightSel);
leftSel.children().remove();
el.find('option').attr("selected", true);
// el.children().attr("selected", true); -- PROBLEM WITH OPTGROUP
+ o.sortOptions();
} else if ($(this).hasClass("RemoveOne")) {
rightSel.find("option:selected").each(function(i, selected){
$(this).remove().appendTo(leftSel);
el.find("[value=" + $(selected).val() + "]").attr("selected", false).remove().appendTo(el);
});
+ o.sortOptions();
} else if ($(this).hasClass("RemoveAll")) { // ALL REMOVED
rightSel.children().appendTo(leftSel);
rightSel.children().remove();
el.find('option').attr("selected", false);
//el.children().attr("selected", false); -- PROBLEM WITH OPTGROUP
+ o.sortOptions();
}
}
@@ -272,6 +296,7 @@
// UPDATE BUTTON ON START
leftSel.trigger('change');
+ o.sortOptions();
// SHOW WHEN ALL READY
$(this).next().show();
});