Create wrapper html tags based on attributes instead of raw html
This commit is contained in:
parent
9dabd1f344
commit
e93b5c3c1c
1 changed files with 8 additions and 6 deletions
|
@ -41,6 +41,7 @@ class Wrapper
|
||||||
|
|
||||||
$("#inner-iframe").focus()
|
$("#inner-iframe").focus()
|
||||||
|
|
||||||
|
|
||||||
verifyEvent: (allowed_target, e) =>
|
verifyEvent: (allowed_target, e) =>
|
||||||
if not e.originalEvent.isTrusted
|
if not e.originalEvent.isTrusted
|
||||||
throw "Event not trusted"
|
throw "Event not trusted"
|
||||||
|
@ -239,12 +240,13 @@ class Wrapper
|
||||||
body = $("<span class='message'>"+message.params[1]+"</span>")
|
body = $("<span class='message'>"+message.params[1]+"</span>")
|
||||||
@notifications.add("notification-#{message.id}", message.params[0], body, message.params[2])
|
@notifications.add("notification-#{message.id}", message.params[0], body, message.params[2])
|
||||||
|
|
||||||
displayConfirm: (message, captions, cb) ->
|
displayConfirm: (body, captions, cb) ->
|
||||||
body = $("<span class='message-outer'><span class='message'>"+message+"</span></span>")
|
body = $("<span class='message-outer'><span class='message'>"+body+"</span></span>")
|
||||||
buttons = $("<span class='buttons'></span>")
|
buttons = $("<span class='buttons'></span>")
|
||||||
if captions not instanceof Array then captions = [captions] # Convert to list if necessary
|
if captions not instanceof Array then captions = [captions] # Convert to list if necessary
|
||||||
for caption, i in captions
|
for caption, i in captions
|
||||||
button = $("<a href='##{caption}' class='button button-confirm button-#{caption} button-#{i+1}' data-value='#{i+1}'>#{caption}</a>") # Add confirm button
|
button = $("<a></a>", {href: "#" + caption, class: "button button-confirm button-#{caption} button-#{i+1}", "data-value": i + 1}) # Add confirm button
|
||||||
|
button.text(caption)
|
||||||
((button) =>
|
((button) =>
|
||||||
button.on "click", (e) =>
|
button.on "click", (e) =>
|
||||||
@verifyEvent button, e
|
@verifyEvent button, e
|
||||||
|
@ -268,17 +270,17 @@ class Wrapper
|
||||||
|
|
||||||
|
|
||||||
displayPrompt: (message, type, caption, placeholder, cb) ->
|
displayPrompt: (message, type, caption, placeholder, cb) ->
|
||||||
body = $("<span class='message'>"+message+"</span>")
|
body = $("<span class='message'></span>").text(message)
|
||||||
placeholder ?= ""
|
placeholder ?= ""
|
||||||
|
|
||||||
input = $("<input type='#{type}' class='input button-#{type}' placeholder='#{placeholder}'/>") # Add input
|
input = $("<input/>", {type: type, class: "input button-#{type}", placeholder: placeholder}) # Add input
|
||||||
input.on "keyup", (e) => # Send on enter
|
input.on "keyup", (e) => # Send on enter
|
||||||
@verifyEvent input, e
|
@verifyEvent input, e
|
||||||
if e.keyCode == 13
|
if e.keyCode == 13
|
||||||
cb input.val() # Response to confirm
|
cb input.val() # Response to confirm
|
||||||
body.append(input)
|
body.append(input)
|
||||||
|
|
||||||
button = $("<a href='##{caption}' class='button button-#{caption}'>#{caption}</a>") # Add confirm button
|
button = $("<a></a>", {href: "#" + caption, class: "button button-#{caption}"}).text(caption) # Add confirm button
|
||||||
button.on "click", (e) => # Response on button click
|
button.on "click", (e) => # Response on button click
|
||||||
@verifyEvent button, e
|
@verifyEvent button, e
|
||||||
cb input.val()
|
cb input.val()
|
||||||
|
|
Loading…
Reference in a new issue