public function run()
    {
        $chatModel = new \nitm\widgets\models\Replies(['constrain' => ['type' => 'chat']]);
        $notificationModel = new \nitm\widgets\models\Notification(['constrain' => ['user_id' => \Yii::$app->user->getId()], 'queryOptions' => ['read' => 0]]);
        $uniqid = uniqid();
        $chatWidget = Nav::widget(['encodeLabels' => false, 'options' => ['id' => 'communication-center-messages-wrapper' . $uniqid, 'class' => 'nav navbar-right navbar-nav'], 'items' => [['label' => Icon::show('comment') . Html::tag('span', $chatModel->hasNew(), ['class' => 'badge']), 'options' => ['class' => !$chatModel->hasNew() ? 'text-disabled' : 'text-success'], 'linkOptions' => ['id' => 'communication-center-messages-button' . $uniqid, 'title' => 'Click here again to refresh the info', 'role' => 'dynamicValue', 'data-run-once' => 1, 'data-animation-target' => '#chat' . $uniqid, 'data-animation-start-only' => 1, 'data-type' => 'html', 'data-id' => '#chat' . $uniqid, 'data-url' => \Yii::$app->urlManager->createUrl(['/reply/index/chat/0', '__format' => 'html', \nitm\widgets\models\Replies::FORM_PARAM => true])], 'items' => [['label' => Html::tag('div', Html::tag('h2', 'Loading Messages...', ['class' => 'text-center']) . Html::script('$("#communication-center-messages-button' . $uniqid . '").one("mouseover", function (event) {
								$(this).trigger("click");
							})', ['type' => 'text/javascript']), ['role' => 'chatParent', 'id' => 'chat' . $uniqid, 'class' => '']), 'options' => $this->contentOptions]]]]]);
        $alertWidget = Nav::widget(['encodeLabels' => false, 'options' => ['id' => 'communication-center-notifications-wrapper' . $uniqid, 'class' => 'nav navbar-right navbar-nav'], 'items' => [['label' => Icon::show('bell') . Html::tag('span', $notificationModel->count(), ['class' => 'badge']), 'options' => ['class' => !$notificationModel->count() ? 'bg-disabled' : 'bg-success'], 'linkOptions' => ['id' => 'communication-center-notifications-button' . $uniqid, 'title' => 'Click here again to refresh the info', 'role' => 'dynamicValue', 'data-run-once' => 1, 'data-animation-target' => '#communication-center-notifications' . $uniqid, 'data-animation-start-only' => 1, 'data-type' => 'html', 'data-id' => '#communication-center-notifications' . $uniqid, 'data-url' => \Yii::$app->urlManager->createUrl(['/alerts/notifications', '__format' => 'html'])], 'items' => [['label' => Html::tag('div', Html::tag('h2', 'Loading Alerts...', ['class' => 'text-center']) . Html::script('$("#communication-center-notifications-button' . $uniqid . '").one("mouseover", function (event) {
								$(this).trigger("click");
							})', ['type' => 'text/javascript']), ['id' => 'communication-center-notifications' . $uniqid, 'class' => '']), 'options' => $this->contentOptions]]]]]);
        $widget = $alertWidget . $chatWidget;
        //$js = "\$nitm.onModuleLoad('communication-center', function (module) {
        //	module.initChatTabs('#".$this->options['id']."');
        //});";
        $js = "";
        if ($this->chatUpdateOptions['enabled']) {
            $js .= "\$nitm.onModuleLoad('polling', function (module) {\r\n\t\t\t\tmodule.initPolling('chat', {\r\n\t\t\t\t\tenabled: true,\r\n\t\t\t\t\turl: '" . $this->chatUpdateOptions['url'] . "', \r\n\t\t\t\t\tinterval: " . $this->chatUpdateOptions['interval'] . ",\r\n\t\t\t\t\tcontainer: '#nitm-communication-center-widget" . $uniqid . "'\r\n\t\t\t\t}, {object: \$nitm.module('replies'), method: 'chatStatus'});\r\n\t\t\t});";
        }
        if ($this->notificationUpdateOptions['enabled']) {
            $js .= "\r\n\t\t\t\$nitm.onModuleLoad('polling', function (module) {\r\n\t\t\t\tmodule.initPolling('notifications', {\r\n\t\t\t\t\tenabled: true,\r\n\t\t\t\t\tinterval: " . $this->notificationUpdateOptions['interval'] . ",\r\n\t\t\t\t\turl: '" . $this->notificationUpdateOptions['url'] . "',\r\n\t\t\t\t\tcontainer: '#nitm-communication-center-widget" . $uniqid . "'\r\n\t\t\t\t}, {object: \$nitm.module('notifications'), method: 'notificationStatus'});\r\n\t\t\t});";
        }
        if ($js) {
            $js = Html::script($js, ['type' => 'text/javascript']);
        }
        return $widget . $js;
    }
Esempio n. 2
0
    public function run()
    {
        $header = Html::tag(ArrayHelper::remove($this->labelOptions, 'tag', 'h4'), 'Parents', $this->labelOptions);
        if (count($this->labelContainerOptions)) {
            $header = Html::tag(ArrayHelper::remove($this->labelContainerOptions, 'tag', 'div'), $header, $this->labelContainerOptions);
        }
        $list = ListView::widget(['summary' => false, 'emptyText' => Html::tag('ul', '', $this->options), 'options' => $this->options, 'itemOptions' => $this->itemOptions, 'dataProvider' => $this->dataProvider, 'itemView' => function ($model, $key, $index, $widget) {
            return $model->name . (!$this->viewOnly ? Html::tag('span', Html::a("Remove " . Icon::show('remove'), '/' . $this->model->isWhat() . "/remove-parent/" . $this->model->getId() . '/' . $model['id'], ['role' => 'parentListItem', 'style' => 'color:white']), ['class' => 'badge']) : '');
        }]);
        if (count($this->listOptions)) {
            $list = Html::tag(ArrayHelper::remove($this->listOptions, 'tag', 'div'), $list, $this->listOptions);
        }
        if (!$this->viewOnly) {
            $script = Html::tag('script', new \yii\web\jsExpression('$(document).ready(function () {
				$("#' . $this->options['id'] . '").find(\'[role="parentListItem"]\').each(function () {
					$(this).on("click", function (event) {
						event.preventDefault();
						var $element = $(this);
						$.post(this.href, function (result) {
							if(result) $element.parents("li").remove();
						});
					});
				});
			})'), ['type' => 'text/javascript']);
        } else {
            $script = '';
        }
        return Html::tag('div', $header . $list, $this->containerOptions) . $script;
    }
Esempio n. 3
0
$this->title = Yii::t('app', 'Alerts');
$this->params['breadcrumbs'][] = $this->title;
if (isset($contentOnly) && $contentOnly === false || !isset($contentOnly)) {
    ?>
<div id='notification-index' class="absolute full full-width full-height" role="notificationListForm">
	<div class="col-md-6 col-lg-6">
		<h1>
			<?php 
    echo Html::encode($this->title);
    ?>
		</h1>
	</div>
	<div class="col-md-6 col-lg-6">
		<h1>
			<?php 
    echo Html::a(Icon::show('refresh'), \Yii::$app->urlManager->createUrl(['/alerts/notifications', '__format' => 'html', '__contentOnly' => true]), ['role' => 'dynamicValue', 'data-id' => 'notification-list-container', 'data-type' => 'html', 'class' => 'pull-right']);
    ?>
		</h1>
	</div>
	<div class="col-md-12 col-lg-12">
	<?php 
}
?>
		<?php 
echo ListView::widget(['dataProvider' => $dataProvider, 'itemView' => function ($model, $key, $index, $widget) {
    return $this->render('view-notification', ['model' => $model]);
}, "layout" => "{summary}\n{items}{pager}", 'itemOptions' => ['class' => 'item'], 'options' => ['id' => 'notification-list-container', 'tag' => 'div', 'class' => 'list-group', 'role' => 'notificationList'], 'pager' => ['class' => \nitm\widgets\ias\ScrollPager::className(), 'overflowContainer' => '#notification-index', 'container' => '#notification-list-container', 'item' => ".item", 'negativeMargin' => 75, 'noneLeftText' => 'No more notifications', 'triggerText' => 'More notifications']]);
?>
	<?php 
if (isset($contentOnly) && $contentOnly === false) {
    ?>
 public function actionFollow($type, $id, $key)
 {
     $_REQUEST['do'] = true;
     \Yii::$app->request->setBodyParams([$this->model->formName() => ['remote_id' => $id, 'remote_type' => $type, 'methods' => $key, 'action' => 'any']]);
     $ret_val = ['message' => "There was an error following this " . $type . ". Please try again and report this if it keeps happening", 'success' => false];
     try {
         $ret_val = parent::actionCreate();
         $result['message'] = 'Successfully followed ' . $type;
         if (ArrayHelper::getValue((array) $ret_val, 'success', false) === true) {
             $ret_val['data'] = '';
             switch ($this->model->methods) {
                 case 'email':
                     $methods = 'envelope';
                     break;
                 case 'mobile':
                     $methods = 'mobile';
                     break;
                 default:
                     $methods = 'send';
                     break;
             }
             $ret_val['actionHtml'] = 'Unfollow ' . \nitm\helpers\Icon::show($methods);
             $ret_val['class'] = 'btn-success';
         }
     } catch (\Exception $e) {
         if (YII_DEBUG) {
             throw $e;
         }
     }
     if (ArrayHelper::getValue((array) $ret_val, 'success', false)) {
         \nitm\traits\Relations::setCachedRelationModel($this->model, ['remote_id', 'remote_type'], 'followModel');
     }
     return $ret_val;
 }
Esempio n. 5
0
 protected function initializeMethods()
 {
     $this->followMethods = array_merge($this->_defaultFollowMethods, $this->followMethods);
     $supported = \nitm\helpers\alerts\DispatcherData::supportedMethods();
     foreach ($this->followMethods as $idx => $method) {
         switch (isset($supported[$method['method']])) {
             case true:
                 $method['label'] = Icon::show($method['icon']) . ' ' . $method['label'];
                 $method['url'] = '/alerts/follow/' . $this->model->remote_type . '/' . $this->model->remote_id . '/' . $method['method'];
                 $method['linkOptions'] = ['role' => 'dynamicValue', 'data-pjax' => 0, 'data-run-once' => true, 'data-type' => 'callback', 'data-ajax-method' => 'post', 'data-id' => '#' . $this->options['id'], 'data-callback' => "function (result, elem) { \$nitm.module('follow').afterAction(result, elem);}"];
                 $this->followMethods[$idx] = $method;
                 break;
             default:
                 unset($this->followMethods[$idx]);
                 break;
         }
     }
 }