Created
December 11, 2013 11:47
-
-
Save micahredding/7909041 to your computer and use it in GitHub Desktop.
Coffeescript that didn't work for some reason, with the Javascript that did
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# namespace jQuery | |
(($) -> | |
# Document.ready | |
$ -> | |
switchColorbox = () -> | |
if $(window).width() < 1000 | |
$.colorbox.remove() | |
else | |
if $.colorbox.element().length < 1 | |
$('.preview').colorbox({ | |
iframe: true, | |
innerWidth:700, | |
innerHeight:400, | |
}) | |
$(window).resize(() -> | |
switchColorbox() | |
) | |
switchColorbox() | |
console.log 'hi' | |
console.log $.colorbox.element().length < 1 | |
) jQuery |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
addColorbox = function() { | |
$('.preview').colorbox({ | |
iframe: true, | |
innerWidth:700, | |
innerHeight:400 | |
}); | |
} | |
switchColorbox = function() { | |
if ($(window).width() < 1000) { | |
$.colorbox.remove(); | |
} else if ($.colorbox.element().length < 1) { | |
addColorbox(); | |
} | |
} | |
return $(function() { | |
switchColorbox(); | |
$(window).resize(function() { | |
switchColorbox(); | |
}); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment