Skip to content

Instantly share code, notes, and snippets.

View jhdavids8's full-sized avatar

Jamie Davidson jhdavids8

View GitHub Profile
@jhdavids8
jhdavids8 / load.js
Created December 16, 2014 03:49
Call the pleaseWait library in order to show our loading screen.
var loading_screen = pleaseWait({
logo: "assets/images/pathgather.png",
backgroundColor: '#f46d3b',
loadingHtml: "<div class='sk-spinner sk-spinner-wave'><div class='sk-rect1'></div><div class='sk-rect2'></div><div class='sk-rect3'></div><div class='sk-rect4'></div><div class='sk-rect5'></div></div>"
});
@jhdavids8
jhdavids8 / default.css
Created December 15, 2014 23:47
Sample CSS styling for the template underneath a PleaseWait loading screen
body > .inner {
display: none;
}
body.pg-loaded > .inner {
display: block;
}
@jhdavids8
jhdavids8 / index.html
Created December 15, 2014 23:19
A sample way to include and call the PleaseWait library.
<!DOCTYPE html>
<html ng-app="AngularApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link href="assets/css/please-wait.css" rel="stylesheet">
<link href="assets/css/default.css" rel="stylesheet">
</head>
<body ng-controller="MainCtrl">
@jhdavids8
jhdavids8 / gist:6265398
Last active December 21, 2015 06:39
Angular directive to dynamically render a follow or unfollow button, depending on whether we are already following the given user
angular.module("PathgatherApp").directive('pgFollowBtn', ["CurrentFollowedUsers", "$compile", (CurrentFollowedUsers, $compile) ->
restrict: 'A',
scope: {user: '=pgFollowBtn'},
link: (scope, element, attrs) ->
follow_btn = null
unfollow_btn = null
createFollowBtn = () ->
follow_btn = angular.element(
"<a href='javascript:void(0)' ng-disabled='submitting'>" +
"<span>Follow</span></a>"
@jhdavids8
jhdavids8 / gist:6265395
Created August 19, 2013 02:46
Angular service that fetches and stores the users the current, logged-in user is following
angular.module("PathgatherApp").factory 'CurrentFollowedUsers', (["CurrentUser", "$q", (CurrentUser, $q) ->
followed_users = null
followed_users_promise = null
{
getFollowedUsers: () ->
return CurrentUser.getUser().then (current_user) ->
if followed_users?
deferred = $q.defer()
deferred.resolve(followed_users)
return deferred.promise
@jhdavids8
jhdavids8 / gist:6265389
Created August 19, 2013 02:45
Angular service that fetches and stores the current, logged-in user
angular.module("PathgatherApp").factory 'CurrentUser', (["$q", "Restangular", ($q, Rectangular) ->
current_user = null
current_user_promise = Restangular.all("users").customGET("current")
current_user_promise.then (response) ->
current_user = response
{
getUser: () ->
if current_user?
deferred = $q.defer()
@jhdavids8
jhdavids8 / gist:6265365
Last active December 21, 2015 06:38
Methods added to our CurrentFollowedUsers service to follow/unfollow a user
angular.module("PathgatherApp").factory 'CurrentFollowedUsers', (["CurrentUser", "$q", (CurrentUser, $q) ->
followed_users = null
followed_users_promise = null
{
getFollowedUsers: () ->
return CurrentUser.getUser().then (current_user) ->
if followed_users?
deferred = $q.defer()
deferred.resolve(followed_users)
return deferred.promise
@jhdavids8
jhdavids8 / right_click_link_tracking.js
Created April 16, 2012 17:36
A bit of a hack to track right-click/context menu link openings (i.e. right-click and select "Open in New Tab/Window")