source: branches/2.2.0.1/calendar/js/dhtmlx/sources/ext/ext_readonly.js @ 4001

Revision 4001, 3.1 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1615 - Componente novo para agenda......................................

Line 
1scheduler.attachEvent("onTemplatesReady",function(){
2   scheduler.attachEvent("onBeforeLightbox",function(id){
3      if (this.config.readonly_form || this.getEvent(id).readonly)
4         this.config.readonly_active = true;
5      else {
6         this.config.readonly_active = false;
7         return true;
8      }
9         
10      for (var i=0; i < this.config.lightbox.sections.length; i++) {
11         this.config.lightbox.sections[i].focus = false;
12      };
13     
14      return true;
15   });
16   
17        function txt_replace(tag,d,n,text){
18                var txts = d.getElementsByTagName(tag);
19                var txtt = n.getElementsByTagName(tag);
20                for (var i=txtt.length-1; i>=0; i--){
21                        var n = txtt[i];
22                        if (!text)
23                                n.disabled = true;
24                        else {
25                                var t = document.createElement("SPAN");
26                                t.className = "dhx_text_disabled";
27                                t.innerHTML=text(txts[i]);
28                                n.parentNode.insertBefore(t,n);
29                                n.parentNode.removeChild(n);   
30                        }
31                }
32        }
33   
34   var old = scheduler._fill_lightbox;
35   scheduler._fill_lightbox=function(){
36      var sns = this.config.lightbox.sections;
37      if (this.config.readonly_active){
38         for (var i=0; i < sns.length; i++) {
39            if (sns[i].type == 'recurring') {
40               var s = document.getElementById(sns[i].id);
41               s.style.display=s.nextSibling.style.display='none';
42               sns.splice(i,1);
43               i--;
44            }
45         };
46      }
47     
48      var res = old.apply(this,arguments);
49      if (this.config.readonly_active){
50         
51         var d = this._get_lightbox();
52         var n = this._lightbox_r = d.cloneNode(true);
53         
54         txt_replace("textarea",d,n,function(a){ return a.value; });
55         txt_replace("input",d,n,false);
56         txt_replace("select",d,n,function(a){ return a.options[Math.max((a.selectedIndex||0),0)].text; });
57           
58         n.removeChild(n.childNodes[2]);
59         n.removeChild(n.childNodes[3]);
60         
61         d.parentNode.insertBefore(n,d);
62         
63         olds.call(this,n);
64         this._lightbox = n;
65         this.setLightboxSize();
66         this._lightbox = null;
67         n.onclick=function(e){
68            var src=e?e.target:event.srcElement;
69            if (!src.className) src=src.previousSibling;
70            if (src && src.className)
71               switch(src.className){
72                  case "dhx_cancel_btn":
73                     scheduler.callEvent("onEventCancel",[scheduler._lightbox_id]);
74                     scheduler._edit_stop_event(scheduler.getEvent(scheduler._lightbox_id),false);
75                     scheduler.hide_lightbox();
76                     break;
77               }
78         };
79      }
80      return res;
81   };
82   
83        var olds = scheduler.showCover;
84        scheduler.showCover=function(){
85                if (!this.config.readonly_active)
86                        olds.apply(this,arguments);
87        };
88   
89   var hold = scheduler.hide_lightbox;
90   scheduler.hide_lightbox=function(){
91      if (this._lightbox_r){
92         this._lightbox_r.parentNode.removeChild(this._lightbox_r);
93         this._lightbox_r = null;
94      }
95     
96      return hold.apply(this,arguments);
97   };
98   
99   
100});
Note: See TracBrowser for help on using the repository browser.