From b6c8c8df80478dfb26780494ded30ac27982f7c8 Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Wed, 15 Jul 2015 14:56:04 +0900 Subject: [PATCH] refresh highlights on debug mode trigger; various template tweaks --- .../lib/client/templates/posts_daily.html | 1 - .../lib/client/stylesheets/highlight.scss | 15 ++++---- .../telescope-debug/lib/client/templates.js | 38 +++++++------------ .../templates/posts_list/posts_list.html | 1 - .../lib/client/templates/posts_views_nav.html | 2 +- .../lib/client/templates/tagline_banner.html | 8 ++-- .../lib/client/scss/modules/_posts.scss | 2 +- 7 files changed, 27 insertions(+), 40 deletions(-) diff --git a/packages/telescope-daily/lib/client/templates/posts_daily.html b/packages/telescope-daily/lib/client/templates/posts_daily.html index 9b51e876b..0ff12aa7f 100644 --- a/packages/telescope-daily/lib/client/templates/posts_daily.html +++ b/packages/telescope-daily/lib/client/templates/posts_daily.html @@ -4,7 +4,6 @@ {{> before_day}} {{> day_heading date=date}} {{> posts_list_controller context}} - {{> after_day}} {{/each}} {{> load_more_days}} diff --git a/packages/telescope-debug/lib/client/stylesheets/highlight.scss b/packages/telescope-debug/lib/client/stylesheets/highlight.scss index 49c6c3d0c..c7725503d 100644 --- a/packages/telescope-debug/lib/client/stylesheets/highlight.scss +++ b/packages/telescope-debug/lib/client/stylesheets/highlight.scss @@ -11,8 +11,8 @@ } } -.template-highlighter:hover:after{ - display: inline-block; +.template-highlighter:after{ + display: none; content: attr(data-template); background:red; color:white; @@ -23,13 +23,14 @@ z-index: 20000; padding: 2px 8px; } +.template-highlighter:hover:after{ + display: inline-block; +} .zone-highlighter{ border-color: rgba(0,0,255,0.3); - &:hover{ - // background: rgba(0,0,255,0.15); + &:after, &:hover:after{ + display: inline-block; + background: blue; } } -.zone-highlighter:hover:after{ - background: blue; -} \ No newline at end of file diff --git a/packages/telescope-debug/lib/client/templates.js b/packages/telescope-debug/lib/client/templates.js index cafd9ec67..095e86adb 100644 --- a/packages/telescope-debug/lib/client/templates.js +++ b/packages/telescope-debug/lib/client/templates.js @@ -42,22 +42,12 @@ var createHighlighter = function (templateName, $node) { $node.append(div); }; -Router.configure({ - onBeforeAction: function () { - // clear out all previous template highlighters - this.next(); - }, - onRun: function () { - // console.log("route changed"); - $(".template-highlighter").remove(); - - // trigger autorun to re-run - templatesDep.changed(); - } -}); - Telescope.debug.refresh = function () { console.log('refreshing…') + + $(".template-highlighter").remove(); + + // trigger autorun to re-run templatesDep.changed(); }; @@ -67,7 +57,7 @@ Template.onRendered(function () { var templateName = template.view.name.replace("Template.", ""); // exclude weird Blaze stuff and special templates - var excludedTemplates = ["__dynamicWithDataContext", "__dynamic", "module", "menuComponent", "menuItem", "avatar"]; + var excludedTemplates = ["__dynamicWithDataContext", "__dynamic", "module", "menuComponent", "menuItem", "avatar", "posts_list_controller"]; if (!_.contains(excludedTemplates, templateName)) { @@ -75,13 +65,14 @@ Template.onRendered(function () { templatesDep.depend() ; - // console.log(templateName) - // console.log(template) - // console.log("-------------") + console.log(templateName) + console.log(_.clone(template)) + console.log("-------------") // put this in setTimeout so app has the time to load in and render content Meteor.setTimeout(function () { + // TODO: when using {{#if}}, template.firstNode stays empty even after it's rendered var node = template.firstNode; if (node) { @@ -93,8 +84,8 @@ Template.onRendered(function () { // if this is a text node, try using nextElementSibling instead if (node.nodeName === "#text") { - if (node.nextElementSibling) { - node = node.nextElementSibling; + if (node.nextSibling && node.nextSibling.nodeName !== "#text") { + node = node.nextSibling; } else { throw new Error("Node has no content"); } @@ -110,7 +101,7 @@ Template.onRendered(function () { console.log(error); } } - }, 1000); + }, 100); }); } @@ -124,11 +115,8 @@ $(function () { if (!allowKeydown) return; if(e.keyCode === 192){ - $("body").addClass("show-highlighters"); - } - - if(e.keyCode === 27){ Telescope.debug.refresh(); + $("body").addClass("show-highlighters"); } allowKeydown = false; diff --git a/packages/telescope-posts/lib/client/templates/posts_list/posts_list.html b/packages/telescope-posts/lib/client/templates/posts_list/posts_list.html index f09b6cfc1..89ec248e5 100644 --- a/packages/telescope-posts/lib/client/templates/posts_list/posts_list.html +++ b/packages/telescope-posts/lib/client/templates/posts_list/posts_list.html @@ -29,7 +29,6 @@ showFilters (Boolean)