Categories
Programming

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 without […]

Categories
Programming

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” }); } […]

Categories
Programming

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 gets […]

Categories
Programming

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 in […]

Categories
Process

Hide Trello Columns

If you have seen the average Trello board that has evolved over any length of time, you will have noticed they can suffer a little from column explosion. Fear not. You can use this short script to get rid of the boring columns with a single click. All you need to do is adjust the […]

Categories
Programming

The Novice View of Jquery

I’m not picking on jQuery in particular here. I chose it because it is no doubt the biggest and most widely used example of a JavaScript library. So when I mention jQuery here, be in no doubt that this applies to Prototype, Mootools, and any other framework that makes your JavaScript easier to write. And […]

Categories
Programming

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 need […]

Categories
Programming

Optimising Your jQuery

jQuery is taking the JavaScript world by storm, but because it makes life so easy, it also makes it easy to forget about the amount of work you are asking the browser to do. This is especially important if you are performing an action against multiple elements, in a loop or as part of an […]

Categories
Programming

jQuery Get Text While Excluding Children

I recently came across a problem while obtaining the text from an HTML label element, based on the fact that I knew the form element that related to the label. This came about because there are two valid ways to use a label. The first way is to use the “for” attribute on the label […]