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-4.2.3 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.2.2 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.2.1 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.2 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.1.9 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.1.8 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.1.7 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.1.6 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.1.5 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.1.4 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.1.3 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.1.2 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.1.1 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.1.0 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.0.2 app/assets/javascripts/admin/page-edit.js
trusty-cms-3.9.7 app/assets/javascripts/admin/page-edit.js
trusty-cms-3.9.6 app/assets/javascripts/admin/page-edit.js
trusty-cms-3.9.5 app/assets/javascripts/admin/page-edit.js
trusty-cms-4.0.1 app/assets/javascripts/admin/page-edit.js
trusty-cms-3.9.4 app/assets/javascripts/admin/page-edit.js