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

Commit

Permalink
new version 0.2.7 fixed #28
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Jul 10, 2013
1 parent e19ac60 commit 5b5840b
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 85 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Version: 0.2.6
* Version: 0.2.7
* Author: Gianluca Guarini
* Contact: [email protected]
* Website: http://www.gianlucaguarini.com/
Expand Down
2 changes: 1 addition & 1 deletion ajax-contents.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<link href="css/BlackAndWhite.css" rel="stylesheet">

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="src/jquery.min.js"></script>
<script src="jquery.BlackAndWhite.js"></script>

</head>
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery.BlackAndWhite",
"version": "0.2.6",
"version": "0.2.7",
"main": "jquery.BlackAndWhite.js",
"ignore": [
"**/.*",
Expand Down
2 changes: 1 addition & 1 deletion demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<link href="css/BlackAndWhite.css" rel="stylesheet">

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="src/jquery.min.js"></script>
<script src="jquery.BlackAndWhite.js"></script>
<script>
//init
Expand Down
2 changes: 1 addition & 1 deletion invertHoverEffect.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<link href="css/BlackAndWhite.css" rel="stylesheet">

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="src/jquery.min.js"></script>
<script src="jquery.BlackAndWhite.js"></script>

</head>
Expand Down
73 changes: 32 additions & 41 deletions jquery.BlackAndWhite.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Version: 0.2.6
* Version: 0.2.7
* Author: Gianluca Guarini
* Contact: [email protected]
* Website: http://www.gianlucaguarini.com/
Expand Down Expand Up @@ -50,11 +50,11 @@
*
*/
var hoverEffect = options.hoverEffect,
webworkerPath = options.webworkerPath,
invertHoverEffect = options.invertHoverEffect,
responsive = options.responsive,
fadeSpeedIn = $.isPlainObject(options.speed) ? options.speed.fadeIn : options.speed,
fadeSpeedOut = $.isPlainObject(options.speed) ? options.speed.fadeOut : options.speed;
webworkerPath = options.webworkerPath,
invertHoverEffect = options.invertHoverEffect,
responsive = options.responsive,
fadeSpeedIn = $.isPlainObject(options.speed) ? options.speed.fadeIn : options.speed,
fadeSpeedOut = $.isPlainObject(options.speed) ? options.speed.fadeOut : options.speed;

var isIE7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;

Expand Down Expand Up @@ -93,22 +93,22 @@
*
*/
var supportsCanvas = !!document.createElement('canvas').getContext,
$window = $(window),
/* Check if Web Workers are supported */
supportWebworker = (function () {
return (typeof (Worker) !== "undefined") ? true : false;
}()),
cssFilter = cssPrefix('Filter'),
imagesArray = [],
BnWWorker = supportWebworker && webworkerPath ? new Worker(webworkerPath + "BnWWorker.js") : false;
$window = $(window),
/* Check if Web Workers are supported */
supportWebworker = (function () {
return (typeof (Worker) !== "undefined") ? true : false;
}()),
cssFilter = cssPrefix('Filter'),
imagesArray = [],
BnWWorker = supportWebworker && webworkerPath ? new Worker(webworkerPath + "BnWWorker.js") : false;

/**
*
* Private methods
*
*/
var _onMouseLeave = function (e) {
$(e.currentTarget).find('.BWfade').stop(true, true)[!invertHoverEffect ? 'fadeIn' : 'fadeOut'](fadeSpeedIn);
$(e.currentTarget).find('.BWfade').stop(true, true)[!invertHoverEffect ? 'fadeIn' : 'fadeOut'](fadeSpeedOut);
};
var _onMouseEnter = function (e) {
$(e.currentTarget).find('.BWfade').stop(true, true)[invertHoverEffect ? 'fadeIn' : 'fadeOut'](fadeSpeedIn);
Expand All @@ -133,9 +133,9 @@
//convert any image into B&W using HTML5 canvas
var _manipulateImage = function (img, canvas, width, height) {
var ctx = canvas.getContext('2d'),
currImg = img,
i = 0,
grey;
currImg = img,
i = 0,
grey;

ctx.drawImage(img, 0, 0, width, height);

Expand Down Expand Up @@ -169,22 +169,19 @@
var _injectTags = function ($img, $imageWrapper) {

var pic = $img[0],
src = pic.src,
width = $img.width(),
height = $img.height(),
css = {
'position': 'absolute',
top: 0,
left: 0,
display: invertHoverEffect ? 'none' : 'block',
width:width,
height:height
};

src = pic.src,
width = $img.width(),
height = $img.height(),
css = {
'position': 'absolute',
top: 0,
left: 0,
display: invertHoverEffect ? 'none' : 'block'
};
if (supportsCanvas && !cssfilters) {

var realWidth = pic.width,
realHeight = pic.height;
realHeight = pic.height;

//adding the canvas
$('<canvas class="BWfade" width="' + realWidth + '" height="' + realHeight + '"></canvas>').prependTo($imageWrapper);
Expand All @@ -196,7 +193,7 @@
_manipulateImage(pic, $canvas[0], realWidth, realHeight);

} else {

css[cssPrefix('Filter')] = 'grayscale(100%)';
//adding the canvas
$('<img src=' + src + ' width="' + width + '" height="' + height + '" class="BWFilter BWfade" /> ').prependTo($imageWrapper);
Expand Down Expand Up @@ -238,15 +235,9 @@
this.resizeImages = function () {

$container.each(function (index, currImageWrapper) {
var pic = $(currImageWrapper).find('img:not(.BWFilter)');
var currWidth,currHeight;
if (isIE7) {
currWidth = $(pic).prop('width');
currHeight = $(pic).prop('height');
} else {
currWidth = $(pic).width();
currHeight = $(pic).height();
}
var pic = $(currImageWrapper).find('img:not(.BWFilter)'),
currWidth = isIE7 ? $(pic).prop('width') : $(pic).width(),
currHeight = isIE7 ? $(pic).prop('height') : $(pic).height();

$(this).find('.BWFilter, canvas').css({
width: currWidth,
Expand Down
3 changes: 1 addition & 2 deletions responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
</style>

<link href="css/BlackAndWhite.css" rel="stylesheet">

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="src/jquery.min.js"></script>
<script src="jquery.BlackAndWhite.js"></script>

</head>
Expand Down
61 changes: 31 additions & 30 deletions src/jquery.BlackAndWhite.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
*
*/
var hoverEffect = options.hoverEffect,
webworkerPath = options.webworkerPath,
invertHoverEffect = options.invertHoverEffect,
responsive = options.responsive,
fadeSpeedIn = $.isPlainObject(options.speed) ? options.speed.fadeIn : options.speed,
fadeSpeedOut = $.isPlainObject(options.speed) ? options.speed.fadeOut : options.speed;
webworkerPath = options.webworkerPath,
invertHoverEffect = options.invertHoverEffect,
responsive = options.responsive,
fadeSpeedIn = $.isPlainObject(options.speed) ? options.speed.fadeIn : options.speed,
fadeSpeedOut = $.isPlainObject(options.speed) ? options.speed.fadeOut : options.speed;

var isIE7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;

Expand Down Expand Up @@ -93,14 +93,14 @@
*
*/
var supportsCanvas = !!document.createElement('canvas').getContext,
$window = $(window),
/* Check if Web Workers are supported */
supportWebworker = (function () {
return (typeof (Worker) !== "undefined") ? true : false;
}()),
cssFilter = cssPrefix('Filter'),
imagesArray = [],
BnWWorker = supportWebworker && webworkerPath ? new Worker(webworkerPath + "BnWWorker.js") : false;
$window = $(window),
/* Check if Web Workers are supported */
supportWebworker = (function () {
return (typeof (Worker) !== "undefined") ? true : false;
}()),
cssFilter = cssPrefix('Filter'),
imagesArray = [],
BnWWorker = supportWebworker && webworkerPath ? new Worker(webworkerPath + "BnWWorker.js") : false;

/**
*
Expand Down Expand Up @@ -133,9 +133,9 @@
//convert any image into B&W using HTML5 canvas
var _manipulateImage = function (img, canvas, width, height) {
var ctx = canvas.getContext('2d'),
currImg = img,
i = 0,
grey;
currImg = img,
i = 0,
grey;

ctx.drawImage(img, 0, 0, width, height);

Expand Down Expand Up @@ -169,17 +169,17 @@
var _injectTags = function ($img, $imageWrapper) {

var pic = $img[0],
src = pic.src,
width = $img.width(),
height = $img.height(),
css = {
'position': 'absolute',
top: 0,
left: 0,
display: invertHoverEffect ? 'none' : 'block',
width:width,
height:height
};
src = pic.src,
width = $img.width(),
height = $img.height(),
css = {
'position': 'absolute',
top: 0,
left: 0,
display: invertHoverEffect ? 'none' : 'block',
width:width,
height:height
};

if (supportsCanvas && !cssfilters) {

Expand All @@ -196,7 +196,7 @@
_manipulateImage(pic, $canvas[0], realWidth, realHeight);

} else {

console.log('s');
css[cssPrefix('Filter')] = 'grayscale(100%)';
//adding the canvas
$('<img src=' + src + ' width="' + width + '" height="' + height + '" class="BWFilter BWfade" /> ').prependTo($imageWrapper);
Expand Down Expand Up @@ -244,8 +244,9 @@
currWidth = $(pic).prop('width');
currHeight = $(pic).prop('height');
} else {
currWidth = $(pic).width();
currHeight = $(pic).height();
console.log('ehy');
currWidth = $img.attr('width') || $(pic).width();
currHeight = $img.attr('height') || $(pic).height();
}

$(this).find('.BWFilter, canvas').css({
Expand Down
9 changes: 2 additions & 7 deletions src/jquery.BlackAndWhite.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5b5840b

Please sign in to comment.