Sha256: bf9febdd96020bd108b033f8133a60849dbad8caac037129ea445d31ec9db277

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

module Ropenlayer
  module JsHelper
    module Prototype
      
      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
      
     
      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
      
      def self.insert_into_xhtml_element(js_element, content)
        Ropenlayer::Openlayer::Js.new("#{ js_element }.insert(#{ content })").to_s
      end
      
      def self.update_xhtml_element(js_element, content)
        Ropenlayer::Openlayer::Js.new("#{ js_element }.update(#{ 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

4 entries across 4 versions & 1 rubygems

Version Path
ropenlayer-0.3.5 lib/ropenlayer/js_helper/prototype.rb
ropenlayer-0.3.4 lib/ropenlayer/js_helper/prototype.rb
ropenlayer-0.3.3 lib/ropenlayer/js_helper/prototype.rb
ropenlayer-0.3.1 lib/ropenlayer/js_helper/prototype.rb