You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2013/07/22 01:49:32 UTC

[3/6] git commit: Limit the height of the floating console Scroll to the bottom when new alert added

Limit the height of the floating console
Scroll to the bottom when new alert added


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/fdda179e
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/fdda179e
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/fdda179e

Branch: refs/heads/master
Commit: fdda179e75165b189d1f9152d2c17901d4742d63
Parents: 9689b26
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Sun Jul 21 16:02:30 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Sun Jul 21 16:02:30 2013 -0700

----------------------------------------------------------------------
 .../META-INF/modules/t5/core/console.coffee           | 14 +++++++++++---
 .../org/apache/tapestry5/t5-core-dom.coffee           |  2 +-
 .../META-INF/assets/tapestry5/tapestry-console.css    |  5 +++++
 3 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fdda179e/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee
----------------------------------------------------------------------
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 1e2de33..2a3794c 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
@@ -20,6 +20,7 @@ define ["./dom", "underscore"],
 
     nativeConsole = {}
     floatingConsole = null
+    alertContainer = null
 
     forceFloating = (dom.body.attribute "data-floating-console") == "true"
 
@@ -45,14 +46,17 @@ define ["./dom", "underscore"],
           class: "tapestry-console",
           """
             <div class="console-backdrop"></div>
-            <div data-content="alerts"></div>
+            <div class="alert-container"></div>
             <button class="btn btn-mini"><i class="icon-remove"></i> Clear Console</button>
             """
 
         dom.body.prepend floatingConsole
 
+        alertContainer = floatingConsole.findFirst ".alert-container"
+
         floatingConsole.on "click", ".btn-mini", ->
-          floatingConsole.hide().findFirst("[data-content=alerts]").update ""
+          floatingConsole.hide()
+          alertContainer.update ""
 
       div = dom.create
         class: "alert #{className}"
@@ -61,7 +65,11 @@ define ["./dom", "underscore"],
           #{_.escape message}
         """
 
-      floatingConsole.show().findFirst("[data-content=alerts]").append div.hide().fadeIn FADE_DURATION
+      floatingConsole.show()
+      alertContainer.append div.hide().fadeIn FADE_DURATION
+
+      # A slightly clumsy way to ensure that the container is scrolled to the bottom.
+      _.delay -> alertContainer.element.scrollTop = alertContainer.element.scrollHeight
 
       animating = false
       removed = false

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fdda179e/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee b/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee
index 6b1ce81..f141f3d 100644
--- a/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee
+++ b/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee
@@ -641,7 +641,7 @@ define ["underscore", "./utils", "./events", "jquery"],
 #endif
       return current
 
-    # Returns true if a checkbox is checked
+    # Returns true if element is a checkbox and is checked
     checked: ->
       @element.checked
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fdda179e/tapestry-core/src/main/resources/META-INF/assets/tapestry5/tapestry-console.css
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/META-INF/assets/tapestry5/tapestry-console.css b/tapestry-core/src/main/resources/META-INF/assets/tapestry5/tapestry-console.css
index 4f9d62f..55eb257 100644
--- a/tapestry-core/src/main/resources/META-INF/assets/tapestry5/tapestry-console.css
+++ b/tapestry-core/src/main/resources/META-INF/assets/tapestry5/tapestry-console.css
@@ -20,6 +20,11 @@
     z-index: -1;
 }
 
+.tapestry-console > .alert-container {
+    max-height: 300px;
+    overflow-x: auto;
+}
+
 /** Unlike a normal alert, a console message can be dismissed by a click anywhere. */
 .tapestry-console .alert{
     cursor: pointer;