Created
April 13, 2011 15:51
-
-
Save rnmp/917798 to your computer and use it in GitHub Desktop.
Register the clicked position of the page in a form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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