dashpanel notifications badge
This commit is contained in:
parent
0700b69b2e
commit
7c08194665
|
@ -77,5 +77,5 @@ var desk_web_browser = function(url) {
|
|||
};
|
||||
|
||||
var desk_web_zira = function() {
|
||||
desk_web_browser('h'+'t' +'t'+'p'+ ':'+'/' +'/' +'d'+'r' +'o' +'1'+'d' +'.'+'r' +'u'+'/' +'z'+'i' +'r'+'a');
|
||||
desk_web_browser('https://ziracms.github.io/ziracms/download.html');
|
||||
};
|
|
@ -13,24 +13,6 @@ use Dash;
|
|||
class Index extends Dash\Controller {
|
||||
public function index() {
|
||||
Dash\Dash::addAssetScript('dash.js');
|
||||
|
||||
$script = Zira\Helper::tag_open('script', array('type'=>'text/javascript'));
|
||||
$script .= 'jQuery(document).ready(function(){ ';
|
||||
$script .= 'window.setTimeout(function(){';
|
||||
$script .= 'jQuery.post(\''.Zira\Helper::url('dash/index/notifications').'\',{\'token\':\''.Dash\Dash::getToken().'\'},function(response){';
|
||||
$script .= 'if (!response || typeof(response.notifications)=="undefined") return;';
|
||||
$script .= 'for (var i=0; i<response.notifications.length; i++){';
|
||||
$script .= 'window.setTimeout(zira_bind({message:response.notifications[i].message,callback:response.notifications[i].callback},function(){';
|
||||
$script .= 'dashboard_notification(this.message,this.callback);';
|
||||
$script .= '}), 5+200*i);';
|
||||
$script .= '}';
|
||||
$script .= '},\'json\');';
|
||||
$script .= '}, 1000);';
|
||||
$script .= ' });';
|
||||
$script .= Zira\Helper::tag_close('script');
|
||||
//Zira\View::addHTML($script, Zira\View::VAR_HEAD_BOTTOM);
|
||||
Zira\View::addBodyBottomScript($script);
|
||||
|
||||
$records_co = Zira\Models\Record::getCollection()
|
||||
->count()
|
||||
->where('published','=',Zira\Models\Record::STATUS_PUBLISHED)
|
||||
|
@ -233,6 +215,21 @@ class Index extends Dash\Controller {
|
|||
Zira\View::setAjax(true);
|
||||
$response = array('notifications'=>array());
|
||||
|
||||
if (Zira\Config::get('check_updates', 1)) {
|
||||
$check_url = 'https://ziracms.github.io/version.txt';
|
||||
try {
|
||||
$check_version = @file_get_contents($check_url . '?t=' . time());
|
||||
} catch(\Exception $e) {
|
||||
$check_version = false;
|
||||
}
|
||||
if ($check_version && version_compare($check_version, Zira::VERSION)>0) {
|
||||
$response['notifications'][] = array(
|
||||
'message'=>Zira\Locale::t('Version %s is available for download', $check_version),
|
||||
'callback'=>'desk_web_zira'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$commentsModel = new Dash\Models\Comments(new Dash\Windows\Comments());
|
||||
$comments = $commentsModel->getNewCommentsCount();
|
||||
if ($comments > 0) {
|
||||
|
|
|
@ -487,6 +487,24 @@ class Dash {
|
|||
// ignore
|
||||
}
|
||||
}
|
||||
$js .= 'window.setTimeout(function(){';
|
||||
$js .= '$.post(\''.Zira\Helper::url('dash/index/notifications').'\',{\'token\':\''.self::getToken().'\'},function(response){';
|
||||
$js .= 'if (!response || typeof(response.notifications)=="undefined") return;';
|
||||
$js .= 'if (typeof(dashboard_notification) == "undefined") {';
|
||||
$js .= '$(\'#dashpanel-container .navbar-collapse\').append(\'<ul class="nav navbar-nav notifications"><li><a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="badge"><span class="glyphicon glyphicon-comment"></span> \'+response.notifications.length+\'</span></a><ul class="dropdown-menu"></ul></li></ul>\');';
|
||||
$js .= '}';
|
||||
$js .= 'for (var i=0; i<response.notifications.length; i++){';
|
||||
$js .= 'if (typeof(dashboard_notification) != "undefined"){';
|
||||
$js .= 'window.setTimeout(zira_bind({message:response.notifications[i].message,callback:response.notifications[i].callback},function(){';
|
||||
$js .= 'dashboard_notification(this.message,this.callback);';
|
||||
$js .= '}), 5+200*i);';
|
||||
$js .= '} else {';
|
||||
$js .= '$(\'#dashpanel-container .navbar-collapse ul.navbar-nav.notifications ul.dropdown-menu\').append(\'<li><a href="javascript:void(0)">\'+response.notifications[i].message+\'</a></li>\');';
|
||||
$js .= '$(\'#dashpanel-container .navbar-collapse ul.navbar-nav.notifications ul.dropdown-menu li:last-child a\').click(zira_bind({callback:response.notifications[i].callback}, function(){desk_call(this.callback);}));';
|
||||
$js .= '}';
|
||||
$js .= '}';
|
||||
$js .= '},\'json\');';
|
||||
$js .= '}, 1000);';
|
||||
if ($renderWindows && !$this->isReferedFromDash()) {
|
||||
$js .= '})(jQuery);' . "\r\n";
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ class Options extends Form
|
|||
));
|
||||
$html .= $this->checkbox(Locale::t('Maximize windows'), 'dashwindow_maximized', null, false);
|
||||
$html .= $this->checkbox(Locale::t('Switch to offline mode'), 'site_offline', null, false);
|
||||
$html .= $this->checkbox(Locale::t('Check for updates'), 'check_updates', null, false);
|
||||
$html .= $this->close();
|
||||
return $html;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class Options extends Model {
|
|||
'dashwindow_maximized' => 'int',
|
||||
'watermark_margin' => 'int',
|
||||
'site_offline' => 'int',
|
||||
'check_updates' => 'int',
|
||||
'captcha_type' => 'string',
|
||||
'recaptcha_site_key' => 'string',
|
||||
'recaptcha_secret_key' => 'string',
|
||||
|
|
|
@ -42,6 +42,7 @@ class Options extends Window {
|
|||
if (empty($configs['timezone'])) $configs['timezone'] = date_default_timezone_get();
|
||||
if (!array_key_exists('db_widgets_enabled', $configs)) $configs['db_widgets_enabled'] = 1;
|
||||
if (!array_key_exists('watermark_margin', $configs)) $configs['watermark_margin'] = 10;
|
||||
if (!array_key_exists('check_updates', $configs)) $configs['check_updates'] = 1;
|
||||
if (!array_key_exists('captcha_type', $configs)) $configs['captcha_type'] = Zira\Models\Captcha::TYPE_DEFAULT;
|
||||
if (!array_key_exists('recaptcha3_score', $configs)) $configs['recaptcha3_score'] = Zira\Models\Captcha::RECAPTCHA_v3_MIN_SCORE;
|
||||
|
||||
|
|
|
@ -114,6 +114,9 @@
|
|||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
#dashpanel-container .badge {
|
||||
background-color: #6f90ae;
|
||||
}
|
||||
body {
|
||||
padding-top: 42px;
|
||||
}
|
||||
|
|
|
@ -106,6 +106,9 @@
|
|||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
#dashpanel-container .badge {
|
||||
background-color: #2ec73a;
|
||||
}
|
||||
body {
|
||||
padding-top: 42px;
|
||||
}
|
||||
|
|
|
@ -109,6 +109,9 @@
|
|||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
#dashpanel-container .badge {
|
||||
background-color: #ca7095;
|
||||
}
|
||||
body {
|
||||
padding-top: 42px;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue