Skip to content
Browse files

Detect device and set configuration respectively.

  • Loading branch information...
1 parent 13aac29 commit 8f7a73821694d55365d7e424abb3a8c8f7b330d5 Carlos Mantilla committed Feb 17, 2014
Showing with 39 additions and 2 deletions.
  1. +35 −2 app/js/cdl.js
  2. +4 −0 app/js/config.js
View
37 app/js/cdl.js
@@ -18,8 +18,39 @@
background,
system,
draw = {},
- width = 900,
- height = 600;
+ width = config.chart.canvas.width,
+ height = config.chart.canvas.height,
+ agent = navigator.userAgent;
+
+ // Detect device and set configuration respectively.
+ if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(agent) ) {
+ if (agent.match(/iPad/)) {
+ config.chart.initial.minZoom = 0.43;
+ config.chart.zoom.hideGrandChildren = 0.44;
+ config.chart.initial.y = function(height) { return height * 0.30;};
+ config.nodes.root.r = config.nodes.root.rFocus = config.nodes.root.target = config.nodes.translation.r = config.nodes.translation.rFocus = config.nodes.translation.target = 35;
+ }
+ else if (agent.match(/Android/)) {
+ if (agent.match(/Pad/)) {
+ config.chart.initial.minZoom = 0.65;
+ config.chart.zoom.hideGrandChildren = 0.66;
+ config.chart.initial.y = function(height) { return height * 0.40;};
+ config.nodes.root.r = config.nodes.root.rFocus = config.nodes.root.target = config.nodes.translation.r = config.nodes.translation.rFocus = config.nodes.translation.target = 60 ;
+ }
+ else {
+ config.chart.initial.minZoom = 0.33;
+ config.chart.zoom.hideGrandChildren = 0.34
+ config.chart.initial.y = function(height) { return height * 0.25;};
+ config.nodes.root.r = config.nodes.root.rFocus = config.nodes.root.target = config.nodes.translation.r = config.nodes.translation.rFocus = config.nodes.translation.target = 30 ;
+ }
+ }
+
+ }
+ else {
+ config.chart.initial.minZoom = 0.55;
+ config.chart.zoom.hideGrandChildren = 0.56;
+ config.nodes.root.r = config.nodes.root.rFocus = config.nodes.root.target = config.nodes.translation.r = config.nodes.translation.rFocus = config.nodes.translation.target = 50;
+ }
/**
* Create the 'Canvas' area, it's possible define the dimensions.
@@ -30,6 +61,8 @@
function prepareScenario() {
var initialScaleOnZoom;
+ // Define
+
function zoomstart() {
initialScaleOnZoom = draw.getScale();
}
View
4 app/js/config.js
@@ -18,6 +18,10 @@
* transitions: Define duration in miliseconds of the transitions, for each kind of elements.
*/
this.chart = {
+ canvas: {
+ width: 900,
+ height: 600
+ },
initial: {
x: function(width) { return -width * 0.03;},
y: function(height) { return height * 0.35;},

0 comments on commit 8f7a738

Please sign in to comment.
Something went wrong with that request. Please try again.