Skip to content

Instantly share code, notes, and snippets.

@rorlab
Created February 23, 2013 07:56
Show Gist options
  • Save rorlab/5018898 to your computer and use it in GitHub Desktop.
Save rorlab/5018898 to your computer and use it in GitHub Desktop.
$(document).ready ->
$("a[data-share]").on "click", (e) ->
e.preventDefault()
network = $(this).data('share')
width = 550
height = 430
left = ($(window).width() - width) / 2
top = ($(window).height() - height) / 2
url = this.href
options = 'status=1' + ',width=' + width + ',height=' + height + ',top=' + top + ',left=' + left
window.open url, network, options
false

Usage

= social_link_to "Tweet", 'twitter', { url: object_url(@object), text: @object.title }, 'data-share' => 'twitter'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment