/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: c11emian
  • Date: 2013-04-03 12:27:12 UTC
  • mfrom: (9 lenasys)
  • mto: (9.2.2 lenasys)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: c11emian@student.his.se-20130403122712-ha93wrxm4isfv16h
Adjusted the file showcode.php so that it conforms to our code standard.

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'