Index: trunk/extensions/CreateAPage/CreateMultiPage.php |
— | — | @@ -157,10 +157,10 @@ |
158 | 158 | // multiple toolbars... |
159 | 159 | $toolbar = "<div id='toolbar" . $toolbar_id . "' style='display: none'>\n"; |
160 | 160 | $toolbar .= "<script type='$wgJsMimeType'>\n/*<![CDATA[*/\n"; |
161 | | - $toolbar .= "YAHOO.Createpage.multiEditTextboxes[YAHOO.Createpage.multiEditTextboxes.length] = $toolbar_id;\n"; |
162 | | - $toolbar .= "YAHOO.Createpage.multiEditButtons[$toolbar_id] = [];\n"; |
163 | | - $toolbar .= "YAHOO.Createpage.multiEditCustomButtons[$toolbar_id] = [];\n"; |
164 | | - $toolbar .= "YAHOO.util.Event.addListener('wpTextboxes' + $toolbar_id, 'focus', YAHOO.Createpage.showThisBox, {'toolbarId' : $toolbar_id }); \n"; |
| 161 | + $toolbar .= "CreateAPage.multiEditTextboxes[CreateAPage.multiEditTextboxes.length] = $toolbar_id;\n"; |
| 162 | + $toolbar .= "CreateAPage.multiEditButtons[$toolbar_id] = [];\n"; |
| 163 | + $toolbar .= "CreateAPage.multiEditCustomButtons[$toolbar_id] = [];\n"; |
| 164 | + $toolbar .= "jQuery( document ).ready( function() { jQuery( '#wpTextboxes' + $toolbar_id ).focus( function( e ) { CreateAPage.showThisBox( e, {'toolbarId' : $toolbar_id } ); } ); } ); \n"; |
165 | 165 | $toolbar .= "/*]]>*/\n</script>"; |
166 | 166 | |
167 | 167 | $toolbar .= "\n</div>"; |
Index: trunk/extensions/CreateAPage/CreatePageImageUploadForm.php |
— | — | @@ -165,7 +165,7 @@ |
166 | 166 | array( 'img_name' => $img_name ), |
167 | 167 | __METHOD__ |
168 | 168 | ); |
169 | | - if ( 0 == $dbr->numRows( $resource ) ) { |
| 169 | + if ( $dbr->numRows( $resource ) == 0 ) { |
170 | 170 | $dbr->freeResult( $resource ); |
171 | 171 | return false; |
172 | 172 | } |
— | — | @@ -376,11 +376,20 @@ |
377 | 377 | * Try actually saving the thing... |
378 | 378 | * It will show an error form on failure. |
379 | 379 | */ |
380 | | - $pageText = self::getInitialPageText( $this->mComment, $this->mLicense, |
381 | | - $this->mCopyrightStatus, $this->mCopyrightSource ); |
| 380 | + $pageText = self::getInitialPageText( |
| 381 | + $this->mComment, |
| 382 | + $this->mLicense, |
| 383 | + $this->mCopyrightStatus, |
| 384 | + $this->mCopyrightSource |
| 385 | + ); |
382 | 386 | |
383 | | - $status = $this->mLocalFile->upload( $this->mTempPath, $this->mComment, $pageText, |
384 | | - File::DELETE_SOURCE, $this->mFileProps ); |
| 387 | + $status = $this->mLocalFile->upload( |
| 388 | + $this->mTempPath, |
| 389 | + $this->mComment, |
| 390 | + $pageText, |
| 391 | + File::DELETE_SOURCE, |
| 392 | + $this->mFileProps |
| 393 | + ); |
385 | 394 | |
386 | 395 | if ( !$status->isGood() ) { |
387 | 396 | $this->showError( $status->getWikiText() ); |
Index: trunk/extensions/CreateAPage/SpecialCreatePage.body.php |
— | — | @@ -38,13 +38,6 @@ |
39 | 39 | // Set the page title, robot policies, etc. |
40 | 40 | $this->setHeaders(); |
41 | 41 | |
42 | | - // Add YUI CSS & JS |
43 | | - $out->addScript( '<script language="javascript" src="http://yui.yahooapis.com/2.5.2/build/utilities/utilities.js"></script>' . "\n" ); |
44 | | - $out->addScript( '<script language="javascript" src="http://yui.yahooapis.com/2.5.2/build/container/container-min.js"></script>' . "\n" ); |
45 | | - // this MUST be included so that the overlay thingy on |
46 | | - // Special:CreatePage works properly |
47 | | - $out->addExtensionStyle( 'http://yui.yahooapis.com/2.5.2/build/container/assets/container.css' ); |
48 | | - |
49 | 42 | $mainForm = new CreatePageCreateplateForm( $par ); |
50 | 43 | |
51 | 44 | $action = $wgRequest->getVal( 'action' ); |
Index: trunk/extensions/CreateAPage/CreatePageCreateplateForm.php |
— | — | @@ -1,6 +1,9 @@ |
2 | 2 | <?php |
3 | | - |
4 | | -// this class takes care for the createplate loader form |
| 3 | +/** |
| 4 | + * This class takes care for the createplate loader form |
| 5 | + * |
| 6 | + * @file |
| 7 | + */ |
5 | 8 | class CreatePageCreateplateForm { |
6 | 9 | var $mCreateplatesLocation; |
7 | 10 | var $mTitle, $mNamespace, $mCreateplate; |
— | — | @@ -60,7 +63,11 @@ |
61 | 64 | $action = $titleObj->escapeLocalURL( 'action=submit' ); |
62 | 65 | |
63 | 66 | if ( $wgRequest->getCheck( 'wpPreview' ) ) { |
64 | | - $wgOut->addHTML( '<div class="previewnote"><p>' . wfMsg( 'previewnote' ) . '</p></div>' ); |
| 67 | + $wgOut->addHTML( |
| 68 | + '<div class="previewnote"><p>' . |
| 69 | + wfMsg( 'previewnote' ) . |
| 70 | + '</p></div>' |
| 71 | + ); |
65 | 72 | } else { |
66 | 73 | $wgOut->addHTML( wfMsg( 'createpage-title-additional' ) ); |
67 | 74 | } |
— | — | @@ -81,19 +88,16 @@ |
82 | 89 | $wgOut->addWikiMsg( 'anoneditwarning' ); |
83 | 90 | } |
84 | 91 | } |
85 | | - global $wgScriptPath; |
86 | 92 | |
87 | | - if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { |
88 | | - $wgOut->addModuleStyles( 'ext.createAPage' ); |
89 | | - } else { |
90 | | - $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/CreateAPage/CreatePage.css' ); |
91 | | - } |
| 93 | + // Add CSS & JS |
| 94 | + $wgOut->addModuleStyles( 'ext.createAPage' ); |
| 95 | + $wgOut->addModuleScripts( 'ext.createAPage' ); |
92 | 96 | /*if( $wgUser->getOption( 'disablelinksuggest' ) != true ) { |
93 | 97 | $wgOut->addHTML( '<div id="wpTextbox1_container" class="yui-ac-container"></div> '); |
94 | 98 | $wgOut->addScriptFile( $wgScriptPath . '/extensions/LinkSuggest/LinkSuggest.js' ); |
95 | 99 | }*/ |
96 | 100 | |
97 | | - $alternateLink = '<a href="#" onclick="CreatePageNormalEdit(); return false;">' . |
| 101 | + $alternateLink = '<a href="#" onclick="CreateAPage.goToNormalEditMode(); return false;">' . |
98 | 102 | wfMsg( 'createpage-here' ) . '</a>'; |
99 | 103 | $wgOut->addHTML( |
100 | 104 | '<div id="createpage_subtitle" style="display:none">' . |
— | — | @@ -105,9 +109,6 @@ |
106 | 110 | $this->showPreview( $content_prev, $wgRequest->getVal( 'Createtitle' ) ); |
107 | 111 | } |
108 | 112 | |
109 | | - $tmpl = new EasyTemplate( dirname( __FILE__ ) . '/templates/' ); |
110 | | - $wgOut->addHTML( $tmpl->render( 'title-check' ) ); |
111 | | - |
112 | 113 | $html = " |
113 | 114 | <form name=\"createpageform\" enctype=\"multipart/form-data\" method=\"post\" action=\"{$action}\" id=\"createpageform\"> |
114 | 115 | <div id=\"createpage_messenger\" style=\"display:none; color:red\"></div> |
— | — | @@ -129,16 +130,15 @@ |
130 | 131 | call_user_func_array( $formCallback, array( &$wgOut ) ); |
131 | 132 | } |
132 | 133 | |
133 | | - $wgOut->addHTML( $tmpl->render( 'toggles' ) ); |
134 | 134 | $parsedTemplates = $this->getCreateplates(); |
135 | | - $show_field = ''; |
| 135 | + $showField = ''; |
136 | 136 | if ( !$parsedTemplates ) { |
137 | | - $show_field = ' style="display: none";'; |
| 137 | + $showField = ' style="display: none";'; |
138 | 138 | } |
139 | 139 | |
140 | 140 | if ( !$wgRequest->getCheck( 'wpPreview' ) ) { |
141 | 141 | $wgOut->addHTML( |
142 | | - '<fieldset id="cp-chooser-fieldset"' . $show_field . '> |
| 142 | + '<fieldset id="cp-chooser-fieldset"' . $showField . '> |
143 | 143 | <legend>' . wfMsg( 'createpage-choose-createplate' ) . |
144 | 144 | '<span style="font-size: small; font-weight: normal; margin-left: 5px">[<a id="cp-chooser-toggle" title="toggle" href="#">' |
145 | 145 | . wfMsg( 'createpage-hide' ) . '</a>]</span> |
— | — | @@ -211,7 +211,12 @@ |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | | - // produce a list of radio buttons from the given createplate array |
| 215 | + /** |
| 216 | + * Produce a list of radio buttons from the given createplate array and |
| 217 | + * output the generated HTML. |
| 218 | + * |
| 219 | + * @param $createplates Array: array of createplates |
| 220 | + */ |
216 | 221 | function produceRadioList( $createplates ) { |
217 | 222 | global $wgOut, $wgRequest, $wgServer, $wgScript; |
218 | 223 | |
— | — | @@ -233,10 +238,10 @@ |
234 | 239 | $parserOptions = ParserOptions::newFromUser( $wgUser ); |
235 | 240 | $parserOptions->setEditSection( false ); |
236 | 241 | $rtitle = Title::newFromText( $this->mTitle ); |
237 | | - $parsed_info = $wgParser->parse( |
| 242 | + $parsedInfo = $wgParser->parse( |
238 | 243 | wfMsg( 'createpage-about-info' ), $rtitle, $parserOptions |
239 | 244 | ); |
240 | | - $aboutinfo = str_replace( '</p>', '', $parsed_info->mText ); |
| 245 | + $aboutinfo = str_replace( '</p>', '', $parsedInfo->mText ); |
241 | 246 | $aboutinfo .= wfMsg( |
242 | 247 | 'createpage-advanced-text', |
243 | 248 | '<a href="' . $wgServer . $wgScript . '" id="wpAdvancedEdit">' . |
— | — | @@ -268,7 +273,7 @@ |
269 | 274 | * exists and we're not in AJAX mode |
270 | 275 | */ |
271 | 276 | function checkArticleExists( $given, $ajax = false ) { |
272 | | - global $wgOut, $wgUser; |
| 277 | + global $wgOut; |
273 | 278 | |
274 | 279 | if ( $ajax ) { |
275 | 280 | $wgOut->setArticleBodyOnly( true ); |
— | — | @@ -280,14 +285,12 @@ |
281 | 286 | |
282 | 287 | $title = Title::newFromText( $given ); |
283 | 288 | if ( is_object( $title ) ) { |
284 | | - $page = $title->getText(); |
285 | | - $page = str_replace( ' ', '_', $page ); |
286 | 289 | $dbr = wfGetDB( DB_SLAVE ); |
287 | 290 | $exists = $dbr->selectField( |
288 | 291 | 'page', |
289 | 292 | 'page_title', |
290 | 293 | array( |
291 | | - 'page_title' => $page, |
| 294 | + 'page_title' => $title->getDBkey(), |
292 | 295 | 'page_namespace' => $title->getNamespace() |
293 | 296 | ), |
294 | 297 | __METHOD__ |
— | — | @@ -296,11 +299,10 @@ |
297 | 300 | if ( $ajax ) { |
298 | 301 | $wgOut->addHTML( 'pagetitleexists' ); |
299 | 302 | } else { |
300 | | - $sk = $wgUser->getSkin(); |
301 | 303 | // Mimick the way AJAX version displays things and use the |
302 | 304 | // same two messages. 2 are needed for full i18n support. |
303 | 305 | return wfMsg( 'createpage-article-exists' ) . ' ' . |
304 | | - $sk->makeKnownLinkObj( $title, '', 'action=edit' ) . |
| 306 | + Linker::linkKnown( $title, '', array(), array( 'action' => 'edit' ) ) . |
305 | 307 | wfMsg( 'createpage-article-exists2' ); |
306 | 308 | } |
307 | 309 | } |
— | — | @@ -337,7 +339,7 @@ |
338 | 340 | $mainform = new CreatePageCreateplateForm(); |
339 | 341 | $mainform->showForm( $valid ); |
340 | 342 | $editor = new CreatePageMultiEditor( $this->mCreateplate ); |
341 | | - $editor->GenerateForm( $editor->GlueArticle() ); |
| 343 | + $editor->generateForm( $editor->glueArticle() ); |
342 | 344 | return false; |
343 | 345 | } |
344 | 346 | |
— | — | @@ -348,7 +350,7 @@ |
349 | 351 | $editpage = new EditPage( $rarticle ); |
350 | 352 | $editpage->mTitle = $rtitle; |
351 | 353 | $editpage->mArticle = $rarticle; |
352 | | - $editpage->textbox1 = CreateMultiPage::unescapeBlankMarker( $editor->GlueArticle() ); |
| 354 | + $editpage->textbox1 = CreateMultiPage::unescapeBlankMarker( $editor->glueArticle() ); |
353 | 355 | |
354 | 356 | $editpage->minoredit = $wgRequest->getCheck( 'wpMinoredit' ); |
355 | 357 | $editpage->watchthis = $wgRequest->getCheck( 'wpWatchthis' ); |
— | — | @@ -361,14 +363,14 @@ |
362 | 364 | } elseif( $wgRequest->getCheck( 'wpPreview' ) ) { |
363 | 365 | $mainform = new CreatePageCreatePlateForm(); |
364 | 366 | $editor = new CreatePageMultiEditor( $this->mCreateplate, true ); |
365 | | - $content = $editor->GlueArticle( true, false ); |
366 | | - $content_static = $editor->GlueArticle( true ); |
| 367 | + $content = $editor->glueArticle( true, false ); |
| 368 | + $content_static = $editor->glueArticle( true ); |
367 | 369 | $mainform->showForm( '', $content_static ); |
368 | | - $editor->GenerateForm( $content ); |
| 370 | + $editor->generateForm( $content ); |
369 | 371 | return false; |
370 | 372 | } elseif( $wgRequest->getCheck( 'wpAdvancedEdit' ) ) { |
371 | 373 | $editor = new CreatePageMultiEditor( $this->mCreateplate ); |
372 | | - $content = CreateMultiPage::unescapeBlankMarker( $editor->GlueArticle() ); |
| 374 | + $content = CreateMultiPage::unescapeBlankMarker( $editor->glueArticle() ); |
373 | 375 | wfCreatePageUnescapeKnownMarkupTags( $content ); |
374 | 376 | $_SESSION['article_content'] = $content; |
375 | 377 | $wgOut->redirect( |
— | — | @@ -380,8 +382,8 @@ |
381 | 383 | $mainform = new CreatePageCreatePlateForm(); |
382 | 384 | $mainform->showForm( '' ); |
383 | 385 | $editor = new CreatePageMultiEditor( $this->mCreateplate ); |
384 | | - $content = $editor->GlueArticle(); |
385 | | - $editor->GenerateForm( $content ); |
| 386 | + $content = $editor->glueArticle(); |
| 387 | + $editor->generateForm( $content ); |
386 | 388 | } elseif( $wgRequest->getCheck( 'wpCancel' ) ) { |
387 | 389 | if ( $wgRequest->getVal( 'Createtitle' ) != '' ) { |
388 | 390 | $wgOut->redirect( $wgServer . $wgScript . '?title=' . $wgRequest->getVal( 'Createtitle' ) ); |
— | — | @@ -432,6 +434,6 @@ |
433 | 435 | if ( $isInitial ) { |
434 | 436 | $editor->mInitial = true; |
435 | 437 | } |
436 | | - $editor->GenerateForm(); |
| 438 | + $editor->generateForm(); |
437 | 439 | } |
438 | 440 | } |
\ No newline at end of file |
Index: trunk/extensions/CreateAPage/CreateAPage.i18n.php |
— | — | @@ -57,6 +57,9 @@ |
58 | 58 | 'createpage-advanced-edit' => 'advanced editor', |
59 | 59 | 'createpage-optionals-text' => 'Add optional sections:', |
60 | 60 | 'createpage-save' => 'Save', |
| 61 | + 'createpage-must-specify-title' => 'Please specify a title first!', |
| 62 | + 'createpage-unsaved-changes' => 'Unsaved changes', |
| 63 | + 'createpage-unsaved-changes-details' => 'You have unsaved changes. Clicking OK will result in abandoning them.', |
61 | 64 | 'tog-createpage-redlinks' => 'Use <a href="http://www.shoutwiki.com/wiki/Help:CreatePage">CreatePage</a> when following broken links', |
62 | 65 | 'createpage-template-infobox-format' => '/\{\{[^\{\}]*Infobox.*\}\}/is', # regex used to find out whether our template is an infobox or not |
63 | 66 | ); |
— | — | @@ -308,6 +311,9 @@ |
309 | 312 | 'createpage-advanced-edit' => 'kehittynyttä editoria', |
310 | 313 | 'createpage-optionals-text' => 'Lisää vapaaehtoisia osioita:', |
311 | 314 | 'createpage-save' => 'Tallenna', |
| 315 | + 'createpage-must-specify-title' => 'Anna otsikko ensiksi!', |
| 316 | + 'createpage-unsaved-changes' => 'Tallentamattomat muutokset', |
| 317 | + 'createpage-unsaved-changes-details' => 'Sinulla on tallentamattomia muutoksia. Painamalla OK-painiketta hylkäät ne.', |
312 | 318 | 'tog-createpage-redlinks' => 'Käytä <a href="http://fi.shoutwiki.com/wiki/Ohje:CreatePage">CreatePagea</a> rikkinäisiä linkkejä seuratessa', |
313 | 319 | 'createpage-template-infobox-format' => '/\{\{[^\{\}]*tietolaatikko.*\}\}/is', |
314 | 320 | ); |
Index: trunk/extensions/CreateAPage/CreatePage.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * |
7 | 7 | * @file |
8 | 8 | * @ingroup Extensions |
9 | | - * @version 3.80 (r15554) |
| 9 | + * @version 3.90 (r15554) |
10 | 10 | * @author Bartek Łapiński <bartek@wikia-inc.com> |
11 | 11 | * @author Jack Phoenix <jack@countervandalism.net> |
12 | 12 | * @copyright Copyright © 2007-2008 Wikia Inc. |
— | — | @@ -21,8 +21,11 @@ |
22 | 22 | // Extension credits that will show up on Special:Version |
23 | 23 | $wgExtensionCredits['specialpage'][] = array( |
24 | 24 | 'name' => 'CreateAPage', |
25 | | - 'author' => array( 'Bartek Łapiński', 'Łukasz Garczewski', 'Przemek Piotrowski', 'Jack Phoenix' ), |
26 | | - 'version' => '3.80', |
| 25 | + 'author' => array( |
| 26 | + 'Bartek Łapiński', 'Łukasz Garczewski', 'Przemek Piotrowski', |
| 27 | + 'Jack Phoenix' |
| 28 | + ), |
| 29 | + 'version' => '3.90', |
27 | 30 | 'description' => '[[Special:CreatePage|Easy to use interface]] for creating new articles', |
28 | 31 | 'url' => 'http://www.mediawiki.org/wiki/Extension:CreateAPage', |
29 | 32 | ); |
— | — | @@ -47,6 +50,19 @@ |
48 | 51 | // ResourceLoader support for MediaWiki 1.17+ |
49 | 52 | $wgResourceModules['ext.createAPage'] = array( |
50 | 53 | 'styles' => 'CreatePage.css', |
| 54 | + 'scripts' => 'js/CreateAPage.js', |
| 55 | + 'messages' => array( |
| 56 | + 'createpage-insert-image', 'createpage-upload-aborted', |
| 57 | + 'createpage-img-uploaded', 'createpage-login-required', |
| 58 | + 'createpage-login-href', 'createpage-login-required2', |
| 59 | + 'createpage-give-title', 'createpage-img-uploaded', |
| 60 | + 'createpage-article-exists', 'createpage-article-exists2', |
| 61 | + 'createpage-title-invalid', 'createpage-please-wait', |
| 62 | + 'createpage-show', 'createpage-hide', |
| 63 | + 'createpage-must-specify-title', 'createpage-unsaved-changes', |
| 64 | + 'createpage-unsaved-changes-details' |
| 65 | + ), |
| 66 | + 'dependencies' => array( 'jquery.ui', 'jquery.ui.dialog' ), |
51 | 67 | 'localBasePath' => dirname( __FILE__ ), |
52 | 68 | 'remoteExtPath' => 'CreateAPage', |
53 | 69 | 'position' => 'top' // available since r85616 |
— | — | @@ -59,12 +75,14 @@ |
60 | 76 | |
61 | 77 | // Hooked functions |
62 | 78 | $wgHooks['EditPage::showEditForm:initial'][] = 'wfCreatePagePreloadContent'; |
63 | | -$wgHooks['Image::RecordUpload:article'][] = 'wfCreatePageShowNoImagePage'; |
| 79 | +// I'm not sure if this and the related, custom Article class are even needed |
| 80 | +// nowadays, so I'm disabling it for the time being. |
| 81 | +//$wgHooks['Image::RecordUpload:article'][] = 'wfCreatePageShowNoImagePage'; |
64 | 82 | $wgHooks['CustomEditor'][] = 'wfCreatePageRedLinks'; |
65 | 83 | $wgHooks['ConfirmEdit::onConfirmEdit'][] = 'wfCreatePageConfirmEdit'; // ConfirmEdit CAPTCHA |
66 | 84 | |
67 | 85 | if ( $wgCreatePageCoverRedLinks ) { |
68 | | - $wgHooks['UserToggles'][] = 'wfCreatePageToggle'; |
| 86 | + $wgHooks['GetPreferences'][] = 'wfCreatePageToggle'; |
69 | 87 | } |
70 | 88 | |
71 | 89 | // handle ConfirmEdit CAPTCHA, only for CreatePage, which will be treated a bit differently (edits in special page) |
— | — | @@ -93,7 +111,7 @@ |
94 | 112 | $mainform = new CreatePageCreatePlateForm(); |
95 | 113 | $mainform->showForm( '', false, array( &$captcha, 'editCallback' ) ); |
96 | 114 | $editor = new CreatePageMultiEditor( $_SESSION['article_createplate'] ); |
97 | | - $editor->GenerateForm( $newtext ); |
| 115 | + $editor->generateForm( $newtext ); |
98 | 116 | |
99 | 117 | $result = false; |
100 | 118 | return false; |
— | — | @@ -130,15 +148,17 @@ |
131 | 149 | if ( |
132 | 150 | ( $user->getOption( 'createpage-redlinks', 1 ) == 0 ) || |
133 | 151 | !in_array( $namespace, $wgContentNamespaces ) |
134 | | - ) { |
| 152 | + ) |
| 153 | + { |
135 | 154 | return true; |
136 | 155 | } |
137 | 156 | |
138 | 157 | // nomulti should always bypass that (this is for AdvancedEdit mode) |
139 | 158 | if ( |
140 | 159 | $article->getTitle()->exists() || |
141 | | - ( 'nomulti' == $wgRequest->getVal( 'editmode' ) ) |
142 | | - ) { |
| 160 | + ( $wgRequest->getVal( 'editmode' ) == 'nomulti' ) |
| 161 | + ) |
| 162 | + { |
143 | 163 | return true; |
144 | 164 | } else { |
145 | 165 | if ( $wgRequest->getCheck( 'wpPreview' ) ) { |
— | — | @@ -174,4 +194,4 @@ |
175 | 195 | // moved from CreateMultiPage.php |
176 | 196 | function wfCreatePageUnescapeKnownMarkupTags( &$text ) { |
177 | 197 | $text = str_replace( '<!---pipe--->', '|', $text ); |
178 | | -} |
| 198 | +} |
\ No newline at end of file |
Index: trunk/extensions/CreateAPage/SpecialCreatePage_ajax.php |
— | — | @@ -34,16 +34,16 @@ |
35 | 35 | $title = Title::newFromText( "Createplate-{$template}", NS_MEDIAWIKI ); |
36 | 36 | |
37 | 37 | // transfer optional sections data |
38 | | - $optional_sections = array(); |
| 38 | + $optionalSections = array(); |
39 | 39 | foreach( $_POST as $key => $value ) { |
40 | 40 | if( strpos( $key, 'wpOptionalInput' ) !== false ) { |
41 | | - $optional_sections = str_replace( 'wpOptionalInput', '', $key ); |
| 41 | + $optionalSections = str_replace( 'wpOptionalInput', '', $key ); |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | if ( $title->exists() ) { |
46 | 46 | $rev = Revision::newFromTitle( $title ); |
47 | | - $me = CreateMultiPage::multiEditParse( 10, 10, '?', $rev->getText(), $optional_sections ); |
| 47 | + $me = CreateMultiPage::multiEditParse( 10, 10, '?', $rev->getText(), $optionalSections ); |
48 | 48 | } else { |
49 | 49 | $me = CreateMultiPage::multiEditParse( 10, 10, '?', '<!---blanktemplate--->' ); |
50 | 50 | } |
— | — | @@ -131,7 +131,7 @@ |
132 | 132 | |
133 | 133 | $mCreateplate = $wgRequest->getVal( 'createplates' ); |
134 | 134 | $editor = new CreatePageMultiEditor( $mCreateplate ); |
135 | | - $content = CreateMultiPage::unescapeBlankMarker( $editor->GlueArticle() ); |
| 135 | + $content = CreateMultiPage::unescapeBlankMarker( $editor->glueArticle() ); |
136 | 136 | wfCreatePageUnescapeKnownMarkupTags( $content ); |
137 | 137 | $_SESSION['article_content'] = $content; |
138 | 138 | |
Index: trunk/extensions/CreateAPage/js/CreateAPage.js |
— | — | @@ -0,0 +1,1559 @@ |
| 2 | +/** |
| 3 | + * JavaScript for the CreateAPage extension (its Special:CreatePage page). |
| 4 | + * |
| 5 | + * Classes: |
| 6 | + * CreateAPage |
| 7 | + * -main class |
| 8 | + * CreateAPageInfobox |
| 9 | + * -class for uploading images from infoboxes (I think) |
| 10 | + * CreateAPageCategoryTagCloud |
| 11 | + * -class for managing the category tag cloud |
| 12 | + * CreateAPageListeners |
| 13 | + * -a small class used to handle clicking of the "hide/show" link on |
| 14 | + * Special:CreatePage which hides or shows the list of available createplates |
| 15 | + * |
| 16 | + * Rewritten by Jack Phoenix <jack@countervandalism.net> from YUI to jQuery and |
| 17 | + * to be object-oriented in late September/early October 2011. |
| 18 | + * |
| 19 | + * @file |
| 20 | + */ |
| 21 | + |
| 22 | +/** |
| 23 | + * @file |
| 24 | + */ |
| 25 | +var CreateAPageListeners = { |
| 26 | + /** |
| 27 | + * @param e Event |
| 28 | + * @param data Array: [ div, link ] |
| 29 | + */ |
| 30 | + toggle: function( e, data ) { |
| 31 | + e.preventDefault(); |
| 32 | + var display = '', text = '', opacity; |
| 33 | + |
| 34 | + if ( jQuery( '#' + data[0] ).css( 'display' ) !== 'none' ) { |
| 35 | + display = 'none'; |
| 36 | + text = mw.msg( 'createpage-show' ); |
| 37 | + opacity = 0; |
| 38 | + |
| 39 | + jQuery( '#' + data[0] ).fadeIn( 5000, function() { |
| 40 | + jQuery( '#' + data[0] ).css( 'display', display ); |
| 41 | + jQuery( '#' + data[1] ).text( text ); |
| 42 | + }); |
| 43 | + } else { |
| 44 | + display = 'block'; |
| 45 | + text = mw.msg( 'createpage-hide' ); |
| 46 | + opacity = 1; |
| 47 | + |
| 48 | + jQuery( '#' + data[0] ).css( 'opacity', opacity ); |
| 49 | + jQuery( '#' + data[0] ).css( 'display', display ); |
| 50 | + |
| 51 | + jQuery( '#' + data[1] ).text( text ); |
| 52 | + } |
| 53 | + } |
| 54 | +}; |
| 55 | + |
| 56 | +/** |
| 57 | + * A class for managing the category tag cloud. |
| 58 | + */ |
| 59 | +var CreateAPageCategoryTagCloud = { |
| 60 | + add: function( category, num ) { // previously cloudAdd |
| 61 | + var category_text = document.getElementById( 'wpCategoryTextarea' ); |
| 62 | + |
| 63 | + if ( category_text.value === '' ) { |
| 64 | + category_text.value += unescape( category ); |
| 65 | + } else { |
| 66 | + category_text.value += '|' + unescape( category ); |
| 67 | + } |
| 68 | + |
| 69 | + var this_button = document.getElementById( 'cloud' + num ); |
| 70 | + this_button.onclick = function() { |
| 71 | + this.remove( category, num ); |
| 72 | + return false; |
| 73 | + }; |
| 74 | + this_button.style.color = '#419636'; |
| 75 | + return false; |
| 76 | + }, |
| 77 | + |
| 78 | + build: function( o ) { // previously cloudBuild |
| 79 | + var categories = o.value; |
| 80 | + var new_text = ''; |
| 81 | + |
| 82 | + categories = categories.split( '|' ); |
| 83 | + for ( var i = 0; i < categories.length; i++ ) { |
| 84 | + if ( categories[i] !== '' ) { |
| 85 | + new_text += '[[' + wgFormattedNamespaces[14] + ':' + |
| 86 | + categories[i] + ']]'; |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | + return new_text; |
| 91 | + }, |
| 92 | + |
| 93 | + inputAdd: function() { // previously cloudInputAdd |
| 94 | + var category_input = document.getElementById( 'wpCategoryInput' ); |
| 95 | + var category_text = document.getElementById( 'wpCategoryTextarea' ); |
| 96 | + var category = category_input.value; |
| 97 | + if ( category_input.value !== '' ) { |
| 98 | + if ( category_text.value === '' ) { |
| 99 | + category_text.value += unescape( category ); |
| 100 | + } else { |
| 101 | + category_text.value += '|' + unescape( category ); |
| 102 | + } |
| 103 | + category_input.value = ''; |
| 104 | + var c_found = false; |
| 105 | + var core_cat = category.replace( /\|.*/, '' ); |
| 106 | + for ( var j in CreateAPage.foundCategories ) { |
| 107 | + if ( CreateAPage.foundCategories[j] === core_cat ) { |
| 108 | + var this_button = document.getElementById( 'cloud' + j ); |
| 109 | + var actual_cloud = CreateAPage.foundCategories[j]; |
| 110 | + var cl_num = j; |
| 111 | + |
| 112 | + this_button.onclick = CreateAPage.onclickCategoryFn( core_cat, j ); |
| 113 | + this_button.style.color = '#419636'; |
| 114 | + c_found = true; |
| 115 | + break; |
| 116 | + } |
| 117 | + } |
| 118 | + if ( !c_found ) { |
| 119 | + var n_cat = document.createElement( 'a' ); |
| 120 | + var s_cat = document.createElement( 'span' ); |
| 121 | + var n_cat_count = CreateAPage.foundCategories.length; |
| 122 | + |
| 123 | + var cat_full_section = document.getElementById( 'createpage_cloud_section' ); |
| 124 | + var cat_num = n_cat_count; |
| 125 | + n_cat.setAttribute( 'id', 'cloud' + cat_num ); |
| 126 | + n_cat.setAttribute( 'href', '#' ); |
| 127 | + n_cat.onclick = CreateAPage.onclickCategoryFn( core_cat, cat_num ); |
| 128 | + n_cat.style.color = '#419636'; |
| 129 | + n_cat.style.fontSize = '10pt'; |
| 130 | + s_cat.setAttribute( 'id', 'tag' + cat_num ); |
| 131 | + var t_cat = document.createTextNode( core_cat ); |
| 132 | + var space = document.createTextNode( ' ' ); |
| 133 | + n_cat.appendChild( t_cat ); |
| 134 | + s_cat.appendChild( n_cat ); |
| 135 | + s_cat.appendChild( space ); |
| 136 | + cat_full_section.appendChild( s_cat ); |
| 137 | + CreateAPage.foundCategories[n_cat_count] = core_cat; |
| 138 | + } |
| 139 | + } |
| 140 | + }, |
| 141 | + |
| 142 | + remove: function( category, num ) { // previously cloudRemove |
| 143 | + var category_text = document.getElementById( 'wpCategoryTextarea' ); |
| 144 | + var this_pos = category_text.value.indexOf( unescape( category ) ); |
| 145 | + if ( this_pos !== -1 ) { |
| 146 | + category_text.value = category_text.value.substr( 0, this_pos - 1 ) + |
| 147 | + category_text.value.substr( this_pos + unescape( category ).length ); |
| 148 | + } |
| 149 | + var this_button = document.getElementById( 'cloud' + num ); |
| 150 | + this_button.onclick = function() { |
| 151 | + this.add( category, num ); |
| 152 | + return false; |
| 153 | + }; |
| 154 | + this_button.style.color = ''; |
| 155 | + return false; |
| 156 | + } |
| 157 | +}; |
| 158 | + |
| 159 | +var CreateAPage = { |
| 160 | + noCanDo: false, |
| 161 | + submitEnabled: false, |
| 162 | + |
| 163 | + disabledCr: false, |
| 164 | + |
| 165 | + toolbarButtons: [], |
| 166 | + |
| 167 | + multiEditTextboxes: [], |
| 168 | + multiEditButtons: [], |
| 169 | + multiEditCustomButtons: [], |
| 170 | + |
| 171 | + foundCategories: [], |
| 172 | + |
| 173 | + myId: 0, |
| 174 | + //previewMode: '<?php echo !$ispreview ? 'No' : 'Yes' ?>'; |
| 175 | + //redLinkMode: '<?php echo !$isredlink ? 'No' : 'Yes' ?>'; |
| 176 | + |
| 177 | + /** |
| 178 | + * Copy of CreatePageNormalEdit from extensions/wikiwyg/share/MediaWiki/extensions/CreatePage/js/createpage.js |
| 179 | + * with a few tweaks (the textarea stuff + i18n). |
| 180 | + * Asks the user for a confirmation if they want to discard all changes |
| 181 | + * done via Special:CreatePage and if the answer is yes, takes them to |
| 182 | + * ?action=edit (normal edit mode). |
| 183 | + */ |
| 184 | + goToNormalEditMode: function() { |
| 185 | + var title = document.getElementById( 'title' ); |
| 186 | + var errorMsg = document.getElementById( 'createpage_messenger' ); |
| 187 | + |
| 188 | + if ( title.value === '' ) { |
| 189 | + errorMsg.innerHTML = mw.msg( 'createpage-must-specify-title' ); |
| 190 | + errorMsg.style.display = ''; |
| 191 | + return; |
| 192 | + } |
| 193 | + |
| 194 | + /* check for unsaved changes (they will always be *unsaved* here... ) */ |
| 195 | + // @todo CHECKME |
| 196 | + var textarea; |
| 197 | + var edit_textareas = CreateAPage.getElementsBy( |
| 198 | + CreateAPage.editTextareaTest, |
| 199 | + 'textarea', |
| 200 | + document.getElementById( 'wpTableMultiEdit' ), |
| 201 | + CreateAPage.textareaAddToolbar |
| 202 | + ); |
| 203 | + |
| 204 | + if ( edit_textareas[0].id === 'wpTextboxes0' ) { |
| 205 | + textarea = edit_textareas[0]; |
| 206 | + textarea = textarea.replace( '<br>', '' ); |
| 207 | + } |
| 208 | + |
| 209 | + if ( textarea !== '' ) { |
| 210 | + var abandonChanges = confirm( |
| 211 | + mw.msg( 'createpage-unsaved-changes-details' ), |
| 212 | + mw.msg( 'createpage-unsaved-changes' ) |
| 213 | + ); |
| 214 | + |
| 215 | + if ( !abandonChanges ) { |
| 216 | + return; |
| 217 | + } |
| 218 | + } |
| 219 | + |
| 220 | + var fixedArticlePath = wgArticlePath.replace( '$1', '' ); |
| 221 | + fixedArticlePath = fixedArticlePath.replace( 'index.php[^\/]', 'index.php?title=' ); |
| 222 | + |
| 223 | + window.location = fixedArticlePath + title.value + '?action=edit'; |
| 224 | + }, |
| 225 | + |
| 226 | + callbackTitle: function( data ) { |
| 227 | + var res = '', helperButton; |
| 228 | + document.getElementById( 'cp-title-check' ).innerHTML = ''; |
| 229 | + if( /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test( data ) ) { |
| 230 | + res = eval( '(' + data + ')' ); |
| 231 | + } |
| 232 | + if ( ( res['text'] !== false ) && ( res['empty'] !== true ) ) { |
| 233 | + var url = res['url'].replace( /&/g, '&' ).replace( /</g, '<' ).replace( />/g, '>' ); |
| 234 | + var text = res['text'].replace( /&/g, '&' ).replace( /</g, '<' ).replace( />/g, '>' ); |
| 235 | + |
| 236 | + document.getElementById( 'cp-title-check' ).innerHTML = '<span style="color: red;">' + |
| 237 | + mw.msg( 'createpage-article-exists' ) + ' <a href="' + |
| 238 | + url + '?action=edit" title="' + text + '">' + text + |
| 239 | + '</a>' + mw.msg( 'createpage-article-exists2' ) + '</span>'; |
| 240 | + if ( CreateAPage.Overlay ) { |
| 241 | + CreateAPage.Overlay.show(); // @todo FIXME |
| 242 | + helperButton = document.getElementById( 'wpRunInitialCheck' ); |
| 243 | + helperButton.style.display = ''; |
| 244 | + } else { |
| 245 | + CreateAPage.contentOverlay(); |
| 246 | + } |
| 247 | + } else if ( res['empty'] === true ) { |
| 248 | + document.getElementById( 'cp-title-check' ).innerHTML = |
| 249 | + '<span style="color: red;">' + |
| 250 | + mw.msg( 'createpage-title-invalid' ) + |
| 251 | + '</span>'; |
| 252 | + if ( CreateAPage.Overlay ) { |
| 253 | + CreateAPage.resizeOverlay( 0 ); |
| 254 | + CreateAPage.Overlay.show(); // @todo FIXME |
| 255 | + helperButton = document.getElementById( 'wpRunInitialCheck' ); |
| 256 | + helperButton.style.display = ''; |
| 257 | + } else { |
| 258 | + CreateAPage.contentOverlay(); |
| 259 | + } |
| 260 | + } else { |
| 261 | + if ( CreateAPage.Overlay ) { |
| 262 | + CreateAPage.Overlay.hide(); // @todo FIXME |
| 263 | + helperButton = document.getElementById( 'wpRunInitialCheck' ); |
| 264 | + helperButton.style.display = 'none'; |
| 265 | + } |
| 266 | + } |
| 267 | + CreateAPage.noCanDo = false; |
| 268 | + }, |
| 269 | + |
| 270 | + /** |
| 271 | + * The name of this function is misleading and as such it should be renamed |
| 272 | + * one day. |
| 273 | + * |
| 274 | + * In any case, this function gets called whenever the user inputs |
| 275 | + * something on the "Article Title" input on Special:CreatePage and moves |
| 276 | + * the cursor elsewhere on the page or presses the "Proceed to edit" button. |
| 277 | + * This function then shows a progress bar image and checks whether there |
| 278 | + * is or isn't a page with the given title. |
| 279 | + * |
| 280 | + * If there isn't a page with the given title, the overlay on the editor is |
| 281 | + * removed. |
| 282 | + * If such a page however exists, a red error message ("This article |
| 283 | + * already exists. Edit <article name> or specify another title.") is shown |
| 284 | + * to the user. |
| 285 | + */ |
| 286 | + watchTitle: function() { |
| 287 | + document.getElementById( 'cp-title-check' ).innerHTML = |
| 288 | + '<img src="' + wgServer + wgScriptPath + |
| 289 | + '/extensions/CreateAPage/images/progress_bar.gif" width="70" height="11" alt="' + |
| 290 | + mw.msg( 'createpage-please-wait' ) + '" border="0" />'; |
| 291 | + CreateAPage.noCanDo = true; |
| 292 | + |
| 293 | + jQuery.ajax({ // using .ajax instead of .get for better flexibility |
| 294 | + url: wgScript, |
| 295 | + data: { |
| 296 | + action: 'ajax', |
| 297 | + rs: 'axTitleExists', |
| 298 | + title: document.getElementById( 'Createtitle' ).value |
| 299 | + }, |
| 300 | + success: function( data, textStatus, jqXHR ) { |
| 301 | + CreateAPage.callbackTitle( data ); |
| 302 | + }, |
| 303 | + error: function( jqXHR, textStatus, errorThrown ) { |
| 304 | + document.getElementById( 'cp-title-check' ).innerHTML = ''; |
| 305 | + } |
| 306 | + }); |
| 307 | + }, |
| 308 | + |
| 309 | + clearInput: function( o ) { |
| 310 | + var cDone = false; |
| 311 | + jQuery( '#wpInfoboxPar' + o.num ).bind( 'focus', function() { |
| 312 | + var previewarea = jQuery( '#createpagepreview' ); |
| 313 | + if ( !cDone && ( previewarea === null ) ) { |
| 314 | + cDone = true; |
| 315 | + document.getElementById( 'wpInfoboxPar' + o.num ).value = ''; |
| 316 | + } |
| 317 | + }); |
| 318 | + }, |
| 319 | + |
| 320 | + goToEdit: function( e ) { |
| 321 | + e.preventDefault(); |
| 322 | + jQuery.post( |
| 323 | + wgScript,//mw.config.get( 'wgScript' ), |
| 324 | + { |
| 325 | + action: 'ajax', |
| 326 | + rs: 'axCreatepageAdvancedSwitch' |
| 327 | + }, |
| 328 | + function( data ) { |
| 329 | + window.location = wgServer + wgScript + '?title=' + |
| 330 | + encodeURIComponent( document.getElementById( 'Createtitle' ).value ) + |
| 331 | + '&action=edit&editmode=nomulti&createpage=true'; |
| 332 | + } |
| 333 | + ); |
| 334 | + CreateAPage.warningPanel.hide(); // @todo FIXME |
| 335 | + }, |
| 336 | + |
| 337 | + goToLogin: function( e ) { |
| 338 | + e.preventDefault(); |
| 339 | + if ( CreateAPage.redLinkMode ) { |
| 340 | + window.location = wgServer + wgScript + |
| 341 | + '?title=Special:UserLogin&returnto=' + |
| 342 | + encodeURIComponent( document.getElementById( 'Createtitle' ).value ); |
| 343 | + } else { |
| 344 | + window.location = wgServer + wgScript + |
| 345 | + '?title=Special:UserLogin&returnto=Special:CreatePage'; |
| 346 | + } |
| 347 | + }, |
| 348 | + |
| 349 | + hideWarningPanel: function( e ) { |
| 350 | + if ( CreateAPage.warningPanel ) { |
| 351 | + CreateAPage.warningPanel.hide(); // @todo FIXME |
| 352 | + } |
| 353 | + }, |
| 354 | + |
| 355 | + showWarningPanel: function( e ) { |
| 356 | + e.preventDefault(); |
| 357 | + if ( document.getElementById( 'Createtitle' ).value !== '' ) { |
| 358 | + if ( !CreateAPage.warningPanel ) { |
| 359 | + CreateAPage.buildWarningPanel(); |
| 360 | + } |
| 361 | + CreateAPage.warningPanel.show(); // @todo FIXME |
| 362 | + jQuery( '#wpCreatepageWarningYes' ).focus(); |
| 363 | + } else { |
| 364 | + jQuery( '#cp-title-check' ).html( |
| 365 | + '<span style="color: red;">' + |
| 366 | + mw.msg( 'createpage-give-title' ) + |
| 367 | + '</span>' |
| 368 | + ); |
| 369 | + } |
| 370 | + }, |
| 371 | + |
| 372 | + hideWarningLoginPanel: function( e ) { |
| 373 | + if ( CreateAPage.warningLoginPanel ) { |
| 374 | + CreateAPage.warningLoginPanel.hide(); // @todo FIXME |
| 375 | + } |
| 376 | + }, |
| 377 | + |
| 378 | + showWarningLoginPanel: function( e ) { |
| 379 | + e.preventDefault(); |
| 380 | + if ( document.getElementById( 'Createtitle' ).value !== '' ) { |
| 381 | + if ( !CreateAPage.warningLoginPanel ) { |
| 382 | + CreateAPage.buildWarningLoginPanel( e ); |
| 383 | + } |
| 384 | + CreateAPage.warningLoginPanel.show(); |
| 385 | + jQuery( '#wpCreatepageWarningYes' ).focus(); |
| 386 | + } else { |
| 387 | + jQuery( '#cp-title-check' ).html( |
| 388 | + '<span style="color: red;">' + |
| 389 | + mw.msg( 'createpage-give-title' ) + |
| 390 | + '</span>' |
| 391 | + ); |
| 392 | + } |
| 393 | + }, |
| 394 | + |
| 395 | + uploadCallback: function( oResponse ) { |
| 396 | + var aResponse = []; // initialize it as an empty array so that JSHint can STFU |
| 397 | + if( /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test( oResponse.responseText ) ) { |
| 398 | + aResponse = eval( '(' + oResponse.responseText + ')' ); |
| 399 | + } |
| 400 | + var ProgressBar = document.getElementById( 'createpage_upload_progress_section' + aResponse['num'] ); |
| 401 | + |
| 402 | + if ( aResponse['error'] !== 1 ) { |
| 403 | + ProgressBar.innerHTML = mw.msg( 'createpage-img-uploaded' ); |
| 404 | + var target_info = document.getElementById( 'wpAllUploadTarget' + aResponse['num'] ).value; |
| 405 | + var target_tag = jQuery( target_info ); |
| 406 | + target_tag.value = '[[' + aResponse['msg'] + '|thumb]]'; |
| 407 | + |
| 408 | + var ImageThumbnail = document.getElementById( 'createpage_image_thumb_section' + aResponse['num'] ); |
| 409 | + var thumb_container = document.getElementById( 'createpage_main_thumb_section' + aResponse['num'] ); |
| 410 | + var tempstamp = new Date(); |
| 411 | + ImageThumbnail.src = aResponse['url'] + '?' + tempstamp.getTime(); |
| 412 | + if ( document.getElementById( 'wpAllLastTimestamp' + aResponse['num'] ).value === 'None' ) { |
| 413 | + var break_tag = document.createElement( 'br' ); |
| 414 | + thumb_container.style.display = ''; |
| 415 | + var label_node = document.getElementById( 'createpage_image_label_section' + aResponse['num'] ); |
| 416 | + var par_node = label_node.parentNode; |
| 417 | + par_node.insertBefore( break_tag, label_node ); |
| 418 | + } |
| 419 | + document.getElementById( 'wpAllLastTimestamp' + oResponse.argument ).value = aResponse['timestamp']; |
| 420 | + } else if ( ( aResponse['error'] === 1 ) && ( aResponse['msg'] === 'cp_no_login' ) ) { |
| 421 | + // @todo FIXME: oh my fucking god this is UGLY |
| 422 | + ProgressBar.innerHTML = '<span style="color: red">' + |
| 423 | + mw.msg( 'createpage-login-required' ) + |
| 424 | + '<a href="' + wgServer + wgScript +'?title=Special:Userlogin&returnto=Special:Createpage" id="createpage_login' + |
| 425 | + oResponse.argument + '">' + |
| 426 | + mw.msg( 'createpage-login-href' ) + '</a>' + |
| 427 | + mw.msg( 'createpage-login-required2' ) + |
| 428 | + '</span>'; |
| 429 | + jQuery( '#createpage_login' + oResponse.argument ).click( function( e ) { |
| 430 | + CreateAPage.showWarningLoginPanel( e ); |
| 431 | + }); |
| 432 | + } else { |
| 433 | + ProgressBar.innerHTML = '<span style="color: red">' + aResponse['msg'] + '</span>'; |
| 434 | + } |
| 435 | + |
| 436 | + document.getElementById( 'createpage_image_text_section' + oResponse.argument ).innerHTML = mw.msg( 'createpage-insert-image' ); |
| 437 | + document.getElementById( 'createpage_upload_file_section' + oResponse.argument ).style.display = ''; |
| 438 | + document.getElementById( 'createpage_image_text_section' + oResponse.argument ).style.display = ''; |
| 439 | + document.getElementById( 'createpage_image_cancel_section' + oResponse.argument ).style.display = 'none'; |
| 440 | + }, |
| 441 | + |
| 442 | + failureCallback: function( response ) { |
| 443 | + document.getElementById( 'createpage_image_text_section' + response.argument ).innerHTML = mw.msg( 'createpage-insert-image' ); |
| 444 | + document.getElementById( 'createpage_upload_progress_section' + response.argument ).innerHTML = mw.msg( 'createpage-upload-aborted' ); |
| 445 | + document.getElementById( 'createpage_upload_file_section' + response.argument ).style.display = ''; |
| 446 | + document.getElementById( 'createpage_image_text_section' + response.argument ).style.display = ''; |
| 447 | + document.getElementById( 'createpage_image_cancel_section' + response.argument ).style.display = 'none'; |
| 448 | + }, |
| 449 | + |
| 450 | + restoreSection: function( section, text ) { |
| 451 | + var sectionContent = CreateAPage.getElementsBy( |
| 452 | + CreateAPage.optionalContentTest, '', section |
| 453 | + ); |
| 454 | + for( var i = 0; i < sectionContent.length; i++ ) { |
| 455 | + text = text.replace( sectionContent[i].id, '' ); |
| 456 | + } |
| 457 | + section.style.display = 'block'; |
| 458 | + return text; |
| 459 | + }, |
| 460 | + |
| 461 | + unuseSection: function( section, text ) { |
| 462 | + var sectionContent = CreateAPage.getElementsBy( |
| 463 | + CreateAPage.optionalContentTest, '', section |
| 464 | + ); |
| 465 | + var first = true; |
| 466 | + var ivalue = ''; |
| 467 | + |
| 468 | + for( var i = 0; i < sectionContent.length; i++ ) { |
| 469 | + if ( first ) { |
| 470 | + if ( text !== '' ) { |
| 471 | + ivalue += ','; |
| 472 | + } |
| 473 | + first = false; |
| 474 | + } else { |
| 475 | + ivalue += ','; |
| 476 | + } |
| 477 | + ivalue += sectionContent[i].id; |
| 478 | + } |
| 479 | + |
| 480 | + section.style.display = 'none'; |
| 481 | + |
| 482 | + return text + ivalue; |
| 483 | + }, |
| 484 | + |
| 485 | + toggleSection: function( e, o ) { |
| 486 | + var section = document.getElementById( 'createpage_section_' + o.num ); |
| 487 | + var input = document.getElementById( 'wpOptionalInput' + o.num ); |
| 488 | + var optionals = document.getElementById( 'wpOptionals' ); |
| 489 | + var ivalue = ''; |
| 490 | + if ( input.checked ) { |
| 491 | + optionals.value = CreateAPage.restoreSection( section, optionals.value ); |
| 492 | + } else { |
| 493 | + optionals.value = CreateAPage.unuseSection( section, optionals.value ); |
| 494 | + } |
| 495 | + }, |
| 496 | + |
| 497 | + upload: function( e, o ) { |
| 498 | + var oForm = document.getElementById( 'createpageform' ); |
| 499 | + e.preventDefault(); |
| 500 | + |
| 501 | + var ProgressBar = document.getElementById( 'createpage_upload_progress_section' + o.num ); |
| 502 | + ProgressBar.style.display = 'block'; |
| 503 | + ProgressBar.innerHTML = '<img src="' + stylepath + |
| 504 | + '/common/images/spinner.gif" width="16" height="16" alt="' + |
| 505 | + mw.msg( 'createpage-please-wait' ) + '" border="0" /> '; |
| 506 | + |
| 507 | + var sent_request = jQuery.ajax({ // using .ajax instead of .post for better flexibility |
| 508 | + type: 'POST', |
| 509 | + url: wgScript, |
| 510 | + data: { |
| 511 | + action: 'ajax', |
| 512 | + rs: 'axMultiEditImageUpload', |
| 513 | + infix: 'All', |
| 514 | + num: o.num |
| 515 | + }, |
| 516 | + success: function( data, textStatus, jqXHR ) { |
| 517 | + // @todo FIXME/CHECKME: make sure that the num (o.num) is passed as response.argument to uploadCallback |
| 518 | + CreateAPageInfobox.uploadCallback( jqXHR ); |
| 519 | + }, |
| 520 | + error: function( jqXHR, textStatus, errorThrown ) { |
| 521 | + CreateAPageInfobox.failureCallback( jqXHR ); |
| 522 | + }, |
| 523 | + timeout: 240000 |
| 524 | + }); |
| 525 | + document.getElementById( 'createpage_image_cancel_section' + o.num ).style.display = ''; |
| 526 | + document.getElementById( 'createpage_image_text_section' + o.num ).style.display = 'none'; |
| 527 | + |
| 528 | + jQuery( '#createpage_image_cancel_section' + o.num ).click( function( e ) { |
| 529 | + sent_request.abort(); |
| 530 | + }); |
| 531 | + |
| 532 | + var neoInput = document.createElement( 'input' ); |
| 533 | + var thisInput = document.getElementById( 'createpage_upload_file_section' + o.num ); |
| 534 | + var thisContainer = document.getElementById( 'createpage_image_label_section' + o.num ); |
| 535 | + thisContainer.removeChild( thisInput ); |
| 536 | + |
| 537 | + neoInput.setAttribute( 'type', 'file' ); |
| 538 | + neoInput.setAttribute( 'id', 'createpage_upload_file_section' + o.num ); |
| 539 | + neoInput.setAttribute( 'name', 'wpAllUploadFile' + o.num ); |
| 540 | + neoInput.setAttribute( 'tabindex', '-1' ); |
| 541 | + |
| 542 | + thisContainer.appendChild( neoInput ); |
| 543 | + jQuery( '#createpage_upload_file_section' + o.num ).change( function( e ) { |
| 544 | + CreateAPage.upload( e, { 'num': o.num } ); |
| 545 | + }); |
| 546 | + |
| 547 | + document.getElementById( 'createpage_upload_file_section' + o.num ).style.display = 'none'; |
| 548 | + }, |
| 549 | + |
| 550 | + buildWarningPanel: function( e ) { |
| 551 | + var editwarn = document.getElementById( 'createpage_advanced_warning' ); |
| 552 | + var editwarn_copy = document.createElement( 'div' ); |
| 553 | + editwarn_copy.id = 'createpage_warning_copy'; |
| 554 | + editwarn_copy.innerHTML = editwarn.innerHTML; |
| 555 | + document.body.appendChild( editwarn_copy ); |
| 556 | + |
| 557 | + CreateAPage.warningPanel = jQuery( '#createpage_warning_copy' ).dialog({ |
| 558 | + draggable: false, |
| 559 | + modal: true, |
| 560 | + resizable: false, |
| 561 | + width: 250 |
| 562 | + }); |
| 563 | + /* |
| 564 | + CreateAPage.warningPanel = new YAHOO.widget.Panel( 'createpage_warning_copy', { |
| 565 | + width: '250px', |
| 566 | + modal: true, |
| 567 | + constraintoviewport: true, |
| 568 | + draggable: false, |
| 569 | + fixedcenter: true, |
| 570 | + underlay: 'none' |
| 571 | + } ); |
| 572 | + CreateAPage.warningPanel.cfg.setProperty( 'zIndex', 1000 ); |
| 573 | + CreateAPage.warningPanel.render( document.body ); |
| 574 | + */ |
| 575 | + |
| 576 | + jQuery( '#wpCreatepageWarningYes' ).click( function( e ) { |
| 577 | + CreateAPage.goToEdit( e ); |
| 578 | + }); |
| 579 | + jQuery( '#wpCreatepageWarningNo' ).click( function( e ) { |
| 580 | + CreateAPage.hideWarningPanel( e ); |
| 581 | + }); |
| 582 | + }, |
| 583 | + |
| 584 | + buildWarningLoginPanel: function( e ) { |
| 585 | + var editwarn = document.getElementById( 'createpage_advanced_warning' ); |
| 586 | + var editwarn_copy = document.createElement( 'div' ); |
| 587 | + editwarn_copy.id = 'createpage_warning_copy2'; |
| 588 | + editwarn_copy.innerHTML = editwarn.innerHTML; |
| 589 | + editwarn_copy.childNodes[1].innerHTML = mw.msg( 'login' ); |
| 590 | + editwarn_copy.childNodes[3].innerHTML = mw.msg( 'createpage-login-warning' ); |
| 591 | + document.body.appendChild( editwarn_copy ); |
| 592 | + |
| 593 | + CreateAPage.warningLoginPanel = jQuery( '#createpage_warning_copy2' ).dialog({ |
| 594 | + draggable: false, |
| 595 | + modal: true, |
| 596 | + resizable: false, |
| 597 | + width: 250 |
| 598 | + }); |
| 599 | + /* |
| 600 | + CreateAPage.warningLoginPanel = new YAHOO.widget.Panel( 'createpage_warning_copy2', { |
| 601 | + width: '250px', |
| 602 | + modal: true, |
| 603 | + constraintoviewport: true, |
| 604 | + draggable: false, |
| 605 | + fixedcenter: true, |
| 606 | + underlay: 'none' |
| 607 | + } ); |
| 608 | + CreateAPage.warningLoginPanel.cfg.setProperty( 'zIndex', 1000 ); |
| 609 | + CreateAPage.warningLoginPanel.render( document.body ); |
| 610 | + */ |
| 611 | + |
| 612 | + jQuery( '#wpCreatepageWarningYes' ).click( function( e ) { |
| 613 | + CreateAPage.goToLogin( e ); |
| 614 | + }); |
| 615 | + jQuery( '#wpCreatepageWarningNo' ).click( function( e ) { |
| 616 | + CreateAPage.hideWarningLoginPanel( e ); |
| 617 | + }); |
| 618 | + }, |
| 619 | + |
| 620 | + onclickCategoryFn: function( cat, id ) { |
| 621 | + return function() { |
| 622 | + CreateAPageCategoryTagCloud.remove( escape( cat ), id ); |
| 623 | + return false; |
| 624 | + }; |
| 625 | + }, |
| 626 | + |
| 627 | + /** |
| 628 | + * Remove any and all "This article already exists" messages. |
| 629 | + * |
| 630 | + * @param e Event |
| 631 | + */ |
| 632 | + clearTitleMessage: function( e ) { |
| 633 | + e.preventDefault(); |
| 634 | + document.getElementById( 'cp-title-check' ).innerHTML = ''; |
| 635 | + }, |
| 636 | + |
| 637 | + /** |
| 638 | + * Test whether the given element's ID matches createpage_upload_file_section |
| 639 | + * or not. |
| 640 | + * |
| 641 | + * @param el Element HTML element to test |
| 642 | + * @return Boolean: true if the element's ID matches, else false |
| 643 | + */ |
| 644 | + uploadTest: function( el ) { |
| 645 | + if ( el.id.match( 'createpage_upload_file_section' ) ) { |
| 646 | + return true; |
| 647 | + } else { |
| 648 | + return false; |
| 649 | + } |
| 650 | + }, |
| 651 | + |
| 652 | + /** |
| 653 | + * Test whether the given element's ID matches wpTextboxes and that it's |
| 654 | + * visible (i.e. display != none). |
| 655 | + * |
| 656 | + * @param el Element HTML element to test |
| 657 | + * @return Boolean: true if the element's ID matches, else false |
| 658 | + */ |
| 659 | + editTextareaTest: function( el ) { |
| 660 | + if ( el.id.match( 'wpTextboxes' ) && ( el.style.display !== 'none' ) ) { |
| 661 | + return true; |
| 662 | + } else { |
| 663 | + return false; |
| 664 | + } |
| 665 | + }, |
| 666 | + |
| 667 | + /** |
| 668 | + * Test whether the given element's ID matches wpOptionalInput and that |
| 669 | + * it's visible (i.e. display != none). |
| 670 | + * |
| 671 | + * @param el Element HTML element to test |
| 672 | + * @return Boolean: true if the element's ID matches, else false |
| 673 | + */ |
| 674 | + optionalSectionTest: function( el ) { |
| 675 | + if ( el.id.match( 'wpOptionalInput' ) && ( el.style.display !== 'none' ) ) { |
| 676 | + return true; |
| 677 | + } else { |
| 678 | + return false; |
| 679 | + } |
| 680 | + }, |
| 681 | + |
| 682 | + /** |
| 683 | + * Test whether the given element's ID matches wpTextboxes. |
| 684 | + * |
| 685 | + * @param el Element HTML element to test |
| 686 | + * @return Boolean: true if the element's ID matches, else false |
| 687 | + */ |
| 688 | + optionalContentTest: function( el ) { |
| 689 | + if ( el.id.match( 'wpTextboxes' ) ) { |
| 690 | + return true; |
| 691 | + } else { |
| 692 | + return false; |
| 693 | + } |
| 694 | + }, |
| 695 | + |
| 696 | + uploadEvent: function( el ) { |
| 697 | + var j = parseInt( el.id.replace( 'createpage_upload_file_section', '' ) ); |
| 698 | + jQuery( '#createpage_upload_file_section' + j ).change( function( e ) { |
| 699 | + CreateAPage.upload( e, { num : j } ); |
| 700 | + }); |
| 701 | + }, |
| 702 | + |
| 703 | + textareaAddToolbar: function( el ) { |
| 704 | + var el_id = parseInt( el.id.replace( 'wpTextboxes', '' ) ); |
| 705 | + CreateAPage.multiEditTextboxes[CreateAPage.multiEditTextboxes.length] = el_id; |
| 706 | + CreateAPage.multiEditButtons[el_id] = []; |
| 707 | + CreateAPage.multiEditCustomButtons[el_id] = []; |
| 708 | + |
| 709 | + jQuery( '#' + el.id ).focus( function( e ) { |
| 710 | + CreateAPage.showThisBox( e, { 'toolbarId': el_id } ); |
| 711 | + }); |
| 712 | + |
| 713 | + jQuery( '#wpTextIncrease' + el_id ).click( function( e ) { |
| 714 | + CreateAPage.resizeThisTextarea( e, { 'textareaId': el_id, 'numRows': 1 } ); |
| 715 | + }); |
| 716 | + jQuery( '#wpTextDecrease' + el_id ).click( function( e ) { |
| 717 | + CreateAPage.resizeThisTextarea( e, { 'textareaId': el_id, 'numRows': -1 } ); |
| 718 | + }); |
| 719 | + |
| 720 | + for ( var i = 0; i < CreateAPage.toolbarButtons.length; i++ ) { |
| 721 | + CreateAPage.addMultiEditButton( |
| 722 | + CreateAPage.toolbarButtons[i]['image'], |
| 723 | + CreateAPage.toolbarButtons[i]['tip'], |
| 724 | + CreateAPage.toolbarButtons[i]['open'], |
| 725 | + CreateAPage.toolbarButtons[i]['close'], |
| 726 | + CreateAPage.toolbarButtons[i]['sample'], |
| 727 | + CreateAPage.toolbarButtons[i]['id'] + el_id, |
| 728 | + el_id |
| 729 | + ); |
| 730 | + } |
| 731 | + }, |
| 732 | + |
| 733 | + checkCategoryCloud: function() { |
| 734 | + var cat_textarea = document.getElementById( 'wpCategoryTextarea' ); |
| 735 | + if ( !cat_textarea ) { |
| 736 | + return; |
| 737 | + } |
| 738 | + |
| 739 | + var cat_full_section = document.getElementById( 'createpage_cloud_section' ); |
| 740 | + |
| 741 | + var cloud_num = ( cat_full_section.childNodes.length - 1 ) / 2; |
| 742 | + var n_cat_count = cloud_num; |
| 743 | + var text_categories = []; |
| 744 | + for ( var i = 0; i < cloud_num; i++ ) { |
| 745 | + var cloud_id = 'cloud' + i; |
| 746 | + var found_category = document.getElementById( cloud_id ).innerHTML; |
| 747 | + if ( found_category ) { |
| 748 | + CreateAPage.foundCategories[i] = found_category; |
| 749 | + } |
| 750 | + } |
| 751 | + |
| 752 | + var categories = cat_textarea.value; |
| 753 | + if ( categories === '' ) { |
| 754 | + return; |
| 755 | + } |
| 756 | + |
| 757 | + categories = categories.split( '|' ); |
| 758 | + for ( i = 0; i < categories.length; i++ ) { |
| 759 | + text_categories[i] = categories[i]; |
| 760 | + } |
| 761 | + |
| 762 | + for ( i = 0; i < text_categories.length; i++ ) { |
| 763 | + var c_found = false; |
| 764 | + var core_cat; |
| 765 | + for ( var j in CreateAPage.foundCategories ) { |
| 766 | + core_cat = text_categories[i].replace( /\|.*/, '' ); |
| 767 | + if ( CreateAPage.foundCategories[j] === core_cat ) { |
| 768 | + var this_button = document.getElementById( 'cloud' + j ); |
| 769 | + var actual_cloud = CreateAPage.foundCategories[j]; |
| 770 | + var cl_num = j; |
| 771 | + |
| 772 | + this_button.onclick = CreateAPage.onclickCategoryFn( text_categories[i], j ); |
| 773 | + this_button.style.color = '#419636'; |
| 774 | + c_found = true; |
| 775 | + break; |
| 776 | + } |
| 777 | + } |
| 778 | + |
| 779 | + if ( !c_found ) { |
| 780 | + var n_cat = document.createElement( 'a' ); |
| 781 | + var s_cat = document.createElement( 'span' ); |
| 782 | + n_cat_count++; |
| 783 | + var cat_num = n_cat_count - 1; |
| 784 | + n_cat.setAttribute( 'id', 'cloud' + cat_num ); |
| 785 | + n_cat.setAttribute( 'href', '#' ); |
| 786 | + n_cat.onclick = CreateAPage.onclickCategoryFn( text_categories[i], cat_num ); |
| 787 | + n_cat.style.color = '#419636'; |
| 788 | + n_cat.style.fontSize = '10pt'; |
| 789 | + s_cat.setAttribute( 'id', 'tag' + n_cat_count ); |
| 790 | + var t_cat = document.createTextNode( core_cat ); |
| 791 | + var space = document.createTextNode( ' ' ); |
| 792 | + n_cat.appendChild( t_cat ); |
| 793 | + s_cat.appendChild( n_cat ); |
| 794 | + s_cat.appendChild( space ); |
| 795 | + cat_full_section.appendChild( s_cat ); |
| 796 | + } |
| 797 | + } |
| 798 | + }, |
| 799 | + |
| 800 | + addMultiEditButton: function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, toolbarId ) { |
| 801 | + CreateAPage.multiEditButtons[toolbarId][CreateAPage.multiEditButtons[toolbarId].length] = { |
| 802 | + 'imageId': imageId, |
| 803 | + 'toolbarId': toolbarId, |
| 804 | + 'imageFile': imageFile, |
| 805 | + 'speedTip': speedTip, |
| 806 | + 'tagOpen': tagOpen, |
| 807 | + 'tagClose': tagClose, |
| 808 | + 'sampleText': sampleText |
| 809 | + }; |
| 810 | + }, |
| 811 | + |
| 812 | + showThisBox: function( e, o ) { |
| 813 | + e.preventDefault(); |
| 814 | + document.getElementById( 'toolbar' + o.toolbarId ).style.display = ''; |
| 815 | + CreateAPage.hideOtherBoxes( o.toolbarId ); |
| 816 | + }, |
| 817 | + |
| 818 | + resizeThisTextarea: function( e, o ) { |
| 819 | + e.preventDefault(); |
| 820 | + var r_textarea = jQuery( '#wpTextboxes' + o.textareaId ); |
| 821 | + |
| 822 | + if ( |
| 823 | + !( ( r_textarea.rows < 4 ) && ( o.numRows < 0 ) ) && |
| 824 | + !( ( r_textarea.rows > 10 ) && ( o.numRows > 0 ) ) |
| 825 | + ) |
| 826 | + { |
| 827 | + r_textarea.rows = r_textarea.rows + o.numRows; |
| 828 | + } |
| 829 | + }, |
| 830 | + |
| 831 | + hideOtherBoxes: function( boxId ) { |
| 832 | + for ( var i = 0; i < CreateAPage.multiEditTextboxes.length; i++ ) { |
| 833 | + if ( CreateAPage.multiEditTextboxes[i] !== boxId ) { |
| 834 | + document.getElementById( 'toolbar' + CreateAPage.multiEditTextboxes[i] ).style.display = 'none'; |
| 835 | + } |
| 836 | + } |
| 837 | + }, |
| 838 | + |
| 839 | + multiEditSetupToolbar: function() { |
| 840 | + for ( var j = 0; j < CreateAPage.multiEditButtons.length; j++ ) { |
| 841 | + var toolbar = document.getElementById( 'toolbar' + j ); |
| 842 | + if ( toolbar ) { |
| 843 | + var textbox = document.getElementById( 'wpTextboxes' + j ); |
| 844 | + if ( !textbox ) { |
| 845 | + return false; |
| 846 | + } |
| 847 | + if ( |
| 848 | + !( document.selection && document.selection.createRange ) && |
| 849 | + textbox.selectionStart === null |
| 850 | + ) |
| 851 | + { |
| 852 | + return false; |
| 853 | + } |
| 854 | + |
| 855 | + for ( var i = 0; i < CreateAPage.multiEditButtons[j].length; i++ ) { |
| 856 | + CreateAPage.insertMultiEditButton( toolbar, CreateAPage.multiEditButtons[j][i] ); |
| 857 | + } |
| 858 | + } |
| 859 | + } |
| 860 | + return true; |
| 861 | + }, |
| 862 | + |
| 863 | + multiEditSetupOptionalSections: function() { |
| 864 | + var snum = 0; |
| 865 | + if ( document.getElementById( 'createpage_optionals_content' ) ) { |
| 866 | + var optionals = CreateAPage.getElementsBy( |
| 867 | + CreateAPage.optionalSectionTest, |
| 868 | + 'input', |
| 869 | + document.getElementById( 'createpage_optionals_content' ) |
| 870 | + ); |
| 871 | + var optionalsElements = document.getElementById( 'wpOptionals' ); |
| 872 | + for ( var i = 0; i < optionals.length; i++ ) { |
| 873 | + snum = optionals[i].id.replace( 'wpOptionalInput', '' ); |
| 874 | + if ( !document.getElementById( 'wpOptionalInput' + snum ).checked ) { |
| 875 | + optionalsElements.value = CreateAPage.unuseSection( |
| 876 | + document.getElementById( 'createpage_section_' + snum ), |
| 877 | + optionalsElements.value |
| 878 | + ); |
| 879 | + } |
| 880 | + jQuery( '#' + optionals[i] ).change( function( e ) { |
| 881 | + CreateAPage.toggleSection( e, { num: snum } ); |
| 882 | + }); |
| 883 | + } |
| 884 | + } |
| 885 | + }, |
| 886 | + |
| 887 | + insertMultiEditButton: function( parent, item ) { |
| 888 | + var image = document.createElement( 'img' ); |
| 889 | + image.width = 23; |
| 890 | + image.height = 22; |
| 891 | + image.className = 'mw-toolbar-editbutton'; |
| 892 | + if ( item.imageId ) { |
| 893 | + image.id = item.imageId; |
| 894 | + } |
| 895 | + image.src = item.imageFile; |
| 896 | + image.border = 0; |
| 897 | + image.alt = item.speedTip; |
| 898 | + image.title = item.speedTip; |
| 899 | + image.style.cursor = 'pointer'; |
| 900 | + |
| 901 | + parent.appendChild( image ); |
| 902 | + |
| 903 | + jQuery( '#' + item.imageId ).click( function( e ) { |
| 904 | + CreateAPage.insertTags( e, { |
| 905 | + 'tagOpen': item.tagOpen, |
| 906 | + 'tagClose': item.tagClose, |
| 907 | + 'sampleText': item.sampleText, |
| 908 | + 'textareaId': 'wpTextboxes' + item.toolbarId |
| 909 | + }); |
| 910 | + }); |
| 911 | + |
| 912 | + return true; |
| 913 | + }, |
| 914 | + |
| 915 | + insertTags: function( e, o ) { |
| 916 | + e.preventDefault(); |
| 917 | + var textarea = document.getElementById( o.textareaId ); |
| 918 | + if ( !textarea ) { |
| 919 | + return; |
| 920 | + } |
| 921 | + var selText, isSample = false; |
| 922 | + |
| 923 | + if ( document.selection && document.selection.createRange ) { |
| 924 | + var winScroll; |
| 925 | + if ( document.documentElement && document.documentElement.scrollTop ) { |
| 926 | + winScroll = document.documentElement.scrollTop; |
| 927 | + } else if ( document.body ) { |
| 928 | + winScroll = document.body.scrollTop; |
| 929 | + } |
| 930 | + textarea.focus(); |
| 931 | + var range = document.selection.createRange(); |
| 932 | + selText = range.text; |
| 933 | + |
| 934 | + if ( !selText ) { |
| 935 | + selText = o.sampleText; |
| 936 | + isSample = true; |
| 937 | + } else if ( selText.charAt( selText.length - 1 ) === ' ' ) { |
| 938 | + selText = selText.substring( 0, selText.length - 1 ); |
| 939 | + o.tagClose += ' '; |
| 940 | + } |
| 941 | + |
| 942 | + range.text = o.tagOpen + selText + o.tagClose; |
| 943 | + if ( isSample && range.moveStart ) { |
| 944 | + if ( window.opera ) { |
| 945 | + o.tagClose = o.tagClose.replace( /\n/g, '' ); |
| 946 | + } |
| 947 | + range.moveStart( 'character', - o.tagClose.length - selText.length ); |
| 948 | + range.moveEnd( 'character', - o.tagClose.length ); |
| 949 | + } |
| 950 | + range.select(); |
| 951 | + if ( document.documentElement && document.documentElement.scrollTop ) { |
| 952 | + document.documentElement.scrollTop = winScroll; |
| 953 | + } else if ( document.body ) { |
| 954 | + document.body.scrollTop = winScroll; |
| 955 | + } |
| 956 | + } else if ( textarea.selectionStart || textarea.selectionStart === '0' ) { |
| 957 | + var textScroll = textarea.scrollTop; |
| 958 | + textarea.focus(); |
| 959 | + var startPos = textarea.selectionStart; |
| 960 | + var endPos = textarea.selectionEnd; |
| 961 | + selText = textarea.value.substring( startPos, endPos ); |
| 962 | + |
| 963 | + if ( !selText ) { |
| 964 | + selText = o.sampleText; |
| 965 | + isSample = true; |
| 966 | + } else if ( selText.charAt( selText.length - 1 ) === ' ' ) { |
| 967 | + selText = selText.substring( 0, selText.length - 1 ); |
| 968 | + o.tagClose += ' '; |
| 969 | + } |
| 970 | + |
| 971 | + textarea.value = textarea.value.substring( 0, startPos ) + |
| 972 | + o.tagOpen + selText + o.tagClose + |
| 973 | + textarea.value.substring( endPos, textarea.value.length ); |
| 974 | + if ( isSample ) { |
| 975 | + textarea.selectionStart = startPos + o.tagOpen.length; |
| 976 | + textarea.selectionEnd = startPos + o.tagOpen.length + selText.length; |
| 977 | + } else { |
| 978 | + textarea.selectionStart = startPos + o.tagOpen.length + |
| 979 | + selText.length + o.tagClose.length; |
| 980 | + textarea.selectionEnd = textarea.selectionStart; |
| 981 | + } |
| 982 | + textarea.scrollTop = textScroll; |
| 983 | + } |
| 984 | + }, |
| 985 | + |
| 986 | + initialRound: function() { |
| 987 | + document.getElementById( 'Createtitle' ).setAttribute( 'autocomplete', 'off' ); |
| 988 | + if ( ( CreateAPage.previewMode === 'No' ) && ( CreateAPage.redLinkMode === 'No' ) ) { |
| 989 | + CreateAPage.contentOverlay(); |
| 990 | + } else { |
| 991 | + var catlink = document.getElementById( 'catlinks' ); // @todo FIXME/CHECKME: isn't it a class in modern MWs? |
| 992 | + if ( catlink ) { |
| 993 | + var newCatlink = document.createElement( 'div' ); |
| 994 | + newCatlink.setAttribute( 'id', 'catlinks' ); |
| 995 | + newCatlink.innerHTML = catlink.innerHTML; |
| 996 | + catlink.parentNode.removeChild( catlink ); |
| 997 | + var previewArea = document.getElementById( 'createpagepreview' ); |
| 998 | + previewArea.insertBefore( newCatlink, document.getElementById( 'createpage_preview_delimiter' ) ); |
| 999 | + } |
| 1000 | + } |
| 1001 | + |
| 1002 | + var edit_textareas = CreateAPage.getElementsBy( |
| 1003 | + CreateAPage.editTextareaTest, |
| 1004 | + 'textarea', |
| 1005 | + document.getElementById( 'wpTableMultiEdit' ), |
| 1006 | + CreateAPage.textareaAddToolbar |
| 1007 | + ); |
| 1008 | + if ( ( CreateAPage.redLinkMode === 'Yes' ) && ( edit_textareas[0].id === 'wpTextboxes0' ) ) { |
| 1009 | + edit_textareas[0].focus(); |
| 1010 | + } else { |
| 1011 | + var el_id = parseInt( edit_textareas[0].id.replace( 'wpTextboxes', '' ) ); |
| 1012 | + document.getElementById( 'toolbar' + el_id ).style.display = ''; |
| 1013 | + CreateAPage.hideOtherBoxes( el_id ); |
| 1014 | + } |
| 1015 | + |
| 1016 | + CreateAPage.multiEditSetupToolbar(); |
| 1017 | + CreateAPage.multiEditSetupOptionalSections(); |
| 1018 | + CreateAPage.checkCategoryCloud(); |
| 1019 | + }, |
| 1020 | + |
| 1021 | + /** |
| 1022 | + * Render the overlay that hides the editing buttons, the textarea and the |
| 1023 | + * save/preview/view changes buttons until the user supplies a title that |
| 1024 | + * does not exist yet on the wiki. |
| 1025 | + */ |
| 1026 | + contentOverlay: function() { |
| 1027 | + /* |
| 1028 | + CreateAPage.Overlay = new YAHOO.widget.Overlay( 'createpageoverlay' ); |
| 1029 | + CreateAPage.resizeOverlay( 20 ); |
| 1030 | + CreateAPage.Overlay.render(); |
| 1031 | + */ |
| 1032 | + |
| 1033 | + // Based on the MIT-licensed jquery.overlay plugin by Tom McFarlin |
| 1034 | + CreateAPage.Overlay = jQuery( '#createpageoverlay' ).css({ |
| 1035 | + background: '#000', |
| 1036 | + display: 'none', |
| 1037 | + // throw in an extra 25px to make sure that we *really* cover all |
| 1038 | + // the editing buttons, the whole textarea *and* the buttons |
| 1039 | + height: jQuery( '#cp-restricted' ).height() + 25, |
| 1040 | + //left: jQuery( '#cp-restricted' ).offset().left, // more harmful than useful |
| 1041 | + opacity: 0.5, |
| 1042 | + overflow: 'hidden', |
| 1043 | + position: 'absolute', |
| 1044 | + //top: jQuery( '#cp-restricted' ).offset().top, // more harmful than useful |
| 1045 | + width: jQuery( '#cp-restricted' ).width(), |
| 1046 | + zIndex: 1000 |
| 1047 | + }).show(); |
| 1048 | + |
| 1049 | + var helperButton = document.getElementById( 'wpRunInitialCheck' ); |
| 1050 | + jQuery( '#wpRunInitialCheck' ).click( function() { |
| 1051 | + CreateAPage.watchTitle(); |
| 1052 | + }); |
| 1053 | + helperButton.style.display = ''; |
| 1054 | + }, |
| 1055 | + |
| 1056 | + appendHeight: function( elem_height, number ) { |
| 1057 | + var x_fixed_height = elem_height.replace( 'px', '' ); |
| 1058 | + x_fixed_height = parseFloat( x_fixed_height ) + number; |
| 1059 | + x_fixed_height = x_fixed_height.toString() + 'px'; |
| 1060 | + return x_fixed_height; |
| 1061 | + }, |
| 1062 | + |
| 1063 | + resizeOverlay: function( number ) { |
| 1064 | + var cont_elem = jQuery( '#cp-restricted' ); |
| 1065 | + var fixed_height; |
| 1066 | + var fixed_width; |
| 1067 | + if ( cont_elem.css( 'height' ) === 'auto' ) { |
| 1068 | + fixed_height = document.getElementById( 'cp-restricted' ).offsetHeight + number; |
| 1069 | + fixed_width = document.getElementById( 'cp-restricted' ).offsetWidth; |
| 1070 | + } else { |
| 1071 | + fixed_height = cont_elem.css( 'height' ); |
| 1072 | + fixed_height = CreateAPage.appendHeight( fixed_height, number ); |
| 1073 | + fixed_width = cont_elem.css( 'width' ); |
| 1074 | + } |
| 1075 | + |
| 1076 | + // @todo FIXME: commented out for now to prevent JS errors |
| 1077 | + //CreateAPage.Overlay.cfg.setProperty( 'height', fixed_height ); |
| 1078 | + //CreateAPage.Overlay.cfg.setProperty( 'width', fixed_width ); |
| 1079 | + }, |
| 1080 | + |
| 1081 | + testInfoboxToggle: function() { |
| 1082 | + var listeners = jQuery( '#cp-infobox-toggle' ).data( 'events' ); |
| 1083 | + if ( listeners ) { |
| 1084 | + for ( var i = 0; i < listeners.length; ++i ) { |
| 1085 | + var listener = listeners[i]; |
| 1086 | + if ( listener.type !== 'click' ) { |
| 1087 | + jQuery( '#cp-infobox-toggle' ).click( function( e ) { |
| 1088 | + CreateAPageListeners.toggle( e, ['cp-infobox', 'cp-infobox-toggle'] ); |
| 1089 | + }); |
| 1090 | + } |
| 1091 | + } |
| 1092 | + } else { |
| 1093 | + jQuery( '#cp-infobox-toggle' ).click( function( e ) { |
| 1094 | + CreateAPageListeners.toggle( e, ['cp-infobox', 'cp-infobox-toggle'] ); |
| 1095 | + }); |
| 1096 | + } |
| 1097 | + }, |
| 1098 | + |
| 1099 | + initializeMultiEdit: function() { |
| 1100 | + // Original PHP implementation was: join( ', ', $elements_for_yui ) |
| 1101 | + var elements = wgCreateAPageElementsForJavaScript; //[ Array.prototype.join.call( wgCreateAPageElementsForJavaScript, ', ' ) ]; |
| 1102 | + |
| 1103 | + for ( var i = 0; i < wgCreateAPageElementsForJavaScript.length; i++ ) { |
| 1104 | + jQuery( '#' + wgCreateAPageElementsForJavaScript[i] ).click( function( e ) { |
| 1105 | + CreateAPage.switchTemplate( e, wgCreateAPageElementsForJavaScript[i] ); |
| 1106 | + }); |
| 1107 | + } |
| 1108 | + |
| 1109 | + var src, tt; |
| 1110 | + // Hide the radio buttons on the left side of each createplate's name, |
| 1111 | + // they look ugly in here |
| 1112 | + for ( i in elements ) { |
| 1113 | + jQuery( '#' + elements[i] + '-radio' ).hide(); |
| 1114 | + } |
| 1115 | + }, |
| 1116 | + |
| 1117 | + /** |
| 1118 | + * Whenever a user clicks on one of the various createplate names, this |
| 1119 | + * function is called. |
| 1120 | + * |
| 1121 | + * @param e Event |
| 1122 | + * @param elementId String: name of the createplate template (i.e. |
| 1123 | + * cp-template-Name) |
| 1124 | + */ |
| 1125 | + switchTemplate: function( e, elementId ) { |
| 1126 | + CreateAPage.myId = elementId; |
| 1127 | + e.preventDefault(); |
| 1128 | + |
| 1129 | + document.getElementById( 'cp-multiedit' ).innerHTML = |
| 1130 | + '<img src="' + wgScriptPath + '/extensions/CreateAPage/images/progress_bar.gif" width="70" height="11" alt="' + |
| 1131 | + mw.msg( 'createpage-please-wait' ) + '" border="0" />'; |
| 1132 | + if ( CreateAPage.Overlay ) { |
| 1133 | + CreateAPage.resizeOverlay( 20 ); |
| 1134 | + } |
| 1135 | + |
| 1136 | + jQuery.ajax({ // using .ajax instead of .get for better flexibility |
| 1137 | + url: wgScript, |
| 1138 | + data: { |
| 1139 | + action: 'ajax', |
| 1140 | + rs: 'axMultiEditParse', |
| 1141 | + template: elementId.replace( 'cp-template-', '' ) |
| 1142 | + }, |
| 1143 | + success: function( data, textStatus, jqXHR ) { |
| 1144 | + document.getElementById( 'cp-multiedit' ).innerHTML = ''; |
| 1145 | + |
| 1146 | + var res = ''; |
| 1147 | + if( /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test( jqXHR.responseText ) ) { |
| 1148 | + res = eval( '(' + jqXHR.responseText + ')' ); |
| 1149 | + } |
| 1150 | + if ( res !== '' ) { |
| 1151 | + document.getElementById( 'cp-multiedit' ).innerHTML = res; |
| 1152 | + } |
| 1153 | + |
| 1154 | + // @todo FIXME: need to add some code to remove the |
| 1155 | + // 'templateFrameSelected' class from other templates except |
| 1156 | + // the currently selected one |
| 1157 | + // |
| 1158 | + // I tried this above the addClass( 'templateFrameSelected' ) |
| 1159 | + // stuff, but it didn't work (when you would select the 2nd |
| 1160 | + // template, the class would be given to the 3rd template |
| 1161 | + // instead...lol wut): |
| 1162 | + // |
| 1163 | + // jQuery( '.templateFrameSelected' ).each( function( index ) { |
| 1164 | + // jQuery( this ).removeClass( 'templateFrameSelected' ); |
| 1165 | + // }); |
| 1166 | + var elements = wgCreateAPageElementsForJavaScript; |
| 1167 | + for ( var i in elements ) { |
| 1168 | + jQuery( '#' + elements[i] ).addClass( 'templateFrame' ); |
| 1169 | + } |
| 1170 | + |
| 1171 | + // ...and make the recently selected createplate active! |
| 1172 | + jQuery( '#' + CreateAPage.myId ).addClass( 'templateFrameSelected' ); |
| 1173 | + |
| 1174 | + var infoboxToggle = jQuery( '#cp-infobox-toggle' ); |
| 1175 | + if ( infoboxToggle.length > 0 ) { |
| 1176 | + CreateAPage.testInfoboxToggle(); |
| 1177 | + //YAHOO.util.Event.onAvailable( 'cp-infobox-toggle', CreateAPage.testInfoboxToggle ); |
| 1178 | + } |
| 1179 | + |
| 1180 | + var infobox_root = document.getElementById( 'cp-infobox' ); |
| 1181 | + var infobox_inputs = CreateAPage.getElementsBy( |
| 1182 | + CreateAPageInfobox.inputTest, |
| 1183 | + 'input', |
| 1184 | + infobox_root, |
| 1185 | + CreateAPageInfobox.inputEvent |
| 1186 | + ); |
| 1187 | + var infobox_uploads = CreateAPage.getElementsBy( |
| 1188 | + CreateAPageInfobox.uploadTest, |
| 1189 | + 'input', |
| 1190 | + infobox_root, |
| 1191 | + CreateAPageInfobox.uploadEvent |
| 1192 | + ); |
| 1193 | + var content_root = document.getElementById( 'wpTableMultiEdit' ); |
| 1194 | + var section_uploads = CreateAPage.getElementsBy( |
| 1195 | + CreateAPage.uploadTest, |
| 1196 | + 'input', |
| 1197 | + content_root, |
| 1198 | + CreateAPage.uploadEvent |
| 1199 | + ); |
| 1200 | + |
| 1201 | + var cloud_div = document.getElementById( 'createpage_cloud_div' ); |
| 1202 | + if ( cloud_div !== null ) { |
| 1203 | + cloud_div.style.display = 'block'; |
| 1204 | + } |
| 1205 | + CreateAPage.checkCategoryCloud(); |
| 1206 | + |
| 1207 | + if ( |
| 1208 | + CreateAPage.Overlay && |
| 1209 | + ( document.getElementById( 'createpageoverlay' ).style.visibility !== 'hidden' ) |
| 1210 | + ) |
| 1211 | + { |
| 1212 | + CreateAPage.resizeOverlay( 20 ); |
| 1213 | + } |
| 1214 | + |
| 1215 | + CreateAPage.multiEditTextboxes = []; |
| 1216 | + CreateAPage.multiEditButtons = []; |
| 1217 | + CreateAPage.multiEditCustomButtons = []; |
| 1218 | + |
| 1219 | + var edit_textareas = CreateAPage.getElementsBy( |
| 1220 | + CreateAPage.editTextareaTest, |
| 1221 | + 'textarea', |
| 1222 | + content_root, |
| 1223 | + CreateAPage.textareaAddToolbar |
| 1224 | + ); |
| 1225 | + |
| 1226 | + if ( ( CreateAPage.redLinkMode === 'Yes' ) && ( 'wpTextboxes0' === edit_textareas[0].id ) ) { |
| 1227 | + edit_textareas[0].focus(); |
| 1228 | + } else { |
| 1229 | + var el_id = parseInt( edit_textareas[0].id.replace( 'wpTextboxes', '' ) ); |
| 1230 | + document.getElementById( 'toolbar' + el_id ).style.display = ''; |
| 1231 | + CreateAPage.hideOtherBoxes( el_id ); |
| 1232 | + } |
| 1233 | + |
| 1234 | + var edittools_div = document.getElementById( 'createpage_editTools' ); |
| 1235 | + if ( edittools_div ) { |
| 1236 | + if ( CreateAPage.myId != 'cp-template-Blank' ) { |
| 1237 | + edittools_div.style.display = 'none'; |
| 1238 | + } else { |
| 1239 | + edittools_div.style.display = ''; |
| 1240 | + } |
| 1241 | + } |
| 1242 | + |
| 1243 | + CreateAPage.multiEditSetupToolbar(); |
| 1244 | + CreateAPage.multiEditSetupOptionalSections(); |
| 1245 | + }, |
| 1246 | + error: function( jqXHR, textStatus, errorThrown ) { |
| 1247 | + document.getElementById( 'cp-multiedit' ).innerHTML = ''; |
| 1248 | + }, |
| 1249 | + timeout: 50000 |
| 1250 | + }); |
| 1251 | + }, |
| 1252 | + |
| 1253 | + checkExistingTitle: function( e ) { |
| 1254 | + if ( document.getElementById( 'Createtitle' ).value === '' ) { |
| 1255 | + e.preventDefault(); |
| 1256 | + document.getElementById( 'cp-title-check' ).innerHTML = '<span style="color: red;">' + |
| 1257 | + mw.msg( 'createpage-give-title' ) + '</span>'; |
| 1258 | + window.location.hash = 'title_loc'; |
| 1259 | + CreateAPage.SubmitEnabled = false; |
| 1260 | + } else if ( CreateAPage.noCanDo === true ) { |
| 1261 | + CreateAPage.warningPanel = jQuery( '#dlg' ).dialog({ |
| 1262 | + //autoOpen: false, |
| 1263 | + draggable: false, |
| 1264 | + hide: 'slide', |
| 1265 | + modal: true, |
| 1266 | + resizable: false, |
| 1267 | + title: mw.msg( 'createpage-title-check-header' ), |
| 1268 | + // original YUI code used 20em, but I don't think jQuery supports that. |
| 1269 | + // So I went to PXtoEM.com to convert 20em to pixels; I used |
| 1270 | + // 20.5 as the base font size in pixels, because we set the |
| 1271 | + // font size to 127% in Monobook's main.css and according to |
| 1272 | + // their conversion tables, 20px is 125% |
| 1273 | + width: 410 |
| 1274 | + }); |
| 1275 | + /* |
| 1276 | + TitleDialog = new YAHOO.widget.SimpleDialog( 'dlg', { |
| 1277 | + width: '20em', |
| 1278 | + effect: { |
| 1279 | + effect: YAHOO.widget.ContainerEffect.FADE, |
| 1280 | + duration: 0.4 |
| 1281 | + }, |
| 1282 | + fixedcenter: true, |
| 1283 | + modal: true, |
| 1284 | + visible: false, |
| 1285 | + draggable: false |
| 1286 | + }); |
| 1287 | + TitleDialog.setHeader( mw.msg( 'createpage-title-check-header' ) ); |
| 1288 | + TitleDialog.setBody( mw.msg( 'createpage-title-check-text' ) ); |
| 1289 | + TitleDialog.cfg.setProperty( 'icon', YAHOO.widget.SimpleDialog.ICON_WARN ); |
| 1290 | + TitleDialog.cfg.setProperty( 'zIndex', 1000 ); |
| 1291 | + TitleDialog.render( document.body ); |
| 1292 | + TitleDialog.show(); |
| 1293 | + */ |
| 1294 | + e.preventDefault(); |
| 1295 | + CreateAPage.submitEnabled = false; |
| 1296 | + } |
| 1297 | + if ( |
| 1298 | + ( CreateAPage.submitEnabled !== true ) || |
| 1299 | + ( CreateAPage.Overlay && ( document.getElementById( 'createpageoverlay' ).style.visibility != 'hidden' ) ) |
| 1300 | + ) |
| 1301 | + { |
| 1302 | + e.preventDefault(); |
| 1303 | + } |
| 1304 | + }, |
| 1305 | + |
| 1306 | + enableSubmit: function( e ) { |
| 1307 | + CreateAPage.submitEnabled = true; |
| 1308 | + }, |
| 1309 | + |
| 1310 | + /** |
| 1311 | + * Copied from the YUI library, version 2.5.2 |
| 1312 | + * |
| 1313 | + * Copyright (c) 2008, Yahoo! Inc. All rights reserved. |
| 1314 | + * Code licensed under the BSD License: |
| 1315 | + * http://developer.yahoo.net/yui/license.txt |
| 1316 | + */ |
| 1317 | + getElementsBy: function( method, tag, root, apply ) { |
| 1318 | + tag = tag || '*'; |
| 1319 | + |
| 1320 | + root = ( root ) ? /*jQuery( */root /*)*/ : null || document; |
| 1321 | + |
| 1322 | + if ( !root ) { |
| 1323 | + return []; |
| 1324 | + } |
| 1325 | + |
| 1326 | + var nodes = [], |
| 1327 | + elements = root.getElementsByTagName( tag ); |
| 1328 | + |
| 1329 | + for ( var i = 0, len = elements.length; i < len; ++i ) { |
| 1330 | + if ( method( elements[i] ) ) { |
| 1331 | + nodes[nodes.length] = elements[i]; |
| 1332 | + |
| 1333 | + if ( apply ) { |
| 1334 | + apply( elements[i] ); |
| 1335 | + } |
| 1336 | + } |
| 1337 | + } |
| 1338 | + |
| 1339 | + return nodes; |
| 1340 | + } |
| 1341 | +}; // end of the CreateAPage class |
| 1342 | + |
| 1343 | +window.onresize = function() { |
| 1344 | + if ( CreateAPage.Overlay && ( document.getElementById( 'createpageoverlay' ).style.visibility !== 'hidden' ) ) { |
| 1345 | + //CreateAPage.resizeOverlay( 0 ); |
| 1346 | + } |
| 1347 | +}; |
| 1348 | + |
| 1349 | +/** |
| 1350 | + * Class for uploading images from an infobox on the Special:CreatePage page. |
| 1351 | + */ |
| 1352 | +var CreateAPageInfobox = { |
| 1353 | + failureCallback: function( response ) { |
| 1354 | + document.getElementById( 'createpage_image_text' + response.argument ).innerHTML = mw.msg( 'createpage-insert-image' ); |
| 1355 | + document.getElementById( 'createpage_upload_progress' + response.argument ).innerHTML = mw.msg( 'createpage-upload-aborted' ); |
| 1356 | + document.getElementById( 'createpage_upload_file' + response.argument ).style.display = ''; |
| 1357 | + document.getElementById( 'createpage_image_text' + response.argument ).style.display = ''; |
| 1358 | + document.getElementById( 'createpage_image_cancel' + response.argument ).style.display = 'none'; |
| 1359 | + }, |
| 1360 | + |
| 1361 | + upload: function( e, o ) { |
| 1362 | + var n = o.num; |
| 1363 | + var oForm = document.getElementById( 'createpageform' ); |
| 1364 | + if ( oForm ) { |
| 1365 | + e.preventDefault(); |
| 1366 | + var ProgressBar = document.getElementById( 'createpage_upload_progress' + o.num ); |
| 1367 | + ProgressBar.style.display = 'block'; |
| 1368 | + ProgressBar.innerHTML = '<img src="' + stylepath + '/common/images/spinner.gif" width="16" height="16" alt="' + |
| 1369 | + mw.msg( 'createpage-please-wait' ) + '" border="0" /> '; |
| 1370 | + |
| 1371 | + var sent_request = jQuery.ajax({ // using .ajax instead of .post for better flexibility |
| 1372 | + type: 'POST', |
| 1373 | + url: wgScript, |
| 1374 | + data: { |
| 1375 | + action: 'ajax', |
| 1376 | + rs: 'axMultiEditImageUpload', |
| 1377 | + num: n |
| 1378 | + }, |
| 1379 | + success: function( data, textStatus, jqXHR ) { |
| 1380 | + // @todo FIXME/CHECKME: make sure that the num (n) is passed as response.argument to uploadCallback |
| 1381 | + CreateAPageInfobox.uploadCallback( jqXHR ); |
| 1382 | + }, |
| 1383 | + error: function( jqXHR, textStatus, errorThrown ) { |
| 1384 | + CreateAPageInfobox.failureCallback( jqXHR ); |
| 1385 | + }, |
| 1386 | + timeout: 60000 |
| 1387 | + }); |
| 1388 | + document.getElementById( 'createpage_image_cancel' + o.num ).style.display = ''; |
| 1389 | + document.getElementById( 'createpage_image_text' + o.num ).style.display = 'none'; |
| 1390 | + |
| 1391 | + jQuery( '#createpage_image_cancel' + o.num ).click( function( e ) { |
| 1392 | + sent_request.abort(); |
| 1393 | + }); |
| 1394 | + |
| 1395 | + var neoInput = document.createElement( 'input' ); |
| 1396 | + var thisInput = document.getElementById( 'createpage_upload_file' + o.num ); |
| 1397 | + var thisContainer = document.getElementById( 'createpage_image_label' + o.num ); |
| 1398 | + thisContainer.removeChild( thisInput ); |
| 1399 | + |
| 1400 | + neoInput.setAttribute( 'type', 'file' ); |
| 1401 | + neoInput.setAttribute( 'id', 'createpage_upload_file' + o.num ); |
| 1402 | + neoInput.setAttribute( 'name', 'wpUploadFile' + o.num ); |
| 1403 | + neoInput.setAttribute( 'tabindex', '-1' ); |
| 1404 | + |
| 1405 | + thisContainer.appendChild( neoInput ); |
| 1406 | + jQuery( '#createpage_upload_file' + o.num ).change( function( e ) { |
| 1407 | + CreateAPageInfobox.upload( e, { 'num': o.num } ); |
| 1408 | + }); |
| 1409 | + |
| 1410 | + document.getElementById( 'createpage_upload_file' + o.num ).style.display = 'none'; |
| 1411 | + } |
| 1412 | + }, |
| 1413 | + |
| 1414 | + uploadCallback: function( response ) { |
| 1415 | + var aResponse = []; // initialize it as an empty array so that JSHint can STFU |
| 1416 | + if( /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test( response.responseText ) ) { |
| 1417 | + aResponse = eval( '(' + response.responseText + ')' ); |
| 1418 | + } |
| 1419 | + var ProgressBar = document.getElementById( 'createpage_upload_progress' + response.argument ); |
| 1420 | + if ( aResponse['error'] != 1 ) { |
| 1421 | + var xInfoboxText = document.getElementById( 'wpInfoboxValue' ).value; |
| 1422 | + var xImageHelper = document.getElementById( 'wpInfImg' + response.argument ).value; |
| 1423 | + document.getElementById( 'wpInfImg' + response.argument ).value = aResponse['msg']; |
| 1424 | + document.getElementById( 'wpNoUse' + response.argument ).value = 'Yes'; |
| 1425 | + ProgressBar.innerHTML = mw.msg( 'createpage-img-uploaded' ); |
| 1426 | + var ImageThumbnail = document.getElementById( 'createpage_image_thumb' + response.argument ); |
| 1427 | + var thumb_container = document.getElementById( 'createpage_main_thumb' + response.argument ); |
| 1428 | + var tempstamp = new Date(); |
| 1429 | + ImageThumbnail.src = aResponse['url'] + '?' + tempstamp.getTime(); |
| 1430 | + if ( document.getElementById( 'wpLastTimestamp' + response.argument ).value == 'None' ) { |
| 1431 | + var break_tag = document.createElement( 'br' ); |
| 1432 | + thumb_container.style.display = ''; |
| 1433 | + var label_node = document.getElementById( 'createpage_image_label' + response.argument ); |
| 1434 | + var par_node = label_node.parentNode; |
| 1435 | + par_node.insertBefore( break_tag, label_node ); |
| 1436 | + } |
| 1437 | + document.getElementById( 'wpLastTimestamp' + response.argument ).value = aResponse['timestamp']; |
| 1438 | + } else if ( ( aResponse['error'] == 1 ) && ( aResponse['msg'] == 'cp_no_login' ) ) { |
| 1439 | + ProgressBar.innerHTML = '<span style="color: red">' + |
| 1440 | + mw.msg( 'createpage-login-required' ) + '<a href="' + wgServer + |
| 1441 | + wgScript + '?title=Special:UserLogin&returnto=Special:CreatePage" id="createpage_login_infobox' + |
| 1442 | + response.argument + '">' + mw.msg( 'createpage-login-href' ) + |
| 1443 | + '</a>' + mw.msg( 'createpage-login-required2' ) + |
| 1444 | + '</span>'; |
| 1445 | + jQuery( '#createpage_login_infobox' + response.argument ).click( |
| 1446 | + function( e ) { |
| 1447 | + CreateAPage.showWarningLoginPanel( e ); |
| 1448 | + } |
| 1449 | + ); |
| 1450 | + } else { |
| 1451 | + ProgressBar.innerHTML = '<span style="color: red">' + aResponse['msg'] + '</span>'; |
| 1452 | + } |
| 1453 | + document.getElementById( 'createpage_image_text' + response.argument ).innerHTML = mw.msg( 'createpage-insert-image' ); |
| 1454 | + document.getElementById( 'createpage_upload_file' + response.argument ).style.display = ''; |
| 1455 | + document.getElementById( 'createpage_image_text' + response.argument ).style.display = ''; |
| 1456 | + document.getElementById( 'createpage_image_cancel' + response.argument ).style.display = 'none'; |
| 1457 | + }, |
| 1458 | + |
| 1459 | + inputTest: function( el ) { |
| 1460 | + if ( el.id.match( 'wpInfoboxPar' ) ) { |
| 1461 | + return true; |
| 1462 | + } else { |
| 1463 | + return false; |
| 1464 | + } |
| 1465 | + }, |
| 1466 | + |
| 1467 | + inputEvent: function( el ) { |
| 1468 | + var j = parseInt( el.id.replace( 'wpInfoboxPar', '' ) ); |
| 1469 | + if ( jQuery( '#wpInfoboxPar' + j ).length > 0 ) { |
| 1470 | + CreateAPage.clearInput( { num: j } ); |
| 1471 | + } |
| 1472 | + //YAHOO.util.Event.onContentReady( 'wpInfoboxPar' + j, CreateAPage.clearInput, { num: j } ); |
| 1473 | + }, |
| 1474 | + |
| 1475 | + uploadTest: function( el ) { |
| 1476 | + if ( el.id.match( 'createpage_upload_file' ) ) { |
| 1477 | + return true; |
| 1478 | + } else { |
| 1479 | + return false; |
| 1480 | + } |
| 1481 | + }, |
| 1482 | + |
| 1483 | + uploadEvent: function( el ) { |
| 1484 | + var j = parseInt( el.id.replace( 'createpage_upload_file', '' ) ); |
| 1485 | + jQuery( '#createpage_upload_file' + j ).change( function( e ) { |
| 1486 | + CreateAPageInfobox.upload( e, { 'num' : j } ); |
| 1487 | + } ); |
| 1488 | + } |
| 1489 | +}; |
| 1490 | + |
| 1491 | +// Initialize stuff when the DOM is ready |
| 1492 | +jQuery( document ).ready( function() { |
| 1493 | + // This creates the overlay over the editor and effectively blocks the user |
| 1494 | + // from typing text on the textarea and thus forces them to supply the page |
| 1495 | + // title first. |
| 1496 | + // Should be executed when #cp-multiedit exists |
| 1497 | + CreateAPage.initialRound(); |
| 1498 | + |
| 1499 | + CreateAPage.initializeMultiEdit(); |
| 1500 | + |
| 1501 | + jQuery( '#createpageform' ).submit( function( e ) { |
| 1502 | + CreateAPage.checkExistingTitle( e ); |
| 1503 | + }); |
| 1504 | + |
| 1505 | + jQuery( '#wpSave' ).click( function( e ) { |
| 1506 | + CreateAPage.enableSubmit( e ); |
| 1507 | + }); |
| 1508 | + |
| 1509 | + jQuery( '#wpPreview' ).click( function( e ) { |
| 1510 | + CreateAPage.enableSubmit( e ); |
| 1511 | + }); |
| 1512 | + |
| 1513 | + jQuery( '#wpCancel' ).click( function( e ) { |
| 1514 | + CreateAPage.enableSubmit( e ); |
| 1515 | + }); |
| 1516 | + |
| 1517 | + jQuery( '#cp-chooser-toggle' ).click( function( e ) { |
| 1518 | + CreateAPageListeners.toggle( e, ['cp-chooser', 'cp-chooser-toggle'] ); |
| 1519 | + }); |
| 1520 | + |
| 1521 | + // FIXME onAvailable? |
| 1522 | + var listeners = jQuery( '#cp-infobox-toggle' ).data( 'events' ); |
| 1523 | + if ( listeners ) { |
| 1524 | + for ( var i = 0; i < listeners.length; ++i ) { |
| 1525 | + var listener = listeners[i]; |
| 1526 | + if ( listener.type !== 'click' ) { |
| 1527 | + jQuery( '#cp-infobox-toggle' ).click( function( e ) { |
| 1528 | + CreateAPageListeners.toggle( e, ['cp-infobox', 'cp-infobox-toggle'] ); |
| 1529 | + }); |
| 1530 | + } |
| 1531 | + } |
| 1532 | + } else { |
| 1533 | + jQuery( '#cp-chooser-toggle' ).click( function( e ) { |
| 1534 | + CreateAPageListeners.toggle( e, ['cp-infobox', 'cp-infobox-toggle'] ); |
| 1535 | + }); |
| 1536 | + } |
| 1537 | + |
| 1538 | + // "Add a category" input (see categorypage.tmpl.php) |
| 1539 | + var categoryButton = jQuery( '#wpCategoryButton' ); |
| 1540 | + if ( categoryButton.length > 0 ) { |
| 1541 | + categoryButton.click( function( e ) { |
| 1542 | + CreateAPageCategoryTagCloud.inputAdd(); |
| 1543 | + return false; |
| 1544 | + }); |
| 1545 | + } |
| 1546 | + |
| 1547 | + jQuery( '#Createtitle' ).change( CreateAPage.watchTitle ); |
| 1548 | + |
| 1549 | + // Clicking on the "Advanced Edit" button shows a modal dialog asking the |
| 1550 | + // user, "Switching editing modes may break page formatting, do you want to continue?" |
| 1551 | + jQuery( '#wpAdvancedEdit' ).bind( 'click', function( e ) { |
| 1552 | + CreateAPage.showWarningPanel( e ); |
| 1553 | + }); |
| 1554 | + |
| 1555 | + // Clicking on the "Article Title" input clears any "This article already |
| 1556 | + // exists" messages |
| 1557 | + jQuery( '#Createtitle' ).bind( 'focus', function( e ) { |
| 1558 | + CreateAPage.clearTitleMessage( e ); |
| 1559 | + }); |
| 1560 | +}); |
\ No newline at end of file |
Property changes on: trunk/extensions/CreateAPage/js/CreateAPage.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 1561 | + native |
Index: trunk/extensions/CreateAPage/CreatePageEditor.php |
— | — | @@ -15,8 +15,8 @@ |
16 | 16 | $this->mTemplate = $template; |
17 | 17 | } |
18 | 18 | |
19 | | - abstract public function GenerateForm(); |
20 | | - abstract public function GlueArticle(); |
| 19 | + abstract public function generateForm(); |
| 20 | + abstract public function glueArticle(); |
21 | 21 | } |
22 | 22 | |
23 | 23 | // wraps up special multi editor class |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | $this->mPreviewed = $previewed; |
32 | 32 | } |
33 | 33 | |
34 | | - function GenerateForm( $content = false ) { |
| 34 | + function generateForm( $content = false ) { |
35 | 35 | global $wgOut, $wgUser, $wgRequest; |
36 | 36 | |
37 | 37 | $optional_sections = array(); |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | } |
132 | 132 | |
133 | 133 | // take given categories and glue them together |
134 | | - function GlueCategories( $checkboxes_array, $categories ) { |
| 134 | + function glueCategories( $checkboxes_array, $categories ) { |
135 | 135 | global $wgContLang; |
136 | 136 | |
137 | 137 | $text = ''; |
— | — | @@ -152,7 +152,7 @@ |
153 | 153 | } |
154 | 154 | |
155 | 155 | // get the infobox' text and substitute all known values... |
156 | | - function GlueInfobox( $infoboxes_array, $infobox_text ) { |
| 156 | + function glueInfobox( $infoboxes_array, $infobox_text ) { |
157 | 157 | $inf_pars = preg_split( "/\|/", $infobox_text, -1 ); |
158 | 158 | |
159 | 159 | // correct for additional |'s the users may have put in here... |
— | — | @@ -201,7 +201,7 @@ |
202 | 202 | return $text; |
203 | 203 | } |
204 | 204 | |
205 | | - function GlueArticle( $preview = false, $render_option = true ) { |
| 205 | + function glueArticle( $preview = false, $render_option = true ) { |
206 | 206 | global $wgRequest, $wgOut; |
207 | 207 | |
208 | 208 | $text = ''; |
— | — | @@ -298,7 +298,7 @@ |
299 | 299 | $file_ext = explode( '.', $uploadform->mSrcName ); |
300 | 300 | $file_ext = $file_ext[1]; |
301 | 301 | } else { |
302 | | - $file_ext = '' ; |
| 302 | + $file_ext = ''; |
303 | 303 | } |
304 | 304 | $uploadform->mParameterExt = $file_ext; |
305 | 305 | $uploadform->mDesiredDestName = $wgRequest->getText( 'Createtitle' ); |
— | — | @@ -345,11 +345,11 @@ |
346 | 346 | } |
347 | 347 | |
348 | 348 | if ( isset( $_POST['wpInfoboxValue'] ) ) { |
349 | | - $text = $this->GlueInfobox( $infoboxes, $_POST['wpInfoboxValue'] ) . $text; |
| 349 | + $text = $this->glueInfobox( $infoboxes, $_POST['wpInfoboxValue'] ) . $text; |
350 | 350 | } |
351 | 351 | |
352 | 352 | if ( isset( $_POST['wpCategoryTextarea'] ) ) { |
353 | | - $text .= $this->GlueCategories( $categories, $_POST['wpCategoryTextarea'] ); |
| 353 | + $text .= $this->glueCategories( $categories, $_POST['wpCategoryTextarea'] ); |
354 | 354 | } |
355 | 355 | |
356 | 356 | return $text; |
— | — | @@ -367,11 +367,18 @@ |
368 | 368 | |
369 | 369 | } |
370 | 370 | |
371 | | -// a small class to overcome some MediaWiki shortages :) |
372 | | -// MediaWiki always shows a newly created article, which in this case |
373 | | -// disrupts the form and generally doesn't suit us, and uploading a new |
374 | | -// image creates a new article |
375 | | -class PocketSilentArticle extends Article { |
| 371 | +/** |
| 372 | + * A small class to overcome some MediaWiki shortages :) |
| 373 | + * MediaWiki always shows a newly created article, which in this case disrupts |
| 374 | + * the form and generally doesn't suit us, and uploading a new image creates a |
| 375 | + * new article. |
| 376 | + * |
| 377 | + * @todo FIXME: in May 2011 iAlex wrote on CodeReview that insertNewArticle() |
| 378 | + * no longer exists |
| 379 | + * @see http://www.mediawiki.org/wiki/Special:Code/MediaWiki/84472 |
| 380 | + * @see http://www.mediawiki.org/wiki/Special:Code/MediaWiki/87884#c16799 |
| 381 | + */ |
| 382 | +class PocketSilentArticle extends Article/*WikiPage*/ { |
376 | 383 | // don't SHOW article upon creation, because it's IRRITATING |
377 | 384 | function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC = false, $comment = false, $bot = false ) { |
378 | 385 | $flags = EDIT_NEW | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY | |
Index: trunk/extensions/CreateAPage/templates/toggles.tmpl.php |
— | — | @@ -1,55 +0,0 @@ |
2 | | -<script type="text/javascript"> |
3 | | -/*<![CDATA[*/ |
4 | | - |
5 | | -// data = [ div, link ] |
6 | | -YAHOO.WRequest.toggle = function( e, data ) { |
7 | | - YAHOO.util.Event.preventDefault(e); |
8 | | - |
9 | | - var display = ''; |
10 | | - var text = ''; |
11 | | - |
12 | | - if ( 'none' != YAHOO.util.Dom.getStyle( data[0], 'display' ) ) { |
13 | | - display = 'none'; |
14 | | - text = <?php echo Xml::encodeJsVar( wfMsg( 'createpage-show' ) ) ?>; |
15 | | - opacity = 0; |
16 | | - |
17 | | - onFadeEnd = function() { |
18 | | - YAHOO.util.Dom.setStyle(data[0], 'display', display); |
19 | | - YAHOO.util.Dom.get(data[1]).innerHTML = text; |
20 | | - } |
21 | | - |
22 | | - var fade = new YAHOO.util.Anim(YAHOO.util.Dom.get(data[0]), {opacity: {to: opacity}}, 0.5); |
23 | | - fade.onComplete.subscribe(onFadeEnd); |
24 | | - fade.animate(); |
25 | | - } else { |
26 | | - display = 'block'; |
27 | | - text = <?php echo Xml::encodeJsVar( wfMsg( 'createpage-hide' ) ) ?>; |
28 | | - opacity = 1; |
29 | | - |
30 | | - YAHOO.util.Dom.setStyle(data[0], 'opacity', 0); |
31 | | - |
32 | | - YAHOO.util.Dom.setStyle(data[0], 'display', display); |
33 | | - YAHOO.util.Dom.get(data[1]).innerHTML = text; |
34 | | - |
35 | | - var fade = new YAHOO.util.Anim(YAHOO.util.Dom.get(data[0]), {opacity: {to: opacity}}, 0.5); |
36 | | - fade.animate(); |
37 | | - } |
38 | | - |
39 | | -}; |
40 | | - |
41 | | -YAHOO.util.Event.addListener('cp-chooser-toggle', 'click', YAHOO.WRequest.toggle, ['cp-chooser', 'cp-chooser-toggle']); |
42 | | - |
43 | | -// FIXME onAvailable? |
44 | | -var listeners = YAHOO.util.Event.getListeners('cp-infobox-toggle'); |
45 | | -if ( listeners ) { |
46 | | - for ( var i = 0; i < listeners.length; ++i ) { |
47 | | - var listener = listeners[i]; |
48 | | - if ( listener.type != 'click' ) { |
49 | | - YAHOO.util.Event.addListener('cp-infobox-toggle', 'click', YAHOO.WRequest.toggle, ['cp-infobox', 'cp-infobox-toggle']); |
50 | | - } |
51 | | - } |
52 | | -} else { |
53 | | - YAHOO.util.Event.addListener('cp-infobox-toggle', 'click', YAHOO.WRequest.toggle, ['cp-infobox', 'cp-infobox-toggle']); |
54 | | -} |
55 | | -/*]]>*/ |
56 | | -</script> |
\ No newline at end of file |
Index: trunk/extensions/CreateAPage/templates/title-check.tmpl.php |
— | — | @@ -1,64 +0,0 @@ |
2 | | -<script type="text/javascript"> |
3 | | -/*<![CDATA[*/ |
4 | | -YAHOO.namespace('WRequest'); |
5 | | -YAHOO.namespace('Createpage'); |
6 | | -YAHOO.namespace('CreatepageInfobox'); |
7 | | - |
8 | | -var DisabledCr = false; |
9 | | - |
10 | | -var ajaxpath = wgScriptPath + '/index.php'; |
11 | | - |
12 | | -YAHOO.WRequest.callbackTitle = { |
13 | | - success: |
14 | | - function( r ) { |
15 | | - YAHOO.util.Dom.get('cp-title-check').innerHTML = ''; |
16 | | - if( /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test( r.responseText ) ) { |
17 | | - var res = eval( '(' + r.responseText + ')' ); |
18 | | - } |
19 | | - if ( ( false != res['text'] ) && ( true != res['empty'] ) ) { |
20 | | - var url = res['url' ].replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); |
21 | | - var text = res['text'].replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); |
22 | | - |
23 | | - YAHOO.util.Dom.get('cp-title-check').innerHTML = '<span style="color: red;"><?php echo wfMsg( 'createpage-article-exists' ) ?> <a href="' + url + '?action=edit" title="' + text + '">' + text + '</a><?php echo wfMsg( 'createpage-article-exists2' ) ?></span>'; |
24 | | - if ( YAHOO.Createpage.Overlay ) { |
25 | | - YAHOO.Createpage.Overlay.show(); |
26 | | - var helperButton = YAHOO.util.Dom.get( 'wpRunInitialCheck' ); |
27 | | - helperButton.style.display = ''; |
28 | | - } else { |
29 | | - YAHOO.Createpage.ContentOverlay(); |
30 | | - } |
31 | | - } else if ( true == res['empty'] ) { |
32 | | - YAHOO.util.Dom.get('cp-title-check').innerHTML = '<span style="color: red;"><?php echo wfMsg( 'createpage-title-invalid' ) ?></span>'; |
33 | | - if ( YAHOO.Createpage.Overlay ) { |
34 | | - YAHOO.Createpage.ResizeOverlay( 0 ); |
35 | | - YAHOO.Createpage.Overlay.show(); |
36 | | - var helperButton = YAHOO.util.Dom.get( 'wpRunInitialCheck' ); |
37 | | - helperButton.style.display = ''; |
38 | | - } else { |
39 | | - YAHOO.Createpage.ContentOverlay(); |
40 | | - } |
41 | | - } else { |
42 | | - if ( YAHOO.Createpage.Overlay ) { |
43 | | - YAHOO.Createpage.Overlay.hide(); |
44 | | - var helperButton = YAHOO.util.Dom.get( 'wpRunInitialCheck' ); |
45 | | - helperButton.style.display = 'none'; |
46 | | - } |
47 | | - } |
48 | | - NoCanDo = false; |
49 | | - }, |
50 | | - failure: |
51 | | - function( r ) { |
52 | | - YAHOO.util.Dom.get('cp-title-check').innerHTML = ''; |
53 | | - }, |
54 | | - timeout: 50000 |
55 | | -}; |
56 | | - |
57 | | -YAHOO.WRequest.watchTitle = function( e ) { |
58 | | - YAHOO.util.Dom.get('cp-title-check').innerHTML = '<img src="' + wgServer + wgScriptPath + '/extensions/CreateAPage/images/process_bar.gif" width="70" height="11" alt="<?php echo wfMsg( 'createpage-please-wait' ) ?>" border="0" />'; |
59 | | - NoCanDo = true; |
60 | | - YAHOO.util.Connect.asyncRequest( 'GET', ajaxpath + '?action=ajax&rs=axTitleExists&title=' + YAHOO.util.Dom.get('Createtitle').value, YAHOO.WRequest.callbackTitle ); |
61 | | -}; |
62 | | - |
63 | | -YAHOO.util.Event.addListener( 'Createtitle', 'change', YAHOO.WRequest.watchTitle ); |
64 | | -/*]]>*/ |
65 | | -</script> |
\ No newline at end of file |
Index: trunk/extensions/CreateAPage/templates/editpage.tmpl.php |
— | — | @@ -28,7 +28,11 @@ |
29 | 29 | $visible = ''; |
30 | 30 | while( $i < count( $boxes ) - 1 ) { |
31 | 31 | $i++; |
32 | | - if ( ( $boxes[$i]['type'] == 'title' ) || ( $boxes[$i]['type'] == 'optional_textarea' ) ) { |
| 32 | + if ( |
| 33 | + ( $boxes[$i]['type'] == 'title' ) || |
| 34 | + ( $boxes[$i]['type'] == 'optional_textarea' ) |
| 35 | + ) |
| 36 | + { |
33 | 37 | $title_found = true; |
34 | 38 | if ( $boxes[$i]['type'] == 'optional_textarea' ) { |
35 | 39 | $optionalSections[] = array( $sections, $box['value'] ); |
— | — | @@ -107,8 +111,6 @@ |
108 | 112 | </div> |
109 | 113 | <?php |
110 | 114 | } |
111 | | - |
112 | | - |
113 | 115 | ?> |
114 | 116 | |
115 | 117 | |
Index: trunk/extensions/CreateAPage/templates/infobox.tmpl.php |
— | — | @@ -37,7 +37,12 @@ |
38 | 38 | |
39 | 39 | <script type="text/javascript"> |
40 | 40 | /*<![CDATA[*/ |
41 | | -YAHOO.util.Event.onContentReady('<?php echo "wpInfoboxPar" . $inf_par_num ?>', YAHOO.Createpage.ClearInput, {num: <?php echo $inf_par_num ?>}); |
| 41 | +var ourInfoboxElement = jQuery( '#wpInfoboxPar<?php echo $inf_par_num ?>' ); |
| 42 | +if ( ourInfoboxElement.length > 0 ) { |
| 43 | + jQuery( document ).ready( function( e ) { |
| 44 | + CreateAPage.clearInput( e, {num: <?php echo $inf_par_num ?>} ); |
| 45 | + }); |
| 46 | +} |
42 | 47 | /*]]>*/ |
43 | 48 | </script> |
44 | 49 | <?php |
Index: trunk/extensions/CreateAPage/templates/templates-list.tmpl.php |
— | — | @@ -33,888 +33,47 @@ |
34 | 34 | |
35 | 35 | <script type="text/javascript"> |
36 | 36 | /*<![CDATA[*/ |
| 37 | +CreateAPage.previewMode = '<?php echo !$ispreview ? 'No' : 'Yes' ?>'; |
| 38 | +CreateAPage.redLinkMode = '<?php echo !$isredlink ? 'No' : 'Yes' ?>'; |
37 | 39 | |
38 | | -var NoCanDo = false; |
39 | | - |
40 | | -YAHOO.Createpage.PreviewMode = '<?php echo !$ispreview ? 'No' : 'Yes' ?>'; |
41 | | -YAHOO.Createpage.RedLinkMode = '<?php echo !$isredlink ? 'No' : 'Yes' ?>'; |
42 | | - |
43 | | -YAHOO.Createpage.RedirectCallback = { |
44 | | - success: function( oResponse ) { |
45 | | - window.location = wgServer + wgScript + '?title=' + escape( document.getElementById('Createtitle').value ) + '&action=edit&editmode=nomulti&createpage=true'; |
46 | | - }, |
47 | | - failure: function( oResponse ) { |
48 | | - }, |
49 | | - timeout: 50000 |
50 | | -}; |
51 | | - |
52 | | -YAHOO.Createpage.SubmitEnabled = false; |
53 | | - |
54 | | -YAHOO.Createpage.ClearInput = function( o ) { |
55 | | - var Cdone = false; |
56 | | - var Infobox_callback = function( e, o ) { |
57 | | - var previewarea = YAHOO.util.Dom.get('createpagepreview'); |
58 | | - if ( !Cdone && ( previewarea == null ) ) { |
59 | | - Cdone = true; |
60 | | - YAHOO.util.Dom.get('wpInfoboxPar' + o.num).value = ''; |
61 | | - } |
62 | | - } |
63 | | - YAHOO.util.Event.addListener( 'wpInfoboxPar' + o.num, 'focus', Infobox_callback, {num: o.num} ); |
64 | | -}; |
65 | | - |
66 | | -YAHOO.Createpage.goToEdit = function( e ) { |
67 | | - var oForm = YAHOO.util.Dom.get('createpageform'); |
68 | | - YAHOO.util.Event.preventDefault(e); |
69 | | - YAHOO.util.Connect.setForm( oForm, false ); |
70 | | - YAHOO.util.Connect.asyncRequest( 'POST', wgScriptPath + '/index.php?action=ajax&rs=axCreatepageAdvancedSwitch', YAHOO.Createpage.RedirectCallback ); |
71 | | - YAHOO.Createpage.warningPanel.hide(); |
72 | | -} |
73 | | - |
74 | | -YAHOO.Createpage.goToLogin = function( e ) { |
75 | | - YAHOO.util.Event.preventDefault(e); |
76 | | - if ( YAHOO.Createpage.RedLinkMode ) { |
77 | | - window.location = wgServer + wgScript + '?title=Special:UserLogin&returnto=' + escape( document.getElementById('Createtitle').value ); |
78 | | - } else { |
79 | | - window.location = wgServer + wgScript + '?title=Special:UserLogin&returnto=Special:CreatePage'; |
80 | | - } |
81 | | -} |
82 | | - |
83 | | -YAHOO.Createpage.hideWarningPanel = function( e ) { |
84 | | - if ( YAHOO.Createpage.warningPanel ) { |
85 | | - YAHOO.Createpage.warningPanel.hide(); |
86 | | - } |
87 | | -} |
88 | | - |
89 | | -YAHOO.Createpage.showWarningPanel = function( e ) { |
90 | | - YAHOO.util.Event.preventDefault(e); |
91 | | - if ( document.getElementById('Createtitle').value != '' ) { |
92 | | - if ( !YAHOO.Createpage.warningPanel ) { |
93 | | - YAHOO.Createpage.buildWarningPanel(); |
94 | | - } |
95 | | - YAHOO.Createpage.warningPanel.show(); |
96 | | - YAHOO.util.Dom.get('wpCreatepageWarningYes').focus(); |
97 | | - } else { |
98 | | - YAHOO.util.Dom.get('cp-title-check').innerHTML = '<span style="color: red;"><?php echo wfMsg( 'createpage-give-title' ) ?></span>'; |
99 | | - } |
100 | | -} |
101 | | - |
102 | | -YAHOO.Createpage.hideWarningLoginPanel = function( e ) { |
103 | | - if ( YAHOO.Createpage.warningLoginPanel ) { |
104 | | - YAHOO.Createpage.warningLoginPanel.hide(); |
105 | | - } |
106 | | -} |
107 | | - |
108 | | -YAHOO.Createpage.showWarningLoginPanel = function( e ) { |
109 | | - YAHOO.util.Event.preventDefault(e); |
110 | | - if ( document.getElementById('Createtitle').value != '' ) { |
111 | | - if ( !YAHOO.Createpage.warningLoginPanel ) { |
112 | | - YAHOO.Createpage.buildWarningLoginPanel(); |
113 | | - } |
114 | | - YAHOO.Createpage.warningLoginPanel.show(); |
115 | | - YAHOO.util.Dom.get('wpCreatepageWarningYes').focus(); |
116 | | - } else { |
117 | | - YAHOO.util.Dom.get('cp-title-check').innerHTML = '<span style="color: red;"><?php echo wfMsg( 'createpage-give-title' ) ?></span>'; |
118 | | - } |
119 | | -} |
120 | | - |
121 | | -YAHOO.Createpage.Abort = function( e, o ) { |
122 | | - YAHOO.util.Connect.abort( o.request, o.callback ); |
123 | | -} |
124 | | - |
125 | | -YAHOO.Createpage.ToolbarButtons = []; |
126 | | - |
127 | 40 | <?php |
128 | | - $tool_arr = CreateMultiPage::getToolArray(); |
129 | | - $tool_num = 0; |
130 | | - global $wgStylePath; |
131 | | - foreach ( $tool_arr as $single_tool ) { ?> |
132 | | - YAHOO.Createpage.ToolbarButtons[<?php echo $tool_num ?>] = []; |
133 | | - YAHOO.Createpage.ToolbarButtons[<?php echo $tool_num ?>]['image'] = '<?php echo $wgStylePath . '/common/images/' . $single_tool['image'] ?>'; |
134 | | - YAHOO.Createpage.ToolbarButtons[<?php echo $tool_num ?>]['id'] = '<?php echo $single_tool['id'] ?>'; |
135 | | - YAHOO.Createpage.ToolbarButtons[<?php echo $tool_num ?>]['open'] = '<?php echo $single_tool['open'] ?>'; |
136 | | - YAHOO.Createpage.ToolbarButtons[<?php echo $tool_num ?>]['close'] = '<?php echo $single_tool['close'] ?>'; |
137 | | - YAHOO.Createpage.ToolbarButtons[<?php echo $tool_num ?>]['sample'] = '<?php echo $single_tool['sample'] ?>'; |
138 | | - YAHOO.Createpage.ToolbarButtons[<?php echo $tool_num ?>]['tip'] = '<?php echo $single_tool['tip'] ?>'; |
139 | | - YAHOO.Createpage.ToolbarButtons[<?php echo $tool_num ?>]['key'] = '<?php echo $single_tool['key'] ?>'; |
| 41 | +$tool_arr = CreateMultiPage::getToolArray(); |
| 42 | +$tool_num = 0; |
| 43 | +foreach ( $tool_arr as $single_tool ) { ?> |
| 44 | +CreateAPage.toolbarButtons[<?php echo $tool_num ?>] = []; |
| 45 | +CreateAPage.toolbarButtons[<?php echo $tool_num ?>]['image'] = stylepath + '/common/images/' + '<?php echo $single_tool['image'] ?>'; |
| 46 | +CreateAPage.toolbarButtons[<?php echo $tool_num ?>]['id'] = '<?php echo $single_tool['id'] ?>'; |
| 47 | +CreateAPage.toolbarButtons[<?php echo $tool_num ?>]['open'] = '<?php echo $single_tool['open'] ?>'; |
| 48 | +CreateAPage.toolbarButtons[<?php echo $tool_num ?>]['close'] = '<?php echo $single_tool['close'] ?>'; |
| 49 | +CreateAPage.toolbarButtons[<?php echo $tool_num ?>]['sample'] = '<?php echo $single_tool['sample'] ?>'; |
| 50 | +CreateAPage.toolbarButtons[<?php echo $tool_num ?>]['tip'] = '<?php echo $single_tool['tip'] ?>'; |
| 51 | +CreateAPage.toolbarButtons[<?php echo $tool_num ?>]['key'] = '<?php echo $single_tool['key'] ?>'; |
140 | 52 | <?php |
141 | | - $tool_num++; |
142 | | - } |
143 | | -?> |
144 | | - |
145 | | -YAHOO.Createpage.UploadCallback = function( oResponse ) { |
146 | | - if( /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test( oResponse.responseText ) ) { |
147 | | - var aResponse = eval( '(' + oResponse.responseText + ')' ); |
148 | | - } |
149 | | - var ProgressBar = YAHOO.util.Dom.get( 'createpage_upload_progress_section' + aResponse['num'] ); |
150 | | - |
151 | | - if ( aResponse['error'] != 1 ) { |
152 | | - ProgressBar.innerHTML = "<?php echo wfMsg( 'createpage-img-uploaded' ) ?>"; |
153 | | - var target_info = YAHOO.util.Dom.get( 'wpAllUploadTarget' + aResponse['num'] ).value; |
154 | | - var target_tag = YAHOO.util.Dom.get( target_info ); |
155 | | - target_tag.value = '[[' + aResponse['msg'] + '|thumb]]'; |
156 | | - |
157 | | - var ImageThumbnail = YAHOO.util.Dom.get( 'createpage_image_thumb_section' + aResponse['num'] ); |
158 | | - var thumb_container = YAHOO.util.Dom.get( 'createpage_main_thumb_section' + aResponse['num'] ); |
159 | | - var tempstamp = new Date(); |
160 | | - ImageThumbnail.src = aResponse['url'] + '?' + tempstamp.getTime(); |
161 | | - if ( YAHOO.util.Dom.get( 'wpAllLastTimestamp' + aResponse['num'] ).value == 'None' ) { |
162 | | - var break_tag = document.createElement('br'); |
163 | | - thumb_container.style.display = ''; |
164 | | - var label_node = YAHOO.util.Dom.get( 'createpage_image_label_section' + aResponse['num'] ); |
165 | | - var par_node = label_node.parentNode; |
166 | | - par_node.insertBefore( break_tag, label_node ); |
167 | | - } |
168 | | - YAHOO.util.Dom.get( 'wpAllLastTimestamp' + oResponse.argument ).value = aResponse['timestamp']; |
169 | | - } else if ( ( aResponse['error'] == 1 ) && ( aResponse['msg'] == 'cp_no_login' ) ) { |
170 | | - ProgressBar.innerHTML = '<span style="color: red"><?php echo wfMsg( 'createpage-login-required' ) ?>' + '<a href="' + wgServer + wgScript +'?title=Special:Userlogin&returnto=Special:Createpage" id="createpage_login' + oResponse.argument + '"><?php echo wfMsg( 'createpage-login-href' ) ?></a>' + "<?php echo wfMsg( 'createpage-login-required2' ) ?></span>"; |
171 | | - YAHOO.util.Event.addListener( 'createpage_login' + oResponse.argument, 'click', YAHOO.Createpage.showWarningLoginPanel ); |
172 | | - } else { |
173 | | - ProgressBar.innerHTML = '<span style="color: red">' + aResponse['msg'] + '</span>'; |
174 | | - } |
175 | | - |
176 | | - YAHOO.util.Dom.get( 'createpage_image_text_section' + oResponse.argument ).innerHTML = "<?php echo wfMsg( 'createpage-insert-image' ) ?>"; |
177 | | - YAHOO.util.Dom.get( 'createpage_upload_file_section' + oResponse.argument ).style.display = ''; |
178 | | - YAHOO.util.Dom.get( 'createpage_image_text_section' + oResponse.argument ).style.display = ''; |
179 | | - YAHOO.util.Dom.get( 'createpage_image_cancel_section' + oResponse.argument ).style.display = 'none'; |
180 | | -}; |
181 | | - |
182 | | -YAHOO.Createpage.FailureCallback = function( oResponse ) { |
183 | | - YAHOO.util.Dom.get( 'createpage_image_text_section' + oResponse.argument ).innerHTML = "<?php echo wfMsg( 'createpage-insert-image' ) ?>"; |
184 | | - YAHOO.util.Dom.get( 'createpage_upload_progress_section' + oResponse.argument ).innerHTML = "<?php echo wfMsg( 'createpage-upload-aborted' ) ?>"; |
185 | | - YAHOO.util.Dom.get( 'createpage_upload_file_section' + oResponse.argument ).style.display = ''; |
186 | | - YAHOO.util.Dom.get( 'createpage_image_text_section' + oResponse.argument ).style.display = ''; |
187 | | - YAHOO.util.Dom.get( 'createpage_image_cancel_section' + oResponse.argument ).style.display = 'none'; |
188 | | -}; |
189 | | - |
190 | | -YAHOO.Createpage.RestoreSection = function( section, text ) { |
191 | | - var section_content = YAHOO.util.Dom.getElementsBy( YAHOO.Createpage.OptionalContentTest, '', section ); |
192 | | - for( var i = 0; i < section_content.length; i++ ) { |
193 | | - text = text.replace( section_content[i].id, '' ); |
194 | | - } |
195 | | - section.style.display = 'block'; |
196 | | - return text; |
| 53 | + $tool_num++; |
197 | 54 | } |
198 | | - |
199 | | -YAHOO.Createpage.UnuseSection = function( section, text ) { |
200 | | - var section_content = YAHOO.util.Dom.getElementsBy( YAHOO.Createpage.OptionalContentTest, '', section ); |
201 | | - var first = true; |
202 | | - var ivalue = ''; |
203 | | - for( var i = 0; i < section_content.length; i++ ) { |
204 | | - if ( first ) { |
205 | | - if ( '' != text ) { |
206 | | - ivalue += ','; |
207 | | - } |
208 | | - first = false; |
209 | | - } else { |
210 | | - ivalue += ','; |
211 | | - } |
212 | | - ivalue += section_content[i].id; |
213 | | - } |
214 | | - section.style.display = 'none'; |
215 | | - return text + ivalue; |
216 | | -} |
217 | | - |
218 | | -YAHOO.Createpage.ToggleSection = function( e, o ) { |
219 | | - var section = YAHOO.util.Dom.get( 'createpage_section_' + o.num ); |
220 | | - var input = YAHOO.util.Dom.get( 'wpOptionalInput' + o.num ); |
221 | | - var optionals = YAHOO.util.Dom.get( 'wpOptionals' ); |
222 | | - var ivalue = ''; |
223 | | - if ( input.checked ) { |
224 | | - optionals.value = YAHOO.Createpage.RestoreSection( section, optionals.value ); |
225 | | - } else { |
226 | | - optionals.value = YAHOO.Createpage.UnuseSection( section, optionals.value ); |
227 | | - } |
228 | | -} |
229 | | - |
230 | | -YAHOO.Createpage.Upload = function( e, o ) { |
231 | | - var oForm = YAHOO.util.Dom.get('createpageform'); |
232 | | - YAHOO.util.Event.preventDefault(e); |
233 | | - YAHOO.util.Connect.setForm( oForm, true ); |
234 | | - |
235 | | - var ProgressBar = YAHOO.util.Dom.get('createpage_upload_progress_section' + o.num); |
236 | | - ProgressBar.style.display = 'block'; |
237 | | - ProgressBar.innerHTML = '<img src="' + wgServer + stylepath + '/skins/common/images/spinner.gif" width="16" height="16" alt="wait" border="0" /> '; |
238 | | - |
239 | | - var callback = { |
240 | | - success: YAHOO.Createpage.UploadCallback, |
241 | | - failure: YAHOO.Createpage.FailureCallback, |
242 | | - argument: [o.num], |
243 | | - timeout: 240000 |
244 | | - } |
245 | | - |
246 | | - var sent_request = YAHOO.util.Connect.asyncRequest( 'POST', wgScriptPath + '/index.php?action=ajax&rs=axMultiEditImageUpload&infix=All&num=' + o.num, callback ); |
247 | | - YAHOO.util.Dom.get( 'createpage_image_cancel_section' + o.num ).style.display = ''; |
248 | | - YAHOO.util.Dom.get( 'createpage_image_text_section' + o.num ).style.display = 'none'; |
249 | | - |
250 | | - YAHOO.util.Event.addListener( 'createpage_image_cancel_section' + o.num, 'click', YAHOO.Createpage.Abort, {"request": sent_request, "callback": callback} ); |
251 | | - |
252 | | - var neoInput = document.createElement( 'input' ); |
253 | | - var thisInput = YAHOO.util.Dom.get('createpage_upload_file_section' + o.num); |
254 | | - var thisContainer = YAHOO.util.Dom.get('createpage_image_label_section' + o.num); |
255 | | - thisContainer.removeChild( thisInput ); |
256 | | - |
257 | | - neoInput.setAttribute( 'type', 'file' ); |
258 | | - neoInput.setAttribute( 'id', 'createpage_upload_file_section' + o.num ); |
259 | | - neoInput.setAttribute( 'name', 'wpAllUploadFile' + o.num ); |
260 | | - neoInput.setAttribute( 'tabindex', '-1' ); |
261 | | - |
262 | | - thisContainer.appendChild( neoInput ); |
263 | | - YAHOO.util.Event.addListener( 'createpage_upload_file_section' + o.num, 'change', YAHOO.Createpage.Upload, {"num" : o.num } ); |
264 | | - |
265 | | - YAHOO.util.Dom.get( 'createpage_upload_file_section' + o.num ).style.display = 'none'; |
266 | | -} |
267 | | - |
268 | | -YAHOO.Createpage.buildWarningPanel = function( e ) { |
269 | | - var editwarn = document.getElementById( 'createpage_advanced_warning' ); |
270 | | - var editwarn_copy = document.createElement( 'div' ); |
271 | | - editwarn_copy.id = 'createpage_warning_copy'; |
272 | | - editwarn_copy.innerHTML = editwarn.innerHTML; |
273 | | - document.body.appendChild( editwarn_copy ); |
274 | | - YAHOO.Createpage.warningPanel = new YAHOO.widget.Panel('createpage_warning_copy', { |
275 | | - width: '250px', |
276 | | - modal: true, |
277 | | - constraintoviewport: true, |
278 | | - draggable: false, |
279 | | - fixedcenter: true, |
280 | | - underlay: 'none' |
281 | | - } ); |
282 | | - YAHOO.Createpage.warningPanel.cfg.setProperty( 'zIndex', 1000 ); |
283 | | - YAHOO.Createpage.warningPanel.render( document.body ); |
284 | | - YAHOO.util.Event.addListener( 'wpCreatepageWarningYes', 'click', YAHOO.Createpage.goToEdit ); |
285 | | - YAHOO.util.Event.addListener( 'wpCreatepageWarningNo', 'click', YAHOO.Createpage.hideWarningPanel ); |
286 | | -} |
287 | | - |
288 | | -YAHOO.Createpage.buildWarningLoginPanel = function( e ) { |
289 | | - var editwarn = document.getElementById( 'createpage_advanced_warning' ); |
290 | | - var editwarn_copy = document.createElement( 'div' ); |
291 | | - editwarn_copy.id = 'createpage_warning_copy2'; |
292 | | - editwarn_copy.innerHTML = editwarn.innerHTML; |
293 | | - editwarn_copy.childNodes[1].innerHTML = "<?php echo wfMsg( 'login' ) ?>"; |
294 | | - editwarn_copy.childNodes[3].innerHTML = "<?php echo wfMsg( 'createpage-login-warning' ) ?>"; |
295 | | - document.body.appendChild( editwarn_copy ); |
296 | | - YAHOO.Createpage.warningLoginPanel = new YAHOO.widget.Panel('createpage_warning_copy2', { |
297 | | - width: '250px', |
298 | | - modal: true, |
299 | | - constraintoviewport: true, |
300 | | - draggable: false, |
301 | | - fixedcenter: true, |
302 | | - underlay: 'none' |
303 | | - } ); |
304 | | - YAHOO.Createpage.warningLoginPanel.cfg.setProperty( 'zIndex', 1000 ); |
305 | | - YAHOO.Createpage.warningLoginPanel.render( document.body ); |
306 | | - YAHOO.util.Event.addListener( 'wpCreatepageWarningYes', 'click', YAHOO.Createpage.goToLogin ); |
307 | | - YAHOO.util.Event.addListener( 'wpCreatepageWarningNo', 'click', YAHOO.Createpage.hideWarningLoginPanel ); |
308 | | -} |
309 | | - |
310 | | -YAHOO.Createpage.onclickCategoryFn = function( cat, id ) { |
311 | | - return function() { |
312 | | - cloudRemove( escape( cat ), id ); |
313 | | - return false; |
314 | | - } |
315 | | -} |
316 | | - |
317 | | -YAHOO.Createpage.clearTitleMessage = function( e ) { |
318 | | - YAHOO.util.Event.preventDefault(e); |
319 | | - YAHOO.util.Dom.get('cp-title-check').innerHTML = ''; |
320 | | -} |
321 | | - |
322 | | -YAHOO.Createpage.UploadTest = function( el ) { |
323 | | - if ( el.id.match( 'createpage_upload_file_section' ) ) { |
324 | | - return true; |
325 | | - } else { |
326 | | - return false; |
327 | | - } |
328 | | -} |
329 | | - |
330 | | -YAHOO.Createpage.EditTextareaTest = function( el ) { |
331 | | - if ( el.id.match( 'wpTextboxes' ) && ( el.style.display != 'none' ) ) { |
332 | | - return true; |
333 | | - } else { |
334 | | - return false; |
335 | | - } |
336 | | -} |
337 | | - |
338 | | -YAHOO.Createpage.OptionalSectionTest = function( el ) { |
339 | | - if ( el.id.match( 'wpOptionalInput' ) && ( el.style.display != 'none' ) ) { |
340 | | - return true; |
341 | | - } else { |
342 | | - return false; |
343 | | - } |
344 | | -} |
345 | | - |
346 | | -YAHOO.Createpage.OptionalContentTest = function( el ) { |
347 | | - if ( el.id.match( 'wpTextboxes' ) ) { |
348 | | - return true; |
349 | | - } else { |
350 | | - return false; |
351 | | - } |
352 | | -} |
353 | | - |
354 | | -YAHOO.Createpage.UploadEvent = function( el ) { |
355 | | - var j = parseInt( el.id.replace( 'createpage_upload_file_section', '' ) ); |
356 | | - YAHOO.util.Event.addListener( 'createpage_upload_file_section' + j, 'change', YAHOO.Createpage.Upload, {num : j } ); |
357 | | -} |
358 | | - |
359 | | -YAHOO.Createpage.TextareaAddToolbar = function( el ) { |
360 | | - var el_id = parseInt( el.id.replace( 'wpTextboxes', '' ) ); |
361 | | - YAHOO.Createpage.multiEditTextboxes[YAHOO.Createpage.multiEditTextboxes.length] = el_id; |
362 | | - YAHOO.Createpage.multiEditButtons[el_id] = []; |
363 | | - YAHOO.Createpage.multiEditCustomButtons[el_id] = []; |
364 | | - YAHOO.util.Event.addListener( el.id, 'focus', YAHOO.Createpage.showThisBox, {'toolbarId' : el_id } ); |
365 | | - |
366 | | - YAHOO.util.Event.addListener( 'wpTextIncrease' + el_id, 'click', YAHOO.Createpage.resizeThisTextarea, {'textareaId' : el_id, 'numRows' : 1 } ); |
367 | | - YAHOO.util.Event.addListener( 'wpTextDecrease' + el_id, 'click', YAHOO.Createpage.resizeThisTextarea, {'textareaId' : el_id, 'numRows' : -1 } ); |
368 | | - |
369 | | - for ( var i = 0; i < YAHOO.Createpage.ToolbarButtons.length; i++ ) { |
370 | | - YAHOO.Createpage.addMultiEditButton( |
371 | | - YAHOO.Createpage.ToolbarButtons[i]['image'], |
372 | | - YAHOO.Createpage.ToolbarButtons[i]['tip'], |
373 | | - YAHOO.Createpage.ToolbarButtons[i]['open'], |
374 | | - YAHOO.Createpage.ToolbarButtons[i]['close'], |
375 | | - YAHOO.Createpage.ToolbarButtons[i]['sample'], |
376 | | - YAHOO.Createpage.ToolbarButtons[i]['id'] + el_id, |
377 | | - el_id |
378 | | - ); |
379 | | - } |
380 | | -} |
381 | | - |
382 | | -YAHOO.Createpage.foundCategories = []; |
383 | | - |
384 | | -YAHOO.Createpage.CheckCategoryCloud = function() { |
385 | | - var cat_textarea = YAHOO.util.Dom.get('wpCategoryTextarea'); |
386 | | - if ( !cat_textarea ) { |
387 | | - return; |
388 | | - } |
389 | | - |
390 | | - var cat_full_section = YAHOO.util.Dom.get('createpage_cloud_section'); |
391 | | - |
392 | | - var cloud_num = ( cat_full_section.childNodes.length - 1 ) / 2; |
393 | | - var n_cat_count = cloud_num; |
394 | | - var text_categories = new Array(); |
395 | | - for ( i = 0; i < cloud_num; i++ ) { |
396 | | - var cloud_id = 'cloud' + i; |
397 | | - var found_category = YAHOO.util.Dom.get(cloud_id).innerHTML; |
398 | | - if ( found_category ) { |
399 | | - YAHOO.Createpage.foundCategories[i] = found_category; |
400 | | - } |
401 | | - } |
402 | | - |
403 | | - var categories = cat_textarea.value; |
404 | | - if ( '' == categories ) { |
405 | | - return; |
406 | | - } |
407 | | - |
408 | | - categories = categories.split("|"); |
409 | | - for ( i = 0; i < categories.length; i++ ) { |
410 | | - text_categories [i] = categories[i]; |
411 | | - } |
412 | | - |
413 | | - for ( i = 0; i < text_categories.length;i++) { |
414 | | - var c_found = false; |
415 | | - for ( j in YAHOO.Createpage.foundCategories ) { |
416 | | - var core_cat = text_categories[i].replace (/\|.*/,''); |
417 | | - if ( YAHOO.Createpage.foundCategories[j] == core_cat ) { |
418 | | - this_button = YAHOO.util.Dom.get('cloud' + j); |
419 | | - var actual_cloud = YAHOO.Createpage.foundCategories[j]; |
420 | | - var cl_num = j; |
421 | | - |
422 | | - this_button.onclick = YAHOO.Createpage.onclickCategoryFn( text_categories[i], j ); |
423 | | - this_button.style.color = '#419636'; |
424 | | - c_found = true; |
425 | | - break; |
426 | | - } |
427 | | - } |
428 | | - if ( !c_found ) { |
429 | | - var n_cat = document.createElement( 'a' ); |
430 | | - var s_cat = document.createElement( 'span' ); |
431 | | - n_cat_count++; |
432 | | - var cat_num = n_cat_count - 1; |
433 | | - n_cat.setAttribute( 'id', 'cloud' + cat_num ); |
434 | | - n_cat.setAttribute( 'href', '#' ); |
435 | | - n_cat.onclick = YAHOO.Createpage.onclickCategoryFn( text_categories[i], cat_num ); |
436 | | - n_cat.style.color = '#419636'; |
437 | | - n_cat.style.fontSize = '10pt'; |
438 | | - s_cat.setAttribute( 'id', 'tag' + n_cat_count ); |
439 | | - t_cat = document.createTextNode( core_cat ); |
440 | | - space = document.createTextNode( ' ' ); |
441 | | - n_cat.appendChild( t_cat ); |
442 | | - s_cat.appendChild( n_cat ); |
443 | | - s_cat.appendChild( space ); |
444 | | - cat_full_section.appendChild( s_cat ); |
445 | | - } |
446 | | - } |
447 | | -} |
448 | | - |
449 | | -YAHOO.Createpage.multiEditTextboxes = []; |
450 | | -YAHOO.Createpage.multiEditButtons = []; |
451 | | -YAHOO.Createpage.multiEditCustomButtons = []; |
452 | | - |
453 | | -YAHOO.Createpage.addMultiEditButton = function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, toolbarId ) { |
454 | | - YAHOO.Createpage.multiEditButtons[toolbarId][YAHOO.Createpage.multiEditButtons[toolbarId].length] = { |
455 | | - 'imageId': imageId, |
456 | | - 'toolbarId': toolbarId, |
457 | | - 'imageFile': imageFile, |
458 | | - 'speedTip': speedTip, |
459 | | - 'tagOpen': tagOpen, |
460 | | - 'tagClose': tagClose, |
461 | | - 'sampleText': sampleText |
462 | | - }; |
463 | | -} |
464 | | - |
465 | | -YAHOO.Createpage.showThisBox = function( e, o ) { |
466 | | - YAHOO.util.Event.preventDefault(e); |
467 | | - YAHOO.util.Dom.get('toolbar' + o.toolbarId).style.display = ''; |
468 | | - YAHOO.Createpage.hideOtherBoxes(o.toolbarId); |
469 | | -} |
470 | | - |
471 | | -YAHOO.Createpage.resizeThisTextarea = function( e, o ) { |
472 | | - YAHOO.util.Event.preventDefault(e); |
473 | | - var r_textarea = YAHOO.util.Dom.get( 'wpTextboxes' + o.textareaId ); |
474 | | - if ( |
475 | | - !( ( r_textarea.rows < 4 ) && ( o.numRows < 0 ) ) && |
476 | | - !( ( r_textarea.rows > 10 ) && ( o.numRows > 0 ) ) |
477 | | - ) { |
478 | | - r_textarea.rows = r_textarea.rows + o.numRows; |
479 | | - } |
480 | | -} |
481 | | - |
482 | | -YAHOO.Createpage.hideOtherBoxes = function( box_id ) { |
483 | | - for ( var i = 0; i < YAHOO.Createpage.multiEditTextboxes.length; i++ ) { |
484 | | - if ( YAHOO.Createpage.multiEditTextboxes[i] != box_id ) { |
485 | | - YAHOO.util.Dom.get( 'toolbar' + YAHOO.Createpage.multiEditTextboxes[i] ).style.display = 'none'; |
486 | | - } |
487 | | - } |
488 | | -} |
489 | | - |
490 | | -YAHOO.Createpage.multiEditSetupToolbar = function() { |
491 | | - for ( var j = 0; j < YAHOO.Createpage.multiEditButtons.length; j++ ) { |
492 | | - var toolbar = document.getElementById( 'toolbar' + j ); |
493 | | - if ( toolbar ) { |
494 | | - var textbox = document.getElementById( 'wpTextboxes' + j ); |
495 | | - if ( !textbox ) { |
496 | | - return false; |
497 | | - } |
498 | | - if ( !( document.selection && document.selection.createRange ) |
499 | | - && textbox.selectionStart === null |
500 | | - ) { |
501 | | - return false; |
502 | | - } |
503 | | - |
504 | | - for ( var i = 0; i < YAHOO.Createpage.multiEditButtons[j].length; i++ ) { |
505 | | - YAHOO.Createpage.insertMultiEditButton( toolbar, YAHOO.Createpage.multiEditButtons[j][i] ); |
506 | | - } |
507 | | - } |
508 | | - } |
509 | | - return true; |
510 | | -} |
511 | | - |
512 | | -YAHOO.Createpage.multiEditSetupOptionalSections = function() { |
513 | | - var snum = 0; |
514 | | - if ( YAHOO.util.Dom.get( 'createpage_optionals_content' ) ) { |
515 | | - var optionals = YAHOO.util.Dom.getElementsBy( YAHOO.Createpage.OptionalSectionTest, 'input', YAHOO.util.Dom.get( 'createpage_optionals_content' ) ); |
516 | | - var optionalsElements = YAHOO.util.Dom.get( 'wpOptionals' ); |
517 | | - for ( i = 0; i < optionals.length; i++ ) { |
518 | | - snum = optionals[i].id.replace( 'wpOptionalInput', '' ); |
519 | | - if ( !YAHOO.util.Dom.get( 'wpOptionalInput' + snum ).checked ) { |
520 | | - optionalsElements.value = YAHOO.Createpage.UnuseSection( YAHOO.util.Dom.get( 'createpage_section_' + snum ), optionalsElements.value ); |
521 | | - } |
522 | | - YAHOO.util.Event.addListener( optionals[i], 'change', YAHOO.Createpage.ToggleSection, {num: snum} ); |
523 | | - } |
524 | | - } |
525 | | -} |
526 | | - |
527 | | -YAHOO.Createpage.insertMultiEditButton = function( parent, item ) { |
528 | | - var image = document.createElement( 'img' ); |
529 | | - image.width = 23; |
530 | | - image.height = 22; |
531 | | - image.className = 'mw-toolbar-editbutton'; |
532 | | - if ( item.imageId ) { |
533 | | - image.id = item.imageId; |
534 | | - } |
535 | | - image.src = item.imageFile; |
536 | | - image.border = 0; |
537 | | - image.alt = item.speedTip; |
538 | | - image.title = item.speedTip; |
539 | | - image.style.cursor = 'pointer'; |
540 | | - |
541 | | - parent.appendChild( image ); |
542 | | - YAHOO.util.Event.addListener( |
543 | | - item.imageId, |
544 | | - 'click', |
545 | | - YAHOO.Createpage.insertTags, { |
546 | | - 'tagOpen' : item.tagOpen, |
547 | | - 'tagClose' : item.tagClose, |
548 | | - 'sampleText' : item.sampleText, |
549 | | - 'textareaId' : 'wpTextboxes' + item.toolbarId |
550 | | - } |
551 | | - ); |
552 | | - return true; |
553 | | -} |
554 | | - |
555 | | -YAHOO.Createpage.insertTags = function( e, o ) { |
556 | | - YAHOO.util.Event.preventDefault(e); |
557 | | - var textarea = YAHOO.util.Dom.get( o.textareaId ); |
558 | | - if ( !textarea ) { |
559 | | - return; |
560 | | - } |
561 | | - var selText, isSample = false; |
562 | | - |
563 | | - if ( document.selection && document.selection.createRange ) { |
564 | | - if ( document.documentElement && document.documentElement.scrollTop ) { |
565 | | - var winScroll = document.documentElement.scrollTop; |
566 | | - } else if ( document.body ) { |
567 | | - var winScroll = document.body.scrollTop; |
568 | | - } |
569 | | - textarea.focus(); |
570 | | - var range = document.selection.createRange(); |
571 | | - selText = range.text; |
572 | | - checkSelectedText(); |
573 | | - range.text = o.tagOpen + selText + o.tagClose; |
574 | | - if ( isSample && range.moveStart ) { |
575 | | - if ( window.opera ) { |
576 | | - o.tagClose = o.tagClose.replace(/\n/g,''); |
577 | | - } |
578 | | - range.moveStart('character', - o.tagClose.length - selText.length); |
579 | | - range.moveEnd('character', - o.tagClose.length); |
580 | | - } |
581 | | - range.select(); |
582 | | - if ( document.documentElement && document.documentElement.scrollTop ) { |
583 | | - document.documentElement.scrollTop = winScroll; |
584 | | - } else if ( document.body ) { |
585 | | - document.body.scrollTop = winScroll; |
586 | | - } |
587 | | - } else if ( textarea.selectionStart || textarea.selectionStart == '0' ) { |
588 | | - var textScroll = textarea.scrollTop; |
589 | | - textarea.focus(); |
590 | | - var startPos = textarea.selectionStart; |
591 | | - var endPos = textarea.selectionEnd; |
592 | | - selText = textarea.value.substring( startPos, endPos ); |
593 | | - checkSelectedText(); |
594 | | - textarea.value = textarea.value.substring( 0, startPos ) |
595 | | - + o.tagOpen + selText + o.tagClose |
596 | | - + textarea.value.substring( endPos, textarea.value.length ); |
597 | | - if ( isSample ) { |
598 | | - textarea.selectionStart = startPos +o.tagOpen.length; |
599 | | - textarea.selectionEnd = startPos + o.tagOpen.length + selText.length; |
600 | | - } else { |
601 | | - textarea.selectionStart = startPos + o.tagOpen.length + selText.length + o.tagClose.length; |
602 | | - textarea.selectionEnd = textarea.selectionStart; |
603 | | - } |
604 | | - textarea.scrollTop = textScroll; |
605 | | - } |
606 | | - |
607 | | - function checkSelectedText() { |
608 | | - if ( !selText ) { |
609 | | - selText = o.sampleText; |
610 | | - isSample = true; |
611 | | - } else if ( selText.charAt( selText.length - 1 ) == ' ' ) { |
612 | | - selText = selText.substring( 0, selText.length - 1 ); |
613 | | - o.tagClose += ' '; |
614 | | - } |
615 | | - } |
616 | | -} |
617 | | - |
618 | | -window.onresize = function() { |
619 | | - if ( YAHOO.Createpage.Overlay && ( YAHOO.util.Dom.get('createpageoverlay').style.visibility != 'hidden' ) ) { |
620 | | - YAHOO.Createpage.ResizeOverlay( 0 ); |
621 | | - } |
622 | | -}; |
623 | | - |
624 | | -YAHOO.CreatepageInfobox.UploadCallback = function( oResponse ) { |
625 | | - if( /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test( oResponse.responseText ) ) { |
626 | | - var aResponse = eval( '(' + oResponse.responseText + ')' ); |
627 | | - } |
628 | | - var ProgressBar = YAHOO.util.Dom.get( 'createpage_upload_progress' + oResponse.argument ); |
629 | | - if ( aResponse['error'] != 1 ) { |
630 | | - var xInfoboxText = YAHOO.util.Dom.get( 'wpInfoboxValue' ).value; |
631 | | - var xImageHelper = YAHOO.util.Dom.get( 'wpInfImg' + oResponse.argument ).value; |
632 | | - YAHOO.util.Dom.get( 'wpInfImg' + oResponse.argument ).value = aResponse['msg']; |
633 | | - YAHOO.util.Dom.get( 'wpNoUse' + oResponse.argument ).value = 'Yes'; |
634 | | - ProgressBar.innerHTML = "<?php echo wfMsg( 'createpage-img-uploaded' ) ?>"; |
635 | | - var ImageThumbnail = YAHOO.util.Dom.get( 'createpage_image_thumb' + oResponse.argument ); |
636 | | - var thumb_container = YAHOO.util.Dom.get( 'createpage_main_thumb' + oResponse.argument ); |
637 | | - var tempstamp = new Date(); |
638 | | - ImageThumbnail.src = aResponse['url'] + '?' + tempstamp.getTime(); |
639 | | - if ( YAHOO.util.Dom.get( 'wpLastTimestamp' + oResponse.argument ).value == 'None' ) { |
640 | | - var break_tag = document.createElement( 'br' ); |
641 | | - thumb_container.style.display = ''; |
642 | | - var label_node = YAHOO.util.Dom.get( 'createpage_image_label' + oResponse.argument ); |
643 | | - var par_node = label_node.parentNode; |
644 | | - par_node.insertBefore( break_tag, label_node ); |
645 | | - } |
646 | | - YAHOO.util.Dom.get( 'wpLastTimestamp' + oResponse.argument ).value = aResponse['timestamp']; |
647 | | - } else if ( ( aResponse['error'] == 1 ) && ( aResponse['msg'] == 'cp_no_login' ) ) { |
648 | | - ProgressBar.innerHTML = '<span style="color: red"><?php echo wfMsg( 'createpage-login-required' ) ?>' + '<a href="' + wgServer + wgScript + '?title=Special:UserLogin&returnto=Special:CreatePage" id="createpage_login_infobox' + oResponse.argument + '" ><?php echo wfMsg( 'createpage-login-href' ) ?></a>' + "<?php echo wfMsg( 'createpage-login-required2' ) ?></span>"; |
649 | | - YAHOO.util.Event.addListener('createpage_login_infobox' + oResponse.argument, 'click', YAHOO.Createpage.showWarningLoginPanel ); |
650 | | - } else { |
651 | | - ProgressBar.innerHTML = '<span style="color: red">' + aResponse['msg'] + '</span>'; |
652 | | - } |
653 | | - YAHOO.util.Dom.get( 'createpage_image_text' + oResponse.argument ).innerHTML = "<?php echo wfMsg( 'createpage-insert-image' ) ?>"; |
654 | | - YAHOO.util.Dom.get( 'createpage_upload_file' + oResponse.argument ).style.display = ''; |
655 | | - YAHOO.util.Dom.get( 'createpage_image_text' + oResponse.argument ).style.display = ''; |
656 | | - YAHOO.util.Dom.get( 'createpage_image_cancel' + oResponse.argument ).style.display = 'none'; |
657 | | -}; |
658 | | - |
659 | | -YAHOO.CreatepageInfobox.FailureCallback = function( oResponse ) { |
660 | | - YAHOO.util.Dom.get( 'createpage_image_text' + oResponse.argument ).innerHTML = "<?php echo wfMsg( 'createpage-insert-image' ) ?>"; |
661 | | - YAHOO.util.Dom.get( 'createpage_upload_progress' + oResponse.argument ).innerHTML = "<?php echo wfMsg( 'createpage-upload-aborted' ) ?>"; |
662 | | - YAHOO.util.Dom.get( 'createpage_upload_file' + oResponse.argument ).style.display = ''; |
663 | | - YAHOO.util.Dom.get( 'createpage_image_text' + oResponse.argument ).style.display = ''; |
664 | | - YAHOO.util.Dom.get( 'createpage_image_cancel' + oResponse.argument ).style.display = 'none'; |
665 | | -}; |
666 | | - |
667 | | -YAHOO.CreatepageInfobox.Abort = function( e, o ) { |
668 | | - YAHOO.util.Connect.abort( o.request, o.callback ); |
669 | | -} |
670 | | - |
671 | | -YAHOO.CreatepageInfobox.Upload = function( e, o ) { |
672 | | - var n = o.num; |
673 | | - var oForm = YAHOO.util.Dom.get( 'createpageform' ); |
674 | | - if ( oForm ) { |
675 | | - YAHOO.util.Event.preventDefault(e); |
676 | | - YAHOO.util.Connect.setForm( oForm, true ); |
677 | | - var ProgressBar = YAHOO.util.Dom.get( 'createpage_upload_progress' + o.num ); |
678 | | - ProgressBar.style.display = 'block'; |
679 | | - ProgressBar.innerHTML = '<img src="' + wgServer + stylepath + '/common/images/spinner.gif" width="16" height="16" alt="wait" border="0" /> '; |
680 | | - |
681 | | - var callback = { |
682 | | - upload: YAHOO.CreatepageInfobox.UploadCallback, |
683 | | - failure: YAHOO.CreatepageInfobox.FailureCallback, |
684 | | - timeout: 60000, |
685 | | - argument: [n] |
686 | | - }; |
687 | | - |
688 | | - var sent_request = YAHOO.util.Connect.asyncRequest( 'POST', wgScriptPath + '/index.php?action=ajax&rs=axMultiEditImageUpload&num=' + n, callback ); |
689 | | - YAHOO.util.Dom.get( 'createpage_image_cancel' + o.num ).style.display = ''; |
690 | | - YAHOO.util.Dom.get( 'createpage_image_text' + o.num ).style.display = 'none'; |
691 | | - |
692 | | - YAHOO.util.Event.addListener( 'createpage_image_cancel' + o.num, 'click', YAHOO.CreatepageInfobox.Abort, {"request": sent_request, "callback": callback} ); |
693 | | - |
694 | | - var neoInput = document.createElement( 'input' ); |
695 | | - var thisInput = YAHOO.util.Dom.get( 'createpage_upload_file' + o.num ); |
696 | | - var thisContainer = YAHOO.util.Dom.get( 'createpage_image_label' + o.num ); |
697 | | - thisContainer.removeChild( thisInput ); |
698 | | - |
699 | | - neoInput.setAttribute( 'type', 'file' ); |
700 | | - neoInput.setAttribute( 'id', 'createpage_upload_file' + o.num ); |
701 | | - neoInput.setAttribute( 'name', 'wpUploadFile' + o.num ); |
702 | | - neoInput.setAttribute( 'tabindex', '-1' ); |
703 | | - |
704 | | - thisContainer.appendChild( neoInput ); |
705 | | - YAHOO.util.Event.addListener( 'createpage_upload_file' + o.num, 'change', YAHOO.CreatepageInfobox.Upload, {"num" : o.num } ); |
706 | | - |
707 | | - YAHOO.util.Dom.get( 'createpage_upload_file' + o.num ).style.display = 'none'; |
708 | | - } |
709 | | -} |
710 | | - |
711 | | -YAHOO.CreatepageInfobox.InputTest = function( el ) { |
712 | | - if ( el.id.match( 'wpInfoboxPar' ) ) { |
713 | | - return true; |
714 | | - } else { |
715 | | - return false; |
716 | | - } |
717 | | -} |
718 | | - |
719 | | -YAHOO.CreatepageInfobox.InputEvent = function( el ) { |
720 | | - var j = parseInt( el.id.replace( 'wpInfoboxPar', '' ) ); |
721 | | - YAHOO.util.Event.onContentReady( 'wpInfoboxPar' + j, YAHOO.Createpage.ClearInput, {num: j} ); |
722 | | -} |
723 | | - |
724 | | -YAHOO.CreatepageInfobox.UploadTest = function( el ) { |
725 | | - if ( el.id.match( 'createpage_upload_file' ) ) { |
726 | | - return true; |
727 | | - } else { |
728 | | - return false; |
729 | | - } |
730 | | -} |
731 | | - |
732 | | -YAHOO.Createpage.InitialRound = function() { |
733 | | - YAHOO.util.Dom.get('Createtitle').setAttribute('autocomplete', 'off'); |
734 | | - if ( ( YAHOO.Createpage.PreviewMode == 'No' ) && ( YAHOO.Createpage.RedLinkMode == 'No' ) ) { |
735 | | - YAHOO.Createpage.ContentOverlay(); |
736 | | - } else { |
737 | | - var catlink = YAHOO.util.Dom.get( 'catlinks' ); |
738 | | - if ( catlink ) { |
739 | | - var newCatlink = document.createElement( 'div' ); |
740 | | - newCatlink.setAttribute( 'id', 'catlinks' ); |
741 | | - newCatlink.innerHTML = catlink.innerHTML; |
742 | | - catlink.parentNode.removeChild( catlink ); |
743 | | - var previewArea = YAHOO.util.Dom.get( 'createpagepreview' ); |
744 | | - previewArea.insertBefore( newCatlink, YAHOO.util.Dom.get( 'createpage_preview_delimiter' ) ); |
745 | | - } |
746 | | - } |
747 | | - |
748 | | - var edit_textareas = YAHOO.util.Dom.getElementsBy( YAHOO.Createpage.EditTextareaTest, 'textarea', YAHOO.util.Dom.get('wpTableMultiEdit'), YAHOO.Createpage.TextareaAddToolbar ); |
749 | | - if ( ( 'Yes' == YAHOO.Createpage.RedLinkMode ) && ( 'wpTextboxes0' == edit_textareas[0].id ) ) { |
750 | | - edit_textareas[0].focus(); |
751 | | - } else { |
752 | | - var el_id = parseInt( edit_textareas[0].id.replace( 'wpTextboxes', '' ) ); |
753 | | - YAHOO.util.Dom.get('toolbar' + el_id).style.display = ''; |
754 | | - YAHOO.Createpage.hideOtherBoxes( el_id ); |
755 | | - } |
756 | | - YAHOO.Createpage.multiEditSetupToolbar(); |
757 | | - YAHOO.Createpage.multiEditSetupOptionalSections(); |
758 | | - YAHOO.Createpage.CheckCategoryCloud(); |
759 | | -} |
760 | | - |
761 | | -YAHOO.Createpage.ContentOverlay = function() { |
762 | | - YAHOO.Createpage.Overlay = new YAHOO.widget.Overlay('createpageoverlay'); |
763 | | - YAHOO.Createpage.ResizeOverlay( 20 ); |
764 | | - YAHOO.Createpage.Overlay.render(); |
765 | | - var helperButton = YAHOO.util.Dom.get('wpRunInitialCheck'); |
766 | | - YAHOO.util.Event.addListener( helperButton, 'click', YAHOO.WRequest.watchTitle ); |
767 | | - helperButton.style.display = ''; |
768 | | -} |
769 | | - |
770 | | -YAHOO.Createpage.appendHeight = function( elem_height, number ) { |
771 | | - var x_fixed_height = elem_height.replace('px', ''); |
772 | | - x_fixed_height = parseFloat( x_fixed_height ) + number; |
773 | | - x_fixed_height = x_fixed_height.toString() + 'px'; |
774 | | - return x_fixed_height; |
775 | | -} |
776 | | - |
777 | | -YAHOO.Createpage.ResizeOverlay = function( number ) { |
778 | | - var cont_elem = new YAHOO.util.Element('cp-restricted'); |
779 | | - var fixed_height; |
780 | | - var fixed_width; |
781 | | - if ( cont_elem.getStyle( 'height' ) == 'auto' ) { |
782 | | - fixed_height = YAHOO.util.Dom.get( 'cp-restricted' ).offsetHeight + number; |
783 | | - fixed_width = YAHOO.util.Dom.get( 'cp-restricted' ).offsetWidth; |
784 | | - } else { |
785 | | - fixed_height = cont_elem.getStyle( 'height' ); |
786 | | - fixed_height = YAHOO.Createpage.appendHeight( fixed_height, number ); |
787 | | - fixed_width = cont_elem.getStyle( 'width' ); |
788 | | - } |
789 | | - |
790 | | - YAHOO.Createpage.Overlay.cfg.setProperty( 'height', fixed_height ); |
791 | | - YAHOO.Createpage.Overlay.cfg.setProperty( 'width', fixed_width ); |
792 | | -} |
793 | | - |
794 | | -YAHOO.util.Event.onContentReady( 'cp-multiedit', YAHOO.Createpage.InitialRound ); |
795 | | - |
796 | | -YAHOO.CreatepageInfobox.UploadEvent = function( el ) { |
797 | | - var j = parseInt( el.id.replace( 'createpage_upload_file', '' ) ); |
798 | | - YAHOO.util.Event.addListener( 'createpage_upload_file' + j, 'change', YAHOO.CreatepageInfobox.Upload, {'num' : j } ); |
799 | | -} |
800 | | - |
801 | | -YAHOO.util.Event.addListener( 'wpAdvancedEdit', 'click', YAHOO.Createpage.showWarningPanel ); |
802 | | -YAHOO.util.Event.addListener( 'Createtitle', 'focus', YAHOO.Createpage.clearTitleMessage ); |
803 | | - |
804 | | -function cloudAdd( category, num ) { |
805 | | - category_text = YAHOO.util.Dom.get('wpCategoryTextarea'); |
806 | | - |
807 | | - if ( category_text.value == '' ) { |
808 | | - category_text.value += unescape( category ); |
809 | | - } else { |
810 | | - category_text.value += '|' + unescape( category ); |
811 | | - } |
812 | | - this_button = document.getElementById('cloud' + num); |
813 | | - this_button.onclick = function() { |
814 | | - eval("cloudRemove('" + category + "'," + num + ")"); |
815 | | - return false; |
816 | | - } |
817 | | - this_button.style['color'] = '#419636'; |
818 | | - return false; |
819 | | -}; |
820 | | - |
821 | | -function cloudInputAdd() { |
822 | | - category_input = YAHOO.util.Dom.get('wpCategoryInput'); |
823 | | - category_text = YAHOO.util.Dom.get('wpCategoryTextarea'); |
824 | | - var category = category_input.value; |
825 | | - if ( '' != category_input.value ) { |
826 | | - if ( category_text.value == '' ) { |
827 | | - category_text.value += unescape( category ); |
828 | | - } else { |
829 | | - category_text.value += '|' + unescape( category ); |
830 | | - } |
831 | | - category_input.value = ''; |
832 | | - var c_found = false; |
833 | | - var core_cat = category.replace(/\|.*/,''); |
834 | | - for ( j in YAHOO.Createpage.foundCategories ) { |
835 | | - if ( YAHOO.Createpage.foundCategories[j] == core_cat ) { |
836 | | - this_button = YAHOO.util.Dom.get( 'cloud' + j ); |
837 | | - var actual_cloud = YAHOO.Createpage.foundCategories[j]; |
838 | | - var cl_num = j; |
839 | | - |
840 | | - this_button.onclick = YAHOO.Createpage.onclickCategoryFn( core_cat, j ); |
841 | | - this_button.style.color = '#419636'; |
842 | | - c_found = true; |
843 | | - break; |
844 | | - } |
845 | | - } |
846 | | - if ( !c_found ) { |
847 | | - var n_cat = document.createElement( 'a' ); |
848 | | - var s_cat = document.createElement( 'span' ); |
849 | | - n_cat_count = YAHOO.Createpage.foundCategories.length; |
850 | | - |
851 | | - var cat_full_section = YAHOO.util.Dom.get('createpage_cloud_section'); |
852 | | - var cat_num = n_cat_count; |
853 | | - n_cat.setAttribute( 'id', 'cloud' + cat_num ); |
854 | | - n_cat.setAttribute( 'href', '#' ); |
855 | | - n_cat.onclick = YAHOO.Createpage.onclickCategoryFn( core_cat, cat_num ); |
856 | | - n_cat.style.color = '#419636'; |
857 | | - n_cat.style.fontSize = '10pt'; |
858 | | - s_cat.setAttribute( 'id', 'tag' + cat_num ); |
859 | | - t_cat = document.createTextNode( core_cat ); |
860 | | - space = document.createTextNode( ' ' ); |
861 | | - n_cat.appendChild( t_cat ); |
862 | | - s_cat.appendChild( n_cat ); |
863 | | - s_cat.appendChild( space ); |
864 | | - cat_full_section.appendChild( s_cat ); |
865 | | - YAHOO.Createpage.foundCategories[n_cat_count] = core_cat; |
866 | | - } |
867 | | - } |
868 | | -} |
869 | | - |
870 | | -function cloudRemove( category, num ) { |
871 | | - category_text = YAHOO.util.Dom.get('wpCategoryTextarea'); |
872 | | - this_pos = category_text.value.indexOf( unescape( category ) ); |
873 | | - if ( this_pos != -1 ) { |
874 | | - category_text.value = category_text.value.substr( 0, this_pos - 1 ) + category_text.value.substr( this_pos + unescape( category ).length ); |
875 | | - } |
876 | | - this_button = document.getElementById('cloud' + num); |
877 | | - this_button.onclick = function() { |
878 | | - eval("cloudAdd('" + category + "'," + num + ")"); |
879 | | - return false; |
880 | | - }; |
881 | | - this_button.style['color'] = ''; |
882 | | - return false; |
883 | | -}; |
884 | | - |
885 | | -function cloudBuild( o ) { |
886 | | - var categories = o.value; |
887 | | - new_text = ''; |
888 | | - categories = categories.split('|'); |
889 | | - for ( i = 0; i < categories.length; i++ ) { |
890 | | - if ( categories[i] != '' ) { |
891 | | - new_text += '[[Category:' + categories[i] + ']]'; |
892 | | - } |
893 | | - } |
894 | | - return new_text; |
895 | | -}; |
896 | | - |
| 55 | +?> |
897 | 56 | /*]]>*/ |
898 | 57 | </script> |
899 | 58 | |
900 | 59 | <?php if ( !$ispreview ) { ?> |
901 | 60 | |
902 | 61 | <div id="templateThumbs"> |
903 | | -<?php } ?> |
904 | | - <?php $elements_for_yui = array(); |
905 | | - if ( !$ispreview ) { |
906 | | -?> |
| 62 | +<?php |
| 63 | +} |
| 64 | + // What can I say except that this is a pretty nasty hack that is required |
| 65 | + // ever since I rewrote the JS to be less inline? |
| 66 | + global $wgCreateAPageElementsForJavaScript; |
| 67 | + $wgCreateAPageElementsForJavaScript = array(); |
907 | 68 | |
908 | | - <?php foreach ( $data as $e => $element ): ?> |
909 | | - <?php $name = $element['page']; ?> |
910 | | - <?php $label = str_replace( ' Page', '', $element['label'] ); ?> |
| 69 | + if ( !$ispreview ) { |
| 70 | + foreach ( $data as $e => $element ): |
| 71 | + $name = $element['page']; |
| 72 | + $label = str_replace( ' Page', '', $element['label'] ); |
| 73 | + $wgCreateAPageElementsForJavaScript[] = "cp-template-{$name}"; |
911 | 74 | |
912 | | - <?php $elements_for_yui[] = "'cp-template-{$name}'"; ?> |
913 | | - |
914 | | - <?php |
915 | 75 | $thumb = ''; |
916 | 76 | if ( !empty( $element['preview'] ) ) { |
917 | 77 | $thumb = "<img id=\"cp-template-$name-thumb\" src=\"" . $element['preview'] . "\" alt=\"$name\" />"; |
918 | | - } else { |
919 | 78 | } |
920 | 79 | ?> |
921 | 80 | |
— | — | @@ -930,187 +89,18 @@ |
931 | 90 | <?php endforeach; ?> |
932 | 91 | </div> |
933 | 92 | |
934 | | -<?php } ?> |
935 | | - |
936 | | -<div style="clear: both"></div> |
937 | | - |
938 | | -<script type="text/javascript"> |
939 | | -/*<![CDATA[*/ |
940 | | - |
941 | | -var myid = 0; |
942 | | - |
943 | | -YAHOO.Createpage.TestInfoboxToggle = function() { |
944 | | - var listeners = YAHOO.util.Event.getListeners('cp-infobox-toggle'); |
945 | | - if ( listeners ) { |
946 | | - for ( var i = 0; i < listeners.length; ++i ) { |
947 | | - var listener = listeners[i]; |
948 | | - if ( listener.type != 'click' ) { |
949 | | - YAHOO.util.Event.addListener( 'cp-infobox-toggle', 'click', YAHOO.WRequest.toggle, ['cp-infobox', 'cp-infobox-toggle'] ); |
950 | | - } |
951 | | - } |
952 | | - } else { |
953 | | - YAHOO.util.Event.addListener( 'cp-infobox-toggle', 'click', YAHOO.WRequest.toggle, ['cp-infobox', 'cp-infobox-toggle'] ); |
| 93 | +<?php |
954 | 94 | } |
955 | | -} |
956 | 95 | |
957 | | -YAHOO.Createpage.MultiEdit = function() { |
958 | | - var elements = [<?php echo join( ', ', $elements_for_yui ) ?>]; |
959 | | - var callback = { |
960 | | - success: function( e ) { |
961 | | - YAHOO.util.Dom.get('cp-multiedit').innerHTML = ''; |
962 | | - |
963 | | - if( /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test( e.responseText ) ) { |
964 | | - var res = eval( '(' + e.responseText + ')' ); |
965 | | - } |
966 | | - if ( '' != res ) { |
967 | | - YAHOO.util.Dom.get('cp-multiedit').innerHTML = res; |
968 | | - } |
969 | | - |
970 | | - var i; |
971 | | - for ( i in elements ) { |
972 | | - YAHOO.util.Dom.get( elements[i] ).className = 'templateFrame'; |
973 | | - } |
974 | | - |
975 | | - YAHOO.util.Dom.get( myid ).className += ' templateFrameSelected'; |
976 | | - |
977 | | - YAHOO.util.Event.onAvailable( 'cp-infobox-toggle', YAHOO.Createpage.TestInfoboxToggle ); |
978 | | - |
979 | | - var infobox_root = YAHOO.util.Dom.get('cp-infobox'); |
980 | | - var infobox_inputs = YAHOO.util.Dom.getElementsBy( YAHOO.CreatepageInfobox.InputTest, 'input', infobox_root, YAHOO.CreatepageInfobox.InputEvent ); |
981 | | - var infobox_uploads = YAHOO.util.Dom.getElementsBy( YAHOO.CreatepageInfobox.UploadTest, 'input', infobox_root, YAHOO.CreatepageInfobox.UploadEvent ); |
982 | | - var content_root = YAHOO.util.Dom.get( 'wpTableMultiEdit' ); |
983 | | - var section_uploads = YAHOO.util.Dom.getElementsBy( YAHOO.Createpage.UploadTest, 'input', content_root, YAHOO.Createpage.UploadEvent ); |
984 | | - |
985 | | - var cloud_div = YAHOO.util.Dom.get( 'createpage_cloud_div' ); |
986 | | - if ( null != cloud_div ) { |
987 | | - cloud_div.style.display = 'block'; |
988 | | - } |
989 | | - YAHOO.Createpage.CheckCategoryCloud(); |
990 | | - |
991 | | - var cont_elem = new YAHOO.util.Element( 'cp-restricted' ); |
992 | | - |
993 | | - if ( YAHOO.Createpage.Overlay && ( YAHOO.util.Dom.get('createpageoverlay').style.visibility != 'hidden' ) ) { |
994 | | - YAHOO.Createpage.ResizeOverlay( 20 ); |
995 | | - } |
996 | | - |
997 | | - YAHOO.Createpage.multiEditTextboxes = []; |
998 | | - YAHOO.Createpage.multiEditButtons = []; |
999 | | - YAHOO.Createpage.multiEditCustomButtons = []; |
1000 | | - |
1001 | | - var edit_textareas = YAHOO.util.Dom.getElementsBy( YAHOO.Createpage.EditTextareaTest, 'textarea', content_root, YAHOO.Createpage.TextareaAddToolbar ); |
1002 | | - // Link Suggest |
1003 | | - /*var link_sugg_area = YAHOO.util.Dom.get( 'wpTextbox1_container' ); |
1004 | | - if ( link_sugg_area ) { |
1005 | | - if( YAHOO.env.ua.ie > 0 || YAHOO.env.ua.gecko > 0 ) { |
1006 | | - var oDS = new YAHOO.widget.DS_XHR( wgServer + wgScriptPath, ['results', 'title', 'title_org'] ); |
1007 | | - oDS.scriptQueryAppend = 'action=ajax&rs=getLinkSuggest'; |
1008 | | - |
1009 | | - var content_root = YAHOO.util.Dom.get( 'wpTableMultiEdit' ); |
1010 | | - var edit_textareas = YAHOO.util.Dom.getElementsBy(function( el ) { |
1011 | | - if ( el.id.match( 'wpTextboxes' ) && ( el.style.display != 'none' ) ) { |
1012 | | - return true; |
1013 | | - } else { |
1014 | | - return false; |
1015 | | - } |
1016 | | - }, 'textarea', content_root, function( el ) { |
1017 | | - LS_PrepareTextarea( el.id, oDS ); |
1018 | | - }); |
1019 | | - } |
1020 | | - }*/ |
1021 | | - |
1022 | | - if ( ( 'Yes' == YAHOO.Createpage.RedLinkMode ) && ( 'wpTextboxes0' == edit_textareas[0].id ) ) { |
1023 | | - edit_textareas[0].focus(); |
1024 | | - } else { |
1025 | | - var el_id = parseInt( edit_textareas[0].id.replace( 'wpTextboxes', '' ) ); |
1026 | | - YAHOO.util.Dom.get( 'toolbar' + el_id ).style.display = ''; |
1027 | | - YAHOO.Createpage.hideOtherBoxes( el_id ); |
1028 | | - } |
1029 | | - |
1030 | | - var edittools_div = YAHOO.util.Dom.get( 'createpage_editTools' ); |
1031 | | - if ( edittools_div ) { |
1032 | | - if ( 'cp-template-Blank' != myid ) { |
1033 | | - edittools_div.style.display = 'none'; |
1034 | | - } else { |
1035 | | - edittools_div.style.display = ''; |
1036 | | - } |
1037 | | - } |
1038 | | - |
1039 | | - YAHOO.Createpage.multiEditSetupToolbar(); |
1040 | | - YAHOO.Createpage.multiEditSetupOptionalSections(); |
1041 | | - }, |
1042 | | - failure: function(e) { |
1043 | | - YAHOO.util.Dom.get('cp-multiedit').innerHTML = ''; |
1044 | | - }, |
1045 | | - timeout: 50000 |
| 96 | + global $wgHooks; |
| 97 | + $wgHooks['MakeGlobalVariablesScript'][] = function( $vars ) { |
| 98 | + global $wgCreateAPageElementsForJavaScript; |
| 99 | + $vars['wgCreateAPageElementsForJavaScript'] = $wgCreateAPageElementsForJavaScript; |
| 100 | + return true; |
1046 | 101 | }; |
| 102 | +?> |
1047 | 103 | |
1048 | | - return { |
1049 | | - init: function() { |
1050 | | - YAHOO.util.Event.addListener( elements, 'click', this.switchTemplate ); |
1051 | | - |
1052 | | - var i, src, tt; |
1053 | | - for ( i in elements ) { |
1054 | | - YAHOO.util.Dom.setStyle( elements[i] + '-radio', 'display', 'none' ); |
1055 | | - } |
1056 | | - }, |
1057 | | - switchTemplate: function( e ) { |
1058 | | - myid = this.id; |
1059 | | - YAHOO.util.Event.preventDefault(e); |
1060 | | - |
1061 | | - YAHOO.util.Dom.get('cp-multiedit').innerHTML = '<img src="' + wgServer + wgScriptPath + '/extensions/CreateAPage/images/progress_bar.gif" width="70" height="11" alt="<?php echo wfMsg( 'createpage-please-wait' ) ?>" border="0" />'; |
1062 | | - if ( YAHOO.Createpage.Overlay ) { |
1063 | | - YAHOO.Createpage.ResizeOverlay( 20 ); |
1064 | | - } |
1065 | | - YAHOO.util.Connect.asyncRequest('GET', ajaxpath + '?action=ajax&rs=axMultiEditParse&template=' + this.id.replace('cp-template-', ''), callback); |
1066 | | - } |
1067 | | - }; |
1068 | | -}(); |
1069 | | - |
1070 | | -YAHOO.Createpage.MultiEdit.init(); |
1071 | | - |
1072 | | -YAHOO.Createpage.CheckExistingTitle = function( e ) { |
1073 | | - if ( YAHOO.util.Dom.get('Createtitle').value == '' ) { |
1074 | | - YAHOO.util.Event.preventDefault(e); |
1075 | | - YAHOO.util.Dom.get('cp-title-check').innerHTML = '<span style="color: red;"><?php echo wfMsg( 'createpage-give-title' ) ?></span>'; |
1076 | | - window.location.hash = 'title_loc'; |
1077 | | - YAHOO.Createpage.SubmitEnabled = false; |
1078 | | - } else if ( true == NoCanDo ) { |
1079 | | - TitleDialog = new YAHOO.widget.SimpleDialog("dlg", { |
1080 | | - width: "20em", |
1081 | | - effect: {effect:YAHOO.widget.ContainerEffect.FADE, |
1082 | | - duration:0.4}, |
1083 | | - fixedcenter:true, |
1084 | | - modal:true, |
1085 | | - visible:false, |
1086 | | - draggable:false }); |
1087 | | - TitleDialog.setHeader("<?php echo wfMsg( 'createpage-title-check-header' ); ?>"); |
1088 | | - TitleDialog.setBody("<?php echo wfMsg( 'createpage-title-check-text' ); ?>"); |
1089 | | - TitleDialog.cfg.setProperty( 'icon', YAHOO.widget.SimpleDialog.ICON_WARN ); |
1090 | | - TitleDialog.cfg.setProperty( 'zIndex', 1000 ); |
1091 | | - TitleDialog.render( document.body ); |
1092 | | - TitleDialog.show(); |
1093 | | - YAHOO.util.Event.preventDefault(e); |
1094 | | - YAHOO.Createpage.SubmitEnabled = false; |
1095 | | - } |
1096 | | - if ( |
1097 | | - ( YAHOO.Createpage.SubmitEnabled !== true ) || |
1098 | | - ( YAHOO.Createpage.Overlay && ( YAHOO.util.Dom.get('createpageoverlay').style.visibility != 'hidden' ) ) |
1099 | | - ) { |
1100 | | - YAHOO.util.Event.preventDefault(e); |
1101 | | - } |
1102 | | -} |
1103 | | - |
1104 | | -YAHOO.Createpage.SubmitEnable = function( e ) { |
1105 | | - YAHOO.Createpage.SubmitEnabled = true; |
1106 | | -} |
1107 | | - |
1108 | | -YAHOO.util.Event.addListener( 'createpageform', 'submit', YAHOO.Createpage.CheckExistingTitle ); |
1109 | | -YAHOO.util.Event.addListener( 'wpSave', 'click', YAHOO.Createpage.SubmitEnable ); |
1110 | | -YAHOO.util.Event.addListener( 'wpPreview', 'click', YAHOO.Createpage.SubmitEnable ); |
1111 | | -YAHOO.util.Event.addListener( 'wpCancel', 'click', YAHOO.Createpage.SubmitEnable ); |
1112 | | - |
1113 | | -/*]]>*/ |
1114 | | -</script> |
| 104 | +<div style="clear: both"></div> |
1115 | 105 | <?php if ( !$ispreview ) { ?> |
1116 | 106 | </div> |
1117 | 107 | </fieldset> |
Index: trunk/extensions/CreateAPage/templates/editimage.tmpl.php |
— | — | @@ -2,7 +2,9 @@ |
3 | 3 | <!-- JavaScript part --> |
4 | 4 | <script type="text/javascript"> |
5 | 5 | /*<![CDATA[*/ |
6 | | -YAHOO.util.Event.addListener( "createpage_upload_file<?php echo $image_num ?>", "change", YAHOO.CreatepageInfobox.Upload, {"num" : <?php echo $image_num ?> } ); |
| 6 | +jQuery( '#createpage_upload_file<?php echo $image_num ?>' ).change( function( e ) { |
| 7 | + CreateAPageInfobox.upload( e, { 'num': <?php echo $image_num ?> } ); |
| 8 | +}); |
7 | 9 | /*]]>*/ |
8 | 10 | </script> |
9 | 11 | <div class="createpage_input_file createpage_input_file_no_path"> |
Index: trunk/extensions/CreateAPage/templates/categorypage.tmpl.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | foreach ( $cloud->tags as $xname => $xtag ) { |
19 | 19 | ?> |
20 | 20 | <span id="tag<?php echo $xnum ?>" style="font-size:<?php echo $xtag['size'] ?>pt"> |
21 | | - <a href="#" id="cloud<?php echo $xnum ?>" onclick="cloudAdd(escape('<?php echo $xname ?>'), <?php echo $xnum ?>); return false;"><?php echo $xname ?></a> |
| 21 | + <a href="#" id="cloud<?php echo $xnum ?>" onclick="CreateAPageCategoryTagCloud.add(escape('<?php echo $xname ?>'), <?php echo $xnum ?>); return false;"><?php echo $xname ?></a> |
22 | 22 | </span> |
23 | 23 | <?php |
24 | 24 | $xnum++; |
— | — | @@ -26,13 +26,13 @@ |
27 | 27 | </div> |
28 | 28 | <?php } // if ( $cloud->tags ) ?> |
29 | 29 | <textarea accesskey="," name="wpCategoryTextarea" id="wpCategoryTextarea" rows="3" cols="<?php echo $cols ?>"<?php echo $ew ?>><?php echo $text_category ?></textarea> |
30 | | -<input type="button" name="wpCategoryButton" id="wpCategoryButton" class="button color1" value="<?php echo wfMsg( 'createpage-addcategory' ) ?>" onclick="cloudInputAdd(); return false ;" /> |
| 30 | +<input type="button" name="wpCategoryButton" id="wpCategoryButton" class="button color1" value="<?php echo wfMsg( 'createpage-addcategory' ) ?>" /> |
31 | 31 | <input type="text" name="wpCategoryInput" id="wpCategoryInput" value="" /> |
32 | 32 | </div> |
33 | 33 | <script type="text/javascript"> |
34 | 34 | /*<![CDATA[*/ |
35 | | -var div = document.getElementById('createpage_cloud_div'); |
36 | | -document.getElementById('createpage_cloud_div').style.display = 'block'; |
| 35 | +var div = document.getElementById( 'createpage_cloud_div' ); |
| 36 | +div.style.display = 'block'; |
37 | 37 | /*]]>*/ |
38 | 38 | </script> |
39 | 39 | <noscript> |
Index: trunk/extensions/CreateAPage/templates/editimage-section.tmpl.php |
— | — | @@ -2,7 +2,9 @@ |
3 | 3 | <!-- JavaScript part --> |
4 | 4 | <script type="text/javascript"> |
5 | 5 | /*<![CDATA[*/ |
6 | | -YAHOO.util.Event.addListener( "createpage_upload_file_section<?php echo $imagenum ?>", "change", YWC.Upload, {"num" : <?php echo $imagenum ?> } ); |
| 6 | +jQuery( '#createpage_upload_file_section<?php echo $imagenum ?>' ).change( function( e ) { |
| 7 | + CreateAPage.upload( e, { 'num': <?php echo $imagenum ?> } ); |
| 8 | +}); |
7 | 9 | /*]]>*/ |
8 | 10 | </script> |
9 | 11 | <div id="createpage_upload_div_section<?php echo $imagenum ?>"> |
— | — | @@ -27,4 +29,4 @@ |
28 | 30 | <input type="submit" id="createpage_upload_submit_section<?php echo $imagenum ?>" name="wpImageUpload" value="<?php echo wfMsg( 'createpage-upload' ) ?>" class="upload_submit" /> |
29 | 31 | </noscript> |
30 | 32 | </div> |
31 | | -<!-- e:<?php echo __FILE__ ?> --> |
| 33 | +<!-- e:<?php echo __FILE__ ?> --> |
\ No newline at end of file |