Sha256: 6ac39f60ace3f59c054b4d53007b7e52ea8428c8a494ce8ac3407e12fd702272

Contents?: true

Size: 795 Bytes

Versions: 6

Compression:

Stored size: 795 Bytes

Contents

module SharesHelper
  def record_share(shareable,service_ident,options={})
    options.reverse_merge!({
      :remote => true
    })
    
    if options[:remote]
      '<script>      
      (function(){
        var ua = navigator.userAgent.toLowerCase();
        if (!window.ActiveXObject) {
          request = new XMLHttpRequest();
        } else if (ua.indexOf("msie 5") == -1) {
          request = new ActiveXObject("Msxml2.XMLHTTP");
        } else {
          request = new ActiveXObject("Microsoft.XMLHTTP");
        }
        var params = {"share[service_ident]":\''+service_ident+'\'};
        request.open("POST", "'+shareable.class.name.underscore.pluralize+'/'+shareable.id.to_s+'/shares.json");
        request.send(params);
      }());
      </script>'.html_safe
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
how_are_we_doing-0.0.9 app/helpers/shares_helper.rb
how_are_we_doing-0.0.8 app/helpers/shares_helper.rb
how_are_we_doing-0.0.7 app/helpers/shares_helper.rb
how_are_we_doing-0.0.6 app/helpers/shares_helper.rb
how_are_we_doing-0.0.5 app/helpers/shares_helper.rb
how_are_we_doing-0.0.4 app/helpers/shares_helper.rb