preference

This commit is contained in:
Van 2014-11-17 14:15:28 +08:00
parent 05fdf6fb36
commit a470c9869a
7 changed files with 108 additions and 29 deletions

View File

@ -18,18 +18,29 @@
"Password": "admin",
"Workspace": "${GOPATH}",
"Locale": "en_US",
"GoFormat": "gofmt",
"GoFormat": "",
"FontFamily": "Helvetica",
"FontSize": "13px",
"Editor": {
"FontFamily": "Consolas, 'Courier New', monospace",
"FontSize": "13px",
"LineHeight": "17px"
"LineHeight": ""
},
"LatestSessionContent": {
"FileTree": [],
"Files": [],
"CurrentFile": ""
"FileTree": [
"E:\\Work\\go\\src",
"E:\\Work\\go\\src\\code.google.com\\p",
"E:\\Work\\go\\src\\code.google.com\\p\\go.net",
"E:\\Work\\go\\src\\code.google.com\\p\\go.net\\.hg",
"E:\\Work\\go\\src\\code.google.com\\p\\go.net\\.hg\\cache",
"E:\\Work\\go\\src\\github.com",
"E:\\Work\\go\\src\\github.com\\88250",
"E:\\Work\\go\\src\\github.com\\88250\\gohtml"
],
"Files": [
"E:\\Work\\go\\src\\github.com\\88250\\gohtml\\doc.go"
],
"CurrentFile": "E:\\Work\\go\\src\\github.com\\88250\\gohtml\\doc.go"
}
}
]

View File

@ -131,5 +131,6 @@
"font_size": "Font Size",
"line_height": "Line Height",
"go_format": "Go Format",
"locale": "Locale"
"locale": "Locale",
"apply": "Apply"
}

View File

@ -106,3 +106,13 @@
background-color: #FFF;
border: 1px solid #9B9B9B;
}
#dialogPreference {
margin: 10px;
border: 1px solid #A4A4A4;
border-top-width: 0;
}
#dialogPreference .tabs-panel {
padding: 10px;
}

View File

@ -144,6 +144,9 @@
} else {
// 20(footer) + 23(header)
top = parseInt((windowH - dialogH - 43) / 2);
if (top < 0) {
top = 0;
}
left = parseInt((windowW - dialogW) / 2);
}
$dialog.css({
@ -215,12 +218,12 @@
if (positionX > $(window).width() - $(dialog).width()) {
positionX = $(window).width() - $(dialog).width();
}
if (positionY < 0) {
positionY = 0;
}
if (positionY > $(window).height() - $(dialog).height()) {
positionY = $(window).height() - $(dialog).height();
}
if (positionY < 0) {
positionY = 0;
}
dialog.style.left = positionX + "px";
dialog.style.top = positionY + "px";
};

View File

@ -456,21 +456,79 @@ var wide = {
},
_initPreference: function () {
$("#dialogPreference").load('/preference', function () {
$("#dialogPreference input").keyup(function () {
var isChange = false;
$("#dialogPreference input").each(function () {
if ($(this).val() !== $(this).data("value")) {
isChange = true;
}
});
var $okBtn = $("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)");
if (isChange) {
$okBtn.prop("disabled", false);
} else {
$okBtn.prop("disabled", true);
}
});
$("#dialogPreference").dialog({
"modal": true,
"height": 460,
"width": 800,
"title": config.label.perference,
"okText": config.label.apply,
"cancelText": config.label.cancel,
"afterOpen": function () {
var $okBtn = $("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)");
$okBtn.prop("disabled", true);
},
"ok": function () {
var request = newWideRequest();
request.executable = data.executable;
var request = newWideRequest(),
$dialogPreference = $("#dialogPreference"),
$fontFamily = $dialogPreference.find("input[name=fontFamily]"),
$fontSize = $dialogPreference.find("input[name=fontSize]"),
$editorFontFamily = $dialogPreference.find("input[name=editorFontFamily]"),
$editorFontSize = $dialogPreference.find("input[name=editorFontSize]"),
$editorLineHeight = $dialogPreference.find("input[name=editorLineHeight]"),
$goFmt = $dialogPreference.find("input[name=goFmt]"),
$workspace = $dialogPreference.find("input[name=workspace]"),
$password = $dialogPreference.find("input[name=password]"),
$locale = $dialogPreference.find("input[name=locale]");
$.extend(request, {
"fontFamily": $fontFamily.val(),
"fontSize": $fontSize.val(),
"editorFontFamily": $editorFontFamily.val(),
"editorFontSize": $editorFontSize.val(),
"editorLineHeight": $editorLineHeight.val(),
"goFmt": $goFmt.val(),
"workspace": $workspace.val(),
"password": $password.val(),
"locale": $locale.val()
});
$.ajax({
type: 'POST',
url: '/preference',
data: JSON.stringify(request),
success: function (data, textStatus, jqXHR) {
if (!data.succ) {
return false;
}
$fontFamily.data("value", $fontFamily.val());
$fontSize.data("value", $fontSize.val());
$editorFontFamily.data("value", $editorFontFamily.val());
$editorFontSize.data("value", $editorFontSize.val());
$editorLineHeight.data("value", $editorLineHeight.val());
$goFmt.data("value", $goFmt.val());
$workspace.data("value", $workspace.val());
$password.data("value", $password.val());
$locale.data("value", $locale.val());
$("#dialogPreference").dialog("close");
}
});
}

View File

@ -295,7 +295,8 @@
"colon": "{{.i18n.colon}}",
"file": "{{.i18n.file}}",
"uptodate": "{{.i18n.uptodate}}",
"perference": "{{.i18n.perference}}"
"perference": "{{.i18n.perference}}",
"apply": "{{.i18n.apply}}"
},
"channel": {
"editor": '{{.conf.EditorChannel}}',

View File

@ -1,4 +1,3 @@
<font style="color: red;">DEV in progress...</font>
<div class="preference">
<div class="tabs">
<div class="current" data-index="appearence">
@ -18,49 +17,45 @@
<div data-index="appearence">
<label>
{{.i18n.font}}{{.i18n.colon}}
<input value="{{.user.FontFamily}}" name="fontFamily"/>
<input data-value="{{.user.FontFamily}}" value="{{.user.FontFamily}}" name="fontFamily"/>
</label>
<label>
{{.i18n.font_size}}{{.i18n.colon}}
<input value="{{.user.FontSize}}" name="fontSize"/>
</label>
<label>
{{.i18n.line_height}}{{.i18n.colon}}
<input value="{{.user.Editor.LineHeight}}" name="lineHeight"/>
<input data-value="{{.user.FontSize}}" value="{{.user.FontSize}}" name="fontSize"/>
</label>
</div>
<div class="fn-none" data-index="editor">
<label>
{{.i18n.font}}{{.i18n.colon}}
<input value="{{.user.Editor.FontFamily}}" name="editorFontFamily"/>
<input data-value="{{.user.Editor.FontFamily}}" value="{{.user.Editor.FontFamily}}" name="editorFontFamily"/>
</label>
<label>
{{.i18n.font_size}}{{.i18n.colon}}
<input value="{{.user.Editor.FontSize}}" name="editorFontSize"/>
<input data-value="{{.user.Editor.FontSize}}" value="{{.user.Editor.FontSize}}" name="editorFontSize"/>
</label>
<label>
{{.i18n.line_height}}{{.i18n.colon}}
<input data-value="{{.user.Editor.LineHeight}}" value="{{.user.Editor.LineHeight}}" name="lineHeight"/>
</label>
</div>
<div class="fn-none" data-index="gotool">
<label>
{{.i18n.go_format}}{{.i18n.colon}}
<input value="{{.user.GoFormat}}" name="goFormat"/>
<input data-value="{{.user.GoFormat}}" value="{{.user.GoFormat}}" name="goFormat"/>
</label>
</div>
<div class="fn-none" data-index="user">
<label>
{{.i18n.locale}}{{.i18n.colon}}
<input value="{{.user.Locale}}" name="locale"/>
<input data-value="{{.user.Locale}}" value="{{.user.Locale}}" name="locale"/>
</label>
<label>
{{.i18n.workspace}}{{.i18n.colon}}
<input value="{{.user.Workspace}}" name="workspace"/>
</label>
<label>
{{.i18n.username}}{{.i18n.colon}}
<input value="{{.user.Name}}" name="username"/>
<input data-value="{{.user.Workspace}}" value="{{.user.Workspace}}" name="workspace"/>
</label>
<label>
{{.i18n.password}}{{.i18n.colon}}
<input value="{{.user.Password}}" name="password"/>
<input data-value="{{.user.Password}}" value="{{.user.Password}}" name="password"/>
</label>
</div>
</div>