Skip to content

Instantly share code, notes, and snippets.

@rnmp
Created April 13, 2011 15:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnmp/917798 to your computer and use it in GitHub Desktop.
Save rnmp/917798 to your computer and use it in GitHub Desktop.
Register the clicked position of the page in a form
$(function(){
var page = $('#page')
page.prepend('<i id="position" />');
var position = $('#position')
position.hide();
$('.submit-hover').hide();
page.click( function(e){
$('#x').val(e.pageX);
$('#y').val(e.pageY);
position.css('top', e.pageY - 15);
position.css('left', e.pageX - 15);
position.show();
$('.submit-hover').fadeIn('fast')
$('.submit-hover').css('width', $('#page img').width())
$('#giveup').click(function(){
$('#x').val(-1);
$('#y').val(-1);
});
});
});
#page
= img '/assets/slv.png'
%form{:action => ""}
%input{:type => "hidden", :name => 'x', :id => 'x'}/
%input{:type => "hidden", :name => 'y', :id => 'y'}/
.submit-hover
%h2
If you are completely sure, please press
%input{:type => "submit", :value => 'Submit' }/
or
%input{ :id => 'giveup', :type => "submit", :value => 'I give up'}/
if you didn't find it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment