Commits

tehshin committed 10b66e1

refactored html element creations, replaced x with ×

Comments (0)

Files changed (1)

src/jquery.notifyme.js

   * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
   *
   * Written by Patrick Pichler <thepikse@gmail.com>
-  * Last updated: 2011-06-22
+  * Last updated: 2011-08-19
   */
  
 (function($) {
     
     function createNotificationWindow() {
         var $windowDiv = $('<div/>', { 
-            id: config.id,
-            style: 'display:none;position:absolute;'
-        }).addClass(config.className)
-        .draggable({
+            'id': config.id,
+            'style': 'display:none;position:absolute;',
+            'class': config.className
+        }).draggable({
             handle: '.title',
             containment: 'window',
             cancel: 'a'
         });
         
-        var $titleDiv = $('<div/>')
-            .addClass('title').text(config.windowTitle);
+        var $titleDiv = $('<div/>', {
+            'class': 'title',
+            'text': config.windowTitle
+        });
         
-        var $closeWindow = $('<a/>', { href: '#' })
-            .text('x')
-            .addClass('close-notification-window')
-            .click(function () {
+        $('<a/>', { 
+            'href': '#', 
+            'html': '&times;',
+            'class': 'close-notification-window',
+            'click': function () {
                 closeNotificationWindow();
                 return false;
-            });
+            }
+        }).appendTo($titleDiv);
         
-        $titleDiv.append($closeWindow);
-        
-        var $contentDiv = $('<div/>')
-            .addClass('content');
-        
+        var $contentDiv = $('<div/>', { 'class': 'content' });
+            
         return $windowDiv.append($titleDiv).append($contentDiv);
     }
     
     
     function createMessage(type, message) {
         var className = type + 'Class';
-        var $message = $('<div/>', { style: 'display:none;' })
-            .addClass('message').addClass(config[className]);
+        var $message = $('<div/>', { 
+            'style': 'display:none',
+            'class': 'message ' + config[className]
+        });
         
-        var title = "";
-        var body = "";
+        var title = "", body = "";
         if(typeof message === 'object') {
             title = message.title;
             body = message.body;
             body = message;
         }
         
-        if(title !== "") {
-            var $head = $('<div/>').addClass('head').text(title);
-            $message.append($head);
+        if(title) {
+            $('<div/>', { 'class': 'head', 'text': title }).appendTo($message);
         }
         
-        var $body = $('<div/>').addClass('body').text(body);
+        var $body = $('<div/>', { 'class': 'body', 'text': body });
             
         var $closer = $('<a/>', { 
             'href': '#', 
             'title': 'close message',
-            'class': 'closer' 
-        }).text('x').click(function () {
-            $(this).parent().fadeToggle('fast', function () {
-                $(this).remove(); 
-                if(!hasMessages() && !config.preserve) {
-                    closeNotificationWindow();
-                }
-            });
+            'class': 'closer',
+            'html': '&times;',
+            'click': function () {
+                $(this).parent().fadeToggle('fast', function () {
+                    $(this).remove(); 
+                    if(!hasMessages() && !config.preserve) {
+                        closeNotificationWindow();
+                    }
+                });
+            }
         });
         
         return $message.append($body).append($closer);