Archived
(Experimental) Replace htmlarea with XINHA. Thanks to abdussamad!
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
|
||||
/* This file is part of version 0.95 released Mon, 12 May 2008 17:33:15 +0200 */
|
||||
/* The URL of the most recent version of this file is http://svn.xinha.webfactional.com/trunk/modules/Dialogs/dialog.js */
|
||||
function Dialog(_1,_2,_3){
|
||||
if(typeof _3=="undefined"){
|
||||
_3=window;
|
||||
}
|
||||
if(typeof window.showModalDialog=="function"&&!Xinha.is_webkit){
|
||||
Dialog._return=function(_4){
|
||||
if(typeof _2=="function"){
|
||||
_2(_4);
|
||||
}
|
||||
};
|
||||
var r=window.showModalDialog(_1,_3,"dialogheight=300;dialogwidth=400;resizable=yes");
|
||||
}else{
|
||||
Dialog._geckoOpenModal(_1,_2,_3);
|
||||
}
|
||||
}
|
||||
Dialog._parentEvent=function(ev){
|
||||
setTimeout(function(){
|
||||
if(Dialog._modal&&!Dialog._modal.closed){
|
||||
Dialog._modal.focus();
|
||||
}
|
||||
},50);
|
||||
try{
|
||||
if(Dialog._modal&&!Dialog._modal.closed){
|
||||
Xinha._stopEvent(ev);
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
}
|
||||
};
|
||||
Dialog._return=null;
|
||||
Dialog._modal=null;
|
||||
Dialog._arguments=null;
|
||||
Dialog._selection=null;
|
||||
Dialog._geckoOpenModal=function(_7,_8,_9){
|
||||
var _a=window.open(_7,"hadialog","toolbar=no,menubar=no,personalbar=no,width=10,height=10,"+"scrollbars=no,resizable=yes,modal=yes,dependable=yes");
|
||||
Dialog._modal=_a;
|
||||
Dialog._arguments=_9;
|
||||
function capwin(w){
|
||||
Xinha._addEvent(w,"click",Dialog._parentEvent);
|
||||
Xinha._addEvent(w,"mousedown",Dialog._parentEvent);
|
||||
Xinha._addEvent(w,"focus",Dialog._parentEvent);
|
||||
}
|
||||
function relwin(w){
|
||||
Xinha._removeEvent(w,"click",Dialog._parentEvent);
|
||||
Xinha._removeEvent(w,"mousedown",Dialog._parentEvent);
|
||||
Xinha._removeEvent(w,"focus",Dialog._parentEvent);
|
||||
}
|
||||
capwin(window);
|
||||
for(var i=0;i<window.frames.length;i++){
|
||||
try{
|
||||
capwin(window.frames[i]);
|
||||
}
|
||||
catch(e){
|
||||
}
|
||||
}
|
||||
Dialog._return=function(_e){
|
||||
if(_e&&_8){
|
||||
_8(_e);
|
||||
}
|
||||
relwin(window);
|
||||
for(var i=0;i<window.frames.length;i++){
|
||||
try{
|
||||
relwin(window.frames[i]);
|
||||
}
|
||||
catch(e){
|
||||
}
|
||||
}
|
||||
Dialog._modal=null;
|
||||
};
|
||||
Dialog._modal.focus();
|
||||
};
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
|
||||
/* This file is part of version 0.95 released Mon, 12 May 2008 17:33:15 +0200 */
|
||||
/* The URL of the most recent version of this file is http://svn.xinha.webfactional.com/trunk/modules/Dialogs/inline-dialog.js */
|
||||
Xinha.Dialog=function(_1,_2,_3){
|
||||
this.id={};
|
||||
this.r_id={};
|
||||
this.editor=_1;
|
||||
this.document=document;
|
||||
this.rootElem=document.createElement("div");
|
||||
this.rootElem.className="dialog";
|
||||
this.rootElem.style.position="absolute";
|
||||
this.rootElem.style.display="none";
|
||||
this.editor._framework.ed_cell.insertBefore(this.rootElem,this.editor._framework.ed_cell.firstChild);
|
||||
this.rootElem.style.width=this.width=this.editor._framework.ed_cell.offsetWidth+"px";
|
||||
this.rootElem.style.height=this.height=this.editor._framework.ed_cell.offsetHeight+"px";
|
||||
var _4=this;
|
||||
if(typeof _3=="function"){
|
||||
this._lc=_3;
|
||||
}else{
|
||||
if(_3){
|
||||
this._lc=function(_5){
|
||||
return Xinha._lc(_5,_3);
|
||||
};
|
||||
}else{
|
||||
this._lc=function(_6){
|
||||
return _6;
|
||||
};
|
||||
}
|
||||
}
|
||||
_2=_2.replace(/\[([a-z0-9_]+)\]/ig,function(_7,id){
|
||||
if(typeof _4.id[id]=="undefined"){
|
||||
_4.id[id]=Xinha.uniq("Dialog");
|
||||
_4.r_id[_4.id[id]]=id;
|
||||
}
|
||||
return _4.id[id];
|
||||
}).replace(/<l10n>(.*?)<\/l10n>/ig,function(_9,_a){
|
||||
return _4._lc(_a);
|
||||
}).replace(/="_\((.*?)\)"/g,function(_b,_c){
|
||||
return "=\""+_4._lc(_c)+"\"";
|
||||
});
|
||||
this.rootElem.innerHTML=_2;
|
||||
this.editor.notifyOn("resize",function(e,_e){
|
||||
_4.rootElem.style.width=_4.width=_4.editor._framework.ed_cell.offsetWidth+"px";
|
||||
_4.rootElem.style.height=_4.height=_4.editor._framework.ed_cell.offsetHeight+"px";
|
||||
_4.onresize();
|
||||
});
|
||||
};
|
||||
Xinha.Dialog.prototype.onresize=function(){
|
||||
return true;
|
||||
};
|
||||
Xinha.Dialog.prototype.show=function(_f){
|
||||
if(Xinha.is_ie){
|
||||
this._lastRange=this.editor._createRange(this.editor._getSelection());
|
||||
}
|
||||
if(typeof _f!="undefined"){
|
||||
this.setValues(_f);
|
||||
}
|
||||
this._restoreTo=[this.editor._textArea.style.display,this.editor._iframe.style.visibility,this.editor.hidePanels()];
|
||||
this.editor._textArea.style.display="none";
|
||||
this.editor._iframe.style.visibility="hidden";
|
||||
this.rootElem.style.display="";
|
||||
};
|
||||
Xinha.Dialog.prototype.hide=function(){
|
||||
this.rootElem.style.display="none";
|
||||
this.editor._textArea.style.display=this._restoreTo[0];
|
||||
this.editor._iframe.style.visibility=this._restoreTo[1];
|
||||
this.editor.showPanels(this._restoreTo[2]);
|
||||
if(Xinha.is_ie){
|
||||
this._lastRange.select();
|
||||
}
|
||||
this.editor.updateToolbar();
|
||||
return this.getValues();
|
||||
};
|
||||
Xinha.Dialog.prototype.toggle=function(){
|
||||
if(this.rootElem.style.display=="none"){
|
||||
this.show();
|
||||
}else{
|
||||
this.hide();
|
||||
}
|
||||
};
|
||||
Xinha.Dialog.prototype.setValues=function(_10){
|
||||
for(var i in _10){
|
||||
var _12=this.getElementsByName(i);
|
||||
if(!_12){
|
||||
continue;
|
||||
}
|
||||
for(var x=0;x<_12.length;x++){
|
||||
var e=_12[x];
|
||||
switch(e.tagName.toLowerCase()){
|
||||
case "select":
|
||||
for(var j=0;j<e.options.length;j++){
|
||||
if(typeof _10[i]=="object"){
|
||||
for(var k=0;k<_10[i].length;k++){
|
||||
if(_10[i][k]==e.options[j].value){
|
||||
e.options[j].selected=true;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(_10[i]==e.options[j].value){
|
||||
e.options[j].selected=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "textarea":
|
||||
case "input":
|
||||
switch(e.getAttribute("type")){
|
||||
case "radio":
|
||||
if(e.value==_10[i]){
|
||||
e.checked=true;
|
||||
}
|
||||
break;
|
||||
case "checkbox":
|
||||
if(typeof _10[i]=="object"){
|
||||
for(var j in _10[i]){
|
||||
if(_10[i][j]==e.value){
|
||||
e.checked=true;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(_10[i]==e.value){
|
||||
e.checked=true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
e.value=_10[i];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Xinha.Dialog.prototype.getValues=function(){
|
||||
var _17=[];
|
||||
var _18=Xinha.collectionToArray(this.rootElem.getElementsByTagName("input")).append(Xinha.collectionToArray(this.rootElem.getElementsByTagName("textarea"))).append(Xinha.collectionToArray(this.rootElem.getElementsByTagName("select")));
|
||||
for(var x=0;x<_18.length;x++){
|
||||
var i=_18[x];
|
||||
if(!(i.name&&this.r_id[i.name])){
|
||||
continue;
|
||||
}
|
||||
if(typeof _17[this.r_id[i.name]]=="undefined"){
|
||||
_17[this.r_id[i.name]]=null;
|
||||
}
|
||||
var v=_17[this.r_id[i.name]];
|
||||
switch(i.tagName.toLowerCase()){
|
||||
case "select":
|
||||
if(i.multiple){
|
||||
if(!v.push){
|
||||
if(v!=null){
|
||||
v=[v];
|
||||
}else{
|
||||
v=new Array();
|
||||
}
|
||||
}
|
||||
for(var j=0;j<i.options.length;j++){
|
||||
if(i.options[j].selected){
|
||||
v.push(i.options[j].value);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(i.selectedIndex>=0){
|
||||
v=i.options[i.selectedIndex];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "textarea":
|
||||
case "input":
|
||||
default:
|
||||
switch(i.type.toLowerCase()){
|
||||
case "radio":
|
||||
if(i.checked){
|
||||
v=i.value;
|
||||
break;
|
||||
}
|
||||
case "checkbox":
|
||||
if(v==null){
|
||||
if(this.getElementsByName(this.r_id[i.name]).length>1){
|
||||
v=new Array();
|
||||
}
|
||||
}
|
||||
if(i.checked){
|
||||
if(v!=null&&typeof v=="object"&&v.push){
|
||||
v.push(i.value);
|
||||
}else{
|
||||
v=i.value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
v=i.value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_17[this.r_id[i.name]]=v;
|
||||
}
|
||||
return _17;
|
||||
};
|
||||
Xinha.Dialog.prototype.getElementById=function(id){
|
||||
return this.document.getElementById(this.id[id]?this.id[id]:id);
|
||||
};
|
||||
Xinha.Dialog.prototype.getElementsByName=function(_1e){
|
||||
return this.document.getElementsByName(this.id[_1e]?this.id[_1e]:_1e);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
|
||||
/* This file is part of version 0.95 released Mon, 12 May 2008 17:33:15 +0200 */
|
||||
/* The URL of the most recent version of this file is http://svn.xinha.webfactional.com/trunk/modules/Dialogs/panel-dialog.js */
|
||||
Xinha.PanelDialog=function(_1,_2,_3,_4){
|
||||
this.id={};
|
||||
this.r_id={};
|
||||
this.editor=_1;
|
||||
this.document=document;
|
||||
this.rootElem=_1.addPanel(_2);
|
||||
var _5=this;
|
||||
if(typeof _4=="function"){
|
||||
this._lc=_4;
|
||||
}else{
|
||||
if(_4){
|
||||
this._lc=function(_6){
|
||||
return Xinha._lc(_6,_4);
|
||||
};
|
||||
}else{
|
||||
this._lc=function(_7){
|
||||
return _7;
|
||||
};
|
||||
}
|
||||
}
|
||||
_3=_3.replace(/\[([a-z0-9_]+)\]/ig,function(_8,id){
|
||||
if(typeof _5.id[id]=="undefined"){
|
||||
_5.id[id]=Xinha.uniq("Dialog");
|
||||
_5.r_id[_5.id[id]]=id;
|
||||
}
|
||||
return _5.id[id];
|
||||
}).replace(/<l10n>(.*?)<\/l10n>/ig,function(_a,_b){
|
||||
return _5._lc(_b);
|
||||
}).replace(/="_\((.*?)\)"/g,function(_c,_d){
|
||||
return "=\""+_5._lc(_d)+"\"";
|
||||
});
|
||||
this.rootElem.innerHTML=_3;
|
||||
};
|
||||
Xinha.PanelDialog.prototype.show=function(_e){
|
||||
this.setValues(_e);
|
||||
this.editor.showPanel(this.rootElem);
|
||||
};
|
||||
Xinha.PanelDialog.prototype.hide=function(){
|
||||
this.editor.hidePanel(this.rootElem);
|
||||
return this.getValues();
|
||||
};
|
||||
Xinha.PanelDialog.prototype.onresize=Xinha.Dialog.prototype.onresize;
|
||||
Xinha.PanelDialog.prototype.toggle=Xinha.Dialog.prototype.toggle;
|
||||
Xinha.PanelDialog.prototype.setValues=Xinha.Dialog.prototype.setValues;
|
||||
Xinha.PanelDialog.prototype.getValues=Xinha.Dialog.prototype.getValues;
|
||||
Xinha.PanelDialog.prototype.getElementById=Xinha.Dialog.prototype.getElementById;
|
||||
Xinha.PanelDialog.prototype.getElementsByName=Xinha.Dialog.prototype.getElementsByName;
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
|
||||
/* This file is part of version 0.95 released Mon, 12 May 2008 17:33:15 +0200 */
|
||||
/* The URL of the most recent version of this file is http://svn.xinha.webfactional.com/trunk/modules/Dialogs/popupwin.js */
|
||||
function PopupWin(_1,_2,_3,_4){
|
||||
this.editor=_1;
|
||||
this.handler=_3;
|
||||
var _5=window.open("","__ha_dialog","toolbar=no,menubar=no,personalbar=no,width=600,height=600,left=20,top=40,scrollbars=no,resizable=yes");
|
||||
this.window=_5;
|
||||
var _6=_5.document;
|
||||
this.doc=_6;
|
||||
var _7=this;
|
||||
var _8=document.baseURI||document.URL;
|
||||
if(_8&&_8.match(/(.*)\/([^\/]+)/)){
|
||||
_8=RegExp.$1+"/";
|
||||
}
|
||||
if(typeof _editor_url!="undefined"&&!(/^\//.test(_editor_url))&&!(/http:\/\//.test(_editor_url))){
|
||||
_8+=_editor_url;
|
||||
}else{
|
||||
_8=_editor_url;
|
||||
}
|
||||
if(!(/\/$/.test(_8))){
|
||||
_8+="/";
|
||||
}
|
||||
this.baseURL=_8;
|
||||
_6.open();
|
||||
var _9="<html><head><title>"+_2+"</title>\n";
|
||||
_9+="<style type=\"text/css\">@import url("+_editor_url+"Xinha.css);</style>\n";
|
||||
if(_editor_skin!=""){
|
||||
_9+="<style type=\"text/css\">@import url("+_editor_url+"skins/"+_editor_skin+"/skin.css);</style>\n";
|
||||
}
|
||||
_9+="</head>\n";
|
||||
_9+="<body class=\"dialog popupwin\" id=\"--HA-body\"></body></html>";
|
||||
_6.write(_9);
|
||||
_6.close();
|
||||
function init2(){
|
||||
var _a=_6.body;
|
||||
if(!_a){
|
||||
setTimeout(init2,25);
|
||||
return false;
|
||||
}
|
||||
_5.title=_2;
|
||||
_6.documentElement.style.padding="0px";
|
||||
_6.documentElement.style.margin="0px";
|
||||
var _b=_6.createElement("div");
|
||||
_b.className="content";
|
||||
_7.content=_b;
|
||||
_a.appendChild(_b);
|
||||
_7.element=_a;
|
||||
_4(_7);
|
||||
_5.focus();
|
||||
}
|
||||
init2();
|
||||
}
|
||||
PopupWin.prototype.callHandler=function(){
|
||||
var _c=["input","textarea","select"];
|
||||
var _d={};
|
||||
for(var ti=_c.length;--ti>=0;){
|
||||
var _f=_c[ti];
|
||||
var els=this.content.getElementsByTagName(_f);
|
||||
for(var j=0;j<els.length;++j){
|
||||
var el=els[j];
|
||||
var val=el.value;
|
||||
if(el.tagName.toLowerCase()=="input"){
|
||||
if(el.type=="checkbox"){
|
||||
val=el.checked;
|
||||
}
|
||||
}
|
||||
_d[el.name]=val;
|
||||
}
|
||||
}
|
||||
this.handler(this,_d);
|
||||
return false;
|
||||
};
|
||||
PopupWin.prototype.close=function(){
|
||||
this.window.close();
|
||||
};
|
||||
PopupWin.prototype.addButtons=function(){
|
||||
var _14=this;
|
||||
var div=this.doc.createElement("div");
|
||||
this.content.appendChild(div);
|
||||
div.id="buttons";
|
||||
div.className="buttons";
|
||||
for(var i=0;i<arguments.length;++i){
|
||||
var btn=arguments[i];
|
||||
var _18=this.doc.createElement("button");
|
||||
div.appendChild(_18);
|
||||
_18.innerHTML=Xinha._lc(btn,"Xinha");
|
||||
switch(btn.toLowerCase()){
|
||||
case "ok":
|
||||
Xinha.addDom0Event(_18,"click",function(){
|
||||
_14.callHandler();
|
||||
_14.close();
|
||||
return false;
|
||||
});
|
||||
break;
|
||||
case "cancel":
|
||||
Xinha.addDom0Event(_18,"click",function(){
|
||||
_14.close();
|
||||
return false;
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
PopupWin.prototype.showAtElement=function(){
|
||||
var _19=this;
|
||||
setTimeout(function(){
|
||||
var w=_19.content.offsetWidth+4;
|
||||
var h=_19.content.offsetHeight+4;
|
||||
var el=_19.content;
|
||||
var s=el.style;
|
||||
s.position="absolute";
|
||||
s.left=parseInt((w-el.offsetWidth)/2,10)+"px";
|
||||
s.top=parseInt((h-el.offsetHeight)/2,10)+"px";
|
||||
if(Xinha.is_gecko){
|
||||
_19.window.innerWidth=w;
|
||||
_19.window.innerHeight=h;
|
||||
}else{
|
||||
_19.window.resizeTo(w+8,h+70);
|
||||
}
|
||||
},25);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user