You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2011/08/10 10:11:11 UTC
svn commit: r1156061 - in
/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard: ./
src/main/resources/META-INF/
src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/
Author: lofwyr
Date: Wed Aug 10 08:11:10 2011
New Revision: 1156061
URL: http://svn.apache.org/viewvc?rev=1156061&view=rev
Log:
TOBAGO-377: Improved Tree
- tree works now, when loaded via AJAX
- clean up JavaScript code for the tree
- remove own JavaScript file for the tree
Removed:
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js
Modified:
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml?rev=1156061&r1=1156060&r2=1156061&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml Wed Aug 10 08:11:10 2011
@@ -60,7 +60,7 @@
<configuration>
<target>
<concat destfile="${project.build.directory}/javascript-min/standard/script/tobago.min.js">
- <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script" files="tobago.js,calendar.js,dateConverter.js,tobago-menu.js,tobago-sheet.js,tobago-tree.js" />
+ <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script" files="tobago.js,calendar.js,dateConverter.js,tobago-menu.js,tobago-sheet.js" />
</concat>
<concat destfile="${project.build.directory}/javascript-min/msie_6_0/script/tobago.min.js">
<filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie_6_0/script" files="tobago.js" />
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml?rev=1156061&r1=1156060&r2=1156061&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml Wed Aug 10 08:11:10 2011
@@ -328,7 +328,6 @@
<script name="script/dateConverter.js"/>
<script name="script/tobago-menu.js"/>
<script name="script/tobago-sheet.js"/>
- <script name="script/tobago-tree.js"/>
<script name="script/jquery-ui/1_7_2/ui.core.min.js"/>
<script name="script/jquery-ui/1_7_2/ui.draggable.min.js"/>
<script name="script/logging.js"/>
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=1156061&r1=1156060&r2=1156061&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Wed Aug 10 08:11:10 2011
@@ -454,10 +454,7 @@ var Tobago = {
},
destroyObject: function(obj) {
- if (obj.initSelection) {
- // Tree object
- Tobago.Tree.destroy(obj);
- } else if (obj.htmlElement) {
+ if (obj.htmlElement) {
// test
delete obj.htmlElement.jsObjects;
delete obj.htmlElement;
@@ -2638,6 +2635,7 @@ Tobago.ToolBar.setRadioValue = function(
function xxx_tobagoInit(elements) {
Tobago.Menu.init(elements);
Tobago.TabGroup.init(elements);
+ Tobago.Tree.init(elements);
Tobago.ToolBar.init(elements);
Tobago.fixPngAlphaAll(elements);
}
@@ -3147,5 +3145,123 @@ Tobago.TabGroup.ensureScrollPosition = f
};
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Tree
+
+Tobago.Tree = {};
+
+Tobago.Tree.toggleNode = function(element) {
+ var node = element.closest(".tobago-treeNode, .tobago-treeMenuNode");
+ var content = jQuery(Tobago.escapeClientId(node.attr("id") + Tobago.SUB_COMPONENT_SEP + "content"));
+ var expanded = node.find(".tobago-treeMenuNode-expanded, .tobago-treeNode-expanded");
+ var toggle = node.find(".tobago-treeMenuNode-toggle, .tobago-treeNode-toggle");
+ if (content.css("display") == "none") {
+ content.css("display", "block");
+ toggle.each(function() {
+ jQuery(this).attr("src", jQuery(this).attr("srcopen"));
+ Tobago.fixPngAlpha(this);
+ });
+ expanded.attr("value", "true");
+ node.filter(".tobago-treeNode").addClass("tobago-treeNode-markup-expanded");
+ node.filter(".tobago-treeMenuNode").addClass("tobago-treeMenuNode-markup-expanded");
+ } else {
+ content.css("display", "none");
+ toggle.each(function() {
+ jQuery(this).attr("src", jQuery(this).attr("srcclose"));
+ Tobago.fixPngAlpha(this);
+ });
+ expanded.attr("value", "false");
+ node.filter(".tobago-treeNode").removeClass("tobago-treeNode-markup-expanded");
+ node.filter(".tobago-treeMenuNode").removeClass("tobago-treeMenuNode-markup-expanded");
+ }
+};
+
+Tobago.Tree.init = function(elements) {
+
+ var listboxSelects = Tobago.selectWidthJQuery(elements, ".tobago-treeListbox").find("select");
+
+ // find all option tags and add the dedicated select tag in its data section.
+
+ listboxSelects.children("option").each(function() {
+ var option = jQuery(this);
+ var optionId = option.attr("id");
+ var selectId = optionId + "::select";
+ var select = jQuery(Tobago.escapeClientId(selectId));
+ if (select.length == 1) {
+ option.data("select", select);
+ } else {
+ var empty = option.parent().parent().next().children(":first");
+ option.data("select", empty);
+ }
+ });
+
+ // add on change on all select tag, all options that are not selected hide there dedicated
+ // select tag, and the selected option show its dedicated select tag.
+
+ listboxSelects.each(function() {
+
+ jQuery(this).change(function() {
+ jQuery(this).children("option:not(:selected)").each(function() {
+ jQuery(this).data("select").hide();
+ });
+ jQuery(this).children("option:selected").data("select").show();
+
+ // Deeper level (2nd and later) should only show the empty select tag.
+ // The first child is the empty selection.
+ jQuery(this).parent().nextAll(":not(:first)").children(":not(:first)").hide();
+ jQuery(this).parent().nextAll(":not(:first)").children(":first").show();
+
+ });
+
+ jQuery(this).focus(function() {
+ jQuery(this).change();
+ });
+
+ });
+
+ Tobago.selectWidthJQuery(elements, ".tobago-treeNode-markup-folder .tobago-treeNode-toggle").click(function() {
+ Tobago.Tree.toggleNode(jQuery(this));
+ });
+
+ Tobago.selectWidthJQuery(elements, ".tobago-treeMenuNode-markup-folder .tobago-treeMenuNode-toggle")
+ .parent().each(function() {
+ // if there is no command, than the whole node element should be the toggle
+ var toggle = jQuery(this).children(".tobago-treeMenuCommand").size() == 0
+ ? jQuery(this)
+ : jQuery(this).find(".tobago-treeMenuNode-toggle");
+ toggle.click(function() {
+ Tobago.Tree.toggleNode(jQuery(this));
+ });
+ });
+
+ // normal hover effect (not possible with CSS in IE 6)
+ Tobago.selectWidthJQuery(elements, ".tobago-treeMenuNode").hover(function() {
+ jQuery(this).toggleClass("tobago-treeMenuNode-markup-hover");
+ });
+
+ // marked for treeNode
+ Tobago.selectWidthJQuery(elements, ".tobago-treeNode").focus(function() {
+ var command = jQuery(this);
+ var node = command.parent(".tobago-treeNode");
+ var tree = node.closest(".tobago-tree");
+ var marked = tree.children(".tobago-tree-marked");
+ marked.attr("value", node.attr("id"));
+ tree.find(".tobago-treeNode").removeClass("tobago-treeNode-markup-marked");
+ node.addClass("tobago-treeNode-markup-marked");
+ });
+
+ // marked for treeMenuNode
+ Tobago.selectWidthJQuery(elements, ".tobago-treeMenuCommand").focus(function() {
+ var command = jQuery(this);
+ var node = command.parent(".tobago-treeMenuNode");
+ var tree = node.closest(".tobago-treeMenu");
+ var marked = tree.children(".tobago-treeMenu-marked");
+ marked.attr("value", node.attr("id"));
+ tree.find(".tobago-treeMenuNode").removeClass("tobago-treeMenuNode-markup-marked");
+ node.addClass("tobago-treeMenuNode-markup-marked");
+ });
+};
+
+
+// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TbgTimer.endTbgJs = new Date(); // @DEV_ONLY