2017-10-27 01:00:52 +08:00
|
|
|
(function() {
|
2018-10-18 01:50:25 +08:00
|
|
|
$.getScript("lib/file_saver.js");
|
2019-01-09 22:54:35 +08:00
|
|
|
$.getScript('https://rawgit.com/nodeca/pako/master/dist/pako.js', function() {
|
|
|
|
window.zlib = pako
|
|
|
|
})
|
2017-10-27 01:00:52 +08:00
|
|
|
})()
|
|
|
|
|
2018-10-18 01:50:25 +08:00
|
|
|
$(document).ready(function() {
|
2019-07-18 00:02:07 +08:00
|
|
|
|
|
|
|
$(document.body).on('click', 'a[href]', (event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
window.open(event.target.href, '_blank');
|
2018-10-18 01:50:25 +08:00
|
|
|
});
|
2019-07-18 00:02:07 +08:00
|
|
|
if (!Blockbench.isMobile) {
|
|
|
|
$('#web_download_button').show()
|
2017-10-27 01:00:52 +08:00
|
|
|
}
|
2019-07-18 00:02:07 +08:00
|
|
|
if (location.hash.substr(1, 8) == 'session=') {
|
|
|
|
EditSession.dialog()
|
|
|
|
$('#edit_session_token').val(location.hash.substr(9))
|
2018-12-27 21:03:04 +08:00
|
|
|
}
|
2019-07-18 00:02:07 +08:00
|
|
|
|
|
|
|
})
|
|
|
|
setInterval(function() {
|
|
|
|
Prop.zoom = Math.round(devicePixelRatio*100)
|
|
|
|
}, 500)
|
2017-10-27 01:00:52 +08:00
|
|
|
|
|
|
|
//Misc
|
|
|
|
window.onbeforeunload = function() {
|
2018-03-29 02:48:11 +08:00
|
|
|
if (Prop.project_saved === false && elements.length > 0) {
|
2019-07-18 00:02:07 +08:00
|
|
|
return 'Unsaved Changes';
|
2019-04-13 04:39:53 +08:00
|
|
|
} else {
|
|
|
|
EditSession.quit()
|
2017-10-27 01:00:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
function showSaveDialog(close) {
|
2018-10-18 01:50:25 +08:00
|
|
|
var unsaved_textures = 0;
|
|
|
|
textures.forEach(function(t) {
|
|
|
|
if (!t.saved) {
|
|
|
|
unsaved_textures++;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if ((Prop.project_saved === false && elements.length > 0) || unsaved_textures) {
|
|
|
|
|
|
|
|
var answer = confirm(tl('message.close_warning.web'))
|
|
|
|
if (answer == true) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
2019-07-18 00:02:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BARS.defineActions(function() {
|
|
|
|
if (Blockbench.isMobile) {
|
|
|
|
new Action({
|
|
|
|
id: 'sidebar_left',
|
|
|
|
icon: 'burst_mode',
|
|
|
|
category: 'view',
|
|
|
|
condition: () => !Modes.start,
|
|
|
|
click: function () {
|
|
|
|
$('#page_wrapper').removeClass('show_right')
|
|
|
|
$('#page_wrapper').toggleClass('show_left')
|
|
|
|
var s = $('#page_wrapper').hasClass('show_left')
|
|
|
|
this.nodes.forEach(n => {
|
|
|
|
$(n).toggleClass('sel', s)
|
|
|
|
})
|
|
|
|
BarItems.sidebar_right.nodes.forEach(n => {
|
|
|
|
$(n).removeClass('sel')
|
|
|
|
})
|
|
|
|
updateInterfacePanels()
|
2019-07-19 23:31:22 +08:00
|
|
|
resizeWindow()
|
2019-07-18 00:02:07 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
new Action({
|
|
|
|
id: 'sidebar_right',
|
|
|
|
icon: 'view_list',
|
|
|
|
category: 'view',
|
|
|
|
condition: () => !Modes.start,
|
|
|
|
click: function () {
|
|
|
|
$('#page_wrapper').removeClass('show_left')
|
|
|
|
$('#page_wrapper').toggleClass('show_right')
|
|
|
|
var s = $('#page_wrapper').hasClass('show_right')
|
|
|
|
this.nodes.forEach(n => {
|
|
|
|
$(n).toggleClass('sel', s)
|
|
|
|
})
|
|
|
|
BarItems.sidebar_left.nodes.forEach(n => {
|
|
|
|
$(n).removeClass('sel')
|
|
|
|
})
|
|
|
|
updateInterfacePanels()
|
2019-07-19 23:31:22 +08:00
|
|
|
resizeWindow()
|
2019-07-18 00:02:07 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|