Sha256: fbf53f076b8ef04f91df6f19a957a009260d571bbd9105b3cb9094956c26a32b

Contents?: true

Size: 1.28 KB

Versions: 154

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

154 entries across 154 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 app/assets/javascripts/admin/page-edit.js
trusty-cms-7.0.2 app/assets/javascripts/admin/page-edit.js
trusty-cms-7.0.1 app/assets/javascripts/admin/page-edit.js
trusty-cms-7.0.0 app/assets/javascripts/admin/page-edit.js
trusty-cms-6.3 app/assets/javascripts/admin/page-edit.js
trusty-cms-6.2.1 app/assets/javascripts/admin/page-edit.js
trusty-cms-6.2.2.1 app/assets/javascripts/admin/page-edit.js
trusty-cms-6.2.0 app/assets/javascripts/admin/page-edit.js
trusty-cms-6.1.2 app/assets/javascripts/admin/page-edit.js
trusty-cms-6.1.1 app/assets/javascripts/admin/page-edit.js
trusty-cms-6.0.5 app/assets/javascripts/admin/page-edit.js
trusty-cms-6.0.4 app/assets/javascripts/admin/page-edit.js
trusty-cms-6.0.3 app/assets/javascripts/admin/page-edit.js
trusty-cms-6.0.2 app/assets/javascripts/admin/page-edit.js
trusty-cms-6.0.1 app/assets/javascripts/admin/page-edit.js
trusty-cms-5.6.1 app/assets/javascripts/admin/page-edit.js
trusty-cms-6.0.0 app/assets/javascripts/admin/page-edit.js
trusty-cms-5.6.0 app/assets/javascripts/admin/page-edit.js
trusty-cms-5.5.9 app/assets/javascripts/admin/page-edit.js
trusty-cms-5.5.8 app/assets/javascripts/admin/page-edit.js