Enhance-Add message stack (#2521)

Implement new messages class
Support legacy $_SESSION['message_*']
New function messages::add($message, $mood, $delay) to simplify adding messages
updated core/users/user_edit.php to demonstrate
includes space->tab corrections
This commit is contained in:
Mafoo
2017-04-27 18:30:52 +01:00
committed by FusionPBX
parent 32c1522cbb
commit 941b115d92
4 changed files with 135 additions and 44 deletions

View File

@@ -1392,6 +1392,46 @@ $default_login = ($_REQUEST['login'] == 'default') ? true : false;
color: <?php echo $_SESSION['theme']['message_alert_color']['text']; ?>;
}
/* MESSAGES STACK *******************************************************/
#messages_container {
z-index: 99998;
position: absolute;
top: 0;
left: 0;
right: 0;
padding: 0;
}
.message_text {
z-index: 99999;
margin: 0 auto;
padding: 0.5em 0;
text-align: center;
font-family: arial, san-serif;
font-size: 10pt;
display: block;
border-bottom: solid 1px;
}
.message_mood_default {
color: <?php echo $_SESSION['theme']['message_default_color']['text']; ?>;
background: <?php echo $_SESSION['theme']['message_default_background_color']['text']; ?>;
border-bottom-color: <?php echo $_SESSION['theme']['message_default_color']['text']; ?>;
}
.message_mood_negative {
color: <?php echo $_SESSION['theme']['message_negative_color']['text']; ?>;
background: <?php echo $_SESSION['theme']['message_negative_background_color']['text']; ?>;
border-bottom-color: <?php echo $_SESSION['theme']['message_negative_color']['text']; ?>;
}
.message_mood_alert {
color: <?php echo $_SESSION['theme']['message_alert_color']['text']; ?>;
background: <?php echo $_SESSION['theme']['message_alert_background_color']['text']; ?>;
border-bottom-color: <?php echo $_SESSION['theme']['message_alert_color']['text']; ?>;
}
/* OPERATOR PANEL ****************************************************************/
div.op_ext {

View File

@@ -66,43 +66,27 @@
//display message bar via js
function display_message(msg, mood, delay) {
var mood = (typeof mood !== 'undefined') ? mood : 'default';
var delay = (typeof delay !== 'undefined') ? delay : <?php echo (1000 * (float) $_SESSION['theme']['message_delay']['text']); ?>;
if (msg != '') {
var inner_width = $(window).width();
// add class by mood
$("#message_container").addClass('message_container_mood_'+mood);
$("#message_text").addClass('message_text_mood_'+mood);
// output message
$("#message_text").html(msg);
$("#message_container").css({height: $("#message_text").css("height")});
$("#message_container").css({width: inner_width});
$("#message_text").show().animate({top: '+=80'}, 500).animate({opacity: 1}, 'fast').delay(delay).animate({top: '-=80'}, 1000).animate({opacity: 0});
$("#message_container").show().animate({top: '+=80'}, 500).animate({opacity: <?php echo $_SESSION['theme']['message_opacity']['text']; ?>}, "fast").delay(delay).animate({top: '-=80'}, 1000).animate({opacity: 0}, function() {
$("#message_container").removeClass('message_container_mood_'+mood);
});
mood = (typeof mood !== 'undefined') ? mood : 'default';
delay = (typeof delay !== 'undefined') ? delay : <?php echo (1000 * (float) $_SESSION['theme']['message_delay']['text']); ?>;
if (msg !== '') {
var message_text = $(document.createElement('div'));
message_text.addClass('message_text message_mood_'+mood);
message_text.html(msg);
message_text.click(function() {
var object = $(this);
object.clearQueue().finish();
object.css({height: '3em'});
object.animate({height: '0', 'font-size': '0', 'border-bottom-width': '0'}, 1000).animate({opacity: 0});
} );
$("#messages_container").append(message_text);
message_text.animate({height: '3em'}, 500).animate({opacity: 1}, 'fast').delay(delay).animate({height: '0', 'font-size': '0', 'border-bottom-width': '0'}, 1000).animate({opacity: 0});
}
}
$(document).ready(function() {
//set response message, if any
<?php
if (strlen($_SESSION['message']) > 0) {
$message_text = addslashes($_SESSION['message']);
$message_mood = $_SESSION['message_mood'];
$message_delay = $_SESSION['message_delay'];
echo "display_message('".$message_text."'";
echo ($message_mood != '') ? ", '".$message_mood."'" : ", 'default'";
if ($message_delay != '') {
echo ", '".$message_delay."'";
}
echo "); ";
unset($_SESSION['message'], $_SESSION['message_mood'], $_SESSION['message_delay']);
}
?>
//render the messages
<?php echo messages::html(); ?>
//hide message bar on hover
$("#message_text").mouseover(function() { $(this).hide(); $("#message_container").hide(); });
@@ -253,8 +237,8 @@
$('audio').each(function(){
if ($(this).get(0) != recording_audio) {
$(this).get(0).pause(); // Stop playing
$(this).get(0).currentTime = 0; // Reset time
$(this).get(0).pause(); // Stop playing
$(this).get(0).currentTime = 0; // Reset time
}
});
}
@@ -301,15 +285,14 @@
</head>
<?php
//add multi-lingual support
//add multilingual support
$language = new text;
$text = $language->get(null,'themes/default');
?>
<body onload="<?php echo $onload;?>">
<div id='message_container' class='message_container_mood_default'></div>
<div id='message_text' class='message_container_text_default'></div>
<div id='messages_container'></div>
<?php
//logged in show the domains block