]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/frio/templates/jot-header.tpl
Fix review points
[friendica.git] / view / theme / frio / templates / jot-header.tpl
index d52f4b98dec41eac862d5ce3ebff8c0c937166f0..8eb76ccc6941aa08811b268ce0a8096fb4b396e8 100644 (file)
@@ -1,5 +1,7 @@
 
-<script type="text/javascript" src="{{$baseurl}}/js/ajaxupload.js" ></script>
+<script type="text/javascript" src="{{$baseurl}}/view/js/ajaxupload.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
+<script type="text/javascript" src="{{$baseurl}}/view/js/linkPreview.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
+<script type="text/javascript" src="{{$baseurl}}/view/theme/frio/js/jot.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
 
 <script type="text/javascript">
        var editor = false;
@@ -13,7 +15,7 @@
                        $("#jot-category").show();
                        $("#jot-category").addClass("jot-category-ex");
                        $("#jot-profile-jot-wrapper").show();
-                       $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
+                       $("#profile-jot-text").editor_autocomplete(baseurl + '/search/acl');
                        $("#profile-jot-text").bbco_autocomplete('bbcode');
                        $("a#jot-perms-icon").colorbox({
                                'inline' : true,
@@ -38,7 +40,8 @@
 </script>
 
 <script type="text/javascript">
-       var ispublic = '{{$ispublic}}';
+       var ispublic = '{{$ispublic nofilter}}';
+       aStr.linkurl = '{{$linkurl}}';
 
 
        $(document).ready(function() {
                        jotTextOpenUI(document.getElementById("profile-jot-text"));
                        jotActive();
                        addeditortext(embedcode);
-               });
-               $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
+               })
+               .on('fbrowser.file.main', function(e, filename, embedcode, id) {
                        jotTextOpenUI(document.getElementById("profile-jot-text"));
                        jotActive();
                        addeditortext(embedcode);
+               })
+               // Asynchronous jot submission
+               .on('submit', '#profile-jot-form', function (e) {
+                       e.preventDefault();
+
+                       // Disable jot submit buttons during processing
+                       let $share = $('#profile-jot-submit').button('loading');
+                       let $sharePreview = $('#profile-jot-preview-submit').button('loading');
+
+                       let formData = new FormData(e.target);
+                       // This cancels the automatic redirection after item submission
+                       formData.delete('return');
+
+                       $.ajax({
+                               url: 'item',
+                               data: formData,
+                               processData: false,
+                               contentType: false,
+                               type: 'POST',
+                       })
+                       .then(function () {
+                               // Reset to form for jot reuse in the same page
+                               e.target.reset();
+                               $('#jot-modal').modal('hide');
+                       })
+                       .always(function() {
+                               // Reset the post_id_random to avoid duplicate post errors
+                               let new_post_id_random = Math.floor(Math.random() * (Number.MAX_SAFE_INTEGER - (Number.MAX_SAFE_INTEGER / 10))) + Number.MAX_SAFE_INTEGER / 10;
+                               $('#profile-jot-form [name=post_id_random]').val(new_post_id_random);
+
+                               // Reset jot submit button state
+                               $share.button('reset');
+                               $sharePreview.button('reset');
+
+                               // Force the display update of the edited post/comment
+                               if (formData.get('post_id')) {
+                                       force_update = true;
+                                       update_item = formData.get('post_id');
+                               }
+
+                               NavUpdate();
+                       })
                });
 
                $('#wall-image-upload').on('click', function(){
                }
        }
 
-       function jotGetLink() {
-               reply = prompt("{{$linkurl}}");
-               if(reply && reply.length) {
-                       reply = bin2hex(reply);
-                       $('#profile-rotator').show();
-                       $.get('parse_url?binurl=' + reply, function(data) {
-                               addeditortext(data);
-                               $('#profile-rotator').hide();
-                       });
-               }
-       }
-
        function jotVideoURL() {
                reply = prompt("{{$vidurl}}");
                if(reply && reply.length) {
                }
        }
 
-
        function jotGetLocation() {
                reply = prompt("{{$whereareu}}", $('#jot-location').val());
                if(reply && reply.length) {
                $("#jot-popup").show();
        }
 
-       function linkdropper(event) {
+       function linkDropper(event) {
                var linkFound = event.dataTransfer.types.contains("text/uri-list");
                if(linkFound)
                        event.preventDefault();
        }
 
-       function linkdrop(event) {
+       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('parseurl?binurl=' + reply + noAttachment, function(data) {
                                if (!editor) $("#profile-jot-text").val("");
                                initEditor(function(){
                                        addeditortext(data);
                                        $('#profile-rotator').hide();
                                });
                        });
+                       autosize.update($("#profile-jot-text"));
                }
        }
 
        }
 
        function itemFiler(id) {
-
                var bordercolor = $("input").css("border-color");
 
                $.get('filer/', function(data){
 //                                     if(timer) clearTimeout(timer);
 //                                     timer = setTimeout(NavUpdate,3000);
                                        liking = 1;
+                                       force_update = true;
                                        $.colorbox.close();
                                } else {
                                        $("#id_term").css("border-color","#FF0000");
                var currentText = $("#profile-jot-text").val();
                //insert the data as new value
                textfield.value = currentText + data;
+               autosize.update($("#profile-jot-text"));
        }
 
-       {{$geotag}}
+       {{$geotag nofilter}}
 
        function jotShow() {
                var modal = $('#jot-modal').modal();
                        .find('#jot-modal-content')
                        .append(jotcache)
                        .modal.show;
+
+               // Jot attachment live preview.
+               linkPreview = $('#profile-jot-text').linkPreview();
        }
 
        // Activate the jot text section in the jot modal