Want more features on Pastebin? Sign Up, it's FREE!
Guest

George Mauer

By: a guest on Nov 16th, 2009  |  syntax: JavaScript  |  size: 1.29 KB  |  views: 232  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         // Closure in charge of taking a set of notifications and displaying them in an area defined by a jquery element.
  2.         // Usage: NotificationDisplay($('#someArea')).populateWith(notificationArray)
  3.         function NotificationsDisplay(area) {
  4.             // private vars
  5.             var displayArea = area
  6.             var templateElem = $('#notificationTemplate');
  7.             // private methods
  8.             function createNotificationDisplay(notification, copyFunc) {
  9.                 var container = templateElem.clone().attr('id', 'notif_' + notification.Id).css('display', 'block')
  10.                 TextNotificationMapper(container).mapToElement(notification)
  11.                 container.find('[name=copy]').click(function() { copyFunc(notification) })
  12.                 return container;
  13.             }
  14.            
  15.             // Closure constructor
  16.             var f = function() { }
  17.             // Public methods
  18.             f.populateWith = function(notifications) {
  19.                 displayArea.empty()
  20.                 for (var i in notifications) {
  21.                     var elem = createNotificationDisplay(notifications[i], CopyManager($('#copyOrderArea')).setTemplate);
  22.                     displayArea.append(elem)
  23.                 }
  24.             }
  25.             return f;
  26.         }
clone this paste RAW Paste Data