Skip to content

Instantly share code, notes, and snippets.

View Bewitchedyegor's full-sized avatar

Yegor Ostapenko Bewitchedyegor

View GitHub Profile
@Bewitchedyegor
Bewitchedyegor / add_hashtag.vue
Created January 4, 2018 12:09
Add hash to current link inside browser address bar without reloading the page
<template>
<a href="#cfd" @click="updateLink()">
</template>
<script>
export default {
methods: {
updateLink: function() {
var href = event.currentTarget.getAttribute('href');
history.pushState("", "", "cfd_products"+href);
}
@Bewitchedyegor
Bewitchedyegor / charCount.js
Created November 9, 2017 10:08
Character count
$('textarea').on('input', function () {
$(".js-countChar").fadeIn();
});
$('textarea').on('input', updateCount);
function updateCount() {
var cs = [150 - $(this).val().length];
$('#characters').text(cs);
}
@Bewitchedyegor
Bewitchedyegor / stylingScroll.css
Created November 6, 2017 11:45
Styling scrollbar appearance
.selector::-webkit-scrollbar {
width: 5px;
}
.selector::-webkit-scrollbar-track {
-webkit-box-shadow: transparent;
}
.selector::-webkit-scrollbar-thumb {
border-radius: 10px;
background: #40c4e8;
-webkit-box-shadow: none;
@Bewitchedyegor
Bewitchedyegor / placeholderTrick.html
Created November 6, 2017 09:29
Hide placeholder on input click, get it back on blur when nothing is entered
<input
type="text"
placeholder="enter your text"
onfocus="this.placeholder = ''"
onblur="this.placeholder = 'enter your text'" />
@Bewitchedyegor
Bewitchedyegor / optionSelected.js
Created October 31, 2017 08:57
Add action on option being selected in dropdown
$('#list').change(function() {
if ($(this).val() === '2') {
// Do something for option "b"
}
});
@Bewitchedyegor
Bewitchedyegor / money_mask.js
Created October 12, 2017 15:07
Money input mask based on jQuery-Mask-Plugin
$('#price_per_item, #price_per_item2').length) {
$('#price_per_item, #price_per_item2').mask('000 000 000,00₴', {reverse: true}
);
});
@Bewitchedyegor
Bewitchedyegor / autofill.js
Created October 12, 2017 15:00
Auto-fill any container with value from other input
$("input[id=pickAgeStart]").on('keyup click change', function () {
$('.ageStart').html($(this).val());
});
@Bewitchedyegor
Bewitchedyegor / url_mask.js
Created October 12, 2017 14:52
URL mask based on jquery.mask.js
$('#banner_link').inputmask("url", {
mask: "https://www.*{1,20}[.*{1,20}]",
greedy: false,
clearMaskOnLostFocus: false,
clearIncomplete: false,
definitions: {
'*': {
validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
cardinality: 1,
casing: "lower"
@Bewitchedyegor
Bewitchedyegor / verify_input.js
Created October 12, 2017 14:33
Check if input value is empty and display a message inside
$('.js-checkWeb').click(function () {
if ($('#banner_link').val() === '') { //check if value is empty
$('#banner_link').val('your message here').css('color', 'red');
}
});
@Bewitchedyegor
Bewitchedyegor / redirect.js
Created October 12, 2017 14:14
Simple redirect on click
$('.js-startBannerCamp').click(function () {
window.location.href = "/advert/"; //insert yor link here
});