Skip to content

Instantly share code, notes, and snippets.

@handleman
handleman / custom.property.js
Created September 30, 2014 13:51
custom ui object attribute JqueryUI Autocomplete
var carMake = [{
"make": "Smart",
"id": '200038885'
}, {
"make": "Bomb",
"id": '200038885'
}, {
"make": "Volkswagen",
"id": '200000238'
@handleman
handleman / objectLength.js
Created September 30, 2014 19:50
Get Length of Javascript Object
getObjectLength = function (obj) {
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
}
@handleman
handleman / preventBUbbling.js
Created October 8, 2014 11:52
if Input Fires Keypress Event Twice
self.$inputFilter.on('keyup', function (event) {
text = $(this).val();
event.stopImmediatePropagation();
// data
return false;
}).click(function () {
return false;
});
@handleman
handleman / scrollbar.css
Last active August 29, 2015 14:07
a way to keep the scrollbar present all the time in Mac OS X Lion
/* Overwrite the default to keep the scrollbar always visible */
.showScroll.lion::-webkit-scrollbar {
-webkit-appearance: none;
width: 7px;
}
.showScroll.lion::-webkit-scrollbar-thumb {
border-radius: 4px;
@handleman
handleman / withoutPx.js
Created October 14, 2014 14:35
How to get just numeric part of CSS property with jQuery
$(this).css('marginBottom').replace(/[^-\d\.]/g, '');
@handleman
handleman / detectmac.js
Created October 14, 2014 15:01
Best way to detect Mac OS X or Windows computers with JavaScript or jQuery
var isMac = navigator.platform.toUpperCase().indexOf('MAC')>=0;
var isMacLike = navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i)?true:false;
var isIOS = navigator.platform.match(/(iPhone|iPod|iPad)/i)?true:false;
@handleman
handleman / onsubmit.js
Created November 3, 2014 08:29
How can I listen to the form submit event in pure javascript
var ele = [Your Form Element];
if(ele.addEventListener){
ele.addEventListener("submit", callback, false); //Modern browsers
}else if(ele.attachEvent){
ele.attachEvent('onsubmit', callback); //Old IE
}
@handleman
handleman / services.js
Last active January 8, 2021 01:03 — forked from bullgare/services.js
serialize form - pure js
serialize: function serialize(form)
{
if (!form || form.nodeName !== "FORM") {
return;
}
var i, j,
obj = {};
for (i = form.elements.length - 1; i >= 0; i = i - 1) {
if (form.elements[i].name === "") {
continue;
@handleman
handleman / getRequest.js
Last active August 29, 2015 14:09
function that executes Jquer.ajax to defined url and then launch handler function or return data recevied
var getRequest = function (dataToSend,url,handler) {
if(!dataToSend){
dataToSend = '';
}
$.ajax({
type: 'GET',
url: url,
data:dataToSend,
success: function(data) {
if(typeof handler == 'function'){
@handleman
handleman / gmaps_controls_classifier.js
Last active August 29, 2015 14:10 — forked from matellis/gmaps_controls_classifier.js
hack to give classes on goole map interface elements
controlList = {
'map_type_control': 'margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px; z-index: 11; position: absolute; cursor: pointer; right: 0px; top: 0px; ',
'pan_control': 'cursor: url(https://maps-api-ssl.google.com/intl/en_us/mapfiles/openhand_8_8.cur), default; width: 78px; height: 78px; position: absolute; left: 0px; top: 0px; ',
'zoom_control': 'position: absolute; left: 27px; top: 128px; ',
'streetmap_control': 'width: 32px; height: 38px; overflow-x: hidden; overflow-y: hidden; position: absolute; left: 0px; top: 0px; ',
};
function labelControls() {
$.each(controlList, function(id, attr) {
$('div[style^="' + attr + '"]').attr('class',id);