add dijit/dojo stuff; initial ui mockup

This commit is contained in:
Andrew Dolgov
2010-11-15 10:39:52 +03:00
parent 951906dcec
commit 2f01fe57a8
1122 changed files with 102828 additions and 49 deletions

View File

@@ -0,0 +1,119 @@
/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dijit._editor.plugins.AlwaysShowToolbar"]){
dojo._hasResource["dijit._editor.plugins.AlwaysShowToolbar"]=true;
dojo.provide("dijit._editor.plugins.AlwaysShowToolbar");
dojo.declare("dijit._editor.plugins.AlwaysShowToolbar",dijit._editor._Plugin,{_handleScroll:true,setEditor:function(e){
if(!e.iframe){
return;
}
this.editor=e;
e.onLoadDeferred.addCallback(dojo.hitch(this,this.enable));
},enable:function(d){
this._updateHeight();
this.connect(window,"onscroll","globalOnScrollHandler");
this.connect(this.editor,"onNormalizedDisplayChanged","_updateHeight");
return d;
},_updateHeight:function(){
var e=this.editor;
if(!e.isLoaded){
return;
}
if(e.height){
return;
}
var _1=dojo.marginBox(e.editNode).h;
if(dojo.isOpera){
_1=e.editNode.scrollHeight;
}
if(!_1){
_1=dojo.marginBox(e.document.body).h;
}
if(_1==0){
return;
}
if(dojo.isIE<=7&&this.editor.minHeight){
var _2=parseInt(this.editor.minHeight);
if(_1<_2){
_1=_2;
}
}
if(_1!=this._lastHeight){
this._lastHeight=_1;
dojo.marginBox(e.iframe,{h:this._lastHeight});
}
},_lastHeight:0,globalOnScrollHandler:function(){
var _3=dojo.isIE<7;
if(!this._handleScroll){
return;
}
var _4=this.editor.header;
var db=dojo.body;
if(!this._scrollSetUp){
this._scrollSetUp=true;
this._scrollThreshold=dojo.position(_4,true).y;
}
var _5=dojo._docScroll().y;
var s=_4.style;
if(_5>this._scrollThreshold&&_5<this._scrollThreshold+this._lastHeight){
if(!this._fixEnabled){
var _6=dojo.marginBox(_4);
this.editor.iframe.style.marginTop=_6.h+"px";
if(_3){
s.left=dojo.position(_4).x;
if(_4.previousSibling){
this._IEOriginalPos=["after",_4.previousSibling];
}else{
if(_4.nextSibling){
this._IEOriginalPos=["before",_4.nextSibling];
}else{
this._IEOriginalPos=["last",_4.parentNode];
}
}
dojo.body().appendChild(_4);
dojo.addClass(_4,"dijitIEFixedToolbar");
}else{
s.position="fixed";
s.top="0px";
}
dojo.marginBox(_4,{w:_6.w});
s.zIndex=2000;
this._fixEnabled=true;
}
var _7=(this.height)?parseInt(this.editor.height):this.editor._lastHeight;
s.display=(_5>this._scrollThreshold+_7)?"none":"";
}else{
if(this._fixEnabled){
this.editor.iframe.style.marginTop="";
s.position="";
s.top="";
s.zIndex="";
s.display="";
if(_3){
s.left="";
dojo.removeClass(_4,"dijitIEFixedToolbar");
if(this._IEOriginalPos){
dojo.place(_4,this._IEOriginalPos[1],this._IEOriginalPos[0]);
this._IEOriginalPos=null;
}else{
dojo.place(_4,this.editor.iframe,"before");
}
}
s.width="";
this._fixEnabled=false;
}
}
},destroy:function(){
this._IEOriginalPos=null;
this._handleScroll=false;
dojo.forEach(this._connects,dojo.disconnect);
if(dojo.isIE<7){
dojo.removeClass(this.editor.header,"dijitIEFixedToolbar");
}
}});
}

View File

@@ -0,0 +1,423 @@
/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dijit._editor.plugins.EnterKeyHandling"]){
dojo._hasResource["dijit._editor.plugins.EnterKeyHandling"]=true;
dojo.provide("dijit._editor.plugins.EnterKeyHandling");
dojo.require("dojo.window");
dojo.declare("dijit._editor.plugins.EnterKeyHandling",dijit._editor._Plugin,{blockNodeForEnter:"BR",constructor:function(_1){
if(_1){
dojo.mixin(this,_1);
}
},setEditor:function(_2){
this.editor=_2;
if(this.blockNodeForEnter=="BR"){
if(dojo.isIE){
_2.contentDomPreFilters.push(dojo.hitch(this,"regularPsToSingleLinePs"));
_2.contentDomPostFilters.push(dojo.hitch(this,"singleLinePsToRegularPs"));
_2.onLoadDeferred.addCallback(dojo.hitch(this,"_fixNewLineBehaviorForIE"));
}else{
_2.onLoadDeferred.addCallback(dojo.hitch(this,function(d){
try{
this.editor.document.execCommand("insertBrOnReturn",false,true);
}
catch(e){
}
return d;
}));
}
}else{
if(this.blockNodeForEnter){
dojo["require"]("dijit._editor.range");
var h=dojo.hitch(this,this.handleEnterKey);
_2.addKeyHandler(13,0,0,h);
_2.addKeyHandler(13,0,1,h);
this.connect(this.editor,"onKeyPressed","onKeyPressed");
}
}
},onKeyPressed:function(e){
if(this._checkListLater){
if(dojo.withGlobal(this.editor.window,"isCollapsed",dijit)){
var _3=dojo.withGlobal(this.editor.window,"getAncestorElement",dijit._editor.selection,["LI"]);
if(!_3){
dijit._editor.RichText.prototype.execCommand.call(this.editor,"formatblock",this.blockNodeForEnter);
var _4=dojo.withGlobal(this.editor.window,"getAncestorElement",dijit._editor.selection,[this.blockNodeForEnter]);
if(_4){
_4.innerHTML=this.bogusHtmlContent;
if(dojo.isIE){
var r=this.editor.document.selection.createRange();
r.move("character",-1);
r.select();
}
}else{
console.error("onKeyPressed: Cannot find the new block node");
}
}else{
if(dojo.isMoz){
if(_3.parentNode.parentNode.nodeName=="LI"){
_3=_3.parentNode.parentNode;
}
}
var fc=_3.firstChild;
if(fc&&fc.nodeType==1&&(fc.nodeName=="UL"||fc.nodeName=="OL")){
_3.insertBefore(fc.ownerDocument.createTextNode(" "),fc);
var _5=dijit.range.create(this.editor.window);
_5.setStart(_3.firstChild,0);
var _6=dijit.range.getSelection(this.editor.window,true);
_6.removeAllRanges();
_6.addRange(_5);
}
}
}
this._checkListLater=false;
}
if(this._pressedEnterInBlock){
if(this._pressedEnterInBlock.previousSibling){
this.removeTrailingBr(this._pressedEnterInBlock.previousSibling);
}
delete this._pressedEnterInBlock;
}
},bogusHtmlContent:"&nbsp;",blockNodes:/^(?:P|H1|H2|H3|H4|H5|H6|LI)$/,handleEnterKey:function(e){
var _7,_8,_9,_a=this.editor.document,br;
if(e.shiftKey){
var _b=dojo.withGlobal(this.editor.window,"getParentElement",dijit._editor.selection);
var _c=dijit.range.getAncestor(_b,this.blockNodes);
if(_c){
if(!e.shiftKey&&_c.tagName=="LI"){
return true;
}
_7=dijit.range.getSelection(this.editor.window);
_8=_7.getRangeAt(0);
if(!_8.collapsed){
_8.deleteContents();
_7=dijit.range.getSelection(this.editor.window);
_8=_7.getRangeAt(0);
}
if(dijit.range.atBeginningOfContainer(_c,_8.startContainer,_8.startOffset)){
if(e.shiftKey){
br=_a.createElement("br");
_9=dijit.range.create(this.editor.window);
_c.insertBefore(br,_c.firstChild);
_9.setStartBefore(br.nextSibling);
_7.removeAllRanges();
_7.addRange(_9);
}else{
dojo.place(br,_c,"before");
}
}else{
if(dijit.range.atEndOfContainer(_c,_8.startContainer,_8.startOffset)){
_9=dijit.range.create(this.editor.window);
br=_a.createElement("br");
if(e.shiftKey){
_c.appendChild(br);
_c.appendChild(_a.createTextNode(" "));
_9.setStart(_c.lastChild,0);
}else{
dojo.place(br,_c,"after");
_9.setStartAfter(_c);
}
_7.removeAllRanges();
_7.addRange(_9);
}else{
return true;
}
}
}else{
dijit._editor.RichText.prototype.execCommand.call(this.editor,"inserthtml","<br>");
}
return false;
}
var _d=true;
_7=dijit.range.getSelection(this.editor.window);
_8=_7.getRangeAt(0);
if(!_8.collapsed){
_8.deleteContents();
_7=dijit.range.getSelection(this.editor.window);
_8=_7.getRangeAt(0);
}
var _e=dijit.range.getBlockAncestor(_8.endContainer,null,this.editor.editNode);
var _f=_e.blockNode;
if((this._checkListLater=(_f&&(_f.nodeName=="LI"||_f.parentNode.nodeName=="LI")))){
if(dojo.isMoz){
this._pressedEnterInBlock=_f;
}
if(/^(\s|&nbsp;|\xA0|<span\b[^>]*\bclass=['"]Apple-style-span['"][^>]*>(\s|&nbsp;|\xA0)<\/span>)?(<br>)?$/.test(_f.innerHTML)){
_f.innerHTML="";
if(dojo.isWebKit){
_9=dijit.range.create(this.editor.window);
_9.setStart(_f,0);
_7.removeAllRanges();
_7.addRange(_9);
}
this._checkListLater=false;
}
return true;
}
if(!_e.blockNode||_e.blockNode===this.editor.editNode){
try{
dijit._editor.RichText.prototype.execCommand.call(this.editor,"formatblock",this.blockNodeForEnter);
}
catch(e2){
}
_e={blockNode:dojo.withGlobal(this.editor.window,"getAncestorElement",dijit._editor.selection,[this.blockNodeForEnter]),blockContainer:this.editor.editNode};
if(_e.blockNode){
if(_e.blockNode!=this.editor.editNode&&(!(_e.blockNode.textContent||_e.blockNode.innerHTML).replace(/^\s+|\s+$/g,"").length)){
this.removeTrailingBr(_e.blockNode);
return false;
}
}else{
_e.blockNode=this.editor.editNode;
}
_7=dijit.range.getSelection(this.editor.window);
_8=_7.getRangeAt(0);
}
var _10=_a.createElement(this.blockNodeForEnter);
_10.innerHTML=this.bogusHtmlContent;
this.removeTrailingBr(_e.blockNode);
if(dijit.range.atEndOfContainer(_e.blockNode,_8.endContainer,_8.endOffset)){
if(_e.blockNode===_e.blockContainer){
_e.blockNode.appendChild(_10);
}else{
dojo.place(_10,_e.blockNode,"after");
}
_d=false;
_9=dijit.range.create(this.editor.window);
_9.setStart(_10,0);
_7.removeAllRanges();
_7.addRange(_9);
if(this.editor.height){
dojo.window.scrollIntoView(_10);
}
}else{
if(dijit.range.atBeginningOfContainer(_e.blockNode,_8.startContainer,_8.startOffset)){
dojo.place(_10,_e.blockNode,_e.blockNode===_e.blockContainer?"first":"before");
if(_10.nextSibling&&this.editor.height){
_9=dijit.range.create(this.editor.window);
_9.setStart(_10.nextSibling,0);
_7.removeAllRanges();
_7.addRange(_9);
dojo.window.scrollIntoView(_10.nextSibling);
}
_d=false;
}else{
if(_e.blockNode===_e.blockContainer){
_e.blockNode.appendChild(_10);
}else{
dojo.place(_10,_e.blockNode,"after");
}
_d=false;
if(_e.blockNode.style){
if(_10.style){
if(_e.blockNode.style.cssText){
_10.style.cssText=_e.blockNode.style.cssText;
}
}
}
var rs=_8.startContainer;
if(rs&&rs.nodeType==3){
var _11,_12;
var txt=rs.nodeValue;
var _13=_a.createTextNode(txt.substring(0,_8.startOffset));
var _14=_a.createTextNode(txt.substring(_8.startOffset,txt.length));
dojo.place(_13,rs,"before");
dojo.place(_14,rs,"after");
dojo.destroy(rs);
var _15=_13.parentNode;
while(_15!==_e.blockNode){
var tg=_15.tagName;
var _16=_a.createElement(tg);
if(_15.style){
if(_16.style){
if(_15.style.cssText){
_16.style.cssText=_15.style.cssText;
}
}
}
_11=_14;
while(_11){
_12=_11.nextSibling;
_16.appendChild(_11);
_11=_12;
}
dojo.place(_16,_15,"after");
_13=_15;
_14=_16;
_15=_15.parentNode;
}
_11=_14;
if(_11.nodeType==1||(_11.nodeType==3&&_11.nodeValue)){
_10.innerHTML="";
}
while(_11){
_12=_11.nextSibling;
_10.appendChild(_11);
_11=_12;
}
}
_9=dijit.range.create(this.editor.window);
_9.setStart(_10,0);
_7.removeAllRanges();
_7.addRange(_9);
if(this.editor.height){
dijit.scrollIntoView(_10);
}
if(dojo.isMoz){
this._pressedEnterInBlock=_e.blockNode;
}
}
}
return _d;
},removeTrailingBr:function(_17){
var _18=/P|DIV|LI/i.test(_17.tagName)?_17:dijit._editor.selection.getParentOfType(_17,["P","DIV","LI"]);
if(!_18){
return;
}
if(_18.lastChild){
if((_18.childNodes.length>1&&_18.lastChild.nodeType==3&&/^[\s\xAD]*$/.test(_18.lastChild.nodeValue))||_18.lastChild.tagName=="BR"){
dojo.destroy(_18.lastChild);
}
}
if(!_18.childNodes.length){
_18.innerHTML=this.bogusHtmlContent;
}
},_fixNewLineBehaviorForIE:function(d){
var doc=this.editor.document;
if(doc.__INSERTED_EDITIOR_NEWLINE_CSS===undefined){
var _19=dojo.create("style",{type:"text/css"},doc.getElementsByTagName("head")[0]);
_19.styleSheet.cssText="p{margin:0;}";
this.editor.document.__INSERTED_EDITIOR_NEWLINE_CSS=true;
}
return d;
},regularPsToSingleLinePs:function(_1a,_1b){
function _1c(el){
function _1d(_1e){
var _1f=_1e[0].ownerDocument.createElement("p");
_1e[0].parentNode.insertBefore(_1f,_1e[0]);
dojo.forEach(_1e,function(_20){
_1f.appendChild(_20);
});
};
var _21=0;
var _22=[];
var _23;
while(_21<el.childNodes.length){
_23=el.childNodes[_21];
if(_23.nodeType==3||(_23.nodeType==1&&_23.nodeName!="BR"&&dojo.style(_23,"display")!="block")){
_22.push(_23);
}else{
var _24=_23.nextSibling;
if(_22.length){
_1d(_22);
_21=(_21+1)-_22.length;
if(_23.nodeName=="BR"){
dojo.destroy(_23);
}
}
_22=[];
}
_21++;
}
if(_22.length){
_1d(_22);
}
};
function _25(el){
var _26=null;
var _27=[];
var _28=el.childNodes.length-1;
for(var i=_28;i>=0;i--){
_26=el.childNodes[i];
if(_26.nodeName=="BR"){
var _29=_26.ownerDocument.createElement("p");
dojo.place(_29,el,"after");
if(_27.length==0&&i!=_28){
_29.innerHTML="&nbsp;";
}
dojo.forEach(_27,function(_2a){
_29.appendChild(_2a);
});
dojo.destroy(_26);
_27=[];
}else{
_27.unshift(_26);
}
}
};
var _2b=[];
var ps=_1a.getElementsByTagName("p");
dojo.forEach(ps,function(p){
_2b.push(p);
});
dojo.forEach(_2b,function(p){
var _2c=p.previousSibling;
if((_2c)&&(_2c.nodeType==1)&&(_2c.nodeName=="P"||dojo.style(_2c,"display")!="block")){
var _2d=p.parentNode.insertBefore(this.document.createElement("p"),p);
_2d.innerHTML=_1b?"":"&nbsp;";
}
_25(p);
},this.editor);
_1c(_1a);
return _1a;
},singleLinePsToRegularPs:function(_2e){
function _2f(_30){
var ps=_30.getElementsByTagName("p");
var _31=[];
for(var i=0;i<ps.length;i++){
var p=ps[i];
var _32=false;
for(var k=0;k<_31.length;k++){
if(_31[k]===p.parentNode){
_32=true;
break;
}
}
if(!_32){
_31.push(p.parentNode);
}
}
return _31;
};
function _33(_34){
return (!_34.childNodes.length||_34.innerHTML=="&nbsp;");
};
var _35=_2f(_2e);
for(var i=0;i<_35.length;i++){
var _36=_35[i];
var _37=null;
var _38=_36.firstChild;
var _39=null;
while(_38){
if(_38.nodeType!=1||_38.tagName!="P"||(_38.getAttributeNode("style")||{}).specified){
_37=null;
}else{
if(_33(_38)){
_39=_38;
_37=null;
}else{
if(_37==null){
_37=_38;
}else{
if((!_37.lastChild||_37.lastChild.nodeName!="BR")&&(_38.firstChild)&&(_38.firstChild.nodeName!="BR")){
_37.appendChild(this.editor.document.createElement("br"));
}
while(_38.firstChild){
_37.appendChild(_38.firstChild);
}
_39=_38;
}
}
}
_38=_38.nextSibling;
if(_39){
dojo.destroy(_39);
_39=null;
}
}
}
return _2e;
}});
}

View File

@@ -0,0 +1,265 @@
/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dijit._editor.plugins.FontChoice"]){
dojo._hasResource["dijit._editor.plugins.FontChoice"]=true;
dojo.provide("dijit._editor.plugins.FontChoice");
dojo.require("dijit._editor._Plugin");
dojo.require("dijit._editor.range");
dojo.require("dijit._editor.selection");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojo.i18n");
dojo.requireLocalization("dijit._editor","FontChoice",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");
dojo.declare("dijit._editor.plugins._FontDropDown",[dijit._Widget,dijit._Templated],{label:"",widgetsInTemplate:true,plainText:false,templateString:"<span style='white-space: nowrap' class='dijit dijitReset dijitInline'>"+"<label class='dijitLeft dijitInline' for='${selectId}'>${label}</label>"+"<input dojoType='dijit.form.FilteringSelect' required=false labelType=html labelAttr=label searchAttr=name "+"tabIndex='-1' id='${selectId}' dojoAttachPoint='select' value=''/>"+"</span>",postMixInProperties:function(){
this.inherited(arguments);
this.strings=dojo.i18n.getLocalization("dijit._editor","FontChoice");
this.label=this.strings[this.command];
this.id=dijit.getUniqueId(this.declaredClass.replace(/\./g,"_"));
this.selectId=this.id+"_select";
this.inherited(arguments);
},postCreate:function(){
var _1=dojo.map(this.values,function(_2){
var _3=this.strings[_2]||_2;
return {label:this.getLabel(_2,_3),name:_3,value:_2};
},this);
this.select.store=new dojo.data.ItemFileReadStore({data:{identifier:"value",items:_1}});
this.select.set("value","",false);
this.disabled=this.select.get("disabled");
},_setValueAttr:function(_4,_5){
_5=_5!==false?true:false;
this.select.set("value",dojo.indexOf(this.values,_4)<0?"":_4,_5);
if(!_5){
this.select._lastValueReported=null;
}
},_getValueAttr:function(){
return this.select.get("value");
},focus:function(){
this.select.focus();
},_setDisabledAttr:function(_6){
this.disabled=_6;
this.select.set("disabled",_6);
}});
dojo.declare("dijit._editor.plugins._FontNameDropDown",dijit._editor.plugins._FontDropDown,{generic:false,command:"fontName",postMixInProperties:function(){
if(!this.values){
this.values=this.generic?["serif","sans-serif","monospace","cursive","fantasy"]:["Arial","Times New Roman","Comic Sans MS","Courier New"];
}
this.inherited(arguments);
},getLabel:function(_7,_8){
if(this.plainText){
return _8;
}else{
return "<div style='font-family: "+_7+"'>"+_8+"</div>";
}
},_setValueAttr:function(_9,_a){
_a=_a!==false?true:false;
if(this.generic){
var _b={"Arial":"sans-serif","Helvetica":"sans-serif","Myriad":"sans-serif","Times":"serif","Times New Roman":"serif","Comic Sans MS":"cursive","Apple Chancery":"cursive","Courier":"monospace","Courier New":"monospace","Papyrus":"fantasy"};
_9=_b[_9]||_9;
}
this.inherited(arguments,[_9,_a]);
}});
dojo.declare("dijit._editor.plugins._FontSizeDropDown",dijit._editor.plugins._FontDropDown,{command:"fontSize",values:[1,2,3,4,5,6,7],getLabel:function(_c,_d){
if(this.plainText){
return _d;
}else{
return "<font size="+_c+"'>"+_d+"</font>";
}
},_setValueAttr:function(_e,_f){
_f=_f!==false?true:false;
if(_e.indexOf&&_e.indexOf("px")!=-1){
var _10=parseInt(_e,10);
_e={10:1,13:2,16:3,18:4,24:5,32:6,48:7}[_10]||_e;
}
this.inherited(arguments,[_e,_f]);
}});
dojo.declare("dijit._editor.plugins._FormatBlockDropDown",dijit._editor.plugins._FontDropDown,{command:"formatBlock",values:["noFormat","p","h1","h2","h3","pre"],postCreate:function(){
this.inherited(arguments);
this.set("value","noFormat",false);
},getLabel:function(_11,_12){
if(this.plainText){
return _12;
}else{
return "<"+_11+">"+_12+"</"+_11+">";
}
},_execCommand:function(_13,_14,_15){
if(_15==="noFormat"){
var _16;
var end;
var sel=dijit.range.getSelection(_13.window);
if(sel&&sel.rangeCount>0){
var _17=sel.getRangeAt(0);
var _18,tag;
if(_17){
_16=_17.startContainer;
end=_17.endContainer;
while(_16&&_16!==_13.editNode&&_16!==_13.document.body&&_16.nodeType!==1){
_16=_16.parentNode;
}
while(end&&end!==_13.editNode&&end!==_13.document.body&&end.nodeType!==1){
end=end.parentNode;
}
var _19=dojo.hitch(this,function(_1a,_1b){
if(_1a.childNodes&&_1a.childNodes.length){
var i;
for(i=0;i<_1a.childNodes.length;i++){
var c=_1a.childNodes[i];
if(c.nodeType==1){
if(dojo.withGlobal(_13.window,"inSelection",dijit._editor.selection,[c])){
var tag=c.tagName?c.tagName.toLowerCase():"";
if(dojo.indexOf(this.values,tag)!==-1){
_1b.push(c);
}
_19(c,_1b);
}
}
}
}
});
var _1c=dojo.hitch(this,function(_1d){
if(_1d&&_1d.length){
_13.beginEditing();
while(_1d.length){
this._removeFormat(_13,_1d.pop());
}
_13.endEditing();
}
});
var _1e=[];
if(_16==end){
var _1f;
_18=_16;
while(_18&&_18!==_13.editNode&&_18!==_13.document.body){
if(_18.nodeType==1){
tag=_18.tagName?_18.tagName.toLowerCase():"";
if(dojo.indexOf(this.values,tag)!==-1){
_1f=_18;
break;
}
}
_18=_18.parentNode;
}
_19(_16,_1e);
if(_1f){
_1e=[_1f].concat(_1e);
}
_1c(_1e);
}else{
_18=_16;
while(dojo.withGlobal(_13.window,"inSelection",dijit._editor.selection,[_18])){
if(_18.nodeType==1){
tag=_18.tagName?_18.tagName.toLowerCase():"";
if(dojo.indexOf(this.values,tag)!==-1){
_1e.push(_18);
}
_19(_18,_1e);
}
_18=_18.nextSibling;
}
_1c(_1e);
}
_13.onDisplayChanged();
}
}
}else{
_13.execCommand(_14,_15);
}
},_removeFormat:function(_20,_21){
if(_20.customUndo){
while(_21.firstChild){
dojo.place(_21.firstChild,_21,"before");
}
_21.parentNode.removeChild(_21);
}else{
dojo.withGlobal(_20.window,"selectElementChildren",dijit._editor.selection,[_21]);
var _22=dojo.withGlobal(_20.window,"getSelectedHtml",dijit._editor.selection,[null]);
dojo.withGlobal(_20.window,"selectElement",dijit._editor.selection,[_21]);
_20.execCommand("inserthtml",_22||"");
}
}});
dojo.declare("dijit._editor.plugins.FontChoice",dijit._editor._Plugin,{useDefaultCommand:false,_initButton:function(){
var _23={fontName:dijit._editor.plugins._FontNameDropDown,fontSize:dijit._editor.plugins._FontSizeDropDown,formatBlock:dijit._editor.plugins._FormatBlockDropDown}[this.command],_24=this.params;
if(this.params.custom){
_24.values=this.params.custom;
}
var _25=this.editor;
this.button=new _23(dojo.delegate({dir:_25.dir,lang:_25.lang},_24));
this.connect(this.button.select,"onChange",function(_26){
this.editor.focus();
if(this.command=="fontName"&&_26.indexOf(" ")!=-1){
_26="'"+_26+"'";
}
if(this.button._execCommand){
this.button._execCommand(this.editor,this.command,_26);
}else{
this.editor.execCommand(this.command,_26);
}
this.editor.customUndo=this.editor.customUndo||dojo.isWebKit;
});
},updateState:function(){
var _27=this.editor;
var _28=this.command;
if(!_27||!_27.isLoaded||!_28.length){
return;
}
if(this.button){
var _29;
try{
_29=_27.queryCommandValue(_28)||"";
}
catch(e){
_29="";
}
var _2a=dojo.isString(_29)&&_29.match(/'([^']*)'/);
if(_2a){
_29=_2a[1];
}
if(_28==="formatBlock"){
if(!_29||_29=="p"){
_29=null;
var _2b;
var sel=dijit.range.getSelection(this.editor.window);
if(sel&&sel.rangeCount>0){
var _2c=sel.getRangeAt(0);
if(_2c){
_2b=_2c.endContainer;
}
}
while(_2b&&_2b!==_27.editNode&&_2b!==_27.document){
var tg=_2b.tagName?_2b.tagName.toLowerCase():"";
if(tg&&dojo.indexOf(this.button.values,tg)>-1){
_29=tg;
break;
}
_2b=_2b.parentNode;
}
if(!_29){
_29="noFormat";
}
}else{
if(dojo.indexOf(this.button.values,_29)<0){
_29="noFormat";
}
}
}
if(_29!==this.button.get("value")){
this.button.set("value",_29,false);
}
}
}});
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
if(o.plugin){
return;
}
switch(o.args.name){
case "fontName":
case "fontSize":
case "formatBlock":
o.plugin=new dijit._editor.plugins.FontChoice({command:o.args.name,plainText:o.args.plainText?o.args.plainText:false});
}
});
}

View File

@@ -0,0 +1,232 @@
/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dijit._editor.plugins.FullScreen"]){
dojo._hasResource["dijit._editor.plugins.FullScreen"]=true;
dojo.provide("dijit._editor.plugins.FullScreen");
dojo.require("dojo.window");
dojo.require("dojo.i18n");
dojo.require("dijit._editor._Plugin");
dojo.require("dijit.form.Button");
dojo.requireLocalization("dijit._editor","commands",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");
dojo.declare("dijit._editor.plugins.FullScreen",dijit._editor._Plugin,{zIndex:500,_origState:null,_origiFrameState:null,_resizeHandle:null,isFullscreen:false,toggle:function(){
this.button.set("checked",!this.button.get("checked"));
},_initButton:function(){
var _1=dojo.i18n.getLocalization("dijit._editor","commands"),_2=this.editor;
this.button=new dijit.form.ToggleButton({label:_1["fullScreen"],dir:_2.dir,lang:_2.lang,showLabel:false,iconClass:this.iconClassPrefix+" "+this.iconClassPrefix+"FullScreen",tabIndex:"-1",onChange:dojo.hitch(this,"_setFullScreen")});
},setEditor:function(_3){
this.editor=_3;
this._initButton();
this.editor.addKeyHandler(dojo.keys.F11,true,true,dojo.hitch(this,function(e){
this.toggle();
dojo.stopEvent(e);
setTimeout(dojo.hitch(this,function(){
this.editor.focus();
}),250);
return true;
}));
this.connect(this.editor.domNode,"onkeydown","_containFocus");
},_containFocus:function(e){
if(this.isFullscreen){
var ed=this.editor;
if(!ed.isTabIndent&&ed._fullscreen_oldOnKeyDown&&e.keyCode===dojo.keys.TAB){
var f=dijit.getFocus();
var _4=this._getAltViewNode();
if(f.node==ed.iframe||(_4&&f.node===_4)){
setTimeout(dojo.hitch(this,function(){
ed.toolbar.focus();
}),10);
}else{
if(_4&&dojo.style(ed.iframe,"display")==="none"){
setTimeout(dojo.hitch(this,function(){
dijit.focus(_4);
}),10);
}else{
setTimeout(dojo.hitch(this,function(){
ed.focus();
}),10);
}
}
dojo.stopEvent(e);
}else{
if(ed._fullscreen_oldOnKeyDown){
ed._fullscreen_oldOnKeyDown(e);
}
}
}
},_resizeEditor:function(){
var vp=dojo.window.getBox();
dojo.marginBox(this.editor.domNode,{w:vp.w,h:vp.h});
var _5=this.editor.getHeaderHeight();
var _6=this.editor.getFooterHeight();
var _7=dojo._getPadBorderExtents(this.editor.domNode);
var _8=dojo._getPadBorderExtents(this.editor.iframe.parentNode);
var _9=dojo._getMarginExtents(this.editor.iframe.parentNode);
var _a=vp.h-(_5+_7.h+_6);
dojo.marginBox(this.editor.iframe.parentNode,{h:_a,w:vp.w});
dojo.marginBox(this.editor.iframe,{h:_a-(_8.h+_9.h)});
},_getAltViewNode:function(){
},_setFullScreen:function(_b){
var vp=dojo.window.getBox();
var ed=this.editor;
var _c=dojo.body();
var _d=ed.domNode.parentNode;
this.isFullscreen=_b;
if(_b){
while(_d&&_d!==dojo.body()){
dojo.addClass(_d,"dijitForceStatic");
_d=_d.parentNode;
}
this._editorResizeHolder=this.editor.resize;
ed.resize=function(){
};
ed._fullscreen_oldOnKeyDown=ed.onKeyDown;
ed.onKeyDown=dojo.hitch(this,this._containFocus);
this._origState={};
this._origiFrameState={};
var _e=ed.domNode,_f=_e&&_e.style||{};
this._origState={width:_f.width||"",height:_f.height||"",top:dojo.style(_e,"top")||"",left:dojo.style(_e,"left")||"",position:dojo.style(_e,"position")||"static",marginBox:dojo.marginBox(ed.domNode)};
var _10=ed.iframe,_11=_10&&_10.style||{};
var bc=dojo.style(ed.iframe,"backgroundColor");
this._origiFrameState={backgroundColor:bc||"transparent",width:_11.width||"auto",height:_11.height||"auto",zIndex:_11.zIndex||""};
dojo.style(ed.domNode,{position:"absolute",top:"0px",left:"0px",zIndex:this.zIndex,width:vp.w+"px",height:vp.h+"px"});
dojo.style(ed.iframe,{height:"100%",width:"100%",zIndex:this.zIndex,backgroundColor:bc!=="transparent"&&bc!=="rgba(0, 0, 0, 0)"?bc:"white"});
dojo.style(ed.iframe.parentNode,{height:"95%",width:"100%"});
if(_c.style&&_c.style.overflow){
this._oldOverflow=dojo.style(_c,"overflow");
}else{
this._oldOverflow="";
}
if(dojo.isIE&&!dojo.isQuirks){
if(_c.parentNode&&_c.parentNode.style&&_c.parentNode.style.overflow){
this._oldBodyParentOverflow=_c.parentNode.style.overflow;
}else{
try{
this._oldBodyParentOverflow=dojo.style(_c.parentNode,"overflow");
}
catch(e){
this._oldBodyParentOverflow="scroll";
}
}
dojo.style(_c.parentNode,"overflow","hidden");
}
dojo.style(_c,"overflow","hidden");
var _12=function(){
var vp=dojo.window.getBox();
if("_prevW" in this&&"_prevH" in this){
if(vp.w===this._prevW&&vp.h===this._prevH){
return;
}
}else{
this._prevW=vp.w;
this._prevH=vp.h;
}
if(this._resizer){
clearTimeout(this._resizer);
delete this._resizer;
}
this._resizer=setTimeout(dojo.hitch(this,function(){
delete this._resizer;
this._resizeEditor();
}),10);
};
this._resizeHandle=dojo.connect(window,"onresize",this,_12);
this._resizeHandle2=dojo.connect(ed,"resize",dojo.hitch(this,function(){
if(this._resizer){
clearTimeout(this._resizer);
delete this._resizer;
}
this._resizer=setTimeout(dojo.hitch(this,function(){
delete this._resizer;
this._resizeEditor();
}),10);
}));
this._resizeEditor();
var dn=this.editor.toolbar.domNode;
setTimeout(function(){
dojo.window.scrollIntoView(dn);
},250);
}else{
if(this._resizeHandle){
dojo.disconnect(this._resizeHandle);
this._resizeHandle=null;
}
if(this._resizeHandle2){
dojo.disconnect(this._resizeHandle2);
this._resizeHandle2=null;
}
if(this._rst){
clearTimeout(this._rst);
this._rst=null;
}
while(_d&&_d!==dojo.body()){
dojo.removeClass(_d,"dijitForceStatic");
_d=_d.parentNode;
}
if(this._editorResizeHolder){
this.editor.resize=this._editorResizeHolder;
}
if(!this._origState&&!this._origiFrameState){
return;
}
if(ed._fullscreen_oldOnKeyDown){
ed.onKeyDown=ed._fullscreen_oldOnKeyDown;
delete ed._fullscreen_oldOnKeyDown;
}
var _13=this;
setTimeout(function(){
var mb=_13._origState.marginBox;
var oh=_13._origState.height;
if(dojo.isIE&&!dojo.isQuirks){
_c.parentNode.style.overflow=_13._oldBodyParentOverflow;
delete _13._oldBodyParentOverflow;
}
dojo.style(_c,"overflow",_13._oldOverflow);
delete _13._oldOverflow;
dojo.style(ed.domNode,_13._origState);
dojo.style(ed.iframe.parentNode,{height:"",width:""});
dojo.style(ed.iframe,_13._origiFrameState);
delete _13._origState;
delete _13._origiFrameState;
var _14=dijit.getEnclosingWidget(ed.domNode.parentNode);
if(_14&&_14.resize){
_14.resize();
}else{
if(!oh||oh.indexOf("%")<0){
setTimeout(dojo.hitch(this,function(){
ed.resize({h:mb.h});
}),0);
}
}
dojo.window.scrollIntoView(_13.editor.toolbar.domNode);
},100);
}
},destroy:function(){
if(this._resizeHandle){
dojo.disconnect(this._resizeHandle);
this._resizeHandle=null;
}
if(this._resizeHandle2){
dojo.disconnect(this._resizeHandle2);
this._resizeHandle2=null;
}
if(this._resizer){
clearTimeout(this._resizer);
this._resizer=null;
}
this.inherited(arguments);
}});
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
if(o.plugin){
return;
}
var _15=o.args.name.toLowerCase();
if(_15==="fullscreen"){
o.plugin=new dijit._editor.plugins.FullScreen({zIndex:("zIndex" in o.args)?o.args.zIndex:500});
}
});
}

View File

@@ -0,0 +1,236 @@
/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dijit._editor.plugins.LinkDialog"]){
dojo._hasResource["dijit._editor.plugins.LinkDialog"]=true;
dojo.provide("dijit._editor.plugins.LinkDialog");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dijit._editor._Plugin");
dojo.require("dijit.TooltipDialog");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.form.Select");
dojo.require("dijit._editor.range");
dojo.require("dojo.i18n");
dojo.require("dojo.string");
dojo.requireLocalization("dijit","common",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");
dojo.requireLocalization("dijit._editor","LinkDialog",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");
dojo.declare("dijit._editor.plugins.LinkDialog",dijit._editor._Plugin,{buttonClass:dijit.form.DropDownButton,useDefaultCommand:false,urlRegExp:"((https?|ftps?|file)\\://|./|/|)(/[a-zA-Z]{1,1}:/|)(((?:(?:[\\da-zA-Z](?:[-\\da-zA-Z]{0,61}[\\da-zA-Z])?)\\.)*(?:[a-zA-Z](?:[-\\da-zA-Z]{0,80}[\\da-zA-Z])?)\\.?)|(((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])|(0[xX]0*[\\da-fA-F]?[\\da-fA-F]\\.){3}0[xX]0*[\\da-fA-F]?[\\da-fA-F]|(0+[0-3][0-7][0-7]\\.){3}0+[0-3][0-7][0-7]|(0|[1-9]\\d{0,8}|[1-3]\\d{9}|4[01]\\d{8}|42[0-8]\\d{7}|429[0-3]\\d{6}|4294[0-8]\\d{5}|42949[0-5]\\d{4}|429496[0-6]\\d{3}|4294967[01]\\d{2}|42949672[0-8]\\d|429496729[0-5])|0[xX]0*[\\da-fA-F]{1,8}|([\\da-fA-F]{1,4}\\:){7}[\\da-fA-F]{1,4}|([\\da-fA-F]{1,4}\\:){6}((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])))(\\:\\d+)?(/(?:[^?#\\s/]+/)*(?:[^?#\\s/]+(?:\\?[^?#\\s/]*)?(?:#.*)?)?)?",emailRegExp:"<?(mailto\\:)([!#-'*+\\-\\/-9=?A-Z^-~]+[.])*[!#-'*+\\-\\/-9=?A-Z^-~]+"+"@"+"((?:(?:[\\da-zA-Z](?:[-\\da-zA-Z]{0,61}[\\da-zA-Z])?)\\.)+(?:[a-zA-Z](?:[-\\da-zA-Z]{0,6}[\\da-zA-Z])?)\\.?)|localhost|^[^-][a-zA-Z0-9_-]*>?",htmlTemplate:"<a href=\"${urlInput}\" _djrealurl=\"${urlInput}\""+" target=\"${targetSelect}\""+">${textInput}</a>",tag:"a",_hostRxp:new RegExp("^((([^\\[:]+):)?([^@]+)@)?(\\[([^\\]]+)\\]|([^\\[:]*))(:([0-9]+))?$"),_userAtRxp:new RegExp("^([!#-'*+\\-\\/-9=?A-Z^-~]+[.])*[!#-'*+\\-\\/-9=?A-Z^-~]+@","i"),linkDialogTemplate:["<table><tr><td>","<label for='${id}_urlInput'>${url}</label>","</td><td>","<input dojoType='dijit.form.ValidationTextBox' required='true' "+"id='${id}_urlInput' name='urlInput' intermediateChanges='true'>","</td></tr><tr><td>","<label for='${id}_textInput'>${text}</label>","</td><td>","<input dojoType='dijit.form.ValidationTextBox' required='true' id='${id}_textInput' "+"name='textInput' intermediateChanges='true'>","</td></tr><tr><td>","<label for='${id}_targetSelect'>${target}</label>","</td><td>","<select id='${id}_targetSelect' name='targetSelect' dojoType='dijit.form.Select'>","<option selected='selected' value='_self'>${currentWindow}</option>","<option value='_blank'>${newWindow}</option>","<option value='_top'>${topWindow}</option>","<option value='_parent'>${parentWindow}</option>","</select>","</td></tr><tr><td colspan='2'>","<button dojoType='dijit.form.Button' type='submit' id='${id}_setButton'>${set}</button>","<button dojoType='dijit.form.Button' type='button' id='${id}_cancelButton'>${buttonCancel}</button>","</td></tr></table>"].join(""),_initButton:function(){
var _1=this;
this.tag=this.command=="insertImage"?"img":"a";
var _2=dojo.mixin(dojo.i18n.getLocalization("dijit","common",this.lang),dojo.i18n.getLocalization("dijit._editor","LinkDialog",this.lang));
var _3=(this.dropDown=new dijit.TooltipDialog({title:_2[this.command+"Title"],execute:dojo.hitch(this,"setValue"),onOpen:function(){
_1._onOpenDialog();
dijit.TooltipDialog.prototype.onOpen.apply(this,arguments);
},onCancel:function(){
setTimeout(dojo.hitch(_1,"_onCloseDialog"),0);
}}));
_2.urlRegExp=this.urlRegExp;
_2.id=dijit.getUniqueId(this.editor.id);
this._uniqueId=_2.id;
this._setContent(_3.title+"<div style='border-bottom: 1px black solid;padding-bottom:2pt;margin-bottom:4pt'></div>"+dojo.string.substitute(this.linkDialogTemplate,_2));
_3.startup();
this._urlInput=dijit.byId(this._uniqueId+"_urlInput");
this._textInput=dijit.byId(this._uniqueId+"_textInput");
this._setButton=dijit.byId(this._uniqueId+"_setButton");
this.connect(dijit.byId(this._uniqueId+"_cancelButton"),"onClick",function(){
this.dropDown.onCancel();
});
if(this._urlInput){
this.connect(this._urlInput,"onChange","_checkAndFixInput");
}
if(this._textInput){
this.connect(this._textInput,"onChange","_checkAndFixInput");
}
this._urlRegExp=new RegExp("^"+this.urlRegExp+"$","i");
this._emailRegExp=new RegExp("^"+this.emailRegExp+"$","i");
this._urlInput.isValid=dojo.hitch(this,function(){
var _4=this._urlInput.get("value");
return this._urlRegExp.test(_4)||this._emailRegExp.test(_4);
});
this._connectTagEvents();
this.inherited(arguments);
},_checkAndFixInput:function(){
var _5=this;
var _6=this._urlInput.get("value");
var _7=function(_8){
var _9=false;
var _a=false;
if(_8&&_8.length>1){
_8=dojo.trim(_8);
if(_8.indexOf("mailto:")!==0){
if(_8.indexOf("/")>0){
if(_8.indexOf("://")===-1){
if(_8.charAt(0)!=="/"&&_8.indexOf("./")!==0){
if(_5._hostRxp.test(_8)){
_9=true;
}
}
}
}else{
if(_5._userAtRxp.test(_8)){
_a=true;
}
}
}
}
if(_9){
_5._urlInput.set("value","http://"+_8);
}
if(_a){
_5._urlInput.set("value","mailto:"+_8);
}
_5._setButton.set("disabled",!_5._isValid());
};
if(this._delayedCheck){
clearTimeout(this._delayedCheck);
this._delayedCheck=null;
}
this._delayedCheck=setTimeout(function(){
_7(_6);
},250);
},_connectTagEvents:function(){
this.editor.onLoadDeferred.addCallback(dojo.hitch(this,function(){
this.connect(this.editor.editNode,"ondblclick",this._onDblClick);
}));
},_isValid:function(){
return this._urlInput.isValid()&&this._textInput.isValid();
},_setContent:function(_b){
this.dropDown.set("content",_b);
},_checkValues:function(_c){
if(_c&&_c.urlInput){
_c.urlInput=_c.urlInput.replace(/"/g,"&quot;");
}
return _c;
},setValue:function(_d){
this._onCloseDialog();
if(dojo.isIE){
var _e=dijit.range.getSelection(this.editor.window);
var _f=_e.getRangeAt(0);
var a=_f.endContainer;
if(a.nodeType===3){
a=a.parentNode;
}
if(a&&(a.nodeName&&a.nodeName.toLowerCase()!==this.tag)){
a=dojo.withGlobal(this.editor.window,"getSelectedElement",dijit._editor.selection,[this.tag]);
}
if(a&&(a.nodeName&&a.nodeName.toLowerCase()===this.tag)){
if(this.editor.queryCommandEnabled("unlink")){
dojo.withGlobal(this.editor.window,"selectElementChildren",dijit._editor.selection,[a]);
this.editor.execCommand("unlink");
}
}
}
_d=this._checkValues(_d);
this.editor.execCommand("inserthtml",dojo.string.substitute(this.htmlTemplate,_d));
},_onCloseDialog:function(){
this.editor.focus();
},_getCurrentValues:function(a){
var url,_10,_11;
if(a&&a.tagName.toLowerCase()===this.tag){
url=a.getAttribute("_djrealurl")||a.getAttribute("href");
_11=a.getAttribute("target")||"_self";
_10=a.textContent||a.innerText;
dojo.withGlobal(this.editor.window,"selectElement",dijit._editor.selection,[a,true]);
}else{
_10=dojo.withGlobal(this.editor.window,dijit._editor.selection.getSelectedText);
}
return {urlInput:url||"",textInput:_10||"",targetSelect:_11||""};
},_onOpenDialog:function(){
var a;
if(dojo.isIE){
var sel=dijit.range.getSelection(this.editor.window);
var _12=sel.getRangeAt(0);
a=_12.endContainer;
if(a.nodeType===3){
a=a.parentNode;
}
if(a&&(a.nodeName&&a.nodeName.toLowerCase()!==this.tag)){
a=dojo.withGlobal(this.editor.window,"getSelectedElement",dijit._editor.selection,[this.tag]);
}
}else{
a=dojo.withGlobal(this.editor.window,"getAncestorElement",dijit._editor.selection,[this.tag]);
}
this.dropDown.reset();
this._setButton.set("disabled",true);
this.dropDown.set("value",this._getCurrentValues(a));
},_onDblClick:function(e){
if(e&&e.target){
var t=e.target;
var tg=t.tagName?t.tagName.toLowerCase():"";
if(tg===this.tag&&dojo.attr(t,"href")){
dojo.withGlobal(this.editor.window,"selectElement",dijit._editor.selection,[t]);
this.editor.onDisplayChanged();
setTimeout(dojo.hitch(this,function(){
this.button.set("disabled",false);
this.button.openDropDown();
}),10);
}
}
}});
dojo.declare("dijit._editor.plugins.ImgLinkDialog",[dijit._editor.plugins.LinkDialog],{linkDialogTemplate:["<table><tr><td>","<label for='${id}_urlInput'>${url}</label>","</td><td>","<input dojoType='dijit.form.ValidationTextBox' regExp='${urlRegExp}' "+"required='true' id='${id}_urlInput' name='urlInput' intermediateChanges='true'>","</td></tr><tr><td>","<label for='${id}_textInput'>${text}</label>","</td><td>","<input dojoType='dijit.form.ValidationTextBox' required='false' id='${id}_textInput' "+"name='textInput' intermediateChanges='true'>","</td></tr><tr><td>","</td><td>","</td></tr><tr><td colspan='2'>","<button dojoType='dijit.form.Button' type='submit' id='${id}_setButton'>${set}</button>","<button dojoType='dijit.form.Button' type='button' id='${id}_cancelButton'>${buttonCancel}</button>","</td></tr></table>"].join(""),htmlTemplate:"<img src=\"${urlInput}\" _djrealurl=\"${urlInput}\" alt=\"${textInput}\" />",tag:"img",_getCurrentValues:function(img){
var url,_13;
if(img&&img.tagName.toLowerCase()===this.tag){
url=img.getAttribute("_djrealurl")||img.getAttribute("src");
_13=img.getAttribute("alt");
dojo.withGlobal(this.editor.window,"selectElement",dijit._editor.selection,[img,true]);
}else{
_13=dojo.withGlobal(this.editor.window,dijit._editor.selection.getSelectedText);
}
return {urlInput:url||"",textInput:_13||""};
},_isValid:function(){
return this._urlInput.isValid();
},_connectTagEvents:function(){
this.inherited(arguments);
this.editor.onLoadDeferred.addCallback(dojo.hitch(this,function(){
this.connect(this.editor.editNode,"onmousedown",this._selectTag);
}));
},_selectTag:function(e){
if(e&&e.target){
var t=e.target;
var tg=t.tagName?t.tagName.toLowerCase():"";
if(tg===this.tag){
dojo.withGlobal(this.editor.window,"selectElement",dijit._editor.selection,[t]);
}
}
},_checkValues:function(_14){
if(_14&&_14.urlInput){
_14.urlInput=_14.urlInput.replace(/"/g,"&quot;");
}
if(_14&&_14.textInput){
_14.textInput=_14.textInput.replace(/"/g,"&quot;");
}
return _14;
},_onDblClick:function(e){
if(e&&e.target){
var t=e.target;
var tg=t.tagName?t.tagName.toLowerCase():"";
if(tg===this.tag&&dojo.attr(t,"src")){
dojo.withGlobal(this.editor.window,"selectElement",dijit._editor.selection,[t]);
this.editor.onDisplayChanged();
setTimeout(dojo.hitch(this,function(){
this.button.set("disabled",false);
this.button.openDropDown();
}),10);
}
}
}});
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
if(o.plugin){
return;
}
switch(o.args.name){
case "createLink":
o.plugin=new dijit._editor.plugins.LinkDialog({command:o.args.name});
break;
case "insertImage":
o.plugin=new dijit._editor.plugins.ImgLinkDialog({command:o.args.name});
break;
}
});
}

View File

@@ -0,0 +1,36 @@
/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dijit._editor.plugins.NewPage"]){
dojo._hasResource["dijit._editor.plugins.NewPage"]=true;
dojo.provide("dijit._editor.plugins.NewPage");
dojo.require("dijit._editor._Plugin");
dojo.require("dijit.form.Button");
dojo.require("dojo.i18n");
dojo.requireLocalization("dijit._editor","commands",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");
dojo.declare("dijit._editor.plugins.NewPage",dijit._editor._Plugin,{content:"<br>",_initButton:function(){
var _1=dojo.i18n.getLocalization("dijit._editor","commands"),_2=this.editor;
this.button=new dijit.form.Button({label:_1["newPage"],dir:_2.dir,lang:_2.lang,showLabel:false,iconClass:this.iconClassPrefix+" "+this.iconClassPrefix+"NewPage",tabIndex:"-1",onClick:dojo.hitch(this,"_newPage")});
},setEditor:function(_3){
this.editor=_3;
this._initButton();
},_newPage:function(){
this.editor.beginEditing();
this.editor.set("value",this.content);
this.editor.endEditing();
this.editor.focus();
}});
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
if(o.plugin){
return;
}
var _4=o.args.name.toLowerCase();
if(_4==="newpage"){
o.plugin=new dijit._editor.plugins.NewPage({content:("content" in o.args)?o.args.content:"<br>"});
}
});
}

View File

@@ -0,0 +1,65 @@
/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dijit._editor.plugins.Print"]){
dojo._hasResource["dijit._editor.plugins.Print"]=true;
dojo.provide("dijit._editor.plugins.Print");
dojo.require("dijit._editor._Plugin");
dojo.require("dijit.form.Button");
dojo.require("dojo.i18n");
dojo.requireLocalization("dijit._editor","commands",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");
dojo.declare("dijit._editor.plugins.Print",dijit._editor._Plugin,{_initButton:function(){
var _1=dojo.i18n.getLocalization("dijit._editor","commands"),_2=this.editor;
this.button=new dijit.form.Button({label:_1["print"],dir:_2.dir,lang:_2.lang,showLabel:false,iconClass:this.iconClassPrefix+" "+this.iconClassPrefix+"Print",tabIndex:"-1",onClick:dojo.hitch(this,"_print")});
},setEditor:function(_3){
this.editor=_3;
this._initButton();
this.editor.onLoadDeferred.addCallback(dojo.hitch(this,function(){
if(!this.editor.iframe.contentWindow["print"]){
this.button.set("disabled",true);
}
}));
},_print:function(){
var _4=this.editor.iframe;
if(_4.contentWindow["print"]){
if(!dojo.isOpera&&!dojo.isChrome){
dijit.focus(_4);
_4.contentWindow.print();
}else{
var _5=this.editor.document;
var _6=this.editor.get("value");
_6="<html><head><meta http-equiv='Content-Type' "+"content='text/html; charset='UTF-8'></head><body>"+_6+"</body></html>";
var _7=window.open("javascript: ''","","status=0,menubar=0,location=0,toolbar=0,"+"width=1,height=1,resizable=0,scrollbars=0");
_7.document.open();
_7.document.write(_6);
_7.document.close();
var _8=[];
var _9=_5.getElementsByTagName("style");
if(_9){
var i;
for(i=0;i<_9.length;i++){
var _a=_9[i].innerHTML;
var _b=_7.document.createElement("style");
_b.appendChild(_7.document.createTextNode(_a));
_7.document.getElementsByTagName("head")[0].appendChild(_b);
}
}
_7.print();
_7.close();
}
}
}});
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
if(o.plugin){
return;
}
var _c=o.args.name.toLowerCase();
if(_c==="print"){
o.plugin=new dijit._editor.plugins.Print({command:"print"});
}
});
}

View File

@@ -0,0 +1,33 @@
/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dijit._editor.plugins.TabIndent"]){
dojo._hasResource["dijit._editor.plugins.TabIndent"]=true;
dojo.provide("dijit._editor.plugins.TabIndent");
dojo.experimental("dijit._editor.plugins.TabIndent");
dojo.require("dijit._editor._Plugin");
dojo.require("dijit.form.ToggleButton");
dojo.declare("dijit._editor.plugins.TabIndent",dijit._editor._Plugin,{useDefaultCommand:false,buttonClass:dijit.form.ToggleButton,command:"tabIndent",_initButton:function(){
this.inherited(arguments);
var e=this.editor;
this.connect(this.button,"onChange",function(_1){
e.set("isTabIndent",_1);
});
this.updateState();
},updateState:function(){
this.button.set("checked",this.editor.isTabIndent,false);
}});
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
if(o.plugin){
return;
}
switch(o.args.name){
case "tabIndent":
o.plugin=new dijit._editor.plugins.TabIndent({command:o.args.name});
}
});
}

View File

@@ -0,0 +1,62 @@
/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dijit._editor.plugins.TextColor"]){
dojo._hasResource["dijit._editor.plugins.TextColor"]=true;
dojo.provide("dijit._editor.plugins.TextColor");
dojo.require("dijit._editor._Plugin");
dojo.require("dijit.ColorPalette");
dojo.declare("dijit._editor.plugins.TextColor",dijit._editor._Plugin,{buttonClass:dijit.form.DropDownButton,useDefaultCommand:false,constructor:function(){
this.dropDown=new dijit.ColorPalette();
this.connect(this.dropDown,"onChange",function(_1){
this.editor.execCommand(this.command,_1);
});
},updateState:function(){
var _2=this.editor;
var _3=this.command;
if(!_2||!_2.isLoaded||!_3.length){
return;
}
if(this.button){
var _4;
try{
_4=_2.queryCommandValue(_3)||"";
}
catch(e){
_4="";
}
}
if(_4==""){
_4="#000000";
}
if(_4=="transparent"){
_4="#ffffff";
}
if(typeof _4=="string"){
if(_4.indexOf("rgb")>-1){
_4=dojo.colorFromRgb(_4).toHex();
}
}else{
_4=((_4&255)<<16)|(_4&65280)|((_4&16711680)>>>16);
_4=_4.toString(16);
_4="#000000".slice(0,7-_4.length)+_4;
}
if(_4!==this.dropDown.get("value")){
this.dropDown.set("value",_4,false);
}
}});
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
if(o.plugin){
return;
}
switch(o.args.name){
case "foreColor":
case "hiliteColor":
o.plugin=new dijit._editor.plugins.TextColor({command:o.args.name});
}
});
}

View File

@@ -0,0 +1,42 @@
/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dijit._editor.plugins.ToggleDir"]){
dojo._hasResource["dijit._editor.plugins.ToggleDir"]=true;
dojo.provide("dijit._editor.plugins.ToggleDir");
dojo.experimental("dijit._editor.plugins.ToggleDir");
dojo.require("dijit._editor._Plugin");
dojo.require("dijit.form.ToggleButton");
dojo.declare("dijit._editor.plugins.ToggleDir",dijit._editor._Plugin,{useDefaultCommand:false,command:"toggleDir",buttonClass:dijit.form.ToggleButton,_initButton:function(){
this.inherited(arguments);
this.editor.onLoadDeferred.addCallback(dojo.hitch(this,function(){
var _1=this.editor.editorObject.contentWindow.document.documentElement;
_1=_1.getElementsByTagName("body")[0];
var _2=dojo.getComputedStyle(_1).direction=="ltr";
this.button.set("checked",!_2);
this.connect(this.button,"onChange","_setRtl");
}));
},updateState:function(){
},_setRtl:function(_3){
var _4="ltr";
if(_3){
_4="rtl";
}
var _5=this.editor.editorObject.contentWindow.document.documentElement;
_5=_5.getElementsByTagName("body")[0];
_5.dir=_4;
}});
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
if(o.plugin){
return;
}
switch(o.args.name){
case "toggleDir":
o.plugin=new dijit._editor.plugins.ToggleDir({command:o.args.name});
}
});
}

View File

@@ -0,0 +1,317 @@
/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dijit._editor.plugins.ViewSource"]){
dojo._hasResource["dijit._editor.plugins.ViewSource"]=true;
dojo.provide("dijit._editor.plugins.ViewSource");
dojo.require("dojo.window");
dojo.require("dojo.i18n");
dojo.require("dijit._editor._Plugin");
dojo.require("dijit.form.Button");
dojo.requireLocalization("dijit._editor","commands",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");
dojo.declare("dijit._editor.plugins.ViewSource",dijit._editor._Plugin,{stripScripts:true,stripComments:true,stripIFrames:true,readOnly:false,_fsPlugin:null,toggle:function(){
if(dojo.isWebKit){
this._vsFocused=true;
}
this.button.set("checked",!this.button.get("checked"));
},_initButton:function(){
var _1=dojo.i18n.getLocalization("dijit._editor","commands"),_2=this.editor;
this.button=new dijit.form.ToggleButton({label:_1["viewSource"],dir:_2.dir,lang:_2.lang,showLabel:false,iconClass:this.iconClassPrefix+" "+this.iconClassPrefix+"ViewSource",tabIndex:"-1",onChange:dojo.hitch(this,"_showSource")});
if(dojo.isIE==7){
this._ieFixNode=dojo.create("div",{style:{opacity:"0",zIndex:"-1000",position:"absolute",top:"-1000px"}},dojo.body());
}
this.button.set("readOnly",false);
},setEditor:function(_3){
this.editor=_3;
this._initButton();
this.editor.addKeyHandler(dojo.keys.F12,true,true,dojo.hitch(this,function(e){
this.button.focus();
this.toggle();
dojo.stopEvent(e);
setTimeout(dojo.hitch(this,function(){
this.editor.focus();
}),100);
}));
},_showSource:function(_4){
var ed=this.editor;
var _5=ed._plugins;
var _6;
this._sourceShown=_4;
var _7=this;
try{
if(!this.sourceArea){
this._createSourceView();
}
if(_4){
ed._sourceQueryCommandEnabled=ed.queryCommandEnabled;
ed.queryCommandEnabled=function(_8){
var _9=_8.toLowerCase();
if(_9==="viewsource"){
return true;
}else{
return false;
}
};
this.editor.onDisplayChanged();
_6=ed.get("value");
_6=this._filter(_6);
ed.set("value",_6);
this._pluginList=[];
this._disabledPlugins=dojo.filter(_5,function(p){
if(p&&p.button&&!p.button.get("disabled")&&!(p instanceof dijit._editor.plugins.ViewSource)){
p._vs_updateState=p.updateState;
p.updateState=function(){
return false;
};
p.button.set("disabled",true);
if(p.command){
switch(p.command){
case "bold":
case "italic":
case "underline":
case "strikethrough":
case "superscript":
case "subscript":
p.button.set("checked",false);
break;
default:
break;
}
}
return true;
}
});
if(this._fsPlugin){
this._fsPlugin._getAltViewNode=function(){
return _7.sourceArea;
};
}
this.sourceArea.value=_6;
var is=dojo.marginBox(ed.iframe.parentNode);
dojo.marginBox(this.sourceArea,{w:is.w,h:is.h});
dojo.style(ed.iframe,"display","none");
dojo.style(this.sourceArea,{display:"block"});
var _a=function(){
var vp=dojo.window.getBox();
if("_prevW" in this&&"_prevH" in this){
if(vp.w===this._prevW&&vp.h===this._prevH){
return;
}else{
this._prevW=vp.w;
this._prevH=vp.h;
}
}else{
this._prevW=vp.w;
this._prevH=vp.h;
}
if(this._resizer){
clearTimeout(this._resizer);
delete this._resizer;
}
this._resizer=setTimeout(dojo.hitch(this,function(){
delete this._resizer;
this._resize();
}),10);
};
this._resizeHandle=dojo.connect(window,"onresize",this,_a);
setTimeout(dojo.hitch(this,this._resize),100);
this.editor.onNormalizedDisplayChanged();
}else{
if(!ed._sourceQueryCommandEnabled){
return;
}
dojo.disconnect(this._resizeHandle);
delete this._resizeHandle;
ed.queryCommandEnabled=ed._sourceQueryCommandEnabled;
if(!this._readOnly){
_6=this.sourceArea.value;
_6=this._filter(_6);
ed.beginEditing();
ed.set("value",_6);
ed.endEditing();
}
dojo.forEach(this._disabledPlugins,function(p){
p.button.set("disabled",false);
if(p._vs_updateState){
p.updateState=p._vs_updateState;
}
});
this._disabledPlugins=null;
dojo.style(this.sourceArea,"display","none");
dojo.style(ed.iframe,"display","block");
delete ed._sourceQueryCommandEnabled;
this.editor.onDisplayChanged();
}
setTimeout(dojo.hitch(this,function(){
var _b=ed.domNode.parentNode;
if(_b){
var _c=dijit.getEnclosingWidget(_b);
if(_c&&_c.resize){
_c.resize();
}
}
ed.resize();
}),300);
}
catch(e){
}
},_resize:function(){
var ed=this.editor;
var _d=ed.getHeaderHeight();
var fH=ed.getFooterHeight();
var eb=dojo.position(ed.domNode);
var _e=dojo._getPadBorderExtents(ed.iframe.parentNode);
var _f=dojo._getMarginExtents(ed.iframe.parentNode);
var _10=dojo._getPadBorderExtents(ed.domNode);
var _11=dojo._getMarginExtents(ed.domNode);
var edb={w:eb.w-(_10.w+_11.w),h:eb.h-(_d+_10.h+_11.h+fH)};
if(this._fsPlugin&&this._fsPlugin.isFullscreen){
var vp=dojo.window.getBox();
edb.w=(vp.w-_10.w);
edb.h=(vp.h-(_d+_10.h+fH));
}
if(dojo.isIE){
edb.h-=2;
}
if(this._ieFixNode){
var _12=-this._ieFixNode.offsetTop/1000;
edb.w=Math.floor((edb.w+0.9)/_12);
edb.h=Math.floor((edb.h+0.9)/_12);
}
dojo.marginBox(this.sourceArea,{w:edb.w-(_e.w+_f.w),h:edb.h-(_e.h+_f.h)});
dojo.marginBox(ed.iframe.parentNode,{h:edb.h});
},_createSourceView:function(){
var ed=this.editor;
var _13=ed._plugins;
this.sourceArea=dojo.create("textarea");
if(this.readOnly){
dojo.attr(this.sourceArea,"readOnly",true);
this._readOnly=true;
}
dojo.style(this.sourceArea,{padding:"0px",margin:"0px",borderWidth:"0px",borderStyle:"none"});
dojo.place(this.sourceArea,ed.iframe,"before");
if(dojo.isIE&&ed.iframe.parentNode.lastChild!==ed.iframe){
dojo.style(ed.iframe.parentNode.lastChild,{width:"0px",height:"0px",padding:"0px",margin:"0px",borderWidth:"0px",borderStyle:"none"});
}
ed._viewsource_oldFocus=ed.focus;
var _14=this;
ed.focus=function(){
if(_14._sourceShown){
_14.setSourceAreaCaret();
}else{
try{
if(this._vsFocused){
delete this._vsFocused;
dijit.focus(ed.editNode);
}else{
ed._viewsource_oldFocus();
}
}
catch(e){
}
}
};
var i,p;
for(i=0;i<_13.length;i++){
p=_13[i];
if(p&&(p.declaredClass==="dijit._editor.plugins.FullScreen"||p.declaredClass===(dijit._scopeName+"._editor.plugins.FullScreen"))){
this._fsPlugin=p;
break;
}
}
if(this._fsPlugin){
this._fsPlugin._viewsource_getAltViewNode=this._fsPlugin._getAltViewNode;
this._fsPlugin._getAltViewNode=function(){
return _14._sourceShown?_14.sourceArea:this._viewsource_getAltViewNode();
};
}
this.connect(this.sourceArea,"onkeydown",dojo.hitch(this,function(e){
if(this._sourceShown&&e.keyCode==dojo.keys.F12&&e.ctrlKey&&e.shiftKey){
this.button.focus();
this.button.set("checked",false);
setTimeout(dojo.hitch(this,function(){
ed.focus();
}),100);
dojo.stopEvent(e);
}
}));
},_stripScripts:function(_15){
if(_15){
_15=_15.replace(/<\s*script[^>]*>((.|\s)*?)<\\?\/\s*script\s*>/ig,"");
_15=_15.replace(/<\s*script\b([^<>]|\s)*>?/ig,"");
_15=_15.replace(/<[^>]*=(\s|)*[("|')]javascript:[^$1][(\s|.)]*[$1][^>]*>/ig,"");
}
return _15;
},_stripComments:function(_16){
if(_16){
_16=_16.replace(/<!--(.|\s){1,}?-->/g,"");
}
return _16;
},_stripIFrames:function(_17){
if(_17){
_17=_17.replace(/<\s*iframe[^>]*>((.|\s)*?)<\\?\/\s*iframe\s*>/ig,"");
}
return _17;
},_filter:function(_18){
if(_18){
if(this.stripScripts){
_18=this._stripScripts(_18);
}
if(this.stripComments){
_18=this._stripComments(_18);
}
if(this.stripIFrames){
_18=this._stripIFrames(_18);
}
}
return _18;
},setSourceAreaCaret:function(){
var win=dojo.global;
var _19=this.sourceArea;
dijit.focus(_19);
if(this._sourceShown&&!this.readOnly){
if(dojo.isIE){
if(this.sourceArea.createTextRange){
var _1a=_19.createTextRange();
_1a.collapse(true);
_1a.moveStart("character",-99999);
_1a.moveStart("character",0);
_1a.moveEnd("character",0);
_1a.select();
}
}else{
if(win.getSelection){
if(_19.setSelectionRange){
_19.setSelectionRange(0,0);
}
}
}
}
},destroy:function(){
if(this._ieFixNode){
dojo.body().removeChild(this._ieFixNode);
}
if(this._resizer){
clearTimeout(this._resizer);
delete this._resizer;
}
if(this._resizeHandle){
dojo.disconnect(this._resizeHandle);
delete this._resizeHandle;
}
this.inherited(arguments);
}});
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
if(o.plugin){
return;
}
var _1b=o.args.name.toLowerCase();
if(_1b==="viewsource"){
o.plugin=new dijit._editor.plugins.ViewSource({readOnly:("readOnly" in o.args)?o.args.readOnly:false,stripComments:("stripComments" in o.args)?o.args.stripComments:true,stripScripts:("stripScripts" in o.args)?o.args.stripScripts:true,stripIFrames:("stripIFrames" in o.args)?o.args.stripIFrames:true});
}
});
}