Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCI task pull request #474

Merged
merged 8 commits into from
Nov 18, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions examples/demo.css
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,17 @@ h1 {
opacity:0.5;
color:#BABABA;
}

#stepRemovedNotification{
background-color: #808b96;
padding:4px;
color:white;
border-radius:3px;
font-size:2rem;
position:fixed;
bottom:8px;
left:45%;
min-width:14rem;
text-align:center;
display:none;
}
87 changes: 49 additions & 38 deletions examples/lib/defaultHtmlStepUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@
// The variable 'step' stores useful data like input and
// output values, step information.
// See documetation for more details.
function DefaultHtmlStepUi(_sequencer, options) {
function stepRemovedNotify() {
if ($('#stepRemovedNotification').length == 0) {
var notification = document.createElement('span');
notification.innerHTML = ' <i class="fa fa-info-circle" aria-hidden="true"></i> Step Removed ';
notification.id = 'stepRemovedNotification';

$('body').append(notification);
}

$('#stepRemovedNotification').DOMNotification.fadeIn(500).delay(200).fadeOut(500);
}

function DefaultHtmlStepUi(_sequencer, options) {
options = options || {};
var stepsEl = options.stepsEl || document.querySelector("#steps");
var selectStepSel = options.selectStepSel = options.selectStepSel || "#selectStep";
Expand Down Expand Up @@ -37,7 +48,7 @@ function DefaultHtmlStepUi(_sequencer, options) {

var tools =
'<div class="tools btn-group">\
<button confirm="Are you sure?" class="remove btn btn btn-default">\
<button confirm="Are you sure?" onclick="stepRemovedNotify()" class="stepRemoveButton remove btn btn btn-default">\
<i class="fa fa-trash"></i>\
</button>\
</div>';
Expand Down Expand Up @@ -66,7 +77,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
}
html += "</select>";
} else {
let paramVal = step.options[paramName] || inputDesc.default;
let paramVal = step.options[paramName] || inputDesc.default;
html =
'<input class="form-control target" type="' +
inputDesc.type +
Expand All @@ -76,19 +87,17 @@ function DefaultHtmlStepUi(_sequencer, options) {
paramVal +
'" placeholder ="' +
(inputDesc.placeholder || "");

if(inputDesc.type.toLowerCase() == "range")
{
html+=
'"min="'+

if (inputDesc.type.toLowerCase() == "range") {
html +=
'"min="' +
inputDesc.min +
'"max="'+
'"max="' +
inputDesc.max +
'"step="' +
inputDesc.step + '">'+'<span>'+paramVal+'</span>';
inputDesc.step + '">' + '<span>' + paramVal + '</span>';

}
else html+= '">';
} else html += '">';
}

var div = document.createElement("div");
Expand All @@ -109,8 +118,8 @@ function DefaultHtmlStepUi(_sequencer, options) {
step.ui.querySelector("div.details").appendChild(div);
}

function toggleSaveButton(){
$(step.ui.querySelector("div.details .btn-save")).prop("disabled",false);
function toggleSaveButton() {
$(step.ui.querySelector("div.details .btn-save")).prop("disabled", false);
}

$(step.ui.querySelectorAll(".target")).focus(toggleSaveButton);
Expand All @@ -122,15 +131,17 @@ function DefaultHtmlStepUi(_sequencer, options) {
function saveOptions() {
$(step.ui.querySelector("div.details"))
.find("input,select")
.each(function(i, input) {
.each(function (i, input) {
step.options[$(input).attr("name")] = input.value;
});
_sequencer.run({ index: step.index - 1 });
_sequencer.run({
index: step.index - 1
});

// modify the url hash
setUrlHashParameter("steps", _sequencer.toString());
// disable the save button
$(step.ui.querySelector("div.details .btn-save")).prop("disabled",true);
$(step.ui.querySelector("div.details .btn-save")).prop("disabled", true);
}

// on clicking Save in the details pane of the step
Expand All @@ -139,18 +150,18 @@ function DefaultHtmlStepUi(_sequencer, options) {

if (step.name != "load-image")
step.ui
.querySelector("div.details")
.appendChild(
parser.parseFromString(tools, "text/html").querySelector("div")
);
.querySelector("div.details")
.appendChild(
parser.parseFromString(tools, "text/html").querySelector("div")
);

stepsEl.appendChild(step.ui);

var inputs = document.querySelectorAll('input[type="range"]')
for(i in inputs)
inputs[i].oninput = function(e) {
e.target.nextSibling.innerHTML = e.target.value;
}
for (i in inputs)
inputs[i].oninput = function (e) {
e.target.nextSibling.innerHTML = e.target.value;
}
}

function onDraw(step) {
Expand All @@ -164,8 +175,8 @@ function DefaultHtmlStepUi(_sequencer, options) {

step.imgElement.src = step.output;
var imgthumbnail = step.ui.querySelector(".img-thumbnail");
for(let index=0; index < step.linkElements.length; index++) {
if(step.linkElements[index].contains(imgthumbnail))
for (let index = 0; index < step.linkElements.length; index++) {
if (step.linkElements[index].contains(imgthumbnail))
step.linkElements[index].href = step.output;
}

Expand All @@ -174,7 +185,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
return output.split("/")[1].split(";")[0];
}

for(let index=0; index < step.linkElements.length; index++) {
for (let index = 0; index < step.linkElements.length; index++) {
step.linkElements[index].download = step.name + "." + fileExtension(step.output);
step.linkElements[index].target = "_blank";
}
Expand All @@ -185,18 +196,18 @@ function DefaultHtmlStepUi(_sequencer, options) {
var outputs = _sequencer.modulesInfo(step.name).outputs;
for (var i in inputs) {
if (step.options[i] !== undefined) {
if (inputs[i].type.toLowerCase() === "input")
step.ui.querySelector('div[name="' + i + '"] input').value =
step.options[i];
if (inputs[i].type.toLowerCase() === "select")
step.ui.querySelector('div[name="' + i + '"] select').value =
step.options[i];
}
if (inputs[i].type.toLowerCase() === "input")
step.ui.querySelector('div[name="' + i + '"] input').value =
step.options[i];
if (inputs[i].type.toLowerCase() === "select")
step.ui.querySelector('div[name="' + i + '"] select').value =
step.options[i];
}
}
for (var i in outputs) {
if (step[i] !== undefined)
step.ui.querySelector('div[name="' + i + '"] input').value =
step[i];
step[i];
}
}
}
Expand All @@ -216,4 +227,4 @@ function DefaultHtmlStepUi(_sequencer, options) {
onRemove: onRemove,
onDraw: onDraw
}
}
}