Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "tv", | ||
"description": "Interactive debug console plugin for hapi", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)", | ||
@@ -10,3 +10,3 @@ "contributors":[ | ||
"Ben Nguyen <benobviate@gmail.com>", | ||
"Alex Lande" | ||
"Alex Lande <alexlande@gmail.com>" | ||
], | ||
@@ -13,0 +13,0 @@ "repository": "git://github.com/spumko/tv", |
@@ -1,6 +0,5 @@ | ||
(function (window, $, _) { | ||
(function (window, $, _, interact) { | ||
$.tv = $.tv || {}; // Add tv plugin namespace | ||
var tagList = []; // Complete Tag List | ||
@@ -21,3 +20,15 @@ var requestList = []; | ||
]; | ||
var defaultColumnList = [ | ||
{ "name": "timestamp" }, | ||
{ "name": "method" }, | ||
{ "name": "path" }, | ||
{ "name": "data" }, | ||
{ "name": "tags" } | ||
]; | ||
var columnList = JSON.parse(localStorage.getItem("columnList")) || _.clone(defaultColumnList, true); | ||
var $dragEl = null; | ||
var $resizeCol = null; | ||
function tagsContain (tags, tagName) { | ||
@@ -172,3 +183,3 @@ | ||
var mergeKeys = ["method", "path", "truncatedPath"]; | ||
var mergeKeys = ["method", "path"]; | ||
requestList = requestList.map(function (request) { | ||
@@ -237,3 +248,2 @@ | ||
var path = payload.data ? payload.data.url : null; | ||
var truncatedPath = path && path.length > 15 ? path.substring(0, 15) + '...' : path; | ||
@@ -244,3 +254,2 @@ var requestData = { | ||
path: path, | ||
truncatedPath: truncatedPath, | ||
data: payload.data, | ||
@@ -294,3 +303,2 @@ rawTimestamp: payload.timestamp, | ||
$('#tagList').on('change', ':checkbox', function() { | ||
@@ -310,8 +318,87 @@ | ||
$('#reset-columns').on('click', function(e) { | ||
e.preventDefault(); | ||
resetCols(); | ||
}); | ||
$table.on('click', '.data ul', function(e) { | ||
$(this).toggleClass('expanded'); | ||
e.stopPropagation(); | ||
}).on('dragstart th', function(e) { | ||
$dragEl = $(e.target); | ||
// Firefox requires setData for drag and drop behavior. | ||
e.originalEvent.dataTransfer.setData('text/plain', ''); | ||
e.originalEvent.dataTransfer.effectAllowed = 'move'; | ||
}).on('dragover th', function(e) { | ||
var $dragEl = $(e.target); | ||
e.preventDefault(); | ||
$dragEl.addClass("is-droppable"); | ||
}).on('dragleave th', function(e) { | ||
var $dragEl = $(e.target); | ||
$dragEl.removeClass("is-droppable"); | ||
}).on('drop th', function(e) { | ||
var $dropEl = $(e.target); | ||
e.stopPropagation(); | ||
if (!$dropEl.is('th') || $dropEl.is($dragEl)) { return; } | ||
if ($dropEl.prevAll().filter($dragEl).length) { | ||
$dragEl.insertAfter($dropEl); | ||
} else { | ||
$dragEl.insertBefore($dropEl); | ||
} | ||
orderCols(); | ||
}).on('dragend', function(e) { | ||
$('th').removeClass('is-droppable'); | ||
}); | ||
$('thead').on('mouseenter', function() { | ||
$('.cursor-styles').html('html { cursor: move; }'); | ||
}).on('mouseleave', function() { | ||
$('.cursor-styles').html(''); | ||
}); | ||
interact("th").resizeable({ | ||
onstart: function(e) { | ||
startColResize($(e.target)); | ||
}, | ||
onmove: function(e) { | ||
adjustColWidth(e.dx); | ||
}, | ||
onend: function (e) { | ||
saveColWidth(); | ||
} | ||
}); | ||
} | ||
function startColResize ($sourceEl) { | ||
var index = $("th").index($sourceEl); | ||
$resizeCol = $("col").eq(index); | ||
$resizeCol.width($sourceEl.outerWidth()); | ||
} | ||
function adjustColWidth (widthChange) { | ||
$resizeCol.width($resizeCol.width() + widthChange); | ||
} | ||
function saveColWidth () { | ||
_.forEach(columnList, function (col) { | ||
if (col.name === $resizeCol.data('name')) { | ||
col.width = $resizeCol.width(); | ||
} | ||
}); | ||
saveCols(); | ||
$resizeCol = null; | ||
} | ||
function compileTemplates () { | ||
@@ -322,4 +409,61 @@ | ||
$.tv.templates.tags = Handlebars.compile($('#tags-template').html()); | ||
$.tv.templates.thead = Handlebars.compile($('#thead-template').html()); | ||
$.tv.templates.colgroup = Handlebars.compile($('#colgroup-template').html()); | ||
$.tv.templates.colEl = Handlebars.compile($('#col-element-template').html()); | ||
$.tv.templates.colHeadingTpl = Handlebars.compile($('#colheading-template').html()); | ||
// Column partials | ||
$.tv.templates.col = $.tv.templates.col || {}; | ||
$.tv.templates.col.timestamp = Handlebars.compile($('#col-timestamp-template').html()); | ||
$.tv.templates.col.method = Handlebars.compile($('#col-method-template').html()); | ||
$.tv.templates.col.path = Handlebars.compile($('#col-path-template').html()); | ||
$.tv.templates.col.data = Handlebars.compile($('#col-data-template').html()); | ||
$.tv.templates.col.tags = Handlebars.compile($('#col-tags-template').html()); | ||
} | ||
function orderCols () { | ||
var reorderedColumnList = []; | ||
$("th").each(function () { | ||
var col = _.where(columnList, { name: $(this).html() }); | ||
reorderedColumnList.push(col[0]); | ||
}); | ||
columnList = reorderedColumnList; | ||
saveCols(); | ||
render(); | ||
} | ||
function saveCols () { | ||
localStorage.setItem("columnList", JSON.stringify(columnList)); | ||
} | ||
function resetCols () { | ||
localStorage.setItem("columnList", null); | ||
columnList = defaultColumnList; | ||
render(); | ||
} | ||
function render () { | ||
$('colgroup') | ||
.html('') | ||
.append($.tv.templates.colgroup()); | ||
$('thead') | ||
.html('') | ||
.append($.tv.templates.thead()); | ||
$('tbody').html(''); | ||
requestList.forEach(function (requestData) { | ||
$('tbody').prepend($.tv.templates.row(requestData)); | ||
}); | ||
} | ||
// Grouping Stuff | ||
@@ -502,3 +646,38 @@ var Grouping = function () { | ||
}); | ||
Handlebars.registerHelper('columnHeadings', function () { | ||
var self = this, | ||
colHeadings = []; | ||
_.forEach(columnList, function (col) { | ||
colHeadings.push($.tv.templates.colHeadingTpl(col)); | ||
}); | ||
return new Handlebars.SafeString(colHeadings.join('')); | ||
}); | ||
Handlebars.registerHelper('columnElements', function () { | ||
var self = this, | ||
cols = []; | ||
_.forEach(columnList, function (col) { | ||
cols.push($.tv.templates.colEl(col)); | ||
}); | ||
return new Handlebars.SafeString(cols.join('')); | ||
}); | ||
Handlebars.registerHelper('columnList', function () { | ||
var self = this, | ||
colList = []; | ||
_.forEach(columnList, function (col) { | ||
colList.push($.tv.templates.col[col.name](self)); | ||
}); | ||
return new Handlebars.SafeString(colList.join('')); | ||
}); | ||
render(); | ||
}; | ||
})(window, jQuery, _); | ||
})(window, jQuery, _, interact); |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
534166
20
12556
0