Simon Hunt
Committed by Gerrit Code Review

GUI -- Renamed 'preload' callback function to be 'init'; a better name, I feel.

Change-Id: I96d0892c0d78b1ac50044f57669bd84146808018
......@@ -28,7 +28,7 @@
// invoked only the first time the view is loaded
// - used to initialize the view contents
function preload(view, ctx, flags) {
function init(view, ctx, flags) {
// NOTE: view.$div is a D3 selection of the view's div
list = view.$div.append('ul');
// ... further code to initialize the SVG view ...
......@@ -80,7 +80,7 @@
// load and resize events would look like this:
onos.ui.addView('myDivViewId', {
preload: preload,
init: init,
load: load,
resize: resize
});
......@@ -96,7 +96,7 @@
// The complete gamut of callbacks would look like this:
//
// onos.ui.addView('myViewId', {
// preload: preload,
// init: init,
// reset: reset,
// load: load,
// unload: unload,
......
......@@ -28,7 +28,7 @@
// invoked only the first time the view is loaded
// - used to initialize the view contents
function preload(view, ctx, flags) {
function init(view, ctx, flags) {
svg = view.$div.append('svg');
resize(view);
// ... further code to initialize the SVG view ...
......@@ -110,7 +110,7 @@
// load and resize events would look like this:
onos.ui.addView('mySvgViewId', {
preload: preload,
init: init,
load: load,
resize: resize
});
......@@ -126,7 +126,7 @@
// The complete gamut of callbacks would look like this:
//
// onos.ui.addView('myViewId', {
// preload: preload,
// init: init,
// reset: reset,
// load: load,
// unload: unload,
......
......@@ -331,10 +331,10 @@
current.ctx = t.ctx || '';
current.flags = t.flags || {};
// preload is called only once, after the view is in the DOM
if (!view.preloaded) {
view.preload(current.ctx, current.flags);
view.preloaded = true;
// init is called only once, after the view is in the DOM
if (!view.inited) {
view.init(current.ctx, current.flags);
view.inited = true;
}
// clear the view of stale data
......@@ -569,7 +569,7 @@
// Constructor
// vid : view id
// nid : id of associated nav-item (optional)
// cb : callbacks (preload, reset, load, unload, resize, error)
// cb : callbacks (init, reset, load, unload, resize, theme, error)
function View(vid) {
var av = 'addView(): ',
args = Array.prototype.slice.call(arguments),
......@@ -630,12 +630,12 @@
// == Life-cycle functions
// TODO: factor common code out of life-cycle
preload: function (ctx, flags) {
init: function (ctx, flags) {
var c = ctx || '',
fn = isF(this.cb.preload);
traceFn('View.preload', this.vid + ', ' + c);
fn = isF(this.cb.init);
traceFn('View.init', this.vid + ', ' + c);
if (fn) {
trace('PRELOAD cb for ' + this.vid);
trace('INIT cb for ' + this.vid);
fn(this.token(), c, flags);
}
},
......@@ -771,7 +771,6 @@
var fpConfig = {
TR: {
side: 'right'
},
TL: {
side: 'left'
......@@ -891,7 +890,7 @@
* the framework can infer it.
* <p>
* <i>cb</i> is a plain object containing callback functions:
* "preload", "reset", "load", "unload", "resize", "error".
* "init", "reset", "load", "unload", "resize", "theme", "error".
* <pre>
* function myLoad(view, ctx) { ... }
* ...
......
......@@ -49,7 +49,7 @@
}
// gets invoked only the first time the view is loaded
function preload(view, ctx) {
function init(view, ctx, flags) {
// prepare our SVG layer...
svg = view.$div.append('svg');
sizeSvg(view);
......@@ -57,7 +57,7 @@
}
// gets invoked just before our view is loaded
function reset(view) {
function reset(view, ctx, flags) {
// clear dot group and reset circle data
dotG.html('');
circleData = [];
......@@ -177,7 +177,7 @@
.remove();
}
function load(view, ctx) {
function load(view, ctx, flags) {
var ctxText = ctx ? 'Context is "' + ctx + '"' : '';
// display our view context
......@@ -197,7 +197,7 @@
doCircles(view);
}
function resize(view, ctx) {
function resize(view, ctx, flags) {
sizeSvg(view);
updateCirclePositions(view);
......@@ -213,7 +213,7 @@
// == register our view here, with links to lifecycle callbacks
onos.ui.addView('sample', {
preload: preload,
init: init,
reset: reset,
load: load,
resize: resize
......
......@@ -2862,7 +2862,7 @@
// ==============================
// View life-cycle callbacks
function preload(view, ctx, flags) {
function init(view, ctx, flags) {
var w = view.width(),
h = view.height(),
fcfg = config.force;
......@@ -3161,7 +3161,7 @@
// View registration
onos.ui.addView('topo', {
preload: preload,
init: init,
load: load,
unload: unload,
resize: resize,
......