Skip to content

Instantly share code, notes, and snippets.

@unknownuser88
unknownuser88 / gist:10598964
Created April 13, 2014 19:35
hide popover on doc click
$(document).click(function(e) {
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) {
$('.add_btn').popover('hide');
}
});
@unknownuser88
unknownuser88 / gist:9523179
Created March 13, 2014 07:09
disable console
(function() {
try {
var $_console$$ = console;
Object.defineProperty(window, "console", {
get: function() {
if ($_console$$._commandLineAPI)
throw "Sorry, for security reasons, the script console is deactivated";
return $_console$$
},
set: function($val$$) {
@unknownuser88
unknownuser88 / mobile_drag_&_drop.js
Last active July 28, 2020 14:11
mobile drag & drop
$(document).on('pageshow', '#index', function(){
$(".dragzones").draggable({
start: handleDragStart,
cursor: 'move',
revert: "invalid",
});
$(".dropzones").droppable({
drop: handleDropEvent,
tolerance: "touch",
});
@unknownuser88
unknownuser88 / gist:8284947
Created January 6, 2014 16:01
JQUERY GET ELEMENT IDS LIST USING JQUERY.MAP()
$(':checkbox').map(function() {
return this.id;
}).get().join(',');
@unknownuser88
unknownuser88 / gist:8284938
Created January 6, 2014 16:00
JQUERY CONVERT ARRAY TO STRING
var blkstr = $.map(value, function(val,index) {
var str = index + ":" + val;
return str;
}).join(", ");
@unknownuser88
unknownuser88 / gist:8284923
Created January 6, 2014 16:00
hover class toggle
$('div').on("mouseenter mouseleave", function(e) {
$(this).toggleClass('highlight', e.type === "mouseenter");
});
@unknownuser88
unknownuser88 / gist:8284914
Created January 6, 2014 15:59
The Preload CSS Images Function
jQuery.preloadCssImages = function(){
var allImgs = [];//new array for all the image urls
var k = 0; //iterator for adding images
var sheets = document.styleSheets;//array of stylesheets
@unknownuser88
unknownuser88 / gist:8284872
Created January 6, 2014 15:56
sort json by
var people = [
{'name': 'a75','item1': false,'item2': false},
{'name': 'z32','item1': true,'item2': false},
{'name': 'e77','item1': false,'item2': false},
];
function sortByKey(array, key, asc) {
var asc = asc || false;
@unknownuser88
unknownuser88 / gist:8284869
Created January 6, 2014 15:56
FIND THE KEYCODE OF KEYBOARD KEY PRESSED
(function($) {
/* get key code */
function getKeyCode(key) {
//return the key code
return (key == null) ? event.keyCode : key.keyCode;
}
/* get key character */
function getKey(key) {
//return the key
@unknownuser88
unknownuser88 / gist:8284864
Created January 6, 2014 15:55
jQuery Plugin Boilerplate
// jQuery Plugin Boilerplate
// A boilerplate for jumpstarting jQuery plugins development
// version 1.1, May 14th, 2011
// by Stefan Gabos
// remember to change every instance of "pluginName" to the name of your plugin!
(function($) {
// here we go!
$.pluginName = function(element, options) {