Skip to content

Instantly share code, notes, and snippets.

@micahredding
Created December 11, 2013 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micahredding/7909041 to your computer and use it in GitHub Desktop.
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
# 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
(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