-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript-portfolio.js
74 lines (55 loc) · 2.21 KB
/
script-portfolio.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var ALBUM_NAMES = ["Pete's Wedding", "Joe's Birthday Party", "Emily's Dance", "Beach Day", "Safari 2016"];
var BACKGROUND_PHOTOS = ['simmons', 'kresge', 'dome', 'river', 'stata'];
var IMAGE_SOURCE = "./images/"
var EXTENSION = ".jpg";
var UPLOAD_ICON_SOURCE = IMAGE_SOURCE + "plus.png";
var NUM_ALBUMS = ALBUM_NAMES.length;
var NUM_COLS = 4;
var MAX_WIDTH = 12;
//loads the columns into the page
function loadColumns(){
var albumsDiv = $("#albums");
var columnWidth = MAX_WIDTH/NUM_COLS;
for (i = 0; i < NUM_COLS; i++){
var col = $("<div id='albums-col-" + i + "' class='col-md-" + columnWidth + "'></div>");
albumsDiv.append(col);
}
}
//loads albums and the new album buttons
function loadAlbums(){
for (i = 0; i < NUM_ALBUMS; i++) {
var name = ALBUM_NAMES[i];
var backgroundSource = IMAGE_SOURCE + BACKGROUND_PHOTOS[i] + EXTENSION;
var album = $("<button id=$='album-" + i + "' class='album'></button>");//creates and sets the button to the right class
album.css("background","url(" + backgroundSource + ") no-repeat scroll 0 0 transparent");
var albumName = $("<div class='album-text'></div>");//creates the album-text within the albums
albumName.text(name);
album.append(albumName);
var column = $('#albums-col-' + i%NUM_COLS);
column.append(album);
}
//for adding the new album button
var addNewAlbumName = "Add new album";
var newAlbum = $("<button class = 'new-album'></button>");
var newAlbumName = $('<div class=album-text></div>');
newAlbumName.append(addNewAlbumName);
newAlbum.append(newAlbumName);
//attempts at making an upload icon
//var uploadIcon = $("<img src='" + UPLOAD_ICON_SOURCE + "'class='upload'>");
//newAlbum.append(uploadIcon);
var column = $("#albums-col-" + NUM_ALBUMS%NUM_COLS);
column.append(newAlbum);
}
$(document).on('click', '.album', function(evt){
window.location.href = "./album.html";
});
$(document).on('click', '.new-album', function(evt){
window.location.href = "./uploadphoto.html";
})
$(document).ready(function() {
loadColumns();
loadAlbums();
});
$(document).on('click', '#newAlbum', function(evt) {
loadNewAlbum();
});