From 781f31a4cbcf94207d513bb110968a4d87e2e717 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 10 Oct 2014 00:22:33 +0200 Subject: [PATCH 1/5] Add extra method to i18n service. --- app/coffee/modules/base/i18n.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/coffee/modules/base/i18n.coffee b/app/coffee/modules/base/i18n.coffee index 0a4b34e9..f9584746 100644 --- a/app/coffee/modules/base/i18n.coffee +++ b/app/coffee/modules/base/i18n.coffee @@ -45,6 +45,9 @@ class I18nService extends taiga.Service i18n.init(@.options) @rootscope.t = i18n.t + t: (path, opts) -> + return i18n.t(path, opts) + I18nDirective = ($rootscope, $i18n) -> link = ($scope, $el, $attrs) -> From d145e272f77aca4fce9df0a1025e93e631dd966f Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 10 Oct 2014 00:22:48 +0200 Subject: [PATCH 2/5] Remove useless data/event binding on i18n directive. --- app/coffee/modules/base/i18n.coffee | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/coffee/modules/base/i18n.coffee b/app/coffee/modules/base/i18n.coffee index f9584746..6097cf6b 100644 --- a/app/coffee/modules/base/i18n.coffee +++ b/app/coffee/modules/base/i18n.coffee @@ -53,18 +53,14 @@ I18nDirective = ($rootscope, $i18n) -> link = ($scope, $el, $attrs) -> values = $attrs.tr.split(",") options = $attrs.trOpts or '{}' + opts = $scope.$eval(options) - applyTranslation = -> - opts = $scope.$eval(options) - for v in values - if v.indexOf(":") == -1 - $el.html(_.escape($scope.t(v, opts))) - else - [ns, v] = v.split(":") - $el.attr(ns, _.escape($scope.t(v, opts))) - - bindOnce($scope, "t", applyTranslation) - $scope.$on("i18n:changeLang", applyTranslation) + for v in values + if v.indexOf(":") == -1 + $el.html(_.escape($i18n.t(v, opts))) + else + [ns, v] = v.split(":") + $el.attr(ns, _.escape($i18n.t(v, opts))) return { link: link From bdd773c94518d51bcd7225406fe34e9e5ec8e4ad Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 10 Oct 2014 00:24:43 +0200 Subject: [PATCH 3/5] Remove i18n mock from wisiwyg directive. --- app/coffee/modules/common/wisiwyg.coffee | 81 ++++++++---------------- 1 file changed, 28 insertions(+), 53 deletions(-) diff --git a/app/coffee/modules/common/wisiwyg.coffee b/app/coffee/modules/common/wisiwyg.coffee index 3e39fc0f..de500089 100644 --- a/app/coffee/modules/common/wisiwyg.coffee +++ b/app/coffee/modules/common/wisiwyg.coffee @@ -28,32 +28,7 @@ module = angular.module("taigaCommon") ############################################################################# ## WYSIWYG markitup editor directive ############################################################################# - -# TODO: fix when i18n is implemented -$i18next = { - t: (key) -> - keywords = { - "markdown-editor.heading-1": "First Level Heading", - "markdown-editor.heading-2": "Second Level Heading", - "markdown-editor.heading-3": "Third Level Heading", - "markdown-editor.bold": "Bold", - "markdown-editor.italic": "Italic", - "markdown-editor.strike": "Strike", - "markdown-editor.bulleted-list": "Bulleted List", - "markdown-editor.numeric-list": "Numeric List", - "markdown-editor.picture": "Picture", - "markdown-editor.link": "Link", - "markdown-editor.quotes": "Quotes", - "markdown-editor.code-block": "Code Block / Code", - "markdown-editor.preview": "Preview", - "markdown-editor.help": "Help", - "markdown-editor.placeholder": "Your title here...", - "markdown-editor.link-placeholder": "Your text to link here..." - } - return keywords[key] or key -} - -tgMarkitupDirective = ($rootscope, $rs) -> +tgMarkitupDirective = ($rootscope, $rs, $tr) -> previewTemplate = _.template("""
@@ -175,40 +150,40 @@ tgMarkitupDirective = ($rootscope, $rs) -> markupSet: [ { - name: $i18next.t('markdown-editor.heading-1') + name: $tr.t("markdown-editor.heading-1") key: "1" - placeHolder: $i18next.t('markdown-editor.placeholder') - closeWith: (markItUp) -> markdownTitle(markItUp, '=') + placeHolder: $tr.t("markdown-editor.placeholder") + closeWith: (markItUp) -> markdownTitle(markItUp, "=") }, { - name: $i18next.t('markdown-editor.heading-2') + name: $tr.t("markdown-editor.heading-2") key: "2" - placeHolder: $i18next.t('markdown-editor.placeholder') - closeWith: (markItUp) -> markdownTitle(markItUp, '-') + placeHolder: $tr.t("markdown-editor.placeholder") + closeWith: (markItUp) -> markdownTitle(markItUp, "-") }, { - name: $i18next.t('markdown-editor.heading-3') + name: $tr.t("markdown-editor.heading-3") key: "3" - openWith: '### ' - placeHolder: $i18next.t('markdown-editor.placeholder') + openWith: "### " + placeHolder: $tr.t("markdown-editor.placeholder") }, { separator: '---------------' }, { - name: $i18next.t('markdown-editor.bold') + name: $tr.t("markdown-editor.bold") key: "B" openWith: '**' closeWith: '**' }, { - name: $i18next.t('markdown-editor.italic') + name: $tr.t("markdown-editor.italic") key: "I" openWith: '_' closeWith: '_' }, { - name: $i18next.t('markdown-editor.strike') + name: $tr.t("markdown-editor.strike") key: "S" openWith: '~~' closeWith: '~~' @@ -217,45 +192,45 @@ tgMarkitupDirective = ($rootscope, $rs) -> separator: '---------------' }, { - name: $i18next.t('markdown-editor.bulleted-list') - openWith: '- ' + name: $tr.t("markdown-editor.bulleted-list") + openWith: "- " }, { - name: $i18next.t('markdown-editor.numeric-list') - openWith: (markItUp) -> markItUp.line+'. ' + name: $tr.t("markdown-editor.numeric-list") + openWith: (markItUp) -> markItUp.line+". " }, { separator: '---------------' }, { - name: $i18next.t('markdown-editor.picture') + name: $tr.t("markdown-editor.picture") key: "P" replaceWith: '![[![Alternative text]!]]([![Url:!:http://]!] "[![Title]!]")' }, { - name: $i18next.t('markdown-editor.link') + name: $tr.t("markdown-editor.link") key: "L" openWith: '[' closeWith: ']([![Url:!:http://]!] "[![Title]!]")' - placeHolder: $i18next.t('markdown-editor.link-placeholder') + placeHolder: $tr.t("markdown-editor.link-placeholder") }, { separator: '---------------' }, { - name: $i18next.t('markdown-editor.quotes') - openWith: '> ' + name: $tr.t("markdown-editor.quotes") + openWith: "> " }, { - name: $i18next.t('markdown-editor.code-block') - openWith: '```\n' - closeWith: '\n```' + name: $tr.t("markdown-editor.code-block") + openWith: "```\n" + closeWith: "\n```" }, { separator: '---------------' }, { - name: $i18next.t('markdown-editor.preview') + name: $tr.t("markdown-editor.preview") call: preview className: "preview-icon" }, @@ -263,7 +238,7 @@ tgMarkitupDirective = ($rootscope, $rs) -> # separator: '---------------' # }, # { - # name: $i18next.t('markdown-editor.help') + # name: $tr.t("markdown-editor.help") # call: openHelp # className: "help" # } @@ -291,4 +266,4 @@ tgMarkitupDirective = ($rootscope, $rs) -> return {link:link, require:"ngModel"} -module.directive("tgMarkitup", ["$rootScope", "$tgResources", tgMarkitupDirective]) +module.directive("tgMarkitup", ["$rootScope", "$tgResources", "$tgI18n", tgMarkitupDirective]) From bc3d2ef389b0e6bd12b0060bbb682f8478ce6fc3 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 10 Oct 2014 00:25:05 +0200 Subject: [PATCH 4/5] Normalize usage of quote char to double-quote char on wisiwyg module. --- app/coffee/modules/common/wisiwyg.coffee | 39 ++++++++++++------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/app/coffee/modules/common/wisiwyg.coffee b/app/coffee/modules/common/wisiwyg.coffee index de500089..3abb17b3 100644 --- a/app/coffee/modules/common/wisiwyg.coffee +++ b/app/coffee/modules/common/wisiwyg.coffee @@ -45,7 +45,7 @@ tgMarkitupDirective = ($rootscope, $rs, $tr) -> previewDomNode = $("
", {class: "preview"}) #openHelp = -> - # window.open($rootscope.urls.wikiHelpUrl(), '_blank') + # window.open($rootscope.urls.wikiHelpUrl(), "_blank") closePreviewMode = -> element.parents(".markdown").find(".preview").remove() @@ -72,7 +72,7 @@ tgMarkitupDirective = ($rootscope, $rs, $tr) -> setCaretPosition = (elm, caretPos) -> if elm.createTextRange range = elm.createTextRange() - range.move('character', caretPos) + range.move("character", caretPos) range.select() else if elm.selectionStart @@ -91,8 +91,8 @@ tgMarkitupDirective = ($rootscope, $rs, $tr) -> return currentCaretPosition - removedLineLength + 1 markdownSettings = - nameSpace: 'markdown' - onShiftEnter: {keepDefault:false, openWith:'\n\n'} + nameSpace: "markdown" + onShiftEnter: {keepDefault:false, openWith:"\n\n"} onEnter: keepDefault: false replaceWith: (data) => @@ -168,28 +168,28 @@ tgMarkitupDirective = ($rootscope, $rs, $tr) -> placeHolder: $tr.t("markdown-editor.placeholder") }, { - separator: '---------------' + separator: "---------------" }, { name: $tr.t("markdown-editor.bold") key: "B" - openWith: '**' - closeWith: '**' + openWith: "**" + closeWith: "**" }, { name: $tr.t("markdown-editor.italic") key: "I" - openWith: '_' - closeWith: '_' + openWith: "_" + closeWith: "_" }, { name: $tr.t("markdown-editor.strike") key: "S" - openWith: '~~' - closeWith: '~~' + openWith: "~~" + closeWith: "~~" }, { - separator: '---------------' + separator: "---------------" }, { name: $tr.t("markdown-editor.bulleted-list") @@ -200,7 +200,7 @@ tgMarkitupDirective = ($rootscope, $rs, $tr) -> openWith: (markItUp) -> markItUp.line+". " }, { - separator: '---------------' + separator: "---------------" }, { name: $tr.t("markdown-editor.picture") @@ -210,12 +210,12 @@ tgMarkitupDirective = ($rootscope, $rs, $tr) -> { name: $tr.t("markdown-editor.link") key: "L" - openWith: '[' + openWith: "[" closeWith: ']([![Url:!:http://]!] "[![Title]!]")' placeHolder: $tr.t("markdown-editor.link-placeholder") }, { - separator: '---------------' + separator: "---------------" }, { name: $tr.t("markdown-editor.quotes") @@ -227,7 +227,7 @@ tgMarkitupDirective = ($rootscope, $rs, $tr) -> closeWith: "\n```" }, { - separator: '---------------' + separator: "---------------" }, { name: $tr.t("markdown-editor.preview") @@ -235,7 +235,7 @@ tgMarkitupDirective = ($rootscope, $rs, $tr) -> className: "preview-icon" }, # { - # separator: '---------------' + # separator: "---------------" # }, # { # name: $tr.t("markdown-editor.help") @@ -248,16 +248,15 @@ tgMarkitupDirective = ($rootscope, $rs, $tr) -> $model.$setViewValue(target.val()) markdownTitle = (markItUp, char) -> - heading = '' + heading = "" n = $.trim(markItUp.selection or markItUp.placeHolder).length for i in [0..n-1] heading += char - return '\n'+heading+'\n' + return "\n"+heading+"\n" element.markItUp(markdownSettings) - element.on "keypress", (event) -> $scope.$apply() From 2fd3b5534df5c388941d0c70d2ee32dd78418b7b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 10 Oct 2014 00:25:43 +0200 Subject: [PATCH 5/5] Fix vendor css loading on gulpfile. Bug introduced in gulpfile refactor. --- gulpfile.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.coffee b/gulpfile.coffee index fdbc59e4..a98469fa 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -31,7 +31,7 @@ paths.jade = [ paths.images = paths.app + "images/**/*" paths.svg = paths.app + "svg/**/*" -paths.css = paths.app + "app/styles/vendor/*.css" +paths.css = paths.app + "styles/vendor/*.css" paths.locales = paths.app + "locales/**/*.json" paths.sass = [ paths.app + "styles/**/*.scss"