Sha256: 9ea536a6d3bfc1f66358f16c2dc556a77e082d56ccb2301dda63a9710f1e53c7

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

pageflow.sitemap.SelectionNavigator = pageflow.Object.extend({
  initialize: function(options) {
    this.api = options.api || pageflow.editor;
    this.selection = options.selection;
    this.options = options;
  },

  attach: function() {
    this.listenToSelection('pages', function(page) {
      return '/pages/' + page.id;
    });

    this.listenToSelection('chapters', function(chapter) {
      return '/chapters/' + chapter.id;
    });

    this.listenToSelection('storylines', function(storyline) {
      return '/storylines/' + storyline.id;
    });

    this.listenToSelection('successorLinks', function(link) {
      return '/storylines/' + link.successor.id;
    });

    this.listenToSelection('pageLinks', function(pageLink) {
      return pageLink.editPath ? pageLink.editPath() : this.options.emptySelectionPath;
    });
  },

  listenToSelection: function(name, path) {
    this.listenTo(this.selection, 'select:' + name, function(models) {
      if (models.length === 1) {
        this.api.navigate(path(models[0]), {trigger: true});
      }
      else if (models.length > 1) {
        this.api.navigate(this.options.multiSelectionPath, {trigger: true});
      }
      else {
        this.api.navigate(this.options.emptySelectionPath, {trigger: true});
      }
    });
  }
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pageflow-sitemap-1.5.0 app/assets/javascripts/pageflow/sitemap/editor/controllers/selection_navigator.js
pageflow-sitemap-1.4.0 app/assets/javascripts/pageflow/sitemap/editor/controllers/selection_navigator.js
pageflow-sitemap-1.3.0 app/assets/javascripts/pageflow/sitemap/editor/controllers/selection_navigator.js
pageflow-sitemap-1.2.0 app/assets/javascripts/pageflow/sitemap/editor/controllers/selection_navigator.js
pageflow-sitemap-1.1.0 app/assets/javascripts/pageflow/sitemap/editor/controllers/selection_navigator.js
pageflow-sitemap-1.0.0 app/assets/javascripts/pageflow/sitemap/editor/controllers/selection_navigator.js
pageflow-sitemap-0.1.0 app/assets/javascripts/pageflow/sitemap/editor/controllers/selection_navigator.js