Skip to content

Commit 91b0864

Browse files
committed
Updates
1 parent 4b268df commit 91b0864

File tree

4 files changed

+176
-178
lines changed

4 files changed

+176
-178
lines changed

install.json

Lines changed: 100 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,101 @@
11
{
2-
"resources":
3-
{
4-
"head": [{
5-
"type":"style",
6-
"src":"styles.css"
7-
}, {
8-
"type":"script",
9-
"src":"script.js"
10-
}]
11-
},
12-
13-
"options":
14-
{
15-
"properties":
16-
{
17-
"location":
18-
{
19-
"title": "Location",
20-
"type": "object",
21-
"format": "element",
22-
"order": 1
23-
},
24-
25-
"height":
26-
{
27-
"title":"Enter height",
28-
"type":"integer",
29-
"order":2,
30-
"default":250
31-
},
32-
33-
"images":
34-
{
35-
"title":"Accordion Setup",
36-
"type":"array",
37-
"maxItems":5,
38-
"order": 3,
39-
40-
"items":
41-
{
42-
"title":"Images",
43-
"type":"object",
44-
45-
"properties":
46-
{
47-
"url":
48-
{
49-
"title":"Upload",
50-
"type":"string",
51-
"format":"image"
52-
},
53-
54-
"title":
55-
{
56-
"title":"Title",
57-
"type":"string"
58-
},
59-
"caption":
60-
{
61-
"title":"Caption",
62-
"type":"string"
63-
},
64-
65-
"linkHref":
66-
{
67-
"title":"Link",
68-
"type":"string"
69-
}
70-
71-
},
72-
73-
"required":
74-
["image"]
75-
},
76-
77-
"default":
78-
[
79-
80-
{
81-
"image":"//www.filepicker.io/api/file/JRDnZJbWQByU3XBE4lXV",
82-
"title": "Nissan 370Z",
83-
"caption":"V6 Naturally Aspirated"
84-
},
85-
86-
{
87-
"image":"//www.filepicker.io/api/file/YIXvSnThSkKzYaw1fFag",
88-
"title": "Nissan GTR",
89-
"caption":"V6 Twin Turboed"
90-
},
91-
92-
{
93-
"image":"//www.filepicker.io/api/file/MXiHNErLQ8e6CWhtGmyw",
94-
"title": "Porsche 911 GT3",
95-
"caption":"Deadliest car known to man"
96-
},
97-
98-
{
99-
"image":"//www.filepicker.io/api/file/unSwaSXRhu86Ky5SqpMb",
100-
"title": "Toyota FT-1 Concept",
101-
"caption":"New Supra?"
102-
},
103-
104-
{
105-
"image":"//www.filepicker.io/api/file/kZZLHrqXSkC0cPvBeQqx",
106-
"title": "Lykan Hypersport",
107-
"caption":"3.4 Million Dollar Car"
108-
}
109-
]
110-
}
111-
}
112-
}
113-
}
2+
"resources":
3+
{
4+
"head":
5+
[
6+
{
7+
"type": "style",
8+
"src": "styles.css"
9+
},
10+
{
11+
"type": "script",
12+
"src": "script.js"
13+
}
14+
]
15+
},
16+
"options":
17+
{
18+
"properties":
19+
{
20+
"location":
21+
{
22+
"title": "Location",
23+
"type": "object",
24+
"format": "element",
25+
"order": 1
26+
},
27+
"height":
28+
{
29+
"title": "Enter height",
30+
"type": "integer",
31+
"order": 2,
32+
"default": 250
33+
},
34+
"images":
35+
{
36+
"title": "Accordion Setup",
37+
"type": "array",
38+
"maxItems":5,
39+
"order": 3,
40+
"items":
41+
{
42+
"title": "Images",
43+
"type": "object",
44+
"properties":
45+
{
46+
"url":
47+
{
48+
"title": "Upload",
49+
"type": "string",
50+
"format": "image"
51+
},
52+
"title":
53+
{
54+
"title": "Title",
55+
"type": "string"
56+
},
57+
"caption":
58+
{
59+
"title": "Caption",
60+
"type": "string"
61+
},
62+
"linkHref":
63+
{
64+
"title": "Link",
65+
"type": "string"
66+
}
67+
},
68+
"required": ["image"]
69+
},
70+
"default":
71+
[
72+
{
73+
"url": "//www.filepicker.io/api/file/JRDnZJbWQByU3XBE4lXV",
74+
"title": "Nissan 370Z",
75+
"caption": "V6 Naturally Aspirated"
76+
},
77+
{
78+
"url": "//www.filepicker.io/api/file/YIXvSnThSkKzYaw1fFag",
79+
"title": "Nissan GTR",
80+
"caption": "V6 Twin Turboed"
81+
},
82+
{
83+
"url": "//www.filepicker.io/api/file/MXiHNErLQ8e6CWhtGmyw",
84+
"title": "Porsche 911 GT3",
85+
"caption": "Deadliest car known to man"
86+
},
87+
{
88+
"url": "//www.filepicker.io/api/file/unSwaSXRhu86Ky5SqpMb",
89+
"title": "Toyota FT-1 Concept",
90+
"caption": "New Supra?"
91+
},
92+
{
93+
"url": "//www.filepicker.io/api/file/kZZLHrqXSkC0cPvBeQqx",
94+
"title": "Lykan Hypersport",
95+
"caption": "3.4 Million Dollar Car"
96+
}
97+
]
98+
}
99+
}
100+
}
101+
}

script.js

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
(function(){
22
// Our app needs modern browser support
33
if (!document.addEventListener && !document.documentElement.classList && !document.documentElement.getAttribute) return;
4-
4+
55
var ready = function(fn) {
66
if (document.readyState !== 'loading') {
77
fn();
88
} else {
99
document.addEventListener('DOMContentLoaded', fn);
1010
}
1111
};
12-
12+
1313
var options = INSTALL_OPTIONS;
14-
14+
1515
var styleEl = document.createElement('style');
1616
var styleString = '.eager-accordion { height:' + options.height + 'px }\n';
1717
for (var i = 0; i < options.images.length; i++) {
18-
styleString += '.eager-accordion ul li:nth-child(' + (i + 1) + ') { background-image: url("' + images[i] + '") }\n';
18+
styleString += '.eager-accordion ul li:nth-child(' + (i + 1) + ') { background-image: url("' + options.images[i].url + '") }\n';
1919
}
2020
styleEl.innerHTML = styleString;
2121
document.body.appendChild(styleEl);
22-
22+
2323
var buildAccordian = function(images) {
2424
/*
2525
<div class="eager-accordion">
@@ -36,37 +36,40 @@
3636
...
3737
</li>
3838
</ul>
39-
</div>
39+
</div>
4040
*/
41-
41+
4242
var div = document.createElement('div');
4343
div.classList.add('eager-accordion');
44-
45-
var ul = document.createElement('ul');
46-
47-
for (var i = 0; i < images.length; i ++) {
48-
var li = document.createElement('li'),
49-
liDiv = document.createElement('div'),
50-
anchor = document.createElement('a'),
51-
h2 = document.createElement('h2'),
52-
p = document.createElement('p');
44+
45+
var ul = document.createElement('ul');
46+
47+
for (var i = 0; i < images.length; i ++) {
48+
var li = document.createElement('li'),
49+
liDiv = document.createElement('div'),
50+
anchor = document.createElement('a'),
51+
h2 = document.createElement('h2'),
52+
p = document.createElement('p');
5353

5454
p.appendChild(document.createTextNode(images[i].caption));
5555
h2.appendChild(document.createTextNode(images[i].title));
56-
anchor.setAttribute('href', images[i].linkHref);
57-
56+
57+
if (images[i].linkHref) {
58+
anchor.setAttribute('href', images[i].linkHref);
59+
}
60+
5861
anchor.appendChild(h2);
5962
anchor.appendChild(p);
6063
liDiv.appendChild(anchor);
6164
li.appendChild(liDiv);
6265
ul.appendChild(li);
63-
}
66+
}
6467

65-
div.appendChild(ul);
66-
return div;
68+
div.appendChild(ul);
69+
return div;
6770
}
68-
71+
6972
ready(function(){
70-
Eager.createElement(options.location).appendChild(buildAccordian(options.images))
73+
Eager.createElement(options.location).appendChild(buildAccordian(options.images));
7174
});
7275
})();

styles.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.eager-accordion {
55
width: 100%;
66
max-width: 990px;
7-
/*height: 250px;*/
7+
min-height: 25px;
88
overflow: hidden;
99
margin: 50px auto;
1010
}
@@ -20,10 +20,10 @@
2020
vertical-align: bottom;
2121
position: relative;
2222
width: 16.666%;
23-
height: 250px;
2423
background-repeat: no-repeat;
2524
background-position: center center;
2625
transition: all 500ms ease;
26+
background-size: cover;
2727
}
2828
.eager-accordion ul li div {
2929
display: block;

0 commit comments

Comments
 (0)