Module: ActionView::Helpers::ScriptaculousHelper
- Defined in:
- lib/jrails.rb
Constant Summary collapse
- JQUERY_VAR =
PrototypeHelper::JQUERY_VAR
- SCRIPTACULOUS_EFFECTS =
{ :appear => {:method => 'fadeIn'}, :blind_down => {:method => 'blind', :mode => 'show', :options => {:direction => 'vertical'}}, :blind_up => {:method => 'blind', :mode => 'hide', :options => {:direction => 'vertical'}}, :blind_right => {:method => 'blind', :mode => 'show', :options => {:direction => 'horizontal'}}, :blind_left => {:method => 'blind', :mode => 'hide', :options => {:direction => 'horizontal'}}, :bounce_in => {:method => 'bounce', :mode => 'show', :options => {:direction => 'up'}}, :bounce_out => {:method => 'bounce', :mode => 'hide', :options => {:direction => 'up'}}, :drop_in => {:method => 'drop', :mode => 'show', :options => {:direction => 'up'}}, :drop_out => {:method => 'drop', :mode => 'hide', :options => {:direction => 'down'}}, :fade => {:method => 'fadeOut'}, :fold_in => {:method => 'fold', :mode => 'hide'}, :fold_out => {:method => 'fold', :mode => 'show'}, :grow => {:method => 'scale', :mode => 'show'}, :shrink => {:method => 'scale', :mode => 'hide'}, :slide_down => {:method => 'slide', :mode => 'show', :options => {:direction => 'up'}}, :slide_up => {:method => 'slide', :mode => 'hide', :options => {:direction => 'up'}}, :slide_right => {:method => 'slide', :mode => 'show', :options => {:direction => 'left'}}, :slide_left => {:method => 'slide', :mode => 'hide', :options => {:direction => 'left'}}, :squish => {:method => 'scale', :mode => 'hide', :options => {:origin => "['top','left']"}}, :switch_on => {:method => 'clip', :mode => 'show', :options => {:direction => 'vertical'}}, :switch_off => {:method => 'clip', :mode => 'hide', :options => {:direction => 'vertical'}}, :toggle_appear => {:method => 'fadeToggle'}, :toggle_slide => {:method => 'slide', :mode => 'toggle', :options => {:direction => 'up'}}, :toggle_blind => {:method => 'blind', :mode => 'toggle', :options => {:direction => 'vertical'}}, }
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
396 397 398 |
# File 'lib/jrails.rb', line 396 def draggable_element_js(element_id, = {}) %(#{JQUERY_VAR}("#{jquery_id(element_id)}").draggable(#{()});) end |
#drop_receiving_element_js(element_id, options = {}) ⇒ Object
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/jrails.rb', line 400 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(#{JQUERY_VAR}(ui.draggable).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] [:activeClass, :hoverClass, :tolerance].each do |option| [option] = "'#{[option]}'" if [option] end %(#{JQUERY_VAR}('#{jquery_id(element_id)}').droppable(#{()});) end |
#sortable_element_js(element_id, options = {}) ⇒ Object
:nodoc:
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/jrails.rb', line 347 def sortable_element_js(element_id, = {}) #:nodoc: #convert similar attributes [:handle] = ".#{[:handle]}" if [:handle] if [:tag] || [:only] [:items] = "> " [:items] << .delete(:tag) if [:tag] [:items] << ".#{.delete(:only)}" if [:only] end [:connectWith] = .delete(:containment).map {|x| "##{x}"} if [:containment] [:containment] = .delete(:container) if [:container] [:dropOnEmpty] = false unless [:dropOnEmpty] [:helper] = "'clone'" if [:ghosting] == true [:axis] = case .delete(:constraint) when "vertical", :vertical "y" when "horizontal", :horizontal "x" when false nil when nil "y" end .delete(:axis) if [:axis].nil? .delete(:overlap) .delete(:ghosting) if [:onUpdate] || [:url] if [:format] [:with] ||= "#{JQUERY_VAR}(this).sortable('serialize',{key:'#{element_id}[]', expression:#{[:format]}})" .delete(:format) else [:with] ||= "#{JQUERY_VAR}(this).sortable('serialize',{key:'#{element_id}[]'})" end [:onUpdate] ||= "function(){" + remote_function() + "}" end .delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) } [:update] = .delete(:onUpdate) if [:onUpdate] [:axis, :cancel, :containment, :cursor, :handle, :tolerance, :items, :placeholder].each do |option| [option] = "'#{[option]}'" if [option] end [:connectWith] = array_or_string_for_javascript([:connectWith]) if [:connectWith] %(#{JQUERY_VAR}('#{jquery_id(element_id)}').sortable(#{()});) end |
#visual_effect(name, element_id = false, js_options = {}) ⇒ Object
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/jrails.rb', line 311 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] mode = effect[:mode] = .merge(effect[:options]) if effect[:options] end [:color, :direction, :startcolor, :endcolor].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 ['fadeIn','fadeOut','fadeToggle'].include?(name) # 090905 - Jake - changed ' to \" so it passes assert_select_rjs with an id javascript = "#{JQUERY_VAR}(\"#{jquery_id(element_id)}\").#{name}(" javascript << "#{speed}" unless speed.nil? javascript << ");" else # 090905 - Jake - changed ' to \" so it passes "assert_select_rjs :effect, ID" javascript = "#{JQUERY_VAR}(\"#{jquery_id(element_id)}\").#{mode || 'effect'}('#{name}'" javascript << ",#{()}" unless speed.nil? && .empty? javascript << ",#{speed}" unless speed.nil? javascript << ");" end end |