2013-05-11 20:44:25 +04:00
|
|
|
/*globals exports */
|
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var FancyFirstChar;
|
|
|
|
|
|
|
|
FancyFirstChar = function (ghost) {
|
|
|
|
this.ghost = function () {
|
|
|
|
return ghost;
|
|
|
|
};
|
|
|
|
};
|
2013-05-29 04:10:39 +04:00
|
|
|
|
2013-05-11 20:44:25 +04:00
|
|
|
FancyFirstChar.prototype.init = function () {
|
|
|
|
this.ghost().registerFilter('prePostsRender', function (posts) {
|
|
|
|
var post,
|
|
|
|
originalContent,
|
|
|
|
newContent,
|
|
|
|
firstCharIndex = 0;
|
|
|
|
|
|
|
|
console.log('got content to filter', posts);
|
|
|
|
|
|
|
|
for (post in posts) {
|
|
|
|
if (posts.hasOwnProperty(post)) {
|
|
|
|
originalContent = posts[post].content;
|
|
|
|
if (originalContent.substr(0, 1) === '<') {
|
|
|
|
firstCharIndex = originalContent.indexOf('>') + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
newContent = originalContent.substr(0, firstCharIndex);
|
|
|
|
newContent += '<span class="fancyChar">';
|
|
|
|
newContent += originalContent.substr(firstCharIndex, 1);
|
|
|
|
newContent += '</span>';
|
|
|
|
newContent += originalContent.substr(firstCharIndex + 1, originalContent.length - firstCharIndex - 1);
|
|
|
|
|
|
|
|
posts[post].content = newContent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return posts;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
FancyFirstChar.prototype.activate = function () {};
|
|
|
|
FancyFirstChar.prototype.deactivate = function () {};
|
|
|
|
|
2013-05-29 04:10:39 +04:00
|
|
|
|
|
|
|
|
2013-05-11 20:44:25 +04:00
|
|
|
module.exports = FancyFirstChar;
|
|
|
|
}());
|