Skip to content

Commit

Permalink
Merge pull request jquery-ui-rails#105 from Borzik/jquery-ui-upgrade
Browse files Browse the repository at this point in the history
jQuery UI upgrade to 1.12
  • Loading branch information
joliss authored Nov 29, 2016
2 parents de88822 + 441a9eb commit 82e6c6e
Show file tree
Hide file tree
Showing 279 changed files with 14,520 additions and 11,722 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rvm:
- 1.9.3
- 2.2.2
4 changes: 4 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# master

# 6.0.0

* Update to jQuery UI 1.12.1

# 5.0.5

* Update to jQuery UI 1.11.4
Expand Down
61 changes: 35 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ Also add the jQuery UI CSS to your application.css:
*/
```

Warning: If you are using a version below 5.0, you will have to use a different naming
for the files to require, see https://github.com/joliss/jquery-ui-rails/blob/v4.2.1/README.md
for more information.
### Warning:
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 naming
for the files to require, please check following links for more information:
[for 5.0 users](https://github.com/joliss/jquery-ui-rails/blob/v5.0.5/README.md),
[for 4.2 users](https://github.com/joliss/jquery-ui-rails/blob/v4.2.1/README.md).

All images required by jQuery UI are automatically served through the asset
pipeline, so you are good to go! For example, this code will add a
Expand All @@ -66,10 +69,11 @@ For example, if you only need the datepicker module, add this to your
application.js:

```javascript
//= require jquery-ui/datepicker
//= require jquery-ui/widgets/datepicker
```

In your application.css, require the corresponding CSS module:
In your application.css, require the corresponding CSS module (notice
no `widgets/` subdirectory here):

```css
/*
Expand All @@ -84,7 +88,6 @@ In your application.css, require the corresponding CSS module:
```javascript
//= require jquery-ui/core
//= require jquery-ui/widget
//= require jquery-ui/mouse
//= require jquery-ui/position
```

Expand All @@ -94,31 +97,32 @@ other JavaScript modules as needed.
### Interactions

```javascript
//= require jquery-ui/draggable
//= require jquery-ui/droppable
//= require jquery-ui/resizable
//= require jquery-ui/selectable
//= require jquery-ui/sortable
//= 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 but `jquery-ui/droppable`, remember to `require` their matching CSS
For all but `jquery-ui/mouse` and `jquery-ui/droppable`, remember to `require` their matching CSS
files in your application.css as well.

### Widgets

```javascript
//= 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
//= 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 to `require` their matching CSS files in your
Expand All @@ -132,8 +136,8 @@ Datepicker has optional i18n modules for non-US locales, named
for example:

```javascript
//= require jquery-ui/datepicker
//= require jquery-ui/datepicker-pt-BR
//= 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 not
Expand All @@ -144,6 +148,11 @@ reasons](https://github.com/joliss/jquery-ui-rails/issues/9#issuecomment-6524987

```javascript
//= require jquery-ui/effect.all
```

OR

```javascript
//= require jquery-ui/effect
//= require jquery-ui/effect-blind
//= require jquery-ui/effect-bounce
Expand Down
75 changes: 48 additions & 27 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ Encoding.default_external = "UTF-8" if defined?(Encoding)
require 'json'
require 'bundler/gem_tasks'

# returns the source filename for a given JSON build file
# (e.g., "ui.core.jquery.json" returns "core.js")
def source_file_for_build_file(build_file)
"#{build_file.sub('ui.', '').sub('.jquery.json', '')}.js"
end

# returns the source filename for a named file in the 'dependencies'
# array of a JSON build file
# (e.g., if the JSON build file contains
Expand All @@ -22,30 +16,44 @@ end
#
# The only exception is "jquery", which doesn't follow the
# same naming conventions so it's a special case.
def source_file_for_dependency_entry(dep_entry)
return "jquery.js" if dep_entry == 'jquery'

"#{dep_entry.sub 'ui.', ''}.js"
def source_file_for_dependency_entry(caller, dep_entry)
p = Pathname.new caller
parent_path = p.parent
parent_path.join(dep_entry + '.js').to_s
end

# return a Hash of dependency info, whose keys are jquery-ui
# source files and values are Arrays containing the source files
# they depend on
def map_dependencies
dependencies = {}
Dir.glob("jquery-ui/*.jquery.json").each do |build_file|
build_info = JSON.parse(File.read build_file)
source_file_name = source_file_for_build_file(File.basename(build_file))
Dir.glob("jquery-ui/ui/**/*.js").each do |path|
basename = File.basename path
file = File.read path

matchdata = file.match(/define\(\s*\[\s*([\"\.\/\,\w\s-\:]+)\]/m)

next if matchdata.nil?

deps = matchdata[1]

deps = build_info['dependencies'].keys
# remove lines with comments
deps = deps.gsub(/\/\/.+\s/, "")

# remove all non-path symbols
deps = deps.gsub(/[\r\n\t\"\[\]\s]/, "")

deps_paths = deps.split(',')

deps_paths.map!(&method(:remove_js_extension))

# None of jquery.ui files should depend on jquery.js,
# so we remove 'jquery' from the list of dependencies for all files
deps.reject! {|d| d == "jquery" }
deps_paths.reject! {|d| d == "jquery" }

deps.map! {|d| source_file_for_dependency_entry d }
deps_paths.map! {|d| source_file_for_dependency_entry path, d }

dependencies[source_file_name] = deps
dependencies[basename] = deps_paths
end
dependencies
end
Expand All @@ -70,7 +78,7 @@ def get_js_dependencies(basename)
end
# Make sure we do not package assets with broken dependencies
dependencies.each do |dep|
unless File.exist?("jquery-ui/ui/#{dep}")
unless File.exist?("#{dep}")
fail "#{basename}: missing #{dep}"
end
end
Expand Down Expand Up @@ -107,13 +115,18 @@ task :javascripts => :submodule do
target_dir = "app/assets/javascripts"
target_ui_dir = "#{target_dir}/jquery-ui"
mkdir_p target_ui_dir
mkdir_p target_ui_dir + '/effects'
mkdir_p target_ui_dir + '/widgets'
mkdir_p target_ui_dir + '/i18n'

Dir.glob("jquery-ui/ui/*.js").each do |path|
Dir.glob("jquery-ui/ui/**/*.js").each do |path|
basename = File.basename(path)
clean_path = path.gsub('/ui', '')
dep_modules = get_js_dependencies(basename).map(&method(:remove_js_extension))
File.open("#{target_ui_dir}/#{basename}", "w") do |out|
File.open("#{target_dir}/#{clean_path}", "w") do |out|
dep_modules.each do |mod|
out.write("//= require jquery-ui/#{mod}\n")
mod.gsub!('/ui', '')
out.write("//= require #{mod}\n")
end
out.write("\n") unless dep_modules.empty?
source_code = File.read(path)
Expand All @@ -127,7 +140,7 @@ task :javascripts => :submodule do
# https://github.com/joliss/jquery-ui-rails/issues/9
Dir.glob("jquery-ui/ui/i18n/*.js").each do |path|
basename = File.basename(path)
File.open("#{target_ui_dir}/#{basename}", "w") do |out|
File.open("#{target_ui_dir}/i18n/#{basename}", "w") do |out|
source_code = File.read(path)
source_code.gsub!('@VERSION', version)
protect_copyright_notice(source_code)
Expand All @@ -136,15 +149,23 @@ task :javascripts => :submodule do
end

File.open("#{target_ui_dir}/effect.all.js", "w") do |out|
Dir.glob("jquery-ui/ui/effect*.js").sort.each do |path|
asset_name = remove_js_extension(File.basename(path))
out.write("//= require jquery-ui/#{asset_name}\n")
Dir.glob("jquery-ui/ui/effects/*.js").sort.each do |path|
clean_path = remove_js_extension(path).gsub('/ui', '')
out.write("//= require #{clean_path}\n")
end
end
File.open("#{target_dir}/jquery-ui.js", "w") do |out|
Dir.glob("jquery-ui/ui/*.js").sort.each do |path|
asset_name = remove_js_extension(File.basename(path))
out.write("//= require jquery-ui/#{asset_name}\n")
clean_path = remove_js_extension(path).gsub('/ui', '')
out.write("//= require #{clean_path}\n")
end
Dir.glob("jquery-ui/ui/effects/*.js").sort.each do |path|
clean_path = remove_js_extension(path).gsub('/ui', '')
out.write("//= require #{clean_path}\n")
end
Dir.glob("jquery-ui/ui/widgets/*.js").sort.each do |path|
clean_path = remove_js_extension(path).gsub('/ui', '')
out.write("//= require #{clean_path}\n")
end
end
end
Expand Down
1 change: 1 addition & 0 deletions VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

| Gem | jQuery UI |
|--------|-----------|
| 6.0.0 | 1.12.1 |
| 5.0.5 | 1.11.4 |
| 5.0.4 | 1.11.3 |
| 5.0.3 | 1.11.2 |
Expand Down
Binary file modified app/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 52 additions & 33 deletions app/assets/javascripts/jquery-ui.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,56 @@
//= require jquery-ui/accordion
//= require jquery-ui/autocomplete
//= require jquery-ui/button
//= require jquery-ui/core
//= require jquery-ui/datepicker
//= require jquery-ui/dialog
//= require jquery-ui/draggable
//= require jquery-ui/droppable
//= require jquery-ui/effect-blind
//= require jquery-ui/effect-bounce
//= require jquery-ui/effect-clip
//= require jquery-ui/effect-drop
//= require jquery-ui/effect-explode
//= require jquery-ui/effect-fade
//= require jquery-ui/effect-fold
//= require jquery-ui/effect-highlight
//= require jquery-ui/effect-puff
//= require jquery-ui/effect-pulsate
//= require jquery-ui/effect-scale
//= require jquery-ui/effect-shake
//= require jquery-ui/effect-size
//= require jquery-ui/effect-slide
//= require jquery-ui/effect-transfer
//= require jquery-ui/data
//= require jquery-ui/disable-selection
//= require jquery-ui/effect
//= require jquery-ui/menu
//= require jquery-ui/mouse
//= require jquery-ui/escape-selector
//= require jquery-ui/focusable
//= require jquery-ui/form-reset-mixin
//= require jquery-ui/form
//= require jquery-ui/ie
//= require jquery-ui/jquery-1-7
//= require jquery-ui/keycode
//= require jquery-ui/labels
//= require jquery-ui/plugin
//= require jquery-ui/position
//= require jquery-ui/progressbar
//= require jquery-ui/resizable
//= require jquery-ui/selectable
//= require jquery-ui/selectmenu
//= require jquery-ui/slider
//= require jquery-ui/sortable
//= require jquery-ui/spinner
//= require jquery-ui/tabs
//= require jquery-ui/tooltip
//= require jquery-ui/safe-active-element
//= require jquery-ui/safe-blur
//= require jquery-ui/scroll-parent
//= require jquery-ui/tabbable
//= require jquery-ui/unique-id
//= require jquery-ui/version
//= require jquery-ui/widget
//= 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/widgets/accordion
//= require jquery-ui/widgets/autocomplete
//= require jquery-ui/widgets/button
//= require jquery-ui/widgets/checkboxradio
//= require jquery-ui/widgets/controlgroup
//= require jquery-ui/widgets/datepicker
//= require jquery-ui/widgets/dialog
//= require jquery-ui/widgets/draggable
//= require jquery-ui/widgets/droppable
//= require jquery-ui/widgets/menu
//= require jquery-ui/widgets/mouse
//= require jquery-ui/widgets/progressbar
//= require jquery-ui/widgets/resizable
//= require jquery-ui/widgets/selectable
//= require jquery-ui/widgets/selectmenu
//= require jquery-ui/widgets/slider
//= require jquery-ui/widgets/sortable
//= require jquery-ui/widgets/spinner
//= require jquery-ui/widgets/tabs
//= require jquery-ui/widgets/tooltip
Loading

0 comments on commit 82e6c6e

Please sign in to comment.