Browse files

Mobile Toggle

* Add a mobile toggle to the UI to allow admins to change between mobile and full template views of pages.
  • Loading branch information...
1 parent ede00dd commit 625007171495dd546b396a0471fee3e09ff063c7 @peakpg peakpg committed Feb 9, 2012
View
31 app/views/bcms_mobile/_mobile_toggle.html.erb
@@ -0,0 +1,31 @@
+<style>
+ #mobile_toggle {
+ float: left;
+ text-transform: uppercase;
+ padding-left: 110px;
+ margin-top: 12px;
+ margin-right: 0px;
+ color: black;
+ font-weight: bold;
+ width: 200px;
+ }
+
+ #mobile_toggle div {
+ float: left;
+ }
+</style>
+<%
+ mobile_state = session[:mobile_mode] == true ? "ON" : "OFF"
+ button_text = session[:mobile_mode] == true ? "TURN OFF" : "TURN ON"
+ new_template = session[:mobile_mode] == true ? "full" : "mobile"
+%>
+
+<div id="mobile_toggle">
+ <div class="visual_editor_label">View As Mobile?:</div>
+ <div class="visual_editor_value_container">
+ <div><span id="visual_editor_state"><%= mobile_state %></span></div>
+ </div>
+ <div class="visual_editor_toggle_container">
+ <div class="sm_button"><%= link_to "<span id='visual_editor_action'>#{button_text}</span>".html_safe, "#{@page.path}?template=#{new_template}", :target => "_top", :class => "sm_button" %></div>
+ </div>
+</div>
View
21 app/views/cms/content/show.html.erb
@@ -1,21 +0,0 @@
-<%
- # This is a 100% copy of show.html.erb from core browsercms.
- # This seems to need to be present in the same project as show.mobile.erb, or else cmsadmins will just see use the .mobile file during edit mode, which
- # make the entire result mobile. Not sure why, or if this will be require to be packaged in the gem too.
-%>
-<% page_title @page.page_title %>
-
-<%= content_for :html_head do %>
- <meta name="generator" content="BrowserCMS <%= Cms.version %>"/>
-<% end %>
-<% if @show_toolbar %>
- <% flash.keep %>
-<% end %>
-
-<% @_connectors.each_with_index do |connector, i| %>
- <%= content_for(connector.container.to_sym) do %>
- <%= render_connector_and_connectable(connector, @_connectables[i]) %>
- <% end %>
-<% end %>
-
-
View
22 app/views/cms/content/show.mobile.erb
@@ -1,22 +0,0 @@
-<%
- # This is a 100% copy of show.html.erb.
- # We need it so that mobile requests can also use the mobile templates
- # @todo Would be better to DRY this up perhaps with a Custom Renderer for Content
- # (http://stackoverflow.com/questions/5284443/rails-custom-renderer)
-%>
-<% page_title @page.page_title %>
-
-<%= content_for :html_head do %>
- <meta name="generator" content="BrowserCMS <%= Cms.version %>"/>
-<% end %>
-<% if @show_toolbar %>
- <% flash.keep %>
-<% end %>
-
-<% @_connectors.each_with_index do |connector, i| %>
- <%= content_for(connector.container.to_sym) do %>
- <%= render_connector_and_connectable(connector, @_connectables[i]) %>
- <% end %>
-<% end %>
-
-
View
121 app/views/layouts/_page_toolbar.html.erb
@@ -0,0 +1,121 @@
+<% if (logged_in? && @page && !@hide_page_toolbar) %>
+ <% status = @page.live? ? 'published' : 'draft' %>
+ <%= image_tag "cms/page_toolbar/page_toolbar_l.gif", :style => "float: left;" %>
+ <%= image_tag "cms/page_toolbar/status_#{status}_l.gif", :style => "float: left;" %>
+ <%= image_tag "cms/page_toolbar/page_toolbar_r.gif", :style => "float: right;" %>
+ <div id="page_toolbar">
+ <div id="status_div" class="<%= status %> page_attribute_div">
+ <div class="page_attribute_label">Status:</div>
+ <div id="<%= status %>_page_status_container" class="page_attribute_value_container">
+ <%= image_tag "cms/page_toolbar/page_toolbar_inset_#{ status }_l.gif", :style => "float: left;" %>
+ <div id="page_status" class="page_attribute_value"><%= status %></div>
+ <%= image_tag "cms/page_toolbar/page_toolbar_inset_#{ status }_r.gif", :style => "float: left;" %>
+ </div>
+ </div>
+ <div class="page_attribute_div">
+ <div class="page_attribute_label">Section:</div>
+ <div class="page_attribute_value_container">
+ <%= image_tag "cms/page_toolbar/page_toolbar_inset_l.gif", :style => "float: left;" %>
+ <div id="section_link" class="page_attribute_value"><%= link_to h(@page.section.name), cms_sections_path(:page_id => @page), :target => "_top" %></div>
+ <%= image_tag "cms/page_toolbar/page_toolbar_inset_r.gif", :style => "float: left;" %>
+ </div>
+ </div>
+ <div class="page_attribute_div">
+ <div class="page_attribute_label">Page:</div>
+ <div class="page_attribute_value_container">
+ <%= image_tag "cms/page_toolbar/page_toolbar_inset_l.gif", :style => "float: left;" %>
+ <div class="page_attribute_value"><%= h(@page.name) %></div>
+ <%= image_tag "cms/page_toolbar/page_toolbar_inset_r.gif", :style => "float: left;" %>
+ </div>
+ </div>
+ <div class="page_attribute_div">
+ <div class="page_attribute_label">Template:</div>
+ <div class="page_attribute_value_container">
+ <%= image_tag "cms/page_toolbar/page_toolbar_inset_l.gif", :style => "float: left;" %>
+ <div class="page_attribute_value"><%= h(@page.template_name) %></div>
+ <%= image_tag "cms/page_toolbar/page_toolbar_inset_r.gif", :style => "float: left;" %>
+ </div>
+ </div>
+ <div class="page_attribute_div">
+ <div class="page_attribute_label">Version:</div>
+ <div class="page_attribute_value_container">
+ <%= image_tag "cms/page_toolbar/page_toolbar_inset_l.gif", :style => "float: left;" %>
+ <div class="page_attribute_value"><%= h(@page.version) %><%= ' (LIVE)' if @page.live_version && @page.version == @page.live_version.version %></div>
+ <%= image_tag "cms/page_toolbar/page_toolbar_inset_r.gif", :style => "float: left;" %>
+ </div>
+ </div>
+ </div>
+ <div class="buttons">
+
+ <%= link_to "<span>Publish</span>".html_safe,
+ @page.live? ? '#' : publish_cms_page_path(@page),
+ :id => "publish_button",
+ :class => "http_put button#{' disabled' if !current_user.able_to?(:publish_content) || !current_user.able_to_edit?(@page) || @page.version != @page.draft.version || @page.live?} left",
+ :target => "_top" %>
+
+ <%= link_to "<span>Assign</span>".html_safe,
+ new_cms_page_task_path(@page),
+ :id => "assign_button",
+ :class => "button#{ ' disabled' if @page.assigned_to == current_user || !current_user.able_to_edit?(@page) } middle",
+ :target => "_top" %>
+
+ <%= link_to "<span>Complete Task</span>".html_safe,
+ @page.current_task ? complete_cms_task_path(@page.current_task) : '#',
+ :id => "complete_task_button",
+ :class => "http_put button#{ ' disabled' if @page.assigned_to != current_user || !current_user.able_to_edit?(@page) } right",
+ :target => "_top" %>
+
+ <%= link_to "<span>Edit Properties</span>".html_safe,
+ [:edit, :cms, @page],
+ :id => "edit_properties_button",
+ :class => "spacer button#{ ' disabled' unless current_user.able_to_edit?(@page) }",
+ :target => "_top" %>
+
+ <%= link_to "<span>List Versions</span>".html_safe,
+ versions_cms_page_path(@page),
+ :class => "spacer button#{ ' disabled' unless current_user.able_to_edit?(@page) }",
+ :target => "_top" %>
+
+ <%= able_to? :publish_content do %>
+ <% if @page.draft_version? %>
+ <%= link_to "<span><span class=\"delete_img\">&nbsp;</span>Delete</span>".html_safe,
+ [:cms, @page],
+ :id => "delete_button",
+ :title => "Are you sure you want to delete '#{@page.name}'?",
+ :target => "_top",
+ :class => "spacer button confirm_with_title http_delete#{ ' disabled' unless current_user.able_to_publish?(@page) }" %>
+ <% else %>
+ <%= link_to "<span>Revert to this Version</span>".html_safe,
+ revert_to_cms_page_path(@page, @page.version),
+ :id => "revert_button",
+ :class => "button http_put",
+ :target => "_top" %>
+ <% end %>
+ <% end %>
+ <%= render :partial => "bcms_mobile/mobile_toggle" %>
+ <div id="visual_editor_toggle">
+ <% if @page.version == @page.draft.version %>
+ <div class="visual_editor_label">Visual Editor:</div>
+ <div class="visual_editor_value_container">
+ <% if @mode == "edit" %>
+ <div>
+ <span id="visual_editor_state"<%= ' title="You don\'t have permission to edit this page"' unless current_user.able_to_edit?(@page) %>>ON<%= '*' unless current_user.able_to_edit?(@page) %></span>
+ </div>
+ <% else %>
+ <div><span id="visual_editor_state">OFF</span></div>
+ <% end %>
+ </div>
+ <div class="visual_editor_toggle_container">
+ <% if @mode == "edit" %>
+ <div class="sm_button"><%= link_to '<span id="visual_editor_action">TURN OFF</span>'.html_safe, url_with_mode(request.referrer, "view"), :target => "_top", :class => "sm_button" %></div>
+ <% else %>
+ <div class="sm_button"><%= link_to '<span id="visual_editor_action">TURN ON</span>'.html_safe, url_with_mode(request.referrer, "edit"), :target => "_top", :class => "sm_button" %></div>
+ <% end %>
+ </div>
+ <% else %>
+ </div>
+ <%= link_to("<span>View Current Version</span>".html_safe, @page.path, :class => "button current_version", :target => "_top") %>
+ <% end %>
+ </div>
+ </div>
+<% end %>
View
2 lib/bcms_mobile/mobile_aware.rb
@@ -9,6 +9,8 @@ def full_site_url
def mobile_site_url
url_for(:host=>SITE_DOMAIN, :prefer_mobile_site=>true)
end
+
+
end
module MobileAware

0 comments on commit 6250071

Please sign in to comment.