code stringlengths 1 2.08M | language stringclasses 1 value |
|---|---|
if ($.fn.pagination){
$.fn.pagination.defaults.beforePageText = 'Strana';
$.fn.pagination.defaults.afterPageText = 'z {pages}';
$.fn.pagination.defaults.displayMsg = 'Zobrazuji {from} do {to} z {celkové} položky';
}
if ($.fn.datagrid){
$.fn.datagrid.defaults.loadMsg = 'Zpracování, čekejte prosím ...';
}
if ($.messager){
$.messager.defaults.ok = 'Ok';
$.messager.defaults.cancel = 'Zrušit';
}
if ($.fn.validatebox){
$.fn.validatebox.defaults.missingMessage = 'Toto pole je vyžadováno.';
$.fn.validatebox.defaults.rules.email.message = 'Zadejte prosím platnou e-mailovou adresu.';
$.fn.validatebox.defaults.rules.url.message = 'Zadejte prosím platnou adresu URL.';
$.fn.validatebox.defaults.rules.length.message = 'Prosím, zadejte hodnotu mezi {0} a {1}.';
}
if ($.fn.numberbox){
$.fn.numberbox.defaults.missingMessage = 'Toto pole je vyžadováno.';
}
if ($.fn.combobox){
$.fn.combobox.defaults.missingMessage = 'Toto pole je vyžadováno.';
}
if ($.fn.combotree){
$.fn.combotree.defaults.missingMessage = 'Toto pole je vyžadováno.';
}
if ($.fn.calendar){
$.fn.calendar.defaults.weeks = ['S','M','T','W','T','F','S'];
$.fn.calendar.defaults.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
}
if ($.fn.datebox){
$.fn.datebox.defaults.currentText = 'Dnes';
$.fn.datebox.defaults.closeText = 'Zavřít';
$.fn.datebox.defaults.missingMessage = 'Toto pole je vyžadováno.';
}
| JavaScript |
if ($.fn.pagination){
$.fn.pagination.defaults.beforePageText = 'Page';
$.fn.pagination.defaults.afterPageText = 'de {pages}';
$.fn.pagination.defaults.displayMsg = 'Affichage de {from} et {to} au {total} des articles';
}
if ($.fn.datagrid){
$.fn.datagrid.defaults.loadMsg = "Traitement, s'il vous plaît patienter ...";
}
if ($.messager){
$.messager.defaults.ok = 'Ok';
$.messager.defaults.cancel = 'Annuler';
}
if ($.fn.validatebox){
$.fn.validatebox.defaults.missingMessage = 'Ce champ est obligatoire.';
$.fn.validatebox.defaults.rules.email.message = "S'il vous plaît entrer une adresse email valide.";
$.fn.validatebox.defaults.rules.url.message = "S'il vous plaît entrer une URL valide.";
$.fn.validatebox.defaults.rules.length.message = "S'il vous plaît entrez une valeur comprise entre {0} et {1}.";
}
if ($.fn.numberbox){
$.fn.numberbox.defaults.missingMessage = 'Ce champ est obligatoire.';
}
if ($.fn.combobox){
$.fn.combobox.defaults.missingMessage = 'Ce champ est obligatoire.';
}
if ($.fn.combotree){
$.fn.combotree.defaults.missingMessage = 'Ce champ est obligatoire.';
}
if ($.fn.calendar){
$.fn.calendar.defaults.weeks = ['S','M','T','W','T','F','S'];
$.fn.calendar.defaults.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
}
if ($.fn.datebox){
$.fn.datebox.defaults.currentText = "Aujourd'hui";
$.fn.datebox.defaults.closeText = 'Fermer';
$.fn.datebox.defaults.missingMessage = 'Ce champ est obligatoire.';
}
| JavaScript |
if ($.fn.pagination){
$.fn.pagination.defaults.beforePageText = '第';
$.fn.pagination.defaults.afterPageText = '共{pages}页';
$.fn.pagination.defaults.displayMsg = '显示{from}到{to},共{total}记录';
}
if ($.fn.datagrid){
$.fn.datagrid.defaults.loadMsg = '正在处理,请稍待。。。';
}
if ($.messager){
$.messager.defaults.ok = '确定';
$.messager.defaults.cancel = '取消';
}
if ($.fn.validatebox){
$.fn.validatebox.defaults.missingMessage = '该输入项为必输项';
$.fn.validatebox.defaults.rules.email.message = '请输入有效的电子邮件地址';
$.fn.validatebox.defaults.rules.url.message = '请输入有效的URL地址';
$.fn.validatebox.defaults.rules.length.message = '输入内容长度必须介于{0}和{1}之间';
}
if ($.fn.numberbox){
$.fn.numberbox.defaults.missingMessage = '该输入项为必输项';
}
if ($.fn.combobox){
$.fn.combobox.defaults.missingMessage = '该输入项为必输项';
}
if ($.fn.combotree){
$.fn.combotree.defaults.missingMessage = '该输入项为必输项';
}
if ($.fn.calendar){
$.fn.calendar.defaults.weeks = ['日','一','二','三','四','五','六'];
$.fn.calendar.defaults.months = ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'];
}
if ($.fn.datebox){
$.fn.datebox.defaults.currentText = '今天';
$.fn.datebox.defaults.closeText = '关闭';
$.fn.datebox.defaults.missingMessage = '该输入项为必输项';
}
| JavaScript |
if ($.fn.pagination){
$.fn.pagination.defaults.beforePageText = 'Seite';
$.fn.pagination.defaults.afterPageText = 'von {pages}';
$.fn.pagination.defaults.displayMsg = 'Angezeigte {from} zu {to} von {total} Artikel';
}
if ($.fn.datagrid){
$.fn.datagrid.defaults.loadMsg = 'Processing, bitte warten ...';
}
if ($.messager){
$.messager.defaults.ok = 'OK';
$.messager.defaults.cancel = 'Stornieren';
}
if ($.fn.validatebox){
$.fn.validatebox.defaults.missingMessage = 'Dieses Feld ist obligatorisch.';
$.fn.validatebox.defaults.rules.email.message = 'Bitte geben Sie eine gültige E-Mail-Adresse.';
$.fn.validatebox.defaults.rules.url.message = 'Bitte geben Sie eine gültige URL.';
$.fn.validatebox.defaults.rules.length.message = 'Bitte geben Sie einen Wert zwischen {0} und {1}.';
}
if ($.fn.numberbox){
$.fn.numberbox.defaults.missingMessage = 'Dieses Feld ist obligatorisch.';
}
if ($.fn.combobox){
$.fn.combobox.defaults.missingMessage = 'Dieses Feld ist obligatorisch.';
}
if ($.fn.combotree){
$.fn.combotree.defaults.missingMessage = 'Dieses Feld ist obligatorisch.';
}
if ($.fn.calendar){
$.fn.calendar.defaults.weeks = ['S','M','T','W','T','F','S'];
$.fn.calendar.defaults.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
}
if ($.fn.datebox){
$.fn.datebox.defaults.currentText = 'Heute';
$.fn.datebox.defaults.closeText = 'Schließen';
$.fn.datebox.defaults.missingMessage = 'Dieses Feld ist obligatorisch.';
}
| JavaScript |
if ($.fn.pagination){
$.fn.pagination.defaults.beforePageText = 'Страница';
$.fn.pagination.defaults.afterPageText = 'от {pages}';
$.fn.pagination.defaults.displayMsg = 'Показани {from} за {to} от {total} продукти';
}
if ($.fn.datagrid){
$.fn.datagrid.defaults.loadMsg = 'Обработка, моля изчакайте ...';
}
if ($.messager){
$.messager.defaults.ok = 'Добре';
$.messager.defaults.cancel = 'Задрасквам';
}
if ($.fn.validatebox){
$.fn.validatebox.defaults.missingMessage = 'Това поле е задължително.';
$.fn.validatebox.defaults.rules.email.message = 'Моля, въведете валиден имейл адрес.';
$.fn.validatebox.defaults.rules.url.message = 'Моля въведете валиден URL.';
$.fn.validatebox.defaults.rules.length.message = 'Моля, въведете стойност между {0} и {1}.';
}
if ($.fn.numberbox){
$.fn.numberbox.defaults.missingMessage = 'Това поле е задължително.';
}
if ($.fn.combobox){
$.fn.combobox.defaults.missingMessage = 'Това поле е задължително.';
}
if ($.fn.combotree){
$.fn.combotree.defaults.missingMessage = 'Това поле е задължително.';
}
if ($.fn.calendar){
$.fn.calendar.defaults.weeks = ['S','M','T','W','T','F','S'];
$.fn.calendar.defaults.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
}
if ($.fn.datebox){
$.fn.datebox.defaults.currentText = 'Днес';
$.fn.datebox.defaults.closeText = 'Близо';
$.fn.datebox.defaults.missingMessage = 'Това поле е задължително.';
}
| JavaScript |
if ($.fn.pagination){
$.fn.pagination.defaults.beforePageText = 'Pagina';
$.fn.pagination.defaults.afterPageText = 'van {pages}';
$.fn.pagination.defaults.displayMsg = 'Tonen van {from} tot {to} van de {totale} items';
}
if ($.fn.datagrid){
$.fn.datagrid.defaults.loadMsg = 'Verwerking, even geduld ...';
}
if ($.messager){
$.messager.defaults.ok = 'Okee';
$.messager.defaults.cancel = 'Annuleren';
}
if ($.fn.validatebox){
$.fn.validatebox.defaults.missingMessage = 'Dit veld is verplicht.';
$.fn.validatebox.defaults.rules.email.message = 'Geef een geldig e-mailadres.';
$.fn.validatebox.defaults.rules.url.message = 'Vul een geldige URL.';
$.fn.validatebox.defaults.rules.length.message = 'Voer een waarde tussen {0} en {1}.';
}
if ($.fn.numberbox){
$.fn.numberbox.defaults.missingMessage = 'Dit veld is verplicht.';
}
if ($.fn.combobox){
$.fn.combobox.defaults.missingMessage = 'Dit veld is verplicht.';
}
if ($.fn.combotree){
$.fn.combotree.defaults.missingMessage = 'Dit veld is verplicht.';
}
if ($.fn.calendar){
$.fn.calendar.defaults.weeks = ['S','M','T','W','T','F','S'];
$.fn.calendar.defaults.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
}
if ($.fn.datebox){
$.fn.datebox.defaults.currentText = 'Vandaag';
$.fn.datebox.defaults.closeText = 'Dicht';
$.fn.datebox.defaults.missingMessage = 'Dit veld is verplicht.';
}
| JavaScript |
if ($.fn.pagination){
$.fn.pagination.defaults.beforePageText = '第';
$.fn.pagination.defaults.afterPageText = '共{pages}頁';
$.fn.pagination.defaults.displayMsg = '顯示{from}到{to},共{total}記錄';
}
if ($.fn.datagrid){
$.fn.datagrid.defaults.loadMsg = '正在處理,請稍待。。。';
}
if ($.messager){
$.messager.defaults.ok = '確定';
$.messager.defaults.cancel = '取消';
}
if ($.fn.validatebox){
$.fn.validatebox.defaults.missingMessage = '該輸入項為必輸項';
$.fn.validatebox.defaults.rules.email.message = '請輸入有效的電子郵件地址';
$.fn.validatebox.defaults.rules.url.message = '請輸入有效的URL地址';
$.fn.validatebox.defaults.rules.length.message = '輸入內容長度必須介於{0}和{1}之間';
}
if ($.fn.numberbox){
$.fn.numberbox.defaults.missingMessage = '該輸入項為必輸項';
}
if ($.fn.combobox){
$.fn.combobox.defaults.missingMessage = '該輸入項為必輸項';
}
if ($.fn.combotree){
$.fn.combotree.defaults.missingMessage = '該輸入項為必輸項';
}
if ($.fn.calendar){
$.fn.calendar.defaults.weeks = ['日','一','二','三','四','五','六'];
$.fn.calendar.defaults.months = ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'];
}
if ($.fn.datebox){
$.fn.datebox.defaults.currentText = '今天';
$.fn.datebox.defaults.closeText = '關閉';
$.fn.datebox.defaults.missingMessage = '該輸入項為必輸項';
}
| JavaScript |
if ($.fn.pagination){
$.fn.pagination.defaults.beforePageText = 'Page';
$.fn.pagination.defaults.afterPageText = 'of {pages}';
$.fn.pagination.defaults.displayMsg = 'Displaying {from} to {to} of {total} items';
}
if ($.fn.datagrid){
$.fn.datagrid.defaults.loadMsg = 'Processing, please wait ...';
}
if ($.messager){
$.messager.defaults.ok = 'Ok';
$.messager.defaults.cancel = 'Cancel';
}
if ($.fn.validatebox){
$.fn.validatebox.defaults.missingMessage = 'This field is required.';
$.fn.validatebox.defaults.rules.email.message = 'Please enter a valid email address.';
$.fn.validatebox.defaults.rules.url.message = 'Please enter a valid URL.';
$.fn.validatebox.defaults.rules.length.message = 'Please enter a value between {0} and {1}.';
}
if ($.fn.numberbox){
$.fn.numberbox.defaults.missingMessage = 'This field is required.';
}
if ($.fn.combobox){
$.fn.combobox.defaults.missingMessage = 'This field is required.';
}
if ($.fn.combotree){
$.fn.combotree.defaults.missingMessage = 'This field is required.';
}
if ($.fn.calendar){
$.fn.calendar.defaults.weeks = ['S','M','T','W','T','F','S'];
$.fn.calendar.defaults.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
}
if ($.fn.datebox){
$.fn.datebox.defaults.currentText = 'Today';
$.fn.datebox.defaults.closeText = 'Close';
$.fn.datebox.defaults.missingMessage = 'This field is required.';
}
| JavaScript |
if ($.fn.pagination){
$.fn.pagination.defaults.beforePageText = 'Pàgina';
$.fn.pagination.defaults.afterPageText = 'de {pages}';
$.fn.pagination.defaults.displayMsg = "Veient {from} a {to} de {total} d'articles";
}
if ($.fn.datagrid){
$.fn.datagrid.defaults.loadMsg = 'Elaboració, si us plau esperi ...';
}
if ($.messager){
$.messager.defaults.ok = 'Ok';
$.messager.defaults.cancel = 'Cancel';
}
if ($.fn.validatebox){
$.fn.validatebox.defaults.missingMessage = 'Aquest camp és obligatori.';
$.fn.validatebox.defaults.rules.email.message = 'Introduïu una adreça de correu electrònic vàlida.';
$.fn.validatebox.defaults.rules.url.message = 'Si us plau, introduïu un URL vàlida.';
$.fn.validatebox.defaults.rules.length.message = 'Si us plau, introduïu un valor entre {0} i {1}.';
}
if ($.fn.numberbox){
$.fn.numberbox.defaults.missingMessage = 'Aquest camp és obligatori.';
}
if ($.fn.combobox){
$.fn.combobox.defaults.missingMessage = 'Aquest camp és obligatori.';
}
if ($.fn.combotree){
$.fn.combotree.defaults.missingMessage = 'Aquest camp és obligatori.';
}
if ($.fn.calendar){
$.fn.calendar.defaults.weeks = ['S','M','T','W','T','F','S'];
$.fn.calendar.defaults.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
}
if ($.fn.datebox){
$.fn.datebox.defaults.currentText = 'Avui';
$.fn.datebox.defaults.closeText = 'Tancar';
$.fn.datebox.defaults.missingMessage = 'Aquest camp és obligatori.';
}
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$("<span class=\"spinner\">"+"<span class=\"spinner-arrow\">"+"<span class=\"spinner-arrow-up\"></span>"+"<span class=\"spinner-arrow-down\"></span>"+"</span>"+"</span>").insertAfter(_2);
$(_2).addClass("spinner-text").prependTo(_3);
return _3;
};
function _4(_5,_6){
var _7=$.data(_5,"spinner").options;
var _8=$.data(_5,"spinner").spinner;
if(_6){
_7.width=_6;
}
var _9=$("<div style=\"display:none\"></div>").insertBefore(_8);
_8.appendTo("body");
if(isNaN(_7.width)){
_7.width=$(_5).outerWidth();
}
var _a=_8.find(".spinner-arrow").outerWidth();
var _6=_7.width-_a;
if($.boxModel==true){
_6-=_8.outerWidth()-_8.width();
}
$(_5).width(_6);
_8.insertAfter(_9);
_9.remove();
};
function _b(_c){
var _d=$.data(_c,"spinner").options;
var _e=$.data(_c,"spinner").spinner;
_e.find(".spinner-arrow-up,.spinner-arrow-down").unbind(".spinner");
if(!_d.disabled){
_e.find(".spinner-arrow-up").bind("mouseenter.spinner",function(){
$(this).addClass("spinner-arrow-hover");
}).bind("mouseleave.spinner",function(){
$(this).removeClass("spinner-arrow-hover");
}).bind("click.spinner",function(){
_d.spin.call(_c,false);
_d.onSpinUp.call(_c);
$(_c).validatebox("validate");
});
_e.find(".spinner-arrow-down").bind("mouseenter.spinner",function(){
$(this).addClass("spinner-arrow-hover");
}).bind("mouseleave.spinner",function(){
$(this).removeClass("spinner-arrow-hover");
}).bind("click.spinner",function(){
_d.spin.call(_c,true);
_d.onSpinDown.call(_c);
$(_c).validatebox("validate");
});
}
};
function _f(_10,_11){
var _12=$.data(_10,"spinner").options;
if(_11){
_12.disabled=true;
$(_10).attr("disabled",true);
}else{
_12.disabled=false;
$(_10).removeAttr("disabled");
}
};
$.fn.spinner=function(_13,_14){
if(typeof _13=="string"){
var _15=$.fn.spinner.methods[_13];
if(_15){
return _15(this,_14);
}else{
return this.validatebox(_13,_14);
}
}
_13=_13||{};
return this.each(function(){
var _16=$.data(this,"spinner");
if(_16){
$.extend(_16.options,_13);
}else{
_16=$.data(this,"spinner",{options:$.extend({},$.fn.spinner.defaults,$.fn.spinner.parseOptions(this),_13),spinner:_1(this)});
$(this).removeAttr("disabled");
}
$(this).val(_16.options.value);
$(this).attr("readonly",!_16.options.editable);
_f(this,_16.options.disabled);
_4(this);
$(this).validatebox(_16.options);
_b(this);
});
};
$.fn.spinner.methods={options:function(jq){
var _17=$.data(jq[0],"spinner").options;
return $.extend(_17,{value:jq.val()});
},destroy:function(jq){
return jq.each(function(){
var _18=$.data(this,"spinner").spinner;
$(this).validatebox("destroy");
_18.remove();
});
},resize:function(jq,_19){
return jq.each(function(){
_4(this,_19);
});
},enable:function(jq){
return jq.each(function(){
_f(this,false);
_b(this);
});
},disable:function(jq){
return jq.each(function(){
_f(this,true);
_b(this);
});
},getValue:function(jq){
return jq.val();
},setValue:function(jq,_1a){
return jq.each(function(){
var _1b=$.data(this,"spinner").options;
_1b.value=_1a;
$(this).val(_1a);
});
},clear:function(jq){
return jq.each(function(){
var _1c=$.data(this,"spinner").options;
_1c.value="";
$(this).val("");
});
}};
$.fn.spinner.parseOptions=function(_1d){
var t=$(_1d);
return $.extend({},$.fn.validatebox.parseOptions(_1d),{width:(parseInt(_1d.style.width)||undefined),value:(t.val()||undefined),min:t.attr("min"),max:t.attr("max"),increment:(parseFloat(t.attr("increment"))||undefined),editable:(t.attr("editable")?t.attr("editable")=="true":undefined),disabled:(t.attr("disabled")?true:undefined)});
};
$.fn.spinner.defaults=$.extend({},$.fn.validatebox.defaults,{width:"auto",value:"",min:null,max:null,increment:1,editable:true,disabled:false,spin:function(_1e){
},onSpinUp:function(){
},onSpinDown:function(){
}});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
$(_2).appendTo("body");
$(_2).addClass("menu-top");
var _3=[];
_4($(_2));
var _5=null;
for(var i=0;i<_3.length;i++){
var _6=_3[i];
_7(_6);
_6.find(">div.menu-item").each(function(){
_8($(this));
});
_6.find("div.menu-item").click(function(){
if(!this.submenu){
_17(_2);
var _9=$(this).attr("href");
if(_9){
location.href=_9;
}
}
var _a=$(_2).menu("getItem",this);
$.data(_2,"menu").options.onClick.call(_2,_a);
});
_6.bind("mouseenter",function(){
if(_5){
clearTimeout(_5);
_5=null;
}
}).bind("mouseleave",function(){
_5=setTimeout(function(){
_17(_2);
},100);
});
}
function _4(_b){
_3.push(_b);
_b.find(">div").each(function(){
var _c=$(this);
var _d=_c.find(">div");
if(_d.length){
_d.insertAfter(_2);
_c[0].submenu=_d;
_4(_d);
}
});
};
function _8(_e){
_e.hover(function(){
_e.siblings().each(function(){
if(this.submenu){
_1a(this.submenu);
}
$(this).removeClass("menu-active");
});
_e.addClass("menu-active");
var _f=_e[0].submenu;
if(_f){
var _10=_e.offset().left+_e.outerWidth()-2;
if(_10+_f.outerWidth()>$(window).width()){
_10=_e.offset().left-_f.outerWidth()+2;
}
_1e(_f,{left:_10,top:_e.offset().top-3});
}
},function(e){
_e.removeClass("menu-active");
var _11=_e[0].submenu;
if(_11){
if(e.pageX>=parseInt(_11.css("left"))){
_e.addClass("menu-active");
}else{
_1a(_11);
}
}else{
_e.removeClass("menu-active");
}
});
_e.unbind(".menu").bind("mousedown.menu",function(){
return false;
});
};
function _7(_12){
_12.addClass("menu").find(">div").each(function(){
var _13=$(this);
if(_13.hasClass("menu-sep")){
_13.html(" ");
}else{
var _14=_13.addClass("menu-item").html();
_13.empty().append($("<div class=\"menu-text\"></div>").html(_14));
var _15=_13.attr("iconCls")||_13.attr("icon");
if(_15){
$("<div class=\"menu-icon\"></div>").addClass(_15).appendTo(_13);
}
if(_13[0].submenu){
$("<div class=\"menu-rightarrow\"></div>").appendTo(_13);
}
if($.boxModel==true){
var _16=_13.height();
_13.height(_16-(_13.outerHeight()-_13.height()));
}
}
});
_12.hide();
};
};
function _17(_18){
var _19=$.data(_18,"menu").options;
_1a($(_18));
$(document).unbind(".menu");
_19.onHide.call(_18);
return false;
};
function _1b(_1c,pos){
var _1d=$.data(_1c,"menu").options;
if(pos){
_1d.left=pos.left;
_1d.top=pos.top;
}
_1e($(_1c),{left:_1d.left,top:_1d.top},function(){
$(document).unbind(".menu").bind("mousedown.menu",function(){
_17(_1c);
$(document).unbind(".menu");
return false;
});
_1d.onShow.call(_1c);
});
};
function _1e(_1f,pos,_20){
if(!_1f){
return;
}
if(pos){
_1f.css(pos);
}
_1f.show(1,function(){
if(!_1f[0].shadow){
_1f[0].shadow=$("<div class=\"menu-shadow\"></div>").insertAfter(_1f);
}
_1f[0].shadow.css({display:"block",zIndex:$.fn.menu.defaults.zIndex++,left:_1f.css("left"),top:_1f.css("top"),width:_1f.outerWidth(),height:_1f.outerHeight()});
_1f.css("z-index",$.fn.menu.defaults.zIndex++);
if(_20){
_20();
}
});
};
function _1a(_21){
if(!_21){
return;
}
_22(_21);
_21.find("div.menu-item").each(function(){
if(this.submenu){
_1a(this.submenu);
}
$(this).removeClass("menu-active");
});
function _22(m){
if(m[0].shadow){
m[0].shadow.hide();
}
m.hide();
};
};
$.fn.menu=function(_23,_24){
if(typeof _23=="string"){
return $.fn.menu.methods[_23](this,_24);
}
_23=_23||{};
return this.each(function(){
var _25=$.data(this,"menu");
if(_25){
$.extend(_25.options,_23);
}else{
_25=$.data(this,"menu",{options:$.extend({},$.fn.menu.defaults,_23)});
_1(this);
}
$(this).css({left:_25.options.left,top:_25.options.top});
});
};
$.fn.menu.methods={show:function(jq,pos){
return jq.each(function(){
_1b(this,pos);
});
},hide:function(jq){
return jq.each(function(){
_17(this);
});
},setText:function(jq,_26){
return jq.each(function(){
$(_26.target).children("div.menu-text").html(_26.text);
});
},setIcon:function(jq,_27){
return jq.each(function(){
var _28=$(this).menu("getItem",_27.target);
if(_28.iconCls){
$(_28.target).children("div.menu-icon").removeClass(_28.iconCls).addClass(_27.iconCls);
}else{
$("<div class=\"menu-icon\"></div>").addClass(_27.iconCls).appendTo(_27.target);
}
});
},getItem:function(jq,_29){
var _2a={target:_29,text:$(_29).children("div.menu-text").html()};
var _2b=$(_29).children("div.menu-icon");
if(_2b.length){
var cc=[];
var aa=_2b.attr("class").split(" ");
for(var i=0;i<aa.length;i++){
if(aa[i]!="menu-icon"){
cc.push(aa[i]);
}
}
_2a.iconCls=cc.join(" ");
}
return _2a;
}};
$.fn.menu.defaults={zIndex:110000,left:0,top:0,onShow:function(){
},onHide:function(){
},onClick:function(_2c){
}};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"combogrid").options;
var _4=$.data(_2,"combogrid").grid;
$(_2).addClass("combogrid-f");
$(_2).combo(_3);
var _5=$(_2).combo("panel");
if(!_4){
_4=$("<table></table>").appendTo(_5);
$.data(_2,"combogrid").grid=_4;
}
_4.datagrid($.extend({},_3,{border:false,fit:true,singleSelect:(!_3.multiple),onLoadSuccess:function(_6){
var _7=$.data(_2,"combogrid").remainText;
var _8=$(_2).combo("getValues");
_1c(_2,_8,_7);
$.data(_2,"combogrid").remainText=false;
_3.onLoadSuccess.apply(this,arguments);
},onClickRow:_9,onSelect:function(_a,_b){
_c();
_3.onSelect.call(this,_a,_b);
},onUnselect:function(_d,_e){
_c();
_3.onUnselect.call(this,_d,_e);
},onSelectAll:function(_f){
_c();
_3.onSelectAll.call(this,_f);
},onUnselectAll:function(_10){
_c();
_3.onUnselectAll.call(this,_10);
}}));
function _9(_11,row){
$.data(_2,"combogrid").remainText=false;
_c();
if(!_3.multiple){
$(_2).combo("hidePanel");
}
_3.onClickRow.call(this,_11,row);
};
function _c(){
var _12=$.data(_2,"combogrid").remainText;
var _13=_4.datagrid("getSelections");
var vv=[],ss=[];
for(var i=0;i<_13.length;i++){
vv.push(_13[i][_3.idField]);
ss.push(_13[i][_3.textField]);
}
$(_2).combo("setValues",vv);
if(!vv.length&&!_3.multiple){
$(_2).combo("setValues",[""]);
}
if(!_12){
$(_2).combo("setText",ss.join(_3.separator));
}
};
};
function _14(_15,_16){
var _17=$.data(_15,"combogrid").options;
var _18=$.data(_15,"combogrid").grid;
var _19=_18.datagrid("getRows").length;
$.data(_15,"combogrid").remainText=false;
var _1a;
var _1b=_18.datagrid("getSelections");
if(_1b.length){
_1a=_18.datagrid("getRowIndex",_1b[_1b.length-1][_17.idField]);
_1a+=_16;
if(_1a<0){
_1a=0;
}
if(_1a>=_19){
_1a=_19-1;
}
}else{
if(_16>0){
_1a=0;
}else{
if(_16<0){
_1a=_19-1;
}else{
_1a=-1;
}
}
}
if(_1a>=0){
_18.datagrid("clearSelections");
_18.datagrid("selectRow",_1a);
}
};
function _1c(_1d,_1e,_1f){
var _20=$.data(_1d,"combogrid").options;
var _21=$.data(_1d,"combogrid").grid;
var _22=_21.datagrid("getRows");
var ss=[];
_21.datagrid("clearSelections");
for(var i=0;i<_1e.length;i++){
var _23=_21.datagrid("getRowIndex",_1e[i]);
if(_23>=0){
_21.datagrid("selectRow",_23);
ss.push(_22[_23][_20.textField]);
}else{
ss.push(_1e[i]);
}
}
$(_1d).combo("setValues",_1e);
if(!_1f){
$(_1d).combo("setText",ss.join(_20.separator));
}
};
function _24(_25,q){
var _26=$.data(_25,"combogrid").options;
var _27=$.data(_25,"combogrid").grid;
$.data(_25,"combogrid").remainText=true;
if(_26.multiple&&!q){
_1c(_25,[],true);
}else{
_1c(_25,[q],true);
}
if(_26.mode=="remote"){
_27.datagrid("reload",{q:q});
}else{
if(!q){
return;
}
var _28=_27.datagrid("getRows");
for(var i=0;i<_28.length;i++){
if(_26.filter.call(_25,q,_28[i])){
_27.datagrid("clearSelections");
_27.datagrid("selectRow",i);
return;
}
}
}
};
$.fn.combogrid=function(_29,_2a){
if(typeof _29=="string"){
var _2b=$.fn.combogrid.methods[_29];
if(_2b){
return _2b(this,_2a);
}else{
return $.fn.combo.methods[_29](this,_2a);
}
}
_29=_29||{};
return this.each(function(){
var _2c=$.data(this,"combogrid");
if(_2c){
$.extend(_2c.options,_29);
}else{
_2c=$.data(this,"combogrid",{options:$.extend({},$.fn.combogrid.defaults,$.fn.combogrid.parseOptions(this),_29)});
}
_1(this);
});
};
$.fn.combogrid.methods={options:function(jq){
return $.data(jq[0],"combogrid").options;
},grid:function(jq){
return $.data(jq[0],"combogrid").grid;
},setValues:function(jq,_2d){
return jq.each(function(){
_1c(this,_2d);
});
},setValue:function(jq,_2e){
return jq.each(function(){
_1c(this,[_2e]);
});
},clear:function(jq){
return jq.each(function(){
$(this).combogrid("grid").datagrid("clearSelections");
$(this).combo("clear");
});
}};
$.fn.combogrid.parseOptions=function(_2f){
var t=$(_2f);
return $.extend({},$.fn.combo.parseOptions(_2f),$.fn.datagrid.parseOptions(_2f),{idField:(t.attr("idField")||undefined),textField:(t.attr("textField")||undefined),mode:t.attr("mode")});
};
$.fn.combogrid.defaults=$.extend({},$.fn.combo.defaults,$.fn.datagrid.defaults,{loadMsg:null,idField:null,textField:null,mode:"local",keyHandler:{up:function(){
_14(this,-1);
},down:function(){
_14(this,1);
},enter:function(){
_14(this,0);
$(this).combo("hidePanel");
},query:function(q){
_24(this,q);
}},filter:function(q,row){
var _30=$(this).combogrid("options");
return row[_30.textField].indexOf(q)==0;
}});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
_2.each(function(){
$(this).remove();
if($.browser.msie){
this.outerHTML="";
}
});
};
function _3(_4,_5){
var _6=$.data(_4,"panel").options;
var _7=$.data(_4,"panel").panel;
var _8=_7.children("div.panel-header");
var _9=_7.children("div.panel-body");
if(_5){
if(_5.width){
_6.width=_5.width;
}
if(_5.height){
_6.height=_5.height;
}
if(_5.left!=null){
_6.left=_5.left;
}
if(_5.top!=null){
_6.top=_5.top;
}
}
if(_6.fit==true){
var p=_7.parent();
_6.width=p.width();
_6.height=p.height();
}
_7.css({left:_6.left,top:_6.top});
if(!isNaN(_6.width)){
if($.boxModel==true){
_7.width(_6.width-(_7.outerWidth()-_7.width()));
}else{
_7.width(_6.width);
}
}else{
_7.width("auto");
}
if($.boxModel==true){
_8.width(_7.width()-(_8.outerWidth()-_8.width()));
_9.width(_7.width()-(_9.outerWidth()-_9.width()));
}else{
_8.width(_7.width());
_9.width(_7.width());
}
if(!isNaN(_6.height)){
if($.boxModel==true){
_7.height(_6.height-(_7.outerHeight()-_7.height()));
_9.height(_7.height()-_8.outerHeight()-(_9.outerHeight()-_9.height()));
}else{
_7.height(_6.height);
_9.height(_7.height()-_8.outerHeight());
}
}else{
_9.height("auto");
}
_7.css("height",null);
_6.onResize.apply(_4,[_6.width,_6.height]);
_7.find(">div.panel-body>div").triggerHandler("_resize");
};
function _a(_b,_c){
var _d=$.data(_b,"panel").options;
var _e=$.data(_b,"panel").panel;
if(_c){
if(_c.left!=null){
_d.left=_c.left;
}
if(_c.top!=null){
_d.top=_c.top;
}
}
_e.css({left:_d.left,top:_d.top});
_d.onMove.apply(_b,[_d.left,_d.top]);
};
function _f(_10){
var _11=$(_10).addClass("panel-body").wrap("<div class=\"panel\"></div>").parent();
_11.bind("_resize",function(){
var _12=$.data(_10,"panel").options;
if(_12.fit==true){
_3(_10);
}
return false;
});
return _11;
};
function _13(_14){
var _15=$.data(_14,"panel").options;
var _16=$.data(_14,"panel").panel;
_1(_16.find(">div.panel-header"));
if(_15.title&&!_15.noheader){
var _17=$("<div class=\"panel-header\"><div class=\"panel-title\">"+_15.title+"</div></div>").prependTo(_16);
if(_15.iconCls){
_17.find(".panel-title").addClass("panel-with-icon");
$("<div class=\"panel-icon\"></div>").addClass(_15.iconCls).appendTo(_17);
}
var _18=$("<div class=\"panel-tool\"></div>").appendTo(_17);
if(_15.closable){
$("<div class=\"panel-tool-close\"></div>").appendTo(_18).bind("click",_19);
}
if(_15.maximizable){
$("<div class=\"panel-tool-max\"></div>").appendTo(_18).bind("click",_1a);
}
if(_15.minimizable){
$("<div class=\"panel-tool-min\"></div>").appendTo(_18).bind("click",_1b);
}
if(_15.collapsible){
$("<div class=\"panel-tool-collapse\"></div>").appendTo(_18).bind("click",_1c);
}
if(_15.tools){
for(var i=_15.tools.length-1;i>=0;i--){
var t=$("<div></div>").addClass(_15.tools[i].iconCls).appendTo(_18);
if(_15.tools[i].handler){
t.bind("click",eval(_15.tools[i].handler));
}
}
}
_18.find("div").hover(function(){
$(this).addClass("panel-tool-over");
},function(){
$(this).removeClass("panel-tool-over");
});
_16.find(">div.panel-body").removeClass("panel-body-noheader");
}else{
_16.find(">div.panel-body").addClass("panel-body-noheader");
}
function _1c(){
if(_15.collapsed==true){
_38(_14,true);
}else{
_28(_14,true);
}
return false;
};
function _1b(){
_43(_14);
return false;
};
function _1a(){
if(_15.maximized==true){
_47(_14);
}else{
_27(_14);
}
return false;
};
function _19(){
_1d(_14);
return false;
};
};
function _1e(_1f){
var _20=$.data(_1f,"panel");
if(_20.options.href&&(!_20.isLoaded||!_20.options.cache)){
_20.isLoaded=false;
var _21=_20.panel.find(">div.panel-body");
_21.html($("<div class=\"panel-loading\"></div>").html(_20.options.loadingMessage));
_21.load(_20.options.href,null,function(){
if($.parser){
$.parser.parse(_21);
}
_20.options.onLoad.apply(_1f,arguments);
_20.isLoaded=true;
});
}
};
function _22(_23,_24){
var _25=$.data(_23,"panel").options;
var _26=$.data(_23,"panel").panel;
if(_24!=true){
if(_25.onBeforeOpen.call(_23)==false){
return;
}
}
_26.show();
_25.closed=false;
_25.minimized=false;
_25.onOpen.call(_23);
if(_25.maximized==true){
_25.maximized=false;
_27(_23);
}
if(_25.collapsed==true){
_25.collapsed=false;
_28(_23);
}
if(!_25.collapsed){
_1e(_23);
}
};
function _1d(_29,_2a){
var _2b=$.data(_29,"panel").options;
var _2c=$.data(_29,"panel").panel;
if(_2a!=true){
if(_2b.onBeforeClose.call(_29)==false){
return;
}
}
_2c.hide();
_2b.closed=true;
_2b.onClose.call(_29);
};
function _2d(_2e,_2f){
var _30=$.data(_2e,"panel").options;
var _31=$.data(_2e,"panel").panel;
if(_2f!=true){
if(_30.onBeforeDestroy.call(_2e)==false){
return;
}
}
_1(_31);
_30.onDestroy.call(_2e);
};
function _28(_32,_33){
var _34=$.data(_32,"panel").options;
var _35=$.data(_32,"panel").panel;
var _36=_35.children("div.panel-body");
var _37=_35.children("div.panel-header").find("div.panel-tool-collapse");
if(_34.collapsed==true){
return;
}
_36.stop(true,true);
if(_34.onBeforeCollapse.call(_32)==false){
return;
}
_37.addClass("panel-tool-expand");
if(_33==true){
_36.slideUp("normal",function(){
_34.collapsed=true;
_34.onCollapse.call(_32);
});
}else{
_36.hide();
_34.collapsed=true;
_34.onCollapse.call(_32);
}
};
function _38(_39,_3a){
var _3b=$.data(_39,"panel").options;
var _3c=$.data(_39,"panel").panel;
var _3d=_3c.children("div.panel-body");
var _3e=_3c.children("div.panel-header").find("div.panel-tool-collapse");
if(_3b.collapsed==false){
return;
}
_3d.stop(true,true);
if(_3b.onBeforeExpand.call(_39)==false){
return;
}
_3e.removeClass("panel-tool-expand");
if(_3a==true){
_3d.slideDown("normal",function(){
_3b.collapsed=false;
_3b.onExpand.call(_39);
_1e(_39);
});
}else{
_3d.show();
_3b.collapsed=false;
_3b.onExpand.call(_39);
_1e(_39);
}
};
function _27(_3f){
var _40=$.data(_3f,"panel").options;
var _41=$.data(_3f,"panel").panel;
var _42=_41.children("div.panel-header").find("div.panel-tool-max");
if(_40.maximized==true){
return;
}
_42.addClass("panel-tool-restore");
$.data(_3f,"panel").original={width:_40.width,height:_40.height,left:_40.left,top:_40.top,fit:_40.fit};
_40.left=0;
_40.top=0;
_40.fit=true;
_3(_3f);
_40.minimized=false;
_40.maximized=true;
_40.onMaximize.call(_3f);
};
function _43(_44){
var _45=$.data(_44,"panel").options;
var _46=$.data(_44,"panel").panel;
_46.hide();
_45.minimized=true;
_45.maximized=false;
_45.onMinimize.call(_44);
};
function _47(_48){
var _49=$.data(_48,"panel").options;
var _4a=$.data(_48,"panel").panel;
var _4b=_4a.children("div.panel-header").find("div.panel-tool-max");
if(_49.maximized==false){
return;
}
_4a.show();
_4b.removeClass("panel-tool-restore");
var _4c=$.data(_48,"panel").original;
_49.width=_4c.width;
_49.height=_4c.height;
_49.left=_4c.left;
_49.top=_4c.top;
_49.fit=_4c.fit;
_3(_48);
_49.minimized=false;
_49.maximized=false;
_49.onRestore.call(_48);
};
function _4d(_4e){
var _4f=$.data(_4e,"panel").options;
var _50=$.data(_4e,"panel").panel;
if(_4f.border==true){
_50.children("div.panel-header").removeClass("panel-header-noborder");
_50.children("div.panel-body").removeClass("panel-body-noborder");
}else{
_50.children("div.panel-header").addClass("panel-header-noborder");
_50.children("div.panel-body").addClass("panel-body-noborder");
}
_50.css(_4f.style);
_50.addClass(_4f.cls);
_50.children("div.panel-header").addClass(_4f.headerCls);
_50.children("div.panel-body").addClass(_4f.bodyCls);
};
function _51(_52,_53){
$.data(_52,"panel").options.title=_53;
$(_52).panel("header").find("div.panel-title").html(_53);
};
var TO=false;
var _54=true;
$(window).unbind(".panel").bind("resize.panel",function(){
if(!_54){
return;
}
if(TO!==false){
clearTimeout(TO);
}
TO=setTimeout(function(){
_54=false;
var _55=$("body.layout");
if(_55.length){
_55.layout("resize");
}else{
$("body>div.panel").triggerHandler("_resize");
}
_54=true;
TO=false;
},200);
});
$.fn.panel=function(_56,_57){
if(typeof _56=="string"){
return $.fn.panel.methods[_56](this,_57);
}
_56=_56||{};
return this.each(function(){
var _58=$.data(this,"panel");
var _59;
if(_58){
_59=$.extend(_58.options,_56);
}else{
_59=$.extend({},$.fn.panel.defaults,$.fn.panel.parseOptions(this),_56);
$(this).attr("title","");
_58=$.data(this,"panel",{options:_59,panel:_f(this),isLoaded:false});
}
if(_59.content){
$(this).html(_59.content);
if($.parser){
$.parser.parse(this);
}
}
_13(this);
_4d(this);
if(_59.doSize==true){
_58.panel.css("display","block");
_3(this);
}
if(_59.closed==true||_59.minimized==true){
_58.panel.hide();
}else{
_22(this);
}
});
};
$.fn.panel.methods={options:function(jq){
return $.data(jq[0],"panel").options;
},panel:function(jq){
return $.data(jq[0],"panel").panel;
},header:function(jq){
return $.data(jq[0],"panel").panel.find(">div.panel-header");
},body:function(jq){
return $.data(jq[0],"panel").panel.find(">div.panel-body");
},setTitle:function(jq,_5a){
return jq.each(function(){
_51(this,_5a);
});
},open:function(jq,_5b){
return jq.each(function(){
_22(this,_5b);
});
},close:function(jq,_5c){
return jq.each(function(){
_1d(this,_5c);
});
},destroy:function(jq,_5d){
return jq.each(function(){
_2d(this,_5d);
});
},refresh:function(jq){
return jq.each(function(){
$.data(this,"panel").isLoaded=false;
_1e(this);
});
},resize:function(jq,_5e){
return jq.each(function(){
_3(this,_5e);
});
},move:function(jq,_5f){
return jq.each(function(){
_a(this,_5f);
});
},maximize:function(jq){
return jq.each(function(){
_27(this);
});
},minimize:function(jq){
return jq.each(function(){
_43(this);
});
},restore:function(jq){
return jq.each(function(){
_47(this);
});
},collapse:function(jq,_60){
return jq.each(function(){
_28(this,_60);
});
},expand:function(jq,_61){
return jq.each(function(){
_38(this,_61);
});
}};
$.fn.panel.parseOptions=function(_62){
var t=$(_62);
return {width:(parseInt(_62.style.width)||undefined),height:(parseInt(_62.style.height)||undefined),left:(parseInt(_62.style.left)||undefined),top:(parseInt(_62.style.top)||undefined),title:(t.attr("title")||undefined),iconCls:(t.attr("iconCls")||t.attr("icon")),cls:t.attr("cls"),headerCls:t.attr("headerCls"),bodyCls:t.attr("bodyCls"),href:t.attr("href"),cache:(t.attr("cache")?t.attr("cache")=="true":undefined),fit:(t.attr("fit")?t.attr("fit")=="true":undefined),border:(t.attr("border")?t.attr("border")=="true":undefined),noheader:(t.attr("noheader")?t.attr("noheader")=="true":undefined),collapsible:(t.attr("collapsible")?t.attr("collapsible")=="true":undefined),minimizable:(t.attr("minimizable")?t.attr("minimizable")=="true":undefined),maximizable:(t.attr("maximizable")?t.attr("maximizable")=="true":undefined),closable:(t.attr("closable")?t.attr("closable")=="true":undefined),collapsed:(t.attr("collapsed")?t.attr("collapsed")=="true":undefined),minimized:(t.attr("minimized")?t.attr("minimized")=="true":undefined),maximized:(t.attr("maximized")?t.attr("maximized")=="true":undefined),closed:(t.attr("closed")?t.attr("closed")=="true":undefined)};
};
$.fn.panel.defaults={title:null,iconCls:null,width:"auto",height:"auto",left:null,top:null,cls:null,headerCls:null,bodyCls:null,style:{},href:null,cache:true,fit:false,border:true,doSize:true,noheader:false,content:null,collapsible:false,minimizable:false,maximizable:false,closable:false,collapsed:false,minimized:false,maximized:false,closed:false,tools:[],href:null,loadingMessage:"Loading...",onLoad:function(){
},onBeforeOpen:function(){
},onOpen:function(){
},onBeforeClose:function(){
},onClose:function(){
},onBeforeDestroy:function(){
},onDestroy:function(){
},onResize:function(_63,_64){
},onMove:function(_65,top){
},onMaximize:function(){
},onRestore:function(){
},onMinimize:function(){
},onBeforeCollapse:function(){
},onBeforeExpand:function(){
},onCollapse:function(){
},onExpand:function(){
}};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
var _1=false;
function _2(_3){
var _4=$.data(_3,"layout").options;
var _5=$.data(_3,"layout").panels;
var cc=$(_3);
if(_4.fit==true){
var p=cc.parent();
cc.width(p.width()).height(p.height());
}
var _6={top:0,left:0,width:cc.width(),height:cc.height()};
function _7(pp){
if(pp.length==0){
return;
}
pp.panel("resize",{width:cc.width(),height:pp.panel("options").height,left:0,top:0});
_6.top+=pp.panel("options").height;
_6.height-=pp.panel("options").height;
};
if(_b(_5.expandNorth)){
_7(_5.expandNorth);
}else{
_7(_5.north);
}
function _8(pp){
if(pp.length==0){
return;
}
pp.panel("resize",{width:cc.width(),height:pp.panel("options").height,left:0,top:cc.height()-pp.panel("options").height});
_6.height-=pp.panel("options").height;
};
if(_b(_5.expandSouth)){
_8(_5.expandSouth);
}else{
_8(_5.south);
}
function _9(pp){
if(pp.length==0){
return;
}
pp.panel("resize",{width:pp.panel("options").width,height:_6.height,left:cc.width()-pp.panel("options").width,top:_6.top});
_6.width-=pp.panel("options").width;
};
if(_b(_5.expandEast)){
_9(_5.expandEast);
}else{
_9(_5.east);
}
function _a(pp){
if(pp.length==0){
return;
}
pp.panel("resize",{width:pp.panel("options").width,height:_6.height,left:0,top:_6.top});
_6.left+=pp.panel("options").width;
_6.width-=pp.panel("options").width;
};
if(_b(_5.expandWest)){
_a(_5.expandWest);
}else{
_a(_5.west);
}
_5.center.panel("resize",_6);
};
function _c(_d){
var cc=$(_d);
if(cc[0].tagName=="BODY"){
$("html").css({height:"100%",overflow:"hidden"});
$("body").css({height:"100%",overflow:"hidden",border:"none"});
}
cc.addClass("layout");
cc.css({margin:0,padding:0});
function _e(_f){
var pp=$(">div[region="+_f+"]",_d).addClass("layout-body");
var _10=null;
if(_f=="north"){
_10="layout-button-up";
}else{
if(_f=="south"){
_10="layout-button-down";
}else{
if(_f=="east"){
_10="layout-button-right";
}else{
if(_f=="west"){
_10="layout-button-left";
}
}
}
}
var cls="layout-panel layout-panel-"+_f;
if(pp.attr("split")=="true"){
cls+=" layout-split-"+_f;
}
pp.panel({cls:cls,doSize:false,border:(pp.attr("border")=="false"?false:true),tools:[{iconCls:_10,handler:function(){
_1b(_d,_f);
}}]});
if(pp.attr("split")=="true"){
var _11=pp.panel("panel");
var _12="";
if(_f=="north"){
_12="s";
}
if(_f=="south"){
_12="n";
}
if(_f=="east"){
_12="w";
}
if(_f=="west"){
_12="e";
}
_11.resizable({handles:_12,onStartResize:function(e){
_1=true;
if(_f=="north"||_f=="south"){
var _13=$(">div.layout-split-proxy-v",_d);
}else{
var _13=$(">div.layout-split-proxy-h",_d);
}
var top=0,_14=0,_15=0,_16=0;
var pos={display:"block"};
if(_f=="north"){
pos.top=parseInt(_11.css("top"))+_11.outerHeight()-_13.height();
pos.left=parseInt(_11.css("left"));
pos.width=_11.outerWidth();
pos.height=_13.height();
}else{
if(_f=="south"){
pos.top=parseInt(_11.css("top"));
pos.left=parseInt(_11.css("left"));
pos.width=_11.outerWidth();
pos.height=_13.height();
}else{
if(_f=="east"){
pos.top=parseInt(_11.css("top"))||0;
pos.left=parseInt(_11.css("left"))||0;
pos.width=_13.width();
pos.height=_11.outerHeight();
}else{
if(_f=="west"){
pos.top=parseInt(_11.css("top"))||0;
pos.left=_11.outerWidth()-_13.width();
pos.width=_13.width();
pos.height=_11.outerHeight();
}
}
}
}
_13.css(pos);
$("<div class=\"layout-mask\"></div>").css({left:0,top:0,width:cc.width(),height:cc.height()}).appendTo(cc);
},onResize:function(e){
if(_f=="north"||_f=="south"){
var _17=$(">div.layout-split-proxy-v",_d);
_17.css("top",e.pageY-$(_d).offset().top-_17.height()/2);
}else{
var _17=$(">div.layout-split-proxy-h",_d);
_17.css("left",e.pageX-$(_d).offset().left-_17.width()/2);
}
return false;
},onStopResize:function(){
$(">div.layout-split-proxy-v",_d).css("display","none");
$(">div.layout-split-proxy-h",_d).css("display","none");
var _18=pp.panel("options");
_18.width=_11.outerWidth();
_18.height=_11.outerHeight();
_18.left=_11.css("left");
_18.top=_11.css("top");
pp.panel("resize");
_2(_d);
_1=false;
cc.find(">div.layout-mask").remove();
}});
}
return pp;
};
$("<div class=\"layout-split-proxy-h\"></div>").appendTo(cc);
$("<div class=\"layout-split-proxy-v\"></div>").appendTo(cc);
var _19={center:_e("center")};
_19.north=_e("north");
_19.south=_e("south");
_19.east=_e("east");
_19.west=_e("west");
$(_d).bind("_resize",function(){
var _1a=$.data(_d,"layout").options;
if(_1a.fit==true){
_2(_d);
}
return false;
});
return _19;
};
function _1b(_1c,_1d){
var _1e=$.data(_1c,"layout").panels;
var cc=$(_1c);
function _1f(dir){
var _20;
if(dir=="east"){
_20="layout-button-left";
}else{
if(dir=="west"){
_20="layout-button-right";
}else{
if(dir=="north"){
_20="layout-button-down";
}else{
if(dir=="south"){
_20="layout-button-up";
}
}
}
}
var p=$("<div></div>").appendTo(cc).panel({cls:"layout-expand",title:" ",closed:true,doSize:false,tools:[{iconCls:_20,handler:function(){
_21(_1c,_1d);
}}]});
p.panel("panel").hover(function(){
$(this).addClass("layout-expand-over");
},function(){
$(this).removeClass("layout-expand-over");
});
return p;
};
if(_1d=="east"){
if(_1e.east.panel("options").onBeforeCollapse.call(_1e.east)==false){
return;
}
_1e.center.panel("resize",{width:_1e.center.panel("options").width+_1e.east.panel("options").width-28});
_1e.east.panel("panel").animate({left:cc.width()},function(){
_1e.east.panel("close");
_1e.expandEast.panel("open").panel("resize",{top:_1e.east.panel("options").top,left:cc.width()-28,width:28,height:_1e.east.panel("options").height});
_1e.east.panel("options").onCollapse.call(_1e.east);
});
if(!_1e.expandEast){
_1e.expandEast=_1f("east");
_1e.expandEast.panel("panel").click(function(){
_1e.east.panel("open").panel("resize",{left:cc.width()});
_1e.east.panel("panel").animate({left:cc.width()-_1e.east.panel("options").width});
return false;
});
}
}else{
if(_1d=="west"){
if(_1e.west.panel("options").onBeforeCollapse.call(_1e.west)==false){
return;
}
_1e.center.panel("resize",{width:_1e.center.panel("options").width+_1e.west.panel("options").width-28,left:28});
_1e.west.panel("panel").animate({left:-_1e.west.panel("options").width},function(){
_1e.west.panel("close");
_1e.expandWest.panel("open").panel("resize",{top:_1e.west.panel("options").top,left:0,width:28,height:_1e.west.panel("options").height});
_1e.west.panel("options").onCollapse.call(_1e.west);
});
if(!_1e.expandWest){
_1e.expandWest=_1f("west");
_1e.expandWest.panel("panel").click(function(){
_1e.west.panel("open").panel("resize",{left:-_1e.west.panel("options").width});
_1e.west.panel("panel").animate({left:0});
return false;
});
}
}else{
if(_1d=="north"){
if(_1e.north.panel("options").onBeforeCollapse.call(_1e.north)==false){
return;
}
var hh=cc.height()-28;
if(_b(_1e.expandSouth)){
hh-=_1e.expandSouth.panel("options").height;
}else{
if(_b(_1e.south)){
hh-=_1e.south.panel("options").height;
}
}
_1e.center.panel("resize",{top:28,height:hh});
_1e.east.panel("resize",{top:28,height:hh});
_1e.west.panel("resize",{top:28,height:hh});
if(_b(_1e.expandEast)){
_1e.expandEast.panel("resize",{top:28,height:hh});
}
if(_b(_1e.expandWest)){
_1e.expandWest.panel("resize",{top:28,height:hh});
}
_1e.north.panel("panel").animate({top:-_1e.north.panel("options").height},function(){
_1e.north.panel("close");
_1e.expandNorth.panel("open").panel("resize",{top:0,left:0,width:cc.width(),height:28});
_1e.north.panel("options").onCollapse.call(_1e.north);
});
if(!_1e.expandNorth){
_1e.expandNorth=_1f("north");
_1e.expandNorth.panel("panel").click(function(){
_1e.north.panel("open").panel("resize",{top:-_1e.north.panel("options").height});
_1e.north.panel("panel").animate({top:0});
return false;
});
}
}else{
if(_1d=="south"){
if(_1e.south.panel("options").onBeforeCollapse.call(_1e.south)==false){
return;
}
var hh=cc.height()-28;
if(_b(_1e.expandNorth)){
hh-=_1e.expandNorth.panel("options").height;
}else{
if(_b(_1e.north)){
hh-=_1e.north.panel("options").height;
}
}
_1e.center.panel("resize",{height:hh});
_1e.east.panel("resize",{height:hh});
_1e.west.panel("resize",{height:hh});
if(_b(_1e.expandEast)){
_1e.expandEast.panel("resize",{height:hh});
}
if(_b(_1e.expandWest)){
_1e.expandWest.panel("resize",{height:hh});
}
_1e.south.panel("panel").animate({top:cc.height()},function(){
_1e.south.panel("close");
_1e.expandSouth.panel("open").panel("resize",{top:cc.height()-28,left:0,width:cc.width(),height:28});
_1e.south.panel("options").onCollapse.call(_1e.south);
});
if(!_1e.expandSouth){
_1e.expandSouth=_1f("south");
_1e.expandSouth.panel("panel").click(function(){
_1e.south.panel("open").panel("resize",{top:cc.height()});
_1e.south.panel("panel").animate({top:cc.height()-_1e.south.panel("options").height});
return false;
});
}
}
}
}
}
};
function _21(_22,_23){
var _24=$.data(_22,"layout").panels;
var cc=$(_22);
if(_23=="east"&&_24.expandEast){
if(_24.east.panel("options").onBeforeExpand.call(_24.east)==false){
return;
}
_24.expandEast.panel("close");
_24.east.panel("panel").stop(true,true);
_24.east.panel("open").panel("resize",{left:cc.width()});
_24.east.panel("panel").animate({left:cc.width()-_24.east.panel("options").width},function(){
_2(_22);
_24.east.panel("options").onExpand.call(_24.east);
});
}else{
if(_23=="west"&&_24.expandWest){
if(_24.west.panel("options").onBeforeExpand.call(_24.west)==false){
return;
}
_24.expandWest.panel("close");
_24.west.panel("panel").stop(true,true);
_24.west.panel("open").panel("resize",{left:-_24.west.panel("options").width});
_24.west.panel("panel").animate({left:0},function(){
_2(_22);
_24.west.panel("options").onExpand.call(_24.west);
});
}else{
if(_23=="north"&&_24.expandNorth){
if(_24.north.panel("options").onBeforeExpand.call(_24.north)==false){
return;
}
_24.expandNorth.panel("close");
_24.north.panel("panel").stop(true,true);
_24.north.panel("open").panel("resize",{top:-_24.north.panel("options").height});
_24.north.panel("panel").animate({top:0},function(){
_2(_22);
_24.north.panel("options").onExpand.call(_24.north);
});
}else{
if(_23=="south"&&_24.expandSouth){
if(_24.south.panel("options").onBeforeExpand.call(_24.south)==false){
return;
}
_24.expandSouth.panel("close");
_24.south.panel("panel").stop(true,true);
_24.south.panel("open").panel("resize",{top:cc.height()});
_24.south.panel("panel").animate({top:cc.height()-_24.south.panel("options").height},function(){
_2(_22);
_24.south.panel("options").onExpand.call(_24.south);
});
}
}
}
}
};
function _25(_26){
var _27=$.data(_26,"layout").panels;
var cc=$(_26);
if(_27.east.length){
_27.east.panel("panel").bind("mouseover","east",_1b);
}
if(_27.west.length){
_27.west.panel("panel").bind("mouseover","west",_1b);
}
if(_27.north.length){
_27.north.panel("panel").bind("mouseover","north",_1b);
}
if(_27.south.length){
_27.south.panel("panel").bind("mouseover","south",_1b);
}
_27.center.panel("panel").bind("mouseover","center",_1b);
function _1b(e){
if(_1==true){
return;
}
if(e.data!="east"&&_b(_27.east)&&_b(_27.expandEast)){
_27.east.panel("panel").animate({left:cc.width()},function(){
_27.east.panel("close");
});
}
if(e.data!="west"&&_b(_27.west)&&_b(_27.expandWest)){
_27.west.panel("panel").animate({left:-_27.west.panel("options").width},function(){
_27.west.panel("close");
});
}
if(e.data!="north"&&_b(_27.north)&&_b(_27.expandNorth)){
_27.north.panel("panel").animate({top:-_27.north.panel("options").height},function(){
_27.north.panel("close");
});
}
if(e.data!="south"&&_b(_27.south)&&_b(_27.expandSouth)){
_27.south.panel("panel").animate({top:cc.height()},function(){
_27.south.panel("close");
});
}
return false;
};
};
function _b(pp){
if(!pp){
return false;
}
if(pp.length){
return pp.panel("panel").is(":visible");
}else{
return false;
}
};
$.fn.layout=function(_28,_29){
if(typeof _28=="string"){
return $.fn.layout.methods[_28](this,_29);
}
return this.each(function(){
var _2a=$.data(this,"layout");
if(!_2a){
var _2b=$.extend({},{fit:$(this).attr("fit")=="true"});
$.data(this,"layout",{options:_2b,panels:_c(this)});
_25(this);
}
_2(this);
});
};
$.fn.layout.methods={resize:function(jq){
return jq.each(function(){
_2(this);
});
},panel:function(jq,_2c){
return $.data(jq[0],"layout").panels[_2c];
},collapse:function(jq,_2d){
return jq.each(function(){
_1b(this,_2d);
});
},expand:function(jq,_2e){
return jq.each(function(){
_21(this,_2e);
});
}};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(e){
var _2=$.data(e.data.target,"draggable").options;
var _3=e.data;
var _4=_3.startLeft+e.pageX-_3.startX;
var _5=_3.startTop+e.pageY-_3.startY;
if(_2.deltaX!=null&&_2.deltaX!=undefined){
_4=e.pageX+_2.deltaX;
}
if(_2.deltaY!=null&&_2.deltaY!=undefined){
_5=e.pageY+_2.deltaY;
}
if(e.data.parnet!=document.body){
if($.boxModel==true){
_4+=$(e.data.parent).scrollLeft();
_5+=$(e.data.parent).scrollTop();
}
}
if(_2.axis=="h"){
_3.left=_4;
}else{
if(_2.axis=="v"){
_3.top=_5;
}else{
_3.left=_4;
_3.top=_5;
}
}
};
function _6(e){
var _7=$.data(e.data.target,"draggable").options;
var _8=$.data(e.data.target,"draggable").proxy;
if(_8){
_8.css("cursor",_7.cursor);
}else{
_8=$(e.data.target);
$.data(e.data.target,"draggable").handle.css("cursor",_7.cursor);
}
_8.css({left:e.data.left,top:e.data.top});
};
function _9(e){
var _a=$.data(e.data.target,"draggable").options;
var _b=$(".droppable").filter(function(){
return e.data.target!=this;
}).filter(function(){
var _c=$.data(this,"droppable").options.accept;
if(_c){
return $(_c).filter(function(){
return this==e.data.target;
}).length>0;
}else{
return true;
}
});
$.data(e.data.target,"draggable").droppables=_b;
var _d=$.data(e.data.target,"draggable").proxy;
if(!_d){
if(_a.proxy){
if(_a.proxy=="clone"){
_d=$(e.data.target).clone().insertAfter(e.data.target);
}else{
_d=_a.proxy.call(e.data.target,e.data.target);
}
$.data(e.data.target,"draggable").proxy=_d;
}else{
_d=$(e.data.target);
}
}
_d.css("position","absolute");
_1(e);
_6(e);
_a.onStartDrag.call(e.data.target,e);
return false;
};
function _e(e){
_1(e);
if($.data(e.data.target,"draggable").options.onDrag.call(e.data.target,e)!=false){
_6(e);
}
var _f=e.data.target;
$.data(e.data.target,"draggable").droppables.each(function(){
var _10=$(this);
var p2=$(this).offset();
if(e.pageX>p2.left&&e.pageX<p2.left+_10.outerWidth()&&e.pageY>p2.top&&e.pageY<p2.top+_10.outerHeight()){
if(!this.entered){
$(this).trigger("_dragenter",[_f]);
this.entered=true;
}
$(this).trigger("_dragover",[_f]);
}else{
if(this.entered){
$(this).trigger("_dragleave",[_f]);
this.entered=false;
}
}
});
return false;
};
function _11(e){
_1(e);
var _12=$.data(e.data.target,"draggable").proxy;
var _13=$.data(e.data.target,"draggable").options;
if(_13.revert){
if(_14()==true){
_15();
$(e.data.target).css({position:e.data.startPosition,left:e.data.startLeft,top:e.data.startTop});
}else{
if(_12){
_12.animate({left:e.data.startLeft,top:e.data.startTop},function(){
_15();
});
}else{
$(e.data.target).animate({left:e.data.startLeft,top:e.data.startTop},function(){
$(e.data.target).css("position",e.data.startPosition);
});
}
}
}else{
$(e.data.target).css({position:"absolute",left:e.data.left,top:e.data.top});
_15();
_14();
}
_13.onStopDrag.call(e.data.target,e);
function _15(){
if(_12){
_12.remove();
}
$.data(e.data.target,"draggable").proxy=null;
};
function _14(){
var _16=false;
$.data(e.data.target,"draggable").droppables.each(function(){
var _17=$(this);
var p2=$(this).offset();
if(e.pageX>p2.left&&e.pageX<p2.left+_17.outerWidth()&&e.pageY>p2.top&&e.pageY<p2.top+_17.outerHeight()){
if(_13.revert){
$(e.data.target).css({position:e.data.startPosition,left:e.data.startLeft,top:e.data.startTop});
}
$(this).trigger("_drop",[e.data.target]);
_16=true;
this.entered=false;
}
});
return _16;
};
$(document).unbind(".draggable");
return false;
};
$.fn.draggable=function(_18,_19){
if(typeof _18=="string"){
return $.fn.draggable.methods[_18](this,_19);
}
return this.each(function(){
var _1a;
var _1b=$.data(this,"draggable");
if(_1b){
_1b.handle.unbind(".draggable");
_1a=$.extend(_1b.options,_18);
}else{
_1a=$.extend({},$.fn.draggable.defaults,_18||{});
}
if(_1a.disabled==true){
$(this).css("cursor","default");
return;
}
var _1c=null;
if(typeof _1a.handle=="undefined"||_1a.handle==null){
_1c=$(this);
}else{
_1c=(typeof _1a.handle=="string"?$(_1a.handle,this):_1c);
}
$.data(this,"draggable",{options:_1a,handle:_1c});
_1c.bind("mousedown.draggable",{target:this},_1d);
_1c.bind("mousemove.draggable",{target:this},_1e);
function _1d(e){
if(_1f(e)==false){
return;
}
var _20=$(e.data.target).position();
var _21={startPosition:$(e.data.target).css("position"),startLeft:_20.left,startTop:_20.top,left:_20.left,top:_20.top,startX:e.pageX,startY:e.pageY,target:e.data.target,parent:$(e.data.target).parent()[0]};
$(document).bind("mousedown.draggable",_21,_9);
$(document).bind("mousemove.draggable",_21,_e);
$(document).bind("mouseup.draggable",_21,_11);
};
function _1e(e){
if(_1f(e)){
$(this).css("cursor",_1a.cursor);
}else{
$(this).css("cursor","default");
}
};
function _1f(e){
var _22=$(_1c).offset();
var _23=$(_1c).outerWidth();
var _24=$(_1c).outerHeight();
var t=e.pageY-_22.top;
var r=_22.left+_23-e.pageX;
var b=_22.top+_24-e.pageY;
var l=e.pageX-_22.left;
return Math.min(t,r,b,l)>_1a.edge;
};
});
};
$.fn.draggable.methods={options:function(jq){
return $.data(jq[0],"draggable").options;
},proxy:function(jq){
return $.data(jq[0],"draggable").proxy;
},enable:function(jq){
return jq.each(function(){
$(this).draggable({disabled:false});
});
},disable:function(jq){
return jq.each(function(){
$(this).draggable({disabled:true});
});
}};
$.fn.draggable.defaults={proxy:null,revert:false,cursor:"move",deltaX:null,deltaY:null,handle:null,disabled:false,edge:0,axis:null,onStartDrag:function(e){
},onDrag:function(e){
},onStopDrag:function(e){
}};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var t=$(_2);
t.wrapInner("<div class=\"dialog-content\"></div>");
var _3=t.find(">div.dialog-content");
_3.css("padding",t.css("padding"));
t.css("padding",0);
_3.panel({border:false,doSize:false});
return _3;
};
function _4(_5){
var _6=$.data(_5,"dialog").options;
var _7=$.data(_5,"dialog").contentPanel;
$(_5).find("div.dialog-toolbar").remove();
$(_5).find("div.dialog-button").remove();
if(_6.toolbar){
var _8=$("<div class=\"dialog-toolbar\"></div>").prependTo(_5);
for(var i=0;i<_6.toolbar.length;i++){
var p=_6.toolbar[i];
if(p=="-"){
_8.append("<div class=\"dialog-tool-separator\"></div>");
}else{
var _9=$("<a href=\"javascript:void(0)\"></a>").appendTo(_8);
_9.css("float","left");
_9[0].onclick=eval(p.handler||function(){
});
_9.linkbutton($.extend({},p,{plain:true}));
}
}
_8.append("<div style=\"clear:both\"></div>");
}
if(_6.buttons){
var _a=$("<div class=\"dialog-button\"></div>").appendTo(_5);
for(var i=0;i<_6.buttons.length;i++){
var p=_6.buttons[i];
var _b=$("<a href=\"javascript:void(0)\"></a>").appendTo(_a);
if(p.handler){
_b[0].onclick=p.handler;
}
_b.linkbutton(p);
}
}
var _c=_6.href;
_6.href=null;
$(_5).window($.extend({},_6,{onResize:function(_d,_e){
var _f=$(_5).panel("panel").find(">div.panel-body");
_7.panel("resize",{width:_f.width(),height:(_e=="auto")?"auto":_f.height()-_f.find(">div.dialog-toolbar").outerHeight()-_f.find(">div.dialog-button").outerHeight()});
if(_6.onResize){
_6.onResize.call(_5,_d,_e);
}
}}));
_7.panel({href:_c,onLoad:function(){
if(_6.height=="auto"){
$(_5).window("resize");
}
_6.onLoad.apply(_5,arguments);
}});
_6.href=_c;
};
function _10(_11){
var _12=$.data(_11,"dialog").contentPanel;
_12.panel("refresh");
};
$.fn.dialog=function(_13,_14){
if(typeof _13=="string"){
var _15=$.fn.dialog.methods[_13];
if(_15){
return _15(this,_14);
}else{
return this.window(_13,_14);
}
}
_13=_13||{};
return this.each(function(){
var _16=$.data(this,"dialog");
if(_16){
$.extend(_16.options,_13);
}else{
$.data(this,"dialog",{options:$.extend({},$.fn.dialog.defaults,$.fn.dialog.parseOptions(this),_13),contentPanel:_1(this)});
}
_4(this);
});
};
$.fn.dialog.methods={options:function(jq){
var _17=$.data(jq[0],"dialog").options;
var _18=jq.panel("options");
$.extend(_17,{closed:_18.closed,collapsed:_18.collapsed,minimized:_18.minimized,maximized:_18.maximized});
var _19=$.data(jq[0],"dialog").contentPanel;
return _17;
},dialog:function(jq){
return jq.window("window");
},refresh:function(jq){
return jq.each(function(){
_10(this);
});
}};
$.fn.dialog.parseOptions=function(_1a){
var t=$(_1a);
return $.extend({},$.fn.window.parseOptions(_1a),{});
};
$.fn.dialog.defaults=$.extend({},$.fn.window.defaults,{title:"New Dialog",collapsible:false,minimizable:false,maximizable:false,resizable:false,toolbar:null,buttons:null});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"treegrid").options;
$(_2).datagrid($.extend({},_3,{url:null,onLoadSuccess:function(){
},onResizeColumn:function(_4,_5){
_6(_2);
_3.onResizeColumn.call(_2,_4,_5);
}}));
};
function _6(_7,_8){
var _9=$.data(_7,"datagrid").options;
var _a=$.data(_7,"datagrid").panel;
var _b=_a.children("div.datagrid-view");
var _c=_b.children("div.datagrid-view1");
var _d=_b.children("div.datagrid-view2");
if(_9.rownumbers||(_9.frozenColumns&&_9.frozenColumns.length>0)){
if(_8){
_e(_8);
_d.find("tr[node-id="+_8+"]").next("tr.treegrid-tr-tree").find("tr[node-id]").each(function(){
_e($(this).attr("node-id"));
});
}else{
_d.find("tr[node-id]").each(function(){
_e($(this).attr("node-id"));
});
}
}
if(_9.height=="auto"){
var _f=_d.find("div.datagrid-body table").height()+18;
_c.find("div.datagrid-body").height(_f);
_d.find("div.datagrid-body").height(_f);
_b.height(_d.height());
}
function _e(_10){
var tr1=_c.find("tr[node-id="+_10+"]");
var tr2=_d.find("tr[node-id="+_10+"]");
tr1.css("height",null);
tr2.css("height",null);
var _11=Math.max(tr1.height(),tr2.height());
tr1.css("height",_11);
tr2.css("height",_11);
};
};
function _12(_13){
var _14=$.data(_13,"treegrid").options;
if(!_14.rownumbers){
return;
}
$(_13).datagrid("getPanel").find("div.datagrid-view1 div.datagrid-body div.datagrid-cell-rownumber").each(function(i){
$(this).html(i+1);
});
};
function _15(_16){
var _17=$.data(_16,"treegrid").options;
var _18=$(_16).datagrid("getPanel");
var _19=_18.find("div.datagrid-body");
_19.find("span.tree-hit").unbind(".treegrid").bind("click.treegrid",function(){
var tr=$(this).parent().parent().parent();
var id=tr.attr("node-id");
_99(_16,id);
return false;
}).bind("mouseenter.treegrid",function(){
if($(this).hasClass("tree-expanded")){
$(this).addClass("tree-expanded-hover");
}else{
$(this).addClass("tree-collapsed-hover");
}
}).bind("mouseleave.treegrid",function(){
if($(this).hasClass("tree-expanded")){
$(this).removeClass("tree-expanded-hover");
}else{
$(this).removeClass("tree-collapsed-hover");
}
});
_19.find("tr[node-id]").unbind(".treegrid").bind("mouseenter.treegrid",function(){
var id=$(this).attr("node-id");
_19.find("tr[node-id="+id+"]").addClass("datagrid-row-over");
}).bind("mouseleave.treegrid",function(){
var id=$(this).attr("node-id");
_19.find("tr[node-id="+id+"]").removeClass("datagrid-row-over");
}).bind("click.treegrid",function(){
var id=$(this).attr("node-id");
if(_17.singleSelect){
_1c(_16);
_83(_16,id);
}else{
if($(this).hasClass("datagrid-row-selected")){
_87(_16,id);
}else{
_83(_16,id);
}
}
_17.onClickRow.call(_16,_42(_16,id));
return false;
}).bind("dblclick.treegrid",function(){
var id=$(this).attr("node-id");
_17.onDblClickRow.call(_16,_42(_16,id));
return false;
}).bind("contextmenu.treegrid",function(e){
var id=$(this).attr("node-id");
_17.onContextMenu.call(_16,e,_42(_16,id));
});
_19.find("div.datagrid-cell-check input[type=checkbox]").unbind(".treegrid").bind("click.treegrid",function(e){
var id=$(this).parent().parent().parent().attr("node-id");
if(_17.singleSelect){
_1c(_16);
_83(_16,id);
}else{
if($(this).attr("checked")){
_83(_16,id);
}else{
_87(_16,id);
}
}
e.stopPropagation();
});
var _1a=_18.find("div.datagrid-header");
_1a.find("input[type=checkbox]").unbind().bind("click.treegrid",function(){
if(_17.singleSelect){
return false;
}
if($(this).attr("checked")){
_1b(_16);
}else{
_1c(_16);
}
});
};
function _1d(_1e,_1f){
var _20=$.data(_1e,"datagrid").options;
var _21=$(_1e).datagrid("getPanel").children("div.datagrid-view");
var _22=_21.children("div.datagrid-view1");
var _23=_21.children("div.datagrid-view2");
var tr1=_22.children("div.datagrid-body").find("tr[node-id="+_1f+"]");
var tr2=_23.children("div.datagrid-body").find("tr[node-id="+_1f+"]");
var _24=tr1.next("tr.treegrid-tr-tree");
var _25=tr2.next("tr.treegrid-tr-tree");
var _26=_24.children("td").find("div");
var _27=_25.children("td").find("div");
var td1=tr1.find("td[field="+_20.treeField+"]");
var td2=tr2.find("td[field="+_20.treeField+"]");
var _28=td1.find("span.tree-indent,span.tree-hit").length+td2.find("span.tree-indent,span.tree-hit").length;
return [_26,_27,_28];
};
function _29(_2a,_2b){
var _2c=$.data(_2a,"treegrid").options;
var _2d=$(_2a).datagrid("getPanel").children("div.datagrid-view");
var _2e=_2d.children("div.datagrid-view1");
var _2f=_2d.children("div.datagrid-view2");
var tr1=_2e.children("div.datagrid-body").find("tr[node-id="+_2b+"]");
var tr2=_2f.children("div.datagrid-body").find("tr[node-id="+_2b+"]");
var _30=$(_2a).datagrid("getColumnFields",true).length+(_2c.rownumbers?1:0);
var _31=$(_2a).datagrid("getColumnFields",false).length;
_32(tr1,_30);
_32(tr2,_31);
function _32(tr,_33){
$("<tr class=\"treegrid-tr-tree\">"+"<td style=\"border:0px\" colspan=\""+_33+"\">"+"<div></div>"+"</td>"+"</tr>").insertAfter(tr);
};
};
function _34(_35,_36,_37,_38){
var _39=$.data(_35,"treegrid").options;
var _3a=$.data(_35,"datagrid").panel;
var _3b=_3a.children("div.datagrid-view");
var _3c=_3b.children("div.datagrid-view1");
var _3d=_3b.children("div.datagrid-view2");
var _3e=$(_35).datagrid("getColumnFields",true);
var _3f=$(_35).datagrid("getColumnFields",false);
_40(_37,_36);
var _41=_42(_35,_36);
if(_41){
if(_41.children){
_41.children=_41.children.concat(_37);
}else{
_41.children=_37;
}
var _43=_1d(_35,_36);
var cc1=_43[0];
var cc2=_43[1];
var _44=_43[2];
}else{
$.data(_35,"treegrid").data=$.data(_35,"treegrid").data.concat(_37);
var cc1=_3c.children("div.datagrid-body").children("div.datagrid-body-inner");
var cc2=_3d.children("div.datagrid-body");
var _44=0;
}
if(!_38){
$.data(_35,"treegrid").data=_37;
cc1.empty();
cc2.empty();
}
var _45=_46(_37,_44);
cc1.html(cc1.html()+_45[0].join(""));
cc2.html(cc2.html()+_45[1].join(""));
_39.onLoadSuccess.call(_35,_41,_37);
_6(_35);
_12(_35);
_47();
_15(_35);
function _40(_48,_49){
for(var i=0;i<_48.length;i++){
var row=_48[i];
row._parentId=_49;
if(row.children&&row.children.length){
_40(row.children,row[_39.idField]);
}
}
};
function _46(_4a,_4b){
var _4c=["<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>"];
var _4d=["<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>"];
var _4e=[_4c,_4d];
for(var i=0;i<_4a.length;i++){
var row=_4a[i];
if(row.state!="open"&&row.state!="closed"){
row.state="open";
}
_4e[0]=_4e[0].concat(_4f(row,_3e,_4b,_39.rownumbers));
_4e[1]=_4e[1].concat(_4f(row,_3f,_4b));
if(row.children&&row.children.length){
var tt=_46(row.children,_4b+1);
var v=row.state=="closed"?"none":"block";
_4e[0].push("<tr class=\"treegrid-tr-tree\"><td style=\"border:0px\" colspan="+(_3e.length+(_39.rownumbers?1:0))+"><div style=\"display:"+v+"\">");
_4e[0]=_4e[0].concat(tt[0]);
_4e[0].push("</div></td></tr>");
_4e[1].push("<tr class=\"treegrid-tr-tree\"><td style=\"border:0px\" colspan="+_3f.length+"><div style=\"display:"+v+"\">");
_4e[1]=_4e[1].concat(tt[1]);
_4e[1].push("</div></td></tr>");
}
}
_4e[0].push("</tbody></table>");
_4e[1].push("</tbody></table>");
return _4e;
};
function _4f(row,_50,_51,_52){
var _53=["<tr node-id="+row[_39.idField]+">"];
if(_52){
_53.push("<td class=\"datagrid-td-rownumber\"><div class=\"datagrid-cell-rownumber\">0</div></td>");
}
for(var i=0;i<_50.length;i++){
var _54=_50[i];
var col=$(_35).datagrid("getColumnOption",_54);
if(col){
var _55="width:"+(col.boxWidth)+"px;";
_55+="text-align:"+(col.align||"left")+";";
_55+=_39.nowrap==false?"white-space:normal;":"";
_53.push("<td field=\""+_54+"\">");
_53.push("<div style=\""+_55+"\" ");
if(col.checkbox){
_53.push("class=\"datagrid-cell-check ");
}else{
_53.push("class=\"datagrid-cell ");
}
_53.push("\">");
if(col.checkbox){
if(row.checked){
_53.push("<input type=\"checkbox\" checked=\"checked\"/>");
}else{
_53.push("<input type=\"checkbox\"/>");
}
}
var val=null;
if(col.formatter){
val=col.formatter(row[_54],row);
}else{
val=row[_54]||" ";
}
if(_54==_39.treeField){
for(var j=0;j<_51;j++){
_53.push("<span class=\"tree-indent\"></span>");
}
if(row.state=="closed"){
_53.push("<span class=\"tree-hit tree-collapsed\"></span>");
_53.push("<span class=\"tree-icon tree-folder "+(row.iconCls?row.iconCls:"")+"\"></span>");
}else{
if(row.children&&row.children.length){
_53.push("<span class=\"tree-hit tree-expanded\"></span>");
_53.push("<span class=\"tree-icon tree-folder tree-folder-open "+(row.iconCls?row.iconCls:"")+"\"></span>");
}else{
_53.push("<span class=\"tree-indent\"></span>");
_53.push("<span class=\"tree-icon tree-file "+(row.iconCls?row.iconCls:"")+"\"></span>");
}
}
_53.push("<span class=\"tree-title\">"+val+"</span>");
}else{
_53.push(val);
}
_53.push("</div>");
_53.push("</td>");
}
}
_53.push("</tr>");
return _53;
};
function _47(){
var _56=_3b.find("div.datagrid-header");
var _57=_3b.find("div.datagrid-body");
var _58=_56.find("div.datagrid-header-check");
if(_58.length){
var ck=_57.find("div.datagrid-cell-check");
if($.boxModel){
ck.width(_58.width());
ck.height(_58.height());
}else{
ck.width(_58.outerWidth());
ck.height(_58.outerHeight());
}
}
};
};
function _59(_5a,_5b,_5c,_5d,_5e){
var _5f=$.data(_5a,"treegrid").options;
var _60=$(_5a).datagrid("getPanel").find("div.datagrid-body");
if(_5c){
_5f.queryParams=_5c;
}
var _61=$.extend({},_5f.queryParams);
var row=_42(_5a,_5b);
if(_5f.onBeforeLoad.call(_5a,row,_61)==false){
return;
}
if(!_5f.url){
return;
}
var _62=_60.find("tr[node-id="+_5b+"] span.tree-folder");
_62.addClass("tree-loading");
$.ajax({type:_5f.method,url:_5f.url,data:_61,dataType:"json",success:function(_63){
_62.removeClass("tree-loading");
_34(_5a,_5b,_63,_5d);
if(_5e){
_5e();
}
},error:function(){
_62.removeClass("tree-loading");
_5f.onLoadError.apply(_5a,arguments);
if(_5e){
_5e();
}
}});
};
function _64(_65){
var _66=_67(_65);
if(_66.length){
return _66[0];
}else{
return null;
}
};
function _67(_68){
return $.data(_68,"treegrid").data;
};
function _69(_6a,_6b){
var row=_42(_6a,_6b);
if(row._parentId){
return _42(_6a,row._parentId);
}else{
return null;
}
};
function _6c(_6d,_6e){
var _6f=$.data(_6d,"treegrid").options;
var _70=$(_6d).datagrid("getPanel").find("div.datagrid-view2 div.datagrid-body");
var _71=[];
if(_6e){
_72(_6e);
}else{
var _73=_67(_6d);
for(var i=0;i<_73.length;i++){
_71.push(_73[i]);
_72(_73[i][_6f.idField]);
}
}
function _72(_74){
var _75=_42(_6d,_74);
if(_75&&_75.children){
for(var i=0,len=_75.children.length;i<len;i++){
var _76=_75.children[i];
_71.push(_76);
_72(_76[_6f.idField]);
}
}
};
return _71;
};
function _77(_78){
var _79=_7a(_78);
if(_79.length){
return _79[0];
}else{
return null;
}
};
function _7a(_7b){
var _7c=[];
var _7d=$(_7b).datagrid("getPanel");
_7d.find("div.datagrid-view2 div.datagrid-body tr.datagrid-row-selected").each(function(){
var id=$(this).attr("node-id");
_7c.push(_42(_7b,id));
});
return _7c;
};
function _42(_7e,_7f){
var _80=$.data(_7e,"treegrid").options;
var _81=$.data(_7e,"treegrid").data;
var cc=[_81];
while(cc.length){
var c=cc.shift();
for(var i=0;i<c.length;i++){
var _82=c[i];
if(_82[_80.idField]==_7f){
return _82;
}else{
if(_82["children"]){
cc.push(_82["children"]);
}
}
}
}
return null;
};
function _83(_84,_85){
var _86=$(_84).datagrid("getPanel").find("div.datagrid-body");
var tr=_86.find("tr[node-id="+_85+"]");
tr.addClass("datagrid-row-selected");
tr.find("div.datagrid-cell-check input[type=checkbox]").attr("checked",true);
};
function _87(_88,_89){
var _8a=$(_88).datagrid("getPanel").find("div.datagrid-body");
var tr=_8a.find("tr[node-id="+_89+"]");
tr.removeClass("datagrid-row-selected");
tr.find("div.datagrid-cell-check input[type=checkbox]").attr("checked",false);
};
function _1b(_8b){
var tr=$(_8b).datagrid("getPanel").find("div.datagrid-body tr[node-id]");
tr.addClass("datagrid-row-selected");
tr.find("div.datagrid-cell-check input[type=checkbox]").attr("checked",true);
};
function _1c(_8c){
var tr=$(_8c).datagrid("getPanel").find("div.datagrid-body tr[node-id]");
tr.removeClass("datagrid-row-selected");
tr.find("div.datagrid-cell-check input[type=checkbox]").attr("checked",false);
};
function _8d(_8e,_8f){
var _90=$.data(_8e,"treegrid").options;
var _91=$(_8e).datagrid("getPanel").find("div.datagrid-body");
var row=_42(_8e,_8f);
var tr=_91.find("tr[node-id="+_8f+"]");
var hit=tr.find("span.tree-hit");
if(hit.length==0){
return;
}
if(hit.hasClass("tree-collapsed")){
return;
}
if(_90.onBeforeCollapse.call(_8e,row)==false){
return;
}
hit.removeClass("tree-expanded tree-expanded-hover").addClass("tree-collapsed");
hit.next().removeClass("tree-folder-open");
row.state="closed";
tr=tr.next("tr.treegrid-tr-tree");
var cc=tr.children("td").children("div");
if(_90.animate){
cc.slideUp("normal",function(){
_90.onCollapse.call(_8e,row);
});
}else{
cc.hide();
_90.onCollapse.call(_8e,row);
}
};
function _92(_93,_94){
var _95=$.data(_93,"treegrid").options;
var _96=$(_93).datagrid("getPanel").find("div.datagrid-body");
var tr=_96.find("tr[node-id="+_94+"]");
var hit=tr.find("span.tree-hit");
var row=_42(_93,_94);
if(hit.length==0){
return;
}
if(hit.hasClass("tree-expanded")){
return;
}
if(_95.onBeforeExpand.call(_93,row)==false){
return;
}
hit.removeClass("tree-collapsed tree-collapsed-hover").addClass("tree-expanded");
hit.next().addClass("tree-folder-open");
var _97=tr.next("tr.treegrid-tr-tree");
if(_97.length){
var cc=_97.children("td").children("div");
_98(cc);
}else{
_29(_93,row[_95.idField]);
var _97=tr.next("tr.treegrid-tr-tree");
var cc=_97.children("td").children("div");
cc.hide();
_59(_93,row[_95.idField],{id:row[_95.idField]},true,function(){
_98(cc);
});
}
function _98(cc){
row.state="open";
if(_95.animate){
cc.slideDown("normal",function(){
_6(_93,_94);
_95.onExpand.call(_93,row);
});
}else{
cc.show();
_6(_93,_94);
_95.onExpand.call(_93,row);
}
};
};
function _99(_9a,_9b){
var _9c=$(_9a).datagrid("getPanel").find("div.datagrid-body");
var tr=_9c.find("tr[node-id="+_9b+"]");
var hit=tr.find("span.tree-hit");
if(hit.hasClass("tree-expanded")){
_8d(_9a,_9b);
}else{
_92(_9a,_9b);
}
};
function _9d(_9e,_9f){
var _a0=$.data(_9e,"treegrid").options;
var _a1=_6c(_9e,_9f);
if(_9f){
_a1.unshift(_42(_9e,_9f));
}
for(var i=0;i<_a1.length;i++){
_8d(_9e,_a1[i][_a0.idField]);
}
};
function _a2(_a3,_a4){
var _a5=$.data(_a3,"treegrid").options;
var _a6=_6c(_a3,_a4);
if(_a4){
_a6.unshift(_42(_a3,_a4));
}
for(var i=0;i<_a6.length;i++){
_92(_a3,_a6[i][_a5.idField]);
}
};
function _a7(_a8,_a9){
var _aa=$.data(_a8,"treegrid").options;
var ids=[];
var p=_69(_a8,_a9);
while(p){
var id=p[_aa.idField];
ids.unshift(id);
p=_69(_a8,id);
}
for(var i=0;i<ids.length;i++){
_92(_a8,ids[i]);
}
};
function _ab(_ac,_ad){
var _ae=$.data(_ac,"treegrid").options;
if(_ad.parent){
var _af=$(_ac).datagrid("getPanel").find("div.datagrid-body");
var tr=_af.find("tr[node-id="+_ad.parent+"]");
if(tr.next("tr.treegrid-tr-tree").length==0){
_29(_ac,_ad.parent);
}
var _b0=tr.children("td[field="+_ae.treeField+"]").children("div.datagrid-cell");
var _b1=_b0.children("span.tree-icon");
if(_b1.hasClass("tree-file")){
_b1.removeClass("tree-file").addClass("tree-folder");
var hit=$("<span class=\"tree-hit tree-expanded\"></span>").insertBefore(_b1);
if(hit.prev().length){
hit.prev().remove();
}
}
}
_34(_ac,_ad.parent,_ad.data,true);
};
function _b2(_b3,_b4){
var _b5=$.data(_b3,"treegrid").options;
var _b6=$(_b3).datagrid("getPanel").find("div.datagrid-body");
var tr=_b6.find("tr[node-id="+_b4+"]");
tr.next("tr.treegrid-tr-tree").remove();
tr.remove();
var _b7=del(_b4);
if(_b7){
if(_b7.children.length==0){
tr=_b6.find("tr[node-id="+_b7[_b5.treeField]+"]");
var _b8=tr.children("td[field="+_b5.treeField+"]").children("div.datagrid-cell");
_b8.find(".tree-icon").removeClass("tree-folder").addClass("tree-file");
_b8.find(".tree-hit").remove();
$("<span class=\"tree-indent\"></span>").prependTo(_b8);
}
}
_12(_b3);
function del(id){
var cc;
var _b9=_69(_b3,_b4);
if(_b9){
cc=_b9.children;
}else{
cc=$(_b3).treegrid("getData");
}
for(var i=0;i<cc.length;i++){
if(cc[i][_b5.treeField]==id){
cc.splice(i,1);
break;
}
}
return _b9;
};
};
function _ba(_bb,_bc){
var row=_42(_bb,_bc);
var _bd=$.data(_bb,"treegrid").options;
var _be=$(_bb).datagrid("getPanel").find("div.datagrid-body");
var tr=_be.find("tr[node-id="+_bc+"]");
tr.children("td").each(function(){
var _bf=$(this).find("div.datagrid-cell");
var _c0=$(this).attr("field");
var col=$(_bb).datagrid("getColumnOption",_c0);
if(col){
var val=null;
if(col.formatter){
val=col.formatter(row[_c0],row);
}else{
val=row[_c0]||" ";
}
if(_c0==_bd.treeField){
_bf.children("span.tree-title").html(val);
var cls="tree-icon";
var _c1=_bf.children("span.tree-icon");
if(_c1.hasClass("tree-folder")){
cls+=" tree-folder";
}
if(_c1.hasClass("tree-folder-open")){
cls+=" tree-folder-open";
}
if(_c1.hasClass("tree-file")){
cls+=" tree-file";
}
if(row.iconCls){
cls+=" "+row.iconCls;
}
_c1.attr("class",cls);
}else{
_bf.html(val);
}
}
});
_6(_bb,_bc);
};
$.fn.treegrid=function(_c2,_c3){
if(typeof _c2=="string"){
return $.fn.treegrid.methods[_c2](this,_c3);
}
_c2=_c2||{};
return this.each(function(){
var _c4=$.data(this,"treegrid");
if(_c4){
$.extend(_c4.options,_c2);
}else{
$.data(this,"treegrid",{options:$.extend({},$.fn.treegrid.defaults,$.fn.treegrid.parseOptions(this),_c2),data:[]});
}
_1(this);
_59(this);
});
};
$.fn.treegrid.methods={options:function(jq){
return $.data(jq[0],"treegrid").options;
},resize:function(jq,_c5){
return jq.each(function(){
$(this).datagrid("resize",_c5);
});
},loadData:function(jq,_c6){
return jq.each(function(){
_34(this,null,_c6);
});
},reload:function(jq,id){
return jq.each(function(){
if(id){
var _c7=$(this).treegrid("find",id);
if(_c7.children){
_c7.children.splice(0,_c7.children.length);
}
var _c8=$(this).datagrid("getPanel").find("div.datagrid-body");
var tr=_c8.find("tr[node-id="+id+"]");
tr.next("tr.treegrid-tr-tree").remove();
var hit=tr.find("span.tree-hit");
hit.removeClass("tree-expanded tree-expanded-hover").addClass("tree-collapsed");
_92(this,id);
}else{
_59(this);
}
});
},getData:function(jq){
return $.data(jq[0],"treegrid").data;
},getRoot:function(jq){
return _64(jq[0]);
},getRoots:function(jq){
return _67(jq[0]);
},getParent:function(jq,id){
return _69(jq[0],id);
},getChildren:function(jq,id){
return _6c(jq[0],id);
},getSelected:function(jq){
return _77(jq[0]);
},getSelections:function(jq){
return _7a(jq[0]);
},find:function(jq,id){
return _42(jq[0],id);
},select:function(jq,id){
return jq.each(function(){
_83(this,id);
});
},unselect:function(jq,id){
return jq.each(function(){
_87(this,id);
});
},selectAll:function(jq){
return jq.each(function(){
_1b(this);
});
},unselectAll:function(jq){
return jq.each(function(){
_1c(this);
});
},collapse:function(jq,id){
return jq.each(function(){
_8d(this,id);
});
},expand:function(jq,id){
return jq.each(function(){
_92(this,id);
});
},toggle:function(jq,id){
return jq.each(function(){
_99(this,id);
});
},collapseAll:function(jq,id){
return jq.each(function(){
_9d(this,id);
});
},expandAll:function(jq,id){
return jq.each(function(){
_a2(this,id);
});
},expandTo:function(jq,id){
return jq.each(function(){
_a7(this,id);
});
},append:function(jq,_c9){
return jq.each(function(){
_ab(this,_c9);
});
},remove:function(jq,id){
return jq.each(function(){
_b2(this,id);
});
},refresh:function(jq,id){
return jq.each(function(){
_ba(this,id);
});
}};
$.fn.treegrid.parseOptions=function(_ca){
var t=$(_ca);
return $.extend({},$.fn.datagrid.parseOptions(_ca),{treeField:t.attr("treeField"),animate:(t.attr("animate")?t.attr("animate")=="true":undefined)});
};
$.fn.treegrid.defaults=$.extend({},$.fn.datagrid.defaults,{treeField:null,animate:false,singleSelect:true,onBeforeLoad:function(row,_cb){
},onLoadSuccess:function(row,_cc){
},onLoadError:function(){
},onBeforeCollapse:function(row){
},onCollapse:function(row){
},onBeforeExpand:function(row){
},onExpand:function(row){
},onClickRow:function(row){
},onDblClickRow:function(row){
},onContextMenu:function(e,row){
}});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
$.fn.resizable=function(_1,_2){
if(typeof _1=="string"){
return $.fn.resizable.methods[_1](this,_2);
}
function _3(e){
var _4=e.data;
var _5=$.data(_4.target,"resizable").options;
if(_4.dir.indexOf("e")!=-1){
var _6=_4.startWidth+e.pageX-_4.startX;
_6=Math.min(Math.max(_6,_5.minWidth),_5.maxWidth);
_4.width=_6;
}
if(_4.dir.indexOf("s")!=-1){
var _7=_4.startHeight+e.pageY-_4.startY;
_7=Math.min(Math.max(_7,_5.minHeight),_5.maxHeight);
_4.height=_7;
}
if(_4.dir.indexOf("w")!=-1){
_4.width=_4.startWidth-e.pageX+_4.startX;
if(_4.width>=_5.minWidth&&_4.width<=_5.maxWidth){
_4.left=_4.startLeft+e.pageX-_4.startX;
}
}
if(_4.dir.indexOf("n")!=-1){
_4.height=_4.startHeight-e.pageY+_4.startY;
if(_4.height>=_5.minHeight&&_4.height<=_5.maxHeight){
_4.top=_4.startTop+e.pageY-_4.startY;
}
}
};
function _8(e){
var _9=e.data;
var _a=_9.target;
if($.boxModel==true){
$(_a).css({width:_9.width-_9.deltaWidth,height:_9.height-_9.deltaHeight,left:_9.left,top:_9.top});
}else{
$(_a).css({width:_9.width,height:_9.height,left:_9.left,top:_9.top});
}
};
function _b(e){
$.data(e.data.target,"resizable").options.onStartResize.call(e.data.target,e);
return false;
};
function _c(e){
_3(e);
if($.data(e.data.target,"resizable").options.onResize.call(e.data.target,e)!=false){
_8(e);
}
return false;
};
function _d(e){
_3(e,true);
_8(e);
$(document).unbind(".resizable");
$.data(e.data.target,"resizable").options.onStopResize.call(e.data.target,e);
return false;
};
return this.each(function(){
var _e=null;
var _f=$.data(this,"resizable");
if(_f){
$(this).unbind(".resizable");
_e=$.extend(_f.options,_1||{});
}else{
_e=$.extend({},$.fn.resizable.defaults,_1||{});
}
if(_e.disabled==true){
return;
}
$.data(this,"resizable",{options:_e});
var _10=this;
$(this).bind("mousemove.resizable",_11).bind("mousedown.resizable",_12);
function _11(e){
var dir=_13(e);
if(dir==""){
$(_10).css("cursor","default");
}else{
$(_10).css("cursor",dir+"-resize");
}
};
function _12(e){
var dir=_13(e);
if(dir==""){
return;
}
var _14={target:this,dir:dir,startLeft:_15("left"),startTop:_15("top"),left:_15("left"),top:_15("top"),startX:e.pageX,startY:e.pageY,startWidth:$(_10).outerWidth(),startHeight:$(_10).outerHeight(),width:$(_10).outerWidth(),height:$(_10).outerHeight(),deltaWidth:$(_10).outerWidth()-$(_10).width(),deltaHeight:$(_10).outerHeight()-$(_10).height()};
$(document).bind("mousedown.resizable",_14,_b);
$(document).bind("mousemove.resizable",_14,_c);
$(document).bind("mouseup.resizable",_14,_d);
};
function _13(e){
var dir="";
var _16=$(_10).offset();
var _17=$(_10).outerWidth();
var _18=$(_10).outerHeight();
var _19=_e.edge;
if(e.pageY>_16.top&&e.pageY<_16.top+_19){
dir+="n";
}else{
if(e.pageY<_16.top+_18&&e.pageY>_16.top+_18-_19){
dir+="s";
}
}
if(e.pageX>_16.left&&e.pageX<_16.left+_19){
dir+="w";
}else{
if(e.pageX<_16.left+_17&&e.pageX>_16.left+_17-_19){
dir+="e";
}
}
var _1a=_e.handles.split(",");
for(var i=0;i<_1a.length;i++){
var _1b=_1a[i].replace(/(^\s*)|(\s*$)/g,"");
if(_1b=="all"||_1b==dir){
return dir;
}
}
return "";
};
function _15(css){
var val=parseInt($(_10).css(css));
if(isNaN(val)){
return 0;
}else{
return val;
}
};
});
};
$.fn.resizable.methods={};
$.fn.resizable.defaults={disabled:false,handles:"n, e, s, w, ne, se, sw, nw, all",minWidth:10,minHeight:10,maxWidth:10000,maxHeight:10000,edge:5,onStartResize:function(e){
},onResize:function(e){
},onStopResize:function(e){
}};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2,_3){
var _4=$.data(_2,"window").options;
if(_3){
if(_3.width){
_4.width=_3.width;
}
if(_3.height){
_4.height=_3.height;
}
if(_3.left!=null){
_4.left=_3.left;
}
if(_3.top!=null){
_4.top=_3.top;
}
}
$(_2).panel("resize",_4);
};
function _5(_6,_7){
var _8=$.data(_6,"window");
if(_7){
if(_7.left!=null){
_8.options.left=_7.left;
}
if(_7.top!=null){
_8.options.top=_7.top;
}
}
$(_6).panel("move",_8.options);
if(_8.shadow){
_8.shadow.css({left:_8.options.left,top:_8.options.top});
}
};
function _9(_a){
var _b=$.data(_a,"window");
var _c=$(_a).panel($.extend({},_b.options,{border:false,doSize:true,closed:true,cls:"window",headerCls:"window-header",bodyCls:"window-body",onBeforeDestroy:function(){
if(_b.options.onBeforeDestroy.call(_a)==false){
return false;
}
if(_b.shadow){
_b.shadow.remove();
}
if(_b.mask){
_b.mask.remove();
}
},onClose:function(){
if(_b.shadow){
_b.shadow.hide();
}
if(_b.mask){
_b.mask.hide();
}
_b.options.onClose.call(_a);
},onOpen:function(){
if(_b.mask){
_b.mask.css({display:"block",zIndex:$.fn.window.defaults.zIndex++});
}
if(_b.shadow){
_b.shadow.css({display:"block",zIndex:$.fn.window.defaults.zIndex++,left:_b.options.left,top:_b.options.top,width:_b.window.outerWidth(),height:_b.window.outerHeight()});
}
_b.window.css("z-index",$.fn.window.defaults.zIndex++);
_b.options.onOpen.call(_a);
},onResize:function(_d,_e){
var _f=$(_a).panel("options");
_b.options.width=_f.width;
_b.options.height=_f.height;
_b.options.left=_f.left;
_b.options.top=_f.top;
if(_b.shadow){
_b.shadow.css({left:_b.options.left,top:_b.options.top,width:_b.window.outerWidth(),height:_b.window.outerHeight()});
}
_b.options.onResize.call(_a,_d,_e);
},onMinimize:function(){
if(_b.shadow){
_b.shadow.hide();
}
if(_b.mask){
_b.mask.hide();
}
_b.options.onMinimize.call(_a);
},onBeforeCollapse:function(){
if(_b.options.onBeforeCollapse.call(_a)==false){
return false;
}
if(_b.shadow){
_b.shadow.hide();
}
},onExpand:function(){
if(_b.shadow){
_b.shadow.show();
}
_b.options.onExpand.call(_a);
}}));
_b.window=_c.panel("panel");
if(_b.mask){
_b.mask.remove();
}
if(_b.options.modal==true){
_b.mask=$("<div class=\"window-mask\"></div>").appendTo("body");
_b.mask.css({width:_10().width,height:_10().height,display:"none"});
}
if(_b.shadow){
_b.shadow.remove();
}
if(_b.options.shadow==true){
_b.shadow=$("<div class=\"window-shadow\"></div>").insertAfter(_b.window);
_b.shadow.css({display:"none"});
}
if(_b.options.left==null){
var _11=_b.options.width;
if(isNaN(_11)){
_11=_b.window.outerWidth();
}
_b.options.left=($(window).width()-_11)/2+$(document).scrollLeft();
}
if(_b.options.top==null){
var _12=_b.window.height;
if(isNaN(_12)){
_12=_b.window.outerHeight();
}
_b.options.top=($(window).height()-_12)/2+$(document).scrollTop();
}
_5(_a);
if(_b.options.closed==false){
_c.window("open");
}
};
function _13(_14){
var _15=$.data(_14,"window");
_15.window.draggable({handle:">div.panel-header>div.panel-title",disabled:_15.options.draggable==false,onStartDrag:function(e){
if(_15.mask){
_15.mask.css("z-index",$.fn.window.defaults.zIndex++);
}
if(_15.shadow){
_15.shadow.css("z-index",$.fn.window.defaults.zIndex++);
}
_15.window.css("z-index",$.fn.window.defaults.zIndex++);
if(!_15.proxy){
_15.proxy=$("<div class=\"window-proxy\"></div>").insertAfter(_15.window);
}
_15.proxy.css({display:"none",zIndex:$.fn.window.defaults.zIndex++,left:e.data.left,top:e.data.top,width:($.boxModel==true?(_15.window.outerWidth()-(_15.proxy.outerWidth()-_15.proxy.width())):_15.window.outerWidth()),height:($.boxModel==true?(_15.window.outerHeight()-(_15.proxy.outerHeight()-_15.proxy.height())):_15.window.outerHeight())});
setTimeout(function(){
if(_15.proxy){
_15.proxy.show();
}
},500);
},onDrag:function(e){
_15.proxy.css({display:"block",left:e.data.left,top:e.data.top});
return false;
},onStopDrag:function(e){
_15.options.left=e.data.left;
_15.options.top=e.data.top;
$(_14).window("move");
_15.proxy.remove();
_15.proxy=null;
}});
_15.window.resizable({disabled:_15.options.resizable==false,onStartResize:function(e){
if(!_15.proxy){
_15.proxy=$("<div class=\"window-proxy\"></div>").insertAfter(_15.window);
}
_15.proxy.css({zIndex:$.fn.window.defaults.zIndex++,left:e.data.left,top:e.data.top,width:($.boxModel==true?(e.data.width-(_15.proxy.outerWidth()-_15.proxy.width())):e.data.width),height:($.boxModel==true?(e.data.height-(_15.proxy.outerHeight()-_15.proxy.height())):e.data.height)});
},onResize:function(e){
_15.proxy.css({left:e.data.left,top:e.data.top,width:($.boxModel==true?(e.data.width-(_15.proxy.outerWidth()-_15.proxy.width())):e.data.width),height:($.boxModel==true?(e.data.height-(_15.proxy.outerHeight()-_15.proxy.height())):e.data.height)});
return false;
},onStopResize:function(e){
_15.options.left=e.data.left;
_15.options.top=e.data.top;
_15.options.width=e.data.width;
_15.options.height=e.data.height;
_1(_14);
_15.proxy.remove();
_15.proxy=null;
}});
};
function _10(){
if(document.compatMode=="BackCompat"){
return {width:Math.max(document.body.scrollWidth,document.body.clientWidth),height:Math.max(document.body.scrollHeight,document.body.clientHeight)};
}else{
return {width:Math.max(document.documentElement.scrollWidth,document.documentElement.clientWidth),height:Math.max(document.documentElement.scrollHeight,document.documentElement.clientHeight)};
}
};
$(window).resize(function(){
$(".window-mask").css({width:$(window).width(),height:$(window).height()});
setTimeout(function(){
$(".window-mask").css({width:_10().width,height:_10().height});
},50);
});
$.fn.window=function(_16,_17){
if(typeof _16=="string"){
var _18=$.fn.window.methods[_16];
if(_18){
return _18(this,_17);
}else{
return this.panel(_16,_17);
}
}
_16=_16||{};
return this.each(function(){
var _19=$.data(this,"window");
if(_19){
$.extend(_19.options,_16);
}else{
_19=$.data(this,"window",{options:$.extend({},$.fn.window.defaults,$.fn.window.parseOptions(this),_16)});
$(this).appendTo("body");
}
_9(this);
_13(this);
});
};
$.fn.window.methods={options:function(jq){
var _1a=jq.panel("options");
var _1b=$.data(jq[0],"window").options;
return $.extend(_1b,{closed:_1a.closed,collapsed:_1a.collapsed,minimized:_1a.minimized,maximized:_1a.maximized});
},window:function(jq){
return $.data(jq[0],"window").window;
},resize:function(jq,_1c){
return jq.each(function(){
_1(this,_1c);
});
},move:function(jq,_1d){
return jq.each(function(){
_5(this,_1d);
});
}};
$.fn.window.parseOptions=function(_1e){
var t=$(_1e);
return $.extend({},$.fn.panel.parseOptions(_1e),{draggable:(t.attr("draggable")?t.attr("draggable")=="true":undefined),resizable:(t.attr("resizable")?t.attr("resizable")=="true":undefined),shadow:(t.attr("shadow")?t.attr("shadow")=="true":undefined),modal:(t.attr("modal")?t.attr("modal")=="true":undefined)});
};
$.fn.window.defaults=$.extend({},$.fn.panel.defaults,{zIndex:9000,draggable:true,resizable:true,shadow:true,modal:false,title:"New Window",collapsible:true,minimizable:true,maximizable:true,closable:true,closed:false});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$(">div.tabs-header",_2);
var _4=0;
$("ul.tabs li",_3).each(function(){
_4+=$(this).outerWidth(true);
});
var _5=$("div.tabs-wrap",_3).width();
var _6=parseInt($("ul.tabs",_3).css("padding-left"));
return _4-_5+_6;
};
function _7(_8){
var _9=$.data(_8,"tabs").options;
var _a=$(_8).children("div.tabs-header");
var _b=_a.children("div.tabs-tool");
var _c=_a.children("div.tabs-scroller-left");
var _d=_a.children("div.tabs-scroller-right");
var _e=_a.children("div.tabs-wrap");
var _f=($.boxModel==true?(_a.outerHeight()-(_b.outerHeight()-_b.height())):_a.outerHeight());
if(_9.plain){
_f-=2;
}
_b.height(_f);
var _10=0;
$("ul.tabs li",_a).each(function(){
_10+=$(this).outerWidth(true);
});
var _11=_a.width()-_b.outerWidth();
if(_10>_11){
_c.show();
_d.show();
_b.css("right",_d.outerWidth());
_e.css({marginLeft:_c.outerWidth(),marginRight:_d.outerWidth()+_b.outerWidth(),left:0,width:_11-_c.outerWidth()-_d.outerWidth()});
}else{
_c.hide();
_d.hide();
_b.css("right",0);
_e.css({marginLeft:0,marginRight:_b.outerWidth(),left:0,width:_11});
_e.scrollLeft(0);
}
};
function _12(_13){
var _14=$.data(_13,"tabs").options;
var _15=$(_13).children("div.tabs-header");
var _16=_15.children("div.tabs-tool");
_16.remove();
if(_14.tools){
_16=$("<div class=\"tabs-tool\"></div>").appendTo(_15);
for(var i=0;i<_14.tools.length;i++){
var _17=$("<a href=\"javascript:void(0);\"></a>").appendTo(_16);
_17[0].onclick=eval(_14.tools[i].handler||function(){
});
_17.linkbutton($.extend({},_14.tools[i],{plain:true}));
}
}
};
function _18(_19){
var _1a=$.data(_19,"tabs").options;
var cc=$(_19);
if(_1a.fit==true){
var p=cc.parent();
_1a.width=p.width();
_1a.height=p.height();
}
cc.width(_1a.width).height(_1a.height);
var _1b=$(">div.tabs-header",_19);
if($.boxModel==true){
_1b.width(_1a.width-(_1b.outerWidth()-_1b.width()));
}else{
_1b.width(_1a.width);
}
_7(_19);
var _1c=$(">div.tabs-panels",_19);
var _1d=_1a.height;
if(!isNaN(_1d)){
if($.boxModel==true){
var _1e=_1c.outerHeight()-_1c.height();
_1c.css("height",(_1d-_1b.outerHeight()-_1e)||"auto");
}else{
_1c.css("height",_1d-_1b.outerHeight());
}
}else{
_1c.height("auto");
}
var _1f=_1a.width;
if(!isNaN(_1f)){
if($.boxModel==true){
_1c.width(_1f-(_1c.outerWidth()-_1c.width()));
}else{
_1c.width(_1f);
}
}else{
_1c.width("auto");
}
};
function _20(_21){
var _22=$.data(_21,"tabs").options;
var tab=_23(_21);
if(tab){
var _24=$(_21).find(">div.tabs-panels");
var _25=_22.width=="auto"?"auto":_24.width();
var _26=_22.height=="auto"?"auto":_24.height();
tab.panel("resize",{width:_25,height:_26});
}
};
function _27(_28){
var cc=$(_28);
cc.addClass("tabs-container");
cc.wrapInner("<div class=\"tabs-panels\"/>");
$("<div class=\"tabs-header\">"+"<div class=\"tabs-scroller-left\"></div>"+"<div class=\"tabs-scroller-right\"></div>"+"<div class=\"tabs-wrap\">"+"<ul class=\"tabs\"></ul>"+"</div>"+"</div>").prependTo(_28);
var _29=[];
var _2a=$(">div.tabs-header",_28);
$(">div.tabs-panels>div",_28).each(function(){
var pp=$(this);
_29.push(pp);
_37(_28,pp);
});
$(".tabs-scroller-left, .tabs-scroller-right",_2a).hover(function(){
$(this).addClass("tabs-scroller-over");
},function(){
$(this).removeClass("tabs-scroller-over");
});
cc.bind("_resize",function(){
var _2b=$.data(_28,"tabs").options;
if(_2b.fit==true){
_18(_28);
_20(_28);
}
return false;
});
return _29;
};
function _2c(_2d){
var _2e=$.data(_2d,"tabs").options;
var _2f=$(">div.tabs-header",_2d);
var _30=$(">div.tabs-panels",_2d);
if(_2e.plain==true){
_2f.addClass("tabs-header-plain");
}else{
_2f.removeClass("tabs-header-plain");
}
if(_2e.border==true){
_2f.removeClass("tabs-header-noborder");
_30.removeClass("tabs-panels-noborder");
}else{
_2f.addClass("tabs-header-noborder");
_30.addClass("tabs-panels-noborder");
}
$(".tabs-scroller-left",_2f).unbind(".tabs").bind("click.tabs",function(){
var _31=$(".tabs-wrap",_2f);
var pos=_31.scrollLeft()-_2e.scrollIncrement;
_31.animate({scrollLeft:pos},_2e.scrollDuration);
});
$(".tabs-scroller-right",_2f).unbind(".tabs").bind("click.tabs",function(){
var _32=$(".tabs-wrap",_2f);
var pos=Math.min(_32.scrollLeft()+_2e.scrollIncrement,_1(_2d));
_32.animate({scrollLeft:pos},_2e.scrollDuration);
});
var _33=$.data(_2d,"tabs").tabs;
for(var i=0,len=_33.length;i<len;i++){
var _34=_33[i];
var tab=_34.panel("options").tab;
var _35=_34.panel("options").title;
tab.unbind(".tabs").bind("click.tabs",{title:_35},function(e){
_45(_2d,e.data.title);
}).bind("contextmenu.tabs",{title:_35},function(e){
_2e.onContextMenu.call(_2d,e,e.data.title);
});
tab.find("a.tabs-close").unbind(".tabs").bind("click.tabs",{title:_35},function(e){
_36(_2d,e.data.title);
return false;
});
}
};
function _37(_38,pp,_39){
_39=_39||{};
pp.panel($.extend({},{selected:pp.attr("selected")=="true"},_39,{border:false,noheader:true,closed:true,doSize:false,iconCls:(_39.icon?_39.icon:undefined),onLoad:function(){
$.data(_38,"tabs").options.onLoad.call(_38,pp);
}}));
var _3a=pp.panel("options");
var _3b=$(">div.tabs-header",_38);
var _3c=$("ul.tabs",_3b);
var tab=$("<li></li>").appendTo(_3c);
var _3d=$("<a href=\"javascript:void(0)\" class=\"tabs-inner\"></a>").appendTo(tab);
var _3e=$("<span class=\"tabs-title\"></span>").html(_3a.title).appendTo(_3d);
var _3f=$("<span class=\"tabs-icon\"></span>").appendTo(_3d);
if(_3a.closable){
_3e.addClass("tabs-closable");
$("<a href=\"javascript:void(0)\" class=\"tabs-close\"></a>").appendTo(tab);
}
if(_3a.iconCls){
_3e.addClass("tabs-with-icon");
_3f.addClass(_3a.iconCls);
}
_3a.tab=tab;
};
function _40(_41,_42){
var _43=$.data(_41,"tabs").options;
var _44=$.data(_41,"tabs").tabs;
var pp=$("<div></div>").appendTo($(">div.tabs-panels",_41));
_44.push(pp);
_37(_41,pp,_42);
_43.onAdd.call(_41,_42.title);
_7(_41);
_2c(_41);
_45(_41,_42.title);
};
function _46(_47,_48){
var _49=$.data(_47,"tabs").selectHis;
var pp=_48.tab;
var _4a=pp.panel("options").title;
pp.panel($.extend({},_48.options,{iconCls:(_48.options.icon?_48.options.icon:undefined)}));
var _4b=pp.panel("options");
var tab=_4b.tab;
tab.find("span.tabs-icon").attr("class","tabs-icon");
tab.find("a.tabs-close").remove();
tab.find("span.tabs-title").html(_4b.title);
if(_4b.closable){
tab.find("span.tabs-title").addClass("tabs-closable");
$("<a href=\"javascript:void(0)\" class=\"tabs-close\"></a>").appendTo(tab);
}else{
tab.find("span.tabs-title").removeClass("tabs-closable");
}
if(_4b.iconCls){
tab.find("span.tabs-title").addClass("tabs-with-icon");
tab.find("span.tabs-icon").addClass(_4b.iconCls);
}else{
tab.find("span.tabs-title").removeClass("tabs-with-icon");
}
if(_4a!=_4b.title){
for(var i=0;i<_49.length;i++){
if(_49[i]==_4a){
_49[i]=_4b.title;
}
}
}
_2c(_47);
$.data(_47,"tabs").options.onUpdate.call(_47,_4b.title);
};
function _36(_4c,_4d){
var _4e=$.data(_4c,"tabs").options;
var _4f=$.data(_4c,"tabs").tabs;
var _50=$.data(_4c,"tabs").selectHis;
if(!_51(_4c,_4d)){
return;
}
if(_4e.onBeforeClose.call(_4c,_4d)==false){
return;
}
var tab=_52(_4c,_4d,true);
tab.panel("options").tab.remove();
tab.panel("destroy");
_4e.onClose.call(_4c,_4d);
_7(_4c);
for(var i=0;i<_50.length;i++){
if(_50[i]==_4d){
_50.splice(i,1);
i--;
}
}
var _53=_50.pop();
if(_53){
_45(_4c,_53);
}else{
if(_4f.length){
_45(_4c,_4f[0].panel("options").title);
}
}
};
function _52(_54,_55,_56){
var _57=$.data(_54,"tabs").tabs;
for(var i=0;i<_57.length;i++){
var tab=_57[i];
if(tab.panel("options").title==_55){
if(_56){
_57.splice(i,1);
}
return tab;
}
}
return null;
};
function _23(_58){
var _59=$.data(_58,"tabs").tabs;
for(var i=0;i<_59.length;i++){
var tab=_59[i];
if(tab.panel("options").closed==false){
return tab;
}
}
return null;
};
function _5a(_5b){
var _5c=$.data(_5b,"tabs").tabs;
for(var i=0;i<_5c.length;i++){
var tab=_5c[i];
if(tab.panel("options").selected){
_45(_5b,tab.panel("options").title);
return;
}
}
if(_5c.length){
_45(_5b,_5c[0].panel("options").title);
}
};
function _45(_5d,_5e){
var _5f=$.data(_5d,"tabs").options;
var _60=$.data(_5d,"tabs").tabs;
var _61=$.data(_5d,"tabs").selectHis;
if(_60.length==0){
return;
}
var _62=_52(_5d,_5e);
if(!_62){
return;
}
var _63=_23(_5d);
if(_63){
_63.panel("close");
_63.panel("options").tab.removeClass("tabs-selected");
}
_62.panel("open");
var tab=_62.panel("options").tab;
tab.addClass("tabs-selected");
var _64=$(_5d).find(">div.tabs-header div.tabs-wrap");
var _65=tab.position().left+_64.scrollLeft();
var _66=_65-_64.scrollLeft();
var _67=_66+tab.outerWidth();
if(_66<0||_67>_64.innerWidth()){
var pos=Math.min(_65-(_64.width()-tab.width())/2,_1(_5d));
_64.animate({scrollLeft:pos},_5f.scrollDuration);
}else{
var pos=Math.min(_64.scrollLeft(),_1(_5d));
_64.animate({scrollLeft:pos},_5f.scrollDuration);
}
_20(_5d);
_61.push(_5e);
_5f.onSelect.call(_5d,_5e);
};
function _51(_68,_69){
return _52(_68,_69)!=null;
};
$.fn.tabs=function(_6a,_6b){
if(typeof _6a=="string"){
return $.fn.tabs.methods[_6a](this,_6b);
}
_6a=_6a||{};
return this.each(function(){
var _6c=$.data(this,"tabs");
var _6d;
if(_6c){
_6d=$.extend(_6c.options,_6a);
_6c.options=_6d;
}else{
$.data(this,"tabs",{options:$.extend({},$.fn.tabs.defaults,$.fn.tabs.parseOptions(this),_6a),tabs:_27(this),selectHis:[]});
}
_12(this);
_2c(this);
_18(this);
var _6e=this;
setTimeout(function(){
_5a(_6e);
},0);
});
};
$.fn.tabs.methods={options:function(jq){
return $.data(jq[0],"tabs").options;
},tabs:function(jq){
return $.data(jq[0],"tabs").tabs;
},resize:function(jq){
return jq.each(function(){
_18(this);
_20(this);
});
},add:function(jq,_6f){
return jq.each(function(){
_40(this,_6f);
});
},close:function(jq,_70){
return jq.each(function(){
_36(this,_70);
});
},getTab:function(jq,_71){
return _52(jq[0],_71);
},getSelected:function(jq){
return _23(jq[0]);
},select:function(jq,_72){
return jq.each(function(){
_45(this,_72);
});
},exists:function(jq,_73){
return _51(jq[0],_73);
},update:function(jq,_74){
return jq.each(function(){
_46(this,_74);
});
}};
$.fn.tabs.parseOptions=function(_75){
var t=$(_75);
return {width:(parseInt(_75.style.width)||undefined),height:(parseInt(_75.style.height)||undefined),fit:(t.attr("fit")?t.attr("fit")=="true":undefined),border:(t.attr("border")?t.attr("border")=="true":undefined),plain:(t.attr("plain")?t.attr("plain")=="true":undefined)};
};
$.fn.tabs.defaults={width:"auto",height:"auto",plain:false,fit:false,border:true,tools:null,scrollIncrement:100,scrollDuration:400,onLoad:function(_76){
},onSelect:function(_77){
},onBeforeClose:function(_78){
},onClose:function(_79){
},onAdd:function(_7a){
},onUpdate:function(_7b){
},onContextMenu:function(e,_7c){
}};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
$(_2).addClass("validatebox-text");
};
function _3(_4){
var _5=$.data(_4,"validatebox").tip;
if(_5){
_5.remove();
}
$(_4).unbind();
$(_4).remove();
};
function _6(_7){
var _8=$(_7);
var _9=$.data(_7,"validatebox");
_9.validating=false;
_8.unbind(".validatebox").bind("focus.validatebox",function(){
_9.validating=true;
(function(){
if(_9.validating){
_11(_7);
setTimeout(arguments.callee,200);
}
})();
}).bind("blur.validatebox",function(){
_9.validating=false;
_a(_7);
}).bind("mouseenter.validatebox",function(){
if(_8.hasClass("validatebox-invalid")){
_b(_7);
}
}).bind("mouseleave.validatebox",function(){
_a(_7);
});
};
function _b(_c){
var _d=$(_c);
var _e=$.data(_c,"validatebox").message;
var _f=$.data(_c,"validatebox").tip;
if(!_f){
_f=$("<div class=\"validatebox-tip\">"+"<span class=\"validatebox-tip-content\">"+"</span>"+"<span class=\"validatebox-tip-pointer\">"+"</span>"+"</div>").appendTo("body");
$.data(_c,"validatebox").tip=_f;
}
_f.find(".validatebox-tip-content").html(_e);
_f.css({display:"block",left:_d.offset().left+_d.outerWidth(),top:_d.offset().top});
};
function _a(_10){
var tip=$.data(_10,"validatebox").tip;
if(tip){
tip.remove();
$.data(_10,"validatebox").tip=null;
}
};
function _11(_12){
var _13=$.data(_12,"validatebox").options;
var tip=$.data(_12,"validatebox").tip;
var box=$(_12);
var _14=box.val();
function _15(msg){
$.data(_12,"validatebox").message=msg;
};
var _16=box.attr("disabled");
if(_16==true||_16=="true"){
return true;
}
if(_13.required){
if(_14==""){
box.addClass("validatebox-invalid");
_15(_13.missingMessage);
_b(_12);
return false;
}
}
if(_13.validType){
var _17=/([a-zA-Z_]+)(.*)/.exec(_13.validType);
var _18=_13.rules[_17[1]];
if(_14&&_18){
var _19=eval(_17[2]);
if(!_18["validator"](_14,_19)){
box.addClass("validatebox-invalid");
var _1a=_18["message"];
if(_19){
for(var i=0;i<_19.length;i++){
_1a=_1a.replace(new RegExp("\\{"+i+"\\}","g"),_19[i]);
}
}
_15(_13.invalidMessage||_1a);
_b(_12);
return false;
}
}
}
box.removeClass("validatebox-invalid");
_a(_12);
return true;
};
$.fn.validatebox=function(_1b,_1c){
if(typeof _1b=="string"){
return $.fn.validatebox.methods[_1b](this,_1c);
}
_1b=_1b||{};
return this.each(function(){
var _1d=$.data(this,"validatebox");
if(_1d){
$.extend(_1d.options,_1b);
}else{
_1(this);
$.data(this,"validatebox",{options:$.extend({},$.fn.validatebox.defaults,$.fn.validatebox.parseOptions(this),_1b)});
}
_6(this);
});
};
$.fn.validatebox.methods={destroy:function(jq){
return jq.each(function(){
_3(this);
});
},validate:function(jq){
return jq.each(function(){
_11(this);
});
},isValid:function(jq){
return _11(jq[0]);
}};
$.fn.validatebox.parseOptions=function(_1e){
var t=$(_1e);
return {required:(t.attr("required")?(t.attr("required")=="true"||t.attr("required")==true):undefined),validType:(t.attr("validType")||undefined),missingMessage:(t.attr("missingMessage")||undefined),invalidMessage:(t.attr("invalidMessage")||undefined)};
};
$.fn.validatebox.defaults={required:false,validType:null,missingMessage:"This field is required.",invalidMessage:null,rules:{email:{validator:function(_1f){
return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(_1f);
},message:"Please enter a valid email address."},url:{validator:function(_20){
return /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(_20);
},message:"Please enter a valid URL."},length:{validator:function(_21,_22){
var len=$.trim(_21).length;
return len>=_22[0]&&len<=_22[1];
},message:"Please enter a value between {0} and {1}."}}};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
$(_2).addClass("droppable");
$(_2).bind("_dragenter",function(e,_3){
$.data(_2,"droppable").options.onDragEnter.apply(_2,[e,_3]);
});
$(_2).bind("_dragleave",function(e,_4){
$.data(_2,"droppable").options.onDragLeave.apply(_2,[e,_4]);
});
$(_2).bind("_dragover",function(e,_5){
$.data(_2,"droppable").options.onDragOver.apply(_2,[e,_5]);
});
$(_2).bind("_drop",function(e,_6){
$.data(_2,"droppable").options.onDrop.apply(_2,[e,_6]);
});
};
$.fn.droppable=function(_7,_8){
if(typeof _7=="string"){
return $.fn.droppable.methods[_7](this,_8);
}
_7=_7||{};
return this.each(function(){
var _9=$.data(this,"droppable");
if(_9){
$.extend(_9.options,_7);
}else{
_1(this);
$.data(this,"droppable",{options:$.extend({},$.fn.droppable.defaults,_7)});
}
});
};
$.fn.droppable.methods={};
$.fn.droppable.defaults={accept:null,onDragEnter:function(e,_a){
},onDragOver:function(e,_b){
},onDragLeave:function(e,_c){
},onDrop:function(e,_d){
}};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2,_3){
_3=_3||{};
if(_3.onSubmit){
if(_3.onSubmit.call(_2)==false){
return;
}
}
var _4=$(_2);
if(_3.url){
_4.attr("action",_3.url);
}
var _5="easyui_frame_"+(new Date().getTime());
var _6=$("<iframe id="+_5+" name="+_5+"></iframe>").attr("src",window.ActiveXObject?"javascript:false":"about:blank").css({position:"absolute",top:-1000,left:-1000});
var t=_4.attr("target"),a=_4.attr("action");
_4.attr("target",_5);
try{
_6.appendTo("body");
_6.bind("load",cb);
_4[0].submit();
}
finally{
_4.attr("action",a);
t?_4.attr("target",t):_4.removeAttr("target");
}
var _7=10;
function cb(){
_6.unbind();
var _8=$("#"+_5).contents().find("body");
var _9=_8.html();
if(_9==""){
if(--_7){
setTimeout(cb,100);
return;
}
return;
}
var ta=_8.find(">textarea");
if(ta.length){
_9=ta.val();
}else{
var _a=_8.find(">pre");
if(_a.length){
_9=_a.html();
}
}
if(_3.success){
_3.success(_9);
}
setTimeout(function(){
_6.unbind();
_6.remove();
},100);
};
};
function _b(_c,_d){
if(!$.data(_c,"form")){
$.data(_c,"form",{options:$.extend({},$.fn.form.defaults)});
}
var _e=$.data(_c,"form").options;
if(typeof _d=="string"){
var _f={};
if(_e.onBeforeLoad.call(_c,_f)==false){
return;
}
$.ajax({url:_d,data:_f,dataType:"json",success:function(_10){
_11(_10);
},error:function(){
_e.onLoadError.apply(_c,arguments);
}});
}else{
_11(_d);
}
function _11(_12){
var _13=$(_c);
for(var _14 in _12){
var val=_12[_14];
$("input[name="+_14+"]",_13).val(val);
$("textarea[name="+_14+"]",_13).val(val);
$("select[name="+_14+"]",_13).val(val);
var cc=["combo","combobox","combotree","combogrid"];
for(var i=0;i<cc.length;i++){
_15(cc[i],_14,val);
}
}
_e.onLoadSuccess.call(_c,_12);
_1f(_c);
};
function _15(_16,_17,val){
var _18=$(_c);
var c=_18.find("."+_16+"-f[comboName="+_17+"]");
if(c.length&&c[_16]){
if(c[_16]("options").multiple){
c[_16]("setValues",val);
}else{
c[_16]("setValue",val);
}
}
};
};
function _19(_1a){
$("input,select,textarea",_1a).each(function(){
var t=this.type,tag=this.tagName.toLowerCase();
if(t=="text"||t=="hidden"||t=="password"||tag=="textarea"){
this.value="";
}else{
if(t=="checkbox"||t=="radio"){
this.checked=false;
}else{
if(tag=="select"){
this.selectedIndex=-1;
}
}
}
});
if($.fn.combo){
$(".combo-f",_1a).combo("clear");
}
if($.fn.combobox){
$(".combobox-f",_1a).combobox("clear");
}
if($.fn.combotree){
$(".combotree-f",_1a).combotree("clear");
}
if($.fn.combogrid){
$(".combogrid-f",_1a).combogrid("clear");
}
};
function _1b(_1c){
var _1d=$.data(_1c,"form").options;
var _1e=$(_1c);
_1e.unbind(".form").bind("submit.form",function(){
setTimeout(function(){
_1(_1c,_1d);
},0);
return false;
});
};
function _1f(_20){
if($.fn.validatebox){
var box=$(".validatebox-text",_20);
if(box.length){
box.validatebox("validate");
box.trigger("blur");
var _21=$(".validatebox-invalid:first",_20).focus();
return _21.length==0;
}
}
return true;
};
$.fn.form=function(_22,_23){
if(typeof _22=="string"){
return $.fn.form.methods[_22](this,_23);
}
_22=_22||{};
return this.each(function(){
if(!$.data(this,"form")){
$.data(this,"form",{options:$.extend({},$.fn.form.defaults,_22)});
}
_1b(this);
});
};
$.fn.form.methods={submit:function(jq,_24){
return jq.each(function(){
_1(this,$.extend({},$.fn.form.defaults,_24||{}));
});
},load:function(jq,_25){
return jq.each(function(){
_b(this,_25);
});
},clear:function(jq){
return jq.each(function(){
_19(this);
});
},validate:function(jq){
return _1f(jq[0]);
}};
$.fn.form.defaults={url:null,onSubmit:function(){
},success:function(_26){
},onBeforeLoad:function(_27){
},onLoadSuccess:function(_28){
},onLoadError:function(){
}};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(el,_2,_3,_4){
var _5=$(el).window("window");
if(!_5){
return;
}
switch(_2){
case null:
_5.show();
break;
case "slide":
_5.slideDown(_3);
break;
case "fade":
_5.fadeIn(_3);
break;
case "show":
_5.show(_3);
break;
}
var _6=null;
if(_4>0){
_6=setTimeout(function(){
_7(el,_2,_3);
},_4);
}
_5.hover(function(){
if(_6){
clearTimeout(_6);
}
},function(){
if(_4>0){
_6=setTimeout(function(){
_7(el,_2,_3);
},_4);
}
});
};
function _7(el,_8,_9){
if(el.locked==true){
return;
}
el.locked=true;
var _a=$(el).window("window");
if(!_a){
return;
}
switch(_8){
case null:
_a.hide();
break;
case "slide":
_a.slideUp(_9);
break;
case "fade":
_a.fadeOut(_9);
break;
case "show":
_a.hide(_9);
break;
}
setTimeout(function(){
$(el).window("destroy");
},_9);
};
function _b(_c,_d,_e){
var _f=$("<div class=\"messager-body\"></div>").appendTo("body");
_f.append(_d);
if(_e){
var tb=$("<div class=\"messager-button\"></div>").appendTo(_f);
for(var _10 in _e){
$("<a></a>").attr("href","javascript:void(0)").text(_10).css("margin-left",10).bind("click",eval(_e[_10])).appendTo(tb).linkbutton();
}
}
_f.window({title:_c,width:300,height:"auto",modal:true,collapsible:false,minimizable:false,maximizable:false,resizable:false,onClose:function(){
setTimeout(function(){
_f.window("destroy");
},100);
}});
return _f;
};
$.messager={show:function(_11){
var _12=$.extend({showType:"slide",showSpeed:600,width:250,height:100,msg:"",title:"",timeout:4000},_11||{});
var win=$("<div class=\"messager-body\"></div>").html(_12.msg).appendTo("body");
win.window({title:_12.title,width:_12.width,height:_12.height,collapsible:false,minimizable:false,maximizable:false,shadow:false,draggable:false,resizable:false,closed:true,onBeforeOpen:function(){
_1(this,_12.showType,_12.showSpeed,_12.timeout);
return false;
},onBeforeClose:function(){
_7(this,_12.showType,_12.showSpeed);
return false;
}});
win.window("window").css({left:null,top:null,right:0,zIndex:$.fn.window.defaults.zIndex++,bottom:-document.body.scrollTop-document.documentElement.scrollTop});
win.window("open");
},alert:function(_13,msg,_14,fn){
var _15="<div>"+msg+"</div>";
switch(_14){
case "error":
_15="<div class=\"messager-icon messager-error\"></div>"+_15;
break;
case "info":
_15="<div class=\"messager-icon messager-info\"></div>"+_15;
break;
case "question":
_15="<div class=\"messager-icon messager-question\"></div>"+_15;
break;
case "warning":
_15="<div class=\"messager-icon messager-warning\"></div>"+_15;
break;
}
_15+="<div style=\"clear:both;\"/>";
var _16={};
_16[$.messager.defaults.ok]=function(){
win.dialog({closed:true});
if(fn){
fn();
return false;
}
};
_16[$.messager.defaults.ok]=function(){
win.window("close");
if(fn){
fn();
return false;
}
};
var win=_b(_13,_15,_16);
},confirm:function(_17,msg,fn){
var _18="<div class=\"messager-icon messager-question\"></div>"+"<div>"+msg+"</div>"+"<div style=\"clear:both;\"/>";
var _19={};
_19[$.messager.defaults.ok]=function(){
win.window("close");
if(fn){
fn(true);
return false;
}
};
_19[$.messager.defaults.cancel]=function(){
win.window("close");
if(fn){
fn(false);
return false;
}
};
var win=_b(_17,_18,_19);
},prompt:function(_1a,msg,fn){
var _1b="<div class=\"messager-icon messager-question\"></div>"+"<div>"+msg+"</div>"+"<br/>"+"<input class=\"messager-input\" type=\"text\"/>"+"<div style=\"clear:both;\"/>";
var _1c={};
_1c[$.messager.defaults.ok]=function(){
win.window("close");
if(fn){
fn($(".messager-input",win).val());
return false;
}
};
_1c[$.messager.defaults.cancel]=function(){
win.window("close");
if(fn){
fn();
return false;
}
};
var win=_b(_1a,_1b,_1c);
}};
$.messager.defaults={ok:"Ok",cancel:"Cancel"};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$(_2);
_3.addClass("tree");
return _3;
};
function _4(_5){
var _6=[];
_7(_6,$(_5));
function _7(aa,_8){
_8.children("li").each(function(){
var _9=$(this);
var _a={};
_a.text=_9.children("span").html();
if(!_a.text){
_a.text=_9.html();
}
_a.id=_9.attr("id");
_a.iconCls=_9.attr("iconCls")||_9.attr("icon");
_a.checked=_9.attr("checked")=="true";
_a.state=_9.attr("state")||"open";
var _b=_9.children("ul");
if(_b.length){
_a.children=[];
_7(_a.children,_b);
}
aa.push(_a);
});
};
return _6;
};
function _c(_d){
var _e=$.data(_d,"tree").options;
var _f=$.data(_d,"tree").tree;
$("div.tree-node",_f).unbind(".tree").bind("dblclick.tree",function(){
_ae(_d,this);
_e.onDblClick.call(_d,_8b(_d));
}).bind("click.tree",function(){
_ae(_d,this);
_e.onClick.call(_d,_8b(_d));
}).bind("mouseenter.tree",function(){
$(this).addClass("tree-node-hover");
return false;
}).bind("mouseleave.tree",function(){
$(this).removeClass("tree-node-hover");
return false;
}).bind("contextmenu.tree",function(e){
_e.onContextMenu.call(_d,e,_33(_d,this));
});
$("span.tree-hit",_f).unbind(".tree").bind("click.tree",function(){
var _10=$(this).parent();
_68(_d,_10[0]);
return false;
}).bind("mouseenter.tree",function(){
if($(this).hasClass("tree-expanded")){
$(this).addClass("tree-expanded-hover");
}else{
$(this).addClass("tree-collapsed-hover");
}
}).bind("mouseleave.tree",function(){
if($(this).hasClass("tree-expanded")){
$(this).removeClass("tree-expanded-hover");
}else{
$(this).removeClass("tree-collapsed-hover");
}
}).bind("mousedown.tree",function(){
return false;
});
$("span.tree-checkbox",_f).unbind(".tree").bind("click.tree",function(){
var _11=$(this).parent();
_2a(_d,_11[0],!$(this).hasClass("tree-checkbox1"));
return false;
}).bind("mousedown.tree",function(){
return false;
});
};
function _12(_13){
var _14=$.data(_13,"tree").options;
var _15=$.data(_13,"tree").tree;
if(!_14.dnd){
_15.find("div.tree-node").draggable("disable");
_15.find("div.tree-node").css("cursor","pointer");
return;
}
_15.find("div.tree-node").draggable({revert:true,cursor:"pointer",proxy:function(_16){
var p=$("<div class=\"tree-node-proxy tree-dnd-no\"></div>").appendTo("body");
p.html($(_16).find(".tree-title").html());
p.hide();
return p;
},deltaX:15,deltaY:15,onStartDrag:function(){
$(this).draggable("proxy").css({left:-10000,top:-10000});
},onDrag:function(e){
$(this).draggable("proxy").show();
this.pageY=e.pageY;
}}).droppable({onDragOver:function(e,_17){
var _18=_17.pageY;
var top=$(this).offset().top;
var _19=top+$(this).outerHeight();
$(_17).draggable("proxy").removeClass("tree-dnd-no").addClass("tree-dnd-yes");
$(this).removeClass("tree-node-append tree-node-top tree-node-bottom");
if(_18>top+(_19-top)/2){
if(_19-_18<5){
$(this).addClass("tree-node-bottom");
}else{
$(this).addClass("tree-node-append");
}
}else{
if(_18-top<5){
$(this).addClass("tree-node-top");
}else{
$(this).addClass("tree-node-append");
}
}
},onDragLeave:function(e,_1a){
$(_1a).draggable("proxy").removeClass("tree-dnd-yes").addClass("tree-dnd-no");
$(this).removeClass("tree-node-append tree-node-top tree-node-bottom");
},onDrop:function(e,_1b){
var _1c=this;
var _1d,_1e;
if($(this).hasClass("tree-node-append")){
_1d=_1f;
}else{
_1d=_20;
_1e=$(this).hasClass("tree-node-top")?"top":"bottom";
}
setTimeout(function(){
_1d(_1b,_1c,_1e);
},0);
$(this).removeClass("tree-node-append tree-node-top tree-node-bottom");
}});
function _1f(_21,_22){
if(_33(_13,_22).state=="closed"){
_5c(_13,_22,function(){
_23();
});
}else{
_23();
}
function _23(){
var _24=$(_13).tree("pop",_21);
$(_13).tree("append",{parent:_22,data:[_24]});
_14.onDrop.call(_13,_22,_24,"append");
};
};
function _20(_25,_26,_27){
var _28={};
if(_27=="top"){
_28.before=_26;
}else{
_28.after=_26;
}
var _29=$(_13).tree("pop",_25);
_28.data=_29;
$(_13).tree("insert",_28);
_14.onDrop.call(_13,_26,_29,_27);
};
};
function _2a(_2b,_2c,_2d){
var _2e=$.data(_2b,"tree").options;
if(!_2e.checkbox){
return;
}
var _2f=$(_2c);
var ck=_2f.find(".tree-checkbox");
ck.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2");
if(_2d){
ck.addClass("tree-checkbox1");
}else{
ck.addClass("tree-checkbox0");
}
if(_2e.cascadeCheck){
_30(_2f);
_31(_2f);
}
var _32=_33(_2b,_2c);
_2e.onCheck.call(_2b,_32,_2d);
function _31(_34){
var _35=_34.next().find(".tree-checkbox");
_35.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2");
if(_34.find(".tree-checkbox").hasClass("tree-checkbox1")){
_35.addClass("tree-checkbox1");
}else{
_35.addClass("tree-checkbox0");
}
};
function _30(_36){
var _37=_73(_2b,_36[0]);
if(_37){
var ck=$(_37.target).find(".tree-checkbox");
ck.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2");
if(_38(_36)){
ck.addClass("tree-checkbox1");
}else{
if(_39(_36)){
ck.addClass("tree-checkbox0");
}else{
ck.addClass("tree-checkbox2");
}
}
_30($(_37.target));
}
function _38(n){
var ck=n.find(".tree-checkbox");
if(ck.hasClass("tree-checkbox0")||ck.hasClass("tree-checkbox2")){
return false;
}
var b=true;
n.parent().siblings().each(function(){
if(!$(this).children("div.tree-node").children(".tree-checkbox").hasClass("tree-checkbox1")){
b=false;
}
});
return b;
};
function _39(n){
var ck=n.find(".tree-checkbox");
if(ck.hasClass("tree-checkbox1")||ck.hasClass("tree-checkbox2")){
return false;
}
var b=true;
n.parent().siblings().each(function(){
if(!$(this).children("div.tree-node").children(".tree-checkbox").hasClass("tree-checkbox0")){
b=false;
}
});
return b;
};
};
};
function _3a(_3b,_3c){
var _3d=$.data(_3b,"tree").options;
var _3e=$(_3c);
if(_3f(_3b,_3c)){
var ck=_3e.find(".tree-checkbox");
if(ck.length){
if(ck.hasClass("tree-checkbox1")){
_2a(_3b,_3c,true);
}else{
_2a(_3b,_3c,false);
}
}else{
if(_3d.onlyLeafCheck){
$("<span class=\"tree-checkbox tree-checkbox0\"></span>").insertBefore(_3e.find(".tree-title"));
_c(_3b);
}
}
}else{
var ck=_3e.find(".tree-checkbox");
if(_3d.onlyLeafCheck){
ck.remove();
}else{
if(ck.hasClass("tree-checkbox1")){
_2a(_3b,_3c,true);
}else{
if(ck.hasClass("tree-checkbox2")){
var _40=true;
var _41=true;
var _42=_43(_3b,_3c);
for(var i=0;i<_42.length;i++){
if(_42[i].checked){
_41=false;
}else{
_40=false;
}
}
if(_40){
_2a(_3b,_3c,true);
}
if(_41){
_2a(_3b,_3c,false);
}
}
}
}
}
};
function _44(_45,ul,_46,_47){
var _48=$.data(_45,"tree").options;
if(!_47){
$(ul).empty();
}
var _49=[];
var _4a=$(ul).prev("div.tree-node").find("span.tree-indent, span.tree-hit").length;
_4b(ul,_46,_4a);
_c(_45);
_12(_45);
for(var i=0;i<_49.length;i++){
_2a(_45,_49[i],true);
}
var _4c=null;
if(_45!=ul){
var _4d=$(ul).prev();
_4c=_33(_45,_4d[0]);
}
_48.onLoadSuccess.call(_45,_4c,_46);
function _4b(ul,_4e,_4f){
for(var i=0;i<_4e.length;i++){
var li=$("<li></li>").appendTo(ul);
var _50=_4e[i];
if(_50.state!="open"&&_50.state!="closed"){
_50.state="open";
}
var _51=$("<div class=\"tree-node\"></div>").appendTo(li);
_51.attr("node-id",_50.id);
$.data(_51[0],"tree-node",{id:_50.id,text:_50.text,iconCls:_50.iconCls,attributes:_50.attributes});
$("<span class=\"tree-title\"></span>").html(_50.text).appendTo(_51);
if(_48.checkbox){
if(_48.onlyLeafCheck){
if(_50.state=="open"&&(!_50.children||!_50.children.length)){
if(_50.checked){
$("<span class=\"tree-checkbox tree-checkbox1\"></span>").prependTo(_51);
}else{
$("<span class=\"tree-checkbox tree-checkbox0\"></span>").prependTo(_51);
}
}
}else{
if(_50.checked){
$("<span class=\"tree-checkbox tree-checkbox1\"></span>").prependTo(_51);
_49.push(_51[0]);
}else{
$("<span class=\"tree-checkbox tree-checkbox0\"></span>").prependTo(_51);
}
}
}
if(_50.children&&_50.children.length){
var _52=$("<ul></ul>").appendTo(li);
if(_50.state=="open"){
$("<span class=\"tree-icon tree-folder tree-folder-open\"></span>").addClass(_50.iconCls).prependTo(_51);
$("<span class=\"tree-hit tree-expanded\"></span>").prependTo(_51);
}else{
$("<span class=\"tree-icon tree-folder\"></span>").addClass(_50.iconCls).prependTo(_51);
$("<span class=\"tree-hit tree-collapsed\"></span>").prependTo(_51);
_52.css("display","none");
}
_4b(_52,_50.children,_4f+1);
}else{
if(_50.state=="closed"){
$("<span class=\"tree-icon tree-folder\"></span>").addClass(_50.iconCls).prependTo(_51);
$("<span class=\"tree-hit tree-collapsed\"></span>").prependTo(_51);
}else{
$("<span class=\"tree-icon tree-file\"></span>").addClass(_50.iconCls).prependTo(_51);
$("<span class=\"tree-indent\"></span>").prependTo(_51);
}
}
for(var j=0;j<_4f;j++){
$("<span class=\"tree-indent\"></span>").prependTo(_51);
}
}
};
};
function _53(_54,ul,_55,_56){
var _57=$.data(_54,"tree").options;
_55=_55||{};
var _58=null;
if(_54!=ul){
var _59=$(ul).prev();
_58=_33(_54,_59[0]);
}
if(_57.onBeforeLoad.call(_54,_58,_55)==false){
return;
}
if(!_57.url){
return;
}
var _5a=$(ul).prev().children("span.tree-folder");
_5a.addClass("tree-loading");
$.ajax({type:_57.method,url:_57.url,data:_55,dataType:"json",success:function(_5b){
_5a.removeClass("tree-loading");
_44(_54,ul,_5b);
if(_56){
_56();
}
},error:function(){
_5a.removeClass("tree-loading");
_57.onLoadError.apply(_54,arguments);
if(_56){
_56();
}
}});
};
function _5c(_5d,_5e,_5f){
var _60=$.data(_5d,"tree").options;
var hit=$(_5e).children("span.tree-hit");
if(hit.length==0){
return;
}
if(hit.hasClass("tree-expanded")){
return;
}
var _61=_33(_5d,_5e);
if(_60.onBeforeExpand.call(_5d,_61)==false){
return;
}
hit.removeClass("tree-collapsed tree-collapsed-hover").addClass("tree-expanded");
hit.next().addClass("tree-folder-open");
var ul=$(_5e).next();
if(ul.length){
if(_60.animate){
ul.slideDown("normal",function(){
_60.onExpand.call(_5d,_61);
if(_5f){
_5f();
}
});
}else{
ul.css("display","block");
_60.onExpand.call(_5d,_61);
if(_5f){
_5f();
}
}
}else{
var _62=$("<ul style=\"display:none\"></ul>").insertAfter(_5e);
_53(_5d,_62[0],{id:_61.id},function(){
if(_60.animate){
_62.slideDown("normal",function(){
_60.onExpand.call(_5d,_61);
if(_5f){
_5f();
}
});
}else{
_62.css("display","block");
_60.onExpand.call(_5d,_61);
if(_5f){
_5f();
}
}
});
}
};
function _63(_64,_65){
var _66=$.data(_64,"tree").options;
var hit=$(_65).children("span.tree-hit");
if(hit.length==0){
return;
}
if(hit.hasClass("tree-collapsed")){
return;
}
var _67=_33(_64,_65);
if(_66.onBeforeCollapse.call(_64,_67)==false){
return;
}
hit.removeClass("tree-expanded tree-expanded-hover").addClass("tree-collapsed");
hit.next().removeClass("tree-folder-open");
var ul=$(_65).next();
if(_66.animate){
ul.slideUp("normal",function(){
_66.onCollapse.call(_64,_67);
});
}else{
ul.css("display","none");
_66.onCollapse.call(_64,_67);
}
};
function _68(_69,_6a){
var hit=$(_6a).children("span.tree-hit");
if(hit.length==0){
return;
}
if(hit.hasClass("tree-expanded")){
_63(_69,_6a);
}else{
_5c(_69,_6a);
}
};
function _6b(_6c,_6d){
var _6e=_43(_6c,_6d);
if(_6d){
_6e.unshift(_33(_6c,_6d));
}
for(var i=0;i<_6e.length;i++){
_5c(_6c,_6e[i].target);
}
};
function _6f(_70,_71){
var _72=[];
var p=_73(_70,_71);
while(p){
_72.unshift(p);
p=_73(_70,p.target);
}
for(var i=0;i<_72.length;i++){
_5c(_70,_72[i].target);
}
};
function _74(_75,_76){
var _77=_43(_75,_76);
if(_76){
_77.unshift(_33(_75,_76));
}
for(var i=0;i<_77.length;i++){
_63(_75,_77[i].target);
}
};
function _78(_79){
var _7a=_7b(_79);
if(_7a.length){
return _7a[0];
}else{
return null;
}
};
function _7b(_7c){
var _7d=[];
$(_7c).children("li").each(function(){
var _7e=$(this).children("div.tree-node");
_7d.push(_33(_7c,_7e[0]));
});
return _7d;
};
function _43(_7f,_80){
var _81=[];
if(_80){
_82($(_80));
}else{
var _83=_7b(_7f);
for(var i=0;i<_83.length;i++){
_81.push(_83[i]);
_82($(_83[i].target));
}
}
function _82(_84){
_84.next().find("div.tree-node").each(function(){
_81.push(_33(_7f,this));
});
};
return _81;
};
function _73(_85,_86){
var ul=$(_86).parent().parent();
if(ul[0]==_85){
return null;
}else{
return _33(_85,ul.prev()[0]);
}
};
function _87(_88){
var _89=[];
$(_88).find(".tree-checkbox1").each(function(){
var _8a=$(this).parent();
_89.push(_33(_88,_8a[0]));
});
return _89;
};
function _8b(_8c){
var _8d=$(_8c).find("div.tree-node-selected");
if(_8d.length){
return _33(_8c,_8d[0]);
}else{
return null;
}
};
function _8e(_8f,_90){
var _91=$(_90.parent);
var ul;
if(_91.length==0){
ul=$(_8f);
}else{
ul=_91.next();
if(ul.length==0){
ul=$("<ul></ul>").insertAfter(_91);
}
}
if(_90.data&&_90.data.length){
var _92=_91.find("span.tree-icon");
if(_92.hasClass("tree-file")){
_92.removeClass("tree-file").addClass("tree-folder");
var hit=$("<span class=\"tree-hit tree-expanded\"></span>").insertBefore(_92);
if(hit.prev().length){
hit.prev().remove();
}
}
}
_44(_8f,ul[0],_90.data,true);
_3a(_8f,ul.prev());
};
function _93(_94,_95){
var ref=_95.before||_95.after;
var _96=_73(_94,ref);
var li;
if(_96){
_8e(_94,{parent:_96.target,data:[_95.data]});
li=$(_96.target).next().children("li:last");
}else{
_8e(_94,{parent:null,data:[_95.data]});
li=$(_94).children("li:last");
}
if(_95.before){
li.insertBefore($(ref).parent());
}else{
li.insertAfter($(ref).parent());
}
};
function _97(_98,_99){
var _9a=_73(_98,_99);
var _9b=$(_99);
var li=_9b.parent();
var ul=li.parent();
li.remove();
if(ul.children("li").length==0){
var _9b=ul.prev();
_9b.find(".tree-icon").removeClass("tree-folder").addClass("tree-file");
_9b.find(".tree-hit").remove();
$("<span class=\"tree-indent\"></span>").prependTo(_9b);
if(ul[0]!=_98){
ul.remove();
}
}
if(_9a){
_3a(_98,_9a.target);
}
};
function _9c(_9d,_9e){
function _9f(aa,ul){
ul.children("li").each(function(){
var _a0=$(this).children("div.tree-node");
var _a1=_33(_9d,_a0[0]);
var sub=$(this).children("ul");
if(sub.length){
_a1.children=[];
_9c(_a1.children,sub);
}
aa.push(_a1);
});
};
if(_9e){
var _a2=_33(_9d,_9e);
_a2.children=[];
_9f(_a2.children,$(_9e).next());
return _a2;
}else{
return null;
}
};
function _a3(_a4,_a5){
var _a6=$(_a5.target);
var _a7=$.data(_a5.target,"tree-node");
if(_a7.iconCls){
_a6.find(".tree-icon").removeClass(_a7.iconCls);
}
$.extend(_a7,_a5);
$.data(_a5.target,"tree-node",_a7);
_a6.attr("node-id",_a7.id);
_a6.find(".tree-title").html(_a7.text);
if(_a7.iconCls){
_a6.find(".tree-icon").addClass(_a7.iconCls);
}
var ck=_a6.find(".tree-checkbox");
ck.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2");
if(_a7.checked){
_2a(_a4,_a5.target,true);
}else{
_2a(_a4,_a5.target,false);
}
};
function _33(_a8,_a9){
var _aa=$.extend({},$.data(_a9,"tree-node"),{target:_a9,checked:$(_a9).find(".tree-checkbox").hasClass("tree-checkbox1")});
if(!_3f(_a8,_a9)){
_aa.state=$(_a9).find(".tree-hit").hasClass("tree-expanded")?"open":"closed";
}
return _aa;
};
function _ab(_ac,id){
var _ad=$(_ac).find("div.tree-node[node-id="+id+"]");
if(_ad.length){
return _33(_ac,_ad[0]);
}else{
return null;
}
};
function _ae(_af,_b0){
var _b1=$.data(_af,"tree").options;
var _b2=_33(_af,_b0);
if(_b1.onBeforeSelect.call(_af,_b2)==false){
return;
}
$("div.tree-node-selected",_af).removeClass("tree-node-selected");
$(_b0).addClass("tree-node-selected");
_b1.onSelect.call(_af,_b2);
};
function _3f(_b3,_b4){
var _b5=$(_b4);
var hit=_b5.children("span.tree-hit");
return hit.length==0;
};
$.fn.tree=function(_b6,_b7){
if(typeof _b6=="string"){
return $.fn.tree.methods[_b6](this,_b7);
}
var _b6=_b6||{};
return this.each(function(){
var _b8=$.data(this,"tree");
var _b9;
if(_b8){
_b9=$.extend(_b8.options,_b6);
_b8.options=_b9;
}else{
_b9=$.extend({},$.fn.tree.defaults,$.fn.tree.parseOptions(this),_b6);
$.data(this,"tree",{options:_b9,tree:_1(this)});
var _ba=_4(this);
_44(this,this,_ba);
}
if(_b9.data){
_44(this,this,_b9.data);
}
if(_b9.url){
_53(this,this);
}
});
};
$.fn.tree.methods={options:function(jq){
return $.data(jq[0],"tree").options;
},loadData:function(jq,_bb){
return jq.each(function(){
_44(this,this,_bb);
});
},getNode:function(jq,_bc){
return _33(jq[0],_bc);
},getData:function(jq,_bd){
return _9c(jq[0],_bd);
},reload:function(jq,_be){
return jq.each(function(){
if(_be){
var _bf=$(_be);
var hit=_bf.children("span.tree-hit");
hit.removeClass("tree-expanded tree-expanded-hover").addClass("tree-collapsed");
_bf.next().remove();
_5c(this,_be);
}else{
$(this).empty();
_53(this,this);
}
});
},getRoot:function(jq){
return _78(jq[0]);
},getRoots:function(jq){
return _7b(jq[0]);
},getParent:function(jq,_c0){
return _73(jq[0],_c0);
},getChildren:function(jq,_c1){
return _43(jq[0],_c1);
},getChecked:function(jq){
return _87(jq[0]);
},getSelected:function(jq){
return _8b(jq[0]);
},isLeaf:function(jq,_c2){
return _3f(jq[0],_c2);
},find:function(jq,id){
return _ab(jq[0],id);
},select:function(jq,_c3){
return jq.each(function(){
_ae(this,_c3);
});
},check:function(jq,_c4){
return jq.each(function(){
_2a(this,_c4,true);
});
},uncheck:function(jq,_c5){
return jq.each(function(){
_2a(this,_c5,false);
});
},collapse:function(jq,_c6){
return jq.each(function(){
_63(this,_c6);
});
},expand:function(jq,_c7){
return jq.each(function(){
_5c(this,_c7);
});
},collapseAll:function(jq,_c8){
return jq.each(function(){
_74(this,_c8);
});
},expandAll:function(jq,_c9){
return jq.each(function(){
_6b(this,_c9);
});
},expandTo:function(jq,_ca){
return jq.each(function(){
_6f(this,_ca);
});
},toggle:function(jq,_cb){
return jq.each(function(){
_68(this,_cb);
});
},append:function(jq,_cc){
return jq.each(function(){
_8e(this,_cc);
});
},insert:function(jq,_cd){
return jq.each(function(){
_93(this,_cd);
});
},remove:function(jq,_ce){
return jq.each(function(){
_97(this,_ce);
});
},pop:function(jq,_cf){
var _d0=jq.tree("getData",_cf);
jq.tree("remove",_cf);
return _d0;
},update:function(jq,_d1){
return jq.each(function(){
_a3(this,_d1);
});
}};
$.fn.tree.parseOptions=function(_d2){
var t=$(_d2);
return {url:t.attr("url"),checkbox:(t.attr("checkbox")?t.attr("checkbox")=="true":undefined),cascadeCheck:(t.attr("cascadeCheck")?t.attr("cascadeCheck")=="true":undefined),onlyLeafCheck:(t.attr("onlyLeafCheck")?t.attr("onlyLeafCheck")=="true":undefined),animate:(t.attr("animate")?t.attr("animate")=="true":undefined),dnd:(t.attr("dnd")?t.attr("dnd")=="true":undefined)};
};
$.fn.tree.defaults={url:null,method:"post",animate:false,checkbox:false,cascadeCheck:true,onlyLeafCheck:false,dnd:false,data:null,onBeforeLoad:function(_d3,_d4){
},onLoadSuccess:function(_d5,_d6){
},onLoadError:function(){
},onClick:function(_d7){
},onDblClick:function(_d8){
},onBeforeExpand:function(_d9){
},onExpand:function(_da){
},onBeforeCollapse:function(_db){
},onCollapse:function(_dc){
},onCheck:function(_dd,_de){
},onBeforeSelect:function(_df){
},onSelect:function(_e0){
},onContextMenu:function(e,_e1){
},onDrop:function(_e2,_e3,_e4){
}};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
$.parser={auto:true,onComplete:function(_1){
},plugins:["linkbutton","menu","menubutton","splitbutton","tree","combobox","combotree","numberbox","validatebox","numberspinner","timespinner","calendar","datebox","layout","panel","datagrid","tabs","accordion","window","dialog"],parse:function(_2){
var aa=[];
for(var i=0;i<$.parser.plugins.length;i++){
var _3=$.parser.plugins[i];
var r=$(".easyui-"+_3,_2);
if(r.length){
if(r[_3]){
r[_3]();
}else{
aa.push({name:_3,jq:r});
}
}
}
if(aa.length&&window.easyloader){
var _4=[];
for(var i=0;i<aa.length;i++){
_4.push(aa[i].name);
}
easyloader.load(_4,function(){
for(var i=0;i<aa.length;i++){
var _5=aa[i].name;
var jq=aa[i].jq;
jq[_5]();
}
$.parser.onComplete.call($.parser,_2);
});
}else{
$.parser.onComplete.call($.parser,_2);
}
}};
$(function(){
if(!window.easyloader&&$.parser.auto){
$.parser.parse();
}
});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"combotree").options;
var _4=$.data(_2,"combotree").tree;
$(_2).addClass("combotree-f");
$(_2).combo(_3);
var _5=$(_2).combo("panel");
if(!_4){
_4=$("<ul></ul>").appendTo(_5);
$.data(_2,"combotree").tree=_4;
}
_4.tree($.extend({},_3,{checkbox:_3.multiple,onLoadSuccess:function(_6,_7){
var _8=$(_2).combotree("getValues");
if(_3.multiple){
var _9=_4.tree("getChecked");
for(var i=0;i<_9.length;i++){
var id=_9[i].id;
(function(){
for(var i=0;i<_8.length;i++){
if(id==_8[i]){
return;
}
}
_8.push(id);
})();
}
}
$(_2).combotree("setValues",_8);
_3.onLoadSuccess.call(this,_6,_7);
},onClick:function(_a){
_d(_2);
$(_2).combo("hidePanel");
_3.onClick.call(this,_a);
},onCheck:function(_b,_c){
_d(_2);
_3.onCheck.call(this,_b,_c);
}}));
};
function _d(_e){
var _f=$.data(_e,"combotree").options;
var _10=$.data(_e,"combotree").tree;
var vv=[],ss=[];
if(_f.multiple){
var _11=_10.tree("getChecked");
for(var i=0;i<_11.length;i++){
vv.push(_11[i].id);
ss.push(_11[i].text);
}
}else{
var _12=_10.tree("getSelected");
if(_12){
vv.push(_12.id);
ss.push(_12.text);
}
}
$(_e).combo("setValues",vv).combo("setText",ss.join(_f.separator));
};
function _13(_14,_15){
var _16=$.data(_14,"combotree").options;
var _17=$.data(_14,"combotree").tree;
_17.find("span.tree-checkbox").addClass("tree-checkbox0").removeClass("tree-checkbox1 tree-checkbox2");
var vv=[],ss=[];
for(var i=0;i<_15.length;i++){
var v=_15[i];
var s=v;
var _18=_17.tree("find",v);
if(_18){
s=_18.text;
_17.tree("check",_18.target);
_17.tree("select",_18.target);
}
vv.push(v);
ss.push(s);
}
$(_14).combo("setValues",vv).combo("setText",ss.join(_16.separator));
};
$.fn.combotree=function(_19,_1a){
if(typeof _19=="string"){
var _1b=$.fn.combotree.methods[_19];
if(_1b){
return _1b(this,_1a);
}else{
return this.combo(_19,_1a);
}
}
_19=_19||{};
return this.each(function(){
var _1c=$.data(this,"combotree");
if(_1c){
$.extend(_1c.options,_19);
}else{
$.data(this,"combotree",{options:$.extend({},$.fn.combotree.defaults,$.fn.combotree.parseOptions(this),_19)});
}
_1(this);
});
};
$.fn.combotree.methods={options:function(jq){
return $.data(jq[0],"combotree").options;
},tree:function(jq){
return $.data(jq[0],"combotree").tree;
},loadData:function(jq,_1d){
return jq.each(function(){
var _1e=$.data(this,"combotree").options;
_1e.data=_1d;
var _1f=$.data(this,"combotree").tree;
_1f.tree("loadData",_1d);
});
},reload:function(jq,url){
return jq.each(function(){
var _20=$.data(this,"combotree").options;
var _21=$.data(this,"combotree").tree;
if(url){
_20.url=url;
}
_21.tree({url:_20.url});
});
},setValues:function(jq,_22){
return jq.each(function(){
_13(this,_22);
});
},setValue:function(jq,_23){
return jq.each(function(){
_13(this,[_23]);
});
},clear:function(jq){
return jq.each(function(){
var _24=$.data(this,"combotree").tree;
_24.find("div.tree-node-selected").removeClass("tree-node-selected");
$(this).combo("clear");
});
}};
$.fn.combotree.parseOptions=function(_25){
return $.extend({},$.fn.combo.parseOptions(_25),$.fn.tree.parseOptions(_25));
};
$.fn.combotree.defaults=$.extend({},$.fn.combo.defaults,$.fn.tree.defaults,{editable:false});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
$.extend(Array.prototype,{indexOf:function(o){
for(var i=0,_1=this.length;i<_1;i++){
if(this[i]==o){
return i;
}
}
return -1;
},remove:function(o){
var _2=this.indexOf(o);
if(_2!=-1){
this.splice(_2,1);
}
return this;
}});
function _3(_4,_5){
var _6=$.data(_4,"datagrid").options;
var _7=$.data(_4,"datagrid").panel;
if(_5){
if(_5.width){
_6.width=_5.width;
}
if(_5.height){
_6.height=_5.height;
}
}
if(_6.fit==true){
var p=_7.panel("panel").parent();
_6.width=p.width();
_6.height=p.height();
}
_7.panel("resize",{width:_6.width,height:_6.height});
};
function _8(_9){
var _a=$.data(_9,"datagrid").options;
var _b=$.data(_9,"datagrid").panel;
var _c=_b.width();
var _d=_b.height();
var _e=_b.find("div.datagrid-view");
var _f=_e.find("div.datagrid-view1");
var _10=_e.find("div.datagrid-view2");
_e.width(_c);
_f.width(_f.find("table").width());
_10.width(_c-_f.outerWidth());
_f.children("div.datagrid-header,div.datagrid-body").width(_f.width());
_10.children("div.datagrid-header,div.datagrid-body").width(_10.width());
var hh;
var _11=_f.children("div.datagrid-header");
var _12=_10.children("div.datagrid-header");
var _13=_11.find("table");
var _14=_12.find("table");
_11.css("height",null);
_12.css("height",null);
_13.css("height",null);
_14.css("height",null);
hh=Math.max(_13.height(),_14.height());
_13.height(hh);
_14.height(hh);
if($.boxModel==true){
_11.height(hh-(_11.outerHeight()-_11.height()));
_12.height(hh-(_12.outerHeight()-_12.height()));
}else{
_11.height(hh);
_12.height(hh);
}
var _15=_e.find("div.datagrid-body");
if(_a.height=="auto"){
var _16=_10.children("div.datagrid-body");
var _17=18;
_16.children().each(function(){
_17+=$(this).outerHeight();
});
_15.height(_17);
}else{
_15.height(_d-_10.children("div.datagrid-header").outerHeight(true)-_b.children("div.datagrid-toolbar").outerHeight(true)-_b.children("div.datagrid-pager").outerHeight(true));
}
_e.height(_10.height());
_10.css("left",_f.outerWidth());
};
function _18(_19,_1a){
var _1b=$.data(_19,"datagrid").data.rows;
var _1c=$.data(_19,"datagrid").options;
var _1d=$.data(_19,"datagrid").panel;
var _1e=_1d.children("div.datagrid-view");
var _1f=_1e.children("div.datagrid-view1");
var _20=_1e.children("div.datagrid-view2");
if(!_1f.find("div.datagrid-body-inner").is(":empty")){
if(_1a>=0){
_21(_1a);
}else{
for(var i=0;i<_1b.length;i++){
_21(i);
}
}
}
if(_1c.height=="auto"){
var _22=_1f.children("div.datagrid-body");
var _23=_20.children("div.datagrid-body");
var _24=18;
_23.children().each(function(){
_24+=$(this).outerHeight();
});
_22.height(_24);
_23.height(_24);
_1e.height(_20.height());
}
function _21(_25){
var tr1=_1f.find("tr[datagrid-row-index="+_25+"]");
var tr2=_20.find("tr[datagrid-row-index="+_25+"]");
tr1.css("height",null);
tr2.css("height",null);
var _26=Math.max(tr1.height(),tr2.height());
tr1.css("height",_26);
tr2.css("height",_26);
};
};
function _27(_28,_29){
function _2a(_2b){
var _2c=[];
$("tr",_2b).each(function(){
var _2d=[];
$("th",this).each(function(){
var th=$(this);
var col={title:th.html(),align:th.attr("align")||"left",sortable:th.attr("sortable")=="true"||false,checkbox:th.attr("checkbox")=="true"||false};
if(th.attr("field")){
col.field=th.attr("field");
}
if(th.attr("formatter")){
col.formatter=eval(th.attr("formatter"));
}
if(th.attr("editor")){
var s=$.trim(th.attr("editor"));
if(s.substr(0,1)=="{"){
col.editor=eval("("+s+")");
}else{
col.editor=s;
}
}
if(th.attr("rowspan")){
col.rowspan=parseInt(th.attr("rowspan"));
}
if(th.attr("colspan")){
col.colspan=parseInt(th.attr("colspan"));
}
if(th.attr("width")){
col.width=parseInt(th.attr("width"));
}
if(th.attr("hidden")){
col.hidden=th.attr("hidden")=="true";
}
_2d.push(col);
});
_2c.push(_2d);
});
return _2c;
};
var _2e=$("<div class=\"datagrid-wrap\">"+"<div class=\"datagrid-view\">"+"<div class=\"datagrid-view1\">"+"<div class=\"datagrid-header\">"+"<div class=\"datagrid-header-inner\"></div>"+"</div>"+"<div class=\"datagrid-body\">"+"<div class=\"datagrid-body-inner\"></div>"+"</div>"+"</div>"+"<div class=\"datagrid-view2\">"+"<div class=\"datagrid-header\">"+"<div class=\"datagrid-header-inner\"></div>"+"</div>"+"<div class=\"datagrid-body\"></div>"+"</div>"+"<div class=\"datagrid-resize-proxy\"></div>"+"</div>"+"</div>").insertAfter(_28);
_2e.panel({doSize:false});
_2e.panel("panel").addClass("datagrid").bind("_resize",function(){
var _2f=$.data(_28,"datagrid").options;
if(_2f.fit==true){
_3(_28);
setTimeout(function(){
_30(_28);
},0);
}
return false;
});
$(_28).hide().appendTo(_2e.children("div.datagrid-view"));
var _31=_2a($("thead[frozen=true]",_28));
var _32=_2a($("thead[frozen!=true]",_28));
return {panel:_2e,frozenColumns:_31,columns:_32};
};
function _33(_34){
var _35={total:0,rows:[]};
var _36=_37(_34,true).concat(_37(_34,false));
$(_34).find("tbody tr").each(function(){
_35.total++;
var col={};
for(var i=0;i<_36.length;i++){
col[_36[i]]=$("td:eq("+i+")",this).html();
}
_35.rows.push(col);
});
return _35;
};
function _38(_39){
var _3a=$.data(_39,"datagrid").options;
var _3b=$.data(_39,"datagrid").panel;
_3b.panel($.extend({},_3a,{doSize:false,onResize:function(_3c,_3d){
setTimeout(function(){
_8(_39);
_6e(_39);
_3a.onResize.call(_3b,_3c,_3d);
},0);
},onExpand:function(){
_8(_39);
_3a.onExpand.call(_3b);
}}));
var _3e=_3b.find("div.datagrid-view1 div.datagrid-header-inner");
var _3f=_3b.find("div.datagrid-view2 div.datagrid-header-inner");
_40(_3e,_3a.frozenColumns,true);
_40(_3f,_3a.columns,false);
$("div.datagrid-toolbar",_3b).remove();
if(_3a.toolbar){
var tb=$("<div class=\"datagrid-toolbar\"></div>").prependTo(_3b);
for(var i=0;i<_3a.toolbar.length;i++){
var btn=_3a.toolbar[i];
if(btn=="-"){
$("<div class=\"datagrid-btn-separator\"></div>").appendTo(tb);
}else{
var _41=$("<a href=\"javascript:void(0)\"></a>");
_41[0].onclick=eval(btn.handler||function(){
});
_41.css("float","left").appendTo(tb).linkbutton($.extend({},btn,{plain:true}));
}
}
}
$("div.datagrid-pager",_3b).remove();
if(_3a.pagination){
var _42=$("<div class=\"datagrid-pager\"></div>").appendTo(_3b);
_42.pagination({pageNumber:_3a.pageNumber,pageSize:_3a.pageSize,pageList:_3a.pageList,onSelectPage:function(_43,_44){
_3a.pageNumber=_43;
_3a.pageSize=_44;
_13b(_39);
}});
_3a.pageSize=_42.pagination("options").pageSize;
}
function _40(_45,_46,_47){
$(_45).empty();
var t=$("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tbody></tbody></table>").appendTo(_45);
for(var i=0;i<_46.length;i++){
var tr=$("<tr></tr>").appendTo($("tbody",t));
var _48=_46[i];
for(var j=0;j<_48.length;j++){
var col=_48[j];
var _49="";
if(col.rowspan){
_49+="rowspan=\""+col.rowspan+"\" ";
}
if(col.colspan){
_49+="colspan=\""+col.colspan+"\" ";
}
var td=$("<td "+_49+"></td>").appendTo(tr);
if(col.checkbox){
td.attr("field",col.field);
$("<div class=\"datagrid-header-check\"></div>").html("<input type=\"checkbox\"/>").appendTo(td);
}else{
if(col.field){
td.attr("field",col.field);
td.append("<div class=\"datagrid-cell\"><span></span><span class=\"datagrid-sort-icon\"></span></div>");
$("span",td).html(col.title);
$("span.datagrid-sort-icon",td).html(" ");
var _4a=td.find("div.datagrid-cell");
col.boxWidth=$.boxModel?(col.width-(_4a.outerWidth()-_4a.width())):col.width;
_4a.width(col.boxWidth);
_4a.css("text-align",(col.align||"left"));
}else{
$("<div class=\"datagrid-cell-group\"></div>").html(col.title).appendTo(td);
}
}
if(col.hidden){
td.hide();
}
}
}
if(_47&&_3a.rownumbers){
var td=$("<td rowspan=\""+_3a.frozenColumns.length+"\"><div class=\"datagrid-header-rownumber\"></div></td>");
if($("tr",t).length==0){
td.wrap("<tr></tr>").parent().appendTo($("tbody",t));
}else{
td.prependTo($("tr:first",t));
}
}
return t;
};
};
function _4b(_4c){
var _4d=$.data(_4c,"datagrid").panel;
var _4e=$.data(_4c,"datagrid").options;
var _4f=$.data(_4c,"datagrid").data;
var _50=_4d.find("div.datagrid-body");
_50.find("tr[datagrid-row-index]").unbind(".datagrid").bind("mouseenter.datagrid",function(){
var _51=$(this).attr("datagrid-row-index");
_50.find("tr[datagrid-row-index="+_51+"]").addClass("datagrid-row-over");
}).bind("mouseleave.datagrid",function(){
var _52=$(this).attr("datagrid-row-index");
_50.find("tr[datagrid-row-index="+_52+"]").removeClass("datagrid-row-over");
}).bind("click.datagrid",function(){
var _53=$(this).attr("datagrid-row-index");
if(_4e.singleSelect==true){
_57(_4c);
_58(_4c,_53);
}else{
if($(this).hasClass("datagrid-row-selected")){
_59(_4c,_53);
}else{
_58(_4c,_53);
}
}
if(_4e.onClickRow){
_4e.onClickRow.call(_4c,_53,_4f.rows[_53]);
}
}).bind("dblclick.datagrid",function(){
var _54=$(this).attr("datagrid-row-index");
if(_4e.onDblClickRow){
_4e.onDblClickRow.call(_4c,_54,_4f.rows[_54]);
}
}).bind("contextmenu.datagrid",function(e){
var _55=$(this).attr("datagrid-row-index");
if(_4e.onRowContextMenu){
_4e.onRowContextMenu.call(_4c,e,_55,_4f.rows[_55]);
}
});
_50.find("div.datagrid-cell-check input[type=checkbox]").unbind(".datagrid").bind("click.datagrid",function(e){
var _56=$(this).parent().parent().parent().attr("datagrid-row-index");
if(_4e.singleSelect){
_57(_4c);
_58(_4c,_56);
}else{
if($(this).attr("checked")){
_58(_4c,_56);
}else{
_59(_4c,_56);
}
}
e.stopPropagation();
});
};
function _5a(_5b){
var _5c=$.data(_5b,"datagrid").panel;
var _5d=$.data(_5b,"datagrid").options;
var _5e=_5c.find("div.datagrid-header");
_5e.find("td:has(div.datagrid-cell)").unbind(".datagrid").bind("mouseenter.datagrid",function(){
$(this).addClass("datagrid-header-over");
}).bind("mouseleave.datagrid",function(){
$(this).removeClass("datagrid-header-over");
}).bind("contextmenu.datagrid",function(e){
var _5f=$(this).attr("field");
_5d.onHeaderContextMenu.call(_5b,e,_5f);
});
_5e.find("div.datagrid-cell").unbind(".datagrid").bind("click.datagrid",function(){
var _60=$(this).parent().attr("field");
var opt=_6c(_5b,_60);
if(!opt.sortable){
return;
}
_5d.sortName=_60;
_5d.sortOrder="asc";
var c="datagrid-sort-asc";
if($(this).hasClass("datagrid-sort-asc")){
c="datagrid-sort-desc";
_5d.sortOrder="desc";
}
_5e.find("div.datagrid-cell").removeClass("datagrid-sort-asc datagrid-sort-desc");
$(this).addClass(c);
if(_5d.onSortColumn){
_5d.onSortColumn.call(_5b,_5d.sortName,_5d.sortOrder);
}
if(_5d.remoteSort){
_13b(_5b);
}else{
var _61=$.data(_5b,"datagrid").data;
_97(_5b,_61);
}
});
_5e.find("input[type=checkbox]").unbind(".datagrid").bind("click.datagrid",function(){
if(_5d.singleSelect){
return false;
}
if($(this).attr("checked")){
_b4(_5b);
}else{
_b2(_5b);
}
});
var _62=_5c.children("div.datagrid-view");
var _63=_62.children("div.datagrid-view1");
var _64=_62.children("div.datagrid-view2");
var _65=_64.find("div.datagrid-header");
var _66=_63.find("div.datagrid-body");
_64.find("div.datagrid-body").unbind(".datagrid").bind("scroll.datagrid",function(){
_65.scrollLeft($(this).scrollLeft());
_66.scrollTop($(this).scrollTop());
});
_5e.find("div.datagrid-cell").resizable({handles:"e",minWidth:25,onStartResize:function(e){
var _67=_62.children("div.datagrid-resize-proxy");
_67.css({left:e.pageX-$(_5c).offset().left-1});
_67.css("display","block");
},onResize:function(e){
var _68=_62.children("div.datagrid-resize-proxy");
_68.css({display:"block",left:e.pageX-$(_5c).offset().left-1});
return false;
},onStopResize:function(e){
var _69=$(this).parent().attr("field");
var col=_6c(_5b,_69);
col.width=$(this).outerWidth();
col.boxWidth=$.boxModel==true?$(this).width():$(this).outerWidth();
_30(_5b,_69);
_6e(_5b);
var _6a=_5c.find("div.datagrid-view2");
_6a.find("div.datagrid-header").scrollLeft(_6a.find("div.datagrid-body").scrollLeft());
_62.children("div.datagrid-resize-proxy").css("display","none");
_5d.onResizeColumn.call(_5b,_69,col.width);
}});
$("div.datagrid-view1 div.datagrid-header div.datagrid-cell",_5c).resizable({onStopResize:function(e){
var _6b=$(this).parent().attr("field");
var col=_6c(_5b,_6b);
col.width=$(this).outerWidth();
col.boxWidth=$.boxModel==true?$(this).width():$(this).outerWidth();
_30(_5b,_6b);
var _6d=_5c.find("div.datagrid-view2");
_6d.find("div.datagrid-header").scrollLeft(_6d.find("div.datagrid-body").scrollLeft());
_62.children("div.datagrid-resize-proxy").css("display","none");
_5d.onResizeColumn.call(_5b,_6b,col.width);
_3(_5b);
}});
};
function _6e(_6f){
var _70=$.data(_6f,"datagrid").options;
if(!_70.fitColumns){
return;
}
var _71=$.data(_6f,"datagrid").panel;
var _72=_71.find("div.datagrid-view2 div.datagrid-header");
var _73=0;
var _74=_37(_6f,false);
for(var i=0;i<_74.length;i++){
var col=_6c(_6f,_74[i]);
if(!col.hidden){
_73+=col.width;
}
}
var _75=(_72.width()-_72.find("table").width()-18)/_73;
for(var i=0;i<_74.length;i++){
var col=_6c(_6f,_74[i]);
var _76=col.width-col.boxWidth;
var _77=Math.floor(col.width+col.width*_75);
col.width=_77;
col.boxWidth=_77-_76;
_72.find("td[field="+col.field+"] div.datagrid-cell").width(col.boxWidth);
}
_30(_6f);
};
function _30(_78,_79){
var _7a=$.data(_78,"datagrid").panel;
var _7b=$.data(_78,"datagrid").options;
var _7c=_7a.find("div.datagrid-body");
if(_79){
fix(_79);
}else{
_7a.find("div.datagrid-header td[field]").each(function(){
fix($(this).attr("field"));
});
}
_7f(_78);
setTimeout(function(){
_18(_78);
_88(_78);
},0);
function fix(_7d){
var col=_6c(_78,_7d);
_7c.find("td[field="+_7d+"]").each(function(){
var td=$(this);
var _7e=td.attr("colspan")||1;
if(_7e==1){
td.find("div.datagrid-cell").width(col.boxWidth);
td.find("div.datagrid-editable").width(col.width);
}
});
};
};
function _7f(_80){
var _81=$.data(_80,"datagrid").panel;
var _82=_81.find("div.datagrid-header");
_81.find("div.datagrid-body td.datagrid-td-merged").each(function(){
var td=$(this);
var _83=td.attr("colspan")||1;
var _84=td.attr("field");
var _85=_82.find("td[field="+_84+"]");
var _86=_85.width();
for(var i=1;i<_83;i++){
_85=_85.next();
_86+=_85.outerWidth();
}
var _87=td.children("div.datagrid-cell");
if($.boxModel==true){
_87.width(_86-(_87.outerWidth()-_87.width()));
}else{
_87.width(_86);
}
});
};
function _88(_89){
var _8a=$.data(_89,"datagrid").panel;
_8a.find("div.datagrid-editable").each(function(){
var ed=$.data(this,"datagrid.editor");
if(ed.actions.resize){
ed.actions.resize(ed.target,$(this).width());
}
});
};
function _6c(_8b,_8c){
var _8d=$.data(_8b,"datagrid").options;
if(_8d.columns){
for(var i=0;i<_8d.columns.length;i++){
var _8e=_8d.columns[i];
for(var j=0;j<_8e.length;j++){
var col=_8e[j];
if(col.field==_8c){
return col;
}
}
}
}
if(_8d.frozenColumns){
for(var i=0;i<_8d.frozenColumns.length;i++){
var _8e=_8d.frozenColumns[i];
for(var j=0;j<_8e.length;j++){
var col=_8e[j];
if(col.field==_8c){
return col;
}
}
}
}
return null;
};
function _37(_8f,_90){
var _91=$.data(_8f,"datagrid").options;
var _92=(_90==true)?(_91.frozenColumns||[[]]):_91.columns;
if(_92.length==0){
return [];
}
var _93=[];
function _94(_95){
var c=0;
var i=0;
while(true){
if(_93[i]==undefined){
if(c==_95){
return i;
}
c++;
}
i++;
}
};
function _96(r){
var ff=[];
var c=0;
for(var i=0;i<_92[r].length;i++){
var col=_92[r][i];
if(col.field){
ff.push([c,col.field]);
}
c+=parseInt(col.colspan||"1");
}
for(var i=0;i<ff.length;i++){
ff[i][0]=_94(ff[i][0]);
}
for(var i=0;i<ff.length;i++){
var f=ff[i];
_93[f[0]]=f[1];
}
};
for(var i=0;i<_92.length;i++){
_96(i);
}
return _93;
};
function _97(_98,_99){
var _9a=$.data(_98,"datagrid").options;
var _9b=$.data(_98,"datagrid").panel;
var _9c=$.data(_98,"datagrid").selectedRows;
var _9d=_99.rows;
$.data(_98,"datagrid").data=_99;
if(!_9a.remoteSort){
var opt=_6c(_98,_9a.sortName);
if(opt){
var _9e=opt.sorter||function(a,b){
return (a>b?1:-1);
};
_99.rows.sort(function(r1,r2){
return _9e(r1[_9a.sortName],r2[_9a.sortName])*(_9a.sortOrder=="asc"?1:-1);
});
}
}
var _9f=_9b.children("div.datagrid-view");
var _a0=_9f.children("div.datagrid-view1");
var _a1=_9f.children("div.datagrid-view2");
if(_9a.view.onBeforeRender){
_9a.view.onBeforeRender.call(_9a.view,_98,_9d);
}
_9a.view.render.call(_9a.view,_98,_a1.children("div.datagrid-body"),false);
_9a.view.render.call(_9a.view,_98,_a0.children("div.datagrid-body").children("div.datagrid-body-inner"),true);
if(_9a.view.onAfterRender){
_9a.view.onAfterRender.call(_9a.view,_98);
}
_9a.onLoadSuccess.call(_98,_99);
_a1.children("div.datagrid-body").triggerHandler("scroll");
var _a2=_9b.children("div.datagrid-pager");
if(_a2.length){
if(_a2.pagination("options").total!=_99.total){
_a2.pagination({total:_99.total});
}
}
_18(_98);
_4b(_98);
if(_9a.idField){
for(var i=0;i<_9d.length;i++){
if(_a3(_9d[i])){
_cc(_98,_9d[i][_9a.idField]);
}
}
}
function _a3(row){
for(var i=0;i<_9c.length;i++){
if(_9c[i][_9a.idField]==row[_9a.idField]){
_9c[i]=row;
return true;
}
}
return false;
};
};
function _a4(_a5,row){
var _a6=$.data(_a5,"datagrid").options;
var _a7=$.data(_a5,"datagrid").data.rows;
if(typeof row=="object"){
return _a7.indexOf(row);
}else{
for(var i=0;i<_a7.length;i++){
if(_a7[i][_a6.idField]==row){
return i;
}
}
return -1;
}
};
function _a8(_a9){
var _aa=$.data(_a9,"datagrid").options;
var _ab=$.data(_a9,"datagrid").panel;
var _ac=$.data(_a9,"datagrid").data;
if(_aa.idField){
var _ad=$.data(_a9,"datagrid").deletedRows;
var _ae=$.data(_a9,"datagrid").selectedRows;
var _af=[];
for(var i=0;i<_ae.length;i++){
(function(){
var row=_ae[i];
for(var j=0;j<_ad.length;j++){
if(row[_aa.idField]==_ad[j][_aa.idField]){
return;
}
}
_af.push(row);
})();
}
return _af;
}
var _af=[];
$("div.datagrid-view2 div.datagrid-body tr.datagrid-row-selected",_ab).each(function(){
var _b0=parseInt($(this).attr("datagrid-row-index"));
if(_ac.rows[_b0]){
_af.push(_ac.rows[_b0]);
}
});
return _af;
};
function _57(_b1){
_b2(_b1);
var _b3=$.data(_b1,"datagrid").selectedRows;
while(_b3.length>0){
_b3.pop();
}
};
function _b4(_b5){
var _b6=$.data(_b5,"datagrid").options;
var _b7=$.data(_b5,"datagrid").panel;
var _b8=$.data(_b5,"datagrid").data;
var _b9=$.data(_b5,"datagrid").selectedRows;
var _ba=_b8.rows;
var _bb=_b7.find("div.datagrid-body");
$("tr",_bb).addClass("datagrid-row-selected");
$("div.datagrid-cell-check input[type=checkbox]",_bb).attr("checked",true);
for(var _bc=0;_bc<_ba.length;_bc++){
if(_b6.idField){
(function(){
var row=_ba[_bc];
for(var i=0;i<_b9.length;i++){
if(_b9[i][_b6.idField]==row[_b6.idField]){
return;
}
}
_b9.push(row);
})();
}
}
_b6.onSelectAll.call(_b5,_ba);
};
function _b2(_bd){
var _be=$.data(_bd,"datagrid").options;
var _bf=$.data(_bd,"datagrid").panel;
var _c0=$.data(_bd,"datagrid").data;
var _c1=$.data(_bd,"datagrid").selectedRows;
$("div.datagrid-body tr.datagrid-row-selected",_bf).removeClass("datagrid-row-selected");
$("div.datagrid-body div.datagrid-cell-check input[type=checkbox]",_bf).attr("checked",false);
if(_be.idField){
for(var _c2=0;_c2<_c0.rows.length;_c2++){
var id=_c0.rows[_c2][_be.idField];
for(var i=0;i<_c1.length;i++){
if(_c1[i][_be.idField]==id){
_c1.splice(i,1);
break;
}
}
}
}
_be.onUnselectAll.call(_bd,_c0.rows);
};
function _58(_c3,_c4){
var _c5=$.data(_c3,"datagrid").panel;
var _c6=$.data(_c3,"datagrid").options;
var _c7=$.data(_c3,"datagrid").data;
var _c8=$.data(_c3,"datagrid").selectedRows;
if(_c4<0||_c4>=_c7.rows.length){
return;
}
var tr=$("div.datagrid-body tr[datagrid-row-index="+_c4+"]",_c5);
var ck=$("div.datagrid-cell-check input[type=checkbox]",tr);
tr.addClass("datagrid-row-selected");
ck.attr("checked",true);
var _c9=_c5.find("div.datagrid-view2");
var _ca=_c9.find("div.datagrid-header").outerHeight();
var _cb=_c9.find("div.datagrid-body");
var top=tr.position().top-_ca;
if(top<=0){
_cb.scrollTop(_cb.scrollTop()+top);
}else{
if(top+tr.outerHeight()>_cb.height()-18){
_cb.scrollTop(_cb.scrollTop()+top+tr.outerHeight()-_cb.height()+18);
}
}
if(_c6.idField){
var row=_c7.rows[_c4];
(function(){
for(var i=0;i<_c8.length;i++){
if(_c8[i][_c6.idField]==row[_c6.idField]){
return;
}
}
_c8.push(row);
})();
}
_c6.onSelect.call(_c3,_c4,_c7.rows[_c4]);
};
function _cc(_cd,_ce){
var _cf=$.data(_cd,"datagrid").options;
var _d0=$.data(_cd,"datagrid").data;
if(_cf.idField){
var _d1=-1;
for(var i=0;i<_d0.rows.length;i++){
if(_d0.rows[i][_cf.idField]==_ce){
_d1=i;
break;
}
}
if(_d1>=0){
_58(_cd,_d1);
}
}
};
function _59(_d2,_d3){
var _d4=$.data(_d2,"datagrid").options;
var _d5=$.data(_d2,"datagrid").panel;
var _d6=$.data(_d2,"datagrid").data;
var _d7=$.data(_d2,"datagrid").selectedRows;
if(_d3<0||_d3>=_d6.rows.length){
return;
}
var _d8=_d5.find("div.datagrid-body");
var tr=$("tr[datagrid-row-index="+_d3+"]",_d8);
var ck=$("tr[datagrid-row-index="+_d3+"] div.datagrid-cell-check input[type=checkbox]",_d8);
tr.removeClass("datagrid-row-selected");
ck.attr("checked",false);
var row=_d6.rows[_d3];
if(_d4.idField){
for(var i=0;i<_d7.length;i++){
var _d9=_d7[i];
if(_d9[_d4.idField]==row[_d4.idField]){
for(var j=i+1;j<_d7.length;j++){
_d7[j-1]=_d7[j];
}
_d7.pop();
break;
}
}
}
_d4.onUnselect.call(_d2,_d3,row);
};
function _da(_db,_dc){
var _dd=$.data(_db,"datagrid").options;
var _de=$.data(_db,"datagrid").panel;
var _df=$.data(_db,"datagrid").data;
var _e0=$.data(_db,"datagrid").editingRows;
var tr=$("div.datagrid-body tr[datagrid-row-index="+_dc+"]",_de);
if(tr.hasClass("datagrid-row-editing")){
return;
}
if(_dd.onBeforeEdit.call(_db,_dc,_df.rows[_dc])==false){
return;
}
tr.addClass("datagrid-row-editing");
_e1(_db,_dc);
_88(_db);
_e0.push(_df.rows[_dc]);
_e2(_db,_dc,_df.rows[_dc]);
_e3(_db,_dc);
};
function _e4(_e5,_e6,_e7){
var _e8=$.data(_e5,"datagrid").options;
var _e9=$.data(_e5,"datagrid").panel;
var _ea=$.data(_e5,"datagrid").data;
var _eb=$.data(_e5,"datagrid").updatedRows;
var _ec=$.data(_e5,"datagrid").insertedRows;
var _ed=$.data(_e5,"datagrid").editingRows;
var row=_ea.rows[_e6];
var tr=$("div.datagrid-body tr[datagrid-row-index="+_e6+"]",_e9);
if(!tr.hasClass("datagrid-row-editing")){
return;
}
if(!_e7){
if(!_e3(_e5,_e6)){
return;
}
var _ee=false;
var _ef={};
var nd=_f0(_e5,_e6);
for(var _f1 in nd){
if(row[_f1]!=nd[_f1]){
row[_f1]=nd[_f1];
_ee=true;
_ef[_f1]=nd[_f1];
}
}
if(_ee){
if(_ec.indexOf(row)==-1){
if(_eb.indexOf(row)==-1){
_eb.push(row);
}
}
}
}
tr.removeClass("datagrid-row-editing");
_ed.remove(row);
_f2(_e5,_e6);
$(_e5).datagrid("refreshRow",_e6);
if(!_e7){
_e8.onAfterEdit.call(_e5,_e6,row,_ef);
}else{
_e8.onCancelEdit.call(_e5,_e6,row);
}
};
function _e2(_f3,_f4,_f5){
var _f6=$.data(_f3,"datagrid").panel;
var tr=$("div.datagrid-body tr[datagrid-row-index="+_f4+"]",_f6);
if(!tr.hasClass("datagrid-row-editing")){
return;
}
tr.find("div.datagrid-editable").each(function(){
var _f7=$(this).parent().attr("field");
var ed=$.data(this,"datagrid.editor");
ed.actions.setValue(ed.target,_f5[_f7]);
});
};
function _f0(_f8,_f9){
var _fa=$.data(_f8,"datagrid").panel;
var tr=$("div.datagrid-body tr[datagrid-row-index="+_f9+"]",_fa);
if(!tr.hasClass("datagrid-row-editing")){
return {};
}
var _fb={};
tr.find("div.datagrid-editable").each(function(){
var _fc=$(this).parent().attr("field");
var ed=$.data(this,"datagrid.editor");
_fb[_fc]=ed.actions.getValue(ed.target);
});
return _fb;
};
function _fd(_fe,_ff){
var _100=[];
var _101=$.data(_fe,"datagrid").panel;
var tr=$("div.datagrid-body tr[datagrid-row-index="+_ff+"]",_101);
tr.children("td").each(function(){
var cell=$(this).find("div.datagrid-editable");
if(cell.length){
var ed=$.data(cell[0],"datagrid.editor");
_100.push(ed);
}
});
return _100;
};
function _102(_103,_104){
var _105=_fd(_103,_104.index);
for(var i=0;i<_105.length;i++){
if(_105[i].field==_104.field){
return _105[i];
}
}
return null;
};
function _e1(_106,_107){
var opts=$.data(_106,"datagrid").options;
var _108=$.data(_106,"datagrid").panel;
var tr=$("div.datagrid-body tr[datagrid-row-index="+_107+"]",_108);
tr.children("td").each(function(){
var cell=$(this).find("div.datagrid-cell");
var _109=$(this).attr("field");
var col=_6c(_106,_109);
if(col&&col.editor){
var _10a,_10b;
if(typeof col.editor=="string"){
_10a=col.editor;
}else{
_10a=col.editor.type;
_10b=col.editor.options;
}
var _10c=opts.editors[_10a];
if(_10c){
var _10d=cell.outerWidth();
cell.addClass("datagrid-editable");
if($.boxModel==true){
cell.width(_10d-(cell.outerWidth()-cell.width()));
}
cell.html("<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\"><tr><td></td></tr></table>");
cell.find("table").attr("align",col.align);
$.data(cell[0],"datagrid.editor",{actions:_10c,target:_10c.init(cell.find("td"),_10b),field:_109,type:_10a});
}
}
});
_18(_106,_107);
};
function _f2(_10e,_10f){
var _110=$.data(_10e,"datagrid").panel;
var tr=$("div.datagrid-body tr[datagrid-row-index="+_10f+"]",_110);
tr.children("td").each(function(){
var cell=$(this).find("div.datagrid-editable");
if(cell.length){
var ed=$.data(cell[0],"datagrid.editor");
if(ed.actions.destroy){
ed.actions.destroy(ed.target);
}
$.removeData(cell[0],"datagrid.editor");
var _111=cell.outerWidth();
cell.removeClass("datagrid-editable");
if($.boxModel==true){
cell.width(_111-(cell.outerWidth()-cell.width()));
}
}
});
};
function _e3(_112,_113){
var _114=$.data(_112,"datagrid").panel;
var tr=$("div.datagrid-body tr[datagrid-row-index="+_113+"]",_114);
if(!tr.hasClass("datagrid-row-editing")){
return true;
}
var vbox=tr.find(".validatebox-text");
vbox.validatebox("validate");
vbox.trigger("mouseleave");
var _115=tr.find(".validatebox-invalid");
return _115.length==0;
};
function _116(_117,_118){
var _119=$.data(_117,"datagrid").insertedRows;
var _11a=$.data(_117,"datagrid").deletedRows;
var _11b=$.data(_117,"datagrid").updatedRows;
if(!_118){
var rows=[];
rows=rows.concat(_119);
rows=rows.concat(_11a);
rows=rows.concat(_11b);
return rows;
}else{
if(_118=="inserted"){
return _119;
}else{
if(_118=="deleted"){
return _11a;
}else{
if(_118=="updated"){
return _11b;
}
}
}
}
return [];
};
function _11c(_11d,_11e){
var data=$.data(_11d,"datagrid").data;
var _11f=$.data(_11d,"datagrid").insertedRows;
var _120=$.data(_11d,"datagrid").deletedRows;
var _121=$.data(_11d,"datagrid").editingRows;
var _122=$.data(_11d,"datagrid").selectedRows;
var row=data.rows[_11e];
data.total-=1;
if(_11f.indexOf(row)>=0){
_11f.remove(row);
_122.remove(row);
}else{
_120.push(row);
}
if(_121.indexOf(row)>=0){
_121.remove(row);
_f2(_11d,_11e);
}
var _123=[];
for(var i=0;i<_121.length;i++){
var idx=data.rows.indexOf(_121[i]);
_123.push(_f0(_11d,idx));
_f2(_11d,idx);
}
data.rows.remove(row);
_97(_11d,data);
var _124=[];
for(var i=0;i<_121.length;i++){
var idx=data.rows.indexOf(_121[i]);
_124.push(idx);
}
_121.splice(0,_121.length);
for(var i=0;i<_124.length;i++){
_da(_11d,_124[i]);
_e2(_11d,_124[i],_123[i]);
}
};
function _125(_126,row){
if(!row){
return;
}
var _127=$.data(_126,"datagrid").panel;
var data=$.data(_126,"datagrid").data;
var _128=$.data(_126,"datagrid").insertedRows;
var _129=$.data(_126,"datagrid").editingRows;
data.total+=1;
data.rows.push(row);
_128.push(row);
var _12a=[];
for(var i=0;i<_129.length;i++){
var idx=data.rows.indexOf(_129[i]);
_12a.push(_f0(_126,idx));
_f2(_126,idx);
}
_97(_126,data);
var _12b=[];
for(var i=0;i<_129.length;i++){
var idx=data.rows.indexOf(_129[i]);
_12b.push(idx);
}
_129.splice(0,_129.length);
for(var i=0;i<_12b.length;i++){
_da(_126,_12b[i]);
_e2(_126,_12b[i],_12a[i]);
}
var _12c=$("div.datagrid-view2 div.datagrid-body",_127);
var _12d=_12c.children("table");
var top=_12d.outerHeight()-_12c.outerHeight();
_12c.scrollTop(top+20);
};
function _12e(_12f){
var data=$.data(_12f,"datagrid").data;
var rows=data.rows;
var _130=[];
for(var i=0;i<rows.length;i++){
_130.push($.extend({},rows[i]));
}
$.data(_12f,"datagrid").originalRows=_130;
$.data(_12f,"datagrid").updatedRows=[];
$.data(_12f,"datagrid").insertedRows=[];
$.data(_12f,"datagrid").deletedRows=[];
$.data(_12f,"datagrid").editingRows=[];
};
function _131(_132){
var data=$.data(_132,"datagrid").data;
var ok=true;
for(var i=0,len=data.rows.length;i<len;i++){
if(_e3(_132,i)){
_e4(_132,i,false);
}else{
ok=false;
}
}
if(ok){
_12e(_132);
}
};
function _133(_134){
var opts=$.data(_134,"datagrid").options;
var _135=$.data(_134,"datagrid").originalRows;
var _136=$.data(_134,"datagrid").insertedRows;
var _137=$.data(_134,"datagrid").deletedRows;
var _138=$.data(_134,"datagrid").updatedRows;
var _139=$.data(_134,"datagrid").selectedRows;
var data=$.data(_134,"datagrid").data;
for(var i=0;i<data.rows.length;i++){
_e4(_134,i,true);
}
var rows=[];
var _13a={};
if(opts.idField){
for(var i=0;i<_139.length;i++){
_13a[_139[i][opts.idField]]=true;
}
}
_139.splice(0,_139.length);
for(var i=0;i<_135.length;i++){
var row=$.extend({},_135[i]);
rows.push(row);
if(_13a[row[opts.idField]]){
_139.push(row);
}
}
data.total+=_137.length-_136.length;
data.rows=rows;
_97(_134,data);
$.data(_134,"datagrid").updatedRows=[];
$.data(_134,"datagrid").insertedRows=[];
$.data(_134,"datagrid").deletedRows=[];
$.data(_134,"datagrid").editingRows=[];
};
function _13b(_13c,_13d){
var _13e=$.data(_13c,"datagrid").panel;
var opts=$.data(_13c,"datagrid").options;
if(_13d){
opts.queryParams=_13d;
}
if(!opts.url){
return;
}
var _13f=$.extend({},opts.queryParams);
if(opts.pagination){
$.extend(_13f,{page:opts.pageNumber,rows:opts.pageSize});
}
if(opts.sortName){
$.extend(_13f,{sort:opts.sortName,order:opts.sortOrder});
}
if(opts.onBeforeLoad.call(_13c,_13f)==false){
return;
}
_140();
setTimeout(function(){
_141();
},0);
function _141(){
$.ajax({type:opts.method,url:opts.url,data:_13f,dataType:"json",success:function(data){
setTimeout(function(){
_142();
},0);
_97(_13c,data);
setTimeout(function(){
_12e(_13c);
},0);
},error:function(){
setTimeout(function(){
_142();
},0);
if(opts.onLoadError){
opts.onLoadError.apply(_13c,arguments);
}
}});
};
function _140(){
_13e.children("div.datagrid-pager").pagination("loading");
if(opts.loadMsg){
var wrap=_13e;
$("<div class=\"datagrid-mask\"></div>").css({display:"block",width:wrap.width(),height:wrap.height()}).appendTo(wrap);
$("<div class=\"datagrid-mask-msg\"></div>").html(opts.loadMsg).appendTo(wrap).css({display:"block",left:(wrap.width()-$("div.datagrid-mask-msg",wrap).outerWidth())/2,top:(wrap.height()-$("div.datagrid-mask-msg",wrap).outerHeight())/2});
}
};
function _142(){
_13e.find("div.datagrid-pager").pagination("loaded");
_13e.find("div.datagrid-mask-msg").remove();
_13e.find("div.datagrid-mask").remove();
};
};
function _143(_144,_145){
var rows=$.data(_144,"datagrid").data.rows;
var _146=$.data(_144,"datagrid").panel;
_145.rowspan=_145.rowspan||1;
_145.colspan=_145.colspan||1;
if(_145.index<0||_145.index>=rows.length){
return;
}
if(_145.rowspan==1&&_145.colspan==1){
return;
}
var _147=rows[_145.index][_145.field];
var tr=_146.find("div.datagrid-body tr[datagrid-row-index="+_145.index+"]");
var td=tr.find("td[field="+_145.field+"]");
td.attr("rowspan",_145.rowspan).attr("colspan",_145.colspan);
td.addClass("datagrid-td-merged");
for(var i=1;i<_145.colspan;i++){
td=td.next();
td.hide();
rows[_145.index][td.attr("field")]=_147;
}
for(var i=1;i<_145.rowspan;i++){
tr=tr.next();
var td=tr.find("td[field="+_145.field+"]").hide();
rows[_145.index+i][td.attr("field")]=_147;
for(var j=1;j<_145.colspan;j++){
td=td.next();
td.hide();
rows[_145.index+i][td.attr("field")]=_147;
}
}
setTimeout(function(){
_7f(_144);
},0);
};
$.fn.datagrid=function(_148,_149){
if(typeof _148=="string"){
return $.fn.datagrid.methods[_148](this,_149);
}
_148=_148||{};
return this.each(function(){
var _14a=$.data(this,"datagrid");
var opts;
if(_14a){
opts=$.extend(_14a.options,_148);
_14a.options=opts;
}else{
opts=$.extend({},$.fn.datagrid.defaults,$.fn.datagrid.parseOptions(this),_148);
$(this).css("width",null).css("height",null);
var _14b=_27(this,opts.rownumbers);
if(!opts.columns){
opts.columns=_14b.columns;
}
if(!opts.frozenColumns){
opts.frozenColumns=_14b.frozenColumns;
}
$.data(this,"datagrid",{options:opts,panel:_14b.panel,selectedRows:[],data:{total:0,rows:[]},originalRows:[],updatedRows:[],insertedRows:[],deletedRows:[],editingRows:[]});
_97(this,_33(this));
_12e(this);
}
_38(this);
if(!_14a){
_30(this);
}
_3(this);
if(opts.url){
_13b(this);
}
_5a(this);
});
};
var _14c={text:{init:function(_14d,_14e){
var _14f=$("<input type=\"text\" class=\"datagrid-editable-input\">").appendTo(_14d);
return _14f;
},getValue:function(_150){
return $(_150).val();
},setValue:function(_151,_152){
$(_151).val(_152);
},resize:function(_153,_154){
var _155=$(_153);
if($.boxModel==true){
_155.width(_154-(_155.outerWidth()-_155.width()));
}else{
_155.width(_154);
}
}},textarea:{init:function(_156,_157){
var _158=$("<textarea class=\"datagrid-editable-input\"></textarea>").appendTo(_156);
return _158;
},getValue:function(_159){
return $(_159).val();
},setValue:function(_15a,_15b){
$(_15a).val(_15b);
},resize:function(_15c,_15d){
var _15e=$(_15c);
if($.boxModel==true){
_15e.width(_15d-(_15e.outerWidth()-_15e.width()));
}else{
_15e.width(_15d);
}
}},checkbox:{init:function(_15f,_160){
var _161=$("<input type=\"checkbox\">").appendTo(_15f);
_161.val(_160.on);
_161.attr("offval",_160.off);
return _161;
},getValue:function(_162){
if($(_162).attr("checked")){
return $(_162).val();
}else{
return $(_162).attr("offval");
}
},setValue:function(_163,_164){
if($(_163).val()==_164){
$(_163).attr("checked",true);
}else{
$(_163).attr("checked",false);
}
}},numberbox:{init:function(_165,_166){
var _167=$("<input type=\"text\" class=\"datagrid-editable-input\">").appendTo(_165);
_167.numberbox(_166);
return _167;
},getValue:function(_168){
return $(_168).val();
},setValue:function(_169,_16a){
$(_169).val(_16a);
},resize:function(_16b,_16c){
var _16d=$(_16b);
if($.boxModel==true){
_16d.width(_16c-(_16d.outerWidth()-_16d.width()));
}else{
_16d.width(_16c);
}
}},validatebox:{init:function(_16e,_16f){
var _170=$("<input type=\"text\" class=\"datagrid-editable-input\">").appendTo(_16e);
_170.validatebox(_16f);
return _170;
},destroy:function(_171){
$(_171).validatebox("destroy");
},getValue:function(_172){
return $(_172).val();
},setValue:function(_173,_174){
$(_173).val(_174);
},resize:function(_175,_176){
var _177=$(_175);
if($.boxModel==true){
_177.width(_176-(_177.outerWidth()-_177.width()));
}else{
_177.width(_176);
}
}},datebox:{init:function(_178,_179){
var _17a=$("<input type=\"text\" class=\"datagrid-editable-input\">").appendTo(_178);
_17a.datebox(_179);
return _17a;
},destroy:function(_17b){
$(_17b).datebox("destroy");
},getValue:function(_17c){
return $(_17c).val();
},setValue:function(_17d,_17e){
$(_17d).val(_17e);
},resize:function(_17f,_180){
var _181=$(_17f);
if($.boxModel==true){
_181.width(_180-(_181.outerWidth()-_181.width()));
}else{
_181.width(_180);
}
}},combobox:{init:function(_182,_183){
var _184=$("<input type=\"text\">").appendTo(_182);
_184.combobox(_183||{});
return _184;
},destroy:function(_185){
$(_185).combobox("destroy");
},getValue:function(_186){
return $(_186).combobox("getValue");
},setValue:function(_187,_188){
$(_187).combobox("setValue",_188);
},resize:function(_189,_18a){
$(_189).combobox("resize",_18a);
}},combotree:{init:function(_18b,_18c){
var _18d=$("<input type=\"text\">").appendTo(_18b);
_18d.combotree(_18c);
return _18d;
},destroy:function(_18e){
$(_18e).combotree("destroy");
},getValue:function(_18f){
return $(_18f).combotree("getValue");
},setValue:function(_190,_191){
$(_190).combotree("setValue",_191);
},resize:function(_192,_193){
$(_192).combotree("resize",_193);
}}};
$.fn.datagrid.methods={options:function(jq){
var _194=$.data(jq[0],"datagrid").options;
var _195=$.data(jq[0],"datagrid").panel.panel("options");
var opts=$.extend(_194,{width:_195.width,height:_195.height,closed:_195.closed,collapsed:_195.collapsed,minimized:_195.minimized,maximized:_195.maximized});
var _196=jq.datagrid("getPager");
if(_196.length){
var _197=_196.pagination("options");
$.extend(opts,{pageNumber:_197.pageNumber,pageSize:_197.pageSize});
}
return opts;
},getPanel:function(jq){
return $.data(jq[0],"datagrid").panel;
},getPager:function(jq){
return $.data(jq[0],"datagrid").panel.find("div.datagrid-pager");
},getColumnFields:function(jq,_198){
return _37(jq[0],_198);
},getColumnOption:function(jq,_199){
return _6c(jq[0],_199);
},resize:function(jq,_19a){
return jq.each(function(){
_3(this,_19a);
});
},reload:function(jq,_19b){
return jq.each(function(){
_13b(this,_19b);
});
},fitColumns:function(jq){
return jq.each(function(){
_6e(this);
});
},fixColumnSize:function(jq){
return jq.each(function(){
_30(this);
});
},fixRowHeight:function(jq,_19c){
return jq.each(function(){
_18(this,_19c);
});
},loadData:function(jq,data){
return jq.each(function(){
_97(this,data);
_12e(this);
});
},getData:function(jq){
return $.data(jq[0],"datagrid").data;
},getRows:function(jq){
return $.data(jq[0],"datagrid").data.rows;
},getRowIndex:function(jq,id){
return _a4(jq[0],id);
},getSelected:function(jq){
var rows=_a8(jq[0]);
return rows.length>0?rows[0]:null;
},getSelections:function(jq){
return _a8(jq[0]);
},clearSelections:function(jq){
return jq.each(function(){
_57(this);
});
},selectAll:function(jq){
return jq.each(function(){
_b4(this);
});
},unselectAll:function(jq){
return jq.each(function(){
_b2(this);
});
},selectRow:function(jq,_19d){
return jq.each(function(){
_58(this,_19d);
});
},selectRecord:function(jq,id){
return jq.each(function(){
_cc(this,id);
});
},unselectRow:function(jq,_19e){
return jq.each(function(){
_59(this,_19e);
});
},beginEdit:function(jq,_19f){
return jq.each(function(){
_da(this,_19f);
});
},endEdit:function(jq,_1a0){
return jq.each(function(){
_e4(this,_1a0,false);
});
},cancelEdit:function(jq,_1a1){
return jq.each(function(){
_e4(this,_1a1,true);
});
},getEditors:function(jq,_1a2){
return _fd(jq[0],_1a2);
},getEditor:function(jq,_1a3){
return _102(jq[0],_1a3);
},refreshRow:function(jq,_1a4){
return jq.each(function(){
var opts=$.data(this,"datagrid").options;
opts.view.refreshRow.call(opts.view,this,_1a4);
});
},validateRow:function(jq,_1a5){
return jq.each(function(){
_e3(this,_1a5);
});
},appendRow:function(jq,row){
return jq.each(function(){
_125(this,row);
});
},deleteRow:function(jq,_1a6){
return jq.each(function(){
_11c(this,_1a6);
});
},getChanges:function(jq,_1a7){
return _116(jq[0],_1a7);
},acceptChanges:function(jq){
return jq.each(function(){
_131(this);
});
},rejectChanges:function(jq){
return jq.each(function(){
_133(this);
});
},mergeCells:function(jq,_1a8){
return jq.each(function(){
_143(this,_1a8);
});
},showColumn:function(jq,_1a9){
return jq.each(function(){
var _1aa=$(this).datagrid("getPanel");
_1aa.find("td[field="+_1a9+"]").show();
$(this).datagrid("getColumnOption",_1a9).hidden=false;
$(this).datagrid("fitColumns");
});
},hideColumn:function(jq,_1ab){
return jq.each(function(){
var _1ac=$(this).datagrid("getPanel");
_1ac.find("td[field="+_1ab+"]").hide();
$(this).datagrid("getColumnOption",_1ab).hidden=true;
$(this).datagrid("fitColumns");
});
}};
$.fn.datagrid.parseOptions=function(_1ad){
var t=$(_1ad);
return $.extend({},$.fn.panel.parseOptions(_1ad),{fitColumns:(t.attr("fitColumns")?t.attr("fitColumns")=="true":undefined),striped:(t.attr("striped")?t.attr("striped")=="true":undefined),nowrap:(t.attr("nowrap")?t.attr("nowrap")=="true":undefined),rownumbers:(t.attr("rownumbers")?t.attr("rownumbers")=="true":undefined),singleSelect:(t.attr("singleSelect")?t.attr("singleSelect")=="true":undefined),pagination:(t.attr("pagination")?t.attr("pagination")=="true":undefined),remoteSort:(t.attr("remoteSort")?t.attr("remoteSort")=="true":undefined),idField:t.attr("idField"),url:t.attr("url")});
};
var _1ae={render:function(_1af,_1b0,_1b1){
var opts=$.data(_1af,"datagrid").options;
var rows=$.data(_1af,"datagrid").data.rows;
var _1b2=$(_1af).datagrid("getColumnFields",_1b1);
if(_1b1){
if(!(opts.rownumbers||(opts.frozenColumns&&opts.frozenColumns.length))){
return;
}
}
var _1b3=["<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>"];
for(var i=0;i<rows.length;i++){
if(i%2&&opts.striped){
_1b3.push("<tr datagrid-row-index=\""+i+"\" class=\"datagrid-row-alt\">");
}else{
_1b3.push("<tr datagrid-row-index=\""+i+"\">");
}
_1b3.push(this.renderRow.call(this,_1af,_1b2,_1b1,i,rows[i]));
_1b3.push("</tr>");
}
_1b3.push("</tbody></table>");
$(_1b0).html(_1b3.join(""));
},renderRow:function(_1b4,_1b5,_1b6,_1b7,_1b8){
var opts=$.data(_1b4,"datagrid").options;
var cc=[];
if(_1b6&&opts.rownumbers){
var _1b9=_1b7+1;
if(opts.pagination){
_1b9+=(opts.pageNumber-1)*opts.pageSize;
}
cc.push("<td class=\"datagrid-td-rownumber\"><div class=\"datagrid-cell-rownumber\">"+_1b9+"</div></td>");
}
for(var i=0;i<_1b5.length;i++){
var _1ba=_1b5[i];
var col=$(_1b4).datagrid("getColumnOption",_1ba);
if(col){
var _1bb="width:"+(col.boxWidth)+"px;";
_1bb+="text-align:"+(col.align||"left")+";";
_1bb+=opts.nowrap==false?"white-space:normal;":"";
if(col.hidden){
cc.push("<td field=\""+_1ba+"\" style=\"display:none;\">");
}else{
cc.push("<td field=\""+_1ba+"\">");
}
cc.push("<div style=\""+_1bb+"\" ");
if(col.checkbox){
cc.push("class=\"datagrid-cell-check ");
}else{
cc.push("class=\"datagrid-cell ");
}
cc.push("\">");
if(col.checkbox){
cc.push("<input type=\"checkbox\"/>");
}else{
if(col.formatter){
cc.push(col.formatter(_1b8[_1ba],_1b8,_1b7));
}else{
cc.push(_1b8[_1ba]);
}
}
cc.push("</div>");
cc.push("</td>");
}
}
return cc.join("");
},refreshRow:function(_1bc,_1bd){
var _1be=$(_1bc).datagrid("getPanel");
var rows=$(_1bc).datagrid("getRows");
_1be.find("div.datagrid-body tr[datagrid-row-index="+_1bd+"] td").each(function(){
var cell=$(this).find("div.datagrid-cell");
var _1bf=$(this).attr("field");
var col=$(_1bc).datagrid("getColumnOption",_1bf);
if(col){
if(col.formatter){
cell.html(col.formatter(rows[_1bd][_1bf],rows[_1bd],_1bd));
}else{
cell.html(rows[_1bd][_1bf]);
}
}
});
$(_1bc).datagrid("fixRowHeight",_1bd);
},onBeforeRender:function(_1c0,rows){
},onAfterRender:function(_1c1){
}};
$.fn.datagrid.defaults=$.extend({},$.fn.panel.defaults,{frozenColumns:null,columns:null,fitColumns:false,toolbar:null,striped:false,method:"post",nowrap:true,idField:null,url:null,loadMsg:"Processing, please wait ...",rownumbers:false,singleSelect:false,pagination:false,pageNumber:1,pageSize:10,pageList:[10,20,30,40,50],queryParams:{},sortName:null,sortOrder:"asc",remoteSort:true,editors:_14c,view:_1ae,onBeforeLoad:function(_1c2){
},onLoadSuccess:function(){
},onLoadError:function(){
},onClickRow:function(_1c3,_1c4){
},onDblClickRow:function(_1c5,_1c6){
},onSortColumn:function(sort,_1c7){
},onResizeColumn:function(_1c8,_1c9){
},onSelect:function(_1ca,_1cb){
},onUnselect:function(_1cc,_1cd){
},onSelectAll:function(rows){
},onUnselectAll:function(rows){
},onBeforeEdit:function(_1ce,_1cf){
},onAfterEdit:function(_1d0,_1d1,_1d2){
},onCancelEdit:function(_1d3,_1d4){
},onHeaderContextMenu:function(e,_1d5){
},onRowContextMenu:function(e,_1d6,_1d7){
}});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"timespinner").options;
$(_2).spinner(_3);
$(_2).unbind(".timespinner");
$(_2).bind("click.timespinner",function(){
var _4=0;
if(this.selectionStart!=null){
_4=this.selectionStart;
}else{
if(this.createTextRange){
var _5=_2.createTextRange();
var s=document.selection.createRange();
s.setEndPoint("StartToStart",_5);
_4=s.text.length;
}
}
if(_4>=0&&_4<=2){
_3.highlight=0;
}else{
if(_4>=3&&_4<=5){
_3.highlight=1;
}else{
if(_4>=6&&_4<=8){
_3.highlight=2;
}
}
}
_7(_2);
}).bind("blur.timespinner",function(){
_6(_2);
});
};
function _7(_8){
var _9=$.data(_8,"timespinner").options;
var _a=0,_b=0;
if(_9.highlight==0){
_a=0;
_b=2;
}else{
if(_9.highlight==1){
_a=3;
_b=5;
}else{
if(_9.highlight==2){
_a=6;
_b=8;
}
}
}
if(_8.selectionStart!=null){
_8.setSelectionRange(_a,_b);
}else{
if(_8.createTextRange){
var _c=_8.createTextRange();
_c.collapse();
_c.moveEnd("character",_b);
_c.moveStart("character",_a);
_c.select();
}
}
$(_8).focus();
};
function _d(_e,_f){
var _10=$.data(_e,"timespinner").options;
if(!_f){
return null;
}
var vv=_f.split(_10.separator);
for(var i=0;i<vv.length;i++){
if(isNaN(vv[i])){
return null;
}
}
while(vv.length<3){
vv.push(0);
}
return new Date(1900,0,0,vv[0],vv[1],vv[2]);
};
function _6(_11){
var _12=$.data(_11,"timespinner").options;
var _13=$(_11).val();
var _14=_d(_11,_13);
if(!_14){
_14=_d(_11,_12.value);
}
if(!_14){
_12.value="";
$(_11).val("");
return;
}
var _15=_d(_11,_12.min);
var _16=_d(_11,_12.max);
if(_15&&_15>_14){
_14=_15;
}
if(_16&&_16<_14){
_14=_16;
}
var tt=[_17(_14.getHours()),_17(_14.getMinutes())];
if(_12.showSeconds){
tt.push(_17(_14.getSeconds()));
}
var val=tt.join(_12.separator);
_12.value=val;
$(_11).val(val);
function _17(_18){
return (_18<10?"0":"")+_18;
};
};
function _19(_1a,_1b){
var _1c=$.data(_1a,"timespinner").options;
var val=$(_1a).val();
if(val==""){
val=[0,0,0].join(_1c.separator);
}
var vv=val.split(_1c.separator);
for(var i=0;i<vv.length;i++){
vv[i]=parseInt(vv[i],10);
}
if(_1b==true){
vv[_1c.highlight]-=_1c.increment;
}else{
vv[_1c.highlight]+=_1c.increment;
}
$(_1a).val(vv.join(_1c.separator));
_6(_1a);
_7(_1a);
};
$.fn.timespinner=function(_1d,_1e){
if(typeof _1d=="string"){
var _1f=$.fn.timespinner.methods[_1d];
if(_1f){
return _1f(this,_1e);
}else{
return this.spinner(_1d,_1e);
}
}
_1d=_1d||{};
return this.each(function(){
var _20=$.data(this,"timespinner");
if(_20){
$.extend(_20.options,_1d);
}else{
$.data(this,"timespinner",{options:$.extend({},$.fn.timespinner.defaults,$.fn.timespinner.parseOptions(this),_1d)});
_1(this);
}
});
};
$.fn.timespinner.methods={options:function(jq){
var _21=$.data(jq[0],"timespinner").options;
return $.extend(_21,{value:jq.val()});
},setValue:function(jq,_22){
return jq.each(function(){
$(this).val(_22);
_6(this);
});
}};
$.fn.timespinner.parseOptions=function(_23){
var t=$(_23);
return $.extend({},$.fn.spinner.parseOptions(_23),{separator:t.attr("separator"),showSeconds:(t.attr("showSeconds")?t.attr("showSeconds")=="true":undefined),highlight:(parseInt(t.attr("highlight"))||undefined)});
};
$.fn.timespinner.defaults=$.extend({},$.fn.spinner.defaults,{separator:":",showSeconds:false,highlight:0,spin:function(_24){
_19(this,_24);
}});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2,_3){
var _4=$.data(_2,"combo").options;
var _5=$.data(_2,"combo").combo;
var _6=$.data(_2,"combo").panel;
if(_3){
_4.width=_3;
}
_5.appendTo("body");
if(isNaN(_4.width)){
_4.width=_5.find("input.combo-text").outerWidth();
}
var _7=_5.find(".combo-arrow").outerWidth();
var _3=_4.width-_7;
if($.boxModel==true){
_3-=_5.outerWidth()-_5.width();
}
_5.find("input.combo-text").width(_3);
_6.panel("resize",{width:(_4.panelWidth?_4.panelWidth:_5.outerWidth()),height:_4.panelHeight});
_5.insertAfter(_2);
};
function _8(_9){
$(_9).addClass("combo-f").hide();
var _a=$("<span class=\"combo\"></span>").insertAfter(_9);
var _b=$("<input type=\"text\" class=\"combo-text\">").appendTo(_a);
$("<span><span class=\"combo-arrow\"></span></span>").appendTo(_a);
$("<input type=\"hidden\" class=\"combo-value\">").appendTo(_a);
var _c=$("<div class=\"combo-panel\"></div>").appendTo("body");
_c.panel({doSize:false,closed:true,style:{position:"absolute",zIndex:10},onOpen:function(){
$(this).panel("resize");
}});
var _d=$(_9).attr("name");
if(_d){
_a.find("input.combo-value").attr("name",_d);
$(_9).removeAttr("name").attr("comboName",_d);
}
_b.attr("autocomplete","off");
return {combo:_a,panel:_c};
};
function _e(_f){
var _10=$.data(_f,"combo").combo.find("input.combo-text");
_10.validatebox("destroy");
$.data(_f,"combo").panel.panel("destroy");
$.data(_f,"combo").combo.remove();
$(_f).remove();
};
function _11(_12){
var _13=$.data(_12,"combo").options;
var _14=$.data(_12,"combo").combo;
var _15=$.data(_12,"combo").panel;
var _16=_14.find(".combo-text");
var _17=_14.find(".combo-arrow");
$(document).unbind(".combo");
_14.unbind(".combo");
_15.unbind(".combo");
_16.unbind(".combo");
_17.unbind(".combo");
if(!_13.disabled){
$(document).bind("mousedown.combo",function(e){
$("div.combo-panel").panel("close");
});
_15.bind("mousedown.combo",function(e){
return false;
});
_16.bind("mousedown.combo",function(e){
e.stopPropagation();
}).bind("keydown.combo",function(e){
switch(e.keyCode){
case 38:
_13.keyHandler.up.call(_12);
break;
case 40:
_13.keyHandler.down.call(_12);
break;
case 13:
e.preventDefault();
_13.keyHandler.enter.call(_12);
return false;
case 9:
case 27:
_1e(_12);
break;
default:
if(_13.editable){
setTimeout(function(){
var q=_16.val();
if($.data(_12,"combo").previousValue!=q){
$.data(_12,"combo").previousValue=q;
_18(_12);
_13.keyHandler.query.call(_12,_16.val());
_22(_12,true);
}
},10);
}
}
});
_17.bind("click.combo",function(){
_16.focus();
_18(_12);
}).bind("mouseenter.combo",function(){
$(this).addClass("combo-arrow-hover");
}).bind("mouseleave.combo",function(){
$(this).removeClass("combo-arrow-hover");
});
}
};
function _18(_19){
var _1a=$.data(_19,"combo").options;
var _1b=$.data(_19,"combo").combo;
var _1c=$.data(_19,"combo").panel;
if($.fn.window){
_1c.panel("panel").css("z-index",$.fn.window.defaults.zIndex++);
}
_1c.panel("move",{left:_1b.offset().left,top:_1d()});
_1c.panel("open");
_1a.onShowPanel.call(_19);
(function(){
if(_1c.is(":visible")){
_1c.panel("move",{left:_1b.offset().left,top:_1d()});
setTimeout(arguments.callee,200);
}
})();
function _1d(){
var top=_1b.offset().top+_1b.outerHeight();
if(top+_1c.outerHeight()>$(window).height()+$(document).scrollTop()){
top=_1b.offset().top-_1c.outerHeight();
}
if(top<$(document).scrollTop()){
top=_1b.offset().top+_1b.outerHeight();
}
return top;
};
};
function _1e(_1f){
var _20=$.data(_1f,"combo").options;
var _21=$.data(_1f,"combo").panel;
_21.panel("close");
_20.onHidePanel.call(_1f);
};
function _22(_23,_24){
var _25=$.data(_23,"combo").options;
var _26=$.data(_23,"combo").combo.find("input.combo-text");
_26.validatebox(_25);
if(_24){
_26.validatebox("validate");
_26.trigger("mouseleave");
}
};
function _27(_28,_29){
var _2a=$.data(_28,"combo").options;
var _2b=$.data(_28,"combo").combo;
if(_29){
_2a.disabled=true;
$(_28).attr("disabled",true);
_2b.find(".combo-value").attr("disabled",true);
_2b.find(".combo-text").attr("disabled",true);
}else{
_2a.disabled=false;
$(_28).removeAttr("disabled");
_2b.find(".combo-value").removeAttr("disabled");
_2b.find(".combo-text").removeAttr("disabled");
}
};
function _2c(_2d){
var _2e=$.data(_2d,"combo").options;
var _2f=$.data(_2d,"combo").combo;
if(_2e.multiple){
_2f.find("input.combo-value").remove();
}else{
_2f.find("input.combo-value").val("");
}
_2f.find("input.combo-text").val("");
};
function _30(_31){
var _32=$.data(_31,"combo").combo;
return _32.find("input.combo-text").val();
};
function _33(_34,_35){
var _36=$.data(_34,"combo").combo;
_36.find("input.combo-text").val(_35);
_22(_34,true);
$.data(_34,"combo").previousValue=_35;
};
function _37(_38){
var _39=[];
var _3a=$.data(_38,"combo").combo;
_3a.find("input.combo-value").each(function(){
_39.push($(this).val());
});
return _39;
};
function _3b(_3c,_3d){
var _3e=$.data(_3c,"combo").options;
var _3f=_37(_3c);
var _40=$.data(_3c,"combo").combo;
_40.find("input.combo-value").remove();
var _41=$(_3c).attr("comboName");
for(var i=0;i<_3d.length;i++){
var _42=$("<input type=\"hidden\" class=\"combo-value\">").appendTo(_40);
if(_41){
_42.attr("name",_41);
}
_42.val(_3d[i]);
}
var tmp=[];
for(var i=0;i<_3f.length;i++){
tmp[i]=_3f[i];
}
var aa=[];
for(var i=0;i<_3d.length;i++){
for(var j=0;j<tmp.length;j++){
if(_3d[i]==tmp[j]){
aa.push(_3d[i]);
tmp.splice(j,1);
break;
}
}
}
if(aa.length!=_3d.length||_3d.length!=_3f.length){
if(_3e.multiple){
_3e.onChange.call(_3c,_3d,_3f);
}else{
_3e.onChange.call(_3c,_3d[0],_3f[0]);
}
}
};
function _43(_44){
var _45=_37(_44);
return _45[0];
};
function _46(_47,_48){
_3b(_47,[_48]);
};
function _49(_4a){
var _4b=$.data(_4a,"combo").options;
if(_4b.multiple){
if(_4b.value){
if(typeof _4b.value=="object"){
_3b(_4a,_4b.value);
}else{
_46(_4a,_4b.value);
}
}else{
_3b(_4a,[]);
}
}else{
_46(_4a,_4b.value);
}
};
$.fn.combo=function(_4c,_4d){
if(typeof _4c=="string"){
return $.fn.combo.methods[_4c](this,_4d);
}
_4c=_4c||{};
return this.each(function(){
var _4e=$.data(this,"combo");
if(_4e){
$.extend(_4e.options,_4c);
}else{
var r=_8(this);
_4e=$.data(this,"combo",{options:$.extend({},$.fn.combo.defaults,$.fn.combo.parseOptions(this),_4c),combo:r.combo,panel:r.panel,previousValue:null});
$(this).removeAttr("disabled");
}
$("input.combo-text",_4e.combo).attr("readonly",!_4e.options.editable);
_27(this,_4e.options.disabled);
_1(this);
_11(this);
_22(this);
_49(this);
});
};
$.fn.combo.methods={options:function(jq){
return $.data(jq[0],"combo").options;
},panel:function(jq){
return $.data(jq[0],"combo").panel;
},textbox:function(jq){
return $.data(jq[0],"combo").combo.find("input.combo-text");
},destroy:function(jq){
return jq.each(function(){
_e(this);
});
},resize:function(jq,_4f){
return jq.each(function(){
_1(this,_4f);
});
},showPanel:function(jq){
return jq.each(function(){
_18(this);
});
},hidePanel:function(jq){
return jq.each(function(){
_1e(this);
});
},disable:function(jq){
return jq.each(function(){
_27(this,true);
_11(this);
});
},enable:function(jq){
return jq.each(function(){
_27(this,false);
_11(this);
});
},validate:function(jq){
return jq.each(function(){
_22(this,true);
});
},isValid:function(jq){
var _50=$.data(jq[0],"combo").combo.find("input.combo-text");
return _50.validatebox("isValid");
},clear:function(jq){
return jq.each(function(){
_2c(this);
});
},getText:function(jq){
return _30(jq[0]);
},setText:function(jq,_51){
return jq.each(function(){
_33(this,_51);
});
},getValues:function(jq){
return _37(jq[0]);
},setValues:function(jq,_52){
return jq.each(function(){
_3b(this,_52);
});
},getValue:function(jq){
return _43(jq[0]);
},setValue:function(jq,_53){
return jq.each(function(){
_46(this,_53);
});
}};
$.fn.combo.parseOptions=function(_54){
var t=$(_54);
return $.extend({},$.fn.validatebox.parseOptions(_54),{width:(parseInt(_54.style.width)||undefined),panelWidth:(parseInt(t.attr("panelWidth"))||undefined),panelHeight:(t.attr("panelHeight")=="auto"?"auto":parseInt(t.attr("panelHeight"))||undefined),separator:(t.attr("separator")||undefined),multiple:(t.attr("multiple")?(t.attr("multiple")=="true"||t.attr("multiple")==true):undefined),editable:(t.attr("editable")?t.attr("editable")=="true":undefined),disabled:(t.attr("disabled")?true:undefined),value:(t.val()||undefined)});
};
$.fn.combo.defaults=$.extend({},$.fn.validatebox.defaults,{width:"auto",panelWidth:null,panelHeight:200,multiple:false,separator:",",editable:true,disabled:false,value:"",keyHandler:{up:function(){
},down:function(){
},enter:function(){
},query:function(q){
}},onShowPanel:function(){
},onHidePanel:function(){
},onChange:function(_55,_56){
}});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"pagination").options;
var _4=$(_2).addClass("pagination").empty();
var t=$("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr></tr></table>").appendTo(_4);
var tr=$("tr",t);
if(_3.showPageList){
var ps=$("<select class=\"pagination-page-list\"></select>");
for(var i=0;i<_3.pageList.length;i++){
$("<option></option>").text(_3.pageList[i]).attr("selected",_3.pageList[i]==_3.pageSize?"selected":"").appendTo(ps);
}
$("<td></td>").append(ps).appendTo(tr);
_3.pageSize=parseInt(ps.val());
$("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr);
}
$("<td><a href=\"javascript:void(0)\" icon=\"pagination-first\"></a></td>").appendTo(tr);
$("<td><a href=\"javascript:void(0)\" icon=\"pagination-prev\"></a></td>").appendTo(tr);
$("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr);
$("<span style=\"padding-left:6px;\"></span>").html(_3.beforePageText).wrap("<td></td>").parent().appendTo(tr);
$("<td><input class=\"pagination-num\" type=\"text\" value=\"1\" size=\"2\"></td>").appendTo(tr);
$("<span style=\"padding-right:6px;\"></span>").wrap("<td></td>").parent().appendTo(tr);
$("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr);
$("<td><a href=\"javascript:void(0)\" icon=\"pagination-next\"></a></td>").appendTo(tr);
$("<td><a href=\"javascript:void(0)\" icon=\"pagination-last\"></a></td>").appendTo(tr);
if(_3.showRefresh){
$("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr);
$("<td><a href=\"javascript:void(0)\" icon=\"pagination-load\"></a></td>").appendTo(tr);
}
if(_3.buttons){
$("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr);
for(var i=0;i<_3.buttons.length;i++){
var _5=_3.buttons[i];
if(_5=="-"){
$("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr);
}else{
var td=$("<td></td>").appendTo(tr);
$("<a href=\"javascript:void(0)\"></a>").addClass("l-btn").css("float","left").text(_5.text||"").attr("icon",_5.iconCls||"").bind("click",eval(_5.handler||function(){
})).appendTo(td).linkbutton({plain:true});
}
}
}
$("<div class=\"pagination-info\"></div>").appendTo(_4);
$("<div style=\"clear:both;\"></div>").appendTo(_4);
$("a[icon^=pagination]",_4).linkbutton({plain:true});
_4.find("a[icon=pagination-first]").unbind(".pagination").bind("click.pagination",function(){
if(_3.pageNumber>1){
_a(_2,1);
}
});
_4.find("a[icon=pagination-prev]").unbind(".pagination").bind("click.pagination",function(){
if(_3.pageNumber>1){
_a(_2,_3.pageNumber-1);
}
});
_4.find("a[icon=pagination-next]").unbind(".pagination").bind("click.pagination",function(){
var _6=Math.ceil(_3.total/_3.pageSize);
if(_3.pageNumber<_6){
_a(_2,_3.pageNumber+1);
}
});
_4.find("a[icon=pagination-last]").unbind(".pagination").bind("click.pagination",function(){
var _7=Math.ceil(_3.total/_3.pageSize);
if(_3.pageNumber<_7){
_a(_2,_7);
}
});
_4.find("a[icon=pagination-load]").unbind(".pagination").bind("click.pagination",function(){
if(_3.onBeforeRefresh.call(_2,_3.pageNumber,_3.pageSize)!=false){
_a(_2,_3.pageNumber);
_3.onRefresh.call(_2,_3.pageNumber,_3.pageSize);
}
});
_4.find("input.pagination-num").unbind(".pagination").bind("keydown.pagination",function(e){
if(e.keyCode==13){
var _8=parseInt($(this).val())||1;
_a(_2,_8);
}
});
_4.find(".pagination-page-list").unbind(".pagination").bind("change.pagination",function(){
_3.pageSize=$(this).val();
_3.onChangePageSize.call(_2,_3.pageSize);
var _9=Math.ceil(_3.total/_3.pageSize);
_a(_2,_3.pageNumber);
});
};
function _a(_b,_c){
var _d=$.data(_b,"pagination").options;
var _e=Math.ceil(_d.total/_d.pageSize);
var _f=_c;
if(_c<1){
_f=1;
}
if(_c>_e){
_f=_e;
}
_d.onSelectPage.call(_b,_f,_d.pageSize);
_d.pageNumber=_f;
_10(_b);
};
function _10(_11){
var _12=$.data(_11,"pagination").options;
var _13=Math.ceil(_12.total/_12.pageSize);
var num=$(_11).find("input.pagination-num");
num.val(_12.pageNumber);
num.parent().next().find("span").html(_12.afterPageText.replace(/{pages}/,_13));
var _14=_12.displayMsg;
_14=_14.replace(/{from}/,_12.pageSize*(_12.pageNumber-1)+1);
_14=_14.replace(/{to}/,Math.min(_12.pageSize*(_12.pageNumber),_12.total));
_14=_14.replace(/{total}/,_12.total);
$(_11).find(".pagination-info").html(_14);
$("a[icon=pagination-first],a[icon=pagination-prev]",_11).linkbutton({disabled:(_12.pageNumber==1)});
$("a[icon=pagination-next],a[icon=pagination-last]",_11).linkbutton({disabled:(_12.pageNumber==_13)});
if(_12.loading){
$(_11).find("a[icon=pagination-load]").find(".pagination-load").addClass("pagination-loading");
}else{
$(_11).find("a[icon=pagination-load]").find(".pagination-load").removeClass("pagination-loading");
}
};
function _15(_16,_17){
var _18=$.data(_16,"pagination").options;
_18.loading=_17;
if(_18.loading){
$(_16).find("a[icon=pagination-load]").find(".pagination-load").addClass("pagination-loading");
}else{
$(_16).find("a[icon=pagination-load]").find(".pagination-load").removeClass("pagination-loading");
}
};
$.fn.pagination=function(_19,_1a){
if(typeof _19=="string"){
return $.fn.pagination.methods[_19](this,_1a);
}
_19=_19||{};
return this.each(function(){
var _1b;
var _1c=$.data(this,"pagination");
if(_1c){
_1b=$.extend(_1c.options,_19);
}else{
_1b=$.extend({},$.fn.pagination.defaults,_19);
$.data(this,"pagination",{options:_1b});
}
_1(this);
_10(this);
});
};
$.fn.pagination.methods={options:function(jq){
return $.data(jq[0],"pagination").options;
},loading:function(jq){
return jq.each(function(){
_15(this,true);
});
},loaded:function(jq){
return jq.each(function(){
_15(this,false);
});
}};
$.fn.pagination.defaults={total:1,pageSize:10,pageNumber:1,pageList:[10,20,30,50],loading:false,buttons:null,showPageList:true,showRefresh:true,onSelectPage:function(_1d,_1e){
},onBeforeRefresh:function(_1f,_20){
},onRefresh:function(_21,_22){
},onChangePageSize:function(_23){
},beforePageText:"Page",afterPageText:"of {pages}",displayMsg:"Displaying {from} to {to} of {total} items"};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"calendar").options;
var t=$(_2);
if(_3.fit==true){
var p=t.parent();
_3.width=p.width();
_3.height=p.height();
}
var _4=t.find(".calendar-header");
if($.boxModel==true){
t.width(_3.width-(t.outerWidth()-t.width()));
t.height(_3.height-(t.outerHeight()-t.height()));
}else{
t.width(_3.width);
t.height(_3.height);
}
var _5=t.find(".calendar-body");
var _6=t.height()-_4.outerHeight();
if($.boxModel==true){
_5.height(_6-(_5.outerHeight()-_5.height()));
}else{
_5.height(_6);
}
};
function _7(_8){
$(_8).addClass("calendar").wrapInner("<div class=\"calendar-header\">"+"<div class=\"calendar-prevmonth\"></div>"+"<div class=\"calendar-nextmonth\"></div>"+"<div class=\"calendar-prevyear\"></div>"+"<div class=\"calendar-nextyear\"></div>"+"<div class=\"calendar-title\">"+"<span>Aprial 2010</span>"+"</div>"+"</div>"+"<div class=\"calendar-body\">"+"<div class=\"calendar-menu\">"+"<div class=\"calendar-menu-year-inner\">"+"<span class=\"calendar-menu-prev\"></span>"+"<span><input class=\"calendar-menu-year\" type=\"text\"></input></span>"+"<span class=\"calendar-menu-next\"></span>"+"</div>"+"<div class=\"calendar-menu-month-inner\">"+"</div>"+"</div>"+"</div>");
$(_8).find(".calendar-title span").hover(function(){
$(this).addClass("calendar-menu-hover");
},function(){
$(this).removeClass("calendar-menu-hover");
}).click(function(){
var _9=$(_8).find(".calendar-menu");
if(_9.is(":visible")){
_9.hide();
}else{
_16(_8);
}
});
$(".calendar-prevmonth,.calendar-nextmonth,.calendar-prevyear,.calendar-nextyear",_8).hover(function(){
$(this).addClass("calendar-nav-hover");
},function(){
$(this).removeClass("calendar-nav-hover");
});
$(_8).find(".calendar-nextmonth").click(function(){
_b(_8,1);
});
$(_8).find(".calendar-prevmonth").click(function(){
_b(_8,-1);
});
$(_8).find(".calendar-nextyear").click(function(){
_11(_8,1);
});
$(_8).find(".calendar-prevyear").click(function(){
_11(_8,-1);
});
$(_8).bind("_resize",function(){
var _a=$.data(_8,"calendar").options;
if(_a.fit==true){
_1(_8);
}
return false;
});
};
function _b(_c,_d){
var _e=$.data(_c,"calendar").options;
_e.month+=_d;
if(_e.month>12){
_e.year++;
_e.month=1;
}else{
if(_e.month<1){
_e.year--;
_e.month=12;
}
}
_f(_c);
var _10=$(_c).find(".calendar-menu-month-inner");
_10.find("td.calendar-selected").removeClass("calendar-selected");
_10.find("td:eq("+(_e.month-1)+")").addClass("calendar-selected");
};
function _11(_12,_13){
var _14=$.data(_12,"calendar").options;
_14.year+=_13;
_f(_12);
var _15=$(_12).find(".calendar-menu-year");
_15.val(_14.year);
};
function _16(_17){
var _18=$.data(_17,"calendar").options;
$(_17).find(".calendar-menu").show();
if($(_17).find(".calendar-menu-month-inner").is(":empty")){
$(_17).find(".calendar-menu-month-inner").empty();
var t=$("<table></table>").appendTo($(_17).find(".calendar-menu-month-inner"));
var idx=0;
for(var i=0;i<3;i++){
var tr=$("<tr></tr>").appendTo(t);
for(var j=0;j<4;j++){
$("<td class=\"calendar-menu-month\"></td>").html(_18.months[idx++]).attr("abbr",idx).appendTo(tr);
}
}
$(_17).find(".calendar-menu-prev,.calendar-menu-next").hover(function(){
$(this).addClass("calendar-menu-hover");
},function(){
$(this).removeClass("calendar-menu-hover");
});
$(_17).find(".calendar-menu-next").click(function(){
var y=$(_17).find(".calendar-menu-year");
if(!isNaN(y.val())){
y.val(parseInt(y.val())+1);
}
});
$(_17).find(".calendar-menu-prev").click(function(){
var y=$(_17).find(".calendar-menu-year");
if(!isNaN(y.val())){
y.val(parseInt(y.val()-1));
}
});
$(_17).find(".calendar-menu-year").keypress(function(e){
if(e.keyCode==13){
_19();
}
});
$(_17).find(".calendar-menu-month").hover(function(){
$(this).addClass("calendar-menu-hover");
},function(){
$(this).removeClass("calendar-menu-hover");
}).click(function(){
var _1a=$(_17).find(".calendar-menu");
_1a.find(".calendar-selected").removeClass("calendar-selected");
$(this).addClass("calendar-selected");
_19();
});
}
function _19(){
var _1b=$(_17).find(".calendar-menu");
var _1c=_1b.find(".calendar-menu-year").val();
var _1d=_1b.find(".calendar-selected").attr("abbr");
if(!isNaN(_1c)){
_18.year=parseInt(_1c);
_18.month=parseInt(_1d);
_f(_17);
}
_1b.hide();
};
var _1e=$(_17).find(".calendar-body");
var _1f=$(_17).find(".calendar-menu");
var _20=_1f.find(".calendar-menu-year-inner");
var _21=_1f.find(".calendar-menu-month-inner");
_20.find("input").val(_18.year).focus();
_21.find("td.calendar-selected").removeClass("calendar-selected");
_21.find("td:eq("+(_18.month-1)+")").addClass("calendar-selected");
if($.boxModel==true){
_1f.width(_1e.outerWidth()-(_1f.outerWidth()-_1f.width()));
_1f.height(_1e.outerHeight()-(_1f.outerHeight()-_1f.height()));
_21.height(_1f.height()-(_21.outerHeight()-_21.height())-_20.outerHeight());
}else{
_1f.width(_1e.outerWidth());
_1f.height(_1e.outerHeight());
_21.height(_1f.height()-_20.outerHeight());
}
};
function _22(_23,_24){
var _25=[];
var _26=new Date(_23,_24,0).getDate();
for(var i=1;i<=_26;i++){
_25.push([_23,_24,i]);
}
var _27=[],_28=[];
while(_25.length>0){
var _29=_25.shift();
_28.push(_29);
if(new Date(_29[0],_29[1]-1,_29[2]).getDay()==6){
_27.push(_28);
_28=[];
}
}
if(_28.length){
_27.push(_28);
}
var _2a=_27[0];
if(_2a.length<7){
while(_2a.length<7){
var _2b=_2a[0];
var _29=new Date(_2b[0],_2b[1]-1,_2b[2]-1);
_2a.unshift([_29.getFullYear(),_29.getMonth()+1,_29.getDate()]);
}
}else{
var _2b=_2a[0];
var _28=[];
for(var i=1;i<=7;i++){
var _29=new Date(_2b[0],_2b[1]-1,_2b[2]-i);
_28.unshift([_29.getFullYear(),_29.getMonth()+1,_29.getDate()]);
}
_27.unshift(_28);
}
var _2c=_27[_27.length-1];
while(_2c.length<7){
var _2d=_2c[_2c.length-1];
var _29=new Date(_2d[0],_2d[1]-1,_2d[2]+1);
_2c.push([_29.getFullYear(),_29.getMonth()+1,_29.getDate()]);
}
if(_27.length<6){
var _2d=_2c[_2c.length-1];
var _28=[];
for(var i=1;i<=7;i++){
var _29=new Date(_2d[0],_2d[1]-1,_2d[2]+i);
_28.push([_29.getFullYear(),_29.getMonth()+1,_29.getDate()]);
}
_27.push(_28);
}
return _27;
};
function _f(_2e){
var _2f=$.data(_2e,"calendar").options;
$(_2e).find(".calendar-title span").html(_2f.months[_2f.month-1]+" "+_2f.year);
var _30=$(_2e).find("div.calendar-body");
_30.find(">table").remove();
var t=$("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><thead></thead><tbody></tbody></table>").prependTo(_30);
var tr=$("<tr></tr>").appendTo(t.find("thead"));
for(var i=0;i<_2f.weeks.length;i++){
tr.append("<th>"+_2f.weeks[i]+"</th>");
}
var _31=_22(_2f.year,_2f.month);
for(var i=0;i<_31.length;i++){
var _32=_31[i];
var tr=$("<tr></tr>").appendTo(t.find("tbody"));
for(var j=0;j<_32.length;j++){
var day=_32[j];
$("<td class=\"calendar-day calendar-other-month\"></td>").attr("abbr",day[0]+","+day[1]+","+day[2]).html(day[2]).appendTo(tr);
}
}
t.find("td[abbr^="+_2f.year+","+_2f.month+"]").removeClass("calendar-other-month");
var now=new Date();
var _33=now.getFullYear()+","+(now.getMonth()+1)+","+now.getDate();
t.find("td[abbr="+_33+"]").addClass("calendar-today");
if(_2f.current){
t.find(".calendar-selected").removeClass("calendar-selected");
var _34=_2f.current.getFullYear()+","+(_2f.current.getMonth()+1)+","+_2f.current.getDate();
t.find("td[abbr="+_34+"]").addClass("calendar-selected");
}
t.find("tr").find("td:first").addClass("calendar-sunday");
t.find("tr").find("td:last").addClass("calendar-saturday");
t.find("td").hover(function(){
$(this).addClass("calendar-hover");
},function(){
$(this).removeClass("calendar-hover");
}).click(function(){
t.find(".calendar-selected").removeClass("calendar-selected");
$(this).addClass("calendar-selected");
var _35=$(this).attr("abbr").split(",");
_2f.current=new Date(_35[0],parseInt(_35[1])-1,_35[2]);
_2f.onSelect.call(_2e,_2f.current);
});
};
$.fn.calendar=function(_36){
if(typeof _36=="string"){
return $.fn.calendar.methods[_36](this,param);
}
_36=_36||{};
return this.each(function(){
var _37=$.data(this,"calendar");
if(_37){
$.extend(_37.options,_36);
}else{
_37=$.data(this,"calendar",{options:$.extend({},$.fn.calendar.defaults,$.fn.calendar.parseOptions(this),_36)});
_7(this);
}
if(_37.options.border==false){
$(this).addClass("calendar-noborder");
}
_1(this);
_f(this);
$(this).find("div.calendar-menu").hide();
});
};
$.fn.calendar.methods={};
$.fn.calendar.parseOptions=function(_38){
var t=$(_38);
return {width:(parseInt(_38.style.width)||undefined),height:(parseInt(_38.style.height)||undefined),fit:(t.attr("fit")?t.attr("fit")=="true":undefined),border:(t.attr("border")?t.attr("border")=="true":undefined)};
};
$.fn.calendar.defaults={width:180,height:180,fit:false,border:true,weeks:["S","M","T","W","T","F","S"],months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],year:new Date().getFullYear(),month:new Date().getMonth()+1,current:new Date(),onSelect:function(_39){
}};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"numberbox").options;
var _4=parseFloat($(_2).val()).toFixed(_3.precision);
if(isNaN(_4)){
$(_2).val("");
return;
}
if(_3.min!=null&&_3.min!=undefined&&_4<_3.min){
$(_2).val(_3.min.toFixed(_3.precision));
}else{
if(_3.max!=null&&_3.max!=undefined&&_4>_3.max){
$(_2).val(_3.max.toFixed(_3.precision));
}else{
$(_2).val(_4);
}
}
};
function _5(_6){
$(_6).unbind(".numberbox");
$(_6).bind("keypress.numberbox",function(e){
if(e.which==45){
return true;
}
if(e.which==46){
return true;
}else{
if((e.which>=48&&e.which<=57&&e.ctrlKey==false&&e.shiftKey==false)||e.which==0||e.which==8){
return true;
}else{
if(e.ctrlKey==true&&(e.which==99||e.which==118)){
return true;
}else{
return false;
}
}
}
}).bind("paste.numberbox",function(){
if(window.clipboardData){
var s=clipboardData.getData("text");
if(!/\D/.test(s)){
return true;
}else{
return false;
}
}else{
return false;
}
}).bind("dragenter.numberbox",function(){
return false;
}).bind("blur.numberbox",function(){
_1(_6);
});
};
function _7(_8){
if($.fn.validatebox){
var _9=$.data(_8,"numberbox").options;
$(_8).validatebox(_9);
}
};
function _a(_b,_c){
var _d=$.data(_b,"numberbox").options;
if(_c){
_d.disabled=true;
$(_b).attr("disabled",true);
}else{
_d.disabled=false;
$(_b).removeAttr("disabled");
}
};
$.fn.numberbox=function(_e,_f){
if(typeof _e=="string"){
var _10=$.fn.numberbox.methods[_e];
if(_10){
return _10(this,_f);
}else{
return this.validatebox(_e,_f);
}
}
_e=_e||{};
return this.each(function(){
var _11=$.data(this,"numberbox");
if(_11){
$.extend(_11.options,_e);
}else{
_11=$.data(this,"numberbox",{options:$.extend({},$.fn.numberbox.defaults,$.fn.numberbox.parseOptions(this),_e)});
$(this).removeAttr("disabled");
$(this).css({imeMode:"disabled"});
}
_a(this,_11.options.disabled);
_5(this);
_7(this);
});
};
$.fn.numberbox.methods={disable:function(jq){
return jq.each(function(){
_a(this,true);
});
},enable:function(jq){
return jq.each(function(){
_a(this,false);
});
},fix:function(jq){
return jq.each(function(){
_1(this);
});
}};
$.fn.numberbox.parseOptions=function(_12){
var t=$(_12);
return $.extend({},$.fn.validatebox.parseOptions(_12),{disabled:(t.attr("disabled")?true:undefined),min:(t.attr("min")=="0"?0:parseFloat(t.attr("min"))||undefined),max:(t.attr("max")=="0"?0:parseFloat(t.attr("max"))||undefined),precision:(parseInt(t.attr("precision"))||undefined)});
};
$.fn.numberbox.defaults=$.extend({},$.fn.validatebox.defaults,{disabled:false,min:null,max:null,precision:0});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"accordion").options;
var _4=$.data(_2,"accordion").panels;
var cc=$(_2);
if(_3.fit==true){
var p=cc.parent();
_3.width=p.width();
_3.height=p.height();
}
if(_3.width>0){
cc.width($.boxModel==true?(_3.width-(cc.outerWidth()-cc.width())):_3.width);
}
var _5="auto";
if(_3.height>0){
cc.height($.boxModel==true?(_3.height-(cc.outerHeight()-cc.height())):_3.height);
var _6=_4.length?_4[0].panel("header").css("height",null).outerHeight():"auto";
var _5=cc.height()-(_4.length-1)*_6;
}
for(var i=0;i<_4.length;i++){
var _7=_4[i];
var _8=_7.panel("header");
_8.height($.boxModel==true?(_6-(_8.outerHeight()-_8.height())):_6);
_7.panel("resize",{width:cc.width(),height:_5});
}
};
function _9(_a){
var _b=$.data(_a,"accordion").panels;
for(var i=0;i<_b.length;i++){
var _c=_b[i];
if(_c.panel("options").collapsed==false){
return _c;
}
}
return null;
};
function _d(_e,_f,_10){
var _11=$.data(_e,"accordion").panels;
for(var i=0;i<_11.length;i++){
var _12=_11[i];
if(_12.panel("options").title==_f){
if(_10){
_11.splice(i,1);
}
return _12;
}
}
return null;
};
function _13(_14){
var cc=$(_14);
cc.addClass("accordion");
if(cc.attr("border")=="false"){
cc.addClass("accordion-noborder");
}else{
cc.removeClass("accordion-noborder");
}
if(cc.find(">div[selected=true]").length==0){
cc.find(">div:first").attr("selected","true");
}
var _15=[];
cc.find(">div").each(function(){
var pp=$(this);
_15.push(pp);
_17(_14,pp,{});
});
cc.bind("_resize",function(){
var _16=$.data(_14,"accordion").options;
if(_16.fit==true){
_1(_14);
}
return false;
});
return {accordion:cc,panels:_15};
};
function _17(_18,pp,_19){
pp.panel($.extend({},_19,{collapsible:false,minimizable:false,maximizable:false,closable:false,doSize:false,collapsed:pp.attr("selected")!="true",tools:[{iconCls:"accordion-collapse",handler:function(){
var _1a=$.data(_18,"accordion").options.animate;
if(pp.panel("options").collapsed){
pp.panel("expand",_1a);
}else{
pp.panel("collapse",_1a);
}
return false;
}}],onBeforeExpand:function(){
var _1b=_9(_18);
if(_1b){
var _1c=$(_1b).panel("header");
_1c.removeClass("accordion-header-selected");
_1c.find(".accordion-collapse").triggerHandler("click");
}
var _1c=pp.panel("header");
_1c.addClass("accordion-header-selected");
_1c.find("div.accordion-collapse").removeClass("accordion-expand");
},onExpand:function(){
pp.panel("body").find(">div").triggerHandler("_resize");
var _1d=$.data(_18,"accordion").options;
_1d.onSelect.call(_18,pp.panel("options").title);
},onBeforeCollapse:function(){
var _1e=pp.panel("header");
_1e.removeClass("accordion-header-selected");
_1e.find("div.accordion-collapse").addClass("accordion-expand");
}}));
pp.panel("body").addClass("accordion-body");
pp.panel("header").addClass("accordion-header").click(function(){
$(this).find(".accordion-collapse").triggerHandler("click");
return false;
});
};
function _1f(_20,_21){
var _22=$.data(_20,"accordion").options;
var _23=$.data(_20,"accordion").panels;
var _24=_9(_20);
if(_24&&_24.panel("options").title==_21){
return;
}
var _25=_d(_20,_21);
if(_25){
_25.panel("header").triggerHandler("click");
}else{
if(_24){
_24.panel("header").addClass("accordion-header-selected");
_22.onSelect.call(_20,_24.panel("options").title);
}
}
};
function add(_26,_27){
var _28=$.data(_26,"accordion").options;
var _29=$.data(_26,"accordion").panels;
var pp=$("<div></div>").appendTo(_26);
_29.push(pp);
_17(_26,pp,_27);
_1(_26);
_28.onAdd.call(_26,_27.title);
_1f(_26,_27.title);
};
function _2a(_2b,_2c){
var _2d=$.data(_2b,"accordion").options;
var _2e=$.data(_2b,"accordion").panels;
if(_2d.onBeforeRemove.call(_2b,_2c)==false){
return;
}
var _2f=_d(_2b,_2c,true);
if(_2f){
_2f.panel("destroy");
if(_2e.length){
_1(_2b);
var _30=_9(_2b);
if(!_30){
_1f(_2b,_2e[0].panel("options").title);
}
}
}
_2d.onRemove.call(_2b,_2c);
};
$.fn.accordion=function(_31,_32){
if(typeof _31=="string"){
return $.fn.accordion.methods[_31](this,_32);
}
_31=_31||{};
return this.each(function(){
var _33=$.data(this,"accordion");
var _34;
if(_33){
_34=$.extend(_33.options,_31);
_33.opts=_34;
}else{
_34=$.extend({},$.fn.accordion.defaults,$.fn.accordion.parseOptions(this),_31);
var r=_13(this);
$.data(this,"accordion",{options:_34,accordion:r.accordion,panels:r.panels});
}
_1(this);
_1f(this);
});
};
$.fn.accordion.methods={options:function(jq){
return $.data(jq[0],"accordion").options;
},panels:function(jq){
return $.data(jq[0],"accordion").panels;
},resize:function(jq){
return jq.each(function(){
_1(this);
});
},getSelected:function(jq){
return _9(jq[0]);
},getPanel:function(jq,_35){
return _d(jq[0],_35);
},select:function(jq,_36){
return jq.each(function(){
_1f(this,_36);
});
},add:function(jq,_37){
return jq.each(function(){
add(this,_37);
});
},remove:function(jq,_38){
return jq.each(function(){
_2a(this,_38);
});
}};
$.fn.accordion.parseOptions=function(_39){
var t=$(_39);
return {width:(parseInt(_39.style.width)||undefined),height:(parseInt(_39.style.height)||undefined),fit:(t.attr("fit")?t.attr("fit")=="true":undefined),border:(t.attr("border")?t.attr("border")=="true":undefined),animate:(t.attr("animate")?t.attr("animate")=="true":undefined)};
};
$.fn.accordion.defaults={width:"auto",height:"auto",fit:false,border:true,animate:true,onSelect:function(_3a){
},onAdd:function(_3b){
},onBeforeRemove:function(_3c){
},onRemove:function(_3d){
}};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"splitbutton").options;
var _4=$(_2);
_4.removeClass("s-btn-active s-btn-plain-active");
_4.linkbutton(_3);
if(_3.menu){
$(_3.menu).menu({onShow:function(){
_4.addClass((_3.plain==true)?"s-btn-plain-active":"s-btn-active");
},onHide:function(){
_4.removeClass((_3.plain==true)?"s-btn-plain-active":"s-btn-active");
}});
}
_5(_2,_3.disabled);
};
function _5(_6,_7){
var _8=$.data(_6,"splitbutton").options;
_8.disabled=_7;
var _9=$(_6);
var _a=_9.find(".s-btn-downarrow");
if(_7){
_9.linkbutton("disable");
_a.unbind(".splitbutton");
}else{
_9.linkbutton("enable");
_a.unbind(".splitbutton");
_a.bind("click.splitbutton",function(){
_b();
return false;
});
var _c=null;
_a.bind("mouseenter.splitbutton",function(){
_c=setTimeout(function(){
_b();
},_8.duration);
return false;
}).bind("mouseleave.splitbutton",function(){
if(_c){
clearTimeout(_c);
}
});
}
function _b(){
if(!_8.menu){
return;
}
var _d=_9.offset().left;
if(_d+$(_8.menu).outerWidth()+5>$(window).width()){
_d=$(window).width()-$(_8.menu).outerWidth()-5;
}
$("body>div.menu-top").menu("hide");
$(_8.menu).menu("show",{left:_d,top:_9.offset().top+_9.outerHeight()});
_9.blur();
};
};
$.fn.splitbutton=function(_e,_f){
if(typeof _e=="string"){
return $.fn.splitbutton.methods[_e](this,_f);
}
_e=_e||{};
return this.each(function(){
var _10=$.data(this,"splitbutton");
if(_10){
$.extend(_10.options,_e);
}else{
$(this).append("<span class=\"s-btn-downarrow\"> </span>");
$.data(this,"splitbutton",{options:$.extend({},$.fn.splitbutton.defaults,$.fn.splitbutton.parseOptions(this),_e)});
$(this).removeAttr("disabled");
}
_1(this);
});
};
$.fn.splitbutton.methods={options:function(jq){
return $.data(jq[0],"splitbutton").options;
},enable:function(jq){
return jq.each(function(){
_5(this,false);
});
},disable:function(jq){
return jq.each(function(){
_5(this,true);
});
}};
$.fn.splitbutton.parseOptions=function(_11){
var t=$(_11);
return $.extend({},$.fn.linkbutton.parseOptions(_11),{menu:t.attr("menu"),duration:t.attr("duration")});
};
$.fn.splitbutton.defaults=$.extend({},$.fn.linkbutton.defaults,{plain:true,menu:null,duration:100});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$(_2);
var _4=$("<div class=\"datebox-calendar\">"+"<div class=\"datebox-calendar-inner\">"+"<div></div>"+"</div>"+"<div class=\"datebox-button\"></div>"+"</div>").appendTo("body");
_4.find("div.datebox-calendar-inner>div").calendar({fit:true,border:false,onSelect:function(_5){
var _6=$.data(_2,"datebox").options;
var v=_6.formatter(_5);
$(_2).val(v);
_4.hide();
_1a(_2,true);
_6.onSelect.call(_2,_5);
}});
_4.hide().mousedown(function(){
return false;
});
return _4;
};
function _7(_8){
$(document).unbind(".datebox");
$.data(_8,"datebox").calendar.remove();
$(_8).validatebox("destroy");
};
function _9(_a){
var _b=$.data(_a,"datebox").options;
var _c=$(_a);
$(document).unbind(".datebox");
_c.unbind(".datebox");
if(!_b.disabled){
$(document).bind("mousedown.datebox",function(){
$("body>div.datebox-calendar").hide();
});
_c.bind("focus.datebox",function(){
_d(_a);
}).bind("click.datebox",function(){
_d(_a);
});
}
};
function _e(_f){
var _10=$.data(_f,"datebox").options;
var _11=$.data(_f,"datebox").calendar;
var _12=_11.find("div.datebox-button");
_12.empty();
$("<a href=\"javascript:void(0)\" class=\"datebox-current\"></a>").html(_10.currentText).appendTo(_12);
$("<a href=\"javascript:void(0)\" class=\"datebox-close\"></a>").html(_10.closeText).appendTo(_12);
_12.find(".datebox-current,.datebox-close").hover(function(){
$(this).addClass("datebox-button-hover");
},function(){
$(this).removeClass("datebox-button-hover");
});
_12.find(".datebox-current").click(function(){
_11.find("div.datebox-calendar-inner>div").calendar({year:new Date().getFullYear(),month:new Date().getMonth()+1,current:new Date()});
});
_12.find(".datebox-close").click(function(){
_11.hide();
});
};
function _d(_13){
var _14=$.data(_13,"datebox").options;
var _15=$.data(_13,"datebox").calendar;
_15.show();
if($.fn.window){
_15.css("z-index",$.fn.window.defaults.zIndex++);
}
(function(){
if(_15.is(":visible")){
_15.css({display:"block",left:$(_13).offset().left,top:$(_13).offset().top+$(_13).outerHeight()});
setTimeout(arguments.callee,200);
}
})();
var _16=_14.parser($(_13).val());
_15.find("div.datebox-calendar-inner>div").calendar({year:_16.getFullYear(),month:_16.getMonth()+1,current:_16});
};
function _17(_18){
var _19=$.data(_18,"datebox").calendar;
_19.hide();
};
function _1a(_1b,_1c){
if($.fn.validatebox){
var _1d=$.data(_1b,"datebox").options;
$(_1b).validatebox(_1d);
if(_1c){
$(_1b).validatebox("validate");
$(_1b).trigger("mouseleave");
}
}
};
function _1e(_1f,_20){
var _21=$.data(_1f,"datebox").options;
if(_20){
_21.disabled=true;
$(_1f).attr("disabled",true);
}else{
_21.disabled=false;
$(_1f).removeAttr("disabled");
}
};
$.fn.datebox=function(_22,_23){
if(typeof _22=="string"){
var _24=$.fn.datebox.methods[_22];
if(_24){
return _24(this,_23);
}else{
return this.validatebox(_22,_23);
}
}
_22=_22||{};
return this.each(function(){
var _25=$.data(this,"datebox");
if(_25){
$.extend(_25.options,_22);
}else{
_25=$.data(this,"datebox",{options:$.extend({},$.fn.datebox.defaults,$.fn.datebox.parseOptions(this),_22),calendar:_1(this)});
$(this).removeAttr("disabled");
}
_e(this);
_1e(this,_25.options.disabled);
_9(this);
_1a(this);
});
};
$.fn.datebox.methods={destroy:function(jq){
return jq.each(function(){
_7(this);
});
},disable:function(jq){
return jq.each(function(){
_1e(this,true);
_9(this);
});
},enable:function(jq){
return jq.each(function(){
_1e(this,false);
_9(this);
});
}};
$.fn.datebox.parseOptions=function(_26){
var t=$(_26);
return $.extend({},$.fn.validatebox.parseOptions(_26),{disabled:(t.attr("disabled")?true:undefined)});
};
$.fn.datebox.defaults=$.extend({},$.fn.validatebox.defaults,{currentText:"Today",closeText:"Close",disabled:false,formatter:function(_27){
var y=_27.getFullYear();
var m=_27.getMonth()+1;
var d=_27.getDate();
return m+"/"+d+"/"+y;
},parser:function(s){
var t=Date.parse(s);
if(!isNaN(t)){
return new Date(t);
}else{
return new Date();
}
},onSelect:function(_28){
}});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"numberspinner").options;
$(_2).spinner(_3).numberbox(_3);
};
function _4(_5,_6){
var _7=$.data(_5,"numberspinner").options;
var v=parseFloat($(_5).val()||_7.value)||0;
if(_6==true){
v-=_7.increment;
}else{
v+=_7.increment;
}
$(_5).val(v).numberbox("fix");
};
$.fn.numberspinner=function(_8,_9){
if(typeof _8=="string"){
var _a=$.fn.numberspinner.methods[_8];
if(_a){
return _a(this,_9);
}else{
return this.spinner(_8,_9);
}
}
_8=_8||{};
return this.each(function(){
var _b=$.data(this,"numberspinner");
if(_b){
$.extend(_b.options,_8);
}else{
$.data(this,"numberspinner",{options:$.extend({},$.fn.numberspinner.defaults,$.fn.numberspinner.parseOptions(this),_8)});
}
_1(this);
});
};
$.fn.numberspinner.methods={options:function(jq){
var _c=$.data(jq[0],"numberspinner").options;
return $.extend(_c,{value:jq.val()});
},setValue:function(jq,_d){
return jq.each(function(){
$(this).val(_d).numberbox("fix");
});
}};
$.fn.numberspinner.parseOptions=function(_e){
return $.extend({},$.fn.spinner.parseOptions(_e),$.fn.numberbox.parseOptions(_e),{});
};
$.fn.numberspinner.defaults=$.extend({},$.fn.spinner.defaults,$.fn.numberbox.defaults,{spin:function(_f){
_4(this,_f);
}});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"menubutton").options;
var _4=$(_2);
_4.removeClass("m-btn-active m-btn-plain-active");
_4.linkbutton(_3);
if(_3.menu){
$(_3.menu).menu({onShow:function(){
_4.addClass((_3.plain==true)?"m-btn-plain-active":"m-btn-active");
},onHide:function(){
_4.removeClass((_3.plain==true)?"m-btn-plain-active":"m-btn-active");
}});
}
_5(_2,_3.disabled);
};
function _5(_6,_7){
var _8=$.data(_6,"menubutton").options;
_8.disabled=_7;
var _9=$(_6);
if(_7){
_9.linkbutton("disable");
_9.unbind(".menubutton");
}else{
_9.linkbutton("enable");
_9.unbind(".menubutton");
_9.bind("click.menubutton",function(){
_a();
return false;
});
var _b=null;
_9.bind("mouseenter.menubutton",function(){
_b=setTimeout(function(){
_a();
},_8.duration);
return false;
}).bind("mouseleave.menubutton",function(){
if(_b){
clearTimeout(_b);
}
});
}
function _a(){
if(!_8.menu){
return;
}
var _c=_9.offset().left;
if(_c+$(_8.menu).outerWidth()+5>$(window).width()){
_c=$(window).width()-$(_8.menu).outerWidth()-5;
}
$("body>div.menu-top").menu("hide");
$(_8.menu).menu("show",{left:_c,top:_9.offset().top+_9.outerHeight()});
_9.blur();
};
};
$.fn.menubutton=function(_d,_e){
if(typeof _d=="string"){
return $.fn.menubutton.methods[_d](this,_e);
}
_d=_d||{};
return this.each(function(){
var _f=$.data(this,"menubutton");
if(_f){
$.extend(_f.options,_d);
}else{
$(this).append("<span class=\"m-btn-downarrow\"> </span>");
$.data(this,"menubutton",{options:$.extend({},$.fn.menubutton.defaults,$.fn.menubutton.parseOptions(this),_d)});
$(this).removeAttr("disabled");
}
_1(this);
});
};
$.fn.menubutton.methods={options:function(jq){
return $.data(jq[0],"menubutton").options;
},enable:function(jq){
return jq.each(function(){
_5(this,false);
});
},disable:function(jq){
return jq.each(function(){
_5(this,true);
});
}};
$.fn.menubutton.parseOptions=function(_10){
var t=$(_10);
return $.extend({},$.fn.linkbutton.parseOptions(_10),{menu:t.attr("menu"),duration:t.attr("duration")});
};
$.fn.menubutton.defaults=$.extend({},$.fn.linkbutton.defaults,{plain:true,menu:null,duration:100});
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"linkbutton").options;
$(_2).empty();
$(_2).addClass("l-btn");
if(_3.id){
$(_2).attr("id",_3.id);
}else{
$(_2).removeAttr("id");
}
if(_3.plain){
$(_2).addClass("l-btn-plain");
}else{
$(_2).removeClass("l-btn-plain");
}
if(_3.text){
$(_2).html(_3.text).wrapInner("<span class=\"l-btn-left\">"+"<span class=\"l-btn-text\">"+"</span>"+"</span>");
if(_3.iconCls){
$(_2).find(".l-btn-text").addClass(_3.iconCls).css("padding-left","20px");
}
}else{
$(_2).html(" ").wrapInner("<span class=\"l-btn-left\">"+"<span class=\"l-btn-text\">"+"<span class=\"l-btn-empty\"></span>"+"</span>"+"</span>");
if(_3.iconCls){
$(_2).find(".l-btn-empty").addClass(_3.iconCls);
}
}
_4(_2,_3.disabled);
};
function _4(_5,_6){
var _7=$.data(_5,"linkbutton");
if(_6){
_7.options.disabled=true;
var _8=$(_5).attr("href");
if(_8){
_7.href=_8;
$(_5).attr("href","javascript:void(0)");
}
var _9=$(_5).attr("onclick");
if(_9){
_7.onclick=_9;
$(_5).attr("onclick",null);
}
$(_5).addClass("l-btn-disabled");
}else{
_7.options.disabled=false;
if(_7.href){
$(_5).attr("href",_7.href);
}
if(_7.onclick){
_5.onclick=_7.onclick;
}
$(_5).removeClass("l-btn-disabled");
}
};
$.fn.linkbutton=function(_a,_b){
if(typeof _a=="string"){
return $.fn.linkbutton.methods[_a](this,_b);
}
_a=_a||{};
return this.each(function(){
var _c=$.data(this,"linkbutton");
if(_c){
$.extend(_c.options,_a);
}else{
$.data(this,"linkbutton",{options:$.extend({},$.fn.linkbutton.defaults,$.fn.linkbutton.parseOptions(this),_a)});
$(this).removeAttr("disabled");
}
_1(this);
});
};
$.fn.linkbutton.methods={options:function(jq){
return $.data(jq[0],"linkbutton").options;
},enable:function(jq){
return jq.each(function(){
_4(this,false);
});
},disable:function(jq){
return jq.each(function(){
_4(this,true);
});
}};
$.fn.linkbutton.parseOptions=function(_d){
var t=$(_d);
return {id:t.attr("id"),disabled:(t.attr("disabled")?true:undefined),plain:(t.attr("plain")?t.attr("plain")=="true":undefined),text:$.trim(t.html()),iconCls:(t.attr("icon")||t.attr("iconCls"))};
};
$.fn.linkbutton.defaults={id:null,disabled:false,plain:false,text:"",iconCls:null};
})(jQuery);
| JavaScript |
/**
* jQuery EasyUI 1.2.1
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2,_3){
var _4=$(_2).combo("panel");
var _5=_4.find("div.combobox-item[value="+_3+"]");
if(_5.length){
if(_5.position().top<=0){
var h=_4.scrollTop()+_5.position().top;
_4.scrollTop(h);
}else{
if(_5.position().top+_5.outerHeight()>_4.height()){
var h=_4.scrollTop()+_5.position().top+_5.outerHeight()-_4.height();
_4.scrollTop(h);
}
}
}
};
function _6(_7){
var _8=$(_7).combo("panel");
var _9=$(_7).combo("getValues");
var _a=_8.find("div.combobox-item[value="+_9.pop()+"]");
if(_a.length){
var _b=_a.prev(":visible");
if(_b.length){
_a=_b;
}
}else{
_a=_8.find("div.combobox-item:visible:last");
}
var _c=_a.attr("value");
_d(_7,[_c]);
_1(_7,_c);
};
function _e(_f){
var _10=$(_f).combo("panel");
var _11=$(_f).combo("getValues");
var _12=_10.find("div.combobox-item[value="+_11.pop()+"]");
if(_12.length){
var _13=_12.next(":visible");
if(_13.length){
_12=_13;
}
}else{
_12=_10.find("div.combobox-item:visible:first");
}
var _14=_12.attr("value");
_d(_f,[_14]);
_1(_f,_14);
};
function _15(_16,_17){
var _18=$.data(_16,"combobox").options;
var _19=$.data(_16,"combobox").data;
if(_18.multiple){
var _1a=$(_16).combo("getValues");
for(var i=0;i<_1a.length;i++){
if(_1a[i]==_17){
return;
}
}
_1a.push(_17);
_d(_16,_1a);
}else{
_d(_16,[_17]);
}
for(var i=0;i<_19.length;i++){
if(_19[i][_18.valueField]==_17){
_18.onSelect.call(_16,_19[i]);
return;
}
}
};
function _1b(_1c,_1d){
var _1e=$.data(_1c,"combobox").options;
var _1f=$.data(_1c,"combobox").data;
var _20=$(_1c).combo("getValues");
for(var i=0;i<_20.length;i++){
if(_20[i]==_1d){
_20.splice(i,1);
_d(_1c,_20);
break;
}
}
for(var i=0;i<_1f.length;i++){
if(_1f[i][_1e.valueField]==_1d){
_1e.onUnselect.call(_1c,_1f[i]);
return;
}
}
};
function _d(_21,_22,_23){
var _24=$.data(_21,"combobox").options;
var _25=$.data(_21,"combobox").data;
var _26=$(_21).combo("panel");
_26.find("div.combobox-item-selected").removeClass("combobox-item-selected");
var vv=[],ss=[];
for(var i=0;i<_22.length;i++){
var v=_22[i];
var s=v;
for(var j=0;j<_25.length;j++){
if(_25[j][_24.valueField]==v){
s=_25[j][_24.textField];
break;
}
}
vv.push(v);
ss.push(s);
_26.find("div.combobox-item[value="+v+"]").addClass("combobox-item-selected");
}
$(_21).combo("setValues",vv);
if(!_23){
$(_21).combo("setText",ss.join(_24.separator));
}
};
function _27(_28){
var _29=$.data(_28,"combobox").options;
var _2a=[];
$(">option",_28).each(function(){
var _2b={};
_2b[_29.valueField]=$(this).attr("value")||$(this).html();
_2b[_29.textField]=$(this).html();
_2b["selected"]=$(this).attr("selected");
_2a.push(_2b);
});
return _2a;
};
function _2c(_2d,_2e,_2f){
var _30=$.data(_2d,"combobox").options;
var _31=$(_2d).combo("panel");
$.data(_2d,"combobox").data=_2e;
var _32=$(_2d).combobox("getValues");
_31.empty();
for(var i=0;i<_2e.length;i++){
var v=_2e[i][_30.valueField];
var s=_2e[i][_30.textField];
var _33=$("<div class=\"combobox-item\"></div>").appendTo(_31);
_33.attr("value",v);
if(_30.formatter){
_33.html(_30.formatter.call(_2d,_2e[i]));
}else{
_33.html(s);
}
if(_2e[i]["selected"]){
(function(){
for(var i=0;i<_32.length;i++){
if(v==_32[i]){
return;
}
}
_32.push(v);
})();
}
}
if(_30.multiple){
_d(_2d,_32,_2f);
}else{
if(_32.length){
_d(_2d,[_32[_32.length-1]],_2f);
}else{
_d(_2d,[],_2f);
}
}
_30.onLoadSuccess.call(_2d,_2e);
$(".combobox-item",_31).hover(function(){
$(this).addClass("combobox-item-hover");
},function(){
$(this).removeClass("combobox-item-hover");
}).click(function(){
var _34=$(this);
if(_30.multiple){
if(_34.hasClass("combobox-item-selected")){
_1b(_2d,_34.attr("value"));
}else{
_15(_2d,_34.attr("value"));
}
}else{
_15(_2d,_34.attr("value"));
$(_2d).combo("hidePanel");
}
});
};
function _35(_36,url,_37,_38){
var _39=$.data(_36,"combobox").options;
if(url){
_39.url=url;
}
if(!_39.url){
return;
}
_37=_37||{};
$.ajax({url:_39.url,dataType:"json",data:_37,success:function(_3a){
_2c(_36,_3a,_38);
},error:function(){
_39.onLoadError.apply(this,arguments);
}});
};
function _3b(_3c,q){
var _3d=$.data(_3c,"combobox").options;
if(_3d.multiple&&!q){
_d(_3c,[],true);
}else{
_d(_3c,[q],true);
}
if(_3d.mode=="remote"){
_35(_3c,null,{q:q},true);
}else{
var _3e=$(_3c).combo("panel");
_3e.find("div.combobox-item").hide();
var _3f=$.data(_3c,"combobox").data;
for(var i=0;i<_3f.length;i++){
if(_3d.filter.call(_3c,q,_3f[i])){
var v=_3f[i][_3d.valueField];
var s=_3f[i][_3d.textField];
var _40=_3e.find("div.combobox-item[value="+v+"]");
_40.show();
if(s==q){
_d(_3c,[v],true);
_40.addClass("combobox-item-selected");
}
}
}
}
};
function _41(_42){
var _43=$.data(_42,"combobox").options;
$(_42).addClass("combobox-f");
$(_42).combo($.extend({},_43,{onShowPanel:function(){
$(_42).combo("panel").find("div.combobox-item").show();
_1(_42,$(_42).combobox("getValue"));
_43.onShowPanel.call(_42);
}}));
};
$.fn.combobox=function(_44,_45){
if(typeof _44=="string"){
var _46=$.fn.combobox.methods[_44];
if(_46){
return _46(this,_45);
}else{
return this.combo(_44,_45);
}
}
_44=_44||{};
return this.each(function(){
var _47=$.data(this,"combobox");
if(_47){
$.extend(_47.options,_44);
_41(this);
}else{
_47=$.data(this,"combobox",{options:$.extend({},$.fn.combobox.defaults,$.fn.combobox.parseOptions(this),_44)});
_41(this);
_2c(this,_27(this));
}
if(_47.options.data){
_2c(this,_47.options.data);
}
_35(this);
});
};
$.fn.combobox.methods={options:function(jq){
return $.data(jq[0],"combobox").options;
},getData:function(jq){
return $.data(jq[0],"combobox").data;
},setValues:function(jq,_48){
return jq.each(function(){
_d(this,_48);
});
},setValue:function(jq,_49){
return jq.each(function(){
_d(this,[_49]);
});
},clear:function(jq){
return jq.each(function(){
$(this).combo("clear");
var _4a=$(this).combo("panel");
_4a.find("div.combobox-item-selected").removeClass("combobox-item-selected");
});
},loadData:function(jq,_4b){
return jq.each(function(){
_2c(this,_4b);
});
},reload:function(jq,url){
return jq.each(function(){
_35(this,url);
});
},select:function(jq,_4c){
return jq.each(function(){
_15(this,_4c);
});
},unselect:function(jq,_4d){
return jq.each(function(){
_1b(this,_4d);
});
}};
$.fn.combobox.parseOptions=function(_4e){
var t=$(_4e);
return $.extend({},$.fn.combo.parseOptions(_4e),{valueField:t.attr("valueField"),textField:t.attr("textField"),mode:t.attr("mode"),url:t.attr("url")});
};
$.fn.combobox.defaults=$.extend({},$.fn.combo.defaults,{valueField:"value",textField:"text",mode:"local",url:null,data:null,keyHandler:{up:function(){
_6(this);
},down:function(){
_e(this);
},enter:function(){
var _4f=$(this).combobox("getValues");
$(this).combobox("setValues",_4f);
$(this).combobox("hidePanel");
},query:function(q){
_3b(this,q);
}},filter:function(q,row){
var _50=$(this).combobox("options");
return row[_50.textField].indexOf(q)==0;
},formatter:function(row){
var _51=$(this).combobox("options");
return row[_51.textField];
},onLoadSuccess:function(){
},onLoadError:function(){
},onSelect:function(_52){
},onUnselect:function(_53){
}});
})(jQuery);
| JavaScript |
/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* $LastChangedDate: 2007-07-21 18:44:59 -0500 (Sat, 21 Jul 2007) $
* $Rev: 2446 $
*
* Version 2.1.1
*/
(function($){
/**
* The bgiframe is chainable and applies the iframe hack to get
* around zIndex issues in IE6. It will only apply itself in IE6
* and adds a class to the iframe called 'bgiframe'. The iframe
* is appeneded as the first child of the matched element(s)
* with a tabIndex and zIndex of -1.
*
* By default the plugin will take borders, sized with pixel units,
* into account. If a different unit is used for the border's width,
* then you will need to use the top and left settings as explained below.
*
* NOTICE: This plugin has been reported to cause perfromance problems
* when used on elements that change properties (like width, height and
* opacity) a lot in IE6. Most of these problems have been caused by
* the expressions used to calculate the elements width, height and
* borders. Some have reported it is due to the opacity filter. All
* these settings can be changed if needed as explained below.
*
* @example $('div').bgiframe();
* @before <div><p>Paragraph</p></div>
* @result <div><iframe class="bgiframe".../><p>Paragraph</p></div>
*
* @param Map settings Optional settings to configure the iframe.
* @option String|Number top The iframe must be offset to the top
* by the width of the top border. This should be a negative
* number representing the border-top-width. If a number is
* is used here, pixels will be assumed. Otherwise, be sure
* to specify a unit. An expression could also be used.
* By default the value is "auto" which will use an expression
* to get the border-top-width if it is in pixels.
* @option String|Number left The iframe must be offset to the left
* by the width of the left border. This should be a negative
* number representing the border-left-width. If a number is
* is used here, pixels will be assumed. Otherwise, be sure
* to specify a unit. An expression could also be used.
* By default the value is "auto" which will use an expression
* to get the border-left-width if it is in pixels.
* @option String|Number width This is the width of the iframe. If
* a number is used here, pixels will be assume. Otherwise, be sure
* to specify a unit. An experssion could also be used.
* By default the value is "auto" which will use an experssion
* to get the offsetWidth.
* @option String|Number height This is the height of the iframe. If
* a number is used here, pixels will be assume. Otherwise, be sure
* to specify a unit. An experssion could also be used.
* By default the value is "auto" which will use an experssion
* to get the offsetHeight.
* @option Boolean opacity This is a boolean representing whether or not
* to use opacity. If set to true, the opacity of 0 is applied. If
* set to false, the opacity filter is not applied. Default: true.
* @option String src This setting is provided so that one could change
* the src of the iframe to whatever they need.
* Default: "javascript:false;"
*
* @name bgiframe
* @type jQuery
* @cat Plugins/bgiframe
* @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
*/
$.fn.bgIframe = $.fn.bgiframe = function(s) {
// This is only for IE6
if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
s = $.extend({
top : 'auto', // auto == .currentStyle.borderTopWidth
left : 'auto', // auto == .currentStyle.borderLeftWidth
width : 'auto', // auto == offsetWidth
height : 'auto', // auto == offsetHeight
opacity : true,
src : 'javascript:false;'
}, s || {});
var prop = function(n){return n&&n.constructor==Number?n+'px':n;},
html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
'style="display:block;position:absolute;z-index:-1;'+
(s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+
'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
'"/>';
return this.each(function() {
if ( $('> iframe.bgiframe', this).length == 0 )
this.insertBefore( document.createElement(html), this.firstChild );
});
}
return this;
};
})(jQuery); | JavaScript |
/**
* This jQuery plugin displays pagination links inside the selected elements.
*
* @author Gabriel Birke (birke *at* d-scribe *dot* de)
* @version 1.1
* @param {int} maxentries Number of entries to paginate
* @param {Object} opts Several options (see README for documentation)
* @return {Object} jQuery Object
*/
jQuery.fn.pagination = function(maxentries, opts){
opts = jQuery.extend({
items_per_page:10,
num_display_entries:10,
current_page:0,
num_edge_entries:0,
link_to:"#",
prev_text:"Prev",
next_text:"Next",
ellipse_text:"...",
prev_show_always:true,
next_show_always:true,
callback:function(){return false;}
},opts||{});
return this.each(function() {
/**
* Calculate the maximum number of pages
*/
function numPages() {
return Math.ceil(maxentries/opts.items_per_page);
}
/**
* Calculate start and end point of pagination links depending on
* current_page and num_display_entries.
* @return {Array}
*/
function getInterval() {
var ne_half = Math.ceil(opts.num_display_entries/2);
var np = numPages();
var upper_limit = np-opts.num_display_entries;
var start = current_page>ne_half?Math.max(Math.min(current_page-ne_half, upper_limit), 0):0;
var end = current_page>ne_half?Math.min(current_page+ne_half, np):Math.min(opts.num_display_entries, np);
return [start,end];
}
/**
* This is the event handling function for the pagination links.
* @param {int} page_id The new page number
*/
function pageSelected(page_id, evt){
current_page = page_id;
drawLinks();
var continuePropagation = opts.callback(page_id, panel);
if (!continuePropagation) {
if (evt.stopPropagation) {
evt.stopPropagation();
}
else {
evt.cancelBubble = true;
}
}
return continuePropagation;
}
/**
* This function inserts the pagination links into the container element
*/
function drawLinks() {
panel.empty();
var interval = getInterval();
var np = numPages();
// This helper function returns a handler function that calls pageSelected with the right page_id
var getClickHandler = function(page_id) {
return function(evt){ return pageSelected(page_id,evt); }
}
// Helper function for generating a single link (or a span tag if it'S the current page)
var appendItem = function(page_id, appendopts){
page_id = page_id<0?0:(page_id<np?page_id:np-1); // Normalize page id to sane value
appendopts = jQuery.extend({text:page_id+1, classes:""}, appendopts||{});
if(page_id == current_page){
var lnk = $("<span class='current'>"+(appendopts.text)+"</span>");
}
else
{
var lnk = $("<a>"+(appendopts.text)+"</a>")
.bind("click", getClickHandler(page_id))
.attr('href', opts.link_to.replace(/__id__/,page_id));
}
if(appendopts.classes){lnk.addClass(appendopts.classes);}
panel.append(lnk);
}
// Generate "Previous"-Link
if(opts.prev_text && (current_page > 0 || opts.prev_show_always)){
appendItem(current_page-1,{text:opts.prev_text, classes:"prev"});
}
// Generate starting points
if (interval[0] > 0 && opts.num_edge_entries > 0)
{
var end = Math.min(opts.num_edge_entries, interval[0]);
for(var i=0; i<end; i++) {
appendItem(i);
}
if(opts.num_edge_entries < interval[0] && opts.ellipse_text)
{
jQuery("<span>"+opts.ellipse_text+"</span>").appendTo(panel);
}
}
// Generate interval links
for(var i=interval[0]; i<interval[1]; i++) {
appendItem(i);
}
// Generate ending points
if (interval[1] < np && opts.num_edge_entries > 0)
{
if(np-opts.num_edge_entries > interval[1]&& opts.ellipse_text)
{
jQuery("<span>"+opts.ellipse_text+"</span>").appendTo(panel);
}
var begin = Math.max(np-opts.num_edge_entries, interval[1]);
for(var i=begin; i<np; i++) {
appendItem(i);
}
}
// Generate "Next"-Link
if(opts.next_text && (current_page < np-1 || opts.next_show_always)){
appendItem(current_page+1,{text:opts.next_text, classes:"next"});
}
}
// Extract current_page from options
var current_page = opts.current_page;
// Create a sane value for maxentries and items_per_page
maxentries = (!maxentries || maxentries < 0)?1:maxentries;
opts.items_per_page = (!opts.items_per_page || opts.items_per_page < 0)?1:opts.items_per_page;
// Store DOM element for easy access from all inner functions
var panel = jQuery(this);
// Attach control functions to the DOM element
this.selectPage = function(page_id){ pageSelected(page_id);}
this.prevPage = function(){
if (current_page > 0) {
pageSelected(current_page - 1);
return true;
}
else {
return false;
}
}
this.nextPage = function(){
if(current_page < numPages()-1) {
pageSelected(current_page+1);
return true;
}
else {
return false;
}
}
// When all initialisation is done, draw the links
drawLinks();
});
}
| JavaScript |
/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
* used when the cookie was set.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
// CAUTION: Needed to parenthesize options.path and options.domain
// in the following expressions, otherwise they evaluate to undefined
// in the packed version for some reason...
var path = options.path ? '; path=' + (options.path) : '';
var domain = options.domain ? '; domain=' + (options.domain) : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
}; | JavaScript |
/*
Copyright (C) 2009 - 2012
WebSite: Http://wangking717.javaeye.com/
Author: wangking
*/
$(function(){
var xOffset = -20; // x distance from mouse
var yOffset = 20; // y distance from mouse
//input action
$("[reg],[url]:not([reg]),[tip]").hover(
function(e) {
if($(this).attr('tip') != undefined){
var top = (e.pageY + yOffset);
var left = (e.pageX + xOffset);
$('body').append( '<p id="vtip"><img id="vtipArrow" src="images/vtip_arrow.png"/>' + $(this).attr('tip') + '</p>' );
$('p#vtip').css("top", top+"px").css("left", left+"px");
$('p#vtip').bgiframe();
}
},
function() {
if($(this).attr('tip') != undefined){
$("p#vtip").remove();
}
}
).mousemove(
function(e) {
if($(this).attr('tip') != undefined){
var top = (e.pageY + yOffset);
var left = (e.pageX + xOffset);
$("p#vtip").css("top", top+"px").css("left", left+"px");
}
}
).blur(function(){
if($(this).attr("url") != undefined){
ajax_validate($(this));
}else if($(this).attr("reg") != undefined){
validate($(this));
}
});
$("form").submit(function(){
var isSubmit = true;
$(this).find("[reg],[url]:not([reg])").each(function(){
if($(this).attr("reg") == undefined){
if(!ajax_validate($(this))){
isSubmit = false;
}
}else{
if(!validate($(this))){
isSubmit = false;
}
}
});
if(typeof(isExtendsValidate) != "undefined"){
if(isSubmit && isExtendsValidate){
return extendsValidate();
}
}
return isSubmit;
});
});
function validate(obj){
var reg = new RegExp(obj.attr("reg"));
var objValue = obj.attr("value");
if(!reg.test(objValue)){
change_error_style(obj,"add");
change_tip(obj,null,"remove");
return false;
}else{
if(obj.attr("url") == undefined){
change_error_style(obj,"remove");
change_tip(obj,null,"remove");
return true;
}else{
return ajax_validate(obj);
}
}
}
function ajax_validate(obj){
var url_str = obj.attr("url");
if(url_str.indexOf("?") != -1){
url_str = url_str+"&"+obj.attr("name")+"="+obj.attr("value");
}else{
url_str = url_str+"?"+obj.attr("name")+"="+obj.attr("value");
}
var feed_back = $.ajax({url: url_str,cache: false,async: false}).responseText;
feed_back = feed_back.replace(/(^\s*)|(\s*$)/g, "");
if(feed_back == 'success'){
change_error_style(obj,"remove");
change_tip(obj,null,"remove");
return true;
}else{
change_error_style(obj,"add");
change_tip(obj,feed_back,"add");
return false;
}
}
function change_tip(obj,msg,action_type){
if(obj.attr("tip") == undefined){//初始化判断TIP是否为空
obj.attr("is_tip_null","yes");
}
if(action_type == "add"){
if(obj.attr("is_tip_null") == "yes"){
obj.attr("tip",msg);
}else{
if(msg != null){
if(obj.attr("tip_bak") == undefined){
obj.attr("tip_bak",obj.attr("tip"));
}
obj.attr("tip",msg);
}
}
}else{
if(obj.attr("is_tip_null") == "yes"){
obj.removeAttr("tip");
obj.removeAttr("tip_bak");
}else{
obj.attr("tip",obj.attr("tip_bak"));
obj.removeAttr("tip_bak");
}
}
}
function change_error_style(obj,action_type){
if(action_type == "add"){
obj.addClass("input_validation-failed");
}else{
obj.removeClass("input_validation-failed");
}
}
$.fn.validate_callback = function(msg,action_type,options){
this.each(function(){
if(action_type == "failed"){
change_error_style($(this),"add");
change_tip($(this),msg,"add");
}else{
change_error_style($(this),"remove");
change_tip($(this),null,"remove");
}
});
};
| JavaScript |
function FindProxyForURL(url, host) {
PROXY = "PROXY yourhttpproxy:80";
DEFAULT = "DIRECT";
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?appspot\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?blogspot\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(\d{2,}\.)docs\.google\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(\d{2,}\.)drive\.google\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?googleapis\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?googlecode\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?googlegroups\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?googlemashups\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?ig\.ig\.gmodules\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?a\.orkut\.gmodules\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)doc-(.{5})-docs\.googleusercontent\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\-)?a-fc-opensocial\.googleusercontent\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)images(\d{2,})-focus-opensocial\.googleusercontent\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(\d{2,}\.)-wave-opensocial\.googleusercontent\.com/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?au\.doubleclick\.net/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?de\.doubleclick\.net/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?fr\.doubleclick\.net/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?jp\.doubleclick\.net/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?uk\.doubleclick\.net/i.test(url)) return PROXY;
if(/^[\w\-]+:\/+(?!\/)(www|ssl)\.google-analytics\.net/i.test(url)) return DEFAULT;
if(/^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?google-analytics\.net/i.test(url)) return PROXY;
return DEFAULT;
} | JavaScript |
function ReinitIframe(frame){
this.iframe = document.getElementById(frame);
var bHeight = 0;
var dHeight = 0;
if(this.iframe != null){
if(this.iframe.contentWindow.document.body.scrollHeight != null)
bHeight = this.iframe.contentWindow.document.body.scrollHeight;
if(this.iframe.contentWindow.document.documentElement.scrollHeight != null)
dHeight = this.iframe.contentWindow.document.documentElement.scrollHeight;
}
var height = Math.max(bHeight, dHeight);
this.iframe.height = height;
}
function SortTr(content,dates,btn){
this.content = document.getElementById(content);
this.trs=this.content.getElementsByTagName('TR');
this.btn=document.getElementById(btn);
this.btn.style.cursor = 'pointer';
this.dir=1;
this.a = [];
var reg = /(\d{4})-(\d{1,2})-(\d{1,2})/;
for(var i=0;i<this.trs.length;i++){
var time=css.find(dates,this.trs[i])[0];
var date = new Date();
var re = reg.exec(time.innerHTML);
date.setFullYear(re[1]);
date.setMonth(re[2]-1);
date.setDate(re[3]);
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
this.a.push({
node:this.trs[i],
formatTime:date
})
}
var _this = this;
this.btn.onclick = function(){
_this.a.sort(function(a1,a2){
if(a1.formatTime > a2.formatTime){
return _this.dir;
} else if(a1.formatTime < a2.formatTime){
return -_this.dir;
} else{
return 0;
}
});
_this.dir = -_this.dir;
_this.add();
}
};
SortTr.prototype = {
add:function(){
this.content.innerHTML = '';
var frag = document.createDocumentFragment();
for(var i=0;i<this.a.length;i++){
frag.appendChild(this.a[i].node);
if(i%2==0){
css.add(this.a[i].node,'alt-row');
} else{
css.del(this.a[i].node,'alt-row')
}
}
this.content.appendChild(frag);
}
};
function SrotStage(content,stage,btn){
this.content = document.getElementById(content);
this.trs=this.content.getElementsByTagName('TR');
this.btn=document.getElementById(btn);
this.btn.style.cursor = 'pointer';
this.dir=1;
this.a = [];
for(var i=0; i<this.trs.length;i++){
var stageOrder = css.find(stage,this.trs[i])[0].value;
this.a.push({
node:this.trs[i],
formatTime:stageOrder
})
}
var _this = this;
this.btn.onclick=function(){
_this.a.sort(function(a1,a2){
if(a1.formatTime>a2.formatTime){
return _this.dir;
} else if(a1.formatTime<a2.formatTime){
return -_this.dir;
} else{
return 0;
}
});
_this.dir = -_this.dir;
_this.add();
}
};
SrotStage.prototype = {
add:function(){
this.content.innerHTML = '';
var frag = document.createDocumentFragment();
for(var i=0;i<this.a.length;i++){
frag.appendChild(this.a[i].node);
if(i%2==0){
css.add(this.a[i].node,'alt-row');
} else{
css.del(this.a[i].node,'alt-row')
}
}
this.content.appendChild(frag);
}
};
var css={
has:function(o,n){
var reg=new RegExp("(^|\\s)" + n + "(\\s|$)");
if(reg.test(o.className)){
return true;
} else {
return false;
}
},
add:function(o,n){
if(this.has(o,n)){
return;
} else{
var ao=o.className.split(' ');
ao.push(n);
o.className = ao.join(' ');
}
},
del:function(o,n){
var ao=o.className.split(' ');
for(var i in ao){
if(ao[i] == n){
ao.splice(i,1);
o.className=ao.join(' ');
return;
}
}
},
find: function(n, e){
e = e || document;
if(e.getElementsByClassName){
return e.getElementsByClassName(n);
} else if(e.querySelectorAll){
return e.querySelectorAll("." + n);
} else{
var tem = [];
var nodes=e.getElementsByTagName('*');
for(var i=0;i<nodes.length;i++){
if(this.has(nodes[i],n)){
tem.push(nodes[i]);
}
}
return tem;
}
}
} | JavaScript |
var cal;
var isFocus=false; //是否为焦点
var pickMode ={
"second":1,
"minute":2,
"hour":3,
"day":4,
"month":5,
"year":6 };
var topY=0,leftX=0; //自定义定位偏移量 2007-02-11 由 寒羽枫添加
//选择日期 → 由 寒羽枫 2007-06-10 添加,通过 ID 来选日期
function SelectDateById(id,strFormat,x,y) { var obj = document.getElementById(id); if(obj
== null){return false;} obj.focus(); if(obj.onclick != null){obj.onclick();}
else if(obj.click != null){obj.click();} else{SelectDate(obj,strFormat,x,y)} }
//选择日期 → 由 寒羽枫 2006-06-25 添加
function SelectDate(obj,strFormat,x,y)
{
leftX =(x == null) ? leftX : x;
topY =(y == null) ? topY : y;//自定义定位偏移量 2007-02-11 由 寒羽枫添加
if(document.getElementById("ContainerPanel")==null){InitContainerPanel();}
var date = new Date();
var by = date.getFullYear()-50; //最小值 → 50 年前
var ey = date.getFullYear()+50; //最大值 → 50 年后
//cal = new Calendar(by, ey,1,strFormat); //初始化英文版,0 为中文版
cal = (cal==null) ? new Calendar(by, ey, 0) : cal; //不用每次都初始化 2006-12-03 修正
cal.DateMode =pickMode["second"]; //复位
if(strFormat.indexOf('s')< 0) {cal.DateMode =pickMode["minute"];}//精度为分
if(strFormat.indexOf('m')< 0) {cal.DateMode =pickMode["hour"];}//精度为时
if(strFormat.indexOf('h')< 0) {cal.DateMode =pickMode["day"];}//精度为日
if(strFormat.indexOf('d')< 0) {cal.DateMode =pickMode["month"];}//精度为月
if(strFormat.indexOf('M')< 0) {cal.DateMode =pickMode["year"];}//精度为年
if(strFormat.indexOf('y')< 0) {cal.DateMode =pickMode["second"];}//默认精度为秒
cal.dateFormatStyleOld = cal.dateFormatStyle;
cal.dateFormatStyle = strFormat;
cal.show(obj);
}
/**//**//**//**//**//**//**//**
* 返回日期
* @param d the delimiter
* @param p the pattern of your date
2006-06-25 由 寒羽枫 修改为根据用户指定的 style 来确定;
*/
String.prototype.toDate = function(style) {
var y = this.substring(style.indexOf('y'),style.lastIndexOf('y')+1);// 年
var M = this.substring(style.indexOf('M'),style.lastIndexOf('M')+1);// 月
var d = this.substring(style.indexOf('d'),style.lastIndexOf('d')+1);// 日
var h = this.substring(style.indexOf('h'),style.lastIndexOf('h')+1);// 时
var m = this.substring(style.indexOf('m'),style.lastIndexOf('m')+1);// 分
var s = this.substring(style.indexOf('s'),style.lastIndexOf('s')+1);// 秒
if(s == null ||s == "" || isNaN(s)) {s = new Date().getSeconds();}
if(m == null ||m == "" || isNaN(m)) {m = new Date().getMinutes();}
if(h == null ||h == "" || isNaN(h)) {h = new Date().getHours();}
if(d == null ||d == "" || isNaN(d)) {d = new Date().getDate();}
if(M == null ||M == "" || isNaN(M)) {M = new Date().getMonth()+1;}
if(y == null ||y == "" || isNaN(y)) {y = new Date().getFullYear();}
var dt ;
eval ("dt = new Date('"+ y+"', '"+(M-1)+"','"+ d+"','"+ h+"','"+ m+"','"+ s +"')");
return dt;
}
/**//**//**//**//**//**//**//**
* 格式化日期
* @param d the delimiter
* @param p the pattern of your date
* @author meizz
*/
Date.prototype.format = function(style) {
var o = {
"M+" : this.getMonth() + 1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"w+" : "天一二三四五六".charAt(this.getDay()), //week
"q+" : Math.floor((this.getMonth() + 3) / 3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(style)) {
style = style.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for(var k in o){
if(new RegExp("("+ k +")").test(style)){
style = style.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
}
}
return style;
}
//2007-09-14 由寒羽枫添加返回所选日期
Calendar.prototype.ReturnDate = function(dt) {
if (this.dateControl != null){this.dateControl.value = dt;}
calendar.hide();
if(this.dateControl.onchange == null){return;}
//将 onchange 转成其它函数,以免触发验证事件
var ev = this.dateControl.onchange.toString(); //找出函数的字串
ev = ev.substring(
((ev.indexOf("ValidatorOnChange();")> 0) ? ev.indexOf("ValidatorOnChange();") + 20 : ev.indexOf("{") + 1)
, ev.lastIndexOf("}"));//去除验证函数 ValidatorOnChange();
var fun = new Function(ev); //重新定义函数
this.dateControl.changeEvent = fun;
this.dateControl.changeEvent();//触发自定义 changeEvent 函数
}
/**//**//**//**//**//**//**//**
* 日历类
* @param beginYear 1990
* @param endYear 2010
* @param lang 0(中文)|1(英语) 可自由扩充
* @param dateFormatStyle "yyyy-MM-dd";
* @version 2006-04-01
* @author KimSoft (jinqinghua [at] gmail.com)
* @update
*/
function Calendar(beginYear, endYear, lang, dateFormatStyle) {
this.beginYear = 1950;
this.endYear = 2050;
this.lang = 0; //0(中文) | 1(英文)
this.dateFormatStyle = "yyyy-MM-dd hh:mm:ss";
if (beginYear != null && endYear != null){
this.beginYear = beginYear;
this.endYear = endYear;
}
if (lang != null){
this.lang = lang
}
if (dateFormatStyle != null){
this.dateFormatStyle = dateFormatStyle
}
this.dateControl = null;
this.panel = this.getElementById("calendarPanel");
this.container = this.getElementById("ContainerPanel");
this.form = null;
this.date = new Date();
this.year = this.date.getFullYear();
this.month = this.date.getMonth();
this.day = this.date.getDate();
this.hour = this.date.getHours();
this.minute = this.date.getMinutes();
this.second = this.date.getSeconds();
this.colors = {
"cur_word" : "#FFFFFF", //当日日期文字颜色
"cur_bg" : "#00FF00", //当日日期单元格背影色
"sel_bg" : "#FFCCCC", //已被选择的日期单元格背影色 2006-12-03 寒羽枫添加
"sun_word" : "#FF0000", //星期天文字颜色
"sat_word" : "#0000FF", //星期六文字颜色
"td_word_light" : "#333333", //单元格文字颜色
"td_word_dark" : "#CCCCCC", //单元格文字暗色
"td_bg_out" : "#EFEFEF", //单元格背影色
"td_bg_over" : "#FFCC00", //单元格背影色
"tr_word" : "#FFFFFF", //日历头文字颜色
"tr_bg" : "#666666", //日历头背影色
"input_border" : "#CCCCCC", //input控件的边框颜色
"input_bg" : "#EFEFEF" //input控件的背影色
}
/* //2008-01-29 放到了 show ,因为要做 pickMode 判断
this.draw();
this.bindYear();
this.bindMonth();
*/
//this.changeSelect();
//this.bindData(); //2006-12-30 由民工.砖家注释
}
/**//**//**//**//**//**//**//**
* 日历类属性(语言包,可自由扩展)
*/
Calendar.language = {
"year" : [[""], [""]],
"months" : [["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]
],
"weeks" : [["日","一","二","三","四","五"," 六"],
["SUN","MON","TUR","WED","THU","FRI","SAT"]
],
"hour" : [["时"], ["H"]],
"minute" : [["分"], ["M"]],
"second" : [["秒"], ["S"]],
"clear" : [["清空"], ["CLS"]],
"today" : [["今天"], ["TODAY"]],
"pickTxt" : [["确定"], ["OK"]],//pickMode 精确到年、月时把今天变成“确定”
"close" : [["关闭"], ["CLOSE"]]
}
Calendar.prototype.draw = function() {
calendar = this;
var mvAry = [];
//mvAry[mvAry.length] = ' <form name="calendarForm" style="margin: 0px;">'; //因 <form> 不能嵌套, 2006-12-01 由寒羽枫改用 Div
mvAry[mvAry.length] = ' <div name="calendarForm" style="margin: 0px;">';
mvAry[mvAry.length] = ' <table width="100%" border="0" cellpadding="0" cellspacing="1" style="font-size:12px;">';
mvAry[mvAry.length] = ' <tr>';
mvAry[mvAry.length] = ' <th align="left" width="1%"><input style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:16px;height:20px;';
if(calendar.DateMode > pickMode["month"]){mvAry[mvAry.length] = 'display:none;';}//pickMode 精确到年时隐藏 “月”
mvAry[mvAry.length] ='" name="prevMonth" type="button" id="prevMonth" value="<" /></th>';
mvAry[mvAry.length] = ' <th align="center" width="98%" nowrap="nowrap"><select name="calendarYear" id="calendarYear" style="font-size:12px;"></select><select name="calendarMonth" id="calendarMonth" style="font-size:12px;';
if(calendar.DateMode > pickMode["month"]){mvAry[mvAry.length] = 'display:none;';}//pickMode 精确到年时隐藏 “月”
mvAry[mvAry.length] = '"></select></th>';
mvAry[mvAry.length] = ' <th align="right" width="1%"><input style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:16px;height:20px;';
if(calendar.DateMode > pickMode["month"]){mvAry[mvAry.length] = 'display:none;';}//pickMode 精确到年时隐藏 “月”
mvAry[mvAry.length] ='" name="nextMonth" type="button" id="nextMonth" value=">" /></th>';
mvAry[mvAry.length] = ' </tr>';
mvAry[mvAry.length] = ' </table>';
mvAry[mvAry.length] = ' <table id="calendarTable" width="100%" style="border:0px solid #CCCCCC;background-color:#FFFFFF;font-size:12px;';
if(calendar.DateMode >= pickMode["month"]){mvAry[mvAry.length] = 'display:none;';}//pickMode 精确到年、月时隐藏 “天”
mvAry[mvAry.length] = '" border="0" cellpadding="3" cellspacing="1">';
mvAry[mvAry.length] = ' <tr>';
for(var i = 0; i < 7; i++) {
mvAry[mvAry.length] = ' <th style="font-weight:normal;background-color:' + calendar.colors["tr_bg"] + ';color:' + calendar.colors["tr_word"] + ';">' + Calendar.language["weeks"][this.lang][i] + '</th>';
}
mvAry[mvAry.length] = ' </tr>';
for(var i = 0; i < 6;i++){
mvAry[mvAry.length] = ' <tr align="center">';
for(var j = 0; j < 7; j++) {
if (j == 0){
mvAry[mvAry.length] = ' <td style="cursor:default;color:' + calendar.colors["sun_word"] + ';"></td>';
} else if(j == 6) {
mvAry[mvAry.length] = ' <td style="cursor:default;color:' + calendar.colors["sat_word"] + ';"></td>';
} else {
mvAry[mvAry.length] = ' <td style="cursor:default;"></td>';
}
}
mvAry[mvAry.length] = ' </tr>';
}
//2009-03-03 添加的代码,放置时间的行
mvAry[mvAry.length] = ' <tr style="';
if(calendar.DateMode >= pickMode["day"]){mvAry[mvAry.length] = 'display:none;';}//pickMode 精确到时日隐藏“时间”
mvAry[mvAry.length] = '"><td align="center" colspan="7">';
mvAry[mvAry.length] = ' <select name="calendarHour" id="calendarHour" style="font-size:12px;"></select>' + Calendar.language["hour"][this.lang];
mvAry[mvAry.length] = '<span style="'
if(calendar.DateMode >= pickMode["hour"]){mvAry[mvAry.length] = 'display:none;';}//pickMode 精确到小时时隐藏 “分”
mvAry[mvAry.length] = '"><select name="calendarMinute" id="calendarMinute" style="font-size:12px;"></select>' + Calendar.language["minute"][this.lang]+'</span>';
mvAry[mvAry.length] = '<span style="'
if(calendar.DateMode >= pickMode["minute"]){mvAry[mvAry.length] = 'display:none;';}//pickMode 精确到小时、分时隐藏 “秒”
mvAry[mvAry.length] = '"><select name="calendarSecond" id="calendarSecond" style="font-size:12px;"></select>'+ Calendar.language["second"][this.lang]+'</span>';
mvAry[mvAry.length] = ' </td></tr>';
mvAry[mvAry.length] = ' </table>';
//mvAry[mvAry.length] = ' </from>';
mvAry[mvAry.length] = ' <div align="center" style="padding:4px 4px 4px 4px;background-color:' + calendar.colors["input_bg"] + ';">';
mvAry[mvAry.length] = ' <input name="calendarClear" type="button" id="calendarClear" value="' + Calendar.language["clear"][this.lang] + '" style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:40px;height:20px;font-size:12px;cursor:pointer;"/>';
mvAry[mvAry.length] = ' <input name="calendarToday" type="button" id="calendarToday" value="'
mvAry[mvAry.length] = (calendar.DateMode == pickMode["day"]) ? Calendar.language["today"][this.lang] : Calendar.language["pickTxt"][this.lang];
mvAry[mvAry.length] = '" style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:60px;height:20px;font-size:12px;cursor:pointer"/>';
mvAry[mvAry.length] = ' <input name="calendarClose" type="button" id="calendarClose" value="' + Calendar.language["close"][this.lang] + '" style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:40px;height:20px;font-size:12px;cursor:pointer"/>';
mvAry[mvAry.length] = ' </div>';
mvAry[mvAry.length] = ' </div>';
this.panel.innerHTML = mvAry.join("");
/**//**//**//******** 以下代码由寒羽枫 2006-12-01 添加 **********/
var obj = this.getElementById("prevMonth");
obj.onclick = function () {calendar.goPrevMonth(calendar);}
obj.onblur = function () {calendar.onblur();}
this.prevMonth= obj;
obj = this.getElementById("nextMonth");
obj.onclick = function () {calendar.goNextMonth(calendar);}
obj.onblur = function () {calendar.onblur();}
this.nextMonth= obj;
obj = this.getElementById("calendarClear");
obj.onclick = function ()
{ calendar.ReturnDate(""); /*calendar.dateControl.value = "";calendar.hide();*///2007-09-14 由寒羽枫注释
}
this.calendarClear = obj;
obj = this.getElementById("calendarClose");
obj.onclick = function () {calendar.hide();}
this.calendarClose = obj;
obj = this.getElementById("calendarYear");
obj.onchange = function () {calendar.update(calendar);}
obj.onblur = function () {calendar.onblur();}
this.calendarYear = obj;
obj = this.getElementById("calendarMonth");
with(obj)
{
onchange = function () {calendar.update(calendar);}
onblur = function () {calendar.onblur();}
}this.calendarMonth = obj;
obj = this.getElementById("calendarHour");
obj.onchange = function () {calendar.hour = this.options[this.selectedIndex].value;}
obj.onblur = function () {calendar.onblur();}
this.calendarHour = obj;
obj = this.getElementById("calendarMinute");
obj.onchange = function () {calendar.minute = this.options[this.selectedIndex].value;}
obj.onblur = function () {calendar.onblur();}
this.calendarMinute = obj;
obj = this.getElementById("calendarSecond");
obj.onchange = function () {calendar.second = this.options[this.selectedIndex].value;}
obj.onblur = function () {calendar.onblur();}
this.calendarSecond = obj;
obj = this.getElementById("calendarToday");
obj.onclick = function () {
var today = (calendar.DateMode != pickMode["day"]) ?
new Date(calendar.year,calendar.month,calendar.day,calendar.hour,calendar.minute,calendar.second)
: new Date();//2008-01-29
calendar.ReturnDate(today.format(calendar.dateFormatStyle));
}
this.calendarToday = obj;
}
//年份下拉框绑定数据
Calendar.prototype.bindYear = function() {
var cy = this.calendarYear;//2006-12-01 由寒羽枫修改
cy.length = 0;
for (var i = this.beginYear; i <= this.endYear; i++){
cy.options[cy.length] = new Option(i + Calendar.language["year"][this.lang], i);
}
}
//月份下拉框绑定数据
Calendar.prototype.bindMonth = function() {
var cm = this.calendarMonth;//2006-12-01 由寒羽枫修改
cm.length = 0;
for (var i = 0; i < 12; i++){
cm.options[cm.length] = new Option(Calendar.language["months"][this.lang][i], i);
}
}
//小时下拉框绑定数据
Calendar.prototype.bindHour = function() {
var ch = this.calendarHour;
if(ch.length > 0){return;}//2009-03-03 不需要重新绑定,提高性能
//ch.length = 0;
var h;
for (var i = 0; i < 24; i++){
h = ("00" + i +"").substr(("" + i).length);
ch.options[ch.length] = new Option(h, h);
}
}
//分钟下拉框绑定数据
Calendar.prototype.bindMinute = function() {
var cM = this.calendarMinute;
if(cM.length > 0){return;}//2009-03-03 不需要重新绑定,提高性能
//cM.length = 0;
var M;
for (var i = 0; i < 60; i++){
M = ("00" + i +"").substr(("" + i).length);
cM.options[cM.length] = new Option(M, M);
}
}
//秒钟下拉框绑定数据
Calendar.prototype.bindSecond = function() {
var cs = this.calendarSecond;
if(cs.length > 0){return;}//2009-03-03 不需要重新绑定,提高性能
//cs.length = 0;
var s;
for (var i = 0; i < 60; i++){
s = ("00" + i +"").substr(("" + i).length);
cs.options[cs.length] = new Option(s, s);
}
}
//向前一月
Calendar.prototype.goPrevMonth = function(e){
if (this.year == this.beginYear && this.month == 0){return;}
this.month--;
if (this.month == -1) {
this.year--;
this.month = 11;
}
this.date = new Date(this.year, this.month, 1);
this.changeSelect();
this.bindData();
}
//向后一月
Calendar.prototype.goNextMonth = function(e){
if (this.year == this.endYear && this.month == 11){return;}
this.month++;
if (this.month == 12) {
this.year++;
this.month = 0;
}
this.date = new Date(this.year, this.month, 1);
this.changeSelect();
this.bindData();
}
//改变SELECT选中状态
Calendar.prototype.changeSelect = function() {
var cy = this.calendarYear;//2006-12-01 由寒羽枫修改
var cm = this.calendarMonth;
var ch = this.calendarHour;
var cM = this.calendarMinute;
var cs = this.calendarSecond;
//2006-12-30 由民工.砖家修改,减少运算次数
cy[this.date.getFullYear()-this.beginYear].selected = true;
cm[this.date.getMonth()].selected =true;
//2009-03-03 添加,初始化时间的值
ch[this.hour].selected =true;
cM[this.minute].selected =true;
cs[this.second].selected =true;
}
//更新年、月
Calendar.prototype.update = function (e){
this.year = e.calendarYear.options[e.calendarYear.selectedIndex].value;//2006-12-01 由寒羽枫修改
this.month = e.calendarMonth.options[e.calendarMonth.selectedIndex].value;
this.date = new Date(this.year, this.month, 1);
//this.changeSelect();
this.bindData();
}
//绑定数据到月视图
Calendar.prototype.bindData = function () {
var calendar = this;
if(calendar.DateMode >= pickMode["month"]){return;}//2008-01-29
// var dateArray = this.getMonthViewArray(this.date.getYear(), this.date.getMonth());
//2006-12-30 由民工.砖家修改 在Firefox 下年份错误
var dateArray = this.getMonthViewArray(this.date.getFullYear(), this.date.getMonth());
var tds = this.getElementById("calendarTable").getElementsByTagName("td");
for(var i = 0; i < tds.length; i++) {
tds[i].style.backgroundColor = calendar.colors["td_bg_out"];
tds[i].onclick = function () {return;}
tds[i].onmouseover = function () {return;}
tds[i].onmouseout = function () {return;}
if (i > dateArray.length - 1) break;
tds[i].innerHTML = dateArray[i];
if (dateArray[i] != " "){
tds[i].bgColorTxt = "td_bg_out"; //2009-03-03 保存背景色的 class
var cur = new Date();
tds[i].isToday = false;
if (cur.getFullYear() == calendar.date.getFullYear() && cur.getMonth() == calendar.date.getMonth() && cur.getDate() == dateArray[i]) {
//是今天的单元格
tds[i].style.backgroundColor = calendar.colors["cur_bg"];
tds[i].bgColorTxt = "cur_bg";
tds[i].isToday = true;
}
if(calendar.dateControl != null )
{
cur = calendar.dateControl.value.toDate(calendar.dateFormatStyle);
if (cur.getFullYear() == calendar.date.getFullYear() && cur.getMonth() == calendar.date.getMonth()&& cur.getDate() == dateArray[i]) {
//是已被选中的单元格
calendar.selectedDayTD = tds[i];
tds[i].style.backgroundColor = calendar.colors["sel_bg"];
tds[i].bgColorTxt = "sel_bg";
}
}
tds[i].onclick = function () {
if(calendar.DateMode == pickMode["day"]) //2009-03-03 当选择日期时,点击格子即返回值
{
calendar.ReturnDate(new Date(calendar.date.getFullYear(),
calendar.date.getMonth(),
this.innerHTML).format(calendar.dateFormatStyle));
}
else
{
if(calendar.selectedDayTD != null) //2009-03-03 清除已选中的背景色
{
calendar.selectedDayTD.style.backgroundColor =(calendar.selectedDayTD.isToday)? calendar.colors["cur_bg"] : calendar.colors["td_bg_out"];
}
this.style.backgroundColor = calendar.colors["sel_bg"];
calendar.day = this.innerHTML;
calendar.selectedDayTD = this; //2009-03-03 记录已选中的日子
}
}
tds[i].style.cursor ="pointer"; //2007-08-06 由寒羽枫添加,鼠标变成手指状
tds[i].onmouseover = function () {
this.style.backgroundColor = calendar.colors["td_bg_over"];
}
tds[i].onmouseout = function () {
if(calendar.selectedDayTD != this) {
this.style.backgroundColor = calendar.colors[this.bgColorTxt];}
}
tds[i].onblur = function () {calendar.onblur();}
}
}
}
//根据年、月得到月视图数据(数组形式)
Calendar.prototype.getMonthViewArray = function (y, m) {
var mvArray = [];
var dayOfFirstDay = new Date(y, m, 1).getDay();
var daysOfMonth = new Date(y, m + 1, 0).getDate();
for (var i = 0; i < 42; i++) {
mvArray[i] = " ";
}
for (var i = 0; i < daysOfMonth; i++){
mvArray[i + dayOfFirstDay] = i + 1;
}
return mvArray;
}
//扩展 document.getElementById(id) 多浏览器兼容性 from meizz tree source
Calendar.prototype.getElementById = function(id){
if (typeof(id) != "string" || id == "") return null;
if (document.getElementById) return document.getElementById(id);
if (document.all) return document.all(id);
try {return eval(id);} catch(e){ return null;}
}
//扩展 object.getElementsByTagName(tagName)
Calendar.prototype.getElementsByTagName = function(object, tagName){
if (document.getElementsByTagName) return document.getElementsByTagName(tagName);
if (document.all) return document.all.tags(tagName);
}
//取得HTML控件绝对位置
Calendar.prototype.getAbsPoint = function (e){
var x = e.offsetLeft;
var y = e.offsetTop;
while(e = e.offsetParent){
x += e.offsetLeft;
y += e.offsetTop;
}
return {"x": x, "y": y};
}
//显示日历
Calendar.prototype.show = function (dateObj, popControl) {
if (dateObj == null){
throw new Error("arguments[0] is necessary")
}
this.dateControl = dateObj;
var now = new Date();
this.date = (dateObj.value.length > 0) ? new Date(dateObj.value.toDate(this.dateFormatStyle)) : now.format(this.dateFormatStyle).toDate(this.dateFormatStyle) ;//2008-01-29 寒羽枫添加 → 若为空则根据dateFormatStyle初始化日期
if(this.panel.innerHTML==""||cal.dateFormatStyleOld != cal.dateFormatStyle)//2008-01-29 把构造表格放在此处,2009-03-03 若请示的样式改变,则重新初始化
{
this.draw();
this.bindYear();
this.bindMonth();
this.bindHour();
this.bindMinute();
this.bindSecond();
}
this.year = this.date.getFullYear();
this.month = this.date.getMonth();
this.day = this.date.getDate();
this.hour = this.date.getHours();
this.minute = this.date.getMinutes();
this.second = this.date.getSeconds();
this.changeSelect();
this.bindData();
if (popControl == null){
popControl = dateObj;
}
var xy = this.getAbsPoint(popControl);
//this.panel.style.left = xy.x + "px";
//this.panel.style.top = (xy.y + dateObj.offsetHeight) + "px";
this.panel.style.left = (xy.x + leftX)+ "px"; //由寒羽枫 2007-02-11 修改 → 加入自定义偏移量
this.panel.style.top = (xy.y + topY + dateObj.offsetHeight) + "px";
//由寒羽枫 2006-06-25 修改 → 把 visibility 变为 display,并添加失去焦点的事件 //this.setDisplayStyle("select", "hidden");
//this.panel.style.visibility = "visible";
//this.container.style.visibility = "visible";
this.panel.style.display = "";
this.container.style.display = "";
if( !this.dateControl.isTransEvent)
{
this.dateControl.isTransEvent = true;
/* 已写在返回值的时候 ReturnDate 函数中,去除验证事件的函数
this.dateControl.changeEvent = this.dateControl.onchange;//将 onchange 转成其它函数,以免触发验证事件
this.dateControl.onchange = function()
{if(typeof(this.changeEvent) =='function'){this.changeEvent();}}*/
if(this.dateControl.onblur != null){
this.dateControl.blurEvent = this.dateControl.onblur;}//2007-09-14 保存主文本框的 onblur ,使其原本的事件不被覆盖
this.dateControl.onblur = function()
{calendar.onblur();if(typeof(this.blurEvent) =='function'){this.blurEvent();}
}
}
this.container.onmouseover = function(){isFocus=true;}
this.container.onmouseout = function(){isFocus=false;}
}
//隐藏日历
Calendar.prototype.hide = function() {
//this.setDisplayStyle("select", "visible");
//this.panel.style.visibility = "hidden";
//this.container.style.visibility = "hidden";
this.panel.style.display = "none";
this.container.style.display = "none";
isFocus=false;
}
//焦点转移时隐藏日历 → 由寒羽枫 2006-06-25 添加
Calendar.prototype.onblur = function() {
if(!isFocus){this.hide();}
}
//以下由寒羽枫 2007-07-26 修改 → 确保日历容器节点在 body 最后,否则 FireFox 中不能出现在最上方
function InitContainerPanel() //初始化容器
{
var str = '<div id="calendarPanel" style="position: absolute;display: none;z-index:9999; background-color: #FFFFFF;border: 1px solid #CCCCCC;width:175px;font-size:12px;"></div>';
if(document.all)
{
str += '<iframe style="position:absolute;z-index:2000;width:expression(this.previousSibling.offsetWidth);';
str += 'height:expression(this.previousSibling.offsetHeight);';
str += 'left:expression(this.previousSibling.offsetLeft);top:expression(this.previousSibling.offsetTop);';
str += 'display:expression(this.previousSibling.style.display);" scrolling="no" frameborder="no"></iframe>';
}
var div = document.createElement("div");
div.innerHTML = str;
div.id = "ContainerPanel";
div.style.display ="none";
document.body.appendChild(div);
}//调用calendar.show(dateControl, popControl);
| JavaScript |
(function(){
var oHead = document.getElementsByTagName('head')[0];
var sBlock = 'header,footer,section,aside,article,nav,hgroup,figure,figcaption,details,summary';
var sInline = 'time,mark,ruby,rt,rp,output,keygen,meter,progress,command,source';
var sOther = 'video,audio,canvas,datalist';
var oStyle = document.createElement('style');
oStyle.type = 'text/css';
sCSS = sBlock + '{display:block;margin:0;padding:0;border:none}' + sInline + '{text-decoration:none;font-style:normal;font-weight:normal}';
if(oStyle.styleSheet){
var aTags = (sBlock + ',' + sInline + ',' + sOther).split(',');
for(var i=0;i<aTags.length;i++){
document.createElement(aTags[i]);
}
oStyle.styleSheet.cssText = sCSS;
}else{
oStyle.innerHTML = sCSS;
}
oHead.appendChild(oStyle);
})();
function $(id){
return document.getElementById(id);
}
function date(s,t) {
//s Y-m-d H:i:s
//t new Date()
t=t || new Date();
var re=/Y|m|d|H|i|s/g;
return s.replace(re,function($1) {
switch($1) {
case "Y":return t.getFullYear();
case "m":return t.getMonth()+1;
case "d":return t.getDate();
case "H":return t.getHours();
case "i":return t.getMinutes();
case "s":return t.getSeconds();
}
return $1;
});
}
function htmlEncode(html) {
//return html.replace("<","<").replace(">",">")
arguments.callee.textNode.nodeValue=html;
return arguments.callee.div.innerHTML;
}
htmlEncode.div=document.createElement("div");
htmlEncode.textNode=document.createTextNode("");
htmlEncode.div.appendChild(htmlEncode.textNode);
function nextNode(node){
var temObj=node.nextSibling;
while(temObj.nodeType!= 1 && temObj.nextSibling!=null){ //1是元素借点
temObj=temObj.nextSibling;
}
return (temObj.nodeType == 1)?temObj:false;
}
function previousNode(node){
var temObj=node.previousSibling;
while(temObj.nodeType!=1 && temObj!=null){
temObj=temObj.previousSibling;
}
return (temObj.nodeType ==1) ?temObj :false;
}
function lastSilibing(node){
var tempObj=node.parentNode.lastChild;
while(tempObj.nodeType!=1 && tempObj!=null){
tempObj=tempObj.previousSibling;
}
return (tempObj.nodeType==1) ? tempObj : false;
}
function firstSilibing(node){
var tempObj=node.parentNode.firstChild;
while(tempObj.nodeType!=1 && tempObj!=null){
tempObj=tempObj.nextSilibing;
}
return (tempObj.nodeType==1) ? tempObj : false;
}
function getText(node){
if(!node.hasChildNodes()){return false;}
var reg=/^s+$/;
while(node.nodeType!=3 && node.nextSilibing!=null || reg.test(node.nodeValue) ){
node=node.nextSilibing;
}
return (node.nodeType==3) ? node.nodeValue : false;
}
function setText(node,txt){
if(!node.hasChildNode){
return false;
}
var reg=/^s+$/;
while(node.nodeType!=3 && node.nextSilibing!=null || reg.test(node.nodeValue)){
node=node.nextSilibing;
}
if(node.nodeType==3) {node.nodeValue = txt} else return false;
}
function createLink(to,txt){
var tempObj=document.createElement('a');
tempObj.appendChild(document.createTextNode(txt));
tempObj.setAttribute('href',to);
return tempObj;
}
function addEvent(ele,evType,fn,useCapture){
if(ele.addEventListener){
ele.addEventListener(evType,fn,useCapture);
} else
if(ele.attachEvent){
ele.attachEvent('on'+evType,fn);
} else{
window['on'+evType] = fn;
}
}
function css(type,node,c1,c2){
switch (type){
case 'add':
if(!css('check',node,c1)){
node.className+=(node.className?" "+c1:c1);
}
break;
case 'del':
var rep=node.className.match(' '+c1) ? ' '+c1 : c1;
node.className=node.className.replace(rep,'');
break;
case 'swap':
node.className=!css('check',node,c1) ? node.className.replace(c2,c1) : node.className.replace(c1,c2);
break;
case 'check':
var found=false;
var temArray=node.className.split(' ');
for(var i=0;i<temArray.length;i++){
if(c1==temArray[i])
found=true;
}
return found;
break;
}
}
function getByClass(className,context) {
context=context || document;
if (context.getElementsByClassName) {
return context.getElementsByClassName(className);
}
var nodes=context.getElementsByTagName('*'),
ret=[];
for (var i=0;i<nodes.length;i++) {
if (hasClass(nodes[i],className)) ret.push(nodes[i]);
}
return ret;
}
function hasClass(node,className) {
var names=node.className.split(/\s+/);
for (var i=0;i<names.length;i++) {
if (names[i]==className) return true;
}
return false;
}
| JavaScript |
/* jQuery form plug-in 1.0.1
*
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
* http://docs.jquery.com/Plugins/Validation
*
* Copyright (c) 2010 NickCheng
* You can affiliation me My Email Address :NickCZPing@gmail.com
* And My QQ Number is: 406762380
*
* $Id: jquery.form-1.0.1 6403 2010-04-09 09:07
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Power description :
* All of the form item's valid
* Involve hidden ,textBox,radio,checkBox,textArea,select and so on
* I will define their's style and validate
* And for example the textBox have many items userName,companyName,telephone,Address and so on
* 目前该版本支持:ie6,7,8;firefox3.以上;Chrome
*/
(function($) {
var str = "";
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
//判断浏览器类型
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
//定义所有需验证的控件名称
//定义所有的正则
var WIDGETREG =
{
'username':/^[A-Za-z]\w{3,19}$/,
'feikomg':'',
'password':/^[0-9A-z-_~!@#$%^&*()_+`\[\]\;\:\"\<\>]{6,20}$/,
'number':'',//这个用于验证学号格式是否正确以及是否存在
'chineseName':/(^[\u4e00-\u9fa5]*$)/,
'address':/(^[\u4e00-\u9fa5]*[0-9a-zA-Z]*([\u4e00-\u9fa5]|[0-9a-zA-Z])*$)/,
'qq':/^[1-9][0-9]{4,}$/,
'email':/^[a-zA-Z0-9_\\.]+@[a-zA-Z0-9-]+[\\.a-zA-Z]+$/,
'phone':/^(\+)?([0-9]{1,3}[-\s])?([0-9]{3,4}[-\s])?([0-9]{7,8})([-\s][0-9]{1,5})?$/,
'mobile':/^([0-9]{11,12})?$/,
'zipcode':/^[0-9]{6}$/,
'money':/^-?\d+(\.\d{0,2})?$/,
'authcode':/^[^\s?<>\'\"!@%#$~&*():;]*$/,
'datetime':/^\d{4}-\d{2}-\d{2}$/,
'bankaccount':/^(?:\d{4}){4,5}\d{3}$/,
'textbox':/^[^;,'"<>#]*$/,
'textarea':/^[^;,'"<>#]*$/,
'confirmpwd':'',
'commonSelect':'',
'commonRadio':'',
'idcard':'',
'invalidchar': /^[^<>$';]*$/,
'realName':/^([\u4e00-\u9fa5]{2,12})/g,//真实姓名,必须为汉字开始为(/^([\u4e00-\u9fa5]{2,12})|([a-zA-Z-\s]{3,20})$/)!
'urlname':/^([a-z]+:\/\/)?([\w-]+)\.([\w-]+)(\.[\w-]+)*(\/)?[^s]*$/,
// 'domain':/^(\*\.)?[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?$/,
// 'ip':/^(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))$/
};
//初始化项当鼠标移向控件弹出提示信息,移开则隐藏提示信息(obj:当前对象,str_:初始化提示信息)
$.init = function(obj,str_){
if(obj.attr("required")){
var redstar = "<span class='redstar'>*</span>"
var newtitle= obj.parent().prev().find('label').text();
var trimtitle = $.trim(newtitle);
if(_isHaveStar(trimtitle))
obj.parent().prev().find('label').html(newtitle + redstar);
}
obj.hover(function(){
var splitclass = obj.attr('class').substring(16);
if(obj.val().length == 0 || splitclass == 'error-style'){
//如果存在则不加
if($('#tooltips-box').size()==0){
if($('#TB_window').size() > 0){
$('#TB_window').append('<div id="tooltips-box"><div class="tooltips-howpanel-top" style="display:none;"></div><div class="tooltips-howpanel"></div><iframe id="tooltips_iframe"></iframe></div>');
}else{
$('body').append('<div id="tooltips-box"><div class="tooltips-howpanel-top" style="display:none;"></div><div class="tooltips-howpanel"></div><iframe id="tooltips_iframe"></iframe></div>');
}
}
tipShow();
}else{
if(obj.attr('type') == 'text') str_ = '输入正确' ;
tipHidden();
}
},function(){
tipHidden();
});
//获得当前高度(obj:当前对象)
_getTop = function(obj){
var position = obj.position();
var type = obj.attr("type");
var top = position.top ;
if(type == "textarea"){
var _top = 0;
if(Sys.ie) _top = obj.attr("rows") * 22;
if(Sys.firefox) _top = obj.attr("rows") * 19;
else _top = obj.attr("rows") * 17;
var tatop = top + _top;
return tatop;
}else{
var untatop = top+28;
return untatop;
}
};
_getWidth = function(object) {
return object.offsetWidth;
};
_getLeft = function(obj) {
var position = obj.position();
var left = position.left;
return left;
};
/* _getTop = function(object) {
var go = object;
var oParent,oTop = go.offsetTop;
while(go.offsetParent!=null) {
oParent = go.offsetParent;
oTop += oParent.offsetTop;
go = oParent;
}
return oTop + $(object).height()+ 5;
};*/
tipShow = function(){
var left = _getLeft(obj);
var width = $(".tooltips-howpanel").width();
var swidth = document.body.scrollWidth;
var xx = left+width-swidth;
var lf = 0;
var tp = _getTop(obj);
if(xx>0){
lf = _getLeft(obj)-xx;
$('.tooltips-howpanel-top').css({left:xx+'px'});
//$('.tooltips-howpanel-top').css({left:(lf+xx)+'px',top:tp+'px'});
}else{
lf = _getLeft(obj);
$('.tooltips-howpanel-top').css({left:'10px'});
//$('.tooltips-howpanel-top').css({left:lf+10+'px',top:tp+'px'});
}
$('#tooltips-box').css({left:lf+'px',top:tp+'px',position:'absolute'});
$('#tooltips_iframe').css({width:'240px',border:0,height:'35px'});
//$('.tooltips-howpanel').css({left:lf+'px',top:tp+'px'});
$('.tooltips-howpanel').html(str_);
$('.tooltips-howpanel').fadeIn("fast");
$('.tooltips-howpanel-top').fadeIn("fast");
};
tipHidden = function(){
$('.tooltips-howpanel').hide();
$('.tooltips-howpanel-top').hide();
$('#tooltips_iframe').css({width:'0px',height:'0px'});
};
// obj.info = obj.options.message;
obj.hover(window['tipShow'],window['tipHidden'])
.focus(window['tipShow'])
.blur(window['tipHidden']);
};
//判断是否需要加“*”号
_isHaveStar = function(str){
var flag = true;
if(Sys.ie || Sys.chrome){
str = str.substring(str.length-1);
if(str == "*")
return false;
}else{
for(var i in str){
if(str[i] == "*"){
flag = false;
break;
}
}
}
return flag;
};
//表单所填信息验证(name:当前方法名,obj:当前控件对象)
$.validator = function(name , obj,param){
var title = _getLabelInfo(obj);
var errorPrompt = title+'格式输入错误.';
str = obj.val();
for(j in WIDGETREG){
var reg = WIDGETREG[j];
if(name == j && reg != ""){
if(str !="" && str != null && reg.test(str)){
str = str;
}else{
str = this.error = {level:'error' ,text:errorPrompt};
}
return str;
}
else{
if(name == 'idcard'){
if(str.length!==16 && str.lenght!=17 && /^[1-9]\d{5}(?:\d{2}|\d{4})(?:(?:01|03|05|07|08|10|12)(?:0[1-9]|[1-2]\d|3[0-1])|(?:04|06|09|11)(?:0[1-9]|[1-2]\d|30)|02(?:0[1-9]|[1-2]\d))(?:\d{3}|\d{4}|\d{3}[xX])$/.test(str)){
str = str;
}else{
str = this.error = {level:'error' ,text:errorPrompt+'(规范:15位或者18位)!'};
}
return str;
}
else if(name == 'confirmpwd'){
var pwd = obj.parent().parent().parent().find("input[type='password']").val();
if(str != pwd){
str = this.error = {level:'error' ,text:'两次密码输入不一致.'};
}
if( /^[0-9A-z-_~!@#$%^&*()_+`\[\]\;\:\"\<\>]{6,20}$/.test(str))
{
str = str;
}
else{
str = this.error = {level:'error' ,text:errorPrompt};
}
return str;
}
else if(name == 'commonSelect'){
if(str != -1){
str=str;
}else{
str = this.error = {level:'error' ,text:'请选择'+title};
}
return str;
}else if ( name == 'callback' ){
var res = param.callback( $(obj).val() );
if( !res || res == true || res.result == true) {}
else {
str = { text : res.message , level : "error"} ;
}
return str;
}
/*else{
if(str != "" && str != null){
str=str;
}else{
str = this.error = {level:'error' ,text:'请选择'+title};
}
return str;
}*/
//******************后加如的ajax验证学号是否已注册********************************
else if(name == 'number'){
if(str==""){
str = this.error = {level:'error' ,text:'请输入'+title};
}else{
var data = 'uname=' + str;
$.ajax({
async :false,//默认为true,为true时为异步提交,无法更新str
type: "GET",
url: "/HongZhu/StunumIsExists",
data: data,
success: function (Msg) {
if(Msg=="1"){
str = this.error = {level:'error' ,text:'学号已存在'};
}
}
})}
return str;
}
//***************************THE END******************************************
else if(name == 'feikong'){
if(str==""){
str = this.error = {level:'error' ,text:'请输入'+title};
}
return str;
}
}
}
};
_callbackValid = function( name , self , param ) {
var valid = $.validator( name ,self , param);
if(valid != self.val()){
if(valid['level'] == 'error'){
$.addStyle(self);
$.init(self,valid['text']);
}
}else{
$.removeStyle(self);
}
};
//必填项验证(itemName:当前方法名,self:当前控件对象)
_requiredVaild = function(itemname,self){
if(self.attr("required")){
var valid = $.validator(itemname,self);
if(valid != self.val()){
if(valid['level'] == 'error'){
$.addStyle(self);
$.init(self,valid['text']);
}
}else{
$.removeStyle(self);
}
}
};
//可填项验证(itemName:当前方法名,self:当前控件对象)
_commonValid = function(itemname,self){
if(self.attr("required")){
var valid = $.validator(itemname,self);
if(valid != self.val()){
if(valid['level'] == 'error'){
$.addStyle(self);
$.init(self,valid['text']);
}
}else{
$.removeStyle(self);
}
}else{
if(self.val() == ""){
$.removeStyle(self);
}
if(self.val() !="" ){
var valid = $.validator(itemname,self);
if(valid != self.val()){
if(valid['level'] == 'error'){
$.addStyle(self);
$.init(self,valid['text']);
}
}else{
$.removeStyle(self);
}
}
}
};
//提交时验证(form:当前form对象)
submitValid = function(form){
var flag = true ;
$.each($(":input[type!='checkbox'][type!='radio'][type!='button'][type!='submit'][type!='reset']" , form ) , function(){
if(flag==false) return;
var self = $(this) ;
var selftype = self.attr("type");
var selfvalid = self.attr("valid");
var selfid = self.attr("id");
if(selfvalid == undefined ){
if(_checkSelfid(self)==true) selfvalid = selfid;
else selfvalid = _checkSelfid(self);//
}
var valid = $.validator(selfvalid,self);
if(self.attr("required")){
if(valid != undefined ){
if(valid != self.val()){
if(valid['level'] == 'error'){
$.addStyle(self);
$.init(self,valid['text']);
flag =false;
return;
}
}else{
$.removeStyle(self);
flag =true;
}
}
}else{
if(self.val() == ""){
$.removeStyle(self);
flag =true;
}
if(self.val() !="" ){
if(valid != undefined){
if(valid != self.val()){
if(valid['level'] == 'error'){
$.addStyle(self);
$.init(self,valid['text']);
flag =false;
return;
}
}else{
$.removeStyle(self);
flag =true;
}
}
}
}
}) ;
return flag;
};
//查看是否定义了名为控件id的验证器(self:当前控件对象)返回true:表示存在false:不存在
_checkSelfid = function(self){
var flag = false;
for(i in WIDGETREG){
if(i == self.attr('id')){
flag = true;
break;
}
}
//如果不存在,进行分析如果type为textarea则返回验证器‘textarea’
if(!flag){
if(self.attr('type') == 'textarea'){
return 'textarea';
}
else{
return 'textbox';
}
}
return flag;
};
//获得表单值(form:当前form对象)
_getData = function(form){
var data = "{";
$.each($(":input[type!='button'][type!='submit'][type!='reset']" , form ) , function(){
var self = $(this) ;
var selfid = self.attr("id");
var selfval = (self.val() != null && self.val() != '')? self.val() : null;
data += selfid+":"+selfval+",";
});
data = data.substring(0,data.length-1);
data = data + "}";
return data;
};
//获得当前控件前提示(self:当前控件对象)
_getLabelInfo = function(self){
var _title = self.parent().prev().find('label').html();
if(_title == null)
_title = self.parent().prev().html();
return _title.replace('\:','').replace('\*','');
};
//添加错误提示信息样式(隐藏正确样式)(obj:当前控件对象)
$.addStyle = function(obj){
obj.removeClass('right-style');
// $('#tooltips-box').hide();
tipShow();
obj.addClass("error-style");
};
//添加正确时样式(隐藏错误提示样式)(obj:当前控件对象)
$.removeStyle = function(obj){
obj.removeClass('error-style');
obj.remove('error-style');
// obj.removeClass('prompt-info');
tipHidden();
obj.addClass('right-style');
};
$.tipHidden = function(){
$('.tooltips-howpanel').hide();
$('.tooltips-howpanel-top').hide();
$('#tooltips_iframe').css({width:'0px',height:'0px'});
};
})(jQuery);
$(function(){
$(".formBody").find("input[type!='radio'][type!='checkbox'][type!='button'][type!='submit'][type!='reset']").each(function(){
$(this).addClass("form_item_input");
});
});
| JavaScript |
/**
* User: Allen
* Date: 12-4-18
*/
window.onload=function(){
new PosIt($('container'));
var btns=getByClass('pass');
new LoginIn(btns,'hover')
getByClass('login')[0].onmouseover=function(){
css('add',this,'hovers')
}
getByClass('login')[0].onmouseout=function(){
css('del',this,'hovers')
}
}
function PosIt(container){
this.container=container;
this.width=container.offsetWidth;
this.height=container.offsetHeight;
var _this=this;
window.onresize=function(){
_this.getWinsize();
}
this.getWinsize();
}
PosIt.prototype={
getWinsize:function(){
var wWidth=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var wHeight=window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
this.container.style.top=(wHeight-this.height)/2+'px';
this.container.style.left=(wWidth-this.width)/2+'px';
}
}
function LoginIn(inputs,hoverClass){
this.inputs=inputs;
this.hoverClass=hoverClass;
var _this=this;
for(var i=0;i<this.inputs.length;i++){
this.inputs[i].onfocus=function(){
css('add',this.parentNode,_this.hoverClass);
}
this.inputs[i].onkeyup=function(){
if(this.value){
previousNode(this).style.display='none';
}
else{
previousNode(this).style.display='';
}
}
this.inputs[i].onblur=function(){
css('del',this.parentNode,_this.hoverClass);
}
this.inputs[i].onpaste=function(){
return false;
}
}
}
| JavaScript |
/*! jQuery form plug-in 1.0.1
*
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
* http://docs.jquery.com/Plugins/Validation
*
* Copyright (c) 2010 NickCheng
* You can affiliation me My Email Address :NickCZPing@gmail.com
* And My QQ Number is: 406762380
*
* $Id: jquery.form-1.0.1 6403 2010-04-09 09:07
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Power description :
* All of the form item's define
* Involve hidden 、textBox、radio、checkBox、textArea、select and so on
* I will define their's style and validate
* And for example the textBox have many items user Name,company Name,telephone,Address and so on
*/
(function($) {
jQuery.fn.extend({
textbox : function(validname){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
if(validname == undefined) validname = 'invalidchar';
_commonValid(validname,self);
});
},
invalidchar : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('invalidchar',self);
});
},
username : function(){
var message = "请正确输入用户名:字母开头,不少于4位";
var self = this;
$.init(self,message);
this.blur(function(){
_requiredVaild('username',self);
});
},
feikong : function(){
var message = "请输入内容";
var self = this;
$.init(self,message);
this.blur(function(){
_requiredVaild('feikong',self);
});
},
password : function(){
var message = "请输入密码 注意:格式必须为6-20个非特殊字符。 ";
var self = this;
$.init(self,message);
this.blur(function(){
_requiredVaild('password',self);
});
},
confirmpwd : function(firstpwd){
var message = "请输入确认密码 注意:格式必须为6-20个非特殊字符。";
var self = this;
$.init(self,message);
this.blur(function(){
_requiredVaild('confirmpwd',self,firstpwd);
});
},
number : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('number',self);
}).keyup(function(){
var val = self.val();
this.value = val.replace(/\s/g,'').replace(/\D/g,'');
});
},
textarea : function() {
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('textarea',self);
});
},
chineseName : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title+"注意:只能为汉字";
$.init(self,message);
this.blur(function(){
_commonValid('chineseName',self);
});
},
realName : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title+"注意:只能为汉字";
$.init(self,message);
this.blur(function(){
_commonValid('realName',self);
});
},
address : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title+",注意:只能以汉字开头,中间可以包含字母和数字。)";
$.init(self,message);
this.blur(function(){
_commonValid('address',self);
});
},
qq : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('qq',self);
}).keyup(function(){
var val = self.val();
this.value = val.replace(/\s/g,'').replace(/\D/g,'');
});
},
email : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('email',self);
});
},
phone : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('phone',self);
});
},
mobile : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('mobile',self);
});
},
domain : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title+",例如:www.3jia5.cn)";
$.init(self,message);
this.blur(function(){
_commonValid('domain',self);
});
},
ip : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title+",例如:192.168.1.1)";
$.init(self,message);
this.blur(function(){
_commonValid('ip',self);
});
},
zipcode : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('zipcode',self);
}).keyup(function(){
var val = self.val();
this.value = val.replace(/\s/g,'').replace(/\D/g,'');
});
},
idcard : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('idcard',self);
});
},
money : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('money',self);
});
},
authcode : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('authcode',self);
});
},
datetime : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.click(function(){
MyCalendar.SetDate(this);
}).blur(function(){
_commonValid('datetime',self);
});
},
provinceAndCity : function(){
var self = this;
var province = self.attr("id");
var city = self.next().attr("id");
hw_init(province,city,"${province}$city");
this.click(function(){
hw_select(province,city);
});
},
commonSelect : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请选择"+title;
$.init(self,message);
var selfid = self.attr("id");
this.blur(function(){
_commonValid('commonSelect',self);
});
},
commonRadio : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请选择"+title;
$.init(self,message);
var selfid = self.attr("id");
this.click(function(){
});
},
callbackValid : function(options){
var self = this ;
this.blur(function(){
_callbackValid("callback" , self , options ) ;
});
},
//URL
urlname : function(){
var message = "请正确输入url地址。";
var self = this;
$.init(self,message);
this.blur(function(){
_requiredVaild('urlname',self);
});
},
numberRange : function( min , max ) {
this.callbackValid({callback:function(val){
if( val < min || val > max ) {
return { message : "数字必须大于" + min + "小于" + max } ;
}
return true ;
}});
},
//Button form 提交按钮
htmlform : function(formid){
var obj = this;
var form = obj.parents("form") ;
this.click(function(){
var flag = submitValid(form);
if(flag) form.submit();
});
},
//Button form Ajax提交按钮
ajaxform : function(){
var obj = this;
var form = obj.parents("form") ;
this.click(function(){
var flag = submitValid(form);
var data =_getData(form);// $.extend({},this.options.data) ;
if(flag){
var url = form.attr( "action" ) ;
var method = form.attr( "method" ) ;
$.ajax({
url : url ,
async : true ,
type : method,
data : data ,
success : function(){alert("success");} ,
error : function(){alert("error");}
});
}
});
}
});
})(jQuery); | JavaScript |
$(document).ready(function(){
//Sidebar Accordion Menu:
$("#main-nav li ul").hide(); // Hide all sub menus
$("#main-nav li a.current").parent().find("ul").slideToggle("slow"); // Slide down the current menu item's sub menu
$("#main-nav li a.nav-top-item").click( // When a top menu item is clicked...
function () {
$(this).parent().siblings().find("ul").slideUp("normal"); // Slide up all sub menus except the one clicked
$(this).next().slideToggle("normal"); // Slide down the clicked sub menu
return false;
}
);
$("#main-nav li a.no-submenu").click( // When a menu item with no sub menu is clicked...
function () {
window.location.href=(this.href); // Just open the link instead of a sub menu
return false;
}
);
// Sidebar Accordion Menu Hover Effect:
$("#main-nav li .nav-top-item").hover(
function () {
$(this).stop().animate({ paddingRight: "25px" }, 200);
},
function () {
$(this).stop().animate({ paddingRight: "15px" });
}
);
//Minimize Content Box
$(".content-box-header h3").css({ "cursor":"s-resize" }); // Give the h3 in Content Box Header a different cursor
$(".closed-box .content-box-content").hide(); // Hide the content of the header if it has the class "closed"
$(".closed-box .content-box-tabs").hide(); // Hide the tabs in the header if it has the class "closed"
$(".content-box-header h3").click( // When the h3 is clicked...
function () {
$(this).parent().next().toggle(); // Toggle the Content Box
$(this).parent().parent().toggleClass("closed-box"); // Toggle the class "closed-box" on the content box
$(this).parent().find(".content-box-tabs").toggle(); // Toggle the tabs
}
);
// Content box tabs:
$('.content-box .content-box-content div.tab-content').hide(); // Hide the content divs
$('ul.content-box-tabs li a.default-tab').addClass('current'); // Add the class "current" to the default tab
$('.content-box-content div.default-tab').show(); // Show the div with class "default-tab"
$('.content-box ul.content-box-tabs li a').click( // When a tab is clicked...
function() {
$(this).parent().siblings().find("a").removeClass('current'); // Remove "current" class from all tabs
$(this).addClass('current'); // Add class "current" to clicked tab
var currentTab = $(this).attr('href'); // Set variable "currentTab" to the value of href of clicked tab
$(currentTab).siblings().hide(); // Hide all content divs
$(currentTab).show(); // Show the content div with the id equal to the id of clicked tab
return false;
}
);
//Close button:
$(".close").click(
function () {
$(this).parent().fadeTo(400, 0, function () { // Links with the class "close" will close parent
$(this).slideUp(400);
});
return false;
}
);
// Alternating table rows:
$('tbody tr:even').addClass("alt-row"); // Add class "alt-row" to even table rows
// Check all checkboxes when the one in a table head is checked:
$('.check-all').click(
function(){
$(this).parent().parent().parent().parent().find("input[type='checkbox']").attr('checked', $(this).is(':checked'));
}
);
// Initialise Facebox Modal window:
$('a[rel*=modal]').facebox(); // Applies modal window to any link with attribute rel="modal"
// Initialise jQuery WYSIWYG:
$(".wysiwyg").wysiwyg(); // Applies WYSIWYG editor to any textarea with the class "wysiwyg"
});
| JavaScript |
/**
* WYSIWYG - jQuery plugin 0.5
*
* Copyright (c) 2008-2009 Juan M Martinez
* http://plugins.jquery.com/project/jWYSIWYG
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* $Id: $
*/
(function( $ )
{
$.fn.document = function()
{
var element = this[0];
if ( element.nodeName.toLowerCase() == 'iframe' )
return element.contentWindow.document;
/*
return ( $.browser.msie )
? document.frames[element.id].document
: element.contentWindow.document // contentDocument;
*/
else
return $(this);
};
$.fn.documentSelection = function()
{
var element = this[0];
if ( element.contentWindow.document.selection )
return element.contentWindow.document.selection.createRange().text;
else
return element.contentWindow.getSelection().toString();
};
$.fn.wysiwyg = function( options )
{
if ( arguments.length > 0 && arguments[0].constructor == String )
{
var action = arguments[0].toString();
var params = [];
for ( var i = 1; i < arguments.length; i++ )
params[i - 1] = arguments[i];
if ( action in Wysiwyg )
{
return this.each(function()
{
$.data(this, 'wysiwyg')
.designMode();
Wysiwyg[action].apply(this, params);
});
}
else return this;
}
var controls = {};
/**
* If the user set custom controls, we catch it, and merge with the
* defaults controls later.
*/
if ( options && options.controls )
{
var controls = options.controls;
delete options.controls;
}
var options = $.extend({
html : '<'+'?xml version="1.0" encoding="UTF-8"?'+'><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">STYLE_SHEET</head><body style="font-family: Arial, Helvetica, sans-serif !important; font-size: 13px; height: 100%; line-height: 1.5em !important;">INITIAL_CONTENT</body></html>',
css : {},
debug : false,
autoSave : true, // http://code.google.com/p/jwysiwyg/issues/detail?id=11
rmUnwantedBr : true, // http://code.google.com/p/jwysiwyg/issues/detail?id=15
brIE : true,
controls : {},
messages : {}
}, options);
options.messages = $.extend(true, options.messages, Wysiwyg.MSGS_EN);
options.controls = $.extend(true, options.controls, Wysiwyg.TOOLBAR);
for ( var control in controls )
{
if ( control in options.controls )
$.extend(options.controls[control], controls[control]);
else
options.controls[control] = controls[control];
}
// not break the chain
return this.each(function()
{
Wysiwyg(this, options);
});
};
function Wysiwyg( element, options )
{
return this instanceof Wysiwyg
? this.init(element, options)
: new Wysiwyg(element, options);
}
$.extend(Wysiwyg, {
insertImage : function( szURL, attributes )
{
var self = $.data(this, 'wysiwyg');
if ( self.constructor == Wysiwyg && szURL && szURL.length > 0 )
{
if ( attributes )
{
self.editorDoc.execCommand('insertImage', false, '#jwysiwyg#');
var img = self.getElementByAttributeValue('img', 'src', '#jwysiwyg#');
if ( img )
{
img.src = szURL;
for ( var attribute in attributes )
{
img.setAttribute(attribute, attributes[attribute]);
}
}
}
else
{
self.editorDoc.execCommand('insertImage', false, szURL);
}
}
},
createLink : function( szURL )
{
var self = $.data(this, 'wysiwyg');
if ( self.constructor == Wysiwyg && szURL && szURL.length > 0 )
{
var selection = $(self.editor).documentSelection();
if ( selection.length > 0 )
{
self.editorDoc.execCommand('unlink', false, []);
self.editorDoc.execCommand('createLink', false, szURL);
}
else if ( self.options.messages.nonSelection )
alert(self.options.messages.nonSelection);
}
},
setContent : function( newContent )
{
var self = $.data(this, 'wysiwyg');
self.setContent( newContent );
self.saveContent();
},
clear : function()
{
var self = $.data(this, 'wysiwyg');
self.setContent('');
self.saveContent();
},
MSGS_EN : {
nonSelection : 'select the text you wish to link'
},
TOOLBAR : {
bold : { visible : true, tags : ['b', 'strong'], css : { fontWeight : 'bold' } },
italic : { visible : true, tags : ['i', 'em'], css : { fontStyle : 'italic' } },
strikeThrough : { visible : false, tags : ['s', 'strike'], css : { textDecoration : 'line-through' } },
underline : { visible : false, tags : ['u'], css : { textDecoration : 'underline' } },
separator00 : { visible : false, separator : true },
justifyLeft : { visible : false, css : { textAlign : 'left' } },
justifyCenter : { visible : false, tags : ['center'], css : { textAlign : 'center' } },
justifyRight : { visible : false, css : { textAlign : 'right' } },
justifyFull : { visible : false, css : { textAlign : 'justify' } },
separator01 : { visible : false, separator : true },
indent : { visible : false },
outdent : { visible : false },
separator02 : { visible : false, separator : true },
subscript : { visible : false, tags : ['sub'] },
superscript : { visible : false, tags : ['sup'] },
separator03 : { visible : false, separator : true },
undo : { visible : false },
redo : { visible : false },
separator04 : { visible : false, separator : true },
insertOrderedList : { visible : false, tags : ['ol'] },
insertUnorderedList : { visible : false, tags : ['ul'] },
insertHorizontalRule : { visible : false, tags : ['hr'] },
separator05 : { separator : true },
createLink : {
visible : true,
exec : function()
{
var selection = $(this.editor).documentSelection();
if ( selection.length > 0 )
{
if ( $.browser.msie )
this.editorDoc.execCommand('createLink', true, null);
else
{
var szURL = prompt('URL', 'http://');
if ( szURL && szURL.length > 0 )
{
this.editorDoc.execCommand('unlink', false, []);
this.editorDoc.execCommand('createLink', false, szURL);
}
}
}
else if ( this.options.messages.nonSelection )
alert(this.options.messages.nonSelection);
},
tags : ['a']
},
insertImage : {
visible : true,
exec : function()
{
if ( $.browser.msie )
this.editorDoc.execCommand('insertImage', true, null);
else
{
var szURL = prompt('URL', 'http://');
if ( szURL && szURL.length > 0 )
this.editorDoc.execCommand('insertImage', false, szURL);
}
},
tags : ['img']
},
separator06 : { separator : true },
h1mozilla : { visible : true && $.browser.mozilla, className : 'h1', command : 'heading', arguments : ['h1'], tags : ['h1'] },
h2mozilla : { visible : true && $.browser.mozilla, className : 'h2', command : 'heading', arguments : ['h2'], tags : ['h2'] },
h3mozilla : { visible : true && $.browser.mozilla, className : 'h3', command : 'heading', arguments : ['h3'], tags : ['h3'] },
h1 : { visible : true && !( $.browser.mozilla ), className : 'h1', command : 'formatBlock', arguments : ['Heading 1'], tags : ['h1'] },
h2 : { visible : true && !( $.browser.mozilla ), className : 'h2', command : 'formatBlock', arguments : ['Heading 2'], tags : ['h2'] },
h3 : { visible : true && !( $.browser.mozilla ), className : 'h3', command : 'formatBlock', arguments : ['Heading 3'], tags : ['h3'] },
separator07 : { visible : false, separator : true },
cut : { visible : false },
copy : { visible : false },
paste : { visible : false },
separator08 : { separator : true && !( $.browser.msie ) },
increaseFontSize : { visible : true && !( $.browser.msie ), tags : ['big'] },
decreaseFontSize : { visible : true && !( $.browser.msie ), tags : ['small'] },
separator09 : { separator : true },
html : {
visible : false,
exec : function()
{
if ( this.viewHTML )
{
this.setContent( $(this.original).val() );
$(this.original).hide();
}
else
{
this.saveContent();
$(this.original).show();
}
this.viewHTML = !( this.viewHTML );
}
},
removeFormat : {
visible : true,
exec : function()
{
this.editorDoc.execCommand('removeFormat', false, []);
this.editorDoc.execCommand('unlink', false, []);
}
}
}
});
$.extend(Wysiwyg.prototype,
{
original : null,
options : {},
element : null,
editor : null,
init : function( element, options )
{
var self = this;
this.editor = element;
this.options = options || {};
$.data(element, 'wysiwyg', this);
var newX = element.width || element.clientWidth;
var newY = element.height || element.clientHeight;
if ( element.nodeName.toLowerCase() == 'textarea' )
{
this.original = element;
if ( newX == 0 && element.cols )
newX = ( element.cols * 8 ) + 21;
if ( newY == 0 && element.rows )
newY = ( element.rows * 16 ) + 16;
var editor = this.editor = $('<iframe></iframe>').css({
minHeight : ( newY - 6 ).toString() + 'px',
width : ( newX - 8 ).toString() + 'px'
}).attr('id', $(element).attr('id') + 'IFrame');
if ( $.browser.msie )
{
this.editor
.css('height', ( newY ).toString() + 'px');
/**
var editor = $('<span></span>').css({
width : ( newX - 6 ).toString() + 'px',
height : ( newY - 8 ).toString() + 'px'
}).attr('id', $(element).attr('id') + 'IFrame');
editor.outerHTML = this.editor.outerHTML;
*/
}
}
var panel = this.panel = $('<ul></ul>').addClass('panel');
this.appendControls();
this.element = $('<div></div>').css({
width : ( newX > 0 ) ? ( newX ).toString() + 'px' : '100%'
}).addClass('wysiwyg')
.append(panel)
.append( $('<div><!-- --></div>').css({ clear : 'both' }) )
.append(editor);
$(element)
// .css('display', 'none')
.hide()
.before(this.element);
this.viewHTML = false;
this.initialHeight = newY - 8;
/**
* @link http://code.google.com/p/jwysiwyg/issues/detail?id=52
*/
this.initialContent = $(element).val();
this.initFrame();
if ( this.initialContent.length == 0 )
this.setContent('');
if ( this.options.autoSave )
$('form').submit(function() { self.saveContent(); });
$('form').bind('reset', function()
{
self.setContent( self.initialContent );
self.saveContent();
});
},
initFrame : function()
{
var self = this;
var style = '';
/**
* @link http://code.google.com/p/jwysiwyg/issues/detail?id=14
*/
if ( this.options.css && this.options.css.constructor == String )
style = '<link rel="stylesheet" type="text/css" media="screen" href="' + this.options.css + '" />';
this.editorDoc = $(this.editor).document();
this.editorDoc_designMode = false;
try {
this.editorDoc.designMode = 'on';
this.editorDoc_designMode = true;
} catch ( e ) {
// Will fail on Gecko if the editor is placed in an hidden container element
// The design mode will be set ones the editor is focused
$(this.editorDoc).focus(function()
{
self.designMode();
});
}
this.editorDoc.open();
this.editorDoc.write(
this.options.html
.replace(/INITIAL_CONTENT/, this.initialContent)
.replace(/STYLE_SHEET/, style)
);
this.editorDoc.close();
this.editorDoc.contentEditable = 'true';
if ( $.browser.msie )
{
/**
* Remove the horrible border it has on IE.
*/
setTimeout(function() { $(self.editorDoc.body).css('border', 'none'); }, 0);
}
$(this.editorDoc).click(function( event )
{
self.checkTargets( event.target ? event.target : event.srcElement);
});
/**
* @link http://code.google.com/p/jwysiwyg/issues/detail?id=20
*/
$(this.original).focus(function()
{
$(self.editorDoc.body).focus();
});
if ( this.options.autoSave )
{
/**
* @link http://code.google.com/p/jwysiwyg/issues/detail?id=11
*/
$(this.editorDoc).keydown(function() { self.saveContent(); })
.keyup(function() { self.saveContent(); })
.mousedown(function() { self.saveContent(); });
}
if ( this.options.css )
{
setTimeout(function()
{
if ( self.options.css.constructor == String )
{
/**
* $(self.editorDoc)
* .find('head')
* .append(
* $('<link rel="stylesheet" type="text/css" media="screen" />')
* .attr('href', self.options.css)
* );
*/
}
else
$(self.editorDoc).find('body').css(self.options.css);
}, 0);
}
$(this.editorDoc).keydown(function( event )
{
if ( $.browser.msie && self.options.brIE && event.keyCode == 13 )
{
var rng = self.getRange();
rng.pasteHTML('<br />');
rng.collapse(false);
rng.select();
return false;
}
});
},
designMode : function()
{
if ( !( this.editorDoc_designMode ) )
{
try {
this.editorDoc.designMode = 'on';
this.editorDoc_designMode = true;
} catch ( e ) {}
}
},
getSelection : function()
{
return ( window.getSelection ) ? window.getSelection() : document.selection;
},
getRange : function()
{
var selection = this.getSelection();
if ( !( selection ) )
return null;
return ( selection.rangeCount > 0 ) ? selection.getRangeAt(0) : selection.createRange();
},
getContent : function()
{
return $( $(this.editor).document() ).find('body').html();
},
setContent : function( newContent )
{
$( $(this.editor).document() ).find('body').html(newContent);
},
saveContent : function()
{
if ( this.original )
{
var content = this.getContent();
if ( this.options.rmUnwantedBr )
content = ( content.substr(-4) == '<br>' ) ? content.substr(0, content.length - 4) : content;
$(this.original).val(content);
}
},
appendMenu : function( cmd, args, className, fn )
{
var self = this;
var args = args || [];
$('<li></li>').append(
$('<a><!-- --></a>').addClass(className || cmd)
).mousedown(function() {
if ( fn ) fn.apply(self); else self.editorDoc.execCommand(cmd, false, args);
if ( self.options.autoSave ) self.saveContent();
}).appendTo( this.panel );
},
appendMenuSeparator : function()
{
$('<li class="separator"></li>').appendTo( this.panel );
},
appendControls : function()
{
for ( var name in this.options.controls )
{
var control = this.options.controls[name];
if ( control.separator )
{
if ( control.visible !== false )
this.appendMenuSeparator();
}
else if ( control.visible )
{
this.appendMenu(
control.command || name, control.arguments || [],
control.className || control.command || name || 'empty', control.exec
);
}
}
},
checkTargets : function( element )
{
for ( var name in this.options.controls )
{
var control = this.options.controls[name];
var className = control.className || control.command || name || 'empty';
$('.' + className, this.panel).removeClass('active');
if ( control.tags )
{
var elm = element;
do {
if ( elm.nodeType != 1 )
break;
if ( $.inArray(elm.tagName.toLowerCase(), control.tags) != -1 )
$('.' + className, this.panel).addClass('active');
} while ( elm = elm.parentNode );
}
if ( control.css )
{
var elm = $(element);
do {
if ( elm[0].nodeType != 1 )
break;
for ( var cssProperty in control.css )
if ( elm.css(cssProperty).toString().toLowerCase() == control.css[cssProperty] )
$('.' + className, this.panel).addClass('active');
} while ( elm = elm.parent() );
}
}
},
getElementByAttributeValue : function( tagName, attributeName, attributeValue )
{
var elements = this.editorDoc.getElementsByTagName(tagName);
for ( var i = 0; i < elements.length; i++ )
{
var value = elements[i].getAttribute(attributeName);
if ( $.browser.msie )
{
/** IE add full path, so I check by the last chars. */
value = value.substr(value.length - attributeValue.length);
}
if ( value == attributeValue )
return elements[i];
}
return false;
}
});
})(jQuery); | JavaScript |
/*
* Facebox (for jQuery)
* version: 1.2 (05/05/2008)
* @requires jQuery v1.2 or later
*
* Examples at http://famspam.com/facebox/
*
* Licensed under the MIT:
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ]
*
* Usage:
*
* jQuery(document).ready(function() {
* jQuery('a[rel*=facebox]').facebox()
* })
*
* <a href="#terms" rel="facebox">Terms</a>
* Loads the #terms div in the box
*
* <a href="terms.html" rel="facebox">Terms</a>
* Loads the terms.html page in the box
*
* <a href="terms.png" rel="facebox">Terms</a>
* Loads the terms.png image in the box
*
*
* You can also use it programmatically:
*
* jQuery.facebox('some html')
*
* The above will open a facebox with "some html" as the content.
*
* jQuery.facebox(function($) {
* $.get('blah.html', function(data) { $.facebox(data) })
* })
*
* The above will show a loading screen before the passed function is called,
* allowing for a better ajaxy experience.
*
* The facebox function can also display an ajax page or image:
*
* jQuery.facebox({ ajax: 'remote.html' })
* jQuery.facebox({ image: 'dude.jpg' })
*
* Want to close the facebox? Trigger the 'close.facebox' document event:
*
* jQuery(document).trigger('close.facebox')
*
* Facebox also has a bunch of other hooks:
*
* loading.facebox
* beforeReveal.facebox
* reveal.facebox (aliased as 'afterReveal.facebox')
* init.facebox
*
* Simply bind a function to any of these hooks:
*
* $(document).bind('reveal.facebox', function() { ...stuff to do after the facebox and contents are revealed... })
*
*/
(function($) {
$.facebox = function(data, klass) {
$.facebox.loading()
if (data.ajax) fillFaceboxFromAjax(data.ajax)
else if (data.image) fillFaceboxFromImage(data.image)
else if (data.div) fillFaceboxFromHref(data.div)
else if ($.isFunction(data)) data.call($)
else $.facebox.reveal(data, klass)
}
/*
* Public, $.facebox methods
*/
$.extend($.facebox, {
settings: {
opacity : 0,
overlay : true,
loadingImage : '../../../resources/images/loading.gif',
closeImage : '../../../resources/images/icons/cross.png',
imageTypes : [ 'png', 'jpg', 'jpeg', 'gif' ],
faceboxHtml : '\
<div id="facebox" style="display:none;"> \
<div class="popup"> \
<table> \
<tbody> \
<tr> \
<td class="tl"/><td class="b"/><td class="tr"/> \
</tr> \
<tr> \
<td class="b"/> \
<td class="body"> \
<div class="content"> \
</div> \
<div class="footer"> \
<a href="#" class="close"> \
<img src="../../../resources/images/icons/cross.png" title="close" class="close_image" /> \
</a> \
</div> \
</td> \
<td class="b"/> \
</tr> \
<tr> \
<td class="bl"/><td class="b"/><td class="br"/> \
</tr> \
</tbody> \
</table> \
</div> \
</div>'
},
loading: function() {
init()
if ($('#facebox .loading').length == 1) return true
showOverlay()
$('#facebox .content').empty()
$('#facebox .body').children().hide().end().
append('<div class="loading"><img src="'+$.facebox.settings.loadingImage+'"/></div>')
$('#facebox').css({
top: getPageScroll()[1] + (getPageHeight() / 10),
left: 385.5
}).show()
$(document).bind('keydown.facebox', function(e) {
if (e.keyCode == 27) $.facebox.close()
return true
})
$(document).trigger('loading.facebox')
},
reveal: function(data, klass) {
$(document).trigger('beforeReveal.facebox')
if (klass) $('#facebox .content').addClass(klass)
$('#facebox .content').append(data)
$('#facebox .loading').remove()
$('#facebox .body').children().fadeIn('normal')
$('#facebox').css('left', $(window).width() / 2 - ($('#facebox table').width() / 2))
$(document).trigger('reveal.facebox').trigger('afterReveal.facebox')
},
close: function() {
$(document).trigger('close.facebox')
return false
}
})
/*
* Public, $.fn methods
*/
$.fn.facebox = function(settings) {
init(settings)
function clickHandler() {
$.facebox.loading(true)
// support for rel="facebox.inline_popup" syntax, to add a class
// also supports deprecated "facebox[.inline_popup]" syntax
var klass = this.rel.match(/facebox\[?\.(\w+)\]?/)
if (klass) klass = klass[1]
fillFaceboxFromHref(this.href, klass)
return false
}
return this.click(clickHandler)
}
/*
* Private methods
*/
// called one time to setup facebox on this page
function init(settings) {
if ($.facebox.settings.inited) return true
else $.facebox.settings.inited = true
$(document).trigger('init.facebox')
makeCompatible()
var imageTypes = $.facebox.settings.imageTypes.join('|')
$.facebox.settings.imageTypesRegexp = new RegExp('\.' + imageTypes + '$', 'i')
if (settings) $.extend($.facebox.settings, settings)
$('body').append($.facebox.settings.faceboxHtml)
var preload = [ new Image(), new Image() ]
preload[0].src = $.facebox.settings.closeImage
preload[1].src = $.facebox.settings.loadingImage
$('#facebox').find('.b:first, .bl, .br, .tl, .tr').each(function() {
preload.push(new Image())
preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1')
})
$('#facebox .close').click($.facebox.close)
$('#facebox .close_image').attr('src', $.facebox.settings.closeImage)
}
// getPageScroll() by quirksmode.com
function getPageScroll() {
var xScroll, yScroll;
if (self.pageYOffset) {
yScroll = self.pageYOffset;
xScroll = self.pageXOffset;
} else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
yScroll = document.documentElement.scrollTop;
xScroll = document.documentElement.scrollLeft;
} else if (document.body) {// all other Explorers
yScroll = document.body.scrollTop;
xScroll = document.body.scrollLeft;
}
return new Array(xScroll,yScroll)
}
// Adapted from getPageSize() by quirksmode.com
function getPageHeight() {
var windowHeight
if (self.innerHeight) { // all except Explorer
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowHeight = document.body.clientHeight;
}
return windowHeight
}
// Backwards compatibility
function makeCompatible() {
var $s = $.facebox.settings
$s.loadingImage = $s.loading_image || $s.loadingImage
$s.closeImage = $s.close_image || $s.closeImage
$s.imageTypes = $s.image_types || $s.imageTypes
$s.faceboxHtml = $s.facebox_html || $s.faceboxHtml
}
// Figures out what you want to display and displays it
// formats are:
// div: #id
// image: blah.extension
// ajax: anything else
function fillFaceboxFromHref(href, klass) {
// div
if (href.match(/#/)) {
var url = window.location.href.split('#')[0]
var target = href.replace(url,'')
$.facebox.reveal($(target).clone().show(), klass)
// image
} else if (href.match($.facebox.settings.imageTypesRegexp)) {
fillFaceboxFromImage(href, klass)
// ajax
} else {
fillFaceboxFromAjax(href, klass)
}
}
function fillFaceboxFromImage(href, klass) {
var image = new Image()
image.onload = function() {
$.facebox.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass)
}
image.src = href
}
function fillFaceboxFromAjax(href, klass) {
$.get(href, function(data) { $.facebox.reveal(data, klass) })
}
function skipOverlay() {
return $.facebox.settings.overlay == false || $.facebox.settings.opacity === null
}
function showOverlay() {
if (skipOverlay()) return
if ($('facebox_overlay').length == 0)
$("body").append('<div id="facebox_overlay" class="facebox_hide"></div>')
$('#facebox_overlay').hide().addClass("facebox_overlayBG")
.css('opacity', $.facebox.settings.opacity)
.click(function() { $(document).trigger('close.facebox') })
.fadeIn(200)
return false
}
function hideOverlay() {
if (skipOverlay()) return
$('#facebox_overlay').fadeOut(200, function(){
$("#facebox_overlay").removeClass("facebox_overlayBG")
$("#facebox_overlay").addClass("facebox_hide")
$("#facebox_overlay").remove()
})
return false
}
/*
* Bindings
*/
$(document).bind('close.facebox', function() {
$(document).unbind('keydown.facebox')
$('#facebox').fadeOut(function() {
$('#facebox .content').removeClass().addClass('content')
hideOverlay()
$('#facebox .loading').remove()
})
})
})(jQuery);
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.lang({
source : 'Source',
preview : 'Preview',
undo : 'Undo(Ctrl+Z)',
redo : 'Redo(Ctrl+Y)',
cut : 'Cut(Ctrl+X)',
copy : 'Copy(Ctrl+C)',
paste : 'Paste(Ctrl+V)',
plainpaste : 'Paste as plain text',
wordpaste : 'Paste from Word',
selectall : 'Select all',
justifyleft : 'Align left',
justifycenter : 'Align center',
justifyright : 'Align right',
justifyfull : 'Align full',
insertorderedlist : 'Ordered list',
insertunorderedlist : 'Unordered list',
indent : 'Increase indent',
outdent : 'Decrease indent',
subscript : 'Subscript',
superscript : 'Superscript',
formatblock : 'Paragraph format',
fontname : 'Font family',
fontsize : 'Font size',
forecolor : 'Text color',
hilitecolor : 'Highlight color',
bold : 'Bold(Ctrl+B)',
italic : 'Italic(Ctrl+I)',
underline : 'Underline(Ctrl+U)',
strikethrough : 'Strikethrough',
removeformat : 'Remove format',
image : 'Image',
flash : 'Flash',
media : 'Embeded media',
table : 'Table',
tablecell : 'Cell',
hr : 'Insert horizontal line',
emoticons : 'Insert emoticon',
link : 'Link',
unlink : 'Unlink',
fullscreen : 'Toggle fullscreen mode(Esc)',
about : 'About',
print : 'Print',
filemanager : 'File Manager',
code : 'Insert code',
map : 'Google Maps',
lineheight : 'Line height',
clearhtml : 'Clear HTML code',
pagebreak : 'Insert Page Break',
quickformat : 'Quick Format',
insertfile : 'Insert file',
template : 'Insert Template',
anchor : 'Anchor',
yes : 'OK',
no : 'Cancel',
close : 'Close',
editImage : 'Image properties',
deleteImage : 'Delete image',
editFlash : 'Flash properties',
deleteFlash : 'Delete flash',
editMedia : 'Media properties',
deleteMedia : 'Delete media',
editLink : 'Link properties',
deleteLink : 'Unlink',
tableprop : 'Table properties',
tablecellprop : 'Cell properties',
tableinsert : 'Insert table',
tabledelete : 'Delete table',
tablecolinsertleft : 'Insert column left',
tablecolinsertright : 'Insert column right',
tablerowinsertabove : 'Insert row above',
tablerowinsertbelow : 'Insert row below',
tablerowmerge : 'Merge down',
tablecolmerge : 'Merge right',
tablerowsplit : 'Split row',
tablecolsplit : 'Split column',
tablecoldelete : 'Delete column',
tablerowdelete : 'Delete row',
noColor : 'Default',
invalidImg : "Please type valid URL.\nAllowed file extension: jpg,gif,bmp,png",
invalidMedia : "Please type valid URL.\nAllowed file extension: swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb",
invalidWidth : "The width must be number.",
invalidHeight : "The height must be number.",
invalidBorder : "The border must be number.",
invalidUrl : "Please type valid URL.",
invalidRows : 'Invalid rows.',
invalidCols : 'Invalid columns.',
invalidPadding : 'The padding must be number.',
invalidSpacing : 'The spacing must be number.',
invalidJson : 'Invalid JSON string.',
uploadSuccess : 'Upload success.',
cutError : 'Currently not supported by your browser, use keyboard shortcut(Ctrl+X) instead.',
copyError : 'Currently not supported by your browser, use keyboard shortcut(Ctrl+C) instead.',
pasteError : 'Currently not supported by your browser, use keyboard shortcut(Ctrl+V) instead.',
'plainpaste.comment' : 'Use keyboard shortcut(Ctrl+V) to paste the text into the window.',
'wordpaste.comment' : 'Use keyboard shortcut(Ctrl+V) to paste the text into the window.',
'link.url' : 'URL',
'link.linkType' : 'Target',
'link.newWindow' : 'New window',
'link.selfWindow' : 'Same window',
'flash.url' : 'URL',
'flash.width' : 'Width',
'flash.height' : 'Height',
'flash.upload' : 'Upload',
'flash.viewServer' : 'Browse',
'media.url' : 'URL',
'media.width' : 'Width',
'media.height' : 'Height',
'media.autostart' : 'Auto start',
'media.upload' : 'Upload',
'media.viewServer' : 'Browse',
'image.remoteImage' : 'Insert URL',
'image.localImage' : 'Upload',
'image.remoteUrl' : 'URL',
'image.localUrl' : 'File',
'image.size' : 'Size',
'image.width' : 'Width',
'image.height' : 'Height',
'image.resetSize' : 'Reset dimensions',
'image.align' : 'Align',
'image.defaultAlign' : 'Default',
'image.leftAlign' : 'Left',
'image.rightAlign' : 'Right',
'image.imgTitle' : 'Title',
'image.viewServer' : 'Browse',
'filemanager.emptyFolder' : 'Blank',
'filemanager.moveup' : 'Parent folder',
'filemanager.viewType' : 'Display: ',
'filemanager.viewImage' : 'Thumbnails',
'filemanager.listImage' : 'List',
'filemanager.orderType' : 'Sorting: ',
'filemanager.fileName' : 'By name',
'filemanager.fileSize' : 'By size',
'filemanager.fileType' : 'By type',
'insertfile.url' : 'URL',
'insertfile.title' : 'Title',
'insertfile.upload' : 'Upload',
'insertfile.viewServer' : 'Browse',
'table.cells' : 'Cells',
'table.rows' : 'Rows',
'table.cols' : 'Columns',
'table.size' : 'Dimensions',
'table.width' : 'Width',
'table.height' : 'Height',
'table.percent' : '%',
'table.px' : 'px',
'table.space' : 'Space',
'table.padding' : 'Padding',
'table.spacing' : 'Spacing',
'table.align' : 'Align',
'table.textAlign' : 'Horizontal',
'table.verticalAlign' : 'Vertical',
'table.alignDefault' : 'Default',
'table.alignLeft' : 'Left',
'table.alignCenter' : 'Center',
'table.alignRight' : 'Right',
'table.alignTop' : 'Top',
'table.alignMiddle' : 'Middle',
'table.alignBottom' : 'Bottom',
'table.alignBaseline' : 'Baseline',
'table.border' : 'Border',
'table.borderWidth' : 'Width',
'table.borderColor' : 'Color',
'table.backgroundColor' : 'Background',
'map.address' : 'Address: ',
'map.search' : 'Search',
'anchor.name' : 'Anchor name',
'formatblock.formatBlock' : {
h1 : 'Heading 1',
h2 : 'Heading 2',
h3 : 'Heading 3',
h4 : 'Heading 4',
p : 'Normal'
},
'fontname.fontName' : {
'Arial' : 'Arial',
'Arial Black' : 'Arial Black',
'Comic Sans MS' : 'Comic Sans MS',
'Courier New' : 'Courier New',
'Garamond' : 'Garamond',
'Georgia' : 'Georgia',
'Tahoma' : 'Tahoma',
'Times New Roman' : 'Times New Roman',
'Trebuchet MS' : 'Trebuchet MS',
'Verdana' : 'Verdana'
},
'lineheight.lineHeight' : [
{'1' : 'Line height 1'},
{'1.5' : 'Line height 1.5'},
{'2' : 'Line height 2'},
{'2.5' : 'Line height 2.5'},
{'3' : 'Line height 3'}
],
'template.selectTemplate' : 'Template',
'template.replaceContent' : 'Replace current content',
'template.fileList' : {
'1.html' : 'Image and Text',
'2.html' : 'Table',
'3.html' : 'List'
}
}, 'en');
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.lang({
source : '原始碼',
preview : '預覽',
undo : '復原(Ctrl+Z)',
redo : '重複(Ctrl+Y)',
cut : '剪下(Ctrl+X)',
copy : '複製(Ctrl+C)',
paste : '貼上(Ctrl+V)',
plainpaste : '貼為純文字格式',
wordpaste : '自Word貼上',
selectall : '全選(Ctrl+A)',
justifyleft : '靠左對齊',
justifycenter : '置中',
justifyright : '靠右對齊',
justifyfull : '左右對齊',
insertorderedlist : '編號清單',
insertunorderedlist : '項目清單',
indent : '增加縮排',
outdent : '減少縮排',
subscript : '下標',
superscript : '上標',
formatblock : '標題',
fontname : '字體',
fontsize : '文字大小',
forecolor : '文字顏色',
hilitecolor : '背景顏色',
bold : '粗體(Ctrl+B)',
italic : '斜體(Ctrl+I)',
underline : '底線(Ctrl+U)',
strikethrough : '刪除線',
removeformat : '清除格式',
image : '影像',
flash : 'Flash',
media : '多媒體',
table : '表格',
hr : '插入水平線',
emoticons : '插入表情',
link : '超連結',
unlink : '移除超連結',
fullscreen : '最大化',
about : '關於',
print : '列印(Ctrl+P)',
fileManager : '瀏覽伺服器',
code : '插入程式代碼',
map : 'Google地圖',
lineheight : '行距',
clearhtml : '清理HTML代碼',
pagebreak : '插入分頁符號',
quickformat : '快速排版',
insertfile : '插入文件',
template : '插入樣板',
anchor : '錨點',
yes : '確定',
no : '取消',
close : '關閉',
editImage : '影像屬性',
deleteImage : '刪除影像',
editFlash : 'Flash屬性',
deleteFlash : '删除Flash',
editMedia : '多媒體屬性',
deleteMedia : '删除多媒體',
editLink : '超連結屬性',
deleteLink : '移除超連結',
tableprop : '表格屬性',
tablecellprop : '儲存格屬性',
tableinsert : '插入表格',
tabledelete : '刪除表格',
tablecolinsertleft : '向左插入列',
tablecolinsertright : '向右插入列',
tablerowinsertabove : '向上插入欄',
tablerowinsertbelow : '下方插入欄',
tablerowmerge : '向下合併單元格',
tablecolmerge : '向右合併單元格',
tablerowsplit : '分割欄',
tablecolsplit : '分割列',
tablecoldelete : '删除列',
tablerowdelete : '删除欄',
noColor : '自動',
invalidImg : "請輸入有效的URL。\n只允許jpg,gif,bmp,png格式。",
invalidMedia : "請輸入有效的URL。\n只允許swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb格式。",
invalidWidth : "寬度必須是數字。",
invalidHeight : "高度必須是數字。",
invalidBorder : "邊框必須是數字。",
invalidUrl : "請輸入有效的URL。",
invalidRows : '欄數是必須輸入項目,只允許輸入大於0的數字。',
invalidCols : '列數是必須輸入項目,只允許輸入大於0的數字。',
invalidPadding : '內距必須是數字。',
invalidSpacing : '間距必須是數字。',
invalidBorder : '边框必须为数字。',
pleaseInput : "請輸入內容。",
invalidJson : '伺服器發生故障。',
cutError : '您的瀏覽器安全設置不允許使用剪下操作,請使用快捷鍵(Ctrl+X)完成。',
copyError : '您的瀏覽器安全設置不允許使用剪下操作,請使用快捷鍵(Ctrl+C)完成。',
pasteError : '您的瀏覽器安全設置不允許使用剪下操作,請使用快捷鍵(Ctrl+V)完成。',
'plainpaste.comment' : '請使用快捷鍵(Ctrl+V)把內容貼到下方區域裡。',
'wordpaste.comment' : '請使用快捷鍵(Ctrl+V)把內容貼到下方區域裡。',
'link.url' : 'URL',
'link.linkType' : '打開類型',
'link.newWindow' : '新窗口',
'link.selfWindow' : '本頁窗口',
'flash.url' : 'URL',
'flash.width' : '寬度',
'flash.height' : '高度',
'flash.upload' : '上傳',
'flash.viewServer' : '瀏覽',
'media.url' : 'URL',
'media.width' : '寬度',
'media.height' : '高度',
'media.autostart' : '自動播放',
'media.upload' : '上傳',
'media.viewServer' : '瀏覽',
'image.remoteImage' : '影像URL',
'image.localImage' : '上傳影像',
'image.remoteUrl' : '影像URL',
'image.localUrl' : '影像URL',
'image.size' : '影像大小',
'image.width' : '寬度',
'image.height' : '高度',
'image.resetSize' : '原始大小',
'image.align' : '對齊方式',
'image.defaultAlign' : '未設定',
'image.leftAlign' : '向左對齊',
'image.rightAlign' : '向右對齊',
'image.imgTitle' : '影像說明',
'image.viewServer' : '瀏覽...',
'filemanager.emptyFolder' : '空文件夾',
'filemanager.moveup' : '至上一級文件夾',
'filemanager.viewType' : '顯示方式:',
'filemanager.viewImage' : '縮略圖',
'filemanager.listImage' : '詳細信息',
'filemanager.orderType' : '排序方式:',
'filemanager.fileName' : '名稱',
'filemanager.fileSize' : '大小',
'filemanager.fileType' : '類型',
'insertfile.url' : 'URL',
'insertfile.title' : '文件說明',
'insertfile.upload' : '上傳',
'insertfile.viewServer' : '瀏覽',
'table.cells' : '儲存格數',
'table.rows' : '欄數',
'table.cols' : '列數',
'table.size' : '表格大小',
'table.width' : '寬度',
'table.height' : '高度',
'table.percent' : '%',
'table.px' : 'px',
'table.space' : '內距間距',
'table.padding' : '內距',
'table.spacing' : '間距',
'table.align' : '對齊方式',
'table.textAlign' : '水平對齊',
'table.verticalAlign' : '垂直對齊',
'table.alignDefault' : '未設定',
'table.alignLeft' : '向左對齊',
'table.alignCenter' : '置中',
'table.alignRight' : '向右對齊',
'table.alignTop' : '靠上',
'table.alignMiddle' : '置中',
'table.alignBottom' : '靠下',
'table.alignBaseline' : '基線',
'table.border' : '表格邊框',
'table.borderWidth' : '邊框',
'table.borderColor' : '顏色',
'table.backgroundColor' : '背景顏色',
'map.address' : '住所: ',
'map.search' : '尋找',
'anchor.name' : '錨點名稱',
'formatblock.formatBlock' : {
h1 : '標題 1',
h2 : '標題 2',
h3 : '標題 3',
h4 : '標題 4',
p : '一般'
},
'fontname.fontName' : {
'MingLiU' : '細明體',
'PMingLiU' : '新細明體',
'DFKai-SB' : '標楷體',
'SimSun' : '宋體',
'NSimSun' : '新宋體',
'FangSong' : '仿宋體',
'Arial' : 'Arial',
'Arial Black' : 'Arial Black',
'Times New Roman' : 'Times New Roman',
'Courier New' : 'Courier New',
'Tahoma' : 'Tahoma',
'Verdana' : 'Verdana'
},
'lineheight.lineHeight' : [
{'1' : '单倍行距'},
{'1.5' : '1.5倍行距'},
{'2' : '2倍行距'},
{'2.5' : '2.5倍行距'},
{'3' : '3倍行距'}
],
'template.selectTemplate' : '可選樣板',
'template.replaceContent' : '取代當前內容',
'template.fileList' : {
'1.html' : '影像和文字',
'2.html' : '表格',
'3.html' : '项目清單'
}
}, 'zh_TW');
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.lang({
source : 'HTML代码',
preview : '预览',
undo : '后退(Ctrl+Z)',
redo : '前进(Ctrl+Y)',
cut : '剪切(Ctrl+X)',
copy : '复制(Ctrl+C)',
paste : '粘贴(Ctrl+V)',
plainpaste : '粘贴为无格式文本',
wordpaste : '从Word粘贴',
selectall : '全选(Ctrl+A)',
justifyleft : '左对齐',
justifycenter : '居中',
justifyright : '右对齐',
justifyfull : '两端对齐',
insertorderedlist : '编号',
insertunorderedlist : '项目符号',
indent : '增加缩进',
outdent : '减少缩进',
subscript : '下标',
superscript : '上标',
formatblock : '段落',
fontname : '字体',
fontsize : '文字大小',
forecolor : '文字颜色',
hilitecolor : '文字背景',
bold : '粗体(Ctrl+B)',
italic : '斜体(Ctrl+I)',
underline : '下划线(Ctrl+U)',
strikethrough : '删除线',
removeformat : '删除格式',
image : '图片',
flash : 'Flash',
media : '视音频',
table : '表格',
tablecell : '单元格',
hr : '插入横线',
emoticons : '插入表情',
link : '超级链接',
unlink : '取消超级链接',
fullscreen : '全屏显示(Esc)',
about : '关于',
print : '打印(Ctrl+P)',
filemanager : '浏览服务器',
code : '插入程序代码',
map : 'Google地图',
lineheight : '行距',
clearhtml : '清理HTML代码',
pagebreak : '插入分页符',
quickformat : '一键排版',
insertfile : '插入文件',
template : '插入模板',
anchor : '锚点',
yes : '确定',
no : '取消',
close : '关闭',
editImage : '图片属性',
deleteImage : '删除图片',
editFlash : 'Flash属性',
deleteFlash : '删除Flash',
editMedia : '视音频属性',
deleteMedia : '删除视音频',
editLink : '超级链接属性',
deleteLink : '取消超级链接',
editAnchor : '锚点属性',
deleteAnchor : '删除锚点',
tableprop : '表格属性',
tablecellprop : '单元格属性',
tableinsert : '插入表格',
tabledelete : '删除表格',
tablecolinsertleft : '左侧插入列',
tablecolinsertright : '右侧插入列',
tablerowinsertabove : '上方插入行',
tablerowinsertbelow : '下方插入行',
tablerowmerge : '向下合并单元格',
tablecolmerge : '向右合并单元格',
tablerowsplit : '拆分行',
tablecolsplit : '拆分列',
tablecoldelete : '删除列',
tablerowdelete : '删除行',
noColor : '无颜色',
invalidImg : "请输入有效的URL地址。\n只允许jpg,gif,bmp,png格式。",
invalidMedia : "请输入有效的URL地址。\n只允许swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb格式。",
invalidWidth : "宽度必须为数字。",
invalidHeight : "高度必须为数字。",
invalidBorder : "边框必须为数字。",
invalidUrl : "请输入有效的URL地址。",
invalidRows : '行数为必选项,只允许输入大于0的数字。',
invalidCols : '列数为必选项,只允许输入大于0的数字。',
invalidPadding : '边距必须为数字。',
invalidSpacing : '间距必须为数字。',
invalidJson : '服务器发生故障。',
uploadSuccess : '上传成功。',
cutError : '您的浏览器安全设置不允许使用剪切操作,请使用快捷键(Ctrl+X)来完成。',
copyError : '您的浏览器安全设置不允许使用复制操作,请使用快捷键(Ctrl+C)来完成。',
pasteError : '您的浏览器安全设置不允许使用粘贴操作,请使用快捷键(Ctrl+V)来完成。',
'plainpaste.comment' : '请使用快捷键(Ctrl+V)把内容粘贴到下面的方框里。',
'wordpaste.comment' : '请使用快捷键(Ctrl+V)把内容粘贴到下面的方框里。',
'link.url' : 'URL',
'link.linkType' : '打开类型',
'link.newWindow' : '新窗口',
'link.selfWindow' : '当前窗口',
'flash.url' : 'URL',
'flash.width' : '宽度',
'flash.height' : '高度',
'flash.upload' : '上传',
'flash.viewServer' : '浏览',
'media.url' : 'URL',
'media.width' : '宽度',
'media.height' : '高度',
'media.autostart' : '自动播放',
'media.upload' : '上传',
'media.viewServer' : '浏览',
'image.remoteImage' : '远程图片',
'image.localImage' : '本地上传',
'image.remoteUrl' : '图片地址',
'image.localUrl' : '图片地址',
'image.size' : '图片大小',
'image.width' : '宽',
'image.height' : '高',
'image.resetSize' : '重置大小',
'image.align' : '对齐方式',
'image.defaultAlign' : '默认方式',
'image.leftAlign' : '左对齐',
'image.rightAlign' : '右对齐',
'image.imgTitle' : '图片说明',
'image.viewServer' : '浏览...',
'filemanager.emptyFolder' : '空文件夹',
'filemanager.moveup' : '移到上一级文件夹',
'filemanager.viewType' : '显示方式:',
'filemanager.viewImage' : '缩略图',
'filemanager.listImage' : '详细信息',
'filemanager.orderType' : '排序方式:',
'filemanager.fileName' : '名称',
'filemanager.fileSize' : '大小',
'filemanager.fileType' : '类型',
'insertfile.url' : 'URL',
'insertfile.title' : '文件说明',
'insertfile.upload' : '上传',
'insertfile.viewServer' : '浏览',
'table.cells' : '单元格数',
'table.rows' : '行数',
'table.cols' : '列数',
'table.size' : '大小',
'table.width' : '宽度',
'table.height' : '高度',
'table.percent' : '%',
'table.px' : 'px',
'table.space' : '边距间距',
'table.padding' : '边距',
'table.spacing' : '间距',
'table.align' : '对齐方式',
'table.textAlign' : '水平对齐',
'table.verticalAlign' : '垂直对齐',
'table.alignDefault' : '默认',
'table.alignLeft' : '左对齐',
'table.alignCenter' : '居中',
'table.alignRight' : '右对齐',
'table.alignTop' : '顶部',
'table.alignMiddle' : '中部',
'table.alignBottom' : '底部',
'table.alignBaseline' : '基线',
'table.border' : '边框',
'table.borderWidth' : '边框',
'table.borderColor' : '颜色',
'table.backgroundColor' : '背景颜色',
'map.address' : '地址: ',
'map.search' : '搜索',
'anchor.name' : '锚点名称',
'formatblock.formatBlock' : {
h1 : '标题 1',
h2 : '标题 2',
h3 : '标题 3',
h4 : '标题 4',
p : '正 文'
},
'fontname.fontName' : {
'SimSun' : '宋体',
'NSimSun' : '新宋体',
'FangSong_GB2312' : '仿宋_GB2312',
'KaiTi_GB2312' : '楷体_GB2312',
'SimHei' : '黑体',
'Microsoft YaHei' : '微软雅黑',
'Arial' : 'Arial',
'Arial Black' : 'Arial Black',
'Times New Roman' : 'Times New Roman',
'Courier New' : 'Courier New',
'Tahoma' : 'Tahoma',
'Verdana' : 'Verdana'
},
'lineheight.lineHeight' : [
{'1' : '单倍行距'},
{'1.5' : '1.5倍行距'},
{'2' : '2倍行距'},
{'2.5' : '2.5倍行距'},
{'3' : '3倍行距'}
],
'template.selectTemplate' : '可选模板',
'template.replaceContent' : '替换当前内容',
'template.fileList' : {
'1.html' : '图片和文字',
'2.html' : '表格',
'3.html' : '项目编号'
}
}, 'zh_CN');
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @website http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
* @version 4.0 (2011-09-26)
*******************************************************************************/
(function (window, undefined) {
if (window.KindEditor) {
return;
}
var _VERSION = '4.0 (2011-09-26)',
_ua = navigator.userAgent.toLowerCase(),
_IE = _ua.indexOf('msie') > -1 && _ua.indexOf('opera') == -1,
_GECKO = _ua.indexOf('gecko') > -1 && _ua.indexOf('khtml') == -1,
_WEBKIT = _ua.indexOf('applewebkit') > -1,
_OPERA = _ua.indexOf('opera') > -1,
_MOBILE = _ua.indexOf('mobile') > -1,
_QUIRKS = document.compatMode != 'CSS1Compat',
_matches = /(?:msie|firefox|webkit|opera)[\/:\s](\d+)/.exec(_ua),
_V = _matches ? _matches[1] : '0',
_TIME = new Date().getTime();
function _isArray(val) {
if (!val) {
return false;
}
return Object.prototype.toString.call(val) === '[object Array]';
}
function _isFunction(val) {
if (!val) {
return false;
}
return Object.prototype.toString.call(val) === '[object Function]';
}
function _inArray(val, arr) {
for (var i = 0, len = arr.length; i < len; i++) {
if (val === arr[i]) {
return i;
}
}
return -1;
}
function _each(obj, fn) {
if (_isArray(obj)) {
for (var i = 0, len = obj.length; i < len; i++) {
if (fn.call(obj[i], i, obj[i]) === false) {
break;
}
}
} else {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
if (fn.call(obj[key], key, obj[key]) === false) {
break;
}
}
}
}
}
function _trim(str) {
return str.replace(/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g, '');
}
function _inString(val, str, delimiter) {
delimiter = delimiter === undefined ? ',' : delimiter;
return (delimiter + str + delimiter).indexOf(delimiter + val + delimiter) >= 0;
}
function _addUnit(val, unit) {
unit = unit || 'px';
return val && /^\d+$/.test(val) ? val + 'px' : val;
}
function _removeUnit(val) {
var match;
return val && (match = /(\d+)/.exec(val)) ? parseInt(match[1], 10) : 0;
}
function _escape(val) {
return val.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
}
function _unescape(val) {
return val.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/&/g, '&');
}
function _toCamel(str) {
var arr = str.split('-');
str = '';
_each(arr, function(key, val) {
str += (key > 0) ? val.charAt(0).toUpperCase() + val.substr(1) : val;
});
return str;
}
function _toHex(val) {
function hex(d) {
var s = parseInt(d, 10).toString(16).toUpperCase();
return s.length > 1 ? s : '0' + s;
}
return val.replace(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/ig,
function($0, $1, $2, $3) {
return '#' + hex($1) + hex($2) + hex($3);
}
);
}
function _toMap(val, delimiter) {
delimiter = delimiter === undefined ? ',' : delimiter;
var map = {}, arr = _isArray(val) ? val : val.split(delimiter), match;
_each(arr, function(key, val) {
if ((match = /^(\d+)\.\.(\d+)$/.exec(val))) {
for (var i = parseInt(match[1], 10); i <= parseInt(match[2], 10); i++) {
map[i.toString()] = true;
}
} else {
map[val] = true;
}
});
return map;
}
function _toArray(obj, offset) {
return Array.prototype.slice.call(obj, offset || 0);
}
function _undef(val, defaultVal) {
return val === undefined ? defaultVal : val;
}
function _invalidUrl(url) {
return !url || /[<>"]/.test(url);
}
function _addParam(url, param) {
return url.indexOf('?') >= 0 ? url + '&' + param : url + '?' + param;
}
function _extend(child, parent, proto) {
if (!proto) {
proto = parent;
parent = null;
}
var childProto;
if (parent) {
var fn = function () {};
fn.prototype = parent.prototype;
childProto = new fn();
_each(proto, function(key, val) {
childProto[key] = val;
});
} else {
childProto = proto;
}
childProto.constructor = child;
child.prototype = childProto;
child.parent = parent ? parent.prototype : null;
}
function _json(text) {
var match;
if ((match = /\{[\s\S]*\}|\[[\s\S]*\]/.exec(text))) {
text = match[0];
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
if (/^[\],:{}\s]*$/.
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
return eval('(' + text + ')');
}
throw 'JSON parse error';
}
var _round = Math.round;
var K = {
DEBUG : false,
VERSION : _VERSION,
IE : _IE,
GECKO : _GECKO,
WEBKIT : _WEBKIT,
OPERA : _OPERA,
V : _V,
TIME : _TIME,
each : _each,
isArray : _isArray,
isFunction : _isFunction,
inArray : _inArray,
inString : _inString,
trim : _trim,
addUnit : _addUnit,
removeUnit : _removeUnit,
escape : _escape,
unescape : _unescape,
toCamel : _toCamel,
toHex : _toHex,
toMap : _toMap,
toArray : _toArray,
undef : _undef,
invalidUrl : _invalidUrl,
addParam : _addParam,
extend : _extend,
json : _json
};
var _INLINE_TAG_MAP = _toMap('a,abbr,acronym,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,img,input,ins,kbd,label,map,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'),
_BLOCK_TAG_MAP = _toMap('address,applet,blockquote,body,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,h1,h2,h3,h4,h5,h6,head,hr,html,iframe,ins,isindex,li,map,menu,meta,noframes,noscript,object,ol,p,pre,script,style,table,tbody,td,tfoot,th,thead,title,tr,ul'),
_SINGLE_TAG_MAP = _toMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'),
_STYLE_TAG_MAP = _toMap('b,basefont,big,del,em,font,i,s,small,span,strike,strong,sub,sup,u'),
_CONTROL_TAG_MAP = _toMap('img,table,input,textarea,button'),
_PRE_TAG_MAP = _toMap('pre,style,script'),
_NOSPLIT_TAG_MAP = _toMap('html,head,body,td,tr,table,ol,ul,li'),
_AUTOCLOSE_TAG_MAP = _toMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'),
_FILL_ATTR_MAP = _toMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'),
_VALUE_TAG_MAP = _toMap('input,button,textarea,select');
function _getBasePath() {
var els = document.getElementsByTagName('script'), src;
for (var i = 0, len = els.length; i < len; i++) {
src = els[i].src || '';
if (/kindeditor[\w\-\.]*\.js/.test(src)) {
return src.substring(0, src.lastIndexOf('/') + 1);
}
}
return '';
}
K.basePath = _getBasePath();
K.options = {
designMode : true,
fullscreenMode : false,
filterMode : false,
wellFormatMode : true,
shadowMode : true,
loadStyleMode : true,
basePath : K.basePath,
themesPath : K.basePath + 'themes/',
langPath : K.basePath + 'lang/',
pluginsPath : K.basePath + 'plugins/',
themeType : 'default',
langType : 'zh_CN',
urlType : '',
newlineTag : 'p',
resizeType : 2,
syncType : 'form',
pasteType : 2,
dialogAlignType : 'page',
useContextmenu : true,
bodyClass : 'ke-content',
indentChar : '\t',
cssPath : '',
cssData : '',
minWidth : 650,
minHeight : 100,
minChangeSize : 5,
items : [
'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste',
'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image',
'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'map', 'code', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about'
],
noDisableItems : ['source', 'fullscreen'],
colorTable : [
['#E53333', '#E56600', '#FF9900', '#64451D', '#DFC5A4', '#FFE500'],
['#009900', '#006600', '#99BB00', '#B8D100', '#60D978', '#00D5FF'],
['#337FE5', '#003399', '#4C33E5', '#9933E5', '#CC33E5', '#EE33EE'],
['#FFFFFF', '#CCCCCC', '#999999', '#666666', '#333333', '#000000']
],
fontSizeTable : ['9px', '10px', '12px', '14px', '16px', '18px', '24px', '32px'],
htmlTags : {
font : ['color', 'size', 'face', '.background-color'],
span : [
'.color', '.background-color', '.font-size', '.font-family', '.background',
'.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.line-height'
],
div : [
'align', '.border', '.margin', '.padding', '.text-align', '.color',
'.background-color', '.font-size', '.font-family', '.font-weight', '.background',
'.font-style', '.text-decoration', '.vertical-align', '.margin-left'
],
table: [
'border', 'cellspacing', 'cellpadding', 'width', 'height', 'align', 'bordercolor',
'.padding', '.margin', '.border', 'bgcolor', '.text-align', '.color', '.background-color',
'.font-size', '.font-family', '.font-weight', '.font-style', '.text-decoration', '.background',
'.width', '.height'
],
'td,th': [
'align', 'valign', 'width', 'height', 'colspan', 'rowspan', 'bgcolor',
'.text-align', '.color', '.background-color', '.font-size', '.font-family', '.font-weight',
'.font-style', '.text-decoration', '.vertical-align', '.background'
],
a : ['href', 'target', 'name'],
embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
img : ['src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height'],
'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [
'align', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.background',
'.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left'
],
pre : ['class'],
'hr,br,tbody,tr,strong,b,sub,sup,em,i,u,strike' : []
},
layout : '<div class="container"><div class="toolbar"></div><div class="edit"></div><div class="statusbar"></div></div>'
};
var _useCapture = false;
var _INPUT_KEY_MAP = _toMap('8,9,13,32,46,48..57,59,61,65..90,106,109..111,188,190..192,219..222');
var _CURSORMOVE_KEY_MAP = _toMap('33..40');
var _CHANGE_KEY_MAP = {};
_each(_INPUT_KEY_MAP, function(key, val) {
_CHANGE_KEY_MAP[key] = val;
});
_each(_CURSORMOVE_KEY_MAP, function(key, val) {
_CHANGE_KEY_MAP[key] = val;
});
function _bindEvent(el, type, fn) {
if (el.addEventListener){
el.addEventListener(type, fn, _useCapture);
} else if (el.attachEvent){
el.attachEvent('on' + type, fn);
}
}
function _unbindEvent(el, type, fn) {
if (el.removeEventListener){
el.removeEventListener(type, fn, _useCapture);
} else if (el.detachEvent){
el.detachEvent('on' + type, fn);
}
}
var _EVENT_PROPS = ('altKey,attrChange,attrName,bubbles,button,cancelable,charCode,clientX,clientY,ctrlKey,currentTarget,' +
'data,detail,eventPhase,fromElement,handler,keyCode,layerX,layerY,metaKey,newValue,offsetX,offsetY,originalTarget,pageX,' +
'pageY,prevValue,relatedNode,relatedTarget,screenX,screenY,shiftKey,srcElement,target,toElement,view,wheelDelta,which').split(',');
function KEvent(el, event) {
this.init(el, event);
}
_extend(KEvent, {
init : function(el, event) {
var self = this, doc = el.ownerDocument || el.document || el;
self.event = event;
_each(_EVENT_PROPS, function(key, val) {
self[val] = event[val];
});
if (!self.target) {
self.target = self.srcElement || doc;
}
if (self.target.nodeType === 3) {
self.target = self.target.parentNode;
}
if (!self.relatedTarget && self.fromElement) {
self.relatedTarget = self.fromElement === self.target ? self.toElement : self.fromElement;
}
if (self.pageX == null && self.clientX != null) {
var d = doc.documentElement, body = doc.body;
self.pageX = self.clientX + (d && d.scrollLeft || body && body.scrollLeft || 0) - (d && d.clientLeft || body && body.clientLeft || 0);
self.pageY = self.clientY + (d && d.scrollTop || body && body.scrollTop || 0) - (d && d.clientTop || body && body.clientTop || 0);
}
if (!self.which && ((self.charCode || self.charCode === 0) ? self.charCode : self.keyCode)) {
self.which = self.charCode || self.keyCode;
}
if (!self.metaKey && self.ctrlKey) {
self.metaKey = self.ctrlKey;
}
if (!self.which && self.button !== undefined) {
self.which = (self.button & 1 ? 1 : (self.button & 2 ? 3 : (self.button & 4 ? 2 : 0)));
}
switch (self.which) {
case 186 :
self.which = 59;
break;
case 187 :
case 107 :
case 43 :
self.which = 61;
break;
case 189 :
case 45 :
self.which = 109;
break;
case 42 :
self.which = 106;
break;
case 47 :
self.which = 111;
break;
case 78 :
self.which = 110;
break;
}
if (self.which >= 96 && self.which <= 105) {
self.which -= 48;
}
},
preventDefault : function() {
var ev = this.event;
if (ev.preventDefault) {
ev.preventDefault();
}
ev.returnValue = false;
},
stopPropagation : function() {
var ev = this.event;
if (ev.stopPropagation) {
ev.stopPropagation();
}
ev.cancelBubble = true;
},
stop : function() {
this.preventDefault();
this.stopPropagation();
}
});
var _eventExpendo = 'kindeditor_' + _TIME, _eventId = 0, _eventData = {};
function _getId(el) {
return el[_eventExpendo] || null;
}
function _setId(el) {
el[_eventExpendo] = ++_eventId;
return _eventId;
}
function _removeId(el) {
try {
delete el[_eventExpendo];
} catch(e) {
if (el.removeAttribute) {
el.removeAttribute(_eventExpendo);
}
}
}
function _bind(el, type, fn) {
if (type.indexOf(',') >= 0) {
_each(type.split(','), function() {
_bind(el, this, fn);
});
return;
}
var id = _getId(el);
if (!id) {
id = _setId(el);
}
if (_eventData[id] === undefined) {
_eventData[id] = {};
}
var events = _eventData[id][type];
if (events && events.length > 0) {
_unbindEvent(el, type, events[0]);
} else {
_eventData[id][type] = [];
_eventData[id].el = el;
}
events = _eventData[id][type];
if (events.length === 0) {
events[0] = function(e) {
var kevent = e ? new KEvent(el, e) : undefined;
_each(events, function(i, event) {
if (i > 0 && event) {
event.call(el, kevent);
}
});
};
}
if (_inArray(fn, events) < 0) {
events.push(fn);
}
_bindEvent(el, type, events[0]);
}
function _unbind(el, type, fn) {
if (type && type.indexOf(',') >= 0) {
_each(type.split(','), function() {
_unbind(el, this, fn);
});
return;
}
var id = _getId(el);
if (!id) {
return;
}
if (type === undefined) {
if (id in _eventData) {
_each(_eventData[id], function(key, events) {
if (key != 'el' && events.length > 0) {
_unbindEvent(el, key, events[0]);
}
});
delete _eventData[id];
_removeId(el);
}
return;
}
if (!_eventData[id]) {
return;
}
var events = _eventData[id][type];
if (events && events.length > 0) {
if (fn === undefined) {
_unbindEvent(el, type, events[0]);
delete _eventData[id][type];
} else {
_each(events, function(i, event) {
if (i > 0 && event === fn) {
events.splice(i, 1);
}
});
if (events.length == 1) {
_unbindEvent(el, type, events[0]);
delete _eventData[id][type];
}
}
var count = 0;
_each(_eventData[id], function() {
count++;
});
if (count < 2) {
delete _eventData[id];
_removeId(el);
}
}
}
function _fire(el, type) {
if (type.indexOf(',') >= 0) {
_each(type.split(','), function() {
_fire(el, this);
});
return;
}
var id = _getId(el);
if (!id) {
return;
}
var events = _eventData[id][type];
if (_eventData[id] && events && events.length > 0) {
events[0]();
}
}
function _ctrl(el, key, fn) {
var self = this;
key = /^\d{2,}$/.test(key) ? key : key.toUpperCase().charCodeAt(0);
_bind(el, 'keydown', function(e) {
if (e.ctrlKey && e.which == key && !e.shiftKey && !e.altKey) {
fn.call(el);
e.stop();
}
});
}
function _ready(fn) {
var loaded = false;
function readyFunc() {
if (!loaded) {
loaded = true;
fn(KindEditor);
if (document.addEventListener) {
_unbind(document, 'DOMContentLoaded', readyFunc);
} else if (document.attachEvent) {
_unbind(document, 'readystatechange', ieReadyStateFunc);
}
_unbind(window, 'load', readyFunc);
}
}
function ieReadyFunc() {
if (!loaded) {
try {
document.documentElement.doScroll('left');
} catch(e) {
setTimeout(ieReadyFunc, 0);
return;
}
readyFunc();
}
}
function ieReadyStateFunc() {
if (document.readyState === 'complete') {
readyFunc();
}
}
if (document.addEventListener) {
_bind(document, 'DOMContentLoaded', readyFunc);
} else if (document.attachEvent) {
_bind(document, 'readystatechange', ieReadyStateFunc);
if (document.documentElement.doScroll && window.frameElement === undefined) {
ieReadyFunc();
}
}
_bind(window, 'load', readyFunc);
}
if (_IE) {
window.attachEvent('onunload', function() {
_each(_eventData, function(key, events) {
if (events.el) {
_unbind(events.el);
}
});
});
}
K.ctrl = _ctrl;
K.ready = _ready;
function _getCssList(css) {
var list = {},
reg = /\s*([\w\-]+)\s*:([^;]*)(;|$)/g,
match;
while ((match = reg.exec(css))) {
var key = _trim(match[1].toLowerCase()),
val = _trim(_toHex(match[2]));
list[key] = val;
}
return list;
}
function _getAttrList(tag) {
var list = {},
reg = /\s+(?:([\w\-:]+)|(?:([\w\-:]+)=([^\s"'<>]+))|(?:([\w\-:"]+)="([^"]*)")|(?:([\w\-:"]+)='([^']*)'))(?=(?:\s|\/|>)+)/g,
match;
while ((match = reg.exec(tag))) {
var key = (match[1] || match[2] || match[4] || match[6]).toLowerCase(),
val = (match[2] ? match[3] : (match[4] ? match[5] : match[7])) || '';
list[key] = val;
}
return list;
}
function _addClassToTag(tag, className) {
if (/\s+class\s*=/.test(tag)) {
tag = tag.replace(/(\s+class=["']?)([^"']*)(["']?[\s>])/, function($0, $1, $2, $3) {
if ((' ' + $2 + ' ').indexOf(' ' + className + ' ') < 0) {
return $2 === '' ? $1 + className + $3 : $1 + $2 + ' ' + className + $3;
} else {
return $0;
}
});
} else {
tag = tag.substr(0, tag.length - 1) + ' class="' + className + '">';
}
return tag;
}
function _formatCss(css) {
var str = '';
_each(_getCssList(css), function(key, val) {
str += key + ':' + val + ';';
});
return str;
}
function _formatUrl(url, mode, host, pathname) {
mode = _undef(mode, '').toLowerCase();
if (_inArray(mode, ['absolute', 'relative', 'domain']) < 0) {
return url;
}
host = host || location.protocol + '//' + location.host;
if (pathname === undefined) {
var m = location.pathname.match(/^(\/.*)\//);
pathname = m ? m[1] : '';
}
var match;
if ((match = /^(\w+:\/\/[^\/]*)/.exec(url))) {
if (match[1] !== host) {
return url;
}
} else if (/^\w+:/.test(url)) {
return url;
}
function getRealPath(path) {
var parts = path.split('/'), paths = [];
for (var i = 0, len = parts.length; i < len; i++) {
var part = parts[i];
if (part == '..') {
if (paths.length > 0) {
paths.pop();
}
} else if (part !== '' && part != '.') {
paths.push(part);
}
}
return '/' + paths.join('/');
}
if (/^\//.test(url)) {
url = host + getRealPath(url.substr(1));
} else if (!/^\w+:\/\//.test(url)) {
url = host + getRealPath(pathname + '/' + url);
}
function getRelativePath(path, depth) {
if (url.substr(0, path.length) === path) {
var arr = [];
for (var i = 0; i < depth; i++) {
arr.push('..');
}
var prefix = '.';
if (arr.length > 0) {
prefix += '/' + arr.join('/');
}
if (pathname == '/') {
prefix += '/';
}
return prefix + url.substr(path.length);
} else {
if ((match = /^(.*)\//.exec(path))) {
return getRelativePath(match[1], ++depth);
}
}
}
if (mode === 'relative') {
url = getRelativePath(host + pathname, 0).substr(2);
} else if (mode === 'absolute') {
if (url.substr(0, host.length) === host) {
url = url.substr(host.length);
}
}
return url;
}
function _formatHtml(html, htmlTags, urlType, wellFormatted, indentChar) {
urlType = urlType || '';
wellFormatted = _undef(wellFormatted, false);
indentChar = _undef(indentChar, '\t');
var fontSizeList = 'xx-small,x-small,small,medium,large,x-large,xx-large'.split(',');
html = html.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/ig, function($0, $1, $2, $3) {
return $1 + $2.replace(/<(?:br|br\s[^>]*)>/ig, '\n') + $3;
});
html = html.replace(/<(?:br|br\s[^>]*)\s*\/?>\s*<\/p>/ig, '</p>');
html = html.replace(/<(?:p|p\s[^>]*)><\/p>/ig, '');
html = html.replace(/\u200B/g, '');
var htmlTagMap = {};
if (htmlTags) {
_each(htmlTags, function(key, val) {
var arr = key.split(',');
for (var i = 0, len = arr.length; i < len; i++) {
htmlTagMap[arr[i]] = _toMap(val);
}
});
if (!htmlTagMap.script) {
html = html.replace(/(<(?:script|script\s[^>]*)>)([\s\S]*?)(<\/script>)/ig, '');
}
if (!htmlTagMap.style) {
html = html.replace(/(<(?:style|style\s[^>]*)>)([\s\S]*?)(<\/style>)/ig, '');
}
}
var re = /(\s*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"'<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+='[^']*'))*)(\/)?>(\s*)/g;
var tagStack = [];
html = html.replace(re, function($0, $1, $2, $3, $4, $5, $6) {
var full = $0,
startNewline = $1 || '',
startSlash = $2 || '',
tagName = $3.toLowerCase(),
attr = $4 || '',
endSlash = $5 ? ' ' + $5 : '',
endNewline = $6 || '';
if (htmlTags && !htmlTagMap[tagName]) {
return '';
}
if (endSlash === '' && _SINGLE_TAG_MAP[tagName]) {
endSlash = ' /';
}
if (_INLINE_TAG_MAP[tagName]) {
if (startNewline) {
startNewline = ' ';
}
if (endNewline) {
endNewline = ' ';
}
}
if (_PRE_TAG_MAP[tagName]) {
if (startSlash) {
endNewline = '\n';
} else {
startNewline = '\n';
}
}
if (wellFormatted && tagName == 'br') {
endNewline = '\n';
}
if (_BLOCK_TAG_MAP[tagName] && !_PRE_TAG_MAP[tagName]) {
if (wellFormatted) {
if (startSlash && tagStack.length > 0 && tagStack[tagStack.length - 1] === tagName) {
tagStack.pop();
} else {
tagStack.push(tagName);
}
startNewline = '\n';
endNewline = '\n';
for (var i = 0, len = startSlash ? tagStack.length : tagStack.length - 1; i < len; i++) {
startNewline += indentChar;
if (!startSlash) {
endNewline += indentChar;
}
}
if (endSlash) {
tagStack.pop();
} else if (!startSlash) {
endNewline += indentChar;
}
} else {
startNewline = endNewline = '';
}
}
if (attr !== '') {
var attrMap = _getAttrList(full);
if (tagName === 'font') {
var fontStyleMap = {}, fontStyle = '';
_each(attrMap, function(key, val) {
if (key === 'color') {
fontStyleMap.color = val;
delete attrMap[key];
}
if (key === 'size') {
fontStyleMap['font-size'] = fontSizeList[parseInt(val, 10) - 1] || '';
delete attrMap[key];
}
if (key === 'face') {
fontStyleMap['font-family'] = val;
delete attrMap[key];
}
if (key === 'style') {
fontStyle = val;
}
});
if (fontStyle && !/;$/.test(fontStyle)) {
fontStyle += ';';
}
_each(fontStyleMap, function(key, val) {
if (val === '') {
return;
}
if (/\s/.test(val)) {
val = "'" + val + "'";
}
fontStyle += key + ':' + val + ';';
});
attrMap.style = fontStyle;
}
_each(attrMap, function(key, val) {
if (_FILL_ATTR_MAP[key]) {
attrMap[key] = key;
}
if (_inArray(key, ['src', 'href']) >= 0) {
attrMap[key] = _formatUrl(val, urlType);
}
if (htmlTags && key !== 'style' && !htmlTagMap[tagName]['*'] && !htmlTagMap[tagName][key] ||
tagName === 'body' && key === 'contenteditable' ||
/^kindeditor_\d+$/.test(key)) {
delete attrMap[key];
}
if (key === 'style' && val !== '') {
var styleMap = _getCssList(val);
_each(styleMap, function(k, v) {
if (htmlTags && !htmlTagMap[tagName].style && !htmlTagMap[tagName]['.' + k]) {
delete styleMap[k];
}
});
var style = '';
_each(styleMap, function(k, v) {
style += k + ':' + v + ';';
});
attrMap.style = style;
}
});
attr = '';
_each(attrMap, function(key, val) {
if (key === 'style' && val === '') {
return;
}
attr += ' ' + key + '="' + val + '"';
});
}
if (tagName === 'font') {
tagName = 'span';
}
return startNewline + '<' + startSlash + tagName + attr + endSlash + '>' + endNewline;
});
html = html.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/ig, function($0, $1, $2, $3) {
return $1 + $2.replace(/\n/g, '<span id="__kindeditor_pre_newline__">\n') + $3;
});
html = html.replace(/\n\s*\n/g, '\n');
html = html.replace(/<span id="__kindeditor_pre_newline__">\n/g, '\n');
return _trim(html);
}
function _clearMsWord(html, htmlTags) {
html = html.replace(/<meta[\s\S]*?>/ig, '')
.replace(/<![\s\S]*?>/ig, '')
.replace(/<style[^>]*>[\s\S]*?<\/style>/ig, '')
.replace(/<script[^>]*>[\s\S]*?<\/script>/ig, '')
.replace(/<w:[^>]+>[\s\S]*?<\/w:[^>]+>/ig, '')
.replace(/<o:[^>]+>[\s\S]*?<\/o:[^>]+>/ig, '')
.replace(/<xml>[\s\S]*?<\/xml>/ig, '')
.replace(/(<table[^>]*)(>)/ig, function(full, start, end) {
full = full.replace(/border="?\d+"?/, '');
var attrs = _getAttrList(full), newFull = start;
if (attrs.border === undefined) {
newFull += ' border="1"';
}
if (attrs.bordercolor === undefined) {
newFull += ' bordercolor="#000000"';
}
newFull += end;
return newFull;
});
return _formatHtml(html, htmlTags);
}
function _mediaType(src) {
if (/\.(rm|rmvb)(\?|$)/i.test(src)) {
return 'audio/x-pn-realaudio-plugin';
}
if (/\.(swf|flv)(\?|$)/i.test(src)) {
return 'application/x-shockwave-flash';
}
return 'video/x-ms-asf-plugin';
}
function _mediaClass(type) {
if (/realaudio/i.test(type)) {
return 'ke-rm';
}
if (/flash/i.test(type)) {
return 'ke-flash';
}
return 'ke-media';
}
function _mediaAttrs(srcTag) {
return _getAttrList(unescape(srcTag));
}
function _mediaEmbed(attrs) {
var html = '<embed ';
_each(attrs, function(key, val) {
html += key + '="' + val + '" ';
});
html += '/>';
return html;
}
function _mediaImg(blankPath, attrs) {
var width = attrs.width,
height = attrs.height,
type = attrs.type || _mediaType(attrs.src),
srcTag = _mediaEmbed(attrs),
style = '';
if (width > 0) {
style += 'width:' + width + 'px;';
}
if (height > 0) {
style += 'height:' + height + 'px;';
}
var html = '<img class="' + _mediaClass(type) + '" src="' + blankPath + '" ';
if (style !== '') {
html += 'style="' + style + '" ';
}
html += 'data-ke-tag="' + escape(srcTag) + '" alt="" />';
return html;
}
K.formatUrl = _formatUrl;
K.formatHtml = _formatHtml;
K.getCssList = _getCssList;
K.getAttrList = _getAttrList;
K.mediaType = _mediaType;
K.mediaAttrs = _mediaAttrs;
K.mediaEmbed = _mediaEmbed;
K.mediaImg = _mediaImg;
K.clearMsWord = _clearMsWord;
function _contains(nodeA, nodeB) {
if (nodeA.nodeType == 9 && nodeB.nodeType != 9) {
return true;
}
while ((nodeB = nodeB.parentNode)) {
if (nodeB == nodeA) {
return true;
}
}
return false;
}
function _getAttr(el, key) {
key = key.toLowerCase();
var val = null;
if (_IE && _V < 8) {
var div = el.ownerDocument.createElement('div');
div.appendChild(el.cloneNode(false));
var list = _getAttrList(div.innerHTML.toLowerCase());
if (key in list) {
val = list[key];
}
} else {
val = el.getAttribute(key, 2);
}
if (key === 'style' && val !== null) {
val = _formatCss(val);
}
return val;
}
function _queryAll(expr, root) {
var exprList = expr.split(',');
if (exprList.length > 1) {
var mergedResults = [];
_each(exprList, function() {
_each(_queryAll(this, root), function() {
if (_inArray(this, mergedResults) < 0) {
mergedResults.push(this);
}
});
});
return mergedResults;
}
root = root || document;
function escape(str) {
if (typeof str != 'string') {
return str;
}
return str.replace(/([^\w\-])/g, '\\$1');
}
function stripslashes(str) {
return str.replace(/\\/g, '');
}
function cmpTag(tagA, tagB) {
return tagA === '*' || tagA.toLowerCase() === escape(tagB.toLowerCase());
}
function byId(id, tag, root) {
var arr = [],
doc = root.ownerDocument || root,
el = doc.getElementById(stripslashes(id));
if (el) {
if (cmpTag(tag, el.nodeName) && _contains(root, el)) {
arr.push(el);
}
}
return arr;
}
function byClass(className, tag, root) {
var doc = root.ownerDocument || root, arr = [], els, i, len, el;
if (root.getElementsByClassName) {
els = root.getElementsByClassName(stripslashes(className));
for (i = 0, len = els.length; i < len; i++) {
el = els[i];
if (cmpTag(tag, el.nodeName)) {
arr.push(el);
}
}
} else if (doc.querySelectorAll) {
els = doc.querySelectorAll((root.nodeName !== '#document' ? root.nodeName + ' ' : '') + tag + '.' + className);
for (i = 0, len = els.length; i < len; i++) {
el = els[i];
if (_contains(root, el)) {
arr.push(el);
}
}
} else {
els = root.getElementsByTagName(tag);
className = ' ' + className + ' ';
for (i = 0, len = els.length; i < len; i++) {
el = els[i];
if (el.nodeType == 1) {
var cls = el.className;
if (cls && (' ' + cls + ' ').indexOf(className) > -1) {
arr.push(el);
}
}
}
}
return arr;
}
function byName(name, tag, root) {
var arr = [], doc = root.ownerDocument || root,
els = doc.getElementsByName(stripslashes(name)), el;
for (var i = 0, len = els.length; i < len; i++) {
el = els[i];
if (cmpTag(tag, el.nodeName) && _contains(root, el)) {
if (el.getAttributeNode('name')) {
arr.push(el);
}
}
}
return arr;
}
function byAttr(key, val, tag, root) {
var arr = [], els = root.getElementsByTagName(tag), el;
for (var i = 0, len = els.length; i < len; i++) {
el = els[i];
if (el.nodeType == 1) {
if (val === null) {
if (_getAttr(el, key) !== null) {
arr.push(el);
}
} else {
if (val === escape(_getAttr(el, key))) {
arr.push(el);
}
}
}
}
return arr;
}
function select(expr, root) {
var arr = [], matches;
matches = /^((?:\\.|[^.#\s\[<>])+)/.exec(expr);
var tag = matches ? matches[1] : '*';
if ((matches = /#((?:[\w\-]|\\.)+)$/.exec(expr))) {
arr = byId(matches[1], tag, root);
} else if ((matches = /\.((?:[\w\-]|\\.)+)$/.exec(expr))) {
arr = byClass(matches[1], tag, root);
} else if ((matches = /\[((?:[\w\-]|\\.)+)\]/.exec(expr))) {
arr = byAttr(matches[1].toLowerCase(), null, tag, root);
} else if ((matches = /\[((?:[\w\-]|\\.)+)\s*=\s*['"]?((?:\\.|[^'"]+)+)['"]?\]/.exec(expr))) {
var key = matches[1].toLowerCase(), val = matches[2];
if (key === 'id') {
arr = byId(val, tag, root);
} else if (key === 'class') {
arr = byClass(val, tag, root);
} else if (key === 'name') {
arr = byName(val, tag, root);
} else {
arr = byAttr(key, val, tag, root);
}
} else {
var els = root.getElementsByTagName(tag), el;
for (var i = 0, len = els.length; i < len; i++) {
el = els[i];
if (el.nodeType == 1) {
arr.push(el);
}
}
}
return arr;
}
var parts = [], arr, re = /((?:\\.|[^\s>])+|[\s>])/g;
while ((arr = re.exec(expr))) {
if (arr[1] !== ' ') {
parts.push(arr[1]);
}
}
var results = [];
if (parts.length == 1) {
return select(parts[0], root);
}
var isChild = false, part, els, subResults, val, v, i, j, k, length, len, l;
for (i = 0, lenth = parts.length; i < lenth; i++) {
part = parts[i];
if (part === '>') {
isChild = true;
continue;
}
if (i > 0) {
els = [];
for (j = 0, len = results.length; j < len; j++) {
val = results[j];
subResults = select(part, val);
for (k = 0, l = subResults.length; k < l; k++) {
v = subResults[k];
if (isChild) {
if (val === v.parentNode) {
els.push(v);
}
} else {
els.push(v);
}
}
}
results = els;
} else {
results = select(part, root);
}
if (results.length === 0) {
return [];
}
}
return results;
}
function _query(expr, root) {
var arr = _queryAll(expr, root);
return arr.length > 0 ? arr[0] : null;
}
K.query = _query;
K.queryAll = _queryAll;
function _get(val) {
return K(val)[0];
}
function _getDoc(node) {
if (!node) {
return document;
}
return node.ownerDocument || node.document || node;
}
function _getWin(node) {
if (!node) {
return window;
}
var doc = _getDoc(node);
return doc.parentWindow || doc.defaultView;
}
function _setHtml(el, html) {
if (el.nodeType != 1) {
return;
}
var doc = _getDoc(el);
try {
el.innerHTML = '<img id="__kindeditor_temp_tag__" width="0" height="0" style="display:none;" />' + html;
var temp = doc.getElementById('__kindeditor_temp_tag__');
temp.parentNode.removeChild(temp);
} catch(e) {
K(el).empty();
K('@' + html, doc).each(function() {
el.appendChild(this);
});
}
}
function _hasClass(el, cls) {
return _inString(cls, el.className, ' ');
}
function _setAttr(el, key, val) {
if (_IE && _V < 8 && key.toLowerCase() == 'class') {
key = 'className';
}
el.setAttribute(key, '' + val);
}
function _removeAttr(el, key) {
if (_IE && _V < 8 && key.toLowerCase() == 'class') {
key = 'className';
}
_setAttr(el, key, '');
el.removeAttribute(key);
}
function _getNodeName(node) {
if (!node || !node.nodeName) {
return '';
}
return node.nodeName.toLowerCase();
}
function _computedCss(el, key) {
var self = this, win = _getWin(el), camelKey = _toCamel(key), val = '';
if (win.getComputedStyle) {
var style = win.getComputedStyle(el, null);
val = style[camelKey] || style.getPropertyValue(key) || el.style[camelKey];
} else if (el.currentStyle) {
val = el.currentStyle[camelKey] || el.style[camelKey];
}
return val;
}
function _hasVal(node) {
return !!_VALUE_TAG_MAP[_getNodeName(node)];
}
function _docElement(doc) {
doc = doc || document;
return _QUIRKS ? doc.body : doc.documentElement;
}
function _docHeight(doc) {
var el = _docElement(doc);
return Math.max(el.scrollHeight, el.clientHeight);
}
function _docWidth(doc) {
var el = _docElement(doc);
return Math.max(el.scrollWidth, el.clientWidth);
}
function _getScrollPos(doc) {
doc = doc || document;
var x, y;
if (_IE || _OPERA) {
x = _docElement(doc).scrollLeft;
y = _docElement(doc).scrollTop;
} else {
x = _getWin(doc).scrollX;
y = _getWin(doc).scrollY;
}
return {x : x, y : y};
}
function KNode(node) {
this.init(node);
}
_extend(KNode, {
init : function(node) {
var self = this;
for (var i = 0, len = node.length; i < len; i++) {
self[i] = node[i].get ? node[i][0] : node[i];
}
self.length = node.length;
self.doc = _getDoc(self[0]);
self.name = _getNodeName(self[0]);
self.type = self.length > 0 ? self[0].nodeType : null;
self.win = _getWin(self[0]);
self._data = {};
},
each : function(fn) {
var self = this;
for (var i = 0; i < self.length; i++) {
if (fn.call(self[i], i, self[i]) === false) {
return self;
}
}
return self;
},
bind : function(type, fn) {
this.each(function() {
_bind(this, type, fn);
});
return this;
},
unbind : function(type, fn) {
this.each(function() {
_unbind(this, type, fn);
});
return this;
},
fire : function(type) {
if (this.length < 1) {
return this;
}
_fire(this[0], type);
return this;
},
hasAttr : function(key) {
if (this.length < 1) {
return false;
}
return !!_getAttr(this[0], key);
},
attr : function(key, val) {
var self = this;
if (key === undefined) {
return _getAttrList(self.outer());
}
if (typeof key === 'object') {
_each(key, function(k, v) {
self.attr(k, v);
});
return self;
}
if (val === undefined) {
val = self.length < 1 ? null : _getAttr(self[0], key);
return val === null ? '' : val;
}
self.each(function() {
_setAttr(this, key, val);
});
return self;
},
removeAttr : function(key) {
this.each(function() {
_removeAttr(this, key);
});
return this;
},
get : function(i) {
if (this.length < 1) {
return null;
}
return this[i || 0];
},
hasClass : function(cls) {
if (this.length < 1) {
return false;
}
return _hasClass(this[0], cls);
},
addClass : function(cls) {
this.each(function() {
if (!_hasClass(this, cls)) {
this.className = _trim(this.className + ' ' + cls);
}
});
return this;
},
removeClass : function(cls) {
this.each(function() {
if (_hasClass(this, cls)) {
this.className = _trim(this.className.replace(new RegExp('(^|\\s)' + cls + '(\\s|$)'), ' '));
}
});
return this;
},
html : function(val) {
var self = this;
if (val === undefined) {
if (self.length < 1) {
return '';
}
return _formatHtml(self[0].innerHTML);
}
self.each(function() {
_setHtml(this, val);
});
return self;
},
text : function() {
var self = this;
if (self.length < 1) {
return '';
}
return _IE ? self[0].innerText : self[0].textContent;
},
hasVal : function() {
if (this.length < 1) {
return false;
}
return _hasVal(this[0]);
},
val : function(val) {
var self = this;
if (val === undefined) {
if (self.length < 1) {
return '';
}
return self.hasVal() ? self[0].value : self.attr('value');
} else {
self.each(function() {
if (_hasVal(this)) {
this.value = val;
} else {
_setAttr(this, 'value' , val);
}
});
return self;
}
},
css : function(key, val) {
var self = this;
if (key === undefined) {
return _getCssList(self.attr('style'));
}
if (typeof key === 'object') {
_each(key, function(k, v) {
self.css(k, v);
});
return self;
}
if (val === undefined) {
if (self.length < 1) {
return '';
}
return self[0].style[_toCamel(key)] || _computedCss(self[0], key) || '';
}
self.each(function() {
this.style[_toCamel(key)] = val;
});
return self;
},
width : function(val) {
var self = this;
if (val === undefined) {
if (self.length < 1) {
return 0;
}
return self[0].offsetWidth;
}
return self.css('width', _addUnit(val));
},
height : function(val) {
var self = this;
if (val === undefined) {
if (self.length < 1) {
return 0;
}
return self[0].offsetHeight;
}
return self.css('height', _addUnit(val));
},
opacity : function(val) {
this.each(function() {
if (this.style.opacity === undefined) {
this.style.filter = val == 1 ? '' : 'alpha(opacity=' + (val * 100) + ')';
} else {
this.style.opacity = val == 1 ? '' : val;
}
});
return this;
},
data : function(key, val) {
var self = this;
if (val === undefined) {
return self._data[key];
}
self._data[key] = val;
return self;
},
pos : function() {
var self = this, node = self[0], x = 0, y = 0;
if (node) {
if (node.getBoundingClientRect) {
var box = node.getBoundingClientRect(),
pos = _getScrollPos(self.doc);
x = box.left + pos.x;
y = box.top + pos.y;
} else {
while (node) {
x += node.offsetLeft;
y += node.offsetTop;
node = node.offsetParent;
}
}
}
return {x : _round(x), y : _round(y)};
},
clone : function(bool) {
if (this.length < 1) {
return new KNode([]);
}
return new KNode([this[0].cloneNode(bool)]);
},
append : function(expr) {
this.each(function() {
if (this.appendChild) {
this.appendChild(_get(expr));
}
});
return this;
},
before : function(expr) {
this.each(function() {
this.parentNode.insertBefore(_get(expr), this);
});
return this;
},
after : function(expr) {
this.each(function() {
if (this.nextSibling) {
this.parentNode.insertBefore(_get(expr), this.nextSibling);
} else {
this.parentNode.appendChild(_get(expr));
}
});
return this;
},
replaceWith : function(expr) {
var nodes = [];
this.each(function(i, node) {
_unbind(node);
var newNode = _get(expr);
node.parentNode.replaceChild(newNode, node);
nodes.push(newNode);
});
return K(nodes);
},
empty : function() {
var self = this;
self.each(function(i, node) {
var child = node.firstChild;
while (child) {
if (!node.parentNode) {
return;
}
var next = child.nextSibling;
child.parentNode.removeChild(child);
child = next;
}
});
return self;
},
remove : function(keepChilds) {
var self = this;
self.each(function(i, node) {
if (!node.parentNode) {
return;
}
_unbind(node);
if (keepChilds) {
var child = node.firstChild;
while (child) {
var next = child.nextSibling;
node.parentNode.insertBefore(child, node);
child = next;
}
}
node.parentNode.removeChild(node);
delete self[i];
});
self.length = 0;
self._data = {};
return self;
},
show : function(val) {
return this.css('display', val === undefined ? 'block' : val);
},
hide : function() {
return this.css('display', 'none');
},
outer : function() {
var self = this;
if (self.length < 1) {
return '';
}
var div = self.doc.createElement('div'), html;
div.appendChild(self[0].cloneNode(true));
html = _formatHtml(div.innerHTML);
div = null;
return html;
},
isSingle : function() {
return !!_SINGLE_TAG_MAP[this.name];
},
isInline : function() {
return !!_INLINE_TAG_MAP[this.name];
},
isBlock : function() {
return !!_BLOCK_TAG_MAP[this.name];
},
isStyle : function() {
return !!_STYLE_TAG_MAP[this.name];
},
isControl : function() {
return !!_CONTROL_TAG_MAP[this.name];
},
contains : function(otherNode) {
if (this.length < 1) {
return false;
}
return _contains(this[0], _get(otherNode));
},
parent : function() {
if (this.length < 1) {
return null;
}
var node = this[0].parentNode;
return node ? new KNode([node]) : null;
},
children : function() {
if (this.length < 1) {
return [];
}
var list = [], child = this[0].firstChild;
while (child) {
if (child.nodeType != 3 || _trim(child.nodeValue) !== '') {
list.push(new KNode([child]));
}
child = child.nextSibling;
}
return list;
},
first : function() {
var list = this.children();
return list.length > 0 ? list[0] : null;
},
last : function() {
var list = this.children();
return list.length > 0 ? list[list.length - 1] : null;
},
index : function() {
if (this.length < 1) {
return -1;
}
var i = -1, sibling = this[0];
while (sibling) {
i++;
sibling = sibling.previousSibling;
}
return i;
},
prev : function() {
if (this.length < 1) {
return null;
}
var node = this[0].previousSibling;
return node ? new KNode([node]) : null;
},
next : function() {
if (this.length < 1) {
return null;
}
var node = this[0].nextSibling;
return node ? new KNode([node]) : null;
},
scan : function(fn, order) {
if (this.length < 1) {
return;
}
order = (order === undefined) ? true : order;
function walk(node) {
var n = order ? node.firstChild : node.lastChild;
while (n) {
var next = order ? n.nextSibling : n.previousSibling;
if (fn(n) === false) {
return false;
}
if (walk(n) === false) {
return false;
}
n = next;
}
}
walk(this[0]);
return this;
}
});
_each(('blur,focus,focusin,focusout,load,resize,scroll,unload,click,dblclick,' +
'mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,' +
'change,select,submit,keydown,keypress,keyup,error,contextmenu').split(','), function(i, type) {
KNode.prototype[type] = function(fn) {
return fn ? this.bind(type, fn) : this.fire(type);
};
});
var _K = K;
K = function(expr, root) {
if (expr === undefined || expr === null) {
return;
}
function newNode(node) {
if (!node[0]) {
node = [];
}
return new KNode(node);
}
if (typeof expr === 'string') {
if (root) {
root = _get(root);
}
var length = expr.length;
if (expr.charAt(0) === '@') {
expr = expr.substr(1);
}
if (expr.length !== length || /<.+>/.test(expr)) {
var doc = root ? root.ownerDocument || root : document,
div = doc.createElement('div'), list = [];
div.innerHTML = '<img id="__kindeditor_temp_tag__" width="0" height="0" style="display:none;" />' + expr;
for (var i = 0, len = div.childNodes.length; i < len; i++) {
var child = div.childNodes[i];
if (child.id == '__kindeditor_temp_tag__') {
continue;
}
list.push(child);
}
return newNode(list);
}
return newNode(_queryAll(expr, root));
}
if (expr && expr.get) {
return expr;
}
if (_isArray(expr)) {
return newNode(expr);
}
return newNode(_toArray(arguments));
};
_each(_K, function(key, val) {
K[key] = val;
});
window.KindEditor = K;
var _START_TO_START = 0,
_START_TO_END = 1,
_END_TO_END = 2,
_END_TO_START = 3,
_BOOKMARK_ID = 0;
function _updateCollapsed(range) {
range.collapsed = (range.startContainer === range.endContainer && range.startOffset === range.endOffset);
return range;
}
function _copyAndDelete(range, isCopy, isDelete) {
var doc = range.doc, nodeList = [];
function splitTextNode(node, startOffset, endOffset) {
var length = node.nodeValue.length, centerNode;
if (isCopy) {
var cloneNode = node.cloneNode(true);
if (startOffset > 0) {
centerNode = cloneNode.splitText(startOffset);
} else {
centerNode = cloneNode;
}
if (endOffset < length) {
centerNode.splitText(endOffset - startOffset);
}
}
if (isDelete) {
var center = node;
if (startOffset > 0) {
center = node.splitText(startOffset);
range.setStart(node, startOffset);
}
if (endOffset < length) {
var right = center.splitText(endOffset - startOffset);
range.setEnd(right, 0);
}
nodeList.push(center);
}
return centerNode;
}
function removeNodes() {
if (isDelete) {
range.up().collapse(true);
}
for (var i = 0, len = nodeList.length; i < len; i++) {
var node = nodeList[i];
if (node.parentNode) {
node.parentNode.removeChild(node);
}
}
}
var copyRange = range.cloneRange().down();
var start = -1, incStart = -1, incEnd = -1, end = -1,
ancestor = range.commonAncestor(), frag = doc.createDocumentFragment();
if (ancestor.nodeType == 3) {
var textNode = splitTextNode(ancestor, range.startOffset, range.endOffset);
if (isCopy) {
frag.appendChild(textNode);
}
removeNodes();
return isCopy ? frag : range;
}
function extractNodes(parent, frag) {
var node = parent.firstChild, nextNode;
while (node) {
var testRange = new KRange(doc).selectNode(node);
if (start <= 0) {
start = testRange.compareBoundaryPoints(_START_TO_END, range);
}
if (start >= 0 && incStart <= 0) {
incStart = testRange.compareBoundaryPoints(_START_TO_START, range);
}
if (incStart >= 0 && incEnd <= 0) {
incEnd = testRange.compareBoundaryPoints(_END_TO_END, range);
}
if (incEnd >= 0 && end <= 0) {
end = testRange.compareBoundaryPoints(_END_TO_START, range);
}
if (end >= 0) {
return false;
}
nextNode = node.nextSibling;
if (start > 0) {
if (node.nodeType == 1) {
if (incStart >= 0 && incEnd <= 0) {
if (isCopy) {
frag.appendChild(node.cloneNode(true));
}
if (isDelete) {
nodeList.push(node);
}
} else {
var childFlag;
if (isCopy) {
childFlag = node.cloneNode(false);
frag.appendChild(childFlag);
}
if (extractNodes(node, childFlag) === false) {
return false;
}
}
} else if (node.nodeType == 3) {
var textNode;
if (node == copyRange.startContainer) {
textNode = splitTextNode(node, copyRange.startOffset, node.nodeValue.length);
} else if (node == copyRange.endContainer) {
textNode = splitTextNode(node, 0, copyRange.endOffset);
} else {
textNode = splitTextNode(node, 0, node.nodeValue.length);
}
if (isCopy) {
try {
frag.appendChild(textNode);
} catch(e) {}
}
}
}
node = nextNode;
}
}
extractNodes(ancestor, frag);
if (isDelete) {
range.up().collapse(true);
}
for (var i = 0, len = nodeList.length; i < len; i++) {
var node = nodeList[i];
if (node.parentNode) {
node.parentNode.removeChild(node);
}
}
return isCopy ? frag : range;
}
function _moveToElementText(range, el) {
var node = el;
while (node) {
var knode = K(node);
if (knode.name == 'marquee' || knode.name == 'select') {
return;
}
node = node.parentNode;
}
try {
range.moveToElementText(el);
} catch(e) {}
}
function _getStartEnd(rng, isStart) {
var doc = rng.parentElement().ownerDocument,
pointRange = rng.duplicate();
pointRange.collapse(isStart);
var parent = pointRange.parentElement(),
nodes = parent.childNodes;
if (nodes.length === 0) {
return {node: parent.parentNode, offset: K(parent).index()};
}
var startNode = doc, startPos = 0, cmp = -1;
var testRange = rng.duplicate();
_moveToElementText(testRange, parent);
for (var i = 0, len = nodes.length; i < len; i++) {
var node = nodes[i];
cmp = testRange.compareEndPoints('StartToStart', pointRange);
if (cmp === 0) {
return {node: node.parentNode, offset: i};
}
if (node.nodeType == 1) {
var nodeRange = rng.duplicate(), dummy, knode = K(node), newNode = node;
if (knode.isControl()) {
dummy = doc.createElement('span');
knode.after(dummy);
newNode = dummy;
startPos += knode.text().replace(/\r\n|\n|\r/g, '').length;
}
_moveToElementText(nodeRange, newNode);
testRange.setEndPoint('StartToEnd', nodeRange);
if (cmp > 0) {
startPos += nodeRange.text.replace(/\r\n|\n|\r/g, '').length;
} else {
startPos = 0;
}
if (dummy) {
K(dummy).remove();
}
} else if (node.nodeType == 3) {
testRange.moveStart('character', node.nodeValue.length);
startPos += node.nodeValue.length;
}
if (cmp < 0) {
startNode = node;
}
}
if (cmp < 0 && startNode.nodeType == 1) {
return {node: parent, offset: K(parent.lastChild).index() + 1};
}
if (cmp > 0) {
while (startNode.nextSibling && startNode.nodeType == 1) {
startNode = startNode.nextSibling;
}
}
testRange = rng.duplicate();
_moveToElementText(testRange, parent);
testRange.setEndPoint('StartToEnd', pointRange);
startPos -= testRange.text.replace(/\r\n|\n|\r/g, '').length;
return {node: startNode, offset: startPos};
}
function _getEndRange(node, offset) {
var doc = node.ownerDocument || node,
range = doc.body.createTextRange();
if (doc == node) {
range.collapse(true);
return range;
}
if (node.nodeType == 1 && node.childNodes.length > 0) {
var children = node.childNodes, isStart, child;
if (offset === 0) {
child = children[0];
isStart = true;
} else {
child = children[offset - 1];
isStart = false;
}
if (!child) {
return range;
}
if (K(child).name === 'head') {
if (offset === 1) {
isStart = true;
}
if (offset === 2) {
isStart = false;
}
range.collapse(isStart);
return range;
}
if (child.nodeType == 1) {
var kchild = K(child), span;
if (kchild.isControl()) {
span = doc.createElement('span');
if (isStart) {
kchild.before(span);
} else {
kchild.after(span);
}
child = span;
}
_moveToElementText(range, child);
range.collapse(isStart);
if (span) {
K(span).remove();
}
return range;
}
node = child;
offset = isStart ? 0 : child.nodeValue.length;
}
var dummy = doc.createElement('span');
K(node).before(dummy);
_moveToElementText(range, dummy);
range.moveStart('character', offset);
K(dummy).remove();
return range;
}
function _toRange(rng) {
var doc, range;
function tr2td(start) {
if (K(start.node).name == 'tr') {
start.node = start.node.cells[start.offset];
start.offset = 0;
}
}
if (_IE) {
if (rng.item) {
doc = _getDoc(rng.item(0));
range = new KRange(doc);
range.selectNode(rng.item(0));
return range;
}
doc = rng.parentElement().ownerDocument;
var start = _getStartEnd(rng, true),
end = _getStartEnd(rng, false);
tr2td(start);
tr2td(end);
range = new KRange(doc);
range.setStart(start.node, start.offset);
range.setEnd(end.node, end.offset);
return range;
}
var startContainer = rng.startContainer;
doc = startContainer.ownerDocument || startContainer;
range = new KRange(doc);
range.setStart(startContainer, rng.startOffset);
range.setEnd(rng.endContainer, rng.endOffset);
return range;
}
function KRange(doc) {
this.init(doc);
}
_extend(KRange, {
init : function(doc) {
var self = this;
self.startContainer = doc;
self.startOffset = 0;
self.endContainer = doc;
self.endOffset = 0;
self.collapsed = true;
self.doc = doc;
},
commonAncestor : function() {
function getParents(node) {
var parents = [];
while (node) {
parents.push(node);
node = node.parentNode;
}
return parents;
}
var parentsA = getParents(this.startContainer),
parentsB = getParents(this.endContainer),
i = 0, lenA = parentsA.length, lenB = parentsB.length, parentA, parentB;
while (++i) {
parentA = parentsA[lenA - i];
parentB = parentsB[lenB - i];
if (!parentA || !parentB || parentA !== parentB) {
break;
}
}
return parentsA[lenA - i + 1];
},
setStart : function(node, offset) {
var self = this, doc = self.doc;
self.startContainer = node;
self.startOffset = offset;
if (self.endContainer === doc) {
self.endContainer = node;
self.endOffset = offset;
}
return _updateCollapsed(this);
},
setEnd : function(node, offset) {
var self = this, doc = self.doc;
self.endContainer = node;
self.endOffset = offset;
if (self.startContainer === doc) {
self.startContainer = node;
self.startOffset = offset;
}
return _updateCollapsed(this);
},
setStartBefore : function(node) {
return this.setStart(node.parentNode || this.doc, K(node).index());
},
setStartAfter : function(node) {
return this.setStart(node.parentNode || this.doc, K(node).index() + 1);
},
setEndBefore : function(node) {
return this.setEnd(node.parentNode || this.doc, K(node).index());
},
setEndAfter : function(node) {
return this.setEnd(node.parentNode || this.doc, K(node).index() + 1);
},
selectNode : function(node) {
return this.setStartBefore(node).setEndAfter(node);
},
selectNodeContents : function(node) {
var knode = K(node);
if (knode.type == 3 || knode.isSingle()) {
return this.selectNode(node);
}
var children = knode.children();
if (children.length > 0) {
return this.setStartBefore(children[0][0]).setEndAfter(children[children.length - 1][0]);
}
return this.setStart(node, 0).setEnd(node, 0);
},
collapse : function(toStart) {
if (toStart) {
return this.setEnd(this.startContainer, this.startOffset);
}
return this.setStart(this.endContainer, this.endOffset);
},
compareBoundaryPoints : function(how, range) {
var rangeA = this.get(), rangeB = range.get();
if (_IE) {
var arr = {};
arr[_START_TO_START] = 'StartToStart';
arr[_START_TO_END] = 'EndToStart';
arr[_END_TO_END] = 'EndToEnd';
arr[_END_TO_START] = 'StartToEnd';
var cmp = rangeA.compareEndPoints(arr[how], rangeB);
if (cmp !== 0) {
return cmp;
}
var nodeA, nodeB, nodeC, posA, posB;
if (how === _START_TO_START || how === _END_TO_START) {
nodeA = this.startContainer;
posA = this.startOffset;
}
if (how === _START_TO_END || how === _END_TO_END) {
nodeA = this.endContainer;
posA = this.endOffset;
}
if (how === _START_TO_START || how === _START_TO_END) {
nodeB = range.startContainer;
posB = range.startOffset;
}
if (how === _END_TO_END || how === _END_TO_START) {
nodeB = range.endContainer;
posB = range.endOffset;
}
if (nodeA === nodeB) {
var diff = posA - posB;
return diff > 0 ? 1 : (diff < 0 ? -1 : 0);
}
nodeC = nodeB;
while (nodeC && nodeC.parentNode !== nodeA) {
nodeC = nodeC.parentNode;
}
if (nodeC) {
return K(nodeC).index() >= posA ? -1 : 1;
}
nodeC = nodeA;
while (nodeC && nodeC.parentNode !== nodeB) {
nodeC = nodeC.parentNode;
}
if (nodeC) {
return K(nodeC).index() >= posB ? 1 : -1;
}
nodeC = K(nodeB).next();
if (nodeC && nodeC.contains(nodeA)) {
return 1;
}
nodeC = K(nodeA).next();
if (nodeC && nodeC.contains(nodeB)) {
return -1;
}
} else {
return rangeA.compareBoundaryPoints(how, rangeB);
}
},
cloneRange : function() {
return new KRange(this.doc).setStart(this.startContainer, this.startOffset).setEnd(this.endContainer, this.endOffset);
},
toString : function() {
var rng = this.get(), str = _IE ? rng.text : rng.toString();
return str.replace(/\r\n|\n|\r/g, '');
},
cloneContents : function() {
return _copyAndDelete(this, true, false);
},
deleteContents : function() {
return _copyAndDelete(this, false, true);
},
extractContents : function() {
return _copyAndDelete(this, true, true);
},
insertNode : function(node) {
var self = this,
sc = self.startContainer, so = self.startOffset,
ec = self.endContainer, eo = self.endOffset,
firstChild, lastChild, c, nodeCount = 1;
if (node.nodeName.toLowerCase() === '#document-fragment') {
firstChild = node.firstChild;
lastChild = node.lastChild;
nodeCount = node.childNodes.length;
}
if (sc.nodeType == 1) {
c = sc.childNodes[so];
if (c) {
sc.insertBefore(node, c);
if (sc === ec) {
eo += nodeCount;
}
} else {
sc.appendChild(node);
}
} else if (sc.nodeType == 3) {
if (so === 0) {
sc.parentNode.insertBefore(node, sc);
if (sc.parentNode === ec) {
eo += nodeCount;
}
} else if (so >= sc.nodeValue.length) {
if (sc.nextSibling) {
sc.parentNode.insertBefore(node, sc.nextSibling);
} else {
sc.parentNode.appendChild(node);
}
} else {
if (so > 0) {
c = sc.splitText(so);
} else {
c = sc;
}
sc.parentNode.insertBefore(node, c);
if (sc === ec) {
ec = c;
eo -= so;
}
}
}
if (firstChild) {
self.setStartBefore(firstChild).setEndAfter(lastChild);
} else {
self.selectNode(node);
}
if (self.compareBoundaryPoints(_END_TO_END, self.cloneRange().setEnd(ec, eo)) >= 1) {
return self;
}
return self.setEnd(ec, eo);
},
surroundContents : function(node) {
node.appendChild(this.extractContents());
return this.insertNode(node).selectNode(node);
},
isControl : function() {
var self = this,
sc = self.startContainer, so = self.startOffset,
ec = self.endContainer, eo = self.endOffset, rng;
return sc.nodeType == 1 && sc === ec && so + 1 === eo && K(sc.childNodes[so]).isControl();
},
get : function(hasControlRange) {
var self = this, doc = self.doc, node, rng;
if (!_IE) {
rng = doc.createRange();
try {
rng.setStart(self.startContainer, self.startOffset);
rng.setEnd(self.endContainer, self.endOffset);
} catch (e) {}
return rng;
}
if (hasControlRange && self.isControl()) {
rng = doc.body.createControlRange();
rng.addElement(self.startContainer.childNodes[self.startOffset]);
return rng;
}
var range = self.cloneRange().down();
rng = doc.body.createTextRange();
rng.setEndPoint('StartToStart', _getEndRange(range.startContainer, range.startOffset));
rng.setEndPoint('EndToStart', _getEndRange(range.endContainer, range.endOffset));
return rng;
},
html : function() {
return K(this.cloneContents()).outer();
},
down : function() {
var self = this;
function downPos(node, pos, isStart) {
if (node.nodeType != 1) {
return;
}
var children = K(node).children();
if (children.length === 0) {
return;
}
var left, right, child, offset;
if (pos > 0) {
left = children[pos - 1];
}
if (pos < children.length) {
right = children[pos];
}
if (left && left.type == 3) {
child = left[0];
offset = child.nodeValue.length;
}
if (right && right.type == 3) {
child = right[0];
offset = 0;
}
if (!child) {
return;
}
if (isStart) {
self.setStart(child, offset);
} else {
self.setEnd(child, offset);
}
}
downPos(self.startContainer, self.startOffset, true);
downPos(self.endContainer, self.endOffset, false);
return self;
},
up : function() {
var self = this;
function upPos(node, pos, isStart) {
if (node.nodeType != 3) {
return;
}
if (pos === 0) {
if (isStart) {
self.setStartBefore(node);
} else {
self.setEndBefore(node);
}
} else if (pos == node.nodeValue.length) {
if (isStart) {
self.setStartAfter(node);
} else {
self.setEndAfter(node);
}
}
}
upPos(self.startContainer, self.startOffset, true);
upPos(self.endContainer, self.endOffset, false);
return self;
},
enlarge : function(toBlock) {
var self = this;
self.up();
function enlargePos(node, pos, isStart) {
var knode = K(node), parent;
if (knode.type == 3 || _NOSPLIT_TAG_MAP[knode.name] || !toBlock && knode.isBlock()) {
return;
}
if (pos === 0) {
while (!knode.prev()) {
parent = knode.parent();
if (!parent || _NOSPLIT_TAG_MAP[parent.name] || !toBlock && parent.isBlock()) {
break;
}
knode = parent;
}
if (isStart) {
self.setStartBefore(knode[0]);
} else {
self.setEndBefore(knode[0]);
}
} else if (pos == knode.children().length) {
while (!knode.next()) {
parent = knode.parent();
if (!parent || _NOSPLIT_TAG_MAP[parent.name] || !toBlock && parent.isBlock()) {
break;
}
knode = parent;
}
if (isStart) {
self.setStartAfter(knode[0]);
} else {
self.setEndAfter(knode[0]);
}
}
}
enlargePos(self.startContainer, self.startOffset, true);
enlargePos(self.endContainer, self.endOffset, false);
return self;
},
createBookmark : function(serialize) {
var self = this, doc = self.doc, endNode,
startNode = K('<span style="display:none;"></span>', doc)[0];
startNode.id = '__kindeditor_bookmark_start_' + (_BOOKMARK_ID++) + '__';
if (!self.collapsed) {
endNode = startNode.cloneNode(true);
endNode.id = '__kindeditor_bookmark_end_' + (_BOOKMARK_ID++) + '__';
}
if (endNode) {
self.cloneRange().collapse(false).insertNode(endNode).setEndBefore(endNode);
}
self.insertNode(startNode).setStartAfter(startNode);
return {
start : serialize ? '#' + startNode.id : startNode,
end : endNode ? (serialize ? '#' + endNode.id : endNode) : null
};
},
moveToBookmark : function(bookmark) {
var self = this, doc = self.doc,
start = K(bookmark.start, doc), end = bookmark.end ? K(bookmark.end, doc) : null;
if (!start || start.length < 1) {
return self;
}
self.setStartBefore(start[0]);
start.remove();
if (end && end.length > 0) {
self.setEndBefore(end[0]);
end.remove();
} else {
self.collapse(true);
}
return self;
},
dump : function() {
console.log('--------------------');
console.log(this.startContainer.nodeType == 3 ? this.startContainer.nodeValue : this.startContainer, this.startOffset);
console.log(this.endContainer.nodeType == 3 ? this.endContainer.nodeValue : this.endContainer, this.endOffset);
}
});
function _range(mixed) {
if (!mixed.nodeName) {
return mixed.get ? mixed : _toRange(mixed);
}
return new KRange(mixed);
}
K.range = _range;
K.START_TO_START = _START_TO_START;
K.START_TO_END = _START_TO_END;
K.END_TO_END = _END_TO_END;
K.END_TO_START = _END_TO_START;
function _nativeCommand(doc, key, val) {
try {
doc.execCommand(key, false, val);
} catch(e) {}
}
function _nativeCommandValue(doc, key) {
var val = '';
try {
val = doc.queryCommandValue(key);
} catch (e) {}
if (typeof val !== 'string') {
val = '';
}
return val;
}
function _getSel(doc) {
var win = _getWin(doc);
return doc.selection || win.getSelection();
}
function _getRng(doc) {
var sel = _getSel(doc), rng;
try {
if (sel.rangeCount > 0) {
rng = sel.getRangeAt(0);
} else {
rng = sel.createRange();
}
} catch(e) {}
if (_IE && (!rng || (!rng.item && rng.parentElement().ownerDocument !== doc))) {
return null;
}
return rng;
}
function _singleKeyMap(map) {
var newMap = {}, arr, v;
_each(map, function(key, val) {
arr = key.split(',');
for (var i = 0, len = arr.length; i < len; i++) {
v = arr[i];
newMap[v] = val;
}
});
return newMap;
}
function _hasAttrOrCss(knode, map) {
return _hasAttrOrCssByKey(knode, map, '*') || _hasAttrOrCssByKey(knode, map);
}
function _hasAttrOrCssByKey(knode, map, mapKey) {
mapKey = mapKey || knode.name;
if (knode.type !== 1) {
return false;
}
var newMap = _singleKeyMap(map);
if (!newMap[mapKey]) {
return false;
}
var arr = newMap[mapKey].split(',');
for (var i = 0, len = arr.length; i < len; i++) {
var key = arr[i];
if (key === '*') {
return true;
}
var match = /^(\.?)([^=]+)(?:=([^=]*))?$/.exec(key);
var method = match[1] ? 'css' : 'attr';
key = match[2];
var val = match[3] || '';
if (val === '' && knode[method](key) !== '') {
return true;
}
if (val !== '' && knode[method](key) === val) {
return true;
}
}
return false;
}
function _removeAttrOrCss(knode, map) {
if (knode.type != 1) {
return;
}
_removeAttrOrCssByKey(knode, map, '*');
_removeAttrOrCssByKey(knode, map);
}
function _removeAttrOrCssByKey(knode, map, mapKey) {
mapKey = mapKey || knode.name;
if (knode.type !== 1) {
return;
}
var newMap = _singleKeyMap(map);
if (!newMap[mapKey]) {
return;
}
var arr = newMap[mapKey].split(','), allFlag = false;
for (var i = 0, len = arr.length; i < len; i++) {
var key = arr[i];
if (key === '*') {
allFlag = true;
break;
}
var match = /^(\.?)([^=]+)(?:=([^=]*))?$/.exec(key);
key = match[2];
if (match[1]) {
key = _toCamel(key);
if (knode[0].style[key]) {
knode[0].style[key] = '';
}
} else {
knode.removeAttr(key);
}
}
if (allFlag) {
knode.remove(true);
}
}
function _getInnerNode(knode) {
var inner = knode;
while (inner.first()) {
inner = inner.first();
}
return inner;
}
function _isEmptyNode(knode) {
return _getInnerNode(knode).isStyle();
}
function _mergeWrapper(a, b) {
a = a.clone(true);
var lastA = _getInnerNode(a), childA = a, merged = false;
while (b) {
while (childA) {
if (childA.name === b.name) {
_mergeAttrs(childA, b.attr(), b.css());
merged = true;
}
childA = childA.first();
}
if (!merged) {
lastA.append(b.clone(false));
}
merged = false;
b = b.first();
}
return a;
}
function _wrapNode(knode, wrapper) {
wrapper = wrapper.clone(true);
if (knode.type == 3) {
_getInnerNode(wrapper).append(knode.clone(false));
knode.replaceWith(wrapper);
return wrapper;
}
var nodeWrapper = knode, child;
while ((child = knode.first()) && child.children().length == 1) {
knode = child;
}
child = knode.first();
var frag = knode.doc.createDocumentFragment();
while (child) {
frag.appendChild(child[0]);
child = child.next();
}
wrapper = _mergeWrapper(nodeWrapper, wrapper);
if (frag.firstChild) {
_getInnerNode(wrapper).append(frag);
}
nodeWrapper.replaceWith(wrapper);
return wrapper;
}
function _mergeAttrs(knode, attrs, styles) {
_each(attrs, function(key, val) {
if (key !== 'style') {
knode.attr(key, val);
}
});
_each(styles, function(key, val) {
knode.css(key, val);
});
}
function _inPreElement(knode) {
while (knode && knode.name != 'body') {
if (_PRE_TAG_MAP[knode.name] || knode.name == 'div' && knode.hasClass('ke-script')) {
return true;
}
knode = knode.parent();
}
return false;
}
function KCmd(range) {
this.init(range);
}
_extend(KCmd, {
init : function(range) {
var self = this, doc = range.doc;
self.doc = doc;
self.win = _getWin(doc);
self.sel = _getSel(doc);
self.range = range;
},
selection : function(forceReset) {
var self = this, doc = self.doc, rng = _getRng(doc);
self.sel = _getSel(doc);
if (rng) {
self.range = _range(rng);
if (K(self.range.startContainer).name == 'html') {
self.range.selectNodeContents(doc.body).collapse(false);
}
return self;
}
if (forceReset) {
self.range.selectNodeContents(doc.body).collapse(false);
}
return self;
},
select : function() {
var self = this, sel = self.sel, range = self.range.cloneRange(),
sc = range.startContainer, so = range.startOffset,
ec = range.endContainer, eo = range.endOffset,
doc = _getDoc(sc), win = self.win, rng;
if (sc.nodeType == 1 && range.collapsed) {
if (_IE) {
var dummy = K('<span> </span>', doc);
range.insertNode(dummy[0]);
rng = doc.body.createTextRange();
try {
rng.moveToElementText(dummy[0]);
} catch(ex) {}
rng.collapse(false);
rng.select();
dummy.remove();
win.focus();
return self;
}
if (_WEBKIT) {
var children = sc.childNodes;
if (K(sc).isInline() || so > 0 && K(children[so - 1]).isInline() || children[so] && K(children[so]).isInline()) {
range.insertNode(doc.createTextNode('\u200B'));
}
}
}
rng = range.get(true);
if (_IE) {
try {
rng.select();
} catch(e) {}
} else {
sel.removeAllRanges();
sel.addRange(rng);
}
win.focus();
return self;
},
wrap : function(val) {
var self = this, doc = self.doc, range = self.range, wrapper;
wrapper = K(val, doc);
if (range.collapsed) {
range.insertNode(wrapper[0]).selectNodeContents(wrapper[0]);
return self;
}
if (wrapper.isBlock()) {
var copyWrapper = wrapper.clone(true), child = copyWrapper;
while (child.first()) {
child = child.first();
}
child.append(range.extractContents());
range.insertNode(copyWrapper[0]).selectNode(copyWrapper[0]);
return self;
}
range.enlarge();
var bookmark = range.createBookmark(), ancestor = range.commonAncestor(), isStart = false;
K(ancestor).scan(function(node) {
if (!isStart && node == bookmark.start) {
isStart = true;
return;
}
if (isStart) {
if (node == bookmark.end) {
return false;
}
var knode = K(node);
if (_inPreElement(knode)) {
return;
}
if (knode.type == 3 && _trim(node.nodeValue).length > 0) {
var parent;
while ((parent = knode.parent()) && parent.isStyle() && parent.children().length == 1) {
knode = parent;
}
_wrapNode(knode, wrapper);
}
}
});
range.moveToBookmark(bookmark);
return self;
},
split : function(isStart, map) {
var range = this.range, doc = range.doc;
var tempRange = range.cloneRange().collapse(isStart);
var node = tempRange.startContainer, pos = tempRange.startOffset,
parent = node.nodeType == 3 ? node.parentNode : node,
needSplit = false, knode;
while (parent && parent.parentNode) {
knode = K(parent);
if (map) {
if (!knode.isStyle()) {
break;
}
if (!_hasAttrOrCss(knode, map)) {
break;
}
} else {
if (_NOSPLIT_TAG_MAP[knode.name]) {
break;
}
}
needSplit = true;
parent = parent.parentNode;
}
if (needSplit) {
var dummy = doc.createElement('span');
range.cloneRange().collapse(!isStart).insertNode(dummy);
if (isStart) {
tempRange.setStartBefore(parent.firstChild).setEnd(node, pos);
} else {
tempRange.setStart(node, pos).setEndAfter(parent.lastChild);
}
var frag = tempRange.extractContents(),
first = frag.firstChild, last = frag.lastChild;
if (isStart) {
tempRange.insertNode(frag);
range.setStartAfter(last).setEndBefore(dummy);
} else {
parent.appendChild(frag);
range.setStartBefore(dummy).setEndBefore(first);
}
var dummyParent = dummy.parentNode;
if (dummyParent == range.endContainer) {
var prev = K(dummy).prev(), next = K(dummy).next();
if (prev && next && prev.type == 3 && next.type == 3) {
range.setEnd(prev[0], prev[0].nodeValue.length);
} else if (!isStart) {
range.setEnd(range.endContainer, range.endOffset - 1);
}
}
dummyParent.removeChild(dummy);
}
return this;
},
remove : function(map) {
var self = this, doc = self.doc, range = self.range;
if (range.collapsed) {
self.split(true, map);
range.collapse(true);
return self;
}
range.enlarge();
if (range.startOffset === 0) {
var ksc = K(range.startContainer), parent;
while ((parent = ksc.parent()) && parent.isStyle() && parent.children().length == 1) {
ksc = parent;
}
range.setStart(ksc[0], 0);
ksc = K(range.startContainer);
if (ksc.isBlock()) {
_removeAttrOrCss(ksc, map);
}
var kscp = ksc.parent();
if (kscp && kscp.isBlock()) {
_removeAttrOrCss(kscp, map);
}
}
self.split(true, map);
self.split(false, map);
var startDummy = doc.createElement('span'), endDummy = doc.createElement('span');
range.cloneRange().collapse(false).insertNode(endDummy);
range.cloneRange().collapse(true).insertNode(startDummy);
var nodeList = [], cmpStart = false;
K(range.commonAncestor()).scan(function(node) {
if (!cmpStart && node == startDummy) {
cmpStart = true;
return;
}
if (node == endDummy) {
return false;
}
if (cmpStart) {
nodeList.push(node);
}
});
K(startDummy).remove();
K(endDummy).remove();
var sc = range.startContainer, so = range.startOffset,
ec = range.endContainer, eo = range.endOffset;
if (so > 0) {
var startBefore = K(sc.childNodes[so - 1]);
if (startBefore && _isEmptyNode(startBefore)) {
startBefore.remove();
range.setStart(sc, so - 1);
if (sc == ec) {
range.setEnd(ec, eo - 1);
}
}
var startAfter = K(sc.childNodes[so]);
if (startAfter && _isEmptyNode(startAfter)) {
startAfter.remove();
if (sc == ec) {
range.setEnd(ec, eo - 1);
}
}
}
var endAfter = K(ec.childNodes[range.endOffset]);
if (endAfter && _isEmptyNode(endAfter)) {
endAfter.remove();
}
var bookmark = range.createBookmark(true);
_each(nodeList, function(i, node) {
_removeAttrOrCss(K(node), map);
});
range.moveToBookmark(bookmark);
return self;
},
commonNode : function(map) {
var range = this.range,
ec = range.endContainer, eo = range.endOffset,
node = (ec.nodeType == 3 || eo === 0) ? ec : ec.childNodes[eo - 1],
child = node, parent = node;
while (parent) {
if (_hasAttrOrCss(K(parent), map)) {
return K(parent);
}
parent = parent.parentNode;
}
while (child && (child = child.firstChild) && child.childNodes.length == 1) {
if (_hasAttrOrCss(K(child), map)) {
return K(child);
}
}
if (node.nodeType == 1 || (ec.nodeType == 3 && eo === 0)) {
var prev = K(node).prev();
if (prev && _hasAttrOrCss(prev, map)) {
return prev;
}
}
return null;
},
commonAncestor : function(tagName) {
var range = this.range,
sc = range.startContainer, so = range.startOffset,
ec = range.endContainer, eo = range.endOffset,
startNode = (sc.nodeType == 3 || so === 0) ? sc : sc.childNodes[so - 1],
endNode = (ec.nodeType == 3 || eo === 0) ? ec : ec.childNodes[eo - 1];
function find(node) {
while (node) {
if (node.nodeType == 1) {
if (node.tagName.toLowerCase() === tagName) {
return node;
}
}
node = node.parentNode;
}
return null;
}
var start = find(startNode), end = find(endNode);
if (start && end && start === end) {
return K(start);
}
return null;
},
state : function(key) {
var self = this, doc = self.doc, bool = false;
try {
bool = doc.queryCommandState(key);
} catch (e) {}
return bool;
},
val : function(key) {
var self = this, doc = self.doc, range = self.range;
function lc(val) {
return val.toLowerCase();
}
key = lc(key);
var val = '', knode;
if (key === 'fontfamily' || key === 'fontname') {
val = _nativeCommandValue(doc, 'fontname');
val = val.replace(/['"]/g, '');
return lc(val);
}
if (key === 'formatblock') {
val = _nativeCommandValue(doc, key);
if (val === '') {
knode = self.commonNode({'h1,h2,h3,h4,h5,h6,p,div,pre,address' : '*'});
if (knode) {
val = knode.name;
}
}
if (val === 'Normal') {
val = 'p';
}
return lc(val);
}
if (key === 'fontsize') {
knode = self.commonNode({'*' : '.font-size'});
if (knode) {
val = knode.css('font-size');
}
return lc(val);
}
if (key === 'forecolor') {
knode = self.commonNode({'*' : '.color'});
if (knode) {
val = knode.css('color');
}
val = _toHex(val);
if (val === '') {
val = 'default';
}
return lc(val);
}
if (key === 'hilitecolor') {
knode = self.commonNode({'*' : '.background-color'});
if (knode) {
val = knode.css('background-color');
}
val = _toHex(val);
if (val === '') {
val = 'default';
}
return lc(val);
}
return val;
},
toggle : function(wrapper, map) {
var self = this;
if (self.commonNode(map)) {
self.remove(map);
} else {
self.wrap(wrapper);
}
return self.select();
},
bold : function() {
return this.toggle('<strong></strong>', {
span : '.font-weight=bold',
strong : '*',
b : '*'
});
},
italic : function() {
return this.toggle('<em></em>', {
span : '.font-style=italic',
em : '*',
i : '*'
});
},
underline : function() {
return this.toggle('<u></u>', {
span : '.text-decoration=underline',
u : '*'
});
},
strikethrough : function() {
return this.toggle('<s></s>', {
span : '.text-decoration=line-through',
s : '*'
});
},
forecolor : function(val) {
return this.toggle('<span style="color:' + val + ';"></span>', {
span : '.color=' + val,
font : 'color'
});
},
hilitecolor : function(val) {
return this.toggle('<span style="background-color:' + val + ';"></span>', {
span : '.background-color=' + val
});
},
fontsize : function(val) {
return this.toggle('<span style="font-size:' + val + ';"></span>', {
span : '.font-size=' + val,
font : 'size'
});
},
fontname : function(val) {
return this.fontfamily(val);
},
fontfamily : function(val) {
return this.toggle('<span style="font-family:' + val + ';"></span>', {
span : '.font-family=' + val,
font : 'face'
});
},
removeformat : function() {
var map = {
'*' : '.font-weight,.font-style,.text-decoration,.color,.background-color,.font-size,.font-family'
},
tags = _STYLE_TAG_MAP;
_each(tags, function(key, val) {
map[key] = '*';
});
this.remove(map);
return this.select();
},
inserthtml : function(val) {
var self = this, range = self.range;
if (val === '') {
return self;
}
if (_inPreElement(K(range.startContainer))) {
return self;
}
function pasteHtml(range, val) {
val = '<img id="__kindeditor_temp_tag__" width="0" height="0" style="display:none;" />' + val;
var rng = range.get();
if (rng.item) {
rng.item(0).outerHTML = val;
} else {
rng.pasteHTML(val);
}
var temp = range.doc.getElementById('__kindeditor_temp_tag__');
temp.parentNode.removeChild(temp);
var newRange = _toRange(rng);
range.setEnd(newRange.endContainer, newRange.endOffset);
range.collapse(false);
self.select();
}
function insertHtml(range, val) {
var doc = range.doc,
frag = doc.createDocumentFragment();
K('@' + val, doc).each(function() {
frag.appendChild(this);
});
range.deleteContents();
range.insertNode(frag);
range.collapse(false);
self.select();
}
if (_IE) {
try {
pasteHtml(range, val);
} catch(e) {
insertHtml(range, val);
}
return self;
}
insertHtml(range, val);
return self;
},
hr : function() {
return this.inserthtml('<hr />');
},
print : function() {
this.win.print();
return this;
},
insertimage : function(url, title, width, height, border, align) {
title = _undef(title, '');
border = _undef(border, 0);
var html = '<img src="' + _escape(url) + '" data-ke-src="' + _escape(url) + '" ';
if (width) {
html += 'width="' + _escape(width) + '" ';
}
if (height) {
html += 'height="' + _escape(height) + '" ';
}
if (title) {
html += 'title="' + _escape(title) + '" ';
}
if (align) {
html += 'align="' + _escape(align) + '" ';
}
html += 'alt="' + _escape(title) + '" ';
html += '/>';
return this.inserthtml(html);
},
createlink : function(url, type) {
var self = this, doc = self.doc, range = self.range;
self.select();
var a = self.commonNode({ a : '*' });
if (a && !range.isControl()) {
range.selectNode(a.get());
self.select();
}
if (range.collapsed) {
var html = '<a href="' + _escape(url) + '" data-ke-src="' + _escape(url) + '" ';
if (type) {
html += ' target="' + _escape(type) + '"';
}
html += '>' + _escape(url) + '</a>';
self.inserthtml(html);
} else {
_nativeCommand(doc, 'createlink', '__kindeditor_temp_url__');
a = self.commonNode({ a : '*' });
K('a[href="__kindeditor_temp_url__"]', a ? a.parent() : doc).each(function() {
K(this).attr('href', url).attr('data-ke-src', url);
if (type) {
K(this).attr('target', type);
} else {
K(this).removeAttr('target');
}
});
}
return self;
},
unlink : function() {
var self = this, doc = self.doc, range = self.range;
self.select();
if (range.collapsed) {
var a = self.commonNode({ a : '*' });
if (a) {
range.selectNode(a.get());
self.select();
}
_nativeCommand(doc, 'unlink', null);
if (_WEBKIT && K(range.startContainer).name === 'img') {
var parent = K(range.startContainer).parent();
if (parent.name === 'a') {
parent.remove(true);
}
}
} else {
_nativeCommand(doc, 'unlink', null);
}
return self;
}
});
_each(('formatblock,selectall,justifyleft,justifycenter,justifyright,justifyfull,insertorderedlist,' +
'insertunorderedlist,indent,outdent,subscript,superscript').split(','), function(i, name) {
KCmd.prototype[name] = function(val) {
var self = this;
if (_IE) {
rng = self.range.get(true);
try {
rng.select();
} catch(e) {}
}
_nativeCommand(self.doc, name, val);
if (!_IE || _inArray(name, 'formatblock,selectall,insertorderedlist,insertunorderedlist'.split(',')) >= 0) {
self.selection();
}
return self;
};
});
_each('cut,copy,paste'.split(','), function(i, name) {
KCmd.prototype[name] = function() {
var self = this;
if (!self.doc.queryCommandSupported(name)) {
throw 'not supported';
}
if (_IE) {
rng = self.range.get(true);
try {
rng.select();
} catch(e) {}
}
_nativeCommand(self.doc, name, null);
return self;
};
});
function _cmd(mixed) {
if (mixed.nodeName) {
var doc = _getDoc(mixed);
mixed = _range(doc).selectNodeContents(doc.body).collapse(false);
}
return new KCmd(mixed);
}
K.cmd = _cmd;
function _drag(options) {
var moveEl = options.moveEl,
moveFn = options.moveFn,
clickEl = options.clickEl || moveEl,
beforeDrag = options.beforeDrag,
iframeFix = options.iframeFix === undefined ? true : options.iframeFix;
var docs = [document],
poss = [{ x : 0, y : 0}],
listeners = [];
if (iframeFix) {
K('iframe').each(function() {
try {
docs.push(_iframeDoc(this));
} catch (e) {}
poss.push(K(this).pos());
});
}
clickEl.mousedown(function(e) {
var self = clickEl.get(),
x = _removeUnit(moveEl.css('left')),
y = _removeUnit(moveEl.css('top')),
width = moveEl.width(),
height = moveEl.height(),
pageX = e.pageX,
pageY = e.pageY,
dragging = true;
if (beforeDrag) {
beforeDrag();
}
_each(docs, function(i, doc) {
function moveListener(e) {
if (dragging) {
var diffX = _round(poss[i].x + e.pageX - pageX),
diffY = _round(poss[i].y + e.pageY - pageY);
moveFn.call(clickEl, x, y, width, height, diffX, diffY);
}
e.stop();
}
function selectListener(e) {
e.stop();
}
function upListener(e) {
dragging = false;
if (self.releaseCapture) {
self.releaseCapture();
}
_each(listeners, function() {
K(this.doc).unbind('mousemove', this.move)
.unbind('mouseup', this.up)
.unbind('selectstart', this.select);
});
e.stop();
}
K(doc).mousemove(moveListener)
.mouseup(upListener)
.bind('selectstart', selectListener);
listeners.push({
doc : doc,
move : moveListener,
up : upListener,
select : selectListener
});
});
if (self.setCapture) {
self.setCapture();
}
e.stop();
});
}
function KWidget(options) {
this.init(options);
}
_extend(KWidget, {
init : function(options) {
var self = this;
self.name = options.name || '';
self.doc = options.doc || document;
self.win = _getWin(self.doc);
self.x = _addUnit(options.x);
self.y = _addUnit(options.y);
self.z = options.z;
self.width = _addUnit(options.width);
self.height = _addUnit(options.height);
self.div = K('<div style="display:block;"></div>');
self.options = options;
self._alignEl = options.alignEl;
if (self.width) {
self.div.css('width', self.width);
}
if (self.height) {
self.div.css('height', self.height);
}
if (self.z) {
self.div.css({
position : 'absolute',
left : self.x,
top : self.y,
'z-index' : self.z
});
}
if (self.z && (self.x === undefined || self.y === undefined)) {
self.autoPos(self.width, self.height);
}
if (options.cls) {
self.div.addClass(options.cls);
}
if (options.css) {
self.div.css(options.css);
}
if (options.src) {
K(options.src).hide().after(self.div);
} else {
K(self.doc.body).append(self.div);
}
if (options.html) {
self.div.html(options.html);
}
if (options.autoScroll) {
if (_IE && _V < 7 || _QUIRKS) {
var scrollPos = _getScrollPos();
K(self.win).bind('scroll', function(e) {
var pos = _getScrollPos(),
diffX = pos.x - scrollPos.x,
diffY = pos.y - scrollPos.y;
self.pos(_removeUnit(self.x) + diffX, _removeUnit(self.y) + diffY, false);
});
} else {
self.div.css('position', 'fixed');
}
}
},
pos : function(x, y, updateProp) {
var self = this;
updateProp = _undef(updateProp, true);
if (x !== null) {
x = x < 0 ? 0 : _addUnit(x);
self.div.css('left', x);
if (updateProp) {
self.x = x;
}
}
if (y !== null) {
y = y < 0 ? 0 : _addUnit(y);
self.div.css('top', y);
if (updateProp) {
self.y = y;
}
}
return self;
},
autoPos : function(width, height) {
var self = this,
w = _removeUnit(width) || 0,
h = _removeUnit(height) || 0,
scrollPos = _getScrollPos();
if (self._alignEl) {
var knode = K(self._alignEl),
pos = knode.pos(),
diffX = _round(knode[0].clientWidth / 2 - w / 2),
diffY = _round(knode[0].clientHeight / 2 - h / 2);
x = diffX < 0 ? pos.x : pos.x + diffX;
y = diffY < 0 ? pos.y : pos.y + diffY;
} else {
var docEl = _docElement(self.doc);
x = _round(scrollPos.x + (docEl.clientWidth - w) / 2);
y = _round(scrollPos.y + (docEl.clientHeight - h) / 2);
}
if (!(_IE && _V < 7 || _QUIRKS)) {
x -= scrollPos.x;
y -= scrollPos.y;
}
return self.pos(x, y);
},
remove : function() {
var self = this;
if (_IE && _V < 7) {
K(self.win).unbind('scroll');
}
self.div.remove();
_each(self, function(i) {
self[i] = null;
});
return this;
},
show : function() {
this.div.show();
return this;
},
hide : function() {
this.div.hide();
return this;
},
draggable : function(options) {
var self = this;
options = options || {};
options.moveEl = self.div;
options.moveFn = function(x, y, width, height, diffX, diffY) {
if ((x = x + diffX) < 0) {
x = 0;
}
if ((y = y + diffY) < 0) {
y = 0;
}
self.pos(x, y);
};
_drag(options);
return self;
}
});
function _widget(options) {
return new KWidget(options);
}
K.widget = _widget;
function _iframeDoc(iframe) {
iframe = _get(iframe);
return iframe.contentDocument || iframe.contentWindow.document;
}
function _getInitHtml(themesPath, bodyClass, cssPath, cssData) {
var arr = [
'<html><head><meta charset="utf-8" /><title>KindEditor</title>',
'<style>',
'html {margin:0;padding:0;}',
'body {margin:0;padding:5px;}',
'body, td {font:12px/1.5 "sans serif",tahoma,verdana,helvetica;}',
'body, p, div {word-wrap: break-word;}',
'p {margin:5px 0;}',
'table {border-collapse:collapse;}',
'table.ke-zeroborder td {border:1px dotted #AAA;}',
'img.ke-flash {',
' border:1px solid #AAA;',
' background-image:url(' + themesPath + 'common/flash.gif);',
' background-position:center center;',
' background-repeat:no-repeat;',
' width:100px;',
' height:100px;',
'}',
'img.ke-rm {',
' border:1px solid #AAA;',
' background-image:url(' + themesPath + 'common/rm.gif);',
' background-position:center center;',
' background-repeat:no-repeat;',
' width:100px;',
' height:100px;',
'}',
'img.ke-media {',
' border:1px solid #AAA;',
' background-image:url(' + themesPath + 'common/media.gif);',
' background-position:center center;',
' background-repeat:no-repeat;',
' width:100px;',
' height:100px;',
'}',
'img.ke-anchor {',
' border:1px dashed #666;',
' width:16px;',
' height:16px;',
'}',
'.ke-script {',
' display:none;',
' font-size:0;',
' width:0;',
' height:0;',
'}',
'.ke-pagebreak {',
' border:1px dotted #AAA;',
' font-size:0;',
' height:2px;',
'}',
'</style>'
];
if (!_isArray(cssPath)) {
cssPath = [cssPath];
}
_each(cssPath, function(i, path) {
if (path) {
arr.push('<link href="' + path + '" rel="stylesheet" />');
}
});
if (cssData) {
arr.push('<style>' + cssData + '</style>');
}
arr.push('</head><body ' + (bodyClass ? 'class="' + bodyClass + '"' : '') + '></body></html>');
return arr.join('\n');
}
function _elementVal(knode, val) {
return knode.hasVal() ? knode.val(val) : knode.html(val);
}
function KEdit(options) {
this.init(options);
}
_extend(KEdit, KWidget, {
init : function(options) {
var self = this;
KEdit.parent.init.call(self, options);
self.srcElement = K(options.srcElement);
self.div.addClass('ke-edit');
self.designMode = _undef(options.designMode, true);
self.beforeGetHtml = options.beforeGetHtml;
self.beforeSetHtml = options.beforeSetHtml;
self.afterSetHtml = options.afterSetHtml;
var themesPath = _undef(options.themesPath, ''),
bodyClass = options.bodyClass,
cssPath = options.cssPath,
cssData = options.cssData,
isDocumentDomain = location.host.replace(/:\d+/, '') !== document.domain,
srcScript = ('document.open();' +
(isDocumentDomain ? 'document.domain="' + document.domain + '";' : '') +
'document.close();'),
iframeSrc = _IE ? ' src="javascript:void(function(){' + encodeURIComponent(srcScript) + '}())"' : '';
self.iframe = K('<iframe class="ke-edit-iframe" hidefocus="true" frameborder="0"' + iframeSrc + '></iframe>').css('width', '100%');
self.textarea = K('<textarea class="ke-edit-textarea" hidefocus="true"></textarea>').css('width', '100%');
if (self.width) {
self.setWidth(self.width);
}
if (self.height) {
self.setHeight(self.height);
}
if (self.designMode) {
self.textarea.hide();
} else {
self.iframe.hide();
}
function ready() {
var doc = _iframeDoc(self.iframe);
doc.open();
if (isDocumentDomain) {
doc.domain = document.domain;
}
doc.write(_getInitHtml(themesPath, bodyClass, cssPath, cssData));
doc.close();
self.win = self.iframe[0].contentWindow;
self.doc = doc;
var cmd = _cmd(doc);
self.afterChange(function(e) {
cmd.selection();
});
if (_WEBKIT) {
K(doc).click(function(e) {
if (K(e.target).name === 'img') {
cmd.selection(true);
cmd.range.selectNode(e.target);
cmd.select();
}
});
}
if (_IE) {
K(doc).keydown(function(e) {
if (e.which == 8) {
cmd.selection();
var rng = cmd.range;
if (rng.isControl()) {
rng.collapse(true);
K(rng.startContainer.childNodes[rng.startOffset]).remove();
e.preventDefault();
}
}
});
}
self.cmd = cmd;
self.html(_elementVal(self.srcElement));
if (_IE) {
doc.body.disabled = true;
doc.body.contentEditable = true;
doc.body.removeAttribute('disabled');
} else {
doc.designMode = 'on';
}
if (options.afterCreate) {
options.afterCreate.call(self);
}
}
if (isDocumentDomain) {
self.iframe.bind('load', function(e) {
self.iframe.unbind('load');
if (_IE) {
ready();
} else {
setTimeout(ready, 0);
}
});
}
self.div.append(self.iframe);
self.div.append(self.textarea);
self.srcElement.hide();
!isDocumentDomain && ready();
},
setWidth : function(val) {
this.div.css('width', _addUnit(val));
return this;
},
setHeight : function(val) {
var self = this;
val = _addUnit(val);
self.div.css('height', val);
self.iframe.css('height', val);
if ((_IE && _V < 8) || _QUIRKS) {
val = _addUnit(_removeUnit(val) - 2);
}
self.textarea.css('height', val);
return self;
},
remove : function() {
var self = this, doc = self.doc;
K(doc.body).unbind();
K(doc).unbind();
K(self.win).unbind();
_elementVal(self.srcElement, self.html());
self.srcElement.show();
doc.write('');
self.iframe.unbind();
self.textarea.unbind();
KEdit.parent.remove.call(self);
},
html : function(val, isFull) {
var self = this, doc = self.doc;
if (self.designMode) {
var body = doc.body;
if (val === undefined) {
if (isFull) {
val = '<!doctype html><html>' + body.parentNode.innerHTML + '</html>';
} else {
val = body.innerHTML;
}
if (self.beforeGetHtml) {
val = self.beforeGetHtml(val);
}
if (_GECKO && val == '<br />') {
val = '';
}
return val;
}
if (self.beforeSetHtml) {
val = self.beforeSetHtml(val);
}
K(body).html(val);
if (self.afterSetHtml) {
self.afterSetHtml();
}
return self;
}
if (val === undefined) {
return self.textarea.val();
}
self.textarea.val(val);
return self;
},
design : function(bool) {
var self = this, val;
if (bool === undefined ? !self.designMode : bool) {
if (!self.designMode) {
val = self.html();
self.designMode = true;
self.html(val);
self.textarea.hide();
self.iframe.show();
}
} else {
if (self.designMode) {
val = self.html();
self.designMode = false;
self.html(val);
self.iframe.hide();
self.textarea.show();
}
}
return self.focus();
},
focus : function() {
var self = this;
self.designMode ? self.win.focus() : self.textarea[0].focus();
return self;
},
blur : function() {
var self = this;
if (_IE) {
var input = K('<input type="text" style="float:left;width:0;height:0;padding:0;margin:0;border:0;" value="" />', self.div);
self.div.append(input);
input[0].focus();
input.remove();
} else {
self.designMode ? self.win.blur() : self.textarea[0].blur();
}
return self;
},
afterChange : function(fn) {
var self = this, doc = self.doc, body = doc.body;
K(doc).keyup(function(e) {
if (!e.ctrlKey && !e.altKey && _CHANGE_KEY_MAP[e.which]) {
fn(e);
}
});
K(doc).mouseup(fn).contextmenu(fn);
K(self.win).blur(fn);
function timeoutHandler(e) {
setTimeout(function() {
fn(e);
}, 1);
}
K(body).bind('paste', timeoutHandler);
K(body).bind('cut', timeoutHandler);
return self;
}
});
function _edit(options) {
return new KEdit(options);
}
K.edit = _edit;
K.iframeDoc = _iframeDoc;
function _selectToolbar(name, fn) {
var self = this,
knode = self.get(name);
if (knode) {
if (knode.hasClass('ke-disabled')) {
return;
}
fn(knode);
}
}
function KToolbar(options) {
this.init(options);
}
_extend(KToolbar, KWidget, {
init : function(options) {
var self = this;
KToolbar.parent.init.call(self, options);
self.disableMode = _undef(options.disableMode, false);
self.noDisableItemMap = _toMap(_undef(options.noDisableItems, []));
self._itemMap = {};
self.div.addClass('ke-toolbar').bind('contextmenu,mousedown,mousemove', function(e) {
e.preventDefault();
});
function find(target) {
var knode = K(target);
if (knode.hasClass('ke-outline')) {
return knode;
}
if (knode.hasClass('ke-toolbar-icon')) {
return knode.parent();
}
}
function hover(e, method) {
var knode = find(e.target);
if (knode) {
if (knode.hasClass('ke-disabled')) {
return;
}
if (knode.hasClass('ke-selected')) {
return;
}
knode[method]('ke-on');
}
}
self.div.mouseover(function(e) {
hover(e, 'addClass');
})
.mouseout(function(e) {
hover(e, 'removeClass');
})
.click(function(e) {
var knode = find(e.target);
if (knode) {
if (knode.hasClass('ke-disabled')) {
return;
}
self.options.click.call(this, e, knode.attr('data-name'));
}
});
},
get : function(name) {
if (this._itemMap[name]) {
return this._itemMap[name];
}
return (this._itemMap[name] = K('span.ke-icon-' + name, this.div).parent());
},
select : function(name) {
_selectToolbar.call(this, name, function(knode) {
knode.addClass('ke-selected');
});
return self;
},
unselect : function(name) {
_selectToolbar.call(this, name, function(knode) {
knode.removeClass('ke-selected').removeClass('ke-on');
});
return self;
},
enable : function(name) {
var self = this,
knode = name.get ? name : self.get(name);
if (knode) {
knode.removeClass('ke-disabled');
knode.opacity(1);
}
return self;
},
disable : function(name) {
var self = this,
knode = name.get ? name : self.get(name);
if (knode) {
knode.removeClass('ke-selected').addClass('ke-disabled');
knode.opacity(0.5);
}
return self;
},
disableAll : function(bool, noDisableItems) {
var self = this, map = self.noDisableItemMap, item;
if (noDisableItems) {
map = _toMap(noDisableItems);
}
if (bool === undefined ? !self.disableMode : bool) {
K('span.ke-outline', self.div).each(function() {
var knode = K(this),
name = knode[0].getAttribute('data-name', 2);
if (!map[name]) {
self.disable(knode);
}
});
self.disableMode = true;
} else {
K('span.ke-outline', self.div).each(function() {
var knode = K(this),
name = knode[0].getAttribute('data-name', 2);
if (!map[name]) {
self.enable(knode);
}
});
self.disableMode = false;
}
return self;
}
});
function _toolbar(options) {
return new KToolbar(options);
}
K.toolbar = _toolbar;
function KMenu(options) {
this.init(options);
}
_extend(KMenu, KWidget, {
init : function(options) {
var self = this;
options.z = options.z || 811213;
KMenu.parent.init.call(self, options);
self.centerLineMode = _undef(options.centerLineMode, true);
self.div.addClass('ke-menu').bind('click,mousedown', function(e){
e.stopPropagation();
});
},
addItem : function(item) {
var self = this;
if (item.title === '-') {
self.div.append(K('<div class="ke-menu-separator"></div>'));
return;
}
var itemDiv = K('<div class="ke-menu-item"></div>'),
leftDiv = K('<div class="ke-inline-block ke-menu-item-left"></div>'),
rightDiv = K('<div class="ke-inline-block ke-menu-item-right"></div>'),
height = _addUnit(item.height),
iconClass = item.iconClass;
self.div.append(itemDiv);
if (height) {
itemDiv.css('height', height);
rightDiv.css('line-height', height);
}
var centerDiv;
if (self.centerLineMode) {
centerDiv = K('<div class="ke-inline-block ke-menu-item-center"></div>');
if (height) {
centerDiv.css('height', height);
}
}
itemDiv.mouseover(function(e) {
K(this).addClass('ke-menu-item-on');
if (centerDiv) {
centerDiv.addClass('ke-menu-item-center-on');
}
})
.mouseout(function(e) {
K(this).removeClass('ke-menu-item-on');
if (centerDiv) {
centerDiv.removeClass('ke-menu-item-center-on');
}
})
.click(function(e) {
item.click.call(K(this));
e.stopPropagation();
})
.append(leftDiv);
if (centerDiv) {
itemDiv.append(centerDiv);
}
itemDiv.append(rightDiv);
if (item.checked) {
iconClass = 'ke-icon-checked';
}
leftDiv.html('<span class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ' + iconClass + '"></span>');
rightDiv.html(item.title);
return self;
},
remove : function() {
var self = this;
if (self.options.beforeRemove) {
self.options.beforeRemove.call(self);
}
K('.ke-menu-item', self.div[0]).unbind();
KMenu.parent.remove.call(self);
return self;
}
});
function _menu(options) {
return new KMenu(options);
}
K.menu = _menu;
function KColorPicker(options) {
this.init(options);
}
_extend(KColorPicker, KWidget, {
init : function(options) {
var self = this;
options.z = options.z || 811213;
KColorPicker.parent.init.call(self, options);
var colors = options.colors || [
['#E53333', '#E56600', '#FF9900', '#64451D', '#DFC5A4', '#FFE500'],
['#009900', '#006600', '#99BB00', '#B8D100', '#60D978', '#00D5FF'],
['#337FE5', '#003399', '#4C33E5', '#9933E5', '#CC33E5', '#EE33EE'],
['#FFFFFF', '#CCCCCC', '#999999', '#666666', '#333333', '#000000']
];
self.selectedColor = (options.selectedColor || '').toLowerCase();
self._cells = [];
self.div.addClass('ke-colorpicker').bind('click,mousedown', function(e){
e.stopPropagation();
});
var table = self.doc.createElement('table');
self.div.append(table);
table.className = 'ke-colorpicker-table';
table.cellPadding = 0;
table.cellSpacing = 0;
table.border = 0;
var row = table.insertRow(0), cell = row.insertCell(0);
cell.colSpan = colors[0].length;
self._addAttr(cell, '', 'ke-colorpicker-cell-top');
for (var i = 0; i < colors.length; i++) {
row = table.insertRow(i + 1);
for (var j = 0; j < colors[i].length; j++) {
cell = row.insertCell(j);
self._addAttr(cell, colors[i][j], 'ke-colorpicker-cell');
}
}
},
_addAttr : function(cell, color, cls) {
var self = this;
cell = K(cell).addClass(cls);
if (self.selectedColor === color.toLowerCase()) {
cell.addClass('ke-colorpicker-cell-selected');
}
cell.attr('title', color || self.options.noColor);
cell.mouseover(function(e) {
K(this).addClass('ke-colorpicker-cell-on');
});
cell.mouseout(function(e) {
K(this).removeClass('ke-colorpicker-cell-on');
});
cell.click(function(e) {
e.stop();
self.options.click.call(K(this), color);
});
if (color) {
cell.append(K('<div class="ke-colorpicker-cell-color"></div>').css('background-color', color));
} else {
cell.html(self.options.noColor);
}
self._cells.push(cell);
},
remove : function() {
var self = this;
_each(self._cells, function() {
this.unbind();
});
KColorPicker.parent.remove.call(self);
return self;
}
});
function _colorpicker(options) {
return new KColorPicker(options);
}
K.colorpicker = _colorpicker;
function KUploadButton(options) {
this.init(options);
}
_extend(KUploadButton, {
init : function(options) {
var self = this,
button = K(options.button),
fieldName = options.fieldName || 'file',
url = options.url || '',
title = button.val(),
cls = button[0].className || '',
target = 'kindeditor_upload_iframe_' + new Date().getTime();
var html = [
'<div class="ke-inline-block ' + cls + '">',
'<iframe name="' + target + '" style="display:none;"></iframe>',
'<form class="ke-upload-area ke-form" method="post" enctype="multipart/form-data" target="' + target + '" action="' + url + '">',
'<span class="ke-button-common">',
'<input type="button" class="ke-button-common ke-button" value="' + title + '" />',
'</span>',
'<input type="file" class="ke-upload-file" name="' + fieldName + '" tabindex="-1" />',
'</form></div>'].join('');
var div = K(html, button.doc);
button.hide();
button.before(div);
self.div = div;
self.button = button;
self.iframe = K('iframe', div);
self.form = K('form', div);
self.fileBox = K('.ke-upload-file', div).width(K('.ke-button-common').width());
self.options = options;
},
submit : function() {
var self = this,
iframe = self.iframe;
iframe.bind('load', function() {
iframe.unbind();
var data, str = K.iframeDoc(iframe).body.innerHTML;
try {
data = K.json(str);
} catch (e) {
alert(str);
}
if (data) {
self.options.afterUpload.call(self, data);
}
});
self.form[0].submit();
var tempForm = document.createElement('form');
self.fileBox.before(tempForm);
K(tempForm).append(self.fileBox);
tempForm.reset();
K(tempForm).remove(true);
return self;
},
remove : function() {
var self = this;
if (self.fileBox) {
self.fileBox.unbind();
}
self.div.remove();
self.button.show();
return self;
}
});
function _uploadbutton(options) {
return new KUploadButton(options);
}
K.uploadbutton = _uploadbutton;
function _createButton(arg) {
arg = arg || {};
var name = arg.name || '',
span = K('<span class="ke-button-common ke-button-outer" title="' + name + '"></span>'),
btn = K('<input class="ke-button-common ke-button" type="button" value="' + name + '" />');
if (arg.click) {
btn.click(arg.click);
}
span.append(btn);
return span;
}
function KDialog(options) {
this.init(options);
}
_extend(KDialog, KWidget, {
init : function(options) {
var self = this;
options.z = options.z || 811213;
KDialog.parent.init.call(self, options);
var title = options.title,
body = K(options.body, self.doc),
previewBtn = options.previewBtn,
yesBtn = options.yesBtn,
noBtn = options.noBtn,
closeBtn = options.closeBtn,
shadowMode = _undef(options.shadowMode, true),
showMask = _undef(options.showMask, true);
self.div.addClass('ke-dialog').bind('click,mousedown', function(e){
e.stopPropagation();
}).addClass('ke-dialog-' + (shadowMode ? '' : 'no-') + 'shadow');
var headerDiv = K('<div class="ke-dialog-header"></div>');
self.div.append(headerDiv);
headerDiv.html(title);
self.closeIcon = K('<span class="ke-dialog-icon-close" title="' + closeBtn.name + '"></span>').click(closeBtn.click);
headerDiv.append(self.closeIcon);
self.draggable({
clickEl : headerDiv,
beforeDrag : options.beforeDrag
});
var bodyDiv = K('<div class="ke-dialog-body"></div>');
self.div.append(bodyDiv);
bodyDiv.append(body);
var footerDiv = K('<div class="ke-dialog-footer"></div>');
if (previewBtn || yesBtn || noBtn) {
self.div.append(footerDiv);
}
_each([
{ btn : previewBtn, name : 'preview' },
{ btn : yesBtn, name : 'yes' },
{ btn : noBtn, name : 'no' }
], function() {
if (this.btn) {
var button = _createButton(this.btn);
button.addClass('ke-dialog-' + this.name);
footerDiv.append(button);
}
});
if (self.height) {
bodyDiv.height(_removeUnit(self.height) - headerDiv.height() - footerDiv.height());
}
self.mask = null;
if (showMask) {
var docEl = _docElement(self.doc),
docWidth = Math.max(docEl.scrollWidth, docEl.clientWidth),
docHeight = Math.max(docEl.scrollHeight, docEl.clientHeight);
self.mask = _widget({
x : 0,
y : 0,
z : self.z - 1,
cls : 'ke-dialog-mask',
width : docWidth,
height : docHeight
});
}
self.autoPos(self.div.width(), self.div.height());
self.footerDiv = footerDiv;
self.bodyDiv = bodyDiv;
self.headerDiv = headerDiv;
},
remove : function() {
var self = this;
if (self.options.beforeRemove) {
self.options.beforeRemove.call(self);
}
if (self.mask) {
self.mask.remove();
}
self.closeIcon.unbind();
K('input', self.div).unbind();
self.footerDiv.unbind();
self.bodyDiv.unbind();
self.headerDiv.unbind();
KDialog.parent.remove.call(self);
return self;
}
});
function _dialog(options) {
return new KDialog(options);
}
K.dialog = _dialog;
function _tabs(options) {
var self = _widget(options),
remove = self.remove,
afterSelect = options.afterSelect,
div = self.div,
liList = [];
div.addClass('ke-tabs')
.bind('contextmenu,mousedown,mousemove', function(e) {
e.preventDefault();
});
var ul = K('<ul class="ke-tabs-ul ke-clearfix"></ul>');
div.append(ul);
self.add = function(tab) {
var li = K('<li class="ke-tabs-li">' + tab.title + '</li>');
li.data('tab', tab);
liList.push(li);
ul.append(li);
};
self.selectedIndex = 0;
self.select = function(index) {
self.selectedIndex = index;
_each(liList, function(i, li) {
li.unbind();
if (i === index) {
li.addClass('ke-tabs-li-selected');
K(li.data('tab').panel).show('');
} else {
li.removeClass('ke-tabs-li-selected').removeClass('ke-tabs-li-on')
.mouseover(function() {
K(this).addClass('ke-tabs-li-on');
})
.mouseout(function() {
K(this).removeClass('ke-tabs-li-on');
})
.click(function() {
self.select(i);
});
K(li.data('tab').panel).hide();
}
});
if (afterSelect) {
afterSelect.call(self, index);
}
};
self.remove = function() {
_each(liList, function() {
this.remove();
});
ul.remove();
remove.call(self);
};
return self;
}
K.tabs = _tabs;
function _loadScript(url, fn) {
var head = document.getElementsByTagName('head')[0] || (_QUIRKS ? document.body : document.documentElement),
script = document.createElement('script');
head.appendChild(script);
script.src = url;
script.charset = 'utf-8';
script.onload = script.onreadystatechange = function() {
if (!this.readyState || this.readyState === 'loaded') {
if (fn) {
fn();
}
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
}
function _loadStyle(url) {
var head = document.getElementsByTagName('head')[0] || (_QUIRKS ? document.body : document.documentElement),
link = document.createElement('link'),
absoluteUrl = _formatUrl(url, 'absolute');
var links = K('link[rel="stylesheet"]', head);
for (var i = 0, len = links.length; i < len; i++) {
if (_formatUrl(links[i].href, 'absolute') === absoluteUrl) {
return;
}
}
head.appendChild(link);
link.href = url;
link.rel = 'stylesheet';
}
function _ajax(url, fn, method, data) {
method = method || 'GET';
var xhr = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
xhr.open(method, url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
if (fn) {
data = _json(_trim(xhr.responseText));
fn(data);
}
}
};
if (method == 'POST') {
var params = [];
_each(data, function(key, val) {
params.push(encodeURIComponent(key) + '=' + encodeURIComponent(val));
});
try {
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
} catch (e) {}
xhr.send(params.join('&'));
} else {
xhr.send(null);
}
}
K.loadScript = _loadScript;
K.loadStyle = _loadStyle;
K.ajax = _ajax;
var _plugins = {};
function _plugin(name, fn) {
if (!fn) {
return _plugins[name];
}
_plugins[name] = fn;
}
var _language = {};
function _parseLangKey(key) {
var match, ns = 'core';
if ((match = /^(\w+)\.(\w+)$/.exec(key))) {
ns = match[1];
key = match[2];
}
return { ns : ns, key : key };
}
function _lang(mixed, langType) {
langType = langType === undefined ? K.options.langType : langType;
if (typeof mixed === 'string') {
if (!_language[langType]) {
return 'no language';
}
var pos = mixed.length - 1;
if (mixed.substr(pos) === '.') {
return _language[langType][mixed.substr(0, pos)];
}
var obj = _parseLangKey(mixed);
return _language[langType][obj.ns][obj.key];
}
_each(mixed, function(key, val) {
var obj = _parseLangKey(key);
if (!_language[langType]) {
_language[langType] = {};
}
if (!_language[langType][obj.ns]) {
_language[langType][obj.ns] = {};
}
_language[langType][obj.ns][obj.key] = val;
});
}
function _getImageFromRange(range, fn) {
var sc = range.startContainer, so = range.startOffset;
if (!_WEBKIT && !range.isControl()) {
return;
}
var img = K(sc.childNodes[so]);
if (!img || img.name != 'img') {
return;
}
if (fn(img)) {
return img;
}
}
function _bindContextmenuEvent() {
var self = this, doc = self.edit.doc;
K(doc).contextmenu(function(e) {
if (self.menu) {
self.hideMenu();
}
if (!self.useContextmenu) {
e.preventDefault();
return;
}
if (self._contextmenus.length === 0) {
return;
}
var maxWidth = 0, items = [];
_each(self._contextmenus, function() {
if (this.title == '-') {
items.push(this);
return;
}
if (this.cond && this.cond()) {
items.push(this);
if (this.width && this.width > maxWidth) {
maxWidth = this.width;
}
}
});
while (items.length > 0 && items[0].title == '-') {
items.shift();
}
while (items.length > 0 && items[items.length - 1].title == '-') {
items.pop();
}
var prevItem = null;
_each(items, function(i) {
if (this.title == '-' && prevItem.title == '-') {
delete items[i];
}
prevItem = this;
});
if (items.length > 0) {
e.preventDefault();
var pos = K(self.edit.iframe).pos(),
menu = _menu({
x : pos.x + e.clientX,
y : pos.y + e.clientY,
width : maxWidth,
css : { visibility: 'hidden' }
});
_each(items, function() {
if (this.title) {
menu.addItem(this);
}
});
var docEl = _docElement(menu.doc),
menuHeight = menu.div.height();
if (e.clientY + menuHeight >= docEl.clientHeight - 100) {
menu.pos(menu.x, _removeUnit(menu.y) - menuHeight);
}
menu.div.css('visibility', 'visible');
self.menu = menu;
}
});
}
function _bindNewlineEvent() {
var self = this, doc = self.edit.doc, newlineTag = self.newlineTag;
if (_IE && newlineTag !== 'br') {
return;
}
if (_GECKO && _V < 3 && newlineTag !== 'p') {
return;
}
if (_OPERA) {
return;
}
var brSkipTagMap = _toMap('h1,h2,h3,h4,h5,h6,pre,li'),
pSkipTagMap = _toMap('p,h1,h2,h3,h4,h5,h6,pre,li,blockquote');
function getAncestorTagName(range) {
var ancestor = K(range.commonAncestor());
while (ancestor) {
if (ancestor.type == 1 && !ancestor.isStyle()) {
break;
}
ancestor = ancestor.parent();
}
return ancestor.name;
}
K(doc).keydown(function(e) {
if (e.which != 13 || e.shiftKey || e.ctrlKey || e.altKey) {
return;
}
self.cmd.selection();
var tagName = getAncestorTagName(self.cmd.range);
if (tagName == 'marquee' || tagName == 'select') {
return;
}
if (newlineTag === 'br' && !brSkipTagMap[tagName]) {
e.preventDefault();
self.insertHtml('<br />');
return;
}
if (!pSkipTagMap[tagName]) {
_nativeCommand(doc, 'formatblock', '<p>');
}
});
K(doc).keyup(function(e) {
if (e.which != 13 || e.shiftKey || e.ctrlKey || e.altKey) {
return;
}
if (newlineTag == 'br') {
return;
}
self.cmd.selection();
var tagName = getAncestorTagName(self.cmd.range);
if (tagName == 'marquee' || tagName == 'select') {
return;
}
if (!pSkipTagMap[tagName]) {
_nativeCommand(doc, 'formatblock', '<p>');
}
var div = self.cmd.commonAncestor('div');
if (div) {
var p = K('<p></p>'),
child = div[0].firstChild;
while (child) {
var next = child.nextSibling;
p.append(child);
child = next;
}
div.before(p);
div.remove();
self.cmd.range.selectNodeContents(p[0]);
self.cmd.select();
}
});
}
function _bindTabEvent() {
var self = this;
K(self.edit.doc).keydown(function(e) {
if (e.which == 9) {
e.preventDefault();
if (self.afterTab) {
self.afterTab.call(self, e);
return;
}
self.insertHtml(' ');
}
});
}
function _bindFocusEvent() {
var self = this;
K(self.edit.textarea[0], self.edit.win).focus(function(e) {
if (self.afterFocus) {
self.afterFocus.call(self, e);
}
}).blur(function(e) {
if (self.afterBlur) {
self.afterBlur.call(self, e);
}
});
}
function _removeBookmarkTag(html) {
return _trim(html.replace(/<span [^>]*id="?__kindeditor_bookmark_\w+_\d+__"?[^>]*><\/span>/ig, ''));
}
function _addBookmarkToStack(stack, bookmark) {
if (stack.length === 0) {
stack.push(bookmark);
return;
}
var prev = stack[stack.length - 1];
if (_removeBookmarkTag(bookmark.html) !== _removeBookmarkTag(prev.html)) {
stack.push(bookmark);
}
}
function _undoToRedo(fromStack, toStack) {
var self = this, edit = self.edit,
body = edit.doc.body,
range, bookmark;
if (fromStack.length === 0) {
return self;
}
if (edit.designMode) {
range = self.cmd.range;
bookmark = range.createBookmark(true);
bookmark.html = body.innerHTML;
} else {
bookmark = {
html : body.innerHTML
};
}
_addBookmarkToStack(toStack, bookmark);
var prev = fromStack.pop();
if (_removeBookmarkTag(bookmark.html) === _removeBookmarkTag(prev.html) && fromStack.length > 0) {
prev = fromStack.pop();
}
if (edit.designMode) {
edit.html(prev.html);
if (prev.start) {
range.moveToBookmark(prev);
self.select();
}
} else {
K(body).html(_removeBookmarkTag(prev.html));
}
return self;
}
function KEditor(options) {
var self = this;
self.options = {};
function setOption(key, val) {
if (KEditor.prototype[key] === undefined) {
self[key] = val;
}
self.options[key] = val;
}
_each(options, function(key, val) {
setOption(key, options[key]);
});
_each(K.options, function(key, val) {
if (self[key] === undefined) {
setOption(key, val);
}
});
setOption('width', _undef(self.width, self.minWidth));
setOption('height', _undef(self.height, self.minHeight));
setOption('width', _addUnit(self.width));
setOption('height', _addUnit(self.height));
if (_MOBILE) {
self.designMode = false;
}
var se = K(self.srcElement || '<textarea/>');
self.srcElement = se;
self.initContent = _elementVal(se);
self.plugin = {};
self.isCreated = false;
self._handlers = {};
self._contextmenus = [];
self._undoStack = [];
self._redoStack = [];
self._calledPlugins = {};
self._firstAddBookmark = true;
self.menu = self.contextmenu = null;
self.dialogs = [];
}
KEditor.prototype = {
lang : function(mixed) {
return _lang(mixed, this.langType);
},
loadPlugin : function(name, fn) {
var self = this;
if (_plugins[name]) {
if (self._calledPlugins[name]) {
if (fn) {
fn.call(self);
}
return self;
}
_plugins[name].call(self, KindEditor);
if (fn) {
fn.call(self);
}
self._calledPlugins[name] = true;
return self;
}
_loadScript(self.pluginsPath + name + '/' + name + '.js?ver=' + encodeURIComponent(K.DEBUG ? _TIME : _VERSION), function() {
if (_plugins[name]) {
self.loadPlugin(name, fn);
}
});
return self;
},
handler : function(key, fn) {
var self = this;
if (!self._handlers[key]) {
self._handlers[key] = [];
}
if (_isFunction(fn)) {
self._handlers[key].push(fn);
return self;
}
_each(self._handlers[key], function() {
fn = this.call(self, fn);
});
return fn;
},
clickToolbar : function(name, fn) {
var self = this, key = 'clickToolbar' + name;
if (fn === undefined) {
if (self._handlers[key]) {
return self.handler(key);
}
self.loadPlugin(name, function() {
self.handler(key);
});
return self;
}
return self.handler(key, fn);
},
updateState : function() {
var self = this;
_each(('justifyleft,justifycenter,justifyright,justifyfull,insertorderedlist,insertunorderedlist,' +
'subscript,superscript,bold,italic,underline,strikethrough').split(','), function(i, name) {
self.cmd.state(name) ? self.toolbar.select(name) : self.toolbar.unselect(name);
});
return self;
},
addContextmenu : function(item) {
this._contextmenus.push(item);
return this;
},
afterCreate : function(fn) {
return this.handler('afterCreate', fn);
},
beforeRemove : function(fn) {
return this.handler('beforeRemove', fn);
},
beforeGetHtml : function(fn) {
return this.handler('beforeGetHtml', fn);
},
beforeSetHtml : function(fn) {
return this.handler('beforeSetHtml', fn);
},
afterSetHtml : function(fn) {
return this.handler('afterSetHtml', fn);
},
create : function() {
var self = this, fullscreenMode = self.fullscreenMode;
if (self.isCreated) {
return self;
}
if (fullscreenMode) {
_docElement().style.overflow = 'hidden';
} else {
_docElement().style.overflow = '';
}
var width = fullscreenMode ? _docElement().clientWidth + 'px' : self.width,
height = fullscreenMode ? _docElement().clientHeight + 'px' : self.height;
if ((_IE && _V < 8) || _QUIRKS) {
height = _addUnit(_removeUnit(height) + 2);
}
var container = self.container = K(self.layout);
if (fullscreenMode) {
K(document.body).append(container);
} else {
self.srcElement.before(container);
}
var toolbarDiv = K('.toolbar', container),
editDiv = K('.edit', container),
statusbar = self.statusbar = K('.statusbar', container);
container.removeClass('container')
.addClass('ke-container ke-container-' + self.themeType).css('width', width);
if (fullscreenMode) {
container.css({
position : 'absolute',
left : 0,
top : 0,
'z-index' : 811211
});
self._scrollPos = _getScrollPos();
window.scrollTo(0, 0);
K(document.body).css({
'height' : '1px',
'overflow' : 'hidden'
});
K(document.body.parentNode).css('overflow', 'hidden');
} else {
if (self._scrollPos) {
K(document.body).css({
'height' : '',
'overflow' : ''
});
K(document.body.parentNode).css('overflow', '');
window.scrollTo(self._scrollPos.x, self._scrollPos.y);
}
}
var htmlList = [];
K.each(self.items, function(i, name) {
if (name == '|') {
htmlList.push('<span class="ke-inline-block ke-separator"></span>');
} else if (name == '/') {
htmlList.push('<br />');
} else {
htmlList.push('<span class="ke-inline-block ke-outline" data-name="' + name + '" title="' + self.lang(name) + '">');
htmlList.push('<span class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-' + name + '"></span></span>');
}
});
var toolbar = self.toolbar = _toolbar({
src : toolbarDiv,
html : htmlList.join(''),
noDisableItems : self.noDisableItems,
click : function(e, name) {
e.stop();
if (self.menu) {
var menuName = self.menu.name;
self.hideMenu();
if (menuName === name) {
return;
}
}
self.clickToolbar(name);
}
});
var edit = self.edit = _edit({
height : _removeUnit(height) - toolbar.div.height(),
src : editDiv,
srcElement : self.srcElement,
designMode : self.designMode,
themesPath : self.themesPath,
bodyClass : self.bodyClass,
cssPath : self.cssPath,
cssData : self.cssData,
beforeGetHtml : function(html) {
html = self.beforeGetHtml(html);
return _formatHtml(html, self.filterMode ? self.htmlTags : null, self.urlType, self.wellFormatMode, self.indentChar);
},
beforeSetHtml : function(html) {
html = _formatHtml(html, self.filterMode ? self.htmlTags : null, '', false);
return self.beforeSetHtml(html);
},
afterSetHtml : function() {
self.afterSetHtml();
},
afterCreate : function() {
self.edit = edit = this;
self.cmd = edit.cmd;
self._docMousedownFn = function(e) {
if (self.menu) {
self.hideMenu();
}
};
K(edit.doc, document).mousedown(self._docMousedownFn);
_bindContextmenuEvent.call(self);
_bindNewlineEvent.call(self);
_bindTabEvent.call(self);
_bindFocusEvent.call(self);
edit.afterChange(function(e) {
if (!edit.designMode) {
return;
}
self.updateState();
self.addBookmark();
if (self.options.afterChange) {
self.options.afterChange.call(self);
}
});
edit.textarea.keyup(function(e) {
if (!e.ctrlKey && !e.altKey && _INPUT_KEY_MAP[e.which]) {
if (self.options.afterChange) {
self.options.afterChange.call(self);
}
}
});
if (self.readonlyMode) {
self.readonly();
}
self.isCreated = true;
self.initContent = self.html();
self.afterCreate();
if (self.options.afterCreate) {
self.options.afterCreate.call(self);
}
}
});
statusbar.removeClass('statusbar').addClass('ke-statusbar')
.append('<span class="ke-inline-block ke-statusbar-center-icon"></span>')
.append('<span class="ke-inline-block ke-statusbar-right-icon"></span>');
K(window).unbind('resize');
self.resize(width, height);
function newResize(width, height, updateProp) {
updateProp = _undef(updateProp, true);
if (width && width >= self.minWidth) {
self.resize(width, null);
if (updateProp) {
self.width = _addUnit(width);
}
}
if (height && height >= self.minHeight) {
self.resize(null, height);
if (updateProp) {
self.height = _addUnit(height);
}
}
}
if (fullscreenMode) {
K(window).bind('resize', function(e) {
if (self.isCreated) {
newResize(_docElement().clientWidth, _docElement().clientHeight, false);
}
});
toolbar.select('fullscreen');
statusbar.first().css('visibility', 'hidden');
statusbar.last().css('visibility', 'hidden');
} else {
if (self.resizeType > 0) {
_drag({
moveEl : container,
clickEl : statusbar,
moveFn : function(x, y, width, height, diffX, diffY) {
height += diffY;
newResize(null, height);
}
});
} else {
statusbar.first().css('visibility', 'hidden');
}
if (self.resizeType === 2) {
_drag({
moveEl : container,
clickEl : statusbar.last(),
moveFn : function(x, y, width, height, diffX, diffY) {
width += diffX;
height += diffY;
newResize(width, height);
}
});
} else {
statusbar.last().css('visibility', 'hidden');
}
}
return self;
},
remove : function() {
var self = this;
if (!self.isCreated) {
return self;
}
self.beforeRemove();
if (self.menu) {
self.hideMenu();
}
_each(self.dialogs, function() {
self.hideDialog();
});
K(document).unbind('mousedown', self._docMousedownFn);
self.toolbar.remove();
self.edit.remove();
self.statusbar.last().unbind();
self.statusbar.unbind();
self.container.remove();
self.container = self.toolbar = self.edit = self.menu = null;
self.dialogs = [];
self.isCreated = false;
return self;
},
resize : function(width, height) {
var self = this;
if (width !== null) {
self.container.css('width', _addUnit(width));
}
if (height !== null) {
height = _removeUnit(height) - self.toolbar.div.height() - self.statusbar.height();
if (height > 0) {
self.edit.setHeight(height);
}
}
return self;
},
select : function() {
this.isCreated && this.cmd.select();
return this;
},
html : function(val) {
var self = this;
if (val === undefined) {
return self.isCreated ? self.edit.html() : _elementVal(self.srcElement);
}
self.isCreated ? self.edit.html(val) : _elementVal(self.srcElement, val);
return self;
},
fullHtml : function() {
return this.isCreated ? this.edit.html(undefined, true) : '';
},
text : function(val) {
var self = this;
if (val === undefined) {
return _trim(self.html().replace(/<(?!img|embed).*?>/ig, '').replace(/ /ig, ' '));
} else {
return self.html(_escape(val));
}
},
isEmpty : function() {
return _trim(this.text().replace(/\r\n|\n|\r/, '')) === '';
},
isDirty : function() {
return _trim(this.initContent.replace(/\r\n|\n|\r|t/g, '')) !== _trim(this.html().replace(/\r\n|\n|\r|t/g, ''));
},
selectedHtml : function() {
return this.isCreated ? this.cmd.range.html() : '';
},
count : function(mode) {
var self = this;
mode = (mode || 'html').toLowerCase();
if (mode === 'html') {
return _removeBookmarkTag(self.html()).length;
}
if (mode === 'text') {
return self.text().replace(/<(?:img|embed).*?>/ig, 'K').replace(/\r\n|\n|\r/g, '').length;
}
return 0;
},
exec : function(key) {
key = key.toLowerCase();
var self = this, cmd = self.cmd,
changeFlag = _inArray(key, 'selectall,copy,paste,print'.split(',')) < 0;
if (changeFlag) {
self.addBookmark(false);
}
cmd[key].apply(cmd, _toArray(arguments, 1));
if (changeFlag) {
self.updateState();
self.addBookmark(false);
if (self.options.afterChange) {
self.options.afterChange.call(self);
}
}
return self;
},
insertHtml : function(val) {
if (!this.isCreated) {
return this;
}
val = this.beforeSetHtml(val);
this.exec('inserthtml', val);
return this;
},
appendHtml : function(val) {
this.html(this.html() + val);
if (this.isCreated) {
var cmd = this.cmd;
cmd.range.selectNodeContents(cmd.doc.body).collapse(false);
cmd.select();
}
return this;
},
sync : function() {
_elementVal(this.srcElement, this.html());
return this;
},
focus : function() {
this.isCreated ? this.edit.focus() : this.srcElement[0].focus();
return this;
},
blur : function() {
this.isCreated ? this.edit.blur() : this.srcElement[0].blur();
return this;
},
addBookmark : function(checkSize) {
checkSize = _undef(checkSize, true);
var self = this, edit = self.edit,
body = edit.doc.body,
html = body.innerHTML, bookmark;
if (checkSize && self._undoStack.length > 0) {
var prev = self._undoStack[self._undoStack.length - 1];
if (Math.abs(html.length - _removeBookmarkTag(prev.html).length) < self.minChangeSize) {
return self;
}
}
if (edit.designMode && !self._firstAddBookmark) {
var range = self.cmd.range;
bookmark = range.createBookmark(true);
bookmark.html = body.innerHTML;
range.moveToBookmark(bookmark);
} else {
bookmark = {
html : body.innerHTML
};
}
self._firstAddBookmark = false;
_addBookmarkToStack(self._undoStack, bookmark);
return self;
},
undo : function() {
return _undoToRedo.call(this, this._undoStack, this._redoStack);
},
redo : function() {
return _undoToRedo.call(this, this._redoStack, this._undoStack);
},
fullscreen : function(bool) {
this.fullscreenMode = (bool === undefined ? !this.fullscreenMode : bool);
return this.remove().create();
},
readonly : function(isReadonly) {
isReadonly = _undef(isReadonly, true);
var self = this, edit = self.edit, doc = edit.doc;
if (self.designMode) {
self.toolbar.disableAll(isReadonly, []);
} else {
_each(self.noDisableItems, function() {
self.toolbar[isReadonly ? 'disable' : 'enable'](this);
});
}
if (_IE) {
doc.body.contentEditable = !isReadonly;
} else {
doc.designMode = isReadonly ? 'off' : 'on';
}
edit.textarea[0].disabled = isReadonly;
},
createMenu : function(options) {
var self = this,
name = options.name,
knode = self.toolbar.get(name),
pos = knode.pos();
options.x = pos.x;
options.y = pos.y + knode.height();
if (options.selectedColor !== undefined) {
options.cls = 'ke-colorpicker-' + self.themeType;
options.noColor = self.lang('noColor');
self.menu = _colorpicker(options);
} else {
options.cls = 'ke-menu-' + self.themeType;
options.centerLineMode = false;
self.menu = _menu(options);
}
return self.menu;
},
hideMenu : function() {
this.menu.remove();
this.menu = null;
return this;
},
hideContextmenu : function() {
this.contextmenu.remove();
this.contextmenu = null;
return this;
},
createDialog : function(options) {
var self = this, name = options.name;
options.autoScroll = _undef(options.autoScroll, true);
options.shadowMode = _undef(options.shadowMode, self.shadowMode);
options.closeBtn = _undef(options.closeBtn, {
name : self.lang('close'),
click : function(e) {
self.hideDialog().focus();
}
});
options.noBtn = _undef(options.noBtn, {
name : self.lang(options.yesBtn ? 'no' : 'close'),
click : function(e) {
self.hideDialog().focus();
}
});
if (self.dialogAlignType != 'page') {
options.alignEl = self.container;
}
options.cls = 'ke-dialog-' + self.themeType;
if (self.dialogs.length > 0) {
var firstDialog = self.dialogs[0],
parentDialog = self.dialogs[self.dialogs.length - 1];
firstDialog.mask.div.css('z-index', parentDialog.z + 1);
options.z = parentDialog.z + 2;
options.showMask = false;
}
var dialog = _dialog(options);
self.dialogs.push(dialog);
return dialog;
},
hideDialog : function() {
var self = this;
if (self.dialogs.length > 0) {
self.dialogs.pop().remove();
}
if (self.dialogs.length > 0) {
var firstDialog = self.dialogs[0],
parentDialog = self.dialogs[self.dialogs.length - 1];
firstDialog.mask.div.css('z-index', parentDialog.z - 1);
}
return self;
}
};
function _editor(options) {
return new KEditor(options);
}
function _create(expr, options) {
options = options || {};
options.basePath = _undef(options.basePath, K.basePath);
options.themesPath = _undef(options.themesPath, options.basePath + 'themes/');
options.langPath = _undef(options.langPath, options.basePath + 'lang/');
options.pluginsPath = _undef(options.pluginsPath, options.basePath + 'plugins/');
if (_undef(options.loadStyleMode, K.options.loadStyleMode)) {
var themeType = _undef(options.themeType, K.options.themeType);
_loadStyle(options.themesPath + 'default/default.css');
_loadStyle(options.themesPath + themeType + '/' + themeType + '.css');
}
function create(editor) {
_each(_plugins, function(name, fn) {
fn.call(editor, KindEditor);
});
return editor.create();
}
var knode = K(expr);
if (!knode) {
return;
}
options.srcElement = knode[0];
if (!options.width) {
options.width = knode.width();
}
if (!options.height) {
options.height = knode.height();
}
var editor = new KEditor(options);
if (_language[editor.langType]) {
return create(editor);
}
_loadScript(editor.langPath + editor.langType + '.js?ver=' + encodeURIComponent(K.DEBUG ? _TIME : _VERSION), function() {
return create(editor);
});
return editor;
}
if (_IE && _V < 7) {
_nativeCommand(document, 'BackgroundImageCache', true);
}
K.editor = _editor;
K.create = _create;
K.plugin = _plugin;
K.lang = _lang;
_plugin('core', function(K) {
var self = this,
shortcutKeys = {
undo : 'Z', redo : 'Y', bold : 'B', italic : 'I', underline : 'U', print : 'P', selectall : 'A'
};
self.afterSetHtml(function() {
if (self.options.afterChange) {
self.options.afterChange.call(self);
}
});
if (self.syncType == 'form') {
var el = K(self.srcElement), hasForm = false;
while ((el = el.parent())) {
if (el.name == 'form') {
hasForm = true;
break;
}
}
if (hasForm) {
el.bind('submit', function(e) {
self.sync();
});
var resetBtn = K('[type="reset"]', el);
resetBtn.click(function() {
self.html(self.initContent);
});
self.beforeRemove(function() {
el.unbind();
resetBtn.unbind();
});
}
}
self.clickToolbar('source', function() {
if (_MOBILE) {
return;
}
if (self.edit.designMode) {
self.toolbar.disableAll(true);
self.edit.design(false);
self.toolbar.select('source');
} else {
self.toolbar.disableAll(false);
self.edit.design(true);
self.toolbar.unselect('source');
}
self.designMode = self.edit.designMode;
});
self.afterCreate(function() {
if (!self.designMode) {
self.toolbar.disableAll(true).select('source');
}
});
self.clickToolbar('fullscreen', function() {
self.fullscreen();
});
var loaded = false;
self.afterCreate(function() {
K(self.edit.doc, self.edit.textarea).keyup(function(e) {
if (e.which == 27) {
setTimeout(function() {
self.fullscreen();
}, 0);
}
});
if (loaded) {
if (_IE && !self.designMode) {
return;
}
self.focus();
}
if (!loaded) {
loaded = true;
}
});
_each('undo,redo'.split(','), function(i, name) {
if (shortcutKeys[name]) {
self.afterCreate(function() {
_ctrl(this.edit.doc, shortcutKeys[name], function() {
self.clickToolbar(name);
});
});
}
self.clickToolbar(name, function() {
self[name]();
});
});
self.clickToolbar('formatblock', function() {
var blocks = self.lang('formatblock.formatBlock'),
heights = {
h1 : 28,
h2 : 24,
h3 : 18,
H4 : 14,
p : 12
},
curVal = self.cmd.val('formatblock'),
menu = self.createMenu({
name : 'formatblock',
width : self.langType == 'en' ? 200 : 150
});
_each(blocks, function(key, val) {
var style = 'font-size:' + heights[key] + 'px;';
if (key.charAt(0) === 'h') {
style += 'font-weight:bold;';
}
menu.addItem({
title : '<span style="' + style + '">' + val + '</span>',
height : heights[key] + 12,
checked : (curVal === key || curVal === val),
click : function() {
self.select().exec('formatblock', '<' + key + '>').hideMenu();
}
});
});
});
self.clickToolbar('fontname', function() {
var curVal = self.cmd.val('fontname'),
menu = self.createMenu({
name : 'fontname',
width : 150
});
_each(self.lang('fontname.fontName'), function(key, val) {
menu.addItem({
title : '<span style="font-family: ' + key + ';">' + val + '</span>',
checked : (curVal === key.toLowerCase() || curVal === val.toLowerCase()),
click : function() {
self.exec('fontname', key).hideMenu();
}
});
});
});
self.clickToolbar('fontsize', function() {
var curVal = self.cmd.val('fontsize');
menu = self.createMenu({
name : 'fontsize',
width : 150
});
_each(self.fontSizeTable, function(i, val) {
menu.addItem({
title : '<span style="font-size:' + val + ';">' + val + '</span>',
height : _removeUnit(val) + 12,
checked : curVal === val,
click : function() {
self.exec('fontsize', val).hideMenu();
}
});
});
});
_each('forecolor,hilitecolor'.split(','), function(i, name) {
self.clickToolbar(name, function() {
self.createMenu({
name : name,
selectedColor : self.cmd.val(name) || 'default',
colors : self.colorTable,
click : function(color) {
self.exec(name, color).hideMenu();
}
});
});
});
_each(('cut,copy,paste').split(','), function(i, name) {
self.clickToolbar(name, function() {
self.focus();
try {
self.exec(name, null);
} catch(e) {
alert(self.lang(name + 'Error'));
}
});
});
self.clickToolbar('about', function() {
var html = '<div style="margin:20px;">' +
'<div>KindEditor ' + _VERSION + '</div>' +
'<div>Copyright © <a href="http://www.kindsoft.net/" target="_blank">kindsoft.net</a> All rights reserved.</div>' +
'</div>';
self.createDialog({
name : 'about',
width : 300,
title : self.lang('about'),
body : html
});
});
self.plugin.getSelectedLink = function() {
return self.cmd.commonAncestor('a');
};
self.plugin.getSelectedImage = function() {
return _getImageFromRange(self.edit.cmd.range, function(img) {
return !/^ke-\w+$/i.test(img[0].className);
});
};
self.plugin.getSelectedFlash = function() {
return _getImageFromRange(self.edit.cmd.range, function(img) {
return img[0].className == 'ke-flash';
});
};
self.plugin.getSelectedMedia = function() {
return _getImageFromRange(self.edit.cmd.range, function(img) {
return img[0].className == 'ke-flash' || img[0].className == 'ke-rm';
});
};
self.plugin.getSelectedAnchor = function() {
return _getImageFromRange(self.edit.cmd.range, function(img) {
return img[0].className == 'ke-anchor';
});
};
_each('link,image,flash,media,anchor'.split(','), function(i, name) {
var uName = name.charAt(0).toUpperCase() + name.substr(1);
_each('edit,delete'.split(','), function(j, val) {
self.addContextmenu({
title : self.lang(val + uName),
click : function() {
self.loadPlugin(name, function() {
self.plugin[name][val]();
self.hideMenu();
});
},
cond : self.plugin['getSelected' + uName],
width : 150,
iconClass : val == 'edit' ? 'ke-icon-' + name : undefined
});
});
self.addContextmenu({ title : '-' });
});
self.plugin.getSelectedTable = function() {
return self.cmd.commonAncestor('table');
};
self.plugin.getSelectedRow = function() {
return self.cmd.commonAncestor('tr');
};
self.plugin.getSelectedCell = function() {
return self.cmd.commonAncestor('td');
};
_each(('prop,cellprop,colinsertleft,colinsertright,rowinsertabove,rowinsertbelow,rowmerge,colmerge,' +
'rowsplit,colsplit,coldelete,rowdelete,insert,delete').split(','), function(i, val) {
var cond = _inArray(val, ['prop', 'delete']) < 0 ? self.plugin.getSelectedCell : self.plugin.getSelectedTable;
self.addContextmenu({
title : self.lang('table' + val),
click : function() {
self.loadPlugin('table', function() {
self.plugin.table[val]();
self.hideMenu();
});
},
cond : cond,
width : 170,
iconClass : 'ke-icon-table' + val
});
});
self.addContextmenu({ title : '-' });
_each(('selectall,justifyleft,justifycenter,justifyright,justifyfull,insertorderedlist,' +
'insertunorderedlist,indent,outdent,subscript,superscript,hr,print,' +
'bold,italic,underline,strikethrough,removeformat,unlink').split(','), function(i, name) {
if (shortcutKeys[name]) {
self.afterCreate(function() {
_ctrl(this.edit.doc, shortcutKeys[name], function() {
self.cmd.selection();
self.clickToolbar(name);
});
});
}
self.clickToolbar(name, function() {
self.focus().exec(name, null);
});
});
self.afterCreate(function() {
var doc = self.edit.doc, cmd, bookmark, div,
cls = '__kindeditor_paste__', pasting = false;
function movePastedData() {
cmd.range.moveToBookmark(bookmark);
cmd.select();
if (_WEBKIT) {
K('div.' + cls, div).each(function() {
K(this).after('<br />').remove(true);
});
K('span.Apple-style-span', div).remove(true);
K('meta', div).remove();
}
var html = div[0].innerHTML;
div.remove();
if (html === '') {
return;
}
if (self.pasteType === 2) {
if (/schemas-microsoft-com|worddocument|mso-\w+/i.test(html)) {
html = _clearMsWord(html, self.filterMode ? self.htmlTags : K.options.htmlTags);
} else {
html = _formatHtml(html, self.filterMode ? self.htmlTags : null);
html = self.beforeSetHtml(html);
}
}
if (self.pasteType === 1) {
html = html.replace(/<br[^>]*>/ig, '\n');
html = html.replace(/<\/p><p[^>]*>/ig, '\n');
html = html.replace(/<[^>]+/g, '');
html = html.replace(/ /ig, ' ');
html = html.replace(/\n\s*\n/g, '\n');
if (self.newlineTag == 'p') {
html = html.replace(/^/, '<p>').replace(/$/, '</p>').replace(/\n/g, '</p><p>');
} else {
html = html.replace(/\n/g, '<br />$&');
}
}
self.insertHtml(html);
}
K(doc.body).bind('paste', function(e){
if (self.pasteType === 0) {
e.stop();
return;
}
if (pasting) {
return;
}
pasting = true;
K('div.' + cls, doc).remove();
cmd = self.cmd.selection();
bookmark = cmd.range.createBookmark();
div = K('<div class="' + cls + '"></div>', doc).css({
position : 'absolute',
width : '1px',
height : '1px',
overflow : 'hidden',
left : '-1981px',
top : K(bookmark.start).pos().y + 'px',
'white-space' : 'nowrap'
});
K(doc.body).append(div);
if (_IE) {
var rng = cmd.range.get(true);
rng.moveToElementText(div[0]);
rng.select();
rng.execCommand('paste');
e.preventDefault();
} else {
cmd.range.selectNodeContents(div[0]);
cmd.select();
}
setTimeout(function() {
movePastedData();
pasting = false;
}, 0);
});
});
self.beforeGetHtml(function(html) {
return html.replace(/<img[^>]*class="?ke-(flash|rm|media)"?[^>]*>/ig, function(full) {
var imgAttrs = _getAttrList(full),
attrs = _mediaAttrs(imgAttrs['data-ke-tag']);
return _mediaEmbed(attrs);
})
.replace(/<img[^>]*class="?ke-anchor"?[^>]*>/ig, function(full) {
var imgAttrs = _getAttrList(full);
return '<a name="' + unescape(imgAttrs['data-ke-name']) + '"></a>';
})
.replace(/<div\s+[^>]*data-ke-script-attr="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig, function(full, attr, code) {
return '<script' + unescape(attr) + '>' + code + '</script>';
})
.replace(/(<[^>]*)data-ke-src="([^"]*)"([^>]*>)/ig, function(full, start, src, end) {
full = full.replace(/(\s+(?:href|src)=")[^"]*(")/i, '$1' + src + '$2');
full = full.replace(/\s+data-ke-src="[^"]*"/i, '');
return full;
})
.replace(/(<[^>]+\s)data-ke-(on\w+="[^"]*"[^>]*>)/ig, function(full, start, end) {
return start + end;
});
});
self.beforeSetHtml(function(html) {
return html.replace(/<embed[^>]*type="([^"]+)"[^>]*>(?:<\/embed>)?/ig, function(full) {
var attrs = _getAttrList(full);
attrs.src = _undef(attrs.src, '');
attrs.width = _undef(attrs.width, 0);
attrs.height = _undef(attrs.height, 0);
return _mediaImg(self.themesPath + 'common/blank.gif', attrs);
})
.replace(/<a[^>]*name="([^"]+)"[^>]*>(?:<\/a>)?/ig, function(full) {
var attrs = _getAttrList(full);
return '<img class="ke-anchor" src="' + self.themesPath + 'common/anchor.gif" data-ke-name="' + escape(attrs.name) + '" />';
})
.replace(/<script([^>]*)>([\s\S]*?)<\/script>/ig, function(full, attr, code) {
return '<div class="ke-script" data-ke-script-attr="' + escape(attr) + '">' + code + '</div>';
})
.replace(/(<[^>]*)(href|src)="([^"]*)"([^>]*>)/ig, function(full, start, key, src, end) {
if (full.match(/\sdata-ke-src="[^"]*"/i)) {
return full;
}
full = start + key + '="' + src + '"' + ' data-ke-src="' + src + '"' + end;
return full;
})
.replace(/(<[^>]+\s)(on\w+="[^"]*"[^>]*>)/ig, function(full, start, end) {
return start + 'data-ke-' + end;
})
.replace(/<table[^>]*\s+border="0"[^>]*>/ig, function(full) {
if (full.indexOf('ke-zeroborder') >= 0) {
return full;
}
return _addClassToTag(full, 'ke-zeroborder');
});
});
});
})(window);
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('pagebreak', function(K) {
var self = this, name = 'pagebreak';
self.clickToolbar(name, function() {
var cmd = self.cmd, range = cmd.range;
self.focus();
range.enlarge(true);
cmd.split(true);
var tail = self.newlineTag == 'br' || K.WEBKIT ? '' : '<p id="__kindeditor_tail_tag__"></p>';
self.insertHtml('<hr class="ke-pagebreak" style="page-break-after: always;" />' + tail);
if (tail !== '') {
var p = K('#__kindeditor_tail_tag__', self.edit.doc);
range.selectNodeContents(p[0]);
p.removeAttr('id');
cmd.select();
}
});
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('plainpaste', function(K) {
var self = this, name = 'plainpaste';
self.clickToolbar(name, function() {
var lang = self.lang(name + '.'),
html = '<div style="padding:10px 20px;">' +
'<div style="margin-bottom:10px;">' + lang.comment + '</div>' +
'<textarea class="ke-textarea" style="width:408px;height:260px;"></textarea>' +
'</div>',
dialog = self.createDialog({
name : name,
width : 450,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var html = textarea.val();
html = K.escape(html);
html = html.replace(/ /g, ' ');
if (self.newlineTag == 'p') {
html = html.replace(/^/, '<p>').replace(/$/, '</p>').replace(/\n/g, '</p><p>');
} else {
html = html.replace(/\n/g, '<br />$&');
}
self.insertHtml(html).hideDialog().focus();
}
}
}),
textarea = K('textarea', dialog.div);
textarea[0].focus();
});
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
// Google Maps: http://code.google.com/apis/maps/index.html
KindEditor.plugin('map', function(K) {
var self = this, name = 'map', lang = self.lang(name + '.');
self.clickToolbar(name, function() {
var html = ['<div style="padding:10px 20px;">',
'<div class="ke-dialog-row">',
lang.address + ' <input id="kindeditor_plugin_map_address" name="address" class="ke-input-text" value="" style="width:200px;" /> ',
'<span class="ke-button-common ke-button-outer">',
'<input type="button" name="searchBtn" class="ke-button-common ke-button" value="' + lang.search + '" />',
'</span>',
'</div>',
'<div class="ke-map" style="width:558px;height:360px;"></div>',
'</div>'].join('');
var dialog = self.createDialog({
name : name,
width : 600,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var geocoder = win.geocoder,
map = win.map,
center = map.getCenter().lat() + ',' + map.getCenter().lng(),
zoom = map.getZoom(),
maptype = map.getMapTypeId(),
url = 'http://maps.googleapis.com/maps/api/staticmap';
url += '?center=' + encodeURIComponent(center);
url += '&zoom=' + encodeURIComponent(zoom);
url += '&size=558x360';
url += '&maptype=' + encodeURIComponent(maptype);
url += '&markers=' + encodeURIComponent(center);
url += '&language=' + self.langType;
url += '&sensor=false';
self.exec('insertimage', url).hideDialog().focus();
}
},
beforeRemove : function() {
searchBtn.remove();
if (doc) {
doc.write('');
}
iframe.remove();
}
});
var div = dialog.div,
addressBox = K('[name="address"]', div),
searchBtn = K('[name="searchBtn"]', div),
win, doc;
var iframeHtml = ['<!doctype html><html><head>',
'<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />',
'<style>',
' html { height: 100% }',
' body { height: 100%; margin: 0; padding: 0; background-color: #FFF }',
' #map_canvas { height: 100% }',
'</style>',
'<script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=' + self.langType + '"></script>',
'<script>',
'var map, geocoder;',
'function initialize() {',
' var latlng = new google.maps.LatLng(31.230393, 121.473704);',
' var options = {',
' zoom: 11,',
' center: latlng,',
' disableDefaultUI: true,',
' panControl: true,',
' zoomControl: true,',
' mapTypeControl: true,',
' scaleControl: true,',
' streetViewControl: false,',
' overviewMapControl: true,',
' mapTypeId: google.maps.MapTypeId.ROADMAP',
' };',
' map = new google.maps.Map(document.getElementById("map_canvas"), options);',
' geocoder = new google.maps.Geocoder();',
' geocoder.geocode({latLng: latlng}, function(results, status) {',
' if (status == google.maps.GeocoderStatus.OK) {',
' if (results[3]) {',
' parent.document.getElementById("kindeditor_plugin_map_address").value = results[3].formatted_address;',
' }',
' }',
' });',
'}',
'function search(address) {',
' if (!map) return;',
' geocoder.geocode({address : address}, function(results, status) {',
' if (status == google.maps.GeocoderStatus.OK) {',
' map.setZoom(11);',
' map.setCenter(results[0].geometry.location);',
' var marker = new google.maps.Marker({',
' map: map,',
' position: results[0].geometry.location',
' });',
' } else {',
' alert("Invalid address: " + address);',
' }',
' });',
'}',
'</script>',
'</head>',
'<body onload="initialize();">',
'<div id="map_canvas" style="width:100%; height:100%"></div>',
'</body></html>'].join('\n');
// TODO:用doc.write(iframeHtml)方式加载时,在IE6上第一次加载报错,暂时使用src方式
var iframe = K('<iframe class="ke-textarea" frameborder="0" src="' + self.pluginsPath + 'map/map.html" style="width:558px;height:360px;"></iframe>');
function ready() {
win = iframe[0].contentWindow;
doc = K.iframeDoc(iframe);
//doc.open();
//doc.write(iframeHtml);
//doc.close();
}
iframe.bind('load', function() {
iframe.unbind('load');
if (K.IE) {
ready();
} else {
setTimeout(ready, 0);
}
});
K('.ke-map', div).replaceWith(iframe);
// search map
searchBtn.click(function() {
win.search(addressBox.val());
});
});
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('flash', function(K) {
var self = this, name = 'flash', lang = self.lang(name + '.'),
allowFlashUpload = K.undef(self.allowFlashUpload, true),
allowFileManager = K.undef(self.allowFileManager, false),
uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php');
self.plugin.flash = {
edit : function() {
var html = [
'<div style="padding:10px 20px;">',
//url
'<div class="ke-dialog-row">',
'<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
'<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:160px;" /> ',
'<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> ',
'<span class="ke-button-common ke-button-outer">',
'<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
'</span>',
'</div>',
//width
'<div class="ke-dialog-row">',
'<label for="keWidth" style="width:60px;">' + lang.width + '</label>',
'<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="550" maxlength="4" /> ',
'</div>',
//height
'<div class="ke-dialog-row">',
'<label for="keHeight" style="width:60px;">' + lang.height + '</label>',
'<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" /> ',
'</div>',
'</div>'
].join('');
var dialog = self.createDialog({
name : name,
width : 450,
height : 200,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var url = K.trim(urlBox.val()),
width = widthBox.val(),
height = heightBox.val();
if (url == 'http://' || K.invalidUrl(url)) {
alert(self.lang('invalidUrl'));
urlBox[0].focus();
return;
}
if (!/^\d*$/.test(width)) {
alert(self.lang('invalidWidth'));
widthBox[0].focus();
return;
}
if (!/^\d*$/.test(height)) {
alert(self.lang('invalidHeight'));
heightBox[0].focus();
return;
}
var html = K.mediaImg(self.themesPath + 'common/blank.gif', {
src : url,
type : K.mediaType('.swf'),
width : width,
height : height,
quality : 'high'
});
self.insertHtml(html).hideDialog().focus();
}
}
}),
div = dialog.div,
urlBox = K('[name="url"]', div),
viewServerBtn = K('[name="viewServer"]', div),
widthBox = K('[name="width"]', div),
heightBox = K('[name="height"]', div);
urlBox.val('http://');
if (allowFlashUpload) {
var uploadbutton = K.uploadbutton({
button : K('.ke-upload-button', div)[0],
fieldName : 'imgFile',
url : K.addParam(uploadJson, 'dir=flash'),
afterUpload : function(data) {
if (data.error === 0) {
var url = K.formatUrl(data.url, 'absolute');
urlBox.val(url);
if (self.afterUpload) {
self.afterUpload.call(self, url);
}
alert(self.lang('uploadSuccess'));
} else {
alert(data.message);
}
}
});
uploadbutton.fileBox.change(function(e) {
uploadbutton.submit();
});
} else {
K('.ke-upload-button', div).hide();
urlBox.width(250);
}
if (allowFileManager) {
viewServerBtn.click(function(e) {
self.loadPlugin('filemanager', function() {
self.plugin.filemanagerDialog({
viewType : 'LIST',
dirName : 'flash',
clickFn : function(url, title) {
if (self.dialogs.length > 1) {
K('[name="url"]', div).val(url);
self.hideDialog();
}
}
});
});
});
} else {
viewServerBtn.hide();
}
var img = self.plugin.getSelectedFlash();
if (img) {
var attrs = K.mediaAttrs(img.attr('data-ke-tag'));
urlBox.val(attrs.src);
widthBox.val(K.removeUnit(img.css('width')) || attrs.width || 0);
heightBox.val(K.removeUnit(img.css('height')) || attrs.height || 0);
}
urlBox[0].focus();
urlBox[0].select();
},
'delete' : function() {
self.plugin.getSelectedFlash().remove();
}
};
self.clickToolbar(name, self.plugin.flash.edit);
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('preview', function(K) {
var self = this, name = 'preview', undefined;
self.clickToolbar(name, function() {
var lang = self.lang(name + '.'),
html = '<div style="padding:10px 20px;">' +
'<iframe class="ke-textarea" frameborder="0" style="width:708px;height:400px;"></iframe>' +
'</div>',
dialog = self.createDialog({
name : name,
width : 750,
title : self.lang(name),
body : html
}),
iframe = K('iframe', dialog.div),
doc = K.iframeDoc(iframe);
doc.open();
doc.write(self.fullHtml());
doc.close();
K(doc.body).css('background-color', '#FFF');
iframe[0].contentWindow.focus();
});
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('link', function(K) {
var self = this, name = 'link';
self.plugin.link = {
edit : function() {
var lang = self.lang(name + '.'),
html = '<div style="padding:10px 20px;">' +
//url
'<div class="ke-dialog-row">' +
'<label for="keUrl">' + lang.url + '</label>' +
'<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:90%;" /></div>' +
//type
'<div class="ke-dialog-row"">' +
'<label for="keType">' + lang.linkType + '</label>' +
'<select id="keType" name="type"></select>' +
'</div>' +
'</div>',
dialog = self.createDialog({
name : name,
width : 400,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var url = K.trim(urlBox.val());
if (url == 'http://' || K.invalidUrl(url)) {
alert(self.lang('invalidUrl'));
urlBox[0].focus();
return;
}
self.exec('createlink', url, typeBox.val()).hideDialog().focus();
}
}
}),
div = dialog.div,
urlBox = K('input[name="url"]', div),
typeBox = K('select[name="type"]', div);
urlBox.val('http://');
typeBox[0].options[0] = new Option(lang.newWindow, '_blank');
typeBox[0].options[1] = new Option(lang.selfWindow, '');
var a = self.plugin.getSelectedLink();
if (a) {
self.cmd.range.selectNode(a[0]);
self.cmd.select();
urlBox.val(a.attr('data-ke-src'));
typeBox.val(a.attr('target'));
}
urlBox[0].focus();
urlBox[0].select();
},
'delete' : function() {
self.exec('unlink', null);
}
};
self.clickToolbar(name, self.plugin.link.edit);
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('insertfile', function(K) {
var self = this, name = 'insertfile',
allowFileManager = K.undef(self.allowFileManager, false),
uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
lang = self.lang(name + '.');
self.clickToolbar(name, function() {
var html = [
'<div style="padding:10px 20px;">',
'<div class="ke-dialog-row">',
'<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
'<input type="text" id="keUrl" name="url" class="ke-input-text" style="width:160px;" /> ',
'<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> ',
'<span class="ke-button-common ke-button-outer">',
'<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
'</span>',
'</div>',
//title
'<div class="ke-dialog-row">',
'<label for="keTitle" style="width:60px;">' + lang.title + '</label>',
'<input type="text" id="keTitle" class="ke-input-text" name="title" value="" style="width:160px;" /></div>',
'</div>',
//form end
'</form>',
'</div>'
].join('');
var dialog = self.createDialog({
name : name,
width : 450,
height : 180,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var url = K.trim(urlBox.val()),
title = titleBox.val();
if (url == 'http://' || K.invalidUrl(url)) {
alert(self.lang('invalidUrl'));
urlBox[0].focus();
return;
}
if (K.trim(title) === '') {
title = url;
}
var html = '<a href="' + url + '" data-ke-src="' + url + '" target="_blank">' + title + '</a>';
self.insertHtml(html);
uploadbutton.remove();
self.hideDialog().focus();
}
}
}),
div = dialog.div;
var urlBox = K('[name="url"]', div),
viewServerBtn = K('[name="viewServer"]', div),
titleBox = K('[name="title"]', div);
var uploadbutton = K.uploadbutton({
button : K('.ke-upload-button', div)[0],
fieldName : 'imgFile',
url : K.addParam(uploadJson, 'dir=file'),
afterUpload : function(data) {
if (data.error === 0) {
var url = K.formatUrl(data.url, 'absolute');
urlBox.val(url);
if (self.afterUpload) {
self.afterUpload.call(self, url);
}
alert(self.lang('uploadSuccess'));
} else {
alert(data.message);
}
}
});
uploadbutton.fileBox.change(function(e) {
uploadbutton.submit();
});
if (allowFileManager) {
viewServerBtn.click(function(e) {
self.loadPlugin('filemanager', function() {
self.plugin.filemanagerDialog({
viewType : 'LIST',
dirName : 'file',
clickFn : function(url, title) {
if (self.dialogs.length > 1) {
K('[name="url"]', div).val(url);
self.hideDialog();
}
}
});
});
});
} else {
viewServerBtn.hide();
}
urlBox.val('http://');
urlBox[0].focus();
urlBox[0].select();
});
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('media', function(K) {
var self = this, name = 'media', lang = self.lang(name + '.'),
allowMediaUpload = K.undef(self.allowMediaUpload, true),
allowFileManager = K.undef(self.allowFileManager, false),
uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php');
self.plugin.media = {
edit : function() {
var html = [
'<div style="padding:10px 20px;">',
//url
'<div class="ke-dialog-row">',
'<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
'<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:160px;" /> ',
'<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> ',
'<span class="ke-button-common ke-button-outer">',
'<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
'</span>',
'</div>',
//width
'<div class="ke-dialog-row">',
'<label for="keWidth" style="width:60px;">' + lang.width + '</label>',
'<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="550" maxlength="4" />',
'</div>',
//height
'<div class="ke-dialog-row">',
'<label for="keHeight" style="width:60px;">' + lang.height + '</label>',
'<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" />',
'</div>',
//autostart
'<div class="ke-dialog-row">',
'<label for="keAutostart">' + lang.autostart + '</label>',
'<input type="checkbox" id="keAutostart" name="autostart" value="" /> ',
'</div>',
'</div>'
].join('');
var dialog = self.createDialog({
name : name,
width : 450,
height : 230,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var url = K.trim(urlBox.val()),
width = widthBox.val(),
height = heightBox.val();
if (url == 'http://' || K.invalidUrl(url)) {
alert(self.lang('invalidUrl'));
urlBox[0].focus();
return;
}
if (!/^\d*$/.test(width)) {
alert(self.lang('invalidWidth'));
widthBox[0].focus();
return;
}
if (!/^\d*$/.test(height)) {
alert(self.lang('invalidHeight'));
heightBox[0].focus();
return;
}
var html = K.mediaImg(self.themesPath + 'common/blank.gif', {
src : url,
type : K.mediaType(url),
width : width,
height : height,
autostart : autostartBox[0].checked ? 'true' : 'false',
loop : 'true'
});
self.insertHtml(html).hideDialog().focus();
}
}
}),
div = dialog.div,
urlBox = K('[name="url"]', div),
viewServerBtn = K('[name="viewServer"]', div),
widthBox = K('[name="width"]', div),
heightBox = K('[name="height"]', div),
autostartBox = K('[name="autostart"]', div);
urlBox.val('http://');
if (allowMediaUpload) {
var uploadbutton = K.uploadbutton({
button : K('.ke-upload-button', div)[0],
fieldName : 'imgFile',
url : K.addParam(uploadJson, 'dir=media'),
afterUpload : function(data) {
if (data.error === 0) {
var url = K.formatUrl(data.url, 'absolute');
urlBox.val(url);
if (self.afterUpload) {
self.afterUpload.call(self, url);
}
alert(self.lang('uploadSuccess'));
} else {
alert(data.message);
}
}
});
uploadbutton.fileBox.change(function(e) {
uploadbutton.submit();
});
} else {
K('.ke-upload-button', div).hide();
urlBox.width(250);
}
if (allowFileManager) {
viewServerBtn.click(function(e) {
self.loadPlugin('filemanager', function() {
self.plugin.filemanagerDialog({
viewType : 'LIST',
dirName : 'media',
clickFn : function(url, title) {
if (self.dialogs.length > 1) {
K('[name="url"]', div).val(url);
self.hideDialog();
}
}
});
});
});
} else {
viewServerBtn.hide();
}
var img = self.plugin.getSelectedMedia();
if (img) {
var attrs = K.mediaAttrs(img.attr('data-ke-tag'));
urlBox.val(attrs.src);
widthBox.val(K.removeUnit(img.css('width')) || attrs.width || 0);
heightBox.val(K.removeUnit(img.css('height')) || attrs.height || 0);
autostartBox[0].checked = (attrs.autostart === 'true');
}
urlBox[0].focus();
urlBox[0].select();
},
'delete' : function() {
self.plugin.getSelectedMedia().remove();
}
};
self.clickToolbar(name, self.plugin.media.edit);
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('wordpaste', function(K) {
var self = this, name = 'wordpaste';
self.clickToolbar(name, function() {
var lang = self.lang(name + '.'),
html = '<div style="padding:10px 20px;">' +
'<div style="margin-bottom:10px;">' + lang.comment + '</div>' +
'<iframe class="ke-textarea" frameborder="0" style="width:408px;height:260px;"></iframe>' +
'</div>',
dialog = self.createDialog({
name : name,
width : 450,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var str = doc.body.innerHTML;
str = K.clearMsWord(str, self.filterMode ? self.htmlTags : K.options.htmlTags);
self.insertHtml(str).hideDialog().focus();
}
}
}),
div = dialog.div,
iframe = K('iframe', div),
doc = K.iframeDoc(iframe);
if (!K.IE) {
doc.designMode = 'on';
}
doc.open();
doc.write('<!doctype html><html><head><title>WordPaste</title></head>');
doc.write('<body style="background-color:#FFF;font-size:12px;margin:2px;">');
if (!K.IE) {
doc.write('<br />');
}
doc.write('</body></html>');
doc.close();
if (K.IE) {
doc.body.contentEditable = 'true';
}
iframe[0].contentWindow.focus();
});
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('quickformat', function(K) {
var self = this, name = 'quickformat',
blockMap = K.toMap('blockquote,center,div,h1,h2,h3,h4,h5,h6,p');
self.clickToolbar(name, function() {
self.focus();
var doc = self.edit.doc,
range = self.cmd.range,
child = K(doc.body).first(), next,
nodeList = [], subList = [],
bookmark = range.createBookmark(true);
while(child) {
next = child.next();
if (blockMap[child.name]) {
child.html(child.html().replace(/^(\s| | )+/ig, ''));
child.css('text-indent', '2em');
} else {
subList.push(child);
}
if (!next || (blockMap[next.name] || blockMap[child.name] && !blockMap[next.name])) {
if (subList.length > 0) {
nodeList.push(subList);
}
subList = [];
}
child = next;
}
K.each(nodeList, function(i, subList) {
var wrapper = K('<p style="text-indent:2em;"></p>', doc);
subList[0].before(wrapper);
K.each(subList, function(i, knode) {
wrapper.append(knode);
});
});
range.moveToBookmark(bookmark);
self.addBookmark();
});
});
/**
--------------------------
abcd<br />
1234<br />
to
<p style="text-indent:2em;">
abcd<br />
1234<br />
</p>
--------------------------
abcd<img>1233
<p>1234</p>
to
<p style="text-indent:2em;">abcd<img>1233</p>
<p style="text-indent:2em;">1234</p>
--------------------------
*/ | JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('clearhtml', function(K) {
var self = this, name = 'clearhtml';
self.clickToolbar(name, function() {
self.focus();
var html = self.html();
html = html.replace(/(<script[^>]*>)([\s\S]*?)(<\/script>)/ig, '');
html = html.replace(/(<style[^>]*>)([\s\S]*?)(<\/style>)/ig, '');
html = K.formatHtml(html, {
a : ['href', 'target'],
embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
img : ['src', 'width', 'height', 'border', 'alt', 'title', '.width', '.height'],
table : ['border'],
'td,th' : ['rowspan', 'colspan'],
'div,hr,br,tbody,tr,p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : []
});
self.html(html);
self.cmd.selection(true);
self.addBookmark();
});
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('lineheight', function(K) {
var self = this, name = 'lineheight', lang = self.lang(name + '.');
self.clickToolbar(name, function() {
var curVal = '', commonNode = self.cmd.commonNode({'*' : '.line-height'});
if (commonNode) {
curVal = commonNode.css('line-height');
}
var menu = self.createMenu({
name : name,
width : 150
});
K.each(lang.lineHeight, function(i, row) {
K.each(row, function(key, val) {
menu.addItem({
title : val,
checked : curVal === key,
click : function() {
self.cmd.toggle('<span style="line-height:' + key + ';"></span>', {
span : '.line-height=' + key
});
self.updateState();
self.addBookmark();
self.hideMenu();
}
});
});
});
});
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('image', function(K) {
var self = this, name = 'image',
allowImageUpload = K.undef(self.allowImageUpload, true),
allowFileManager = K.undef(self.allowFileManager, false),
uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
imgPath = self.basePath + 'plugins/image/images/',
lang = self.lang(name + '.');
self.plugin.image = {
edit : function() {
var html = [
'<div style="padding:10px 20px;">',
//tabs
'<div class="tabs"></div>',
//url or file
'<div class="ke-dialog-row">',
'<div class="tab1" style="display:none;">',
'<label for="keUrl" style="width:60px;">' + lang.remoteUrl + '</label>',
'<input type="text" id="keUrl" class="ke-input-text" name="url" value="" style="width:200px;" /> ',
'<span class="ke-button-common ke-button-outer">',
'<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
'</span>',
'</div>',
'<div class="tab2" style="display:none;">',
'<label style="width:60px;">' + lang.localUrl + '</label>',
'<input type="text" name="localUrl" class="ke-input-text" tabindex="-1" style="width:200px;" readonly="true" /> ',
'<input type="button" class="ke-upload-button" value="' + lang.viewServer + '" />',
'</div>',
'</div>',
//size
'<div class="ke-dialog-row">',
'<label for="keWidth" style="width:60px;">' + lang.size + '</label>',
lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> ',
lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> ',
'<img class="ke-refresh-btn" src="' + imgPath + 'refresh.gif" width="16" height="16" alt="" style="cursor:pointer;" />',
'</div>',
//align
'<div class="ke-dialog-row">',
'<label style="width:60px;">' + lang.align + '</label>',
'<input type="radio" name="align" class="ke-inline-block" value="" checked="checked" /> <img name="defaultImg" src="' + imgPath + 'align_top.gif" width="23" height="25" alt="" />',
' <input type="radio" name="align" class="ke-inline-block" value="left" /> <img name="leftImg" src="' + imgPath + 'align_left.gif" width="23" height="25" alt="" />',
' <input type="radio" name="align" class="ke-inline-block" value="right" /> <img name="rightImg" src="' + imgPath + 'align_right.gif" width="23" height="25" alt="" />',
'</div>',
//title
'<div class="ke-dialog-row">',
'<label for="keTitle" style="width:60px;">' + lang.imgTitle + '</label>',
'<input type="text" id="keTitle" class="ke-input-text" name="title" value="" style="width:200px;" /></div>',
'</div>',
'</div>'
].join('');
var dialogWidth = allowImageUpload ? 450 : 400;
dialogHeight = allowImageUpload ? 300 : 250;
var dialog = self.createDialog({
name : name,
width : dialogWidth,
height : dialogHeight,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
// insert local image
if (tabs && tabs.selectedIndex === 1) {
uploadbutton.submit();
localUrlBox.val('');
return;
}
// insert remote image
var url = K.trim(urlBox.val()),
width = widthBox.val(),
height = heightBox.val(),
title = titleBox.val(),
align = '';
alignBox.each(function() {
if (this.checked) {
align = this.value;
return false;
}
});
if (url == 'http://' || K.invalidUrl(url)) {
alert(self.lang('invalidUrl'));
urlBox[0].focus();
return;
}
if (!/^\d*$/.test(width)) {
alert(self.lang('invalidWidth'));
widthBox[0].focus();
return;
}
if (!/^\d*$/.test(height)) {
alert(self.lang('invalidHeight'));
heightBox[0].focus();
return;
}
self.exec('insertimage', url, title, width, height, 0, align).hideDialog().focus();
}
},
beforeRemove : function() {
viewServerBtn.remove();
widthBox.remove();
heightBox.remove();
refreshBtn.remove();
uploadbutton.remove();
}
}),
div = dialog.div;
var tabs;
if (allowImageUpload) {
tabs = K.tabs({
src : K('.tabs', div),
afterSelect : function(i) {
}
});
tabs.add({
title : lang.remoteImage,
panel : K('.tab1', div)
});
tabs.add({
title : lang.localImage,
panel : K('.tab2', div)
});
tabs.select(0);
} else {
K('.tab1', div).show();
}
var urlBox = K('[name="url"]', div),
localUrlBox = K('[name="localUrl"]', div),
viewServerBtn = K('[name="viewServer"]', div),
widthBox = K('[name="width"]', div),
heightBox = K('[name="height"]', div),
refreshBtn = K('.ke-refresh-btn', div),
titleBox = K('[name="title"]', div),
alignBox = K('[name="align"]');
var uploadbutton = K.uploadbutton({
button : K('.ke-upload-button', div)[0],
fieldName : 'imgFile',
url : K.addParam(uploadJson, 'dir=image'),
afterUpload : function(data) {
if (data.error === 0) {
var width = widthBox.val(),
height = heightBox.val(),
title = titleBox.val(),
align = '';
alignBox.each(function() {
if (this.checked) {
align = this.value;
return false;
}
});
var url = K.formatUrl(data.url, 'absolute');
self.exec('insertimage', url, title, width, height, 0, align).hideDialog().focus();
if (self.afterUpload) {
self.afterUpload.call(self, url);
}
} else {
alert(data.message);
}
}
});
uploadbutton.fileBox.change(function(e) {
localUrlBox.val(uploadbutton.fileBox.val());
});
if (allowFileManager) {
viewServerBtn.click(function(e) {
self.loadPlugin('filemanager', function() {
self.plugin.filemanagerDialog({
viewType : 'VIEW',
dirName : 'image',
clickFn : function(url, title) {
if (self.dialogs.length > 1) {
K('[name="url"]', div).val(url);
self.hideDialog();
}
}
});
});
});
} else {
viewServerBtn.hide();
}
var originalWidth = 0, originalHeight = 0;
function setSize(width, height) {
widthBox.val(width);
heightBox.val(height);
originalWidth = width;
originalHeight = height;
}
refreshBtn.click(function(e) {
var tempImg = K('<img src="' + urlBox.val() + '" />', self.edit.doc).css({
position : 'absolute',
visibility : 'hidden',
top : 0,
left : '1000px'
});
K(self.edit.doc.body).append(tempImg);
setSize(tempImg.width(), tempImg.height());
tempImg.remove();
});
widthBox.change(function(e) {
if (originalWidth > 0) {
heightBox.val(Math.round(originalHeight / originalWidth * parseInt(this.value, 10)));
}
});
heightBox.change(function(e) {
if (originalHeight > 0) {
widthBox.val(Math.round(originalWidth / originalHeight * parseInt(this.value, 10)));
}
});
urlBox.val('http://');
var img = self.plugin.getSelectedImage();
if (img) {
urlBox.val(img.attr('data-ke-src'));
setSize(img.width(), img.height());
titleBox.val(img.attr('title'));
alignBox.each(function() {
if (this.value === img.attr('align')) {
this.checked = true;
return false;
}
});
}
urlBox[0].focus();
urlBox[0].select();
},
'delete' : function() {
self.plugin.getSelectedImage().remove();
}
};
self.clickToolbar(name, self.plugin.image.edit);
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('anchor', function(K) {
var self = this, name = 'anchor', lang = self.lang(name + '.');
self.plugin.anchor = {
edit : function() {
var html = ['<div style="padding:10px 20px;">',
'<div class="ke-dialog-row">',
'<label for="keName">' + lang.name + '</label>',
'<input class="ke-input-text" type="text" id="keName" name="name" value="" style="width:100px;" />',
'</div>',
'</div>'].join('');
var dialog = self.createDialog({
name : name,
width : 300,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
self.insertHtml('<a name="' + nameBox.val() + '">').hideDialog().focus();
}
}
});
var div = dialog.div,
nameBox = K('input[name="name"]', div);
var img = self.plugin.getSelectedAnchor();
if (img) {
nameBox.val(unescape(img.attr('data-ke-name')));
}
nameBox[0].focus();
nameBox[0].select();
},
'delete' : function() {
self.plugin.getSelectedAnchor().remove();
}
};
self.clickToolbar(name, self.plugin.anchor.edit);
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
// google code prettify: http://google-code-prettify.googlecode.com/
// http://google-code-prettify.googlecode.com/
KindEditor.plugin('code', function(K) {
var self = this, name = 'code';
self.clickToolbar(name, function() {
var lang = self.lang(name + '.'),
html = ['<div style="padding:10px 20px;">',
'<div class="ke-dialog-row">',
'<select class="ke-code-type">',
'<option value="js">JavaScript</option>',
'<option value="html">HTML</option>',
'<option value="css">CSS</option>',
'<option value="php">PHP</option>',
'<option value="pl">Perl</option>',
'<option value="py">Python</option>',
'<option value="rb">Ruby</option>',
'<option value="java">Java</option>',
'<option value="vb">ASP/VB</option>',
'<option value="cpp">C/C++</option>',
'<option value="cs">C#</option>',
'<option value="xml">XML</option>',
'<option value="bsh">Shell</option>',
'<option value="">Other</option>',
'</select>',
'</div>',
'<textarea class="ke-textarea" style="width:408px;height:260px;"></textarea>',
'</div>'].join(''),
dialog = self.createDialog({
name : name,
width : 450,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var type = K('.ke-code-type', dialog.div).val(),
code = textarea.val(),
cls = type === '' ? '' : ' lang-' + type,
html = '<pre class="prettyprint' + cls + '">\n' + K.escape(code) + '</pre> ';
self.insertHtml(html).hideDialog().focus();
}
}
}),
textarea = K('textarea', dialog.div);
textarea[0].focus();
});
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('template', function(K) {
var self = this, name = 'template', lang = self.lang(name + '.'),
htmlPath = self.pluginsPath + name + '/html/';
function getFilePath(fileName) {
return htmlPath + fileName + '?ver=' + encodeURIComponent(K.DEBUG ? K.TIME : K.VERSION);
}
self.clickToolbar(name, function() {
var lang = self.lang(name + '.'),
arr = ['<div class="ke-plugin-template" style="padding:10px 20px;">',
'<div class="ke-header">',
// left start
'<div class="ke-left">',
lang. selectTemplate + ' <select>'];
K.each(lang.fileList, function(key, val) {
arr.push('<option value="' + key + '">' + val + '</option>');
});
html = [arr.join(''),
'</select></div>',
// right start
'<div class="ke-right">',
'<input type="checkbox" id="keReplaceFlag" name="replaceFlag" value="1" /> <label for="keReplaceFlag">' + lang.replaceContent + '</label>',
'</div>',
'<div class="ke-clearfix"></div>',
'</div>',
'<iframe class="ke-textarea" frameborder="0" style="width:458px;height:260px;background-color:#FFF;"></iframe>',
'</div>'].join('');
var dialog = self.createDialog({
name : name,
width : 500,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var doc = K.iframeDoc(iframe);
self[checkbox[0].checked ? 'html' : 'insertHtml'](doc.body.innerHTML).hideDialog().focus();
}
}
});
var selectBox = K('select', dialog.div),
checkbox = K('[name="replaceFlag"]', dialog.div),
iframe = K('iframe', dialog.div);
checkbox[0].checked = true;
iframe.attr('src', getFilePath(selectBox.val()));
selectBox.change(function() {
iframe.attr('src', getFilePath(this.value));
});
});
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('filemanager', function(K) {
var self = this, name = 'filemanager',
fileManagerJson = K.undef(self.fileManagerJson, self.basePath + 'php/file_manager_json.php'),
imgPath = self.pluginsPath + name + '/images/',
lang = self.lang(name + '.');
function makeFileTitle(filename, filesize, datetime) {
return filename + ' (' + Math.ceil(filesize / 1024) + 'KB, ' + datetime + ')';
}
function bindTitle(el, data) {
if (data.is_dir) {
el.attr('title', data.filename);
} else {
el.attr('title', makeFileTitle(data.filename, data.filesize, data.datetime));
}
}
self.plugin.filemanagerDialog = function(options) {
var width = K.undef(options.width, 520),
height = K.undef(options.height, 510),
dirName = K.undef(options.dirName, ''),
viewType = K.undef(options.viewType, 'VIEW').toUpperCase(), // "LIST" or "VIEW"
clickFn = options.clickFn;
var html = [
'<div style="padding:10px 20px;">',
// header start
'<div class="ke-plugin-filemanager-header">',
// left start
'<div class="ke-left">',
'<img class="ke-inline-block" name="moveupImg" src="' + imgPath + 'go-up.gif" width="16" height="16" border="0" alt="" /> ',
'<a class="ke-inline-block" name="moveupLink" href="javascript:;">' + lang.moveup + '</a>',
'</div>',
// right start
'<div class="ke-right">',
lang.viewType + ' <select class="ke-inline-block" name="viewType">',
'<option value="VIEW">' + lang.viewImage + '</option>',
'<option value="LIST">' + lang.listImage + '</option>',
'</select> ',
lang.orderType + ' <select class="ke-inline-block" name="orderType">',
'<option value="NAME">' + lang.fileName + '</option>',
'<option value="SIZE">' + lang.fileSize + '</option>',
'<option value="TYPE">' + lang.fileType + '</option>',
'</select>',
'</div>',
'<div class="ke-clearfix"></div>',
'</div>',
// body start
'<div class="ke-plugin-filemanager-body"></div>',
'</div>'
].join('');
var dialog = self.createDialog({
name : name,
width : width,
height : height,
title : self.lang(name),
body : html
}),
div = dialog.div,
bodyDiv = K('.ke-plugin-filemanager-body', div),
moveupImg = K('[name="moveupImg"]', div),
moveupLink = K('[name="moveupLink"]', div),
viewServerBtn = K('[name="viewServer"]', div),
viewTypeBox = K('[name="viewType"]', div),
orderTypeBox = K('[name="orderType"]', div);
function reloadPage(path, order, func) {
var param = 'path=' + path + '&order=' + order + '&dir=' + dirName;
K.ajax(K.addParam(fileManagerJson, param + '&' + new Date().getTime()), func);
}
var elList = [];
function bindEvent(el, result, data, createFunc) {
var fileUrl = K.formatUrl(result.current_url + data.filename, 'absolute'),
dirPath = encodeURIComponent(result.current_dir_path + data.filename + '/');
if (data.is_dir) {
el.click(function(e) {
reloadPage(dirPath, orderTypeBox.val(), createFunc);
});
} else if (data.is_photo) {
el.click(function(e) {
clickFn.call(this, fileUrl, data.filename);
});
} else {
el.click(function(e) {
clickFn.call(this, fileUrl, data.filename);
});
}
elList.push(el);
}
function createCommon(result, createFunc) {
// remove events
K.each(elList, function() {
this.unbind();
});
moveupLink.unbind();
viewTypeBox.unbind();
orderTypeBox.unbind();
// add events
if (result.current_dir_path) {
moveupLink.click(function(e) {
reloadPage(result.moveup_dir_path, orderTypeBox.val(), createFunc);
});
}
function changeFunc() {
if (viewTypeBox.val() == 'VIEW') {
reloadPage(result.current_dir_path, orderTypeBox.val(), createView);
} else {
reloadPage(result.current_dir_path, orderTypeBox.val(), createList);
}
}
viewTypeBox.change(changeFunc);
orderTypeBox.change(changeFunc);
bodyDiv.html('');
}
function createList(result) {
createCommon(result, createList);
var table = document.createElement('table');
table.className = 'ke-table';
table.cellPadding = 0;
table.cellSpacing = 0;
table.border = 0;
bodyDiv.append(table);
var fileList = result.file_list;
for (var i = 0, len = fileList.length; i < len; i++) {
var data = fileList[i], row = K(table.insertRow(i));
row.mouseover(function(e) {
K(this).addClass('ke-on');
})
.mouseout(function(e) {
K(this).removeClass('ke-on');
});
var iconUrl = imgPath + (data.is_dir ? 'folder-16.gif' : 'file-16.gif'),
img = K('<img src="' + iconUrl + '" width="16" height="16" alt="' + data.filename + '" align="absmiddle" />'),
cell0 = K(row[0].insertCell(0)).addClass('ke-cell ke-name').append(img).append(document.createTextNode(' ' + data.filename));
if (!data.is_dir || data.has_file) {
row.css('cursor', 'pointer');
cell0.attr('title', data.filename);
bindEvent(cell0, result, data, createList);
} else {
cell0.attr('title', lang.emptyFolder);
}
K(row[0].insertCell(1)).addClass('ke-cell ke-size').html(data.is_dir ? '-' : Math.ceil(data.filesize / 1024) + 'KB');
K(row[0].insertCell(2)).addClass('ke-cell ke-datetime').html(data.datetime);
}
}
function createView(result) {
createCommon(result, createView);
var fileList = result.file_list;
for (var i = 0, len = fileList.length; i < len; i++) {
var data = fileList[i],
div = K('<div class="ke-inline-block ke-item"></div>');
bodyDiv.append(div);
var photoDiv = K('<div class="ke-inline-block ke-photo"></div>')
.mouseover(function(e) {
K(this).addClass('ke-on');
})
.mouseout(function(e) {
K(this).removeClass('ke-on');
});
div.append(photoDiv);
var fileUrl = result.current_url + data.filename,
iconUrl = data.is_dir ? imgPath + 'folder-64.gif' : (data.is_photo ? fileUrl : imgPath + 'file-64.gif');
var img = K('<img src="' + iconUrl + '" width="80" height="80" alt="' + data.filename + '" />');
if (!data.is_dir || data.has_file) {
photoDiv.css('cursor', 'pointer');
bindTitle(photoDiv, data);
bindEvent(photoDiv, result, data, createView);
} else {
photoDiv.attr('title', lang.emptyFolder);
}
photoDiv.append(img);
div.append('<div class="ke-name" title="' + data.filename + '">' + data.filename + '</div>');
}
}
viewTypeBox.val(viewType);
reloadPage('', orderTypeBox.val(), viewType == 'VIEW' ? createView : createList);
return dialog;
}
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('table', function(K) {
var self = this, name = 'table', lang = self.lang(name + '.'), zeroborder = 'ke-zeroborder';
// 取得下一行cell的index
function _getCellIndex(table, row, cell) {
var rowSpanCount = 0;
for (var i = 0, len = row.cells.length; i < len; i++) {
if (row.cells[i] == cell) {
break;
}
rowSpanCount += row.cells[i].rowSpan - 1;
}
return cell.cellIndex - rowSpanCount;
}
self.plugin.table = {
//insert or modify table
prop : function(isInsert) {
var html = [
'<div style="padding:10px 20px;">',
//rows, cols
'<div class="ke-dialog-row">',
'<label for="keRows" style="width:90px;">' + lang.cells + '</label>',
lang.rows + ' <input type="text" id="keRows" class="ke-input-text ke-input-number" name="rows" value="" maxlength="4" /> ',
lang.cols + ' <input type="text" class="ke-input-text ke-input-number" name="cols" value="" maxlength="4" />',
'</div>',
//width, height
'<div class="ke-dialog-row">',
'<label for="keWidth" style="width:90px;">' + lang.size + '</label>',
lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> ',
'<select name="widthType">',
'<option value="%">' + lang.percent + '</option>',
'<option value="px">' + lang.px + '</option>',
'</select> ',
lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> ',
'<select name="heightType">',
'<option value="%">' + lang.percent + '</option>',
'<option value="px">' + lang.px + '</option>',
'</select>',
'</div>',
//space, padding
'<div class="ke-dialog-row">',
'<label for="kePadding" style="width:90px;">' + lang.space + '</label>',
lang.padding + ' <input type="text" id="kePadding" class="ke-input-text ke-input-number" name="padding" value="" maxlength="4" /> ',
lang.spacing + ' <input type="text" class="ke-input-text ke-input-number" name="spacing" value="" maxlength="4" />',
'</div>',
//align
'<div class="ke-dialog-row">',
'<label for="keAlign" style="width:90px;">' + lang.align + '</label>',
'<select id="keAlign" name="align">',
'<option value="">' + lang.alignDefault + '</option>',
'<option value="left">' + lang.alignLeft + '</option>',
'<option value="center">' + lang.alignCenter + '</option>',
'<option value="right">' + lang.alignRight + '</option>',
'</select>',
'</div>',
//border
'<div class="ke-dialog-row">',
'<label for="keBorder" style="width:90px;">' + lang.border + '</label>',
lang.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> ',
lang.borderColor + ' <span class="ke-inline-block ke-input-color"></span>',
'</div>',
//background color
'<div class="ke-dialog-row">',
'<label for="keBgColor" style="width:90px;">' + lang.backgroundColor + '</label>',
'<span class="ke-inline-block ke-input-color"></span>',
'</div>',
'</div>'
].join('');
var picker, currentElement;
function removePicker() {
if (picker) {
picker.remove();
picker = null;
currentElement = null;
}
}
var dialog = self.createDialog({
name : name,
width : 500,
height : 300,
title : self.lang(name),
body : html,
beforeDrag : removePicker,
beforeRemove : function() {
removePicker();
colorBox.unbind();
},
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var rows = rowsBox.val(),
cols = colsBox.val(),
width = widthBox.val(),
height = heightBox.val(),
widthType = widthTypeBox.val(),
heightType = heightTypeBox.val(),
padding = paddingBox.val(),
spacing = spacingBox.val(),
align = alignBox.val(),
border = borderBox.val(),
borderColor = K(colorBox[0]).html() || '',
bgColor = K(colorBox[1]).html() || '';
if (rows == 0 || !/^\d+$/.test(rows)) {
alert(self.lang('invalidRows'));
rowsBox[0].focus();
return;
}
if (cols == 0 || !/^\d+$/.test(cols)) {
alert(self.lang('invalidRows'));
colsBox[0].focus();
return;
}
if (!/^\d*$/.test(width)) {
alert(self.lang('invalidWidth'));
widthBox[0].focus();
return;
}
if (!/^\d*$/.test(height)) {
alert(self.lang('invalidHeight'));
heightBox[0].focus();
return;
}
if (!/^\d*$/.test(padding)) {
alert(self.lang('invalidPadding'));
paddingBox[0].focus();
return;
}
if (!/^\d*$/.test(spacing)) {
alert(self.lang('invalidSpacing'));
spacingBox[0].focus();
return;
}
if (!/^\d*$/.test(border)) {
alert(self.lang('invalidBorder'));
borderBox[0].focus();
return;
}
//modify table
if (table) {
if (width !== '') {
table.width(width + widthType);
} else {
table.css('width', '');
}
if (table[0].width !== undefined) {
table.removeAttr('width');
}
if (height !== '') {
table.height(height + heightType);
} else {
table.css('height', '');
}
if (table[0].height !== undefined) {
table.removeAttr('height');
}
table.css('background-color', bgColor);
if (table[0].bgColor !== undefined) {
table.removeAttr('bgColor');
}
if (padding !== '') {
table[0].cellPadding = padding;
} else {
table.removeAttr('cellPadding');
}
if (spacing !== '') {
table[0].cellSpacing = spacing;
} else {
table.removeAttr('cellSpacing');
}
if (align !== '') {
table[0].align = align;
} else {
table.removeAttr('align');
}
if (border !== '') {
table.attr('border', border);
} else {
table.removeAttr('border');
}
if (border === '' || border === '0') {
table.addClass(zeroborder);
} else {
table.removeClass(zeroborder);
}
if (borderColor !== '') {
table.attr('borderColor', borderColor);
} else {
table.removeAttr('borderColor');
}
self.hideDialog().focus();
return;
}
//insert new table
var style = '';
if (width !== '') {
style += 'width:' + width + widthType + ';';
}
if (height !== '') {
style += 'height:' + height + heightType + ';';
}
if (bgColor !== '') {
style += 'background-color:' + bgColor + ';';
}
var html = '<table';
if (style !== '') {
html += ' style="' + style + '"';
}
if (padding !== '') {
html += ' cellpadding="' + padding + '"';
}
if (spacing !== '') {
html += ' cellspacing="' + spacing + '"';
}
if (align !== '') {
html += ' align="' + align + '"';
}
if (border !== '') {
html += ' border="' + border + '"';
}
if (border === '' || border === '0') {
html += ' class="' + zeroborder + '"';
}
if (borderColor !== '') {
html += ' bordercolor="' + borderColor + '"';
}
html += '>';
for (var i = 0; i < rows; i++) {
html += '<tr>';
for (var j = 0; j < cols; j++) {
html += '<td>' + (K.IE ? '' : '<br />') + '</td>';
}
html += '</tr>';
}
html += '</table>';
if (!K.IE) {
html += '<br />';
}
self.insertHtml(html);
self.select().hideDialog().focus();
self.addBookmark();
}
}
}),
div = dialog.div,
rowsBox = K('[name="rows"]', div).val(3),
colsBox = K('[name="cols"]', div).val(2),
widthBox = K('[name="width"]', div).val(100),
heightBox = K('[name="height"]', div),
widthTypeBox = K('[name="widthType"]', div),
heightTypeBox = K('[name="heightType"]', div),
paddingBox = K('[name="padding"]', div).val(2),
spacingBox = K('[name="spacing"]', div).val(0),
alignBox = K('[name="align"]', div),
borderBox = K('[name="border"]', div).val(1),
colorBox = K('.ke-input-color', div);
function setColor(box, color) {
color = color.toUpperCase();
box.css('background-color', color);
box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
box.html(color);
}
setColor(K(colorBox[0]), '#000000');
setColor(K(colorBox[1]), '');
function clickHandler(e) {
removePicker();
if (!picker || this !== currentElement) {
var box = K(this),
pos = box.pos();
picker = K.colorpicker({
x : pos.x,
y : pos.y + box.height(),
z : 811214,
selectedColor : K(this).html(),
colors : self.colorTable,
noColor : self.lang('noColor'),
click : function(color) {
setColor(box, color);
removePicker();
}
});
currentElement = this;
}
}
colorBox.click(clickHandler);
// foucs and select
rowsBox[0].focus();
rowsBox[0].select();
var table;
if (isInsert) {
return;
}
//get selected table node
table = self.plugin.getSelectedTable();
if (table) {
rowsBox.val(table[0].rows.length);
colsBox.val(table[0].rows.length > 0 ? table[0].rows[0].cells.length : 0);
rowsBox.attr('disabled', true);
colsBox.attr('disabled', true);
var match,
tableWidth = table[0].style.width || table[0].width,
tableHeight = table[0].style.height || table[0].height;
if (tableWidth !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableWidth))) {
widthBox.val(match[1]);
widthTypeBox.val(match[2]);
} else {
widthBox.val('');
}
if (tableHeight !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableHeight))) {
heightBox.val(match[1]);
heightTypeBox.val(match[2]);
}
paddingBox.val(table[0].cellPadding || '');
spacingBox.val(table[0].cellSpacing || '');
alignBox.val(table[0].align || '');
borderBox.val(table[0].border === undefined ? '' : table[0].border);
setColor(K(colorBox[0]), K.toHex(table.attr('borderColor') || ''));
setColor(K(colorBox[1]), K.toHex(table[0].style.backgroundColor || table[0].bgColor || ''));
widthBox[0].focus();
widthBox[0].select();
}
},
//modify cell
cellprop : function() {
var html = [
'<div style="padding:10px 20px;">',
//width, height
'<div class="ke-dialog-row">',
'<label for="keWidth" style="width:90px;">' + lang.size + '</label>',
lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> ',
'<select name="widthType">',
'<option value="%">' + lang.percent + '</option>',
'<option value="px">' + lang.px + '</option>',
'</select> ',
lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> ',
'<select name="heightType">',
'<option value="%">' + lang.percent + '</option>',
'<option value="px">' + lang.px + '</option>',
'</select>',
'</div>',
//align
'<div class="ke-dialog-row">',
'<label for="keAlign" style="width:90px;">' + lang.align + '</label>',
lang.textAlign + ' <select id="keAlign" name="textAlign">',
'<option value="">' + lang.alignDefault + '</option>',
'<option value="left">' + lang.alignLeft + '</option>',
'<option value="center">' + lang.alignCenter + '</option>',
'<option value="right">' + lang.alignRight + '</option>',
'</select> ',
lang.verticalAlign + ' <select name="verticalAlign">',
'<option value="">' + lang.alignDefault + '</option>',
'<option value="top">' + lang.alignTop + '</option>',
'<option value="middle">' + lang.alignMiddle + '</option>',
'<option value="bottom">' + lang.alignBottom + '</option>',
'<option value="baseline">' + lang.alignBaseline + '</option>',
'</select>',
'</div>',
//border
'<div class="ke-dialog-row">',
'<label for="keBorder" style="width:90px;">' + lang.border + '</label>',
lang.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> ',
lang.borderColor + ' <span class="ke-inline-block ke-input-color"></span>',
'</div>',
//background color
'<div class="ke-dialog-row">',
'<label for="keBgColor" style="width:90px;">' + lang.backgroundColor + '</label>',
'<span class="ke-inline-block ke-input-color"></span>',
'</div>',
'</div>'
].join('');
var picker, currentElement;
function removePicker() {
if (picker) {
picker.remove();
picker = null;
currentElement = null;
}
}
var dialog = self.createDialog({
name : name,
width : 500,
height : 220,
title : self.lang('tablecell'),
body : html,
beforeDrag : removePicker,
beforeRemove : function() {
removePicker();
colorBox.unbind();
},
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var width = widthBox.val(),
height = heightBox.val(),
widthType = widthTypeBox.val(),
heightType = heightTypeBox.val(),
padding = paddingBox.val(),
spacing = spacingBox.val(),
textAlign = textAlignBox.val(),
verticalAlign = verticalAlignBox.val(),
border = borderBox.val(),
borderColor = K(colorBox[0]).html() || '',
bgColor = K(colorBox[1]).html() || '';
if (!/^\d*$/.test(width)) {
alert(self.lang('invalidWidth'));
widthBox[0].focus();
return;
}
if (!/^\d*$/.test(height)) {
alert(self.lang('invalidHeight'));
heightBox[0].focus();
return;
}
if (!/^\d*$/.test(border)) {
alert(self.lang('invalidBorder'));
borderBox[0].focus();
return;
}
cell.css({
width : width !== '' ? (width + widthType) : '',
height : height !== '' ? (height + heightType) : '',
'background-color' : bgColor,
'text-align' : textAlign,
'vertical-align' : verticalAlign,
'border-width' : border,
'border-style' : border !== '' ? 'solid' : '',
'border-color' : borderColor
});
self.hideDialog().focus();
self.addBookmark();
}
}
}),
div = dialog.div,
widthBox = K('[name="width"]', div).val(100),
heightBox = K('[name="height"]', div),
widthTypeBox = K('[name="widthType"]', div),
heightTypeBox = K('[name="heightType"]', div),
paddingBox = K('[name="padding"]', div).val(2),
spacingBox = K('[name="spacing"]', div).val(0),
textAlignBox = K('[name="textAlign"]', div),
verticalAlignBox = K('[name="verticalAlign"]', div),
borderBox = K('[name="border"]', div).val(1),
colorBox = K('.ke-input-color', div);
function setColor(box, color) {
color = color.toUpperCase();
box.css('background-color', color);
box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
box.html(color);
}
setColor(K(colorBox[0]), '#000000');
setColor(K(colorBox[1]), '');
function clickHandler(e) {
removePicker();
if (!picker || this !== currentElement) {
var box = K(this),
pos = box.pos();
picker = K.colorpicker({
x : pos.x,
y : pos.y + box.height(),
z : 811214,
selectedColor : K(this).html(),
colors : self.colorTable,
noColor : self.lang('noColor'),
click : function(color) {
setColor(box, color);
removePicker();
}
});
currentElement = this;
}
}
colorBox.click(clickHandler);
// foucs and select
widthBox[0].focus();
widthBox[0].select();
// get selected cell
var cell = self.plugin.getSelectedCell();
var match,
cellWidth = cell[0].style.width || cell[0].width || '',
cellHeight = cell[0].style.height || cell[0].height || '';
if ((match = /^(\d+)((?:px|%)*)$/.exec(cellWidth))) {
widthBox.val(match[1]);
widthTypeBox.val(match[2]);
} else {
widthBox.val('');
}
if ((match = /^(\d+)((?:px|%)*)$/.exec(cellHeight))) {
heightBox.val(match[1]);
heightTypeBox.val(match[2]);
}
textAlignBox.val(cell[0].style.textAlign || '');
verticalAlignBox.val(cell[0].style.verticalAlign || '');
var border = cell[0].style.borderWidth || '';
if (border) {
border = parseInt(border);
}
borderBox.val(border);
setColor(K(colorBox[0]), K.toHex(cell[0].style.borderColor || ''));
setColor(K(colorBox[1]), K.toHex(cell[0].style.backgroundColor || ''));
widthBox[0].focus();
widthBox[0].select();
},
insert : function() {
this.prop(true);
},
'delete' : function() {
var table = self.plugin.getSelectedTable();
self.cmd.range.setStartBefore(table[0]).collapse(true);
self.cmd.select();
table.remove();
self.addBookmark();
},
colinsert : function(offset) {
var table = self.plugin.getSelectedTable()[0],
row = self.plugin.getSelectedRow()[0],
cell = self.plugin.getSelectedCell()[0],
index = cell.cellIndex + offset;
for (var i = 0, len = table.rows.length; i < len; i++) {
var newRow = table.rows[i],
newCell = newRow.insertCell(index);
newCell.innerHTML = K.IE ? '' : '<br />';
// 调整下一行的单元格index
index = _getCellIndex(table, newRow, newCell);
}
self.cmd.range.selectNodeContents(cell).collapse(true);
self.cmd.select();
self.addBookmark();
},
colinsertleft : function() {
this.colinsert(0);
},
colinsertright : function() {
this.colinsert(1);
},
rowinsert : function(offset) {
var table = self.plugin.getSelectedTable()[0],
row = self.plugin.getSelectedRow()[0],
cell = self.plugin.getSelectedCell()[0],
newRow;
if (offset === 1) {
newRow = table.insertRow(row.rowIndex + (cell.rowSpan - 1) + offset);
} else {
newRow = table.insertRow(row.rowIndex);
}
for (var i = 0, len = row.cells.length; i < len; i++) {
var newCell = newRow.insertCell(i);
// copy colspan
if (offset === 1 && row.cells[i].colSpan > 1) {
newCell.colSpan = row.cells[i].colSpan;
}
newCell.innerHTML = K.IE ? '' : '<br />';
}
self.cmd.range.selectNodeContents(cell).collapse(true);
self.cmd.select();
self.addBookmark();
},
rowinsertabove : function() {
this.rowinsert(0);
},
rowinsertbelow : function() {
this.rowinsert(1);
},
rowmerge : function() {
var table = self.plugin.getSelectedTable()[0],
row = self.plugin.getSelectedRow()[0],
cell = self.plugin.getSelectedCell()[0],
rowIndex = row.rowIndex, // 当前行的index
nextRowIndex = rowIndex + cell.rowSpan, // 下一行的index
nextRow = table.rows[nextRowIndex]; // 下一行
// 最后一行不能合并
if (table.rows.length <= nextRowIndex) {
return;
}
var cellIndex = _getCellIndex(table, row, cell); // 下一行单元格的index
if (nextRow.cells.length <= cellIndex) {
return;
}
var nextCell = nextRow.cells[cellIndex]; // 下一行单元格
// 上下行的colspan不一致时不能合并
if (cell.colSpan !== nextCell.colSpan) {
return;
}
cell.rowSpan += nextCell.rowSpan;
nextRow.deleteCell(cellIndex);
self.cmd.range.selectNodeContents(cell).collapse(true);
self.cmd.select();
self.addBookmark();
},
colmerge : function() {
var table = self.plugin.getSelectedTable()[0],
row = self.plugin.getSelectedRow()[0],
cell = self.plugin.getSelectedCell()[0],
rowIndex = row.rowIndex, // 当前行的index
cellIndex = cell.cellIndex,
nextCellIndex = cellIndex + 1;
// 最后一列不能合并
if (row.cells.length <= nextCellIndex) {
return;
}
var nextCell = row.cells[nextCellIndex];
// 左右列的rowspan不一致时不能合并
if (cell.rowSpan !== nextCell.rowSpan) {
return;
}
cell.colSpan += nextCell.colSpan;
row.deleteCell(nextCellIndex);
self.cmd.range.selectNodeContents(cell).collapse(true);
self.cmd.select();
self.addBookmark();
},
rowsplit : function() {
var table = self.plugin.getSelectedTable()[0],
row = self.plugin.getSelectedRow()[0],
cell = self.plugin.getSelectedCell()[0],
rowIndex = row.rowIndex;
// 不是可分割单元格
if (cell.rowSpan === 1) {
return;
}
var cellIndex = _getCellIndex(table, row, cell);
for (var i = 1, len = cell.rowSpan; i < len; i++) {
var newRow = table.rows[rowIndex + i],
newCell = newRow.insertCell(cellIndex);
if (cell.colSpan > 1) {
newCell.colSpan = cell.colSpan;
}
newCell.innerHTML = K.IE ? '' : '<br />';
// 调整下一行的单元格index
cellIndex = _getCellIndex(table, newRow, newCell);
}
K(cell).removeAttr('rowSpan');
self.cmd.range.selectNodeContents(cell).collapse(true);
self.cmd.select();
self.addBookmark();
},
colsplit : function() {
var table = self.plugin.getSelectedTable()[0],
row = self.plugin.getSelectedRow()[0],
cell = self.plugin.getSelectedCell()[0],
cellIndex = cell.cellIndex;
// 不是可分割单元格
if (cell.colSpan === 1) {
return;
}
for (var i = 1, len = cell.colSpan; i < len; i++) {
var newCell = row.insertCell(cellIndex + i);
if (cell.rowSpan > 1) {
newCell.rowSpan = cell.rowSpan;
}
newCell.innerHTML = K.IE ? '' : '<br />';
}
K(cell).removeAttr('colSpan');
self.cmd.range.selectNodeContents(cell).collapse(true);
self.cmd.select();
self.addBookmark();
},
coldelete : function() {
var table = self.plugin.getSelectedTable()[0],
row = self.plugin.getSelectedRow()[0],
cell = self.plugin.getSelectedCell()[0],
index = cell.cellIndex;
for (var i = 0, len = table.rows.length; i < len; i++) {
var newRow = table.rows[i],
newCell = newRow.cells[index];
if (newCell.colSpan > 1) {
newCell.colSpan -= 1;
if (newCell.colSpan === 1) {
K(newCell).removeAttr('colSpan');
}
} else {
newRow.deleteCell(index);
}
// 跳过不需要删除的行
if (newCell.rowSpan > 1) {
i += newCell.rowSpan - 1;
}
}
if (row.cells.length === 0) {
self.cmd.range.setStartBefore(table).collapse(true);
self.cmd.select();
K(table).remove();
} else {
self.cmd.selection(true);
}
self.addBookmark();
},
rowdelete : function() {
var table = self.plugin.getSelectedTable()[0],
row = self.plugin.getSelectedRow()[0],
cell = self.plugin.getSelectedCell()[0],
rowIndex = row.rowIndex;
// 从下到上删除
for (var i = cell.rowSpan - 1; i >= 0; i--) {
table.deleteRow(rowIndex + i);
}
if (table.rows.length === 0) {
self.cmd.range.setStartBefore(table).collapse(true);
self.cmd.select();
K(table).remove();
} else {
self.cmd.selection(true);
}
self.addBookmark();
}
};
self.clickToolbar(name, self.plugin.table.prop);
});
| JavaScript |
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('emoticons', function(K) {
var self = this, name = 'emoticons',
path = (self.emoticonsPath || self.basePath + 'plugins/emoticons/images/'),
allowPreview = self.allowPreviewEmoticons === undefined ? true : self.allowPreviewEmoticons,
currentPageNum = 1;
self.clickToolbar(name, function() {
var rows = 5, cols = 9, total = 135, startNum = 0,
cells = rows * cols, pages = Math.ceil(total / cells),
colsHalf = Math.floor(cols / 2),
wrapperDiv = K('<div class="ke-plugin-emoticons"></div>'),
elements = [],
menu = self.createMenu({
name : name,
beforeRemove : function() {
removeEvent();
}
});
menu.div.append(wrapperDiv);
var previewDiv, previewImg;
if (allowPreview) {
previewDiv = K('<div class="ke-preview"></div>').css('right', 0);
previewImg = K('<img class="ke-preview-img" src="' + path + startNum + '.gif" />');
wrapperDiv.append(previewDiv);
previewDiv.append(previewImg);
}
function bindCellEvent(cell, j, num) {
if (previewDiv) {
cell.mouseover(function() {
if (j > colsHalf) {
previewDiv.css('left', 0);
previewDiv.css('right', '');
} else {
previewDiv.css('left', '');
previewDiv.css('right', 0);
}
previewImg.attr('src', path + num + '.gif');
K(this).addClass('ke-on');
});
} else {
cell.mouseover(function() {
K(this).addClass('ke-on');
});
}
cell.mouseout(function() {
K(this).removeClass('ke-on');
});
cell.click(function(e) {
self.insertHtml('<img src="' + path + num + '.gif" border="0" alt="" />').hideMenu().focus();
e.stop();
});
}
function createEmoticonsTable(pageNum, parentDiv) {
var table = document.createElement('table');
parentDiv.append(table);
if (previewDiv) {
K(table).mouseover(function() {
previewDiv.show();
});
K(table).mouseout(function() {
previewDiv.hide();
});
elements.push(K(table));
}
table.className = 'ke-table';
table.cellPadding = 0;
table.cellSpacing = 0;
table.border = 0;
var num = (pageNum - 1) * cells + startNum;
for (var i = 0; i < rows; i++) {
var row = table.insertRow(i);
for (var j = 0; j < cols; j++) {
var cell = K(row.insertCell(j));
cell.addClass('ke-cell');
bindCellEvent(cell, j, num);
var span = K('<span class="ke-img"></span>')
.css('background-position', '-' + (24 * num) + 'px 0px')
.css('background-image', 'url(' + path + 'static.gif)');
cell.append(span);
elements.push(cell);
num++;
}
}
return table;
}
var table = createEmoticonsTable(currentPageNum, wrapperDiv);
function removeEvent() {
K.each(elements, function() {
this.unbind();
});
}
var pageDiv;
function bindPageEvent(el, pageNum) {
el.click(function(e) {
removeEvent();
table.parentNode.removeChild(table);
pageDiv.remove();
table = createEmoticonsTable(pageNum, wrapperDiv);
createPageTable(pageNum);
currentPageNum = pageNum;
e.stop();
});
}
function createPageTable(currentPageNum) {
pageDiv = K('<div class="ke-page"></div>');
wrapperDiv.append(pageDiv);
for (var pageNum = 1; pageNum <= pages; pageNum++) {
if (currentPageNum !== pageNum) {
var a = K('<a href="javascript:;">[' + pageNum + ']</a>');
bindPageEvent(a, pageNum);
pageDiv.append(a);
elements.push(a);
} else {
pageDiv.append(K('@[' + pageNum + ']'));
}
pageDiv.append(K('@ '));
}
}
createPageTable(currentPageNum);
});
});
| JavaScript |
/* jQuery form plug-in 1.0.1
*
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
* http://docs.jquery.com/Plugins/Validation
*
* Copyright (c) 2010 NickCheng
* You can affiliation me My Email Address :NickCZPing@gmail.com
* And My QQ Number is: 406762380
*
* $Id: jquery.form-1.0.1 6403 2010-04-09 09:07
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Power description :
* All of the form item's valid
* Involve hidden ,textBox,radio,checkBox,textArea,select and so on
* I will define their's style and validate
* And for example the textBox have many items userName,companyName,telephone,Address and so on
* 目前该版本支持:ie6,7,8;firefox3.以上;Chrome
*/
(function($) {
var str = "";
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
//判断浏览器类型
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
//定义所有需验证的控件名称
//定义所有的正则
var WIDGETREG =
{
'username':/^[A-Za-z]\w{3,19}$/,
'feikong':'',
'password':/^[0-9A-z-_~!@#$%^&*()_+`\[\]\;\:\"\<\>]{6,20}$/,
'number':'',//这个用于验证学号格式是否正确以及是否存在
'chineseName':/(^[\u4e00-\u9fa5]*$)/,
'address':/(^[\u4e00-\u9fa5]*[0-9a-zA-Z]*([\u4e00-\u9fa5]|[0-9a-zA-Z])*$)/,
'qq':/^[1-9][0-9]{4,}$/,
'email':/^[a-zA-Z0-9_\\.]+@[a-zA-Z0-9-]+[\\.a-zA-Z]+$/,
'phone':/^(\+)?([0-9]{1,3}[-\s])?([0-9]{3,4}[-\s])?([0-9]{7,8})([-\s][0-9]{1,5})?$/,
'mobile':/^([0-9]{11,12})?$/,
'zipcode':/^[0-9]{6}$/,
'money':/^-?\d+(\.\d{0,2})?$/,
'authcode':/^[^\s?<>\'\"!@%#$~&*():;]*$/,
'datetime':/^\d{4}-\d{2}-\d{2}$/,
'bankaccount':/^(?:\d{4}){4,5}\d{3}$/,
'textbox':/^[^;,'"<>#]*$/,
'textarea':/^[^;,'"<>#]*$/,
'confirmpwd':'',
'commonSelect':'',
'commonRadio':'',
'idcard':'',
'invalidchar': /^[^<>$';]*$/,
'realName':/^([\u4e00-\u9fa5]{2,12})/g,//真实姓名,必须为汉字开始为(/^([\u4e00-\u9fa5]{2,12})|([a-zA-Z-\s]{3,20})$/)!
'urlname':/^([a-z]+:\/\/)?([\w-]+)\.([\w-]+)(\.[\w-]+)*(\/)?[^s]*$/
};
//初始化项当鼠标移向控件弹出提示信息,移开则隐藏提示信息(obj:当前对象,str_:初始化提示信息)
$.init = function(obj,str_){
if(obj.attr("required")){
var redstar = "<span class='redstar'>*</span>"
var newtitle= obj.parent().prev().find('label').text();
var trimtitle = $.trim(newtitle);
if(_isHaveStar(trimtitle))
obj.parent().prev().find('label').html(newtitle + redstar);
}
obj.hover(function(){
var splitclass = obj.attr('class').substring(16);
if(obj.val().length == 0 || splitclass == 'error-style'){
//如果存在则不加
if($('#tooltips-box').size()==0){
if($('#TB_window').size() > 0){
$('#TB_window').append('<div id="tooltips-box"><div class="tooltips-howpanel-top" style="display:none;"></div><div class="tooltips-howpanel"></div><iframe id="tooltips_iframe"></iframe></div>');
}else{
$('body').append('<div id="tooltips-box"><div class="tooltips-howpanel-top" style="display:none;"></div><div class="tooltips-howpanel"></div><iframe id="tooltips_iframe"></iframe></div>');
}
}
tipShow();
}else{
if(obj.attr('type') == 'text') str_ = '输入正确' ;
tipHidden();
}
},function(){
tipHidden();
});
//获得当前高度(obj:当前对象)
_getTop = function(obj){
var position = obj.position();
var type = obj.attr("type");
var top = position.top ;
if(type == "textarea"){
var _top = 0;
if(Sys.ie) _top = obj.attr("rows") * 22;
if(Sys.firefox) _top = obj.attr("rows") * 19;
else _top = obj.attr("rows") * 17;
var tatop = top + _top;
return tatop;
}else{
var untatop = top+28;
return untatop;
}
};
_getWidth = function(object) {
return object.offsetWidth;
};
_getLeft = function(obj) {
var position = obj.position();
var left = position.left;
return left;
};
/* _getTop = function(object) {
var go = object;
var oParent,oTop = go.offsetTop;
while(go.offsetParent!=null) {
oParent = go.offsetParent;
oTop += oParent.offsetTop;
go = oParent;
}
return oTop + $(object).height()+ 5;
};*/
tipShow = function(){
var left = _getLeft(obj);
var width = $(".tooltips-howpanel").width();
var swidth = document.body.scrollWidth;
var xx = left+width-swidth;
var lf = 0;
var tp = _getTop(obj);
if(xx>0){
lf = _getLeft(obj)-xx;
$('.tooltips-howpanel-top').css({left:xx+'px'});
//$('.tooltips-howpanel-top').css({left:(lf+xx)+'px',top:tp+'px'});
}else{
lf = _getLeft(obj);
$('.tooltips-howpanel-top').css({left:'10px'});
//$('.tooltips-howpanel-top').css({left:lf+10+'px',top:tp+'px'});
}
$('#tooltips-box').css({left:lf+'px',top:tp+'px',position:'absolute'});
$('#tooltips_iframe').css({width:'240px',border:0,height:'35px'});
//$('.tooltips-howpanel').css({left:lf+'px',top:tp+'px'});
$('.tooltips-howpanel').html(str_);
$('.tooltips-howpanel').fadeIn("fast");
$('.tooltips-howpanel-top').fadeIn("fast");
};
tipHidden = function(){
$('.tooltips-howpanel').hide();
$('.tooltips-howpanel-top').hide();
$('#tooltips_iframe').css({width:'0px',height:'0px'});
};
// obj.info = obj.options.message;
obj.hover(window['tipShow'],window['tipHidden'])
.focus(window['tipShow'])
.blur(window['tipHidden']);
};
//判断是否需要加“*”号
_isHaveStar = function(str){
var flag = true;
if(Sys.ie || Sys.chrome){
str = str.substring(str.length-1);
if(str == "*")
return false;
}else{
for(var i in str){
if(str[i] == "*"){
flag = false;
break;
}
}
}
return flag;
};
//表单所填信息验证(name:当前方法名,obj:当前控件对象)
$.validator = function(name , obj,param){
var title = _getLabelInfo(obj);
var errorPrompt = title+'格式输入错误.';
str = obj.val();
for(j in WIDGETREG){
var reg = WIDGETREG[j];
if(name == j && reg != ""){
if(str !="" && str != null && reg.test(str)){
str = str;
}else{
str = this.error = {level:'error' ,text:errorPrompt};
}
return str;
}
else{
if(name == 'idcard'){
if(str.length!==16 && str.lenght!=17 && /^[1-9]\d{5}(?:\d{2}|\d{4})(?:(?:01|03|05|07|08|10|12)(?:0[1-9]|[1-2]\d|3[0-1])|(?:04|06|09|11)(?:0[1-9]|[1-2]\d|30)|02(?:0[1-9]|[1-2]\d))(?:\d{3}|\d{4}|\d{3}[xX])$/.test(str)){
str = str;
}else{
str = this.error = {level:'error' ,text:errorPrompt+'(规范:15位或者18位)!'};
}
return str;
}
else if(name == 'confirmpwd'){
var pwd = obj.parent().parent().parent().find("input[type='password']").val();
if(str != pwd){
str = this.error = {level:'error' ,text:'两次密码输入不一致.'};
}
if( /^[0-9A-z-_~!@#$%^&*()_+`\[\]\;\:\"\<\>]{6,20}$/.test(str))
{
str = str;
}
else{
str = this.error = {level:'error' ,text:errorPrompt};
}
return str;
}
else if(name == 'commonSelect'){
if(str != -1){
str=str;
}else{
str = this.error = {level:'error' ,text:'请选择'+title};
}
return str;
}else if ( name == 'callback' ){
var res = param.callback( $(obj).val() );
if( !res || res == true || res.result == true) {}
else {
str = { text : res.message , level : "error"} ;
}
return str;
}
/*else{
if(str != "" && str != null){
str=str;
}else{
str = this.error = {level:'error' ,text:'请选择'+title};
}
return str;
}*/
//******************后加如的ajax验证学号是否已注册********************************
else if(name == 'number'){
if(str==""){
str = this.error = {level:'error' ,text:'请输入'+title};
}else{
var data = 'uname=' + str;
$.ajax({
async :false,//默认为true,为true时为异步提交,无法更新str
type: "GET",
url: "/HongZhu/StunumIsExists",
data: data,
success: function (Msg) {
if(Msg=="1"){
str = this.error = {level:'error' ,text:'学号已存在'};
}
}
})}
return str;
}
//***************************THE END******************************************
else if(name == 'feikong'){
if(str==""){
str = this.error = {level:'error' ,text:'请输入'+title};
}
return str;
}
}
}
};
_callbackValid = function( name , self , param ) {
var valid = $.validator( name ,self , param);
if(valid != self.val()){
if(valid['level'] == 'error'){
$.addStyle(self);
$.init(self,valid['text']);
}
}else{
$.removeStyle(self);
}
};
//必填项验证(itemName:当前方法名,self:当前控件对象)
_requiredVaild = function(itemname,self){
if(self.attr("required")){
var valid = $.validator(itemname,self);
if(valid != self.val()){
if(valid['level'] == 'error'){
$.addStyle(self);
$.init(self,valid['text']);
}
}else{
$.removeStyle(self);
}
}
};
//可填项验证(itemName:当前方法名,self:当前控件对象)
_commonValid = function(itemname,self){
if(self.attr("required")){
var valid = $.validator(itemname,self);
if(valid != self.val()){
if(valid['level'] == 'error'){
$.addStyle(self);
$.init(self,valid['text']);
}
}else{
$.removeStyle(self);
}
}else{
if(self.val() == ""){
$.removeStyle(self);
}
if(self.val() !="" ){
var valid = $.validator(itemname,self);
if(valid != self.val()){
if(valid['level'] == 'error'){
$.addStyle(self);
$.init(self,valid['text']);
}
}else{
$.removeStyle(self);
}
}
}
};
//提交时验证(form:当前form对象)
submitValid = function(form){
var flag = true ;
$.each($(":input[type!='checkbox'][type!='radio'][type!='button'][type!='submit'][type!='reset']" , form ) , function(){
if(flag==false) return;
var self = $(this) ;
var selftype = self.attr("type");
var selfvalid = self.attr("valid");
var selfid = self.attr("id");
if(selfvalid == undefined ){
if(_checkSelfid(self)==true) selfvalid = selfid;
else selfvalid = _checkSelfid(self);//
}
var valid = $.validator(selfvalid,self);
if(self.attr("required")){
if(valid != undefined ){
if(valid != self.val()){
if(valid['level'] == 'error'){
$.addStyle(self);
$.init(self,valid['text']);
flag =false;
return;
}
}else{
$.removeStyle(self);
flag =true;
}
}
}else{
if(self.val() == ""){
$.removeStyle(self);
flag =true;
}
if(self.val() !="" ){
if(valid != undefined){
if(valid != self.val()){
if(valid['level'] == 'error'){
$.addStyle(self);
$.init(self,valid['text']);
flag =false;
return;
}
}else{
$.removeStyle(self);
flag =true;
}
}
}
}
}) ;
return flag;
};
//查看是否定义了名为控件id的验证器(self:当前控件对象)返回true:表示存在false:不存在
_checkSelfid = function(self){
var flag = false;
for(i in WIDGETREG){
if(i == self.attr('id')){
flag = true;
break;
}
}
//如果不存在,进行分析如果type为textarea则返回验证器‘textarea’
if(!flag){
if(self.attr('type') == 'textarea'){
return 'textarea';
}
else{
return 'textbox';
}
}
return flag;
};
//获得表单值(form:当前form对象)
_getData = function(form){
var data = "{";
$.each($(":input[type!='button'][type!='submit'][type!='reset']" , form ) , function(){
var self = $(this) ;
var selfid = self.attr("id");
var selfval = (self.val() != null && self.val() != '')? self.val() : null;
data += selfid+":"+selfval+",";
});
data = data.substring(0,data.length-1);
data = data + "}";
return data;
};
//获得当前控件前提示(self:当前控件对象)
_getLabelInfo = function(self){
var _title = self.parent().prev().find('label').html();
if(_title == null)
_title = self.parent().prev().html();
return _title.replace('\:','').replace('\*','');
};
//添加错误提示信息样式(隐藏正确样式)(obj:当前控件对象)
$.addStyle = function(obj){
obj.removeClass('right-style');
// $('#tooltips-box').hide();
tipShow();
obj.addClass("error-style");
};
//添加正确时样式(隐藏错误提示样式)(obj:当前控件对象)
$.removeStyle = function(obj){
obj.removeClass('error-style');
obj.remove('error-style');
// obj.removeClass('prompt-info');
tipHidden();
obj.addClass('right-style');
};
$.tipHidden = function(){
$('.tooltips-howpanel').hide();
$('.tooltips-howpanel-top').hide();
$('#tooltips_iframe').css({width:'0px',height:'0px'});
};
})(jQuery);
$(function(){
$(".formBody").find("input[type!='radio'][type!='checkbox'][type!='button'][type!='submit'][type!='reset']").each(function(){
$(this).addClass("form_item_input");
});
});
| JavaScript |
/*! jQuery form plug-in 1.0.1
*
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
* http://docs.jquery.com/Plugins/Validation
*
* Copyright (c) 2010 NickCheng
* You can affiliation me My Email Address :NickCZPing@gmail.com
* And My QQ Number is: 406762380
*
* $Id: jquery.form-1.0.1 6403 2010-04-09 09:07
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Power description :
* All of the form item's define
* Involve hidden 、textBox、radio、checkBox、textArea、select and so on
* I will define their's style and validate
* And for example the textBox have many items user Name,company Name,telephone,Address and so on
*/
(function($) {
jQuery.fn.extend({
textbox : function(validname){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
if(validname == undefined) validname = 'invalidchar';
_commonValid(validname,self);
});
},
invalidchar : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('invalidchar',self);
});
},
username : function(){
var message = "请正确输入用户名:字母开头,不少于4位";
var self = this;
$.init(self,message);
this.blur(function(){
_requiredVaild('username',self);
});
},
feikong : function(){
var message = "请输入内容";
var self = this;
$.init(self,message);
this.blur(function(){
_requiredVaild('feikong',self);
});
},
password : function(){
var message = "请输入密码 注意:格式必须为6-20个非特殊字符。 ";
var self = this;
$.init(self,message);
this.blur(function(){
_requiredVaild('password',self);
});
},
confirmpwd : function(firstpwd){
var message = "请输入确认密码 注意:格式必须为6-20个非特殊字符。";
var self = this;
$.init(self,message);
this.blur(function(){
_requiredVaild('confirmpwd',self,firstpwd);
});
},
number : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('number',self);
}).keyup(function(){
var val = self.val();
this.value = val.replace(/\s/g,'').replace(/\D/g,'');
});
},
textarea : function() {
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('textarea',self);
});
},
chineseName : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title+"注意:只能为汉字";
$.init(self,message);
this.blur(function(){
_commonValid('chineseName',self);
});
},
realName : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title+"注意:只能为汉字";
$.init(self,message);
this.blur(function(){
_commonValid('realName',self);
});
},
address : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title+",注意:只能以汉字开头,中间可以包含字母和数字。)";
$.init(self,message);
this.blur(function(){
_commonValid('address',self);
});
},
qq : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('qq',self);
}).keyup(function(){
var val = self.val();
this.value = val.replace(/\s/g,'').replace(/\D/g,'');
});
},
email : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('email',self);
});
},
phone : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('phone',self);
});
},
mobile : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('mobile',self);
});
},
domain : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title+",例如:www.3jia5.cn)";
$.init(self,message);
this.blur(function(){
_commonValid('domain',self);
});
},
ip : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title+",例如:192.168.1.1)";
$.init(self,message);
this.blur(function(){
_commonValid('ip',self);
});
},
zipcode : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('zipcode',self);
}).keyup(function(){
var val = self.val();
this.value = val.replace(/\s/g,'').replace(/\D/g,'');
});
},
idcard : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('idcard',self);
});
},
money : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('money',self);
});
},
authcode : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.blur(function(){
_commonValid('authcode',self);
});
},
datetime : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请输入"+title;
$.init(self,message);
this.click(function(){
MyCalendar.SetDate(this);
}).blur(function(){
_commonValid('datetime',self);
});
},
provinceAndCity : function(){
var self = this;
var province = self.attr("id");
var city = self.next().attr("id");
hw_init(province,city,"${province}$city");
this.click(function(){
hw_select(province,city);
});
},
commonSelect : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请选择"+title;
$.init(self,message);
var selfid = self.attr("id");
this.blur(function(){
_commonValid('commonSelect',self);
});
},
commonRadio : function(){
var self = this;
var title = _getLabelInfo(self);
var message = "请选择"+title;
$.init(self,message);
var selfid = self.attr("id");
this.click(function(){
});
},
callbackValid : function(options){
var self = this ;
this.blur(function(){
_callbackValid("callback" , self , options ) ;
});
},
//URL
urlname : function(){
var message = "请正确输入url地址。";
var self = this;
$.init(self,message);
this.blur(function(){
_requiredVaild('urlname',self);
});
},
numberRange : function( min , max ) {
this.callbackValid({callback:function(val){
if( val < min || val > max ) {
return { message : "数字必须大于" + min + "小于" + max } ;
}
return true ;
}});
},
//Button form 提交按钮
htmlform : function(formid){
var obj = this;
var form = obj.parents("form") ;
this.click(function(){
var flag = submitValid(form);
if(flag) form.submit();
});
},
//Button form Ajax提交按钮
ajaxform : function(){
var obj = this;
var form = obj.parents("form") ;
this.click(function(){
var flag = submitValid(form);
var data =_getData(form);// $.extend({},this.options.data) ;
if(flag){
var url = form.attr( "action" ) ;
var method = form.attr( "method" ) ;
$.ajax({
url : url ,
async : true ,
type : method,
data : data ,
success : function(){alert("success");} ,
error : function(){alert("error");}
});
}
});
}
});
})(jQuery); | JavaScript |
/*$(document).on('click','a.modal',function(){
alert('test');
$.colorbox({
href: $(this).attr('href'),
transition: 'fade',
scrolling:false,
opacity: 0.95
});
});*/
$(document).ready(function(){
$(".modal").colorbox({overlayClose: false});
}); | JavaScript |
/*!
* jQuery Form Plugin
* version: 2.84 (12-AUG-2011)
* @requires jQuery v1.3.2 or later
*
* Examples and documentation at: http://malsup.com/jquery/form/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
;(function($) {
/*
Usage Note:
-----------
Do not use both ajaxSubmit and ajaxForm on the same form. These
functions are intended to be exclusive. Use ajaxSubmit if you want
to bind your own submit handler to the form. For example,
$(document).ready(function() {
$('#myForm').bind('submit', function(e) {
e.preventDefault(); // <-- important
$(this).ajaxSubmit({
target: '#output'
});
});
});
Use ajaxForm when you want the plugin to manage all the event binding
for you. For example,
$(document).ready(function() {
$('#myForm').ajaxForm({
target: '#output'
});
});
When using ajaxForm, the ajaxSubmit function will be invoked for you
at the appropriate time.
*/
/**
* ajaxSubmit() provides a mechanism for immediately submitting
* an HTML form using AJAX.
*/
$.fn.ajaxSubmit = function(options) {
// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
if (!this.length) {
log('ajaxSubmit: skipping submit process - no element selected');
return this;
}
var method, action, url, $form = this;
if (typeof options == 'function') {
options = { success: options };
}
method = this.attr('method');
action = this.attr('action');
url = (typeof action === 'string') ? $.trim(action) : '';
url = url || window.location.href || '';
if (url) {
// clean url (don't include hash vaue)
url = (url.match(/^([^#]+)/)||[])[1];
}
options = $.extend(true, {
url: url,
success: $.ajaxSettings.success,
type: method || 'GET',
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
}, options);
// hook for manipulating the form data before it is extracted;
// convenient for use with rich editors like tinyMCE or FCKEditor
var veto = {};
this.trigger('form-pre-serialize', [this, options, veto]);
if (veto.veto) {
log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
return this;
}
// provide opportunity to alter form data before it is serialized
if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
log('ajaxSubmit: submit aborted via beforeSerialize callback');
return this;
}
var n,v,a = this.formToArray(options.semantic);
if (options.data) {
options.extraData = options.data;
for (n in options.data) {
if( $.isArray(options.data[n]) ) {
for (var k in options.data[n]) {
a.push( { name: n, value: options.data[n][k] } );
}
}
else {
v = options.data[n];
v = $.isFunction(v) ? v() : v; // if value is fn, invoke it
a.push( { name: n, value: v } );
}
}
}
// give pre-submit callback an opportunity to abort the submit
if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
log('ajaxSubmit: submit aborted via beforeSubmit callback');
return this;
}
// fire vetoable 'validate' event
this.trigger('form-submit-validate', [a, this, options, veto]);
if (veto.veto) {
log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
return this;
}
var q = $.param(a);
if (options.type.toUpperCase() == 'GET') {
options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
options.data = null; // data is null for 'get'
}
else {
options.data = q; // data is the query string for 'post'
}
var callbacks = [];
if (options.resetForm) {
callbacks.push(function() { $form.resetForm(); });
}
if (options.clearForm) {
callbacks.push(function() { $form.clearForm(); });
}
// perform a load on the target only if dataType is not provided
if (!options.dataType && options.target) {
var oldSuccess = options.success || function(){};
callbacks.push(function(data) {
var fn = options.replaceTarget ? 'replaceWith' : 'html';
$(options.target)[fn](data).each(oldSuccess, arguments);
});
}
else if (options.success) {
callbacks.push(options.success);
}
options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
var context = options.context || options; // jQuery 1.4+ supports scope context
for (var i=0, max=callbacks.length; i < max; i++) {
callbacks[i].apply(context, [data, status, xhr || $form, $form]);
}
};
// are there files to upload?
var fileInputs = $('input:file', this).length > 0;
var mp = 'multipart/form-data';
var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
// options.iframe allows user to force iframe mode
// 06-NOV-09: now defaulting to iframe mode if file input is detected
if (options.iframe !== false && (fileInputs || options.iframe || multipart)) {
// hack to fix Safari hang (thanks to Tim Molendijk for this)
// see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
if (options.closeKeepAlive) {
$.get(options.closeKeepAlive, function() { fileUpload(a); });
}
else {
fileUpload(a);
}
}
else {
// IE7 massage (see issue 57)
if ($.browser.msie && method == 'get') {
var ieMeth = $form[0].getAttribute('method');
if (typeof ieMeth === 'string')
options.type = ieMeth;
}
$.ajax(options);
}
// fire 'notify' event
this.trigger('form-submit-notify', [this, options]);
return this;
// private function for handling file uploads (hat tip to YAHOO!)
function fileUpload(a) {
var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;
var useProp = !!$.fn.prop;
if (a) {
// ensure that every serialized input is still enabled
for (i=0; i < a.length; i++) {
el = $(form[a[i].name]);
el[ useProp ? 'prop' : 'attr' ]('disabled', false);
}
}
if ($(':input[name=submit],:input[id=submit]', form).length) {
// if there is an input with a name or id of 'submit' then we won't be
// able to invoke the submit fn on the form (at least not x-browser)
alert('Error: Form elements must not have name or id of "submit".');
return;
}
s = $.extend(true, {}, $.ajaxSettings, options);
s.context = s.context || s;
id = 'jqFormIO' + (new Date().getTime());
if (s.iframeTarget) {
$io = $(s.iframeTarget);
n = $io.attr('name');
if (n == null)
$io.attr('name', id);
else
id = n;
}
else {
$io = $('<iframe name="' + id + '" src="'+ s.iframeSrc +'" />');
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
}
io = $io[0];
xhr = { // mock object
aborted: 0,
responseText: null,
responseXML: null,
status: 0,
statusText: 'n/a',
getAllResponseHeaders: function() {},
getResponseHeader: function() {},
setRequestHeader: function() {},
abort: function(status) {
var e = (status === 'timeout' ? 'timeout' : 'aborted');
log('aborting upload... ' + e);
this.aborted = 1;
$io.attr('src', s.iframeSrc); // abort op in progress
xhr.error = e;
s.error && s.error.call(s.context, xhr, e, status);
g && $.event.trigger("ajaxError", [xhr, s, e]);
s.complete && s.complete.call(s.context, xhr, e);
}
};
g = s.global;
// trigger ajax global events so that activity/block indicators work like normal
if (g && ! $.active++) {
$.event.trigger("ajaxStart");
}
if (g) {
$.event.trigger("ajaxSend", [xhr, s]);
}
if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
if (s.global) {
$.active--;
}
return;
}
if (xhr.aborted) {
return;
}
// add submitting element to data if we know it
sub = form.clk;
if (sub) {
n = sub.name;
if (n && !sub.disabled) {
s.extraData = s.extraData || {};
s.extraData[n] = sub.value;
if (sub.type == "image") {
s.extraData[n+'.x'] = form.clk_x;
s.extraData[n+'.y'] = form.clk_y;
}
}
}
var CLIENT_TIMEOUT_ABORT = 1;
var SERVER_ABORT = 2;
function getDoc(frame) {
var doc = frame.contentWindow ? frame.contentWindow.document : frame.contentDocument ? frame.contentDocument : frame.document;
return doc;
}
// take a breath so that pending repaints get some cpu time before the upload starts
function doSubmit() {
// make sure form attrs are set
var t = $form.attr('target'), a = $form.attr('action');
// update form attrs in IE friendly way
form.setAttribute('target',id);
if (!method) {
form.setAttribute('method', 'POST');
}
if (a != s.url) {
form.setAttribute('action', s.url);
}
// ie borks in some cases when setting encoding
if (! s.skipEncodingOverride && (!method || /post/i.test(method))) {
$form.attr({
encoding: 'multipart/form-data',
enctype: 'multipart/form-data'
});
}
// support timout
if (s.timeout) {
timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout);
}
// look for server aborts
function checkState() {
try {
var state = getDoc(io).readyState;
log('state = ' + state);
if (state.toLowerCase() == 'uninitialized')
setTimeout(checkState,50);
}
catch(e) {
log('Server abort: ' , e, ' (', e.name, ')');
cb(SERVER_ABORT);
timeoutHandle && clearTimeout(timeoutHandle);
timeoutHandle = undefined;
}
}
// add "extra" data to form if provided in options
var extraInputs = [];
try {
if (s.extraData) {
for (var n in s.extraData) {
extraInputs.push(
$('<input type="hidden" name="'+n+'" />').attr('value',s.extraData[n])
.appendTo(form)[0]);
}
}
if (!s.iframeTarget) {
// add iframe to doc and submit the form
$io.appendTo('body');
io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
}
setTimeout(checkState,15);
form.submit();
}
finally {
// reset attrs and remove "extra" input elements
form.setAttribute('action',a);
if(t) {
form.setAttribute('target', t);
} else {
$form.removeAttr('target');
}
$(extraInputs).remove();
}
}
if (s.forceSync) {
doSubmit();
}
else {
setTimeout(doSubmit, 10); // this lets dom updates render
}
var data, doc, domCheckCount = 50, callbackProcessed;
function cb(e) {
if (xhr.aborted || callbackProcessed) {
return;
}
try {
doc = getDoc(io);
}
catch(ex) {
log('cannot access response document: ', ex);
e = SERVER_ABORT;
}
if (e === CLIENT_TIMEOUT_ABORT && xhr) {
xhr.abort('timeout');
return;
}
else if (e == SERVER_ABORT && xhr) {
xhr.abort('server abort');
return;
}
if (!doc || doc.location.href == s.iframeSrc) {
// response not received yet
if (!timedOut)
return;
}
io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
var status = 'success', errMsg;
try {
if (timedOut) {
throw 'timeout';
}
var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
log('isXml='+isXml);
if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
if (--domCheckCount) {
// in some browsers (Opera) the iframe DOM is not always traversable when
// the onload callback fires, so we loop a bit to accommodate
log('requeing onLoad callback, DOM not available');
setTimeout(cb, 250);
return;
}
// let this fall through because server response could be an empty document
//log('Could not access iframe DOM after mutiple tries.');
//throw 'DOMException: not available';
}
//log('response detected');
var docRoot = doc.body ? doc.body : doc.documentElement;
xhr.responseText = docRoot ? docRoot.innerHTML : null;
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
if (isXml)
s.dataType = 'xml';
xhr.getResponseHeader = function(header){
var headers = {'content-type': s.dataType};
return headers[header];
};
// support for XHR 'status' & 'statusText' emulation :
if (docRoot) {
xhr.status = Number( docRoot.getAttribute('status') ) || xhr.status;
xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
}
var dt = s.dataType || '';
var scr = /(json|script|text)/.test(dt.toLowerCase());
if (scr || s.textarea) {
// see if user embedded response in textarea
var ta = doc.getElementsByTagName('textarea')[0];
if (ta) {
xhr.responseText = ta.value;
// support for XHR 'status' & 'statusText' emulation :
xhr.status = Number( ta.getAttribute('status') ) || xhr.status;
xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
}
else if (scr) {
// account for browsers injecting pre around json response
var pre = doc.getElementsByTagName('pre')[0];
var b = doc.getElementsByTagName('body')[0];
if (pre) {
xhr.responseText = pre.textContent ? pre.textContent : pre.innerHTML;
}
else if (b) {
xhr.responseText = b.innerHTML;
}
}
}
else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
xhr.responseXML = toXml(xhr.responseText);
}
try {
data = httpData(xhr, s.dataType, s);
}
catch (e) {
status = 'parsererror';
xhr.error = errMsg = (e || status);
}
}
catch (e) {
log('error caught: ',e);
status = 'error';
xhr.error = errMsg = (e || status);
}
if (xhr.aborted) {
log('upload aborted');
status = null;
}
if (xhr.status) { // we've set xhr.status
status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error';
}
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
if (status === 'success') {
s.success && s.success.call(s.context, data, 'success', xhr);
g && $.event.trigger("ajaxSuccess", [xhr, s]);
}
else if (status) {
if (errMsg == undefined)
errMsg = xhr.statusText;
s.error && s.error.call(s.context, xhr, status, errMsg);
g && $.event.trigger("ajaxError", [xhr, s, errMsg]);
}
g && $.event.trigger("ajaxComplete", [xhr, s]);
if (g && ! --$.active) {
$.event.trigger("ajaxStop");
}
s.complete && s.complete.call(s.context, xhr, status);
callbackProcessed = true;
if (s.timeout)
clearTimeout(timeoutHandle);
// clean up
setTimeout(function() {
if (!s.iframeTarget)
$io.remove();
xhr.responseXML = null;
}, 100);
}
var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
if (window.ActiveXObject) {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML(s);
}
else {
doc = (new DOMParser()).parseFromString(s, 'text/xml');
}
return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
};
var parseJSON = $.parseJSON || function(s) {
return window['eval']('(' + s + ')');
};
var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4
var ct = xhr.getResponseHeader('content-type') || '',
xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
data = xml ? xhr.responseXML : xhr.responseText;
if (xml && data.documentElement.nodeName === 'parsererror') {
$.error && $.error('parsererror');
}
if (s && s.dataFilter) {
data = s.dataFilter(data, type);
}
if (typeof data === 'string') {
if (type === 'json' || !type && ct.indexOf('json') >= 0) {
data = parseJSON(data);
} else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
$.globalEval(data);
}
}
return data;
};
}
};
/**
* ajaxForm() provides a mechanism for fully automating form submission.
*
* The advantages of using this method instead of ajaxSubmit() are:
*
* 1: This method will include coordinates for <input type="image" /> elements (if the element
* is used to submit the form).
* 2. This method will include the submit element's name/value data (for the element that was
* used to submit the form).
* 3. This method binds the submit() method to the form for you.
*
* The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
* passes the options argument along after properly binding events for submit elements and
* the form itself.
*/
$.fn.ajaxForm = function(options) {
// in jQuery 1.3+ we can fix mistakes with the ready state
if (this.length === 0) {
var o = { s: this.selector, c: this.context };
if (!$.isReady && o.s) {
log('DOM not ready, queuing ajaxForm');
$(function() {
$(o.s,o.c).ajaxForm(options);
});
return this;
}
// is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
return this;
}
return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
e.preventDefault();
$(this).ajaxSubmit(options);
}
}).bind('click.form-plugin', function(e) {
var target = e.target;
var $el = $(target);
if (!($el.is(":submit,input:image"))) {
// is this a child element of the submit el? (ex: a span within a button)
var t = $el.closest(':submit');
if (t.length == 0) {
return;
}
target = t[0];
}
var form = this;
form.clk = target;
if (target.type == 'image') {
if (e.offsetX != undefined) {
form.clk_x = e.offsetX;
form.clk_y = e.offsetY;
} else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
var offset = $el.offset();
form.clk_x = e.pageX - offset.left;
form.clk_y = e.pageY - offset.top;
} else {
form.clk_x = e.pageX - target.offsetLeft;
form.clk_y = e.pageY - target.offsetTop;
}
}
// clear form vars
setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
});
};
// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
$.fn.ajaxFormUnbind = function() {
return this.unbind('submit.form-plugin click.form-plugin');
};
/**
* formToArray() gathers form element data into an array of objects that can
* be passed to any of the following ajax functions: $.get, $.post, or load.
* Each object in the array has both a 'name' and 'value' property. An example of
* an array for a simple login form might be:
*
* [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
*
* It is this array that is passed to pre-submit callback functions provided to the
* ajaxSubmit() and ajaxForm() methods.
*/
$.fn.formToArray = function(semantic) {
var a = [];
if (this.length === 0) {
return a;
}
var form = this[0];
var els = semantic ? form.getElementsByTagName('*') : form.elements;
if (!els) {
return a;
}
var i,j,n,v,el,max,jmax;
for(i=0, max=els.length; i < max; i++) {
el = els[i];
n = el.name;
if (!n) {
continue;
}
if (semantic && form.clk && el.type == "image") {
// handle image inputs on the fly when semantic == true
if(!el.disabled && form.clk == el) {
a.push({name: n, value: $(el).val()});
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
}
continue;
}
v = $.fieldValue(el, true);
if (v && v.constructor == Array) {
for(j=0, jmax=v.length; j < jmax; j++) {
a.push({name: n, value: v[j]});
}
}
else if (v !== null && typeof v != 'undefined') {
a.push({name: n, value: v});
}
}
if (!semantic && form.clk) {
// input type=='image' are not found in elements array! handle it here
var $input = $(form.clk), input = $input[0];
n = input.name;
if (n && !input.disabled && input.type == 'image') {
a.push({name: n, value: $input.val()});
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
}
}
return a;
};
/**
* Serializes form data into a 'submittable' string. This method will return a string
* in the format: name1=value1&name2=value2
*/
$.fn.formSerialize = function(semantic) {
//hand off to jQuery.param for proper encoding
return $.param(this.formToArray(semantic));
};
/**
* Serializes all field elements in the jQuery object into a query string.
* This method will return a string in the format: name1=value1&name2=value2
*/
$.fn.fieldSerialize = function(successful) {
var a = [];
this.each(function() {
var n = this.name;
if (!n) {
return;
}
var v = $.fieldValue(this, successful);
if (v && v.constructor == Array) {
for (var i=0,max=v.length; i < max; i++) {
a.push({name: n, value: v[i]});
}
}
else if (v !== null && typeof v != 'undefined') {
a.push({name: this.name, value: v});
}
});
//hand off to jQuery.param for proper encoding
return $.param(a);
};
/**
* Returns the value(s) of the element in the matched set. For example, consider the following form:
*
* <form><fieldset>
* <input name="A" type="text" />
* <input name="A" type="text" />
* <input name="B" type="checkbox" value="B1" />
* <input name="B" type="checkbox" value="B2"/>
* <input name="C" type="radio" value="C1" />
* <input name="C" type="radio" value="C2" />
* </fieldset></form>
*
* var v = $(':text').fieldValue();
* // if no values are entered into the text inputs
* v == ['','']
* // if values entered into the text inputs are 'foo' and 'bar'
* v == ['foo','bar']
*
* var v = $(':checkbox').fieldValue();
* // if neither checkbox is checked
* v === undefined
* // if both checkboxes are checked
* v == ['B1', 'B2']
*
* var v = $(':radio').fieldValue();
* // if neither radio is checked
* v === undefined
* // if first radio is checked
* v == ['C1']
*
* The successful argument controls whether or not the field element must be 'successful'
* (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
* The default value of the successful argument is true. If this value is false the value(s)
* for each element is returned.
*
* Note: This method *always* returns an array. If no valid value can be determined the
* array will be empty, otherwise it will contain one or more values.
*/
$.fn.fieldValue = function(successful) {
for (var val=[], i=0, max=this.length; i < max; i++) {
var el = this[i];
var v = $.fieldValue(el, successful);
if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
continue;
}
v.constructor == Array ? $.merge(val, v) : val.push(v);
}
return val;
};
/**
* Returns the value of the field element.
*/
$.fieldValue = function(el, successful) {
var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
if (successful === undefined) {
successful = true;
}
if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
(t == 'checkbox' || t == 'radio') && !el.checked ||
(t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
tag == 'select' && el.selectedIndex == -1)) {
return null;
}
if (tag == 'select') {
var index = el.selectedIndex;
if (index < 0) {
return null;
}
var a = [], ops = el.options;
var one = (t == 'select-one');
var max = (one ? index+1 : ops.length);
for(var i=(one ? index : 0); i < max; i++) {
var op = ops[i];
if (op.selected) {
var v = op.value;
if (!v) { // extra pain for IE...
v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
}
if (one) {
return v;
}
a.push(v);
}
}
return a;
}
return $(el).val();
};
/**
* Clears the form data. Takes the following actions on the form's input fields:
* - input text fields will have their 'value' property set to the empty string
* - select elements will have their 'selectedIndex' property set to -1
* - checkbox and radio inputs will have their 'checked' property set to false
* - inputs of type submit, button, reset, and hidden will *not* be effected
* - button elements will *not* be effected
*/
$.fn.clearForm = function() {
return this.each(function() {
$('input,select,textarea', this).clearFields();
});
};
/**
* Clears the selected form elements.
*/
$.fn.clearFields = $.fn.clearInputs = function() {
var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
return this.each(function() {
var t = this.type, tag = this.tagName.toLowerCase();
if (re.test(t) || tag == 'textarea') {
this.value = '';
}
else if (t == 'checkbox' || t == 'radio') {
this.checked = false;
}
else if (tag == 'select') {
this.selectedIndex = -1;
}
});
};
/**
* Resets the form data. Causes all form elements to be reset to their original value.
*/
$.fn.resetForm = function() {
return this.each(function() {
// guard against an input with the name of 'reset'
// note that IE reports the reset function as an 'object'
if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
this.reset();
}
});
};
/**
* Enables or disables any matching elements.
*/
$.fn.enable = function(b) {
if (b === undefined) {
b = true;
}
return this.each(function() {
this.disabled = !b;
});
};
/**
* Checks/unchecks any matching checkboxes or radio buttons and
* selects/deselects and matching option elements.
*/
$.fn.selected = function(select) {
if (select === undefined) {
select = true;
}
return this.each(function() {
var t = this.type;
if (t == 'checkbox' || t == 'radio') {
this.checked = select;
}
else if (this.tagName.toLowerCase() == 'option') {
var $sel = $(this).parent('select');
if (select && $sel[0] && $sel[0].type == 'select-one') {
// deselect all other options
$sel.find('option').selected(false);
}
this.selected = select;
}
});
};
// helper fn for console logging
function log() {
var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
if (window.console && window.console.log) {
window.console.log(msg);
}
else if (window.opera && window.opera.postError) {
window.opera.postError(msg);
}
};
})(jQuery);
| JavaScript |
(function ($, document, window) {
var
defaults = {
transition: "elastic",
speed: 300,
width: false,
initialWidth: "600",
innerWidth: false,
maxWidth: false,
height: false,
initialHeight: "450",
innerHeight: false,
maxHeight: false,
scalePhotos: true,
scrolling: true,
inline: false,
html: false,
iframe: false,
fastIframe: true,
photo: false,
href: false,
title: false,
rel: false,
opacity: 0.9,
preloading: true,
current: "image {current} of {total}",
previous: "previous",
next: "next",
close: "",
open: false,
returnFocus: true,
reposition: true,
loop: true,
slideshow: false,
slideshowAuto: true,
slideshowSpeed: 2500,
slideshowStart: "start slideshow",
slideshowStop: "stop slideshow",
onOpen: false,
onLoad: false,
onComplete: false,
onCleanup: false,
onClosed: false,
overlayClose: true, escKey: true,
arrowKey: true,
top: false,
bottom: false,
left: false,
right: false,
fixed: false,
data: undefined
},
colorbox = 'colorbox',
prefix = 'cbox',
boxElement = prefix + 'Element',
event_open = prefix + '_open',
event_load = prefix + '_load',
event_complete = prefix + '_complete',
event_cleanup = prefix + '_cleanup',
event_closed = prefix + '_closed',
event_purge = prefix + '_purge',
isIE = !$.support.opacity && !$.support.style,
isIE6 = isIE && !window.XMLHttpRequest,
event_ie6 = prefix + '_IE6',
$overlay,
$box,
$wrap,
$content,
$topBorder,
$leftBorder,
$rightBorder,
$bottomBorder,
$related,
$window,
$loaded,
$loadingBay,
$loadingOverlay,
$title,
$current,
$slideshow,
$next,
$prev,
$close,
$groupControls,
settings,
interfaceHeight,
interfaceWidth,
loadedHeight,
loadedWidth,
element,
index,
photo,
open,
active,
closing,
loadingTimer,
publicMethod,
div = "div",
init;
function $tag(tag, id, css) {
var element = document.createElement(tag);
if (id) {
element.id = prefix + id;
}
if (css) {
element.style.cssText = css;
}
return $(element);
}
function getIndex(increment) {
var
max = $related.length,
newIndex = (index + increment) % max;
return (newIndex < 0) ? max + newIndex : newIndex;
}
function setSize(size, dimension) {
return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : $window.height()) / 100) : 1) * parseInt(size, 10));
}
function isImage(url) {
return settings.photo || /\.(gif|png|jpe?g|bmp|ico)((#|\?).*)?$/i.test(url);
}
function makeSettings() {
var i;
settings = $.extend({}, $.data(element, colorbox));
for (i in settings) {
if ($.isFunction(settings[i]) && i.slice(0, 2) !== 'on') {
settings[i] = settings[i].call(element);
}
}
settings.rel = settings.rel || element.rel || 'nofollow';
settings.href = settings.href || $(element).attr('href');
settings.title = settings.title || element.title;
if (typeof settings.href === "string") {
settings.href = $.trim(settings.href);
}
}
function trigger(event, callback) {
$.event.trigger(event);
if (callback) {
callback.call(element);
}
}
function slideshow() {
var
timeOut,
className = prefix + "Slideshow_",
click = "click." + prefix,
start,
stop,
clear;
if (settings.slideshow && $related[1]) {
start = function () {
$slideshow
.text(settings.slideshowStop)
.unbind(click)
.bind(event_complete, function () {
if (settings.loop || $related[index + 1]) {
timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
}
})
.bind(event_load, function () {
clearTimeout(timeOut);
})
.one(click + ' ' + event_cleanup, stop);
$box.removeClass(className + "off").addClass(className + "on");
timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
};
stop = function () {
clearTimeout(timeOut);
$slideshow
.text(settings.slideshowStart)
.unbind([event_complete, event_load, event_cleanup, click].join(' '))
.one(click, function () {
publicMethod.next();
start();
});
$box.removeClass(className + "on").addClass(className + "off");
};
if (settings.slideshowAuto) {
start();
} else {
stop();
}
} else {
$box.removeClass(className + "off " + className + "on");
}
}
function launch(target) {
if (!closing) {
element = target;
makeSettings();
$related = $(element);
index = 0;
if (settings.rel !== 'nofollow') {
$related = $('.' + boxElement).filter(function () {
var relRelated = $.data(this, colorbox).rel || this.rel;
return (relRelated === settings.rel);
});
index = $related.index(element);
if (index === -1) {
$related = $related.add(element);
index = $related.length - 1;
}
}
if (!open) {
open = active = true;
$box.show();
if (settings.returnFocus) {
$(element).blur().one(event_closed, function () {
$(this).focus();
});
}
$overlay.css({"opacity": +settings.opacity, "cursor": settings.overlayClose ? "pointer" : "auto"}).show();
settings.w = setSize(settings.initialWidth, 'x');
settings.h = setSize(settings.initialHeight, 'y');
publicMethod.position();
if (isIE6) {
$window.bind('resize.' + event_ie6 + ' scroll.' + event_ie6, function () {
$overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()});
}).trigger('resize.' + event_ie6);
}
trigger(event_open, settings.onOpen);
$groupControls.add($title).hide();
$close.html(settings.close).show();
}
publicMethod.load(true);
}
}
function appendHTML() {
if (!$box && document.body) {
init = false;
$window = $(window);
$box = $tag(div).attr({id: colorbox, 'class': isIE ? prefix + (isIE6 ? 'IE6' : 'IE') : ''}).hide();
$overlay = $tag(div, "Overlay", isIE6 ? 'position:absolute' : '').hide();
$wrap = $tag(div, "Wrapper");
$content = $tag(div, "Content").append(
$loaded = $tag(div, "LoadedContent", 'width:0; height:0; overflow:hidden'),
$loadingOverlay = $tag(div, "LoadingOverlay").add($tag(div, "LoadingGraphic")),
$title = $tag(div, "Title"),
$current = $tag(div, "Current"),
$next = $tag(div, "Next"),
$prev = $tag(div, "Previous"),
$slideshow = $tag(div, "Slideshow").bind(event_open, slideshow),
$close = $tag(div, "Close")
);
$wrap.append(
$tag(div).append(
$tag(div, "TopLeft"),
$topBorder = $tag(div, "TopCenter"),
$tag(div, "TopRight")
),
$tag(div, false, 'clear:left').append(
$leftBorder = $tag(div, "MiddleLeft"),
$content,
$rightBorder = $tag(div, "MiddleRight")
),
$tag(div, false, 'clear:left').append(
$tag(div, "BottomLeft"),
$bottomBorder = $tag(div, "BottomCenter"),
$tag(div, "BottomRight")
)
).find('div div').css({'float': 'left'});
$loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none');
$groupControls = $next.add($prev).add($current).add($slideshow);
$(document.body).append($overlay, $box.append($wrap, $loadingBay));
}
}
function addBindings() {
if ($box) {
if (!init) {
init = true;
interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();//Subtraction needed for IE6
interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
loadedHeight = $loaded.outerHeight(true);
loadedWidth = $loaded.outerWidth(true);
$box.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth});
$next.click(function () {
publicMethod.next();
});
$prev.click(function () {
publicMethod.prev();
});
$close.click(function () {
publicMethod.close();
});
$overlay.click(function () {
if (settings.overlayClose) {
publicMethod.close();
}
});
$(document).bind('keydown.' + prefix, function (e) {
var key = e.keyCode;
if (open && settings.escKey && key === 27) {
e.preventDefault();
publicMethod.close();
}
if (open && settings.arrowKey && $related[1]) {
if (key === 37) {
e.preventDefault();
$prev.click();
} else if (key === 39) {
e.preventDefault();
$next.click();
}
}
});
$('.' + boxElement, document).live('click', function (e) {
if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey)) {
e.preventDefault();
launch(this);
}
});
}
return true;
}
return false;
}
if ($.colorbox) {
return;
}
$(appendHTML);
publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
var $this = this;
options = options || {};
appendHTML();
if (addBindings()) {
if (!$this[0]) {
if ($this.selector) {
return $this;
}
$this = $('<a/>');
options.open = true;
}
if (callback) {
options.onComplete = callback;
}
$this.each(function () {
$.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options));
}).addClass(boxElement);
if (($.isFunction(options.open) && options.open.call($this)) || options.open) {
launch($this[0]);
}
}
return $this;
};
publicMethod.position = function (speed, loadedCallback) {
var
top = 0,
left = 0,
offset = $box.offset(),
scrollTop = $window.scrollTop(),
scrollLeft = $window.scrollLeft();
$window.unbind('resize.' + prefix);
$box.css({top: -9e4, left: -9e4});
if (settings.fixed && !isIE6) {
offset.top -= scrollTop;
offset.left -= scrollLeft;
$box.css({position: 'fixed'});
} else {
top = scrollTop;
left = scrollLeft;
$box.css({position: 'absolute'});
}
if (settings.right !== false) {
left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0);
} else if (settings.left !== false) {
left += setSize(settings.left, 'x');
} else {
left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2);
}
if (settings.bottom !== false) {
top += Math.max($window.height() - settings.h - loadedHeight - interfaceHeight - setSize(settings.bottom, 'y'), 0);
} else if (settings.top !== false) {
top += setSize(settings.top, 'y');
} else {
top += Math.round(Math.max($window.height() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
}
$box.css({top: offset.top, left: offset.left});
speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed || 0;
$wrap[0].style.width = $wrap[0].style.height = "9999px";
function modalDimensions(that) {
$topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
$content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
}
$box.dequeue().animate({width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: top, left: left}, {
duration: speed,
complete: function () {
modalDimensions(this);
active = false;
$wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
$wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
if (settings.reposition) {
setTimeout(function () {
$window.bind('resize.' + prefix, publicMethod.position);
}, 1);
}
if (loadedCallback) {
loadedCallback();
}
},
step: function () {
modalDimensions(this);
}
});
};
publicMethod.resize = function (options) {
if (open) {
options = options || {};
if (options.width) {
settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth;
}
if (options.innerWidth) {
settings.w = setSize(options.innerWidth, 'x');
}
$loaded.css({width: settings.w});
if (options.height) {
settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight;
}
if (options.innerHeight) {
settings.h = setSize(options.innerHeight, 'y');
}
if (!options.innerHeight && !options.height) {
$loaded.css({height: "auto"});
settings.h = $loaded.height();
}
$loaded.css({height: settings.h});
publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
}
};
publicMethod.prep = function (object) {
if (!open) {
return;
}
var callback, speed = settings.transition === "none" ? 0 : settings.speed;
$loaded.remove();
$loaded = $tag(div, 'LoadedContent').append(object);
function getWidth() {
settings.w = settings.w || $loaded.width();
settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
return settings.w;
}
function getHeight() {
settings.h = settings.h || $loaded.height();
settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
return settings.h;
}
$loaded.hide()
.appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
.css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
.css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
.prependTo($content);
$loadingBay.hide();
$(photo).css({'float': 'none'});
if (isIE6) {
$('select').not($box.find('select')).filter(function () {
return this.style.visibility !== 'hidden';
}).css({'visibility': 'hidden'}).one(event_cleanup, function () {
this.style.visibility = 'inherit';
});
}
callback = function () {
var preload, i, total = $related.length, iframe, frameBorder = 'frameBorder', allowTransparency = 'allowTransparency', complete, src, img;
if (!open) {
return;
}
function removeFilter() {
if (isIE) {
$box[0].style.removeAttribute('filter');
}
}
complete = function () {
clearTimeout(loadingTimer);
$loadingOverlay.hide();
trigger(event_complete, settings.onComplete);
};
if (isIE) {
if (photo) {
$loaded.fadeIn(100);
}
}
$title.html(settings.title).add($loaded).show();
if (total > 1) {
if (typeof settings.current === "string") {
$current.html(settings.current.replace('{current}', index + 1).replace('{total}', total)).show();
}
$next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
$prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous);
if (settings.slideshow) {
$slideshow.show();
}
if (settings.preloading) {
preload = [
getIndex(-1),
getIndex(1)
];
while (i = $related[preload.pop()]) {
src = $.data(i, colorbox).href || i.href;
if ($.isFunction(src)) {
src = src.call(i);
}
if (isImage(src)) {
img = new Image();
img.src = src;
}
}
}
} else {
$groupControls.hide();
}
if (settings.iframe) {
iframe = $tag('iframe')[0];
if (frameBorder in iframe) {
iframe[frameBorder] = 0;
}
if (allowTransparency in iframe) {
iframe[allowTransparency] = "true";
}
iframe.name = prefix + (+new Date());
if (settings.fastIframe) {
complete();
} else {
$(iframe).one('load', complete);
}
iframe.src = settings.href;
if (!settings.scrolling) {
iframe.scrolling = "no";
}
$(iframe).addClass(prefix + 'Iframe').appendTo($loaded).one(event_purge, function () {
iframe.src = "//about:blank";
});
} else {
complete();
}
if (settings.transition === 'fade') {
$box.fadeTo(speed, 1, removeFilter);
} else {
removeFilter();
}
};
if (settings.transition === 'fade') {
$box.fadeTo(speed, 0, function () {
publicMethod.position(0, callback);
});
} else {
publicMethod.position(speed, callback);
}
};
publicMethod.load = function (launched) {
var href, setResize, prep = publicMethod.prep;
active = true;
photo = false;
element = $related[index];
if (!launched) {
makeSettings();
}
trigger(event_purge);
trigger(event_load, settings.onLoad);
settings.h = settings.height ?
setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
settings.innerHeight && setSize(settings.innerHeight, 'y');
settings.w = settings.width ?
setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
settings.innerWidth && setSize(settings.innerWidth, 'x');
settings.mw = settings.w;
settings.mh = settings.h;
if (settings.maxWidth) {
settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
}
if (settings.maxHeight) {
settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
}
href = settings.href;
loadingTimer = setTimeout(function () {
$loadingOverlay.show();
}, 100);
if (settings.inline) {
$tag(div).hide().insertBefore($(href)[0]).one(event_purge, function () {
$(this).replaceWith($loaded.children());
});
prep($(href));
} else if (settings.iframe) {
prep(" ");
} else if (settings.html) {
prep(settings.html);
} else if (isImage(href)) {
$(photo = new Image())
.addClass(prefix + 'Photo')
.error(function () {
settings.title = false;
prep($tag(div, 'Error').text('This image could not be loaded'));
})
.load(function () {
var percent;
photo.onload = null;
if (settings.scalePhotos) {
setResize = function () {
photo.height -= photo.height * percent;
photo.width -= photo.width * percent; };
if (settings.mw && photo.width > settings.mw) {
percent = (photo.width - settings.mw) / photo.width;
setResize();
}
if (settings.mh && photo.height > settings.mh) {
percent = (photo.height - settings.mh) / photo.height;
setResize();
}
}
if (settings.h) {
photo.style.marginTop = Math.max(settings.h - photo.height, 0) / 2 + 'px';
}
if ($related[1] && (settings.loop || $related[index + 1])) {
photo.style.cursor = 'pointer';
photo.onclick = function () {
publicMethod.next();
};
}
if (isIE) {
photo.style.msInterpolationMode = 'bicubic';
}
setTimeout(function () {
prep(photo);
}, 1);
});
setTimeout(function () {
photo.src = href;
}, 1);
} else if (href) {
$loadingBay.load(href, settings.data, function (data, status, xhr) {
prep(status === 'error' ? $tag(div, 'Error').text('Request unsuccessful: ' + xhr.statusText) : $(this).contents());
});
}
};
publicMethod.next = function () {
if (!active && $related[1] && (settings.loop || $related[index + 1])) {
index = getIndex(1);
publicMethod.load();
}
};
publicMethod.prev = function () {
if (!active && $related[1] && (settings.loop || index)) {
index = getIndex(-1);
publicMethod.load();
}
};
publicMethod.close = function () {
if (open && !closing) {
closing = true;
open = false;
trigger(event_cleanup, settings.onCleanup);
$window.unbind('.' + prefix + ' .' + event_ie6);
$overlay.fadeTo(200, 0);
$box.stop().fadeTo(300, 0, function () {
$box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
trigger(event_purge);
$loaded.remove();
setTimeout(function () {
closing = false;
trigger(event_closed, settings.onClosed);
}, 1);
});
}
};
publicMethod.remove = function () {
$([]).add($box).add($overlay).remove();
$box = null;
$('.' + boxElement)
.removeData(colorbox)
.removeClass(boxElement)
.die();
};
publicMethod.element = function () {
return $(element);
};
publicMethod.settings = defaults;
}(jQuery, document, this));
| JavaScript |
var OutlookController = {
MessagesPaneName: "MessageList",
MessageBodyName: "messageBody",
ContentSplitterPaneResized: function (s, e) {
if(typeof (MessagesGrid) != "undefined") {
if(e.pane.name === OutlookController.MessagesPaneName) {
MessagesGrid.SetHeight(e.pane.GetClientHeight());
}
}
},
MessagesGridRowChanged: function (s, e) {
var currentRow = s.GetFocusedRowIndex();
s.GetRowValues(currentRow, 'Text', OutlookController.OnGetRowValues);
},
MailFilterNodeClick: function (s, e) {
var filter = e.node.text;
if(e.node.text === "Inbox" || !e.node.parent) {
filter = "%";
}
// DXCOMMENT: Define the filter row's name
MessagesGrid.ApplyFilter("[Folder] LIKE '" + filter + "'");
},
MessagesGridEndCallback: function (s, e) {
ContentSplitter.GetPaneByName(OutlookController.MessagesPaneName).RaiseResizedEvent();
},
OnGetRowValues: function (values) {
document.getElementById(OutlookController.MessageBodyName).innerHTML = values;
}
} | JavaScript |
/*! SWFObject v2.2 <http://code.google.com/p/swfobject/>
is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject = function() {
var UNDEF = "undefined",
OBJECT = "object",
SHOCKWAVE_FLASH = "Shockwave Flash",
SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
FLASH_MIME_TYPE = "application/x-shockwave-flash",
EXPRESS_INSTALL_ID = "SWFObjectExprInst",
ON_READY_STATE_CHANGE = "onreadystatechange",
win = window,
doc = document,
nav = navigator,
plugin = false,
domLoadFnArr = [main],
regObjArr = [],
objIdArr = [],
listenersArr = [],
storedAltContent,
storedAltContentId,
storedCallbackFn,
storedCallbackObj,
isDomLoaded = false,
isExpressInstallActive = false,
dynamicStylesheet,
dynamicStylesheetMedia,
autoHideShow = true,
/* Centralized function for browser feature detection
- User agent string detection is only used when no good alternative is possible
- Is executed directly for optimal performance
*/
ua = function() {
var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
u = nav.userAgent.toLowerCase(),
p = nav.platform.toLowerCase(),
windows = p ? /win/.test(p) : /win/.test(u),
mac = p ? /mac/.test(p) : /mac/.test(u),
webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
playerVersion = [0,0,0],
d = null;
if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
d = nav.plugins[SHOCKWAVE_FLASH].description;
if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
plugin = true;
ie = false; // cascaded feature detection for Internet Explorer
d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
}
}
else if (typeof win.ActiveXObject != UNDEF) {
try {
var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
if (a) { // a will return null when ActiveX is disabled
d = a.GetVariable("$version");
if (d) {
ie = true; // cascaded feature detection for Internet Explorer
d = d.split(" ")[1].split(",");
playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
}
}
}
catch(e) {}
}
return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
}(),
/* Cross-browser onDomLoad
- Will fire an event as soon as the DOM of a web page is loaded
- Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/
- Regular onload serves as fallback
*/
onDomLoad = function() {
if (!ua.w3) { return; }
if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically
callDomLoadFunctions();
}
if (!isDomLoaded) {
if (typeof doc.addEventListener != UNDEF) {
doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false);
}
if (ua.ie && ua.win) {
doc.attachEvent(ON_READY_STATE_CHANGE, function() {
if (doc.readyState == "complete") {
doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee);
callDomLoadFunctions();
}
});
if (win == top) { // if not inside an iframe
(function(){
if (isDomLoaded) { return; }
try {
doc.documentElement.doScroll("left");
}
catch(e) {
setTimeout(arguments.callee, 0);
return;
}
callDomLoadFunctions();
})();
}
}
if (ua.wk) {
(function(){
if (isDomLoaded) { return; }
if (!/loaded|complete/.test(doc.readyState)) {
setTimeout(arguments.callee, 0);
return;
}
callDomLoadFunctions();
})();
}
addLoadEvent(callDomLoadFunctions);
}
}();
function callDomLoadFunctions() {
if (isDomLoaded) { return; }
try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early
var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span"));
t.parentNode.removeChild(t);
}
catch (e) { return; }
isDomLoaded = true;
var dl = domLoadFnArr.length;
for (var i = 0; i < dl; i++) {
domLoadFnArr[i]();
}
}
function addDomLoadEvent(fn) {
if (isDomLoaded) {
fn();
}
else {
domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
}
}
/* Cross-browser onload
- Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
- Will fire an event as soon as a web page including all of its assets are loaded
*/
function addLoadEvent(fn) {
if (typeof win.addEventListener != UNDEF) {
win.addEventListener("load", fn, false);
}
else if (typeof doc.addEventListener != UNDEF) {
doc.addEventListener("load", fn, false);
}
else if (typeof win.attachEvent != UNDEF) {
addListener(win, "onload", fn);
}
else if (typeof win.onload == "function") {
var fnOld = win.onload;
win.onload = function() {
fnOld();
fn();
};
}
else {
win.onload = fn;
}
}
/* Main function
- Will preferably execute onDomLoad, otherwise onload (as a fallback)
*/
function main() {
if (plugin) {
testPlayerVersion();
}
else {
matchVersions();
}
}
/* Detect the Flash Player version for non-Internet Explorer browsers
- Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
a. Both release and build numbers can be detected
b. Avoid wrong descriptions by corrupt installers provided by Adobe
c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
- Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
*/
function testPlayerVersion() {
var b = doc.getElementsByTagName("body")[0];
var o = createElement(OBJECT);
o.setAttribute("type", FLASH_MIME_TYPE);
var t = b.appendChild(o);
if (t) {
var counter = 0;
(function(){
if (typeof t.GetVariable != UNDEF) {
var d = t.GetVariable("$version");
if (d) {
d = d.split(" ")[1].split(",");
ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
}
}
else if (counter < 10) {
counter++;
setTimeout(arguments.callee, 10);
return;
}
b.removeChild(o);
t = null;
matchVersions();
})();
}
else {
matchVersions();
}
}
/* Perform Flash Player and SWF version matching; static publishing only
*/
function matchVersions() {
var rl = regObjArr.length;
if (rl > 0) {
for (var i = 0; i < rl; i++) { // for each registered object element
var id = regObjArr[i].id;
var cb = regObjArr[i].callbackFn;
var cbObj = {success:false, id:id};
if (ua.pv[0] > 0) {
var obj = getElementById(id);
if (obj) {
if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match!
setVisibility(id, true);
if (cb) {
cbObj.success = true;
cbObj.ref = getObjectById(id);
cb(cbObj);
}
}
else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported
var att = {};
att.data = regObjArr[i].expressInstall;
att.width = obj.getAttribute("width") || "0";
att.height = obj.getAttribute("height") || "0";
if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); }
if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); }
// parse HTML object param element's name-value pairs
var par = {};
var p = obj.getElementsByTagName("param");
var pl = p.length;
for (var j = 0; j < pl; j++) {
if (p[j].getAttribute("name").toLowerCase() != "movie") {
par[p[j].getAttribute("name")] = p[j].getAttribute("value");
}
}
showExpressInstall(att, par, id, cb);
}
else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF
displayAltContent(obj);
if (cb) { cb(cbObj); }
}
}
}
else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content)
setVisibility(id, true);
if (cb) {
var o = getObjectById(id); // test whether there is an HTML object element or not
if (o && typeof o.SetVariable != UNDEF) {
cbObj.success = true;
cbObj.ref = o;
}
cb(cbObj);
}
}
}
}
}
function getObjectById(objectIdStr) {
var r = null;
var o = getElementById(objectIdStr);
if (o && o.nodeName == "OBJECT") {
if (typeof o.SetVariable != UNDEF) {
r = o;
}
else {
var n = o.getElementsByTagName(OBJECT)[0];
if (n) {
r = n;
}
}
}
return r;
}
/* Requirements for Adobe Express Install
- only one instance can be active at a time
- fp 6.0.65 or higher
- Win/Mac OS only
- no Webkit engines older than version 312
*/
function canExpressInstall() {
return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312);
}
/* Show the Adobe Express Install dialog
- Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75
*/
function showExpressInstall(att, par, replaceElemIdStr, callbackFn) {
isExpressInstallActive = true;
storedCallbackFn = callbackFn || null;
storedCallbackObj = {success:false, id:replaceElemIdStr};
var obj = getElementById(replaceElemIdStr);
if (obj) {
if (obj.nodeName == "OBJECT") { // static publishing
storedAltContent = abstractAltContent(obj);
storedAltContentId = null;
}
else { // dynamic publishing
storedAltContent = obj;
storedAltContentId = replaceElemIdStr;
}
att.id = EXPRESS_INSTALL_ID;
if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; }
if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; }
doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
fv = "MMredirectURL=" + encodeURI(window.location).toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title;
if (typeof par.flashvars != UNDEF) {
par.flashvars += "&" + fv;
}
else {
par.flashvars = fv;
}
// IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
// because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
if (ua.ie && ua.win && obj.readyState != 4) {
var newObj = createElement("div");
replaceElemIdStr += "SWFObjectNew";
newObj.setAttribute("id", replaceElemIdStr);
obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf
obj.style.display = "none";
(function(){
if (obj.readyState == 4) {
obj.parentNode.removeChild(obj);
}
else {
setTimeout(arguments.callee, 10);
}
})();
}
createSWF(att, par, replaceElemIdStr);
}
}
/* Functions to abstract and display alternative content
*/
function displayAltContent(obj) {
if (ua.ie && ua.win && obj.readyState != 4) {
// IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
// because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
var el = createElement("div");
obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content
el.parentNode.replaceChild(abstractAltContent(obj), el);
obj.style.display = "none";
(function(){
if (obj.readyState == 4) {
obj.parentNode.removeChild(obj);
}
else {
setTimeout(arguments.callee, 10);
}
})();
}
else {
obj.parentNode.replaceChild(abstractAltContent(obj), obj);
}
}
function abstractAltContent(obj) {
var ac = createElement("div");
if (ua.win && ua.ie) {
ac.innerHTML = obj.innerHTML;
}
else {
var nestedObj = obj.getElementsByTagName(OBJECT)[0];
if (nestedObj) {
var c = nestedObj.childNodes;
if (c) {
var cl = c.length;
for (var i = 0; i < cl; i++) {
if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
ac.appendChild(c[i].cloneNode(true));
}
}
}
}
}
return ac;
}
/* Cross-browser dynamic SWF creation
*/
function createSWF(attObj, parObj, id) {
var r, el = getElementById(id);
if (ua.wk && ua.wk < 312) { return r; }
if (el) {
if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
attObj.id = id;
}
if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML
var att = "";
for (var i in attObj) {
if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries
if (i.toLowerCase() == "data") {
parObj.movie = attObj[i];
}
else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
att += ' class="' + attObj[i] + '"';
}
else if (i.toLowerCase() != "classid") {
att += ' ' + i + '="' + attObj[i] + '"';
}
}
}
var par = "";
for (var j in parObj) {
if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries
par += '<param name="' + j + '" value="' + parObj[j] + '" />';
}
}
el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only)
r = getElementById(attObj.id);
}
else { // well-behaving browsers
var o = createElement(OBJECT);
o.setAttribute("type", FLASH_MIME_TYPE);
for (var m in attObj) {
if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries
if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
o.setAttribute("class", attObj[m]);
}
else if (m.toLowerCase() != "classid") { // filter out IE specific attribute
o.setAttribute(m, attObj[m]);
}
}
}
for (var n in parObj) {
if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element
createObjParam(o, n, parObj[n]);
}
}
el.parentNode.replaceChild(o, el);
r = o;
}
}
return r;
}
function createObjParam(el, pName, pValue) {
var p = createElement("param");
p.setAttribute("name", pName);
p.setAttribute("value", pValue);
el.appendChild(p);
}
/* Cross-browser SWF removal
- Especially needed to safely and completely remove a SWF in Internet Explorer
*/
function removeSWF(id) {
var obj = getElementById(id);
if (obj && obj.nodeName == "OBJECT") {
if (ua.ie && ua.win) {
obj.style.display = "none";
(function(){
if (obj.readyState == 4) {
removeObjectInIE(id);
}
else {
setTimeout(arguments.callee, 10);
}
})();
}
else {
obj.parentNode.removeChild(obj);
}
}
}
function removeObjectInIE(id) {
var obj = getElementById(id);
if (obj) {
for (var i in obj) {
if (typeof obj[i] == "function") {
obj[i] = null;
}
}
obj.parentNode.removeChild(obj);
}
}
/* Functions to optimize JavaScript compression
*/
function getElementById(id) {
var el = null;
try {
el = doc.getElementById(id);
}
catch (e) {}
return el;
}
function createElement(el) {
return doc.createElement(el);
}
/* Updated attachEvent function for Internet Explorer
- Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
*/
function addListener(target, eventType, fn) {
target.attachEvent(eventType, fn);
listenersArr[listenersArr.length] = [target, eventType, fn];
}
/* Flash Player and SWF content version matching
*/
function hasPlayerVersion(rv) {
var pv = ua.pv, v = rv.split(".");
v[0] = parseInt(v[0], 10);
v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
v[2] = parseInt(v[2], 10) || 0;
return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
}
/* Cross-browser dynamic CSS creation
- Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php
*/
function createCSS(sel, decl, media, newStyle) {
if (ua.ie && ua.mac) { return; }
var h = doc.getElementsByTagName("head")[0];
if (!h) { return; } // to also support badly authored HTML pages that lack a head element
var m = (media && typeof media == "string") ? media : "screen";
if (newStyle) {
dynamicStylesheet = null;
dynamicStylesheetMedia = null;
}
if (!dynamicStylesheet || dynamicStylesheetMedia != m) {
// create dynamic stylesheet + get a global reference to it
var s = createElement("style");
s.setAttribute("type", "text/css");
s.setAttribute("media", m);
dynamicStylesheet = h.appendChild(s);
if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1];
}
dynamicStylesheetMedia = m;
}
// add style rule
if (ua.ie && ua.win) {
if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) {
dynamicStylesheet.addRule(sel, decl);
}
}
else {
if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) {
dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
}
}
}
function setVisibility(id, isVisible) {
if (!autoHideShow) { return; }
var v = isVisible ? "visible" : "hidden";
if (isDomLoaded && getElementById(id)) {
getElementById(id).style.visibility = v;
}
else {
createCSS("#" + id, "visibility:" + v);
}
}
/* Filter to avoid XSS attacks
*/
function urlEncodeIfNecessary(s) {
var regex = /[\\\"<>\.;]/;
var hasBadChars = regex.exec(s) != null;
return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
}
/* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
*/
var cleanup = function() {
if (ua.ie && ua.win) {
window.attachEvent("onunload", function() {
// remove listeners to avoid memory leaks
var ll = listenersArr.length;
for (var i = 0; i < ll; i++) {
listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
}
// cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
var il = objIdArr.length;
for (var j = 0; j < il; j++) {
removeSWF(objIdArr[j]);
}
// cleanup library's main closures to avoid memory leaks
for (var k in ua) {
ua[k] = null;
}
ua = null;
for (var l in swfobject) {
swfobject[l] = null;
}
swfobject = null;
});
}
}();
return {
/* Public API
- Reference: http://code.google.com/p/swfobject/wiki/documentation
*/
registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) {
if (ua.w3 && objectIdStr && swfVersionStr) {
var regObj = {};
regObj.id = objectIdStr;
regObj.swfVersion = swfVersionStr;
regObj.expressInstall = xiSwfUrlStr;
regObj.callbackFn = callbackFn;
regObjArr[regObjArr.length] = regObj;
setVisibility(objectIdStr, false);
}
else if (callbackFn) {
callbackFn({success:false, id:objectIdStr});
}
},
getObjectById: function(objectIdStr) {
if (ua.w3) {
return getObjectById(objectIdStr);
}
},
embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
var callbackObj = {success:false, id:replaceElemIdStr};
if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
setVisibility(replaceElemIdStr, false);
addDomLoadEvent(function() {
widthStr += ""; // auto-convert to string
heightStr += "";
var att = {};
if (attObj && typeof attObj === OBJECT) {
for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs
att[i] = attObj[i];
}
}
att.data = swfUrlStr;
att.width = widthStr;
att.height = heightStr;
var par = {};
if (parObj && typeof parObj === OBJECT) {
for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs
par[j] = parObj[j];
}
}
if (flashvarsObj && typeof flashvarsObj === OBJECT) {
for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs
if (typeof par.flashvars != UNDEF) {
par.flashvars += "&" + k + "=" + flashvarsObj[k];
}
else {
par.flashvars = k + "=" + flashvarsObj[k];
}
}
}
if (hasPlayerVersion(swfVersionStr)) { // create SWF
var obj = createSWF(att, par, replaceElemIdStr);
if (att.id == replaceElemIdStr) {
setVisibility(replaceElemIdStr, true);
}
callbackObj.success = true;
callbackObj.ref = obj;
}
else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install
att.data = xiSwfUrlStr;
showExpressInstall(att, par, replaceElemIdStr, callbackFn);
return;
}
else { // show alternative content
setVisibility(replaceElemIdStr, true);
}
if (callbackFn) { callbackFn(callbackObj); }
});
}
else if (callbackFn) { callbackFn(callbackObj); }
},
switchOffAutoHideShow: function() {
autoHideShow = false;
},
ua: ua,
getFlashPlayerVersion: function() {
return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
},
hasFlashPlayerVersion: hasPlayerVersion,
createSWF: function(attObj, parObj, replaceElemIdStr) {
if (ua.w3) {
return createSWF(attObj, parObj, replaceElemIdStr);
}
else {
return undefined;
}
},
showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) {
if (ua.w3 && canExpressInstall()) {
showExpressInstall(att, par, replaceElemIdStr, callbackFn);
}
},
removeSWF: function(objElemIdStr) {
if (ua.w3) {
removeSWF(objElemIdStr);
}
},
createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) {
if (ua.w3) {
createCSS(selStr, declStr, mediaStr, newStyleBoolean);
}
},
addDomLoadEvent: addDomLoadEvent,
addLoadEvent: addLoadEvent,
getQueryParamValue: function(param) {
var q = doc.location.search || doc.location.hash;
if (q) {
if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark
if (param == null) {
return urlEncodeIfNecessary(q);
}
var pairs = q.split("&");
for (var i = 0; i < pairs.length; i++) {
if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1)));
}
}
}
return "";
},
// For internal usage only
expressInstallCallback: function() {
if (isExpressInstallActive) {
var obj = getElementById(EXPRESS_INSTALL_ID);
if (obj && storedAltContent) {
obj.parentNode.replaceChild(storedAltContent, obj);
if (storedAltContentId) {
setVisibility(storedAltContentId, true);
if (ua.ie && ua.win) { storedAltContent.style.display = "block"; }
}
if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); }
}
isExpressInstallActive = false;
}
}
};
}();
| JavaScript |
BrowserHistoryUtils = {
addEvent: function(elm, evType, fn, useCapture) {
useCapture = useCapture || false;
if (elm.addEventListener) {
elm.addEventListener(evType, fn, useCapture);
return true;
}
else if (elm.attachEvent) {
var r = elm.attachEvent('on' + evType, fn);
return r;
}
else {
elm['on' + evType] = fn;
}
}
}
BrowserHistory = (function() {
// type of browser
var browser = {
ie: false,
ie8: false,
firefox: false,
safari: false,
opera: false,
version: -1
};
// Default app state URL to use when no fragment ID present
var defaultHash = '';
// Last-known app state URL
var currentHref = document.location.href;
// Initial URL (used only by IE)
var initialHref = document.location.href;
// Initial URL (used only by IE)
var initialHash = document.location.hash;
// History frame source URL prefix (used only by IE)
var historyFrameSourcePrefix = 'history/historyFrame.html?';
// History maintenance (used only by Safari)
var currentHistoryLength = -1;
// Flag to denote the existence of onhashchange
var browserHasHashChange = false;
var historyHash = [];
var initialState = createState(initialHref, initialHref + '#' + initialHash, initialHash);
var backStack = [];
var forwardStack = [];
var currentObjectId = null;
//UserAgent detection
var useragent = navigator.userAgent.toLowerCase();
if (useragent.indexOf("opera") != -1) {
browser.opera = true;
} else if (useragent.indexOf("msie") != -1) {
browser.ie = true;
browser.version = parseFloat(useragent.substring(useragent.indexOf('msie') + 4));
if (browser.version == 8)
{
browser.ie = false;
browser.ie8 = true;
}
} else if (useragent.indexOf("safari") != -1) {
browser.safari = true;
browser.version = parseFloat(useragent.substring(useragent.indexOf('safari') + 7));
} else if (useragent.indexOf("gecko") != -1) {
browser.firefox = true;
}
if (browser.ie == true && browser.version == 7) {
window["_ie_firstload"] = false;
}
function hashChangeHandler()
{
currentHref = document.location.href;
var flexAppUrl = getHash();
//ADR: to fix multiple
if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) {
var pl = getPlayers();
for (var i = 0; i < pl.length; i++) {
pl[i].browserURLChange(flexAppUrl);
}
} else {
getPlayer().browserURLChange(flexAppUrl);
}
}
// Accessor functions for obtaining specific elements of the page.
function getHistoryFrame()
{
return document.getElementById('ie_historyFrame');
}
function getFormElement()
{
return document.getElementById('safari_formDiv');
}
function getRememberElement()
{
return document.getElementById("safari_remember_field");
}
// Get the Flash player object for performing ExternalInterface callbacks.
// Updated for changes to SWFObject2.
function getPlayer(id) {
var i;
if (id && document.getElementById(id)) {
var r = document.getElementById(id);
if (typeof r.SetVariable != "undefined") {
return r;
}
else {
var o = r.getElementsByTagName("object");
var e = r.getElementsByTagName("embed");
for (i = 0; i < o.length; i++) {
if (typeof o[i].browserURLChange != "undefined")
return o[i];
}
for (i = 0; i < e.length; i++) {
if (typeof e[i].browserURLChange != "undefined")
return e[i];
}
}
}
else {
var o = document.getElementsByTagName("object");
var e = document.getElementsByTagName("embed");
for (i = 0; i < e.length; i++) {
if (typeof e[i].browserURLChange != "undefined")
{
return e[i];
}
}
for (i = 0; i < o.length; i++) {
if (typeof o[i].browserURLChange != "undefined")
{
return o[i];
}
}
}
return undefined;
}
function getPlayers() {
var i;
var players = [];
if (players.length == 0) {
var tmp = document.getElementsByTagName('object');
for (i = 0; i < tmp.length; i++)
{
if (typeof tmp[i].browserURLChange != "undefined")
players.push(tmp[i]);
}
}
if (players.length == 0 || players[0].object == null) {
var tmp = document.getElementsByTagName('embed');
for (i = 0; i < tmp.length; i++)
{
if (typeof tmp[i].browserURLChange != "undefined")
players.push(tmp[i]);
}
}
return players;
}
function getIframeHash() {
var doc = getHistoryFrame().contentWindow.document;
var hash = String(doc.location.search);
if (hash.length == 1 && hash.charAt(0) == "?") {
hash = "";
}
else if (hash.length >= 2 && hash.charAt(0) == "?") {
hash = hash.substring(1);
}
return hash;
}
/* Get the current location hash excluding the '#' symbol. */
function getHash() {
// It would be nice if we could use document.location.hash here,
// but it's faulty sometimes.
var idx = document.location.href.indexOf('#');
return (idx >= 0) ? document.location.href.substr(idx+1) : '';
}
/* Get the current location hash excluding the '#' symbol. */
function setHash(hash) {
// It would be nice if we could use document.location.hash here,
// but it's faulty sometimes.
if (hash == '') hash = '#'
document.location.hash = hash;
}
function createState(baseUrl, newUrl, flexAppUrl) {
return { 'baseUrl': baseUrl, 'newUrl': newUrl, 'flexAppUrl': flexAppUrl, 'title': null };
}
/* Add a history entry to the browser.
* baseUrl: the portion of the location prior to the '#'
* newUrl: the entire new URL, including '#' and following fragment
* flexAppUrl: the portion of the location following the '#' only
*/
function addHistoryEntry(baseUrl, newUrl, flexAppUrl) {
//delete all the history entries
forwardStack = [];
if (browser.ie) {
//Check to see if we are being asked to do a navigate for the first
//history entry, and if so ignore, because it's coming from the creation
//of the history iframe
if (flexAppUrl == defaultHash && document.location.href == initialHref && window['_ie_firstload']) {
currentHref = initialHref;
return;
}
if ((!flexAppUrl || flexAppUrl == defaultHash) && window['_ie_firstload']) {
newUrl = baseUrl + '#' + defaultHash;
flexAppUrl = defaultHash;
} else {
// for IE, tell the history frame to go somewhere without a '#'
// in order to get this entry into the browser history.
getHistoryFrame().src = historyFrameSourcePrefix + flexAppUrl;
}
setHash(flexAppUrl);
} else {
//ADR
if (backStack.length == 0 && initialState.flexAppUrl == flexAppUrl) {
initialState = createState(baseUrl, newUrl, flexAppUrl);
} else if(backStack.length > 0 && backStack[backStack.length - 1].flexAppUrl == flexAppUrl) {
backStack[backStack.length - 1] = createState(baseUrl, newUrl, flexAppUrl);
}
if (browser.safari && !browserHasHashChange) {
// for Safari, submit a form whose action points to the desired URL
if (browser.version <= 419.3) {
var file = window.location.pathname.toString();
file = file.substring(file.lastIndexOf("/")+1);
getFormElement().innerHTML = '<form name="historyForm" action="'+file+'#' + flexAppUrl + '" method="GET"></form>';
//get the current elements and add them to the form
var qs = window.location.search.substring(1);
var qs_arr = qs.split("&");
for (var i = 0; i < qs_arr.length; i++) {
var tmp = qs_arr[i].split("=");
var elem = document.createElement("input");
elem.type = "hidden";
elem.name = tmp[0];
elem.value = tmp[1];
document.forms.historyForm.appendChild(elem);
}
document.forms.historyForm.submit();
} else {
top.location.hash = flexAppUrl;
}
// We also have to maintain the history by hand for Safari
historyHash[history.length] = flexAppUrl;
_storeStates();
} else {
// Otherwise, just tell the browser to go there
setHash(flexAppUrl);
}
}
backStack.push(createState(baseUrl, newUrl, flexAppUrl));
}
function _storeStates() {
if (browser.safari) {
getRememberElement().value = historyHash.join(",");
}
}
function handleBackButton() {
//The "current" page is always at the top of the history stack.
var current = backStack.pop();
if (!current) { return; }
var last = backStack[backStack.length - 1];
if (!last && backStack.length == 0){
last = initialState;
}
forwardStack.push(current);
}
function handleForwardButton() {
//summary: private method. Do not call this directly.
var last = forwardStack.pop();
if (!last) { return; }
backStack.push(last);
}
function handleArbitraryUrl() {
//delete all the history entries
forwardStack = [];
}
/* Called periodically to poll to see if we need to detect navigation that has occurred */
function checkForUrlChange() {
if (browser.ie) {
if (currentHref != document.location.href && currentHref + '#' != document.location.href) {
//This occurs when the user has navigated to a specific URL
//within the app, and didn't use browser back/forward
//IE seems to have a bug where it stops updating the URL it
//shows the end-user at this point, but programatically it
//appears to be correct. Do a full app reload to get around
//this issue.
if (browser.version < 7) {
currentHref = document.location.href;
document.location.reload();
} else {
if (getHash() != getIframeHash()) {
// this.iframe.src = this.blankURL + hash;
var sourceToSet = historyFrameSourcePrefix + getHash();
getHistoryFrame().src = sourceToSet;
currentHref = document.location.href;
}
}
}
}
if (browser.safari && !browserHasHashChange) {
// For Safari, we have to check to see if history.length changed.
if (currentHistoryLength >= 0 && history.length != currentHistoryLength) {
//alert("did change: " + history.length + ", " + historyHash.length + "|" + historyHash[history.length] + "|>" + historyHash.join("|"));
var flexAppUrl = getHash();
if (browser.version < 528.16 /* Anything earlier than Safari 4.0 */)
{
// If it did change and we're running Safari 3.x or earlier,
// then we have to look the old state up in our hand-maintained
// array since document.location.hash won't have changed,
// then call back into BrowserManager.
currentHistoryLength = history.length;
flexAppUrl = historyHash[currentHistoryLength];
}
//ADR: to fix multiple
if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) {
var pl = getPlayers();
for (var i = 0; i < pl.length; i++) {
pl[i].browserURLChange(flexAppUrl);
}
} else {
getPlayer().browserURLChange(flexAppUrl);
}
_storeStates();
}
}
if (browser.firefox && !browserHasHashChange) {
if (currentHref != document.location.href) {
var bsl = backStack.length;
var urlActions = {
back: false,
forward: false,
set: false
}
if ((window.location.hash == initialHash || window.location.href == initialHref) && (bsl == 1)) {
urlActions.back = true;
// FIXME: could this ever be a forward button?
// we can't clear it because we still need to check for forwards. Ugg.
// clearInterval(this.locationTimer);
handleBackButton();
}
// first check to see if we could have gone forward. We always halt on
// a no-hash item.
if (forwardStack.length > 0) {
if (forwardStack[forwardStack.length-1].flexAppUrl == getHash()) {
urlActions.forward = true;
handleForwardButton();
}
}
// ok, that didn't work, try someplace back in the history stack
if ((bsl >= 2) && (backStack[bsl - 2])) {
if (backStack[bsl - 2].flexAppUrl == getHash()) {
urlActions.back = true;
handleBackButton();
}
}
if (!urlActions.back && !urlActions.forward) {
var foundInStacks = {
back: -1,
forward: -1
}
for (var i = 0; i < backStack.length; i++) {
if (backStack[i].flexAppUrl == getHash() && i != (bsl - 2)) {
arbitraryUrl = true;
foundInStacks.back = i;
}
}
for (var i = 0; i < forwardStack.length; i++) {
if (forwardStack[i].flexAppUrl == getHash() && i != (bsl - 2)) {
arbitraryUrl = true;
foundInStacks.forward = i;
}
}
handleArbitraryUrl();
}
// Firefox changed; do a callback into BrowserManager to tell it.
currentHref = document.location.href;
var flexAppUrl = getHash();
//ADR: to fix multiple
if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) {
var pl = getPlayers();
for (var i = 0; i < pl.length; i++) {
pl[i].browserURLChange(flexAppUrl);
}
} else {
getPlayer().browserURLChange(flexAppUrl);
}
}
}
}
var _initialize = function () {
browserHasHashChange = ("onhashchange" in document.body);
if (browser.ie)
{
var scripts = document.getElementsByTagName('script');
for (var i = 0, s; s = scripts[i]; i++) {
if (s.src.indexOf("history.js") > -1) {
var iframe_location = (new String(s.src)).replace("history.js", "historyFrame.html");
}
}
historyFrameSourcePrefix = iframe_location + "?";
var src = historyFrameSourcePrefix;
var iframe = document.createElement("iframe");
iframe.id = 'ie_historyFrame';
iframe.name = 'ie_historyFrame';
iframe.src = 'javascript:false;';
try {
document.body.appendChild(iframe);
} catch(e) {
setTimeout(function() {
document.body.appendChild(iframe);
}, 0);
}
}
if (browser.safari && !browserHasHashChange)
{
var rememberDiv = document.createElement("div");
rememberDiv.id = 'safari_rememberDiv';
document.body.appendChild(rememberDiv);
rememberDiv.innerHTML = '<input type="text" id="safari_remember_field" style="width: 500px;">';
var formDiv = document.createElement("div");
formDiv.id = 'safari_formDiv';
document.body.appendChild(formDiv);
var reloader_content = document.createElement('div');
reloader_content.id = 'safarireloader';
var scripts = document.getElementsByTagName('script');
for (var i = 0, s; s = scripts[i]; i++) {
if (s.src.indexOf("history.js") > -1) {
html = (new String(s.src)).replace(".js", ".html");
}
}
reloader_content.innerHTML = '<iframe id="safarireloader-iframe" src="about:blank" frameborder="no" scrolling="no"></iframe>';
document.body.appendChild(reloader_content);
reloader_content.style.position = 'absolute';
reloader_content.style.left = reloader_content.style.top = '-9999px';
iframe = reloader_content.getElementsByTagName('iframe')[0];
if (document.getElementById("safari_remember_field").value != "" ) {
historyHash = document.getElementById("safari_remember_field").value.split(",");
}
}
if (browserHasHashChange)
document.body.onhashchange = hashChangeHandler;
}
return {
historyHash: historyHash,
backStack: function() { return backStack; },
forwardStack: function() { return forwardStack },
getPlayer: getPlayer,
initialize: function(src) {
_initialize(src);
},
setURL: function(url) {
document.location.href = url;
},
getURL: function() {
return document.location.href;
},
getTitle: function() {
return document.title;
},
setTitle: function(title) {
try {
backStack[backStack.length - 1].title = title;
} catch(e) { }
//if on safari, set the title to be the empty string.
if (browser.safari) {
if (title == "") {
try {
var tmp = window.location.href.toString();
title = tmp.substring((tmp.lastIndexOf("/")+1), tmp.lastIndexOf("#"));
} catch(e) {
title = "";
}
}
}
document.title = title;
},
setDefaultURL: function(def)
{
defaultHash = def;
def = getHash();
//trailing ? is important else an extra frame gets added to the history
//when navigating back to the first page. Alternatively could check
//in history frame navigation to compare # and ?.
if (browser.ie)
{
window['_ie_firstload'] = true;
var sourceToSet = historyFrameSourcePrefix + def;
var func = function() {
getHistoryFrame().src = sourceToSet;
window.location.replace("#" + def);
setInterval(checkForUrlChange, 50);
}
try {
func();
} catch(e) {
window.setTimeout(function() { func(); }, 0);
}
}
if (browser.safari)
{
currentHistoryLength = history.length;
if (historyHash.length == 0) {
historyHash[currentHistoryLength] = def;
var newloc = "#" + def;
window.location.replace(newloc);
} else {
//alert(historyHash[historyHash.length-1]);
}
setInterval(checkForUrlChange, 50);
}
if (browser.firefox || browser.opera)
{
var reg = new RegExp("#" + def + "$");
if (window.location.toString().match(reg)) {
} else {
var newloc ="#" + def;
window.location.replace(newloc);
}
setInterval(checkForUrlChange, 50);
}
},
/* Set the current browser URL; called from inside BrowserManager to propagate
* the application state out to the container.
*/
setBrowserURL: function(flexAppUrl, objectId) {
if (browser.ie && typeof objectId != "undefined") {
currentObjectId = objectId;
}
//fromIframe = fromIframe || false;
//fromFlex = fromFlex || false;
//alert("setBrowserURL: " + flexAppUrl);
//flexAppUrl = (flexAppUrl == "") ? defaultHash : flexAppUrl ;
var pos = document.location.href.indexOf('#');
var baseUrl = pos != -1 ? document.location.href.substr(0, pos) : document.location.href;
var newUrl = baseUrl + '#' + flexAppUrl;
if (document.location.href != newUrl && document.location.href + '#' != newUrl) {
currentHref = newUrl;
addHistoryEntry(baseUrl, newUrl, flexAppUrl);
currentHistoryLength = history.length;
}
},
browserURLChange: function(flexAppUrl) {
var objectId = null;
if (browser.ie && currentObjectId != null) {
objectId = currentObjectId;
}
if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) {
var pl = getPlayers();
for (var i = 0; i < pl.length; i++) {
try {
pl[i].browserURLChange(flexAppUrl);
} catch(e) { }
}
} else {
try {
getPlayer(objectId).browserURLChange(flexAppUrl);
} catch(e) { }
}
currentObjectId = null;
},
getUserAgent: function() {
return navigator.userAgent;
},
getPlatform: function() {
return navigator.platform;
}
}
})();
// Initialization
// Automated unit testing and other diagnostics
function setURL(url)
{
document.location.href = url;
}
function backButton()
{
history.back();
}
function forwardButton()
{
history.forward();
}
function goForwardOrBackInHistory(step)
{
history.go(step);
}
//BrowserHistoryUtils.addEvent(window, "load", function() { BrowserHistory.initialize(); });
(function(i) {
var u =navigator.userAgent;var e=/*@cc_on!@*/false;
var st = setTimeout;
if(/webkit/i.test(u)){
st(function(){
var dr=document.readyState;
if(dr=="loaded"||dr=="complete"){i()}
else{st(arguments.callee,10);}},10);
} else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){
document.addEventListener("DOMContentLoaded",i,false);
} else if(e){
(function(){
var t=document.createElement('doc:rdy');
try{t.doScroll('left');
i();t=null;
}catch(e){st(arguments.callee,0);}})();
} else{
window.onload=i;
}
})( function() {BrowserHistory.initialize();} );
| JavaScript |
var links = [];
links[links.length] = [5, 0];
links[links.length] = [1, 0];
links[links.length] = [6, 5];
links[links.length] = [2, 0];
links[links.length] = [3, 2];
links[links.length] = [7, 5];
links[links.length] = [8, 7];
links[links.length] = [9, 8];
links[links.length] = [10, 9];
links[links.length] = [11, 10];
links[links.length] = [12, 11];
links[links.length] = [13, 8];
links[links.length] = [14, 13];
links[links.length] = [15, 14];
links[links.length] = [16, 15];
links[links.length] = [16, 14];
links[links.length] = [17, 16];
links[links.length] = [18, 17];
links[links.length] = [19, 18];
links[links.length] = [24, 1];
links[links.length] = [24, 21];
links[links.length] = [21, 20];
links[links.length] = [22, 21];
links[links.length] = [23, 22];
links[links.length] = [25, 24];
links[links.length] = [26, 25];
links[links.length] = [27, 26];
links[links.length] = [28, 27];
links[links.length] = [28, 26];
links[links.length] = [29, 28];
links[links.length] = [32, 31];
links[links.length] = [33, 32];
links[links.length] = [34, 33];
links[links.length] = [31, 30];
links[links.length] = [36, 22];
links[links.length] = [30, 29];
links[links.length] = [35, 34];
links[links.length] = [35, 28];
links[links.length] = [35, 29];
links[links.length] = [35, 30];
links[links.length] = [38, 29];
links[links.length] = [40, 29];
links[links.length] = [40, 38];
links[links.length] = [38, 37];
links[links.length] = [39, 37];
links[links.length] = [41, 40];
links[links.length] = [49, 41];
links[links.length] = [42, 39];
links[links.length] = [43, 42];
links[links.length] = [44, 43];
links[links.length] = [46, 44];
links[links.length] = [45, 44];
links[links.length] = [47, 46];
links[links.length] = [47, 43];
links[links.length] = [49, 47];
links[links.length] = [48, 47];
links[links.length] = [49, 48];
links[links.length] = [48, 41];
links[links.length] = [48, 42];
links[links.length] = [41, 39];
links[links.length] = [50, 49];
links[links.length] = [50, 19];
links[links.length] = [51, 19];
links[links.length] = [55, 51];
links[links.length] = [58, 19];
links[links.length] = [56, 55];
links[links.length] = [55, 50];
links[links.length] = [55, 49];
links[links.length] = [49, 46];
links[links.length] = [53, 46];
links[links.length] = [53, 52];
links[links.length] = [52, 50];
links[links.length] = [52, 49];
links[links.length] = [55, 52];
links[links.length] = [56, 54];
links[links.length] = [55, 54];
links[links.length] = [59, 53];
links[links.length] = [59, 57];
links[links.length] = [57, 56];
links[links.length] = [66, 58];
links[links.length] = [66, 18];
links[links.length] = [69, 57];
links[links.length] = [75, 69];
links[links.length] = [67, 57];
links[links.length] = [67, 66];
links[links.length] = [68, 67];
links[links.length] = [75, 74];
links[links.length] = [74, 68];
links[links.length] = [74, 73];
links[links.length] = [66, 17];
links[links.length] = [66, 65];
links[links.length] = [64, 17];
links[links.length] = [65, 64];
links[links.length] = [73, 65];
links[links.length] = [73, 71];
links[links.length] = [72, 71];
links[links.length] = [72, 65];
links[links.length] = [72, 70];
links[links.length] = [64, 60];
links[links.length] = [70, 60];
links[links.length] = [70, 63];
links[links.length] = [63, 60];
links[links.length] = [63, 62];
links[links.length] = [62, 61];
links[links.length] = [61, 60];
links[links.length] = [60, 13];
links[links.length] = [61, 13];
links[links.length] = [69, 68];
links[links.length] = [76, 23];
links[links.length] = [77, 36];
links[links.length] = [77, 22];
links[links.length] = [77, 76];
links[links.length] = [78, 77];
links[links.length] = [79, 77];
links[links.length] = [79, 76];
links[links.length] = [80, 76];
links[links.length] = [80, 79];
links[links.length] = [81, 79];
links[links.length] = [81, 78];
links[links.length] = [82, 81];
links[links.length] = [83, 82];
links[links.length] = [84, 83];
links[links.length] = [85, 84];
links[links.length] = [85, 83];
links[links.length] = [85, 82];
links[links.length] = [82, 80];
links[links.length] = [20, 1];
links[links.length] = [87, 20];
links[links.length] = [86, 23];
links[links.length] = [87, 86];
links[links.length] = [86, 85];
links[links.length] = [88, 86];
links[links.length] = [88, 84];
links[links.length] = [88, 85];
links[links.length] = [89, 86];
links[links.length] = [89, 88];
links[links.length] = [90, 88];
links[links.length] = [90, 89];
links[links.length] = [91, 89];
links[links.length] = [91, 90];
links[links.length] = [93, 92];
links[links.length] = [95, 74];
links[links.length] = [95, 94];
links[links.length] = [96, 95];
links[links.length] = [96, 75];
links[links.length] = [100, 75];
links[links.length] = [100, 96];
links[links.length] = [97, 96];
links[links.length] = [98, 96];
links[links.length] = [99, 98];
links[links.length] = [101, 94];
links[links.length] = [101, 97];
links[links.length] = [104, 101];
links[links.length] = [104, 102];
links[links.length] = [102, 101];
links[links.length] = [103, 102];
links[links.length] = [104, 103];
links[links.length] = [105, 103];
links[links.length] = [106, 105];
links[links.length] = [107, 106];
links[links.length] = [108, 107];
links[links.length] = [109, 108];
links[links.length] = [110, 109];
links[links.length] = [111, 110];
links[links.length] = [63, 112];
links[links.length] = [93, 112];
links[links.length] = [94, 112];
links[links.length] = [118, 117];
links[links.length] = [117, 116];
links[links.length] = [116, 114];
links[links.length] = [115, 114];
links[links.length] = [115, 113];
links[links.length] = [114, 113];
links[links.length] = [4, 3];
links[links.length] = [113, 4];
links[links.length] = [6, 4]; | JavaScript |
var nodes = [];
nodes[nodes.length] = ["富山", "賓霞洞", 22.34155, 114.20847];
nodes[nodes.length] = ["富山", "宏景花園", 22.34094, 114.20793];
nodes[nodes.length] = ["富山", "嘉峰臺", 22.34066, 114.20979];
nodes[nodes.length] = ["富山", "健體站", 22.34058, 114.21114];
nodes[nodes.length] = ["富山", "MID1", 22.34136, 114.21191];
nodes[nodes.length] = ["富山", "教堂", 22.34286, 114.20793];
nodes[nodes.length] = ["富山", "郵局", 22.34318, 114.20876];
nodes[nodes.length] = ["富山", "巴士站", 22.34366, 114.20769];
nodes[nodes.length] = ["富山", "火葬場", 22.34437, 114.20741];
nodes[nodes.length] = ["富山", "火葬場大樓", 22.34518, 114.20769];
nodes[nodes.length] = ["富山", "墳場1", 22.34638, 114.20762];
nodes[nodes.length] = ["富山", "墳場2", 22.34689, 114.20785];
nodes[nodes.length] = ["富山", "石獅", 22.34897, 114.20898];
nodes[nodes.length] = ["蒲崗村道公園", "東面入口", 22.34529, 114.2061];
nodes[nodes.length] = ["蒲崗村道公園", "大樓", 22.34462, 114.20581];
nodes[nodes.length] = ["蒲崗村道公園", "風車", 22.34276, 114.20618];
nodes[nodes.length] = ["蒲崗村道公園", "天幕", 22.34372, 114.20391];
nodes[nodes.length] = ["蒲崗村道公園", "北面入口", 22.34631, 114.20319];
nodes[nodes.length] = ["蒲崗村道公園", "公園", 22.34586, 114.20286];
nodes[nodes.length] = ["蒲崗村道公園", "西面入口", 22.34452, 114.20299];
nodes[nodes.length] = ["斧山道運動場", "運動場", 22.3386, 114.20784];
nodes[nodes.length] = ["斧山道運動場", "入口", 22.33888, 114.20655];
nodes[nodes.length] = ["斧山道運動場", "泳池", 22.33768, 114.20592];
nodes[nodes.length] = ["斧山道運動場", "泳池入口", 22.33701, 114.20656];
nodes[nodes.length] = ["志蓮淨苑", "公園東面入口", 22.33942, 114.20694];
nodes[nodes.length] = ["志蓮淨苑", "公園中間", 22.33976, 114.20619];
nodes[nodes.length] = ["志蓮淨苑", "東門", 22.34004, 114.20542];
nodes[nodes.length] = ["志蓮淨苑", "中庭", 22.3404, 114.20517];
nodes[nodes.length] = ["志蓮淨苑", "天橋", 22.3398, 114.20477];
nodes[nodes.length] = ["志蓮淨苑", "巴士站", 22.33997, 114.20403];
nodes[nodes.length] = ["志蓮淨苑", "午橋", 22.33932, 114.20405];
nodes[nodes.length] = ["志蓮淨苑", "香海軒", 22.33883, 114.20473];
nodes[nodes.length] = ["志蓮淨苑", "鯉魚池", 22.33873, 114.20534];
nodes[nodes.length] = ["志蓮淨苑", "大水輪", 22.33908, 114.20561];
nodes[nodes.length] = ["志蓮淨苑", "水滴", 22.33925, 114.20525];
nodes[nodes.length] = ["志蓮淨苑", "奇石", 22.3394, 114.20477];
nodes[nodes.length] = ["彩虹邨", "大磡變電站", 22.33796, 114.20419];
nodes[nodes.length] = ["鑽石山地鐵站", "C出口", 22.34035, 114.20187];
nodes[nodes.length] = ["鑽石山地鐵站", "史力加", 22.34035, 114.20266];
nodes[nodes.length] = ["鑽石山地鐵站", "A出口", 22.34106, 114.20118];
nodes[nodes.length] = ["鑽石山地鐵站", "浸信會", 22.34128, 114.20272];
nodes[nodes.length] = ["鑽石山地鐵站", "悅庭軒", 22.34189, 114.2016];
nodes[nodes.length] = ["龍蟠苑", "東南", 22.3412, 114.20063];
nodes[nodes.length] = ["龍蟠苑", "南", 22.34143, 114.20014];
nodes[nodes.length] = ["龍蟠苑", "西南", 22.34167, 114.19979];
nodes[nodes.length] = ["龍蟠苑", "西", 22.34185, 114.19895];
nodes[nodes.length] = ["龍蟠苑", "西北", 22.3426, 114.19945];
nodes[nodes.length] = ["龍蟠苑", "中", 22.34222, 114.20054];
nodes[nodes.length] = ["龍蟠苑", "東", 22.34192, 114.20119];
nodes[nodes.length] = ["龍蟠苑", "北", 22.34263, 114.20105];
nodes[nodes.length] = ["鳳德邨", "Va Room", 22.34297, 114.20177];
nodes[nodes.length] = ["鳳德邨", "東", 22.3442, 114.20208];
nodes[nodes.length] = ["鳳德邨", "商場", 22.34372, 114.20024];
nodes[nodes.length] = ["鳳德邨", "西南", 22.34356, 114.19911];
nodes[nodes.length] = ["鳳德邨", "西", 22.34439, 114.19959];
nodes[nodes.length] = ["鳳德邨", "中", 22.344, 114.20133];
nodes[nodes.length] = ["鳳德邨", "學校", 22.3451, 114.2006];
nodes[nodes.length] = ["鳳德邨", "西北", 22.34551, 114.19966];
nodes[nodes.length] = ["鳳德邨", "東北", 22.34517, 114.2025];
nodes[nodes.length] = ["鳳德邨", "教會", 22.34497, 114.19896];
nodes[nodes.length] = ["慈雲山南", "協和書院", 22.34685, 114.20448];
nodes[nodes.length] = ["慈雲山南", "配水庫遊樂場", 22.34708, 114.20547];
nodes[nodes.length] = ["慈雲山南", "水塔", 22.34814, 114.20523];
nodes[nodes.length] = ["慈雲山南", "樂華街遊樂場", 22.34806, 114.20471];
nodes[nodes.length] = ["慈雲山南", "巴士站", 22.34658, 114.2032];
nodes[nodes.length] = ["慈雲山南", "萬年", 22.34693, 114.20228];
nodes[nodes.length] = ["慈雲山南", "體育館", 22.3461, 114.20141];
nodes[nodes.length] = ["慈雲山南", "社區會堂", 22.34618, 114.20093];
nodes[nodes.length] = ["慈雲山南", "龜池", 22.3468, 114.20034];
nodes[nodes.length] = ["慈雲山南", "社區中心", 22.34631, 114.19928];
nodes[nodes.length] = ["慈雲山南", "東迴旋處", 22.34787, 114.20335];
nodes[nodes.length] = ["慈雲山南", "西迴旋處", 22.348, 114.20205];
nodes[nodes.length] = ["慈雲山南", "停車場", 22.34792, 114.20298];
nodes[nodes.length] = ["慈雲山南", "街巿", 22.34771, 114.2011];
nodes[nodes.length] = ["慈雲山南", "慈雲山中心", 22.348, 114.20044];
nodes[nodes.length] = ["慈雲山南", "慈樂邨", 22.3478, 114.19927];
nodes[nodes.length] = ["彩虹邨", "紅萼樓", 22.33675, 114.20609];
nodes[nodes.length] = ["彩虹邨", "迴旋處", 22.33667, 114.20458];
nodes[nodes.length] = ["彩虹邨", "巴士站", 22.33624, 114.20437];
nodes[nodes.length] = ["彩虹邨", "靜山小學", 22.33626, 114.20532];
nodes[nodes.length] = ["彩虹邨", "基華小學", 22.33615, 114.20654];
nodes[nodes.length] = ["彩虹邨", "郵局", 22.33473, 114.20577];
nodes[nodes.length] = ["彩虹邨", "中學", 22.33531, 114.20663];
nodes[nodes.length] = ["彩虹邨", "停車場", 22.33475, 114.20695];
nodes[nodes.length] = ["彩虹邨", "浸信會", 22.33424, 114.20787];
nodes[nodes.length] = ["彩虹邨", "教堂", 22.33537, 114.20737];
nodes[nodes.length] = ["牛池灣", "垃圾站", 22.33593, 114.20771];
nodes[nodes.length] = ["牛池灣", "公園", 22.33627, 114.20845];
nodes[nodes.length] = ["牛池灣", "小巴站", 22.33515, 114.20827];
nodes[nodes.length] = ["牛池灣", "街巿", 22.33531, 114.20893];
nodes[nodes.length] = ["牛池灣", "文娛中心", 22.33455, 114.20883];
nodes[nodes.length] = ["牛池灣", "體育館", 22.33471, 114.20966];
nodes[nodes.length] = ["慈雲山中", "廟", 22.34919, 114.20457];
nodes[nodes.length] = ["慈雲山中", "菩提學會", 22.34927, 114.20335];
nodes[nodes.length] = ["慈雲山中", "中央遊樂場", 22.34918, 114.20163];
nodes[nodes.length] = ["慈雲山中", "巴士站", 22.34887, 114.20078];
nodes[nodes.length] = ["慈雲山中", "郵局", 22.3492, 114.1999];
nodes[nodes.length] = ["慈雲山中", "地鐵站", 22.34976, 114.2];
nodes[nodes.length] = ["慈雲山中", "桃園", 22.34936, 114.19907];
nodes[nodes.length] = ["慈雲山中", "西", 22.34947, 114.19844];
nodes[nodes.length] = ["慈雲山中", "慈樂邨", 22.34877, 114.19795];
nodes[nodes.length] = ["慈雲山北", "佛教聯合會", 22.35064, 114.20053];
nodes[nodes.length] = ["慈雲山北", "太極園", 22.35143, 114.20021];
nodes[nodes.length] = ["慈雲山北", "三期遊樂場", 22.35114, 114.1993];
nodes[nodes.length] = ["慈雲山北", "入口", 22.35087, 114.19992];
nodes[nodes.length] = ["慈雲山北", "巴士站", 22.35084, 114.19841];
nodes[nodes.length] = ["慈雲山北", "觀音廟", 22.35032, 114.19752];
nodes[nodes.length] = ["慈雲山北", "慈愛閣", 22.34985, 114.19686];
nodes[nodes.length] = ["慈雲山北", "報案中心", 22.34986, 114.19635];
nodes[nodes.length] = ["慈雲山北", "沙田坳邨", 22.34961, 114.19559];
nodes[nodes.length] = ["慈雲山北", "西", 22.34917, 114.19512];
nodes[nodes.length] = ["慈雲山北", "法藏寺", 22.3493, 114.19428];
nodes[nodes.length] = ["慈雲山中", "MID1", 22.34863, 114.20314];
nodes[nodes.length] = ["牛池灣公園", "北", 22.33913, 114.21314];
nodes[nodes.length] = ["牛池灣公園", "音樂算盤", 22.33884, 114.21309];
nodes[nodes.length] = ["牛池灣公園", "峻弦", 22.33887, 114.21349];
nodes[nodes.length] = ["牛池灣公園", "中", 22.33714, 114.21368];
nodes[nodes.length] = ["牛池灣公園", "壁畫", 22.33662, 114.21405];
nodes[nodes.length] = ["牛池灣公園", "南", 22.33598, 114.21397]; | JavaScript |
$(document).ready(function(){
if($("ul.dropdown").length) {
$("ul.dropdown li").dropdown();
}
if($("ul.user_navigation").length) {
$("ul.user_navigation li").dropdown();
}
});
$.fn.dropdown = function() {
return this.each(function() {
$(this).hover(function(){
$(this).addClass("hover");
$('> .dir',this).addClass("open");
$('ul:first',this).css('visibility', 'visible');
},function(){
$(this).removeClass("hover");
$('.open',this).removeClass("open");
$('ul:first',this).css('visibility', 'hidden');
});
});
}; | JavaScript |
//** Smooth Navigational Menu- By Dynamic Drive DHTML code library: http://www.dynamicdrive.com
//** Script Download/ instructions page: http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/
//** Menu created: Nov 12, 2008
//** Dec 12th, 08" (v1.01): Fixed Shadow issue when multiple LIs within the same UL (level) contain sub menus: http://www.dynamicdrive.com/forums/showthread.php?t=39177&highlight=smooth
//** Feb 11th, 09" (v1.02): The currently active main menu item (LI A) now gets a CSS class of ".selected", including sub menu items.
//** May 1st, 09" (v1.3):
//** 1) Now supports vertical (side bar) menu mode- set "orientation" to 'v'
//** 2) In IE6, shadows are now always disabled
//** July 27th, 09" (v1.31): Fixed bug so shadows can be disabled if desired.
//** Feb 2nd, 10" (v1.4): Adds ability to specify delay before sub menus appear and disappear, respectively. See showhidedelay variable below
//** Dec 17th, 10" (v1.5): Updated menu shadow to use CSS3 box shadows when the browser is FF3.5+, IE9+, Opera9.5+, or Safari3+/Chrome. Only .js file changed.
var ddsmoothmenu={
//Specify full URL to down and right arrow images (23 is padding-right added to top level LIs with drop downs):
arrowimages: {down:['downarrowclass', '../../images/image_default/menu_smooth_down.gif', 24], right:['rightarrowclass', '../../images/image_default/menu_smooth_right.gif']},
transition: {overtime:300, outtime:300}, //duration of slide in/ out animation, in milliseconds
shadow: {enable:true, offsetx:5, offsety:5}, //enable shadow?
showhidedelay: {showdelay: 100, hidedelay: 200}, //set delay in milliseconds before sub menus appear and disappear, respectively
///////Stop configuring beyond here///////////////////////////
detectwebkit: navigator.userAgent.toLowerCase().indexOf("applewebkit")!=-1, //detect WebKit browsers (Safari, Chrome etc)
detectie6: document.all && !window.XMLHttpRequest,
css3support: window.msPerformance || (!document.all && document.querySelector), //detect browsers that support CSS3 box shadows (ie9+ or FF3.5+, Safari3+, Chrome etc)
getajaxmenu:function($, setting){ //function to fetch external page containing the panel DIVs
var $menucontainer=$('#'+setting.contentsource[0]); //reference empty div on page that will hold menu
$menucontainer.html("Loading Menu...");
$.ajax({
url: setting.contentsource[1], //path to external menu file
async: true,
error:function(ajaxrequest){
$menucontainer.html('Error fetching content. Server Response: '+ajaxrequest.responseText);
},
success:function(content){
$menucontainer.html(content);
ddsmoothmenu.buildmenu($, setting);
}
});
},
buildmenu:function($, setting){
var smoothmenu=ddsmoothmenu;
var $mainmenu=$("#"+setting.mainmenuid+">ul"); //reference main menu UL
$mainmenu.parent().get(0).className=setting.classname || "ddsmoothmenu";
var $headers=$mainmenu.find("ul").parent();
$headers.hover(
function(e){
$(this).children('a:eq(0)').addClass('selected');
},
function(e){
$(this).children('a:eq(0)').removeClass('selected');
}
);
$headers.each(function(i){ //loop through each LI header
var $curobj=$(this).css({zIndex: 100-i}); //reference current LI header
var $subul=$(this).find('ul:eq(0)').css({display:'block'});
$subul.data('timers', {});
this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()};
this.istopheader=$curobj.parents("ul").length==1? true : false; //is top level header?
$subul.css({top:this.istopheader && setting.orientation!='v'? this._dimensions.h+"px" : 0});
$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: smoothmenu.arrowimages.down[2]} : {}).append( //add arrow images
'<img src="'+ (this.istopheader && setting.orientation!='v'? smoothmenu.arrowimages.down[1] : smoothmenu.arrowimages.right[1])
+'" class="' + (this.istopheader && setting.orientation!='v'? smoothmenu.arrowimages.down[0] : smoothmenu.arrowimages.right[0])
+ '" style="border:0;" />'
);
if (smoothmenu.shadow.enable && !smoothmenu.css3support){ //if shadows enabled and browser doesn't support CSS3 box shadows
this._shadowoffset={x:(this.istopheader?$subul.offset().left+smoothmenu.shadow.offsetx : this._dimensions.w), y:(this.istopheader? $subul.offset().top+smoothmenu.shadow.offsety : $curobj.position().top)}; //store this shadow's offsets
if (this.istopheader)
$parentshadow=$(document.body);
else{
var $parentLi=$curobj.parents("li:eq(0)");
$parentshadow=$parentLi.get(0).$shadow;
}
this.$shadow=$('<div class="ddshadow'+(this.istopheader? ' toplevelshadow' : '')+'"></div>').prependTo($parentshadow).css({left:this._shadowoffset.x+'px', top:this._shadowoffset.y+'px'}); //insert shadow DIV and set it to parent node for the next shadow div
}
$curobj.hover(
function(e){
var $targetul=$subul; //reference UL to reveal
var header=$curobj.get(0); //reference header LI as DOM object
clearTimeout($targetul.data('timers').hidetimer);
$targetul.data('timers').showtimer=setTimeout(function(){
header._offsets={left:$curobj.offset().left, top:$curobj.offset().top};
var menuleft=header.istopheader && setting.orientation!='v'? 0 : header._dimensions.w;
menuleft=(header._offsets.left+menuleft+header._dimensions.subulw>$(window).width())? (header.istopheader && setting.orientation!='v'? -header._dimensions.subulw+header._dimensions.w : -header._dimensions.w) : menuleft; //calculate this sub menu's offsets from its parent
if ($targetul.queue().length<=1){ //if 1 or less queued animations
$targetul.css({left:menuleft+"px", width:header._dimensions.subulw+'px'}).animate({height:'show',opacity:'show'}, ddsmoothmenu.transition.overtime);
if (smoothmenu.shadow.enable && !smoothmenu.css3support){
var shadowleft=header.istopheader? $targetul.offset().left+ddsmoothmenu.shadow.offsetx : menuleft;
var shadowtop=header.istopheader?$targetul.offset().top+smoothmenu.shadow.offsety : header._shadowoffset.y;
if (!header.istopheader && ddsmoothmenu.detectwebkit){ //in WebKit browsers, restore shadow's opacity to full
header.$shadow.css({opacity:1});
}
header.$shadow.css({overflow:'', width:header._dimensions.subulw+'px', left:shadowleft+'px', top:shadowtop+'px'}).animate({height:header._dimensions.subulh+'px'}, ddsmoothmenu.transition.overtime);
}
}
}, ddsmoothmenu.showhidedelay.showdelay);
},
function(e){
var $targetul=$subul;
var header=$curobj.get(0);
clearTimeout($targetul.data('timers').showtimer);
$targetul.data('timers').hidetimer=setTimeout(function(){
$targetul.animate({height:'hide', opacity:'hide'}, ddsmoothmenu.transition.outtime);
if (smoothmenu.shadow.enable && !smoothmenu.css3support){
if (ddsmoothmenu.detectwebkit){ //in WebKit browsers, set first child shadow's opacity to 0, as "overflow:hidden" doesn't work in them
header.$shadow.children('div:eq(0)').css({opacity:0});
}
header.$shadow.css({overflow:'hidden'}).animate({height:0}, ddsmoothmenu.transition.outtime);
}
}, ddsmoothmenu.showhidedelay.hidedelay);
}
); //end hover
}); //end $headers.each()
if (smoothmenu.shadow.enable && smoothmenu.css3support){ //if shadows enabled and browser supports CSS3 shadows
var $toplevelul=$('#'+setting.mainmenuid+' ul li ul');
var css3shadow=parseInt(smoothmenu.shadow.offsetx)+"px "+parseInt(smoothmenu.shadow.offsety)+"px 5px #aaa"; //construct CSS3 box-shadow value
var shadowprop=["boxShadow", "MozBoxShadow", "WebkitBoxShadow", "MsBoxShadow"]; //possible vendor specific CSS3 shadow properties
for (var i=0; i<shadowprop.length; i++){
$toplevelul.css(shadowprop[i], css3shadow);
}
}
$mainmenu.find("ul").css({display:'none', visibility:'visible'});
},
init:function(setting){
if (typeof setting.customtheme=="object" && setting.customtheme.length==2){ //override default menu colors (default/hover) with custom set?
var mainmenuid='#'+setting.mainmenuid;
var mainselector=(setting.orientation=="v")? mainmenuid : mainmenuid+', '+mainmenuid;
document.write('<style type="text/css">\n'
+mainselector+' ul li a {background:'+setting.customtheme[0]+';}\n'
+mainmenuid+' ul li a:hover {background:'+setting.customtheme[1]+';}\n'
+'</style>');
}
this.shadow.enable=(document.all && !window.XMLHttpRequest)? false : this.shadow.enable; //in IE6, always disable shadow
jQuery(document).ready(function($){ //ajax menu?
if (typeof setting.contentsource=="object"){ //if external ajax menu
ddsmoothmenu.getajaxmenu($, setting);
}
else{ //else if markup menu
ddsmoothmenu.buildmenu($, setting);
}
});
}
}; //end ddsmoothmenu variable
| JavaScript |
/*
* jQuery UI Multilevel Accordion v.1
*
* Copyright (c) 2011 Pieter Pareit
*
* http://www.scriptbreaker.com
*
*/
//plugin definition
(function($){
$.fn.extend({
//pass the options variable to the function
accordion: function(options) {
var defaults = {
accordion: 'true',
speed: 300,
closedSign: '[+]',
openedSign: '[-]'
};
// Extend our default options with those provided.
var opts = $.extend(defaults, options);
//Assign current element to variable, in this case is UL element
var $this = $(this);
//add a mark [+] to a multilevel menu
$this.find("li").each(function() {
if($(this).find("ul").size() != 0){
//add the multilevel sign next to the link
$(this).find("a:first").append("<span>"+ opts.closedSign +"</span>");
//avoid jumping to the top of the page when the href is an #
if($(this).find("a:first-child").attr('href') == "#"){
$(this).click(function(){return false;});
}
}
});
//open active level
$this.find("li.active").each(function() {
$(this).parents("ul").slideDown(opts.speed);
$(this).parents("ul").parent("li").find("span:first").html(opts.openedSign);
});
$this.find("li a").click(function() {
if($(this).parent().find("ul").size() != 0){
if(opts.accordion){
//Do nothing when the list is open
if(!$(this).parent().find("ul").is(':visible')){
parents = $(this).parent().parents("ul");
visible = $this.find("ul:visible");
visible.each(function(visibleIndex){
var close = true;
parents.each(function(parentIndex){
if(parents[parentIndex] == visible[visibleIndex]){
close = false;
return false;
}
});
if(close){
if($(this).parent().find("ul") != visible[visibleIndex]){
$(visible[visibleIndex]).slideUp(opts.speed, function(){
$(this).parent("li").find("span:first").html(opts.closedSign);
});
}
}
});
}
}
if($(this).parent().find("ul:first").is(":visible")){
$(this).parent().find("ul:first").slideUp(opts.speed, function(){
$(this).parent("li").find("span:first").delay(opts.speed).html(opts.closedSign);
});
}else{
$(this).parent().find("ul:first").slideDown(opts.speed, function(){
$(this).parent("li").find("span:first").delay(opts.speed).html(opts.openedSign);
});
}
}
});
}
});
})(jQuery); | JavaScript |
/************************************************************************
*************************************************************************
@Name : QapTcha - jQuery Plugin
@Revison : 2.6
@Date : 26/01/2011
@Author: Surrel Mickael (www.myjqueryplugins.com - www.msconcept.fr)
@License : Open Source - MIT License : http://www.opensource.org/licenses/mit-license.php
**************************************************************************
*************************************************************************/
jQuery.QapTcha = {
build : function(options)
{
var defaults = {
txtLock : 'Khóa : Không thể gửi đi',
txtUnlock : 'Khóa mở : có thể gửi đi',
disabledSubmit : true,
autoRevert : false,
PHPfile : './../assets/javaScript/js_catcha_slider/Qaptcha.jquery.php'
};
if(this.length>0)
return jQuery(this).each(function(i) {
/** Vars **/
var
opts = $.extend(defaults, options),
$this = $(this),
form = $('form').has($this),
//Clr = jQuery('<div>',{'class':'clr'}),
bgSlider = jQuery('<div>',{id:'bgSlider'}),
Slider = jQuery('<div>',{id:'Slider'}),
Icons = jQuery('<div>',{id:'Icons'}),
TxtStatus = jQuery('<div>',{id:'TxtStatus','class':'dropError',text:opts.txtLock}),
inputQapTcha = jQuery('<input>',{name:'iQapTcha',value:generatePass(),type:'hidden'});
/** Disabled submit button **/
if(opts.disabledSubmit) form.find('input[type=\'submit\']').attr('disabled','disabled');
/** Construct DOM **/
bgSlider.appendTo($this);
Icons.insertAfter(bgSlider);
//Clr.insertAfter(Icons);
TxtStatus.insertAfter(Icons);
inputQapTcha.appendTo($this);
Slider.appendTo(bgSlider);
$this.show();
Slider.draggable({
revert: function(){
if(opts.autoRevert)
{
if(parseInt(Slider.css("left")) > 150) return false;
else return true;
}
},
containment: bgSlider,
axis:'x',
stop: function(event,ui){
if(ui.position.left > 150)
{
// set the SESSION iQaptcha in PHP file
$.post(opts.PHPfile,{
action : 'qaptcha'
},
function(data) {
if(!data.error)
{
Slider.draggable('disable').css('cursor','default');
inputQapTcha.val("");
TxtStatus.text(opts.txtUnlock).addClass('dropSuccess').removeClass('dropError');
Icons.css('background-position', '-16px 0');
form.find('input[type=\'submit\']').removeAttr('disabled');
}
},'json');
}
}
});
function generatePass() {
var chars = 'azertyupqsdfghjkmwxcvbn23456789AZERTYUPQSDFGHJKMWXCVBN';
var pass = '';
for(i=0;i<10;i++){
var wpos = Math.round(Math.random()*chars.length);
pass += chars.substring(wpos,wpos+1);
}
return pass;
}
});
}
}; jQuery.fn.QapTcha = jQuery.QapTcha.build; | JavaScript |
jQuery.extend({
createUploadIframe: function(id, uri)
{
//create frame
var frameId = 'jUploadFrame' + id;
var iframeHtml = '<iframe id="' + frameId + '" name="' + frameId + '" style="position:absolute; top:-9999px; left:-9999px"';
if(window.ActiveXObject)
{
if(typeof uri== 'boolean'){
iframeHtml += ' src="' + 'javascript:false' + '"';
}
else if(typeof uri== 'string'){
iframeHtml += ' src="' + uri + '"';
}
}
iframeHtml += ' />';
jQuery(iframeHtml).appendTo(document.body);
return jQuery('#' + frameId).get(0);
},
createUploadForm: function(id, fileElementId, data)
{
//create form
var formId = 'jUploadForm' + id;
var fileId = 'jUploadFile' + id;
var form = jQuery('<form action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
if(data)
{
for(var i in data)
{
jQuery('<input type="hidden" name="' + i + '" value="' + data[i] + '" />').appendTo(form);
}
}
var oldElement = jQuery('#' + fileElementId);
var newElement = jQuery(oldElement).clone();
jQuery(oldElement).attr('id', fileId);
jQuery(oldElement).before(newElement);
jQuery(oldElement).appendTo(form);
//set attributes
jQuery(form).css('position', 'absolute');
jQuery(form).css('top', '-1200px');
jQuery(form).css('left', '-1200px');
jQuery(form).appendTo('body');
return form;
},
ajaxFileUpload: function(s) {
// TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
s = jQuery.extend({}, jQuery.ajaxSettings, s);
var id = new Date().getTime();
var form = jQuery.createUploadForm(id, s.fileElementId, (typeof(s.data)=='undefined'?false:s.data));
var io = jQuery.createUploadIframe(id, s.secureuri);
if(io==null){
alert("can create object");
}
var frameId = 'jUploadFrame' + id;
var formId = 'jUploadForm' + id;
// Watch for a new set of requests
if ( s.global && ! jQuery.active++ )
{
jQuery.event.trigger( "ajaxStart" );
}
var requestDone = false;
// Create the request object
var xml = {};
if ( s.global )
jQuery.event.trigger("ajaxSend", [xml, s]);
// Wait for a response to come back
var uploadCallback = function(isTimeout)
{
var io = document.getElementById(frameId);
try
{
if(io.contentWindow)
{
xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
}else if(io.contentDocument)
{
xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;
xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
}
}catch(e)
{
jQuery.handleError(s, xml, null, e);
}
if ( xml || isTimeout == "timeout")
{
requestDone = true;
var status;
try {
status = isTimeout != "timeout" ? "success" : "error";
// Make sure that the request was successful or notmodified
if ( status != "error" )
{
// process the data (runs the xml through httpData regardless of callback)
var data = jQuery.uploadHttpData( xml, s.dataType );
// If a local callback was specified, fire it and pass it the data
if ( s.success )
s.success( data, status );
// Fire the global callback
if( s.global )
jQuery.event.trigger( "ajaxSuccess", [xml, s] );
} else
jQuery.handleError(s, xml, status);
} catch(e)
{
status = "error";
jQuery.handleError(s, xml, status, e);
}
// The request was completed
if( s.global )
jQuery.event.trigger( "ajaxComplete", [xml, s] );
// Handle the global AJAX counter
if ( s.global && ! --jQuery.active )
jQuery.event.trigger( "ajaxStop" );
// Process result
if ( s.complete )
s.complete(xml, status);
jQuery(io).unbind();
setTimeout(function()
{ try
{
jQuery(io).remove();
jQuery(form).remove();
} catch(e)
{
jQuery.handleError(s, xml, null, e);
}
}, 100);
xml = null;
}
};
// Timeout checker
if ( s.timeout > 0 )
{
setTimeout(function(){
// Check to see if the request is still happening
if( !requestDone ) uploadCallback( "timeout" );
}, s.timeout);
}
try
{
var form = jQuery('#' + formId);
jQuery(form).attr('action', s.url);
jQuery(form).attr('method', 'POST');
jQuery(form).attr('target', frameId);
if(form.encoding)
{
jQuery(form).attr('encoding', 'multipart/form-data');
}
else
{
jQuery(form).attr('enctype', 'multipart/form-data');
}
jQuery(form).submit();
} catch(e)
{
jQuery.handleError(s, xml, null, e);
}
jQuery('#' + frameId).load(uploadCallback );
return {abort: function () {}};
},
uploadHttpData: function( r, type ) {
var data = !type;
data = type == "xml" || data ? r.responseXML : r.responseText;
// If the type is "script", eval it in global context
if ( type == "script" )
jQuery.globalEval( data );
// Get the JavaScript object, if JSON is used.
if ( type == "json" )
eval( "data = " + data );
// evaluate scripts within html
if ( type == "html" )
jQuery("<div>").html(data).evalScripts();
return data;
},
handleError: function( s, xhr, status, e ) {
// If a local callback was specified, fire it
if ( s.error ) {
s.error.call( s.context || window, xhr, status, e );
}
// Fire the global callback
if ( s.global ) {
(s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
}
}
});
| JavaScript |
/**
* Copyright (c) 2010 Anders Ekdahl (http://coffeescripter.com/)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Version: 1.2.4
*
* Demo and documentation: http://coffeescripter.com/code/ad-gallery/
*/
(function($) {
$.fn.adGallery = function(options) {
var defaults = { loader_image: 'loader.gif',
start_at_index: 0,
description_wrapper: false,
thumb_opacity: 0.7,
animate_first_image: false,
animation_speed: 400,
width: false,
height: false,
display_next_and_prev: true,
display_back_and_forward: true,
scroll_jump: 0, // If 0, it jumps the width of the container
slideshow: {
enable: true,
autostart: false,
speed: 5000,
start_label: 'Start',
stop_label: 'Stop',
stop_on_scroll: true,
countdown_prefix: '(',
countdown_sufix: ')',
onStart: false,
onStop: false
},
effect: 'slide-hori', // or 'slide-vert', 'fade', or 'resize', 'none'
enable_keyboard_move: true,
cycle: true,
callbacks: {
init: false,
afterImageVisible: false,
beforeImageVisible: false
}
};
var settings = $.extend(false, defaults, options);
if(options && options.slideshow) {
settings.slideshow = $.extend(false, defaults.slideshow, options.slideshow);
};
if(!settings.slideshow.enable) {
settings.slideshow.autostart = false;
};
var galleries = [];
$(this).each(function() {
var gallery = new AdGallery(this, settings);
galleries[galleries.length] = gallery;
});
// Sorry, breaking the jQuery chain because the gallery instances
// are returned so you can fiddle with them
return galleries;
};
function VerticalSlideAnimation(img_container, direction, desc) {
var current_top = parseInt(img_container.css('top'), 10);
if(direction == 'left') {
var old_image_top = '-'+ this.image_wrapper_height +'px';
img_container.css('top', this.image_wrapper_height +'px');
} else {
var old_image_top = this.image_wrapper_height +'px';
img_container.css('top', '-'+ this.image_wrapper_height +'px');
};
if(desc) {
desc.css('bottom', '-'+ desc[0].offsetHeight +'px');
desc.animate({bottom: 0}, this.settings.animation_speed * 2);
};
if(this.current_description) {
this.current_description.animate({bottom: '-'+ this.current_description[0].offsetHeight +'px'}, this.settings.animation_speed * 2);
};
return {old_image: {top: old_image_top},
new_image: {top: current_top}};
};
function HorizontalSlideAnimation(img_container, direction, desc) {
var current_left = parseInt(img_container.css('left'), 10);
if(direction == 'left') {
var old_image_left = '-'+ this.image_wrapper_width +'px';
img_container.css('left',this.image_wrapper_width +'px');
} else {
var old_image_left = this.image_wrapper_width +'px';
img_container.css('left','-'+ this.image_wrapper_width +'px');
};
if(desc) {
desc.css('bottom', '-'+ desc[0].offsetHeight +'px');
desc.animate({bottom: 0}, this.settings.animation_speed * 2);
};
if(this.current_description) {
this.current_description.animate({bottom: '-'+ this.current_description[0].offsetHeight +'px'}, this.settings.animation_speed * 2);
};
return {old_image: {left: old_image_left},
new_image: {left: current_left}};
};
function ResizeAnimation(img_container, direction, desc) {
var image_width = img_container.width();
var image_height = img_container.height();
var current_left = parseInt(img_container.css('left'), 10);
var current_top = parseInt(img_container.css('top'), 10);
img_container.css({width: 0, height: 0, top: this.image_wrapper_height / 2, left: this.image_wrapper_width / 2});
return {old_image: {width: 0,
height: 0,
top: this.image_wrapper_height / 2,
left: this.image_wrapper_width / 2},
new_image: {width: image_width,
height: image_height,
top: current_top,
left: current_left}};
};
function FadeAnimation(img_container, direction, desc) {
img_container.css('opacity', 0);
return {old_image: {opacity: 0},
new_image: {opacity: 1}};
};
// Sort of a hack, will clean this up... eventually
function NoneAnimation(img_container, direction, desc) {
img_container.css('opacity', 0);
return {old_image: {opacity: 0},
new_image: {opacity: 1},
speed: 0};
};
function AdGallery(wrapper, settings) {
this.init(wrapper, settings);
};
AdGallery.prototype = {
// Elements
wrapper: false,
image_wrapper: false,
gallery_info: false,
nav: false,
loader: false,
preloads: false,
thumbs_wrapper: false,
scroll_back: false,
scroll_forward: false,
next_link: false,
prev_link: false,
slideshow: false,
image_wrapper_width: 0,
image_wrapper_height: 0,
current_index: 0,
current_image: false,
current_description: false,
nav_display_width: 0,
settings: false,
images: false,
in_transition: false,
animations: false,
init: function(wrapper, settings) {
var context = this;
this.wrapper = $(wrapper);
this.settings = settings;
this.setupElements();
this.setupAnimations();
if(this.settings.width) {
this.image_wrapper_width = this.settings.width;
this.image_wrapper.width(this.settings.width);
this.wrapper.width(this.settings.width);
} else {
this.image_wrapper_width = this.image_wrapper.width();
};
if(this.settings.height) {
this.image_wrapper_height = this.settings.height;
this.image_wrapper.height(this.settings.height);
} else {
this.image_wrapper_height = this.image_wrapper.height();
};
this.nav_display_width = this.nav.width();
this.current_index = 0;
this.current_image = false;
this.current_description = false;
this.in_transition = false;
this.findImages();
if(this.settings.display_next_and_prev) {
this.initNextAndPrev();
};
// The slideshow needs a callback to trigger the next image to be shown
// but we don't want to give it access to the whole gallery instance
var nextimage_callback = function(callback) {
return context.nextImage(callback);
};
this.slideshow = new AdGallerySlideshow(nextimage_callback, this.settings.slideshow);
this.controls.append(this.slideshow.create());
if(this.settings.slideshow.enable) {
this.slideshow.enable();
} else {
this.slideshow.disable();
};
if(this.settings.display_back_and_forward) {
this.initBackAndForward();
};
if(this.settings.enable_keyboard_move) {
this.initKeyEvents();
};
var start_at = parseInt(this.settings.start_at_index, 10);
if(window.location.hash && window.location.hash.indexOf('#ad-image') === 0) {
start_at = window.location.hash.replace(/[^0-9]+/g, '');
// Check if it's a number
if((start_at * 1) != start_at) {
start_at = this.settings.start_at_index;
};
};
this.loading(true);
this.showImage(start_at,
function() {
// We don't want to start the slideshow before the image has been
// displayed
if(context.settings.slideshow.autostart) {
context.preloadImage(start_at + 1);
context.slideshow.start();
};
}
);
this.fireCallback(this.settings.callbacks.init);
},
setupAnimations: function() {
this.animations = {
'slide-vert': VerticalSlideAnimation,
'slide-hori': HorizontalSlideAnimation,
'resize': ResizeAnimation,
'fade': FadeAnimation,
'none': NoneAnimation
};
},
setupElements: function() {
this.controls = this.wrapper.find('.ad-controls');
this.gallery_info = $('<p class="ad-info"></p>');
this.controls.append(this.gallery_info);
this.image_wrapper = this.wrapper.find('.ad-image-wrapper');
this.image_wrapper.empty();
this.nav = this.wrapper.find('.ad-nav');
this.thumbs_wrapper = this.nav.find('.ad-thumbs');
this.preloads = $('<div class="ad-preloads"></div>');
this.loader = $('<img class="ad-loader" src="'+ this.settings.loader_image +'">');
this.image_wrapper.append(this.loader);
this.loader.hide();
$(document.body).append(this.preloads);
},
loading: function(bool) {
if(bool) {
this.loader.show();
} else {
this.loader.hide();
};
},
addAnimation: function(name, fn) {
if($.isFunction(fn)) {
this.animations[name] = fn;
};
},
findImages: function() {
var context = this;
this.images = [];
var thumb_wrapper_width = 0;
var thumbs_loaded = 0;
var thumbs = this.thumbs_wrapper.find('a');
var thumb_count = thumbs.length;
if(this.settings.thumb_opacity < 1) {
thumbs.find('img').css('opacity', this.settings.thumb_opacity);
};
thumbs.each(
function(i) {
var link = $(this);
var image_src = link.attr('href');
var thumb = link.find('img');
// Check if the thumb has already loaded
if(!context.isImageLoaded(thumb[0])) {
thumb.load(
function() {
thumb_wrapper_width += this.parentNode.parentNode.offsetWidth;
thumbs_loaded++;
}
);
} else{
thumb_wrapper_width += thumb[0].parentNode.parentNode.offsetWidth;
thumbs_loaded++;
};
link.addClass('ad-thumb'+ i);
link.click(
function() {
context.showImage(i);
context.slideshow.stop();
return false;
}
).hover(
function() {
if(!$(this).is('.ad-active') && context.settings.thumb_opacity < 1) {
$(this).find('img').fadeTo(300, 1);
};
context.preloadImage(i);
},
function() {
if(!$(this).is('.ad-active') && context.settings.thumb_opacity < 1) {
$(this).find('img').fadeTo(300, context.settings.thumb_opacity);
};
}
);
var link = false;
if(thumb.data('ad-link')) {
link = thumb.data('ad-link');
} else if(thumb.attr('longdesc') && thumb.attr('longdesc').length) {
link = thumb.attr('longdesc');
};
var desc = false;
if(thumb.data('ad-desc')) {
desc = thumb.data('ad-desc');
} else if(thumb.attr('alt') && thumb.attr('alt').length) {
desc = thumb.attr('alt');
};
var title = false;
if(thumb.data('ad-title')) {
title = thumb.data('ad-title');
} else if(thumb.attr('title') && thumb.attr('title').length) {
title = thumb.attr('title');
};
context.images[i] = { thumb: thumb.attr('src'), image: image_src, error: false,
preloaded: false, desc: desc, title: title, size: false,
link: link };
}
);
// Wait until all thumbs are loaded, and then set the width of the ul
var inter = setInterval(
function() {
if(thumb_count == thumbs_loaded) {
thumb_wrapper_width -= 100;
var list = context.nav.find('.ad-thumb-list');
list.css('width', thumb_wrapper_width +'px');
var i = 1;
var last_height = list.height();
while(i < 201) {
list.css('width', (thumb_wrapper_width + i) +'px');
if(last_height != list.height()) {
break;
}
last_height = list.height();
i++;
}
clearInterval(inter);
};
},
100
);
},
initKeyEvents: function() {
var context = this;
$(document).keydown(
function(e) {
if(e.keyCode == 39) {
// right arrow
context.nextImage();
context.slideshow.stop();
} else if(e.keyCode == 37) {
// left arrow
context.prevImage();
context.slideshow.stop();
};
}
);
},
initNextAndPrev: function() {
this.next_link = $('<div class="ad-next"><div class="ad-next-image"></div></div>');
this.prev_link = $('<div class="ad-prev"><div class="ad-prev-image"></div></div>');
this.image_wrapper.append(this.next_link);
this.image_wrapper.append(this.prev_link);
var context = this;
this.prev_link.add(this.next_link).mouseover(
function(e) {
// IE 6 hides the wrapper div, so we have to set it's width
$(this).css('height', context.image_wrapper_height);
$(this).find('div').show();
}
).mouseout(
function(e) {
$(this).find('div').hide();
}
).click(
function() {
if($(this).is('.ad-next')) {
context.nextImage();
context.slideshow.stop();
} else {
context.prevImage();
context.slideshow.stop();
};
}
).find('div').css('opacity', 0.7);
},
initBackAndForward: function() {
var context = this;
this.scroll_forward = $('<div class="ad-forward"></div>');
this.scroll_back = $('<div class="ad-back"></div>');
this.nav.append(this.scroll_forward);
this.nav.prepend(this.scroll_back);
var has_scrolled = 0;
var thumbs_scroll_interval = false;
$(this.scroll_back).add(this.scroll_forward).click(
function() {
// We don't want to jump the whole width, since an image
// might be cut at the edge
var width = context.nav_display_width - 50;
if(context.settings.scroll_jump > 0) {
var width = context.settings.scroll_jump;
};
if($(this).is('.ad-forward')) {
var left = context.thumbs_wrapper.scrollLeft() + width;
} else {
var left = context.thumbs_wrapper.scrollLeft() - width;
};
if(context.settings.slideshow.stop_on_scroll) {
context.slideshow.stop();
};
context.thumbs_wrapper.animate({scrollLeft: left +'px'});
return false;
}
).css('opacity', 0.6).hover(
function() {
var direction = 'left';
if($(this).is('.ad-forward')) {
direction = 'right';
};
thumbs_scroll_interval = setInterval(
function() {
has_scrolled++;
// Don't want to stop the slideshow just because we scrolled a pixel or two
if(has_scrolled > 30 && context.settings.slideshow.stop_on_scroll) {
context.slideshow.stop();
};
var left = context.thumbs_wrapper.scrollLeft() + 1;
if(direction == 'left') {
left = context.thumbs_wrapper.scrollLeft() - 1;
};
context.thumbs_wrapper.scrollLeft(left);
},
10
);
$(this).css('opacity', 1);
},
function() {
has_scrolled = 0;
clearInterval(thumbs_scroll_interval);
$(this).css('opacity', 0.6);
}
);
},
_afterShow: function() {
this.gallery_info.html((this.current_index + 1) +' / '+ this.images.length);
if(!this.settings.cycle) {
// Needed for IE
this.prev_link.show().css('height', this.image_wrapper_height);
this.next_link.show().css('height', this.image_wrapper_height);
if(this.current_index == (this.images.length - 1)) {
this.next_link.hide();
};
if(this.current_index == 0) {
this.prev_link.hide();
};
};
this.fireCallback(this.settings.callbacks.afterImageVisible);
},
/**
* Checks if the image is small enough to fit inside the container
* If it's not, shrink it proportionally
*/
_getContainedImageSize: function(image_width, image_height) {
if(image_height > this.image_wrapper_height) {
var ratio = image_width / image_height;
image_height = this.image_wrapper_height;
image_width = this.image_wrapper_height * ratio;
};
if(image_width > this.image_wrapper_width) {
var ratio = image_height / image_width;
image_width = this.image_wrapper_width;
image_height = this.image_wrapper_width * ratio;
};
return {width: image_width, height: image_height};
},
/**
* If the image dimensions are smaller than the wrapper, we position
* it in the middle anyway
*/
_centerImage: function(img_container, image_width, image_height) {
img_container.css('top', '0px');
if(image_height < this.image_wrapper_height) {
var dif = this.image_wrapper_height - image_height;
img_container.css('top', (dif / 2) +'px');
};
img_container.css('left', '0px');
if(image_width < this.image_wrapper_width) {
var dif = this.image_wrapper_width - image_width;
img_container.css('left', (dif / 2) +'px');
};
},
_getDescription: function(image) {
var desc = false;
if(image.desc.length || image.title.length) {
var title = '';
if(image.title.length) {
title = '<strong class="ad-description-title">'+ image.title +'</strong>';
};
var desc = '';
if(image.desc.length) {
desc = '<span>'+ image.desc +'</span>';
};
desc = $('<p class="ad-image-description">'+ title + desc +'</p>');
};
return desc;
},
/**
* @param function callback Gets fired when the image has loaded, is displaying
* and it's animation has finished
*/
showImage: function(index, callback) {
if(this.images[index] && !this.in_transition) {
var context = this;
var image = this.images[index];
this.in_transition = true;
if(!image.preloaded) {
this.loading(true);
this.preloadImage(index, function() {
context.loading(false);
context._showWhenLoaded(index, callback);
});
} else {
this._showWhenLoaded(index, callback);
};
};
},
/**
* @param function callback Gets fired when the image has loaded, is displaying
* and it's animation has finished
*/
_showWhenLoaded: function(index, callback) {
if(this.images[index]) {
var context = this;
var image = this.images[index];
var img_container = $(document.createElement('div')).addClass('ad-image');
var img = $(new Image()).attr('src', image.image);
if(image.link) {
var link = $('<a href="'+ image.link +'" target="_blank"></a>');
link.append(img);
img_container.append(link);
} else {
img_container.append(img);
}
this.image_wrapper.prepend(img_container);
var size = this._getContainedImageSize(image.size.width, image.size.height);
img.attr('width', size.width);
img.attr('height', size.height);
img_container.css({width: size.width +'px', height: size.height +'px'});
this._centerImage(img_container, size.width, size.height);
var desc = this._getDescription(image, img_container);
if(desc) {
if(!this.settings.description_wrapper) {
img_container.append(desc);
var width = size.width - parseInt(desc.css('padding-left'), 10) - parseInt(desc.css('padding-right'), 10);
desc.css('width', width +'px');
} else {
this.settings.description_wrapper.append(desc);
}
};
this.highLightThumb(this.nav.find('.ad-thumb'+ index));
var direction = 'right';
if(this.current_index < index) {
direction = 'left';
};
this.fireCallback(this.settings.callbacks.beforeImageVisible);
if(this.current_image || this.settings.animate_first_image) {
var animation_speed = this.settings.animation_speed;
var easing = 'swing';
var animation = this.animations[this.settings.effect].call(this, img_container, direction, desc);
if(typeof animation.speed != 'undefined') {
animation_speed = animation.speed;
};
if(typeof animation.easing != 'undefined') {
easing = animation.easing;
};
if(this.current_image) {
var old_image = this.current_image;
var old_description = this.current_description;
old_image.animate(animation.old_image, animation_speed, easing,
function() {
old_image.remove();
if(old_description) old_description.remove();
}
);
};
img_container.animate(animation.new_image, animation_speed, easing,
function() {
context.current_index = index;
context.current_image = img_container;
context.current_description = desc;
context.in_transition = false;
context._afterShow();
context.fireCallback(callback);
}
);
} else {
this.current_index = index;
this.current_image = img_container;
context.current_description = desc;
this.in_transition = false;
context._afterShow();
this.fireCallback(callback);
};
};
},
nextIndex: function() {
if(this.current_index == (this.images.length - 1)) {
if(!this.settings.cycle) {
return false;
};
var next = 0;
} else {
var next = this.current_index + 1;
};
return next;
},
nextImage: function(callback) {
var next = this.nextIndex();
if(next === false) return false;
this.preloadImage(next + 1);
this.showImage(next, callback);
return true;
},
prevIndex: function() {
if(this.current_index == 0) {
if(!this.settings.cycle) {
return false;
};
var prev = this.images.length - 1;
} else {
var prev = this.current_index - 1;
};
return prev;
},
prevImage: function(callback) {
var prev = this.prevIndex();
if(prev === false) return false;
this.preloadImage(prev - 1);
this.showImage(prev, callback);
return true;
},
preloadAll: function() {
var context = this;
var i = 0;
function preloadNext() {
if(i < context.images.length) {
i++;
context.preloadImage(i, preloadNext);
};
};
context.preloadImage(i, preloadNext);
},
preloadImage: function(index, callback) {
if(this.images[index]) {
var image = this.images[index];
if(!this.images[index].preloaded) {
var img = $(new Image());
img.attr('src', image.image);
if(!this.isImageLoaded(img[0])) {
this.preloads.append(img);
var context = this;
img.load(
function() {
image.preloaded = true;
image.size = { width: this.width, height: this.height };
context.fireCallback(callback);
}
).error(
function() {
image.error = true;
image.preloaded = false;
image.size = false;
}
);
} else {
image.preloaded = true;
image.size = { width: img[0].width, height: img[0].height };
this.fireCallback(callback);
};
} else {
this.fireCallback(callback);
};
};
},
isImageLoaded: function(img) {
if(typeof img.complete != 'undefined' && !img.complete) {
return false;
};
if(typeof img.naturalWidth != 'undefined' && img.naturalWidth == 0) {
return false;
};
return true;
},
highLightThumb: function(thumb) {
this.thumbs_wrapper.find('.ad-active').removeClass('ad-active');
thumb.addClass('ad-active');
if(this.settings.thumb_opacity < 1) {
this.thumbs_wrapper.find('a:not(.ad-active) img').fadeTo(300, this.settings.thumb_opacity);
thumb.find('img').fadeTo(300, 1);
};
var left = thumb[0].parentNode.offsetLeft;
left -= (this.nav_display_width / 2) - (thumb[0].offsetWidth / 2);
this.thumbs_wrapper.animate({scrollLeft: left +'px'});
},
fireCallback: function(fn) {
if($.isFunction(fn)) {
fn.call(this);
};
}
};
function AdGallerySlideshow(nextimage_callback, settings) {
this.init(nextimage_callback, settings);
};
AdGallerySlideshow.prototype = {
start_link: false,
stop_link: false,
countdown: false,
controls: false,
settings: false,
nextimage_callback: false,
enabled: false,
running: false,
countdown_interval: false,
init: function(nextimage_callback, settings) {
var context = this;
this.nextimage_callback = nextimage_callback;
this.settings = settings;
},
create: function() {
this.start_link = $('<span class="ad-slideshow-start">'+ this.settings.start_label +'</span>');
this.stop_link = $('<span class="ad-slideshow-stop">'+ this.settings.stop_label +'</span>');
this.countdown = $('<span class="ad-slideshow-countdown"></span>');
this.controls = $('<div class="ad-slideshow-controls"></div>');
this.controls.append(this.start_link).append(this.stop_link).append(this.countdown);
this.countdown.hide();
var context = this;
this.start_link.click(
function() {
context.start();
}
);
this.stop_link.click(
function() {
context.stop();
}
);
$(document).keydown(
function(e) {
if(e.keyCode == 83) {
// 's'
if(context.running) {
context.stop();
} else {
context.start();
};
};
}
);
return this.controls;
},
disable: function() {
this.enabled = false;
this.stop();
this.controls.hide();
},
enable: function() {
this.enabled = true;
this.controls.show();
},
toggle: function() {
if(this.enabled) {
this.disable();
} else {
this.enable();
};
},
start: function() {
if(this.running || !this.enabled) return false;
var context = this;
this.running = true;
this.controls.addClass('ad-slideshow-running');
this._next();
this.fireCallback(this.settings.onStart);
return true;
},
stop: function() {
if(!this.running) return false;
this.running = false;
this.countdown.hide();
this.controls.removeClass('ad-slideshow-running');
clearInterval(this.countdown_interval);
this.fireCallback(this.settings.onStop);
return true;
},
_next: function() {
var context = this;
var pre = this.settings.countdown_prefix;
var su = this.settings.countdown_sufix;
clearInterval(context.countdown_interval);
this.countdown.show().html(pre + (this.settings.speed / 1000) + su);
var slide_timer = 0;
this.countdown_interval = setInterval(
function() {
slide_timer += 1000;
if(slide_timer >= context.settings.speed) {
var whenNextIsShown = function() {
// A check so the user hasn't stoped the slideshow during the
// animation
if(context.running) {
context._next();
};
slide_timer = 0;
};
if(!context.nextimage_callback(whenNextIsShown)) {
context.stop();
};
slide_timer = 0;
};
var sec = parseInt(context.countdown.text().replace(/[^0-9]/g, ''), 10);
sec--;
if(sec > 0) {
context.countdown.html(pre + sec + su);
};
},
1000
);
},
fireCallback: function(fn) {
if($.isFunction(fn)) {
fn.call(this);
};
}
};
})(jQuery); | JavaScript |
/*
* jQuery Nivo Slider v3.1
* http://nivo.dev7studios.com
*
* Copyright 2012, Dev7studios
* Free to use and abuse under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*/
(function($) {
var NivoSlider = function(element, options){
// Defaults are below
var settings = $.extend({}, $.fn.nivoSlider.defaults, options);
// Useful variables. Play carefully.
var vars = {
currentSlide: 0,
currentImage: '',
totalSlides: 0,
running: false,
paused: false,
stop: false,
controlNavEl: false
};
// Get this slider
var slider = $(element);
slider.data('nivo:vars', vars).addClass('nivoSlider');
// Find our slider children
var kids = slider.children();
kids.each(function() {
var child = $(this);
var link = '';
if(!child.is('img')){
if(child.is('a')){
child.addClass('nivo-imageLink');
link = child;
}
child = child.find('img:first');
}
// Get img width & height
var childWidth = (childWidth === 0) ? child.attr('width') : child.width(),
childHeight = (childHeight === 0) ? child.attr('height') : child.height();
if(link !== ''){
link.css('display','none');
}
child.css('display','none');
vars.totalSlides++;
});
// If randomStart
if(settings.randomStart){
settings.startSlide = Math.floor(Math.random() * vars.totalSlides);
}
// Set startSlide
if(settings.startSlide > 0){
if(settings.startSlide >= vars.totalSlides) { settings.startSlide = vars.totalSlides - 1; }
vars.currentSlide = settings.startSlide;
}
// Get initial image
if($(kids[vars.currentSlide]).is('img')){
vars.currentImage = $(kids[vars.currentSlide]);
} else {
vars.currentImage = $(kids[vars.currentSlide]).find('img:first');
}
// Show initial link
if($(kids[vars.currentSlide]).is('a')){
$(kids[vars.currentSlide]).css('display','block');
}
// Set first background
var sliderImg = $('<img class="nivo-main-image" src="#" />');
sliderImg.attr('src', vars.currentImage.attr('src')).show();
slider.append(sliderImg);
// Detect Window Resize
$(window).resize(function() {
slider.children('img').width(slider.width());
sliderImg.attr('src', vars.currentImage.attr('src'));
sliderImg.stop().height('auto');
$('.nivo-slice').remove();
$('.nivo-box').remove();
});
//Create caption
slider.append($('<div class="nivo-caption"></div>'));
// Process caption function
var processCaption = function(settings){
var nivoCaption = $('.nivo-caption', slider);
if(vars.currentImage.attr('title') != '' && vars.currentImage.attr('title') != undefined){
var title = vars.currentImage.attr('title');
if(title.substr(0,1) == '#') title = $(title).html();
if(nivoCaption.css('display') == 'block'){
setTimeout(function(){
nivoCaption.html(title);
}, settings.animSpeed);
} else {
nivoCaption.html(title);
nivoCaption.stop().fadeIn(settings.animSpeed);
}
} else {
nivoCaption.stop().fadeOut(settings.animSpeed);
}
}
//Process initial caption
processCaption(settings);
// In the words of Super Mario "let's a go!"
var timer = 0;
if(!settings.manualAdvance && kids.length > 1){
timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime);
}
// Add Direction nav
if(settings.directionNav){
slider.append('<div class="nivo-directionNav"><a class="nivo-prevNav">'+ settings.prevText +'</a><a class="nivo-nextNav">'+ settings.nextText +'</a></div>');
$('a.nivo-prevNav', slider).live('click', function(){
if(vars.running) { return false; }
clearInterval(timer);
timer = '';
vars.currentSlide -= 2;
nivoRun(slider, kids, settings, 'prev');
});
$('a.nivo-nextNav', slider).live('click', function(){
if(vars.running) { return false; }
clearInterval(timer);
timer = '';
nivoRun(slider, kids, settings, 'next');
});
}
// Add Control nav
if(settings.controlNav){
vars.controlNavEl = $('<div class="nivo-controlNav"></div>');
slider.after(vars.controlNavEl);
for(var i = 0; i < kids.length; i++){
if(settings.controlNavThumbs){
vars.controlNavEl.addClass('nivo-thumbs-enabled');
var child = kids.eq(i);
if(!child.is('img')){
child = child.find('img:first');
}
if(child.attr('data-thumb')) vars.controlNavEl.append('<a class="nivo-control" rel="'+ i +'"><img src="'+ child.attr('data-thumb') +'" alt="" /></a>');
} else {
vars.controlNavEl.append('<a class="nivo-control" rel="'+ i +'">'+ (i + 1) +'</a>');
}
}
//Set initial active link
$('a:eq('+ vars.currentSlide +')', vars.controlNavEl).addClass('active');
$('a', vars.controlNavEl).bind('click', function(){
if(vars.running) return false;
if($(this).hasClass('active')) return false;
clearInterval(timer);
timer = '';
sliderImg.attr('src', vars.currentImage.attr('src'));
vars.currentSlide = $(this).attr('rel') - 1;
nivoRun(slider, kids, settings, 'control');
});
}
//For pauseOnHover setting
if(settings.pauseOnHover){
slider.hover(function(){
vars.paused = true;
clearInterval(timer);
timer = '';
}, function(){
vars.paused = false;
// Restart the timer
if(timer === '' && !settings.manualAdvance){
timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime);
}
});
}
// Event when Animation finishes
slider.bind('nivo:animFinished', function(){
sliderImg.attr('src', vars.currentImage.attr('src'));
vars.running = false;
// Hide child links
$(kids).each(function(){
if($(this).is('a')){
$(this).css('display','none');
}
});
// Show current link
if($(kids[vars.currentSlide]).is('a')){
$(kids[vars.currentSlide]).css('display','block');
}
// Restart the timer
if(timer === '' && !vars.paused && !settings.manualAdvance){
timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime);
}
// Trigger the afterChange callback
settings.afterChange.call(this);
});
// Add slices for slice animations
var createSlices = function(slider, settings, vars) {
if($(vars.currentImage).parent().is('a')) $(vars.currentImage).parent().css('display','block');
$('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show();
var sliceHeight = ($('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().is('a')) ? $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().height() : $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').height();
for(var i = 0; i < settings.slices; i++){
var sliceWidth = Math.round(slider.width()/settings.slices);
if(i === settings.slices-1){
slider.append(
$('<div class="nivo-slice" name="'+i+'"><img src="'+ vars.currentImage.attr('src') +'" style="position:absolute; width:'+ slider.width() +'px; height:auto; display:block !important; top:0; left:-'+ ((sliceWidth + (i * sliceWidth)) - sliceWidth) +'px;" /></div>').css({
left:(sliceWidth*i)+'px',
width:(slider.width()-(sliceWidth*i))+'px',
height:sliceHeight+'px',
opacity:'0',
overflow:'hidden'
})
);
} else {
slider.append(
$('<div class="nivo-slice" name="'+i+'"><img src="'+ vars.currentImage.attr('src') +'" style="position:absolute; width:'+ slider.width() +'px; height:auto; display:block !important; top:0; left:-'+ ((sliceWidth + (i * sliceWidth)) - sliceWidth) +'px;" /></div>').css({
left:(sliceWidth*i)+'px',
width:sliceWidth+'px',
height:sliceHeight+'px',
opacity:'0',
overflow:'hidden'
})
);
}
}
$('.nivo-slice', slider).height(sliceHeight);
sliderImg.stop().animate({
height: $(vars.currentImage).height()
}, settings.animSpeed);
};
// Add boxes for box animations
var createBoxes = function(slider, settings, vars){
if($(vars.currentImage).parent().is('a')) $(vars.currentImage).parent().css('display','block');
$('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show();
var boxWidth = Math.round(slider.width()/settings.boxCols),
boxHeight = Math.round($('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').height() / settings.boxRows);
for(var rows = 0; rows < settings.boxRows; rows++){
for(var cols = 0; cols < settings.boxCols; cols++){
if(cols === settings.boxCols-1){
slider.append(
$('<div class="nivo-box" name="'+ cols +'" rel="'+ rows +'"><img src="'+ vars.currentImage.attr('src') +'" style="position:absolute; width:'+ slider.width() +'px; height:auto; display:block; top:-'+ (boxHeight*rows) +'px; left:-'+ (boxWidth*cols) +'px;" /></div>').css({
opacity:0,
left:(boxWidth*cols)+'px',
top:(boxHeight*rows)+'px',
width:(slider.width()-(boxWidth*cols))+'px'
})
);
$('.nivo-box[name="'+ cols +'"]', slider).height($('.nivo-box[name="'+ cols +'"] img', slider).height()+'px');
} else {
slider.append(
$('<div class="nivo-box" name="'+ cols +'" rel="'+ rows +'"><img src="'+ vars.currentImage.attr('src') +'" style="position:absolute; width:'+ slider.width() +'px; height:auto; display:block; top:-'+ (boxHeight*rows) +'px; left:-'+ (boxWidth*cols) +'px;" /></div>').css({
opacity:0,
left:(boxWidth*cols)+'px',
top:(boxHeight*rows)+'px',
width:boxWidth+'px'
})
);
$('.nivo-box[name="'+ cols +'"]', slider).height($('.nivo-box[name="'+ cols +'"] img', slider).height()+'px');
}
}
}
sliderImg.stop().animate({
height: $(vars.currentImage).height()
}, settings.animSpeed);
};
// Private run method
var nivoRun = function(slider, kids, settings, nudge){
// Get our vars
var vars = slider.data('nivo:vars');
// Trigger the lastSlide callback
if(vars && (vars.currentSlide === vars.totalSlides - 1)){
settings.lastSlide.call(this);
}
// Stop
if((!vars || vars.stop) && !nudge) { return false; }
// Trigger the beforeChange callback
settings.beforeChange.call(this);
// Set current background before change
if(!nudge){
sliderImg.attr('src', vars.currentImage.attr('src'));
} else {
if(nudge === 'prev'){
sliderImg.attr('src', vars.currentImage.attr('src'));
}
if(nudge === 'next'){
sliderImg.attr('src', vars.currentImage.attr('src'));
}
}
vars.currentSlide++;
// Trigger the slideshowEnd callback
if(vars.currentSlide === vars.totalSlides){
vars.currentSlide = 0;
settings.slideshowEnd.call(this);
}
if(vars.currentSlide < 0) { vars.currentSlide = (vars.totalSlides - 1); }
// Set vars.currentImage
if($(kids[vars.currentSlide]).is('img')){
vars.currentImage = $(kids[vars.currentSlide]);
} else {
vars.currentImage = $(kids[vars.currentSlide]).find('img:first');
}
// Set active links
if(settings.controlNav){
$('a', vars.controlNavEl).removeClass('active');
$('a:eq('+ vars.currentSlide +')', vars.controlNavEl).addClass('active');
}
// Process caption
processCaption(settings);
// Remove any slices from last transition
$('.nivo-slice', slider).remove();
// Remove any boxes from last transition
$('.nivo-box', slider).remove();
var currentEffect = settings.effect,
anims = '';
// Generate random effect
if(settings.effect === 'random'){
anims = new Array('sliceDownRight','sliceDownLeft','sliceUpRight','sliceUpLeft','sliceUpDown','sliceUpDownLeft','fold','fade',
'boxRandom','boxRain','boxRainReverse','boxRainGrow','boxRainGrowReverse');
currentEffect = anims[Math.floor(Math.random()*(anims.length + 1))];
if(currentEffect === undefined) { currentEffect = 'fade'; }
}
// Run random effect from specified set (eg: effect:'fold,fade')
if(settings.effect.indexOf(',') !== -1){
anims = settings.effect.split(',');
currentEffect = anims[Math.floor(Math.random()*(anims.length))];
if(currentEffect === undefined) { currentEffect = 'fade'; }
}
// Custom transition as defined by "data-transition" attribute
if(vars.currentImage.attr('data-transition')){
currentEffect = vars.currentImage.attr('data-transition');
}
// Run effects
vars.running = true;
var timeBuff = 0,
i = 0,
slices = '',
firstSlice = '',
totalBoxes = '',
boxes = '';
if(currentEffect === 'sliceDown' || currentEffect === 'sliceDownRight' || currentEffect === 'sliceDownLeft'){
createSlices(slider, settings, vars);
timeBuff = 0;
i = 0;
slices = $('.nivo-slice', slider);
if(currentEffect === 'sliceDownLeft') { slices = $('.nivo-slice', slider)._reverse(); }
slices.each(function(){
var slice = $(this);
slice.css({ 'top': '0px' });
if(i === settings.slices-1){
setTimeout(function(){
slice.animate({opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
}, (100 + timeBuff));
} else {
setTimeout(function(){
slice.animate({opacity:'1.0' }, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 50;
i++;
});
} else if(currentEffect === 'sliceUp' || currentEffect === 'sliceUpRight' || currentEffect === 'sliceUpLeft'){
createSlices(slider, settings, vars);
timeBuff = 0;
i = 0;
slices = $('.nivo-slice', slider);
if(currentEffect === 'sliceUpLeft') { slices = $('.nivo-slice', slider)._reverse(); }
slices.each(function(){
var slice = $(this);
slice.css({ 'bottom': '0px' });
if(i === settings.slices-1){
setTimeout(function(){
slice.animate({opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
}, (100 + timeBuff));
} else {
setTimeout(function(){
slice.animate({opacity:'1.0' }, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 50;
i++;
});
} else if(currentEffect === 'sliceUpDown' || currentEffect === 'sliceUpDownRight' || currentEffect === 'sliceUpDownLeft'){
createSlices(slider, settings, vars);
timeBuff = 0;
i = 0;
var v = 0;
slices = $('.nivo-slice', slider);
if(currentEffect === 'sliceUpDownLeft') { slices = $('.nivo-slice', slider)._reverse(); }
slices.each(function(){
var slice = $(this);
if(i === 0){
slice.css('top','0px');
i++;
} else {
slice.css('bottom','0px');
i = 0;
}
if(v === settings.slices-1){
setTimeout(function(){
slice.animate({opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
}, (100 + timeBuff));
} else {
setTimeout(function(){
slice.animate({opacity:'1.0' }, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 50;
v++;
});
} else if(currentEffect === 'fold'){
createSlices(slider, settings, vars);
timeBuff = 0;
i = 0;
$('.nivo-slice', slider).each(function(){
var slice = $(this);
var origWidth = slice.width();
slice.css({ top:'0px', width:'0px' });
if(i === settings.slices-1){
setTimeout(function(){
slice.animate({ width:origWidth, opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
}, (100 + timeBuff));
} else {
setTimeout(function(){
slice.animate({ width:origWidth, opacity:'1.0' }, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 50;
i++;
});
} else if(currentEffect === 'fade'){
createSlices(slider, settings, vars);
firstSlice = $('.nivo-slice:first', slider);
firstSlice.css({
'width': slider.width() + 'px'
});
firstSlice.animate({ opacity:'1.0' }, (settings.animSpeed*2), '', function(){ slider.trigger('nivo:animFinished'); });
} else if(currentEffect === 'slideInRight'){
createSlices(slider, settings, vars);
firstSlice = $('.nivo-slice:first', slider);
firstSlice.css({
'width': '0px',
'opacity': '1'
});
firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed*2), '', function(){ slider.trigger('nivo:animFinished'); });
} else if(currentEffect === 'slideInLeft'){
createSlices(slider, settings, vars);
firstSlice = $('.nivo-slice:first', slider);
firstSlice.css({
'width': '0px',
'opacity': '1',
'left': '',
'right': '0px'
});
firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed*2), '', function(){
// Reset positioning
firstSlice.css({
'left': '0px',
'right': ''
});
slider.trigger('nivo:animFinished');
});
} else if(currentEffect === 'boxRandom'){
createBoxes(slider, settings, vars);
totalBoxes = settings.boxCols * settings.boxRows;
i = 0;
timeBuff = 0;
boxes = shuffle($('.nivo-box', slider));
boxes.each(function(){
var box = $(this);
if(i === totalBoxes-1){
setTimeout(function(){
box.animate({ opacity:'1' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
}, (100 + timeBuff));
} else {
setTimeout(function(){
box.animate({ opacity:'1' }, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 20;
i++;
});
} else if(currentEffect === 'boxRain' || currentEffect === 'boxRainReverse' || currentEffect === 'boxRainGrow' || currentEffect === 'boxRainGrowReverse'){
createBoxes(slider, settings, vars);
totalBoxes = settings.boxCols * settings.boxRows;
i = 0;
timeBuff = 0;
// Split boxes into 2D array
var rowIndex = 0;
var colIndex = 0;
var box2Darr = [];
box2Darr[rowIndex] = [];
boxes = $('.nivo-box', slider);
if(currentEffect === 'boxRainReverse' || currentEffect === 'boxRainGrowReverse'){
boxes = $('.nivo-box', slider)._reverse();
}
boxes.each(function(){
box2Darr[rowIndex][colIndex] = $(this);
colIndex++;
if(colIndex === settings.boxCols){
rowIndex++;
colIndex = 0;
box2Darr[rowIndex] = [];
}
});
// Run animation
for(var cols = 0; cols < (settings.boxCols * 2); cols++){
var prevCol = cols;
for(var rows = 0; rows < settings.boxRows; rows++){
if(prevCol >= 0 && prevCol < settings.boxCols){
/* Due to some weird JS bug with loop vars
being used in setTimeout, this is wrapped
with an anonymous function call */
(function(row, col, time, i, totalBoxes) {
var box = $(box2Darr[row][col]);
var w = box.width();
var h = box.height();
if(currentEffect === 'boxRainGrow' || currentEffect === 'boxRainGrowReverse'){
box.width(0).height(0);
}
if(i === totalBoxes-1){
setTimeout(function(){
box.animate({ opacity:'1', width:w, height:h }, settings.animSpeed/1.3, '', function(){ slider.trigger('nivo:animFinished'); });
}, (100 + time));
} else {
setTimeout(function(){
box.animate({ opacity:'1', width:w, height:h }, settings.animSpeed/1.3);
}, (100 + time));
}
})(rows, prevCol, timeBuff, i, totalBoxes);
i++;
}
prevCol--;
}
timeBuff += 100;
}
}
};
// Shuffle an array
var shuffle = function(arr){
for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i, 10), x = arr[--i], arr[i] = arr[j], arr[j] = x);
return arr;
};
// For debugging
var trace = function(msg){
if(this.console && typeof console.log !== 'undefined') { console.log(msg); }
};
// Start / Stop
this.stop = function(){
if(!$(element).data('nivo:vars').stop){
$(element).data('nivo:vars').stop = true;
trace('Stop Slider');
}
};
this.start = function(){
if($(element).data('nivo:vars').stop){
$(element).data('nivo:vars').stop = false;
trace('Start Slider');
}
};
// Trigger the afterLoad callback
settings.afterLoad.call(this);
return this;
};
$.fn.nivoSlider = function(options) {
return this.each(function(key, value){
var element = $(this);
// Return early if this element already has a plugin instance
if (element.data('nivoslider')) { return element.data('nivoslider'); }
// Pass options to plugin constructor
var nivoslider = new NivoSlider(this, options);
// Store plugin object in this element's data
element.data('nivoslider', nivoslider);
});
};
//Default settings
$.fn.nivoSlider.defaults = {
effect: 'random',
slices: 15,
boxCols: 8,
boxRows: 4,
animSpeed: 500,
pauseTime: 3000,
startSlide: 0,
directionNav: true,
controlNav: true,
controlNavThumbs: false,
pauseOnHover: true,
manualAdvance: false,
prevText: 'Prev',
nextText: 'Next',
randomStart: false,
beforeChange: function(){},
afterChange: function(){},
slideshowEnd: function(){},
lastSlide: function(){},
afterLoad: function(){}
};
$.fn._reverse = [].reverse;
})(jQuery); | JavaScript |
// Password strength meter
// This jQuery plugin is written by Firas Kassem [2007.04.05] and modified by Amin Rajaee [2009.07.26]
// Firas Kassem phiras.wordpress.com || phiras at gmail {dot} com
// Amin Rajaee rajaee at gmail (dot) com
// for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/
var shortPass = 'Mật khẩu phải hơn 4 ký tự';
var badPass = 'Mật khẩu yếu, nên dùng cả chữ và số';
var goodPass = 'Mật khẩu bình thường, nên dùng thêm ký tự đặc biệt';
var strongPass = 'Mật khẩu đạt yêu cầu';
var sameAsUsername = 'Mật khẩu không nên giống với với tên đăng nhập.';
function passwordStrength(password,username)
{
score = 0;
//password < 4
if (password.length < 4 ) { return shortPass; }
//password == username
if (password.toLowerCase() == username.toLowerCase()) return sameAsUsername;
//password length
score += password.length * 4;
score += ( checkRepetition(1,password).length - password.length ) * 1;
score += ( checkRepetition(2,password).length - password.length ) * 1;
score += ( checkRepetition(3,password).length - password.length ) * 1;
score += ( checkRepetition(4,password).length - password.length ) * 1;
//password has 3 numbers
if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) score += 5;
//password has 2 sybols
if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) score += 5;
//password has Upper and Lower chars
if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) score += 10;
//password has number and chars
if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) score += 15;
//
//password has number and symbol
if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) score += 15;
//password has char and symbol
if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) score += 15;
//password is just a nubers or chars
if (password.match(/^\w+$/) || password.match(/^\d+$/) ) score -= 10;
//verifing 0 < score < 100
if ( score < 0 ) score = 0;
if ( score > 100 ) score = 100;
if (score < 34 ) return badPass;
if (score < 68 ) return goodPass;
return strongPass;
}
function passwordStrengthPercent(password,username)
{
score = 0;
//password < 4
if (password.length < 4 ) { return 0; }
//password == username
if (password.toLowerCase()==username.toLowerCase()) return 0;
//password length
score += password.length * 4;
score += ( checkRepetition(1,password).length - password.length ) * 1;
score += ( checkRepetition(2,password).length - password.length ) * 1;
score += ( checkRepetition(3,password).length - password.length ) * 1;
score += ( checkRepetition(4,password).length - password.length ) * 1;
//password has 3 numbers
if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) score += 5;
//password has 2 sybols
if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) score += 5;
//password has Upper and Lower chars
if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) score += 10;
//password has number and chars
if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) score += 15;
//
//password has number and symbol
if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) score += 15;
//password has char and symbol
if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) score += 15;
//password is just a nubers or chars
if (password.match(/^\w+$/) || password.match(/^\d+$/) ) score -= 10;
if (score > 100) return 100;
return (score);
}
// checkRepetition(1,'aaaaaaabcbc') = 'abcbc'
// checkRepetition(2,'aaaaaaabcbc') = 'aabc'
// checkRepetition(2,'aaaaaaabcdbcd') = 'aabcd'
function checkRepetition(pLen,str) {
res = "";
for ( var i=0; i<str.length ; i++ ) {
repeated=true;
for (var j=0;j < pLen && (j+i+pLen) < str.length;j++)
repeated=repeated && (str.charAt(j+i)==str.charAt(j+i+pLen));
if (j<pLen) repeated=false;
if (repeated) {
i+=pLen-1;
repeated=false;
}
else {
res+=str.charAt(i);
}
}
return res;
} | JavaScript |
/* ==================================================
*
* @Method: echeck
* @Describe: check format of email
* =================================================== */
function echeck(d) {
return /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(d);
}
/* ==================================================
*
* @Method: load_page
* @Describe: load page with full url or apart url of website
* =================================================== */
function load_page(url) {
if(url == ""){
window.location.reload();
}else {
window.location.assign(url);
}
}
/* ==================================================
*
* @Method: remove_utf8
* @Describe: replace utf-8 character to alphabe character
* =================================================== */
function remove_utf8(str) {
var from = "àáạảãâầấậẩẫăằắặẳẵèéẹẻẽêềếệểễìíịỉĩòóọỏõôồốộổỗơờớợởỡùúụủũưừứựửữỳýỵỷỹđ";
var to = "aaaaaaaaaaaaaaaaaeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyd";
for (var i = 0, l = from.length; i < l; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
return str;
}
/* ==================================================
*
* @Method: numeric_press
* @Describe: only numberic is allowed
* =================================================== */
function numeric_press(e)
{
var keypressed = null;
if (window.event)
{
keypressed = window.event.keyCode; //IE
}
else
{
keypressed = e.which; //NON-IE, Standard
}
if (keypressed < 48 || keypressed > 57)
{
if (keypressed == 8 || keypressed == 127)
{
return;
}
return false;
}
}
/* ==================================================
*
* @Method: keypress_alphanumberic
* @Describe: only alphabet and numberic is allowed, not special characters
* =================================================== */
function keypress_alphanumberic(event) {
//prevent user press "'" character
if (event.keyCode == 222)
return false;
//Alow user press tab in firefox
if (event.keyCode == 9)
return true;
//Alow user press tab in firefox
if (event.keyCode == 13)
return true;
var k;
document.all ? k = event.keyCode : k = event.which;
return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
}
/* ==================================================
*
* @Method: format_currency
* @Describe: return string with currency format when user typing number
* =================================================== */
function format_currency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "";
num = Math.abs(num);
num = Math.floor(num*100+0.50000000001);
num = Math.floor(num/100).toString();
if(num==0)
num = "";
for (var i = 0; i < Math.floor(( num.length -(1+i))/3); i++){
num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
}
return (num);
}
/**
* Set all status of child-checkboxes as general checkbox
*
* @author TuanNguyen
* @version Created 2015-04-05
* @param HTMLElement element
* @param string lbl_validationId
* @return void
*/
function validation_empty( element, lbl_validationId)
{
if( $.trim(element.value) == '' ) {
$('#'+lbl_validationId).fadeIn('slow', 'linear');
} else {
$('#'+lbl_validationId).fadeOut();
}
}//End validation_empty
/**
* Set all status of child-checkboxes as general checkbox
*
* @author TuanNguyen
* @version Created 2015-04-05
* @param HTMLElement generalCheckbox
* @param string childCheckboxName
* @return void
*/
function setGeneralStatusOfCheckboxes( generalCheckbox, childCheckboxName )
{
//Init
var b_generalStatus = generalCheckbox.checked;
//loop all child-checkboxes to set status
$("input[name='" + childCheckboxName + "']").each( function() {
$(this).attr('checked', b_generalStatus);
});
} | JavaScript |
/**
* A Javascript object to encode and/or decode html characters using HTML or Numeric entities that handles double or partial encoding
* Author: R Reid
* source: http://www.strictly-software.com/htmlencode
* Licences: GPL, The MIT License (MIT)
* Copyright: (c) 2011 Robert Reid - Strictly-Software.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Revision:
* 2011-07-14, Jacques-Yves Bleau:
* - fixed conversion error with capitalized accentuated characters
* + converted arr1 and arr2 to object property to remove redundancy
*
* Revision:
* 2011-11-10, Ce-Yi Hio:
* - fixed conversion error with a number of capitalized entity characters
*
* Revision:
* 2011-11-10, Rob Reid:
* - changed array format
*/
/**
* //example of using the html encode object
* // set the type of encoding to numerical entities e.g & instead of &
* Encoder.EncodeType = "numerical";
*
* // or to set it to encode to html entities e.g & instead of &
* Encoder.EncodeType = "entity";
*
* // HTML encode text from an input element
* // This will prevent double encoding.
* var encoded = Encoder.htmlEncode(document.getElementById('input'));
*
* // To encode but to allow double encoding which means any existing entities such as
* // & will be converted to &amp;
* var dblEncoded = Encoder.htmlEncode(document.getElementById('input'),true);
*
* // Decode the now encoded text
* var decoded = Encoder.htmlDecode(encoded);
*
* // Check whether the text still contains HTML/Numerical entities
* var containsEncoded = Encoder.hasEncoded(decoded);
*/
Encoder = {
// When encoding do we convert characters into html or numerical entities
EncodeType : "entity", // entity OR numerical
isEmpty : function(val){
if(val){
return ((val===null) || val.length==0 || /^\s+$/.test(val));
}else{
return true;
}
},
// arrays for conversion from HTML Entities to Numerical values
arr1: [' ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','­','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','"','&','<','>','Œ','œ','Š','š','Ÿ','ˆ','˜',' ',' ',' ','‌','‍','‎','‏','–','—','‘','’','‚','“','”','„','†','‡','‰','‹','›','€','ƒ','Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','ς','σ','τ','υ','φ','χ','ψ','ω','ϑ','ϒ','ϖ','•','…','′','″','‾','⁄','℘','ℑ','ℜ','™','ℵ','←','↑','→','↓','↔','↵','⇐','⇑','⇒','⇓','⇔','∀','∂','∃','∅','∇','∈','∉','∋','∏','∑','−','∗','√','∝','∞','∠','∧','∨','∩','∪','∫','∴','∼','≅','≈','≠','≡','≤','≥','⊂','⊃','⊄','⊆','⊇','⊕','⊗','⊥','⋅','⌈','⌉','⌊','⌋','⟨','⟩','◊','♠','♣','♥','♦'],
arr2: [' ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','­','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','"','&','<','>','Œ','œ','Š','š','Ÿ','ˆ','˜',' ',' ',' ','‌','‍','‎','‏','–','—','‘','’','‚','“','”','„','†','‡','‰','‹','›','€','ƒ','Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','ς','σ','τ','υ','φ','χ','ψ','ω','ϑ','ϒ','ϖ','•','…','′','″','‾','⁄','℘','ℑ','ℜ','™','ℵ','←','↑','→','↓','↔','↵','⇐','⇑','⇒','⇓','⇔','∀','∂','∃','∅','∇','∈','∉','∋','∏','∑','−','∗','√','∝','∞','∠','∧','∨','∩','∪','∫','∴','∼','≅','≈','≠','≡','≤','≥','⊂','⊃','⊄','⊆','⊇','⊕','⊗','⊥','⋅','⌈','⌉','⌊','⌋','〈','〉','◊','♠','♣','♥','♦'],
// Convert HTML entities into numerical entities
HTML2Numerical : function(s){
return this.swapArrayVals(s,this.arr1,this.arr2);
},
// Convert Numerical entities into HTML entities
NumericalToHTML : function(s){
return this.swapArrayVals(s,this.arr2,this.arr1);
},
// Numerically encodes all unicode characters
numEncode : function(s){
if(this.isEmpty(s)) return "";
var e = "";
for (var i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (c < " " || c > "~")
{
c = "&#" + c.charCodeAt() + ";";
}
e += c;
}
return e;
},
// HTML Decode numerical and HTML entities back to original values
htmlDecode : function(s){
var c,m,d = s;
if(this.isEmpty(d)) return "";
// convert HTML entites back to numerical entites first
d = this.HTML2Numerical(d);
// look for numerical entities "
arr=d.match(/&#[0-9]{1,5};/g);
// if no matches found in string then skip
if(arr!=null){
for(var x=0;x<arr.length;x++){
m = arr[x];
c = m.substring(2,m.length-1); //get numeric part which is refernce to unicode character
// if its a valid number we can decode
if(c >= -32768 && c <= 65535){
// decode every single match within string
d = d.replace(m, String.fromCharCode(c));
}else{
d = d.replace(m, ""); //invalid so replace with nada
}
}
}
return d;
},
// encode an input string into either numerical or HTML entities
htmlEncode : function(s,dbl){
if(this.isEmpty(s)) return "";
// do we allow double encoding? E.g will & be turned into &amp;
dbl = dbl || false; //default to prevent double encoding
// if allowing double encoding we do ampersands first
if(dbl){
if(this.EncodeType=="numerical"){
s = s.replace(/&/g, "&");
}else{
s = s.replace(/&/g, "&");
}
}
// convert the xss chars to numerical entities ' " < >
s = this.XSSEncode(s,false);
if(this.EncodeType=="numerical" || !dbl){
// Now call function that will convert any HTML entities to numerical codes
s = this.HTML2Numerical(s);
}
// Now encode all chars above 127 e.g unicode
s = this.numEncode(s);
// now we know anything that needs to be encoded has been converted to numerical entities we
// can encode any ampersands & that are not part of encoded entities
// to handle the fact that I need to do a negative check and handle multiple ampersands &&&
// I am going to use a placeholder
// if we don't want double encoded entities we ignore the & in existing entities
if(!dbl){
s = s.replace(/&#/g,"##AMPHASH##");
if(this.EncodeType=="numerical"){
s = s.replace(/&/g, "&");
}else{
s = s.replace(/&/g, "&");
}
s = s.replace(/##AMPHASH##/g,"&#");
}
// replace any malformed entities
s = s.replace(/&#\d*([^\d;]|$)/g, "$1");
if(!dbl){
// safety check to correct any double encoded &
s = this.correctEncoding(s);
}
// now do we need to convert our numerical encoded string into entities
if(this.EncodeType=="entity"){
s = this.NumericalToHTML(s);
}
return s;
},
// Encodes the basic 4 characters used to malform HTML in XSS hacks
XSSEncode : function(s,en){
if(!this.isEmpty(s)){
en = en || true;
// do we convert to numerical or html entity?
if(en){
s = s.replace(/\'/g,"'"); //no HTML equivalent as &apos is not cross browser supported
s = s.replace(/\"/g,""");
s = s.replace(/</g,"<");
s = s.replace(/>/g,">");
}else{
s = s.replace(/\'/g,"'"); //no HTML equivalent as &apos is not cross browser supported
s = s.replace(/\"/g,""");
s = s.replace(/</g,"<");
s = s.replace(/>/g,">");
}
return s;
}else{
return "";
}
},
// returns true if a string contains html or numerical encoded entities
hasEncoded : function(s){
if(/&#[0-9]{1,5};/g.test(s)){
return true;
}else if(/&[A-Z]{2,6};/gi.test(s)){
return true;
}else{
return false;
}
},
// will remove any unicode characters
stripUnicode : function(s){
return s.replace(/[^\x20-\x7E]/g,"");
},
// corrects any double encoded & entities e.g &amp;
correctEncoding : function(s){
return s.replace(/(&)(amp;)+/,"$1");
},
// Function to loop through an array swaping each item with the value from another array e.g swap HTML entities with Numericals
swapArrayVals : function(s,arr1,arr2){
if(this.isEmpty(s)) return "";
var re;
if(arr1 && arr2){
//ShowDebug("in swapArrayVals arr1.length = " + arr1.length + " arr2.length = " + arr2.length)
// array lengths must match
if(arr1.length == arr2.length){
for(var x=0,i=arr1.length;x<i;x++){
re = new RegExp(arr1[x], 'g');
s = s.replace(re,arr2[x]); //swap arr1 item with matching item from arr2
}
}
}
return s;
},
inArray : function( item, arr ) {
for ( var i = 0, x = arr.length; i < x; i++ ){
if ( arr[i] === item ){
return i;
}
}
return -1;
}
}; | JavaScript |
/**
* @license Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* This file was added automatically by CKEditor builder.
* You may re-use it at any time at http://ckeditor.com/builder to build CKEditor again.
*
* NOTE:
* This file is not used by CKEditor, you may remove it.
* Changing this file will not change your CKEditor configuration.
*/
var CKBUILDER_CONFIG = {
skin: 'moono',
preset: 'full',
ignore: [
'dev',
'.gitignore',
'.gitattributes',
'README.md',
'.mailmap'
],
plugins : {
'about' : 1,
'a11yhelp' : 1,
'dialogadvtab' : 1,
'basicstyles' : 1,
'bidi' : 1,
'blockquote' : 1,
'clipboard' : 1,
'colorbutton' : 1,
'colordialog' : 1,
'templates' : 1,
'contextmenu' : 1,
'div' : 1,
'resize' : 1,
'toolbar' : 1,
'elementspath' : 1,
'enterkey' : 1,
'entities' : 1,
'filebrowser' : 1,
'find' : 1,
'flash' : 1,
'floatingspace' : 1,
'font' : 1,
'forms' : 1,
'format' : 1,
'htmlwriter' : 1,
'horizontalrule' : 1,
'iframe' : 1,
'wysiwygarea' : 1,
'image' : 1,
'indent' : 1,
'smiley' : 1,
'justify' : 1,
'link' : 1,
'list' : 1,
'liststyle' : 1,
'magicline' : 1,
'maximize' : 1,
'newpage' : 1,
'pagebreak' : 1,
'pastetext' : 1,
'pastefromword' : 1,
'preview' : 1,
'print' : 1,
'removeformat' : 1,
'save' : 1,
'selectall' : 1,
'showblocks' : 1,
'showborders' : 1,
'sourcearea' : 1,
'specialchar' : 1,
'stylescombo' : 1,
'tab' : 1,
'table' : 1,
'tabletools' : 1,
'undo' : 1,
'dialog' : 1,
'dialogui' : 1,
'panelbutton' : 1,
'button' : 1,
'floatpanel' : 1,
'panel' : 1,
'menu' : 1,
'popup' : 1,
'fakeobjects' : 1,
'richcombo' : 1,
'listblock' : 1
},
languages : {
'af' : 1,
'ar' : 1,
'eu' : 1,
'bn' : 1,
'bs' : 1,
'bg' : 1,
'ca' : 1,
'zh-cn' : 1,
'zh' : 1,
'hr' : 1,
'cs' : 1,
'da' : 1,
'nl' : 1,
'en' : 1,
'en-au' : 1,
'en-ca' : 1,
'en-gb' : 1,
'eo' : 1,
'et' : 1,
'fo' : 1,
'fi' : 1,
'fr' : 1,
'fr-ca' : 1,
'gl' : 1,
'ka' : 1,
'de' : 1,
'el' : 1,
'gu' : 1,
'he' : 1,
'hi' : 1,
'hu' : 1,
'is' : 1,
'it' : 1,
'ja' : 1,
'km' : 1,
'ko' : 1,
'ku' : 1,
'lv' : 1,
'lt' : 1,
'mk' : 1,
'ms' : 1,
'mn' : 1,
'no' : 1,
'nb' : 1,
'fa' : 1,
'pl' : 1,
'pt-br' : 1,
'pt' : 1,
'ro' : 1,
'ru' : 1,
'sr' : 1,
'sr-latn' : 1,
'sk' : 1,
'sl' : 1,
'es' : 1,
'sv' : 1,
'th' : 1,
'tr' : 1,
'ug' : 1,
'uk' : 1,
'vi' : 1,
'cy' : 1,
}
}; | JavaScript |
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
| JavaScript |
/**
* @license Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
};
| JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.