From 9ac0939bb87ab5bd19fc358ac5919739ea210fb7 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Thu, 13 Feb 2014 09:26:21 -0800 Subject: [PATCH] Fixed modal switchout and palette property interpolation. Refactored all use of .hide to .secret so we can use jQuery to show/hide things again. --- app/styles/base.sass | 4 +++ app/templates/account/settings.jade | 2 +- app/templates/account/unsubscribe.jade | 6 ++-- app/templates/editor/level/thang/edit.jade | 4 +-- app/templates/editor/level/thangs_tab.jade | 2 +- app/templates/editor/thang/colors_tab.jade | 2 +- app/templates/kinds/search.jade | 2 +- app/templates/modal/contact.jade | 2 +- app/templates/modal/modal_base.jade | 2 +- app/templates/play/level.jade | 6 ++-- app/templates/play/level/chat.jade | 2 +- app/templates/play/level/modal/victory.jade | 4 +-- app/templates/play/level/playback.jade | 6 ++-- app/views/account/settings_view.coffee | 4 +-- app/views/account/unsubscribe_view.coffee | 26 +++++++------- .../account/wizard_settings_tab_view.coffee | 34 +++++++++---------- app/views/editor/level/thang/edit.coffee | 22 ++++++------ app/views/editor/level/thangs_tab_view.coffee | 4 +-- app/views/editor/thang/colors_tab_view.coffee | 30 ++++++++-------- app/views/kinds/CocoView.coffee | 14 ++++---- app/views/play/level/goals_view.coffee | 4 +-- app/views/play/level/gold_view.coffee | 2 +- app/views/play/level/hud_view.coffee | 16 ++++----- app/views/play/level/level_chat_view.coffee | 21 ++++-------- .../play/level/modal/multiplayer_modal.coffee | 4 +-- app/views/play/level/playback_view.coffee | 16 ++++----- .../tome/spell_palette_entry_view.coffee | 2 +- app/views/play/level_view.coffee | 2 +- 28 files changed, 119 insertions(+), 126 deletions(-) diff --git a/app/styles/base.sass b/app/styles/base.sass index 663326fcc..f26501f6a 100644 --- a/app/styles/base.sass +++ b/app/styles/base.sass @@ -1,6 +1,10 @@ @import "bootstrap/variables" @import "bootstrap/mixins" +// https://github.com/twbs/bootstrap/issues/9237 -- need a version that's not !important +.secret + display: none + h1 h2 h3 h4 letter-spacing: 2px diff --git a/app/templates/account/settings.jade b/app/templates/account/settings.jade index ba1ab1757..483b35f88 100644 --- a/app/templates/account/settings.jade +++ b/app/templates/account/settings.jade @@ -8,7 +8,7 @@ block content p(data-i18n="account_settings.not_logged_in") Log in or create an account to change your settings. else - button.btn#save-button.disabled.hide(data-i18n="account_settings.saveBackups") Changes Save Automatically + button.btn#save-button.disabled.secret(data-i18n="account_settings.saveBackups") Changes Save Automatically ul.nav.nav-pills#settings-tabs li diff --git a/app/templates/account/unsubscribe.jade b/app/templates/account/unsubscribe.jade index 8f4eaebe8..5eeee57cc 100644 --- a/app/templates/account/unsubscribe.jade +++ b/app/templates/account/unsubscribe.jade @@ -9,9 +9,9 @@ block content button.btn.btn-warning#unsubscribe-button(data-i18n="account.unsubscribe_button") Do it - .progress.progress-striped.active.hide + .progress.progress-striped.active.secret .progress-bar - p.hide#fail-alert(data-i18n="account.unsubscribe_failed").alert.alert-danger Failed + p.secret#fail-alert(data-i18n="account.unsubscribe_failed").alert.alert-danger Failed - p.hide#success-alert(data-i18n="account.unsubscribe_success").alert.alert-success Success + p.secret#success-alert(data-i18n="account.unsubscribe_success").alert.alert-success Success diff --git a/app/templates/editor/level/thang/edit.jade b/app/templates/editor/level/thang/edit.jade index beb9fbfa2..467a00a20 100644 --- a/app/templates/editor/level/thang/edit.jade +++ b/app/templates/editor/level/thang/edit.jade @@ -3,13 +3,13 @@ div.well span#thang-props a#thang-name-link span= thang.id - input.hide(value=thang.id) + input.secret(value=thang.id) | ( span(data-i18n="editor.level_components_type") Type | : a#thang-type-link span= thang.thangType - input.hide(value=thang.thangType) + input.secret(value=thang.thangType) | ) #thang-components-edit-view \ No newline at end of file diff --git a/app/templates/editor/level/thangs_tab.jade b/app/templates/editor/level/thangs_tab.jade index 431c1e27e..af1ab989e 100644 --- a/app/templates/editor/level/thangs_tab.jade +++ b/app/templates/editor/level/thangs_tab.jade @@ -31,4 +31,4 @@ - path = '/file/db/thang.type/'+thangType.original+'/portrait.png' img(title="Add " + thangType.name, src=path, alt="") div.clearfix -#editor-level-thang-edit.hide \ No newline at end of file +#editor-level-thang-edit.secret \ No newline at end of file diff --git a/app/templates/editor/thang/colors_tab.jade b/app/templates/editor/thang/colors_tab.jade index 3c517093e..503d4a681 100644 --- a/app/templates/editor/thang/colors_tab.jade +++ b/app/templates/editor/thang/colors_tab.jade @@ -1,6 +1,6 @@ div#color-groups-treema -div#color-group-settings.hide +div#color-group-settings.secret div#shape-buttons canvas#tinting-display(width=400, height=400) diff --git a/app/templates/kinds/search.jade b/app/templates/kinds/search.jade index 15728c47b..89d64d25b 100644 --- a/app/templates/kinds/search.jade +++ b/app/templates/kinds/search.jade @@ -21,7 +21,7 @@ block content .modal-footer button.btn(data-dismiss="modal") Cancel button.btn.btn-primary.new-model-submit Create - .modal-body.wait.hide + .modal-body.wait.secret h3 Reticulating Splines... .progress.progress-striped.active .progress-bar diff --git a/app/templates/modal/contact.jade b/app/templates/modal/contact.jade index 00cb24b94..7143520c2 100644 --- a/app/templates/modal/contact.jade +++ b/app/templates/modal/contact.jade @@ -22,6 +22,6 @@ block modal-body-content textarea#contact-message.form-control(name="message", rows=8) block modal-footer-content - span.sending-indicator.pull-left.hide(data-i18n="common.sending") Sending... + span.sending-indicator.pull-left.secret(data-i18n="common.sending") Sending... a(href='#', data-dismiss="modal", aria-hidden="true", data-i18n="common.cancel").btn Cancel button.btn.btn-primary#contact-submit-button(data-i18n="contact.send") Send Feedback diff --git a/app/templates/modal/modal_base.jade b/app/templates/modal/modal_base.jade index ac0b92600..caebe847c 100644 --- a/app/templates/modal/modal_base.jade +++ b/app/templates/modal/modal_base.jade @@ -14,7 +14,7 @@ img(src="http://www.manbitesgod.com/images/picturecoupleb.jpg") img(src="http://www.manbitesgod.com/images/manrantb.jpg") - .modal-body.wait.hide + .modal-body.wait.secret block modal-body-wait-content h3 Reticulating Splines... .progress.progress-striped.active diff --git a/app/templates/play/level.jade b/app/templates/play/level.jade index 276d9fc80..7abc94dd5 100644 --- a/app/templates/play/level.jade +++ b/app/templates/play/level.jade @@ -11,11 +11,11 @@ #canvas-left-gradient.gradient #canvas-top-gradient.gradient - a.btn.btn-primary.banner.hide#level-done-button(data-i18n="play_level.done") Done + a.btn.btn-primary.banner.secret#level-done-button(data-i18n="play_level.done") Done - #goals-view.hide + #goals-view.secret - #gold-view.hide.expanded + #gold-view.secret.expanded #level-chat-view diff --git a/app/templates/play/level/chat.jade b/app/templates/play/level/chat.jade index e974cd3e0..a3ba76174 100644 --- a/app/templates/play/level/chat.jade +++ b/app/templates/play/level/chat.jade @@ -2,7 +2,7 @@ table tbody -.open-chat-area.hide +.open-chat-area.secret table tbody diff --git a/app/templates/play/level/modal/victory.jade b/app/templates/play/level/modal/victory.jade index 1b7969473..afdd19f88 100644 --- a/app/templates/play/level/modal/victory.jade +++ b/app/templates/play/level/modal/victory.jade @@ -15,7 +15,7 @@ button.btn.btn-success.sign-up-button.btn-large(data-toggle="coco-modal", data-target="modal/signup", data-i18n="play_level.victory_sign_up") Sign Up to Save Progress span(data-i18n="play_level.victory_sign_up_poke") Want to save your code? Create a free account! else - div.rating.hide + div.rating.secret span(data-i18n="play_level.victory_rate_the_level") Rate the level: i.icon-star-empty i.icon-star-empty @@ -30,7 +30,7 @@ else a.btn.btn-primary(href="/", data-dismiss="modal", data-i18n="play_level.victory_go_home") Go Home if !me.get('anonymous') - div.review.hide + div.review.secret span(data-i18n="play_level.victory_review") Tell us more! br textarea diff --git a/app/templates/play/level/playback.jade b/app/templates/play/level/playback.jade index 7a1755ac4..84801141f 100644 --- a/app/templates/play/level/playback.jade +++ b/app/templates/play/level/playback.jade @@ -11,7 +11,7 @@ button.btn.btn-xs.btn-inverse#music-button(title="Toggle Music") | ♫ .scrubber - .progress.hide + .progress.secret .progress-bar .scrubber-handle @@ -27,11 +27,11 @@ button.btn.btn-xs.btn-inverse#music-button(title="Toggle Music") li(title="Ctrl/Cmd + \\: Toggle debug display").selectable#debug-toggle i.icon-globe | Debug Mode - i.icon-ok.hide + i.icon-ok.secret li(title="Ctrl/Cmd + G: Toggle grid display").selectable#grid-toggle i.icon-th span(data-i18n="play_level.grid") Grid - i.icon-ok.hide + i.icon-ok.secret li.selectable#edit-wizard-settings i.icon-user span(data-i18n="play_level.customize_wizard") Customize Wizard diff --git a/app/views/account/settings_view.coffee b/app/views/account/settings_view.coffee index 763a5f629..bb028c0cf 100644 --- a/app/views/account/settings_view.coffee +++ b/app/views/account/settings_view.coffee @@ -48,7 +48,7 @@ module.exports = class SettingsView extends View @updateWizardColor() wizardSettingsTabView = new WizardSettingsTabView() wizardSettingsTabView.on 'change', @save, @ - @insertSubView wizardSettingsTabView + @insertSubView wizardSettingsTabView chooseTab: (category) -> id = "##{category}-pane" @@ -102,7 +102,7 @@ module.exports = class SettingsView extends View res = me.save() return unless res save = $('#save-button', @$el).text($.i18n.t('common.saving', defaultValue: 'Saving...')) - .addClass('btn-info').removeClass('hide').removeClass('btn-danger') + .addClass('btn-info').show().removeClass('btn-danger') res.error -> errors = JSON.parse(res.responseText) diff --git a/app/views/account/unsubscribe_view.coffee b/app/views/account/unsubscribe_view.coffee index f9320e216..9c951abb0 100644 --- a/app/views/account/unsubscribe_view.coffee +++ b/app/views/account/unsubscribe_view.coffee @@ -5,7 +5,7 @@ template = require 'templates/account/unsubscribe' module.exports = class UnsubscribeView extends RootView id: "unsubscribe-view" template: template - + events: 'click #unsubscribe-button': 'onUnsubscribeButtonClicked' @@ -15,21 +15,21 @@ module.exports = class UnsubscribeView extends RootView context onUnsubscribeButtonClicked: -> - @$el.find('#unsubscribe-button').addClass 'hide' - @$el.find('.progress').removeClass 'hide' - @$el.find('.alert').addClass 'hide' - + @$el.find('#unsubscribe-button').hide() + @$el.find('.progress').show() + @$el.find('.alert').hide() + email = @getQueryVariable 'email' url = "/auth/unsubscribe?email=#{encodeURIComponent(email)}" - + success = => - @$el.find('.progress').addClass 'hide' - @$el.find('#success-alert').removeClass 'hide' + @$el.find('.progress').hide() + @$el.find('#success-alert').show() me.fetch() - + error = => - @$el.find('.progress').addClass 'hide' - @$el.find('#fail-alert').removeClass 'hide' - @$el.find('#unsubscribe-button').removeClass 'hide' - + @$el.find('.progress').hide() + @$el.find('#fail-alert').show() + @$el.find('#unsubscribe-button').show() + $.ajax { url: url, success: success, error: error } diff --git a/app/views/account/wizard_settings_tab_view.coffee b/app/views/account/wizard_settings_tab_view.coffee index a26c1452f..ea0462761 100644 --- a/app/views/account/wizard_settings_tab_view.coffee +++ b/app/views/account/wizard_settings_tab_view.coffee @@ -7,7 +7,7 @@ SpriteBuilder = require 'lib/sprites/SpriteBuilder' module.exports = class WizardSettingsTabView extends RootView id: 'wizard-settings-tab-view' template: template - + events: 'change .color-group-checkbox': (e) -> colorGroup = $(e.target).closest('.color-group') @@ -17,13 +17,13 @@ module.exports = class WizardSettingsTabView extends RootView constructor: -> super(arguments...) @loadWizard() - + loadWizard: -> @wizardThangType = new ThangType() @wizardThangType.url = -> '/db/thang_type/wizard' @wizardThangType.fetch() @wizardThangType.once 'sync', @initCanvas, @ - + initCanvas: -> @render() @spriteBuilder = new SpriteBuilder(@wizardThangType) @@ -32,9 +32,9 @@ module.exports = class WizardSettingsTabView extends RootView getRenderData: -> c = super() wizardSettings = me.get('wizard')?.colorConfig or {} - + colorGroups = @wizardThangType.get('colorGroups') or {} - f = (name) -> { + f = (name) -> { dasherized: _.string.dasherize(name) humanized: _.string.humanize name name: name @@ -42,26 +42,26 @@ module.exports = class WizardSettingsTabView extends RootView } c.colorGroups = (f(colorName) for colorName in _.keys colorGroups) c - + afterRender: -> wizardSettings = me.get('wizard') or {} wizardSettings.colorConfig ?= {} - + @$el.find('.selector').each (i, slider) => [groupName, prop] = $(slider).attr('name').split('.') value = 100 * (wizardSettings.colorConfig[groupName]?[prop] ? 0.5) @initSlider $(slider), value, @onSliderChanged - + @$el.find('.color-group').each (i, colorGroup) => @updateSliderVisibility($(colorGroup)) - + updateSliderVisibility: (colorGroup) -> enabled = colorGroup.find('.color-group-checkbox').prop('checked') - colorGroup.find('.sliders').toggleClass 'hide', not enabled - + colorGroup.find('.sliders').toggle Boolean(enabled) + updateColorSettings: (colorGroup) -> wizardSettings = me.get('wizard') or {} - wizardSettings.colorConfig ?= {} + wizardSettings.colorConfig ?= {} colorName = colorGroup.data('name') wizardSettings.colorConfig[colorName] ?= {} if colorGroup.find('.color-group-checkbox').prop('checked') @@ -75,7 +75,7 @@ module.exports = class WizardSettingsTabView extends RootView me.set('wizard', wizardSettings) @updateMovieClip() @trigger 'change' - + onSliderChanged: (e, result) => @updateColorSettings $(result.handle).closest('.color-group') @@ -84,12 +84,12 @@ module.exports = class WizardSettingsTabView extends RootView @updateMovieClip() createjs.Ticker.setFPS 20 createjs.Ticker.addEventListener("tick", @stage) - + updateMovieClip: -> return unless @wizardThangType.loaded wizardSettings = me.get('wizard') or {} wizardSettings.colorConfig ?= {} - + @stage.removeChild(@movieClip) if @movieClip options = {colorConfig: wizardSettings.colorConfig} @spriteBuilder.setOptions options @@ -100,10 +100,10 @@ module.exports = class WizardSettingsTabView extends RootView @movieClip.scaleY = @movieClip.scaleX = 1.7 * (castAction.scale or 1) reg = castAction.positions?.registration if reg - @movieClip.regX = reg.x + @movieClip.regX = reg.x @movieClip.regY = reg.y @stage.addChild @movieClip @stage.update() destroy: -> - @stage?.removeAllEventListeners() \ No newline at end of file + @stage?.removeAllEventListeners() diff --git a/app/views/editor/level/thang/edit.coffee b/app/views/editor/level/thang/edit.coffee index cd0ee3a14..2a92fd0b1 100644 --- a/app/views/editor/level/thang/edit.coffee +++ b/app/views/editor/level/thang/edit.coffee @@ -9,10 +9,10 @@ module.exports = class LevelThangEditView extends View Everything below is part of the ThangComponentEditView, which is shared with the ThangType editor view. ### - + id: "editor-level-thang-edit" template: template - + events: 'click #all-thangs-link': 'navigateToAllThangs' 'click #thang-name-link span': 'toggleNameEdit' @@ -32,7 +32,7 @@ module.exports = class LevelThangEditView extends View context = super(context) context.thang = @thangData context - + afterRender: -> options = components: @thangData.components @@ -40,7 +40,7 @@ module.exports = class LevelThangEditView extends View level: @level world: @world callback: @onComponentsChanged - + @thangComponentEditView = new ThangComponentEditView options @insertSubView @thangComponentEditView thangTypeNames = (m.get('name') for m in @supermodel.getModels ThangType) @@ -57,35 +57,35 @@ module.exports = class LevelThangEditView extends View thangData: @thangData id: @oldID Backbone.Mediator.publish 'level-thang-edited', event - + navigateToAllThangs: -> Backbone.Mediator.publish 'level-thang-done-editing' - + toggleNameEdit: -> link = @$el.find '#thang-name-link' wasEditing = link.find('input:visible').length span = link.find('span') input = link.find('input') if wasEditing then span.text(input.val()) else input.val(span.text()) - link.find('span, input').toggleClass('hide') + link.find('span, input').toggle() input.select() unless wasEditing @thangData.id = span.text() @saveThang() - + toggleTypeEdit: -> link = @$el.find '#thang-type-link' wasEditing = link.find('input:visible').length span = link.find('span') input = link.find('input') - span.text(input.val()) if wasEditing - link.find('span, input').toggleClass('hide') + span.text(input.val()) if wasEditing + link.find('span, input').toggle() input.select() unless wasEditing thangTypeName = input.val() thangType = _.find @supermodel.getModels(ThangType), (m) -> m.get('name') is thangTypeName if thangType and wasEditing @thangData.thangType = thangType.get('original') @saveThang() - + onComponentsChanged: (components) => @thangData.components = components @saveThang() diff --git a/app/views/editor/level/thangs_tab_view.coffee b/app/views/editor/level/thangs_tab_view.coffee index 05865634e..45fbb8d6e 100644 --- a/app/views/editor/level/thangs_tab_view.coffee +++ b/app/views/editor/level/thangs_tab_view.coffee @@ -374,7 +374,7 @@ module.exports = class ThangsTabView extends View thangData = @thangsTreema.get "id=#{e.thangID}" @editThangView = new LevelThangEditView thangData: thangData, supermodel: @supermodel, level: @level, world: @world @insertSubView @editThangView - @$el.find('.thangs-column').addClass('hide') + @$el.find('.thangs-column').hide() Backbone.Mediator.publish 'level:view-switched', e onLevelThangEdited: (e) -> @@ -383,7 +383,7 @@ module.exports = class ThangsTabView extends View onLevelThangDoneEditing: -> @removeSubView @editThangView - @$el.find('.thangs-column').removeClass('hide') + @$el.find('.thangs-column').show() class ThangsNode extends TreemaNode.nodeMap.array diff --git a/app/views/editor/thang/colors_tab_view.coffee b/app/views/editor/thang/colors_tab_view.coffee index 125ca2ab7..4f42a15fc 100644 --- a/app/views/editor/thang/colors_tab_view.coffee +++ b/app/views/editor/thang/colors_tab_view.coffee @@ -1,21 +1,21 @@ CocoView = require 'views/kinds/CocoView' template = require 'templates/editor/thang/colors_tab' SpriteBuilder = require 'lib/sprites/SpriteBuilder' -{hexToHSL} = require 'lib/utils' +{hexToHSL} = require 'lib/utils' module.exports = class ColorsTabView extends CocoView id: 'editor-thang-colors-tab-view' template: template className: 'tab-pane' - + offset: 0 - + constructor: (@thangType, options) -> @thangType.once 'sync', @tryToBuild, @ @thangType.schema().once 'sync', @tryToBuild, @ @colorConfig = { hue: 0, saturation: 0.5, lightness: 0.5 } @spriteBuilder = new SpriteBuilder(@thangType) - f = => + f = => @offset++ @updateMovieClip() @interval = setInterval f, 1000 @@ -27,21 +27,21 @@ module.exports = class ColorsTabView extends CocoView @initStage() @initSliders() @tryToBuild() - + # sliders initSliders: -> @hueSlider = @initSlider $("#hue-slider", @$el), 0, @makeSliderCallback 'hue' @saturationSlider = @initSlider $("#saturation-slider", @$el), 50, @makeSliderCallback 'saturation' @lightnessSlider = @initSlider $("#lightness-slider", @$el), 50, @makeSliderCallback 'lightness' - + makeSliderCallback: (property) -> (e, result) => @colorConfig[property] = result.value / 100 @updateMovieClip() - + # movie clip - + initStage: -> canvas = @$el.find('#tinting-display') @stage = new createjs.Stage(canvas[0]) @@ -95,7 +95,7 @@ module.exports = class ColorsTabView extends CocoView aHSL = hexToHSL(a) bHSL = hexToHSL(b) if aHSL[0] > bHSL[0] then -1 else 1 - + for color in colors button = $('').addClass('btn') button.css('background', color) @@ -130,23 +130,23 @@ module.exports = class ColorsTabView extends CocoView @thangType.set('colorGroups', @colorGroups.data) onColorGroupSelected: (e, selected) => - @$el.find('#color-group-settings').toggleClass('hide', not selected.length) + @$el.find('#color-group-settings').toggle selected.length > 0 treema = @colorGroups.getLastSelectedTreema() return unless treema @currentColorGroupTreema = treema - + shapes = {} shapes[shape] = true for shape in treema.data - + colors = {} for key, shape of @thangType.get('raw')?.shapes or {} continue unless shape.fc? colors[shape.fc] = true if shapes[key] - + @buttons.find('button').removeClass('selected') @buttons.find('button').each (i, button) -> $(button).addClass('selected') if colors[$(button).val()] - + @updateMovieClip() updateColorGroup: -> @@ -155,7 +155,7 @@ module.exports = class ColorsTabView extends CocoView return unless $(button).hasClass('selected') window.button = button colors[$(button).val()] = true - + shapes = [] for key, shape of @thangType.get('raw')?.shapes or {} continue unless shape.fc? diff --git a/app/views/kinds/CocoView.coffee b/app/views/kinds/CocoView.coffee index 905099fd3..dcff0dee2 100644 --- a/app/views/kinds/CocoView.coffee +++ b/app/views/kinds/CocoView.coffee @@ -115,7 +115,7 @@ module.exports = class CocoView extends Backbone.View visibleModal.willDisappear() if visibleModal visibleModal.destroy() visibleModal = null - $('#modal-wrapper .modal').off 'hidden.bs.modal', @modalClosed + #$('#modal-wrapper .modal').off 'hidden.bs.modal', @modalClosed if waitingModal wm = waitingModal waitingModal = null @@ -127,7 +127,7 @@ module.exports = class CocoView extends Backbone.View # Loading RootViews showLoading: ($el=@$el) -> - $el.find('>').addClass('hide') + $el.find('>').hide() $el.append($('
') .append('

Loading

') .append('
')) @@ -136,18 +136,18 @@ module.exports = class CocoView extends Backbone.View hideLoading: -> return unless @_lastLoading? @_lastLoading.find('.loading-screen').remove() - @_lastLoading.find('>').removeClass('hide') + @_lastLoading.find('>').show() @_lastLoading = null # Loading ModalViews enableModalInProgress: (modal) -> - $('> div', modal).addClass('hide') - $('.wait', modal).removeClass('hide') + $('> div', modal).hide() + $('.wait', modal).show() disableModalInProgress: (modal) -> - $('> div', modal).removeClass('hide') - $('.wait', modal).addClass('hide') + $('> div', modal).show() + $('.wait', modal).hide() # Subscriptions diff --git a/app/views/play/level/goals_view.coffee b/app/views/play/level/goals_view.coffee index 6c2ce9dc1..44e82d655 100644 --- a/app/views/play/level/goals_view.coffee +++ b/app/views/play/level/goals_view.coffee @@ -46,11 +46,11 @@ module.exports = class GoalsView extends View li.prepend($('').addClass(stateIconMap[state.status])) list.append(li) goals.push goal - if goals.length then @$el.removeClass('hide') else @$el.addClass('hide') + @$el.toggle goals.length > 0 render: -> super() @$el.addClass('hide').addClass('expanded') onSetLetterbox: (e) -> - if e.on then @$el.hide() else @$el.show() + @$el.toggle not e.on diff --git a/app/views/play/level/gold_view.coffee b/app/views/play/level/gold_view.coffee index f552db431..e5fcaf03e 100644 --- a/app/views/play/level/gold_view.coffee +++ b/app/views/play/level/gold_view.coffee @@ -19,4 +19,4 @@ module.exports = class GoldView extends View goldEl.text(e.gold) onSetLetterbox: (e) -> - if e.on then @$el.hide() else @$el.show() + @$el.toggle not e.on diff --git a/app/views/play/level/hud_view.coffee b/app/views/play/level/hud_view.coffee index e12903c72..a3282beb4 100644 --- a/app/views/play/level/hud_view.coffee +++ b/app/views/play/level/hud_view.coffee @@ -153,7 +153,7 @@ module.exports = class HUDView extends View @bubble.removeClass(@lastMood) if @lastMood @lastMood = mood @bubble.text('') - group = $('
') + group = $('
') @bubble.append(group) if responses @lastResponses = responses @@ -176,7 +176,7 @@ module.exports = class HUDView extends View if @animator.done() clearInterval(@messageInterval) @messageInterval = null - $('.enter', @bubble).removeClass("hide").css('opacity', 0.0).delay(500).animate({opacity:1.0}, 500, @animateEnterButton) + $('.enter', @bubble).removeClass("secret").css('opacity', 0.0).delay(500).animate({opacity:1.0}, 500, @animateEnterButton) if @lastResponses buttons = $('.enter button') for response, i in @lastResponses @@ -207,10 +207,10 @@ module.exports = class HUDView extends View switchToDialogueElements: -> @dialogueMode = true - $('.thang-elem', @$el).addClass('hide') - @$el.find('.thang-canvas-wrapper').removeClass('hide') + $('.thang-elem', @$el).addClass('secret') + @$el.find('.thang-canvas-wrapper').removeClass('secret') $('.dialogue-area', @$el) - .removeClass('hide') + .removeClass('secret') .animate({opacity:1.0}, 200) $('.dialogue-bubble', @$el) .css('opacity', 0.0) @@ -220,8 +220,8 @@ module.exports = class HUDView extends View switchToThangElements: -> @dialogueMode = false - $('.thang-elem', @$el).removeClass('hide') - $('.dialogue-area', @$el).addClass('hide') + $('.thang-elem', @$el).removeClass('secret') + $('.dialogue-area', @$el).addClass('secret') update: -> return unless @thang and not @speaker @@ -321,7 +321,7 @@ module.exports = class HUDView extends View changed = true break return unless changed - ael.toggleClass 'hidden', not timespans.length + ael.toggleClass 'secret', not timespans.length @lastActionTimespans[action] = timespans timeline = ael.find('.action-timeline .timeline-wrapper').empty() lifespan = @thang.world.totalFrames / @thang.world.frameRate diff --git a/app/views/play/level/level_chat_view.coffee b/app/views/play/level/level_chat_view.coffee index 2412f7d84..d3ca03a90 100644 --- a/app/views/play/level/level_chat_view.coffee +++ b/app/views/play/level/level_chat_view.coffee @@ -27,10 +27,7 @@ module.exports = class LevelChatView extends View updateMultiplayerVisibility: -> return unless @$el? - if @session.get('multiplayer') - @$el.removeClass('hide') - else - @$el.addClass('hide') + @$el.toggle Boolean @session.get('multiplayer') afterRender: -> @chatTables = $('table', @$el) @@ -48,7 +45,7 @@ module.exports = class LevelChatView extends View row.fadeOut(1000, -> $(this).remove()) onNewMessage: (e) -> - @$el.removeClass('hide') unless e.message.system + @$el.show() unless e.message.system @addOne(e.message) @trimClosedPanel() @playNoise() if e.message.authorID isnt me.id @@ -108,16 +105,10 @@ module.exports = class LevelChatView extends View return false onIconClick: -> - openPanel = $('.open-chat-area', @$el) - closedPanel = $('.closed-chat-area', @$el) @open = not @open - if @open - closedPanel.addClass('hide') - openPanel.removeClass('hide') - @scrollDown() - else - openPanel.addClass('hide') - closedPanel.removeClass('hide') + openPanel = $('.open-chat-area', @$el).toggle @open + closedPanel = $('.closed-chat-area', @$el).toggle not @open + @scrollDown() if @open if window.getSelection? sel = window.getSelection() sel.empty?() @@ -134,4 +125,4 @@ module.exports = class LevelChatView extends View key.deleteScope('level') @session.off 'change:multiplayer', @updateMultiplayerVisibility, @ clearInterval @clearOldMessagesInterval if @clearOldMessagesInterval - @clearOldMessages = null \ No newline at end of file + @clearOldMessages = null diff --git a/app/views/play/level/modal/multiplayer_modal.coffee b/app/views/play/level/modal/multiplayer_modal.coffee index 1006c44ee..80ec95ad1 100644 --- a/app/views/play/level/modal/multiplayer_modal.coffee +++ b/app/views/play/level/modal/multiplayer_modal.coffee @@ -35,7 +35,7 @@ module.exports = class MultiplayerModal extends View updateLinkSection: -> multiplayer = @$el.find('#multiplayer').prop('checked') la = @$el.find('#link-area') - if multiplayer then la.show() else la.hide() + la.toggle Boolean(multiplayer) true onHidden: -> @@ -44,4 +44,4 @@ module.exports = class MultiplayerModal extends View destroy: -> super() - @session.off 'change:multiplayer', @updateLinkSection, @ \ No newline at end of file + @session.off 'change:multiplayer', @updateLinkSection, @ diff --git a/app/views/play/level/playback_view.coffee b/app/views/play/level/playback_view.coffee index a10363fbf..7053cc010 100644 --- a/app/views/play/level/playback_view.coffee +++ b/app/views/play/level/playback_view.coffee @@ -55,8 +55,8 @@ module.exports = class PlaybackView extends View @$el.find('#music-button').toggleClass('music-on', me.get('music')) onSetLetterbox: (e) -> - button = @$el.find '#play-button, .scrubber-handle' - if e.on then button.css('visibility', 'hidden') else button.css('visibility', 'visible') + buttons = @$el.find '#play-button, .scrubber-handle' + buttons.css 'visibility', if e.on then 'hidden' else 'visible' @disabled = e.on onWindowResize: (s...) => @@ -64,17 +64,17 @@ module.exports = class PlaybackView extends View onNewWorld: (e) -> pct = parseInt(100 * e.world.totalFrames / e.world.maxTotalFrames) + '%' - @barWidth = $('.progress', @$el).css('width', pct).removeClass('hide').width() + @barWidth = $('.progress', @$el).css('width', pct).show().width() onToggleDebug: -> return if @shouldIgnore() flag = $('#debug-toggle i.icon-ok') - Backbone.Mediator.publish('level-set-debug', {debug: flag.hasClass('hide')}) + Backbone.Mediator.publish('level-set-debug', {debug: flag.hasClass('invisible')}) onToggleGrid: -> return if @shouldIgnore() flag = $('#grid-toggle i.icon-ok') - Backbone.Mediator.publish('level-set-grid', {grid: flag.hasClass('hide')}) + Backbone.Mediator.publish('level-set-grid', {grid: flag.hasClass('invisible')}) onEditWizardSettings: -> Backbone.Mediator.publish 'edit-wizard-settings' @@ -145,13 +145,11 @@ module.exports = class PlaybackView extends View onSetDebug: (e) -> flag = $('#debug-toggle i.icon-ok') - flag.removeClass('hide') - flag.addClass('hide') unless e.debug + flag.toggleClass 'invisible', not e.debug onSetGrid: (e) -> flag = $('#grid-toggle i.icon-ok') - flag.removeClass('hide') - flag.addClass('hide') unless e.grid + flag.toggleClass 'invisible', not e.grid # to refactor diff --git a/app/views/play/level/tome/spell_palette_entry_view.coffee b/app/views/play/level/tome/spell_palette_entry_view.coffee index 381dd12e0..4f26afc17 100644 --- a/app/views/play/level/tome/spell_palette_entry_view.coffee +++ b/app/views/play/level/tome/spell_palette_entry_view.coffee @@ -64,7 +64,7 @@ module.exports = class SpellPaletteEntryView extends View content.replace /\#\{(.*?)\}/g, (s, properties) => @formatValue downTheChain(owner, properties.split('.')) formatValue: (v) -> - return '' if @doc.type is 'function' + return '[Function]' if not v and @doc.type is 'function' unless v? if @doc.owner is 'this' v = @thang[@doc.name] diff --git a/app/views/play/level_view.coffee b/app/views/play/level_view.coffee index 67433cca9..80031b796 100644 --- a/app/views/play/level_view.coffee +++ b/app/views/play/level_view.coffee @@ -117,6 +117,7 @@ module.exports = class PlayLevelView extends View window.onPlayLevelViewLoaded? @ # still a hack @loadingScreen = new LoadingScreen(@$el.find('canvas')[0]) @loadingScreen.show() + @$el.find('#level-done-button').hide() super() onLevelLoaderLoaded: => @@ -197,7 +198,6 @@ module.exports = class PlayLevelView extends View onDonePressed: -> @showVictory() onShowVictory: (e) -> - console.log 'show vict', e $('#level-done-button').show() @showVictory() if e.showModal setTimeout(@preloadNextLevel, 3000)