mirror of
https://github.com/apache/superset.git
synced 2026-04-23 01:55:09 +00:00
Revise markup.js and iframe.js (#5672)
* Do not call slice.xxx * remove iframe id * remove old code * use import instead of require * update iframe.js
This commit is contained in:
committed by
Chris Williams
parent
5c49514e2f
commit
9fb28b5f4e
@@ -1,12 +1,20 @@
|
||||
const $ = require('jquery');
|
||||
import Mustache from 'mustache';
|
||||
|
||||
function iframeWidget(slice) {
|
||||
$('#code').attr('rows', '15');
|
||||
const url = slice.render_template(slice.formData.url);
|
||||
slice.container.html('<iframe style="width:100%;"></iframe>');
|
||||
const iframe = slice.container.find('iframe');
|
||||
iframe.css('height', slice.height());
|
||||
iframe.attr('src', url);
|
||||
export default function iframeWidget(slice) {
|
||||
const { selector, formData } = slice;
|
||||
const { url } = formData;
|
||||
const width = slice.width();
|
||||
const height = slice.height();
|
||||
const container = document.querySelector(selector);
|
||||
|
||||
const completedUrl = Mustache.render(url, {
|
||||
width,
|
||||
height,
|
||||
});
|
||||
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.style.width = '100%';
|
||||
iframe.style.height = height;
|
||||
iframe.setAttribute('src', completedUrl);
|
||||
container.appendChild(iframe);
|
||||
}
|
||||
|
||||
module.exports = iframeWidget;
|
||||
|
||||
Reference in New Issue
Block a user