Added the debug toolkit plugin, found on the bakery website.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@92 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-10 21:12:59 +00:00
parent 18b928411b
commit 8ab8d087e6
41 changed files with 4502 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
/* SVN FILE: $Id$ */
/**
* Debug Toolbar Javascript. jQuery 1.2.x compatible.
*
* Long description here.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2006-2008, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.
* @since CakePHP v 1.2.0.4487
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
(function($) {
$(document).ready(function(){
DebugKit.Toolbar();
DebugKit.NeatArray();
});
var DebugKit = {};
/**
* Create all behaviors for neat array elements
*
*/
DebugKit.NeatArray = function() {
$('.neat-array').find('li:has(ul)').toggle(
function() {
$(this).toggleClass('expanded').removeClass('collapsed').find('ul:first').show();
},
function() {
$(this).toggleClass('expanded').addClass('collapsed').find('ul:first').hide();
}
).addClass('expandable').addClass('collapsed').find('ul').hide();
}
/**
* Add behavior for toolbar buttons
*
*/
DebugKit.Toolbar = function() {
var tabCollection = $('#debug-kit-toolbar li > div');
$('#debug-kit-toolbar .panel-tab > a').click(
function(e){
e.preventDefault();
var targetPanel = $(this.hash + '-tab');
if (targetPanel.hasClass('active')) {
tabCollection.hide().removeClass('active');
} else {
tabCollection
.hide().removeClass('active')
.filter(this.hash + '-tab').show().addClass('active');
}
$('#debug-kit-toolbar .panel-tab > a').removeClass('active');
$(this).addClass('active');
}
);
//enable hiding of toolbar.
var panelButtons = $('#debug-kit-toolbar .panel-tab:not(.panel-tab.icon)');
$('#debug-kit-toolbar #hide-toolbar').toggle(
function() {
panelButtons.hide();
},
function() {
panelButtons.show();
}
);
}
})(jQuery);

View File

@@ -0,0 +1,212 @@
/* SVN FILE: $Id$ */
/**
* Debug Toolbar Javascript.
*
* Long description here.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2006-2008, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.
* @since CakePHP v 1.2.0.4487
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
var DebugKit = function(id) {
var undefined,
elements = {},
panels = {},
hidden = false;
this.initialize = function(id) {
elements.toolbar = document.getElementById(id || 'debug-kit-toolbar');
if (elements.toolbar === undefined) {
throw new Exception('Toolbar not found, make sure you loaded it.');
}
for (var i in elements.toolbar.childNodes) {
var element = elements.toolbar.childNodes[i];
if (element.nodeName && element.id === 'panel-tabs') {
elements.panel = element;
break;
}
}
for (var i in elements.panel.childNodes) {
var element = elements.panel.childNodes[i];
if (element.className && element.className.match(/panel-tab/)) {
this.addPanel(element);
}
}
var lists = document.getElementsByTagName('ul'), index = 0;
while (lists[index] !== undefined) {
var element = lists[index];
if (element.className && element.className.match(/neat-array/)) {
neatArray(element);
}
++index;
}
}
/**
* Add a panel to the toolbar
*/
this.addPanel = function(tab, callback) {
if (!tab.nodeName || tab.nodeName.toUpperCase() !== 'LI') {
throw new Exception('Toolbar not found, make sure you loaded it.');
}
var panel = {
id : false,
element : tab,
callback : callback,
button : undefined,
content : undefined,
active : false
};
for (var i in tab.childNodes) {
var element = tab.childNodes[i],
tag = element.nodeName? element.nodeName.toUpperCase(): false;
if (tag === 'A') {
panel.id = element.hash.replace(/^#/, '');
panel.button = element;
} else if (tag === 'DIV') {
panel.content = element;
}
}
if (!panel.id) {
throw new Exception('invalid element');
}
if (panel.button.id && panel.button.id === 'hide-toolbar') {
panel.callback = this.toggleToolbar;
}
if (panel.callback !== undefined) {
panel.button.onclick = function() { return panel.callback(); };
} else {
panel.button.onclick = function() { return window.DebugKit.togglePanel(panel.id); };
}
panels[panel.id] = panel;
return panel.id;
};
/**
* Hide/show the toolbar (minimize cake)
*/
this.toggleToolbar = function() {
for (var i in panels) {
var panel = panels[i],
display = hidden? 'block': 'none';
if (panel.content !== undefined) {
panel.element.style.display = display;
}
}
hidden = !hidden;
return true;
};
/**
* Toggle a panel
*/
this.togglePanel = function(id) {
if (panels[id] && panels[id].active) {
this.deactivatePanel(true);
} else {
this.deactivatePanel(true);
this.activatePanel(id);
}
}
/**
* Make a panel active.
*/
this.activatePanel = function(id, unique) {
if (panels[id] !== undefined && !panels[id].active) {
var panel = panels[id];
this.deactivatePanel(true);
if (panel.content !== undefined) {
panel.content.style.display = 'block';
}
panel.button.className = panel.button.className.replace(/^(.*)$/, '$1 active');
panel.active = true;
return true;
}
return false;
};
/**
* Deactivate a panel. use true to hide all panels.
*/
this.deactivatePanel = function(id) {
if (id === true) {
for (var i in panels) {
this.deactivatePanel(i);
}
return true;
}
if (panels[id] !== undefined && panels[id].active) {
var panel = panels[id];
if (panel.content !== undefined) {
panel.content.style.display = 'none';
}
panel.button.className = panel.button.className.replace(/ ?(active) ?/, '');
panel.active = false;
return true;
}
return false;
};
/**
* Add neat array functionality.
*/
function neatArray(list) {
if (!list.className.match(/depth-0/)) {
var item = list.parentNode;
list.style.display = 'none';
item.className = (item.className || '').replace(/^(.*)$/, '$1 expandable collapsed');
item.onclick = function(event) {
//var element = (event === undefined)? this: event.target;
var element = this,
event = event || window.event,
act = Boolean(item === element),
hide = Boolean(list.style.display === 'block');
if (act && hide) {
list.style.display = 'none';
item.className = item.className.replace(/expanded|$/, 'collapsed');
} else if (act) {
list.style.display = 'block';
item.className = item.className.replace('collapsed', 'expanded');
}
if (event.cancelBubble !== undefined) {
event.cancelBubble = true;
}
return false;
}
}
}
this.initialize(id);
}
DebugKit.install = function() {
var initializer = window.onload || function() {};
window.onload = function() {
initializer();
// makes DebugKit a singletone instance
window.DebugKit = new DebugKit();
}
}
DebugKit.install();

View File

@@ -0,0 +1,95 @@
/* SVN FILE: $Id$ */
/**
* Debug Toolbar Javascript. Mootools 1.2 compatible.
*
* Requires Class, Event, Element, and Selectors
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2006-2008, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.
* @since CakePHP v 1.2.0.4487
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
window.addEvent('domready', function() {
new DebugKit();
});
var DebugKit = new Class({
initialize : function() {
this.neatArray();
this.toolbar();
},
/**
* Create all behaviors for neat array elements
*/
neatArray : function() {
$$('#debug-kit-toolbar .neat-array li').each(function(listItem) {
var subUl = listItem.getElement('ul');
if (subUl) {
listItem.addClass('expandable').addClass('collapsed');
subUl.setStyle('display', 'none').set('state', 'closed');
listItem.addEvent('click', function(event) {
event.stop();
this.toggleClass('expanded').toggleClass('collapsed');
if (subUl.get('state') == 'closed') {
subUl.setStyle('display', 'block').set('state', 'open');
} else {
subUl.setStyle('display', 'none').set('state', 'closed');
}
})
}
});
},
/**
* Add behavior for toolbar buttons
*/
toolbar : function() {
var tabCollection = $$('#debug-kit-toolbar li > div');
$$('#debug-kit-toolbar .panel-tab > a').addEvent('click', function(event) {
event.stop();
var buttonId = this.hash.substring(1, this.hash.length) + '-tab';
var targetPanel = $(buttonId);
if (!targetPanel) return;
$$('#debug-kit-toolbar .panel-tab > a').removeClass('active');
if (targetPanel.hasClass('active')) {
tabCollection.removeClass('active').setStyle('display', 'none');
} else {
tabCollection.setStyle('display', 'none').removeClass('active');
targetPanel.addClass('active').setStyle('display', 'block');
this.addClass('active');
}
});
//enable hiding of toolbar.
var panelButtons = $$('#debug-kit-toolbar .panel-tab:not(.panel-tab.icon)');
var toolbarHide = $('hide-toolbar').set('state', 'open');
toolbarHide.addEvent('click', function(event) {
event.stop();
var state = this.get('state');
if (state == 'open') {
panelButtons.setStyle('display', 'none');
this.set('state', 'closed')
} else {
panelButtons.setStyle('display');
this.set('state', 'open');
}
});
}
});

View File

@@ -0,0 +1,95 @@
/* SVN FILE: $Id$ */
/**
* Debug Toolbar Javascript. Prototype 1.6.x compatible.
*
* Long description here.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2006-2008, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.
* @since CakePHP v 1.2.0.4487
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
document.observe('dom:loaded', function() {
new DebugKit();
});
var DebugKit = Class.create({
initialize: function(){
this.toolbar();
this.neatArray();
},
toolbar: function(){
var tabCollection = $('debug-kit-toolbar').select('li > div');
$('debug-kit-toolbar').select('.panel-tab > a').invoke('observe', 'click', function(e){
e.stop();
var targetPanel = $(e.element().hash.replace(/#/, '') + '-tab');
if (targetPanel.hasClassName('active')) {
tabCollection.each(function(ele){
ele.hide().removeClassName('active');
});
} else {
tabCollection.each(function(ele){
ele.hide().removeClassName('active');
if (targetPanel.id == ele.id) {
ele.setStyle({display: 'block'}).addClassName('active');
}
});
}
$('debug-kit-toolbar').select('.panel-tab > a').invoke('removeClassName', 'active');
e.element().addClassName('active');
});
// enable hiding of toolbar.
var panelButtons = $('debug-kit-toolbar').select('.panel-tab');
$('hide-toolbar').observe('click', function(eve){
eve.stop();
panelButtons.each(function(panel){
if (!panel.hasClassName('icon')) {
panel.toggle();
};
});
});
},
/**
* Create all behaviors for neat array elements
*/
neatArray: function() {
$('debug-kit-toolbar').select('.neat-array li').each(function(ele){
var sub = ele.select('ul');
if (sub.length > 0) {
ele.addClassName('collapsed').addClassName('expandable');
sub.invoke('hide');
ele.observe('click', function(eve){
if (eve.element() == ele || eve.element().up() == ele) {
if (sub.length > 0) {
ele.toggleClassName('expanded').toggleClassName('collapsed');
sub[0].toggle();
}
}
});
};
});
}
});

View File

@@ -0,0 +1,126 @@
/* SVN FILE: $Id$ */
/**
* Debug Toolbar Javascript. YUI 2.6 compatible.
*
* Long description here.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2006-2008, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.
* @since CakePHP v 1.2.0.4487
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
YAHOO.namespace('CakePHP.DebugKit');
YAHOO.CakePHP.DebugKit = function() {
var Event = YAHOO.util.Event;
var Dom = YAHOO.util.Dom;
var Selector = YAHOO.util.Selector;
var toggle = function(el) {
Dom.setStyle(el, 'display', ((Dom.getStyle(el, 'display') == 'none') ? '' : 'none'));
};
var toggleClass = function(element, className) {
(Dom.hasClass(element, className)) ? Dom.removeClass(element, className) : Dom.addClass(element, className);
};
var toolbar = function() {
var tabCollection = Selector.query('#debug-kit-toolbar li > div');
Dom.batch(Selector.query('#debug-kit-toolbar .panel-tab > a'), function(el) {
Event.on(el, 'click', function(ev) {
Event.preventDefault(ev);
targetPanel =Dom.get(el.hash.replace(/#/, '') + '-tab');
if (Dom.hasClass(targetPanel, 'active')) {
Dom.batch(tabCollection, function(ele) {
toggle(ele);
Dom.removeClass(ele, 'active');
Dom.setStyle(ele, 'display', '');
});
} else {
Dom.batch(tabCollection, function(ele) {
toggle(ele);
Dom.removeClass(ele, 'active');
if (targetPanel && targetPanel.id == ele.id) {
Dom.setStyle(ele, 'display', 'block');
Dom.addClass(ele, 'active');
}
});
}
Dom.removeClass(Selector.query('#debug-kit-toolbar .panel-tab > a'), 'active');
Dom.addClass(el, 'active');
});
});
};
var neatArray = function() {
nodes = Selector.query('#debug-kit-toolbar .panel-content > ul.neat-array li > ul');
if (nodes.length > 0) {
Dom.batch(nodes, function(el) {
var parent = el.parentNode;
Dom.addClass(parent, 'collapsed');
Dom.addClass(parent, 'expandable');
toggle(nodes);
Event.on(parent, 'click', function(ev) {
sub = Selector.query('ul', parent);
toggleClass(parent, 'expanded');
toggleClass(parent, 'collapsed');
toggle(sub);
});
});
}
};
var panelButtons = function() {
Event.on('hide-toolbar', 'click', function(ev) {
Event.preventDefault(ev);
Dom.getElementsByClassName('panel-tab', 'li', 'debug-kit-toolbar', function (el) {
if (!Dom.hasClass(el, 'icon')) {
toggle(el);
}
});
});
};
return {
initialize: function() {
neatArray();
toolbar();
panelButtons();
}
};
}(); // Execute annonymous closure & return results
YAHOO.util.Event.onDOMReady(YAHOO.CakePHP.DebugKit.initialize);