root / trunk / web / dojo / dojox / editor / plugins / Preview.js
History | View | Annotate | Download (2.02 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.Preview"]){ |
9 |
dojo._hasResource["dojox.editor.plugins.Preview"]=true; |
10 |
dojo.provide("dojox.editor.plugins.Preview");
|
11 |
dojo.require("dijit._editor._Plugin");
|
12 |
dojo.require("dijit.form.Button");
|
13 |
dojo.require("dojo.i18n");
|
14 |
dojo.requireLocalization("dojox.editor.plugins","Preview",null,"ROOT,cs,de,es,fr,hu,it,ja,ko,pl,pt,ro,ru,zh,zh-tw"); |
15 |
dojo.declare("dojox.editor.plugins.Preview",dijit._editor._Plugin,{useDefaultCommand:false,styles:"",stylesheets:null,iconClassPrefix:"dijitAdditionalEditorIcon",_initButton:function(){ |
16 |
this._nlsResources=dojo.i18n.getLocalization("dojox.editor.plugins","Preview"); |
17 |
this.button=new dijit.form.Button({label:this._nlsResources["preview"],showLabel:false,iconClass:this.iconClassPrefix+" "+this.iconClassPrefix+"Preview",tabIndex:"-1",onClick:dojo.hitch(this,"_preview")}); |
18 |
},setEditor:function(_1){ |
19 |
this.editor=_1;
|
20 |
this._initButton();
|
21 |
},_preview:function(){ |
22 |
try{
|
23 |
var _2=this.editor.get("value"); |
24 |
var _3="\t\t<meta http-equiv='Content-Type' content='text/html; charset='UTF-8'>\n"; |
25 |
var i;
|
26 |
if(this.stylesheets){ |
27 |
for(i=0;i<this.stylesheets.length;i++){ |
28 |
_3+="\t\t<link rel='stylesheet' type='text/css' href='"+this.stylesheets[i]+"'>\n"; |
29 |
} |
30 |
} |
31 |
if(this.styles){ |
32 |
_3+=("\t\t<style>"+this.styles+"</style>\n"); |
33 |
} |
34 |
_2="<html>\n\t<head>\n"+_3+"\t</head>\n\t<body>\n"+_2+"\n\t</body>\n</html>"; |
35 |
var _4=window.open("javascript: ''",this._nlsResources["preview"],"status=1,menubar=0,location=0,toolbar=0"); |
36 |
_4.document.open(); |
37 |
_4.document.write(_2); |
38 |
_4.document.close(); |
39 |
} |
40 |
catch(e){
|
41 |
console.warn(e); |
42 |
} |
43 |
}}); |
44 |
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){ |
45 |
if(o.plugin){
|
46 |
return;
|
47 |
} |
48 |
var _5=o.args.name.toLowerCase();
|
49 |
if(_5==="preview"){ |
50 |
o.plugin=new dojox.editor.plugins.Preview({styles:("styles" in o.args)?o.args.styles:"",stylesheets:("stylesheets" in o.args)?o.args.stylesheets:null}); |
51 |
} |
52 |
}); |
53 |
} |