diff --git a/dev/css/main.css b/dev/css/main.css index 7818da8..b98a990 100644 --- a/dev/css/main.css +++ b/dev/css/main.css @@ -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; -} \ No newline at end of file +} + +/* This is used to align the add button with the other buttons on the recipe page. */ +.padding8 { + padding: 8px; +} diff --git a/dev/index.html b/dev/index.html index 353af77..e6fd227 100644 --- a/dev/index.html +++ b/dev/index.html @@ -27,8 +27,10 @@ - + + + @@ -37,6 +39,9 @@ + + + @@ -47,8 +52,6 @@ - -
diff --git a/dev/js/hasfocus.js b/dev/js/hasfocus.js new file mode 100644 index 0000000..d9b26ce --- /dev/null +++ b/dev/js/hasfocus.js @@ -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);"); + } + }); + }; +} diff --git a/dev/js/home.js b/dev/js/home.js new file mode 100644 index 0000000..b384cca --- /dev/null +++ b/dev/js/home.js @@ -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); diff --git a/dev/js/lists/all.js b/dev/js/lists/all.js index 0b2d209..240d1f9 100644 --- a/dev/js/lists/all.js +++ b/dev/js/lists/all.js @@ -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 + '/'); }); @@ -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 + '/'); }); }; @@ -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']; diff --git a/dev/js/lists/view.js b/dev/js/lists/view.js index 9567662..5768fb1 100644 --- a/dev/js/lists/view.js +++ b/dev/js/lists/view.js @@ -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; diff --git a/dev/js/modal.js b/dev/js/modal.js new file mode 100644 index 0000000..9db661a --- /dev/null +++ b/dev/js/modal.js @@ -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) { + + } + + }; +} diff --git a/dev/js/recipes/all.js b/dev/js/recipes/all.js index fbeb737..da6a719 100644 --- a/dev/js/recipes/all.js +++ b/dev/js/recipes/all.js @@ -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 + '/'); }); @@ -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 + '/'); }); @@ -49,5 +49,7 @@ function RecipesAllCtrl($scope, $location, Recipes) { Recipes.getall(function (recipes) { $scope.recipes = recipes; }); + + $scope.data = {}; } RecipesAllCtrl.$inject = ['$scope', '$location', 'Recipes']; diff --git a/dev/js/recipes/view.js b/dev/js/recipes/view.js index 4c09195..3136de2 100644 --- a/dev/js/recipes/view.js +++ b/dev/js/recipes/view.js @@ -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() { @@ -170,9 +175,15 @@ 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; @@ -180,5 +191,14 @@ function RecipesViewCtrl($scope, $routeParams, $timeout, "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']; diff --git a/dev/js/routing.js b/dev/js/routing.js index f3a9c97..5ebe525 100644 --- a/dev/js/routing.js +++ b/dev/js/routing.js @@ -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/'}); +} diff --git a/dev/lists/all.html b/dev/lists/all.html index 8575236..3d2d94f 100644 --- a/dev/lists/all.html +++ b/dev/lists/all.html @@ -52,91 +52,60 @@

Lists

- +
+
+
+ + + + Required + +
+
+
+
-
- - + +
diff --git a/dev/modal.html b/dev/modal.html new file mode 100644 index 0000000..0d336a0 --- /dev/null +++ b/dev/modal.html @@ -0,0 +1,24 @@ + diff --git a/dev/recipes/all.html b/dev/recipes/all.html index 1312807..063a9ad 100644 --- a/dev/recipes/all.html +++ b/dev/recipes/all.html @@ -52,96 +52,65 @@

Recipes

- +
+
+
+ + + + Required + +
+
+
+
-