mojito-debug
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -114,5 +114,7 @@ /* | ||
// need to remove auto from height else it will close immediately | ||
if (!this.maximized) { | ||
contentWrapper.setStyle("height", contentWrapper.get("scrollHeight") + "px"); | ||
// need to remove auto from height else it will close immediately | ||
contentWrapper.setStyle("height", contentWrapper.get("offsetHeight") + "px") | ||
// When closed make sure overflowing content is not visible. | ||
.setStyle('overflow', 'hidden'); | ||
} | ||
@@ -127,3 +129,5 @@ | ||
if (this.maximized) { | ||
contentWrapper.setStyle("height", "auto"); | ||
contentWrapper.setStyle("height", "auto") | ||
// When open allow overflow to show. | ||
.setStyle('overflow', 'visible'); | ||
} | ||
@@ -130,0 +134,0 @@ }.bind(this)); |
@@ -7,3 +7,3 @@ /* | ||
/*jslint browser: true */ | ||
/*jslint browser: true, nomen: true, plusplus: true */ | ||
/*global YUI */ | ||
@@ -19,9 +19,17 @@ | ||
if (Y.Object.size(json) === 2 && json.json && json.options) { | ||
options = Y.mix(json.options, options); | ||
json = json.json; | ||
} | ||
if (Y.Lang.isObject(json)) { | ||
tree = new Y.TreeView({ | ||
container: node, | ||
nodes: self.getNodes(json) | ||
nodes: this.getNodes(json) | ||
}); | ||
tree.render(); | ||
tree.render(); | ||
if (Y.Lang.isObject(options)) { | ||
this.addOptions(options, json, tree); | ||
} | ||
} else { | ||
@@ -53,2 +61,61 @@ node.append(String(json)); | ||
return nodes; | ||
}, | ||
addOptions: function (options, json, tree) { | ||
if (options.text) { | ||
this.addText(options.text, json, tree); | ||
} | ||
}, | ||
addText: function (text, json, tree) { | ||
var firstLabel = tree.children[0] && tree.children[0]._htmlNode.one('.yui3-treeview-label'), | ||
// If the text is a string, use that instead of stringifying the json. | ||
jsonString = Y.Lang.isString(text) ? text : JSON.stringify(json, null, 4), | ||
numLines = 0, | ||
widthSet = false, | ||
textContainer = Y.Node.create('<span/>'), | ||
textArea = Y.Node.create('<textarea readonly wrap="off"/>') | ||
.addClass('yui3-treeview-text-area'), | ||
textButton = Y.Node.create('<img/>') | ||
.set('title', 'Toggle JSON text, double click show JSON text on new page.') | ||
.addClass('yui3-treeview-text-button') | ||
.set('src', 'http://svn.corp.yahoo.com/docroot/images/log.png'); | ||
Y.Array.each(jsonString, function (c) { | ||
if (c === '\n') { | ||
numLines++; | ||
} | ||
}); | ||
// Set the height accornding to the number of lines as long as it is | ||
// between the specified range. | ||
textArea.setStyle('height', 16 * Math.min(15, numLines)); | ||
textArea.set("text", jsonString); | ||
textArea.toggleView(); | ||
textArea.hide(); | ||
// Toggle textarea after a single click. | ||
textButton.on("click", function (e) { | ||
textArea.toggleView(); | ||
if (!widthSet) { | ||
// Set the width to the scroll width as long as it doesn't exceed the specified width. | ||
textArea.setStyle('width', Math.min(500, textArea.get('scrollWidth'))); | ||
widthSet = true; | ||
} | ||
e.stopPropagation(); | ||
}); | ||
// Open up a new window with the jsonString. | ||
textButton.on("dblclick", function (e) { | ||
var newWindow = window.open(); | ||
newWindow.document.write("<pre>" + Y.Escape.html(jsonString) + "</pre>"); | ||
newWindow.document.body.style.margin = 0; | ||
newWindow.document.close(); | ||
e.stopPropagation(); | ||
}); | ||
textContainer.append(textButton); | ||
textContainer.append(textArea); | ||
firstLabel.append(textContainer); | ||
} | ||
@@ -55,0 +122,0 @@ }; |
{ | ||
"name": "mojito-debug", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "mojito-debug helps developers debug their applications through debug hooks, whose results are shown on the client-side under the application when the 'debug' parameter appears in the URL.", | ||
@@ -5,0 +5,0 @@ "author": "Albert Jimenez <jimenez@yahoo-inc.com>", |
@@ -18,6 +18,11 @@ /*jslint plusplus: true */ | ||
ac.debug.setContent('simple-hook', { | ||
"version": version, | ||
"simple-hook": { | ||
created: info.time, | ||
location: info.location | ||
json: { | ||
"version": version, | ||
"simple-hook": { | ||
created: info.time, | ||
location: info.location | ||
} | ||
}, | ||
options: { | ||
text: true | ||
} | ||
@@ -24,0 +29,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
301878
2658