source: branches/1.2/workflow/js/jscode/generic_select.js @ 1349

Revision 1349, 2.1 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

  • Property svn:executable set to *
Line 
1var target;
2var target_desc;
3var source;
4
5function genericListSetLists(source_id,target_id)
6{
7        target                  = window.opener.document.getElementById(target_id);
8        target_desc     = window.opener.document.getElementById(target_id + "_desc");
9        source                  = window.document.getElementById(source_id);
10}
11
12function genericCheckShortcuts(e)
13{
14        var whichCode = (e.which) ? e.which : e.keyCode;
15        var handled = false;
16
17        if (whichCode == 13) /* ENTER */
18                handled = true;
19
20        if (whichCode == 27) /* ESC */
21        {
22                document.getElementById("closeButton").onclick();
23                handled = true;
24        }
25
26        if (whichCode == 38) /* key up */
27        {
28                if (source.selectedIndex > 0)
29                        if (!source[source.selectedIndex - 1].disabled)
30                                source.selectedIndex--;
31                handled = true;
32        }
33
34        if (whichCode == 40) /* key down */
35        {
36                if (source.selectedIndex < source.length - 1)
37                        if (!source[source.selectedIndex + 1].disabled)
38                                source.selectedIndex++;
39                handled = true;
40        }
41
42        return handled;
43}
44
45function genericListOptionFinder(oText, e)
46{
47        if (genericCheckShortcuts(e))
48                return true;
49
50        var searchText = oText.value.toUpperCase();
51        var textSize = searchText.length;
52        for(i = 0; i < source.length; i++)
53        if(source[i].text.substring(0 ,textSize).toUpperCase() == searchText)
54        {
55                source.value = source[i].value;
56                break;
57        }
58}
59
60function genericListAdd()
61{
62        for (var i = 0 ; i < source.length ; i++)
63                if (source.options[i].selected)
64                {
65                        target.value = source.options[i].value;
66                        target_desc.value = source.options[i].text;
67                        break;
68                }
69}
70
71function genericListRemove(target_name, target_desc_name)
72{
73        var target = document.getElementById(target_name);
74        var target_desc = document.getElementById(target_desc_name);
75        target.value = '';
76        target_desc.value = '';
77}
78
79function openGenericList(target, option)
80{
81        newWidth   = 350;
82        newHeight  = 500;
83        newScreenX = screen.width - newWidth;
84        newScreenY = 0;
85        page = 'index.php?menuaction=workflow.ui_generic_select.form';
86        if (target)
87                page += "&target_element=" + target;
88
89        if (option)
90                page += "&" + option;
91
92        window.open(page,'','width='+newWidth+',height='+newHeight+',screenX='+newScreenX+',left='+newScreenX+',screenY='+newScreenY+',top='+newScreenY+',toolbar=no,scrollbars=no,resizable=no');
93}
Note: See TracBrowser for help on using the repository browser.