Ads

Thursday, 18 December 2014

jQuery Tristate


Download Demo
jQuery standalone tristate (indeterminate) checkbox with pseudo selectors and optional value modification and .val() overwrite. Standalone, so usable for purposes other than list/tree marking.

Features
  • Simple syntax: .tristate()
  • Options to set alternative values for true, false and null state.
  • Access using val() (when alternative values specified).
  • Set state using widget-like syntax .tristate(‘state’, true/false/null);
  • :tristate, :indeterminate and :determinate pseudo selectors included.
  • Indeterminate state can be set using indeterminate=”indeterminate” attribute.
  • Alternative values can be set using checkedvalue, uncheckedvalue and indeterminatevalueattributes or options.
  • HTML attributes modified by the plugin.
  • Should support every major browser, including IE6.
Browser support
Tested with v1.0.5
  • Chrome 31
  • FireFox 25
  • Opera 17
  • Internet Explorer 10
1. INCLUDE CSS AND JS FILES
<!-- jQuery/jQueryUI (hosted) -->
<!-- Markdown parser -->
<!-- Prettyprint -->
<link href="https://google-code-prettify.googlecode.com/svn/loader/prettify.css" rel="stylesheet" type="text/css"/>
 
<script src="jquery.tristate.js"></script>
2. HTML
<input type="checkbox" class="tristate"/>
<input type="checkbox" class="tristate" checked="checked"/>
<input type="checkbox" class="tristate" indeterminate="1"/>
3. JAVASCRIPT
$(function() {
        $('.tristate').tristate({
            change: function(state, value) {
                console.log('Input:', this);
                console.log('Unknown?', state === null);
                console.log('Known?', state !== null);
                console.log('Checked?', state === true);
                console.log('Unhecked?', state === false);
            }
        });
});
4. OPTIONS
  • state: true for checked, false for unchecked or null for undeterminate.
  • value: Set the value in order to set the state. Only works if values are specified for checked, uncheckedand/or indeterminate.
  • checked: The value to return for checked state. If not specified, the value in the value attribute is returned.
  • unchecked: The value to return for unchecked state. If not specified, the value in the value attribute is returned.
  • indeterminate: The value to return for indeterminate state. If not specified, the value in the value attribute is returned.
5. EVENTS
  • init(state, value): Triggered upon initialization. State can be true, false or null. Value is the value as it would be returned from .val().
  • change(state, value): Triggered whenever the state changes. State can be true, false or null. Value is the value as it would be returned from .val().
6. METHODS
  • state: Either get or set the state of the checkbox. Uses true for checked, false for unchecked or null for indeterminate state.
  • value: Get the current value or set the state by specifying the value. Setting the value only works if you have specified values (either using expando attributes or options) for the different states.

Responsiv Bootstrap Data, package, price Table




Download Demo
Bootstrap Data Table

  • sorting, pagination and search for tables
  • bootstrap framework is used for the styling, in the bootstrap data table css file there are only a view lines like positioning elements
  • fontawesome arrow icons are used for sorting, you can choose the arrows you like the most
1. INCLUDE CSS AND JS FILES
<link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
<link href="css/font-awesome.min.css" type="text/css" rel="stylesheet">
<link href="css/jquery.bdt.css" type="text/css" rel="stylesheet">
 
<script src="http://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<script src="js/jquery.sortelements.js" type="text/javascript"></script>
<script src="js/jquery.bdt.js" type="text/javascript"></script>
2. HTML
<table class="table table-hover" id="bootstrap-table">
    <thead>
    <tr>
        <th>#ID</th>
        <th>Username</th>
        <th>First Name</th>
        <th>Last Name</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td>200</td>
        <td>janedoe</td>
        <td>Yane</td>
        <td>Doe</td>
    </tr>
    <tr>
        <td>100</td>
        <td>zanedoe</td>
        <td>Jane</td>
        <td>Moe</td>
    </tr>
    <tr>
        <td>300</td>
        <td>aanedoe</td>
        <td>Lane</td>
        <td>Doe</td>
    </tr>
    <tr>
        <td>100</td>
        <td>canedoe</td>
        <td>Jane</td>
        <td>Boe</td>
    </tr>
    </tbody>
</table>
3. JAVASCRIPT
$(document).ready( function () {
    $('#bootstrap-table').bdt();
});
4. OPTIONS
  • pageRowCount : initial row count per page / default is 10
  • arrowDown : font awesome arrow down icon / default is “fa-angle-down”
  • arrowUp : font awesome arrow up icon / default is “fa-angle-up”

Bigpicture.js

Download Demo
Bigpicture.js is a library that allows infinite panning and infinite zooming in HTML pages.
1. INCLUDE CSS AND JS FILES
<link href="bigpicture.css" rel="stylesheet">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script type="text/javascript" src="bigpicture.js"></script>
2. HTML
<div id="bigpicture-container">
    <div id="bigpicture" data-zoom="1" data-x="721" data-y="480">
      <div contenteditable="true" class="text" data-size="57" data-x="941" data-y="735">What is BigPicture ?</div>
      <div contenteditable="true" class="text" data-size="11.7647" data-x="977.918" data-y="812.327">BigPicture is like an infinite notepad, in which you can pan (north/south/east/west),<br />but also in which you can ZOOM ! (Nearly) infinitely many times.<br /></div>
      <div contenteditable="true" class="text" data-size="20" data-x="1589.92" data-y="593.974">USAGE<br />######<br /><br /><span class="fa fa-search"></span>   Search : F3 or CTRL+F<br /><br /><span class="fa fa-arrows"></span>   Pan : click and drag<br /><br /><span class="fa fa-fw">? </span>  Move text : CTRL+click and drag<br /><br /><span class="fa fa-search-plus"></span>   Zoom In : PageDown  or CTRL+ or<br />                       mousewheel  or double-click<br /><span class="fa fa-search-minus"></span>   Zoom Out : PageUp  or CTRL- or<br />                         mousewheel  or CTRL+double-click<br /><br /><span class="fa fa-cloud"></span>   Biggest picture : F2  (try it twice!)<br /></div>
      <div contenteditable="true" class="text" data-size="20" data-x="853.918" data-y="946.974">Easy write in one click : click anywhere and write!</div>
      <div contenteditable="true" class="text" data-size="6.92042" data-x="921.984" data-y="979.527">No need to go into a Toolbox and choose to create a new Textbox... Just click anywhere and write !</div>
      <div contenteditable="true" class="text" data-size="20" data-x="1569.31" data-y="1022.37">More features to come soon...</div>
      <div contenteditable="true" class="text" data-size="20" data-x="1200.31" data-y="558.372">Don't forget to zoom out...<br />... to see the BigPicture<br /></div>
      <div contenteditable="true" class="text" data-size="34" data-x="2178.21" data-y="686.772">TODO</div>
      <div contenteditable="true" class="text" data-size="11.7647" data-x="2171.79" data-y="731.566">eat more vegetables!</div>
      <div contenteditable="true" class="text" data-size="2.39461" data-x="2184.11" data-y="745.768"><br /></div>
      <div contenteditable="true" class="text" data-size="11.7647" data-x="2307.46" data-y="682.461">buy some chocolate</div>
      <div contenteditable="true" class="text" data-size="11.7647" data-x="2217.45" data-y="650.697">Gaelle's website</div>
      <div contenteditable="true" class="text" data-size="6.92042" data-x="2301.16" data-y="716.672">playlist for next party</div>
      <div contenteditable="true" class="text" data-size="1.40859" data-x="2309.22" data-y="725.513">Tove Lo - Stay High<br />Ariana Grande - Love Me Harder ft. The Weeknd (Official Audio)<br />Cut Copy - Lights Shine On<br />Porter Robinson - Sea of Voices<br /><br /></div>
      <div contenteditable="true" class="text" data-size="98.26" data-x="-2070.87" data-y="1698.75">This is not the biggest text yet... <br /></div>
      <div contenteditable="true" class="text" data-size="482.751" data-x="3394.25" data-y="3171.58">Think outside the box.</div>
      <div contenteditable="true" class="text" data-size="20" data-x="867.486" data-y="699.86">mind mapping tool</div>
      <div contenteditable="true" class="text" data-size="4.07083" data-x="2185.72" data-y="745.497">carrots<br />salad<br />artichokes<br />tomatoes<br />spinach<br /></div>
      <div contenteditable="true" class="text" data-size="11.7647" data-x="1593.01" data-y="1051.39">(follow me on twitter @JosephErnest)</div>
    </div>
</div>



Tuesday, 16 December 2014

Focusable



Download   Demo
Focusable is an awesome and lightweight library for performing spotlight in your DOM elements, setting an animated overlay to the rest of the page.
1. INCLUDE JS FILES
<script src="jquery-2.1.1.js"></script>
2. HTML
<div class="example">
    <header>
      <button class="show" data-selector="header">Focus header</button>
      <button class="show" data-selector="ul">Focus list</button>
      <button class="show" data-selector="li:first">Focus first item</button>
      <button class="show" data-selector="img">Focus image</button>
    </header>
    <ul>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
      <li>5</li>
      <li>6</li>
      <li>7</li>
      <li>8</li>
      <li>9</li>
      <li>10</li>
    </ul>
</div>
<div class="options">
    <h2>Options:</h2>
    <ul>
      <li>- fadeDuration (seconds) <input type="text" id="fade-duration" value="700"></li>
      <li>- hideOnClick <input type="checkbox" id="hide-on-click" checked></li>
      <li>- hideOnEsc <input type="checkbox" id="hide-on-esc" checked></li>
      <li>- findOnResize <input type="checkbox" id="find-on-resize"></li>
    </ul>
</div>
3. JAVASCRIPT
(function() {
  $(document).ready(init);
 
  function init() {
    $('.show').on('click', show);
    $('.hide').on('click', hide);
 
    function show() {
      var selector = $(this).attr('data-selector');
      var options = getOptions();
      Focusable.setFocus($(selector), options);
    }
 
    function hide() {
      Focusable.hide();
    }
  }
 
  function getOptions() {
    return {
      fadeDuration: parseInt($('#fade-duration').val()),
      hideOnClick: $('#hide-on-click').is(':checked'),
      hideOnESC: $('#hide-on-esc').is(':checked'),
      findOnResize: $('#find-on-resize').is(':checked')
    };
  }
})();
4. API
Set spotlight (jQuery style)
$('#my-element').setFocus(options);
Set spotlight (through library)
Focusable.setFocus($('#my-element'), options);
Refresh current focused element
Focusable.refresh();
Hide spotlight
Focusable.hide();
5. OPTIONS

Property Value Default Description
fadeDuration Number 700 Duration of the overlay transition (milliseconds).
hideOnClick Boolean false Hides the overlay when the user click into it.
hideOnESC Boolean false Hides the overlay when the user press Esc.
findOnResize Boolean false Refind the element in the DOM in case that the element don’t still exists.

textAssist – a elegant assistant for your users about texts



Download   Demo
textAssist is the smart auto text assistant script with highly customizable options. This script uses the jQuery framework and you can use it on dynamic web pages. textAssist helps web developers in making web sites more usable and user friendly.
With the help of this plugin a web page could be easily assisted for users who selected some texts on it.
Features
  • jQuery capabilities.
  • Highly Flexible and Customizable.
  • Highly User Interface Design.
  • Multilanguage support.
  • Customizable through css.
  • Extremely simple configuration.
  • Auto Assist.
  • Auto adjustment.
  • Customizable items.
  • Items could be builded from JSON hash.
  • Unlimited items.
  • Items can contain HTML tags.
  • Customizable actions.
  • Works in all browsers.
1. INCLUDE CSS AND JS FILES
<link rel="stylesheet" href="textassist.css" media="screen">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="textassist.min.js"></script>
2. HTML
<div class="container" id="container">
 <h1 class="logo">textAssist<span>A powerful and elegant assistant for your users about texts. Select some Words, URLs and Emails from below.</span></h1>
 <h3>Proin ullamcorper congue mauris.</h3>
 <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam velit justo, malesuada at, egestas vitae, lacinia nec, mauris. Duis auctor, nisl et venenatis dapibus, turpis risus tempus dolor, at vehicula metus enim et neque. Mauris sed lectus. Maecenas tempor, augue quis tincidunt imperdiet, dolor ante mattis est, sit amet vulputate libero arcu quis turpis. Sed varius, neque sit amet ornare ullamcorper, massa orci vestibulum purus, sit amet ultricies enim purus nonummy nibh. Nullam ultrices. Nam odio. Vestibulum posuere magna. Suspendisse potenti. Cras vitae nunc non tortor euismod rhoncus. Etiam nonummy. Aenean sodales. Suspendisse tempus, mi ac consequat venenatis, lorem sapien scelerisque lacus, sit amet sagittis nunc ante non turpis. Nunc ornare.</p>
</div>
3. JAVASCRIPT

$(document).ready(function(){

 function isValidURL(url){
  var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
  return RegExp.test(url);
 }

 function isValidEmail(email) {
  var RegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  return RegExp.test(email);
 }

 $('body').textAssist({
  items: [
   {
    title: "Go to &quot;{%s}&quot;",
    classN: "goto",
    onShow: function(text, offset) {
     if(!isValidURL(text) || isValidEmail(text)) offset.hide();
    },
    onClick: function(text, offset){
     window.open('http://'+text.replace('http://'));
    }
   },
   {
    title: "Mail to &quot;{%s}&quot;",
    classN: "mailto",
    onShow: function(text, offset) {
     if(!isValidEmail(text)) offset.hide();
    },
    onClick: function(text, offset){
     window.location.href = 'mailto:'+text;
    }
   },
   {
    title: "Search for &quot;{%s}&quot;",
    onClick: function(text, offset){
     return false;
    },
    classN: "search",
    href: "http://google.com/search?q={%s}",
    target: "_blank"
   },
   {
    title: "Wikipedia (en)",
    classN: "wikipedia",
    href: "http://en.wikipedia.org/w/index.php?title=Special:Search&search={%s}",
    target: "_blank",
    onShow: function(text, offset) {
     if(isValidEmail(text) || (text.length > 50)) offset.hide();
    }
   },
   {
    title: "Translate",
    classN: "translate",
    href: "http://translate.google.com/?q={%s}",
    target: "_blank",
    onShow: function(text, offset) {
     if(isValidEmail(text)) offset.hide();
    }
   },
   {
    divider: true,
    onShow: function(text, offset) {
     if(isValidEmail(text)) offset.hide();
    }
   },
   {
    title: "Map with Google",
    classN: "map",
    href: "http://maps.google.com/maps?q={%s}",
    onShow: function(text, offset) {
     if(isValidEmail(text)) offset.hide();
    }
   },
   {
    divider: true,
    onShow: function(text, offset) {
     if(isValidEmail(text)) offset.hide();
    }
   },
   {
    title: "Email",
    classN: "email",
    href: "mailto:someone@some.domain?body={%s}",
    onShow: function(text, offset) {
     if(isValidEmail(text)) offset.hide();
    }
   }
  ]
 });

});