Sha256: 05a17c898289886d57e7ab55709fd92bc8c74f37caba298500d74b12b1fa610a

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

pageflow.internalLinks.EditPageLinkView = Backbone.Marionette.Layout.extend({
  template: 'pageflow/internal_links/editor/templates/edit_page_link',

  regions: {
    formContainer: '.form_container'
  },

  ui: {
    backButton: 'a.back'
  },

  events: {
    'click a.back': 'goBack',

    'click a.destroy': 'destroy'
  },

  onRender: function() {
    var configurationEditor = new pageflow.ConfigurationEditorView({
      model: this.model
    });

    this.configure(configurationEditor);
    this.formContainer.show(configurationEditor);

    this.highlight();
  },

  highlight: function() {
    var page = this.model.collection.page;

    this.model.highlight();
    page.set('internal_links_editable', true);

    this.listenTo(this, 'close', function() {
      this.model.resetHighlight();
      page.unset('internal_links_editable');
    });
  },

  configure: function(configurationEditor) {
    configurationEditor.tab('general', function() {
      this.input('label', pageflow.TextInputView);
      this.input('target_page_id', pageflow.PageLinkInputView);
      this.input('page_transition', pageflow.SelectInputView, {
        translationKeyPrefix: 'pageflow.page_transitions',
        includeBlank: true,
        blankTranslationKey: 'pageflow.internal_links.editor.views.edit_page_link_view.default_page_transition',
        values: pageflow.pageTransitions.names()
      });
      this.input('description', pageflow.TextAreaInputView, {
        size: 'short'
      });
    });
  },

  destroy: function() {
    if (confirm(I18n.t('pageflow.internal_links.editor.views.edit_page_link_view.confirm_destroy'))) {
      this.model.remove();
      this.goBack();
    }
  },

  goBack: function() {
    pageflow.editor.navigate('/pages/' + this.options.page.id + '/links', {trigger: true});
  }
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pageflow-internal-links-0.1.0 app/assets/javascripts/pageflow/internal_links/editor/views/edit_page_link_view.js