-
Notifications
You must be signed in to change notification settings - Fork 620
/
o_animate.editor.js
163 lines (130 loc) · 6.2 KB
/
o_animate.editor.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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
odoo.define('website_animate.o_animate_editor', function (require) {
'use strict';
var s_options = require('web_editor.snippets.options');
// Animations
s_options.registry.o_animate = s_options.Class.extend({
start: function () {
this._super();
var self = this;
setTimeout(function () {
if (self.$overlay.find("li.snippet-option-o_animate > ul > li li.active").length > 0) {
self.update_options_visibility("show");
} else {
self.update_options_visibility("hide");
}
// remove theme_enark animation options from the context menu
// WARNING: theme_enark do not prefix js methods,
// Remove in Odoo9
if (self.$overlay.find('li.snippet-option-animation').length > 0) {
$(this).addClass("hidden");
}
}, 500)
},
select_class: function (type, value, $li) {
this._super(type, value, $li);
var self = this;
setTimeout(function () {
self.$target.addClass("o_animate_preview o_animate").css('animation-name', 'dummy-none');
self.$target.css('animation-name', '');
});
if (type != "click") {return}
if (value.length > 0 ) {
self.update_options_visibility("show");
self.$target.removeClass("o_animate_preview");
} else {
setTimeout(function () {
self.update_options_visibility("hide");
self.$target.removeClass("o_animate_preview o_animate");
}, 500)
}
},
update_options_visibility: function (value) {
var self = this;
var opts = ".snippet-option-o_animate_duration, .snippet-option-o_animate_delay, .snippet-option-o_animate_options";
setTimeout(function () {
if (value == "show") {
self.$overlay.find(opts).removeClass("hidden");
} else if (value == "hide") {
self.$overlay.find(opts).addClass("hidden");
}
})
},
clean_for_save: function () {
var self = this;
// Clean elements
self.$target
.removeClass("o_animating o_animated o_animate_preview")
.css({
'animation': '',
'animation-name': '',
'animation-play-state': '',
'visibility': ''
});
if (self.$target.hasClass("o_animate")) {
self.$target.css('animation-play-state', 'paused');
}
// Clean all inView elements
$("#wrapwrap").find(".o_animate").removeClass("o_visible");
},
});
// Duration
s_options.registry.o_animate_duration = s_options.Class.extend({
select_class: function (type, value, $li) {
this._super(type, value, $li);
var self = this;
var $timeline_duration = self.$overlay.find(".timeline.duration span[simulate='duration']");
var $timeline_delay = self.$overlay.find(".timeline.duration span[simulate='delay']");
self.$target
.css({
'animation-duration': '',
'animation-delay': ''
});
var el_delay = self.$target.css("animation-delay");
var el_duration = self.$target.css("animation-duration");
var el_period;
el_delay = parseFloat(el_delay.slice(0,-1));
el_duration = parseFloat(el_duration.slice(0,-1));
el_period = el_delay + el_duration;
$timeline_duration.parent().width((el_duration*100)/el_period +"%");
$timeline_delay.parent().width((el_delay*100)/el_period +"%");
self.$target.addClass("o_animate_preview").css('animation-name', 'dummy-none').css('animation-duration', '0s');
$timeline_duration.css('animation-name', 'dummy-none').css('animation-duration', el_duration + "s").css('animation-delay', el_delay + "s");
$timeline_delay.css('animation-name', 'dummy-none').css('animation-duration', el_delay + "s");
setTimeout(function () {
self.$target.css('animation-name', '').css('animation-duration', '');
$timeline_duration.css('animation-name', '');
$timeline_delay.css('animation-name', '');
});
},
});
// Delay
s_options.registry.o_animate_delay = s_options.Class.extend({
select_class: function (type, value, $li) {
this._super(type, value, $li);
var self = this;
var $timeline_delay = self.$overlay.find(".timeline.delay span[simulate='delay']");
var $timeline_duration = self.$overlay.find(".timeline.delay span[simulate='duration']");
self.$target
.css({
'animation-duration': '',
'animation-delay': ''
});
var el_delay = self.$target.css("animation-delay");
var el_duration = self.$target.css("animation-duration");
var el_period;
el_delay = parseFloat(el_delay.slice(0,-1));
el_duration = parseFloat(el_duration.slice(0,-1));
el_period = el_delay + el_duration;
$timeline_duration.parent().width((el_duration*100)/el_period +"%");
$timeline_delay.parent().width((el_delay*100)/el_period +"%");
self.$target.addClass("o_animate_preview").css('animation-name', 'dummy-none').css('animation-duration', '0s');
$timeline_duration.css('animation-name', 'dummy-none').css('animation-duration', el_duration + "s").css('animation-delay', el_delay + "s");
$timeline_delay.css('animation-name', 'dummy-none').css('animation-duration', el_delay + "s");
setTimeout(function () {
self.$target.css('animation-name', '').css('animation-duration', '');
$timeline_duration.css('animation-name', '');
$timeline_delay.css('animation-name', '');
});
},
});
});