dnagir / ios-checkboxes Goto Github PK
View Code? Open in Web Editor NEWiOS style checkboxes for Rails 3.1
iOS style checkboxes for Rails 3.1
I need to simulate a click on a styled checkbox.
If I do
$('#checkbox').parents('.iPhoneCheckContainer').trigger('mousedown')
it raise me the following error :
event.originalEvent is undefined
it seems to came from the line 90 (coffeescript version) :
x = event.pageX || event.originalEvent.changedTouches[0].pageX
I am using the iOs checkboxes in a tabbed menu. The checkboxes in the tab that is initially visible look fine: http://screencast.com/t/K2m4UB6e1iJ
But when I change to another tab (that was invisible via display: none
), the checkboxes are barely visible: http://screencast.com/t/4wyUZr4D
The width of <div class="iPhoneCheckContainer">
is set to 15px in this case.
I am pretty sure the issue is somewhere in this method but I can't figure it out: https://github.com/dnagir/ios-checkboxes/blob/master/lib/assets/javascripts/ios-checkboxes/ios-checkboxes.js.coffee#L66
Would be nice to include link to a screenshot in the documentation.
Hey, thanks for the great work! I've used this in two places in our app, and one of them is acting strangely -- it only sticks if dragged. When clicked, the switch toggles on, then flips back.
Any idea what could cause this, or how to fix it? I haven't dove into the JS internals or tried debugging yet.
Here's my js: https://github.com/codeforamerica/textizen/blob/dev/app/assets/javascripts/polls.js.coffee
The problematic view: https://github.com/codeforamerica/textizen/blob/dev/app/views/polls/_form.html.erb
ios-checkboxes.js
always loads jQuery which can cause problems.
Example:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js" type="text/javascript"></script>
<script src="//foo.com/ios-checkboxes.js" type="text/javascript"></script>
jQuery UI will not be available after that because when it is loaded, it enhances the jQuery namespace, and when ios-checkboxes.js
loads jQuery again it overwrites these enhancements.
I'd suggest just kicking the loading of jQuery and expecting the user to load jQuery manually before loading ios-checkboxes.js
.
Alternatively you could add a check to see if jQuery is already loaded and only load it if it's not loaded.
I'd go with the first option though, since I've neves seen a jQuery plugin requiring jQuery by itself (correct me if I'm wrong), they all expect jQuery to already be present.
In rails 3.2.21 I got this error:
TypeError: $.browser is undefined
Near this:
iOSCheckbox.prototype.disableTextSelection = function() {
if ($.browser.msie) {
return $([this.handle, this.offLabel, this.onLabel, this.container]).attr("unselectable", "on");
}
};
I have installed the gem but found this error. Any help is really appreciated because the gem looks really cool.
Compiled ios-checkboxes.css (19ms) (pid 71062)
Error compiling asset application.css:
Sass::SyntaxError: File to import not found or unreadable: compass/css3/opacity.
Load paths:
Sass::Rails::Importer(/Users/Vidya/.rvm/gems/ruby-1.9.3-p194@global/gems/ios-checkboxes-0.1.3/lib/assets/stylesheets/ios-checkboxes/ios-checkboxes.css.sass)
/Users/Vidya/.rvm/gems/ruby-1.9.3-p194@global/gems/ios-checkboxes-0.1.3/lib/assets/stylesheets
Here is my Gemfile.lock:
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.4)
actionpack (= 3.1.4)
mail (> 2.3.0)> 3.0.0)
actionpack (3.1.4)
activemodel (= 3.1.4)
activesupport (= 3.1.4)
builder (
erubis (> 2.7.0)> 0.6)
i18n (
rack (> 1.3.6)> 1.1)
rack-cache (
rack-mount (> 0.8.2)> 0.6.1)
rack-test (
sprockets (> 2.0.3)> 3.0.0)
activemodel (3.1.4)
activesupport (= 3.1.4)
builder (
i18n (> 0.6)> 2.2.3)
activerecord (3.1.4)
activemodel (= 3.1.4)
activesupport (= 3.1.4)
arel (
tzinfo (> 0.3.29)> 1.0)
activeresource (3.1.4)
activemodel (= 3.1.4)
activesupport (= 3.1.4)
activesupport (3.1.4)
multi_json (
addressable (2.2.8)
ansi (1.4.2)
arel (2.2.3)
bcrypt-ruby (3.0.1)
builder (3.0.0)
chunky_png (1.2.5)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (> 3.1.0)> 1.2)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.1)
compass (0.13.alpha.0)
chunky_png (
fssm (>= 0.2.7)
sass (> 3.2.0.alpha.93)> 2.1)
daemons (1.1.8)
data_objects (0.10.8)
addressable (
delayed_job (2.1.4)
activesupport (> 3.0)> 2.1)
daemons
delayed_job_data_mapper (1.0.0.rc)
delayed_job (
dm-aggregates
dm-core
dm-observer
diff-lcs (1.1.3)
dm-active_model (1.2.1)
activemodel (> 3.0)> 1.2.0)
dm-core (
dm-aggregates (1.2.0)
dm-core (> 1.2.0)> 1.2.0)
dm-constraints (1.2.0)
dm-core (
dm-core (1.2.0)
addressable (> 2.2.6)> 0.10.6)
dm-do-adapter (1.2.0)
data_objects (
dm-core (> 1.2.0)> 1.2.0)
dm-migrations (1.2.0)
dm-core (
dm-observer (1.2.0)
dm-core (> 1.2.0)> 1.2.0)
dm-postgres-adapter (1.2.0)
dm-do-adapter (
do_postgres (> 0.10.6)> 3.0)
dm-rails (1.2.1)
actionpack (
dm-active_model (> 1.2.0)> 1.2.0)
dm-core (
railties (> 3.0)> 1.2.0)
dm-sqlite-adapter (1.2.0)
dm-do-adapter (
do_sqlite3 (> 0.10.6)> 1.2.0)
dm-timestamps (1.2.0)
dm-core (
dm-transactions (1.2.0)
dm-core (> 1.2.0)> 3.0.0)
dm-types (1.2.1)
bcrypt-ruby (
dm-core (> 1.2.0)> 1.5.4)
fastercsv (
json (> 1.6.1)> 1.0.3)
multi_json (
stringex (> 1.3.0)> 2.1.2)
uuidtools (
dm-validations (1.2.0)
dm-core (> 1.2.0)> 1.0)
do_postgres (0.10.8)
data_objects (= 0.10.8)
do_sqlite3 (0.10.8)
data_objects (= 0.10.8)
erubis (2.7.0)
eventmachine (0.12.10)
execjs (1.3.2)
multi_json (
factory_girl (3.3.0)
activesupport (>= 3.0.0)
factory_girl_rails (3.3.0)
factory_girl (> 3.3.0)> 0.4)
railties (>= 3.0.0)
faker (1.0.1)
i18n (
fastercsv (1.5.4)
fssm (0.2.9)
gibberish (1.2.0)
hike (1.2.1)
i18n (0.6.0)
ios-checkboxes (0.1.3)
compass (>= 0.12.alpha.1)
rails (> 3.1.2)> 3.0)
sass-rails
jquery-rails (1.0.19)
railties (
thor (> 0.14)> 1.16)
json (1.6.7)
mail (2.3.3)
i18n (>= 0.4.0)
mime-types (
treetop (> 1.4.8)> 1.0)
mime-types (1.18)
multi_json (1.0.4)
polyglot (0.3.3)
rack (1.3.6)
rack-cache (1.2)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.1.4)
actionmailer (= 3.1.4)
actionpack (= 3.1.4)
activerecord (= 3.1.4)
activeresource (= 3.1.4)
activesupport (= 3.1.4)
bundler (
railties (= 3.1.4)
railties (3.1.4)
actionpack (= 3.1.4)
activesupport (= 3.1.4)
rack-ssl (> 1.3.2)> 3.4)
rake (>= 0.8.7)
rdoc (
thor (> 0.14.6)> 1.4)
rake (0.9.2.2)
rdoc (3.12)
json (
right_aws (3.0.4)
right_http_connection (>= 1.2.5)
right_http_connection (1.3.0)
rspec (2.10.0)
rspec-core (> 2.10.0)> 2.10.0)
rspec-expectations (
rspec-mocks (> 2.10.0)> 1.1.3)
rspec-core (2.10.0)
rspec-expectations (2.10.0)
diff-lcs (
rspec-mocks (2.10.1)
rspec-rails (2.10.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (> 2.10.0)> 3.1.0)
sass (3.2.0.alpha.237)
sass-rails (3.1.6)
actionpack (
railties (> 3.1.0)> 1.3.2)
sass (>= 3.1.10)
tilt (
sprockets (2.0.4)
hike (> 1.2)> 1.0)
rack (
tilt (~> 1.1, != 1.3.0)
stringex (1.3.3)
thin (1.3.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
turn (0.9.5)
ansi
tzinfo (0.3.33)
uuidtools (2.1.2)
PLATFORMS
ruby
DEPENDENCIES
actionmailer (> 3.1.3)> 3.1.3)
actionpack (
activesupport (> 3.1.3)> 3.1.1)
coffee-rails (
daemons
delayed_job
delayed_job_data_mapper
dm-aggregates (> 1.2.0)> 1.2.0)
dm-constraints (
dm-migrations (> 1.2.0)> 1.2.0)
dm-observer (
dm-postgres-adapter (> 1.2.0)> 1.2.0)
dm-rails (
dm-sqlite-adapter
dm-timestamps (> 1.2.0)> 1.2.0)
dm-transactions (
dm-types (> 1.2.0)> 1.2.0)
dm-validations (
factory_girl_rails
faker
gibberish
ios-checkboxes (> 0.1.3)> 3.1.3)
jquery-rails
railties (
right_aws
rspec-rails (> 2.6)> 3.1.1)
sass-rails (
thin
turn
tzinfo
Hi @tdreyno,
Could you please release this gem?
It provides built-in assets via SASS as well as native implementation with CoffeeScript (no need to precompile).
To push just do:
git clone [email protected]:dnagir/ios-checkboxes.git
cd ios-checkboxes
bundle install
rake release
Or you can give me access to this gem so that I can do it.
Thanks a lot.
Any plans to update the dependencies to support rails > 3.1 ?
Hey there!
Any plans to relax the rails dependency in the gemspec s.add_dependency "rails", "~> 3.1"
so that it's compatible with Rails4 projects? We're currently in the midst of an upgrade and I was curious if you wanted to tweak that dependency in the .gemspec so it could work for Rails4? Let me know what you think.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.