Author: lgiessmann Date: Tue Jun 30 06:16:38 2009 New Revision: 80
Log: ajax-client: implemented a topic map overview
Modified: trunk/src/ajax/css/tree.css trunk/src/ajax/javascripts/constants.js trunk/src/ajax/javascripts/create.js trunk/src/ajax/javascripts/datamodel.js trunk/src/ajax/javascripts/edit.js trunk/src/ajax/javascripts/home.js trunk/src/unit_tests/poems.xtm
Modified: trunk/src/ajax/css/tree.css ============================================================================== --- trunk/src/ajax/css/tree.css (original) +++ trunk/src/ajax/css/tree.css Tue Jun 30 06:16:38 2009 @@ -27,18 +27,28 @@ }
ul.topicPsis + span { + color: #7090d0; + font-size: 0.8em; margin-left: 20px; - margin-right: 2px; }
-ul.topicPsis + span + span{ +ul.topicPsis + span + span + span { + color: #7090d0; + font-size: 0.8em; +} + +ul.topicPsis + span + span { + color: #7090d0; margin-left: 2px; + margin-right: 2px; }
ul.topicPsis + span.disabled { + font-size: 0.8em; color: #eaeaee; }
-ul.topicPsis + span + span.disabled { +ul.topicPsis + span + span + span.disabled { + font-size: 0.8em; color: #eaeaee; } \ No newline at end of file
Modified: trunk/src/ajax/javascripts/constants.js ============================================================================== --- trunk/src/ajax/javascripts/constants.js (original) +++ trunk/src/ajax/javascripts/constants.js Tue Jun 30 06:16:38 2009 @@ -11,7 +11,7 @@
// --- Some constants fot the http connections via the XMLHttpRequest-Object -var HOST_PREF = /*"http://143.93.190.237:8000/%22;*/ "http://localhost:8000/"; // of the form "http://(.+)/" +var HOST_PREF = "http://143.93.190.237:8000/"; // "http://localhost:8000/"; // of the form "http://(.+)/" var GET_PREFIX = HOST_PREF + "json/get/"; var GET_STUB_PREFIX = HOST_PREF + "json/topicstubs/"; var TMCL_TYPE_URL = HOST_PREF + "json/tmcl/type/";
Modified: trunk/src/ajax/javascripts/create.js ============================================================================== --- trunk/src/ajax/javascripts/create.js (original) +++ trunk/src/ajax/javascripts/create.js Tue Jun 30 06:16:38 2009 @@ -43,7 +43,7 @@ liTopicSelect.insert({"bottom" : err}); } else { - instanceOf = new InstanceOfC(json.flatten().sort(), innerMakeFragment); + instanceOf = new InstanceOfC(json.flatten().sort(), innerMakeFragment, psi); liTopicSelect.insert({"bottom" : instanceOf.getFrame()}); } }
Modified: trunk/src/ajax/javascripts/datamodel.js ============================================================================== --- trunk/src/ajax/javascripts/datamodel.js (original) +++ trunk/src/ajax/javascripts/datamodel.js Tue Jun 30 06:16:38 2009 @@ -186,6 +186,18 @@ "enable" : function(){ this.__content__.removeAttribute("disabled"); this.__disabled__ = false; + }, + "select" : function(value){ + var opts = this.__content__.select("option"); + for(var i = 0; i !== opts.length; ++i){ + try{ + if(opts[i].value === value){ + opts[i].writeAttribute({"selected" : "selected"}); + this.__content__.insert({"top" : opts[i]}); + } + else opts[i].removeAttribute("selected"); + }catch(err){ alert("err [" + i + "]" + err); } + } }});
@@ -243,12 +255,13 @@
// --- Representation of a -var EditC = Class.create(ContainerC, {"initialize" : function($super, contents, successFun){ +var EditC = Class.create(ContainerC, {"initialize" : function($super, contents, successFun, psi){ $super(); this.__frame__.writeAttribute({"class" : CLASSES.editFrame()}); this.__container__ = new Object(); try{ var row = new SelectrowC(contents, this.__container__, 1, 1); + if(psi && psi.length !== 0) row.select(psi); this.__error__.insert({"before" : row.getFrame()}); } catch(err){ @@ -274,6 +287,12 @@ clearFragment(); requestConstraints("[" + myself.toJSON() + "]", onSuccessHandler, null) }); + + if(psi && psi.length !== 0) { + myself.hideError(); + clearFragment(); + requestConstraints("[" + myself.toJSON() + "]", onSuccessHandler, null); + } } setHandler(this);
@@ -288,12 +307,13 @@
// --- Represents a container for all instanceOf-Psis of a fragment's topic -var InstanceOfC = Class.create(ContainerC, {"initialize" : function($super, contents, successFun){ +var InstanceOfC = Class.create(ContainerC, {"initialize" : function($super, contents, successFun, psi){ $super(); this.__frame__.writeAttribute({"class" : CLASSES.instanceOfFrame()}); this.__container__ = new Object(); try{ var row = new SelectrowC(contents, this.__container__, 1, -1); + if(psi && psi.length !== 0) row.select(psi); this.__error__.insert({"before" : row.getFrame()}); } catch(err){ @@ -339,6 +359,12 @@ clearFragment(); requestConstraints(myself.toJSON(true), onSuccessHandler, null, true); }); + + if(psi && psi.length !== 0) { + myself.hideError(); + clearFragment(); + requestConstraints(myself.toJSON(true), onSuccessHandler, null, true); + } } setHandler(this);
@@ -2824,7 +2850,7 @@ } }, "__createFromContent__" : function(contents){ - if(!contents || contents.lenght === 0) return; + if(!contents || contents.length === 0) return; var cContents = contents; var usedContents = new Array();
Modified: trunk/src/ajax/javascripts/edit.js ============================================================================== --- trunk/src/ajax/javascripts/edit.js (original) +++ trunk/src/ajax/javascripts/edit.js Tue Jun 30 06:16:38 2009 @@ -53,7 +53,8 @@ liTopicSelect.insert({"bottom" : err}); } else { - edit = new EditC(json.flatten().sort(), innerMakeFragment); + if(!psi || psi.strip().lenght === 0) psi = null; + edit = new EditC(json.flatten().sort(), innerMakeFragment, psi); liTopicSelect.insert({"bottom" : edit.getFrame()}); } }
Modified: trunk/src/ajax/javascripts/home.js ============================================================================== --- trunk/src/ajax/javascripts/home.js (original) +++ trunk/src/ajax/javascripts/home.js Tue Jun 30 06:16:38 2009 @@ -42,6 +42,7 @@ }
+// --- Represents a list of trees. var TreeViewC = Class.create({"initialize" : function(contents){ if(!contents) throw "From NodeC(): content must be set!"; try { @@ -60,6 +61,7 @@ }});
+// --- Represents the root of a tree of nodes and contain all tree's nodes. var TreeC = Class.create({"initialize" : function(content){ if(!content) throw "From NodeC(): content must be set!"; try { @@ -75,17 +77,49 @@ }});
+// --- Represents a tree node with a topic as a list of psis, +// --- an edit and a create button. Furter the node can contain +// --- more nodes as listings of instances and subtypes of the +// --- current node's topic. var NodeC = Class.create({"initialize" : function(content){ if(!content) throw "From NodeC(): content must be set!"; try { this.__frame__ = new Element("li", {"class" : CLASSES.node()}); + this.__isMinimized__ = false; + + function setClickHandler(myself){ + myself.__frame__.observe("click", function(event){ + if(myself.__isMinimized__ === false){ + if(myself.__instances__) myself.__instances__.hide(); + if(myself.__subtypes__) myself.__subtypes__.hide(); + myself.__frame__.setStyle({"color" : "#ff7f00"}); + myself.__isMinimized__ = true; + } + else { + if(myself.__instances__) myself.__instances__.show(); + if(myself.__subtypes__) myself.__subtypes__.show(); + myself.__frame__.setStyle({"color" : "inherit"}); + myself.__isMinimized__ = false; + } + Event.stop(event); + }); + } + setClickHandler(this); + + if((content.instances && content.instances.length !== 0) || (content.subtypes && content.subtypes.length !== 0)) { + this.getFrame().setStyle({"cursor" : "pointer"}); + } + else { + this.getFrame().setStyle({"cursor" : "text"}); + } + this.__topic__ = new Element("ul", {"class" : CLASSES.topicPsis()}); - this.__frame__.update(this.__topic__); + this.__frame__.insert({"bottom" : this.__topic__}); for(var i = 0; content.topic && i !== content.topic.length; ++i){ var tLi = new Element("li").update(content.topic[i]); this.__topic__.insert({"bottom" : tLi}); } - + this.__edit__ = new Element("span", {"class" : CLASSES.clickable()}).update("edit"); this.__create__ = new Element("span", {"class" : CLASSES.clickable()}).update("create"); if(content.isType !== true){ @@ -93,9 +127,10 @@ } else { this.__create__.observe("click", function(event){ - alert("create"); + setNaviClasses($(PAGES.create)); + makePage(PAGES.create, content.topic[0]); + Event.stop(event); }); - // TODO: define a handler }
if(content.isInstance !== true){ @@ -103,14 +138,15 @@ } else { this.__edit__.observe("click", function(event){ - alert("edit"); + setNaviClasses($(PAGES.edit)); + makePage(PAGES.edit, content.topic[0]); + Event.stop(event); }); - // TODO: define a handler } - this.__frame__.update(this.__topic__); this.__frame__.insert({"bottom" : this.__edit__}); - this.__frame__.insert({"bottom" : "|"}); + this.__frame__.insert({"bottom" : "<span>|</span>"}); this.__frame__.insert({"bottom" : this.__create__}); + for(var i = 1; content.topic && i < content.topic.length; ++i) this.__frame__.insert({"bottom" : "<br/><span> </span>"});
this.__instances__ = null; this.__subtypes__ = null;
Modified: trunk/src/unit_tests/poems.xtm ============================================================================== --- trunk/src/unit_tests/poems.xtm (original) +++ trunk/src/unit_tests/poems.xtm Tue Jun 30 06:16:38 2009 @@ -619,6 +619,7 @@ <!-- author --> <tm:topic id="author"> <tm:subjectIdentifier href="http://some.where/base-psis/author%22/%3E + <tm:subjectIdentifier href="http://some.where/base-psis/author-psi%22/%3E tm:instanceOf<tm:topicRef href="#topictype"/></tm:instanceOf> </tm:topic>