From 8707432aa9412e365e41b027cbe0d945e66ea3af Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 9 Jan 2014 22:13:57 -0800 Subject: [PATCH] CRM-14065 - Activity Form - Consolodate misplaced/duplicate js code --- js/Common.js | 52 --------- templates/CRM/Activity/Form/Activity.tpl | 45 +------- templates/CRM/Activity/Form/ActivityJs.tpl | 123 +++++++++++++++++++++ templates/CRM/Case/Form/Activity.tpl | 45 +------- 4 files changed, 125 insertions(+), 140 deletions(-) create mode 100644 templates/CRM/Activity/Form/ActivityJs.tpl diff --git a/js/Common.js b/js/Common.js index e5d14fef7f..d0108f6ac1 100644 --- a/js/Common.js +++ b/js/Common.js @@ -447,58 +447,6 @@ function showHideRow(index) { return false; } -/** - * Function to check activity status in relavent to activity date - * - * @param element message JSON object. - */ -function activityStatus(message) { - var d = new Date(), time = [], i; - var currentDateTime = d.getTime() - var activityTime = cj("input#activity_date_time_time").val().replace(":", ""); - - //chunk the time in bunch of 2 (hours,minutes,ampm) - for (i = 0; i < activityTime.length; i += 2) { - time.push(activityTime.slice(i, i + 2)); - } - var activityDate = new Date(cj("input#activity_date_time_hidden").val()); - - d.setFullYear(activityDate.getFullYear()); - d.setMonth(activityDate.getMonth()); - d.setDate(activityDate.getDate()); - var hours = time['0']; - var ampm = time['2']; - - if (ampm == "PM" && hours != 0 && hours != 12) { - // force arithmetic instead of string concatenation - hours = hours * 1 + 12; - } - else { - if (ampm == "AM" && hours == 12) { - hours = 0; - } - } - d.setHours(hours); - d.setMinutes(time['1']); - - var activity_date_time = d.getTime(); - - var activityStatusId = cj('#status_id').val(); - - if (activityStatusId == 2 && currentDateTime < activity_date_time) { - if (!confirm(message.completed)) { - return false; - } - } - else { - if (activity_date_time && activityStatusId == 1 && currentDateTime >= activity_date_time) { - if (!confirm(message.scheduled)) { - return false; - } - } - } -} - CRM.strings = CRM.strings || {}; CRM.validate = CRM.validate || { params: {}, diff --git a/templates/CRM/Activity/Form/Activity.tpl b/templates/CRM/Activity/Form/Activity.tpl index 74963be3b5..73a9f945ba 100644 --- a/templates/CRM/Activity/Form/Activity.tpl +++ b/templates/CRM/Activity/Form/Activity.tpl @@ -39,50 +39,7 @@
{/if} {* added onload javascript for source contact*} - {literal} - - - {/literal} + {include file="CRM/Activity/Form/ActivityJs.tpl" tokenContext="activity"} {if !$action or ( $action eq 1 ) or ( $action eq 2 ) }
{include file="CRM/common/formButtons.tpl" location="top"}
{/if} diff --git a/templates/CRM/Activity/Form/ActivityJs.tpl b/templates/CRM/Activity/Form/ActivityJs.tpl new file mode 100644 index 0000000000..d47b6cc4b2 --- /dev/null +++ b/templates/CRM/Activity/Form/ActivityJs.tpl @@ -0,0 +1,123 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.4 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2013 | + +--------------------------------------------------------------------+ + | This file is a part of CiviCRM. | + | | + | CiviCRM is free software; you can copy, modify, and distribute it | + | under the terms of the GNU Affero General Public License | + | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | + | | + | CiviCRM is distributed in the hope that it will be useful, but | + | WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | See the GNU Affero General Public License for more details. | + | | + | You should have received a copy of the GNU Affero General Public | + | License and the CiviCRM Licensing Exception along | + | with this program; if not, contact CiviCRM LLC | + | at info[AT]civicrm[DOT]org. If you have questions about the | + | GNU Affero General Public License or the licensing of CiviCRM, | + | see the CiviCRM license FAQ at http://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} +{* added onload javascript for source contact*} +{literal} + +{/literal} diff --git a/templates/CRM/Case/Form/Activity.tpl b/templates/CRM/Case/Form/Activity.tpl index e7077cec99..3a0220d228 100644 --- a/templates/CRM/Case/Form/Activity.tpl +++ b/templates/CRM/Case/Form/Activity.tpl @@ -41,50 +41,7 @@
{include file="CRM/common/formButtons.tpl" location="top"}
{* added onload javascript for source contact*} - {literal} - - {/literal} + {include file="CRM/Activity/Form/ActivityJs.tpl" tokenContext="case_activity"} {/if} -- 2.25.1