-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaper-input-image.html
121 lines (105 loc) · 2.47 KB
/
paper-input-image.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">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../iron-input-image/iron-input-image.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-tile/paper-tile.html">
<!--
Example:
<paper-input-image></paper-input-image>
@group Paper Elements
@element paper-input-image
@demo demo/index.html
@hero hero.svg
-->
<dom-module id="paper-input-image">
<template>
<style>
:host {
display: block;
box-sizing: border-box;
}
paper-tile {
width: 100%;
height: 100%;
}
</style>
<input
id="inputImage"
is="iron-input-image"
src="{{src}}"
title="{{title}}"
size="{{size}}"
files="{{value::change}}">
<paper-tile
img="[[src]]"
first-line="[[title]]"
second-line="[[size]] ko"
icon="[[_computeIcon(src)]]"
footer-content
on-primary-action="choose"
on-secondary-action="clear">
</paper-tile>
</template>
</dom-module>
<script>
Polymer({
is: 'paper-input-image',
behaviors: [
Polymer.IronFormElementBehavior
],
properties: {
/**
* The text displayed when no image is selected.
*/
noImageText: {
type: String,
value: 'No image selected',
notify: true
},
/**
* The image src.
*/
src: {
type: String,
value: '',
notify: true
},
/**
* The size of the selected image (ko).
*/
size: {
type: Number,
value: 0,
notify: true
},
/**
* The text displayed. Equales to noImageText if no image is selected and
* updates from the image file's title when a new one is selected.
*/
title: {
type: String
}
},
attached: function() {
this.title = this.noImageText;
},
/**
* Choose a new image from the user disk.
*/
choose: function() {
this.$.inputImage.choose();
},
/**
* Remove the selected image.
*/
clear: function() {
this.$.inputImage.clear();
this.title = this.noImageText;
},
_computeIcon: function(src) {
return src ? 'icons:clear' : '';
}
});
</script>