-
Notifications
You must be signed in to change notification settings - Fork 7.6k
#11801 - Restricted Font Size Input To Only Valid Entries #13123
Changes from 2 commits
df77e15
7689017
2143187
f7a0cab
01ae3a8
8131ef4
337946f
9a6f12c
a5253e7
8839926
fdfdcc5
febb9cb
e337dc7
737f086
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,20 +30,20 @@ <h1 class="dialog-title">{{Strings.THEMES_SETTINGS}}</h1> | |
<div class="control-group"> | ||
<label class="control-label">{{Strings.FONT_SIZE}}:</label> | ||
<div class="controls"> | ||
<input type="text" data-target="fontSize" value="{{settings.fontSize}}"> | ||
<input type="text" id="font-size-input" data-target="fontSize" value="{{settings.fontSize}}"> | ||
</div> | ||
</div> | ||
|
||
<div class="control-group"> | ||
<label class="control-label">{{Strings.FONT_FAMILY}}:</label> | ||
<div class="controls"> | ||
<input type="text" data-target="fontFamily" value="{{settings.fontFamily}}"> | ||
<input type="text" id="font-family-input" data-target="fontFamily" value="{{settings.fontFamily}}"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't need to introduce id's here, you can use |
||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
<div class="modal-footer"> | ||
<button class="dialog-button btn" data-button-id="cancel">{{Strings.CANCEL}}</button> | ||
<button class="dialog-button btn primary" data-button-id="save">{{Strings.DONE}}</button> | ||
<button class="dialog-button btn primary" id="done" data-button-id="save">{{Strings.DONE}}</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. id |
||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,7 +100,24 @@ define(function (require, exports, module) { | |
var attr = $target.attr("data-target"); | ||
newSettings[attr] = $target.is(":checked"); | ||
}) | ||
.on("input", "[data-target]:text", function () { | ||
.on("input", "#font-size-input", function () { | ||
var $target = $(this); | ||
var $input = $target.val(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
var validInput = /^[\d\.]+(p|px|e|em){0,1}$/g; | ||
var btn = document.getElementById("done"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add |
||
|
||
// Make sure that the font size is expressed in terms we can handle (px or em). If not, 'done' button disabled until input corrected. | ||
|
||
if ($input.search(validInput) === -1) { | ||
($input.length === 0) ? btn.disabled=false : btn.disabled=true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return false; | ||
}else{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if(btn.disabled) btn.disabled = false; | ||
var attr = $target.attr("data-target"); | ||
newSettings[attr] = $input; | ||
} | ||
}) | ||
.on("input", "#font-family-input", function () { | ||
var $target = $(this); | ||
var attr = $target.attr("data-target"); | ||
newSettings[attr] = $target.val(); | ||
|
@@ -126,7 +143,7 @@ define(function (require, exports, module) { | |
// Figure out if the setting is in the ViewCommandHandlers, which means it is | ||
// a font setting | ||
setterFn = "set" + setting[0].toLocaleUpperCase() + setting.substr(1); | ||
if (typeof ViewCommandHandlers[setterFn] === 'function') { | ||
if (typeof ViewCommandHandlers[setterFn] === "function") { | ||
ViewCommandHandlers[setterFn](newSettings[setting]); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to revert this change (it applies automatically after doing npm install, but we don't want it in PRs)