/*!
* strength.js
* original author: @aaronlumsden
* further changes, comments: @aaronlumsden
* licensed under the mit license
*/
;(function ( $, window, document, undefined ) {
var pluginname = "tabulous",
defaults = {
effect: 'scale'
};
// $('').appendto('head');
function plugin( element, options ) {
this.element = element;
this.$elem = $(this.element);
this.options = $.extend( {}, defaults, options );
this._defaults = defaults;
this._name = pluginname;
this.init();
}
plugin.prototype = {
init: function() {
var links = this.$elem.find('a');
var firstchild = this.$elem.find('li:first-child').find('a');
var lastchild = this.$elem.find('li:last-child').after('');
if (this.options.effect == 'scale') {
tab_content = this.$elem.find('div').not(':first').not(':nth-child(1)').addclass('hidescale');
} else if (this.options.effect == 'slideleft') {
tab_content = this.$elem.find('div').not(':first').not(':nth-child(1)').addclass('hideleft');
} else if (this.options.effect == 'scaleup') {
tab_content = this.$elem.find('div').not(':first').not(':nth-child(1)').addclass('hidescaleup');
} else if (this.options.effect == 'flip') {
tab_content = this.$elem.find('div').not(':first').not(':nth-child(1)').addclass('hideflip');
}
var firstdiv = this.$elem.find('#tabs_container');
var firstdivheight = firstdiv.find('div:first').height();
var alldivs = this.$elem.find('div:first').find('div');
alldivs.css({'position': 'absolute','top':'40px'});
firstdiv.css('height',firstdivheight+'px');
firstchild.addclass('tabulous_active');
links.bind('click', {myoptions: this.options}, function(e) {
e.preventdefault();
var $options = e.data.myoptions;
var effect = $options.effect;
var mythis = $(this);
var thisform = mythis.parent().parent().parent();
var thislink = mythis.attr('href');
firstdiv.addclass('transition');
links.removeclass('tabulous_active');
mythis.addclass('tabulous_active');
thisdivwidth = thisform.find('div'+thislink).height();
if (effect == 'scale') {
alldivs.removeclass('showscale').addclass('make_transist').addclass('hidescale');
thisform.find('div'+thislink).addclass('make_transist').addclass('showscale');
} else if (effect == 'slideleft') {
alldivs.removeclass('showleft').addclass('make_transist').addclass('hideleft');
thisform.find('div'+thislink).addclass('make_transist').addclass('showleft');
} else if (effect == 'scaleup') {
alldivs.removeclass('showscaleup').addclass('make_transist').addclass('hidescaleup');
thisform.find('div'+thislink).addclass('make_transist').addclass('showscaleup');
} else if (effect == 'flip') {
alldivs.removeclass('showflip').addclass('make_transist').addclass('hideflip');
thisform.find('div'+thislink).addclass('make_transist').addclass('showflip');
}
firstdiv.css('height',thisdivwidth+'px');
});
},
yourotherfunction: function(el, options) {
// some logic
}
};
// a really lightweight plugin wrapper around the constructor,
// preventing against multiple instantiations
$.fn[pluginname] = function ( options ) {
return this.each(function () {
new plugin( this, options );
});
};
})( jquery, window, document );