Merge "Make sure that SQLite uses no prefix"
[lhc/web/wiklou.git] / resources / jquery / jquery.badge.js
index 3a2a337..c8073d1 100644 (file)
         *   if the badge should overlay the parent element (default is inline)
         */
        $.fn.badge = function ( text, inline ) {
-               var div, $badge = this.find( '.mw-badge' );
+               var $badge = this.find( '.mw-badge' );
 
                if ( text ) {
                        // If a badge already exists, reuse it
                        if ( $badge.length ) {
                                $badge.find( '.mw-badge-content' ).text( text );
+                       } else {
+                               // Otherwise, create a new badge with the specified text and style
+                               $badge = $( '<div class="mw-badge mw-badge-' + ( inline ? 'inline' : 'overlay' ) + '"></div>' )
+                                       .append( $( '<span class="mw-badge-content"></span>' ).text ( text ) )
+                                       .appendTo( this );
                        }
-                       // Otherwise, create a new badge with the specified text and style
-                       div = document.createElement( 'div' );
-                       div.className = 'mw-badge mw-badge-' + ( inline ? 'inline' : 'overlay' );
-                       div.innerHTML = '<span class="mw-badge-content">' + text + '</span>';
                } else {
                        $badge.remove();
                }