Class: Lapillus::Draggable

Inherits:
UniqueIdentifier show all
Defined in:
lib/lapillus/behaviours.rb

Instance Attribute Summary

Attributes inherited from Component

#behaviours, #identifier, #model, #property, #visible

Instance Method Summary collapse

Methods inherited from UniqueIdentifier

#value

Methods inherited from Component

#add_behaviour, #behaviour, #has_behaviour?, #has_model?, #has_parent?, #on_render, #parent, #path, #render_component, #response_page=, #session, #value, #visible?, #webpage

Constructor Details

#initialize(options = []) ⇒ Draggable

Returns a new instance of Draggable.



60
61
62
63
64
# File 'lib/lapillus/behaviours.rb', line 60

def initialize(options=[])
  super()
  @extra_options=options.to_a
  @option=Hash.new
end

Instance Method Details

#change=(value) ⇒ Object



102
103
104
# File 'lib/lapillus/behaviours.rb', line 102

def change= value
  @option[:change]= value
end

#constraint=(value) ⇒ Object



82
83
84
# File 'lib/lapillus/behaviours.rb', line 82

def constraint= value
  @option[:constraint]="'#{value}'"
end

#end_effect=(value) ⇒ Object



98
99
100
# File 'lib/lapillus/behaviours.rb', line 98

def end_effect= value
  @option[:endeffect]= value
end

#ghosting=(value) ⇒ Object



86
87
88
# File 'lib/lapillus/behaviours.rb', line 86

def ghosting= value
  @option[:ghosting]= value ? "true" : "false"
end

#handle=(handleclass) ⇒ Object



66
67
68
# File 'lib/lapillus/behaviours.rb', line 66

def handle= handleclass
  @option[:handle] = "'#{handleclass}'"
end

#render_to_element(element) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/lapillus/behaviours.rb', line 106

def render_to_element(element)
  super
  #add_javascript_to_header(element.root_node,"/editiemachine/context/javascript/prototype.js")
  #add_javascript_to_header(element.root_node,"/editiemachine/context/javascript/scriptaculous.js")
  
  script = REXML::Element.new('script')
  script.add_attributes({'type'=>'text/javascript', 'language'=>'javascript'})
  options=@option.to_a.collect{|o| "#{o[0]}:#{o[1]}" }.sort.concat(@extra_options).join(",")
  text=REXML::Text.new("\n// <![CDATA[\nnew Draggable('#{parent.path}', {#{options}});\n// ]]>\n")
  def text.to_s
    @normalized=@string
  end
  script.add_text(text)
  element.add_element(script)
end

#revert=(value) ⇒ Object



70
71
72
# File 'lib/lapillus/behaviours.rb', line 70

def revert= value
  @option[:revert]= value ? "true" : "false"
end

#revert_effect=(value) ⇒ Object



94
95
96
# File 'lib/lapillus/behaviours.rb', line 94

def revert_effect= value
  @option[:reverteffect]= value
end

#snap=(value) ⇒ Object



74
75
76
# File 'lib/lapillus/behaviours.rb', line 74

def snap= value
  @option[:snap]= value ? "true" : "false"
end

#start_effect=(value) ⇒ Object



90
91
92
# File 'lib/lapillus/behaviours.rb', line 90

def start_effect= value
  @option[:starteffect]= value
end

#zindex=(value) ⇒ Object



78
79
80
# File 'lib/lapillus/behaviours.rb', line 78

def zindex= value
  @option[:zindex]= value
end