Skip to content

Commit

Permalink
Add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
garafu committed Aug 30, 2015
1 parent aab8314 commit 010830c
Show file tree
Hide file tree
Showing 23 changed files with 130 additions and 97 deletions.
10 changes: 3 additions & 7 deletions demo/index_compile.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
<title></title>
<link rel="stylesheet" type="text/css" href="../lib/bootstrap/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="../stylesheets/simple.css" />
<style>
#main .poststoc-list {
list-style-type: decimal;
}
</style>
</head>
<body>
<div>
Expand All @@ -18,11 +13,12 @@ <h1>Compile Mode</h1>
var POSTSTOC_SETTINGS = {
blogURL: 'garafu.blogspot.jp',
sort: {
key: 'published'
key: 'title',
order: 'asc'
},
printby: 'title',
thumbnail: {
enabled: false
enabled: true
},
published: {
enabled: true,
Expand Down
3 changes: 3 additions & 0 deletions src/blogger/toc/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ var contract = {
}
};




/**
* Settings contract.
*/
Expand Down
6 changes: 6 additions & 0 deletions src/blogger/toc/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ goog.require('garafu.events');
// --------------------------------------------------------------------------------
// constructor
// --------------------------------------------------------------------------------

/**
* @class
*
Expand Down Expand Up @@ -93,6 +94,7 @@ garafu.blogger.toc.Main._data = contract;
// --------------------------------------------------------------------------------
// static method
// --------------------------------------------------------------------------------

/**
* Callback when feed data has been recieved.
*
Expand Down Expand Up @@ -138,6 +140,7 @@ garafu.blogger.toc.Main.load = function (data) {
// --------------------------------------------------------------------------------
// method
// --------------------------------------------------------------------------------

/**
* Get the singleton instance.
*
Expand Down Expand Up @@ -282,7 +285,10 @@ garafu.blogger.toc.Main.prototype.print = function (data) {


/**
* Create footer license element.
*
* @private
* @return {DOMElement}
*/
garafu.blogger.toc.Main.prototype.createLicenseElement = function () {
var container = document.createElement('div');
Expand Down
5 changes: 3 additions & 2 deletions src/blogger/toc/printer/abstractprinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ goog.provide('garafu.blogger.toc.printer.AbstractPrinter');


// --------------------------------------------------------------------------------
// garafu.blogger.toc.PretyPrint class
// constructor
// --------------------------------------------------------------------------------
/**
* @class
* @public
* @constructor
* @class
* @param {garafu.blogger.toc.Settings} settings Settings object.
*/
garafu.blogger.toc.printer.AbstractPrinter = function (settings) {
this._settings = settings;
Expand Down
12 changes: 10 additions & 2 deletions src/blogger/toc/printer/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ goog.provide('garafu.blogger.toc.printer.Category');
// constructor
// --------------------------------------------------------------------------------
/**
* @class
* @public
* @constructor
* @class
* @param {garafu.blogger.toc.Settings} settings Settings object.
* @param {feed.category} category Feed category data.
*/
garafu.blogger.toc.printer.Category = function (settings, category) {
// Properties.
Expand All @@ -37,9 +39,9 @@ garafu.blogger.toc.printer.Category = function (settings, category) {
// --------------------------------------------------------------------------------
// method
// --------------------------------------------------------------------------------

/**
* Get category name.
*
* @public
*/
garafu.blogger.toc.printer.Category.prototype.getName = function () {
Expand All @@ -51,6 +53,7 @@ garafu.blogger.toc.printer.Category.prototype.getName = function () {

/**
* Get the root DOM element of this category.
*
* @public
*/
garafu.blogger.toc.printer.Category.prototype.getRootElement = function () {
Expand All @@ -62,6 +65,7 @@ garafu.blogger.toc.printer.Category.prototype.getRootElement = function () {

/**
* Get the number of appended entries.
*
* @public
*/
garafu.blogger.toc.printer.Category.prototype.getEntryCounts = function () {
Expand All @@ -73,7 +77,9 @@ garafu.blogger.toc.printer.Category.prototype.getEntryCounts = function () {

/**
* Append specific entry to the end of this category.
*
* @public
* @param {garafu.blogger.toc.printer.Entry} entry Entry object.
*/
garafu.blogger.toc.printer.Category.prototype.addEntry = function (entry) {
var entryElement = entry.getRootElement();
Expand All @@ -90,6 +96,8 @@ garafu.blogger.toc.printer.Category.prototype.addEntry = function (entry) {


/**
* Initialize this instance.
*
* @private
*/
garafu.blogger.toc.printer.Category.prototype.initialize = function () {
Expand Down
12 changes: 11 additions & 1 deletion src/blogger/toc/printer/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ goog.require('garafu.date.W3CDTF');
// constructor
// --------------------------------------------------------------------------------
/**
* @class
* @public
* @constructor
* @class
* @param {garafu.blogger.toc.Settings} settings Settings object.
* @param {feed.entry} entry Feed entry data.
*/
garafu.blogger.toc.printer.Entry = function (settings, entry) {
// Properties.
Expand All @@ -39,6 +41,7 @@ garafu.blogger.toc.printer.Entry = function (settings, entry) {
// --------------------------------------------------------------------------------
/**
* Get entry name.
*
* @public
*/
garafu.blogger.toc.printer.Entry.prototype.getName = function () {
Expand All @@ -50,6 +53,7 @@ garafu.blogger.toc.printer.Entry.prototype.getName = function () {

/**
* Get the root DOM element of this category.
*
* @public
*/
garafu.blogger.toc.printer.Entry.prototype.getRootElement = function () {
Expand Down Expand Up @@ -118,6 +122,12 @@ garafu.blogger.toc.printer.Entry.prototype.initialize = function () {




/**
* @private
* @param {feed.entry.media$thumbnail} Thumbnail data.
* @return {DOMElement} Thumbnail image DOM element.
*/
garafu.blogger.toc.printer.Entry.prototype.createThumbnailElement = function (media) {
var img = document.createElement('img');

Expand Down
6 changes: 4 additions & 2 deletions src/blogger/toc/printer/labelcontentsorderprinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ goog.require('garafu.blogger.toc.printer.LabelPrinter');
// constructor
// --------------------------------------------------------------------------------
/**
* @class
* @public
* @constructor
* @class
* @param {garafu.blogger.toc.Settings} settings Settings object.
*/
garafu.blogger.toc.printer.LabelContentsOrderPrinter = function (settings) {
goog.base(this, settings);
Expand All @@ -30,10 +31,11 @@ goog.inherits(garafu.blogger.toc.printer.LabelContentsOrderPrinter, garafu.blogg
// --------------------------------------------------------------------------------
// method
// --------------------------------------------------------------------------------

/**
* Sort category name list.
* @public
* @param {garafu.blogger.toc.printer.Category[]} originalList Category list.
* @return {garafu.blogger.toc.printer.Category[]} Sorted list.
*/
garafu.blogger.toc.printer.LabelContentsOrderPrinter.prototype.sort = function (originalList) {
var sortedList;
Expand Down
6 changes: 4 additions & 2 deletions src/blogger/toc/printer/labelnameorderprinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ goog.require('garafu.blogger.toc.printer.LabelPrinter');
// constructor
// --------------------------------------------------------------------------------
/**
* @class
* @public
* @constructor
* @class
* @param {garafu.blogger.toc.Settings} settings Settings object.
*/
garafu.blogger.toc.printer.LabelNameOrderPrinter = function (settings) {
goog.base(this, settings);
Expand All @@ -30,10 +31,11 @@ goog.inherits(garafu.blogger.toc.printer.LabelNameOrderPrinter, garafu.blogger.t
// --------------------------------------------------------------------------------
// method
// --------------------------------------------------------------------------------

/**
* Sort category name list.
* @public
* @param {garafu.blogger.toc.printer.Category[]} originalList Category list.
* @return {garafu.blogger.toc.printer.Category[]} Sorted list.
*/
garafu.blogger.toc.printer.LabelNameOrderPrinter.prototype.sort = function (originalList) {
var sortedList;
Expand Down
5 changes: 5 additions & 0 deletions src/blogger/toc/printer/labelprinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ goog.inherits(garafu.blogger.toc.printer.LabelPrinter, garafu.blogger.toc.printe
// --------------------------------------------------------------------------------
/**
* @public
* @param {feed} feed Original feed data.
* @return {DOMElement} Root DOM element.
*/
garafu.blogger.toc.printer.LabelPrinter.prototype.execute = function (feed) {
var settings = this._settings;
Expand Down Expand Up @@ -85,9 +87,12 @@ garafu.blogger.toc.printer.LabelPrinter.prototype.execute = function (feed) {




/**
* Sort category name list.
* @public
* @param {garafu.blogger.toc.printer.Category[]} originalList Category list.
* @return {garafu.blogger.toc.printer.Category[]} Sorted list.
*/
garafu.blogger.toc.printer.LabelPrinter.prototype.sort = function (originalList) {
return originalList;
Expand Down
70 changes: 9 additions & 61 deletions src/blogger/toc/printer/titleprinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ goog.require('garafu.blogger.toc.printer.Entry')




// --------------------------------------------------------------------------------
// constructor
// --------------------------------------------------------------------------------
/**
* @class
*
* @public
* @constructor
* @param {garafu.blogger.toc.Settings} settings Settings object.
*/
garafu.blogger.toc.printer.TitlePrinter = function (settings) {
goog.base(this, settings);
Expand All @@ -32,7 +33,10 @@ goog.inherits(garafu.blogger.toc.printer.TitlePrinter, garafu.blogger.toc.printe
// method
// --------------------------------------------------------------------------------
/**
* Create DOM elements according to the feed data.
* @public
* @param {feed} feed Feed data.
* @return {DOMElement} Created feed DOM element.
*/
garafu.blogger.toc.printer.TitlePrinter.prototype.execute = function (feed) {
var entry = feed.entry || [];
Expand All @@ -48,6 +52,8 @@ garafu.blogger.toc.printer.TitlePrinter.prototype.execute = function (feed) {

/**
* @private
* @param {feed.entry} entry Feed entry data.
* @return {DOMElement} Created root DOM element of feed entry list.
*/
garafu.blogger.toc.printer.TitlePrinter.prototype.createList = function (entry) {
var ul, li, i, length;
Expand All @@ -70,70 +76,12 @@ garafu.blogger.toc.printer.TitlePrinter.prototype.createList = function (entry)

/**
* @private
* @param {feed.entry} entry Feed entry data.
* @param {DOMElement} Created feed entry DOM element.
*/
garafu.blogger.toc.printer.TitlePrinter.prototype.createEntry = function (entry) {

var entry = new garafu.blogger.toc.printer.Entry(this._settings, entry);
return entry.getRootElement();

////var settings = this._settings;
////var container = document.createElement('span');
////var published = document.createElement('span');
////var updated = document.createElement('span');
////var thumbnail = document.createElement('span');
////var title = document.createElement('a');
////var img;

////// Create thumbnail
////if (settings.thumbnail.enabled) {
//// thumbnail.appendChild(this.createThumbnail(entry.media$thumbnail));
//// thumbnail.className = 'poststoc-thumbnail';
////}

////// Create published date
////published.appendChild(document.createTextNode(entry.published.$t));
////published.className = 'poststoc-published';

////// Create update date
////updated.appendChild(document.createTextNode(entry.updated.$t));
////updated.className = 'poststoc-updated';

////// Create title
////title.appendChild(document.createTextNode(entry.title.$t));
////title.href = entry.link[entry.link.length - 1].href;
////title.className = 'poststoc-title';

////// Compose DOM element structure
////if (settings.thumbnail.enabled) {
//// container.appendChild(thumbnail);
////}
////container.appendChild(published);
////container.appendChild(updated);
////container.appendChild(title);
////container.className = 'poststoc-entry';

////return container;
};




/**
* @private
*/
garafu.blogger.toc.printer.TitlePrinter.prototype.createThumbnail = function (media) {
var img = document.createElement('img');

if (media) {
// Create image element.
img.src = media.url;
img.className = 'poststoc-thumbnail-image';
} else {
// Create no-image element.
img.src = this._settings.thumbnail.noImageURL;
img.className = 'poststoc-thumbnail-noimage';
}

return img;
};

7 changes: 6 additions & 1 deletion src/blogger/toc/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ goog.require('garafu.i18n.DateTimeFormat');


// --------------------------------------------------------------------------------
// garafu.blogger.toc.Settings class
// constructor
// --------------------------------------------------------------------------------

/**
* @class
* @putlic
Expand All @@ -39,6 +40,10 @@ garafu.blogger.toc.Settings = function () {



// --------------------------------------------------------------------------------
// method
// --------------------------------------------------------------------------------

/**
* Create default settings object.
*
Expand Down
Loading

0 comments on commit 010830c

Please sign in to comment.