Created
September 27, 2012 20:45
-
-
Save nowk/3796369 to your computer and use it in GitHub Desktop.
A basic wrapper for drag and drop simulation
This file contains hidden or 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
class DragAndDropSimulator | |
def initialize(page, drag) | |
@page = page | |
@drag = drag | |
end | |
def up(num) | |
drag_and_drop(num) | |
end | |
def down(num) | |
drag_and_drop(num*-1) | |
end | |
private | |
def drag_and_drop(num) | |
@page.execute_script %{ | |
$.getScript("https://raw.github.com/nowk/jquery.simulate.drag-sortable.js/master/jquery.simulate.drag-sortable.js", function() { | |
$("#{@drag}").simulateDragSortable({move: #{num}, handle: '.handle'}); | |
}); | |
} | |
end | |
end |
This file contains hidden or 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
def drag_and_drop(selector) | |
DragAndDropSimulator.new(page, selector) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment