Commit: 0c9a8d38562c9c74bc3a200401de515d4d286861 Author: Dejan Marjanovic <[email protected]> Sun, 15 Dec 2013 23:13:49 +0100 Parents: b74ce060629aa5df3e157ff7f35a3358982b1c72 Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=0c9a8d38562c9c74bc3a200401de515d4d286861 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; -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
