images
3 years ago
Common.js
3 years ago
jquery.alert.js
3 years ago
jquery.calendar.js
3 years ago
jquery.cleditor.css
3 years ago
jquery.cleditor.js
3 years ago
jquery.colorselect.js
3 years ago
jquery.dropdown.js
3 years ago
jquery.form.js
3 years ago
jquery.validate.js
3 years ago
multiview.js
3 years ago
multiview.public.js
3 years ago
repeat.js
3 years ago
rrule.js
3 years ago
underscore.js
3 years ago
widget.admin.js
3 years ago
jquery.dropdown.js
135 lines
| 1 | /// <reference path="../intellisense/jquery-1.2.6-vsdoc-cn.js" /> |
| 2 | (function($) { |
| 3 | $.fn.DhoverClass = function(className) { |
| 4 | return $(this).hover(function() { $(this).addClass(className); }, function() { $(this).removeClass(className); }); |
| 5 | } |
| 6 | function getDulyOffset(target, w, h) { |
| 7 | var pos = target.offset(); |
| 8 | var height = target.outerHeight(); |
| 9 | var newpos = { left: pos.left, top: pos.top + height - 1 } |
| 10 | var bw = document.documentElement.clientWidth; |
| 11 | var bh = document.documentElement.clientHeight; |
| 12 | if ((newpos.left + w) >= bw) { |
| 13 | newpos.left = bw - w - 2; |
| 14 | } |
| 15 | if ((newpos.top + h) >= bh && bw > newpos.top) { |
| 16 | newpos.top = pos.top - h - 2; |
| 17 | } |
| 18 | return newpos; |
| 19 | } |
| 20 | function returnfalse() { return false; }; |
| 21 | $.fn.dropdown = function(o) { |
| 22 | var options = $.extend({ |
| 23 | vinputid: null, |
| 24 | cssClass: "bbit-dropdown", |
| 25 | containerCssClass: "dropdowncontainer", |
| 26 | dropwidth: false, |
| 27 | dropheight: "auto", |
| 28 | autoheight: true, |
| 29 | selectedchange: false, |
| 30 | items: [], |
| 31 | selecteditem: false, |
| 32 | parse: { |
| 33 | name: "list", |
| 34 | render: function(parent) { |
| 35 | var p = this.target; |
| 36 | var ul = $("<ul/>"); |
| 37 | if (this.items && this.items.length > 0) { |
| 38 | $.each(this.items, function() { |
| 39 | var item = this; |
| 40 | var d = $("<div/>").html(item.text); |
| 41 | var li = $("<li/>").DhoverClass("hover").append(d) |
| 42 | .click(function() { p.SelectedChanged(item); }); |
| 43 | if (item.classes && item.classes != "") { |
| 44 | d.addClass(item.classes); |
| 45 | } |
| 46 | ul.append(li); |
| 47 | }); |
| 48 | } |
| 49 | parent.append(ul); |
| 50 | }, |
| 51 | items: [], |
| 52 | setValue: function(item) { }, |
| 53 | target: null |
| 54 | } |
| 55 | }, o); |
| 56 | var me = $(this); |
| 57 | var v; |
| 58 | if (options.vinputid) { |
| 59 | v = $("#" + options.vinputid); |
| 60 | } |
| 61 | if (options.selecteditem) { |
| 62 | me.val(options.selecteditem.text); |
| 63 | if (v && options.selecteditem.value) { |
| 64 | v.val(options.selecteditem.value); |
| 65 | } |
| 66 | } |
| 67 | var requireCss = { height: 18, "padding-top": "1px", "padding-bottom": "1px" }; |
| 68 | me.css(requireCss).addClass(options.cssClass).DhoverClass("hover"); |
| 69 | if (!options.dropwidth) { |
| 70 | options.dropwidth = me.outerWidth(); |
| 71 | } |
| 72 | var d = $("<div/>").addClass(options.containerCssClass) |
| 73 | .css({ position: "absolute", "z-index": "999", "overflow": "auto", width: options.dropwidth, display: "none", "border": "solid 1px #555", background: "#fff" }) |
| 74 | .click(function(event) { event.stopPropagation(); }) |
| 75 | .appendTo($("body")); |
| 76 | if (options.autoheight) { |
| 77 | d.css("max-height", options.dropheight); |
| 78 | } |
| 79 | else { |
| 80 | d.css("height", options.dropheight); |
| 81 | } |
| 82 | |
| 83 | if ($.browser.msie) { |
| 84 | if (parseFloat($.browser.version) <= 6) { |
| 85 | var ie6hack = $("<div/>").css({ position: "absolute", "z-index": "-2", "overflow": "hidden", "height": "100%", width: "100%" }); |
| 86 | ie6hack.append($('<iframe style="position:absolute;z-index:-1;width:100%;height:100%;top:0;left:0;scrolling:no;" frameborder="0" src="about:blank"></iframe>')); |
| 87 | d.append(ie6hack); |
| 88 | } |
| 89 | } |
| 90 | me.click(function() { |
| 91 | var m = this; |
| 92 | if (d.attr("isinited") != "true") { |
| 93 | options.parse.items = options.items; |
| 94 | if (options.selecteditem) { |
| 95 | options.parse.setValue.call(d, options.selecteditem); |
| 96 | } |
| 97 | options.parse.render(d); |
| 98 | d.attr("isinited", "true"); |
| 99 | } |
| 100 | var pos = getDulyOffset(me, options.dropwidth, options.dropheight); |
| 101 | d.css(pos); |
| 102 | d.show(); |
| 103 | if ($.browser.msie) { |
| 104 | if (parseFloat($.browser.version) <= 6) { |
| 105 | var h = d.height(); |
| 106 | if (h > options.dropheight) { |
| 107 | d.height(options.dropheight); |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | $(document).one("click", function(event) { d.hide(); }); |
| 112 | return false; |
| 113 | }); |
| 114 | me.SelectedChanged = function(t) { |
| 115 | var b = true; |
| 116 | if (options.selectedchange) { |
| 117 | b = options.selectedchange.apply(me, [t]); |
| 118 | } |
| 119 | if (b != false) { |
| 120 | me.val(t.text); |
| 121 | if (v && t.value) { |
| 122 | v.val(t.value); |
| 123 | } |
| 124 | } |
| 125 | d.hide(); |
| 126 | |
| 127 | }; |
| 128 | me.Cancel = function() { |
| 129 | d.hide(); |
| 130 | } |
| 131 | options.parse.target = me; |
| 132 | return me; |
| 133 | } |
| 134 | |
| 135 | })(jQuery); |