eita-jrails 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/action_view/helpers/{proxies.rb → javascript_proxies.rb} +0 -2
- data/lib/action_view/helpers/jquery_helper.rb +2 -2
- data/lib/action_view/helpers/{generator.rb → jquery_helper/generator.rb} +26 -0
- data/lib/action_view/helpers/jquery_ui_helper.rb +10 -11
- metadata +53 -13
- data/lib/action_view/helpers/scriptaculous_helper.rb +0 -263
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0462f93583c291aed4e06b26f5a37c50ff776fdd
|
4
|
+
data.tar.gz: f44293654e643e839c5df6b86715c4bd6ac929af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7689ec616fb7c5bcce9f2aef73779e4ea25112cd6de1d5c9449efc932ce7d10b530fb244a7d69ed96554d34478609e337f4da1604de06261a4874bee936767c6
|
7
|
+
data.tar.gz: 3d8c0796930dc14ae7d700fbe46cf89382d924956a2ba663481bcf5f161ad8a062bd8abb94a458753664ebdb94f6bf21538be284a8bf7ade2a4e279a4e304086
|
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
jRails
|
2
2
|
======
|
3
3
|
|
4
|
-
jRails is a drop-in jQuery replacement for the prototope-rails gem, so that you can still use RJS and Jquery/JqueryUi helpers with the same API as Prototype/Scryptaculous helpers
|
4
|
+
jRails is a drop-in jQuery replacement for the prototope-rails gem, so that you can still use RJS and Jquery/JqueryUi helpers with the same API as Prototype/Scryptaculous helpers.
|
5
5
|
|
6
|
-
|
6
|
+
Based on prototype-rails gem.
|
7
|
+
|
8
|
+
Support Rails 3.1+.
|
7
9
|
|
8
10
|
Install
|
9
11
|
-------
|
@@ -231,6 +231,32 @@ module ActionView
|
|
231
231
|
record "window.location.href = #{url.inspect}"
|
232
232
|
end
|
233
233
|
|
234
|
+
# Starts a script.aculo.us visual effect. See
|
235
|
+
# ActionView::Helpers::ScriptaculousHelper for more information.
|
236
|
+
def visual_effect(name, id = nil, options = {})
|
237
|
+
record @context.send(:visual_effect, name, id, options)
|
238
|
+
end
|
239
|
+
|
240
|
+
# Creates a script.aculo.us sortable element. Useful
|
241
|
+
# to recreate sortable elements after items get added
|
242
|
+
# or deleted.
|
243
|
+
# See ActionView::Helpers::ScriptaculousHelper for more information.
|
244
|
+
def sortable(id, options = {})
|
245
|
+
record @context.send(:sortable_element_js, id, options)
|
246
|
+
end
|
247
|
+
|
248
|
+
# Creates a script.aculo.us draggable element.
|
249
|
+
# See ActionView::Helpers::ScriptaculousHelper for more information.
|
250
|
+
def draggable(id, options = {})
|
251
|
+
record @context.send(:draggable_element_js, id, options)
|
252
|
+
end
|
253
|
+
|
254
|
+
# Creates a script.aculo.us drop receiving element.
|
255
|
+
# See ActionView::Helpers::ScriptaculousHelper for more information.
|
256
|
+
def drop_receiving(id, options = {})
|
257
|
+
record @context.send(:drop_receiving_element_js, id, options)
|
258
|
+
end
|
259
|
+
|
234
260
|
# Reloads the browser's current +location+ using JavaScript
|
235
261
|
#
|
236
262
|
# Examples:
|
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
module ActionView
|
2
3
|
module Helpers
|
3
4
|
|
@@ -51,13 +52,11 @@ module ActionView
|
|
51
52
|
speed = js_options.delete :speed
|
52
53
|
end
|
53
54
|
|
54
|
-
if [
|
55
|
-
# 090905 - Jake - changed ' to \" so it passes assert_select_rjs with an id
|
55
|
+
if %w[fadeIn fadeOut fadeToggle].include? name
|
56
56
|
javascript = "#{JQUERY_VAR}(\"#{jquery_id(element_id)}\").#{name}("
|
57
57
|
javascript << "#{speed}" unless speed.nil?
|
58
58
|
javascript << ");"
|
59
59
|
else
|
60
|
-
# 090905 - Jake - changed ' to \" so it passes "assert_select_rjs :effect, ID"
|
61
60
|
javascript = "#{JQUERY_VAR}(\"#{jquery_id(element_id)}\").#{mode || 'effect'}('#{name}'"
|
62
61
|
javascript << ",#{options_for_javascript(js_options)}" unless speed.nil? && js_options.empty?
|
63
62
|
javascript << ",#{speed}" unless speed.nil?
|
@@ -66,14 +65,6 @@ module ActionView
|
|
66
65
|
|
67
66
|
end
|
68
67
|
|
69
|
-
def drop_receiving_element(element_id, options = {})
|
70
|
-
javascript_tag(drop_receiving_element_js(element_id, options).chop!)
|
71
|
-
end
|
72
|
-
|
73
|
-
def draggable_element(element_id, options = {})
|
74
|
-
javascript_tag(draggable_element_js(element_id, options).chop!)
|
75
|
-
end
|
76
|
-
|
77
68
|
def sortable_element(element_id, options = {})
|
78
69
|
javascript_tag(sortable_element_js(element_id, options).chop!)
|
79
70
|
end
|
@@ -127,10 +118,18 @@ module ActionView
|
|
127
118
|
%(#{JQUERY_VAR}('#{jquery_id(element_id)}').sortable(#{options_for_javascript(options)});)
|
128
119
|
end
|
129
120
|
|
121
|
+
def draggable_element(element_id, options = {})
|
122
|
+
javascript_tag(draggable_element_js(element_id, options).chop!)
|
123
|
+
end
|
124
|
+
|
130
125
|
def draggable_element_js(element_id, options = {})
|
131
126
|
%(#{JQUERY_VAR}("#{jquery_id(element_id)}").draggable(#{options_for_javascript(options)});)
|
132
127
|
end
|
133
128
|
|
129
|
+
def drop_receiving_element(element_id, options = {})
|
130
|
+
javascript_tag(drop_receiving_element_js(element_id, options).chop!)
|
131
|
+
end
|
132
|
+
|
134
133
|
def drop_receiving_element_js(element_id, options = {})
|
135
134
|
#convert similar options
|
136
135
|
options[:hoverClass] = options.delete(:hoverclass) if options[:hoverclass]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eita-jrails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Eisenberger
|
@@ -11,10 +11,49 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-10-
|
15
|
-
dependencies:
|
16
|
-
|
17
|
-
|
14
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: activesupport
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.2'
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 3.0.0
|
26
|
+
type: :runtime
|
27
|
+
prerelease: false
|
28
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.2'
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 3.0.0
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: actionpack
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '3.2'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.1.0
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '3.2'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 3.1.0
|
56
|
+
description:
|
18
57
|
email: braulio@eita.org.br
|
19
58
|
executables:
|
20
59
|
- jrails
|
@@ -48,11 +87,10 @@ files:
|
|
48
87
|
- assets/javascripts/jrails/jrails.min.js
|
49
88
|
- assets/stylesheets/smoothness/jquery-ui.css
|
50
89
|
- bin/jrails
|
51
|
-
- lib/action_view/helpers/
|
90
|
+
- lib/action_view/helpers/javascript_proxies.rb
|
52
91
|
- lib/action_view/helpers/jquery_helper.rb
|
92
|
+
- lib/action_view/helpers/jquery_helper/generator.rb
|
53
93
|
- lib/action_view/helpers/jquery_ui_helper.rb
|
54
|
-
- lib/action_view/helpers/proxies.rb
|
55
|
-
- lib/action_view/helpers/scriptaculous_helper.rb
|
56
94
|
- lib/action_view/template/handlers/rjs.rb
|
57
95
|
- lib/jrails.rb
|
58
96
|
- lib/jrails/asset_tag_ext.rb
|
@@ -65,7 +103,8 @@ files:
|
|
65
103
|
- lib/jrails/selector_assertions.rb
|
66
104
|
- lib/tasks/jrails.rake
|
67
105
|
homepage: http://github.com/coletivoEITA/jrails
|
68
|
-
licenses:
|
106
|
+
licenses:
|
107
|
+
- MIT
|
69
108
|
metadata: {}
|
70
109
|
post_install_message:
|
71
110
|
rdoc_options:
|
@@ -76,16 +115,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
115
|
requirements:
|
77
116
|
- - ">="
|
78
117
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
118
|
+
version: 1.9.3
|
80
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
120
|
requirements:
|
82
121
|
- - ">="
|
83
122
|
- !ruby/object:Gem::Version
|
84
123
|
version: '0'
|
85
124
|
requirements: []
|
86
|
-
rubyforge_project:
|
125
|
+
rubyforge_project:
|
87
126
|
rubygems_version: 2.2.2
|
88
127
|
signing_key:
|
89
|
-
specification_version:
|
90
|
-
summary:
|
128
|
+
specification_version: 4
|
129
|
+
summary: RJS and JqueryHelper/JqueryUiHelper with the same API from prototype-rails
|
130
|
+
gem, for Rails 3.1+
|
91
131
|
test_files: []
|
@@ -1,263 +0,0 @@
|
|
1
|
-
require 'action_view/helpers/javascript_helper'
|
2
|
-
require 'active_support/json'
|
3
|
-
|
4
|
-
module ActionView
|
5
|
-
# = Action View Scriptaculous Helpers
|
6
|
-
module Helpers
|
7
|
-
# Provides a set of helpers for calling Scriptaculous[http://script.aculo.us/]
|
8
|
-
# JavaScript functions, including those which create Ajax controls and visual
|
9
|
-
# effects.
|
10
|
-
#
|
11
|
-
# To be able to use these helpers, you must include the Prototype
|
12
|
-
# JavaScript framework and the Scriptaculous JavaScript library in your
|
13
|
-
# pages. See the documentation for ActionView::Helpers::JavaScriptHelper
|
14
|
-
# for more information on including the necessary JavaScript.
|
15
|
-
#
|
16
|
-
# The Scriptaculous helpers' behavior can be tweaked with various options.
|
17
|
-
#
|
18
|
-
# See the documentation at http://script.aculo.us for more information on
|
19
|
-
# using these helpers in your application.
|
20
|
-
module ScriptaculousHelper
|
21
|
-
TOGGLE_EFFECTS = [:toggle_appear, :toggle_slide, :toggle_blind]
|
22
|
-
|
23
|
-
# Returns a JavaScript snippet to be used on the Ajax callbacks for
|
24
|
-
# starting visual effects.
|
25
|
-
#
|
26
|
-
# If no +element_id+ is given, it assumes "element" which should be a local
|
27
|
-
# variable in the generated JavaScript execution context. This can be
|
28
|
-
# used for example with +drop_receiving_element+:
|
29
|
-
#
|
30
|
-
# <%= drop_receiving_element (...), :loading => visual_effect(:fade) %>
|
31
|
-
#
|
32
|
-
# This would fade the element that was dropped on the drop receiving
|
33
|
-
# element.
|
34
|
-
#
|
35
|
-
# For toggling visual effects, you can use <tt>:toggle_appear</tt>, <tt>:toggle_slide</tt>, and
|
36
|
-
# <tt>:toggle_blind</tt> which will alternate between appear/fade, slidedown/slideup, and
|
37
|
-
# blinddown/blindup respectively.
|
38
|
-
#
|
39
|
-
# You can change the behaviour with various options, see
|
40
|
-
# http://script.aculo.us for more documentation.
|
41
|
-
def visual_effect(name, element_id = false, js_options = {})
|
42
|
-
element = element_id ? ActiveSupport::JSON.encode(element_id) : "element"
|
43
|
-
|
44
|
-
js_options[:queue] = if js_options[:queue].is_a?(Hash)
|
45
|
-
'{' + js_options[:queue].map {|k, v| k == :limit ? "#{k}:#{v}" : "#{k}:'#{v}'" }.join(',') + '}'
|
46
|
-
elsif js_options[:queue]
|
47
|
-
"'#{js_options[:queue]}'"
|
48
|
-
end if js_options[:queue]
|
49
|
-
|
50
|
-
[:endcolor, :direction, :startcolor, :scaleMode, :restorecolor].each do |option|
|
51
|
-
js_options[option] = "'#{js_options[option]}'" if js_options[option]
|
52
|
-
end
|
53
|
-
|
54
|
-
if TOGGLE_EFFECTS.include? name.to_sym
|
55
|
-
"Effect.toggle(#{element},'#{name.to_s.gsub(/^toggle_/,'')}',#{options_for_javascript(js_options)});"
|
56
|
-
else
|
57
|
-
"new Effect.#{name.to_s.camelize}(#{element},#{options_for_javascript(js_options)});"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# Makes the element with the DOM ID specified by +element_id+ sortable
|
62
|
-
# by drag-and-drop and make an Ajax call whenever the sort order has
|
63
|
-
# changed. By default, the action called gets the serialized sortable
|
64
|
-
# element as parameters.
|
65
|
-
#
|
66
|
-
# Example:
|
67
|
-
#
|
68
|
-
# <%= sortable_element("my_list", :url => { :action => "order" }) %>
|
69
|
-
#
|
70
|
-
# In the example, the action gets a "my_list" array parameter
|
71
|
-
# containing the values of the ids of elements the sortable consists
|
72
|
-
# of, in the current order.
|
73
|
-
#
|
74
|
-
# Important: For this to work, the sortable elements must have id
|
75
|
-
# attributes in the form "string_identifier". For example, "item_1". Only
|
76
|
-
# the identifier part of the id attribute will be serialized.
|
77
|
-
#
|
78
|
-
# Additional +options+ are:
|
79
|
-
#
|
80
|
-
# * <tt>:format</tt> - A regular expression to determine what to send as the
|
81
|
-
# serialized id to the server (the default is <tt>/^[^_]*_(.*)$/</tt>).
|
82
|
-
#
|
83
|
-
# * <tt>:constraint</tt> - Whether to constrain the dragging to either
|
84
|
-
# <tt>:horizontal</tt> or <tt>:vertical</tt> (or false to make it unconstrained).
|
85
|
-
#
|
86
|
-
# * <tt>:overlap</tt> - Calculate the item overlap in the <tt>:horizontal</tt>
|
87
|
-
# or <tt>:vertical</tt> direction.
|
88
|
-
#
|
89
|
-
# * <tt>:tag</tt> - Which children of the container element to treat as
|
90
|
-
# sortable (default is <tt>li</tt>).
|
91
|
-
#
|
92
|
-
# * <tt>:containment</tt> - Takes an element or array of elements to treat as
|
93
|
-
# potential drop targets (defaults to the original target element).
|
94
|
-
#
|
95
|
-
# * <tt>:only</tt> - A CSS class name or array of class names used to filter
|
96
|
-
# out child elements as candidates.
|
97
|
-
#
|
98
|
-
# * <tt>:scroll</tt> - Determines whether to scroll the list during drag
|
99
|
-
# operations if the list runs past the visual border.
|
100
|
-
#
|
101
|
-
# * <tt>:tree</tt> - Determines whether to treat nested lists as part of the
|
102
|
-
# main sortable list. This means that you can create multi-layer lists,
|
103
|
-
# and not only sort items at the same level, but drag and sort items
|
104
|
-
# between levels.
|
105
|
-
#
|
106
|
-
# * <tt>:hoverclass</tt> - If set, the Droppable will have this additional CSS class
|
107
|
-
# when an accepted Draggable is hovered over it.
|
108
|
-
#
|
109
|
-
# * <tt>:handle</tt> - Sets whether the element should only be draggable by an
|
110
|
-
# embedded handle. The value may be a string referencing a CSS class value
|
111
|
-
# (as of script.aculo.us V1.5). The first child/grandchild/etc. element
|
112
|
-
# found within the element that has this CSS class value will be used as
|
113
|
-
# the handle.
|
114
|
-
#
|
115
|
-
# * <tt>:ghosting</tt> - Clones the element and drags the clone, leaving
|
116
|
-
# the original in place until the clone is dropped (default is <tt>false</tt>).
|
117
|
-
#
|
118
|
-
# * <tt>:dropOnEmpty</tt> - If true the Sortable container will be made into
|
119
|
-
# a Droppable, that can receive a Draggable (as according to the containment
|
120
|
-
# rules) as a child element when there are no more elements inside (default
|
121
|
-
# is <tt>false</tt>).
|
122
|
-
#
|
123
|
-
# * <tt>:onChange</tt> - Called whenever the sort order changes while dragging. When
|
124
|
-
# dragging from one Sortable to another, the callback is called once on each
|
125
|
-
# Sortable. Gets the affected element as its parameter.
|
126
|
-
#
|
127
|
-
# * <tt>:onUpdate</tt> - Called when the drag ends and the Sortable's order is
|
128
|
-
# changed in any way. When dragging from one Sortable to another, the callback
|
129
|
-
# is called once on each Sortable. Gets the container as its parameter.
|
130
|
-
#
|
131
|
-
# See http://script.aculo.us for more documentation.
|
132
|
-
def sortable_element(element_id, options = {})
|
133
|
-
javascript_tag(sortable_element_js(element_id, options).chop!)
|
134
|
-
end
|
135
|
-
|
136
|
-
def sortable_element_js(element_id, options = {}) #:nodoc:
|
137
|
-
options[:with] ||= "Sortable.serialize(#{ActiveSupport::JSON.encode(element_id)})"
|
138
|
-
options[:onUpdate] ||= "function(){" + remote_function(options) + "}"
|
139
|
-
options.delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) }
|
140
|
-
|
141
|
-
[:tag, :overlap, :constraint, :handle].each do |option|
|
142
|
-
options[option] = "'#{options[option]}'" if options[option]
|
143
|
-
end
|
144
|
-
|
145
|
-
options[:containment] = array_or_string_for_javascript(options[:containment]) if options[:containment]
|
146
|
-
options[:only] = array_or_string_for_javascript(options[:only]) if options[:only]
|
147
|
-
|
148
|
-
%(Sortable.create(#{ActiveSupport::JSON.encode(element_id)}, #{options_for_javascript(options)});)
|
149
|
-
end
|
150
|
-
|
151
|
-
# Makes the element with the DOM ID specified by +element_id+ draggable.
|
152
|
-
#
|
153
|
-
# Example:
|
154
|
-
# <%= draggable_element("my_image", :revert => true)
|
155
|
-
#
|
156
|
-
# You can change the behaviour with various options, see
|
157
|
-
# http://script.aculo.us for more documentation.
|
158
|
-
def draggable_element(element_id, options = {})
|
159
|
-
javascript_tag(draggable_element_js(element_id, options).chop!)
|
160
|
-
end
|
161
|
-
|
162
|
-
def draggable_element_js(element_id, options = {}) #:nodoc:
|
163
|
-
%(new Draggable(#{ActiveSupport::JSON.encode(element_id)}, #{options_for_javascript(options)});)
|
164
|
-
end
|
165
|
-
|
166
|
-
# Makes the element with the DOM ID specified by +element_id+ receive
|
167
|
-
# dropped draggable elements (created by +draggable_element+).
|
168
|
-
# and make an AJAX call. By default, the action called gets the DOM ID
|
169
|
-
# of the element as parameter.
|
170
|
-
#
|
171
|
-
# Example:
|
172
|
-
# <%= drop_receiving_element("my_cart", :url =>
|
173
|
-
# { :controller => "cart", :action => "add" }) %>
|
174
|
-
#
|
175
|
-
# You can change the behaviour with various options, see
|
176
|
-
# http://script.aculo.us for more documentation.
|
177
|
-
#
|
178
|
-
# Some of these +options+ include:
|
179
|
-
# * <tt>:accept</tt> - Set this to a string or an array of strings describing the
|
180
|
-
# allowable CSS classes that the +draggable_element+ must have in order
|
181
|
-
# to be accepted by this +drop_receiving_element+.
|
182
|
-
#
|
183
|
-
# * <tt>:confirm</tt> - Adds a confirmation dialog. Example:
|
184
|
-
#
|
185
|
-
# :confirm => "Are you sure you want to do this?"
|
186
|
-
#
|
187
|
-
# * <tt>:hoverclass</tt> - If set, the +drop_receiving_element+ will have
|
188
|
-
# this additional CSS class when an accepted +draggable_element+ is
|
189
|
-
# hovered over it.
|
190
|
-
#
|
191
|
-
# * <tt>:onDrop</tt> - Called when a +draggable_element+ is dropped onto
|
192
|
-
# this element. Override this callback with a JavaScript expression to
|
193
|
-
# change the default drop behaviour. Example:
|
194
|
-
#
|
195
|
-
# :onDrop => "function(draggable_element, droppable_element, event) { alert('I like bananas') }"
|
196
|
-
#
|
197
|
-
# This callback gets three parameters: The Draggable element, the Droppable
|
198
|
-
# element and the Event object. You can extract additional information about
|
199
|
-
# the drop - like if the Ctrl or Shift keys were pressed - from the Event object.
|
200
|
-
#
|
201
|
-
# * <tt>:with</tt> - A JavaScript expression specifying the parameters for
|
202
|
-
# the XMLHttpRequest. Any expressions should return a valid URL query string.
|
203
|
-
def drop_receiving_element(element_id, options = {})
|
204
|
-
javascript_tag(drop_receiving_element_js(element_id, options).chop!)
|
205
|
-
end
|
206
|
-
|
207
|
-
def drop_receiving_element_js(element_id, options = {}) #:nodoc:
|
208
|
-
options[:with] ||= "'id=' + encodeURIComponent(element.id)"
|
209
|
-
options[:onDrop] ||= "function(element){" + remote_function(options) + "}"
|
210
|
-
options.delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) }
|
211
|
-
|
212
|
-
options[:accept] = array_or_string_for_javascript(options[:accept]) if options[:accept]
|
213
|
-
options[:hoverclass] = "'#{options[:hoverclass]}'" if options[:hoverclass]
|
214
|
-
|
215
|
-
# Confirmation happens during the onDrop callback, so it can be removed from the options
|
216
|
-
options.delete(:confirm) if options[:confirm]
|
217
|
-
|
218
|
-
%(Droppables.add(#{ActiveSupport::JSON.encode(element_id)}, #{options_for_javascript(options)});)
|
219
|
-
end
|
220
|
-
|
221
|
-
protected
|
222
|
-
def array_or_string_for_javascript(option)
|
223
|
-
if option.kind_of?(Array)
|
224
|
-
"['#{option.join('\',\'')}']"
|
225
|
-
elsif !option.nil?
|
226
|
-
"'#{option}'"
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
module PrototypeHelper
|
232
|
-
class JavaScriptGenerator
|
233
|
-
module GeneratorMethods
|
234
|
-
# Starts a script.aculo.us visual effect. See
|
235
|
-
# ActionView::Helpers::ScriptaculousHelper for more information.
|
236
|
-
def visual_effect(name, id = nil, options = {})
|
237
|
-
record @context.send(:visual_effect, name, id, options)
|
238
|
-
end
|
239
|
-
|
240
|
-
# Creates a script.aculo.us sortable element. Useful
|
241
|
-
# to recreate sortable elements after items get added
|
242
|
-
# or deleted.
|
243
|
-
# See ActionView::Helpers::ScriptaculousHelper for more information.
|
244
|
-
def sortable(id, options = {})
|
245
|
-
record @context.send(:sortable_element_js, id, options)
|
246
|
-
end
|
247
|
-
|
248
|
-
# Creates a script.aculo.us draggable element.
|
249
|
-
# See ActionView::Helpers::ScriptaculousHelper for more information.
|
250
|
-
def draggable(id, options = {})
|
251
|
-
record @context.send(:draggable_element_js, id, options)
|
252
|
-
end
|
253
|
-
|
254
|
-
# Creates a script.aculo.us drop receiving element.
|
255
|
-
# See ActionView::Helpers::ScriptaculousHelper for more information.
|
256
|
-
def drop_receiving(id, options = {})
|
257
|
-
record @context.send(:drop_receiving_element_js, id, options)
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|