Skip to content

Instantly share code, notes, and snippets.

@justintech
Created October 2, 2015 04:06
Show Gist options
  • Save justintech/d6d5bdb8468b79f60663 to your computer and use it in GitHub Desktop.
Save justintech/d6d5bdb8468b79f60663 to your computer and use it in GitHub Desktop.
js
(function() {
$(document).ready(function() {
var $container, gp2;
gp2 = function() {
var autocomplete, input, types;
input = document.getElementById('loc-field');
types = document.getElementById('type-selector');
autocomplete = new google.maps.places.Autocomplete(input);
};
google.maps.event.addDomListener(window, 'load', gp2);
$("#reward-box").bootstrapSwitch();
$container = $('#items-index-ctnr, #user-items-ctnr', 'items-ctnr');
$container.imagesLoaded(function() {
$container.masonry();
});
$container = $('#items-ctnr');
$container.imagesLoaded(function() {
$container.masonry({
itemSelector: '.box',
columnWidth: function(containerWidth) {
return containerWidth / 6;
}
});
});
$container.infinitescroll({
navSelector: '#page-nav',
nextSelector: '#page-nav a',
itemSelector: '.box',
loading: {
finishedMsg: 'No more items to load.',
img: '/assets/masonry/loader.gif'
}
}, function(newElements) {
var $newElems;
$newElems = $(newElements).css({
opacity: 0
});
$newElems.imagesLoaded(function() {
$newElems.animate({
opacity: 1
});
$container.masonry('appended', $newElems, true);
});
});
$('#user-items-ctnr').masonry({
itemSelector: '.box',
columnWidth: function(containerWidth) {
return containerWidth / 10;
}
});
$('#item-show-ctnr').masonry({
itemSelector: '.box',
columnWidth: function(containerWidth) {
return containerWidth / 33;
}
});
Dropzone.autoDiscover = false;
return $('#new_item').dropzone({
acceptedFiles: '.jpeg, .jpg, .png',
maxFilesize: 1,
maxFiles: 100,
addRemoveLinks: true,
paramName: 'item[image]',
clickable: '#image-preview',
headers: {
"X-CSRF-Token": $('meta[name="csrf-token"]').attr('content')
},
previewsContainer: '#image-preview',
thumbnailWidth: 300,
thumbnailHeight: 300,
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 100,
init: function() {
var myDropzone;
myDropzone = this;
this.element.querySelector('button[type=submit]').addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
});
this.on('sendingmultiple', function() {});
this.on('successmultiple', function(files, response) {});
this.on('errormultiple', function(files, response) {});
}
});
});
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment