-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
96 lines (89 loc) · 2.67 KB
/
app.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
Vue.use(VueMask.VueMaskPlugin);
const vm = new Vue({
el: "#app",
data: {
clipped: false,
clippedTimeout: null,
name: 'Ben Feitor',
role: 'Colaborador',
email: 'ben@benfeitoria.com',
phone: '+55 (99) 99999 9999',
url: {
blog: 'https://blog.benfeitoria.com',
site: 'https://benfeitoria.com',
instagram: "https://www.instagram.com/benfeitores/",
facebook: "https://www.facebook.com/benfeitoria/",
linkedin: "https://www.linkedin.com/company/benfeitoria/",
twitter: "https://twitter.com/benfeitoria"
},
phone_mask: '+## (##) ##### ####',
storage_infos: ['name','role','email','phone']
},
methods: {
getStorageKeyName(info){
return `SignAppStorageData|${info}`
},
getStorageValue(info){
let data = JSON.parse(window.localStorage.getItem(
this.getStorageKeyName(info)
));
return data !== null ? data : ''
},
setStorageValue(info,value){
window.localStorage.setItem(
this.getStorageKeyName(info),
JSON.stringify(value)
);
},
getInformationsFromStorage(){
for(let info of this.storage_infos){
if(this.getStorageValue(info).toString().length){
this[info] = this.getStorageValue(info).toString();
}
}
},
clippedHandler(){
this.clipped = true;
clearTimeout(this.clearTimeout);
this.clearTimeout = setTimeout(() => {
this.clipped = false;
},8000);
}
},
watch: {
name(value){
this.setStorageValue("name",value);
},
role(value){
this.setStorageValue("role",value);
},
email(value){
this.setStorageValue("email",value);
},
phone(value){
this.setStorageValue("phone",value);
}
},
computed: {
html() {
return ``;
},
},
created(){
this.getInformationsFromStorage();
const clipboard = new ClipboardJS('#copy-text');
clipboard.on('success', (e) => {
e.clearSelection();
this.clippedHandler();
});
const clipboardHTML = new ClipboardJS('#copy-html', {
text: function() {
return document.getElementById("signature-div").innerHTML;
}
});
clipboardHTML.on('success', (e) => {
e.clearSelection();
this.clippedHandler();
});
}
});