Added confirmation prompt when deleting current logo
This commit is contained in:
parent
05a8fdf091
commit
26d875ed66
|
@ -233,26 +233,13 @@ function setAddShowEvents(form) {
|
||||||
if(!form.find("#add_show_rebroadcast").attr('checked')) {
|
if(!form.find("#add_show_rebroadcast").attr('checked')) {
|
||||||
form.find("#schedule-record-rebroadcast > fieldset:not(:first-child)").hide();
|
form.find("#schedule-record-rebroadcast > fieldset:not(:first-child)").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're adding a new show, hide the "Current Logo" element/label
|
// If we're adding a new show or the show has no logo, hide the "Current Logo" element tree
|
||||||
if ($(".button-bar.bottom").find(".ui-button-text").text() === "Update show") {
|
$("[id^=add_show_logo_current]").toggle(($("#add_show_logo_current").attr("src") !== "")
|
||||||
// Display the current show logo if it exists
|
&& ($(".button-bar.bottom").find(".ui-button-text").text() === "Update show"));
|
||||||
if ($("#show_logo_current").attr("src") !== "") {
|
|
||||||
$("#show_logo_current-element").show();
|
var submitButton = $(".button-bar.bottom").find(".add-show-submit");
|
||||||
$("#show_logo_current-label").show();
|
$("[id^=add_show_instance_description]").toggle(submitButton.attr("data-action") === "edit-repeating-show-instance");
|
||||||
$("#show_logo_current").show();
|
|
||||||
$("#show_remove_logo").show();
|
|
||||||
} else {
|
|
||||||
$("#show_logo_current-element").hide();
|
|
||||||
$("#show_logo_current-label").hide();
|
|
||||||
$("#show_logo_current").hide();
|
|
||||||
$("#show_remove_logo").hide();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$("#show_logo_current-element").hide();
|
|
||||||
$("#show_logo_current-label").hide();
|
|
||||||
$("#show_remove_logo").hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
form.find("#add_show_repeats").click(function(){
|
form.find("#add_show_repeats").click(function(){
|
||||||
$(this).blur();
|
$(this).blur();
|
||||||
|
@ -539,6 +526,7 @@ function setAddShowEvents(form) {
|
||||||
showButtonPanel: true,
|
showButtonPanel: true,
|
||||||
firstDay: calendarPref.weekStart
|
firstDay: calendarPref.weekStart
|
||||||
});
|
});
|
||||||
|
|
||||||
form.find('input[name^="add_show_rebroadcast_time"]').timepicker({
|
form.find('input[name^="add_show_rebroadcast_time"]').timepicker({
|
||||||
amPmText: ['', ''],
|
amPmText: ['', ''],
|
||||||
defaultTime: '',
|
defaultTime: '',
|
||||||
|
@ -616,11 +604,11 @@ function setAddShowEvents(form) {
|
||||||
// when an image is uploaded, we want to show it to the user
|
// when an image is uploaded, we want to show it to the user
|
||||||
form.find("#add_show_logo").change(function(event) {
|
form.find("#add_show_logo").change(function(event) {
|
||||||
if (this.files && this.files[0]) {
|
if (this.files && this.files[0]) {
|
||||||
$("#show_logo_preview").show();
|
$("#add_show_logo_preview").show();
|
||||||
var reader = new FileReader(); // browser compatibility?
|
var reader = new FileReader(); // browser compatibility?
|
||||||
|
|
||||||
reader.onload = function (e) {
|
reader.onload = function (e) {
|
||||||
$("#show_logo_preview")
|
$("#add_show_logo_preview")
|
||||||
.attr('src', e.target.result);
|
.attr('src', e.target.result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -631,10 +619,10 @@ function setAddShowEvents(form) {
|
||||||
} else {
|
} else {
|
||||||
// remove the file element data
|
// remove the file element data
|
||||||
$(this).val('').replaceWith($(this).clone(true));
|
$(this).val('').replaceWith($(this).clone(true));
|
||||||
$("#show_logo_preview").hide();
|
$("#add_show_logo_preview").hide();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$("#show_logo_preview").hide();
|
$("#add_show_logo_preview").hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -662,36 +650,34 @@ function setAddShowEvents(form) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Duplicate of the function in ShowController - provide it as a GET endpoint?
|
||||||
function validateMimeType(mime) {
|
function validateMimeType(mime) {
|
||||||
var extensions = [
|
var extensions = [
|
||||||
'image/jpeg',
|
'image/jpeg',
|
||||||
'image/png',
|
'image/png',
|
||||||
'image/gif'
|
'image/gif'
|
||||||
|
// BMP?
|
||||||
];
|
];
|
||||||
return $.inArray(mime, extensions);
|
return $.inArray(mime, extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
form.find("#show_remove_logo").click(function() {
|
form.find("#add_show_logo_current_remove").click(function() {
|
||||||
var showId = $("#add_show_id").attr("value");
|
if (confirm($.i18n._('Are you sure you want to delete the current logo?'))) {
|
||||||
|
var showId = $("#add_show_id").attr("value");
|
||||||
console.log(showId);
|
|
||||||
console.log($("#show_logo_current").attr("src"));
|
|
||||||
|
|
||||||
if (showId && $("#show_logo_current").attr("src") !== "") {
|
|
||||||
var action = '/rest/show/' + showId + '/delete-image';
|
|
||||||
|
|
||||||
$.ajax({
|
if (showId && $("#add_show_logo_current").attr("src") !== "") {
|
||||||
url: action,
|
var action = '/rest/show/' + showId + '/delete-image';
|
||||||
data: '',
|
|
||||||
type: 'POST',
|
$.ajax({
|
||||||
success: function() {
|
url: action,
|
||||||
$("#show_logo_current").prop("src", "")
|
data: '',
|
||||||
$("#show_logo_current-element").hide();
|
type: 'POST',
|
||||||
$("#show_logo_current-label").hide();
|
success: function() {
|
||||||
$("#show_logo_current").hide();
|
$("#add_show_logo_current").prop("src", "")
|
||||||
$("#show_remove_logo").hide();
|
$("[id^=add_show_logo_current]").hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue