Merge branch 'stable' into develop

This commit is contained in:
Dennis Schubert 2015-08-27 05:25:51 +02:00
commit 6b863defa3
13 changed files with 60 additions and 207 deletions

View file

@ -77,6 +77,7 @@ With the port to Bootstrap 3, app/views/terms/default.haml has a new structure.
* Extract CommentService from CommentsController [#6307](https://github.com/diaspora/diaspora/pull/6307)
* Extract user/profile discovery into the diaspora\_federation-rails gem [#6310](https://github.com/diaspora/diaspora/pull/6310)
* Refactor PostPresenter [#6315](https://github.com/diaspora/diaspora/pull/6315)
* Convert BackToTop to a backbone view [#6279](https://github.com/diaspora/diaspora/pull/6279)
## Bug fixes
* Fix indentation and a link title on the default home page [#6212](https://github.com/diaspora/diaspora/pull/6212)

View file

@ -108,6 +108,7 @@ var app = {
new app.views.AspectMembership({el: this});
});
app.sidebar = new app.views.Sidebar();
app.backToTop = new app.views.BackToTop();
},
/* mixpanel wrapper function */

View file

@ -0,0 +1,26 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
app.views.BackToTop = Backbone.View.extend({
events: {
"click #back-to-top": "backToTop"
},
initialize: function() {
var throttledScroll = _.throttle(this.toggleVisibility, 250);
$(window).scroll(throttledScroll);
},
backToTop: function(evt) {
evt.preventDefault();
$("html, body").animate({scrollTop: 0});
},
toggleVisibility: function() {
if($("html, body").scrollTop() > 1000) {
$("#back-to-top").addClass("visible");
} else {
$("#back-to-top").removeClass("visible");
}
}
});
// @license-end

View file

@ -21,7 +21,6 @@ app.views.Hovercard = app.views.Base.extend({
// cache some element references
this.avatar = this.$('.avatar');
this.avatarLink = this.$("a.person_avatar");
this.dropdown = this.$('.dropdown_list');
this.dropdown_container = this.$('#hovercard_dropdown_container');
this.hashtags = this.$('.hashtags');
this.person_link = this.$('a.person');
@ -120,7 +119,6 @@ app.views.Hovercard = app.views.Base.extend({
this.person_link.attr('href', person.url);
this.person_link.text(person.name);
this.person_handle.text(person.handle);
this.dropdown.attr('data-person-id', person.id);
// set hashtags
this.hashtags.empty();

View file

@ -68,7 +68,6 @@
Diaspora.BasePage = function(body) {
$.extend(this, Diaspora.BaseWidget);
$.extend(this, {
backToTop: this.instantiate("BackToTop", body.find("#back-to-top")),
directionDetector: this.instantiate("DirectionDetector"),
events: function() { return Diaspora.page.eventsContainer.data("events"); },
flashMessages: this.instantiate("FlashMessages"),
@ -92,11 +91,6 @@
Diaspora.page.publish("page/ready", [$(document.body)]);
};
// temp hack to check if backbone is enabled for the page
Diaspora.backboneEnabled = function(){
return window.app && window.app.stream !== undefined;
};
window.Diaspora = Diaspora;
})();

View file

@ -1,17 +1,9 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
var View = {
initialize: function() {
/* Buttons */
$("input:submit").addClass("button");
/* label placeholders */
$("input, textarea").placeholder();
/* Dropdowns */
$(document)
.on('click', this.dropdowns.selector, this.dropdowns.click)
.on('keypress', this.dropdowns.selector, this.dropdowns.click);
$(document).on('ajax:success', 'form[data-remote]', function () {
$(this).clearForm();
$(this).focusout();
@ -21,39 +13,7 @@ var View = {
$("#new_tag_following .tag_input").bind('focus', function(){
$(this).siblings("#tag_following_submit").removeClass('hidden');
});
$(document.body).click(this.dropdowns.removeFocus);
$("a.new_aspect").click(function(){
$("input#aspect_name").focus();
});
/* notification routing */
$("#notification").delegate('.hard_object_link', 'click', function(evt){
var post = $("#"+ $(this).attr('data-ref')),
lastComment = post.find('.comment.posted').last();
if(post.length > 0){
evt.preventDefault();
$('html, body').animate({scrollTop: parseInt(lastComment.offset().top)-80 }, 'fast');
}
});
},
dropdowns: {
click: function(evt) {
$(this).parent('.dropdown').toggleClass("active");
evt.preventDefault();
},
removeFocus: function(evt) {
var $target = $(evt.target);
if(!$target.is('.dropdown_list *') && !$target.is('.dropdown.active > .toggle')) {
$(View.dropdowns.selector).parent().removeClass("active");
}
},
selector: ".dropdown > .toggle",
parentSelector: ".dropdown > .wrapper"
}
};
$(function() {

View file

@ -1,36 +0,0 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
(function() {
var BackToTop = function() {
var self = this;
this.subscribe("widget/ready", function(evt, button) {
$.extend(self, {
button: button,
body: $("html, body"),
window: $(window)
});
self.button.click(self.backToTop);
var throttledScroll = _.throttle($.proxy(self.toggleVisibility, self), 250);
self.window.scroll(throttledScroll);
});
this.backToTop = function(evt) {
evt.preventDefault();
self.body.animate({scrollTop: 0});
};
this.toggleVisibility = function() {
self.button[
(self.body.scrollTop() > 1000) ?
'addClass' :
'removeClass'
]('visible');
};
};
Diaspora.Widgets.BackToTop = BackToTop;
})();
// @license-end

View file

@ -1,36 +0,0 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
(function() {
var Stream = function() {
var self = this;
this.subscribe("widget/ready", function(evt, stream) {
if( Diaspora.backboneEnabled() ){ return }
$.extend(self, {
stream: $(stream),
mainStream: $(stream).find('#main_stream'),
headerTitle: $(stream).find('#aspect_stream_header > h3')
});
});
this.globalSubscribe("stream/reloaded stream/scrolled", function() {
self.publish("widget/ready", self.stream);
});
this.empty = function() {
self.mainStream.empty();
self.headerTitle.text(Diaspora.I18n.t('stream.no_aspects'));
};
this.setHeaderTitle = function(newTitle) {
self.headerTitle.text(newTitle);
};
};
if(!Diaspora.backboneEnabled()) {
Diaspora.Widgets.Stream = Stream;
}
})();
// @license-end

View file

@ -743,37 +743,6 @@ form p.checkbox_select {
}
}
#file-upload.button {
@include button-gradient($light-grey);
border-radius: 3px;
box-shadow: 0 1px 1px #cfcfcf;
@include transition(border);
display: inline-block;
font {
style: normal;
size: 12px;
}
color: #505050;
padding: 4px 9px;
min-height: 10px;
border: 1px solid;
cursor: pointer;
white-space: normal;
&:hover {
@include button-gradient-hover-no-saturation($light-grey);
color: #505050;
text-decoration: none;
border: 1px solid;
}
}
form#update_profile_form {
select {
padding: 3px;

View file

@ -84,7 +84,7 @@
%p
= t('aspects.index.help.contact_podmin')
%p
= link_to t('aspects.index.help.mail_podmin'), "mailto:#{AppConfig.admins.podmin_email}", :class => "button"
= link_to t("aspects.index.help.mail_podmin"), "mailto:#{AppConfig.admins.podmin_email}"
.section
.title

View file

@ -90,7 +90,7 @@ module UserCukeHelpers
# submit forgot password form to get reset password link
def submit_forgot_password_form
find("#new_user input.button").click
find("#new_user input.btn").click
end
# fill the reset password form
@ -101,7 +101,7 @@ module UserCukeHelpers
# submit reset password form
def submit_reset_password_form
find(".button").click
find(".btn").click
end
def confirm_not_signed_up

View file

@ -0,0 +1,29 @@
describe("app.views.BackToTop", function() {
beforeEach(function() {
spec.loadFixture("aspects_index");
this.view = new app.views.BackToTop();
});
describe("backToTop", function() {
it("scrolls to the top of the page", function() {
var spy = spyOn($.fn, "animate");
this.view.backToTop($.Event());
expect(spy).toHaveBeenCalledWith({scrollTop: 0});
});
});
describe("toggleVisibility", function() {
it("toggles the button visibility depending on the scroll position", function() {
expect($("#back-to-top")).not.toHaveClass("visible");
var spy = spyOn($.fn, "scrollTop").and.returnValue(1000);
this.view.toggleVisibility();
expect($("#back-to-top")).not.toHaveClass("visible");
spy.and.returnValue(1001);
this.view.toggleVisibility();
expect($("#back-to-top")).toHaveClass("visible");
spy.and.returnValue(1000);
this.view.toggleVisibility();
expect($("#back-to-top")).not.toHaveClass("visible");
});
});
});

View file

@ -1,53 +0,0 @@
describe("Diaspora.Widgets.BackToTop", function() {
var backToTop;
beforeEach(function() {
spec.loadFixture("aspects_index");
backToTop = Diaspora.BaseWidget.instantiate("BackToTop", $("#back-to-top"));
$.fx.off = true;
});
describe("integration", function() {
beforeEach(function() {
backToTop = new Diaspora.Widgets.BackToTop();
spyOn(backToTop, "backToTop");
spyOn(backToTop, "toggleVisibility");
backToTop.publish("widget/ready", [$("#back-to-top")]);
});
it("calls backToTop when the button is clicked", function() {
backToTop.button.click();
expect(backToTop.backToTop).toHaveBeenCalled();
});
});
describe("backToTop", function() {
it("animates scrollTop to 0", function() {
backToTop.backToTop($.Event());
expect($("body").scrollTop()).toEqual(0);
});
});
describe("toggleVisibility", function() {
it("adds a visibility class to the button", function() {
var spy = spyOn(backToTop.body, "scrollTop").and.returnValue(999);
backToTop.toggleVisibility();
expect(backToTop.button.hasClass("visible")).toBe(false);
spy.and.returnValue(1001);
backToTop.toggleVisibility();
expect(backToTop.button.hasClass("visible")).toBe(true);
});
});
afterEach(function() {
$.fx.off = false;
});
});