Module: Ropenlayer::JsHelper::Prototype
- Defined in:
- lib/ropenlayer/js_helper/prototype.rb
Class Method Summary collapse
- .create_new_feature_callback(map, form) ⇒ Object
- .create_xhtml_element(element_type, attributes = {}) ⇒ Object
- .hide_xhtml_element(js_element) ⇒ Object
- .insert_into_xhtml_element(js_element, content) ⇒ Object
- .toggle_xhtml_element(js_element) ⇒ Object
- .update_xhtml_element(js_element, content) ⇒ Object
Class Method Details
.create_new_feature_callback(map, form) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ropenlayer/js_helper/prototype.rb', line 18 def self.create_new_feature_callback(map, form) Ropenlayer::Openlayer::Js.new("function addFeatureToMap(feature) { total_features = feature.layer.features.size(); // Right now, just one feature for node if(total_features > 1) { first_feature = feature.layer.features.first(); feature.layer.removeFeatures(first_feature); } //update_geomtry $('#{ form.object.class.name.underscore }_node_attributes_geometry_string').value = feature.geometry; }").to_s end |
.create_xhtml_element(element_type, attributes = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ropenlayer/js_helper/prototype.rb', line 5 def self.create_xhtml_element(element_type, attributes = {}) inner_html = attributes.delete(:inner_html) attributes.each do |name, value| attributes[name] = %( "#{ value }" ) if name.to_s.match(/^on/) end return_js = Ropenlayer::Openlayer::Js.new_method("Element", :args => [ "'#{ element_type }'" ], :propierties => attributes) return_js.body << ".update('#{ inner_html.gsub("'",'') }')" if inner_html return_js.to_s end |
.hide_xhtml_element(js_element) ⇒ Object
42 43 44 |
# File 'lib/ropenlayer/js_helper/prototype.rb', line 42 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
34 35 36 |
# File 'lib/ropenlayer/js_helper/prototype.rb', line 34 def self.insert_into_xhtml_element(js_element, content) Ropenlayer::Openlayer::Js.new("#{ js_element }.insert(#{ content })").to_s end |
.toggle_xhtml_element(js_element) ⇒ Object
46 47 48 |
# File 'lib/ropenlayer/js_helper/prototype.rb', line 46 def self.toggle_xhtml_element(js_element) Ropenlayer::Openlayer::Js.new("#{ js_element }.toggle()").to_s end |
.update_xhtml_element(js_element, content) ⇒ Object
38 39 40 |
# File 'lib/ropenlayer/js_helper/prototype.rb', line 38 def self.update_xhtml_element(js_element, content) Ropenlayer::Openlayer::Js.new("#{ js_element }.update(#{ content })").to_s end |