Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / editor / plugins / Save.js

History | View | Annotate | Download (1.81 KB)

1 9 andrej.cim
/*
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.Save"]){
9
dojo._hasResource["dojox.editor.plugins.Save"]=true;
10
dojo.provide("dojox.editor.plugins.Save");
11
dojo.require("dijit._editor._Plugin");
12
dojo.require("dijit.form.Button");
13
dojo.require("dojo.i18n");
14
dojo.requireLocalization("dojox.editor.plugins","Save",null,"ROOT,cs,de,es,fr,hu,it,ja,ko,pl,pt,ro,ru,zh,zh-tw");
15
dojo.declare("dojox.editor.plugins.Save",dijit._editor._Plugin,{iconClassPrefix:"dijitAdditionalEditorIcon",url:"",logResults:true,_initButton:function(){
16
var _1=dojo.i18n.getLocalization("dojox.editor.plugins","Save");
17
this.button=new dijit.form.Button({label:_1["save"],showLabel:false,iconClass:this.iconClassPrefix+" "+this.iconClassPrefix+"Save",tabIndex:"-1",onClick:dojo.hitch(this,"_save")});
18
},setEditor:function(_2){
19
this.editor=_2;
20
this._initButton();
21
},_save:function(){
22
var _3=this.editor.get("value");
23
this.save(_3);
24
},save:function(_4){
25
var _5={"Content-Type":"text/html"};
26
if(this.url){
27
var _6={url:this.url,postData:_4,headers:_5,handleAs:"text"};
28
this.button.set("disabled",true);
29
var _7=dojo.xhrPost(_6);
30
_7.addCallback(dojo.hitch(this,this.onSuccess));
31
_7.addErrback(dojo.hitch(this,this.onError));
32
}else{
33
}
34
},onSuccess:function(_8,_9){
35
this.button.set("disabled",false);
36
if(this.logResults){
37
}
38
},onError:function(_a,_b){
39
this.button.set("disabled",false);
40
if(this.logResults){
41
}
42
}});
43
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
44
if(o.plugin){
45
return;
46
}
47
var _c=o.args.name.toLowerCase();
48
if(_c==="save"){
49
o.plugin=new dojox.editor.plugins.Save({url:("url" in o.args)?o.args.url:"",logResults:("logResults" in o.args)?o.args.logResults:true});
50
}
51
});
52
}