ng2-awesome-disqus
Version:
Angular Disqus Module
63 lines • 2.14 kB
JavaScript
import { Injectable } from '@angular/core';
var nativeWindow = function () {
// return the global native browser window object
return typeof window !== 'undefined' ? window : undefined;
};
var DisqusService = (function () {
function DisqusService() {
// constructor() {
this.window = nativeWindow();
}
Object.defineProperty(DisqusService.prototype, "url", {
get: function () {
return (this.window) ? this.window.location.href : global.url || '';
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisqusService.prototype, "disqus", {
get: function () {
return (this.window) ? this.window.DISQUS : global.DISQUS;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisqusService.prototype, "disqusConfig", {
get: function () {
return (this.window) ? this.window.disqus_config : global.disqus_config;
},
set: function (config) {
if (this.window) {
this.window.disqus_config = config;
}
else {
global.disqus_config = config;
}
},
enumerable: true,
configurable: true
});
DisqusService.prototype.validateUrl = function (url) {
/** If URL is specified then validate it, otherwise use window URL */
if (url) {
var r = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
if (r.test(url)) {
return url;
}
else {
console.warn('[Disqus]: Invalid URL, fallback to Window URL');
}
}
/** fallback to "Window" URL, or to "Global" in universal */
return this.url;
};
;
return DisqusService;
}());
export { DisqusService };
DisqusService.decorators = [
{ type: Injectable },
];
/** @nocollapse */
DisqusService.ctorParameters = function () { return []; };
//# sourceMappingURL=disqus.service.js.map