-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiFrame.js
108 lines (82 loc) · 2.95 KB
/
iFrame.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
SirTrevor.Blocks.Iframe = (function() {
return SirTrevor.Block.extend({
type : 'iframe',
icon_name : 'iframe',
title : function() {
return "iFrame";
},
toolbarEnabled : true,
droppable : false,
pastable : true,
paste_options : {
html : '<input type="text" placeholder="<iframe>" class="st-block__paste-input st-paste-block">'
},
onContentPasted : function(event) {
this.loading();
obj = {};
val = $(event.target).val();
iframeObj = $.parseHTML(val);
$.each(iframeObj, function(i, el)
{
if(el.nodeName=='IFRAME')
{
if(el.attributes.src.value){
["src", "width", "height", "style", "sandbox", "lang", "title", "frameborder"].forEach(function(attribute){
console.log("outer; "+attribute);
if(el.attributes[attribute]) {
console.log("inner; "+attribute)
if(typeof el.attributes[attribute].value != undefined){
obj[attribute] = el.attributes[attribute].value;
}else
{
obj[attribute] = el.attributes[attribute];
}
}
});
}
}
});
if(obj)
{
this.setAndLoadData(obj);
}
},
uploadable : false,
formattable : false,
loadData : function(data) {
data.width = (typeof data.width == undefined || !data.width) ? '100%' : data.width;
data.height = (typeof data.height == undefined || !data.height) ? '100%' : data.height;
data.style = (typeof data.style == undefined || !data.style) ? 'pointer-events:none' : 'pointer-events:none;'+data.style;
data.frameborder = (typeof data.frameborder == undefined || !data.frameborder) ? '0' : data.frameborder;
this.$inner.prepend(
$('<iframe>')
.attr('src', data.src)
.attr('class', 'st-block-embed')
.attr('width', data.width)
.attr('height', data.height)
.attr('frameborder', data.frameborder)
);
if(typeof data.style != undefined){
$('<iframe>')
.attr('style', data.style)
}
if(typeof data.sandbox != undefined)
{
$('<iframe>')
.attr('sandbox', data.sandbox)
}
if(typeof data.lang != undefined)
{
$('<iframe>')
.attr('lang', data.lang)
}
if(typeof data.title != undefined)
{
$('<iframe>')
.attr('title', data.title)
}
this.$inner.addClass('text-center');
this.ready();
},
});
})();