Dotclear


Ignore:
Timestamp:
11/17/13 20:25:53 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
2.6
Children:
2567:6c11245cbf04, 2568:61c67a7d17fa
Message:

Add some people in CREDITS, remove trailing spaces and tabs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/js/date-picker.js

    r0 r2566  
    22{ 
    33     if (!document.getElementById) { return; } 
    4       
     4 
    55     if (!target || target.nodeName.toLowerCase() != 'input') { 
    66          return; 
    77     } 
    8       
     8 
    99     this.target = target; 
    1010     this.oTable = document.createElement('table'); 
     
    1717     this.oTable.id = 'dc_datepicker_'+target.id; 
    1818     this.oTable.className = 'date-picker'; 
    19       
     19 
    2020     var cur = 1; 
    2121     var oRow, oHeading, oSpan; 
    22       
     22 
    2323     // Set title 
    2424     oRow = document.createElement('tr'); 
    25       
     25 
    2626     // Month block 
    2727     oHeading = document.createElement('th'); 
    2828     oHeading.colSpan = 4; 
    2929     oHeading.className = 'date-picker-month'; 
    30       
     30 
    3131     var nav = document.createElement('span'); 
    3232     nav.appendChild(document.createTextNode(String.fromCharCode(171))); 
     
    3636     nav.className = 'date-picker-control'; 
    3737     oHeading.appendChild(nav); 
    38       
    39      oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    40       
     38 
     39     oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
     40 
    4141     nav = document.createElement('span'); 
    4242     nav.appendChild(document.createTextNode(String.fromCharCode(187))); 
     
    4646     nav.className = 'date-picker-control'; 
    4747     oHeading.appendChild(nav); 
    48       
    49      oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    50       
     48 
     49     oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
     50 
    5151     oHeading.appendChild(this.oMonth); 
    52       
     52 
    5353     oRow.appendChild(oHeading); 
    54       
     54 
    5555     // Year block 
    5656     oHeading = document.createElement('th'); 
    5757     oHeading.colSpan = 3; 
    5858     oHeading.className = 'date-picker-year'; 
    59       
     59 
    6060     oHeading.appendChild(this.oYear); 
    61       
    62      oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    63       
     61 
     62     oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
     63 
    6464     nav = document.createElement('span'); 
    6565     nav.appendChild(document.createTextNode(String.fromCharCode(171))); 
     
    6969     nav.className = 'date-picker-control'; 
    7070     oHeading.appendChild(nav); 
    71       
    72      oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    73       
     71 
     72     oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
     73 
    7474     nav = document.createElement('span'); 
    7575     nav.appendChild(document.createTextNode(String.fromCharCode(187))); 
     
    7979     nav.className = 'date-picker-control'; 
    8080     oHeading.appendChild(nav); 
    81       
     81 
    8282     oRow.appendChild(oHeading); 
    83       
     83 
    8484     this.oBody.appendChild(oRow); 
    85       
     85 
    8686     // Create legend 
    8787     oRow = document.createElement('tr'); 
     
    9595     } 
    9696     this.oBody.appendChild(oRow); 
    97       
     97 
    9898     // Create 6 rows of 7 cols for days 
    9999     for (var i=0; i<6; i++) { 
    100100          oRow = document.createElement('tr'); 
    101            
     101 
    102102          for (var j=0; j<7; j++) { 
    103103               this.oDates[cur] = document.createElement('td'); 
     
    107107               cur++; 
    108108          } 
    109            
     109 
    110110          this.oBody.appendChild(oRow); 
    111111     } 
    112       
     112 
    113113     // Time controls 
    114114     oRow = document.createElement('tr'); 
    115       
     115 
    116116     oHeading = document.createElement('th'); 
    117117     oHeading.className = 'date-picker-control'; 
     
    121121     oHeading.obj = this; 
    122122     oHeading.onclick = function() { this.fn.call(this.obj); }; 
    123       
     123 
    124124     oRow.appendChild(oHeading); 
    125       
     125 
    126126     oHeading = document.createElement('th'); 
    127127     oHeading.colSpan = 5; 
    128       
     128 
    129129     oSpan = document.createElement('span'); 
    130130     oSpan.className = 'date-picker-control'; 
     
    143143     oHeading.appendChild(oSpan); 
    144144     oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    145       
     145 
    146146     this.oHour.size = 3; 
    147147     oHeading.appendChild(this.oHour); 
    148       
     148 
    149149     oHeading.appendChild(document.createTextNode(' : ')); 
    150       
     150 
    151151     this.oMinute.size = 3; 
    152152     oHeading.appendChild(this.oMinute); 
    153       
     153 
    154154     oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    155155     oSpan = document.createElement('span'); 
     
    167167     oSpan.obj = this; 
    168168     oSpan.onclick = function() { this.fn.call(this.obj,+1); }; 
    169       
     169 
    170170     oHeading.appendChild(oSpan); 
    171       
     171 
    172172     oRow.appendChild(oHeading); 
    173       
     173 
    174174     // Close control 
    175175     oHeading = document.createElement('th'); 
     
    180180     oHeading.obj = this; 
    181181     oHeading.onclick = function() { this.fn.call(this.obj); }; 
    182       
     182 
    183183     oRow.appendChild(oHeading); 
    184       
     184 
    185185     this.oBody.appendChild(oRow); 
    186186}; 
     
    192192     hour: 0, 
    193193     minute: 0, 
    194       
     194 
    195195     img_src: '', 
    196196     img_top: '0.2em', 
    197197     now_msg: 'now', 
    198198     close_msg: 'close', 
    199       
     199 
    200200     days: new Array('Monday','Tuesday','Wednesday','Thursday','Friday', 
    201201     'Saturday','Sunday'), 
    202       
     202 
    203203     months: new Array('January','February','March','April','May','June', 
    204204     'July','August','September','October','November','December'), 
    205       
    206       
     205 
     206 
    207207     setDate: function() { 
    208208          if (this.numberOfDays() < this.day) { 
    209209               this.day = this.numberOfDays(); 
    210210          } 
    211            
     211 
    212212          while (this.oYear.hasChildNodes()) { 
    213213               this.oYear.removeChild(this.oYear.firstChild) 
    214214          } 
    215215          this.oYear.appendChild(document.createTextNode(this.year)); 
    216            
     216 
    217217          while (this.oMonth.hasChildNodes()) { 
    218218               this.oMonth.removeChild(this.oMonth.firstChild) 
     
    220220          this.oMonth.appendChild(document.createTextNode( 
    221221               this.months[this.month-1])); 
    222            
     222 
    223223          var firstDay = this.firstDay(); 
    224224          var nbDays = this.numberOfDays(); 
    225            
     225 
    226226          // Empty days 
    227227          for (var i=1; i<=42; i++) { 
     
    233233               this.oDates[i].onclick = function() { return; }; 
    234234          } 
    235            
     235 
    236236          // Insert days from the first day to the last 
    237237          for (i=1; i<=nbDays; i++) { 
    238238               var j=firstDay+i-1; 
    239                 
     239 
    240240               while (this.oDates[j].hasChildNodes()) { 
    241241                    this.oDates[j].removeChild(this.oDates[j].firstChild) 
    242242               } 
    243                 
     243 
    244244               this.oDates[j].appendChild(document.createTextNode(i)); 
    245245               this.oDates[j].index = i; 
     
    253253               } 
    254254          } 
    255            
     255 
    256256          // Set time 
    257257          this.setHour(this.hour); 
    258258          this.setMinute(this.minute); 
    259259     }, 
    260       
     260 
    261261     setHour: function(h) { 
    262262          if (h < 0) { h = 23; } 
    263263          if (h > 23) { h = 0; } 
    264264          if (h < 10) { h = '0'+h; } 
    265            
     265 
    266266          this.hour = h*1; 
    267267          this.oHour.value = h; 
    268268     }, 
    269       
     269 
    270270     setMinute: function(m) { 
    271271          if (m < 0) { m = 59; } 
    272272          if (m > 59) { m = 0; } 
    273273          if (m < 10) { m = '0'+m; } 
    274            
     274 
    275275          this.minute = m*1; 
    276276          this.oMinute.value = m; 
    277277     }, 
    278       
     278 
    279279     changeMonth: function(dir) { 
    280280          var y = this.year; 
    281281          var m = this.month; 
    282282          m = m+dir; 
    283            
     283 
    284284          if (m > 12) { this.month = 1; this.year++; } 
    285285          else if ( m < 1) { this.month = 12; this.year--; } 
    286286          else { this.month = m; } 
    287            
     287 
    288288          this.setDate(); 
    289289     }, 
    290       
     290 
    291291     changeYear: function(dir) { 
    292292          this.year = this.year + dir; 
    293293          this.setDate(); 
    294294     }, 
    295       
     295 
    296296     changeHour: function(dir) { 
    297297          this.setHour(this.hour*1+dir); 
    298298     }, 
    299       
     299 
    300300     changeMinute: function(dir) { 
    301301          this.setMinute(this.minute*1+dir); 
    302302     }, 
    303       
     303 
    304304     sendDate: function(d) { 
    305305          var m = this.month; 
    306306          var hour = this.oHour.value*1; 
    307307          var minute = this.oMinute.value*1; 
    308            
     308 
    309309          if (hour < 0 || hour > 23 || isNaN(hour)) { hour = 0; } 
    310310          if (minute < 0 || minute > 59 || isNaN(minute)) { minute = 0; } 
    311            
     311 
    312312          if (m < 10) { m = '0'+m; } 
    313313          if (d < 10) { d = '0'+d; } 
    314314          if (hour < 10) { hour = '0'+hour; } 
    315315          if (minute < 10) { minute = '0'+minute; } 
    316            
     316 
    317317          this.target.value = this.year+'-'+m+'-'+d+' '+hour+':'+minute; 
    318318          this.close(); 
    319319     }, 
    320       
     320 
    321321     sendNow: function() { 
    322322          var dt = new Date(); 
     
    326326          var h = dt.getHours(); 
    327327          var i = dt.getMinutes(); 
    328            
     328 
    329329          if (m < 10) { m = '0'+m; } 
    330330          if (d < 10) { d = '0'+d; } 
    331331          if (h < 10) { h = '0'+h; } 
    332332          if (i < 10) { i = '0'+i; } 
    333            
     333 
    334334          this.target.value = y+'-'+m+'-'+d+' '+h+':'+i; 
    335335          this.close(); 
    336336     }, 
    337       
     337 
    338338     close: function() { 
    339339          document.body.removeChild(this.oTable); 
    340340     }, 
    341       
     341 
    342342     numberOfDays: function() { 
    343343          var res = 31; 
     
    352352               } 
    353353          } 
    354            
     354 
    355355          return res; 
    356356     }, 
    357       
     357 
    358358     firstDay: function() { 
    359359          var dt = new Date(this.year,this.month-1,1); 
    360360          var res = dt.getDay(); 
    361            
     361 
    362362          if (res == 0) { 
    363363               res = 7; 
    364364          } 
    365            
     365 
    366366          return res; 
    367367     }, 
    368       
     368 
    369369     show: function() { 
    370370          // Parsing target value 
     
    385385               this.minute = dt.getMinutes(); 
    386386          } 
    387            
     387 
    388388          this.oTable.appendChild(this.oBody); 
    389389          this.setDate(); 
     
    392392          this.oHour.focus(); 
    393393     }, 
    394       
     394 
    395395     setPosition: function() { 
    396396          var t_x = this.findPosX(this.target); 
     
    398398          var o_h = this.oTable.offsetHeight; 
    399399          var o_w = this.oTable.offsetWidth; 
    400            
     400 
    401401          this.oTable.style.position = 'absolute'; 
    402402          this.oTable.style.zIndex = '100'; 
     
    404404          this.oTable.style.left = t_x+'px'; 
    405405     }, 
    406       
     406 
    407407     findPosX: function(obj) { 
    408408          var curleft = 0; 
     
    420420          return curleft; 
    421421     }, 
    422       
     422 
    423423     findPosY: function(obj) { 
    424424          var curtop = 0; 
     
    436436          return curtop; 
    437437     }, 
    438       
     438 
    439439     draw: function() { 
    440440          var imgE = document.createElement('img'); 
     
    446446          imgE.fn = this.show; 
    447447          imgE.onclick = function() { this.fn.apply(this.obj); }; 
    448            
     448 
    449449          this.target.parentNode.style.position = 'relative'; 
    450450          this.target.parentNode.insertBefore(imgE,this.target.nextSibling); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map