You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 lines
1.5 KiB

var EXPO = EXPO || {}; //isolated namespace
EXPO.place = EXPO.place || {};
if (EXPO.place.object){
console.warn('WARNING: EXPO.place.object is already defined!');
}else {
EXPO.place.object = (function () {
// variables
var that = {},
Article = function (opt, it) {
this.$annotation = $('.'+opt.annotationClass, it);
this.$fullPart = $('.'+opt.fullPartClass, it);
this.$readMore = $('.'+opt.readMoreClass, it);
this.cutLength = opt.cutLength;
this.fullText;
this.init();
};
Article.prototype = {
init: function () {
var self = this,
anText = this.$annotation.html().slice(0,self.cutLength);
this.fullText = this.$annotation.html();
this.$annotation.html(anText+'...');
this.$fullPart.html(this.fullText);
},
showMore: function () {
this.$readMore.hide();
this.$annotation.hide();
this.$fullPart.removeClass('hidden');
},
_cutAnnotation: function () {
}
};
that.opt = {}; //свойства по умолчанию
//private
$(function () {
});
// methods
//инициализация общих свойств
that.init = function (options) {
$.extend(this.opt, options);
var self = this;
this.articles = [];
//readmore on Articles
$('.'+self.opt.article.class).each(function () {
var article = new Article(self.opt.article, this);
article.$readMore.on('click', function () {
article.showMore();
});
self.articles.push(article);
});
};
return that;
}());
}