/*! * artDialog 4.1.6 * Date: 2012-07-16 22:57 * http://code.google.com/p/artdialog/ * (c) 2009-2012 TangBin, http://www.planeArt.cn * * This is licensed under the GNU LGPL, version 2.1 or later. * For details, see: http://creativecommons.org/licenses/LGPL/2.1/ */ (function($, window, undefined) { $.noop = $.noop || function() { }; var _box, _thisScript, _skin, _path, _count = 0, _$window = $(window), _$document = $(document), _$html = $("html"), _elem = document.documentElement, _isIE6 = window.VBArray && !window.XMLHttpRequest, _isMobile = "createTouch" in document && !("onmousemove" in _elem) || /(iPhone|iPad|iPod)/i.test(navigator.userAgent), _expando = "artDialog" + +new Date; var artDialog = function(config, ok, cancel) { config = config || {}; if (typeof config === "string" || config.nodeType === 1) { config = { content : config, fixed : !_isMobile } } var api, defaults = artDialog.defaults, elem = config.follow = this.nodeType === 1 && this || config.follow; for ( var i in defaults) { if (config[i] === undefined) { config[i] = defaults[i] } } $.each({ ok : "yesFn", cancel : "noFn", close : "closeFn", init : "initFn", okVal : "yesText", cancelVal : "noText" }, function(i, o) { config[i] = config[i] !== undefined ? config[i] : config[o] }); if (typeof elem === "string") { elem = $(elem)[0] } config.id = elem && elem[_expando + "follow"] || config.id || _expando + _count; api = artDialog.list[config.id]; if (elem && api) { return api.follow(elem).zIndex().focus() } if (api) { return api.zIndex().focus() } if (_isMobile) { config.fixed = false } if (!$.isArray(config.button)) { config.button = config.button ? [ config.button ] : [] } if (ok !== undefined) { config.ok = ok } if (cancel !== undefined) { config.cancel = cancel } config.ok && config.button.push({ name : config.okVal, callback : config.ok, focus : true }); config.cancel && config.button.push({ name : config.cancelVal, callback : config.cancel }); artDialog.defaults.zIndex = config.zIndex; _count++; return artDialog.list[config.id] = _box ? _box._init(config) : new artDialog.fn._init(config) }; artDialog.fn = artDialog.prototype = { version : "4.1.6", closed : true, _init : function(config) { var that = this, DOM, icon = config.icon, iconBg = icon && (_isIE6 ? { png : "icons/" + icon + ".png" } : { backgroundImage : "url('" + config.path + "/skins/icons/" + icon + ".png')" }); that.closed = false; that.config = config; that.DOM = DOM = that.DOM || that._getDOM(); DOM.wrap.addClass(config.skin); DOM.close[config.cancel === false ? "hide" : "show"](); DOM.icon[0].style.display = icon ? "" : "none"; DOM.iconBg.css(iconBg || { background : "none" }); DOM.se.css("cursor", config.resize ? "se-resize" : "auto"); DOM.title.css("cursor", config.drag ? "move" : "auto"); DOM.content.css("padding", config.padding); that[config.show ? "show" : "hide"](true); that.button(config.button).title(config.title).content( config.content, true).size(config.width, config.height) .time(config.time); config.follow ? that.follow(config.follow) : that.position( config.left, config.top); that.zIndex().focus(); config.lock && that.lock(); that._addEvent(); that._ie6PngFix(); _box = null; if (config.id == "Tips") { DOM.wrap.addClass("dr_tips") } config.init && config.init.call(that, window); return that }, content : function(msg) { var prev, next, parent, display, that = this, DOM = that.DOM, wrap = DOM.wrap[0], width = wrap.offsetWidth, height = wrap.offsetHeight, left = parseInt(wrap.style.left), top = parseInt(wrap.style.top), cssWidth = wrap.style.width, $content = DOM.content, content = $content[0]; that._elemBack && that._elemBack(); wrap.style.width = "auto"; if (msg === undefined) { return content } if (typeof msg === "string") { $content.html(msg) } else { if (msg && msg.nodeType === 1) { display = msg.style.display; prev = msg.previousSibling; next = msg.nextSibling; parent = msg.parentNode; that._elemBack = function() { if (prev && prev.parentNode) { prev.parentNode.insertBefore(msg, prev.nextSibling) } else { if (next && next.parentNode) { next.parentNode.insertBefore(msg, next) } else { if (parent) { parent.appendChild(msg) } } } msg.style.display = display; that._elemBack = null }; $content.html(""); content.appendChild(msg); msg.style.display = "block" } } if (!arguments[1]) { if (that.config.follow) { that.follow(that.config.follow) } else { width = wrap.offsetWidth - width; height = wrap.offsetHeight - height; left = left - width / 2; top = top - height / 2; wrap.style.left = Math.max(left, 0) + "px"; wrap.style.top = Math.max(top, 0) + "px" } if (cssWidth && cssWidth !== "auto") { wrap.style.width = wrap.offsetWidth + "px" } that._autoPositionType() } that._ie6SelectFix(); that._runScript(content); return that }, title : function(text) { var DOM = this.DOM, wrap = DOM.wrap, title = DOM.title, className = "aui_state_noTitle"; if (text === undefined) { return title[0] } if (text === false) { title.hide().html(""); wrap.addClass(className) } else { title.show().html(text || ""); wrap.removeClass(className) } return this }, position : function(left, top) { var that = this, config = that.config, wrap = that.DOM.wrap[0], isFixed = _isIE6 ? false : config.fixed, ie6Fixed = _isIE6 && that.config.fixed, docLeft = _$document .scrollLeft(), docTop = _$document.scrollTop(), dl = isFixed ? 0 : docLeft, dt = isFixed ? 0 : docTop, ww = _$window.width(), wh = _$window .height(), ow = wrap.offsetWidth, oh = wrap.offsetHeight, style = wrap.style; if (left || left === 0) { that._left = left.toString().indexOf("%") !== -1 ? left : null; left = that._toNumber(left, ww - ow); if (typeof left === "number") { left = ie6Fixed ? (left += docLeft) : left + dl; style.left = Math.max(left, dl) + "px" } else { if (typeof left === "string") { style.left = left } } } if (top || top === 0) { that._top = top.toString().indexOf("%") !== -1 ? top : null; top = that._toNumber(top, wh - oh); if (typeof top === "number") { top = ie6Fixed ? (top += docTop) : top + dt; style.top = Math.max(top, dt) + "px" } else { if (typeof top === "string") { style.top = top } } } if (left !== undefined && top !== undefined) { that._follow = null; that._autoPositionType() } return that }, size : function(width, height) { var maxWidth, maxHeight, scaleWidth, scaleHeight, that = this, config = that.config, DOM = that.DOM, wrap = DOM.wrap, main = DOM.main, wrapStyle = wrap[0].style, style = main[0].style; if (width) { that._width = width.toString().indexOf("%") !== -1 ? width : null; maxWidth = _$window.width() - wrap[0].offsetWidth + main[0].offsetWidth; scaleWidth = that._toNumber(width, maxWidth); width = scaleWidth; if (typeof width === "number") { wrapStyle.width = "auto"; style.width = Math.max(that.config.minWidth, width) + "px"; wrapStyle.width = wrap[0].offsetWidth + "px" } else { if (typeof width === "string") { style.width = width; width === "auto" && wrap.css("width", "auto") } } } if (height) { that._height = height.toString().indexOf("%") !== -1 ? height : null; maxHeight = _$window.height() - wrap[0].offsetHeight + main[0].offsetHeight; scaleHeight = that._toNumber(height, maxHeight); height = scaleHeight; if (typeof height === "number") { style.height = Math.max(that.config.minHeight, height) + "px" } else { if (typeof height === "string") { style.height = height } } } that._ie6SelectFix(); return that }, follow : function(elem) { var $elem, that = this, config = that.config; if (typeof elem === "string" || elem && elem.nodeType === 1) { $elem = $(elem); elem = $elem[0] } if (!elem || !elem.offsetWidth && !elem.offsetHeight) { return that.position(that._left, that._top) } var expando = _expando + "follow", winWidth = _$window.width(), winHeight = _$window .height(), docLeft = _$document.scrollLeft(), docTop = _$document .scrollTop(), offset = $elem.offset(), width = elem.offsetWidth, height = elem.offsetHeight, isFixed = _isIE6 ? false : config.fixed, left = isFixed ? offset.left - docLeft : offset.left, top = isFixed ? offset.top - docTop : offset.top, wrap = that.DOM.wrap[0], style = wrap.style, wrapWidth = wrap.offsetWidth, wrapHeight = wrap.offsetHeight, setLeft = left - (wrapWidth - width) / 2, setTop = top + height, dl = isFixed ? 0 : docLeft, dt = isFixed ? 0 : docTop; setLeft = setLeft < dl ? left : (setLeft + wrapWidth > winWidth) && (left - wrapWidth > dl) ? left - wrapWidth + width : setLeft; setTop = (setTop + wrapHeight > winHeight + dt) && (top - wrapHeight > dt) ? top - wrapHeight : setTop; style.left = setLeft + "px"; style.top = setTop + "px"; that._follow && that._follow.removeAttribute(expando); that._follow = elem; elem[expando] = config.id; that._autoPositionType(); return that }, button : function() { var that = this, ags = arguments, DOM = that.DOM, buttons = DOM.buttons, elem = buttons[0], strongButton = "aui_state_highlight", listeners = that._listeners = that._listeners || {}, list = $.isArray(ags[0]) ? ags[0] : [].slice .call(ags); $(".aui_icon").css("padding-bottom", "0"); $(".aui_main").css("padding-bottom", "0"); if (ags[0] === undefined) { return elem } $ .each( list, function(i, val) { var name = val.name, isNewButton = !listeners[name], button = !isNewButton ? listeners[name].elem : document.createElement("button"); if (!listeners[name]) { listeners[name] = {} } if (val.callback) { listeners[name].callback = val.callback } if (val.className) { button.className = val.className } if (val.focus) { that._focus && that._focus .removeClass(strongButton); that._focus = $(button).addClass( strongButton); that.focus() } button.setAttribute("type", "button"); button[_expando + "callback"] = name; button.disabled = !!val.disabled; if (isNewButton) { button.innerHTML = name; listeners[name].elem = button; elem.appendChild(button) } }); buttons[0].style.display = list.length ? "" : "none"; that._ie6SelectFix(); return that }, show : function() { this.DOM.wrap.show(); !arguments[0] && this._lockMaskWrap && this._lockMaskWrap.show(); return this }, hide : function() { this.DOM.wrap.hide(); !arguments[0] && this._lockMaskWrap && this._lockMaskWrap.hide(); return this }, close : function() { if (this.closed) { return this } var that = this, DOM = that.DOM, wrap = DOM.wrap, list = artDialog.list, fn = that.config.close, follow = that.config.follow; that.time(); if (typeof fn === "function" && fn.call(that, window) === false) { return that } that.unlock(); that._elemBack && that._elemBack(); wrap[0].className = wrap[0].style.cssText = ""; DOM.title.html(""); DOM.content.html(""); DOM.buttons.html(""); if (artDialog.focus === that) { artDialog.focus = null } if (follow) { follow.removeAttribute(_expando + "follow") } delete list[that.config.id]; that._removeEvent(); that.hide(true)._setAbsolute(); for ( var i in that) { if (that.hasOwnProperty(i) && i !== "DOM") { delete that[i] } } _box ? wrap.remove() : _box = that; return that }, time : function(second) { var that = this, cancel = that.config.cancelVal, timer = that._timer; timer && clearTimeout(timer); if (second) { that._timer = setTimeout(function() { that._click(cancel) }, 1000 * second) } return that }, focus : function() { try { var elem = this._focus && this._focus[0] || this.DOM.close[0]; elem && elem.focus() } catch (e) { } return this }, zIndex : function() { var that = this, DOM = that.DOM, wrap = DOM.wrap, top = artDialog.focus, index = artDialog.defaults.zIndex++; wrap.css("zIndex", index); that._lockMask && that._lockMask.css("zIndex", index - 1); top && top.DOM.wrap.removeClass("aui_state_focus"); artDialog.focus = that; wrap.addClass("aui_state_focus"); return that }, lock : function() { if (this._lock) { return this } var that = this, index = artDialog.defaults.zIndex - 1, wrap = that.DOM.wrap, config = that.config, docWidth = _$document .width(), docHeight = _$document.height(), lockMaskWrap = that._lockMaskWrap || $(document.body.appendChild(document .createElement("div"))), lockMask = that._lockMask || $(lockMaskWrap[0].appendChild(document .createElement("div"))), domTxt = "(document).documentElement", sizeCss = _isMobile ? "width:" + docWidth + "px;height:" + docHeight + "px" : "width:100%;height:100%", ie6Css = _isIE6 ? "position:absolute;left:expression(" + domTxt + ".scrollLeft);top:expression(" + domTxt + ".scrollTop);width:expression(" + domTxt + ".clientWidth);height:expression(" + domTxt + ".clientHeight)" : ""; that.zIndex(); wrap.addClass("aui_state_lock"); lockMaskWrap[0].style.cssText = sizeCss + ";position:fixed;z-index:" + index + ";top:0;left:0;overflow:hidden;" + ie6Css; lockMask[0].style.cssText = "height:100%;background:" + config.background + ";filter:alpha(opacity=0);opacity:0"; if (_isIE6) { lockMask .html('') } lockMask.stop(); lockMask.bind("click", function() { that._reset() }).bind("dblclick", function() { //that._click(that.config.cancelVal) }); if (config.duration === 0) { lockMask.css({ opacity : config.opacity }) } else { lockMask.animate({ opacity : config.opacity }, config.duration) } that._lockMaskWrap = lockMaskWrap; that._lockMask = lockMask; that._lock = true; return that }, unlock : function() { var that = this, lockMaskWrap = that._lockMaskWrap, lockMask = that._lockMask; if (!that._lock) { return that } var style = lockMaskWrap[0].style; var un = function() { if (_isIE6) { style.removeExpression("width"); style.removeExpression("height"); style.removeExpression("left"); style.removeExpression("top") } style.cssText = "display:none"; _box && lockMaskWrap.remove() }; lockMask.stop().unbind(); that.DOM.wrap.removeClass("aui_state_lock"); if (!that.config.duration) { un() } else { lockMask.animate({ opacity : 0 }, that.config.duration, un) } that._lock = false; return that }, _getDOM : function() { var wrap = document.createElement("div"), body = document.body; wrap.style.cssText = "position:absolute;left:0;top:0"; wrap.innerHTML = artDialog._templates; body.insertBefore(wrap, body.firstChild); var name, i = 0, DOM = { wrap : $(wrap) }, els = wrap.getElementsByTagName("*"), elsLen = els.length; for (; i < elsLen; i++) { name = els[i].className.split("aui_")[1]; if (name) { DOM[name] = $(els[i]) } } return DOM }, _toNumber : function(thisValue, maxValue) { if (!thisValue && thisValue !== 0 || typeof thisValue === "number") { return thisValue } var last = thisValue.length - 1; if (thisValue.lastIndexOf("px") === last) { thisValue = parseInt(thisValue) } else { if (thisValue.lastIndexOf("%") === last) { thisValue = parseInt(maxValue * thisValue.split("%")[0] / 100) } } return thisValue }, _ie6PngFix : _isIE6 ? function() { var i = 0, elem, png, pngPath, runtimeStyle, path = artDialog.defaults.path + "/skins/", list = this.DOM.wrap[0] .getElementsByTagName("*"); for (; i < list.length; i++) { elem = list[i]; png = elem.currentStyle["png"]; if (png) { pngPath = path + png; runtimeStyle = elem.runtimeStyle; runtimeStyle.backgroundImage = "none"; runtimeStyle.filter = "progid:DXImageTransform.Microsoft." + "AlphaImageLoader(src='" + pngPath + "',sizingMethod='crop')" } } } : $.noop, _ie6SelectFix : _isIE6 ? function() { var $wrap = this.DOM.wrap, wrap = $wrap[0], expando = _expando + "iframeMask", iframe = $wrap[expando], width = wrap.offsetWidth, height = wrap.offsetHeight; width = width + "px"; height = height + "px"; if (iframe) { iframe.style.width = width; iframe.style.height = height } else { iframe = wrap.appendChild(document.createElement("iframe")); $wrap[expando] = iframe; iframe.src = "about:blank"; iframe.style.cssText = "position:absolute;z-index:-1;left:0;top:0;" + "filter:alpha(opacity=0);width:" + width + ";height:" + height } } : $.noop, _runScript : function(elem) { var fun, i = 0, n = 0, tags = elem.getElementsByTagName("script"), length = tags.length, script = []; for (; i < length; i++) { if (tags[i].type === "text/dialog") { script[n] = tags[i].innerHTML; n++ } } if (script.length) { script = script.join(""); fun = new Function(script); fun.call(this) } }, _autoPositionType : function() { this[this.config.fixed ? "_setFixed" : "_setAbsolute"]() }, _setFixed : (function() { _isIE6 && $(function() { var bg = "backgroundAttachment"; if (_$html.css(bg) !== "fixed" && $("body").css(bg) !== "fixed") { _$html.css({ zoom : 1, backgroundImage : "url(about:blank)", backgroundAttachment : "fixed" }) } }); return function() { var $elem = this.DOM.wrap, style = $elem[0].style; if (_isIE6) { var left = parseInt($elem.css("left")), top = parseInt($elem .css("top")), sLeft = _$document.scrollLeft(), sTop = _$document .scrollTop(), txt = "(document.documentElement)"; this._setAbsolute(); style.setExpression("left", "eval(" + txt + ".scrollLeft + " + (left - sLeft) + ') + "px"'); style.setExpression("top", "eval(" + txt + ".scrollTop + " + (top - sTop) + ') + "px"') } else { style.position = "fixed" } } }()), _setAbsolute : function() { var style = this.DOM.wrap[0].style; if (_isIE6) { style.removeExpression("left"); style.removeExpression("top") } style.position = "absolute" }, _click : function(name) { var that = this, fn = that._listeners[name] && that._listeners[name].callback; return typeof fn !== "function" || fn.call(that, window) !== false ? that .close() : that }, _reset : function(test) { var newSize, that = this, oldSize = that._winSize || _$window.width() * _$window.height(), elem = that._follow, width = that._width, height = that._height, left = that._left, top = that._top; if (test) { newSize = that._winSize = _$window.width() * _$window.height(); if (oldSize === newSize) { return } } if (width || height) { that.size(width, height) } if (elem) { that.follow(elem) } else { if (left || top) { that.position(left, top) } } }, _addEvent : function() { var resizeTimer, that = this, config = that.config, isIE = "CollectGarbage" in window, DOM = that.DOM; that._winResize = function() { resizeTimer && clearTimeout(resizeTimer); resizeTimer = setTimeout(function() { that._reset(isIE) }, 40) }; _$window.bind("resize", that._winResize); DOM.wrap.bind("click", function(event) { var target = event.target, callbackID; if (target.disabled) { return false } if (target === DOM.close[0]) { that._click(config.cancelVal); return false } else { callbackID = target[_expando + "callback"]; callbackID && that._click(callbackID) } that._ie6SelectFix() }).bind("mousedown", function() { that.zIndex() }) }, _removeEvent : function() { var that = this, DOM = that.DOM; DOM.wrap.unbind(); _$window.unbind("resize", that._winResize) } }; artDialog.fn._init.prototype = artDialog.fn; $.fn.dialog = $.fn.artDialog = function() { var config = arguments; this[this.live ? "live" : "bind"]("click", function() { artDialog.apply(this, config); return false }); return this }; artDialog.focus = null; artDialog.get = function(id) { return id === undefined ? artDialog.list : artDialog.list[id] }; artDialog.list = {}; _$document .bind( "keydown", function(event) { var target = event.target, nodeName = target.nodeName, rinput = /^INPUT|TEXTAREA$/, api = artDialog.focus, keyCode = event.keyCode; if (!api || !api.config.esc || rinput.test(nodeName)) { return } keyCode === 27 && api._click(api.config.cancelVal) }); _path = window["_artDialog_path"] || (function(script, i, me) { for (i in script) { if (script[i].src && script[i].src.indexOf("artDialog") !== -1) { me = script[i] } } _thisScript = me || script[script.length - 1]; me = _thisScript.src.replace(/\\/g, "/"); return me.lastIndexOf("/") < 0 ? "." : me.substring(0, me .lastIndexOf("/")) }(document.getElementsByTagName("script"))); _skin = _thisScript.src.split("skin=")[1]; if (_skin) { var link = document.createElement("link"); link.rel = "stylesheet"; link.href = _path + "/skins/" + _skin + ".css?" + artDialog.fn.version; _thisScript.parentNode.insertBefore(link, _thisScript) } _$window.bind("load", function() { setTimeout(function() { if (_count) { return } artDialog({ left : "-9999em", time : 9, fixed : false, lock : false, focus : false }) }, 150) }); try { document.execCommand("BackgroundImageCache", false, true) } catch (e) { } artDialog._templates = '
' + '' + "" + "" + '' + '' + '' + "" + "" + '' + '" + '' + "" + "" + '' + '' + '' + "" + "" + "
' + '
' + '' + "" + "" + '" + "" + "" + '" + '" + "" + "" + '" + "" + "" + "
' + '
' + '
' + '' + "\xd7" + "" + "
" + "
' + '
' + "
' + '
' + "
" + "
" + "
" + "
"; artDialog.defaults = { content : '
loading..
', title : "", button : null, ok : null, cancel : null, init : null, close : null, okVal : "\u786E\u5B9A", cancelVal : "\u53D6\u6D88", width : "auto", height : "auto", minWidth : 96, minHeight : 32, padding : "10px 15px", skin : "", icon : null, time : null, esc : true, focus : true, show : true, follow : null, path : _path, lock : false, background : "#fdfdfd", opacity : 0.7, duration : 300, fixed : false, left : "50%", top : "38.2%", zIndex : 1987, resize : true, drag : true }; window.artDialog = $.dialog = $.artDialog = artDialog }(this.art || this.jQuery && (this.art = jQuery), this)); (function($) { var _dragEvent, _use, _$window = $(window), _$document = $(document), _elem = document.documentElement, _isIE6 = !("minWidth" in _elem.style), _isLosecapture = "onlosecapture" in _elem, _isSetCapture = "setCapture" in _elem; artDialog.dragEvent = function() { var that = this, proxy = function(name) { var fn = that[name]; that[name] = function() { return fn.apply(that, arguments) } }; proxy("start"); proxy("move"); proxy("end") }; artDialog.dragEvent.prototype = { onstart : $.noop, start : function(event) { _$document.bind("mousemove", this.move).bind("mouseup", this.end); this._sClientX = event.clientX; this._sClientY = event.clientY; this.onstart(event.clientX, event.clientY); return false }, onmove : $.noop, move : function(event) { this._mClientX = event.clientX; this._mClientY = event.clientY; this.onmove(event.clientX - this._sClientX, event.clientY - this._sClientY); return false }, onend : $.noop, end : function(event) { _$document.unbind("mousemove", this.move).unbind("mouseup", this.end); this.onend(event.clientX, event.clientY); return false } }; _use = function(event) { var limit, startWidth, startHeight, startLeft, startTop, isResize, api = artDialog.focus, DOM = api.DOM, wrap = DOM.wrap, title = DOM.title, main = DOM.main; var clsSelect = "getSelection" in window ? function() { window.getSelection().removeAllRanges() } : function() { try { document.selection.empty() } catch (e) { } }; _dragEvent.onstart = function(x, y) { if (isResize) { startWidth = main[0].offsetWidth; startHeight = main[0].offsetHeight } else { startLeft = wrap[0].offsetLeft; startTop = wrap[0].offsetTop } _$document.bind("dblclick", _dragEvent.end); !_isIE6 && _isLosecapture ? title.bind("losecapture", _dragEvent.end) : _$window.bind("blur", _dragEvent.end); _isSetCapture && title[0].setCapture(); wrap.addClass("aui_state_drag"); api.focus() }; _dragEvent.onmove = function(x, y) { if (isResize) { var wrapStyle = wrap[0].style, style = main[0].style, width = x + startWidth, height = y + startHeight; wrapStyle.width = "auto"; style.width = Math.max(0, width) + "px"; wrapStyle.width = wrap[0].offsetWidth + "px"; style.height = Math.max(0, height) + "px" } else { var style = wrap[0].style, left = Math.max(limit.minX, Math .min(limit.maxX, x + startLeft)), top = Math.max( limit.minY, Math.min(limit.maxY, y + startTop)); style.left = left + "px"; style.top = top + "px" } clsSelect(); api._ie6SelectFix() }; _dragEvent.onend = function(x, y) { _$document.unbind("dblclick", _dragEvent.end); !_isIE6 && _isLosecapture ? title.unbind("losecapture", _dragEvent.end) : _$window.unbind("blur", _dragEvent.end); _isSetCapture && title[0].releaseCapture(); _isIE6 && !api.closed && api._autoPositionType(); wrap.removeClass("aui_state_drag") }; isResize = event.target === DOM.se[0] ? true : false; limit = (function() { var maxX, maxY, wrap = api.DOM.wrap[0], fixed = wrap.style.position === "fixed", ow = wrap.offsetWidth, oh = wrap.offsetHeight, ww = _$window .width(), wh = _$window.height(), dl = fixed ? 0 : _$document.scrollLeft(), dt = fixed ? 0 : _$document .scrollTop(), maxX = ww - ow + dl; maxY = wh - oh + dt; return { minX : dl, minY : dt, maxX : maxX, maxY : maxY } })(); _dragEvent.start(event) }; _$document.bind("mousedown", function(event) { var api = artDialog.focus; if (!api) { return } var target = event.target, config = api.config, DOM = api.DOM; if (config.drag !== false && target === DOM.title[0] || config.resize !== false && target === DOM.se[0]) { _dragEvent = _dragEvent || new artDialog.dragEvent(); _use(event); return false } }) })(this.art || this.jQuery && (this.art = jQuery)); /* * ! artDialog iframeTools Date: 2011-11-25 13:54 * http://code.google.com/p/artdialog/ (c) 2009-2011 TangBin, * http://www.planeArt.cn * * This is licensed under the GNU LGPL, version 2.1 or later. For details, see: * http://creativecommons.org/licenses/LGPL/2.1/ */ (function($, window, artDialog, undefined) { var _topDialog, _proxyDialog, _zIndex, _data = "@ARTDIALOG.DATA", _open = "@ARTDIALOG.OPEN", _opener = "@ARTDIALOG.OPENER", _winName = window.name = window.name || "@ARTDIALOG.WINNAME" + +new Date, _isIE6 = window.VBArray && !window.XMLHttpRequest; $(function() { !window.jQuery && document.compatMode === "BackCompat" && alert('artDialog Error: document.compatMode === "BackCompat"') }); var _top = artDialog.top = function() { var top = window, test = function(name) { try { var doc = window[name].document; doc.getElementsByTagName } catch (e) { return false } return window[name].artDialog && doc.getElementsByTagName("frameset").length === 0 }; if (test("top")) { top = window.top } else { if (test("parent")) { top = window.parent } } return top }(); artDialog.parent = _top; _topDialog = _top.artDialog; _zIndex = function() { return _topDialog.defaults.zIndex }; artDialog.data = function(name, value) { var top = artDialog.top, cache = top[_data] || {}; top[_data] = cache; if (value !== undefined) { cache[name] = value } else { return cache[name] } return cache }; artDialog.removeData = function(name) { var cache = artDialog.top[_data]; if (cache && cache[name]) { delete cache[name] } }; artDialog.through = _proxyDialog = function() { var api = _topDialog.apply(this, arguments); if (_top !== window) { artDialog.list[api.config.id] = api } return api }; _top !== window && $(window).bind("unload", function() { var list = artDialog.list, config; for ( var i in list) { if (list[i]) { config = list[i].config; if (config) { config.duration = 0 } list[i].close() } } }); artDialog.open = function(url, options, cache) { options = options || {}; var api, DOM, $content, $main, iframe, $iframe, $idoc, iwin, ibody, top = artDialog.top, initCss = "position:absolute;left:-9999em;top:-9999em;border:none 0;background:transparent", loadCss = "width:100%;height:100%;border:none 0"; console.log("open"); if (cache === false) { var ts = +new Date, ret = url.replace(/([?&])_=[^&]*/, "$1_=" + ts); url = ret + ((ret === url) ? (/\?/.test(url) ? "&" : "?") + "_=" + ts : "") } var load = function() { console.log('load...'); var iWidth, iHeight, loading = DOM.content.find(".aui_loading"), aConfig = api.config; $content.addClass("aui_state_full"); loading && loading.hide(); try { iwin = iframe.contentWindow; $idoc = $(iwin.document); ibody = iwin.document.body } catch (e) { iframe.style.cssText = loadCss; aConfig.follow ? api.follow(aConfig.follow) : api.position( aConfig.left, aConfig.top); options.init && options.init.call(api, iwin, top); options.init = null; return } iWidth = aConfig.width === "auto" ? $idoc.width() + (_isIE6 ? 0 : parseInt($(ibody).css("marginLeft"))) : aConfig.width; iHeight = aConfig.height === "auto" ? $idoc.height() : aConfig.height; setTimeout(function() { iframe.style.cssText = loadCss }, 0); api.size(iWidth, iHeight); aConfig.follow ? api.follow(aConfig.follow) : api.position( aConfig.left, aConfig.top); options.init && options.init.call(api, iwin, top); options.init = null }; var config = { zIndex : _zIndex(), init : function() { api = this; DOM = api.DOM; $main = DOM.main; $content = DOM.content; iframe = api.iframe = top.document.createElement("iframe"); iframe.src = url; iframe.name = "Open" + api.config.id; iframe.style.cssText = initCss; iframe.setAttribute("frameborder", 0, 0); iframe.setAttribute("allowTransparency", true); $iframe = $(iframe); api.content().appendChild(iframe); iwin = iframe.contentWindow; load(); try { iwin.name = iframe.name; artDialog.data(iframe.name + _open, api); artDialog.data(iframe.name + _opener, window) } catch (e) { } console.log("config"); $iframe.bind("load", load) }, close : function() { $iframe.css("display", "none").unbind("load", load); if (options.close && options.close.call(this, iframe.contentWindow, top) === false) { return false } $content.removeClass("aui_state_full"); $iframe[0].src = "about:blank"; $iframe.remove(); try { artDialog.removeData(iframe.name + _open); artDialog.removeData(iframe.name + _opener) } catch (e) { } } }; if (typeof options.ok === "function") { config.ok = function() { return options.ok.call(api, iframe.contentWindow, top) } } if (typeof options.cancel === "function") { config.cancel = function() { return options.cancel.call(api, iframe.contentWindow, top) } } delete options.content; for ( var i in options) { if (config[i] === undefined) { config[i] = options[i] } } return _proxyDialog(config) }; artDialog.open.api = artDialog.data(_winName + _open); artDialog.opener = artDialog.data(_winName + _opener) || window; artDialog.open.origin = artDialog.opener; artDialog.close = function() { var api = artDialog.data(_winName + _open); api && api.close(); return false }; _top != window && $(document).bind("mousedown", function() { var api = artDialog.open.api; api && api.zIndex() }); artDialog.load = function(url, options, cache) { cache = cache || false; var opt = options || {}; var config = { zIndex : _zIndex(), init : function(here) { var api = this, aConfig = api.config; $.ajax({ url : url, success : function(content) { api.content(content); opt.init && opt.init.call(api, here) }, cache : cache }) } }; delete options.content; for ( var i in opt) { if (config[i] === undefined) { config[i] = opt[i] } } return _proxyDialog(config) }; artDialog.alert = function(content, callback) { return _proxyDialog({ id : "Alert", zIndex : _zIndex(), icon : "warning", fixed : true, lock : true, content : content, ok : true, close : callback }) }; artDialog.confirm = function(content, yes, no) { return _proxyDialog({ id : "Confirm", zIndex : _zIndex(), icon : "question", fixed : true, lock : true, opacity : 0.1, content : content, ok : function(here) { return yes.call(this, here) }, cancel : function(here) { return no && no.call(this, here) } }) }; artDialog.prompt = function(content, yes, value) { value = value || ""; var input; return _proxyDialog({ id : "Prompt", zIndex : _zIndex(), icon : "question", fixed : true, lock : true, opacity : 0.1, content : [ '
', content, "
", "
", '', "
" ] .join(""), init : function() { input = this.DOM.content.find("input")[0]; input.select(); input.focus() }, ok : function(here) { return yes && yes.call(this, input.value, here) }, cancel : true }) }; artDialog.tips = function(content, time, mark) { if (mark == 1) { return _proxyDialog({ id : "Tips", zIndex : _zIndex(), title : false, cancel : false, padding : "", fixed : true, lock : false }) .content( '
' + content + '
') .time(time || 1.5) } else { if (mark == 2) { return _proxyDialog({ id : "Tips", zIndex : _zIndex(), title : false, cancel : false, padding : "", fixed : true, lock : false }) .content( '
' + content + '
') .time(time || 1.5) } else { return _proxyDialog({ id : "Tips", zIndex : _zIndex(), title : false, padding : "", cancel : false, fixed : true, lock : false }) .content( '
' + content + '
') .time(time || 1.5) } } }; $(function() { var event = artDialog.dragEvent; if (!event) { return } var $window = $(window), $document = $(document), positionType = _isIE6 ? "absolute" : "fixed", dragEvent = event.prototype, mask = document .createElement("div"), style = mask.style; style.cssText = "display:none;position:" + positionType + ";left:0;top:0;width:100%;height:100%;" + "cursor:move;filter:alpha(opacity=0);opacity:0;background:#FFF"; document.body.appendChild(mask); dragEvent._start = dragEvent.start; dragEvent._end = dragEvent.end; dragEvent.start = function() { var DOM = artDialog.focus.DOM, main = DOM.main[0], iframe = DOM.content[0] .getElementsByTagName("iframe")[0]; dragEvent._start.apply(this, arguments); style.display = "block"; style.zIndex = artDialog.defaults.zIndex + 3; if (positionType === "absolute") { style.width = $window.width() + "px"; style.height = $window.height() + "px"; style.left = $document.scrollLeft() + "px"; style.top = $document.scrollTop() + "px" } if (iframe && main.offsetWidth * main.offsetHeight > 307200) { main.style.visibility = "hidden" } }; dragEvent.end = function() { var dialog = artDialog.focus; dragEvent._end.apply(this, arguments); style.display = "none"; if (dialog) { dialog.DOM.main[0].style.visibility = "visible" } } }) })(this.art || this.jQuery, this, this.artDialog); artDialog.notice = function(options) { var opt = options || {}, api, aConfig, hide, wrap, top, duration = 800; var config = { id : "dr_notice", left : "95%", top : "100%", lock : false, init : function(here) { api = this; aConfig = api.config; wrap = api.DOM.wrap; top = parseInt(wrap[0].style.top) - 70; hide = top + wrap[0].offsetHeight; wrap.css("top", hide + "px").animate({ top : top + "px" }, duration, function() { opt.init && opt.init.call(api, here) }) }, close : function(here) { wrap.animate({ top : hide + "px" }, duration, function() { opt.close && opt.close.call(this, here); aConfig.close = $.noop; api.close() }); return false } }; for ( var i in opt) { if (config[i] === undefined) { config[i] = opt[i] } } return artDialog(config) };