some more replacements for deprecated jquery methods

closes #7356
This commit is contained in:
cmrd Senya 2017-01-29 04:40:39 +02:00 committed by Steffen van Bergerem
parent f36a4cd1f5
commit 2739259fb6
No known key found for this signature in database
GPG key ID: 315C9787D548DC6B
11 changed files with 17 additions and 11 deletions

View file

@ -2,6 +2,7 @@
## Refactor ## Refactor
* Remove unused setPreload function [#7354](https://github.com/diaspora/diaspora/pull/7354) * 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 ## Bug fixes

View file

@ -1,5 +1,5 @@
$(document).ready(function() { $(document).ready(function() {
$("#js-app-logo").error(function () { $("#js-app-logo").on("error", function() {
$(this).attr("src", ImagePaths.get("user/default.png")); $(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("/"))); .attr("data-template", _.last(this.templateName.split("/")));
// add avatar fallback if it can't be loaded // 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 // add placeholder support for old browsers
this.$("input, textarea").placeholder(); this.$("input, textarea").placeholder();

View file

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

View file

@ -96,7 +96,7 @@ app.views.NotificationDropdown = app.views.Base.extend({
afterNotificationChanges: function(node) { afterNotificationChanges: function(node) {
node.find(".unread-toggle .entypo-eye").tooltip("destroy").tooltip(); 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() { finishLoading: function() {

View file

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

View file

@ -44,7 +44,7 @@ app.views.Publisher = Backbone.View.extend({
// if there is data in the publisher we ask for a confirmation // if there is data in the publisher we ask for a confirmation
// before the user is able to leave the page // before the user is able to leave the page
$(window).on("beforeunload", _.bind(this._beforeUnload, this)); $(window).on("beforeunload", _.bind(this._beforeUnload, this));
$(window).unload(this.clear.bind(this)); $(window).on("unload", this.clear.bind(this));
// sync textarea content // sync textarea content
if( this.hiddenInputEl.val() === "" ) { if( this.hiddenInputEl.val() === "" ) {

View file

@ -6,7 +6,7 @@ app.views.Tags = Backbone.View.extend({
app.publisher.setText("#"+ opts.hashtagName + " "); app.publisher.setText("#"+ opts.hashtagName + " ");
} }
// add avatar fallback if it can't be loaded // 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 // @license-end

View file

@ -123,14 +123,18 @@ describe('app.Router', function () {
}); });
describe("gettingStarted", function() { describe("gettingStarted", function() {
beforeEach(function() {
spec.content().append($("<div id='hello-there'>"));
});
it("renders app.pages.GettingStarted", function() { it("renders app.pages.GettingStarted", function() {
app.router.navigate("/getting_started", {trigger: true}); 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() { it("renders app.pages.GettingStarted when the URL has a trailing slash", function() {
app.router.navigate("/getting_started/", {trigger: true}); 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

@ -16,7 +16,7 @@ describe("app.views.PublisherMention", function() {
this.view = new app.views.PublisherMention({ el: "#publisher" }); this.view = new app.views.PublisherMention({ el: "#publisher" });
expect(app.views.SearchBase.prototype.initialize).toHaveBeenCalled(); expect(app.views.SearchBase.prototype.initialize).toHaveBeenCalled();
var call = app.views.SearchBase.prototype.initialize.calls.mostRecent(); 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].customSearch).toBeTruthy();
expect(call.args[0].autoselect).toBeTruthy(); expect(call.args[0].autoselect).toBeTruthy();
expect(call.args[0].remoteRoute).toEqual({url: "/contacts"}); expect(call.args[0].remoteRoute).toEqual({url: "/contacts"});

View file

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