﻿/**----------------------------------------------------------------------------------------------------------------------------------------
** core
**----------------------------------------------------------------------------------------------------------------------------------------
*
* 最后更新：
*      2009年8月25日17:06:37
*
**/
(function(d) { var c = navigator.userAgent.toLowerCase(); var b = (c.match(/.+(?:rv|webkit|khtml|opera|msie)[\/: ]([\d.]+)/) || [0, "0"])[1]; if (/msie/.test(c) && !/opera/.test(c)) { d.browser.msie = true; d.browser.opera = false; d.browser.version = parseInt(b); if (d.browser.version < 7 && !window.XMLHttpRequest) { d.browser.version = 6; d.browser.msie6 = true } } window.reload = function() { var e = window.location.href; window.location = e.split("#")[0] }; d(function() { window.scrollWidth = a() }); function a() { var g = d(document.createElement("div")).css({ position: "absolute", top: "-1000px", left: "-1000px", width: "100px", height: "50px", overflow: "auto" }).appendTo("body"); var f = d(document.createElement("div")).css({ background: "#ff0", height: "200px" }).appendTo(g); var e = g.width() - f.width(); g.remove(); return e } })(jQuery);

/**----------------------------------------------------------------------------------------------------------------------------------------
** overlay
**----------------------------------------------------------------------------------------------------------------------------------------
* 参数：
*      zIndex: 999,             // z-index
*      opacity: 0.75,           // 不透明度
*      message: null,           // 提示信息，可使用HTML代码
*      css: null,               // 提示信息的自定义CSS样式
*      spotlight: null          // 聚光灯效果，设置为jQuery选择器或jQuery对象或DOM对象即可
*      onOverlay: null,        // 打开遮罩时的回调
*      onClose: null            // 关闭遮罩时的回调
* 用法：
*      打开遮罩：$.overLay()或者$.overLay(options)
*      关闭遮罩：$.overLay("close")
* 更新时间：
*      2009年8月27日16:56:07
*
*/
(function(f) { var c = { zIndex: 999, opacity: 0.75, message: null, background: "#000", css: null, spotlight: null, onOverlay: null, onClose: null }; var g = null; var i = null; var j = null; var b = 0; var a = 0; f.extend(f, { overlay: function(k) { if (k && typeof (k) == "string" && k === "close") { e() } else { var l = f.extend({}, c, k); setTimeout(function() { if (l.spotlight) { h(l) } else { d(l) } }, 0) } } }); function d(q) { if (f(document).data("cui-overlay") && f(document).data("cui-overlay") === "spotlight") { e("spotlight") } f(document).data("cui-overlay", "normal"); var m = f("#cui-overlay"); if (m.size() === 0) { g = q; m = f(document.createElement("div")).css({ position: "fixed", top: "0", right: "0", bottom: "0", left: "0", opacity: "0", "z-index": q.zIndex++, background: q.background }).attr("id", "cui-overlay"); if (f.browser.msie6) { var l = f("html")[0]; var k = Math.max(l.scrollWidth, f(window).width()); var p = Math.max(l.scrollHeight, f(window).height()); f("html").css("overflow", "hidden"); var o = f('<iframe frameborder="0" hspace="0" width="100%" height="100%"></iframe>').css({ opacity: "0" }); m.css({ position: "absolute", width: k + "px", height: p + "px" }).append(o); f(window).unbind("resize.cui-overlay").bind("resize.cui-overlay", function() { window.clearTimeout(j); j = window.setTimeout(function() { k = Math.max(l.scrollWidth, f(window).width()); p = Math.max(l.scrollHeight, f(window).height()); m.width(k).height(p) }, 200) }) } else { f("object, embed", "body").css("visibility", "hidden") } m.appendTo("body").fadeTo(300, q.opacity, function() { if (q.onOverlay && f.isFunction(q.onOverlay)) { q.onOverlay() } }) } else { if (g.onClose && f.isFunction(g.onClose)) { g.onClose() } if (q.onOverlay && f.isFunction(q.onOverlay)) { q.onOverlay() } g = q } if (q.message) { var n = f("#cui-overlay-message"); if (n.size() === 0) { n = f(document.createElement("div")).css({ position: f.browser.msie6 ? "absolute" : "fixed", top: "50%", left: "50%", opacity: "0", "text-align": "center", "min-width": "300px", "max-width": "35%", padding: "5px 15px", border: "3px solid #aaa", "-webkit-border-radius": "10px", "-moz-border-radius": "10px", background: "#000", "z-index": q.zIndex++, "line-height": "2em", "font-size": "12px", color: "#fff" }).attr("id", "cui-overlay-message").insertAfter(m) } else { n.empty() } f(document.createElement("p")).css({ margin: "0" }).append(q.message).appendTo(n); if (f.browser.msie6) { n.css({ width: "300px" }); setTimeout(function() { f(window).unbind("scroll.cui-overlay").bind("scroll.cui-overlay", function() { window.clearTimeout(i); i = window.setTimeout(function() { var r = (parseInt(n.css("marginLeft").replace("px", "")) || 0) + f(window).scrollLeft() - b; var s = (parseInt(n.css("marginTop").replace("px", "")) || 0) + f(window).scrollTop() - a; n.animate({ marginLeft: r + "px", marginTop: s + "px" }); b = f(window).scrollLeft(); a = f(window).scrollTop() }, 200) }) }, 0) } if (q.css) { n.css(q.css) } n.css({ "margin-left": (-n.outerWidth() / 2) + "px", "margin-top": (-n.outerHeight() / 2) + "px" }).fadeTo(300, 0.5) } } function h(u) { if (f(document).data("cui-overlay") && f(document).data("cui-overlay") === "normal") { e("normal") } f(document).data("cui-overlay", "spotlight"); var B = f(u.spotlight); var v = f("html")[0]; var C = Math.max(f(window).width(), v.scrollWidth); var m = Math.max(f(window).height(), v.scrollHeight); var A = B.outerWidth(); var l = B.outerHeight(); var w = B.offset().top; var s = m - w - l; var r = B.offset().left; var z = C - r - A; var y = f(".cui-spotlight").size() !== 0; var q = { position: "absolute", opacity: "0", background: u.background }; var o = f('<iframe frameborder="0" hspace="0" width="100%" height="100%"></iframe>').css({ opacity: "0" }); var p = f("#cui-sl-n"); if (p.size() === 0) { p = f(document.createElement("div")).attr({ id: "cui-sl-n", "class": "cui-spotlight" }).css(f.extend({}, q, { top: "0", left: "0" })).appendTo("body"); if (f.browser.msie6) { p.append(o.clone()) } } p.css({ width: C + "px", height: w + "px" }); var n = f("#cui-sl-s"); if (n.size() === 0) { n = f(document.createElement("div")).attr({ id: "cui-sl-s", "class": "cui-spotlight" }).css(f.extend({}, q, { top: w + l + "px", left: "0" })); if (f.browser.msie6) { n.append(o.clone()) } } n.css({ width: C + "px", height: s + "px" }); var k = f("#cui-sl-w"); if (k.size() === 0) { k = f(document.createElement("div")).attr({ id: "cui-sl-w", "class": "cui-spotlight" }).css(f.extend({}, q, { left: "0" })); if (f.browser.msie6) { k.append(o.clone()) } } k.css({ width: r + "px", height: l + "px", top: w + "px" }); var t = f("#cui-sl-e"); if (t.size() === 0) { t = f(document.createElement("div")).attr({ id: "cui-sl-e", "class": "cui-spotlight" }).css(q); if (f.browser.msie6) { t.append(o) } } t.css({ width: z + "px", height: l + "px", top: w + "px", left: r + A + "px" }); if (!y) { g = u; setTimeout(function() { f("object, embed", "body").css("visibility", "hidden"); f("object, embed", B).css("visibility", "visible") }, 0); var x = false; f("body").append(p).append(n).append(k).append(t); f(".cui-spotlight").fadeTo(300, 0.5, function() { if (!x) { x = true; if (u.onOverlay && f.isFunction(u.onOverlay)) { u.onOverlay() } } }) } else { if (!u.windowResizing) { if (g.onClose && f.isFunction(g.onClose)) { g.onClose() } if (u.onOverlay && f.isFunction(u.onOverlay)) { u.onOverlay() } g = u; u.windowResizing = false } } setTimeout(function() { f(window).unbind("resize.cui-overlay").bind("resize.cui-overlay", function() { window.clearTimeout(j); j = setTimeout(function() { u.windowResizing = true; h(u) }, f.browser.msie ? 200 : 10) }) }, 0) } function e(o) { var m = (o === null || o === undefined); var n = g; if (!o) { o = f(document).data("cui-overlay") } var p = function() { if (!f.browser.msie6) { f("object, embed", "body").css("visibility", "visible") } if (f.isFunction(n.onClose)) { n.onClose() } if (m) { g = null; f(document).removeData("cui-overlay") } }; if (o === "normal") { var l = f("#cui-overlay"); if (l.size() > 0) { setTimeout(function() { p(); f("#cui-overlay, #cui-overlay-message").fadeOut(300, function() { f(this).remove(); f("html").css("overflow", "") }) }, 0); if (f.browser.msie6) { f(window).unbind("scroll.cui-overlay").unbind("resize.cui-overlay") } } } else { if (o === "spotlight") { var k = f(".cui-spotlight"); if (k.size() > 0) { setTimeout(function() { p(); k.fadeOut(300, function() { f(this).remove() }) }, 0); f(window).unbind("resize.cui-overlay") } } else { return } } } })(jQuery);



/**----------------------------------------------------------------------------------------------------------------------------------------
** button
**----------------------------------------------------------------------------------------------------------------------------------------
*
* 用法：
*      $(expr).button();
* 最后更新：
*      2009年8月4日17:11:23
*
*/
(function(b) { b.fn.extend({ button: function() { var c = this; c.each(function() { var e = b(this); var d = a(); e.addClass("cui-button").append(d.find("em").append(e.contents()).end()); if (b.browser.msie || b.browser.opera) { e.css({ margin: "0 3px" }); if (b.browser.msie && b.browser.version <= 7) { e.css({ width: d.width() + "px", height: d.height() + "px" }) } } }); return c } }); b(function() { b(".cui-button").button() }); function a() { var c = '<table border="0" cellpadding="0" cellspacing="0">    <tbody>        <tr class="cui-btn-top">            <td class="cui-btn-left"></td>            <td class="cui-btn-center"></td>            <td class="cui-btn-right"></td>        </tr>        <tr class="cui-btn-middle">            <td class="cui-btn-left"></td>            <td class="cui-btn-center"><em unselectable="on"></em></td>            <td class="cui-btn-right"></td>        </tr>        <tr class="cui-btn-bottom">            <td class="cui-btn-left"></td>            <td class="cui-btn-center"></td>            <td class="cui-btn-right"></td>        </tr>    </tbody></table>'; return b(c) } })(jQuery);

/**----------------------------------------------------------------------------------------------------------------------------------------
** window
**----------------------------------------------------------------------------------------------------------------------------------------
*
* 版本：
*      1.0.8.0827
*
* 最后更新：
*      2009年8月27日16:55:51
*
*/
(function($) { if (!window.log) { window.log = { toggle: function() { }, move: function() { }, resize: function() { }, clear: function() { }, debug: function() { }, info: function() { }, warn: function() { }, error: function() { }, profile: function() { } } } $(function() { setTimeout(function() { initialize("body") }, 0) }); function getOptions(item) { var x = $.trim(item.attr("rev")); if (x.length > 0) { try { return eval("({" + x + "})") } catch (e) { return null } } return null } function initialize(scope) { $(".cui-popwin", scope).each(function() { var ext = getOptions($(this)); if ($(this).is("a")) { $(this).unbind("click.cui-window").bind("click.cui-window", function() { var self = $(this); var content = null; var href = self.attr("href"); if (href.indexOf("#") === 0) { content = $(href); if (content.size() > 0) { content.window($.extend({ title: self.attr("title") || href, source: self }, ext)) } return false } else { href = this.href; var title = self.attr("title") || href; if (isImage(href)) { var onLoading = function() { this.gallery = new Object(); var rel = self.attr("rel"); var images = new Array(); var titles = new Array(); if (rel.length && rel.length > 0) { this.gallery.title = rel; $("a[rel='" + rel + "']").each(function() { images.push(this.href); titles.push(this.title || this.href) }) } if (images.length === 0) { images.push(href); titles.push(this.title) } this.gallery.images = images; this.gallery.titles = titles }; $.window($.extend({ type: "image", url: href, title: title, onLoading: onLoading }, ext)); return false } else { if (self.attr("target") === "_blank" || isCrossDomain(href)) { var options = { type: "iframe", url: href, title: title, source: self }; $.window($.extend(options, ext)); return false } else { $.window($.extend({ type: "ajax", url: href, title: title, source: self, selector: self.attr("rel") }, ext)); return false } } } }) } if ($(this).is("form")) { var form = $(this); form.unbind("submit.cui-window").bind("submit.cui-window", function() { var href = form.attr("action"); $.window($.extend({ type: "ajax", url: href, title: form.attr("title") || href, data: form.serialize(), method: form.attr("method"), source: form }, ext)); return false }) } }) } var defaults = { type: null, url: null, drag: { enabled: true, hideContent: true }, icon: null, title: null, description: { display: false, icon: null, title: null, message: null }, buttons: { display: false, tooltip: null, items: [] }, delay: 300, zIndex: 1000, overlay: { enabled: true }, minWidth: 640, minHeight: 490, culture: null, method: "get", behavior: "original", theme: null, onLoading: null, onClose: null }; var langs = { en: { loading: "Loading...", resizing: "Resizing...", prev: "Prev", next: "Next", original: "Original", error: "Error!", success: "Success!", warn: "Warn!", confirm: "Confirm!", prompt: "Prompt!", requestError: "Request Error: ", requestErrorContent: 'The requested content cannot be loaded.<br />Please try again later.<br /><br /><a href="#close" class="cui-win-close">Close</a>', ok: "OK", cancel: "CANCEL" }, zh: { loading: "加载中...", resizing: "重置...", prev: "上一张", next: "下一张", original: "打开原始图片", error: "错误！", success: "成功！", warn: "警告！", confirm: "请确认！", prompt: "需要参数！", requestError: "请求失败： ", requestErrorContent: '所请求的内容无法加载。<br />请稍后再试。<br /><br /><a href="#close" class="cui-win-close">关闭</a>', ok: "确定", cancel: "取消"} }; var currentWindow = null; var globals = { multiple: true, zIndex: defaults.zIndex }; $.extend($, { window: function(options) { if (typeof (options) == "string") { switch (options) { case "close": closeWindow(); break; case "set-defaults": if (arguments.length > 1 && typeof (arguments[1]) === "object") { defaults = mergeSettings(defaults, arguments[1]) } break; case "set-lang": if (arguments.length > 2 && typeof (arguments[1]) === "string" && typeof (arguments[2]) === "object") { langs[arguments[1]] = $.extend({}, langs[arguments[1]], arguments[2]) } break; case "set-multiple": if (arguments.length > 1 && typeof (arguments[1]) === "boolean") { globals.multiple = arguments[1] } break; default: break } } else { if (options.source) { var id = options.source.attr("ref"); if (id && id.length > 0 && $("#" + id).size() > 0) { activeWindow(id); return } } var setting = mergeSettings(defaults, options); if (!setting.culture) { setting.culture = getCulture() } currentWindow = createWindow(setting); currentWindow.setting = setting; currentWindow.lang = langs[setting.culture]; setting.overlay.onOverlay = function() { init(); open(); currentWindow.data("inited", true) }; overlay(setting) } }, alert: function(options) { if (typeof (options) == "string") { modalWindow({ type: "warn", message: options }) } else { var setting = $.extend({}, { type: "warn", message: null, callback: null }, options); if (setting.type !== "warn" && setting.type !== "success" && setting.type !== "error") { setting.type = "warn" } modalWindow(setting) } }, confirm: function(options) { var setting = $.extend({}, { message: null, callback: null }, options); setting.type = "confirm"; modalWindow(setting) }, prompt: function(options) { var setting = $.extend({}, { message: null, callback: null }, options); setting.type = "prompt"; modalWindow(setting) } }); $.fn.extend({ window: function(options) { var self = this; var onLoading = options.onLoading; options.onLoading = function() { if (self.closest("body").size() > 0) { this.originalContent = self; this.content = self.clone(true) } else { this.content = self } initBlock(this.content); if (onLoading && $.isFunction(onLoading)) { onLoading.call(this) } }; $.window(options); return self } }); function modalWindow(options) { var culture = options.culture || defaults.culture; if (!culture) { culture = getCulture() } var lang = langs[culture]; var setting = $.extend({}, { type: "warn", title: lang[options.type], message: null, value: null, callback: null }, options); modal(globals.zIndex++); var content = $(document.createElement("div")).addClass("cui-win-specify cui-win-" + setting.type); content.append($(document.createElement("p")).append(setting.message).css({ margin: "0", padding: "5px 0" })); var buttons = new Array(); switch (setting.type) { case "warn": case "success": case "error": buttons.push({ text: lang.ok, click: function() { if ($.isFunction(setting.callback)) { setting.callback(); setting.callback = null } $.window("close") } }); break; case "confirm": buttons.push({ text: lang.ok, click: function() { if ($.isFunction(setting.callback)) { setting.callback(true); setting.callback = null } $.window("close") } }); buttons.push({ text: lang.cancel, click: function() { if ($.isFunction(setting.callback)) { setting.callback(false); setting.callback = null } $.window("close") } }); break; case "prompt": var input = $(document.createElement("input")).attr("type", "text").css({ border: "1px solid #ccc", width: "100%" }); content.append($(document.createElement("p")).append(input)); buttons.push({ text: lang.ok, click: function() { if ($.isFunction(setting.callback)) { setting.callback(input.val()); setting.callback = null } $.window("close") } }); buttons.push({ text: lang.cancel, click: function() { if ($.isFunction(setting.callback)) { setting.callback(null); setting.callback = null } $.window("close") } }); break } content.window({ title: setting.title, overlay: { enabled: false }, description: { display: false }, buttons: { display: true, tooltip: null, items: buttons }, onClose: function() { if ($.isFunction(setting.callback)) { setting.callback(false) } unModal() }, behavior: "new", theme: setting.theme }) } function mergeSettings(defaults, options) { var setting = $.extend({}, defaults, options); setting.drag = $.extend({}, defaults.drag, options.drag); setting.description = $.extend({}, defaults.description, options.description); setting.buttons = $.extend({}, defaults.buttons, options.buttons); setting.overlay = $.extend({}, defaults.overlay, options.overlay); return setting } function createWindow(setting) { var parent = null; if (globals.multiple && setting.behavior === "new") { if (currentWindow !== null) { setting.zIndex = currentWindow.setting.zIndex; parent = currentWindow; currentWindow = null } else { globals.zIndex = setting.zIndex } } var win = null; if (currentWindow === null) { var html = '<table class="cui-window" cellpadding="0" cellspacing="0" border="0">    <tbody>        <tr class="cui-win-header">            <td class="cui-win-left"></td>            <td class="cui-win-center">                <div>                    <span></span><a class="cui-win-close" href="#close">X</a>                    <h1>{title}</h1>                </div>            </td>            <td class="cui-win-right"></td>        </tr>        <tr class="cui-win-body">            <td class="cui-win-left"></td>            <td class="cui-win-center">                <div class="cui-win-wrapper">                    <div class="cui-win-content">                        <div class="cui-win-desc">                            <span></span>                            <div>                                <h2>{desc-title}</h2>                                <p>{desc-message}</p>                            </div>                        </div>                        <div class="cui-win-container"></div>                        <div class="cui-win-buttons">                            <p>{tooltip}</p>                            <div></div>                        </div>                    </div>                    <div class="cui-win-loading"></div>                </div>            </td>            <td class="cui-win-right"></td>        </tr>        <tr class="cui-win-footer">            <td class="cui-win-left"></td>            <td class="cui-win-center"></td>            <td class="cui-win-right"></td>        </tr>    </tbody></table>'; var dock = $("#cui-window-dock"); if (dock.size() === 0) { dock = $(document.createElement("div")).attr("id", "cui-window-dock").css({ width: setting.minWidth + "px", height: "0", overflow: "hidden", position: $.browser.msie6 ? "absolute" : "fixed", top: "0", left: "0", "z-index": setting.zIndex++, opacity: "0" }).appendTo("body") } var id = "cui-window-" + random(); win = $(html).attr("id", id).css("z-index", globals.zIndex++); win.dock = dock; win.id = id; $(document).data(id, win); win.mousedown(function() { activeWindow(this.id) }); win.active = function() { activeWindow(win.id) }; win.close = function() { closeWindow(win) } } else { currentWindow.body.loading.show(); currentWindow.body.content.css("visibility", "hidden"); currentWindow.originalContent = null; currentWindow.body.container.empty().css({ width: "auto", height: "auto" }); if (currentWindow.setting.source) { currentWindow.setting.source.removeAttr("ref") } if (currentWindow.setting.theme && setting.theme) { currentWindow.removeClass(currentWindow.setting.theme) } win = currentWindow } if (setting.source) { setting.source.attr("ref", win.id) } if (setting.theme) { win.addClass(setting.theme) } if (parent) { win.parent = parent; parent.child = win } return win } function activeWindow(id) { if (id !== currentWindow.id) { var win = getWindow(id); if (win) { win.css({ "z-index": globals.zIndex++ }); currentWindow = win } } } function closeWindow(win) { if (!win) { win = currentWindow } if ($(".cui-window").size() === 1) { unOverLay() } win.header.title.html(""); win.header.title.css("width", "auto"); win.body.content.hide(); var minW = Math.min(win.width(), 160); var minH = Math.min(win.height(), 120); setTimeout(function() { var top = win.position().top + (win.outerHeight(true) - minH) / 2 - ($.browser.msie6 ? 0 : $(window).scrollTop()); var left = win.position().left + (win.outerWidth(true) - minW) / 2 - ($.browser.msie6 ? 0 : $(window).scrollLeft()); win.animate({ left: left + "px", top: top + "px" }, win.setting.delay) }, 0); setTimeout(function() { win.body.wrapper.animate({ width: (minW - win.borderH) + "px", height: (minH - win.borderV) + "px" }, win.setting.delay, function() { win.hide(); if ($.isFunction(win.setting.onClose)) { win.setting.onClose.call(win) } if (win.originalContent) { win.originalContent.replaceWith(win.content) } if (win.setting.source) { win.setting.source.removeAttr("ref") } win.body.container.empty(); win.remove(); var childWin = win.child; if (childWin) { childWin.parent = undefined } var parentWin = win.parent; if (parentWin) { parentWin.child = undefined } $(document).removeData(win.id); if ($(".cui-window").size() === 0) { win.dock.remove(); win = null; $(window).unbind("resize.cui-window"); $(document).unbind("mousemove.cui-window"); $(document).unbind("mouseup.cui-window"); if ($.browser.msie6) { $(window).unbind("scroll.cui-window") } currentWindow = null; globals.zIndex = defaults.zIndex } else { var x = 0; $.each($(".cui-window"), function(i, n) { var z = $(n).css("z-index"); if (z > x) { currentWindow = getWindow(n.id); x = z } }); if (!currentWindow) { currentWindow = getWindow($(".cui-window")[0].id) } } }) }, 0) } function initClose(win) { setTimeout(function() { currentWindow.closer.unbind("click.cui-window").bind("click.cui-window", function(e) { $(this).blur(); var id = $(this).closest(".cui-window").attr("id"); var win = getWindow(id); closeWindow(win); return false }).mousedown(function() { return false }) }, 0) } function getWindow(id) { return $(document).data(id) } function init() { if (currentWindow.data("inited")) { return } currentWindow.extend({ closer: $(".cui-win-close", currentWindow), header: $(">tbody>tr.cui-win-header>td.cui-win-center", currentWindow), body: $(">tbody>tr.cui-win-body>td.cui-win-center", currentWindow), handle: $(">tbody>tr.cui-win-header, >tbody>tr.cui-win-header h1, >tbody>tr.cui-win-footer, >tbody>tr.cui-win-body>td.cui-win-left, >tbody>tr.cui-win-body>td.cui-win-right", currentWindow) }); currentWindow.header.extend({ icon: $("span", currentWindow.header), title: $("h1", currentWindow.header) }); currentWindow.body.extend({ description: $(">.cui-win-wrapper>.cui-win-content>.cui-win-desc", currentWindow.body), container: $(">.cui-win-wrapper>.cui-win-content>.cui-win-container", currentWindow.body), buttons: $(">.cui-win-wrapper>.cui-win-content>.cui-win-buttons", currentWindow.body), content: $(">.cui-win-wrapper>.cui-win-content", currentWindow.body), wrapper: $(">.cui-win-wrapper", currentWindow.body), loading: $(">.cui-win-wrapper>.cui-win-loading", currentWindow.body) }); currentWindow.body.description.extend({ wrapper: $(">div", currentWindow.body.description), icon: $(">div>span", currentWindow.body.description), title: $(">div>h2", currentWindow.body.description), message: $(">div>p", currentWindow.body.description) }); currentWindow.body.buttons.extend({ container: $(">div", currentWindow.body.buttons), tooltip: $(">p", currentWindow.body.buttons) }); if (currentWindow.setting.icon) { currentWindow.header.icon.addClass(currentWindow.setting.icon) } else { currentWindow.header.addClass("cui-win-noicon") } currentWindow.header.title.text(currentWindow.lang.loading); if (currentWindow.setting.description.display) { if (currentWindow.setting.description.icon) { currentWindow.body.description.icon.addClass(currentWindow.setting.description.icon) } else { currentWindow.body.description.addClass("cui-win-noicon") } } else { currentWindow.body.description.hide() } if (currentWindow.setting.buttons.tooltip) { currentWindow.body.buttons.tooltip.html(currentWindow.setting.buttons.tooltip) } else { currentWindow.body.buttons.tooltip.hide() } currentWindow.dock.append(currentWindow); initDrag(); initClose() } function open() { if (currentWindow.setting.url && !currentWindow.setting.type) { if (isImage(currentWindow.setting.url)) { currentWindow.setting.type = "image" } else { if (isCrossDomain(currentWindow.setting.url)) { currentWindow.setting.type = "iframe" } else { currentWindow.setting.type = "ajax" } } } var w = currentWindow.width(); var h = currentWindow.height(); currentWindow.body.wrapper.css({ width: currentWindow.body.width() + "px", height: currentWindow.body.height() + "px" }); if (!currentWindow.data("inited")) { var dw = $(window).width(); var dh = $(window).height(); var top = ((dh - h) / 2 + ($.browser.msie6 ? ($(window).scrollTop()) : 0)); var left = ((dw - w) / 2 + ($.browser.msie6 ? ($(window).scrollLeft()) : 0)); currentWindow.hide().appendTo("body").css({ position: $.browser.msie6 ? "absolute" : "fixed", top: top + "px", left: left + "px" }).show(); if (currentWindow.setting.buttons.display && currentWindow.setting.buttons.items.length > 0) { $.each(currentWindow.setting.buttons.items, function(i, n) { var button = $(document.createElement("button")).html(n.text).appendTo(currentWindow.body.buttons.container).click(n.click); if (n.tooltip) { button.attr("title", n.tooltip) } if ($.isFunction($.fn.button)) { button.button() } }) } var v1 = $(">tbody>tr.cui-win-header>td.cui-win-center", currentWindow).outerHeight(true); var v2 = $(">tbody>tr.cui-win-footer>td.cui-win-center", currentWindow).outerHeight(true); currentWindow.borderV = v1 + v2; var h1 = $(">tbody>tr.cui-win-body>td.cui-win-left", currentWindow).outerWidth(true); var h2 = $(">tbody>tr.cui-win-body>td.cui-win-right", currentWindow).outerWidth(true); currentWindow.borderH = h1 + h2 } render() } function resize(win, w, h) { if (win.data("resizing")) { return } win.data("resizing", true); win.header.title.css("width", "auto"); if (win.setting.description.display) { win.body.description.wrapper.css("width", "auto"); if (win.setting.description.title) { win.body.description.title.html("") } if (win.setting.description.message) { win.body.description.message.html("") } } if (win.data("window-resizing")) { win.header.title.text(win.lang.resizing) } else { win.header.title.text(win.lang.loading) } var dw = $(window).width(); var dh = $(window).height(); var h1 = 0; if (win.setting.description.display) { win.body.description.width(w); h1 += win.body.description.outerHeight(true); win.body.description.css("width", "auto") } if (win.setting.buttons.display) { win.body.buttons.width(w); h1 += win.body.buttons.outerHeight(true); win.body.buttons.css("width", "auto") } var dwf = dw - win.borderH; var dhf = dh - win.borderV; if ($.browser.msie6) { dwf -= 20 } if (win.setting.type === "image") { var rate = w / h; if (dwf > dhf) { if (w > h) { h = (h + win.borderV) > dhf ? (dhf - win.borderV) : h; w = (h - h1) * rate } else { w = (w + win.borderH) > dwf ? (dwf - win.borderH) : w; h = w / rate } } else { if (w > h) { w = (w + win.borderH) > dwf ? (dwf - win.borderH) : w; h = w / rate } else { h = (h + win.borderV) > dhf ? (dhf - win.borderV) : h; w = (h - h1) * rate } } w = Math.min(w, dwf); h = Math.min(h, dhf) } else { w = (w + win.borderH) > dwf ? (dwf - win.borderH) : w; h += h1; h = (h + win.borderV) > dhf ? (dhf - win.borderV) : h } w = Math.round(w); h = Math.round(h); if (win.onSizeCompute && $.isFunction(win.onSizeCompute)) { var size = win.onSizeCompute(w, h); w = size.width; h = size.height } log.debug("重设大小：" + w + "*" + h); win.body.loading.show(); win.body.content.hide(); setTimeout(function() { var top = (dh - (h + win.borderV)) / 2 + ($.browser.msie6 ? ($(window).scrollTop()) : 0); var left = (dw - (w + win.borderH)) / 2 + ($.browser.msie6 ? ($(window).scrollLeft()) : 0); win.animate({ left: left + "px", top: top + "px" }, win.setting.delay) }, 0); setTimeout(function() { win.body.wrapper.animate({ width: w + "px", height: h + "px" }, win.setting.delay, function() { if (win.onResizeComplete && $.isFunction(win.onResizeComplete)) { win.onResizeComplete(w, h - h1) } win.body.loading.hide(); win.body.description.css({ display: win.setting.description.display ? "block" : "none" }); win.body.buttons.css({ display: win.setting.buttons.display ? "block" : "none" }); win.body.content.css({ visibility: "visible" }).fadeIn(); win.header.title.css("width", "auto"); win.header.title.width(win.header.title.width()); win.header.title.html(win.setting.title); if (win.setting.description.display) { win.body.description.wrapper.css("width", "auto"); win.body.description.wrapper.width(win.body.description.wrapper.width()); if (win.setting.description.title) { win.body.description.title.html(win.setting.description.title) } if (win.setting.description.message) { win.body.description.message.html(win.setting.description.message) } } win.data("window-resizing", false); win.data("resizing", false) }) }, 0) } function render() { if (currentWindow.setting.onLoading && $.isFunction(currentWindow.setting.onLoading)) { currentWindow.setting.onLoading.call(currentWindow) } if (currentWindow.setting.type === "iframe") { wrapLoader(loadIframe) } else { if (currentWindow.setting.type === "image") { wrapLoader(loadImage) } else { if (currentWindow.setting.type === "ajax") { loadAjax() } else { wrapLoader(loadBlock) } } } } function wrapLoader(callback) { $(window).unbind("resize.cui-window").bind("resize.cui-window", function(e) { $(".cui-window").each(function() { var win = getWindow(this.id); window.clearTimeout(win.windowResizeTimeout); win.windowResizeTimeout = window.setTimeout(function() { win.data("window-resizing", true); callback(win) }, 200) }) }); callback(currentWindow) } function ajaxLoaded(data) { log.debug("Ajax加载：" + currentWindow.setting.url); var block = $(document.createElement("div")).append(filterScripts(data)); if (currentWindow.setting.selector) { initBlock($("style, link, title, meta, " + currentWindow.setting.selector, block)) } else { initBlock(block.contents()) } setTimeout(function() { initialize(currentWindow.body.container) }, 0); wrapLoader(loadBlock); log.debug("Ajax操作完毕！") } function filterScripts(data) { if (typeof data == "string") { data = data.replace(/<\/?(html|head|body)([^>]*)>/gi, "") } var tmp = new Array(); $.each($.clean({ 0: data }, this.ownerDocument), function() { if (!$.nodeName(this, "script")) { tmp.push(this) } }); return tmp } function loadingError() { log.error("加载失败！"); currentWindow.setting.title = currentWindow.lang.error; var error = $('<p class="cui-win-specify cui-win-error"></p>').append(currentWindow.lang.requestError + currentWindow.setting.url + "<br /><br />").append(currentWindow.lang.requestErrorContent); initBlock(error); wrapLoader(loadBlock); $(".cui-win-close", error).click(function() { closeWindow(currentWindow) }); return false } function initBlock(data) { var content = $("<div></div>").css({ "float": "left" }).append(data).appendTo(currentWindow.dock); var title = $("title", content); if (title.size() > 0) { currentWindow.setting.title = $.trim(title.text()) || currentWindow.setting.title } currentWindow.data("content-width", content.outerWidth(true)); currentWindow.data("content-height", content.outerHeight(true)); currentWindow.body.container.append(content.contents()); setTimeout(function() { content.remove() }, 0) } function loadAjax() { var url = currentWindow.setting.url; if (url.indexOf(" ") > -1) { currentWindow.setting.url = url.substring(0, url.indexOf(" ")); currentWindow.setting.selector = url.substring(url.indexOf(" ")) } $.ajax({ type: currentWindow.setting.method, url: currentWindow.setting.url, data: currentWindow.setting.data, success: ajaxLoaded, error: loadingError, cache: !$.browser.msie }) } function loadBlock(win) { var w = win.data("content-width"); var h = win.data("content-height"); log.debug("块尺寸：" + w + "*" + h); win.onResizeComplete = function(w, h) { win.body.container.width(w).height(h) }; resize(win, w, h) } function loadImage(win) { var analyzeSize = function(w, h) { var minWidth = 384; var minHeight = 288; var img = $("img", win.body.container); var wrap = img.parent(); if (w < minWidth || h < minHeight) { wrap.css({ background: "url(" + img[0].src + ") no-repeat 50% 50%" }); img.hide() } else { wrap.css("background", ""); img.show() } w = w < minWidth ? minWidth : w; h = h < minHeight ? minHeight : h; return { width: w, height: h} }; if (win.data("window-resizing")) { var w = win.data("content-width"); var h = win.data("content-height"); log.debug("原始尺寸：" + w + "*" + h); var size = analyzeSize(w, h); resize(win, size.width, size.height) } else { if (win.gallery.images.length === 0) { win.gallery.images.push(win.setting.url); win.gallery.titles.push(win.setting.title) } var wrap = $(document.createElement("div")).css({ width: "0", height: "0", overflow: "hidden" }).addClass("cui-win-gallery"); var img = $(document.createElement("img")).appendTo(wrap); var prev = $(document.createElement("a")).addClass("cui-win-prev").appendTo(wrap).click(function() { var i = $.inArray(img[0].src, win.gallery.images); if (i > 0) { wrap.fadeTo(300, 0.01, function() { i--; wrap.css("visibility", "hidden"); img.attr({ src: win.gallery.images[i], title: win.gallery.titles[i] }); toggleHandler(i) }) } }).attr("title", win.lang.prev); var next = $(document.createElement("a")).addClass("cui-win-next").appendTo(wrap).click(function() { var i = $.inArray(img[0].src, win.gallery.images); if (i < win.gallery.images.length - 1) { wrap.fadeTo(300, 0.01, function() { i++; wrap.css("visibility", "hidden"); img.attr({ src: win.gallery.images[i], title: win.gallery.titles[i] }); toggleHandler(i) }) } }).attr("title", win.lang.next); var original = $(document.createElement("a")).addClass("cui-win-original").appendTo(wrap).attr({ title: win.lang.original, target: "_blank" }); var desc = $(document.createElement("a")).addClass("cui-win-desc").appendTo(wrap).data("show", true); if (win.setting.description.display) { desc.hide().data("show", false) } var toggleHandler = function(i) { if (i > 0) { prev.show().data("show", true) } else { prev.hide().data("show", false) } if (i < win.gallery.images.length - 1) { next.show().data("show", true) } else { next.hide().data("show", false) } original.show() }; wrap.hover(function() { if (prev.data("show")) { prev.show() } if (next.data("show")) { next.show() } if (desc.data("show")) { desc.show() } original.show() }, function() { prev.hide(); next.hide(); desc.hide(); original.hide() }); var resizing = function(obj, callback) { var w = obj.outerWidth(true); var h = obj.outerHeight(true); win.data("content-width", w); win.data("content-height", h); log.debug("原始尺寸：" + w + "*" + h); var size = analyzeSize(w, h); win.onResizeComplete = function(w, h) { img.width(w).height(h); wrap.width(w).height(h); wrap.css("visibility", "visible"); if (callback && $.isFunction(callback)) { callback() } }; resize(win, size.width, size.height) }; img.load(function() { var src = img[0].src; setTimeout(function() { log.debug("图片已加载：" + src); wrap.fadeTo(300, 1); if (img.data("inited")) { $(document.createElement("img")).hide().appendTo("body").load(function() { var t = $(this); resizing(t, function() { t.remove() }) }).attr("src", src) } else { resizing(img, function() { wrap.css({ overflow: "visible", position: "relative" }) }); img.data("inited", true) } var it = '<b style="font-size:1.5em;line-height:100%;font-family:Arial,Helvetica,sans-serif;">' + ($.inArray(src, win.gallery.images) + 1) + '</b><b style="font-size:10px;font-weight:400;font-family:Arial,Helvetica,sans-serif;">/' + win.gallery.images.length + "</b>"; var id = win.gallery.titles[$.inArray(src, win.gallery.images)]; if (win.setting.description.display) { win.setting.title = win.gallery.title; win.setting.description.title = it; win.setting.description.message = id } else { if (win.gallery.images.length > 1) { win.setting.title = (win.gallery.title || src) + "[" + $(it).text() + "]" } else { win.setting.title = win.gallery.title || src } desc.text(id) } original.attr("href", src); log.debug("图片操作完毕！") }, 0); win.setting.url = src }).attr({ src: win.setting.url }).error(loadingError); toggleHandler($.inArray(img[0].src, win.gallery.images)); win.body.container.append(wrap) } } function loadIframe(win) { if (win.data("window-resizing")) { var w = win.data("content-width", w); var h = win.data("content-height", h); log.debug("原始尺寸：" + w + "*" + h); resize(win, w, h) } else { var iframe = $('<iframe frameborder="0" hspace="0"></iframe>').css({ width: win.setting.minWidth + "px", height: "0" }); iframe.load(function() { log.debug("iFrame已加载：" + win.setting.url); var body = null; try { body = iframe.contents().find("body"); win.setting.title = iframe.contents().find("title").text() || win.setting.title } catch (ex) { body = null } if (!iframe.data("inited") || body) { var w = win.setting.minWidth; var h = win.setting.minHeight; if (body && body.height() > 0) { body.css("float", "left"); body.width(body.width()); w = body.outerWidth(true); h = body.outerHeight(true); if ($.browser.msie && $.browser.version < 8) { var ib = body.closest("html")[0]; w = ib.scrollWidth; h = ib.scrollHeight } if (iframe[0].contentWindow) { var contentWindow = iframe[0].contentWindow; contentWindow.popwin = win; if (win.parent && win.parent.iframe && win.parent.iframe[0].contentWindow) { contentWindow.parent = win.parent.iframe[0].contentWindow } if (!contentWindow.jQuery || !$.isFunction(contentWindow.jQuery.window)) { setTimeout(function() { initialize(body) }, 0) } } } win.data("content-width", w); win.data("content-height", h); log.debug("原始尺寸：" + w + "*" + h); win.onResizeComplete = function(xw, xh) { iframe.width(xw).height(xh) }; win.onSizeCompute = function(vw, vh) { if (body && body.height() > 0) { if (h > vh) { log.debug("有垂直滚动条"); vw += window.scrollWidth } } return { width: vw, height: vh} }; resize(win, w, h) } iframe.data("inited", true); log.debug("iFrame处理完毕！") }).error(loadingError); var id = "cui-window-" + random(); iframe.attr({ id: id, name: id, src: win.setting.url }); win.body.container.append(iframe); win.iframe = iframe } } function initDrag() { if (currentWindow.setting.drag.enabled) { var dw = $(window).width(); var dh = $(window).height(); setTimeout(function() { currentWindow.handle.mousedown(function(e) { activeWindow($(this).closest(".cui-window").attr("id")); currentWindow.body.css("opacity", "0.75"); if (currentWindow.setting.drag.hideContent) { currentWindow.body.content.css("visibility", "hidden") } dw = $(window).width(); dh = $(window).height(); var offset = currentWindow.offset(); var x = e.pageX - offset.left; var y = e.pageY - offset.top; if (!$.browser.msie6) { x += $(window).scrollLeft(); y += $(window).scrollTop() } currentWindow.data("moving", true); currentWindow.data("x", x); currentWindow.data("y", y); currentWindow.handle.addClass("cui-win-move") }) }, 0); setTimeout(function() { $(document).unbind("mouseup.cui-window").bind("mouseup.cui-window", function() { if (!currentWindow.data("moving")) { return } currentWindow.data("moving", false); currentWindow.handle.removeClass("cui-win-move"); currentWindow.body.css("opacity", ""); if (currentWindow.setting.drag.hideContent) { currentWindow.body.content.css("visibility", "visible") } }).unbind("mousemove.cui-window").bind("mousemove.cui-window", function(e) { if (!currentWindow.data("moving")) { return } var w = currentWindow.width(); var h = currentWindow.height(); var x = e.pageX - parseInt(currentWindow.data("x")); var y = e.pageY - parseInt(currentWindow.data("y")); var rt = 0; var rl = 0; if ($.browser.msie6) { rt = $(window).scrollTop(); rl = $(window).scrollLeft() } var rr = dw + rl; var rb = dh + rt; x = x < rl ? rl : x; y = y < rt ? rt : y; x = (x + w) < rr ? x : (rr - w); y = (y + h) < rb ? y : (rb - h); currentWindow.css({ top: y + "px", left: x + "px" }) }) }, 0) } } function scrollFix() { if ($.browser.msie6) { setTimeout(function() { $(window).unbind("scroll.cui-window").bind("scroll.cui-window", function() { $(".cui-window").each(function() { var win = getWindow(this.id); if (win) { window.clearTimeout(win.windowScrollTimeout); win.windowScrollTimeout = window.setTimeout(function() { var sl = $(window).scrollLeft(); var st = $(window).scrollTop(); var x = win.offset().left + sl - (win.ox || 0); var y = win.offset().top + st - (win.oy || 0); win.ox = sl; win.oy = st; win.animate({ left: x + "px", top: y + "px" }) }, 200) } }) }) }, 0) } } function random() { var under = 10000000; var over = 99999999; return parseInt(Math.random() * (over - under + 1) + under) } function getCulture() { var l = "en"; if (navigator.appName == "Netscape") { l = navigator.language } else { l = navigator.browserLanguage } l = l.substring(0, 2); if (typeof (langs[l]) === "undefined") { l = "en" } return l } function overlay(setting) { if ($.isFunction($.overlay) && setting.overlay.enabled) { setting.overlay.zIndex = setting.zIndex - 5; $.overlay(setting.overlay); $(document).data("cui-win-overlay", true) } else { setting.overlay.onOverlay() } } function unOverLay() { if ($.isFunction($.overlay)) { $.overlay("close"); $(document).data("cui-win-overlay", false) } } function isImage(href) { var regexImg = "[^.].(jpg|jpeg|png|tiff|gif|bmp)s*$"; var image = new RegExp(regexImg, "i"); return image.test(href) } function isCrossDomain(href) { if (window.location.hostname) { return (href.indexOf(window.location.hostname) === -1) } else { return (href.indexOf("http://") > -1) } } function modal(zIndex) { var modal = $("#cui-win-modal"); if (modal.size() === 0) { modal = $(document.createElement("div")).appendTo("body").css({ position: "fixed", top: "0", right: "0", bottom: "0", left: "0", opacity: "0", background: "#fff", "z-index": zIndex }).attr("id", "cui-win-modal"); if ($.browser.msie6) { var root = $("html")[0]; var w = Math.max(root.scrollWidth, $(window).width()); var h = Math.max(root.scrollHeight, $(window).height()); var iframe = $('<iframe frameborder="0" hspace="0" width="100%" height="100%"></iframe>').css({ opacity: "0" }); modal.css({ position: "absolute", width: w + "px", height: h + "px" }).append(iframe); var windowResizeTimeout = null; $(window).unbind("resize.cui-win-modal").bind("resize.cui-win-modal", function() { window.clearTimeout(windowResizeTimeout); windowResizeTimeout = window.setTimeout(function() { w = Math.max(root.scrollWidth, $(window).width()); h = Math.max(root.scrollHeight, $(window).height()); modal.width(w).height(h) }, 200) }) } else { if (!$(document).data("cui-win-overlay")) { $("object, embed", "body").css("visibility", "hidden") } } modal.show() } } function unModal() { var modal = $("#cui-win-modal"); modal.remove(); if (!$(document).data("cui-win-overlay")) { $("object, embed", "body").css("visibility", "visible") } if ($.browser.msie6) { $(window).unbind("resize.cui-win-modal") } } })(jQuery);

$.window("set-defaults", {
    theme: "biz",
    culture: 'en'
});
