/** * jQuery ligerUI 1.1.9 * * http://ligerui.com * * Author daomi 2012 [ gd_star@163.com ] * */ (function ($) { //ligerui 继承方法 Function.prototype.ligerExtend = function (parent, overrides) { if (typeof parent != 'function') return this; //保存对父类的引用 this.base = parent.prototype; this.base.constructor = parent; //继承 var f = function () { }; f.prototype = parent.prototype; this.prototype = new f(); this.prototype.constructor = this; //附加属性方法 if (overrides) $.extend(this.prototype, overrides); }; //延时加载 Function.prototype.ligerDefer = function (o, defer, args) { var fn = this; return setTimeout(function () { fn.apply(o, args || []); }, defer); }; // 核心对象 window.liger = $.ligerui = { version: 'V1.1.9', managerCount: 0, //组件管理器池 managers: {}, managerIdPrev: 'ligerui', //错误提示 error: { managerIsExist: '管理器id已经存在' }, getId: function (prev) { prev = prev || this.managerIdPrev; var id = prev + (1000 + this.managerCount); this.managerCount++; return id; }, add: function (manager) { if (arguments.length == 2) { var m = arguments[1]; m.id = m.id || m.options.id || arguments[0].id; this.addManager(m); return; } if (!manager.id) manager.id = this.getId(manager.__idPrev()); if (this.managers[manager.id]) throw new Error(this.error.managerIsExist); this.managers[manager.id] = manager; }, remove: function (arg) { if (typeof arg == "string" || typeof arg == "number") { delete $.ligerui.managers[arg]; } else if (typeof arg == "object" && arg instanceof $.ligerui.core.Component) { delete $.ligerui.managers[arg.id]; } }, //获取ligerui对象 //1,传入ligerui ID //2,传入Dom Object Array(jQuery) get: function (arg, idAttrName) { idAttrName = idAttrName || "ligeruiid"; if (typeof arg == "string" || typeof arg == "number") { return $.ligerui.managers[arg]; } else if (typeof arg == "object" && arg.length) { if (!arg[0][idAttrName] && !$(arg[0]).attr(idAttrName)) return null; return $.ligerui.managers[arg[0][idAttrName] || $(arg[0]).attr(idAttrName)]; } return null; }, //根据类型查找某一个对象 find: function (type) { var arr = []; for (var id in this.managers) { var manager = this.managers[id]; if (type instanceof Function) { if (manager instanceof type) { arr.push(manager); } } else if (type instanceof Array) { if ($.inArray(manager.__getType(), type) != -1) { arr.push(manager); } } else { if (manager.__getType() == type) { arr.push(manager); } } } return arr; }, //$.fn.liger{Plugin} 和 $.fn.ligerGet{Plugin}Manager //会调用这个方法,并传入作用域(this) //@parm [plugin] 插件名 //@parm [args] 参数(数组) //@parm [ext] 扩展参数,定义命名空间或者id属性名 run: function (plugin, args, ext) { if (!plugin) return; ext = $.extend({ defaultsNamespace: 'ligerDefaults', methodsNamespace: 'ligerMethods', controlNamespace: 'controls', idAttrName: 'ligeruiid', isStatic: false, hasElement: true, //是否拥有element主体(比如drag、resizable等辅助性插件就不拥有) propertyToElemnt: null //链接到element的属性名 }, ext || {}); plugin = plugin.replace(/^ligerGet/, ''); plugin = plugin.replace(/^liger/, ''); if (this == null || this == window || ext.isStatic) { if (!$.ligerui.plugins[plugin]) { $.ligerui.plugins[plugin] = { fn: $['liger' + plugin], isStatic: true }; } return new $.ligerui[ext.controlNamespace][plugin]($.extend({}, $[ext.defaultsNamespace][plugin] || {}, $[ext.defaultsNamespace][plugin + 'String'] || {}, args.length > 0 ? args[0] : {})); } if (!$.ligerui.plugins[plugin]) { $.ligerui.plugins[plugin] = { fn: $.fn['liger' + plugin], isStatic: false }; } if (/Manager$/.test(plugin)) return $.ligerui.get(this, ext.idAttrName); this.each(function () { if (this[ext.idAttrName] || $(this).attr(ext.idAttrName)) { var manager = $.ligerui.get(this[ext.idAttrName] || $(this).attr(ext.idAttrName)); if (manager && args.length > 0) manager.set(args[0]); //已经执行过 return; } if (args.length >= 1 && typeof args[0] == 'string') return; //只要第一个参数不是string类型,都执行组件的实例化工作 var options = args.length > 0 ? args[0] : null; var p = $.extend({}, $[ext.defaultsNamespace][plugin] || {} , $[ext.defaultsNamespace][plugin + 'String'] || {}, options || {}); if (ext.propertyToElemnt) p[ext.propertyToElemnt] = this; if (ext.hasElement) { new $.ligerui[ext.controlNamespace][plugin](this, p); } else { new $.ligerui[ext.controlNamespace][plugin](p); } }); if (this.length == 0) return null; if (args.length == 0) return $.ligerui.get(this, ext.idAttrName); if (typeof args[0] == 'object') return $.ligerui.get(this, ext.idAttrName); if (typeof args[0] == 'string') { var manager = $.ligerui.get(this, ext.idAttrName); if (manager == null) return; if (args[0] == "option") { if (args.length == 2) return manager.get(args[1]); //manager get else if (args.length >= 3) return manager.set(args[1], args[2]); //manager set } else { var method = args[0]; if (!manager[method]) return; //不存在这个方法 var parms = Array.apply(null, args); parms.shift(); return manager[method].apply(manager, parms); //manager method } } return null; }, //扩展 //1,默认参数 //2,本地化扩展 defaults: {}, //3,方法接口扩展 methods: {}, //命名空间 //核心控件,封装了一些常用方法 core: {}, //命名空间 //组件的集合 controls: {}, //plugin 插件的集合 plugins: {} }; //扩展对象 $.ligerDefaults = {}; //扩展对象 $.ligerMethos = {}; //关联起来 $.ligerui.defaults = $.ligerDefaults; $.ligerui.methods = $.ligerMethos; //获取ligerui对象 //@parm [plugin] 插件名,可为空 $.fn.liger = function (plugin) { if (plugin) { return $.ligerui.run.call(this, plugin, arguments); } else { return $.ligerui.get(this); } }; //组件基类 //1,完成定义参数处理方法和参数属性初始化的工作 //2,完成定义事件处理方法和事件属性初始化的工作 $.ligerui.core.Component = function (options) { //事件容器 this.events = this.events || {}; //配置参数 this.options = options || {}; //子组件集合索引 this.children = {}; }; $.extend($.ligerui.core.Component.prototype, { __getType: function () { return '$.ligerui.core.Component'; }, __idPrev: function () { return 'ligerui'; }, //设置属性 // arg 属性名 value 属性值 // arg 属性/值 value 是否只设置事件 set: function (arg, value) { if (!arg) return; if (typeof arg == 'object') { var tmp; if (this.options != arg) { $.extend(this.options, arg); tmp = arg; } else { tmp = $.extend({}, arg); } if (value == undefined || value == true) { for (var p in tmp) { if (p.indexOf('on') == 0) this.set(p, tmp[p]); } } if (value == undefined || value == false) { for (var p in tmp) { if (p.indexOf('on') != 0) this.set(p, tmp[p]); } } return; } var name = arg; //事件参数 if (name.indexOf('on') == 0) { if (typeof value == 'function') this.bind(name.substr(2), value); return; } this.trigger('propertychange', arg, value); if (!this.options) this.options = {}; this.options[name] = value; var pn = '_set' + name.substr(0, 1).toUpperCase() + name.substr(1); if (this[pn]) { this[pn].call(this, value); } this.trigger('propertychanged', arg, value); }, //获取属性 get: function (name) { var pn = '_get' + name.substr(0, 1).toUpperCase() + name.substr(1); if (this[pn]) { return this[pn].call(this, name); } return this.options[name]; }, hasBind: function (arg) { var name = arg.toLowerCase(); var event = this.events[name]; if (event && event.length) return true; return false; }, //触发事件 //data (可选) Array(可选)传递给事件处理函数的附加参数 trigger: function (arg, data) { var name = arg.toLowerCase(); var event = this.events[name]; if (!event) return; data = data || []; if ((data instanceof Array) == false) { data = [data]; } for (var i = 0; i < event.length; i++) { var ev = event[i]; if (ev.handler.apply(ev.context, data) == false) return false; } }, //绑定事件 bind: function (arg, handler, context) { if (typeof arg == 'object') { for (var p in arg) { this.bind(p, arg[p]); } return; } if (typeof handler != 'function') return false; var name = arg.toLowerCase(); var event = this.events[name] || []; context = context || this; event.push({ handler: handler, context: context }); this.events[name] = event; }, //取消绑定 unbind: function (arg, handler) { if (!arg) { this.events = {}; return; } var name = arg.toLowerCase(); var event = this.events[name]; if (!event || !event.length) return; if (!handler) { delete this.events[name]; } else { for (var i = 0, l = event.length; i < l; i++) { if (event[i].handler == handler) { event.splice(i, 1); break; } } } }, destroy: function () { $.ligerui.remove(this); } }); //界面组件基类, //1,完成界面初始化:设置组件id并存入组件管理器池,初始化参数 //2,渲染的工作,细节交给子类实现 //@parm [element] 组件对应的dom element对象 //@parm [options] 组件的参数 $.ligerui.core.UIComponent = function (element, options) { $.ligerui.core.UIComponent.base.constructor.call(this, options); var extendMethods = this._extendMethods(); if (extendMethods) $.extend(this, extendMethods); this.element = element; this._init(); this._preRender(); this.trigger('render'); this._render(); this.trigger('rendered'); this._rendered(); }; $.ligerui.core.UIComponent.ligerExtend($.ligerui.core.Component, { __getType: function () { return '$.ligerui.core.UIComponent'; }, //扩展方法 _extendMethods: function () { }, _init: function () { this.type = this.__getType(); if (!this.element) { this.id = this.options.id || $.ligerui.getId(this.__idPrev()); } else { this.id = this.options.id || this.element.id || $.ligerui.getId(this.__idPrev()); } //存入管理器池 $.ligerui.add(this); if (!this.element) return; //读取attr方法,并加载到参数,比如['url'] var attributes = this.attr(); if (attributes && attributes instanceof Array) { for (var i = 0; i < attributes.length; i++) { var name = attributes[i]; this.options[name] = $(this.element).attr(name); } } //读取ligerui这个属性,并加载到参数,比如 ligerui = "width:120,heigth:100" var p = this.options; if ($(this.element).attr("ligerui")) { try { var attroptions = $(this.element).attr("ligerui"); if (attroptions.indexOf('{') != 0) attroptions = "{" + attroptions + "}"; eval("attroptions = " + attroptions + ";"); if (attroptions) $.extend(p, attroptions); } catch (e) { } } }, //预渲染,可以用于继承扩展 _preRender: function () { }, _render: function () { }, _rendered: function () { if (this.element) { $(this.element).attr("ligeruiid", this.id); } }, //返回要转换成ligerui参数的属性,比如['url'] attr: function () { return []; }, destroy: function () { if (this.element) $(this.element).remove(); this.options = null; $.ligerui.remove(this); } }); //表单控件基类 $.ligerui.controls.Input = function (element, options) { $.ligerui.controls.Input.base.constructor.call(this, element, options); }; $.ligerui.controls.Input.ligerExtend($.ligerui.core.UIComponent, { __getType: function () { return '$.ligerui.controls.Input'; }, attr: function () { return ['nullText']; }, setValue: function (value) { return this.set('value', value); }, getValue: function () { return this.get('value'); }, setEnabled: function () { return this.set('disabled', false); }, setDisabled: function () { return this.set('disabled', true); }, updateStyle: function () { } }); //全局窗口对象 $.ligerui.win = { //顶端显示 top: false, //遮罩 mask: function (win) { function setHeight() { if (!$.ligerui.win.windowMask) return; var h = $(window).height() + $(window).scrollTop(); $.ligerui.win.windowMask.height(h); } if (!this.windowMask) { this.windowMask = $("
").appendTo('body'); $(window).bind('resize.ligeruiwin', setHeight); $(window).bind('scroll', setHeight); } this.windowMask.show(); setHeight(); this.masking = true; }, //取消遮罩 unmask: function (win) { var jwins = $("body > .l-dialog:visible,body > .l-window:visible"); for (var i = 0, l = jwins.length; i < l; i++) { var winid = jwins.eq(i).attr("ligeruiid"); if (win && win.id == winid) continue; //获取ligerui对象 var winmanager = $.ligerui.get(winid); if (!winmanager) continue; //是否模态窗口 var modal = winmanager.get('modal'); //如果存在其他模态窗口,那么不会取消遮罩 if (modal) return; } if (this.windowMask) this.windowMask.hide(); this.masking = false; }, //显示任务栏 createTaskbar: function () { if (!this.taskbar) { this.taskbar = $('
').appendTo('body'); if (this.top) this.taskbar.addClass("l-taskbar-top"); this.taskbar.tasks = $(".l-taskbar-tasks:first", this.taskbar); this.tasks = {}; } this.taskbar.show(); this.taskbar.animate({ bottom: 0 }); return this.taskbar; }, //关闭任务栏 removeTaskbar: function () { var self = this; self.taskbar.animate({ bottom: -32 }, function () { self.taskbar.remove(); self.taskbar = null; }); }, activeTask: function (win) { for (var winid in this.tasks) { var t = this.tasks[winid]; if (winid == win.id) { t.addClass("l-taskbar-task-active"); } else { t.removeClass("l-taskbar-task-active"); } } }, //获取任务 getTask: function (win) { var self = this; if (!self.taskbar) return; if (self.tasks[win.id]) return self.tasks[win.id]; return null; }, //增加任务 addTask: function (win) { var self = this; if (!self.taskbar) self.createTaskbar(); if (self.tasks[win.id]) return self.tasks[win.id]; var title = win.get('title'); var task = self.tasks[win.id] = $('
' + title + '
'); self.taskbar.tasks.append(task); self.activeTask(win); task.bind('click', function () { self.activeTask(win); if (win.actived) win.min(); else win.active(); }).hover(function () { $(this).addClass("l-taskbar-task-over"); }, function () { $(this).removeClass("l-taskbar-task-over"); }); return task; }, hasTask: function () { for (var p in this.tasks) { if (this.tasks[p]) return true; } return false; }, //移除任务 removeTask: function (win) { var self = this; if (!self.taskbar) return; if (self.tasks[win.id]) { self.tasks[win.id].unbind(); self.tasks[win.id].remove(); delete self.tasks[win.id]; } if (!self.hasTask()) { self.removeTaskbar(); } }, //前端显示 setFront: function (win) { var wins = $.ligerui.find($.ligerui.core.Win); for (var i in wins) { var w = wins[i]; if (w == win) { $(w.element).css("z-index", "9200"); this.activeTask(w); } else { $(w.element).css("z-index", "9100"); } } } }; //窗口基类 window、dialog $.ligerui.core.Win = function (element, options) { $.ligerui.core.Win.base.constructor.call(this, element, options); }; $.ligerui.core.Win.ligerExtend($.ligerui.core.UIComponent, { __getType: function () { return '$.ligerui.controls.Win'; }, mask: function () { if (this.options.modal) $.ligerui.win.mask(this); }, unmask: function () { if (this.options.modal) $.ligerui.win.unmask(this); }, min: function () { }, max: function () { }, active: function () { } }); $.ligerui.draggable = { dragging: false }; $.ligerui.resizable = { reszing: false }; $.ligerui.toJSON = typeof JSON === 'object' && JSON.stringify ? JSON.stringify : function (o) { var f = function (n) { return n < 10 ? '0' + n : n; }, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, quote = function (value) { escapable.lastIndex = 0; return escapable.test(value) ? '"' + value.replace(escapable, function (a) { var c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + '"' : '"' + value + '"'; }; if (o === null) return 'null'; var type = typeof o; if (type === 'undefined') return undefined; if (type === 'string') return quote(o); if (type === 'number' || type === 'boolean') return '' + o; if (type === 'object') { if (typeof o.toJSON === 'function') { return $.ligerui.toJSON(o.toJSON()); } if (o.constructor === Date) { return isFinite(this.valueOf()) ? this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + 'Z' : null; } var pairs = []; if (o.constructor === Array) { for (var i = 0, l = o.length; i < l; i++) { pairs.push($.ligerui.toJSON(o[i]) || 'null'); } return '[' + pairs.join(',') + ']'; } var name, val; for (var k in o) { type = typeof k; if (type === 'number') { name = '"' + k + '"'; } else if (type === 'string') { name = quote(k); } else { continue; } type = typeof o[k]; if (type === 'function' || type === 'undefined') { continue; } val = $.ligerui.toJSON(o[k]); pairs.push(name + ':' + val); } return '{' + pairs.join(',') + '}'; } }; })(jQuery);/** * jQuery ligerUI 1.1.9 * * http://ligerui.com * * Author daomi 2012 [ gd_star@163.com ] * */ (function ($) { $.fn.ligerAccordion = function (options) { return $.ligerui.run.call(this, "ligerAccordion", arguments); }; $.fn.ligerGetAccordionManager = function () { return $.ligerui.get(this); }; $.ligerDefaults.Accordion = { height: null, speed: "normal", changeHeightOnResize: false, heightDiff: 0 // 高度补差 }; $.ligerMethos.Accordion = {}; $.ligerui.controls.Accordion = function (element, options) { $.ligerui.controls.Accordion.base.constructor.call(this, element, options); }; $.ligerui.controls.Accordion.ligerExtend($.ligerui.core.UIComponent, { __getType: function () { return 'Accordion'; }, __idPrev: function () { return 'Accordion'; }, _extendMethods: function () { return $.ligerMethos.Accordion; }, _render: function () { var g = this, p = this.options; g.accordion = $(g.element); if (!g.accordion.hasClass("l-accordion-panel")) g.accordion.addClass("l-accordion-panel"); var selectedIndex = 0; if ($("> div[lselected=true]", g.accordion).length > 0) selectedIndex = $("> div", g.accordion).index($("> div[lselected=true]", g.accordion)); $("> div", g.accordion).each(function (i, box) { var header = $('
'); if (i == selectedIndex) $(".l-accordion-toggle", header).addClass("l-accordion-toggle-open"); if ($(box).attr("title")) { $(".l-accordion-header-inner", header).html($(box).attr("title")); $(box).attr("title", ""); } $(box).before(header); if (!$(box).hasClass("l-accordion-content")) $(box).addClass("l-accordion-content"); }); //add Even $(".l-accordion-toggle", g.accordion).each(function () { if (!$(this).hasClass("l-accordion-toggle-open") && !$(this).hasClass("l-accordion-toggle-close")) { $(this).addClass("l-accordion-toggle-close"); } if ($(this).hasClass("l-accordion-toggle-close")) { $(this).parent().next(".l-accordion-content:visible").hide(); } }); $(".l-accordion-header", g.accordion).hover(function () { $(this).addClass("l-accordion-header-over"); }, function () { $(this).removeClass("l-accordion-header-over"); }); $(".l-accordion-toggle", g.accordion).hover(function () { if ($(this).hasClass("l-accordion-toggle-open")) $(this).addClass("l-accordion-toggle-open-over"); else if ($(this).hasClass("l-accordion-toggle-close")) $(this).addClass("l-accordion-toggle-close-over"); }, function () { if ($(this).hasClass("l-accordion-toggle-open")) $(this).removeClass("l-accordion-toggle-open-over"); else if ($(this).hasClass("l-accordion-toggle-close")) $(this).removeClass("l-accordion-toggle-close-over"); }); $(">.l-accordion-header", g.accordion).click(function () { var togglebtn = $(".l-accordion-toggle:first", this); if (togglebtn.hasClass("l-accordion-toggle-close")) { togglebtn.removeClass("l-accordion-toggle-close") .removeClass("l-accordion-toggle-close-over l-accordion-toggle-open-over") togglebtn.addClass("l-accordion-toggle-open"); $(this).next(".l-accordion-content") .show(p.speed) .siblings(".l-accordion-content:visible").hide(p.speed); $(this).siblings(".l-accordion-header").find(".l-accordion-toggle").removeClass("l-accordion-toggle-open").addClass("l-accordion-toggle-close"); } else { togglebtn.removeClass("l-accordion-toggle-open") .removeClass("l-accordion-toggle-close-over l-accordion-toggle-open-over") .addClass("l-accordion-toggle-close"); $(this).next(".l-accordion-content").hide(p.speed); } }); //init g.headerHoldHeight = 0; $("> .l-accordion-header", g.accordion).each(function () { g.headerHoldHeight += $(this).height(); }); if (p.height && typeof (p.height) == 'string' && p.height.indexOf('%') > 0) { g.onResize(); if (p.changeHeightOnResize) { $(window).resize(function () { g.onResize(); }); } } else { if (p.height) { g.height = p.heightDiff + p.height; g.accordion.height(g.height); g.setHeight(p.height); } else { g.header = g.accordion.height(); } } g.set(p); }, onResize: function () { var g = this, p = this.options; if (!p.height || typeof (p.height) != 'string' || p.height.indexOf('%') == -1) return false; //set accordion height if (g.accordion.parent()[0].tagName.toLowerCase() == "body") { var windowHeight = $(window).height(); windowHeight -= parseInt(g.layout.parent().css('paddingTop')); windowHeight -= parseInt(g.layout.parent().css('paddingBottom')); g.height = p.heightDiff + windowHeight * parseFloat(g.height) * 0.01; } else { g.height = p.heightDiff + (g.accordion.parent().height() * parseFloat(p.height) * 0.01); } g.accordion.height(g.height); g.setContentHeight(g.height - g.headerHoldHeight); }, setHeight: function (height) { var g = this, p = this.options; g.accordion.height(height); height -= g.headerHoldHeight; $("> .l-accordion-content", g.accordion).height(height); } }); })(jQuery);/** * jQuery ligerUI 1.1.9 * * http://ligerui.com * * Author daomi 2012 [ gd_star@163.com ] * */ (function ($) { $.fn.ligerButton = function (options) { return $.ligerui.run.call(this, "ligerButton", arguments); }; $.fn.ligerGetButtonManager = function () { return $.ligerui.run.call(this, "ligerGetButtonManager", arguments); }; $.ligerDefaults.Button = { width: 100, text: 'Button', disabled: false }; $.ligerMethos.Button = {}; $.ligerui.controls.Button = function (element, options) { $.ligerui.controls.Button.base.constructor.call(this, element, options); }; $.ligerui.controls.Button.ligerExtend($.ligerui.controls.Input, { __getType: function () { return 'Button'; }, __idPrev: function () { return 'Button'; }, _extendMethods: function () { return $.ligerMethos.Button; }, _render: function () { var g = this, p = this.options; g.button = $(g.element); g.button.addClass("l-btn"); g.button.append('
'); p.click && g.button.click(function () { if (!p.disabled) p.click(); }); g.set(p); }, _setEnabled: function (value) { if (value) this.button.removeClass("l-btn-disabled"); }, _setDisabled: function (value) { if (value) { this.button.addClass("l-btn-disabled"); this.options.disabled = true; } }, _setWidth: function (value) { this.button.width(value); }, _setText: function (value) { $("span", this.button).html(value); }, setValue: function (value) { this.set('text', value); }, getValue: function () { return this.options.text; }, setEnabled: function () { this.set('disabled', false); }, setDisabled: function () { this.set('disabled', true); } }); })(jQuery);/** * jQuery ligerUI 1.1.9 * * http://ligerui.com * * Author daomi 2012 [ gd_star@163.com ] * */ (function ($) { $.fn.ligerCheckBox = function (options) { return $.ligerui.run.call(this, "ligerCheckBox", arguments); }; $.fn.ligerGetCheckBoxManager = function () { return $.ligerui.run.call(this, "ligerGetCheckBoxManager", arguments); }; $.ligerDefaults.CheckBox = { disabled: false }; $.ligerMethos.CheckBox = {}; $.ligerui.controls.CheckBox = function (element, options) { $.ligerui.controls.CheckBox.base.constructor.call(this, element, options); }; $.ligerui.controls.CheckBox.ligerExtend($.ligerui.controls.Input, { __getType: function () { return 'CheckBox'; }, __idPrev: function () { return 'CheckBox'; }, _extendMethods: function () { return $.ligerMethos.CheckBox; }, _render: function () { var g = this, p = this.options; g.input = $(g.element); g.link = $(''); g.wrapper = g.input.addClass('l-hidden').wrap('
').parent(); g.wrapper.prepend(g.link); g.link.click(function () { if (g.input.attr('disabled')) { return false; } if (p.disabled) return false; if (g.trigger('beforeClick', [g.element]) == false) return false; if ($(this).hasClass("l-checkbox-checked")) { g._setValue(false); } else { g._setValue(true); } g.input.trigger("change"); }); g.wrapper.hover(function () { if (!p.disabled) $(this).addClass("l-over"); }, function () { $(this).removeClass("l-over"); }); this.set(p); this.updateStyle(); }, _setCss: function (value) { this.wrapper.css(value); }, _setValue: function (value) { var g = this, p = this.options; if (!value) { g.input[0].checked = false; g.link.removeClass('l-checkbox-checked'); } else { g.input[0].checked = true; g.link.addClass('l-checkbox-checked'); } }, _setDisabled: function (value) { if (value) { this.input.attr('disabled', true); this.wrapper.addClass("l-disabled"); } else { this.input.attr('disabled', false); this.wrapper.removeClass("l-disabled"); } }, _getValue: function () { return this.element.checked; }, updateStyle: function () { if (this.input.attr('disabled')) { this.wrapper.addClass("l-disabled"); this.options.disabled = true; } if (this.input[0].checked) { this.link.addClass('l-checkbox-checked'); } else { this.link.removeClass('l-checkbox-checked'); } } }); })(jQuery);/** * jQuery ligerUI 1.1.9 * * http://ligerui.com * * Author daomi 2012 [ gd_star@163.com ] * */ (function ($) { $.fn.ligerComboBox = function (options) { return $.ligerui.run.call(this, "ligerComboBox", arguments); }; $.fn.ligerGetComboBoxManager = function () { return $.ligerui.run.call(this, "ligerGetComboBoxManager", arguments); }; $.ligerDefaults.ComboBox = { resize: true, //是否调整大小 isMultiSelect: false, //是否多选 isShowCheckBox: false, //是否选择复选框 columns: false, //表格状态 selectBoxWidth: false, //宽度 selectBoxHeight: false, //高度 onBeforeSelect: false, //选择前事件 onSelected: null, //选择值事件 initValue: null, initText: null, valueField: 'id', textField: 'text', valueFieldID: null, slide: true, //是否以动画的形式显示 split: ";", data: null, tree: null, //下拉框以树的形式显示,tree的参数跟LigerTree的参数一致 treeLeafOnly: true, //是否只选择叶子 grid: null, //表格 onStartResize: null, onEndResize: null, hideOnLoseFocus: true, url: null, //数据源URL(需返回JSON) onSuccess: null, onError: null, onBeforeOpen: null, //打开下拉框前事件,可以通过return false来阻止继续操作,利用这个参数可以用来调用其他函数,比如打开一个新窗口来选择值 render: null, //文本框显示html函数 absolute: true //选择框是否在附加到body,并绝对定位 }; //扩展方法 $.ligerMethos.ComboBox = $.ligerMethos.ComboBox || {}; $.ligerui.controls.ComboBox = function (element, options) { $.ligerui.controls.ComboBox.base.constructor.call(this, element, options); }; $.ligerui.controls.ComboBox.ligerExtend($.ligerui.controls.Input, { __getType: function () { return 'ComboBox'; }, _extendMethods: function () { return $.ligerMethos.ComboBox; }, _init: function () { $.ligerui.controls.ComboBox.base._init.call(this); var p = this.options; if (p.columns) { p.isShowCheckBox = true; } if (p.isMultiSelect) { p.isShowCheckBox = true; } }, _render: function () { var g = this, p = this.options; g.data = p.data; g.inputText = null; g.select = null; g.textFieldID = ""; g.valueFieldID = ""; g.valueField = null; //隐藏域(保存值) //文本框初始化 if (this.element.tagName.toLowerCase() == "input") { this.element.readOnly = true; g.inputText = $(this.element); g.textFieldID = this.element.id; } else if (this.element.tagName.toLowerCase() == "select") { $(this.element).hide(); g.select = $(this.element); p.isMultiSelect = false; p.isShowCheckBox = false; g.textFieldID = this.element.id + "_txt"; g.inputText = $(''); g.inputText.attr("id", g.textFieldID).insertAfter($(this.element)); } else { //不支持其他类型 return; } if (g.inputText[0].name == undefined) g.inputText[0].name = g.textFieldID; //隐藏域初始化 g.valueField = null; if (p.valueFieldID) { g.valueField = $("#" + p.valueFieldID + ":input"); if (g.valueField.length == 0) g.valueField = $(''); g.valueField[0].id = g.valueField[0].name = p.valueFieldID; } else { g.valueField = $(''); g.valueField[0].id = g.valueField[0].name = g.textFieldID + "_val"; } if (g.valueField[0].name == undefined) g.valueField[0].name = g.valueField[0].id; //开关 g.link = $('
'); //下拉框 g.selectBox = $('
'); g.selectBox.table = $("table:first", g.selectBox); //外层 g.wrapper = g.inputText.wrap('
').parent(); g.wrapper.append('
'); g.wrapper.append(g.link); //添加个包裹, g.textwrapper = g.wrapper.wrap('
').parent(); if (p.absolute) g.selectBox.appendTo('body').addClass("l-box-select-absolute"); else g.textwrapper.append(g.selectBox); g.textwrapper.append(g.valueField); g.inputText.addClass("l-text-field"); if (p.isShowCheckBox && !g.select) { $("table", g.selectBox).addClass("l-table-checkbox"); } else { p.isShowCheckBox = false; $("table", g.selectBox).addClass("l-table-nocheckbox"); } //开关 事件 g.link.hover(function () { if (p.disabled) return; this.className = "l-trigger-hover"; }, function () { if (p.disabled) return; this.className = "l-trigger"; }).mousedown(function () { if (p.disabled) return; this.className = "l-trigger-pressed"; }).mouseup(function () { if (p.disabled) return; this.className = "l-trigger-hover"; }).click(function () { if (p.disabled) return; if (g.trigger('beforeOpen') == false) return false; g._toggleSelectBox(g.selectBox.is(":visible")); }); g.inputText.click(function () { if (p.disabled) return; if (g.trigger('beforeOpen') == false) return false; g._toggleSelectBox(g.selectBox.is(":visible")); }).blur(function () { if (p.disabled) return; g.wrapper.removeClass("l-text-focus"); }).focus(function () { if (p.disabled) return; g.wrapper.addClass("l-text-focus"); }); g.wrapper.hover(function () { if (p.disabled) return; g.wrapper.addClass("l-text-over"); }, function () { if (p.disabled) return; g.wrapper.removeClass("l-text-over"); }); g.resizing = false; g.selectBox.hover(null, function (e) { if (p.hideOnLoseFocus && g.selectBox.is(":visible") && !g.boxToggling && !g.resizing) { g._toggleSelectBox(true); } }); var itemsleng = $("tr", g.selectBox.table).length; if (!p.selectBoxHeight && itemsleng < 8) p.selectBoxHeight = itemsleng * 30; if (p.selectBoxHeight) { g.selectBox.height(p.selectBoxHeight); } //下拉框内容初始化 g.bulidContent(); g.set(p); //下拉框宽度、高度初始化 if (p.selectBoxWidth) { g.selectBox.width(p.selectBoxWidth); } else { g.selectBox.css('width', g.wrapper.css('width')); } }, destroy: function () { if (this.wrapper) this.wrapper.remove(); if (this.selectBox) this.selectBox.remove(); this.options = null; $.ligerui.remove(this); }, _setDisabled: function (value) { //禁用样式 if (value) { this.wrapper.addClass('l-text-disabled'); } else { this.wrapper.removeClass('l-text-disabled'); } }, _setLable: function (label) { var g = this, p = this.options; if (label) { if (g.labelwrapper) { g.labelwrapper.find(".l-text-label:first").html(label + ': '); } else { g.labelwrapper = g.textwrapper.wrap('
').parent(); g.labelwrapper.prepend('
' + label + ': 
'); g.textwrapper.css('float', 'left'); } if (!p.labelWidth) { p.labelWidth = $('.l-text-label', g.labelwrapper).outerWidth(); } else { $('.l-text-label', g.labelwrapper).outerWidth(p.labelWidth); } $('.l-text-label', g.labelwrapper).width(p.labelWidth); $('.l-text-label', g.labelwrapper).height(g.wrapper.height()); g.labelwrapper.append('
'); if (p.labelAlign) { $('.l-text-label', g.labelwrapper).css('text-align', p.labelAlign); } g.textwrapper.css({ display: 'inline' }); g.labelwrapper.width(g.wrapper.outerWidth() + p.labelWidth + 2); } }, _setWidth: function (value) { var g = this; if (value > 20) { g.wrapper.css({ width: value }); g.inputText.css({ width: value - 20 }); g.textwrapper.css({ width: value }); } }, _setHeight: function (value) { var g = this; if (value > 10) { g.wrapper.height(value); g.inputText.height(value - 2); g.link.height(value - 4); g.textwrapper.css({ width: value }); } }, _setResize: function (resize) { //调整大小支持 if (resize && $.fn.ligerResizable) { var g = this; g.selectBox.ligerResizable({ handles: 'se,s,e', onStartResize: function () { g.resizing = true; g.trigger('startResize'); } , onEndResize: function () { g.resizing = false; if (g.trigger('endResize') == false) return false; } }); g.selectBox.append("
"); } }, //查找Text,适用多选和单选 findTextByValue: function (value) { var g = this, p = this.options; if (value == undefined) return ""; var texts = ""; var contain = function (checkvalue) { var targetdata = value.toString().split(p.split); for (var i = 0; i < targetdata.length; i++) { if (targetdata[i] == checkvalue) return true; } return false; }; $(g.data).each(function (i, item) { var val = item[p.valueField]; var txt = item[p.textField]; if (contain(val)) { texts += txt + p.split; } }); if (texts.length > 0) texts = texts.substr(0, texts.length - 1); return texts; }, //查找Value,适用多选和单选 findValueByText: function (text) { var g = this, p = this.options; if (!text && text == "") return ""; var contain = function (checkvalue) { var targetdata = text.toString().split(p.split); for (var i = 0; i < targetdata.length; i++) { if (targetdata[i] == checkvalue) return true; } return false; }; var values = ""; $(g.data).each(function (i, item) { var val = item[p.valueField]; var txt = item[p.textField]; if (contain(txt)) { values += val + p.split; } }); if (values.length > 0) values = values.substr(0, values.length - 1); return values; }, removeItem: function () { }, insertItem: function () { }, addItem: function () { }, _setValue: function (value) { var g = this, p = this.options; var text = g.findTextByValue(value); if (p.tree) { g.selectValueByTree(value); } else if (!p.isMultiSelect) { g._changeValue(value, text); $("tr[value=" + value + "] td", g.selectBox).addClass("l-selected"); $("tr[value!=" + value + "] td", g.selectBox).removeClass("l-selected"); } else { g._changeValue(value, text); var targetdata = value.toString().split(p.split); $("table.l-table-checkbox :checkbox", g.selectBox).each(function () { this.checked = false; }); for (var i = 0; i < targetdata.length; i++) { $("table.l-table-checkbox tr[value=" + targetdata[i] + "] :checkbox", g.selectBox).each(function () { this.checked = true; }); } } }, selectValue: function (value) { this._setValue(value); }, bulidContent: function () { var g = this, p = this.options; this.clearContent(); if (g.select) { g.setSelect(); } else if (g.data) { g.setData(g.data); } else if (p.tree) { g.setTree(p.tree); } else if (p.grid) { g.setGrid(p.grid); } else if (p.url) { $.ajax({ type: 'post', url: p.url, cache: false, dataType: 'json', success: function (data) { g.data = data; g.setData(g.data); g.trigger('success', [g.data]); }, error: function (XMLHttpRequest, textStatus) { g.trigger('error', [XMLHttpRequest, textStatus]); } }); } }, clearContent: function () { var g = this, p = this.options; $("table", g.selectBox).html(""); //g.inputText.val(""); //g.valueField.val(""); }, setSelect: function () { var g = this, p = this.options; this.clearContent(); $('option', g.select).each(function (i) { var val = $(this).val(); var txt = $(this).html(); var tr = $("" + txt + ""); $("table.l-table-nocheckbox", g.selectBox).append(tr); $("td", tr).hover(function () { $(this).addClass("l-over"); }, function () { $(this).removeClass("l-over"); }); }); $('td:eq(' + g.select[0].selectedIndex + ')', g.selectBox).each(function () { if ($(this).hasClass("l-selected")) { g.selectBox.hide(); return; } $(".l-selected", g.selectBox).removeClass("l-selected"); $(this).addClass("l-selected"); if (g.select[0].selectedIndex != $(this).attr('index') && g.select[0].onchange) { g.select[0].selectedIndex = $(this).attr('index'); g.select[0].onchange(); } var newIndex = parseInt($(this).attr('index')); g.select[0].selectedIndex = newIndex; g.select.trigger("change"); g.selectBox.hide(); var value = $(this).attr("value"); var text = $(this).html(); if (p.render) { g.inputText.val(p.render(value, text)); } else { g.inputText.val(text); } }); g._addClickEven(); }, setData: function (data) { var g = this, p = this.options; this.clearContent(); if (!data || !data.length) return; if (g.data != data) g.data = data; if (p.columns) { g.selectBox.table.headrow = $(""); g.selectBox.table.append(g.selectBox.table.headrow); g.selectBox.table.addClass("l-box-select-grid"); for (var j = 0; j < p.columns.length; j++) { var headrow = $("" + p.columns[j].header + ""); if (p.columns[j].width) { headrow.width(p.columns[j].width); } g.selectBox.table.headrow.append(headrow); } } for (var i = 0; i < data.length; i++) { var val = data[i][p.valueField]; var txt = data[i][p.textField]; if (!p.columns) { $("table.l-table-checkbox", g.selectBox).append("" + txt + ""); $("table.l-table-nocheckbox", g.selectBox).append("" + txt + ""); } else { var tr = $(""); $("td", g.selectBox.table.headrow).each(function () { var columnname = $(this).attr("columnname"); if (columnname) { var td = $("" + data[i][columnname] + ""); tr.append(td); } }); g.selectBox.table.append(tr); } } //自定义复选框支持 if (p.isShowCheckBox && $.fn.ligerCheckBox) { $("table input:checkbox", g.selectBox).ligerCheckBox(); } $(".l-table-checkbox input:checkbox", g.selectBox).change(function () { if (this.checked && g.hasBind('beforeSelect')) { var parentTD = null; if ($(this).parent().get(0).tagName.toLowerCase() == "div") { parentTD = $(this).parent().parent(); } else { parentTD = $(this).parent(); } if (parentTD != null && g.trigger('beforeSelect', [parentTD.attr("value"), parentTD.attr("text")]) == false) { g.selectBox.slideToggle("fast"); return false; } } if (!p.isMultiSelect) { if (this.checked) { $("input:checked", g.selectBox).not(this).each(function () { this.checked = false; $(".l-checkbox-checked", $(this).parent()).removeClass("l-checkbox-checked"); }); g.selectBox.slideToggle("fast"); } } g._checkboxUpdateValue(); }); $("table.l-table-nocheckbox td", g.selectBox).hover(function () { $(this).addClass("l-over"); }, function () { $(this).removeClass("l-over"); }); g._addClickEven(); //选择项初始化 g._dataInit(); }, //树 setTree: function (tree) { var g = this, p = this.options; this.clearContent(); g.selectBox.table.remove(); if (tree.checkbox != false) { tree.onCheck = function () { var nodes = g.treeManager.getChecked(); var value = []; var text = []; $(nodes).each(function (i, node) { if (p.treeLeafOnly && node.data.children) return; value.push(node.data[p.valueField]); text.push(node.data[p.textField]); }); g._changeValue(value.join(p.split), text.join(p.split)); }; } else { tree.onSelect = function (node) { if (p.treeLeafOnly && node.data.children) return; var value = node.data[p.valueField]; var text = node.data[p.textField]; g._changeValue(value, text); }; tree.onCancelSelect = function (node) { g._changeValue("", ""); }; } tree.onAfterAppend = function (domnode, nodedata) { if (!g.treeManager) return; var value = null; if (p.initValue) value = p.initValue; else if (g.valueField.val() != "") value = g.valueField.val(); g.selectValueByTree(value); }; g.tree = $(""); $("div:first", g.selectBox).append(g.tree); g.tree.ligerTree(tree); g.treeManager = g.tree.ligerGetTreeManager(); }, selectValueByTree: function (value) { var g = this, p = this.options; if (value != null) { var text = ""; var valuelist = value.toString().split(p.split); $(valuelist).each(function (i, item) { g.treeManager.selectNode(item.toString()); text += g.treeManager.getTextByID(item); if (i < valuelist.length - 1) text += p.split; }); g._changeValue(value, text); } }, //表格 setGrid: function (grid) { var g = this, p = this.options; this.clearContent(); g.selectBox.table.remove(); g.grid = $("div:first", g.selectBox); grid.columnWidth = grid.columnWidth || 120; grid.width = "100%"; grid.height = "100%"; grid.heightDiff = -2; grid.InWindow = false; g.gridManager = g.grid.ligerGrid(grid); p.hideOnLoseFocus = false; if (grid.checkbox != false) { var onCheckRow = function () { var rowsdata = g.gridManager.getCheckedRows(); var value = []; var text = []; $(rowsdata).each(function (i, rowdata) { value.push(rowdata[p.valueField]); text.push(rowdata[p.textField]); }); g._changeValue(value.join(p.split), text.join(p.split)); }; g.gridManager.bind('CheckAllRow', onCheckRow); g.gridManager.bind('CheckRow', onCheckRow); } else { g.gridManager.bind('SelectRow', function (rowdata, rowobj, index) { var value = rowdata[p.valueField]; var text = rowdata[p.textField]; g._changeValue(value, text); }); g.gridManager.bind('UnSelectRow', function (rowdata, rowobj, index) { g._changeValue("", ""); }); } g.bind('show', function () { if (g.gridManager) { g.gridManager._updateFrozenWidth(); } }); g.bind('endResize', function () { if (g.gridManager) { g.gridManager._updateFrozenWidth(); g.gridManager.setHeight(g.selectBox.height() - 2); } }); }, _getValue: function () { return $(this.valueField).val(); }, getValue: function () { //获取值 return this._getValue(); }, updateStyle: function () { var g = this, p = this.options; g._dataInit(); }, _dataInit: function () { var g = this, p = this.options; var value = null; if (p.initValue != null && p.initText != null) { g._changeValue(p.initValue, p.initText); } //根据值来初始化 if (p.initValue != null) { value = p.initValue; if (p.tree) { if(value) g.selectValueByTree(value); } else { var text = g.findTextByValue(value); g._changeValue(value, text); } } //根据文本来初始化 else if (p.initText != null) { value = g.findValueByText(p.initText); g._changeValue(value, p.initText); } else if (g.valueField.val() != "") { value = g.valueField.val(); if (p.tree) { if(value) g.selectValueByTree(value); } else { var text = g.findTextByValue(value); g._changeValue(value, text); } } if (!p.isShowCheckBox && value != null) { $("table tr", g.selectBox).find("td:first").each(function () { if (value == $(this).attr("value")) { $(this).addClass("l-selected"); } }); } if (p.isShowCheckBox && value != null) { $(":checkbox", g.selectBox).each(function () { var parentTD = null; var checkbox = $(this); if (checkbox.parent().get(0).tagName.toLowerCase() == "div") { parentTD = checkbox.parent().parent(); } else { parentTD = checkbox.parent(); } if (parentTD == null) return; var valuearr = value.toString().split(p.split); $(valuearr).each(function (i, item) { if (item == parentTD.attr("value")) { $(".l-checkbox", parentTD).addClass("l-checkbox-checked"); checkbox[0].checked = true; } }); }); } }, //设置值到 文本框和隐藏域 _changeValue: function (newValue, newText) { var g = this, p = this.options; g.valueField.val(newValue); if (p.render) { g.inputText.val(p.render(newValue, newText)); } else { g.inputText.val(newText); } g.selectedValue = newValue; g.selectedText = newText; g.inputText.trigger("change").focus(); g.trigger('selected', [newValue, newText]); }, //更新选中的值(复选框) _checkboxUpdateValue: function () { var g = this, p = this.options; var valueStr = ""; var textStr = ""; $("input:checked", g.selectBox).each(function () { var parentTD = null; if ($(this).parent().get(0).tagName.toLowerCase() == "div") { parentTD = $(this).parent().parent(); } else { parentTD = $(this).parent(); } if (!parentTD) return; valueStr += parentTD.attr("value") + p.split; textStr += parentTD.attr("text") + p.split; }); if (valueStr.length > 0) valueStr = valueStr.substr(0, valueStr.length - 1); if (textStr.length > 0) textStr = textStr.substr(0, textStr.length - 1); g._changeValue(valueStr, textStr); }, _addClickEven: function () { var g = this, p = this.options; //选项点击 $(".l-table-nocheckbox td", g.selectBox).click(function () { var value = $(this).attr("value"); var index = parseInt($(this).attr('index')); var text = $(this).html(); if (g.hasBind('beforeSelect') && g.trigger('beforeSelect', [value, text]) == false) { if (p.slide) g.selectBox.slideToggle("fast"); else g.selectBox.hide(); return false; } if ($(this).hasClass("l-selected")) { if (p.slide) g.selectBox.slideToggle("fast"); else g.selectBox.hide(); return; } $(".l-selected", g.selectBox).removeClass("l-selected"); $(this).addClass("l-selected"); if (g.select) { if (g.select[0].selectedIndex != index) { g.select[0].selectedIndex = index; g.select.trigger("change"); } } if (p.slide) { g.boxToggling = true; g.selectBox.hide("fast", function () { g.boxToggling = false; }) } else g.selectBox.hide(); g._changeValue(value, text); }); }, updateSelectBoxPosition: function () { var g = this, p = this.options; if (p.absolute) { g.selectBox.css({ left: g.wrapper.offset().left, top: g.wrapper.offset().top + 1 + g.wrapper.outerHeight() }); } else { var topheight = g.wrapper.offset().top - $(window).scrollTop(); var selfheight = g.selectBox.height() + textHeight + 4; if (topheight + selfheight > $(window).height() && topheight > selfheight) { g.selectBox.css("marginTop", -1 * (g.selectBox.height() + textHeight + 5)); } } }, _toggleSelectBox: function (isHide) { var g = this, p = this.options; var textHeight = g.wrapper.height(); g.boxToggling = true; if (isHide) { if (p.slide) { g.selectBox.slideToggle('fast', function () { g.boxToggling = false; }); } else { g.selectBox.hide(); g.boxToggling = false; } } else { g.updateSelectBoxPosition(); if (p.slide) { g.selectBox.slideToggle('fast', function () { g.boxToggling = false; if (!p.isShowCheckBox && $('td.l-selected', g.selectBox).length > 0) { var offSet = ($('td.l-selected', g.selectBox).offset().top - g.selectBox.offset().top); $(".l-box-select-inner", g.selectBox).animate({ scrollTop: offSet }); } }); } else { g.selectBox.show(); g.boxToggling = false; if (!g.tree && !g.grid && !p.isShowCheckBox && $('td.l-selected', g.selectBox).length > 0) { var offSet = ($('td.l-selected', g.selectBox).offset().top - g.selectBox.offset().top); $(".l-box-select-inner", g.selectBox).animate({ scrollTop: offSet }); } } } g.isShowed = g.selectBox.is(":visible"); g.trigger('toggle', [isHide]); g.trigger(isHide ? 'hide' : 'show'); } }); $.ligerui.controls.ComboBox.prototype.setValue = $.ligerui.controls.ComboBox.prototype.selectValue; //设置文本框和隐藏控件的值 $.ligerui.controls.ComboBox.prototype.setInputValue = $.ligerui.controls.ComboBox.prototype._changeValue; })(jQuery);/** * jQuery ligerUI 1.1.9 * * http://ligerui.com * * Author daomi 2012 [ gd_star@163.com ] * */ (function ($) { $.fn.ligerDateEditor = function () { return $.ligerui.run.call(this, "ligerDateEditor", arguments); }; $.fn.ligerGetDateEditorManager = function () { return $.ligerui.run.call(this, "ligerGetDateEditorManager", arguments); }; $.ligerDefaults.DateEditor = { format: "yyyy-MM-dd hh:mm", showTime: false, onChangeDate: false, absolute: true //选择框是否在附加到body,并绝对定位 }; $.ligerDefaults.DateEditorString = { dayMessage: ["日", "一", "二", "三", "四", "五", "六"], monthMessage: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], todayMessage: "今天", closeMessage: "关闭" }; $.ligerMethos.DateEditor = {}; $.ligerui.controls.DateEditor = function (element, options) { $.ligerui.controls.DateEditor.base.constructor.call(this, element, options); }; $.ligerui.controls.DateEditor.ligerExtend($.ligerui.controls.Input, { __getType: function () { return 'DateEditor'; }, __idPrev: function () { return 'DateEditor'; }, _extendMethods: function () { return $.ligerMethos.DateEditor; }, _render: function () { var g = this, p = this.options; if (!p.showTime && p.format.indexOf(" hh:mm") > -1) p.format = p.format.replace(" hh:mm", ""); if (this.element.tagName.toLowerCase() != "input" || this.element.type != "text") return; g.inputText = $(this.element); if (!g.inputText.hasClass("l-text-field")) g.inputText.addClass("l-text-field"); g.link = $('
'); g.text = g.inputText.wrap('
').parent(); g.text.append('
'); g.text.append(g.link); //添加个包裹, g.textwrapper = g.text.wrap('
').parent(); var dateeditorHTML = ""; dateeditorHTML += ""; g.dateeditor = $(dateeditorHTML); if (p.absolute) g.dateeditor.appendTo('body').addClass("l-box-dateeditor-absolute"); else g.textwrapper.append(g.dateeditor); g.header = $(".l-box-dateeditor-header", g.dateeditor); g.body = $(".l-box-dateeditor-body", g.dateeditor); g.toolbar = $(".l-box-dateeditor-toolbar", g.dateeditor); g.body.thead = $("thead", g.body); g.body.tbody = $("tbody", g.body); g.body.monthselector = $(".l-box-dateeditor-monthselector", g.body); g.body.yearselector = $(".l-box-dateeditor-yearselector", g.body); g.body.hourselector = $(".l-box-dateeditor-hourselector", g.body); g.body.minuteselector = $(".l-box-dateeditor-minuteselector", g.body); g.toolbar.time = $(".l-box-dateeditor-time", g.toolbar); g.toolbar.time.hour = $(""); g.toolbar.time.minute = $(""); g.buttons = { btnPrevYear: $(".l-box-dateeditor-header-prevyear", g.header), btnNextYear: $(".l-box-dateeditor-header-nextyear", g.header), btnPrevMonth: $(".l-box-dateeditor-header-prevmonth", g.header), btnNextMonth: $(".l-box-dateeditor-header-nextmonth", g.header), btnYear: $(".l-box-dateeditor-header-year", g.header), btnMonth: $(".l-box-dateeditor-header-month", g.header), btnToday: $(".l-button-today", g.toolbar), btnClose: $(".l-button-close", g.toolbar) }; var nowDate = new Date(); g.now = { year: nowDate.getFullYear(), month: nowDate.getMonth() + 1, //注意这里 day: nowDate.getDay(), date: nowDate.getDate(), hour: nowDate.getHours(), minute: nowDate.getMinutes() }; //当前的时间 g.currentDate = { year: nowDate.getFullYear(), month: nowDate.getMonth() + 1, day: nowDate.getDay(), date: nowDate.getDate(), hour: nowDate.getHours(), minute: nowDate.getMinutes() }; //选择的时间 g.selectedDate = null; //使用的时间 g.usedDate = null; //初始化数据 //设置周日至周六 $("td", g.body.thead).each(function (i, td) { $(td).html(p.dayMessage[i]); }); //设置一月到十一二月 $("li", g.body.monthselector).each(function (i, li) { $(li).html(p.monthMessage[i]); }); //设置按钮 g.buttons.btnToday.html(p.todayMessage); g.buttons.btnClose.html(p.closeMessage); //设置时间 if (p.showTime) { g.toolbar.time.show(); g.toolbar.time.append(g.toolbar.time.hour).append(":").append(g.toolbar.time.minute); $("li", g.body.hourselector).each(function (i, item) { var str = i; if (i < 10) str = "0" + i.toString(); $(this).html(str); }); $("li", g.body.minuteselector).each(function (i, item) { var str = i; if (i < 10) str = "0" + i.toString(); $(this).html(str); }); } //设置主体 g.bulidContent(); //初始化 if (g.inputText.val() != "") g.onTextChange(); /************** **bulid evens** *************/ g.dateeditor.hover(null, function (e) { if (g.dateeditor.is(":visible") && !g.editorToggling) { g.toggleDateEditor(true); } }); //toggle even g.link.hover(function () { if (p.disabled) return; this.className = "l-trigger-hover"; }, function () { if (p.disabled) return; this.className = "l-trigger"; }).mousedown(function () { if (p.disabled) return; this.className = "l-trigger-pressed"; }).mouseup(function () { if (p.disabled) return; this.className = "l-trigger-hover"; }).click(function () { if (p.disabled) return; g.bulidContent(); g.toggleDateEditor(g.dateeditor.is(":visible")); }); //不可用属性时处理 if (p.disabled) { g.inputText.attr("readonly", "readonly"); g.text.addClass('l-text-disabled'); } //初始值 if (p.initValue) { g.inputText.val(p.initValue); } g.buttons.btnClose.click(function () { g.toggleDateEditor(true); }); //日期 点击 $("td", g.body.tbody).hover(function () { if ($(this).hasClass("l-box-dateeditor-today")) return; $(this).addClass("l-box-dateeditor-over"); }, function () { $(this).removeClass("l-box-dateeditor-over"); }).click(function () { $(".l-box-dateeditor-selected", g.body.tbody).removeClass("l-box-dateeditor-selected"); if (!$(this).hasClass("l-box-dateeditor-today")) $(this).addClass("l-box-dateeditor-selected"); g.currentDate.date = parseInt($(this).html()); g.currentDate.day = new Date(g.currentDate.year, g.currentDate.month - 1, 1).getDay(); if ($(this).hasClass("l-box-dateeditor-out")) { if ($("tr", g.body.tbody).index($(this).parent()) == 0) { if (--g.currentDate.month == 0) { g.currentDate.month = 12; g.currentDate.year--; } } else { if (++g.currentDate.month == 13) { g.currentDate.month = 1; g.currentDate.year++; } } } g.selectedDate = { year: g.currentDate.year, month: g.currentDate.month, date: g.currentDate.date }; g.showDate(); g.editorToggling = true; g.dateeditor.slideToggle('fast', function () { g.editorToggling = false; }); }); $(".l-box-dateeditor-header-btn", g.header).hover(function () { $(this).addClass("l-box-dateeditor-header-btn-over"); }, function () { $(this).removeClass("l-box-dateeditor-header-btn-over"); }); //选择年份 g.buttons.btnYear.click(function () { //build year list if (!g.body.yearselector.is(":visible")) { $("li", g.body.yearselector).each(function (i, item) { var currentYear = g.currentDate.year + (i - 4); if (currentYear == g.currentDate.year) $(this).addClass("l-selected"); else $(this).removeClass("l-selected"); $(this).html(currentYear); }); } g.body.yearselector.slideToggle(); }); g.body.yearselector.hover(function () { }, function () { $(this).slideUp(); }); $("li", g.body.yearselector).click(function () { g.currentDate.year = parseInt($(this).html()); g.body.yearselector.slideToggle(); g.bulidContent(); }); //select month g.buttons.btnMonth.click(function () { $("li", g.body.monthselector).each(function (i, item) { //add selected style if (g.currentDate.month == i + 1) $(this).addClass("l-selected"); else $(this).removeClass("l-selected"); }); g.body.monthselector.slideToggle(); }); g.body.monthselector.hover(function () { }, function () { $(this).slideUp("fast"); }); $("li", g.body.monthselector).click(function () { var index = $("li", g.body.monthselector).index(this); g.currentDate.month = index + 1; g.body.monthselector.slideToggle(); g.bulidContent(); }); //选择小时 g.toolbar.time.hour.click(function () { $("li", g.body.hourselector).each(function (i, item) { //add selected style if (g.currentDate.hour == i) $(this).addClass("l-selected"); else $(this).removeClass("l-selected"); }); g.body.hourselector.slideToggle(); }); g.body.hourselector.hover(function () { }, function () { $(this).slideUp("fast"); }); $("li", g.body.hourselector).click(function () { var index = $("li", g.body.hourselector).index(this); g.currentDate.hour = index; g.body.hourselector.slideToggle(); g.bulidContent(); }); //选择分钟 g.toolbar.time.minute.click(function () { $("li", g.body.minuteselector).each(function (i, item) { //add selected style if (g.currentDate.minute == i) $(this).addClass("l-selected"); else $(this).removeClass("l-selected"); }); g.body.minuteselector.slideToggle("fast", function () { var index = $("li", this).index($('li.l-selected', this)); if (index > 29) { var offSet = ($('li.l-selected', this).offset().top - $(this).offset().top); $(this).animate({ scrollTop: offSet }); } }); }); g.body.minuteselector.hover(function () { }, function () { $(this).slideUp("fast"); }); $("li", g.body.minuteselector).click(function () { var index = $("li", g.body.minuteselector).index(this); g.currentDate.minute = index; g.body.minuteselector.slideToggle("fast"); g.bulidContent(); }); //上个月 g.buttons.btnPrevMonth.click(function () { if (--g.currentDate.month == 0) { g.currentDate.month = 12; g.currentDate.year--; } g.bulidContent(); }); //下个月 g.buttons.btnNextMonth.click(function () { if (++g.currentDate.month == 13) { g.currentDate.month = 1; g.currentDate.year++; } g.bulidContent(); }); //上一年 g.buttons.btnPrevYear.click(function () { g.currentDate.year--; g.bulidContent(); }); //下一年 g.buttons.btnNextYear.click(function () { g.currentDate.year++; g.bulidContent(); }); //今天 g.buttons.btnToday.click(function () { g.currentDate = { year: g.now.year, month: g.now.month, day: g.now.day, date: g.now.date }; g.selectedDate = { year: g.now.year, month: g.now.month, day: g.now.day, date: g.now.date }; g.showDate(); g.dateeditor.slideToggle("fast"); }); //文本框 g.inputText.change(function () { g.onTextChange(); }).blur(function () { g.text.removeClass("l-text-focus"); }).focus(function () { g.text.addClass("l-text-focus"); }); g.text.hover(function () { g.text.addClass("l-text-over"); }, function () { g.text.removeClass("l-text-over"); }); //LEABEL 支持 if (p.label) { g.labelwrapper = g.textwrapper.wrap('
').parent(); g.labelwrapper.prepend('
' + p.label + ': 
'); g.textwrapper.css('float', 'left'); if (!p.labelWidth) { p.labelWidth = $('.l-text-label', g.labelwrapper).outerWidth(); } else { $('.l-text-label', g.labelwrapper).outerWidth(p.labelWidth); } $('.l-text-label', g.labelwrapper).width(p.labelWidth); $('.l-text-label', g.labelwrapper).height(g.text.height()); g.labelwrapper.append('
'); if (p.labelAlign) { $('.l-text-label', g.labelwrapper).css('text-align', p.labelAlign); } g.textwrapper.css({ display: 'inline' }); g.labelwrapper.width(g.text.outerWidth() + p.labelWidth + 2); } g.set(p); }, destroy: function () { if (this.textwrapper) this.textwrapper.remove(); if (this.dateeditor) this.dateeditor.remove(); this.options = null; $.ligerui.remove(this); }, bulidContent: function () { var g = this, p = this.options; //当前月第一天星期 var thismonthFirstDay = new Date(g.currentDate.year, g.currentDate.month - 1, 1).getDay(); //当前月天数 var nextMonth = g.currentDate.month; var nextYear = g.currentDate.year; if (++nextMonth == 13) { nextMonth = 1; nextYear++; } var monthDayNum = new Date(nextYear, nextMonth - 1, 0).getDate(); //当前上个月天数 var prevMonthDayNum = new Date(g.currentDate.year, g.currentDate.month - 1, 0).getDate(); g.buttons.btnMonth.html(p.monthMessage[g.currentDate.month - 1]); g.buttons.btnYear.html(g.currentDate.year); g.toolbar.time.hour.html(g.currentDate.hour); g.toolbar.time.minute.html(g.currentDate.minute); if (g.toolbar.time.hour.html().length == 1) g.toolbar.time.hour.html("0" + g.toolbar.time.hour.html()); if (g.toolbar.time.minute.html().length == 1) g.toolbar.time.minute.html("0" + g.toolbar.time.minute.html()); $("td", this.body.tbody).each(function () { this.className = "" }); $("tr", this.body.tbody).each(function (i, tr) { $("td", tr).each(function (j, td) { var id = i * 7 + (j - thismonthFirstDay); var showDay = id + 1; if (g.selectedDate && g.currentDate.year == g.selectedDate.year && g.currentDate.month == g.selectedDate.month && id + 1 == g.selectedDate.date) { if (j == 0 || j == 6) { $(td).addClass("l-box-dateeditor-holiday") } $(td).addClass("l-box-dateeditor-selected"); $(td).siblings().removeClass("l-box-dateeditor-selected"); } else if (g.currentDate.year == g.now.year && g.currentDate.month == g.now.month && id + 1 == g.now.date) { if (j == 0 || j == 6) { $(td).addClass("l-box-dateeditor-holiday") } $(td).addClass("l-box-dateeditor-today"); } else if (id < 0) { showDay = prevMonthDayNum + showDay; $(td).addClass("l-box-dateeditor-out") .removeClass("l-box-dateeditor-selected"); } else if (id > monthDayNum - 1) { showDay = showDay - monthDayNum; $(td).addClass("l-box-dateeditor-out") .removeClass("l-box-dateeditor-selected"); } else if (j == 0 || j == 6) { $(td).addClass("l-box-dateeditor-holiday") .removeClass("l-box-dateeditor-selected"); } else { td.className = ""; } $(td).html(showDay); }); }); }, updateSelectBoxPosition: function () { var g = this, p = this.options; if (p.absolute) { g.dateeditor.css({ left: g.text.offset().left, top: g.text.offset().top + 1 + g.text.outerHeight() }); } else { if (g.text.offset().top + 4 > g.dateeditor.height() && g.text.offset().top + g.dateeditor.height() + textHeight + 4 - $(window).scrollTop() > $(window).height()) { g.dateeditor.css("marginTop", -1 * (g.dateeditor.height() + textHeight + 5)); g.showOnTop = true; } else { g.showOnTop = false; } } }, toggleDateEditor: function (isHide) { var g = this, p = this.options; var textHeight = g.text.height(); g.editorToggling = true; if (isHide) { g.dateeditor.hide('fast', function () { g.editorToggling = false; }); } else { g.updateSelectBoxPosition(); g.dateeditor.slideDown('fast', function () { g.editorToggling = false; }); } }, showDate: function () { var g = this, p = this.options; if (!this.selectedDate) return; var dateStr = g.selectedDate.year + "/" + g.selectedDate.month + "/" + g.selectedDate.date; this.currentDate.hour = parseInt(g.toolbar.time.hour.html(), 10); this.currentDate.minute = parseInt(g.toolbar.time.minute.html(), 10); if (p.showTime) { dateStr += " " + this.currentDate.hour + ":" + this.currentDate.minute; } this.inputText.val(dateStr); this.inputText.trigger("change").focus(); }, isDateTime: function (dateStr) { var g = this, p = this.options; var r = dateStr.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/); if (r == null) return false; var d = new Date(r[1], r[3] - 1, r[4]); if (d == "NaN") return false; return (d.getFullYear() == r[1] && (d.getMonth() + 1) == r[3] && d.getDate() == r[4]); }, isLongDateTime: function (dateStr) { var g = this, p = this.options; var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2})$/; var r = dateStr.match(reg); if (r == null) return false; var d = new Date(r[1], r[3] - 1, r[4], r[5], r[6]); if (d == "NaN") return false; return (d.getFullYear() == r[1] && (d.getMonth() + 1) == r[3] && d.getDate() == r[4] && d.getHours() == r[5] && d.getMinutes() == r[6]); }, getFormatDate: function (date) { var g = this, p = this.options; if (date == "NaN") return null; var format = p.format; var o = { "M+": date.getMonth() + 1, "d+": date.getDate(), "h+": date.getHours(), "m+": date.getMinutes(), "s+": date.getSeconds(), "q+": Math.floor((date.getMonth() + 3) / 3), "S": date.getMilliseconds() } if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (date.getFullYear() + "") .substr(4 - RegExp.$1.length)); } for (var k in o) { if (new RegExp("(" + k + ")").test(format)) { format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); } } return format; }, onTextChange: function () { var g = this, p = this.options; var val = g.inputText.val(); if (val == "") { g.selectedDate = null; return true; } if (!p.showTime && !g.isDateTime(val)) { //恢复 if (!g.usedDate) { g.inputText.val(""); } else { g.inputText.val(g.getFormatDate(g.usedDate)); } } else if (p.showTime && !g.isLongDateTime(val)) { //恢复 if (!g.usedDate) { g.inputText.val(""); } else { g.inputText.val(g.getFormatDate(g.usedDate)); } } else { val = val.replace(/-/g, "/"); var formatVal = g.getFormatDate(new Date(val)); if (formatVal == null) { //恢复 if (!g.usedDate) { g.inputText.val(""); } else { g.inputText.val(g.getFormatDate(g.usedDate)); } } g.usedDate = new Date(val); //记录 g.selectedDate = { year: g.usedDate.getFullYear(), month: g.usedDate.getMonth() + 1, //注意这里 day: g.usedDate.getDay(), date: g.usedDate.getDate(), hour: g.usedDate.getHours(), minute: g.usedDate.getMinutes() }; g.currentDate = { year: g.usedDate.getFullYear(), month: g.usedDate.getMonth() + 1, //注意这里 day: g.usedDate.getDay(), date: g.usedDate.getDate(), hour: g.usedDate.getHours(), minute: g.usedDate.getMinutes() }; g.inputText.val(formatVal); g.trigger('changeDate', [formatVal]); if ($(g.dateeditor).is(":visible")) g.bulidContent(); } }, _setHeight: function (value) { var g = this; if (value > 4) { g.text.css({ height: value }); g.inputText.css({ height: value }); g.textwrapper.css({ height: value }); } }, _setWidth: function (value) { var g = this; if (value > 20) { g.text.css({ width: value }); g.inputText.css({ width: value - 20 }); g.textwrapper.css({ width: value }); } }, _setValue: function (value) { var g = this; if (!value) g.inputText.val(''); if (typeof value == "string") { g.inputText.val(value); } else if (typeof value == "object") { if (value instanceof Date) { g.inputText.val(g.getFormatDate(value)); g.onTextChange(); } } }, _getValue: function () { return this.usedDate; }, setEnabled: function () { var g = this, p = this.options; this.inputText.removeAttr("readonly"); this.text.removeClass('l-text-disabled'); p.disabled = false; }, setDisabled: function () { var g = this, p = this.options; this.inputText.attr("readonly", "readonly"); this.text.addClass('l-text-disabled'); p.disabled = true; } }); })(jQuery);/** * jQuery ligerUI 1.1.9 * * http://ligerui.com * * Author daomi 2012 [ gd_star@163.com ] * */ (function ($) { var l = $.ligerui; //全局事件 $(".l-dialog-btn").live('mouseover', function () { $(this).addClass("l-dialog-btn-over"); }).live('mouseout', function () { $(this).removeClass("l-dialog-btn-over"); }); $(".l-dialog-tc .l-dialog-close").live('mouseover', function () { $(this).addClass("l-dialog-close-over"); }).live('mouseout', function () { $(this).removeClass("l-dialog-close-over"); }); $.ligerDialog = function () { return l.run.call(null, "ligerDialog", arguments, { isStatic: true }); }; //dialog 图片文件夹的路径 预加载 $.ligerui.DialogImagePath = "../../lib/ligerUI/skins/Aqua/images/win/"; function prevImage(paths) { for (var i in paths) { $('').attr('src', l.DialogImagePath + paths[i]); } } //prevImage(['dialog.gif', 'dialog-winbtns.gif', 'dialog-bc.gif', 'dialog-tc.gif']); $.ligerDefaults.Dialog = { cls: null, //给dialog附加css class id: null, //给dialog附加id buttons: null, //按钮集合 isDrag: true, //是否拖动 width: 280, //宽度 height: null, //高度,默认自适应 content: '', //内容 target: null, //目标对象,指定它将以appendTo()的方式载入 url: null, //目标页url,默认以iframe的方式载入 load: false, //是否以load()的方式加载目标页的内容 onLoaded: null, type: 'none', //类型 warn、success、error、question left: null, //位置left top: null, //位置top modal: true, //是否模态对话框 name: null, //创建iframe时 作为iframe的name和id isResize: false, // 是否调整大小 allowClose: true, //允许关闭 opener: null, timeParmName: null, //是否给URL后面加上值为new Date().getTime()的参数,如果需要指定一个参数名即可 closeWhenEnter: null, //回车时是否关闭dialog isHidden: true, //关闭对话框时是否只是隐藏,还是销毁对话框 show: true, //初始化时是否马上显示 title: '提示', //头部 showMax: false, //是否显示最大化按钮 showToggle: false, //是否显示收缩窗口按钮 showMin: false, //是否显示最小化按钮 slide: $.browser.msie ? false : true, //是否以动画的形式显示 fixedType: null, //在固定的位置显示, 可以设置的值有n, e, s, w, ne, se, sw, nw showType: null //显示类型,可以设置为slide(固定显示时有效) }; $.ligerDefaults.DialogString = { titleMessage: '提示', //提示文本标题 ok: '确定', yes: '是', no: '否', cancel: '取消', waittingMessage: '正在等待中,请稍候...' }; $.ligerMethos.Dialog = $.ligerMethos.Dialog || {}; l.controls.Dialog = function (options) { l.controls.Dialog.base.constructor.call(this, null, options); }; l.controls.Dialog.ligerExtend(l.core.Win, { __getType: function () { return 'Dialog'; }, __idPrev: function () { return 'Dialog'; }, _extendMethods: function () { return $.ligerMethos.Dialog; }, _render: function () { var g = this, p = this.options; g.set(p, true); var dialog = $('
'); $('body').append(dialog); g.dialog = dialog; g.element = dialog[0]; g.dialog.body = $(".l-dialog-body:first", g.dialog); g.dialog.header = $(".l-dialog-tc-inner:first", g.dialog); g.dialog.winbtns = $(".l-dialog-winbtns:first", g.dialog.header); g.dialog.buttons = $(".l-dialog-buttons:first", g.dialog); g.dialog.content = $(".l-dialog-content:first", g.dialog); g.set(p, false); if (p.allowClose == false) $(".l-dialog-close", g.dialog).remove(); if (p.target || p.url || p.type == "none") { p.type = null; g.dialog.addClass("l-dialog-win"); } if (p.cls) g.dialog.addClass(p.cls); if (p.id) g.dialog.attr("id", p.id); //设置锁定屏幕、拖动支持 和设置图片 g.mask(); if (p.isDrag) g._applyDrag(); if (p.isResize) g._applyResize(); if (p.type) g._setImage(); else { $(".l-dialog-image", g.dialog).remove(); g.dialog.content.addClass("l-dialog-content-noimage"); } if (!p.show) { g.unmask(); g.dialog.hide(); } //设置主体内容 if (p.target) { g.dialog.content.prepend(p.target); $(p.target).show(); } else if (p.url) { if (p.timeParmName) { p.url += p.url.indexOf('?') == -1 ? "?" : "&"; p.url += p.timeParmName + "=" + new Date().getTime(); } if (p.load) { g.dialog.body.load(p.url, function () { g._saveStatus(); g.trigger('loaded'); }); } else { g.jiframe = $(""); var framename = p.name ? p.name : "ligerwindow" + new Date().getTime(); g.jiframe.attr("name", framename); g.jiframe.attr("id", framename); g.dialog.content.prepend(g.jiframe); g.dialog.content.addClass("l-dialog-content-nopadding"); setTimeout(function () { g.jiframe.attr("src", p.url); g.frame = window.frames[g.jiframe.attr("name")]; }, 0); } } if (p.opener) g.dialog.opener = p.opener; //设置按钮 if (p.buttons) { $(p.buttons).each(function (i, item) { var btn = $('
'); $(".l-dialog-btn-inner", btn).html(item.text); $(".l-dialog-buttons-inner", g.dialog.buttons).prepend(btn); item.width && btn.width(item.width); item.onclick && btn.click(function () { item.onclick(item, g, i) }); }); } else { g.dialog.buttons.remove(); } $(".l-dialog-buttons-inner", g.dialog.buttons).append("
"); $(".l-dialog-title", g.dialog) .bind("selectstart", function () { return false; }); g.dialog.click(function () { l.win.setFront(g); }); //设置事件 $(".l-dialog-tc .l-dialog-close", g.dialog).click(function () { if (p.isHidden) g.hide(); else g.close(); }); if (!p.fixedType) { //位置初始化 var left = 0; var top = 0; var width = p.width || g.dialog.width(); if (p.slide == true) p.slide = 'fast'; if (p.left != null) left = p.left; else p.left = left = 0.5 * ($(window).width() - width); if (p.top != null) top = p.top; else p.top = top = 0.5 * ($(window).height() - g.dialog.height()) + $(window).scrollTop() - 10; if (left < 0) p.left = left = 0; if (top < 0) p.top = top = 0; g.dialog.css({ left: left, top: top }); } g.show(); $('body').bind('keydown.dialog', function (e) { var key = e.which; if (key == 13) { g.enter(); } else if (key == 27) { g.esc(); } }); g._updateBtnsWidth(); g._saveStatus(); g._onReisze(); }, _borderX: 12, _borderY: 32, doMax: function (slide) { var g = this, p = this.options; var width = $(window).width(), height = $(window).height(), left = 0, top = 0; if (l.win.taskbar) { height -= l.win.taskbar.outerHeight(); if (l.win.top) top += l.win.taskbar.outerHeight(); } if (slide) { g.dialog.body.animate({ width: width - g._borderX }, p.slide); g.dialog.animate({ left: left, top: top }, p.slide); g.dialog.content.animate({ height: height - g._borderY - g.dialog.buttons.outerHeight() }, p.slide, function () { g._onReisze(); }); } else { g.set({ width: width, height: height, left: left, top: top }); g._onReisze(); } }, //最大化 max: function () { var g = this, p = this.options; if (g.winmax) { g.winmax.addClass("l-dialog-recover"); g.doMax(p.slide); if (g.wintoggle) { if (g.wintoggle.hasClass("l-dialog-extend")) g.wintoggle.addClass("l-dialog-toggle-disabled l-dialog-extend-disabled"); else g.wintoggle.addClass("l-dialog-toggle-disabled l-dialog-collapse-disabled"); } if (g.resizable) g.resizable.set({ disabled: true }); if (g.draggable) g.draggable.set({ disabled: true }); g.maximum = true; $(window).bind('resize.dialogmax', function () { g.doMax(false); }); } }, //恢复 recover: function () { var g = this, p = this.options; if (g.winmax) { g.winmax.removeClass("l-dialog-recover"); if (p.slide) { g.dialog.body.animate({ width: g._width - g._borderX }, p.slide); g.dialog.animate({ left: g._left, top: g._top }, p.slide); g.dialog.content.animate({ height: g._height - g._borderY - g.dialog.buttons.outerHeight() }, p.slide, function () { g._onReisze(); }); } else { g.set({ width: g._width, height: g._height, left: g._left, top: g._top }); g._onReisze(); } if (g.wintoggle) { g.wintoggle.removeClass("l-dialog-toggle-disabled l-dialog-extend-disabled l-dialog-collapse-disabled"); } $(window).unbind('resize.dialogmax'); } if (this.resizable) this.resizable.set({ disabled: false }); if (g.draggable) g.draggable.set({ disabled: false }); g.maximum = false; }, //最小化 min: function () { var g = this, p = this.options; var task = l.win.getTask(this); if (p.slide) { g.dialog.body.animate({ width: 1 }, p.slide); task.y = task.offset().top + task.height(); task.x = task.offset().left + task.width() / 2; g.dialog.animate({ left: task.x, top: task.y }, p.slide, function () { g.dialog.hide(); }); } else { g.dialog.hide(); } g.unmask(); g.minimize = true; g.actived = false; }, active: function () { var g = this, p = this.options; if (g.minimize) { var width = g._width, height = g._height, left = g._left, top = g._top; if (g.maximum) { width = $(window).width(); height = $(window).height(); left = top = 0; if (l.win.taskbar) { height -= l.win.taskbar.outerHeight(); if (l.win.top) top += l.win.taskbar.outerHeight(); } } if (p.slide) { g.dialog.body.animate({ width: width - g._borderX }, p.slide); g.dialog.animate({ left: left, top: top }, p.slide); } else { g.set({ width: width, height: height, left: left, top: top }); } } g.actived = true; g.minimize = false; l.win.setFront(g); g.show(); }, //展开 收缩 toggle: function () { var g = this, p = this.options; if (!g.wintoggle) return; if (g.wintoggle.hasClass("l-dialog-extend")) g.extend(); else g.collapse(); }, //收缩 collapse: function () { var g = this, p = this.options; if (!g.wintoggle) return; if (p.slide) g.dialog.content.animate({ height: 1 }, p.slide); else g.dialog.content.height(1); if (this.resizable) this.resizable.set({ disabled: true }); }, //展开 extend: function () { var g = this, p = this.options; if (!g.wintoggle) return; var contentHeight = g._height - g._borderY - g.dialog.buttons.outerHeight(); if (p.slide) g.dialog.content.animate({ height: contentHeight }, p.slide); else g.dialog.content.height(contentHeight); if (this.resizable) this.resizable.set({ disabled: false }); }, _updateBtnsWidth: function () { var g = this; var btnscount = $(">div", g.dialog.winbtns).length; g.dialog.winbtns.width(22 * btnscount); }, _setLeft: function (value) { if (!this.dialog) return; if (value != null) this.dialog.css({ left: value }); }, _setTop: function (value) { if (!this.dialog) return; if (value != null) this.dialog.css({ top: value }); }, _setWidth: function (value) { if (!this.dialog) return; if (value >= this._borderX) { this.dialog.body.width(value - this._borderX); } }, _setHeight: function (value) { var g = this, p = this.options; if (!this.dialog) return; if (value >= this._borderY) { var height = value - this._borderY - g.dialog.buttons.outerHeight(); g.dialog.content.height(height); } }, _setShowMax: function (value) { var g = this, p = this.options; if (value) { if (!g.winmax) { g.winmax = $('
').appendTo(g.dialog.winbtns) .hover(function () { if ($(this).hasClass("l-dialog-recover")) $(this).addClass("l-dialog-recover-over"); else $(this).addClass("l-dialog-max-over"); }, function () { $(this).removeClass("l-dialog-max-over l-dialog-recover-over"); }).click(function () { if ($(this).hasClass("l-dialog-recover")) g.recover(); else g.max(); }); } } else if (g.winmax) { g.winmax.remove(); g.winmax = null; } g._updateBtnsWidth(); }, _setShowMin: function (value) { var g = this, p = this.options; if (value) { if (!g.winmin) { g.winmin = $('
').appendTo(g.dialog.winbtns) .hover(function () { $(this).addClass("l-dialog-min-over"); }, function () { $(this).removeClass("l-dialog-min-over"); }).click(function () { g.min(); }); l.win.addTask(g); } } else if (g.winmin) { g.winmin.remove(); g.winmin = null; } g._updateBtnsWidth(); }, _setShowToggle: function (value) { var g = this, p = this.options; if (value) { if (!g.wintoggle) { g.wintoggle = $('
').appendTo(g.dialog.winbtns) .hover(function () { if ($(this).hasClass("l-dialog-toggle-disabled")) return; if ($(this).hasClass("l-dialog-extend")) $(this).addClass("l-dialog-extend-over"); else $(this).addClass("l-dialog-collapse-over"); }, function () { $(this).removeClass("l-dialog-extend-over l-dialog-collapse-over"); }).click(function () { if ($(this).hasClass("l-dialog-toggle-disabled")) return; if (g.wintoggle.hasClass("l-dialog-extend")) { if (g.trigger('extend') == false) return; g.wintoggle.removeClass("l-dialog-extend"); g.extend(); g.trigger('extended'); } else { if (g.trigger('collapse') == false) return; g.wintoggle.addClass("l-dialog-extend"); g.collapse(); g.trigger('collapseed') } }); } } else if (g.wintoggle) { g.wintoggle.remove(); g.wintoggle = null; } }, //按下回车 enter: function () { var g = this, p = this.options; var isClose; if (p.closeWhenEnter != undefined) { isClose = p.closeWhenEnter; } else if (p.type == "warn" || p.type == "error" || p.type == "success" || p.type == "question") { isClose = true; } if (isClose) { g.close(); } }, esc: function () { }, _removeDialog: function () { var g = this, p = this.options; if (p.showType && p.fixedType) { g.dialog.animate({ bottom: -1 * p.height }, function () { g.dialog.remove(); }); } else { g.dialog.remove(); } }, close: function () { var g = this, p = this.options; l.win.removeTask(this); g.unmask(); g._removeDialog(); $('body').unbind('keydown.dialog'); }, _getVisible: function () { return this.dialog.is(":visible"); }, _setUrl: function (url) { var g = this, p = this.options; p.url = url; if (p.load) { g.dialog.body.html("").load(p.url, function () { g.trigger('loaded'); }); } else if (g.jiframe) { g.jiframe.attr("src", p.url); } }, _setContent: function (content) { this.dialog.content.html(content); }, _setTitle: function (value) { var g = this; var p = this.options; if (value) { $(".l-dialog-title", g.dialog).html(value); } }, _hideDialog: function () { var g = this, p = this.options; if (p.showType && p.fixedType) { g.dialog.animate({ bottom: -1 * p.height }, function () { g.dialog.hide(); }); } else { g.dialog.hide(); } }, hidden: function () { var g = this; l.win.removeTask(g); g.dialog.hide(); g.unmask(); }, show: function () { var g = this, p = this.options; g.mask(); if (p.fixedType) { if (p.showType) { g.dialog.css({ bottom: -1 * p.height }).addClass("l-dialog-fixed"); g.dialog.show().animate({ bottom: 0 }); } else { g.dialog.show().css({ bottom: 0 }); } } else { g.dialog.show(); } //前端显示 $.ligerui.win.setFront.ligerDefer($.ligerui.win, 100, [g]); }, setUrl: function (url) { this._setUrl(url); }, _saveStatus: function () { var g = this; g._width = g.dialog.body.width(); g._height = g.dialog.body.height(); var top = 0; var left = 0; if (!isNaN(parseInt(g.dialog.css('top')))) top = parseInt(g.dialog.css('top')); if (!isNaN(parseInt(g.dialog.css('left')))) left = parseInt(g.dialog.css('left')); g._top = top; g._left = left; }, _applyDrag: function () { var g = this, p = this.options; if ($.fn.ligerDrag) g.draggable = g.dialog.ligerDrag({ handler: '.l-dialog-title', animate: false, onStartDrag: function () { l.win.setFront(g); }, onStopDrag: function () { if (p.target) { var triggers1 = l.find($.ligerui.controls.DateEditor); var triggers2 = l.find($.ligerui.controls.ComboBox); //更新所有下拉选择框的位置 $($.merge(triggers1, triggers2)).each(function () { if (this.updateSelectBoxPosition) this.updateSelectBoxPosition(); }); } g._saveStatus(); } }); }, _onReisze: function () { var g = this, p = this.options; if (p.target) { var manager = $(p.target).liger(); if (!manager) manager = $(p.target).find(":first").liger(); if (!manager) return; var contentHeight = g.dialog.content.height(); var contentWidth = g.dialog.content.width(); manager.trigger('resize', [{ width: contentWidth, height: contentHeight}]); } }, _applyResize: function () { var g = this, p = this.options; if ($.fn.ligerResizable) { g.resizable = g.dialog.ligerResizable({ onStopResize: function (current, e) { var top = 0; var left = 0; if (!isNaN(parseInt(g.dialog.css('top')))) top = parseInt(g.dialog.css('top')); if (!isNaN(parseInt(g.dialog.css('left')))) left = parseInt(g.dialog.css('left')); if (current.diffLeft) { g.set({ left: left + current.diffLeft }); } if (current.diffTop) { g.set({ top: top + current.diffTop }); } if (current.newWidth) { g.set({ width: current.newWidth }); g.dialog.body.css({ width: current.newWidth - g._borderX }); } if (current.newHeight) { g.set({ height: current.newHeight }); } g._onReisze(); g._saveStatus(); return false; }, animate: false }); } }, _setImage: function () { var g = this, p = this.options; if (p.type) { if (p.type == 'success' || p.type == 'donne' || p.type == 'ok') { $(".l-dialog-image", g.dialog).addClass("l-dialog-image-donne").show(); g.dialog.content.css({ paddingLeft: 64, paddingBottom: 30 }); } else if (p.type == 'error') { $(".l-dialog-image", g.dialog).addClass("l-dialog-image-error").show(); g.dialog.content.css({ paddingLeft: 64, paddingBottom: 30 }); } else if (p.type == 'warn') { $(".l-dialog-image", g.dialog).addClass("l-dialog-image-warn").show(); g.dialog.content.css({ paddingLeft: 64, paddingBottom: 30 }); } else if (p.type == 'question') { $(".l-dialog-image", g.dialog).addClass("l-dialog-image-question").show(); g.dialog.content.css({ paddingLeft: 64, paddingBottom: 40 }); } } } }); l.controls.Dialog.prototype.hide = l.controls.Dialog.prototype.hidden; $.ligerDialog.open = function (p) { return $.ligerDialog(p); }; $.ligerDialog.close = function () { var dialogs = l.find(l.controls.Dialog.prototype.__getType()); for (var i in dialogs) { var d = dialogs[i]; d.destroy.ligerDefer(d, 5); } l.win.unmask(); }; $.ligerDialog.show = function (p) { var dialogs = l.find(l.controls.Dialog.prototype.__getType()); if (dialogs.length) { for (var i in dialogs) { dialogs[i].show(); return; } } return $.ligerDialog(p); }; $.ligerDialog.hide = function () { var dialogs = l.find(l.controls.Dialog.prototype.__getType()); for (var i in dialogs) { var d = dialogs[i]; d.hide(); } }; $.ligerDialog.tip = function (options) { options = $.extend({ showType: 'slide', width: 240, modal: false, height: 100 }, options || {}); $.extend(options, { fixedType: 'se', type: 'none', isDrag: false, isResize: false, showMax: false, showToggle: false, showMin: false }); return $.ligerDialog.open(options); }; $.ligerDialog.alert = function (content, title, type, callback) { content = content || ""; if (typeof (title) == "function") { callback = title; type = null; } else if (typeof (type) == "function") { callback = type; } var btnclick = function (item, Dialog, index) { Dialog.close(); if (callback) callback(item, Dialog, index); }; p = { content: content, buttons: [{ text: $.ligerDefaults.DialogString.ok, onclick: btnclick}] }; if (typeof (title) == "string" && title != "") p.title = title; if (typeof (type) == "string" && type != "") p.type = type; $.extend(p, { showMax: false, showToggle: false, showMin: false }); return $.ligerDialog(p); }; $.ligerDialog.confirm = function (content, title, callback) { if (typeof (title) == "function") { callback = title; type = null; } var btnclick = function (item, Dialog) { Dialog.close(); if (callback) { callback(item.type == 'ok'); } }; p = { type: 'question', content: content, buttons: [{ text: $.ligerDefaults.DialogString.yes, onclick: btnclick, type: 'ok' }, { text: $.ligerDefaults.DialogString.no, onclick: btnclick, type: 'no'}] }; if (typeof (title) == "string" && title != "") p.title = title; $.extend(p, { showMax: false, showToggle: false, showMin: false }); return $.ligerDialog(p); }; $.ligerDialog.warning = function (content, title, callback) { if (typeof (title) == "function") { callback = title; type = null; } var btnclick = function (item, Dialog) { Dialog.close(); if (callback) { callback(item.type); } }; p = { type: 'question', content: content, buttons: [{ text: $.ligerDefaults.DialogString.yes, onclick: btnclick, type: 'yes' }, { text: $.ligerDefaults.DialogString.no, onclick: btnclick, type: 'no' }, { text: $.ligerDefaults.DialogString.cancel, onclick: btnclick, type: 'cancel'}] }; if (typeof (title) == "string" && title != "") p.title = title; $.extend(p, { showMax: false, showToggle: false, showMin: false }); return $.ligerDialog(p); }; $.ligerDialog.waitting = function (title) { title = title || $.ligerDefaults.Dialog.waittingMessage; return $.ligerDialog.open({ cls: 'l-dialog-waittingdialog', type: 'none', content: '
' + title + '
', allowClose: false }); }; $.ligerDialog.closeWaitting = function () { var dialogs = l.find(l.controls.Dialog); for (var i in dialogs) { var d = dialogs[i]; if (d.dialog.hasClass("l-dialog-waittingdialog")) d.close(); } }; $.ligerDialog.success = function (content, title, onBtnClick) { return $.ligerDialog.alert(content, title, 'success', onBtnClick); }; $.ligerDialog.error = function (content, title, onBtnClick) { return $.ligerDialog.alert(content, title, 'error', onBtnClick); }; $.ligerDialog.warn = function (content, title, onBtnClick) { return $.ligerDialog.alert(content, title, 'warn', onBtnClick); }; $.ligerDialog.question = function (content, title) { return $.ligerDialog.alert(content, title, 'question'); }; $.ligerDialog.prompt = function (title, value, multi, callback) { var target = $(''); if (typeof (multi) == "function") { callback = multi; } if (typeof (value) == "function") { callback = value; } else if (typeof (value) == "boolean") { multi = value; } if (typeof (multi) == "boolean" && multi) { target = $(''); } if (typeof (value) == "string" || typeof (value) == "int") { target.val(value); } var btnclick = function (item, Dialog, index) { Dialog.close(); if (callback) { callback(item.type == 'yes', target.val()); } } p = { title: title, target: target, width: 320, buttons: [{ text: $.ligerDefaults.DialogString.ok, onclick: btnclick, type: 'yes' }, { text: $.ligerDefaults.DialogString.cancel, onclick: btnclick, type: 'cancel'}] }; return $.ligerDialog(p); }; })(jQuery);/** * jQuery ligerUI 1.1.9 * * http://ligerui.com * * Author daomi 2012 [ gd_star@163.com ] * */ (function ($) { var l = $.ligerui; $.fn.ligerDrag = function (options) { return l.run.call(this, "ligerDrag", arguments, { idAttrName: 'ligeruidragid', hasElement: false, propertyToElemnt: 'target' } ); }; $.fn.ligerGetDragManager = function () { return l.run.call(this, "ligerGetDragManager", arguments, { idAttrName: 'ligeruidragid', hasElement: false, propertyToElemnt: 'target' }); }; $.ligerDefaults.Drag = { onStartDrag: false, onDrag: false, onStopDrag: false, handler: null, //代理 拖动时的主体,可以是'clone'或者是函数,放回jQuery 对象 proxy: true, revert: false, animate: true, onRevert: null, onEndRevert: null, //接收区域 jQuery对象或者jQuery选择字符 receive: null, //进入区域 onDragEnter: null, //在区域移动 onDragOver: null, //离开区域 onDragLeave: null, //在区域释放 onDrop: null, disabled: false, proxyX: null, //代理相对鼠标指针的位置,如果不设置则对应target的left proxyY: null }; l.controls.Drag = function (options) { l.controls.Drag.base.constructor.call(this, null, options); }; l.controls.Drag.ligerExtend(l.core.UIComponent, { __getType: function () { return 'Drag'; }, __idPrev: function () { return 'Drag'; }, _render: function () { var g = this, p = this.options; this.set(p); g.cursor = "move"; g.handler.css('cursor', g.cursor); g.handler.bind('mousedown.drag', function (e) { if (p.disabled) return; if (e.button == 2) return; g._start.call(g, e); }).bind('mousemove.drag', function () { if (p.disabled) return; g.handler.css('cursor', g.cursor); }); }, _rendered: function () { this.options.target.ligeruidragid = this.id; }, _start: function (e) { var g = this, p = this.options; if (g.reverting) return; if (p.disabled) return; g.current = { target: g.target, left: g.target.offset().left, top: g.target.offset().top, startX: e.pageX || e.screenX, startY: e.pageY || e.clientY }; if (g.trigger('startDrag', [g.current, e]) == false) return false; g.cursor = "move"; g._createProxy(p.proxy, e); //代理没有创建成功 if (p.proxy && !g.proxy) return false; (g.proxy || g.handler).css('cursor', g.cursor); $(document).bind("selectstart.drag", function () { return false; }); $(document).bind('mousemove.drag', function () { g._drag.apply(g, arguments); }); l.draggable.dragging = true; $(document).bind('mouseup.drag', function () { l.draggable.dragging = false; g._stop.apply(g, arguments); }); }, _drag: function (e) { var g = this, p = this.options; if (!g.current) return; var pageX = e.pageX || e.screenX; var pageY = e.pageY || e.screenY; g.current.diffX = pageX - g.current.startX; g.current.diffY = pageY - g.current.startY; (g.proxy || g.handler).css('cursor', g.cursor); if (g.receive) { g.receive.each(function (i, obj) { var receive = $(obj); var xy = receive.offset(); if (pageX > xy.left && pageX < xy.left + receive.width() && pageY > xy.top && pageY < xy.top + receive.height()) { if (!g.receiveEntered[i]) { g.receiveEntered[i] = true; g.trigger('dragEnter', [obj, g.proxy || g.target, e]); } else { g.trigger('dragOver', [obj, g.proxy || g.target, e]); } } else if (g.receiveEntered[i]) { g.receiveEntered[i] = false; g.trigger('dragLeave', [obj, g.proxy || g.target, e]); } }); } if (g.hasBind('drag')) { if (g.trigger('drag', [g.current, e]) != false) { g._applyDrag(); } else { g._removeProxy(); } } else { g._applyDrag(); } }, _stop: function (e) { var g = this, p = this.options; $(document).unbind('mousemove.drag'); $(document).unbind('mouseup.drag'); $(document).unbind("selectstart.drag"); if (g.receive) { g.receive.each(function (i, obj) { if (g.receiveEntered[i]) { g.trigger('drop', [obj, g.proxy || g.target, e]); } }); } if (g.proxy) { if (p.revert) { if (g.hasBind('revert')) { if (g.trigger('revert', [g.current, e]) != false) g._revert(e); else g._removeProxy(); } else { g._revert(e); } } else { g._applyDrag(g.target); g._removeProxy(); } } g.cursor = 'move'; g.trigger('stopDrag', [g.current, e]); g.current = null; g.handler.css('cursor', g.cursor); }, _revert: function (e) { var g = this; g.reverting = true; g.proxy.animate({ left: g.current.left, top: g.current.top }, function () { g.reverting = false; g._removeProxy(); g.trigger('endRevert', [g.current, e]); g.current = null; }); }, _applyDrag: function (applyResultBody) { var g = this, p = this.options; applyResultBody = applyResultBody || g.proxy || g.target; var cur = {}, changed = false; var noproxy = applyResultBody == g.target; if (g.current.diffX) { if (noproxy || p.proxyX == null) cur.left = g.current.left + g.current.diffX; else cur.left = g.current.startX + p.proxyX + g.current.diffX; changed = true; } if (g.current.diffY) { if (noproxy || p.proxyY == null) cur.top = g.current.top + g.current.diffY; else cur.top = g.current.startY + p.proxyY + g.current.diffY; changed = true; } if (applyResultBody == g.target && g.proxy && p.animate) { g.reverting = true; applyResultBody.animate(cur, function () { g.reverting = false; }); } else { applyResultBody.css(cur); } }, _setReceive: function (receive) { this.receiveEntered = {}; if (!receive) return; if (typeof receive == 'string') this.receive = $(receive); else this.receive = receive; }, _setHandler: function (handler) { var g = this, p = this.options; if (!handler) g.handler = $(p.target); else g.handler = (typeof handler == 'string' ? $(handler, p.target) : handler); }, _setTarget: function (target) { this.target = $(target); }, _setCursor: function (cursor) { this.cursor = cursor; (this.proxy || this.handler).css('cursor', cursor); }, _createProxy: function (proxy, e) { if (!proxy) return; var g = this, p = this.options; if (typeof proxy == 'function') { g.proxy = proxy.call(this.options.target, g, e); } else if (proxy == 'clone') { g.proxy = g.target.clone().css('position', 'absolute'); g.proxy.appendTo('body'); } else { g.proxy = $("
"); g.proxy.width(g.target.width()).height(g.target.height()) g.proxy.attr("dragid", g.id).appendTo('body'); } g.proxy.css({ left: p.proxyX == null ? g.current.left : g.current.startX + p.proxyX, top: p.proxyY == null ? g.current.top : g.current.startY + p.proxyY }).show(); }, _removeProxy: function () { var g = this; if (g.proxy) { g.proxy.remove(); g.proxy = null; } } }); })(jQuery);/** * jQuery ligerUI 1.1.9 * * http://ligerui.com * * Author daomi 2012 [ gd_star@163.com ] * */ (function ($) { $.fn.ligerEasyTab = function () { return $.ligerui.run.call(this, "ligerEasyTab", arguments); }; $.fn.ligerGetEasyTabManager = function () { return $.ligerui.run.call(this, "ligerGetEasyTabManager", arguments); }; $.ligerDefaults.EasyTab = {}; $.ligerMethos.EasyTab = {}; $.ligerui.controls.EasyTab = function (element, options) { $.ligerui.controls.EasyTab.base.constructor.call(this, element, options); }; $.ligerui.controls.EasyTab.ligerExtend($.ligerui.core.UIComponent, { __getType: function () { return 'EasyTab'; }, __idPrev: function () { return 'EasyTab'; }, _extendMethods: function () { return $.ligerMethos.EasyTab; }, _render: function () { var g = this, p = this.options; g.tabs = $(this.element); g.tabs.addClass("l-easytab"); var selectedIndex = 0; if ($("> div[lselected=true]", g.tabs).length > 0) selectedIndex = $("> div", g.tabs).index($("> div[lselected=true]", g.tabs)); g.tabs.ul = $(''); $("> div", g.tabs).each(function (i, box) { var li = $('
  • '); if (i == selectedIndex) $("span", li).addClass("l-selected"); if ($(box).attr("title")) $("span", li).html($(box).attr("title")); g.tabs.ul.append(li); if (!$(box).hasClass("l-easytab-panelbox")) $(box).addClass("l-easytab-panelbox"); }); g.tabs.ul.prependTo(g.tabs); //init $(".l-easytab-panelbox:eq(" + selectedIndex + ")", g.tabs).show().siblings(".l-easytab-panelbox").hide(); //add even $("> ul:first span", g.tabs).click(function () { if ($(this).hasClass("l-selected")) return; var i = $("> ul:first span", g.tabs).index(this); $(this).addClass("l-selected").parent().siblings().find("span.l-selected").removeClass("l-selected"); $(".l-easytab-panelbox:eq(" + i + ")", g.tabs).show().siblings(".l-easytab-panelbox").hide(); }).not("l-selected").hover(function () { $(this).addClass("l-over"); }, function () { $(this).removeClass("l-over"); }); g.set(p); } }); })(jQuery);/** * jQuery ligerUI 1.1.9 * * http://ligerui.com * * Author daomi 2012 [ gd_star@163.com ] * */ (function ($) { $.fn.ligerFilter = function () { return $.ligerui.run.call(this, "ligerFilter", arguments); }; $.fn.ligerGetFilterManager = function () { return $.ligerui.run.call(this, "ligerGetFilterManager", arguments); }; $.ligerDefaults.Filter = { //字段列表 fields: [], //字段类型 - 运算符 的对应关系 operators: {}, //自定义输入框(如下拉框、日期) editors: {} }; $.ligerDefaults.FilterString = { strings: { "and": "并且", "or": "或者", "equal": "相等", "notequal": "不相等", "startwith": "以..开始", "endwith": "以..结束", "like": "相似", "greater": "大于", "greaterorequal": "大于或等于", "less": "小于", "lessorequal": "小于或等于", "in": "包括在...", "notin": "不包括...", "addgroup": "增加分组", "addrule": "增加条件", "deletegroup": "删除分组" } }; $.ligerDefaults.Filter.operators['string'] = $.ligerDefaults.Filter.operators['text'] = ["equal", "notequal", "startwith", "endwith", "like", "greater", "greaterorequal", "less", "lessorequal", "in", "notin"]; $.ligerDefaults.Filter.operators['number'] = $.ligerDefaults.Filter.operators['int'] = $.ligerDefaults.Filter.operators['float'] = $.ligerDefaults.Filter.operators['date'] = ["equal", "notequal", "greater", "greaterorequal", "less", "lessorequal", "in", "notin"]; $.ligerDefaults.Filter.editors['string'] = { create: function (container, field) { var input = $(""); container.append(input); input.ligerTextBox(field.editor.options || {}); return input; }, setValue: function (input, value) { input.val(value); }, getValue: function (input) { return input.liger('option', 'value'); }, destroy: function (input) { input.liger('destroy'); } }; $.ligerDefaults.Filter.editors['date'] = { create: function (container, field) { var input = $(""); container.append(input); input.ligerDateEditor(field.editor.options || {}); return input; }, setValue: function (input, value) { input.liger('option', 'value', value); }, getValue: function (input, field) { return input.liger('option', 'value'); }, destroy: function (input) { input.liger('destroy'); } }; $.ligerDefaults.Filter.editors['number'] = { create: function (container, field) { var input = $(""); container.append(input); var options = { minValue: field.editor.minValue, maxValue: field.editor.maxValue }; input.ligerSpinner($.extend(options, field.editor.options || {})); return input; }, setValue: function (input, value) { input.val(value); }, getValue: function (input, field) { var isInt = field.editor.type == "int"; if (isInt) return parseInt(input.val(), 10); else return parseFloat(input.val()); }, destroy: function (input) { input.liger('destroy'); } }; $.ligerDefaults.Filter.editors['combobox'] = { create: function (container, field) { var input = $(""); container.append(input); var options = { data: field.data, slide: false, valueField: field.editor.valueField || field.editor.valueColumnName, textField: field.editor.textField || field.editor.displayColumnName }; $.extend(options, field.editor.options || {}); input.ligerComboBox(options); return input; }, setValue: function (input, value) { input.liger('option', 'value', value); }, getValue: function (input) { return input.liger('option', 'value'); }, destroy: function (input) { input.liger('destroy'); } }; //过滤器组件 $.ligerui.controls.Filter = function (element, options) { $.ligerui.controls.Filter.base.constructor.call(this, element, options); }; $.ligerui.controls.Filter.ligerExtend($.ligerui.core.UIComponent, { __getType: function () { return 'Filter' }, __idPrev: function () { return 'Filter'; }, _init: function () { $.ligerui.controls.Filter.base._init.call(this); }, _render: function () { var g = this, p = this.options; g.set(p); //事件:增加分组 $("#" + g.id + " .addgroup").live('click', function () { var jtable = $(this).parent().parent().parent().parent(); g.addGroup(jtable); }); //事件:删除分组 $("#" + g.id + " .deletegroup").live('click', function () { var jtable = $(this).parent().parent().parent().parent(); g.deleteGroup(jtable); }); //事件:增加条件 $("#" + g.id + " .addrule").live('click', function () { var jtable = $(this).parent().parent().parent().parent(); g.addRule(jtable); }); //事件:删除条件 $("#" + g.id + " .deleterole").live('click', function () { var rulerow = $(this).parent().parent(); g.deleteRule(rulerow); }); }, //设置字段列表 _setFields: function (fields) { var g = this, p = this.options; if (g.group) g.group.remove(); g.group = $(g._bulidGroupTableHtml()).appendTo(g.element); }, //输入框列表 editors: {}, //输入框计算器 editorCounter: 0, //增加分组 //@parm [jgroup] jQuery对象(主分组的table dom元素) addGroup: function (jgroup) { var g = this, p = this.options; jgroup = $(jgroup || g.group); var lastrow = $(">tbody:first > tr:last", jgroup); var groupHtmlArr = []; groupHtmlArr.push(''); var altering = !jgroup.hasClass("l-filter-group-alt"); groupHtmlArr.push(g._bulidGroupTableHtml(altering, true)); groupHtmlArr.push(''); var row = $(groupHtmlArr.join('')); lastrow.before(row); return row.find("table:first"); }, //删除分组 deleteGroup: function (group) { var g = this, p = this.options; $("td.l-filter-value", group).each(function () { var rulerow = $(this).parent(); $("select.fieldsel", rulerow).unbind(); g.removeEditor(rulerow); }); $(group).parent().parent().remove(); }, //删除编辑器 removeEditor: function (rulerow) { var g = this, p = this.options; var type = $(rulerow).attr("editortype"); var id = $(rulerow).attr("editorid"); var editor = g.editors[id]; if (editor) p.editors[type].destroy(editor); $("td.l-filter-value:first", rulerow).html(""); }, //设置规则 //@parm [group] 分组数据 //@parm [jgruop] 分组table dom jQuery对象 setData: function (group, jgroup) { var g = this, p = this.options; jgroup = jgroup || g.group; var lastrow = $(">tbody:first > tr:last", jgroup); jgroup.find(">tbody:first > tr").not(lastrow).remove(); $("select:first", lastrow).val(group.op); if (group.rules) { $(group.rules).each(function () { var rulerow = g.addRule(jgroup); rulerow.attr("fieldtype", this.type || "string"); $("select.opsel", rulerow).val(this.op); $("select.fieldsel", rulerow).val(this.field).trigger('change'); var editorid = rulerow.attr("editorid"); if (editorid && g.editors[editorid]) { var field = g.getField(this.field); p.editors[field.editor.type].setValue(g.editors[editorid], this.value, field); } else { $(":text", rulerow).val(this.value); } }); } if (group.groups) { $(group.groups).each(function () { var subjgroup = g.addGroup(jgroup); g.setData(this, subjgroup); }); } }, //增加一个条件 //@parm [jgroup] 分组的jQuery对象 addRule: function (jgroup) { var g = this, p = this.options; jgroup = jgroup || g.group; var lastrow = $(">tbody:first > tr:last", jgroup); var rulerow = $(g._bulidRuleRowHtml()); lastrow.before(rulerow); if (p.fields.length) { //如果第一个字段启用了自定义输入框 g.appendEditor(rulerow, p.fields[0]); } //事件:字段列表改变时 $("select.fieldsel", rulerow).bind('change', function () { var jopsel = $(this).parent().next().find("select:first"); var fieldName = $(this).val(); var field = g.getField(fieldName); //字段类型处理 var fieldType = field.type || "string"; var oldFieldtype = rulerow.attr("fieldtype"); if (fieldType != oldFieldtype) { jopsel.html(g._bulidOpSelectOptionsHtml(fieldType)); rulerow.attr("fieldtype", fieldType); } //当前的编辑器 var editorType = null; //上一次的编辑器 var oldEditorType = rulerow.attr("editortype"); if (g.enabledEditor(field)) editorType = field.editor.type; if (oldEditorType) { //如果存在旧的输入框 g.removeEditor(rulerow); } if (editorType) { //如果当前选择的字段定义了输入框 g.appendEditor(rulerow, field); } else { rulerow.removeAttr("editortype").removeAttr("editorid"); $("td.l-filter-value:first", rulerow).html(''); } }); return rulerow; }, //删除一个条件 deleteRule: function (rulerow) { $("select.fieldsel", rulerow).unbind(); this.removeEditor(rulerow); $(rulerow).remove(); }, //附加一个输入框 appendEditor: function (rulerow, field) { var g = this, p = this.options; if (g.enabledEditor(field)) { var cell = $("td.l-filter-value:first", rulerow).html(""); var editor = p.editors[field.editor.type]; g.editors[++g.editorCounter] = editor.create(cell, field); rulerow.attr("editortype", field.editor.type).attr("editorid", g.editorCounter); } }, //获取分组数据 getData: function (group) { var g = this, p = this.options; group = group || g.group; var groupData = {}; $("> tbody > tr", group).each(function (i, row) { var rowlast = $(row).hasClass("l-filter-rowlast"); var rowgroup = $(row).hasClass("l-filter-rowgroup"); if (rowgroup) { var groupTable = $("> td:first > table:first", row); if (groupTable.length) { if (!groupData.groups) groupData.groups = []; groupData.groups.push(g.getData(groupTable)); } } else if (rowlast) { groupData.op = $(".groupopsel:first", row).val(); } else { var fieldName = $("select.fieldsel:first", row).val(); var field = g.getField(fieldName); var op = $(".opsel:first", row).val(); var value = g._getRuleValue(row, field); var type = $(row).attr("fieldtype") || "string"; if (!groupData.rules) groupData.rules = []; groupData.rules.push({ field: fieldName, op: op, value: value, type: type }); } }); return groupData; }, _getRuleValue: function (rulerow, field) { var g = this, p = this.options; var editorid = $(rulerow).attr("editorid"); var editortype = $(rulerow).attr("editortype"); var editor = g.editors[editorid]; if (editor) return p.editors[editortype].getValue(editor, field); return $(".valtxt:first", rulerow).val(); }, //判断某字段是否启用自定义的输入框 enabledEditor: function (field) { var g = this, p = this.options; if (!field.editor || !field.editor.type) return false; return (field.editor.type in p.editors); }, //根据fieldName 获取 字段 getField: function (fieldname) { var g = this, p = this.options; for (var i = 0, l = p.fields.length; i < l; i++) { var field = p.fields[i]; if (field.name == fieldname) return field; } return null; }, //获取一个分组的html _bulidGroupTableHtml: function (altering, allowDelete) { var g = this, p = this.options; var tableHtmlArr = []; tableHtmlArr.push(''); tableHtmlArr.push(''); tableHtmlArr.push('
    '); //and or tableHtmlArr.push(''); //add group tableHtmlArr.push(''); //add rule tableHtmlArr.push(''); if (allowDelete) tableHtmlArr.push(''); tableHtmlArr.push('
    '); return tableHtmlArr.join(''); }, //获取字段值规则的html _bulidRuleRowHtml: function (fields) { var g = this, p = this.options; fields = fields || p.fields; var rowHtmlArr = []; var fieldType = fields[0].type || "string"; rowHtmlArr.push(''); rowHtmlArr.push('"); rowHtmlArr.push(''); rowHtmlArr.push(''); rowHtmlArr.push(''); rowHtmlArr.push(''); rowHtmlArr.push(''); rowHtmlArr.push(''); rowHtmlArr.push(''); rowHtmlArr.push(''); rowHtmlArr.push('
    '); rowHtmlArr.push(''); rowHtmlArr.push(''); return rowHtmlArr.join(''); }, //获取一个运算符选择框的html _bulidOpSelectOptionsHtml: function (fieldType) { var g = this, p = this.options; var ops = p.operators[fieldType]; var opHtmlArr = []; for (var i = 0, l = ops.length; i < l; i++) { var op = ops[i]; opHtmlArr[opHtmlArr.length] = ''; } return opHtmlArr.join(''); } }); })(jQuery);/** * jQuery ligerUI 1.1.9 * * http://ligerui.com * * Author daomi 2012 [ gd_star@163.com ] * */ (function ($) { $.fn.ligerForm = function () { return $.ligerui.run.call(this, "ligerForm", arguments); }; $.ligerDefaults = $.ligerDefaults || {}; $.ligerDefaults.Form = { //控件宽度 inputWidth: 180, //标签宽度 labelWidth: 90, //间隔宽度 space: 40, rightToken: ':', //标签对齐方式 labelAlign: 'left', //控件对齐方式 align: 'left', //字段 fields: [], //创建的表单元素是否附加ID appendID: true, //生成表单元素ID的前缀 prefixID: "", //json解析函数 toJSON: $.ligerui.toJSON }; //@description 默认表单编辑器构造器扩展(如果创建的表单效果不满意 建议重载) //@param {jinput} 表单元素jQuery对象 比如input、select、textarea $.ligerDefaults.Form.editorBulider = function (jinput) { //这里this就是form的ligerui对象 var g = this, p = this.options; var inputOptions = {}; if (p.inputWidth) inputOptions.width = p.inputWidth; if (jinput.is("select")) { jinput.ligerComboBox(inputOptions); } else if (jinput.is(":text") || jinput.is(":password")) { var ltype = jinput.attr("ltype"); switch (ltype) { case "select": case "combobox": jinput.ligerComboBox(inputOptions); break; case "spinner": jinput.ligerSpinner(inputOptions); break; case "date": jinput.ligerDateEditor(inputOptions); break; case "float": case "number": inputOptions.number = true; jinput.ligerTextBox(inputOptions); break; case "int": case "digits": inputOptions.digits = true; default: jinput.ligerTextBox(inputOptions); break; } } else if (jinput.is(":radio")) { jinput.ligerRadio(inputOptions); } else if (jinput.is(":checkbox")) { jinput.ligerCheckBox(inputOptions); } else if (jinput.is("textarea")) { jinput.addClass("l-textarea"); } } //表单组件 $.ligerui.controls.Form = function (element, options) { $.ligerui.controls.Form.base.constructor.call(this, element, options); }; $.ligerui.controls.Form.ligerExtend($.ligerui.core.UIComponent, { __getType: function () { return 'Form' }, __idPrev: function () { return 'Form'; }, _init: function () { $.ligerui.controls.Form.base._init.call(this); }, _render: function () { var g = this, p = this.options; var jform = $(this.element); //自动创建表单 if (p.fields && p.fields.length) { if (!jform.hasClass("l-form")) jform.addClass("l-form"); var out = []; var appendULStartTag = false; $(p.fields).each(function (index, field) { var name = field.name || field.id; if (!name) return; if (field.type == "hidden") { out.push(''); return; } var newLine = field.renderToNewLine || field.newline; if (newLine == null) newLine = true; if (field.merge) newLine = false; if (field.group) newLine = true; if (newLine) { if (appendULStartTag) { out.push(''); appendULStartTag = false; } if (field.group) { out.push('
    '); if (field.groupicon) out.push(''); out.push('' + field.group + '
    '); } out.push(''); appendULStartTag = false; } jform.append(out.join('')); } //生成ligerui表单样式 $("input,select,textarea", jform).each(function () { p.editorBulider.call(g, $(this)); }); }, //标签部分 _buliderLabelContainer: function (field) { var g = this, p = this.options; var label = field.label || field.display; var labelWidth = field.labelWidth || field.labelwidth || p.labelWidth; var labelAlign = field.labelAlign || p.labelAlign; if (label) label += p.rightToken; var out = []; out.push('
  • '); if (label) { out.push(label); } out.push('
  • '); return out.join(''); }, //控件部分 _buliderControlContainer: function (field) { var g = this, p = this.options; var width = field.width || p.inputWidth; var align = field.align || field.textAlign || field.textalign || p.align; var out = []; out.push('
  • '); out.push(g._buliderControl(field)); out.push('
  • '); return out.join(''); }, //间隔部分 _buliderSpaceContainer: function (field) { var g = this, p = this.options; var spaceWidth = field.space || field.spaceWidth || p.space; var out = []; out.push('
  • '); out.push('
  • '); return out.join(''); }, _buliderControl: function (field) { var g = this, p = this.options; var width = field.width || p.inputWidth; var name = field.name || field.id; var out = []; if (field.comboboxName && field.type == "select") { out.push(''); } if (field.textarea || field.type == "textarea") { out.push('