X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdevel%2Fwebprofiler%2Fjs%2Fapp%2Fviews%2Flayout.js;fp=web%2Fmodules%2Fcontrib%2Fdevel%2Fwebprofiler%2Fjs%2Fapp%2Fviews%2Flayout.js;h=6168b343040f921930c25d8ab9d445c41b944fc8;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/devel/webprofiler/js/app/views/layout.js b/web/modules/contrib/devel/webprofiler/js/app/views/layout.js new file mode 100644 index 000000000..6168b3430 --- /dev/null +++ b/web/modules/contrib/devel/webprofiler/js/app/views/layout.js @@ -0,0 +1,83 @@ +(function ($, Drupal, drupalSettings, Backbone) { + + "use strict"; + + Drupal.webprofiler.views.Layout = Backbone.View.extend({ + template: _.template( + '
' + + '' + + '
' + + '
' + + 'Choose a collector.' + + '
' + ), + + /** + * + * @returns {Drupal.webprofiler.views.Layout} + */ + render: function () { + this.$el.html(this.template()); + + if(this.currentDetails) { + this.currentDetails.setElement(this.$('#details')).render(); + } + + this.overview.setElement(this.$('#overview ul')).render(); + return this; + }, + + /** + * + * @param options + */ + initialize: function (options) { + options.router.collectors.on('request', this.beginSync); + options.router.collectors.on('sync', this.finishSync); + + this.overview = new Drupal.webprofiler.views.CollectorsList({ + collection: options.router.collectors, + router: options.router + }); + }, + + /** + * + * @param collector + */ + setDetails: function (collector) { + if (this.currentDetails) this.currentDetails.remove(); + this.currentDetails = new Drupal.webprofiler.views.DetailsView({model: collector}); + this.render(); + Drupal.attachBehaviors(/*this.$el, drupalSettings*/); + }, + + /** + * + */ + beginSync: function () { + $('.loader--fixed').fadeIn({duration: 100}); + }, + + /** + * + */ + finishSync: function () { + $('.loader--fixed').fadeOut({duration: 100}); + } + }); + + var instance; + Drupal.webprofiler.views.Layout.getInstance = function (options) { + if (!instance) { + instance = new Drupal.webprofiler.views.Layout({ + el: options.el, + router: options.router, + collection: options.router.collectors + }); + } + + return instance; + } + +}(jQuery, Drupal, drupalSettings, Backbone));