#29801 - Fixed title encoding bug and made long js in embed as including file.
[com.zyxware.civiwci.git] / templates / CRM / Wci / Form / CreateWidget.tpl
index 350ef9a67db859749a759298247dc634b2a45572..5737d69a569af96693d9444a552f28d0106b7f24 100644 (file)
@@ -14,6 +14,7 @@
   </div>
 {/foreach}
 
+{* {if $form.title.value != ""} *}
   {php} 
     if(isset($_REQUEST['id'])) {
       $wid_id = $_REQUEST['id'];
@@ -27,6 +28,7 @@
         $wcidata = $template->fetch('string:' . base64_decode($wid_page[$dao->id]['custom_template']));
       }
       $widget_controller_path = getWciWidgetControllerPath();
+      $extension_root_path = getExtensionRootPath();
     }
   {/php}
 
     <div class="content">
       <div class="resizable-textarea">
         <span>{literal}
-          <textarea name="embd_code" id="embd_code" class="form-textarea textarea-processed">
-<script type="text/javascript" src="{/literal}{php}echo $widget_controller_path;{/php}{literal}?widgetId={/literal}{php}echo $wid_id;{/php}{literal}"></script>
-<script type="text/javascript">
-// Cleanup functions for the document ready method
-if ( document.addEventListener ) {
-    DOMContentLoaded = function() {
-        document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
-        onReady();
-    };
-} else if ( document.attachEvent ) {
-    DOMContentLoaded = function() {
-        // Make sure body exists, at least, in case IE gets a little overzealous
-        if ( document.readyState === "complete" ) {
-            document.detachEvent( "onreadystatechange", DOMContentLoaded );
-            onReady();
-        }
-    };
-}
-if ( document.readyState === "complete" ) {
-    // Handle it asynchronously to allow scripts the opportunity to delay ready
-    setTimeout( onReady, 1 );
-}
-
-// Mozilla, Opera and webkit support this event
-if ( document.addEventListener ) {
-    // Use the handy event callback
-    document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
-    // A fallback to window.onload, that will always work
-    window.addEventListener( "load", onReady, false );
-    // If IE event model is used
-} else if ( document.attachEvent ) {
-    // ensure firing before onload,
-    // maybe late but safe also for iframes
-    document.attachEvent("onreadystatechange", DOMContentLoaded);
-
-    // A fallback to window.onload, that will always work
-    window.attachEvent( "onload", onReady );
-}
-
-function onReady( ) {
-  document.getElementById('widgetwci').innerHTML = wciwidgetcode;
-}
-</script>
+          <textarea rows="5" name="embd_code" id="embd_code" class="form-textarea textarea-processed">
+<script type="text/javascript" src="{/literal}{php}echo $widget_controller_path;{/php}{literal}?widgetId={/literal}{php}echo $wid_id;{/php}{literal}&embed=1"></script>
+<script type="text/javascript" src="{/literal}{php}echo $extension_root_path;{/php}{literal}/extern/wciembed.js"></script>
 <div id='widgetwci'></div></textarea>{/literal}
           <div class="grippie" style="margin-right: 18px;"></div>
         </span>
@@ -91,17 +53,13 @@ function onReady( ) {
     <div class="content">
    {* {include file="CRM/Wci/Page/wciwidget.tpl"} *}
 
-<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
-<script type="text/javascript" src="{php}echo $widget_controller_path;{/php}?widgetId={php}echo $wid_id;{/php}"></script>
-<script>
-  $( document ).ready(function()  {ldelim} 
-    $('#widgetwci').html(wciwidgetcode);
-   {rdelim} );
-</script>
+<script type="text/javascript" src="{php}echo $widget_controller_path;{/php}?widgetId={php}echo $wid_id;{/php}&embed=0"></script>
+<script type="text/javascript" src="{/literal}{php}echo $extension_root_path;{/php}{literal}/extern/wciembed.js"></script>
 <div id='widgetwci'></div>
 
     </div>
   </div>
+{* {/if} *}
 
 {* FIELD EXAMPLE: OPTION 2 (MANUAL LAYOUT)