Sha256: 2467c5f199ab043fa960fc8122c855f13807ad4148c25006053f62e0aed1fd9e
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
module Caculo class JQueryObject attr_accessor :javascript def self.method_missing name , *params obj = JQueryObject.new("") obj.javascript = "jQuery.#{name}(#{params.join(" , ").to_js} , function(content){ jQuery(document.body).append( content ); } )" obj end def self.to_param obj if obj.is_a? String return obj.to_js elsif obj.is_a? Array return obj.collect{|o| self.to_param( o ) }.join(" , ") else return obj.to_s end end def initialize selector=nil if selector.nil? @javascript = "window.jQuery(window.document)" elsif selector.kind_of?( String ) @javascript = "window.jQuery(#{selector.to_js})" else @javascript = "window.jQuery(#{selector})" end def method_missing name , *params obj = JQueryObject.new( "" ) js_parameters = JQueryObject.to_param( params ) obj.javascript = "#{@javascript}.#{name.to_s}( #{js_parameters} )" return obj end def to_s return @javascript end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cohitre-caculo-0.0.4 | lib/caculo/jquery.rb |
cohitre-caculo-0.0.6 | lib/caculo/jquery.rb |
cohitre-caculo-0.0.7 | lib/caculo/jquery.rb |