Merge branch 'Jagadees-zyxware-master'
[com.zyxware.civiwci.git] / templates / CRM / Wci / Form / CreateWidget.tpl
1 {* HEADER *}
2
3 <div class="crm-submit-buttons">
4 {include file="CRM/common/formButtons.tpl" location="top"}
5 </div>
6
7 {* FIELD EXAMPLE: OPTION 1 (AUTOMATIC LAYOUT) *}
8
9 {foreach from=$elementNames item=elementName}
10 <div class="crm-section">
11 <div class="label">{$form.$elementName.label}</div>
12 <div class="content">{$form.$elementName.html}</div>
13 <div class="clear"></div>
14 </div>
15 {/foreach}
16
17 {if $form.title.value != ""}
18 {php}
19 if(isset($_REQUEST['id'])) {
20 $wid_id = $_REQUEST['id'];
21 $data = CRM_Wci_BAO_Widget::getWidgetData($wid_id);
22 $template = CRM_Core_Smarty::singleton();
23 $template->assign('wciform', $data);
24 if($data["override"] == 0) {
25 $template->template_dir[] = getWciWidgetTemplatePath();
26 $wcidata = $template->fetch('wciwidget.tpl');
27 } else {
28 $wcidata = $template->fetch('string:' . base64_decode($wid_page[$dao->id]['custom_template']));
29 }
30 $widget_controller_path = getWciWidgetControllerPath();
31 }
32 {/php}
33
34 <div class="crm-section">
35 <div class="label">
36 <label for="embd_code">Code to embed:</label>
37 </div>
38 <div class="content">
39 <div class="resizable-textarea">
40 <span>{literal}
41 <textarea rows="5" name="embd_code" id="embd_code" class="form-textarea textarea-processed">
42 <script type="text/javascript" src="{/literal}{php}echo $widget_controller_path;{/php}{literal}?widgetId={/literal}{php}echo $wid_id;{/php}{literal}&embed=1"></script>
43 <script type="text/javascript">
44 // Cleanup functions for the document ready method
45 if ( document.addEventListener ) {
46 DOMContentLoaded = function() {
47 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
48 onReady();
49 };
50 } else if ( document.attachEvent ) {
51 DOMContentLoaded = function() {
52 // Make sure body exists, at least, in case IE gets a little overzealous
53 if ( document.readyState === "complete" ) {
54 document.detachEvent( "onreadystatechange", DOMContentLoaded );
55 onReady();
56 }
57 };
58 }
59 if ( document.readyState === "complete" ) {
60 // Handle it asynchronously to allow scripts the opportunity to delay ready
61 setTimeout( onReady, 1 );
62 }
63
64 // Mozilla, Opera and webkit support this event
65 if ( document.addEventListener ) {
66 // Use the handy event callback
67 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
68 // A fallback to window.onload, that will always work
69 window.addEventListener( "load", onReady, false );
70 // If IE event model is used
71 } else if ( document.attachEvent ) {
72 // ensure firing before onload,
73 // maybe late but safe also for iframes
74 document.attachEvent("onreadystatechange", DOMContentLoaded);
75
76 // A fallback to window.onload, that will always work
77 window.attachEvent( "onload", onReady );
78 }
79
80 function onReady( ) {
81 document.getElementById('widgetwci').innerHTML = wciwidgetcode;
82 }
83 </script>
84 <div id='widgetwci'></div></textarea>{/literal}
85 <div class="grippie" style="margin-right: 18px;"></div>
86 </span>
87 </div>
88 </div>
89 <div class="clear"></div>
90 </div>
91 <div class="crm-section">
92 <div class="content">
93 {* {include file="CRM/Wci/Page/wciwidget.tpl"} *}
94
95 <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
96 <script type="text/javascript" src="{php}echo $widget_controller_path;{/php}?widgetId={php}echo $wid_id;{/php}&embed=0"></script>
97 <script>
98 $( document ).ready(function() {ldelim}
99 $('#widgetwci').html(wciwidgetcode);
100 {rdelim} );
101 </script>
102 <div id='widgetwci'></div>
103
104 </div>
105 </div>
106 {/if}
107
108 {* FIELD EXAMPLE: OPTION 2 (MANUAL LAYOUT)
109
110 <div>
111 <span>{$form.favorite_color.label}</span>
112 <span>{$form.favorite_color.html}</span>
113 </div>
114
115 {* FOOTER *}
116
117 <div class="crm-submit-buttons">
118 {include file="CRM/common/formButtons.tpl" location="bottom"}
119 </div>
120