Commit e6cb8e964ac636ca6d024614a0004296e74f32d1

Authored by Fernando Brito
1 parent 06cb3f6f
Exists in master and in 2 other branches v2, wikilibras

Some javascript refactoring

app/assets/javascripts/v_libras/requests/new.js
... ... @@ -25,18 +25,18 @@ $(function () {
25 25 var totalSteps = $("#vlibras-wizard .content section").size();
26 26  
27 27 if ((priorIndex === 0) && (currentIndex === 1)) {
28   - VLibrasVideo.stop();
29   - VLibrasSubAudio.play();
  28 + $("#video-step").find("video")[0].pause();
  29 + $("#service-step").find("video")[0].play();
30 30 }
31 31  
32 32 if ((priorIndex === 1) && (currentIndex === 2)) {
33   - VLibrasSubAudio.stop();
34   - VLibrasPosition.play();
  33 + $("#service-step").find("video")[0].pause();
  34 + $("#position-step").find("video")[0].play();
35 35 }
36 36  
37 37 if ((priorIndex === 2) && (currentIndex === 3)) {
38   - VLibrasPosition.stop();
39   - VLibrasSize.play();
  38 + $("#position-step").find("video")[0].pause();
  39 + $("#size-step").find("video")[0].play();
40 40 }
41 41  
42 42 if ((currentIndex + 1) === totalSteps) {
... ... @@ -107,7 +107,7 @@ $(function () {
107 107  
108 108 $('html, body').animate({
109 109 scrollTop: $("#subtitle-upload").offset().top
110   - }, 1000);
  110 + }, 600);
111 111  
112 112 return false;
113 113 });
... ...
app/assets/javascripts/v_libras/requests/workflow.js
... ... @@ -33,19 +33,20 @@ var VLibrasLocalization = function() {
33 33 var interval = setInterval(function() {
34 34 var time = Math.round( _video[0].currentTime * 10 ) / 10;
35 35  
36   - if (time !== time_helper){
37   - $('.footnote').text(time);
38   -
  36 + if (time !== time_helper) {
39 37 for (var i = 0; i < _options.buttons.length; i++)
40 38 _createButton(i, time);
41 39  
42 40 time_helper = time;
43 41 }
44   - }, 500);
  42 + }, 200);
45 43 }
46 44  
47 45 function _createButton(index, time) {
48   - if ((time > _options.buttons[index].start) && (_options.buttons[index].shown != true)) {
  46 + if ((time >= _options.buttons[index].start) && (_options.buttons[index].shown != true)) {
  47 + _options.buttons[index].shown = true;
  48 + console.debug("[VLibrasLocalization] showing " + _options.buttons[index]);
  49 +
49 50 var image = null;
50 51  
51 52 if (_options.buttons[index].clickable === true) {
... ... @@ -62,14 +63,13 @@ var VLibrasLocalization = function() {
62 63 image.css('left', _options.buttons[index].x);
63 64  
64 65 image.hide().appendTo(_video_wrapper).fadeIn(_options.buttons[index].delay);
65   -
66   - _options.buttons[index].shown = true;
67 66 }
68 67  
69   - if ((time > _options.buttons[index].end) && (_options.buttons[index].hidden != true)) {
70   - $('#' + _options.buttons[index].id).fadeOut(_options.buttons[index].delay);
71   -
  68 + if ((time >= _options.buttons[index].end) && (_options.buttons[index].hidden != true) && (_options.buttons[index].shown === true)) {
  69 + console.debug("[VLibrasLocalization] hiding " + _options.buttons[index]);
72 70 _options.buttons[index].hidden = true;
  71 +
  72 + $('#' + _options.buttons[index].id).fadeOut(_options.buttons[index].delay);
73 73 }
74 74 }
75 75  
... ... @@ -90,7 +90,7 @@ var VLibrasLocalization = function() {
90 90 },
91 91  
92 92 stop: function() {
93   - /* _video[0].pause() */;
  93 + _video[0].pause();
94 94 }
95 95 }
96 96 };
97 97 \ No newline at end of file
... ...
app/views/layouts/application.html.erb
... ... @@ -5,6 +5,8 @@
5 5 <%= javascript_include_tag "application" %>
6 6 <%= yield :js %>
7 7  
  8 + <%= yield :javascript_code %>
  9 +
8 10 <%= yield :css %>
9 11 <%= stylesheet_link_tag "application", :media => "all" %>
10 12  
... ... @@ -46,5 +48,6 @@
46 48 <link href="//vjs.zencdn.net/4.6/video-js.css" rel="stylesheet">
47 49 <script src="//vjs.zencdn.net/4.6/video.js"></script>
48 50  
  51 +
49 52 </body>
50 53 </html>
... ...
app/views/v_libras/requests/_position_step.haml
... ... @@ -3,21 +3,22 @@
3 3  
4 4 = html5_video_tag(['/system/videos/workflow/localizacao.webm', '/system/videos/workflow/localizacao.mp4'], 'id-4', 'video-wizard')
5 5  
6   -:javascript
7   - $(function () {
8   - var optionsPosition = {
9   - video: { width: 940, height: 530 },
10   - buttons: [ { id: 'b_loc_1', path: '/system/images/loc/p_1.png', clickable: false, start: 7.6, end: 8.5, x: 670, y: 340, delay: 300, value: null },
11   - { id: 'b_loc_2', path: '/system/images/loc/p_2.png', clickable: false, start: 10, end: 10.5, x: 160, y: 340, delay: 300, value: null },
12   - { id: 'b_loc_3', path: '/system/images/loc/p_3.png', clickable: false, start: 12, end: 12.5, x: 210, y: 40, delay: 300, value: null },
13   - { id: 'b_loc_4', path: '/system/images/loc/p_4.png', clickable: false, start: 14, end: 14.5, x: 650, y: 80, delay: 300, value: null },
14   - { id: 'b_loc_5', path: '/system/images/loc/p_4.png', clickable: true, start: 19.1, end: null, x: 30, y: 30, delay: 300, value: "superior-esquerdo" },
15   - { id: 'b_loc_6', path: '/system/images/loc/p_3.png', clickable: true, start: 19.1, end: null, x: 680, y: 30, delay: 300, value: "superior-direito" },
16   - { id: 'b_loc_7', path: '/system/images/loc/p_1.png', clickable: true, start: 19.1, end: null, x: 568, y: 410, delay: 300, value: "inferior-direito" },
17   - { id: 'b_loc_8', path: '/system/images/loc/p_2.png', clickable: true, start: 19.1, end: null, x: -310, y: 410, delay: 300, value: "inferior-esquerdo" }
18   - ]
19   - };
  6 +- content_for :javascript_code do
  7 + :javascript
  8 + $(function () {
  9 + var optionsPosition = {
  10 + video: { width: 940, height: 530 },
  11 + buttons: [ { id: 'b_loc_1', path: '/system/images/loc/p_1.png', clickable: false, start: 7.6, end: 8.5, x: 670, y: 340, delay: 300, value: null },
  12 + { id: 'b_loc_2', path: '/system/images/loc/p_2.png', clickable: false, start: 10, end: 10.5, x: 160, y: 340, delay: 300, value: null },
  13 + { id: 'b_loc_3', path: '/system/images/loc/p_3.png', clickable: false, start: 12, end: 12.5, x: 210, y: 40, delay: 300, value: null },
  14 + { id: 'b_loc_4', path: '/system/images/loc/p_4.png', clickable: false, start: 14, end: 14.5, x: 650, y: 80, delay: 300, value: null },
  15 + { id: 'b_loc_5', path: '/system/images/loc/p_4.png', clickable: true, start: 19.1, end: 9999, x: 30, y: 30, delay: 300, value: "superior-esquerdo" },
  16 + { id: 'b_loc_6', path: '/system/images/loc/p_3.png', clickable: true, start: 19.1, end: 9999, x: 680, y: 30, delay: 300, value: "superior-direito" },
  17 + { id: 'b_loc_7', path: '/system/images/loc/p_1.png', clickable: true, start: 19.1, end: 9999, x: 568, y: 410, delay: 300, value: "inferior-direito" },
  18 + { id: 'b_loc_8', path: '/system/images/loc/p_2.png', clickable: true, start: 19.1, end: 9999, x: -310, y: 410, delay: 300, value: "inferior-esquerdo" }
  19 + ]
  20 + };
20 21  
21   - var VLibrasPosition = new VLibrasLocalization();
22   - VLibrasPosition.init("#position-step", optionsPosition);
23   - });
24 22 \ No newline at end of file
  23 + var VLibrasPosition = new VLibrasLocalization();
  24 + VLibrasPosition.init("#position-step", optionsPosition);
  25 + });
25 26 \ No newline at end of file
... ...
app/views/v_libras/requests/_service_step.haml
... ... @@ -11,18 +11,19 @@
11 11 = file_field_tag 'subtitle', :id => 'subtitle-upload'
12 12  
13 13  
14   -:javascript
15   - $(function () {
16   - var optionsService = {
17   - video: { width: 940, height: 530 },
18   - buttons: [ { id: 'b_aS_1', path: '/system/images/sub_audio/p_1.png', clickable: false, start: 20, end: 21, x: 700, y: 390, delay: 300, value: null },
19   - { id: 'b_aS_2', path: '/system/images/sub_audio/p_2.png', clickable: false, start: 24.5, end: 25.5, x: 150, y: 410, delay: 300, value: null },
20   - { id: 'btn-video-legenda', path: '/system/images/sub_audio/p_1.png', clickable: true, start: 26, end: null, x: 790, y: 410, delay: 300 },
21   - { id: 'btn-video', path: '/system/images/sub_audio/p_2.png', clickable: true, start: 26, end: null, x: -80, y: 410, delay: 300 }
22   - ]
23   - };
  14 +- content_for :javascript_code do
  15 + :javascript
  16 + $(function () {
  17 + var optionsService = {
  18 + video: { width: 940, height: 530 },
  19 + buttons: [ { id: 'b_aS_1', path: '/system/images/sub_audio/p_1.png', clickable: false, start: 20, end: 21, x: 700, y: 390, delay: 300, value: null },
  20 + { id: 'b_aS_2', path: '/system/images/sub_audio/p_2.png', clickable: false, start: 24.5, end: 25.5, x: 150, y: 410, delay: 300, value: null },
  21 + { id: 'btn-video-legenda', path: '/system/images/sub_audio/p_1.png', clickable: true, start: 26, end: 9999, x: 790, y: 410, delay: 300 },
  22 + { id: 'btn-video', path: '/system/images/sub_audio/p_2.png', clickable: true, start: 26, end: 9999, x: -80, y: 410, delay: 300 }
  23 + ]
  24 + };
24 25  
25   - var VLibrasSubAudio = new VLibrasLocalization();
26   - VLibrasSubAudio.init("#service-step", optionsService);
27   - });
  26 + var VLibrasSubAudio = new VLibrasLocalization();
  27 + VLibrasSubAudio.init("#service-step", optionsService);
  28 + });
28 29  
... ...
app/views/v_libras/requests/_size_step.haml
... ... @@ -3,20 +3,21 @@
3 3  
4 4 = html5_video_tag(['/system/videos/workflow/tamanho.webm', '/system/videos/workflow/tamanho.mp4'], 'id-3', 'video-wizard')
5 5  
6   -:javascript
7   - $(function () {
8   - var optionsSize = {
9   - video: { width: 940, height: 530 },
10   - buttons: [ { id: 'b_size_1', path: '/system/images/size/p_1.png', clickable: false, start: 6.8, end: 7.8, x: 770, y: 400, delay: 300, value: null },
11   - { id: 'b_size_2', path: '/system/images/size/p_2.png', clickable: false, start: 8.2, end: 9.2, x: 714, y: 355, delay: 300, value: null },
12   - { id: 'b_size_3', path: '/system/images/size/p_3.png', clickable: false, start: 9.7, end: 10.7, x: 658, y: 310, delay: 300, value: null},
13   - { id: 'b_size_4', path: '/system/images/size/p_1.png', clickable: true, start: 11.3, end: null, x: 780, y: 320, delay: 300, value: "pequeno" },
14   - { id: 'b_size_5', path: '/system/images/size/p_2.png', clickable: true, start: 11.3, end: null, x: 610, y: 320, delay: 300, value: "medio" },
15   - { id: 'b_size_6', path: '/system/images/size/p_3.png', clickable: true, start: 11.3, end: null, x: 384, y: 320, delay: 300, value: "grande" }
16   - ]
17   - };
  6 +- content_for :javascript_code do
  7 + :javascript
  8 + $(function () {
  9 + var optionsSize = {
  10 + video: { width: 940, height: 530 },
  11 + buttons: [ { id: 'b_size_1', path: '/system/images/size/p_1.png', clickable: false, start: 6.8, end: 7.8, x: 770, y: 400, delay: 300, value: null },
  12 + { id: 'b_size_2', path: '/system/images/size/p_2.png', clickable: false, start: 8.2, end: 9.2, x: 714, y: 355, delay: 300, value: null },
  13 + { id: 'b_size_3', path: '/system/images/size/p_3.png', clickable: false, start: 9.7, end: 10.7, x: 658, y: 310, delay: 300, value: null},
  14 + { id: 'b_size_4', path: '/system/images/size/p_1.png', clickable: true, start: 11.3, end: 9999, x: 780, y: 320, delay: 300, value: "pequeno" },
  15 + { id: 'b_size_5', path: '/system/images/size/p_2.png', clickable: true, start: 11.3, end: 9999, x: 610, y: 320, delay: 300, value: "medio" },
  16 + { id: 'b_size_6', path: '/system/images/size/p_3.png', clickable: true, start: 11.3, end: 9999, x: 384, y: 320, delay: 300, value: "grande" }
  17 + ]
  18 + };
18 19  
19   - var VLibrasSize = new VLibrasLocalization();
20   - VLibrasSize.init("#size-step", optionsSize);
21   - });
  20 + var VLibrasSize = new VLibrasLocalization();
  21 + VLibrasSize.init("#size-step", optionsSize);
  22 + });
22 23  
... ...
app/views/v_libras/requests/_video_step.haml
... ... @@ -11,15 +11,16 @@
11 11 = file_field_tag 'video', :id => 'video-upload'
12 12  
13 13  
14   -:javascript
15   - $(function () {
16   - var optionsVideo = {
17   - video: { width: 940, height: 530 },
18   - buttons: [ ]
19   - };
  14 +- content_for :javascript_code do
  15 + :javascript
  16 + $(function () {
  17 + var optionsVideo = {
  18 + video: { width: 940, height: 530 },
  19 + buttons: [ '' ]
  20 + };
20 21  
21   - var VLibrasVideo = new VLibrasLocalization();
22   - VLibrasVideo.init("#video-step", optionsVideo);
  22 + var VLibrasVideo = new VLibrasLocalization();
  23 + VLibrasVideo.init("#video-step", optionsVideo);
23 24  
24   - VLibrasVideo.play();
25   - });
26 25 \ No newline at end of file
  26 + VLibrasVideo.play();
  27 + })
27 28 \ No newline at end of file
... ...