Created
October 11, 2013 21:22
-
-
Save cbfranca/6942238 to your computer and use it in GitHub Desktop.
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 to enable reposition cover | |
function enableRepositionCover() { | |
$("#cover_image").css('cursor','move'); | |
var y1 = $('.img-header').height(); | |
var y2 = $('#cover_image').height(); | |
$("#cover_image").liveDraggable({ | |
scroll: false, | |
axis: "y", | |
drag: function(event, ui) { | |
if(ui.position.top >= 0) | |
{ | |
ui.position.top = 0; | |
} | |
else if(ui.position.top <= y1 - y2) | |
{ | |
ui.position.top = y1 - y2; | |
} | |
}, | |
stop: function(event, ui) { | |
var img = { | |
"id": $(this).attr('id'), | |
"position_y": $(this).position().top.toString(), | |
"position_x": $(this).position().left.toString() | |
}; | |
$("#farm_cover_position_x").val(img.position_x); | |
$("#farm_cover_position_y").val(img.position_y); | |
} | |
}); | |
} | |
//Function to disable reposition cover | |
function disableRepositionCover(){ | |
$('#drag_instruction').css('visibility','hidden'); | |
$("#cover_image").draggable('destroy'); | |
$('.cover-editor-bar').css('visibility','hidden'); | |
$("#cover_image").css('cursor','default'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment