﻿(function(a){var j="fileinput-wrapper ui-widget",h="fileinput-input ui-state-default ui-widget-content ui-corner-left",c="fileinput-button ui-state-default ui-widget-header ui-corner-right",d="fileinput-button-text",f="fileinput-file",g="ui-state-hover",b="ui-state-active",i=g+" "+b,e="C:\\fakepath\\";a.widget("shimmy.fileinput",{options:{buttonText:"Browse",inputText:""},_create:function(){var l=this,k=l.options;l.fileFile=l.element,l.fileWrapper=a("<div></div>").addClass(j).hover(function(){l.fileButton.addClass(g)},function(){l.fileButton.removeClass(i)}).bind("mousemove.fileinput",function(m){var n=(m.pageX-a(this).offset().left)-(l.fileFile.width()/1.2);var o=(m.pageY-a(this).offset().top)-(l.fileFile.height()/2);l.fileFile.css("top",o).css("left",n)}).bind("mousedown.fileinput",function(m){l.fileButton.addClass(b)}).bind("mouseup.fileinput",function(m){l.fileButton.removeClass(b)}),l.fileFile.addClass(f).wrap(l.fileWrapper),l.fileInput=a("<span></span>").addClass(h).text(l._getText()).insertBefore(l.fileFile),l.fileButtonText=a("<span></span>").addClass(d).text(k.buttonText);l.fileButton=a("<span></span>").addClass(c).insertAfter(l.fileInput).html(l.fileButtonText);l.fileFile.bind("change.fileinput mouseout.fileinput",function(){l.fileInput.text(l._getText())}).bind("focusin.fileinput",function(){l.fileButton.addClass(g)}).bind("focusout.fileinput",function(){l.fileButton.removeClass(g)})},_getText:function(){var k=this;fileValue=k.getValue();inputTextValue=k.options.inputText;if(fileValue==""){return inputTextValue}else{return fileValue}},getValue:function(){var k=this;return fileValue=k.fileFile.val().replace(e,"")},reset:function(){var k=this;k.fileInput.text(k.options.inputText)},destroy:function(){var k=this;k.fileInput.remove();k.fileButton.remove();k.fileButtonText.remove();k.fileFile.removeClass(f).unwrap(k.fileWrapper);k.fileWrapper.remove();a.Widget.prototype.destroy.call(k)},_setOption:function(k,m){var l=this;a.Widget.prototype._setOption.apply(l,arguments);switch(k){case"buttonText":l.fileButtonText.text(m);break;case"inputText":l.fileInput.text(l._getText());break}}})})(jQuery);
