",s=i.options.buttonBefore?l+i.htmlInput():i.htmlInput()+l,i.$elementFilestyle=e(''+s+"
"),i.$elementFilestyle.find(".group-span-filestyle").attr("tabindex","0").keypress(function(e){return 13===e.keyCode||32===e.charCode?(i.$elementFilestyle.find("label").click(),!1):void 0}),i.$element.css({position:"absolute",clip:"rect(0px 0px 0px 0px)"}).attr("tabindex","-1").after(i.$elementFilestyle),(i.options.disabled||i.$element.attr("disabled"))&&(i.$element.attr("disabled","true"),i.options.disabled?i.$elementFilestyle.find("label").css("opacity","0.65"):i.$elementFilestyle.find("label").css("opacity","1")),i.$element.change(function(){var e=i.pushNameFiles();i.options.badge?0==i.$elementFilestyle.find(".badge").length?i.$elementFilestyle.find("label").append(' '+e.length+""):0==e.length?i.$elementFilestyle.find(".badge").remove():i.$elementFilestyle.find(".badge").html(e.length):i.$elementFilestyle.find(".badge").remove(),i.options.onChange(e)}),window.navigator.userAgent.search(/firefox/i)>-1&&i.$elementFilestyle.find("label").click(function(){return i.$element.click(),!1})}};var s=e.fn.filestyle;e.fn.filestyle=function(t,s){var n="",l=this.each(function(){if("file"===e(this).attr("type")){var l=e(this),o=l.data("filestyle"),a=e.extend({},e.fn.filestyle.defaults,t,"object"==typeof t&&t);o||(l.data("filestyle",o=new i(this,a)),o.constructor()),"string"==typeof t&&(n=o[t](s))}});return void 0!==typeof n?n:l},e.fn.filestyle.defaults={text:"Choose file",htmlIcon:"",btnClass:"btn-secondary",size:"nr",input:!0,badge:!1,badgeName:"badge-light",buttonBefore:!1,disabled:!1,placeholder:"",onChange:function(){}},e.fn.filestyle.noConflict=function(){return e.fn.filestyle=s,this},e(function(){e(".filestyle").each(function(){var t=e(this),i={input:"false"!==t.attr("data-input"),htmlIcon:t.attr("data-icon"),buttonBefore:"true"===t.attr("data-buttonBefore"),disabled:"true"===t.attr("data-disabled"),size:t.attr("data-size"),text:t.attr("data-text"),btnClass:t.attr("data-btnClass"),badge:"true"===t.attr("data-badge"),badgeName:t.attr("data-badgeName"),placeholder:t.attr("data-placeholder")};t.filestyle(i)})})}(window.jQuery);
\ No newline at end of file
diff --git a/test/index.html b/test/index.html
index bbbb6e0..059939c 100644
--- a/test/index.html
+++ b/test/index.html
@@ -7,7 +7,7 @@
Testing - Bootstrap FileStyle
-
+
@@ -70,7 +71,10 @@ Testing Options JavaScript
-
+
@@ -164,7 +168,7 @@
Testing initialize via data attributes
-
+
@@ -181,8 +185,10 @@ Testing initialize via data attributes
});
$('#input03').filestyle({
+ badge: true,
input : false,
- btnClass : 'btn-primary'
+ btnClass : 'btn-primary',
+ htmlIcon : ' '
});
$('#input04').filestyle({
@@ -250,6 +256,13 @@ Testing initialize via data attributes
$('#countRed').on('click', function () {
$('#input03').filestyle('badgeName', 'badge-danger');
})
+
+ $('#countToggle').on('click', function () {
+ if ($('#input03').filestyle('badge'))
+ $('#input03').filestyle('badge', false);
+ else
+ $('#input03').filestyle('badge', true);
+ })