Newer
Older
$(document).ready(function()
{
accordion: false // A setting that changes the collapsible behavior to expandable instead of the default accordion style
$('.milestone-title').click(function()
var $header = $(this);
//getting the next element
var $content = $header.next();
//open up the content needed - toggle the slide- if visible, slide up, if not slidedown.
$content.slideToggle(200);
//expand specific milestones on first load
var initialExpandedMilestones = document.getElementsByClassName('init-as-expanded');
for(var i = 0; i < initialExpandedMilestones.length; i++)
{
$(initialExpandedMilestones[i]).slideToggle(200);
}
//reacts to resize event of card and calls createTrainMap to adjust circles
//https://github.com/marcj/css-element-queries
var entries = document.getElementsByClassName('milestone');
$('.button-save-roadmap').click(function()
{
editRoadmap(this.dataset.id, $('#project-name').val());
});
$('.button-delete-roadmap').click(function()
{
var r = confirm("Do you really want to delete this roadmap?");
if(r == true)
{
deleteRoadmap(this.dataset.id);
}
});
});
function isNull(object)
{
if(object != "" && object != undefined)
{
return false;
}
else
{
return true;
}
}
function hideElement(element, value)
{
if(value == true)
{
element.classList.add("hide");
}
else
{
if(element.classList.contains("hide"))
{
element.classList.remove("hide");
}
}
}
var entries = document.getElementsByClassName('milestone');

Robert Goldmann
committed
var smallLines = document.getElementsByClassName('train-line-small');

Robert Goldmann
committed
var height = entries[i].offsetHeight;
lines[i].style.height = (height - 15) + "px";
smallLines[i].style.height = (height - 2) + "px";
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
}
function editRoadmap(roadmap_ID, projectname)
{
if(isNull(projectname))
{
alert("Project Name shouldn't be empty!");
return;
}
if(roadmap_ID == "0")
{
//insert new roadmap
$.post('../admin/helper/edit-roadmap.php',
{
"project-name": projectname,
"edit": "false"
}, function(data, error)
{
data = data.toString().trim();
switch(data)
{
case "error":
alert('An error occurred');
break;
case "error-edit":
alert('An error occurred while editing the roadmap with the ID ' + roadmap_ID);
break;
case "error-insert":
alert('An error occurred while inserting the new roadmap');
break;
default:
window.location.href = "../admin/admin-roadmaps.php";
break;
}
});
}
else
{
//edit existing roadmap
$.post('../admin/helper/edit-roadmap.php',
{
"ID": roadmap_ID,
"project-name": projectname,
"edit": "true"
}, function(data, error)
{
data = data.toString().trim();
switch(data)
{
case "error":
alert('An error occurred');
break;
case "error-edit":
alert('An error occurred while editing the roadmap with the ID ' + roadmap_ID);
break;
case "error-insert":
alert('An error occurred while inserting the new roadmap');
break;
default:
window.location.href = "../admin/admin-roadmaps.php";
break;
}
});
}
}
function deleteRoadmap(roadmap_ID)
{
$.post('../admin/helper/delete-roadmap.php',
{
"roadmap_ID": roadmap_ID,
}, function(data, error)
{
data = data.toString().trim();
if(data != "error")
{
window.location.href = "../admin/admin-roadmaps.php";
}
else
{
alert('An error occurred while deleting the roadmap with the ID ' + roadmap_ID);
}
});