WCF.System.PageNavigation.init('.pageNavigation');
WCF.Date.Picker.init();
- //new WCF.User.ProfilePreview();
- new WCF.Notice.Dismiss();
WCF.User.Profile.ActivityPointList.init();
{event name='javascriptInit'}
<p class="warning">{lang}wcf.user.register.needActivation{/lang}</p>
{/if}
- {foreach from=$__wcf->getNoticeHandler()->getVisibleNotices() item='notice'}
- <p class="{$notice->cssClassName} notice{if $notice->isDismissible} noticeDismissible{/if}">
- {if $notice->isDismissible}
- <span class="icon icon16 fa-times pointer jsDismissNoticeButton jsTooltip" data-object-id="{$notice->noticeID}" title="{lang}wcf.notice.button.dismiss{/lang}"></span>
- {/if}
-
- {if $notice->noticeUseHtml}{@$notice->notice|language}{else}{@$notice->notice|language|htmlspecialchars|nl2br}{/if}
- </p>
- {/foreach}
+ {hascontent}
+ {content}
+ {foreach from=$__wcf->getNoticeHandler()->getVisibleNotices() item='notice'}
+ <p class="{$notice->cssClassName} notice{if $notice->isDismissible} noticeDismissible{/if}">
+ {if $notice->isDismissible}
+ <span class="icon icon16 fa-times pointer jsDismissNoticeButton jsTooltip" data-object-id="{$notice->noticeID}" title="{lang}wcf.notice.button.dismiss{/lang}"></span>
+ {/if}
+
+ {if $notice->noticeUseHtml}{@$notice->notice|language}{else}{@$notice->notice|language|htmlspecialchars|nl2br}{/if}
+ </p>
+ {/foreach}
+ {/content}
+
+ <script data-relocate="true">
+ require(['WoltLab/WCF/Controller/Notice/Dismiss'], function(ControllerNoticeDismiss) {
+ ControllerNoticeDismiss.setup();
+ });
+ </script>
+ {/hascontent}
{event name='userNotice'}
</div>
*/
WCF.Notice = { };
-/**
- * Handles dismissing notices.
- */
-WCF.Notice.Dismiss = Class.extend({
- /**
- * list with notices
- * @var jQuery
- */
- _notices: { },
-
- /**
- * action proxy object
- * @var WCF.Action.Proxy
- */
- _proxy: null,
-
- /**
- * Initializes a new WCF.Notice.Dismiss object.
- */
- init: function() {
- this._proxy = new WCF.Action.Proxy({
- success: $.proxy(this._success, this)
- });
-
- var $dismissButtons = $('.jsDismissNoticeButton').click($.proxy(this._click, this));
-
- $dismissButtons.each($.proxy(function(index, element) {
- this._notices[$(element).data('objectID')] = $(element).parent();
- }, this));
- },
-
- /**
- * Handles clicking on
- */
- _click: function(event) {
- this._proxy.setOption('data', {
- actionName: 'dismiss',
- className: 'wcf\\data\\notice\\NoticeAction',
- objectIDs: [ $(event.currentTarget).data('objectID') ]
- });
- this._proxy.sendRequest();
- },
-
- /**
- * Handles successfull AJAX request.
- *
- * @param object data
- * @param string textStatus
- * @param jQuery jqXHR
- */
- _success: function(data, textStatus, jqXHR) {
- this._notices[data.returnValues.noticeID].wcfFadeOut();
- }
-});
-
/**
* Encapsulate eval() within an own function to prevent problems
* with optimizing and minifiny JS.
--- /dev/null
+/**
+ * Handles dismissable user notices.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2015 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLab/WCF/Controller/Notice/Dismiss
+ */
+define(function() {
+ "use strict";
+
+ /**
+ * @constructor
+ */
+ function ControllerNoticeDismiss() {};
+ ControllerNoticeDismiss.prototype = {
+ /**
+ * Initializes dismiss buttons.
+ */
+ setup: function() {
+ var buttons = document.getElementsByClassName('jsDismissNoticeButton');
+
+ if (buttons.length) {
+ var clickCallback = this._click.bind(this);
+ for (var i = 0, length = buttons.length; i < length; i++) {
+ buttons[i].addEventListener('click', clickCallback);
+ }
+ }
+ },
+
+ /**
+ * Sends a request to dismiss a notice and removes it afterwards.
+ */
+ _click: function(event) {
+ var button = event.currentTarget;
+
+ new WCF.Action.Proxy({
+ autoSend: true,
+ data: {
+ actionName: 'dismiss',
+ className: 'wcf\\data\\notice\\NoticeAction',
+ objectIDs: [ button.getAttribute('data-object-id') ]
+ },
+ success: function() {
+ var parent = button.parentNode;
+
+ parent.addEventListener('transitionend', function() {
+ parent.parentNode.removeChild(parent);
+ });
+
+ parent.classList.remove('active');
+ }
+ });
+ }
+ };
+
+ return new ControllerNoticeDismiss();
+});