Skip to content

Instantly share code, notes, and snippets.

View Metaviolet's full-sized avatar

Zaira Vega Metaviolet

View GitHub Profile
@Metaviolet
Metaviolet / js-gulpfile-useful-basic
Created April 7, 2017 17:05
Useful Gulpfile, sass, prefix, miniy, live server, js min, etc.
//Require plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
@Metaviolet
Metaviolet / jquery-cookie-validation-snippet.js
Created November 25, 2016 18:46
jquery-cookie-validator
@Metaviolet
Metaviolet / jquery-validator-specialChar
Created November 8, 2016 18:29
jQuery validator method for detecting special characters and symbols
jQuery.validator.addMethod("specialChar", function(value, element) {
return this.optional(element) || /([0-9a-zA-Z\s])$/.test(value);
}, "Este campo no admite símbolos ni caracteres especiales.");
jQuery.validator.addMethod("lettersonly", function(value, element){
return this.optional(element) || /^[a-z áãâäàéêëèíîïìóõôöòúûüùç]+$/i.test(value);
}, "Este campo solo acepta letras y espacios");
@Metaviolet
Metaviolet / jquery_mobile_browser_detection_v2
Created October 5, 2016 15:58
jquery_mobile_browser_detection_v2
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
@Metaviolet
Metaviolet / js-mobile-browser-detection
Created March 31, 2016 23:09
Detección de navegador móvil
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
// some code..
}
//jQuery way
$.browser.device = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
@Metaviolet
Metaviolet / jquery-detect-orientation-and-block
Created March 31, 2016 18:59
Mostrar imágen para bloquear rotación de teléfono a vertical
//Suponiendo que tenemos un contenedor con una imagen que nos indica que giremos el teléfono
$(window).load(function(){
//al cargar la página evalúa si el ancho es mayor que el alto, lo que significaría que el teléfono esta en posición landscape
if(window.innerWidth > window.innerHeight){
$('#turnPhone').fadeIn('fast');
}
});
/*---------- Eventos en el cambio de orientación del dispositivo ----------*/
@Metaviolet
Metaviolet / checkScroll.js
Created November 10, 2015 19:39
JQUERY- Check Scroll funciton to see if an element is in the top of the page and refresh on scroll
(function($){
/* trigger when page is ready */
$(document).ready(function (){
// your functions go here
var $animation_elements = $('.animation-element');
var $window = $(window);
function check_if_in_view() {
@Metaviolet
Metaviolet / CSS-Smooth-for-anchors
Created November 3, 2015 19:13
Smooth scroll for anchors
/* Smooth scrolling para anclas */
$('a.smooth').on('click', function(e) {
e.preventDefault();
var $link = $(this);
var anchor = $link.attr('href');
$('html, body').stop().animate({
scrollTop: $(anchor).offset().top
}, 1000);
});
@Metaviolet
Metaviolet / css-center-horizontal-vertical
Created October 20, 2015 22:26
CSS - Center horizontally and vertically an AP object
.object{
position:absolute;
margin:auto;
left:0;
right:0;
}
@Metaviolet
Metaviolet / styl-center-horizontal-n-vertical
Last active October 20, 2015 22:29
STYLUS - snippet to center horizontally and vertically an element
#logo
position: absolute
top: 50%
left: 50%
width: w = 150px
height: h = 80px
margin-left: -(w / 2)
margin-top: -(h / 2)