labelWidget: function(tag, klass) {
return $('<span>')
.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) {
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;
<select class="rng-module-documentToolbar-toolbarOption" data-option="newTag-tag">
<% var options = ['', 'section', 'header', 'div', 'span', 'aside']; %>
<% options.forEach(function(option) { %>
- <option value="<%= option %>" <% if(option==='span') { %>selected<% } %>><%= tagNames[option] %></option>
+ <option value="<%= option %>" <% if(option==='span') { %>selected<% } %>><%= wlxmlUtils.getTagLabel(option) %></option>
<% }); %>
</select>
<select class="rng-module-documentToolbar-toolbarOption" data-option="newTag-class">
<% var options = ['', 'author', 'title', 'cite', 'cite.code', 'cite.code.xml', 'list.items', 'item', 'uri', 'p', 'footnote', 'todo', 'emp'] %>
<% options.forEach(function(option) { %>
- <option value="<%= option.replace(/\./g, '-') %>" <% if(option==='cite') { %>selected<% } %>><%= classNames[option] %></option>
+ <option value="<%= option.replace(/\./g, '-') %>" <% if(option==='cite') { %>selected<% } %>><%= wlxmlUtils.getClassLabel(option) %></option>
<% }); %>
</select>
<button data-name="new-node" data-btn-type="cmd" class="btn btn-mini"><i class="icon-plus"></i></button>
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]);
<ul class="breadcrumb">
<% if(node && parents) { %>
<% for(var i = parents.length - 1; i >= 0; i--) { %>
- <li><a href="#"> <%= tagNames[parents[i].getTagName()] %><% if(parents[i].getClass()) { %>.<%= classNames[parents[i].getClass()] %> <% } %></a><span class="divider">/</span></li>
+ <li><a href="#"> <%= utils.getTagLabel(parents[i].getTagName()) %><% if(parents[i].getClass()) { %>.<%= utils.getClassLabel(parents[i].getClass()) %> <% } %></a><span class="divider">/</span></li>
<% } %>
- <li class="active"><%= tagNames[node.getTagName()] %><% if(node.getClass()) { %>.<%= classNames[node.getClass()] %> <% } %></span></li>
+ <li class="active"><%= utils.getTagLabel(node.getTagName()) %><% if(node.getClass()) { %>.<%= utils.getClassLabel(node.getClass()) %> <% } %></span></li>
<% } %>
</ul>
</div>
\ No newline at end of file
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()) : '')
};
}
} 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);
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) {
<select class="rng-module-nodePane-tagSelect">
<% var options = ['', 'section', 'header', 'div', 'span', 'aside']; %>
<% options.forEach(function(option) { %>
- <option value="<%= option %>" <% if(option === '') { %>selected<% } %>><%= tagNames[option] %></option>
+ <option value="<%= option %>" <% if(option === '') { %>selected<% } %>><%= utils.getTagLabel(option) %></option>
<% }); %>
</select>
</div>
<select class="rng-module-nodePane-classSelect">
<% var options = ['', 'author', 'title', 'cite', 'cite.code', 'cite.code.xml', 'list.items', 'list.items.enum', 'item', 'uri', 'p', 'footnote', 'todo', 'emp'] %>
<% options.forEach(function(option) { %>
- <option value="<%= option.replace(/\./g, '-') %>" <% if(option === '') { %>selected<% } %>><%= classNames[option] %></option>
+ <option value="<%= option.replace(/\./g, '-') %>" <% if(option === '') { %>selected<% } %>><%= utils.getClassLabel(option) %></option>
<% }); %>
</select>
</div>
-return {
- wlxmlTagNames: {
- '': '',
+var names = {
+ tag: {
+ '': '-',
section: 'sekcja',
header: 'nagłówek',
div: 'blok',
span: 'tekst',
aside: 'poboczny'
},
- wlxmlClassNames: {
- '': '',
+ 'class': {
+ '': '-',
author: 'autor',
title: 'tytuł',
cite: 'cytat',
}
};
+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