r81660 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81659‎ | r81660 | r81661 >
Date:00:20, 8 February 2011
Author:krinkle
Status:ok
Tags:
Comment:
Renaming new jQuery.jsMessage plugin to jQuery.mesageBox(). Name was too generic and could be confusing with localization messages.
. Next commit will deal with the contents of the messageBox .js/css files
Modified paths:
  • /trunk/phase3/resources/Resources.php (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.jsMessage.css (deleted) (history)
  • /trunk/phase3/resources/jquery/jquery.jsMessage.js (deleted) (history)
  • /trunk/phase3/resources/jquery/jquery.messageBox.css (added) (history)
  • /trunk/phase3/resources/jquery/jquery.messageBox.js (added) (history)
  • /trunk/phase3/resources/mediawiki.util/mediawiki.util.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.jsMessage.css
@@ -1,15 +0,0 @@
2 -.js-message-box {
3 - margin: 1em 5%;
4 - padding: 0.5em 2.5%;
5 - border: 1px solid #ccc;
6 - background-color: #fcfcfc;
7 - font-size: 0.8em;
8 -}
9 -.js-message-box .js-message-group {
10 - margin: 1px;
11 - padding: 0.5em 2.5%;
12 - border-bottom: 1px solid #ddd;
13 -}
14 -.js-message-box .js-message-group:last-child {
15 - border-bottom: thin none transparent;
16 -}
\ No newline at end of file
Index: trunk/phase3/resources/jquery/jquery.jsMessage.js
@@ -1,95 +0,0 @@
2 -/**
3 - * jQuery jsMessage
4 - *
5 - * Function to inform the user of something. Use sparingly (since there's mw.log for
6 - * messages aimed at developers / debuggers). Based on the function in MediaWiki's
7 - * legacy javascript (wikibits.js) by Aryeh Gregor called jsMsg() added in r23233.
8 - *
9 - * @author Krinkle <krinklemail@gmail.com>
10 - *
11 - * Dual license:
12 - * @license CC-BY 3.0 <http://creativecommons.org/licenses/by/3.0>
13 - * @license GPL2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
14 - */
15 -( function( $, mw ) {
16 -// @return jQuery object of the message box
17 -$.jsMessageNew = function( options ) {
18 - options = $.extend( {
19 - 'id': 'js-message', // unique identifier for this message box
20 - 'parent': 'body', // jQuery/CSS selector
21 - 'insert': 'prepend' // 'prepend' or 'append'
22 - }, options );
23 - var $curBox = $( '#'+ options.id );
24 - // Only create a new box if it doesn't exist already
25 - if ( $curBox.size() > 0 ) {
26 - if ( $curBox.hasClass( 'js-message-box' ) ) {
27 - return $curBox;
28 - } else {
29 - return $curBox.addClass( 'js-message-box' );
30 - }
31 - } else {
32 - var $newBox = $( '<div/>', {
33 - 'id': options.id,
34 - 'class': 'js-message-box',
35 - 'css': {
36 - 'display': 'none'
37 - }
38 - });
39 - if ( options.insert === 'append' ) {
40 - $newBox.appendTo( options.parent );
41 - return $newBox;
42 - } else {
43 - $newBox.prependTo( options.parent );
44 - return $newBox;
45 - }
46 - }
47 -};
48 -// Calling with no message or message set to empty string or null will hide the group,
49 -// setting 'replace' to true as well will reset and hide the group entirely.
50 -// If there are no visible groups the main message box is hidden automatically,
51 -// and shown again once there are messages
52 -// @return jQuery object of message group
53 -$.jsMessage = function( options ) {
54 - options = $.extend( {
55 - 'message': '',
56 - 'group': 'default',
57 - 'replace': false, // if true replaces any previous message in this group
58 - 'target': 'js-message'
59 - }, options );
60 - var $target = $.jsMessageNew( { id: options.target } );
61 - var groupID = options.target + '-' + options.group;
62 - var $group = $( '#' + groupID );
63 - // Create group container if not existant
64 - if ( $group.size() < 1 ) {
65 - $group = $( '<div/>', {
66 - 'id': groupID,
67 - 'class': 'js-message-group'
68 - });
69 - $target.prepend( $group );
70 - }
71 - // Replace ?
72 - if ( options.replace === true ) {
73 - $group.empty();
74 - }
75 - // Hide it ?
76 - if ( options.message === '' || options.message === null ) {
77 - $group.hide();
78 - } else {
79 - // Actual message addition
80 - $group.prepend( $( '<p/>' ).append( options.message ) ).show();
81 - $target.slideDown()
82 - }
83 - // If the last visible group was just hidden, slide the entire box up
84 - // Othere wise slideDown (if already visible nothing will happen)
85 - if ( $target.find( '> *:visible' ).size() === 0 ) {
86 - // to avoid a sudden dissapearance of the last group followed by
87 - // a slide up of only the outline, show it for a second
88 - $group.show();
89 - $target.slideUp();
90 - $group.hide();
91 - } else {
92 - $target.slideDown();
93 - }
94 - return $group;
95 -};
96 -} )( jQuery, mediaWiki );
\ No newline at end of file
Index: trunk/phase3/resources/jquery/jquery.messageBox.js
@@ -0,0 +1,95 @@
 2+/**
 3+ * jQuery jsMessage
 4+ *
 5+ * Function to inform the user of something. Use sparingly (since there's mw.log for
 6+ * messages aimed at developers / debuggers). Based on the function in MediaWiki's
 7+ * legacy javascript (wikibits.js) by Aryeh Gregor called jsMsg() added in r23233.
 8+ *
 9+ * @author Krinkle <krinklemail@gmail.com>
 10+ *
 11+ * Dual license:
 12+ * @license CC-BY 3.0 <http://creativecommons.org/licenses/by/3.0>
 13+ * @license GPL2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
 14+ */
 15+( function( $, mw ) {
 16+// @return jQuery object of the message box
 17+$.jsMessageNew = function( options ) {
 18+ options = $.extend( {
 19+ 'id': 'js-message', // unique identifier for this message box
 20+ 'parent': 'body', // jQuery/CSS selector
 21+ 'insert': 'prepend' // 'prepend' or 'append'
 22+ }, options );
 23+ var $curBox = $( '#'+ options.id );
 24+ // Only create a new box if it doesn't exist already
 25+ if ( $curBox.size() > 0 ) {
 26+ if ( $curBox.hasClass( 'js-message-box' ) ) {
 27+ return $curBox;
 28+ } else {
 29+ return $curBox.addClass( 'js-message-box' );
 30+ }
 31+ } else {
 32+ var $newBox = $( '<div/>', {
 33+ 'id': options.id,
 34+ 'class': 'js-message-box',
 35+ 'css': {
 36+ 'display': 'none'
 37+ }
 38+ });
 39+ if ( options.insert === 'append' ) {
 40+ $newBox.appendTo( options.parent );
 41+ return $newBox;
 42+ } else {
 43+ $newBox.prependTo( options.parent );
 44+ return $newBox;
 45+ }
 46+ }
 47+};
 48+// Calling with no message or message set to empty string or null will hide the group,
 49+// setting 'replace' to true as well will reset and hide the group entirely.
 50+// If there are no visible groups the main message box is hidden automatically,
 51+// and shown again once there are messages
 52+// @return jQuery object of message group
 53+$.jsMessage = function( options ) {
 54+ options = $.extend( {
 55+ 'message': '',
 56+ 'group': 'default',
 57+ 'replace': false, // if true replaces any previous message in this group
 58+ 'target': 'js-message'
 59+ }, options );
 60+ var $target = $.jsMessageNew( { id: options.target } );
 61+ var groupID = options.target + '-' + options.group;
 62+ var $group = $( '#' + groupID );
 63+ // Create group container if not existant
 64+ if ( $group.size() < 1 ) {
 65+ $group = $( '<div/>', {
 66+ 'id': groupID,
 67+ 'class': 'js-message-group'
 68+ });
 69+ $target.prepend( $group );
 70+ }
 71+ // Replace ?
 72+ if ( options.replace === true ) {
 73+ $group.empty();
 74+ }
 75+ // Hide it ?
 76+ if ( options.message === '' || options.message === null ) {
 77+ $group.hide();
 78+ } else {
 79+ // Actual message addition
 80+ $group.prepend( $( '<p/>' ).append( options.message ) ).show();
 81+ $target.slideDown()
 82+ }
 83+ // If the last visible group was just hidden, slide the entire box up
 84+ // Othere wise slideDown (if already visible nothing will happen)
 85+ if ( $target.find( '> *:visible' ).size() === 0 ) {
 86+ // to avoid a sudden dissapearance of the last group followed by
 87+ // a slide up of only the outline, show it for a second
 88+ $group.show();
 89+ $target.slideUp();
 90+ $group.hide();
 91+ } else {
 92+ $target.slideDown();
 93+ }
 94+ return $group;
 95+};
 96+} )( jQuery, mediaWiki );
\ No newline at end of file
Property changes on: trunk/phase3/resources/jquery/jquery.messageBox.js
___________________________________________________________________
Added: svn:eol-style
197 + native
Index: trunk/phase3/resources/jquery/jquery.messageBox.css
@@ -0,0 +1,15 @@
 2+.js-message-box {
 3+ margin: 1em 5%;
 4+ padding: 0.5em 2.5%;
 5+ border: 1px solid #ccc;
 6+ background-color: #fcfcfc;
 7+ font-size: 0.8em;
 8+}
 9+.js-message-box .js-message-group {
 10+ margin: 1px;
 11+ padding: 0.5em 2.5%;
 12+ border-bottom: 1px solid #ddd;
 13+}
 14+.js-message-box .js-message-group:last-child {
 15+ border-bottom: thin none transparent;
 16+}
\ No newline at end of file
Property changes on: trunk/phase3/resources/jquery/jquery.messageBox.css
___________________________________________________________________
Added: svn:eol-style
117 + native
Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.js
@@ -14,8 +14,8 @@
1515 // Any initialisation after the DOM is ready
1616 $( function() {
1717
18 - /* Set up $.jsMessage */
19 - $.jsMessageNew( {
 18+ /* Set up $.messageBox */
 19+ $.messageBoxNew( {
2020 'id': 'mw-js-message',
2121 'parent': '#content'
2222 } );
Index: trunk/phase3/resources/Resources.php
@@ -89,9 +89,9 @@
9090 'jquery.hoverIntent' => array(
9191 'scripts' => 'resources/jquery/jquery.hoverIntent.js',
9292 ),
93 - 'jquery.jsMessage' => array(
94 - 'scripts' => 'resources/jquery/jquery.jsMessage.js',
95 - 'styles' => 'resources/jquery/jquery.jsMessage.css',
 93+ 'jquery.messageBox' => array(
 94+ 'scripts' => 'resources/jquery/jquery.messageBox.js',
 95+ 'styles' => 'resources/jquery/jquery.messageBox.css',
9696 ),
9797 'jquery.placeholder' => array(
9898 'scripts' => 'resources/jquery/jquery.placeholder.js',
@@ -371,7 +371,7 @@
372372 'jquery.checkboxShiftClick',
373373 'jquery.client',
374374 'jquery.cookie',
375 - 'jquery.jsMessage',
 375+ 'jquery.messageBox',
376376 'jquery.makeCollapsible',
377377 'jquery.placeholder',
378378 ),

Follow-up revisions

RevisionCommit summaryAuthorDate
r81662Follow-up r81660....krinkle00:22, 8 February 2011

Status & tagging log