aboutsummaryrefslogtreecommitdiffstats
path: root/resources/mediawiki/mediawiki.util.js
Commit message (Collapse)AuthorAgeFilesLines
...
* [Core JS] mw.util.addCSS: Insert style tag into dom before setting cssTextKrinkle2011-12-211-1/+2
| | | | | | | * Fixes bug 33305 Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/106992
* [Core JS] Applying conventions to mw.utilKrinkle2011-12-211-43/+59
| | | | | | | | | | - new recommended closure format - fixing repeated var statements, or var statement inside blocks (there is no block scope in JavaScript) and moving them to the top of the function - line breaking, indention, white space - and more.. see also https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/106991
* Whitespace indention fix for r96150 (seperate to make review easier)Krinkle2011-09-021-75/+75
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/96151
* Separate execution from definition (mediawiki.util.init)Krinkle2011-09-021-15/+2
| | | | | | | | | * bug 30710 Also makes it easier to do unit testing, this way the module can be included and the test can initialize it if and when it wants to. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/96150
* Followup r95332 (bug 30441 fix) -- Roan pointed out that I forgot to do a ↵Brion Vibber2011-08-241-1/+1
| | | | | | | | | | | global replace (d'oh!) Now works with parameters containing multiple spaces. :) Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/95451
* * (bug 30441) getParamValue must understand "+" encoding of spaceBrion Vibber2011-08-231-1/+3
| | | | | | | | | | $.param() produces query string form encoding using the traditional '+' encoding for space; mediawiki.util.getParamValue() was using only decodeURIComponent() to do unescaping, which is not required by spec to handle '+'. Explicitly replacing '+' with '%20' before the decode nicely resolves this. Added a test case to qunit tests for mediawiki.util module. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/95332
* Use .prop instead of .attr where appropriateKrinkle2011-08-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Although jQuery covers for us in most cases (since .prop didn't exist before jQuery 1.6 and many people abused .attr in laziness of doing their own loop and setting the property manually). It's better to know what we're doing and call the function we intend to call. Both because jQuery may decide to stop rerouting common mistakes to .prop and because it makes code more readable. * Aside from switching to prop, for boolean properties also replacing null/undefined with false and 'propname' with true. This is no longer being covered by jQuery when using prop directly (as it shouldn't). When an element is created the HTML specification says that the attribute should be set to it's name (ie. '<foo selected="selected">'), the properties however must remain boolean. * Changing the attribute value for a boolean property (ie. checkbox.setAttribute( 'checked', 'checked' ) does not make the checkbox enabled. All it does is set the attribute. The reason this works with jQuery's attr() is because jQuery calls .prop internally after a bunch of checking inside attr(). -- Reference -- The list of keys that .attr and .removeAttr jQuery is currently (as of jQuery 1.6.1) remapping to use .prop and .removeProp can be found here: https://github.com/jquery/jquery/blob/b22c9046529852c7ce567df13397849e11e2b9cc/src/attributes.js#L425 { tabindex: "tabIndex", readonly: "readOnly", "for": "htmlFor", "class": "className", maxlength: "maxLength", cellspacing: "cellSpacing", cellpadding: "cellPadding", rowspan: "rowSpan", colspan: "colSpan", usemap: "useMap", frameborder: "frameBorder", contenteditable: "contentEditable" } In addition to those, jQuery also maps these boolean properties to .prop when they are passed to .attr: rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, (source: https://github.com/jquery/jquery/blob/b22c9046529852c7ce567df13397849e11e2b9cc/src/attributes.js#L9 ) Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/94386
* Fix usage of the jQuery global in a few spots.Daniel Friesen2011-08-121-1/+1
| | | | | | | | | | | - jQuery changed to $ in some files because there is a closure that creates a locally scoped $, but the jQuery var is globally scoped, meaning using jQuery instead of $ inside that closure could result in interacting with a different instance of jQuery than the uses of $ in that same closure. - In mwExtension wrap the code inside a closure which it is missing. Also take this chance to fix the whitespace style `fn( arg )` instead of `fn(arg)` on the isArray I added. This is partially a followup to r94331. Note: The jquery plugins inside the jquery/ folder look fine for use of jQuery within closures, except for mockjax. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/94332
* Fix a few comment typos noticed when doing JS reviewRoan Kattouw2011-08-111-1/+1
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/94247
* Follows-up r89848 CR: Cleaner solutionKrinkle2011-08-031-1/+4
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/93805
* Adding fix for bug 27427. Fixes unit test. Patch provided by Michael M. ↵Krinkle2011-07-301-1/+1
| | | | | | | | | | | through BugZilla. * (bug 27427) mw.util.getParamValue shouldn't return value from hash even if param is only present in hash. (Follows-up r93516) Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/93517
* Applying code conventions:Krinkle2011-07-281-5/+5
| | | | | | | | | | | | * size() -> length * strict comparison to undefined instead of typeof + string comparison * merge var statements * strict comparison to 0 and '' * dot notation * trailing whitespace Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/93364
* Minor mw.loader fixesKrinkle2011-07-231-1/+1
| | | | | | | | | | | | | | | | | | | - 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 /> Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/92933
* Remove mw.util.inArrayKrinkle2011-07-211-11/+0
| | | | | | | | | | | | - redundant and makes it even more confusing than jQuery's "inArray" already was. - Reverts r92261 - Fixed usage in /trunk/* -- http://toolserver.org/~krinkle/wikimedia-svn-search/view.php?id=245&hash=4ef50cd2f7017954e562155ccceba878 While at it, also took take of the r92297 fixme. Item argument must be before array argument. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/92752
* ajaxCategories fixes:Krinkle2011-07-151-6/+0
| | | | | | | | | | | | | | | | | | | | | * Partial revert of r92264. mw.ajaxCategories has nothing to do with mediawiki.util.init, moved into separate initiation module, only loaded when ajax categories is enabled. * Removing instantiation from the script. mw.ajaxCategories is now a public accessible constructor * Fix Uncaught ReferenceError: wgUserGroups is not defined ($wgLegacyJavaScriptGlobals = false;) * Renamimng stripIllegals() to clean(), adding '#' to the regex as those are not allowed either. * Combining var statements by separating them with comma's ( var foo, bar, baz; ) instead of "var foo; var bar; var baz;"svn up * Using dot.notation for objects instead of array-like['string'] keys * Whitespace conventions * Using inArray utility instead of indexOf (cross-browser support, mostly IE6) ** $.inArray uses Array.prototype.indexOf if available, otherwise fallback to a loop. mw.util.inArray is a wrapper around $.inArray to return a boolean value (since inArray/indexOf may return 0) * Don't use $( '#bodyContent' ) (skin specific) but mw.util.$content * Using mw.Title * Re-using helper functions from the outer-closure instead of re-declaring them privately for every instance again (performance!) Follows-up: r92112, r92151, r92264 Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/92288
* r92253 : readd useful changesLeo Koppelkamm2011-07-151-0/+6
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/92264
* Add boolean inArray utilityKrinkle2011-07-151-0/+11
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/92261
* Revert r92238: partial addition of broken test cases to qunit test suite; ↵Brion Vibber2011-07-151-6/+0
| | | | | | | loading of modules with uninitialized data triggers errors in console and marks the entire revision black in TestSwarm. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/92253
* AjaxCategories: move self init to mw.util.init; start with qunitLeo Koppelkamm2011-07-151-0/+6
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/92238
* Removing calls to deprecated functionality in favor of the new versions. Old ↵Krinkle2011-07-071-6/+9
| | | | | | | | | | | | | version worked fine but shouldn't be used. Follows-up: * r75275: Introduced the updateTooltipAccessKeys function in the new library but didn't call it on document ready and left the deprecated one in the onloadhook-run in wikibits.js untouched * r75287: Introduced jquery.checkboxShiftClick and called on-load but left the load call for the legacy version untouched. Depending on the load order at any given time it may not have been used. Also reordering the if-else case in mw.util.updateTooltipAccessKeys to allow a call without arguments ("undefined instanceof Foo" throws exception) Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/91660
* Partial (?) fix for bug 29753 -- wrong Firefox version comparison for ↵Brion Vibber2011-07-071-2/+2
| | | | | | | non-Mac Firefox 2+ accesskey tooltip. However, this code IS NOT YET USED which is very suspicious. An earlier version of this code is wikibits.js is still being used for some reason, which indicates a maintenance problem. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/91652
* mw.util.wikiGetlink default to wgPageNameKrinkle2011-07-051-2/+2
| | | | | | | | | | * (bug 29723) mw.util.wikiGetlink() should default to wgPageName * Solution by mybugs.mail * Adding unit tests Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/91500
* mw.util optimalizations:Krinkle2011-07-051-22/+23
| | | | | | | | * Remove redundant mw>mediaWiki passing through IIFE * Using local alias to global mw.util Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/91497
* (bug 29567) mw.util.addPortletLink should only wrap link in <span> for ↵Krinkle2011-06-241-2/+7
| | | | | | | | | | "vectorTabs" portlets * Patch by Erwin Dokter * This unbreaks test introduced in r90728 Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/90729
* New mediawiki.page modulesKrinkle2011-06-221-11/+0
| | | | | | | | | | | | | | | | | | | First step towards cleaning up mw.util.init and removing bugus dependancies on mediawiki.util which are just added there in order to load them on every page and do something on-load. Introducing mediawiki.page.startup (in the head) and mediawiki.page.ready (on the bottom) Moved the following to them: * document.ready from jquery.cient -- Shouldn't have been in the plugin itself in the first place * jquery.placeholder * jquery.makeCollapsible * mediawiki.action.view.tablesorting * jquery.checkboxShiftClick (This also solves part of bug 26799) Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/90605
* Remove redundant mediawiki.util directoryKrinkle2011-06-141-0/+598
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/90063
* Introducing mediaWiki.language, and mediaWiki.message which are modeled ↵Trevor Parscal2010-10-261-314/+0
| | | | | | | after their PHP counterparts Language and wfMessage respectively. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/75486
* added support for standard, cologneblue, nostalgia in mw.util.addPortletLink ↵Krinkle2010-10-241-49/+77
| | | | | | | + updated the test suite Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/75336
* adding debug test suit for mediaWiki.util, visible on ↵Krinkle2010-10-241-7/+7
| | | | | | | Special:MWUtilTest?debug=true Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/75325
* added string trimming for older browsersKrinkle2010-10-231-1/+30
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/75294
* added mw.util.getWikilink and ported enableCheckboxShiftClick to jQueryKrinkle2010-10-231-16/+45
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/75287
* adding begin of mediaWiki.util and loading it by default + trailing ↵Krinkle2010-10-231-0/+228
whitespace cleanup in mediawiki.js Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/75275