]> git.mxchange.org Git - friendica.git/commitdiff
comment preview
authorfriendica <info@friendica.com>
Fri, 6 Jan 2012 00:38:24 +0000 (16:38 -0800)
committerfriendica <info@friendica.com>
Fri, 6 Jan 2012 00:38:24 +0000 (16:38 -0800)
include/conversation.php
js/main.js
mod/item.php
mod/photos.php
view/comment_item.tpl

index ec1fd4152cd1c5818c84339fd17a561c58e590fe..d4d6a55694a94da82bc00f0d7daf6538879b1c57 100644 (file)
@@ -129,7 +129,7 @@ function localize_item(&$item){
  * that are based on unique features of the calling module.
  *
  */
-function conversation(&$a, $items, $mode, $update) {
+function conversation(&$a, $items, $mode, $update, $preview = false) {
 
        require_once('bbcode.php');
 
@@ -287,7 +287,7 @@ function conversation(&$a, $items, $mode, $update) {
                                        '$like' => '',
                                        '$dislike' => '',
                                        '$comment' => '',
-                                       '$conv' => array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context')),
+                                       '$conv' => (($preview) ? '' : array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))),
                                        '$wait' => t('Please wait'),
                                ));
 
@@ -483,6 +483,7 @@ function conversation(&$a, $items, $mode, $update) {
                                                        '$myphoto' => $a->contact['thumb'],
                                                        '$comment' => t('Comment'),
                                                        '$submit' => t('Submit'),
+                                                       '$preview' => t('Preview'),
                                                        '$ww' => (($mode === 'network') ? $commentww : '')
                                                ));
                                        }
index 96c7fa642b3d29779d7e7036ae2a6896bd80ac06..009fb55bbbf11fcff4b173fff478e4b1a8d9ef5d 100644 (file)
                unpause();
                commentBusy = true;
                $('body').css('cursor', 'wait');
+               $("#comment-preview-inp-" + id).val("0");
                $.post(  
              "item",  
              $("#comment-edit-form-" + id).serialize(),
          return false;  
        }
 
+
+       function preview_comment(id) {
+               $("#comment-preview-inp-" + id).val("1");
+               $("#comment-edit-preview-" + id).show();
+               $.post(  
+             "item",  
+             $("#comment-edit-form-" + id).serialize(),
+                       function(data) {
+                               if(data.preview) {
+                                               
+                                       $("#comment-edit-preview-" + id).html(data.preview);
+                                       $("#comment-edit-preview-" + id + " a").removeAttr('href');
+                               }
+                       },
+                       "json"  
+         );  
+         return true;  
+       }
+
+
+
+
        function unpause() {
                // unpause auto reloads if they are currently stopped
                totStopped = false;
index d4d337584c2617939d3834c5254f64bb431c975b..069f1393cf438a392e1669f5db8b0303ae9f798d 100644 (file)
@@ -588,7 +588,7 @@ function item_post(&$a) {
        if($preview) {
                $b = prepare_body($datarray,true);
                require_once('include/conversation.php');
-               $o = conversation(&$a,array(array_merge($datarray,$contact_record)),'search',false);
+               $o = conversation(&$a,array(array_merge($contact_record,$datarray)),'search',false,true);
                $json = array('preview' => $o);
                echo json_encode($json);
                killme();
index bf3299de07fb867a44e67326dc2033d7158825b4..d2f45652ff14371344b7a259898b61fbd4803bcd 100644 (file)
@@ -1203,6 +1203,7 @@ function photos_content(&$a) {
                                                        '$myphoto' => $contact['thumb'],
                                                        '$comment' => t('Comment'),
                                                        '$submit' => t('Submit'),
+                                                       '$preview' => t('Preview'),
                                                        '$ww' => ''
                                                ));
                                        }
index 0216e31d3d558294fbbd7345cde6bf3bb148895f..49751c42b38135b5614af06a88ac398eaa0fe720 100644 (file)
@@ -5,6 +5,7 @@
                                <input type="hidden" name="parent" value="$parent" />
                                <input type="hidden" name="return" value="$return_path" />
                                <input type="hidden" name="jsreload" value="$jsreload" />
+                               <input type="hidden" name="preview" id="comment-preview-inp-$id" value="0" />
 
                                <div class="comment-edit-photo" id="comment-edit-photo-$id" >
                                        <a class="comment-edit-photo-link" href="$mylink" title="$mytitle"><img class="my-comment-photo" src="$myphoto" alt="$mytitle" title="$mytitle" /></a>
@@ -15,6 +16,8 @@
                                <div class="comment-edit-text-end"></div>
                                <div class="comment-edit-submit-wrapper" id="comment-edit-submit-wrapper-$id" style="display: none;" >
                                        <input type="submit" onclick="post_comment($id); return false;" id="comment-edit-submit-$id" class="comment-edit-submit" name="submit" value="$submit" />
+                                       <span onclick="preview_comment($id);" id="comment-edit-preview-link-$id" class="fakelink">$preview</span>
+                                       <div id="comment-edit-preview-$id" style="display:none;"></div>
                                </div>
 
                                <div class="comment-edit-end"></div>