CC-2950: Tell users if they are running an out-of-date version or not
- Hide tooltip and close button on mouseout when current version is up to date - Return version diff instead of tooltip msg in VersionNotify.php, make js side responsible for picking the msg
This commit is contained in:
parent
fdff88cb76
commit
383fa35fc5
2 changed files with 59 additions and 17 deletions
|
@ -1,19 +1,63 @@
|
|||
/**
|
||||
* Get the tooltip message to be displayed,
|
||||
* which is stored inside a pair of hidden div tags
|
||||
* Get the tooltip message to be displayed
|
||||
*/
|
||||
function getContent() {
|
||||
return $("#version_message").html();
|
||||
var diff = getVersionDiff();
|
||||
var link = getLatestLink();
|
||||
|
||||
var msg = "";
|
||||
if(isUpToDate()) {
|
||||
msg = "You are running the latest version";
|
||||
} else if(diff <= 2) {
|
||||
msg = "New version available: " + link;
|
||||
} else if(diff == 3) {
|
||||
msg = "This version will soon be obsolete.<br/>Please upgrade to " + link;
|
||||
} else {
|
||||
msg = "This version is no longer supported.<br/>Please upgrade to " + link;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current version,
|
||||
* which is stored inside a pair of hidden div tags
|
||||
* Get major version difference b/w current and latest version, in int
|
||||
*/
|
||||
function getVersionDiff() {
|
||||
return parseInt($("#version_diff").html());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current version
|
||||
*/
|
||||
function getCurrentVersion() {
|
||||
return $("#version_current").html();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version
|
||||
*/
|
||||
function getLatestVersion() {
|
||||
return $("#version_latest").html();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if current version is up to date
|
||||
*/
|
||||
function isUpToDate() {
|
||||
var diff = getVersionDiff();
|
||||
var current = getCurrentVersion();
|
||||
var latest = getLatestVersion();
|
||||
var temp = (diff == 0 && current == latest) || diff < 0;
|
||||
return (diff == 0 && current == latest) || diff < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the download link to latest release in HTML
|
||||
*/
|
||||
function getLatestLink() {
|
||||
return "<a href='http://apt.sourcefabric.org/misc/'>" + getLatestVersion() + "</a>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the tooltip for version notification
|
||||
*/
|
||||
|
@ -26,10 +70,12 @@ function setupVersionQtip(){
|
|||
text: getContent(),
|
||||
title: {
|
||||
text: getCurrentVersion(),
|
||||
button: true
|
||||
button: isUpToDate() ? false : true
|
||||
}
|
||||
},
|
||||
hide: false, /* Don't hide on mouseout */
|
||||
hide: {
|
||||
event: isUpToDate() ? 'mouseleave' : 'unfocus'
|
||||
},
|
||||
position: {
|
||||
my: "top right",
|
||||
at: "bottom left"
|
||||
|
@ -46,7 +92,7 @@ function setupVersionQtip(){
|
|||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
if($('#version_message').length > 0) {
|
||||
if($('#version_icon').length > 0) {
|
||||
setupVersionQtip();
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue