CC-5404 : colorpickers littering DOM

This commit is contained in:
Naomi 2013-10-11 13:13:30 -04:00
parent 5defb12430
commit 22d5df866c
3 changed files with 91 additions and 88 deletions

View File

@ -500,107 +500,82 @@ function setAddShowEvents() {
}); });
form.find("#add-show-close") form.find("#add-show-close").click(closeAddShowForm);
.click(function(event){
event.stopPropagation();
event.preventDefault();
$("#add-show-form").hide(); form.find(".add-show-submit").click(function(event) {
windowResize(); event.preventDefault();
var addShowButton = $(this);
$('#schedule-add-show').block({
message: null,
applyPlatformOpacityRules: false
});
$.get(baseUrl+"Schedule/get-form", {format:"json"}, function(json){ //when editing a show, the record option is disabled
//we have to enable it to get the correct value when
//we call serializeArray()
if (form.find("#add_show_record").attr("disabled", true)) {
form.find("#add_show_record").attr("disabled", false);
}
var data = $("form").serializeArray();
var hosts = $('#add_show_hosts-element input').map(function() {
if($(this).attr("checked")) {
return $(this).val();
}
}).get();
var days = $('#add_show_day_check-element input').map(function() {
if($(this).attr("checked")) {
return $(this).val();
}
}).get();
var start_date = $("#add_show_start_date").val();
var end_date = $("#add_show_end_date").val();
var action = baseUrl+"Schedule/"+String(addShowButton.attr("data-action"));
$.post(action, {format: "json", data: data, hosts: hosts, days: days}, function(json){
$('#schedule-add-show').unblock();
if (json.form) {
$("#add-show-form") $("#add-show-form")
.empty() .empty()
.append(json.form); .append(json.form);
setAddShowEvents(); setAddShowEvents();
});
makeAddShowButton();
});
form.find(".add-show-submit") $("#add_show_end_date").val(end_date);
.click(function(event){ $("#add_show_start_date").val(start_date);
var addShowButton = $(this); showErrorSections();
/* }else if(json.edit){
if (!addShowButton.hasClass("disabled")){ $("#schedule_calendar").removeAttr("style")
addShowButton.addClass("disabled"); .fullCalendar('render');
}
else {
return;
}
*/
event.preventDefault(); $("#add-show-form").hide();
$.get(baseUrl+"Schedule/get-form", {format:"json"}, function(json){
//when editing a show, the record option is disabled
//we have to enable it to get the correct value when
//we call serializeArray()
if (form.find("#add_show_record").attr("disabled", true)) {
form.find("#add_show_record").attr("disabled", false);
}
var data = $("form").serializeArray();
var hosts = $('#add_show_hosts-element input').map(function() {
if($(this).attr("checked")) {
return $(this).val();
}
}).get();
var days = $('#add_show_day_check-element input').map(function() {
if($(this).attr("checked")) {
return $(this).val();
}
}).get();
var start_date = $("#add_show_start_date").val();
var end_date = $("#add_show_end_date").val();
$('#schedule-add-show').block({
message: null,
applyPlatformOpacityRules: false
});
var action = baseUrl+"Schedule/"+String(addShowButton.attr("data-action"));
$.post(action, {format: "json", data: data, hosts: hosts, days: days}, function(json){
//addShowButton.removeClass("disabled");
$('#schedule-add-show').unblock();
if(json.form) {
$("#add-show-form") $("#add-show-form")
.empty() .empty()
.append(json.form); .append(json.form);
setAddShowEvents(); setAddShowEvents();
});
makeAddShowButton();
}
else {
$("#add-show-form")
.empty()
.append(json.newForm);
$("#add_show_end_date").val(end_date); setAddShowEvents();
$("#add_show_start_date").val(start_date); scheduleRefetchEvents(json);
showErrorSections(); }
}else if(json.edit){ });
$("#schedule_calendar").removeAttr("style") });
.fullCalendar('render');
$("#add-show-form").hide();
$.get(baseUrl+"Schedule/get-form", {format:"json"}, function(json){
$("#add-show-form")
.empty()
.append(json.form);
setAddShowEvents();
});
makeAddShowButton();
}
else {
$("#add-show-form")
.empty()
.append(json.newForm);
setAddShowEvents();
scheduleRefetchEvents(json);
}
});
});
var regDate = new RegExp(/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/); var regDate = new RegExp(/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/);
var regTime = new RegExp(/^[0-2][0-9]:[0-5][0-9]$/); var regTime = new RegExp(/^[0-2][0-9]:[0-5][0-9]$/);

View File

@ -42,6 +42,34 @@ function openAddShowForm() {
} }
} }
function closeAddShowForm(event) {
event.stopPropagation();
event.preventDefault();
var $el = $("#add-show-form");
$el.hide();
windowResize();
$.get(baseUrl+"Schedule/get-form", {format:"json"}, function(json) {
//need to clean up the color picker.
$el.find("#schedule-show-style input").each(function(i, el){
var $input = $(this),
colId = $input.data("colorpickerId");
$("#"+colId).remove();
$input.removeData();
});
$el.empty().append(json.form);
setAddShowEvents();
});
makeAddShowButton();
}
function makeAddShowButton(){ function makeAddShowButton(){
$('.fc-header-left') $('.fc-header-left')
.append('<span class="fc-header-space"></span>') .append('<span class="fc-header-space"></span>')

View File

@ -482,4 +482,4 @@
ColorPickerShow: ColorPicker.showPicker, ColorPickerShow: ColorPicker.showPicker,
ColorPickerSetColor: ColorPicker.setColor ColorPickerSetColor: ColorPicker.setColor
}); });
})(jQuery) })(jQuery);