Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -475,7 +475,6 @@ |
476 | 476 | "\u215c", "\u215d", "\u215e", "\u221e", |
477 | 477 | "\u2018", "\u201c", "\u2019", |
478 | 478 | "\u201d", { |
479 | | - 'type': 'link', |
480 | 479 | 'label': "\u00ab\u00bb", |
481 | 480 | 'action': { |
482 | 481 | 'type': 'encapsulate', |
— | — | @@ -499,9 +498,7 @@ |
500 | 499 | 'greek': { |
501 | 500 | 'labelMsg': 'edittoolbar-characters-page-greek', |
502 | 501 | 'layout': 'characters', |
503 | | - 'attributes': { |
504 | | - 'lang': 'hl' |
505 | | - }, |
| 502 | + 'language': 'hl', |
506 | 503 | 'characters': ["\u0391", |
507 | 504 | "\u0386", "\u03b1", "\u03ac", "\u0392", |
508 | 505 | "\u03b2", "\u0393", "\u03b3", "\u0394", |
— | — | @@ -558,13 +555,8 @@ |
559 | 556 | 'arabic': { |
560 | 557 | 'labelMsg': 'edittoolbar-characters-page-arabic', |
561 | 558 | 'layout': 'characters', |
562 | | - 'attributes': { |
563 | | - 'lang': 'ar', |
564 | | - 'class': 'rtl' |
565 | | - }, |
566 | | - 'styles': { |
567 | | - 'font-size': '1.25em' |
568 | | - }, |
| 559 | + 'language': 'ar', |
| 560 | + 'direction': 'rtl', |
569 | 561 | 'characters': ["\u061b", |
570 | 562 | "\u061f", "\u0621", "\u0622", "\u0623", |
571 | 563 | "\u0624", "\u0625", "\u0626", "\u0627", |
— | — | @@ -581,9 +573,7 @@ |
582 | 574 | 'hebrew': { |
583 | 575 | 'labelMsg': 'edittoolbar-characters-page-hebrew', |
584 | 576 | 'layout': 'characters', |
585 | | - 'attributes': { |
586 | | - 'class': 'rtl' |
587 | | - }, |
| 577 | + 'direction': 'rtl', |
588 | 578 | 'characters': ["\u05d0", |
589 | 579 | "\u05d1", "\u05d2", "\u05d3", "\u05d4", |
590 | 580 | "\u05d5", "\u05d6", "\u05d7", "\u05d8", |
Index: trunk/extensions/UsabilityInitiative/css/wikiEditor.toolbar.css |
— | — | @@ -172,78 +172,75 @@ |
173 | 173 | font-size: 0.9em; |
174 | 174 | } |
175 | 175 | /* Booklet */ |
176 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index { |
| 176 | +.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index { |
177 | 177 | float: left; |
178 | 178 | width: 20%; |
179 | 179 | height: 125px; |
180 | 180 | overflow: auto; |
181 | 181 | } |
182 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index { |
| 182 | +body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index { |
183 | 183 | float: right; |
184 | 184 | } |
185 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index div { |
| 185 | +.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index div { |
186 | 186 | padding: 4px; |
187 | 187 | padding-left: 6px; |
188 | 188 | cursor: pointer; |
189 | 189 | color: #0645ad; |
190 | 190 | } |
191 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index div { |
| 191 | +body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index div { |
192 | 192 | padding-left: 4px; |
193 | 193 | padding-right: 6px; |
194 | 194 | } |
195 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index .current { |
| 195 | +.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index .current { |
196 | 196 | background-color: #FAFAFA; |
197 | 197 | color: #333333; |
198 | 198 | cursor: default; |
199 | 199 | } |
200 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .pages { |
| 200 | +.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .pages { |
201 | 201 | float: right; |
202 | 202 | width: 80%; |
203 | 203 | height: 125px; |
204 | 204 | overflow: auto; |
205 | 205 | background-color: #FAFAFA; |
206 | 206 | } |
207 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .pages { |
| 207 | +body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .pages { |
208 | 208 | float: left; |
209 | 209 | } |
210 | 210 | /* Help Pages */ |
211 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page { |
212 | | - display: none; |
213 | | -} |
214 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table { |
| 211 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table { |
215 | 212 | padding-left: 5px; |
216 | 213 | padding-right: 5px; |
217 | 214 | background: none; |
218 | 215 | } |
219 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table th { |
| 216 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th { |
220 | 217 | color: #999999; |
221 | 218 | } |
222 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td { |
| 219 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td { |
223 | 220 | color: black; |
224 | 221 | border-top: solid 1px #EEEEEE; |
225 | 222 | } |
226 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table th, |
227 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td { |
| 223 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th, |
| 224 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td { |
228 | 225 | text-align: left; |
229 | 226 | padding: 5px; |
230 | 227 | margin: 0px; |
231 | 228 | } |
232 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table th, |
233 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td { |
| 229 | +body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th, |
| 230 | +body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td { |
234 | 231 | text-align: right; |
235 | 232 | } |
236 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td.syntax { |
| 233 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.syntax { |
237 | 234 | font-family: monospace; |
238 | 235 | } |
239 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td.syntax, |
240 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td.result { |
| 236 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.syntax, |
| 237 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.result { |
241 | 238 | width: 40%; |
242 | 239 | } |
243 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td.description { |
| 240 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.description { |
244 | 241 | width: 20%; |
245 | 242 | } |
246 | 243 | /* Characters Pages */ |
247 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-characters .page div a { |
| 244 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div a { |
248 | 245 | border: solid 1px #DDDDDD; |
249 | 246 | padding: 5px; |
250 | 247 | padding-left: 8px; |
— | — | @@ -256,14 +253,14 @@ |
257 | 254 | color: black; |
258 | 255 | text-decoration: none; |
259 | 256 | } |
260 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-characters .page > div > a, |
261 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-characters .page .rtl a { |
| 257 | +body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters > div > a, |
| 258 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div.rtl a { |
262 | 259 | direction: rtl; |
263 | 260 | float: right; |
264 | 261 | margin-left: 0; |
265 | 262 | margin-right: 5px; |
266 | 263 | } |
267 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-characters .page div a:hover { |
| 264 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div a:hover { |
268 | 265 | background-color: white; |
269 | 266 | text-decoration: none; |
270 | 267 | border-color: #a8d7f9; |
Index: trunk/extensions/UsabilityInitiative/css/combined.css |
— | — | @@ -243,78 +243,75 @@ |
244 | 244 | font-size: 0.9em; |
245 | 245 | } |
246 | 246 | /* Booklet */ |
247 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index { |
| 247 | +.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index { |
248 | 248 | float: left; |
249 | 249 | width: 20%; |
250 | 250 | height: 125px; |
251 | 251 | overflow: auto; |
252 | 252 | } |
253 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index { |
| 253 | +body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index { |
254 | 254 | float: right; |
255 | 255 | } |
256 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index div { |
| 256 | +.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index div { |
257 | 257 | padding: 4px; |
258 | 258 | padding-left: 6px; |
259 | 259 | cursor: pointer; |
260 | 260 | color: #0645ad; |
261 | 261 | } |
262 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index div { |
| 262 | +body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index div { |
263 | 263 | padding-left: 4px; |
264 | 264 | padding-right: 6px; |
265 | 265 | } |
266 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index .current { |
| 266 | +.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index .current { |
267 | 267 | background-color: #FAFAFA; |
268 | 268 | color: #333333; |
269 | 269 | cursor: default; |
270 | 270 | } |
271 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .pages { |
| 271 | +.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .pages { |
272 | 272 | float: right; |
273 | 273 | width: 80%; |
274 | 274 | height: 125px; |
275 | 275 | overflow: auto; |
276 | 276 | background-color: #FAFAFA; |
277 | 277 | } |
278 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .pages { |
| 278 | +body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .pages { |
279 | 279 | float: left; |
280 | 280 | } |
281 | 281 | /* Help Pages */ |
282 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page { |
283 | | - display: none; |
284 | | -} |
285 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table { |
| 282 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table { |
286 | 283 | padding-left: 5px; |
287 | 284 | padding-right: 5px; |
288 | 285 | background: none; |
289 | 286 | } |
290 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table th { |
| 287 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th { |
291 | 288 | color: #999999; |
292 | 289 | } |
293 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td { |
| 290 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td { |
294 | 291 | color: black; |
295 | 292 | border-top: solid 1px #EEEEEE; |
296 | 293 | } |
297 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table th, |
298 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td { |
| 294 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th, |
| 295 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td { |
299 | 296 | text-align: left; |
300 | 297 | padding: 5px; |
301 | 298 | margin: 0px; |
302 | 299 | } |
303 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table th, |
304 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td { |
| 300 | +body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th, |
| 301 | +body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td { |
305 | 302 | text-align: right; |
306 | 303 | } |
307 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td.syntax { |
| 304 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.syntax { |
308 | 305 | font-family: monospace; |
309 | 306 | } |
310 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td.syntax, |
311 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td.result { |
| 307 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.syntax, |
| 308 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.result { |
312 | 309 | width: 40%; |
313 | 310 | } |
314 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td.description { |
| 311 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.description { |
315 | 312 | width: 20%; |
316 | 313 | } |
317 | 314 | /* Characters Pages */ |
318 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-characters .page div a { |
| 315 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div a { |
319 | 316 | border: solid 1px #DDDDDD; |
320 | 317 | padding: 5px; |
321 | 318 | padding-left: 8px; |
— | — | @@ -327,14 +324,14 @@ |
328 | 325 | color: black; |
329 | 326 | text-decoration: none; |
330 | 327 | } |
331 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-characters .page > div > a, |
332 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-characters .page .rtl a { |
| 328 | +body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters > div > a, |
| 329 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div.rtl a { |
333 | 330 | direction: rtl; |
334 | 331 | float: right; |
335 | 332 | margin-left: 0; |
336 | 333 | margin-right: 5px; |
337 | 334 | } |
338 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-characters .page div a:hover { |
| 335 | +.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div a:hover { |
339 | 336 | background-color: white; |
340 | 337 | text-decoration: none; |
341 | 338 | border-color: #a8d7f9; |
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css |
— | — | @@ -1 +1 @@ |
2 | | -@CHARSET "UTF-8";form#editform{margin:0;padding:0;}.wikiEditor-ui textarea#wpTextbox1{border:none;margin:0;padding:0;width:100%;}.wikiEditor-ui{position:relative;border:solid silver 1px;background-color:#f3f3f3;clear:both;line-height:1em;}.wikiEditor-ui .wikiEditor-ui-bottom{position:relative;}@CHARSET "UTF-8";.wikiEditor-ui .wikiEditor-ui-toc{position:absolute;right:-1px;top:0;padding:0;border-left:solid silver 1px;overflow:auto;}body.rtl .wikiEditor-ui .wikiEditor-ui-toc{right:auto;left:-1px;border-left:none;border-right:solid silver 1px;}.wikiEditor-ui .wikiEditor-ui-toc ul{padding:0;margin:0.5em 1em;list-style:none;}.wikiEditor-ui .wikiEditor-ui-toc ul ul{padding:0;margin:0;margin-left:0.75em;margin-bottom:0 !important;margin-top:0 !important;list-style:none;}body.rtl .wikiEditor-ui .wikiEditor-ui-toc ul ul{margin-left:0;margin-right:0.75em;}.wikiEditor-ui .wikiEditor-ui-toc ul li a{display:block;font-size:0.9em;}.wikiEditor-ui .wikiEditor-ui-toc ul li a.currentSelection{font-weight:bold;}.wikiEditor-ui .wikiEditor-ui-toc ul li a.section-0{font-size:1em;border-bottom:solid 1px #DDDDDD;}@CHARSET "UTF-8";.wikiEditor-ui .wikiEditor-ui-toolbar{background-color:#F3F3F3;}.wikiEditor-ui .wikiEditor-ui-toolbar .break{border-bottom:solid silver 1px;clear:both;}.wikiEditor-ui .wikiEditor-ui-toolbar .sections{float:left;width:100%;clear:both;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections{float:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .sections .section{display:none;float:left;width:100%;margin-left:-1px;border-left:solid silver 1px;border-right:solid silver 1px;border-top:solid 1px #DDDDDD;background-color:#F3F3F3;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections .section{float:right;margin-left:auto;margin-right:-1px;}.wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading{padding-top:0.5em;padding-bottom:0.5em;}.wikiEditor-ui .wikiEditor-ui-toolbar .sections div .spinner{display:none;}.wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading .spinner{display:block;background-image:url(../images/wikiEditor/toolbar/loading.gif);background-position:left center;background-repeat:no-repeat;padding-left:32px;margin-left:1em;float:left;color:#666666;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading .spinner{background-position:right center;padding-left:0;padding-right:32px;margin-left:0;margin-right:1em;float:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .tabs,.wikiEditor-ui .wikiEditor-ui-toolbar .group{float:left;height:26px;margin:3px;padding:0;padding-right:6px;border-right:solid 1px #DDDDDD;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs,body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group{float:right;padding-right:0;padding-left:6px;border-right:none;border-left:solid 1px #DDDDDD;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .first{border-right:none;}.wikiEditor-ui .wikiEditor-ui-toolbar .tabs{list-style:none;}.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab{display:inline-block;float:left;line-height:26px;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab{float:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a,.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a:visited{display:inline-block;float:left;padding-left:18px;padding-right:12px;height:26px;cursor:pointer;color:#0645ad;background-image:url(../images/wikiEditor/toolbar/arrow-right.png);background-position:left center;background-repeat:no-repeat;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a,body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a:visited{padding-left:12px;padding-right:18px;background-image:url(../images/wikiEditor/toolbar/arrow-left.png);background-position:right center;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab > a,body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > pan.tab > a:visited{float:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current,.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:visited{color:#333333;background-image:url(../images/wikiEditor/toolbar/arrow-down.png);}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current,body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:visited{background-image:url(../images/wikiEditor/toolbar/arrow-down.png);}.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:hover{text-decoration:none;}.wikiEditor-ui .wikiEditor-ui-toolbar .group .label{float:left;border:0px;height:22px;line-height:22px;margin:2px;margin-left:5px;margin-right:8px;color:#777777;cursor:default;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > .label{float:right;margin-left:8px;margin-right:5px;}.wikiEditor-ui .wikiEditor-ui-toolbar .group input.tool{float:left;border:0px;height:22px;width:22px;padding:2px;cursor:pointer;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > input.tool{float:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .group select{float:left;margin:2px;height:22px;cursor:pointer;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > select{float:right;font-size:0.9em;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index{float:left;width:20%;height:125px;overflow:auto;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index{float:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index div{padding:4px;padding-left:6px;cursor:pointer;color:#0645ad;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index div{padding-left:4px;padding-right:6px;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .index .current{background-color:#FAFAFA;color:#333333;cursor:default;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .pages{float:right;width:80%;height:125px;overflow:auto;background-color:#FAFAFA;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet .pages{float:left;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page{display:none;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table{padding-left:5px;padding-right:5px;background:none;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table th{color:#999999;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td{color:black;border-top:solid 1px #EEEEEE;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table th,.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td{text-align:left;padding:5px;margin:0px;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table th,body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td{text-align:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td.syntax{font-family:monospace;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td.syntax,.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td.result{width:40%;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-help .page table td.description{width:20%;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-characters .page div a{border:solid 1px #DDDDDD;padding:5px;padding-left:8px;padding-right:8px;margin-left:5px;margin-top:5px;height:1em;float:left;display:block;color:black;text-decoration:none;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-characters .page > div > a,.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-characters .page .rtl a{direction:rtl;float:right;margin-left:0;margin-right:5px;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-booklet-characters .page div a:hover{background-color:white;text-decoration:none;border-color:#a8d7f9;} |
| 2 | +@CHARSET "UTF-8";form#editform{margin:0;padding:0;}.wikiEditor-ui textarea#wpTextbox1{border:none;margin:0;padding:0;width:100%;}.wikiEditor-ui{position:relative;border:solid silver 1px;background-color:#f3f3f3;clear:both;line-height:1em;}.wikiEditor-ui .wikiEditor-ui-bottom{position:relative;}@CHARSET "UTF-8";.wikiEditor-ui .wikiEditor-ui-toc{position:absolute;right:-1px;top:0;padding:0;border-left:solid silver 1px;overflow:auto;}body.rtl .wikiEditor-ui .wikiEditor-ui-toc{right:auto;left:-1px;border-left:none;border-right:solid silver 1px;}.wikiEditor-ui .wikiEditor-ui-toc ul{padding:0;margin:0.5em 1em;list-style:none;}.wikiEditor-ui .wikiEditor-ui-toc ul ul{padding:0;margin:0;margin-left:0.75em;margin-bottom:0 !important;margin-top:0 !important;list-style:none;}body.rtl .wikiEditor-ui .wikiEditor-ui-toc ul ul{margin-left:0;margin-right:0.75em;}.wikiEditor-ui .wikiEditor-ui-toc ul li a{display:block;font-size:0.9em;}.wikiEditor-ui .wikiEditor-ui-toc ul li a.currentSelection{font-weight:bold;}.wikiEditor-ui .wikiEditor-ui-toc ul li a.section-0{font-size:1em;border-bottom:solid 1px #DDDDDD;}@CHARSET "UTF-8";.wikiEditor-ui .wikiEditor-ui-toolbar{background-color:#F3F3F3;}.wikiEditor-ui .wikiEditor-ui-toolbar .break{border-bottom:solid silver 1px;clear:both;}.wikiEditor-ui .wikiEditor-ui-toolbar .sections{float:left;width:100%;clear:both;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections{float:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .sections .section{display:none;float:left;width:100%;margin-left:-1px;border-left:solid silver 1px;border-right:solid silver 1px;border-top:solid 1px #DDDDDD;background-color:#F3F3F3;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections .section{float:right;margin-left:auto;margin-right:-1px;}.wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading{padding-top:0.5em;padding-bottom:0.5em;}.wikiEditor-ui .wikiEditor-ui-toolbar .sections div .spinner{display:none;}.wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading .spinner{display:block;background-image:url(../images/wikiEditor/toolbar/loading.gif);background-position:left center;background-repeat:no-repeat;padding-left:32px;margin-left:1em;float:left;color:#666666;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading .spinner{background-position:right center;padding-left:0;padding-right:32px;margin-left:0;margin-right:1em;float:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .tabs,.wikiEditor-ui .wikiEditor-ui-toolbar .group{float:left;height:26px;margin:3px;padding:0;padding-right:6px;border-right:solid 1px #DDDDDD;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs,body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group{float:right;padding-right:0;padding-left:6px;border-right:none;border-left:solid 1px #DDDDDD;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .first{border-right:none;}.wikiEditor-ui .wikiEditor-ui-toolbar .tabs{list-style:none;}.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab{display:inline-block;float:left;line-height:26px;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab{float:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a,.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a:visited{display:inline-block;float:left;padding-left:18px;padding-right:12px;height:26px;cursor:pointer;color:#0645ad;background-image:url(../images/wikiEditor/toolbar/arrow-right.png);background-position:left center;background-repeat:no-repeat;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a,body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a:visited{padding-left:12px;padding-right:18px;background-image:url(../images/wikiEditor/toolbar/arrow-left.png);background-position:right center;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab > a,body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > pan.tab > a:visited{float:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current,.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:visited{color:#333333;background-image:url(../images/wikiEditor/toolbar/arrow-down.png);}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current,body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:visited{background-image:url(../images/wikiEditor/toolbar/arrow-down.png);}.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:hover{text-decoration:none;}.wikiEditor-ui .wikiEditor-ui-toolbar .group .label{float:left;border:0px;height:22px;line-height:22px;margin:2px;margin-left:5px;margin-right:8px;color:#777777;cursor:default;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > .label{float:right;margin-left:8px;margin-right:5px;}.wikiEditor-ui .wikiEditor-ui-toolbar .group input.tool{float:left;border:0px;height:22px;width:22px;padding:2px;cursor:pointer;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > input.tool{float:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .group select{float:left;margin:2px;height:22px;cursor:pointer;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > select{float:right;font-size:0.9em;}.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index{float:left;width:20%;height:125px;overflow:auto;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index{float:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index div{padding:4px;padding-left:6px;cursor:pointer;color:#0645ad;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index div{padding-left:4px;padding-right:6px;}.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index .current{background-color:#FAFAFA;color:#333333;cursor:default;}.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .pages{float:right;width:80%;height:125px;overflow:auto;background-color:#FAFAFA;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .pages{float:left;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table{padding-left:5px;padding-right:5px;background:none;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th{color:#999999;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td{color:black;border-top:solid 1px #EEEEEE;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th,.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td{text-align:left;padding:5px;margin:0px;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th,body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td{text-align:right;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.syntax{font-family:monospace;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.syntax,.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.result{width:40%;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.description{width:20%;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div a{border:solid 1px #DDDDDD;padding:5px;padding-left:8px;padding-right:8px;margin-left:5px;margin-top:5px;height:1em;float:left;display:block;color:black;text-decoration:none;}body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters > div > a,.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div.rtl a{direction:rtl;float:right;margin-left:0;margin-right:5px;}.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div a:hover{background-color:white;text-decoration:none;border-color:#a8d7f9;} |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -860,6 +860,7 @@ |
861 | 861 | };})(jQuery);/** |
862 | 862 | * Toolbar module for wikiEditor |
863 | 863 | */ |
| 864 | + |
864 | 865 | (function($) { $.wikiEditor.modules.toolbar = { |
865 | 866 | /** |
866 | 867 | * Path to images - this is a bit messy, and it would need to change if this |
— | — | @@ -871,6 +872,12 @@ |
872 | 873 | * API accessible functions |
873 | 874 | */ |
874 | 875 | api: { |
| 876 | + addToToolbar: function( context, data ) { |
| 877 | + // |
| 878 | + }, |
| 879 | + modifyToolbar: function( context, data ) { |
| 880 | + // |
| 881 | + }, |
875 | 882 | removeFromToolbar: function( context, data ) { |
876 | 883 | if ( typeof data.section == 'string' ) { |
877 | 884 | var selector = 'div[rel=' + data.section + '].section'; |
— | — | @@ -888,6 +895,16 @@ |
889 | 896 | * Internally used functions |
890 | 897 | */ |
891 | 898 | fn: { |
| 899 | + // Wraps gM from js2, but allows raw text to supercede |
| 900 | + autoMsg: function( object, property ) { |
| 901 | + if ( property in object ) { |
| 902 | + return object[property]; |
| 903 | + } else if ( property + 'Msg' in object ) { |
| 904 | + return gM( object[property + 'Msg'] ); |
| 905 | + } else { |
| 906 | + return ''; |
| 907 | + } |
| 908 | + }, |
892 | 909 | /** |
893 | 910 | * Creates a toolbar module within a wikiEditor |
894 | 911 | * |
— | — | @@ -910,7 +927,7 @@ |
911 | 928 | * @param {Object} context |
912 | 929 | * @param {Object} action |
913 | 930 | */ |
914 | | - performAction: function( context, action ) { |
| 931 | + doAction: function( context, action ) { |
915 | 932 | switch ( action.type) { |
916 | 933 | case 'encapsulate': |
917 | 934 | var parts = { 'pre': '', 'peri': '', 'post': '' }; |
— | — | @@ -931,320 +948,285 @@ |
932 | 949 | default: break; |
933 | 950 | } |
934 | 951 | }, |
935 | | - /** |
936 | | - * Adds a toolbar section to a containing div |
937 | | - * |
938 | | - * @param {Object} context |
939 | | - * @param {Object} $section Container to add section content to |
940 | | - * @param {Object} section Configuration to build toolbar from |
941 | | - * @param {String} sectionId Unique identifier of this section |
942 | | - */ |
943 | | - addSection: function( context, $section, section, sectionId ) { |
944 | | - /** |
945 | | - * Wraps performAction with tool specific UI interaction |
946 | | - */ |
947 | | - var useTool = function() { |
948 | | - var tool = $(this).data( 'tool' ); |
949 | | - if ( 'type' in tool ) { |
950 | | - switch ( tool.type ) { |
951 | | - case 'button': |
952 | | - case 'link': |
953 | | - if ( 'action' in tool ) { |
954 | | - $.wikiEditor.modules.toolbar.fn.performAction( |
955 | | - context, tool.action |
956 | | - ); |
957 | | - } |
958 | | - break; |
959 | | - case 'select': |
960 | | - if ( 'list' in tool && $(this).val() in tool.list ) { |
961 | | - $.wikiEditor.modules.toolbar.fn.performAction( |
962 | | - context, tool.list[$(this).val()].action |
963 | | - ); |
964 | | - } |
965 | | - $(this).find(":selected").attr( 'selected', false ); |
966 | | - $(this).find(":first").attr( 'selected', true ); |
967 | | - break; |
| 952 | + buildSection: function( context, id, section ) { |
| 953 | + switch ( section.type ) { |
| 954 | + case 'toolbar': |
| 955 | + return $.wikiEditor.modules.toolbar.fn.buildToolbar( |
| 956 | + context, id, section |
| 957 | + ); |
| 958 | + case 'booklet': |
| 959 | + return $.wikiEditor.modules.toolbar.fn.buildBooklet( |
| 960 | + context, id, section |
| 961 | + ); |
| 962 | + default: return null; |
| 963 | + } |
| 964 | + }, |
| 965 | + buildToolbar: function( context, id, toolbar ) { |
| 966 | + var $toolbar = $( '<div></div>' ).attr( { |
| 967 | + 'class': 'toolbar section section-' + id, |
| 968 | + 'rel': id |
| 969 | + } ); |
| 970 | + if ( 'groups' in toolbar ) { |
| 971 | + for ( group in toolbar.groups ) { |
| 972 | + $toolbar.append( |
| 973 | + $.wikiEditor.modules.toolbar.fn.buildGroup( |
| 974 | + context, group, toolbar.groups[group] |
| 975 | + ) |
| 976 | + ); |
| 977 | + } |
| 978 | + } |
| 979 | + return $toolbar; |
| 980 | + }, |
| 981 | + buildGroup: function( context, id, group ) { |
| 982 | + var $group = $( '<div></div>' ).attr( { |
| 983 | + 'class': 'group group-' + id, |
| 984 | + 'rel': id |
| 985 | + } ); |
| 986 | + var label = $.wikiEditor.modules.toolbar.fn.autoMsg( group, 'label' ); |
| 987 | + if ( label ) { |
| 988 | + $group.append( |
| 989 | + $( '<div></div>' ).text( label ).addClass( 'label' ) |
| 990 | + ) |
| 991 | + } |
| 992 | + if ( 'tools' in group ) { |
| 993 | + for ( tool in group.tools ) { |
| 994 | + $group.append( |
| 995 | + $.wikiEditor.modules.toolbar.fn.buildTool( |
| 996 | + context, tool, group.tools[tool] |
| 997 | + ) |
| 998 | + ); |
| 999 | + } |
| 1000 | + } |
| 1001 | + return $group; |
| 1002 | + }, |
| 1003 | + buildTool: function( context, id, tool ) { |
| 1004 | + if ( 'filters' in tool ) { |
| 1005 | + for ( filter in tool.filters ) { |
| 1006 | + if ( $( tool.filters[filter] ).size() == 0 ) { |
| 1007 | + return null; |
968 | 1008 | } |
969 | 1009 | } |
970 | | - return false; |
971 | 1010 | } |
972 | | - /** |
973 | | - * Adds tools to a group |
974 | | - * |
975 | | - * @param {Object} $group jQuery selection to add tools to |
976 | | - * @param {Object} tools Configurations for tools |
977 | | - * @param {String} sectionId Unique ID of section |
978 | | - */ |
979 | | - function addTools( $group, tools, sectionId ) { |
980 | | - for ( tool in section.groups[group].tools ) { |
981 | | - // Filters are the input to a jQuery selector. The tool will |
982 | | - // only be shown if the selection contains one or more elements |
983 | | - if ( 'filters' in tools[tool] ) { |
984 | | - var skip = false; |
985 | | - for ( filter in tools[tool].filters ) { |
986 | | - if ( $( tools[tool].filters[filter] ).size() == 0 ) { |
987 | | - skip = true; |
988 | | - } |
989 | | - } |
990 | | - if ( skip ) { |
991 | | - continue; |
992 | | - } |
| 1011 | + var label = $.wikiEditor.modules.toolbar.fn.autoMsg( tool, 'label' ); |
| 1012 | + switch ( tool.type ) { |
| 1013 | + case 'button': |
| 1014 | + $button = $( '<input />' ).attr( { |
| 1015 | + 'type': 'image', |
| 1016 | + 'src': $.wikiEditor.modules.toolbar.imgPath + tool.icon, |
| 1017 | + 'alt': label, |
| 1018 | + 'title': label, |
| 1019 | + 'rel': id, |
| 1020 | + 'class': 'tool tool-' + id |
| 1021 | + } ); |
| 1022 | + if ( 'action' in tool ) { |
| 1023 | + $button |
| 1024 | + .data( 'action', tool.action ) |
| 1025 | + .data( 'context', context ) |
| 1026 | + .click( function() { |
| 1027 | + $.wikiEditor.modules.toolbar.fn.doAction( |
| 1028 | + $(this).data( 'context' ), |
| 1029 | + $(this).data( 'action' ) |
| 1030 | + ); |
| 1031 | + return false; |
| 1032 | + } ); |
993 | 1033 | } |
994 | | - var label = msg( tools[tool], 'label' ); |
995 | | - switch ( tools[tool].type ) { |
996 | | - case 'button': |
997 | | - $group.append( |
998 | | - $( '<input />' ) |
999 | | - .attr( { |
1000 | | - 'src': $.wikiEditor.modules.toolbar.imgPath + |
1001 | | - tools[tool].icon, |
1002 | | - 'alt': label, |
1003 | | - 'title': label, |
1004 | | - 'type': 'image', |
1005 | | - 'rel': tool |
1006 | | - } ) |
1007 | | - .addClass( 'tool' ) |
1008 | | - .addClass( 'tool-' + tool ) |
1009 | | - .data( 'tool', tools[tool] ) |
1010 | | - .click( useTool ) |
1011 | | - ); |
1012 | | - break; |
1013 | | - case 'select': |
1014 | | - var $select = $( '<select></select>' ) |
1015 | | - .attr( 'rel', tool ) |
1016 | | - .data( 'tool', tools[tool] ) |
1017 | | - .change( useTool ) |
1018 | | - .append( $( '<option></option>' ).text( label ) ) |
1019 | | - .appendTo( $group ); |
1020 | | - for ( option in tools[tool].list ) { |
1021 | | - $select.append( |
1022 | | - $( '<option></option>' ) |
1023 | | - .text( |
1024 | | - msg( tools[tool].list[option], 'label' ) |
1025 | | - ) |
1026 | | - .attr( 'value', option ) |
| 1034 | + return $button; |
| 1035 | + case 'select': |
| 1036 | + var $select = $( '<select></select>' ).attr( { |
| 1037 | + 'rel': id, |
| 1038 | + 'class': 'tool tool-' + id |
| 1039 | + } ); |
| 1040 | + $select.append( $( '<option></option>' ).text( label ) ) |
| 1041 | + if ( 'list' in tool ) { |
| 1042 | + $select |
| 1043 | + .data( 'list', tool.list ) |
| 1044 | + .data( 'context', context ) |
| 1045 | + .click( function() { |
| 1046 | + var list = $(this).data( 'list' ); |
| 1047 | + var val = $(this).val(); |
| 1048 | + if ( val in list && 'action' in list[val] ) { |
| 1049 | + $.wikiEditor.modules.toolbar.fn.doAction( |
| 1050 | + $(this).data( 'context' ), list[val].action |
| 1051 | + ); |
| 1052 | + } |
| 1053 | + $(this) |
| 1054 | + .find(":selected").attr( 'selected', false ) |
| 1055 | + .find(":first").attr( 'selected', true ); |
| 1056 | + return false; |
| 1057 | + } ); |
| 1058 | + for ( option in tool.list ) { |
| 1059 | + var optionLabel = |
| 1060 | + $.wikiEditor.modules.toolbar.fn.autoMsg( |
| 1061 | + tool.list[option], 'label' |
1027 | 1062 | ); |
1028 | | - } |
1029 | | - break; |
| 1063 | + $select.append( |
| 1064 | + $( '<option></option>' ) |
| 1065 | + .text( optionLabel ) |
| 1066 | + .attr( 'value', option ) |
| 1067 | + ); |
| 1068 | + } |
1030 | 1069 | } |
1031 | | - } |
| 1070 | + return $select; |
| 1071 | + default: return null; |
1032 | 1072 | } |
1033 | | - /** |
1034 | | - * Adds pages to a booklet |
1035 | | - * |
1036 | | - * @param {Object} $index jQuery selection to add index entry to |
1037 | | - * @param {Object} $pages jQuery selection to add pages to |
1038 | | - * @param {Object} pages Configurations for pages |
1039 | | - * @param {String} sectionId Unique ID of section |
1040 | | - */ |
1041 | | - function addPages( $index, $pages, pages, sectionId ) { |
1042 | | - var selected = $.cookie( sectionId ); |
1043 | | - // The pages may have changed since the user was last here, so we |
1044 | | - // must check that the page they want to default to still exists |
1045 | | - if ( !( selected in pages ) ) { |
| 1073 | + }, |
| 1074 | + buildBooklet: function( context, id, booklet ) { |
| 1075 | + var selected = $.cookie( |
| 1076 | + 'wikiEditor-' + context.instance + '-booklet-' + id + '-page' |
| 1077 | + ); |
| 1078 | + var $booklet = $( '<div></div>' ).attr( { |
| 1079 | + 'class': 'booklet section section-' + id, |
| 1080 | + 'rel': id |
| 1081 | + } ); |
| 1082 | + var $pages = $( '<div></div>' ).attr( 'class', 'pages' ); |
| 1083 | + var $index = $( '<div></div>' ).attr( 'class', 'index' ); |
| 1084 | + if ( 'pages' in booklet ) { |
| 1085 | + if ( !( selected in booklet.pages ) ) { |
1046 | 1086 | selected = null; |
1047 | 1087 | } |
1048 | | - for ( page in pages ) { |
1049 | | - // If there's no layout property, we can just skip over this one |
1050 | | - if ( !( 'layout' in pages[page] ) ) { |
1051 | | - continue; |
1052 | | - } |
1053 | | - // When no page state is present, deafult to the first page |
1054 | | - if ( selected == null ) { |
| 1088 | + for ( page in booklet.pages ) { |
| 1089 | + if ( selected === null ) { |
1055 | 1090 | selected = page; |
1056 | 1091 | } |
1057 | | - // Add an entry to the index of pages so the user can navigate |
1058 | | - // from one to another |
1059 | | - $index.append( |
1060 | | - $( '<div></div>' ) |
1061 | | - .attr( 'class', page === selected ? 'current' : null ) |
1062 | | - .attr( 'rel', page ) |
1063 | | - .text( msg( pages[page], 'label' ) ) |
1064 | | - .data( 'page', page ) |
1065 | | - .data( 'sectionId', sectionId ) |
1066 | | - .click( function() { |
1067 | | - $(this) |
1068 | | - .parent() |
1069 | | - .parent() |
1070 | | - .find( '.page' ) |
1071 | | - .hide() |
1072 | | - .end() |
1073 | | - .parent() |
1074 | | - .find( 'div' ) |
1075 | | - .removeClass( 'current' ) |
1076 | | - .end() |
1077 | | - .parent() |
1078 | | - .parent() |
1079 | | - .find( '.page-' + $(this).data( 'page' ) ) |
1080 | | - .show(); |
1081 | | - $(this).addClass( 'current' ); |
1082 | | - // Store the state each time the user changes pages |
1083 | | - $.cookie( |
1084 | | - $(this).data( 'sectionId'), |
1085 | | - $(this).data( 'page' ) |
1086 | | - ); |
1087 | | - } ) |
| 1092 | + var $page = $.wikiEditor.modules.toolbar.fn.buildPage( |
| 1093 | + context, page, booklet.pages[page] |
1088 | 1094 | ); |
1089 | | - // Add the content of the page and only show the selected one |
1090 | | - var $page = $( '<div></div>' ) |
1091 | | - .attr( 'rel', page ) |
1092 | | - .addClass( 'page' ) |
1093 | | - .addClass( 'page-' + page ) |
1094 | | - .css( 'display', page == selected ? 'block' : 'none' ) |
1095 | | - .appendTo( $pages ); |
1096 | | - // Depending on the layout, we can render different page types |
1097 | | - switch ( pages[page].layout ) { |
1098 | | - case 'table': |
1099 | | - var $table = $( '<table></table>' ) |
1100 | | - .attr( { |
1101 | | - 'cellpadding': '0', |
1102 | | - 'cellspacing': '0', |
1103 | | - 'border': '0', |
1104 | | - 'width': '100%' |
1105 | | - } ) |
1106 | | - .appendTo( $page ); |
1107 | | - if ( |
1108 | | - 'headings' in pages[page] && |
1109 | | - typeof pages[page].headings == 'object' |
1110 | | - ) { |
1111 | | - var $headings = $( '<tr></tr>' ).appendTo( $table ); |
1112 | | - for ( heading in pages[page].headings ) { |
1113 | | - var content = msg( |
1114 | | - pages[page].headings[heading], 'content' |
1115 | | - ); |
1116 | | - $( '<th></th>' ) |
1117 | | - .text( content ) |
1118 | | - .appendTo( $headings ); |
1119 | | - } |
1120 | | - } |
1121 | | - if ( |
1122 | | - 'rows' in pages[page] && |
1123 | | - typeof pages[page].rows == 'object' |
1124 | | - ) { |
1125 | | - for ( row in pages[page].rows ) { |
1126 | | - var $row = $( '<tr></tr>' ).appendTo( $table ); |
1127 | | - for ( cell in pages[page].rows[row] ) { |
1128 | | - var content = msg( |
1129 | | - pages[page].rows[row][cell], 'content' |
1130 | | - ); |
1131 | | - $( '<td></td>' ) |
1132 | | - .addClass( cell ) |
1133 | | - .attr( 'valign', 'top' ) |
1134 | | - .append( |
1135 | | - $( '<span></span>' ).html( content ) |
1136 | | - ) |
1137 | | - .appendTo( $row ); |
1138 | | - } |
1139 | | - } |
1140 | | - } |
1141 | | - break; |
1142 | | - case 'characters': |
1143 | | - var $characters = $( '<div></div>' ) |
1144 | | - .attr( pages[page].attributes ) |
1145 | | - .css( pages[page].styles ) |
1146 | | - .appendTo( $page ); |
1147 | | - if ( |
1148 | | - 'characters' in pages[page] && |
1149 | | - typeof pages[page].characters == 'object' |
1150 | | - ) { |
1151 | | - for ( character in pages[page].characters ) { |
1152 | | - var char = pages[page].characters[character]; |
1153 | | - var tool = {}; |
1154 | | - /* |
1155 | | - * The contents of char may be a string, or an |
1156 | | - * object. If it's a string the string is both |
1157 | | - * the label and the inserted value treated as |
1158 | | - * a pre parameter to the encapsulateSelection |
1159 | | - * action. If it's an object, the object must |
1160 | | - * contain a label or it will be skipped - and |
1161 | | - * the entire object is passed through as the |
1162 | | - * tool configuration so it must contain valid |
1163 | | - * tool configuration content as well. |
1164 | | - */ |
1165 | | - if ( typeof char == 'string' ) { |
1166 | | - tool = { |
1167 | | - 'type': 'link', |
1168 | | - 'label': char, |
1169 | | - 'action': { |
1170 | | - 'type': 'encapsulate', |
1171 | | - 'options': { |
1172 | | - 'pre': char |
1173 | | - } |
1174 | | - } |
1175 | | - }; |
1176 | | - } else if ( typeof char == 'object' ) { |
1177 | | - tool = char; |
1178 | | - } else { |
1179 | | - continue; |
1180 | | - } |
1181 | | - if ( !( 'label' in tool ) ) { |
1182 | | - continue; |
1183 | | - } |
1184 | | - $characters.append( |
1185 | | - $( '<a></a>' ) |
1186 | | - .attr( 'href', '#' ) |
1187 | | - .text( tool.label ) |
1188 | | - .data( 'tool', tool ) |
1189 | | - .click( useTool ) |
1190 | | - ); |
1191 | | - } |
1192 | | - } |
1193 | | - break; |
| 1095 | + var $bookmark = $.wikiEditor.modules.toolbar.fn.buildBookmark( |
| 1096 | + context, page, booklet.pages[page] |
| 1097 | + ); |
| 1098 | + if ( selected == page ) { |
| 1099 | + $page.show(); |
| 1100 | + $bookmark.addClass( 'current' ); |
| 1101 | + } else { |
| 1102 | + $page.hide(); |
1194 | 1103 | } |
| 1104 | + $pages.append( $page ); |
| 1105 | + $index.append( $bookmark ); |
1195 | 1106 | } |
1196 | 1107 | } |
1197 | | - // Wraps gM from js2, but allows raw text to supercede |
1198 | | - function msg( object, property ) { |
1199 | | - return object[property] || gM( object[property + 'Msg'] ); |
1200 | | - } |
1201 | | - // Checks if a message of any kind is in an object |
1202 | | - function objHasMsg( object, property ) { |
1203 | | - return property in object || property + 'Msg' in object; |
1204 | | - } |
1205 | | - switch ( section.type ) { |
1206 | | - case 'toolbar': |
1207 | | - // Tools must be in groups, so if there're no groups this part |
1208 | | - // of the configuration is not valid and we need to skip over it |
1209 | | - if ( !( 'groups' in section ) ) { |
1210 | | - return; |
| 1108 | + return $booklet.append( $index ).append( $pages ); |
| 1109 | + }, |
| 1110 | + buildBookmark: function( context, id, page ) { |
| 1111 | + var label = $.wikiEditor.modules.toolbar.fn.autoMsg( page, 'label' ); |
| 1112 | + return $( '<div></div>' ) |
| 1113 | + .text( label ) |
| 1114 | + .attr( 'rel', id ) |
| 1115 | + .data( 'context', context ) |
| 1116 | + .click( function() { |
| 1117 | + $(this) |
| 1118 | + .parent() |
| 1119 | + .parent() |
| 1120 | + .find( '.page' ) |
| 1121 | + .hide(); |
| 1122 | + $(this) |
| 1123 | + .parent() |
| 1124 | + .parent() |
| 1125 | + .find( '.page-' + $(this).attr( 'rel' ) ) |
| 1126 | + .show(); |
| 1127 | + $(this).siblings().removeClass( 'current' ); |
| 1128 | + $(this).addClass( 'current' ); |
| 1129 | + var section = $(this).parent().parent().attr( 'rel' ); |
| 1130 | + $.cookie( |
| 1131 | + 'wikiEditor-' + $(this).data( 'context' ).instance + |
| 1132 | + '-booklet-' + section + '-page', |
| 1133 | + $(this).attr( 'rel' ) |
| 1134 | + ); |
| 1135 | + } ); |
| 1136 | + }, |
| 1137 | + buildPage: function( context, id, page ) { |
| 1138 | + var $page = $( '<div></div>' ).attr( { |
| 1139 | + 'class': 'page page-' + id, |
| 1140 | + 'rel': id |
| 1141 | + } ); |
| 1142 | + switch( page.layout ) { |
| 1143 | + case 'table': |
| 1144 | + $page.addClass( 'page-table' ); |
| 1145 | + var $table = $( '<table></table>' ).attr( { |
| 1146 | + 'cellpadding': '0', |
| 1147 | + 'cellspacing': '0', |
| 1148 | + 'border': '0', |
| 1149 | + 'width': '100%', |
| 1150 | + 'class': 'table table-' + id |
| 1151 | + } ); |
| 1152 | + if ( 'headings' in page ) { |
| 1153 | + var $headings = $( '<tr></tr>' ); |
| 1154 | + for ( heading in page.headings ) { |
| 1155 | + var content = |
| 1156 | + $.wikiEditor.modules.toolbar.fn.autoMsg( |
| 1157 | + page.headings[heading], 'content' |
| 1158 | + ); |
| 1159 | + $headings.append( |
| 1160 | + $( '<th></th>' ).text( content ) |
| 1161 | + ); |
| 1162 | + } |
| 1163 | + $table.append( $headings ); |
1211 | 1164 | } |
1212 | | - for ( group in section.groups ) { |
1213 | | - var $group = $( '<div></div>' ) |
1214 | | - .attr( 'class', 'group' ) |
1215 | | - .attr( 'rel', group ) |
1216 | | - .appendTo( $section ); |
1217 | | - if ( objHasMsg( section.groups[group], 'label' ) ) { |
1218 | | - $group.append( |
1219 | | - $( '<div></div>' ) |
1220 | | - .attr( 'class', 'label' ) |
1221 | | - .text( msg( section.groups[group], 'label' ) ) |
1222 | | - ) |
| 1165 | + if ( 'rows' in page ) { |
| 1166 | + for ( row in page.rows ) { |
| 1167 | + var $row = $( '<tr></tr>' ); |
| 1168 | + for ( cell in page.rows[row] ) { |
| 1169 | + var $cell = $( '<td></td>' ).attr( { |
| 1170 | + 'class': 'cell cell-' + cell, |
| 1171 | + 'valign': 'top' |
| 1172 | + } ); |
| 1173 | + var content = |
| 1174 | + $.wikiEditor.modules.toolbar.fn.autoMsg( |
| 1175 | + page.rows[row][cell], 'content' |
| 1176 | + ); |
| 1177 | + $cell.append( |
| 1178 | + $( '<span></span>' ).html( content ) |
| 1179 | + ); |
| 1180 | + $row.append( $cell ); |
| 1181 | + } |
| 1182 | + $table.append( $row ); |
1223 | 1183 | } |
1224 | | - addTools( $group, section.groups[group].tools, sectionId ); |
1225 | 1184 | } |
1226 | | - break; |
1227 | | - case 'booklet': |
1228 | | - if ( !( 'pages' in section ) ) { |
1229 | | - return; |
| 1185 | + $page.append( $table ); |
| 1186 | + break; |
| 1187 | + case 'characters': |
| 1188 | + $page.addClass( 'page-characters' ); |
| 1189 | + $characters = $( '<div></div>' ); |
| 1190 | + if ( 'language' in page ) { |
| 1191 | + $characters.attr( 'lang', page.language ); |
1230 | 1192 | } |
1231 | | - var $index = $( '<div></div>' ) |
1232 | | - .attr( 'class', 'index' ) |
1233 | | - .appendTo( $section ); |
1234 | | - var $pages = $( '<div></div>' ) |
1235 | | - .attr( 'class', 'pages' ) |
1236 | | - .appendTo( $section ); |
1237 | | - addPages( $index, $pages, section.pages, sectionId ); |
| 1193 | + if ( 'direction' in page ) { |
| 1194 | + $characters.attr( 'dir', page.direction ); |
| 1195 | + } |
| 1196 | + if ( 'characters' in page ) { |
| 1197 | + for ( character in page.characters ) { |
| 1198 | + var tool = page.characters[character]; |
| 1199 | + if ( typeof tool == 'string' ) { |
| 1200 | + tool = { |
| 1201 | + 'label': tool, |
| 1202 | + 'action': { |
| 1203 | + 'type': 'encapsulate', |
| 1204 | + 'options': { 'pre': tool } |
| 1205 | + } |
| 1206 | + }; |
| 1207 | + } |
| 1208 | + if ( 'action' in tool && 'label' in tool ) { |
| 1209 | + var $character = $( '<a></a>' ) |
| 1210 | + .attr( 'href', '#' ) |
| 1211 | + .text( tool.label ) |
| 1212 | + .data( 'context', context ) |
| 1213 | + .data( 'action', tool.action ) |
| 1214 | + .click( function() { |
| 1215 | + $.wikiEditor.modules.toolbar.fn.doAction( |
| 1216 | + $(this).data( 'context' ), |
| 1217 | + $(this).data( 'action' ) |
| 1218 | + ); |
| 1219 | + return false; |
| 1220 | + } ); |
| 1221 | + $characters.append( $character ); |
| 1222 | + } |
| 1223 | + } |
| 1224 | + $page.append( $characters ); |
| 1225 | + } |
1238 | 1226 | break; |
1239 | 1227 | } |
| 1228 | + return $page; |
1240 | 1229 | }, |
1241 | | - /** |
1242 | | - * Builds toolbar |
1243 | | - * |
1244 | | - * @param {Object} context |
1245 | | - * @param {Object} config |
1246 | | - */ |
1247 | 1230 | build: function( context, config ) { |
1248 | | - // Create some containers for various elements and append them |
1249 | 1231 | var $tabs = $( '<div></div>' ) |
1250 | 1232 | .addClass( 'tabs' ) |
1251 | 1233 | .appendTo( context.modules.$toolbar ); |
— | — | @@ -1254,83 +1236,46 @@ |
1255 | 1237 | context.modules.$toolbar.append( |
1256 | 1238 | $( '<div></div>' ).addClass( 'break' ) |
1257 | 1239 | ); |
1258 | | - // Create a base name for keys that will be stored in a cookie which |
1259 | | - // maintain the state of which sections are open and closed |
1260 | | - var sectionIdBase = |
1261 | | - 'wikiEditor-' + context.instance + '-ui-toolbar-section'; |
1262 | | - // Add section container, initially in loading class - but that will |
1263 | | - // get removed once the section is done being built |
1264 | | - var sectionCookie = 'wikiEditor-' + context.instance + '-section'; |
1265 | | - // To prevent slow page rendering times, we store the individual |
1266 | | - // section configurations in a queue to be built asynchrnously later on |
| 1240 | + var selected = $.cookie( |
| 1241 | + 'wikiEditor-' + context.instance + '-toolbar-section' |
| 1242 | + ); |
1267 | 1243 | var sectionQueue = []; |
1268 | 1244 | for ( section in config ) { |
1269 | | - // Unique section HTML ID |
1270 | | - var sectionId = |
1271 | | - sectionCookie + '-' + config[section].type + '-' + section; |
1272 | | - // Handle the main specially both for layout purposes and |
1273 | | - // so that it is rendered immediately while the other sections are |
1274 | | - // rendered asynchronously and possibly much later |
1275 | 1245 | if ( section == 'main' ) { |
1276 | | - var $section = $( '<div></div>' ) |
1277 | | - .attr( 'rel', section ) |
1278 | | - .addClass( 'section-' + config[section].type ) |
1279 | | - .addClass( |
1280 | | - 'section-' + config[section].type + '-' + section |
| 1246 | + context.modules.$toolbar.prepend( |
| 1247 | + $.wikiEditor.modules.toolbar.fn.buildSection( |
| 1248 | + context, section, config[section] |
1281 | 1249 | ) |
1282 | | - .attr( 'id', sectionId ) |
1283 | | - .prependTo( context.modules.$toolbar ); |
1284 | | - |
1285 | | - $.wikiEditor.modules.toolbar.fn.addSection( |
1286 | | - context, $section, config[section], 'main' |
1287 | 1250 | ); |
1288 | | - continue; |
1289 | | - } |
1290 | | - // Handle normal sections by giving them tabs and hiding them away |
1291 | | - // by default |
1292 | | - var $section = $( '<div></div>' ) |
1293 | | - .attr( 'rel', section ) |
1294 | | - .addClass( 'section loading' ) |
1295 | | - .addClass( 'section-' + config[section].type ) |
1296 | | - .addClass( |
1297 | | - 'section-' + config[section].type + '-' + section |
1298 | | - ) |
1299 | | - .attr( 'id', sectionId ) |
1300 | | - .append( |
1301 | | - $( '<div></div>' ) |
1302 | | - .addClass( 'spinner' ) |
1303 | | - .text( gM( 'edittoolbar-loading' ) ) |
1304 | | - ) |
1305 | | - .appendTo( $sections ); |
1306 | | - // Recall the state from cookie |
1307 | | - var current = false; |
1308 | | - if ( $.cookie( sectionCookie ) == sectionId ) { |
1309 | | - $section.attr( 'style', 'display:block' ); |
1310 | | - current = true; |
1311 | | - } |
1312 | | - // Add section to queue for later processing |
1313 | | - sectionQueue[sectionQueue.length] = { |
1314 | | - '$section': $section, |
1315 | | - 'tools': config[section], |
1316 | | - 'id': sectionId |
1317 | | - }; |
1318 | | - // Add a tab the user can click to hide and show the section |
1319 | | - $tabs.append( |
1320 | | - $( '<span></span>' ) |
1321 | | - .attr( 'class', 'tab' ) |
1322 | | - .attr( 'rel', section ) |
1323 | | - .append( |
1324 | | - $( '<a></a>' ) |
| 1251 | + } else { |
| 1252 | + $sections.append( |
| 1253 | + $.wikiEditor.modules.toolbar.fn.buildSection( |
| 1254 | + context, section, config[section] |
| 1255 | + ) |
| 1256 | + .css( 'display', selected == section ? 'block' : 'none' ) |
| 1257 | + ); |
| 1258 | + $tabs.append( |
| 1259 | + $( '<span></span>' ) |
| 1260 | + .attr( { |
| 1261 | + 'class': 'tab tab-' + section, |
| 1262 | + 'rel': section |
| 1263 | + } ) |
| 1264 | + .append( |
| 1265 | + $( '<a></a>' ) |
| 1266 | + .addClass( selected == section ? 'current' : null ) |
| 1267 | + .attr( 'href', '#' ) |
1325 | 1268 | .text( |
1326 | | - config[section].label || |
1327 | | - gM( config[section].labelMsg ) |
| 1269 | + $.wikiEditor.modules.toolbar.fn.autoMsg( |
| 1270 | + config[section], 'label' |
| 1271 | + ) |
1328 | 1272 | ) |
1329 | | - .attr( 'href', '#' ) |
1330 | | - .addClass( current ? 'current' : null ) |
1331 | | - .data( '$section', $section ) |
1332 | | - .data( 'sectionCookie', sectionCookie ) |
| 1273 | + .data( 'context', context ) |
1333 | 1274 | .click( function() { |
1334 | | - var $section = $(this).data( '$section' ); |
| 1275 | + var $section = |
| 1276 | + $(this).data( 'context' ).$ui.find( |
| 1277 | + '.section-' + |
| 1278 | + $(this).parent().attr( 'rel' ) |
| 1279 | + ); |
1335 | 1280 | $(this).blur(); |
1336 | 1281 | var show = $section.css( 'display' ) == 'none'; |
1337 | 1282 | $section.parent().children().hide(); |
— | — | @@ -1344,26 +1289,17 @@ |
1345 | 1290 | $(this).addClass( 'current' ); |
1346 | 1291 | } |
1347 | 1292 | $.cookie( |
1348 | | - $(this).data( 'sectionCookie' ), |
1349 | | - show ? $section.attr( 'id' ) : null |
| 1293 | + 'wikiEditor-' + |
| 1294 | + $(this).data( 'context' ).instance + |
| 1295 | + '-toolbar-section', |
| 1296 | + show ? $section.attr( 'rel' ) : null |
1350 | 1297 | ); |
1351 | 1298 | return false; |
1352 | 1299 | } ) |
1353 | | - ) |
1354 | | - ); |
1355 | | - } |
1356 | | - // Process the section queue |
1357 | | - $.eachAsync( sectionQueue, { |
1358 | | - bulk: 0, |
1359 | | - loop: function( index, section ) { |
1360 | | - $.wikiEditor.modules.toolbar.fn.addSection( |
1361 | | - context, section.$section, section.tools, section.id |
| 1300 | + ) |
1362 | 1301 | ); |
1363 | | - // When addSection is done, we can remove the loading |
1364 | | - // class to hide the spinner and reveal the content |
1365 | | - section.$section.removeClass( 'loading' ) |
1366 | 1302 | } |
1367 | | - } ); |
| 1303 | + } |
1368 | 1304 | } |
1369 | 1305 | } |
1370 | 1306 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -62,35 +62,32 @@ |
63 | 63 | var lastLevel=0;var nLevel=0;for(var i=0;i<outline.length;i++){if(outline[i].level>lastLevel){nLevel++;} |
64 | 64 | else if(outline[i].level<lastLevel){nLevel-=Math.max(1,lastLevel-outline[i].level);} |
65 | 65 | outline[i].nLevel=nLevel;lastLevel=nLevel;} |
66 | | -var structure=buildStructure(outline);structure.unshift({'text':wgTitle,'level':1,'index':0,'position':0});context.modules.$toc.html(buildList(structure));context.data.outline=outline;}}};})(jQuery);(function($){$.wikiEditor.modules.toolbar={imgPath:wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/toolbar/',api:{removeFromToolbar:function(context,data){if(typeof data.section=='string'){var selector='div[rel='+data.section+'].section';if(typeof data.group=='string'){selector+=' div[rel='+data.group+'].group';if(typeof data.tool=='string'){selector+=' div[rel='+data.tool+'].tool';}} |
67 | | -context.modules.$toolbar.find(selector).remove();}}},fn:{create:function(context,config){if('$toolbar'in context.modules){return;} |
68 | | -context.modules.$toolbar=$('<div></div>').addClass('wikiEditor-ui-toolbar');$.wikiEditor.modules.toolbar.fn.build(context,config);context.$ui.find('.wikiEditor-ui-top').append(context.modules.$toolbar);},performAction:function(context,action){switch(action.type){case'encapsulate':var parts={'pre':'','peri':'','post':''};for(part in parts){if(part+'Msg'in action.options){parts[part]=gM(action.options[part+'Msg'],(action.options[part]||null));}else{parts[part]=(action.options[part]||'')}} |
69 | | -context.$textarea.encapsulateSelection(parts.pre,parts.peri,parts.post);break;default:break;}},addSection:function(context,$section,section,sectionId){var useTool=function(){var tool=$(this).data('tool');if('type'in tool){switch(tool.type){case'button':case'link':if('action'in tool){$.wikiEditor.modules.toolbar.fn.performAction(context,tool.action);} |
70 | | -break;case'select':if('list'in tool&&$(this).val()in tool.list){$.wikiEditor.modules.toolbar.fn.performAction(context,tool.list[$(this).val()].action);} |
71 | | -$(this).find(":selected").attr('selected',false);$(this).find(":first").attr('selected',true);break;}} |
72 | | -return false;} |
73 | | -function addTools($group,tools,sectionId){for(tool in section.groups[group].tools){if('filters'in tools[tool]){var skip=false;for(filter in tools[tool].filters){if($(tools[tool].filters[filter]).size()==0){skip=true;}} |
74 | | -if(skip){continue;}} |
75 | | -var label=msg(tools[tool],'label');switch(tools[tool].type){case'button':$group.append($('<input />').attr({'src':$.wikiEditor.modules.toolbar.imgPath+ |
76 | | -tools[tool].icon,'alt':label,'title':label,'type':'image','rel':tool}).addClass('tool').addClass('tool-'+tool).data('tool',tools[tool]).click(useTool));break;case'select':var $select=$('<select></select>').attr('rel',tool).data('tool',tools[tool]).change(useTool).append($('<option></option>').text(label)).appendTo($group);for(option in tools[tool].list){$select.append($('<option></option>').text(msg(tools[tool].list[option],'label')).attr('value',option));} |
77 | | -break;}}} |
78 | | -function addPages($index,$pages,pages,sectionId){var selected=$.cookie(sectionId);if(!(selected in pages)){selected=null;} |
79 | | -for(page in pages){if(!('layout'in pages[page])){continue;} |
80 | | -if(selected==null){selected=page;} |
81 | | -$index.append($('<div></div>').attr('class',page===selected?'current':null).attr('rel',page).text(msg(pages[page],'label')).data('page',page).data('sectionId',sectionId).click(function(){$(this).parent().parent().find('.page').hide().end().parent().find('div').removeClass('current').end().parent().parent().find('.page-'+$(this).data('page')).show();$(this).addClass('current');$.cookie($(this).data('sectionId'),$(this).data('page'));}));var $page=$('<div></div>').attr('rel',page).addClass('page').addClass('page-'+page).css('display',page==selected?'block':'none').appendTo($pages);switch(pages[page].layout){case'table':var $table=$('<table></table>').attr({'cellpadding':'0','cellspacing':'0','border':'0','width':'100%'}).appendTo($page);if('headings'in pages[page]&&typeof pages[page].headings=='object'){var $headings=$('<tr></tr>').appendTo($table);for(heading in pages[page].headings){var content=msg(pages[page].headings[heading],'content');$('<th></th>').text(content).appendTo($headings);}} |
82 | | -if('rows'in pages[page]&&typeof pages[page].rows=='object'){for(row in pages[page].rows){var $row=$('<tr></tr>').appendTo($table);for(cell in pages[page].rows[row]){var content=msg(pages[page].rows[row][cell],'content');$('<td></td>').addClass(cell).attr('valign','top').append($('<span></span>').html(content)).appendTo($row);}}} |
83 | | -break;case'characters':var $characters=$('<div></div>').attr(pages[page].attributes).css(pages[page].styles).appendTo($page);if('characters'in pages[page]&&typeof pages[page].characters=='object'){for(character in pages[page].characters){var char=pages[page].characters[character];var tool={};if(typeof char=='string'){tool={'type':'link','label':char,'action':{'type':'encapsulate','options':{'pre':char}}};}else if(typeof char=='object'){tool=char;}else{continue;} |
84 | | -if(!('label'in tool)){continue;} |
85 | | -$characters.append($('<a></a>').attr('href','#').text(tool.label).data('tool',tool).click(useTool));}} |
86 | | -break;}}} |
87 | | -function msg(object,property){return object[property]||gM(object[property+'Msg']);} |
88 | | -function objHasMsg(object,property){return property in object||property+'Msg'in object;} |
89 | | -switch(section.type){case'toolbar':if(!('groups'in section)){return;} |
90 | | -for(group in section.groups){var $group=$('<div></div>').attr('class','group').attr('rel',group).appendTo($section);if(objHasMsg(section.groups[group],'label')){$group.append($('<div></div>').attr('class','label').text(msg(section.groups[group],'label')))} |
91 | | -addTools($group,section.groups[group].tools,sectionId);} |
92 | | -break;case'booklet':if(!('pages'in section)){return;} |
93 | | -var $index=$('<div></div>').attr('class','index').appendTo($section);var $pages=$('<div></div>').attr('class','pages').appendTo($section);addPages($index,$pages,section.pages,sectionId);break;}},build:function(context,config){var $tabs=$('<div></div>').addClass('tabs').appendTo(context.modules.$toolbar);var $sections=$('<div></div>').addClass('sections').appendTo(context.modules.$toolbar);context.modules.$toolbar.append($('<div></div>').addClass('break'));var sectionIdBase='wikiEditor-'+context.instance+'-ui-toolbar-section';var sectionCookie='wikiEditor-'+context.instance+'-section';var sectionQueue=[];for(section in config){var sectionId=sectionCookie+'-'+config[section].type+'-'+section;if(section=='main'){var $section=$('<div></div>').attr('rel',section).addClass('section-'+config[section].type).addClass('section-'+config[section].type+'-'+section).attr('id',sectionId).prependTo(context.modules.$toolbar);$.wikiEditor.modules.toolbar.fn.addSection(context,$section,config[section],'main');continue;} |
94 | | -var $section=$('<div></div>').attr('rel',section).addClass('section loading').addClass('section-'+config[section].type).addClass('section-'+config[section].type+'-'+section).attr('id',sectionId).append($('<div></div>').addClass('spinner').text(gM('edittoolbar-loading'))).appendTo($sections);var current=false;if($.cookie(sectionCookie)==sectionId){$section.attr('style','display:block');current=true;} |
95 | | -sectionQueue[sectionQueue.length]={'$section':$section,'tools':config[section],'id':sectionId};$tabs.append($('<span></span>').attr('class','tab').attr('rel',section).append($('<a></a>').text(config[section].label||gM(config[section].labelMsg)).attr('href','#').addClass(current?'current':null).data('$section',$section).data('sectionCookie',sectionCookie).click(function(){var $section=$(this).data('$section');$(this).blur();var show=$section.css('display')=='none';$section.parent().children().hide();$(this).parent().parent().find('a').removeClass('current');if(show){$section.show();$(this).addClass('current');} |
96 | | -$.cookie($(this).data('sectionCookie'),show?$section.attr('id'):null);return false;})));} |
97 | | -$.eachAsync(sectionQueue,{bulk:0,loop:function(index,section){$.wikiEditor.modules.toolbar.fn.addSection(context,section.$section,section.tools,section.id);section.$section.removeClass('loading')}});}}};})(jQuery); |
\ No newline at end of file |
| 66 | +var structure=buildStructure(outline);structure.unshift({'text':wgTitle,'level':1,'index':0,'position':0});context.modules.$toc.html(buildList(structure));context.data.outline=outline;}}};})(jQuery);(function($){$.wikiEditor.modules.toolbar={imgPath:wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/toolbar/',api:{addToToolbar:function(context,data){},modifyToolbar:function(context,data){},removeFromToolbar:function(context,data){if(typeof data.section=='string'){var selector='div[rel='+data.section+'].section';if(typeof data.group=='string'){selector+=' div[rel='+data.group+'].group';if(typeof data.tool=='string'){selector+=' div[rel='+data.tool+'].tool';}} |
| 67 | +context.modules.$toolbar.find(selector).remove();}}},fn:{autoMsg:function(object,property){if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}},create:function(context,config){if('$toolbar'in context.modules){return;} |
| 68 | +context.modules.$toolbar=$('<div></div>').addClass('wikiEditor-ui-toolbar');$.wikiEditor.modules.toolbar.fn.build(context,config);context.$ui.find('.wikiEditor-ui-top').append(context.modules.$toolbar);},doAction:function(context,action){switch(action.type){case'encapsulate':var parts={'pre':'','peri':'','post':''};for(part in parts){if(part+'Msg'in action.options){parts[part]=gM(action.options[part+'Msg'],(action.options[part]||null));}else{parts[part]=(action.options[part]||'')}} |
| 69 | +context.$textarea.encapsulateSelection(parts.pre,parts.peri,parts.post);break;default:break;}},buildSection:function(context,id,section){switch(section.type){case'toolbar':return $.wikiEditor.modules.toolbar.fn.buildToolbar(context,id,section);case'booklet':return $.wikiEditor.modules.toolbar.fn.buildBooklet(context,id,section);default:return null;}},buildToolbar:function(context,id,toolbar){var $toolbar=$('<div></div>').attr({'class':'toolbar section section-'+id,'rel':id});if('groups'in toolbar){for(group in toolbar.groups){$toolbar.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,toolbar.groups[group]));}} |
| 70 | +return $toolbar;},buildGroup:function(context,id,group){var $group=$('<div></div>').attr({'class':'group group-'+id,'rel':id});var label=$.wikiEditor.modules.toolbar.fn.autoMsg(group,'label');if(label){$group.append($('<div></div>').text(label).addClass('label'))} |
| 71 | +if('tools'in group){for(tool in group.tools){$group.append($.wikiEditor.modules.toolbar.fn.buildTool(context,tool,group.tools[tool]));}} |
| 72 | +return $group;},buildTool:function(context,id,tool){if('filters'in tool){for(filter in tool.filters){if($(tool.filters[filter]).size()==0){return null;}}} |
| 73 | +var label=$.wikiEditor.modules.toolbar.fn.autoMsg(tool,'label');switch(tool.type){case'button':$button=$('<input />').attr({'type':'image','src':$.wikiEditor.modules.toolbar.imgPath+tool.icon,'alt':label,'title':label,'rel':id,'class':'tool tool-'+id});if('action'in tool){$button.data('action',tool.action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'));return false;});} |
| 74 | +return $button;case'select':var $select=$('<select></select>').attr({'rel':id,'class':'tool tool-'+id});$select.append($('<option></option>').text(label)) |
| 75 | +if('list'in tool){$select.data('list',tool.list).data('context',context).click(function(){var list=$(this).data('list');var val=$(this).val();if(val in list&&'action'in list[val]){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),list[val].action);} |
| 76 | +$(this).find(":selected").attr('selected',false).find(":first").attr('selected',true);return false;});for(option in tool.list){var optionLabel=$.wikiEditor.modules.toolbar.fn.autoMsg(tool.list[option],'label');$select.append($('<option></option>').text(optionLabel).attr('value',option));}} |
| 77 | +return $select;default:return null;}},buildBooklet:function(context,id,booklet){var selected=$.cookie('wikiEditor-'+context.instance+'-booklet-'+id+'-page');var $booklet=$('<div></div>').attr({'class':'booklet section section-'+id,'rel':id});var $pages=$('<div></div>').attr('class','pages');var $index=$('<div></div>').attr('class','index');if('pages'in booklet){if(!(selected in booklet.pages)){selected=null;} |
| 78 | +for(page in booklet.pages){if(selected===null){selected=page;} |
| 79 | +var $page=$.wikiEditor.modules.toolbar.fn.buildPage(context,page,booklet.pages[page]);var $bookmark=$.wikiEditor.modules.toolbar.fn.buildBookmark(context,page,booklet.pages[page]);if(selected==page){$page.show();$bookmark.addClass('current');}else{$page.hide();} |
| 80 | +$pages.append($page);$index.append($bookmark);}} |
| 81 | +return $booklet.append($index).append($pages);},buildBookmark:function(context,id,page){var label=$.wikiEditor.modules.toolbar.fn.autoMsg(page,'label');return $('<div></div>').text(label).attr('rel',id).data('context',context).click(function(){$(this).parent().parent().find('.page').hide();$(this).parent().parent().find('.page-'+$(this).attr('rel')).show();$(this).siblings().removeClass('current');$(this).addClass('current');var section=$(this).parent().parent().attr('rel');$.cookie('wikiEditor-'+$(this).data('context').instance+'-booklet-'+section+'-page',$(this).attr('rel'));});},buildPage:function(context,id,page){var $page=$('<div></div>').attr({'class':'page page-'+id,'rel':id});switch(page.layout){case'table':$page.addClass('page-table');var $table=$('<table></table>').attr({'cellpadding':'0','cellspacing':'0','border':'0','width':'100%','class':'table table-'+id});if('headings'in page){var $headings=$('<tr></tr>');for(heading in page.headings){var content=$.wikiEditor.modules.toolbar.fn.autoMsg(page.headings[heading],'content');$headings.append($('<th></th>').text(content));} |
| 82 | +$table.append($headings);} |
| 83 | +if('rows'in page){for(row in page.rows){var $row=$('<tr></tr>');for(cell in page.rows[row]){var $cell=$('<td></td>').attr({'class':'cell cell-'+cell,'valign':'top'});var content=$.wikiEditor.modules.toolbar.fn.autoMsg(page.rows[row][cell],'content');$cell.append($('<span></span>').html(content));$row.append($cell);} |
| 84 | +$table.append($row);}} |
| 85 | +$page.append($table);break;case'characters':$page.addClass('page-characters');$characters=$('<div></div>');if('language'in page){$characters.attr('lang',page.language);} |
| 86 | +if('direction'in page){$characters.attr('dir',page.direction);} |
| 87 | +if('characters'in page){for(character in page.characters){var tool=page.characters[character];if(typeof tool=='string'){tool={'label':tool,'action':{'type':'encapsulate','options':{'pre':tool}}};} |
| 88 | +if('action'in tool&&'label'in tool){var $character=$('<a></a>').attr('href','#').text(tool.label).data('context',context).data('action',tool.action).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'));return false;});$characters.append($character);}} |
| 89 | +$page.append($characters);} |
| 90 | +break;} |
| 91 | +return $page;},build:function(context,config){var $tabs=$('<div></div>').addClass('tabs').appendTo(context.modules.$toolbar);var $sections=$('<div></div>').addClass('sections').appendTo(context.modules.$toolbar);context.modules.$toolbar.append($('<div></div>').addClass('break'));var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');var sectionQueue=[];for(section in config){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,config[section]));}else{$sections.append($.wikiEditor.modules.toolbar.fn.buildSection(context,section,config[section]).css('display',selected==section?'block':'none'));$tabs.append($('<span></span>').attr({'class':'tab tab-'+section,'rel':section}).append($('<a></a>').addClass(selected==section?'current':null).attr('href','#').text($.wikiEditor.modules.toolbar.fn.autoMsg(config[section],'label')).data('context',context).click(function(){var $section=$(this).data('context').$ui.find('.section-'+ |
| 92 | +$(this).parent().attr('rel'));$(this).blur();var show=$section.css('display')=='none';$section.parent().children().hide();$(this).parent().parent().find('a').removeClass('current');if(show){$section.show();$(this).addClass('current');} |
| 93 | +$.cookie('wikiEditor-'+ |
| 94 | +$(this).data('context').instance+'-toolbar-section',show?$section.attr('rel'):null);return false;})));}}}}};})(jQuery); |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | /** |
3 | 3 | * Toolbar module for wikiEditor |
4 | 4 | */ |
| 5 | + |
5 | 6 | (function($) { $.wikiEditor.modules.toolbar = { |
6 | 7 | /** |
7 | 8 | * Path to images - this is a bit messy, and it would need to change if this |
— | — | @@ -12,6 +13,12 @@ |
13 | 14 | * API accessible functions |
14 | 15 | */ |
15 | 16 | api: { |
| 17 | + addToToolbar: function( context, data ) { |
| 18 | + // |
| 19 | + }, |
| 20 | + modifyToolbar: function( context, data ) { |
| 21 | + // |
| 22 | + }, |
16 | 23 | removeFromToolbar: function( context, data ) { |
17 | 24 | if ( typeof data.section == 'string' ) { |
18 | 25 | var selector = 'div[rel=' + data.section + '].section'; |
— | — | @@ -29,6 +36,16 @@ |
30 | 37 | * Internally used functions |
31 | 38 | */ |
32 | 39 | fn: { |
| 40 | + // Wraps gM from js2, but allows raw text to supercede |
| 41 | + autoMsg: function( object, property ) { |
| 42 | + if ( property in object ) { |
| 43 | + return object[property]; |
| 44 | + } else if ( property + 'Msg' in object ) { |
| 45 | + return gM( object[property + 'Msg'] ); |
| 46 | + } else { |
| 47 | + return ''; |
| 48 | + } |
| 49 | + }, |
33 | 50 | /** |
34 | 51 | * Creates a toolbar module within a wikiEditor |
35 | 52 | * |
— | — | @@ -51,7 +68,7 @@ |
52 | 69 | * @param {Object} context |
53 | 70 | * @param {Object} action |
54 | 71 | */ |
55 | | - performAction: function( context, action ) { |
| 72 | + doAction: function( context, action ) { |
56 | 73 | switch ( action.type) { |
57 | 74 | case 'encapsulate': |
58 | 75 | var parts = { 'pre': '', 'peri': '', 'post': '' }; |
— | — | @@ -72,320 +89,285 @@ |
73 | 90 | default: break; |
74 | 91 | } |
75 | 92 | }, |
76 | | - /** |
77 | | - * Adds a toolbar section to a containing div |
78 | | - * |
79 | | - * @param {Object} context |
80 | | - * @param {Object} $section Container to add section content to |
81 | | - * @param {Object} section Configuration to build toolbar from |
82 | | - * @param {String} sectionId Unique identifier of this section |
83 | | - */ |
84 | | - addSection: function( context, $section, section, sectionId ) { |
85 | | - /** |
86 | | - * Wraps performAction with tool specific UI interaction |
87 | | - */ |
88 | | - var useTool = function() { |
89 | | - var tool = $(this).data( 'tool' ); |
90 | | - if ( 'type' in tool ) { |
91 | | - switch ( tool.type ) { |
92 | | - case 'button': |
93 | | - case 'link': |
94 | | - if ( 'action' in tool ) { |
95 | | - $.wikiEditor.modules.toolbar.fn.performAction( |
96 | | - context, tool.action |
97 | | - ); |
98 | | - } |
99 | | - break; |
100 | | - case 'select': |
101 | | - if ( 'list' in tool && $(this).val() in tool.list ) { |
102 | | - $.wikiEditor.modules.toolbar.fn.performAction( |
103 | | - context, tool.list[$(this).val()].action |
104 | | - ); |
105 | | - } |
106 | | - $(this).find(":selected").attr( 'selected', false ); |
107 | | - $(this).find(":first").attr( 'selected', true ); |
108 | | - break; |
| 93 | + buildSection: function( context, id, section ) { |
| 94 | + switch ( section.type ) { |
| 95 | + case 'toolbar': |
| 96 | + return $.wikiEditor.modules.toolbar.fn.buildToolbar( |
| 97 | + context, id, section |
| 98 | + ); |
| 99 | + case 'booklet': |
| 100 | + return $.wikiEditor.modules.toolbar.fn.buildBooklet( |
| 101 | + context, id, section |
| 102 | + ); |
| 103 | + default: return null; |
| 104 | + } |
| 105 | + }, |
| 106 | + buildToolbar: function( context, id, toolbar ) { |
| 107 | + var $toolbar = $( '<div></div>' ).attr( { |
| 108 | + 'class': 'toolbar section section-' + id, |
| 109 | + 'rel': id |
| 110 | + } ); |
| 111 | + if ( 'groups' in toolbar ) { |
| 112 | + for ( group in toolbar.groups ) { |
| 113 | + $toolbar.append( |
| 114 | + $.wikiEditor.modules.toolbar.fn.buildGroup( |
| 115 | + context, group, toolbar.groups[group] |
| 116 | + ) |
| 117 | + ); |
| 118 | + } |
| 119 | + } |
| 120 | + return $toolbar; |
| 121 | + }, |
| 122 | + buildGroup: function( context, id, group ) { |
| 123 | + var $group = $( '<div></div>' ).attr( { |
| 124 | + 'class': 'group group-' + id, |
| 125 | + 'rel': id |
| 126 | + } ); |
| 127 | + var label = $.wikiEditor.modules.toolbar.fn.autoMsg( group, 'label' ); |
| 128 | + if ( label ) { |
| 129 | + $group.append( |
| 130 | + $( '<div></div>' ).text( label ).addClass( 'label' ) |
| 131 | + ) |
| 132 | + } |
| 133 | + if ( 'tools' in group ) { |
| 134 | + for ( tool in group.tools ) { |
| 135 | + $group.append( |
| 136 | + $.wikiEditor.modules.toolbar.fn.buildTool( |
| 137 | + context, tool, group.tools[tool] |
| 138 | + ) |
| 139 | + ); |
| 140 | + } |
| 141 | + } |
| 142 | + return $group; |
| 143 | + }, |
| 144 | + buildTool: function( context, id, tool ) { |
| 145 | + if ( 'filters' in tool ) { |
| 146 | + for ( filter in tool.filters ) { |
| 147 | + if ( $( tool.filters[filter] ).size() == 0 ) { |
| 148 | + return null; |
109 | 149 | } |
110 | 150 | } |
111 | | - return false; |
112 | 151 | } |
113 | | - /** |
114 | | - * Adds tools to a group |
115 | | - * |
116 | | - * @param {Object} $group jQuery selection to add tools to |
117 | | - * @param {Object} tools Configurations for tools |
118 | | - * @param {String} sectionId Unique ID of section |
119 | | - */ |
120 | | - function addTools( $group, tools, sectionId ) { |
121 | | - for ( tool in section.groups[group].tools ) { |
122 | | - // Filters are the input to a jQuery selector. The tool will |
123 | | - // only be shown if the selection contains one or more elements |
124 | | - if ( 'filters' in tools[tool] ) { |
125 | | - var skip = false; |
126 | | - for ( filter in tools[tool].filters ) { |
127 | | - if ( $( tools[tool].filters[filter] ).size() == 0 ) { |
128 | | - skip = true; |
129 | | - } |
130 | | - } |
131 | | - if ( skip ) { |
132 | | - continue; |
133 | | - } |
| 152 | + var label = $.wikiEditor.modules.toolbar.fn.autoMsg( tool, 'label' ); |
| 153 | + switch ( tool.type ) { |
| 154 | + case 'button': |
| 155 | + $button = $( '<input />' ).attr( { |
| 156 | + 'type': 'image', |
| 157 | + 'src': $.wikiEditor.modules.toolbar.imgPath + tool.icon, |
| 158 | + 'alt': label, |
| 159 | + 'title': label, |
| 160 | + 'rel': id, |
| 161 | + 'class': 'tool tool-' + id |
| 162 | + } ); |
| 163 | + if ( 'action' in tool ) { |
| 164 | + $button |
| 165 | + .data( 'action', tool.action ) |
| 166 | + .data( 'context', context ) |
| 167 | + .click( function() { |
| 168 | + $.wikiEditor.modules.toolbar.fn.doAction( |
| 169 | + $(this).data( 'context' ), |
| 170 | + $(this).data( 'action' ) |
| 171 | + ); |
| 172 | + return false; |
| 173 | + } ); |
134 | 174 | } |
135 | | - var label = msg( tools[tool], 'label' ); |
136 | | - switch ( tools[tool].type ) { |
137 | | - case 'button': |
138 | | - $group.append( |
139 | | - $( '<input />' ) |
140 | | - .attr( { |
141 | | - 'src': $.wikiEditor.modules.toolbar.imgPath + |
142 | | - tools[tool].icon, |
143 | | - 'alt': label, |
144 | | - 'title': label, |
145 | | - 'type': 'image', |
146 | | - 'rel': tool |
147 | | - } ) |
148 | | - .addClass( 'tool' ) |
149 | | - .addClass( 'tool-' + tool ) |
150 | | - .data( 'tool', tools[tool] ) |
151 | | - .click( useTool ) |
152 | | - ); |
153 | | - break; |
154 | | - case 'select': |
155 | | - var $select = $( '<select></select>' ) |
156 | | - .attr( 'rel', tool ) |
157 | | - .data( 'tool', tools[tool] ) |
158 | | - .change( useTool ) |
159 | | - .append( $( '<option></option>' ).text( label ) ) |
160 | | - .appendTo( $group ); |
161 | | - for ( option in tools[tool].list ) { |
162 | | - $select.append( |
163 | | - $( '<option></option>' ) |
164 | | - .text( |
165 | | - msg( tools[tool].list[option], 'label' ) |
166 | | - ) |
167 | | - .attr( 'value', option ) |
| 175 | + return $button; |
| 176 | + case 'select': |
| 177 | + var $select = $( '<select></select>' ).attr( { |
| 178 | + 'rel': id, |
| 179 | + 'class': 'tool tool-' + id |
| 180 | + } ); |
| 181 | + $select.append( $( '<option></option>' ).text( label ) ) |
| 182 | + if ( 'list' in tool ) { |
| 183 | + $select |
| 184 | + .data( 'list', tool.list ) |
| 185 | + .data( 'context', context ) |
| 186 | + .click( function() { |
| 187 | + var list = $(this).data( 'list' ); |
| 188 | + var val = $(this).val(); |
| 189 | + if ( val in list && 'action' in list[val] ) { |
| 190 | + $.wikiEditor.modules.toolbar.fn.doAction( |
| 191 | + $(this).data( 'context' ), list[val].action |
| 192 | + ); |
| 193 | + } |
| 194 | + $(this) |
| 195 | + .find(":selected").attr( 'selected', false ) |
| 196 | + .find(":first").attr( 'selected', true ); |
| 197 | + return false; |
| 198 | + } ); |
| 199 | + for ( option in tool.list ) { |
| 200 | + var optionLabel = |
| 201 | + $.wikiEditor.modules.toolbar.fn.autoMsg( |
| 202 | + tool.list[option], 'label' |
168 | 203 | ); |
169 | | - } |
170 | | - break; |
| 204 | + $select.append( |
| 205 | + $( '<option></option>' ) |
| 206 | + .text( optionLabel ) |
| 207 | + .attr( 'value', option ) |
| 208 | + ); |
| 209 | + } |
171 | 210 | } |
172 | | - } |
| 211 | + return $select; |
| 212 | + default: return null; |
173 | 213 | } |
174 | | - /** |
175 | | - * Adds pages to a booklet |
176 | | - * |
177 | | - * @param {Object} $index jQuery selection to add index entry to |
178 | | - * @param {Object} $pages jQuery selection to add pages to |
179 | | - * @param {Object} pages Configurations for pages |
180 | | - * @param {String} sectionId Unique ID of section |
181 | | - */ |
182 | | - function addPages( $index, $pages, pages, sectionId ) { |
183 | | - var selected = $.cookie( sectionId ); |
184 | | - // The pages may have changed since the user was last here, so we |
185 | | - // must check that the page they want to default to still exists |
186 | | - if ( !( selected in pages ) ) { |
| 214 | + }, |
| 215 | + buildBooklet: function( context, id, booklet ) { |
| 216 | + var selected = $.cookie( |
| 217 | + 'wikiEditor-' + context.instance + '-booklet-' + id + '-page' |
| 218 | + ); |
| 219 | + var $booklet = $( '<div></div>' ).attr( { |
| 220 | + 'class': 'booklet section section-' + id, |
| 221 | + 'rel': id |
| 222 | + } ); |
| 223 | + var $pages = $( '<div></div>' ).attr( 'class', 'pages' ); |
| 224 | + var $index = $( '<div></div>' ).attr( 'class', 'index' ); |
| 225 | + if ( 'pages' in booklet ) { |
| 226 | + if ( !( selected in booklet.pages ) ) { |
187 | 227 | selected = null; |
188 | 228 | } |
189 | | - for ( page in pages ) { |
190 | | - // If there's no layout property, we can just skip over this one |
191 | | - if ( !( 'layout' in pages[page] ) ) { |
192 | | - continue; |
193 | | - } |
194 | | - // When no page state is present, deafult to the first page |
195 | | - if ( selected == null ) { |
| 229 | + for ( page in booklet.pages ) { |
| 230 | + if ( selected === null ) { |
196 | 231 | selected = page; |
197 | 232 | } |
198 | | - // Add an entry to the index of pages so the user can navigate |
199 | | - // from one to another |
200 | | - $index.append( |
201 | | - $( '<div></div>' ) |
202 | | - .attr( 'class', page === selected ? 'current' : null ) |
203 | | - .attr( 'rel', page ) |
204 | | - .text( msg( pages[page], 'label' ) ) |
205 | | - .data( 'page', page ) |
206 | | - .data( 'sectionId', sectionId ) |
207 | | - .click( function() { |
208 | | - $(this) |
209 | | - .parent() |
210 | | - .parent() |
211 | | - .find( '.page' ) |
212 | | - .hide() |
213 | | - .end() |
214 | | - .parent() |
215 | | - .find( 'div' ) |
216 | | - .removeClass( 'current' ) |
217 | | - .end() |
218 | | - .parent() |
219 | | - .parent() |
220 | | - .find( '.page-' + $(this).data( 'page' ) ) |
221 | | - .show(); |
222 | | - $(this).addClass( 'current' ); |
223 | | - // Store the state each time the user changes pages |
224 | | - $.cookie( |
225 | | - $(this).data( 'sectionId'), |
226 | | - $(this).data( 'page' ) |
227 | | - ); |
228 | | - } ) |
| 233 | + var $page = $.wikiEditor.modules.toolbar.fn.buildPage( |
| 234 | + context, page, booklet.pages[page] |
229 | 235 | ); |
230 | | - // Add the content of the page and only show the selected one |
231 | | - var $page = $( '<div></div>' ) |
232 | | - .attr( 'rel', page ) |
233 | | - .addClass( 'page' ) |
234 | | - .addClass( 'page-' + page ) |
235 | | - .css( 'display', page == selected ? 'block' : 'none' ) |
236 | | - .appendTo( $pages ); |
237 | | - // Depending on the layout, we can render different page types |
238 | | - switch ( pages[page].layout ) { |
239 | | - case 'table': |
240 | | - var $table = $( '<table></table>' ) |
241 | | - .attr( { |
242 | | - 'cellpadding': '0', |
243 | | - 'cellspacing': '0', |
244 | | - 'border': '0', |
245 | | - 'width': '100%' |
246 | | - } ) |
247 | | - .appendTo( $page ); |
248 | | - if ( |
249 | | - 'headings' in pages[page] && |
250 | | - typeof pages[page].headings == 'object' |
251 | | - ) { |
252 | | - var $headings = $( '<tr></tr>' ).appendTo( $table ); |
253 | | - for ( heading in pages[page].headings ) { |
254 | | - var content = msg( |
255 | | - pages[page].headings[heading], 'content' |
256 | | - ); |
257 | | - $( '<th></th>' ) |
258 | | - .text( content ) |
259 | | - .appendTo( $headings ); |
260 | | - } |
261 | | - } |
262 | | - if ( |
263 | | - 'rows' in pages[page] && |
264 | | - typeof pages[page].rows == 'object' |
265 | | - ) { |
266 | | - for ( row in pages[page].rows ) { |
267 | | - var $row = $( '<tr></tr>' ).appendTo( $table ); |
268 | | - for ( cell in pages[page].rows[row] ) { |
269 | | - var content = msg( |
270 | | - pages[page].rows[row][cell], 'content' |
271 | | - ); |
272 | | - $( '<td></td>' ) |
273 | | - .addClass( cell ) |
274 | | - .attr( 'valign', 'top' ) |
275 | | - .append( |
276 | | - $( '<span></span>' ).html( content ) |
277 | | - ) |
278 | | - .appendTo( $row ); |
279 | | - } |
280 | | - } |
281 | | - } |
282 | | - break; |
283 | | - case 'characters': |
284 | | - var $characters = $( '<div></div>' ) |
285 | | - .attr( pages[page].attributes ) |
286 | | - .css( pages[page].styles ) |
287 | | - .appendTo( $page ); |
288 | | - if ( |
289 | | - 'characters' in pages[page] && |
290 | | - typeof pages[page].characters == 'object' |
291 | | - ) { |
292 | | - for ( character in pages[page].characters ) { |
293 | | - var char = pages[page].characters[character]; |
294 | | - var tool = {}; |
295 | | - /* |
296 | | - * The contents of char may be a string, or an |
297 | | - * object. If it's a string the string is both |
298 | | - * the label and the inserted value treated as |
299 | | - * a pre parameter to the encapsulateSelection |
300 | | - * action. If it's an object, the object must |
301 | | - * contain a label or it will be skipped - and |
302 | | - * the entire object is passed through as the |
303 | | - * tool configuration so it must contain valid |
304 | | - * tool configuration content as well. |
305 | | - */ |
306 | | - if ( typeof char == 'string' ) { |
307 | | - tool = { |
308 | | - 'type': 'link', |
309 | | - 'label': char, |
310 | | - 'action': { |
311 | | - 'type': 'encapsulate', |
312 | | - 'options': { |
313 | | - 'pre': char |
314 | | - } |
315 | | - } |
316 | | - }; |
317 | | - } else if ( typeof char == 'object' ) { |
318 | | - tool = char; |
319 | | - } else { |
320 | | - continue; |
321 | | - } |
322 | | - if ( !( 'label' in tool ) ) { |
323 | | - continue; |
324 | | - } |
325 | | - $characters.append( |
326 | | - $( '<a></a>' ) |
327 | | - .attr( 'href', '#' ) |
328 | | - .text( tool.label ) |
329 | | - .data( 'tool', tool ) |
330 | | - .click( useTool ) |
331 | | - ); |
332 | | - } |
333 | | - } |
334 | | - break; |
| 236 | + var $bookmark = $.wikiEditor.modules.toolbar.fn.buildBookmark( |
| 237 | + context, page, booklet.pages[page] |
| 238 | + ); |
| 239 | + if ( selected == page ) { |
| 240 | + $page.show(); |
| 241 | + $bookmark.addClass( 'current' ); |
| 242 | + } else { |
| 243 | + $page.hide(); |
335 | 244 | } |
| 245 | + $pages.append( $page ); |
| 246 | + $index.append( $bookmark ); |
336 | 247 | } |
337 | 248 | } |
338 | | - // Wraps gM from js2, but allows raw text to supercede |
339 | | - function msg( object, property ) { |
340 | | - return object[property] || gM( object[property + 'Msg'] ); |
341 | | - } |
342 | | - // Checks if a message of any kind is in an object |
343 | | - function objHasMsg( object, property ) { |
344 | | - return property in object || property + 'Msg' in object; |
345 | | - } |
346 | | - switch ( section.type ) { |
347 | | - case 'toolbar': |
348 | | - // Tools must be in groups, so if there're no groups this part |
349 | | - // of the configuration is not valid and we need to skip over it |
350 | | - if ( !( 'groups' in section ) ) { |
351 | | - return; |
| 249 | + return $booklet.append( $index ).append( $pages ); |
| 250 | + }, |
| 251 | + buildBookmark: function( context, id, page ) { |
| 252 | + var label = $.wikiEditor.modules.toolbar.fn.autoMsg( page, 'label' ); |
| 253 | + return $( '<div></div>' ) |
| 254 | + .text( label ) |
| 255 | + .attr( 'rel', id ) |
| 256 | + .data( 'context', context ) |
| 257 | + .click( function() { |
| 258 | + $(this) |
| 259 | + .parent() |
| 260 | + .parent() |
| 261 | + .find( '.page' ) |
| 262 | + .hide(); |
| 263 | + $(this) |
| 264 | + .parent() |
| 265 | + .parent() |
| 266 | + .find( '.page-' + $(this).attr( 'rel' ) ) |
| 267 | + .show(); |
| 268 | + $(this).siblings().removeClass( 'current' ); |
| 269 | + $(this).addClass( 'current' ); |
| 270 | + var section = $(this).parent().parent().attr( 'rel' ); |
| 271 | + $.cookie( |
| 272 | + 'wikiEditor-' + $(this).data( 'context' ).instance + |
| 273 | + '-booklet-' + section + '-page', |
| 274 | + $(this).attr( 'rel' ) |
| 275 | + ); |
| 276 | + } ); |
| 277 | + }, |
| 278 | + buildPage: function( context, id, page ) { |
| 279 | + var $page = $( '<div></div>' ).attr( { |
| 280 | + 'class': 'page page-' + id, |
| 281 | + 'rel': id |
| 282 | + } ); |
| 283 | + switch( page.layout ) { |
| 284 | + case 'table': |
| 285 | + $page.addClass( 'page-table' ); |
| 286 | + var $table = $( '<table></table>' ).attr( { |
| 287 | + 'cellpadding': '0', |
| 288 | + 'cellspacing': '0', |
| 289 | + 'border': '0', |
| 290 | + 'width': '100%', |
| 291 | + 'class': 'table table-' + id |
| 292 | + } ); |
| 293 | + if ( 'headings' in page ) { |
| 294 | + var $headings = $( '<tr></tr>' ); |
| 295 | + for ( heading in page.headings ) { |
| 296 | + var content = |
| 297 | + $.wikiEditor.modules.toolbar.fn.autoMsg( |
| 298 | + page.headings[heading], 'content' |
| 299 | + ); |
| 300 | + $headings.append( |
| 301 | + $( '<th></th>' ).text( content ) |
| 302 | + ); |
| 303 | + } |
| 304 | + $table.append( $headings ); |
352 | 305 | } |
353 | | - for ( group in section.groups ) { |
354 | | - var $group = $( '<div></div>' ) |
355 | | - .attr( 'class', 'group' ) |
356 | | - .attr( 'rel', group ) |
357 | | - .appendTo( $section ); |
358 | | - if ( objHasMsg( section.groups[group], 'label' ) ) { |
359 | | - $group.append( |
360 | | - $( '<div></div>' ) |
361 | | - .attr( 'class', 'label' ) |
362 | | - .text( msg( section.groups[group], 'label' ) ) |
363 | | - ) |
| 306 | + if ( 'rows' in page ) { |
| 307 | + for ( row in page.rows ) { |
| 308 | + var $row = $( '<tr></tr>' ); |
| 309 | + for ( cell in page.rows[row] ) { |
| 310 | + var $cell = $( '<td></td>' ).attr( { |
| 311 | + 'class': 'cell cell-' + cell, |
| 312 | + 'valign': 'top' |
| 313 | + } ); |
| 314 | + var content = |
| 315 | + $.wikiEditor.modules.toolbar.fn.autoMsg( |
| 316 | + page.rows[row][cell], 'content' |
| 317 | + ); |
| 318 | + $cell.append( |
| 319 | + $( '<span></span>' ).html( content ) |
| 320 | + ); |
| 321 | + $row.append( $cell ); |
| 322 | + } |
| 323 | + $table.append( $row ); |
364 | 324 | } |
365 | | - addTools( $group, section.groups[group].tools, sectionId ); |
366 | 325 | } |
367 | | - break; |
368 | | - case 'booklet': |
369 | | - if ( !( 'pages' in section ) ) { |
370 | | - return; |
| 326 | + $page.append( $table ); |
| 327 | + break; |
| 328 | + case 'characters': |
| 329 | + $page.addClass( 'page-characters' ); |
| 330 | + $characters = $( '<div></div>' ); |
| 331 | + if ( 'language' in page ) { |
| 332 | + $characters.attr( 'lang', page.language ); |
371 | 333 | } |
372 | | - var $index = $( '<div></div>' ) |
373 | | - .attr( 'class', 'index' ) |
374 | | - .appendTo( $section ); |
375 | | - var $pages = $( '<div></div>' ) |
376 | | - .attr( 'class', 'pages' ) |
377 | | - .appendTo( $section ); |
378 | | - addPages( $index, $pages, section.pages, sectionId ); |
| 334 | + if ( 'direction' in page ) { |
| 335 | + $characters.attr( 'dir', page.direction ); |
| 336 | + } |
| 337 | + if ( 'characters' in page ) { |
| 338 | + for ( character in page.characters ) { |
| 339 | + var tool = page.characters[character]; |
| 340 | + if ( typeof tool == 'string' ) { |
| 341 | + tool = { |
| 342 | + 'label': tool, |
| 343 | + 'action': { |
| 344 | + 'type': 'encapsulate', |
| 345 | + 'options': { 'pre': tool } |
| 346 | + } |
| 347 | + }; |
| 348 | + } |
| 349 | + if ( 'action' in tool && 'label' in tool ) { |
| 350 | + var $character = $( '<a></a>' ) |
| 351 | + .attr( 'href', '#' ) |
| 352 | + .text( tool.label ) |
| 353 | + .data( 'context', context ) |
| 354 | + .data( 'action', tool.action ) |
| 355 | + .click( function() { |
| 356 | + $.wikiEditor.modules.toolbar.fn.doAction( |
| 357 | + $(this).data( 'context' ), |
| 358 | + $(this).data( 'action' ) |
| 359 | + ); |
| 360 | + return false; |
| 361 | + } ); |
| 362 | + $characters.append( $character ); |
| 363 | + } |
| 364 | + } |
| 365 | + $page.append( $characters ); |
| 366 | + } |
379 | 367 | break; |
380 | 368 | } |
| 369 | + return $page; |
381 | 370 | }, |
382 | | - /** |
383 | | - * Builds toolbar |
384 | | - * |
385 | | - * @param {Object} context |
386 | | - * @param {Object} config |
387 | | - */ |
388 | 371 | build: function( context, config ) { |
389 | | - // Create some containers for various elements and append them |
390 | 372 | var $tabs = $( '<div></div>' ) |
391 | 373 | .addClass( 'tabs' ) |
392 | 374 | .appendTo( context.modules.$toolbar ); |
— | — | @@ -395,83 +377,46 @@ |
396 | 378 | context.modules.$toolbar.append( |
397 | 379 | $( '<div></div>' ).addClass( 'break' ) |
398 | 380 | ); |
399 | | - // Create a base name for keys that will be stored in a cookie which |
400 | | - // maintain the state of which sections are open and closed |
401 | | - var sectionIdBase = |
402 | | - 'wikiEditor-' + context.instance + '-ui-toolbar-section'; |
403 | | - // Add section container, initially in loading class - but that will |
404 | | - // get removed once the section is done being built |
405 | | - var sectionCookie = 'wikiEditor-' + context.instance + '-section'; |
406 | | - // To prevent slow page rendering times, we store the individual |
407 | | - // section configurations in a queue to be built asynchrnously later on |
| 381 | + var selected = $.cookie( |
| 382 | + 'wikiEditor-' + context.instance + '-toolbar-section' |
| 383 | + ); |
408 | 384 | var sectionQueue = []; |
409 | 385 | for ( section in config ) { |
410 | | - // Unique section HTML ID |
411 | | - var sectionId = |
412 | | - sectionCookie + '-' + config[section].type + '-' + section; |
413 | | - // Handle the main specially both for layout purposes and |
414 | | - // so that it is rendered immediately while the other sections are |
415 | | - // rendered asynchronously and possibly much later |
416 | 386 | if ( section == 'main' ) { |
417 | | - var $section = $( '<div></div>' ) |
418 | | - .attr( 'rel', section ) |
419 | | - .addClass( 'section-' + config[section].type ) |
420 | | - .addClass( |
421 | | - 'section-' + config[section].type + '-' + section |
| 387 | + context.modules.$toolbar.prepend( |
| 388 | + $.wikiEditor.modules.toolbar.fn.buildSection( |
| 389 | + context, section, config[section] |
422 | 390 | ) |
423 | | - .attr( 'id', sectionId ) |
424 | | - .prependTo( context.modules.$toolbar ); |
425 | | - |
426 | | - $.wikiEditor.modules.toolbar.fn.addSection( |
427 | | - context, $section, config[section], 'main' |
428 | 391 | ); |
429 | | - continue; |
430 | | - } |
431 | | - // Handle normal sections by giving them tabs and hiding them away |
432 | | - // by default |
433 | | - var $section = $( '<div></div>' ) |
434 | | - .attr( 'rel', section ) |
435 | | - .addClass( 'section loading' ) |
436 | | - .addClass( 'section-' + config[section].type ) |
437 | | - .addClass( |
438 | | - 'section-' + config[section].type + '-' + section |
439 | | - ) |
440 | | - .attr( 'id', sectionId ) |
441 | | - .append( |
442 | | - $( '<div></div>' ) |
443 | | - .addClass( 'spinner' ) |
444 | | - .text( gM( 'edittoolbar-loading' ) ) |
445 | | - ) |
446 | | - .appendTo( $sections ); |
447 | | - // Recall the state from cookie |
448 | | - var current = false; |
449 | | - if ( $.cookie( sectionCookie ) == sectionId ) { |
450 | | - $section.attr( 'style', 'display:block' ); |
451 | | - current = true; |
452 | | - } |
453 | | - // Add section to queue for later processing |
454 | | - sectionQueue[sectionQueue.length] = { |
455 | | - '$section': $section, |
456 | | - 'tools': config[section], |
457 | | - 'id': sectionId |
458 | | - }; |
459 | | - // Add a tab the user can click to hide and show the section |
460 | | - $tabs.append( |
461 | | - $( '<span></span>' ) |
462 | | - .attr( 'class', 'tab' ) |
463 | | - .attr( 'rel', section ) |
464 | | - .append( |
465 | | - $( '<a></a>' ) |
| 392 | + } else { |
| 393 | + $sections.append( |
| 394 | + $.wikiEditor.modules.toolbar.fn.buildSection( |
| 395 | + context, section, config[section] |
| 396 | + ) |
| 397 | + .css( 'display', selected == section ? 'block' : 'none' ) |
| 398 | + ); |
| 399 | + $tabs.append( |
| 400 | + $( '<span></span>' ) |
| 401 | + .attr( { |
| 402 | + 'class': 'tab tab-' + section, |
| 403 | + 'rel': section |
| 404 | + } ) |
| 405 | + .append( |
| 406 | + $( '<a></a>' ) |
| 407 | + .addClass( selected == section ? 'current' : null ) |
| 408 | + .attr( 'href', '#' ) |
466 | 409 | .text( |
467 | | - config[section].label || |
468 | | - gM( config[section].labelMsg ) |
| 410 | + $.wikiEditor.modules.toolbar.fn.autoMsg( |
| 411 | + config[section], 'label' |
| 412 | + ) |
469 | 413 | ) |
470 | | - .attr( 'href', '#' ) |
471 | | - .addClass( current ? 'current' : null ) |
472 | | - .data( '$section', $section ) |
473 | | - .data( 'sectionCookie', sectionCookie ) |
| 414 | + .data( 'context', context ) |
474 | 415 | .click( function() { |
475 | | - var $section = $(this).data( '$section' ); |
| 416 | + var $section = |
| 417 | + $(this).data( 'context' ).$ui.find( |
| 418 | + '.section-' + |
| 419 | + $(this).parent().attr( 'rel' ) |
| 420 | + ); |
476 | 421 | $(this).blur(); |
477 | 422 | var show = $section.css( 'display' ) == 'none'; |
478 | 423 | $section.parent().children().hide(); |
— | — | @@ -485,26 +430,17 @@ |
486 | 431 | $(this).addClass( 'current' ); |
487 | 432 | } |
488 | 433 | $.cookie( |
489 | | - $(this).data( 'sectionCookie' ), |
490 | | - show ? $section.attr( 'id' ) : null |
| 434 | + 'wikiEditor-' + |
| 435 | + $(this).data( 'context' ).instance + |
| 436 | + '-toolbar-section', |
| 437 | + show ? $section.attr( 'rel' ) : null |
491 | 438 | ); |
492 | 439 | return false; |
493 | 440 | } ) |
494 | | - ) |
495 | | - ); |
496 | | - } |
497 | | - // Process the section queue |
498 | | - $.eachAsync( sectionQueue, { |
499 | | - bulk: 0, |
500 | | - loop: function( index, section ) { |
501 | | - $.wikiEditor.modules.toolbar.fn.addSection( |
502 | | - context, section.$section, section.tools, section.id |
| 441 | + ) |
503 | 442 | ); |
504 | | - // When addSection is done, we can remove the loading |
505 | | - // class to hide the spinner and reveal the content |
506 | | - section.$section.removeClass( 'loading' ) |
507 | 443 | } |
508 | | - } ); |
| 444 | + } |
509 | 445 | } |
510 | 446 | } |
511 | 447 | |