This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
settings_dialog.js
52 lines (40 loc) · 1.73 KB
/
settings_dialog.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define, brackets, $, window, CSSLint, Mustache */
define(function (require, exports, module) {
'use strict';
var PreferencesManager = brackets.getModule("preferences/PreferencesManager");
var settingsTemplate = require("text!templates/settings-template.html");
var prefs = PreferencesManager.getExtensionPrefs("robotframework");
function setFormValues(prefs) {
$("#run-command").val(prefs.get("run-command"));
$("#rflint-command").val(prefs.get("rflint-command"));
$("#rfhub-url").val(prefs.get("hub-url"));
}
function showSettingsDialog() {
var form_data = {
"run-command": prefs.get("run-command"),
"rflint-command": prefs.get("rflint-command")
}
var Dialogs = brackets.getModule("widgets/Dialogs");
var template = Mustache.render(settingsTemplate, form_data);
var dialog = Dialogs.showModalDialogUsingTemplate(template);
$("button[data-button-id='defaults']").on("click", function (e) {
e.stopPropagation();
setFormValues(prefs);
});
setFormValues(prefs);
dialog.done(function (buttonId) {
if (buttonId === "ok") {
var $dialog = dialog.getElement();
var run_command = $("#run-command", $dialog).val();
var rflint_command = $("#rflint-command", $dialog).val();
var rfhub_url = $("#rfhub-url", $dialog).val();
prefs.set("run-command", run_command);
prefs.set("rflint-command", rflint_command);
prefs.set("hub-url", rfhub_url);
prefs.save();
}
})
}
exports.showSettingsDialog = showSettingsDialog;
});