Code Monkey home page Code Monkey logo

bootstrap-switch-rails's Introduction

bootstrap-switch-rails Gem Version

bootstrap-switch-rails provides the bootstrap-switch plugin as a Rails engine to use it within the asset pipeline.

Installation

Add this to your Gemfile:

gem "bootstrap-switch-rails"

and run bundle install.

Usage

In your application.js, include the following:

//= require bootstrap-switch

In your application.css, include the following:

/*
 * for bootstrap3
 *= require bootstrap3-switch
 *
 * or for bootstrap2
 *= require bootstrap2-switch
 */

 *= require bootstrap-switch

or in any SASS file, include the following:

/* for bootstrap3 */
@import "bootstrap3-switch";
/* or for bootstrap2 */
@import "bootstrap2-switch";

Examples

See the demo page for examples how to use the plugin

License

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

bootstrap-switch-rails's People

Contributors

davidhrbac avatar halissonvit avatar knomedia avatar manuelvanrijn avatar nickl- avatar umhan35 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bootstrap-switch-rails's Issues

Bootstrap 4

Is there any updates on bootstrap 4 styling compatibility?

generated html is incorrect( using on/off I18n translated texts)

I am trying to use the gem with Rails 4 this way

<div class="col-sm-9">
    <%= f.check_box :allow_read, :data => { :size=>'medium', 'on-color'=>'success', 'on-text'=> "#{t('yes').upcase}", 'off-text'=> "#{t('no').upcase}" } %>
</div>

The generated HTML is weird , the OFF text is displayed on the left side of the switch with translated on/off texts ..

<div class="col-sm-9">

  <div class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-off bootstrap-switch-medium bootstrap-switch-animate">
    <div class="bootstrap-switch-container">
      <span class="bootstrap-switch-handle-on bootstrap-switch-success">ON</span>
      <label class="bootstrap-switch-label">&nbsp;</label>
      <span class="bootstrap-switch-handle-off bootstrap-switch-default">OFF</span>
      <input name="permission[allow_read]" type="hidden" value="0">
    </div>
  </div>

  <div class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-on bootstrap-switch-medium bootstrap-switch-animate bootstrap-switch-id-permission_allow_read">
    <div class="bootstrap-switch-container">
      <span class="bootstrap-switch-handle-on bootstrap-switch-success">OUI</span>
      <label class="bootstrap-switch-label">&nbsp;</label>
      <span class="bootstrap-switch-handle-off bootstrap-switch-default">NON</span>
      <input data-size="medium" data-on-color="success" data-on-text="OUI" data-off-text="NON" type="checkbox" value="1" checked="checked" name="permission[allow_read]" id="permission_allow_read">
    </div>
  </div>

</div>

screen shot 2015-11-19 at 18 34 19

Depreciation Warning

I've started getting the following warning when I use your gem.

DEPRECATION WARNING: Extra .css in SCSS file is unnecessary. Rename /usr/local/rvm/gems/ruby-2.2.5/gems/bootstrap-switch-rails-3.0.0/vendor/assets/stylesheets/bootstrap3-switch.css.scss to /usr/local/rvm/gems/ruby-2.2.5/gems/bootstrap-switch-rails-3.0.0/vendor/assets/stylesheets/bootstrap3-switch.scss. (called from _app_views_layouts_blank_html_erb__1211379351604111721_92167400 at /home/ubuntu/workspace/law_dasher/app/views/layouts/blank.html.erb:5)

SASS Import does not work

Hello,

I installed this gem following the README. I included bootstrap-switch in my SASS stylesheets using the "import" statements as described there (btw, the statements include semicolons; didn't SASS get rid of semicolons?!).

@import "bootstrap3-switch"

This leads to the following error message (development mode):

Sass::SyntaxError
...
File to import not found or unreadable: bootstrap3-switch.
Load paths:
...
  /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/bootstrap-switch-rails-3.3.2/vendor/assets/javascripts
  /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/bootstrap-switch-rails-3.3.2/vendor/assets/stylesheets
...

However, when I use the CSS import
*= require bootstrap3-switch
there is no error message and the CSS file gets loaded (from the produced HTML):
<link data-turbolinks-track="true" href="/assets/bootstrap3-switch.self.css?body=1" media="all" rel="stylesheet" />

So I guess there is something wrong with the SASS import.

I identified the problem and found a solution.
Problem: the SASS import filename statement tries to import "_filename.scss".
Solution: use import "bootstrap3-switch.css.scss" in your application.css.sass

You should update the README or change the files to "_bootstrap3-switch.scss".

Unknown property 'user-select'.

I've got following errors:

Unknown property 'user-select'.  Declaration dropped. bootstrap3-switch.self-eca58a24352b32df1ad2218f1a4561a9a8d00ae4825c407a57df83d56f54fb85.css:37
Expected 'none', URL, or filter function but found 'alpha('.  Error in parsing value for 'filter'.  Declaration dropped. bootstrap3-switch.self-eca58a24352b32df1ad2218f1a4561a9a8d00ae4825c407a57df83d56f54fb85.css:145
Expected 'none', URL, or filter function but found 'alpha('.  Error in parsing value for 'filter'.  Declaration dropped.

..when using bootstrap-sass 3.2 with bootstrap-switch-rails (3.3.3)
Any ideas what this might be?

Rails can't find switch's .js and .css files

I installed your gem, no errors.
Then I included //= require bootstrap-switch on application.js, as you instructed, and my rails app stopped working saying: "couldn't find file 'bootstrap-switch' (in .../app/assets/javascripts/application.js:17)
A similar error shows up if I make a similar edit on application.css.

Why can't rails find the files? Shouldn't the gem take care of it?


After I @import "bootstrap2-switch" I get this:

  File to import not found or unreadable: bootstrap2-switch.
  Load paths:
    /home/.../Documents/.../app/assets/images
    /home/.../Documents/.../app/assets/javascripts
    /home/.../Documents/.../app/assets/stylesheets
    /home/.../Documents/.../vendor/assets/javascripts
    /home/.../Documents/.../vendor/assets/stylesheets
    /home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/turbolinks-1.1.1/lib/assets/javascripts
    /home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/jquery-rails-3.0.4/vendor/assets/javascripts
    /home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/coffee-rails-4.0.1/lib/assets/javascripts
    /home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/font-awesome-rails-4.0.3.1/app/assets/fonts
    /home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/font-awesome-rails-4.0.3.1/app/assets/stylesheets
    /home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/bootstrap-sass-2.3.2.0/vendor/assets/images
    /home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/bootstrap-sass-2.3.2.0/vendor/assets/javascripts
    /home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/bootstrap-sass-2.3.2.0/vendor/assets/stylesheets
    /home/.../Documents/rails_projects/vendor/assets/stylesheets

Switch's folder is not even listed... however bundle show bootstrap-switch-rails returns /home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/bootstrap-switch-rails-2.0.2, so it is installed.

Turbolinks Compatibility

It appears that bootstrap-switch does not play nicely with turbolinks. I needed to disable turbolinks to utilize bootstrap-switch. Is there any workaround to utilizing this with turbolinks, or would this require a fork of bootstrap-switch that listens for turbolink events?

Deprecation warning fixes

Hi,

do you plan to release a new version for this gem? This would remove the deprecation warnings already fixed in master.

Compilation error

I'm getting the following error from the sass compiler in my Rails 4.1 beta-1 project. Anybody have any suggestions?

Invalid CSS after "...0 8px rgba(red(": expected ")", was "@btnPrimaryBack..."

Bootstrap 4 usage in 3.3.4

Can you clarify the correct settings to use for Bootstrap 4?

Seems like I can only switch css between bootstrap2 and bootstrap3, do I use bootstrap3-switch for bootstrap4 or something different?

application.js
//= require bootstrap-switch
application.scss
@import "bootstrap3-switch";

Cannot read property 'apply' of undefined

I am applying bootstrap switch with options like this
$('#switch-state').bootstrapSwitch('setSizeClass', 'switch-mini');
its throwing this error
Uncaught TypeError: Cannot read property 'apply' of undefined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.