Commit 15dc178d authored by Wolfgang's avatar Wolfgang

Remove now unused riot tags

parent d00f5b16
<code-editor>
<pre ref="code" onclick="{ initCodeEditor }" class="{ mode }">{ this.code }</pre>
<script>
this.mixin('utils');
var self = this;
this.code = opts.code;
this.mode = opts.mode;
this.placeholder = opts.placeholder;
this.callback = opts.callback;
this.on('mount', function() {
self.initCodeEditor();
});
initCodeEditor() {
var isVisible = this.root.offsetWidth > 0 && this.root.offsetHeight > 0;
if (this.codemirror || !isVisible) {
return;
}
this.codemirror = CodeMirror(function(elt) {
self.refs.code.style.display = 'none';
self.refs.code.parentNode.appendChild(elt);
}, {
value: self.code,
mode: self.mode,
lineNumbers: false,
lineWrapping: true,
autofocus: false,
theme: "ttcn",
matchBrackets: true,
placeholder: self.placeholder || '[Empty]',
gutters: ["CodeMirror-lint-markers"],
lint: true
});
if (this.callback) {
this.codemirror.on('change', this.callback);
}
}
get() {
if (this.codemirror) {
return this.codemirror.getValue();
}
return this.code;
}
</script>
<style>
:scope {
display: block;
min-height: 1em;
}
</style>
</code-editor>
<edit-source>
<a target="eXide" data-exide-open="{ path }"
href="../eXide/index.html?open={path}" onclick="{ click }"><yield/></a>
<script>
setPath(path) {
this.path = path;
}
click(ev) {
// try to retrieve existing eXide window
var exide = window.open("", "eXide");
if (exide && !exide.closed) {
var snip = this.root.getAttribute('exide-create');
var path = this.path;
// check if eXide is really available or it's an empty page
var app = exide.eXide;
if (app) {
// eXide is there
if (snip) {
exide.eXide.app.newDocument(snip, "xquery");
} else {
console.log("Locating document %s", path);
exide.eXide.app.findDocument(path);
}
exide.focus();
setTimeout(function() {
if (typeof exide.eXide.app.hasFocus == "function" && !exide.eXide.app.hasFocus()) {
alert("Opened code in existing eXide window.");
}
}, 200);
} else {
window.eXide_onload = function() {
console.log("onload called for %s", path);
if (snip) {
exide.eXide.app.newDocument(snip, "xquery");
} else {
exide.eXide.app.findDocument(path);
}
};
// empty page
console.log("Opening %s", ev.target.href.substring(0, ev.target.href.indexOf('?')));
exide.location = ev.target.href.substring(0, ev.target.href.indexOf('?'));
}
ev.preventDefault();
}
return true;
}
</script>
<style>
a:link {
color: inherit;
}
</style>
</edit-source>
This diff is collapsed.
<element-spec ident="{ ident }" mode="{ mode }">
<h3>
<paper-icon-button ref="toggle" icon="expand-more" if="{ models.length > 0 }" onclick="{ toggle }"></paper-icon-button>
{ ident }
<paper-menu-button>
<paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
<paper-listbox slot="dropdown-content">
<paper-item onclick="{ addModel }">model</paper-item>
<paper-item onclick="{ addModel }">modelSequence</paper-item>
<paper-item onclick="{ addModel }">modelGrp</paper-item>
</paper-listbox>
</paper-menu-button>
<paper-icon-button onclick="{ remove }" icon="delete"></paper-icon-button>
<paper-icon-button onclick="{ paste }" icon="content-paste"></paper-icon-button>
</h3>
<iron-collapse ref="models" class="models" opened="{show}" id="elem-{ ident }">
<model each="{ models }" behaviour="{ this.behaviour }" predicate="{ this.predicate }"
type="{ this.type }" output="{ this.output }" css="{ this.css }" models="{ this.models }"
parameters="{ this.parameters }" desc="{ this.desc }"
sourcerend="{ this.sourcerend }"/>
</iron-collapse>
<script>
this.mixin('utils');
this.on("mount", function() {
var self = this;
this.refs.models.addEventListener("opened-changed", function() {
var opened = this.refs.models.opened;
var icon = opened ? 'expand-less' : 'expand-more';
if (this.refs.toggle) {
this.refs.toggle.icon = icon;
}
if (opened) {
this.parent.collapseAll(this);
} else {
this.models = this.updateTag('model');
}
}.bind(this));
});
toggle(ev) {
this.refs.models.toggle();
}
collapse() {
this.refs.models.hide();
}
collapseAll(current) {
this.forEachTag('model', function(model) {
if (model == current) {
return;
}
model.collapse();
})
}
addModel(ev) {
ev.preventDefault();
var type = ev.target.innerText;
this.models = this.updateTag('model');
this.refs.models.show();
this.models.unshift({
behaviour: 'inline',
predicate: null,
type: type,
output: null,
models: [],
parameters: [],
renditions: [],
sourcerend: false,
show: true
});
}
removeModel(item) {
this.parent.refs.dialog.confirm('Delete?', 'Are you sure to delete the model?')
.then(function() {
var index = this.models.indexOf(item);
this.models = this.updateTag('model');
this.models.splice(index, 1);
this.update();
}.bind(this)
);
}
remove(ev) {
this.parent.removeElementSpec(ev.item);
}
paste(ev) {
var data = this.clipboard.paste();
if (data) {
this.models = this.updateTag('model');
this.refs.models.open();
this.models.unshift(data);
}
}
getData() {
return {
ident: this.ident,
mode: this.mode,
models: this.updateTag('model')
};
}
serialize(indent) {
var xml = indent + '<elementSpec ident="' + this.ident + '"';
if (this.mode) {
xml += ' mode="' + this.mode + '"';
}
xml += '>\n';
xml += this.serializeTag('model', indent + this.indentString);
xml += indent + '</elementSpec>\n';
return xml;
}
</script>
<style>
input { vertical-align: middle; }
</style>
</element-spec>
<message type="{ type }">
<paper-dialog ref="modal">
<h2 ref="title">Action</h2>
<paper-dialog-scrollable ref="message" class="message"></paper-dialog-scrollable>
<div class="buttons">
<paper-button dialog-confirm="dialog-confirm" autofocus="autofocus" if="{ this.type == 'message' }">Close</paper-button>
<paper-button ref="confirm" dialog-confirm="dialog-confirm" autofocus="autofocus" if="{ this.type == 'confirm' }">Yes</paper-button>
<paper-button dialog-confirm="dialog-confirm" autofocus="autofocus" if="{ this.type == 'confirm' }">No</paper-button>
</div>
</paper-dialog>
<script>
this.type = this.opts.type;
show(title, message) {
this.type = 'message';
message = message || '';
this.update();
this.refs.title.innerHTML = title;
this.refs.message.innerHTML = message;
this.refs.modal.open();
}
confirm(title, message) {
this.type = 'confirm';
this.set(title, message);
this.update();
this.refs.modal.open();
return new Promise(function(resolve, reject) {
this.refs.confirm.addEventListener('click', resolve, { once: true });
}.bind(this));
}
set(title, message) {
this.refs.title.innerHTML = title;
this.refs.message.innerHTML = message;
}
</script>
<style>
paper-dialog {
min-width: 420px;
max-width: 640px;
min-height: 128px;
}
paper-dialog h2 {
background-color: #607D8B;
}
</style>
</message>
function Clipboard() {
this.data = null;
this.copy = function(model) {
console.log("Copied to clipboard: %o", model);
this.data = model;
}
this.paste = function() {
console.log("Paste from clipboard: %o", this.data);
return this.data;
}
}
function Mixin(app) {
this.app = app;
this.indentString = ' ';
this.clipboard = new Clipboard();
var replaceChars = {
'"': '&quot;',
'&': '&amp;',
'<': '&lt;',
'>': '&gt;'
};
this.escape = function(code) {
var regex = new RegExp(Object.keys(replaceChars).join("|"), "g");
return code.replace(regex, function(match) {
return replaceChars[match];
});
}
this.updateTag = function(name) {
var data = [];
this.forEachTag(name, function(tag) {
data.push(tag.getData());
});
return data;
}
this.forEachTag = function(name, callback) {
if (this.tags && this.tags[name]) {
if (this.tags[name].length) {
this.tags[name].forEach(function(tag) {
callback(tag);
});
} else {
callback(this.tags[name]);
}
}
}
this.serializeTag = function(name, indent) {
indent = indent || '';
var xml = "";
this.forEachTag(name, function(tag) {
xml += tag.serialize(indent);
});
return xml;
}
this.moveModelDown = function(item) {
var index = this.models.indexOf(item);
if (index == this.models.length - 1) {
return;
}
this.models = this.updateTag('model');
var m = [];
for (var i = 0; i < this.models.length; i++) {
if (i == index) {
m.push(this.models[i + 1]);
m.push(this.models[i]);
i++;
} else {
m.push(this.models[i]);
}
}
this.models = m;
this.update();
}
this.moveModelUp = function(item) {
var index = this.models.indexOf(item);
if (index == 0) {
return;
}
this.models = this.updateTag('model');
var m = [];
for (var i = 0; i < this.models.length; i++) {
if (i == index - 1) {
m.push(this.models[index]);
m.push(this.models[i]);
} else if (i != index){
m.push(this.models[i]);
}
}
this.models = m;
this.update();
}
}
This diff is collapsed.
<odd-select>
<paper-dropdown-menu label="Editing ODD:">
<paper-listbox ref="select" name="odd" slot="dropdown-content" attr-for-selected="value">
<yield/>
</paper-listbox>
</paper-dropdown-menu>
<script>
var self = this;
var historySupport = !!(window.history && window.history.pushState);
selected(ev) {
var odd = this.refs.select.selected;
if (this.odd === odd) {
return;
}
this.odd = odd;
console.log("Selected odd %s", odd);
// if (historySupport) {
// var state = TeiPublisher.config;
// state.odd = odd;
// var url = window.location.pathname + '?' + $.param(state);
// history.pushState(state, null, url);
// }
this.parent.setODD(odd);
}
this.on("mount", function() {
self.refs.select.selected = TeiPublisher.config.odd;
self.refs.select.addEventListener('selected-item-changed', self.selected.bind(self));
this.selected();
// $(window).on("popstate", function(ev) {
// var state = ev.originalEvent.state;
// console.log("popstate: %s", state.odd);
// self.refs.select.value = state.odd;
// self.parent.setODD(state.odd);
// });
});
</script>
<style>
paper-dropdown-menu {
width: 100%;
}
</style>
</odd-select>
<parameter name="{ name }" value="{ value }">
<paper-autocomplete ref="combo" text="{ name }" placeholder="[Param name]" label="Name" source="[]"></paper-autocomplete>
<span class="value">
<code-editor ref="value" mode="xquery" code="{ value }" placeholder="[XPath to define param value]"></code-editor>
</span>
<span class="actions">
<paper-icon-button onclick="{ delete }" icon="delete"></paper-icon-button>
</span>
<script>
this.mixin('utils');
this.on("mount", function() {
this.show();
this.updateList();
});
updateList() {
var autocomplete = [];
var values = parameters[this.parent.getBehaviour()] || [];
values.forEach(function(val) {
autocomplete.push({
text: val, value: val
});
});
this.refs.combo.source = autocomplete;
}
delete(ev) {
ev.preventDefault();
this.parent.removeParameter(ev.item);
}
getData() {
return {
name: this.refs.combo.text,
value: this.refs.value.get()
};
}
serialize(indent) {
var name = this.refs.combo.text;
if (!name) {
return '';
}
return indent + '<param name="' + name + '" value="' + this.escape(this.refs.value.get()) + '"/>\n';
}
show() {
this.refs.value.initCodeEditor();
}
var parameters = {
alternate: ["content", "default", "alternate"],
anchor: ["content", "id"],
block: ["content"],
body: ["content"],
break: ["content", "type"],
cell: ["content"],
cit: ["content", "source"],
"document": ["content"],
figure: ["content", "title"],
graphic: ["content", "url", "width", "height", "scale", "title"],
heading: ["content", "level"],
inline: ["content"],
link: ["content", "link"],
list: ["content"],
listItem: ["content"],
metadata: ["content"],
note: ["content", "place", "label"],
omit: ["content"],
paragraph: ["content"],
row: ["content"],
section: ["content"],
table: ["content"],
text: ["content"],
title: ["content"]
};
<style>
:scope { display: flex; flex-direction: row; align-items: flex-start; }
paper-autocomplete { flex: 1 0; margin-right: 10px; }
.actions { }
.btn { margin: 0; }
.value { flex: 2 0; padding-left: 10px; min-width: 300px; min-height: 1em; }
</style>
</parameter>
<rendition scope="{ scope }">
<paper-dropdown-menu label="Scope">
<paper-listbox ref="scope" slot="dropdown-content" selected="{ scope }" attr-for-selected="value">
<option each="{ s in scopes }" value="{ s }">{ s }</option>
</paper-listbox>
</paper-dropdown-menu>
<paper-icon-button onclick="{ remove }" icon="delete"></paper-icon-button>
<code-editor ref="css" mode="css" code="{ this.css }" placeholder="[CSS to apply]"></code-editor>
<script>
this.mixin('utils');
var self = this;
this.scopes = ["", "before", "after"];
remove(ev) {
this.parent.removeRendition(ev.item);
}
getData() {
return {
scope: this.refs.scope.selected,
css: this.refs.css.get()
};
}
serialize(indent) {
var css = this.refs.css.get();
if (!css) {
return '';
}
css = this.escape(css);
var scope = this.refs.scope.selected;
var xml = indent + '<outputRendition';
if (scope) {
xml += ' scope="' + scope + '"';
}
xml += '>\n';
xml += indent + this.indentString + css;
xml += '\n' + indent + '</outputRendition>\n';
return xml;
}
show() {
this.refs.css.initCodeEditor();
}
</script>
<style>
code-editor {
margin-top: 10px;
}
</style>
</rendition>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment