From e93b5c3c1c971c1bebfa5dcce994e7060fc0a88c Mon Sep 17 00:00:00 2001 From: shortcutme Date: Tue, 6 Mar 2018 12:02:39 +0100 Subject: [PATCH] Create wrapper html tags based on attributes instead of raw html --- src/Ui/media/Wrapper.coffee | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Ui/media/Wrapper.coffee b/src/Ui/media/Wrapper.coffee index d2a7ac6a..5f0cfeb6 100644 --- a/src/Ui/media/Wrapper.coffee +++ b/src/Ui/media/Wrapper.coffee @@ -41,6 +41,7 @@ class Wrapper $("#inner-iframe").focus() + verifyEvent: (allowed_target, e) => if not e.originalEvent.isTrusted throw "Event not trusted" @@ -239,12 +240,13 @@ class Wrapper body = $(""+message.params[1]+"") @notifications.add("notification-#{message.id}", message.params[0], body, message.params[2]) - displayConfirm: (message, captions, cb) -> - body = $(""+message+"") + displayConfirm: (body, captions, cb) -> + body = $(""+body+"") buttons = $("") if captions not instanceof Array then captions = [captions] # Convert to list if necessary for caption, i in captions - button = $("#{caption}") # Add confirm button + button = $("", {href: "#" + caption, class: "button button-confirm button-#{caption} button-#{i+1}", "data-value": i + 1}) # Add confirm button + button.text(caption) ((button) => button.on "click", (e) => @verifyEvent button, e @@ -268,17 +270,17 @@ class Wrapper displayPrompt: (message, type, caption, placeholder, cb) -> - body = $(""+message+"") + body = $("").text(message) placeholder ?= "" - input = $("") # Add input + input = $("", {type: type, class: "input button-#{type}", placeholder: placeholder}) # Add input input.on "keyup", (e) => # Send on enter @verifyEvent input, e if e.keyCode == 13 cb input.val() # Response to confirm body.append(input) - button = $("#{caption}") # Add confirm button + button = $("", {href: "#" + caption, class: "button button-#{caption}"}).text(caption) # Add confirm button button.on "click", (e) => # Response on button click @verifyEvent button, e cb input.val()