";
- };
+ }
// reinit listeners on stream
photozone.html(photos_html);
- Stream.initialize();
- InfiniteScroll.initialize();
-
- Publisher.initialize();
+ Diaspora.widgets.publish("stream/reloaded");
// fade contents back in
- if(requests == 0){
- $("#aspect_stream_container").fadeTo(100, 1);
- $("#aspect_contact_pictures").fadeTo(100, 1);
- performAspectUpdate();
+ if(AspectFilters.requests === 0){
+ AspectFilters.fadeIn();
+ AspectFilters.performAspectUpdate();
}
}
});
-
+ },
+ fadeIn: function(){
+ $("#aspect_stream_container").fadeTo(100, 1);
+ $("#aspect_contact_pictures").fadeTo(100, 1);
+ },
+ fadeOut: function(){
+ $("#aspect_stream_container").fadeTo(100, 0.4);
+ $("#aspect_contact_pictures").fadeTo(100, 0.4);
}
-
+}
+$(document).ready(function(){
+ AspectFilters.initialize();
});
diff --git a/public/javascripts/contact-list.js b/public/javascripts/contact-list.js
index 3120626b5..439f1228b 100644
--- a/public/javascripts/contact-list.js
+++ b/public/javascripts/contact-list.js
@@ -47,7 +47,6 @@ $(document).ready(function() {
$(this).fadeTo(200,0.4);
});
-
$('.added').live('ajax:failure', function(data, html, xhr) {
if(confirm(Diaspora.widgets.i18n.t('shared.contact_list.cannot_remove'))){
var contact_id;
@@ -64,7 +63,6 @@ $(document).ready(function() {
$(this).fadeTo(200,1);
});
-
$('.added').live('mouseover', function() {
$(this).addClass("remove");
$(this).children("img").attr("src","/images/icons/monotone_close_exit_delete.png");
diff --git a/public/javascripts/diaspora.js b/public/javascripts/diaspora.js
index a896631cc..8b2e8c032 100644
--- a/public/javascripts/diaspora.js
+++ b/public/javascripts/diaspora.js
@@ -3,33 +3,53 @@
* the COPYRIGHT file.
*/
-var Diaspora = Diaspora || {};
+(function() {
+ if(typeof window.Diaspora !== "undefined") {
+ return;
+ }
-Diaspora.widgetCollection = function() {
- this.initialized = false;
- this.collection = {};
-};
+ var Diaspora = { };
-Diaspora.widgetCollection.prototype.add = function(widgetId, widget) {
+ Diaspora.WidgetCollection = function() {
+ this.initialized = false;
+ this.collection = { };
+ this.eventsContainer = $({});
+ };
+
+ Diaspora.WidgetCollection.prototype.add = function(widgetId, widget) {
this[widgetId] = this.collection[widgetId] = new widget();
if(this.initialized) {
this.collection[widgetId].start();
}
};
-Diaspora.widgetCollection.prototype.remove = function(widgetId) {
+ Diaspora.WidgetCollection.prototype.remove = function(widgetId) {
delete this.collection[widgetId];
-};
+ };
-Diaspora.widgetCollection.prototype.init = function() {
- this.initialized = true;
- for(var widgetId in this.collection) {
- this.collection[widgetId].start();
- }
-}
+ Diaspora.WidgetCollection.prototype.init = function() {
+ this.initialized = true;
-Diaspora.widgets = Diaspora.widgets || new Diaspora.widgetCollection();
+ for(var widgetId in this.collection) {
+ if(typeof this.collection[widgetId].start !== "undefined") {
+ this.collection[widgetId].start();
+ }
+ }
+ };
+
+ Diaspora.WidgetCollection.prototype.subscribe = function(id, callback, context) {
+ this.eventsContainer.bind(id, $.proxy(callback, context));
+ };
+
+ Diaspora.WidgetCollection.prototype.publish = function(id) {
+ this.eventsContainer.trigger(id);
+ };
+
+ Diaspora.widgets = new Diaspora.WidgetCollection();
+
+ window.Diaspora = Diaspora;
+})();
+
+
+$(document).ready(function() { Diaspora.widgets.init(); });
-$(document).ready(function() {
- Diaspora.widgets.init();
-});
diff --git a/public/javascripts/fileuploader-custom.js b/public/javascripts/fileuploader-custom.js
index 7b9b044d9..4fc1ad643 100644
--- a/public/javascripts/fileuploader-custom.js
+++ b/public/javascripts/fileuploader-custom.js
@@ -28,12 +28,12 @@ qq.extend = function(first, second){
* @param {Number} [from] The index at which to begin the search
*/
qq.indexOf = function(arr, elt, from){
- if (arr.indexOf) return arr.indexOf(elt, from);
+ if (arr.indexOf) { return arr.indexOf(elt, from); }
from = from || 0;
var len = arr.length;
- if (from < 0) from += len;
+ if (from < 0) { from += len; }
for (; from < len; from++){
if (from in arr && arr[from] === elt){
@@ -89,7 +89,7 @@ qq.remove = function(element){
qq.contains = function(parent, descendant){
// compareposition returns false in this case
- if (parent == descendant) return true;
+ if (parent == descendant) { return true; }
if (parent.contains){
return parent.contains(descendant);
@@ -120,7 +120,7 @@ qq.toElement = (function(){
* Fixes opacity in IE6-8.
*/
qq.css = function(element, styles){
- if (styles.opacity != null){
+ if (styles.opacity !== null){
if (typeof element.style.opacity != 'string' && typeof(element.filters) != 'undefined'){
styles.filter = 'alpha(opacity=' + Math.round(100 * styles.opacity) + ')';
}
diff --git a/public/javascripts/inbox.js b/public/javascripts/inbox.js
index 6320659a5..637b6480d 100644
--- a/public/javascripts/inbox.js
+++ b/public/javascripts/inbox.js
@@ -16,7 +16,7 @@ $(document).ready(function(){
if(conv.hasClass('unread') ){
conv.removeClass('unread');
}
- if(cBadge.html() != null) {
+ if(cBadge.html() !== null) {
cBadge.html().replace(/\d+/, function(num){
num = parseInt(num);
cBadge.html(parseInt(num)-1);
@@ -30,7 +30,7 @@ $(document).ready(function(){
});
$(window).bind("popstate", function(){
- if (location.href.match(/conversations\/\d+/) != null) {
+ if (location.href.match(/conversations\/\d+/) !== null) {
$.getScript(location.href, function() {
Diaspora.widgets.directionDetector.updateBinds();
});
@@ -72,7 +72,7 @@ $(document).ready(function(){
// remove the paginator when we're done.
$(document).ajaxError(function(e,xhr,opt){
- if (xhr.status == 404) $('a.next_page').remove();
+ if (xhr.status == 404) { $('a.next_page').remove(); }
});
$('#reply_to_conversation').live('click', function(evt) {
@@ -84,7 +84,7 @@ $(document).ready(function(){
});
var resize = function(){
- var inboxSidebar = $('#conversation_inbox');
+ var inboxSidebar = $('#conversation_inbox'),
inboxSidebarOffset = inboxSidebar.offset().top,
windowHeight = $(window).height();
diff --git a/public/javascripts/infinite-scroll.js b/public/javascripts/infinite-scroll.js
deleted file mode 100644
index 9ec191d41..000000000
--- a/public/javascripts/infinite-scroll.js
+++ /dev/null
@@ -1,36 +0,0 @@
-var InfiniteScroll = {
- options: {
- navSelector : "#pagination",
- // selector for the paged navigation (it will be hidden)
- nextSelector : ".paginate",
- // selector for the NEXT link (to page 2)
- itemSelector : ".stream_element",
- // selector for all items you'll retrieve
- pathParse : function( pathStr, nextPage ){
- var newPath = pathStr.replace("?", "?only_posts=true&");
- return newPath.replace( "page=2", "page=" + nextPage);
- },
- bufferPx: 500,
- debug: false,
- donetext: "no more.",
- loadingText: "",
- loadingImg: '/images/ajax-loader.gif'
- },
- postScrollCallback: function(){
- for (var callback in InfiniteScroll.postScrollCallbacks){
- InfiniteScroll.postScrollCallbacks[callback]();
- }
- },
- postScrollCallbacks: [],
- initialize: function(){
- $('#main_stream').infinitescroll(InfiniteScroll.options, InfiniteScroll.postScrollCallback);
- },
- postScroll: function( callback ){
- InfiniteScroll.postScrollCallbacks.push(callback);
- }
-}
-
-$(document).ready(function() {
- InfiniteScroll.initialize();
-});
-
diff --git a/public/javascripts/keycodes.js b/public/javascripts/keycodes.js
index ca275d1ce..ae6c143db 100644
--- a/public/javascripts/keycodes.js
+++ b/public/javascripts/keycodes.js
@@ -112,5 +112,5 @@ isInsertion : function(keyCode){
}else {
return true;
}
-},
}
+};
diff --git a/public/javascripts/publisher.js b/public/javascripts/publisher.js
index 89e215baa..621935201 100644
--- a/public/javascripts/publisher.js
+++ b/public/javascripts/publisher.js
@@ -28,13 +28,6 @@ var Publisher = {
}
return Publisher.cachedInput;
},
- cachedSubmit : false,
- submit: function(){
- if(!Publisher.cachedSubmit){
- Publisher.cachedSubmit = Publisher.form().find('#status_message_submit');
- }
- return Publisher.cachedSubmit;
- },
cachedHiddenInput : false,
hiddenInput: function(){
@@ -107,7 +100,7 @@ var Publisher = {
},
generateHiddenInput : function(visibleString){
var resultString = visibleString;
- for(i in this.sortedMentions()){
+ for(var i in this.sortedMentions()){
var mention = this.mentions[i];
var start = resultString.slice(0, mention.visibleStart);
var insertion = mention.mentionString;
@@ -165,14 +158,14 @@ var Publisher = {
},
updateMentionLocations : function(effectiveCursorIndex, offset){
var changedMentions = this.mentionsAfter(effectiveCursorIndex);
- for(i in changedMentions){
+ for(var i in changedMentions){
var mention = changedMentions[i];
mention.visibleStart += offset;
mention.visibleEnd += offset;
}
},
mentionAt : function(visibleCursorIndex){
- for(i in this.mentions){
+ for(var i in this.mentions){
var mention = this.mentions[i];
if(visibleCursorIndex > mention.visibleStart && visibleCursorIndex < mention.visibleEnd){
return i;
@@ -182,14 +175,14 @@ var Publisher = {
},
mentionsAfter : function(visibleCursorIndex){
var resultMentions = [];
- for(i in this.mentions){
+ for(var i in this.mentions){
var mention = this.mentions[i];
if(visibleCursorIndex <= mention.visibleStart){
resultMentions.push(mention);
}
}
return resultMentions;
- },
+ }
},
repopulateHiddenInput: function(){
var newHiddenVal = Publisher.autocompletion.mentionList.generateHiddenInput(Publisher.input().val());
@@ -207,8 +200,8 @@ var Publisher = {
var input = Publisher.input();
var selectionStart = input[0].selectionStart;
var selectionEnd = input[0].selectionEnd;
- var isDeletion = (event.keyCode == KEYCODES.DEL && selectionStart < input.val().length) || (event.keyCode == KEYCODES.BACKSPACE && (selectionStart > 0 || selectionStart != selectionEnd))
- var isInsertion = (KEYCODES.isInsertion(event.keyCode) && event.keyCode != KEYCODES.RETURN )
+ var isDeletion = (event.keyCode == KEYCODES.DEL && selectionStart < input.val().length) || (event.keyCode == KEYCODES.BACKSPACE && (selectionStart > 0 || selectionStart != selectionEnd));
+ var isInsertion = (KEYCODES.isInsertion(event.keyCode) && event.keyCode != KEYCODES.RETURN );
if(isDeletion){
Publisher.autocompletion.mentionList.deletionAt(selectionStart, selectionEnd, event.keyCode);
@@ -226,15 +219,15 @@ var Publisher = {
var stringEnd = inputContent.slice(stringLoc[1]);
input.val(stringStart + formatted + stringEnd);
- var offset = formatted.length - (stringLoc[1] - stringLoc[0])
+ var offset = formatted.length - (stringLoc[1] - stringLoc[0]);
Publisher.autocompletion.mentionList.updateMentionLocations(stringStart.length, offset);
- return [stringStart.length, stringStart.length + formatted.length]
+ return [stringStart.length, stringStart.length + formatted.length];
},
findStringToReplace: function(value, cursorIndex){
var atLocation = value.lastIndexOf('@', cursorIndex);
if(atLocation == -1){return [0,0];}
- var nextAt = cursorIndex
+ var nextAt = cursorIndex;
if(nextAt == -1){nextAt = value.length;}
return [atLocation, nextAt];
@@ -247,7 +240,7 @@ var Publisher = {
if(stringLoc[0] <= 2){
stringLoc[0] = 0;
}else{
- stringLoc[0] -= 2
+ stringLoc[0] -= 2;
}
var relevantString = value.slice(stringLoc[0], stringLoc[1]).replace(/\s+$/,"");
@@ -270,9 +263,9 @@ var Publisher = {
}
},
determineSubmitAvailability: function(){
- var onlyWhitespaces = (Publisher.input().val().trim() == '');
+ var onlyWhitespaces = (Publisher.input().val().trim() === '');
var isSubmitDisabled = Publisher.submit().attr('disabled');
- var isPhotoAttached = ($("#photodropzone").children().length > 0)
+ var isPhotoAttached = ($("#photodropzone").children().length > 0);
if ((onlyWhitespaces && !isPhotoAttached) && !isSubmitDisabled) {
Publisher.submit().attr('disabled', true);
} else if ((!onlyWhitespaces || isPhotoAttached) && isSubmitDisabled) {
@@ -295,40 +288,40 @@ var Publisher = {
$(this).toggleClass("dim");
var public_field= $("#publisher #status_message_public");
- (public_field.val() == 'false')?(public_field.val('true')):(public_field.val('false'));
+ (public_field.val() == 'false') ? (public_field.val('true')) : (public_field.val('false'));
});
},
toggleServiceField: function(service){
Publisher.createCounter(service);
var provider = service.attr('id');
- var hidden_field = $('#publisher [name="services[]"][value="'+provider+'"]')
+ var hidden_field = $('#publisher [name="services[]"][value="'+provider+'"]');
if(hidden_field.length > 0){
hidden_field.remove();
} else {
$("#publisher .content_creation form").append(
'');
- };
+ }
},
toggleAspectIds: function(aspectId) {
- var hidden_field = $('#publisher [name="aspect_ids[]"][value="'+aspectId+'"]')
+ var hidden_field = $('#publisher [name="aspect_ids[]"][value="'+aspectId+'"]');
if(hidden_field.length > 0){
hidden_field.remove();
} else {
$("#publisher .content_creation form").append(
'');
- };
+ }
},
createCounter: function(service){
var counter = $("#publisher .counter");
counter.remove();
-
+
var min = 40000;
var a = $('.service_icon:not(.dim)');
if(a.length > 0){
$.each(a, function(index, value){
var num = parseInt($(value).attr('maxchar'));
- if (min > num) { min = num}
+ if (min > num) { min = num; }
});
$('#status_message_fake_text').charCount({allowed: min, warning: min/10 });
}
@@ -338,26 +331,24 @@ var Publisher = {
$('#publisher .aspect_badge').bind("click", function(){
var unremovedAspects = $(this).parent().children('.aspect_badge').length - $(this).parent().children(".aspect_badge.removed").length;
if(!$(this).hasClass('removed') && ( unremovedAspects == 1 )){
- alert(Diaspora.widgets.i18n.t('publisher.at_least_one_aspect'))
+ alert(Diaspora.widgets.i18n.t('publisher.at_least_one_aspect'));
}else{
Publisher.toggleAspectIds($(this).children('a').attr('data-guid'));
$(this).toggleClass("removed");
- };
+ }
});
},
initialize: function() {
- Publisher.cachedForm = false;
- Publisher.cachedInput = false;
- Publisher.cachedHiddenInput = false;
- Publisher.cachedSubmit = false;
+ Publisher.cachedForm = Publisher.cachedSubmit =
+ Publisher.cachedInput = Publisher.cachedHiddenInput = false;
Publisher.bindServiceIcons();
Publisher.bindPublicIcon();
Publisher.bindAspectToggles();
- if ($("#status_message_fake_text").val() == "") {
+ if ($("#status_message_fake_text").val() === "") {
Publisher.close();
- };
+ }
Publisher.autocompletion.initialize();
Publisher.hiddenInput().val(Publisher.input().val());
@@ -371,4 +362,5 @@ var Publisher = {
$(document).ready(function() {
Publisher.initialize();
+ Diaspora.widgets.subscribe("stream/reloaded", Publisher.initialize);
});
diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js
index e5f3b5e37..646365a91 100644
--- a/public/javascripts/stream.js
+++ b/public/javascripts/stream.js
@@ -5,24 +5,27 @@
var Stream = {
initialize: function() {
- var $stream = $(".stream");
- var $publisher = $("#publisher");
+ var stream_string = '#main_stream';
+ var $stream = $(stream_string);
$(".status_message_delete").tipsy({trigger: 'hover', gravity: 'n'});
+ Diaspora.widgets.subscribe("stream/reloaded", Stream.initialized);
Diaspora.widgets.timeago.updateTimeAgo();
Diaspora.widgets.directionDetector.updateBinds();
- $stream.not(".show").delegate("a.show_post_comments", "click", Stream.toggleComments);
+
+
+ $(stream_string + " a.show_post_comments:not(.show)").live("click", Stream.toggleComments);
//audio linx
Stream.setUpAudioLinks();
//Stream.setUpImageLinks();
// comment link form focus
- $stream.delegate(".focus_comment_textarea", "click", function(e){
+ $(stream_string + " .focus_comment_textarea").live("click", function(e){
Stream.focusNewComment($(this), e);
});
- $stream.delegate("textarea.comment_box", "focus", function(evt) {
+ $(stream_string + " textarea.comment_box").live("focus", function(evt) {
var commentBox = $(this);
commentBox
.attr('rows',2)
@@ -30,7 +33,7 @@ var Stream = {
.addClass('open');
});
- $stream.delegate("textarea.comment_box", "blur", function(evt) {
+ $(stream_string + " textarea.comment_box").live("blur", function(evt) {
var commentBox = $(this);
if (!commentBox.val()) {
commentBox
@@ -42,18 +45,18 @@ var Stream = {
});
// like/dislike
- $stream.delegate("a.expand_likes", "click", function(evt) {
+ $(stream_string + " a.expand_likes").live("click", function(evt) {
evt.preventDefault();
$(this).siblings('.likes_list').fadeToggle('fast');
});
- $stream.delegate("a.expand_dislikes", "click", function(evt) {
+ $(stream_string + " a.expand_dislikes").live("click", function(evt) {
evt.preventDefault();
$(this).siblings('.dislikes_list').fadeToggle('fast');
});
// reshare button action
- $stream.delegate(".reshare_button", "click", function(evt) {
+ $(stream_string + ' .reshare_button').live("click", function(evt) {
evt.preventDefault();
var button = $(this);
var box = button.siblings(".reshare_box");
@@ -77,24 +80,24 @@ var Stream = {
Stream.setUpAudioLinks();
});
- $(".new_status_message").bind('ajax:failure', function(data, html , xhr) {
- json = $.parseJSON(html.response);
- if(json.errors.length != 0){
+ $(".new_status_message").live('ajax:failure', function(data, html , xhr) {
+ json = $.parseJSON(html.responseText);
+ if(json.errors.length !== 0){
Diaspora.widgets.alert.alert(json.errors);
}else{
Diaspora.widgets.alert.alert('Failed to post message!');
}
});
- $(".new_comment").live('ajax:success', function(data, json, xhr) {
+ $(stream_string + " .new_comment").live('ajax:success', function(data, json, xhr) {
json = $.parseJSON(json);
WebSocketReceiver.processComment(json.post_id, json.comment_id, json.html, false);
});
- $(".new_comment").live('ajax:failure', function(data, html, xhr) {
+ $(stream_string + ".new_comment").live('ajax:failure', function(data, html, xhr) {
Diaspora.widgets.alert.alert('Failed to post message!');
});
- $(".stream").find(".comment_delete", ".comment").live('ajax:success', function(data, html, xhr) {
+ $stream.find(".comment_delete", ".comment").live('ajax:success', function(data, html, xhr) {
var element = $(this),
target = element.parents(".comment"),
post = element.closest('.stream_element'),
@@ -183,7 +186,7 @@ var Stream = {
commentBlock.removeClass('hidden');
commentBlock.find('textarea').focus();
} else {
- if(!(commentBlock.children().length > 1)){
+ if(commentBlock.children().length <= 1){
commentBlock.addClass('hidden');
} else {
commentBlock.find('textarea').focus();
diff --git a/public/javascripts/vendor/jquery.infinitescroll.min.js b/public/javascripts/vendor/jquery.infinitescroll.min.js
index c092afa69..5249dec6c 100644
--- a/public/javascripts/vendor/jquery.infinitescroll.min.js
+++ b/public/javascripts/vendor/jquery.infinitescroll.min.js
@@ -1,9 +1,8 @@
/*!
// Infinite Scroll jQuery plugin
// copyright Paul Irish, licensed GPL & MIT
-// version 1.5.101207
+// version 2.0b1.110420
// home and docs: http://www.infinite-scroll.com
*/
-(function($){$.fn.infinitescroll=function(options,callback){function debug(){if(opts.debug){window.console&&console.log.call(console,arguments)}}function areSelectorsValid(opts){for(var key in opts){if(key.indexOf&&key.indexOf("Selector")>-1&&$(opts[key]).length===0){debug("Your "+key+" found no elements.");return false}return true}}function determinePath(path){if(path.match(/^(.*?)\b2\b(.*?$)/)){path=path.match(/^(.*?)\b2\b(.*?$)/).slice(1)}else{if(path.match(/^(.*?)2(.*?$)/)){if(path.match(/^(.*?page=)2(\/.*|$)/)){path=path.match(/^(.*?page=)2(\/.*|$)/).slice(1);return path}debug("Trying backup next selector parse technique. Treacherous waters here, matey.");path=path.match(/^(.*?)2(.*?$)/).slice(1)}else{if(path.match(/^(.*?page=)1(\/.*|$)/)){path=path.match(/^(.*?page=)1(\/.*|$)/).slice(1);return path}if($.isFunction(opts.pathParse)){return[path]}else{debug("Sorry, we couldn't parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com.");props.isInvalidPage=true}}}return path}function filterNav(){opts.isFiltered=true;return $(window).trigger("error.infscr."+opts.infid,[302])}function isNearBottom(){var pixelsFromWindowBottomToBottom=0+$(document).height()-($(props.container).scrollTop()||$(props.container.ownerDocument.body).scrollTop())-$(window).height();debug("math:",pixelsFromWindowBottomToBottom,props.pixelsFromNavToBottom);return(pixelsFromWindowBottomToBottom-opts.bufferPx"):$("");frag=document.createDocumentFragment();if($.isFunction(opts.pathParse)){desturl=opts.pathParse(path.join("2"),opts.currPage)}else{desturl=path.join(opts.currPage)}box.load(desturl+" "+opts.itemSelector,null,loadCallback)})}function loadCallback(){if(opts.isDone){showDoneMsg();return false}else{var children=box.children();if(children.length==0||children.hasClass("error404")){return $(window).trigger("error.infscr."+opts.infid,[404])}while(box[0].firstChild){frag.appendChild(box[0].firstChild)}$(opts.contentSelector)[0].appendChild(frag);props.loadingMsg.fadeOut("normal");if(opts.animate){var scrollTo=$(window).scrollTop()+$("#infscr-loading").height()+opts.extraScrollPx+"px";$("html,body").animate({scrollTop:scrollTo},800,function(){opts.isDuringAjax=false})}callback.call($(opts.contentSelector)[0],children.get());if(!opts.animate){opts.isDuringAjax=false}}}function initPause(pauseValue){if(pauseValue=="pause"){opts.isPaused=true}else{if(pauseValue=="resume"){opts.isPaused=false}else{opts.isPaused=!opts.isPaused}}debug("Paused: "+opts.isPaused);return false}function infscrError(xhr){if(!opts.isDone&&xhr==404){debug("Page not found. Self-destructing...");showDoneMsg();opts.isDone=true;opts.currPage=1;$(window).unbind("scroll.infscr."+opts.infid);$(document).unbind("retrieve.infscr."+opts.infid)}if(opts.isFiltered&&xhr==302){debug("Filtered. Going to next instance...");opts.isDone=true;opts.currPage=1;opts.isPaused=false;$(window).unbind("scroll.infscr."+opts.infid,infscrSetup).unbind("pause.infscr."+opts.infid).unbind("filter.infscr."+opts.infid).unbind("error.infscr."+opts.infid);$(document).unbind("retrieve.infscr."+opts.infid,kickOffAjax)}}$.browser.ie6=$.browser.msie&&$.browser.version<7;var opts=$.extend({},$.infinitescroll.defaults,options),props=$.infinitescroll,box,frag,desturl,thisPause,errorStatus;callback=callback||function(){};if(!areSelectorsValid(opts)){return false}props.container=document.documentElement;opts.contentSelector=opts.contentSelector||this;opts.loadMsgSelector=opts.loadMsgSelector||opts.contentSelector;var relurl=/(.*?\/\/).*?(\/.*)/,path=$(opts.nextSelector).attr("href");if(!path){debug("Navigation selector not found");return}path=determinePath(path);props.pixelsFromNavToBottom=$(document).height()+(props.container==document.documentElement?0:$(props.container).offset().top)-$(opts.navSelector).offset().top;props.loadingMsg=$('
'+opts.loadingText+"
");(new Image()).src=opts.loadingImg;$(window).bind("scroll.infscr."+opts.infid,infscrSetup).bind("filter.infscr."+opts.infid,filterNav).bind("error.infscr."+opts.infid,function(event,errorStatus){infscrError(errorStatus)}).bind("pause.infscr."+opts.infid,function(event,thisPause){initPause(thisPause)}).trigger("scroll.infscr."+opts.infid);$(document).bind("retrieve.infscr."+opts.infid,kickOffAjax);return this};$.infinitescroll={defaults:{debug:false,preload:false,nextSelector:"div.navigation a:first",loadingImg:"http://www.infinite-scroll.com/loading.gif",loadingText:"Loading the next set of posts...",donetext:"Congratulations, you've reached the end of the internet.",navSelector:"div.navigation",contentSelector:null,loadMsgSelector:null,loadingMsgRevealSpeed:"fast",extraScrollPx:150,itemSelector:"div.post",animate:false,pathParse:undefined,bufferPx:40,errorCallback:function(){},infid:1,currPage:1,isDuringAjax:false,isInvalidPage:false,isFiltered:false,isDone:false,isPaused:false},loadingImg:undefined,loadingMsg:undefined,container:undefined,currDOMChunk:null}})(jQuery);
-
+(function($){$.fn.infinitescroll=function infscr(options,callback){function areSelectorsValid(opts){var debug=$.fn.infinitescroll._debug;for(var key in opts){if(key.indexOf&&key.indexOf("Selector")>-1&&$(opts[key]).length===0){debug("Your "+key+" found no elements.");return false}return true}}function determinePath(path){if($.isFunction(opts.pathParse)){debug("pathParse");return[path]}else{if(path.match(/^(.*?)\b2\b(.*?$)/)){path=path.match(/^(.*?)\b2\b(.*?$)/).slice(1)}else{if(path.match(/^(.*?)2(.*?$)/)){if(path.match(/^(.*?page=)2(\/.*|$)/)){path=path.match(/^(.*?page=)2(\/.*|$)/).slice(1);return path}path=path.match(/^(.*?)2(.*?$)/).slice(1)}else{if(path.match(/^(.*?page=)1(\/.*|$)/)){path=path.match(/^(.*?page=)1(\/.*|$)/).slice(1);return path}else{debug("Sorry, we couldn't parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com.");props.isInvalidPage=true}}}}debug("determinePath",path);return path}function hiddenHeight(element){var height=0;$(element).children().each(function(){height=height+$(this).outerHeight(false)});return height}function generateInstanceID(element){var number=$(element).length+$(element).html().length+$(element).attr("class").length+$(element).attr("id").length;opts.infid=number}if(typeof options=="string"){var command=options,argument=callback,validCommand=(command=="pause"||command=="destroy"||command=="retrieve"||command=="binding"),debug=$.fn.infinitescroll._debug;argument=argument||null;command=(validCommand)?$.fn.infinitescroll[command](argument):debug("Invalid command");return false}var opts=$.infinitescroll.opts=$.extend({},$.infinitescroll.defaults,options),props=$.infinitescroll,innerContainerHeight,box,frag,desturl,pause,error,errorStatus,method,result;callback=$.fn.infinitescroll._callback=callback||function(){},debug=$.fn.infinitescroll._debug,error=$.fn.infinitescroll._error,pause=$.fn.infinitescroll.pause,destroy=$.fn.infinitescroll.destroy,binding=$.fn.infinitescroll.binding;if(!areSelectorsValid(opts)){return false}opts.container=opts.container||document.documentElement;opts.contentSelector=opts.contentSelector||this;opts.infid=(opts.infid==0)?generateInstanceID(opts.contentSelector):opts.infid;opts.loadMsgSelector=opts.loadMsgSelector||opts.contentSelector;var relurl=/(.*?\/\/).*?(\/.*)/,path=$(opts.nextSelector).attr("href");if(!path){debug("Navigation selector not found");return}opts.path=determinePath(path);props.loadingMsg=$('
'+opts.loadingText+"
");(new Image()).src=opts.loadingImg;opts.binder=(opts.container.nodeName=="HTML")?$(window):$(opts.container);innerContainerHeight=(opts.container.nodeName=="HTML")?$(document).height():innerContainerHeight=hiddenHeight(opts.container);debug("Scrolling in: ",(opts.container.nodeName=="HTML")?"window":opts.container);opts.pixelsFromNavToBottom=innerContainerHeight+(opts.container==document.documentElement?0:$(opts.container).offset().top)-$(opts.navSelector).offset().top;binding("bind");opts.binder.trigger("smartscroll.infscr."+opts.infid);return this};$.infinitescroll={defaults:{debug:false,binder:$(window),preload:false,nextSelector:"div.navigation a:first",loadingImg:"http://www.infinite-scroll.com/loading.gif",loadingText:"Loading the next set of posts...",donetext:"Congratulations, you've reached the end of the internet.",navSelector:"div.navigation",contentSelector:null,loadMsgSelector:null,loadingMsgRevealSpeed:"fast",extraScrollPx:150,itemSelector:"div.post",animate:false,pathParse:undefined,dataType:"html",appendCallback:true,bufferPx:40,orientation:"height",errorCallback:function(){},currPage:1,infid:0,isDuringAjax:false,isInvalidPage:false,isDestroyed:false,isDone:false,isPaused:false,container:undefined,pixelsFromNavToBottom:undefined,path:undefined},loadingImg:undefined,loadingMsg:undefined,currDOMChunk:null};$.fn.infinitescroll._debug=function infscr_debug(){if($.infinitescroll.opts.debug){return window.console&&console.log.call(console,arguments)}};$.fn.infinitescroll._shorthand=function infscr_shorthand(){};$.fn.infinitescroll._nearbottom=function infscr_nearbottom(){var opts=$.infinitescroll.opts,debug=$.fn.infinitescroll._debug,hiddenHeight=$.fn.infinitescroll._hiddenheight;if(opts.container.nodeName=="HTML"){var pixelsFromWindowBottomToBottom=0+$(document).height()-($(opts.container).scrollTop()||$(opts.container.ownerDocument.body).scrollTop())-$(window).height()}else{var pixelsFromWindowBottomToBottom=0+hiddenHeight(opts.container)-$(opts.container).scrollTop()-$(opts.container).height()}debug("math:",pixelsFromWindowBottomToBottom,opts.pixelsFromNavToBottom);return(pixelsFromWindowBottomToBottom-opts.bufferPx"):$("");desturl=($.isFunction(opts.pathParse))?opts.pathParse(path.join("2"),opts.currPage):desturl=path.join(opts.currPage);method=(opts.dataType=="html"||opts.dataType=="json")?opts.dataType:"html+callback";if(opts.appendCallback&&opts.dataType=="html"){method+="+callback"}switch(method){case"html+callback":debug("Using HTML via .load() method");box.load(desturl+" "+opts.itemSelector,null,function(jqXHR,textStatus){loadCallback(box,jqXHR.responseText)});break;case"html":case"json":debug("Using "+(method.toUpperCase())+" via $.ajax() method");$.ajax({url:desturl,dataType:opts.dataType,complete:function _infscrAjax(jqXHR,textStatus){condition=(typeof(jqXHR.isResolved)!=="undefined")?(jqXHR.isResolved()):(textStatus==="success"||textStatus==="notmodified");(condition)?loadCallback(box,jqXHR.responseText):error([404])}});break}})};$.fn.infinitescroll._loadcallback=function infscr_loadcallback(box,data){var props=$.infinitescroll,opts=$.infinitescroll.opts,error=$.fn.infinitescroll._error,showDoneMsg=$.fn.infinitescroll._donemsg,callback=$.fn.infinitescroll._callback,result,frag;result=(opts.isDone)?"done":(!opts.appendCallback)?"no-append":"append";switch(result){case"done":showDoneMsg();return false;break;case"no-append":if(opts.dataType=="html"){data="
"+data+"
";data=$(data).find(opts.itemSelector)}break;case"append":var children=box.children();if(children.length==0||children.hasClass("error404")){return error([404])}frag=document.createDocumentFragment();while(box[0].firstChild){frag.appendChild(box[0].firstChild)}$(opts.contentSelector)[0].appendChild(frag);data=children.get();break}props.loadingMsg.fadeOut("normal");if(opts.animate){var scrollTo=$(window).scrollTop()+$("#infscr-loading").height()+opts.extraScrollPx+"px";$("html,body").animate({scrollTop:scrollTo},800,function(){opts.isDuringAjax=false})}if(!opts.animate){opts.isDuringAjax=false}callback.call($(opts.contentSelector)[0],data)};$.fn.infinitescroll._donemsg=function infscr_donemsg(){var props=$.infinitescroll,opts=$.infinitescroll.opts;props.loadingMsg.find("img").hide().parent().find("div").html(opts.donetext).animate({opacity:1},2000,function(){$(this).parent().fadeOut("normal")});opts.errorCallback()};$.fn.infinitescroll.pause=function infscr_pause(pause){var debug=$.fn.infinitescroll._debug,opts=$.infinitescroll.opts;if(pause!=="pause"&&pause!=="resume"&&pause!=="toggle"&&pause!==null){debug("Invalid argument. Toggling pause value instead")}pause=(pause&&(pause=="pause"||pause=="resume"))?pause:"toggle";switch(pause){case"pause":opts.isPaused=true;break;case"resume":opts.isPaused=false;break;case"toggle":opts.isPaused=!opts.isPaused;break}debug("Paused",opts.isPaused);return false};$.fn.infinitescroll._error=function infscr_error(xhr){var opts=$.infinitescroll.opts,binder=(opts.container.nodeName=="HTML")?$(window):$(opts.container),debug=$.fn.infinitescroll._debug,showDoneMsg=$.fn.infinitescroll._donemsg,error=(!opts.isDone&&xhr==404)?"end":(opts.isDestroyed&&xhr==302)?"destroy":"unknown";switch(error){case"end":debug("Page not found. Self-destructing...");showDoneMsg();opts.isDone=true;opts.currPage=1;opts.isPaused=false;binder.unbind("smartscroll.infscr."+opts.infid);break;case"destroy":debug("Destroyed. Going to next instance...");opts.isDone=true;opts.currPage=1;opts.isPaused=false;binder.unbind("smartscroll.infscr."+opts.infid);break;case"unknown":debug("Unknown Error. WHAT DID YOU DO?!...");showDoneMsg();opts.isDone=true;opts.currPage=1;binder.unbind("smartscroll.infscr."+opts.infid);break}};$.fn.infinitescroll.destroy=function infscr_destroy(){var opts=$.infinitescroll.opts,error=$.fn.infinitescroll._error;opts.isDestroyed=true;return error([302])};$.fn.infinitescroll.binding=function infscr_binding(binding){var opts=$.infinitescroll.opts,setup=$.fn.infinitescroll._setup,error=$.fn.infinitescroll._error,debug=$.fn.infinitescroll._debug;switch(binding){case"bind":opts.binder.bind("smartscroll.infscr."+opts.infid,setup);break;case"unbind":opts.binder.unbind("smartscroll.infscr."+opts.infid);break}debug("Binding",binding);return false};var event=$.event,scrollTimeout;event.special.smartscroll={setup:function(){$(this).bind("scroll",event.special.smartscroll.handler)},teardown:function(){$(this).unbind("scroll",event.special.smartscroll.handler)},handler:function(event,execAsap){var context=this,args=arguments;event.type="smartscroll";if(scrollTimeout){clearTimeout(scrollTimeout)}scrollTimeout=setTimeout(function(){jQuery.event.handle.apply(context,args)},execAsap==="execAsap"?0:100)}};$.fn.smartscroll=function(fn){return fn?this.bind("smartscroll",fn):this.trigger("smartscroll",["execAsap"])}})(jQuery);
\ No newline at end of file
diff --git a/public/javascripts/view.js b/public/javascripts/view.js
index 47cc08724..dfbfcf6a4 100644
--- a/public/javascripts/view.js
+++ b/public/javascripts/view.js
@@ -18,7 +18,8 @@ var View = {
$(document).bind('afterReveal.facebox', function() {
jQuery("#facebox label").inFieldLabels();
});
- InfiniteScroll.postScroll(function(){
+
+ Diaspora.widgets.subscribe("stream/scrolled", function() {
$('#main_stream .comments label').inFieldLabels();
});
diff --git a/public/javascripts/web-socket-receiver.js b/public/javascripts/web-socket-receiver.js
index 5b39cc415..c0bfdc578 100644
--- a/public/javascripts/web-socket-receiver.js
+++ b/public/javascripts/web-socket-receiver.js
@@ -6,6 +6,12 @@ var WebSocketReceiver = {
//Attach onmessage to websocket
ws.onmessage = WSR.onMessage;
ws.onclose = function() {
+ Diaspora.widgets.notifications.showNotification({
+ html: '