- Notifications
You must be signed in to change notification settings - Fork244
jQuery UI for the Rails asset pipeline
License
jquery-ui-rails/jquery-ui-rails
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This gem packages the jQuery UI assets (JavaScripts, stylesheets, andimages) for the Railsassetpipeline, so you never haveto download a custom package through thewebinterface again.
SeeVERSIONS.md to see which versions of jquery-ui-rails bundlewhich versions of jQuery UI.
Warning: This gem is incompatible with thejquery-rails
gem before version3.0.0! Strange things will happen if you use an earlierjquery-rails
version. Runbundle list
to ensure that you either aren't usingjquery-rails
, or at least version 3.0.0 ofjquery-rails
.
In your Gemfile, add:
gem'jquery-ui-rails'
To require all jQuery UI modules, add the following to your application.js:
//= require jquery-ui
Also add the jQuery UI CSS to your application.css:
/* *= require jquery-ui */
Due to directory structure changes between jQuery UI 1.10, 1.11, and 1.12,if you use version is lower than 6.0, you will have to use a different namingfor the files to require, please check following links for more information:for 5.0 users,for 4.2 users.
All images required by jQuery UI are automatically served through the assetpipeline, so you are good to go! For example, this code will add adatepicker:
$(function(){$('.datepicker').datepicker();});
The jQuery UI code weighs 51KB (minified + gzipped) and takes a while toexecute, so for production apps it's recommended to only include the modulesthat your application actually uses. Dependencies are automatically resolved.Simply pick one or more modules from the asset list below.
For example, if you only need the datepicker module, add this to yourapplication.js:
//= require jquery-ui/widgets/datepicker
In your application.css, require the corresponding CSS module (noticenowidgets/
subdirectory here):
/* *= require jquery-ui/datepicker */
//= require jquery-ui/core//= require jquery-ui/widget//= require jquery-ui/position
You usually do not need to require these directly, as they are pulled in by theother JavaScript modules as needed.
//= require jquery-ui/widgets/mouse//= require jquery-ui/widgets/draggable//= require jquery-ui/widgets/droppable//= require jquery-ui/widgets/resizable//= require jquery-ui/widgets/selectable//= require jquery-ui/widgets/sortable
For all butjquery-ui/mouse
andjquery-ui/droppable
, remember torequire
their matching CSSfiles in your application.css as well.
//= require jquery-ui/widgets/accordion//= require jquery-ui/widgets/autocomplete//= require jquery-ui/widgets/button//= require jquery-ui/widgets/datepicker//= require jquery-ui/widgets/dialog//= require jquery-ui/widgets/menu//= require jquery-ui/widgets/progressbar//= require jquery-ui/widgets/selectmenu//= require jquery-ui/widgets/slider//= require jquery-ui/widgets/spinner//= require jquery-ui/widgets/tabs//= require jquery-ui/widgets/tooltip
For all of these, remember torequire
their matching CSS files in yourapplication.css as well.
Datepicker has optional i18n modules for non-US locales, namedjquery-ui/datepicker-xx[-YY]
(list),for example:
//= require jquery-ui/widgets/datepicker//= require jquery-ui/i18n/datepicker-pt-BR
Note that you still need to include the main datepicker module. It is notrequired automaticallyfor performancereasons.
//= require jquery-ui/effect.all
OR
//= require jquery-ui/effect//= require jquery-ui/effects/effect-blind//= require jquery-ui/effects/effect-bounce//= require jquery-ui/effects/effect-clip//= require jquery-ui/effects/effect-drop//= require jquery-ui/effects/effect-explode//= require jquery-ui/effects/effect-fade//= require jquery-ui/effects/effect-fold//= require jquery-ui/effects/effect-highlight//= require jquery-ui/effects/effect-puff//= require jquery-ui/effects/effect-pulsate//= require jquery-ui/effects/effect-scale//= require jquery-ui/effects/effect-shake//= require jquery-ui/effects/effect-size//= require jquery-ui/effects/effect-slide//= require jquery-ui/effects/effect-transfer
/* *= require jquery-ui/core *= require jquery-ui/theme */
You might want to require these if you do not use any of the following modules,but still want jQuery UI's basic theming CSS. Otherwise they are automaticallypulled in as dependencies.
/* *= require jquery-ui/draggable *= require jquery-ui/resizable *= require jquery-ui/selectable *= require jquery-ui/sortable */
/* *= require jquery-ui/accordion *= require jquery-ui/autocomplete *= require jquery-ui/button *= require jquery-ui/datepicker *= require jquery-ui/dialog *= require jquery-ui/menu *= require jquery-ui/progressbar *= require jquery-ui/selectmenu *= require jquery-ui/slider *= require jquery-ui/spinner *= require jquery-ui/tabs *= require jquery-ui/tooltip */
For bugs in jQuery UI itself, head to thejQuery UI DevelopmentCenter.
For bugs in this gem distribution, use the GitHub issue tracker.
Thejquery-ui-rails
gem should work in Ruby 1.8.7 apps. To run the raketasks, you need Ruby 1.9 however.
git clone git://github.com/jquery-ui-rails/jquery-ui-rails.gitcd jquery-ui-railsgit submodule update --initbundle installbundleexec rake# rebuild assets
Most of the code lives in theRakefile
. Pull requests are more than welcome!
The jquery-ui-rails repository iscontributor-friendlyand has a git submodule containing the officialjquery-uirepo. This way it's easy to hack thejQuery UI code:
cd jquery-uigit checkout master# or 1-8-stable... hack-hack-hack ...bundleexec rake# rebuild assets based on your changes
Assuming your app's Gemfile points at your jquery-ui-rails checkout (gem 'jquery-ui-rails', :path => '~/path/to/jquery-ui-rails'
), all you need to donow is refresh your browser, and your changes to jQuery UI are live in yourRails application.
You can send pull requests to thejquery-ui GitHub project straight out ofyour submodule. See also theirGetting Involvedguide.
As a smoke test, atestapp
application is available in the repository, whichdisplays a check mark and a datepicker to make sure the assets load correctly:
cd testappbundle installrails server
Now point your browser athttp://localhost:3000/.
Be sure thatVERSIONS.md
,History.md
andlib/jquery/ui/rails/version.rb
are up-to-date. Then build and push like so:
rake buildgem push pkg/jquery-ui-rails-X.Y.Z.gemgit tag vX.Y.Zgit push --tags
Only the base theme (Smoothness) is included. Once it becomes possible togenerate all themefilesfrom the jQuery UI sources, we can package all the other themes in theThemeRoller gallery.
Perhaps we can also add helper tasks to help developers generate assets fortheir own custom themes or for third-party themes (likeSelene).
If you still want a different theme right now, you could probably downloada custom theme and require the theme CSSafter requiring any other jQueryUI CSS files you need, making sure to serve up the theme images correctly.(This is arguably cumbersome, not officially supported by this gem, andadds 1 KB overhead as both the base theme and the custom theme are servedup.)
About
jQuery UI for the Rails asset pipeline
Resources
License
Uh oh!
There was an error while loading.Please reload this page.