From 93f40c64e9f2f4d1f5a0866d82a91dad223ad2f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 15 Feb 2014 14:42:53 +0000 Subject: [PATCH] Fix embed DOM classes Classes, IDs and Names in the DOM have to begin with a letter. The $$hashKey however might not, so prefix it with embed_. This also makes the classes more unique, which is a good thing. Additionally, don't scroll on undefined should that ever happen. Fixes #45 --- directives/plugin.html | 2 +- js/glowingbear.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/directives/plugin.html b/directives/plugin.html index c0669bb..b3b5651 100644 --- a/directives/plugin.html +++ b/directives/plugin.html @@ -4,7 +4,7 @@ Hide {{ plugin.name }} -
+
diff --git a/js/glowingbear.js b/js/glowingbear.js index 8e3ff25..3a2ab93 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -813,8 +813,10 @@ weechat.directive('plugin', function() { // Scroll embed content into view var scroll = function() { - var embed = document.querySelector("." + $scope.plugin.$$hashKey); - embed.scrollIntoViewIfNeeded(); + var embed = document.querySelector(".embed_" + $scope.plugin.$$hashKey); + if (embed) { + embed.scrollIntoViewIfNeeded(); + } }; setTimeout(scroll, 100); };