From a24be0c6f9ca1daf922fdc50e49050575fd5eb2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Mart=C3=ADn?= Date: Fri, 31 May 2013 11:34:17 +0200 Subject: [PATCH] Moved all init functions to a separate file --- .../studio/static/coffee/loader.coffee | 49 +++++++++++++++++ .../studio/templates/studio/main.html | 53 +------------------ 2 files changed, 50 insertions(+), 52 deletions(-) create mode 100644 minecraftcodex/studio/static/coffee/loader.coffee diff --git a/minecraftcodex/studio/static/coffee/loader.coffee b/minecraftcodex/studio/static/coffee/loader.coffee new file mode 100644 index 0000000..9ebb278 --- /dev/null +++ b/minecraftcodex/studio/static/coffee/loader.coffee @@ -0,0 +1,49 @@ +window.onload = -> + # Studio + if window.Studio + window.Studio.init '.studio-canvas', 320, 240 + window.modalManager.studio = window.Studio + + # Textures + $('.texture-list .item').hover -> + $('.texture-name').html $(@).attr('data-name') + + $('div.texture-list').on 'onmouseout', -> + $('.texture.name').html 'Mouseover a texture' + + $('input.texture-search').on 'keyup', (event) -> + # [enter] -> do search + if event.which == 13 || event.keyCode == 13 + value = $(@).val() + if value == '' + $('.texture-list .item').removeClass 'hide' + else + $('.texture-list .item').addClass 'hide' + $('.texture-list [data-name*="' + value + '"]').removeClass 'hide' + + # [esc] -> cancel search + if event.which == 27 || event.keyCode == 27 + $(@).val '' + $('.texture-list .item').removeClass 'hide' + + # input:select + $('select.flatui').selectpicker + style: 'btn-primary' + menuStyle: 'dropdown-inverse' + + # Camera controls + $(':radio[name="cameraType"]').on 'toggle', -> + camera = $(@).val() + window.Studio.onCameraChange camera + + $(':radio[name="cameraType"]:first').click() + + # Toggles + $('[data-action="toggle"]').click -> + target = $(this).attr 'data-target' + $(target).toggle 'fast' + + # TESTS + $('[data-studio="change-texture"]').click -> + texture = $(this).attr('data-texture') + window.Studio.changeTexture texture diff --git a/minecraftcodex/studio/templates/studio/main.html b/minecraftcodex/studio/templates/studio/main.html index 591669b..515adb1 100644 --- a/minecraftcodex/studio/templates/studio/main.html +++ b/minecraftcodex/studio/templates/studio/main.html @@ -23,58 +23,7 @@ - + {% endblock %} {% block header %}