source: sandbox/2.3-MailArchiver/calendar/js/dhtmlx/sources/ext/ext_multiselect.js @ 6779

Revision 6779, 2.1 KB checked in by rafaelraymundo, 12 years ago (diff)

Ticket #2946 - Liberado Expresso(branch 2.3) integrado ao MailArchiver?.

Line 
1scheduler.form_blocks["multiselect"]={
2        render:function(sns) {
3                var _result = "<div class='dhx_multi_select_"+sns.name+"' style='overflow: auto; height: "+sns.height+"px; position: relative;' >";
4                for (var i=0; i<sns.options.length; i++) {
5                        _result += "<label><input type='checkbox' value='"+sns.options[i].key+"'/>"+sns.options[i].label+"</label>";
6                        if(convertStringToBoolean(sns.vertical)) _result += '<br/>';
7                }
8                _result += "</div>";
9                return _result;
10        },
11        set_value:function(node,value,ev,config){
12               
13                var _children = node.getElementsByTagName('input');
14                for(var i=0;i<_children.length;i++) {
15                        _children[i].checked = false; //unchecking all inputs on the form
16                }
17               
18                function _mark_inputs(ids) { // ids = [ 0: undefined, 1: undefined, 2: true ... ]
19                        var _children = node.getElementsByTagName('input');
20                        for(var i=0;i<_children.length; i++) {
21                                _children[i].checked = !! ids[_children[i].value];
22                        }                       
23                }
24               
25                if(!scheduler._new_event) { // if it is a new event - new to get saved options
26                        var _ids = [];
27                        if(ev[config.map_to]) {
28                                var results = ev[config.map_to].split(',');
29                                for(var i=0;i<results.length;i++){
30                                        _ids[results[i]] = true;
31                                }
32                                _mark_inputs(_ids);
33                        }
34                        else {
35                                var divLoading = document.createElement('div');
36                                divLoading.className='dhx_loading';
37                                divLoading.style.cssText = "position: absolute; top: 40%; left: 40%;";
38                                node.appendChild(divLoading);
39                                dhtmlxAjax.get(config.script_url+'?dhx_crosslink_'+config.map_to+'='+ev.id+'&uid='+scheduler.uid(), function(loader) {
40                                        var _result = loader.doXPath("//data/item");
41                                        var _ids = [];
42                                        for(var i=0;i<_result.length;i++){
43                                                _ids[_result[i].getAttribute(config.map_to)] = true;
44                                        }
45                                        _mark_inputs(_ids);
46                                        node.removeChild(divLoading);
47                                });
48                        }
49                }
50        },
51        get_value:function(node,ev,config){
52                var _result = [];
53                var _children = node.getElementsByTagName("input");
54                for(var i=0;i<_children.length;i++) {
55                        if(_children[i].checked)
56                                _result.push(_children[i].value);
57                }
58                return _result.join(',');
59        },
60       
61        focus:function(node){
62        }
63};
Note: See TracBrowser for help on using the repository browser.