-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinlineOptions.min.js
More file actions
7 lines (7 loc) · 2.03 KB
/
inlineOptions.min.js
File metadata and controls
7 lines (7 loc) · 2.03 KB
1
2
3
4
5
6
7
/*!
jQuery inlineOptions Plugin
Version: 0.2.0
URL: http://github.com/bpartridg83/inlineOptions-jQuery-plugin
Copyright: Copyright 2011 Brian Partridge
License: GPL
*/(function(c){var e={init:function(a){this.each(function(){var d=a?a:c(this).data("iop");e.create(c(this),d)})},create:function(a,d){var b=typeof a==="object"?a:c(a),d=c.extend({},this.defaults,d);b.parent().hasClass(d.className)||b.wrap(c("<ul />",{"class":d.className}));var f=b.find("option"),b=b.parent().attr("data-iop",true).data("iop-opts",d);if(!b.find("small").length){b.append('<span class="window"><span class="wrapper"></span></span>');for(var h=0,g=f.length;h<g;h+=1)c("<a />",{text:f.eq(h).text(), href:"#"+f.eq(h).val()}).data("value",f.eq(h).val()).wrap("<li />").parent().appendTo(b),c("<small />",{text:f.eq(h).text()}).appendTo(b.find(".wrapper"));b.find(".window").css({height:b.height()+"px"});b.find("select").bind("change",function(){c.fn.inlineOptions("update",c(this).parent())});b.find("a").bind("click",function(){c(this).closest("ul").find("select").val(c(this).data("value")).trigger("change");return false})}this.update(b,false)},destroy:function(a){var d;d=this.length?this:arguments.length? typeof a==="object"?a:c(a):c("select");var b=d.parent(),f=b.data("iop-opts");return b.hasClass(f.className)?(b.find("li, span").remove(),d.unwrap().unbind("change"),d):false},update:function(a,d){var b=arguments;(b.length?typeof a==="object"?a:c(a):c("[data-iop]")).each(function(){var a=c(this).data("iop-opts"),d=(b.length>1?b[1]:a.animate)?a.speed:0,g=c(this).find(":selected"),e=g.index(),g=g.closest("ul"),i=g.find("a").eq(e),e=i.outerWidth(),i=i.position().left;g.find(".window").stop().animate({width:e+ 1,left:i},d,a.easing).fadeIn(d).find(".wrapper").stop().animate({left:-i+2},d,a.easing)})},defaults:{animate:true,speed:250,className:"iop",easing:"swing"}};c.fn.inlineOptions=function(a){return e[a]?e[a].apply(this,Array.prototype.slice.call(arguments,1)):typeof a==="object"||!a?e.init.apply(this,arguments):'$.fn.inlineOptions: "'+a+'" does not exist'}})(jQuery);