Skip to content

Instantly share code, notes, and snippets.

@dimitrianoudi
dimitrianoudi / gist:8758b7f76361f20d73829f1fb4a34701
Last active October 21, 2018 18:40
A collection of handwritten Angular.js filters
/**
* Capitalize word
*/
eReceipts.filter('capitalize', function() {
return function(context) {
return (context || '').charAt(0).toUpperCase() + (context || '').slice(1);
};
});
/**
@dimitrianoudi
dimitrianoudi / emailValidation.js
Last active January 4, 2016 15:27
Overrides default Angular validation directive with focus on top-level domain format validation (eg someone@example.com instead of someone@example)
'use strict';
angular.module('frontend-angular.common')
.directive('emailValidation', function() {
var EMAIL_REGEXP = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return {
require: 'ngModel',
restrict: '',
@dimitrianoudi
dimitrianoudi / screencenter.js
Created May 23, 2014 11:26
jQuery prototype that can center an element in the middle of the screen
jQuery.fn.screencenter = function () {
this.css("position","fixed");
this.css("top", ($(window).height() / 2) - (this.outerHeight() / 2));
this.css("left", ($(window).width() / 2) - (this.outerWidth() / 2));
return this;
}
@dimitrianoudi
dimitrianoudi / ipadclick.js
Created May 23, 2014 11:25
Fix click on iPad
var userAgent = navigator.userAgent, event = (userAgent.match(/iPad/i)) ? "touchstart" : "click";
@dimitrianoudi
dimitrianoudi / raphaeljs_image_rotation
Last active December 18, 2015 18:19
Continuous Image Rotation with RaphaelJS
/*
* Copyright MIT © <2013> <Dimitri Anoudis>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
var updateLayout = function() {
if (window.innerWidth != currentWidth) {
currentWidth = window.innerWidth;
var orient = (currentWidth == 320) ? "profile" : "landscape";
document.body.setAttribute("orient", orient);
window.scrollTo(0, 1);
}
};
iPhone.DomLoad(updateLayout);
@dimitrianoudi
dimitrianoudi / navitemsbgcolour
Created May 19, 2013 14:43
Adding some background colour to the different menu items
.nav li:nth-child(6n+1) {
background: rgb(208, 101, 3);
}
.nav li:nth-child(6n+2) {
background: rgb(233, 147, 26);
}
.nav li:nth-child(6n+3) {
background: rgb(22, 145, 190);
@dimitrianoudi
dimitrianoudi / navnotouch
Created May 19, 2013 14:41
Hover effect for the whole navigation to make the hovered item stand out
.no-touch .nav ul:hover a {
color: rgba(249, 249, 249, .5);
}
.no-touch .nav ul:hover a:hover {
color: rgba(249, 249, 249, 0.99);
}
@dimitrianoudi
dimitrianoudi / navallscreensizes
Created May 19, 2013 14:40
Global CSS that are applied for all screen sizes
.nav ul {
max-width: 1240px;
margin: 0;
padding: 0;
list-style: none;
font-size: 1.5em;
font-weight: 300;
}
.nav li span {
@dimitrianoudi
dimitrianoudi / removewebkitbgontap
Created May 19, 2013 14:36
Remove the blue Webkit background when element is tapped
a, button {
-webkit-tap-highlight-color: rgba(0,0,0,0);
}