Skip to content

Instantly share code, notes, and snippets.

View fleimisch's full-sized avatar

Nate Fleimisch Bezlaj fleimisch

  • Slovenia
View GitHub Profile
const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2
})
formatter.format(1000) // "$1,000.00"
formatter.format(10) // "$10.00"
formatter.format(123233000) // "$123,233,000.00"
LOADING
//////////////////////////////////////////////////////////////////////////////////
// queue scripts and fire a callback when loading is finished
head.load("file1.js", "file2.js", function() {
// do something
});
// same as above, but pass files in as an Array
head.load(["file1.js", "file2.js"], function() {
// do something
@fleimisch
fleimisch / s
Created May 27, 2019 20:28
universalLoading("class", "id");
universalLoading("class", "id");
javascript shorthand list: https://www.sitepoint.com/shorthand-javascript-techniques/
SCE function to get and check element // will avoid "of unexpected.." error:
let a = x0(".MobileSearchWrapperHelper");
a ? a.style.display = "block" : void 0;
$(element).is(':visible')
element.offsetWidth > 0 && element.offsetHeight > 0;
window on load:
@fleimisch
fleimisch / s
Created January 9, 2019 18:16
onclick="toggleActive(this, '0', true, false)" on any element a = this b = select parent '0' takes this element '-1' selects first parent, '-2' selects second parent, etc. c = true|false remove/hide this element when clicked outside (great for toolt
onclick="toggleActive(this, '0', true, false)" on any element
a = this
b = select parent '0' takes this element '-1' selects first parent, '-2' selects second parent, etc.
c = true|false remove/hide this element when clicked outside (great for tooltips, popups, etc)
d = run custom function after opening, example: myfunction()
@fleimisch
fleimisch / Custom Checkbox and Radio Buttons.html
Created May 17, 2017 16:34
Custom Checkbox and Radio Buttons
example: https://bootsnipp.com/snippets/ZkMKE
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css">
<div class="container">
<h2>Checkboxes</h2>
<form role="form">
<div class="row">
<div class="col-md-4">
<fieldset>
@fleimisch
fleimisch / label JS events.js
Created March 9, 2017 14:16
Label JS events
$(window).bind("resize.rainbows", function(e){
// do something when any span.rainbows element resizes
});
$(window).unbind("resize.rainbows");
@fleimisch
fleimisch / SCECSS3-Animations.html
Last active October 2, 2018 12:02
SCE CSS3 Animations
https://github.com/daneden/animate.css
Add the class "animated" to the element you want to animate. You may also want to include the class infinite for an infinite loop.
Finally you need to add one of the following classes:
Class Name
bounce flash pulse rubberBand
@fleimisch
fleimisch / Add URL query
Last active December 12, 2016 07:48
Add URL query
UpdateQueryString(key, value, url, redirect)
url is not needed as it will generate automatically unless you want a different one
redirect = true or false
$('#element').hasClasses(['class1', 'class2', 'class3']);