Commit 417547525bcc8cba7ec8641e604c9a7c8f1e574d

Authored by Vandhuy Martins
1 parent 64d72e5f
Exists in master and in 1 other branch devel

D1.0 - Filtrar os tipos dos arquivos aceitos pela interface do VLibras

app/assets/javascripts/site/videos.js
1 // 1 //
2 // Author Igor Amorim - www.igoramorim.com 2 // Author Igor Amorim - www.igoramorim.com
3 // 3 //
  4 +
  5 +function check_subtitle(file) {
  6 + var accepted_file_types = ["srt"];
  7 + return check_type(file, accepted_file_types)
  8 +};
  9 +
  10 +function check_video(file) {
  11 + var accepted_file_types = ["avi", "mp4", "mov", "webm", "wmv", "mkv",];
  12 + return check_type(file, accepted_file_types)
  13 +};
  14 +
  15 +function check_type(file, accepted_file_types) {
  16 +
  17 + var ext = file.value.substring(file.value.lastIndexOf('.') + 1).toLowerCase();
  18 + var isValidFile = false;
  19 +
  20 + for (var i = 0; i < accepted_file_types.length; i++) {
  21 + if (ext == accepted_file_types[i]) {
  22 + isValidFile = true;
  23 + break;
  24 + }
  25 + }
  26 +
  27 + if (!isValidFile) {
  28 + file.value = null;
  29 + alert("Apenas os formatos abaixo são aceitos:\n\n" + accepted_file_types.join(", "));
  30 + }
  31 +
  32 + return isValidFile;
  33 +};
  34 +
4 $(function(){ 35 $(function(){
5 36
6 $("#url").hide(); 37 $("#url").hide();
app/views/static/subtitle.html.haml
@@ -6,6 +6,6 @@ @@ -6,6 +6,6 @@
6 = form_for(@presenter.subtitle, :html => {:multipart => true, :class => "horizontal-form"}) do |f| 6 = form_for(@presenter.subtitle, :html => {:multipart => true, :class => "horizontal-form"}) do |f|
7 %fieldset 7 %fieldset
8 %label Coloque a Legenda 8 %label Coloque a Legenda
9 - = f.file_field :legend, :prompt => "LEGENDA", :id => "link_cc" 9 + = f.file_field :legend, :prompt => "LEGENDA", :id => "link_cc", :onchange => "return check_subtitle(this)"
10 #url 10 #url
11 = f.submit "CONTINUAR", :class => "btn btn-success btn-large" 11 = f.submit "CONTINUAR", :class => "btn btn-success btn-large"
12 \ No newline at end of file 12 \ No newline at end of file
app/views/static/upload.html.haml
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 = form_for(@presenter.upload, :html => {:multipart => true, :class => "horizontal-form"}) do |f| 6 = form_for(@presenter.upload, :html => {:multipart => true, :class => "horizontal-form"}) do |f|
7 %fieldset 7 %fieldset
8 %label Coloque o Vídeo 8 %label Coloque o Vídeo
9 - = f.file_field :url, :id => "link_cc" 9 + = f.file_field :url, :id => "link_cc", :onchange => "return check_video(this)"
10 #url 10 #url
11 = f.submit "CONTINUAR", :class => "btn btn-success btn-large" 11 = f.submit "CONTINUAR", :class => "btn btn-success btn-large"
12 -- content_for :menu, render(:partial => 'shared/menu')  
13 \ No newline at end of file 12 \ No newline at end of file
  13 +- content_for :menu, render(:partial => 'shared/menu')
app/views/videos/_form.html.haml
@@ -23,10 +23,10 @@ @@ -23,10 +23,10 @@
23 Legenda (.SRT) 23 Legenda (.SRT)
24 #url 24 #url
25 = f.label :url, t('videos.url'), :class => "bold" 25 = f.label :url, t('videos.url'), :class => "bold"
26 - = f.file_field :url 26 + = f.file_field :url, :onchange => "return check_video(this)"
27 #legend 27 #legend
28 = f.label :legend, t('videos.subtitle'), :class => "bold" 28 = f.label :legend, t('videos.subtitle'), :class => "bold"
29 - = f.file_field :legend, :prompt => "LEGENDA" 29 + = f.file_field :legend, :prompt => "LEGENDA", :onchange => "return check_subtitle(this)"
30 .field 30 .field
31 = f.label :window_size, t('videos.window_size'), :class => "bold" 31 = f.label :window_size, t('videos.window_size'), :class => "bold"
32 = f.select :window_size, [['Pequena', '1'], ['Média', '2'], ['Grande', '3']] 32 = f.select :window_size, [['Pequena', '1'], ['Média', '2'], ['Grande', '3']]