-
Notifications
You must be signed in to change notification settings - Fork 3
/
iphone5s-view.html
97 lines (90 loc) · 3.09 KB
/
iphone5s-view.html
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
<link rel="import" href="../polymer/polymer-element.html">
<link rel="import" href="./device-styles.html">
<dom-module id="iphone5s-view">
<template>
<style include="device-styles">
:host {
display: block;
}
</style>
<div class$="marvel-device iphone5s silver {{orientation}}" hidden$="{{visible}}">
<div class="top-bar"></div>
<div class="sleep"></div>
<div class="volume"></div>
<div class="camera"></div>
<div class="sensor"></div>
<div class="speaker"></div>
<div class="screen" id="ixcontainer">
<!-- Content goes here -->
</div>
<div class="home"></div>
<div class="bottom-bar"></div>
</div>
</template>
<script>
/**
* `iphone5s-view`
* iphone5s-view element enables you to create a responsive view inside an iframe and applying skins of different devices inculding smartphones, tablets and desktop
*
* @customElement
* @polymer
* @demo demo/index.html
*/
class Iphone5sView extends Polymer.Element {
constructor() {
super();
}
static get is() {
return 'iphone5s-view';
}
static get properties() {
return {
device: {
type: String
},
visible: {
type: Boolean,
value: true
},
orientation: {
type: String,
observer: "_orChange"
},
data: {
type: Object
}
};
}
loadView(d) {
this._openScreen();
this.orientation = d.orientation
this.$.ixcontainer.innerHTML = "";
var i = document.createElement('iframe');
if (d.isUrl) {
i.src = d.url;
} else {
i.srcdoc = d.content;
}
i.width = 320;
i.height = 568;
this.$.ixcontainer.appendChild(i);
this.data = d;
}
_openScreen() {
this.visible = false;
}
_orChange(o) {
if (this.shadowRoot.querySelector('iframe') !== null) {
if (o === "portrait") {
this.shadowRoot.querySelector('iframe').width = 320;
this.shadowRoot.querySelector('iframe').height = 568;
} else {
this.shadowRoot.querySelector('iframe').width = 568;
this.shadowRoot.querySelector('iframe').height = 320;
}
}
}
}
window.customElements.define(Iphone5sView.is, Iphone5sView);
</script>
</dom-module>