Skip to content

Commit

Permalink
Merge branch 'release/v0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
icub3d committed Feb 16, 2013
2 parents 8ee4b56 + b021989 commit 1d3bd45
Show file tree
Hide file tree
Showing 15 changed files with 357 additions and 299 deletions.
9 changes: 7 additions & 2 deletions dev/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ and buttons and the list items. */
}

/* The drag icon is slightly off, so we move it up a bit. */
.drag-icon {
.drag-icon, .remove-icon {
margin-top: -5px;
}
}

/* This is used to align the add button with the other buttons on the recipe page. */
.padding8 {
padding: 8px;
}
9 changes: 6 additions & 3 deletions dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-responsive.min.css"
rel="stylesheet">

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/js/bootstrap.min.js"></script>

<!-- APP JS -->
<script src="/js/rest/alerts.js"></script>
Expand All @@ -37,6 +39,9 @@
<script src="/js/rest/user.js"></script>
<script src="/js/rest/rest.js"></script>
<script src="/js/routing.js"></script>
<script src="/js/hasfocus.js"></script>
<script src="/js/modal.js"></script>
<script src="/js/home.js"></script>
<script src="/js/alerts.js"></script>
<script src="/js/user.js"></script>
<script src="/js/lists/all.js"></script>
Expand All @@ -47,8 +52,6 @@
<script src="/js/touch-punch.min.js"></script>
<!-- APP JS -->

<script async src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
<script async src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
Expand Down
29 changes: 29 additions & 0 deletions dev/js/hasfocus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2013 Joshua Marsh. All rights reserved. Use of this
source code is governed by a BSD-style license that can be found in
the LICENSE file.
*/

// This is used to auto-focus the items then they are switched
// from a span to a text box.
function HasFocus() {
return function(scope, element, attrs) {
scope.$watch(attrs.ngHasfocus, function (nVal, oVal) {
if (nVal) {
$(element[0]).show();
$(element[0]).focus();
$(element[0]).select();
}
});

element.bind('blur', function() {
scope.$apply("edit(-1);");
});

element.bind('keydown', function (e) {
if (e.which == 13) {
scope.$apply("edit(-1);");
}
});
};
}
11 changes: 11 additions & 0 deletions dev/js/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Copyright 2013 Joshua Marsh. All rights reserved. Use of this
source code is governed by a BSD-style license that can be found in
the LICENSE file.
*/

var home = angular.module('home', ['rest']);

home.config(['$routeProvider', Router]);
home.directive('ngHasfocus', HasFocus);
home.directive('modal', Modal);
20 changes: 11 additions & 9 deletions dev/js/lists/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ function ListsAllCtrl($scope, $location, Lists) {
// setcopy handles clicking the copy button. It prepares the key
// to be copied and the new name.
$scope.setcopy = function(key, name) {
$scope.copyKey = key;
$scope.copyName = "Copy of " + name;
$scope.data.key = key;
$scope.data.name = "Copy of " + name;
};

// copy actually makes the copy of the list and redirects to the
// new list.
$scope.copy = function() {
Lists.get($scope.copyKey, function(l) {
l.Name = $scope.copyName;
Lists.get($scope.data.key, function(l) {
l.Name = $scope.data.name;
Lists.create(l, function(nl) {
$location.path('/lists/view/' + nl.Key + '/');
});
Expand All @@ -27,20 +27,20 @@ function ListsAllCtrl($scope, $location, Lists) {
// del prepare the delete values that might be used if the user
// verifies they want to delete an item.
$scope.del = function(index, key) {
$scope.delIndex = index;
$scope.delKey = key;
$scope.data.index = index;
$scope.data.key = key;
};

// sure performs the actual delete.
$scope.sure = function() {
Lists.del($scope.delKey, function() {
$scope.lists.splice($scope.delIndex, 1);
Lists.del($scope.data.key, function() {
$scope.lists.splice($scope.data.index, 1);
});
};

// save creates the new list and redirects to that list.
$scope.save = function() {
Lists.create({"Name": $scope.name}, function (l) {
Lists.create({"Name": $scope.data.name}, function (l) {
$location.path('/lists/view/' + l.Key + '/');
});
};
Expand All @@ -50,5 +50,7 @@ function ListsAllCtrl($scope, $location, Lists) {
$scope.lists = lists;
});

// This is where we'll get our form information from the modals.
$scope.data = {};
}
ListsAllCtrl.$inject = ['$scope', '$location', 'Lists'];
3 changes: 0 additions & 3 deletions dev/js/lists/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ function ListsViewCtrl($scope, $routeParams, $timeout, Lists) {
});
});

// Start out with cursor in the add text box.
$('#newitem').focus();

// We start out not editing any list.
$scope.editing = -1;

Expand Down
31 changes: 31 additions & 0 deletions dev/js/modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2013 Joshua Marsh. All rights reserved. Use of this
source code is governed by a BSD-style license that can be found in
the LICENSE file.
*/

// This is used to auto-focus the items then they are switched
// from a span to a text box.
function Modal() {
return {
restrict: 'A',
transclude: true,
scope: {
id: '@modalId',
title: '@modalTitle',
message: '@modalMessage',
data: "=modalData",
form: "=modalForm",
okbtncls: '@modalOkButtonClass',
okbtntxt: '@modalOkButtonText',
okbtnico: '@modalOkButtonIcon',
onok: '&modalOnOk'

},
templateUrl: 'modal.html',
link: function (scope, element, attrs) {

}

};
}
20 changes: 11 additions & 9 deletions dev/js/recipes/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ function RecipesAllCtrl($scope, $location, Recipes) {
// setcopy handles clicking the copy button. It prepares the key to be
// copied and the new name.
$scope.setcopy = function(key, name) {
$scope.copyKey = key;
$scope.copyName = "Copy of " + name;
$scope.data.key = key;
$scope.data.name = "Copy of " + name;
};

// copy actually makes the copy of the recipe.
$scope.copy = function() {
Recipes.get($scope.copyKey, function(l) {
l.Name = $scope.copyName;
Recipes.get($scope.data.key, function(l) {
l.Name = $scope.data.name;
Recipes.create(l, function(nl) {
$location.path('/recipes/view/' + nl.Key + '/');
});
Expand All @@ -26,20 +26,20 @@ function RecipesAllCtrl($scope, $location, Recipes) {
// del prepare the delete values that might be used if
// the user verifies they want to delete a recipe.
$scope.del = function(index, key) {
$scope.delIndex = index;
$scope.delKey = key;
$scope.data.index = index;
$scope.data.key = key;
};

// sure performs the actual delete.
$scope.sure = function() {
Recipes.del($scope.delKey, function() {
$scope.recipes.splice($scope.delIndex, 1);
Recipes.del($scope.data.key, function() {
$scope.recipes.splice($scope.data.index, 1);
});
};

// save creates the new recipe and redirects you to that recipe.
$scope.save = function() {
Recipes.create({"Name": $scope.name, "URL": $scope.URL},
Recipes.create({"Name": $scope.data.name, "URL": $scope.data.URL},
function (l) {
$location.path('/recipes/view/' + l.Key + '/');
});
Expand All @@ -49,5 +49,7 @@ function RecipesAllCtrl($scope, $location, Recipes) {
Recipes.getall(function (recipes) {
$scope.recipes = recipes;
});

$scope.data = {};
}
RecipesAllCtrl.$inject = ['$scope', '$location', 'Recipes'];
28 changes: 24 additions & 4 deletions dev/js/recipes/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,32 @@ function RecipesViewCtrl($scope, $routeParams, $timeout,
// modal.
$scope.getlists = function() {
Lists.getall(function (lists) {
$scope.lists = lists;
$scope.data.lists = lists;
});
};

// copy makes a copy of each of the ingredients and push it onto
// the list. It then save the list.
$scope.copy = function() {
$scope.copyList.Items = new Array();
$scope.data.list.Items = new Array();
$scope.Ingredients.forEach(function(e, i, a) {
$scope.copyList.Items.push({
$scope.data.list.Items.push({
Name: e.value,
Completed: false,
Delete: false
});
});

Lists.save($scope.copyList, function(data) {
Lists.save($scope.data.list, function(data) {
$location.path('/lists/view/' + data.Key + '/');
});
};

// del removes the given item from the list.
$scope.del = function(type, index) {
$scope[type].splice(index, 1);
$scope.dirty = true;
};

// Save saves changes to the recipe back to the datastore.
$scope.save = function() {
Expand Down Expand Up @@ -170,15 +175,30 @@ function RecipesViewCtrl($scope, $routeParams, $timeout,
});
});


$scope.togglecleanup = function() {
$scope.cleanup = !$scope.cleanup;
};

// We start out not editing any recipe.
$scope.editingtype = "";
$scope.editing = -1;
$scope.cleanup = false;

// The recipe should start clean.
$scope.dirty = false;
$scope.toadd = {
"Ingredients": "",
"Directions": ""
};

// Add shit+enter to save for the direction box.
$('#newdirection').on('keyup', function (event) {
if (event.which == 13 && event.shiftKey) {
$scope.$apply($scope.add('Directions'));
}
});

$scope.data = {};
}
RecipesViewCtrl.$inject = ['$scope', '$routeParams', '$timeout', '$location', 'Recipes', 'Lists'];
69 changes: 20 additions & 49 deletions dev/js/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,23 @@
*/

// This is the routing mechanism.
angular.module('home', ['rest'])
.config(['$routeProvider',
function ($routeProvider) {
$routeProvider
.when('/lists/', {
controller:ListsAllCtrl,
templateUrl: 'lists/all.html'
})
.when('/lists/view/:id', {
controller:ListsViewCtrl,
templateUrl: 'lists/view.html'
})
.when('/recipes/', {
controller:RecipesAllCtrl,
templateUrl: 'recipes/all.html'
})
.when('/recipes/view/:id', {
controller:RecipesViewCtrl,
templateUrl: 'recipes/view.html'
})
.otherwise({redirectTo: '/lists/'});
}

])
// This is used to auto-focus the items then they are switched
// from a span to a text box.
.directive('ngHasfocus',
function() {
return function(scope, element, attrs) {
scope.$watch(attrs.ngHasfocus, function (nVal, oVal) {
if (nVal) {
$(element[0]).show();
$(element[0]).focus();
$(element[0]).select();
}
});

element.bind('blur', function() {
scope.$apply("edit(-1);");
});

element.bind('keydown', function (e) {
if (e.which == 13) {
scope.$apply("edit(-1);");
}
});
};
});

function Router($routeProvider) {
$routeProvider
.when('/lists/', {
controller:ListsAllCtrl,
templateUrl: 'lists/all.html'
})
.when('/lists/view/:id', {
controller:ListsViewCtrl,
templateUrl: 'lists/view.html'
})
.when('/recipes/', {
controller:RecipesAllCtrl,
templateUrl: 'recipes/all.html'
})
.when('/recipes/view/:id', {
controller:RecipesViewCtrl,
templateUrl: 'recipes/view.html'
})
.otherwise({redirectTo: '/lists/'});
}
Loading

0 comments on commit 1d3bd45

Please sign in to comment.