|
|
|
@ -2,6 +2,7 @@ from lib.snabbdom import h, patch
|
|
|
|
|
from message import *
|
|
|
|
|
import random
|
|
|
|
|
from view.utils import *
|
|
|
|
|
from model import Translation, Sense
|
|
|
|
|
|
|
|
|
|
from export import export_to_xml
|
|
|
|
|
|
|
|
|
@ -22,7 +23,7 @@ class View:
|
|
|
|
|
return h("div", {"on": { "click": msg(Reset()) }}, [
|
|
|
|
|
View.view_entry(self.model.entry),
|
|
|
|
|
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)])
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
@ -128,20 +129,29 @@ class View:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def view_menu(location, menu_shown, translation):
|
|
|
|
|
def view_menu(location, menu_target):
|
|
|
|
|
style = {
|
|
|
|
|
"left": "{}px".format(location[0]),
|
|
|
|
|
"top": "{}px".format(location[1])
|
|
|
|
|
}
|
|
|
|
|
if menu_shown:
|
|
|
|
|
style["opacity"] = "1"
|
|
|
|
|
style["visibility"] = "visible"
|
|
|
|
|
|
|
|
|
|
return h("span.popup-menu", { "style": style }, [
|
|
|
|
|
h("button.shyButton", { "on": {"click": msg(ShowEditTranslation(translation))}}, "✎"),
|
|
|
|
|
h("button.shyButton", { "on": {"click": msg(MoveRight(translation))}}, "→"),
|
|
|
|
|
h("button.shyButton", { "on": {"click": msg(MoveLeft(translation))}}, "←"),
|
|
|
|
|
h("button.shyButton", { "on": {"click": msg(BinTranslation(translation))}}, "🗑")])
|
|
|
|
|
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 }, [
|
|
|
|
|
h("button.shyButton", { "on": {"click": msg(ShowEditTranslation(translation))}}, "✎"),
|
|
|
|
|
h("button.shyButton", { "on": {"click": msg(MoveRight(translation))}}, "→"),
|
|
|
|
|
h("button.shyButton", { "on": {"click": msg(MoveLeft(translation))}}, "←"),
|
|
|
|
|
h("button.shyButton", { "on": {"click": msg(BinTranslation(translation))}}, "🗑")])
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
console.log("Should not be heree!!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|