JQuery and TypeScript – We Have a Big Problem With jquery.d.ts

This is a call to all my TypeScript connections. This is a call to all. We have a big problem with the official Definitely Typed definition for jQuery. The most fundamental definition for the JQuery interface is incorrect, as you can see in the snippet from jquery.d.ts below. We can fix it, but not withoutContinue reading “JQuery and TypeScript – We Have a Big Problem With jquery.d.ts”

Set a Minimum Font Size

This is just a little script I needed to use to increase text size conditionally. It only increases text below a minimum size and leaves everything else. (function () { var minFontSize = function () { $(“.content-zone *”).each(function () { var $this = $(this); if (parseInt($this.css(“fontSize”), 10) < 16) { $this.css({ “font-size”: “16px” }); }Continue reading “Set a Minimum Font Size”

A JavaScript resizeDone Event for jQuery

If you have ever handled a resize event in JavaScript, you will have noticed that when a user manually resizes their browser window by dragging the edges… you get a lot of events. This is because the resize event fires constantly as the user resizes the window. $window.on(‘resize’, function () { // Your code getsContinue reading “A JavaScript resizeDone Event for jQuery”

Bind Multiple Actions With Conditional Keys For Keyboard Events

I don’t talk about jQuery very much because I avoid it wherever possible. However, I was working on some custom inputs that needed to respond to a number of events, including specific keys on the keyboard. To achieve this, I wrote a little jQuery extension called “bindactions” that allows you to get it all inContinue reading “Bind Multiple Actions With Conditional Keys For Keyboard Events”

Using RequireJS and Jquery in TypeScript

A common question I have come across on various TypeScript communities is how to use RequireJS to load jQuery. Of course, you could substitute “jQuery” here for pretty much anything. Here is a simple example to explain the concept, which you can use to load pretty much anything you like using require.js. Downloads You’ll needContinue reading “Using RequireJS and Jquery in TypeScript”