Merge pull request #466 from glowing-bear/fix-plugins
Fix plugin selectors after angular upgrade
This commit is contained in:
commit
cd4aad7931
3 changed files with 11 additions and 4 deletions
|
@ -4,7 +4,7 @@
|
||||||
Hide {{ ::plugin.name }}
|
Hide {{ ::plugin.name }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div ng-bind-html="displayedContent" class="embed" ng-class="::('embed_' + plugin.$$hashKey)"></div>
|
<div ng-bind-html="displayedContent" class="embed" ng-class="::plugin.className"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-hide="plugin.visible">
|
<div ng-hide="plugin.visible">
|
||||||
|
|
|
@ -21,6 +21,13 @@ weechat.directive('plugin', ['$rootScope', function($rootScope) {
|
||||||
|
|
||||||
$scope.plugin.visible = $rootScope.auto_display_embedded_content;
|
$scope.plugin.visible = $rootScope.auto_display_embedded_content;
|
||||||
|
|
||||||
|
// user-accessible hash key that is a valid CSS class name
|
||||||
|
$scope.plugin.className = "embed_" + $scope.plugin.$$hashKey.replace(':','_');
|
||||||
|
|
||||||
|
$scope.plugin.getElement = function() {
|
||||||
|
return document.querySelector("." + $scope.plugin.className);
|
||||||
|
};
|
||||||
|
|
||||||
$scope.hideContent = function() {
|
$scope.hideContent = function() {
|
||||||
$scope.plugin.visible = false;
|
$scope.plugin.visible = false;
|
||||||
};
|
};
|
||||||
|
@ -33,7 +40,7 @@ weechat.directive('plugin', ['$rootScope', function($rootScope) {
|
||||||
* content is shown.
|
* content is shown.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var embed = document.querySelector(".embed_" + $scope.plugin.$$hashKey);
|
var embed = $scope.plugin.getElement();
|
||||||
|
|
||||||
// If the plugin is asynchronous / lazy, execute it now and let it insert itself
|
// If the plugin is asynchronous / lazy, execute it now and let it insert itself
|
||||||
// TODO store the result between channel switches
|
// TODO store the result between channel switches
|
||||||
|
|
|
@ -348,7 +348,7 @@ plugins.factory('userPlugins', function() {
|
||||||
url = match[0] + '.json';
|
url = match[0] + '.json';
|
||||||
// load gist asynchronously -- return a function here
|
// load gist asynchronously -- return a function here
|
||||||
return function() {
|
return function() {
|
||||||
var element = document.querySelector('.embed_' + this.$$hashKey);
|
var element = this.getElement();
|
||||||
jsonp(url, function(data) {
|
jsonp(url, function(data) {
|
||||||
// Add the gist stylesheet only once
|
// Add the gist stylesheet only once
|
||||||
if (document.querySelectorAll('link[rel=stylesheet][href="' + data.stylesheet + '"]').length < 1) {
|
if (document.querySelectorAll('link[rel=stylesheet][href="' + data.stylesheet + '"]').length < 1) {
|
||||||
|
@ -370,7 +370,7 @@ plugins.factory('userPlugins', function() {
|
||||||
if (match) {
|
if (match) {
|
||||||
url = 'https://api.twitter.com/1/statuses/oembed.json?id=' + match[2];
|
url = 'https://api.twitter.com/1/statuses/oembed.json?id=' + match[2];
|
||||||
return function() {
|
return function() {
|
||||||
var element = document.querySelector('.embed_' + this.$$hashKey);
|
var element = this.getElement();
|
||||||
jsonp(url, function(data) {
|
jsonp(url, function(data) {
|
||||||
// sepearate the HTML into content and script tag
|
// sepearate the HTML into content and script tag
|
||||||
var scriptIndex = data.html.indexOf("<script ");
|
var scriptIndex = data.html.indexOf("<script ");
|
||||||
|
|
Loading…
Reference in a new issue