streams/view/tpl/jot-header.tpl

852 lines
27 KiB
Smarty
Raw Permalink Normal View History

2023-01-01 08:13:37 +00:00
<script src="vendor/blueimp/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
<script src="vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js"></script>
<script src="vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js"></script>
2022-09-16 10:57:04 +00:00
<script type="text/javascript">
2010-07-01 23:48:07 +00:00
2022-02-18 01:38:12 +00:00
let editor = false;
let plaintext = '{{$editselect}}';
let pretext = '{{$pretext}}';
2011-01-31 22:21:23 +00:00
2023-01-01 08:13:37 +00:00
let activeCommentID = 0;
let activeCommentText = '';
let postSaveTimer = null;
$(document).on( "click", ".wall-item-delete-link,.page-delete-link,.layout-delete-link,.block-delete-link", function(e) {
let link = $(this).attr("href"); // "get" the intended link in a let
if (typeof(eval($.fn.modal)) === 'function'){
e.preventDefault();
bootbox.confirm("<h4>{{$confirmdelete}}</h4>",function(result) {
if (result) {
document.location.href = link;
}
});
} else {
return confirm("{{$confirmdelete}}");
}
});
$(document).ready(function() {
let cleaned = false;
if({{$auto_save_draft}}) {
let doctype = $('#jot-webpage').val();
let postid = '-' + doctype + '-' + $('#jot-postid').val();
let postTitle = localStorage.getItem("post_title" + postid);
let postBody = localStorage.getItem("post_body" + postid);
let postCategory = (($("#jot-category").length) ? localStorage.getItem("post_category" + postid) : '');
let openEditor = false;
if(postTitle) {
$('#jot-title').val(postTitle);
openEditor = true;
2018-08-16 01:56:18 +00:00
}
2023-01-01 08:13:37 +00:00
if(postBody) {
$('#profile-jot-text').val(postBody);
openEditor = true;
}
if(postCategory) {
let categories = postCategory.split(',');
categories.forEach(function(cat) {
$('#jot-category').tagsinput('add', cat);
});
openEditor = true;
2018-08-16 01:56:18 +00:00
}
2023-01-01 08:13:37 +00:00
if(openEditor) {
enableOnUser();
}
} else {
postSaveChanges('clean');
}
2023-01-01 08:13:37 +00:00
$(document).on('submit', '#profile-jot-form', function() {
postSaveChanges('clean');
cleaned = true;
});
2023-01-01 08:13:37 +00:00
$(document).on('focusout',"#profile-jot-wrapper",function(e){
if(! cleaned)
postSaveChanges('stop');
});
2023-01-01 08:13:37 +00:00
$(document).on('focusin',"#profile-jot-wrapper",function(e){
postSaveTimer = setTimeout(function () {
postSaveChanges('start');
},10000);
});
});
2010-07-23 03:22:03 +00:00
$(document).ready(function() {
2018-05-20 09:02:18 +00:00
2011-12-19 17:02:43 +00:00
$("#profile-jot-text").focus(enableOnUser);
$("#profile-jot-text").click(enableOnUser);
$('#id_mimetype').on('load', jotSetMime);
$('#id_mimetype').on('change', jotSetMime);
2019-04-17 00:44:42 +00:00
$("input[name='link_style']").change(function() {
2022-02-18 01:38:12 +00:00
let radioValue = $("input[name='link_style']:checked"). val();
2019-04-17 00:44:42 +00:00
if(radioValue == '0') {
$("#linkmodaldiscover").hide();
}
else {
$("#linkmodaldiscover").show();
}
});
2022-09-16 10:57:04 +00:00
jotLocateStatus();
2022-11-15 20:16:26 +00:00
jotCheckinStatus();
2022-11-21 19:15:54 +00:00
jotCheckoutStatus();
2022-09-16 10:57:04 +00:00
2020-02-27 04:48:28 +00:00
$('#jot-add-option').on('click', jotAddOption);
$(document).on('click', '.poll-option-close', jotRemoveOption);
function jotSetMime() {
2022-02-18 01:38:12 +00:00
let mtype = $('#id_mimetype').val();
2021-03-22 04:56:18 +00:00
if(mtype == 'text/bbcode' || mtype == 'text/x-multicode')
$('#profile-jot-submit-left').show();
else
$('#profile-jot-submit-left').hide();
}
/**
* uses the jQuery file upload plugin to upload files.
* It is initialized on an element with an ID of "invisible-wall-file-upload" using the .fileupload() method.
* It is configured with several options passed as an object to the .fileupload() method:
* url: specifies the server endpoint to which the uploaded file will be sent. It includes a PHP variable $nickname in the URL path.
* dataType: specifies the expected format of the response from the server, which is JSON in this case.
* dropZone: specifies the element that is used as the drop zone for the file upload. In this case, it's the element with an ID of "profile-jot-text".
* maxChunkSize: specifies the maximum chunk size for chunked file uploads. It's set to 2 megabytes in this case.
* add: specifies a callback function to be executed when a file is added to the queue.
* In this case, the function shows a rotating icon to indicate that the upload is in progress and submits the file for uploading.
* done: specifies a callback function to be executed when the upload is complete.
* In this case, the function appends the file's URL to a text area with an ID of "jot-media"
* and adds the file's URL to the text editor by calling a function named addeditortext().
* stop: specifies a callback function to be executed when the upload is stopped,
* either because it's completed or because it was cancelled.
* In this case, the function hides the rotating icon and calls a function named preview_post(), which previews the uploaded file in the user's post.
*
*/
$('#invisible-wall-file-upload').fileupload({
url: 'wall_attach/{{$nickname}}',
dataType: 'json',
dropZone: $('#profile-jot-text'),
maxChunkSize: 2 * 1024 * 1024,
add: function(e,data) {
// console.log(e);
// console.log(data);
$('#profile-rotator').show();
data.submit();
},
done: function(e,data) {
2023-03-06 18:43:40 +00:00
console.log(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;});
2023-03-06 23:01:54 +00:00
// call initialization file
if (window.File && window.FileList && window.FileReader) {
DragDropUploadInit();
}
$('#invisible-comment-upload').fileupload({
url: 'wall_attach/{{$nickname}}',
dataType: 'json',
dropZone: $(),
maxChunkSize: 2 * 1024 * 1024,
add: function(e,data) {
2022-02-18 01:38:12 +00:00
let 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);
if (textarea != null ) {
textarea.value = textarea.value + data.result.message;
}
},
stop: function(e,data) {
$('body').css('cursor', 'auto');
preview_comment(activeCommentID);
activeCommentID = 0;
},
});
2020-02-27 04:48:28 +00:00
2010-07-23 03:22:03 +00:00
});
2023-01-01 08:13:37 +00:00
function initEditor(cb){
if(editor == false){
$("#profile-jot-text-loading").show();
$("#profile-jot-reset").removeClass('d-none');
{{$geotag}}
if(plaintext == 'none') {
$("#profile-jot-text-loading").hide();
$(".jothidden").show();
$("#profile-jot-text").addClass('jot-expanded');
$("#profile-jot-summary").addClass('jot-expanded');
2023-01-04 03:32:03 +00:00
// let bodytextarea = document.querySelector('#profile-jot-text');
// if (typeof bodytextarea != "undefined") {
// bodytextarea.addEventListener('input', function handlechange(event) {
// imagewatcher(event)
// });
// }
2023-01-10 18:53:00 +00:00
2023-01-01 08:13:37 +00:00
{{if $bbco_autocomplete}}
$("#profile-jot-text").bbco_autocomplete('{{$bbco_autocomplete}}'); // autocomplete bbcode
$("#profile-jot-summary").bbco_autocomplete('{{$bbco_autocomplete}}'); // autocomplete bbcode
{{/if}}
{{if $editor_autocomplete}}
if(typeof channelId === 'undefined') {
$("#profile-jot-text").editor_autocomplete(baseurl+"/acloader");
$("#profile-jot-summary").editor_autocomplete(baseurl+"/acloader");
}
else {
$("#profile-jot-text").editor_autocomplete(baseurl+"/acloader",[channelId]); // Also gives suggestions from current channel's connections
$("#profile-jot-summary").editor_autocomplete(baseurl+"/acloader",[channelId]); // Also gives suggestions from current channel's connections
}
{{/if}}
editor = true;
if (typeof cb!="undefined") cb();
if(pretext.length)
addeditortext(pretext);
return;
}
editor = true;
} else {
if (typeof cb!="undefined") cb();
}
}
2023-01-04 03:32:03 +00:00
function imagewatcher(event) {
altTexts = []
2023-01-10 18:53:00 +00:00
let imgfind = /\[[iz]mg.*?alt="(.*?)".*?](.*?)\[/.exec(event.target.value)
if (imgfind) {
if (!altTexts.find(this,imgfind[2])) {
altTexts.append(imgfind[2] = 1)
}
console.log(altTexts);
console.log(imgfind);
}
2023-01-04 03:32:03 +00:00
}
2023-01-01 08:13:37 +00:00
function enableOnUser(){
if(editor)
return;
initEditor();
}
2011-06-16 03:43:39 +00:00
function deleteCheckedItems() {
2022-02-18 01:38:12 +00:00
let checkedstr = '';
2011-06-16 03:43:39 +00:00
$('.item-select').each( function() {
if($(this).is(':checked')) {
2011-06-16 22:26:39 +00:00
if(checkedstr.length != 0) {
2011-06-16 03:43:39 +00:00
checkedstr = checkedstr + ',' + $(this).val();
2011-06-16 22:26:39 +00:00
}
else {
2011-06-16 03:43:39 +00:00
checkedstr = $(this).val();
2011-06-16 22:26:39 +00:00
}
}
2011-06-16 03:43:39 +00:00
});
$.post('item', { dropitems: checkedstr }, function(data) {
window.location.reload();
});
2011-06-16 03:43:39 +00:00
}
2010-07-23 05:41:45 +00:00
function jotGetLink() {
2019-05-23 23:37:56 +00:00
textarea = document.getElementById('profile-jot-text');
if (textarea.selectionStart || textarea.selectionStart == "0") {
2022-02-18 01:38:12 +00:00
let start = textarea.selectionStart;
let end = textarea.selectionEnd;
2019-05-23 23:37:56 +00:00
if (end > start) {
2022-02-18 01:38:12 +00:00
let reply = prompt("{{$linkurl}}");
2019-05-23 23:37:56 +00:00
if(reply && reply.length) {
textarea.value = textarea.value.substring(0, start) + "[url=" + reply + "]" + textarea.value.substring(start, end) + "[/url]" + textarea.value.substring(end, textarea.value.length);
}
return true;
}
}
2021-09-17 07:02:02 +00:00
$('#linkModal').modal('show');
2019-05-23 23:37:56 +00:00
$('#id_link_url').focus();
2019-05-30 02:55:29 +00:00
$('#link-modal-OKButton').on('click',jotgetlinkmodal);
$('#link-modal-CancelButton').on('click',jotclearmodal);
}
2022-09-16 10:57:04 +00:00
function jotLocateStatus() {
if($('#jot-lat').val() || $('#jot-lon').val() || $('#jot-location').val()) {
$('#profile-nolocation-wrapper').attr('disabled', false);
$('#profile-nolocation-wrapper').show();
}
else {
$('#profile-nolocation-wrapper').attr('disabled', true);
$('#profile-nolocation-wrapper').hide();
}
}
2019-05-30 02:55:29 +00:00
function jotclearmodal() {
$('#link-modal-OKButton').off('click',jotgetlinkmodal);
$('#link-modal-CancelButton').off('click',jotclearmodal);
}
function jotgetlinkmodal() {
2022-02-18 01:38:12 +00:00
let reply = $('#id_link_url').val();
2019-05-30 02:55:29 +00:00
if(reply && reply.length) {
2022-02-18 01:38:12 +00:00
let radioValue = $("input[name='link_style']:checked"). val();
2019-05-30 02:55:29 +00:00
if(radioValue == '0') {
reply = '!' + reply;
}
2022-02-18 01:38:12 +00:00
let optstr = '';
let opts = $("input[name='oembed']:checked"). val();
2019-05-30 02:55:29 +00:00
if(opts) {
optstr = optstr + '&oembed=1';
2019-05-23 23:37:56 +00:00
}
opts = $("input[name='zotobj']:checked"). val();
2019-05-30 02:55:29 +00:00
if(opts) {
optstr = optstr + '&zotobj=1';
}
reply = bin2hex(reply);
$('#profile-rotator').show();
$.get('{{$baseurl}}/linkinfo?f=&binurl=' + reply + optstr, function(data) {
addeditortext(data);
preview_post();
$('#id_link_url').val('');
$('#link-modal-OKButton').off('click',jotgetlinkmodal);
$('#link-modal-CancelButton').off('click',jotclearmodal);
$('#profile-rotator').hide();
});
$('#linkModal').modal('hide');
}
2010-07-23 05:41:45 +00:00
}
2010-08-20 21:33:15 +00:00
function jotGetLocation() {
2022-09-16 10:57:04 +00:00
let reply = prompt("{{$whereareu}}", $('#jot-location').val());
2010-08-20 21:33:15 +00:00
if(reply && reply.length) {
// A single period indicates "use my browser location"
2022-09-16 10:57:04 +00:00
if(reply == '.') {
if(navigator.geolocation) {
reply = '';
navigator.geolocation.getCurrentPosition(function(position) {
2022-09-16 10:57:04 +00:00
$('#jot-lat').val(position.coords.latitude);
$('#jot-lon').val(position.coords.longitude);
2023-12-17 08:22:20 +00:00
$('#jot-location').val('');
2022-09-16 10:57:04 +00:00
jotLocateStatus();
jotCheckinStatus();
jotCheckoutStatus();
2022-09-16 10:57:04 +00:00
});
}
}
else {
$('#jot-location').val(reply);
jotLocateStatus();
jotCheckinStatus();
jotCheckoutStatus();
}
2010-08-20 21:33:15 +00:00
}
}
2020-03-20 04:08:50 +00:00
function superblock(author,item) {
$.get('superblock?f=&item=' + item + '&block=' + author, function(data) {
location.reload(true);
});
}
2020-04-17 11:08:04 +00:00
function blocksite(author) {
$.get('superblock?f=&blocksite=' + author, function(data) {
location.reload(true);
});
}
2024-05-01 09:53:45 +00:00
function blockproj(project) {
$.get('superblock?f=&blockproj=' + project, function(data) {
location.reload(true);
});
}
2020-04-17 11:08:04 +00:00
function jotGetExpiry() {
2013-12-22 13:21:57 +00:00
//reply = prompt("{{$expirewhen}}", $('#jot-expire').val());
2021-09-17 07:02:02 +00:00
$('#expiryModal').modal('show');
2013-12-22 13:21:57 +00:00
$('#expiry-modal-OKButton').on('click', function() {
reply=$('#expiration-date').val();
if(reply && reply.length) {
$('#jot-expire').val(reply);
$('#expiryModal').modal('hide');
}
})
}
function jotGetCommCtrl() {
2021-09-17 07:02:02 +00:00
$('#commModal').modal('show');
$('#comm-modal-OKButton').on('click', function() {
2020-11-25 03:22:59 +00:00
2022-02-18 01:38:12 +00:00
let comment_state = $("input[name='comments_allowed']:checked").val();
2020-11-25 03:22:59 +00:00
if (comment_state && comment_state.length) {
$('#jot-commentstate').val(comment_state);
}
else {
$('#jot-commentstate').val(0);
}
2022-02-18 01:38:12 +00:00
let post_comments = $('#id_post_comments').val();
if (post_comments && post_comments.length) {
$('#jot-commfrom').val(post_comments);
}
2022-02-18 01:38:12 +00:00
let reply=$('#commclose-date').val();
if(reply && reply.length) {
$('#jot-commclosed').val(reply);
}
$('#commModal').modal('hide');
})
}
/**
* opens a modal window with an ID of "createdModal"
* and listens for a click event on a button with an ID of "created-modal-OKButton".
* When the button is clicked, it retrieves the value of an input field with an ID of "created-date"
* and if it is not empty, it sets the value of an input field with an ID of "jot-created"
* to the retrieved value and hides the modal window.
*/
2015-10-25 23:54:18 +00:00
function jotGetPubDate() {
2021-09-17 07:02:02 +00:00
$('#createdModal').modal('show');
2015-10-25 23:54:18 +00:00
$('#created-modal-OKButton').on('click', function() {
reply=$('#created-date').val();
if(reply && reply.length) {
$('#jot-created').val(reply);
$('#createdModal').modal('hide');
}
})
}
2017-09-06 01:32:37 +00:00
function jotShare(id,post_type) {
2018-09-03 03:16:04 +00:00
$('#like-rotator-' + id).show();
$.get('{{$baseurl}}/share/' + id, function(data) {
$('#like-rotator-' + id).hide();
2019-02-08 05:05:42 +00:00
updateInit();
2018-09-03 03:16:04 +00:00
});
2011-03-17 02:36:59 +00:00
}
2010-08-20 21:33:15 +00:00
2022-11-09 11:42:23 +00:00
function jotCheckin() {
2022-11-10 08:56:42 +00:00
let checkinVal = 1 - $('#jot-checkin').val();
$('#jot-checkin').val(checkinVal);
if (checkinVal) {
$('#profile-checkin-wrapper').addClass('_orange');
}
else {
$('#profile-checkin-wrapper').removeClass('_orange');
}
2022-11-09 11:42:23 +00:00
}
2022-11-15 20:16:26 +00:00
function jotCheckinStatus() {
let checkinVal = parseInt($('#jot-checkin').val());
if (checkinVal > 0) {
2022-11-15 20:16:26 +00:00
$('#profile-checkin-wrapper').addClass('_orange');
}
else {
$('#profile-checkin-wrapper').removeClass('_orange');
}
if ($('#jot-lat').val() && $('#jot-lon').val()) {
$('#profile-checkin-wrapper').show();
} else {
$('#profile-checkin-wrapper').hide();
}
2022-11-15 20:16:26 +00:00
}
2022-11-21 19:15:54 +00:00
function jotCheckout() {
let checkoutVal = 1 - $('#jot-checkout').val();
$('#jot-checkout').val(checkoutVal);
if (checkoutVal) {
$('#profile-checkout-wrapper').addClass('_orange');
}
else {
$('#profile-checkout-wrapper').removeClass('_orange');
}
}
function jotCheckoutStatus() {
let checkoutVal = parseInt($('#jot-checkout').val());
if (checkoutVal > 0) {
$('#profile-checkout-wrapper').addClass('_orange');
}
else {
$('#profile-checkout-wrapper').removeClass('_orange');
}
if ($('#jot-lat').val() && $('#jot-lon').val()) {
$('#profile-checkout-wrapper').show();
} else {
$('#profile-checkout-wrapper').hide();
}
2022-11-21 19:15:54 +00:00
}
2022-11-16 18:51:58 +00:00
function jotEmbed(id,post_type) {
if ($('#jot-popup').length != 0) $('#jot-popup').show();
2019-01-30 05:26:52 +00:00
$('#like-rotator-' + id).show();
$.get('{{$baseurl}}/embed/' + id, function(data) {
if (!editor) $("#profile-jot-text").val("");
initEditor(function(){
addeditortext(data);
$('#like-rotator-' + id).hide();
$(window).scrollTop(0);
});
2019-01-30 05:26:52 +00:00
});
}
2018-09-03 03:16:04 +00:00
2010-08-03 02:06:36 +00:00
function linkdropper(event) {
2022-02-18 01:38:12 +00:00
let linkFound = ((event.dataTransfer.types.indexOf("text/uri-list") > -1) ? true : false);
if(linkFound) {
2010-08-03 02:06:36 +00:00
event.preventDefault();
2022-02-18 01:38:12 +00:00
let editwin = '#' + event.target.id;
let commentwin = false;
if(editwin) {
commentwin = ((editwin.indexOf('comment') >= 0) ? true : false);
if(commentwin) {
2022-02-18 01:38:12 +00:00
let commentid = editwin.substring(editwin.lastIndexOf('-') + 1);
$('#comment-edit-text-' + commentid).addClass('hover');
}
}
}
}
function linkdropexit(event) {
2022-02-18 01:38:12 +00:00
let editwin = '#' + event.target.id;
let commentwin = false;
if(editwin) {
commentwin = ((editwin.indexOf('comment') >= 0) ? true : false);
if(commentwin) {
2022-02-18 01:38:12 +00:00
let commentid = editwin.substring(editwin.lastIndexOf('-') + 1);
$('#comment-edit-text-' + commentid).removeClass('hover');
}
}
2010-08-03 02:06:36 +00:00
}
2010-07-24 13:56:02 +00:00
2010-08-03 02:06:36 +00:00
function linkdrop(event) {
2022-02-18 01:38:12 +00:00
let reply = event.dataTransfer.getData("text/uri-list");
if(reply) {
event.preventDefault();
2022-02-18 01:38:12 +00:00
let editwin = '#' + event.target.id;
let commentwin = false;
if(editwin) {
commentwin = ((editwin.indexOf('comment') >= 0) ? true : false);
if(commentwin) {
2022-02-18 01:38:12 +00:00
let commentid = editwin.substring(editwin.lastIndexOf('-') + 1);
2018-12-15 22:03:20 +00:00
$("#comment-edit-text-" + commentid).addClass("expanded");
}
}
}
2010-08-03 02:06:36 +00:00
if(reply && reply.length) {
2011-11-09 08:29:14 +00:00
reply = bin2hex(reply);
$('#profile-rotator').show();
2015-08-26 02:23:21 +00:00
$.get('{{$baseurl}}/linkinfo?f=&binurl=' + reply, function(data) {
if(commentwin) {
$(editwin).val( $(editwin).val() + data );
$('#profile-rotator').hide();
}
else {
if (!editor) $("#profile-jot-text").val("");
initEditor(function(){
addeditortext(data);
preview_post();
$('#profile-rotator').hide();
});
}
2010-08-03 02:06:36 +00:00
});
}
}
2010-07-23 05:41:45 +00:00
2011-10-24 22:47:17 +00:00
function itemTag(id) {
reply = prompt("{{$term}}");
2011-10-24 22:47:17 +00:00
if(reply && reply.length) {
2011-10-25 00:00:22 +00:00
reply = reply.replace('#','');
2011-10-24 22:47:17 +00:00
if(reply.length) {
commentBusy = true;
$('body').css('cursor', 'wait');
$.get('{{$baseurl}}/tagger/' + id + '?term=' + reply);
if(timer) clearTimeout(timer);
timer = setTimeout(updateInit,3000);
liking = 1;
2011-10-24 22:47:17 +00:00
}
}
}
function itemCancel() {
$("#jot-title").val('');
$("#profile-jot-text").val('');
2020-02-27 04:48:28 +00:00
$(".jot-poll-option input").val('');
2018-05-20 09:02:18 +00:00
$("#jot-category").tagsinput('removeAll');
2018-05-20 07:23:44 +00:00
postSaveChanges('clean');
{{if $reset}}
$(".jothidden").hide();
$("#profile-jot-text").removeClass('jot-expanded');
$("#profile-jot-reset").addClass('d-none');
2020-02-27 04:48:28 +00:00
$("#jot-poll-wrap").addClass('d-none');
2018-05-20 10:30:08 +00:00
$("#jot-preview-content").html('').hide();
2018-05-20 07:23:44 +00:00
editor = false;
{{else}}
window.history.back();
2018-05-20 07:23:44 +00:00
{{/if}}
}
function itemFiler(id) {
if($('#item-filer-dialog').length)
$('#item-filer-dialog').remove();
$.get('filer/', function(data){
$('body').append(data);
$('#item-filer-dialog').modal('show');
$("#filer_save").click(function(e){
e.preventDefault();
reply = $("#id_term").val();
if(reply && reply.length) {
commentBusy = true;
$('body').css('cursor', 'wait');
$.get('{{$baseurl}}/filer/' + id + '?term=' + reply, updateInit);
liking = 1;
$('#item-filer-dialog').modal('hide');
}
return false;
});
});
}
2014-02-05 01:12:13 +00:00
function itemBookmark(id) {
$.get('{{$baseurl}}/bookmarks?f=&item=' + id);
if(timer) clearTimeout(timer);
timer = setTimeout(updateInit,1000);
2014-02-05 01:12:13 +00:00
}
2014-05-30 03:09:21 +00:00
function itemAddToCal(id) {
2019-05-13 01:20:37 +00:00
$.get('{{$baseurl}}/calendar/add/' + id);
2014-05-30 03:09:21 +00:00
if(timer) clearTimeout(timer);
timer = setTimeout(updateInit,1000);
2014-05-30 03:09:21 +00:00
}
function jotReact(id,icon) {
if(id && icon) {
$.get('{{$baseurl}}/react?f=&postid=' + id + '&emoji=' + icon);
if(timer) clearTimeout(timer);
timer = setTimeout(updateInit,1000);
}
}
function jotClearLocation() {
2022-09-16 10:57:04 +00:00
$('#jot-lat').val('');
$('#jot-lon').val('');
$('#jot-location').val('');
jotLocateStatus();
jotCheckinStatus();
jotCheckoutStatus();
}
2022-02-18 01:38:12 +00:00
let initializeEmbedPhotoDialog = function () {
$('.embed-photo-selected-photo').each(function (index) {
$(this).removeClass('embed-photo-selected-photo');
});
getPhotoAlbumList();
$('#embedPhotoModalBodyAlbumDialog').off('click');
2017-04-13 21:20:09 +00:00
$('#embedPhotoModal').modal('show');
};
2022-02-18 01:38:12 +00:00
let choosePhotoFromAlbum = function (album) {
$.post("embedphotos/album", {name: album},
function(data) {
// alert(JSON.stringify(data));
if (data['status']) {
$('#embedPhotoModalLabel').html("{{$modalchooseimages}}");
$('#embedPhotoModalBodyAlbumDialog').html('\
2017-03-22 12:15:53 +00:00
<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>&nbsp\n\
{{$modaldiffalbum}}\n\
</a>\n\
</li>\n\
2017-03-22 12:15:53 +00:00
</div><br></div>')
$('#embedPhotoModalBodyAlbumDialog').append(data['content']);
$('#embedPhotoModalBodyAlbumDialog').click(function (evt) {
evt.preventDefault();
2022-02-18 01:38:12 +00:00
let image = document.getElementById(evt.target.id);
if (typeof($(image).parent()[0]) !== 'undefined') {
2022-02-18 01:38:12 +00:00
let imageparent = document.getElementById($(image).parent()[0].id);
$(imageparent).toggleClass('embed-photo-selected-photo');
2022-02-18 01:38:12 +00:00
let href = $(imageparent).attr('href');
$.post(href,
function(ddata) {
2023-02-27 22:10:22 +00:00
if (ddata['status']) {
2024-01-08 20:58:16 +00:00
addActiveEditorText(ddata['photolink']);
} else {
window.console.log("{{$modalerrorlink}}" + ':' + ddata['errormsg']);
}
return false;
},
'json');
$('#embedPhotoModalBodyAlbumDialog').html('');
$('#embedPhotoModalBodyAlbumDialog').off('click');
$('#embedPhotoModal').modal('hide');
}
});
$('#embedPhotoModalBodyAlbumListDialog').addClass('d-none');
$('#embedPhotoModalBodyAlbumDialog').removeClass('d-none');
} else {
window.console.log("{{$modalerroralbum}} " + JSON.stringify(album) + ':' + data['errormsg']);
}
return false;
},
'json');
};
2022-02-18 01:38:12 +00:00
let getPhotoAlbumList = function () {
2023-04-06 12:12:55 +00:00
$.post("embedphotos/filelist", {},
function(data) {
if (data['status']) {
2022-02-18 01:38:12 +00:00
let albums = data['albumlist']; //JSON.parse(data['albumlist']);
$('#embedPhotoModalLabel').html("{{$modalchoosealbum}}");
2017-03-22 12:15:53 +00:00
$('#embedPhotoModalBodyAlbumList').html('<ul class="nav nav-pills flex-column"></ul>');
2023-03-28 17:55:23 +00:00
for (let i=0; i < albums.length; i++) {
2022-02-18 01:38:12 +00:00
let albumName = albums[i].text;
2023-03-28 17:55:23 +00:00
let jsAlbumName = albums[i].jstext;
let albumLink = '<li class="nav-item">';
2023-03-28 17:55:23 +00:00
albumLink += '<a class="nav-link" href="#" '
+ 'onclick="choosePhotoFromAlbum(\'' + jsAlbumName + '\'); return false;">'
+ albumName + '</a>';
albumLink += '</li>';
$('#embedPhotoModalBodyAlbumList').find('ul').append(albumLink);
}
2017-03-22 12:15:53 +00:00
$('#embedPhotoModalBodyAlbumDialog').addClass('d-none');
$('#embedPhotoModalBodyAlbumListDialog').removeClass('d-none');
} else {
window.console.log("{{$modalerrorlist}}" + ':' + data['errormsg']);
}
return false;
},
'json');
};
2023-02-22 16:45:28 +00:00
// initialize drag-drop
function DragDropUploadInit() {
2022-02-18 01:38:12 +00:00
let filedrag = $("#profile-jot-text");
// file drop
filedrag.on("dragover", DragDropUploadFileHover);
filedrag.on("dragleave", DragDropUploadFileHover);
filedrag.on("drop", DragDropUploadFileSelectHandler);
}
2018-07-20 08:42:16 +00:00
// file drag hover
function DragDropUploadFileHover(e) {
if(e.type == 'dragover')
$(e.target).addClass('hover');
else
$(e.target).removeClass('hover');
}
// file selection
function DragDropUploadFileSelectHandler(e) {
// cancel event and hover styling
DragDropUploadFileHover(e);
// open editor if it isn't yet initialised
if (! editor) {
2018-07-20 08:42:16 +00:00
enableOnUser();
}
linkdrop(e);
}
2020-02-27 04:48:28 +00:00
function initPoll() {
$('#jot-poll-wrap').toggleClass('d-none');
}
function jotAddOption() {
2022-02-18 01:38:12 +00:00
let option = '<div class="jot-poll-option form-group"><input class="w-100 border-0" name="poll_answers[]" type="text" value="" placeholder="Option"><div class="poll-option-close"><i class="fa fa-close"></i></div></div>';
2020-02-27 04:48:28 +00:00
$('#jot-poll-options').append(option);
}
function jotRemoveOption(e) {
$(this).closest('.jot-poll-option').remove();
}
2022-04-21 21:46:21 +00:00
function initRecipe() {
$('#jot-recipe-wrap').toggleClass('d-none');
}
function jotAddIngredient() {
let option = '<div class="jot-ingredient form-group"><input class="w-100 border-0" name="poll_answers[]" type="text" value="" placeholder="Option"><div class="poll-option-close"><i class="fa fa-close"></i></div></div>';
$('#jot-poll-options').append(option);
}
function jotRemoveIngedient(e) {
$(this).closest('.jot-ingredient').remove();
}
2018-05-20 07:23:44 +00:00
function postSaveChanges(action) {
if({{$auto_save_draft}}) {
2022-02-18 01:38:12 +00:00
let doctype = $('#jot-webpage').val();
let postid = '-' + doctype + '-' + $('#jot-postid').val();
if(action != 'clean') {
localStorage.setItem("post_title" + postid, $("#jot-title").val());
localStorage.setItem("post_body" + postid, $("#profile-jot-text").val());
if($("#jot-category").length)
localStorage.setItem("post_category" + postid, $("#jot-category").val());
}
if(action == 'start') {
postSaveTimer = setTimeout(function () {
postSaveChanges('start');
},10000);
}
if(action == 'stop') {
clearTimeout(postSaveTimer);
postSaveTimer = null;
}
if(action == 'clean') {
clearTimeout(postSaveTimer);
postSaveTimer = null;
localStorage.removeItem("post_title" + postid);
localStorage.removeItem("post_body" + postid);
localStorage.removeItem("post_category" + postid);
}
}
2023-01-01 08:13:37 +00:00
}
</script>