Sha256: 810fae06c07afd805e046c5130bbea8cd7d4696eaa5b6f0e4d1ac9da14c34ace

Contents?: true

Size: 1.28 KB

Versions: 42

Compression:

Stored size: 1.28 KB

Contents

(function(PageEdit, $) {
  PageEdit.addPart = function (form) {
    if (PageEdit.validPartName()) {
      PageEdit.partLoading();
      $.post(
        $(form).attr('action'),
        $(form).serialize(),
        function(data) {
          $('#tab_control .pages').append(data);
          PageEdit.partAdded();
        }
      )
    }
  }

  PageEdit.partAdded = function (tabId) {
    $('#add_part_busy').hide();
    $('#add_part_button').attr('disabled', false);
    Popup.close();
    $('#part_name_field').val('');
    TabControl.updateTabsBasedOnPages();
    TabControl.selectTab($('div#tab_control .tabs .tab').last().attr('id'));
  }

  PageEdit.partLoading = function () {
    $('#add_part_button').attr('disabled', true);
    $('#add_part_busy').show();
  }

  PageEdit.validPartName = function () {
    var partNameField = $('#part_name_field');
    var name = partNameField.val().toLowerCase();
    if (name === '') {
      alert('Part name cannot be empty.');
      return false;
    }
    if ($('#tab_' + name).length > 0) {
      alert('Part name must be unique.');
      return false;
    }
    return true;
  }

}(window.PageEdit = window.PageEdit || {}, jQuery));

$(function () {
  $('#new_page_part').submit(function(event) {
    event.preventDefault();
    PageEdit.addPart(this);
  });
});

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
trusty-cms-1.1.19 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.18 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.17 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.16 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.15 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.14 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.13 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.12 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.11 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.10 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.9 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.8 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.7 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.6 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.5 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.4 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.3 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.2 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.1 app/assets/javascripts/admin/page-edit.js
trusty-cms-1.1.0 app/assets/javascripts/admin/page-edit.js