diff --git a/resources/js/assetpreview.js b/resources/js/assetpreview.js index 472f9b4..75a04f4 100644 --- a/resources/js/assetpreview.js +++ b/resources/js/assetpreview.js @@ -12,78 +12,78 @@ // Inject jQuery and wait for it to be ready (function($) { - $(function() { + $(function() { - // Keep state - var state = 0; + // Keep state + var state = 0; - // Trigger on keydown - $('.elements').on('keydown', '*', function(e) { + // Trigger on keydown + $('.elements').on('keydown', '*', function(e) { - // Listen for space - if(e.which == 32) { - e.stopPropagation(); - var assetFields = []; + // Listen for space + if (e.which == 32) { + e.stopPropagation(); + var assetFields = []; - // Select the element and check if it's a asset field element - var thisAsset = $(this).find('.element.hasthumb'); + // Select the element and check if it's a asset field element + var thisAsset = $(this).find('.element.hasthumb'); - // If it's not a asset field element, it's a element in assets element index - if (!thisAsset.hasClass('hasthumb')) { + // If it's not a asset field element, it's a element in assets element index + if (!thisAsset.hasClass('hasthumb')) { - // Select the element in asset element index - thisAsset = $(this).closest('.element.hasthumb'); - } + // Select the element in asset element index + thisAsset = $(this).closest('.element.hasthumb'); + } - // Toggle - if(state) { - // Close all boxes - $.fancybox.close(); - state = 0; - }else { + // Toggle + if (state) { + // Close all boxes + $.fancybox.close(); + state = 0; + }else { - // Build array of asset fields - assetFields = []; - $(this).parent().find('.element.hasthumb').each(function(index) { - assetFields.push({ - href: $(this).data('url'), - title: $(this).data('label') - }); - }); + // Build array of asset fields + assetFields = []; + $(this).parent().find('.element.hasthumb').each(function(index) { + assetFields.push({ + href: $(this).data('url'), + title: $(this).data('label'), + }); + }); - // Create object for this asset - var thisAssetFieldUrl = thisAsset.data('url'); + // Create object for this asset + var thisAssetFieldUrl = thisAsset.data('url'); - // Find the index of this asset in assetFields array - var thisAssetIndex = 0; - var i, s, len = assetFields.length; - for (i=0; i