root / trunk / web / dojo / dojox / editor / plugins / ShowBlockNodes.js
History | View | Annotate | Download (3.17 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.editor.plugins.ShowBlockNodes"]){ |
9 |
dojo._hasResource["dojox.editor.plugins.ShowBlockNodes"]=true; |
10 |
dojo.provide("dojox.editor.plugins.ShowBlockNodes");
|
11 |
dojo.require("dijit._editor._Plugin");
|
12 |
dojo.require("dijit.form.Button");
|
13 |
dojo.require("dojo.i18n");
|
14 |
dojo.requireLocalization("dojox.editor.plugins","ShowBlockNodes",null,"ROOT,cs,de,es,fr,hu,it,ja,ko,pl,pt,ro,ru,zh,zh-tw"); |
15 |
dojo.declare("dojox.editor.plugins.ShowBlockNodes",dijit._editor._Plugin,{useDefaultCommand:false,iconClassPrefix:"dijitAdditionalEditorIcon",_styled:false,_initButton:function(){ |
16 |
var _1=dojo.i18n.getLocalization("dojox.editor.plugins","ShowBlockNodes"); |
17 |
this.button=new dijit.form.ToggleButton({label:_1["showBlockNodes"],showLabel:false,iconClass:this.iconClassPrefix+" "+this.iconClassPrefix+"ShowBlockNodes",tabIndex:"-1",onChange:dojo.hitch(this,"_showBlocks")}); |
18 |
this.editor.addKeyHandler(dojo.keys.F9,true,true,dojo.hitch(this,this.toggle)); |
19 |
},setEditor:function(_2){ |
20 |
this.editor=_2;
|
21 |
this._initButton();
|
22 |
},toggle:function(){ |
23 |
this.button.set("checked",!this.button.get("checked")); |
24 |
},_showBlocks:function(_3){ |
25 |
var _4=this.editor.document; |
26 |
if(!this._styled){ |
27 |
try{
|
28 |
this._styled=true; |
29 |
var _5=""; |
30 |
var _6=["div","p","ul","ol","table","h1","h2","h3","h4","h5","h6","pre","dir","center","blockquote","form","fieldset","address","object","pre","hr","ins","noscript","li","map","button","dd","dt"]; |
31 |
var _7="@media screen {\n"+"\t.editorShowBlocks {TAG} {\n"+"\t\tbackground-image: url({MODURL}/images/blockelems/{TAG}.gif);\n"+"\t\tbackground-repeat: no-repeat;\n"+"\t\tbackground-position: top left;\n"+"\t\tborder-width: 1px;\n"+"\t\tborder-style: dashed;\n"+"\t\tborder-color: #D0D0D0;\n"+"\t\tpadding-top: 15px;\n"+"\t\tpadding-left: 15px;\n"+"\t}\n"+"}\n"; |
32 |
dojo.forEach(_6,function(_8){
|
33 |
_5+=_7.replace(/\{TAG\}/gi,_8);
|
34 |
}); |
35 |
var _9=dojo.moduleUrl(dojox._scopeName,"editor/plugins/resources").toString(); |
36 |
if(!(_9.match(/^https?:\/\//i))&&!(_9.match(/^file:\/\//i))){ |
37 |
var _a;
|
38 |
if(_9.charAt(0)==="/"){ |
39 |
var _b=dojo.doc.location.protocol;
|
40 |
var _c=dojo.doc.location.host;
|
41 |
_a=_b+"//"+_c;
|
42 |
}else{
|
43 |
_a=this._calcBaseUrl(dojo.global.location.href);
|
44 |
} |
45 |
if(_a[_a.length-1]!=="/"&&_9.charAt(0)!=="/"){ |
46 |
_a+="/";
|
47 |
} |
48 |
_9=_a+_9; |
49 |
} |
50 |
_5=_5.replace(/\{MODURL\}/gi,_9);
|
51 |
if(!dojo.isIE){
|
52 |
var _d=_4.createElement("style"); |
53 |
_d.appendChild(_4.createTextNode(_5)); |
54 |
_4.getElementsByTagName("head")[0].appendChild(_d); |
55 |
}else{
|
56 |
var ss=_4.createStyleSheet(""); |
57 |
ss.cssText=_5; |
58 |
} |
59 |
} |
60 |
catch(e){
|
61 |
console.warn(e); |
62 |
} |
63 |
} |
64 |
if(_3){
|
65 |
dojo.addClass(this.editor.editNode,"editorShowBlocks"); |
66 |
}else{
|
67 |
dojo.removeClass(this.editor.editNode,"editorShowBlocks"); |
68 |
} |
69 |
},_calcBaseUrl:function(_e){ |
70 |
var _f=null; |
71 |
if(_e!==null){ |
72 |
var _10=_e.indexOf("?"); |
73 |
if(_10!=-1){ |
74 |
_e=_e.substring(0,_10);
|
75 |
} |
76 |
_10=_e.lastIndexOf("/");
|
77 |
if(_10>0&&_10<_e.length){ |
78 |
_f=_e.substring(0,_10);
|
79 |
}else{
|
80 |
_f=_e; |
81 |
} |
82 |
} |
83 |
return _f;
|
84 |
}}); |
85 |
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){ |
86 |
if(o.plugin){
|
87 |
return;
|
88 |
} |
89 |
var _11=o.args.name.toLowerCase();
|
90 |
if(_11==="showblocknodes"){ |
91 |
o.plugin=new dojox.editor.plugins.ShowBlockNodes();
|
92 |
} |
93 |
}); |
94 |
} |