Merge branch 'next-minor' into develop

This commit is contained in:
Steffen van Bergerem 2017-03-06 21:11:54 +01:00
commit 1b9ab16039
No known key found for this signature in database
GPG key ID: 315C9787D548DC6B
15 changed files with 46 additions and 26 deletions

View file

@ -18,6 +18,7 @@
## Refactor
* Remove unused setPreload function [#7354](https://github.com/diaspora/diaspora/pull/7354)
* Remove jQuery deprecations [#7356](https://github.com/diaspora/diaspora/pull/7356)
## Bug fixes

View file

@ -1,5 +1,5 @@
$(document).ready(function() {
$("#js-app-logo").error(function () {
$("#js-app-logo").on("error", function() {
$(this).attr("src", ImagePaths.get("user/default.png"));
});
});

View file

@ -56,7 +56,7 @@ app.views.Base = Backbone.View.extend({
.attr("data-template", _.last(this.templateName.split("/")));
// add avatar fallback if it can't be loaded
this.$el.find(this.avatars.selector).error(this.avatars.fallback);
this.$el.find(this.avatars.selector).on("error", this.avatars.fallback);
// add placeholder support for old browsers
this.$("input, textarea").placeholder();

View file

@ -18,7 +18,7 @@ app.views.ContactStream = Backbone.View.extend({
$("#paginate .loader").removeClass("hidden");
$.ajax(this._fetchUrl(), {
context: this
}).success(function(response) {
}).done(function(response) {
if (response.length === 0) {
this.onEmptyResponse();
} else {

View file

@ -96,7 +96,7 @@ app.views.NotificationDropdown = app.views.Base.extend({
afterNotificationChanges: function(node) {
node.find(".unread-toggle .entypo-eye").tooltip("destroy").tooltip();
node.find(this.avatars.selector).error(this.avatars.fallback);
node.find(this.avatars.selector).on("error", this.avatars.fallback);
},
finishLoading: function() {

View file

@ -149,7 +149,7 @@ app.views.PublisherUploader = Backbone.View.extend({
dataType: "json",
type: "DELETE",
success: function() {
$.when(photo.fadeOut(400)).then(function(){
photo.fadeOut(400, function() {
photo.remove();
if( self.publisher.$(".publisher_photo").length === 0 ) {

View file

@ -43,7 +43,7 @@ app.views.Publisher = Backbone.View.extend({
// if there is data in the publisher we ask for a confirmation
// before the user is able to leave the page
$(window).on("beforeunload", _.bind(this._beforeUnload, this));
$(window).unload(this.clear.bind(this));
$(window).on("unload", this.clear.bind(this));
// hide close and preview buttons and manage services link
// in case publisher is standalone

View file

@ -6,7 +6,7 @@ app.views.Tags = Backbone.View.extend({
app.publisher.setText("#"+ opts.hashtagName + " ");
}
// add avatar fallback if it can't be loaded
$(app.views.Base.prototype.avatars.selector).error(app.views.Base.prototype.avatars.fallback);
$(app.views.Base.prototype.avatars.selector).on("error", app.views.Base.prototype.avatars.fallback);
}
});
// @license-end

View file

@ -4,6 +4,7 @@ describe("app", function() {
spyOn(app.Router.prototype, "initialize");
spyOn(app, "setupDummyPreloads");
spyOn(app, "setupUser");
spyOn(app, "setupAspects");
spyOn(app, "setupHeader");
spyOn(app, "setupBackboneLinks");
spyOn(app, "setupGlobalViews");
@ -16,6 +17,7 @@ describe("app", function() {
expect(app.Router.prototype.initialize).toHaveBeenCalled();
expect(app.setupDummyPreloads).toHaveBeenCalled();
expect(app.setupUser).toHaveBeenCalled();
expect(app.setupAspects).toHaveBeenCalled();
expect(app.setupHeader).toHaveBeenCalled();
expect(app.setupBackboneLinks).toHaveBeenCalled();
expect(app.setupGlobalViews).toHaveBeenCalled();
@ -39,18 +41,23 @@ describe("app", function() {
});
describe("setupForms", function() {
beforeEach(function() {
spec.content().append("<textarea/> <input/>");
});
it("calls jQuery.placeholder() for inputs", function() {
spyOn($.fn, "placeholder");
app.setupForms();
expect($.fn.placeholder).toHaveBeenCalled();
expect($.fn.placeholder.calls.mostRecent().object.selector).toBe("input, textarea");
expect($.fn.placeholder.calls.mostRecent().object.is($("input"))).toBe(true);
expect($.fn.placeholder.calls.mostRecent().object.is($("textarea"))).toBe(true);
});
it("initializes autosize for textareas", function(){
spyOn(window, "autosize");
app.setupForms();
expect(window.autosize).toHaveBeenCalled();
expect(window.autosize.calls.mostRecent().args[0].selector).toBe("textarea");
expect(window.autosize.calls.mostRecent().args[0].is($("textarea"))).toBe(true);
});
});

View file

@ -123,14 +123,18 @@ describe('app.Router', function () {
});
describe("gettingStarted", function() {
beforeEach(function() {
spec.content().append($("<div id='hello-there'>"));
});
it("renders app.pages.GettingStarted", function() {
app.router.navigate("/getting_started", {trigger: true});
expect(app.page.$el.selector).toEqual("#hello-there");
expect(app.page.$el.is($("#hello-there"))).toBe(true);
});
it("renders app.pages.GettingStarted when the URL has a trailing slash", function() {
app.router.navigate("/getting_started/", {trigger: true});
expect(app.page.$el.selector).toEqual("#hello-there");
expect(app.page.$el.is($("#hello-there"))).toBe(true);
});
});

View file

@ -15,7 +15,7 @@ describe("app.views.PublisherMention", function() {
this.view = new app.views.PublisherMention({ el: "#publisher" });
expect(app.views.SearchBase.prototype.initialize).toHaveBeenCalled();
var call = app.views.SearchBase.prototype.initialize.calls.mostRecent();
expect(call.args[0].typeaheadInput.selector).toBe("#publisher .typeahead-mention-box");
expect(call.args[0].typeaheadInput.is($("#publisher .typeahead-mention-box"))).toBe(true);
expect(call.args[0].customSearch).toBeTruthy();
expect(call.args[0].autoselect).toBeTruthy();
expect(call.args[0].remoteRoute).toEqual({url: "/contacts"});

View file

@ -591,7 +591,7 @@ describe("app.views.Publisher", function() {
});
context('photo removal', function() {
beforeEach(function() {
beforeEach(function(done) {
this.view = new app.views.Publisher();
this.view.wrapperEl.addClass("with_attachments");
this.view.photozoneEl.html(
@ -603,6 +603,7 @@ describe("app.views.Publisher", function() {
);
spyOn(jQuery, 'ajax').and.callFake(function(opts) { opts.success(); });
this.view.viewUploader.on("change", done);
this.view.photozoneEl.find(".x").click();
});

View file

@ -10,7 +10,7 @@ describe("app.views.Search", function() {
spyOn(app.views.SearchBase.prototype, "initialize");
this.view = new app.views.Search({el: "#search_people_form"});
var call = app.views.SearchBase.prototype.initialize.calls.mostRecent();
expect(call.args[0].typeaheadInput.selector).toBe("#search_people_form #q");
expect(call.args[0].typeaheadInput.is($("#search_people_form #q"))).toBe(true);
expect(call.args[0].remoteRoute).toEqual({url: "/search"});
});

View file

@ -119,42 +119,49 @@ describe("app.views.Base", function(){
context("calling out to third party plugins", function() {
it("replaces .time with relative time ago in words", function() {
this.view.templateName = false;
spyOn($.fn, "timeago");
this.view.$el.append("<time/>");
this.view.render();
expect($.fn.timeago).toHaveBeenCalled();
expect($.fn.timeago.calls.mostRecent().object.selector).toBe("time");
expect($.fn.timeago.calls.mostRecent().object.first().is("time")).toBe(true);
});
it("initializes tooltips declared with the view's tooltipSelector property", function(){
this.view.templateName = false;
this.view.tooltipSelector = ".christopher_columbus, .barrack_obama, .block_user";
this.view.$el.append("<div class='christopher_columbus barrack_obama block_user'/>");
spyOn($.fn, "tooltip");
this.view.render();
expect($.fn.tooltip.calls.mostRecent().object.selector).toBe(".christopher_columbus, .barrack_obama, .block_user");
});
it("applies infield labels", function(){
spyOn($.fn, "placeholder");
this.view.render();
expect($.fn.placeholder).toHaveBeenCalled();
expect($.fn.placeholder.calls.mostRecent().object.selector).toBe("input, textarea");
expect(
$.fn.tooltip.calls.mostRecent().object.is(".christopher_columbus, .barrack_obama, .block_user")
).toBe(true);
});
});
});
describe("#renderTemplate", function(){
beforeEach(function() {
this.view.$el.htmlOriginal = this.view.$el.html;
spyOn(this.view.$el, "html").and.callFake(function() {
this.htmlOriginal("<input><textarea/></input>");
return this;
});
});
it("calls jQuery.placeholder() for inputs", function() {
spyOn($.fn, "placeholder");
this.view.renderTemplate();
expect($.fn.placeholder).toHaveBeenCalled();
expect($.fn.placeholder.calls.mostRecent().object.selector).toBe("input, textarea");
expect($.fn.placeholder.calls.mostRecent().object.is("input, textarea")).toBe(true);
});
it("initializes autosize for textareas", function(){
spyOn(window, "autosize");
this.view.renderTemplate();
expect(window.autosize).toHaveBeenCalled();
expect(window.autosize.calls.mostRecent().args[0].selector).toBe("textarea");
expect(window.autosize.calls.mostRecent().args[0].is("textarea")).toBe(true);
});
});
});

View file

@ -8,7 +8,7 @@ describe("Diaspora.Mobile", function(){
it("calls autosize for textareas", function(){
Diaspora.Mobile.initialize();
expect(window.autosize).toHaveBeenCalled();
expect(window.autosize.calls.mostRecent().args[0].selector).toBe("textarea");
expect(window.autosize.calls.mostRecent().args[0].is($("textarea"))).toBe(true);
});
it("deactivates shield", function(){