(function($){
var defaults = {
widget:{
wrapper:{
css:{},
element:false
},
nav:{
css:{},
element:false,
ul:{
css:{},
element:false,
li:{
css:{},
elements:[]
}
}
}
},
events:{
create:function(){},
destroy:function(){},
change:function(){},
resize:function(){}
}
};
var methods = {
init:function(options){
return this.each(function(){
// Initialize
var $this = $(this).addClass('cytoNav');
if ($this.data('cytoNav')!=null) return console.warn("You cannot reinstatiate cytoNav before calling the destroy method.\nProtip: Use the refresh method to reinstantiate in one move.");
var settings = $.extend(true,{},defaults,options);
// Generate widget
settings.widget.wrapper.element = $('
').addClass('cytoNav-wrapper').css(settings.widget.wrapper.css).appendTo($('header'));
settings.widget.nav.element = (($this.is("nav")) ? $this : $('')).addClass('cytoNav-nav').css(settings.widget.nav.css).appendTo(settings.widget.wrapper.element);
settings.widget.nav.ul.element = (($this.has("ul")) ? $this.find("ul").first() : $("")).addClass('cytoNav-ul').css(settings.widget.nav.ul.css).appendTo(settings.widget.nav.element);
if (settings.widget.nav.ul.element.has("li")) {
var lis = [];
settings.widget.nav.ul.element.find("li").each(function(){lis.push($(this))});
settings.widget.nav.ul.li.elements = $.merge(settings.widget.nav.ul.li.elements,lis);
}
$.each(settings.widget.nav.ul.li.elements,function(i,li){
li.addClass('cytoNav-li').css(settings.widget.nav.ul.li.css);
});
// Finalize
$this.data('cytoNav',settings);
settings.events.create.apply($this);
});
},
destroy:function(){
return this.each(function(){
var $this = $(this);
});
},
resize:function(){
return this.each(function(){
var $this = $(this);
});
},
value:function(){
return this.each(function(){
var $this = $(this);
});
}
};
$.fn.cytoNav=function(method){
if (methods[method]) return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
else if (typeof method == 'object' || !method) return methods.init.apply(this,arguments);
else $.error('Method ' + method + ' does not exist on $.cytoNav!');
};
$(window).resize(function(){$('.cytoNav').cytoNav('resize');});
$.Cytoplasm("ready",function(){
$('nav').cytoNav();
});
})(jQuery);