add dialog + enhance clipboard api

This commit is contained in:
Xuan Sang LE 2020-05-21 17:26:59 +02:00
parent b9ad064928
commit 61a0196c79
2 changed files with 49 additions and 1 deletions

View File

@ -120,6 +120,48 @@ PromptDialog.scheme = """
""" """
this.OS.register "PromptDialog", PromptDialog this.OS.register "PromptDialog", PromptDialog
class TextDialog extends this.OS.GUI.BasicDialog
constructor: () ->
super "TextDialog", TextDialog.scheme
init: () ->
super.init()
$input = $(@find "txtInput")
$input.val @data.value if @data and @data.value
@find("btnOk").set "onbtclick", (e) =>
value = $input.val()
return unless value and value isnt ""
@handle value if @handle
@quit()
@find("btnCancel").set "onbtclick", (e) =>
@quit()
$input.focus()
TextDialog.scheme = """
<afx-app-window data-id = "TextDialog" width='400' height='300'>
<afx-vbox>
<afx-hbox>
<div data-width = "10" />
<afx-vbox>
<div data-height="10" />
<textarea data-id= "txtInput" />
<div data-height="10" />
<afx-hbox data-height="30">
<div />
<afx-button data-id = "btnOk" text = "__(Ok)" data-width = "40" />
<afx-button data-id = "btnCancel" text = "__(Cancel)" data-width = "50" />
</afx-hbox>
</afx-vbox>
<div data-width = "10" />
</afx-hbox>
</afx-vbox>
</afx-app-window>
"""
this.OS.register "TextDialog", TextDialog
class CalendarDialog extends BasicDialog class CalendarDialog extends BasicDialog
constructor: () -> constructor: () ->
super "CalendarDialog" super "CalendarDialog"

View File

@ -400,7 +400,13 @@ Ant.OS.API =
document.execCommand("copy") document.execCommand("copy")
getClipboard: () -> getClipboard: () ->
$("#clipboard").val() new Promise (resolve, reject) ->
$el = $("#clipboard")
return resolve $el.val() unless navigator.clipboard
navigator.clipboard.readText().then (d) ->
resolve d
.catch (e) -> reject e
# utilities functioncs # utilities functioncs
switcher: () -> switcher: () ->