-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmeme-container.html
121 lines (120 loc) · 2.97 KB
/
meme-container.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="meme-container" attributes="y" >
<template>
<style>
:host {
display: block;
position: relative;
margin: .6em;
padding: .7em;
background-color: #f0f0f0;
box-shadow: 0 .4em .5em 0 rgba(0, 0, 0, 0.24);
}
#image {
width: 100%;
position: relative;
text-align: center;
}
#title {
font-size: 1em;
}
#top {
top: 0;
position: absolute;
padding: 0;
margin: 0;
width: 100%;
color: white;
font-family: Impact, Charcoal, sans-serif;
/* make a text stroke .. */
text-shadow: 0 0 0.15em #000;
font-size: 1.5em;
line-height: 1;
}
#bottom {
bottom: 5px;
position: absolute;
padding: 0;
margin: 0;
width: 100%;
color: white;
font-family: Impact, Charcoal, sans-serif;
/* make a text stroke .. */
text-shadow: 0 0 0.15em #000;
font-size: 1.17em;
line-height: 1;
}
#image img {
width: 100%;
height: auto;
padding: 0;
margin: 0;
}
.delete_btn {
background-color: gray;
position: absolute;
right: -20px;
top: -20px;
}
</style>
<paper-fab class="delete_btn" icon="delete" mini on-tap="{{deleteHandler}}"></paper-fab>
<h1 id="title" contentEditable spellCheck=false></h1>
<div id="image">
<h2 id="top" contentEditable spellCheck=false ></h2>
<h3 id="bottom" contentEditable spellCheck=false></h3>
<img src="{{img}}" />
</div>
</template>
<script>
Polymer("meme-container",{
ready: function(){
if(this.y != null){
var that = this;
var bind = function(){
var e = that.y.val();
that.img = e.img;
if(e.title != null){
e.title.bind(that.$.title, that.shadowRoot)
}
if(e.top != null){
e.top.bind(that.$.top, that.shadowRoot)
}
if(e.bottom != null){
e.bottom.bind(that.$.bottom, that.shadowRoot)
}
}
bind();
this.y.observe(bind);
}
},
yChanged: function(){
var that = this;
var bind = function(){
var e = that.y.val();
that.img = e.img;
if(e.title != null){
e.title.bind(that.$.title,that.shadowRoot)
}
if(e.top != null){
e.top.bind(that.$.top, that.shadowRoot)
}
if(e.bottom != null){
e.bottom.bind(that.$.bottom, that.shadowRoot)
}
}
bind();
this.y.observe(bind);
},
deleteHandler: function(){
var cs = this.parentElement.children
for(var i = 0; i< cs.length; i++){
if(cs[i] === this){
num = i;
break;
}
}
this.feed.delete(i,1)
}
})
</script>
</polymer-element>