Implement simplified commercials workflow

It's now possible to simply enter the url of the third party provider to enter a commercial.
This commit is contained in:
chrisbr 2015-04-22 21:30:32 +02:00 committed by Christian Bruckmayer
parent fb7ebab5a0
commit 23664119bd
25 changed files with 220 additions and 194 deletions

View file

@ -37,6 +37,7 @@
//= require bootstrap-switch
//= require osem-switch
//= require osem-bootstrap
//= require osem-commercials
$(document).ready(function() {
$('a[disabled=disabled]').click(function(event){

View file

@ -0,0 +1,33 @@
$(function () {
$(document).ready(function() {
$("#commercial_url").bind('paste keyup', function() {
clearTimeout($(this).data('timeout'));
$(this).data('timeout', setTimeout(function () {
var url = $('#new_commercial').attr('action');
url = url + '/render_commercial'
$.ajax({
method: 'GET',
url: url,
data: { url: $('#commercial_url').val() },
error: function(xhr, status, error) {
$('#commercial_submit_action').prop('disabled', true);
$('#resource-content').hide();
$('#resource-placeholder').show();
$('#commercial_error').hide();
$('#commercial_url_input').addClass('has-error error');
$('<span id="commercial_error" class="help-block">' + xhr.responseText + '</span>').insertAfter('#commercial_url');
},
success: function(msg) {
$('#commercial_submit_action').prop('disabled', false);
$('#commercial_url_input').removeClass('has-error error');
$('#commercial_error').hide();
$('#resource-placeholder').hide();
$('#resource-content').html(msg).show();
}
})
}, 200)
);
});
});
});