");
topBorderDiv.css({"position":"absolute", "top":e.offset().top + "px", "left":e.offset().left + "px", "height":"0px", "width":e.width() + "px", "border":"1px solid red"});
bottomBorderDiv.css({"position":"absolute", "top":(e.offset().top + e.height()) + "px", "left":e.offset().left + "px", "height":"0px", "width":e.width() + "px", "border":"1px solid red"});
leftBorderDiv.css({"position":"absolute", "top":e.offset().top + "px", "left":e.offset().left + "px", "height":e.height() + "px", "width":"0px", "border":"1px solid red"});
rightBorderDiv.css({"position":"absolute", "top":e.offset().top + "px", "left":(e.offset().left + e.width()) + "px", "height":e.height() + "px", "width":"0px", "border":"1px solid red"});
$("body").append(topBorderDiv, bottomBorderDiv, leftBorderDiv, rightBorderDiv);
_elements.push(topBorderDiv);
_elements.push(bottomBorderDiv);
_elements.push(leftBorderDiv);
_elements.push(rightBorderDiv);
}
var addMouseEventsToInfoContainer = function(infoContainer, filepath, nodename, namespace, name, match)
{
infoContainer.click(function()
{
_currentFilepath = filepath;
_currentNodename = nodename;
_currentNamespace = namespace;
_currentName = name;
_currentMatch = match;
var responseName = "requestedNameTemplate";
var url = gs.xsltParams.library_name + "?a=g&rt=r&s=RetrieveXMLTemplateFromFile&s1.filePath=" + _currentFilepath + "&s1.namespace=" + _currentNamespace + "&s1.nodename=" + _currentNodename;
if(_currentMatch && _currentMatch.length > 0){url += "&s1.match=" + _currentMatch; responseName = "requestedMatchTemplate";}
if(_currentName && _currentName.length > 0){url += "&s1.name=" + _currentName;}
$.ajax(url)
.success(function(response)
{
var template;
if(response.search(responseName) != -1)
{
var startIndex = response.indexOf("<" + responseName + ">") + responseName.length + 2;
var endIndex = response.indexOf("" + responseName + ">");
template = response.substring(startIndex, endIndex);
}
else
{
return;
}
var editArea = $("
", {"id":"textEditor"});
editArea.css({"width":"98%", "height":"180px"});
editArea.val(template);
_editingDiv.empty();
_editingDiv.append(editArea);
_editingDiv.css({"height":"190px"});
_editor = ace.edit("textEditor");
_editor.getSession().setMode("ace/mode/xml");
_editor.setValue(template);
_editor.clearSelection();
console.log(_editor);
_mainDiv.css({"height":"500px"});
_closeEditorButton.removeAttr("disabled");
})
.error(function()
{
console.log("ERROR");
});
});
infoContainer.mouseover(function()
{
$(this).data("background", $(this).css("background"));
$(this).css("background", "yellow");
});
infoContainer.mouseout(function()
{
$(this).css("background", $(this).data("background"));
});
}
var addMouseEventsToDebugElements = function(debugElems)
{
debugElems.click(function()
{
if(_debugOn)
{
_pauseSelector = true;
_unpauseButton.removeAttr("disabled");
}
});
debugElems.mouseover(function()
{
if(_debugOn && !_pauseSelector)
{
var nodes = new Array();
if($(this).is("table, tr"))
{
var size = parseInt($(this).attr("debugSize"));
for(var i = 0; i < size; i++)
{
var tempNode = $("
");
tempNode.tempAttrs = new Array();
$(this.attributes).each(function()
{
if(this.value.charAt(0) == '[')
{
var values = eval(this.value);
if(values[i] == "")
{
return;
}
tempNode.attr(this.name, values[i]);
tempNode.tempAttrs.push({name:this.name, value:values[i]});
}
});
nodes.push(tempNode);
}
}
else
{
nodes.push(this);
}
$(nodes).each(function()
{
var filepath = $(this).attr("filename");
var fullNodename = $(this).attr("nodename");
var colonIndex = fullNodename.indexOf(":");
var namespace = fullNodename.substring(0, colonIndex);
var nodename = fullNodename.substring(colonIndex + 1);
var name = $(this).attr("name");
var match = $(this).attr("match");
var infoContainer = $("
");
infoContainer.css({"cursor":"pointer", "border":"1px dashed #AAAAAA", "margin":"5px"});
var fromDIV = $("
");
var elementDIV = $("
");
elementDIV.css("font-size", "1.1em");
fromDIV.css("font-size", "0.9em");
infoContainer.append(fromDIV);
infoContainer.append(elementDIV);
_elements.push(infoContainer);
addMouseEventsToInfoContainer(infoContainer, filepath, nodename, namespace, name, match);
var attrstr = "";
var illegalNames = ["nodename", "filename", "style", "debug", "id", "class"];
var attributes = ((this.tempAttrs) ? this.tempAttrs : this.attributes);
$(attributes).each(function()
{
for(var i = 0; i < illegalNames.length; i++)
{
if(this.name == illegalNames[i]){return;}
}
attrstr += this.name + "=\"" + this.value + "\" ";
});
fromDIV.text("From " + filepath + ":");
elementDIV.text("<" + fullNodename + " " + attrstr + ">");
_textDiv.prepend(infoContainer);
});
if(!_itemSelected)
{
_itemSelected = true;
highlightElement($(this));
}
}
});
debugElems.mouseout(function()
{
if(_debugOn && !_pauseSelector)
{
clearAll();
}
});
}
this.init = function()
{
//We only want this on if we have debug elements in the page
var debugElems = $('debug, [debug="true"]');
if(!debugElems.length)
{
console.log("No debug tags present, debugging disabled.");
return;
}
createDebugDiv();
$("body").append(_mainDiv);
addMouseEventsToDebugElements(debugElems);
}
}
$(window).load(function()
{
var debugWidget = new DebugWidget();
debugWidget.init();
});