Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
9c649259dd
|
@ -26,35 +26,31 @@ class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate version diff
|
// Calculate major version diff;
|
||||||
|
// Example: if current = 1.9.5 and latest = 3.0.0, major diff = 11
|
||||||
// Note: algorithm assumes the number after 1st dot never goes above 9
|
// Note: algorithm assumes the number after 1st dot never goes above 9
|
||||||
$diff = (intval($latestMatch[1]) * 10 + intval($latestMatch[2]))
|
$diff = (intval($latestMatch[1]) * 10 + intval($latestMatch[2]))
|
||||||
- (intval($curMatch[1]) * 10 + intval($curMatch[2]));
|
- (intval($curMatch[1]) * 10 + intval($curMatch[2]));
|
||||||
|
|
||||||
// Pick icon and tooltip msg
|
// Pick icon
|
||||||
$bg = "/css/images/";
|
$bg = "/css/images/";
|
||||||
$msg = "";
|
|
||||||
$link = "<a href='http://apt.sourcefabric.org/misc/'>" . $latest . "</a>";
|
|
||||||
if(($diff == 0 && $current == $latest) || $diff < 0) {
|
if(($diff == 0 && $current == $latest) || $diff < 0) {
|
||||||
// current version is up to date
|
// current version is up to date
|
||||||
$bg .= "icon_uptodate.png";
|
$bg .= "icon_uptodate.png";
|
||||||
$msg = "You are running the latest version";
|
|
||||||
} else if($diff <= 2) {
|
} else if($diff <= 2) {
|
||||||
// 2 or less major versions back
|
// 2 or less major versions back
|
||||||
$bg .= "icon_update.png";
|
$bg .= "icon_update.png";
|
||||||
$msg = "New version available: " . $link;
|
|
||||||
} else if($diff == 3) {
|
} else if($diff == 3) {
|
||||||
// 3 major versions back
|
// 3 major versions back
|
||||||
$bg .= "icon_update2.png";
|
$bg .= "icon_update2.png";
|
||||||
$msg = "This version will soon be obsolete.<br/>Please upgrade to " . $link;
|
|
||||||
} else {
|
} else {
|
||||||
// more than 3 major versions back
|
// more than 3 major versions back
|
||||||
$bg .= "icon_outdated.png";
|
$bg .= "icon_outdated.png";
|
||||||
$msg = "This version is no longer supported.<br/>Please upgrade to " . $link;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = "<div id='version_message' style='display:none'>" . $msg . "</div>"
|
$result = "<div id='version_diff' style='display:none'>" . $diff . "</div>"
|
||||||
. "<div id='version_current' style='display:none'>" . $current . "</div>"
|
. "<div id='version_current' style='display:none'>" . $current . "</div>"
|
||||||
|
. "<div id='version_latest' style='display:none'>" . $latest . "</div>"
|
||||||
. "<div id='version_icon' style='background-image: url(" . $bg . ");'></div>";
|
. "<div id='version_icon' style='background-image: url(" . $bg . ");'></div>";
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,63 @@
|
||||||
/**
|
/**
|
||||||
* Get the tooltip message to be displayed,
|
* Get the tooltip message to be displayed
|
||||||
* which is stored inside a pair of hidden div tags
|
|
||||||
*/
|
*/
|
||||||
function getContent() {
|
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,
|
* Get major version difference b/w current and latest version, in int
|
||||||
* which is stored inside a pair of hidden div tags
|
*/
|
||||||
|
function getVersionDiff() {
|
||||||
|
return parseInt($("#version_diff").html());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current version
|
||||||
*/
|
*/
|
||||||
function getCurrentVersion() {
|
function getCurrentVersion() {
|
||||||
return $("#version_current").html();
|
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
|
* Sets up the tooltip for version notification
|
||||||
*/
|
*/
|
||||||
|
@ -26,10 +70,12 @@ function setupVersionQtip(){
|
||||||
text: getContent(),
|
text: getContent(),
|
||||||
title: {
|
title: {
|
||||||
text: getCurrentVersion(),
|
text: getCurrentVersion(),
|
||||||
button: true
|
button: isUpToDate() ? false : true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hide: false, /* Don't hide on mouseout */
|
hide: {
|
||||||
|
event: isUpToDate() ? 'mouseleave' : 'unfocus'
|
||||||
|
},
|
||||||
position: {
|
position: {
|
||||||
my: "top right",
|
my: "top right",
|
||||||
at: "bottom left"
|
at: "bottom left"
|
||||||
|
@ -46,7 +92,7 @@ function setupVersionQtip(){
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if($('#version_message').length > 0) {
|
if($('#version_icon').length > 0) {
|
||||||
setupVersionQtip();
|
setupVersionQtip();
|
||||||
}
|
}
|
||||||
});
|
});
|
Loading…
Reference in New Issue