Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -56,16 +56,16 @@ |
57 | 57 | array( 'src' => 'js/plugins/jquery.async.js', 'version' => 3 ), |
58 | 58 | array( 'src' => 'js/plugins/jquery.browser.js', 'version' => 3 ), |
59 | 59 | array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 3 ), |
60 | | - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 8 ), |
| 60 | + array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 9 ), |
61 | 61 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 4 ), |
62 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 9 ), |
| 62 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 10 ), |
63 | 63 | array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 4 ), |
64 | 64 | ), |
65 | 65 | 'combined' => array( |
66 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 13 ), |
| 66 | + array( 'src' => 'js/plugins.combined.js', 'version' => 14 ), |
67 | 67 | ), |
68 | 68 | 'minified' => array( |
69 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 13 ), |
| 69 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 14 ), |
70 | 70 | ), |
71 | 71 | ), |
72 | 72 | ); |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -98,10 +98,26 @@ |
99 | 99 | var invalidMsg = gM( 'edittoolbar-tool-link-int-target-status-invalid' ); |
100 | 100 | var loadingMsg = gM( 'edittoolbar-tool-link-int-target-status-loading' ); |
101 | 101 | $j( '#edittoolbar-link-int-target-status' ) |
102 | | - .html( '<img id="edittoolbar-link-int-target-status-exists" src="' + existsImg + '" alt="' + existsMsg + '" title="' + existsMsg + '" />' + |
103 | | - '<img id="edittoolbar-link-int-target-status-notexists" src="' + notexistsImg + '" alt="' + notexistsMsg + '" title="' + notexistsMsg + '" />' + |
104 | | - '<img id="edittoolbar-link-int-target-status-invalid" src="' + invalidImg + '" alt="' + invalidMsg + '" title="' + invalidMsg + '" />' + |
105 | | - '<img id="edittoolbar-link-int-target-status-loading" src="' + loadingImg + '" alt="' + loadingMsg + '" title="' + loadingMsg + '" />' ) |
| 102 | + .append( $j( '<img />' ).attr( { |
| 103 | + 'id': 'edittoolbar-link-int-target-status-exists', |
| 104 | + 'src': existsImg, |
| 105 | + 'alt': existsMsg, |
| 106 | + 'title': existsMsg } ) ) |
| 107 | + .append( $j( '<img />' ).attr( { |
| 108 | + 'id': 'edittoolbar-link-int-target-status-notexists', |
| 109 | + 'src': notexistsImg, |
| 110 | + 'alt': notexistsMsg, |
| 111 | + 'title': notexistsMsg } ) ) |
| 112 | + .append( $j( '<img />' ).attr( { |
| 113 | + 'id': 'edittoolbar-link-int-target-status-invalid', |
| 114 | + 'src': invalidImg, |
| 115 | + 'alt': invalidMsg, |
| 116 | + 'title': invalidMsg } ) ) |
| 117 | + .append( $j( '<img />' ).attr( { |
| 118 | + 'id': 'edittoolbar-link-int-target-status-loading', |
| 119 | + 'src': loadingImg, |
| 120 | + 'alt': loadingMsg, |
| 121 | + 'title': loadingMsg } ) ) |
106 | 122 | .data( 'cache', {} ) |
107 | 123 | .children().hide(); |
108 | 124 | |
— | — | @@ -195,6 +211,7 @@ |
196 | 212 | return s.replace( /(]+)/g, '<nowiki>$1</nowiki>' ); |
197 | 213 | } |
198 | 214 | var insertText = ''; |
| 215 | + var whitespace = [ '', '' ]; |
199 | 216 | switch ( $j( '#edittoolbar-link-tabs' ).tabs( 'option', 'selected' ) ) { |
200 | 217 | case 0: // Internal link |
201 | 218 | // FIXME: Exactly how fragile is this? |
— | — | @@ -205,6 +222,7 @@ |
206 | 223 | } |
207 | 224 | var target = $j( '#edittoolbar-link-int-target' ).val(); |
208 | 225 | var text = $j( '#edittoolbar-link-int-text' ).val(); |
| 226 | + whitespace = $j( '#edittoolbar-link-dialog-tab-int' ).data( 'whitespace' ); |
209 | 227 | if ( target == text ) |
210 | 228 | insertText = '[[' + target + ']]'; |
211 | 229 | else |
— | — | @@ -215,6 +233,7 @@ |
216 | 234 | var text = $j( '#edittoolbar-link-ext-text' ).val(); |
217 | 235 | var escTarget = escapeExternalTarget( target ); |
218 | 236 | var escText = escapeExternalText( text ); |
| 237 | + whitespace = $j( '#edittoolbar-link-dialog-tab-ext' ).data( 'whitespace' ); |
219 | 238 | if ( escTarget == escText ) |
220 | 239 | insertText = escTarget; |
221 | 240 | else if ( text == '' ) |
— | — | @@ -223,8 +242,10 @@ |
224 | 243 | insertText = '[' + escTarget + ' ' + escText + ']'; |
225 | 244 | break; |
226 | 245 | } |
| 246 | + // Preserve whitespace in selection when replacing |
| 247 | + insertText = whitespace[0] + insertText + whitespace[1]; |
227 | 248 | $j.wikiEditor.modules.toolbar.fn.doAction( $j(this).data( 'context' ), { |
228 | | - type: 'encapsulate', |
| 249 | + type: 'replace', |
229 | 250 | options: { |
230 | 251 | pre: insertText |
231 | 252 | } |
— | — | @@ -235,48 +256,49 @@ |
236 | 257 | $j(this).dialog( 'close' ); |
237 | 258 | } |
238 | 259 | }, |
239 | | - close: function() { |
240 | | - // Clear text fields |
241 | | - $j(this).find( 'input' ).val( '' ); |
242 | | - }, |
243 | 260 | open: function() { |
244 | 261 | // Smart pre-fill text fields |
245 | | - // TODO: Replace selection, replace button |
246 | | - // TODO: Don't clear fields in other tab |
247 | 262 | var selection = $j(this).data( 'context' ).$textarea.getSelection(); |
248 | 263 | if ( selection != '' ) { |
249 | 264 | var inttext, inttarget, exttext, exttarget; |
250 | 265 | var matches; |
251 | 266 | var tab = -1; |
252 | | - if ( ( matches = selection.match( /^\s*\[\[([^\]\|]+)(\|([^\]\|]*))?\]\]\s*$/ ) ) ) { |
| 267 | + $j( '#edittoolbar-link-dialog-tab-int' ).data( 'whitespace', [ '', '' ] ); |
| 268 | + $j( '#edittoolbar-link-dialog-tab-ext' ).data( 'whitespace', [ '', '' ] ); |
| 269 | + if ( ( matches = selection.match( /^(\s*)\[\[([^\]\|]+)(\|([^\]\|]*))?\]\](\s*)$/ ) ) ) { |
253 | 270 | // [[foo|bar]] or [[foo]] |
254 | | - inttarget = matches[1]; |
255 | | - inttext = ( matches[3] ? matches[3] : matches[1] ); |
256 | | - exttarget = 'http://'; |
257 | | - exttext = ''; |
| 271 | + inttarget = matches[2]; |
| 272 | + inttext = ( matches[4] ? matches[4] : matches[2] ); |
258 | 273 | tab = 0; |
259 | | - } else if ( ( matches = selection.match( /^\s*\[([^\] ]+)( ([^\]]+))?\]\s*$/ ) ) ) { |
| 274 | + // Preserve whitespace when replacing |
| 275 | + $j( '#edittoolbar-link-dialog-tab-int' ).data( 'whitespace', [ matches[1], matches[5] ] ); |
| 276 | + } else if ( ( matches = selection.match( /^(\s*)\[([^\] ]+)( ([^\]]+))?\](\s*)$/ ) ) ) { |
260 | 277 | // [http://www.example.com foo] or [http://www.example.com] |
261 | | - exttarget = matches[1]; |
262 | | - exttext = ( matches[3] ? matches[3] : '' ); |
263 | | - inttarget = ''; |
264 | | - inttext = ''; |
| 278 | + exttarget = matches[2]; |
| 279 | + exttext = ( matches[4] ? matches[4] : '' ); |
265 | 280 | tab = 1; |
| 281 | + // Preserve whitespace when replacing |
| 282 | + $j( '#edittoolbar-link-dialog-tab-ext' ).data( 'whitespace', [ matches[1], matches[5] ] ); |
266 | 283 | } else { |
267 | 284 | inttarget = inttext = exttext = selection; |
268 | 285 | exttarget = 'http://'; |
269 | 286 | } |
270 | 287 | |
271 | 288 | // val() doesn't trigger the change event, so let's do that ourselves |
272 | | - $j( '#edittoolbar-link-int-text' ).val( inttext ).change(); |
273 | | - $j( '#edittoolbar-link-int-target' ).val( inttarget ).change(); |
274 | | - $j( '#edittoolbar-link-ext-text' ).val( exttext ).change(); |
275 | | - $j( '#edittoolbar-link-ext-target' ).val( exttarget ).change(); |
| 289 | + if ( typeof inttext != 'undefined' ) |
| 290 | + $j( '#edittoolbar-link-int-text' ).val( inttext ).change(); |
| 291 | + if ( typeof inttarget != 'undefined' ) |
| 292 | + $j( '#edittoolbar-link-int-target' ).val( inttarget ).change(); |
| 293 | + if ( typeof exttext != 'undefined' ) |
| 294 | + $j( '#edittoolbar-link-ext-text' ).val( exttext ).change(); |
| 295 | + if ( typeof exttarget != 'undefined' ) |
| 296 | + $j( '#edittoolbar-link-ext-target' ).val( exttarget ).change(); |
276 | 297 | if ( tab != -1 ) |
277 | 298 | $j( '#edittoolbar-link-tabs' ).tabs( 'select', tab ); |
278 | 299 | } |
279 | | - if ( $j( '#edittoolbar-link-int-text' ).val() == $j( '#edittoolbar-link-int-target' ).val() ) |
280 | | - $j( '#edittoolbar-link-int-text' ).data( 'untouched', true ); |
| 300 | + $j( '#edittoolbar-link-int-text' ).data( 'untouched', |
| 301 | + $j( '#edittoolbar-link-int-text' ).val() == $j( '#edittoolbar-link-int-target' ).val() |
| 302 | + ); |
281 | 303 | } |
282 | 304 | } |
283 | 305 | } |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | /* Configuration */ |
21 | 21 | |
22 | 22 | // Bump the version number every time you change any of the .css/.js files |
23 | | -$wgEditToolbarStyleVersion = 24; |
| 23 | +$wgEditToolbarStyleVersion = 25; |
24 | 24 | |
25 | 25 | // Set this to true to simply override the stock toolbar for everyone |
26 | 26 | $wgEditToolbarGlobalEnable = false; |
Index: trunk/extensions/UsabilityInitiative/css/combined.css |
— | — | @@ -91,21 +91,21 @@ |
92 | 92 | border-bottom: solid 1px #DDDDDD; |
93 | 93 | }/* wikiEditor toolbar module */ |
94 | 94 | |
95 | | -.wikiEditor-ui .wikiEditor-ui-toolbar { |
| 95 | +.wikiEditor-ui-toolbar { |
96 | 96 | position: relative; |
97 | 97 | width: 100%; |
98 | 98 | } |
99 | 99 | |
100 | 100 | /* Expandable Sections */ |
101 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections { |
| 101 | +.wikiEditor-ui-toolbar .sections { |
102 | 102 | float: left; |
103 | 103 | width: 100%; |
104 | 104 | clear: both; |
105 | 105 | } |
106 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections { |
| 106 | +body.rtl .wikiEditor-ui-toolbar .sections { |
107 | 107 | float: right; |
108 | 108 | } |
109 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections .section { |
| 109 | +.wikiEditor-ui-toolbar .sections .section { |
110 | 110 | display: none; |
111 | 111 | float: left; |
112 | 112 | width: 100%; |
— | — | @@ -115,20 +115,20 @@ |
116 | 116 | border-top: solid 1px #DDDDDD; |
117 | 117 | background-color: #F3F3F3; |
118 | 118 | } |
119 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections .section { |
| 119 | +body.rtl .wikiEditor-ui-toolbar .sections .section { |
120 | 120 | float: right; |
121 | 121 | margin-left: auto; |
122 | 122 | margin-right: -1px; |
123 | 123 | } |
124 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading { |
| 124 | +.wikiEditor-ui-toolbar .sections .loading { |
125 | 125 | padding-top: 0.5em; |
126 | 126 | padding-bottom: 0.5em; |
127 | 127 | } |
128 | 128 | /* Gets overridden when the section div is in class loading - see below */ |
129 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections div .spinner { |
| 129 | +.wikiEditor-ui-toolbar .sections div .spinner { |
130 | 130 | display: none; |
131 | 131 | } |
132 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading .spinner { |
| 132 | +.wikiEditor-ui-toolbar .sections .loading .spinner { |
133 | 133 | display: block; |
134 | 134 | background-image: url(../images/wikiEditor/toolbar/loading.gif); |
135 | 135 | background-position: left center; |
— | — | @@ -138,7 +138,7 @@ |
139 | 139 | float: left; |
140 | 140 | color: #666666; |
141 | 141 | } |
142 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading .spinner { |
| 142 | +body.rtl .wikiEditor-ui-toolbar .sections .loading .spinner { |
143 | 143 | background-position: right center; |
144 | 144 | padding-left: 0; |
145 | 145 | padding-right: 32px; |
— | — | @@ -147,25 +147,25 @@ |
148 | 148 | float: right; |
149 | 149 | } |
150 | 150 | /* Top Level Containers */ |
151 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs, |
152 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-main { |
| 151 | +.wikiEditor-ui-toolbar .tabs, |
| 152 | +.wikiEditor-ui-toolbar .section-main { |
153 | 153 | position: relative; |
154 | 154 | float: left; |
155 | 155 | height: 26px; |
156 | 156 | } |
157 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs, |
158 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-main { |
| 157 | +body.rtl .wikiEditor-ui-toolbar .tabs, |
| 158 | +body.rtl .wikiEditor-ui-toolbar .section-main { |
159 | 159 | float: right; |
160 | 160 | } |
161 | 161 | /* Groups */ |
162 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .group { |
| 162 | +.wikiEditor-ui-toolbar .group { |
163 | 163 | float: left; |
164 | 164 | height: 26px; |
165 | 165 | padding-right: 6px; |
166 | 166 | border-right: solid 1px #DDDDDD; |
167 | 167 | margin: 3px; |
168 | 168 | } |
169 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group { |
| 169 | +body.rtl .wikiEditor-ui-toolbar .group { |
170 | 170 | float: right; |
171 | 171 | padding-right: 0; |
172 | 172 | padding-left: 6px; |
— | — | @@ -173,25 +173,25 @@ |
174 | 174 | border-left: solid 1px #DDDDDD; |
175 | 175 | } |
176 | 176 | /* Tabs */ |
177 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs { |
| 177 | +.wikiEditor-ui-toolbar .tabs { |
178 | 178 | list-style: none; |
179 | 179 | margin: 3px; |
180 | 180 | } |
181 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab { |
| 181 | +.wikiEditor-ui-toolbar .tabs span.tab { |
182 | 182 | display: inline-block; |
183 | 183 | float: left; |
184 | 184 | line-height: 26px; |
185 | 185 | } |
186 | 186 | /* IGNORED BY IE6 */ |
187 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab { |
| 187 | +.wikiEditor-ui-toolbar .tabs > span.tab { |
188 | 188 | display: block; |
189 | 189 | } |
190 | 190 | /* IGNORED BY IE6 */ |
191 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab { |
| 191 | +body.rtl .wikiEditor-ui-toolbar .tabs > span.tab { |
192 | 192 | float: right; |
193 | 193 | } |
194 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a, |
195 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a:visited { |
| 194 | +.wikiEditor-ui-toolbar .tabs span.tab a, |
| 195 | +.wikiEditor-ui-toolbar .tabs span.tab a:visited { |
196 | 196 | display: inline-block; |
197 | 197 | float: left; |
198 | 198 | padding-left: 18px; |
— | — | @@ -203,32 +203,32 @@ |
204 | 204 | background-position: left center; |
205 | 205 | background-repeat: no-repeat; |
206 | 206 | } |
207 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a, |
208 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a:visited { |
| 207 | +body.rtl .wikiEditor-ui-toolbar .tabs span.tab a, |
| 208 | +body.rtl .wikiEditor-ui-toolbar .tabs span.tab a:visited { |
209 | 209 | padding-left: 12px; |
210 | 210 | padding-right: 18px; |
211 | 211 | background-image: url(../images/wikiEditor/toolbar/arrow-left.png); |
212 | 212 | background-position: right center; |
213 | 213 | } |
214 | 214 | /* IGNORED BY IE6 */ |
215 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab > a, |
216 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > pan.tab > a:visited { |
| 215 | +body.rtl .wikiEditor-ui-toolbar .tabs > span.tab > a, |
| 216 | +body.rtl .wikiEditor-ui-toolbar .tabs > pan.tab > a:visited { |
217 | 217 | float: right; |
218 | 218 | } |
219 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current, |
220 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:visited { |
| 219 | +.wikiEditor-ui-toolbar .tabs span.tab a.current, |
| 220 | +.wikiEditor-ui-toolbar .tabs span.tab a.current:visited { |
221 | 221 | color: #333333; |
222 | 222 | background-image: url(../images/wikiEditor/toolbar/arrow-down.png); |
223 | 223 | } |
224 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current, |
225 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:visited { |
| 224 | +body.rtl .wikiEditor-ui-toolbar .tabs span.tab a.current, |
| 225 | +body.rtl .wikiEditor-ui-toolbar .tabs span.tab a.current:visited { |
226 | 226 | background-image: url(../images/wikiEditor/toolbar/arrow-down.png); |
227 | 227 | } |
228 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:hover { |
| 228 | +.wikiEditor-ui-toolbar .tabs span.tab a.current:hover { |
229 | 229 | text-decoration: none; |
230 | 230 | } |
231 | 231 | /* Toolbar */ |
232 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .group .label { |
| 232 | +.wikiEditor-ui-toolbar .group .label { |
233 | 233 | float: left; |
234 | 234 | border: 0px; |
235 | 235 | height: 22px; |
— | — | @@ -240,12 +240,12 @@ |
241 | 241 | cursor: default; |
242 | 242 | } |
243 | 243 | /* IGNORED BY IE6 */ |
244 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > .label { |
| 244 | +body.rtl .wikiEditor-ui-toolbar .group > .label { |
245 | 245 | float: right; |
246 | 246 | margin-left: 8px; |
247 | 247 | margin-right: 5px; |
248 | 248 | } |
249 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .group img.tool { |
| 249 | +.wikiEditor-ui-toolbar .group img.tool { |
250 | 250 | float: left; |
251 | 251 | border: 0px; |
252 | 252 | height: 22px; |
— | — | @@ -254,90 +254,90 @@ |
255 | 255 | cursor: pointer; |
256 | 256 | } |
257 | 257 | /* IGNORED BY IE6 */ |
258 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > img.tool { |
| 258 | +body.rtl .wikiEditor-ui-toolbar .group > img.tool { |
259 | 259 | float: right; |
260 | 260 | } |
261 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .group select { |
| 261 | +.wikiEditor-ui-toolbar .group select { |
262 | 262 | float: left; |
263 | 263 | margin: 2px; |
264 | 264 | height: 22px; |
265 | 265 | cursor: pointer; |
266 | 266 | } |
267 | 267 | /* IGNORED BY IE6 */ |
268 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > select { |
| 268 | +body.rtl .wikiEditor-ui-toolbar .group > select { |
269 | 269 | float: right; |
270 | 270 | font-size: 0.9em; |
271 | 271 | } |
272 | 272 | /* Booklet */ |
273 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index { |
| 273 | +.wikiEditor-ui-toolbar .booklet .index { |
274 | 274 | float: left; |
275 | 275 | width: 20%; |
276 | 276 | height: 125px; |
277 | 277 | overflow: auto; |
278 | 278 | } |
279 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index { |
| 279 | +body.rtl .wikiEditor-ui-toolbar .booklet .index { |
280 | 280 | float: right; |
281 | 281 | } |
282 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index div { |
| 282 | +.wikiEditor-ui-toolbar .booklet .index div { |
283 | 283 | padding: 4px; |
284 | 284 | padding-left: 6px; |
285 | 285 | cursor: pointer; |
286 | 286 | color: #0645ad; |
287 | 287 | } |
288 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index div { |
| 288 | +body.rtl .wikiEditor-ui-toolbar .booklet .index div { |
289 | 289 | padding-left: 4px; |
290 | 290 | padding-right: 6px; |
291 | 291 | } |
292 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index .current { |
| 292 | +.wikiEditor-ui-toolbar .booklet .index .current { |
293 | 293 | background-color: #FAFAFA; |
294 | 294 | color: #333333; |
295 | 295 | cursor: default; |
296 | 296 | } |
297 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .pages { |
| 297 | +.wikiEditor-ui-toolbar .booklet .pages { |
298 | 298 | float: right; |
299 | 299 | width: 80%; |
300 | 300 | height: 125px; |
301 | 301 | overflow: auto; |
302 | 302 | background-color: #FAFAFA; |
303 | 303 | } |
304 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .pages { |
| 304 | +body.rtl .wikiEditor-ui-toolbar .booklet .pages { |
305 | 305 | float: left; |
306 | 306 | } |
307 | 307 | /* Help Pages */ |
308 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table { |
| 308 | +.wikiEditor-ui-toolbar .page-table table { |
309 | 309 | padding-left: 5px; |
310 | 310 | padding-right: 5px; |
311 | 311 | background: none; |
312 | 312 | } |
313 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th { |
| 313 | +.wikiEditor-ui-toolbar .page-table th { |
314 | 314 | color: #999999; |
315 | 315 | } |
316 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td { |
| 316 | +.wikiEditor-ui-toolbar .page-table td { |
317 | 317 | color: black; |
318 | 318 | border-top: solid 1px #EEEEEE; |
319 | 319 | } |
320 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th, |
321 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td { |
| 320 | +.wikiEditor-ui-toolbar .page-table th, |
| 321 | +.wikiEditor-ui-toolbar .page-table td { |
322 | 322 | text-align: left; |
323 | 323 | padding: 5px; |
324 | 324 | margin: 0px; |
325 | 325 | } |
326 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th, |
327 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td { |
| 326 | +body.rtl .wikiEditor-ui-toolbar .page-table th, |
| 327 | +body.rtl .wikiEditor-ui-toolbar .page-table td { |
328 | 328 | text-align: right; |
329 | 329 | } |
330 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.syntax { |
| 330 | +.wikiEditor-ui-toolbar .section-help .page-table td.syntax { |
331 | 331 | font-family: monospace; |
332 | 332 | } |
333 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.syntax, |
334 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.result { |
| 333 | +.wikiEditor-ui-toolbar .section-help .page-table td.syntax, |
| 334 | +.wikiEditor-ui-toolbar .section-help .page-table td.result { |
335 | 335 | width: 40%; |
336 | 336 | } |
337 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.description { |
| 337 | +.wikiEditor-ui-toolbar .section-help .page-table td.description { |
338 | 338 | width: 20%; |
339 | 339 | } |
340 | 340 | /* Characters Pages */ |
341 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div a { |
| 341 | +.wikiEditor-ui-toolbar .page-characters div a { |
342 | 342 | border: solid 1px #DDDDDD; |
343 | 343 | padding: 5px; |
344 | 344 | padding-left: 8px; |
— | — | @@ -350,14 +350,14 @@ |
351 | 351 | color: black; |
352 | 352 | text-decoration: none; |
353 | 353 | } |
354 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters > div > a, |
355 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div[dir=rtl] a { |
| 354 | +body.rtl .wikiEditor-ui-toolbar .page-characters > div > a, |
| 355 | +.wikiEditor-ui-toolbar .page-characters div[dir=rtl] a { |
356 | 356 | direction: rtl; |
357 | 357 | float: right; |
358 | 358 | margin-left: 0; |
359 | 359 | margin-right: 5px; |
360 | 360 | } |
361 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div a:hover { |
| 361 | +.wikiEditor-ui-toolbar .page-characters div a:hover { |
362 | 362 | background-color: white; |
363 | 363 | text-decoration: none; |
364 | 364 | border-color: #a8d7f9; |
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css |
— | — | @@ -81,19 +81,19 @@ |
82 | 82 | font-size:1em; |
83 | 83 | border-bottom:solid 1px #DDDDDD; |
84 | 84 | } |
85 | | -.wikiEditor-ui .wikiEditor-ui-toolbar{ |
| 85 | +.wikiEditor-ui-toolbar{ |
86 | 86 | position:relative; |
87 | 87 | width:100%; |
88 | 88 | } |
89 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections{ |
| 89 | +.wikiEditor-ui-toolbar .sections{ |
90 | 90 | float:left; |
91 | 91 | width:100%; |
92 | 92 | clear:both; |
93 | 93 | } |
94 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections{ |
| 94 | +body.rtl .wikiEditor-ui-toolbar .sections{ |
95 | 95 | float:right; |
96 | 96 | } |
97 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections .section{ |
| 97 | +.wikiEditor-ui-toolbar .sections .section{ |
98 | 98 | display:none; |
99 | 99 | float:left; |
100 | 100 | width:100%; |
— | — | @@ -103,19 +103,19 @@ |
104 | 104 | border-top:solid 1px #DDDDDD; |
105 | 105 | background-color:#F3F3F3; |
106 | 106 | } |
107 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections .section{ |
| 107 | +body.rtl .wikiEditor-ui-toolbar .sections .section{ |
108 | 108 | float:right; |
109 | 109 | margin-left:auto; |
110 | 110 | margin-right:-1px; |
111 | 111 | } |
112 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading{ |
| 112 | +.wikiEditor-ui-toolbar .sections .loading{ |
113 | 113 | padding-top:0.5em; |
114 | 114 | padding-bottom:0.5em; |
115 | 115 | } |
116 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections div .spinner{ |
| 116 | +.wikiEditor-ui-toolbar .sections div .spinner{ |
117 | 117 | display:none; |
118 | 118 | } |
119 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading .spinner{ |
| 119 | +.wikiEditor-ui-toolbar .sections .loading .spinner{ |
120 | 120 | display:block; |
121 | 121 | background-image:url(../images/wikiEditor/toolbar/loading.gif); |
122 | 122 | background-position:left center; |
— | — | @@ -125,7 +125,7 @@ |
126 | 126 | float:left; |
127 | 127 | color:#666666; |
128 | 128 | } |
129 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .sections .loading .spinner{ |
| 129 | +body.rtl .wikiEditor-ui-toolbar .sections .loading .spinner{ |
130 | 130 | background-position:right center; |
131 | 131 | padding-left:0; |
132 | 132 | padding-right:32px; |
— | — | @@ -133,47 +133,47 @@ |
134 | 134 | margin-right:1em; |
135 | 135 | float:right; |
136 | 136 | } |
137 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs, |
138 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-main{ |
| 137 | +.wikiEditor-ui-toolbar .tabs, |
| 138 | +.wikiEditor-ui-toolbar .section-main{ |
139 | 139 | position:relative; |
140 | 140 | float:left; |
141 | 141 | height:26px; |
142 | 142 | } |
143 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs, |
144 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-main{ |
| 143 | +body.rtl .wikiEditor-ui-toolbar .tabs, |
| 144 | +body.rtl .wikiEditor-ui-toolbar .section-main{ |
145 | 145 | float:right; |
146 | 146 | } |
147 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .group{ |
| 147 | +.wikiEditor-ui-toolbar .group{ |
148 | 148 | float:left; |
149 | 149 | height:26px; |
150 | 150 | padding-right:6px; |
151 | 151 | border-right:solid 1px #DDDDDD; |
152 | 152 | margin:3px; |
153 | 153 | } |
154 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group{ |
| 154 | +body.rtl .wikiEditor-ui-toolbar .group{ |
155 | 155 | float:right; |
156 | 156 | padding-right:0; |
157 | 157 | padding-left:6px; |
158 | 158 | border-right:none; |
159 | 159 | border-left:solid 1px #DDDDDD; |
160 | 160 | } |
161 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs{ |
| 161 | +.wikiEditor-ui-toolbar .tabs{ |
162 | 162 | list-style:none; |
163 | 163 | margin:3px; |
164 | 164 | } |
165 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab{ |
| 165 | +.wikiEditor-ui-toolbar .tabs span.tab{ |
166 | 166 | display:inline-block; |
167 | 167 | float:left; |
168 | 168 | line-height:26px; |
169 | 169 | } |
170 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab{ |
| 170 | +.wikiEditor-ui-toolbar .tabs > span.tab{ |
171 | 171 | display:block; |
172 | 172 | } |
173 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab{ |
| 173 | +body.rtl .wikiEditor-ui-toolbar .tabs > span.tab{ |
174 | 174 | float:right; |
175 | 175 | } |
176 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a, |
177 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a:visited{ |
| 176 | +.wikiEditor-ui-toolbar .tabs span.tab a, |
| 177 | +.wikiEditor-ui-toolbar .tabs span.tab a:visited{ |
178 | 178 | display:inline-block; |
179 | 179 | float:left; |
180 | 180 | padding-left:18px; |
— | — | @@ -185,30 +185,30 @@ |
186 | 186 | background-position:left center; |
187 | 187 | background-repeat:no-repeat; |
188 | 188 | } |
189 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a, |
190 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a:visited{ |
| 189 | +body.rtl .wikiEditor-ui-toolbar .tabs span.tab a, |
| 190 | +body.rtl .wikiEditor-ui-toolbar .tabs span.tab a:visited{ |
191 | 191 | padding-left:12px; |
192 | 192 | padding-right:18px; |
193 | 193 | background-image:url(../images/wikiEditor/toolbar/arrow-left.png); |
194 | 194 | background-position:right center; |
195 | 195 | } |
196 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > span.tab > a, |
197 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs > pan.tab > a:visited{ |
| 196 | +body.rtl .wikiEditor-ui-toolbar .tabs > span.tab > a, |
| 197 | +body.rtl .wikiEditor-ui-toolbar .tabs > pan.tab > a:visited{ |
198 | 198 | float:right; |
199 | 199 | } |
200 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current, |
201 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:visited{ |
| 200 | +.wikiEditor-ui-toolbar .tabs span.tab a.current, |
| 201 | +.wikiEditor-ui-toolbar .tabs span.tab a.current:visited{ |
202 | 202 | color:#333333; |
203 | 203 | background-image:url(../images/wikiEditor/toolbar/arrow-down.png); |
204 | 204 | } |
205 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current, |
206 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:visited{ |
| 205 | +body.rtl .wikiEditor-ui-toolbar .tabs span.tab a.current, |
| 206 | +body.rtl .wikiEditor-ui-toolbar .tabs span.tab a.current:visited{ |
207 | 207 | background-image:url(../images/wikiEditor/toolbar/arrow-down.png); |
208 | 208 | } |
209 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .tabs span.tab a.current:hover{ |
| 209 | +.wikiEditor-ui-toolbar .tabs span.tab a.current:hover{ |
210 | 210 | text-decoration:none; |
211 | 211 | } |
212 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .group .label{ |
| 212 | +.wikiEditor-ui-toolbar .group .label{ |
213 | 213 | float:left; |
214 | 214 | border:0px; |
215 | 215 | height:22px; |
— | — | @@ -219,12 +219,12 @@ |
220 | 220 | color:#777777; |
221 | 221 | cursor:default; |
222 | 222 | } |
223 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > .label{ |
| 223 | +body.rtl .wikiEditor-ui-toolbar .group > .label{ |
224 | 224 | float:right; |
225 | 225 | margin-left:8px; |
226 | 226 | margin-right:5px; |
227 | 227 | } |
228 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .group img.tool{ |
| 228 | +.wikiEditor-ui-toolbar .group img.tool{ |
229 | 229 | float:left; |
230 | 230 | border:0px; |
231 | 231 | height:22px; |
— | — | @@ -232,86 +232,86 @@ |
233 | 233 | padding:2px; |
234 | 234 | cursor:pointer; |
235 | 235 | } |
236 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > img.tool{ |
| 236 | +body.rtl .wikiEditor-ui-toolbar .group > img.tool{ |
237 | 237 | float:right; |
238 | 238 | } |
239 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .group select{ |
| 239 | +.wikiEditor-ui-toolbar .group select{ |
240 | 240 | float:left; |
241 | 241 | margin:2px; |
242 | 242 | height:22px; |
243 | 243 | cursor:pointer; |
244 | 244 | } |
245 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .group > select{ |
| 245 | +body.rtl .wikiEditor-ui-toolbar .group > select{ |
246 | 246 | float:right; |
247 | 247 | font-size:0.9em; |
248 | 248 | } |
249 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index{ |
| 249 | +.wikiEditor-ui-toolbar .booklet .index{ |
250 | 250 | float:left; |
251 | 251 | width:20%; |
252 | 252 | height:125px; |
253 | 253 | overflow:auto; |
254 | 254 | } |
255 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index{ |
| 255 | +body.rtl .wikiEditor-ui-toolbar .booklet .index{ |
256 | 256 | float:right; |
257 | 257 | } |
258 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index div{ |
| 258 | +.wikiEditor-ui-toolbar .booklet .index div{ |
259 | 259 | padding:4px; |
260 | 260 | padding-left:6px; |
261 | 261 | cursor:pointer; |
262 | 262 | color:#0645ad; |
263 | 263 | } |
264 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index div{ |
| 264 | +body.rtl .wikiEditor-ui-toolbar .booklet .index div{ |
265 | 265 | padding-left:4px; |
266 | 266 | padding-right:6px; |
267 | 267 | } |
268 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .index .current{ |
| 268 | +.wikiEditor-ui-toolbar .booklet .index .current{ |
269 | 269 | background-color:#FAFAFA; |
270 | 270 | color:#333333; |
271 | 271 | cursor:default; |
272 | 272 | } |
273 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .booklet .pages{ |
| 273 | +.wikiEditor-ui-toolbar .booklet .pages{ |
274 | 274 | float:right; |
275 | 275 | width:80%; |
276 | 276 | height:125px; |
277 | 277 | overflow:auto; |
278 | 278 | background-color:#FAFAFA; |
279 | 279 | } |
280 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .booklet .pages{ |
| 280 | +body.rtl .wikiEditor-ui-toolbar .booklet .pages{ |
281 | 281 | float:left; |
282 | 282 | } |
283 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table{ |
| 283 | +.wikiEditor-ui-toolbar .page-table table{ |
284 | 284 | padding-left:5px; |
285 | 285 | padding-right:5px; |
286 | 286 | background:none; |
287 | 287 | } |
288 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th{ |
| 288 | +.wikiEditor-ui-toolbar .page-table th{ |
289 | 289 | color:#999999; |
290 | 290 | } |
291 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td{ |
| 291 | +.wikiEditor-ui-toolbar .page-table td{ |
292 | 292 | color:black; |
293 | 293 | border-top:solid 1px #EEEEEE; |
294 | 294 | } |
295 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th, |
296 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td{ |
| 295 | +.wikiEditor-ui-toolbar .page-table th, |
| 296 | +.wikiEditor-ui-toolbar .page-table td{ |
297 | 297 | text-align:left; |
298 | 298 | padding:5px; |
299 | 299 | margin:0px; |
300 | 300 | } |
301 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table th, |
302 | | -body.rtl .wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td{ |
| 301 | +body.rtl .wikiEditor-ui-toolbar .page-table th, |
| 302 | +body.rtl .wikiEditor-ui-toolbar .page-table td{ |
303 | 303 | text-align:right; |
304 | 304 | } |
305 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.syntax{ |
| 305 | +.wikiEditor-ui-toolbar .section-help .page-table td.syntax{ |
306 | 306 | font-family:monospace; |
307 | 307 | } |
308 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.syntax, |
309 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.result{ |
| 308 | +.wikiEditor-ui-toolbar .section-help .page-table td.syntax, |
| 309 | +.wikiEditor-ui-toolbar .section-help .page-table td.result{ |
310 | 310 | width:40%; |
311 | 311 | } |
312 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-help .page-table table td.description{ |
| 312 | +.wikiEditor-ui-toolbar .section-help .page-table td.description{ |
313 | 313 | width:20%; |
314 | 314 | } |
315 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div a{ |
| 315 | +.wikiEditor-ui-toolbar .page-characters div a{ |
316 | 316 | border:solid 1px #DDDDDD; |
317 | 317 | padding:5px; |
318 | 318 | padding-left:8px; |
— | — | @@ -324,15 +324,15 @@ |
325 | 325 | color:black; |
326 | 326 | text-decoration:none; |
327 | 327 | } |
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[dir=rtl] a{ |
| 328 | +body.rtl .wikiEditor-ui-toolbar .page-characters > div > a, |
| 329 | +.wikiEditor-ui-toolbar .page-characters div[dir=rtl] a{ |
330 | 330 | direction:rtl; |
331 | 331 | float:right; |
332 | 332 | margin-left:0; |
333 | 333 | margin-right:5px; |
334 | 334 | } |
335 | | -.wikiEditor-ui .wikiEditor-ui-toolbar .section-characters .page-characters div a:hover{ |
| 335 | +.wikiEditor-ui-toolbar .page-characters div a:hover{ |
336 | 336 | background-color:white; |
337 | 337 | text-decoration:none; |
338 | 338 | border-color:#a8d7f9; |
339 | | -} |
| 339 | +} |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js |
— | — | @@ -2,18 +2,6 @@ |
3 | 3 | * These plugins provide extra functionality for interaction with textareas. |
4 | 4 | */ |
5 | 5 | ( function( $ ) { $.fn.extend( { |
6 | | -/** |
7 | | - * Ported from skins/common/edit.js by Trevor Parscal |
8 | | - * (c) 2009 Wikimedia Foundation (GPLv2) - http://www.wikimedia.org |
9 | | - * |
10 | | - * Inserts text at the begining and end of a text selection, optionally |
11 | | - * inserting text at the caret when selection is empty. |
12 | | - * |
13 | | - * @param pre Text to insert before selection |
14 | | - * @param peri Text to insert at caret if selection is empty |
15 | | - * @param post Text to insert after selection |
16 | | - * @param ownline If true, put the inserted text is on its own line |
17 | | - */ |
18 | 6 | |
19 | 7 | getSelection: function() { |
20 | 8 | var e = this.jquery ? this[0] : this; |
— | — | @@ -28,8 +16,22 @@ |
29 | 17 | } |
30 | 18 | return retval; |
31 | 19 | }, |
| 20 | + |
| 21 | +/** |
| 22 | + * Ported from skins/common/edit.js by Trevor Parscal |
| 23 | + * (c) 2009 Wikimedia Foundation (GPLv2) - http://www.wikimedia.org |
| 24 | + * |
| 25 | + * Inserts text at the begining and end of a text selection, optionally |
| 26 | + * inserting text at the caret when selection is empty. |
| 27 | + * |
| 28 | + * @param pre Text to insert before selection |
| 29 | + * @param peri Text to insert at caret if selection is empty |
| 30 | + * @param post Text to insert after selection |
| 31 | + * @param ownline If true, put the inserted text is on its own line |
| 32 | + * @param replace If true, replaces any selected text with peri; if false, peri is ignored and selected text is left alone |
| 33 | + */ |
32 | 34 | |
33 | | -encapsulateSelection: function( pre, peri, post, ownline ) { |
| 35 | +encapsulateSelection: function( pre, peri, post, ownline, replace ) { |
34 | 36 | /** |
35 | 37 | * Check if the selected text is the same as the insert text |
36 | 38 | */ |
— | — | @@ -37,6 +39,8 @@ |
38 | 40 | if ( !selText ) { |
39 | 41 | selText = peri; |
40 | 42 | isSample = true; |
| 43 | + } else if ( replace ) { |
| 44 | + selText = peri; |
41 | 45 | } else if ( selText.charAt( selText.length - 1 ) == ' ' ) { |
42 | 46 | // Exclude ending space char |
43 | 47 | selText = selText.substring(0, selText.length - 1); |
— | — | @@ -111,7 +115,7 @@ |
112 | 116 | } |
113 | 117 | e.scrollTop = textScroll; |
114 | 118 | } |
115 | | - $(this).trigger( 'encapsulateSelection', [ pre, peri, post, ownline ] ); |
| 119 | + $(this).trigger( 'encapsulateSelection', [ pre, peri, post, ownline, replace ] ); |
116 | 120 | }, |
117 | 121 | /** |
118 | 122 | * Ported from Wikia's LinkSuggest extension |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js |
— | — | @@ -221,6 +221,7 @@ |
222 | 222 | */ |
223 | 223 | doAction: function( context, action ) { |
224 | 224 | switch ( action.type ) { |
| 225 | + case 'replace': |
225 | 226 | case 'encapsulate': |
226 | 227 | var parts = { 'pre': '', 'peri': '', 'post': '' }; |
227 | 228 | for ( part in parts ) { |
— | — | @@ -235,7 +236,8 @@ |
236 | 237 | } |
237 | 238 | context.$textarea.encapsulateSelection( |
238 | 239 | parts.pre, parts.peri, parts.post, |
239 | | - action.options.ownline |
| 240 | + action.options.ownline, |
| 241 | + action.type == 'replace' |
240 | 242 | ); |
241 | 243 | break; |
242 | 244 | case 'dialog': |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -259,18 +259,6 @@ |
260 | 260 | * These plugins provide extra functionality for interaction with textareas. |
261 | 261 | */ |
262 | 262 | ( function( $ ) { $.fn.extend( { |
263 | | -/** |
264 | | - * Ported from skins/common/edit.js by Trevor Parscal |
265 | | - * (c) 2009 Wikimedia Foundation (GPLv2) - http://www.wikimedia.org |
266 | | - * |
267 | | - * Inserts text at the begining and end of a text selection, optionally |
268 | | - * inserting text at the caret when selection is empty. |
269 | | - * |
270 | | - * @param pre Text to insert before selection |
271 | | - * @param peri Text to insert at caret if selection is empty |
272 | | - * @param post Text to insert after selection |
273 | | - * @param ownline If true, put the inserted text is on its own line |
274 | | - */ |
275 | 263 | |
276 | 264 | getSelection: function() { |
277 | 265 | var e = this.jquery ? this[0] : this; |
— | — | @@ -285,8 +273,22 @@ |
286 | 274 | } |
287 | 275 | return retval; |
288 | 276 | }, |
| 277 | + |
| 278 | +/** |
| 279 | + * Ported from skins/common/edit.js by Trevor Parscal |
| 280 | + * (c) 2009 Wikimedia Foundation (GPLv2) - http://www.wikimedia.org |
| 281 | + * |
| 282 | + * Inserts text at the begining and end of a text selection, optionally |
| 283 | + * inserting text at the caret when selection is empty. |
| 284 | + * |
| 285 | + * @param pre Text to insert before selection |
| 286 | + * @param peri Text to insert at caret if selection is empty |
| 287 | + * @param post Text to insert after selection |
| 288 | + * @param ownline If true, put the inserted text is on its own line |
| 289 | + * @param replace If true, replaces any selected text with peri; if false, peri is ignored and selected text is left alone |
| 290 | + */ |
289 | 291 | |
290 | | -encapsulateSelection: function( pre, peri, post, ownline ) { |
| 292 | +encapsulateSelection: function( pre, peri, post, ownline, replace ) { |
291 | 293 | /** |
292 | 294 | * Check if the selected text is the same as the insert text |
293 | 295 | */ |
— | — | @@ -294,6 +296,8 @@ |
295 | 297 | if ( !selText ) { |
296 | 298 | selText = peri; |
297 | 299 | isSample = true; |
| 300 | + } else if ( replace ) { |
| 301 | + selText = peri; |
298 | 302 | } else if ( selText.charAt( selText.length - 1 ) == ' ' ) { |
299 | 303 | // Exclude ending space char |
300 | 304 | selText = selText.substring(0, selText.length - 1); |
— | — | @@ -368,7 +372,7 @@ |
369 | 373 | } |
370 | 374 | e.scrollTop = textScroll; |
371 | 375 | } |
372 | | - $(this).trigger( 'encapsulateSelection', [ pre, peri, post, ownline ] ); |
| 376 | + $(this).trigger( 'encapsulateSelection', [ pre, peri, post, ownline, replace ] ); |
373 | 377 | }, |
374 | 378 | /** |
375 | 379 | * Ported from Wikia's LinkSuggest extension |
— | — | @@ -663,16 +667,16 @@ |
664 | 668 | } |
665 | 669 | } |
666 | 670 | } |
667 | | -// Each browser seems to do this differently, so let's keep our editor |
668 | | -// consistent by allways starting at the begining |
669 | | -context.$textarea.scrollToCaretPosition( 0 ); |
670 | 671 | // If there was a configuration passed, it's assumed to be for the addModule |
671 | 672 | // API call, so we can just send it on it's way right now |
672 | 673 | if ( arguments.length > 0 && typeof arguments[0] == 'object' ) { |
673 | 674 | context.api.addModule( context, arguments[0] ); |
674 | 675 | } |
| 676 | +//Each browser seems to do this differently, so let's keep our editor |
| 677 | +//consistent by always starting at the begining |
| 678 | +context.$textarea.scrollToCaretPosition( 0 ); |
675 | 679 | // Store the context for next time, and support chaining |
676 | | -return $(this).data( 'context', context );; |
| 680 | +return $(this).data( 'context', context ); |
677 | 681 | |
678 | 682 | };})(jQuery);/** |
679 | 683 | * TOC Module for wikiEditor |
— | — | @@ -917,11 +921,134 @@ |
918 | 922 | */ |
919 | 923 | api: { |
920 | 924 | addToToolbar: function( context, data ) { |
921 | | - // |
| 925 | + for ( type in data ) { |
| 926 | + switch ( type ) { |
| 927 | + case 'sections': |
| 928 | + var $sections = |
| 929 | + context.modules.$toolbar.find( 'div.sections' ); |
| 930 | + var $tabs = context.modules.$toolbar.find( 'div.tabs' ); |
| 931 | + for ( section in data[type] ) { |
| 932 | + if ( section == 'main' ) { |
| 933 | + // Section |
| 934 | + context.modules.$toolbar.prepend( |
| 935 | + $.wikiEditor.modules.toolbar.fn.buildSection( |
| 936 | + context, section, data[type][section] |
| 937 | + ) |
| 938 | + ); |
| 939 | + continue; |
| 940 | + } |
| 941 | + // Section |
| 942 | + $sections.append( |
| 943 | + $.wikiEditor.modules.toolbar.fn.buildSection( |
| 944 | + context, section, data[type][section] |
| 945 | + ) |
| 946 | + ); |
| 947 | + // Tab |
| 948 | + $tabs.append( |
| 949 | + $.wikiEditor.modules.toolbar.fn.buildTab( |
| 950 | + context, section, data[type][section] |
| 951 | + ) |
| 952 | + ); |
| 953 | + } |
| 954 | + break; |
| 955 | + case 'groups': |
| 956 | + if ( !( 'section' in data ) ) { |
| 957 | + continue; |
| 958 | + } |
| 959 | + var $section = context.modules.$toolbar.find( |
| 960 | + 'div[rel=' + data.section + '].section' |
| 961 | + ); |
| 962 | + for ( group in data[type] ) { |
| 963 | + // Group |
| 964 | + $section.append( |
| 965 | + $.wikiEditor.modules.toolbar.fn.buildGroup( |
| 966 | + context, group, data[type][group] |
| 967 | + ) |
| 968 | + ); |
| 969 | + } |
| 970 | + break; |
| 971 | + case 'tools': |
| 972 | + if ( !( 'section' in data && 'group' in data ) ) { |
| 973 | + continue; |
| 974 | + } |
| 975 | + var $group = context.modules.$toolbar.find( |
| 976 | + 'div[rel=' + data.section + '].section ' + |
| 977 | + 'div[rel=' + data.group + '].group' |
| 978 | + ); |
| 979 | + for ( tool in data[type] ) { |
| 980 | + // Tool |
| 981 | + $group.append( |
| 982 | + $.wikiEditor.modules.toolbar.fn.buildTool( |
| 983 | + context, tool, data[type][tool] |
| 984 | + ) |
| 985 | + ); |
| 986 | + } |
| 987 | + break; |
| 988 | + case 'pages': |
| 989 | + if ( !( 'section' in data ) ) { |
| 990 | + continue; |
| 991 | + } |
| 992 | + var $pages = context.modules.$toolbar.find( |
| 993 | + 'div[rel=' + data.section + '].section .pages' |
| 994 | + ); |
| 995 | + var $index = context.modules.$toolbar.find( |
| 996 | + 'div[rel=' + data.section + '].section .index' |
| 997 | + ); |
| 998 | + for ( page in data[type] ) { |
| 999 | + // Page |
| 1000 | + $pages.append( |
| 1001 | + $.wikiEditor.modules.toolbar.fn.buildPage( |
| 1002 | + context, page, data[type][page] |
| 1003 | + ) |
| 1004 | + ); |
| 1005 | + // Index |
| 1006 | + $index.append( |
| 1007 | + $.wikiEditor.modules.toolbar.fn.buildBookmark( |
| 1008 | + context, page, data[type][page] |
| 1009 | + ) |
| 1010 | + ); |
| 1011 | + } |
| 1012 | + $.wikiEditor.modules.toolbar.fn.updateBookletSelection( |
| 1013 | + context, page, $pages, $index |
| 1014 | + ); |
| 1015 | + break; |
| 1016 | + case 'rows': |
| 1017 | + if ( !( 'section' in data && 'page' in data ) ) { |
| 1018 | + continue; |
| 1019 | + } |
| 1020 | + var $table = context.modules.$toolbar.find( |
| 1021 | + 'div[rel=' + data.section + '].section ' + |
| 1022 | + 'div[rel=' + data.page + '].page table' |
| 1023 | + ) |
| 1024 | + for ( row in data[type] ) { |
| 1025 | + // Row |
| 1026 | + $table.append( |
| 1027 | + $.wikiEditor.modules.toolbar.fn.buildRow( |
| 1028 | + context, data[type][row] |
| 1029 | + ) |
| 1030 | + ); |
| 1031 | + } |
| 1032 | + break; |
| 1033 | + case 'characters': |
| 1034 | + if ( !( 'section' in data && 'page' in data ) ) { |
| 1035 | + continue; |
| 1036 | + } |
| 1037 | + $characters = context.modules.$toolbar.find( |
| 1038 | + 'div[rel=' + data.section + '].section ' + |
| 1039 | + 'div[rel=' + data.page + '].page div' |
| 1040 | + ); |
| 1041 | + for ( character in data[type] ) { |
| 1042 | + // Character |
| 1043 | + $characters.append( |
| 1044 | + $.wikiEditor.modules.toolbar.fn.buildCharacter( |
| 1045 | + context, data[type][character] |
| 1046 | + ) |
| 1047 | + ); |
| 1048 | + } |
| 1049 | + break; |
| 1050 | + } |
| 1051 | + } |
922 | 1052 | }, |
923 | | - modifyToolbar: function( context, data ) { |
924 | | - // |
925 | | - }, |
926 | 1053 | removeFromToolbar: function( context, data ) { |
927 | 1054 | if ( typeof data.section == 'string' ) { |
928 | 1055 | // Section |
— | — | @@ -947,6 +1074,12 @@ |
948 | 1075 | } else { |
949 | 1076 | // Just a page, remove the index too! |
950 | 1077 | context.modules.$toolbar.find( index ).remove(); |
| 1078 | + $.wikiEditor.modules.toolbar.fn.updateBookletSelection( |
| 1079 | + context, |
| 1080 | + null, |
| 1081 | + context.modules.$toolbar.find( target ), |
| 1082 | + context.modules.$toolbar.find( index ) |
| 1083 | + ); |
951 | 1084 | } |
952 | 1085 | } else { |
953 | 1086 | // Just a section, remove the tab too! |
— | — | @@ -995,6 +1128,7 @@ |
996 | 1129 | */ |
997 | 1130 | doAction: function( context, action ) { |
998 | 1131 | switch ( action.type ) { |
| 1132 | + case 'replace': |
999 | 1133 | case 'encapsulate': |
1000 | 1134 | var parts = { 'pre': '', 'peri': '', 'post': '' }; |
1001 | 1135 | for ( part in parts ) { |
— | — | @@ -1009,7 +1143,8 @@ |
1010 | 1144 | } |
1011 | 1145 | context.$textarea.encapsulateSelection( |
1012 | 1146 | parts.pre, parts.peri, parts.post, |
1013 | | - action.options.ownline |
| 1147 | + action.options.ownline, |
| 1148 | + action.type == 'replace' |
1014 | 1149 | ); |
1015 | 1150 | break; |
1016 | 1151 | case 'dialog': |
— | — | @@ -1043,35 +1178,6 @@ |
1044 | 1179 | default: break; |
1045 | 1180 | } |
1046 | 1181 | }, |
1047 | | - buildSection: function( context, id, section ) { |
1048 | | - switch ( section.type ) { |
1049 | | - case 'toolbar': |
1050 | | - return $.wikiEditor.modules.toolbar.fn.buildToolbar( |
1051 | | - context, id, section |
1052 | | - ); |
1053 | | - case 'booklet': |
1054 | | - return $.wikiEditor.modules.toolbar.fn.buildBooklet( |
1055 | | - context, id, section |
1056 | | - ); |
1057 | | - default: return null; |
1058 | | - } |
1059 | | - }, |
1060 | | - buildToolbar: function( context, id, toolbar ) { |
1061 | | - var $toolbar = $( '<div></div>' ).attr( { |
1062 | | - 'class': 'toolbar section section-' + id, |
1063 | | - 'rel': id |
1064 | | - } ); |
1065 | | - if ( 'groups' in toolbar ) { |
1066 | | - for ( group in toolbar.groups ) { |
1067 | | - $toolbar.append( |
1068 | | - $.wikiEditor.modules.toolbar.fn.buildGroup( |
1069 | | - context, group, toolbar.groups[group] |
1070 | | - ) |
1071 | | - ); |
1072 | | - } |
1073 | | - } |
1074 | | - return $toolbar; |
1075 | | - }, |
1076 | 1182 | buildGroup: function( context, id, group ) { |
1077 | 1183 | var $group = $( '<div></div>' ).attr( { |
1078 | 1184 | 'class': 'group group-' + id, |
— | — | @@ -1105,8 +1211,15 @@ |
1106 | 1212 | var label = $.wikiEditor.modules.toolbar.fn.autoMsg( tool, 'label' ); |
1107 | 1213 | switch ( tool.type ) { |
1108 | 1214 | case 'button': |
| 1215 | + var src = tool.icon; |
| 1216 | + if ( |
| 1217 | + src.indexOf( 'http://' ) !== 0 && |
| 1218 | + src.indexOf( 'https://' ) !== 0 |
| 1219 | + ) { |
| 1220 | + src = $.wikiEditor.modules.toolbar.imgPath + src; |
| 1221 | + } |
1109 | 1222 | $button = $( '<img />' ).attr( { |
1110 | | - 'src': $.wikiEditor.modules.toolbar.imgPath + tool.icon, |
| 1223 | + 'src': src, |
1111 | 1224 | 'width': 22, |
1112 | 1225 | 'height': 22, |
1113 | 1226 | 'alt': label, |
— | — | @@ -1166,42 +1279,6 @@ |
1167 | 1280 | default: return null; |
1168 | 1281 | } |
1169 | 1282 | }, |
1170 | | - buildBooklet: function( context, id, booklet ) { |
1171 | | - var selected = $.cookie( |
1172 | | - 'wikiEditor-' + context.instance + '-booklet-' + id + '-page' |
1173 | | - ); |
1174 | | - var $booklet = $( '<div></div>' ).attr( { |
1175 | | - 'class': 'booklet section section-' + id, |
1176 | | - 'rel': id |
1177 | | - } ); |
1178 | | - var $pages = $( '<div></div>' ).attr( 'class', 'pages' ); |
1179 | | - var $index = $( '<div></div>' ).attr( 'class', 'index' ); |
1180 | | - if ( 'pages' in booklet ) { |
1181 | | - if ( !( selected in booklet.pages ) ) { |
1182 | | - selected = null; |
1183 | | - } |
1184 | | - for ( page in booklet.pages ) { |
1185 | | - if ( selected === null ) { |
1186 | | - selected = page; |
1187 | | - } |
1188 | | - var $page = $.wikiEditor.modules.toolbar.fn.buildPage( |
1189 | | - context, page, booklet.pages[page] |
1190 | | - ); |
1191 | | - var $bookmark = $.wikiEditor.modules.toolbar.fn.buildBookmark( |
1192 | | - context, page, booklet.pages[page] |
1193 | | - ); |
1194 | | - if ( selected == page ) { |
1195 | | - $page.show(); |
1196 | | - $bookmark.addClass( 'current' ); |
1197 | | - } else { |
1198 | | - $page.hide(); |
1199 | | - } |
1200 | | - $pages.append( $page ); |
1201 | | - $index.append( $bookmark ); |
1202 | | - } |
1203 | | - } |
1204 | | - return $booklet.append( $index ).append( $pages ); |
1205 | | - }, |
1206 | 1283 | buildBookmark: function( context, id, page ) { |
1207 | 1284 | var label = $.wikiEditor.modules.toolbar.fn.autoMsg( page, 'label' ); |
1208 | 1285 | return $( '<div></div>' ) |
— | — | @@ -1245,36 +1322,19 @@ |
1246 | 1323 | 'class': 'table table-' + id |
1247 | 1324 | } ); |
1248 | 1325 | if ( 'headings' in page ) { |
1249 | | - var $headings = $( '<tr></tr>' ); |
1250 | | - for ( heading in page.headings ) { |
1251 | | - var content = |
1252 | | - $.wikiEditor.modules.toolbar.fn.autoMsg( |
1253 | | - page.headings[heading], 'content' |
1254 | | - ); |
1255 | | - $headings.append( |
1256 | | - $( '<th></th>' ).text( content ) |
1257 | | - ); |
1258 | | - } |
1259 | | - $table.append( $headings ); |
| 1326 | + $table.append( |
| 1327 | + $.wikiEditor.modules.toolbar.fn.buildHeading( |
| 1328 | + context, page.headings |
| 1329 | + ) |
| 1330 | + ); |
1260 | 1331 | } |
1261 | 1332 | if ( 'rows' in page ) { |
1262 | 1333 | for ( row in page.rows ) { |
1263 | | - var $row = $( '<tr></tr>' ); |
1264 | | - for ( cell in page.rows[row] ) { |
1265 | | - var $cell = $( '<td></td>' ).attr( { |
1266 | | - 'class': 'cell cell-' + cell, |
1267 | | - 'valign': 'top' |
1268 | | - } ); |
1269 | | - var content = |
1270 | | - $.wikiEditor.modules.toolbar.fn.autoMsg( |
1271 | | - page.rows[row][cell], 'content' |
1272 | | - ); |
1273 | | - $cell.append( |
1274 | | - $( '<span></span>' ).html( content ) |
1275 | | - ); |
1276 | | - $row.append( $cell ); |
1277 | | - } |
1278 | | - $table.append( $row ); |
| 1334 | + $table.append( |
| 1335 | + $.wikiEditor.modules.toolbar.fn.buildRow( |
| 1336 | + context, page.rows[row] |
| 1337 | + ) |
| 1338 | + ); |
1279 | 1339 | } |
1280 | 1340 | } |
1281 | 1341 | $page.append( $table ); |
— | — | @@ -1290,47 +1350,198 @@ |
1291 | 1351 | } |
1292 | 1352 | if ( 'characters' in page ) { |
1293 | 1353 | for ( character in page.characters ) { |
1294 | | - var tool = page.characters[character]; |
1295 | | - if ( typeof tool == 'string' ) { |
1296 | | - tool = { |
1297 | | - 'label': tool, |
1298 | | - 'action': { |
1299 | | - 'type': 'encapsulate', |
1300 | | - 'options': { 'pre': tool } |
1301 | | - } |
1302 | | - }; |
1303 | | - } else if ( 0 in tool && 1 in tool ) { |
1304 | | - tool = { |
1305 | | - 'label': tool[0], |
1306 | | - 'action': { |
1307 | | - 'type': 'encapsulate', |
1308 | | - 'options': { 'pre': tool[1] } |
1309 | | - } |
1310 | | - }; |
1311 | | - } |
1312 | | - if ( 'action' in tool && 'label' in tool ) { |
1313 | | - var $character = $( '<a></a>' ) |
1314 | | - .attr( 'rel', tool.label ) |
1315 | | - .attr( 'href', '#' ) |
1316 | | - .text( tool.label ) |
1317 | | - .data( 'context', context ) |
1318 | | - .data( 'action', tool.action ) |
1319 | | - .click( function() { |
1320 | | - $.wikiEditor.modules.toolbar.fn.doAction( |
1321 | | - $(this).data( 'context' ), |
1322 | | - $(this).data( 'action' ) |
1323 | | - ); |
1324 | | - return false; |
1325 | | - } ); |
1326 | | - $characters.append( $character ); |
1327 | | - } |
| 1354 | + $characters.append( |
| 1355 | + $.wikiEditor.modules.toolbar.fn.buildCharacter( |
| 1356 | + context, page.characters[character] |
| 1357 | + ) |
| 1358 | + ); |
1328 | 1359 | } |
1329 | | - $page.append( $characters ); |
1330 | 1360 | } |
| 1361 | + $page.append( $characters ); |
1331 | 1362 | break; |
1332 | 1363 | } |
1333 | 1364 | return $page; |
1334 | 1365 | }, |
| 1366 | + buildHeading: function( context, headings ) { |
| 1367 | + var $headings = $( '<tr></tr>' ); |
| 1368 | + for ( heading in headings ) { |
| 1369 | + $headings.append( |
| 1370 | + $( '<th></th>' ).text( |
| 1371 | + $.wikiEditor.modules.toolbar.fn.autoMsg( |
| 1372 | + headings[heading], 'content' |
| 1373 | + ) |
| 1374 | + ) |
| 1375 | + ); |
| 1376 | + } |
| 1377 | + return $headings; |
| 1378 | + }, |
| 1379 | + buildRow: function( context, row ) { |
| 1380 | + var $row = $( '<tr></tr>' ); |
| 1381 | + for ( cell in row ) { |
| 1382 | + $row.append( |
| 1383 | + $( '<td></td>' ) |
| 1384 | + .attr( { |
| 1385 | + 'class': 'cell cell-' + cell, |
| 1386 | + 'valign': 'top' |
| 1387 | + } ) |
| 1388 | + .append( |
| 1389 | + $( '<span></span>' ).html( |
| 1390 | + $.wikiEditor.modules.toolbar.fn.autoMsg( |
| 1391 | + row[cell], 'content' |
| 1392 | + ) |
| 1393 | + ) |
| 1394 | + ) |
| 1395 | + ); |
| 1396 | + } |
| 1397 | + return $row; |
| 1398 | + }, |
| 1399 | + buildCharacter: function( context, character ) { |
| 1400 | + if ( typeof character == 'string' ) { |
| 1401 | + character = { |
| 1402 | + 'label': character, |
| 1403 | + 'action': { |
| 1404 | + 'type': 'encapsulate', |
| 1405 | + 'options': { 'pre': character } |
| 1406 | + } |
| 1407 | + }; |
| 1408 | + } else if ( 0 in character && 1 in character ) { |
| 1409 | + character = { |
| 1410 | + 'label': character[0], |
| 1411 | + 'action': { |
| 1412 | + 'type': 'encapsulate', |
| 1413 | + 'options': { 'pre': character[1] } |
| 1414 | + } |
| 1415 | + }; |
| 1416 | + } |
| 1417 | + if ( 'action' in character && 'label' in character ) { |
| 1418 | + return $( '<a></a>' ) |
| 1419 | + .attr( 'rel', character.label ) |
| 1420 | + .attr( 'href', '#' ) |
| 1421 | + .text( character.label ) |
| 1422 | + .data( 'context', context ) |
| 1423 | + .data( 'action', character.action ) |
| 1424 | + .click( function() { |
| 1425 | + $.wikiEditor.modules.toolbar.fn.doAction( |
| 1426 | + $(this).data( 'context' ), |
| 1427 | + $(this).data( 'action' ) |
| 1428 | + ); |
| 1429 | + return false; |
| 1430 | + } ); |
| 1431 | + } |
| 1432 | + }, |
| 1433 | + buildTab: function( context, id, section ) { |
| 1434 | + var selected = $.cookie( |
| 1435 | + 'wikiEditor-' + context.instance + '-toolbar-section' |
| 1436 | + ); |
| 1437 | + return $( '<span></span>' ) |
| 1438 | + .attr( { |
| 1439 | + 'class': 'tab tab-' + id, |
| 1440 | + 'rel': id |
| 1441 | + } ) |
| 1442 | + .append( |
| 1443 | + $( '<a></a>' ) |
| 1444 | + .addClass( selected == id ? 'current' : null ) |
| 1445 | + .attr( 'href', '#' ) |
| 1446 | + .text( |
| 1447 | + $.wikiEditor.modules.toolbar.fn.autoMsg( section, 'label' ) |
| 1448 | + ) |
| 1449 | + .data( 'context', context ) |
| 1450 | + .click( function() { |
| 1451 | + var $section = |
| 1452 | + $(this).data( 'context' ).$ui.find( |
| 1453 | + '.section-' + $(this).parent().attr( 'rel' ) |
| 1454 | + ); |
| 1455 | + $(this).blur(); |
| 1456 | + var show = $section.css( 'display' ) == 'none'; |
| 1457 | + $section.parent().children().hide(); |
| 1458 | + $(this) |
| 1459 | + .parent() |
| 1460 | + .parent() |
| 1461 | + .find( 'a' ) |
| 1462 | + .removeClass( 'current' ); |
| 1463 | + if ( show ) { |
| 1464 | + $section.show(); |
| 1465 | + $(this).addClass( 'current' ); |
| 1466 | + } |
| 1467 | + $.cookie( |
| 1468 | + 'wikiEditor-' + |
| 1469 | + $(this).data( 'context' ).instance + |
| 1470 | + '-toolbar-section', |
| 1471 | + show ? $section.attr( 'rel' ) : null |
| 1472 | + ); |
| 1473 | + return false; |
| 1474 | + } ) |
| 1475 | + ); |
| 1476 | + }, |
| 1477 | + buildSection: function( context, id, section ) { |
| 1478 | + var selected = $.cookie( |
| 1479 | + 'wikiEditor-' + context.instance + '-toolbar-section' |
| 1480 | + ); |
| 1481 | + var $section; |
| 1482 | + switch ( section.type ) { |
| 1483 | + case 'toolbar': |
| 1484 | + var $section = $( '<div></div>' ).attr( { |
| 1485 | + 'class': 'toolbar section section-' + id, |
| 1486 | + 'rel': id |
| 1487 | + } ); |
| 1488 | + if ( 'groups' in section ) { |
| 1489 | + for ( group in section.groups ) { |
| 1490 | + $section.append( |
| 1491 | + $.wikiEditor.modules.toolbar.fn.buildGroup( |
| 1492 | + context, group, section.groups[group] |
| 1493 | + ) |
| 1494 | + ); |
| 1495 | + } |
| 1496 | + } |
| 1497 | + break; |
| 1498 | + case 'booklet': |
| 1499 | + var $pages = $( '<div></div>' ).attr( 'class', 'pages' ); |
| 1500 | + var $index = $( '<div></div>' ).attr( 'class', 'index' ); |
| 1501 | + if ( 'pages' in section ) { |
| 1502 | + |
| 1503 | + for ( page in section.pages ) { |
| 1504 | + $pages.append( |
| 1505 | + $.wikiEditor.modules.toolbar.fn.buildPage( |
| 1506 | + context, page, section.pages[page] |
| 1507 | + ) |
| 1508 | + ); |
| 1509 | + $index.append( |
| 1510 | + $.wikiEditor.modules.toolbar.fn.buildBookmark( |
| 1511 | + context, page, section.pages[page] |
| 1512 | + ) |
| 1513 | + ); |
| 1514 | + } |
| 1515 | + } |
| 1516 | + $section = $( '<div></div>' ) |
| 1517 | + .attr( { |
| 1518 | + 'class': 'booklet section section-' + id, |
| 1519 | + 'rel': id |
| 1520 | + } ) |
| 1521 | + .append( $index ) |
| 1522 | + .append( $pages ); |
| 1523 | + $.wikiEditor.modules.toolbar.fn.updateBookletSelection( |
| 1524 | + context, page, $pages, $index |
| 1525 | + ); |
| 1526 | + break; |
| 1527 | + } |
| 1528 | + if ( $section !== null && id !== 'main' ) { |
| 1529 | + $section.css( 'display', selected == id ? 'block' : 'none' ); |
| 1530 | + } |
| 1531 | + return $section; |
| 1532 | + }, |
| 1533 | + updateBookletSelection: function( context, id, $pages, $index ) { |
| 1534 | + var cookie = |
| 1535 | + 'wikiEditor-' + context.instance + '-booklet-' + id + '-page'; |
| 1536 | + var selected = $.cookie( cookie ); |
| 1537 | + if ( $index.find( '*[rel=' + selected + ']' ).size() == 0 ) { |
| 1538 | + selected = $index.find( ':first' ).attr( 'rel' ); |
| 1539 | + $.cookie( cookie, selected ); |
| 1540 | + } |
| 1541 | + $pages.children().hide(); |
| 1542 | + $pages.find( '*[rel=' + selected + ']' ).show(); |
| 1543 | + $index.children().removeClass( 'current' ); |
| 1544 | + $index.find( '*[rel=' + selected + ']' ).addClass( 'current' ); |
| 1545 | + }, |
1335 | 1546 | build: function( context, config ) { |
1336 | 1547 | var $tabs = $( '<div></div>' ) |
1337 | 1548 | .addClass( 'tabs' ) |
— | — | @@ -1341,9 +1552,6 @@ |
1342 | 1553 | context.modules.$toolbar.append( |
1343 | 1554 | $( '<div></div>' ).css( 'clear', 'both' ) |
1344 | 1555 | ); |
1345 | | - var selected = $.cookie( |
1346 | | - 'wikiEditor-' + context.instance + '-toolbar-section' |
1347 | | - ); |
1348 | 1556 | var sectionQueue = []; |
1349 | 1557 | for ( section in config ) { |
1350 | 1558 | if ( section == 'main' ) { |
— | — | @@ -1353,58 +1561,16 @@ |
1354 | 1562 | ) |
1355 | 1563 | ); |
1356 | 1564 | } else { |
1357 | | - s = { |
| 1565 | + sectionQueue.push( { |
| 1566 | + '$sections': $sections, |
1358 | 1567 | 'context': context, |
1359 | | - '$sections': $sections, |
1360 | | - '$tabs': $tabs, |
1361 | | - 'section': section, |
1362 | | - 'config': config[section], |
1363 | | - 'selected': ( selected == section ) |
1364 | | - }; |
1365 | | - sectionQueue[sectionQueue.length] = s; |
1366 | | - s.$tabs.append( |
1367 | | - $( '<span></span>' ) |
1368 | | - .attr( { |
1369 | | - 'class': 'tab tab-' + s.section, |
1370 | | - 'rel': s.section |
1371 | | - } ) |
1372 | | - .append( |
1373 | | - $( '<a></a>' ) |
1374 | | - .addClass( s.selected ? 'current' : null ) |
1375 | | - .attr( 'href', '#' ) |
1376 | | - .text( |
1377 | | - $.wikiEditor.modules.toolbar.fn.autoMsg( |
1378 | | - s.config, 'label' |
1379 | | - ) |
1380 | | - ) |
1381 | | - .data( 'context', s.context ) |
1382 | | - .click( function() { |
1383 | | - var $section = |
1384 | | - $(this).data( 'context' ).$ui.find( |
1385 | | - '.section-' + |
1386 | | - $(this).parent().attr( 'rel' ) |
1387 | | - ); |
1388 | | - $(this).blur(); |
1389 | | - var show = $section.css( 'display' ) == 'none'; |
1390 | | - $section.parent().children().hide(); |
1391 | | - $(this) |
1392 | | - .parent() |
1393 | | - .parent() |
1394 | | - .find( 'a' ) |
1395 | | - .removeClass( 'current' ); |
1396 | | - if ( show ) { |
1397 | | - $section.show(); |
1398 | | - $(this).addClass( 'current' ); |
1399 | | - } |
1400 | | - $.cookie( |
1401 | | - 'wikiEditor-' + |
1402 | | - $(this).data( 'context' ).instance + |
1403 | | - '-toolbar-section', |
1404 | | - show ? $section.attr( 'rel' ) : null |
1405 | | - ); |
1406 | | - return false; |
1407 | | - } ) |
1408 | | - ) |
| 1568 | + 'id': section, |
| 1569 | + 'config': config[section] |
| 1570 | + } ); |
| 1571 | + $tabs.append( |
| 1572 | + $.wikiEditor.modules.toolbar.fn.buildTab( |
| 1573 | + context, section, config[section] |
| 1574 | + ) |
1409 | 1575 | ); |
1410 | 1576 | } |
1411 | 1577 | } |
— | — | @@ -1419,11 +1585,9 @@ |
1420 | 1586 | 'loop': function( i, s ) { |
1421 | 1587 | s.$sections.append( |
1422 | 1588 | $.wikiEditor.modules.toolbar.fn.buildSection( |
1423 | | - s.context, s.section, s.config |
| 1589 | + s.context, s.id, s.config |
1424 | 1590 | ) |
1425 | | - .css( 'display', s.selected ? 'block' : 'none' ) |
1426 | 1591 | ); |
1427 | | - |
1428 | 1592 | } |
1429 | 1593 | } ); |
1430 | 1594 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | expires='; expires='+date.toUTCString();} |
21 | 21 | var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}} |
22 | 22 | return cookieValue;}};(function($){$.fn.extend({getSelection:function(){var e=this.jquery?this[0]:this;var retval='';if(e.style.display=='none'){}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();retval=range.text;}else if(e.selectionStart||e.selectionStart=='0'){retval=e.value.substring(e.selectionStart,e.selectionEnd);} |
23 | | -return retval;},encapsulateSelection:function(pre,peri,post,ownline){function checkSelectedText(){if(!selText){selText=peri;isSample=true;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' '}} |
| 23 | +return retval;},encapsulateSelection:function(pre,peri,post,ownline,replace){function checkSelectedText(){if(!selText){selText=peri;isSample=true;}else if(replace){selText=peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' '}} |
24 | 24 | var e=this.jquery?this[0]:this;var selText=$(this).getSelection();var isSample=false;if(e.style.display=='none'){}else if(document.selection&&document.selection.createRange){if(document.documentElement&&document.documentElement.scrollTop){var winScroll=document.documentElement.scrollTop;}else if(document.body){var winScroll=document.body.scrollTop;} |
25 | 25 | $(this).focus();var range=document.selection.createRange();if(ownline&&range.moveStart){var range2=document.selection.createRange();range2.collapse();range2.moveStart('character',-1);if(range2.text!="\r"&&range2.text!="\n"&&range3.text!="") |
26 | 26 | pre="\n"+pre;var range3=document.selection.createRange();range3.collapse(false);range3.moveEnd('character',1);if(range3.text!="\r"&&range3.text!="\n"&&range3.text!="") |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | e.value=e.value.substring(0,startPos)+pre+selText+post+ |
34 | 34 | e.value.substring(endPos,e.value.length);if(isSample){e.selectionStart=startPos+pre.length;e.selectionEnd=startPos+pre.length+selText.length;}else{e.selectionStart=startPos+pre.length+selText.length+post.length;e.selectionEnd=e.selectionStart;} |
35 | 35 | e.scrollTop=textScroll;} |
36 | | -$(this).trigger('encapsulateSelection',[pre,peri,post,ownline]);},getCaretPosition:function(){function getCaret(e){var caretPos=0;if($.browser.msie){var postFinished=false;var periFinished=false;var postFinished=false;var preText,rawPreText,periText;var rawPeriText,postText,rawPostText;var periRange=document.selection.createRange().duplicate();var preRange=document.body.createTextRange();preRange.moveToElementText(e);preRange.setEndPoint("EndToStart",periRange);var postRange=document.body.createTextRange();postRange.moveToElementText(e);postRange.setEndPoint("StartToEnd",periRange);preText=rawPreText=preRange.text;periText=rawPeriText=periRange.text;postText=rawPostText=postRange.text;do{if(!postFinished){if(preRange.compareEndPoints("StartToEnd",preRange)==0){postFinished=true;}else{preRange.moveEnd("character",-1) |
| 36 | +$(this).trigger('encapsulateSelection',[pre,peri,post,ownline,replace]);},getCaretPosition:function(){function getCaret(e){var caretPos=0;if($.browser.msie){var postFinished=false;var periFinished=false;var postFinished=false;var preText,rawPreText,periText;var rawPeriText,postText,rawPostText;var periRange=document.selection.createRange().duplicate();var preRange=document.body.createTextRange();preRange.moveToElementText(e);preRange.setEndPoint("EndToStart",periRange);var postRange=document.body.createTextRange();postRange.moveToElementText(e);postRange.setEndPoint("StartToEnd",periRange);preText=rawPreText=preRange.text;periText=rawPeriText=periRange.text;postText=rawPostText=postRange.text;do{if(!postFinished){if(preRange.compareEndPoints("StartToEnd",preRange)==0){postFinished=true;}else{preRange.moveEnd("character",-1) |
37 | 37 | if(preRange.text==preText){rawPreText+="\r\n";}else{postFinished=true;}}} |
38 | 38 | if(!periFinished){if(periRange.compareEndPoints("StartToEnd",periRange)==0){periFinished=true;}else{periRange.moveEnd("character",-1) |
39 | 39 | if(periRange.text==periText){rawPeriText+="\r\n";}else{periFinished=true;}}} |
— | — | @@ -52,8 +52,8 @@ |
53 | 53 | return $(this);} |
54 | 54 | var instance=$.wikiEditor.instances.length;context={'$textarea':$(this),'modules':{},'data':{},'instance':instance};$.wikiEditor.instances[instance]=$(this);$(this).wrap($('<div></div>').addClass('wikiEditor-ui').attr('id','wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom').attr('id','wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text').attr('id','wikiEditor-ui-text'));context.$ui=$(this).parent().parent().parent();context.$ui.after($('<div style="clear:both;"></div>'));context.$ui.prepend($('<div></div>').addClass('wikiEditor-ui-top').attr('id','wikiEditor-ui-top'));context.api={addModule:function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){$.wikiEditor.modules[module].fn[call](context,data);}} |
55 | 55 | if(typeof data=='string'){callModuleApi(data,'create',{});}else if(typeof data=='object'){for(module in data){if(typeof module=='string'){callModuleApi(module,'create',data[module]);}}}}};for(module in $.wikiEditor.modules){if('api'in $.wikiEditor.modules[module]){for(call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}}} |
56 | | -context.$textarea.scrollToCaretPosition(0);if(arguments.length>0&&typeof arguments[0]=='object'){context.api.addModule(context,arguments[0]);} |
57 | | -return $(this).data('context',context);;};})(jQuery);(function($){$.wikiEditor.modules.toc={api:{},fn:{create:function(context,config){if('$toc'in context.modules){return;} |
| 56 | +if(arguments.length>0&&typeof arguments[0]=='object'){context.api.addModule(context,arguments[0]);} |
| 57 | +context.$textarea.scrollToCaretPosition(0);return $(this).data('context',context);};})(jQuery);(function($){$.wikiEditor.modules.toc={api:{},fn:{create:function(context,config){if('$toc'in context.modules){return;} |
58 | 58 | context.modules.$toc=$('<div></div>').addClass('wikiEditor-ui-toc').attr('id','wikiEditor-ui-toc');$.wikiEditor.modules.toc.fn.build(context,config);context.$ui.find('.wikiEditor-ui-bottom').append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-bottom').height());context.modules.$toc.css('width','12em');context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);context.$textarea.bind('keyup encapsulateSelection',function(event){var context=$(this).data('context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).bind('mouseup scrollToPosition',function(event){var context=$(this).data('context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});});},update:function(context){context.modules.$toc.find('a').removeClass('currentSelection');var position=context.$textarea.getCaretPosition();var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;} |
59 | 59 | section=Math.max(0,section);} |
60 | 60 | context.modules.$toc.find('a.section-'+section).addClass('currentSelection');}},build:function(context){function buildStructure(outline,offset,level){if(offset==undefined)offset=0;if(level==undefined)level=1;var sections=[];for(var i=offset;i<outline.length;i++){if(outline[i].nLevel==level){var sub=buildStructure(outline,i+1,level+1);if(sub.length){outline[i].sections=sub;} |
— | — | @@ -69,35 +69,47 @@ |
70 | 70 | var lastLevel=0;var nLevel=0;for(var i=0;i<outline.length;i++){if(outline[i].level>lastLevel){nLevel++;} |
71 | 71 | else if(outline[i].level<lastLevel){nLevel-=Math.max(1,lastLevel-outline[i].level);} |
72 | 72 | outline[i].nLevel=nLevel;lastLevel=nLevel;} |
73 | | -var structure=buildStructure(outline);structure.unshift({'text':wgPageName.replace(/_/g,' '),'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 tab='div.tabs span[rel='+data.section+'].tab';var target='div[rel='+data.section+'].section';if(typeof data.group=='string'){target+=' div[rel='+data.group+'].group';if(typeof data.tool=='string'){target+=' div[rel='+data.tool+'].tool';}}else if(typeof data.page=='string'){var index=target+' div.index div[rel='+data.page+']';target+=' div.pages div[rel='+data.page+'].page';if(typeof data.character=='string'){target+=' a[rel='+data.character+']';}else if(typeof data.row=='number'){target+=' table tr:not(:has(th)):eq('+data.row+')';}else{context.modules.$toolbar.find(index).remove();}}else{context.modules.$toolbar.find(tab).remove();} |
| 73 | +var structure=buildStructure(outline);structure.unshift({'text':wgPageName.replace(/_/g,' '),'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){for(type in data){switch(type){case'sections':var $sections=context.modules.$toolbar.find('div.sections');var $tabs=context.modules.$toolbar.find('div.tabs');for(section in data[type]){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));continue;} |
| 74 | +$sections.append($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,data[type][section]));} |
| 75 | +break;case'groups':if(!('section'in data)){continue;} |
| 76 | +var $section=context.modules.$toolbar.find('div[rel='+data.section+'].section');for(group in data[type]){$section.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,data[type][group]));} |
| 77 | +break;case'tools':if(!('section'in data&&'group'in data)){continue;} |
| 78 | +var $group=context.modules.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.group+'].group');for(tool in data[type]){$group.append($.wikiEditor.modules.toolbar.fn.buildTool(context,tool,data[type][tool]));} |
| 79 | +break;case'pages':if(!('section'in data)){continue;} |
| 80 | +var $pages=context.modules.$toolbar.find('div[rel='+data.section+'].section .pages');var $index=context.modules.$toolbar.find('div[rel='+data.section+'].section .index');for(page in data[type]){$pages.append($.wikiEditor.modules.toolbar.fn.buildPage(context,page,data[type][page]));$index.append($.wikiEditor.modules.toolbar.fn.buildBookmark(context,page,data[type][page]));} |
| 81 | +$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,page,$pages,$index);break;case'rows':if(!('section'in data&&'page'in data)){continue;} |
| 82 | +var $table=context.modules.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page table') |
| 83 | +for(row in data[type]){$table.append($.wikiEditor.modules.toolbar.fn.buildRow(context,data[type][row]));} |
| 84 | +break;case'characters':if(!('section'in data&&'page'in data)){continue;} |
| 85 | +$characters=context.modules.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page div');for(character in data[type]){$characters.append($.wikiEditor.modules.toolbar.fn.buildCharacter(context,data[type][character]));} |
| 86 | +break;}}},removeFromToolbar:function(context,data){if(typeof data.section=='string'){var tab='div.tabs span[rel='+data.section+'].tab';var target='div[rel='+data.section+'].section';if(typeof data.group=='string'){target+=' div[rel='+data.group+'].group';if(typeof data.tool=='string'){target+=' div[rel='+data.tool+'].tool';}}else if(typeof data.page=='string'){var index=target+' div.index div[rel='+data.page+']';target+=' div.pages div[rel='+data.page+'].page';if(typeof data.character=='string'){target+=' a[rel='+data.character+']';}else if(typeof data.row=='number'){target+=' table tr:not(:has(th)):eq('+data.row+')';}else{context.modules.$toolbar.find(index).remove();$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,null,context.modules.$toolbar.find(target),context.modules.$toolbar.find(index));}}else{context.modules.$toolbar.find(tab).remove();} |
74 | 87 | context.modules.$toolbar.find(target).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;} |
75 | | -context.modules.$toolbar=$('<div></div>').addClass('wikiEditor-ui-toolbar').attr('id','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]||'')}} |
76 | | -context.$textarea.encapsulateSelection(parts.pre,parts.peri,parts.post,action.options.ownline);break;case'dialog':if($j('#'+action.id).size()==0){var dialogConf=action.dialog;dialogConf.bgiframe=true;dialogConf.autoOpen=false;dialogConf.modal=true;dialogConf.title=gM(action.titleMsg);for(msg in dialogConf.buttons){dialogConf.buttons[gM(msg)]=dialogConf.buttons[msg];delete dialogConf.buttons[msg];} |
| 88 | +context.modules.$toolbar=$('<div></div>').addClass('wikiEditor-ui-toolbar').attr('id','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'replace':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]||'')}} |
| 89 | +context.$textarea.encapsulateSelection(parts.pre,parts.peri,parts.post,action.options.ownline,action.type=='replace');break;case'dialog':if($j('#'+action.id).size()==0){var dialogConf=action.dialog;dialogConf.bgiframe=true;dialogConf.autoOpen=false;dialogConf.modal=true;dialogConf.title=gM(action.titleMsg);for(msg in dialogConf.buttons){dialogConf.buttons[gM(msg)]=dialogConf.buttons[msg];delete dialogConf.buttons[msg];} |
77 | 90 | $j('<div></div> ').attr('id',action.id).html(action.html).data('context',context).appendTo($j('body')).each(action.init).dialog(dialogConf);} |
78 | | -$j('#'+action.id).dialog('open');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]));}} |
79 | | -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'))} |
| 91 | +$j('#'+action.id).dialog('open');break;default:break;}},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'))} |
80 | 92 | if('tools'in group){for(tool in group.tools){$group.append($.wikiEditor.modules.toolbar.fn.buildTool(context,tool,group.tools[tool]));}} |
81 | 93 | return $group;},buildTool:function(context,id,tool){if('filters'in tool){for(filter in tool.filters){if($(tool.filters[filter]).size()==0){return null;}}} |
82 | | -var label=$.wikiEditor.modules.toolbar.fn.autoMsg(tool,'label');switch(tool.type){case'button':$button=$('<img />').attr({'src':$.wikiEditor.modules.toolbar.imgPath+tool.icon,'width':22,'height':22,'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;});} |
| 94 | +var label=$.wikiEditor.modules.toolbar.fn.autoMsg(tool,'label');switch(tool.type){case'button':var src=tool.icon;if(src.indexOf('http://')!==0&&src.indexOf('https://')!==0){src=$.wikiEditor.modules.toolbar.imgPath+src;} |
| 95 | +$button=$('<img />').attr({'src':src,'width':22,'height':22,'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;});} |
83 | 96 | return $button;case'select':var $select=$('<select></select>').attr({'rel':id,'class':'tool tool-'+id});$select.append($('<option></option>').text(label)) |
84 | 97 | 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);} |
85 | 98 | $(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));}} |
86 | | -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;} |
87 | | -for(page in booklet.pages){if(selected===null){selected=page;} |
88 | | -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();} |
89 | | -$pages.append($page);$index.append($bookmark);}} |
90 | | -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));} |
91 | | -$table.append($headings);} |
92 | | -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);} |
93 | | -$table.append($row);}} |
| 99 | +return $select;default:return null;}},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){$table.append($.wikiEditor.modules.toolbar.fn.buildHeading(context,page.headings));} |
| 100 | +if('rows'in page){for(row in page.rows){$table.append($.wikiEditor.modules.toolbar.fn.buildRow(context,page.rows[row]));}} |
94 | 101 | $page.append($table);break;case'characters':$page.addClass('page-characters');$characters=$('<div></div>');if('language'in page){$characters.attr('lang',page.language);} |
95 | 102 | if('direction'in page){$characters.attr('dir',page.direction);} |
96 | | -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}}};}else if(0 in tool&&1 in tool){tool={'label':tool[0],'action':{'type':'encapsulate','options':{'pre':tool[1]}}};} |
97 | | -if('action'in tool&&'label'in tool){var $character=$('<a></a>').attr('rel',tool.label).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);}} |
98 | | -$page.append($characters);} |
99 | | -break;} |
100 | | -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>').css('clear','both'));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{s={'context':context,'$sections':$sections,'$tabs':$tabs,'section':section,'config':config[section],'selected':(selected==section)};sectionQueue[sectionQueue.length]=s;s.$tabs.append($('<span></span>').attr({'class':'tab tab-'+s.section,'rel':s.section}).append($('<a></a>').addClass(s.selected?'current':null).attr('href','#').text($.wikiEditor.modules.toolbar.fn.autoMsg(s.config,'label')).data('context',s.context).click(function(){var $section=$(this).data('context').$ui.find('.section-'+ |
101 | | -$(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');} |
| 103 | +if('characters'in page){for(character in page.characters){$characters.append($.wikiEditor.modules.toolbar.fn.buildCharacter(context,page.characters[character]));}} |
| 104 | +$page.append($characters);break;} |
| 105 | +return $page;},buildHeading:function(context,headings){var $headings=$('<tr></tr>');for(heading in headings){$headings.append($('<th></th>').text($.wikiEditor.modules.toolbar.fn.autoMsg(headings[heading],'content')));} |
| 106 | +return $headings;},buildRow:function(context,row){var $row=$('<tr></tr>');for(cell in row){$row.append($('<td></td>').attr({'class':'cell cell-'+cell,'valign':'top'}).append($('<span></span>').html($.wikiEditor.modules.toolbar.fn.autoMsg(row[cell],'content'))));} |
| 107 | +return $row;},buildCharacter:function(context,character){if(typeof character=='string'){character={'label':character,'action':{'type':'encapsulate','options':{'pre':character}}};}else if(0 in character&&1 in character){character={'label':character[0],'action':{'type':'encapsulate','options':{'pre':character[1]}}};} |
| 108 | +if('action'in character&&'label'in character){return $('<a></a>').attr('rel',character.label).attr('href','#').text(character.label).data('context',context).data('action',character.action).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'));return false;});}},buildTab:function(context,id,section){var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');return $('<span></span>').attr({'class':'tab tab-'+id,'rel':id}).append($('<a></a>').addClass(selected==id?'current':null).attr('href','#').text($.wikiEditor.modules.toolbar.fn.autoMsg(section,'label')).data('context',context).click(function(){var $section=$(this).data('context').$ui.find('.section-'+$(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');} |
102 | 109 | $.cookie('wikiEditor-'+ |
103 | | -$(this).data('context').instance+'-toolbar-section',show?$section.attr('rel'):null);return false;})));}} |
104 | | -$.eachAsync(sectionQueue,{'bulk':0,'end':function(){$('body').css('position','static');$('body').css('position','relative');},'loop':function(i,s){s.$sections.append($.wikiEditor.modules.toolbar.fn.buildSection(s.context,s.section,s.config).css('display',s.selected?'block':'none'));}});}}};})(jQuery); |
\ No newline at end of file |
| 110 | +$(this).data('context').instance+'-toolbar-section',show?$section.attr('rel'):null);return false;}));},buildSection:function(context,id,section){var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');var $section;switch(section.type){case'toolbar':var $section=$('<div></div>').attr({'class':'toolbar section section-'+id,'rel':id});if('groups'in section){for(group in section.groups){$section.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,section.groups[group]));}} |
| 111 | +break;case'booklet':var $pages=$('<div></div>').attr('class','pages');var $index=$('<div></div>').attr('class','index');if('pages'in section){for(page in section.pages){$pages.append($.wikiEditor.modules.toolbar.fn.buildPage(context,page,section.pages[page]));$index.append($.wikiEditor.modules.toolbar.fn.buildBookmark(context,page,section.pages[page]));}} |
| 112 | +$section=$('<div></div>').attr({'class':'booklet section section-'+id,'rel':id}).append($index).append($pages);$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,page,$pages,$index);break;} |
| 113 | +if($section!==null&&id!=='main'){$section.css('display',selected==id?'block':'none');} |
| 114 | +return $section;},updateBookletSelection:function(context,id,$pages,$index){var cookie='wikiEditor-'+context.instance+'-booklet-'+id+'-page';var selected=$.cookie(cookie);if($index.find('*[rel='+selected+']').size()==0){selected=$index.find(':first').attr('rel');$.cookie(cookie,selected);} |
| 115 | +$pages.children().hide();$pages.find('*[rel='+selected+']').show();$index.children().removeClass('current');$index.find('*[rel='+selected+']').addClass('current');},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>').css('clear','both'));var sectionQueue=[];for(section in config){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,config[section]));}else{sectionQueue.push({'$sections':$sections,'context':context,'id':section,'config':config[section]});$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,config[section]));}} |
| 116 | +$.eachAsync(sectionQueue,{'bulk':0,'end':function(){$('body').css('position','static');$('body').css('position','relative');},'loop':function(i,s){s.$sections.append($.wikiEditor.modules.toolbar.fn.buildSection(s.context,s.id,s.config));}});}}};})(jQuery); |
\ No newline at end of file |