Scope stream scrolled events to new elements
This commit is contained in:
parent
67123a277c
commit
0b1ef41838
6 changed files with 48 additions and 31 deletions
|
|
@ -18,8 +18,12 @@ var Stream = {
|
|||
Stream.setUpAudioLinks();
|
||||
//Stream.setUpImageLinks();
|
||||
|
||||
Diaspora.widgets.subscribe("stream/scrolled", Stream.collapseText);
|
||||
},
|
||||
collapseText: function(){
|
||||
elements = $(Array.prototype.slice.call(arguments,1));
|
||||
// collapse long posts
|
||||
$(".content p", this.selector).expander({
|
||||
$(".content p", elements).expander({
|
||||
slicePoint: 400,
|
||||
widow: 12,
|
||||
expandText: Diaspora.widgets.i18n.t("show_more"),
|
||||
|
|
@ -27,14 +31,13 @@ var Stream = {
|
|||
});
|
||||
|
||||
// collapse long comments
|
||||
$(".comment .content span", this.selector).expander({
|
||||
$(".comment .content span", elements).expander({
|
||||
slicePoint: 200,
|
||||
widow: 400,
|
||||
expandText: Diaspora.widgets.i18n.t("show_more"),
|
||||
userCollapse: false
|
||||
});
|
||||
},
|
||||
|
||||
initializeLives: function(){
|
||||
// reshare button action
|
||||
$(".reshare_button", this.selector).live("click", function(evt) {
|
||||
|
|
@ -152,7 +155,7 @@ var Stream = {
|
|||
toggle.html(Diaspora.widgets.i18n.t("comments.hide"));
|
||||
commentList.html(data)
|
||||
.addClass('loaded');
|
||||
Diaspora.widgets.publish("stream/scrolled")
|
||||
Diaspora.widgets.publish("stream/scrolled", commentList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ var View = {
|
|||
});
|
||||
|
||||
Diaspora.widgets.subscribe("stream/scrolled", function() {
|
||||
$('#main_stream label').inFieldLabels();
|
||||
new_elements = Array.prototype.slice.call(arguments,1)
|
||||
$(new_elements).find('label').inFieldLabels();
|
||||
});
|
||||
|
||||
Diaspora.widgets.subscribe("stream/reloaded", function() {
|
||||
|
|
@ -56,11 +57,15 @@ var View = {
|
|||
|
||||
/* Autoexpand textareas */
|
||||
var startAutoResize = function() {
|
||||
$('textarea')
|
||||
.autoResize({
|
||||
'animate': false,
|
||||
'extraSpace': 5
|
||||
});
|
||||
if (arguments.length > 1){
|
||||
target = $(Array.prototype.slice.call(arguments,1)).find('textarea');
|
||||
}else{
|
||||
target = $('textarea')
|
||||
}
|
||||
target.autoResize({
|
||||
'animate': false,
|
||||
'extraSpace': 5
|
||||
});
|
||||
}
|
||||
Diaspora.widgets.subscribe("stream/scrolled", startAutoResize)
|
||||
Diaspora.widgets.subscribe("stream/reloaded", startAutoResize)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* the COPYRIGHT file.
|
||||
*/
|
||||
/* Modified version of https://gitorious.org/statusnet/mainline/blobs/master/plugins/DirectionDetector/jquery.DirectionDetector.js */
|
||||
(function() {
|
||||
(function() {
|
||||
var DirectionDetector = function() {
|
||||
var self = this;
|
||||
this.binds = [];
|
||||
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
this.subscribe("widget/ready", function() {
|
||||
self.updateBinds();
|
||||
|
||||
Diaspora.widgets.subscribe("stream/scrolled", function() {
|
||||
|
||||
Diaspora.widgets.subscribe("stream/scrolled", function(eventID, new_elements) {
|
||||
self.updateBinds();
|
||||
});
|
||||
});
|
||||
|
|
@ -21,35 +21,35 @@
|
|||
if(typeof str !== "string" || str.length < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var charCode = str.charCodeAt(0);
|
||||
if(charCode >= 1536 && charCode <= 1791) // Sarabic, Persian, ...
|
||||
return true;
|
||||
|
||||
|
||||
else if(charCode >= 65136 && charCode <= 65279) // Arabic present 1
|
||||
return true;
|
||||
|
||||
|
||||
else if(charCode >= 64336 && charCode <= 65023) // Arabic present 2
|
||||
return true;
|
||||
|
||||
|
||||
else if(charCode>=1424 && charCode<=1535) // Hebrew
|
||||
return true;
|
||||
|
||||
|
||||
else if(charCode>=64256 && charCode<=64335) // Hebrew present
|
||||
return true;
|
||||
|
||||
|
||||
else if(charCode>=1792 && charCode<=1871) // Syriac
|
||||
return true;
|
||||
|
||||
|
||||
else if(charCode>=1920 && charCode<=1983) // Thaana
|
||||
return true;
|
||||
|
||||
|
||||
else if(charCode>=1984 && charCode<=2047) // NKo
|
||||
return true;
|
||||
|
||||
|
||||
else if(charCode>=11568 && charCode<=11647) // Tifinagh
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
@ -72,7 +72,7 @@
|
|||
this.updateDirection = function() {
|
||||
var textArea = $(this),
|
||||
cleaned = textArea.val().replace(self.cleaner, "").replace(/^[ ]+/, "");
|
||||
|
||||
|
||||
if(self.isRTL(cleaned)) {
|
||||
textArea.css("direction", "rtl");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@
|
|||
|
||||
this.initialize = function() {
|
||||
if($('#main_stream').length !== 0){
|
||||
$('#main_stream').infinitescroll(this.options, function() {
|
||||
Diaspora.widgets.publish("stream/scrolled");
|
||||
$('#main_stream').infinitescroll(this.options, function(new_elements) {
|
||||
Diaspora.widgets.publish("stream/scrolled", new_elements);
|
||||
});
|
||||
} else if($('#people_stream').length !== 0){
|
||||
$("#people_stream").infinitescroll($.extend(self.options, {
|
||||
|
|
@ -44,8 +44,8 @@
|
|||
pathParse : function( pathStr, nextPage){
|
||||
return pathStr.replace("page=2", "page=" + nextPage);
|
||||
}
|
||||
}), function() {
|
||||
Diaspora.widgets.publish("stream/scrolled");
|
||||
}), function(new_elements) {
|
||||
Diaspora.widgets.publish("stream/scrolled", new_elements);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,7 +23,12 @@
|
|||
};
|
||||
|
||||
this.updateTimeAgo = function() {
|
||||
self.timeAgoElement().timeago();
|
||||
if (arguments.length > 1){
|
||||
new_elements = Array.prototype.slice.call(arguments,1);
|
||||
$(new_elements).find(self.selector).timeago();
|
||||
}else{
|
||||
self.timeAgoElement().timeago();
|
||||
}
|
||||
};
|
||||
};
|
||||
Diaspora.widgets.add("timeago", TimeAgo);
|
||||
|
|
|
|||
|
|
@ -20,17 +20,21 @@ describe("Stream", function() {
|
|||
});
|
||||
|
||||
});
|
||||
describe("initialize", function() {
|
||||
describe("collapseText", function() {
|
||||
|
||||
it("adds a 'show more' links to long posts", function() {
|
||||
Diaspora.widgets.i18n.loadLocale(
|
||||
{show_more: 'Placeholder'}, 'en');
|
||||
Stream.initialize();
|
||||
|
||||
stream_element = $('#main_stream .stream_element:first');
|
||||
Stream.collapseText('eventID', stream_element[0]);
|
||||
|
||||
expect(stream_element.find("p .details").css('display')).toEqual('none');
|
||||
expect(stream_element.find(".read-more a").css('display')).toEqual('inline');
|
||||
|
||||
stream_element.find(".read-more a").click();
|
||||
jasmine.Clock.tick(200);
|
||||
|
||||
expect(stream_element.find(".read-more").css('display')).toEqual('none');
|
||||
expect(stream_element.find(".details").css('display')).toEqual('inline');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue