blinker / firefox.plugin / data / scripts / choices / range.js @ 76dd22bd
History | View | Annotate | Download (3.118 KB)
1 |
/*
|
---|---|
2 |
* Copyright 2015 Thies Pfeiffer and Dimitri Heil and Kevin Taron
|
3 |
* Blinker is distributed under the terms of the GNU General Public License
|
4 |
*
|
5 |
* This file is part of Blinker.
|
6 |
*
|
7 |
* Blinker is free software: you can redistribute it and/or modify
|
8 |
* it under the terms of the GNU General Public License as published by
|
9 |
* the Free Software Foundation, either version 3 of the License, or
|
10 |
* (at your option) any later version.
|
11 |
*
|
12 |
* Blinker is distributed in the hope that it will be useful,
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
* GNU General Public License for more details.
|
16 |
*
|
17 |
* You should have received a copy of the GNU General Public License
|
18 |
* along with Blinker. If not, see <http://www.gnu.org/licenses/>.
|
19 |
*/
|
20 |
|
21 |
function getItemsForRange(element) { |
22 |
var min = $(element).attr('min'); |
23 |
var max = $(element).attr('max'); |
24 |
console.log("range element");
|
25 |
|
26 |
var myarray = [];
|
27 |
|
28 |
var minelement = '<div data-gaze="true" data-gaze-type="action" data-gaze-model="dwell"'; |
29 |
minelement += ' data-gaze-function-after="closeAll()" data-gaze-function="rangeSet(' + min + ')"'; |
30 |
minelement += '>';
|
31 |
minelement += 'Min';
|
32 |
minelement += '</div>';
|
33 |
|
34 |
var minuselementdrei = '<div data-gaze="true" data-gaze-type="action" data-gaze-model="dwell"'; |
35 |
minuselementdrei += 'data-gaze-function-after="closeAll()" data-gaze-function="rangeAdd(-3)"';
|
36 |
minuselementdrei += '>';
|
37 |
minuselementdrei += '-3';
|
38 |
minuselementdrei += '</div>';
|
39 |
|
40 |
var minuselement = '<div data-gaze="true" data-gaze-type="action" data-gaze-model="dwell"'; |
41 |
minuselement += 'data-gaze-function-after="closeAll()" data-gaze-function="rangeAdd(-1)"';
|
42 |
minuselement += '>';
|
43 |
minuselement += '-1';
|
44 |
minuselement += '</div>';
|
45 |
|
46 |
var pluselement = '<div data-gaze="true" data-gaze-type="action" data-gaze-model="dwell"'; |
47 |
pluselement += 'data-gaze-function-after="closeAll()" data-gaze-function="rangeAdd(1)"';
|
48 |
pluselement += '>';
|
49 |
pluselement += '+1';
|
50 |
pluselement += '</div>';
|
51 |
|
52 |
var pluselementdrei = '<div data-gaze="true" data-gaze-type="action" data-gaze-model="dwell"'; |
53 |
pluselementdrei += 'data-gaze-function-after="closeAll()" data-gaze-function="rangeAdd(3)"';
|
54 |
pluselementdrei += '>';
|
55 |
pluselementdrei += '+3';
|
56 |
pluselementdrei += '</div>';
|
57 |
|
58 |
var maxelement = '<div data-gaze="true" data-gaze-type="action" data-gaze-model="dwell"'; |
59 |
maxelement += 'data-gaze-function-after="closeAll()" data-gaze-function="rangeSet(' + max +')"'; |
60 |
maxelement += '>';
|
61 |
maxelement += 'Max';
|
62 |
maxelement += '</div>';
|
63 |
|
64 |
myarray.push(minelement); |
65 |
myarray.push(minuselementdrei); |
66 |
myarray.push(minuselement); |
67 |
myarray.push(pluselement); |
68 |
myarray.push(pluselementdrei); |
69 |
myarray.push(maxelement); |
70 |
|
71 |
return myarray;
|
72 |
} |
73 |
|
74 |
function rangeSet(value) { |
75 |
jQuery('.openedElement').attr('value', value); |
76 |
} |
77 |
|
78 |
function rangeAdd(value) { |
79 |
var initval = parseInt(jQuery('.openedElement').attr('value')); |
80 |
if(initval == null) { |
81 |
var max = jQuery('.openedElement').attr('max'); |
82 |
initval = parseInt(max) / 2;
|
83 |
} |
84 |
|
85 |
var val = initval + value;
|
86 |
jQuery('.openedElement').attr('value', val); |
87 |
} |