]> git.mxchange.org Git - friendica.git/commitdiff
Add multimedia link for jot + enables hover text in jot + autosize in when paste...
authorJonny Tischbein <jonny_tischbein@systemli.org>
Wed, 24 Oct 2018 14:20:10 +0000 (16:20 +0200)
committerJonny Tischbein <jonny_tischbein@systemli.org>
Wed, 24 Oct 2018 14:20:10 +0000 (16:20 +0200)
include/conversation.php
mod/parse_url.php
src/Object/Post.php
view/js/main.js
view/theme/frio/js/textedit.js
view/theme/frio/templates/comment_item.tpl
view/theme/frio/templates/jot-header.tpl
view/theme/frio/templates/jot.tpl

index 43854bb40f7b7e8d1486edb47d41e3a092fa7063..0362e9a4459f1d9730e13f4148b37cc6fb84660d 100644 (file)
@@ -1082,9 +1082,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
                '$geotag'    => $geotag,
                '$nickname'  => $x['nickname'],
                '$ispublic'  => L10n::t('Visible to <strong>everybody</strong>'),
-               '$linkurl'   => L10n::t('Please enter a link URL:'),
-               '$vidurl'    => L10n::t("Please enter a video link/URL:"),
-               '$audurl'    => L10n::t("Please enter an audio link/URL:"),
+               '$linkurl'   => L10n::t('Please enter a image/video/audio/webpage URL:'),
                '$term'      => L10n::t('Tag term:'),
                '$fileas'    => L10n::t('Save to Folder:'),
                '$whereareu' => L10n::t('Where are you right now?'),
@@ -1128,12 +1126,14 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
                '$shortupload'  => L10n::t('upload photo'),
                '$attach'       => L10n::t('Attach file'),
                '$shortattach'  => L10n::t('attach file'),
-               '$weblink'      => L10n::t('Insert web link'),
-               '$shortweblink' => L10n::t('web link'),
-               '$video'        => L10n::t('Insert video link'),
-               '$shortvideo'   => L10n::t('video link'),
-               '$audio'        => L10n::t('Insert audio link'),
-               '$shortaudio'   => L10n::t('audio link'),
+               '$edbold'       => L10n::t('Bold'),
+               '$editalic'     => L10n::t('Italic'),
+               '$eduline'      => L10n::t('Underline'),
+               '$edquote'      => L10n::t('Quote'),
+               '$edcode'       => L10n::t('Code'),
+               '$edimg'        => L10n::t('Image'),
+               '$edurl'        => L10n::t('Link'),
+               '$edattach'     => L10n::t('Link or Media'),
                '$setloc'       => L10n::t('Set your location'),
                '$shortsetloc'  => L10n::t('set location'),
                '$noloc'        => L10n::t('Clear browser location'),
index 61c681d7230293f7b94d253f08ec36028996fc67..331ebf2629edb0ff74a58f5628d815a31a0f53fb 100644 (file)
@@ -92,10 +92,6 @@ function parse_url_content(App $a)
                }
        }
 
-       if (!empty($_GET['isComment'])) {
-               echo $br . '[url]' . $url . '[/url]';
-               exit();
-       }
 
        $template = '[bookmark=%s]%s[/bookmark]%s';
 
@@ -128,6 +124,12 @@ function parse_url_content(App $a)
 
        unset($siteinfo['keywords']);
 
+       // Bypass attachment if parse url for a comment
+       if (!empty($_GET['noAttachment'])) {
+               echo $br . '[url=' . $url . ']' . $siteinfo['title'] . '[/url]';
+               exit();
+       }
+
        // Format it as BBCode attachment
        $info = add_page_info_data($siteinfo);
 
index 0ec6aca0d3f8d43f285f9571e02c0950338a5b0f..e8bc29ac030908ee955b9112378572db3b48e7aa 100644 (file)
@@ -157,7 +157,7 @@ class Post extends BaseObject
                        if ($item["event-id"] != 0) {
                                $edpost = ["events/event/" . $item['event-id'], L10n::t("Edit")];
                        } else {
-                               $edpost = ["editpost/" . $item['id'] . "/" . base64_encode($a->cmd), L10n::t("Edit")];
+                               $edpost = ["editpost/" . $item['id'], L10n::t("Edit")];
                        }
                        $dropping = in_array($item['uid'], [0, local_user()]);
                } else {
@@ -209,7 +209,13 @@ class Post extends BaseObject
 
                $author = ['uid' => 0, 'id' => $item['author-id'],
                        'network' => $item['author-network'], 'url' => $item['author-link']];
-               $profile_link = Contact::magicLinkbyContact($author);
+
+               if (local_user() || remote_user()) {
+                       $profile_link = Contact::magicLinkbyContact($author);
+               } else {
+                       $profile_link = $item['author-link'];
+               }
+
                if (strpos($profile_link, 'redir/') === 0) {
                        $sparkle = ' sparkle';
                }
@@ -765,7 +771,7 @@ class Post extends BaseObject
                         * Hmmm, code depending on the presence of a particular addon?
                         * This should be better if done by a hook
                         */
-                       if (in_array('qcomment', $a->addons)) {
+                       if (Addon::isEnabled('qcomment')) {
                                $qc = ((local_user()) ? PConfig::get(local_user(), 'qcomment', 'words') : null);
                                $qcomment = (($qc) ? explode("\n", $qc) : null);
                        }
@@ -799,7 +805,9 @@ class Post extends BaseObject
                                '$edquote'     => L10n::t('Quote'),
                                '$edcode'      => L10n::t('Code'),
                                '$edimg'       => L10n::t('Image'),
-                               '$edurl'       => L10n::t('Link or Media'),
+                               '$edurl'       => L10n::t('Link'),
+                               '$edattach'    => L10n::t('Link or Media'),
+                               '$prompttext'  => L10n::t('Please enter a image/video/audio/webpage URL:'),
                                '$preview'     => ((Feature::isEnabled($conv->getProfileOwner(), 'preview')) ? L10n::t('Preview') : ''),
                                '$indent'      => $indent,
                                '$sourceapp'   => L10n::t($a->sourcename),
index 7e726248d3fd0f3c939dc7957a407ec4a266cbee..b2c469a6d9ae5091ac3bdf4e9b0738e2f61cc53b 100644 (file)
@@ -24,7 +24,7 @@ function openClose(theID) {
 }
 
 function openMenu(theID) {
-       var el = document.getElementById(theID)
+       var el = document.getElementById(theID);
 
        if (el) {
                el.style.display = "block";
index 3bfec8cfe6ef7f3ff167c0184ec9de263dfe4979..5074c3009cd1876e0c1fa606de77f52c7b452c38 100644 (file)
@@ -2,17 +2,17 @@
  * @brief The file contains functions for text editing and commenting
  */
 
-function commentGetLink(id) {
-    reply = prompt("Please enter a link URL:");
+function commentGetLink(id,prompttext) {
+    reply = prompt(prompttext);
     if(reply && reply.length) {
-        reply = bin2hex(reply);
-        $.get('parse_url?isComment=1&binurl=' + reply, function(data) {
-            addcommenttext(data, id);
-        });
-    }
+               reply = bin2hex(reply);
+               $.get('parse_url?noAttachment=1&binurl=' + reply, function(data) {
+                       addCommentText(data, id);
+               });
+       }
 }
 
-function addcommenttext(data, id) {
+function addCommentText(data, id) {
     // get the textfield
     var textfield = document.getElementById("comment-edit-text-" + id);
     // check if the textfield does have the default-value
@@ -24,19 +24,19 @@ function addcommenttext(data, id) {
     autosize.update($("#comment-edit-text-" + id));
 }
 
-function commentlinkdrop(event, id) {
+function commentLinkDrop(event, id) {
     var reply = event.dataTransfer.getData("text/uri-list");
     event.target.textContent = reply;
     event.preventDefault();
     if (reply && reply.length) {
         reply = bin2hex(reply);
-        $.get('parse_url?isComment=1&binurl=' + reply, function(data) {
-                       addcommenttext(data, id);
+        $.get('parse_url?noAttachment=1&binurl=' + reply, function(data) {
+                       addCommentText(data, id);
         });
     }
 }
 
-function commentlinkdropper(event) {
+function commentLinkDropper(event) {
     var linkFound = event.dataTransfer.types.contains("text/uri-list");
     if (linkFound) {
         event.preventDefault();
index 4fa6421b51fc8d2fb2eb969a915c56c08e7b2706..4ef5f2caa1114d589ffa07798a63fdb616d83244 100644 (file)
                                        </button>
                                </li>
                                <li>
-                                       <button type="button" class="btn-link icon bb-url" style="cursor: pointer;" aria-label="{{$edurl}}" title="{{$edurl}}" ondragenter="return commentlinkdrop(event, {{$id}});" ondragover="return commentlinkdrop(event, {{$id}});" ondrop="commentlinkdropper(event);" onclick="commentGetLink({{$id}});">
+                                       <button type="button" class="btn-link icon bb-url" style="cursor: pointer;" aria-label="{{$edurl}}" title="{{$edurl}}" onclick="insertFormatting('url',{{$id}});">
                                                <i class="fa fa-link"></i>
                                        </button>
                                </li>
+                               <li>
+                                       <button type="button" class="btn-link icon" style="cursor: pointer;" aria-label="{{$edattach}}" title="{{$edattach}}" ondragenter="return commentLinkDrop(event, {{$id}});" ondragover="return commentLinkDrop(event, {{$id}});" ondrop="commentLinkDropper(event);" onclick="commentGetLink({{$id}}, '{{$prompttext}}');">
+                                               <i class="fa fa-paperclip"></i>
+                                       </button>
+                               </li>
                                <li>
                                        <button type="button" class="btn-link icon underline" style="cursor: pointer;" aria-label="{{$eduline}}" title="{{$eduline}}" onclick="insertFormatting('u',{{$id}});">
                                                <i class="fa fa-underline"></i>
index 81921598ab30fa40f4a6e26174411b9003c7b270..8289692f377a7bb52fa0c32937db4ea662c5e749 100644 (file)
        }
 
        function jotGetLink() {
+               var currentText = $("#profile-jot-text").val();
+               var noAttachment = '';
                reply = prompt("{{$linkurl}}");
                if(reply && reply.length) {
                        reply = bin2hex(reply);
                        $('#profile-rotator').show();
-                       $.get('parse_url?binurl=' + reply, function(data) {
+                       if (currentText.includes("[attachment") && currentText.includes("[/attachment]")) {
+                               noAttachment = '&noAttachment=1';
+                       }
+                       $.get('parse_url?binurl=' + reply + noAttachment, function(data) {
                                addeditortext(data);
                                $('#profile-rotator').hide();
                        });
+                       autosize.update($("#profile-jot-text"));
                }
        }
 
 
        function linkdrop(event) {
                var reply = event.dataTransfer.getData("text/uri-list");
+               var noAttachment = '';
                event.target.textContent = reply;
                event.preventDefault();
                if(reply && reply.length) {
                        reply = bin2hex(reply);
                        $('#profile-rotator').show();
-                       $.get('parse_url?binurl=' + reply, function(data) {
+                       if (currentText.includes("[attachment") && currentText.includes("[/attachment]")) {
+                               noAttachment = '&noAttachment=1';
+                       }
+                       $.get('parse_url?binurl=' + reply + noAttachment, function(data) {
                                if (!editor) $("#profile-jot-text").val("");
                                initEditor(function(){
                                        addeditortext(data);
                                        $('#profile-rotator').hide();
                                });
                        });
+                       autosize.update($("#profile-jot-text"));
                }
        }
 
                var currentText = $("#profile-jot-text").val();
                //insert the data as new value
                textfield.value = currentText + data;
+               autosize.update($("#profile-jot-text"));
        }
 
        {{$geotag}}
index 14f383ac8d346e8d4e3867616474a0ce22c40f54..46d0351d9dae0181c1d6c9401c457cab6061945a 100644 (file)
@@ -97,9 +97,8 @@
                                                <li role="presentation"><button type="button" class="hidden-xs btn-link icon italic" style="cursor: pointer;" aria-label="{{$editalic}}" title="{{$editalic}}" onclick="insertFormattingToPost('i');"><i class="fa fa-italic"></i></button></li>
                                                <li role="presentation"><button type="button" class="hidden-xs btn-link icon bold" style="cursor: pointer;" aria-label="{{$edbold}}" title="{{$edbold}}" onclick="insertFormattingToPost('b');"><i class="fa fa-bold"></i></button></li>
                                                <li role="presentation"><button type="button" class="hidden-xs btn-link icon quote" style="cursor: pointer;" aria-label="{{$edquote}}" title="{{$edquote}}" onclick="insertFormattingToPost('quote');"><i class="fa fa-quote-left"></i></button></li>
-                                               <li role="presentation"><button type="button" class="btn-link" id="profile-link"  ondragenter="return linkdropper(event);" ondragover="return linkdropper(event);" ondrop="linkdrop(event);" onclick="jotGetLink();" title="{{$weblink}}"><i class="fa fa-link"></i></button></li>
-                                               <li role="presentation"><button type="button" class="btn-link" id="profile-video" onclick="jotVideoURL();" title="{{$video}}"><i class="fa fa-film" aria-hidden="true"></i></button></li>
-                                               <li role="presentation"><button type="button" class="btn-link" id="profile-audio" onclick="jotAudioURL();" title="{{$audio}}"><i class="fa fa-music" aria-hidden="true"></i></button></li>
+                                               <li role="presentation"><button type="button" class="btn-link icon" style="cursor: pointer;" aria-label="{{$edurl}}" title="{{$edurl}}" onclick="insertFormattingToPost('url');"><i class="fa fa-link"></i></button></li>
+                                               <li role="presentation"><button type="button" class="btn-link" id="profile-attach"  ondragenter="return linkdropper(event);" ondragover="return linkdropper(event);" ondrop="linkdrop(event);" onclick="jotGetLink();" title="{{$edattach}}"><i class="fa fa-paperclip"></i></button></li>
                                                <li role="presentation"><button type="button" class="btn-link" id="profile-location" onclick="jotGetLocation();" title="{{$setloc}}"><i class="fa fa-map-marker" aria-hidden="true"></i></button></li>
                                                <!-- TODO: waiting for a better placement
                                                <li><button type="button" class="btn-link" id="profile-nolocation" onclick="jotClearLocation();" title="{{$noloc}}">{{$shortnoloc}}</button></li>