X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=js%2Fjquery.multiselect2side.js;h=e47a35fac051ce361b8dac00ea4a282e935b495f;hb=947583f50e01c950349274b6707702293f6c495a;hp=259614192ba1575c1e858b5158ed8d9101b51f12;hpb=d31c7de4fbb1d62fac99037ed1bfb94a2f735a83;p=kivitendo-erp.git
diff --git a/js/jquery.multiselect2side.js b/js/jquery.multiselect2side.js
index 259614192..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');
@@ -118,17 +133,17 @@
// FIRST HIDE ALL
div.find(".RemoveOne, .MoveUp, .MoveDown, .MoveTop, .MoveBottom, .SelSort").addClass('ms2side__hide');
- if (selectDx.size() > 1)
- div.find(".SelSort").removeClass('ms2side__hide');
+ // if (selectDx.size() > 1)
+ // div.find(".SelSort").removeClass('ms2side__hide');
if (selectedDx.size() > 0) {
div.find(".RemoveOne").removeClass('ms2side__hide');
- // ALL SELECTED - NO MOVE
- if (selectedDx.size() < selectDx.size()) { // FOR NOW (JOE) && selectedDx.size() == 1
- if (selectedDx.val() != selectDx.val()) // FIRST OPTION, NO UP AND TOP BUTTON
- div.find(".MoveUp, .MoveTop").removeClass('ms2side__hide');
- if (selectedDx.last().val() != selectDx.last().val()) // LAST OPTION, NO DOWN AND BOTTOM BUTTON
- div.find(".MoveDown, .MoveBottom").removeClass('ms2side__hide');
- }
+ // // ALL SELECTED - NO MOVE
+ // if (selectedDx.size() < selectDx.size()) { // FOR NOW (JOE) && selectedDx.size() == 1
+ // if (selectedDx.val() != selectDx.val()) // FIRST OPTION, NO UP AND TOP BUTTON
+ // div.find(".MoveUp, .MoveTop").removeClass('ms2side__hide');
+ // if (selectedDx.last().val() != selectDx.last().val()) // LAST OPTION, NO DOWN AND BOTTOM BUTTON
+ // div.find(".MoveDown, .MoveBottom").removeClass('ms2side__hide');
+ // }
}
if (selectSx.size() == 0 || (o.maxSelected >= 0 && selectSx.size() >= o.maxSelected))
@@ -140,6 +155,12 @@
div.find(".RemoveAll").addClass('ms2side__hide');
else
div.find(".RemoveAll").removeClass('ms2side__hide');
+
+ // 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
@@ -152,6 +173,7 @@
}
});
$(this).trigger('change');
+ o.sortOptions();
});
// DOUBLE CLICK ON RIGHT SELECT OPTION
@@ -161,6 +183,7 @@
el.find("[value=" + $(selected).val() + "]").attr("selected", false).remove().appendTo(el);
});
$(this).trigger('change');
+ o.sortOptions();
});
// CLICK ON OPTION
@@ -171,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();
}
}
@@ -269,6 +296,7 @@
// UPDATE BUTTON ON START
leftSel.trigger('change');
+ o.sortOptions();
// SHOW WHEN ALL READY
$(this).next().show();
});