move desktop mode to user pref
This commit is contained in:
@@ -28,6 +28,17 @@ $(function() {
|
|||||||
$('#notice').fadeOut("fast");
|
$('#notice').fadeOut("fast");
|
||||||
e.preventDefault();
|
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 = {};
|
var Danbooru = {};
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
class StaticController < ApplicationController
|
class StaticController < ApplicationController
|
||||||
before_filter :check_desktop_mode, only: :site_map
|
|
||||||
|
|
||||||
def terms_of_service
|
def terms_of_service
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -19,15 +17,5 @@ class StaticController < ApplicationController
|
|||||||
|
|
||||||
def site_map
|
def site_map
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def check_desktop_mode
|
|
||||||
if params[:dm]
|
|
||||||
cookies[:dm] = "1"
|
|
||||||
redirect_to :back
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json
|
||||||
skip_before_filter :api_check
|
skip_before_filter :api_check
|
||||||
before_filter :process_session_actions, only: [:update]
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@user = User.new
|
@user = User.new
|
||||||
@@ -79,16 +78,6 @@ class UsersController < ApplicationController
|
|||||||
|
|
||||||
private
|
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)
|
def check_privilege(user)
|
||||||
raise User::PrivilegeError unless (user.id == CurrentUser.id || CurrentUser.is_admin?)
|
raise User::PrivilegeError unless (user.id == CurrentUser.id || CurrentUser.is_admin?)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -269,6 +269,10 @@ class AnonymousUser
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def disable_responsive_mode?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
User::Roles.reject {|r| r == :anonymous}.each do |name|
|
User::Roles.reject {|r| r == :anonymous}.each do |name|
|
||||||
define_method("is_#{name}?") do
|
define_method("is_#{name}?") do
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -57,13 +57,14 @@ class User < ApplicationRecord
|
|||||||
disable_cropped_thumbnails
|
disable_cropped_thumbnails
|
||||||
disable_mobile_gestures
|
disable_mobile_gestures
|
||||||
enable_safe_mode
|
enable_safe_mode
|
||||||
|
disable_responsive_mode
|
||||||
)
|
)
|
||||||
|
|
||||||
include Danbooru::HasBitFlags
|
include Danbooru::HasBitFlags
|
||||||
has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs"
|
has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs"
|
||||||
|
|
||||||
attr_accessor :password, :old_password
|
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
|
attr_accessible :level, :as => :admin
|
||||||
|
|
||||||
validates :name, user_name: true, on: :create
|
validates :name, user_name: true, on: :create
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
|
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
|
||||||
<link rel="top" title="<%= Danbooru.config.app_name %>" href="/">
|
<link rel="top" title="<%= Danbooru.config.app_name %>" href="/">
|
||||||
<%= csrf_meta_tag %>
|
<%= csrf_meta_tag %>
|
||||||
<% unless cookies[:dm] %>
|
<% unless CurrentUser.disable_responsive_mode? %>
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
<% end %>
|
<% end %>
|
||||||
<meta name="tag-category-names" content="<%= TagCategory.categories %>">
|
<meta name="tag-category-names" content="<%= TagCategory.categories %>">
|
||||||
|
|||||||
@@ -8,8 +8,10 @@
|
|||||||
<% if CurrentUser.user.enable_post_navigation %>
|
<% if CurrentUser.user.enable_post_navigation %>
|
||||||
– <%= link_to "Keyboard shortcuts available", keyboard_shortcuts_path %>
|
– <%= link_to "Keyboard shortcuts available", keyboard_shortcuts_path %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<span id="desktop-version-link">
|
<% if CurrentUser.is_member? %>
|
||||||
–
|
<span id="desktop-version-link">
|
||||||
<%= link_to "Desktop version", site_map_path(:dm => "1"), :rel => "nofollow" %>
|
–
|
||||||
</span>
|
<%= link_to "Disable responsive mode", edit_user_path(CurrentUser.id), :rel => "nofollow" %>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -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" } } %>
|
<%= 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" } } %>
|
||||||
|
|
||||||
<div class="input select field_with_hint">
|
<%= f.input :disable_responsive_mode, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false, :hint => "Disable alternative layout for mobile and tablet" %>
|
||||||
<label class="select optional" for="user_desktop_mode">Desktop mode</label>
|
|
||||||
<%= select_tag "user[desktop_mode]", options_for_select([["No", "0"], ["Yes", "1"]], cookies[:dm]), :class => "select optional" %>
|
|
||||||
<span class="hint">Force desktop version of site even on mobile.</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= f.input :custom_style, :label => "Custom <a href='http://en.wikipedia.org/wiki/Cascading_Style_Sheets'>CSS</a> style".html_safe, :hint => "Style to apply to the whole site.", :input_html => {:size => "40x5"} %>
|
<%= f.input :custom_style, :label => "Custom <a href='http://en.wikipedia.org/wiki/Cascading_Style_Sheets'>CSS</a> style".html_safe, :hint => "Style to apply to the whole site.", :input_html => {:size => "40x5"} %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
Reference in New Issue
Block a user