Skip to content

Commit

Permalink
Updated how we handle AJAX notifications to users
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Benc committed Jul 27, 2015
1 parent 5eba6d6 commit aae2690
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 23 deletions.
41 changes: 40 additions & 1 deletion PF.Base/less/alerts.less
@@ -1,5 +1,5 @@

div.public_message, div.message, div.error_message, .valid_message {
div.message, div.error_message, .valid_message {
background:@brandInfo;
color:@brandPrimaryColor;
font-size:@fontSizeBase + 2;
Expand All @@ -14,4 +14,43 @@ div.error_message {

.valid_message {
background:@brandSuccess;
}

div.public_message {
.reset();

position:fixed;
bottom:0px;
left:0px;
right:0px;
height:50px;
line-height:50px;
margin-bottom:-50px;
display:none;
z-index:1000000;
background:fade(#2ecc71, 80%);
color:#fff;
font-size:18px;
font-weight:200;
text-align:center;
}

.ajax_processing {
position:fixed;
top:5px;
right:0px;
z-index:100000000;
height:@headerHeight;
text-align:right;
/*background:@topBg;*/
left:auto;


i {
display:inline-block;
font-size:20px;
color:@brandPrimary;
margin-right:10px;
vertical-align:middle;
}
}
5 changes: 2 additions & 3 deletions PF.Base/module/custom/include/component/ajax/ajax.class.php
Expand Up @@ -150,13 +150,12 @@ public function updateFields()

if ($bReturnCustom && $bReturnUser)
{
$this->call('$(\'#js_custom_submit_button\').attr(\'disabled\', false).removeClass(\'disabled\'); $(\'#js_custom_update_info\').html(\''.str_replace("'", "\\'", Phpfox::getPhrase('user.done')).'\').fadeOut(5000);')
->slideDown('#js_custom_public_message');
$this->call('$(\'#public_message\').html(\'Profile successfully updated!\'); $Core.processingEnd(); $Core.loadInit();');
return true;
}
}

$this->call('$(\'#js_custom_submit_button\').attr(\'disabled\', false).removeClass(\'disabled\'); $(\'#js_custom_update_info\').hide();');
$this->call('$(\'#js_custom_submit_button\').attr(\'disabled\', false).removeClass(\'disabled\'); $Core.processingEnd();');

}
}
Expand Down
Expand Up @@ -21,7 +21,7 @@ class Language_Component_Controller_Admincp_Index extends Phpfox_Component
public function process()
{
Phpfox::getUserParam('language.can_manage_lang_packs', true);

if (($sExportId = $this->request()->get('export')))
{
$oArchiveExport = Phpfox::getLib('archive.export')->set(array('zip'));
Expand All @@ -43,14 +43,14 @@ public function process()
}
}

if (PHPFOX_IS_TECHIE) {
// if (PHPFOX_IS_TECHIE) {
$this->template()->setActionMenu([
'New Language' => [
'url' => $this->url()->makeUrl('admincp.language.add'),
'class' => 'popup'
]
]);
}
// }

$this->template()->assign(array(
'aLanguages' => $aLanguages
Expand Down
Expand Up @@ -27,13 +27,7 @@
<div class="clear"></div>
</div>



<div id="js_custom_public_message" class="public_message" style="margin-bottom:10px;">
<a href="{url link='profile'}">{phrase var='user.view_your_updated_profile'}</a>
</div>

<form method="post" action="{url link='user.profile'}"{if !$bIsEdit} onsubmit="{plugin call='user.template_controller_profile_form_onsubmit'} $('#js_custom_public_message').hide(); $('#js_custom_submit_button').attr('disabled', true).addClass('disabled'); $('#js_custom_update_info').html($.ajaxProcess('{phrase var='user.updating_profile' phpfox_squote=true}')).show(); $(this).ajaxCall('custom.updateFields'); return false;"{/if}>
<form method="post" action="{url link='user.profile'}"{if !$bIsEdit} onsubmit="{plugin call='user.template_controller_profile_form_onsubmit'} $Core.processing(); $('#js_custom_submit_button').attr('disabled', true).addClass('disabled'); $(this).ajaxCall('custom.updateFields'); return false;"{/if}>
{if isset($iUserId)}
<div><input type="hidden" name="id" value="{$iUserId}" /></div>
{/if}
Expand Down
17 changes: 17 additions & 0 deletions PF.Base/static/jscript/main.js
Expand Up @@ -2192,6 +2192,23 @@ $Core.reloadPage = function()

$Behavior.addModerationListener = function()
{
var m = $('#public_message');
if (m.length) {
var h = m.html().length;
if (h) {
m.show();
m.animate({
'margin-bottom': '0px'
}, 'fast', function() {
setTimeout(function() {
m.animate({'margin-bottom': '-50px'}, 'fast', function() {
m.html('').hide();
});
}, 1100);
});
}
}

$(window).on('moderation_ended', function(){
/* Search for moderation rows */
if ($('.moderation_row:visible').length < 1)
Expand Down
38 changes: 33 additions & 5 deletions PF.Base/theme/adminpanel/default/style/default/css/custom.css
Expand Up @@ -936,7 +936,6 @@ select:focus {
}
.js_box .table {
padding: 0px;
margin-bottom: 10px;
border: 0px;
}
.js_box .table_clear {
Expand Down Expand Up @@ -1774,7 +1773,6 @@ div#main div.block div.bottom ul li a:hover {
opacity: 1;
}
.error_message,
div.public_message,
div.message {
text-align: left;
background: transparent;
Expand All @@ -1800,18 +1798,48 @@ div.message {
color: #ffffff;
}
.error_message a,
div.public_message a,
div.message a,
.error_message a:hover,
div.public_message a:hover,
div.message a:hover {
color: #ffffff !important;
text-decoration: underline;
}
div.public_message,
div.message {
background: #5bc0de;
}
div.public_message {
text-align: left;
background: transparent;
border-radius: 0px;
box-shadow: none;
color: inherit;
height: auto;
line-height: normal;
position: static;
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
vertical-align: baseline;
width: auto;
float: none;
text-indent: 0px;
position: fixed;
bottom: 0px;
left: 0px;
right: 0px;
height: 50px;
line-height: 50px;
margin-bottom: -50px;
display: none;
z-index: 1000000;
background: rgba(46, 204, 113, 0.8);
color: #fff;
font-size: 18px;
font-weight: 200;
text-align: center;
}
i._aa {
background: #2980b9;
}
Expand Down
23 changes: 21 additions & 2 deletions PF.Base/theme/adminpanel/default/style/default/less/alerts.less
@@ -1,5 +1,5 @@

.error_message, div.public_message, div.message {
.error_message, div.message {
.reset();
.alert();

Expand All @@ -12,6 +12,25 @@
}
}

div.public_message, div.message {
div.message {
background:@brandInfo;
}

div.public_message {
.reset();

position:fixed;
bottom:0px;
left:0px;
right:0px;
height:50px;
line-height:50px;
margin-bottom:-50px;
display:none;
z-index:1000000;
background:fade(#2ecc71, 80%);
color:#fff;
font-size:18px;
font-weight:200;
text-align:center;
}
Expand Up @@ -19,7 +19,6 @@ select, select:focus {
.js_box {
.table {
padding:0px;
margin-bottom:10px;
border:0px;
}

Expand Down
50 changes: 49 additions & 1 deletion PF.Base/theme/default/flavor/default.css
Expand Up @@ -5919,7 +5919,6 @@ a.item_bar_approve:hover {
/* Target only IE7 and IE8 with this hack */
opacity: 0.99;
}
div.public_message,
div.message,
div.error_message,
.valid_message {
Expand All @@ -5936,6 +5935,55 @@ div.error_message {
.valid_message {
background: #5cb85c;
}
div.public_message {
background: transparent;
border-radius: 0px;
box-shadow: none;
color: inherit;
height: auto;
line-height: normal;
position: static;
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
vertical-align: baseline;
width: auto;
float: none;
text-indent: 0px;
position: fixed;
bottom: 0px;
left: 0px;
right: 0px;
height: 50px;
line-height: 50px;
margin-bottom: -50px;
display: none;
z-index: 1000000;
background: rgba(46, 204, 113, 0.8);
color: #fff;
font-size: 18px;
font-weight: 200;
text-align: center;
}
.ajax_processing {
position: fixed;
top: 5px;
right: 0px;
z-index: 100000000;
height: 40px;
text-align: right;
/*background:@topBg;*/
left: auto;
}
.ajax_processing i {
display: inline-block;
font-size: 20px;
color: #298ada;
margin-right: 10px;
vertical-align: middle;
}
#left #js_block_border_music_list,
#right #js_block_border_music_list {
border: 1px #dbdbdb solid;
Expand Down
2 changes: 2 additions & 0 deletions PF.Base/theme/frontend/default/template/error.html.php
Expand Up @@ -25,6 +25,8 @@
$('#public_message').show();
{r};
</script>
{else}
<div class="public_message" id="public_message"></div>
{/if}
<div id="pem"><a href="#"></a></div>
<div id="core_js_messages">
Expand Down

0 comments on commit aae2690

Please sign in to comment.