mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-11-08 14:08:22 +01:00
add dialog + enhance clipboard api
This commit is contained in:
parent
b9ad064928
commit
61a0196c79
@ -120,6 +120,48 @@ PromptDialog.scheme = """
|
||||
"""
|
||||
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
|
||||
constructor: () ->
|
||||
super "CalendarDialog"
|
||||
|
@ -400,7 +400,13 @@ Ant.OS.API =
|
||||
document.execCommand("copy")
|
||||
|
||||
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
|
||||
switcher: () ->
|
||||
|
Loading…
Reference in New Issue
Block a user