com web/php: Fix duplicate flash messages and improve a bit: include/header.inc js/common.js styles/theme-base.css
| From: | Dejan Marjanovic | Date: | Sun, 15 Dec 2013 22:13:49 +0000 |
| Subject: | com web/php: Fix duplicate flash messages and improve a bit: include/header.inc js/common.js styles/theme-base.css | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-17648@lists.php.net to get a copy of this message | ||
Commit: 6f0bf1a41a6d0ef56e69b1c60c50d843279c3981
Author: Dejan Marjanovic <dejan.marjanovic@gmail.com> Sun, 15 Dec 2013 23:13:49
+0100
Parents: c2bfb90c016632b2ae5e664f2cfda27cc3f03b69
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=6f0bf1a41a6d0ef56e69b1c60c50d843279c3981
Log:
Fix duplicate flash messages and improve a bit
Changed paths:
M include/header.inc
M js/common.js
M styles/theme-base.css
Diff:
diff --git a/include/header.inc b/include/header.inc
index 8820337..a7e7965 100755
--- a/include/header.inc
+++ b/include/header.inc
@@ -81,7 +81,10 @@ if (isset($shortname) && $shortname) {
<input type="search" name="pattern" class="search-query"
placeholder="Search" accesskey="s">
</form>
</div>
- <div id="flash-message"></div>
+ <div id="flash-message">
+ <div data-type="success" class="message">Hello there</div>
+ <div data-type="error" class="message">Naughty!</div>
+ </div>
</nav>
<?php if (!empty($config['breadcrumbs'])): ?>
diff --git a/js/common.js b/js/common.js
index 1079e21..db08c81 100755
--- a/js/common.js
+++ b/js/common.js
@@ -308,8 +308,8 @@ $(document).ready(function() {
/* {{{ Init template generated flash messages */
$('#flash-message .message').each(function()
{
- var alertType = $(this).data('type');
- var timeout = 6000;
+ var alertType = $(this).data('type') || 'success';
+ var timeout = $(this).data('timeout') || 6000;
var n = flashMessage({
text: $(this).html(),
type: alertType,
@@ -396,22 +396,25 @@ function flashMessage(options)
$(options.parent).append(message);
var o = $('#' + id);
-
+
+ var remove = function(o) {
+ o.slideUp(400, function() {
+ $(this).remove();
+ });
+ };
+
if (options.timeout)
{
setTimeout(function()
{
if ( ! o.length)
return;
- o.slideUp(400, function()
- {
- $(this).remove();
- });
+ remove(o);
}, options.timeout);
}
o.on('click', function() {
- o.remove();
+ remove($(this));
});
return true;
diff --git a/styles/theme-base.css b/styles/theme-base.css
index 13e6149..b3c7ddd 100755
--- a/styles/theme-base.css
+++ b/styles/theme-base..css
@@ -2129,6 +2129,14 @@ aside.tips div.inner {
opacity: 0.9;
}
+#flash-message > div{
+ display: none;
+}
+
+#flash-message > div[id] {
+ display: block;
+}
+
#flash-message .message:last-child {
box-shadow: 0 0.25em 0.25em rgba(0, 0, 0, 0.1);
z-index: -1;