Skip to content

Instantly share code, notes, and snippets.

Avatar

Alejandro García Iglesias alejandroiglesias

View GitHub Profile
View WindowInstanceMap.js
import Vue from 'vue'
export default class extends Vue {
constructor() {
super({
data() {
return {
scrollY: 0
}
},
@alejandroiglesias
alejandroiglesias / flatten-array.js
Last active Sep 6, 2016
Recursively flattens arbitrarily nested arrays.
View flatten-array.js
/**
* Recursively flattens arbitrarily nested arrays.
*
* @param {Array} array The array to flatten.
* @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array.
*/
function flattenArray(array, result = []) {
if (!Array.isArray(array)) throw new TypeError('Called on non-array.');
array.forEach(item => {
@alejandroiglesias
alejandroiglesias / index.html
Created Dec 9, 2015
Barebones implementation of RRSSB
View index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/bower_components/rrssb/css/rrssb.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.css">
</head>
View buyer-rfp-notification.js
var _pageConfirm = {
include: 'partials/buyer/rfp-detail/send-confirmation.html',
header: 'Confirmation',
primary_button: {
label: "Done",
css_classes: "btn-success"
},
do_load: function() {
return (($scope.recipientsToNotify.length > 0) || ($scope.recipientsToUpdate.length > 0));
},
View gist:9194661
it('can export budget level', inject(function(DownloadGeneratedFile, TestToolbox) {
var token = 123,
downloadUrl = DownloadGeneratedFile.budgetLevel(PROPOSAL_ID, BUDGET_1_ID).url;
scope.start_loader = angular.noop;
$httpBackend.expectGET(downloadUrl).respond({status: 'pending', token: token});
scope.downloadBudgetLevel(BUDGET_1_ID);
TestToolbox.httpBackendFlush($httpBackend);
// TODO: Should add more expectations when the DownloadManager is reworked.
// expect(_downloader.downloaded.url).toEqualData();
// expect(_mixpanel.analytics.track.eventName).toEqualData('Proposal: download budget level');
View gist:8869665
/* Vendor dependencies */
@import 'flatui/config';
@import "flatui/flat-ui";
/* Authored dependencies */
@import 'config'; // overrides flat ui config
@import "mixins";
/* Patterns / components */
@import 'base'; // base styling (elements, no classes/components) -- also overrides flat ui and deprecates erfpFlatUi.less
View init1.js
// <div ng-controller="MyCtrl"></div>
function MyCtrl ($scope) {
// my init code here
}
View directives.js
app.factory('notification', function ($document, $templateCache, $compile) {
return {
show: function (message) {
// Compile template.
var template = $templateCache.get('template/notification.html');
console.log('tpl', $compile(template)); // This breaks
// Append notifications to DOM element.
// $document.find('#notifications').append(el);
View gist:6301571
$rootScope.$on('auction:finished', function (event, auction) {
// If current user won, show win modal.
if (auction.winner.facebookId !== $scope.user.facebookId) {
return;
}
$scope.wonAuction = auction;
// If playing for tokens, update user tokens.
if (auction.bidType !== $scope.AUCTION_TYPE_TOKENS) {
return;
}
View gist:6224591
<!-- wonAuction.bidType = 'token'; -->
<!-- AUCTION_TYPE_CREDITS = 'credit'; -->
<div class="win-popup" ng-show="wonAuction" ng-switch="wonAuction.bidType == AUCTION_TYPE_CREDITS">
<div class="title">
<img src="{% static 'images/tokens-won-title.png' %}" ng-switch-when="false">
<img src="{% static 'images/item-won-title.png' %}" ng-switch-when="true">
</div>
</div>