app/assets/javascripts/pageflow/chart/editor/views/embedded/iframe_embedded_view.js in pageflow-chart-2.3.0 vs app/assets/javascripts/pageflow/chart/editor/views/embedded/iframe_embedded_view.js in pageflow-chart-2.4.0

- old
+ new

@@ -2,26 +2,47 @@ modelEvents: { 'change': 'update' }, render: function() { - this.updateScrapedSite(); + if (this.model.has('chart_url')) { + this.updateChartUrl(); + } + else if (this.model.has('scraped_site_id')) { + this.updateScrapedSite(); + } + return this; }, update: function() { - if (this.model.hasChanged(this.options.propertyName)) { + if (this.model.hasChanged('chart_url')) { + this.updateChartUrl(); + } + else if (this.model.hasChanged('scraped_site_id')) { this.updateScrapedSite(); } }, + updateChartUrl: function() { + var url = this.model.get('chart_url'); + + if (url) { + url = url.replace(/^https?:/, ''); + } + + this.$el.attr('src', url); + this.$el.removeAttr('data-use-custom-theme'); + this.$el.removeAttr('data-customize-layout'); + }, + updateScrapedSite: function() { if (this.scrapedSite) { this.stopListening(this.scrapedSite); } - this.scrapedSite = this.model.getReference(this.options.propertyName, + this.scrapedSite = this.model.getReference('scraped_site_id', 'pageflow_chart_scraped_sites'); this.updateAttributes(); if (this.scrapedSite) { this.listenTo(this.scrapedSite, 'change', this.updateAttributes); @@ -31,9 +52,10 @@ updateAttributes: function() { var scrapedSite = this.scrapedSite; if (scrapedSite && scrapedSite.isReady()) { this.$el.attr('src', scrapedSite.get('html_file_url')); + this.$el.attr('data-customize-layout', 'true'); if (scrapedSite.get('use_custom_theme')) { this.$el.attr('data-use-custom-theme', 'true'); } else {