Index: arrow-right.png =================================================================== RCS file: arrow-right.png diff -N arrow-right.png Binary files /dev/null and arrow-right.png differ Index: jquery.treeTable.css =================================================================== RCS file: jquery.treeTable.css diff -N jquery.treeTable.css --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ jquery.treeTable.css 10 Mar 2010 15:42:40 -0000 @@ -0,0 +1,43 @@ +/* jQuery TreeTable Core 2.0 stylesheet + * + * This file contains styles that are used to display the tree table. Each tree + * table is assigned the +treeTable+ class. + * ========================================================================= */ + +/* jquery.treeTable.collapsible + * ------------------------------------------------------------------------- */ +.treeTable tr td .expander { + background-position: left center; + background-repeat: no-repeat; + cursor: pointer; + padding: 0; + zoom: 1; /* IE7 Hack */ +} + +.treeTable tr.collapsed td .expander { + background-image: url(/misc/arrow-asc.png); +} + +.treeTable tr.expanded td .expander { + background-image: url(arrow-right.png); +} + +/* jquery.treeTable.sortable + * ------------------------------------------------------------------------- */ +.treeTable tr.selected, .treeTable tr.accept { + background-color: #3875d7; + color: #fff; +} + +.treeTable tr.collapsed.selected td .expander, .treeTable tr.collapsed.accept td .expander { + background-image: url(../images/toggle-expand-light.png); +} + +.treeTable tr.expanded.selected td .expander, .treeTable tr.expanded.accept td .expander { + background-image: url(../images/toggle-collapse-light.png); +} + +.treeTable .ui-draggable-dragging { + color: #000; + z-index: 1; +} Index: jquery.treeTable.js =================================================================== RCS file: jquery.treeTable.js diff -N jquery.treeTable.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ jquery.treeTable.js 10 Mar 2010 15:42:40 -0000 @@ -0,0 +1,13 @@ +/* jQuery treeTable Plugin 2.2.3 - http://ludo.cubicphuse.nl/jquery-plugins/treeTable/ */ +(function($){var options;var defaultPaddingLeft;$.fn.treeTable=function(opts){options=$.extend({},$.fn.treeTable.defaults,opts);return this.each(function(){$(this).addClass("treeTable").find("tbody tr").each(function(){if(!options.expandable||$(this)[0].className.search("child-of-")==-1){if(isNaN(defaultPaddingLeft)){defaultPaddingLeft=parseInt($($(this).children("td")[options.treeColumn]).css('padding-left'),10);} +initialize($(this));}else if(options.initialState=="collapsed"){this.style.display="none";}});});};$.fn.treeTable.defaults={childPrefix:"child-of-",clickableNodeNames:false,expandable:true,indent:19,initialState:"collapsed",treeColumn:0};$.fn.collapse=function(){$(this).addClass("collapsed");childrenOf($(this)).each(function(){if(!$(this).hasClass("collapsed")){$(this).collapse();} +this.style.display="none";});return this;};$.fn.expand=function(){$(this).removeClass("collapsed").addClass("expanded");childrenOf($(this)).each(function(){initialize($(this));if($(this).is(".expanded.parent")){$(this).expand();} +$(this).show();});return this;};$.fn.appendBranchTo=function(destination){var node=$(this);var parent=parentOf(node);var ancestorNames=$.map(ancestorsOf($(destination)),function(a){return a.id;});if($.inArray(node[0].id,ancestorNames)==-1&&(!parent||(destination.id!=parent[0].id))&&destination.id!=node[0].id){indent(node,ancestorsOf(node).length*options.indent*-1);if(parent){node.removeClass(options.childPrefix+parent[0].id);} +node.addClass(options.childPrefix+destination.id);move(node,destination);indent(node,ancestorsOf(node).length*options.indent);} +return this;};$.fn.reverse=function(){return this.pushStack(this.get().reverse(),arguments);};$.fn.toggleBranch=function(){if($(this).hasClass("collapsed")){$(this).expand();}else{$(this).removeClass("expanded").collapse();} +return this;};function ancestorsOf(node){var ancestors=[];while(node=parentOf(node)){ancestors[ancestors.length]=node[0];} +return ancestors;};function childrenOf(node){return $("table.treeTable tbody tr."+options.childPrefix+node[0].id);};function getPaddingLeft(node){var paddingLeft=parseInt(node[0].style.paddingLeft,10);return(isNaN(paddingLeft))?defaultPaddingLeft:paddingLeft;} +function indent(node,value){var cell=$(node.children("td")[options.treeColumn]);cell[0].style.paddingLeft=getPaddingLeft(cell)+value+"px";childrenOf(node).each(function(){indent($(this),value);});};function initialize(node){if(!node.hasClass("initialized")){node.addClass("initialized");var childNodes=childrenOf(node);if(!node.hasClass("parent")&&childNodes.length>0){node.addClass("parent");} +if(node.hasClass("parent")){var cell=$(node.children("td")[options.treeColumn]);var padding=getPaddingLeft(cell)+options.indent;childNodes.each(function(){$(this).children("td")[options.treeColumn].style.paddingLeft=padding+"px";});if(options.expandable){cell.prepend('');$(cell[0].firstChild).click(function(){node.toggleBranch();});if(options.clickableNodeNames){cell[0].style.cursor="pointer";$(cell).click(function(e){if(e.target.className!='expander'){node.toggleBranch();}});} +if(!(node.hasClass("expanded")||node.hasClass("collapsed"))){node.addClass(options.initialState);} +if(node.hasClass("expanded")){node.expand();}}}}};function move(node,destination){node.insertAfter(destination);childrenOf(node).reverse().each(function(){move($(this),node[0]);});};function parentOf(node){var classNames=node[0].className.split(' ');for(key in classNames){if(classNames[key].match("child-of-")){return $("#"+classNames[key].substring(9));}}};})(jQuery); \ No newline at end of file Index: token.css =================================================================== RCS file: token.css diff -N token.css --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ token.css 10 Mar 2010 15:42:40 -0000 @@ -0,0 +1,3 @@ +table.token-tree { + font-size: 0.85em; +} Index: token.js =================================================================== RCS file: token.js diff -N token.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ token.js 10 Mar 2010 15:42:40 -0000 @@ -0,0 +1,54 @@ +(function ($) { + +Drupal.behaviors.tokenTree = { + attach: function (context, settings) { + $('table.token-tree', context).once('token-tree', function () { + $(this).treeTable(); + }); + } +}; + +Drupal.behaviors.tokenInsert = { + attach: function (context, settings) { + // Keep track of which textfield was last selected/focused. + $('textarea, input[type="text"]', context).focus(function() { + Drupal.settings.tokenFocusedField = this; + }); + + $('table.token-tree td.token-key', context).once('token-insert', function() { + var newThis = $('' + $(this).html() + '').click(function(){ + if (typeof Drupal.settings.tokenFocusedField == 'undefined') { + alert(Drupal.t('First click a text field to insert your tokens into.')); + } + else { + var myField = Drupal.settings.tokenFocusedField; + var myValue = $(this).text(); + + //IE support + if (document.selection) { + myField.focus(); + sel = document.selection.createRange(); + sel.text = myValue; + } + + //MOZILLA/NETSCAPE support + else if (myField.selectionStart || myField.selectionStart == '0') { + var startPos = myField.selectionStart; + var endPos = myField.selectionEnd; + myField.value = myField.value.substring(0, startPos) + + myValue + + myField.value.substring(endPos, myField.value.length); + } else { + myField.value += myValue; + } + + $('html,body').animate({scrollTop: $(myField).offset().top}, 500); + } + return false; + }); + $(this).replaceWith(newThis); + }); + } +}; + +})(jQuery); Index: token.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/token/token.module,v retrieving revision 1.22 diff -u -p -r1.22 token.module --- token.module 8 Mar 2010 03:46:06 -0000 1.22 +++ token.module 10 Mar 2010 15:42:40 -0000 @@ -15,6 +15,55 @@ function token_menu() { } /** + * Implements hook_theme(). + */ +function token_theme() { + return array( + 'token_tree' => array( + 'variables' => array('token_types' => array(), 'global_types' => TRUE, 'click_insert' => TRUE, 'recursion_limit' => 4), + 'file' => 'token.pages.inc', + ), + ); +} + +function token_library() { + // Vertical Tabs. + $libraries['treeTable'] = array( + 'title' => 'jQuery treeTable', + 'website' => 'http://plugins.jquery.com/project/treetable', + 'version' => '2.2.3', + 'js' => array( + drupal_get_path('module', 'token') . '/jquery.treeTable.js' => array(), + ), + 'css' => array( + drupal_get_path('module', 'token') . '/jquery.treeTable.css' => array(), + ), + ); + + return $libraries; +} + +/** + * Get a list of token types that can be used without any context (global). + * + * @return + * An array of global token types. + */ +function token_get_global_token_types() { + $global_types = &drupal_static(__FUNCTION__, array()); + $token_info = token_info(); + + // Add the token types that are always valid in global context. + foreach ($token_info['types'] as $type => $type_info) { + if (empty($type_info['needs-data'])) { + $global_types[] = $type; + } + } + + return $global_types; +} + +/** * Validate an tokens in raw text based on possible contexts. * * @param $text Index: token.pages.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/token/token.pages.inc,v retrieving revision 1.1 diff -u -p -r1.1 token.pages.inc --- token.pages.inc 7 Mar 2010 04:21:43 -0000 1.1 +++ token.pages.inc 10 Mar 2010 15:42:40 -0000 @@ -1,6 +1,123 @@ $type); + $id = drupal_clean_css_identifier('token-' . $type, array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => '', ':' => '-')); + $row = array( + 'id' => $id, + 'class' => array('token-group'), + 'data' => array( + $type_info['name'], + '', + $type_info['description'], + ), + ); + + if (count($token_types) > 1) { + $rows[] = $row; + } + else { + $id = NULL; + } + $rows = array_merge($rows, token_browser_list_tokens($type_info['type'], $type, $id, $variables['recursion_limit'])); + } + + if (count($rows)) { + drupal_add_library('token', 'treeTable'); + drupal_add_js(drupal_get_path('module', 'token') . '/token.js'); + drupal_add_css(drupal_get_path('module', 'token') . '/token.css'); + } + + return theme('table', array( + 'header' => $header, + 'rows' => $rows, + 'attributes' => array('class' => array('token-tree')), + 'empty' => t('No tokens available.'), + 'caption' => $variables['click_insert'] ? 'Click a token to insert it into the field you\'ve last clicked.' : '', + )); +} + +function token_browser_list_tokens($type, $prefix = NULL, $parent_id = NULL, $recursion_limit = 4) { + $info = &drupal_static(__FUNCTION__); + + // Since tokens could possibly recurse (e.g. terms have parents, and those + // parent terms could have parents, etc.), we have to add a depth check. + if ($recursion_limit <= 0) { + return array(); + } + + if (!isset($info)) { + $info = token_info(); + } + + $rows = array(); + + if (!isset($prefix)) { + $prefix = $type; + } + + foreach ($info['tokens'][$type] as $token => $token_info) { + $key = "{$prefix}:{$token}"; + if (!empty($token_info['dynamic'])) { + $key .= ':?'; + } + $id = drupal_clean_css_identifier('token-' . $key, array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => '', ':' => '-')); + $row = array( + 'id' => $id, + 'class' => array(), + 'data' => array( + $token_info['name'], + array( + 'data' => "[{$key}]", + 'class' => 'token-key', + ), + $token_info['description'], + ), + ); + if (isset($parent_id)) { + $row['class'][] = 'child-of-' . $parent_id; + } + $rows[] = $row; + if (!empty($token_info['type'])) { + $rows = array_merge($rows, token_browser_list_tokens($token_info['type'], $key, $id, $recursion_limit - 1)); + } + } + + return $rows; +} + function token_autocomplete() { $args = func_get_args(); $string = implode('/', $args);