Module: ActionView::Helpers::ScriptaculousHelper
- Defined in:
- lib/jrails.rb
Constant Summary collapse
- TOGGLE_EFFECTS =
[:toggle_appear, :toggle_slide, :toggle_blind]
- SCRIPTACULOUS_EFFECTS =
{ :appear => {:method => 'fade', :options => {:mode => 'show'}}, :blind_down => {:method => 'blind', :options => {:direction => 'vertical', :mode => 'show'}}, :blind_up => {:method => 'blind', :options => {:direction => 'vertical', :mode => 'hide'}}, :blind_right => {:method => 'blind', :options => {:direction => 'horizontal', :mode => 'show'}}, :blind_left => {:method => 'blind', :options => {:direction => 'horizontal', :mode => 'hide'}}, :bounce_in => {:method => 'bounce', :options => {:direction => 'up', :mode => 'show'}}, :bounce_out => {:method => 'bounce', :options => {:direction => 'up', :mode => 'hide'}}, :drop_in => {:method => 'drop', :options => {:direction => 'up', :mode => 'show'}}, :drop_out => {:method => 'drop', :options => {:direction => 'down', :mode => 'hide'}}, :fold_in => {:method => 'fold', :options => {:mode => 'hide'}}, :fold_out => {:method => 'fold', :options => {:mode => 'show'}}, :grow => {:method => 'scale', :options => {:mode => 'show'}}, :shrink => {:method => 'scale', :options => {:mode => 'hide'}}, :slide_down => {:method => 'slide', :options => {:direction => 'up', :mode => 'show'}}, :slide_up => {:method => 'slide', :options => {:direction => 'up', :mode => 'hide'}}, :slide_right => {:method => 'slide', :options => {:direction => 'left', :mode => 'show'}}, :slide_left => {:method => 'slide', :options => {:direction => 'left', :mode => 'hide'}}, :squish => {:method => 'scale', :options => {:origin => '["top","left"]', :mode => 'hide'}}, :switch_on => {:method => 'clip', :options => {:direction => 'vertical', :mode => 'show'}}, :switch_off => {:method => 'clip', :options => {:direction => 'vertical', :mode => 'hide'}} }
Instance Method Summary collapse
- #draggable_element_js(element_id, options = {}) ⇒ Object
- #drop_receiving_element_js(element_id, options = {}) ⇒ Object
-
#sortable_element_js(element_id, options = {}) ⇒ Object
:nodoc:.
- #visual_effect(name, element_id = false, js_options = {}) ⇒ Object
Instance Method Details
#draggable_element_js(element_id, options = {}) ⇒ Object
259 260 261 |
# File 'lib/jrails.rb', line 259 def draggable_element_js(element_id, = {}) %($("##{element_id}").draggable(#{()});) end |
#drop_receiving_element_js(element_id, options = {}) ⇒ Object
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/jrails.rb', line 263 def drop_receiving_element_js(element_id, = {}) #convert similar options [:hoverClass] = .delete(:hoverclass) if [:hoverclass] [:drop] = .delete(:onDrop) if [:onDrop] if [:drop] || [:url] [:with] ||= "'id=' + encodeURIComponent($(ui.draggable).clone().attr('id'))" [:drop] ||= "function(ev, ui){" + remote_function() + "}" end .delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) } [:accept] = array_or_string_for_javascript([:accept]) if [:accept] [:hoverClass] = "'#{[:hoverClass]}'" if [:hoverClass] %($("##{element_id}").droppable(#{()});) end |
#sortable_element_js(element_id, options = {}) ⇒ Object
:nodoc:
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/jrails.rb', line 237 def sortable_element_js(element_id, = {}) #:nodoc: #convert similar attributes [:items] = [:only] if [:only] if [:onUpdate] || [:url] [:with] ||= "$(this).sortable('serialize')" [:onUpdate] ||= "function(){" + remote_function() + "}" end .delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) } [:update] = .delete(:onUpdate) if [:onUpdate] [:handle].each do |option| [option] = "'#{[option]}'" if [option] end [:containment] = array_or_string_for_javascript([:containment]) if [:containment] [:items] = array_or_string_for_javascript([:items]) if [:items] %($("##{element_id}").sortable(#{()});) end |
#visual_effect(name, element_id = false, js_options = {}) ⇒ Object
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/jrails.rb', line 207 def visual_effect(name, element_id = false, = {}) element = element_id ? element_id : "this" if SCRIPTACULOUS_EFFECTS.has_key? name.to_sym effect = SCRIPTACULOUS_EFFECTS[name.to_sym] name = effect[:method] = .merge effect[:options] end [:color, :direction, :mode].each do |option| [option] = "\"#{[option]}\"" if [option] end if .has_key? :duration speed = .delete :duration speed = (speed * 1000).to_i unless speed.nil? else speed = .delete :speed end #if TOGGLE_EFFECTS.include? name.to_sym # "Effect.toggle(#{element},'#{name.to_s.gsub(/^toggle_/,'')}',#{options_for_javascript(js_options)});" javascript = "$(\"##{element_id}\").effect(\"#{name.to_s.downcase}\"" javascript << ",#{()}" unless speed.nil? && .empty? javascript << ",#{speed}" unless speed.nil? javascript << ")" end |