diff --git a/devel.module b/devel.module old mode 100644 new mode 100755 index 7967e02..847f8e9 --- a/devel.module +++ b/devel.module @@ -440,8 +440,11 @@ function devel_set_message($msg, $type = NULL) { // Return boolean. No need for cache here. function has_krumo() { // see README.txt or just download from http://krumo.sourceforge.net/ - @include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'devel') .'/krumo/class.krumo.php'; - return function_exists('krumo') && !drupal_is_cli(); + if (function_exists('krumo') && !drupal_is_cli()) { + drupal_add_js(drupal_get_path('module', 'devel') . '/krumo_path.js'); + return TRUE; + } + return FALSE; } /** diff --git a/krumo_path.js b/krumo_path.js new file mode 100755 index 0000000..2231d28 --- /dev/null +++ b/krumo_path.js @@ -0,0 +1,56 @@ +jQuery.extend(jQuery.expr[':'], { + 'containsi': function(elem, i, match, array) { + return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; + } +}); + +jQuery(document).ready(function() { + var krumo_name = []; + var krumo_type = []; + + function krumo_traverse(el) { + krumo_name.push(jQuery(el).html()); + krumo_type.push(jQuery(el).siblings('em').html().match(/\w*/)[0]); + + if (jQuery(el).closest('.krumo-nest').length > 0) { + krumo_traverse(jQuery(el).closest('.krumo-nest').prev().find('.krumo-name')); + } + } + + jQuery('.krumo-child > div:first-child').mousedown(function(e) { + if (e.which === 3) { + if (jQuery(this).find('> .krumo-php-path').length > 0){ + // Remove path if shown + jQuery(this).find('> .krumo-php-path').remove(); + } + else { + // Get elements + krumo_traverse(jQuery(this).find(' > a.krumo-name')); + + // Create path + var krumo_path_string = ''; + for(var i = krumo_name.length - 1; i >= 0; --i) { + //start element + if ( (krumo_name.length - 1) == i) krumo_path_string += '$' + krumo_name[i]; + + if (typeof krumo_name[(i-1)] !== 'undefined') { + if (krumo_type[i] == 'Array') { + krumo_path_string += "[" + if ( ! /^\d*$/.test(krumo_name[(i-1)]) ) krumo_path_string += "'"; + krumo_path_string += krumo_name[(i-1)] ; + if ( ! /^\d*$/.test(krumo_name[(i-1)]) ) krumo_path_string += "'"; + krumo_path_string += "]"; + } + if (krumo_type[i] == 'Object') krumo_path_string += '->' + krumo_name[(i-1)]; + } + + } + jQuery(this).append('
' + krumo_path_string + '
'); + + // Reset arrays + krumo_name = []; + krumo_type = []; + } + } + }); +}); \ No newline at end of file