1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dojox.editor.plugins.StatusBar"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.editor.plugins.StatusBar"] = true;
dojo.provide("dojox.editor.plugins.StatusBar");
dojo.require("dijit.Toolbar");
dojo.require("dijit._editor._Plugin");
dojo.require("dojox.layout.ResizeHandle");
dojo.require("dojo.i18n");
dojo.requireLocalization("dojox.editor.plugins", "StatusBar", null, "");
dojo.experimental("dojox.editor.plugins.StatusBar");
dojo.declare("dojox.editor.plugins._StatusBar", [dijit._Widget, dijit._Templated],{
// templateString: String
// Template for the widget. Currently using table to get the alignment behavior and
// bordering I wanted. Would prefer not to use table, though.
templateString: '<div class="dojoxEditorStatusBar">' +
'<table><tbody><tr>'+
'<td class="dojoxEditorStatusBarText" tabindex="-1" aria-role="presentation" aria-live="aggressive"><span dojoAttachPoint="barContent"> </span></td>' +
'<td><span dojoAttachPoint="handle"></span></td>' +
'</tr></tbody><table>'+
'</div>',
_getValueAttr: function(){
// summary:
// Over-ride to get the value of the status bar from the widget.
// tags:
// Protected
return this.barContent.innerHTML;
},
_setValueAttr: function(str){
// summary:
// Over-ride to set the value of the status bar from the widget.
// If no value is set, it is replaced with a non-blocking space.
// str: String
// The string to set as the status bar content.
// tags:
// protected
if(str){
str = dojo.trim(str);
if(!str){
str = " ";
}
}else{
str = " ";
}
this.barContent.innerHTML = str;
}
});
dojo.declare("dojox.editor.plugins.StatusBar",dijit._editor._Plugin,{
// summary:
// This plugin provides StatusBar cabability to the editor.
// Basically a footer bar where status can be published. It also
// puts a resize handle on the status bar, allowing you to resize the
// editor via mouse.
// statusBar: [protected]
// The status bar and resizer.
statusBar: null,
// resizer: [public] Boolean
// Flag indicating that a resizer should be shown or not. Default is true.
// There are cases (such as using center pane border container to autoresize the editor
// That a resizer is not valued.
resizer: true,
setEditor: function(editor){
// summary:
// Over-ride for the setting of the editor.
// editor: Object
// The editor to configure for this plugin to use.
this.editor = editor;
this.statusBar = new dojox.editor.plugins._StatusBar();
if(this.resizer){
this.resizeHandle = new dojox.layout.ResizeHandle({targetId: this.editor, activeResize: true}, this.statusBar.handle);
this.resizeHandle.startup();
}else{
dojo.style(this.statusBar.handle.parentNode, "display", "none");
}
var pos = null;
if(editor.footer.lastChild){
pos = "after";
}
dojo.place(this.statusBar.domNode, editor.footer.lastChild || editor.footer, pos);
this.statusBar.startup();
this.editor.statusBar = this;
// Register a pub-sub event to listen for status bar messages, in addition to being available off
// the editor as a property 'statusBar'
this._msgListener = dojo.subscribe(this.editor.id + "_statusBar", dojo.hitch(this, this._setValueAttr));
},
_getValueAttr: function(){
// summary:
// Over-ride to get the value of the status bar from the widget.
// tags:
// protected
return this.statusBar.get("value");
},
_setValueAttr: function(str){
// summary:
// Over-ride to set the value of the status bar from the widget.
// If no value is set, it is replaced with a non-blocking space.
// str: String
// The String value to set in the bar.
// tags:
// protected
this.statusBar.set("value", str);
},
set: function(attr, val){
// summary:
// Quick and dirty implementation of 'set' pattern
// attr:
// The attribute to set.
// val:
// The value to set it to.
if(attr){
var fName = "_set" + attr.charAt(0).toUpperCase() + attr.substring(1, attr.length) + "Attr";
if(dojo.isFunction(this[fName])){
this[fName](val);
}else{
this[attr] = val;
}
}
},
get: function(attr){
// summary:
// Quick and dirty implementation of 'get' pattern
// attr:
// The attribute to get.
if(attr){
var fName = "_get" + attr.charAt(0).toUpperCase() + attr.substring(1, attr.length) + "Attr";
var f = this[fName];
if(dojo.isFunction(f)){
return this[fName]();
}else{
return this[attr];
}
}
return null;
},
destroy: function(){
// summary:
// Over-ride to clean up the breadcrumb toolbar.
if(this.statusBar){
this.statusBar.destroy();
delete this.statusBar;
}
if(this.resizeHandle){
this.resizeHandle.destroy();
delete this.resizeHandle;
}
if(this._msgListener){
dojo.unsubscribe(this._msgListener);
delete this._msgListener;
}
delete this.editor.statusBar;
}
});
// Register this plugin.
dojo.subscribe(dijit._scopeName + ".Editor.getPlugin",null,function(o){
if(o.plugin){ return; }
var name = o.args.name.toLowerCase();
if(name === "statusbar"){
var resizer = ("resizer" in o.args)?o.args.resizer:true;
o.plugin = new dojox.editor.plugins.StatusBar({resizer: resizer});
}
});
}
|