Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.php |
— | — | @@ -45,3 +45,4 @@ |
46 | 46 | |
47 | 47 | // Registers Hooks |
48 | 48 | $wgHooks['BeforePageDisplay'][] = 'UsabilityInitiativeHooks::addResources'; |
| 49 | +$wgHooks['MakeGlobalVariablesScript'][] = 'UsabilityInitiativeHooks::addJSVars'; |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.i18n.php |
— | — | @@ -14,6 +14,7 @@ |
15 | 15 | $messages['en'] = array( |
16 | 16 | 'navigabletoc' => 'Navigable table of contents', |
17 | 17 | 'navigabletoc-desc' => 'Adds a table of contents to the edit form that scrolls the text box when a section is clicked', |
| 18 | + 'navigabletoc-preference' => 'Enable navigable table of contents', |
18 | 19 | ); |
19 | 20 | |
20 | 21 | /** Afrikaans (Afrikaans) |
Index: trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.php |
— | — | @@ -18,6 +18,14 @@ |
19 | 19 | |
20 | 20 | /* Configuration */ |
21 | 21 | |
| 22 | +// Set this to true to simply force NavigableTOC on everyone |
| 23 | +$wgNavigableTOCGlobalEnable = false; |
| 24 | + |
| 25 | +// Set this to true to add a preference to the editing section of preferences |
| 26 | +// which enables and disables NavigableTOC (if $wgNavigableTOCGlobalEnable, this |
| 27 | +// will not do anything) |
| 28 | +$wgNavigableTOCUserEnable = true; |
| 29 | + |
22 | 30 | // Bump the version number every time you change any of the .css/.js files |
23 | 31 | $wgNavigableTOCStyleVersion = 3; |
24 | 32 | |
— | — | @@ -45,4 +53,5 @@ |
46 | 54 | dirname( __FILE__ ) . '/NavigableTOC.i18n.php'; |
47 | 55 | |
48 | 56 | // Registers Hooks |
49 | | -$wgHooks['EditPageBeforeEditToolbar'][] = 'NavigableTOCHooks::addTOC'; |
\ No newline at end of file |
| 57 | +$wgHooks['EditPageBeforeEditToolbar'][] = 'NavigableTOCHooks::addTOC'; |
| 58 | +$wgHooks['GetPreferences'][] = 'NavigableTOCHooks::addPreferences'; |
Index: trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.hooks.php |
— | — | @@ -15,14 +15,36 @@ |
16 | 16 | * Adds the TOC to the edit form |
17 | 17 | */ |
18 | 18 | public static function addTOC( &$toolbar ) { |
19 | | - global $wgNavigableTOCStyleVersion, $wgParser, $wgUser; |
20 | | - global $wgEnableParserCache; |
| 19 | + global $wgNavigableTOCStyleVersion, $wgUser; |
| 20 | + global $wgNavigableTOCGlobalEnable, $wgNavigableTOCUserEnable; |
21 | 21 | |
22 | | - // Adds script to document |
23 | | - UsabilityInitiativeHooks::initialize(); |
24 | | - UsabilityInitiativeHooks::addScript( |
25 | | - 'NavigableTOC/NavigableTOC.js', $wgNavigableTOCStyleVersion |
26 | | - ); |
| 22 | + if ( $wgNavigableTOCGlobalEnable || ( $wgNavigableTOCUserEnable && $wgUser->getOption( 'usenavigabletoc' ) ) ) { |
| 23 | + // Adds script to document |
| 24 | + UsabilityInitiativeHooks::initialize(); |
| 25 | + UsabilityInitiativeHooks::addScript( |
| 26 | + 'NavigableTOC/NavigableTOC.js', $wgNavigableTOCStyleVersion |
| 27 | + ); |
| 28 | + } |
27 | 29 | return true; |
28 | 30 | } |
| 31 | + |
| 32 | + /** |
| 33 | + * GetPreferences hook |
| 34 | + * Add NTOC-related items to the preferences |
| 35 | + */ |
| 36 | + public static function addPreferences( $user, &$defaultPreferences ) { |
| 37 | + global $wgNavigableTOCGlobalEnable, $wgNavigableTOCUserEnable; |
| 38 | + |
| 39 | + if ( !$wgNavigableTOCGlobalEnable && $wgNavigableTOCUserEnable ) { |
| 40 | + wfLoadExtensionMessages( 'NavigableTOC' ); |
| 41 | + // Adds preference for opting in |
| 42 | + $defaultPreferences['usenavigabletoc'] = |
| 43 | + array( |
| 44 | + 'type' => 'toggle', |
| 45 | + 'label-message' => 'navigabletoc-preference', |
| 46 | + 'section' => 'editing/advancedediting', |
| 47 | + ); |
| 48 | + } |
| 49 | + return true; |
| 50 | + } |
29 | 51 | } |
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -63,17 +63,17 @@ |
64 | 64 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
65 | 65 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 3 ), |
66 | 66 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 9 ), |
67 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 4 ), |
| 67 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 5 ), |
68 | 68 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 11 ), |
69 | 69 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 2 ), |
70 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 5 ), |
| 70 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 6 ), |
71 | 71 | array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2x' ), |
72 | 72 | ), |
73 | 73 | 'combined' => array( |
74 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 21 ), |
| 74 | + array( 'src' => 'js/plugins.combined.js', 'version' => 22 ), |
75 | 75 | ), |
76 | 76 | 'minified' => array( |
77 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 21 ), |
| 77 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 22 ), |
78 | 78 | ), |
79 | 79 | ), |
80 | 80 | ); |
— | — | @@ -125,31 +125,7 @@ |
126 | 126 | |
127 | 127 | if ( !self::$doOutput ) |
128 | 128 | return true; |
129 | | - // Transforms variables into javascript global variables |
130 | | - foreach ( self::$variables as $key => $value ) { |
131 | | - $escapedVariableValue = Xml::escapeJsString( $value ); |
132 | | - $escapedVariableKey = Xml::escapeJsString( $key ); |
133 | | - self::$variables[$key] = |
134 | | - "var {$escapedVariableKey} = '{$escapedVariableValue}';"; |
135 | | - } |
136 | 129 | |
137 | | - //literal variables, ie ones we do not want escaped as strings |
138 | | - foreach( self::$literalVariables as $key => $value){ |
139 | | - $escapedVariableValue = Xml::escapeJsString( $value ); |
140 | | - $escapedVariableKey = Xml::escapeJsString( $key ); |
141 | | - self::$variables[$key] = |
142 | | - "var {$escapedVariableKey} = {$escapedVariableValue};"; |
143 | | - } |
144 | | - if ( count( self::$variables ) > 0 ) { |
145 | | - $out->addScript( |
146 | | - Xml::tags( |
147 | | - 'script', |
148 | | - array( 'type' => $wgJsMimeType ), |
149 | | - implode( self::$variables ) |
150 | | - ) |
151 | | - ); |
152 | | - } |
153 | | - |
154 | 130 | // Loops over each script |
155 | 131 | foreach ( self::$scripts as $script ) { |
156 | 132 | // Add javascript to document |
— | — | @@ -199,6 +175,14 @@ |
200 | 176 | } |
201 | 177 | return true; |
202 | 178 | } |
| 179 | + |
| 180 | + /** |
| 181 | + * MakeGlobalVariablesScript hook |
| 182 | + */ |
| 183 | + public static function addJSVars( &$vars ) { |
| 184 | + $vars = array_merge( $vars, self::$variables ); |
| 185 | + return true; |
| 186 | + } |
203 | 187 | |
204 | 188 | /** |
205 | 189 | * Adds a reference to a javascript file to the head of the document |
— | — | @@ -234,13 +218,4 @@ |
235 | 219 | public static function addVariables( $variables ) { |
236 | 220 | self::$variables = array_merge( self::$variables, $variables ); |
237 | 221 | } |
238 | | - |
239 | | - /** |
240 | | - * Adds variables that will be turned into global variables in JS, but not escaped as strings |
241 | | - * @param $variables array of "name" => "value" |
242 | | - */ |
243 | | - public static function addLiteralVariables( $variables ) { |
244 | | - self::$literalVariables = array_merge( self::$literalVariables, $variables ); |
245 | | - } |
246 | | - |
247 | 222 | } |
Index: trunk/extensions/UsabilityInitiative/images/wikiEditor/toolbar/insert-ilink.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/UsabilityInitiative/images/wikiEditor/toolbar/insert-ilink.png |
___________________________________________________________________ |
Name: svn:mime-type |
248 | 223 | + application/octet-stream |
Index: trunk/extensions/UsabilityInitiative/images/wikiEditor/toolbar/insert-xlink.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/UsabilityInitiative/images/wikiEditor/toolbar/insert-xlink.png |
___________________________________________________________________ |
Name: svn:mime-type |
249 | 224 | + application/octet-stream |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | 'wgTrackingToken' => ClickTrackingHooks::get_session_id() |
59 | 59 | ) |
60 | 60 | ); |
61 | | - UsabilityInitiativeHooks::addLiteralVariables( |
| 61 | + UsabilityInitiativeHooks::addVariables( |
62 | 62 | array( |
63 | 63 | 'wgClickTrackingIsThrottled' => ClickTrackingHooks::isUserThrottled() |
64 | 64 | ) |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php |
— | — | @@ -15,7 +15,9 @@ |
16 | 16 | * Intercept the display of the toolbar, replacing the content of $toolbar |
17 | 17 | */ |
18 | 18 | public static function addToolbar( &$toolbar ) { |
19 | | - global $wgUser, $wgEditToolbarGlobalEnable, $wgEditToolbarUserEnable; |
| 19 | + global $wgUser, $wgEditToolbarGlobalEnable; |
| 20 | + global $wgEditToolbarUserEnable, $wgEditToolbarCGDGlobalEnable; |
| 21 | + global $wgEditToolbarCGDUserEnable; |
20 | 22 | |
21 | 23 | // Only proceed if some specific conditions are met |
22 | 24 | if ( $wgEditToolbarGlobalEnable || ( $wgEditToolbarUserEnable && $wgUser->getOption( 'usebetatoolbar' ) ) ) { |
— | — | @@ -25,6 +27,9 @@ |
26 | 28 | UsabilityInitiativeHooks::addScript( |
27 | 29 | 'EditToolbar/EditToolbar.js', $wgEditToolbarStyleVersion |
28 | 30 | ); |
| 31 | + UsabilityInitiativeHooks::addVariables( array( |
| 32 | + 'wgEditToolbarCGD' => $wgEditToolbarCGDGlobalEnable || ( $wgEditToolbarCGDUserEnable && $wgUser->getOption( 'usebetatoolbar-cgd' ) ) |
| 33 | + ) ); |
29 | 34 | // Internationalization |
30 | 35 | wfLoadExtensionMessages( 'EditToolbar' ); |
31 | 36 | UsabilityInitiativeHooks::addMessages( |
— | — | @@ -35,6 +40,10 @@ |
36 | 41 | 'edittoolbar-tool-bold-example', |
37 | 42 | 'edittoolbar-tool-italic', |
38 | 43 | 'edittoolbar-tool-italic-example', |
| 44 | + 'edittoolbar-tool-ilink', |
| 45 | + 'edittoolbar-tool-ilink-example', |
| 46 | + 'edittoolbar-tool-xlink', |
| 47 | + 'edittoolbar-tool-xlink-example', |
39 | 48 | 'edittoolbar-tool-link', |
40 | 49 | 'edittoolbar-tool-link-title', |
41 | 50 | 'edittoolbar-tool-link-int', |
— | — | @@ -86,6 +95,7 @@ |
87 | 96 | 'edittoolbar-tool-gallery-example', |
88 | 97 | 'edittoolbar-tool-newline', |
89 | 98 | 'edittoolbar-tool-table', |
| 99 | + 'edittoolbar-tool-table-example-old', |
90 | 100 | 'edittoolbar-tool-table-example', |
91 | 101 | 'edittoolbar-tool-table-example-header', |
92 | 102 | 'edittoolbar-tool-table-title', |
— | — | @@ -198,15 +208,9 @@ |
199 | 209 | */ |
200 | 210 | public static function addPreferences( $user, &$defaultPreferences ) { |
201 | 211 | global $wgEditToolbarGlobalEnable, $wgEditToolbarUserEnable; |
| 212 | + global $wgEditToolbarCGDGlobalEnable, $wgEditToolbarCGDUserEnable; |
202 | 213 | |
203 | | - // Checks if... |
204 | | - if ( |
205 | | - // Toolbar is NOT globablly enabled |
206 | | - !$wgEditToolbarGlobalEnable && |
207 | | - // And Toolbar is per-user enablable |
208 | | - $wgEditToolbarUserEnable |
209 | | - ) { |
210 | | - // Internationalization |
| 214 | + if ( !$wgEditToolbarGlobalEnable && $wgEditToolbarUserEnable ) { |
211 | 215 | wfLoadExtensionMessages( 'EditToolbar' ); |
212 | 216 | // Adds preference for opting in |
213 | 217 | $defaultPreferences['usebetatoolbar'] = |
— | — | @@ -216,6 +220,15 @@ |
217 | 221 | 'section' => 'editing/advancedediting', |
218 | 222 | ); |
219 | 223 | } |
| 224 | + |
| 225 | + if ( !$wgEditToolbarGlobalEnable && $wgEditToolbarUserEnable ) { |
| 226 | + wfLoadExtensionMessages( 'EditToolbar' ); |
| 227 | + $defaultPreferences['usebetatoolbar-cgd'] = array( |
| 228 | + 'type' => 'toggle', |
| 229 | + 'label-message' => 'edittoolbar-cgd-preference', |
| 230 | + 'section' => 'editing/advancedediting', |
| 231 | + ); |
| 232 | + } |
220 | 233 | return true; |
221 | 234 | } |
222 | 235 | } |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -1,6 +1,10 @@ |
2 | 2 | /* JavaScript for EditToolbar extension */ |
3 | 3 | |
4 | 4 | js2AddOnloadHook( function() { |
| 5 | + // Only show content generation dialogs if enabled |
| 6 | + if ( typeof wgEditToolbarCGD != 'undefined' && wgEditToolbarCGD ) |
| 7 | + $j( '#wpTextbox1' ).addClass( 'withCGD' ); |
| 8 | + |
5 | 9 | if ( $j.wikiEditor != undefined && $j.wikiEditor.isSupported() || !$j.wikiEditor.isSupportKnown() ) { |
6 | 10 | // Remove the old toolbar |
7 | 11 | $j( '#toolbar' ).remove(); |
— | — | @@ -47,10 +51,39 @@ |
48 | 52 | }, |
49 | 53 | 'insert': { |
50 | 54 | tools: { |
51 | | - 'link': { |
| 55 | + 'xlink': { |
| 56 | + labelMsg: 'edittoolbar-tool-xlink', |
| 57 | + type: 'button', |
| 58 | + icon: 'insert-xlink.png', |
| 59 | + filters: [ '#wpTextbox1:not(.withCGD)' ], |
| 60 | + action: { |
| 61 | + type: 'encapsulate', |
| 62 | + options: { |
| 63 | + pre: "[", |
| 64 | + periMsg: 'edittoolbar-tool-xlink-example', |
| 65 | + post: "]" |
| 66 | + } |
| 67 | + } |
| 68 | + }, |
| 69 | + 'ilink': { |
| 70 | + labelMsg: 'edittoolbar-tool-ilink', |
| 71 | + type: 'button', |
| 72 | + icon: 'insert-ilink.png', |
| 73 | + filters: [ '#wpTextbox1:not(.withCGD)' ], |
| 74 | + action: { |
| 75 | + type: 'encapsulate', |
| 76 | + options: { |
| 77 | + pre: "[[", |
| 78 | + periMsg: 'edittoolbar-tool-ilink-example', |
| 79 | + post: "]]" |
| 80 | + } |
| 81 | + } |
| 82 | + }, |
| 83 | + 'linkCGD': { |
52 | 84 | labelMsg: 'edittoolbar-tool-link', |
53 | 85 | type: 'button', |
54 | 86 | icon: 'insert-link.png', |
| 87 | + filters: [ '#wpTextbox1.withCGD' ], |
55 | 88 | action: { |
56 | 89 | type: 'dialog', |
57 | 90 | module: 'insert-link' |
— | — | @@ -271,15 +304,30 @@ |
272 | 305 | } |
273 | 306 | } |
274 | 307 | }, |
275 | | - 'table': { |
| 308 | + 'tableCGD': { |
276 | 309 | labelMsg: 'edittoolbar-tool-table', |
277 | 310 | type: 'button', |
278 | 311 | icon: 'insert-table.png', |
| 312 | + filters: [ '#wpTextbox1.withCGD' ], |
279 | 313 | action: { |
280 | 314 | type: 'dialog', |
281 | 315 | module: 'insert-table' |
282 | 316 | } |
283 | 317 | }, |
| 318 | + 'table': { |
| 319 | + labelMsg: 'edittoolbar-tool-table', |
| 320 | + type: 'button', |
| 321 | + icon: 'insert-table.png', |
| 322 | + filters: [ '#wpTextbox1:not(.withCGD)' ], |
| 323 | + action: { |
| 324 | + type: 'encapsulate', |
| 325 | + options: { |
| 326 | + pre: "{| class=\"wikitable\" border=\"1\"\n|", |
| 327 | + periMsg: 'edittoolbar-tool-table-example-old', |
| 328 | + post: "\n|}" |
| 329 | + } |
| 330 | + } |
| 331 | + }, |
284 | 332 | 'newline': { |
285 | 333 | labelMsg: 'edittoolbar-tool-newline', |
286 | 334 | type: 'button', |
— | — | @@ -299,6 +347,7 @@ |
300 | 348 | labelMsg: 'edittoolbar-tool-replace', |
301 | 349 | type: 'button', |
302 | 350 | icon: 'search-replace.png', |
| 351 | + filters: [ '#wpTextbox1.withCGD' ], |
303 | 352 | action: { |
304 | 353 | type: 'dialog', |
305 | 354 | module: 'search-and-replace' |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.i18n.php |
— | — | @@ -15,12 +15,17 @@ |
16 | 16 | 'edittoolbar' => 'Editing toolbar', |
17 | 17 | 'edittoolbar-desc' => 'Edit page toolbar with enhanced usability', |
18 | 18 | 'edittoolbar-preference' => 'Enable enhanced editing toolbar', |
| 19 | + 'edittoolbar-cgd-preference' => 'Enable content generation dialogs in enhanced editing toolbar', |
19 | 20 | 'edittoolbar-loading' => 'Loading...', |
20 | 21 | /* Main Section */ |
21 | 22 | 'edittoolbar-tool-bold' => 'Bold', |
22 | 23 | 'edittoolbar-tool-bold-example' => 'Bold text', |
23 | 24 | 'edittoolbar-tool-italic' => 'Italic', |
24 | 25 | 'edittoolbar-tool-italic-example' => 'Italic text', |
| 26 | + 'edittoolbar-tool-ilink' => 'Internal link', |
| 27 | + 'edittoolbar-tool-ilink-example' => 'Link title', |
| 28 | + 'edittoolbar-tool-xlink' => 'External link (remember http:// prefix)', |
| 29 | + 'edittoolbar-tool-xlink-example' => 'http://www.example.com link title', |
25 | 30 | 'edittoolbar-tool-link' => 'Link', |
26 | 31 | 'edittoolbar-tool-link-title' => 'Insert link', |
27 | 32 | 'edittoolbar-tool-link-int' => 'To a wiki page', |
— | — | @@ -73,6 +78,18 @@ |
74 | 79 | {{ns:file}}:Example.jpg|Caption2", |
75 | 80 | 'edittoolbar-tool-newline' => 'New line', |
76 | 81 | 'edittoolbar-tool-table' => 'Table', |
| 82 | + 'edittoolbar-tool-table-example-old' => "- |
| 83 | +! header 1 |
| 84 | +! header 2 |
| 85 | +! header 3 |
| 86 | +|- |
| 87 | +| row 1, cell 1 |
| 88 | +| row 1, cell 2 |
| 89 | +| row 1, cell 3 |
| 90 | +|- |
| 91 | +| row 2, cell 1 |
| 92 | +| row 2, cell 2 |
| 93 | +| row 2, cell 3", |
77 | 94 | 'edittoolbar-tool-table-example' => 'Row $1, cell $2', |
78 | 95 | 'edittoolbar-tool-table-example-header' => 'Row $1, cell $2 (header)', |
79 | 96 | 'edittoolbar-tool-table-title' => 'Insert table', |
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 = 32; |
| 23 | +$wgEditToolbarStyleVersion = 33; |
24 | 24 | |
25 | 25 | // Set this to true to simply override the stock toolbar for everyone |
26 | 26 | $wgEditToolbarGlobalEnable = false; |
— | — | @@ -29,6 +29,15 @@ |
30 | 30 | // will not do anything) |
31 | 31 | $wgEditToolbarUserEnable = true; |
32 | 32 | |
| 33 | +// Set this to true to enable content generation dialogs for everyone who gets |
| 34 | +// the toolbar |
| 35 | +$wgEditToolbarCGDGlobalEnable = false; |
| 36 | + |
| 37 | +// Set this to true to add a preference to the editing section of preferences |
| 38 | +// which enabled and disables content generation dialogs |
| 39 | +// If $wgEditToolbatCGDGlobalEnable is true, this will be ignored |
| 40 | +$wgEditToolbarCGDUserEnable = true; |
| 41 | + |
33 | 42 | // Set if we should include a client-side testing script |
34 | 43 | $wgEditToolbarRunTests = false; |
35 | 44 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -65,96 +65,88 @@ |
66 | 66 | // gets called again we can pick up where we left off |
67 | 67 | var context = $(this).data( 'wikiEditor-context' ); |
68 | 68 | |
69 | | -/* API */ |
70 | 69 | |
71 | | -// The first time this is called, we expect context to be undefined, meaning |
72 | | -// the editing UI has not yet been, and still needs to be, built. However, each |
73 | | -// additional call after that is expected to be an API call, which contains a |
74 | | -// string as the first argument which corresponds to a supported API call |
75 | | -if ( typeof context !== 'undefined' ) { |
76 | | - // Since javascript gives arguments as an object, we need to convert them |
77 | | - // so they can be used more easily |
78 | | - arguments = $.makeArray( arguments ); |
79 | | - if ( arguments.length > 0 ) { |
80 | | - // Handle API calls |
81 | | - var call = arguments.shift(); |
82 | | - if ( call in context.api ) { |
83 | | - context.api[call]( context, arguments[0] == undefined ? {} : arguments[0] ); |
84 | | - } |
85 | | - // Store the context for next time and return |
86 | | - return $(this).data( 'context', context ); |
87 | | - } |
88 | | - // Nothing to do, just return |
89 | | - return $(this); |
90 | | -} |
91 | | - |
92 | | -/* Construction */ |
93 | | - |
94 | | -var instance = $.wikiEditor.instances.length; |
95 | | -context = { '$textarea': $(this), 'modules': {}, 'data': {}, 'instance': instance }; |
96 | | -$.wikiEditor.instances[instance] = $(this); |
97 | | - |
98 | | -// Encapsulate the textarea with some containers for layout |
99 | | -$(this) |
100 | | - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui' ).attr( 'id', 'wikiEditor-ui' ) ) |
101 | | - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-bottom' ).attr( 'id', 'wikiEditor-ui-bottom' ) ) |
102 | | - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-text' ).attr( 'id', 'wikiEditor-ui-text' ) ); |
103 | | - |
104 | | -// Get a reference to the outer container |
105 | | -context.$ui = $(this).parent().parent().parent(); |
106 | | -context.$ui.after( $( '<div style="clear:both;"></div>' ) ); |
107 | | -// Attach a container in the top |
108 | | -context.$ui.prepend( $( '<div></div>' ).addClass( 'wikiEditor-ui-top' ).attr( 'id', 'wikiEditor-ui-top' ) ); |
109 | | - |
110 | | -// Create a set of standard methods for internal and external use |
111 | | -context.api = { |
112 | | - /** |
113 | | - * Accepts either a string of the name of a module to add without any |
114 | | - * additional configuration parameters, or an object with members keyed with |
115 | | - * module names and valued with configuration objects |
116 | | - */ |
117 | | - addModule: function( context, data ) { |
118 | | - // A safe way of calling an API function on a module |
119 | | - function callModuleApi( module, call, data ) { |
120 | | - if ( |
121 | | - module in $.wikiEditor.modules && |
122 | | - 'fn' in $.wikiEditor.modules[module] && |
123 | | - call in $.wikiEditor.modules[module].fn |
124 | | - ) { |
125 | | - $.wikiEditor.modules[module].fn[call]( context, data ); |
| 70 | +if ( typeof context == 'undefined' ) { |
| 71 | + /* Construction */ |
| 72 | + var instance = $.wikiEditor.instances.length; |
| 73 | + context = { '$textarea': $(this), 'modules': {}, 'data': {}, 'instance': instance }; |
| 74 | + $.wikiEditor.instances[instance] = $(this); |
| 75 | + |
| 76 | + // Encapsulate the textarea with some containers for layout |
| 77 | + $(this) |
| 78 | + .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui' ).attr( 'id', 'wikiEditor-ui' ) ) |
| 79 | + .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-bottom' ).attr( 'id', 'wikiEditor-ui-bottom' ) ) |
| 80 | + .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-text' ).attr( 'id', 'wikiEditor-ui-text' ) ); |
| 81 | + |
| 82 | + // Get a reference to the outer container |
| 83 | + context.$ui = $(this).parent().parent().parent(); |
| 84 | + context.$ui.after( $( '<div style="clear:both;"></div>' ) ); |
| 85 | + // Attach a container in the top |
| 86 | + context.$ui.prepend( $( '<div></div>' ).addClass( 'wikiEditor-ui-top' ).attr( 'id', 'wikiEditor-ui-top' ) ); |
| 87 | + |
| 88 | + // Create a set of standard methods for internal and external use |
| 89 | + context.api = { |
| 90 | + /** |
| 91 | + * Accepts either a string of the name of a module to add without any |
| 92 | + * additional configuration parameters, or an object with members keyed with |
| 93 | + * module names and valued with configuration objects |
| 94 | + */ |
| 95 | + addModule: function( context, data ) { |
| 96 | + // A safe way of calling an API function on a module |
| 97 | + function callModuleApi( module, call, data ) { |
| 98 | + if ( |
| 99 | + module in $.wikiEditor.modules && |
| 100 | + 'fn' in $.wikiEditor.modules[module] && |
| 101 | + call in $.wikiEditor.modules[module].fn |
| 102 | + ) { |
| 103 | + $.wikiEditor.modules[module].fn[call]( context, data ); |
| 104 | + } |
126 | 105 | } |
127 | | - } |
128 | | - if ( typeof data == 'string' ) { |
129 | | - callModuleApi( data, 'create', {} ); |
130 | | - } else if ( typeof data == 'object' ) { |
131 | | - for ( module in data ) { |
132 | | - if ( typeof module == 'string' ) { |
133 | | - callModuleApi( module, 'create', data[module] ); |
| 106 | + if ( typeof data == 'string' ) { |
| 107 | + callModuleApi( data, 'create', {} ); |
| 108 | + } else if ( typeof data == 'object' ) { |
| 109 | + for ( module in data ) { |
| 110 | + if ( typeof module == 'string' ) { |
| 111 | + callModuleApi( module, 'create', data[module] ); |
| 112 | + } |
134 | 113 | } |
135 | 114 | } |
136 | 115 | } |
137 | | - } |
138 | | -}; |
139 | | -// Allow modules to extend the API |
140 | | -for ( module in $.wikiEditor.modules ) { |
141 | | - if ( 'api' in $.wikiEditor.modules[module] ) { |
142 | | - for ( call in $.wikiEditor.modules[module].api ) { |
143 | | - // Modules may not overwrite existing API functions - first come, |
144 | | - // first serve |
145 | | - if ( !( call in context.api ) ) { |
146 | | - context.api[call] = $.wikiEditor.modules[module].api[call]; |
| 116 | + }; |
| 117 | + // Allow modules to extend the API |
| 118 | + for ( module in $.wikiEditor.modules ) { |
| 119 | + if ( 'api' in $.wikiEditor.modules[module] ) { |
| 120 | + for ( call in $.wikiEditor.modules[module].api ) { |
| 121 | + // Modules may not overwrite existing API functions - first come, |
| 122 | + // first serve |
| 123 | + if ( !( call in context.api ) ) { |
| 124 | + context.api[call] = $.wikiEditor.modules[module].api[call]; |
| 125 | + } |
147 | 126 | } |
148 | 127 | } |
149 | 128 | } |
| 129 | + //Each browser seems to do this differently, so let's keep our editor |
| 130 | + //consistent by always starting at the begining |
| 131 | + context.$textarea.scrollToCaretPosition( 0 ); |
150 | 132 | } |
| 133 | + |
151 | 134 | // If there was a configuration passed, it's assumed to be for the addModule |
152 | | -// API call, so we can just send it on it's way right now |
| 135 | +// API call |
153 | 136 | if ( arguments.length > 0 && typeof arguments[0] == 'object' ) { |
154 | 137 | context.api.addModule( context, arguments[0] ); |
| 138 | +} else { |
| 139 | + // Since javascript gives arguments as an object, we need to convert them |
| 140 | + // so they can be used more easily |
| 141 | + arguments = $.makeArray( arguments ); |
| 142 | + if ( arguments.length > 0 ) { |
| 143 | + // Handle API calls |
| 144 | + var call = arguments.shift(); |
| 145 | + if ( call in context.api ) { |
| 146 | + context.api[call]( context, arguments[0] == undefined ? {} : arguments[0] ); |
| 147 | + } |
| 148 | + } |
155 | 149 | } |
156 | | -//Each browser seems to do this differently, so let's keep our editor |
157 | | -//consistent by always starting at the begining |
158 | | -context.$textarea.scrollToCaretPosition( 0 ); |
| 150 | + |
159 | 151 | // Store the context for next time, and support chaining |
160 | 152 | return $(this).data( 'wikiEditor-context', context ); |
161 | 153 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | context.$textarea |
47 | 47 | .bind( 'keyup encapsulateSelection', |
48 | 48 | function( event ) { |
49 | | - var context = $(this).data( 'context' ); |
| 49 | + var context = $(this).data( 'wikiEditor-context' ); |
50 | 50 | $(this).eachAsync( { |
51 | 51 | bulk: 0, |
52 | 52 | loop: function() { |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | ) |
59 | 59 | .bind( 'mouseup scrollToPosition focus', |
60 | 60 | function( event ) { |
61 | | - var context = $(this).data( 'context' ); |
| 61 | + var context = $(this).data( 'wikiEditor-context' ); |
62 | 62 | $(this).eachAsync( { |
63 | 63 | bulk: 0, |
64 | 64 | loop: function() { |
— | — | @@ -67,6 +67,7 @@ |
68 | 68 | } |
69 | 69 | ) |
70 | 70 | .blur( function() { |
| 71 | + var context = $(this).data( 'wikiEditor-context' ); |
71 | 72 | $.wikiEditor.modules.toc.fn.unhighlight( context ); |
72 | 73 | }); |
73 | 74 | }, |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -1086,96 +1086,88 @@ |
1087 | 1087 | // gets called again we can pick up where we left off |
1088 | 1088 | var context = $(this).data( 'wikiEditor-context' ); |
1089 | 1089 | |
1090 | | -/* API */ |
1091 | 1090 | |
1092 | | -// The first time this is called, we expect context to be undefined, meaning |
1093 | | -// the editing UI has not yet been, and still needs to be, built. However, each |
1094 | | -// additional call after that is expected to be an API call, which contains a |
1095 | | -// string as the first argument which corresponds to a supported API call |
1096 | | -if ( typeof context !== 'undefined' ) { |
1097 | | - // Since javascript gives arguments as an object, we need to convert them |
1098 | | - // so they can be used more easily |
1099 | | - arguments = $.makeArray( arguments ); |
1100 | | - if ( arguments.length > 0 ) { |
1101 | | - // Handle API calls |
1102 | | - var call = arguments.shift(); |
1103 | | - if ( call in context.api ) { |
1104 | | - context.api[call]( context, arguments[0] == undefined ? {} : arguments[0] ); |
1105 | | - } |
1106 | | - // Store the context for next time and return |
1107 | | - return $(this).data( 'context', context ); |
1108 | | - } |
1109 | | - // Nothing to do, just return |
1110 | | - return $(this); |
1111 | | -} |
1112 | | - |
1113 | | -/* Construction */ |
1114 | | - |
1115 | | -var instance = $.wikiEditor.instances.length; |
1116 | | -context = { '$textarea': $(this), 'modules': {}, 'data': {}, 'instance': instance }; |
1117 | | -$.wikiEditor.instances[instance] = $(this); |
1118 | | - |
1119 | | -// Encapsulate the textarea with some containers for layout |
1120 | | -$(this) |
1121 | | - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui' ).attr( 'id', 'wikiEditor-ui' ) ) |
1122 | | - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-bottom' ).attr( 'id', 'wikiEditor-ui-bottom' ) ) |
1123 | | - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-text' ).attr( 'id', 'wikiEditor-ui-text' ) ); |
1124 | | - |
1125 | | -// Get a reference to the outer container |
1126 | | -context.$ui = $(this).parent().parent().parent(); |
1127 | | -context.$ui.after( $( '<div style="clear:both;"></div>' ) ); |
1128 | | -// Attach a container in the top |
1129 | | -context.$ui.prepend( $( '<div></div>' ).addClass( 'wikiEditor-ui-top' ).attr( 'id', 'wikiEditor-ui-top' ) ); |
1130 | | - |
1131 | | -// Create a set of standard methods for internal and external use |
1132 | | -context.api = { |
1133 | | - /** |
1134 | | - * Accepts either a string of the name of a module to add without any |
1135 | | - * additional configuration parameters, or an object with members keyed with |
1136 | | - * module names and valued with configuration objects |
1137 | | - */ |
1138 | | - addModule: function( context, data ) { |
1139 | | - // A safe way of calling an API function on a module |
1140 | | - function callModuleApi( module, call, data ) { |
1141 | | - if ( |
1142 | | - module in $.wikiEditor.modules && |
1143 | | - 'fn' in $.wikiEditor.modules[module] && |
1144 | | - call in $.wikiEditor.modules[module].fn |
1145 | | - ) { |
1146 | | - $.wikiEditor.modules[module].fn[call]( context, data ); |
| 1091 | +if ( typeof context == 'undefined' ) { |
| 1092 | + /* Construction */ |
| 1093 | + var instance = $.wikiEditor.instances.length; |
| 1094 | + context = { '$textarea': $(this), 'modules': {}, 'data': {}, 'instance': instance }; |
| 1095 | + $.wikiEditor.instances[instance] = $(this); |
| 1096 | + |
| 1097 | + // Encapsulate the textarea with some containers for layout |
| 1098 | + $(this) |
| 1099 | + .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui' ).attr( 'id', 'wikiEditor-ui' ) ) |
| 1100 | + .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-bottom' ).attr( 'id', 'wikiEditor-ui-bottom' ) ) |
| 1101 | + .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-text' ).attr( 'id', 'wikiEditor-ui-text' ) ); |
| 1102 | + |
| 1103 | + // Get a reference to the outer container |
| 1104 | + context.$ui = $(this).parent().parent().parent(); |
| 1105 | + context.$ui.after( $( '<div style="clear:both;"></div>' ) ); |
| 1106 | + // Attach a container in the top |
| 1107 | + context.$ui.prepend( $( '<div></div>' ).addClass( 'wikiEditor-ui-top' ).attr( 'id', 'wikiEditor-ui-top' ) ); |
| 1108 | + |
| 1109 | + // Create a set of standard methods for internal and external use |
| 1110 | + context.api = { |
| 1111 | + /** |
| 1112 | + * Accepts either a string of the name of a module to add without any |
| 1113 | + * additional configuration parameters, or an object with members keyed with |
| 1114 | + * module names and valued with configuration objects |
| 1115 | + */ |
| 1116 | + addModule: function( context, data ) { |
| 1117 | + // A safe way of calling an API function on a module |
| 1118 | + function callModuleApi( module, call, data ) { |
| 1119 | + if ( |
| 1120 | + module in $.wikiEditor.modules && |
| 1121 | + 'fn' in $.wikiEditor.modules[module] && |
| 1122 | + call in $.wikiEditor.modules[module].fn |
| 1123 | + ) { |
| 1124 | + $.wikiEditor.modules[module].fn[call]( context, data ); |
| 1125 | + } |
1147 | 1126 | } |
1148 | | - } |
1149 | | - if ( typeof data == 'string' ) { |
1150 | | - callModuleApi( data, 'create', {} ); |
1151 | | - } else if ( typeof data == 'object' ) { |
1152 | | - for ( module in data ) { |
1153 | | - if ( typeof module == 'string' ) { |
1154 | | - callModuleApi( module, 'create', data[module] ); |
| 1127 | + if ( typeof data == 'string' ) { |
| 1128 | + callModuleApi( data, 'create', {} ); |
| 1129 | + } else if ( typeof data == 'object' ) { |
| 1130 | + for ( module in data ) { |
| 1131 | + if ( typeof module == 'string' ) { |
| 1132 | + callModuleApi( module, 'create', data[module] ); |
| 1133 | + } |
1155 | 1134 | } |
1156 | 1135 | } |
1157 | 1136 | } |
1158 | | - } |
1159 | | -}; |
1160 | | -// Allow modules to extend the API |
1161 | | -for ( module in $.wikiEditor.modules ) { |
1162 | | - if ( 'api' in $.wikiEditor.modules[module] ) { |
1163 | | - for ( call in $.wikiEditor.modules[module].api ) { |
1164 | | - // Modules may not overwrite existing API functions - first come, |
1165 | | - // first serve |
1166 | | - if ( !( call in context.api ) ) { |
1167 | | - context.api[call] = $.wikiEditor.modules[module].api[call]; |
| 1137 | + }; |
| 1138 | + // Allow modules to extend the API |
| 1139 | + for ( module in $.wikiEditor.modules ) { |
| 1140 | + if ( 'api' in $.wikiEditor.modules[module] ) { |
| 1141 | + for ( call in $.wikiEditor.modules[module].api ) { |
| 1142 | + // Modules may not overwrite existing API functions - first come, |
| 1143 | + // first serve |
| 1144 | + if ( !( call in context.api ) ) { |
| 1145 | + context.api[call] = $.wikiEditor.modules[module].api[call]; |
| 1146 | + } |
1168 | 1147 | } |
1169 | 1148 | } |
1170 | 1149 | } |
| 1150 | + //Each browser seems to do this differently, so let's keep our editor |
| 1151 | + //consistent by always starting at the begining |
| 1152 | + context.$textarea.scrollToCaretPosition( 0 ); |
1171 | 1153 | } |
| 1154 | + |
1172 | 1155 | // If there was a configuration passed, it's assumed to be for the addModule |
1173 | | -// API call, so we can just send it on it's way right now |
| 1156 | +// API call |
1174 | 1157 | if ( arguments.length > 0 && typeof arguments[0] == 'object' ) { |
1175 | 1158 | context.api.addModule( context, arguments[0] ); |
| 1159 | +} else { |
| 1160 | + // Since javascript gives arguments as an object, we need to convert them |
| 1161 | + // so they can be used more easily |
| 1162 | + arguments = $.makeArray( arguments ); |
| 1163 | + if ( arguments.length > 0 ) { |
| 1164 | + // Handle API calls |
| 1165 | + var call = arguments.shift(); |
| 1166 | + if ( call in context.api ) { |
| 1167 | + context.api[call]( context, arguments[0] == undefined ? {} : arguments[0] ); |
| 1168 | + } |
| 1169 | + } |
1176 | 1170 | } |
1177 | | -//Each browser seems to do this differently, so let's keep our editor |
1178 | | -//consistent by always starting at the begining |
1179 | | -context.$textarea.scrollToCaretPosition( 0 ); |
| 1171 | + |
1180 | 1172 | // Store the context for next time, and support chaining |
1181 | 1173 | return $(this).data( 'wikiEditor-context', context ); |
1182 | 1174 | |
— | — | @@ -1926,7 +1918,7 @@ |
1927 | 1919 | context.$textarea |
1928 | 1920 | .bind( 'keyup encapsulateSelection', |
1929 | 1921 | function( event ) { |
1930 | | - var context = $(this).data( 'context' ); |
| 1922 | + var context = $(this).data( 'wikiEditor-context' ); |
1931 | 1923 | $(this).eachAsync( { |
1932 | 1924 | bulk: 0, |
1933 | 1925 | loop: function() { |
— | — | @@ -1938,7 +1930,7 @@ |
1939 | 1931 | ) |
1940 | 1932 | .bind( 'mouseup scrollToPosition focus', |
1941 | 1933 | function( event ) { |
1942 | | - var context = $(this).data( 'context' ); |
| 1934 | + var context = $(this).data( 'wikiEditor-context' ); |
1943 | 1935 | $(this).eachAsync( { |
1944 | 1936 | bulk: 0, |
1945 | 1937 | loop: function() { |
— | — | @@ -1948,6 +1940,7 @@ |
1949 | 1941 | } |
1950 | 1942 | ) |
1951 | 1943 | .blur( function() { |
| 1944 | + var context = $(this).data( 'wikiEditor-context' ); |
1952 | 1945 | $.wikiEditor.modules.toc.fn.unhighlight( context ); |
1953 | 1946 | }); |
1954 | 1947 | }, |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -70,13 +70,11 @@ |
71 | 71 | return this.each(function(){$(this).focus();if(this.selectionStart||this.selectionStart=='0'){this.selectionStart=pos;this.selectionEnd=pos;$(this).scrollTop(getCaretScrollPosition(this));}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();var oldPos=$(this).getCaretPosition();var goBack=false;if(oldPos==pos){pos++;goBack=true;} |
72 | 72 | range.moveToElementText(this);range.collapse();range.move('character',pos);range.select();this.scrollTop+=range.offsetTop;if(goBack){range.move('character',-1);range.select();}} |
73 | 73 | $(this).trigger('scrollToPosition');});}});})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'supportedBrowsers':{'ltr':{'msie':7,'firefox':2,'opera':9,'safari':3,'chrome':1,'camino':1},'rtl':{'msie':8,'firefox':2,'opera':9,'safari':3,'chrome':1,'camino':1}},imgPath:wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/'};$.wikiEditor.isSupportKnown=function(){return(function(supportedBrowsers){return $.browser.name in supportedBrowsers;})($.wikiEditor.supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);};$.wikiEditor.isSupported=function(){return(function(supportedBrowsers){return $.browser.name in supportedBrowsers&&$.browser.versionNumber>=supportedBrowsers[$.browser.name];})($.wikiEditor.supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);};$.wikiEditor.autoMsg=function(object,property){if(typeof property=='object'){for(i in property){if(property[i]in object||property[i]+'Msg'in object){property=property[i];break;}}} |
74 | | -if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}};$.fn.wikiEditor=function(){var context=$(this).data('wikiEditor-context');if(typeof context!=='undefined'){arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,arguments[0]==undefined?{}:arguments[0]);} |
75 | | -return $(this).data('context',context);} |
76 | | -return $(this);} |
77 | | -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);}} |
| 74 | +if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}};$.fn.wikiEditor=function(){var context=$(this).data('wikiEditor-context');if(typeof context=='undefined'){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);}} |
78 | 75 | 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];}}}} |
79 | | -if(arguments.length>0&&typeof arguments[0]=='object'){context.api.addModule(context,arguments[0]);} |
80 | | -context.$textarea.scrollToCaretPosition(0);return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,{'modules':data})},openDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('open');}},closeDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];} |
| 76 | +context.$textarea.scrollToCaretPosition(0);} |
| 77 | +if(arguments.length>0&&typeof arguments[0]=='object'){context.api.addModule(context,arguments[0]);}else{arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,arguments[0]==undefined?{}:arguments[0]);}}} |
| 78 | +return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,{'modules':data})},openDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('open');}},closeDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];} |
81 | 79 | for(module in $.wikiEditor.modules.dialogs.modules){var module=$.wikiEditor.modules.dialogs.modules[module];if($('#'+module.id).size()==0){var configuration=module.dialog;configuration.bgiframe=true;configuration.autoOpen=false;configuration.modal=true;configuration.title=$.wikiEditor.autoMsg(module,'title');for(msg in configuration.buttons){configuration.buttons[gM(msg)]=configuration.buttons[msg];delete configuration.buttons[msg];} |
82 | 80 | $('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration).bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI) |
83 | 81 | maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){$(this).width($(this).get(0).scrollWidth);wrapper.width(wrapper.get(0).scrollWidth);$(this).dialog({'width':wrapper.width()});} |
— | — | @@ -127,7 +125,7 @@ |
128 | 126 | return $section;},updateBookletSelection:function(context,id,$pages,$index){var cookie='wikiEditor-'+context.instance+'-booklet-'+id+'-page';var selected=$.cookie(cookie);var $selectedIndex=$index.find('*[rel='+selected+']');if($selectedIndex.size()==0){selected=$index.children().eq(0).attr('rel');$.cookie(cookie,selected);} |
129 | 127 | $pages.children().hide();$pages.find('*[rel='+selected+']').show();$index.children().removeClass('current');$selectedIndex.addClass('current');},build:function(context,config){var $tabs=$('<div />').addClass('tabs').appendTo(context.modules.$toolbar);var $sections=$('<div />').addClass('sections').appendTo(context.modules.$toolbar);context.modules.$toolbar.append($('<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]));}} |
130 | 128 | $.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);(function($){$.wikiEditor.modules.toc={api:{},fn:{create:function(context,config){if('$toc'in context.modules){return;} |
131 | | -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').css('marginTop',-(context.$ui.find('.wikiEditor-ui-bottom').height()));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 focus',function(event){var context=$(this).data('context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('a').removeClass('currentSelection');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);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++;} |
| 129 | +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').css('marginTop',-(context.$ui.find('.wikiEditor-ui-bottom').height()));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('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).bind('mouseup scrollToPosition focus',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){var context=$(this).data('wikiEditor-context');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('a').removeClass('currentSelection');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);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++;} |
132 | 130 | section=Math.max(0,section);} |
133 | 131 | 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;} |
134 | 132 | sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}} |