Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Prevent negative values for Size and Border width #15

Merged
merged 4 commits into from

2 participants

Rafaël Blais Masson Simon Højberg
Rafaël Blais Masson

No description provided.

public/js/lib/views/arrow_configuration_view.js
@@ -98,9 +98,12 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {};
val = parseInt(target.val()),
increment = ev.keyCode == 38 ? 1 : -1,
multiply = ev.shiftKey ? 10 : 1
Simon Højberg Owner
hojberg added a note

a missing , :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Simon Højberg
Owner

sweet, thanks!

Simon Højberg hojberg merged commit 1a941e6 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
9 public/js/lib/views/arrow_configuration_view.js
View
@@ -97,10 +97,13 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {};
var target = $(ev.currentTarget),
val = parseInt(target.val()),
increment = ev.keyCode == 38 ? 1 : -1,
- multiply = ev.shiftKey ? 10 : 1
+ multiply = ev.shiftKey ? 10 : 1,
+ newVal = val + increment * multiply;
- target.val(val + increment * multiply);
- this._updateModel(ev)
+ if (newVal < 0) newVal = 0;
+
+ target.val(newVal);
+ this._updateModel(ev);
}
};
7 public/js/spec/views/arrow_configuration_view_spec.js
View
@@ -87,12 +87,15 @@ describe("CSSArrowPlease.ArrowConfigurationView", function () {
arrowAttr = object.arrowAttr;
$.each(keystrokes, function (i, keystroke) {
- var keydown = $.Event('keydown')
+ var keydown = $.Event('keydown'),
+ expectedVal = defaultVal + keystroke.increment;
keydown.keyCode = keystroke.key;
keydown.shiftKey = keystroke.shift;
elem.val(defaultVal).trigger(keydown);
- expect( arrow.get(arrowAttr) ).toEqual(defaultVal + keystroke.increment);
+
+ if (expectedVal < 0) expectedVal = 0;
+ expect( arrow.get(arrowAttr) ).toEqual(expectedVal);
});
});
});
Something went wrong with that request. Please try again.