Permalink
Browse files

Merge branch 'IgorMinar-0_9-fixes'

* IgorMinar-0_9-fixes:
  make resources more slide friendly
  fix my:cycle not to run on every eval
  Rakefile fix to get rake db:migrate RAILS_ENV=test going
  • Loading branch information...
2 parents 45576b6 + 420da6f commit 471753afba33d50d11902071cfd5834c607e6a18 Daniel Nelson committed Nov 16, 2011
Showing with 27 additions and 25 deletions.
  1. +2 −0 Rakefile
  2. +11 −7 app/assets/javascripts/services.js
  3. +13 −17 app/assets/javascripts/widgets.js
  4. +1 −1 app/assets/templates/photos.html
View
@@ -2,6 +2,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+require 'rake/dsl_definition'
+
require File.expand_path('../config/application', __FILE__)
AngularDemo::Application.load_tasks
@@ -1,20 +1,24 @@
/* http://docs.angularjs.org/#!angular.service */
angular.service('Photographers', function($resource) {
- return $resource('photographers/:photographer_id', {}, { 'index': { method: 'GET', isArray: true }});
+ return $resource('photographers/:photographer_id', {},
+ { 'index': { method: 'GET', isArray: true }});
});
angular.service('Galleries', function($resource) {
- return $resource('photographers/:photographer_id/galleries/:gallery_id', {}, { 'index': { method: 'GET', isArray: true }});
+ return $resource('photographers/:photographer_id/galleries/:gallery_id', {},
+ { 'index': { method: 'GET', isArray: true }});
});
angular.service('Photos', function($resource) {
- return $resource('photographers/:photographer_id/galleries/:gallery_id/photos', {}, { 'index': { method: 'GET', isArray: true }});
+ return $resource('photographers/:photographer_id/galleries/:gallery_id/photos', {},
+ { 'index': { method: 'GET', isArray: true }});
});
angular.service('SelectedPhotos', function($resource) {
- return $resource('selected_photos/:selected_photo_id', {}, { 'create': { method: 'POST' },
- 'index': { method: 'GET', isArray: true },
- 'update': { method: 'PUT' },
- 'destroy': { method: 'DELETE' }});
+ return $resource('selected_photos/:selected_photo_id', {},
+ { 'create': { method: 'POST' },
+ 'index': { method: 'GET', isArray: true },
+ 'update': { method: 'PUT' },
+ 'destroy': { method: 'DELETE' }});
});
@@ -2,24 +2,20 @@
angular.directive("my:cycle", function(expr,el){
return function(container){
- var lastChildID = container.children().last().attr('id');
+ var scope = this;
+ var $defer = scope.$service("$defer");
- var doIt = function() {
- var lastID = container.children().last().attr('id');
- if (lastID != lastChildID) {
- lastChildID = lastID;
- $(container).cycle({ fx: 'fade',
- speed: 500,
- timeout: 3000,
- pause: 1,
- next: '#next',
- prev: '#prev'});
- }
- }
+ scope.$watch(expr, function(value) {
+ if (value < 1) return;
- var defer = this.$service("$defer");
- this.$onEval( function() {
- defer(doIt);
- });
+ $defer(function() {
+ $(container).cycle({ fx: 'fade',
+ speed: 500,
+ timeout: 3000,
+ pause: 1,
+ next: '#next',
+ prev: '#prev'});
+ });
+ });
}
});
@@ -3,7 +3,7 @@
<div id="outer_picture_frame">
<div id="picture_frame">
<div id="prev">&lsaquo;</div>
- <div id="photos" my:cycle>
+ <div id="photos" my:cycle="photos.length">
<div class="photo" id="photo_{{photo.id}}" ng:click="selectPhoto(photo)" ng:repeat="photo in photos">
<img ng:src="{{photo.image_large_url}}" alt="{{photo.title}}" />
<span class="title">{{photo.title}}</span>

0 comments on commit 471753a

Please sign in to comment.