Skip to content

Instantly share code, notes, and snippets.

View pjsvis's full-sized avatar

Peter John Smith pjsvis

  • Virtual Information Systems
  • Edinburgh
View GitHub Profile
@pjsvis
pjsvis / app.js
Created May 16, 2012 21:43
Angular Example
// This is a module for cloud persistance in mongolab - https://mongolab.com
angular.module('mongolab', ['ngResource']).
factory('Project', function($resource) {
var Project = $resource('https://api.mongolab.com/api/1/databases' + '/cars/collections/projects/:id', {
apiKey: '4f99a253e4b015f77d298ab8'
}, {
update: {
method: 'PUT'
}
});
angular.module('formComponents', [])
.directive('formInput', function() {
return {
restrict: 'E',
scope: {},
link: function(scope, element, attrs)
{
var type = attrs.type || 'text';
var required = attrs.hasOwnProperty('required') ? "required='required'" : "";
var htmlText = '<div class="control-group">' +
@pjsvis
pjsvis / MongoLab.js
Created September 29, 2012 11:53
Module for Could Persistence in MongoLab
// This is a module for cloud persistance in mongolab - https://mongolab.com
angular.module('mongolab', ['ngResource']).
factory('Project', function($resource) {
var Project = $resource('https://api.mongolab.com/api/1/databases' +
'/angularjs/collections/projects/:id',
{ apiKey: '4f847ad3e4b08a2eed5f3b54' }, {
update: { method: 'PUT' }
}
);
@pjsvis
pjsvis / Project.js
Created September 29, 2012 11:54
Project Module which uses Mongo
angular.module('project', ['mongolab']).
config(function($routeProvider) {
$routeProvider.
when('/', {controller:ListCtrl, templateUrl:'list.html'}).
when('/edit/:projectId', {controller:EditCtrl, templateUrl:'detail.html'}).
when('/new', {controller:CreateCtrl, templateUrl:'detail.html'}).
otherwise({redirectTo:'/'});
});
// AngularJS Directive for jQuery Sparklines
// Dependencies: jquery and http://omnipotent.net/jquery.sparkline/
angular.module('sparkline',[])
angular.module('sparkline')
.directive('jqSparkline', [function () {
'use strict';
return {
restrict: 'E,A',
require: 'ngModel',
@pjsvis
pjsvis / gist:5642393
Last active December 17, 2015 16:59
Module definition for flot
// AngularJS directives for jquery.flot
// Dependencies jQuery and flot (http://www.flotcharts.org)
// jquery.flot.plugins: jquery.flot.pie.js, jquery.flot.stack.js, jquery.flot.time.js
angular.module('flot', []);
@pjsvis
pjsvis / gist:5642407
Last active December 17, 2015 16:59
jquery.flot.pie directive
angular.module('flot')
.directive('flotPie', [function () {
'use strict';
return {
restrict: 'E,A',
require: 'ngModel',
link: function (scope, elem, attrs, ngModel) {
var chart = null,
opts = {
@pjsvis
pjsvis / gist:5642410
Last active December 17, 2015 16:59
jquery.flot.stackedline directive
angular.module('flot')
.directive('flotStackedline', [function () {
'use strict';
return {
restrict: 'EA',
require: 'ngModel',
link: function (scope, elem, attrs, ngModel) {
var chart = null,
opts = {
@pjsvis
pjsvis / gist:5642417
Last active December 17, 2015 16:59
flot.line.js
angular.module('flot')
.directive('flotLine', [function () {
'use strict';
return {
restrict: 'EA',
require: 'ngModel',
link: function (scope, elem, attrs, ngModel) {
var chart = null,
opts = {
@pjsvis
pjsvis / gist:6210002
Last active November 13, 2020 00:56
Angular directive for jQuery sparkline
// Requires jQuery from http://jquery.com/
// and jQuerySparklines from http://omnipotent.net/jquery.sparkline
// AngularJS directives for jquery sparkline
angular.module('sparkline', []);
angular.module('sparkline')
.directive('jqSparkline', [function () {
'use strict';
return {