Committed by
Gerrit Code Review
GUI -- Renamed 'preload' callback function to be 'init'; a better name, I feel.
Change-Id: I96d0892c0d78b1ac50044f57669bd84146808018
Showing
5 changed files
with
23 additions
and
24 deletions
... | @@ -28,7 +28,7 @@ | ... | @@ -28,7 +28,7 @@ |
28 | 28 | ||
29 | // invoked only the first time the view is loaded | 29 | // invoked only the first time the view is loaded |
30 | // - used to initialize the view contents | 30 | // - used to initialize the view contents |
31 | - function preload(view, ctx, flags) { | 31 | + function init(view, ctx, flags) { |
32 | // NOTE: view.$div is a D3 selection of the view's div | 32 | // NOTE: view.$div is a D3 selection of the view's div |
33 | list = view.$div.append('ul'); | 33 | list = view.$div.append('ul'); |
34 | // ... further code to initialize the SVG view ... | 34 | // ... further code to initialize the SVG view ... |
... | @@ -80,7 +80,7 @@ | ... | @@ -80,7 +80,7 @@ |
80 | // load and resize events would look like this: | 80 | // load and resize events would look like this: |
81 | 81 | ||
82 | onos.ui.addView('myDivViewId', { | 82 | onos.ui.addView('myDivViewId', { |
83 | - preload: preload, | 83 | + init: init, |
84 | load: load, | 84 | load: load, |
85 | resize: resize | 85 | resize: resize |
86 | }); | 86 | }); |
... | @@ -96,7 +96,7 @@ | ... | @@ -96,7 +96,7 @@ |
96 | // The complete gamut of callbacks would look like this: | 96 | // The complete gamut of callbacks would look like this: |
97 | // | 97 | // |
98 | // onos.ui.addView('myViewId', { | 98 | // onos.ui.addView('myViewId', { |
99 | - // preload: preload, | 99 | + // init: init, |
100 | // reset: reset, | 100 | // reset: reset, |
101 | // load: load, | 101 | // load: load, |
102 | // unload: unload, | 102 | // unload: unload, | ... | ... |
... | @@ -28,7 +28,7 @@ | ... | @@ -28,7 +28,7 @@ |
28 | 28 | ||
29 | // invoked only the first time the view is loaded | 29 | // invoked only the first time the view is loaded |
30 | // - used to initialize the view contents | 30 | // - used to initialize the view contents |
31 | - function preload(view, ctx, flags) { | 31 | + function init(view, ctx, flags) { |
32 | svg = view.$div.append('svg'); | 32 | svg = view.$div.append('svg'); |
33 | resize(view); | 33 | resize(view); |
34 | // ... further code to initialize the SVG view ... | 34 | // ... further code to initialize the SVG view ... |
... | @@ -110,7 +110,7 @@ | ... | @@ -110,7 +110,7 @@ |
110 | // load and resize events would look like this: | 110 | // load and resize events would look like this: |
111 | 111 | ||
112 | onos.ui.addView('mySvgViewId', { | 112 | onos.ui.addView('mySvgViewId', { |
113 | - preload: preload, | 113 | + init: init, |
114 | load: load, | 114 | load: load, |
115 | resize: resize | 115 | resize: resize |
116 | }); | 116 | }); |
... | @@ -126,7 +126,7 @@ | ... | @@ -126,7 +126,7 @@ |
126 | // The complete gamut of callbacks would look like this: | 126 | // The complete gamut of callbacks would look like this: |
127 | // | 127 | // |
128 | // onos.ui.addView('myViewId', { | 128 | // onos.ui.addView('myViewId', { |
129 | - // preload: preload, | 129 | + // init: init, |
130 | // reset: reset, | 130 | // reset: reset, |
131 | // load: load, | 131 | // load: load, |
132 | // unload: unload, | 132 | // unload: unload, | ... | ... |
... | @@ -331,10 +331,10 @@ | ... | @@ -331,10 +331,10 @@ |
331 | current.ctx = t.ctx || ''; | 331 | current.ctx = t.ctx || ''; |
332 | current.flags = t.flags || {}; | 332 | current.flags = t.flags || {}; |
333 | 333 | ||
334 | - // preload is called only once, after the view is in the DOM | 334 | + // init is called only once, after the view is in the DOM |
335 | - if (!view.preloaded) { | 335 | + if (!view.inited) { |
336 | - view.preload(current.ctx, current.flags); | 336 | + view.init(current.ctx, current.flags); |
337 | - view.preloaded = true; | 337 | + view.inited = true; |
338 | } | 338 | } |
339 | 339 | ||
340 | // clear the view of stale data | 340 | // clear the view of stale data |
... | @@ -569,7 +569,7 @@ | ... | @@ -569,7 +569,7 @@ |
569 | // Constructor | 569 | // Constructor |
570 | // vid : view id | 570 | // vid : view id |
571 | // nid : id of associated nav-item (optional) | 571 | // nid : id of associated nav-item (optional) |
572 | - // cb : callbacks (preload, reset, load, unload, resize, error) | 572 | + // cb : callbacks (init, reset, load, unload, resize, theme, error) |
573 | function View(vid) { | 573 | function View(vid) { |
574 | var av = 'addView(): ', | 574 | var av = 'addView(): ', |
575 | args = Array.prototype.slice.call(arguments), | 575 | args = Array.prototype.slice.call(arguments), |
... | @@ -630,12 +630,12 @@ | ... | @@ -630,12 +630,12 @@ |
630 | 630 | ||
631 | // == Life-cycle functions | 631 | // == Life-cycle functions |
632 | // TODO: factor common code out of life-cycle | 632 | // TODO: factor common code out of life-cycle |
633 | - preload: function (ctx, flags) { | 633 | + init: function (ctx, flags) { |
634 | var c = ctx || '', | 634 | var c = ctx || '', |
635 | - fn = isF(this.cb.preload); | 635 | + fn = isF(this.cb.init); |
636 | - traceFn('View.preload', this.vid + ', ' + c); | 636 | + traceFn('View.init', this.vid + ', ' + c); |
637 | if (fn) { | 637 | if (fn) { |
638 | - trace('PRELOAD cb for ' + this.vid); | 638 | + trace('INIT cb for ' + this.vid); |
639 | fn(this.token(), c, flags); | 639 | fn(this.token(), c, flags); |
640 | } | 640 | } |
641 | }, | 641 | }, |
... | @@ -771,7 +771,6 @@ | ... | @@ -771,7 +771,6 @@ |
771 | var fpConfig = { | 771 | var fpConfig = { |
772 | TR: { | 772 | TR: { |
773 | side: 'right' | 773 | side: 'right' |
774 | - | ||
775 | }, | 774 | }, |
776 | TL: { | 775 | TL: { |
777 | side: 'left' | 776 | side: 'left' |
... | @@ -891,7 +890,7 @@ | ... | @@ -891,7 +890,7 @@ |
891 | * the framework can infer it. | 890 | * the framework can infer it. |
892 | * <p> | 891 | * <p> |
893 | * <i>cb</i> is a plain object containing callback functions: | 892 | * <i>cb</i> is a plain object containing callback functions: |
894 | - * "preload", "reset", "load", "unload", "resize", "error". | 893 | + * "init", "reset", "load", "unload", "resize", "theme", "error". |
895 | * <pre> | 894 | * <pre> |
896 | * function myLoad(view, ctx) { ... } | 895 | * function myLoad(view, ctx) { ... } |
897 | * ... | 896 | * ... | ... | ... |
... | @@ -49,7 +49,7 @@ | ... | @@ -49,7 +49,7 @@ |
49 | } | 49 | } |
50 | 50 | ||
51 | // gets invoked only the first time the view is loaded | 51 | // gets invoked only the first time the view is loaded |
52 | - function preload(view, ctx) { | 52 | + function init(view, ctx, flags) { |
53 | // prepare our SVG layer... | 53 | // prepare our SVG layer... |
54 | svg = view.$div.append('svg'); | 54 | svg = view.$div.append('svg'); |
55 | sizeSvg(view); | 55 | sizeSvg(view); |
... | @@ -57,7 +57,7 @@ | ... | @@ -57,7 +57,7 @@ |
57 | } | 57 | } |
58 | 58 | ||
59 | // gets invoked just before our view is loaded | 59 | // gets invoked just before our view is loaded |
60 | - function reset(view) { | 60 | + function reset(view, ctx, flags) { |
61 | // clear dot group and reset circle data | 61 | // clear dot group and reset circle data |
62 | dotG.html(''); | 62 | dotG.html(''); |
63 | circleData = []; | 63 | circleData = []; |
... | @@ -177,7 +177,7 @@ | ... | @@ -177,7 +177,7 @@ |
177 | .remove(); | 177 | .remove(); |
178 | } | 178 | } |
179 | 179 | ||
180 | - function load(view, ctx) { | 180 | + function load(view, ctx, flags) { |
181 | var ctxText = ctx ? 'Context is "' + ctx + '"' : ''; | 181 | var ctxText = ctx ? 'Context is "' + ctx + '"' : ''; |
182 | 182 | ||
183 | // display our view context | 183 | // display our view context |
... | @@ -197,7 +197,7 @@ | ... | @@ -197,7 +197,7 @@ |
197 | doCircles(view); | 197 | doCircles(view); |
198 | } | 198 | } |
199 | 199 | ||
200 | - function resize(view, ctx) { | 200 | + function resize(view, ctx, flags) { |
201 | sizeSvg(view); | 201 | sizeSvg(view); |
202 | updateCirclePositions(view); | 202 | updateCirclePositions(view); |
203 | 203 | ||
... | @@ -213,7 +213,7 @@ | ... | @@ -213,7 +213,7 @@ |
213 | // == register our view here, with links to lifecycle callbacks | 213 | // == register our view here, with links to lifecycle callbacks |
214 | 214 | ||
215 | onos.ui.addView('sample', { | 215 | onos.ui.addView('sample', { |
216 | - preload: preload, | 216 | + init: init, |
217 | reset: reset, | 217 | reset: reset, |
218 | load: load, | 218 | load: load, |
219 | resize: resize | 219 | resize: resize | ... | ... |
... | @@ -2862,7 +2862,7 @@ | ... | @@ -2862,7 +2862,7 @@ |
2862 | // ============================== | 2862 | // ============================== |
2863 | // View life-cycle callbacks | 2863 | // View life-cycle callbacks |
2864 | 2864 | ||
2865 | - function preload(view, ctx, flags) { | 2865 | + function init(view, ctx, flags) { |
2866 | var w = view.width(), | 2866 | var w = view.width(), |
2867 | h = view.height(), | 2867 | h = view.height(), |
2868 | fcfg = config.force; | 2868 | fcfg = config.force; |
... | @@ -3161,7 +3161,7 @@ | ... | @@ -3161,7 +3161,7 @@ |
3161 | // View registration | 3161 | // View registration |
3162 | 3162 | ||
3163 | onos.ui.addView('topo', { | 3163 | onos.ui.addView('topo', { |
3164 | - preload: preload, | 3164 | + init: init, |
3165 | load: load, | 3165 | load: load, |
3166 | unload: unload, | 3166 | unload: unload, |
3167 | resize: resize, | 3167 | resize: resize, | ... | ... |
-
Please register or login to post a comment