diff --git a/common/css/rhymix.less b/common/css/rhymix.less index 22ff2d8f1..240ed9001 100644 --- a/common/css/rhymix.less +++ b/common/css/rhymix.less @@ -157,6 +157,26 @@ a img { background: #333 url("../../common/img/msg.loading.gif") no-repeat center 15px; } +/* alert */ +#rhymix_alert { + display: none; + position: fixed; + left: 50%; + bottom: 20%; + min-width: 250px; + max-width: 500px; + background-color: #000; + color: #fff; + font-size: 16px; + text-align: center; + opacity: 0.6; + padding: 12px 20px; + border: 1px solid #fff; + border-radius: 10px; + transform: translateX(-50%); + z-index: 999999999; +} + /* Debug */ #rhymix_debug_button { display: none; diff --git a/common/js/common.js b/common/js/common.js index e435d1f4e..b7cbdf891 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -82,6 +82,44 @@ } }; + window.rhymix_alert_close = function() { + if($('#rhymix_alert').is(':hidden')) { + return; + } + $('#rhymix_alert').fadeOut(500, function() { + $(this).empty(); + }); + }; + + /** + * @brief display alert + */ + window.rhymix_alert = function(message, redirect_url, delay) { + if(!delay) { + delay = 2500; + } + if(!redirect_url) { + $('#rhymix_alert').text(message).show(); + setTimeout(rhymix_alert_close, delay); + } + else if(isSameOrigin(location.href, redirect_url)) { + Cookies.set('rhymix_alert_message', message, { expires: 1 / 1440, path: '' }); + Cookies.set('rhymix_alert_delay', delay, { expires: 1 / 1440, path: '' }); + } + else { + alert(message); + } + }; + + $(document).ready(function() { + if(Cookies.get('rhymix_alert_message')) { + rhymix_alert(Cookies.get('rhymix_alert_message'), null, Cookies.get('rhymix_alert_delay')); + Cookies.remove('rhymix_alert_message', { path: '' }); + Cookies.remove('rhymix_alert_delay', { path: '' }); + } + $('#rhymix_alert').click(rhymix_alert_close); + }); + /* Array for pending debug data */ window.rhymix_debug_pending_data = []; @@ -531,10 +569,7 @@ function sendMailTo(to) { * @brief url이동 (Rhymix 개선된 버전) */ function redirect(url) { - var absolute_url = window.location.href; - var relative_url = window.location.pathname + window.location.search; - if (url === absolute_url || url.indexOf(absolute_url.replace(/#.+$/, "") + "#") === 0 || - url === relative_url || url.indexOf(relative_url.replace(/#.+$/, "") + "#") === 0) { + if (isCurrentPageUrl(url)) { window.location.href = url; window.location.reload(); } else { @@ -542,6 +577,13 @@ function redirect(url) { } } +function isCurrentPageUrl(url) { + var absolute_url = window.location.href; + var relative_url = window.location.pathname + window.location.search; + return url === absolute_url || url.indexOf(absolute_url.replace(/#.+$/, "") + "#") === 0 || + url === relative_url || url.indexOf(relative_url.replace(/#.+$/, "") + "#") === 0; +} + /** * @brief url이동 (open_window 값이 N 가 아니면 새창으로 띄움) **/ diff --git a/common/js/xml_handler.js b/common/js/xml_handler.js index 47ff8bc2b..3e3a08f3f 100644 --- a/common/js/xml_handler.js +++ b/common/js/xml_handler.js @@ -376,7 +376,15 @@ if (callback_success && window[callback_success] && $.isFunction(window[callback_success])) { callback_success = window[callback_success]; } else { - callback_success = null; + callback_success = function(data) { + if (data.message === 'success') { + return; + } + rhymix_alert(data.message, data.redirect_url); + if (data.redirect_url) { + redirect(data.redirect_url); + } + }; } var callback_error = form.data('callback-error'); if (callback_error && window[callback_error] && $.isFunction(window[callback_error])) { diff --git a/common/tpl/common_layout.html b/common/tpl/common_layout.html index 43bd43d4d..3e7d26f59 100644 --- a/common/tpl/common_layout.html +++ b/common/tpl/common_layout.html @@ -72,6 +72,7 @@