From baf84d6cac649a2987d055277c128818d8399263 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 16 Jul 2010 13:55:53 -0400 Subject: [PATCH] Added XUL frontend for a future dirtag/web.py --- static/dirtag.css | 6 +++ static/dirtag.js | 62 +++++++++++++++++++++ static/dirtag.xul | 129 ++++++++++++++++++++++++++++++++++++++++++++ static/raw-tree.rdf | 61 +++++++++++++++++++++ static/tag-tree.rdf | 38 +++++++++++++ 5 files changed, 296 insertions(+) create mode 100644 static/dirtag.css create mode 100644 static/dirtag.js create mode 100644 static/dirtag.xul create mode 100644 static/raw-tree.rdf create mode 100644 static/tag-tree.rdf diff --git a/static/dirtag.css b/static/dirtag.css new file mode 100644 index 0000000..e57c498 --- /dev/null +++ b/static/dirtag.css @@ -0,0 +1,6 @@ +@import url(chrome://global/skin/); + +/* No groupbox border in Linux: + https://developer.mozilla.org/en/XUL/groupbox + */ +/* groupbox {border-style:solid; border-color:black; border:1px;} */ diff --git a/static/dirtag.js b/static/dirtag.js new file mode 100644 index 0000000..d04acaa --- /dev/null +++ b/static/dirtag.js @@ -0,0 +1,62 @@ +/* Useful helper functions */ + +function tree_selection(id) { + var tree = document.getElementById(id); + var name = tree.columns.getPrimaryColumn(); + var i = tree.currentIndex; + var path = new Array(); + while (i >= 0) { + path.splice(0, 0, tree.view.getCellText(i, name)); + i = tree.view.getParentIndex(i); + } + return path; +} + +/* Functions driving the CherryPy backend */ + +function new_tag(path) { + alert('Adding tag: '+path.toString()); + /* https://developer.mozilla.org/en/RDF_in_Mozilla_FAQ */ +} + +function add_tag(path, tag) { + alert('Add tag '+path.toString()+' to '+tag); +} + +function remove_tag(path, tag) { + alert('Remove tag '+path.toString()+' from '+tag); +} + +/* The bindings themselves */ + +function initialize() { + element = document.getElementById('element').file_path = 'UNDEFINED'; +} + +function new_tag_button() { + var text = document.getElementById('new-tag-text').value; + new_tag(text.split('/')); +} + +function set_selected_element(path) { + element = document.getElementById('element'); + element.file_path = path; + alert(path.toString()); +} + +function raw_tree_select() { + set_selected_element(tree_selection('raw-tree')); +} + +function tag_tree_select() { + set_selected_element(tree_selection('tag-tree')); +} + +function tag_check(event) { + var path = document.getElementById('element').file_path; + if (event.target.checked) { + add_tag(path, event.target.id); + } else { + remove_tag(path, event.target.id); + } +} diff --git a/static/dirtag.xul b/static/dirtag.xul new file mode 100644 index 0000000..7ee1f30 --- /dev/null +++ b/static/dirtag.xul @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + +]> + + + +