Index: trunk/extensions/UsabilityInitiative/css/wikiEditor.toolbar.css |
— | — | @@ -1,20 +1,20 @@ |
2 | 2 | /* wikiEditor toolbar module */ |
3 | 3 | |
4 | | -.wikiEditor-ui .wikiEditor-ui-toolbar { |
| 4 | +.wikiEditor-ui-toolbar { |
5 | 5 | position: relative; |
6 | 6 | width: 100%; |
7 | 7 | } |
8 | 8 | |
9 | 9 | /* Expandable Sections */ |
10 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections { |
| 10 | +.wikiEditor-ui-toolbar .sections { |
11 | 11 | float: left; |
12 | 12 | width: 100%; |
13 | 13 | clear: both; |
14 | 14 | } |
15 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections { |
| 15 | +body.rtl .wikiEditor-ui-toolbar .sections { |
16 | 16 | float: right; |
17 | 17 | } |
18 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections .section { |
| 18 | +.wikiEditor-ui-toolbar .sections .section { |
19 | 19 | display: none; |
20 | 20 | float: left; |
21 | 21 | width: 100%; |
— | — | @@ -24,20 +24,20 @@ |
25 | 25 | border-top: solid 1px #DDDDDD; |
26 | 26 | background-color: #F3F3F3; |
27 | 27 | } |
28 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections .section { |
| 28 | +body.rtl .wikiEditor-ui-toolbar .sections .section { |
29 | 29 | float: right; |
30 | 30 | margin-left: auto; |
31 | 31 | margin-right: -1px; |
32 | 32 | } |
33 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading { |
| 33 | +.wikiEditor-ui-toolbar .sections .loading { |
34 | 34 | padding-top: 0.5em; |
35 | 35 | padding-bottom: 0.5em; |
36 | 36 | } |
37 | 37 | /* Gets overridden when the section div is in class loading - see below */ |
38 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections div .spinner { |
| 38 | +.wikiEditor-ui-toolbar .sections div .spinner { |
39 | 39 | display: none; |
40 | 40 | } |
41 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading .spinner { |
| 41 | +.wikiEditor-ui-toolbar .sections .loading .spinner { |
42 | 42 | display: block; |
43 | 43 | background-image: url(../images/wikiEditor/toolbar/loading.gif); |
44 | 44 | background-position: left center; |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | float: left; |
49 | 49 | color: #666666; |
50 | 50 | } |
51 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading .spinner { |
| 51 | +body.rtl .wikiEditor-ui-toolbar .sections .loading .spinner { |
52 | 52 | background-position: right center; |
53 | 53 | padding-left: 0; |
54 | 54 | padding-right: 32px; |
— | — | @@ -56,25 +56,25 @@ |
57 | 57 | float: right; |
58 | 58 | } |
59 | 59 | /* Top Level Containers */ |
60 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs, |
61 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-main { |
| 60 | +.wikiEditor-ui-toolbar .tabs, |
| 61 | +.wikiEditor-ui-toolbar .section-main { |
62 | 62 | position: relative; |
63 | 63 | float: left; |
64 | 64 | height: 26px; |
65 | 65 | } |
66 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs, |
67 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-main { |
| 66 | +body.rtl .wikiEditor-ui-toolbar .tabs, |
| 67 | +body.rtl .wikiEditor-ui-toolbar .section-main { |
68 | 68 | float: right; |
69 | 69 | } |
70 | 70 | /* Groups */ |
71 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .group { |
| 71 | +.wikiEditor-ui-toolbar .group { |
72 | 72 | float: left; |
73 | 73 | height: 26px; |
74 | 74 | padding-right: 6px; |
75 | 75 | border-right: solid 1px #DDDDDD; |
76 | 76 | margin: 3px; |
77 | 77 | } |
78 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group { |
| 78 | +body.rtl .wikiEditor-ui-toolbar .group { |
79 | 79 | float: right; |
80 | 80 | padding-right: 0; |
81 | 81 | padding-left: 6px; |
— | — | @@ -82,25 +82,25 @@ |
83 | 83 | border-left: solid 1px #DDDDDD; |
84 | 84 | } |
85 | 85 | /* Tabs */ |
86 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs { |
| 86 | +.wikiEditor-ui-toolbar .tabs { |
87 | 87 | list-style: none; |
88 | 88 | margin: 3px; |
89 | 89 | } |
90 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab { |
| 90 | +.wikiEditor-ui-toolbar .tabs span.tab { |
91 | 91 | display: inline-block; |
92 | 92 | float: left; |
93 | 93 | line-height: 26px; |
94 | 94 | } |
95 | 95 | /* IGNORED BY IE6 */ |
96 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab { |
| 96 | +.wikiEditor-ui-toolbar .tabs > span.tab { |
97 | 97 | display: block; |
98 | 98 | } |
99 | 99 | /* IGNORED BY IE6 */ |
100 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab { |
| 100 | +body.rtl .wikiEditor-ui-toolbar .tabs > span.tab { |
101 | 101 | float: right; |
102 | 102 | } |
103 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a, |
104 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a:visited { |
| 103 | +.wikiEditor-ui-toolbar .tabs span.tab a, |
| 104 | +.wikiEditor-ui-toolbar .tabs span.tab a:visited { |
105 | 105 | display: inline-block; |
106 | 106 | float: left; |
107 | 107 | padding-left: 18px; |
— | — | @@ -112,32 +112,32 @@ |
113 | 113 | background-position: left center; |
114 | 114 | background-repeat: no-repeat; |
115 | 115 | } |
116 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a, |
117 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a:visited { |
| 116 | +body.rtl .wikiEditor-ui-toolbar .tabs span.tab a, |
| 117 | +body.rtl .wikiEditor-ui-toolbar .tabs span.tab a:visited { |
118 | 118 | padding-left: 12px; |
119 | 119 | padding-right: 18px; |
120 | 120 | background-image: url(../images/wikiEditor/toolbar/arrow-left.png); |
121 | 121 | background-position: right center; |
122 | 122 | } |
123 | 123 | /* IGNORED BY IE6 */ |
124 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab > a, |
125 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > pan.tab > a:visited { |
| 124 | +body.rtl .wikiEditor-ui-toolbar .tabs > span.tab > a, |
| 125 | +body.rtl .wikiEditor-ui-toolbar .tabs > pan.tab > a:visited { |
126 | 126 | float: right; |
127 | 127 | } |
128 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current, |
129 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:visited { |
| 128 | +.wikiEditor-ui-toolbar .tabs span.tab a.current, |
| 129 | +.wikiEditor-ui-toolbar .tabs span.tab a.current:visited { |
130 | 130 | color: #333333; |
131 | 131 | background-image: url(../images/wikiEditor/toolbar/arrow-down.png); |
132 | 132 | } |
133 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current, |
134 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:visited { |
| 133 | +body.rtl .wikiEditor-ui-toolbar .tabs span.tab a.current, |
| 134 | +body.rtl .wikiEditor-ui-toolbar .tabs span.tab a.current:visited { |
135 | 135 | background-image: url(../images/wikiEditor/toolbar/arrow-down.png); |
136 | 136 | } |
137 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:hover { |
| 137 | +.wikiEditor-ui-toolbar .tabs span.tab a.current:hover { |
138 | 138 | text-decoration: none; |
139 | 139 | } |
140 | 140 | /* Toolbar */ |
141 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .group .label { |
| 141 | +.wikiEditor-ui-toolbar .group .label { |
142 | 142 | float: left; |
143 | 143 | border: 0px; |
144 | 144 | height: 22px; |
— | — | @@ -149,12 +149,12 @@ |
150 | 150 | cursor: default; |
151 | 151 | } |
152 | 152 | /* IGNORED BY IE6 */ |
153 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > .label { |
| 153 | +body.rtl .wikiEditor-ui-toolbar .group > .label { |
154 | 154 | float: right; |
155 | 155 | margin-left: 8px; |
156 | 156 | margin-right: 5px; |
157 | 157 | } |
158 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .group img.tool { |
| 158 | +.wikiEditor-ui-toolbar .group img.tool { |
159 | 159 | float: left; |
160 | 160 | border: 0px; |
161 | 161 | height: 22px; |
— | — | @@ -163,90 +163,90 @@ |
164 | 164 | cursor: pointer; |
165 | 165 | } |
166 | 166 | /* IGNORED BY IE6 */ |
167 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > img.tool { |
| 167 | +body.rtl .wikiEditor-ui-toolbar .group > img.tool { |
168 | 168 | float: right; |
169 | 169 | } |
170 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .group select { |
| 170 | +.wikiEditor-ui-toolbar .group select { |
171 | 171 | float: left; |
172 | 172 | margin: 2px; |
173 | 173 | height: 22px; |
174 | 174 | cursor: pointer; |
175 | 175 | } |
176 | 176 | /* IGNORED BY IE6 */ |
177 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > select { |
| 177 | +body.rtl .wikiEditor-ui-toolbar .group > select { |
178 | 178 | float: right; |
179 | 179 | font-size: 0.9em; |
180 | 180 | } |
181 | 181 | /* Booklet */ |
182 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index { |
| 182 | +.wikiEditor-ui-toolbar .booklet .index { |
183 | 183 | float: left; |
184 | 184 | width: 20%; |
185 | 185 | height: 125px; |
186 | 186 | overflow: auto; |
187 | 187 | } |
188 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index { |
| 188 | +body.rtl .wikiEditor-ui-toolbar .booklet .index { |
189 | 189 | float: right; |
190 | 190 | } |
191 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index div { |
| 191 | +.wikiEditor-ui-toolbar .booklet .index div { |
192 | 192 | padding: 4px; |
193 | 193 | padding-left: 6px; |
194 | 194 | cursor: pointer; |
195 | 195 | color: #0645ad; |
196 | 196 | } |
197 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index div { |
| 197 | +body.rtl .wikiEditor-ui-toolbar .booklet .index div { |
198 | 198 | padding-left: 4px; |
199 | 199 | padding-right: 6px; |
200 | 200 | } |
201 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index .current { |
| 201 | +.wikiEditor-ui-toolbar .booklet .index .current { |
202 | 202 | background-color: #FAFAFA; |
203 | 203 | color: #333333; |
204 | 204 | cursor: default; |
205 | 205 | } |
206 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .pages { |
| 206 | +.wikiEditor-ui-toolbar .booklet .pages { |
207 | 207 | float: right; |
208 | 208 | width: 80%; |
209 | 209 | height: 125px; |
210 | 210 | overflow: auto; |
211 | 211 | background-color: #FAFAFA; |
212 | 212 | } |
213 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .pages { |
| 213 | +body.rtl .wikiEditor-ui-toolbar .booklet .pages { |
214 | 214 | float: left; |
215 | 215 | } |
216 | 216 | /* Help Pages */ |
217 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table { |
| 217 | +.wikiEditor-ui-toolbar .page-table table { |
218 | 218 | padding-left: 5px; |
219 | 219 | padding-right: 5px; |
220 | 220 | background: none; |
221 | 221 | } |
222 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th { |
| 222 | +.wikiEditor-ui-toolbar .page-table th { |
223 | 223 | color: #999999; |
224 | 224 | } |
225 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td { |
| 225 | +.wikiEditor-ui-toolbar .page-table td { |
226 | 226 | color: black; |
227 | 227 | border-top: solid 1px #EEEEEE; |
228 | 228 | } |
229 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th, |
230 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td { |
| 229 | +.wikiEditor-ui-toolbar .page-table th, |
| 230 | +.wikiEditor-ui-toolbar .page-table td { |
231 | 231 | text-align: left; |
232 | 232 | padding: 5px; |
233 | 233 | margin: 0px; |
234 | 234 | } |
235 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th, |
236 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td { |
| 235 | +body.rtl .wikiEditor-ui-toolbar .page-table th, |
| 236 | +body.rtl .wikiEditor-ui-toolbar .page-table td { |
237 | 237 | text-align: right; |
238 | 238 | } |
239 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.syntax { |
| 239 | +.wikiEditor-ui-toolbar .section-help .page-table td.syntax { |
240 | 240 | font-family: monospace; |
241 | 241 | } |
242 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.syntax, |
243 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.result { |
| 242 | +.wikiEditor-ui-toolbar .section-help .page-table td.syntax, |
| 243 | +.wikiEditor-ui-toolbar .section-help .page-table td.result { |
244 | 244 | width: 40%; |
245 | 245 | } |
246 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.description { |
| 246 | +.wikiEditor-ui-toolbar .section-help .page-table td.description { |
247 | 247 | width: 20%; |
248 | 248 | } |
249 | 249 | /* Characters Pages */ |
250 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div a { |
| 250 | +.wikiEditor-ui-toolbar .page-characters div a { |
251 | 251 | border: solid 1px #DDDDDD; |
252 | 252 | padding: 5px; |
253 | 253 | padding-left: 8px; |
— | — | @@ -259,14 +259,14 @@ |
260 | 260 | color: black; |
261 | 261 | text-decoration: none; |
262 | 262 | } |
263 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters > div > a, |
264 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div[dir=rtl] a { |
| 263 | +body.rtl .wikiEditor-ui-toolbar .page-characters > div > a, |
| 264 | +.wikiEditor-ui-toolbar .page-characters div[dir=rtl] a { |
265 | 265 | direction: rtl; |
266 | 266 | float: right; |
267 | 267 | margin-left: 0; |
268 | 268 | margin-right: 5px; |
269 | 269 | } |
270 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div a:hover { |
| 270 | +.wikiEditor-ui-toolbar .page-characters div a:hover { |
271 | 271 | background-color: white; |
272 | 272 | text-decoration: none; |
273 | 273 | border-color: #a8d7f9; |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js |
— | — | @@ -14,11 +14,134 @@ |
15 | 15 | */ |
16 | 16 | api: { |
17 | 17 | addToToolbar: function( context, data ) { |
18 | | - // |
| 18 | + for ( type in data ) { |
| 19 | + switch ( type ) { |
| 20 | + case 'sections': |
| 21 | + var $sections = |
| 22 | + context.modules.$toolbar.find( 'div.sections' ); |
| 23 | + var $tabs = context.modules.$toolbar.find( 'div.tabs' ); |
| 24 | + for ( section in data[type] ) { |
| 25 | + if ( section == 'main' ) { |
| 26 | + // Section |
| 27 | + context.modules.$toolbar.prepend( |
| 28 | + $.wikiEditor.modules.toolbar.fn.buildSection( |
| 29 | + context, section, data[type][section] |
| 30 | + ) |
| 31 | + ); |
| 32 | + continue; |
| 33 | + } |
| 34 | + // Section |
| 35 | + $sections.append( |
| 36 | + $.wikiEditor.modules.toolbar.fn.buildSection( |
| 37 | + context, section, data[type][section] |
| 38 | + ) |
| 39 | + ); |
| 40 | + // Tab |
| 41 | + $tabs.append( |
| 42 | + $.wikiEditor.modules.toolbar.fn.buildTab( |
| 43 | + context, section, data[type][section] |
| 44 | + ) |
| 45 | + ); |
| 46 | + } |
| 47 | + break; |
| 48 | + case 'groups': |
| 49 | + if ( !( 'section' in data ) ) { |
| 50 | + continue; |
| 51 | + } |
| 52 | + var $section = context.modules.$toolbar.find( |
| 53 | + 'div[rel=' + data.section + '].section' |
| 54 | + ); |
| 55 | + for ( group in data[type] ) { |
| 56 | + // Group |
| 57 | + $section.append( |
| 58 | + $.wikiEditor.modules.toolbar.fn.buildGroup( |
| 59 | + context, group, data[type][group] |
| 60 | + ) |
| 61 | + ); |
| 62 | + } |
| 63 | + break; |
| 64 | + case 'tools': |
| 65 | + if ( !( 'section' in data && 'group' in data ) ) { |
| 66 | + continue; |
| 67 | + } |
| 68 | + var $group = context.modules.$toolbar.find( |
| 69 | + 'div[rel=' + data.section + '].section ' + |
| 70 | + 'div[rel=' + data.group + '].group' |
| 71 | + ); |
| 72 | + for ( tool in data[type] ) { |
| 73 | + // Tool |
| 74 | + $group.append( |
| 75 | + $.wikiEditor.modules.toolbar.fn.buildTool( |
| 76 | + context, tool, data[type][tool] |
| 77 | + ) |
| 78 | + ); |
| 79 | + } |
| 80 | + break; |
| 81 | + case 'pages': |
| 82 | + if ( !( 'section' in data ) ) { |
| 83 | + continue; |
| 84 | + } |
| 85 | + var $pages = context.modules.$toolbar.find( |
| 86 | + 'div[rel=' + data.section + '].section .pages' |
| 87 | + ); |
| 88 | + var $index = context.modules.$toolbar.find( |
| 89 | + 'div[rel=' + data.section + '].section .index' |
| 90 | + ); |
| 91 | + for ( page in data[type] ) { |
| 92 | + // Page |
| 93 | + $pages.append( |
| 94 | + $.wikiEditor.modules.toolbar.fn.buildPage( |
| 95 | + context, page, data[type][page] |
| 96 | + ) |
| 97 | + ); |
| 98 | + // Index |
| 99 | + $index.append( |
| 100 | + $.wikiEditor.modules.toolbar.fn.buildBookmark( |
| 101 | + context, page, data[type][page] |
| 102 | + ) |
| 103 | + ); |
| 104 | + } |
| 105 | + $.wikiEditor.modules.toolbar.fn.updateBookletSelection( |
| 106 | + context, page, $pages, $index |
| 107 | + ); |
| 108 | + break; |
| 109 | + case 'rows': |
| 110 | + if ( !( 'section' in data && 'page' in data ) ) { |
| 111 | + continue; |
| 112 | + } |
| 113 | + var $table = context.modules.$toolbar.find( |
| 114 | + 'div[rel=' + data.section + '].section ' + |
| 115 | + 'div[rel=' + data.page + '].page table' |
| 116 | + ) |
| 117 | + for ( row in data[type] ) { |
| 118 | + // Row |
| 119 | + $table.append( |
| 120 | + $.wikiEditor.modules.toolbar.fn.buildRow( |
| 121 | + context, data[type][row] |
| 122 | + ) |
| 123 | + ); |
| 124 | + } |
| 125 | + break; |
| 126 | + case 'characters': |
| 127 | + if ( !( 'section' in data && 'page' in data ) ) { |
| 128 | + continue; |
| 129 | + } |
| 130 | + $characters = context.modules.$toolbar.find( |
| 131 | + 'div[rel=' + data.section + '].section ' + |
| 132 | + 'div[rel=' + data.page + '].page div' |
| 133 | + ); |
| 134 | + for ( character in data[type] ) { |
| 135 | + // Character |
| 136 | + $characters.append( |
| 137 | + $.wikiEditor.modules.toolbar.fn.buildCharacter( |
| 138 | + context, data[type][character] |
| 139 | + ) |
| 140 | + ); |
| 141 | + } |
| 142 | + break; |
| 143 | + } |
| 144 | + } |
19 | 145 | }, |
20 | | - modifyToolbar: function( context, data ) { |
21 | | - // |
22 | | - }, |
23 | 146 | removeFromToolbar: function( context, data ) { |
24 | 147 | if ( typeof data.section == 'string' ) { |
25 | 148 | // Section |
— | — | @@ -44,6 +167,12 @@ |
45 | 168 | } else { |
46 | 169 | // Just a page, remove the index too! |
47 | 170 | context.modules.$toolbar.find( index ).remove(); |
| 171 | + $.wikiEditor.modules.toolbar.fn.updateBookletSelection( |
| 172 | + context, |
| 173 | + null, |
| 174 | + context.modules.$toolbar.find( target ), |
| 175 | + context.modules.$toolbar.find( index ) |
| 176 | + ); |
48 | 177 | } |
49 | 178 | } else { |
50 | 179 | // Just a section, remove the tab too! |
— | — | @@ -140,35 +269,6 @@ |
141 | 270 | default: break; |
142 | 271 | } |
143 | 272 | }, |
144 | | - buildSection: function( context, id, section ) { |
145 | | - switch ( section.type ) { |
146 | | - case 'toolbar': |
147 | | - return $.wikiEditor.modules.toolbar.fn.buildToolbar( |
148 | | - context, id, section |
149 | | - ); |
150 | | - case 'booklet': |
151 | | - return $.wikiEditor.modules.toolbar.fn.buildBooklet( |
152 | | - context, id, section |
153 | | - ); |
154 | | - default: return null; |
155 | | - } |
156 | | - }, |
157 | | - buildToolbar: function( context, id, toolbar ) { |
158 | | - var $toolbar = $( '<div></div>' ).attr( { |
159 | | - 'class': 'toolbar section section-' + id, |
160 | | - 'rel': id |
161 | | - } ); |
162 | | - if ( 'groups' in toolbar ) { |
163 | | - for ( group in toolbar.groups ) { |
164 | | - $toolbar.append( |
165 | | - $.wikiEditor.modules.toolbar.fn.buildGroup( |
166 | | - context, group, toolbar.groups[group] |
167 | | - ) |
168 | | - ); |
169 | | - } |
170 | | - } |
171 | | - return $toolbar; |
172 | | - }, |
173 | 273 | buildGroup: function( context, id, group ) { |
174 | 274 | var $group = $( '<div></div>' ).attr( { |
175 | 275 | 'class': 'group group-' + id, |
— | — | @@ -202,8 +302,15 @@ |
203 | 303 | var label = $.wikiEditor.modules.toolbar.fn.autoMsg( tool, 'label' ); |
204 | 304 | switch ( tool.type ) { |
205 | 305 | case 'button': |
| 306 | + var src = tool.icon; |
| 307 | + if ( |
| 308 | + src.indexOf( 'http://' ) !== 0 && |
| 309 | + src.indexOf( 'https://' ) !== 0 |
| 310 | + ) { |
| 311 | + src = $.wikiEditor.modules.toolbar.imgPath + src; |
| 312 | + } |
206 | 313 | $button = $( '<img />' ).attr( { |
207 | | - 'src': $.wikiEditor.modules.toolbar.imgPath + tool.icon, |
| 314 | + 'src': src, |
208 | 315 | 'width': 22, |
209 | 316 | 'height': 22, |
210 | 317 | 'alt': label, |
— | — | @@ -263,42 +370,6 @@ |
264 | 371 | default: return null; |
265 | 372 | } |
266 | 373 | }, |
267 | | - buildBooklet: function( context, id, booklet ) { |
268 | | - var selected = $.cookie( |
269 | | - 'wikiEditor-' + context.instance + '-booklet-' + id + '-page' |
270 | | - ); |
271 | | - var $booklet = $( '<div></div>' ).attr( { |
272 | | - 'class': 'booklet section section-' + id, |
273 | | - 'rel': id |
274 | | - } ); |
275 | | - var $pages = $( '<div></div>' ).attr( 'class', 'pages' ); |
276 | | - var $index = $( '<div></div>' ).attr( 'class', 'index' ); |
277 | | - if ( 'pages' in booklet ) { |
278 | | - if ( !( selected in booklet.pages ) ) { |
279 | | - selected = null; |
280 | | - } |
281 | | - for ( page in booklet.pages ) { |
282 | | - if ( selected === null ) { |
283 | | - selected = page; |
284 | | - } |
285 | | - var $page = $.wikiEditor.modules.toolbar.fn.buildPage( |
286 | | - context, page, booklet.pages[page] |
287 | | - ); |
288 | | - var $bookmark = $.wikiEditor.modules.toolbar.fn.buildBookmark( |
289 | | - context, page, booklet.pages[page] |
290 | | - ); |
291 | | - if ( selected == page ) { |
292 | | - $page.show(); |
293 | | - $bookmark.addClass( 'current' ); |
294 | | - } else { |
295 | | - $page.hide(); |
296 | | - } |
297 | | - $pages.append( $page ); |
298 | | - $index.append( $bookmark ); |
299 | | - } |
300 | | - } |
301 | | - return $booklet.append( $index ).append( $pages ); |
302 | | - }, |
303 | 374 | buildBookmark: function( context, id, page ) { |
304 | 375 | var label = $.wikiEditor.modules.toolbar.fn.autoMsg( page, 'label' ); |
305 | 376 | return $( '<div></div>' ) |
— | — | @@ -342,36 +413,19 @@ |
343 | 414 | 'class': 'table table-' + id |
344 | 415 | } ); |
345 | 416 | if ( 'headings' in page ) { |
346 | | - var $headings = $( '<tr></tr>' ); |
347 | | - for ( heading in page.headings ) { |
348 | | - var content = |
349 | | - $.wikiEditor.modules.toolbar.fn.autoMsg( |
350 | | - page.headings[heading], 'content' |
351 | | - ); |
352 | | - $headings.append( |
353 | | - $( '<th></th>' ).text( content ) |
354 | | - ); |
355 | | - } |
356 | | - $table.append( $headings ); |
| 417 | + $table.append( |
| 418 | + $.wikiEditor.modules.toolbar.fn.buildHeading( |
| 419 | + context, page.headings |
| 420 | + ) |
| 421 | + ); |
357 | 422 | } |
358 | 423 | if ( 'rows' in page ) { |
359 | 424 | for ( row in page.rows ) { |
360 | | - var $row = $( '<tr></tr>' ); |
361 | | - for ( cell in page.rows[row] ) { |
362 | | - var $cell = $( '<td></td>' ).attr( { |
363 | | - 'class': 'cell cell-' + cell, |
364 | | - 'valign': 'top' |
365 | | - } ); |
366 | | - var content = |
367 | | - $.wikiEditor.modules.toolbar.fn.autoMsg( |
368 | | - page.rows[row][cell], 'content' |
369 | | - ); |
370 | | - $cell.append( |
371 | | - $( '<span></span>' ).html( content ) |
372 | | - ); |
373 | | - $row.append( $cell ); |
374 | | - } |
375 | | - $table.append( $row ); |
| 425 | + $table.append( |
| 426 | + $.wikiEditor.modules.toolbar.fn.buildRow( |
| 427 | + context, page.rows[row] |
| 428 | + ) |
| 429 | + ); |
376 | 430 | } |
377 | 431 | } |
378 | 432 | $page.append( $table ); |
— | — | @@ -387,47 +441,198 @@ |
388 | 442 | } |
389 | 443 | if ( 'characters' in page ) { |
390 | 444 | for ( character in page.characters ) { |
391 | | - var tool = page.characters[character]; |
392 | | - if ( typeof tool == 'string' ) { |
393 | | - tool = { |
394 | | - 'label': tool, |
395 | | - 'action': { |
396 | | - 'type': 'encapsulate', |
397 | | - 'options': { 'pre': tool } |
398 | | - } |
399 | | - }; |
400 | | - } else if ( 0 in tool && 1 in tool ) { |
401 | | - tool = { |
402 | | - 'label': tool[0], |
403 | | - 'action': { |
404 | | - 'type': 'encapsulate', |
405 | | - 'options': { 'pre': tool[1] } |
406 | | - } |
407 | | - }; |
408 | | - } |
409 | | - if ( 'action' in tool && 'label' in tool ) { |
410 | | - var $character = $( '<a></a>' ) |
411 | | - .attr( 'rel', tool.label ) |
412 | | - .attr( 'href', '#' ) |
413 | | - .text( tool.label ) |
414 | | - .data( 'context', context ) |
415 | | - .data( 'action', tool.action ) |
416 | | - .click( function() { |
417 | | - $.wikiEditor.modules.toolbar.fn.doAction( |
418 | | - $(this).data( 'context' ), |
419 | | - $(this).data( 'action' ) |
420 | | - ); |
421 | | - return false; |
422 | | - } ); |
423 | | - $characters.append( $character ); |
424 | | - } |
| 445 | + $characters.append( |
| 446 | + $.wikiEditor.modules.toolbar.fn.buildCharacter( |
| 447 | + context, page.characters[character] |
| 448 | + ) |
| 449 | + ); |
425 | 450 | } |
426 | | - $page.append( $characters ); |
427 | 451 | } |
| 452 | + $page.append( $characters ); |
428 | 453 | break; |
429 | 454 | } |
430 | 455 | return $page; |
431 | 456 | }, |
| 457 | + buildHeading: function( context, headings ) { |
| 458 | + var $headings = $( '<tr></tr>' ); |
| 459 | + for ( heading in headings ) { |
| 460 | + $headings.append( |
| 461 | + $( '<th></th>' ).text( |
| 462 | + $.wikiEditor.modules.toolbar.fn.autoMsg( |
| 463 | + headings[heading], 'content' |
| 464 | + ) |
| 465 | + ) |
| 466 | + ); |
| 467 | + } |
| 468 | + return $headings; |
| 469 | + }, |
| 470 | + buildRow: function( context, row ) { |
| 471 | + var $row = $( '<tr></tr>' ); |
| 472 | + for ( cell in row ) { |
| 473 | + $row.append( |
| 474 | + $( '<td></td>' ) |
| 475 | + .attr( { |
| 476 | + 'class': 'cell cell-' + cell, |
| 477 | + 'valign': 'top' |
| 478 | + } ) |
| 479 | + .append( |
| 480 | + $( '<span></span>' ).html( |
| 481 | + $.wikiEditor.modules.toolbar.fn.autoMsg( |
| 482 | + row[cell], 'content' |
| 483 | + ) |
| 484 | + ) |
| 485 | + ) |
| 486 | + ); |
| 487 | + } |
| 488 | + return $row; |
| 489 | + }, |
| 490 | + buildCharacter: function( context, character ) { |
| 491 | + if ( typeof character == 'string' ) { |
| 492 | + character = { |
| 493 | + 'label': character, |
| 494 | + 'action': { |
| 495 | + 'type': 'encapsulate', |
| 496 | + 'options': { 'pre': character } |
| 497 | + } |
| 498 | + }; |
| 499 | + } else if ( 0 in character && 1 in character ) { |
| 500 | + character = { |
| 501 | + 'label': character[0], |
| 502 | + 'action': { |
| 503 | + 'type': 'encapsulate', |
| 504 | + 'options': { 'pre': character[1] } |
| 505 | + } |
| 506 | + }; |
| 507 | + } |
| 508 | + if ( 'action' in character && 'label' in character ) { |
| 509 | + return $( '<a></a>' ) |
| 510 | + .attr( 'rel', character.label ) |
| 511 | + .attr( 'href', '#' ) |
| 512 | + .text( character.label ) |
| 513 | + .data( 'context', context ) |
| 514 | + .data( 'action', character.action ) |
| 515 | + .click( function() { |
| 516 | + $.wikiEditor.modules.toolbar.fn.doAction( |
| 517 | + $(this).data( 'context' ), |
| 518 | + $(this).data( 'action' ) |
| 519 | + ); |
| 520 | + return false; |
| 521 | + } ); |
| 522 | + } |
| 523 | + }, |
| 524 | + buildTab: function( context, id, section ) { |
| 525 | + var selected = $.cookie( |
| 526 | + 'wikiEditor-' + context.instance + '-toolbar-section' |
| 527 | + ); |
| 528 | + return $( '<span></span>' ) |
| 529 | + .attr( { |
| 530 | + 'class': 'tab tab-' + id, |
| 531 | + 'rel': id |
| 532 | + } ) |
| 533 | + .append( |
| 534 | + $( '<a></a>' ) |
| 535 | + .addClass( selected == id ? 'current' : null ) |
| 536 | + .attr( 'href', '#' ) |
| 537 | + .text( |
| 538 | + $.wikiEditor.modules.toolbar.fn.autoMsg( section, 'label' ) |
| 539 | + ) |
| 540 | + .data( 'context', context ) |
| 541 | + .click( function() { |
| 542 | + var $section = |
| 543 | + $(this).data( 'context' ).$ui.find( |
| 544 | + '.section-' + $(this).parent().attr( 'rel' ) |
| 545 | + ); |
| 546 | + $(this).blur(); |
| 547 | + var show = $section.css( 'display' ) == 'none'; |
| 548 | + $section.parent().children().hide(); |
| 549 | + $(this) |
| 550 | + .parent() |
| 551 | + .parent() |
| 552 | + .find( 'a' ) |
| 553 | + .removeClass( 'current' ); |
| 554 | + if ( show ) { |
| 555 | + $section.show(); |
| 556 | + $(this).addClass( 'current' ); |
| 557 | + } |
| 558 | + $.cookie( |
| 559 | + 'wikiEditor-' + |
| 560 | + $(this).data( 'context' ).instance + |
| 561 | + '-toolbar-section', |
| 562 | + show ? $section.attr( 'rel' ) : null |
| 563 | + ); |
| 564 | + return false; |
| 565 | + } ) |
| 566 | + ); |
| 567 | + }, |
| 568 | + buildSection: function( context, id, section ) { |
| 569 | + var selected = $.cookie( |
| 570 | + 'wikiEditor-' + context.instance + '-toolbar-section' |
| 571 | + ); |
| 572 | + var $section; |
| 573 | + switch ( section.type ) { |
| 574 | + case 'toolbar': |
| 575 | + var $section = $( '<div></div>' ).attr( { |
| 576 | + 'class': 'toolbar section section-' + id, |
| 577 | + 'rel': id |
| 578 | + } ); |
| 579 | + if ( 'groups' in section ) { |
| 580 | + for ( group in section.groups ) { |
| 581 | + $section.append( |
| 582 | + $.wikiEditor.modules.toolbar.fn.buildGroup( |
| 583 | + context, group, section.groups[group] |
| 584 | + ) |
| 585 | + ); |
| 586 | + } |
| 587 | + } |
| 588 | + break; |
| 589 | + case 'booklet': |
| 590 | + var $pages = $( '<div></div>' ).attr( 'class', 'pages' ); |
| 591 | + var $index = $( '<div></div>' ).attr( 'class', 'index' ); |
| 592 | + if ( 'pages' in section ) { |
| 593 | + |
| 594 | + for ( page in section.pages ) { |
| 595 | + $pages.append( |
| 596 | + $.wikiEditor.modules.toolbar.fn.buildPage( |
| 597 | + context, page, section.pages[page] |
| 598 | + ) |
| 599 | + ); |
| 600 | + $index.append( |
| 601 | + $.wikiEditor.modules.toolbar.fn.buildBookmark( |
| 602 | + context, page, section.pages[page] |
| 603 | + ) |
| 604 | + ); |
| 605 | + } |
| 606 | + } |
| 607 | + $section = $( '<div></div>' ) |
| 608 | + .attr( { |
| 609 | + 'class': 'booklet section section-' + id, |
| 610 | + 'rel': id |
| 611 | + } ) |
| 612 | + .append( $index ) |
| 613 | + .append( $pages ); |
| 614 | + $.wikiEditor.modules.toolbar.fn.updateBookletSelection( |
| 615 | + context, page, $pages, $index |
| 616 | + ); |
| 617 | + break; |
| 618 | + } |
| 619 | + if ( $section !== null && id !== 'main' ) { |
| 620 | + $section.css( 'display', selected == id ? 'block' : 'none' ); |
| 621 | + } |
| 622 | + return $section; |
| 623 | + }, |
| 624 | + updateBookletSelection: function( context, id, $pages, $index ) { |
| 625 | + var cookie = |
| 626 | + 'wikiEditor-' + context.instance + '-booklet-' + id + '-page'; |
| 627 | + var selected = $.cookie( cookie ); |
| 628 | + if ( $index.find( '*[rel=' + selected + ']' ).size() == 0 ) { |
| 629 | + selected = $index.find( ':first' ).attr( 'rel' ); |
| 630 | + $.cookie( cookie, selected ); |
| 631 | + } |
| 632 | + $pages.children().hide(); |
| 633 | + $pages.find( '*[rel=' + selected + ']' ).show(); |
| 634 | + $index.children().removeClass( 'current' ); |
| 635 | + $index.find( '*[rel=' + selected + ']' ).addClass( 'current' ); |
| 636 | + }, |
432 | 637 | build: function( context, config ) { |
433 | 638 | var $tabs = $( '<div></div>' ) |
434 | 639 | .addClass( 'tabs' ) |
— | — | @@ -438,9 +643,6 @@ |
439 | 644 | context.modules.$toolbar.append( |
440 | 645 | $( '<div></div>' ).css( 'clear', 'both' ) |
441 | 646 | ); |
442 | | - var selected = $.cookie( |
443 | | - 'wikiEditor-' + context.instance + '-toolbar-section' |
444 | | - ); |
445 | 647 | var sectionQueue = []; |
446 | 648 | for ( section in config ) { |
447 | 649 | if ( section == 'main' ) { |
— | — | @@ -450,58 +652,16 @@ |
451 | 653 | ) |
452 | 654 | ); |
453 | 655 | } else { |
454 | | - s = { |
| 656 | + sectionQueue.push( { |
| 657 | + '$sections': $sections, |
455 | 658 | 'context': context, |
456 | | - '$sections': $sections, |
457 | | - '$tabs': $tabs, |
458 | | - 'section': section, |
459 | | - 'config': config[section], |
460 | | - 'selected': ( selected == section ) |
461 | | - }; |
462 | | - sectionQueue[sectionQueue.length] = s; |
463 | | - s.$tabs.append( |
464 | | - $( '<span></span>' ) |
465 | | - .attr( { |
466 | | - 'class': 'tab tab-' + s.section, |
467 | | - 'rel': s.section |
468 | | - } ) |
469 | | - .append( |
470 | | - $( '<a></a>' ) |
471 | | - .addClass( s.selected ? 'current' : null ) |
472 | | - .attr( 'href', '#' ) |
473 | | - .text( |
474 | | - $.wikiEditor.modules.toolbar.fn.autoMsg( |
475 | | - s.config, 'label' |
476 | | - ) |
477 | | - ) |
478 | | - .data( 'context', s.context ) |
479 | | - .click( function() { |
480 | | - var $section = |
481 | | - $(this).data( 'context' ).$ui.find( |
482 | | - '.section-' + |
483 | | - $(this).parent().attr( 'rel' ) |
484 | | - ); |
485 | | - $(this).blur(); |
486 | | - var show = $section.css( 'display' ) == 'none'; |
487 | | - $section.parent().children().hide(); |
488 | | - $(this) |
489 | | - .parent() |
490 | | - .parent() |
491 | | - .find( 'a' ) |
492 | | - .removeClass( 'current' ); |
493 | | - if ( show ) { |
494 | | - $section.show(); |
495 | | - $(this).addClass( 'current' ); |
496 | | - } |
497 | | - $.cookie( |
498 | | - 'wikiEditor-' + |
499 | | - $(this).data( 'context' ).instance + |
500 | | - '-toolbar-section', |
501 | | - show ? $section.attr( 'rel' ) : null |
502 | | - ); |
503 | | - return false; |
504 | | - } ) |
505 | | - ) |
| 659 | + 'id': section, |
| 660 | + 'config': config[section] |
| 661 | + } ); |
| 662 | + $tabs.append( |
| 663 | + $.wikiEditor.modules.toolbar.fn.buildTab( |
| 664 | + context, section, config[section] |
| 665 | + ) |
506 | 666 | ); |
507 | 667 | } |
508 | 668 | } |
— | — | @@ -516,11 +676,9 @@ |
517 | 677 | 'loop': function( i, s ) { |
518 | 678 | s.$sections.append( |
519 | 679 | $.wikiEditor.modules.toolbar.fn.buildSection( |
520 | | - s.context, s.section, s.config |
| 680 | + s.context, s.id, s.config |
521 | 681 | ) |
522 | | - .css( 'display', s.selected ? 'block' : 'none' ) |
523 | 682 | ); |
524 | | - |
525 | 683 | } |
526 | 684 | } ); |
527 | 685 | } |
Index: trunk/extensions/UsabilityInitiative/js/tests/wikiEditor.toolbar.js |
— | — | @@ -3,36 +3,191 @@ |
4 | 4 | */ |
5 | 5 | var textareaId = '#wpTextbox1'; |
6 | 6 | var wikiEditorTests = { |
7 | | - // Should remove Á from latin characters |
| 7 | + // Add emoticons section |
| 8 | + 'add_sections_toolbar': { |
| 9 | + 'call': 'addToToolbar', |
| 10 | + 'data': { |
| 11 | + 'sections': { |
| 12 | + 'emoticons': { |
| 13 | + 'type': 'toolbar', |
| 14 | + 'label': 'Emoticons' |
| 15 | + } |
| 16 | + } |
| 17 | + }, |
| 18 | + 'test': '*[rel=emoticons].section', |
| 19 | + 'pre': 0, |
| 20 | + 'post': 1 |
| 21 | + }, |
| 22 | + // Add faces group to emoticons section |
| 23 | + 'add_groups': { |
| 24 | + 'call': 'addToToolbar', |
| 25 | + 'data': { |
| 26 | + 'section': 'emoticons', |
| 27 | + 'groups': { |
| 28 | + 'faces': { |
| 29 | + 'label': 'Faces' |
| 30 | + } |
| 31 | + } |
| 32 | + }, |
| 33 | + 'test': '*[rel=emoticons].section *[rel=faces].group', |
| 34 | + 'pre': 0, |
| 35 | + 'post': 1 |
| 36 | + }, |
| 37 | + // Add smile tool to faces group of emoticons section |
| 38 | + 'add_tools': { |
| 39 | + 'call': 'addToToolbar', |
| 40 | + 'data': { |
| 41 | + 'section': 'emoticons', |
| 42 | + 'group': 'faces', |
| 43 | + 'tools': { |
| 44 | + 'smile': { |
| 45 | + label: 'Smile!', |
| 46 | + type: 'button', |
| 47 | + icon: 'http://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png', |
| 48 | + action: { |
| 49 | + type: 'encapsulate', |
| 50 | + options: { |
| 51 | + pre: ":)", |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + }, |
| 57 | + 'test': '*[rel=emoticons].section *[rel=faces].group *[rel=smile].tool', |
| 58 | + 'pre': 0, |
| 59 | + 'post': 1 |
| 60 | + }, |
| 61 | + // Add info section |
| 62 | + 'add_sections_booklet': { |
| 63 | + 'call': 'addToToolbar', |
| 64 | + 'data': { |
| 65 | + 'sections': { |
| 66 | + 'info': { |
| 67 | + 'type': 'booklet', |
| 68 | + 'label': 'Info' |
| 69 | + } |
| 70 | + } |
| 71 | + }, |
| 72 | + 'test': '*[rel=info].section', |
| 73 | + 'pre': 0, |
| 74 | + 'post': 1 |
| 75 | + }, |
| 76 | + // Add info section |
| 77 | + 'add_pages_table': { |
| 78 | + 'call': 'addToToolbar', |
| 79 | + 'data': { |
| 80 | + 'section': 'info', |
| 81 | + 'pages': { |
| 82 | + 'colors': { |
| 83 | + 'layout': 'table', |
| 84 | + 'label': 'Colors', |
| 85 | + 'headings': [ |
| 86 | + { content: 'Name' }, |
| 87 | + { content: 'Temperature' }, |
| 88 | + { content: 'Swatch' } |
| 89 | + ] |
| 90 | + } |
| 91 | + } |
| 92 | + }, |
| 93 | + 'test': '*[rel=info].section *[rel=colors].page', |
| 94 | + 'pre': 0, |
| 95 | + 'post': 1 |
| 96 | + }, |
| 97 | + // Add colors rows |
| 98 | + 'add_rows': { |
| 99 | + 'call': 'addToToolbar', |
| 100 | + 'data': { |
| 101 | + 'section': 'info', |
| 102 | + 'page': 'colors', |
| 103 | + 'rows': [ |
| 104 | + { |
| 105 | + 'name': { content: 'Red' }, |
| 106 | + 'temp': { content: 'Warm' }, |
| 107 | + 'swatch': { content: '<div style="width:10px;height:10px;background-color:red;">' } |
| 108 | + }, |
| 109 | + { |
| 110 | + 'name': { content: 'Blue' }, |
| 111 | + 'temp': { content: 'Cold' }, |
| 112 | + 'swatch': { content: '<div style="width:10px;height:10px;background-color:blue;">' } |
| 113 | + }, |
| 114 | + { |
| 115 | + 'name': { content: 'Silver' }, |
| 116 | + 'temp': { content: 'Neutral' }, |
| 117 | + 'swatch': { content: '<div style="width:10px;height:10px;background-color:silver;">' } |
| 118 | + } |
| 119 | + ] |
| 120 | + }, |
| 121 | + 'test': '*[rel=info].section *[rel=colors].page tr td', |
| 122 | + 'pre': 0, |
| 123 | + 'post': 9 |
| 124 | + }, |
| 125 | + // Add |
| 126 | + 'add_pages_characters': { |
| 127 | + 'call': 'addToToolbar', |
| 128 | + 'data': { |
| 129 | + 'section': 'info', |
| 130 | + 'pages': { |
| 131 | + 'emoticons': { |
| 132 | + 'layout': 'characters', |
| 133 | + 'label': 'Emoticons' |
| 134 | + }, |
| 135 | + 'removeme': { |
| 136 | + 'layout': 'characters', |
| 137 | + 'label': 'Remove Me!' |
| 138 | + } |
| 139 | + } |
| 140 | + }, |
| 141 | + 'test': '*[rel=info].section *[rel=emoticons].page', |
| 142 | + 'pre': 0, |
| 143 | + 'post': 1 |
| 144 | + }, |
| 145 | + // Add |
| 146 | + 'add_characters': { |
| 147 | + 'call': 'addToToolbar', |
| 148 | + 'data': { |
| 149 | + 'section': 'info', |
| 150 | + 'page': 'emoticons', |
| 151 | + 'characters': [ ':)', ':))', ':(', '<3', ';)' ] |
| 152 | + }, |
| 153 | + 'test': '*[rel=info].section *[rel=emoticons].page *[rel=":)"]', |
| 154 | + 'pre': 0, |
| 155 | + 'post': 1 |
| 156 | + }, |
| 157 | + // Remove page |
| 158 | + 'remove_page': { |
| 159 | + 'call': 'removeFromToolbar', |
| 160 | + 'data': { |
| 161 | + 'section': 'info', |
| 162 | + 'page': 'removeme' |
| 163 | + }, |
| 164 | + 'test': '*[rel=info].section *[rel=removeme].page', |
| 165 | + 'pre': 1, |
| 166 | + 'post': 0 |
| 167 | + }, |
| 168 | + // Remove :)) from emoticon characters |
8 | 169 | 'remove_character': { |
9 | 170 | 'call': 'removeFromToolbar', |
10 | 171 | 'data': { |
11 | | - 'section': 'characters', |
12 | | - 'page': 'latin', |
13 | | - 'character': 'Á' |
| 172 | + 'section': 'info', |
| 173 | + 'page': 'emoticons', |
| 174 | + 'character': ':))' |
14 | 175 | }, |
15 | | - 'test': 'div[rel=characters].section div[rel=latin].page a[rel=Á]' |
| 176 | + 'test': '*[rel=info].section *[rel=emoticons].page a[rel=":))"]', |
| 177 | + 'pre': 1, |
| 178 | + 'post': 0 |
16 | 179 | }, |
17 | | - 'remove_table_row_0': { |
18 | | - // Should remove the first non-heading row of format help |
| 180 | + // Remove row from colors table of info section |
| 181 | + 'remove_row': { |
19 | 182 | 'call': 'removeFromToolbar', |
20 | 183 | 'data': { |
21 | | - 'section': 'help', |
22 | | - 'page': 'heading', |
| 184 | + 'section': 'info', |
| 185 | + 'page': 'colors', |
23 | 186 | 'row': 0 |
24 | 187 | }, |
25 | | - 'test': 'div[rel=help].section div[rel=format].page table tr td:eq(0):contains("1st level heading")' |
| 188 | + 'test': '*[rel=info].section *[rel=colors].page tr td', |
| 189 | + 'pre': 9, |
| 190 | + 'post': 6 |
26 | 191 | }, |
27 | | - 'remove_table_row_1': { |
28 | | - // Should remove the second non-heading row of link help |
29 | | - 'call': 'removeFromToolbar', |
30 | | - 'data': { |
31 | | - 'section': 'help', |
32 | | - 'page': 'heading', |
33 | | - 'row': 1 |
34 | | - }, |
35 | | - 'test': 'div[rel=help].section div[rel=format].page table tr td:eq(0):contains("3rd level heading")' |
36 | | - } |
37 | 192 | }; |
38 | 193 | js2AddOnloadHook( function() { |
39 | 194 | var button = $j( '<button>Run wikiEditor Tests!</button>' ) |
— | — | @@ -42,6 +197,7 @@ |
43 | 198 | 'right': 0, |
44 | 199 | 'width': '100%', |
45 | 200 | 'backgroundColor': '#333333', |
| 201 | + 'opacity': 0.75, |
46 | 202 | 'color': '#DDDDDD', |
47 | 203 | 'padding': '0.5em', |
48 | 204 | 'border': 'none', |
— | — | @@ -49,22 +205,26 @@ |
50 | 206 | } ) |
51 | 207 | .click( function() { |
52 | 208 | if ( $j(this).attr( 'enabled' ) == 'false' ) { |
53 | | - $j(this).slideUp( 'slow' ); |
| 209 | + $j(this).slideUp( 'fast' ); |
| 210 | + return false; |
54 | 211 | } |
55 | 212 | var messages = [ 'Running tests for wikiEditor API' ]; |
56 | | - var target = $j( textareaId ); |
57 | | - var ui = target.data( 'context' ).$ui; |
| 213 | + var $target = $j( textareaId ); |
| 214 | + var $ui = $target.data( 'context' ).$ui; |
58 | 215 | var passes = 0; |
59 | 216 | var tests = 0; |
60 | 217 | for ( test in wikiEditorTests ) { |
61 | | - target.wikiEditor( |
| 218 | + var pre = $ui.find( wikiEditorTests[test].test ).size() == |
| 219 | + wikiEditorTests[test].pre; |
| 220 | + messages.push ( test + '-pre: ' + ( pre ? 'PASS' : 'FAIL' ) ); |
| 221 | + $target.wikiEditor( |
62 | 222 | wikiEditorTests[test].call, |
63 | 223 | wikiEditorTests[test].data |
64 | 224 | ); |
65 | | - var pass = ui.find( wikiEditorTests[test].test ).size() == 0; |
66 | | - messages.push ( |
67 | | - test + ':' + ( pass ? 'PASS' : 'FAIL' ) ); |
68 | | - if ( pass ) { |
| 225 | + var post = $ui.find( wikiEditorTests[test].test ).size() == |
| 226 | + wikiEditorTests[test].post; |
| 227 | + messages.push ( test + '-post: ' + ( post ? 'PASS' : 'FAIL' ) ); |
| 228 | + if ( pre && post ) { |
69 | 229 | passes++; |
70 | 230 | } |
71 | 231 | tests++; |
— | — | @@ -76,11 +236,11 @@ |
77 | 237 | } |
78 | 238 | $j(this) |
79 | 239 | .attr( 'title', messages.join( " | " ) ) |
80 | | - .text( tests + ' / ' + passes + ' were successful' ) |
| 240 | + .text( passes + ' / ' + tests + ' were successful' ) |
81 | 241 | .css( 'backgroundColor', passes < tests ? 'red' : 'green' ) |
82 | 242 | .attr( 'enabled', 'false' ) |
83 | 243 | .blur(); |
84 | 244 | } ) |
85 | 245 | .appendTo( $j( 'body' ) ); |
86 | | - button.slideDown( 'slow' ) |
| 246 | + setTimeout( function() { button.slideDown( 'fast' ) }, 2000 ); |
87 | 247 | } ); |
\ No newline at end of file |