Sha256: fe0511dc895045ad523d2bdc7b8caf5cad8e6c2b5591f1e11c93cfe3935ed0f7
Contents?: true
Size: 1.95 KB
Versions: 5
Compression:
Stored size: 1.95 KB
Contents
module Ropenlayer module JsHelper module Jquery 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 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 def self.insert_into_xhtml_element(js_element, content) Ropenlayer::Openlayer::Js.new("$(#{ js_element }).append(#{ content })").to_s end def self.update_xhtml_element(js_element, content) Ropenlayer::Openlayer::Js.new("#{ js_element }.innerHTML = #{ content }").to_s end def self.hide_xhtml_element(js_element) Ropenlayer::Openlayer::Js.new("$(#{ js_element }).hide()").to_s end def self.toggle_xhtml_element(js_element) Ropenlayer::Openlayer::Js.new("$(#{ js_element }).toggle()").to_s end end end end
Version data entries
5 entries across 5 versions & 1 rubygems