Content-Length: 607627 | pFad | http://github.com/sendilkumarj/cocos2d-html5/commit/13fdf2275afb8ae61761dbeb5267bf793ef2270f

38 issue #3419 add comment for listView · sendilkumarj/cocos2d-html5@13fdf22 · GitHub
Skip to content

Commit 13fdf22

Browse files
committed
issue cocos2d#3419 add comment for listView
1 parent f2614c9 commit 13fdf22

File tree

1 file changed

+81
-2
lines changed

1 file changed

+81
-2
lines changed

extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIListView.js

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@
2222
THE SOFTWARE.
2323
****************************************************************************/
2424

25+
/**
26+
* listView event type
27+
* @type {Object}
28+
*/
2529
ccs.ListViewEventType = {
2630
listViewOnselectedItem: 0
2731
};
2832

33+
/**
34+
* listView gravity
35+
* @type {Object}
36+
*/
2937
ccs.ListViewGravity = {
3038
left: 0,
3139
right: 1,
@@ -35,6 +43,11 @@ ccs.ListViewGravity = {
3543
centerVertical: 5
3644
};
3745

46+
/**
47+
* Base class for ccs.ListView
48+
* @class
49+
* @extends ccs.ScrollView
50+
*/
3851
ccs.ListView = ccs.ScrollView.extend({
3952
_model: null,
4053
_items: null,
@@ -65,12 +78,15 @@ ccs.ListView = ccs.ScrollView.extend({
6578
return false;
6679
},
6780

81+
/**
82+
* Sets a item model for listview. A model will be cloned for adding default item.
83+
* @param {ccs.Widget} model
84+
*/
6885
setItemModel: function (model) {
6986
if (!model) {
7087
return;
7188
}
7289
this._model = model;
73-
7490
},
7591

7692
updateInnerContainerSize: function () {
@@ -206,6 +222,9 @@ ccs.ListView = ccs.ScrollView.extend({
206222
}
207223
},
208224

225+
/**
226+
* Push back a default item(create by a cloned model) into listview.
227+
*/
209228
pushBackDefaultItem: function () {
210229
if (!this._model) {
211230
return;
@@ -217,6 +236,10 @@ ccs.ListView = ccs.ScrollView.extend({
217236
this._refreshViewDirty = true;
218237
},
219238

239+
/**
240+
* Insert a default item(create by a cloned model) into listview.
241+
* @param {Number} index
242+
*/
220243
insertDefaultItem: function (index) {
221244
if (!this._model) {
222245
return;
@@ -228,20 +251,33 @@ ccs.ListView = ccs.ScrollView.extend({
228251
this._refreshViewDirty = true;
229252
},
230253

254+
/**
255+
* Push back custom item into listview.
256+
* @param {ccs.Widget} item
257+
*/
231258
pushBackCustomItem: function (item) {
232259
this._items.push(item);
233260
this.remedyLayoutParameter(item);
234261
this.addChild(item);
235262
this._refreshViewDirty = true;
236263
},
237264

265+
/**
266+
* Push back custom item into listview.
267+
* @param {ccs.Widget} item
268+
* @param {Number} index
269+
*/
238270
insertCustomItem: function (item, index) {
239271
cc.ArrayAppendObjectToIndex(this._items, item, index);
240272
this.remedyLayoutParameter(item);
241273
this.addChild(item);
242274
this._refreshViewDirty = true;
243275
},
244276

277+
/**
278+
* Removes a item whose index is same as the parameter.
279+
* @param {Number} index
280+
*/
245281
removeItem: function (index) {
246282
var item = this.getItem(index);
247283
if (!item) {
@@ -252,25 +288,46 @@ ccs.ListView = ccs.ScrollView.extend({
252288
this._refreshViewDirty = true;
253289
},
254290

291+
/**
292+
* Removes the last item of listview.
293+
*/
255294
removeLastItem: function () {
256295
this.removeItem(this._items.length - 1);
257296
},
258297

298+
/**
299+
* Returns a item whose index is same as the parameter.
300+
* @param {Number} index
301+
* @returns {cc.Widget}
302+
*/
259303
getItem: function (index) {
260304
if (index < 0 || index >= this._items.length) {
261305
return null;
262306
}
263307
return this._items[index];
264308
},
265309

310+
/**
311+
* Returns the item container.
312+
* @returns {Array}
313+
*/
266314
getItems: function () {
267315
return this._items;
268316
},
269317

318+
/**
319+
* Returns the index of item.
320+
* @param {ccs.Widget} item
321+
* @returns {Number}
322+
*/
270323
getIndex: function (item) {
271324
return cc.ArrayGetIndexOfObject(this._items, item);
272325
},
273326

327+
/**
328+
* Changes the gravity of listview.
329+
* @param {ccs.ListViewGravity} gravity
330+
*/
274331
setGravity: function (gravity) {
275332
if (this._gravity == gravity) {
276333
return;
@@ -279,6 +336,10 @@ ccs.ListView = ccs.ScrollView.extend({
279336
this._refreshViewDirty = true;
280337
},
281338

339+
/**
340+
* Changes the margin between each item.
341+
* @param {Number} margin
342+
*/
282343
setItemsMargin: function (margin) {
283344
if (this._itemsMargin == margin) {
284345
return;
@@ -287,6 +348,10 @@ ccs.ListView = ccs.ScrollView.extend({
287348
this._refreshViewDirty = true;
288349
},
289350

351+
/**
352+
* Changes scroll direction of scrollview.
353+
* @param {ccs.ScrollViewDir } dir
354+
*/
290355
setDirection: function (dir) {
291356
switch (dir) {
292357
case ccs.ScrollViewDir.vertical:
@@ -305,6 +370,11 @@ ccs.ListView = ccs.ScrollView.extend({
305370

306371
},
307372

373+
/**
374+
* add event listener
375+
* @param {Function} selector
376+
* @param {Object} target
377+
*/
308378
addEventListenerListView: function (selector, target) {
309379
this._listViewEventListener = target;
310380
this._listViewEventSelector = selector;
@@ -331,6 +401,10 @@ ccs.ListView = ccs.ScrollView.extend({
331401
}
332402
},
333403

404+
/**
405+
* get current selected index
406+
* @returns {number}
407+
*/
334408
getCurSelectedIndex: function () {
335409
return this._curSelectedIndex;
336410
},
@@ -363,8 +437,13 @@ ccs.ListView = ccs.ScrollView.extend({
363437
ccs.ScrollView.prototype.onSizeChanged.call(this);
364438
this._refreshViewDirty = true;
365439
},
440+
441+
/**
442+
* Returns the "class name" of widget.
443+
* @returns {string}
444+
*/
366445
getDescription: function () {
367-
return "ListViewEx";
446+
return "ListView";
368447
},
369448

370449
createCloneInstance: function () {

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/sendilkumarj/cocos2d-html5/commit/13fdf2275afb8ae61761dbeb5267bf793ef2270f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy