MCPcopy
hub / github.com/lumapps/lumX / _build

Function _build

components/notification/js/notification_service.js:87–142  ·  view source on GitHub ↗

* Build the notification template. * * @param {string} content The notification content. * @param {string} type The notification type, either info, success, warning or error. * @param {string} [actionLabel] The action button label. * @param {Fun

(content, type, actionLabel, actionCallback)

Source from the content-addressed store, hash-verified

85 * @param {Function} [actionCallback] The action button callback function called on action button click.
86 */
87 function _build(content, type, actionLabel, actionCallback) {
88 const notification = angular.element('<div/>', {
89 class: `${CSS_PREFIX}-notification ${CSS_PREFIX}-notification--color-${_notificationTypes[type].color}`,
90 });
91
92 const notificationIconWrapper = angular.element('<div/>', {
93 class: `${CSS_PREFIX}-notification__icon`,
94 });
95
96 const notificationIcon = $compile(`<lx-icon lx-path="${_notificationTypes[type].icon}" lx-size="s"></lx-icon>`)(
97 $rootScope,
98 );
99
100 const notificationText = angular.element('<span/>', {
101 class: `${CSS_PREFIX}-notification__content`,
102 html: content,
103 });
104
105 notificationIconWrapper.append(notificationIcon);
106
107 notification.append(notificationIconWrapper).append(notificationText);
108
109 if (angular.isDefined(actionLabel)) {
110 notification.addClass(`${CSS_PREFIX}-notification--has-action`);
111
112 const notificationActionWrapper = angular.element('<div/>', {
113 class: `${CSS_PREFIX}-notification__action`,
114 });
115 const notificationAction = $compile(`<lx-button lx-emphasis="medium">${actionLabel}</lx-button>`)(
116 $rootScope,
117 );
118
119 notificationAction.on('click', function onActionCuttonClick(evt) {
120 actionCallback();
121
122 evt.stopPropagation();
123 });
124
125 notificationActionWrapper.append(notificationAction).appendTo(notification);
126 }
127
128 const notificationHideTimeout = $timeout(function waitBeforeHiding() {
129 _hide(notification);
130 }, _HIDE_DELAY);
131
132 LxDepthService.increase();
133
134 notification
135 .css('z-index', LxDepthService.get())
136 .appendTo('body')
137 .on('click', function onNotificationClick() {
138 _hide(notification);
139
140 $timeout.cancel(notificationHideTimeout);
141 });
142 }
143
144 /**

Callers 1

_notifyFunction · 0.85

Calls 1

_hideFunction · 0.85

Tested by

no test coverage detected