aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authormrjive <mrjive@mrjive.it>2018-04-12 10:12:46 +0200
committerGitHub <noreply@github.com>2018-04-12 10:12:46 +0200
commitea36ebd0df3d7612e5a524b7a287f9c57b8783b3 (patch)
tree02d1ed484823bd2c2b34aa85f153af3e1cc3c85e /view/js
parenta7ff2cc5ea11afd7b832bef24866abfb0220d022 (diff)
parent3bd645033330c2db0952e57db1516274487c0712 (diff)
downloadvolse-hubzilla-ea36ebd0df3d7612e5a524b7a287f9c57b8783b3.tar.gz
volse-hubzilla-ea36ebd0df3d7612e5a524b7a287f9c57b8783b3.tar.bz2
volse-hubzilla-ea36ebd0df3d7612e5a524b7a287f9c57b8783b3.zip
Merge pull request #5 from redmatrix/dev
Dev
Diffstat (limited to 'view/js')
-rw-r--r--view/js/autocomplete.js13
-rw-r--r--view/js/main.js38
-rw-r--r--view/js/mod_help.js4
3 files changed, 51 insertions, 4 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 07b9bc449..69ccd1fe5 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -243,8 +243,19 @@ function string2bb(element) {
replace: basic_replace,
template: contact_format,
};
+
+ // Autocomplete forums
+ forums = {
+ match: /(^\!)([^\n]{3,})$/,
+ index: 2,
+ search: function(term, callback) { contact_search(term, callback, backend_url, 'f', [], spinelement='#nav-search-spinner'); },
+ replace: basic_replace,
+ template: contact_format
+ };
+
+
this.attr('autocomplete', 'off');
- var a = this.textcomplete([contacts], {className:'acpopup', maxCount:100, zIndex: 1020, appendTo:'nav'});
+ var a = this.textcomplete([contacts,forums], {className:'acpopup', maxCount:100, zIndex: 1020, appendTo:'nav'});
a.on('textComplete:select', function(e, value, strategy) { submit_form(this); });
};
})( jQuery );
diff --git a/view/js/main.js b/view/js/main.js
index e700c4e6e..ab950e4fb 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -25,13 +25,14 @@ var liveRecurse = 0;
var savedTitle = '';
var initialLoad = true;
-// Clear the session storage if we switch channel or log out
+// Clear the session and local storage if we switch channel or log out
var cache_uid = '';
if(sessionStorage.getItem('uid') !== null) {
cache_uid = sessionStorage.getItem('uid');
}
if(cache_uid !== localUser.toString()) {
sessionStorage.clear();
+ localStorage.clear();
sessionStorage.setItem('uid', localUser.toString());
}
@@ -166,6 +167,16 @@ function handle_comment_form(e) {
$('#' + commentElm).addClass('expanded').removeAttr('placeholder');
$('#' + commentElm).attr('tabindex','9');
$('#' + submitElm).attr('tabindex','10');
+
+ if(auto_save_draft) {
+ var commentBody = localStorage.getItem("comment_body");
+ if(commentBody && $('#' + commentElm).val() === '') {
+ $('#' + commentElm).val(commentBody);
+ }
+ } else {
+ localStorage.removeItem("comment_body");
+ }
+
form.find(':not(:visible)').show();
}
@@ -185,6 +196,30 @@ function handle_comment_form(e) {
form.find(':not(.comment-edit-text)').hide();
}
});
+
+ var commentSaveTimer = null;
+ var emptyCommentElm = form.find('.comment-edit-text').attr('id');
+ $(document).on('focusout','#' + emptyCommentElm,function(e){
+ if(commentSaveTimer)
+ clearTimeout(commentSaveTimer);
+ commentSaveChanges(true);
+ commentSaveTimer = null;
+ });
+
+ $(document).on('focusin','#' + emptyCommentElm,function(e){
+ commentSaveTimer = setTimeout(function () {
+ commentSaveChanges(false);
+ },10000);
+ });
+
+ function commentSaveChanges(isFinal = false) {
+ if(auto_save_draft) {
+ localStorage.setItem("comment_body", $('#' + emptyCommentElm).val());
+ if( !isFinal) {
+ commentSaveTimer = setTimeout(commentSaveChanges,10000);
+ }
+ }
+ }
}
function commentClose(obj, id) {
@@ -1106,6 +1141,7 @@ function post_comment(id) {
$("#comment-edit-form-" + id).serialize(),
function(data) {
if(data.success) {
+ localStorage.removeItem("comment_body");
$("#comment-edit-preview-" + id).hide();
$("#comment-edit-wrapper-" + id).hide();
$("#comment-edit-text-" + id).val('');
diff --git a/view/js/mod_help.js b/view/js/mod_help.js
index 8ee89dd61..a37207807 100644
--- a/view/js/mod_help.js
+++ b/view/js/mod_help.js
@@ -53,7 +53,7 @@ $(document).ready(function () {
.removeClass('selected-doco-nav')
.eq(i).addClass('selected-doco-nav');
if (typeof ($('#doco-side-toc li').eq(i).find('a').attr('href').split('#')[1]) !== 'undefined') {
- window.history.pushState({}, '', location.href.split('#')[0] + '#' + $('#doco-side-toc li').eq(i).find('a').attr('href').split('#')[1]);
+ window.history.replaceState({}, '', location.href.split('#')[0] + '#' + $('#doco-side-toc li').eq(i).find('a').attr('href').split('#')[1]);
}
}
});
@@ -100,7 +100,7 @@ $(document).ready(function () {
}
// Update the address bar to reflect the loaded language
- window.history.pushState({}, '', '/' + pathParts.join('/'));
+ window.history.replaceState({}, '', '/' + pathParts.join('/'));
// Highlight the language in the language selector that is currently viewed
$('.lang-selector').find('.lang-choice:contains("' + help_language + '")').addClass('active');