From 68864a0683c2cf748dae8ef43f5342a11ed9125b Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 24 Feb 2014 09:48:22 +0000 Subject: [PATCH] Remove another inline-script in calendar dayView which was causing CSP violation --- calendar/inc/class.calendar_ui.inc.php | 4 ++-- calendar/js/app.js | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/calendar/inc/class.calendar_ui.inc.php b/calendar/inc/class.calendar_ui.inc.php index 714f93f5fe..86f3a3ef6c 100644 --- a/calendar/inc/class.calendar_ui.inc.php +++ b/calendar/inc/class.calendar_ui.inc.php @@ -545,8 +545,8 @@ class calendar_ui $vars['hour'] = $hour; $vars['minute'] = $minute; } - return html::a_href($content,'/index.php',$vars,' target="_blank" title="'.html::htmlspecialchars(lang('Add')). - '" onclick="'.$this->popup('this.href','this.target').'; return false;"'); + return html::a_href($content,'',$vars,' data-date="' .$vars['date'].'|'.$vars['hour'].'|'.$vars['minute'] + . '" title="'.html::htmlspecialchars(lang('Add')).'"'); } /** diff --git a/calendar/js/app.js b/calendar/js/app.js index 1705d0e18d..657f4f3dcb 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -410,14 +410,17 @@ app.classes.calendar = AppJS.extend( }) //Click event handler for calendar cells - .on("click","div.calendar_calAddEvent",function(ev){ + .on("click","div.calendar_calAddEvent, div.calendar_calTimeRowTime",function(ev){ var timestamp = ev.target.getAttribute('data-date').split("|"); - var owner = ev.target.getAttribute('id').split("_"); - - var ownerId = owner[2].match( /Ogroup/g)?owner[2].replace( /Ogroup/g, '-'):owner[2].replace( /^\D+/g, ''); - if (owner[2].match( /Or/g)) + if (typeof ev.target.getAttribute('id') != 'undefined' && ev.target.getAttribute('id')) { - ownerId = 'r' + ownerId; + var owner = ev.target.getAttribute('id').split("_"); + + var ownerId = owner[2].match( /Ogroup/g)?owner[2].replace( /Ogroup/g, '-'):owner[2].replace( /^\D+/g, ''); + if (owner[2].match( /Or/g)) + { + ownerId = 'r' + ownerId; + } } var eventInfo = @@ -427,7 +430,7 @@ app.classes.calendar = AppJS.extend( minute: timestamp[2] }; - if (ownerId != 0) + if (typeof ownerId !='undefined' && ownerId != 0) { $j(eventInfo).extend(eventInfo,{owner: ownerId}); }