Sha256: f4f6c6813d28d4caf9eec9eecb139aaa2b6f1f0e7d930e2ea3b2e717f4c100b0

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

pageflow.PageSelectionView = Backbone.Marionette.ItemView.extend({
  template: 'templates/page_selection',
  className: 'page_selection dialog',

  mixins: [pageflow.dialogView],

  ui: {
    chapters: 'ul.chapters',
  },

  events: {
    'click ul.pages li': function(event) {
      this.options.onSelect(pageflow.pages.get($(event.currentTarget).data('id')));
      this.close();
    }
  },

  onRender: function() {
    var onSelect = this.onSelect;

    this.subview(new pageflow.CollectionView({
      el: this.ui.chapters,
      collection: this.model.chapters,
      itemViewConstructor: pageflow.ChapterItemView,
      itemViewOptions: {
        pageItemView: pageflow.PageItemView,
        sortable: false
      }
    }));
  }
});

pageflow.PageSelectionView.selectPage = function() {
  return $.Deferred(function(deferred) {
    var view = new pageflow.PageSelectionView({
      model: pageflow.entry,
      onSelect: deferred.resolve
    });

    view.on('close', function() {
      deferred.reject();
    });

    pageflow.app.dialogRegion.show(view.render());
  }).promise();
};

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pageflow-0.9.2 app/assets/javascripts/pageflow/editor/views/page_selection_view.js
pageflow-0.9.1 app/assets/javascripts/pageflow/editor/views/page_selection_view.js
pageflow-0.9.0 app/assets/javascripts/pageflow/editor/views/page_selection_view.js