Skip to content

Commit

Permalink
fix(AdminComponentScreenshots): execute on document ready
Browse files Browse the repository at this point in the history
  • Loading branch information
domtra committed Nov 29, 2019
1 parent bfb2435 commit aa93a59
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Components/FeatureAdminComponentScreenshots/admin.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
/* globals FlyntData, FlyntComponentScreenshots */
import $ from 'jquery'

const $body = $('body')
const ajaxCache = {}

$body.on('mouseenter', 'a[data-layout]', function (e) {
const $target = $(e.currentTarget)
const layout = $target.data('layout')
showComponentScreenshot(layout, $target.closest('.acf-fc-popup'))
})
function init () {
const $body = $('body')

$body.on('mouseleave', 'a[data-layout]', function (e) {
const $target = $(e.currentTarget)
hideComponentScreenshot($target.closest('.acf-fc-popup'))
})
$body.on('mouseenter', 'a[data-layout]', function (e) {
const $target = $(e.currentTarget)
const layout = $target.data('layout')
showComponentScreenshot(layout, $target.closest('.acf-fc-popup'))
})

$body.on('mouseleave', 'a[data-layout]', function (e) {
const $target = $(e.currentTarget)
hideComponentScreenshot($target.closest('.acf-fc-popup'))
})
}

function showComponentScreenshot (layout, $wrapper) {
const componentName = firstToUpperCase(layout)
Expand Down Expand Up @@ -42,3 +45,5 @@ function getImage (image) {
}
return ajaxCache[image]
}

$(init)

0 comments on commit aa93a59

Please # to comment.