Skip to content

Instantly share code, notes, and snippets.

View aseredenko's full-sized avatar
💪

Alexander Seredenko aseredenko

💪
View GitHub Profile
function getScrollTop(){
if(typeof pageYOffset!= 'undefined'){
//most browsers except IE before #9
return pageYOffset;
}
else{
var B= document.body; //IE 'quirks'
var D= document.documentElement; //IE with doctype
D= (D.clientHeight)? D: B;
return D.scrollTop;
@aseredenko
aseredenko / skype.html
Last active November 29, 2015 18:49
Disable skype appearance links
<meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" />
$(document).click( function (event) {
if ($(event.target).closest(".page-navigation").length
|| $(event.target).closest(".nav-switcher").length) return;
// What to do on click
event.stopPropagation();
});
@aseredenko
aseredenko / CheckInputSymbols.js
Created January 19, 2016 14:15
validateInputSymbolsByRegExp
function isRussian(input) {
var value = input.value;
var rep = /[\x00-\x7F]/;
if (rep.test(value)) {
value = value.split(rep).join("");
input.value = value;
}
}
@aseredenko
aseredenko / AutomaticMinDate
Created January 19, 2016 14:23
Add minimal date which calculated automaticly for input (in Example -75 years from current day)
// Add minimal value for date input
var date = new Date();
var currentYear = date.getFullYear();
var currentMonth = ('0' + (date.getMonth() + 1).toString()).slice(-2);
var currentDay = ('0' + (date.getDate()).toString()).slice(-2);
var minDate = currentYear-75 + "-" + currentMonth + "-" + currentDay;
@aseredenko
aseredenko / add-modal-open-class-bootstrap.js
Created June 27, 2016 12:26
Add "modal-open" class when hid one modal box and show another. Bootstrap
$(document).on('hidden.bs.modal', function (event) {
if ($('.modal:visible').length) {
$('body').addClass('modal-open');
}
});
function createCookie(name, value, expires, path, domain) {
var cookie = name + "=" + escape(value) + ";";
if (expires) {
// If it's a date
if(expires instanceof Date) {
// If it isn't a valid date
if (isNaN(expires.getTime()))
expires = new Date();
}
@aseredenko
aseredenko / urlbackgroundimage.js
Created September 9, 2016 15:02
Get url from css background-image
$("div").click(function() {
var bg = $(this).css('background-image');
bg = bg.replace('url(','').replace(')','').replace(/\"/gi, "");
alert(bg);
});
@aseredenko
aseredenko / gulp-compressjs.js
Created September 10, 2016 14:22
Gulp function for compresing js files
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var rename = require("gulp-rename");
gulp.task('compressjs', function () {
gulp.src('js/*.js')
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist'))
})
@aseredenko
aseredenko / defaultgulpfile.js
Created September 10, 2016 15:05
Default gulpfile (minify js, css, compile scss)
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var rename = require("gulp-rename");
var uglifycss = require('gulp-uglifycss');
var sass = require('gulp-sass');
gulp.task('default', function (){
gulp.watch('js/*.js', ['compressjs']);
gulp.watch('css/*.css', ['compresscss']);