Commit graph

42 commits

Author SHA1 Message Date
Krinkle
be06bd4560 Enqueue mw.util.init in document-ready even handler earlier
* Previously $(document).ready(mw.util.init) was in module 'mediawiki.page.ready' (position: bottom). I've now moved this to 'mediawiki.page.startup' so that it'll be enqueued sooner.
* This making it more likely that if someone also enqueues in document-ready that mw.util.init ran before than and thus mw.util.$content populated
* Fixes bug 33711

* All this is still depends on the order in which the event handler queue is executed, which is risky. Bug 30713 will bring the solid "watertight" solution
2012-02-02 00:47:53 +00:00
Krinkle
b2733fa44c [mediawiki.action.watch.ajax.js] Rewrite using mw.Api and fixes bug 27146
* Use mw.Api and new it's new .watch() as of r107350
* No longer get title from url, use wgPageName instead
* No longer simple queryParam check for action in url,
  now supports wgActionPaths as well.
* Simplification and speed up (less back and forth between
functions and jQuery-ism). Previously it had $(..) with several
.add() calls. Now doing one call.
* Uses mw.util.tooltipAccessKeyRegexp instead of local regex
* Uses jQuery.fn.text instead of jQuery.fn.html for link text message

* Should fix bug 27146 (previously a failed attempt in r82498)
* Previousy worked on in r88527, r88511, r78150, r78147

* minor whitespace/comment fix in mediawiki.util.js/mediawiki.page.startup.js
2011-12-27 01:21:56 +00:00
John Du Hart
b520984ea2 Reverting r103856 since it does not work. <body> is not available at startup. 2011-11-22 15:58:28 +00:00
John Du Hart
480f0c7017 Followup r95318, move client-(no)js classes to the body tag per discussion in bug 30497 2011-11-21 22:53:24 +00:00
Brion Vibber
b2fa982253 bug 32183: remove the client-* classes added from user-agent-sniffing onto the <html> element.
Browser sniffing is bad, and having these here encourages unpleasantness.
Keeping the js/nojs ones as those are useful and non-evil (they're an example of feature detection, exposed via CSS here rather than through JS.)
2011-11-03 19:18:49 +00:00
Krinkle
d0677222a5 Split ajaxCategories away from core for now, into an extension:
* Move js/css/images from core into extension dir (kept svn history in tact)

* Removed from core:
** Messages
** Resource definition
** Default settings

* Recreated in extension: 
** Messages with 'inlinecategorizer' prefix (instead of generic 'ajax' prefix).
** wgResourceModule definition
** Hooks for adding module to the page
** Setting wgAJAXCategoriesNamespaces kept (renamed to $wgInlineCategorizerNamespaces)

* Made minor adjustments to the messages:
** Fixed references to other messages (in /qqq) with the new message key

* Made minor adjustments to the javascript:
** Usage of mw.msg fixed to the new message keys
** Removed "@since 1.19"
** Removed "Relies on mw.user.getId" (because it didn't', and still doesn't)
** Object 'mw.ajaxCategories' -> 'mw.InlineCategorizer' (capitalized, since it's a constructor, per our conventions)
** Removed 'disableAJAXCategories' config, not needed.


Summary of justification for move out of core (again):
* Too many issues with the parsing logic (many cases still don't work yet)
* Almost untested and untestable because of mixing UI with logic code. Needs separation.
* See http://www.mediawiki.org/wiki/User:Krinkle/Extension_review/InlineCategorizer#Prequel

One day we might move it in, or if the "new parser" is ready and the "visual editor" we might not need it all together and it'd simply be a 10-20 line module in the visual editor (that, or it'd be part of the visual editor by default).

Anyway, I'm not against this module. if we can get this to an acceptable state soonish before any of the new parser / visual editor is ready, then I see no problem in bundling it with core and/or merging it into core.
2011-09-04 19:35:22 +00:00
Krinkle
fa022cc96c Add local generator function to account for revert of r93063 in r96236. 2011-09-04 17:04:09 +00:00
Krinkle
17cecf2647 Separate execution from definition (mediawiki.util.init)
* 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.
2011-09-02 21:17:54 +00:00
Krinkle
00a2df6872 Fix Uncaught TypeError: Cannot call method 'substr' of undefined
* When changing the name of a category and saving it, this error is thrown from $.ucFirst. Although the script does check for it to be a string, what happens between that and ucFirst is broken. It should always set 'category' of splitresult[0], not just if there is a [1] (=sortkey). Otherwise, if there is no sortkey, 'category' is undefined.
* Also updated outdated comment saying that variable sortkey contains wikitext between "[[Category:Foo" and "]]" (which implies it includes the pipe, which is no longer true)
 
Follows-up r93351.
2011-08-31 14:37:37 +00:00
Sam Reed
907ef110dc Revert r91728
Hence reverting r93382, t93383, r94236
2011-08-24 18:22:53 +00:00
Brion Vibber
e0ab2840db * (bug 30497) Add client-nojs and client-js classes on document element to let styles easily hide or show things based on general JS availability
Patch by John Du Hart - https://bugzilla.wikimedia.org/attachment.cgi?id=8956
2011-08-23 18:33:28 +00:00
Krinkle
0e82a6cfd0 Applying whitespace conventions in core JS files.
* Mostly whitespace in callers: $('foo').bar(baz,quux) => $( 'foo' ).bar( baz, quux )
* Also several occurrences of mixes spaces and tabs in the indention in front of a line, converted to tabs.
* And double spaces -> single spaces at random.
2011-08-12 21:48:10 +00:00
Krinkle
7d569319c7 more ajaxCategories fixes based on review in r93351 CR
* Html-escaping unescaped message in summaryHolder 
* Check for errors in the API response
* Pass true for existence of redirect origin and value of 'exists' for target (instead of backwards)
* Comment fixes
2011-08-12 11:35:50 +00:00
Krinkle
9c52dda64b Solve undefined-message problem by removing it all together. I've moved the .containsCat() check to before the $link.length/createCatLink code, now it's always defined.
(Follows-up r93351, r94268)
2011-08-11 19:14:34 +00:00
Krinkle
fa5f572bd8 ajaxCategories fixes based on review in r93351 CR:
* Using typeof check in clean()
* Use mw.Title to get page title from fullpagename instead of split(':')
* replaceNowikis() and restoreNowikis()
 - Improve documentation
 - Moved dash in the UNIQUEKEY to between the id and the incrementing integer, and made it start with an empty string (so that all following concatenations are toString'ed).
* makeCaseInsensitive(): Moved the wgCaseSensitiveNamespaces-check out and wrapped it around the caller instead. Also cached the outcome of "Is category namespace sensitive ?".
* createButton(): text-argument is indeed text, not html. Applying html-escaping.
* resolveRedirects():
 - Replace access to private property _name of mw.Title with function getMainText().
* handleCategoryAdd() and handleEditLink():
 - Restructure title-handling (no local replace() calls and clean(), let mw.Title handle it)
 - Renaming arguments and documenting them better
 - Renaming local variables and removing redundant parts
 - Preserving sortkey as sortkey as long as possible without the pipe
 - Calling the combination of sortkey and leading pipe 'suffix' instead of, also, sortkey.
* createCatLink():
 - Remove the sanitizing here, the string passed is already clean as it comes from mw.Title now
 - Using .text() instead of .append( which is .html-like), category names can contain special characters.
* containsCat():
 - Using $.each instead of [].filter. Stopping after first match.
* buildRegex(): Allow whitespace before namespace colon, and allow whitespace after category name (but before ]] and |..]])

Additional changes not for any function in particular:
* Literally return null in $.map callbacks.
* Using the existence-system of mw.Title instead of passing around booleans everywhere
** Removed 'exists' argument from the resolveRedirects() and handleCategoryAdd() functions, instead checking .exists() of the mw.Title object.
* Passing and using mw.Title objects where possible instead of converting back and forth between strings and objects etc.
* Using "TitleObj.getUrl()" instead of "catUrl( titleString )". Removed now unused catUrl() function.
* To improve readability, renamed local uses of 'var that = this' to 'var ajaxcat = this'.
* Syntax error fixes (.parent -> .parent())
* Merging var statements
* Renamed generic members of 'stash' from 'stash.summaries' to 'stash.dialogDescriptions' and 'stash.shortSum' to 'stash.editSummaries'. dialogDescription is always HTML (input should be escaped before hand)
2011-08-11 19:01:39 +00:00
Roan Kattouw
0554848efa Fix a few comment typos noticed when doing JS review 2011-08-11 14:47:18 +00:00
Krinkle
3b5aa43bfc Follow-up r93383: api param is 'namespace', not 'namespaces'. 2011-08-11 11:09:53 +00:00
Leo Koppelkamm
3c61c3f17a r91728 : Fix a problem for api.php5 users and remove an unneeded function parameter from deliverResult 2011-07-28 11:22:42 +00:00
Leo Koppelkamm
d957bdfdee r91728 : Fix whitespace and two vars per CR 2011-07-28 11:02:21 +00:00
Niklas Laxström
637725981f Fu r93351: remove extra space 2011-07-28 06:41:45 +00:00
Krinkle
62a3e10fea AjaxCategories rewrite:
Solving syntax problems, performance improvements and applying code conventions: 

* Replaced sprite image with separate images and letting ResourceLoader embed them with @embed (@embed means 0 http requests, less maintenance, none of the known limitations with sprites, and more readable code (named files rather than pixel offsets)

* Many functions were floating in the global namespace (like window.makeCaseInsensitive). A statement ends after a semi-colon(;). All functions declared after "catUrl" were assigned to the window object. I've instead turned the semi-colons back into comma's, merged some other var statements and moved them to the top of the closure. Changed local function declarations into function expressions for clarity.

* fetchSuggestions is called by $.fn.suggestions like ".call( $textbox, $textbox.val() )". So the context (this) isn't the raw element but the jQuery object, no need to re-construct with "$(this)" or "$(that)" which is slow and shouldn't even work. jQuery methods can be called on it directly. I've also replaced "$(this).val()" with the value-argument passed to fetchSuggestions which has this exact value already.

* Adding more function documentation. And changing @since to 1.19 as this was merged from js2-branch into 1.19-trunk and new features aren't backported to 1.18.

* Optimizing options/default construction to just "options = $.extend( {}, options )". Caching defaultOptions is cool, but doesn't really work if it's in a context/instance local variable. Moved it up to the module closure var statements, now it's static across all instances.

* In makeSuggestionBox(): Fixing invalid html fragments passed to jQuery that fail in IE. Shortcuts (like '<foo>' and '<foo/>') are only allowed for createElement triggers, not when creating longer fragments with content and/or attributes which are created through innerHTML, in the latter case the HTML must be completely valid and is not auto-corrected by IE.

* Using more jQuery chaining where possible.

* In buildRegex(): Using $.map with join( '|' ), (rather than $.each with += '|'; and substr).

* Storing the init instance of mw.ajaxCategories in mw.page for reference (rather than local/anonymous).

* Applied some best practices and "write testable code"
** Moved some of the functions created on the fly and assigned to 'this' into prototype (reference is cheaper)
** Making sure at least all 'do', 'set' and/or 'prototype' functions have a return value. Even if it's just a simple boolean true or context/this for chain-ability. 
** Rewrote confirmEdit( .., .., .., ) as a prototyped method named "doConfirmEdit" which takes a single props-object with named valuas as argument, instead of list with 8 arguments.

* Removed trailing whitespace and other minor fixes to comply with the code conventions.
** Removed space between function name and caller: "foo ()" => foo()) 
** Changing "someArray.indexOf() + 1" into "someArr.indexOf() !== -1". We want a Boolean here, not a Number.
** Renamed all underscore-variables to non-underscore variants.

== Bug fixes ==

* When adding a category that is not already on the page as-is but of which the clean() version is already on the page, the script would fail. Fixed it by moving the checks up in handleCategoryAdd() and making sure that createCatLink() actually returned something.

* confirmEdit() wasn't working properly and had unused code (such as submitButton), removed hidden prepending to #catlinks, no need to, it can be dialog'ed directly from the jQuery object without being somewhere in the document.

* in doConfirmEdit() in submitFunction() and multiEdit: Clearing the input field after adding a category, so that when another category is being added it doesn't start with the previous value which is not allowed to be added again...
2011-07-28 00:43:21 +00:00
Leo Koppelkamm
ef665a75c0 r93090 : Make summaries more modular, Siebrand says there'll be problems with translation otherwise. 2011-07-26 15:50:43 +00:00
Leo Koppelkamm
d2fc14068d * Ignore any <nowiki> or comment sections
* More natural messages
* Respect wgCaseSensitiveNamespaces
* Regex: Add possible whitespace between "[[Category:" and the category name. ( [[Category: Foo]] )
* Make nearly all functions publicly accessible
* Add "cancel all" button
* Submit on enter keypress
* Check for redirects
* Color links correctly based on existance of category page
* Add a summary of the changes done into the edit summary ('+Category:foo, -Category:Bar: Foo is not correct...')
* Add more error handlers
* Add more hooks ( afterChange/Delete/add ).
* Pass category names to the hooks
* Allow hooks to abort by returning false
* Handle sortkey correctly in all operations
* Move addCategory form below categories.
* Fix any known IE6 and IE7 bugs.
* Add more documentation
2011-07-25 19:03:26 +00:00
Krinkle
32adabfca4 Remove mw.util.inArray
- 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.
2011-07-21 16:41:21 +00:00
Leo Koppelkamm
7a824f8b34 r92288 : Missed second arg to inArray 2011-07-15 20:24:00 +00:00
Krinkle
cb6029734f ajaxCategories fixes:
* 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
2011-07-15 19:25:16 +00:00
Leo Koppelkamm
f2e383cd4b AjaxCategories: Making MultiEdit mores stable and getting rid of other bugs 2011-07-15 18:21:37 +00:00
Leo Koppelkamm
cd97c09138 r92253 : readd useful changes 2011-07-15 18:19:10 +00:00
Brion Vibber
cf627bc707 Revert r92238: partial addition of broken test cases to qunit test suite; loading of modules with uninitialized data triggers errors in console and marks the entire revision black in TestSwarm. 2011-07-15 17:29:17 +00:00
Leo Koppelkamm
560d6f08d2 AjaxCategories: move self init to mw.util.init; start with qunit 2011-07-15 11:12:07 +00:00
Leo Koppelkamm
5e919c6e10 AjaxCategories: More interface polish 2011-07-14 20:48:01 +00:00
Leo Koppelkamm
b2085330d0 AjaxCategories: Add basic hook functionality. Can be used by sites for stuff like {{uncategorized}} templates etc. 2011-07-14 17:14:39 +00:00
Leo Koppelkamm
dfa4886882 AjaxCategories: Yay! MultiEdit mode working. May need more polish. Ping r92112 2011-07-14 16:00:07 +00:00
Leo Koppelkamm
bfb5b65879 AjaxCategories:
* Lay foundation for MultiEdit mode 
* Add releasenotes 
* Fix typo in function name 
* Change error msg per CR
Ping r92062
2011-07-14 15:00:33 +00:00
Leo Koppelkamm
5d2b0ab0ed AjaxCategories:
* Restructuring to allow both private and public functions/objects. 
* Add an error when category alread present, instead of quitting silently. 
* Add documentation to most functions. 
* Remove hardcoded api.php (Thanks Krinkle)
Ping r92062
2011-07-14 11:36:50 +00:00
Leo Koppelkamm
de96e92368 Rewrite ajaxCategories for ResourceLoader. Add some missing functionality (edit categories and more). Move styles from shared.css into own stylesheet. Fix regex bugs 2011-07-13 22:36:03 +00:00
Leo Koppelkamm
1234da5a71 Readd ajaxCategories from r58959 . This is just a preparation for my next commit, so that the file's history is preserved 2011-07-13 22:15:11 +00:00
Leo Koppelkamm
5c1da6ba27 Rewrite mwsuggest.js using j.ui.autocomplete. This gets rid of a lot of the little kinks of the previously implemenation: The suggestion list now contains regular anchors which can be openened in new indows or separate tabs. The carret doesn't jump around anymore when using the arrow keys to select an item. This should make it much easier to eventually merge Vectors simple search & mwsuggest. 2011-07-08 14:59:20 +00:00
Krinkle
29976f1c91 Removing calls to deprecated functionality in favor of the new versions. Old 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)
2011-07-07 17:52:55 +00:00
Krinkle
a046427547 Revert r90678 per CR 2011-07-04 23:36:54 +00:00
Derk-Jan Hartman
6f225a6c16 Switch jquery.sortable to use mw-sortable and mw-unsortable classes, to be in line with makeCollapsible. Support for legacy .sortable remains.
Follow up to r86088
2011-06-23 21:26:21 +00:00
Krinkle
95173d11f1 New mediawiki.page modules
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)
2011-06-22 21:27:12 +00:00