diff --git a/app/assets/javascripts/common.js b/app/assets/javascripts/common.js index 6bdc81f0b..cbec48d0b 100644 --- a/app/assets/javascripts/common.js +++ b/app/assets/javascripts/common.js @@ -28,6 +28,17 @@ $(function() { $('#notice').fadeOut("fast"); e.preventDefault(); }); + + $("#desktop-version-link a").click(function() { + $.ajax("/users/" + Danbooru.meta("current-user-id"), { + method: "PUT", + data: { + "user[disable_responsive_mode]": "true" + } + }).success(function() { + location.reload(); + }); + }); }); var Danbooru = {}; diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 0af587503..687dbecfd 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -1,6 +1,4 @@ class StaticController < ApplicationController - before_filter :check_desktop_mode, only: :site_map - def terms_of_service end @@ -19,15 +17,5 @@ class StaticController < ApplicationController def site_map end - - private - - def check_desktop_mode - if params[:dm] - cookies[:dm] = "1" - redirect_to :back - return false - end - end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 52622b9a4..6b8cd55af 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,7 +1,6 @@ class UsersController < ApplicationController respond_to :html, :xml, :json skip_before_filter :api_check - before_filter :process_session_actions, only: [:update] def new @user = User.new @@ -79,16 +78,6 @@ class UsersController < ApplicationController private - def process_session_actions - if params[:user].has_key?(:desktop_mode) - if params[:user].delete(:desktop_mode) == "0" - cookies.delete(:dm) - else - cookies[:dm] = "1" - end - end - end - def check_privilege(user) raise User::PrivilegeError unless (user.id == CurrentUser.id || CurrentUser.is_admin?) end diff --git a/app/logical/anonymous_user.rb b/app/logical/anonymous_user.rb index 49d7972ed..4cc921903 100644 --- a/app/logical/anonymous_user.rb +++ b/app/logical/anonymous_user.rb @@ -269,6 +269,10 @@ class AnonymousUser false end + def disable_responsive_mode? + false + end + User::Roles.reject {|r| r == :anonymous}.each do |name| define_method("is_#{name}?") do false diff --git a/app/models/user.rb b/app/models/user.rb index 4679b21b2..ca582c23f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -57,13 +57,14 @@ class User < ApplicationRecord disable_cropped_thumbnails disable_mobile_gestures enable_safe_mode + disable_responsive_mode ) include Danbooru::HasBitFlags has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs" attr_accessor :password, :old_password - attr_accessible :dmail_filter_attributes, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :disable_categorized_saved_searches, :disable_tagged_filenames, :enable_recent_searches, :disable_cropped_thumbnails, :disable_mobile_gestures, :enable_safe_mode, :as => [:moderator, :gold, :platinum, :member, :anonymous, :default, :builder, :admin] + attr_accessible :dmail_filter_attributes, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :disable_categorized_saved_searches, :disable_tagged_filenames, :enable_recent_searches, :disable_cropped_thumbnails, :disable_mobile_gestures, :enable_safe_mode, :disable_responsive_mode, :as => [:moderator, :gold, :platinum, :member, :anonymous, :default, :builder, :admin] attr_accessible :level, :as => :admin validates :name, user_name: true, on: :create diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index eee6c5844..b3ef1ce0f 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -5,7 +5,7 @@ <%= csrf_meta_tag %> - <% unless cookies[:dm] %> + <% unless CurrentUser.disable_responsive_mode? %> <% end %> diff --git a/app/views/static/_footer.html.erb b/app/views/static/_footer.html.erb index c8e3e0242..d84a7c018 100644 --- a/app/views/static/_footer.html.erb +++ b/app/views/static/_footer.html.erb @@ -8,8 +8,10 @@ <% if CurrentUser.user.enable_post_navigation %> – <%= link_to "Keyboard shortcuts available", keyboard_shortcuts_path %> <% end %> - - – - <%= link_to "Desktop version", site_map_path(:dm => "1"), :rel => "nofollow" %> - + <% if CurrentUser.is_member? %> + + – + <%= link_to "Disable responsive mode", edit_user_path(CurrentUser.id), :rel => "nofollow" %> + + <% end %> diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index e826b1615..55812a2e8 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -91,11 +91,7 @@ <%= f.input :favorite_tags, :label => "Frequent tags", :hint => "A list of tags that you use often. They will appear when using the list of Related Tags.", :input_html => { :rows => 5, :data => { :autocomplete => "tag-query" } } %> -