| 1 |
define([ |
| 2 |
"dojo", |
| 3 |
"dijit", |
| 4 |
"dojox", |
| 5 |
"dijit/_Widget", |
| 6 |
"dijit/_TemplatedMixin", |
| 7 |
"dijit/_editor/_Plugin", |
| 8 |
"dojo/_base/connect", |
| 9 |
"dojo/_base/declare", |
| 10 |
"dojox/layout/ResizeHandle" |
| 11 |
], function(dojo, dijit, dojox, _Widget, _TemplatedMixin, _Plugin) { |
| 12 |
|
| 13 |
dojo.experimental("dojox.editor.plugins.StatusBar"); |
| 14 |
|
| 15 |
var _StatusBar = dojo.declare("dojox.editor.plugins._StatusBar", [_Widget, _TemplatedMixin],{ |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
templateString: '<div class="dojoxEditorStatusBar">' + |
| 20 |
'<table><tbody><tr>'+ |
| 21 |
'<td class="dojoxEditorStatusBarText" tabindex="-1" aria-role="presentation" aria-live="aggressive"><span dojoAttachPoint="barContent"> </span></td>' + |
| 22 |
'<td><span dojoAttachPoint="handle"></span></td>' + |
| 23 |
'</tr></tbody><table>'+ |
| 24 |
'</div>', |
| 25 |
|
| 26 |
_getValueAttr: function(){ |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
return this.barContent.innerHTML; |
| 32 |
}, |
| 33 |
|
| 34 |
_setValueAttr: function(str){ |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
if(str){ |
| 43 |
str = dojo.trim(str); |
| 44 |
if(!str){ |
| 45 |
str = " "; |
| 46 |
} |
| 47 |
}else{ |
| 48 |
str = " "; |
| 49 |
} |
| 50 |
this.barContent.innerHTML = str; |
| 51 |
} |
| 52 |
}); |
| 53 |
|
| 54 |
var StatusBar = dojo.declare("dojox.editor.plugins.StatusBar", _Plugin, { |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
statusBar: null, |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
resizer: true, |
| 70 |
|
| 71 |
setEditor: function(editor){ |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
this.editor = editor; |
| 77 |
this.statusBar = new _StatusBar(); |
| 78 |
if(this.resizer){ |
| 79 |
this.resizeHandle = new dojox.layout.ResizeHandle({targetId: this.editor, activeResize: true}, this.statusBar.handle); |
| 80 |
this.resizeHandle.startup(); |
| 81 |
}else{ |
| 82 |
dojo.style(this.statusBar.handle.parentNode, "display", "none"); |
| 83 |
} |
| 84 |
var pos = null; |
| 85 |
if(editor.footer.lastChild){ |
| 86 |
pos = "after"; |
| 87 |
} |
| 88 |
dojo.place(this.statusBar.domNode, editor.footer.lastChild || editor.footer, pos); |
| 89 |
this.statusBar.startup(); |
| 90 |
this.editor.statusBar = this; |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
this._msgListener = dojo.subscribe(this.editor.id + "_statusBar", dojo.hitch(this, this._setValueAttr)); |
| 95 |
}, |
| 96 |
|
| 97 |
_getValueAttr: function(){ |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
return this.statusBar.get("value"); |
| 103 |
}, |
| 104 |
|
| 105 |
_setValueAttr: function(str){ |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
this.statusBar.set("value", str); |
| 114 |
}, |
| 115 |
|
| 116 |
set: function(attr, val){ |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
if(attr){ |
| 124 |
var fName = "_set" + attr.charAt(0).toUpperCase() + attr.substring(1, attr.length) + "Attr"; |
| 125 |
if(dojo.isFunction(this[fName])){ |
| 126 |
this[fName](val); |
| 127 |
}else{ |
| 128 |
this[attr] = val; |
| 129 |
} |
| 130 |
} |
| 131 |
}, |
| 132 |
|
| 133 |
get: function(attr){ |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
if(attr){ |
| 139 |
var fName = "_get" + attr.charAt(0).toUpperCase() + attr.substring(1, attr.length) + "Attr"; |
| 140 |
var f = this[fName]; |
| 141 |
if(dojo.isFunction(f)){ |
| 142 |
return this[fName](); |
| 143 |
}else{ |
| 144 |
return this[attr]; |
| 145 |
} |
| 146 |
} |
| 147 |
return null; |
| 148 |
}, |
| 149 |
|
| 150 |
destroy: function(){ |
| 151 |
|
| 152 |
|
| 153 |
if(this.statusBar){ |
| 154 |
this.statusBar.destroy(); |
| 155 |
delete this.statusBar; |
| 156 |
} |
| 157 |
if(this.resizeHandle){ |
| 158 |
this.resizeHandle.destroy(); |
| 159 |
delete this.resizeHandle; |
| 160 |
} |
| 161 |
if(this._msgListener){ |
| 162 |
dojo.unsubscribe(this._msgListener); |
| 163 |
delete this._msgListener; |
| 164 |
} |
| 165 |
delete this.editor.statusBar; |
| 166 |
} |
| 167 |
}); |
| 168 |
|
| 169 |
|
| 170 |
StatusBar._StatusBar = _StatusBar; |
| 171 |
|
| 172 |
|
| 173 |
dojo.subscribe(dijit._scopeName + ".Editor.getPlugin",null,function(o){ |
| 174 |
if(o.plugin){ return; } |
| 175 |
var name = o.args.name.toLowerCase(); |
| 176 |
if(name === "statusbar"){ |
| 177 |
var resizer = ("resizer" in o.args)?o.args.resizer:true; |
| 178 |
o.plugin = new StatusBar({resizer: resizer}); |
| 179 |
} |
| 180 |
}); |
| 181 |
|
| 182 |
return StatusBar; |
| 183 |
|
| 184 |
}); |