Jan 15, 2015 Tag: Javascript

Looking for Wisdom about Javascript

Ongoing attempt to collect clever stuff about Javascript. Will be updated as needed.

Updated on Dec 14, 2016

Navigate this page:

Incoming

To be sorted:

Libstacks

JQuery

<script src="//code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" type="text/javascript"></script>

Bootstrap

  • http://www.bootstrapcdn.com/

    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.css" rel="stylesheet">
    
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.js" type="text/javascript"></script>
    
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
    

Modernizr

<script src="//modernizr.com/downloads/modernizr-latest.js" type="text/javascript"></script>

Parsley

<script src="//cdnjs.cloudflare.com/ajax/libs/parsley.js/2.0.7/parsley.js" type="text/javascript"></script>

<script src="//cdn.jsdelivr.net/parsleyjs/2.0.7/parsley.js" type="text/javascript"></script>
<script src="//cdn.jsdelivr.net/parsleyjs/2.0.7/parsley.min.js" type="text/javascript"></script>
<script src="//cdn.jsdelivr.net/parsleyjs/2.0.7/parsley.remote.js" type="text/javascript"></script>
<script src="//cdn.jsdelivr.net/parsleyjs/2.0.7/parsley.remote.min.js" type="text/javascript"></script>

Underscore

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.1/underscore-min.js"  type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.1/underscore-min.map" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.1/underscore.js"      type="text/javascript"></script>

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore-contrib/0.3.0/underscore-contrib.js"     type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore-contrib/0.3.0/underscore-contrib.min.js" type="text/javascript"></script>

<script src="//cdn.jsdelivr.net/underscorejs/1.8.1/underscore-min.js"  type="text/javascript"></script>
<script src="//cdn.jsdelivr.net/underscorejs/1.8.1/underscore-min.map" type="text/javascript"></script>
<script src="//cdn.jsdelivr.net/underscorejs/1.8.1/underscore.js"      type="text/javascript"></script>

A Parsley Dev Starter

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>Parsley starter</title>
    <style>
        input {
            display: block;
        }
    </style>
</head>

<body>
    <form id="formid" action="">
        <label for="number">Number</label>
        <input type="text" name="number" id="number" value="" required/>
        <label for="email">Email</label>
        <input type="email" name="email" id="email" value="" required/>
        <input type="submit" name="submit" id="submit" value="submit"/>
    </form>

    <script src="//code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/parsley.js/2.0.7/parsley.js" type="text/javascript"></script>

    <script type='text/javascript'>//<![CDATA[
        $(document).ready(function () {
            $("#formid").parsley();
        });//]]>
    </script>

</body>
</html>

Solutions

Copy to clipboard

2016-12-14

Usage example

Seen at ...:

! function() {
   $('[data-docs-code]').each(function(index, value) {
      var copyBtnId = 'copy-btn-' + index.toString();
      var $button = $('<button class="docs-code-copy" id="' + copyBtnId + '">Copy</button>');
      var text = $(this).find('code').text().replace('&lt;', '<').replace('&gt;', '>');
      $(this).prepend($button);
      var clipboard = new Clipboard('#' + copyBtnId, {
         text: function() {
            return text;
         }
      });
      clipboard.on('success', function(event) {
         $button.text('Copied!');
         window.setTimeout(function() {
            $button.text('Copy');
         }, 3000);
      });
      clipboard.on('error', function(event) {
         console.error('Action:', event.action);
         console.error('Trigger:', event.trigger);
      });
   });
}();

Tutorials

  • Learning Advanced JavaScript: http://www.mybridge.co/view/9935

    This tutorial contains code and discussion from the upcoming book Secrets of the JavaScript Ninja by John Resig.

Comments

comments powered by Disqus

Previous topic

Looking for Wisdom about JQuery

Next topic

Looking for Wisdom about MySql

Tags

Archives

Languages

Recent Posts

This Page