BakerMan

ECP 2.0.10 events-admin.js correction

Dec 20th, 2012
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function($) {
  2.  
  3.     // Admin Google Maps Preview
  4.     $('#event_venue input, #event_venue select').change(function() {
  5.         if($('#EventShowMap').prop('checked')) {
  6.             $('#googlemaps').parent().show();
  7.         } else {
  8.             $('#googlemaps').parent().hide();
  9.         }
  10.  
  11.         var selectedOption = $('#saved_venue option:selected');
  12.         if(selectedOption.val() == 0) {
  13.             var form = $(this).closest('form'), street = form.find('[name="venue[Address]"]').val(),
  14.                 city = form.find('[name="venue[City]"]').val(),
  15.                 country = form.find('[name="venue[Country]"]').val(),
  16.                 state = form.find('[name="venue[Country]"] option:selected').val() == "US"
  17.                     ?form.find('[name="venue[State]"]').val() : form.find('[name="venue[Province]"]').val(),
  18.                 zip = form.find('[name="venue[Zip]"]').val(),
  19.                 address = street + "," + city + "," + state + "," + country + "," + zip;
  20.  
  21.          if ( typeof codeAddress == 'function' )
  22.             codeAddress(address);
  23.         } else {
  24.          if ( typeof codeAddress == 'function' )
  25.             codeAddress(selectedOption.data('address'));
  26.         }
  27.        
  28.     });
  29.  
  30.   $('#doaction, #doaction2').click(function(e){
  31.       var n = $(this).attr('id').substr(2);
  32.       if ( $('select[name="'+n+'"]').val() == 'edit' && $('.post_type_page').val() == 'tribe_events' ) {
  33.          e.preventDefault();
  34.  
  35.          var ids = new Array();
  36.  
  37.          $('#bulk-titles div').each(function() {
  38.             var id = $(this).attr('id'), postId = id.replace('ttle', ''),
  39.                title = $('#post-' + postId + ' .row-title').first().text(),
  40.                tempHolder = $('<div/>').append($(this).find('a'));
  41.          $(this).html('').append(tempHolder).append(title);
  42.  
  43.             if(ids[id])
  44.                $(this).remove();
  45.  
  46.             ids[id] = true;
  47.          });
  48.       }
  49.    });
  50.  
  51.  
  52.     $('.wp-admin.events-cal .submitdelete').click(function(e) {
  53.  
  54.         var link = $(this);
  55.         var isRecurringLink = $(this).attr('href').split('&eventDate');
  56.  
  57.         if(isRecurringLink[1]) {
  58.             e.preventDefault();
  59.  
  60.             $('#deletion-dialog').dialog({
  61.                 //submitdelete
  62.                 modal: true,
  63.                 buttons: [{
  64.                     text: "Only This Event",
  65.                     click: function() {
  66.                         document.location = link.attr('href') + '&event_start=' + $(this).data('start');
  67.                     }
  68.                 },
  69.                 {
  70.                     text: "All Events",
  71.                     click: function() {
  72.                         document.location = link.attr('href') + '&deleteAll';
  73.                     }
  74.                 }]
  75.             });
  76.         }
  77.  
  78.     });
  79.    
  80.     function resetSubmitButton() {
  81.         $('#publishing-action .button-primary-disabled').removeClass('button-primary-disabled');
  82.         $('#publishing-action #ajax-loading').css('visibility', 'hidden');
  83.        
  84.     }
  85.    
  86.     function validRecDays() {
  87.         if( $('[name="recurrence[custom-interval]"]').val() != parseInt($('[name="recurrence[custom-interval]"]').val()) &&
  88.             $('[name="recurrence[type]"] option:selected').val() == "Custom")
  89.         {
  90.             return false;
  91.         }
  92.        
  93.         return true;
  94.     }
  95.    
  96.     $('.wp-admin.events-cal #post').submit(function(e) {
  97.         if(!validRecDays()) {
  98.             e.preventDefault();
  99.             alert($('#rec-days-error').text());
  100.             $('#rec-days-error').show();
  101.             resetSubmitButton();
  102.         }
  103.     });
  104.    
  105.     function validRecEnd() {
  106.         if($('[name="recurrence[type]"]').val() != "None" &&
  107.             $('[name="recurrence[end-type]"] option:selected').val() == "On")
  108.         {
  109.             return $('[name="recurrence[end]"]').val() &&
  110.             !$('[name="recurrence[end]"]').hasClass('placeholder');
  111.         }
  112.        
  113.         return true;
  114.     }
  115.    
  116.     $('.wp-admin.events-cal #post').submit(function(e) {
  117.         if(!validRecEnd()) {
  118.             e.preventDefault();
  119.             alert($('#rec-end-error').text());
  120.             $('#rec-end-error').show();
  121.             resetSubmitButton();
  122.         }
  123.     });
  124.  
  125. });
Advertisement
Add Comment
Please, Sign In to add comment