Statistics
| Branch: | Revision:

blinker / firefox.plugin / data / scripts / modules / piemenuOption.js @ 76dd22bd

History | View | Annotate | Download (2.58 KB)

1 76dd22bd KevinTaron
/*
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() {
22
    $('body').append('<div class="gaze-piemenu"></div>');
23
    $('.gaze-piemenu').append('<div class="gaze-piemenu-background"></div>');
24
    $('.gaze-piemenu').append('<div class="gaze-piemenu-content"></div>');
25
});
26
27
28
function addItemsToPiemenu(elements, piemenu, contentvalue = '.gaze-piemenu-content') {
29
        var elementsLength = elements.length;
30
        var piemenuval = piemenu + " > " + contentvalue; 
31
        $(piemenuval).html('');
32
33
        elements.each(function(index, el) {
34
                var mydiv = '<div class="piemenu-' + elementsLength + '-' + (index + 1) + '">';
35
                mydiv += el;
36
                mydiv += '</div>';
37
                $(piemenuval).append(mydiv);        
38
        });
39
40
}
41
42
function getItemForPiemenu(element, type) {
43
        if(type == 'text') { return getTextElements(element); }
44
        if(type == 'action') { return getActionElements(element); }
45
        return getChoiceElements(element);
46
}
47
48
49
function getTextElements(element) {
50
        var elementType = $(element).get(0).tagName;
51
52
        switch(elementType) {
53
            case "INPUT":
54
                    return getPieMenuInput(element);
55
                break;
56
            case "DIV":
57
                    return getPieMenuDiv(element);
58
                break;
59
            default:
60
                console.log("ERROR MESSAGE: elementType not found - " + elementType);
61
        }
62
63
}
64
65
function getPieMenuInput(element) {
66
        var inputType = $(element).attr('type');
67
68
        switch(inputType) {
69
            case "text":
70
                    return getInputType(element);
71
                break;
72
            default:
73
                console.log("ERROR MESSAGE: elementType not found - " + elementType);
74
        }
75
76
}
77
78
function getPieMenuDiv(element) {
79
        var inputType = $(element).attr('gaze-piemenu');
80
81
        switch(inputType) {
82
            case "submenu":
83
                    return getInputSubMenu(element);
84
                break;
85
            default:
86
                console.log("ERROR MESSAGE: elementType not found - " + elementType);
87
        }
88
}