[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/assets/js/ -> mass-create-sets-page.js (source)

   1  jQuery(function($) {
   2      $gp.notices.init();
   3      $('#project_id').change(function() {
   4          var select = $(this);
   5          var project_id = $('option:selected', select).attr('value');
   6          if ( !project_id ) {
   7              $('#submit').prop('disabled', true);
   8              $('#preview').hide();
   9              return;
  10          }
  11          $gp.notices.notice($gp_mass_create_sets_options.loading);
  12          select.prop('disabled', true);
  13          $.ajax({type: "POST", url: $gp_mass_create_sets_options.url, data: {project_id: project_id}, dataType: 'json',
  14              success: function(data){
  15                  select.prop('disabled', false);
  16                  $gp.notices.clear();
  17                  if (data.added.length || data.removed.length) $('#submit').prop('disabled', false);
  18                  var preview = $('#preview');
  19                  preview.html('<h3>Preview changes:</h3>');
  20                  var preview_html = '';
  21                  preview_html += '<ul>';
  22  				function preview_html_for(kind, text) {
  23                      var sets = data[kind];
  24                      var html = '';
  25                      html += '<li><span class="'+kind+'">'+text.replace('{count}', sets.length)+'</span>';
  26                      if (sets.length) {
  27                          html += '<ul>';
  28                          $.each(sets, function() {
  29                              html += '<li>'+$gp.esc_html(this.name)+' ('+this.locale+'/'+this.slug+')</li>';
  30                          });
  31                          html += '</ul>';
  32                      }
  33                      html += '</li>';
  34                      return html;
  35                  }
  36                  preview_html += preview_html_for('added', '{count} set(s) will be added');
  37                  preview_html += preview_html_for('removed', '{count} set(s) will be removed');
  38                  preview_html += '</ul>';
  39                  preview.append(preview_html);
  40                  preview.fadeIn();
  41              },
  42              error: function(xhr, msg, error) {
  43                  select.prop('disabled', false);
  44                  msg = xhr.responsehtml? 'Error: '+ xhr.responsehtml : 'Error saving the translation!';
  45                  $gp.notices.error(msg);
  46              }
  47          });
  48      });
  49      $('#submit').prop('disabled', true);
  50      $('#preview').hide();
  51  });


Generated: Fri Oct 22 01:01:06 2021 Cross-referenced by PHPXref 0.7.1