Wednesday, September 23, 2015

Building a WordPress Carousel Plugin: Part 3

Without styling, the WordPress carousel we've built in the first part of this tutorial is just a list of items, but it is at least useful, in the sense that they're all visible. The CSS we added in part two of this tutorial enhanced the display of the carousel, but now the problem is that only the first item is shown to the user and there's no way to display the rest of the items.

We added arrows to our carousel, to allow the user to navigate between the different items, and now it's time to make them usable, with a bit of JavaScript.

In the continuation of this tutorial, we'll learn how to properly include our script, then we'll write a script that will launch a function which animates the items when the user hits an arrow.

Linking a JavaScript File

Here we'll use JavaScript to make our arrows useful. As for the CSS part, create a new file. I called it carousel.js and placed it in the root of the plugin's folder.

We need to indicate to WordPress that we are using the JavaScript file. To do this, we'll use the wp_enqueue_script() function.

Continue reading %Building a WordPress Carousel Plugin: Part 3%


by Jérémy Heleine via SitePoint

PostCSS Deep Dive: What You Need to Know

Demystifying RegEx with Practical Examples

A regular expression is a sequence of characters used for parsing and manipulating strings. They are often used to perform searches, replace substrings and validate string data. This article provides tips, tricks, resources and steps for going through intricate regular expressions.

regular expression

There are many books, articles, websites and the PHP official documentation that explain regular expressions, so instead of writing another explanation I’d prefer to go straight to more practical examples. You can find a useful cheat sheet at this link.

Along with a host of useful resources, there is also a conference video by Lea Verou at the bottom of this post - it’s a bit long, but it’s excellent in breaking down RegEx.

How to Build a Good Regex

Regular expressions are often used in the developer’s daily routine - log analysis, form submission validation, find and replace, and so on. That’s why every good developer should know how to use them, but what is the best practice to build a good regex?

1. Define a Scenario

Using natural language to define the problem will give you a better idea of the approach to use. The words could and must, used in a definition, are useful to describe mandatory constraints or assertions.

Below is an example:

  • The string must start with ‘h’ and finish with ‘o’ (e.g. hello, halo).
  • The string could be wrapped in parentheses.

2. Develop a Plan

After having a good definition of the problem, we can understand the kind of elements that are involved in our regular expression:

  • What are the types of characters allowed (word, digit, new line, range, …)?
  • How many times must a character appear (one or more, once, …)?
  • Are there some constraints to follow (optionals, lookahead/behind, if-then-else, …)?

Continue reading %Demystifying RegEx with Practical Examples%


by Nicola Pietroluongo via SitePoint

Getting Started With Google Maps for Android: Basics

How Pointer Events Will Make Cross-Browser Touch Support Easy

This article is part of a web development series from Microsoft. Thank you for supporting the partners who make SitePoint possible.

I often get questions from developers like, “with so many touch-enabled devices on phones and tablets, where do I start?” and “what is the easiest way to build for touch-input?” Short answer: “It’s complex.” Surely there’s a more unified way to handle multi-touch input on the web – in modern, touch-enabled browsers or as a fallback for older browsers. In this article I’d like to show you some browser experiments using Pointers – an emerging multi-touch technology and polyfills that make cross-browser support, well less complex. The kind of code you can also experiment with and easily use on your own site.

First of all, many touch technologies are evolving on the web – for browser support you need to look the iOS touch event model and the W3C mouse event model in additional to at MSPointers, to support all browsers. Yet there is growing support (and willingness) to standardize. In September 2012, Microsoft submitted MSPointers to the W3C for standardization and in February 2015, we’ve reached W3C Recommendation: http://ift.tt/162VJPq. The MS Open Tech team also released an initial Pointer Events prototype for Webkit and recently, Mozilla has announced support for Pointer Events in Firefox Nightly!

The reason why I experiment with Pointer Events is not based on device share – it’s because Microsoft’s approach to basic input handling is quite different than what’s currently available on the web and it deserves a look for what it could become. The difference is that developers can write to a more abstract form of input, called a “Pointer.” A Pointer can be any point of contact on the screen made by a mouse cursor, pen, finger, or multiple fingers. So you don’t waste time coding for every type of input separately.

[author_more]

If you’re running IE10, you’ll need to prefix the API or use our polyfill library Hand.js. You’ll find the original article with prefixes here: Unifying touch and mouse: how Pointer Events will make cross-browsers touch support easy

The Concepts

We will begin by reviewing apps running inside Internet Explorer 11, Microsoft Edge, or Firefox Nightly which exposes the Pointer Events API and then solutions to support all browsers. After that, we will see how you can take advantage of IE/MS Edge gestures services that will help you handling touch in your JavaScript code in an easy way. As Windows 8.1/10 and Windows Phone 8.1/Mobile 10 share the same browser engine, the code & concepts are identical for both platforms. Moreover, everything you’ll learn on touch in this article will help you do the very same tasks in Windows Store apps built with HTML5/JS, as this is again the same engine that is being used.

The idea behind the Pointer is to let you addressing mouse, pen & touch devices via a single code base using a pattern that match the classical mouse events you already know. Indeed, mouse, pen & touch have some properties in common: you can move a pointer with them and you can click on element with them for instance. Let’s then address these scenarios via the very same piece of code! Pointers will aggregate those common properties and expose them in a similar way than the mouse events.

Continue reading %How Pointer Events Will Make Cross-Browser Touch Support Easy%


by David Rousset via SitePoint

Daniel Powell

opl-small

Minimal personal page for 'Daniel Powell' featuring an awesome "shaka" hand gesture that is only revealed when hovering your cursor over the canvas area.

by Rob Hope via One Page Love

Using XAML Controls to Design Windows Phone Apps

Building an app is a cool thing to know, but it may not be easy for everyone. I try to keep articles as simple as possible so that everyone can understand, even those who are on their first day programming. There’s no need to feel shy if you don’t know much yet! Don’t get mad at yourself, everything will come one step at a time.

With this in mind, I decided to write an article about how to build a simple Windows Phone app with little coding knowledge.

If you are wondering How can I build an app without writing any code?, the answer is by designing it. In my opinion it’s easier to learn how to design first, and then add the code to connect the elements logically. With the tools offered today, it’s as simple as drag and drop.

Visual Studio has lots of XAML controls ready to use for designing a beautiful new app. Let’s get started.

Continue reading %Using XAML Controls to Design Windows Phone Apps%


by deivi taka via SitePoint