* zin: support to update user toolbar after save user avatar.

This commit is contained in:
sunhao
2023-11-29 14:33:56 +08:00
parent e6b482ba1f
commit 0607f3013a
5 changed files with 22 additions and 19 deletions
-6
View File
@@ -1,6 +0,0 @@
window.updateUserAvatar = function(dialog)
{
const newSrc = $(dialog).find('.avatar-img').prop('src');
const code = $('#toolbar').find('.avatar-img').dataset('code');
$('.avatar-img[data-code="' + code + '"]').prop('src', newSrc);
};
-5
View File
@@ -18,11 +18,6 @@ class header extends wg
'toolbar' => array('map' => 'btn')
);
public static function getPageJS(): string|false
{
return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
}
protected function buildHeading()
{
if($this->hasBlock('heading')) return $this->block('heading');
+14 -1
View File
@@ -730,6 +730,18 @@ function changeAppsTheme(theme)
});
}
function updateUserToolbar()
{
$.each(apps.openedMap, function(_code, app)
{
if(app.iframe && app.iframe.contentWindow && app.iframe.contentWindow.loadPage)
{
app.iframe.contentWindow.loadPage({selector: '#toolbar', partial: true, target: '#toolbar'});
}
});
}
initAppsMenu();
/* Refresh more menu on window resize */
$(window).on('resize', refreshMenu);
@@ -808,7 +820,8 @@ $.apps = $.extend(apps,
getAppCode: getAppCode,
updateAppsMenu: updateAppsMenu,
changeAppsLang: changeAppsLang,
changeAppsTheme: changeAppsTheme
changeAppsTheme: changeAppsTheme,
updateUserToolbar: updateUserToolbar
});
window.notifyMessage = function(data)
+1 -1
View File
@@ -996,7 +996,7 @@ class user extends control
$this->app->user->avatar = $image->webPath;
$this->session->set('user', $this->app->user);
$this->dao->update(TABLE_USER)->set('avatar')->eq($image->webPath)->where('account')->eq($this->app->user->account)->exec();
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'callback' => "loadModal('" . $this->createLink('my', 'profile') . "', 'profile', {}, window.updateUserAvatar);"));
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'callback' => "loadModal('" . $this->createLink('my', 'profile') . "', 'profile', {}, $.apps.updateUserToolbar);"));
}
$this->view->title = $this->lang->user->cropAvatar;
+7 -6
View File
@@ -54,12 +54,13 @@
if(DEBUG) console.log('[APP]', 'update:', {code, url, title});
return state;
},
isOldPage: () => false,
reloadApp: function(_code, url){loadPage(url);},
openApp: function(url, options){loadPage(url, options);},
goBack: function(){history.go(-1);},
changeAppsLang: changeAppLang,
changeAppsTheme: changeAppTheme
isOldPage: () => false,
reloadApp: function(_code, url){loadPage(url);},
openApp: function(url, options){loadPage(url, options);},
goBack: function(){history.go(-1);},
changeAppsLang: changeAppLang,
changeAppsTheme: changeAppTheme,
updateUserToolbar: function(){loadPage({selector: '#toolbar', partial: true, target: '#toolbar'})},
}, parent.window.$.apps);
const renderMap =