forms.js 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307
  1. /*
  2. CalDavZAP - the open source CalDAV Web Client
  3. Copyright (C) 2011-2015
  4. Jan Mate <jan.mate@inf-it.com>
  5. Andrej Lezo <andrej.lezo@inf-it.com>
  6. Matej Mihalik <matej.mihalik@inf-it.com>
  7. This program is free software: you can redistribute it and/or modify
  8. it under the terms of the GNU Affero General Public License as
  9. published by the Free Software Foundation, either version 3 of the
  10. License, or (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Affero General Public License for more details.
  15. You should have received a copy of the GNU Affero General Public License
  16. along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. function updateTodoFormDimensions(setHeight)
  19. {
  20. $('#CATodo').css('width','');
  21. $('#CATodo').css('width',$('#todo_details_template').css('width'));
  22. if(setHeight)
  23. {
  24. $('#CATodo').css('height','');
  25. $('#CATodo').css('height',$('#todo_details_template').css('height'));
  26. }
  27. }
  28. function updateEventFormDimensions(setHeight)
  29. {
  30. $('#CAEvent').css('width','');
  31. $('#CAEvent').css('width',$('#event_details_template').css('width'));
  32. if(setHeight)
  33. {
  34. $('#CAEvent').css('height','');
  35. $('#CAEvent').css('height',$('#event_details_template').css('height'));
  36. }
  37. }
  38. function setFormPosition(jsEvent, confirmRepeat)
  39. {
  40. var position_x,
  41. position_y,
  42. dist_x,
  43. dist_y;
  44. $('#event_details_template').css('max-height','');
  45. if(jsEvent)
  46. {
  47. if(jsEvent.pageX<=($('#main').width()/2))
  48. {
  49. position_v='left';
  50. dist_x=jsEvent.pageX;
  51. }
  52. else
  53. {
  54. position_v='right';
  55. dist_x=$('body').width()-jsEvent.pageX;
  56. }
  57. /*if(jsEvent.pageY<=($('#main').height()/2))
  58. {
  59. position_h='top';
  60. dist_y=jsEvent.pageY;
  61. }
  62. else
  63. {
  64. position_h='top';
  65. dist_y=jsEvent.pageY-$('#event_details_template').height();
  66. }*/
  67. position_h='top';
  68. dist_y=Math.max(29, jsEvent.pageY-(confirmRepeat ? $('#CAEvent').height() : $('#event_details_template').height()));
  69. }
  70. else
  71. {
  72. position_v='right';
  73. position_h='top';
  74. dist_x=25;
  75. dist_y=29;
  76. }
  77. $('#CAEvent').css('left','');
  78. $('#CAEvent').css('right','');
  79. $('#CAEvent').css('top','');
  80. $('#CAEvent').css('bottom','');
  81. $('#CAEvent').css(position_v, dist_x);
  82. $('#CAEvent').css(position_h, dist_y);
  83. $('#event_details_template').css('max-height', $('#main').height()-dist_y+20+'px');
  84. $('#CAEvent').css('max-height', $('#main').height()-dist_y+20+'px');
  85. }
  86. function setTodoPosition(jsEvent)
  87. {
  88. var dist,
  89. pointY=0;
  90. $('#todo_details_template').css('max-height','');
  91. $('#CATodo').css('max-height','');
  92. if(jsEvent!=undefined)
  93. {
  94. if(jsEvent.pageY!=undefined)
  95. pointY=jsEvent.pageY;
  96. else
  97. pointY=jsEvent.clientY;
  98. }
  99. if(jsEvent)
  100. {
  101. /*if((pointY)+$('#todo_details_template').height()<$(window).height())
  102. dist=jsEvent.pageY;
  103. else
  104. dist=pointY-$('#todo_details_template').height();*/
  105. dist=Math.max(25, jsEvent.pageY-$('#todo_details_template').height());
  106. }
  107. else
  108. dist=25;
  109. $('#CATodo').css('left','');
  110. $('#CATodo').css('right','');
  111. $('#CATodo').css('top','');
  112. $('#CATodo').css('bottom','');
  113. $('#CATodo').css('top', dist);
  114. $('#todo_details_template').css('right', 0);
  115. $('#CATodo').css('right', 25);
  116. $('#todo_details_template').css('max-height', $('#main').height()-dist+20+'px');
  117. $('#CATodo').css('max-height', $('#main').height()-dist+20+'px');
  118. }
  119. function showTimezones(selTimezone, todoSelector)
  120. {
  121. if(!globalSettings.timezonesupport.value)
  122. return false;
  123. var select=$('#timezone'+todoSelector);
  124. select.empty();
  125. var isFirst=false;
  126. for(var izone in timezoneKeys)
  127. {
  128. if(timeZonesEnabled.indexOf(timezoneKeys[izone])==-1)
  129. continue;
  130. if(!isNaN(izone))
  131. {
  132. var tmp=null;
  133. if(!isFirst)
  134. {
  135. tmp=$('<option>');
  136. tmp.attr('data-type','local');
  137. isFirst=true;
  138. if(!(selTimezone in timezones) && selTimezone!= '' && selTimezone!= 'local' && (globalSettings.removeunknowntimezone.value == null || !globalSettings.removeunknowntimezone.value))
  139. {
  140. tmp.text(localization[globalInterfaceLanguage].customTimezone);
  141. tmp.attr('value','custom');
  142. if((todoSelector=='PickerTODO' || todoSelector=='Picker') && globalSettings.timezone.value != null)
  143. tmp.attr('value',globalSettings.timezone.value);
  144. select.append(tmp);
  145. }
  146. }
  147. tmp=$('<option>');
  148. tmp.attr('data-type',timezoneKeys[izone]);
  149. if(izone==0)
  150. {
  151. tmp.text(localization[globalInterfaceLanguage].localTime);
  152. tmp.attr('value','local');
  153. select.append(tmp);
  154. }
  155. else
  156. {
  157. tmp.text(timezoneKeys[izone]);
  158. tmp.attr('value',timezoneKeys[izone]);
  159. select.append(tmp);
  160. }
  161. }
  162. }
  163. if(!selTimezone && typeof globalSessionTimeZone!='undefined' && globalSessionTimeZone)
  164. selTimezone=globalSessionTimeZone;
  165. if(selTimezone in timezones)
  166. select.val(selTimezone);
  167. else
  168. {
  169. if((globalSettings.removeunknowntimezone.value != null && globalSettings.removeunknowntimezone.value) || selTimezone == 'local')
  170. select.val('local');
  171. else
  172. select.val('custom');
  173. }
  174. }
  175. function showTodoForm(todo, mod, repeatOne, confirmRepeat)
  176. {
  177. $('#CATodo').css('display','none');
  178. $('#todo_details_template').remove();
  179. $('#CATodo').html(cleanVtodoTemplate);
  180. setFirstDayTodo();
  181. bindTodoForm();
  182. $('#noteTODO').autosize({defaultStyles: {height: '64', overflow: '', 'overflow-y': '', 'word-wrap': '', resize: 'none'}, callback: function(){checkTodoFormScrollBar();}});
  183. $("#showTODO").val('');
  184. $("#uidTODO").val('');
  185. $("#etagTODO").val('');
  186. $("#vcalendarUIDTODO").val('');
  187. globalPrevDate='';
  188. globalObjectLoading=true;
  189. var color='';
  190. if(todo==null)
  191. {
  192. var activeCollection = $('#ResourceCalDAVTODOList').find('.resourceCalDAVTODO_item.resourceCalDAV_item_selected');
  193. if(activeCollection.length>0 && !globalResourceCalDAVList.getTodoCollectionByUID(activeCollection.attr('data-id')).permissions.read_only)
  194. color=rgbToHex(activeCollection.children('.resourceCalDAVColor').css('background-color'));
  195. }
  196. else
  197. color=globalResourceCalDAVList.getTodoCollectionByUID(todo.res_id).ecolor;
  198. if(confirmRepeat)
  199. {
  200. $('#showTODO').val(todo.id);
  201. $('#repeatTodo').val(true);
  202. $('#CATodo').show();
  203. $('#repeatConfirmBoxTODO').css('visibility', 'visible');
  204. if(todo.repeatCount!='' && todo.repeatCount == 1 || globalSettings.appleremindersmode.value)
  205. {
  206. $('#editFutureTODO').css('display','none');
  207. if($('#editFutureTODO').next('br').length>0)
  208. $('#editFutureTODO').next().remove();
  209. }
  210. else if($('#editFutureTODO').css('display')=='none')
  211. {
  212. $('#editFutureTODO').css('display','block');
  213. if($('#editFutureTODO').next('br').length==0)
  214. $('#editFutureTODO').after('<br/>')
  215. }
  216. $('#editAllTODO, #editOnlyOneTODO, #editFutureTODO').click(function(){
  217. if(globalCalTodo)
  218. {
  219. if($(this).attr('id')=='editOnlyOneTODO')
  220. showTodoForm(globalCalTodo, 'show', 'editOnly');
  221. else if($(this).attr('id')=='editAllTODO')
  222. showTodoForm(globalCalTodo, 'show', '');
  223. else if($(this).attr('id')=='editFutureTODO')
  224. showTodoForm(globalCalTodo, 'show', 'futureOnly');
  225. $('#repeatConfirmBoxContentTODO').html('');
  226. $('#repeatConfirmBoxTODO').css('visibility', 'hidden');
  227. $('#todo_details_template').css('visibility', 'visible');
  228. $('#AlertDisabler').fadeOut(globalEditorFadeAnimation);
  229. }
  230. });
  231. $('#repeatConfirmBoxContentTODO').html('<b>'+todo.title+"</b> "+localization[globalInterfaceLanguage].repeatBoxContentTODO);
  232. $('#repeatConfirmBoxQuestionTODO').html(localization[globalInterfaceLanguage].repeatBoxQuestionTODO);
  233. $('#todo_details_template').css('visibility', 'hidden');
  234. globalObjectLoading=false;
  235. $('#CATodo').show(200, function(){
  236. $('#todoColor').css('background-color',color);
  237. checkTodoFormScrollBar();
  238. $('#todoForm').scrollTop(0);
  239. });
  240. return true;
  241. }
  242. if(mod=='show' && repeatOne=='futureOnly')
  243. {
  244. if(todo.start!=null)
  245. $('#futureStartTODO').val(todo.realRepeatCount+';'+todo.start);
  246. else if(todo.end!=null)
  247. $('#futureStartTODO').val(todo.realRepeatCount+';'+todo.end);
  248. }
  249. if(mod=='show')
  250. {
  251. var checkDataStart='';
  252. if(todo.start)
  253. checkDataStart=$.fullCalendar.formatDate(todo.start, "yyyyMMdd'T'HHmmss'Z'");
  254. if($('.fc-event-selected').length>0 && $('.fc-event-selected').attr("data-start")!=checkDataStart)
  255. $('.fc-view-todo').addClass('fc-view-trans');
  256. else
  257. $('.fc-view-todo').removeClass('fc-view-trans');
  258. }
  259. if(repeatOne=='editOnly')
  260. if(todo!=null && (todo.type || todo.rec_id))
  261. {
  262. var eventsSorted=jQuery.grep(globalEventList.displayTodosArray[todo.res_id],function(e){if(e.id==todo.id)return true}).sort(repeatStartCompare);
  263. if(eventsSorted.indexOf(todo)!=-1)
  264. {
  265. if(eventsSorted.indexOf(todo)<(eventsSorted.length-1))
  266. showTodoNextNav();
  267. if(eventsSorted.indexOf(todo)!=0)
  268. showTodoPrevNav();
  269. var uncomplete=0;
  270. for(var ij=(eventsSorted.indexOf(todo)+1); ij<eventsSorted.length; ij++)
  271. if(eventsSorted[ij].status!='COMPLETED')
  272. uncomplete++;
  273. if(uncomplete>0 && eventsSorted.indexOf(todo)<(eventsSorted.length-1))
  274. showTodoNextNav(true);
  275. var uncomplete=0;
  276. for(var ij=(eventsSorted.indexOf(todo)-1); ij>=0; ij--)
  277. if(eventsSorted[ij].status!='COMPLETED')
  278. uncomplete++;
  279. if(uncomplete>0 && eventsSorted.indexOf(todo)!=0)
  280. showTodoPrevNav(true);
  281. }
  282. }
  283. if(todo!=null)
  284. {
  285. var prior=parseInt(todo.priority,10);
  286. if(prior==5)
  287. $('#priority_TODO').val(5);
  288. else if(prior>5 && prior<10)
  289. {
  290. $('#priority_TODO [data-type="priority_TODO_low"]').attr('value',prior)
  291. $('#priority_TODO').val(prior);
  292. }
  293. else if(prior<5 && prior>0)
  294. {
  295. $('#priority_TODO [data-type="priority_TODO_high"]').attr('value',prior)
  296. $('#priority_TODO').val(prior);
  297. }
  298. else
  299. $('#priority_TODO').val(0);
  300. }
  301. if(todo!=null)
  302. var sliderValue=todo.percent;
  303. else
  304. sliderValue=0;
  305. var cals=globalResourceCalDAVList.sortedTodoCollections;
  306. var todoCalendarObj = $('#todo_calendar');
  307. var calSelected = $('.resourceCalDAVTODO_item.resourceCalDAV_item_selected').attr('data-id');
  308. for(var i=0;i<cals.length;i++)
  309. {
  310. if( cals[i].uid!=undefined && ((todo!=null && todo.res_id==cals[i].uid) || (cals[i].makeLoaded && !cals[i].permissions_read_only)))
  311. {
  312. todoCalendarObj.append(new Option(cals[i].displayValue,cals[i].uid));
  313. }
  314. }
  315. if(mod!='new')
  316. fullVcalendarToTodoData(todo,true);
  317. else
  318. CalDAVeditor_cleanup('form');
  319. if(mod=='new')
  320. {
  321. $('#todoInEdit').val('true');
  322. $('#deleteTODO').hide();
  323. $('#resetTODO').hide();
  324. $('#editTODO').hide();
  325. $('#duplicateTODO').hide();
  326. $('#editOptionsButtonTODO').hide();
  327. $('#showTODO').val('');
  328. if($('#ResourceCalDAVTODOList').find('.resourceCalDAVTODO_item.resourceCalDAV_item_selected').length>0 && $('#todo_calendar').find('option[value="'+$('#ResourceCalDAVTODOList').find('.resourceCalDAVTODO_item.resourceCalDAV_item_selected').attr("data-id")+'"]').length>0)
  329. $('#todo_calendar').val($('#ResourceCalDAVTODOList').find('.resourceCalDAVTODO_item.resourceCalDAV_item_selected').attr("data-id"));
  330. else
  331. $('#todo_calendar').val('choose');
  332. //$('[data-type="name_TODO"]').attr('placeholder', localization[globalInterfaceLanguage].pholderNewTODO);
  333. showTimezones('', 'TODO');
  334. $('.timezone_rowTODO').css('display','none')
  335. }
  336. $('#CATodo').show();
  337. $('#todo_details_template').show();
  338. if(globalSettings.appleremindersmode.value)
  339. {
  340. $('[data-type="todo_type_start"], [data-type="todo_type_both"]').remove();
  341. if(typeof globalSettings.appleremindersmode.value == 'string' && globalSettings.appleremindersmode.value.toLowerCase()=='ios6')
  342. {
  343. $('#url_trTODO').hide();
  344. $('#location_row_TODO').hide();
  345. }
  346. $('[data-type="STATUS_CANCELLED_TODO"],[data-type="STATUS_IN-PROCESS_TODO"]').remove();
  347. }
  348. if(mod=='show')
  349. {
  350. $('#showTODO').val(todo.id);
  351. $('#todoDetailsTable :input[type!="button"]').prop('disabled', true);
  352. if(todo.timeZone)
  353. showTimezones(todo.timeZone,'TODO');
  354. else
  355. showTimezones('local','TODO');
  356. if(todo.etag!='')
  357. $('#todo_calendar').val(todo.res_id);
  358. $('#nameTODO').val(todo.title);
  359. if(todo.status=='CANCELLED')
  360. $('#nameTODO').addClass('title_cancelled');
  361. if(todo.start!=null || todo.end!=null)
  362. {
  363. if((!globalSettings.appleremindersmode.value) && ((todo.start!=null && todo.end!=null && repeatOne!='') || (!todo.type && todo.realStart!='' && todo.realEnd!='' && repeatOne=='') || (todo.type && todo.repeatStart!='' && todo.repeatEnd!='' && repeatOne=='')))
  364. $('#todo_type').val('both');
  365. else if((!globalSettings.appleremindersmode.value) && ((todo.start!=null && todo.end==null && repeatOne!='') || (!todo.type && todo.realStart!='' && todo.realEnd=='' && repeatOne=='') || (todo.type && todo.repeatStart!='' && todo.repeatEnd=='' && repeatOne=='')))
  366. $('#todo_type').val('start');
  367. else
  368. $('#todo_type').val('due');
  369. if(globalSettings.timezonesupport.value)
  370. $('.timezone_rowTODO').show();
  371. }
  372. else
  373. {
  374. $('#todo_type').val('none');
  375. $('.timezone_rowTODO').css('display','none');
  376. }
  377. if(todo.start!='' && todo.start!=null)
  378. {
  379. var date,
  380. year,
  381. month,
  382. day,
  383. hour,
  384. minute;
  385. if(todo.realStart)
  386. date=$.fullCalendar.parseDate(todo.realStart);
  387. else
  388. date=$.fullCalendar.parseDate(todo.start);
  389. if($('#showTODO').val()!='' && todo.repeatStart!='' && repeatOne=='')
  390. date=todo.repeatStart;
  391. else if($('#showTODO').val()!='' && todo.repeatStart=='' && repeatOne=='' && todo.type)
  392. date='';
  393. if(date)
  394. {
  395. (date.getHours())<10 ? (hour='0'+(date.getHours())) : (hour=date.getHours());
  396. (date.getMinutes())<10 ? (minute='0'+(date.getMinutes())) : (minute=date.getMinutes());
  397. var formattedDate=$.datepicker.formatDate(globalSettings.datepickerformat.value, date);
  398. $('#date_fromTODO').val(formattedDate);
  399. if($('#todo_type').val=='both')
  400. globalPrevDate = new Date(date.getTime());
  401. $('#time_fromTODO').val($.fullCalendar.formatDate(date, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  402. }
  403. }
  404. if(todo.end!='' && todo.end!=null)
  405. {
  406. if(todo.realEnd)
  407. date=$.fullCalendar.parseDate(todo.realEnd);
  408. else
  409. date=$.fullCalendar.parseDate(todo.end);
  410. if($('#showTODO').val()!='' && todo.repeatEnd!='' && repeatOne=='')
  411. date=todo.repeatEnd;
  412. else if($('#showTODO').val()!='' && todo.repeatEnd=='' && repeatOne=='' && todo.type)
  413. date='';
  414. if(date)
  415. {
  416. (date.getHours())<10 ? (hour='0'+(date.getHours())) : (hour=date.getHours());
  417. (date.getMinutes())<10 ? (minute='0'+(date.getMinutes())) : (minute=date.getMinutes());
  418. var formattedDate_to=$.datepicker.formatDate(globalSettings.datepickerformat.value, date);
  419. $('#date_toTODO').val(formattedDate_to);
  420. $('#time_toTODO').val($.fullCalendar.formatDate(date, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  421. }
  422. }
  423. if(repeatOne=='editOnly' && todo.rec_id=='')
  424. {
  425. if(todo.repeatStart!='' && todo.start)
  426. {
  427. if(typeof todo.realStart=='object')
  428. $('#recurrenceIDTODO').val($.fullCalendar.formatDate(todo.realStart, "yyyyMMdd'T'HHmmss"));
  429. else if(typeof todo.realStart =='string')
  430. $('#recurrenceIDTODO').val($.fullCalendar.formatDate($.fullCalendar.parseDate(todo.realStart), "yyyyMMdd'T'HHmmss"));
  431. }
  432. else if(todo.repeatEnd!='' && todo.end)
  433. {
  434. if(typeof todo.realEnd =='object')
  435. $('#recurrenceIDTODO').val($.fullCalendar.formatDate(todo.realEnd, "yyyyMMdd'T'HHmmss"));
  436. else if(typeof todo.realEnd =='string')
  437. $('#recurrenceIDTODO').val($.fullCalendar.formatDate($.fullCalendar.parseDate(todo.realEnd), "yyyyMMdd'T'HHmmss"));
  438. }
  439. }
  440. else
  441. $('#recurrenceIDTODO').val(todo.rec_id);
  442. if(todo.rec_id || repeatOne=='editOnly' || repeatOne=='futureOnly')
  443. {
  444. var savedEvs=jQuery.grep(globalEventList.displayTodosArray[todo.res_id],function(e){if(e.id==todo.id && (e.repeatCount<2 || !e.repeatCount))return true});
  445. if(savedEvs.length>1 || (repeatOne=='futureOnly' && todo.repeatCount>1) || (repeatOne=='editOnly' && todo.type!=''))
  446. {
  447. $('#deleteTODO').attr('onclick',"$('#todoInEdit').val('false');updateEventFormDimensions(true);$('#todoLoader').show();saveTodo(true);");
  448. }
  449. }
  450. if(todo.completedOn!='' && todo.completedOn!=null)
  451. {
  452. var date,
  453. year,
  454. month,
  455. day,
  456. hour,
  457. minute;
  458. // (todo.completedOn.getHours())<10 ? (hour='0'+(todo.completedOn.getHours())) : (hour=todo.completedOn.getHours());
  459. // (todo.completedOn.getMinutes())<10 ? (minute='0'+(todo.completedOn.getMinutes())) : (minute=todo.completedOn.getMinutes());
  460. if(typeof todo.completedOn=='string')
  461. date = $.fullCalendar.parseDate(todo.completedOn);
  462. else if(typeof todo.completedOn=='object')
  463. date=new Date(todo.completedOn.getTime());
  464. var formattedDate=$.datepicker.formatDate(globalSettings.datepickerformat.value, date);
  465. $('#completedOnDate').val(formattedDate);
  466. $('#completedOnTime').val($.fullCalendar.formatDate(date, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  467. $('.completedOnTr').show();
  468. }
  469. var alarmDate='';
  470. var alarmIterator=0;
  471. for(alarmIterator=0;alarmIterator<todo.alertTime.length;alarmIterator++)
  472. {
  473. if(alarmIterator>0)
  474. todo_alert_add(alarmIterator);
  475. $(".alertTODO[data-id="+(alarmIterator+1)+"]").val("message");
  476. if(todo.alertTime[alarmIterator].charAt(0)=='-' || todo.alertTime[alarmIterator].charAt(0)=='+')
  477. {
  478. var alVal=parseInt(todo.alertTime[alarmIterator].substring(1, todo.alertTime[alarmIterator].length-1));
  479. var alString='';
  480. if(todo.alertTime[alarmIterator].charAt(todo.alertTime[alarmIterator].length-1)=="W")
  481. {
  482. alVal=alVal/1000/60/60/24/7;
  483. alString='weeks';
  484. }
  485. else if(todo.alertTime[alarmIterator].charAt(todo.alertTime[alarmIterator].length-1)=="D")
  486. {
  487. alVal=alVal/1000/60/60/24;
  488. alString='days';
  489. }
  490. else if(todo.alertTime[alarmIterator].charAt(todo.alertTime[alarmIterator].length-1)=="H")
  491. {
  492. alVal=alVal/1000/60/60;
  493. alString='hours';
  494. }
  495. else if(todo.alertTime[alarmIterator].charAt(todo.alertTime[alarmIterator].length-1)=="M")
  496. {
  497. alVal=alVal/1000/60;
  498. alString='minutes';
  499. }
  500. else if(todo.alertTime[alarmIterator].charAt(todo.alertTime[alarmIterator].length-1)=="S")
  501. {
  502. alVal=alVal/1000;
  503. alString='seconds';
  504. }
  505. if(todo.alertTime[alarmIterator].charAt(0)=='-')
  506. alString+="_before";
  507. else
  508. alString+="_after"
  509. $(".alert_message_detailsTODO[data-id="+(alarmIterator+1)+"]").val(alString);
  510. $(".before_after_inputTODO[data-id="+(alarmIterator+1)+"]").val(alVal);
  511. $('.alert_detailsTODO[data-id="'+(alarmIterator+1)+'"]').show();
  512. $('.alert_message_dateTODO[data-id="'+(alarmIterator+1)+'"]').show();
  513. $('.before_after_inputTODO[data-id="'+(alarmIterator+1)+'"]').show();
  514. $(".message_date_inputTODO[data-id="+(alarmIterator+1)+"]").hide();
  515. $(".message_time_inputTODO[data-id="+(alarmIterator+1)+"]").hide();
  516. }
  517. else
  518. {
  519. alarmDate=$.fullCalendar.parseDate(todo.alertTime[alarmIterator]);
  520. (alarmDate.getHours())<10 ? (hour='0'+(alarmDate.getHours())) : (hour=alarmDate.getHours());
  521. (alarmDate.getMinutes())<10 ? (minute='0'+(alarmDate.getMinutes())) : (minute=alarmDate.getMinutes());
  522. $(".alert_message_detailsTODO[data-id="+(alarmIterator+1)+"]").val('on_date');
  523. var formattedAlarmDate=$.datepicker.formatDate(globalSettings.datepickerformat.value, alarmDate);
  524. $(".message_date_inputTODO[data-id="+(alarmIterator+1)+"]").val(formattedAlarmDate);
  525. $(".message_time_inputTODO[data-id="+(alarmIterator+1)+"]").val($.fullCalendar.formatDate(alarmDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  526. $('.alert_detailsTODO[data-id="'+(alarmIterator+1)+'"]').show();
  527. $('.alert_message_dateTODO[data-id="'+(alarmIterator+1)+'"]').show();
  528. }
  529. }
  530. if(alarmIterator>0)
  531. todo_alert_add(alarmIterator);
  532. if(todo.type!='' && repeatOne!='editOnly' && todo.ruleString.match(vCalendar.re['recurCaldav'])!=null)
  533. {
  534. var ruleString=todo.vcalendar.match(vCalendar.pre['contentline_RRULE2'])[0].match(vCalendar.pre['contentline_parse'])[4];
  535. if(ruleString.indexOf('BYMONTH=')!=-1 || ruleString.indexOf('BYMONTHDAY=')!=-1 || ruleString.indexOf('BYDAY=')!=-1)
  536. {
  537. var pars=ruleString.split(';');
  538. if(pars.indexElementOf('BYMONTH=')!=-1 && pars.indexElementOf('BYMONTHDAY=')==-1 && pars.indexElementOf('BYDAY=')==-1)
  539. pars[pars.length] = "BYMONTHDAY="+todo.start.getDate();
  540. if(todo.type=="DAILY")
  541. {
  542. $("#repeat_TODO option[value='DAILY']").prop('selected', true);
  543. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatDays);
  544. }
  545. else if(todo.type=="WEEKLY")
  546. {
  547. $("#repeat_TODO option[value='CUSTOM_WEEKLY']").prop('selected', true);
  548. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatWeeks);
  549. for(var ri=0;ri<pars.length;ri++)
  550. {
  551. if(pars[ri].indexOf("BYDAY=")!=-1)
  552. {
  553. var byDay=pars[ri].split('=')[1];
  554. byDay=byDay.replace(/\d*MO/,1).replace(/\d*TU/,2).replace(/\d*WE/,3).replace(/\d*TH/,4).replace(/\d*FR/,5).replace(/\d*SA/,6).replace(/\d*SU/,0).split(',');
  555. for(var rj=0;rj<byDay.length;rj++)
  556. {
  557. if(!isNaN(parseInt(byDay[rj],10)))
  558. $('#week_custom_TODO .customTable td[data-type="'+byDay[rj]+'"]').addClass('selected');
  559. }
  560. }
  561. }
  562. $('#week_custom_TODO').show();
  563. }
  564. else if(todo.type=="MONTHLY")
  565. {
  566. $("#repeat_TODO option[value='CUSTOM_MONTHLY']").prop('selected', true).change();
  567. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatMonths);
  568. for(var ri=0;ri<pars.length;ri++)
  569. {
  570. if(pars[ri].indexOf("BYDAY=")!=-1)
  571. {
  572. var byDay=pars[ri].split('=')[1];
  573. byDay=byDay.split(',');
  574. for(var rj=0;rj<byDay.length;rj++)
  575. {
  576. var checkString = byDay[rj].match(vCalendar.pre['+/-number']);
  577. byDay[rj] = byDay[rj].replace(checkString[0],'');
  578. if(!isNaN(parseInt(checkString[0],10)))
  579. {
  580. switch(parseInt(checkString[0],10))
  581. {
  582. case 1:
  583. $('#repeat_month_custom_select_TODO').val('first');
  584. break;
  585. case 2:
  586. $('#repeat_month_custom_select_TODO').val('second');
  587. break;
  588. case 3:
  589. $('#repeat_month_custom_select_TODO').val('third');
  590. break;
  591. case 4:
  592. $('#repeat_month_custom_select_TODO').val('fourth');
  593. break;
  594. case 5:
  595. $('#repeat_month_custom_select_TODO').val('fifth');
  596. break;
  597. case -1:
  598. $('#repeat_month_custom_select_TODO').val('last');
  599. break;
  600. default:
  601. $('#repeat_month_custom_select_TODO').val('every');
  602. break;
  603. }
  604. $('#repeat_month_custom_select2_TODO').val(byDay[rj]);
  605. }
  606. }
  607. }
  608. else if(pars[ri].indexOf("BYMONTHDAY=")!=-1)
  609. {
  610. $('#repeat_month_custom_select_TODO').val('custom').change();
  611. var byMonthDay=pars[ri].split('=')[1];
  612. byMonthDay=byMonthDay.split(',');
  613. for(var rj=0; rj<byMonthDay.length;rj++)
  614. {
  615. if(parseInt(byMonthDay[rj],10)==-1)
  616. {
  617. $('#repeat_month_custom_select_TODO').val('last').change();
  618. $('#repeat_month_custom_select2_TODO').val("DAY");
  619. }
  620. else
  621. $('#month_custom2_TODO .customTable td[data-type="'+(parseInt(byMonthDay[rj],10))+'"]').addClass('selected');
  622. }
  623. }
  624. }
  625. }
  626. else if(todo.type=="YEARLY")
  627. {
  628. $("#repeat_TODO option[value='CUSTOM_YEARLY']").prop('selected', true).change();
  629. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatYears);
  630. var isMonthDay=false;
  631. for(var ri=0;ri<pars.length;ri++)
  632. {
  633. if(pars[ri].indexOf("BYDAY=")!=-1)
  634. {
  635. var byDay=pars[ri].split('=')[1];
  636. byDay=byDay.split(',');
  637. for(var rj=0;rj<byDay.length;rj++)
  638. {
  639. var checkString = byDay[rj].match(vCalendar.pre['+/-number']);
  640. byDay[rj] = byDay[rj].replace(checkString[0],'');
  641. if(!isNaN(parseInt(checkString[0],10)))
  642. {
  643. switch(parseInt(checkString[0],10))
  644. {
  645. case 1:
  646. $('#repeat_year_custom_select1_TODO').val('first');
  647. break;
  648. case 2:
  649. $('#repeat_year_custom_select1_TODO').val('second');
  650. break;
  651. case 3:
  652. $('#repeat_year_custom_select1_TODO').val('third');
  653. break;
  654. case 4:
  655. $('#repeat_year_custom_select1_TODO').val('fourth');
  656. break;
  657. case 5:
  658. $('#repeat_year_custom_select1_TODO').val('fifth');
  659. break;
  660. case -1:
  661. $('#repeat_year_custom_select1_TODO').val('last');
  662. break;
  663. default:
  664. $('#repeat_year_custom_select1_TODO').val('every');
  665. break;
  666. }
  667. $('#repeat_year_custom_select2_TODO').val(byDay[rj]);
  668. }
  669. }
  670. }
  671. else if(pars[ri].indexOf("BYMONTHDAY=")!=-1)
  672. {
  673. $('#repeat_year_custom_select1_TODO').val('custom').change()
  674. var byMonthDay=pars[ri].split('=')[1];
  675. byMonthDay=byMonthDay.split(',');
  676. for(var rj=0; rj<byMonthDay.length;rj++)
  677. {
  678. if(parseInt(byMonthDay[rj],10)==-1)
  679. {
  680. $('#repeat_year_custom_select1_TODO').val('last').change();
  681. $('#repeat_year_custom_select2_TODO').val("DAY");
  682. }
  683. else
  684. $('#year_custom1_TODO .customTable td[data-type="'+(parseInt(byMonthDay[rj],10))+'"]').addClass('selected');
  685. }
  686. isMonthDay=true;
  687. }
  688. else if(pars[ri].indexOf("BYMONTH=")!=-1)
  689. {
  690. var byMonth=pars[ri].split('=')[1];
  691. byMonth=byMonth.split(',');
  692. for(var rj=0; rj<byMonth.length;rj++)
  693. $('#year_custom3_TODO .customTable td[data-type="'+(parseInt(byMonth[rj],10)-1)+'"]').addClass('selected');
  694. }
  695. }
  696. }
  697. if(todo.after=='' && todo.untilDate=='')
  698. $("#repeat_end_details_TODO option[value='never']").prop('selected', true);
  699. else if(todo.after!='')
  700. {
  701. $("#repeat_end_details_TODO option[value='after']").prop('selected', true);
  702. $('#repeat_end_after_TODO').val(todo.after);
  703. }
  704. else if(todo.untilDate!='')
  705. {
  706. date=$.fullCalendar.parseDate(todo.untilDate);
  707. $("#repeat_end_details_TODO option[value='on_date']").prop('selected', true);
  708. var formattedRepeatDate=$.datepicker.formatDate(globalSettings.datepickerformat.value, date);
  709. $('#repeat_end_date_TODO').val(formattedRepeatDate);
  710. }
  711. $('#repeat_interval_detail_TODO').val(todo.interval);
  712. $('#repeat_interval_TODO').show();
  713. if(todo.byDay.length>0)
  714. {
  715. var businessArray=new Array();
  716. if(globalSettings.weekenddays.value.length>0)
  717. for(var i=0;i<7;i++)
  718. if(globalSettings.weekenddays.value.indexOf(i)==-1)
  719. businessArray[businessArray.length]=i+'';
  720. var businessCount=0;
  721. var weekendCount=0;
  722. for(var i=0;i<byDay.length;i++)
  723. {
  724. if(businessArray.indexOf(byDay[i])!=-1)
  725. businessCount++;
  726. if(globalSettings.weekenddays.value.indexOf(parseInt(byDay[i],10))!=-1)
  727. weekendCount++;
  728. }
  729. if(businessArray.length>0 && businessArray.length==businessCount)
  730. {
  731. $("#repeat_TODO option[value='BUSINESS']").prop('selected', true);
  732. $('#repeat_interval_TODO').hide();
  733. $('#week_custom_TODO').hide();
  734. }
  735. else if(globalSettings.weekenddays.value.length>0 && globalSettings.weekenddays.value.length==weekendCount)
  736. {
  737. $("#repeat_TODO option[value='WEEKEND']").prop('selected', true);
  738. $('#repeat_interval_TODO').hide();
  739. $('#week_custom_TODO').hide();
  740. }
  741. }
  742. }
  743. else
  744. {
  745. if(todo.type=="DAILY")
  746. {
  747. $("#repeat_TODO option[value='DAILY']").prop('selected', true);
  748. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatDays);
  749. }
  750. else if(todo.type=="WEEKLY")
  751. {
  752. $("#repeat_TODO option[value='WEEKLY']").prop('selected', true);
  753. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatWeeks);
  754. }
  755. else if(todo.type=="MONTHLY")
  756. {
  757. $("#repeat_TODO option[value='MONTHLY']").prop('selected', true);
  758. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatMonths);
  759. }
  760. else if(todo.type=="YEARLY")
  761. {
  762. $("#repeat_TODO option[value='YEARLY']").prop('selected', true);
  763. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatYears);
  764. }
  765. if(todo.after=='' && todo.untilDate=='')
  766. $("#repeat_end_details_TODO option[value='never']").prop('selected', true);
  767. else if(todo.after!='')
  768. {
  769. $("#repeat_end_details_TODO option[value='after']").prop('selected', true);
  770. $('#repeat_end_after_TODO').val(todo.after);
  771. }
  772. else if(todo.untilDate!='')
  773. {
  774. date=$.fullCalendar.parseDate(todo.untilDate);
  775. $("#repeat_end_details_TODO option[value='on_date']").prop('selected', true);
  776. var formattedRepeatDate=$.datepicker.formatDate(globalSettings.datepickerformat.value, date);
  777. $('#repeat_end_date_TODO').val(formattedRepeatDate);
  778. }
  779. $('#repeat_interval_detail_TODO').val(todo.interval);
  780. $('#repeat_interval_TODO').show();
  781. $('#repeatTodo').val(true);
  782. }
  783. }
  784. else if(todo.type!='' && repeatOne!='editOnly')
  785. {
  786. var cu_opt = new Option(localization[globalInterfaceLanguage].customRepeat, todo.ruleString, false, true);
  787. cu_opt.attr('data-type','custom_repeat');
  788. $('#repeat_TODO').append(cu_opt);
  789. }
  790. else
  791. $('#repeatTodo').val(false);
  792. if(todo.start!=null || todo.end!=null)
  793. {
  794. if(globalSettings.timezonesupport.value)
  795. $('.timezone_rowTODO').show()
  796. }
  797. else
  798. $('.timezone_rowTODO').css('display', 'none');
  799. if(todo.status!='')
  800. $('#statusTODO').find('option[value='+todo.status+']').prop('selected', true);
  801. $('#noteTODO').val(todo.note).trigger('autosize.resize');
  802. if(todo.classType!='')
  803. $('#typeTODO').val(todo.classType.toLowerCase());
  804. else
  805. $('#typeTODO').val('public');
  806. if(todo!=null && mod!='new')
  807. {
  808. var uidArray = todo.id.match(vCalendar.pre['uidParts']);
  809. if(decodeURIComponent(uidArray[4]).indexOf(uidArray[2])==-1)
  810. $('.row_typeTODO').css('display','none');
  811. }
  812. $('#uidTODO').val(todo.id);
  813. $('#url_TODO').val(todo.url);
  814. $('#location_TODO').val(todo.location);
  815. $('#etagTODO').val(todo.etag);
  816. $('#vcalendarHashTODO').val(hex_sha256(todo.vcalendar));
  817. var stringUIDcurrent=todo.vcalendar.match(vCalendar.pre['contentline_UID']);
  818. if(stringUIDcurrent!=null)
  819. stringUIDcurrent=stringUIDcurrent[0].match(vCalendar.pre['contentline_parse'])[4];
  820. if(stringUIDcurrent)
  821. $('#vcalendarUIDTODO').val(stringUIDcurrent);
  822. }
  823. if($('#todo_type').val()=='start')
  824. {
  825. $('.dateTrFromTODO').show();
  826. $('.dateTrToTODO').hide();
  827. }
  828. else if($('#todo_type').val()=='due')
  829. {
  830. $('.dateTrToTODO').show();
  831. $('.dateTrFromTODO').hide();
  832. }
  833. else if($('#todo_type').val()=='both')
  834. {
  835. $('.dateTrToTODO').show();
  836. $('.dateTrFromTODO').show();
  837. }
  838. else
  839. {
  840. $('.dateTrToTODO').hide();
  841. $('.dateTrFromTODO').hide();
  842. $('#repeat_row_TODO').hide();
  843. }
  844. if($('#repeat_TODO option:selected').attr('data-type')!="repeat_no-repeat" && $('#repeat_TODO option:selected').attr('data-type')!="custom_repeat")
  845. $('#repeat_details_TODO').show();
  846. if($('#repeat_end_details_TODO option:selected').attr('data-type')=="repeat_details_on_date")
  847. {
  848. $('#repeat_end_after_TODO').hide();
  849. $('#repeat_end_date_TODO').show();
  850. }
  851. if($('#repeat_end_details_TODO option:selected').attr('data-type')=="repeat_details_after")
  852. {
  853. $('#repeat_end_after_TODO').show();
  854. $('#repeat_end_date_TODO').hide();
  855. }
  856. if($('#repeat_end_details_TODO option:selected').attr('data-type')=="repeat_details_never")
  857. {
  858. $('#repeat_end_after_TODO').hide();
  859. $('#repeat_end_date_TODO').hide();
  860. }
  861. if(mod=='show')
  862. {
  863. if($('#ResourceCalDAVTODOList').find('[data-id="'+todo.res_id+'"]').hasClass("resourceCalDAV_item_ro"))
  864. {
  865. $('#editTODO').hide();
  866. $('#duplicateTODO').hide();
  867. $('#editOptionsButtonTODO').hide();
  868. }
  869. $('#saveTODO').hide();
  870. $('#resetTODO').hide();
  871. $('#deleteTODO').hide();
  872. $('#todoDetailsTable :input[type!="button"]').prop('disabled', true);
  873. $('#todoDetailsTable :input[type="text"]').prop('readonly', true);
  874. $('#todoDetailsTable textarea').prop('readonly', true);
  875. $('#percentageSlider').slider({disabled: true});
  876. /*************************** BAD HACKS SECTION ***************************/
  877. // here we fix the cross OS/cross broser problems (unfixable in pure CSS)
  878. if($.browser.webkit && !!window.chrome) /* Chrome */
  879. {
  880. if(navigator.platform.toLowerCase().indexOf('win')==0) /* Windows version */
  881. {
  882. $('#todo_details_template').find('input').css('text-indent', '2px');
  883. $('#todo_details_template').find('select').css({'padding-left': '0px', 'padding-right': '13px'});
  884. }
  885. else /* non-Windows version */
  886. $('#todo_details_template').find('input').css('text-indent', '1px');
  887. }
  888. else if($.browser.safari)
  889. {
  890. $('#todo_details_template').find('textarea').addClass('safari_hack');
  891. $('#todo_details_template').find('input').addClass('safari_hack');
  892. }
  893. else if($.browser.msie) /* IE */
  894. {
  895. if(parseInt($.browser.version, 10)==10) /* IE 10 (because there are no more conditional comments) */
  896. {
  897. $('#todo_details_template').find('select').css({'padding-top': '1px', 'padding-left': '0px', 'padding-right': '0px'});
  898. $('#todo_details_template').find('textarea').css('padding-top', '3px');
  899. $('#todo_details_template').find('input[type=button]').css('padding-top', '2px');
  900. }
  901. }
  902. if($.browser.msie || $.browser.mozilla)
  903. {
  904. var newSVG=$(SVG_select_dis).attr('data-type', 'select_icon').css({'pointer-events': 'none', 'z-index': '1', 'display': 'inline', 'margin-left': '-22px', 'vertical-align': 'top', 'background-color': '#ffffff'}); // background-color = stupid IE9 bug
  905. $('#todo_details_template').find('svg[data-type="select_icon"]').replaceWith($('<div>').append($(newSVG).clone()).html());
  906. }
  907. /*************************** END OF BAD HACKS SECTION ***************************/
  908. }
  909. if(repeatOne=='editOnly' || $('#recurrenceIDTODO').val()!='')
  910. {
  911. $('#repeat_TODO').parent().parent().css('display', 'none');
  912. $('#week_custom_TODO').css('display', 'none');
  913. $('#month_custom1_TODO').css('display', 'none');
  914. $('#month_custom2_TODO').css('display', 'none');
  915. $('#year_custom1_TODO').css('display', 'none');
  916. $('#year_custom2_TODO').css('display', 'none');
  917. $('#year_custom3_TODO').css('display', 'none');
  918. $('#repeat_details_TODO').css('display', 'none');
  919. }
  920. if(todo==null || todo.type=='' || (globalSettings.appleremindersmode.value && (todo.status=='COMPLETED' || todo.status== 'CANCELLED')) ||
  921. (globalSettings.appleremindersmode.value && typeof globalAppleSupport.nextDates[todo.id] == 'undefined'))
  922. $('#editOptionsButtonTODO').hide();
  923. else
  924. $('#editOptionsButtonTODO').click(function(){
  925. showTodoForm(globalCalTodo, 'show', '', true);
  926. });
  927. if(repeatOne=='editOnly' || repeatOne=='futureOnly' || $('#recurrenceIDTODO').val())
  928. $('#calendarLineTODO').hide();
  929. if(todo && todo.after && repeatOne=='futureOnly')
  930. $('#repeat_end_after_TODO').val(todo.after - todo.realRepeatCount + 1);
  931. $('#percenteCompleteValue').val(sliderValue);
  932. $('#percentageSlider').slider({
  933. animate: true,
  934. range: "min",
  935. value: sliderValue,
  936. min: 0,
  937. max: 100,
  938. step: 1,
  939. //this gets a live reading of the value and prints it on the page
  940. slide: function(event, ui)
  941. {
  942. $("#percenteCompleteValue").val(ui.value);
  943. $(this).parent().parent().find('img').css('display', 'none');
  944. },
  945. //this updates the hidden form field so we can submit the data using a form
  946. change: function(event, ui) {
  947. var status;
  948. if (ui.value>99 && $('#statusTODO').val()==='CANCELLED')
  949. status='CANCELLED';
  950. else if(ui.value>99)
  951. status='COMPLETED';
  952. else if(ui.value>0 && !globalSettings.appleremindersmode.value)
  953. status='IN-PROCESS';
  954. else
  955. status='NEEDS-ACTION';
  956. $('#statusTODO').val(status);
  957. todoStatusChanged(status);
  958. }
  959. });
  960. if(!globalSettings.timezonesupport.value)
  961. $('.timezone_rowTODO').css('display', 'none');
  962. //updateTodoFormDimensions();
  963. //if(window.event!=undefined)
  964. // setTodoPosition(window.event);
  965. //else
  966. // setTodoPosition(event);
  967. if($('#todo_type').val()=='none')
  968. stripTodoAlerts();
  969. if(mod!='new')
  970. $('#closeTODO').hide();
  971. globalObjectLoading=false;
  972. $('#CATodo').show(200, function(){
  973. $('#todoColor').css('background-color',color);
  974. checkTodoFormScrollBar();
  975. $('#todoForm').scrollTop(0);
  976. });
  977. }
  978. function bindTodoForm()
  979. {
  980. initCalDavDatepicker($('#todo_details_template'));
  981. initCalDavTimepicker($('#todo_details_template'));
  982. $('#todo_details_template .alert_message_detailsTODO').change(function(){
  983. var data_id=$(this).attr("data-id");
  984. $('.before_after_inputTODO[data-id="'+data_id+'"]').parent().parent().find('img').css('display','none');
  985. if($('.alert_message_detailsTODO[data-id="'+data_id+'"] option:selected').attr('data-type')=="on_dateTODO")
  986. {
  987. var myDate=new Date();
  988. myDate.setDate(myDate.getDate()+7);
  989. if($('.dateTrToTODO').is(':visible') && $('.dateTrToTODO img:visible').length==0) {
  990. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_toTODO").val());
  991. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  992. myDate=new Date(Date.parse(datetime_to +$("#time_toTODO").val()));
  993. myDate.setHours(myDate.getHours()-1);
  994. }
  995. else if($('.dateTrFromTODO').is(':visible') && $('.dateTrFromTODO img:visible').length==0) {
  996. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_fromTODO").val());
  997. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  998. myDate=new Date(Date.parse(datetime_to +$("#time_fromTODO").val()));
  999. myDate.setHours(myDate.getHours()-1);
  1000. }
  1001. $('.message_date_inputTODO[data-id="'+data_id+'"]').val($.datepicker.formatDate(globalSettings.datepickerformat.value, myDate));
  1002. $('.message_date_inputTODO[data-id="'+data_id+'"]').show();
  1003. $('.message_time_inputTODO[data-id="'+data_id+'"]').val($.fullCalendar.formatDate(myDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  1004. $('.message_time_inputTODO[data-id="'+data_id+'"]').show();
  1005. $('.before_after_inputTODO[data-id="'+data_id+'"]').hide();
  1006. }
  1007. else
  1008. {
  1009. $('.message_date_inputTODO[data-id="'+data_id+'"]').hide();
  1010. $('.message_time_inputTODO[data-id="'+data_id+'"]').hide();
  1011. $('.before_after_inputTODO[data-id="'+data_id+'"]').show();
  1012. $('.before_after_inputTODO[data-id="'+data_id+'"]').val('15');
  1013. }
  1014. });
  1015. $('#todo_details_template .before_after_inputTODO').bind('keyup change', function(){
  1016. if($(this).val()=='')
  1017. {
  1018. $(this).parent().find('img').css('display', 'inline');
  1019. //$(this).parent().find('img').css('visibility','visible');
  1020. }
  1021. else
  1022. {
  1023. if($(this).val().match("^[0-9]+$")==null)
  1024. {
  1025. $(this).parent().find('img').css('display', 'inline');
  1026. //$(this).parent().find('img').css('visibility','visible');
  1027. }
  1028. else
  1029. $(this).parent().find('img').css('display', 'none');
  1030. }
  1031. });
  1032. $('#todo_details_template .alertTODO').change(function(){
  1033. var data_id=$(this).attr("data-id");
  1034. if($(this).val()!='none')
  1035. {
  1036. $('.alert_detailsTODO[data-id="'+data_id+'"]').show();
  1037. $('.alert_message_dateTODO[data-id="'+data_id+'"]').show();
  1038. if($('#todo_type').val()!='none')
  1039. expandTodoAlerts();
  1040. var myDate=new Date();
  1041. myDate.setDate(myDate.getDate()+7);
  1042. if($('.dateTrToTODO').is(':visible') && $('.dateTrToTODO img:visible').length==0) {
  1043. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_toTODO").val());
  1044. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  1045. myDate=new Date(Date.parse(datetime_to +$("#time_toTODO").val()));
  1046. myDate.setHours(myDate.getHours()-1);
  1047. }
  1048. else if($('.dateTrFromTODO').is(':visible') && $('.dateTrFromTODO img:visible').length==0) {
  1049. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_fromTODO").val());
  1050. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  1051. myDate=new Date(Date.parse(datetime_to +$("#time_fromTODO").val()));
  1052. myDate.setHours(myDate.getHours()-1);
  1053. }
  1054. $('.message_date_inputTODO[data-id="'+data_id+'"]').val($.datepicker.formatDate(globalSettings.datepickerformat.value, myDate));
  1055. $('.message_time_inputTODO[data-id="'+data_id+'"]').val($.fullCalendar.formatDate(myDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  1056. todo_alert_add(data_id);
  1057. }
  1058. else
  1059. {
  1060. $('.alert_detailsTODO[data-id="'+data_id+'"]').hide();
  1061. $('.alert_message_dateTODO[data-id="'+data_id+'"]').hide();
  1062. checkForTodo(data_id);
  1063. var data_id=$(this).attr("data-id");
  1064. $('#todo_details_template tr[data-id="'+data_id+'"]').remove();
  1065. }
  1066. checkTodoFormScrollBar();
  1067. });
  1068. $('#repeat_end_after_TODO, #repeat_interval_detail_TODO').bind('keyup change',function(){
  1069. if($(this).val()=='')
  1070. {
  1071. $(this).parent().find('img').css('display', 'inline');
  1072. //$(this).parent().find('img').css('visibility','visible');
  1073. }
  1074. else
  1075. {
  1076. if($(this).val().match("^[0-9]+$")==null || parseInt($(this).val(),10)<1)
  1077. {
  1078. $(this).parent().find('img').css('display', 'inline');
  1079. //$(this).parent().find('img').css('visibility','visible');
  1080. }
  1081. else
  1082. $(this).parent().find('img').css('display', 'none');
  1083. }
  1084. });
  1085. $('#repeat_month_custom_select_TODO').change(function(){
  1086. if($(this).val()=="custom")
  1087. {
  1088. $('#month_custom2_TODO').show();
  1089. $('#repeat_month_custom_select2_TODO').parent().hide();
  1090. }
  1091. else
  1092. {
  1093. $('#month_custom2_TODO').hide();
  1094. $('#repeat_month_custom_select2_TODO').parent().show();
  1095. }
  1096. checkTodoFormScrollBar();
  1097. });
  1098. $('#repeat_year_custom_select1_TODO').change(function(){
  1099. if($(this).val()=="custom")
  1100. {
  1101. $('#year_custom1_TODO').show();
  1102. $('#repeat_year_custom_select2_TODO').parent().hide();
  1103. }
  1104. else
  1105. {
  1106. $('#year_custom1_TODO').hide();
  1107. $('#repeat_year_custom_select2_TODO').parent().show();
  1108. }
  1109. checkTodoFormScrollBar();
  1110. });
  1111. $('#repeat_end_details_TODO').change(function(){
  1112. $('#repeat_end_date_TODO').parent().find('img').css('display', 'none');
  1113. if($('#repeat_end_details_TODO option:selected').attr('data-type')=="repeat_details_on_date")
  1114. {
  1115. $('#repeat_end_after_TODO').hide();
  1116. $('#repeat_end_date_TODO').show();
  1117. var today;
  1118. if($('#date_fromTODO').val()!='')
  1119. {
  1120. today=$.datepicker.parseDate(globalSettings.datepickerformat.value, $('#date_fromTODO').val());
  1121. if(today==null)
  1122. today=new Date();
  1123. }
  1124. else
  1125. today=new Date();
  1126. var date=new Date(today.getFullYear(), today.getMonth(), today.getDate()+2);
  1127. $('#repeat_end_date_TODO').val($.datepicker.formatDate(globalSettings.datepickerformat.value, date));
  1128. }
  1129. if($('#repeat_end_details_TODO option:selected').attr('data-type')=="repeat_details_after")
  1130. {
  1131. $('#repeat_end_after_TODO').show();
  1132. $('#repeat_end_after_TODO').val('2');
  1133. $('#repeat_end_date_TODO').hide();
  1134. }
  1135. if($('#repeat_end_details_TODO option:selected').attr('data-type')=="repeat_details_never")
  1136. {
  1137. $('#repeat_end_after_TODO').hide();
  1138. $('#repeat_end_date_TODO').hide();
  1139. }
  1140. checkTodoFormScrollBar();
  1141. });
  1142. $('#todo_details_template .customTable td').click(function(){
  1143. if($(this).hasClass('disabled'))
  1144. return true;
  1145. else if($(this).hasClass('selected'))
  1146. $(this).removeClass('selected');
  1147. else
  1148. $(this).addClass('selected');
  1149. });
  1150. $('#closeTODO').click(function()
  1151. {
  1152. $('#todoInEdit').val('false');
  1153. if($('#uidTODO').val()!='')
  1154. {
  1155. var uid=$('#uidTODO').val();
  1156. var calUID=uid.substring(0, uid.lastIndexOf('/')+1);
  1157. var color=$('#ResourceCalDAVTODOList').find("[data-id='"+calUID+"']").find('.resourceCalDAVColor').css('background-color');
  1158. $('.event_item[data-id="'+uid+'"]').children('.fc-event-handle').css({'background-color': rgbToRgba(color,0.9), 'border-color': color});
  1159. }
  1160. $('#TodoDisabler').fadeOut(globalEditorFadeAnimation, function(){
  1161. $('#timezonePickerTODO').prop('disabled', false);
  1162. });
  1163. if(typeof globalCalTodo!= 'undefined' && globalCalTodo!=null && globalVisibleCalDAVTODOCollections.indexOf(globalCalTodo.res_id)!=-1)
  1164. {
  1165. $('#todoList').fullCalendar('selectEvent');
  1166. }
  1167. else
  1168. $('#CATodo').attr('style','display:none');
  1169. });
  1170. $('#resetTODO').click(function(){
  1171. $('#todo_details_template').find('img[data-type=invalidSlider],img[data-type=invalidSmall]').css('display','none');
  1172. if($('#uidTODO').val()!='')
  1173. {
  1174. var uid=$('#uidTODO').val();
  1175. var calUID=uid.substring(0, uid.lastIndexOf('/')+1);
  1176. var color=$('#ResourceCalDAVTODOList').find("[data-id='"+calUID+"']").find('.resourceCalDAVColor').css('background-color');
  1177. $('.event_item[data-id="'+uid+'"]').children('.fc-event-handle').css({'background-color': rgbToRgba(color,0.9), 'border-color': color});
  1178. if($('#recurrenceIDTODO').val()!='')
  1179. showTodoForm(globalCalTodo, 'show','editOnly');
  1180. else
  1181. showTodoForm(globalCalTodo, 'show');
  1182. startEditModeTodo();
  1183. }
  1184. });
  1185. $('#todo_calendar').change(function(){
  1186. var color = '';
  1187. if($(this).val()=='choose')
  1188. color = 'rgb(240,240,240)';
  1189. else
  1190. color=$('#ResourceCalDAVTODOList').find("[data-id='"+$(this).val()+"']").find('.resourceCalDAVColor').css('background-color');
  1191. var uid='fooUID';
  1192. if($('#uidTODO').val()!='')
  1193. uid=$('#uidTODO').val();
  1194. $('#todoColor').css('background-color',color);
  1195. $('.event_item[data-id="'+uid+'"]').find('.fc-event-handle').css({'background-color': rgbToRgba(color,0.9), 'border-color': color});
  1196. });
  1197. $('#repeat_TODO').change(function(){
  1198. if($('#repeat_TODO option:selected').attr('data-type')=='repeat_no-repeat' || $('#repeat_TODO option:selected').attr('data-type')=="custom_repeat")
  1199. {
  1200. $('#repeat_details_TODO').hide();
  1201. $('#repeat_interval_TODO').hide();
  1202. $('#week_custom_TODO').hide();
  1203. $('#month_custom1_TODO').hide();
  1204. $('#month_custom2_TODO').hide();
  1205. $('#year_custom1_TODO').hide();
  1206. $('#year_custom2_TODO').hide();
  1207. $('#year_custom3_TODO').hide();
  1208. }
  1209. else
  1210. {
  1211. $('#repeat_details_TODO').show();
  1212. if($(this).val()!='BUSINESS' && $(this).val()!='TWO_WEEKLY' && $(this).val()!='WEEKEND')
  1213. {
  1214. $('#repeat_interval_TODO').show();
  1215. $("#repeat_interval_detail_TODO").val('1');
  1216. $('#repeat_interval_TODO').find('img').css('display','none');
  1217. }
  1218. else
  1219. $('#repeat_interval_TODO').hide();
  1220. if($(this).val()=='DAILY')
  1221. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatDays);
  1222. if($(this).val()=='WEEKLY')
  1223. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatWeeks);
  1224. if($(this).val()=='MONTHLY')
  1225. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatMonths);
  1226. if($(this).val()=='YEARLY')
  1227. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatYears);
  1228. if($(this).val()=='CUSTOM_WEEKLY')
  1229. {
  1230. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatWeeks);
  1231. $('#week_custom_TODO').show();
  1232. }
  1233. else
  1234. $('#week_custom_TODO').hide();
  1235. if($(this).val()=='CUSTOM_MONTHLY')
  1236. {
  1237. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatMonths);
  1238. $('#month_custom1_TODO').show();
  1239. if($('#repeat_month_custom_select_TODO').val() == "custom")
  1240. $('#repeat_month_custom_select_TODO').trigger('change');
  1241. }
  1242. else
  1243. {
  1244. $('#month_custom1_TODO').hide();
  1245. $('#month_custom2_TODO').hide();
  1246. }
  1247. if($(this).val()=='CUSTOM_YEARLY')
  1248. {
  1249. $('#repeat_interval_TODO [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatYears);
  1250. $('#year_custom2_TODO').show();
  1251. $('#year_custom3_TODO').show();
  1252. if($('#repeat_year_custom_select1_TODO').val() == "custom")
  1253. $('#repeat_year_custom_select1_TODO').trigger('change');
  1254. }
  1255. else
  1256. {
  1257. $('#year_custom1_TODO').hide();
  1258. $('#year_custom2_TODO').hide();
  1259. $('#year_custom3_TODO').hide();
  1260. }
  1261. var today;
  1262. if($('#date_fromTODO').val()!='')
  1263. {
  1264. today=$.datepicker.parseDate(globalSettings.datepickerformat.value, $('#date_fromTODO').val());
  1265. if(today==null)
  1266. today=new Date();
  1267. }
  1268. else
  1269. today=new Date();
  1270. var date=new Date(today.getFullYear(),today.getMonth(),today.getDate()+2);
  1271. $('#repeat_end_date_TODO').val($.datepicker.formatDate(globalSettings.datepickerformat.value, date));
  1272. }
  1273. checkTodoFormScrollBar();
  1274. });
  1275. $('#statusTODO').change(function(){
  1276. var status = $(this).val();
  1277. switch(status) {
  1278. case 'NEEDS-ACTION':
  1279. $('#percenteCompleteValue').val(0);
  1280. $('#percentageSlider').slider({value: 0});
  1281. $('#nameTODO').removeClass('title_cancelled');
  1282. break;
  1283. case 'IN-PROCESS':
  1284. var value = 50;
  1285. var id = $('.fc-event-selected').attr('data-repeat-hash');
  1286. if(typeof globalTodolistStatusArray[id]!='undefined' && typeof globalTodolistStatusArray[id].percent!='undefined')
  1287. value=globalTodolistStatusArray[id].percent;
  1288. $('#percenteCompleteValue').val(value);
  1289. $('#percentageSlider').slider({value: value});
  1290. $('#nameTODO').removeClass('title_cancelled');
  1291. break;
  1292. case 'CANCELLED':
  1293. $('#percenteCompleteValue').val(100);
  1294. $('#percentageSlider').slider({value: 100});
  1295. $('#nameTODO').addClass('title_cancelled');
  1296. break;
  1297. case 'COMPLETED':
  1298. $('#percenteCompleteValue').val(100);
  1299. $('#percentageSlider').slider({value: 100});
  1300. $('#nameTODO').removeClass('title_cancelled');
  1301. break;
  1302. default:
  1303. break;
  1304. }
  1305. todoStatusChanged(status);
  1306. });
  1307. $('#todo_type').change(function(){
  1308. if($(this).val()=='none')
  1309. {
  1310. $('#timezoneTODO').val('local');
  1311. $('#repeat_row_TODO').hide();
  1312. $('#date_fromTODO, #time_fromTODO, #date_toTODO, #time_toTODO').parent().find('img').css('display','none');
  1313. $('.dateTrFromTODO, .dateTrToTODO, .timezone_rowTODO').hide();
  1314. stripTodoAlerts();
  1315. }
  1316. else if($(this).val()=='start')
  1317. {
  1318. var myDate=new Date();
  1319. $('#date_fromTODO').val($.datepicker.formatDate(globalSettings.datepickerformat.value, myDate));
  1320. $('#time_fromTODO').val($.fullCalendar.formatDate(myDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  1321. $('#repeat_row_TODO').show();
  1322. $('#date_toTODO, #time_toTODO').parent().find('img').css('display','none');
  1323. $('.dateTrToTODO').hide();
  1324. $('.dateTrFromTODO').show();
  1325. if(globalSettings.timezonesupport.value)
  1326. {
  1327. $('.timezone_rowTODO').show();
  1328. $('#timezoneTODO').val(globalSessionTimeZone);
  1329. }
  1330. $('#date_fromTODO, #time_fromTODO').trigger('change');
  1331. }
  1332. else if($(this).val()=='due')
  1333. {
  1334. var myDate=new Date($('#todoList').fullCalendar('getView').start.getTime());
  1335. myDate.setHours(globalSettings.calendarendofbusiness.value);
  1336. myDate.setMinutes((globalSettings.calendarendofbusiness.value%1)*60);
  1337. $('#date_toTODO').val($.datepicker.formatDate(globalSettings.datepickerformat.value, myDate));
  1338. $('#time_toTODO').val($.fullCalendar.formatDate(myDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  1339. $('#repeat_row_TODO').show();
  1340. $('#date_fromTODO, #time_fromTODO').parent().find('img').css('display','none');
  1341. $('.dateTrFromTODO').hide();
  1342. $('.dateTrToTODO').show();
  1343. if(globalSettings.timezonesupport.value)
  1344. {
  1345. $('.timezone_rowTODO').show();
  1346. $('#timezoneTODO').val(globalSessionTimeZone);
  1347. }
  1348. $('#date_toTODO, #time_toTODO').trigger('change');
  1349. }
  1350. else if($(this).val()=='both')
  1351. {
  1352. var myDate='';
  1353. var myDateStart= new Date();
  1354. if($('#date_toTODO').val()!='')
  1355. {
  1356. var dateFrom=$.datepicker.parseDate(globalSettings.datepickerformat.value, $('#date_toTODO').val());
  1357. var datetime_to=$.fullCalendar.formatDate(dateFrom, 'yyyy-MM-dd');
  1358. var aDate=new Date(Date.parse("01/02/1990, "+$('#time_toTODO').val()));
  1359. var time_from=$.fullCalendar.formatDate(aDate, 'HH:mm:ss');
  1360. var myDate=$.fullCalendar.parseDate(datetime_to+'T'+time_from);
  1361. }
  1362. else
  1363. {
  1364. myDate=new Date($('#todoList').fullCalendar('getView').start.getTime());
  1365. $('#repeat_row_TODO').show();
  1366. myDate.setHours(globalSettings.calendarendofbusiness.value);
  1367. myDate.setMinutes((globalSettings.calendarendofbusiness.value%1)*60);
  1368. if($('#date_toTODO').val()=='')
  1369. $('#date_toTODO').val($.datepicker.formatDate(globalSettings.datepickerformat.value, myDate));
  1370. if($('#time_toTODO').val()=='')
  1371. $('#time_toTODO').val($.fullCalendar.formatDate(myDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  1372. }
  1373. if(myDateStart>myDate)
  1374. myDateStart= new Date(myDate.getTime());
  1375. globalPrevDate = new Date(myDateStart.getTime());
  1376. if($('#date_fromTODO').val()=='')
  1377. $('#date_fromTODO').val($.datepicker.formatDate(globalSettings.datepickerformat.value, myDateStart));
  1378. if($('#time_fromTODO').val()=='')
  1379. $('#time_fromTODO').val($.fullCalendar.formatDate(myDateStart, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  1380. $('.dateTrFromTODO, .dateTrToTODO').show();
  1381. if(globalSettings.timezonesupport.value)
  1382. {
  1383. $('.timezone_rowTODO').show();
  1384. $('#timezoneTODO').val(globalSessionTimeZone);
  1385. }
  1386. $('#date_fromTODO, #time_fromTODO, #date_toTODO, #time_toTODO').trigger('change');
  1387. }
  1388. if($('#todo_type').val()!='none')
  1389. expandTodoAlerts();
  1390. checkTodoFormScrollBar();
  1391. });
  1392. $('#percenteCompleteValue').bind('keyup change',function(){
  1393. if($(this).val()=='')
  1394. {
  1395. $(this).parent().find('img').css('display', 'inline');
  1396. }
  1397. else
  1398. {
  1399. if($(this).val().match('^(([0-9])|([1-9][0-9])|(100))$')==null)
  1400. $(this).parent().find('img').css('display', 'inline');
  1401. else
  1402. {
  1403. $(this).parent().find('img').css('display', 'none');
  1404. $( "#percentageSlider" ).slider({value: $(this).val()});
  1405. }
  1406. }
  1407. });
  1408. }
  1409. function showEventForm(date, allDay, calEvent, jsEvent, mod, repeatOne, confirmRepeat)
  1410. {
  1411. $('#event_details_template').remove();
  1412. $('#CAEvent').html(cleanVcalendarTemplate);
  1413. setFirstDayEvent();
  1414. bindEventForm();
  1415. $('#note').autosize({defaultStyles: {height: '64', overflow: '', 'overflow-y': '', 'word-wrap': '', resize: 'none'}, callback: function(){checkEventFormScrollBar();}});
  1416. $("#show").val('');
  1417. $("#uid").val('');
  1418. $("#etag").val('');
  1419. $("#repeatCount").val('');
  1420. $("#repeatEvent").val('');
  1421. $("#recurrenceID").val('');
  1422. $("#futureStart").val('');
  1423. $("#vcalendarHash").val('');
  1424. $("#vcalendarUID").val('');
  1425. globalPrevDate='';
  1426. var color='';
  1427. if(mod=='new')
  1428. {
  1429. var activeCollection = $('#ResourceCalDAVList').find('.resourceCalDAV_item.resourceCalDAV_item_selected');
  1430. if(activeCollection.length>0 && !globalResourceCalDAVList.getEventCollectionByUID(activeCollection.attr('data-id')).permissions.read_only)
  1431. color=rgbToHex(activeCollection.children('.resourceCalDAVColor').css('background-color'));
  1432. }
  1433. else
  1434. color=globalResourceCalDAVList.getEventCollectionByUID(calEvent.res_id).ecolor;
  1435. if(confirmRepeat)
  1436. {
  1437. $('#show').val(calEvent.id);
  1438. $('#repeatEvent').val(true);
  1439. $('#CAEvent').show();
  1440. $('#repeatConfirmBox').css('visibility', 'visible');
  1441. if(calEvent.repeatCount!='' && calEvent.repeatCount == 1)
  1442. {
  1443. $('#editFuture').css('display','none');
  1444. if($('#editFuture').next('br').length>0)
  1445. $('#editFuture').next().remove();
  1446. }
  1447. else if($('#editFuture').css('display')=='none')
  1448. {
  1449. $('#editFuture').css('display','block');
  1450. if($('#editFuture').next('br').length==0)
  1451. $('#editFuture').after('<br/>')
  1452. }
  1453. $('#repeatConfirmBoxContent').html('<b>'+calEvent.title+"</b> "+localization[globalInterfaceLanguage].repeatBoxContent);
  1454. $('#repeatConfirmBoxQuestion').html(localization[globalInterfaceLanguage].repeatBoxQuestion);
  1455. $('#editAll, #editOnlyOne, #editFuture').click(function(){
  1456. if(globalCalEvent)
  1457. {
  1458. if($(this).attr('id')=='editOnlyOne')
  1459. showEventForm(null, globalCalEvent.allDay, globalCalEvent, globalJsEvent, 'show', 'editOnly');
  1460. else if($(this).attr('id')=='editAll')
  1461. showEventForm(null, globalCalEvent.allDay, globalCalEvent, globalJsEvent, 'show', '');
  1462. else if($(this).attr('id')=='editFuture')
  1463. showEventForm(null, globalCalEvent.allDay, globalCalEvent, globalJsEvent, 'show', 'futureOnly');
  1464. $('#repeatConfirmBoxContent').html('');
  1465. $('#repeatConfirmBox').css('visibility', 'hidden');
  1466. $('#AlertDisabler').fadeOut(globalEditorFadeAnimation);
  1467. }
  1468. });
  1469. $('#CAEvent').height($('#repeatConfirmBox').height());
  1470. $('#eventColor').css('background-color',color);
  1471. updateEventFormDimensions();
  1472. setFormPosition(jsEvent, true);
  1473. $('#event_details_template').scrollTop(0);
  1474. return true;
  1475. }
  1476. if(mod=='show' && repeatOne=='futureOnly')
  1477. {
  1478. $('#futureStart').val(calEvent.realRepeatCount+';'+calEvent.start);
  1479. }
  1480. if(mod!='new')
  1481. fullVcalendarToData(calEvent);
  1482. else
  1483. CalDAVeditor_cleanup();
  1484. if(calEvent!=null && ((repeatOne=='editOnly'&&calEvent.type) || calEvent.rec_id))
  1485. {
  1486. var eventsSorted=jQuery.grep(globalEventList.displayEventsArray[calEvent.res_id],function(e){if(e.id==calEvent.id)return true}).sort(repeatStartCompare);
  1487. if(eventsSorted.indexOf(calEvent)!=-1)
  1488. {
  1489. if(eventsSorted.indexOf(calEvent)<(eventsSorted.length-1))
  1490. showEventNextNav();
  1491. if(eventsSorted.indexOf(calEvent)!=0)
  1492. showEventPrevNav();
  1493. }
  1494. }
  1495. var cals=globalResourceCalDAVList.sortedCollections;
  1496. var calendarObj = $('#event_calendar');
  1497. var calSelected = $('.resourceCalDAV_item.resourceCalDAV_item_selected').attr('data-id');
  1498. for(var i=0;i<cals.length;i++)
  1499. {
  1500. if(cals[i].uid!=undefined && ((calEvent!=null && calEvent.res_id==cals[i].uid) || (cals[i].makeLoaded && !cals[i].permissions_read_only )))
  1501. {
  1502. calendarObj.append(new Option(cals[i].displayValue,cals[i].uid));
  1503. }
  1504. }
  1505. if(mod=='new')
  1506. {
  1507. $('#show').val('');
  1508. $('#editButton').hide();
  1509. $('#duplicateButton').hide();
  1510. $('#editOptionsButton').hide();
  1511. $('#resetButton').hide();
  1512. $('#deleteButton').hide();
  1513. if($('#ResourceCalDAVList').find('.resourceCalDAV_item.resourceCalDAV_item_selected').length>0 && $('#event_calendar').find('option[value="'+$('#ResourceCalDAVList').find('.resourceCalDAV_item.resourceCalDAV_item_selected').attr("data-id")+'"]').length>0)
  1514. $('.R_calendar').val($('#ResourceCalDAVList').find('.resourceCalDAV_item.resourceCalDAV_item_selected').attr("data-id"));
  1515. else
  1516. $('#event_calendar').val('choose');
  1517. }
  1518. if(mod=='drop')
  1519. {
  1520. if(calEvent.etag!='')
  1521. $('#event_calendar').val(calEvent.res_id);
  1522. }
  1523. if(mod=='new')
  1524. {
  1525. //$('[data-type="name"]').attr('placeholder', localization[globalInterfaceLanguage].pholderNewEvent);
  1526. var date_to = null;
  1527. if(calEvent!==null)
  1528. {
  1529. if(calEvent.realStart)
  1530. date=calEvent.realStart;
  1531. else
  1532. date=calEvent.start;
  1533. if(calEvent.realEnd)
  1534. date_to=new Date(calEvent.realEnd.getTime());
  1535. else
  1536. date_to=new Date(calEvent.end.getTime());
  1537. }
  1538. if(!allDay && ((date_to==null) || ((date_to-date)==0))) {
  1539. date_to = new Date(date.getTime());
  1540. if(globalSettings.defaulteventduration.value!==null)
  1541. date_to.setMinutes(date_to.getMinutes()+globalSettings.defaulteventduration.value);
  1542. else {
  1543. date_to.setHours(globalSettings.calendarendofbusiness.value);
  1544. date_to.setMinutes((globalSettings.calendarendofbusiness.value%1)*60);
  1545. }
  1546. if(date_to.getTime()<date.getTime())
  1547. date_to.setDate(date_to.getDate()+1);
  1548. }
  1549. var beforeScroll = $('#main').width()-$('#calendar').width();
  1550. $('#calendar').fullCalendar('renderEvent', $.extend(new items('',date,date_to,localization[globalInterfaceLanguage].pholderNewEvent, allDay, 'fooUID', '', '', '', '', '', '', '', '', '', '', '', '', '','', '', '', '', '', '', '', '', '','', '', '', '', '', '', '', ''),{backgroundColor:hexToRgba(color,0.9),borderColor:color,textColor:checkFontColor(color)}));
  1551. var afterScroll = $('#main').width()-$('#calendar').width();
  1552. rerenderCalendar(beforeScroll!=afterScroll);
  1553. if(allDay)
  1554. {
  1555. $('#allday').prop('checked', true);
  1556. $('#time_from_cell').css('visibility', 'hidden');
  1557. $('#time_to_cell').css('visibility', 'hidden');
  1558. $('.timezone_row').css('display', 'none');
  1559. }
  1560. showTimezones('', '');
  1561. }
  1562. if(mod=='show' || mod=='drop')
  1563. {
  1564. if(calEvent.status=='CANCELLED')
  1565. $('#name').addClass('title_cancelled');
  1566. $('#name').val(calEvent.title);
  1567. $('#location').val(calEvent.location);
  1568. if(calEvent.allDay==true)
  1569. {
  1570. $('#allday').prop('checked', true);
  1571. $('#time_from_cell').css('visibility', 'hidden');
  1572. $('#time_to_cell').css('visibility', 'hidden');
  1573. $('.timezone_row').css('display', 'none');
  1574. }
  1575. if(calEvent.end)
  1576. if(calEvent.realEnd && (mod!='drop' || repeatOne!='editOnly'))
  1577. date_to=new Date(calEvent.realEnd.getTime());
  1578. else
  1579. date_to=new Date(calEvent.end.getTime());
  1580. $('#note').val(calEvent.note).trigger('autosize.resize');
  1581. if(typeof calEvent.classType!='undefined' && calEvent.classType!=null && calEvent.classType!='')
  1582. $('#type').val(calEvent.classType.toLowerCase());
  1583. else
  1584. $('#type').val('public');
  1585. if(calEvent.status!='')
  1586. $('#status').val(calEvent.status);
  1587. else
  1588. $('#status').val('NONE');
  1589. if(calEvent!=null && mod!='new')
  1590. {
  1591. var uidArray = calEvent.id.match(vCalendar.pre['uidParts']);
  1592. if(decodeURIComponent(uidArray[4]).indexOf(uidArray[2])==-1)
  1593. $('.row_type').css('display','none');
  1594. }
  1595. if(calEvent.avail == 'OPAQUE')
  1596. $('#avail').val('busy');
  1597. else
  1598. $('#avail').val('free');
  1599. if(calEvent!=null)
  1600. {
  1601. var prior=parseInt(calEvent.priority,10);
  1602. if(prior==5)
  1603. $('#priority').val(5);
  1604. else if(prior>5 && prior<10)
  1605. {
  1606. $('#priority [data-type="priority_low"]').attr('value',prior)
  1607. $('#priority').val(prior);
  1608. }
  1609. else if(prior<5 && prior>0)
  1610. {
  1611. $('#priority [data-type="priority_high"]').attr('value',prior)
  1612. $('#priority').val(prior);
  1613. }
  1614. else
  1615. $('#priority').val(0);
  1616. }
  1617. $('#uid').val(calEvent.id);
  1618. $('#url_EVENT').val(calEvent.hrefUrl+'');
  1619. $('#vcalendarHash').val(hex_sha256(calEvent.vcalendar));
  1620. $('#etag').val(calEvent.etag);
  1621. var stringUIDcurrent=calEvent.vcalendar.match(vCalendar.pre['contentline_UID']);
  1622. if(stringUIDcurrent!=null)
  1623. stringUIDcurrent=stringUIDcurrent[0].match(vCalendar.pre['contentline_parse'])[4];
  1624. if(stringUIDcurrent)
  1625. $('#vcalendarUID').val(stringUIDcurrent);
  1626. var alarmDate='';
  1627. for(var alarmIterator=0;alarmIterator<calEvent.alertTime.length;alarmIterator++)
  1628. {
  1629. if(alarmIterator>0)
  1630. event_alert_add(alarmIterator);
  1631. $(".alert[data-id="+(alarmIterator+1)+"]").val("message");
  1632. if(calEvent.alertTime[alarmIterator].charAt(0)=='-' || calEvent.alertTime[alarmIterator].charAt(0)=='+')
  1633. {
  1634. var alVal=parseInt(calEvent.alertTime[alarmIterator].substring(1, calEvent.alertTime[alarmIterator].length-1));
  1635. var alString='';
  1636. if(calEvent.alertTime[alarmIterator].charAt(calEvent.alertTime[alarmIterator].length-1)=="W")
  1637. {
  1638. alVal=alVal/1000/60/60/24/7;
  1639. alString='weeks';
  1640. }
  1641. else if(calEvent.alertTime[alarmIterator].charAt(calEvent.alertTime[alarmIterator].length-1)=="D")
  1642. {
  1643. alVal=alVal/1000/60/60/24;
  1644. alString='days';
  1645. }
  1646. else if(calEvent.alertTime[alarmIterator].charAt(calEvent.alertTime[alarmIterator].length-1)=="H")
  1647. {
  1648. alVal=alVal/1000/60/60;
  1649. alString='hours';
  1650. }
  1651. else if(calEvent.alertTime[alarmIterator].charAt(calEvent.alertTime[alarmIterator].length-1)=="M")
  1652. {
  1653. alVal=alVal/1000/60;
  1654. alString='minutes';
  1655. }
  1656. else if(calEvent.alertTime[alarmIterator].charAt(calEvent.alertTime[alarmIterator].length-1)=="S")
  1657. {
  1658. alVal=alVal/1000;
  1659. alString='seconds';
  1660. }
  1661. if(calEvent.alertTime[alarmIterator].charAt(0)=='-')
  1662. alString+="_before";
  1663. else
  1664. alString+="_after"
  1665. $(".alert_message_details[data-id="+(alarmIterator+1)+"]").val(alString);
  1666. $(".before_after_input[data-id="+(alarmIterator+1)+"]").val(alVal);
  1667. $('.alert_details[data-id="'+(alarmIterator+1)+'"]').show();
  1668. $('.alert_message_date[data-id="'+(alarmIterator+1)+'"]').show();
  1669. $('.before_after_input[data-id="'+(alarmIterator+1)+'"]').show();
  1670. $(".message_date_input[data-id="+(alarmIterator+1)+"]").hide();
  1671. $(".message_time_input[data-id="+(alarmIterator+1)+"]").hide();
  1672. }
  1673. else
  1674. {
  1675. alarmDate=$.fullCalendar.parseDate(calEvent.alertTime[alarmIterator]);
  1676. (alarmDate.getHours())<10 ? (hour='0'+(alarmDate.getHours())) : (hour=alarmDate.getHours());
  1677. (alarmDate.getMinutes())<10 ? (minute='0'+(alarmDate.getMinutes())) : (minute=alarmDate.getMinutes());
  1678. $(".alert_message_details[data-id="+(alarmIterator+1)+"]").val('on_date');
  1679. var formattedAlarmDate=$.datepicker.formatDate(globalSettings.datepickerformat.value, alarmDate);
  1680. $(".message_date_input[data-id="+(alarmIterator+1)+"]").val(formattedAlarmDate);
  1681. $(".message_time_input[data-id="+(alarmIterator+1)+"]").val($.fullCalendar.formatDate(alarmDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  1682. $('.alert_details[data-id="'+(alarmIterator+1)+'"]').show();
  1683. $('.alert_message_date[data-id="'+(alarmIterator+1)+'"]').show();
  1684. }
  1685. }
  1686. if(alarmIterator>0)
  1687. event_alert_add(alarmIterator+2);
  1688. if(calEvent.type!='' && repeatOne!='editOnly' && calEvent.ruleString.match(vCalendar.re['recurCaldav'])!=null)
  1689. {
  1690. var ruleString=calEvent.vcalendar.match(vCalendar.pre['contentline_RRULE2'])[0].match(vCalendar.pre['contentline_parse'])[4];
  1691. if(ruleString.indexOf('BYMONTH=')!=-1 || ruleString.indexOf('BYMONTHDAY=')!=-1 || ruleString.indexOf('BYDAY=')!=-1)
  1692. {
  1693. var pars=ruleString.split(';');
  1694. if(pars.indexElementOf('BYMONTH=')!=-1 && pars.indexElementOf('BYMONTHDAY=')==-1 && pars.indexElementOf('BYDAY=')==-1)
  1695. pars[pars.length] = "BYMONTHDAY="+calEvent.start.getDate();
  1696. if(calEvent.type=="DAILY")
  1697. {
  1698. $("#repeat option[value='DAILY']").prop('selected', true);
  1699. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatDays);
  1700. }
  1701. else if(calEvent.type=="WEEKLY")
  1702. {
  1703. $("#repeat option[value='CUSTOM_WEEKLY']").prop('selected', true);
  1704. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatWeeks);
  1705. for(var ri=0;ri<pars.length;ri++)
  1706. {
  1707. if(pars[ri].indexOf("BYDAY=")!=-1)
  1708. {
  1709. var byDay=pars[ri].split('=')[1];
  1710. byDay=byDay.replace(/\d*MO/,1).replace(/\d*TU/,2).replace(/\d*WE/,3).replace(/\d*TH/,4).replace(/\d*FR/,5).replace(/\d*SA/,6).replace(/\d*SU/,0).split(',');
  1711. for(var rj=0;rj<byDay.length;rj++)
  1712. {
  1713. if(!isNaN(parseInt(byDay[rj],10)))
  1714. $('#week_custom .customTable td[data-type="'+byDay[rj]+'"]').addClass('selected');
  1715. }
  1716. }
  1717. }
  1718. $('#week_custom').show();
  1719. }
  1720. else if(calEvent.type=="MONTHLY")
  1721. {
  1722. $("#repeat option[value='CUSTOM_MONTHLY']").prop('selected', true).change();
  1723. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatMonths);
  1724. for(var ri=0;ri<pars.length;ri++)
  1725. {
  1726. if(pars[ri].indexOf("BYDAY=")!=-1)
  1727. {
  1728. var byDay=pars[ri].split('=')[1];
  1729. byDay=byDay.split(',');
  1730. for(var rj=0;rj<byDay.length;rj++)
  1731. {
  1732. var checkString = byDay[rj].match(vCalendar.pre['+/-number']);
  1733. byDay[rj] = byDay[rj].replace(checkString[0],'');
  1734. if(!isNaN(parseInt(checkString[0],10)))
  1735. {
  1736. switch(parseInt(checkString[0],10))
  1737. {
  1738. case 1:
  1739. $('#repeat_month_custom_select').val('first');
  1740. break;
  1741. case 2:
  1742. $('#repeat_month_custom_select').val('second');
  1743. break;
  1744. case 3:
  1745. $('#repeat_month_custom_select').val('third');
  1746. break;
  1747. case 4:
  1748. $('#repeat_month_custom_select').val('fourth');
  1749. break;
  1750. case 5:
  1751. $('#repeat_month_custom_select').val('fifth');
  1752. break;
  1753. case -1:
  1754. $('#repeat_month_custom_select').val('last');
  1755. break;
  1756. default:
  1757. $('#repeat_month_custom_select').val('every');
  1758. break;
  1759. }
  1760. $('#repeat_month_custom_select2').val(byDay[rj]);
  1761. }
  1762. }
  1763. }
  1764. else if(pars[ri].indexOf("BYMONTHDAY=")!=-1)
  1765. {
  1766. $('#repeat_month_custom_select').val('custom').change();
  1767. var byMonthDay=pars[ri].split('=')[1];
  1768. byMonthDay=byMonthDay.split(',');
  1769. for(var rj=0; rj<byMonthDay.length;rj++)
  1770. {
  1771. if(parseInt(byMonthDay[rj],10)==-1)
  1772. {
  1773. $('#repeat_month_custom_select').val('last').change();
  1774. $('#repeat_month_custom_select2').val("DAY");
  1775. }
  1776. else
  1777. $('#month_custom2 .customTable td[data-type="'+(parseInt(byMonthDay[rj],10))+'"]').addClass('selected');
  1778. }
  1779. }
  1780. }
  1781. }
  1782. else if(calEvent.type=="YEARLY")
  1783. {
  1784. $("#repeat option[value='CUSTOM_YEARLY']").prop('selected', true).change();
  1785. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatYears);
  1786. var isMonthDay=false;
  1787. for(var ri=0;ri<pars.length;ri++)
  1788. {
  1789. if(pars[ri].indexOf("BYDAY=")!=-1)
  1790. {
  1791. var byDay=pars[ri].split('=')[1];
  1792. byDay=byDay.split(',');
  1793. for(var rj=0;rj<byDay.length;rj++)
  1794. {
  1795. var checkString = byDay[rj].match(vCalendar.pre['+/-number']);
  1796. byDay[rj] = byDay[rj].replace(checkString[0],'');
  1797. if(!isNaN(parseInt(checkString[0],10)))
  1798. {
  1799. switch(parseInt(checkString[0],10))
  1800. {
  1801. case 1:
  1802. $('#repeat_year_custom_select1').val('first');
  1803. break;
  1804. case 2:
  1805. $('#repeat_year_custom_select1').val('second');
  1806. break;
  1807. case 3:
  1808. $('#repeat_year_custom_select1').val('third');
  1809. break;
  1810. case 4:
  1811. $('#repeat_year_custom_select1').val('fourth');
  1812. break;
  1813. case 5:
  1814. $('#repeat_year_custom_select1').val('fifth');
  1815. break;
  1816. case -1:
  1817. $('#repeat_year_custom_select1').val('last');
  1818. break;
  1819. default:
  1820. $('#repeat_year_custom_select1').val('every');
  1821. break;
  1822. }
  1823. $('#repeat_year_custom_select2').val(byDay[rj]);
  1824. }
  1825. }
  1826. }
  1827. else if(pars[ri].indexOf("BYMONTHDAY=")!=-1)
  1828. {
  1829. $('#repeat_year_custom_select1').val('custom').change()
  1830. var byMonthDay=pars[ri].split('=')[1];
  1831. byMonthDay=byMonthDay.split(',');
  1832. for(var rj=0; rj<byMonthDay.length;rj++)
  1833. {
  1834. if(parseInt(byMonthDay[rj],10)==-1)
  1835. {
  1836. $('#repeat_year_custom_select1').val('last').change();
  1837. $('#repeat_year_custom_select2').val("DAY");
  1838. }
  1839. else
  1840. $('#year_custom1 .customTable td[data-type="'+(parseInt(byMonthDay[rj],10))+'"]').addClass('selected');
  1841. }
  1842. isMonthDay=true;
  1843. }
  1844. else if(pars[ri].indexOf("BYMONTH=")!=-1)
  1845. {
  1846. var byMonth=pars[ri].split('=')[1];
  1847. byMonth=byMonth.split(',');
  1848. for(var rj=0; rj<byMonth.length;rj++)
  1849. $('#year_custom3 .customTable td[data-type="'+(parseInt(byMonth[rj],10)-1)+'"]').addClass('selected');
  1850. }
  1851. }
  1852. }
  1853. if(calEvent.after=='' && calEvent.untilDate=='')
  1854. $("#repeat_end_details option[value='never']").prop('selected', true);
  1855. else if(calEvent.after!='')
  1856. {
  1857. $("#repeat_end_details option[value='after']").prop('selected', true);
  1858. $('#repeat_end_after').val(calEvent.after);
  1859. }
  1860. else if(calEvent.untilDate!='')
  1861. {
  1862. date=$.fullCalendar.parseDate(calEvent.untilDate);
  1863. $("#repeat_end_details option[value='on_date']").prop('selected', true);
  1864. var formattedRepeatDate=$.datepicker.formatDate(globalSettings.datepickerformat.value, date);
  1865. $('#repeat_end_date').val(formattedRepeatDate);
  1866. }
  1867. $('#repeat_interval_detail').val(calEvent.interval);
  1868. $('#repeat_interval').show();
  1869. if(calEvent.byDay.length>0)
  1870. {
  1871. var businessArray=new Array();
  1872. if(globalSettings.weekenddays.value.length>0)
  1873. for(var i=0;i<7;i++)
  1874. if(globalSettings.weekenddays.value.indexOf(i)==-1)
  1875. businessArray[businessArray.length]=i+'';
  1876. var businessCount=0;
  1877. var weekendCount=0;
  1878. for(var i=0;i<byDay.length;i++)
  1879. {
  1880. if(businessArray.indexOf(byDay[i])!=-1)
  1881. businessCount++;
  1882. if(globalSettings.weekenddays.value.indexOf(parseInt(byDay[i],10))!=-1)
  1883. weekendCount++;
  1884. }
  1885. if(businessArray.length>0 && businessArray.length==businessCount)
  1886. {
  1887. $("#repeat option[value='BUSINESS']").prop('selected', true);
  1888. $('#repeat_interval').hide();
  1889. $('#week_custom').hide();
  1890. }
  1891. else if(globalSettings.weekenddays.value.length>0 && globalSettings.weekenddays.value.length==weekendCount)
  1892. {
  1893. $("#repeat option[value='WEEKEND']").prop('selected', true);
  1894. $('#repeat_interval').hide();
  1895. $('#week_custom').hide();
  1896. }
  1897. }
  1898. }
  1899. else
  1900. {
  1901. if(calEvent.type=="DAILY")
  1902. {
  1903. $("#repeat option[value='DAILY']").prop('selected', true);
  1904. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatDays);
  1905. }
  1906. else if(calEvent.type=="WEEKLY")
  1907. {
  1908. $("#repeat option[value='WEEKLY']").prop('selected', true);
  1909. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatWeeks);
  1910. }
  1911. else if(calEvent.type=="MONTHLY")
  1912. {
  1913. $("#repeat option[value='MONTHLY']").prop('selected', true);
  1914. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatMonths);
  1915. }
  1916. else if(calEvent.type=="YEARLY")
  1917. {
  1918. $("#repeat option[value='YEARLY']").prop('selected', true);
  1919. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatYears);
  1920. }
  1921. if(calEvent.after=='' && calEvent.untilDate=='')
  1922. $("#repeat_end_details option[value='never']").prop('selected', true);
  1923. else if(calEvent.after!='')
  1924. {
  1925. $("#repeat_end_details option[value='after']").prop('selected', true);
  1926. $('#repeat_end_after').val(calEvent.after);
  1927. }
  1928. else if(calEvent.untilDate!='')
  1929. {
  1930. date=$.fullCalendar.parseDate(calEvent.untilDate);
  1931. $("#repeat_end_details option[value='on_date']").prop('selected', true);
  1932. var formattedRepeatDate=$.datepicker.formatDate(globalSettings.datepickerformat.value, date);
  1933. $('#repeat_end_date').val(formattedRepeatDate);
  1934. }
  1935. $('#repeat_interval_detail').val(calEvent.interval);
  1936. $('#repeat_interval').show();
  1937. if(calEvent.byDay.length>0)
  1938. {
  1939. if(calEvent.byDay.indexOf('1')!=-1 && calEvent.byDay.indexOf('2')!=-1 && calEvent.byDay.indexOf('3')!=-1 && calEvent.byDay.indexOf('4')!=-1 && calEvent.byDay.indexOf('5')!=-1 && calEvent.byDay.indexOf('6')==-1 && calEvent.byDay.indexOf('0')==-1)
  1940. {
  1941. $("#repeat option[value='BUSINESS']").prop('selected', true);
  1942. $('#repeat_interval').hide();
  1943. }
  1944. else if(calEvent.byDay.indexOf('1')==-1 && calEvent.byDay.indexOf('2')==-1 && calEvent.byDay.indexOf('3')==-1 && calEvent.byDay.indexOf('4')==-1 && calEvent.byDay.indexOf('5')==-1 && calEvent.byDay.indexOf('6')!=-1 && calEvent.byDay.indexOf('0')!=-1)
  1945. {
  1946. $("#repeat option[value='WEEKEND']").prop('selected', true);
  1947. $('#repeat_interval').hide();
  1948. }
  1949. }
  1950. $('#repeatEvent').val(true);
  1951. }
  1952. }
  1953. else if(calEvent.type!='' && repeatOne!='editOnly')
  1954. {
  1955. var cu_opt = new Option(localization[globalInterfaceLanguage].customRepeat, calEvent.ruleString, false, true);
  1956. $(cu_opt).attr('data-type','custom_repeat');
  1957. $('#repeat').append(cu_opt);
  1958. }
  1959. else
  1960. $('#repeatEvent').val(false);
  1961. if(calEvent.timeZone)
  1962. showTimezones(calEvent.timeZone,'');
  1963. else
  1964. showTimezones('local','');
  1965. }
  1966. var year,
  1967. month,
  1968. day,
  1969. hour,
  1970. minute;
  1971. if(mod=='show')
  1972. $('#show').val(calEvent.id);
  1973. if(mod=='show' || mod=='drop')
  1974. {
  1975. $('#repeatCount').val(calEvent.repeatCount);
  1976. if(calEvent.realStart && (mod!='drop' || repeatOne!='editOnly'))
  1977. date=calEvent.realStart;
  1978. else
  1979. date=calEvent.start;
  1980. if($('#show').val())
  1981. {
  1982. if(calEvent.repeatStart && repeatOne=='')
  1983. date=new Date(calEvent.repeatStart.getTime());
  1984. if(calEvent.repeatEnd && repeatOne=='')
  1985. date_to=new Date(calEvent.repeatEnd.getTime());
  1986. }
  1987. if(repeatOne=='editOnly')
  1988. {
  1989. if((mod=='drop' && globalPrevDragEventAllDay) || (mod!='drop' && calEvent.allDay))
  1990. {
  1991. if(calEvent.realStart)
  1992. $('#recurrenceID').val($.fullCalendar.formatDate($.fullCalendar.parseDate(calEvent.realStart), "yyyyMMdd"));
  1993. else
  1994. $('#recurrenceID').val($.fullCalendar.formatDate(date, "yyyyMMdd"));
  1995. }
  1996. else
  1997. {
  1998. if(calEvent.realStart)
  1999. $('#recurrenceID').val($.fullCalendar.formatDate(calEvent.realStart, "yyyyMMdd'T'HHmmss"));
  2000. else
  2001. $('#recurrenceID').val($.fullCalendar.formatDate(date, "yyyyMMdd'T'HHmmss"));
  2002. }
  2003. }
  2004. else
  2005. $('#recurrenceID').val(calEvent.rec_id);
  2006. if(calEvent.rec_id || repeatOne=='editOnly' || repeatOne=='futureOnly')
  2007. {
  2008. var savedEvs=jQuery.grep(globalEventList.displayEventsArray[calEvent.res_id],function(e){if(e.id==calEvent.id && (e.repeatCount<2 || !e.repeatCount))return true});
  2009. if(savedEvs.length>1 || (repeatOne=='futureOnly' && calEvent.repeatCount>1) || (repeatOne=='editOnly' && calEvent.type!=''))
  2010. $('#deleteButton').attr('onclick',"updateEventFormDimensions(true);$('#CAEvent .saveLoader').show();save(false, true);");
  2011. }
  2012. }
  2013. var today = new Date();
  2014. var todayClear = new Date(today.getTime());
  2015. todayClear.setHours(0);
  2016. todayClear.setMinutes(0);
  2017. todayClear.setSeconds(0);
  2018. todayClear.setMilliseconds(0);
  2019. var dateClear = new Date(date.getTime());
  2020. dateClear.setHours(0);
  2021. dateClear.setMinutes(0);
  2022. dateClear.setSeconds(0);
  2023. dateClear.setMilliseconds(0);
  2024. if(allDay)
  2025. {
  2026. if(globalSettings.defaulteventduration.value!==null && todayClear.getTime()===dateClear.getTime())
  2027. {
  2028. if(today.getMinutes()>0) {
  2029. date.setHours(today.getHours()+1);
  2030. date.setMinutes(0);
  2031. }
  2032. else {
  2033. date.setHours(today.getHours());
  2034. date.setMinutes(today.setMinutes());
  2035. }
  2036. }
  2037. else {
  2038. date.setHours(globalSettings.calendarstartofbusiness.value);
  2039. date.setMinutes((globalSettings.calendarstartofbusiness.value%1)*60);
  2040. }
  2041. }
  2042. $('#date_from').val($.datepicker.formatDate(globalSettings.datepickerformat.value, date));
  2043. $('#time_from').val($.fullCalendar.formatDate(date, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  2044. globalPrevDate=new Date(date.getTime());
  2045. if(typeof date_to==='undefined' || date_to===null)
  2046. date_to = new Date(date.getTime());
  2047. if(allDay) {
  2048. if(globalSettings.defaulteventduration.value!==null)
  2049. {
  2050. date_to.setHours(date.getHours());
  2051. date_to.setMinutes(date.getMinutes()+globalSettings.defaulteventduration.value);
  2052. }
  2053. else {
  2054. date_to.setHours(globalSettings.calendarendofbusiness.value);
  2055. date_to.setMinutes((globalSettings.calendarendofbusiness.value%1)*60);
  2056. }
  2057. }
  2058. if(date_to.getTime()<date.getTime())
  2059. date_to.setDate(date_to.getDate()+1);
  2060. $('#date_to').val($.datepicker.formatDate(globalSettings.datepickerformat.value, date_to));
  2061. $('#time_to').val($.fullCalendar.formatDate(date_to, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  2062. if($('#repeat option:selected').attr('data-type')!="repeat_no-repeat" && $('#repeat option:selected').attr('data-type')!="custom_repeat")
  2063. $('#repeat_details').show();
  2064. if($('#repeat_end_details option:selected').attr('data-type')=="repeat_details_on_date")
  2065. {
  2066. $('#repeat_end_after').hide();
  2067. $('#repeat_end_date').show();
  2068. }
  2069. if($('#repeat_end_details option:selected').attr('data-type')=="repeat_details_after")
  2070. {
  2071. $('#repeat_end_after').show();
  2072. $('#repeat_end_date').hide();
  2073. }
  2074. if($('#repeat_end_details option:selected').attr('data-type')=="repeat_details_never")
  2075. {
  2076. $('#repeat_end_after').hide();
  2077. $('#repeat_end_date').hide();
  2078. }
  2079. if(mod=='show')
  2080. {
  2081. $('#saveButton').hide();
  2082. $('#resetButton').hide();
  2083. $('#deleteButton').hide();
  2084. if($('#ResourceCalDAVList').find('[data-id="'+calEvent.res_id+'"]').hasClass("resourceCalDAV_item_ro"))
  2085. {
  2086. $('#editButton').hide();
  2087. $('#duplicateButton').hide();
  2088. $('#editOptionsButton').hide();
  2089. }
  2090. $('#eventDetailsTable :input[type!="button"]').prop('disabled', true);
  2091. $('#eventDetailsTable :input[type="text"]').prop('readonly', true);
  2092. $('#eventDetailsTable .customTable td').addClass('disabled');
  2093. $('#eventDetailsTable textarea').prop('readonly', true);
  2094. /*************************** BAD HACKS SECTION ***************************/
  2095. // here we fix the cross OS/cross broser problems (unfixable in pure CSS)
  2096. if($.browser.webkit && !!window.chrome) /* Chrome */
  2097. {
  2098. if(navigator.platform.toLowerCase().indexOf('win')==0) /* Windows version */
  2099. {
  2100. $('#event_details_template').find('input').css('text-indent', '2px');
  2101. $('#event_details_template').find('select').css({'padding-left': '0px', 'padding-right': '13px'});
  2102. }
  2103. else /* non-Windows version */
  2104. $('#event_details_template').find('input').css('text-indent', '1px');
  2105. }
  2106. else if($.browser.safari)
  2107. {
  2108. $('#event_details_template').find('textarea').addClass('safari_hack');
  2109. $('#event_details_template').find('input').addClass('safari_hack');
  2110. }
  2111. else if($.browser.msie) /* IE */
  2112. {
  2113. if(parseInt($.browser.version, 10)==10) /* IE 10 (because there are no more conditional comments) */
  2114. {
  2115. $('#event_details_template').find('select').css({'padding-top': '1px', 'padding-left': '0px', 'padding-right': '0px'});
  2116. $('#event_details_template').find('textarea').css('padding-top', '3px');
  2117. $('#event_details_template').find('input[type=button]').css('padding-top', '2px');
  2118. }
  2119. }
  2120. if($.browser.msie || $.browser.mozilla)
  2121. {
  2122. var newSVG=$(SVG_select_dis).attr('data-type', 'select_icon').css({'pointer-events': 'none', 'z-index': '1', 'display': 'inline', 'margin-left': '-22px', 'vertical-align': 'top', 'background-color': '#ffffff'}); // background-color = stupid IE9 bug
  2123. $('#event_details_template').find('svg[data-type="select_icon"]').replaceWith($('<div>').append($(newSVG).clone()).html());
  2124. }
  2125. /*************************** END OF BAD HACKS SECTION ***************************/
  2126. if(calEvent.etag!='')
  2127. $('#event_calendar').val(calEvent.res_id);
  2128. }
  2129. if(repeatOne=='editOnly' || $('#recurrenceID').val()!='')
  2130. {
  2131. $('#repeat').parent().parent().css('display', 'none');
  2132. $('#week_custom').css('display', 'none');
  2133. $('#month_custom1').css('display', 'none');
  2134. $('#month_custom2').css('display', 'none');
  2135. $('#year_custom1').css('display', 'none');
  2136. $('#year_custom2').css('display', 'none');
  2137. $('#year_custom3').css('display', 'none');
  2138. $('#repeat_details').css('display', 'none');
  2139. }
  2140. if(repeatOne=='editOnly' || repeatOne=='futureOnly' || $('#recurrenceID').val())
  2141. $('#calendarLine').hide();
  2142. if(calEvent==null || calEvent.type=='')
  2143. $('#editOptionsButton').hide();
  2144. else
  2145. $('#editOptionsButton').click(function(){
  2146. showEventForm(null, globalCalEvent.allDay, globalCalEvent, globalJsEvent, 'show', '', true);
  2147. });
  2148. if(calEvent && calEvent.after && repeatOne=='futureOnly')
  2149. $('#repeat_end_after').val(calEvent.after - calEvent.realRepeatCount + 1);
  2150. if(!globalSettings.timezonesupport.value)
  2151. $('.timezone_row').css('display', 'none');
  2152. if($('#allday').prop('checked'))
  2153. stripEventAlerts();
  2154. if(mod!='drop')
  2155. {
  2156. $('#CAEvent').show();
  2157. $('#event_details_template').show();
  2158. $('#eventColor').css('background-color',color);
  2159. updateEventFormDimensions();
  2160. setFormPosition(jsEvent);
  2161. }
  2162. checkEventFormScrollBar();
  2163. $('#event_details_template').scrollTop(0);
  2164. }
  2165. function bindEventForm()
  2166. {
  2167. initCalDavDatepicker($('#event_details_template'));
  2168. initCalDavTimepicker($('#event_details_template'));
  2169. $('#event_details_template .alert_message_details').change(function(){
  2170. var data_id=$(this).attr("data-id");
  2171. $('.before_after_input[data-id="'+data_id+'"]').parent().parent().find('img').css('display','none');
  2172. if($('.alert_message_details[data-id="'+data_id+'"] option:selected').attr('data-type')=="on_date")
  2173. {
  2174. var myDate=new Date();
  2175. myDate.setDate(myDate.getDate()+7);
  2176. if($('#date_from').parent().parent().find('img:visible').length==0) {
  2177. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_from").val());
  2178. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  2179. myDate=new Date(Date.parse(datetime_to + (!$("#allday").prop('checked')?$("#time_from").val():'')));
  2180. myDate.setHours(myDate.getHours()-1);
  2181. }
  2182. else if($('#date_to').parent().parent().find('img:visible').length==0) {
  2183. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_to").val());
  2184. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  2185. myDate=new Date(Date.parse(datetime_to + (!$("#allday").prop('checked')?$("#time_to").val():'')));
  2186. myDate.setHours(myDate.getHours()-1);
  2187. }
  2188. $('.message_date_input[data-id="'+data_id+'"]').val($.datepicker.formatDate(globalSettings.datepickerformat.value, myDate));
  2189. $('.message_date_input[data-id="'+data_id+'"]').show();
  2190. $('.message_time_input[data-id="'+data_id+'"]').val($.fullCalendar.formatDate(myDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  2191. $('.message_time_input[data-id="'+data_id+'"]').show();
  2192. $('.before_after_input[data-id="'+data_id+'"]').hide();
  2193. }
  2194. else
  2195. {
  2196. $('.message_date_input[data-id="'+data_id+'"]').hide();
  2197. $('.message_time_input[data-id="'+data_id+'"]').hide();
  2198. $('.before_after_input[data-id="'+data_id+'"]').show();
  2199. $('.before_after_input[data-id="'+data_id+'"]').val('15');
  2200. }
  2201. });
  2202. $('#event_details_template .before_after_input').bind('keyup change', function(){
  2203. if($(this).val()=='')
  2204. {
  2205. $(this).parent().find('img').css('display', 'inline');
  2206. //$(this).parent().find('img').css('visibility','visible');
  2207. }
  2208. else
  2209. {
  2210. if($(this).val().match("^(\d*[0-9])*$")==null)
  2211. {
  2212. $(this).parent().find('img').css('display', 'inline');
  2213. //$(this).parent().find('img').css('visibility','visible');
  2214. }
  2215. else
  2216. $(this).parent().find('img').css('display', 'none');
  2217. }
  2218. });
  2219. $('#event_details_template .alert').change(function(){
  2220. var data_id=$(this).attr("data-id");
  2221. if($(this).val()!='none')
  2222. {
  2223. $('.alert_details[data-id="'+data_id+'"]').show();
  2224. $('.alert_message_date[data-id="'+data_id+'"]').show();
  2225. var myDate=new Date();
  2226. myDate.setDate(myDate.getDate()+7);
  2227. if($('#date_from').parent().parent().find('img:visible').length==0) {
  2228. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_from").val());
  2229. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  2230. myDate=new Date(Date.parse(datetime_to + (!$("#allday").prop('checked')?$("#time_from").val():'')));
  2231. myDate.setHours(myDate.getHours()-1);
  2232. }
  2233. else if($('#date_to').parent().parent().find('img:visible').length==0) {
  2234. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_to").val());
  2235. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  2236. myDate=new Date(Date.parse(datetime_to + (!$("#allday").prop('checked')?$("#time_to").val():'')));
  2237. myDate.setHours(myDate.getHours()-1);
  2238. }
  2239. $('.message_date_input[data-id="'+data_id+'"]').val($.datepicker.formatDate(globalSettings.datepickerformat.value, myDate));
  2240. $('.message_time_input[data-id="'+data_id+'"]').val($.fullCalendar.formatDate(myDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  2241. event_alert_add(data_id);
  2242. }
  2243. else
  2244. {
  2245. $('.alert_details[data-id="'+data_id+'"]').hide();
  2246. $('.alert_message_date[data-id="'+data_id+'"]').hide();
  2247. checkFor(data_id);
  2248. var data_id=$(this).attr("data-id");
  2249. $('#event_details_template tr[data-id="'+data_id+'"]').remove();
  2250. }
  2251. checkEventFormScrollBar();
  2252. });
  2253. $('#repeat_end_after, #repeat_interval_detail').bind('keyup change',function(){
  2254. if($(this).val()=='')
  2255. {
  2256. $(this).parent().find('img').css('display', 'inline');
  2257. //$(this).parent().find('img').css('visibility','visible');
  2258. }
  2259. else
  2260. {
  2261. if($(this).val().match("^[0-9]+$")==null || parseInt($(this).val(),10)<1)
  2262. {
  2263. $(this).parent().find('img').css('display', 'inline');
  2264. //$(this).parent().find('img').css('visibility','visible');
  2265. }
  2266. else
  2267. $(this).parent().find('img').css('display', 'none');
  2268. }
  2269. });
  2270. $('#repeat_month_custom_select').change(function(){
  2271. if($(this).val()=="custom")
  2272. {
  2273. $('#month_custom2').show();
  2274. $('#repeat_month_custom_select2').parent().hide();
  2275. }
  2276. else
  2277. {
  2278. $('#month_custom2').hide();
  2279. $('#repeat_month_custom_select2').parent().show();
  2280. }
  2281. checkEventFormScrollBar();
  2282. });
  2283. $('#repeat_year_custom_select1').change(function(){
  2284. if($(this).val()=="custom")
  2285. {
  2286. $('#year_custom1').show();
  2287. $('#repeat_year_custom_select2').parent().hide();
  2288. }
  2289. else
  2290. {
  2291. $('#year_custom1').hide();
  2292. $('#repeat_year_custom_select2').parent().show();
  2293. }
  2294. checkEventFormScrollBar();
  2295. });
  2296. $('#repeat_end_details').change(function(){
  2297. $('#repeat_end_date').parent().find('img').css('display', 'none');
  2298. if($('#repeat_end_details option:selected').attr('data-type')=="repeat_details_on_date")
  2299. {
  2300. $('#repeat_end_after').hide();
  2301. $('#repeat_end_date').show();
  2302. var today;
  2303. if($('#date_from').val()!='')
  2304. {
  2305. today=$.datepicker.parseDate(globalSettings.datepickerformat.value, $('#date_from').val());
  2306. if(today==null)
  2307. today=new Date();
  2308. }
  2309. else
  2310. today=new Date();
  2311. var date=new Date(today.getFullYear(), today.getMonth(), today.getDate()+2);
  2312. $('#repeat_end_date').val($.datepicker.formatDate(globalSettings.datepickerformat.value, date));
  2313. }
  2314. if($('#repeat_end_details option:selected').attr('data-type')=="repeat_details_after")
  2315. {
  2316. $('#repeat_end_after').show();
  2317. $('#repeat_end_after').val('2');
  2318. $('#repeat_end_date').hide();
  2319. }
  2320. if($('#repeat_end_details option:selected').attr('data-type')=="repeat_details_never")
  2321. {
  2322. $('#repeat_end_after').hide();
  2323. $('#repeat_end_date').hide();
  2324. }
  2325. checkEventFormScrollBar();
  2326. });
  2327. $('#closeButton').click(function(){
  2328. if($('#uid').val()!='')
  2329. {
  2330. var uid=$('#uid').val();
  2331. var calUID=uid.substring(0, uid.lastIndexOf('/')+1);
  2332. var events=$('.event_item[data-id="'+uid+'"]');
  2333. var color=$('#ResourceCalDAVList').find("[data-id='"+calUID+"']").find('.resourceCalDAVColor').css('background-color');
  2334. $.each(events, function(index, event){
  2335. if(event.nodeName.toLowerCase()!='tr')
  2336. {
  2337. $(event).find('.fc-event-inner, .fc-event-head').addBack().css({'background-color': rgbToRgba(color,0.9), 'border-color': color});
  2338. $(event).find('.fc-event-title, .fc-event-title-strict, .fc-event-time').css('color',checkFontColor(rgbToHex(color)));
  2339. }
  2340. else
  2341. {
  2342. $(event).children('.fc-event-handle').css({'background-color': rgbToRgba(color,0.9), 'border-color': color});
  2343. }
  2344. });
  2345. }
  2346. else
  2347. {
  2348. var beforeScroll = $('#main').width()-$('#calendar').width();
  2349. $('#calendar').fullCalendar('unselect');
  2350. $('#calendar').fullCalendar('removeEvents', 'fooUID');
  2351. var afterScroll = $('#main').width()-$('#calendar').width();
  2352. rerenderCalendar(beforeScroll!=afterScroll);
  2353. }
  2354. $('#show').val('');
  2355. $('#CAEvent').hide();
  2356. $('#EventDisabler').fadeOut(globalEditorFadeAnimation, function(){
  2357. $('#timezonePicker').prop('disabled', false);
  2358. });
  2359. });
  2360. $('#resetButton').click(function(){
  2361. $('#event_details_template').find('img[data-type=invalidSmall]').css('display','none');
  2362. var uid=$('#uid').val();
  2363. if(uid!='')
  2364. {
  2365. var calUID=uid.substring(0, uid.lastIndexOf('/')+1);
  2366. var events=$('.event_item[data-id="'+uid+'"]');
  2367. var color=$('#ResourceCalDAVList').find("[data-id='"+calUID+"']").find('.resourceCalDAVColor').css('background-color');
  2368. $.each(events, function(index, event){
  2369. if(event.nodeName.toLowerCase()!='tr')
  2370. {
  2371. $(event).find('.fc-event-inner, .fc-event-head').addBack().css({'background-color': rgbToRgba(color,0.9), 'border-color': color});
  2372. $(event).find('.fc-event-title, .fc-event-title-strict, .fc-event-time').css('color',checkFontColor(rgbToHex(color)));
  2373. }
  2374. else
  2375. {
  2376. $(event).children('.fc-event-handle').css({'background-color': rgbToRgba(color,0.9), 'border-color': color})
  2377. }
  2378. });
  2379. if($('#recurrenceID').val()!='' && $('#repeatCount').val()!='')
  2380. showEventForm(null, globalCalEvent.allDay, globalCalEvent, globalJsEvent, 'show', 'editOnly');
  2381. else if($('#futureStart').val()!='')
  2382. showEventForm(null, globalCalEvent.allDay, globalCalEvent, globalJsEvent, 'show', 'futureOnly');
  2383. else
  2384. showEventForm(null, globalCalEvent.allDay, globalCalEvent, globalJsEvent, 'show', '');
  2385. startEditModeEvent();
  2386. }
  2387. });
  2388. $('#allday').click(function(){
  2389. if($('#allday').prop('checked'))
  2390. {
  2391. $('#timezone').val('local');
  2392. $('#time_from_cell').css('visibility','hidden');
  2393. $('#time_to_cell').css('visibility','hidden');
  2394. $('#time_to_cell').find('img').css('display','none');
  2395. $('#time_from_cell').find('img').css('display','none');
  2396. $('.timezone_row').css('display', 'none');
  2397. stripEventAlerts();
  2398. }
  2399. else
  2400. {
  2401. $('#time_from_cell').css('visibility','visible');
  2402. $('#time_to_cell').css('visibility','visible');
  2403. $('#time_from').trigger('change');
  2404. $('#time_to').trigger('change');
  2405. if(globalSettings.timezonesupport.value)
  2406. {
  2407. $('.timezone_row').show();
  2408. $('#timezone').val(globalSessionTimeZone);
  2409. }
  2410. expandEventAlerts();
  2411. }
  2412. checkEventFormScrollBar();
  2413. });
  2414. $('#event_details_template .customTable td').click(function(){
  2415. if($(this).hasClass('disabled'))
  2416. return true;
  2417. else if($(this).hasClass('selected'))
  2418. $(this).removeClass('selected');
  2419. else
  2420. $(this).addClass('selected');
  2421. });
  2422. $('#event_calendar').change(function(){
  2423. var color = '';
  2424. if($(this).val()=='choose')
  2425. color = 'rgb(240,240,240)';
  2426. else
  2427. color=$('#ResourceCalDAVList').find("[data-id='"+$(this).val()+"']").find('.resourceCalDAVColor').css('background-color');
  2428. var uid='fooUID';
  2429. if($('#uid').val()!='')
  2430. uid=$('#uid').val();
  2431. var events=$('.event_item[data-id="'+uid+'"]');
  2432. $('#eventColor').css('background-color',color);
  2433. $.each(events, function(index, event){
  2434. if(event.nodeName.toLowerCase()!='tr')
  2435. {
  2436. $(event).find('.fc-event-inner, .fc-event-head').addBack().css({'background-color': rgbToRgba(color,0.9), 'border-color': color});
  2437. $(event).find('.fc-event-title, .fc-event-title-strict, .fc-event-time').css('color', checkFontColor(rgbToHex(color)));
  2438. }
  2439. else
  2440. {
  2441. $(event).find('.fc-event-handle').css({'background-color': rgbToRgba(color,0.9), 'border-color': color});
  2442. }
  2443. });
  2444. });
  2445. $('#repeat').change(function(){
  2446. if($('#repeat option:selected').attr('data-type')=='repeat_no-repeat' || $('#repeat option:selected').attr('data-type')=="custom_repeat")
  2447. {
  2448. $('#repeat_details').hide();
  2449. $('#repeat_interval').hide();
  2450. $('#week_custom').hide();
  2451. $('#month_custom1').hide();
  2452. $('#month_custom2').hide();
  2453. $('#year_custom1').hide();
  2454. $('#year_custom2').hide();
  2455. $('#year_custom3').hide();
  2456. }
  2457. else
  2458. {
  2459. $('#repeat_details').show();
  2460. if($(this).val()!='BUSINESS' && $(this).val()!='TWO_WEEKLY' && $(this).val()!='WEEKEND')
  2461. {
  2462. $('#repeat_interval').show();
  2463. $("#repeat_interval_detail").val('1');
  2464. $('#repeat_interval').find('img').css('display','none');
  2465. }
  2466. else
  2467. $('#repeat_interval').hide();
  2468. if($(this).val()=='DAILY')
  2469. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatDays);
  2470. if($(this).val()=='WEEKLY')
  2471. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatWeeks);
  2472. if($(this).val()=='MONTHLY')
  2473. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatMonths);
  2474. if($(this).val()=='YEARLY')
  2475. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatYears);
  2476. if($(this).val()=='CUSTOM_WEEKLY')
  2477. {
  2478. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatWeeks);
  2479. $('#week_custom').show();
  2480. }
  2481. else
  2482. $('#week_custom').hide();
  2483. if($(this).val()=='CUSTOM_MONTHLY')
  2484. {
  2485. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatMonths);
  2486. $('#month_custom1').show();
  2487. if($('#repeat_month_custom_select').val() == "custom")
  2488. $('#repeat_month_custom_select').trigger('change');
  2489. }
  2490. else
  2491. {
  2492. $('#month_custom1').hide();
  2493. $('#month_custom2').hide();
  2494. }
  2495. if($(this).val()=='CUSTOM_YEARLY')
  2496. {
  2497. $('#repeat_interval [data-type="txt_interval"]').text(localization[globalInterfaceLanguage].repeatYears);
  2498. $('#year_custom2').show();
  2499. $('#year_custom3').show();
  2500. if($('#repeat_year_custom_select1').val() == "custom")
  2501. $('#repeat_year_custom_select1').trigger('change');
  2502. }
  2503. else
  2504. {
  2505. $('#year_custom1').hide();
  2506. $('#year_custom2').hide();
  2507. $('#year_custom3').hide();
  2508. }
  2509. var today;
  2510. if($('#date_from').val()!='')
  2511. {
  2512. today=$.datepicker.parseDate(globalSettings.datepickerformat.value, $('#date_from').val());
  2513. if(today==null)
  2514. today=new Date();
  2515. }
  2516. else
  2517. today=new Date();
  2518. var date=new Date(today.getFullYear(),today.getMonth(),today.getDate()+2);
  2519. $('#repeat_end_date').val($.datepicker.formatDate(globalSettings.datepickerformat.value, date));
  2520. }
  2521. checkEventFormScrollBar();
  2522. });
  2523. $('#status').change(function(){
  2524. var status = $(this).val();
  2525. if(status=='CANCELLED')
  2526. $('#name').addClass('title_cancelled');
  2527. else
  2528. $('#name').removeClass('title_cancelled');
  2529. todoStatusChanged(status);
  2530. });
  2531. }
  2532. function startEditModeEvent()
  2533. {
  2534. $('#timezonePicker').prop('disabled', true);
  2535. $('#EventDisabler').fadeIn(globalEditorFadeAnimation);
  2536. $('#CAEvent .formNav').css('display', 'none');
  2537. $('#CAEvent textarea.header').removeClass('leftspace rightspace');
  2538. $('#editButton').hide();
  2539. $('#duplicateButton').hide();
  2540. $('#editOptionsButton').hide();
  2541. $('#saveButton').show();
  2542. $('#resetButton').show();
  2543. $('#deleteButton').show();
  2544. $('#show').val('');
  2545. $('#eventDetailsTable :input[disabled]').prop('disabled', false);
  2546. $('#eventDetailsTable :input[type="text"]').prop('readonly', false);
  2547. $('#eventDetailsTable .customTable td').removeClass('disabled');
  2548. $('#eventDetailsTable textarea').prop('readonly', false);
  2549. /*************************** BAD HACKS SECTION ***************************/
  2550. if($.browser.msie || $.browser.mozilla)
  2551. {
  2552. var newSVG=$(SVG_select).attr('data-type', 'select_icon').css({'pointer-events': 'none', 'z-index': '1', 'display': 'inline', 'margin-left': '-19px', 'vertical-align': 'top', 'background-color': '#ffffff'}); // background-color = stupid IE9 bug
  2553. $('#event_details_template').find('svg[data-type="select_icon"]').replaceWith($('<div>').append($(newSVG).clone()).html());
  2554. }
  2555. /*************************** END OF BAD HACKS SECTION ***************************/
  2556. $('#name').focus();
  2557. }
  2558. function startEditModeTodo()
  2559. {
  2560. $('#todoInEdit').val('true');
  2561. $('#timezonePickerTODO').prop('disabled', true);
  2562. $('#TodoDisabler').fadeIn(globalEditorFadeAnimation);
  2563. $('#CATodo .formNav').css('display', 'none');
  2564. $('#CATodo textarea.header').removeClass('leftspace rightspace');
  2565. $('#editTODO').hide();
  2566. $('#duplicateTODO').hide();
  2567. $('#editOptionsButtonTODO').hide();
  2568. $('#closeTODO').show();
  2569. $('#saveTODO').show();
  2570. $('#resetTODO').show();
  2571. $('#deleteTODO').show();
  2572. $('#showTODO').val('');
  2573. $('#todoDetailsTable :input[disabled]').prop('disabled', false);
  2574. $('#todoDetailsTable :input[type="text"]').prop('readonly', false);
  2575. $('#todoDetailsTable textarea').prop('readonly', false);
  2576. /*************************** BAD HACKS SECTION ***************************/
  2577. if($.browser.msie || $.browser.mozilla)
  2578. {
  2579. var newSVG=$(SVG_select).attr('data-type', 'select_icon').css({'pointer-events': 'none', 'z-index': '1', 'display': 'inline', 'margin-left': '-19px', 'vertical-align': 'top', 'background-color': '#ffffff'}); // background-color = stupid IE9 bug
  2580. $('#todo_details_template').find('svg[data-type="select_icon"]').replaceWith($('<div>').append($(newSVG).clone()).html());
  2581. }
  2582. /*************************** END OF BAD HACKS SECTION ***************************/
  2583. $('#percentageSlider').slider({
  2584. disabled: false
  2585. });
  2586. $('#nameTODO').focus();
  2587. }
  2588. function todo_alert_add(data_id)
  2589. {
  2590. data_id++;
  2591. var newTr1,
  2592. newTr2,
  2593. newTr3;
  2594. newTr1='<tr data-id="'+data_id+'">'+
  2595. '<td><label data-type="alert_TODO" for="alertTODO">alert: </label></td>'+
  2596. '<td data-size="full" colspan="2">'+
  2597. '<select class="long alertTODO" name="alert_typeTODO" data-id="'+data_id+'">'+
  2598. '<option data-type="alert_none_TODO" value="none">none</option>'+
  2599. '<option data-type="alert_message_TODO" value="message">message</option>'+
  2600. '</select>'+
  2601. '</td>'+
  2602. '</tr>';
  2603. newTr2='<tr class="alert_detailsTODO" style="display:none;" data-id="'+data_id+'">'+
  2604. '<td></td>'+
  2605. '<td data-size="full" colspan="2">'+
  2606. '<select class="long alert_message_detailsTODO" name="alert_detailsTODO" data-id="'+data_id+'">'+
  2607. '<option data-type="on_dateTODO" class="todoTimeOptions" value="on_date">On date</option>'+
  2608. ($('#todo_type').val()=='none' ? '' : '<option data-type="weeks_beforeTODO" value="weeks_before">weeks before</option>'+
  2609. '<option data-type="days_beforeTODO" value="days_before">days before</option>'+
  2610. '<option data-type="hours_beforeTODO" value="hours_before">hours before</option>'+
  2611. '<option data-type="minutes_beforeTODO" value="minutes_before">minutes before</option>'+
  2612. '<option data-type="seconds_beforeTODO" value="seconds_before">seconds before</option>'+
  2613. '<option data-type="weeks_afterTODO" value="weeks_after">weeks after</option>'+
  2614. '<option data-type="days_afterTODO" value="days_after">days after</option>'+
  2615. '<option data-type="hours_afterTODO" value="hours_after">hours after</option>'+
  2616. '<option data-type="minutes_afterTODO" value="minutes_after">minutes after</option>'+
  2617. '<option data-type="seconds_afterTODO" value="seconds_after">seconds after</option>')+
  2618. '</select>'+
  2619. '</td>'+
  2620. '</tr>';
  2621. newTr3='<tr data-id="'+data_id+'" class="alert_message_dateTODO" style="display:none;">'+
  2622. '<td></td>'+
  2623. '<td><input data-id="'+data_id+'" data-type="PH_before_after_alert_TODO" class="small before_after_inputTODO" type="text" style="display:none;" />'+
  2624. '<input data-id="'+data_id+'" class="date small message_date_inputTODO" data-type="PH_alarm_date_TODO" type="text" name="message_dateTODO" /><div class="invalidWrapper"><img data-type="invalidSmall" data-id="'+data_id+'" style="display: none;" src="images/error_b.svg" alt="invalid" /></div></td>'+
  2625. '<td><input data-id="'+data_id+'" data-type="PH_alarm_time_TODO" class="time small message_time_inputTODO" type="text" name="message_timeTODO" /><div class="invalidWrapper"><img data-type="invalidSmall" data-id="'+data_id+'" style="display: none;" src="images/error_b.svg" alt="invalid" /></div></td>'+
  2626. '<tr>';
  2627. $('#url_trTODO').before(newTr1);
  2628. $('#url_trTODO').before(newTr2);
  2629. $('#url_trTODO').before(newTr3);
  2630. translateTodoAlerts();
  2631. $('#todo_details_template').find('input[placeholder],textarea[placeholder]').placeholder();
  2632. $('#todo_details_template .alert_message_detailsTODO[data-id="'+data_id+'"]').change(function(){
  2633. var data_id=$(this).attr("data-id");
  2634. $('.before_after_inputTODO[data-id="'+data_id+'"]').parent().parent().find('img').css('display','none');
  2635. if($('.alert_message_detailsTODO[data-id="'+data_id+'"] option:selected').attr('data-type')=="on_dateTODO")
  2636. {
  2637. var myDate=new Date();
  2638. myDate.setDate(myDate.getDate()+7);
  2639. if($('.dateTrToTODO').is(':visible') && $('.dateTrToTODO img:visible').length==0) {
  2640. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_toTODO").val());
  2641. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  2642. myDate=new Date(Date.parse(datetime_to +$("#time_toTODO").val()));
  2643. myDate.setHours(myDate.getHours()-1);
  2644. }
  2645. else if($('.dateTrFromTODO').is(':visible') && $('.dateTrFromTODO img:visible').length==0) {
  2646. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_fromTODO").val());
  2647. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  2648. myDate=new Date(Date.parse(datetime_to +$("#time_fromTODO").val()));
  2649. myDate.setHours(myDate.getHours()-1);
  2650. }
  2651. $('.message_date_inputTODO[data-id="'+data_id+'"]').val($.datepicker.formatDate(globalSettings.datepickerformat.value, myDate));
  2652. $('.message_date_inputTODO[data-id="'+data_id+'"]').show();
  2653. $('.message_time_inputTODO[data-id="'+data_id+'"]').val($.fullCalendar.formatDate(myDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  2654. $('.message_time_inputTODO[data-id="'+data_id+'"]').show();
  2655. $('.before_after_inputTODO[data-id="'+data_id+'"]').hide();
  2656. }
  2657. else
  2658. {
  2659. $('.message_date_inputTODO[data-id="'+data_id+'"]').hide();
  2660. $('.message_time_inputTODO[data-id="'+data_id+'"]').hide();
  2661. $('.before_after_inputTODO[data-id="'+data_id+'"]').show();
  2662. $('.before_after_inputTODO[data-id="'+data_id+'"]').val('15');
  2663. }
  2664. });
  2665. $('#todo_details_template .before_after_inputTODO[data-id="'+data_id+'"]').bind('keyup change', function(){
  2666. if($(this).val()=='')
  2667. {
  2668. $(this).parent().find('img').css('display', 'inline');
  2669. //$(this).parent().find('img').css('visibility','visible');
  2670. }
  2671. else
  2672. {
  2673. if($(this).val().match("^[0-9]+$")==null)
  2674. {
  2675. $(this).parent().find('img').css('display', 'inline');
  2676. //$(this).parent().find('img').css('visibility','visible');
  2677. }
  2678. else
  2679. $(this).parent().find('img').css('display', 'none');
  2680. }
  2681. });
  2682. $('#todo_details_template .alertTODO[data-id="'+data_id+'"]').change(function(){
  2683. var data_id=$(this).attr("data-id");
  2684. if($(this).val()!='none')
  2685. {
  2686. $('.alert_detailsTODO[data-id="'+data_id+'"]').show();
  2687. $('.alert_message_dateTODO[data-id="'+data_id+'"]').show();
  2688. if($('#todo_type').val()!='none')
  2689. expandTodoAlerts();
  2690. var myDate=new Date();
  2691. myDate.setDate(myDate.getDate()+7);
  2692. if($('.dateTrToTODO').is(':visible') && $('.dateTrToTODO img:visible').length==0) {
  2693. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_toTODO").val());
  2694. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  2695. myDate=new Date(Date.parse(datetime_to +$("#time_toTODO").val()));
  2696. myDate.setHours(myDate.getHours()-1);
  2697. }
  2698. else if($('.dateTrFromTODO').is(':visible') && $('.dateTrFromTODO img:visible').length==0) {
  2699. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_fromTODO").val());
  2700. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  2701. myDate=new Date(Date.parse(datetime_to +$("#time_fromTODO").val()));
  2702. myDate.setHours(myDate.getHours()-1);
  2703. }
  2704. $('.message_date_inputTODO[data-id="'+data_id+'"]').val($.datepicker.formatDate(globalSettings.datepickerformat.value, myDate));
  2705. $('.message_time_inputTODO[data-id="'+data_id+'"]').val($.fullCalendar.formatDate(myDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  2706. todo_alert_add(data_id);
  2707. }
  2708. else
  2709. {
  2710. $('.alert_detailsTODO[data-id="'+data_id+'"]').hide();
  2711. $('.alert_message_dateTODO[data-id="'+data_id+'"]').hide();
  2712. checkForTodo(data_id);
  2713. var data_id=$(this).attr("data-id");
  2714. $('#todo_details_template tr[data-id="'+data_id+'"]').remove();
  2715. }
  2716. checkTodoFormScrollBar();
  2717. });
  2718. initCalDavDatepicker($('#todo_details_template .alert_message_dateTODO[data-id="'+data_id+'"]'));
  2719. initCalDavTimepicker($('#todo_details_template .alert_message_dateTODO[data-id="'+data_id+'"]'));
  2720. /*************************** BAD HACKS SECTION ***************************/
  2721. // here we fix the cross OS/cross broser problems (unfixable in pure CSS)
  2722. if($.browser.webkit && !!window.chrome) /* Chrome */
  2723. {
  2724. if(navigator.platform.toLowerCase().indexOf('win')==0) /* Windows version */
  2725. {
  2726. $('#todo_details_template').find('input').css('text-indent', '2px');
  2727. $('#todo_details_template').find('select').css({'padding-left': '0px', 'padding-right': '13px'});
  2728. }
  2729. else /* non-Windows version */
  2730. $('#todo_details_template').find('input').css('text-indent', '1px');
  2731. }
  2732. else if($.browser.safari)
  2733. {
  2734. $('#todo_details_template').find('textarea').addClass('safari_hack');
  2735. $('#todo_details_template').find('input').addClass('safari_hack');
  2736. }
  2737. else if($.browser.msie) /* IE */
  2738. {
  2739. if(parseInt($.browser.version, 10)==10) /* IE 10 (because there are no more conditional comments) */
  2740. {
  2741. $('#todo_details_template').find('select').css({'padding-top': '1px', 'padding-left': '0px', 'padding-right': '0px'});
  2742. $('#todo_details_template').find('textarea').css('padding-top', '3px');
  2743. $('#todo_details_template').find('input[type=button]').css('padding-top', '2px');
  2744. }
  2745. }
  2746. /* IE or FF */
  2747. if($.browser.msie || $.browser.mozilla)
  2748. {
  2749. // ADD empty SVG to interface (we will replace it later)
  2750. $('<svg data-type="select_icon"></svg>').css('display', 'none').insertAfter($('#todo_details_template tr[data-id="'+data_id+'"]').find('select'));
  2751. }
  2752. if($.browser.msie || $.browser.mozilla)
  2753. {
  2754. var newSVG=$(SVG_select).attr('data-type', 'select_icon').css({'pointer-events': 'none', 'z-index': '1', 'display': 'inline', 'margin-left': '-19px', 'vertical-align': 'top', 'background-color': '#ffffff'}); // background-color = stupid IE9 bug
  2755. $('#todo_details_template tr[data-id="'+data_id+'"]').find('svg[data-type="select_icon"]').replaceWith($('<div>').append($(newSVG).clone()).html());
  2756. }
  2757. /*************************** END OF BAD HACKS SECTION ***************************/
  2758. }
  2759. function event_alert_add(data_id)
  2760. {
  2761. data_id++;
  2762. var newTr1,
  2763. newTr2,
  2764. newTr3;
  2765. newTr1='<tr data-id="'+data_id+'">'+
  2766. '<td><label data-type="alert" for="alert">alert: </label></td>'+
  2767. '<td data-size="full" colspan="2">'+
  2768. '<select class="long alert" name="alert_type" data-id="'+data_id+'">'+
  2769. '<option data-type="alert_none" value="none">none</option>'+
  2770. '<option data-type="alert_message" value="message">message</option>'+
  2771. '</select>'+
  2772. '</td>'+
  2773. '</tr>';
  2774. newTr2='<tr data-id="'+data_id+'" class="alert_details" style="display:none;">'+
  2775. '<td></td>'+
  2776. '<td data-size="full" colspan="2">'+
  2777. '<select class="long alert_message_details" name="alert_details" data-id="'+data_id+'">'+
  2778. '<option data-type="on_date" value="on_date">On date</option>'+
  2779. ($('#allday').prop('checked') ? '' : '<option data-type="weeks_before" value="weeks_before">weeks before</option>'+
  2780. '<option data-type="days_before" value="days_before">days before</option>'+
  2781. '<option data-type="hours_before" value="hours_before">hours before</option>'+
  2782. '<option data-type="minutes_before" value="minutes_before">minutes before</option>'+
  2783. '<option data-type="seconds_before" value="seconds_before">seconds before</option>'+
  2784. '<option data-type="weeks_after" value="weeks_after">weeks after</option>'+
  2785. '<option data-type="days_after" value="days_after">days after</option>'+
  2786. '<option data-type="hours_after" value="hours_after">hours after</option>'+
  2787. '<option data-type="minutes_after" value="minutes_after">minutes after</option>'+
  2788. '<option data-type="seconds_after" value="seconds_after">seconds after</option>')
  2789. +
  2790. '</select>'+
  2791. '</td>'+
  2792. '</tr>';
  2793. newTr3='<tr data-id="'+data_id+'" class="alert_message_date" style="display:none;">'+
  2794. '<td></td>'+
  2795. '<td><input class="small before_after_input" data-type="PH_before_after_alert" type="text" data-id="'+data_id+'" style="display:none;" />'+
  2796. '<input class="date small message_date_input" data-type="PH_alarm_date" type="text" data-id="'+data_id+'" /><div class="invalidWrapper"><img data-type="invalidSmall" data-id="'+data_id+'" style="display: none;" src="images/error_b.svg" alt="invalid" /></div></td>'+
  2797. '<td><input class="time small message_time_input" data-type="PH_alarm_time" type="text" data-id="'+data_id+'" /><div class="invalidWrapper"><img data-type="invalidSmall" data-id="'+data_id+'" style="display: none;" src="images/error_b.svg" alt="invalid" /></div></td>'+
  2798. '<tr>';
  2799. $('#url_tr').before(newTr1);
  2800. $('#url_tr').before(newTr2);
  2801. $('#url_tr').before(newTr3);
  2802. translateEventAlerts();
  2803. $('#event_details_template').find('input[placeholder],textarea[placeholder]').placeholder();
  2804. $('#event_details_template .before_after_input[data-id="'+data_id+'"]').bind('keyup change', function(){
  2805. if($(this).val()=='')
  2806. {
  2807. $(this).parent().find('img').css('display', 'inline');
  2808. //$(this).parent().find('img').css('visibility','visible');
  2809. }
  2810. else
  2811. {
  2812. if($(this).val().match("^(\d*[0-9])*$")==null)
  2813. {
  2814. $(this).parent().find('img').css('display', 'inline');
  2815. //$(this).parent().find('img').css('visibility','visible');
  2816. }
  2817. else
  2818. $(this).parent().find('img').css('display', 'none');
  2819. }
  2820. });
  2821. $('#event_details_template .alert[data-id="'+data_id+'"]').change(function(){
  2822. var data_id=$(this).attr("data-id");
  2823. if($(this).val()!='none')
  2824. {
  2825. $('.alert_details[data-id="'+data_id+'"]').show();
  2826. $('.alert_message_date[data-id="'+data_id+'"]').show();
  2827. if(!$('#allday').prop('checked'))
  2828. expandEventAlerts();
  2829. var myDate=new Date();
  2830. myDate.setDate(myDate.getDate()+7);
  2831. if($('#date_from').parent().parent().find('img:visible').length==0) {
  2832. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_from").val());
  2833. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  2834. myDate=new Date(Date.parse(datetime_to + (!$("#allday").prop('checked')?$("#time_from").val():'')));
  2835. myDate.setHours(myDate.getHours()-1);
  2836. }
  2837. else if($('#date_to').parent().parent().find('img:visible').length==0) {
  2838. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_to").val());
  2839. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  2840. myDate=new Date(Date.parse(datetime_to + (!$("#allday").prop('checked')?$("#time_to").val():'')));
  2841. myDate.setHours(myDate.getHours()-1);
  2842. }
  2843. $('.message_date_input[data-id="'+data_id+'"]').val($.datepicker.formatDate(globalSettings.datepickerformat.value, myDate));
  2844. $('.message_time_input[data-id="'+data_id+'"]').val($.fullCalendar.formatDate(myDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  2845. event_alert_add(data_id);
  2846. }
  2847. else
  2848. {
  2849. $('.alert_details[data-id="'+data_id+'"]').hide();
  2850. $('.alert_message_date[data-id="'+data_id+'"]').hide();
  2851. checkFor(data_id);
  2852. var data_id=$(this).attr("data-id");
  2853. $('#event_details_template tr[data-id="'+data_id+'"]').remove();
  2854. }
  2855. checkEventFormScrollBar();
  2856. });
  2857. $('#event_details_template .alert_message_details[data-id="'+data_id+'"]').change(function(){
  2858. var data_id=$(this).attr("data-id");
  2859. $('.before_after_input[data-id="'+data_id+'"]').parent().parent().find('img').css('display','none');
  2860. if($('.alert_message_details[data-id="'+data_id+'"] option:selected').attr('data-type')=="on_date")
  2861. {
  2862. var myDate=new Date();
  2863. myDate.setDate(myDate.getDate()+7);
  2864. if($('#date_from').parent().parent().find('img:visible').length==0) {
  2865. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_from").val());
  2866. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  2867. myDate=new Date(Date.parse(datetime_to + (!$("#allday").prop('checked')?$("#time_from").val():'')));
  2868. myDate.setHours(myDate.getHours()-1);
  2869. }
  2870. else if($('#date_to').parent().parent().find('img:visible').length==0) {
  2871. var dateTo=$.datepicker.parseDate(globalSettings.datepickerformat.value,$("#date_to").val());
  2872. var datetime_to=$.fullCalendar.formatDate(dateTo, 'MM/dd/yyyy, ');
  2873. myDate=new Date(Date.parse(datetime_to + (!$("#allday").prop('checked')?$("#time_to").val():'')));
  2874. myDate.setHours(myDate.getHours()-1);
  2875. }
  2876. $('.message_date_input[data-id="'+data_id+'"]').val($.datepicker.formatDate(globalSettings.datepickerformat.value, myDate));
  2877. $('.message_date_input[data-id="'+data_id+'"]').show();
  2878. $('.message_time_input[data-id="'+data_id+'"]').val($.fullCalendar.formatDate(myDate, (globalSettings.ampmformat.value ? 'hh:mm TT' : 'HH:mm')));
  2879. $('.message_time_input[data-id="'+data_id+'"]').show();
  2880. $('.before_after_input[data-id="'+data_id+'"]').hide();
  2881. }
  2882. else
  2883. {
  2884. $('.message_date_input[data-id="'+data_id+'"]').hide();
  2885. $('.message_time_input[data-id="'+data_id+'"]').hide();
  2886. $('.before_after_input[data-id="'+data_id+'"]').show();
  2887. $('.before_after_input[data-id="'+data_id+'"]').val('15');
  2888. }
  2889. });
  2890. initCalDavDatepicker($('#event_details_template .alert_message_date[data-id="'+data_id+'"]'));
  2891. initCalDavTimepicker($('#event_details_template .alert_message_date[data-id="'+data_id+'"]'));
  2892. /*************************** BAD HACKS SECTION ***************************/
  2893. // here we fix the cross OS/cross broser problems (unfixable in pure CSS)
  2894. if($.browser.webkit && !!window.chrome) /* Chrome */
  2895. {
  2896. if(navigator.platform.toLowerCase().indexOf('win')==0) /* Windows version */
  2897. {
  2898. $('#event_details_template').find('input').css('text-indent', '2px');
  2899. $('#event_details_template').find('select').css({'padding-left': '0px', 'padding-right': '13px'});
  2900. }
  2901. else /* non-Windows version */
  2902. $('#event_details_template').find('input').css('text-indent', '1px');
  2903. }
  2904. else if($.browser.safari)
  2905. {
  2906. $('#event_details_template').find('textarea').addClass('safari_hack');
  2907. $('#event_details_template').find('input').addClass('safari_hack');
  2908. }
  2909. else if($.browser.msie) /* IE */
  2910. {
  2911. if(parseInt($.browser.version, 10)==10) /* IE 10 (because there are no more conditional comments) */
  2912. {
  2913. $('#event_details_template').find('select').css({'padding-top': '1px', 'padding-left': '0px', 'padding-right': '0px'});
  2914. $('#event_details_template').find('textarea').css('padding-top', '3px');
  2915. $('#event_details_template').find('input[type=button]').css('padding-top', '2px');
  2916. }
  2917. }
  2918. /* IE or FF */
  2919. if($.browser.msie || $.browser.mozilla)
  2920. {
  2921. // ADD empty SVG to interface (we will replace it later)
  2922. $('<svg data-type="select_icon"></svg>').css('display', 'none').insertAfter($('#event_details_template tr[data-id="'+data_id+'"]').find('select'));
  2923. }
  2924. if($.browser.msie || $.browser.mozilla)
  2925. {
  2926. var newSVG=$(SVG_select).attr('data-type', 'select_icon').css({'pointer-events': 'none', 'z-index': '1', 'display': 'inline', 'margin-left': '-19px', 'vertical-align': 'top', 'background-color': '#ffffff'}); // background-color = stupid IE9 bug
  2927. $('#event_details_template tr[data-id="'+data_id+'"]').find('svg[data-type="select_icon"]').replaceWith($('<div>').append($(newSVG).clone()).html());
  2928. }
  2929. /*************************** END OF BAD HACKS SECTION ***************************/
  2930. }
  2931. function stripEventAlerts()
  2932. {
  2933. $('.alert_message_details').each(function(){
  2934. if($(this).val()=='on_date')
  2935. $(this).find('option').not(':selected').remove();
  2936. else
  2937. {
  2938. var dataID=$(this).parent().parent().attr('data-id');
  2939. $('#event_details_template').find('tr[data-id="'+dataID+'"]').remove();
  2940. }
  2941. });
  2942. }
  2943. function expandEventAlerts()
  2944. {
  2945. $('.alert_message_details').each(function(){
  2946. var value=$(this).val();
  2947. $(this).html('<option data-type="on_date" value="on_date">on date</option>'+
  2948. '<option data-type="weeks_before" value="weeks_before">weeks before</option>'+
  2949. '<option data-type="days_before" value="days_before">days before</option>'+
  2950. '<option data-type="hours_before" value="hours_before">hours before</option>'+
  2951. '<option data-type="minutes_before" value="minutes_before">minutes before</option>'+
  2952. '<option data-type="seconds_before" value="seconds_before">seconds before</option>'+
  2953. '<option data-type="weeks_after" value="weeks_after">weeks after</option>'+
  2954. '<option data-type="days_after" value="days_after">days after</option>'+
  2955. '<option data-type="hours_after" value="hours_after">hours after</option>'+
  2956. '<option data-type="minutes_after" value="minutes_after">minutes after</option>'+
  2957. '<option data-type="seconds_after" value="seconds_after">seconds after</option>');
  2958. $(this).val(value);
  2959. });
  2960. translateEventAlerts();
  2961. }
  2962. function stripTodoAlerts()
  2963. {
  2964. $('.alert_message_detailsTODO').each(function(){
  2965. if($(this).val()=='on_date')
  2966. $(this).find('option').not(':selected').remove();
  2967. else
  2968. {
  2969. var dataID=$(this).parent().parent().attr('data-id');
  2970. $('#todo_details_template').find('tr[data-id="'+dataID+'"]').remove();
  2971. }
  2972. });
  2973. }
  2974. function expandTodoAlerts()
  2975. {
  2976. $('.alert_message_detailsTODO').each(function(){
  2977. var value=$(this).val();
  2978. $(this).html('<option data-type="on_dateTODO" value="on_date">On date</option>'+
  2979. '<option data-type="weeks_beforeTODO" value="weeks_before">weeks before</option>'+
  2980. '<option data-type="days_beforeTODO" value="days_before">days before</option>'+
  2981. '<option data-type="hours_beforeTODO" value="hours_before">hours before</option>'+
  2982. '<option data-type="minutes_beforeTODO" value="minutes_before">minutes before</option>'+
  2983. '<option data-type="seconds_beforeTODO" value="seconds_before">seconds before</option>'+
  2984. '<option data-type="weeks_afterTODO" value="weeks_after">weeks after</option>'+
  2985. '<option data-type="days_afterTODO" value="days_after">days after</option>'+
  2986. '<option data-type="hours_afterTODO" value="hours_after">hours after</option>'+
  2987. '<option data-type="minutes_afterTODO" value="minutes_after">minutes after</option>'+
  2988. '<option data-type="seconds_afterTODO" value="seconds_after">seconds after</option>');
  2989. $(this).val(value);
  2990. });
  2991. translateTodoAlerts();
  2992. }