Refactored show menu so that it will be able to accept sense
This commit is contained in:
parent
1f038e177a
commit
bcd8d3ced9
|
@ -194,9 +194,9 @@
|
||||||
background-color: @white;
|
background-color: @white;
|
||||||
border-radius: 0.2em;
|
border-radius: 0.2em;
|
||||||
|
|
||||||
// by default hidden
|
// by default shown
|
||||||
visibility: hidden;
|
visibility: visible;
|
||||||
opacity: 0;
|
opacity: 1;
|
||||||
transition: visibility 0s, opacity 0.1s linear;
|
transition: visibility 0s, opacity 0.1s linear;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
|
|
|
@ -14,8 +14,8 @@ class ShowMenu(ClickMessage):
|
||||||
|
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
model.menu_location = self.menu_location
|
model.menu_location = self.menu_location
|
||||||
model.menu_shown = True
|
|
||||||
model.translation = self.get_arg(0, Translation)
|
model.translation = self.get_arg(0, Translation)
|
||||||
|
model.menu_target = model.translation
|
||||||
|
|
||||||
|
|
||||||
class ShowSenseLabelEdit(ClickMessage):
|
class ShowSenseLabelEdit(ClickMessage):
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Model:
|
||||||
|
|
||||||
#runtime info
|
#runtime info
|
||||||
self.menu_location = (0, 0)
|
self.menu_location = (0, 0)
|
||||||
self.menu_shown = False
|
self.menu_target = None
|
||||||
|
|
||||||
# modal handling
|
# modal handling
|
||||||
self.modal = lambda: []
|
self.modal = lambda: []
|
||||||
|
@ -25,7 +25,7 @@ class Model:
|
||||||
self.modal_reset()
|
self.modal_reset()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.menu_shown = False
|
self.menu_target = None
|
||||||
self.modal_shown = False
|
self.modal_shown = False
|
||||||
|
|
||||||
def modal_reset(self):
|
def modal_reset(self):
|
||||||
|
|
|
@ -2,6 +2,7 @@ from lib.snabbdom import h, patch
|
||||||
from message import *
|
from message import *
|
||||||
import random
|
import random
|
||||||
from view.utils import *
|
from view.utils import *
|
||||||
|
from model import Translation, Sense
|
||||||
|
|
||||||
from export import export_to_xml
|
from export import export_to_xml
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ class View:
|
||||||
return h("div", {"on": { "click": msg(Reset()) }}, [
|
return h("div", {"on": { "click": msg(Reset()) }}, [
|
||||||
View.view_entry(self.model.entry),
|
View.view_entry(self.model.entry),
|
||||||
h("button.blk", {"on": { "click": lambda _: console.log(export_to_xml(self.model)) } }, "XML2Console"),
|
h("button.blk", {"on": { "click": lambda _: console.log(export_to_xml(self.model)) } }, "XML2Console"),
|
||||||
View.view_menu(self.model.menu_location, self.model.menu_shown, self.model.translation),
|
View.view_menu(self.model.menu_location, self.model.menu_target),
|
||||||
View.view_modal(self.model.modal_shown, self.model.modal)])
|
View.view_modal(self.model.modal_shown, self.model.modal)])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -128,21 +129,30 @@ class View:
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def view_menu(location, menu_shown, translation):
|
def view_menu(location, menu_target):
|
||||||
style = {
|
style = {
|
||||||
"left": "{}px".format(location[0]),
|
"left": "{}px".format(location[0]),
|
||||||
"top": "{}px".format(location[1])
|
"top": "{}px".format(location[1])
|
||||||
}
|
}
|
||||||
if menu_shown:
|
|
||||||
style["opacity"] = "1"
|
|
||||||
style["visibility"] = "visible"
|
|
||||||
|
|
||||||
|
console.log(menu_target)
|
||||||
|
console.log(type(menu_target))
|
||||||
|
|
||||||
|
if menu_target is None:
|
||||||
|
style["opacity"] = "0"
|
||||||
|
style["visibility"] = "hidden"
|
||||||
|
|
||||||
|
elif type(menu_target) is Translation:
|
||||||
|
translation = menu_target
|
||||||
return h("span.popup-menu", { "style": style }, [
|
return h("span.popup-menu", { "style": style }, [
|
||||||
h("button.shyButton", { "on": {"click": msg(ShowEditTranslation(translation))}}, "✎"),
|
h("button.shyButton", { "on": {"click": msg(ShowEditTranslation(translation))}}, "✎"),
|
||||||
h("button.shyButton", { "on": {"click": msg(MoveRight(translation))}}, "→"),
|
h("button.shyButton", { "on": {"click": msg(MoveRight(translation))}}, "→"),
|
||||||
h("button.shyButton", { "on": {"click": msg(MoveLeft(translation))}}, "←"),
|
h("button.shyButton", { "on": {"click": msg(MoveLeft(translation))}}, "←"),
|
||||||
h("button.shyButton", { "on": {"click": msg(BinTranslation(translation))}}, "🗑")])
|
h("button.shyButton", { "on": {"click": msg(BinTranslation(translation))}}, "🗑")])
|
||||||
|
|
||||||
|
else:
|
||||||
|
console.log("Should not be heree!!")
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def view_modal(modal_shown, modal):
|
def view_modal(modal_shown, modal):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user