aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
Diffstat (limited to 'view/js')
-rw-r--r--view/js/acl.js12
-rw-r--r--view/js/autocomplete.js2
-rw-r--r--view/js/main.js564
-rw-r--r--view/js/mod_articles.js9
-rw-r--r--view/js/mod_cloud.js95
-rw-r--r--view/js/mod_defperms.js32
-rw-r--r--view/js/mod_hq.js10
-rw-r--r--view/js/mod_photos.js277
-rw-r--r--view/js/mod_pubstream.js5
9 files changed, 616 insertions, 390 deletions
diff --git a/view/js/acl.js b/view/js/acl.js
index e016158e9..6042b43ca 100644
--- a/view/js/acl.js
+++ b/view/js/acl.js
@@ -173,6 +173,12 @@ ACL.prototype.on_custom = function(event) {
that.deny_cid = [];
that.deny_gid = [];
+ $("#acl-list-content .acl-list-item img[data-src]").each(function(i, el) {
+ //Replace data-src attribute with src attribute for every image
+ $(el).attr('src', $(el).data("src"));
+ $(el).removeAttr("data-src");
+ });
+
that.update_view('custom');
that.on_submit();
@@ -408,10 +414,4 @@ ACL.prototype.populate = function(data) {
}
that.list_content.append(html);
});
-
- $("#acl-list-content .acl-list-item img[data-src]").each(function(i, el) {
- // Replace data-src attribute with src attribute for every image
- $(el).attr('src', $(el).data("src"));
- $(el).removeAttr("data-src");
- });
};
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 08cf97173..01def9900 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -289,7 +289,7 @@ function string2bb(element) {
$.fn.bbco_autocomplete = function(type) {
if(type=='bbcode') {
- var open_close_elements = ['bold', 'italic', 'underline', 'overline', 'strike', 'superscript', 'subscript', 'quote', 'code', 'open', 'spoiler', 'map', 'nobb', 'list', 'checklist', 'ul', 'ol', 'dl', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer', 'observer.language','embed', 'highlight'];
+ var open_close_elements = ['bold', 'italic', 'underline', 'overline', 'strike', 'superscript', 'subscript', 'quote', 'code', 'open', 'spoiler', 'map', 'nobb', 'list', 'checklist', 'ul', 'ol', 'dl', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer', 'observer.language','embed', 'highlight', 'url', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
var open_elements = ['observer.baseurl', 'observer.address', 'observer.photo', 'observer.name', 'observer.webname', 'observer.url', '*', 'hr', ];
var elements = open_close_elements.concat(open_elements);
diff --git a/view/js/main.js b/view/js/main.js
index e231dac60..a228e6fbc 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -1,5 +1,100 @@
+var src = null;
+var prev = null;
+var livetime = null;
+var msie = false;
+var stopped = false;
+var totStopped = false;
+var timer = null;
+var pr = 0;
+var liking = 0;
+var in_progress = false;
+var langSelect = false;
+var commentBusy = false;
+var last_popup_menu = null;
+var last_popup_button = null;
+var scroll_next = false;
+var next_page = 1;
+var page_load = true;
+var loadingPage = true;
+var pageHasMoreContent = true;
+var divmore_height = 400;
+var last_filestorage_id = null;
+var mediaPlaying = false;
+var contentHeightDiff = 0;
+var liveRecurse = 0;
+var savedTitle = '';
+
+$.ajaxSetup({cache: false});
+
+$(document).ready(function() {
+
+ $(document).on('click focus', '.comment-edit-form', handle_comment_form);
+
+ jQuery.timeago.settings.strings = {
+ prefixAgo : aStr['t01'],
+ prefixFromNow : aStr['t02'],
+ suffixAgo : aStr['t03'],
+ suffixFromNow : aStr['t04'],
+ seconds : aStr['t05'],
+ minute : aStr['t06'],
+ minutes : aStr['t07'],
+ hour : aStr['t08'],
+ hours : aStr['t09'],
+ day : aStr['t10'],
+ days : aStr['t11'],
+ month : aStr['t12'],
+ months : aStr['t13'],
+ year : aStr['t14'],
+ years : aStr['t15'],
+ wordSeparator : aStr['t16'],
+ numbers : aStr['t17'],
+ };
+
+ savedTitle = document.title;
+
+ updateInit();
+
+ $('a[rel^="#"]').click(function(e){
+ manage_popup_menu(this, e);
+ return;
+ });
+
+ // Allow folks to stop the ajax page updates with the pause/break key
+ $(document).keydown(function(event) {
+ if(event.keyCode == '8') {
+ var target = event.target || event.srcElement;
+ if (!/input|textarea/i.test(target.nodeName)) {
+ return false;
+ }
+ }
+
+ if(event.keyCode == '19' || (event.ctrlKey && event.which == '32')) {
+ event.preventDefault();
+ if(stopped === false) {
+ stopped = true;
+ if (event.ctrlKey) {
+ totStopped = true;
+ }
+ $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
+ } else {
+ unpause();
+ }
+ } else {
+ if (!totStopped) {
+ unpause();
+ }
+ }
+ });
-function confirmDelete() { return confirm(aStr.delitem); }
+ var e = document.getElementById('content-complete');
+ if(e)
+ pageHasMoreContent = false;
+
+});
+
+function confirmDelete() {
+ return confirm(aStr.delitem);
+}
function handle_comment_form(e) {
e.stopPropagation();
@@ -59,59 +154,6 @@ function handle_comment_form(e) {
});
}
-/*
-function commentOpenUI(obj, id) {
- $(document).unbind( "click.commentOpen", handler );
-
- var handler = function() {
- if(obj.value == aStr.comment) {
- obj.value = '';
- $("#comment-edit-text-" + id).addClass("comment-edit-text-full").removeClass("comment-edit-text-empty");
- // Choose an arbitrary tab index that's greater than what we're using in jot (3 of them)
- // The submit button gets tabindex + 1
- $("#comment-edit-text-" + id).attr('tabindex','9');
- $("#comment-edit-submit-" + id).attr('tabindex','10');
- $("#comment-tools-" + id).show();
- $("#comment-edit-anon-" + id).show();
- }
- };
-
- $(document).bind( "click.commentOpen", handler );
-}
-
-function commentCloseUI(obj, id) {
- var form_id = $(obj)[0].form.id;
-
- $('#' + form_id).on('click', function(e) {
- $(document).unbind( "click.commentClose", handler );
- });
-
- var handler = function() {
- if($('#comment-edit-text-' + id).val() === '') {
- $('#comment-edit-text-' + id).val(aStr.comment);
- $("#comment-edit-text-" + id).removeClass("comment-edit-text-full").addClass("comment-edit-text-empty");
- $("#comment-edit-text-" + id).removeAttr('tabindex');
- $("#comment-edit-submit-" + id).removeAttr('tabindex');
- $("#comment-tools-" + id).hide();
- $("#comment-edit-anon-" + id).hide();
- }
- };
-
- $(document).bind( "click.commentClose", handler );
-}
-
-function commentOpen(obj, id) {
- if(obj.value == aStr.comment) {
- obj.value = '';
- $("#comment-edit-text-" + id).addClass("expanded");
- $("#mod-cmnt-wrap-" + id).show();
- $("#comment-tools-" + id).show();
- $("#comment-edit-anon-" + id).show();
- return true;
- }
- return false;
-}
-*/
function commentClose(obj, id) {
if(obj.value === '') {
obj.value = aStr.comment;
@@ -124,7 +166,6 @@ function commentClose(obj, id) {
return false;
}
-
function showHideCommentBox(id) {
if( $('#comment-edit-form-' + id).is(':visible')) {
$('#comment-edit-form-' + id).hide();
@@ -298,9 +339,9 @@ function closeMenu(theID) {
function markRead(notifType) {
$.get('ping?f=&markRead='+notifType);
- if(timer) clearTimeout(timer);
$('.' + notifType + '-button').hide();
- timer = setTimeout(NavUpdate,2000);
+ if(timer) clearTimeout(timer);
+ timer = setTimeout(updateInit,2000);
}
function markItemRead(itemId) {
@@ -308,191 +349,73 @@ function markItemRead(itemId) {
$('.unseen-wall-indicator-'+itemId).hide();
}
+function manage_popup_menu(w,e) {
+ menu = $( $(w).attr('rel') );
-var src = null;
-var prev = null;
-var livetime = null;
-var msie = false;
-var stopped = false;
-var totStopped = false;
-var timer = null;
-var pr = 0;
-var liking = 0;
-var in_progress = false;
-var langSelect = false;
-var commentBusy = false;
-var last_popup_menu = null;
-var last_popup_button = null;
-var scroll_next = false;
-var next_page = 1;
-var page_load = true;
-var loadingPage = true;
-var pageHasMoreContent = true;
-var updateCountsOnly = false;
-var divmore_height = 400;
-var last_filestorage_id = null;
-var mediaPlaying = false;
-var contentHeightDiff = 0;
-var liveRecurse = 0;
-var savedTitle = '';
-
-$(function() {
- $.ajaxSetup({cache: false});
-
- msie = false; // $.browser.msie ;
-
- var e = document.getElementById('content-complete');
- if(e)
- pageHasMoreContent = false;
-
- /* setup onoff widgets */
- $(".onoff input").each(function(){
- val = $(this).val();
- id = $(this).attr("id");
- $("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
- });
- $(".onoff > a").click(function(event){
- event.preventDefault();
- var input = $(this).siblings("input");
- var val = 1-input.val();
- var id = input.attr("id");
- $("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
- $("#"+id+"_onoff ."+ (val==1?"on":"off")).removeClass("hidden");
- input.val(val);
- //console.log(id);
- });
-
- /* setup field_richtext */
- //setupFieldRichtext();
-
-
- /* Turn elements with one of our special rel tags into popup menus */
- /* CHANGES: let bootstrap handle popups and only do the loading here */
-
+ /* notification menus are loaded dynamically
+ * - here we find a rel tag to figure out what type of notification to load */
- $('a[rel^="#"]').click(function(e){
- manage_popup_menu(this, e);
- return;
- });
+ var loader_source = $(menu).attr('rel');
- function manage_popup_menu(w,e) {
- menu = $( $(w).attr('rel') );
+ if(typeof(loader_source) != 'undefined' && loader_source.length) {
+ notify_popup_loader(loader_source);
+ }
+}
- /* notification menus are loaded dynamically
- * - here we find a rel tag to figure out what type of notification to load */
+function notificationsUpdate() {
+ var pingCmd = 'ping' + ((localUser != 0) ? '?f=&uid=' + localUser : '');
- var loader_source = $(menu).attr('rel');
+ $.get(pingCmd,function(data) {
- if(typeof(loader_source) != 'undefined' && loader_source.length) {
- notify_popup_loader(loader_source);
+ if(data.invalid == 1) {
+ window.location.href=window.location.href;
}
- }
- NavUpdate();
- // Allow folks to stop the ajax page updates with the pause/break key
- $(document).keydown(function(event) {
- if(event.keyCode == '8') {
- var target = event.target || event.srcElement;
- if (!/input|textarea/i.test(target.nodeName)) {
- return false;
- }
+ if(data.network || data.home || data.intros || data.register || data.mail || data.all_events || data.notify || data.files || data.pubs) {
+ $('.notifications-btn').css('opacity', 1);
+ $('#no_notifications').hide();
}
-
- if(event.keyCode == '19' || (event.ctrlKey && event.which == '32')) {
- event.preventDefault();
- if(stopped === false) {
- stopped = true;
- if (event.ctrlKey) {
- totStopped = true;
- }
- $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
- } else {
- unpause();
- }
- } else {
- if (!totStopped) {
- unpause();
- }
+ else {
+ $('.notifications-btn').css('opacity', 0.5);
+ $('#navbar-collapse-1').removeClass('show');
+ $('#no_notifications').show();
}
- });
-});
-function NavUpdate() {
- if(liking)
- $('.like-rotator').hide();
-
- if((! stopped) && (! mediaPlaying)) {
- var pingCmd = 'ping' + ((localUser != 0) ? '?f=&uid=' + localUser : '');
-
- $.get(pingCmd,function(data) {
-
- if(data.invalid == 1) {
- window.location.href=window.location.href;
- }
-
- if(! updateCountsOnly) {
- // start live update
-
- if($('#live-network').length) { src = 'network'; liveUpdate(); }
- if($('#live-channel').length) { src = 'channel'; liveUpdate(); }
- if($('#live-pubstream').length) { src = 'pubstream'; liveUpdate(); }
- if($('#live-display').length) { src = 'display'; liveUpdate(); }
- if($('#live-search').length) { src = 'search'; liveUpdate(); }
- // if($('#live-cards').length) { src = 'cards'; liveUpdate(); }
-
- if($('#live-photos').length || $('#live-cards').length) {
- if(liking) {
- liking = 0;
- window.location.href=window.location.href;
- }
- }
- }
+ if(data.home || data.intros || data.register || data.mail || data.notify || data.files) {
+ $('.notifications-btn-icon').removeClass('fa-exclamation-circle');
+ $('.notifications-btn-icon').addClass('fa-exclamation-triangle');
+ }
+ if(!data.home && !data.intros && !data.register && !data.mail && !data.notify && !data.files) {
+ $('.notifications-btn-icon').removeClass('fa-exclamation-triangle');
+ $('.notifications-btn-icon').addClass('fa-exclamation-circle');
+ }
- updateCountsOnly = false;
+ $.each(data, function(index, item) {
+ //do not process those
+ var arr = ['notice', 'info', 'invalid'];
+ if(arr.indexOf(index) !== -1)
+ return;
- if(data.network || data.home || data.intros || data.register || data.mail || data.all_events || data.notify || data.files || data.pubs) {
- $('#notifications-btn').css('opacity', 1);
- }
- else {
- $('#notifications-btn').css('opacity', 0.5);
- $('#navbar-collapse-1').removeClass('show');
- }
-
- if(data.home || data.intros || data.register || data.mail || data.notify || data.files) {
- $('#notifications-btn-icon').removeClass('fa-exclamation-circle');
- $('#notifications-btn-icon').addClass('fa-exclamation-triangle');
- }
- if(!data.home && !data.intros && !data.register && !data.mail && !data.notify && !data.files) {
- $('#notifications-btn-icon').removeClass('fa-exclamation-triangle');
- $('#notifications-btn-icon').addClass('fa-exclamation-circle');
+ if(item == 0) {
+ $('.' + index + '-button').fadeOut();
+ } else {
+ $('.' + index + '-button').fadeIn();
+ $('.' + index + '-update').html(item);
}
+ });
- $.each(data, function(index, item) {
- //do not process those
- var arr = ['notice', 'info', 'invalid'];
- if(arr.indexOf(index) !== -1)
- return;
-
- if(item == 0) {
- $('.' + index + '-button').hide();
- } else {
- $('.' + index + '-button').show();
- $('.' + index + '-update').html(item);
- }
- });
-
- $.jGrowl.defaults.closerTemplate = '<div>[ ' + aStr.closeAll + ']</div>';
+ $.jGrowl.defaults.closerTemplate = '<div>[ ' + aStr.closeAll + ']</div>';
- $(data.notice).each(function() {
- $.jGrowl(this.message, { sticky: true, theme: 'notice' });
- });
+ $(data.notice).each(function() {
+ $.jGrowl(this.message, { sticky: true, theme: 'notice' });
+ });
- $(data.info).each(function(){
- $.jGrowl(this.message, { sticky: false, theme: 'info', life: 10000 });
- });
- }) ;
- }
- timer = setTimeout(NavUpdate, updateInterval);
+ $(data.info).each(function(){
+ $.jGrowl(this.message, { sticky: false, theme: 'info', life: 10000 });
+ });
+ })
+ if(timer) clearTimeout(timer);
+ timer = setTimeout(updateInit,updateInterval);
}
function contextualHelp() {
@@ -696,7 +619,6 @@ function updateConvItems(mode,data) {
}
$(document.body).trigger("sticky_kit:recalc");
-
}
function collapseHeight() {
@@ -745,21 +667,48 @@ function collapseHeight() {
console.log('collapsed above viewport count: ' + i);
$(window).scrollTop(sval);
}
+}
+
+function updateInit() {
+ if($('#live-network').length) { src = 'network'; }
+ if($('#live-channel').length) { src = 'channel'; }
+ if($('#live-pubstream').length) { src = 'pubstream'; }
+ if($('#live-display').length) { src = 'display'; }
+ if($('#live-hq').length) { src = 'hq'; }
+ if($('#live-search').length) { src = 'search'; }
+ // if($('#live-cards').length) { src = 'cards'; }
+ // if($('#live-articles').length) { src = 'articles'; }
+
+ if(! src) {
+ notificationsUpdate();
+ }
+ else {
+ liveUpdate();
+ }
+ if($('#live-photos').length || $('#live-cards').length || $('#live-articles').length ) {
+ if(liking) {
+ liking = 0;
+ window.location.href=window.location.href;
+ }
+ }
}
-function liveUpdate() {
+function liveUpdate(notify_id) {
if(typeof profile_uid === 'undefined') profile_uid = false; /* Should probably be unified with channelId defined in head.tpl */
+
if((src === null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
- if(($('.comment-edit-text.expanded').length) || (in_progress)) {
+
+ if(($('.comment-edit-text.expanded').length) || (in_progress) || (mediaPlaying)) {
if(livetime) {
clearTimeout(livetime);
}
livetime = setTimeout(liveUpdate, 10000);
return;
}
+
if(livetime !== null)
livetime = null;
@@ -816,6 +765,15 @@ function liveUpdate() {
// else data was valid - reset the recursion counter
liveRecurse = 0;
+ if(typeof notify_id !== 'undefined') {
+ $.post(
+ "hq",
+ {
+ "notify_id" : notify_id
+ }
+ );
+ }
+
var dready = new Date();
console.log('DATA ready in: ' + (dready - dstart)/1000 + ' seconds.');
@@ -839,20 +797,6 @@ function liveUpdate() {
in_progress = false;
- // FIXME - the following lines were added so that almost
- // immediately after we update the posts on the page, we
- // re-check and update the notification counts.
- // As it turns out this causes a bit of an inefficiency
- // as we're pinging twice for every update, once before
- // and once after. A btter way to do this is to rewrite
- // NavUpdate and perhaps LiveUpdate so that we check for
- // post updates first and only call the notification ping
- // once.
-
- updateCountsOnly = true;
- if(timer) clearTimeout(timer);
- timer = setTimeout(NavUpdate,10);
-
});
}
else {
@@ -864,22 +808,11 @@ function liveUpdate() {
in_progress = false;
- // FIXME - the following lines were added so that almost
- // immediately after we update the posts on the page, we
- // re-check and update the notification counts.
- // As it turns out this causes a bit of an inefficiency
- // as we're pinging twice for every update, once before
- // and once after. A btter way to do this is to rewrite
- // NavUpdate and perhaps LiveUpdate so that we check for
- // post updates first and only call the notification ping
- // once.
-
- updateCountsOnly = true;
- if(timer) clearTimeout(timer);
- timer = setTimeout(NavUpdate,10);
-
}
+ })
+ .done(function() {
+ notificationsUpdate();
});
}
@@ -943,6 +876,7 @@ function notify_popup_loader(notifyType) {
var notifications_tpl= unescape($("#nav-notifications-template[rel=template]").html());
var notifications_all = unescape($('<div>').append( $("#nav-" + notifyType + "-see-all").clone() ).html()); //outerHtml hack
var notifications_mark = unescape($('<div>').append( $("#nav-" + notifyType + "-mark-all").clone() ).html()); //outerHtml hack
+ var notifications_tt_only = unescape($('<div>').append( $("#tt-" + notifyType + "-only").clone() ).html()); //outerHtml hack
var notifications_empty = unescape($("#nav-" + notifyType + "-menu").html());
var notify_menu = $("#nav-" + notifyType + "-menu");
@@ -954,14 +888,15 @@ function notify_popup_loader(notifyType) {
window.location.href=window.location.href;
}
- $("#navbar-" + notifyType + "-menu").html(notifications_all + notifications_mark);
- $("#nav-" + notifyType + "-menu").html(notifications_all + notifications_mark);
+ $("#navbar-" + notifyType + "-menu").html(notifications_all + notifications_mark + notifications_tt_only);
+ $("#nav-" + notifyType + "-menu").html(notifications_all + notifications_mark + notifications_tt_only);
+
$("." + notifyType + "-update").html(data.notify.length);
$(data.notify).each(function() {
- html = navbar_notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid);
+ html = navbar_notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top);
$("#navbar-" + notifyType + "-menu").append(html);
- html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid);
+ html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top);
$("#nav-" + notifyType + "-menu").append(html);
});
@@ -970,8 +905,12 @@ function notify_popup_loader(notifyType) {
$(el).attr('src', $(el).data("src"));
$(el).removeAttr("data-src");
});
+
+ if($('#tt-' + notifyType + '-only').hasClass('active'))
+ $('#nav-' + notifyType + '-menu [data-thread_top=false]').hide();
});
+
setTimeout(function() {
if(notify_menu.hasClass('show')) {
console.log('updating ' + notifyType + ' notifications...');
@@ -980,7 +919,6 @@ function notify_popup_loader(notifyType) {
}, 1000);
}
-
// Since our ajax calls are asynchronous, we will give a few
// seconds for the first ajax call (setting like/dislike), then
// run the updater to pick up any changes and display on the page.
@@ -989,13 +927,11 @@ function notify_popup_loader(notifyType) {
// events have completed and therefore there won't be any
// visible feedback that anything changed without all this
// trickery. This still could cause confusion if the "like" ajax call
-// is delayed and NavUpdate runs before it completes.
-
-
+// is delayed and updateInit runs before it completes.
function dolike(ident, verb) {
unpause();
$('#like-rotator-' + ident.toString()).show();
- $.get('like/' + ident.toString() + '?verb=' + verb, NavUpdate );
+ $.get('like/' + ident.toString() + '?verb=' + verb, updateInit );
liking = 1;
}
@@ -1003,7 +939,6 @@ function doprofilelike(ident, verb) {
$.get('like/' + ident + '?verb=' + verb, function() { window.location.href=window.location.href; });
}
-
function dropItem(url, object) {
var confirm = confirmDelete();
if(confirm) {
@@ -1025,20 +960,17 @@ function dropItem(url, object) {
function dosubthread(ident) {
unpause();
$('#like-rotator-' + ident.toString()).show();
- $.get('subthread/sub/' + ident.toString(), NavUpdate );
+ $.get('subthread/sub/' + ident.toString(), updateInit );
liking = 1;
}
-
function dounsubthread(ident) {
unpause();
$('#like-rotator-' + ident.toString()).show();
- $.get('subthread/unsub/' + ident.toString(), NavUpdate );
+ $.get('subthread/unsub/' + ident.toString(), updateInit );
liking = 1;
}
-
-
function dostar(ident) {
ident = ident.toString();
$('#like-rotator-' + ident).show();
@@ -1121,7 +1053,7 @@ function post_comment(id) {
$(document).unbind( "click.commentOpen");
}
if(timer) clearTimeout(timer);
- timer = setTimeout(NavUpdate,1500);
+ timer = setTimeout(updateInit,1500);
}
if(data.reload) {
window.location.href=data.reload;
@@ -1156,7 +1088,7 @@ function importElement(elem) {
{ "element" : elem },
function(data) {
if(timer) clearTimeout(timer);
- timer = setTimeout(NavUpdate,10);
+ timer = setTimeout(updateInit,10);
}
);
return false;
@@ -1165,7 +1097,6 @@ function importElement(elem) {
function preview_post() {
$("#jot-preview").val("1");
$("#jot-preview-content").show();
-// tinyMCE.triggerSave();
$.post(
"item",
$("#profile-jot-form").serialize(),
@@ -1271,60 +1202,6 @@ function checkboxhighlight(box) {
}
}
-
-// code from http://www.tinymce.com/wiki.php/How-to_implement_a_custom_file_browser
-function fcFileBrowser (field_name, url, type, win) {
- /* TODO: If you work with sessions in PHP and your client doesn't accept cookies you might need to carry
- the session name and session ID in the request string (can look like this: "?PHPSESSID=88p0n70s9dsknra96qhuk6etm5").
- These lines of code extract the necessary parameters and add them back to the filebrowser URL again. */
-
- var cmsURL = baseurl+"/fbrowser/"+type+"/";
-
- tinyMCE.activeEditor.windowManager.open({
- file : cmsURL,
- title : 'File Browser',
- width : 420, // Your dimensions may differ - toy around with them!
- height : 400,
- resizable : "yes",
- inline : "yes", // This parameter only has an effect if you use the inlinepopups plugin!
- close_previous : "no"
- }, {
- window : win,
- input : field_name
- });
- return false;
-}
-
-/*
-function setupFieldRichtext(){
-
- tinyMCE.init({
- theme : "advanced",
- mode : "specific_textareas",
- editor_selector: "fieldRichtext",
- plugins : "bbcode,paste, inlinepopups",
- theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
- theme_advanced_buttons2 : "",
- theme_advanced_buttons3 : "",
- theme_advanced_toolbar_location : "top",
- theme_advanced_toolbar_align : "center",
- theme_advanced_blockformats : "blockquote,code",
- paste_text_sticky : true,
- entity_encoding : "raw",
- add_unload_trigger : false,
- remove_linebreaks : false,
- force_p_newlines : false,
- force_br_newlines : true,
- forced_root_block : '',
- convert_urls: false,
- content_css: baseurl+"/view/custom_tinymce.css",
- theme_advanced_path : false,
- file_browser_callback : "fcFileBrowser",
- });
-
-}
-*/
-
/**
* sprintf in javascript
* "{0} and {1}".format('zero','uno');
@@ -1337,6 +1214,7 @@ String.prototype.format = function() {
}
return formatted;
};
+
// Array Remove
Array.prototype.remove = function(item) {
to = undefined;
@@ -1346,34 +1224,6 @@ Array.prototype.remove = function(item) {
return this.push.apply(this, rest);
};
-$(document).ready(function() {
-
- $(document).on('click focus', '.comment-edit-form', handle_comment_form);
-
- jQuery.timeago.settings.strings = {
- prefixAgo : aStr['t01'],
- prefixFromNow : aStr['t02'],
- suffixAgo : aStr['t03'],
- suffixFromNow : aStr['t04'],
- seconds : aStr['t05'],
- minute : aStr['t06'],
- minutes : aStr['t07'],
- hour : aStr['t08'],
- hours : aStr['t09'],
- day : aStr['t10'],
- days : aStr['t11'],
- month : aStr['t12'],
- months : aStr['t13'],
- year : aStr['t14'],
- years : aStr['t15'],
- wordSeparator : aStr['t16'],
- numbers : aStr['t17'],
- };
-
- savedTitle = document.title;
-
-});
-
function zFormError(elm,x) {
if(x) {
$(elm).addClass("zform-error");
@@ -1441,8 +1291,6 @@ function addeditortext(data) {
var currentText = $("#profile-jot-text").val();
$("#profile-jot-text").val(currentText + data);
}
- else
- tinyMCE.execCommand('mceInsertRawHTML',false,data);
}
function h2b(s) {
diff --git a/view/js/mod_articles.js b/view/js/mod_articles.js
new file mode 100644
index 000000000..8b31c0f52
--- /dev/null
+++ b/view/js/mod_articles.js
@@ -0,0 +1,9 @@
+$(document).ready( function() {
+ $(".autotime").timeago();
+
+ /* autocomplete @nicknames */
+ $(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl?f=&n=1");
+ /* autocomplete bbcode */
+ $(".comment-edit-form textarea").bbco_autocomplete('bbcode');
+
+}); \ No newline at end of file
diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js
index 8af90863e..031895caf 100644
--- a/view/js/mod_cloud.js
+++ b/view/js/mod_cloud.js
@@ -16,26 +16,69 @@ function UploadInit() {
var fileselect = $("#files-upload");
var filedrag = $("#cloud-drag-area");
var submit = $("#upload-submit");
+ var count = 1;
- // is XHR2 available?
- var xhr = new XMLHttpRequest();
- if (xhr.upload) {
+
+ $('#invisible-cloud-file-upload').fileupload({
+ url: 'file_upload',
+ dataType: 'json',
+ dropZone: filedrag,
+ maxChunkSize: 4 * 1024 * 1024,
- // file select
- fileselect.attr("multiple", 'multiple');
- fileselect.on("change", UploadFileSelectHandler);
+ add: function(e,data) {
+ $(data.files).each( function() { this.count = ++ count; prepareHtml(this); });
+
+ var allow_cid = ($('#ajax-upload-files').data('allow_cid') || []);
+ var allow_gid = ($('#ajax-upload-files').data('allow_gid') || []);
+ var deny_cid = ($('#ajax-upload-files').data('deny_cid') || []);
+ var deny_gid = ($('#ajax-upload-files').data('deny_gid') || []);
- // file submit
- submit.on("click", fileselect, UploadFileSelectHandler);
+ $('.acl-field').remove();
- // file drop
- filedrag.on("dragover", DragDropUploadFileHover);
- filedrag.on("dragleave", DragDropUploadFileHover);
- filedrag.on("drop", DragDropUploadFileSelectHandler);
- }
+ $(allow_gid).each(function(i,v) {
+ $('#ajax-upload-files').append("<input class='acl-field' type='hidden' name='group_allow[]' value='"+v+"'>");
+ });
+ $(allow_cid).each(function(i,v) {
+ $('#ajax-upload-files').append("<input class='acl-field' type='hidden' name='contact_allow[]' value='"+v+"'>");
+ });
+ $(deny_gid).each(function(i,v) {
+ $('#ajax-upload-files').append("<input class='acl-field' type='hidden' name='group_deny[]' value='"+v+"'>");
+ });
+ $(deny_cid).each(function(i,v) {
+ $('#ajax-upload-files').append("<input class='acl-field' type='hidden' name='contact_deny[]' value='"+v+"'>");
+ });
+
+ data.formData = $('#ajax-upload-files').serializeArray();
+
+ data.submit();
+ },
+
+
+ progress: function(e,data) {
+
+ // there will only be one file, the one we are looking for
+
+ $(data.files).each( function() {
+ var idx = this.count;
+
+ // Dynamically update the percentage complete displayed in the file upload list
+ $('#upload-progress-' + idx).html(Math.round(data.loaded / data.total * 100) + '%');
+ $('#upload-progress-bar-' + idx).css('background-size', Math.round(data.loaded / data.total * 100) + '%');
+
+ });
+
+
+ },
+
+
+ stop: function(e,data) {
+ window.location.href = window.location.href;
+ }
+
+ });
+
+ $('#upload-submit').click(function(event) { event.preventDefault(); $('#invisible-cloud-file-upload').trigger('click'); return false;});
- window.filesToUpload = 0;
- window.fileUploadsCompleted = 0;
}
// file drag hover
@@ -84,8 +127,9 @@ function UploadFileSelectHandler(e) {
}
}
-function prepareHtml(f, i) {
- var num = i - 1;
+function prepareHtml(f) {
+ var num = f.count - 1;
+ var i = f.count;
$('#cloud-index #new-upload-progress-bar-' + num.toString()).after(
'<tr id="new-upload-' + i + '" class="new-upload">' +
'<td><i class="fa ' + getIconFromType(f.type) + '" title="' + f.type + '"></i></td>' +
@@ -158,6 +202,7 @@ function getIconFromType(type) {
// upload files
function UploadFile(file, idx) {
+
window.filesToUpload = window.filesToUpload + 1;
var xhr = new XMLHttpRequest();
@@ -202,15 +247,15 @@ function UploadFile(file, idx) {
});
// POST to the entire cloud path
- xhr.open('post', 'file_upload', true);
+// xhr.open('post', 'file_upload', true);
- var formfields = $("#ajax-upload-files").serializeArray();
+// var formfields = $("#ajax-upload-files").serializeArray();
- var data = new FormData();
- $.each(formfields, function(i, field) {
- data.append(field.name, field.value);
- });
- data.append('userfile', file);
+// var data = new FormData();
+// $.each(formfields, function(i, field) {
+// data.append(field.name, field.value);
+// });
+// data.append('userfile', file);
- xhr.send(data);
+// xhr.send(data);
}
diff --git a/view/js/mod_defperms.js b/view/js/mod_defperms.js
new file mode 100644
index 000000000..c89142579
--- /dev/null
+++ b/view/js/mod_defperms.js
@@ -0,0 +1,32 @@
+$(document).ready(function() {
+
+ $('#id_permcat').change(function() {
+ $('.loading-role-rotator').show();
+ var permName = $('#id_permcat').val();
+ loadConnectionRole(permName);
+ });
+
+
+});
+
+
+function loadConnectionRole(name) {
+
+ if(! name)
+ name = 'default';
+
+ $('.defperms-edit input').each(function() {
+ if(! $(this).is(':disabled'))
+ $(this).removeAttr('checked');
+ });
+
+ $.get('permcat/' + name, function(data) {
+ $(data.perms).each(function() {
+ if(this.value)
+ $('#id_perms_' + this.name).attr('checked','checked');
+ });
+ $('.loading-role-rotator').hide();
+ });
+}
+
+
diff --git a/view/js/mod_hq.js b/view/js/mod_hq.js
new file mode 100644
index 000000000..b321382bd
--- /dev/null
+++ b/view/js/mod_hq.js
@@ -0,0 +1,10 @@
+$(document).on('click', '#jot-toggle', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+
+ $(this).toggleClass('active');
+ $(window).scrollTop(0);
+ $('#jot-popup').toggle();
+ $('#profile-jot-text').focus();
+
+});
diff --git a/view/js/mod_photos.js b/view/js/mod_photos.js
index cbc1d8fa1..bf926c692 100644
--- a/view/js/mod_photos.js
+++ b/view/js/mod_photos.js
@@ -3,6 +3,11 @@
*/
$(document).ready(function() {
+ // call initialization file
+ if (window.File && window.FileList && window.FileReader) {
+ UploadInit();
+ }
+
$("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'a', false, function(data) {
$("#photo-edit-newtag").val('@' + data.name);
});
@@ -18,3 +23,275 @@ function showHideBodyTextarea() {
else
$('#body-textarea').slideUp();
}
+
+// initialize
+function UploadInit() {
+
+ var nickname = $('#invisible-photos-file-upload').data('nickname');
+ var fileselect = $("#photos-upload-choose");
+ var filedrag = $("#photos-upload-form");
+ var submit = $("#dbtn-submit");
+ var count = 1;
+
+ $('#invisible-photos-file-upload').fileupload({
+ url: 'photos/' + nickname,
+ dataType: 'json',
+ dropZone: filedrag,
+ maxChunkSize: 4 * 1024 * 1024,
+
+ add: function(e,data) {
+ $(data.files).each( function() { this.count = ++ count; prepareHtml(this); });
+
+ var allow_cid = ($('#photos-upload-form').data('allow_cid') || []);
+ var allow_gid = ($('#photos-upload-form').data('allow_gid') || []);
+ var deny_cid = ($('#photos-upload-form').data('deny_cid') || []);
+ var deny_gid = ($('#photos-upload-form').data('deny_gid') || []);
+
+ $('.acl-field').remove();
+
+ $(allow_gid).each(function(i,v) {
+ $('#photos-upload-form').append("<input class='acl-field' type='hidden' name='group_allow[]' value='"+v+"'>");
+ });
+ $(allow_cid).each(function(i,v) {
+ $('#photos-upload-form').append("<input class='acl-field' type='hidden' name='contact_allow[]' value='"+v+"'>");
+ });
+ $(deny_gid).each(function(i,v) {
+ $('#photos-upload-form').append("<input class='acl-field' type='hidden' name='group_deny[]' value='"+v+"'>");
+ });
+ $(deny_cid).each(function(i,v) {
+ $('#photos-upload-form').append("<input class='acl-field' type='hidden' name='contact_deny[]' value='"+v+"'>");
+ });
+
+ data.formData = $('#photos-upload-form').serializeArray();
+
+ data.submit();
+ },
+
+ progress: function(e,data) {
+
+ // there will only be one file, the one we are looking for
+
+ $(data.files).each( function() {
+ var idx = this.count;
+
+ // Dynamically update the percentage complete displayed in the file upload list
+ $('#upload-progress-' + idx).html(Math.round(data.loaded / data.total * 100) + '%');
+ $('#upload-progress-bar-' + idx).css('background-size', Math.round(data.loaded / data.total * 100) + '%');
+
+ });
+
+
+ },
+
+
+ stop: function(e,data) {
+ window.location.href = window.location.href;
+ }
+
+ });
+
+ $('#dbtn-submit').click(function(event) { event.preventDefault(); $('#invisible-photos-file-upload').trigger('click'); return false;});
+
+
+
+
+ // is XHR2 available?
+// var xhr = new XMLHttpRequest();
+// if (xhr.upload) {
+
+ // file select
+// fileselect.attr("multiple", 'multiple');
+// fileselect.on("change", UploadFileSelectHandler);
+
+ // file submit
+// submit.on("click", fileselect, UploadFileSelectHandler);
+
+ // 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.currentTarget.className = (e.type == "dragover" ? "hover" : "");
+}
+
+// file selection via drag/drop
+function DragDropUploadFileSelectHandler(e) {
+ // cancel event and hover styling
+ DragDropUploadFileHover(e);
+
+ // fetch FileList object
+ var files = e.target.files || e.originalEvent.dataTransfer.files;
+
+ $('.new-upload').remove();
+
+ // process all File objects
+ for (var i = 0, f; f = files[i]; i++) {
+ prepareHtml(f, i);
+ UploadFile(f, i);
+ }
+}
+
+// file selection via input
+function UploadFileSelectHandler(e) {
+ // fetch FileList object
+ if(e.target.id === 'dbtn-submit') {
+ e.preventDefault();
+ var files = e.data[0].files;
+ }
+ if(e.target.id === 'photos-upload-choose') {
+ $('.new-upload').remove();
+ var files = e.target.files;
+ }
+
+ // process all File objects
+ for (var i = 0, f; f = files[i]; i++) {
+ if(e.target.id === 'photos-upload-choose')
+ prepareHtml(f, i);
+ if(e.target.id === 'dbtn-submit') {
+ UploadFile(f, i);
+ }
+ }
+}
+
+function prepareHtml(f) {
+
+ var num = f.count - 1;
+ var i = f.count;
+
+ $('#upload-index #new-upload-progress-bar-' + num.toString()).after(
+ '<tr id="new-upload-' + i + '" class="new-upload">' +
+ '<td width="1%"><i class="fa ' + getIconFromType(f.type) + '" title="' + f.type + '"></i></td>' +
+ '<td width="96%">' + f.name + '</td>' +
+ '<td id="upload-progress-' + i + '" width="1%"></td>' +
+ '<td class="d-none d-md-table-cell" width="1%">' + formatSizeUnits(f.size) + '</td>' +
+ '</tr>' +
+ '<tr id="new-upload-progress-bar-' + i + '" class="new-upload">' +
+ '<td id="upload-progress-bar-' + i + '" colspan="4" class="upload-progress-bar"></td>' +
+ '</tr>'
+ );
+}
+
+function formatSizeUnits(bytes){
+ if (bytes>=1000000000) {bytes=(bytes/1000000000).toFixed(2)+' GB';}
+ else if (bytes>=1000000) {bytes=(bytes/1000000).toFixed(2)+' MB';}
+ else if (bytes>=1000) {bytes=(bytes/1000).toFixed(2)+' KB';}
+ else if (bytes>1) {bytes=bytes+' bytes';}
+ else if (bytes==1) {bytes=bytes+' byte';}
+ else {bytes='0 byte';}
+ return bytes;
+}
+
+// this is basically a js port of include/text.php getIconFromType() function
+function getIconFromType(type) {
+ var map = {
+ //Common file
+ 'application/octet-stream': 'fa-file-o',
+ //Text
+ 'text/plain': 'fa-file-text-o',
+ 'application/msword': 'fa-file-word-o',
+ 'application/pdf': 'fa-file-pdf-o',
+ 'application/vnd.oasis.opendocument.text': 'fa-file-word-o',
+ 'application/epub+zip': 'fa-book',
+ //Spreadsheet
+ 'application/vnd.oasis.opendocument.spreadsheet': 'fa-file-excel-o',
+ 'application/vnd.ms-excel': 'fa-file-excel-o',
+ //Image
+ 'image/jpeg': 'fa-picture-o',
+ 'image/png': 'fa-picture-o',
+ 'image/gif': 'fa-picture-o',
+ 'image/svg+xml': 'fa-picture-o',
+ //Archive
+ 'application/zip': 'fa-file-archive-o',
+ 'application/x-rar-compressed': 'fa-file-archive-o',
+ //Audio
+ 'audio/mpeg': 'fa-file-audio-o',
+ 'audio/mp3': 'fa-file-audio-o', //webkit browsers need that
+ 'audio/wav': 'fa-file-audio-o',
+ 'application/ogg': 'fa-file-audio-o',
+ 'audio/ogg': 'fa-file-audio-o',
+ 'audio/webm': 'fa-file-audio-o',
+ 'audio/mp4': 'fa-file-audio-o',
+ //Video
+ 'video/quicktime': 'fa-file-video-o',
+ 'video/webm': 'fa-file-video-o',
+ 'video/mp4': 'fa-file-video-o',
+ 'video/x-matroska': 'fa-file-video-o'
+ };
+
+ var iconFromType = 'fa-file-o';
+
+ if (type in map) {
+ iconFromType = map[type];
+ }
+
+ return iconFromType;
+}
+
+// upload files
+function UploadFile(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) {
+
+ var done = e.position || e.loaded;
+ var total = e.totalSize || e.total;
+ // Dynamically update the percentage complete displayed in the file upload list
+ $('#upload-progress-' + idx).html(Math.round(done / total * 100) + '%');
+ $('#upload-progress-bar-' + idx).css('background-size', Math.round(done / total * 100) + '%');
+
+ if(done == total) {
+ $('#upload-progress-' + idx).html('Processing...');
+ }
+
+ });
+
+
+ xhr.addEventListener('load', function (e) {
+ //we could possibly turn the filenames to real links here and add the delete and edit buttons to avoid page reload...
+ $('#upload-progress-' + idx).html('Ready!');
+
+ //console.log('xhr upload complete', e);
+ window.fileUploadsCompleted = window.fileUploadsCompleted + 1;
+
+ // When all the uploads have completed, refresh the page
+ if (window.filesToUpload > 0 && window.fileUploadsCompleted === window.filesToUpload) {
+
+ window.fileUploadsCompleted = window.filesToUpload = 0;
+
+ // After uploads complete, refresh browser window to display new files
+ window.location.href = window.location.href;
+ }
+ });
+
+
+ xhr.addEventListener('error', function (e) {
+ $('#upload-progress-' + idx).html('<span style="color: red;">ERROR</span>');
+ });
+
+ // POST to the entire cloud path
+ xhr.open('post', $('#photos-upload-form').attr( 'action' ), true);
+
+ var formfields = $("#photos-upload-form").serializeArray();
+
+ var data = new FormData();
+ $.each(formfields, function(i, field) {
+ data.append(field.name, field.value);
+ });
+ data.append('userfile', file);
+
+ xhr.send(data);
+}
diff --git a/view/js/mod_pubstream.js b/view/js/mod_pubstream.js
new file mode 100644
index 000000000..7e24a7f86
--- /dev/null
+++ b/view/js/mod_pubstream.js
@@ -0,0 +1,5 @@
+$(document).ready(function() {
+ $(".comment-edit-wrapper textarea").editor_autocomplete(baseurl+"/acl?f=&n=1");
+ // make auto-complete work in more places
+ $(".wall-item-comment-wrapper textarea").editor_autocomplete(baseurl+"/acl?f=&n=1");
+});