Skip to content

Commit 2903d28

Browse files
author
Stanislav Kalashnik
committed
update docs and comments
1 parent 7661c04 commit 2903d28

File tree

6 files changed

+58
-27
lines changed

6 files changed

+58
-27
lines changed

app/js/component.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,10 @@ function Component ( config ) {
117117

118118
// outer handle
119119
if ( config.$node !== undefined ) {
120-
121120
if ( DEBUG ) {
122121
if ( !(config.$node instanceof Element) ) { throw 'wrong config.$node type'; }
123122
}
124-
123+
// apply
125124
this.$node = config.$node;
126125
} else {
127126
// empty div in case nothing is given
@@ -133,7 +132,7 @@ function Component ( config ) {
133132
if ( DEBUG ) {
134133
if ( !(config.$body instanceof Element) ) { throw 'wrong config.$body type'; }
135134
}
136-
135+
// apply
137136
this.$body = config.$body;
138137
} else {
139138
// inner and outer handlers are identical
@@ -145,7 +144,7 @@ function Component ( config ) {
145144
if ( DEBUG ) {
146145
if ( !(config.$content instanceof Element) ) { throw 'wrong config.$content type'; }
147146
}
148-
147+
// apply
149148
this.$body.appendChild(config.$content);
150149
}
151150

@@ -157,7 +156,7 @@ function Component ( config ) {
157156
if ( DEBUG ) {
158157
if ( !(config.parent instanceof Component) ) { throw 'wrong config.parent type'; }
159158
}
160-
159+
// apply
161160
config.parent.add(this);
162161
}
163162

@@ -166,7 +165,7 @@ function Component ( config ) {
166165
// if ( DEBUG ) {
167166
// if ( !(config.page instanceof Component) ) { throw 'wrong config.page type'; }
168167
// }
169-
//
168+
// // apply
170169
// this.page = config.page;
171170
//}
172171

@@ -195,7 +194,7 @@ function Component ( config ) {
195194
if ( DEBUG ) {
196195
if ( !Array.isArray(config.children) ) { throw 'wrong config.children type'; }
197196
}
198-
197+
// apply
199198
this.add.apply(this, config.children);
200199
}
201200

@@ -244,6 +243,10 @@ function Component ( config ) {
244243
this.$node.title = 'component ' + this.constructor.name + '.' + this.id + ' (outer)';
245244
this.$body.title = 'component ' + this.constructor.name + '.' + this.id + ' (inner)';
246245
}
246+
247+
// @todo remove or implement
248+
// navigation by keyboard
249+
//this.addListener('keydown', this.navigateDefault);
247250
}
248251

249252

@@ -252,6 +255,37 @@ Component.prototype = Object.create(Emitter.prototype);
252255
Component.prototype.constructor = Component;
253256

254257

258+
/**
259+
* Default method to move focus according to pressed keys.
260+
*
261+
* @todo remove or implement
262+
*
263+
* @param {Event} event generated event source of movement
264+
*/
265+
/*Component.prototype.navigateDefault = function ( event ) {
266+
switch ( event.code ) {
267+
case keys.up:
268+
case keys.down:
269+
case keys.right:
270+
case keys.left:
271+
// notify listeners
272+
this.emit('overflow');
273+
break;
274+
}
275+
};*/
276+
277+
278+
/**
279+
* Current active method to move focus according to pressed keys.
280+
* Can be redefined to provide custom navigation.
281+
*
282+
* @todo remove or implement
283+
*
284+
* @type {function}
285+
*/
286+
/*Component.prototype.navigate = Component.prototype.navigateDefault;*/
287+
288+
255289
/**
256290
* Add a new component as a child.
257291
*

app/js/ui/grid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function Grid ( config ) {
136136
if ( DEBUG ) {
137137
if ( typeof config.navigate !== 'function' ) { throw 'wrong config.navigate type'; }
138138
}
139-
139+
// apply
140140
this.navigate = config.navigate;
141141
}
142142

app/js/ui/input.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function Input ( config ) {
103103
if ( DEBUG ) {
104104
if ( typeof config.navigate !== 'function' ) { throw 'wrong config.navigate type'; }
105105
}
106-
106+
// apply
107107
this.navigate = config.navigate;
108108
}
109109

@@ -185,7 +185,7 @@ Input.prototype.init = function ( config ) {
185185
if ( Number(config.type) !== config.type ) { throw 'config.type must be a number'; }
186186
if ( config.type !== this.TYPE_TEXT && config.type !== this.TYPE_PASSWORD ) { throw 'config.type must be one of the TYPE_* constant'; }
187187
}
188-
188+
// apply
189189
this.type = config.type;
190190
}
191191

@@ -194,7 +194,7 @@ Input.prototype.init = function ( config ) {
194194
if ( DEBUG ) {
195195
if ( typeof config.value !== 'string' ) { throw 'config.value must be a string'; }
196196
}
197-
197+
// apply
198198
this.setValue(config.value);
199199
}
200200

@@ -204,8 +204,7 @@ Input.prototype.init = function ( config ) {
204204
if ( typeof config.placeholder !== 'string' ) { throw 'config.placeholder must be a string'; }
205205
if ( config.placeholder.length === 0 ) { throw 'config.placeholder must be not an empty string'; }
206206
}
207-
208-
// apply placeholder
207+
// apply
209208
this.$placeholder.innerText = config.placeholder;
210209
}
211210
};

app/js/ui/list.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function List ( config ) {
108108
if ( DEBUG ) {
109109
if ( Number(config.type) !== config.type ) { throw 'config.type must be a number'; }
110110
}
111-
111+
// apply
112112
this.type = config.type;
113113
}
114114

@@ -127,7 +127,7 @@ function List ( config ) {
127127
if ( DEBUG ) {
128128
if ( typeof config.navigate !== 'function' ) { throw 'wrong config.navigate type'; }
129129
}
130-
130+
// apply
131131
this.navigate = config.navigate;
132132
}
133133

@@ -299,7 +299,6 @@ List.prototype.init = function ( config ) {
299299
if ( DEBUG ) {
300300
if ( !Array.isArray(config.data) ) { throw 'wrong config.data type'; }
301301
}
302-
303302
// prepare user data
304303
this.data = normalize(config.data);
305304
}
@@ -309,7 +308,7 @@ List.prototype.init = function ( config ) {
309308
if ( DEBUG ) {
310309
if ( typeof config.render !== 'function' ) { throw 'wrong config.render type'; }
311310
}
312-
311+
// apply
313312
this.renderItem = config.render;
314313
}
315314

@@ -319,7 +318,7 @@ List.prototype.init = function ( config ) {
319318
if ( Number(config.size) !== config.size ) { throw 'config.size must be a number'; }
320319
if ( config.size <= 0 ) { throw 'config.size should be positive'; }
321320
}
322-
321+
// apply
323322
this.size = config.size;
324323
}
325324

app/js/ui/progress.bar.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,45 +161,44 @@ ProgressBar.prototype.set = function ( value ) {
161161
/**
162162
* Init or re-init current max or/and min or/and value.
163163
*
164-
* @param {Object} config init parameters
165-
* @param {number} [config.value=0] initial value
166-
* @param {number} [config.max=100] max progress value
167-
* @param {number} [config.min=0] min progress value
164+
* @param {Object} config init parameters (subset of constructor config params)
168165
*/
169166
ProgressBar.prototype.init = function ( config ) {
170167
if ( DEBUG ) {
171168
if ( arguments.length !== 1 ) { throw 'wrong arguments number'; }
172169
if ( typeof config !== 'object' ) { throw 'wrong config type'; }
173170
}
174171

175-
// assignment of configuration parameters if they were transferred
172+
// set max progress value
176173
if ( config.max !== undefined ) {
177174
if ( DEBUG ) {
178175
if ( Number(config.max) !== config.max ) { throw 'config.max value must be a number'; }
179176
}
180-
177+
// apply
181178
this.max = config.max;
182179
}
183180

181+
// set min progress value
184182
if ( config.min !== undefined ) {
185183
if ( DEBUG ) {
186184
if ( Number(config.min) !== config.min ) { throw 'config.min value must be a number'; }
187185
}
188-
186+
// apply
189187
this.min = config.min;
190188
}
191189

192190
if ( DEBUG ) {
193191
if ( this.min >= this.max ) { throw 'this.min value must be less than this.max'; }
194192
}
195193

194+
// set actual progress value
196195
if ( config.value !== undefined ) {
197196
if ( DEBUG ) {
198197
if ( Number(config.value) !== config.value ) { throw 'config.value must be a number'; }
199198
if ( config.value > this.max ) { throw 'config.value more than config.maximum'; }
200199
if ( config.value < this.min ) { throw 'config.value less than config.minimum'; }
201200
}
202-
201+
// apply
203202
this.value = config.value;
204203
}
205204

app/js/ui/scroll.bar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function ScrollBar ( config ) {
9898
if ( DEBUG ) {
9999
if ( Number(config.type) !== config.type ) { throw 'config.type must be a number'; }
100100
}
101-
101+
// apply
102102
this.type = config.type;
103103
}
104104

0 commit comments

Comments
 (0)