mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Fixed #784.
This commit is contained in:
parent
1864cb09bc
commit
871cd4b3c9
28 changed files with 129 additions and 219 deletions
|
@ -49,7 +49,7 @@ module.exports = class CocoRouter extends Backbone.Router
|
|||
'demo(/*subpath)': go('DemoView')
|
||||
'docs/components': go('docs/ComponentDocumentationView')
|
||||
|
||||
'editor': go('editor/MainEditorView')
|
||||
'editor': go('CommunityView')
|
||||
|
||||
'editor/achievement': go('editor/achievement/AchievementSearchView')
|
||||
'editor/achievement/:articleID': go('editor/achievement/AchievementEditView')
|
||||
|
|
|
@ -907,6 +907,7 @@
|
|||
unknown: "Unknown error."
|
||||
|
||||
resources:
|
||||
sessions: "Sessions"
|
||||
your_sessions: "Your Sessions"
|
||||
level: "Level"
|
||||
social_network_apis: "Social Network APIs"
|
||||
|
@ -922,6 +923,7 @@
|
|||
patched_model: "Source Document"
|
||||
model: "Model"
|
||||
system: "System"
|
||||
systems: "Systems"
|
||||
component: "Component"
|
||||
components: "Components"
|
||||
thang: "Thang"
|
||||
|
@ -936,10 +938,16 @@
|
|||
source_document: "Source Document"
|
||||
document: "Document"
|
||||
sprite_sheet: "Sprite Sheet"
|
||||
employers: "Employers"
|
||||
candidates: "Candidates"
|
||||
candidate_sessions: "Candidate Sessions"
|
||||
user_remark: "User Remark"
|
||||
user_remarks: "User Remarks"
|
||||
versions: "Versions"
|
||||
items: "Items"
|
||||
wizard: "Wizard"
|
||||
achievement: "Achievement"
|
||||
clas: "CLAs"
|
||||
|
||||
delta:
|
||||
added: "Added"
|
||||
|
|
17
app/schemas/models/cla_submission.coffee
Normal file
17
app/schemas/models/cla_submission.coffee
Normal file
|
@ -0,0 +1,17 @@
|
|||
c = require './../schemas'
|
||||
|
||||
CLASubmissionSchema = c.object {
|
||||
title: 'CLA Submission'
|
||||
description: 'Recording when a user signed the CLA.'
|
||||
}
|
||||
|
||||
_.extend CLASubmissionSchema.properties,
|
||||
user: c.objectId links: [{rel: 'extra', href: '/db/user/{($)}'}]
|
||||
email: c.shortString({format: 'email'})
|
||||
name: {type: 'string'}
|
||||
githubUsername: c.shortString()
|
||||
created: c.date title: 'Created', readOnly: true
|
||||
|
||||
c.extendBasicProperties CLASubmissionSchema, 'user.remark'
|
||||
|
||||
module.exports = CLASubmissionSchema
|
|
@ -17,29 +17,25 @@
|
|||
overflow: hidden
|
||||
background: white
|
||||
border: 1px solid #333
|
||||
border-radius: 5px
|
||||
position: relative
|
||||
|
||||
-webkit-transition: opacity 0.3s ease-in-out
|
||||
-moz-transition: opacity 0.3s ease-in-out
|
||||
-ms-transition: opacity 0.3s ease-in-out
|
||||
-o-transition: opacity 0.3s ease-in-out
|
||||
transition: opacity 0.3s ease-in-out
|
||||
|
||||
opacity: 0.4
|
||||
|
||||
border-radius: 5px
|
||||
.only-one
|
||||
-webkit-transition: opacity 0.3s ease-in-out
|
||||
-moz-transition: opacity 0.3s ease-in-out
|
||||
-ms-transition: opacity 0.3s ease-in-out
|
||||
-o-transition: opacity 0.3s ease-in-out
|
||||
transition: opacity 0.3s ease-in-out
|
||||
opacity: 0
|
||||
|
||||
#normal-view:hover
|
||||
.play-option
|
||||
opacity: 0.4
|
||||
|
||||
.play-option:hover
|
||||
opacity: 1
|
||||
.only-one
|
||||
.play-option:hover
|
||||
opacity: 1
|
||||
.only-one
|
||||
opacity: 1
|
||||
|
||||
.my-icon
|
||||
position: relative
|
||||
|
|
|
@ -32,7 +32,7 @@ block content
|
|||
a(href="/editor/article")
|
||||
img(src="/images/pages/community/article.png")
|
||||
h2
|
||||
a.spl(href="/editor/level", data-i18n="editor.article_title")
|
||||
a.spl(href="/editor/article", data-i18n="editor.article_title")
|
||||
p
|
||||
span(data-i18n="community.article_editor_prefix") See a mistake in some of our docs? Want to make some instructions for your own creations? Check out the
|
||||
a.spl.spr(href="/editor/article", data-i18n="editor.article_title")
|
||||
|
|
|
@ -5,6 +5,12 @@ block modal-header-content
|
|||
|
||||
block modal-body-content
|
||||
|
||||
h4.language-selection(data-i18n="ladder.select_your_language") Select your language!
|
||||
.form-group.select-group
|
||||
select#tome-language(name="language")
|
||||
for option in languages
|
||||
option(value=option.id selected=(language === option.id))= option.name
|
||||
|
||||
div#noob-view.secret
|
||||
a(href="/play/level/#{levelID}-tutorial").btn.btn-success.btn-block.btn-lg
|
||||
p
|
||||
|
@ -18,11 +24,6 @@ block modal-body-content
|
|||
strong(data-i18n="ladder.tutorial_not_sure") Not sure what's going on?
|
||||
|
|
||||
a(href="/play/level/#{levelID}-tutorial", data-i18n="ladder.tutorial_play_first") Play the tutorial first.
|
||||
h4.language-selection(data-i18n="ladder.select_your_language") Select your language!
|
||||
.form-group.select-group
|
||||
select#tome-language(name="language")
|
||||
for option in languages
|
||||
option(value=option.id selected=(language === option.id))= option.name
|
||||
a(href="/play/level/#{levelID}?team=#{teamID}")
|
||||
div.play-option
|
||||
img(src=myPortrait).my-icon.only-one
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
RootView = require 'views/kinds/RootView'
|
||||
template = require 'templates/employers'
|
||||
User = require 'models/User'
|
||||
UserRemark = require 'models/UserRemark'
|
||||
{me} = require 'lib/auth'
|
||||
CocoCollection = require 'collections/CocoCollection'
|
||||
EmployerSignupModal = require 'views/modal/EmployerSignupModal'
|
||||
|
@ -10,10 +9,6 @@ class CandidatesCollection extends CocoCollection
|
|||
url: '/db/user/x/candidates'
|
||||
model: User
|
||||
|
||||
class UserRemarksCollection extends CocoCollection
|
||||
url: '/db/user.remark?project=contact,contactName,user'
|
||||
model: UserRemark
|
||||
|
||||
module.exports = class EmployersView extends RootView
|
||||
id: 'employers-view'
|
||||
template: template
|
||||
|
@ -32,9 +27,12 @@ module.exports = class EmployersView extends RootView
|
|||
|
||||
constructor: (options) ->
|
||||
super options
|
||||
@getCandidates()
|
||||
@candidates = @supermodel.loadCollection(new CandidatesCollection(), 'candidates').model
|
||||
@setFilterDefaults()
|
||||
|
||||
onLoaded: ->
|
||||
super()
|
||||
@setUpScrolling()
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
|
@ -53,6 +51,7 @@ module.exports = class EmployersView extends RootView
|
|||
|
||||
swapFolderIcon: ->
|
||||
$('#folder-icon').toggleClass('glyphicon-folder-close').toggleClass('glyphicon-folder-open')
|
||||
|
||||
onFilterChanged: ->
|
||||
@resetFilters()
|
||||
that = @
|
||||
|
@ -75,6 +74,7 @@ module.exports = class EmployersView extends RootView
|
|||
|
||||
openSignupModal: ->
|
||||
@openModalView new EmployerSignupModal
|
||||
|
||||
handleSelectAllChange: (e) ->
|
||||
checkedState = e.currentTarget.checked
|
||||
$('#filters :input').each ->
|
||||
|
@ -110,6 +110,7 @@ module.exports = class EmployersView extends RootView
|
|||
|
||||
|
||||
return filteredCandidates
|
||||
|
||||
setFilterDefaults: ->
|
||||
@filters =
|
||||
phoneScreenFilter: [true, false]
|
||||
|
@ -129,18 +130,19 @@ module.exports = class EmployersView extends RootView
|
|||
return (_.filter candidates, (c) -> c.get('jobProfile').curated?[filterName] is filterValue).length
|
||||
else
|
||||
return Math.floor(Math.random() * 500)
|
||||
|
||||
createFilterAlert: ->
|
||||
currentFilterSet = _.cloneDeep @filters
|
||||
currentSavedFilters = _.cloneDeep me.get('savedEmployerFilterAlerts') ? []
|
||||
currentSavedFilters.push currentFilterSet
|
||||
@patchEmployerFilterAlerts currentSavedFilters, @renderSavedFilters
|
||||
|
||||
|
||||
deleteFilterAlert: (e) ->
|
||||
index = $(e.target).closest('tbody tr').data('filter-index')
|
||||
currentSavedFilters = me.get('savedEmployerFilterAlerts')
|
||||
currentSavedFilters.splice(index,1)
|
||||
@patchEmployerFilterAlerts currentSavedFilters, @renderSavedFilters
|
||||
|
||||
|
||||
patchEmployerFilterAlerts: (newFilters, cb) ->
|
||||
me.set('savedEmployerFilterAlerts',newFilters)
|
||||
unless me.isValid()
|
||||
|
@ -149,7 +151,7 @@ module.exports = class EmployersView extends RootView
|
|||
else
|
||||
triggerErrorAlert = -> alert("There was an error saving your filter alert! Please notify team@codecombat.com.")
|
||||
res = me.save {"savedEmployerFilterAlerts": newFilters}, {patch: true, success: cb, error: triggerErrorAlert}
|
||||
|
||||
|
||||
renderSavedFilters: =>
|
||||
savedFilters = me.get('savedEmployerFilterAlerts')
|
||||
unless savedFilters?.length then return $("#saved-filter-table").hide()
|
||||
|
@ -157,8 +159,7 @@ module.exports = class EmployersView extends RootView
|
|||
$("#saved-filter-table").find("tbody tr").remove()
|
||||
for filter, index in savedFilters
|
||||
$("#saved-filter-table tbody").append("""<tr data-filter-index="#{index}"><td>#{@generateFilterAlertDescription(filter)}</td><td class="deletion-col"><a>✗</a></td></tr> """)
|
||||
|
||||
|
||||
|
||||
generateFilterAlertDescription: (filter) =>
|
||||
descriptionString = ""
|
||||
for key in _.keys(filter).sort()
|
||||
|
@ -168,7 +169,7 @@ module.exports = class EmployersView extends RootView
|
|||
descriptionString += value.join(", ")
|
||||
if descriptionString.length is 0 then descriptionString = "Any new candidate"
|
||||
return descriptionString
|
||||
|
||||
|
||||
getActiveAndApprovedCandidates: =>
|
||||
candidates = _.filter @candidates.models, (c) -> c.get('jobProfile').active
|
||||
return _.filter candidates, (c) -> c.get('jobProfileApproved')
|
||||
|
@ -191,8 +192,6 @@ module.exports = class EmployersView extends RootView
|
|||
ctx.featuredCandidates = ctx.candidates
|
||||
ctx.candidatesInFilter = @candidatesInFilter
|
||||
ctx.otherCandidates = _.reject ctx.activeCandidates, (c) -> c.get('jobProfileApproved')
|
||||
ctx.remarks = {}
|
||||
ctx.remarks[remark.get('user')] = remark for remark in @remarks.models
|
||||
ctx.moment = moment
|
||||
ctx._ = _
|
||||
ctx.numberOfCandidates = ctx.featuredCandidates.length
|
||||
|
@ -202,17 +201,7 @@ module.exports = class EmployersView extends RootView
|
|||
userPermissions = me.get('permissions') ? []
|
||||
_.contains userPermissions, 'employer'
|
||||
|
||||
getCandidates: ->
|
||||
@candidates = new CandidatesCollection()
|
||||
@candidates.fetch()
|
||||
@remarks = new UserRemarksCollection()
|
||||
@remarks.fetch()
|
||||
# Re-render when we have fetched them, but don't wait and show a progress bar while loading.
|
||||
@listenToOnce @candidates, 'all', @renderCandidatesAndSetupScrolling
|
||||
@listenToOnce @remarks, 'all', @renderCandidatesAndSetupScrolling
|
||||
|
||||
renderCandidatesAndSetupScrolling: =>
|
||||
@render()
|
||||
setUpScrolling: =>
|
||||
$('.nano').nanoScroller()
|
||||
#if window.history?.state?.lastViewedCandidateID
|
||||
# $('.nano').nanoScroller({scrollTo: $('#' + window.history.state.lastViewedCandidateID)})
|
||||
|
@ -340,9 +329,11 @@ module.exports = class EmployersView extends RootView
|
|||
8:
|
||||
'✓': filterSelectExactMatch
|
||||
'✗': filterSelectExactMatch
|
||||
|
||||
logoutAccount: ->
|
||||
window.location.hash = ''
|
||||
super()
|
||||
|
||||
onCandidateClicked: (e) ->
|
||||
id = $(e.target).closest('tr').data('candidate-id')
|
||||
if id and (@isEmployer() or me.isAdmin())
|
||||
|
|
|
@ -8,7 +8,6 @@ SpriteBuilder = require 'lib/sprites/SpriteBuilder'
|
|||
module.exports = class WizardSettingsView extends CocoView
|
||||
id: 'wizard-settings-view'
|
||||
template: template
|
||||
startsLoading: true
|
||||
|
||||
events:
|
||||
'click .color-group': (e) ->
|
||||
|
@ -27,13 +26,11 @@ module.exports = class WizardSettingsView extends CocoView
|
|||
|
||||
loadWizard: ->
|
||||
@wizardThangType = new ThangType()
|
||||
@wizardThangType.url = -> '/db/thang.type/wizard'
|
||||
@wizardThangType.fetch()
|
||||
@listenToOnce(@wizardThangType, 'sync', @initCanvas)
|
||||
@wizardThangType.setURL '/db/thang.type/wizard'
|
||||
@supermodel.loadModel @wizardThangType, 'wizard'
|
||||
|
||||
initCanvas: ->
|
||||
@startsLoading = false
|
||||
@render()
|
||||
onLoaded: ->
|
||||
super()
|
||||
@spriteBuilder = new SpriteBuilder(@wizardThangType)
|
||||
@initStage()
|
||||
|
||||
|
@ -56,7 +53,7 @@ module.exports = class WizardSettingsView extends CocoView
|
|||
c
|
||||
|
||||
afterRender: ->
|
||||
return if @startsLoading
|
||||
return unless @supermodel.finished()
|
||||
wizardSettings = me.get('wizard') or {}
|
||||
wizardSettings.colorConfig ?= {}
|
||||
|
||||
|
|
|
@ -1,30 +1,29 @@
|
|||
RootView = require 'views/kinds/RootView'
|
||||
template = require 'templates/admin/clas'
|
||||
CocoCollection = require 'collections/CocoCollection'
|
||||
CocoModel = require 'models/CocoModel'
|
||||
|
||||
class CLASubmission extends CocoModel
|
||||
@className: 'CLA'
|
||||
@schema: require 'schemas/models/cla_submission'
|
||||
urlRoot: '/db/cla.submission'
|
||||
|
||||
class CLACollection extends CocoCollection
|
||||
url: '/db/cla.submissions'
|
||||
model: CLASubmission
|
||||
|
||||
module.exports = class CLAsView extends RootView
|
||||
id: 'admin-clas-view'
|
||||
template: template
|
||||
startsLoading: true
|
||||
|
||||
constructor: (options) ->
|
||||
super options
|
||||
@getCLAs()
|
||||
|
||||
getCLAs: ->
|
||||
CLACollection = Backbone.Collection.extend({
|
||||
url: '/db/cla.submissions'
|
||||
})
|
||||
@clas = new CLACollection()
|
||||
@clas.fetch()
|
||||
@listenTo(@clas, 'sync', @onCLAsLoaded)
|
||||
|
||||
onCLAsLoaded: ->
|
||||
@startsLoading = false
|
||||
@render()
|
||||
@clas = @supermodel.loadCollection(new CLACollection(), 'clas').model
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
c.clas = []
|
||||
unless @startsLoading
|
||||
c.clas = _.uniq (_.sortBy (cla.attributes for cla in @clas.models), (m) -> m.githubUsername?.toLowerCase()), 'githubUsername'
|
||||
if @supermodel.finished()
|
||||
c.clas = _.uniq (_.sortBy (cla.attributes for cla in @clas.models), (m) ->
|
||||
m.githubUsername?.toLowerCase()), 'githubUsername'
|
||||
c
|
||||
|
|
|
@ -23,7 +23,12 @@ module.exports = class CandidatesView extends RootView
|
|||
|
||||
constructor: (options) ->
|
||||
super options
|
||||
@getCandidates()
|
||||
@candidates = @supermodel.loadCollection(new CandidatesCollection(), 'candidates').model
|
||||
@remarks = @supermodel.loadCollection(new UserRemarksCollection(), 'user_remarks').model
|
||||
|
||||
onLoaded: ->
|
||||
super()
|
||||
@setUpScrolling()
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
|
@ -51,17 +56,7 @@ module.exports = class CandidatesView extends RootView
|
|||
userPermissions = me.get('permissions') ? []
|
||||
_.contains userPermissions, "employer"
|
||||
|
||||
getCandidates: ->
|
||||
@candidates = new CandidatesCollection()
|
||||
@candidates.fetch()
|
||||
@remarks = new UserRemarksCollection()
|
||||
@remarks.fetch()
|
||||
# Re-render when we have fetched them, but don't wait and show a progress bar while loading.
|
||||
@listenToOnce @candidates, 'all', @renderCandidatesAndSetupScrolling
|
||||
@listenToOnce @remarks, 'all', @renderCandidatesAndSetupScrolling
|
||||
|
||||
renderCandidatesAndSetupScrolling: =>
|
||||
@render()
|
||||
setUpScrolling: ->
|
||||
$(".nano").nanoScroller()
|
||||
if window.history?.state?.lastViewedCandidateID
|
||||
$(".nano").nanoScroller({scrollTo:$("#" + window.history.state.lastViewedCandidateID)})
|
||||
|
@ -203,4 +198,4 @@ module.exports = class CandidatesView extends RootView
|
|||
url = "/account/profile/#{id}"
|
||||
window.open url,"_blank"
|
||||
else
|
||||
@openModalView new EmployerSignupModal
|
||||
@openModalView new EmployerSignupModal
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = class EmployersListView extends RootView
|
|||
|
||||
constructor: (options) ->
|
||||
super options
|
||||
@getEmployers()
|
||||
@employers = @supermodel.loadCollection(new EmployersCollection(), 'employers').model
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
|
@ -30,12 +30,6 @@ module.exports = class EmployersListView extends RootView
|
|||
ctx.moment = moment
|
||||
ctx
|
||||
|
||||
getEmployers: ->
|
||||
@employers = new EmployersCollection()
|
||||
@employers.fetch()
|
||||
# Re-render when we have fetched them, but don't wait and show a progress bar while loading.
|
||||
@listenToOnce @employers, 'all', => @render()
|
||||
|
||||
sortTable: ->
|
||||
# http://mottie.github.io/tablesorter/docs/example-widget-bootstrap-theme.html
|
||||
$.extend $.tablesorter.themes.bootstrap,
|
||||
|
|
|
@ -33,7 +33,6 @@ module.exports = class FilesView extends RootView
|
|||
currentFolder: -> @$el.find('#folder-select').val()
|
||||
|
||||
loadFiles: ->
|
||||
console.log 'trying to load', "/file/#{@currentFolder()}/"
|
||||
$.ajax
|
||||
url: "/file/#{@currentFolder()}/"
|
||||
success: @onLoadedFiles
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
RootView = require 'views/kinds/RootView'
|
||||
template = require 'templates/admin/level_sessions'
|
||||
LevelSession = require 'models/LevelSession'
|
||||
CocoCollection = require 'collections/CocoCollection'
|
||||
|
||||
# Placeholder
|
||||
class LevelSessionCollection extends Backbone.Collection
|
||||
url: '/db/level_session/x/active'
|
||||
class LevelSessionCollection extends CocoCollection
|
||||
url: '/db/level_session/x/active?project=screenshot,levelName,creatorName'
|
||||
model: LevelSession
|
||||
|
||||
module.exports = class LevelSessionsView extends RootView
|
||||
|
@ -16,9 +16,7 @@ module.exports = class LevelSessionsView extends RootView
|
|||
@getLevelSessions()
|
||||
|
||||
getLevelSessions: ->
|
||||
@sessions = new LevelSessionCollection()
|
||||
@sessions.fetch()
|
||||
@listenToOnce @sessions, 'all', @render
|
||||
@sessions = @supermodel.loadCollection(new LevelSessionCollection(), 'sessions').model
|
||||
|
||||
getRenderData: =>
|
||||
c = super()
|
||||
|
|
|
@ -9,7 +9,6 @@ app = require 'application'
|
|||
module.exports = class AchievementEditView extends RootView
|
||||
id: 'editor-achievement-edit-view'
|
||||
template: template
|
||||
startsLoading: true
|
||||
|
||||
events:
|
||||
'click #save-button': 'saveAchievement'
|
||||
|
@ -23,21 +22,15 @@ module.exports = class AchievementEditView extends RootView
|
|||
super options
|
||||
@achievement = new Achievement(_id: @achievementID)
|
||||
@achievement.saveBackups = true
|
||||
|
||||
@achievement.once 'error', (achievement, jqxhr) =>
|
||||
@hideLoading()
|
||||
$(@$el).find('.main-content-area').children('*').not('.breadcrumb').remove()
|
||||
errors.backboneFailure arguments...
|
||||
|
||||
@achievement.fetch()
|
||||
@listenToOnce(@achievement, 'sync', @buildTreema)
|
||||
@supermodel.loadModel @achievement, 'achievement'
|
||||
@pushChangesToPreview = _.throttle(@pushChangesToPreview, 500)
|
||||
|
||||
onLoaded: ->
|
||||
super()
|
||||
@buildTreema()
|
||||
|
||||
buildTreema: ->
|
||||
return if @treema? or (not @achievement.loaded)
|
||||
|
||||
@startsLoading = false
|
||||
@render()
|
||||
data = $.extend(true, {}, @achievement.attributes)
|
||||
options =
|
||||
data: data
|
||||
|
@ -47,7 +40,6 @@ module.exports = class AchievementEditView extends RootView
|
|||
callbacks:
|
||||
change: @pushChangesToPreview
|
||||
@treema = @$el.find('#achievement-treema').treema(options)
|
||||
|
||||
@treema.build()
|
||||
|
||||
getRenderData: (context={}) ->
|
||||
|
@ -57,21 +49,16 @@ module.exports = class AchievementEditView extends RootView
|
|||
context
|
||||
|
||||
afterRender: ->
|
||||
super(arguments...)
|
||||
super()
|
||||
return unless @supermodel.finished()
|
||||
@pushChangesToPreview()
|
||||
|
||||
pushChangesToPreview: =>
|
||||
$('#achievement-view').empty()
|
||||
|
||||
if @treema?
|
||||
for key, value of @treema.data
|
||||
@achievement.set key, value
|
||||
|
||||
earned =
|
||||
earnedPoints: @achievement.get 'worth'
|
||||
|
||||
popup = new AchievementPopup achievement: @achievement, earnedAchievement:earned, popup: false, container: $('#achievement-view')
|
||||
|
||||
@$el.find('#achievement-view').empty()
|
||||
for key, value of @treema.data
|
||||
@achievement.set key, value
|
||||
earned = earnedPoints: @achievement.get 'worth'
|
||||
popup = new AchievementPopup achievement: @achievement, earnedAchievement: earned, popup: false, container: $('#achievement-view')
|
||||
|
||||
openSaveModal: ->
|
||||
'Maybe later' # TODO patch patch patch
|
||||
|
|
|
@ -8,7 +8,6 @@ PatchesView = require 'views/editor/PatchesView'
|
|||
module.exports = class ArticleEditView extends RootView
|
||||
id: 'editor-article-edit-view'
|
||||
template: template
|
||||
startsLoading: true
|
||||
|
||||
events:
|
||||
'click #preview-button': 'openPreview'
|
||||
|
@ -22,28 +21,17 @@ module.exports = class ArticleEditView extends RootView
|
|||
super options
|
||||
@article = new Article(_id: @articleID)
|
||||
@article.saveBackups = true
|
||||
|
||||
@listenToOnce(@article, 'error',
|
||||
() =>
|
||||
@hideLoading()
|
||||
|
||||
# Hack: editor components appear after calling insertSubView.
|
||||
# So we need to hide them first.
|
||||
$(@$el).find('.main-content-area').children('*').not('#error-view').remove()
|
||||
|
||||
@insertSubView(new ErrorView())
|
||||
)
|
||||
|
||||
@article.fetch()
|
||||
@listenToOnce(@article, 'sync', @buildTreema)
|
||||
@supermodel.loadModel @article, 'article'
|
||||
@pushChangesToPreview = _.throttle(@pushChangesToPreview, 500)
|
||||
|
||||
|
||||
onLoaded: ->
|
||||
super()
|
||||
@buildTreema()
|
||||
|
||||
buildTreema: ->
|
||||
return if @treema? or (not @article.loaded)
|
||||
unless @article.attributes.body
|
||||
@article.set('body', '')
|
||||
@startsLoading = false
|
||||
@render()
|
||||
data = $.extend(true, {}, @article.attributes)
|
||||
options =
|
||||
data: data
|
||||
|
@ -53,7 +41,6 @@ module.exports = class ArticleEditView extends RootView
|
|||
callbacks:
|
||||
change: @pushChangesToPreview
|
||||
@treema = @$el.find('#article-treema').treema(options)
|
||||
|
||||
@treema.build()
|
||||
|
||||
pushChangesToPreview: =>
|
||||
|
@ -73,7 +60,7 @@ module.exports = class ArticleEditView extends RootView
|
|||
|
||||
afterRender: ->
|
||||
super()
|
||||
return if @startsLoading
|
||||
return unless @supermodel.finished()
|
||||
@showReadOnly() if me.get('anonymous')
|
||||
@patchesView = @insertSubView(new PatchesView(@article), @$el.find('.patches-view'))
|
||||
@patchesView.load()
|
||||
|
|
|
@ -19,23 +19,14 @@ module.exports = class AddLevelSystemModal extends ModalView
|
|||
constructor: (options) ->
|
||||
super options
|
||||
@extantSystems = options.extantSystems ? []
|
||||
|
||||
render: ->
|
||||
if not @systems
|
||||
@systems = @supermodel.getCollection new LevelSystemSearchCollection()
|
||||
unless @systems.loaded
|
||||
@listenToOnce(@systems, 'sync', @onSystemsSync)
|
||||
@systems.fetch()
|
||||
super() # do afterRender at the end
|
||||
@systems = @supermodel.loadCollection(new LevelSystemSearchCollection(), 'systems').model
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
return @showLoading() unless @systems?.loaded
|
||||
@hideLoading()
|
||||
return unless @supermodel.finished()
|
||||
@renderAvailableSystems()
|
||||
|
||||
renderAvailableSystems: ->
|
||||
return unless @systems
|
||||
ul = @$el.find('ul.available-systems-list').empty()
|
||||
systems = (m.attributes for m in @systems.models)
|
||||
_.remove systems, (system) =>
|
||||
|
@ -44,10 +35,6 @@ module.exports = class AddLevelSystemModal extends ModalView
|
|||
for system in systems
|
||||
ul.append $(availableSystemTemplate(system: system))
|
||||
|
||||
onSystemsSync: ->
|
||||
@supermodel.addCollection @systems
|
||||
@render()
|
||||
|
||||
onAddSystem: (e) ->
|
||||
id = $(e.currentTarget).data('system-id')
|
||||
system = _.find @systems.models, id: id
|
||||
|
|
|
@ -14,7 +14,6 @@ module.exports = class AddThangsView extends CocoView
|
|||
id: 'add-thangs-column'
|
||||
className: 'add-thangs-palette thangs-column'
|
||||
template: add_thangs_template
|
||||
startsLoading: false
|
||||
|
||||
events:
|
||||
'keyup input#thang-search': 'runSearch'
|
||||
|
|
|
@ -28,7 +28,6 @@ module.exports = class ThangsTabView extends CocoView
|
|||
id: 'editor-level-thangs-tab-view'
|
||||
className: 'tab-pane active'
|
||||
template: thangs_template
|
||||
startsLoading: true
|
||||
|
||||
subscriptions:
|
||||
'surface:sprite-selected': 'onExtantThangSelected'
|
||||
|
|
|
@ -11,23 +11,22 @@ module.exports = class ThangTypeColorsTabView extends CocoView
|
|||
offset: 0
|
||||
|
||||
constructor: (@thangType, options) ->
|
||||
@listenToOnce(@thangType, 'sync', @tryToBuild)
|
||||
# @listenToOnce(@thangType.schema(), 'sync', @tryToBuild)
|
||||
super options
|
||||
@supermodel.loadModel @thangType, 'thang'
|
||||
@colorConfig = {hue: 0, saturation: 0.5, lightness: 0.5}
|
||||
@spriteBuilder = new SpriteBuilder(@thangType)
|
||||
f = =>
|
||||
@offset++
|
||||
@updateMovieClip()
|
||||
@interval = setInterval f, 1000
|
||||
super options
|
||||
|
||||
destroy: ->
|
||||
clearInterval @interval
|
||||
super()
|
||||
|
||||
onLoaded: -> @render()
|
||||
afterRender: ->
|
||||
super()
|
||||
return unless @supermodel.finished()
|
||||
@createShapeButtons()
|
||||
@initStage()
|
||||
@initSliders()
|
||||
|
|
|
@ -21,7 +21,6 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
id: 'thang-type-edit-view'
|
||||
className: 'editor'
|
||||
template: template
|
||||
startsLoading: true
|
||||
resolution: 4
|
||||
scale: 3
|
||||
mockThang:
|
||||
|
|
|
@ -17,7 +17,6 @@ class VersionsViewCollection extends CocoCollection
|
|||
|
||||
module.exports = class VersionsModal extends ModalView
|
||||
template: template
|
||||
startsLoading: true
|
||||
plain: true
|
||||
modalWidthPercent: 80
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@ module.exports = class MainPlayView extends RootView
|
|||
constructor: (options) ->
|
||||
super options
|
||||
@levelStatusMap = {}
|
||||
@sessions = new LevelSessionsCollection()
|
||||
@sessions.fetch()
|
||||
@sessions = @supermodel.loadCollection(new LevelSessionsCollection(), 'your_sessions', null, 0).model
|
||||
@listenToOnce @sessions, 'sync', @onSessionsLoaded
|
||||
|
||||
onSessionsLoaded: (e) ->
|
||||
|
@ -29,8 +28,6 @@ module.exports = class MainPlayView extends RootView
|
|||
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.home = true
|
||||
context.notFound = @getQueryVariable 'not_found'
|
||||
tutorials = [
|
||||
{
|
||||
name: 'Rescue Mission'
|
||||
|
|
|
@ -38,7 +38,6 @@ module.exports = class SpectateLevelView extends RootView
|
|||
template: template
|
||||
cache: false
|
||||
shortcutsEnabled: true
|
||||
startsLoading: true
|
||||
isEditorPreview: false
|
||||
|
||||
subscriptions:
|
||||
|
@ -70,7 +69,6 @@ module.exports = class SpectateLevelView extends RootView
|
|||
console.profile?() if PROFILE_ME
|
||||
super options
|
||||
$(window).on('resize', @onWindowResize)
|
||||
@listenToOnce(@supermodel, 'error', @onLevelLoadError)
|
||||
|
||||
@sessionOne = @getQueryVariable 'session-one'
|
||||
@sessionTwo = @getQueryVariable 'session-two'
|
||||
|
@ -87,9 +85,6 @@ module.exports = class SpectateLevelView extends RootView
|
|||
else
|
||||
@load()
|
||||
|
||||
onLevelLoadError: (e) =>
|
||||
application.router.navigate "/play?not_found=#{@levelID}", {trigger: true}
|
||||
|
||||
setLevel: (@level, @supermodel) ->
|
||||
serializedLevel = @level.serialize @supermodel, @session
|
||||
@god?.setLevel serializedLevel
|
||||
|
@ -106,7 +101,6 @@ module.exports = class SpectateLevelView extends RootView
|
|||
opponentSessionID: @sessionTwo
|
||||
spectateMode: true
|
||||
team: @getQueryVariable('team')
|
||||
@listenToOnce(@levelLoader, 'loaded-all', @onLevelLoaderLoaded)
|
||||
@god = new God maxAngels: 1
|
||||
|
||||
getRenderData: ->
|
||||
|
@ -121,37 +115,10 @@ module.exports = class SpectateLevelView extends RootView
|
|||
super()
|
||||
$('body').addClass('is-playing')
|
||||
|
||||
updateProgress: (progress) ->
|
||||
super(progress)
|
||||
return if @seenDocs
|
||||
return unless showFrequency = @levelLoader.level.get('showGuide')
|
||||
session = @levelLoader.session
|
||||
diff = new Date().getTime() - new Date(session.get('created')).getTime()
|
||||
return if showFrequency is 'first-time' and diff > (5 * 60 * 1000)
|
||||
return unless @levelLoader.level.loaded
|
||||
articles = @levelLoader.supermodel.getModels Article
|
||||
for article in articles
|
||||
return unless article.loaded
|
||||
@showGuide()
|
||||
|
||||
showGuide: ->
|
||||
@seenDocs = true
|
||||
LevelGuideModal = require './level/modal/LevelGuideModal'
|
||||
options = {docs: @levelLoader.level.get('documentation'), supermodel: @supermodel}
|
||||
@openModalView(new LevelGuideModal(options), true)
|
||||
Backbone.Mediator.subscribeOnce 'modal-closed', @onLevelLoaderLoaded, @
|
||||
return true
|
||||
|
||||
onLoaded: ->
|
||||
_.defer => @onLevelLoaded()
|
||||
|
||||
onLevelLoaded: ->
|
||||
return unless @levelLoader.progress() is 1 # double check, since closing the guide may trigger this early
|
||||
# Save latest level played in local storage
|
||||
if window.currentModal and not window.currentModal.destroyed
|
||||
@loadingView.showReady()
|
||||
return Backbone.Mediator.subscribeOnce 'modal-closed', @onLevelLoaderLoaded, @
|
||||
|
||||
@grabLevelLoaderData()
|
||||
#at this point, all requisite data is loaded, and sessions are not denormalized
|
||||
team = @world.teamForPlayer(0)
|
||||
|
|
|
@ -9,7 +9,6 @@ module.exports = class LadderPlayModal extends ModalView
|
|||
id: 'ladder-play-modal'
|
||||
template: template
|
||||
closeButton: true
|
||||
startsLoading: true
|
||||
@shownTutorialButton: false
|
||||
tutorialLevelExists: null
|
||||
|
||||
|
@ -60,11 +59,13 @@ module.exports = class LadderPlayModal extends ModalView
|
|||
challenger.opponentWizard = @nameMap[challenger.opponentID]?.wizard or {}
|
||||
@checkWizardLoaded()
|
||||
|
||||
$.ajax('/db/user/-/names', {
|
||||
userNamesRequest = @supermodel.addRequestResource 'user_names', {
|
||||
url: '/db/user/-/names'
|
||||
data: {ids: ids, wizard: true}
|
||||
type: 'POST'
|
||||
method: 'POST'
|
||||
success: success
|
||||
})
|
||||
}, 0
|
||||
userNamesRequest.load()
|
||||
|
||||
# PART 3: Make sure wizard is loaded
|
||||
|
||||
|
@ -76,7 +77,6 @@ module.exports = class LadderPlayModal extends ModalView
|
|||
finishRendering: ->
|
||||
@checkTutorialLevelExists (exists) =>
|
||||
@tutorialLevelExists = exists
|
||||
@startsLoading = false
|
||||
@render()
|
||||
@maybeShowTutorialButtons()
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@ module.exports = class LadderHomeView extends RootView
|
|||
constructor: (options) ->
|
||||
super options
|
||||
@levelStatusMap = {}
|
||||
@sessions = new LevelSessionsCollection()
|
||||
@sessions.fetch()
|
||||
@sessions = @supermodel.loadCollection(new LevelSessionsCollection(), 'your_sessions', null, 0).model
|
||||
@listenToOnce @sessions, 'sync', @onSessionsLoaded
|
||||
|
||||
onSessionsLoaded: (e) ->
|
||||
|
|
|
@ -8,7 +8,6 @@ LadderSubmissionView = require 'views/play/common/LadderSubmissionView'
|
|||
module.exports = class MyMatchesTabView extends CocoView
|
||||
id: 'my-matches-tab-view'
|
||||
template: require 'templates/play/ladder/my_matches_tab'
|
||||
startsLoading: true
|
||||
|
||||
constructor: (options, @level, @sessions) ->
|
||||
super(options)
|
||||
|
@ -31,7 +30,7 @@ module.exports = class MyMatchesTabView extends CocoView
|
|||
continue
|
||||
ids.push id unless @nameMap[id]
|
||||
|
||||
return @finishRendering() unless ids.length
|
||||
return unless ids.length
|
||||
|
||||
success = (nameMap) =>
|
||||
return if @destroyed
|
||||
|
@ -39,17 +38,15 @@ module.exports = class MyMatchesTabView extends CocoView
|
|||
for match in session.get('matches') or []
|
||||
opponent = match.opponents[0]
|
||||
@nameMap[opponent.userID] ?= nameMap[opponent.userID]?.name ? '<bad match data>'
|
||||
@finishRendering()
|
||||
@render() if @supermodel.finished()
|
||||
|
||||
$.ajax('/db/user/-/names', {
|
||||
userNamesRequest = @supermodel.addRequestResource 'user_names', {
|
||||
url: '/db/user/-/names'
|
||||
data: {ids: ids}
|
||||
type: 'POST'
|
||||
method: 'POST'
|
||||
success: success
|
||||
})
|
||||
|
||||
finishRendering: ->
|
||||
@startsLoading = false
|
||||
@render()
|
||||
}, 0
|
||||
userNamesRequest.load()
|
||||
|
||||
getRenderData: ->
|
||||
ctx = super()
|
||||
|
|
|
@ -41,7 +41,6 @@ module.exports = class PlayLevelView extends RootView
|
|||
template: template
|
||||
cache: false
|
||||
shortcutsEnabled: true
|
||||
startsLoading: true
|
||||
isEditorPreview: false
|
||||
|
||||
subscriptions:
|
||||
|
|
|
@ -39,7 +39,7 @@ module.exports = class VictoryModal extends ModalView
|
|||
loadExistingFeedback: ->
|
||||
url = "/db/level/#{@level.id}/feedback"
|
||||
@feedback = new LevelFeedback()
|
||||
@feedback.url = -> url
|
||||
@feedback.setURL url
|
||||
@feedback.fetch()
|
||||
@listenToOnce(@feedback, 'sync', -> @onFeedbackLoaded())
|
||||
@listenToOnce(@feedback, 'error', -> @onFeedbackNotFound())
|
||||
|
|
Loading…
Reference in a new issue