Bonjour,

Je cherche a créer une classe JS. Mais je n'arrive pas a appeler une methode dans une autre méthode.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function Gallery() {
    this.divOverlay;
    this.iNumImage          = 0;
    this.iNumImages         = 3;
    this.iXStart            = 0;
    this.iXEnd              = 0;
    this.sParentOverlayId   = 'result';
    this.sSlideAreaId       = 'img_and_buttons';
    this.sGalleryId         = 'css_lightbox';
    this.sExpandLinkId      = 'expand';
    this.sImgId             = 'subscriber_pic';
    this.aImages            = [];
    this.bSupportsTouch     = false;
}
 
Gallery.prototype = {
 
    isTouchSupported: function() {
        if ( 'ontouchstart' in window )
        {   //iOS & android
            this.bSupportsTouch = true;
        }
        else if ( window.navigator.msPointerEnabled )
        {   //Win8
            this.bSupportsTouch = true;
        }
 
        return this.bSupportsTouch;
    },
 
    init: function() {
        // var xStart  = 0;
        // var xEnd    = 0;
 
        console.log( this.bSupportsTouch );
        console.log( this.isTouchSupported );
 
        if ( this.isTouchSupported && typeof slideAreaId != 'undefined' && document.getElementById(slideAreaId) )
        {
            var slidebox = document.getElementById(slideAreaId);
            if ( document.addEventListener )
            {
                slidebox.addEventListener('touchstart', this.touchstart_callback, false);
                slidebox.addEventListener('touchend', this.touchend_callback, false);
            }
        }
    }
}
 
var oGallery = new Gallery();
if ( document.addEventListener )
{
    window.addEventListener('load', oGallery.init, false);
}
Dans la méthode init() mes console.log retourne undefined.