|
6 | 6 | * Available under the MIT license. |
7 | 7 | */ |
8 | 8 |
|
9 | | -(function() { |
| 9 | +(function () { |
10 | 10 |
|
11 | 11 | /** |
12 | 12 | * Config |
|
19 | 19 | var module; |
20 | 20 | try { |
21 | 21 | module = angular.module(moduleName); |
22 | | - } catch(err) { |
| 22 | + } catch (err) { |
23 | 23 | // named module does not exist, so create one |
24 | 24 | module = angular.module(moduleName, []); |
25 | 25 | } |
26 | 26 |
|
27 | | - module.directive('dirDisqus', ['$window', function($window) { |
| 27 | + module.directive('dirDisqus', ['$window', function ($window) { |
28 | 28 | return { |
29 | 29 | restrict: 'E', |
30 | 30 | scope: { |
31 | 31 | disqus_shortname: '@disqusShortname', |
32 | 32 | disqus_identifier: '@disqusIdentifier', |
33 | | - disqus_title: '@disqusTitle', |
34 | 33 | disqus_url: '@disqusUrl', |
| 34 | + disqus_title: '@disqusTitle', |
35 | 35 | disqus_category_id: '@disqusCategoryId', |
36 | 36 | disqus_disable_mobile: '@disqusDisableMobile', |
37 | | - disqus_config_language : '@disqusConfigLanguage', |
38 | | - disqus_remote_auth_s3 : '@disqusRemoteAuthS3', |
39 | | - disqus_api_key : '@disqusApiKey', |
| 37 | + disqus_config_language: '@disqusConfigLanguage', |
| 38 | + disqus_remote_auth_s3: '@disqusRemoteAuthS3', |
| 39 | + disqus_api_key: '@disqusApiKey', |
40 | 40 | disqus_on_ready: "&disqusOnReady", |
41 | 41 | readyToBind: "@" |
42 | 42 | }, |
43 | 43 | template: '<div id="disqus_thread"></div><a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>', |
44 | | - link: function(scope) { |
| 44 | + link: function (scope) { |
45 | 45 |
|
46 | 46 | // ensure that the disqus_identifier and disqus_url are both set, otherwise we will run in to identifier conflicts when using URLs with "#" in them |
47 | 47 | // see http://help.disqus.com/customer/portal/articles/662547-why-are-the-same-comments-showing-up-on-multiple-pages- |
48 | 48 | if (typeof scope.disqus_identifier === 'undefined' || typeof scope.disqus_url === 'undefined') { |
49 | 49 | throw "Please ensure that the `disqus-identifier` and `disqus-url` attributes are both set."; |
50 | 50 | } |
51 | 51 |
|
52 | | - scope.$watch("readyToBind", function(isReady) { |
| 52 | + scope.$watch("readyToBind", function (loadedOn) { |
53 | 53 |
|
54 | 54 | // If the directive has been called without the 'ready-to-bind' attribute, we |
55 | | - // set the default to "true" so that Disqus will be loaded straight away. |
56 | | - if ( !angular.isDefined( isReady ) ) { |
57 | | - isReady = "true"; |
| 55 | + // set a default value so that Disqus will be loaded straight away. |
| 56 | + if (!angular.isDefined(loadedOn)) { |
| 57 | + loadedOn = new Date(); |
58 | 58 | } |
59 | | - if (scope.$eval(isReady)) { |
60 | | - console.log('remote'+scope.disqus_remote_auth_s3); |
| 59 | + var isReady = typeof scope.$eval(loadedOn) !== 'undefined'; |
| 60 | + if (isReady) { |
61 | 61 | // put the config variables into separate global vars so that the Disqus script can see them |
62 | 62 | $window.disqus_shortname = scope.disqus_shortname; |
63 | 63 | $window.disqus_identifier = scope.disqus_identifier; |
64 | | - $window.disqus_title = scope.disqus_title; |
65 | 64 | $window.disqus_url = scope.disqus_url; |
| 65 | + $window.disqus_title = scope.disqus_title; |
66 | 66 | $window.disqus_category_id = scope.disqus_category_id; |
67 | 67 | $window.disqus_disable_mobile = scope.disqus_disable_mobile; |
68 | | - $window.disqus_config = function () { |
| 68 | + $window.disqus_config = function () { |
69 | 69 | this.language = scope.disqus_config_language; |
70 | 70 | this.page.remote_auth_s3 = scope.disqus_remote_auth_s3; |
71 | 71 | this.page.api_key = scope.disqus_api_key; |
|
88 | 88 | this.page.url = scope.disqus_url; |
89 | 89 | this.page.title = scope.disqus_title; |
90 | 90 | this.language = scope.disqus_config_language; |
91 | | - this.page.remote_auth_s3=scope.disqus_remote_auth_s3; |
92 | | - this.page.api_key=scope.disqus_api_key; |
| 91 | + this.page.remote_auth_s3 = scope.disqus_remote_auth_s3; |
| 92 | + this.page.api_key = scope.disqus_api_key; |
93 | 93 | } |
94 | 94 | }); |
95 | 95 | } |
|
0 commit comments