Sha256: 57ecd119aa6fa1c09b7342a3d38c17de33caa6b8b2de494abd8788f7b61109e4

Contents?: true

Size: 682 Bytes

Versions: 7

Compression:

Stored size: 682 Bytes

Contents

pageflow.sitemap.FragmentParser = pageflow.Object.extend({
  patterns: {
    storylines: /^\/?storylines\/(\d+)/,
    chapters: /^\/?chapters\/(\d+)/,
    pages: /^\/?pages\/(\d+)/
  },

  initialize: function(entry, fragment) {
    this.entry = entry;
    this.fragment = fragment;
  },

  select: function(selection) {
    _(this.patterns).any(function(pattern, name) {
      var model = this.getModel(name);

      if (model) {
        selection.select(name, model);
        return true;
      }
    }, this);
  },

  getModel: function(name) {
    var match = this.fragment.match(this.patterns[name]);

    if (match) {
      return this.entry[name].get(match[1]);
    }
  }
});

Version data entries

7 entries across 7 versions & 1 rubygems

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