* Added Story.add() method as counterpart to Story.remove() and to establish kind of internal API
* Rewrote external API (Api prototype) reducing redundant code by calling Story.add() method
This commit is contained in:
parent
fe159c3112
commit
2ca26e4f28
7 changed files with 70 additions and 53 deletions
|
@ -19,17 +19,46 @@
|
|||
// limitations under the License.
|
||||
//
|
||||
// $Revision$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $Author$
|
||||
// $Date$
|
||||
// $URL$
|
||||
|
||||
/**
|
||||
* @fileOverview Defindes the Story prototype.
|
||||
* @fileOverview Defines the Story prototype.
|
||||
*/
|
||||
|
||||
markgettext("Story");
|
||||
markgettext("story");
|
||||
|
||||
this.handleMetadata("title");
|
||||
this.handleMetadata("text");
|
||||
|
||||
/**
|
||||
* @function
|
||||
* @param {Story[]} parent
|
||||
* @param {Object} data
|
||||
* @returns {Story}
|
||||
*/
|
||||
Story.add = function(parent, data) {
|
||||
var story = new Story;
|
||||
story.update(data);
|
||||
parent.add(story);
|
||||
return story;
|
||||
}
|
||||
|
||||
/**
|
||||
* @function
|
||||
*/
|
||||
Story.remove = function() {
|
||||
if (this.constructor === Story) {
|
||||
HopObject.remove.call(this.comments);
|
||||
this.deleteMetadata();
|
||||
this.setTags(null);
|
||||
this.remove();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @function
|
||||
* @returns {String[]}
|
||||
|
@ -53,22 +82,6 @@ Story.getCommentModes = defineConstants(Story, markgettext("closed"),
|
|||
/* markgettext("readonly"), markgettext("moderated"), */
|
||||
markgettext("open"));
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Story.remove = function() {
|
||||
if (this.constructor === Story) {
|
||||
HopObject.remove.call(this.comments);
|
||||
this.deleteMetadata();
|
||||
this.setTags(null);
|
||||
this.remove();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.handleMetadata("title");
|
||||
this.handleMetadata("text");
|
||||
|
||||
/**
|
||||
* @name Story
|
||||
* @constructor
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue