1. tehshin
  2. jquery-notifyme

Commits

tehshin  committed 93fdb19

option to set title and body of a message. changed some effects

  • Participants
  • Parent commits b211e39
  • Branches default

Comments (0)

Files changed (4)

File sample/sample.html

View file
  • Ignore whitespace
     <a id="showinfo" href="#">Add Info</a><br />
     <a id="showwarning" href="#">Add Warning</a><br />
     <a id="showerror" href="#">Add Error</a><br />
+    <a id="showwithtitle" href="#">Add Info with title</a><br />
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
     <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
     <script src="../src/jquery.notifyme.js"></script>

File sample/scripts/sample.js

View file
  • Ignore whitespace
 $(function () {
     
-    $.notifyme({ windowTitle: 'GIFT Message Center' });
+    $.notifyme({ windowTitle: 'Message Center' });
     
     $('#showwindow').click(function () {
         $.notifyme('show');
             'This is a error message. '  + getCurrentTime());
         return false;
     });
+    $('#showwithtitle').click(function () {
+        $.notifyme('addInfo', { 
+            title: "This is my custom title", 
+            body: "This is the message. " + getCurrentTime() 
+        });
+    });
 });
 
 function getCurrentTime() {

File src/jquery.notifyme.css

View file
  • Ignore whitespace
     background: #000;
     padding-left: 4px;
     cursor: move;
+    text-align: center;
     border-bottom: 1px solid #444;
     border-top-left-radius: 4px;
     border-top-right-radius: 4px;
     line-height: 16px;
     padding-left: 1px;
     text-align: center;
-    right: 5px;
+    left: 5px;
     top: 2px;
     background: #666;
     border: 1px solid #000;

File src/jquery.notifyme.js

View file
  • Ignore whitespace
     function showNotificationWindow() {
         if(!isNotificationWindowActive()) {
             $('body').append(createNotificationWindow());
-            $('#' + config.id).fadeIn('fast');
+            $('#' + config.id).slideToggle('fast');
         }
     }
     
     function closeNotificationWindow() {
-        $('#' + config.id).fadeOut('fast', function () {
+        $('#' + config.id).slideToggle('fast', function () {
             $('#' + config.id).remove();
         });
     }
         var className = type + 'Class';
         var $message = $('<div/>', { style: 'display:none;' })
             .addClass('message').addClass(config[className]);
-            
-        var $head = $('<div/>').addClass('head').text(type)
+        
+        var title = type;
+        var body = "";
+        if(typeof message === 'object') {
+            title = message.title;
+            body = message.body;
+        } else {
+            body = message;
+        }
+        
+        var $head = $('<div/>').addClass('head').text(title)
             .click(function () {
-                $(this).parent().slideUp('fast', function () {
+                $(this).parent().fadeToggle('fast', function () {
                     $(this).remove(); 
                     if(!hasMessages()) {
                         closeNotificationWindow();
                 });
             });
         
-        var $body = $('<div/>').addClass('body').text(message);
+        var $body = $('<div/>').addClass('body').text(body);
             
         return $message.append($head).append($body);
     }
         showNotificationWindow();
         var $message = createMessage(type, message);
         $('#' + config.id + ' .content').prepend($message);
-        $message.slideDown('fast');
+        $message.fadeToggle();
     }
 })(jQuery);