diff --git a/src/main/resources/lang_zh_CN.properties b/src/main/resources/lang_zh_CN.properties index c12204b9b..0ce913873 100644 --- a/src/main/resources/lang_zh_CN.properties +++ b/src/main/resources/lang_zh_CN.properties @@ -147,6 +147,6 @@ ADLabel=\u9499\u5976\uff0c\u54c7\u5361\u5361~ postLabel=\u53d1\u5e03 previewLabel=\u9884\u89c8 postGuideLabel= \ No newline at end of file diff --git a/src/main/webapp/css/base.css b/src/main/webapp/css/base.css index d37430237..9d6095e74 100644 --- a/src/main/webapp/css/base.css +++ b/src/main/webapp/css/base.css @@ -605,6 +605,7 @@ button.red:active { display: none; position: absolute; z-index: 100; + box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); } .dialog-title { color: #FFFFFF; @@ -614,27 +615,13 @@ button.red:active { margin-left: 3px; } -.dialog-header-bg { - background-color: #fafafa; - background: linear-gradient(#fafafa, #eaeaea); - background: -ms-linear-gradient(#fafafa, #eaeaea); - background: -o-linear-gradient(#fafafa, #eaeaea); - background: -webkit-linear-gradient(#fafafa, #eaeaea); - filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#fafafa', endColorstr='#eaeaea'); - border-color: #C0C0C0 #D9D9D9 #D9D9D9; - border-radius: 6px 6px 0 0; - border-style: solid; - border-width: 1px 1px 0; - cursor: move; - height: 34px; -} - .dialog-close-icon { background: url("../images/icons.png") no-repeat scroll -4px -96px transparent; cursor: pointer; float: right; height: 18px; - margin-top: 6px; + margin-right: -17px; + margin-top: -8px; padding: 3px; width: 22px; } @@ -645,9 +632,7 @@ button.red:active { .dialog-main { background-color: #FFFFFF; - border: 2px solid #666666; - border-color: #C0C0C0 #D9D9D9 #D9D9D9; - border-top-width: 0; + border: 1px solid #777; padding: 12px; } /* end dialog */ diff --git a/src/main/webapp/js/add-article.js b/src/main/webapp/js/add-article.js index edf7ef3e3..bdb76ebff 100644 --- a/src/main/webapp/js/add-article.js +++ b/src/main/webapp/js/add-article.js @@ -1,154 +1,162 @@ -/* - * Copyright (c) 2012, B3log Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview add-article. - * - * @author Liyuan Li - * @version 1.0.0.8, Mar 5, 2013 - */ - -/** - * @description Add article function. - * @static - */ -var AddArticle = { - - /** - * @description 发布文章 - */ - add: function () { - var isError = false; - if (this.editor.getValue().length < 4 || this.editor.getValue().length > 1048576) { - $("#articleContentTip").addClass("tip-error").text(Label.articleContentErrorLabel); - } else { - isError = true; - $("#articleContentTip").removeClass("tip-error").text(""); - } - - if (Validate.goValidate([{ - "id": "articleTitle", - "type": 256, - "msg": Label.articleTitleErrorLabel - }, { - "id": "articleTags", - "type": "tags", - "msg": Label.articleTagsErrorLabel - }]) && isError) { - var requestJSONObject = { - articleTitle: $("#articleTitle").val().replace(/(^\s*)|(\s*$)/g,""), - articleContent: this.editor.getValue(), - articleTags: $("#articleTags").val().replace(/(^\s*)|(\s*$)/g,""), - syncWithSymphonyClient: $("#syncWithSymphonyClient").prop("checked") - }; - - $.ajax({ - url: "/article", - type: "POST", - cache: false, - data: JSON.stringify(requestJSONObject), - beforeSend: function () { - $(".form button.red").attr("disabled", "disabled").css("opacity", "0.3"); - }, - success: function(result, textStatus){ - $(".form button.red").removeAttr("disabled").css("opacity", "1"); - if (result.sc) { - window.location = "/member/" + Label.userName; - } else { - $("#addArticleTip").addClass("tip-error").text(result.msg).css({ - "border-left": "1px solid #E2A0A0", - "top": "-35px", - "width": "985px" - }); - } - }, - complete: function () { - $(".form button.red").removeAttr("disabled").css("opacity", "1"); - } - }); - } - }, - - /** - * @description 初识化发文页面,回车提交表单 - */ - init: function () { - var it = this; - it.editor = CodeMirror.fromTextArea(document.getElementById("articleContent"), { - mode: 'markdown', - lineNumbers: true, - onKeyEvent: function (editor, event) { - if (it.editor.getValue().replace(/(^\s*)|(\s*$)/g, "") !== "") { - $(".form .green").show(); - } else { - $(".form .green").hide(); - } - - if (event.keyCode === 13 && event.ctrlKey) { - AddArticle.add(); - } - } - }); - - $("#articleTitle, #articleTags").keypress(function (event) { - if (event.keyCode === 13) { - AddArticle.add(); - } - }); - - $("#preview").dialog({ - "modal": true, - "hideFooter": true, - "height": 402 - }); - }, - - /** - * @description 预览文章 - */ - preview: function () { - var it = this; - $.ajax({ - url: "/markdown", - type: "POST", - cache: false, - data: { - markdownText: it.editor.getValue() - }, - success: function(result, textStatus){ - $("#preview").dialog("open"); - $("#preview").html(result.html); - } - }); - }, - - /** - * @description 显示简要语法 - */ - grammar: function () { - var $grammar = $(".grammar"), - $codemirror = $(".CodeMirror"); - if ($codemirror.width() > 900) { - $grammar.show(); - $codemirror.width(770); - } else { - $grammar.hide(); - $codemirror.width(996) - } - - } -}; - +/* + * Copyright (c) 2012, B3log Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @fileoverview add-article. + * + * @author Liyuan Li + * @version 1.0.0.8, Mar 5, 2013 + */ + +/** + * @description Add article function. + * @static + */ +var AddArticle = { + + /** + * @description 发布文章 + * @id [string] 文章 id ,如不为空则表示更新文章否则为添加文章 + */ + add: function (id) { + var isError = false; + if (this.editor.getValue().length < 4 || this.editor.getValue().length > 1048576) { + $("#articleContentTip").addClass("tip-error").text(Label.articleContentErrorLabel); + } else { + isError = true; + $("#articleContentTip").removeClass("tip-error").text(""); + } + + if (Validate.goValidate([{ + "id": "articleTitle", + "type": 256, + "msg": Label.articleTitleErrorLabel + }, { + "id": "articleTags", + "type": "tags", + "msg": Label.articleTagsErrorLabel + }]) && isError) { + var requestJSONObject = { + articleTitle: $("#articleTitle").val().replace(/(^\s*)|(\s*$)/g,""), + articleContent: this.editor.getValue(), + articleTags: $("#articleTags").val().replace(/(^\s*)|(\s*$)/g,""), + syncWithSymphonyClient: $("#syncWithSymphonyClient").prop("checked") + }, + url = "/article", + type = "POST"; + + if (id) { + url = url + "/" + id; + type = "PUT"; + } + + $.ajax({ + url: url, + type: type, + cache: false, + data: JSON.stringify(requestJSONObject), + beforeSend: function () { + $(".form button.red").attr("disabled", "disabled").css("opacity", "0.3"); + }, + success: function(result, textStatus){ + $(".form button.red").removeAttr("disabled").css("opacity", "1"); + if (result.sc) { + window.location = "/member/" + Label.userName; + } else { + $("#addArticleTip").addClass("tip-error").text(result.msg).css({ + "border-left": "1px solid #E2A0A0", + "top": "-35px", + "width": "985px" + }); + } + }, + complete: function () { + $(".form button.red").removeAttr("disabled").css("opacity", "1"); + } + }); + } + }, + + /** + * @description 初识化发文页面,回车提交表单 + */ + init: function () { + var it = this; + it.editor = CodeMirror.fromTextArea(document.getElementById("articleContent"), { + mode: 'markdown', + lineNumbers: true, + onKeyEvent: function (editor, event) { + if (it.editor.getValue().replace(/(^\s*)|(\s*$)/g, "") !== "") { + $(".form .green").show(); + } else { + $(".form .green").hide(); + } + + if (event.keyCode === 13 && event.ctrlKey) { + AddArticle.add(); + } + } + }); + + $("#articleTitle, #articleTags").keypress(function (event) { + if (event.keyCode === 13) { + AddArticle.add(); + } + }); + + $("#preview").dialog({ + "modal": true, + "hideFooter": true, + "height": 402 + }); + }, + + /** + * @description 预览文章 + */ + preview: function () { + var it = this; + $.ajax({ + url: "/markdown", + type: "POST", + cache: false, + data: { + markdownText: it.editor.getValue() + }, + success: function(result, textStatus){ + $("#preview").dialog("open"); + $("#preview").html(result.html); + } + }); + }, + + /** + * @description 显示简要语法 + */ + grammar: function () { + var $grammar = $(".grammar"), + $codemirror = $(".CodeMirror"); + if ($codemirror.width() > 900) { + $grammar.show(); + $codemirror.width(770); + } else { + $grammar.hide(); + $codemirror.width(996) + } + + } +}; + AddArticle.init(); \ No newline at end of file diff --git a/src/main/webapp/skins/classic/home/add-article.ftl b/src/main/webapp/skins/classic/home/add-article.ftl index f594e15be..f9ef00eca 100644 --- a/src/main/webapp/skins/classic/home/add-article.ftl +++ b/src/main/webapp/skins/classic/home/add-article.ftl @@ -1,66 +1,66 @@ -<#include "../macro-head.ftl"> - - - - <@head title="${userName} - ${addArticleLabel}"> - - - - - - - <#include "../header.ftl"> -
-
-
- ${titleLabel} -
- - -
- ${contentLabel} - ${baseGrammarLabel} - ${allGrammarLabel} -
-
- - -
-
- ${markdwonGrammarLabel} -
-
- ${tagLabel} -
- - -
-
-
- - ${syncWithSymphonyClientLabel} -
-
- - -
-
-
-
- ${postGuideLabel} -
-
-
-
- <#include "../footer.ftl"> - - - - - - +<#include "../macro-head.ftl"> + + + + <@head title="${userName} - ${addArticleLabel}"> + + + + + + + <#include "../header.ftl"> +
+
+
+ ${titleLabel} +
+ + +
+ ${contentLabel} + ${baseGrammarLabel} + ${allGrammarLabel} +
+
+ + +
+
+ ${markdwonGrammarLabel} +
+
+ ${tagLabel} +
+ + +
+
+
+ disabled="disabled"<#if article.syncWithSymphonyClient> checked="checked" type="checkbox" id="syncWithSymphonyClient"/> + ${syncWithSymphonyClientLabel} +
+
+ + +
+
+
+
+ ${postGuideLabel} +
+
+
+
+ <#include "../footer.ftl"> + + + + + +