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

Stops loading of blend-module when offset unavailable #654

Merged
merged 11 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from 9 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
9 changes: 4 additions & 5 deletions examples/demo.css
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,16 @@ h1 {
overflow: auto;
}

.no-border {
border: 0px;
}

.savesequencemsg{
display: none;
text-align: center;
}

#stepRemovedNotification {
#offset-notification,#remove-notification {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make a generic reusable .notification class here?

We can still leave the ids for hiding/showing uniquely. But to have a generic style seems nice and then it can be reused for more things later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

background-color: #808b96;
padding:4px;
color:white;
Expand All @@ -221,10 +224,6 @@ h1 {
margin-top: 20px;
}

.no-border {
border: 0px;
}

.i-over {
position: absolute;
left: 15px;
Expand Down
1 change: 1 addition & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<script src="lib/intermediateHtmlStepUi.js" charset="utf-8"></script>
<script src="lib/cache.js" charset="utf-8"></script>
<script src="demo.js" charset="utf-8"></script>
<script src="lib/notification.js" charset="utf-8"></script>
<!-- for crop module: -->
<script src="../node_modules/imgareaselect/jquery.imgareaselect.dev.js"></script>
<script src="gifshot.js" type="text/javascript"></script>
Expand Down
29 changes: 16 additions & 13 deletions examples/lib/defaultHtmlStepUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,7 @@
// The variable 'step' stores useful data like input and
// output values, step information.
// See documetation for more details.
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').fadeIn(500).delay(200).fadeOut(500);
}
function DefaultHtmlStepUi(_sequencer, options) {

options = options || {};
Expand Down Expand Up @@ -50,7 +40,7 @@ function DefaultHtmlStepUi(_sequencer, options) {

var tools =
'<div class="collapse"><div class="tools btn-group">\
<button confirm="Are you sure?" onclick="stepRemovedNotify()" class="remove btn btn btn-default">\
<button confirm="Are you sure?" class="remove btn btn btn-default">\
<i class="fa fa-trash"></i>\
</button>\
<button class="btn insert-step" style="margin-left:10px;border-radius:6px;background-color:#fff;border:solid #bababa 1.1px;" >\
Expand Down Expand Up @@ -140,6 +130,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
.appendChild(
parser.parseFromString(tools, "text/html").querySelector("div")
);
$(step.ui.querySelectorAll(".remove")).on('click', function() {onNotify('Step Removed','remove-notification')});
$(step.ui.querySelectorAll(".insert-step")).on('click', function() { util.insertStep(step.ID) });

// Insert the step's UI in the right place
Expand All @@ -157,7 +148,6 @@ function DefaultHtmlStepUi(_sequencer, options) {
}
$(step.ui.querySelector(".toggle")).on("click", (e) => {
var className = e.target.className;
console.log("ele "+element)
if(className=="fa fa-caret-up"){
$(step.ui.querySelectorAll(".collapse")).show();
e.target.className="fa fa-caret-down";
Expand Down Expand Up @@ -291,11 +281,24 @@ function DefaultHtmlStepUi(_sequencer, options) {
return step.imgElement;
}

function onNotify(msg,id){
if ($('#'+id).length == 0) {
var notification = document.createElement('span');
notification.innerHTML = ' <i class="fa fa-info-circle" aria-hidden="true"></i> ' + msg ;
notification.id = id;

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

$('#'+id).fadeIn(500).delay(200).fadeOut(500);
}

return {
getPreview: getPreview,
onSetup: onSetup,
onComplete: onComplete,
onRemove: onRemove,
onDraw: onDraw
onDraw: onDraw,
onNotify: onNotify
}
}
11 changes: 11 additions & 0 deletions examples/lib/notification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function produceNotification(msg) {
if ($('#notification-styles').length == 0) {
var notification = document.createElement('span');
notification.innerHTML = ' <i class="fa fa-info-circle" aria-hidden="true"></i> ' + msg ;
notification.id = 'notification-styles';

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

$('#notification-styles').fadeIn(500).delay(200).fadeOut(500);
}
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ if (program.saveSequence) {
for (var output in step.info.outputs) {
console.log("[" + program.step + "]: " + output + " = " + step[output]);
}
},
onNotify: function(msg) {
console.log('\x1b[36m%s\x1b[0m','🌟 '+msg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this overwrite the default in /src/ui/...? Just checking!

Copy link
Member Author

@Divy123 Divy123 Jan 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not much though providing a beautiful version in console.log
An effort to look it more like a notification.

}
});

Expand Down
6 changes: 6 additions & 0 deletions src/modules/Blend/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ module.exports = function Dynamic(options, UI, util) {
// save first image's pixels
var priorStep = this.getStep(options.offset);

if (priorStep.output === undefined) {
this.output = input;
UI.onNotify('Offset Unavailable','offset-notification');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, if we're going to use it like this, maybe best have it just be UI.notify(...), is that OK?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure..

callback();
}

getPixels(priorStep.output.src, function(err, pixels) {
options.firstImagePixels = pixels;

Expand Down
4 changes: 4 additions & 0 deletions src/ui/UserInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ module.exports = function UserInterface(events = {}) {
}
}

events.onNotify = events.onNotify || function(msg) {
console.log(msg);
}

return events;

}