From a93f41f1c3743f703e33948f3f136297ce4ad0e6 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 30 Sep 2016 10:25:22 -0700 Subject: [PATCH] [API] Miscellaneous platform updates Adds miscellaneous platform updates to include templates via the RequireJS text plugin; to support modification of asset paths; and to support priority order for gestures. Supports integration of new API, #1124. --- platform/commonUI/browse/bundle.js | 4 +++- platform/commonUI/general/bundle.js | 12 ++++++++++-- .../commonUI/general/src/StyleSheetLoader.js | 3 ++- platform/execution/src/WorkerService.js | 18 +++++++++++++----- platform/features/table/bundle.js | 12 +++++++++--- .../src/gestures/GestureProvider.js | 2 +- platform/search/bundle.js | 4 +++- 7 files changed, 41 insertions(+), 14 deletions(-) diff --git a/platform/commonUI/browse/bundle.js b/platform/commonUI/browse/bundle.js index 5ff13d789e..b0aa7e4277 100644 --- a/platform/commonUI/browse/bundle.js +++ b/platform/commonUI/browse/bundle.js @@ -41,6 +41,7 @@ define([ "text!./res/templates/items/items.html", "text!./res/templates/browse/object-properties.html", "text!./res/templates/browse/inspector-region.html", + "text!./res/templates/view-object.html", 'legacyRegistry' ], function ( BrowseController, @@ -63,6 +64,7 @@ define([ itemsTemplate, objectPropertiesTemplate, inspectorRegionTemplate, + viewObjectTemplate, legacyRegistry ) { @@ -142,7 +144,7 @@ define([ "representations": [ { "key": "view-object", - "templateUrl": "templates/view-object.html" + "template": viewObjectTemplate }, { "key": "browse-object", diff --git a/platform/commonUI/general/bundle.js b/platform/commonUI/general/bundle.js index 15ea3076a6..4bd4a83873 100644 --- a/platform/commonUI/general/bundle.js +++ b/platform/commonUI/general/bundle.js @@ -48,6 +48,7 @@ define([ "./src/directives/MCTSplitPane", "./src/directives/MCTSplitter", "./src/directives/MCTTree", + "./src/filters/ReverseFilter.js", "text!./res/templates/bottombar.html", "text!./res/templates/controls/action-button.html", "text!./res/templates/controls/input-filter.html", @@ -96,6 +97,7 @@ define([ MCTSplitPane, MCTSplitter, MCTTree, + ReverseFilter, bottombarTemplate, actionButtonTemplate, inputFilterTemplate, @@ -146,7 +148,8 @@ define([ "depends": [ "stylesheets[]", "$document", - "THEME" + "THEME", + "ASSETS_PATH" ] }, { @@ -158,7 +161,7 @@ define([ ], "filters": [ { - "implementation": "filters/ReverseFilter.js", + "implementation": ReverseFilter, "key": "reverse" } ], @@ -405,6 +408,11 @@ define([ "key": "THEME", "value": "unspecified", "priority": "fallback" + }, + { + "key": "ASSETS_PATH", + "value": ".", + "priority": "fallback" } ], "containers": [ diff --git a/platform/commonUI/general/src/StyleSheetLoader.js b/platform/commonUI/general/src/StyleSheetLoader.js index 13c5075a8b..29787e2ee8 100644 --- a/platform/commonUI/general/src/StyleSheetLoader.js +++ b/platform/commonUI/general/src/StyleSheetLoader.js @@ -38,7 +38,7 @@ define( * @param $document Angular's jqLite-wrapped document element * @param {string} activeTheme the theme in use */ - function StyleSheetLoader(stylesheets, $document, activeTheme) { + function StyleSheetLoader(stylesheets, $document, activeTheme, assetPath) { var head = $document.find('head'), document = $document[0]; @@ -47,6 +47,7 @@ define( // Create a link element, and construct full path var link = document.createElement('link'), path = [ + assetPath, stylesheet.bundle.path, stylesheet.bundle.resources, stylesheet.stylesheetUrl diff --git a/platform/execution/src/WorkerService.js b/platform/execution/src/WorkerService.js index d809a568f2..87efd6f7da 100644 --- a/platform/execution/src/WorkerService.js +++ b/platform/execution/src/WorkerService.js @@ -42,11 +42,19 @@ define( function addWorker(worker) { var key = worker.key; if (!workerUrls[key]) { - workerUrls[key] = [ - worker.bundle.path, - worker.bundle.sources, - worker.scriptUrl - ].join("/"); + if (worker.scriptUrl) { + workerUrls[key] = [ + worker.bundle.path, + worker.bundle.sources, + worker.scriptUrl + ].join("/"); + } else if (worker.scriptText) { + var blob = new Blob( + [worker.scriptText], + {type: 'application/javascript'} + ); + workerUrls[key] = URL.createObjectURL(blob); + } sharedWorkers[key] = worker.shared; } } diff --git a/platform/features/table/bundle.js b/platform/features/table/bundle.js index 4c7b77b47e..8e820abef6 100644 --- a/platform/features/table/bundle.js +++ b/platform/features/table/bundle.js @@ -27,6 +27,9 @@ define([ "./src/controllers/TableOptionsController", '../../commonUI/regions/src/Region', '../../commonUI/browse/src/InspectorRegion', + "text!./res/templates/table-options-edit.html", + "text!./res/templates/rt-table.html", + "text!./res/templates/historical-table.html", "legacyRegistry" ], function ( MCTTable, @@ -35,6 +38,9 @@ define([ TableOptionsController, Region, InspectorRegion, + tableOptionsEditTemplate, + rtTableTemplate, + historicalTableTemplate, legacyRegistry ) { /** @@ -127,8 +133,8 @@ define([ { "name": "Historical Table", "key": "table", + "template": historicalTableTemplate, "cssclass": "icon-tabular", - "templateUrl": "templates/historical-table.html", "needs": [ "telemetry" ], @@ -139,7 +145,7 @@ define([ "name": "Real-time Table", "key": "rt-table", "cssclass": "icon-tabular-realtime", - "templateUrl": "templates/rt-table.html", + "templateUrl": rtTableTemplate, "needs": [ "telemetry" ], @@ -157,7 +163,7 @@ define([ "representations": [ { "key": "table-options-edit", - "templateUrl": "templates/table-options-edit.html" + "template": tableOptionsEditTemplate } ], "stylesheets": [ diff --git a/platform/representation/src/gestures/GestureProvider.js b/platform/representation/src/gestures/GestureProvider.js index 5e170f68ac..051dafd5a7 100644 --- a/platform/representation/src/gestures/GestureProvider.js +++ b/platform/representation/src/gestures/GestureProvider.js @@ -72,7 +72,7 @@ define( // Assemble all gestures into a map, for easy look up gestures.forEach(function (gesture) { - gestureMap[gesture.key] = gesture; + gestureMap[gesture.key] = gestureMap[gesture.key] || gesture; }); this.gestureMap = gestureMap; diff --git a/platform/search/bundle.js b/platform/search/bundle.js index 61a266d049..7f8a64ab04 100644 --- a/platform/search/bundle.js +++ b/platform/search/bundle.js @@ -28,6 +28,7 @@ define([ "text!./res/templates/search-item.html", "text!./res/templates/search.html", "text!./res/templates/search-menu.html", + "text!./src/services/GenericSearchWorker.js", 'legacyRegistry' ], function ( SearchController, @@ -37,6 +38,7 @@ define([ searchItemTemplate, searchTemplate, searchMenuTemplate, + searchWorkerText, legacyRegistry ) { @@ -114,7 +116,7 @@ define([ "workers": [ { "key": "genericSearchWorker", - "scriptUrl": "services/GenericSearchWorker.js" + "scriptText": searchWorkerText } ] }