Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jayanezj/jquery-onoff-rails
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: DatekWireless/jquery-onoff-rails
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 3 commits
  • 7 files changed
  • 2 contributors

Commits on Jan 7, 2021

  1. Restored deleted repo

    larsin committed Jan 7, 2021
    Copy the full SHA
    731669d View commit details

Commits on Jan 8, 2021

  1. Copy the full SHA
    9439e77 View commit details

Commits on Aug 17, 2023

  1. Allow running on rails 7

    larsin committed Aug 17, 2023
    Copy the full SHA
    48421cd View commit details
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -13,3 +13,7 @@
*.a
mkmf.log
*.gem
*~
.#*
.idea
.ruby-version
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in rails-rateit.gemspec
gemspec

gem "jquery-rails", "= 4.0.3"
gem "html5shiv-js-rails", "= 3.7.2.1"
gem "jquery-rails"
gem "html5shiv-js-rails"

group :development do
gem "guard"
2 changes: 1 addition & 1 deletion jquery-onoff-rails.gemspec
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
spec.test_files = Dir["test/**/*"]
spec.require_paths = ["lib"]
spec.version = Onoff::VERSION
spec.add_dependency "railties", ">= 3.2", "< 5.0"
spec.add_dependency "railties", ">= 3.2", "< 8.0"

spec.add_development_dependency "activesupport"
spec.add_development_dependency "sass-rails"
7 changes: 4 additions & 3 deletions lib/onoff/view_helpers/action_view.rb
Original file line number Diff line number Diff line change
@@ -2,15 +2,16 @@ module Onoff
module ViewHelpers
module ActionView
def onoff(options = {})
target = options.delete(:target)
inner = content_tag(:span, nil, { class: "onoffswitch-inner" })
switch = content_tag(:span, nil, { class: "onoffswitch-switch" })
lbl = ERB::Util.html_escape(inner)
lbl += ERB::Util.html_escape(switch)
label = content_tag(:label, lbl, {
class: "onoffswitch-label", for: options[:target] })
input = content_tag(:input, nil, {
class: "onoffswitch-label", for: target })
input = content_tag(:input, nil, options.merge({
class: "onoffswitch-checkbox",
id: options[:target], type: "checkbox" })
id: target, type: "checkbox" }))
lbl = ERB::Util.html_escape(input)
lbl += ERB::Util.html_escape(label)
content_tag(:div, lbl, { class: "onoffswitch" })
1 change: 1 addition & 0 deletions test/dummy/app/views/pages/checked_switcher.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= onoff target: "myTarget", checked: true %>
1 change: 1 addition & 0 deletions test/dummy/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Dummy::Application.routes.draw do
get "/switchers", :to => "pages#switchers"
get "/checked_switcher", :to => "pages#checked_switcher"
end
7 changes: 7 additions & 0 deletions test/jquery_onoff_rails_test.rb
Original file line number Diff line number Diff line change
@@ -51,6 +51,13 @@ class JqueryOnoffRailsTest < ActionDispatch::IntegrationTest
assert_select "span.onoffswitch-switch"
end

test "extra options should be passed to checkbox" do
get "/checked_switcher"
assert_response :success
assert_select "input.onoffswitch-checkbox[checked]"
end


private

def clean_sprockets_cache