\r
var doc = sandbox.getBootstrappedData().document;\r
var document_id = sandbox.getBootstrappedData().document_id;\r
- var document_version = sandbox.getBootstrappedData().version\r
+ var document_version = sandbox.getBootstrappedData().version;\r
var history = sandbox.getBootstrappedData().history;\r
\r
\r
sandbox.publish('historyItemAdded', data.slice(-1)[0]);\r
},\r
});\r
- }\r
+ };\r
\r
return {\r
start: function() {\r
url: '/' + gettext('editor') + '/' + document_id + '/diff',\r
data: {from: ver1, to: ver2},\r
success: function(data) {\r
- sandbox.publish('diffFetched', {table: data, ver1: ver1, ver2: ver2})\r
+ sandbox.publish('diffFetched', {table: data, ver1: ver1, ver2: ver2});\r
},\r
});\r
},\r
getDocumentVersion: function() {\r
return document_version;\r
}\r
- }\r
+ };\r
};\r
\r
});
\ No newline at end of file
data: {description: view.$el.find('textarea').val()},\r
success: function() { view.actionsDisabled = false; view.close(); },\r
error: function() { view.actionsDisabled = false; view.close(); },\r
- })\r
+ });\r
},\r
close: function(e) {\r
if(e)\r
create: function() {\r
return new DialogView();\r
}\r
- }\r
+ };\r
\r
});
\ No newline at end of file
dom.append(tabsView.getAsView());\r
\r
var DiffView = function() {\r
- this.dom = $(diffTemplateSrc)\r
- }\r
+ this.dom = $(diffTemplateSrc);\r
+ };\r
+ \r
DiffView.prototype.setTable = function(table) {\r
this.dom.append(table);\r
- }\r
+ };\r
\r
\r
return {\r
\r
Canvas.prototype.getNodeById = function(id) {\r
return canvasNode.create($(this.content.find('#' +id)));\r
-}\r
+};\r
\r
Canvas.prototype.nodeAppend = function(options) {\r
var element; // = $(this.content.find('#' + options.context.id).get(0));\r
var newNode = canvasNode.create({tag: nodeToSplit.attr('wlxml-tag'), klass: nodeToSplit.attr('wlxml-class')});\r
newNode.dom.append(suffix);\r
succeedingNodes.forEach(function(node) {\r
- newNode.dom.append(node)\r
+ newNode.dom.append(node);\r
});\r
nodeToSplit.after(newNode.dom);\r
return newNode;\r
\r
Canvas.prototype.getPrecedingNode = function(options) {\r
var element = $(this.content.find('#' + options.node.getId()).get(0));\r
- var prev = element.prev()\r
+ var prev = element.prev();\r
if(prev.length === 0)\r
prev = element.parent();\r
return canvasNode.create(prev);\r
parentNode: parent,\r
focusNode: $(selection.focusNode).parent(),\r
isAtEnd: selection.anchorOffset === anchorNode.text().length\r
- }\r
+ };\r
};\r
\r
var Manager = function(canvas, sandbox) {\r
};\r
canvas.dom.onHide = function() {\r
manager.scrollbarPosition = canvas.dom.find('#rng-module-documentCanvas-contentWrapper').scrollTop();\r
- }\r
+ };\r
};\r
\r
Manager.prototype.selectNode = function(cnode, options) {\r
options = options || {};\r
- var nodeElement = this.getNodeElement(cnode)\r
+ var nodeElement = this.getNodeElement(cnode);\r
\r
this.dimNode(cnode);\r
\r
}\r
\r
\r
-}\r
+};\r
\r
Manager.prototype.getNodeElement = function(cnode) {\r
return this.canvas.dom.find('#'+cnode.getId());\r
}).first();\r
var node;\r
if(firstNodeWithText.length)\r
- node = $(firstNodeWithText[0])\r
+ node = $(firstNodeWithText[0]);\r
else {\r
- node = this.canvas.dom.find('[wlxml-class|="p"]')\r
+ node = this.canvas.dom.find('[wlxml-class|="p"]');\r
}\r
this.selectNode(canvasNode.create(node), {movecaret: true});\r
};\r
collapseArg = false;\r
range.collapse(collapseArg);\r
var selection = document.getSelection();\r
- selection.removeAllRanges()\r
+ selection.removeAllRanges();\r
selection.addRange(range);\r
};\r
\r
this.canvas.nodeRemove({node: toRemove}); // jesli nie ma tekstu, to anchor nie jest tex nodem\r
this.selectNode(prevNode, {movecaret: 'end'});\r
}\r
-}\r
+};\r
\r
Manager.prototype.command = function(command, meta) {\r
var pos = getCursorPosition();\r
}\r
}\r
\r
-}\r
+};\r
\r
\r
return Manager;\r
\r
CanvasNode.prototype.getTag = function() {\r
return this.dom.attr('wlxml-tag');\r
-}\r
+};\r
\r
CanvasNode.prototype.getClass = function() {\r
return this.dom.attr('wlxml-class');\r
-}\r
+};\r
\r
CanvasNode.prototype.getId = function() {\r
return this.dom.attr('id');\r
-}\r
+};\r
\r
CanvasNode.prototype.getContent = function() {\r
return this.dom.text();\r
-}\r
+};\r
\r
CanvasNode.prototype.setContent = function(content) {\r
this.dom.text(content);\r
-}\r
+};\r
\r
CanvasNode.prototype.isSame = function(other) {\r
return (other instanceof CanvasNode) && this.dom.get(0) === other.dom.get(0);\r
-}\r
+};\r
\r
CanvasNode.prototype.children = function() {\r
var list = [];\r
\r
CanvasNode.prototype.isOfClass = function(klass) {\r
return this.getClass() && this.getClass().substr(0, klass.length) === klass;\r
-}\r
+};\r
\r
return {\r
create: function(desc) {\r
return new CanvasNode(desc);\r
}\r
\r
-}\r
+};\r
\r
\r
});
\ No newline at end of file
sandbox.publish('documentSet');\r
},\r
getDocument: function() {\r
- return transformations.toXML.getXML(canvas.getContent())\r
+ return transformations.toXML.getXML(canvas.getContent());\r
},\r
modifyCurrentNode: function(attr, value) {\r
if(manager.currentNode) {\r
command: function(command, meta) {\r
manager.command(command, meta);\r
}\r
- }\r
+ };\r
\r
};\r
\r
var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="header">Header 1</div></div>');\r
var header = c.findNodes({tag: 'header'})[0];\r
var wrapper = canvasNode.create({tag: 'aside'});\r
- c.nodeWrap({inside: header, _with: wrapper, offsetStart: 1, offsetEnd: 6})\r
+ c.nodeWrap({inside: header, _with: wrapper, offsetStart: 1, offsetEnd: 6});\r
assertDomEqual(c.getContent(), '<div wlxml-tag="section"><div wlxml-tag="header">H<span wlxml-tag="aside">eader</span> 1</div></div>');\r
});\r
\r
var c = canvas.create('<div wlxml-tag="header">Alice has a <span wlxml-tag="span">small</span> cat</div>');\r
var header = c.findNodes({tag: 'header'})[0];\r
var wrapper = canvasNode.create({tag: 'aside'});\r
- c.nodeWrap({inside: header, _with: wrapper, offsetStart: 6, offsetEnd: 4, textNodeIdx: [0,2]})\r
+ c.nodeWrap({inside: header, _with: wrapper, offsetStart: 6, offsetEnd: 4, textNodeIdx: [0,2]});\r
assertDomEqual(c.getContent(), '<div wlxml-tag="header">Alice <span wlxml-tag="aside">has a <span wlxml-tag="span">small</span> cat</span></div>'); \r
});\r
\r
rhs.attr('id', '');\r
return assert.ok(lhs[0].isEqualNode(rhs[0]), 'nodes are equal');\r
\r
-}\r
+};\r
\r
suite('Create canvas node', function() { \r
test('from description', function() {\r
rmws(this);\r
});\r
}\r
- }\r
+ };\r
\r
xml = $($.trim(xml));\r
xml.each(function() {\r
rhs.find('*').each(function() {$(this).attr('id', '');});\r
return chai.assert.ok(lhs[0].isEqualNode(rhs[0]), 'nodes are equal');\r
}\r
- }\r
+ };\r
});
\ No newline at end of file
\r
test('open+open', function() {\r
assert.equal(utils.cleanUp('<div class="class"> \n <div class="class"></div></div>'), '<div class="class"><div class="class"></div></div>');\r
-})\r
+});\r
\r
test('close+close', function() {\r
assert.equal(utils.cleanUp('<div><div></div>\n </div>'), '<div><div></div></div>');\r
-})\r
+});\r
\r
test('close+open', function() {\r
assert.equal(utils.cleanUp('<div></div>\n <div class="class"></div>'), '<div></div><div class="class"></div>');\r
-})\r
+});\r
\r
test('bug', function() {\r
var txt = '\\r
<section> \\r
<header class="some.class">Head</header>\\r
<header class="some.class">er 1</header>\\r
- </section>'\r
+ </section>';\r
var txt2 = '<section><header class="some.class">Head</header><header class="some.class">er 1</header></section>';\r
assert.equal(utils.cleanUp(txt), txt2); \r
});\r
for(var i = 0; i < this.attributes.length; i++) {\r
var attr = this.attributes.item(i);\r
var value = attr.name === 'class' ? attr.value.replace(/\./g, '-') : attr.value;\r
- toret.attr('wlxml-' + attr.name, value)\r
+ toret.attr('wlxml-' + attr.name, value);\r
}\r
toret.append(currentTag.contents());\r
return toret;\r
});\r
});\r
- }\r
+ };\r
\r
transform(toBlock, 'div');\r
transform(toInline, 'span');\r
\r
toret.find(":not(iframe)").addBack().contents().filter(function() {\r
- return this.nodeType == 3} ).each(function() {\r
+ return this.nodeType == 3;} ).each(function() {\r
var n = $(this); \r
var hasText = /\S/g.test(n.text());\r
if(!hasText) {\r
$(xml).find('metadata').children().each(function() {\r
var node = $(this);\r
toret[this.nodeName.split(':')[1].toLowerCase()] = node.text();\r
- })\r
+ });\r
return toret;\r
},\r
getDocumentDescription: function(xml) {\r
return {\r
HTMLTree: this.getHTMLTree(xml),\r
metadata: this.getMetaData(xml)\r
- }\r
+ };\r
}\r
- }\r
+ };\r
\r
transformations.toXML = {\r
getXML: function(body) {\r
\r
for(var i = 0; i < this.attributes.length; i++) {\r
var attr = this.attributes.item(i);\r
- var split = attr.name.split('-')\r
+ var split = attr.name.split('-');\r
console.log(split);\r
if(split[0] !== 'wlxml' || (split.length > 1 && split[1] === 'tag')) \r
continue;\r
\r
return vkbeautify.xml(toret.html());\r
}\r
- }\r
+ };\r
\r
return transformations;\r
\r
var dom = $(_.template(mainTemplateSrc)());\r
var domNodes = {\r
itemList: dom.find('.rng-module-documentHistory-itemsList'),\r
- }\r
+ };\r
var itemViews = [];\r
\r
\r
if(options.animate) {\r
view.dom.hide().slideDown();\r
}\r
- }\r
+ };\r
\r
var toggleItemViews = function(toggle) {\r
itemViews.forEach(function(view) {\r
if(!historyItems.isSelected(view.item))\r
view.toggle(toggle);\r
});\r
- }\r
+ };\r
\r
var toggleButton = function(btn, toggle) {\r
dom.find('button.'+btn).toggleClass('disabled', !toggle);\r
- }\r
+ };\r
\r
var historyItems = {\r
_itemsById: {},\r
getView: function() {\r
return dom;\r
}\r
- }\r
-}\r
+ };\r
+};\r
\r
});
\ No newline at end of file
data: {description: view.$el.find('textarea').val()},\r
success: function() { view.actionsDisabled = false; view.close(); },\r
error: function() { view.actionsDisabled = false; view.close(); },\r
- })\r
+ });\r
},\r
close: function(e) {\r
if(e)\r
create: function() {\r
return new DialogView();\r
}\r
- }\r
+ };\r
\r
});
\ No newline at end of file
e.stopPropagation();\r
var btn = $(e.currentTarget);\r
if(btn.attr('data-btn-type') === 'toggle') {\r
- btn.toggleClass('active')\r
+ btn.toggleClass('active');\r
var event;\r
var btnId = btn.attr('data-btn');\r
if(btnId === 'grid')\r
getOption: function(option) {\r
return this.node.find('.rng-module-documentToolbar-toolbarOption[data-option=' + option +']').val();\r
}\r
- }\r
+ };\r
\r
view.setup();\r
\r
start: function() { sandbox.publish('ready'); },\r
getView: function() { return view.node; },\r
getOption: function(option) { return view.getOption(option); }\r
- }\r
-}\r
+ };\r
+};\r
\r
});
\ No newline at end of file
setup: function() {\r
\r
}\r
- }\r
+ };\r
\r
return {\r
start: function() { sandbox.publish('ready'); },\r
}\r
}\r
\r
- }\r
+ };\r
\r
-}\r
+};\r
\r
});\r
view.find('button').click(function(e) {\r
e.preventDefault();\r
sandbox.publish('cmd.' + $(e.target).attr('data-cmd'));\r
- })\r
+ });\r
\r
return {\r
start: function() { sandbox.publish('ready'); },\r
setVersion: function(version) {\r
view.find('.version').text(version);\r
}\r
- }\r
+ };\r
\r
};\r
\r
metaTable.find('.rng-module-metadataEditor-metaItemValue').focus();\r
} else {\r
var input = $('<input>');\r
- input.appendTo('body').focus()\r
+ input.appendTo('body').focus();\r
view.node.find('.rng-module-metadataEditor-addBtn').focus();\r
input.remove();\r
}\r
var onKeyUp = function(e) {\r
if(e.which !== 13)\r
sandbox.publish('metadataChanged', view.getMetadata());\r
- }\r
+ };\r
this.metaTable.on('keyup', '[contenteditable]', _.throttle(onKeyUp, 500));\r
},\r
getMetadata: function() {\r
newRow.appendTo(this.metaTable);\r
return newRow;\r
}\r
- }\r
+ };\r
\r
view.setup();\r
\r
var section = toret.find('section');\r
section = section.length ? $(section[0]) : null;\r
if(section) {\r
- section.prepend(meta)\r
+ section.prepend(meta);\r
}\r
} else {\r
metadata.replaceWith(meta);\r
}\r
\r
};\r
-}\r
+};\r
\r
});
\ No newline at end of file
$(xml).find('metadata').children().each(function() {\r
var node = $(this);\r
toret[this.nodeName.split(':')[1].toLowerCase()] = node.text();\r
- })\r
+ });\r
return toret;\r
},\r
getXML: function(metadata) {\r
meta.append('\n');\r
return vkbeautify.xml(meta.html());\r
}\r
- }\r
+ };\r
\r
});
\ No newline at end of file
dimNode: function(node) {\r
this.dom.find('a[data-id="'+node.id+'"]').removeClass('rng-common-hoveredNode');\r
}\r
- }\r
+ };\r
\r
view.setup();\r
\r
},\r
highlightNode: function(id) { view.highlightNode(id); },\r
dimNode: function(id) { view.dimNode(id); }\r
- }\r
-}\r
+ };\r
+};\r
\r
});
\ No newline at end of file
\r
this.dom.on('mouseenter', 'a', function(e) {\r
var target = $(e.target);\r
- sandbox.publish('nodeEntered', view.nodes[target.attr('data-id')])\r
+ sandbox.publish('nodeEntered', view.nodes[target.attr('data-id')]);\r
});\r
this.dom.on('mouseleave', 'a', function(e) {\r
var target = $(e.target);\r
- sandbox.publish('nodeLeft', view.nodes[target.attr('data-id')])\r
+ sandbox.publish('nodeLeft', view.nodes[target.attr('data-id')]);\r
});\r
},\r
setNode: function(node) {\r
dimNode: function(canvasNode) {\r
this.dom.find('a[data-id="'+canvasNode.getId()+'"]').removeClass('rng-common-hoveredNode');\r
}\r
- }\r
+ };\r
\r
view.setup();\r
\r
view.find('.rng-module-nodePane-tagSelect').val(canvasNode.getTag());\r
view.find('.rng-module-nodePane-classSelect').val(canvasNode.getClass());\r
}\r
- }\r
+ };\r
\r
-}\r
+};\r
\r
});
\ No newline at end of file
}\r
sandbox.getModule('data').commitDocument(doc, reason);\r
}\r
- }\r
+ };\r
\r
var commands = {\r
highlightDocumentNode: function(canvasNode, origin) {\r
['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) {\r
if(!origin || moduleName != origin)\r
- sandbox.getModule(moduleName).highlightNode(canvasNode)\r
+ sandbox.getModule(moduleName).highlightNode(canvasNode);\r
});\r
},\r
dimDocumentNode: function(canvasNode, origin) {\r
['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) {\r
if(!origin || moduleName != origin)\r
- sandbox.getModule(moduleName).dimNode(canvasNode)\r
+ sandbox.getModule(moduleName).dimNode(canvasNode);\r
});\r
},\r
selectNode: function(canvasNode, origin) {\r
sandbox.getModule(moduleName).setDocument(document);\r
});\r
}\r
- }\r
+ };\r
\r
\r
var views = {\r
visualEditingSidebar: (new tabs.View({stacked: true})).render(),\r
currentNodePaneLayout: new vbox.VBox(),\r
diffLayout: new layout.Layout(diffLayoutTemplate)\r
- }\r
+ };\r
\r
views.visualEditing.setView('rightColumn', views.visualEditingSidebar.getAsView());\r
addMainTab('Edytor', 'editor', views.visualEditing.getAsView());\r
sandbox.getModule('indicator').clearMessage({message:'Wersja ' + event.reverted_version + ' przywrócona'});\r
sandbox.getModule('mainBar').setVersion(event.current_version);\r
}\r
- }\r
+ };\r
\r
eventHandlers.mainBar = {\r
ready: function() {\r
synchronizeTab(views.mainTabs.getCurrentSlug());\r
sandbox.getModule('data').saveDocument();\r
}\r
- }\r
+ };\r
\r
eventHandlers.indicator = {\r
ready: function() {\r
nodeSelected: function(canvasNode) {\r
commands.selectNode(canvasNode);\r
} \r
- }\r
+ };\r
\r
eventHandlers.documentHistory = {\r
ready: function() {\r
displayVersion: function(event) {\r
window.open('/' + gettext('editor') + '/' + sandbox.getModule('data').getDocumentId() + '?version=' + event.version, _.uniqueId());\r
}\r
- }\r
+ };\r
\r
eventHandlers.diffViewer = {\r
ready: function() {\r
views.diffLayout.setView('right', sandbox.getModule('diffViewer').getView());\r
}\r
- }\r
+ };\r
\r
/* api */\r
\r
eventHandlers[moduleName][eventName].apply(eventHandlers, args);\r
}\r
}\r
- }\r
+ };\r
};\r
\r
});
\ No newline at end of file
\r
editor.getSession().on('change', function() {\r
sandbox.publish('xmlChanged');\r
- })\r
+ });\r
return {\r
start: function() {\r
sandbox.publish('ready');\r
},\r
setDocument: function(document) {\r
editor.setValue(document);\r
- editor.gotoLine(0)\r
+ editor.gotoLine(0);\r
sandbox.publish('documentSet');\r
},\r
getDocument: function() {\r
return editor.getValue();\r
}\r
- }\r
+ };\r
};\r
\r
});
\ No newline at end of file