Index: jquery.treeTable.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/jquery.treeTable.css,v
retrieving revision 1.2
diff -u -p -r1.2 jquery.treeTable.css
--- jquery.treeTable.css 10 Jul 2010 13:57:47 -0000 1.2
+++ jquery.treeTable.css 30 Jan 2011 12:03:06 -0000
@@ -9,7 +9,7 @@
/* jquery.treeTable.collapsible
* ------------------------------------------------------------------------- */
.treeTable tr td .expander {
- background-position: left center;
+ background-position: -100px 0; /* move the image outside the visible part of the element */
background-repeat: no-repeat;
cursor: pointer;
padding: 0;
@@ -24,6 +24,10 @@
background-image: url(arrow-down.png);
}
+.treeTable tr td a.expander:focus {
+ font-weight: bold;
+}
+
/* jquery.treeTable.sortable
* ------------------------------------------------------------------------- */
.treeTable tr.selected, .treeTable tr.accept {
Index: jquery.treeTable.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/jquery.treeTable.js,v
retrieving revision 1.1
diff -u -p -r1.1 jquery.treeTable.js
--- jquery.treeTable.js 16 Mar 2010 23:48:58 -0000 1.1
+++ jquery.treeTable.js 30 Jan 2011 12:03:06 -0000
@@ -42,7 +42,9 @@
expandable: true,
indent: 19,
initialState: "collapsed",
- treeColumn: 0
+ treeColumn: 0,
+ stringExpand: "Expand",
+ stringCollapse: "Collapse"
};
// Recursively hide all node's children in a tree
@@ -124,8 +126,20 @@
$.fn.toggleBranch = function() {
if($(this).hasClass("collapsed")) {
$(this).expand();
+ // Replace the image src, alt, and title.
+ $(this).children('td:first-child').children('a:first-child').children('img:first-child').attr({
+ src: getBackgroundImageSrc($(this).children('td:first-child').children('a:first-child')),
+ title: options.stringCollapse,
+ alt: options.stringCollapse
+ });
} else {
$(this).removeClass("expanded").collapse();
+ // Replace the image src, alt, and title.
+ $(this).children('td:first-child').children('a:first-child').children('img:first-child').attr({
+ src: getBackgroundImageSrc($(this).children('td:first-child').children('a:first-child')),
+ title: options.stringExpand,
+ alt: options.stringExpand
+ });
}
return this;
@@ -178,8 +192,9 @@
});
if(options.expandable) {
- cell.prepend('');
- $(cell[0].firstChild).click(function() { node.toggleBranch(); });
+ cell.wrapInner('');
+ $(cell[0].firstChild).click(function() { node.toggleBranch(); return false; });
+ $(cell[0].firstChild).keydown(function(e) { if(e.keyCode == 13) {node.toggleBranch(); return false; }});
if(options.clickableNodeNames) {
cell[0].style.cursor = "pointer";
@@ -190,7 +205,7 @@
}
});
}
-
+
// Check for a class set explicitly by the user, otherwise set the default class
if(!(node.hasClass("expanded") || node.hasClass("collapsed"))) {
node.addClass(options.initialState);
@@ -199,6 +214,10 @@
if(node.hasClass("expanded")) {
node.expand();
}
+
+ // Change the background css image to a foreground image, to provide an accessible UI.
+ backgroundImage = getBackgroundImageSrc($(cell[0].firstChild));
+ $(cell[0].firstChild).prepend('');
}
}
}
@@ -218,4 +237,9 @@
}
}
};
+
+ function getBackgroundImageSrc(element) {
+ // Take the background-image css attribute, and remove the url("") text.
+ return element.css('background-image').replace(/^url\(\"/, '').replace(/\"\)$/, '');
+ }
})(jQuery);
Index: token.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.js,v
retrieving revision 1.3
diff -u -p -r1.3 token.js
--- token.js 20 Mar 2010 19:48:25 -0000 1.3
+++ token.js 30 Jan 2011 12:03:06 -0000
@@ -5,7 +5,11 @@
Drupal.behaviors.tokenTree = {
attach: function (context, settings) {
$('table.token-tree', context).once('token-tree', function () {
- $(this).treeTable();
+ opts = {
+ stringCollapse: Drupal.t('Collapse'),
+ stringExpand: Drupal.t('Expand')
+ };
+ $(this).treeTable(opts);
});
}
};