-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.js
51 lines (49 loc) · 1.66 KB
/
project.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function Project(projectCollection, data){
this.projectCollection = projectCollection;
this.projectCollection.body = $('body');
this.data = data;
this.makeDOM();
}
Project.prototype.makeHTML = function(){
return [
'<div class="project">',
'<div>',
'<h2 class="title"><span>', this.data.title,'</span></h2>',
'<div class="slide"',
'<div class="about">',
this.data.about,
'</div>',
'<span class="example-url">',
'<a href="', this.data.exampleUrl, '">Пример</a> · ',
'</span>',
'<span class="source-url">',
'<a href="', this.data.sourceUrl, '">Исходный код</a> · ',
'</span>',
'<span class="widget-url">',
this.data.widgetUrl != '#' ?
['<a href="', this.data.widgetUrl, '">Яндекс виджет</a>'].join('') : '',
'</span>',
'</div>',
'</div>',
'</div>',
].join('');
};
Project.prototype.makeDOM = function(){
this.elem = $(this.makeHTML()).appendTo(this.projectCollection.body);
var _this = this;
$.each({
title: '.title',
slide: '.slide',
about: '.about',
exampleUrl: '.example-url',
sourceUrl: '.source-url',
widgetUrl: '.widget-url'
}, function(k, v){
_this[k] = _this.elem.find(v);
});
/*
this.title.click(function(){
_this.projectCollection.makeCurrent(this);
});
*/
};