Skip to content

Commit

Permalink
modified: Gemfile
Browse files Browse the repository at this point in the history
modified:   Gemfile.lock
	-- bumped rails dependency version

modified:   app/assets/javascripts/angular/controllers/listen.js
modified:   app/assets/javascripts/app.js
	-- added in $rootScope and moved the debug function onto it (now available to all)

modified:   app/assets/javascripts/application.js
	-- moved angular inititization to end

modified:   app/assets/javascripts/angular/directives/directives.js
	-- properly set up this file to initialise with clobbering other modules and at the right time (we have a baw.directives module now)

new file:   app/assets/javascripts/angular/controllers/projects_manager.js
renamed:    app/assets/templates/project.html -> app/assets/templates/project_details.html
renamed:    app/assets/templates/projects.html -> app/assets/templates/projects_index.html
new file:   app/assets/templates/projects_manager.html
	-- created for crea task

new file:   app/assets/templates/record_information.html
	-- first attempt at a control (widget / directive)
  • Loading branch information
atruskie committed Nov 13, 2012
1 parent 07f214e commit d6fd7b1
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 100 deletions.
26 changes: 3 additions & 23 deletions app/assets/javascripts/angular/controllers/listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,9 @@ function ListenCtrl($scope, $resource, $routeParams) {
return Object.keys($scope.audio_events[0]);
}

$scope.refresh = function($event) {
//$ngModel.$render();
};


$scope.print = function () {
var seen = [];
var badKeys = ["$digest", "$$watchers", "$$childHead", "$$childTail", "$$listeners", "$$nextSibling", "$$prevSibling", "$root", "this", "$parent"];
var str = JSON.stringify($scope,
(function (key, val) {
if (badKeys.indexOf(key) >= 0) {
return "[Can't do that]";
}
if (typeof val == "object") {
if (seen.indexOf(val) >= 0) {
return "";
}
seen.push(val);
}
return val;
}), 4);
return str;
}




$scope.showHide = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";
function ProjectsManagerCtrl($scope, $resource) {
$scope.projectsResource = $resource('/projects', {}, { get: { method:'GET', params:{}, isArray: true }});
$scope.projects = $scope.projectsResource.get();
}

ProjectsCtrl.$inject = ['$scope', '$resource'];
69 changes: 45 additions & 24 deletions app/assets/javascripts/angular/directives/directives.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,48 @@

// HACK: this is a very bad way to do this!
bawApp.directive('nsDsFade', function() {
return function(scope, element, attrs) {
element.css('display', 'none');
scope.$watch(attrs.ngDsFade, function(value) {
if (value) {
element.fadeIn(200);
}
else {
element.fadeOut(100);
}
});
}

});
// .directive('uiToggle', [function() {
// return function(scope, elm, attrs) {
// scope.$watch(attrs.uiToggle, function(newVal, oldVal){
// if (newVal) {
// elm.removeClass('ui-hide').addClass('ui-show');
// } else {
// elm.removeClass('ui-show').addClass('ui-hide');
// }
(function() {
var bads = angular.module('bawApp.directives', []);

bads.directive('addRedBox', function() {
return function(scope, element, attrs){
element.append("<div style='background-color: red; height: 100px; width: 100px'></div>");
}
});

bads.directive('recordInformation', function(){
return {
restrict: 'AE',
/*scope: false,*/
/* priority: ??? */
/* controller: ??? */
/* require: ??? */
/*template: "<div></div>",*/
templateUrl: "/assets/record_information.html"
/*replace: false*/
/*compile: function(tElement, tAttrs, transclude) {
},*/
/*link: function(scope, iElement, iAttrs, controller) {
} */

}
});

})();

//bawApp.directive('nsDsFade', function() {
// return function(scope, element, attrs) {
// element.css('display', 'none');
// scope.$watch(attrs.ngDsFade, function(value) {
// if (value) {
// element.fadeIn(200);
// }
// else {
// element.fadeOut(100);
// }
// });
// }
//}]);
//
//});
//

89 changes: 59 additions & 30 deletions app/assets/javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,62 @@

/* App Module */

var bawApp = angular.module('baw', ['ngResource', 'ui.directives', 'ui.filters'], function($routeProvider, $locationProvider ) {

// routes
$routeProvider.
when('/home', {templateUrl: '/assets/home.html', controller: HomeCtrl}).

when('/projects', {templateUrl: '/assets/projects.html', controller: ProjectCtrl}).
when('/projects/:projectId', {templateUrl: '/assets/project.html', controller: ProjectsCtrl}).

when('/sites', {templateUrl: '/assets/sites.html', controller: SitesCtrl }).
when('/sites/:siteId', {templateUrl: '/assets/site.html', controller: SiteCtrl }).

when('/photos', {templateUrl: '/assets/photos.html', controller: PhotosCtrl }).
when('/photos/:photoId', {templateUrl: '/assets/photo.html', controller: PhotoCtrl }).

when('/recordings', {templateUrl: '/assets/recordings.html', controller: RecordingsCtrl }).
when('/recordings/:recordingId', {templateUrl: '/assets/recording.html', controller: RecordingCtrl }).

when('/listen', {templateUrl: '/assets/listen.html', controller: ListenCtrl}).
when('/listen/:recordingId', {templateUrl: '/assets/listen.html', controller: ListenCtrl}).

//when('/phones/:phoneId', {templateUrl: 'partials/phone-detail.html', controller: PhoneDetailCtrl}).
otherwise({redirectTo: '/home'});

// location config
$locationProvider.html5Mode(true);



});
var bawApp = angular.module('baw',
[
'ngResource',
'ui.directives', /* angular-ui project */
'ui.filters', /* angular-ui project */
'bawApp.directives' /* our directives.js */
],
function ($routeProvider, $locationProvider) {

// routes
$routeProvider.
when('/home', {templateUrl: '/assets/home.html', controller: HomeCtrl}).

when('/projects', {templateUrl: '/assets/projects_index.html', controller: ProjectCtrl}).
when('/projects/manage', {templateUrl: '/assets/projects_manage.html', controller: ProjectsManagerCtrl}).
when('/projects/:projectId', {templateUrl: '/assets/project_details.html', controller: ProjectsCtrl}).

when('/sites', {templateUrl: '/assets/sites.html', controller: SitesCtrl }).
when('/sites/:siteId', {templateUrl: '/assets/site.html', controller: SiteCtrl }).

when('/photos', {templateUrl: '/assets/photos.html', controller: PhotosCtrl }).
when('/photos/:photoId', {templateUrl: '/assets/photo.html', controller: PhotoCtrl }).

when('/recordings', {templateUrl: '/assets/recordings.html', controller: RecordingsCtrl }).
when('/recordings/:recordingId', {templateUrl: '/assets/recording.html', controller: RecordingCtrl }).

when('/listen', {templateUrl: '/assets/listen.html', controller: ListenCtrl}).
when('/listen/:recordingId', {templateUrl: '/assets/listen.html', controller: ListenCtrl}).

//when('/phones/:phoneId', {templateUrl: 'partials/phone-detail.html', controller: PhoneDetailCtrl}).
otherwise({redirectTo: '/home'});

// location config
$locationProvider.html5Mode(true);


})
.run(function ($rootScope) {
$rootScope.print = function () {
var seen = [];
var badKeys = ["$digest", "$$watchers", "$$childHead", "$$childTail", "$$listeners", "$$nextSibling", "$$prevSibling", "$root", "this", "$parent"];
var str = JSON.stringify($rootScope,
(function (key, val) {
if (badKeys.indexOf(key) >= 0) {
return "[Can't do that]";
}
if (typeof val == "object") {
if (seen.indexOf(val) >= 0) {
return "";
}
seen.push(val);
}
return val;
}), 4);
return str;
};
$rootScope.showOrHideDebugInfo = false;
})
;
3 changes: 1 addition & 2 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
//= require angular-resource.js
//= require angular-ui.js
//= require angular-ui-ieshiv.js
//= require app
//= require_tree .

//= require app

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="content" data-ng-controller="ProjectCtrl">
<div id="content" data-ng-controller="ProjectCtrl" xmlns:baw="">
<h2>Project</h2>

<p>The details for a project.</p>
Expand All @@ -9,12 +9,19 @@ <h2>Project</h2>
<h3><a ng-href="{{project.urn}}">{{project.name}}</a></h3>
<p ng-bind="project.description" ></p>
<pre>{{project.notes}}</pre>
<small>{{updated_at}}</small>
<small>{{project.updated_at}}</small>
<record-information></record-information>
<!--<baw:record-information></baw:record-information>-->

<!--<div baw:record-information ></div>-->
<div record-information ></div>
<ul>
<li data-ng-repeat="site in project.sites">
{{site.id}}
{{site.latitude}}
{{site.longitude}}
</li>
</ul>

<pre ui-toggle="showOrHideDebugInfo" class="ui-hide" ng-bind="print()"></pre>
</div>
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<div id="content" data-ng-controller="ProjectsCtrl">
<h1>Project List</h1>

<p>These are the available projects.</p>

<a href="/">Home</a>

<ul id="project-list">
<li data-ng-repeat="project in projects">
<div>
<h3><a data-ng-href="/projects/{{project.id}}" title="urn: {{project.urn}}">{{project.name}}</a></h3>
<p data-ng-bind="project.description" ></p>
<small>{{project.updated_at}}</small>
<p ng-bind="project.sites.length" ></p>
</div>
<img class="thumb-image" ng-src="{{project.photos[0].uri}}" >
</li>

</ul>
<div id="content" data-ng-controller="ProjectsCtrl">
<h1>Project List</h1>

<p>These are the available projects.</p>

<a href="/projects/manage">Manage projects</a>

<ul id="project-list">
<li data-ng-repeat="project in projects">
<div>
<h3><a data-ng-href="/projects/{{project.id}}" title="urn: {{project.urn}}">{{project.name}}</a></h3>
<p data-ng-bind="project.description" ></p>
<small>{{project.updated_at}}</small>
<p ng-bind="project.sites.length" ></p>
<p add-red-box style=""></p>
</div>
<img class="thumb-image" ng-src="{{project.photos[0].uri}}" >
</li>

</ul>
</div>
22 changes: 22 additions & 0 deletions app/assets/templates/projects_manager.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div id="content" data-ng-controller="ProjectsManagerCtrl">
<h1>Project List</h1>

<p>These are the available projects.</p>

<a href="/">Home</a>

<ul id="project-list">
<li data-ng-repeat="project in projects">
<div>
<h3><a data-ng-href="/projects/{{project.id}}" title="urn: {{project.urn}}">{{project.name}}</a></h3>
<p data-ng-bind="project.description" ></p>
<small>{{project.updated_at}}</small>
<a href="">details</a>&nbsp
<a href="">edit</a>&nbsp
<a href="">delete</a>&nbsp
</div>
<img class="thumb-image" ng-src="{{project.photos[0].uri}}" >
</li>

</ul>
</div>
3 changes: 3 additions & 0 deletions app/assets/templates/record_information.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
modified<span>{{{project.updated_at}}</span>&nbsp;created<span></span>&nbsp;archived<span></span>
</div>

0 comments on commit d6fd7b1

Please sign in to comment.