0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-22 17:27:57 +01:00
doodle3d-client/js/settings/PrinterPanel.js

53 lines
1.5 KiB
JavaScript
Raw Normal View History

2013-12-20 16:31:41 +01:00
/*
* This file is part of the Doodle3D project (http://doodle3d.com).
*
* Copyright (c) 2013, Doodle3D
* This software is licensed under the terms of the GNU GPL v2 or later.
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
*/
// prototype inheritance
// http://robertnyman.com/2008/10/06/javascript-inheritance-how-and-why/
PrinterPanel.prototype = new FormPanel();
2013-12-01 18:38:02 +01:00
function PrinterPanel() {
this.printerType;
// ui elements
var _element;
var _printerSelector;
var _printerSettings;
var _self = this;
2013-12-01 18:38:02 +01:00
this.init = function(wifiboxURL,wifiboxCGIBinURL,panelElement) {
2014-02-04 22:56:58 +01:00
// super call:
_self.constructor.prototype.init.call(_self,wifiboxURL,wifiboxCGIBinURL,panelElement);
2013-12-01 18:38:02 +01:00
_element = panelElement;
2013-12-01 18:38:02 +01:00
_printerSelector = _element.find("#printerType");
_printerSelector.change(_self.printerSelectorChanged);
// we use readForm to get all the settings we need to
// reload after changing printer type
_printerSettings = _self.readForm();
var gcodePanel = _element.find("#gcodePanel");
gcodePanel.coolfieldset({collapsed:true});
2013-12-01 18:38:02 +01:00
}
this.printerSelectorChanged = function(e) {
_self.printerType = _printerSelector.find("option:selected").val();
var settings = {};
settings[_printerSelector.attr("name")] = _self.printerType;
_self.saveSettings(settings,function(validated) {
if(!validated) return;
_self.loadSettings(_printerSettings,function(settings) {
_self.fill(settings);
});
2013-12-01 18:38:02 +01:00
});
}
2013-12-20 16:31:41 +01:00
}