Friday, July 15, 2016

Sharetastic : jQuery Share Plugin

A simple jQuery social sharing plugin, styled with sass for easy customization.

The post Sharetastic : jQuery Share Plugin appeared first on jQuery Rain.


by Admin via jQuery Rain

An Introduction to NativeScript

In this article, we're going to take a look at NativeScript, an open-source framework for building mobile apps with JavaScript. At the end of the article, you should have a pretty good idea of what NativeScript is, how it works, and what technologies it uses. Aside from that, we're also going to answer common questions that you might have when exploring a new technology, such as how it differs from alternatives like Cordova and React Native, and how Telerik is involved in the project.

1. What Is NativeScript?

NativeScript is a framework for building cross-platform native mobile apps. It allows developers to use XML, CSS and JavaScript to build apps for Android, iOS, and even the Windows Universal Platform. Unlike Cordova, which uses WebView for rendering the UI of the app, NativeScript uses the native platform's rendering engine, which means that it provides a truly native user experience. 

2. Pros

  • It is free and open source. This means that you can contribute to the code and use it however you want, as long as you don't violate the Apache 2.0 license.
  • It allows you to build truly native apps for Android and iOS devices. Each of the UI components that NativeScript exposes is translated into its corresponding native UI components.
  • It lets you access native platform APIs through JavaScript code. You don't need to have knowledge of Java or Objective-C in order to use native platform APIs because you can write it all in JavaScript. This means that if you need to access a specific device feature, you can just learn how to access native APIs with JavaScript and you're good to go. 
  • It gives users an experience closer to native than those provided by hybrid mobile app frameworks like Cordova. 
  • It allows developers to easily build, deploy and manage their NativeScript apps through the Telerik platform. I'll discuss the Telerik Platform more in a later section.
  • It has zero-day support for new native platforms. This means that you can immediately use the latest native APIs and UI components whenever Google or Apple updates their platform.
  • The documentation provides lots of information on how to get started, core concepts, and the user interface. There are also examples, tutorials, a forum, Stack Overflow questions, and sample apps which can help beginners get started with NativeScript. 
  • You can write your NativeScript apps with TypeScript. TypeScript is a language that transpiles to JavaScript and adds object-oriented programming capabilities to JavaScript.
  • Any JavaScript library that you can find on npm that doesn't rely on the browser and the DOM can be used within NativeScript. Examples of such libraries include utility libraries such as lodash and underscore
  • You can do almost anything with the NativeScript CLI. Basics such as creating a new project, adding a platform, running on a device and deploying to a specific platform are all included. Aside from that, you can also install plugins, debug the app, and upload to the app store.

3. Cons

  • There's no HTML and DOM in NativeScript. You'll need to learn how to use the different UI components in order to build the UI of the app. 
  • Verified plugins are lacking. At the time of writing of this article, there are only 16 verified plugins in total. Though there are a lot of NativeScript plugins listed on npm, you can never really be sure of their quality. 
  • Developers need to know the native Android and iOS APIs in order to access the device hardware and other platform-specific features.
  • Due to its native nature, you can only test apps on an actual device or an emulator. This makes the initial setup for testing slower. But once you get it running on the device, hot-reloading takes over. This means that every time you make a change to the source code, it immediately reloads the app to reflect the changes.
  • Not all UI components are available for free. You need to purchase Telerik UI for NativeScript if you want to use components such as charts and calendars.

4. How Does It Work?

NativeScript is composed of a JavaScript virtual machine, a runtime, and a bridge module. The JavaScript virtual machine interprets and executes JavaScript code. Then the bridge module translates the calls to the platform-specific API calls and returns the result to the caller. To put it simply, NativeScript provides developers with a way to command the native platform through JavaScript instead of Objective-C on iOS or Java on Android.

Of course, there's a lot more going on behind the scenes, but the developers at Telerik explain it better than I can, so if you want to learn more about the inner workings of NativeScript, you can read the article by Georgi Atanasov on NativeScript - a Technical Overview or TJ VanToll's article on How NativeScript Works.

5. What Technologies Does It Use?

With NativeScript, you use XML to describe the UI of the app, CSS for styling, and JavaScript to add functionality. 

You can use TypeScript with Angular 2 if you prefer to use a framework for authoring your JavaScript code. 

For styling, NativeScript only uses a subset of CSS. This means that not all CSS features that are available in a browser environment can be used. For example, you cannot use floats or position attributes. Here's the full list of supported CSS properties. Just like in the browser, you can add styles that apply to the whole app, to specific pages, or to a specific UI component only. If you prefer to use Sass, you can install the NativeScript Dev Sass plugin.

For describing the structure of the user interface, you use XML. Each page in the app should be in its own XML file. NativeScript comes with pre-defined user interface widgets or components which you can use to build the UI of the app. Some of these components are similar to the different HTML elements that you use in the browser. 

For example, there's an Image component, which is the equivalent of the img element, or the TextField component, which is equivalent to the input element with a type of text. Event handlers such as tapping a button are added in the component itself. Here's an example:

Another thing to note is that the components also serve as templates. If you're familiar with templating libraries such as Handlebars or Mustache, you should be at home with the following syntax:

The example above uses the ListView component. As the name suggests, this component allows you to create lists. animals is an array defined in the JavaScript file and is bound to the animals variable on page load. This makes the animals variable available for use inside the XML file.

This outputs each item in the array inside the ListView.

Lastly, there are plugins which allow you to access the device hardware and platform-specific features. NativeScript comes with a camera plugin pre-installed. This allows you to access the camera of the device and take photos. You can then save the local path to the photo in your app for later use. Platform-specific features such as social sharing can also be used by installing plugins such as the NativeScript Social Share Plugin.

6. What Apps Can You Build?

Due to the native nature of NativeScript, you can build almost any kind of app with it. Here are a few examples of apps that you can build with NativeScript:

  • Apps that talk to the server, such as news apps and social networking apps.
  • Simple games such as chess, tic-tac-toe, or pinball.
  • Real-time apps such as chat apps or live feeds. There's a Firebase plugin for NativeScript which you can use to implement real-time apps.
  • Music and video streaming apps. There's a video player plugin which allows you to play videos stored locally or stream remote videos such as the ones on YouTube.
  • Maps and geolocation apps. There are plugins for Google Maps, and native map APIs.
  • Apps that access the device hardware. Examples include camera apps and IoT apps.

When it comes to the kinds of apps that you can build with NativeScript, the only limiting factors are performance and plugin availability. Writing native mobile apps in JavaScript comes with a price: you can't really expect to build apps that demand high performance. Examples include games with complex graphics and animations, apps with lots of moving parts, and background processes. 

Another limitation is plugin availability. Most developers come to NativeScript from a web development background. This means that most of them aren't familiar with or have limited knowledge of the native platform APIs which could be used to create plugins to access the device hardware or platform-specific features such as contacts or messaging.

If you want to learn more about what kinds of apps you can build with NativeScript, you can check out the App Showcases page. Most of the apps that are listed in there are published on both the Google Play Store and Apple Store. This means that you can install it and run it on your device to get a feel of what apps built with NativeScript look like and how they perform.

7. How Does NativeScript Compare to Hybrid Frameworks?

If you're not new to hybrid mobile app development, you might have come across frameworks such as Cordova and React Native. NativeScript is related to these two frameworks in that they both aim to solve the problem of "Write once, run everywhere" in the field of mobile app development. Now let's look at each framework side by side:


Cordova React Native NativeScript
Creator Nitobi; Later purchased by Adobe Systems Facebook Telerik
UI HTML UI components are translated to their native counterparts UI components are translated to their native counterparts
Can test on Browser, emulator, device Emulator, device Emulator, device
Code with HTML, CSS, JavaScript UI components, JavaScript, subset of CSS UI components, subset of CSS, JavaScript
Native functionality access Through plugins Native modules Native API access through JavaScript
Deploys to Android, iOS, Ubuntu, Windows, OS X, Blackberry 10 Android and iOS. Windows Universal and Samsung Tizen coming soon Android and iOS. Windows Universal coming soon
JavaScript libraries and framework Any front-end library or framework (e.g. Angular, Ember) Any library that doesn't depend on the browser Any library that doesn't depend on the browser
Coding pattern Any front-end framework can be used to structure the code The UI markup, JavaScript and CSS are all lumped together in a single file by default
MVVM/MVC pattern
How JavaScript code is executed WebView JavaScriptCore Engine to execute app code on both Android and iOS
Webkit JavaScriptCore engine to execute app code on iOS and Google's V8 JavaScript engine on Android

To sum it up, Cordova is the old generation of hybrid mobile app frameworks. It uses the WebView to render the UI of the app and accesses native device capabilities by means of plugins. React Native and NativeScript are the new generation because they translate your JavaScript code so that it can be executed by the native platform.

Somebody might come up with a better name for frameworks like React Native and NativeScript in the future. But for now let's classify them as "Native Hybrid Frameworks" because they both use JavaScript for authoring apps and they both offer native-like experience and performance to users.

8. How Is Telerik Involved in the Project?

Telerik is the company that created NativeScript. And, just like any other company, they need to make money in order to survive. So you might ask, if NativeScript is free and open source, how does Telerik make money from it? Well, the answer is through the Telerik Platform and Telerik UI for NativeScript

The Telerik Platform provides developers with the tools they need to easily design, build, test, deploy, manage and measure the performance of NativeScript apps. Here are a few examples of the tools they offer:

  • a visual app builder that allows you to drag and drop different UI components
  • a cloud database that provides the database for your app
  • live app updates for easily pushing updates to the app without having to resubmit it to the app store and have the user update the app manually
  • an analytics service that answers questions such as how your app is being used, how it's performing, and what your users think of it

Telerik UI for NativeScript is a set of components for building the UI of the app. NativeScript already comes with free UI components, but there are also paid UI components such as the Chart and Calendar which you can only use when you purchase it from Telerik.

9. Next Steps

If you want to learn more about NativeScript, I recommend checking out the following resources:

Conclusion

In this article you've learned the very basics of NativeScript. As you have seen, NativeScript is a good option for building mobile apps using the skills you already have as a web developer. I hope this article has provided you with the necessary knowledge to help you decide whether NativeScript is right for you.


by Wernher-Bel Ancheta via Envato Tuts+ Code

This week's JavaScript news, issue 292

This week's JavaScript news
Read this e-mail on the Web
JavaScript Weekly
Issue 292 — July 15, 2016
A flexible, plugin-driven framework for building rich editors like those used by Medium or Dropbox Paper without your codebase getting mired in complexity.
Ian Storm Taylor

The creator of Espruino (a JS interpreter for microcontrollers) is creating a JavaScript-programmable Bluetooth beacon. It’s on KickStarter and has already far surpassed its goal.
Pur3 Ltd

An engaging and educational 15 minute tour of the roles of var, let and const in ES6, led by a front-end developer from Spotify.
Mattias Petter Johansson

Eight days of sessions and workshops on React, Redux, D3, Angular 2, Accessibility, Progressive Web Apps, Dev Ops and Functional JavaScript. Grab one of the last few spots
ForwardJS   Sponsored
ForwardJS

Vue.js is a reactive UI component library. Beta 1 of v2 is now out, and this tutorial provides a thorough introduction.
Alex Sears

Changes to jQuery Deferreds in jQuery 3 caused errors to be silenced in certain places (e.g. document ready handlers). jQuery 3.1 fixes this.
jQuery Foundation

An experimental framework for extracting meaning from web pages, identifying parts like buttons, address forms, and the main textual content. It scores DOM nodes and extracts them based on criteria you specify.
Mozilla

A library to help you format input text content automatically (e.g. dates, card numbers). Take a look at the demo page for plenty of examples.
Max Huang

Jobs Supported by Hired.com

Can't find the right job here? Want companies to apply to you? Try Hired.com.

In brief

Looking for more on Node? Read this week's Node Weekly too :-)

Curated by Peter Cooper and published by Cooper Press.

Stop getting JavaScript Weekly : Change email address : Read this issue on the Web

© Cooper Press Ltd. Office 30, Lincoln Way, Louth, LN11 0LS, UK


by via JavaScript Weekly

How to Use Python Packages

Python packages allow you to break down large systems and organize their modules in a consistent way that you and other people can use and reuse efficiently. Python's motto of "Batteries Included" means that it comes preloaded with lots of useful packages in the standard library. 

But there are also many amazing third-party packages you can take advantage of. In this tutorial you'll learn all you need to know about what packages are exactly, how to import modules from packages, exploring the built-in package in Python's standard library, and installing third-party packages.

What Are Packages?

Before we can talk about packages, let's talk about modules. Modules are the source files with *.py extension where you (and everyone else) put the functions and classes that comprise your program. Packages are the manifestation of Python's hierarchical namespaces concept. To quote from the Zen of Python: 

"Namespaces are one honking great idea -- let's do more of those!"

To view the whole Zen of Python, type import this in a Python interactive session:

Namespaces help with organizing code and preventing naming conflicts. This is critical when multiple people work together or when using packages developed by other people.

While packages represents a hierarchy of sub-packages and modules, which are files the hierarchy doesn't have to file-system based where packages and sub-packages are directories and sub-directories. It is much more flexible than that.

Example Package

Let's take a look at a package called "ansible". It is not a package from the standard library. You'll see later how to find and install third-party packages. Now, let's just check out the directory file structure. 

The packages will be installed typically into the Python interpreter's site-packages directory, which will be located somewhere (depending on version, OS, and distribution) under the "lib". On the Mac, for Python 2.7 it will be located in "<interpreter root>/lib/python2.7/site-packages". Here is how the "ansible" package is organized:

There are two modules and 15 directories. Each directory is a sub-package of the main ansible package. Looking inside the ansible/utils directory, we can see it contains additional modules and even one more sub-package:

The Search Path

When you import a module, Python will go through a search algorithm based on the search path, which is a list of directories to start the search. The search path is a list of directories available through sys.path, and you can manipulate it dynamically (add, remove or move around items in the search path). The site-packages directory is always there.

To import the path.py module from ansible/utils, you'll need to use the following command:

import ansible.utils.path

If you also want to use the standard os.oath module, you'll use the following command:

import os.path

Now you can use either or both path modules with no conflicts due to the difference namespace they belong to.

Exploring the Standard Library

The standard library has a lot of packages. It's worth exploring it whenever you need to accomplish some task and you're not sure how. There is a very high likelihood that for any general-purpose task like math, shell integration, OS integration, string manipulation, networking and common file formats, there is a well-designed, well-performing and well-tested package in the standard library. 

You can really trust standard library packages because it is a big deal to get into the standard library. Either the package was designed by Python's core developers or it was heavily reviewed and often heavily used in the field as a third-party library before making it into the standard library.

Here are all the packages in the standard library organized by topic.

PyPI

The standard library is awesome, but there'll often be some special functionality you need that is not standard. It doesn't mean you have to write it from scratch. Python has a vibrant and active community that develops and shares freely a lot of code. Enter PyPI - the Python Package Index. PyPI hosts all publicly available packages and provides a one-stop shop for browsing through them.

Browsing PyPI

PyPI organizes the packages in a browsable index. You can browse and search by topic, environment, framework, development, status, intended audience, license, natural language, programming language (yes, there are Python packages that support many programming languages), and operating system. 

There is also a distinction between Python 2 and Python 3 packages, and you can see how popular a package is by the number of recent downloads. For example, the ansible package is available on PyPI, and here is its metadata:

Installing Packages

There are two ways to install packages from PyPI. You can download the package and then run python setup.py install. But the modern way is to use pip, setuptools and wheel. Pip stands for Pip Installs Packages (yes, it's one of those acronyms) and is your front end for installation. If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from python.org, you will already have pip and setuptools, but will need to upgrade to the latest version: pip install -U pip setuptools or python -m pip install -U pip setuptools on Windows.

Use pip to install wheel: pip install wheel.

If you're using an earlier version of Python, consider upgrading. If you're unable to, you'll need to install pip, setuptools and wheel on your own. Check the instructions.

Python packages are always installed into an environment. A common practice I will not cover here is to use virtual environments to manage multiple independent installations of Python with different interpreters and/or different sets of installed packages.

Best Practices

The Python packaging authority provides a lot of guidance on the best practices around packaging. This is important because it is an area of active development and recommendations evolve quickly.

Also, if you want to do something special like installing packages from alternative repositories instead of PyPI or using pip in a more sophisticated way, you'll find great discussions and practical advice. 

Conclusion

When you're a Python beginner, you learn the core language and have fun playing with it. Pretty soon you discover the standard library, and as you gain more experience you benefit more and more from its richness. 

The next stage in your evolution as a Pythonista is to incorporate the vast awesomeness the Python community has put on PyPI into your systems. Packages as the deployment unit of reusable Python code enable this ecosystem.


by Gigi Sayfan via Envato Tuts+ Code

New Short Course: Write a jQuery Plugin

Cuberto

Cuberto is a creative team that builds digital products worldwide. We specialize in branding, designing and development of mobile apps and websites.
by via Awwwards - Sites of the day

Live Video: Creative Ways to Do a Live Show on Facebook

ms-podcast206-lou-mongello-600

Do you broadcast live video? Have you considered hosting a regular show on Facebook Live? To discover creative ways to use Facebook Live, I interview Lou Mongello. More About This Show The Social Media Marketing podcast is an on-demand talk radio show from Social Media Examiner. It’s designed to help busy marketers and business owners [...]

This post Live Video: Creative Ways to Do a Live Show on Facebook first appeared on .
- Your Guide to the Social Media Jungle


by Michael Stelzner via