review moved js code to seletate file
authorJagadedes <jagadees.pillai@zyxware.com>
Thu, 23 Oct 2014 09:56:50 +0000 (15:26 +0530)
committerJagadedes <jagadees.pillai@zyxware.com>
Thu, 23 Oct 2014 09:56:50 +0000 (15:26 +0530)
CRM/Wci/Form/CreateWidget.php
createwidget.js [new file with mode: 0644]

index 5e935c8160074bfc081236380c6bec78332f8c7b..cdb62d82b20b53f9986ec24f39d2baf9f76366d0 100644 (file)
@@ -3,30 +3,7 @@
 require_once 'CRM/Core/Form.php';
 require_once 'wci-helper-functions.php';
 require_once 'CRM/Wci/BAO/ProgressBar.php';
-?>
 
-<script type="text/javascript">
-cj(function ( $ ) {
-  function setState() {
-    if ($('#override').is(':checked') == true) {
-      $('#custom_template').attr("disabled",false);
-    }
-    else {
-      $('#custom_template').attr("disabled",true);
-    }
-    if( $('#title').val() != "") {
-      $('#embd_code').parents('.crm-section').show();    
-    } else {
-      $('#embd_code').parents('.crm-section').hide();
-    }
-  }
-  $(document).ready(setState)
-  $('#override').click(setState);
-
-});
-</script>
-
-<?php
 /**
  * Form controller class
  *
@@ -43,6 +20,7 @@ class CRM_Wci_Form_CreateWidget extends CRM_Core_Form {
   protected $_id;
   
   function preProcess() {
+    CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.wci', 'createwidget.js');
     parent::preProcess();
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, 
           FALSE, NULL, 'REQUEST' );
diff --git a/createwidget.js b/createwidget.js
new file mode 100644 (file)
index 0000000..9519b1f
--- /dev/null
@@ -0,0 +1,20 @@
+// 
+cj(function ( $ ) {
+  function setState() {
+    if ($('#override').is(':checked') == true) {
+      $('#custom_template').attr("disabled",false);
+    }
+    else {
+      $('#custom_template').attr("disabled",true);
+    }
+    if( $('#title').val() != "") {
+      $('#embd_code').parents('.crm-section').show();    
+    } else {
+      $('#embd_code').parents('.crm-section').hide();
+    }
+  }
+  $(document).ready(setState)
+  $('#override').click(setState);
+
+});
+