Image zoom for e-commerce

Folks this time lets make some fun with implementing product image zoom for e-commerce site by using jQuery and customizing some jQuery plugins. Now lots of new frameworks and libraries available for the JavaScript. Even though jQuery still hold its better position. It is still used because of its flexibility and easy manipulation of the dom elements.

Mission

Today the mission is to implement a product zoom for a popular e-commerce site which is using jQery for dom manipulations.

Mission Accomplished

Lots of zoom plugins are available online wits lots of various features. Here am not going to give you a plugin and make you use the same for your implementation.

Am just going to explain how I implemented a product zoom by customizing already existing free plugins. sure, this combination and customization will give you a pro look for the product display page’s zoom image.

This customized product zoom has some remarkable function apart from the zooming product image. It holds the enlarged gallery and MegaEnlarge through which you can view the product more clear.

Just Download and go through the code I used simple HTML and Jquery in the way that everyone can understand. Go through the comments in zoom.js & index.html for more clarity.

Demo   |   Download

This jquery zoom implementation has four features

  1. Vertical Thumb image gallery carousel.
  2. Product Zoom
  3. Enlarged Gallery
  4. Mega Enlarge

Vertical Carousel

iZoom - ecommerce product zoomProduct Zoom

iZoom - ecommerce product zoom

Enlarged Gallery

iZoom - ecommerce product zoom

Mega Enlarge with PanZoom

 

Hotlink for demo and the working example links are dropped below just check it out!

Demo   |   Download

Plugin Credits

Product Zoom: ElevateZoom  [Free Plugin with numerous options]

Vertical Thum Gallery Carousel: rcarousel  [ Support horizontal/vertical ]

Enlarged Gallery: Fancybox

MegaEnlarge : ImagePannign.

The comments section is opened for valuable suggestion.

Happy Coding!

 

Simple Method to Localize your Angularjs Project

Localize your Angularjs Project is so simple, Angularjs has its own l10n & i18n scripts which are responsible for localizing the date, number and currency into your project but it has some restrictions with it. If you want to load specific locale library from angular js it can be done it by adding the corresponding locale via the script tag. But in case if you want to change the locale or language inside the application while it is running without reloading the page then here comes a simple solution.

localize angularjs app

Mission

The mission is to implement localization into the project without injecting any third party modules “angular-translate” into our application.

Mission Accomplished

Now am going to brief how I implemented localization manually

  1. Creating resource.json for the different language which holds all your translation as a json object.
  2. Get the JSON data using “$resource” and assign it to an object under “$rootScope”.
  3. Copy new locale object of corresponding to the language to $locale.

Creating  separate resource JSON

I created a separate folder which holding the localization object for the different object. The final level holds the name of the Locale Id, which is going to decide in what language our application renders.

This is how the folder Structure for resource.json created

-app
|_ l10n
|__en-us
|____resource.json
|__de-de
|____resource.json

This resource.json holds all the static value of my app. In all my HTML I use the key to rendering corresponding value.

whenever the user changes the language I get the unique language ID and make a $resource call and get the appropriate resource.json to render the values in selected language.

The same resource.json holds my locale object which is responsible for the date, number & currency formats.

Angular Js localization module on GitHub

Access the above mention URL and open the required language JS and copy the locale object from corresponding js to your resource.json

sample resource.json with Static & locale values for the German language.

{
 "indexPage": {
    "welcomeNote": "Willkommen bei icodefy",
    "followUs": "Folge uns"
    },
 "homeMenu": {
    "home": "Zuhause",
    "aboutUs": "Über uns"
    },
"locale": {
"DATETIME_FORMATS": {
"AMPMS": [
"vorm.",
"nachm."
],
"DAY": [
"Sonntag",
"Montag",
"Dienstag",
"Mittwoch",
"Donnerstag",
"Freitag",
"Samstag"
],
"ERANAMES": [
"v. Chr.",
"n. Chr."
],
"ERAS": [
"v. Chr.",
"n. Chr."
],
"FIRSTDAYOFWEEK": 0,
"MONTH": [
"Januar",
"Februar",
"M\u00e4rz",
"April",
"Mai",
"Juni",
"Juli",
"August",
"September",
"Oktober",
"November",
"Dezember"
],
"SHORTDAY": [
"So.",
"Mo.",
"Di.",
"Mi.",
"Do.",
"Fr.",
"Sa."
],
"SHORTMONTH": [
"Jan.",
"Feb.",
"M\u00e4rz",
"Apr.",
"Mai",
"Juni",
"Juli",
"Aug.",
"Sep.",
"Okt.",
"Nov.",
"Dez."
],
"STANDALONEMONTH": [
"Januar",
"Februar",
"M\u00e4rz",
"April",
"Mai",
"Juni",
"Juli",
"August",
"September",
"Oktober",
"November",
"Dezember"
],
"WEEKENDRANGE": [
5,
6
],
"fullDate": "EEEE, d. MMMM y",
"longDate": "d. MMMM y",
"medium": "dd.MM.y HH:mm:ss",
"mediumDate": "dd.MM.y",
"mediumTime": "HH:mm:ss",
"short": "dd.MM.yy HH:mm",
"shortDate": "dd.MM.yy",
"shortTime": "HH:mm"
},
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u20ac",
"DECIMAL_SEP": ",",
"GROUP_SEP": ".",
"PATTERNS": [{
"gSize": 3,
"lgSize": 3,
"maxFrac": 3,
"minFrac": 0,
"minInt": 1,
"negPre": "-",
"negSuf": "",
"posPre": "",
"posSuf": ""
}, {
"gSize": 3,
"lgSize": 3,
"maxFrac": 2,
"minFrac": 2,
"minInt": 1,
"negPre": "-",
"negSuf": "\u00a0\u00a4",
"posPre": "",
"posSuf": "\u00a0\u00a4"
}]
},
"id": "de-de",
"localeID": "de_DE"
}
}

Get resource.json Data using $resource and copy to $locale

Whenever the user changes the value in the language dropdown I call the appropriate file URL using $resource request and get the resource.json and reassign it back the $rootScope.l10n which hold all the static value of the application.

Here $rootScope.lang is the value bind from the language dropdown which is changed by user.

$resource('/app/l10n/' + $rootScope.lang + '/resources.json')
  .get(function (data) {
            $rootScope.l10n = data;
            // inject LocaleFactory in controller
            LocaleFactory.setLocale($rootScope.l10n.locale);
        });       

LocaleFactory is created for the component reusability. The angular.copy function can also call directly.

.factory('LocaleFactory', function ( $locale ){
 return {
  setLocale: function (currentLocaleObj) {
  angular.copy(currentLocaleObj, $locale);
 }
};

Drop your valuable comments and improvement suggestions in the comment section.

Turn Google Bar chart into Tornado Chart (Butterfly Chart)

Google chart visualization provide multiple varieties of charts to addressing your data visualization needs. The good things about the Google chart are it had lots of customization option and also it is absolutely free to integrate and use with your web application. Google chart includes lots of inbuilt customization options, these options allow you have the better visualization. Even though it doesn’t have any Tornado chart in its library. But we can customize the google bar chart into Tornado Chart with some work around.

google-bar-chart-to-tornado-chart_new

As I got unique requirement from one of the projects, which is a rating and review kind of stuff developed with HTML5 & Jquery for frontend and Laravel 5 & SQL for the backend services.

Mission

Here mission is to show the user’s top 3 positive & negative ratings in a single chart. That Chart contains most liked components on its right and most disliked element on its left along with its average rating and element name as a label. While creating it with the google bar chart the challenge we faced is to make positive and negative values bar at the same level as shown in the figure below.

Tornado butterfly Chart

Mission Accomplished

While implementing google bar chart with negative values it’s not displayed as expected. so we need a workaround to make the chart look like as expected. By default, it displays the chart as shown below with positive and negative values at different levels of the y axis.

Default  google chart with negative valuesnormal google bar chart

Work Around in Google Bar Chart

To make this default bar chart to visualize like a required Tornado chart (Butterfly Chart) we need to do some work around. I will explain those option attribute added to the default chart option.

you can refer the JS part of the code snippet below in which the variable “option” inside “drawbarChart” function holds the additional options for chart visualization.

If you refer that variable in which we added the “isStacked” attribute to make the negative and positive values at the same level

isStacked: true,

we are getting data in ascending order from backend which holds smaller value at the first. But as per the requirement, we need to show the top rated value at first in the google Tornado chart. For invert the chart value we added the another attribute to the option “vAxis” object.

vAxis: {
direction: -1 ,
}

 

Code Snippet

See the Pen Customize Google Barchart into Tornado Chart (Butterfly Chart) by icodefy (@icodefy) on CodePen.

You can find the working code snippet above. Our comment box is open. Drop your valuable comments

Post Feeds to Facebook wall from Web / Mobile Application.

Under this topic, Am sharing that how I implemented a functionality to post feed to users Facebook wall. I used javascript HTTP post method and Facebook Graph API to achieve this.

Am taking a hybrid mobile application was developed using Ionic and AngularJs as an example. That application has the option to share user check-ins, favorites & activity kind of stuff.

Post to facebook wall from mobile applicaiton

Mission

The mission is to post the recent activity of the user to the Facebook wall if share to Facebook option is enabled. The another task is to display posted via “App_Name” and the link to the respective web page in the bottom of the feed.

Mission accomplished

To accomplish the mission of posting the user data to Facebook wall I used the HTTP post method and the Facebook Graph API as I mentioned above.

Code snippets

try {
 $cordovaFacebook.getLoginStatus()
 .then(function(success) {
   // save access_token
   var accessToken = success.authResponse.accessToken;
   var app_id = "Your App ID";
   var content = '&message=YOUR_CUSTOM_MESSAGE&link=YOUR_TARGET_LINK&caption=POST_VIA_NAME&picture=PICTURE_URL';
   var url = "https://graph.facebook.com/me/feed?app_id=" + app_id + "&access_token=" + accessToken + content;
   $http.post(url).then(function(response) {
    // success action
   });
  });
} catch (_error) {
  // Error action
} 

The above example of the application using Ionic & AngularJS

Note: you can use the url variable on any HTTP post or ajax calls

Code Brief

Getting the user login status before posting the feed

on success am getting the user auth token from facebook.

  • app_Id   = facebook developer application ID.
  • YOUR_CUSTOM_MESSAGE : The message to display in the feed
  • YOUR_TARGET_LINK: The URL to navigate if the user click on the Facebook post
  • POST_VIA_NAME : Application / Website name.
    PICTURE_URL: URL of the picture to post along with message

constructing an URL to use with HTTP post method.

Call HTTP post method. Do the success action id the call succeed else it end with “Error action”.

Drop your valuable comments in the Comment box.

Handy Tool to compare, validate, extract & merge JSONs

I got into a case where am need to check the keys and the values for the JSON object in our project which is dropped at an even interval with updated key and values.  It is tough to identify the newly updated values and newly added keys ion the latest drop as each json holds huge number keys.  This  VEM JSON tool assists in resolving this issue.

This tool has some unique functionality like extract the non-identical Keys, Values into a separate object by comparing the source and the destination JSON. This saves time and the have high accuracy level compare to manual extraction/merging techniques while working with multilingual JSONs.

Online Tool:

https://icodefy.com/Tools/vem-json/

Git Url:

https://suriish@bitbucket.org/suriish/vem-json.git

Screenshot:

Json merging tool - screenshot

VEM JSON Tool Options

  • Compare Two JSON and Extract missing keys as a new Object.
  • Compare Two JSON and Extract keys with non-identical values and as a new Object
  • Option to merge the extracted object with Source JSON / Destination JSON
  • Add custom prefix to all the values of the Extracted JSON
  • Validate, Minify / Beautify the JSON
  • Display’s the total number of keys exist in source/ destination / extracted JSON
  • Supports multi-dimensional JSON.

Problem with Existing Tools available

  • No option to extract the Missing keys, non-Identical values as separate object
  • Merge Option are not easy and flexible
  • No option to add a prefix to the extracted values.

Solution from this Tool

  • using this tool developer can update the new key, value pair in Base resource file only, the missing keys (newly added) are extracted using the tool by comparing the old version with latest version using compare key Then those extracted keys are merged with the appropriate lingual resource file with a prefix.
  • Vem JSON tool gives High accuracy level and faster than the conventional method.
  • Developers can compare the Base (English) JSON with other lingual to identify the missed translations using compare key option and they can add a prefix to the value of extracted JSON if required. Finally, they merge the Extracted JSON with the Destination.
  • To identify and extract the values updated in the latest Drop, Developers can compare the old lingual files with the latest lingual file of using the Compare Value option in the tool.
  • The tool itself holds validation option which validates the JSON.

Additional Options

  • This tool holds JSON Error position highlighter.
  • While comparing the Keys, Extracted JSON holds the value from Source which makes the translator’s job easy.
  • While comparing the Values, Extracted JSON holds the value from the destination as it had the latest value.
  • The user can cross check the missing object counts as it displays Total key count of the JSON.
  • Pick the JSON file from your local disk for comparison.
  • Interchange Source / Destination option allow the user to interchange the source and destination JSONs easily at any time.
  • The user has the flexibility to merge the extracted JSON with Source or Destination as per the requirement.
  • Copy – allow the users to copy the entire final JSON available in the Result Section.
  • Users can manually edit and validate the JSON if required.
  • Using Minify / Beautify options user can increase the optimization / Readability respectively.

Please drop your valuable comments regarding this tool in the comments section.

If you feel that any new features need to be added in upcoming version add that also in the comment section.