miscellaneous fixes and style tweaks for pages

behaviors:
 - general
   - prevent links to unauthorized pages (course/pages index)
 - index page
   - add loading indicator
 - show page
   - prevent unauthorized attempts to query sequence footer
 - edit page
   - editing with the sidebar works again
   - removed the toolbar
   - will not prompt to save an unedited page
     (when the user doesn't have rights to modify the title)

style:
 - sticky toolbar
   - margins (left & right)
   - drop shadow
 - index page
   - hide empty toolbar
   - fills the entire page width & height
   - inner border color
   - prevent sort headers from wrapping
 - show page
   - hide empty toolbar
   - adjusted margins for the 'Front Page' label
 - sequence footer
   - faster animation
   - print stylesheet

test plan:
 * ensure all wiki draft state pages still function correctly

closes CNVS-7756

Change-Id: I3b13a672b4caacb3a41fa28a1b1c2b29d35140f3
Reviewed-on: https://gerrit.instructure.com/24308
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Matt Goodwin <mattg@instructure.com>
QA-Review: August Thornton <august@instructure.com>
QA-Review: Hannah Bottalla <hannah@instructure.com>
This commit is contained in:
Mark Severson 2013-09-12 11:49:51 -06:00
parent 8a069215d8
commit 171f8d72a9
13 changed files with 124 additions and 79 deletions

View File

@ -4,7 +4,7 @@ require [
'compiled/views/wiki/WikiPageEditView' 'compiled/views/wiki/WikiPageEditView'
], ($, WikiPage, WikiPageEditView) -> ], ($, WikiPage, WikiPageEditView) ->
$('body').addClass('pages edit') $('body').addClass('edit')
wikiPage = new WikiPage ENV.WIKI_PAGE, revision: ENV.WIKI_PAGE_REVISION, contextAssetString: ENV.context_asset_string wikiPage = new WikiPage ENV.WIKI_PAGE, revision: ENV.WIKI_PAGE_REVISION, contextAssetString: ENV.context_asset_string

View File

@ -10,7 +10,7 @@ require [
$.cookie('deleted_page_title', null, path: '/') $.cookie('deleted_page_title', null, path: '/')
$.flashMessage htmlEscape(I18n.t('notices.page_deleted', 'The page "%{title}" has been deleted.', title: deleted_page_title)) $.flashMessage htmlEscape(I18n.t('notices.page_deleted', 'The page "%{title}" has been deleted.', title: deleted_page_title))
$('body').addClass('pages index') $('body').addClass('index').removeClass('with-right-side')
view = new WikiPageIndexView view = new WikiPageIndexView
collection: new WikiPageCollection collection: new WikiPageCollection
@ -19,10 +19,7 @@ require [
WIKI_RIGHTS: ENV.WIKI_RIGHTS WIKI_RIGHTS: ENV.WIKI_RIGHTS
view.collection.setParams sort:'title', per_page:30 view.collection.setParams sort:'title', per_page:30
view.collection.fetch().then -> view.collection.fetch()
view.fetched = true
# Re-render after fetching is complete, but only if there are no pages in the collection
view.render() if view.collection.models.length == 0
$('#content').append(view.$el)
$('#content').append(view.$el)
view.render() view.render()

View File

@ -5,7 +5,7 @@ require [
'compiled/jquery/ModuleSequenceFooter' 'compiled/jquery/ModuleSequenceFooter'
], ($, WikiPage, WikiPageView) -> ], ($, WikiPage, WikiPageView) ->
$('body').addClass('pages show') $('body').addClass('show')
wikiPage = new WikiPage ENV.WIKI_PAGE, revision: ENV.WIKI_PAGE_REVISION, contextAssetString: ENV.context_asset_string wikiPage = new WikiPage ENV.WIKI_PAGE, revision: ENV.WIKI_PAGE_REVISION, contextAssetString: ENV.context_asset_string

View File

@ -104,10 +104,11 @@ define [
# @api private # @api private
initWikiSidebar: -> initWikiSidebar: ->
unless wikiSidebar.inited unless wikiSidebar.inited
$wikiPageBody = @$wikiPageBody
$ -> $ ->
wikiSidebar.init() wikiSidebar.init()
$.scrollSidebar() $.scrollSidebar()
wikiSidebar.attachToEditor(@$wikiPageBody).show() wikiSidebar.attachToEditor($wikiPageBody).show()
$ -> $ ->
wikiSidebar.show() wikiSidebar.show()
@ -131,11 +132,14 @@ define [
errors errors
hasUnsavedChanges: -> hasUnsavedChanges: ->
json = @toJSON()
formData = @getFormData() formData = @getFormData()
oldBody = @model.get('body') || '' oldBody = @model.get('body') || ''
newBody = formData.body || '' newBody = formData.body || ''
oldTitle = @model.get('title') || '' if json.CAN.EDIT_TITLE
newTitle = formData.title || '' oldTitle = @model.get('title') || ''
newTitle = formData.title || ''
return (oldBody != newBody) || (oldTitle != newTitle) return (oldBody != newBody) || (oldTitle != newTitle)
unsavedWarning: -> unsavedWarning: ->

View File

@ -43,6 +43,14 @@ define [
[@contextName, @contextId] = splitAssetString(@contextAssetString) if @contextAssetString [@contextName, @contextId] = splitAssetString(@contextAssetString) if @contextAssetString
@itemViewOptions.contextName = @contextName @itemViewOptions.contextName = @contextName
@collection.on 'fetch', =>
unless @fetched
@fetched = true
@render()
@collection.on 'fetched:last', =>
@fetchedLast = true
@render()
@collection.on 'sortChanged', @sortChanged @collection.on 'sortChanged', @sortChanged
@currentSortField = @collection.currentSortField @currentSortField = @collection.currentSortField
@ -87,7 +95,7 @@ define [
@$el.hide() @$el.hide()
$('body').removeClass('index') $('body').removeClass('index')
$('body').addClass('edit') $('body').addClass('edit with-right-side')
@editModel = new WikiPage {editing_roles: @default_editing_roles}, contextAssetString: @contextAssetString @editModel = new WikiPage {editing_roles: @default_editing_roles}, contextAssetString: @contextAssetString
@editView = new WikiPageEditView @editView = new WikiPageEditView
@ -107,7 +115,7 @@ define [
@editView.$el.remove() @editView.$el.remove()
wikiSidebar.hide() wikiSidebar.hide()
$('body').removeClass('edit') $('body').removeClass('edit with-right-side')
$('body').addClass('index') $('body').addClass('index')
@$el.show() @$el.show()
@ -117,5 +125,7 @@ define [
CREATE: !!@WIKI_RIGHTS.create_page CREATE: !!@WIKI_RIGHTS.create_page
MANAGE: !!@WIKI_RIGHTS.manage MANAGE: !!@WIKI_RIGHTS.manage
PUBLISH: !!@WIKI_RIGHTS.manage && @contextName == 'courses' PUBLISH: !!@WIKI_RIGHTS.manage && @contextName == 'courses'
json.fetched = @fetched json.CAN.VIEW_TOOLBAR = json.CAN.CREATE
json.fetched = !!@fetched
json.fetchedLast = !!@fetchedLast
json json

View File

@ -82,4 +82,5 @@ define [
DELETE: !!@PAGE_RIGHTS.delete DELETE: !!@PAGE_RIGHTS.delete
READ_REVISIONS: !!@PAGE_RIGHTS.read_revisions READ_REVISIONS: !!@PAGE_RIGHTS.read_revisions
ACCESS_GEAR_MENU: !!@PAGE_RIGHTS.delete || !!@PAGE_RIGHTS.read_revisions ACCESS_GEAR_MENU: !!@PAGE_RIGHTS.delete || !!@PAGE_RIGHTS.read_revisions
json.CAN.VIEW_TOOLBAR = json.CAN.VIEW_PAGES || json.CAN.PUBLISH || json.CAN.UPDATE_CONTENT || json.CAN.ACCESS_GEAR_MENU
json json

View File

@ -440,7 +440,10 @@ class ApplicationController < ActionController::Base
end end
set_badge_counts_for(@context, @current_user, @current_enrollment) set_badge_counts_for(@context, @current_user, @current_enrollment)
assign_localizer if @context.present? assign_localizer if @context.present?
add_crumb(@context.short_name, named_context_url(@context, :context_url), :id => "crumb_#{@context.asset_string}") if @context && @context.respond_to?(:short_name) if @context && @context.respond_to?(:short_name)
crumb_url = named_context_url(@context, :context_url) if @context.grants_right?(@current_user, :read)
add_crumb(@context.short_name, crumb_url)
end
end end
end end

View File

@ -24,12 +24,17 @@ class WikiPagesController < ApplicationController
before_filter :set_js_rights, :only => [:pages_index, :show_page, :edit_page] before_filter :set_js_rights, :only => [:pages_index, :show_page, :edit_page]
before_filter :set_js_wiki_data, :only => [:pages_index, :show_page, :edit_page] before_filter :set_js_wiki_data, :only => [:pages_index, :show_page, :edit_page]
add_crumb(proc { t '#crumbs.wiki_pages', "Pages"}) do |c| add_crumb(proc { t '#crumbs.wiki_pages', "Pages"}) do |c|
url = nil
context = c.instance_variable_get('@context') context = c.instance_variable_get('@context')
if context.draft_state_enabled? current_user = c.instance_variable_get('@current_user')
c.send :polymorphic_path, [context, :pages] if context.grants_right?(current_user, :read)
else if context.draft_state_enabled?
c.send :named_context_url, c.instance_variable_get("@context"), :context_wiki_pages_url url = c.send :polymorphic_path, [context, :pages]
else
url = c.send :named_context_url, c.instance_variable_get("@context"), :context_wiki_pages_url
end
end end
url
end end
before_filter { |c| c.active_tab = "pages" } before_filter { |c| c.active_tab = "pages" }
@ -234,8 +239,11 @@ class WikiPagesController < ApplicationController
hash[:WIKI_PAGE_REVISION] = (current_version = @page.versions.current) ? current_version.number : nil hash[:WIKI_PAGE_REVISION] = (current_version = @page.versions.current) ? current_version.number : nil
hash[:WIKI_PAGE_SHOW_PATH] = polymorphic_path([@context, :named_page], :wiki_page_id => @page) hash[:WIKI_PAGE_SHOW_PATH] = polymorphic_path([@context, :named_page], :wiki_page_id => @page)
hash[:WIKI_PAGE_EDIT_PATH] = polymorphic_path([@context, :edit_named_page], :wiki_page_id => @page) hash[:WIKI_PAGE_EDIT_PATH] = polymorphic_path([@context, :edit_named_page], :wiki_page_id => @page)
hash[:COURSE_ID] = @context.id if @context.is_a? Course
hash[:WIKI_PAGE_HISTORY_PATH] = polymorphic_path([@context, @page, :wiki_page_revisions]) hash[:WIKI_PAGE_HISTORY_PATH] = polymorphic_path([@context, @page, :wiki_page_revisions])
if @context.is_a?(Course)
hash[:COURSE_ID] = @context.id if @context.grants_right?(@current_user, :read)
end
end end
js_env hash js_env hash

View File

@ -55,6 +55,12 @@ $button-hover: #dee5ea;
} }
.module-sequence-padding, .module-sequence-footer{ .module-sequence-padding, .module-sequence-footer{
animation: module-sequence-footer-animation 1.25s; animation: module-sequence-footer-animation 1s;
-webkit-animation: module-sequence-footer-animation 1.25s; -webkit-animation: module-sequence-footer-animation 1s;
}
@media print {
.module-sequence-padding, .module-sequence-footer {
display: none;
}
} }

View File

@ -12,44 +12,49 @@ $unpublished-icon-color: #b4b7ba
$border-color: #c1c7cf $border-color: #c1c7cf
$border-radius: 3px $border-radius: 3px
$pages-border: 1px solid #c1c7cf
$pages-dashed-border: 1px dashed #c1c7cf
$pages-inner-border: 1px solid #e1e3e4
$index-background: #e8ecef $index-background: #e8ecef
$item-background: #ffffff $item-background: #ffffff
$item-hover-background: #eef7ff $item-hover-background: #eef7ff
$shadow: 0 1px 0 rgba(0,0,0,0.15) $shadow: 0 1px 0 rgba(0,0,0,0.15)
$table-shadow: 0 1px 0 #dde0e4
.pages .sticky
position: fixed
z-index: 1000
top: 0px
left: 0px
right: 0px
margin-left: 1px
background: white
height: 33px
max-width: $max_main_width
border-color: $menu-border-color
.pages.with-left-side .sticky
margin-left: $left_side_width + 1px
.pages.with-right-side .sticky
margin-right: $right_side_width + 1px
.pages .pages
.sticky
position: fixed
z-index: 1000
top: 0px
left: 0px
margin-left: $left_side_width + 1px
background: white
height: 33px
max-width: $max_main_width
border-color: $menu-border-color
&.sticky-toolbar
right: 0px
&.sticky-toolbar-with-right-side
right: $right_side_width + 1px
min-width: $min_main_width - 2px
#breadcrumbs #breadcrumbs
:border-bottom 1px solid $border-color :border-bottom $pages-border
.header-bar-outer-container .header-bar-outer-container
:height 64px :height 64px
.header-bar-container .header-bar-container
:box-shadow $shadow
:height 64px :height 64px
.page-changed-alert .page-changed-alert
:overflow hidden :overflow hidden
:height 0 :height 0
.page-changed-alert .alert .page-changed-alert .alert
:border-radius 0 :border-radius 0
.header-bar
:box-shadow $shadow
.header-bar-outer-container.page-changed .header-bar-outer-container.page-changed
:height 103px :height 103px
@ -62,12 +67,16 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15)
.page-changed-alert .page-changed-alert
:margin -1px 0 0 0 :margin -1px 0 0 0
:border-bottom 1px solid $border-color :border-bottom $pages-border
:box-shadow $shadow
:height 39px :height 39px
:animation page-changed-alert 1.15s :animation page-changed-alert 1.15s
:-webkit-animation page-changed-alert 1.15s :-webkit-animation page-changed-alert 1.15s
.pages.index .pages.index
#main
:background $index-background
.index-content-container .index-content-container
:margin-top 1px :margin-top 1px
@ -84,10 +93,10 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15)
:width 270px :width 270px
.index-content .index-content
:background $index-background
:padding 0 1em 1em :padding 0 1em 1em
.table .table
:margin-bottom 0
:border-collapse separate :border-collapse separate
:border-spacing 0 :border-spacing 0
td, th td, th
@ -102,6 +111,7 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15)
:cursor pointer :cursor pointer
:user-select none :user-select none
:color inherit :color inherit
:white-space nowrap
i i
:color #ccc :color #ccc
a.sort-field:hover a.sort-field:hover
@ -113,6 +123,7 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15)
:color black :color black
.table thead .table thead
:background $index-background
tr tr
:height 40px :height 40px
th th
@ -137,18 +148,21 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15)
:text-decoration inherit :text-decoration inherit
:color inherit :color inherit
td:first-child td:first-child
:border-left 1px solid $border-color :border-left $pages-border
td:last-child td:last-child
:border-right 1px solid $border-color :border-right $pages-border
tr:first-child tr:first-child
td
:border-top $pages-border
td:first-child td:first-child
:border-top-left-radius $border-radius :border-top-left-radius $border-radius
td:last-child td:last-child
:border-top-right-radius $border-radius :border-top-right-radius $border-radius
tr:last-child tr:last-child
td td
:border-bottom 1px solid $border-color :border-bottom $pages-border
:box-shadow $table-shadow
td:first-child td:first-child
:border-bottom-left-radius $border-radius :border-bottom-left-radius $border-radius
td:last-child td:last-child
@ -157,7 +171,7 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15)
td td
:font-size 11px :font-size 11px
:color $subdued-text-color :color $subdued-text-color
:border-top 1px solid $border-color :border-top $pages-inner-border
.wiki-page-link .wiki-page-link
:font-size 13px :font-size 13px
@ -174,12 +188,32 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15)
:color $unpublished-icon-color :color $unpublished-icon-color
.table .no-pages .no-pages-cell .table .no-pages .no-pages-cell
:border 1px dashed $border-color :border $pages-dashed-border
.loading
:text-align center
:color #8f9295
img
:margin-top -3px
:opacity 0.75
&.loading
:border 1px solid transparent
&.loading-more
:border $pages-dashed-border
:border-top-width 0
:border-bottom-left-radius $border-radius
:border-bottom-right-radius $border-radius
:margin-top 1px
:padding 4px 12px
:background #f4f6f8
.pages.show .pages.show
.header-bar .header-bar
.publish-button .publish-button
:margin 0 12px :margin 0 12px 0 0
.front-page.label
:margin 6px 12px 6px 0
.show-content .show-content
:padding 15px 25px :padding 15px 25px

View File

@ -1,3 +1,4 @@
{{#if CAN.VIEW_TOOLBAR}}
<div class="header-bar-outer-container"> <div class="header-bar-outer-container">
<div class="header-bar-container sticky-toolbar" data-sticky> <div class="header-bar-container sticky-toolbar" data-sticky>
<div class="header-bar"> <div class="header-bar">
@ -35,6 +36,7 @@
<div class="page-changed-alert" role="alert" aria-atomic="true" aria-live="polite"></div> <div class="page-changed-alert" role="alert" aria-atomic="true" aria-live="polite"></div>
</div> </div>
</div> </div>
{{/if}}
<div class="show-content"> <div class="show-content">
<h2 class="page-title">{{title}}</h2> <h2 class="page-title">{{title}}</h2>

View File

@ -1,31 +1,3 @@
<div class="header-bar-outer-container">
<div class="header-bar-container" data-sticky>
<div class="header-bar">
<div class="header-bar-left">
</div>
<div class="header-bar-right">
{{#if CAN.PUBLISH}}
{{#if published}}
<span class="published" aria-label="{{#t 'unpublish'}}Unpublish{{/t}}"><i class="icon-publish"></i> {{#t 'buttons.unpublish'}}Published{{/t}}</span>
{{else}}
<span class="unpublished" aira-label="{{#t 'publish'}}Publish{{/t}}"><i class="icon-unpublished muted"></i> {{#t 'buttons.publish'}}Unpublished{{/t}}</span>
{{/if}}
{{/if}}
{{#if CAN.DELETE}}
<a class="btn al-trigger" tabindex="0" role="button">
<i class="icon-settings"></i><i class="icon-mini-arrow-down"></i>
<span class="screenreader-only">{{#t 'toolbar_menu.settings'}}Settings{{/t}}</span>
</a>
<ul class="al-options">
<li><a href="#" class="icon-trash delete_page{{#unless deletable}} disabled{{/unless}}" {{#unless deletable}}aria-disabled="true"{{/unless}}>{{#t "delete_wiki"}}Delete{{/t}}</a></li>
</ul>
{{/if}}
</div>
</div>
<div class="page-changed-alert" role="alert" aria-atomic="true" aria-live="assertive"></div>
</div>
</div>
<div class="edit-content"> <div class="edit-content">
<div class="edit-header"> <div class="edit-header">
{{#if CAN.EDIT_TITLE}} {{#if CAN.EDIT_TITLE}}
@ -37,7 +9,7 @@
<a href="#" class="switch_views">{{#t "#editor.switch_views"}}Switch Views{{/t}}</a> <a href="#" class="switch_views">{{#t "#editor.switch_views"}}Switch Views{{/t}}</a>
</div> </div>
<textarea rows="16" cols="40" name="body" class="body" aria-hidden="true"{{#unless PAGE_RIGHTS.update}} autofocus{{/unless}}>{{body}}</textarea> <textarea rows="20" cols="40" name="body" class="body" aria-hidden="true"{{#unless PAGE_RIGHTS.update}} autofocus{{/unless}}>{{body}}</textarea>
{{#if CAN.EDIT_ROLES}} {{#if CAN.EDIT_ROLES}}
<div class="control-group options"> <div class="control-group options">

View File

@ -1,3 +1,4 @@
{{#if CAN.VIEW_TOOLBAR}}
<div class="header-bar-outer-container"> <div class="header-bar-outer-container">
<div class="header-bar-container sticky-toolbar-with-right-side" data-sticky> <div class="header-bar-container sticky-toolbar-with-right-side" data-sticky>
<div class="header-bar"> <div class="header-bar">
@ -9,6 +10,7 @@
</div> </div>
</div> </div>
</div> </div>
{{/if}}
<div class="index-content-container"> <div class="index-content-container">
<div class="index-content"> <div class="index-content">
@ -38,5 +40,11 @@
{{/if}} {{/if}}
</tbody> </tbody>
</table> </table>
{{#unless fetchedLast}}
<div class="loading {{#unless fetched}}loading{{else}}loading-more{{/unless}}">
<img src="/images/ajax-reload-animated.gif">
{{#unless fetched}}{{#t 'loading'}}Loading ...{{/t}}{{else}}{{#t 'loading_more'}}Loading more ...{{/t}}{{/unless}}
</div>
{{/unless}}
</div> </div>
</div> </div>