Only retrieve plugin content when 'Show Content' is pressed

This commit is contained in:
David Cormier 2014-02-06 21:21:49 -05:00
parent 6b12926887
commit f4ee683100
2 changed files with 37 additions and 11 deletions

View file

@ -1,17 +1,18 @@
<div ng-show="data.visible">
<div ng-show="plugin.visible">
<button class="btn btn-primary btn-sm pull-right"
ng-click="data.visible = false">
Hide {{ data.name }}
ng-click="hideContent()">
Hide {{ plugin.name }}
</button>
<div ng-bind-html="data.content"></div>
<div ng-bind-html="displayedContent"></div>
</div>
<div ng-hide="data.visible">
<div ng-hide="plugin.visible">
<button class="btn btn-sm pull-right"
bo-class="{
'btn-warning': data.nsfw,
'btn-primary': !data.nsfw}"
ng-click="data.visible = true">
Show {{ data.name }}
'btn-warning': plugin.nsfw,
'btn-primary': !plugin.nsfw}"
ng-click="showContent()">
Show {{ plugin.name }}
</button>
</div>

View file

@ -764,13 +764,38 @@ weechat.config(['$routeProvider',
weechat.directive('plugin', function() {
/*
* Plugin directive
* Shows additional plugin content
*/
return {
templateUrl: 'directives/plugin.html',
scope: {
data: '=data',
plugin: '=data',
},
controller: function($scope) {
$scope.displayedContent = "";
$scope.hideContent = function() {
$scope.plugin.visible = false;
}
$scope.showContent = function() {
/*
* Shows the plugin content.
* displayedContent is bound to the DOM.
* Actual plugin content is only fetched when
* content is shown.
*/
$scope.displayedContent = $scope.plugin.content;
$scope.plugin.visible = true;
}
}
}
});