Module: Ropenlayer::JsHelper::Jquery

Defined in:
lib/ropenlayer/js_helper/jquery.rb

Class Method Summary collapse

Class Method Details

.create_new_feature_callback(map, form) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ropenlayer/js_helper/jquery.rb', line 30

def self.create_new_feature_callback(map, form)
  Ropenlayer::Openlayer::Js.new("function addFeatureToMap(feature) {
  
    total_features = feature.layer.features.length;
  
    // Right now, just one feature for node
    if(total_features > 1) {
      first_feature =  feature.layer.features[0];
      feature.layer.removeFeatures(first_feature);
    }
    //update_geomtry
    $('##{ form.object.class.name.underscore  }_node_attributes_geometry_string').attr('value', feature.geometry);
 
    }").to_s
end

.create_xhtml_element(element_type, attributes = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ropenlayer/js_helper/jquery.rb', line 5

def self.create_xhtml_element(element_type, attributes = {})

inner_html = attributes.delete(:inner_html)


js_element = Ropenlayer::Openlayer::Js.new("$('<#{ element_type }")


attributes.each do |name, value|
  if name.to_s.match(/^on/)
    gsub_value = value.gsub("'","\\\\'")
  else
    gsub_value = value.gsub("'","")
  end
  
  js_element.body << %( #{ name }="#{ gsub_value }" )
  
end
js_element.body << ">"
js_element.body << inner_html.gsub("'","") if inner_html 

js_element.body << "</#{ element_type }>')"
js_element.to_s
end

.hide_xhtml_element(js_element) ⇒ Object



54
55
56
# File 'lib/ropenlayer/js_helper/jquery.rb', line 54

def self.hide_xhtml_element(js_element)
  Ropenlayer::Openlayer::Js.new("$(#{ js_element }).hide()").to_s
end

.insert_into_xhtml_element(js_element, content) ⇒ Object



46
47
48
# File 'lib/ropenlayer/js_helper/jquery.rb', line 46

def self.insert_into_xhtml_element(js_element, content)
  Ropenlayer::Openlayer::Js.new("$(#{ js_element }).append(#{ content })").to_s
end

.toggle_xhtml_element(js_element) ⇒ Object



58
59
60
# File 'lib/ropenlayer/js_helper/jquery.rb', line 58

def self.toggle_xhtml_element(js_element)
  Ropenlayer::Openlayer::Js.new("$(#{ js_element }).toggle()").to_s
end

.update_xhtml_element(js_element, content) ⇒ Object



50
51
52
# File 'lib/ropenlayer/js_helper/jquery.rb', line 50

def self.update_xhtml_element(js_element, content)
  Ropenlayer::Openlayer::Js.new("#{ js_element }.innerHTML = #{ content }").to_s
end