diff --git a/.eslintrc b/.eslintrc index 62ba89fda..977ea0396 100644 --- a/.eslintrc +++ b/.eslintrc @@ -10,16 +10,17 @@ "autosize": false, "Backbone": false, "Bloodhound": false, + "blueimp": false, "gon": false, "Handlebars": false, "HandlebarsTemplates": false, "ImagePaths": false, "jsxc": false, "L": false, - "Routes": false, "OSM": false, + "PerfectScrollbar": false, "qq": false, - "blueimp": false, + "Routes": false, "loginAs": true, "logout": true, diff --git a/Gemfile b/Gemfile index 82291f0bc..faa3cca85 100644 --- a/Gemfile +++ b/Gemfile @@ -120,7 +120,7 @@ source "https://rails-assets.org" do gem "rails-assets-jquery.are-you-sure", "1.9.0" gem "rails-assets-jquery-placeholder", "2.3.1" gem "rails-assets-jquery-textchange", "0.2.3" - gem "rails-assets-perfect-scrollbar", "0.6.16" + gem "rails-assets-utatti-perfect-scrollbar", "1.3.0" end gem "markdown-it-html5-embed", "1.0.0" diff --git a/Gemfile.lock b/Gemfile.lock index ca992d12a..3a9359908 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -553,8 +553,8 @@ GEM rails-assets-markdown-it-sanitizer (0.4.3) rails-assets-markdown-it-sub (1.0.0) rails-assets-markdown-it-sup (1.0.0) - rails-assets-perfect-scrollbar (0.6.16) rails-assets-underscore (1.8.3) + rails-assets-utatti-perfect-scrollbar (1.3.0) rails-controller-testing (1.0.2) actionpack (~> 5.x, >= 5.0.1) actionview (~> 5.x, >= 5.0.1) @@ -867,7 +867,7 @@ DEPENDENCIES rails-assets-markdown-it-sanitizer (= 0.4.3)! rails-assets-markdown-it-sub (= 1.0.0)! rails-assets-markdown-it-sup (= 1.0.0)! - rails-assets-perfect-scrollbar (= 0.6.16)! + rails-assets-utatti-perfect-scrollbar (= 1.3.0)! rails-controller-testing (= 1.0.2) rails-i18n (= 5.1.1) rails-timeago (= 2.16.0) diff --git a/app/assets/javascripts/app/app.js b/app/assets/javascripts/app/app.js index 1360e952e..c0ee09de5 100644 --- a/app/assets/javascripts/app/app.js +++ b/app/assets/javascripts/app/app.js @@ -14,7 +14,7 @@ //= require_tree ./collections //= require_tree ./views -//= require perfect-scrollbar/perfect-scrollbar.jquery +//= require utatti-perfect-scrollbar/dist/perfect-scrollbar var app = { collections: {}, diff --git a/app/assets/javascripts/app/views/notification_dropdown_view.js b/app/assets/javascripts/app/views/notification_dropdown_view.js index 1d14cac08..0ae192564 100644 --- a/app/assets/javascripts/app/views/notification_dropdown_view.js +++ b/app/assets/javascripts/app/views/notification_dropdown_view.js @@ -12,7 +12,7 @@ app.views.NotificationDropdown = app.views.Base.extend({ this.dropdown = $("#notification-dropdown"); this.dropdownNotifications = this.dropdown.find(".notifications"); this.ajaxLoader = this.dropdown.find(".ajax-loader"); - this.perfectScrollbarInitialized = false; + this.perfectScrollbar = null; this.dropdownNotifications.scroll(this.dropdownScroll.bind(this)); this.bindCollectionEvents(); }, @@ -106,18 +106,17 @@ app.views.NotificationDropdown = app.views.Base.extend({ }, updateScrollbar: function() { - if(this.perfectScrollbarInitialized) { - this.dropdownNotifications.perfectScrollbar("update"); + if (this.perfectScrollbar) { + this.perfectScrollbar.update(); } else { - this.dropdownNotifications.perfectScrollbar(); - this.perfectScrollbarInitialized = true; + this.perfectScrollbar = new PerfectScrollbar(this.dropdownNotifications[0]); } }, destroyScrollbar: function() { - if(this.perfectScrollbarInitialized) { - this.dropdownNotifications.perfectScrollbar("destroy"); - this.perfectScrollbarInitialized = false; + if (this.perfectScrollbar) { + this.perfectScrollbar.destroy(); + this.perfectScrollbar = null; } } }); diff --git a/app/assets/stylesheets/_application.scss b/app/assets/stylesheets/_application.scss index 983ea5151..91a94357d 100644 --- a/app/assets/stylesheets/_application.scss +++ b/app/assets/stylesheets/_application.scss @@ -1,4 +1,4 @@ -@import 'perfect-scrollbar'; +@import 'utatti-perfect-scrollbar/css/perfect-scrollbar'; @import 'color-variables'; @import 'bootstrap-complete'; diff --git a/features/step_definitions/notifications_steps.rb b/features/step_definitions/notifications_steps.rb index 11cb5efa7..9088dacc2 100644 --- a/features/step_definitions/notifications_steps.rb +++ b/features/step_definitions/notifications_steps.rb @@ -32,7 +32,7 @@ Then "the notification dropdown should be visible" do end Then "the notification dropdown scrollbar should be visible" do - expect(find(:css, ".ps-active-y")).to be_visible + expect(find(:css, ".ps--active-y")).to be_visible end Then /^there should be (\d+) notifications loaded$/ do |n| diff --git a/spec/javascripts/app/views/notification_dropdown_view_spec.js b/spec/javascripts/app/views/notification_dropdown_view_spec.js index 5a1452672..725ae0d57 100644 --- a/spec/javascripts/app/views/notification_dropdown_view_spec.js +++ b/spec/javascripts/app/views/notification_dropdown_view_spec.js @@ -73,41 +73,34 @@ describe("app.views.NotificationDropdown", function() { describe("updateScrollbar", function() { it("Initializes perfectScrollbar", function() { - this.view.perfectScrollbarInitialized = false; - spyOn($.fn, "perfectScrollbar"); + this.view.perfectScrollbar = null; + spyOn(window, "PerfectScrollbar"); this.view.updateScrollbar(); - expect($.fn.perfectScrollbar).toHaveBeenCalledWith(); - expect($.fn.perfectScrollbar.calls.mostRecent().object).toEqual(this.view.dropdownNotifications); - expect(this.view.perfectScrollbarInitialized).toBeTruthy(); + expect(window.PerfectScrollbar).toHaveBeenCalledWith(this.view.dropdownNotifications[0]); + expect(this.view.perfectScrollbar).not.toBeNull(); }); it("Updates perfectScrollbar", function() { - this.view.perfectScrollbarInitialized = true; - this.view.dropdownNotifications.perfectScrollbar(); - spyOn($.fn, "perfectScrollbar"); + this.view.perfectScrollbar = new PerfectScrollbar(this.view.dropdownNotifications[0]); + spyOn(this.view.perfectScrollbar, "update"); this.view.updateScrollbar(); - expect($.fn.perfectScrollbar).toHaveBeenCalledWith("update"); - expect($.fn.perfectScrollbar.calls.mostRecent().object).toEqual(this.view.dropdownNotifications); - expect(this.view.perfectScrollbarInitialized).toBeTruthy(); + expect(this.view.perfectScrollbar.update).toHaveBeenCalled(); }); }); describe("destroyScrollbar", function() { it("destroys perfectScrollbar", function() { - this.view.perfectScrollbarInitialized = true; - this.view.dropdownNotifications.perfectScrollbar(); - spyOn($.fn, "perfectScrollbar"); + this.view.perfectScrollbar = new PerfectScrollbar(this.view.dropdownNotifications[0]); + var spy = jasmine.createSpy(); + spyOn(this.view.perfectScrollbar, "destroy").and.callFake(spy); this.view.destroyScrollbar(); - expect($.fn.perfectScrollbar).toHaveBeenCalledWith("destroy"); - expect($.fn.perfectScrollbar.calls.mostRecent().object).toEqual(this.view.dropdownNotifications); - expect(this.view.perfectScrollbarInitialized).toBeFalsy(); + expect(spy).toHaveBeenCalled(); + expect(this.view.perfectScrollbar).toBeNull(); }); it("doesn't destroy perfectScrollbar if it isn't initialized", function() { - this.view.perfectScrollbarInitialized = false; - spyOn($.fn, "perfectScrollbar"); - this.view.destroyScrollbar(); - expect($.fn.perfectScrollbar).not.toHaveBeenCalled(); + this.view.perfectScrollbar = null; + expect(this.view.destroyScrollbar).not.toThrow(); }); });