Wednesday, December 23, 2015

Sharer.js: Create custom Social Share elements

Sharer.js is a very tiny js lib (~1.6kb) to create custom social share components on DOM elements for your website. No dependencies.

The post Sharer.js: Create custom Social Share elements appeared first on jQuery Rain.


by Admin via jQuery Rain

Tabby : Simple Toggle Tabs

Tabby gives you lightweight, simple toggle tabs. It’s easy to install and can be used for buttons, lists, and more.

The post Tabby : Simple Toggle Tabs appeared first on jQuery Rain.


by Admin via jQuery Rain

2015 Photography Trends - #infographic

2015 Photography Trends: The Selfie Days Are Over. What's Popular Now - #infographic

EyeEm, an online photographic community, have carried out an end of year analysis from within their community of 15 million photographers, spanning from 150 countries. The trends that evolved within 2015 bode well for the art of photography, with there being an increase in true photographic styles such as street photography and an identifiable decrease in social phenomenons such as the ‘selfie’.

With the year of 2015 coming to a close, EyeEm wanted to share learnings from the year with their community as well as anyone with an affinity for photography.

The infographic is split into sections where they first outline the growth/decline of the photographic subjects. EyeEm then split the world map to show you which types of photography are most prominent around the globe. EyeEm then use their revolutionary image recognition technology, EyeEm Vision, to show their community which country’s photographs ranked aesthetically higher. Finally, EyeEm share which devices have been most used whilst shooting.

by Guest Author via Digital Information World

Launch Your Career in Project Management with This $39 Bundle

New year, new career? This eduCBA project management and quality management course bundle will help make it happen. Get it at SitePoint Shop for $39. Valued at $2,249, this bundle is packed with more than 1,450 hours of training for essential project management and quality management certifications like PRINCE2, CBAP, PMP, and more. You’ll get […]

Continue reading %Launch Your Career in Project Management with This $39 Bundle%


by SitePoint Offers via SitePoint

The Joys of Block Scoping with ES6

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

Brendan Eich invented JavaScript in 10 days around May 6-15 in 1995. The language, originally called Mocha, started as a simple client-side scripting language. O'Reilly's history on the language details the context at the time the language was invented:

Eich eventually decided that a loosely-typed scripting language suited the environment and audience, namely the few thousand web designers and developers who needed to be able to tie into page elements (such as forms, or frames, or images) without a bytecode compiler or knowledge of object-oriented software design.

JavaScript was born in a time when the web was very different but would eventually become one of the most ubiquitous programming languages in use. Few could have predicted how popular it would become. Naturally, then, JavaScript has some design flaws that have frustrated and confused developers since its inception.

One of the common complaints has been Javascript's lack of block scope. Unlike other popular languages like C or Java, blocks ({...}) in JavaScript (pre-ES6) do not have scope. Variables in JavaScript are scoped to their nearest parent function or globally if there is no function present.

When asked why JavaScript has no block scopes, Brendan Eich’s answer is pretty straightforward: there wasn’t enough time to add block scopes.

Brendan Eich series of tweets

Thankfully, JavaScript descended from C/C++/Java, and was future-proofed for adding block scoping later as Eich explains in this series of tweets.

And now, finally, ECMAScript 6 (ES6) is here and among many things, it gives us block scoping via the two new ES6 variable keywords, let and const. Support for let/const is still limited to Edge, Chrome, and Firefox but more browsers will likely support it soon.

This post will explain why const and let are helpful and how they are used.

Make Love Not Var
source: http://ift.tt/1OohHoM

The Challenges of Using var

Before introducing const and let, it’s worth discussing why they are helpful or necessary in the first place. Var has been the only keyword for variables in JavaScript up until now but it has several drawbacks.

Var scoping is confusing for devs from other languages

The scope of var is confusing for developers coming from other languages. It’s quite easy for them to unintentionally cause bugs in code that uses if blocks or for loops. Variable declaration in ES5 and below doesn’t work in the way they would expect. Given JavaScript’s popularity, developers from other languages sometimes have to write JavaScript, and therefore variable scoping, which is easier to understand, would be helpful for them.

Global vs. local confusion with var

When writing JS using var, it’s difficult to immediately discern which variables are scoped locally vs. globally. It’s very easy to accidentally create a variable on the global object in JavaScript. This generally doesn’t affect simple demo apps but can cause problems for enterprise level applications as team members accidentally obliterate each other's variables.

Confusing workaround patterns

The lack of clear global vs. local scope differentiation in JavaScript has forced developers to come up with patterns like the IIFE (Immediately Invoked Function Expression). This is an awkward workaround to the lack of block scope. It’s also a way to avoid attaching var-declared variables to the global object.


(function(){
  // code here
}());

If you’re not a seasoned Javascript developer, this pattern makes little sense. What is going on here? What are all those parentheses? Why doesn’t that function have a name? Block scoping should lessen the need for workaround design patterns like this.

Continue reading %The Joys of Block Scoping with ES6%


by Kyle Pennell via SitePoint

Win an Apple Music & Beats by Dre Package worth $549

Maybe it’s the holidays or maybe it’s that we started the day with a shower beer…whatever it is, we’re feeling generous. And you can benefit. Enter our Apple Music and Beats by Dre giveaway for a chance to win a package with $549 at SitePoint Shop. We’re choosing one lucky winner to get a set […]

Continue reading %Win an Apple Music & Beats by Dre Package worth $549%


by SitePoint Offers via SitePoint

Front-end Tools: Some of My Favorite Finds of 2015

We’re just about at the end of 2015 and I’m sure you’d all agree it’s been another year jam-packed with new tools for web design and development. While doing my newsletter I’ve come across lots of interesting things, so I thought it would be cool to summarize some of my favorite finds in a year-end post.

Before I begin, I should mention:

  • I can’t necessarily vouch for the quality or security of any of these tools.
  • Just because I discovered them in 2015, doesn’t mean they were built in 2015 (some of them are much older than that).
  • They aren’t in any particular order.
  • Not all of these are necessarily “front-end” tools but I’m discussing them in that context.

So let’s get to it!

[author_more]

ai2html

Let’s start off with one that surely blew many people’s minds when it first came out. This comes from the New York Times Newsroom Developers, and it’s described as:

[A]n open-source script for Adobe Illustrator that converts your Illustrator documents into html and css.

ai2html

It’s written in JavaScript and it’s added to Illustrator by dropping the .js file into the “Scripts” folder of your Illustrator installation. Once that’s done, you follow these steps:

  1. Create your Illustrator artwork.
    • Size the artboard to the dimensions that you want the div to appear on the web page.
    • Make sure your Document Color Mode is set to RGB.
  2. Run the script by choosing: File > Scripts > ai2html.
  3. Go to the folder containing your Illustrator file and find the HTML file(s) located inside the ai2html-output folder.

You can customize the export of image formats, PNG and JPEG quality, page responsiveness, number of HTML files, and lots more. The NYTimes even maintains a collection of examples of how it’s been used from their team as well as others.

sloc

This is pretty neat. It’s a command-line tool to help you build stats on your source code. The output by default is just a simple result list but you can switch it to CSV, JSON, or CLI-table format. After installing via npm, you’ll run a command like this:

[code language="bash"]
sloc index.html
[/code]

I ran the above command on one of my projects that has a very big HTML file and here’s the result:

[code language="bash"]
---------- Result ------------

Physical : 9788
Source : 6340
Comment : 645
Single-line comment : 0
Block comment : 645
Mixed : 642
Empty : 3445

Number of files read : 1

------------------------------
[/code]

Notice the breakdown in comment types

And with the following command, which outputs in JSON format:

[code language="bash"]
sloc --format json index.html
[/code]

We get the following result:

[code language="javascript"]
{
"files": [
{
"path": "index.html",
"stats": {
"total": 9788,
"source": 6340,
"comment": 645,
"single": 0,
"block": 645,
"mixed": 642,
"empty": 3445
},
"badFile": false
}
],
"summary": {
"total": 9788,
"source": 6340,
"comment": 645,
"single": 0,
"block": 645,
"mixed": 642,
"empty": 3445
}
}
[/code]

You can also use this in a node module, via JavaScript in the browser, or as a Grunt plugin.

Walkway

With the explosion of SVG tools and resources of late, it’s only fitting to include some SVG stuff in this post. This one is an “easy way to animate SVG elements”. And I can vouch for its ease of use.

Walkway

The project’s home page has an example of what you can do with this library.

It supports animation of path, line, and polyline elements and lets you define a duration value and an easing function. I was able to put together the demo below in a few minutes using some public domain SVG art.

See the Pen Walkway.js example SVG animation by SitePoint (@SitePoint) on CodePen.

While it’s true there are more complex SVG animation libraries, I’m a sucker for simplicity. Walkway does one thing really well and it’s easy to implement it.

Continue reading %Front-end Tools: Some of My Favorite Finds of 2015%


by Louis Lazaris via SitePoint