Skip to content

Instantly share code, notes, and snippets.

View alejandroiglesias's full-sized avatar

Alejandro García Iglesias alejandroiglesias

View GitHub Profile
import Vue from 'vue'
export default class extends Vue {
constructor() {
super({
data() {
return {
scrollY: 0
}
},
@alejandroiglesias
alejandroiglesias / flatten-array.js
Last active September 6, 2016 19:12
Recursively flattens arbitrarily nested arrays.
/**
* 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 December 9, 2015 21:43
Barebones implementation of RRSSB
<!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>
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));
},
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');
/* 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
// <div ng-controller="MyCtrl"></div>
function MyCtrl ($scope) {
// my init code here
}
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);
$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;
}
<!-- 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>