|
1
|
|
|
// This file is part of Moodle - http://moodle.org/ |
|
2
|
|
|
// |
|
3
|
|
|
// Moodle is free software: you can redistribute it and/or modify |
|
4
|
|
|
// it under the terms of the GNU General Public License as published by |
|
5
|
|
|
// the Free Software Foundation, either version 3 of the License, or |
|
6
|
|
|
// (at your option) any later version. |
|
7
|
|
|
// |
|
8
|
|
|
// Moodle is distributed in the hope that it will be useful, |
|
9
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11
|
|
|
// GNU General Public License for more details. |
|
12
|
|
|
// |
|
13
|
|
|
// You should have received a copy of the GNU General Public License |
|
14
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
|
15
|
|
|
|
|
16
|
|
|
/** global: M */ |
|
17
|
|
|
/** global: Y */ |
|
18
|
|
|
|
|
19
|
|
|
M.mod_bigbluebuttonbn = M.mod_bigbluebuttonbn || {}; |
|
20
|
|
|
|
|
21
|
|
|
M.mod_bigbluebuttonbn.helpers = { |
|
22
|
|
|
|
|
23
|
|
|
element_tag: {}, |
|
24
|
|
|
element_fa_class: {}, |
|
25
|
|
|
element_action_reversed: {}, |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Initialise helpers code. |
|
29
|
|
|
* |
|
30
|
|
|
* @method init |
|
31
|
|
|
*/ |
|
32
|
|
|
init: function() { |
|
33
|
|
|
this.element_tag = this.init_element_tag(); |
|
34
|
|
|
this.element_fa_class = this.init_element_fa_class(); |
|
35
|
|
|
this.element_action_reversed = this.init_element_action_reversed(); |
|
36
|
|
|
}, |
|
37
|
|
|
|
|
38
|
|
|
toggle_spinning_wheel_on: function(data) { |
|
39
|
|
|
var elementid, link, button, text; |
|
40
|
|
|
|
|
41
|
|
|
elementid = this.element_id(data.action, data.target); |
|
42
|
|
|
text = M.util.get_string('view_recording_list_action_' + data.action, 'bigbluebuttonbn'); |
|
43
|
|
|
link = Y.one('a#' + elementid + '-' + data.recordingid); |
|
44
|
|
|
link.setAttribute('data-onclick', link.getAttribute('onclick')); |
|
45
|
|
|
link.setAttribute('onclick', ''); |
|
46
|
|
|
button = link.one('> i'); |
|
47
|
|
|
if (button === null) { |
|
48
|
|
|
// For backward compatibility |
|
49
|
|
|
this.toggle_spinning_wheel_on_compatible(link.one('> img'), text); |
|
50
|
|
|
return; |
|
51
|
|
|
} |
|
52
|
|
|
button.setAttribute('data-aria-label', button.getAttribute('aria-label')); |
|
53
|
|
|
button.setAttribute('aria-label', text); |
|
54
|
|
|
button.setAttribute('data-title', button.getAttribute('title')); |
|
55
|
|
|
button.setAttribute('title', text); |
|
56
|
|
|
button.setAttribute('data-class', button.getAttribute('class')); |
|
57
|
|
|
button.setAttribute('class', this.element_fa_class.process); |
|
58
|
|
|
}, |
|
59
|
|
|
|
|
60
|
|
|
toggle_spinning_wheel_on_compatible: function(button, text) { |
|
61
|
|
|
button.setAttribute('data-alt', button.getAttribute('alt')); |
|
62
|
|
|
button.setAttribute('alt', text); |
|
63
|
|
|
button.setAttribute('data-title', button.getAttribute('title')); |
|
64
|
|
|
button.setAttribute('title', text); |
|
65
|
|
|
button.setAttribute('data-src', button.getAttribute('src')); |
|
66
|
|
|
button.setAttribute('src', M.cfg.wwwroot + "/mod/bigbluebuttonbn/pix/processing16.gif"); |
|
67
|
|
|
}, |
|
68
|
|
|
|
|
69
|
|
|
toggle_spinning_wheel_off: function(data) { |
|
70
|
|
|
var elementid, link, button; |
|
71
|
|
|
|
|
72
|
|
|
elementid = this.element_id(data.action, data.target); |
|
73
|
|
|
link = Y.one('a#' + elementid + '-' + data.recordingid); |
|
74
|
|
|
link.setAttribute('onclick', link.getAttribute('data-onclick')); |
|
75
|
|
|
link.removeAttribute('data-onclick'); |
|
76
|
|
|
button = link.one('> i'); |
|
77
|
|
|
if (button === null) { |
|
78
|
|
|
// For backward compatibility |
|
79
|
|
|
this.toggle_spinning_wheel_off_compatible(link.one('> img')); |
|
80
|
|
|
return; |
|
81
|
|
|
} |
|
82
|
|
|
button.setAttribute('aria-label', button.getAttribute('data-aria-label')); |
|
83
|
|
|
button.removeAttribute('data-aria-label'); |
|
84
|
|
|
button.setAttribute('title', button.getAttribute('data-title')); |
|
85
|
|
|
button.removeAttribute('data-title'); |
|
86
|
|
|
button.setAttribute('class', button.getAttribute('data-class')); |
|
87
|
|
|
button.removeAttribute('data-class'); |
|
88
|
|
|
}, |
|
89
|
|
|
|
|
90
|
|
|
toggle_spinning_wheel_off_compatible: function(button) { |
|
91
|
|
|
button.setAttribute('alt', button.getAttribute('data-alt')); |
|
92
|
|
|
button.removeAttribute('data-alt'); |
|
93
|
|
|
button.setAttribute('title', button.getAttribute('data-title')); |
|
94
|
|
|
button.removeAttribute('data-title'); |
|
95
|
|
|
button.setAttribute('src', button.getAttribute('data-src')); |
|
96
|
|
|
button.removeAttribute('data-src'); |
|
97
|
|
|
}, |
|
98
|
|
|
|
|
99
|
|
|
update_data: function(data) { |
|
100
|
|
|
var action, elementid, link, linkdataonclick, button, buttondatatext, buttondatatag; |
|
101
|
|
|
|
|
102
|
|
|
action = this.element_action_reversed[data.action]; |
|
103
|
|
|
if (action === data.action) { |
|
104
|
|
|
return; |
|
105
|
|
|
} |
|
106
|
|
|
elementid = this.element_id(data.action, data.target); |
|
107
|
|
|
link = Y.one('a#' + elementid + '-' + data.recordingid); |
|
108
|
|
|
link.setAttribute('data-action', action); |
|
109
|
|
|
linkdataonclick = link.getAttribute('data-onclick').replace(data.action, action); |
|
110
|
|
|
link.setAttribute('data-onclick', linkdataonclick); |
|
111
|
|
|
|
|
112
|
|
|
buttondatatext = M.util.get_string('view_recording_list_actionbar_' + action, 'bigbluebuttonbn'); |
|
113
|
|
|
buttondatatag = this.element_tag[action]; |
|
114
|
|
|
button = link.one('> i'); |
|
115
|
|
|
if (button === null) { |
|
116
|
|
|
// For backward compatibility |
|
117
|
|
|
this.update_data_compatible(link.one('> img'), this.element_tag[data.action], buttondatatag, buttondatatext); |
|
118
|
|
|
return; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
button.setAttribute('data-aria-label', buttondatatext); |
|
122
|
|
|
button.setAttribute('data-title', buttondatatext); |
|
123
|
|
|
button.setAttribute('data-class', this.element_fa_class[action]); |
|
124
|
|
|
}, |
|
125
|
|
|
|
|
126
|
|
|
update_data_compatible: function(button, action, buttondatatag, buttondatatext) { |
|
127
|
|
|
var buttondatasrc; |
|
128
|
|
|
|
|
129
|
|
|
buttondatasrc = button.getAttribute('data-src').replace(action, buttondatatag); |
|
130
|
|
|
button.setAttribute('data-alt', buttondatatext); |
|
131
|
|
|
button.setAttribute('data-title', buttondatatext); |
|
132
|
|
|
button.setAttribute('data-src', buttondatasrc); |
|
133
|
|
|
}, |
|
134
|
|
|
|
|
135
|
|
|
update_id: function(data) { |
|
136
|
|
|
var action, elementid, link, button, id; |
|
137
|
|
|
|
|
138
|
|
|
action = this.element_action_reversed[data.action]; |
|
139
|
|
|
if (action === data.action) { |
|
140
|
|
|
return; |
|
141
|
|
|
} |
|
142
|
|
|
elementid = this.element_id(data.action, data.target); |
|
143
|
|
|
link = Y.one('a#' + elementid + '-' + data.recordingid); |
|
144
|
|
|
id = '' + elementid.replace(data.action, action) + '-' + data.recordingid; |
|
145
|
|
|
link.setAttribute('id', id); |
|
146
|
|
|
|
|
147
|
|
|
button = link.one('> i'); |
|
148
|
|
|
if (button === null) { |
|
149
|
|
|
// For backward compatibility |
|
150
|
|
|
button = link.one('> img'); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
button.setAttribute('id', id); |
|
154
|
|
|
}, |
|
155
|
|
|
|
|
156
|
|
|
element_id: function(action, target) { |
|
157
|
|
|
var elementid = 'recording-' + action; |
|
158
|
|
|
if (typeof target !== 'undefined') { |
|
159
|
|
|
elementid += '-' + target; |
|
160
|
|
|
} |
|
161
|
|
|
return elementid; |
|
162
|
|
|
}, |
|
163
|
|
|
|
|
164
|
|
|
init_element_tag: function() { |
|
165
|
|
|
var tags = {}; |
|
166
|
|
|
tags.publish = 'show'; |
|
167
|
|
|
tags.unpublish = 'hide'; |
|
168
|
|
|
tags.protect = 'lock'; |
|
169
|
|
|
tags.unprotect = 'unlock'; |
|
170
|
|
|
tags.edit = 'edit'; |
|
171
|
|
|
tags.process = 'process'; |
|
172
|
|
|
tags['import'] = 'import'; |
|
173
|
|
|
tags['delete'] = 'delete'; |
|
174
|
|
|
return tags; |
|
175
|
|
|
}, |
|
176
|
|
|
|
|
177
|
|
|
init_element_fa_class: function() { |
|
178
|
|
|
var tags = {}; |
|
179
|
|
|
tags.publish = 'icon fa fa-eye fa-fw iconsmall'; |
|
180
|
|
|
tags.unpublish = 'icon fa fa-eye-slash fa-fw iconsmall'; |
|
181
|
|
|
tags.protect = 'icon fa fa-lock fa-fw iconsmall'; |
|
182
|
|
|
tags.unprotect = 'icon fa fa-unlock fa-fw iconsmall'; |
|
183
|
|
|
tags.edit = 'icon fa fa-pencil fa-fw iconsmall'; |
|
184
|
|
|
tags.process = 'icon fa fa-spinner fa-spin iconsmall'; |
|
185
|
|
|
tags['import'] = 'icon fa fa-download fa-fw iconsmall'; |
|
186
|
|
|
tags['delete'] = 'icon fa fa-trash fa-fw iconsmall'; |
|
187
|
|
|
return tags; |
|
188
|
|
|
}, |
|
189
|
|
|
|
|
190
|
|
|
init_element_action_reversed: function() { |
|
191
|
|
|
var actions = {}; |
|
192
|
|
|
actions.publish = 'unpublish'; |
|
193
|
|
|
actions.unpublish = 'publish'; |
|
194
|
|
|
actions.protect = 'unprotect'; |
|
195
|
|
|
actions.unprotect = 'protect'; |
|
196
|
|
|
actions.edit = 'edit'; |
|
197
|
|
|
actions['import'] = 'import'; |
|
198
|
|
|
actions['delete'] = 'delete'; |
|
199
|
|
|
return actions; |
|
200
|
|
|
}, |
|
201
|
|
|
|
|
202
|
|
|
reload_preview: function(data) { |
|
203
|
|
|
var thumbnails = Y.one('#preview-' + data.recordingid).all('> img'); |
|
204
|
|
|
thumbnails.each(function (thumbnail) { |
|
205
|
|
|
var thumbnailsrc = thumbnail.getAttribute('src'); |
|
206
|
|
|
thumbnailsrc = thumbnailsrc.substring(0, thumbnailsrc.indexOf('?')); |
|
207
|
|
|
thumbnailsrc += '?' + new Date().getTime(); |
|
208
|
|
|
thumbnail.setAttribute('src', thumbnailsrc); |
|
209
|
|
|
}); |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
}; |
|
213
|
|
|
|