Permalink
Browse files

fix css/raphael switcher on example pages

  • Loading branch information...
1 parent 6f1b71a commit c78d7194942821f07d6b493faf87f247afefd4c5 @jlongster committed May 25, 2011
Showing with 20 additions and 22 deletions.
  1. +2 −6 index.js
  2. +18 −16 std.js
View
@@ -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)));
@@ -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);
});
View
@@ -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');
@@ -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();
};
@@ -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;

0 comments on commit c78d719

Please sign in to comment.