Skip to content

Instantly share code, notes, and snippets.

View AnkurVyas-BTC's full-sized avatar
🎯
Karma rules world... You get whatever you give!

Ankur Vyas AnkurVyas-BTC

🎯
Karma rules world... You get whatever you give!
View GitHub Profile
@AnkurVyas-BTC
AnkurVyas-BTC / progessive_image_loading.js
Created January 7, 2017 12:15
Code for Progressive Image Loading
window.onload = function() {
var placeholder = $('.placeholder');
placeholder.each( function(index) {
// 1: load small image and show it
var smallImgElement = $(this).find('.img-small');
console.log(smallImgElement);
var img = new Image();
img.src = smallImgElement.attr('src');
@AnkurVyas-BTC
AnkurVyas-BTC / page_performance_blog_load.js
Last active January 7, 2017 13:22
Calculation time difference for the Page Load
// When the page starts loading
var timerStart = Date.now();
// Executes when complete page is fully loaded, including all frames, objects and images
$(window).load(function () {})
loadTime = (Date.now() - timerStart) / 1000;
$('#page_load').html(loadTime + ' s');
});
@AnkurVyas-BTC
AnkurVyas-BTC / tag-it-after-before-callbacks.js
Created August 15, 2016 07:14
Before and after callbacks for the tag it
$(“#tags”).tagit({
availableTags: [‘ruby’, ‘rails’,’range’, ‘ready’],
tagLimit: 2,
beforeTagAdded: function(event, ui){
// Do something special as you want
}
afterTagAdded: function(event, ui){
// Do something special as you want
}
beforeTagRemoved: function(event, ui){
@AnkurVyas-BTC
AnkurVyas-BTC / tag-it-on-limit-exceeded.js
Created August 15, 2016 07:12
On limit exceeded tag it
$(“#tags”).tagit({
availableTags: [‘ruby’, ‘rails’,’range’, ‘ready’],
tagLimit: 2,
onTagLimitExceeded: function(event, ui){
alert('You cannot add more than 2 tags!')
}
});
@AnkurVyas-BTC
AnkurVyas-BTC / tag-it-tag-limit.js
Created August 15, 2016 07:10
Tag limit for tag it
$(“#tags”).tagit({
availableTags: [‘ruby’, ‘rails’,’range’, ‘ready’],
tagLimit: 2
});
@AnkurVyas-BTC
AnkurVyas-BTC / tag-it-available-tags.js
Created August 15, 2016 07:10
Tag it available tags
$(“#tags”).tagit({
availableTags: [‘ruby’, ‘rails’,’range’, ‘ready’]
});
@AnkurVyas-BTC
AnkurVyas-BTC / tag-it-view.html.erb
Created August 15, 2016 06:24
View file for the tag it demo
<ul id="tags">
<li>My Tag 1</li>
<li>My Tag 2</li>
</ul>
<script type="text/javascript">
$(document).ready(function() {
$("#tags").tagit();
});
</script>
@AnkurVyas-BTC
AnkurVyas-BTC / tag-it-structure.js
Created August 15, 2016 06:20
Tag it structure for js files
//= require jquery-ui
//= require tag-it
*= require jquery-ui
*= require jquery-ui.structure
*= require jquery-ui.theme
*= require jquery.tagit
@AnkurVyas-BTC
AnkurVyas-BTC / jquery-ui.theme.scss
Created August 15, 2016 06:02
Jquery UI theme scss file
/*!
* jQuery UI CSS Framework 1.12.0
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* http://api.jqueryui.com/category/theming/
*