From: Aleksander Łukasz Date: Fri, 13 Dec 2013 15:02:26 +0000 (+0100) Subject: editor: fallback to original tag/class name in case of lack of defined human friendly... X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/2eac26a1b1fc8995dcebeba22f6991ef3542a886 editor: fallback to original tag/class name in case of lack of defined human friendly label --- diff --git a/src/editor/modules/documentCanvas/canvas/widgets.js b/src/editor/modules/documentCanvas/canvas/widgets.js index 408d2c0..77dd0fd 100644 --- a/src/editor/modules/documentCanvas/canvas/widgets.js +++ b/src/editor/modules/documentCanvas/canvas/widgets.js @@ -9,7 +9,7 @@ return { labelWidget: function(tag, klass) { return $('') .addClass('canvas-widget canvas-widget-label') - .text(wlxmlUtils.wlxmlTagNames[tag] + (klass ? ' / ' + wlxmlUtils.wlxmlClassNames[klass] : '')); + .text(wlxmlUtils.getTagLabel(tag) + (klass ? ' / ' + wlxmlUtils.getClassLabel(klass) : '')); }, footnoteHandler: function(clickHandler) { diff --git a/src/editor/modules/documentToolbar/documentToolbar.js b/src/editor/modules/documentToolbar/documentToolbar.js index 84361ad..6c58555 100644 --- a/src/editor/modules/documentToolbar/documentToolbar.js +++ b/src/editor/modules/documentToolbar/documentToolbar.js @@ -9,7 +9,7 @@ return function(sandbox) { currentNode; var view = { - node: $(_.template(template)({tagNames: wlxmlUtils.wlxmlTagNames, classNames: wlxmlUtils.wlxmlClassNames, templates: documentTemplates})), + node: $(_.template(template)({wlxmlUtils: wlxmlUtils, templates: documentTemplates})), setup: function() { var view = this; diff --git a/src/editor/modules/documentToolbar/template.html b/src/editor/modules/documentToolbar/template.html index 17eecde..7c01fb1 100644 --- a/src/editor/modules/documentToolbar/template.html +++ b/src/editor/modules/documentToolbar/template.html @@ -7,13 +7,13 @@ diff --git a/src/editor/modules/nodeBreadCrumbs/nodeBreadCrumbs.js b/src/editor/modules/nodeBreadCrumbs/nodeBreadCrumbs.js index 00c6197..55f4fab 100644 --- a/src/editor/modules/nodeBreadCrumbs/nodeBreadCrumbs.js +++ b/src/editor/modules/nodeBreadCrumbs/nodeBreadCrumbs.js @@ -32,7 +32,7 @@ return function(sandbox) { this.dom.empty(); this.currentNodeElement = nodeElement; var parents = nodeElement.parents(); - this.dom.html(template({node: nodeElement, parents: parents, tagNames: wlxmlUtils.wlxmlTagNames, classNames: wlxmlUtils.wlxmlClassNames})); + this.dom.html(template({node: nodeElement, parents: parents, utils: wlxmlUtils})); this.dom.find('li > a[href="#"]').each(function(idx, a) { $(a).data('element', parents[parents.length - 1 - idx]); diff --git a/src/editor/modules/nodeBreadCrumbs/template.html b/src/editor/modules/nodeBreadCrumbs/template.html index 781ef5c..2f96b2d 100644 --- a/src/editor/modules/nodeBreadCrumbs/template.html +++ b/src/editor/modules/nodeBreadCrumbs/template.html @@ -2,9 +2,9 @@ \ No newline at end of file diff --git a/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js b/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js index d6a6290..e2a4eb8 100644 --- a/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js +++ b/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js @@ -65,7 +65,7 @@ return function(sandbox) { items.push(nodeElementParent); parent = { id: items.length - 1, - repr: wlxmlUtils.wlxmlTagNames[nodeElementParent.getTagName()] + (nodeElementParent.getClass() ? ' / ' + wlxmlUtils.wlxmlClassNames[nodeElementParent.getClass()] : '') + repr: wlxmlUtils.getTagLabel(nodeElementParent.getTagName()) + (nodeElementParent.getClass() ? ' / ' + wlxmlUtils.getClassLabel(nodeElementParent.getClass()) : '') }; } @@ -91,7 +91,7 @@ return function(sandbox) { } else { contents.push({ id: items.length, - repr: wlxmlUtils.wlxmlTagNames[child.getTagName()] + (child.getClass() ? ' / ' + wlxmlUtils.wlxmlClassNames[child.getClass()] : '') + repr: wlxmlUtils.getTagLabel(child.getTagName()) + (child.getClass() ? ' / ' + wlxmlUtils.getClassLabel(child.getClass()) : '') }); } items.push(child); diff --git a/src/editor/modules/nodePane/nodePane.js b/src/editor/modules/nodePane/nodePane.js index 80d4b87..b4b3424 100644 --- a/src/editor/modules/nodePane/nodePane.js +++ b/src/editor/modules/nodePane/nodePane.js @@ -10,7 +10,7 @@ define([ return function(sandbox) { - var view = $(_.template(templateSrc)({tagNames: wlxmlUtils.wlxmlTagNames, classNames: wlxmlUtils.wlxmlClassNames})), + var view = $(_.template(templateSrc)({utils: wlxmlUtils})), currentNode; view.on('change', 'select', function(e) { diff --git a/src/editor/modules/nodePane/template.html b/src/editor/modules/nodePane/template.html index b9a1254..f2977db 100644 --- a/src/editor/modules/nodePane/template.html +++ b/src/editor/modules/nodePane/template.html @@ -6,7 +6,7 @@ @@ -15,7 +15,7 @@ diff --git a/src/editor/utils/wlxml.js b/src/editor/utils/wlxml.js index 5f1b84d..9935655 100644 --- a/src/editor/utils/wlxml.js +++ b/src/editor/utils/wlxml.js @@ -6,17 +6,17 @@ define([ -return { - wlxmlTagNames: { - '': '', +var names = { + tag: { + '': '-', section: 'sekcja', header: 'nagłówek', div: 'blok', span: 'tekst', aside: 'poboczny' }, - wlxmlClassNames: { - '': '', + 'class': { + '': '-', author: 'autor', title: 'tytuł', cite: 'cytat', @@ -33,4 +33,16 @@ return { } }; +return { + getLabel: function(of, name) { + return (names[of] && (names[of][name] || name)) || '?'; + }, + getTagLabel: function(tagName) { + return this.getLabel('tag', tagName); + }, + getClassLabel: function(className) { + return this.getLabel('class', className); + } +}; + }); \ No newline at end of file