From d2a30c1d13802571b3149cd5305e81d736c41fff Mon Sep 17 00:00:00 2001 From: David Cormier Date: Fri, 25 Jul 2014 17:34:29 -0400 Subject: [PATCH 1/3] Plugin visibility defaults to value of rootScope.visible And plugin content is shown if it has to be visible --- js/glowingbear.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index c591bda..4dbae7b 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -1300,7 +1300,7 @@ weechat.config(['$routeProvider', ]); -weechat.directive('plugin', function() { +weechat.directive('plugin', function($rootScope) { /* * Plugin directive * Shows additional plugin content @@ -1316,6 +1316,8 @@ weechat.directive('plugin', function() { $scope.displayedContent = ""; + $scope.plugin.visible = $rootScope.visible; + $scope.hideContent = function() { $scope.plugin.visible = false; }; @@ -1339,6 +1341,10 @@ weechat.directive('plugin', function() { }; setTimeout(scroll, 100); }; + + if ($scope.plugin.visible) { + $scope.showContent(); + } } }; }); From ceb31c1947714b51f4ab4b13505ad35a45e9e7de Mon Sep 17 00:00:00 2001 From: David Cormier Date: Fri, 25 Jul 2014 17:32:55 -0400 Subject: [PATCH 2/3] contentForMessage doesn't have to care about content visibility --- js/glowingbear.js | 2 +- js/plugins.js | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 4dbae7b..66d8511 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -63,7 +63,7 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', function buffer.requestedLines++; // Only react to line if its displayed if (message.displayed) { - message = plugins.PluginManager.contentForMessage(message, $rootScope.visible); + message = plugins.PluginManager.contentForMessage(message); buffer.addLine(message); if (manually) { diff --git a/js/plugins.js b/js/plugins.js index eba813d..9e7f30b 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -53,7 +53,7 @@ plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) { * Iterates through all the registered plugins * and run their contentForMessage function. */ - var contentForMessage = function(message, visible) { + var contentForMessage = function(message) { message.metadata = []; for (var i = 0; i < plugins.length; i++) { @@ -66,10 +66,9 @@ plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) { var pluginContent = plugins[i].contentForMessage(message.text); if (pluginContent) { - pluginContent = {'visible': visible, - 'content': $sce.trustAsHtml(pluginContent), - 'nsfw': nsfw, - 'name': plugins[i].name }; + pluginContent = {'content': $sce.trustAsHtml(pluginContent), + 'nsfw': nsfw, + 'name': plugins[i].name }; message.metadata.push(pluginContent); From 04efb1642461e7593c2cdc67c69cce01780c21f7 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Fri, 25 Jul 2014 17:51:21 -0400 Subject: [PATCH 3/3] Rename rootScope.visible -> rootScope.auto_display_embedded_content More verbose but more descriptive --- js/glowingbear.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 66d8511..3f442a3 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -881,7 +881,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } // Save setting for displaying embeds in rootScope so it can be used from service - $rootScope.visible = $scope.noembed === false; + $rootScope.auto_display_embedded_content = $scope.noembed === false; $scope.isSidebarVisible = function() { return document.getElementById('sidebar').getAttribute('sidebar-state') === 'visible'; @@ -934,7 +934,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // Watch model and update show setting when it changes $scope.$watch('noembed', function() { - $rootScope.visible = $scope.noembed === false; + $rootScope.auto_display_embedded_content = $scope.noembed === false; }); // Watch model and update channel sorting when it changes $scope.$watch('orderbyserver', function() { @@ -1316,7 +1316,7 @@ weechat.directive('plugin', function($rootScope) { $scope.displayedContent = ""; - $scope.plugin.visible = $rootScope.visible; + $scope.plugin.visible = $rootScope.auto_display_embedded_content; $scope.hideContent = function() { $scope.plugin.visible = false;