decaf ui/shared (2)

test plan:
  - existing tests pass

flag=none

refs FOO-3470

Change-Id: Ia1a49230dfca95b9101a89c7a469656407310df6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/315949
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Drake Harper <drake.harper@instructure.com>
QA-Review: Drake Harper <drake.harper@instructure.com>
Product-Review: Drake Harper <drake.harper@instructure.com>
This commit is contained in:
Aaron Shafovaloff 2023-04-13 08:12:15 -06:00
parent 283be9e74c
commit c33a9f0d9e
21 changed files with 424 additions and 305 deletions

View File

@ -1,36 +1,3 @@
#
# Copyright (C) 2013 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
import Backbone from '@canvas/backbone'
import _ from 'underscore'
export default class MigrationView extends Backbone.View
# Validations for this view that should be made
# on the client side before save.
# ---------------------------------------------
# @expects void
# @returns ErrorMessage
# @api private override ValidateFormView
validateBeforeSave: =>
# There might be a better way to do this with reduce
validations = {}
_.each @children, (child) =>
_.extend(validations, child.validations()) if child.validations
validations
# required in gems/plugins
import MigrationView from './MigrationView.js'
export default MigrationView

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2023 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {extend} from '@canvas/backbone/utils'
import Backbone from '@canvas/backbone'
import _ from 'underscore'
extend(MigrationView, Backbone.View)
function MigrationView() {
this.validateBeforeSave = this.validateBeforeSave.bind(this)
return MigrationView.__super__.constructor.apply(this, arguments)
}
// Validations for this view that should be made
// on the client side before save.
// ---------------------------------------------
// @expects void
// @returns ErrorMessage
// @api private override ValidateFormView
MigrationView.prototype.validateBeforeSave = function () {
// There might be a better way to do this with reduce
const validations = {}
_.each(
this.children,
(function (_this) {
return function (child) {
if (child.validations) {
return _.extend(validations, child.validations())
}
}
})(this)
)
return validations
}
export default MigrationView

View File

@ -1,30 +1,3 @@
#
# Copyright (C) 2013 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
import Backbone from '@canvas/backbone'
import template from '../../../jst/subviews/OverwriteAssessmentContent.handlebars'
export default class OverwriteAssessmentContentView extends Backbone.View
template: template
events:
"change #overwriteAssessmentContent" : "setAttribute"
setAttribute: =>
settings = @model.get('settings') || {}
settings.overwrite_quizzes = !!@$el.find('#overwriteAssessmentContent').is(":checked")
@model.set('settings', settings)
# required in gems/plugins
import OverwriteAssessmentContentView from './OverwriteAssessmentContentView.js'
export default OverwriteAssessmentContentView

View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2023 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {extend} from '@canvas/backbone/utils'
import Backbone from '@canvas/backbone'
import template from '../../../jst/subviews/OverwriteAssessmentContent.handlebars'
extend(OverwriteAssessmentContentView, Backbone.View)
function OverwriteAssessmentContentView() {
this.setAttribute = this.setAttribute.bind(this)
return OverwriteAssessmentContentView.__super__.constructor.apply(this, arguments)
}
OverwriteAssessmentContentView.prototype.template = template
OverwriteAssessmentContentView.prototype.events = {
'change #overwriteAssessmentContent': 'setAttribute',
}
OverwriteAssessmentContentView.prototype.setAttribute = function () {
const settings = this.model.get('settings') || {}
settings.overwrite_quizzes = !!this.$el.find('#overwriteAssessmentContent').is(':checked')
return this.model.set('settings', settings)
}
export default OverwriteAssessmentContentView

View File

@ -1,31 +0,0 @@
#
# Copyright (C) 2012 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
import DiscussionTopic from './DiscussionTopic'
import _ from 'underscore'
export default class Announcement extends DiscussionTopic
# this is wonky, and admittitedly not the right way to do this, but it is a workaround
# to append the query string '?only_announcements=true' to the index action (which tells
# discussionTopicsController#index to show announcements instead of discussion topics)
# but remove it for create/show/update/delete
urlRoot: -> _.result(@collection, 'url').replace(@collection._stringToAppendToURL, '')
defaults:
is_announcement: true

View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2023 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {extend} from '@canvas/backbone/utils'
import DiscussionTopic from './DiscussionTopic'
import _ from 'underscore'
extend(Announcement, DiscussionTopic)
function Announcement() {
return Announcement.__super__.constructor.apply(this, arguments)
}
// this is wonky, and admittitedly not the right way to do this, but it is a workaround
// to append the query string '?only_announcements=true' to the index action (which tells
// discussionTopicsController#index to show announcements instead of discussion topics)
// but remove it for create/show/update/delete
Announcement.prototype.urlRoot = function () {
return _.result(this.collection, 'url').replace(this.collection._stringToAppendToURL, '')
}
Announcement.prototype.defaults = {
is_announcement: true,
}
export default Announcement

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2012 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
import Backbone from '@canvas/backbone'
import {useScope as useI18nScope} from '@canvas/i18n'
I18n = useI18nScope('discussions.participant')
export default class Participant extends Backbone.Model
defaults:
avatar_image_url: ''
display_name: I18n.t('anonymous_user', 'Anonymous')
id: null

View File

@ -0,0 +1,38 @@
/*
* Copyright (C) 2023 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {extend} from '@canvas/backbone/utils'
import Backbone from '@canvas/backbone'
import {useScope as useI18nScope} from '@canvas/i18n'
const I18n = useI18nScope('discussions.participant')
extend(Participant, Backbone.Model)
function Participant() {
return Participant.__super__.constructor.apply(this, arguments)
}
Participant.prototype.defaults = {
avatar_image_url: '',
display_name: I18n.t('anonymous_user', 'Anonymous'),
id: null,
}
export default Participant

View File

@ -1,36 +0,0 @@
#
# Copyright (C) 2017 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
import LockButtonView from './Button'
export default class LockIconView extends LockButtonView
lockClass: 'lock-icon-lock'
lockedClass: 'lock-icon-locked'
unlockClass: 'lock-icon-unlock'
tagName: 'span'
className: 'lock-icon'
# These values allow the default text to be overridden if necessary
@optionProperty 'lockText'
@optionProperty 'unlockText'
initialize: ->
super
@events = Object.assign({}, LockButtonView.prototype.events, @events)
events: {'keyclick' : 'click'}

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2023 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {extend} from '@canvas/backbone/utils'
import LockButtonView from './Button'
extend(LockIconView, LockButtonView)
function LockIconView() {
return LockIconView.__super__.constructor.apply(this, arguments)
}
LockIconView.prototype.lockClass = 'lock-icon-lock'
LockIconView.prototype.lockedClass = 'lock-icon-locked'
LockIconView.prototype.unlockClass = 'lock-icon-unlock'
LockIconView.prototype.tagName = 'span'
LockIconView.prototype.className = 'lock-icon'
// These values allow the default text to be overridden if necessary
LockIconView.optionProperty('lockText')
LockIconView.optionProperty('unlockText')
LockIconView.prototype.initialize = function () {
LockIconView.__super__.initialize.apply(this, arguments)
return (this.events = {...LockButtonView.prototype.events, ...this.events})
}
LockIconView.prototype.events = {
keyclick: 'click',
}
export default LockIconView

View File

@ -3,5 +3,5 @@
"private": true,
"version": "1.0.0",
"author": "neme",
"main": "./backbone/views/index.coffee"
"main": "./backbone/views/index.js"
}

View File

@ -1,26 +0,0 @@
#
# Copyright (C) 2013 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
import PaginatedCollection from '@canvas/pagination/backbone/collections/PaginatedCollection'
import Module from '../models/Module'
export default class ModuleCollection extends PaginatedCollection
model: Module
@optionProperty 'course_id'
url: -> "/api/v1/courses/#{@course_id}/modules"

View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2023 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {extend} from '@canvas/backbone/utils'
import PaginatedCollection from '@canvas/pagination/backbone/collections/PaginatedCollection'
import Module from '../models/Module'
extend(ModuleCollection, PaginatedCollection)
function ModuleCollection() {
return ModuleCollection.__super__.constructor.apply(this, arguments)
}
ModuleCollection.prototype.model = Module
ModuleCollection.optionProperty('course_id')
ModuleCollection.prototype.url = function () {
return '/api/v1/courses/' + this.course_id + '/modules'
}
export default ModuleCollection

View File

@ -1,27 +0,0 @@
#
# Copyright (C) 2013 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
import PaginatedCollection from '@canvas/pagination/backbone/collections/PaginatedCollection'
import ModuleItem from '../models/ModuleItem'
export default class ModuleItemCollection extends PaginatedCollection
model: ModuleItem
@optionProperty 'course_id'
@optionProperty 'module_id'
url: -> "/api/v1/courses/#{@course_id}/modules/#{@module_id}/items"

View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2023 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {extend} from '@canvas/backbone/utils'
import PaginatedCollection from '@canvas/pagination/backbone/collections/PaginatedCollection'
import ModuleItem from '../models/ModuleItem'
extend(ModuleItemCollection, PaginatedCollection)
function ModuleItemCollection() {
return ModuleItemCollection.__super__.constructor.apply(this, arguments)
}
ModuleItemCollection.prototype.model = ModuleItem
ModuleItemCollection.optionProperty('course_id')
ModuleItemCollection.optionProperty('module_id')
ModuleItemCollection.prototype.url = function () {
return '/api/v1/courses/' + this.course_id + '/modules/' + this.module_id + '/items'
}
export default ModuleItemCollection

View File

@ -1,31 +0,0 @@
#
# Copyright (C) 2014 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
import OutcomeGroup from '@canvas/outcomes/backbone/models/OutcomeGroup'
import splitAssetString from '@canvas/util/splitAssetString'
export default class RootOutcomesFinder
find: ->
# purposely sharing these across instances of RootOutcomesFinder
contextOutcomeGroups = null
contextTypeAndId = splitAssetString(ENV.context_asset_string || '')
contextOutcomeGroups = new OutcomeGroup
contextOutcomeGroups.url = "/api/v1/#{contextTypeAndId[0]}/#{contextTypeAndId[1]}/root_outcome_group"
contextOutcomeGroups.fetch()
[contextOutcomeGroups]

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2023 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import OutcomeGroup from '@canvas/outcomes/backbone/models/OutcomeGroup'
import splitAssetString from '@canvas/util/splitAssetString'
function RootOutcomesFinder() {}
RootOutcomesFinder.prototype.find = function () {
// purposely sharing these across instances of RootOutcomesFinder
let contextOutcomeGroups
contextOutcomeGroups = null
const contextTypeAndId = splitAssetString(ENV.context_asset_string || '')
contextOutcomeGroups = new OutcomeGroup()
contextOutcomeGroups.url =
'/api/v1/' + contextTypeAndId[0] + '/' + contextTypeAndId[1] + '/root_outcome_group'
contextOutcomeGroups.fetch()
return [contextOutcomeGroups]
}
export default RootOutcomesFinder

View File

@ -1,32 +0,0 @@
#
# Copyright (C) 2013 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
import Backbone from '@canvas/backbone'
import _ from 'underscore'
import template from '../../jst/TreeItem.handlebars'
export default class TreeItemView extends Backbone.View
tagName: 'li'
template: template
@optionProperty 'nestingLevel'
attributes: ->
role: 'treeitem'
id: _.uniqueId 'treenode-'
afterRender: ->
# We have to do this here, because @nestingLevel isn't available when attributes is run.
@$el.attr 'aria-level', @nestingLevel

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2023 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {extend} from '@canvas/backbone/utils'
import Backbone from '@canvas/backbone'
import _ from 'underscore'
import template from '../../jst/TreeItem.handlebars'
extend(TreeItemView, Backbone.View)
function TreeItemView() {
return TreeItemView.__super__.constructor.apply(this, arguments)
}
TreeItemView.prototype.tagName = 'li'
TreeItemView.prototype.template = template
TreeItemView.optionProperty('nestingLevel')
TreeItemView.prototype.attributes = function () {
return {
role: 'treeitem',
id: _.uniqueId('treenode-'),
}
}
TreeItemView.prototype.afterRender = function () {
// We have to do this here, because @nestingLevel isn't available when attributes is run
return this.$el.attr('aria-level', this.nestingLevel)
}
export default TreeItemView

View File

@ -1,26 +0,0 @@
#
# Copyright (C) 2013 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
import '@canvas/jquery-sticky'
# Remember, you must define a toolbar with data attribute 'data-sticky'
# for this to work. Also don't forget to create your own styles for the
# sticky class that gets added to the dom element
export default
afterRender: ->
@stickyHeader.remove() if @stickyHeader
@stickyHeader = @$('[data-sticky]').sticky()

View File

@ -0,0 +1,32 @@
/*
* Copyright (C) 2023 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import '@canvas/jquery-sticky'
// Remember, you must define a toolbar with data attribute 'data-sticky'
// for this to work. Also don't forget to create your own styles for the
// sticky class that gets added to the dom element
export default {
// eslint-disable-next-line object-shorthand
afterRender: function () {
if (this.stickyHeader) {
this.stickyHeader.remove()
}
return (this.stickyHeader = this.$('[data-sticky]').sticky())
},
}