Update firerecord.js

This update reflects some of Rylans contributions in the past week toward the current UI
This commit is contained in:
djwesty 2013-03-05 09:27:09 -05:00
parent 7a5f432064
commit 9f008297ef

View File

@ -2,62 +2,84 @@
* To change this template, choose Tools | Templates * To change this template, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */
FBL.ns(function () { FBL.ns(function() { with (FBL) {
with (FBL) { // Panel
// Panel var panelName = "firerecord";
var panelName = "firerecord";
/** /**
* @panel This panel integrates with Firebug Inspector API and provides own logic * @panel This panel integrates with Firebug Inspector API and provides own logic
* and display of custom information for links. This code serves as an example of * and display of custom information for links. This code serves as an example of
* how to properly use and implement Inspector. * how to properly use and implement Inspector.
*/ */
function FireRecordPanel() { } function FireRecordPanel() {}
FireRecordPanel.prototype = extend(Firebug.Panel, FireRecordPanel.prototype = extend(Firebug.Panel,
/** @lends LinkInspectorPanel */ /** @lends LinkInspectorPanel */
{ {
name: panelName, name: panelName,
title: "Trial by Fire", title: "FireRecord",
inspectable: true,
inspectHighlightColor: "red",
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Initialization // Initialization
initialize: function () { initialize: function()
{
Firebug.Panel.initialize.apply(this, arguments); Firebug.Panel.initialize.apply(this, arguments);
if (FBTrace.DBG_ACTIVABLEPANEL)
FBTrace.sysout("ActivablePanel.initialize;");
Firebug.Inspector.addListener(this); Firebug.Inspector.addListener(this);
}, },
destroy: function (state) { destroy: function(state)
{
Firebug.Panel.destroy.apply(this, arguments); Firebug.Panel.destroy.apply(this, arguments);
Firebug.Inspector.removeListener(this); Firebug.Inspector.removeListener(this);
}, },
show: function (state) { show: function(state)
{
Firebug.Panel.show.apply(this, arguments); Firebug.Panel.show.apply(this, arguments);
this.showToolbarButtons("panelButtons", true);
FireRecordPlate.defaultContent.replace({}, this.panelNode); FireRecordPlate.tag.replace({array: inputArray}, this.panelNode);
//FireRecordPlate.defaultContent.replace({}, this.panelNode);
}, },
getOptionsMenuItems: function(context)
{
return [
// Will be resolved to "extensions.firebug.myoptionprefname"
optionMenu("Custom Scripts", "myoptionprefname", "Allow Custom Script")
];
},
onActivationChanged: function(enable)
{
if (FBTrace.DBG_ACTIVABLEPANEL)
FBTrace.sysout("ActivablePanel.onActivationChanged; " + enable);
if (enable)
Firebug.MyActivableModule.addObserver(this);
else
Firebug.MyActivableModule.removeObserver(this);
},
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Inspector API implementation // Inspector API implementation
startInspecting: function () { startInspecting: function()
{
if (FBTrace.DBG_FIRERECORD) if (FBTrace.DBG_FIRERECORD)
FBTrace.sysout("fire_record; startInspecting()"); FBTrace.sysout("fire_record; startInspecting()");
}, },
inspectNode: function (node) { inspectNode: function(node)
{
if (FBTrace.DBG_FIRERECORD) if (FBTrace.DBG_FIRERECORD)
FBTrace.sysout("fire_record; inspectNode(node: " + node.tagName + ")"); FBTrace.sysout("fire_record; inspectNode(node: " + node.tagName + ")");
FireRecordPlate.tName.replace({ object: node }, this.panelNode); FireRecordPlate.tName.replace({object: node}, this.panelNode);
}, },
stopInspecting: function (node, canceled) { stopInspecting: function(node, canceled)
{
if (FBTrace.DBG_FIRERECORD) if (FBTrace.DBG_FIRERECORD)
FBTrace.sysout("fire_record; stopInspecting(node: " + node.tagName + FBTrace.sysout("fire_record; stopInspecting(node: " + node.tagName +
", canceled: " + canceled + ")"); ", canceled: " + canceled + ")");
@ -68,21 +90,23 @@ FBL.ns(function () {
if (node.href.indexOf("http") != 0) if (node.href.indexOf("http") != 0)
return; return;
FireRecordPlate.linkPreview.replace({ object: node }, this.panelNode); FireRecordPlate.linkPreview.replace({object: node}, this.panelNode);
}, },
supportsObject: function (object, type) { supportsObject: function(object, type)
if (object instanceof Element) { {
if (object.tagName.toLowerCase() == "a") { if (object instanceof Element)
{
if (object.tagName.toLowerCase() == "a"){
return 1; return 1;
} }
if (object.tagName.toLowerCase() == "button") { if (object.tagName.toLowerCase() == "button"){
return 1; return 1;
} }
if (object.tagName.toLowerCase() == "img") { if (object.tagName.toLowerCase() == "img"){
return 1; return 1;
} }
if (object.tagName.toLowerCase() == "input") { if (object.tagName.toLowerCase() == "input"){
return 1; return 1;
} }
} }
@ -93,91 +117,157 @@ FBL.ns(function () {
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Inspector Listener // Inspector Listener
onStartInspecting: function (context) { onStartInspecting: function(context)
{
if (FBTrace.DBG_FIRERECORD) if (FBTrace.DBG_FIRERECORD)
FBTrace.sysout("fire_record; Listener.onStartInspecting(context: " + FBTrace.sysout("fire_record; Listener.onStartInspecting(context: " +
context.getTitle() + ")"); context.getTitle() + ")");
}, },
onInspectNode: function (context, node) { onInspectNode: function(context, node)
{
if (FBTrace.DBG_FIRERECORD) if (FBTrace.DBG_FIRERECORD)
FBTrace.sysout("fire_record; Listener.onInspectNode(context: " + FBTrace.sysout("fire_record; Listener.onInspectNode(context: " +
context.getTitle() + ", node: " + node.tagName + ")"); context.getTitle() + ", node: " + node.tagName + ")");
}, },
onStopInspecting: function (context, node, canceled) { onStopInspecting: function(context, node, canceled)
{
if (FBTrace.DBG_FIRERECORD) if (FBTrace.DBG_FIRERECORD)
FBTrace.sysout("fire_record; Listener.onStopInspecting(context: " + FBTrace.sysout("fire_record; Listener.onStopInspecting(context: " +
context.getTitle() + ", node: " + node.tagName + ", canceled: " + context.getTitle() + ", node: " + node.tagName + ", canceled: " +
canceled + ")"); canceled + ")");
} }
});
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
var inputArray = ["red", "green", "blue", "white"];
var FireRecordPlate = domplate(
{
tag:
FOR("item", "$array",
DIV({onclick: "$handleClick"},
"$item"
)
),
handleClick: function(event)
{
alert(event.target.innerHTML);
}
}); });
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
var FireRecordPlate = domplate(
{
/*var FireRecordPlate = domplate(
{
tName: tName:
DIV({ "class": "tName" }, "$object.id"), DIV({"class": "tName"}, "$object.id" ),
linkPreview: linkPreview:
IFRAME({ "class": "linkPreview", "src": "$object.href" }), IFRAME({"class": "linkPreview", "src": "$object.href"}),
defaultContent: defaultContent:
DIV({ "class": "defaultContent" }, DIV({"class": "defaultContent"},
"Use Trial by Fire to record DOM events for later playback." "Use Trial by Fire to record DOM events for later playback."
) )
}); });*/
// ********************************************************************************************* // // ********************************************************************************************* //
// Module & Customizing Tracing // Module & Customizing Tracing
/** /**
* @module The module object isn't really neccessary for the Inspector API. It serves * @module The module object isn't really neccessary for the Inspector API. It serves
* only to support Firebug tracing console, which is useful when debugging inspector * only to support Firebug tracing console, which is useful when debugging inspector
* features. * features.
*/ */
Firebug.FireRecordModule = extend(Firebug.Module, Firebug.FireRecordModule = extend(Firebug.ActivableModule,
/** @lends Firebug.FireRecordModule */ /** @lends Firebug.FireRecordModule */
{
initialize: function()
{ {
initialize: function () { Firebug.ActivableModule.initialize.apply(this, arguments);
Firebug.Module.initialize.apply(this, arguments);
if (Firebug.TraceModule) if (Firebug.TraceModule)
Firebug.TraceModule.addListener(this); Firebug.TraceModule.addListener(this);
}, },
shutdown: function () { onMyButton: function()
Firebug.Module.shutdown.apply(this, arguments); {
alert("hi");
},
shutdown: function()
{
Firebug.ActivableModule.shutdown.apply(this, arguments);
if (Firebug.TraceModule) if (Firebug.TraceModule)
Firebug.TraceModule.removeListener(this); Firebug.TraceModule.removeListener(this);
}, },
onObserverChange: function(observer)
{
if (FBTrace.DBG_ACTIVABLEPANEL)
FBTrace.sysout("ActivableModule.onObserverChange;");
if (this.hasObservers())
{
// There are observers (panels) using this model, let's activate necessary hooks.
}
else
{
// There are no observer using this model, let's clean up registered hooks.
}
},
onSuspendFirebug: function(context)
{
if (FBTrace.DBG_ACTIVABLEPANEL)
FBTrace.sysout("ActivableModule.onSuspendFirebug;");
},
// Called before any suspend actions. Firest caller to return true aborts suspend.
onSuspendingFirebug: function()
{
if (FBTrace.DBG_ACTIVABLEPANEL)
FBTrace.sysout("ActivableModule.onSuspendingFirebug;");
},
onResumeFirebug: function(context)
{
if (FBTrace.DBG_ACTIVABLEPANEL)
FBTrace.sysout("ActivableModule.onResumeFirebug;");
},
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Trace Listener // Trace Listener
onLoadConsole: function (win, rootNode) { onLoadConsole: function(win, rootNode)
{
appendStylesheet(rootNode.ownerDocument, "chrome://firerecord/skin/inspector.css"); appendStylesheet(rootNode.ownerDocument, "chrome://firerecord/skin/inspector.css");
}, },
onDump: function (message) { onDump: function(message)
{
var index = message.text.indexOf("fire_record;"); var index = message.text.indexOf("fire_record;");
if (index == 0) { if (index == 0)
{
message.text = message.text.substr("fire_record;".length); message.text = message.text.substr("fire_record;".length);
message.text = trim(message.text); message.text = trim(message.text);
message.type = "DBG_FIRERECORD"; message.type = "DBG_FIRERECORD";
} }
}
});
// Registration
Firebug.registerPanel(FireRecordPanel);
Firebug.registerModule(Firebug.FireRecordModule);
Firebug.registerStylesheet("chrome://firerecord/skin/inspector.css");
} }
}); });
// Registration
Firebug.registerPanel(FireRecordPanel);
Firebug.registerModule(Firebug.FireRecordModule);
Firebug.registerStylesheet("chrome://firerecord/skin/inspector.css");
}});