PageRenderTime 25ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Nancy/Diagnostics/Resources/Modules/interactive/providers.js

http://github.com/NancyFx/Nancy
JavaScript | 60 lines | 44 code | 16 blank | 0 comment | 0 complexity | d87a14571daac734c8dde152a4f25a1d MD5 | raw file
Possible License(s): CC-BY-SA-3.0, LGPL-3.0, Apache-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.0, BSD-3-Clause
  1. (function (Provider) {
  2. var app = diagnostics.app;
  3. Provider.Model = Backbone.Model.extend({});
  4. Provider.Collection = Backbone.Collection.extend({
  5. model: Provider.Model,
  6. url: function () {
  7. return Nancy.config.basePath + "interactive/providers/";
  8. }
  9. });
  10. Provider.Views.List = Backbone.View.extend({
  11. el: '#main',
  12. initialize: function () {
  13. this.template = $("#providerList").html();
  14. },
  15. render: function () {
  16. var providers = this.model.toJSON();
  17. var html = Handlebars.compile(this.template)({ collection: providers });
  18. $(this.el).html(html);
  19. _.each(providers, this.renderItem, this);
  20. },
  21. renderItem: function (model) {
  22. var itemView = new Provider.Views.Item({ model: model });
  23. $(this.el).append(itemView.el);
  24. }
  25. });
  26. Provider.Views.Item = Backbone.View.extend({
  27. className: "item-list",
  28. events: {
  29. 'click': 'showMethods'
  30. },
  31. initialize: function () {
  32. this.router = app.router;
  33. this.template = $("#provider").html();
  34. this.render();
  35. },
  36. render: function () {
  37. var html = Handlebars.compile(this.template)({ model: this.model });
  38. $(this.el).append(html);
  39. },
  40. showMethods: function () {
  41. this.router.navigate(this.model.name, true);
  42. }
  43. });
  44. })(diagnostics.module("provider"))