mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-06 11:59:56 +02:00
Add user feedback near mouse cursor when voting to a song (democratic playlist)
This commit is contained in:
parent
b7a76aa133
commit
a157856675
6 changed files with 49 additions and 6 deletions
|
@ -405,6 +405,10 @@ class Democratic extends Tmp_Playlist
|
||||||
*/
|
*/
|
||||||
private function _add_vote($object_id, $object_type = 'song')
|
private function _add_vote($object_id, $object_type = 'song')
|
||||||
{
|
{
|
||||||
|
if (!$this->tmp_playlist) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$media = new $object_type($object_id);
|
$media = new $object_type($object_id);
|
||||||
$track = isset($media->track) ? intval($media->track) : null;
|
$track = isset($media->track) ? intval($media->track) : null;
|
||||||
|
|
||||||
|
@ -588,11 +592,13 @@ class Democratic extends Tmp_Playlist
|
||||||
{
|
{
|
||||||
$tmp_id = Dba::escape($this->tmp_playlist);
|
$tmp_id = Dba::escape($this->tmp_playlist);
|
||||||
|
|
||||||
|
if ($tmp_id) {
|
||||||
/* Clear all votes then prune */
|
/* Clear all votes then prune */
|
||||||
$sql = "DELETE FROM `user_vote` USING `user_vote` " .
|
$sql = "DELETE FROM `user_vote` USING `user_vote` " .
|
||||||
"LEFT JOIN `tmp_playlist_data` ON `user_vote`.`object_id` = `tmp_playlist_data`.`id` " .
|
"LEFT JOIN `tmp_playlist_data` ON `user_vote`.`object_id` = `tmp_playlist_data`.`id` " .
|
||||||
"WHERE `tmp_playlist_data`.`tmp_playlist`='$tmp_id'";
|
"WHERE `tmp_playlist_data`.`tmp_playlist`='$tmp_id'";
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
}
|
||||||
|
|
||||||
// Prune!
|
// Prune!
|
||||||
self::prune_tracks();
|
self::prune_tracks();
|
||||||
|
|
|
@ -497,6 +497,7 @@ class Stream_Playlist
|
||||||
}
|
}
|
||||||
|
|
||||||
$democratic->add_vote($items);
|
$democratic->add_vote($items);
|
||||||
|
mouse_message(T_('Vote added'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
//
|
//
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
initTabs();
|
initTabs();
|
||||||
|
$(document).mousemove(mouse_message_move);
|
||||||
});
|
});
|
||||||
|
|
||||||
function initTabs()
|
function initTabs()
|
||||||
|
@ -85,6 +86,25 @@ function toggleVisible(element) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var mouseTimeout = null;
|
||||||
|
function mouseMessage(message, timeout) {
|
||||||
|
if (mouseTimeout != null) {
|
||||||
|
clearTimeout(mouseTimeout);
|
||||||
|
mouseTimeout = null;
|
||||||
|
}
|
||||||
|
$('#mouse_message').html(message);
|
||||||
|
$('#mouse_message').fadeIn();
|
||||||
|
mouseTimeout = setTimeout(function() {
|
||||||
|
$('#mouse_message').fadeOut();
|
||||||
|
}, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
function mouse_message_move(e) {
|
||||||
|
$('#mouse_message').css({top: e.clientY + 10,
|
||||||
|
left: e.clientX + 10
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// delayRun
|
// delayRun
|
||||||
// This function delays the run of another function by X milliseconds
|
// This function delays the run of another function by X milliseconds
|
||||||
function delayRun(element, time, method, page, source) {
|
function delayRun(element, time, method, page, source) {
|
||||||
|
|
|
@ -666,6 +666,13 @@ function toggle_visible($element)
|
||||||
|
|
||||||
} // toggle_visible
|
} // toggle_visible
|
||||||
|
|
||||||
|
function mouse_message($message, $timeout = 1000)
|
||||||
|
{
|
||||||
|
echo "<script type='text/javascript'>";
|
||||||
|
echo "mouseMessage('" . $message . "', " . $timeout . ");";
|
||||||
|
echo "</script>\n";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print_bool
|
* print_bool
|
||||||
* This function takes a boolean value and then prints out a friendly text
|
* This function takes a boolean value and then prints out a friendly text
|
||||||
|
|
|
@ -291,6 +291,7 @@ $_SESSION['login'] = false;
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<!-- rfc3514 implementation -->
|
<!-- rfc3514 implementation -->
|
||||||
<div id="rfc3514" style="display:none;">0x0</div>
|
<div id="rfc3514" style="display:none;">0x0</div>
|
||||||
|
<div id="mouse_message"></div>
|
||||||
<div id="maincontainer">
|
<div id="maincontainer">
|
||||||
<div id="header" class="header-<?php echo AmpConfig::get('ui_fixed') ? 'fixed' : 'float'; ?>"><!-- This is the header -->
|
<div id="header" class="header-<?php echo AmpConfig::get('ui_fixed') ? 'fixed' : 'float'; ?>"><!-- This is the header -->
|
||||||
<h1 id="headerlogo">
|
<h1 id="headerlogo">
|
||||||
|
|
|
@ -185,7 +185,15 @@ input[type=button]:focus:active, input[type=submit]:focus:active {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
display: none;
|
display: none;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center;
|
background-position: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
#mouse_message {
|
||||||
|
z-index: 9999;
|
||||||
|
position: fixed;
|
||||||
|
color: #303335;
|
||||||
|
text-shadow: 2px 2px 9px #fff;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************
|
/***********************************************
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue