]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/frio/templates/jot-header.tpl
Fixed indentation
[friendica.git] / view / theme / frio / templates / jot-header.tpl
index 9f226cda4997bba86e2e5334738e60bf463f2fb8..498ed7fb24daf2750fa96a7bab8f223c9d65d7d5 100644 (file)
@@ -1,7 +1,7 @@
 
-<script type="text/javascript" src="{{$baseurl}}/view/js/ajaxupload.js"></script>
-<script type="text/javascript" src="{{$baseurl}}/view/js/linkPreview.js"></script>
-<script type="text/javascript" src="{{$baseurl}}/view/theme/frio/js/jot.js"></script>
+<script type="text/javascript" src="{{$baseurl}}/view/js/ajaxupload.js?v={{constant('\Friendica\App::VERSION')}}"></script>
+<script type="text/javascript" src="{{$baseurl}}/view/js/linkPreview.js?v={{constant('\Friendica\App::VERSION')}}"></script>
+<script type="text/javascript" src="{{$baseurl}}/view/theme/frio/js/jot.js?v={{constant('\Friendica\App::VERSION')}}"></script>
 
 <script type="text/javascript">
        var editor = false;
                $("#profile-jot-text").focus(enableOnUser);
                $("#profile-jot-text").click(enableOnUser);
 
-               // When clicking on a forum in acl we should remove the profile jot textarea
-               // default value before inserting the forum mention
-               $("body").on('click', '#jot-modal .acl-list-item.forum', function(){
+               // When clicking on a group in acl we should remove the profile jot textarea
+               // default value before inserting the group mention
+               $("body").on('click', '#jot-modal .acl-list-item.group', function(){
                        jotTextOpenUI(document.getElementById("profile-jot-text"));
                });
 
-
                /* show images / file browser window
                 *
                 **/
 
                /* callback */
-               $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
+               $('body').on('fbrowser.photo.main', function(e, filename, embedcode, id) {
                        ///@todo this part isn't ideal and need to be done in a better way
                        jotTextOpenUI(document.getElementById("profile-jot-text"));
                        jotActive();
                        addeditortext(embedcode);
-               });
-               $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
+               })
+               .on('fbrowser.attachment.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(){
                        Dialog.doFileBrowser("main");
                        jotActive();
                });
+
+               $('body').on('click', '.p-category .filerm', function(e){
+                       e.preventDefault();
+
+                       let $href = $(e.target).attr('href');
+                       // Prevents arbitrary Ajax requests
+                       if ($href.substr(0, 7) === 'filerm/') {
+                               $(e.target).parent().removeClass('btn-success btn-danger');
+                               $.post($href)
+                               .done(function() {
+                                       liking = 1;
+                                       force_update = true;
+                               })
+                               .always(function () {
+                                       NavUpdate();
+                               });
+                       }
+               });
        });
 
        function deleteCheckedItems() {
                                }
                        });
 
-                       // Fade the the the container from the items we want to delete
+                       // Fade the container from the items we want to delete
                        for(var key in  ItemsToDelete) {
                                $(ItemsToDelete[key]).fadeTo('fast', 0.33);
                        };
        }
 
        function jotShare(id) {
-               $.get('share/' + id, function(data) {
+               $.get('post/' + id + '/share', function(data) {
                        // remove the former content of the text input
                        $("#profile-jot-text").val("");
                        initEditor(function(){
        }
 
        function linkDropper(event) {
-               var linkFound = event.dataTransfer.types.contains("text/uri-list");
+               var linkFound = event.dataTransfer.types.includes("text/uri-list");
                if(linkFound)
                        event.preventDefault();
        }
                        if (currentText.includes("[attachment") && currentText.includes("[/attachment]")) {
                                noAttachment = '&noAttachment=1';
                        }
-                       $.get('parse_url?binurl=' + reply + noAttachment, function(data) {
+                       $.get('parseurl?binurl=' + reply + noAttachment, function(data) {
                                if (!editor) $("#profile-jot-text").val("");
                                initEditor(function(){
                                        addeditortext(data);
                                commentBusy = true;
                                $('body').css('cursor', 'wait');
 
-                               $.get('tagger/' + id + '?term=' + reply);
+                               $.post('post/' + id + '/tag/add', {term: reply});
                                if(timer) clearTimeout(timer);
                                timer = setTimeout(NavUpdate,3000);
                                liking = 1;
 //                                     if(timer) clearTimeout(timer);
 //                                     timer = setTimeout(NavUpdate,3000);
                                        liking = 1;
+                                       force_update = true;
                                        $.colorbox.close();
                                } else {
                                        $("#id_term").css("border-color","#FF0000");
                                return false;
                        });
                });
-
        }
 
        function jotClearLocation() {