Integrate IV menu hiding by click inside WebView.
This commit is contained in:
parent
5c8e6c3012
commit
5c32423597
|
@ -88,6 +88,12 @@ html.custom_scroll ::-webkit-scrollbar-thumb:hover {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#menu_page_blocker {
|
||||||
|
z-index: 999;
|
||||||
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
#top_shadow {
|
#top_shadow {
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|
|
@ -8,6 +8,11 @@ var IV = {
|
||||||
var target = e.target;
|
var target = e.target;
|
||||||
var context = '';
|
var context = '';
|
||||||
while (target) {
|
while (target) {
|
||||||
|
if (target.id == 'menu_page_blocker') {
|
||||||
|
IV.notify({ event: 'menu_page_blocker_click' });
|
||||||
|
IV.menuShown(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (target.tagName == 'AUDIO' || target.tagName == 'VIDEO') {
|
if (target.tagName == 'AUDIO' || target.tagName == 'VIDEO') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -599,6 +604,20 @@ var IV = {
|
||||||
back: function () {
|
back: function () {
|
||||||
window.history.back();
|
window.history.back();
|
||||||
},
|
},
|
||||||
|
menuShown: function (shown) {
|
||||||
|
var already = document.getElementById('menu_page_blocker');
|
||||||
|
if (already && shown) {
|
||||||
|
return;
|
||||||
|
} else if (already) {
|
||||||
|
document.body.removeChild(already);
|
||||||
|
return;
|
||||||
|
} else if (!shown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var blocker = document.createElement('div');
|
||||||
|
blocker.id = 'menu_page_blocker';
|
||||||
|
document.body.appendChild(blocker);
|
||||||
|
},
|
||||||
|
|
||||||
videos: {},
|
videos: {},
|
||||||
videosPlaying: {},
|
videosPlaying: {},
|
||||||
|
|
|
@ -429,6 +429,10 @@ void Controller::createWebview(const QString &dataPath) {
|
||||||
const auto url = object.value("url").toString();
|
const auto url = object.value("url").toString();
|
||||||
const auto context = object.value("context").toString();
|
const auto context = object.value("context").toString();
|
||||||
processLink(url, context);
|
processLink(url, context);
|
||||||
|
} else if (event == "menu_page_blocker_click") {
|
||||||
|
if (_menu) {
|
||||||
|
_menu->hideMenu();
|
||||||
|
}
|
||||||
} else if (event == u"ready"_q) {
|
} else if (event == u"ready"_q) {
|
||||||
_ready = true;
|
_ready = true;
|
||||||
auto script = QByteArray();
|
auto script = QByteArray();
|
||||||
|
@ -443,6 +447,9 @@ void Controller::createWebview(const QString &dataPath) {
|
||||||
if (base::take(_reloadInitialWhenReady)) {
|
if (base::take(_reloadInitialWhenReady)) {
|
||||||
script += reloadScript(0);
|
script += reloadScript(0);
|
||||||
}
|
}
|
||||||
|
if (_menu) {
|
||||||
|
script += "IV.menuShown(true);";
|
||||||
|
}
|
||||||
if (!script.isEmpty()) {
|
if (!script.isEmpty()) {
|
||||||
_webview->eval(script);
|
_webview->eval(script);
|
||||||
}
|
}
|
||||||
|
@ -648,7 +655,7 @@ bool Controller::active() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::showJoinedTooltip() {
|
void Controller::showJoinedTooltip() {
|
||||||
if (_webview) {
|
if (_webview && _ready) {
|
||||||
_webview->eval("IV.showTooltip('"
|
_webview->eval("IV.showTooltip('"
|
||||||
+ EscapeForScriptString(
|
+ EscapeForScriptString(
|
||||||
tr::lng_action_you_joined(tr::now).toUtf8())
|
tr::lng_action_you_joined(tr::now).toUtf8())
|
||||||
|
@ -679,6 +686,9 @@ void Controller::showMenu() {
|
||||||
_menu = base::make_unique_q<Ui::PopupMenu>(
|
_menu = base::make_unique_q<Ui::PopupMenu>(
|
||||||
_window.get(),
|
_window.get(),
|
||||||
st::popupMenuWithIcons);
|
st::popupMenuWithIcons);
|
||||||
|
if (_webview && _ready) {
|
||||||
|
_webview->eval("IV.menuShown(true);");
|
||||||
|
}
|
||||||
_menu->setDestroyedCallback(crl::guard(_window.get(), [
|
_menu->setDestroyedCallback(crl::guard(_window.get(), [
|
||||||
this,
|
this,
|
||||||
weakButton = Ui::MakeWeak(_menuToggle.data()),
|
weakButton = Ui::MakeWeak(_menuToggle.data()),
|
||||||
|
@ -686,6 +696,13 @@ void Controller::showMenu() {
|
||||||
if (_menu == menu && weakButton) {
|
if (_menu == menu && weakButton) {
|
||||||
weakButton->setForceRippled(false);
|
weakButton->setForceRippled(false);
|
||||||
}
|
}
|
||||||
|
if (const auto widget = _webview ? _webview->widget() : nullptr) {
|
||||||
|
InvokeQueued(widget, crl::guard(_window.get(), [=] {
|
||||||
|
if (_webview && _ready) {
|
||||||
|
_webview->eval("IV.menuShown(false);");
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
_menuToggle->setForceRippled(true);
|
_menuToggle->setForceRippled(true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue