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", "Password": "admin",
"Workspace": "${GOPATH}", "Workspace": "${GOPATH}",
"Locale": "en_US", "Locale": "en_US",
"GoFormat": "gofmt", "GoFormat": "",
"FontFamily": "Helvetica", "FontFamily": "Helvetica",
"FontSize": "13px", "FontSize": "13px",
"Editor": { "Editor": {
"FontFamily": "Consolas, 'Courier New', monospace", "FontFamily": "Consolas, 'Courier New', monospace",
"FontSize": "13px", "FontSize": "13px",
"LineHeight": "17px" "LineHeight": ""
}, },
"LatestSessionContent": { "LatestSessionContent": {
"FileTree": [], "FileTree": [
"Files": [], "E:\\Work\\go\\src",
"CurrentFile": "" "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", "font_size": "Font Size",
"line_height": "Line Height", "line_height": "Line Height",
"go_format": "Go Format", "go_format": "Go Format",
"locale": "Locale" "locale": "Locale",
"apply": "Apply"
} }

View File

@ -105,4 +105,14 @@
margin-top: 5px; margin-top: 5px;
background-color: #FFF; background-color: #FFF;
border: 1px solid #9B9B9B; 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 { } else {
// 20(footer) + 23(header) // 20(footer) + 23(header)
top = parseInt((windowH - dialogH - 43) / 2); top = parseInt((windowH - dialogH - 43) / 2);
if (top < 0) {
top = 0;
}
left = parseInt((windowW - dialogW) / 2); left = parseInt((windowW - dialogW) / 2);
} }
$dialog.css({ $dialog.css({
@ -215,12 +218,12 @@
if (positionX > $(window).width() - $(dialog).width()) { if (positionX > $(window).width() - $(dialog).width()) {
positionX = $(window).width() - $(dialog).width(); positionX = $(window).width() - $(dialog).width();
} }
if (positionY < 0) {
positionY = 0;
}
if (positionY > $(window).height() - $(dialog).height()) { if (positionY > $(window).height() - $(dialog).height()) {
positionY = $(window).height() - $(dialog).height(); positionY = $(window).height() - $(dialog).height();
} }
if (positionY < 0) {
positionY = 0;
}
dialog.style.left = positionX + "px"; dialog.style.left = positionX + "px";
dialog.style.top = positionY + "px"; dialog.style.top = positionY + "px";
}; };

View File

@ -456,21 +456,79 @@ var wide = {
}, },
_initPreference: function () { _initPreference: function () {
$("#dialogPreference").load('/preference', 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({ $("#dialogPreference").dialog({
"modal": true, "modal": true,
"height": 460, "height": 460,
"width": 800, "width": 800,
"title": config.label.perference, "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 () { "ok": function () {
var request = newWideRequest(); var request = newWideRequest(),
request.executable = data.executable; $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({ $.ajax({
type: 'POST', type: 'POST',
url: '/preference', url: '/preference',
data: JSON.stringify(request), data: JSON.stringify(request),
success: function (data, textStatus, jqXHR) { 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}}", "colon": "{{.i18n.colon}}",
"file": "{{.i18n.file}}", "file": "{{.i18n.file}}",
"uptodate": "{{.i18n.uptodate}}", "uptodate": "{{.i18n.uptodate}}",
"perference": "{{.i18n.perference}}" "perference": "{{.i18n.perference}}",
"apply": "{{.i18n.apply}}"
}, },
"channel": { "channel": {
"editor": '{{.conf.EditorChannel}}', "editor": '{{.conf.EditorChannel}}',

View File

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