Skip to content

Commit

Permalink
fix css/raphael switcher on example pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jlongster committed May 25, 2011
1 parent 6f1b71a commit c78d719
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
8 changes: 2 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ $(function() {
}, 50);
}

make_renderer('canvas');
make_renderer(null, 'canvas');

dom3d.current_eye($v(0,0,-20));
dom3d.current_light(vec_unit($v(-1.0, 0.0, 0.0)));
Expand All @@ -95,9 +95,5 @@ $(function() {
bind_controls();
update_controls();

var change_renderer = window.onpopstate;
window.onpopstate = function() {
change_renderer();
update_controls();
}
$('.render-options a').click(update_controls);
});
34 changes: 18 additions & 16 deletions std.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ $(function() {

var renderer_info;

function make_renderer(width_or_canvas, height) {
renderer_info = [width_or_canvas, height];
function default_renderer_type() {
var hash = window.location.hash;
type = hash && hash.substring(1);
return type || 'css';
}

var type = (window.location.hash ?
window.location.hash.substring(1) :
'css');
function make_renderer(type, width_or_canvas, height) {
renderer_info = [width_or_canvas, height];
type = type || default_renderer_type();

if(dom3d.current_renderer()) {
dom3d.clear('canvas');
Expand All @@ -34,13 +37,6 @@ $(function() {
dom3d.current_renderer(new RendererCSS());
}

$('.render-options a').each(function() {
var _this = $(this);
if(_this.attr('href') == '#' + type) {
_this.addClass('selected');
}
});

init(width_or_canvas, height);
return dom3d.current_renderer();
};
Expand All @@ -67,18 +63,24 @@ $(function() {
$('.render-options a').click(function() {
$('.render-options a').removeClass('selected');
$(this).addClass('selected');

var pound = this.href.indexOf('#');
make_renderer(this.href.substring(pound + 1),
renderer_info[0],
renderer_info[1]);
});

$('.render-options a').each(function() {
if(this.href.indexOf(default_renderer_type()) > 0)
$(this).addClass('selected');
});

function install_resize() {
$(window).resize(function() {
init();
});
}

window.onpopstate = function() {
make_renderer.apply(this, renderer_info);
}

window.make_renderer = make_renderer;
window.install_resize = install_resize;
window.fix_canvas = fix_canvas;
Expand Down

0 comments on commit c78d719

Please sign in to comment.