Sunday 21 June 2015

Using Parallax JS

Parallax.js is a dirt simple parallax scrolling effect inspired by Spotify.com and implemented as a jQuery plugin.


Parallax Picture Scrolling


Basic scrolling parallax text 






Google map and Direction API with Visualforce page

Google map API : https://developers.google.com/maps/documentation/javascript/tutorial

Google Direction API: https://developers.google.com/maps/documentation/directions/

Demo: http://jsfiddle.net/vc1zwft0/

Same i want to use in salesforce with dynamic addresses.

So This is the code.

Implement same and write some logic in controller side.

<apex:page showHeader="false" >
<head>
   <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
   <title>Google Maps API v3 Directions Example</title>
   <script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=true"></script>
</head>
<body style="font-family: Arial; font-size: 12px;">

    <div style="width: 100%;" id="mapDiv">
        <div id="map" style="width: 70%; height: 600px; float: left;margin:0px;color:black;"></div>
        <div id="panel" style="width: 30%; float: left;margin:0px;"></div>
    </div>
    <script type="text/javascript">

     var directionsService = new google.maps.DirectionsService();
     var directionsDisplay = new google.maps.DirectionsRenderer();

     var map = new google.maps.Map(document.getElementById('map'), {
               zoom:7,
               mapTypeId: google.maps.MapTypeId.ROADMAP
     });

     directionsDisplay.setMap(map);
     directionsDisplay.setPanel(document.getElementById('panel'));

     var request = {
       origin: 'Mumbai',
       destination: 'Navi Mumbai',
       travelMode: google.maps.DirectionsTravelMode.DRIVING
     };

     directionsService.route(request, function(response, status) {
       if (status == google.maps.DirectionsStatus.OK) {
         directionsDisplay.setDirections(response);
       }
     });
   </script>
</body>
</apex:page>


Here instead of using hard coded value you can create string at controller level and pass here.

origin: {!start address }
destination:- {end address}

Source :- http://stackoverflow.com/questions/3896871/google-map-driving-direction-source-code-for-their-example

Google Polymer Paper Toolbar with visualforce page

VF Page

<apex:page >
<head>
  <meta charset="UTF-8"/>
  <script src="https://www.polymer-project.org/0.5/components/webcomponentsjs/webcomponents.js"></script>

  <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes"/>



  <link rel="import" href="https://www.polymer-project.org/0.5/components/font-roboto/roboto.html"/>
  <link rel="import" href="https://www.polymer-project.org/0.5/components/core-icons/core-icons.html"/>
  <link rel="import" href="https://www.polymer-project.org/0.5/components/core-toolbar/core-toolbar.html"/>
  <link rel="import" href="https://www.polymer-project.org/0.5/components/core-media-query/core-media-query.html"/>
  <link rel="import" href="https://www.polymer-project.org/0.5/components/paper-icon-button/paper-icon-button.html"/>

  <style>

    body {
      font-family: RobotoDraft, 'Helvetica Neue', Helvetica, Arial;
      margin: 0;
   
    }

    core-toolbar {
      color: #f1f1f1;
      fill: #f1f1f1;
    }
 
  </style>

</head>
<body unresolved="">

  <core-toolbar style="background: #4285f4;">
    <paper-icon-button icon="menu"></paper-icon-button>
    <span flex="">Title</span>
    <paper-icon-button icon="refresh"></paper-icon-button>
    <paper-icon-button icon="more-vert"></paper-icon-button>
  </core-toolbar>

  <br/>

  <core-toolbar style="background: #3f51b5;">
    <paper-icon-button icon="menu"></paper-icon-button>
    <span flex="">Title</span>
    <paper-icon-button icon="refresh"></paper-icon-button>
    <paper-icon-button icon="more-vert"></paper-icon-button>
  </core-toolbar>

  <br/>

  <core-toolbar class="tall" style="background: #0f9d58;">
    <paper-icon-button icon="menu"></paper-icon-button>
    <span flex="">Title</span>
    <paper-icon-button icon="refresh"></paper-icon-button>
    <paper-icon-button icon="more-vert"></paper-icon-button>
  </core-toolbar>

  <br/>

  <core-toolbar class="tall" style="background: #ffeb3b; color: #333; fill: #333;">
    <paper-icon-button icon="menu" class="bottom"></paper-icon-button>
    <span flex="" class="bottom">Title</span>
    <paper-icon-button icon="refresh" class="bottom"></paper-icon-button>
    <paper-icon-button icon="more-vert" class="bottom"></paper-icon-button>
  </core-toolbar>

  <br/>

  <core-toolbar class="medium-tall" style="background: #ff5722;">
    <paper-icon-button icon="menu"></paper-icon-button>
    <span flex=""></span>
    <paper-icon-button icon="refresh"></paper-icon-button>
    <paper-icon-button icon="more-vert"></paper-icon-button>
    <span class="bottom indent">Title</span>
  </core-toolbar>

  <br/>

  <core-toolbar class="tall" style="background: #9c27b0;">
    <paper-icon-button icon="menu"></paper-icon-button>
    <div flex=""></div>
    <paper-icon-button icon="refresh"></paper-icon-button>
    <paper-icon-button icon="more-vert"></paper-icon-button>
    <div flex="" class="middle indent">Title</div>
    <div flex="" class="bottom indent" style="font-size: 18px;">Title2</div>
  </core-toolbar>

  <core-media-query id="mediaQuery" query="max-width: 800px"></core-media-query>

  <script>

    document.querySelector('#mediaQuery').addEventListener('core-media-change',
      function(e) {
        document.body.classList.toggle('core-narrow', e.detail.matches);
      });

  </script>

</body>

</apex:page>

Demo: https://www.polymer-project.org/0.5/components/paper-elements/demo.html#core-toolbar
--------------------------------------------------------------------------------------------------------------------------

Google Polymer Paper Tabs with Visualforce page

Visualforce page:-

<apex:page showheader="false">

<head>
  <title>paper-tabs</title>
  <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes"/>

  <script src="https://www.polymer-project.org/0.5/components/webcomponentsjs/webcomponents.js"></script>

  <link rel="import" href="https://www.polymer-project.org/0.5/components/core-icons/core-icons.html"/>
  <link rel="import" href="https://www.polymer-project.org/0.5/components/font-roboto/roboto.html"/>
  <link rel="import" href="https://www.polymer-project.org/0.5/components/paper-tabs/paper-tabs.html"/>
  <link rel="import" href="https://www.polymer-project.org/0.5/components/core-toolbar/core-toolbar.html"/>
  <link rel="import" href="https://www.polymer-project.org/0.5/components/core-media-query/core-media-query.html"/>
  <link rel="import" href="https://www.polymer-project.org/0.5/components/paper-icon-button/paper-icon-button.html"/>

  <style shim-shadowdom="">

    body {
      font-family: RobotoDraft, 'Helvetica Neue', Helvetica, Arial;
      margin: 0;
      /*padding: 24px;*/
      color: #333;
    }
 
    body.core-narrow {
      padding: 8px;
    }
 
    paper-tabs, core-toolbar {
      background-color: #00bcd4;
      color: #fff;
      box-shadow: 0px 3px 2px rgba(0, 0, 0, 0.2);
    }
 
    core-toolbar paper-tabs {
      box-shadow: none;
    }
 
    paper-tabs[noink][nobar] paper-tab.core-selected {
      color: #ffff8d;
    }
 
    paper-tabs.transparent-teal {
      background-color: transparent;
      color: #00bcd4;
      box-shadow: none;
    }
 
    paper-tabs.transparent-teal::shadow #selectionBar {
      background-color: #00bcd4;
    }
 
    paper-tabs.transparent-teal paper-tab::shadow #ink {
      color: #00bcd4;
    }
 
    h3 {
      font-size: 16px;
      font-weight: 400;
    }
 
  </style>

</head>
<body unresolved="">

  <h3>A. No ink effect and no sliding bar</h3>

  <paper-tabs selected="0" noink="" nobar="">

    <paper-tab>ITEM ONE</paper-tab>
    <paper-tab>ITEM TWO</paper-tab>
    <paper-tab>ITEM THREE</paper-tab>
 
  </paper-tabs>

  <br/>
  <br/>

  <h3>B. The bottom bar appears to indicate the selected tab, but without sliding effect.</h3>

  <paper-tabs selected="0" noink="" noslide="">

    <paper-tab>ITEM ONE</paper-tab>
    <paper-tab>ITEM TWO</paper-tab>
    <paper-tab>ITEM THREE</paper-tab>
 
  </paper-tabs>

  <br/>
  <br/>

  <h3>C. The bar slides to the selected tab</h3>

  <paper-tabs selected="0" noink="">

    <paper-tab>ITEM ONE</paper-tab>
    <paper-tab>ITEM TWO</paper-tab>
    <paper-tab>ITEM THREE</paper-tab>
 
  </paper-tabs>

  <br/>
  <br/>

  <h3>D. Inky Tabs</h3>

  <paper-tabs selected="0">

    <paper-tab>ITEM ONE</paper-tab>
    <paper-tab>ITEM TWO</paper-tab>
    <paper-tab>ITEM THREE</paper-tab>
 
  </paper-tabs>

  <br/>
  <br/>

  <paper-tabs selected="0" class="transparent-teal">

    <paper-tab>ITEM ONE</paper-tab>
    <paper-tab>ITEM TWO</paper-tab>
    <paper-tab>ITEM THREE</paper-tab>
 
  </paper-tabs>

  <br/>
  <br/>

  <h3>E. Scrollable Tabs</h3>

  <paper-tabs id="scrollableTabs" selected="0" scrollable="">

    <paper-tab>NUMBER ONE ITEM</paper-tab>
    <paper-tab>ITEM TWO</paper-tab>
    <paper-tab>THE THIRD ITEM</paper-tab>
    <paper-tab>THE ITEM FOUR</paper-tab>
    <paper-tab>FIFTH</paper-tab>
    <paper-tab>THE SIXTH TAB</paper-tab>
    <paper-tab>NUMBER SEVEN</paper-tab>
    <paper-tab>EIGHT</paper-tab>
    <paper-tab>NUMBER NINE</paper-tab>
    <paper-tab>THE TENTH</paper-tab>
    <paper-tab>THE ITEM ELEVEN</paper-tab>
    <paper-tab>TWELFTH ITEM</paper-tab>
 
  </paper-tabs>

  <br/>
  <br/>

  <h3>F. Link Tabs</h3>

  <paper-tabs selected="0" link="">

    <paper-tab><a href="#item1" horizontal="" center-center="" layout="">ITEM ONE</a></paper-tab>
    <paper-tab><a href="#item2" horizontal="" center-center="" layout="">ITEM TWO</a></paper-tab>
    <paper-tab><a href="#item3" horizontal="" center-center="" layout="">ITEM THREE</a></paper-tab>
 
  </paper-tabs>

  <br/>
  <br/>

  <h3>G. Tabs in Toolbar</h3>

  <core-toolbar class="medium-tall">

    <paper-icon-button icon="menu"></paper-icon-button>
    <div flex="">Title</div>
    <paper-icon-button icon="search"></paper-icon-button>
    <paper-icon-button icon="more-vert"></paper-icon-button>
 
    <div class="bottom fit" horizontal="" layout="">
 
      <paper-tabs selected="0" flex="" style="max-width: 600px;">
 
        <paper-tab>ITEM ONE</paper-tab>
        <paper-tab>ITEM TWO</paper-tab>
        <paper-tab>ITEM THREE</paper-tab>
     
      </paper-tabs>
   
    </div>

  </core-toolbar>

  <br/>
  <br/>

  <core-toolbar class="tall">

    <paper-tabs selected="0" class="bottom" self-end="" style="width: 300px;">

      <paper-tab>ITEM ONE</paper-tab>
      <paper-tab>ITEM TWO</paper-tab>
   
    </paper-tabs>
 
    <div class="bottom" flex=""></div>
 
    <paper-icon-button class="bottom" icon="search"></paper-icon-button>
   
  </core-toolbar>

  <br/>
  <br/>

  <h3>H. Tabs aligned to bottom</h3>

  <paper-tabs selected="0" alignBottom="">

    <paper-tab>ITEM ONE</paper-tab>
    <paper-tab>ITEM TWO</paper-tab>
    <paper-tab>ITEM THREE</paper-tab>
 
  </paper-tabs>

  <!-- detect when window is narrow -->
  <core-media-query id="mediaQuery" query="max-width: 640px"></core-media-query>

  <script>

    document.querySelector('#mediaQuery').addEventListener('core-media-change',
      function(e) {
        document.body.classList.toggle('core-narrow', e.detail.matches);
        document.querySelector('#scrollableTabs').updateBar();
      });

  </script>

</body>


</apex:page>

Demo: https://www.polymer-project.org/0.5/components/paper-elements/demo.html#paper-tabs
--------------------------------------------------------------------------------------------------------------------------