r79929 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79928‎ | r79929 | r79930 >
Date:05:33, 10 January 2011
Author:krinkle
Status:resolved (Comments)
Tags:
Comment:
Removing unneeded wraps and using $ and mw instead of jQuery or mediaWiki since r79246 enabled the private scope by default. No need for two wraps.
(the wraps had an extra indention, hence the diff will probably look huge)
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.checkboxShiftClick.js (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.client.js (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.color.js (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.colorUtil.js (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.hoverIntent.js (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.localize.js (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.placeholder.js (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.suggestions.js (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.tabIndex.js (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.textSelection.js (modified) (history)
  • /trunk/phase3/resources/mediawiki.special/mediawiki.special.changeslist.css (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.textSelection.js
@@ -1,7 +1,6 @@
22 /**
33 * These plugins provide extra functionality for interaction with textareas.
44 */
5 -( function( $ ) {
65 $.fn.textSelection = function( command, options ) {
76 var fn = {
87 /**
@@ -399,6 +398,4 @@
400399 context.fn.saveSelection();
401400 }
402401 return retval;
403 -};
404 -
405 -} )( jQuery );
 402+};
\ No newline at end of file
Index: trunk/phase3/resources/jquery/jquery.checkboxShiftClick.js
@@ -7,21 +7,21 @@
88 * @license GPL v2
99 */
1010
11 -jQuery.fn.checkboxShiftClick = function( text ) {
 11+$.fn.checkboxShiftClick = function( text ) {
1212 var prevCheckbox = null;
1313 var $box = this;
1414 // When our boxes are clicked..
15 - $box.click(function (e) {
 15+ $box.click( function( e ) {
1616 // And one has been clicked before...
17 - if (prevCheckbox !== null && e.shiftKey) {
 17+ if ( prevCheckbox !== null && e.shiftKey ) {
1818 // Check or uncheck this one and all in-between checkboxes
1919 $box.slice(
20 - Math.min($box.index(prevCheckbox), $box.index(e.target)),
21 - Math.max($box.index(prevCheckbox), $box.index(e.target)) + 1
22 - ).attr({checked: e.target.checked ? 'checked' : ''});
 20+ Math.min( $box.index( prevCheckbox ), $box.index( e.target ) ),
 21+ Math.max( $box.index( prevCheckbox ), $box.index( e.target ) ) + 1
 22+ ).attr( {checked: e.target.checked ? 'checked' : ''} );
2323 }
2424 // Either way, update the prevCheckbox variable to the one clicked now
2525 prevCheckbox = e.target;
26 - });
 26+ } );
2727 return $box;
2828 };
\ No newline at end of file
Index: trunk/phase3/resources/jquery/jquery.tabIndex.js
@@ -1,27 +1,28 @@
22 /**
33 * Finds the lowerst tabindex in use within a selection
44 *
5 - * @return Integer of lowest tabindex on the page
 5+ * @return number Lowest tabindex on the page
66 */
7 -jQuery.fn.firstTabIndex = function() {
 7+$.fn.firstTabIndex = function() {
88 var minTabIndex = 0;
9 - jQuery(this).find( '[tabindex]' ).each( function() {
10 - var tabIndex = parseInt( jQuery(this).attr( 'tabindex' ) );
 9+ $(this).find( '[tabindex]' ).each( function() {
 10+ var tabIndex = parseInt( $(this).attr( 'tabindex' ) );
1111 if ( tabIndex > minTabIndex ) {
1212 minTabIndex = tabIndex;
1313 }
1414 } );
1515 return minTabIndex;
1616 };
 17+
1718 /**
1819 * Finds the highest tabindex in use within a selection
1920 *
20 - * @return Integer of highest tabindex on the page
 21+ * @return number Highest tabindex on the page
2122 */
22 -jQuery.fn.lastTabIndex = function() {
 23+$.fn.lastTabIndex = function() {
2324 var maxTabIndex = 0;
24 - jQuery(this).find( '[tabindex]' ).each( function() {
25 - var tabIndex = parseInt( jQuery(this).attr( 'tabindex' ) );
 25+ $(this).find( '[tabindex]' ).each( function() {
 26+ var tabIndex = parseInt( $(this).attr( 'tabindex' ) );
2627 if ( tabIndex > maxTabIndex ) {
2728 maxTabIndex = tabIndex;
2829 }
Index: trunk/phase3/resources/jquery/jquery.localize.js
@@ -1,58 +1,53 @@
22 /**
3 - * Simple Placeholder-based Localization
4 - *
 3+ * Simple Placeholder-based Localization
 4+ *
55 * Call on a selection of HTML which contains <msg key="message-key" /> elements or elements with
66 * title-msg="message-key" or alt-msg="message-key" attributes. <msg /> elements will be replaced
77 * with localized text, elements with title-msg and alt-msg attributes will receive localized title
88 * and alt attributes.
9 - *
 9+ *
1010 * Example:
11 - *
12 - * <p class="somethingCool">
13 - * <msg key="my-message" />
14 - * <img src="something.jpg" title-msg="my-title-message" alt-msg="my-alt-message" />
15 - * </p>
16 - *
 11+ * <p class="somethingCool">
 12+ * <msg key="my-message" />
 13+ * <img src="something.jpg" title-msg="my-title-message" alt-msg="my-alt-message" />
 14+ * </p>
 15+ *
1716 * Localizes to...
18 - *
19 - * <p class="somethingCool">
20 - * My Message
21 - * <img src="something.jpg" title="My Title Message" alt="My Alt Message" />
22 - * </p>
 17+ * <p class="somethingCool">
 18+ * My Message
 19+ * <img src="something.jpg" title="My Title Message" alt="My Alt Message" />
 20+ * </p>
2321 */
24 -
25 -( function( $, mw ) {
26 - /**
27 - * Localizes a DOM selection by replacing <msg /> elements with localized text and adding
28 - * localized title and alt attributes to elements with title-msg and alt-msg attributes
29 - * respectively.
30 - *
31 - * @param Object: options Map of options
32 - * * prefix: Message prefix to use when localizing elements and attributes
33 - */
34 - $.fn.localize = function( options ) {
35 - options = $.extend( { 'prefix': '' }, options );
36 - return $(this)
37 - .find( 'msg' )
38 - .each( function() {
39 - $(this)
40 - .text( mediaWiki.msg( options.prefix + $(this).attr( 'key' ) ) )
41 - .replaceWith( $(this).html() );
42 - } )
43 - .end()
44 - .find( '[title-msg]' )
45 - .each( function() {
46 - $(this)
47 - .attr( 'title', mw.msg( options.prefix + $(this).attr( 'title-msg' ) ) )
48 - .removeAttr( 'title-msg' );
49 - } )
50 - .end()
51 - .find( '[alt-msg]' )
52 - .each( function() {
53 - $(this)
54 - .attr( 'alt', mw.msg( options.prefix + $(this).attr( 'alt-msg' ) ) )
55 - .removeAttr( 'alt-msg' );
56 - } )
57 - .end();
58 - };
59 -} )( jQuery, mediaWiki );
 22+/**
 23+ * Localizes a DOM selection by replacing <msg /> elements with localized text and adding
 24+ * localized title and alt attributes to elements with title-msg and alt-msg attributes
 25+ * respectively.
 26+ *
 27+ * @param Object: options Map of options
 28+ * * prefix: Message prefix to use when localizing elements and attributes
 29+ */
 30+$.fn.localize = function( options ) {
 31+ options = $.extend( { 'prefix': '' }, options );
 32+ return $(this)
 33+ .find( 'msg' )
 34+ .each( function() {
 35+ $(this)
 36+ .text( mediaWiki.msg( options.prefix + $(this).attr( 'key' ) ) )
 37+ .replaceWith( $(this).html() );
 38+ } )
 39+ .end()
 40+ .find( '[title-msg]' )
 41+ .each( function() {
 42+ $(this)
 43+ .attr( 'title', mw.msg( options.prefix + $(this).attr( 'title-msg' ) ) )
 44+ .removeAttr( 'title-msg' );
 45+ } )
 46+ .end()
 47+ .find( '[alt-msg]' )
 48+ .each( function() {
 49+ $(this)
 50+ .attr( 'alt', mw.msg( options.prefix + $(this).attr( 'alt-msg' ) ) )
 51+ .removeAttr( 'alt-msg' );
 52+ } )
 53+ .end();
 54+};
\ No newline at end of file
Index: trunk/phase3/resources/jquery/jquery.hoverIntent.js
@@ -81,7 +81,7 @@
8282 if ( p == this ) { return false; }
8383
8484 // copy objects to be passed into t (required for event object to be passed in IE)
85 - var ev = jQuery.extend({},e);
 85+ var ev = $.extend({},e);
8686 var ob = this;
8787
8888 // cancel hoverIntent timer if it exists
Index: trunk/phase3/resources/jquery/jquery.suggestions.js
@@ -41,7 +41,6 @@
4242 * highlightInput: Whether to hightlight matched portions of the input or not
4343 * Type: Boolean, Default: false
4444 */
45 -( function( $ ) {
4645
4746 $.suggestions = {
4847 /**
@@ -516,6 +515,4 @@
517516 $(this).data( 'suggestions-context', context );
518517 } );
519518 return returnValue !== null ? returnValue : $(this);
520 -};
521 -
522 -} )( jQuery );
 519+};
\ No newline at end of file
Index: trunk/phase3/resources/jquery/jquery.colorUtil.js
@@ -1,195 +1,191 @@
2 -/*
 2+/**
33 * jQuery Color Utilities
44 * Written by Krinkle in 2011
55 * Released under the MIT and GPL licenses.
66 * Mostly based on other plugins and functions (taken through JSLint and optimized a little).
77 * Sources cited locally.
88 */
9 -( function( $ ) {
 9+$.colorUtil = {
1010
11 - $.colorUtil = {
 11+ // Color Conversion function from highlightFade
 12+ // By Blair Mitchelmore
 13+ // http://jquery.offput.ca/highlightFade/
 14+ // Parse strings looking for color tuples [255,255,255]
 15+ getRGB : function( color ) {
 16+ var result;
1217
13 - // Color Conversion function from highlightFade
14 - // By Blair Mitchelmore
15 - // http://jquery.offput.ca/highlightFade/
16 - // Parse strings looking for color tuples [255,255,255]
17 - getRGB : function( color ) {
18 - var result;
 18+ // Check if we're already dealing with an array of colors
 19+ if ( color && color.constructor == Array && color.length == 3 ){
 20+ return color;
 21+ }
1922
20 - // Check if we're already dealing with an array of colors
21 - if ( color && color.constructor == Array && color.length == 3 ){
22 - return color;
23 - }
 23+ // Look for rgb(num,num,num)
 24+ if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) {
 25+ return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
 26+ }
2427
25 - // Look for rgb(num,num,num)
26 - if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) {
27 - return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
28 - }
 28+ // Look for rgb(num%,num%,num%)
 29+ if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) {
 30+ return [parseFloat(result[1],10)*2.55, parseFloat(result[2],10)*2.55, parseFloat(result[3])*2.55];
 31+ }
2932
30 - // Look for rgb(num%,num%,num%)
31 - if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) {
32 - return [parseFloat(result[1],10)*2.55, parseFloat(result[2],10)*2.55, parseFloat(result[3])*2.55];
33 - }
 33+ // Look for #a0b1c2
 34+ if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) {
 35+ return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
 36+ }
3437
35 - // Look for #a0b1c2
36 - if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) {
37 - return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
38 - }
 38+ // Look for #fff
 39+ if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) {
 40+ return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
 41+ }
3942
40 - // Look for #fff
41 - if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) {
42 - return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
43 - }
 43+ // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
 44+ if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) {
 45+ return $.colorUtil.colors.transparent;
 46+ }
4447
45 - // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
46 - if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) {
47 - return $.colorUtil.colors.transparent;
48 - }
 48+ // Otherwise, we're most likely dealing with a named color
 49+ return $.colorUtil.colors[jQuery.trim(color).toLowerCase()];
 50+ },
4951
50 - // Otherwise, we're most likely dealing with a named color
51 - return $.colorUtil.colors[jQuery.trim(color).toLowerCase()];
52 - },
 52+ // Some named colors to work with
 53+ // From Interface by Stefan Petre
 54+ // http://interface.eyecon.ro/
 55+ colors: {
 56+ aqua:[0,255,255],
 57+ azure:[240,255,255],
 58+ beige:[245,245,220],
 59+ black:[0,0,0],
 60+ blue:[0,0,255],
 61+ brown:[165,42,42],
 62+ cyan:[0,255,255],
 63+ darkblue:[0,0,139],
 64+ darkcyan:[0,139,139],
 65+ darkgrey:[169,169,169],
 66+ darkgreen:[0,100,0],
 67+ darkkhaki:[189,183,107],
 68+ darkmagenta:[139,0,139],
 69+ darkolivegreen:[85,107,47],
 70+ darkorange:[255,140,0],
 71+ darkorchid:[153,50,204],
 72+ darkred:[139,0,0],
 73+ darksalmon:[233,150,122],
 74+ darkviolet:[148,0,211],
 75+ fuchsia:[255,0,255],
 76+ gold:[255,215,0],
 77+ green:[0,128,0],
 78+ indigo:[75,0,130],
 79+ khaki:[240,230,140],
 80+ lightblue:[173,216,230],
 81+ lightcyan:[224,255,255],
 82+ lightgreen:[144,238,144],
 83+ lightgrey:[211,211,211],
 84+ lightpink:[255,182,193],
 85+ lightyellow:[255,255,224],
 86+ lime:[0,255,0],
 87+ magenta:[255,0,255],
 88+ maroon:[128,0,0],
 89+ navy:[0,0,128],
 90+ olive:[128,128,0],
 91+ orange:[255,165,0],
 92+ pink:[255,192,203],
 93+ purple:[128,0,128],
 94+ violet:[128,0,128],
 95+ red:[255,0,0],
 96+ silver:[192,192,192],
 97+ white:[255,255,255],
 98+ yellow:[255,255,0],
 99+ transparent: [255,255,255]
 100+ },
 101+ /**
 102+ * http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
 103+ * Converts an RGB color value to HSL. Conversion formula
 104+ * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
 105+ * Assumes r, g, and b are contained in the set [0, 255] and
 106+ * returns h, s, and l in the set [0, 1].
 107+ *
 108+ * @param Number R The red color value
 109+ * @param Number G The green color value
 110+ * @param Number B The blue color value
 111+ * @return Array The HSL representation
 112+ */
 113+ rgbToHsl: function( R, G, B ) {
 114+ var r = R / 255,
 115+ g = G / 255,
 116+ b = B / 255;
 117+ var max = Math.max(r, g, b), min = Math.min(r, g, b);
 118+ var h, s, l = (max + min) / 2;
53119
54 - // Some named colors to work with
55 - // From Interface by Stefan Petre
56 - // http://interface.eyecon.ro/
57 - colors: {
58 - aqua:[0,255,255],
59 - azure:[240,255,255],
60 - beige:[245,245,220],
61 - black:[0,0,0],
62 - blue:[0,0,255],
63 - brown:[165,42,42],
64 - cyan:[0,255,255],
65 - darkblue:[0,0,139],
66 - darkcyan:[0,139,139],
67 - darkgrey:[169,169,169],
68 - darkgreen:[0,100,0],
69 - darkkhaki:[189,183,107],
70 - darkmagenta:[139,0,139],
71 - darkolivegreen:[85,107,47],
72 - darkorange:[255,140,0],
73 - darkorchid:[153,50,204],
74 - darkred:[139,0,0],
75 - darksalmon:[233,150,122],
76 - darkviolet:[148,0,211],
77 - fuchsia:[255,0,255],
78 - gold:[255,215,0],
79 - green:[0,128,0],
80 - indigo:[75,0,130],
81 - khaki:[240,230,140],
82 - lightblue:[173,216,230],
83 - lightcyan:[224,255,255],
84 - lightgreen:[144,238,144],
85 - lightgrey:[211,211,211],
86 - lightpink:[255,182,193],
87 - lightyellow:[255,255,224],
88 - lime:[0,255,0],
89 - magenta:[255,0,255],
90 - maroon:[128,0,0],
91 - navy:[0,0,128],
92 - olive:[128,128,0],
93 - orange:[255,165,0],
94 - pink:[255,192,203],
95 - purple:[128,0,128],
96 - violet:[128,0,128],
97 - red:[255,0,0],
98 - silver:[192,192,192],
99 - white:[255,255,255],
100 - yellow:[255,255,0],
101 - transparent: [255,255,255]
102 - },
103 - /**
104 - * http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
105 - * Converts an RGB color value to HSL. Conversion formula
106 - * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
107 - * Assumes r, g, and b are contained in the set [0, 255] and
108 - * returns h, s, and l in the set [0, 1].
109 - *
110 - * @param Number R The red color value
111 - * @param Number G The green color value
112 - * @param Number B The blue color value
113 - * @return Array The HSL representation
114 - */
115 - rgbToHsl: function( R, G, B ) {
116 - var r = R / 255,
117 - g = G / 255,
118 - b = B / 255;
119 - var max = Math.max(r, g, b), min = Math.min(r, g, b);
120 - var h, s, l = (max + min) / 2;
121 -
122 - if(max == min){
123 - h = s = 0; // achromatic
124 - }else{
125 - var d = max - min;
126 - s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
127 - switch(max){
128 - case r: h = (g - b) / d + (g < b ? 6 : 0); break;
129 - case g: h = (b - r) / d + 2; break;
130 - case b: h = (r - g) / d + 4; break;
131 - }
132 - h /= 6;
 120+ if(max == min){
 121+ h = s = 0; // achromatic
 122+ }else{
 123+ var d = max - min;
 124+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
 125+ switch(max){
 126+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
 127+ case g: h = (b - r) / d + 2; break;
 128+ case b: h = (r - g) / d + 4; break;
133129 }
 130+ h /= 6;
 131+ }
134132
135 - return [h, s, l];
136 - },
137 - /**
138 - * http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
139 - * Converts an HSL color value to RGB. Conversion formula
140 - * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
141 - * Assumes h, s, and l are contained in the set [0, 1] and
142 - * returns r, g, and b in the set [0, 255].
143 - *
144 - * @param Number h The hue
145 - * @param Number s The saturation
146 - * @param Number l The lightness
147 - * @return Array The RGB representation
148 - */
149 - hslToRgb: function( h, s, l ) {
150 - var r, g, b;
 133+ return [h, s, l];
 134+ },
 135+ /**
 136+ * http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
 137+ * Converts an HSL color value to RGB. Conversion formula
 138+ * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
 139+ * Assumes h, s, and l are contained in the set [0, 1] and
 140+ * returns r, g, and b in the set [0, 255].
 141+ *
 142+ * @param Number h The hue
 143+ * @param Number s The saturation
 144+ * @param Number l The lightness
 145+ * @return Array The RGB representation
 146+ */
 147+ hslToRgb: function( h, s, l ) {
 148+ var r, g, b;
151149
152 - if(s === 0){
153 - r = g = b = l; // achromatic
154 - }else{
155 - var hue2rgb = function(p, q, t){
156 - if(t < 0){ t += 1; }
157 - if(t > 1){ t -= 1; }
158 - if(t < 1/6){ return p + (q - p) * 6 * t; }
159 - if(t < 1/2){ return q; }
160 - if(t < 2/3){ return p + (q - p) * (2/3 - t) * 6; }
161 - return p;
162 - };
 150+ if(s === 0){
 151+ r = g = b = l; // achromatic
 152+ }else{
 153+ var hue2rgb = function(p, q, t){
 154+ if(t < 0){ t += 1; }
 155+ if(t > 1){ t -= 1; }
 156+ if(t < 1/6){ return p + (q - p) * 6 * t; }
 157+ if(t < 1/2){ return q; }
 158+ if(t < 2/3){ return p + (q - p) * (2/3 - t) * 6; }
 159+ return p;
 160+ };
163161
164 - var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
165 - var p = 2 * l - q;
166 - r = hue2rgb(p, q, h + 1/3);
167 - g = hue2rgb(p, q, h);
168 - b = hue2rgb(p, q, h - 1/3);
169 - }
170 -
171 - return [r * 255, g * 255, b * 255];
172 - },
173 - /**
174 - * Get's a brighter or darker rgb() value string.
175 - *
176 - * @author Krinkle
177 - *
178 - * @example getCSSColorMod( 'red', +0.1 )
179 - * @example getCSSColorMod( 'rgb(200,50,50)', -0.2 )
180 - *
181 - * @param Mixed currentColor current value in css
182 - * @param Number mod wanted brightness modification between -1 and 1
183 - * @return String 'rgb(r,g,b)'
184 - */
185 - getColorBrightness: function( currentColor, mod ) {
186 - var rgbArr = $.colorUtil.getRGB( currentColor ),
187 - hslArr = $.colorUtil.rgbToHsl(rgbArr[0], rgbArr[1], rgbArr[2] );
188 - rgbArr = $.colorUtil.hslToRgb(hslArr[0], hslArr[1], hslArr[2]+mod);
189 - return 'rgb(' +
190 - [parseInt( rgbArr[0], 10), parseInt( rgbArr[1], 10 ), parseInt( rgbArr[2], 10 )].join( ',' ) +
191 - ')';
 162+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
 163+ var p = 2 * l - q;
 164+ r = hue2rgb(p, q, h + 1/3);
 165+ g = hue2rgb(p, q, h);
 166+ b = hue2rgb(p, q, h - 1/3);
192167 }
193168
194 - };
 169+ return [r * 255, g * 255, b * 255];
 170+ },
 171+ /**
 172+ * Get's a brighter or darker rgb() value string.
 173+ *
 174+ * @author Krinkle
 175+ *
 176+ * @example getCSSColorMod( 'red', +0.1 )
 177+ * @example getCSSColorMod( 'rgb(200,50,50)', -0.2 )
 178+ *
 179+ * @param Mixed currentColor current value in css
 180+ * @param Number mod wanted brightness modification between -1 and 1
 181+ * @return String 'rgb(r,g,b)'
 182+ */
 183+ getColorBrightness: function( currentColor, mod ) {
 184+ var rgbArr = $.colorUtil.getRGB( currentColor ),
 185+ hslArr = $.colorUtil.rgbToHsl(rgbArr[0], rgbArr[1], rgbArr[2] );
 186+ rgbArr = $.colorUtil.hslToRgb(hslArr[0], hslArr[1], hslArr[2]+mod);
 187+ return 'rgb(' +
 188+ [parseInt( rgbArr[0], 10), parseInt( rgbArr[1], 10 ), parseInt( rgbArr[2], 10 )].join( ',' ) +
 189+ ')';
 190+ }
195191
196 -} )( jQuery );
\ No newline at end of file
 192+};
\ No newline at end of file
Index: trunk/phase3/resources/jquery/jquery.color.js
@@ -1,43 +1,44 @@
2 -/*
 2+/**
33 * jQuery Color Animations
44 * Copyright 2007 John Resig
55 * Released under the MIT and GPL licenses.
66 *
7 - * - 2011-01-05: Modified by Krinkle to use the jQuery.colorUtil plugin (needs to be loaded first)
 7+ * - 2011-01-05: Modified by Krinkle to use the jQuery.colorUtil plugin (has to be loaded first)
88 */
 9+(function( $ ) {
910
10 -(function(jQuery){
11 -
1211 // We override the animation for all of these color styles
13 - jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
14 - jQuery.fx.step[attr] = function(fx){
15 - if ( fx.state == 0 ) {
16 - fx.start = getColor( fx.elem, attr );
17 - fx.end = $.colorUtil.getRGB( fx.end );
 12+ $.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'],
 13+ function( i, attr ) {
 14+ $.fx.step[attr] = function( fx ) {
 15+ if ( fx.state == 0 ) {
 16+ fx.start = getColor( fx.elem, attr );
 17+ fx.end = $.colorUtil.getRGB( fx.end );
 18+ }
 19+
 20+ fx.elem.style[attr] = 'rgb(' + [
 21+ Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
 22+ Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
 23+ Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
 24+ ].join( ',' ) + ')';
1825 }
19 -
20 - fx.elem.style[attr] = "rgb(" + [
21 - Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
22 - Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
23 - Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
24 - ].join(",") + ")";
2526 }
26 - });
 27+ );
2728
2829 function getColor(elem, attr) {
2930 var color;
3031
3132 do {
32 - color = jQuery.curCSS(elem, attr);
 33+ color = $.curCSS(elem, attr);
3334
3435 // Keep going until we find an element that has color, or we hit the body
35 - if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
 36+ if ( color != '' && color != 'transparent' || $.nodeName(elem, 'body') )
3637 break;
3738
38 - attr = "backgroundColor";
 39+ attr = 'backgroundColor';
3940 } while ( elem = elem.parentNode );
4041
4142 return $.colorUtil.getRGB(color);
4243 };
4344
44 -})(jQuery);
 45+} )( jQuery );
Index: trunk/phase3/resources/jquery/jquery.client.js
@@ -1,7 +1,7 @@
2 -/*
 2+/**
33 * User-agent detection
44 */
5 -jQuery.client = new ( function() {
 5+$.client = new ( function() {
66
77 /* Private Members */
88
@@ -166,8 +166,8 @@
167167 * @return Boolean true if browser known or assumed to be supported, false if blacklisted
168168 */
169169 this.test = function( map ) {
170 - var profile = jQuery.client.profile();
171 - var dir = jQuery( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr';
 170+ var profile = $.client.profile();
 171+ var dir = $( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr';
172172 // Check over each browser condition to determine if we are running in a compatible client
173173 if ( typeof map[dir] !== 'object' || map[dir][profile.name] !== 'object' ) {
174174 // Unknown, so we assume it's working
Index: trunk/phase3/resources/jquery/jquery.placeholder.js
@@ -9,7 +9,7 @@
1010 * @license GPL v2
1111 */
1212
13 -jQuery.fn.placeholder = function() {
 13+$.fn.placeholder = function() {
1414
1515 return this.each( function() {
1616
@@ -19,7 +19,7 @@
2020 }
2121
2222 var placeholder = this.getAttribute('placeholder');
23 - var $input = jQuery(this);
 23+ var $input = $(this);
2424
2525 // Show initially, if empty
2626 if ( this.value === '' || this.value == placeholder ) {
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.changeslist.css
@@ -4,18 +4,18 @@
55
66 table.mw-enhanced-rc {
77 background: none;
8 - border:0;
9 - border-spacing:0;
 8+ border: 0;
 9+ border-spacing: 0;
1010 }
1111
1212 table.mw-enhanced-rc th, table.mw-enhanced-rc td {
13 - padding:0;
14 - vertical-align:top;
 13+ padding: 0;
 14+ vertical-align: top;
1515 }
1616
1717 td.mw-enhanced-rc {
18 - white-space:nowrap;
19 - font-family:monospace;
 18+ white-space: nowrap;
 19+ font-family: monospace;
2020 }
2121
2222 .mw-enhanced-rc-time {
@@ -32,7 +32,7 @@
3333 }
3434
3535 /* If JS is disabled, the arrow is still needed
36 - for spacing, but ideally shouldn't be shown */
 36+ for spacing, but ideally shouldn't be shown */
3737 .mw-enhanced-rc .mw-rc-openarrow {
3838 visibility: hidden;
3939 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r81264Wrapping core modules (FIXME from r79929)...krinkle19:33, 31 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79246(bug 26507) Wrap all ResourceLoader-served JS in (function($, mw) { code here...catrope12:22, 30 December 2010

Comments

#Comment by Catrope (talk | contribs)   13:44, 10 January 2011

While r79246 claims to fix this problem, I've recently realized it doesn't work in debug mode. For this reason, we shouldn't be removing existing wraps.

r79246 is still useful, but not as much as I thought before. It 'fixes' missing wraps in non-debug mode, but they still break in debug mode, so missing wraps can still cause breakage.

#Comment by Mdaletest (talk | contribs)   18:54, 10 January 2011

Furthermore its best to keep the wraps to retain jQuery plugin re usability outside of the resource loader framework. ie if a given plugin can be useful without RL framework dependencies then its best if it can do so in a non-modified state. ( ie we would not want to go in and strip all the wrapping from all the jQuery plugins. )

Adding the wrapping at the framework level is not a complete protection against plugins / modules doing something stupid. i.e $j = jQuery.noConflict(); inside a wrapped scope where it loads some other framework library that uses $ .. then explosion for the rest of the modules that were grouped in that request wrap.

#Comment by Mdale (talk | contribs)   18:55, 10 January 2011

( sorry was logged in with my test account, was mdale who posted the above obviously )

#Comment by Krinkle (talk | contribs)   18:58, 10 January 2011

In that case, we ought to add the wrappers to any and all plugin files, right ?

#Comment by Nikerabbit (talk | contribs)   19:00, 10 January 2011

Can't we wrap them in debug mode too?

#Comment by Mdale (talk | contribs)   19:03, 10 January 2011

debug mode directly references the javascript files.

#Comment by Krinkle (talk | contribs)   19:05, 10 January 2011

That would change the line numbering.

ie. "TypeError in file.js on line 15". Which would be line 13 or 12 ? Right.

"its best to keep the wraps to retain jQuery plugin re usability outside of the resource loader framework. ie if a given plugin can be useful without RL framework dependencies then its best if it can do so in a non-modified state"

Sounds good.

#Comment by Nikerabbit (talk | contribs)   19:16, 10 January 2011

Can't it be done in one line that is prepended to the first line?

#Comment by Catrope (talk | contribs)   20:17, 10 January 2011

Line number preservation is not an issue. Debug mode referencing files directly and reuse are issues, and for those reasons we should indeed add wrappers to anything that needs them but doesn't have them.

#Comment by Krinkle (talk | contribs)   19:34, 31 January 2011

Re-added removed wrappings from this commit + added some more – in r81264. Marking fixme->new.

Status & tagging log