[Common UI] Reorganize general UI bundle

Reorganize sources for bundle platform/commonUI/general;
number of classes here has grown as a consequence of
additions for WTD-614 and so an additional layer of
organization is helpful.

Conflicts:
	platform/commonUI/general/bundle.json
	platform/commonUI/general/src/directives/MCTResize.js
This commit is contained in:
Victor Woeltjen 2014-12-30 13:34:24 -08:00
parent 8dfee64dc8
commit 112622ab9f
12 changed files with 97 additions and 10 deletions

View File

@ -24,54 +24,59 @@
"controllers": [
{
"key": "TreeNodeController",
"implementation": "TreeNodeController.js",
"implementation": "controllers/TreeNodeController.js",
"depends": [ "$scope", "$timeout" ]
},
{
"key": "ActionGroupController",
"implementation": "ActionGroupController.js",
"implementation": "controllers/ActionGroupController.js",
"depends": [ "$scope" ]
},
{
"key": "ToggleController",
"implementation": "ToggleController.js"
"implementation": "controllers/ToggleController.js"
},
{
"key": "ContextMenuController",
"implementation": "ContextMenuController.js",
"implementation": "controllers/ContextMenuController.js",
"depends": [ "$scope" ]
},
{
"key": "ClickAwayController",
"implementation": "ClickAwayController.js",
"implementation": "controllers/ClickAwayController.js",
"depends": [ "$scope", "$document" ]
},
{
"key": "ViewSwitcherController",
"implementation": "ViewSwitcherController.js",
"implementation": "controllers/ViewSwitcherController.js",
"depends": [ "$scope" ]
},
{
"key": "BottomBarController",
"implementation": "BottomBarController.js",
"implementation": "controllers/BottomBarController.js",
"depends": [ "indicators[]" ]
},
{
"key": "GetterSetterController",
"implementation": "GetterSetterController.js",
"implementation": "controllers/GetterSetterController.js",
"depends": [ "$scope" ]
}
],
"directives": [
{
"key": "mctContainer",
"implementation": "MCTContainer.js",
"implementation": "directives/MCTContainer.js",
"depends": [ "containers[]" ]
},
{
"key": "mctDrag",
"implementation": "MCTDrag.js",
"implementation": "directives/MCTDrag.js",
"depends": [ "$document" ]
},
{
"key": "mctResize",
"implementation": "directives/MCTResize.js",
"depends": [ "$timeout" ]
}
],
"containers": [

View File

@ -0,0 +1,82 @@
/*global define*/
define(
[],
function () {
"use strict";
// Default resize interval
var DEFAULT_INTERVAL = 100;
/**
* The mct-resize directive allows the size of a displayed
* HTML element to be tracked. This is done by polling,
* since the DOM API does not currently provide suitable
* events to watch this reliably.
*
* Attributes related to this directive are interpreted as
* follows:
*
* * `mct-resize`: An Angular expression to evaluate when
* the size changes; the variable `bounds` will be provided
* with two fields, `width` and `height`, both in pixels.
* * `mct-resize-interval`: Optional; the interval, in milliseconds,
* at which to watch for updates. In some cases checking for
* resize can carry a cost (it forces recalculation of
* positions within the document) so it may be preferable to watch
* infrequently. If omitted, a default of 100ms will be used.
* This is an Angular expression, and it will be re-evaluated after
* each interval.
*
* @constructor
*
*/
function MCTResize($timeout) {
// Link; start listening for changes to an element's size
function link(scope, element, attrs) {
var lastBounds;
// Determine how long to wait before the next update
function currentInterval() {
return attrs.mctResizeInterval ?
scope.$eval(attrs.mctResizeInterval) :
DEFAULT_INTERVAL;
}
// Evaluate mct-resize with the current bounds
function fireEval(bounds) {
// Only update when bounds actually change
if (!lastBounds ||
lastBounds.width !== bounds.width ||
lastBounds.height !== bounds.height) {
scope.$eval(attrs.mctResize, { bounds: bounds });
lastBounds = bounds;
}
}
// Callback to fire after each timeout;
// update bounds and schedule another timeout
function onInterval() {
fireEval({
width: element[0].offsetWidth,
height: element[0].offsetHeight
});
$timeout(onInterval, currentInterval());
}
// Handle the initial callback
onInterval();
}
return {
// mct-resize only makes sense as an attribute
restrict: "A",
// Link function, to begin watching for changes
link: link
};
}
return MCTResize;
}
);