@@ -460,7 +460,7 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{
460
460
/**
461
461
* @param {Number } s
462
462
*/
463
- setFontSizeObj :function ( s ) {
463
+ setFontSize :function ( s ) {
464
464
this . _fontSize = s ;
465
465
this . _recreateLabel ( ) ;
466
466
} ,
@@ -469,22 +469,22 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{
469
469
*
470
470
* @return {Number }
471
471
*/
472
- fontSizeObj :function ( ) {
472
+ fontSize :function ( ) {
473
473
return this . _fontSize ;
474
474
} ,
475
475
476
476
/**
477
477
* @param {String } name
478
478
*/
479
- setFontNameObj :function ( name ) {
479
+ setFontName :function ( name ) {
480
480
this . _fontName = name ;
481
481
this . _recreateLabel ( ) ;
482
482
} ,
483
483
484
484
/**
485
485
* @return {String }
486
486
*/
487
- fontNameObj :function ( ) {
487
+ fontName :function ( ) {
488
488
return this . _fontName ;
489
489
} ,
490
490
_recreateLabel :function ( ) {
@@ -1029,52 +1029,23 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{
1029
1029
} ,
1030
1030
1031
1031
/**
1032
- * @param {cc.Node } args[0] the first item in the args array is a target
1033
- * @param {function|String } args[1] the second item in the args array is the callback
1034
- * @param {cc.MenuItem } args[2+ ] the rest in the array are cc.MenuItems
1032
+ * @param {cc.MenuItem } args[0...last-2 ] the rest in the array are cc.MenuItems
1033
+ * @param {cc.Node } args[last- 1] the first item in the args array is a target
1034
+ * @param {function|String } args[last ] the second item in the args array is the callback
1035
1035
* @return {Boolean }
1036
1036
*/
1037
- initWithCallback :function ( args ) {
1038
- if ( args . length < 2 ) {
1039
- return false ;
1040
- }
1041
- var target = args [ 0 ] , selector = args [ 1 ] ;
1042
- this . _super ( target , selector ) ;
1043
- if ( args . length == 2 ) {
1044
- return false ;
1045
- }
1046
- this . _subItems = [ ] ;
1047
- for ( var i = 2 ; i < args . length ; i ++ ) {
1048
- if ( args [ i ] ) {
1049
- this . _subItems . push ( args [ i ] ) ;
1050
- }
1037
+ initWithItems :function ( args ) {
1038
+ var l = args . length ;
1039
+ // passing callback.
1040
+ if ( typeof args [ args . length - 1 ] === 'function' ) {
1041
+ this . initWithCallback ( args [ args . length - 2 ] , args [ args . length - 1 ] ) ;
1042
+ l = l - 2 ;
1051
1043
}
1052
- this . _selectedIndex = cc . UINT_MAX ;
1053
- this . setSelectedIndex ( 0 ) ;
1054
- return true ;
1055
- } ,
1044
+ else
1045
+ this . initWithCallback ( null , null ) ;
1056
1046
1057
- /**
1058
- * @param {cc.MenuItem } item
1059
- * @return {Boolean }
1060
- */
1061
- initWithItem :function ( item ) {
1062
- this . initWithCallback ( null , null ) ;
1063
1047
this . _subItems = [ ] ;
1064
- this . _subItems . push ( item ) ;
1065
- this . _selectedIndex = cc . UINT_MAX ;
1066
- this . setSelectedIndex ( 0 ) ;
1067
- return true ;
1068
- } ,
1069
-
1070
- /**
1071
- * @param {cc.MenuItem } args[1+] items
1072
- * @return {Boolean }
1073
- */
1074
- initWithItems :function ( args ) {
1075
- this . initWithCallback ( null , null ) ;
1076
- this . _subItems = [ ] ;
1077
- for ( var i = 0 ; i < args . length ; i ++ ) {
1048
+ for ( var i = 0 ; i < l ; i ++ ) {
1078
1049
if ( args [ i ] ) {
1079
1050
this . _subItems . push ( args [ i ] ) ;
1080
1051
}
@@ -1123,7 +1094,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{
1123
1094
* @param {Boolean } enabled
1124
1095
*/
1125
1096
setEnabled :function ( enabled ) {
1126
- if ( this . _isEnabled = enabled ) {
1097
+ if ( this . _isEnabled == enabled ) {
1127
1098
this . _super ( enabled ) ;
1128
1099
1129
1100
if ( this . _subItems && this . _subItems . length > 0 ) {
@@ -1172,11 +1143,6 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{
1172
1143
*/
1173
1144
cc . MenuItemToggle . create = function ( /*Multiple arguments follow*/ ) {
1174
1145
var ret = new cc . MenuItemToggle ( ) ;
1175
- //ret.initWithItems(arguments);
1176
- if ( arguments . length == 1 ) {
1177
- ret . initWithItem ( arguments ) ;
1178
- } else {
1179
- ret . initWithCallback ( arguments ) ;
1180
- }
1146
+ ret . initWithItems ( arguments ) ;
1181
1147
return ret ;
1182
1148
} ;
0 commit comments