Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Bootstrap 3 support and some options #39

Merged
merged 2 commits into from
Apr 22, 2014
Merged

added Bootstrap 3 support and some options #39

merged 2 commits into from
Apr 22, 2014

Conversation

egea1981
Copy link
Contributor

Now it can add the button before the input, create button and input container when class are set, and can create Bootstrap input group.

Now it can add the button before the input, create button and input container when class are set, and can create Bootstrap input group.
@abdulazeezsk
Copy link

Is this change merged with main branch? Can i get bootstrap3 compatibility with latest download?

@markusslima
Copy link
Owner

Friends have patience because I have not had time to test yet.

@egea1981
Copy link
Contributor Author

abdulazeezsk, of course. Using this methtod (from my commit) you can get a file input such Bootstrap 3 button group:

Sample of creating a Bootstrap 3 input group:

     $(':file').filestyle({
         buttonBefore: true,                                 // set the button before the input
         containerClass: 'input-group',                  // the container class from the label (button) and the input 
         classButtonContainerClass: 'input-group-btn',   // label (button) container class (when set creates a container div)
         classButton: 'btn btn-default btn-file',        // label (button) class
         classInputContainerClass: '',                   // input container class (when set creates a container div)
         classInput: 'form-control',                     // input class
         classIcon: 'fa fa-folder-open',                 // button icon (using FontAwesome)
     });

Note that i haven't tested it on all borwsers.
And note 2, sorry for may bad english :)

@osk2
Copy link

osk2 commented Dec 21, 2013

'containerClass': 'form-group',

should be

'containerClass': 'form-group bootstrap-filestyle',

or it will not work if you create more than one file input.

@egea1981
Copy link
Contributor Author

Solved, but not tested. Also now its not needed to explicit 'bootstrap-filestyle' in 'containerClass', its added in the function.
Thanks osk2.

@julianz-
Copy link

I had to modify your code slightly to make it work. The problem is the selector:

// Data attributes register
    $('.filestyle').each(function () {
        var $this = $(this),
            options = {
                'buttonText': $this.attr('data-buttonText'),
                'input': $this.attr('data-input') === 'false' ? false : true,
                'icon': $this.attr('data-icon') === 'false' ? false : true,
                'classButton': $this.attr('data-classButton'),
                'classInput': $this.attr('data-classInput'),
                'classIcon': $this.attr('data-classIcon')
            };
        $this.filestyle(options);
    });

may run before the document is fully loaded. It certainly does in my case as it ignores any DOM items with class="filestyle". Wrapping this selector to make it wait for the $( document ).ready() event does the trick:

 $(function() {
        $('.filestyle').each(function() {
            var $this = $(this),
                options = {
                    'buttonText': $this.attr('data-buttonText'),
                    'input': $this.attr('data-input') === 'false' ? false : true,
                    'icon': $this.attr('data-icon') === 'false' ? false : true,
                    'classButton': $this.attr('data-classButton'),
                    'classInput': $this.attr('data-classInput'),
                    'classIcon': $this.attr('data-classIcon')
                };
            $this.filestyle(options);
        });
  });

@egea1981
Copy link
Contributor Author

egea1981 commented Jan 7, 2014

julianz,

i was thinking about it. Since i made those changes, i was using Yii (PHP) framework, and, of course, it loaded the script using jQuery(function($) {}); at the end of the document (inside <body />).

Issues apart, i think it should be free when it would be applied. So, per example, in an AJAX request may it will be applied after success handler.

In this case, so as in all others, i have it not tested yet.

Anyway, thanks for the aportation :)

@X13454
Copy link

X13454 commented Apr 18, 2014

image

Hello,

Are all theses changes really necessary for bootstrap 3 integration? With the current version, the result I get seems correct (just had to change the icon name). Would you have any picture of the render you have with this commit please?

@egea1981
Copy link
Contributor Author

Ok, in my case it is a bit different. Those changes are to adapt HTML elements to BS3 HTML structure, and doing it more customizable.

bootstrap filestyle example

Date selectors was made with my jQuery plugin. More info: https://github.com/egea1981/jquery.dateselector

@markusslima markusslima merged commit 7e2093d into markusslima:master Apr 22, 2014
@lucascaton
Copy link

Awesome, thanks! 😄

@egea1981 egea1981 deleted the patch-1 branch April 25, 2014 20:02
@markusslima markusslima mentioned this pull request May 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants