Author: nbelaevski
Date: 2010-08-16 07:16:23 -0400 (Mon, 16 Aug 2010)
New Revision: 18652
Added:
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.ecss
Removed:
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css
Modified:
trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractAjaxLog.java
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js
trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
Log:
https://jira.jboss.org/browse/RF-7816
Modified: trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractAjaxLog.java
===================================================================
--- trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractAjaxLog.java 2010-08-16
10:48:28 UTC (rev 18651)
+++ trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractAjaxLog.java 2010-08-16
11:16:23 UTC (rev 18652)
@@ -41,8 +41,8 @@
@ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "richfaces.js") ,
@ResourceDependency(name = "richfaces-base-component.js") ,
- @ResourceDependency(library = "org.richfaces", name =
"log.js"),
- @ResourceDependency(library = "org.richfaces", name =
"log.css")
+ @ResourceDependency(library = "org.richfaces", name =
"log.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"log.ecss")
})
@JsfComponent(
tag = @Tag(name = "log", type = TagType.Facelets),
Deleted: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css
===================================================================
---
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css 2010-08-16
10:48:28 UTC (rev 18651)
+++
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css 2010-08-16
11:16:23 UTC (rev 18652)
@@ -1,10 +0,0 @@
-.rich-log {
- height: 300px;
- overflow: auto;
- width: 100%;
-}
-
-.rich-log-contents {
- font-family: monospace;
- font-size: 14px;
-}
Copied: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.ecss
(from rev 18650,
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css)
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.ecss
(rev 0)
+++
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.ecss 2010-08-16
11:16:23 UTC (rev 18652)
@@ -0,0 +1,43 @@
+.rf-log {
+ color: '#{richSkin.generalTextColor}';
+ height: 300px;
+ overflow: auto;
+ width: 100%;
+}
+
+.rf-log-popup {
+ overflow: visible;
+}
+
+.rf-log-contents {
+ font-family: monospace;
+}
+
+.rf-log-entry-lbl {
+}
+
+.rf-log-entry-lbl-debug {
+ color: darkblue;
+}
+
+.rf-log-entry-lbl-info {
+ color: blue;
+}
+
+.rf-log-entry-lbl-warn {
+ color: gold;
+}
+
+.rf-log-entry-lbl-error {
+ color: red;
+}
+
+.rf-log-entry-msg {
+}
+
+.rf-log-entry-msg-debug, .rf-log-entry-msg-info, .rf-log-entry-msg-warn,
.rf-log-entry-msg-error {
+}
+
+.rf-log-entry-msg-xml {
+ color: dimgray;
+}
\ No newline at end of file
Modified: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js 2010-08-16
10:48:28 UTC (rev 18651)
+++ trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js 2010-08-16
11:16:23 UTC (rev 18652)
@@ -2,19 +2,67 @@
var logLevels = ['debug', 'info', 'warn', 'error'];
var logLevelsPadded = {'debug': 'debug', 'info': 'info
', 'warn': 'warn ', 'error': 'error'};
var logLevelValues = {'debug': 1, 'info': 2, 'warn': 3,
'error': 4};
- var logLevelColors = {'debug': 'darkblue', 'info':
'blue', 'warn': 'gold', 'error': 'red'};
var logClassMethods = {
+ __import: function(doc, node) {
+ if (doc === document) {
+ return node;
+ }
+
+ var result = jquery();
+ for (var i = 0; i < node.length; i++) {
+ if (doc.importNode) {
+ result = result.add(doc.importNode(node[i], true));
+ } else {
+ var container = doc.createElement("div");
+ container.innerHTML = node[i].outerHTML;
+ for (var child = container.firstChild; child; child = child.nextSibling) {
+ result = result.add(child);
+ }
+ }
+ }
+
+ return result;
+ },
+
+ __getStyles: function() {
+ var head = jQuery("head");
+
+ if (head.length == 0) {
+ return "";
+ }
+
+ try {
+ //TODO - BASE element support?
+ var clonedHead = head.clone();
+ if (clonedHead.children().length == head.children().length) {
+ return
clonedHead.children(":not(style):not(link[rel='stylesheet'])").remove().end().html();
+ } else {
+ var result = new Array();
+ head.children("style, link[rel='stylesheet']").each(function() {
+ result.push(this.outerHTML);
+ });
+
+ return result.join('');
+ }
+ } catch (e) {
+ return "";
+ }
+ },
+
__openPopup: function() {
if (!this.__popupWindow || this.__popupWindow.closed) {
this.__popupWindow = open("", "_richfaces_logWindow",
"height=400, width=600, resizable = yes, status=no, " +
"scrollbars = yes, statusbar=no, toolbar=no, menubar=no, location=no");
- this.__popupWindow.document.write("<html><head></head><body><div
id='richfaces.log'></div></body></html>");
- this.__popupWindow.document.close();
- this.__consoleElement = jquery("#richfaces\\.log",
this.__popupWindow.document);
- this.__initializeControls();
+ var doc = this.__popupWindow.document;
+
+ doc.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" +
+ "<html
xmlns=\"http://www.w3.org/1999/xhtml\"><head>" +
this.__getStyles() + "</head>" +
+ "<body onunload='window.close()'><div
id='richfaces.log' clas='rf-log
rf-log-popup'></div></body></html>");
+ doc.close();
+ this.__initializeControls(doc);
} else {
this.__popupWindow.focus();
}
@@ -32,7 +80,7 @@
var date = new Date();
var timeString = this.__lzpad(date.getHours(), 2) + ':' +
this.__lzpad(date.getMinutes(), 2) + ':' +
- this.__lzpad(date.getSeconds(), 2) + '.' +
this.__lzpad(date.getMilliseconds(), 3);
+ this.__lzpad(date.getSeconds(), 2) + '.' +
this.__lzpad(date.getMilliseconds(), 3);
return timeString;
},
@@ -55,54 +103,68 @@
this.setLevel(event.target.value);
},
- __initializeControls : function() {
- var console = this.__consoleElement;
-
- var clearBtn = console.children("button.rich-log-element");
+ __initializeControls : function(doc) {
+ var console = jquery("#richfaces\\.log", doc);
+
+ var clearBtn = console.children("button.rf-log-element");
if (clearBtn.length == 0) {
- clearBtn = jquery("<button type='button'
class='rich-log-element'>Clear</button>").appendTo(console);
+ clearBtn = jquery("<button type='button'
class='rf-log-element'>Clear</button>", doc).appendTo(console);
}
clearBtn.click(jquery.proxy(this.clear, this));
- var levelSelect = console.children("select.rich-log-element");
+ var levelSelect = console.children("select.rf-log-element");
if (levelSelect.length == 0) {
- levelSelect = jquery("<select class='rich-log-element'
name='richfaces.log' />").appendTo(console);
+ levelSelect = jquery("<select class='rf-log-element'
name='richfaces.log' />", doc).appendTo(console);
}
if (levelSelect.children().length == 0) {
for (var l = 0; l < logLevels.length; l++) {
- jquery("<option value='" + logLevels[l]+ "'>" +
logLevels[l] + "</option>").appendTo(levelSelect);
+ jquery("<option value='" + logLevels[l]+ "'>" +
logLevels[l] + "</option>", doc).appendTo(levelSelect);
}
}
levelSelect.val(this.getLevel());
levelSelect.change(jquery.proxy(this.__setLevelFromSelect, this));
- var consoleEntries = console.children(".rich-log-contents");
+ var consoleEntries = console.children(".rf-log-contents");
if (consoleEntries.length == 0) {
- consoleEntries = jquery("<div
class='rich-log-contents'></div>").appendTo(console);
+ consoleEntries = jquery("<div
class='rf-log-contents'></div>", doc).appendTo(console);
}
+ this.__contentsElement = consoleEntries;
},
+ __append: function(element) {
+ var target = this.__contentsElement;
+ if (this.mode == "popup") {
+ var doc = this.__popupWindow.document;
+ jquery(doc.createElement("div")).appendTo(target).append(this.__import(doc,
element));
+ } else {
+ jquery(document.createElement("div")).appendTo(target).append(element);
+ }
+ },
+
__log: function(level, message) {
//TODO scroll to the added message
- if (!this.__consoleElement) {
+ //TODO check popup is opened
+ if (!this.__contentsElement) {
return;
}
- var console = this.__consoleElement;
-
if (logLevelValues[level] >= logLevelValues[this.getLevel()]) {
- var newEntry =
jquery(document.createElement("div")).appendTo(console.children(".rich-log-contents"));
- jquery("<span style='color: " + logLevelColors[level] +
"'></span>").appendTo(newEntry).text(this.__getMessagePrefix(level));
+ var newEntry = jquery();
+ newEntry = newEntry.add(jquery("<span class='rf-log-entry-lbl
rf-log-entry-lbl-" + level +
"'></span>").text(this.__getMessagePrefix(level)));
- var entrySpan = jquery(document.createElement("span")).appendTo(newEntry);
+ var entrySpan = jquery("<span class='rf-log-entry-msg
rf-log-entry-msg-" + level + "'></span>");
if (typeof message != 'object' || !message.appendTo) {
entrySpan.text(message);
} else {
message.appendTo(entrySpan);
}
+
+ newEntry = newEntry.add(entrySpan);
+
+ this.__append(newEntry);
}
},
@@ -115,8 +177,7 @@
this.__boundHotkeyHandler = jquery.proxy(this.__hotkeyHandler, this);
jquery(document).bind('keydown', this.__boundHotkeyHandler);
} else {
- this.__consoleElement = jquery("#richfaces\\.log");
- this.__initializeControls();
+ this.__initializeControls(document);
}
},
@@ -127,10 +188,12 @@
}
this.__popupWindow = null;
- jquery(document).unbind('keydown', this.__boundHotkeyHandler);
- this.__boundHotkeyHandler = null;
+ if (this.__boundHotkeyHandler) {
+ jquery(document).unbind('keydown', this.__boundHotkeyHandler);
+ this.__boundHotkeyHandler = null;
+ }
- this.__consoleElement = null;
+ this.__contentsElement = null;
this.$super.destroy.call(this);
},
@@ -144,7 +207,9 @@
},
clear: function() {
- this.__consoleElement.children(".rich-log-contents").children().remove();
+ if (this.__contentsElement) {
+ this.__contentsElement.children().remove();
+ }
}
};
@@ -188,7 +253,7 @@
}
jQuery(document.createElement("br")).appendTo(logElement);
- jQuery("<span
style='color:dimgray'></span>").appendTo(logElement).text(change.toXML());
+ jQuery("<span
class='rf-log-entry-msg-xml'></span>").appendTo(logElement).text(change.toXML());
jQuery(document.createElement("br")).appendTo(logElement);
}
@@ -231,7 +296,7 @@
partialResponse = jQuery(responseXML).children("partial-response");
}
- var responseTextEntry = jQuery("<span>Server returned responseText:
</span><span
style='color:dimgray'></span>").eq(1).text(responseText).end();
+ var responseTextEntry = jQuery("<span>Server returned responseText:
</span><span
class='rf-log-entry-msg-xml'></span>").eq(1).text(responseText).end();
if (partialResponse && partialResponse.length) {
log.debug(responseTextEntry);
Modified:
trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
===================================================================
---
trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml 2010-08-16
10:48:28 UTC (rev 18651)
+++
trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml 2010-08-16
11:16:23 UTC (rev 18652)
@@ -12,12 +12,13 @@
</cc:interface>
<cc:implementation>
- <div id="richfaces.log" class="rich-log
#{component.attributes['styleClass']}">
+ <div id="richfaces.log" class="rf-log
#{component.attributes['styleClass']}">
<script type="text/javascript">
RichFaces.log = new RichFaces.HtmlLog({
level: "#{component.attributes['level']}",
hotkey: "#{component.attributes['hotkey']}",
mode: "#{component.attributes['mode']}"
+ /* TODO: pass styleClass in */
});
</script>
</div>