2019-03-21 20:55:58 +03:00
|
|
|
import Component from '@ember/component';
|
2020-06-25 23:45:47 +03:00
|
|
|
import {computed} from '@ember/object';
|
2019-03-21 20:55:58 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
config: service(),
|
|
|
|
tagName: '',
|
2020-06-25 23:45:47 +03:00
|
|
|
srcUrl: computed('src', function () {
|
|
|
|
return this.src || `${this.config.get('blogUrl')}/`;
|
|
|
|
}),
|
2019-03-21 20:55:58 +03:00
|
|
|
didReceiveAttrs() {
|
|
|
|
// reset the src attribute each time the guid changes - allows for
|
|
|
|
// a click on the navigation item to reset back to the homepage
|
2020-06-25 23:45:47 +03:00
|
|
|
if ((this.guid !== this._lastGuid) || (this.src !== this._lastSrc)) {
|
2019-03-21 20:55:58 +03:00
|
|
|
let iframe = document.querySelector('#site-frame');
|
|
|
|
if (iframe) {
|
2020-06-25 23:45:47 +03:00
|
|
|
iframe.src = this.src || `${this.config.get('blogUrl')}/`;
|
2019-03-21 20:55:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this._lastGuid = this.guid;
|
2020-06-25 23:45:47 +03:00
|
|
|
this._lastSrc = this.src;
|
2019-03-21 20:55:58 +03:00
|
|
|
}
|
|
|
|
});
|