Created
November 18, 2019 08:40
-
-
Save cgi-caesar/8ff496b917831b3c8bab30c44f77b7fa to your computer and use it in GitHub Desktop.
aMember (site.php): Forms Editor - Use click event to add Brick to Form
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
<?php | |
/** | |
* Use click event to add Brick to Form | |
*/ | |
Am_Di::getInstance()->hook->add('gridSavedFormInitForm', function(Am_Event_Grid $e) { | |
$e->getGrid()->getForm() | |
->addScript() | |
->setScript(<<<'CUT' | |
let drag = false; | |
jQuery(document).on('mousedown', '.brick', () => drag = false); | |
jQuery(document).on('mousemove', '.brick', () => drag = true); | |
jQuery('#bricks-disabled').on('mouseup', '.brick', function(){ | |
if (drag) return; | |
jQuery('#bricks-enabled').prepend(this); | |
jQuery("#bricks-enabled").trigger('sortreceive', { | |
item: jQuery(this), | |
sender: jQuery("#bricks-disabled"), | |
}); | |
jQuery("#bricks-enabled, #bricks-disabled").sortable('refresh'); | |
bricksEditor.update(); | |
}); | |
CUT | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment