EdgeExpressDB
view release on metacpan or search on metacpan
www/edgeexpress/jscript/SpryAssets/SpryDebug.js view on Meta::CPAN
this.loadfunc = function(e){self.init()}
Spry.Debugger.Utils.addEvListener(window, 'beforeunload', this.unloadfunc, false);
Spry.Debugger.Utils.addEvListener(window, 'load', this.loadfunc, false);
window.onerror = this.myerrorhandler;
};
Spry.Debugger.prototype.init = function(){
var w = document.getElementById('debugdiv');
if (!w){
var debugwindow = document.createElement('div');
var headdiv = document.createElement('div');
var closediv = document.createElement('div');
var maximdiv = document.createElement('div');
var invdiv = document.createElement('div');
var textdiv = document.createElement('div');
var consolediv = document.createElement('div');
var cleardiv = document.createElement('div');
var scripts = document.getElementsByTagName('script');
var link = '';
for (var k=0; k< scripts.length; k++){
if (scripts[k].src != null && scripts[k].src != '' && scripts[k].src.match(/SpryDebug.js$/)){
link = scripts[k].src.replace(/SpryDebug.js/, '../css/SpryDebug.css');
break;
}
}
if (link != ''){
var cssfile = document.createElement("link");
cssfile.setAttribute("rel", "stylesheet");
cssfile.setAttribute("type", "text/css");
cssfile.setAttribute("href", link);
document.getElementsByTagName("head").item(0).appendChild(cssfile);
}
textdiv.id = 'textdiv';
textdiv.innerHTML = '<ol><li>Click the (left) button above.</li><li>Click on the page element to introspect. The red outline shows the current selection.</li></ol>';
headdiv.id = 'headdiv';
closediv.id = 'closediv';
closediv.innerHTML = 'x';
maximdiv.id = 'maximdiv';
maximdiv.innerHTML = '<div></div>';
cleardiv.id = 'cleardiv';
cleardiv.innerHTML = 'clear';
invdiv.id = 'invdiv';
invdiv.innerHTML = 'o';
debugwindow.id = 'debugdiv';
//scroll in the visible area on refresh
setTimeout(function(){
try{
var top = 0;
if (document.documentElement && document.documentElement.scrollTop)
var top = parseInt(document.documentElement.scrollTop, 10);
else if (document.body)
var top = parseInt(document.body.scrollTop, 10);
top = top + 10;
if ( !isNaN(top) && top > 10)
debugwindow.style.top = top+'px';
}catch(silent){alert(silent.message);}
}, 500);
consolediv.id = 'consolediv';
consolediv.innerHTML = '<form id="debugForm" action="#" method="get" onsubmit="return debug.jseval();"><input type="text" id="debugtext" name="debugtext" /><input type="submit" id="submitform" /><div id="debuggersuggestions"></div></form>';
document.body.appendChild(debugwindow);
debugwindow.appendChild(headdiv);
debugwindow.appendChild(textdiv);
debugwindow.appendChild(consolediv);
headdiv.appendChild(closediv);
headdiv.appendChild(maximdiv);
headdiv.appendChild(cleardiv);
headdiv.appendChild(invdiv);
this.jstext = document.getElementById('debugtext');
this.jstext.setAttribute('AutoComplete', 'off');
var self = this;
this.dkfunc = function(e){return self.debuggerKey(e)}
this.cdwfunc = function(e){return self.closeDebugWindow(e)}
this.cldwfunc = function(e){return self.clearDebugWindow(e)}
this.mdwfunc = function(e){return self.maximDebugWindow(e)}
this.mddwfunc = function(e){return self.mousedownDebugWindow(e)}
this.mmdwfunc = function(e){return self.mousemoveDebugWindow(e)}
this.mudwfunc = function(e){return self.mouseupDebugWindow(e)}
this.imdfunc = function(e){return self.introspectPage(e)};
var addEv = Spry.Debugger.Utils.addEvListener;
addEv(self.jstext, 'keydown', this.dkfunc, false);
addEv(closediv,'click', this.cdwfunc, false);
addEv(cleardiv,'click', this.cldwfunc, false);
addEv(invdiv,'click', this.imdfunc, false);
addEv(maximdiv,'click', this.mdwfunc, false);
addEv(headdiv, 'mousedown', this.mddwfunc, false);
addEv(document.body, 'mousemove', this.mmdwfunc, false);
addEv(headdiv, 'mouseup', this.mudwfunc, false);
this.debugdiv = debugwindow;
this.jshints = document.getElementById('debuggersuggestions');
this.headdiv = headdiv;
this.closediv = closediv;
this.maximdiv = maximdiv;
this.textdiv = textdiv;
this.consolediv = consolediv;
this.cleardiv = cleardiv;
}
// clear stack
this.out();
};
Spry.Debugger.prototype.introspectPage = function(e){
if (this.introspRun && this.introspRun == true){
this.introspRun = false;
self.stopHi();
}else{
this.introspRun = true;
if (typeof this.hiElTop == 'undefined'){
var self = this;
Spry.Debugger.Utils.addEvListener(document, 'mouseover', function(ev){
if (!self.introspRun) return;
ev = ev || event;
var el;
www/edgeexpress/jscript/SpryAssets/SpryDebug.js view on Meta::CPAN
};
Spry.Debugger.prototype.mouseupDebugWindow = function (e){
if (this.startDrag){
if (Spry.is.ie)
this.debugdiv.style.filter = 'alpha(opacity=100)';
else
this.debugdiv.style.opacity = 1;
this.startDrag = false;
}
return false;
};
Spry.Debugger.prototype.mousemoveDebugWindow = function (e){
e = e||event;
if (this.startDrag){
this.debugdiv.style.opacity = 0.6;
this.debugdiv.style.filter = 'alpha(opacity=60)';
var x = e.screenX - initialX;
var y = e.screenY - initialY;
this.debugdiv.style.left = (topX + x) + 'px';
this.debugdiv.style.top = (topY + y) + 'px';
}
return false;
};
////////////////////////////////////////////////////////////////
//
// Spry.Debugger.Utils
//
/////////////////////////////////////////////////////////////////
if (!Spry.Debugger.Utils) Spry.Debugger.Utils = {};
Spry.Debugger.Utils.getStyleProp = function(element, prop)
{
var value;
try
{
if (element.style)
value = element.style[Spry.Effect.Utils.camelize(prop)];
if (!value)
{
if (document.defaultView && document.defaultView.getComputedStyle)
{
var css = document.defaultView.getComputedStyle(element, null);
value = css ? css.getPropertyValue(prop) : null;
}
else if (element.currentStyle)
{
value = element.currentStyle[Spry.Effect.Utils.camelize(prop)];
}
}
}
catch (e) {}
return value == 'auto' ? null : value;
};
Spry.Debugger.Utils.getIntProp = function(element, prop){
var a = parseInt(Spry.Debugger.Utils.getStyleProp(element, prop),10);
if (isNaN(a))
return 0;
return a;
};
Spry.Debugger.Utils.getBorderBox = function (el, doc) {
doc = doc || document;
if (typeof(el) == 'string') {
el = doc.getElementById(el);
}
if (!el) {
return false;
}
if (el.parentNode === null || Spry.Debugger.Utils.getStyleProp(el, 'display') == 'none') {
//element must be visible to have a box
return false;
}
var ret = {x:0, y:0, width:0, height:0};
var parent = null;
var box;
if (el.getBoundingClientRect) { // IE
box = el.getBoundingClientRect();
var scrollTop = doc.documentElement.scrollTop || doc.body.scrollTop;
var scrollLeft = doc.documentElement.scrollLeft || doc.body.scrollLeft;
ret.x = box.left + scrollLeft;
ret.y = box.top + scrollTop;
ret.width = box.right - box.left;
ret.height = box.bottom - box.top;
} else if (doc.getBoxObjectFor) { // gecko
box = doc.getBoxObjectFor(el);
ret.x = box.x;
ret.y = box.y;
ret.width = box.width;
ret.height = box.height;
var btw = Spry.Debugger.Utils.getIntProp(el, "border-top-width");
var blw = Spry.Debugger.Utils.getIntProp(el, "border-left-width");
ret.x -= blw;
ret.y -= btw;
} else { // safari/opera
ret.x = el.offsetLeft;
ret.y = el.offsetTop;
ret.width = el.offsetWidth;
ret.height = el.offsetHeight;
parent = el.offsetParent;
if (parent != el) {
while (parent) {
ret.x += parent.offsetLeft;
ret.y += parent.offsetTop;
parent = parent.offsetParent;
}
}
var blw = Spry.Debugger.Utils.getIntProp(el, "border-left-width");
var btw = Spry.Debugger.Utils.getIntProp(el, "border-top-width");
ret.x -= blw;
ret.y -= btw;
// opera & (safari absolute) incorrectly account for body offsetTop
var ua = navigator.userAgent.toLowerCase();
if (Spry.is.opera || Spry.is.safari && Spry.Debugger.Utils.getIntProp(el, 'position') == 'absolute')
( run in 0.749 second using v1.01-cache-2.11-cpan-39bf76dae61 )