Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion video_uploader/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
//= require lodash.core
//= require_tree .

function enableUploadLink(){
var invalidInputs = $(".presentation-validate-content.invalid").length;
var fileField = $("#presentation-file-field");

if (invalidInputs == 0 && (fileField.length == 0 || fileField.val().length > 0))
$("form#presentation .upload-btn").removeClass('disabled')
else
$("form#presentation .upload-btn").addClass('disabled')
}

$(document).ready(function() {
$('.collapsible').collapsible();
$('select').material_select();
Expand All @@ -44,12 +54,25 @@ $(document).ready(function() {
});

$(function() {
$('form#presentation').on("change", ".presentation-validate-content", function() {
var field = $(this);

console.log(field.val());
if (field.val().match(/<|>/) != null)
field.addClass("invalid");
else
field.removeClass("invalid");

enableUploadLink();
});

$(".presentation-validate-content").change();
$('.presentation_upload_form').fileupload({
dataType: 'json',
replaceFileInput: false,
url: $('.presentation_upload_form').attr('action'),
add: function (e, data) {
$(this).find('.upload-btn').removeClass('disabled');
enableUploadLink();
$(this).find('.file-path').removeClass('invalid');
$(this).find('.upload-btn').click(function (e) {
e.preventDefault();
Expand Down
4 changes: 2 additions & 2 deletions video_uploader/app/views/presentations/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
input(type="hidden" name="event_id" value=@presentation.event_id)
.row
.col.s12.input-field
input id="presentation_title" type="text" name="title" class="validate" data-length="100" value=@presentation.title
input id="presentation_title" type="text" name="title" class="presentation-validate-content" data-length="100" value=@presentation.title
label for="presentation_title" Title

.col.s12.input-field
textarea.materialize-textarea(id="presentation_description" name="description")
textarea.materialize-textarea.presentation-validate-content(id="presentation_description" name="description")
=@presentation.description
label(for="presentation_description") Description

Expand Down
7 changes: 3 additions & 4 deletions video_uploader/app/views/presentations/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
input(type="hidden" name="event_id" value=@presentation.event_id)
.row
.col.s12.input-field
input id="presentation_title" type="text" name="title" class="validate" data-length="100" value=@presentation.title
input id="presentation_title" type="text" name="title" class="presentation-validate-content" data-length="100" value=@presentation.title
label for="presentation_title" Title

.col.s12.input-field
textarea.materialize-textarea(id="presentation_description" name="description")
textarea.materialize-textarea.presentation-validate-content(id="presentation_description" name="description")
=@presentation.description
label(for="presentation_description") Description

.col.s12.input-field
= select_tag :playlist_id, options_from_collection_for_select(@playlists, 'id', 'title', @presentation.playlist_id), id: 'presentation_playlist_id'
label for="presentation_playlist_id" Playlist
Expand All @@ -30,7 +29,7 @@
.file-field.input-field
.btn
span Video File
input(type="file" name="file")
input#presentation-file-field(type="file" name="file")

.file-path-wrapper
input.file-path.validate(type="text")
Expand Down