[isidorus-cvs] r43 - trunk/src/ajax/javascripts
Lukas Giessmann
lgiessmann at common-lisp.net
Tue Jun 16 10:52:20 UTC 2009
Author: lgiessmann
Date: Tue Jun 16 06:52:20 2009
New Revision: 43
Log:
ajax-client: finalized the "toJSON()" methods of all needed classes - so it is possible to create a json-string of the users objects
Modified:
trunk/src/ajax/javascripts/constants.js
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Tue Jun 16 06:52:20 2009
@@ -76,6 +76,7 @@
"__spanDeselect__" : "deselect",
"__divFog__" : "fog",
"__inputCommitButton__" : "commitButton",
+ "__divTmIdFrame__" : "tmIdFrame",
"page" : function(){ return this.__divPage__; },
"subPage" : function(){ return this.__divSubPage__; },
@@ -115,5 +116,6 @@
"playerFrame" : function(){ return this.__divPlayerFrame__; },
"deselect" : function(){ return this.__spanDeselect__; },
"fog" : function(){ return this.__divFog__; },
- "commitButton" : function(){ return this.__inputCommitButton__; }
+ "commitButton" : function(){ return this.__inputCommitButton__; },
+ "tmIdFrame" : function(){ return this.__divTmIdFrame__; }
};
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Tue Jun 16 06:52:20 2009
@@ -50,10 +50,14 @@
context.insert({"after" : liT});
addTopicAsPlayer((constraints ? constraints.associationsConstraints : null), topic.getContent().instanceOfs);
- var associations = new AssociationContainerC(null, (constraints ? constraints.associationsConstraints : null), topic);
+ var associations = new AssociationContainerC(null, (constraints ? constraints.associationsConstraints : null));
var liA = new Element("li", {"class" : CLASSES.associationContainer()}).update(associations.getFrame());
liT.insert({"after" : liA});
+ var tmId = new tmIdC(null);
+ var liTm = new Element("li", {"class" : CLASSES.tmIdFrame()}).update(tmId.getFrame());
+ liA.insert({"after" : liTm});
+
var commitButton = new Element("input", {"type" : "button", "value" : "commit fragment", "style" : "float: right; margin-top: -10px;"})
commitButton.observe("click", function(event){
try{
@@ -61,16 +65,20 @@
var referencedTopics = topic.getReferencedTopics().concat(associations.getReferencedTopics()).without(CURRENT_TOPIC).uniq();
function onSuccessHandler(topicStubs){
- var str = "null";
+ var tsStr = "null";
if(topicStubs && topicStubs.length !== 0){
- str = "[";
+ tsStr = "[";
for(var i = 0; i !== topicStubs.length; ++i){
- str += topicStubs[i];
- if(i !== topicStubs.length - 1) str += ",";
+ tsStr += topicStubs[i];
+ if(i !== topicStubs.length - 1) tsStr += ",";
}
- str += "]";
+ tsStr += "]";
}
- var json = "{\"topic\":" + topic.toJSON() + ",\"topicStubs\":" + str + ",\"associations\":" + associations.toJSON().gsub(CURRENT_TOPIC_ESCAPED, tPsis) + ",\"tmIds\":" + "[\"myTM\"]}";
+ var jTopic = "\"topic\":" + topic.toJSON();
+ var jTopicStubs = "\"topicStubs\":" + tsStr;
+ var jAssociations = "\"associations\":" + associations.toJSON().gsub(CURRENT_TOPIC_ESCAPED, tPsis)
+ var jTmId = "\"tmIds\":" + tmId.toJSON();
+ var json = "{" + jTopic + "," + jTopicStubs + "," + jAssociations + "," + jTmId + "}";
alert(json);
}
@@ -84,7 +92,7 @@
});
var liCB = new Element("li", {"class" : CLASSES.commitButton()});
liCB.update(commitButton);
- liA.insert({"after" : liCB});
+ liTm.insert({"after" : liCB});
}
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Tue Jun 16 06:52:20 2009
@@ -2382,10 +2382,9 @@
// --- contains all fragment's associations depending on the main topic
-var AssociationContainerC = Class.create(ContainerC, {"initialize" : function($super, contents, constraints, mainTopic){
+var AssociationContainerC = Class.create(ContainerC, {"initialize" : function($super, contents, constraints){
$super();
this.__minimized__ = false;
- this.__mainTopic__ = mainTopic;
try{
this.__frame__ .writeAttribute({"class" : CLASSES.associationContainer()});
this.__table__ = new Element("table", {"class" : CLASSES.associationContainer()});
@@ -2480,45 +2479,53 @@
}});
+// --- Representation of a topic map if frame.
+var tmIdC = Class.create(ContainerC, {"initialize" : function($super, contents){
+ $super();
+ try{
+ this.__frame__.writeAttribute({"class" : CLASSES.itemIdentityFrame()});
+ this.__container__ = new Object();
+ this.__frame__.writeAttribute({"class" : CLASSES.tmIdFrame()});
+ this.__table__ = new Element("table", {"class" : CLASSES.tmIdFrame()});
+ this.__frame__.insert({"top" : this.__table__});
+ this.__caption__ = new Element("caption", {"class" : CLASSES.clickable()}).update("Topic Map ID");
+ this.__table__.update(this.__caption__);
+ var value = contents && contents.length !== 0 ? contents[0] : "";
+ this.__contentrow__ = new Element("input", {"type" : "text", "value" : value});
+ this.__tr__ = new Element("tr", {"class" : CLASSES.tmIdFrame()});
+ var td =new Element("td", {"class" : CLASSES.content()});
+ this.__tr__.update(td);
+ td.update(this.__contentrow__);
+ this.__table__.insert({"bottom" : this.__tr__});
+
+ this.__minimized__ = false;
+ function setMinimizeHandler(myself){
+ myself.__caption__.observe("click", function(event){
+ myself.minimize();
+ });
+ }
+ setMinimizeHandler(this);
+ }
+ catch(err){
+ alert("From tmIdC(): " + err);
+ }
+ },
+ "getContent" : function(){
+ if(this.__contentrow__.value.strip().length === 0) return null;
+ return new Array(this.__contentrow__.value.strip());
+ },
+ "toJSON" : function(){
+ return (this.getContent() === null ? "null" : this.getContent().toJSON());
+ },
+ "isValid" : function(){
+ return this.getContent() !== null;
+ },
+ "minimize": function(){
+ if(this.__minimized__ === false) this.__tr__.hide();
+ else this.__tr__.show();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ this.__minimized__ = !this.__minimized__;
+ }});
// --- A handler for the dblclick-event. So a frame can be disabled or enabled.
More information about the Isidorus-cvs
mailing list