Skip to content

Commit

Permalink
fix site in Chrome 11
Browse files Browse the repository at this point in the history
  • Loading branch information
maccman committed Jun 13, 2011
1 parent 60d7c70 commit f4549e1
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
42 changes: 41 additions & 1 deletion lib/gfx.cube.js
@@ -1,5 +1,5 @@
(function() {
var $, defaults, sides;
var $, chrome11, chromeMatch, chromeRegex, defaults, sides;
$ = jQuery;
sides = {
front: {
Expand Down Expand Up @@ -111,4 +111,44 @@
}, sides[type]));
});
};
chromeRegex = /(Chrome)[\/]([\w.]+)/;
chromeMatch = chromeRegex.exec(navigator.userAgent) || [];
chrome11 = chromeRegex[1] && chromeRegex[2].test(/^12\./);
if (!$.browser.webkit || chrome11) {
$.fn.gfxCube = function(options) {
var element, opts, wrapper;
opts = $.extend({}, defaults, options);
element = $(this);
element.css({
position: 'relative',
width: opts.width,
height: opts.height
});
wrapper = $('<div />');
wrapper.addClass('gfxCubeWrapper');
wrapper.transform({
position: 'absolute',
width: '100%',
height: '100%',
left: 0,
top: 0,
overflow: 'visible'
});
element.children().wrapAll(wrapper).css({
display: 'block',
position: 'absolute',
width: '100%',
height: '100%',
left: 0,
top: 0,
overflow: 'hidden'
});
wrapper = element.find('.gfxCubeWrapper');
wrapper.children('*:not(.front)').hide();
return element.bind('cube', function(e, type) {
wrapper.children().hide();
return wrapper.children("." + type).show();
});
};
}
}).call(this);
2 changes: 1 addition & 1 deletion site/site.css
Expand Up @@ -143,7 +143,7 @@ a {
text-align: center;
display: none;
color: #FFF;
text-shadow: 0 -2px 0 #000;
text-shadow: 0 -1px 0 #000;
margin: 20px 0;
}

Expand Down
44 changes: 43 additions & 1 deletion src/gfx.cube.coffee
Expand Up @@ -71,4 +71,46 @@ $.fn.gfxCube = (options) ->

$(@).bind 'cube', (e, type) ->
wrapper = element.find('.gfxCubeWrapper')
wrapper.gfx($.extend({}, {translateZ: "-#{tZ}"}, sides[type]))
wrapper.gfx($.extend({}, {translateZ: "-#{tZ}"}, sides[type]))

# Disable cubes in Firefox / Chrome < 12
chromeRegex = /(Chrome)[\/]([\w.]+)/
chromeMatch = chromeRegex.exec( navigator.userAgent ) or []
chrome11 = chromeRegex[1] and chromeRegex[2].test(/^12\./)

if not $.browser.webkit or chrome11
$.fn.gfxCube = (options) ->
opts = $.extend({}, defaults, options)

element = $(@)

element.css
position: 'relative'
width: opts.width
height: opts.height

wrapper = $('<div />')
wrapper.addClass('gfxCubeWrapper')
wrapper.transform
position: 'absolute'
width: '100%'
height: '100%'
left: 0
top: 0
overflow: 'visible'

element.children().wrapAll(wrapper).css
display: 'block'
position: 'absolute'
width: '100%'
height: '100%'
left: 0
top: 0
overflow: 'hidden'

wrapper = element.find('.gfxCubeWrapper')

wrapper.children('*:not(.front)').hide()
element.bind 'cube', (e, type) ->
wrapper.children().hide()
wrapper.children(".#{type}").show()

0 comments on commit f4549e1

Please sign in to comment.