Return-Path: X-Original-To: apmail-tapestry-commits-archive@minotaur.apache.org Delivered-To: apmail-tapestry-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BBCCF6B55 for ; Sat, 2 Jul 2011 19:33:03 +0000 (UTC) Received: (qmail 44850 invoked by uid 500); 2 Jul 2011 19:33:03 -0000 Delivered-To: apmail-tapestry-commits-archive@tapestry.apache.org Received: (qmail 44758 invoked by uid 500); 2 Jul 2011 19:33:02 -0000 Mailing-List: contact commits-help@tapestry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tapestry.apache.org Delivered-To: mailing list commits@tapestry.apache.org Received: (qmail 44751 invoked by uid 99); 2 Jul 2011 19:33:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jul 2011 19:33:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jul 2011 19:33:00 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C00D923888CF for ; Sat, 2 Jul 2011 19:32:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1142279 - in /tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5: t5-console.js tapestry-console.css tapestry-console.js Date: Sat, 02 Jul 2011 19:32:40 -0000 To: commits@tapestry.apache.org From: hlship@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110702193240.C00D923888CF@eris.apache.org> Author: hlship Date: Sat Jul 2 19:32:40 2011 New Revision: 1142279 URL: http://svn.apache.org/viewvc?rev=1142279&view=rev Log: TAP5-999: Improve the "floating" console and make use of the FireBug or WebKit console as well Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.css tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js?rev=1142279&r1=1142278&r2=1142279&view=diff ============================================================================== --- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js (original) +++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-console.js Sat Jul 2 19:32:40 2011 @@ -14,22 +14,36 @@ T5.define("console", function() { - var console; + //FireFox throws an exception is you reference the console when it is not enabled. - function updateConsole(className, message) { - if (!console) { - var console = new Element("div", { "class" : "t-console" }); + var nativeConsoleExists = false; + var nativeConsole = {}; - $(document.body).insert({top: console}); + try { + if (console) { + nativeConsole = console; + nativeConsoleExists = true; + } + } + catch (e) { + } + + var floatingConsole; + + function float(className, message) { + if (!floatingConsole) { + floatingConsole = new Element("div", { "class" : "t-console" }); + + $(document.body).insert({top: floatingConsole}); } - var div = new Element("div", { 'class' : className }).update(message).hide(); + var div = new Element("div", { 'class' : "t-console-entry " + className }).update(message).hide(); - console.insert({ top: div }); + floatingConsole.insert({ top: div }); new Effect.Appear(div, { duration: .25 }); - var effect = new Effect.Fade(div, { delay: T5.console.DURATION, + var effect = new Effect.Fade(div, { delay: T5.console.DURATION, afterFinish: function () { T5.dom.remove(div); } @@ -41,11 +55,20 @@ T5.define("console", function() { }); } - // TODO: replace this with a curry - - function withClassName(className) { + function level(className, consolefn) { return function (message) { - updateConsole(className, message); + float(className, message); + + consolefn && consolefn(message); + } + } + + function error(message) { + float("t-err", message); + + if (nativeConsoleExists) { + console.error(message); + console.trace(); } } @@ -53,9 +76,9 @@ T5.define("console", function() { /** Time, in seconds, that floating console messages are displayed to the user. */ DURATION : 10, - debug : withClassName("t-debug"), - info : withClassName("t-info"), - warn : withClassName("t-warn"), - error : withClassName("t-error") + debug : level("t-debug", nativeConsole.debug), + info : level("t-info", nativeConsole.info), + warn : level("t-warn", nativeConsole.warn), + error : error }; }); \ No newline at end of file Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.css URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.css?rev=1142279&r1=1142278&r2=1142279&view=diff ============================================================================== --- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.css (original) +++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.css Sat Jul 2 19:32:40 2011 @@ -6,9 +6,12 @@ DIV.t-console { left: 2px; } -DIV.t-console DIV { - font-weight: bold; - padding: 0px 2px; +DIV.t-console-entry { + font-weight: bold; + padding: 0px 2px; + cursor: pointer; + border-radius: 5px; + margin-bottom: 5px; } DIV.t-console DIV.t-err { Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js?rev=1142279&r1=1142278&r2=1142279&view=diff ============================================================================== --- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js (original) +++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js Sat Jul 2 19:32:40 2011 @@ -1,4 +1,4 @@ -// Copyright 2009, 2010 The Apache Software Foundation +// Copyright 2009, 2010, 2011 The Apache Software Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,80 +11,17 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -Tapestry.Logging = { - - debug: function(msg) - { - if (Tapestry.DEBUG_ENABLED) - Tapestry.Logging.updateConsole("t-debug", msg); - }, - - info: function(msg) - { - Tapestry.Logging.updateConsole("t-info", msg); - }, - - warn: function(msg) - { - Tapestry.Logging.updateConsole("t-warn", msg); - }, - - error: function(msg) - { - Tapestry.Logging.updateConsole("t-err", msg); - }, - - /** Formats a message and updates the console. The console is virtual - * when FireBug is not present, the messages float in the upper-left corner - * of the page and fade out after a short period. The background color identifies - * the severity of the message (red for error, yellow for warnings, grey for debug). - * Messages can be clicked, which removes the immediately. - * - * When FireBug is present, the error(), warn() and debug() methods do not invoke - * this; instead those functions are rewritten to write entries into the FireBug console. - * - * @param className to use for the div element in the console - * @param message message template - */ - updateConsole : function (className, message) - { - - if (Tapestry.Logging.console == undefined) - Tapestry.Logging.console = Tapestry.Logging.createConsole("t-console"); - - Tapestry.Logging.writeToConsole(Tapestry.Logging.console, className, message); - }, - - createConsole : function(className) - { - var body = $$("BODY").first(); - var console = new Element("div", { 'class': className }); - - body.insert({ top: console }); - - return console; - }, - - writeToConsole : function(console, className, message, slideDown) - { - var div = new Element("div", { 'class': className }).update(message).hide(); +/** + * @deprecated in 5.3, use equivalent T5.console functions instead. + */ +Tapestry.Logging = { - console.insert({ top: div }); + debug : T5.console.debug, - new Effect.Appear(div, { duration: .25 }); + info : T5.console.info, - var effect = new Effect.Fade(div, { delay: Tapestry.CONSOLE_DURATION, - afterFinish: function() - { - Tapestry.remove(div); - }}); + warn : T5.console.warn, - div.observe("click", function() - { - effect.cancel(); - Tapestry.remove(div); - }); - } - -} + error: T5.console.error +}; \ No newline at end of file