123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- //$(function () {
- // $("#FirstBox option:first,#SecondBox option:first").attr("selected", true);
- // $("#FirstBox").dblclick(function () {
- // $("option:selected", this).clone().appendTo("#SecondBox");
- // $("option:selected", this).remove();
- // });
- // $("#SecondBox").dblclick(function () {
- // $("option:selected", this).clone().appendTo("#FirstBox");
- // $("option:selected", this).remove();
- // });
- // $("#add").click(function () {
- // $("#FirstBox option:selected").clone().appendTo("#SecondBox");
- // $("#FirstBox option:selected").remove();
- // });
- // $("#remove").click(function () {
- // $("#SecondBox option:selected").clone().appendTo("#FirstBox");
- // $("#SecondBox option:selected").remove();
- // });
- // $("#addall").click(function () {
- // $("#FirstBox option").clone().appendTo("#SecondBox");
- // $("#FirstBox option").remove();
- // });
- // $("#removeall").click(function () {
- // $("#SecondBox option").clone().appendTo("#FirstBox");
- // $("#SecondBox option").remove();
- // });
- // $("#FirstBoxup").click(function () {
- // var so = $("#FirstBox option:selected");
- // if (so.get(0).index != 0) {
- // so.each(function () {
- // $(this).prev().before($(this));
- // });
- // }
- // });
- // $("#FirstBoxdown").click(function () {
- // var alloptions = $("#FirstBox option");
- // var so = $("#FirstBox option:selected");
- // if (so.get(so.length - 1).index != alloptions.length - 1) {
- // for (i = so.length - 1; i >= 0; i--) {
- // var item = $(so.get(i));
- // item.insertAfter(item.next());
- // }
- // }
- // });
- // $("#SecondBoxup").click(function () {
- // var so = $("#SecondBox option:selected");
- // if (so.get(0).index != 0) {
- // so.each(function () {
- // $(this).prev().before($(this));
- // });
- // }
- // });
- // $("#SecondBoxdown").click(function () {
- // var alloptions = $("#SecondBox option");
- // var so = $("#SecondBox option:selected");
- // if (so.get(so.length - 1).index != alloptions.length - 1) {
- // for (i = so.length - 1; i >= 0; i--) {
- // var item = $(so.get(i));
- // item.insertAfter(item.next());
- // }
- // }
- // });
- //});
- (function ($) {
- $.fn.MultiSelectsBox = function (options, param) {
- function ConcatColumnTag(str) {
- var html = "<td>" + str + "</td>";
- return html;
- };
- function ConcatRowTag(str) {
- var html = "<tr>" + str + "</tr>";
- return html;
- };
- var containerID = $(this).attr("id");
- var identityObject = {
- /// <summary>
- /// MultiSelectsBox内标签对象的id列表
- /// </summary>
- firstBoxItemUpBtn: containerID + "_firstBoxItemUpBtn",
- fristBoxItemDownBtn: containerID + "_fristBoxItemDownBtn",
- secondBoxItemUpBtn: containerID + "_secondBoxItemUpBtn",
- secondBoxItemDownBtn: containerID + "_secondBoxItemDownBtn",
- firstBox: containerID + "_firstBox",
- secondBox: containerID + "_secondBox",
- allItemRightMoveBtn: containerID + "_allItemRightMoveBtn",
- allItemLeftMoveBtn: containerID + "_allItemLeftMoveBtn",
- itemRightMoveBtn: containerID + "_itemRightMoveBtn",
- itemLeftMoveBtn: containerID + "_itemLeftMoveBtn"
- };
- var firstBoxItemUpBtnHtml = "<input type=\"button\" name=\"firstBoxItemUpBtn\" id=\"" + identityObject.firstBoxItemUpBtn + "\" value=\"上 移\" title=\"上移\" style=\"width:70px;\" /><br />";
- var fristBoxItemDownBtnHtml = "<input type=\"button\" name=\"fristBoxItemDownBtn\" id=\"" + identityObject.fristBoxItemDownBtn + "\" value=\"下 移\" title=\"下移\" style=\"width:70px;\" />";
- var secondBoxItemUpBtnHtml = "<input type=\"button\" name=\"secondBoxItemUpBtn\" id=\"" + identityObject.secondBoxItemUpBtn + "\" value=\"上 移\" title=\"上移\" style=\"width:70px;\" /><br />";
- var secondBoxItemDownBtnHtml = "<input type=\"button\" name=\"secondBoxItemDownBtn\" id=\"" + identityObject.secondBoxItemDownBtn + "\" value=\"下 移\" title=\"下移\" style=\"width:70px;\" />";
- var firstBoxHtml = "<select name=\"firstBox\" size=\"10\" multiple=\"multiple\" id=\"" + identityObject.firstBox + "\" style=\"width: 150px;\" mce_style=\" width:150px;\"></select>";
- var secondBoxHtml = "<select name=\"secondBox\" size=\"10\" multiple=\"multiple\" id=\"" + identityObject.secondBox + "\" style=\"width: 150px;\" mce_style=\" width:150px;\"></select>";
- var allItemRightMoveBtnHtml = "<input type=\"button\" name=\"allItemRightMoveBtn\" id=\"" + identityObject.allItemRightMoveBtn + "\" value=\"全部右移\" title=\"全部右移\" style=\"width:70px;\" />";
- var allItemLeftMoveBtnHtml = "<input type=\"button\" name=\"allItemLeftMoveBtn\" id=\"" + identityObject.allItemLeftMoveBtn + "\" value=\"全部左移\" title=\"全部左移\" style=\"width:70px;\" />";
- var itemRightMoveBtnHtml = "<input type=\"button\" name=\"itemRightMoveBtn\" id=\"" + identityObject.itemRightMoveBtn + "\" value=\"右 移\" title=\"右移动\" style=\"width:70px;\" />";
- var itemLeftMoveBtnHtml = "<input type=\"button\" name=\"itemLeftMoveBtn\" id=\"" + identityObject.itemLeftMoveBtn + "\" value=\"左 移\" title=\"左移\" style=\"width:70px;\" />";
- var columnOneHtml = ConcatColumnTag(firstBoxItemUpBtnHtml.concat("<br />").concat(fristBoxItemDownBtnHtml));
- var columnTwoHtml = ConcatColumnTag(firstBoxHtml);
- var columnThreeHtml = ConcatColumnTag(allItemRightMoveBtnHtml.concat("<br />").concat(itemRightMoveBtnHtml).concat("<br />").concat(itemLeftMoveBtnHtml).concat("<br />").concat(allItemLeftMoveBtnHtml));
- var columnFourHtml = ConcatColumnTag(secondBoxHtml);
- var columnFiveHtml = ConcatColumnTag(secondBoxItemUpBtnHtml.concat("<br />").concat(secondBoxItemDownBtnHtml));
- var rowsHtml = ConcatRowTag((columnOneHtml.concat(columnTwoHtml).concat(columnThreeHtml).concat(columnFourHtml).concat(columnFiveHtml)));
- var container = $("#" + containerID);
- container.append(rowsHtml);
- };
- $.fn.MultiSelectsBox.defaults = {
- };
- })(jQuery);
|