diff options
Diffstat (limited to 'view/tpl/jot-header.tpl')
-rwxr-xr-x | view/tpl/jot-header.tpl | 289 |
1 files changed, 119 insertions, 170 deletions
diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index d846f3e34..2f9dd9f15 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -6,11 +6,11 @@ var pretext = '{{$pretext}}'; function initEditor(cb){ if (editor==false){ - $("#profile-jot-text-loading").spin('small').show(); + $("#profile-jot-text-loading").show(); {{$geotag}} if(plaintext == 'none') { - $("#profile-jot-text-loading").spin(false).hide(); - $("#profile-jot-text").css({ 'height': 200, 'color': '#000', 'line-height': 'inherit' }); + $("#profile-jot-text-loading").hide(); + $("#profile-jot-text").css({ 'height': 200 }); {{if $bbco_autocomplete}} $("#profile-jot-text").bbco_autocomplete('{{$bbco_autocomplete}}'); // autocomplete bbcode {{/if}} @@ -80,7 +80,7 @@ function initEditor(cb){ ed.onInit.add(function(ed) { ed.pasteAsPlainText = true; - $("#profile-jot-text-loading").spin(false).hide(); + $("#profile-jot-text-loading").hide(); $(".jothidden").show(); if (typeof cb!="undefined") cb(); }); @@ -100,77 +100,76 @@ function enableOnUser(){ initEditor(); } </script> -<script type="text/javascript" src="{{$baseurl}}/view/js/ajaxupload.js" ></script> + +<script src="library/blueimp_upload/js/vendor/jquery.ui.widget.js"></script> +<script src="library/blueimp_upload/js/jquery.iframe-transport.js"></script> +<script src="library/blueimp_upload/js/jquery.fileupload.js"></script> + <script> +var activeCommentID = 0; +var activeCommentText = ''; + $(document).ready(function() { /* enable tinymce on focus and click */ $("#profile-jot-text").focus(enableOnUser); $("#profile-jot-text").click(enableOnUser); - var upload_title = $('#wall-image-upload').attr('title'); - var attach_title = $('#wall-file-upload').attr('title'); - try { - var uploader = new window.AjaxUpload('wall-image-upload', - { action: '{{$baseurl}}/wall_upload/{{$nickname}}', - name: 'userfile', - title: upload_title, - onSubmit: function(file,ext) { $('#profile-rotator').spin('tiny'); }, - onComplete: function(file,response) { - addeditortext(response); - $('#jot-media').val($('#jot-media').val() + response); - $('#profile-rotator').spin(false); - } - }); - } catch (e) { - } - try { - var uploader_sub = new window.AjaxUpload('wall-image-upload-sub', - { action: '{{$baseurl}}/wall_upload/{{$nickname}}', - name: 'userfile', - title: upload_title, - onSubmit: function(file,ext) { $('#profile-rotator').spin('tiny'); }, - onComplete: function(file,response) { - addeditortext(response); - $('#jot-media').val($('#jot-media').val() + response); - $('#profile-rotator').spin(false); - } - }); - } catch(e) { - } - try { - var file_uploader = new window.AjaxUpload('wall-file-upload', - { action: '{{$baseurl}}/wall_attach/{{$nickname}}', - name: 'userfile', - title: attach_title, - onSubmit: function(file,ext) { $('#profile-rotator').spin('tiny'); }, - onComplete: function(file,response) { - addeditortext(response); - $('#jot-media').val($('#jot-media').val() + response); - $('#profile-rotator').spin(false); - } - }); - } catch(e) { - } - try { - var file_uploader_sub = new window.AjaxUpload('wall-file-upload-sub', - { action: '{{$baseurl}}/wall_attach/{{$nickname}}', - name: 'userfile', - title: attach_title, - onSubmit: function(file,ext) { $('#profile-rotator').spin('tiny'); }, - onComplete: function(file,response) { - addeditortext(response); - $('#jot-media').val($('#jot-media').val() + response); - $('#profile-rotator').spin(false); - } - }); - } catch(e) { - } - - + + $('#invisible-wall-file-upload').fileupload({ + url: 'wall_attach/{{$nickname}}', + dataType: 'json', + dropZone: $('#profile-jot-text'), + maxChunkSize: 4 * 1024 * 1024, + add: function(e,data) { + $('#profile-rotator').show(); + data.submit(); + }, + done: function(e,data) { + addeditortext(data.result.message); + $('#jot-media').val($('#jot-media').val() + data.result.message); + }, + stop: function(e,data) { + preview_post(); + $('#profile-rotator').hide(); + }, + }); + + $('#wall-file-upload').click(function(event) { event.preventDefault(); $('#invisible-wall-file-upload').trigger('click'); return false;}); + $('#wall-file-upload-sub').click(function(event) { event.preventDefault(); $('#invisible-wall-file-upload').trigger('click'); return false;}); + // call initialization file if (window.File && window.FileList && window.FileReader) { DragDropUploadInit(); } + + + $('#invisible-comment-upload').fileupload({ + url: 'wall_attach/{{$nickname}}', + dataType: 'json', + maxChunkSize: 4 * 1024 * 1024, + add: function(e,data) { + + var tmpStr = $("#comment-edit-text-" + activeCommentID).val(); + if(tmpStr == activeCommentText) { + tmpStr = ""; + $("#comment-edit-text-" + activeCommentID).addClass("comment-edit-text-full"); + $("#comment-edit-text-" + activeCommentID).removeClass("comment-edit-text-empty"); + openMenu("comment-tools-" + activeCommentID); + $("#comment-edit-text-" + activeCommentID).val(tmpStr); + } + data.submit(); + }, + + done: function(e,data) { + textarea = document.getElementById("comment-edit-text-" + activeCommentID); + textarea.value = textarea.value + data.result.message; + }, + stop: function(e,data) { + $('body').css('cursor', 'auto'); + preview_comment(activeCommentID); + activeCommentID = 0; + }, + }); }); function deleteCheckedItems() { @@ -205,10 +204,11 @@ function enableOnUser(){ reply = prompt("{{$linkurl}}"); if(reply && reply.length) { reply = bin2hex(reply); - $('#profile-rotator').spin('tiny'); + $('#profile-rotator').show(); $.get('{{$baseurl}}/linkinfo?f=&binurl=' + reply, function(data) { addeditortext(data); - $('#profile-rotator').spin(false); + preview_post(); + $('#profile-rotator').hide(); }); } } @@ -247,18 +247,23 @@ function enableOnUser(){ } - function jotShare(id) { - if ($('#jot-popup').length != 0) $('#jot-popup').show(); + function jotShare(id,post_type) { + if(post_type == 6) { + window.location.href = 'rpost?f=&post_id='+id; + } + else { + if ($('#jot-popup').length != 0) $('#jot-popup').show(); - $('#like-rotator-' + id).spin('tiny'); - $.get('{{$baseurl}}/share/' + id, function(data) { - if (!editor) $("#profile-jot-text").val(""); - initEditor(function(){ - addeditortext(data); - $('#like-rotator-' + id).spin(false); - $(window).scrollTop(0); + $('#like-rotator-' + id).show(); + $.get('{{$baseurl}}/share/' + id, function(data) { + if (!editor) $("#profile-jot-text").val(""); + initEditor(function(){ + addeditortext(data); + $('#like-rotator-' + id).hide(); + $(window).scrollTop(0); + }); }); - }); + } } function linkdropper(event) { @@ -291,31 +296,33 @@ function enableOnUser(){ function linkdrop(event) { var reply = event.dataTransfer.getData("text/uri-list"); - event.preventDefault(); - var editwin = '#' + event.target.id; - var commentwin = false; - if(editwin) { - commentwin = ((editwin.indexOf('comment') >= 0) ? true : false); - if(commentwin) { - var commentid = editwin.substring(editwin.lastIndexOf('-') + 1); - commentOpen(document.getElementById(event.target.id),commentid); + if(reply) { + event.preventDefault(); + var editwin = '#' + event.target.id; + var commentwin = false; + if(editwin) { + commentwin = ((editwin.indexOf('comment') >= 0) ? true : false); + if(commentwin) { + var commentid = editwin.substring(editwin.lastIndexOf('-') + 1); + commentOpen(document.getElementById(event.target.id),commentid); + } } } if(reply && reply.length) { reply = bin2hex(reply); - $('#profile-rotator').spin('tiny'); + $('#profile-rotator').show(); $.get('{{$baseurl}}/linkinfo?f=&binurl=' + reply, function(data) { if(commentwin) { $(editwin).val( $(editwin).val() + data ); - $('#profile-rotator').spin(false); + $('#profile-rotator').hide(); } else { if (!editor) $("#profile-jot-text").val(""); initEditor(function(){ addeditortext(data); - $('#profile-rotator').spin(false); + $('#profile-rotator').hide(); }); } }); @@ -340,18 +347,12 @@ function enableOnUser(){ } function itemFiler(id) { - - var bordercolor = $("input").css("border-color"); + if($('#item-filer-dialog').length) + $('#item-filer-dialog').remove(); $.get('filer/', function(data){ - $.colorbox({html:data}); - $("#id_term").keypress(function(){ - $(this).css("border-color",bordercolor); - }) - $("#select_term").change(function(){ - $("#id_term").css("border-color",bordercolor); - }) - + $('body').append(data); + $('#item-filer-dialog').modal('show'); $("#filer_save").click(function(e){ e.preventDefault(); reply = $("#id_term").val(); @@ -359,12 +360,8 @@ function enableOnUser(){ commentBusy = true; $('body').css('cursor', 'wait'); $.get('{{$baseurl}}/filer/' + id + '?term=' + reply, NavUpdate); -// if(timer) clearTimeout(timer); -// timer = setTimeout(NavUpdate,3000); liking = 1; - $.colorbox.close(); - } else { - $("#id_term").css("border-color","#FF0000"); + $('#item-filer-dialog').modal('hide'); } return false; }); @@ -428,7 +425,7 @@ function enableOnUser(){ }); getPhotoAlbumList(); $('#embedPhotoModalBodyAlbumDialog').off('click'); - $('#embedPhotoModal').modal(); + $('#embedPhotoModal').modal('show'); }; var choosePhotoFromAlbum = function (album) { @@ -437,13 +434,13 @@ function enableOnUser(){ if (data['status']) { $('#embedPhotoModalLabel').html("{{$modalchooseimages}}"); $('#embedPhotoModalBodyAlbumDialog').html('\ - <div><ul class="nav">\n\ - <li><a href="#" onclick="initializeEmbedPhotoDialog();return false;">\n\ + <div><div class="nav nav-pills flex-column">\n\ + <li class="nav-item"><a class="nav-link" href="#" onclick="initializeEmbedPhotoDialog();return false;">\n\ <i class="fa fa-chevron-left"></i> \n\ {{$modaldiffalbum}}\n\ </a>\n\ </li>\n\ - </ul><br></div>') + </div><br></div>') $('#embedPhotoModalBodyAlbumDialog').append(data['content']); $('#embedPhotoModalBodyAlbumDialog').click(function (evt) { evt.preventDefault(); @@ -453,8 +450,8 @@ function enableOnUser(){ $(imageparent).toggleClass('embed-photo-selected-photo'); } }); - $('#embedPhotoModalBodyAlbumListDialog').addClass('hide'); - $('#embedPhotoModalBodyAlbumDialog').removeClass('hide'); + $('#embedPhotoModalBodyAlbumListDialog').addClass('d-none'); + $('#embedPhotoModalBodyAlbumDialog').removeClass('d-none'); $('#embed-photo-OKButton').click(function () { $('.embed-photo-selected-photo').each(function (index) { var href = $(this).attr('href'); @@ -462,6 +459,7 @@ function enableOnUser(){ function(ddata) { if (ddata['status']) { addeditortext(ddata['photolink']); + preview_post(); } else { window.console.log("{{$modalerrorlink}}" + ':' + ddata['errormsg']); } @@ -487,17 +485,17 @@ function enableOnUser(){ if (data['status']) { var albums = data['albumlist']; //JSON.parse(data['albumlist']); $('#embedPhotoModalLabel').html("{{$modalchoosealbum}}"); - $('#embedPhotoModalBodyAlbumList').html('<ul class="nav"></ul>'); + $('#embedPhotoModalBodyAlbumList').html('<ul class="nav nav-pills flex-column"></ul>'); for(var i=0; i<albums.length; i++) { var albumName = albums[i].text; var jsAlbumName = albums[i].jstext; - var albumLink = '<li>'; - albumLink += '<a href="#" onclick="choosePhotoFromAlbum(\'' + jsAlbumName + '\'); return false;">' + albumName + '</a>'; + var albumLink = '<li class="nav-item">'; + albumLink += '<a class="nav-link" href="#" onclick="choosePhotoFromAlbum(\'' + jsAlbumName + '\'); return false;">' + albumName + '</a>'; albumLink += '</li>'; $('#embedPhotoModalBodyAlbumList').find('ul').append(albumLink); } - $('#embedPhotoModalBodyAlbumDialog').addClass('hide'); - $('#embedPhotoModalBodyAlbumListDialog').removeClass('hide'); + $('#embedPhotoModalBodyAlbumDialog').addClass('d-none'); + $('#embedPhotoModalBodyAlbumListDialog').removeClass('d-none'); } else { window.console.log("{{$modalerrorlist}}" + ':' + data['errormsg']); } @@ -507,32 +505,20 @@ function enableOnUser(){ }; // - // initialize + // initialize drag-drop function DragDropUploadInit() { var filedrag = $("#profile-jot-text"); - // is XHR2 available? - var xhr = new XMLHttpRequest(); - if (xhr.upload) { - - // file drop + // file drop filedrag.on("dragover", DragDropUploadFileHover); filedrag.on("dragleave", DragDropUploadFileHover); filedrag.on("drop", DragDropUploadFileSelectHandler); - } - - window.filesToUpload = 0; - window.fileUploadsCompleted = 0; - - } // file drag hover function DragDropUploadFileHover(e) { - e.stopPropagation(); - e.preventDefault(); e.target.className = (e.type == "dragover" ? "hover" : ""); } @@ -541,49 +527,12 @@ function enableOnUser(){ // cancel event and hover styling DragDropUploadFileHover(e); - if (!editor) $("#profile-jot-text").val(""); - - - // fetch FileList object - var files = e.target.files || e.originalEvent.dataTransfer.files; - // process all File objects - for (var i = 0, f; f = files[i]; i++) { - DragDropUploadFile(f, i); - } - - } - - // upload files - function DragDropUploadFile(file, idx) { - - window.filesToUpload = window.filesToUpload + 1; - - var xhr = new XMLHttpRequest(); - xhr.withCredentials = true; // Include the SESSION cookie info for authentication - (xhr.upload || xhr).addEventListener('progress', function (e) { - $('#profile-rotator').spin('tiny'); - }); - xhr.addEventListener('load', function (e) { - //console.log('xhr upload complete', e); - window.fileUploadsCompleted = window.fileUploadsCompleted + 1; - - initEditor(function() { - addeditortext(xhr.responseText); - }); - - $('#jot-media').val($('#jot-media').val() + xhr.responseText); - // When all the uploads have completed, refresh the page - if (window.filesToUpload > 0 && window.fileUploadsCompleted === window.filesToUpload) { - $('#profile-rotator').spin(false); - window.fileUploadsCompleted = window.filesToUpload = 0; - } - }); - // POST to the wall_upload endpoint - xhr.open('post', '{{$baseurl}}/wall_attach/{{$nickname}}', true); + // open editor if it isn't yet initialised + if (!editor) { + initEditor(); + } + linkdrop(e); - var data = new FormData(); - data.append('userfile', file); - xhr.send(data); } </script> |