Commit graph

7 commits

Author SHA1 Message Date
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
39cb0c19d5 Use .prop instead of .attr where appropriate
* 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:
b22c904652/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: b22c904652/src/attributes.js (L9) )
2011-08-12 21:19:45 +00:00
Antoine Musso
5418ac98d2 Find 'all' special ns regardless of its rank in the select
This is done by looking for an <option> element with an empty string value
which denote the special case 'all'.
Also removed a comment in Xml.php asking to keep 'all' as a first element
since it is no longer needed.

Follow up r90943 (comment 18872 by Brion)
2011-06-28 19:32:25 +00:00
Krinkle
bfad162105 per r90984 CR, cleaner this way 2011-06-28 18:17:49 +00:00
Krinkle
ab52899b1d mw.special.recentchanges fixes:
- Partial self-revert of r90982 (binding and triggering must not be chained, as the calling function refers to the variable we're setting)
- The Qunit tests pass now :)



Follows up: r90943 r90960 r90968 r90980 r90982
2011-06-28 17:56:56 +00:00
Krinkle
43bf61fde2 mw.special.recentchanges fixes:
- using mw globally directly
- ID-selectors
- JS Effeciency in mw.special.rc.init (chaining instead of re-getting from this.select)
- passing function by reference instead of calling inside a new anonymous function
- marking checkboxes a private/local variable
- whitespace conventions



Follows up: r90943 r90960 r90968 r90980
2011-06-28 17:40:06 +00:00
Antoine Musso
d4abcb5268 Disable ns selector checkboxes when 'all' namespace is selected
* based on an idea by Aaron on r90866
* comes with QUnit test
* expect the special 'all' namespace to be the first in the list
* function build on mediawiki.special form r90941
2011-06-28 06:40:49 +00:00