Add enable/disable buttons for the client console
- disabled console displays no alerts, but still collects them
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee
index 573a5d3..4eaf6b6 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee
@@ -50,17 +50,37 @@
"""
<div class="console-backdrop"></div>
<div class="alert-container"></div>
- <button class="btn btn-mini"><i class="icon-remove"></i> Clear Console</button>
+ <button data-action="clear" class="btn btn-mini"><i class="icon-remove"></i> Clear Console</button>
+ <button data-action="enable" class="btn btn-mini" disabled="true"><i class="icon-play"></i> Enable Console</button>
+ <button data-action="disable" class="btn btn-mini"><i class="icon-pause"></i> Disable Console</button>
"""
dom.body.prepend floatingConsole
alertContainer = floatingConsole.findFirst ".alert-container"
- floatingConsole.on "click", ".btn-mini", ->
+ floatingConsole.on "click", "[data-action=clear]", ->
floatingConsole.hide()
alertContainer.update ""
+ floatingConsole.on "click", "[data-action=disable]", ->
+
+ @attribute "disabled", true
+ floatingConsole.findFirst("[data-action=enable]").attribute "disabled", false
+
+ alertContainer.hide()
+
+ return false
+
+ floatingConsole.on "click", "[data-action=enable]", ->
+
+ @attribute "disabled", true
+ floatingConsole.findFirst("[data-action=disable]").attribute "disabled", false
+
+ alertContainer.show()
+
+ return false
+
div = dom.create
class: "alert #{className}"
"""
@@ -75,7 +95,6 @@
_.delay -> alertContainer.element.scrollTop = alertContainer.element.scrollHeight
animating = false
- removed = false
runFadeout = ->
return if animating
@@ -84,7 +103,8 @@
div.fadeOut FADE_DURATION, ->
dom.withReflowEventsDisabled ->
- div.remove() unless removed
+ # Remove if not already removed
+ div.remove() if div.parent()
# Hide the console after the last one is removed.
unless floatingConsole.findFirst(".alert")