~smagoun/whoopsie/whoopsie-lp1017637

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/tests/dial/tests/manual/simulate_minimal.html

  • Committer: Evan Dandrea
  • Date: 2012-05-09 05:53:45 UTC
  • Revision ID: evan.dandrea@canonical.com-20120509055345-z2j41tmcbf4as5uf
The backend now lives in lp:daisy and the website (errors.ubuntu.com) now lives in lp:errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
 
<html>
3
 
<head>
4
 
<title>sim only test</title>
5
 
 
6
 
<!-- Source File and Seed for YUI3-->
7
 
<link rel="stylesheet" type="text/css" href="../../../../build/cssreset/reset-min.css">
8
 
<link type="text/css" rel="stylesheet" href="../../../../build/cssfonts/fonts-min.css">
9
 
 
10
 
<script src="../../../../build/yui/yui.js"></script>
11
 
</head>
12
 
<style>
13
 
.obj{
14
 
    display:inline-block;
15
 
    position:absolute;
16
 
    top:30px;
17
 
    left:20px;
18
 
    width:400px;
19
 
    height:400px;
20
 
    background-color:#eee;
21
 
    border:solid 1px #aaa;
22
 
    
23
 
}
24
 
.obj p {
25
 
    margin:1em;
26
 
}
27
 
.end-here {
28
 
    position:absolute;
29
 
    top:300px;
30
 
    left:300px;
31
 
    border:solid 1px #f00;
32
 
    width:40px;
33
 
    height:40px;
34
 
}
35
 
.thing {
36
 
    position:absolute;
37
 
    top:70px;
38
 
    left:40px;
39
 
    border:solid 1px #000;
40
 
    width:20px;
41
 
    height:20px;
42
 
    background-color:#8080ff;
43
 
}
44
 
.btn-container{
45
 
    position:absolute;
46
 
    top:200px;
47
 
    left:460px;
48
 
    width:200px;
49
 
}
50
 
 
51
 
</style>
52
 
<body class="yui3-skin-sam">
53
 
    <div class="obj">
54
 
        <p>
55
 
            Click anywhere in the gray rect. to move A to the place you clicked. This is a native event.
56
 
        </p>
57
 
        <div class="end-here">B</div> 
58
 
        <div class="thing">A</div>
59
 
    
60
 
    </div>
61
 
    <div class="btn-container">
62
 
        This button should <button class=sim-md>Simulate</button> a click in the gray rectangle that would place A in B. 
63
 
        <p> There seems to be a problem in IE9 with e.pageX, e.pageY in an event that receives a simulated event...</p>
64
 
    </div>
65
 
</body>
66
 
</html>
67
 
<script type="text/javascript">
68
 
YUI({filter:'raw'}).use('node','node-event-simulate','event-move', function(Y) {          //, filter:'raw'  this make it really hard to clear cache on iPad
69
 
 
70
 
 
71
 
 
72
 
        var obj = Y.one('obj'),
73
 
    eventX = 330, //Set the X for event simulation. 
74
 
    eventY = 340; //Set the Y for event simulation. 
75
 
        
76
 
 
77
 
 
78
 
    // clicked the button 
79
 
    var handleSimMd = function(e){
80
 
        var scrollT = Y.one('document').get('scrollTop'),
81
 
        scrollL = Y.one('document').get('scrollLeft');
82
 
        Y.one('.obj').simulate("click", {clientX: eventX, clientY: eventY});
83
 
        
84
 
        //Y.one('.obj').simulate("click", {clientX: (eventX - scrollL), clientY: (eventY - scrollT)});   // same as line above, only handles scrolled page
85
 
        
86
 
/* this also does not dispatch an event object that contains e.pageX/Y in IE9
87
 
        Y.one('.obj').simulate("click", {
88
 
            clientX: eventX, 
89
 
            pageX: (eventX), 
90
 
            clientY: eventY, 
91
 
            pageY: (eventY)
92
 
        });
93
 
*/              
94
 
    }
95
 
 
96
 
    // a click (or simulated click) is handled by handleObjEvent  
97
 
    var handleObjEvent = function(e){
98
 
        Y.one('.thing').setXY([(e.pageX),(e.pageY)]);   
99
 
        // in IE 9: 
100
 
        // native event the e.pageX and e.pageY have valid values, but,
101
 
        // simulated event the e.pageX and e.pageY == 0
102
 
        // e.clientX, and e.clientY have valid values in native events and simulated events.
103
 
         
104
 
        // this will work in both simulated and native
105
 
        //Y.one('.thing').setXY([(e.clientX),(e.clientY)]);
106
 
        // Changing Dial.js to use e.clientX/Y, seems too risky, post test-fest
107
 
                                                        
108
 
    }
109
 
    
110
 
    
111
 
    // a click on the button goes to handler that simulates a click on the .obj
112
 
    Y.on('click', handleSimMd, '.sim-md');
113
 
    
114
 
    // a click (or simulated click) is handled by handleObjEvent 
115
 
    Y.on('click', handleObjEvent, '.obj');
116
 
    
117
 
});
118
 
    
119
 
    
120
 
</script>
 
 
b'\\ No newline at end of file'