VulpesOS/gaia/distros/spark/apps/customizer/js/controllers/edit.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

81 lines
No EOL
2.1 KiB
JavaScript
Executable file

define(["exports"], function (exports) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var EditController = (function (Controller) {
var EditController = function EditController(options) {
Controller.call(this, options);
};
_extends(EditController, Controller);
EditController.prototype.teardown = function () {
this.view = null;
this.target = null;
this.changes = null;
};
EditController.prototype.open = function (target) {
this.target = target;
this.changes = {};
this.view.setTarget(target);
this.view.open();
};
EditController.prototype.close = function () {
if (this.changes.innerHTML || this.changes.script || this.changes.createAttributes || this.changes.removeAttributes || this.changes.properties) {
if (window.confirm("Are you sure you want to discard your changes?")) {
this.view.close();
}
} else {
this.view.close();
}
};
EditController.prototype.save = function () {
var _this = this;
AddonService.generate(this.target, function (generator) {
if (_this.changes.innerHTML) {
generator.opInnerHTML(_this.changes.innerHTML);
}
if (_this.changes.script) {
generator.opScript(_this.changes.script);
}
if (_this.changes.createAttributes) {
generator.opCreateAttributes(_this.changes.createAttributes);
}
if (_this.changes.removeAttributes) {
generator.opRemoveAttributes(_this.changes.removeAttributes);
}
if (_this.changes.properties) {
generator.opSetProperties(_this.changes.properties);
}
_this.changes = {};
_this.close();
});
};
return EditController;
})(Controller);
exports["default"] = EditController;
});