Commit graph

131 commits

Author SHA1 Message Date
Krinkle
5819c37b3c More mediawiki.js cleanup
- Convert prototype object modifications into object literal. Saves bandwidth (less characters) and speeds up execution (no need to access 2 level deep object member repetitively). Local testing (Chrome Web Inspector) shows 14.80KB to 14.67KB (non-cached, debug=false), and execution time on cached request 32ms to 25ms.
- Un-indent 1 tab for d.setTime (Follows up r92964)
- Whitespace consistency
- Move var statements to top of loader's addScript

Follows up: r92933
2011-07-24 20:22:36 +00:00
Jeroen De Dauw
ca9b3ef3ec fu r92933 - fix breakage 2011-07-23 20:56:08 +00:00
Roan Kattouw
12f1d43f34 Fix typo in r92933 that resulted in global variable leakage 2011-07-23 09:19:53 +00:00
Krinkle
c8d9bf8191 Minor mw.loader fixes
- No functional changes
- Whitespace correction
- Comment fixes
- Combine var statements
- A few [[JSPERF]]ies
- Using mw instead of mediaWiki
- Putting global alias on top, to avoid a ReferenceError in case the immediately invoked "new function(){}" refers to mw during the construction
- "class" -> "constructor"
- caching "typeof dependencies" in mw.loader.using
- fix var "group" collision in mw.loader.work
- move var statements to top of functions
- fixing some occurrences of var statements in for-loops by declaring them before the loop
- Remove space before slash in html-fragement for jQuery html regex in <link /> and <br />
2011-07-23 09:09:28 +00:00
Roan Kattouw
a2ecfbc945 Change != {} to !$.isEmptyObject(): the former always returned true because objects are compared by reference. This didn't cause any realistic problems, though: the worst that could happen is that if you have a module name longer than the query string request limit (which is extremely unusual), mediawiki.js would probably go into an infinite loop. 2011-07-23 03:48:35 +00:00
Krinkle
1d08327f4c Fix for the broken tests introduced in r91387.
Check input before assuming there are no arguments and the values object is expected.
2011-07-03 23:24:51 +00:00
Krinkle
dab77e715b Minor optimalizations and jsperfs in mediawiki.js
* Use strict comparison to undefined where possible (arguments and object/array members)
* Make sure $ is not implied global (using jQuery.isFunction at the bottom instead of creating another 1-line closure)
2011-07-03 23:13:11 +00:00
Krinkle
c14869313d Fix issues raised through TestSwarm
* Instead of delete window.foobar whitelist the global in QUnit.config.pollution
** the reason either is needed is to make QUnit's "noglobal" option useful)
** delete window.foo throws an "TypeError: Object doesn't support this action" in Internet Explorer.
-> http://perfectionkills.com/understanding-delete/
* Remove other globals introduced
2011-05-29 04:11:10 +00:00
Krinkle
7d345f1836 Introducing mw.libs, moving JpegMeta into it.
* Reverts/re-do's r88794 and r88796.
** mediawiki.util.js no longer extends itself but is defined once.
** mediawiki.util.jpegmeta no longer extends mw.util but is installed as an object property of mw.libs
* Empty placeholder defined in mediawiki.js
* Removed the redundant 'mw' argument from the IIFE around mediawiki.libs.jpegmeta.js


* Fixed all usages in /mediawiki/trunk/*
** http://toolserver.org/~krinkle/wikimedia-svn-search/view.php?id=205&hash=ddc0908eef111558816c9fe1c775f7c1
2011-05-29 03:13:54 +00:00
Krinkle
eb87e5c4a1 Adding or adjusting front-end function and variable documentation per our conventions.
Also did some trivial clean up, JSHint fixes and performance optimizations while at it. (per http://www.mediawiki.org/wiki/JavaScript_performance )
* Missing semicolons.
* [mediawiki.js Line 540] Unreachable 'registry' after 'throw'.
* [mediawiki.log.js] Checked for window.console but used console.
* Added callback option to mw.util.toggleToc (forwarded to jQuery.fn.slideUp/Down)
* Made mw.log argument more descriptive (logmsg instead of string)
* Using deepEqual(, true) instead of ok() when asserting true. (ok() is like casting a boolean (or a plain if() statement) to verify that something is not falsy)

Added missing test suites for:
* mw.util.toggleToc (follow-up r88732, Dummy check was introduced in r87898)

/me has been infected by Reedy and will be doing more of this tonight.
2011-05-29 02:54:01 +00:00
Krinkle
6a408d444c Adding or adjusting front-end function and variable documentation per our conventions.
* Adding "return this;" in object constructor functions.
* Added test suites for Map and Message object constructors to match the @return descriptions.

Also did some trivial clean up and performance optimizations while at it. (per http://www.mediawiki.org/wiki/JavaScript_performance )

/me has been infected by Reedy and will be doing more of this tonight.
2011-05-28 22:38:59 +00:00
Roan Kattouw
8dab43f703 (bug 28840) URLs with dots break because of IE6 security check
* Replace the overly paranoid regex with a function that simulates IE6's behavior
* Remove the UA check in isPathInfoBad(), was causing more problems than it was worth
* Revert r87711, going back to using dots for dots in ResourceLoader URLs, instead of exclamation marks
* Append &* to ResourceLoader URLs. * is an illegal character in extensions, and putting it at the end of the URL ensures that both IE6 and our detection function will deem the URL to have no extension (unless something like .html? appears in the query string, but in that case we're screwed no matter what)
2011-05-26 09:49:45 +00:00
Brion Vibber
2f3cd252a5 * (bug 29107) Fix regression in ResourceLoader debug mode for WikiEditor
One of WikiEditor's modules had only messages, no scripts; updates to the debug mode loader had ended up failing in the case where no scripts got passed in (if passed with a loader function we were fine, hence non-debug mode being ok)
This commit explicitly checks for the empty-array case and marks the module as ready immediately, instead of waiting for the last item in the loop to finish, which never happens. :)

Also consolidated three calls to the same few lines of code into a lambda function.
2011-05-24 00:42:42 +00:00
Krinkle
dc74a0cdb0 * Remove commented-out debug call (FU r88143)
* Update comment to reflect changes to function (FU r87208)
2011-05-18 22:10:32 +00:00
Krinkle
bdac16978c Changing console.log(e) to a throw. console.log makes it go toString() which is pretty much the same as the e.message in the console.log call above it. This also made it impossible for QUnit to get it's hand on the actual error. Fixed it by moing it outside of the if statement so it can be caught. 2011-05-18 20:31:28 +00:00
Krinkle
e6d5a78f2c Passing module to handlePending (bug 28998; Follow-up r88053) 2011-05-17 17:20:24 +00:00
Krinkle
238ed13911 * Moving jQuery extend into its own module (jquery.mwPrototypes) (bug 27149; Introduced in r) 2011-05-17 17:19:12 +00:00
Krinkle
7d4108ecdb Split mw.user from mediawiki.js into its own module
* Split mw.user from mediawiki.js into its own module
* Except for "new Map()" to "new mw.Map()", no code was changed.
* Merged addModules call in OutputPage->addDefaultModules for "mediawiki.action.view.tablesorting" into existing call to addModules (no need for two calls, addModules takes an array)
* This also makes the mw.loader.load call at the bottom of mediawiki.js redundant (now in dependancies for mediawiki.user in Resources.php)
* Added QUnit test suite for mw.user
2011-05-16 17:58:54 +00:00
Mark A. Hershberger
bc205c281c Fix Bug #28995: “public interface for getting state of a module” from
Bergi

    Sometimes userscripts need to know about the registrated modules,
    mostly about their state.
    …
    My patch also resolves inconsistencies in the naming conventions
    of getters and setters; I think there should be a clear
    difference.
2011-05-15 14:26:24 +00:00
Mark A. Hershberger
2d73f683d0 w/s and typo fix 2011-05-15 14:18:35 +00:00
Krinkle
19c92ea75c (bug 27073) Lazy init the style marker and insert if not available (ie. when using resourceloader js on a non-mediawiki domain); fixing typo (r88074 CR) 2011-05-15 10:33:07 +00:00
Trevor Parscal
faf2f592d2 Fixes regression in r88125 - if batch is empty we should bail early 2011-05-15 09:10:04 +00:00
Trevor Parscal
a39c59dd6e Removed the go() call, and the suspended until go() is called behavior. 2011-05-14 23:12:16 +00:00
Trevor Parscal
38b2aa65c4 Fixed language in comments and error messages - see comments in r88053. 2011-05-14 13:21:58 +00:00
Trevor Parscal
3772c10426 Improves on r88053 - added code basically lifted from jQuery.getScript which ensures that onreadystatechange is handled properly - only executing the callback when the state is changed to the correct state, and only calling it one time. Thanks John Resig! 2011-05-14 13:14:34 +00:00
Trevor Parscal
e6bee6f043 Added direct file loading functionality to debug mode for both scripts and styles, with callbacks for module state changes (changing to ready) and executing of jobs and modules awaiting dependency resolutions. These changes also provide a way to used mw.loader.implement with arrays of URLs for the scripts and styles arguments, which will make it possible to implement modules using user scripts. This probably solves bug #27023 - tests to verify that will be coming soon. 2011-05-14 12:15:58 +00:00
Trevor Parscal
137390c5ed (reverts r87985, and does what that was SUPPOSED to do!) Gerenalized code used in 2 places for adding scripts to the body, and switched from using jQuery.getScript to direct DOM manipulation to avoid jQuery running script file contents through eval, which caused insane line numbers when errors occured. 2011-05-13 15:22:52 +00:00
Trevor Parscal
f8d5c3f8aa Expanded the contents of a function that was immediately called. 2011-05-13 14:30:53 +00:00
Krinkle
265bc325d2 Remove unneeded parens in $.compareObject; Fix addCSS QUnit test for IE6 which puts spaces between commas.. 2011-05-12 23:03:16 +00:00
Krinkle
49ce5de7d9 Creating a way to toggle mw.config LEGACY_GLOBALS from LocalSettings (bug 28916).
* I thought a while for a way to somehow get that global variable from php to the start of the main mediaWiki object creation. Considered using a (temporary) global variable and deleting afterwards, but that looked like a hack and wasn't sure about the cross-browser functioning of it. Instead ended up by moving it to the startUp module where other global variables are accessed as well. This seems to work pretty good.

* Can be toggled from LocalSettings by setting $wgLegacyJavaScriptGlobals.
* Changed some usages of mediaWiki to use the global mw alias instead.
2011-05-10 23:17:13 +00:00
Krinkle
dd26bd6a53 Step 1 of QUnit/TestSwarm support (bug 26908)
* Add jQuery QUnit module
* Add a return value to mw.Map.prototype.set
* Add fallback to 'body' for options.parent in a new $.messageBox

(this is a re-do of r87830, but without breaking mw.config, see r87830 CR)

--
* Small whitespace fix (spaces to tabs) in Resources.php
2011-05-10 21:54:42 +00:00
Brion Vibber
a14b9a868f Revert r87830: broke ResourceLoader, MediaWiki config variables 2011-05-10 21:37:15 +00:00
Krinkle
3995a0380a Step 1 of QUnit/TestSwarm support (bug 26908)
* Add jQuery QUnit module
* Add a return value to mw.Map.prototype.set
* Add fallback to 'body' for options.parent in a new $.messageBox
2011-05-10 17:53:21 +00:00
Krinkle
1e48f72623 * [mediaWiki] Using mw-alias where possible + adding missing semi-colons and other JSHint nags
* [mw.util.test] Moving CSS style check for div#js-message after the call to jsMessage(). In most skins this doesn't matter as the element already exists. But some skins this element isn't created untill the call to jsMessage().
2011-05-09 18:44:22 +00:00
Roan Kattouw
950cf2cb86 (bug 28840) Commit patch by bawolff that encodes dots in ResourceLoader module names as exclamation marks in the generated URLs, so as to avoid triggering the recently added IE security measure and causing a blank 403 response. This broke RL in various ways for IE users.
This is by no means intended to be permanent, but it's the best way to unbreak RL for IE users while we work out how to fix this properly.
2011-05-09 13:10:06 +00:00
Krinkle
48c6cc2854 Remove second argument in str.substr() in $.ucFirst, not needed, defaults to full length of string 2011-05-08 20:30:29 +00:00
Roan Kattouw
7fee86c38e Per bug 28738 comment 4, pack ResourceLoader URLs by encoding foo.bar|foo.baz|bar.baz|bar.quux as foo.bar,baz|bar.baz,quux
* Expand these URLs in ResourceLoaderContext
* Build and emit these URLs in OutputPage::makeResourceLoaderLink() and in mw.loader
* Throw an exception in ResourceLoader::register() for module names that contain pipe characters or commas. Commas need to be forbidden for this packing feature to work. Pipes were already forbidden but weren't checked for
2011-05-05 13:46:47 +00:00
Krinkle
373859bafe mw.loader fixes
* Renaming locally declared function "request" to "getScriptTag" to avoid confusion or conflict with the other local "request" function inside the mw.loader closure
* (bug 26804) Code clean up ($skin was generated locally already)
2011-05-04 20:58:14 +00:00
Krinkle
6c1faaaccf mw.util.test fixes
* Remove hiding of rows after the test, in almost all cases someone will want to unhide these, especially in case of an error; Plus, there were some inconsistencies in firefox with the hovering of the last (non-collapsible) row.
* Changing mw.util.addCSS to a style that is actually visible on the action=mwutiltest page.
* Making the entire row red in case of errors (easier finding of the error)
* Moving $.isDomElement tests to mw.util.test instead of in comments
* Adding missing tests for all mw.util properties
* Fix bug where $.isDomElement fails if the passed argument isn't an object at all (eg. null or undefined). Check variable first before checking object property (<code>$.isDomElement( document.getElementById('notexist') );</code> returned TypeError: Result of expression 'el' [null] is not an object.)
** Adding test for this
* Try/Catch the evaluation
** Reports catched exceptions through mw.log instead of using throw. This way non-consoled browsers can be easily debugged through mw.log's console.
** Fixes: (bug 28803) mw.util.test doesn't handle exceptions
* Using a canonical variable instead of a localized one in the tests.
** Fixes: (bug 28788) 2 tests related to wgTitle in mediawiki.util.test are broken for non-English wikis.
2011-05-03 21:57:33 +00:00
Roan Kattouw
2886b924c0 Fix r87203: don't use a for..in loop on an array 2011-05-02 17:57:24 +00:00
Roan Kattouw
f56afa36a6 (bug 28738) Implement request splitting in mw.loader so ResourceLoader requests with query strings longer than a certain value are split up. The maximum query string length is configurable, and this behavior is disabled by default. It's needed in rare cases where there is a query string length or GET variable length limit in place that the wiki admin can't raise. 2011-05-01 18:41:42 +00:00
Brion Vibber
53393a4fa8 Declare some local vars/funcs as local so they don't stomp on JS global namespaces weirdly 2011-04-28 00:18:01 +00:00
Trevor Parscal
46d7b0b4d0 Fixed bugs: Version was being checked against the wrong index after the cookie's "version:bucket" content was parsed, causing it to never match. Bucket names were being converted into numbers, resulting in NaN usually. 2011-04-21 01:05:36 +00:00
Trevor Parscal
357b3c9aee Swtiched to using full mediaWiki prefix in cookies and events, rather than the shortcut version "mw". 2011-04-21 00:24:20 +00:00
Trevor Parscal
08c589df94 Fixed mismatched cookie names, changed to using ":" instead of "-" between cookie basename and bucketing key to help make the cookie more readable and removed some extra space in an error message. 2011-04-21 00:02:27 +00:00
Trevor Parscal
c0973b8bad Added generic bucketing feature to the user object, which handles bucketing users, invalidating bucketing on version changes, tracking and and persistence. 2011-04-20 23:58:22 +00:00
Krinkle
b82d2a04cc bug 28413: Fix IE problems with self-closing link-elements in .innerHTML. Using { attributes } instead so jQuery will use document.createElement instead of innerHTML. See also bug 28413 comments 2011-04-20 20:45:01 +00:00
Max Semenik
9b1d54fc70 Back out r86054 and part of r86059 for now, I'd like to evaluate the possibility of integrating NeilK's work into the core now 2011-04-17 05:46:41 +00:00
Max Semenik
a66fabc04b Added wrapper mw.api() for API calls 2011-04-14 15:56:40 +00:00
Krinkle
b7aaa1c214 Remove color:black from table {} in skins (bug 28422) + small fixes
* Remove color:black from table {} in skins (bug 28422)
* Add color:black to .wikitable (since it has a background-color)
* Update comment about CSS3 'word-wrap:break-word' support in Gecko
* Remove line-break in mediawiki.js (it's ~ 90 chars, acceptable)
2011-04-06 16:31:46 +00:00