Compare commits

...

7 Commits

Author SHA1 Message Date
fe3be17a21 Add Region 2016-05-24 16:36:38 -07:00
56eef16571 Remove empty jsdoc tag 2016-05-24 16:30:33 -07:00
1d1c110dd7 Document view API 2016-05-24 16:30:06 -07:00
d031767ff6 Begin adding View 2016-05-13 16:11:49 -07:00
e98ab5eb97 More WIP 2016-05-13 15:59:46 -07:00
544a7962a1 WIP again 2016-05-13 15:55:21 -07:00
c5d00345ba WIP 2016-05-10 14:47:38 -07:00
7 changed files with 216 additions and 8 deletions

View File

@ -34,7 +34,7 @@
'./example/imagery/bundle', './example/imagery/bundle',
'./example/eventGenerator/bundle', './example/eventGenerator/bundle',
'./example/generator/bundle' './example/generator/bundle'
], mct.run.bind(mct)); ], mct.start.bind(mct));
}); });
</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">

View File

@ -1,9 +1,9 @@
{ {
"source": { "source": {
"include": [ "include": [
"platform/" "src/"
], ],
"includePattern": "platform/.+\\.js$", "includePattern": ".+\\.js$",
"excludePattern": ".+\\Spec\\.js$|lib/.+" "excludePattern": ".+\\Spec\\.js$|lib/.+"
}, },
"plugins": [ "plugins": [

15
main.js
View File

@ -56,6 +56,7 @@ requirejs.config({
}); });
define([ define([
'./src/MCT',
'./platform/framework/src/Main', './platform/framework/src/Main',
'legacyRegistry', 'legacyRegistry',
@ -94,10 +95,14 @@ define([
'./platform/status/bundle', './platform/status/bundle',
'./platform/commonUI/regions/bundle' './platform/commonUI/regions/bundle'
], function (Main, legacyRegistry) { ], function (Main, legacyRegistry) {
return { var base = new MCT();
legacyRegistry: legacyRegistry, var mct = Object.create(base);
run: function () {
return new Main().run(legacyRegistry); mct.legacyRegistry = legacyRegistry;
} mct.start = function () {
base.start();
return new Main().run(legacyRegistry);
}; };
return mct;
}); });

70
src/MCT.js Normal file
View File

@ -0,0 +1,70 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web 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 Web 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(function () {
/**
* This is the namespace for MCT.
* @namespace mct
* @type {MCT}
*/
/**
* The Open MCT application itself. In order to extend its functionality,
* extensions may be installed to MCT before it is run.
*
* The {@link mct} namespace is itself an instance of the MCT object.
*
* @constructor
* @memberof mct
*/
function MCT() {
}
/**
* Register a new type of domain object.
* @param type
*/
MCT.prototype.type = function (type) {
};
/**
* Get all currently registered types.
*/
MCT.prototype.types = function () {
};
MCT.prototype.namespace = function (namespace) {
};
/**
* Start running Open MCT in its current configuration.
*/
MCT.prototype.start = function () {
};
return MCT;
});

38
src/Region.js Normal file
View File

@ -0,0 +1,38 @@
define(['zepto'], function ($) {
/**
* A Region represents a location within the user interface where
* views can be displayed.
* @param {HTMLElement} container the HTML element which will contain nodes
* @constructor
* @memberof mct
*/
function Region(container) {
this.container = $(container);
}
/**
* Show a view in this region.
* @param {mct.View} view the view to show
*/
Region.prototype.show = function (view) {
if (this.activeView) {
this.activeView.deactivate();
}
this.activeView = view;
this.container.empty();
if (view) {
view.activate();
this.container.append($(view.elements()));
}
};
/**
* Stop showing any view in this region.
*/
Region.prototype.clear = function () {
this.show(undefined);
};
return Region;
});

29
src/Type.js Normal file
View File

@ -0,0 +1,29 @@
define(function () {
function Type(name, metadata, baseTypes) {
this.baseTypes = baseTypes;
this.typeName = name;
this.typeMetadata = metadata;
}
Type.prototype.name = function () {
return this.typeName;
};
Type.prototype.metadata = function () {
return this.typeMetadata;
};
Type.prototype.objectify = function (model, id) {
};
Type.prototype.representer = function (factory, region) {
};
Type.prototype.action = function (factory, context) {
};
return Type;
});

66
src/View.js Normal file
View File

@ -0,0 +1,66 @@
define(function () {
/**
* A View describes a set of DOM elements
*
* When parameterized as a type, the type parameter refers to the
* type used for models of this view.
*
* @param model
* @constructor
* @memberof mct
*/
function View(model) {
this.currentModel = model;
this.active = false;
}
/**
* Prepare this view for display. This should be called before a view
* is added to the DOM.
*/
View.prototype.activate = function () {
this.active = false;
};
/**
* Prepare this view for display. This should be called before a view
* is added to the DOM.
*/
View.prototype.deactivate = function () {
this.active = true;
};
/**
* Get the HTML elements that this view consists of.
*
* A View will typically maintain these elements and keep them up to date.
* In cases where a view needs to change the elements being displayed,
* it should emit a `elements` event.
*
* @returns {Array.<HTMLElement>} the HTML elements that comprise this view
*/
View.prototype.elements = function () {
return [];
};
/**
* Change the model for this view.
* @param {*} model the model to display
* @returns {*} the model being displayed
*/
View.prototype.model = function (model) {
if (arguments.length > 0) {
if (this.active) {
this.deactivate();
this.currentModel = model;
this.activate();
} else {
this.currentModel = model;
}
}
return this.currentModel;
};
return View;
});