Renaming new jQuery.jsMessage plugin to jQuery.mesageBox(). Name was too generic...
authorKrinkle <krinkle@users.mediawiki.org>
Tue, 8 Feb 2011 00:20:41 +0000 (00:20 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Tue, 8 Feb 2011 00:20:41 +0000 (00:20 +0000)
. Next commit will deal with the contents of the messageBox .js/css files

resources/Resources.php
resources/jquery/jquery.jsMessage.css [deleted file]
resources/jquery/jquery.jsMessage.js [deleted file]
resources/jquery/jquery.messageBox.css [new file with mode: 0644]
resources/jquery/jquery.messageBox.js [new file with mode: 0644]
resources/mediawiki.util/mediawiki.util.js

index b913c5c..7531833 100644 (file)
@@ -89,9 +89,9 @@ return array(
        'jquery.hoverIntent' => array(
                'scripts' => 'resources/jquery/jquery.hoverIntent.js',
        ),
-       'jquery.jsMessage' => array(
-               'scripts' => 'resources/jquery/jquery.jsMessage.js',
-               'styles' => 'resources/jquery/jquery.jsMessage.css',
+       'jquery.messageBox' => array(
+               'scripts' => 'resources/jquery/jquery.messageBox.js',
+               'styles' => 'resources/jquery/jquery.messageBox.css',
        ),
        'jquery.placeholder' => array(
                'scripts' => 'resources/jquery/jquery.placeholder.js',
@@ -371,7 +371,7 @@ return array(
                        'jquery.checkboxShiftClick',
                        'jquery.client',
                        'jquery.cookie',
-                       'jquery.jsMessage',
+                       'jquery.messageBox',
                        'jquery.makeCollapsible',
                        'jquery.placeholder',
                ),
diff --git a/resources/jquery/jquery.jsMessage.css b/resources/jquery/jquery.jsMessage.css
deleted file mode 100644 (file)
index 58e794a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-.js-message-box {
-       margin: 1em 5%;
-       padding: 0.5em 2.5%;
-       border: 1px solid #ccc;
-       background-color: #fcfcfc;
-       font-size: 0.8em;
-}
-.js-message-box .js-message-group {
-       margin: 1px;
-       padding: 0.5em 2.5%;
-       border-bottom: 1px solid #ddd;
-}
-.js-message-box .js-message-group:last-child {
-       border-bottom: thin none transparent;
-}
\ No newline at end of file
diff --git a/resources/jquery/jquery.jsMessage.js b/resources/jquery/jquery.jsMessage.js
deleted file mode 100644 (file)
index db64f1a..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * jQuery jsMessage
- *
- * Function to inform the user of something. Use sparingly (since there's mw.log for
- * messages aimed at developers / debuggers). Based on the function in MediaWiki's
- * legacy javascript (wikibits.js) by Aryeh Gregor called jsMsg() added in r23233.
- *
- * @author Krinkle <krinklemail@gmail.com>
- *
- * Dual license:
- * @license CC-BY 3.0 <http://creativecommons.org/licenses/by/3.0>
- * @license GPL2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
- */
-( function( $, mw ) {
-// @return jQuery object of the message box
-$.jsMessageNew = function( options ) {
-       options = $.extend( {
-               'id': 'js-message', // unique identifier for this message box
-               'parent': 'body', // jQuery/CSS selector
-               'insert': 'prepend' // 'prepend' or 'append'
-       }, options );
-       var $curBox = $( '#'+ options.id );
-       // Only create a new box if it doesn't exist already
-       if ( $curBox.size() > 0 ) {
-               if ( $curBox.hasClass( 'js-message-box' ) ) {
-                       return $curBox;
-               } else {
-                       return $curBox.addClass( 'js-message-box' );
-               }
-       } else {
-               var $newBox = $( '<div/>', {
-                       'id': options.id,
-                       'class': 'js-message-box',
-                       'css': {
-                               'display': 'none'
-                       }
-               });
-               if ( options.insert === 'append' ) {
-                       $newBox.appendTo( options.parent );
-                       return $newBox;
-               } else {
-                       $newBox.prependTo( options.parent );
-                       return $newBox;
-               }
-       }
-};
-// Calling with no message or message set to empty string or null will hide the group,
-// setting 'replace' to true as well will reset and hide the group entirely.
-// If there are no visible groups the main message box is hidden automatically,
-// and shown again once there are messages
-// @return jQuery object of message group
-$.jsMessage = function( options ) {
-       options = $.extend( {
-               'message': '',
-               'group': 'default',
-               'replace': false, // if true replaces any previous message in this group
-               'target': 'js-message'
-       }, options );     
-       var $target = $.jsMessageNew( { id: options.target } );
-       var groupID = options.target + '-' + options.group;
-       var $group = $( '#' + groupID );
-       // Create group container if not existant
-       if ( $group.size() < 1 ) {
-               $group = $( '<div/>', {
-                       'id': groupID,
-                       'class': 'js-message-group'
-               });
-               $target.prepend( $group );
-       }
-       // Replace ?
-       if ( options.replace === true ) {
-               $group.empty();
-       }
-       // Hide it ?
-       if ( options.message === '' || options.message === null ) {
-               $group.hide();
-       } else {
-               // Actual message addition
-               $group.prepend( $( '<p/>' ).append( options.message ) ).show();
-               $target.slideDown()
-       }
-       // If the last visible group was just hidden, slide the entire box up
-       // Othere wise slideDown (if already visible nothing will happen)
-       if ( $target.find( '> *:visible' ).size() === 0 ) {
-               // to avoid a sudden dissapearance of the last group followed by
-               // a slide up of only the outline, show it for a second
-               $group.show();
-               $target.slideUp();
-               $group.hide();
-       } else {
-               $target.slideDown();
-       }
-       return $group;
-};
-} )( jQuery, mediaWiki );
\ No newline at end of file
diff --git a/resources/jquery/jquery.messageBox.css b/resources/jquery/jquery.messageBox.css
new file mode 100644 (file)
index 0000000..58e794a
--- /dev/null
@@ -0,0 +1,15 @@
+.js-message-box {
+       margin: 1em 5%;
+       padding: 0.5em 2.5%;
+       border: 1px solid #ccc;
+       background-color: #fcfcfc;
+       font-size: 0.8em;
+}
+.js-message-box .js-message-group {
+       margin: 1px;
+       padding: 0.5em 2.5%;
+       border-bottom: 1px solid #ddd;
+}
+.js-message-box .js-message-group:last-child {
+       border-bottom: thin none transparent;
+}
\ No newline at end of file
diff --git a/resources/jquery/jquery.messageBox.js b/resources/jquery/jquery.messageBox.js
new file mode 100644 (file)
index 0000000..db64f1a
--- /dev/null
@@ -0,0 +1,95 @@
+/**
+ * jQuery jsMessage
+ *
+ * Function to inform the user of something. Use sparingly (since there's mw.log for
+ * messages aimed at developers / debuggers). Based on the function in MediaWiki's
+ * legacy javascript (wikibits.js) by Aryeh Gregor called jsMsg() added in r23233.
+ *
+ * @author Krinkle <krinklemail@gmail.com>
+ *
+ * Dual license:
+ * @license CC-BY 3.0 <http://creativecommons.org/licenses/by/3.0>
+ * @license GPL2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
+ */
+( function( $, mw ) {
+// @return jQuery object of the message box
+$.jsMessageNew = function( options ) {
+       options = $.extend( {
+               'id': 'js-message', // unique identifier for this message box
+               'parent': 'body', // jQuery/CSS selector
+               'insert': 'prepend' // 'prepend' or 'append'
+       }, options );
+       var $curBox = $( '#'+ options.id );
+       // Only create a new box if it doesn't exist already
+       if ( $curBox.size() > 0 ) {
+               if ( $curBox.hasClass( 'js-message-box' ) ) {
+                       return $curBox;
+               } else {
+                       return $curBox.addClass( 'js-message-box' );
+               }
+       } else {
+               var $newBox = $( '<div/>', {
+                       'id': options.id,
+                       'class': 'js-message-box',
+                       'css': {
+                               'display': 'none'
+                       }
+               });
+               if ( options.insert === 'append' ) {
+                       $newBox.appendTo( options.parent );
+                       return $newBox;
+               } else {
+                       $newBox.prependTo( options.parent );
+                       return $newBox;
+               }
+       }
+};
+// Calling with no message or message set to empty string or null will hide the group,
+// setting 'replace' to true as well will reset and hide the group entirely.
+// If there are no visible groups the main message box is hidden automatically,
+// and shown again once there are messages
+// @return jQuery object of message group
+$.jsMessage = function( options ) {
+       options = $.extend( {
+               'message': '',
+               'group': 'default',
+               'replace': false, // if true replaces any previous message in this group
+               'target': 'js-message'
+       }, options );     
+       var $target = $.jsMessageNew( { id: options.target } );
+       var groupID = options.target + '-' + options.group;
+       var $group = $( '#' + groupID );
+       // Create group container if not existant
+       if ( $group.size() < 1 ) {
+               $group = $( '<div/>', {
+                       'id': groupID,
+                       'class': 'js-message-group'
+               });
+               $target.prepend( $group );
+       }
+       // Replace ?
+       if ( options.replace === true ) {
+               $group.empty();
+       }
+       // Hide it ?
+       if ( options.message === '' || options.message === null ) {
+               $group.hide();
+       } else {
+               // Actual message addition
+               $group.prepend( $( '<p/>' ).append( options.message ) ).show();
+               $target.slideDown()
+       }
+       // If the last visible group was just hidden, slide the entire box up
+       // Othere wise slideDown (if already visible nothing will happen)
+       if ( $target.find( '> *:visible' ).size() === 0 ) {
+               // to avoid a sudden dissapearance of the last group followed by
+               // a slide up of only the outline, show it for a second
+               $group.show();
+               $target.slideUp();
+               $group.hide();
+       } else {
+               $target.slideDown();
+       }
+       return $group;
+};
+} )( jQuery, mediaWiki );
\ No newline at end of file
index 8473f0b..ad9c299 100644 (file)
@@ -14,8 +14,8 @@
                                // Any initialisation after the DOM is ready
                                $( function() {
 
-                                       /* Set up $.jsMessage */
-                                       $.jsMessageNew( {
+                                       /* Set up $.messageBox */
+                                       $.messageBoxNew( {
                                                'id': 'mw-js-message',
                                                'parent': '#content'
                                        } );