Skip to content

Instantly share code, notes, and snippets.

@ballawala-lv
ballawala-lv / padding and margin mixin
Created May 27, 2014 00:39
padding and margin mixin
@mixin generate-margins($val, $horizontal, $vertical, $all) {
@if $vertical == true {
.mt-#{$val} {
margin-top: $val+px;
}
.mb-#{$val} {
margin-bottom: $val+px;
}
.mtb-#{$val} {
margin-top: $val+px;
var iter = -1,
colSize = 3;
angular.forEach(response.data, function(survey,i){
if(i % colSize === 0){
$scope.videoSurveys.push([]);
iter++;
}
$scope.videoSurveys[iter].push(survey);
})
@ballawala-lv
ballawala-lv / stopEvent.js
Created May 7, 2014 19:41
directive to preventDefault and stopPropogation
.directive('stopEvent', function () {
return {
restrict: 'A',
link: function (scope, element, attr) {
element.bind(attr.stopEvent, function (e) {
e.preventDefault();
e.stopPropagation();
});
}
};
@ballawala-lv
ballawala-lv / multipleEmailsDirective.js
Created May 7, 2014 15:26
Check if multiple emails entered (comma seperated) are valid
.directive('multipleEmails', function () {
var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*$/i;
return {
require: 'ngModel',
link: function (scope, elem, attr, ctrl) {
ctrl.$parsers.push(function (viewValue) {
ctrl.$setValidity('multipleEmails', true);
if (viewValue !== "" && typeof viewValue !== "undefined") {
ctrl.$setValidity('multipleEmails', false);
.directive('pagination', ['GTM', function (GTM) {
return {
restrict: 'E',
scope: {
numPages: '=',
currentPage: '=',
onSelectPage: '&',
capPages: '@',
class: '@'
},