Open GoogleCodeExporter opened 9 years ago
Modified:
// helper array has object function
// thanks to @Vinko Vrsalovic
// http://stackoverflow.com/questions/143847/best-way-to-find-an-item-in-a-javascript-array
WAS incompatible to below:
var hasObject = function (arr, o) {
var l = arr.length + 1;
while (l -= 1) {
if (arr[l - 1] === o) {
return true;
}
}
return false;
};
Then:
// setting array of active tabs
_setActiveTabs: function (tabs) {
var self = this;
var $this = this.element;
if (typeof tabs != 'undefined') {
$this.children('div').each(function (index) {
var $tab = $(this).prev('h3');
if (hasObject(tabs, index)) {
self._showTab($tab);
} else {
self._hideTab($tab);
}
});
}
},
See usage of has object. No does not mess up lots of JS.
Original comment by alab...@gmail.com
on 30 Sep 2011 at 1:30
See attached example.
Please fix it by next release so no worry anymore about this!
Original comment by alab...@gmail.com
on 30 Sep 2011 at 1:31
Attachments:
Here's a better fix using a feature jQuery already has:
@@ -181,7 +181,7 @@
if(typeof tabs != 'undefined') {
$this.children('div').each(function(index){
var $tab = $(this).prev('h3');
- if(tabs.hasObject(index)) {
+ if(jQuery.inArray(index,tabs) != -1) {
self._showTab($tab);
} else {
self._hideTab($tab);
@@ -244,25 +244,5 @@
}
});
-
- // helper array has object function
- // thanks to @Vinko Vrsalovic
- //
http://stackoverflow.com/questions/143847/best-way-to-find-an-item-in-a-javascri
pt-array
-
- /*
- Array.prototype.hasObject = (!Array.indexOf ? function (k) {
- var l = this.length + 1;
- while (l -= 1) {
- if (this[l - 1] === k) {
- return true;
- }
- }
- return false;
- }: function (k) {
- return (this.indexOf(o) !== -1);
- }
- );
- */
-
})(jQuery);
Original comment by gameshow...@gmail.com
on 8 Jun 2012 at 7:17
Attachments:
Original issue reported on code.google.com by
alab...@gmail.com
on 30 Sep 2011 at 1:24