// setup on change event for schedule_year
// we want to update the schedule with new name if updated
- $('#schedule_year').change(function(){
- var newYear = $(this).val();
- $.ajax({
- cache: false,
- url: glm_baseUrl + "schedules/Edit/updateScheduleYear/",
- data: "id=" + glm_scheduleId
- + "&year=" + newYear,
- statusCode: {
- 404: function() {
- alert('page not found');
- }
- },
- success: function(){
- glm_scheduleYear = newYear;
- }
- });
- });
+// $('#schedule_year').change(function(){
+// var newYear = $(this).val();
+// $.ajax({
+// cache: false,
+// url: glm_baseUrl + "schedules/Edit/updateScheduleYear/",
+// data: "id=" + glm_scheduleId
+// + "&year=" + newYear,
+// statusCode: {
+// 404: function() {
+// alert('page not found');
+// }
+// },
+// success: function(){
+// glm_scheduleYear = newYear;
+// }
+// });
+// });
// set loading animation to display while ajax
$('#loading').ajaxSend(function(){
$('#loading').show();
return true;
}
}
- // for the time edit form
- $( "#dialog-form" ).dialog({
- autoOpen: false,
- height: 200,
- width: 350,
- modal: true,
- buttons: {
- "Edit Time": function() {
- var bValid = true;
- allFields.removeClass( "ui-state-error" );
-
- bValid = bValid && checkLength( depart_time, "Time", 4);
-
- if (depart_time.val()) {
- bValid = bValid && checkRegexp( depart_time, /([0-9]{1,2}:[0-9]{2} [APMapm]{2})$/i, "time in HH:MM AM or PM" );
- }
-
- if ( bValid ) {
- // need to send the data to a php page to save it
- var dataVars = "id=" + id.val();
- dataVars += "&depart_time=" + depart_time.val();
- if (id.val()) {
- $.ajax({
- cache: false,
- type: 'post',
- dataType: 'json',
- url: glm_baseUrl + "schedules/Edit/saveTime/?id=" + id.val(),
- data: allFields.serialize(),
- success: function (data){
- $('span[class="form-element"][rel="' + data.id + '"]').html(data.time);
- },
- statusCode: {
- 404: function() {
- alert('Error: 404 Page Not Found!');
- }
- }
- });
- } else {
- $.ajax({
- cache: false,
- type: 'post',
- dataType: 'json',
- url: glm_baseUrl + "schedules/Edit/saveTime/",
- data: allFields.serialize(),
- success: function (data){
- if (data.dock == 1) {
- $('.chxTime.addTime[rel="'+data.departure_id+'"]').before(
- '<label class="timeLabel">' +
- '<span rel="'+data.id+'" class="form-element">'+ data.time + '</span>' +
- '<span rel="'+data.id+'" class="ui-icon ui-icon-circle-minus"></span>' +
- '</label>'
- );
- } else if (data.dock == 2) {
- $('.bviTime.addTime[rel="'+data.departure_id+'"]').before(
- '<label class="timeLabel">' +
- '<span rel="'+data.id+'" class="form-element">'+ data.time + '</span>' +
- '<span rel="'+data.id+'" class="ui-icon ui-icon-circle-minus"></span>' +
- '</label>'
- );
- }
- },
- statusCode: {
- 404: function() {
- alert('Error: 404 Page Not Found!');
- }
- }
- });
- }
-
- $( this ).dialog( "close" );
- }
- },
- Cancel: function() {
- $( this ).dialog( "close" );
- }
- },
- close: function() {
- allFields.val( "" ).removeClass( "ui-state-error" );
- }
- });
-
},
// setup the departures by id
setupDepartureById: function(id){