[Pkg-owncloud-commits] [owncloud] 29/122: Use OC.Notification for update notifications
David Prévot
taffit at moszumanska.debian.org
Sat May 9 00:00:06 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit cd516eedcd4cca1abb92d8781749a6f152d34319
Author: Morris Jobke <hey at morrisjobke.de>
Date: Sun May 3 12:28:29 2015 +0200
Use OC.Notification for update notifications
* instead of a static rendering inside PHP use the
JS OC.Notification.showTemporary to hide the
notification after 7 seconds automatically
* fixes #14811
---
core/js/update-notification.js | 30 ++++++++++++++++++++++++++++++
core/templates/layout.user.php | 9 +++++----
lib/private/templatelayout.php | 1 +
3 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/core/js/update-notification.js b/core/js/update-notification.js
new file mode 100644
index 0000000..42baa7f
--- /dev/null
+++ b/core/js/update-notification.js
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2015 ownCloud Inc
+ *
+ * @author Morris Jobke <hey at morrisjobke.de>
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
+/**
+ * this gets only loaded if an update is available and then shows a temporary notification
+ */
+$(document).ready(function(){
+ var head = $('html > head'),
+ version = head.data('update-version'),
+ docLink = head.data('update-link'),
+ text = t('core', '{version} is available. Get more information on how to update.', {version: version}),
+ element = $('<a>').attr('href', docLink).text(text);
+
+ OC.Notification.showTemporary(
+ element,
+ {
+ isHTML: true
+ }
+ );
+});
+
diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php
index 87a6a92..bcf4731 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -2,7 +2,11 @@
<!--[if lte IE 8]><html class="ng-csp ie ie8 lte9 lte8" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" ><![endif]-->
<!--[if IE 9]><html class="ng-csp ie ie9 lte9" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" ><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html class="ng-csp" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" ><!--<![endif]-->
- <head data-user="<?php p($_['user_uid']); ?>" data-requesttoken="<?php p($_['requesttoken']); ?>">
+ <head data-user="<?php p($_['user_uid']); ?>" data-requesttoken="<?php p($_['requesttoken']); ?>"
+ <?php if ($_['updateAvailable']): ?>
+ data-update-version="<?php print($_['updateVersion']); ?>" data-update-link="<?php print_unescaped($_['updateLink']); ?>"
+ <?php endif; ?>
+ >
<meta charset="utf-8">
<title>
<?php
@@ -31,9 +35,6 @@
<?php include('layout.noscript.warning.php'); ?>
<div id="notification-container">
<div id="notification"></div>
- <?php if ($_['updateAvailable']): ?>
- <div id="update-notification" style="display: inline;"><a href="<?php print_unescaped($_['updateLink']); ?>"><?php p($l->t('%s is available. Get more information on how to update.', array($_['updateVersion']))); ?></a></div>
- <?php endif; ?>
</div>
<header role="banner"><div id="header">
<a href="<?php print_unescaped(link_to('', 'index.php')); ?>"
diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php
index 448276c..0e1a8f3 100644
--- a/lib/private/templatelayout.php
+++ b/lib/private/templatelayout.php
@@ -85,6 +85,7 @@ class OC_TemplateLayout extends OC_Template {
$this->assign('updateAvailable', true);
$this->assign('updateVersion', $data['versionstring']);
$this->assign('updateLink', $data['web']);
+ \OCP\Util::addScript('core', 'update-notification');
} else {
$this->assign('updateAvailable', false); // No update available or not an admin user
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list