mirror of
https://github.com/nasa/openmct.git
synced 2025-06-26 19:12:02 +00:00
Compare commits
39 Commits
vue-hack
...
subobject-
Author | SHA1 | Date | |
---|---|---|---|
407550e6f4 | |||
8b44b44e38 | |||
8dfa8df28a | |||
9e19296b14 | |||
106632c21c | |||
235032a571 | |||
db41f6e64f | |||
e83e0da521 | |||
c411f8fbe3 | |||
4ce952846c | |||
fdab4a614f | |||
152f55652f | |||
c46c42e576 | |||
75bf956c3d | |||
0a44c48338 | |||
e4c3412e8a | |||
4e1cfac4b9 | |||
0a64e9f515 | |||
7341ed9d03 | |||
e2631bdcfd | |||
773a7c0c24 | |||
fdcba66558 | |||
3b1ed7821f | |||
1be517f3ea | |||
5e3dcadfa4 | |||
fd97f4db41 | |||
3228a83802 | |||
1dba551fc6 | |||
20f3b57ddd | |||
58787c4436 | |||
2a45893602 | |||
a94ab44431 | |||
cc9efdff31 | |||
6e664003e3 | |||
70d804fc49 | |||
06c184821e | |||
b76be3d2e5 | |||
8934ba96f7 | |||
3fb4ce7819 |
@ -19,6 +19,7 @@
|
|||||||
"comma-separated-values": "^3.6.4",
|
"comma-separated-values": "^3.6.4",
|
||||||
"FileSaver.js": "^0.0.2",
|
"FileSaver.js": "^0.0.2",
|
||||||
"zepto": "^1.1.6",
|
"zepto": "^1.1.6",
|
||||||
|
"eventemitter3": "^1.2.0",
|
||||||
"html2canvas": "^0.4.1",
|
"html2canvas": "^0.4.1",
|
||||||
"jspdf": "^1.2.61"
|
"jspdf": "^1.2.61"
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,12 @@
|
|||||||
<script src="bower_components/requirejs/require.js">
|
<script src="bower_components/requirejs/require.js">
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
require(['main'], function (mct) {
|
require(['main'], function (openmct) {
|
||||||
require([
|
require([
|
||||||
'./example/imagery/bundle',
|
'./example/imagery/bundle',
|
||||||
'./example/eventGenerator/bundle',
|
'./example/eventGenerator/bundle',
|
||||||
'./example/generator/bundle'
|
'./example/generator/bundle'
|
||||||
], mct.run.bind(mct));
|
], openmct.start.bind(openmct));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<link rel="stylesheet" href="platform/commonUI/general/res/css/startup-base.css">
|
<link rel="stylesheet" href="platform/commonUI/general/res/css/startup-base.css">
|
||||||
|
21
main.js
21
main.js
@ -27,6 +27,7 @@ requirejs.config({
|
|||||||
"angular": "bower_components/angular/angular.min",
|
"angular": "bower_components/angular/angular.min",
|
||||||
"angular-route": "bower_components/angular-route/angular-route.min",
|
"angular-route": "bower_components/angular-route/angular-route.min",
|
||||||
"csv": "bower_components/comma-separated-values/csv.min",
|
"csv": "bower_components/comma-separated-values/csv.min",
|
||||||
|
"EventEmitter": "bower_components/eventemitter3/index",
|
||||||
"es6-promise": "bower_components/es6-promise/es6-promise.min",
|
"es6-promise": "bower_components/es6-promise/es6-promise.min",
|
||||||
"html2canvas": "bower_components/html2canvas/build/html2canvas.min",
|
"html2canvas": "bower_components/html2canvas/build/html2canvas.min",
|
||||||
"jsPDF": "bower_components/jspdf/dist/jspdf.min",
|
"jsPDF": "bower_components/jspdf/dist/jspdf.min",
|
||||||
@ -45,6 +46,9 @@ requirejs.config({
|
|||||||
"angular-route": {
|
"angular-route": {
|
||||||
"deps": ["angular"]
|
"deps": ["angular"]
|
||||||
},
|
},
|
||||||
|
"EventEmitter": {
|
||||||
|
"exports": "EventEmitter"
|
||||||
|
},
|
||||||
"html2canvas": {
|
"html2canvas": {
|
||||||
"exports": "html2canvas"
|
"exports": "html2canvas"
|
||||||
},
|
},
|
||||||
@ -64,6 +68,7 @@ requirejs.config({
|
|||||||
});
|
});
|
||||||
|
|
||||||
define([
|
define([
|
||||||
|
'./src/openmct',
|
||||||
'./platform/framework/src/Main',
|
'./platform/framework/src/Main',
|
||||||
'legacyRegistry',
|
'legacyRegistry',
|
||||||
|
|
||||||
@ -101,12 +106,12 @@ define([
|
|||||||
'./platform/entanglement/bundle',
|
'./platform/entanglement/bundle',
|
||||||
'./platform/search/bundle',
|
'./platform/search/bundle',
|
||||||
'./platform/status/bundle',
|
'./platform/status/bundle',
|
||||||
'./platform/commonUI/regions/bundle'
|
'./platform/commonUI/regions/bundle',
|
||||||
], function (Main, legacyRegistry) {
|
'./src/adapter/legacyBundle'
|
||||||
return {
|
], function (openmct, Main, legacyRegistry) {
|
||||||
legacyRegistry: legacyRegistry,
|
openmct.legacyRegistry = legacyRegistry;
|
||||||
run: function () {
|
openmct.on('start', function () {
|
||||||
return new Main().run(legacyRegistry);
|
return new Main().run(legacyRegistry);
|
||||||
}
|
});
|
||||||
};
|
return openmct;
|
||||||
});
|
});
|
||||||
|
@ -72,7 +72,7 @@ define(
|
|||||||
|
|
||||||
// Assemble all gestures into a map, for easy look up
|
// Assemble all gestures into a map, for easy look up
|
||||||
gestures.forEach(function (gesture) {
|
gestures.forEach(function (gesture) {
|
||||||
gestureMap[gesture.key] = gesture;
|
gestureMap[gesture.key] = gestureMap[gesture.key] || gesture;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.gestureMap = gestureMap;
|
this.gestureMap = gestureMap;
|
||||||
|
21
src/Registry.js
Normal file
21
src/Registry.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
define([], function () {
|
||||||
|
function Registry() {
|
||||||
|
this.providers = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
Registry.prototype.get = function (context) {
|
||||||
|
return this.providers.filter(function (provider) {
|
||||||
|
return provider.appliesTo(context);
|
||||||
|
}).map(function (provider) {
|
||||||
|
return provider.get(context);
|
||||||
|
}).reduce(function (a, b) {
|
||||||
|
return Array.isArray(b) ? a.concat(b) : a.concat([b]);
|
||||||
|
}, []);
|
||||||
|
};
|
||||||
|
|
||||||
|
Registry.prototype.register = function (provider) {
|
||||||
|
this.providers.push(provider);
|
||||||
|
};
|
||||||
|
|
||||||
|
return Registry;
|
||||||
|
});
|
9
src/adapter/gestures/AdaptedContextMenuGesture.js
Normal file
9
src/adapter/gestures/AdaptedContextMenuGesture.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
define(
|
||||||
|
function () {
|
||||||
|
function AdaptedContextMenuGesture(openmct, $els, domainObject) {
|
||||||
|
this.destroy = openmct.gestures.contextual($els[0], domainObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
return AdaptedContextMenuGesture;
|
||||||
|
}
|
||||||
|
);
|
48
src/adapter/legacyBundle.js
Normal file
48
src/adapter/legacyBundle.js
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define([
|
||||||
|
'legacyRegistry',
|
||||||
|
'./gestures/AdaptedContextMenuGesture',
|
||||||
|
'../openmct'
|
||||||
|
], function (legacyRegistry, AdaptedContextMenuGesture, openmct) {
|
||||||
|
legacyRegistry.register('adapter', {
|
||||||
|
extensions: {
|
||||||
|
services: [
|
||||||
|
{
|
||||||
|
key: "openmct",
|
||||||
|
implementation: function () {
|
||||||
|
return openmct;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
gestures: [
|
||||||
|
{
|
||||||
|
key: "menu",
|
||||||
|
implementation: AdaptedContextMenuGesture,
|
||||||
|
priority: "preferred",
|
||||||
|
depends: ["openmct"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
28
src/adapter/ui/AngularView.js
Normal file
28
src/adapter/ui/AngularView.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
define(['angular'], function (angular) {
|
||||||
|
function AngularView(template) {
|
||||||
|
this.template = template;
|
||||||
|
}
|
||||||
|
|
||||||
|
AngularView.prototype.show = function (container) {
|
||||||
|
if (this.activeScope) {
|
||||||
|
this.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
var $injector = angular.injector(['ng']);
|
||||||
|
var $compile = $injector.get('$compile');
|
||||||
|
var $rootScope = $injector.get('$rootScope');
|
||||||
|
var $scope = $rootScope.$new();
|
||||||
|
var elements = $compile(this.template)($scope);
|
||||||
|
|
||||||
|
angular.element(container).append(elements);
|
||||||
|
};
|
||||||
|
|
||||||
|
AngularView.prototype.destroy = function () {
|
||||||
|
if (this.activeScope) {
|
||||||
|
this.activeScope.$destroy();
|
||||||
|
this.activeScope = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return AngularView;
|
||||||
|
});
|
65
src/openmct.js
Normal file
65
src/openmct.js
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define([
|
||||||
|
'EventEmitter',
|
||||||
|
'./Registry',
|
||||||
|
'./selection/Selection',
|
||||||
|
'./selection/ContextManager',
|
||||||
|
'./selection/SelectGesture',
|
||||||
|
'./ui/menu/ContextMenuGesture',
|
||||||
|
'./ui/ViewRegistry'
|
||||||
|
], function (
|
||||||
|
EventEmitter,
|
||||||
|
Registry,
|
||||||
|
Selection,
|
||||||
|
ContextManager,
|
||||||
|
SelectGesture,
|
||||||
|
ContextMenuGesture,
|
||||||
|
ViewRegistry
|
||||||
|
) {
|
||||||
|
var openmct = Object.create(EventEmitter.prototype);
|
||||||
|
var actionRegistry = new Registry();
|
||||||
|
var selection = new Selection();
|
||||||
|
var manager = new ContextManager();
|
||||||
|
var select = new SelectGesture(manager, selection);
|
||||||
|
var contextMenu = new ContextMenuGesture(
|
||||||
|
selection,
|
||||||
|
{},
|
||||||
|
actionRegistry,
|
||||||
|
manager
|
||||||
|
);
|
||||||
|
|
||||||
|
EventEmitter.call(openmct);
|
||||||
|
|
||||||
|
openmct.selection = selection;
|
||||||
|
openmct.inspectors = new ViewRegistry();
|
||||||
|
|
||||||
|
openmct.gestures = {
|
||||||
|
selectable: select.apply.bind(select),
|
||||||
|
contextual: contextMenu.apply.bind(contextMenu)
|
||||||
|
};
|
||||||
|
|
||||||
|
openmct.start = openmct.emit.bind(openmct, 'start');
|
||||||
|
|
||||||
|
return openmct;
|
||||||
|
});
|
77
src/selection/ContextManager.js
Normal file
77
src/selection/ContextManager.js
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define(['zepto'], function ($) {
|
||||||
|
/**
|
||||||
|
* @typedef Context
|
||||||
|
* @property {*} item
|
||||||
|
* @property {HTMLElement} element
|
||||||
|
* @property {Context} parent the containing context (may be undefined)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function ContextManager() {
|
||||||
|
this.counter = 0;
|
||||||
|
this.contexts = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
ContextManager.prototype.nextId = function () {
|
||||||
|
this.counter += 1;
|
||||||
|
return "context-" + this.counter;
|
||||||
|
};
|
||||||
|
|
||||||
|
ContextManager.prototype.context = function (item, htmlElement) {
|
||||||
|
var $element = $(htmlElement);
|
||||||
|
var id = $element.attr('data-context') || this.nextId();
|
||||||
|
|
||||||
|
$element.attr('data-context', id);
|
||||||
|
|
||||||
|
if (this.contexts[id] && this.contexts[id].item !== item) {
|
||||||
|
this.release(htmlElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.contexts[id]) {
|
||||||
|
var $parent = $element.closest('[data-context]');
|
||||||
|
var parentId = $parent.attr('data-context');
|
||||||
|
var parentContext = parentId ? this.contexts[parentId] : undefined;
|
||||||
|
this.contexts[id] = {
|
||||||
|
item: item,
|
||||||
|
element: htmlElement,
|
||||||
|
parent: parentContext
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.contexts[id];
|
||||||
|
};
|
||||||
|
|
||||||
|
ContextManager.prototype.release = function (htmlElement) {
|
||||||
|
var $element = $(htmlElement);
|
||||||
|
var id = $element.attr('data-context');
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
delete this.contexts[id];
|
||||||
|
$element.removeAttr('data-context');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return ContextManager;
|
||||||
|
});
|
58
src/selection/HoverGesture.js
Normal file
58
src/selection/HoverGesture.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define(['zepto'], function ($) {
|
||||||
|
function HoverGesture(hoverManager) {
|
||||||
|
this.hoverManager = hoverManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
HoverGesture.prototype.apply = function (htmlElement) {
|
||||||
|
var $element = $(htmlElement);
|
||||||
|
var hoverManager = this.hoverManager;
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
$(hoverManager.all()).removeClass('hovering');
|
||||||
|
$(hoverManager.top()).addClass('hovering');
|
||||||
|
}
|
||||||
|
|
||||||
|
function enter() {
|
||||||
|
hoverManager.add(htmlElement);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
function leave() {
|
||||||
|
hoverManager.remove(htmlElement);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
$element.on('mouseenter', enter);
|
||||||
|
$element.on('mouseleave', leave);
|
||||||
|
|
||||||
|
return function () {
|
||||||
|
leave();
|
||||||
|
$element.off('mouseenter', enter);
|
||||||
|
$element.off('mouseleave', leave);
|
||||||
|
}.bind(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
return HoverGesture;
|
||||||
|
});
|
60
src/selection/SelectGesture.js
Normal file
60
src/selection/SelectGesture.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define(['zepto'], function ($) {
|
||||||
|
function SelectGesture(selection, contextManager) {
|
||||||
|
this.selection = selection;
|
||||||
|
this.contextManager = contextManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectGesture.prototype.apply = function (htmlElement, item) {
|
||||||
|
var $element = $(htmlElement);
|
||||||
|
var contextManager = this.contextManager;
|
||||||
|
var selection = this.selection;
|
||||||
|
var path = contextManager.path(item, htmlElement);
|
||||||
|
|
||||||
|
function select() {
|
||||||
|
selection.add(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
function change() {
|
||||||
|
var selected = selection.primary();
|
||||||
|
$element.toggleClass(
|
||||||
|
'selected',
|
||||||
|
selected && path.matches(selected)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$element.addClass('selectable');
|
||||||
|
$element.on('click', select);
|
||||||
|
selection.on('change', change);
|
||||||
|
change(); // Initialize
|
||||||
|
|
||||||
|
return function () {
|
||||||
|
contextManager.release(htmlElement);
|
||||||
|
$element.off('click', select);
|
||||||
|
selection.off('change', change);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
return SelectGesture;
|
||||||
|
});
|
64
src/selection/Selection.js
Normal file
64
src/selection/Selection.js
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define(['EventEmitter'], function (EventEmitter) {
|
||||||
|
function Selection() {
|
||||||
|
EventEmitter.call(this);
|
||||||
|
this.selected = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
Selection.prototype = Object.create(EventEmitter.prototype);
|
||||||
|
|
||||||
|
Selection.prototype.add = function (path) {
|
||||||
|
this.clear(); // Only allow single select as initial simplification
|
||||||
|
this.selected.push(path);
|
||||||
|
this.emit('change');
|
||||||
|
};
|
||||||
|
|
||||||
|
Selection.prototype.remove = function (path) {
|
||||||
|
this.selected = this.selected.filter(function (otherPath) {
|
||||||
|
return !path.matches(otherPath);
|
||||||
|
});
|
||||||
|
this.emit('change');
|
||||||
|
};
|
||||||
|
|
||||||
|
Selection.prototype.contains = function (path) {
|
||||||
|
return this.selected.some(function (otherPath) {
|
||||||
|
return path.matches(otherPath);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Selection.prototype.clear = function () {
|
||||||
|
this.selected = [];
|
||||||
|
this.emit('change');
|
||||||
|
};
|
||||||
|
|
||||||
|
Selection.prototype.primary = function () {
|
||||||
|
return this.selected[this.selected.length - 1];
|
||||||
|
};
|
||||||
|
|
||||||
|
Selection.prototype.all = function () {
|
||||||
|
return this.selected;
|
||||||
|
};
|
||||||
|
|
||||||
|
return Selection;
|
||||||
|
});
|
43
src/ui/InspectorRegion.js
Normal file
43
src/ui/InspectorRegion.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
define(['zepto'], function ($) {
|
||||||
|
function InspectorRegion(element, selection, inspectors) {
|
||||||
|
this.element = element;
|
||||||
|
this.selection = selection;
|
||||||
|
this.inspectors = inspectors;
|
||||||
|
this.active = false;
|
||||||
|
|
||||||
|
this.onSelectionChange = this.onSelectionChange.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
InspectorRegion.prototype.onSelectionChange = function (item) {
|
||||||
|
var $element = $(this.element);
|
||||||
|
var providers = this.inspectors.get(item);
|
||||||
|
|
||||||
|
$element.empty();
|
||||||
|
|
||||||
|
if (factories.length > 0) {
|
||||||
|
providers[0].view(item).show(this.element);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
InspectorRegion.prototype.activate = function () {
|
||||||
|
if (this.active) {
|
||||||
|
this.deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selection.on('change', this.onSelectionChange);
|
||||||
|
|
||||||
|
this.active = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
InspectorRegion.prototype.deactivate = function () {
|
||||||
|
if (!this.active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selection.off('change', this.onSelectionChange);
|
||||||
|
|
||||||
|
this.active = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
return InspectorRegion;
|
||||||
|
});
|
18
src/ui/ViewRegistry.js
Normal file
18
src/ui/ViewRegistry.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
define([], function () {
|
||||||
|
function ViewRegistry() {
|
||||||
|
this.providers = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewRegistry.prototype.get = function (item) {
|
||||||
|
return this.providers.filter(function (provider) {
|
||||||
|
return provider.canView(item);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
ViewRegistry.prototype.addProvider = function (provider) {
|
||||||
|
this.providers.push(provider);
|
||||||
|
};
|
||||||
|
|
||||||
|
return ViewRegistry;
|
||||||
|
|
||||||
|
});
|
42
src/ui/menu/ContextMenuGesture.js
Normal file
42
src/ui/menu/ContextMenuGesture.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
define(['zepto', './ContextMenuView'], function ($, ContextMenuView) {
|
||||||
|
function ContextMenuGesture(
|
||||||
|
selection,
|
||||||
|
overlayManager,
|
||||||
|
actionRegistry,
|
||||||
|
contextManager
|
||||||
|
) {
|
||||||
|
this.selection = selection;
|
||||||
|
this.overlayManager = overlayManager;
|
||||||
|
this.actionRegistry = actionRegistry;
|
||||||
|
this.contextManager = contextManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
ContextMenuGesture.prototype.apply = function (htmlElement, item) {
|
||||||
|
var overlayManager = this.overlayManager;
|
||||||
|
var selection = this.selection;
|
||||||
|
var actionRegistry = this.actionRegistry;
|
||||||
|
var contextManager = this.contextManager;
|
||||||
|
|
||||||
|
var $element = $(htmlElement);
|
||||||
|
var context = contextManager.context(item, htmlElement);
|
||||||
|
|
||||||
|
function showMenu(event) {
|
||||||
|
selection.add(context);
|
||||||
|
|
||||||
|
var x = event.clientX;
|
||||||
|
var y = event.clientY;
|
||||||
|
var actions = actionRegistry.get(context);
|
||||||
|
var view = new ContextMenuView(actions);
|
||||||
|
|
||||||
|
overlayManager.show(view, x, y);
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
$element.on('contextmenu', showMenu);
|
||||||
|
|
||||||
|
return $element.off.bind($element, 'contextmenu', showMenu);
|
||||||
|
};
|
||||||
|
|
||||||
|
return ContextMenuGesture;
|
||||||
|
});
|
10
src/ui/menu/ContextMenuView.js
Normal file
10
src/ui/menu/ContextMenuView.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
define(['zepto'], function ($) {
|
||||||
|
function ContextMenuView(actions) {
|
||||||
|
this.actions = actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
ContextMenuView.prototype.show = function (element) {
|
||||||
|
};
|
||||||
|
|
||||||
|
return ContextMenuView;
|
||||||
|
});
|
@ -53,6 +53,7 @@ requirejs.config({
|
|||||||
"angular": "bower_components/angular/angular.min",
|
"angular": "bower_components/angular/angular.min",
|
||||||
"angular-route": "bower_components/angular-route/angular-route.min",
|
"angular-route": "bower_components/angular-route/angular-route.min",
|
||||||
"csv": "bower_components/comma-separated-values/csv.min",
|
"csv": "bower_components/comma-separated-values/csv.min",
|
||||||
|
"EventEmitter": "bower_components/eventemitter3/index",
|
||||||
"es6-promise": "bower_components/es6-promise/es6-promise.min",
|
"es6-promise": "bower_components/es6-promise/es6-promise.min",
|
||||||
"html2canvas": "bower_components/html2canvas/build/html2canvas.min",
|
"html2canvas": "bower_components/html2canvas/build/html2canvas.min",
|
||||||
"jsPDF": "bower_components/jspdf/dist/jspdf.min",
|
"jsPDF": "bower_components/jspdf/dist/jspdf.min",
|
||||||
@ -72,6 +73,9 @@ requirejs.config({
|
|||||||
"angular-route": {
|
"angular-route": {
|
||||||
"deps": [ "angular" ]
|
"deps": [ "angular" ]
|
||||||
},
|
},
|
||||||
|
"EventEmitter": {
|
||||||
|
"exports": "EventEmitter"
|
||||||
|
},
|
||||||
"moment-duration-format": {
|
"moment-duration-format": {
|
||||||
"deps": [ "moment" ]
|
"deps": [ "moment" ]
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user