2015-01-12 02:03:45 +01:00
|
|
|
class Notifications
|
|
|
|
constructor: (@elem) ->
|
|
|
|
@
|
|
|
|
|
|
|
|
test: ->
|
|
|
|
setTimeout (=>
|
|
|
|
@add("connection", "error", "Connection lost to <b>UiServer</b> on <b>localhost</b>!")
|
|
|
|
@add("message-Anyone", "info", "New from <b>Anyone</b>.")
|
|
|
|
), 1000
|
|
|
|
setTimeout (=>
|
|
|
|
@add("connection", "done", "<b>UiServer</b> connection recovered.", 5000)
|
|
|
|
), 3000
|
|
|
|
|
|
|
|
|
|
|
|
add: (id, type, body, timeout=0) ->
|
2017-10-21 11:01:57 +02:00
|
|
|
id = id.replace /[^A-Za-z0-9-]/g, ""
|
2015-01-12 02:03:45 +01:00
|
|
|
# Close notifications with same id
|
|
|
|
for elem in $(".notification-#{id}")
|
|
|
|
@close $(elem)
|
|
|
|
|
|
|
|
# Create element
|
|
|
|
elem = $(".notification.template", @elem).clone().removeClass("template")
|
|
|
|
elem.addClass("notification-#{type}").addClass("notification-#{id}")
|
2017-01-16 13:41:11 +01:00
|
|
|
if type == "progress"
|
|
|
|
elem.addClass("notification-done")
|
2015-01-12 02:03:45 +01:00
|
|
|
|
|
|
|
# Update text
|
|
|
|
if type == "error"
|
|
|
|
$(".notification-icon", elem).html("!")
|
|
|
|
else if type == "done"
|
|
|
|
$(".notification-icon", elem).html("<div class='icon-success'></div>")
|
2017-01-16 13:41:11 +01:00
|
|
|
else if type == "progress"
|
|
|
|
$(".notification-icon", elem).html("<div class='icon-success'></div>")
|
2015-01-21 12:58:26 +01:00
|
|
|
else if type == "ask"
|
|
|
|
$(".notification-icon", elem).html("?")
|
2015-01-12 02:03:45 +01:00
|
|
|
else
|
|
|
|
$(".notification-icon", elem).html("i")
|
|
|
|
|
2015-01-21 12:58:26 +01:00
|
|
|
if typeof(body) == "string"
|
2019-04-08 18:13:58 +02:00
|
|
|
$(".body", elem).html("<div class='message'><span class='multiline'>"+body+"</span></div>")
|
2015-01-21 12:58:26 +01:00
|
|
|
else
|
|
|
|
$(".body", elem).html("").append(body)
|
2015-01-12 02:03:45 +01:00
|
|
|
|
|
|
|
elem.appendTo(@elem)
|
|
|
|
|
|
|
|
# Timeout
|
|
|
|
if timeout
|
|
|
|
$(".close", elem).remove() # No need of close button
|
|
|
|
setTimeout (=>
|
|
|
|
@close elem
|
|
|
|
), timeout
|
|
|
|
|
|
|
|
# Animate
|
2019-10-30 02:28:37 +01:00
|
|
|
width = Math.min(elem.outerWidth() + 50, 580)
|
2015-01-12 02:03:45 +01:00
|
|
|
if not timeout then width += 20 # Add space for close button
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
if elem.outerHeight() > 55 then elem.addClass("long")
|
2015-01-12 02:03:45 +01:00
|
|
|
elem.css({"width": "50px", "transform": "scale(0.01)"})
|
|
|
|
elem.animate({"scale": 1}, 800, "easeOutElastic")
|
|
|
|
elem.animate({"width": width}, 700, "easeInOutCubic")
|
2019-10-30 02:28:37 +01:00
|
|
|
$(".body", elem).css("width": (width - 50))
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
$(".body", elem).cssLater("box-shadow", "0px 0px 5px rgba(0,0,0,0.1)", 1000)
|
2015-01-12 02:03:45 +01:00
|
|
|
|
version 0.3.0, rev187, Trusted authorization sites support, --publish option on signing, cryptSign command line option, OpenSSL enabled on OSX, Crypto verify allows list of valid addresses, Option for version 2 json DB tables, DbCursor SELECT parameters bugfix, Add peer to site on ListModified, Download blind includes when new site added, Publish command better messages, Multi-threaded announce, New http Torrent trackers, Wait for dbschema.json on query, Handle json import errors, More compact writeJson storage command, Testcase for signing and verifying, Workaround to make non target=_top links work, More clean UiWebsocket command route, Send cert_user_id on siteinfo, Notify other local clients on local file modify, Option to wait for file download before sql query, File rules websocket API command, Cert add and select, set websocket API command, Put focus on innerframe, innerloaded wrapper api command to add hashtag, Allow more file error on big sites, Keep worker running after stuked on done task, New more stable openSSL layer that works on OSX, Noparallel parameter bugfix, RateLimit allowed again interval bugfix, Updater skips non-writeable files, Try to close openssl dll before update
2015-05-25 01:26:33 +02:00
|
|
|
# Close button or Confirm button
|
|
|
|
$(".close, .button", elem).on "click", =>
|
2015-01-12 02:03:45 +01:00
|
|
|
@close elem
|
|
|
|
return false
|
|
|
|
|
version 0.3.0, rev187, Trusted authorization sites support, --publish option on signing, cryptSign command line option, OpenSSL enabled on OSX, Crypto verify allows list of valid addresses, Option for version 2 json DB tables, DbCursor SELECT parameters bugfix, Add peer to site on ListModified, Download blind includes when new site added, Publish command better messages, Multi-threaded announce, New http Torrent trackers, Wait for dbschema.json on query, Handle json import errors, More compact writeJson storage command, Testcase for signing and verifying, Workaround to make non target=_top links work, More clean UiWebsocket command route, Send cert_user_id on siteinfo, Notify other local clients on local file modify, Option to wait for file download before sql query, File rules websocket API command, Cert add and select, set websocket API command, Put focus on innerframe, innerloaded wrapper api command to add hashtag, Allow more file error on big sites, Keep worker running after stuked on done task, New more stable openSSL layer that works on OSX, Noparallel parameter bugfix, RateLimit allowed again interval bugfix, Updater skips non-writeable files, Try to close openssl dll before update
2015-05-25 01:26:33 +02:00
|
|
|
# Select list
|
|
|
|
$(".select", elem).on "click", =>
|
2015-01-21 12:58:26 +01:00
|
|
|
@close elem
|
2015-01-12 02:03:45 +01:00
|
|
|
|
2018-03-06 12:07:07 +01:00
|
|
|
# Input enter
|
|
|
|
$("input", elem).on "keyup", (e) =>
|
|
|
|
if e.keyCode == 13
|
|
|
|
@close elem
|
|
|
|
|
2017-01-16 13:41:11 +01:00
|
|
|
return elem
|
|
|
|
|
2015-01-12 02:03:45 +01:00
|
|
|
|
|
|
|
close: (elem) ->
|
|
|
|
elem.stop().animate {"width": 0, "opacity": 0}, 700, "easeInOutCubic"
|
|
|
|
elem.slideUp 300, (-> elem.remove())
|
|
|
|
|
|
|
|
|
|
|
|
log: (args...) ->
|
|
|
|
console.log "[Notifications]", args...
|
|
|
|
|
|
|
|
|
2018-03-06 12:07:07 +01:00
|
|
|
window.Notifications = Notifications
|