mirror of
https://github.com/nasa/openmct.git
synced 2025-05-12 13:33:14 +00:00
[Tree] Enable gestures on labels
This commit is contained in:
parent
02ec6db104
commit
f7ba24c0b6
@ -395,7 +395,7 @@ define([
|
|||||||
{
|
{
|
||||||
"key": "mctTree",
|
"key": "mctTree",
|
||||||
"implementation": MCTTree,
|
"implementation": MCTTree,
|
||||||
"depends": [ '$parse' ]
|
"depends": [ '$parse', 'gestureService' ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"constants": [
|
"constants": [
|
||||||
|
@ -25,9 +25,9 @@ define([
|
|||||||
'angular',
|
'angular',
|
||||||
'../ui/TreeView'
|
'../ui/TreeView'
|
||||||
], function (angular, TreeView) {
|
], function (angular, TreeView) {
|
||||||
function MCTTree($parse) {
|
function MCTTree($parse, gestureService) {
|
||||||
function link(scope, element, attrs) {
|
function link(scope, element, attrs) {
|
||||||
var treeView = new TreeView(),
|
var treeView = new TreeView(gestureService),
|
||||||
expr = $parse(attrs.mctModel),
|
expr = $parse(attrs.mctModel),
|
||||||
unobserve = treeView.observe(function (domainObject) {
|
unobserve = treeView.observe(function (domainObject) {
|
||||||
if (domainObject !== expr(scope.$parent)) {
|
if (domainObject !== expr(scope.$parent)) {
|
||||||
|
@ -27,8 +27,9 @@ define([
|
|||||||
], function ($, labelTemplate) {
|
], function ($, labelTemplate) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function TreeLabelView() {
|
function TreeLabelView(gestureService) {
|
||||||
this.el = $(labelTemplate);
|
this.el = $(labelTemplate);
|
||||||
|
this.gestureService = gestureService;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGlyph(domainObject) {
|
function getGlyph(domainObject) {
|
||||||
@ -62,11 +63,22 @@ define([
|
|||||||
delete this.unlisten;
|
delete this.unlisten;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.activeGestures) {
|
||||||
|
this.activeGestures.destroy();
|
||||||
|
delete this.activeGestures;
|
||||||
|
}
|
||||||
|
|
||||||
this.updateView(domainObject);
|
this.updateView(domainObject);
|
||||||
|
|
||||||
if (domainObject) {
|
if (domainObject) {
|
||||||
this.unlisten = domainObject.getCapability('mutation')
|
this.unlisten = domainObject.getCapability('mutation')
|
||||||
.listen(this.updateView.bind(this, domainObject));
|
.listen(this.updateView.bind(this, domainObject));
|
||||||
|
|
||||||
|
this.activeGestures = this.gestureService.attachGestures(
|
||||||
|
this.elements(),
|
||||||
|
domainObject,
|
||||||
|
[ 'info', 'menu', 'drag' ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ define([
|
|||||||
], function ($, nodeTemplate, ToggleView, TreeLabelView) {
|
], function ($, nodeTemplate, ToggleView, TreeLabelView) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function TreeNodeView(subtreeFactory, selectFn) {
|
function TreeNodeView(gestureService, subtreeFactory, selectFn) {
|
||||||
this.li = $('<li>');
|
this.li = $('<li>');
|
||||||
|
|
||||||
this.toggleView = new ToggleView(false);
|
this.toggleView = new ToggleView(false);
|
||||||
@ -47,7 +47,7 @@ define([
|
|||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
this.labelView = new TreeLabelView();
|
this.labelView = new TreeLabelView(gestureService);
|
||||||
|
|
||||||
$(this.labelView.elements()).on('click', function () {
|
$(this.labelView.elements()).on('click', function () {
|
||||||
selectFn(this.activeObject);
|
selectFn(this.activeObject);
|
||||||
|
@ -27,22 +27,24 @@ define([
|
|||||||
], function ($, TreeNodeView) {
|
], function ($, TreeNodeView) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function TreeView(selectFn) {
|
function TreeView(gestureService, selectFn) {
|
||||||
this.ul = $('<ul class="tree"></ul>');
|
this.ul = $('<ul class="tree"></ul>');
|
||||||
this.nodeViews = [];
|
this.nodeViews = [];
|
||||||
this.callbacks = [];
|
this.callbacks = [];
|
||||||
this.selectFn = selectFn || this.value.bind(this);
|
this.selectFn = selectFn || this.value.bind(this);
|
||||||
|
this.gestureService = gestureService;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeView.prototype.newTreeView = function () {
|
TreeView.prototype.newTreeView = function () {
|
||||||
return new TreeView(this.selectFn);
|
return new TreeView(this.gestureService, this.selectFn);
|
||||||
}
|
};
|
||||||
|
|
||||||
TreeView.prototype.setSize = function (sz) {
|
TreeView.prototype.setSize = function (sz) {
|
||||||
var nodeView;
|
var nodeView;
|
||||||
|
|
||||||
while (this.nodeViews.length < sz) {
|
while (this.nodeViews.length < sz) {
|
||||||
nodeView = new TreeNodeView(
|
nodeView = new TreeNodeView(
|
||||||
|
this.gestureService,
|
||||||
this.newTreeView.bind(this),
|
this.newTreeView.bind(this),
|
||||||
this.selectFn
|
this.selectFn
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user