Skip to content

Instantly share code, notes, and snippets.

View manuelcanga's full-sized avatar
🎯
Focusing

Manuel Canga manuelcanga

🎯
Focusing
View GitHub Profile
@manuelcanga
manuelcanga / backup.sh
Created January 7, 2022 21:48
Create app backup
#!/bin/sh
#set -x
INSTANCIA=$1
TODAY=$(date -I)
### ------------------------------------------------------------
@manuelcanga
manuelcanga / app_gettext.sh
Last active February 26, 2022 08:28
Searching and creating gettext entries
APP_ROOT=$1
if [ $# == 2 ]
then
echo "error: app path?"
fi
@manuelcanga
manuelcanga / scripts.js
Last active February 26, 2022 08:26
Upload html5 images to a tree
(function($) {
jQuery.fn.html5_upload = function(options) {
var available_events = ['onStart', 'onStartOne', 'onProgress', 'onFinishOne', 'onFinish', 'onError'];
var options = jQuery.extend({
onStart: function(event, total) {
@manuelcanga
manuelcanga / info.md
Created January 7, 2022 20:39
Elemento :before o :after no se visualiza

Si has añadido una regla :before o :after y parece que no toma los estilos es porque para que estos se necesita el atributo content aunque sea vacío. Es decir:

div.miclase:before {

  content: '';
}
@manuelcanga
manuelcanga / scripts.js
Created January 7, 2022 19:27
get size of screen (js)
trasweb = trasweb | {};
trasweb.getSize = function () {
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight || e.clientHeight || g.clientHeight;
@manuelcanga
manuelcanga / scripts.js
Created January 7, 2022 19:27
get position of an element in the web (js)
trasweb.getPosition = function (el) {
var xPos = 0;
var yPos = 0;
while (el) {
if (el.tagName === "BODY") {
// deal with browser quirks with body/window/document and page scroll
var xScroll = el.scrollLeft || document.documentElement.scrollLeft;
var yScroll = el.scrollTop || document.documentElement.scrollTop;
@manuelcanga
manuelcanga / scripts.js
Created January 7, 2022 19:26
Cambio de viewport según la orientación
/** Basado en: https://stackoverflow.com/questions/15040408/achieving-min-width-with-viewport-meta-tag */
document.addEventListener('DOMContentLoaded', function () {
trasweb.orientationchange();
});
trasweb.orientationchange = function (force_orientation) {
var vp = document.getElementById('viewport');
var orientation = window.orientation;
var is_desktop = document.body.classList.contains('desktop');
@manuelcanga
manuelcanga / scripts.js
Created January 7, 2022 19:25
Lazy load de imágenes (con soporte responsive)
/**
Alternativa de menos de 1kb: https://apoorv.pro/lozad.js/demo/
*/
document.addEventListener('DOMContentLoaded', function () {
var bLazy = new Blazy({
src: 'data-src',
selector: '*[data-src]',
offset: 500,
breakpoints: [
@manuelcanga
manuelcanga / jquery.js
Created January 7, 2022 19:23
Ajustar zoom al ancho de la pantalla (jquery / vanilla)
jQuery(document).ready(function($){
nsZoomZoom();
$( window ).resize(function() {
nsZoomZoom();
});
function nsZoomZoom() {