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.
|
|
|
|
*/
|
|
|
|
|
2014-02-04 21:06:25 +01:00
|
|
|
// 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;
|
|
|
|
|
2014-02-04 21:06:25 +01:00
|
|
|
// ui elements
|
|
|
|
var _element;
|
|
|
|
var _printerSelector;
|
|
|
|
var _printerSettings;
|
|
|
|
|
|
|
|
var _self = this;
|
2013-12-01 18:38:02 +01:00
|
|
|
|
2014-02-04 21:06:25 +01:00
|
|
|
this.init = function(wifiboxURL,wifiboxCGIBinURL,panelElement) {
|
2014-02-04 22:56:58 +01:00
|
|
|
|
2014-02-04 21:06:25 +01:00
|
|
|
// super call:
|
|
|
|
_self.constructor.prototype.init.call(_self,wifiboxURL,wifiboxCGIBinURL,panelElement);
|
2013-12-01 18:38:02 +01:00
|
|
|
|
2014-02-04 21:06:25 +01:00
|
|
|
_element = panelElement;
|
2013-12-01 18:38:02 +01:00
|
|
|
|
2014-02-04 21:06:25 +01:00
|
|
|
_printerSelector = _element.find("#printerType");
|
|
|
|
_printerSelector.change(_self.printerSelectorChanged);
|
2013-12-04 13:42:37 +01:00
|
|
|
|
2014-02-04 21:06:25 +01:00
|
|
|
// we use readForm to get all the settings we need to
|
|
|
|
// reload after changing printer type
|
|
|
|
_printerSettings = _self.readForm();
|
|
|
|
|
|
|
|
var gcodePanel = _element.find("#gcodePanel");
|
2013-12-04 13:42:37 +01:00
|
|
|
gcodePanel.coolfieldset({collapsed:true});
|
2013-12-01 18:38:02 +01:00
|
|
|
}
|
|
|
|
this.printerSelectorChanged = function(e) {
|
2014-02-04 21:06:25 +01:00
|
|
|
_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
|
|
|
}
|