Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix some JSHint warnnings
  • Loading branch information
Igor Lima committed May 7, 2013
1 parent 9bba2d4 commit 48819d2
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 65 deletions.
21 changes: 11 additions & 10 deletions scripts/ekwal.js
@@ -1,4 +1,5 @@
/**
* @license
* ekwal 1.0.0
*
* To use it, just call the ekwal() function with the elements you want to equalize.
Expand All @@ -17,21 +18,21 @@
* Date: Sep 14 19:45:00 2012
*/

!function() {
;(function(window, undefined) {
window.ekwal = function(els, prop) {
els = [].slice.call(els)
els = [].slice.call(els);
// `height` is the default value
prop = prop || 'height'
prop = prop || 'height';

if (prop !== 'height' && prop !== 'width')
throw new Error('"' + prop + '" must be "height" (by default) or "width"')
throw new Error('"' + prop + '" must be "height" (by default) or "width"');

els.forEach(function(el) {
el.style[prop] = Math.max.apply(null, els.map(function(el) {
return parseInt(getComputedStyle(el).getPropertyValue(prop), 10)
})) + 'px'
})
return parseInt(getComputedStyle(el).getPropertyValue(prop), 10);
})) + 'px';
});

return els
}
}()
return els;
};
}(window));
21 changes: 11 additions & 10 deletions scripts/jquery.ekwal.js
@@ -1,4 +1,5 @@
/**
* @license
* ekwal 1.0.0
*
* To use it, just call the jQuery#ekwal() method on the elements you want to equalize.
Expand All @@ -12,20 +13,20 @@
* Date: Sep 14 19:45:00 2012
*/

!function($) {
;(function($) {
$.fn.ekwal = function(jQueryDimension) {
// `height` is the default value
jQueryDimension = jQueryDimension || 'height'
var $els = this
, prop = /eight/.test(jQueryDimension) ? 'height' : 'width';
jQueryDimension = jQueryDimension || 'height';
var $els = this,
prop = /eight/.test(jQueryDimension) ? 'height' : 'width';

if (typeof $.fn[jQueryDimension] !== 'function')
throw new Error('$.fn.' + jQueryDimension + '() do not exist')
throw new Error('$.fn.' + jQueryDimension + '() do not exist');

$els[prop](Math.max.apply(null, $.map($els, function(el) {
return $(el)[jQueryDimension]()
})))
return $(el)[jQueryDimension]();
})));

return $els
}
}(window.jQuery || window.Zepto);
return $els;
};
}(window.jQuery || window.Zepto));
89 changes: 44 additions & 45 deletions scripts/main.js
@@ -1,74 +1,73 @@
/*global ekwal:false */

!function($) {
;(function($) {

$(function() {
"use strict"; // Yes, that's half an ass, damnit JSHint(╯°□°)╯ ︵ ┻━┻

// Randomize the height/width of the elements we can test
var randomSize = function() {
var tmp
return (tmp = Math.floor(100 * Math.random())) > 10 ? tmp : 50
}
, $globalPlaceholders = $('.placeholder > li')
var tmp;
return (tmp = Math.floor(100 * Math.random())) > 10 ? tmp : 50;
},
$globalPlaceholders = $('.placeholder > li');

$globalPlaceholders.each(function() {
var tmp
var tmp;
$(this).css({
height: randomSize()
, width : randomSize()
})
})
height: randomSize(),
width : randomSize()
});
});

// When the user test the plugin
$('form').on('submit', function(e) {
e.preventDefault()
var $form = $(this)
, $input = $('input', $form)
e.preventDefault();
var $form = $(this),
$input = $('input', $form);
// Add a try catch to alert the exception if needed
try {
// Use the jQuery/Zepto plugin or the Vanilla one
if ($form.data('type') === 'jquery') {
$('.placeholder > li', $form).ekwal($input.val())
canIHazKittens && kittensAllTheWay()
$('.placeholder > li', $form).ekwal($input.val());
} else {
ekwal($form[0].querySelectorAll('.placeholder > li'), $input.val())
canIHazKittens && kittensAllTheWay()
ekwal($form[0].querySelectorAll('.placeholder > li'), $input.val());
}
canIHazKittens && kittensAllTheWay();
} catch(error) {
alert(error.message + ' you silly boy.')
alert(error.message + ' you silly boy.');
}
})
});

// Useless, as usual, I also was looking for cat sound but fuck it
var kittensAllTheWay = function() {
$globalPlaceholders.each(function() {
var $this = $(this)
, kitty = 'http://placekitten.com'
, width = $this.width()
, height = $this.height()
// Yay kittens \o/
// Can i haz grey kittens?
kitty += Math.random() > 0.5 ? '/' : '/g/'
kitty += width + '/' + height
$this.html($('<img>').attr({
src: kitty
, width: width
, height: height
}))
})
canIHazKittens = true
}
, canIHazKittens = false
, kkeys = []
, konami = '38,38,40,40,37,39,37,39,66,65'
$globalPlaceholders.each(function() {
var $this = $(this),
kitty = 'http://placekitten.com',
width = $this.width(),
height = $this.height();
// Yay kittens \o/
// Can i haz grey kittens?
kitty += Math.random() > 0.5 ? '/' : '/g/';
kitty += width + '/' + height;
$this.html($('<img>').attr({
src: kitty,
width: width,
height: height
}));
});
canIHazKittens = true;
},
canIHazKittens = false,
kkeys = [],
konami = '38,38,40,40,37,39,37,39,66,65';
$(document).on('keydown:kittens', function(e) {
kkeys.push(e.keyCode)
kkeys.push(e.keyCode);
if (kkeys.toString().indexOf(konami) >= 0 ) {
$(document).off('keydown:kittens')
kittensAllTheWay()
$(document).off('keydown:kittens');
kittensAllTheWay();
}
})
})
});
});

}(window.jQuery || window.Zepto);
}(window.jQuery || window.Zepto));

0 comments on commit 48819d2

Please sign in to comment.