root / drupal7 / sites / all / modules / admin_menu / admin_devel / admin_devel.js @ 2c8c2b87
1 |
(function($) { |
---|---|
2 |
|
3 |
/**
|
4 |
* jQuery debugging helper.
|
5 |
*
|
6 |
* Invented for Dreditor.
|
7 |
*
|
8 |
* @usage
|
9 |
* $.debug(var [, name]);
|
10 |
* $variable.debug( [name] );
|
11 |
*/
|
12 |
jQuery.extend({ |
13 |
debug: function () { |
14 |
// Setup debug storage in global window. We want to look into it.
|
15 |
window.debug = window.debug || []; |
16 |
|
17 |
args = jQuery.makeArray(arguments);
|
18 |
// Determine data source; this is an object for $variable.debug().
|
19 |
// Also determine the identifier to store data with.
|
20 |
if (typeof this == 'object') { |
21 |
var name = (args.length ? args[0] : window.debug.length); |
22 |
var data = this; |
23 |
} |
24 |
else {
|
25 |
var name = (args.length > 1 ? args.pop() : window.debug.length); |
26 |
var data = args[0]; |
27 |
} |
28 |
// Store data.
|
29 |
window.debug[name] = data; |
30 |
// Dump data into Firebug console.
|
31 |
if (typeof console != 'undefined') { |
32 |
console.log(name, data); |
33 |
} |
34 |
return this; |
35 |
} |
36 |
}); |
37 |
// @todo Is this the right way?
|
38 |
jQuery.fn.debug = jQuery.debug; |
39 |
|
40 |
})(jQuery); |