]> git.mxchange.org Git - friendica.git/commitdiff
port of red's event editing preview
authorrabuzarus <>
Thu, 14 May 2015 11:20:58 +0000 (13:20 +0200)
committerrabuzarus <>
Thu, 14 May 2015 11:20:58 +0000 (13:20 +0200)
mod/events.php
view/templates/event_form.tpl
view/templates/event_head.tpl

index 94e2ba6b40b597fde1f8a4e99d0d13406972009c..eef9303c0bb8a44a147ef630eb52dc8d11de5859 100755 (executable)
@@ -7,6 +7,8 @@ require_once('include/items.php');
 
 function events_post(&$a) {
 
+        logger('post: ' . print_r($_REQUEST,true));
+        
        if(! local_user())
                return;
 
@@ -64,6 +66,10 @@ function events_post(&$a) {
 
        if((! $summary) || (! $start)) {
                notice( t('Event title and start time are required.') . EOL);
+                if(intval($_REQUEST['preview'])) {
+                       echo( t('Event title and start time are required.'));
+                       killme();
+               }
                goaway($a->get_baseurl() . '/events/new');
        }
 
@@ -124,6 +130,12 @@ function events_post(&$a) {
        $datarray['id'] = $event_id;
        $datarray['created'] = $created;
        $datarray['edited'] = $edited;
+        
+       if(intval($_REQUEST['preview'])) {
+               $html = format_event_html($datarray);
+               echo $html;
+                               killme();
+       }
 
        $item_id = event_store($datarray);
 
@@ -474,6 +486,7 @@ function events_content(&$a) {
                        '$t_orig' => $t_orig,
                        '$sh_text' => t('Share this event'),
                        '$sh_checked' => $sh_checked,
+                        '$preview' => t('Preview'),
                        '$acl' => (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user),false)),
                        '$submit' => t('Submit')
 
index 45e2ea71e096ea996ca5272278d0e1c25f3cc0a7..9633d19af1377f467f48ea329041d84c18bf815b 100644 (file)
@@ -5,11 +5,12 @@
 {{$desc}}
 </p>
 
-<form action="{{$post}}" method="post" >
+<form id="event-edit-form" action="{{$post}}" method="post" >
 
 <input type="hidden" name="event_id" value="{{$eid}}" />
 <input type="hidden" name="cid" value="{{$cid}}" />
 <input type="hidden" name="uri" value="{{$uri}}" />
+<input type="hidden" name="preview" id="event-edit-preview" value="0" />
 
 <div id="event-start-text">{{$s_text}}</div>
 {{$s_dsel}} {{$s_tsel}}
 <div id="event-location-text">{{$l_text}}</div>
 <textarea id="event-location-textarea" name="location">{{$l_orig}}</textarea>
 
+<div id="event-location-break"></div>
+
 <input type="checkbox" name="share" value="1" id="event-share-checkbox" {{$sh_checked}} /> <div id="event-share-text">{{$sh_text}}</div>
 <div id="event-share-break"></div>
 
 {{$acl}}
 
 <div class="clear"></div>
+<input id="event-edit-preview" type="submit" name="preview" value="{{$preview|escape:'html'}}" onclick="doEventPreview(); return false;" />
 <input id="event-submit" type="submit" name="submit" value="{{$submit|escape:'html'}}" />
 </form>
 
index 8085a774b3fbdef72a4b0460e0ee47f11173ef12..31f389d9e36ab79ec478fa14fd27191dafeb836e 100644 (file)
                        }
                );                      
        }
+        
+        function doEventPreview() {
+        $('#event-edit-preview').val(1);
+        $.post('events',$('#event-edit-form').serialize(), function(data) {
+                $.colorbox({ html: data });
+        });
+        $('#event-edit-preview').val(0);
+       }
+
        
        $(document).ready(function() {
                $('#events-calendar').fullCalendar({
@@ -75,6 +84,7 @@
 </script>
 
 
+{{if $editselect != 'none'}}
 <script language="javascript" type="text/javascript"
           src="{{$baseurl}}/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script>
 <script language="javascript" type="text/javascript">
                }
 
        });
+        {{else}}
+       <script language="javascript" type="text/javascript">
+       {{/if}}
 
 
        $(document).ready(function() {