Skip to content
This repository has been archived by the owner on Apr 5, 2018. It is now read-only.

Commit

Permalink
Fixed js with jscs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Olde Hampsink committed Sep 11, 2015
1 parent f3d26e4 commit cdc277e
Showing 1 changed file with 60 additions and 60 deletions.
120 changes: 60 additions & 60 deletions resources/js/assetpreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<len; ++i) {
if (i in assetFields) {
s = assetFields[i];
if (s.href == thisAssetFieldUrl) {
thisAssetIndex = i;
}
}
}
// Find the index of this asset in assetFields array
var thisAssetIndex = 0;
var len = assetFields.length;
for (var i = 0; i < len; ++i) {
if (i in assetFields) {
var s = assetFields[i];
if (s.href == thisAssetFieldUrl) {
thisAssetIndex = i;
}
}
}

// Open fancybox
$.fancybox.open(assetFields, {
index: thisAssetIndex,
keys: {close: [32]},
afterShow: function(){
$('.fancybox-close').one('click', function(){
state = 0;
});
}
});
// Open fancybox
$.fancybox.open(assetFields, {
index: thisAssetIndex,
keys: {close: [32]},
afterShow: function() {
$('.fancybox-close').one('click', function() {
state = 0;
});
},
});

state = 1;
}
}
}).on('mouseover', function() {
state = 1;
}
}
}).on('mouseover', function() {

// Add explaining hover text
$('.element.hasthumb').attr('title', Craft.t('Select and press space to preview'));
});
// Add explaining hover text
$('.element.hasthumb').attr('title', Craft.t('Select and press space to preview'));
});
});
})(jQuery);

0 comments on commit cdc277e

Please sign in to comment.