-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsnapshot_ecosystem.php
161 lines (134 loc) · 4.86 KB
/
snapshot_ecosystem.php
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
namespace greenbase;
include 'get_config.php';
?>
<script src="<?php echo Config::$greenbase_root ?>/js/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="<?php echo Config::$greenbase_root ?>/js/masonry.pkgd.min.js"></script>
<script src="<?php echo Config::$greenbase_root ?>/js/imagesloaded.pkgd.min.js"></script>
<link rel="stylesheet" href="<?php echo Config::$greenbase_root ?>/css/reset.css">
<link rel="stylesheet" href="<?php echo Config::$greenbase_root ?>/css/snapshot.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.2/modernizr.js"></script>
<link href='<?php echo Config::$greenbase_root ?>/css/Roboto.css' rel='stylesheet' type='text/css'>
<ul id="nav">
<li class="navItem navOn" id="all">All</li>
</ul>
<div id="ecosystem"></div>
<div class="se-pre-con"></div>
<script>
function makeNavClicks(){
$( "#nav .navItem" ).click(function() {
clickedFocus = $(this).attr("id");
$( "#nav .navItem" ).removeClass("navOn");
$(this).addClass("navOn");
$.each( $('.eco'), function( key, value ) {
if (clickedFocus==="all"){
$(this).css("display","block");
} else if ($(this).data('focusid')==clickedFocus){
$(this).css("display","block");
}else{
$(this).css("display","none");
}
});
makeEcosystem(clickedFocus);
});
}
function makeToolTips(){
$( '.eco' ).tooltip({
items: "[data-details]",
position: {
my: "center bottom-20",
at: "center top",
using: function( position, feedback ) {
$( this ).css( position );
$( "<div>" )
.addClass( "arrow" )
.addClass( feedback.vertical )
.addClass( feedback.horizontal )
.appendTo( this );
}
},
content: function() {
var element = $( this );
if ( element.is( "[data-details]" ) ) {
var str = $(this).data("details");
str = decodeURIComponent(str);
data = JSON.parse(str);
name = data["name"];
description = data["description"];
focus = data["focus"];
org_type = data["org_type"];
b = '<b>'+ name +'</b><br><br>';
b += '<p>'+ description +'</p><br>';
b += 'Focus: ' + focus + '<br>';
b += 'Org Type: ' + org_type + '<br>';
b += '';
return b;
}
}
});
}
function makeEcosystem(focusId){
if(focusId=="all"){
$("#ecosystem").css(
{"width":"90%","margin":"24px auto","border":"1px solid grey","padding":"20px"}
);
}else{
$("#ecosystem").css(
{"width":"50%","margin":"24px auto","border":"1px solid grey","padding":"20px"}
);
}
var container = document.querySelector('#ecosystem');
var msnry;
// initialize Masonry after all images have loaded
imagesLoaded( container, function() {
msnry = new Masonry( container, {
itemSelector: '.eco',
columnWidth: 50
});
$(".se-pre-con").fadeOut("slow");;
$("#ecosystem div.eco img.logo").css("opacity","1");
});
$('#ecosystem').append('<div style="clear:both"></div>');
}
$(function() {
focusIds=[];
orgTypeIds=[];
// perform request for list of orgs
var jqxhr = $.getJSON( "<?php echo Config::$greenbase_root ?>/snapshot_orgs.php", function(data) {
}).done(function(data) {
// for each org, create a focus id, org type id, and push each into an array
$.each( data, function( key, value ) {
focusId = value.focus.replace(/\W/g,""); // strip non-alphas
focusIds.push(focusId);
orgTypeId = value.org_type.replace(/\W/g,""); // strip non-alphas
orgTypeIds.push(orgTypeId);
// strip single quotes - breaks quoted vals - fix later
var details = JSON.stringify(value);
details = details.replace("'","");
details = encodeURIComponent(details);
// create org elemtns with data type set for focus id
b = '<div data-focusid="' + focusId + '" data-orgtype="' + orgTypeId + '" class="eco" data-details="' + details + '">';
b += '<img class="logo" style="opacity:0;" src="<?php echo Config::$greenbase_root ?>/' + value.logo + '" />';
b += '</div>';
$( '#ecosystem' ).append( b );
});
// unique the array of focus ids
focusIds = focusIds.filter(function(elem, pos) {
return focusIds.indexOf(elem) == pos;
});
// unique the array of org types
orgTypeIds = orgTypeIds.filter(function(elem, pos) {
return orgTypeIds.indexOf(elem) == pos;
});
makeEcosystem("all");
$.each( focusIds, function( key, value ) {
$('#nav').append('<li class="navItem" id="'+ value +'">' + value + '</li>');
});
$('#nav').append('<div style="clear:both"></div>');
makeNavClicks();
makeToolTips();
});
});
</script>