Commit 170268c2 authored by Kevin Gutierrez's avatar Kevin Gutierrez
Browse files

Fix tabs

parent d672ac13
var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
'chooser': function(modal, jsonData) {
var searchUrl = $('form.video-search', modal.body).attr('action');
chooser: function(modal, jsonData) {
var searchUrl = $('form.video-search', modal.body).attr('action');
/* currentTag stores the tag currently being filtered on, so that we can
preserve this when paginating */
var currentTag;
/* currentTag stores the tag currently being filtered on, so that we can
preserve this when paginating */
var currentTag;
function ajaxifyLinks(context) {
$('.listing a', context).click(function() {
modal.loadUrl(this.href);
return false;
});
function ajaxifyLinks(context) {
$('.listing a', context).click(function() {
modal.loadUrl(this.href);
return false;
});
$('.pagination a', context).click(function() {
var page = this.getAttribute('data-page');
setPage(page);
return false;
});
}
function fetchResults(requestData) {
$.ajax({
url: searchUrl,
data: requestData,
success: function(data, status) {
$('#image-results').html(data);
ajaxifyLinks($('#image-results'));
}
});
}
$('.pagination a', context).click(function() {
var page = this.getAttribute('data-page');
setPage(page);
return false;
});
}
function search() {
/* Searching causes currentTag to be cleared - otherwise there's
no way to de-select a tag */
currentTag = null;
fetchResults({
q: $('#id_q').val(),
collection_id: $('#collection_chooser_collection_id').val()
});
return false;
}
function fetchResults(requestData) {
$.ajax({
url: searchUrl,
data: requestData,
success: function(data, status) {
$('#image-results').html(data);
ajaxifyLinks($('#image-results'));
}
});
}
function setPage(page) {
var params = { p: page };
if ($('#id_q').val().length) {
params['q'] = $('#id_q').val();
function search() {
/* Searching causes currentTag to be cleared - otherwise there's
no way to de-select a tag */
currentTag = null;
fetchResults({
q: $('#id_q').val(),
collection_id: $('#collection_chooser_collection_id').val()
});
return false;
}
if (currentTag) {
params['tag'] = currentTag;
function setPage(page) {
var params = { p: page };
if ($('#id_q').val().length) {
params['q'] = $('#id_q').val();
}
if (currentTag) {
params['tag'] = currentTag;
}
params['collection_id'] = $('#collection_chooser_collection_id').val();
fetchResults(params);
return false;
}
params['collection_id'] = $('#collection_chooser_collection_id').val();
fetchResults(params);
return false;
}
ajaxifyLinks(modal.body);
ajaxifyLinks(modal.body);
$('form.video-upload', modal.body).submit(function() {
var formdata = new FormData(this);
$.ajax({
url: this.action,
data: formdata,
processData: false,
contentType: false,
type: 'POST',
dataType: 'text',
success: function(response) {
modal.loadResponseText(response);
},
error: function(response, textStatus, errorThrown) {
var message = jsonData['error_message'] + '<br />' + errorThrown + ' - ' + response.status;
$('#upload').append(
'<div class="help-block help-critical">' + '<strong>' + jsonData['error_label'] + ': </strong>' + message + '</div>'
);
}
});
$('form.video-upload', modal.body).submit(function() {
var formdata = new FormData(this);
$.ajax({
url: this.action,
data: formdata,
processData: false,
contentType: false,
type: 'POST',
dataType: 'text',
success: function(response) {
modal.loadResponseText(response);
},
error: function(response, textStatus, errorThrown) {
var message = jsonData['error_message'] + '<br />' + errorThrown + ' - ' + response.status;
$('#upload').append(
'<div class="help-block help-critical">' + '<strong>' + jsonData['error_label'] + ': </strong>' + message + '</div>'
);
}
});
return false;
});
return false;
});
$('form.video-search', modal.body).submit(search);
$('form.video-search', modal.body).submit(search);
$('#id_q').on('input', function() {
clearTimeout($.data(this, 'timer'));
var wait = setTimeout(search, 200);
$(this).data('timer', wait);
});
$('#collection_chooser_collection_id').change(search);
$('a.suggested-tag').click(function() {
currentTag = $(this).text();
$('#id_q').val('');
fetchResults({
tag: currentTag,
collection_id: $('#collection_chooser_collection_id').val()
$('#id_q').on('input', function() {
clearTimeout($.data(this, 'timer'));
var wait = setTimeout(search, 200);
$(this).data('timer', wait);
});
return false;
});
/* Add tag entry interface (with autocompletion) to the tag field of the image upload form */
// $('#id_tags', modal.body).tagit({
// autocomplete: {source: "{{ autocomplete_url|addslashes }}"}
// });
},
'video_chosen': function(modal, jsonData) {
modal.respond('videoChosen', jsonData['result']);
modal.close();
},
$('#collection_chooser_collection_id').change(search);
$('a.suggested-tag').click(function() {
currentTag = $(this).text();
$('#id_q').val('');
fetchResults({
tag: currentTag,
collection_id: $('#collection_chooser_collection_id').val()
});
return false;
});
/* Add tag entry interface (with autocompletion) to the tag field of the image upload form */
// $('#id_tags', modal.body).tagit({
// autocomplete: {source: "{{ autocomplete_url|addslashes }}"}
// });
},
video_chosen: function(modal, jsonData) {
modal.respond('videoChosen', jsonData['result']);
modal.close();
}
};
......@@ -19,7 +19,7 @@
<a class="image-choice" href="{% if will_select_format %}{% url 'wagtailvideos:chooser_select_format' video.id %}{% else %}{% url 'wagtailvideos:video_chosen' video.id %}{% endif %}">
<div class="image">
{% if video.thumbnail %}
<img src="{{video.thumbnail.url}}" width="165" height="165" class="show-transparency" alt="{% trans 'Video thumbnail' %}"/>
<img src="{{ video.thumbnail.url }}" width="165" height="165" class="show-transparency" alt="{% trans 'Video thumbnail' %}"/>
{% else %}
<img width="165" height="165" class="show-transparency" alt=""/>
{% endif %}
......
......@@ -21,7 +21,7 @@
<a class="image-choice" href="{% url 'wagtailvideos:edit' video.id %}">
<div class="image">
{% if video.thumbnail %}
<img src="{{video.thumbnail.url}}" height="165" width="165" class="show-transparency" alt="{% trans 'Video thumbnail' %}"/>
<img src="{{ video.thumbnail.url }}" height="165" width="165" class="show-transparency" alt="{% trans 'Video thumbnail' %}"/>
{% endif %}
</div>
<h3>{{ video.title|ellipsistrim:60 }}</h3>
......
......@@ -6,7 +6,7 @@
{% block chosen_state_view %}
<div class="preview-image">
{% if video and video.thumbnail %}
<img src="{{video.thumbnail.url}}" width="165" height="165" class="show-transparency" alt="{% trans 'Video thumbnail' %}"/>
<img src="{{ video.thumbnail.url }}" width="165" height="165" class="show-transparency" alt="{% trans 'Video thumbnail' %}"/>
{% else %}
<img width="165" height="165" class="show-transparency" alt=""/>
{% endif %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment