-
Notifications
You must be signed in to change notification settings - Fork 0
/
jviz-confirm.html
101 lines (87 loc) · 2.65 KB
/
jviz-confirm.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
<!--
@license
Copyright (c) 2016 The Jviz Project Authors. All rights reserved.
The Jviz Project is under the MIT License. See https://github.com/jviz/jviz/blob/dev/LICENSE
-->
<!-- Import dependencies -->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../jviz/jviz.html">
<link rel="import" href="../jviz-popup/jviz-popup.html">
<link rel="import" href="../jviz-btn/jviz-btn.html">
<!-- Confirmation element -->
<dom-module id="jviz-confirm">
<template>
<style>
:host .content
{
margin-top: 0px;
margin-bottom: 10px;
}
:host .buttons
{
margin-top: 0px;
margin-bottom: 0px;
}
</style>
<jviz-popup id="popup" header$="{{ header }}">
<div class="content">
<content></content>
</div>
<div class="buttons">
<jviz-btn color="green" text$="{{ textConfirm }}" on-tap="_on_confirm"></jviz-btn>
<jviz-btn color="red" text$="{{ textCancel }}" on-tap="_on_cancel"></jviz-btn>
</div>
</jviz-popup>
</template>
</dom-module>
<!-- Element logic -->
<script>
//Initialize the confirm element
var jviz_confirm = { is: 'jviz-confirm' };
//Initialize the properties
jviz_confirm.properties = {};
jviz_confirm.properties.header = { type: String, reflectToAttribute: true, value: '' };
jviz_confirm.properties.visible = { type: Boolean, reflectToAttribute: true, value: false, observer: '_update_visible' };
jviz_confirm.properties.textConfirm = { type: String, reflectToAttribute: true, value: 'Confirm' };
jviz_confirm.properties.textCancel = { type: String, reflectToAttribute: true, value: 'Cancel' };
//Attached method
jviz_confirm.attached = function()
{
//Save this
var self = this;
//Add the popup close event listener
this.$.popup.addEventListener('close', function()
{
//Emit the cancel event
return self._on_cancel();
});
};
//Update the visible value
jviz_confirm._update_visible = function(value)
{
//Update the popup visible property
this.$.popup.visible = value;
};
//Click on confirm button
jviz_confirm._on_confirm = function()
{
//Hide the popup
this.visible = false;
//Emit the confirm event
return this.fire('confirm', {});
};
//Click on cancel button
jviz_confirm._on_cancel = function()
{
//Hide the popup
this.visible = false;
//Emit the cancel event
return this.fire('cancel', {});
};
//Show method
jviz_confirm.show = function(){ this.visible = true; };
//Close method
jviz_confirm.hide = function(){ this.visible = false; };
//Register the confirm element
Polymer(jviz_confirm);
</script>