閿?*!
* lhgcore Dialog Plugin v4.2.0
* Date: 2012-04-19 10:55:11
* http://code.google.com/p/lhgdialog/
* Copyright 2009-2012 LiHuiGang
*/
;(function( $, window, undefined ){
var _ie6 = window.ActiveXObject && !window.XMLHttpRequest,
_fn = function(){},
_count = 0,
_rurl = /^url:/,
_singleton,
onKeyDown,
document = window.document,
expando = 'JDG' + (+new Date),
dialogTpl =
'
' +
'' +
'' +
' | ' +
' | ' +
' | ' +
'
' +
'' +
' | ' +
'' +
'' +
' ' +
'' +
'' +
'' +
'' +
' | ' +
' ' +
'' +
' | ' +
'' +
'' +
' | ' +
' ' +
'' +
'' +
'' +
' | ' +
' ' +
'' +
' ' +
' ' +
' | ' +
' | ' +
'
' +
'' +
' | ' +
' | ' +
' | ' +
'
' +
'' +
'
',
/*!
* _path 閼惧嘲褰囩紒鍕閺嶇绺鹃弬鍥︽lhgdialog.js閹碘偓閸︺劎娈戠紒婵嗩嚠鐠侯垰绶
* _args 閼惧嘲褰噇hgdialog.js閺傚洣娆㈤崥搴f畱url閸欏倹鏆熺紒鍕剁礉婵″偊绱發hgdialog.js?self=true&skin=aero娑擃厾娈?閸氬酣娼伴惃鍕敶鐎
*/
_args, _path = (function( script, i, me )
{
var l = script.length;
for( ; i < l; i++ )
{
me = !!document.querySelector ?
script[i].src : script[i].getAttribute('src',4);
if( me.substr(me.lastIndexOf('/')).indexOf('lhgdialog') !== -1 )
break;
}
me = me.split('?'); _args = me[1];
return me[0].substr( 0, me[0].lastIndexOf('/') + 1 );
})(document.getElementsByTagName('script'),0),
/*!
* 閼惧嘲褰噓rl閸欏倹鏆熼崐鐓庡毐閺
* @param {String}
* @return {String||null}
* @demo lhgdialog.js?skin=aero | _getArgs('skin') => 'aero'
*/
_getArgs = function( name )
{
if( _args )
{
var p = _args.split('&'), i = 0, l = p.length, a;
for( ; i < l; i++ )
{
a = p[i].split('=');
if( name === a[0] ) return a[1];
}
}
return null;
},
/*! 閸欐牜姣婇懖銈嗙壉瀵繐鎮曢敍宀勭帛鐠併倓璐 default */
_skin = _getArgs('skin') || 'default',
/*! 閼惧嘲褰 lhgdialog 閸欘垵娉曠痪褑鐨熼悽銊ф畱閺堚偓妤傛ê鐪伴惃 window 鐎电钖勯崪 document 鐎电钖 */
_doc, _top = (function(w)
{
try{
_doc = w['top'].document; // 鐠恒劌鐓檤閺冪姵娼堥梽
_doc.getElementsByTagName; // chrome 濞村繗顫嶉崳銊︽拱閸︽澘鐣ㄩ崗銊╂閸
}catch(e){
_doc = w.document; return w;
};
// 婵″倹鐏夐幐鍥х暰閸欏倹鏆焥elf娑撶皪rue閸掓瑤绗夌捄銊︻攱閺嬭泛鑴婇崙鐚寸礉閹存牔璐熷鍡樼仸闂嗗棗鍨弮鐘崇《閺勫墽銇氱粭顑跨瑏閺傜懓鍘撶槐
if( _getArgs('self') === 'true' ||
_doc.getElementsByTagName('frameset').length > 0 )
{
_doc = w.document; return w;
}
return w['top'];
})(window),
_root = _doc.documentElement, _doctype = _doc.compatMode === 'BackCompat';
_$doc = $(_doc), _$top = $(_top), _$html = $(_doc.getElementsByTagName('html')[0]);
/*! 瀵偓閸氱枠E6 CSS閼冲本娅欓崶鍓у缂傛挸鐡 */
try{
_doc.execCommand( 'BackgroundImageCache', false, true );
}catch(e){};
/*! 閸︺劍娓舵い璺虹湴妞ょ敻娼板ǎ璇插閺嶅嘲绱¢弬鍥︽ */
(function(style){
if(!style)
{
var head = _doc.getElementsByTagName('head')[0],
link = _doc.createElement('link');
link.href = _path + 'skins/' + _skin + '.css';
link.rel = 'stylesheet';
link.id = 'lhgdialoglink';
head.insertBefore(link, head.firstChild);
}
})(_doc.getElementById('lhgdialoglink'));
/*!
* IE6娑撳┅ixed閺冪姵濮堥崝銊╂饯濮濄垹鐣炬担
* 婵″倹鐏夋担鐘垫畱妞ょ敻娼伴惃鍒猼ml閸忓啰绀岀拋鎯х暰娴滃棜鍎楅弲顖氭禈閻楀洩顕幎濠咁啎缂冾喛鍎楅弲顖氭禈閻楀洨娈慶ss閸愭瑥鍩宐ody閸忓啰绀屾稉
* 婵″倹鐏夋担鐘辩瑝闂団偓鐟曚胶绮嶆禒鍫曟饯濮濄垹鐣炬担宥忕礄娑旂喎姘ㄩ弰顖炴鐏炲繑绮撮崝顭掔礆閹存牗顒濆▓鍏稿敩閻礁濂栭崫宥勭啊娴g姷娈戞い鐢告桨鐢啫鐪崣顖氱殺濮濄倖顔屾禒锝囩垳閸掔娀娅
*/
_ie6 && (function(bg){
if( _$html.css(bg) !== 'fixed' )
{
_$html.css({
zoom: 1,// 闁灝鍘ら崑璺虹毜閸戣櫣骞嘼ody閼冲本娅欓崶鍓у瀵倸鐖堕惃鍕剰閸
backgroundImage: 'url(about:blank)',
backgroundAttachment: 'fixed'
});
}
})('backgroundAttachment');
/*!----------------------------------娴犮儰绗呮稉绨俬gdialog閺嶇绺炬禒锝囩垳闁劌鍨?---------------------------------*/
var lhgdialog = function( config )
{
config = config || {};
var api, setting = lhgdialog.setting;
// 閸氬牆鑻熸妯款吇闁板秶鐤
for( var i in setting )
{
if( config[i] === undefined ) config[i] = setting[i];
}
config.id = config.id || expando + _count;
// 婵″倹鐏夌€规矮绠熸禍鍞卍閸欏倹鏆熼崚娆掔箲閸ョ偛鐡ㄩ崷銊︻劃id閻ㄥ嫮鐛ラ崣锝咁嚠鐠
api = lhgdialog.list[config.id];
if(api) return api.zindex().focus();
// 閹稿鎸抽梼鐔峰灙
config.button = config.button || [];
config.ok &&
config.button.push({
id: 'ok',
name: config.okVal,
callback: config.ok,
focus: config.focus
});
config.cancel &&
config.button.push({
id: 'cancel',
name: config.cancelVal,
callback: config.cancel
});
// zIndex閸忋劌鐪柊宥囩枂
lhgdialog.setting.zIndex = config.zIndex;
_count++;
return lhgdialog.list[config.id] = _singleton ?
_singleton._init(config) : new lhgdialog.fn._init( config );
};
lhgdialog.fn = lhgdialog.prototype =
{
constructor: lhgdialog,
_init: function( config )
{
var that = this, DOM,
content = config.content,
isIfr = _rurl.test(content);
that.opener = window;
that.config = config;
that.DOM = DOM = that.DOM || that._getDOM();
that.closed = false;
that.data = config.data;
// 閸嬪洤顩ч幓鎰仛閹冩禈閺嶅洣璐熼惇鐔肩帛鐠併倓绗夐弰鍓с仛閺堚偓鐏忓繐瀵查崪灞炬付婢堆冨閹稿鎸
if( config.icon && !isIfr )
{
config.min = false;
config.max = false;
DOM.icon[0].style.display = '';
DOM.icon[0].innerHTML = '';
}
else
DOM.icon[0].style.display = 'none';
DOM.wrap.addClass( config.skin ); // 婢舵氨姣婇懖銈呭彙鐎
DOM.rb[0].style.cursor = config.resize ? 'se-resize' : 'auto';
DOM.title[0].style.cursor = config.drag ? 'move' : 'auto';
DOM.max[0].style.display = config.max ? 'inline-block' : 'none';
DOM.min[0].style.display = config.min ? 'inline-block' : 'none';
DOM.close[0].style.display = config.cancel === false ? 'none' : 'inline-block'; //瑜版彿ancel閸欏倹鏆熸稉绡篴lse閺冨爼娈i挊蹇撳彠闂傤厽瀵滈柦
DOM.content[0].style.padding = config.padding;
that.button.apply( that, config.button );
that.title( config.title )
.content( content, true, isIfr )
.size( config.width, config.height )
.position( config.left, config.top )
.time( config.time )
[config.show?'show':'hide'](true).zindex();
config.focus && that.focus();
config.lock && that.lock();
that._ie6PngFix()._addEvent();
_singleton = null;
// 閸嬪洤顩ч崝鐘烘祰閻ㄥ嫭妲搁崡鏇犲妞ょ敻娼伴惃鍕敶鐎瑰綊銆塩onfig.init閸戣姤鏆熸导姘躬閸愬懎顔愭い闈涘鏉炶棄鐣幋鎰倵閹笛嗩攽閿涘矁绻栭柌灞芥皑娑撳秵澧界悰灞肩啊
if( !isIfr && config.init )
config.init.call( that, window );
return that;
},
/**
* 閼奉亜鐣炬稊澶嬪瘻闁
* @example
button({
name: 'login',
callback: function(){},
disabled: false,
focus: true
}, .., ..)
*/
button: function()
{
var that = this, DOM = that.DOM,
buttons = DOM.buttons[0],
focusButton = 'ui_state_highlight',
listeners = that._listeners = that._listeners || {},
ags = [].slice.call(arguments),
i = 0, item, value, id, isNewButton, button;
for( ; i < ags.length; i++ )
{
item = ags[i];
value = item.name;
id = item.id || value;
isNewButton = !listeners[id];
button = !isNewButton ? listeners[id].elem : _doc.createElement('input');
button.type = 'button';
if( !listeners[id] )
listeners[id] = {};
if( value )
button.value = value;
if( item.callback )
listeners[id].callback = item.callback;
if( item.focus )
{
that._focus && that._focus.removeClass(focusButton);
that._focus = $(button).addClass(focusButton);
that.focus();
}
button[expando + 'callback'] = id;
button.disabled = !!item.disabled;
if( isNewButton )
{
listeners[id].elem = button;
buttons.appendChild(button);
}
}
buttons.style.display = ags.length ? '' : 'none';
that._ie6SelectFix();
return that;
},
/**
* 鐠佸墽鐤嗛弽鍥暯
* @param {String, Boolean} 閺嶅洭顣介崘鍛啇. 娑撶alse閸掓瑩娈i挊蹇旂垼妫版ɑ鐖
* @return {this} 婵″倹鐏夐弮鐘插棘閺佹澘鍨潻鏂挎礀鐎电钖勯張顒冮煩
*/
title: function( text )
{
if( text === undefined ) return this;
var DOM = this.DOM,
border = DOM.border,
title = DOM.title[0];
if( text === false )
{
title.style.display = 'none';
title.innerHTML = '';
border.addClass('ui_state_tips');
}
else
{
title.style.display = '';
title.innerHTML = text;
border.removeClass('ui_state_tips');
};
return this;
},
/*!
* 鐠佸墽鐤嗛崘鍛啇
* @param {String} 閸愬懎顔 (婵″倹鐏夐崘鍛啇閸?娑擃亜鐡х粭锔胯礋閳ユΠrl:閳ユ瑥姘ㄩ崝鐘烘祰閸楁洜瀚い鐢告桨閻ㄥ嫬鍞寸€瑰綊銆?
* @param {Boolean} 閺勵垰鎯佹稉鍝勬倵婢х偛濮為惃鍕敶鐎
* @param {Boolean} 閺勵垰鎯佹担璺ㄦ暏iframe閺傜懓绱¢崝鐘烘祰閸愬懎顔愭い
* @return {this} 婵″倹鐏夐弮鐘插棘閺佹澘鍨潻鏂挎礀鐎电钖勯張顒冮煩
*/
content: function( msg, add, frm )
{
if( msg === undefined ) return this;
var 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,
loading = lhgdialog.setting.content;
// 閸嬪洤顩ч崘鍛啇娑擃厼澧?娑擃亜鐡х粭锔胯礋'url:'鐏忓崬濮炴潪鐣屾祲鐎电鐭惧鍕畱閸楁洜瀚い鐢告桨閻ㄥ嫬鍞寸€瑰綊銆
if( frm )
{
$content[0].innerHTML = loading;
that._iframe( msg.split('url:')[1] );
}
else
$content.html( msg );
// 閺傛澘顤冮崘鍛啇閸氬氦鐨熼弫缈犵秴缂
if( !add )
{
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();
return that;
},
/**
* 鐏忓搫顕
* @param {Number, String} 鐎硅棄瀹
* @param {Number, String} 妤傛ê瀹
*/
size: function( width, height )
{
var that = this, DOM = that.DOM,
wrap = DOM.wrap[0],
style = DOM.main[0].style;
wrap.style.width = 'auto';
if( typeof width === 'number' )
width = width + 'px';
if( typeof height === 'number' )
height = height + 'px';
style.width = width;
style.height = height;
if( width !== 'auto' ) // 闂冨弶顒涢張顏勭暰娑斿顔旀惔锔炬畱鐞涖劍鐗搁柆鍥у煂濞村繗顫嶉崳銊ュ礁鏉堢绔熼悾灞煎嚑缂
wrap.style.width = wrap.offsetWidth + 'px';
that._ie6SelectFix();
return that;
},
/**
* 娴e秶鐤?閻╃顕禍搴″讲鐟欏棗灏崺?
* @param {Number, String}
* @param {Number, String}
*/
position: function( left, top )
{
var that = this,
config = that.config,
wrap = that.DOM.wrap[0],
style = wrap.style,
isFixed = _ie6 ? false : config.fixed,
ie6Fixed = _ie6 && config.fixed,
docLeft = _$top.scrollLeft(),
docTop = _$top.scrollTop(),
dl = isFixed ? 0 : docLeft,
dt = isFixed ? 0 : docTop,
ww = _$top.width(),
wh = _$top.height(),
ow = wrap.offsetWidth,
oh = wrap.offsetHeight;
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;
left = Math.max(left,dl) + 'px';
}
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;
top = Math.max(top,dt) + 'px';
}
style.top = top;
}
if( left !== undefined && top !== undefined )
that._autoPositionType();
return that;
},
/*!
* 鐎规碍妞傞崗鎶芥4
* @param {Number} 閸楁洑缍呮稉铏诡潡, 閺冪姴寮弫鏉垮灟閸嬫粍顒涚拋鈩冩閸
* @param {Function} 閸忔娊妫寸粣妤€褰涢崜宥嗗⒔鐞涘瞼娈戦崶鐐剁殶閸戣姤鏆
*/
time: function( second, callback )
{
var that = this,
timer = that._timer;
timer && clearTimeout(timer);
callback && callback.call(that);
if(second)
{
that._timer = setTimeout(function(){
that._click('cancel');
}, 1000 * second);
}
return that;
},
/*! 閺勫墽銇氱€电鐦藉 */
show: function( args )
{
this.DOM.wrap[0].style.visibility = 'visible';
this.DOM.border.addClass('ui_state_visible');
if( !args && this._lock )
$('#ldg_lockmask',_doc)[0].style.display = '';
return this;
},
/*! 闂呮劘妫岀€电鐦藉 */
hide: function( args )
{
this.DOM.wrap[0].style.visibility = 'hidden';
this.DOM.border.removeClass('ui_state_visible');
if( !args && this._lock )
$('#ldg_lockmask',_doc)[0].style.display = 'none';
return this;
},
/*! 缂冾噣銆婄€电鐦藉 */
zindex: function()
{
var that = this, DOM = that.DOM,
load = that._load,
top = lhgdialog.focus,
index = lhgdialog.setting.zIndex++;
// 鐠佸墽鐤嗛崣鐘插妤傛ê瀹
DOM.wrap[0].style.zIndex = index;
// 鐠佸墽鐤嗛張鈧妯虹湴閻ㄥ嫭鐗卞
top && top.DOM.border.removeClass('ui_state_focus');
lhgdialog.focus = that;
DOM.border.addClass('ui_state_focus');
// 閹碘晛鐫嶇粣妤€褰涚純顕€銆婇崝鐔诲厴閿涘苯褰ч悽銊ユ躬iframe閺傜懓绱¢崝鐘烘祰閸愬懎顔
// 閹存牞娉曢崺鐔峰鏉炶棄鍞寸€瑰綊銆夐弮鍓佸仯缁愭褰涢崘鍛啇娑撹缍嬮柈銊ュ瀻缂冾噣銆婄粣妤€褰
if( load && load.style.zIndex )
load.style.display = 'none';
if( top && top !== that && top.iframe )
top._load.style.display = '';
return that;
},
/*! 鐠佸墽鐤嗛悞锔惧仯 */
focus: function()
{
try{
elemFocus = this._focus && this._focus[0] || this.DOM.close[0];
elemFocus && elemFocus.focus();
}catch(e){};
return this;
},
/*! 闁夸礁鐫 */
lock: function()
{
var that = this, frm,
index = lhgdialog.setting.zIndex - 1,
config = that.config,
mask = $('#ldg_lockmask',_doc)[0],
style = mask ? mask.style : '',
positionType = _ie6 ? 'absolute' : 'fixed';
if( !mask )
{
frm = '';
mask = _doc.createElement('div');
mask.id = 'ldg_lockmask';
mask.style.cssText = 'position:' + positionType + ';left:0;top:0;width:100%;height:100%;overflow:hidden;';
style = mask.style;
if( _ie6 ) mask.innerHTML = frm;
_doc.body.appendChild( mask );
}
if( positionType === 'absolute' )
{
style.width = _$top.width();
style.height = _$top.height();
style.top = _$top.scrollTop();
style.left = _$top.scrollLeft();
that._setFixed( mask );
}
style.zIndex = index;
style.display = '';
that.zindex();
that.DOM.border.addClass('ui_state_lock');
that._lock = true;
return that;
},
/*! 鐟欙綁娅庨柨浣哥潌 */
unlock: function()
{
var that = this,
config = that.config,
mask = $('#ldg_lockmask',_doc)[0];
if( mask && that._lock )
{
// 閺冪娀妾虹痪褔鏀g仦
if( config.parent && config.parent._lock )
{
var index = config.parent.DOM.wrap[0].style.zIndex;
mask.style.zIndex = parseInt(index,10) - 1;
}
else
mask.style.display = 'none';
that.DOM.border.removeClass('ui_state_lock');
}
that._lock = false;
return that;
},
/*! 閸忔娊妫寸€电鐦藉 */
close: function()
{
var that = this, DOM = that.DOM,
wrap = DOM.wrap,
list = lhgdialog.list,
fn = that.config.close;
that.time();
// 瑜版挷濞囬悽鈺rame閺傜懓绱¢崝鐘烘祰閸愬懎顔愭い鍨閻ㄥ嫬顦╅悶鍡曞敩閻
if( that.iframe )
{
if( typeof fn === 'function' && fn.call(that, that.iframe.contentWindow, window) === false )
return that;
// 闁插秷顩﹂敍渚€娓剁憰渚€鍣哥純鐢秄rame閸︽澘娼冮敍灞芥儊閸掓瑤绗呭▎鈥冲毉閻滄壆娈戠€电鐦藉鍡楁躬IE6閵?閺冪姵纭堕懕姘卞妽input
// IE閸掔娀娅巌frame閸氬函绱漣frame娴犲秶鍔ф导姘辨殌閸︺劌鍞寸€涙ü鑵戦崙铏瑰箛娑撳﹨鍫梻顕€顣介敍宀€鐤嗛幑顣檙c閺勵垱娓剁€硅妲楃憴锝呭枀閻ㄥ嫭鏌熷▔
$(that.iframe).unbind('load',that._fmLoad).attr('src',"javascript:''").remove();
DOM.content.removeClass('ui_state_full');
if( that._frmTimer ) clearTimeout(that._frmTimer);
}
else
{
if( typeof fn === 'function' && fn.call(that, window) === false )
return that;
}
that.unlock();
if( that._maxState )
{
_$html.removeClass('ui_lock_scroll');
DOM.res[0].style.display = 'none';
}
if( lhgdialog.focus === that ) lhgdialog.focus = null;
that._removeEvent();
delete list[that.config.id];
// 缁夊娅嶩TMLElement閹存牠鍣搁悽
if( _singleton )
wrap.remove();
else
{
_singleton = that;
if( that._minState )
{
DOM.main[0].style.display = '';
DOM.buttons[0].style.display = '';
DOM.dialog[0].style.width = '';
}
DOM.wrap[0].style.cssText = 'left:0;top:0;';
DOM.wrap[0].className = '';
DOM.border.removeClass('ui_state_focus');
DOM.title[0].innerHTML = '';
DOM.content.html('');
DOM.icon[0].innerHTML = '';
DOM.buttons[0].innerHTML = '';
that.hide(true)._setAbsolute();
// 濞撳懐鈹栭梽顦歨is.DOM娑斿顦绘稉瀛樻鐎电钖勯敍灞句划婢跺秴鍩岄崚婵嗩潗閻樿埖鈧緤绱濇禒銉ょ┒娴h法鏁ら崡鏇氱伐濡€崇础
for( var i in that )
{
if(that.hasOwnProperty(i) && i !== 'DOM') delete that[i];
};
}
that.closed = true;
return that;
},
/*! 閺堚偓婢堆冨缁愭褰 */
max: function()
{
var that = this, maxSize,
DOM = that.DOM,
wrapStyle = DOM.wrap[0].style,
mainStyle = DOM.main[0].style,
rbStyle = DOM.rb[0].style,
titleStyle = DOM.title[0].style,
config = that.config,
top = _$top.scrollTop(),
left = _$top.scrollLeft();
if( !that._maxState )
{
_$html.addClass('ui_lock_scroll');
if( that._minState )
that.min();
// 鐎涙ê鍋嶉張鈧径褍瀵茬粣妤€褰涢崜宥囨畱閻樿埖鈧
that._or = {
t: wrapStyle.top,
l: wrapStyle.left,
w: mainStyle.width,
h: mainStyle.height,
d: config.drag,
r: config.resize,
rc: rbStyle.cursor,
tc: titleStyle.cursor
};
wrapStyle.top = top + 'px';
wrapStyle.left = left + 'px';
maxSize = that._maxSize();
that.size( maxSize.w, maxSize.h )._setAbsolute();
if( _ie6 && _doctype )
wrapStyle.width = _$top.width() + 'px';
config.drag = false;
config.resize = false;
rbStyle.cursor = 'auto';
titleStyle.cursor = 'auto';
DOM.max[0].style.display = 'none';
DOM.res[0].style.display = 'inline-block';
that._maxState = true;
}
else
{
_$html.removeClass('ui_lock_scroll');
wrapStyle.top = that._or.t;
wrapStyle.left = that._or.l;
that.size( that._or.w, that._or.h )._autoPositionType();
config.drag = that._or.d;
config.resize = that._or.r;
rbStyle.cursor = that._or.rc;
titleStyle.cursor = that._or.tc;
DOM.res[0].style.display = 'none';
DOM.max[0].style.display = 'inline-block';
delete that._or;
that._maxState = false;
}
return that;
},
/*! 閺堚偓鐏忓繐瀵茬粣妤€褰 */
min: function()
{
var that = this,
DOM = that.DOM,
main = DOM.main[0].style,
buttons = DOM.buttons[0].style,
dialog = DOM.dialog[0].style,
rb = DOM.rb[0].style.cursor,
resize = that.config.resize;
if( !that._minState )
{
if( that._maxState )
that.max();
that._minRz = {rzs:resize,btn:buttons.display};
main.display = 'none';
buttons.display = 'none';
dialog.width = main.width;
rb.cursor = 'auto';
resize = false;
that._minState = true;
}
else
{
main.display = '';
buttons.display = that._minRz.btn;
dialog.width = '';
resize = that._minRz;
rb.cursor = that._minRz.rzs ? 'se-resize' : 'auto';
delete that._minRz;
that._minState = false;
}
that._ie6SelectFix();
return that;
},
/*!
* 閼惧嘲褰囬幐鍥х暰id閻ㄥ嫮鐛ラ崣锝咁嚠鐠炩剝鍨ㄧ粣妤€褰涙稉鐠眆rame閸旂姾娴囬惃鍕敶鐎瑰綊銆夐惃鍓媔ndow鐎电钖
* @param {String} 閹稿洤鐣鹃惃鍒琩
* @param {String} 閺勵垰鎯佹潻鏂挎礀閻ㄥ嫪璐熼幐鍥х暰id閻ㄥ嫮鐛ラ崣锝咁嚠鐠
* 閻劍鏆熺€?閺夈儴銆冪粈铏规埂閿涘苯顩ч弸婊€绗夐崘娆愬灗閸愭瑥鍙剧€瑰啩璐焒alse
* @return {Object|null}
*/
get: function( id, object )
{
if( lhgdialog.list[id] )
{
if( object === 1 )
return lhgdialog.list[id];
else
return lhgdialog.list[id].content || null;
}
return null;
},
/**
* 閸掗攱鏌婇幋鏍儲鏉烆剚瀵氱€规岸銆夐棃
* @param {Object, 閹稿洤鐣炬い鐢告桨閻ㄥ墜indow鐎电钖剗
* @param {String, 鐟曚浇鐑︽潪顒€鍩岄惃鍕€夐棃銏犳勾閸р偓}
*/
reload: function( win, url, callback )
{
win = win || window;
try{
win.location.href = url ? url : win.location.href;
}
catch(e){ // 鐠恒劌鐓
url = this.iframe.src;
$(this.iframe).attr('src', url);
};
callback && callback.call( this );
return this;
},
/*!
* 鐠佸墽鐤唅frame閺傜懓绱¢崝鐘烘祰閸愬懎顔愭い
*/
_iframe: function( url )
{
var that = this, iframe, $iframe, iwin, $idoc, $ibody, iWidth, iHeight,
$content = that.DOM.content,
config = that.config,
loading = that._load = $('.ui_loading',$content[0])[0],
initCss = 'position:absolute;left:-9999em;border:none 0;background:transparent',
loadCss = 'width:100%;height:100%;border:none 0;';
// 閺勵垰鎯侀崗浣筋啅缂傛挸鐡? 姒涙顓籺rue
if( config.cache === false )
{
var ts = (new Date).getTime(),
ret = url.replace(/([?&])_=[^&]*/, '$1_=' + ts );
url = ret + ((ret === url) ? (/\?/.test(url) ? '&' : '?') + '_=' + ts : '');
}
iframe = that.iframe = _doc.createElement('iframe');
iframe.name = config.id;
iframe.style.cssText = initCss;
iframe.setAttribute('frameborder', 0, 0);
$iframe = $(iframe);
$content[0].appendChild( iframe );
// 瀵ゆ儼绻滈崝鐘烘祰iframe閻ㄥ墕rc鐏炵偞鈧嶇礉IE6娑撳绗夊鎯扮箿閸旂姾娴囨导姘毉閻滄澘濮炴潪鍊熺箻鎼达附娼惃鍑歎G
that._frmTimer = setTimeout(function(){
$iframe.attr('src', url);
}, 1);
// iframe娑擃參銆夐棃銏犲鏉炶棄鐣幋鎰倵閹笛嗩攽閻ㄥ嫬鍤遍弫
var load = that._fmLoad = function()
{
$content.addClass('ui_state_full');
// 婢х偛宸辩粣妤€褰涚純顕€銆婇崝鐔诲厴閿涘frame閺傜懓绱¢崝鐘烘祰閸愬懎顔愰幋鏍硶閸╃喎濮炴潪钘夊敶鐎瑰綊銆夐弮鍓佸仯缁愭褰涢崘鍛啇闁劌鍨庣純顕€銆婄粣妤€褰
// 闁俺绻冩担璺ㄦ暏闁插秶鐤唋oading鐏炲倹娼垫导姗€娉ら惃鍕暚閹存劖顒濋崝鐔诲厴閿涘苯婀猣ocus閺傝纭舵稉顓熸箒濮濄倕濮涢懗鐣屾畱閻╃鍙ф禒锝囩垳
var DOM = that.DOM, ltSize,
lt = DOM.lt[0].offsetHeight,
main = DOM.main[0].style;
loading.style.cssText = 'display:none;position:absolute;background:#FFF;opacity:0;' +
'filter:alpha(opacity=0);z-index:1;width:' + main.width + ';height:' + main.height + ';';
// 濮濄倝鍎撮崚鍡曞敩閻胶绮ㄩ弶鐕傜礉閸︺劍瀚嬮崝銊︽暭閸欐ê銇囩亸蹇曟畱_dragEvent.onmove閺傝纭舵稉顓$箷閺堝顒濋崝鐔诲厴閻ㄥ嫮娴夐崗鍏呭敩閻
try{
iwin = that.content = iframe.contentWindow; // 鐎规矮绠熺粣妤€褰涚€电钖刢ontent鐏炵偞鈧傝礋閸愬懎顔愭い鐢垫畱window鐎电钖
$idoc = $(iwin.document);
$ibody = $(iwin.document.body);
}catch(e){// 鐠恒劌鐓
iframe.style.cssText = loadCss;
return;
}
// 閼惧嘲褰噄frame閸愬懘鍎寸亸鍝勵嚟
iWidth = config.width === 'auto'
? $idoc.width() + (_ie6 ? 0 : parseInt($ibody.css('marginLeft')))
: config.width;
iHeight = config.height === 'auto'
? $idoc.height() : config.height;
// 闁倸绨瞚frame鐏忓搫顕
setTimeout(function(){
iframe.style.cssText = loadCss;
},0);// setTimeout: 闂冨弶顒汭E6~7鐎电鐦藉鍡樼壉瀵繑瑕嗛弻鎾崇磽鐢
// 缁愭褰涢張鈧径褍瀵查弮鎯扮箹闁插奔绗夐悽銊ュ晙鐠侊紕鐣荤粣妤€褰涢惃鍕槀鐎电鎷版担宥囩枂娴滃棴绱濇俊鍌涚亯閸愬秷顓哥粻妤冪崶閸欙絼绱伴崙铏瑰箛闁挎瑤缍
if( !that._maxState )
{
that.size( iWidth, iHeight )
.position( config.left, config.top );
}
// 闂堢偠娉曢崺鐔告鏉╂顩︾€电oading鐏炲倿鍣哥拋鎯с亣鐏忓骏绱濈憰浣风瑝鐎硅棄鎷版惔锕傚厴娑?auto'
loading.style.width = main.width;
loading.style.height = main.height;
config.init && config.init.call( that, iwin, _top );
};
// 缂佹垵鐣緄frame閸忓啰绀宎pi鐏炵偞鈧傝礋缁愭褰涢懛顏囬煩鐎电钖勯敍灞芥躬閸愬懎顔愭い鍏歌厬濮濄倕鐫橀幀褍绶㈤柌宥堫洣
that.iframe.api = that;
$iframe.bind( 'load', load );
},
/*! 閼惧嘲褰囩粣妤€褰涢崗鍐 */
_getDOM: function()
{
var wrap = _doc.createElement('div'),
body = _doc.body;
wrap.style.cssText = 'position:absolute;left:0;top:0;visibility:hidden;';
wrap.innerHTML = dialogTpl;
var name, i = 0,
DOM = { wrap: $(wrap) },
els = wrap.getElementsByTagName('*'),
len = els.length;
for( ; i < len; i ++ )
{
name = els[i].className.split('ui_')[1];
if(name) DOM[name] = $(els[i]);
};
body.insertBefore(wrap, body.firstChild);
return DOM;
},
/*!
* px娑?閸楁洑缍呮潪顒佸床閹存劖鏆熼崐 (閻ф儳鍨庡В鏂垮礋娴e秵瀵滈悡褎娓舵径褍鈧吋宕茬粻?
* 閸忔湹绮惃鍕礋娴e秷绻戦崶鐐插斧閸
*/
_toNumber: function( thisValue, maxValue )
{
if( typeof thisValue === 'number' )
return thisValue;
if( thisValue.indexOf('%') !== -1 )
thisValue = parseInt(maxValue * thisValue.split('%')[0] / 100);
return thisValue;
},
/*! 鐠侊紕鐣婚張鈧径褍瀵茬粣妤€褰涢弮鍓佺崶閸欙絿娈戠亸鍝勵嚟 */
_maxSize: function()
{
var that = this, DOM = that.DOM,
wrap = DOM.wrap[0],
main = DOM.main[0],
maxWidth, maxHeight;
maxWidth = _$top.width() - wrap.offsetWidth + main.offsetWidth;
maxHeight = _$top.height() - wrap.offsetHeight + main.offsetHeight;
return { w: maxWidth, h: maxHeight };
},
/*! 鐠併姡E6 CSS閺€顖涘瘮PNG閼冲本娅 */
_ie6PngFix: function()
{
if( _ie6 )
{
var i = 0, elem, png, pngPath, runtimeStyle,
path = lhgdialog.setting.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='scale')";
};
}
}
return this;
},
/*! 瀵搫鍩楃憰鍡欐磰IE6娑撳濯洪幒褌娆 */
_ie6SelectFix: _ie6 ? 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(_doc.createElement('iframe'));
$wrap[expando] = iframe;
iframe.src = "javascript:''";
iframe.style.cssText = 'position:absolute;z-index:-1;left:0;top:0;'
+ 'filter:alpha(opacity=0);width:' + width + ';height:' + height;
}
} : _fn,
/*! 閼奉亜濮╅崚鍥ㄥ床鐎规矮缍呯猾璇茬€ */
_autoPositionType: function()
{
this[this.config.fixed ? '_setFixed' : '_setAbsolute']();
},
/*! 鐠佸墽鐤嗛棃娆愵剾鐎规矮缍 */
_setFixed: function( el )
{
var style = el ? el.style : this.DOM.wrap[0].style;
if( _ie6 )
{
var sLeft = _$top.scrollLeft(),
sTop = _$top.scrollTop(),
left = parseInt(style.left) - sLeft,
top = parseInt(style.top) - sTop,
txt = _doctype ? 'this.ownerDocument.body' :
'this.ownerDocument.documentElement';
this._setAbsolute();
style.setExpression( 'left', txt + '.scrollLeft +' + left );
style.setExpression( 'top', txt + '.scrollTop +' + top );
}
else
style.position = 'fixed';
},
/*! 鐠佸墽鐤嗙紒婵嗩嚠鐎规矮缍 */
_setAbsolute: function()
{
var style = this.DOM.wrap[0].style;
if(_ie6)
{
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()
{
var test = !!window.ActiveXObject,
newSize,
that = this,
tw = _$top.width(),
tt = _$top.height(),
oldSize = that._winSize || tw * tt,
oldWidth = that._lockDocW || tw,
left = that._left,
top = that._top;
if(test)
{
//IE6娑撳浼勭純鈺併亣鐏忓繑鏁奸崣
if( that._lock && _ie6 )
$('#ldg_lockmask',_doc).css({ width:tw + 'px', height:tt + 17 + 'px' });
newWidth = that._lockDocW = tw;
//IE6~7 window.onresize bug
newSize = that._winSize = tw * tt;
if( oldSize === newSize ) return;
};
if( that._maxState )
{
var size = that._maxSize();
that.size( size.w, size.h );
}
//IE6~8娴兼艾鍤悳鐗堟付婢堆冨鏉╂ê甯崥搴g崶閸欙綁鍣搁弬鏉跨暰娴e稄绱濋柨浣哥暰濠婃艾濮╅弶鈥虫躬IE娑撳姘ㄦ导姘承曢崣鎲唀size娴滃娆UG
if( test && Math.abs(oldWidth - newWidth) === 17 ) return;
if( left || top )
that.position( left, top );
},
_addEvent: function()
{
var resizeTimer,
that = this,
config = that.config,
DOM = that.DOM;
// 缁愭褰涚拫鍐Ν娴滃娆
that._winResize = function()
{
resizeTimer && clearTimeout(resizeTimer);
resizeTimer = setTimeout(function()
{
that._reset();
}, 140);
};
_$top.bind('resize', that._winResize);
// 閻╂垵鎯夐悙鐟板毊
DOM.wrap.bind('click', function(event){
var target = event.target, callbackID;
if( target.disabled ) return false; // IE BUG
if( target === DOM.close[0] )
{
that._click('cancel');
return false;
}
else if( target === DOM.max[0] || target === DOM.res[0] || target === DOM.max_b[0]
|| target === DOM.res_b[0] || target === DOM.res_t[0] )
{
that.max();
return false;
}
else if( target === DOM.min[0] || target === DOM.min_b[0] )
{
that.min();
return false;
}
else
{
callbackID = target[expando + 'callback'];
callbackID && that._click(callbackID);
}
}).bind('mousedown',function(event){
that.zindex();
var target = event.target;
if( config.drag !== false && target === DOM.title[0]
|| config.resize !== false && target === DOM.rb[0] )
{
_use(event);
return false;
}
});
// 閸欏苯鍤弽鍥暯閺嶅繑娓舵径褍瀵叉潻妯肩崶閸欙絼绨ㄦ禒
if( config.max )
DOM.title.bind('dblclick',function(){ that.max(); return false; });
},
/*! 閸楁瓕娴囨禍瀣╂娴狅絿鎮 */
_removeEvent: function()
{
var that = this,
DOM = that.DOM;
DOM.wrap.unbind();
DOM.title.unbind();
_$top.unbind('resize', that._winResize);
}
};
lhgdialog.fn._init.prototype = lhgdialog.fn;
/*! 濮濄倕顕挒锛勬暏閺夈儱鐡ㄩ崒銊ㄥ箯瀵版鍔嶉悙鍦畱缁愭褰涚€电钖勭€圭偘绶 */
lhgdialog.focus = null;
/*! 鐎涙ê鍋嶇粣妤€褰涚€圭偘绶ラ惃鍕嚠鐠炩€冲灙鐞 */
lhgdialog.list = {};
/*!
* 閸忋劌鐪箛顐e祹闁
* 閻㈠彉绨捄銊︻攱閺嬭埖妞傛禍瀣╂閺勵垳绮︾€规艾鍩岄張鈧い璺虹湴妞ょ敻娼伴敍灞惧娴犮儱缍嬭ぐ鎾冲妞ょ敻娼伴崡姝屾祰閺冭泛绻€妞ゆ槒顩﹂梽銈囆╁銈勭皑娴
* 閹碘偓娴犮儱绻€妞ょ本nbind濮濄倓绨ㄦ禒鍓佺拨鐎规氨娈戦崙鑺ユ殶閿涘本澧嶆禒銉ㄧ箹闁插矁顩︾紒娆戠拨鐎规氨娈戞禍瀣╂鐎规矮绠熸稉顏勫毐閺
* 鏉╂瑦鐗遍崷銊ョ秼閸撳秹銆夐棃銏犲祻鏉炶姤妞傜亸鍗炲讲娴犮儳些濮濄倓绨ㄦ禒鍓佺拨鐎规氨娈戦惄绋跨安閸戣姤鏆熼敍灞肩瑝閼板奔绗夎ぐ鍗炴惙妞よ泛鐪版い鐢告桨濮濄倓绨ㄦ禒鍓佺拨鐎规氨娈戦崗璺虹暊閸戣姤鏆
*/
onKeyDown = function(event)
{
var target = event.target,
api = lhgdialog.focus,
keyCode = event.keyCode;
if( !api || !api.config.esc || api.config.cancel === false ) return;
keyCode === 27 && api._click(api.config.cancelVal);
};
_$doc.bind('keydown',onKeyDown);
/*!
* 濡楀棙鐏︽い鐢告桨閸楁瓕娴囬崜宥呭彠闂傤厽澧嶉張澶屸敍鐡掑﹦娈戠€电鐦藉
* 閸氬本妞傜粔濠氭珟閹锋牕濮╃仦鍌氭嫲闁喚鍍电仦
*/
_top != window && $(window).bind('unload',function()
{
var list = lhgdialog.list;
for( var i in list )
{
if(list[i])
list[i].close();
}
_singleton && _singleton.DOM.wrap.remove();
_$doc.unbind('keydown',onKeyDown);
$('#ldg_lockmask',_doc)[0] && $('#ldg_lockmask',_doc).remove();
$('#ldg_dragmask',_doc)[0] && $('#ldg_dragmask',_doc).remove();
});
/*! lhgdialog 閻ㄥ嫬鍙忕仦鈧妯款吇闁板秶鐤 */
lhgdialog.setting =
{
content: 'loading...
',
title: '\u89C6\u7A97 ', // 閺嶅洭顣?姒涙顓?鐟欏棛鐛?
button: null, // 閼奉亜鐣炬稊澶嬪瘻闁
ok: null, // 绾喖鐣鹃幐澶愭尦閸ョ偠鐨熼崙鑺ユ殶
cancel: null, // 閸欐牗绉烽幐澶愭尦閸ョ偠鐨熼崙鑺ユ殶
init: null, // 鐎电鐦藉鍡楀灥婵瀵查崥搴㈠⒔鐞涘瞼娈戦崙鑺ユ殶
close: null, // 鐎电鐦藉鍡楀彠闂傤厼澧犻幍褑顢戦惃鍕毐閺
okVal: '\u786E\u5B9A', // 绾喖鐣鹃幐澶愭尦閺傚洦婀?姒涙顓?绾喖鐣?
cancelVal: '\u53D6\u6D88', // 閸欐牗绉烽幐澶愭尦閺傚洦婀?姒涙顓?閸欐牗绉?
skin: '', // 婢舵氨姣婇懖銈呭彙鐎涙﹢顣╅悾娆愬复閸
esc: true, // 閺勵垰鎯侀弨顖涘瘮Esc闁款喖鍙ч梻
show: true, // 閸掓繂顫愰崠鏍ф倵閺勵垰鎯侀弰鍓с仛鐎电鐦藉
width: 'auto', // 閸愬懎顔愮€硅棄瀹
height: 'auto', // 閸愬懎顔愭妯哄
icon: null, // 濞戝牊浼呴崶鐐垼閸氬秶袨
path: _path, // lhgdialog鐠侯垰绶
lock: false, // 閺勵垰鎯侀柨浣哥潌
focus: true, // 缁愭褰涢弰顖氭儊閼奉亜濮╅懢宄板絿閻掞妇鍋
parent: null, // 閹垫挸绱戠€涙劗鐛ラ崣锝囨畱閻栧墎鐛ラ崣锝咁嚠鐠炩槄绱濇稉鏄忣洣閻劋绨径姘湴闁夸礁鐫嗙粣妤€褰
padding: '10px', // 閸愬懎顔愭稉搴ょ珶閻e苯锝為崗鍛扮獩缁
fixed: false, // 閺勵垰鎯侀棃娆愵剾鐎规矮缍
left: '50%', // X鏉炴潙娼楅弽
top: '38.2%', // Y鏉炴潙娼楅弽
max: true, // 閺勵垰鎯侀弰鍓с仛閺堚偓婢堆冨閹稿鎸
min: true, // 閺勵垰鎯侀弰鍓с仛閺堚偓鐏忓繐瀵查幐澶愭尦
zIndex: 1976, // 鐎电鐦藉鍡楀綌閸旂娀鐝惔锕€鈧?闁插秷顩﹂敍姘劃閸婇棿绗夐懗鍊熺Т鏉╁洦绁荤憴鍫濇珤閺堚偓婢堆囨閸?
resize: true, // 閺勵垰鎯侀崗浣筋啅閻劍鍩涚拫鍐Ν鐏忓搫顕
drag: true, // 閺勵垰鎯侀崗浣筋啅閻劍鍩涢幏鏍уЗ娴e秶鐤
cache: true, // 閺勵垰鎯佺紓鎾崇摠缁愭褰涢崘鍛啇妞
data: null, // 娴肩娀鈧帒鎮囩粔宥嗘殶閹
extendDrag: false // 婢х偛濮瀕hgdialog閹锋牗瀚挎担鎾荤崣
};
/*!
*------------------------------------------------
* 鐎电鐦藉鍡樐侀崸?閹锋牗瀚块弨顖涘瘮閿涘牆褰查柅澶婎樆缂冾喗膩閸ф绱
*------------------------------------------------
*/
var _use, _isSetCapture = 'setCapture' in _root,
_isLosecapture = 'onlosecapture' in _root;
lhgdialog.dragEvent =
{
onstart: _fn,
start: function(event)
{
var that = lhgdialog.dragEvent;
_$doc
.bind( 'mousemove', that.move )
.bind( 'mouseup', that.end );
that._sClientX = event.clientX;
that._sClientY = event.clientY;
that.onstart( event.clientX, event.clientY );
return false;
},
onmove: _fn,
move: function(event)
{
var that = lhgdialog.dragEvent;
that.onmove(
event.clientX - that._sClientX,
event.clientY - that._sClientY
);
return false;
},
onend: _fn,
end: function(event)
{
var that = lhgdialog.dragEvent;
_$doc
.unbind('mousemove', that.move)
.unbind('mouseup', that.end);
that.onend( event.clientX, event.clientY );
return false;
}
};
_use = function(event)
{
var limit, startWidth, startHeight, startLeft, startTop, isResize,
api = lhgdialog.focus,
config = api.config,
DOM = api.DOM,
wrap = DOM.wrap[0],
title = DOM.title,
main = DOM.main[0],
_dragEvent = lhgdialog.dragEvent,
// 濞撳懘娅庨弬鍥ㄦ拱闁瀚
clsSelect = 'getSelection' in _top ?
function(){
_top.getSelection().removeAllRanges();
}:function(){
try{_doc.selection.empty();}catch(e){};
};
// 鐎电鐦藉鍡楀櫙婢跺洦瀚嬮崝
_dragEvent.onstart = function( x, y )
{
if( isResize )
{
startWidth = main.offsetWidth;
startHeight = main.offsetHeight;
}
else
{
startLeft = wrap.offsetLeft;
startTop = wrap.offsetTop;
};
_$doc.bind( 'dblclick', _dragEvent.end );
!_ie6 && _isLosecapture
? title.bind('losecapture',_dragEvent.end )
: _$top.bind('blur',_dragEvent.end);
_isSetCapture && title[0].setCapture();
DOM.border.addClass('ui_state_drag');
api.focus();
};
// 鐎电鐦藉鍡樺珛閸斻劏绻樼悰灞艰厬
_dragEvent.onmove = function( x, y )
{
if( isResize )
{
var wrapStyle = wrap.style,
style = main.style,
width = x + startWidth,
height = y + startHeight;
wrapStyle.width = 'auto';
config.width = style.width = Math.max(0,width) + 'px';
wrapStyle.width = wrap.offsetWidth + 'px';
config.height = style.height = Math.max(0,height) + 'px';
//api._ie6SelectFix();
// 娴h法鏁oading鐏炲倻鐤嗘い鍓佺崶閸欙絾妞傜粣妤€褰涙径褍鐨弨鐟板綁閻╃绨瞝oading鐏炲倸銇囩亸蹇庣瘍瀵版鏁奸崣
api._load && $(api._load).css({width:style.width, height:style.height});
}
else
{
var style = wrap.style,
left = x + startLeft,
top = y + startTop;
config.left = Math.max( limit.minX, Math.min(limit.maxX,left) );
config.top = Math.max( limit.minY, Math.min(limit.maxY,top) );
style.left = config.left + 'px';
style.top = config.top + 'px';
}
clsSelect();
};
// 鐎电鐦藉鍡樺珛閸斻劎绮ㄩ弶
_dragEvent.onend = function( x, y )
{
_$doc.unbind('dblclick',_dragEvent.end);
!_ie6 && _isLosecapture
? title.unbind('losecapture',_dragEvent.end)
: _$top.unbind('blur',_dragEvent.end);
_isSetCapture && title[0].releaseCapture();
_ie6 && api._autoPositionType();
DOM.border.removeClass('ui_state_drag');
};
isResize = event.target === DOM.rb[0] ? true : false;
limit = (function(fixed)
{
var ow = wrap.offsetWidth,
// 閸氭垳绗呴幏鏍уЗ閺冩湹绗夐懗钘夌殺閺嶅洭顣介弽蹇斿珛閸戝搫褰茬憴鍡楀隘閸
oh = title[0].offsetHeight || 20,
ww = _$top.width(),
wh = _$top.height(),
dl = fixed ? 0 : _$top.scrollLeft(),
dt = fixed ? 0 : _$top.scrollTop();
// 閸ф劖鐖i張鈧径褍鈧ジ妾洪崚?閸︺劌褰茬憴鍡楀隘閸╃喎鍞?
maxX = ww - ow + dl;
maxY = wh - oh + dt;
return {
minX: dl,
minY: dt,
maxX: maxX,
maxY: maxY
};
})(wrap.style.position === 'fixed');
_dragEvent.start(event);
};
/*!
* 妞ょ敻娼癉OM閸旂姾娴囩€瑰本鍨氶幍褑顢戦惃鍕敩閻
*/
$(function(){
// 鐟欙箑褰傚ù蹇氼潔閸c劑顣╅崗鍫㈢处鐎涙鍎楅弲顖氭禈閻
setTimeout(function()
{
if(_count) return;
lhgdialog({left:'-9999em',time:9,fixed:false,lock:false,focus:false});
},150);
// 婢х偛宸眑hgdialog閹锋牗瀚挎担鎾荤崣閿涘牆褰查柅澶婎樆缂冾喗膩閸ф绱濇俊鍌欑瑝闂団偓鐟曚礁褰查崚鐘绘珟閿
// 闂冨弶顒涙Η鐘崇垼閽€钘夊弳iframe鐎佃壈鍤ф稉宥嗙ウ閻e拑绱濈€电绉存径褍顕拠婵囶攱閹锋牕濮╂导妯哄
lhgdialog.setting.extendDrag &&
(function(dragEvent){
var mask = _doc.createElement('div'),
style = mask.style,
positionType = _ie6 ? 'absolute' : 'fixed';
mask.id = 'ldg_dragmask';
style.cssText = 'display:none;position:' + positionType + ';left:0;top:0;width:100%;height:100%;'
+ 'cursor:move;filter:alpha(opacity=0);opacity:0;background:#FFF;pointer-events:none;';
_doc.body.appendChild(mask);
dragEvent._start = dragEvent.start;
dragEvent._end = dragEvent.end;
dragEvent.start = function()
{
var api = lhgdialog.focus,
main = api.DOM.main[0],
iframe = api.iframe;
dragEvent._start.apply(this, arguments);
style.display = 'block';
style.zIndex = lhgdialog.setting.zIndex + 3;
if(positionType === 'absolute')
{
style.width = _$top.width() + 'px';
style.height = _$top.height() + 'px';
style.left = _$doc.scrollLeft() + 'px';
style.top = _$doc.scrollTop() + 'px';
};
if( iframe && main.offsetWidth * main.offsetHeight > 307200 )
main.style.visibility = 'hidden';
};
dragEvent.end = function()
{
var api = lhgdialog.focus;
dragEvent._end.apply(this, arguments);
style.display = 'none';
if(api) api.DOM.main[0].style.visibility = 'visible';
};
})(lhgdialog.dragEvent);
});
/*! 娴h法鏁Q閺傜懓绱$拫鍐暏缁愭褰 */
$.fn.dialog = function()
{
var config = arguments;
this.bind('click',function(){ lhgdialog.apply(this,config); return false; });
return this;
};
window.lhgdialog = $.dialog = lhgdialog;
})( this.jQuery || this.lhgcore, this );
/*!
*------------------------------------------------
* 鐎电鐦藉鍡楀従鐎瑰啫濮涢懗鑺ュ⒖鐏炴洘膩閸ф绱欓崣顖炩偓澶婎樆缂冾喗膩閸ф绱
*------------------------------------------------
*/
;(function( $, lhgdialog, undefined ){
var _zIndex = function()
{
return lhgdialog.setting.zIndex;
};
/**
* 鐠€锕€鎲
* @param {String} 濞戝牊浼呴崘鍛啇
*/
lhgdialog.alert = function( content, callback, parent )
{
return lhgdialog({
title: '鐠€锕€鎲?,
id: 'Alert',
zIndex: _zIndex(),
icon: 'alert.gif',
fixed: true,
lock: true,
content: content,
ok: true,
resize: false,
close: callback,
parent: parent || null
});
};
/**
* 绾喛顓
* @param {String} 濞戝牊浼呴崘鍛啇
* @param {Function} 绾喖鐣鹃幐澶愭尦閸ョ偠鐨熼崙鑺ユ殶
* @param {Function} 閸欐牗绉烽幐澶愭尦閸ョ偠鐨熼崙鑺ユ殶
*/
lhgdialog.confirm = function( content, yes, no, parent )
{
return lhgdialog({
title: '绾喛顓?,
id: 'confirm.gif',
zIndex: _zIndex(),
icon: 'confirm.gif',
fixed: true,
lock: true,
content: content,
resize: false,
parent: parent || null,
ok: function(here){
return yes.call(this, here);
},
cancel: function(here){
return no && no.call(this, here);
}
});
};
/**
* 閹绘劙妫
* @param {String} 閹绘劙妫堕崘鍛啇
* @param {Function} 閸ョ偠鐨熼崙鑺ユ殶. 閹恒儲鏁归崣鍌涙殶閿涙俺绶崗銉モ偓
* @param {String} 姒涙顓婚崐
*/
lhgdialog.prompt = function( content, yes, value, parent )
{
value = value || '';
var input;
return lhgdialog({
title: '閹绘劙妫?,
id: 'Prompt',
zIndex: _zIndex(),
icon: 'prompt.gif',
fixed: true,
lock: true,
parent: parent || null,
content: [
'',
content,
'
',
'',
'',
'
'
].join(''),
init: function(){
input = this.DOM.content[0].getElementsByTagName('input')[0];
input.select();
input.focus();
},
ok: function(here){
return yes && yes.call(this, input.value, here);
},
cancel: true
});
};
/**
* 閻厽娈忛幓鎰仛
* @param {String} 閹绘劗銇氶崘鍛啇
* @param {Number} 閺勫墽銇氶弮鍫曟? (姒涙顓?.5缁?
* @param {String} 閹绘劗銇氶崶鐐垼 (濞夈劍鍓扮憰浣稿閹碘晛鐫嶉崥?
* @param {Function} 閹绘劗銇氶崗鎶芥4閺冭埖澧界悰宀€娈戦崶鐐剁殶閸戣姤鏆
*/
lhgdialog.tips = function( content, time, icon, callback )
{
var reIcon = icon ? function(){
this.DOM.icon[0].innerHTML = '';
this.DOM.icon[0].style.display = '';
if( callback ) this.config.close = callback;
} : function(){
this.DOM.icon[0].style.display = 'none';
if( callback ) this.config.close = callback;
};
return lhgdialog({
id: 'Tips',
zIndex: _zIndex(),
title: false,
cancel: false,
fixed: true,
lock: false,
resize: false
})
.content(content)
.time(time || 1.5, reIcon);
};
})( this.jQuery||this.lhgcore, this.lhgdialog );