Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.41 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.Smiley"]){
9
dojo._hasResource["dojox.editor.plugins.Smiley"]=true;
10
dojo.provide("dojox.editor.plugins.Smiley");
11
dojo.experimental("dojox.editor.plugins.Smiley");
12
dojo.require("dojo.i18n");
13
dojo.require("dijit._editor._Plugin");
14
dojo.require("dijit.form.ToggleButton");
15
dojo.require("dijit.form.DropDownButton");
16
dojo.require("dojox.editor.plugins._SmileyPalette");
17
dojo.requireLocalization("dojox.editor.plugins","Smiley",null,"ROOT,cs,de,es,fr,hu,it,ja,ko,pl,pt,ro,ru,zh,zh-tw");
18
dojo.declare("dojox.editor.plugins.Smiley",dijit._editor._Plugin,{iconClassPrefix:"dijitAdditionalEditorIcon",emoticonMarker:"[]",emoticonImageClass:"dojoEditorEmoticon",_initButton:function(){
19
this.dropDown=new dojox.editor.plugins._SmileyPalette();
20
this.connect(this.dropDown,"onChange",function(_1){
21
this.button.closeDropDown();
22
this.editor.focus();
23
_1=this.emoticonMarker.charAt(0)+_1+this.emoticonMarker.charAt(1);
24
this.editor.execCommand("inserthtml",_1);
25
});
26
this.i18n=dojo.i18n.getLocalization("dojox.editor.plugins","Smiley");
27
this.button=new dijit.form.DropDownButton({label:this.i18n.smiley,showLabel:false,iconClass:this.iconClassPrefix+" "+this.iconClassPrefix+"Smiley",tabIndex:"-1",dropDown:this.dropDown});
28
this.emoticonImageRegexp=new RegExp("class=(\"|')"+this.emoticonImageClass+"(\"|')");
29
},setEditor:function(_2){
30
this.editor=_2;
31
this._initButton();
32
this.editor.contentPreFilters.push(dojo.hitch(this,this._preFilterEntities));
33
this.editor.contentPostFilters.push(dojo.hitch(this,this._postFilterEntities));
34
},_preFilterEntities:function(_3){
35
return _3.replace(/\[([^\]]*)\]/g,dojo.hitch(this,this._decode));
36
},_postFilterEntities:function(_4){
37
return _4.replace(/<img [^>]*>/gi,dojo.hitch(this,this._encode));
38
},_decode:function(_5,_6){
39
var _7=dojox.editor.plugins.Emoticon.fromAscii(_6);
40
return _7?_7.imgHtml(this.emoticonImageClass):_6;
41
},_encode:function(_8){
42
if(_8.search(this.emoticonImageRegexp)>-1){
43
return this.emoticonMarker.charAt(0)+_8.replace(/(<img [^>]*)alt="([^"]*)"([^>]*>)/,"$2")+this.emoticonMarker.charAt(1);
44
}else{
45
return _8;
46
}
47
}});
48
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
49
if(o.plugin){
50
return;
51
}
52
if(o.args.name==="smiley"){
53
o.plugin=new dojox.editor.plugins.Smiley();
54
}
55
});
56
}