Moved all init functions to a separate file
This commit is contained in:
parent
b5f6366229
commit
a24be0c6f9
|
@ -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
|
|
@ -23,58 +23,7 @@
|
|||
<!-- Studio -->
|
||||
<script type="text/javascript" src="/static/js/studio.js"></script>
|
||||
<script type="text/javascript" src="/static/js/modals.js"></script>
|
||||
<script defer="defer">
|
||||
window.onload = function() {
|
||||
// Initialize Studio
|
||||
if (window.Studio) {
|
||||
mcstudio = window.Studio
|
||||
mcstudio.init('.studio-canvas', 320, 240);
|
||||
window.modalManager.studio = mcstudio
|
||||
}
|
||||
|
||||
// Texture search
|
||||
$('.texture-list .item').hover(function() {
|
||||
$('.texture-name').html($(this).attr('data-name'))
|
||||
})
|
||||
|
||||
$('div.texture-list').on('mouseout', function() {
|
||||
$('.texture-name').html('Mouseover a texture')
|
||||
})
|
||||
|
||||
$('input.texture-search').on('keyup', function(event) {
|
||||
if (event.which == 13 || event.keyCode == 13) {
|
||||
var value = $(this).val()
|
||||
if (value == '') {
|
||||
$('.texture-list .item').removeClass('hide')
|
||||
} else {
|
||||
$('.texture-list .item').addClass('hide')
|
||||
$('.texture-list [data-name*="' + value + '"]').removeClass('hide')
|
||||
}
|
||||
}
|
||||
|
||||
if (event.which == 27 || event.keyCode == 27) {
|
||||
$(this).val('')
|
||||
$('.texture-list .item').removeClass('hide')
|
||||
}
|
||||
})
|
||||
$("select.flatui").selectpicker({style: 'btn-primary', menuStyle: 'dropdown-inverse'});
|
||||
|
||||
$('input[name="cameraType"]').change(function() {
|
||||
mcstudio.onCameraChange($(this).val())
|
||||
})
|
||||
$("select.camera-type").change()
|
||||
|
||||
$('[data-studio="change-texture"]').click(function() {
|
||||
var texture = $(this).attr('data-texture')
|
||||
mcstudio.changeTexture(texture)
|
||||
})
|
||||
|
||||
$('[data-action="toggle"]').click(function() {
|
||||
var target = $(this).attr('data-target')
|
||||
$(target).toggle('fast')
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<script defer="defer" type="text/javascript" src="/static/js/loader.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block header %}
|
||||
|
|
Loading…
Reference in New Issue