1AUI.add( 2 'liferay-plugin-dockbar-notifications', 3 function(A) { 4 var DockbarNotifications = A.Component.create( 5 { 6 AUGMENTS: [Liferay.PortletBase], 7 8 EXTENDS: A.Base, 9 10 NAME: 'dockbarnotifications', 11 12 prototype: { 13 initializer: function(config) { 14 var instance = this; 15 16 instance._actionableNotificationsList = config.actionableNotificationsList; 17 instance._baseActionURL = config.baseActionURL; 18 instance._baseResourceURL = config.baseResourceURL; 19 instance._nonActionableNotificationsList = config.nonActionableNotificationsList; 20 instance._portletKey = config.portletKey; 21 22 var userNotifications = A.one('.dockbar-user-notifications'); 23 24 userNotifications.on( 25 'click', 26 function(event) { 27 var target = event.target; 28 29 if (target.ancestor('.dockbar-user-notifications-container')) { 30 return; 31 } 32 33 instance._setDelivered(); 34 35 var currentTarget = event.currentTarget; 36 37 var container = currentTarget.one('.dockbar-user-notifications-container'); 38 39 container.toggleClass('open'); 40 41 var menuOpen = container.hasClass('open'); 42 43 if (menuOpen) { 44 currentTarget.on( 45 'clickoutside', 46 function(event) { 47 container.removeClass('open'); 48 } 49 ); 50 51 instance._nonActionableNotificationsList.render(); 52 instance._actionableNotificationsList.render(); 53 } 54 } 55 ); 56 57 A.on( 58 'domready', 59 function() { 60 Liferay.Poller.addListener(instance._portletKey, instance._onPollerUpdate, instance); 61 } 62 ); 63 64 Liferay.on('updateNotificationsCount', instance._getNotificationsCount, instance); 65 }, 66 67 _getNotificationsCount: function() { 68 var instance = this; 69 70 var portletURL = new Liferay.PortletURL.createURL(instance._baseResourceURL); 71 72 portletURL.setResourceId('getNotificationsCount'); 73 74 A.io.request( 75 portletURL.toString(), 76 { 77 dataType: 'JSON', 78 on: { 79 success: function() { 80 var response = this.get('responseData'); 81 82 if (response) { 83 var newUserNotificationsCount = response.newUserNotificationsCount; 84 var timestamp = response.timestamp; 85 var unreadUserNotificationsCount = response.unreadUserNotificationsCount; 86 87 instance._updateDockbarNotificationsCount(newUserNotificationsCount, timestamp, unreadUserNotificationsCount); 88 } 89 } 90 } 91 } 92 ); 93 }, 94 95 _onPollerUpdate: function(response) { 96 var instance = this; 97 98 instance._updateDockbarNotificationsCount(response.newUserNotificationsCount, response.timestamp, response.unreadUserNotificationsCount); 99 }, 100 101 _setDelivered: function() { 102 var instance = this; 103 104 var portletURL = new Liferay.PortletURL.createURL(instance._baseActionURL); 105 106 portletURL.setParameter('javax.portlet.action', 'setDelivered'); 107 108 portletURL.setWindowState('normal'); 109 110 A.io.request(portletURL.toString()); 111 }, 112 113 _updateDockbarNotificationsCount: function(newUserNotificationsCount, timestamp, unreadUserNotificationsCount) { 114 var instance = this; 115 116 if (!instance._previousTimestamp || (instance._previousTimestamp < timestamp)) { 117 instance._previousTimestamp = timestamp; 118 119 var dockbarUserNotificationsCount = A.one('.dockbar-user-notifications .user-notifications-count'); 120 121 if (dockbarUserNotificationsCount) { 122 dockbarUserNotificationsCount.toggleClass('alert', (newUserNotificationsCount > 0)); 123 124 dockbarUserNotificationsCount.setHTML(unreadUserNotificationsCount); 125 } 126 } 127 } 128 } 129 } 130 ); 131 132 Liferay.DockbarNotifications = DockbarNotifications; 133 }, 134 '', 135 { 136 requires: ['aui-base', 'aui-io', 'liferay-poller', 'liferay-portlet-base', 'liferay-portlet-url'] 137 } 138 139); 140 141AUI.add( 142 'liferay-plugin-notifications', 143 function(A) { 144 var Notifications = A.Component.create( 145 { 146 AUGMENTS: [Liferay.PortletBase], 147 148 EXTENDS: A.Base, 149 150 NAME: 'notifications', 151 152 prototype: { 153 initializer: function(config) { 154 var instance = this; 155 156 instance._actionableUserNotificationsStart = 0; 157 instance._baseRenderURL = config.baseRenderURL; 158 instance._nonActionableUserNotificationsStart = 0; 159 instance._notificationsList = config.notificationsList; 160 161 instance._notificationsList.render(); 162 163 var notificationsConfigurationNode = A.one('.notifications-portlet .user-notifications-container .notifications-configurations'); 164 var userNotificationsListNode = A.one('.notifications-portlet .user-notifications-container .user-notifications-list'); 165 var userNotificationsContainerNode = A.one('.notifications-portlet .user-notifications-container'); 166 167 var nonActionableUserNotificationsLink = A.one('.notifications-portlet .user-notifications-container .user-notifications-sidebar .nav .non-actionable'); 168 169 if (nonActionableUserNotificationsLink) { 170 nonActionableUserNotificationsLink.on( 171 'click', 172 function() { 173 var userNotificationsSidebar = A.one('.user-notifications-sidebar'); 174 175 if (userNotificationsSidebar) { 176 userNotificationsSidebar.all('.nav a').removeClass('selected'); 177 } 178 179 nonActionableUserNotificationsLink.addClass('selected'); 180 181 if (userNotificationsContainerNode) { 182 userNotificationsContainerNode.addClass('non-actionable'); 183 userNotificationsContainerNode.removeClass('actionable'); 184 } 185 186 notificationsConfigurationNode.hide(); 187 userNotificationsListNode.show(); 188 189 instance._notificationsList.setActionable(false); 190 191 instance._notificationsList.setNotificationsCount('.non-actionable .count'); 192 193 instance._actionableUserNotificationsStart = instance._notificationsList.getStart(); 194 195 instance._notificationsList.setStart(instance._nonActionableUserNotificationsStart); 196 197 instance._notificationsList.render(); 198 } 199 ); 200 } 201 202 var actionableUserNotificationsLink = A.one('.notifications-portlet .user-notifications-container .user-notifications-sidebar .nav .actionable'); 203 204 if (actionableUserNotificationsLink) { 205 actionableUserNotificationsLink.on( 206 'click', 207 function() { 208 var userNotificationsSidebar = A.one('.user-notifications-sidebar'); 209 210 if (userNotificationsSidebar) { 211 userNotificationsSidebar.all('.nav a').removeClass('selected'); 212 } 213 214 actionableUserNotificationsLink.addClass('selected'); 215 216 if (userNotificationsContainerNode) { 217 userNotificationsContainerNode.addClass('actionable'); 218 userNotificationsContainerNode.removeClass('non-actionable'); 219 } 220 221 notificationsConfigurationNode.hide(); 222 userNotificationsListNode.show(); 223 224 instance._notificationsList.setActionable(true); 225 226 instance._notificationsList.setNotificationsCount('.actionable .count'); 227 228 instance._nonActionableUserNotificationsStart = instance._notificationsList.getStart(); 229 230 instance._notificationsList.setStart(instance._actionableUserNotificationsStart); 231 232 instance._notificationsList.render(); 233 } 234 ); 235 } 236 237 var manageLink = A.one('.notifications-portlet .user-notifications-container .user-notifications-sidebar .nav .manage'); 238 239 if (manageLink) { 240 manageLink.on( 241 'click', 242 function() { 243 var userNotificationsSidebar = A.one('.user-notifications-sidebar'); 244 245 if (userNotificationsSidebar) { 246 userNotificationsSidebar.all('.nav a').removeClass('selected'); 247 } 248 249 manageLink.addClass('selected'); 250 251 if (notificationsConfigurationNode) { 252 notificationsConfigurationNode.show(); 253 notificationsConfigurationNode.plug(A.LoadingMask).loadingmask.show(); 254 255 userNotificationsListNode.hide(); 256 257 var portletURL = new Liferay.PortletURL.createURL(instance._baseRenderURL); 258 259 portletURL.setParameter('mvcPath', '/notifications/configuration.jsp'); 260 261 portletURL.setWindowState('exclusive'); 262 263 notificationsConfigurationNode.plug(A.Plugin.ParseContent); 264 265 notificationsConfigurationNode.load( 266 portletURL.toString(), 267 function() { 268 notificationsConfigurationNode.unplug(A.LoadingMask); 269 } 270 ); 271 } 272 } 273 ); 274 } 275 } 276 } 277 } 278 ); 279 280 Liferay.Notifications = Notifications; 281 }, 282 '', 283 { 284 requires: ['aui-base', 'aui-io', 'liferay-portlet-base', 'liferay-portlet-url', 'node-load'] 285 } 286 287); 288 289AUI.add( 290 'liferay-plugin-notifications-list', 291 function(A) { 292 var Lang = A.Lang; 293 294 var NotificationsList = A.Component.create( 295 { 296 AUGMENTS: [Liferay.PortletBase], 297 298 EXTENDS: A.Base, 299 300 NAME: 'notificationslist', 301 302 prototype: { 303 initializer: function(config) { 304 var instance = this; 305 306 instance._actionable = config.actionable; 307 instance._baseActionURL = config.baseActionURL; 308 instance._baseRenderURL = config.baseRenderURL; 309 instance._baseResourceURL = config.baseResourceURL; 310 instance._delta = config.delta; 311 instance._end = config.start + config.delta; 312 instance._fullView = config.fullView; 313 instance._namespace = config.namespace; 314 instance._nextPageNode = config.nextPageNode; 315 instance._markAllAsReadNode = config.markAllAsReadNode; 316 instance._notificationsContainer = config.notificationsContainer; 317 instance._notificationsCount = config.notificationsCount; 318 instance._notificationsNode = config.notificationsNode; 319 instance._paginationInfoNode = config.paginationInfoNode; 320 instance._portletKey = config.portletKey; 321 instance._previousPageNode = config.previousPageNode; 322 instance._start = config.start; 323 324 instance._bindUI(); 325 }, 326 327 getStart: function() { 328 var instance = this; 329 330 return instance._start; 331 }, 332 333 render: function() { 334 var instance = this; 335 336 var notificationsContainer = A.one(instance._notificationsContainer); 337 338 var notificationsNode = notificationsContainer.one(instance._notificationsNode); 339 340 notificationsNode.plug(A.LoadingMask); 341 342 notificationsNode.loadingmask.show(); 343 344 var portletURL = new Liferay.PortletURL.createURL(instance._baseResourceURL); 345 346 portletURL.setParameter('actionable', instance._actionable); 347 portletURL.setParameter('end', instance._end); 348 portletURL.setParameter('fullView', instance._fullView); 349 portletURL.setParameter('start', instance._start); 350 351 portletURL.setResourceId('getUserNotificationEvents'); 352 353 A.io.request( 354 portletURL.toString(), 355 { 356 dataType: 'JSON', 357 on: { 358 success: function() { 359 var response = this.get('responseData'); 360 361 if (response) { 362 var newTotalUuserNotificationEventsCount = response.newTotalUuserNotificationEventsCount; 363 364 var notificationsCountNode = notificationsContainer.one(instance._notificationsCount); 365 366 if (notificationsCountNode) { 367 notificationsCountNode.setHTML(newTotalUuserNotificationEventsCount); 368 } 369 370 var entries = []; 371 372 var entriesJSONArray = response.entries; 373 374 if (entriesJSONArray) { 375 for (var i = 0; i < entriesJSONArray.length; i++) { 376 entries.push(entriesJSONArray[i]); 377 } 378 379 entries = entries.join(''); 380 } 381 382 var markAllAsReadNode = notificationsContainer.one(instance._markAllAsReadNode); 383 384 var markAllAsReadLink; 385 386 if (markAllAsReadNode) { 387 markAllAsReadLink = markAllAsReadNode.one('a'); 388 } 389 390 var hasEntries = (entriesJSONArray.length > 0); 391 392 if (!hasEntries) { 393 var message = '\u004e\u006f\u0020\u0074\u0069\u0065\u006e\u0065\u0020\u006e\u0069\u006e\u0067\u0075\u006e\u0061\u0020\u006e\u006f\u0074\u0069\u0066\u0069\u0063\u0061\u0063\u0069\u00f3\u006e\u002e'; 394 395 if (instance._actionable) { 396 message = '\u004e\u006f\u0020\u0074\u0069\u0065\u006e\u0065\u0073\u0020\u006e\u0069\u006e\u0067\u0075\u006e\u0061\u0020\u0070\u0065\u0074\u0069\u0063\u0069\u00f3\u006e\u002e'; 397 } 398 399 notificationsNode.setHTML('<div class=\"message\">' + message + '</div>'); 400 401 if (markAllAsReadLink) { 402 markAllAsReadLink.hide(); 403 } 404 } 405 else { 406 notificationsNode.setHTML(entries); 407 408 var newUserNotificationEventsCount = response.newUser
408NotificationEventsCount; 409 410 if (markAllAsReadLink) { 411 markAllAsReadLink.toggle(!instance._actionable && newUserNotificationEventsCount > 0); 412 } 413 } 414 415 var nextPageNode = notificationsContainer.all(instance._nextPageNode); 416 var previousPageNode = notificationsContainer.all(instance._previousPageNode); 417 418 var total = response.total; 419 420 if (nextPageNode) { 421 nextPageNode.toggle(total > instance._end); 422 } 423 424 if (previousPageNode) { 425 previousPageNode.toggle(instance._start != 0); 426 } 427 428 var paginationInfoNode = notificationsContainer.all(instance._paginationInfoNode); 429 430 var displayingCount = instance._end <= total ? instance._end : total; 431 432 var paginationInfoText = Lang.sub('\u004d\u006f\u0073\u0074\u0072\u0061\u006e\u0064\u006f\u0020\u0065\u006c\u0020\u0069\u006e\u0074\u0065\u0072\u0076\u0061\u006c\u006f\u0020\u007b\u0030\u007d\u0020\u002d\u0020\u007b\u0031\u007d\u0020\u0064\u0065\u0020\u007b\u0032\u007d\u0020\u0072\u0065\u0073\u0075\u006c\u0074\u0061\u0064\u006f\u0073\u002e', [(instance._start + 1), displayingCount, total]); 433 434 if (paginationInfoNode) { 435 if (hasEntries) { 436 paginationInfoNode.setHTML(paginationInfoText); 437 } 438 439 paginationInfoNode.toggle(hasEntries); 440 } 441 442 instance._userNotificationEventIds = response.newUserNotificationEventIds; 443 444 notificationsNode.loadingmask.hide(); 445 } 446 } 447 } 448 } 449 ); 450 451 Liferay.fire('updateNotificationsCount'); 452 }, 453 454 setActionable: function(actionable) { 455 var instance = this; 456 457 instance._actionable = actionable; 458 }, 459 460 setNotificationsCount: function(notificationsCount) { 461 var instance = this; 462 463 instance._notificationsCount = notificationsCount; 464 }, 465 466 setStart: function(start) { 467 var instance = this; 468 469 instance._start = start; 470 471 instance._end = instance._start + instance._delta; 472 }, 473 474 _bindMarkAllAsRead: function() { 475 var instance = this; 476 477 var notificationsContainer = A.one(instance._notificationsContainer); 478 479 var markAllAsReadNode = notificationsContainer.one(instance._markAllAsReadNode); 480 481 if (markAllAsReadNode) { 482 markAllAsReadNode.on( 483 'click', 484 function(event) { 485 event.preventDefault(); 486 487 var portletURL = new Liferay.PortletURL.createURL(instance._baseActionURL); 488 489 portletURL.setParameter('javax.portlet.action', 'markAllAsRead'); 490 portletURL.setParameter('userNotificationEventIds', instance._userNotificationEventIds); 491 492 portletURL.setWindowState('normal'); 493 494 A.io.request( 495 portletURL.toString(), 496 { 497 after: { 498 success: function() { 499 var response = this.get('responseData'); 500 501 if (response.success) { 502 instance.render(); 503 } 504 } 505 }, 506 dataType: 'JSON' 507 } 508 ); 509 } 510 ); 511 } 512 }, 513 514 _bindMarkAsRead: function() { 515 var instance = this; 516 517 var notificationsContainer = A.one(instance._notificationsContainer); 518 519 var notificationsNode = notificationsContainer.one(instance._notificationsNode); 520 521 if (notificationsNode) { 522 notificationsNode.delegate( 523 'click', 524 function(event) { 525 var currentTarget = event.currentTarget; 526 527 var currentRow = currentTarget.ancestor('.user-notification'); 528 529 currentRow.plug(A.LoadingMask); 530 531 currentRow.loadingmask.show(); 532 533 var userNotificationLink = currentRow.one('.user-notification-link'); 534 535 var markAsReadURL = userNotificationLink.attr('data-markAsReadURL'); 536 537 if (markAsReadURL) { 538 A.io.request( 539 markAsReadURL, 540 { 541 after: { 542 success: function() { 543 var responseData = this.get('responseData'); 544 545 if (responseData.success) { 546 currentRow.loadingmask.hide(); 547 548 instance.render(); 549 } 550 } 551 }, 552 dataType: 'JSON' 553 } 554 ); 555 } 556 }, 557 '.user-notification .mark-as-read' 558 ); 559 } 560 }, 561 562 _bindNextPageNotifications: function() { 563 var instance = this; 564 565 var notificationsContainer = A.one(instance._notificationsContainer); 566 567 if (notificationsContainer) { 568 notificationsContainer.delegate( 569 'click', 570 function() { 571 instance._start += instance._delta; 572 instance._end += instance._delta; 573 574 instance.render(); 575 }, 576 instance._nextPageNode 577 ); 578 } 579 }, 580 581 _bindNotificationsAction: function() { 582 var instance = this; 583 584 var notificationsContainer = A.one(instance._notificationsContainer); 585 586 var notificationsNode = notificationsContainer.one(instance._notificationsNode); 587 588 if (notificationsNode) { 589 notificationsNode.delegate( 590 'click', 591 function(event) { 592 event.preventDefault(); 593 594 var currentTarget = event.currentTarget; 595 596 var currentRow = currentTarget.ancestor('.user-notification'); 597 598 currentRow.plug(A.LoadingMask); 599 600 currentRow.loadingmask.show(); 601 602 A.io.request( 603 currentTarget.attr('href'), 604 { 605 after: { 606 success: function() { 607 var response = this.get('responseData'); 608 609 if (response.success) { 610 var deleteNode = currentTarget.ancestor('.user-notification-delete'); 611 612 if (deleteNode) { 613 A.io.request( 614 deleteNode.getAttribute('data-deleteURL'), 615 { 616 after: { 617 success: function() { 618 instance.render(); 619 } 620 } 621 } 622 ); 623 } 624 } 625 else { 626 currentRow.loadingmask.hide(); 627 } 628 } 629 }, 630 dataType: 'JSON' 631 } 632 ); 633 }, 634 '.user-notification .btn-action' 635 ); 636 } 637 }, 638 639 _bindPreviousPageNotifications: function() { 640 var instance = this; 641 642 var notificationsContainer = A.one(instance._notificationsContainer); 643 644 if (notificationsContainer) { 645 notificationsContainer.delegate( 646 'click', 647 function() { 648 instance._start -= instance._delta;
649 instance._end -= instance._delta; 650 651 instance.render(); 652 }, 653 instance._previousPageNode 654 ); 655 656 } 657 }, 658 659 _bindUI: function() { 660 var instance = this; 661 662 instance._bindMarkAllAsRead(); 663 instance._bindMarkAsRead(); 664 instance._bindNotificationsAction(); 665 instance._bindNextPageNotifications(); 666 instance._bindPreviousPageNotifications(); 667 instance._bindViewNotification(); 668 }, 669 670 _bindViewNotification: function() { 671 var instance = this; 672 673 var notificationsContainer = A.one(instance._notificationsContainer); 674 675 var notificationsNode = notificationsContainer.one(instance._notificationsNode); 676 677 if (notificationsNode) { 678 notificationsNode.delegate( 679 'click', 680 function(event) { 681 var currentTarget = event.currentTarget; 682 683 var target = event.target; 684 685 if (target.hasClass('.mark-as-read') || target.ancestor('.mark-as-read') || (target._node.tagName == 'A')) { 686 return; 687 } 688 689 var uri = currentTarget.attr('data-href'); 690 691 var markAsReadURL = currentTarget.attr('data-markAsReadURL'); 692 693 if (markAsReadURL) { 694 A.io.request( 695 markAsReadURL, 696 { 697 after: { 698 success: function() { 699 var responseData = this.get('responseData'); 700 701 if (responseData.success) { 702 instance._redirect(uri); 703 } 704 } 705 }, 706 dataType: 'JSON' 707 } 708 ); 709 } 710 else { 711 instance._redirect(uri); 712 } 713 }, 714 '.user-notification .user-notification-link' 715 ); 716 } 717 }, 718 719 _openWindow: function(uri) { 720 return /p_p_state=(maximized|pop_up|exclusive)/.test(uri); 721 }, 722 723 _redirect: function(uri) { 724 var instance = this; 725 726 if (uri) { 727 if (instance._openWindow(uri)) { 728 Liferay.Util.openWindow( 729 { 730 id: 'notificationsWindow', 731 uri: uri 732 } 733 ); 734 } 735 else { 736 var topWindow = Liferay.Util.getTop(); 737 738 topWindow.location.href = uri; 739 } 740 } 741 } 742 } 743 } 744 ); 745 746 Liferay.NotificationsList = NotificationsList; 747 }, 748 '', 749 { 750 requires: ['aui-base', 'aui-io', 'aui-loading-mask-deprecated', 'liferay-poller', 'liferay-portlet-base', 'liferay-portlet-url'] 751 } 752);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.