/lenasys/0.1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/0.1

« back to all changes in this revision

Viewing changes to Widget Library/sliderdemo.js

  • Committer: Gustav Hartvigsson
  • Date: 2013-04-03 15:20:28 UTC
  • mfrom: (9.2.3 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130403152028-2pxwtfhr0c8rduy4
Merging the changes made by implementation group 2 from 20130403 into trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Recursive Pos of div in document - should work in most browsers
2
 
function findPos(obj) {
3
 
        var curleft = curtop = 0;
4
 
        if (obj.offsetParent) {
5
 
                curleft = obj.offsetLeft;
6
 
                curtop = obj.offsetTop;
7
 
                while (obj = obj.offsetParent) {
8
 
                        curleft += obj.offsetLeft;
9
 
                        curtop += obj.offsetTop;
10
 
                }
11
 
        }
12
 
        return {
13
 
                x:curleft,
14
 
                y:curtop
15
 
        }
16
 
}
17
 
 
18
 
// The idea is to have a few functions like this one and minimum javascript intervention                
19
 
function updateslider(e, kind, smin, smax, slen, sliderid, boxid) {
20
 
        if(mb) {
21
 
                coords = findPos(e.currentTarget);
22
 
                coords.x = e.clientX - coords.x;
23
 
                coords.y = e.clientY - coords.y;
24
 
                cx = coords.x / slen;
25
 
                sd = smax - smin;
26
 
                val = smin + (sd * cx);
27
 
                if(kind == 1) {
28
 
                        val = Math.round(val);
29
 
                }
30
 
                document.getElementById(boxid).value = val;                             
31
 
                document.getElementById(sliderid).style.left = Math.ceil((slen) * ((val - smin) / sd))+"px";
32
 
        }
33
 
}
34
 
 
35
 
var mb = 0;
36
 
 
37
 
function mbpress(e) {
38
 
        mb = 1;
39
 
}
40
 
 
41
 
function mbrelease(e) {
42
 
        mb = 0;
43
 
}
 
 
b'\\ No newline at end of file'