/dev/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/trunk

« back to all changes in this revision

Viewing changes to js/graph.js

  • Committer: Suren A. Chilingaryan
  • Date: 2011-01-26 02:48:39 UTC
  • mto: This revision was merged to the branch mainline in revision 212.
  • Revision ID: csa@dside.dyndns.org-20110126024839-nv6qp2ie9stmd2dn
Support of Appled devices by Toni Pirhonen

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
    this.height = 0;
16
16
    this.width = 0;
17
17
    
18
 
    this.device = this.getDevice();   
 
18
    this.idevice = isiDevice();   
19
19
    this.startX = 0; 
20
20
    this.startY = 0;
21
21
    this.curX = 0;  
26
26
    this.throwLeft = 0;
27
27
    this.test = 0;
28
28
    this.onlyLegend = 0;
29
 
    if (this.device == "iPhone" || this.device == "iPad"){
30
 
              this.fader = new Animator().addSubject(new NumericalStyleSubject($('graph_image_div'), 'opacity', 1, 0.13));
 
29
    
 
30
    if (this.idevice) {
 
31
        this.fader = new Animator().addSubject(new NumericalStyleSubject($('graph_image_div'), 'opacity', 1, 0.13));        
31
32
    }
32
 
 
33
33
    
34
34
    if (this.frame) {
35
35
        this.img = this.frame.getElementsByTagName('img')[0];
70
70
}
71
71
 
72
72
 
73
 
/** Checks if user is running on iPhone/iPod or iPad
74
 
 * if running on safari with iPhone returns "iPhone" if with iPad returns "iPad"
75
 
 */
76
 
GRAPH.prototype.getDevice = function() {
77
 
  if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
78
 
  {
79
 
    return "iPhone";
80
 
  }
81
 
  else if (navigator.userAgent.match(/iPad/i))
82
 
  {
83
 
    return "iPad";
84
 
  } 
85
 
  else {
86
 
    return "other than iPad iPod iPhone";
87
 
  }
88
 
  
89
 
  
90
 
}
91
 
 
92
73
GRAPH.prototype.onImageLoad = function(self) {
93
74
    return function() {
94
75
        adei.SetSuccessStatus(self.onload_message?self.onload_message:translate("Done"));  
95
 
  if(self.fader!=0){
96
 
    self.AnimatorEffects(self,2);   
97
 
  } 
98
76
 
 
77
        if(self.fader){
 
78
            self.AnimatorEffects(self,2);   
 
79
        } 
99
80
    }
100
81
}
101
82
 
342
323
                        this.window.ZoomIn(x);
343
324
                }
344
325
            break;
345
 
/*          default:
346
 
                alert(adei.key);*/
 
326
//          default:
 
327
//                if(this.fader) this.fader.reverse();
347
328
        }
348
329
}
349
330
 
588
569
            }
589
570
        }
590
571
        else if(self.onlyLegend === 1 && self.swiping === 0){
 
572
            var iphone = isiPhone();
 
573
            if(!iphone) {
591
574
                var x = adeiMathPreciseAdd(self.xmin, self.xsize*(self.startX - self.margins.left) / self.real_width);
592
575
                var y = new Array();
593
576
                for (var i = 0; i < self.axis.length; i++) {
594
577
                    y[i] = self.ymax[i] - (self.ymax[i] - self.ymin[i])*(self.startY - self.margins.top) / self.real_height;
595
578
                }
596
579
                   
597
 
                        var params = {
 
580
                    var params = {
598
581
                    xmin: self.xmin.toString(),
599
582
                    xmax: self.xmax.toString(),
600
583
                    ymin: self.ymin,
615
598
                  alert('GetLegend request is failed');
616
599
                    }
617
600
                });
618
 
          self.onlyLegend = 0;
 
601
                
 
602
                self.onlyLegend = 0;
 
603
          }
619
604
        }
620
 
        
621
 
        
622
 
 
623
605
     }
624
606
}
625
607
 
653
635
      gestureValues.x = adeiMathPreciseAdd(self.xmin, self.xsize*(self.startX - self.margins.left) / self.real_width);
654
636
     // alert(self.margins.left);
655
637
      gestureValues.marginsLeft = self.margins.left;
656
 
      gestureValues.device = self.device;
 
638
      gestureValues.device = self.idevice;
657
639
      gestureValues.y = new Array();
658
640
      for (var i = 0; i < self.axis.length; i++) {
659
641
        gestureValues.y[i] = self.ymax[i] - (self.ymax[i] - self.ymin[i])*(self.startY - self.margins.top) / self.real_height;        
660
642
      }
661
643
      if(self.fader != 0){self.AnimatorEffects(self,1);}
 
644
      gestureValues.scale = scale;
662
645
      gestureValues.startX = self.startX;
663
 
      gestureValues.angle = angle;
664
 
      gestureValues.scale = scale;
665
646
      self.window.PinchZoom(gestureValues);
666
647
      self.startValuesSet = 0;      
667
 
      self.window.Apply();
668
 
      
 
648
      self.window.Apply();      
669
649
  } 
670
650
}
671
 
/*
 
651
 
672
652
GRAPH.prototype.onOrientationChange = function(self){
673
653
  return function(e){
674
 
    self.updateOrientation();
675
 
  }
676
 
}
677
 
 
678
 
 
679
 
//test
680
 
GRAPH.prototype.updateOrientation = function(self){
681
 
  switch(window.orientation){
682
 
    case 0: //normal portrait
683
 
      alert("Normal");
684
 
      break; 
685
 
    case -90: //right landscape
686
 
      alert("Right");
687
 
      break;
688
 
    case 90: //left landscape
689
 
      alert("Left");
690
 
      break;
691
 
    case 180: //Upsidedown portrait
692
 
      alert("UpsideDown");
693
 
      break;
694
 
    default:
695
 
      break;
696
 
    
697
 
  }
698
 
}
699
 
*/
 
654
        if(self.fader != 0){self.AnimatorEffects(self,1);}
 
655
        self.window.Apply();
 
656
  }
 
657
}
 
658
 
 
659
 
700
660
/**Gets direction of Swipe gesture
701
661
 * When user swipes the screen with 1 finger, calculates heading and return an integer.
702
662
 * Return values:
825
785
                    else
826
786
                        tooltip = "";
827
787
 
828
 
      if(this.device == "iPhone" || this.device == "iPad")
 
788
      if(this.idevice)
829
789
      {
830
790
                this.crop = new Cropper.Img("graph_image", {
831
791
    /*     onEndCrop:  this.onEndCrop(this),
836
796
      onMouseScroll: this.onMouseScroll(this),
837
797
      onMouseMove: this.onMouseMove(this),
838
798
      */
839
 
      //onOrientationChange: this.onOrientationChange(this),
 
799
      onOrientationChange: this.onOrientationChange(this),
840
800
      onTouchStart: this.onTouchStart(this),
841
801
      onTouchMove:this.onTouchMove(this),
842
802
      onTouchEnd:this.onTouchEnd(this),