Daniel@0: "use strict"; Daniel@0: Daniel@0: App.module("RepresentationModule", function(RepresentationModule, App, Backbone, Marionette, $, _, Logger) { Daniel@0: Daniel@0: RepresentationModule.addInitializer(function(options){ Daniel@0: Daniel@0: RepresentationModule.registerMaster({ Daniel@0: id: "view._", Daniel@0: inherit: "_", Daniel@0: Daniel@0: options: { Daniel@0: canHaveBase: false, Daniel@0: canHaveOverlay: false, Daniel@0: canHaveTemp: false, Daniel@0: Daniel@0: visInstanceContentHeightMin: 20, Daniel@0: visInstanceContentHeightMax: 20, Daniel@0: visInstanceContentPaddingTop: 5, Daniel@0: visInstanceContentPaddingBottom: 5, Daniel@0: Daniel@0: visInstanceSupportedComparisonModes: [], Daniel@0: Daniel@0: auxiliaryAssetsTimeout: 2000, Daniel@0: auxiliaryAssetsCheckInterval: 500 Daniel@0: }, Daniel@0: Daniel@0: defaultConfigParameterValues: { Daniel@0: widthToHeightRatio: 2 Daniel@0: }, Daniel@0: Daniel@0: Daniel@0: // ================================================================= Daniel@0: // housekeeping Daniel@0: Daniel@0: initialize: function() { Daniel@0: this.obtainAuxiliaryData(); Daniel@0: this.obtainAuxiliaryAssets(); Daniel@0: }, Daniel@0: Daniel@0: Daniel@0: setAuxiliaryDataStatus: function(status) { Daniel@0: this.auxiliaryDataStatus = status; Daniel@0: this.trigger("change:auxiliaryResourcesStatus"); Daniel@0: }, Daniel@0: Daniel@0: setAuxiliaryAssetsStatus: function(status) { Daniel@0: this.auxiliaryAssetsStatus = status; Daniel@0: this.trigger("change:auxiliaryResourcesStatus"); Daniel@0: }, Daniel@0: Daniel@0: Daniel@0: getAuxiliaryResourcesStatus: function() { Daniel@0: if (this.auxiliaryDataStatus == "fail" || this.auxiliaryAssetsStatus == "fail") { Daniel@0: return "fail"; Daniel@0: } Daniel@0: if (this.auxiliaryDataStatus == "pending" || this.auxiliaryAssetsStatus == "pending") { Daniel@0: return "pending"; Daniel@0: } Daniel@0: return ""; Daniel@0: }, Daniel@0: Daniel@0: Daniel@0: obtainAuxiliaryAssets: function() { Daniel@0: if (!this.options.auxiliaryAssets || !this.options.auxiliaryAssets.length) { Daniel@0: return; Daniel@0: } Daniel@0: Daniel@0: if (this.auxiliaryAssetsStatus) { Daniel@0: return Daniel@0: } Daniel@0: Daniel@0: this.setAuxiliaryAssetsStatus("pending"); Daniel@0: Daniel@0: var $body = $("body"); Daniel@0: _.each(this.options.auxiliaryAssets, function(assetURL) { Daniel@0: $body.append("