diff --git a/ionic/components/app/test/weather/flickr.js b/ionic/components/app/test/weather/flickr.js index 6cb32d9964..8ae5dd975d 100644 --- a/ionic/components/app/test/weather/flickr.js +++ b/ionic/components/app/test/weather/flickr.js @@ -25,7 +25,9 @@ export class Flickr { static search(tags, lat, lng) { return new Promise((resolve, reject) => { - Http.get(baseUrl + '?method=flickr.groups.pools.getPhotos&group_id=1463451@N25&safe_search=1&api_key=' + FLICKR_API_KEY + '&format=json&tags=' + tags + '&lat=' + lat + '&lng=' + lng).then((val) => { + Http.get(baseUrl + '?method=flickr.groups.pools.getPhotos&group_id=1463451@N25&safe_search=1&api_key=' + FLICKR_API_KEY + '&jsoncallback=JSON_CALLBACK&format=json&tags=' + tags + '&lat=' + lat + '&lng=' + lng, { + method: 'jsonp' + }).then((val) => { resolve(val); }, (err) => { reject(httpResponse); diff --git a/ionic/components/app/test/weather/index.js b/ionic/components/app/test/weather/index.js index 04abb6ee94..8efcd45f54 100644 --- a/ionic/components/app/test/weather/index.js +++ b/ionic/components/app/test/weather/index.js @@ -17,7 +17,7 @@ console.log('Imported', Geo, Weather, Flickr); }) @View({ templateUrl: 'main.html', - directives: [NgIf, NgFor, Content, Scroll, CurrentWeather, WeatherIcon] + directives: [NgIf, NgFor, Content, Scroll, CurrentWeather, WeatherIcon, BackgroundCycler] }) class WeatherApp { constructor(Modal: Modal) { @@ -65,13 +65,15 @@ class WeatherApp { this.current = resp; // TODO: This should be in a custom pipe - let c, d; + let c, d, h; for(let i = 0; i < this.current.hourly.data.length; i++) { c = this.current.hourly.data[i]; let t = c.temperature; d = new Date(c.time * 1000); c.temperature = Math.floor(t); - c.time_date = d.getHours() % 12 + ' ' + (d.getHours() < 12 ? 'AM' : 'PM'); + h = d.getHours() % 12; + h = (h == 0 ? 12 : h); + c.time_date = h + ' ' + (d.getHours() < 12 ? 'AM' : 'PM'); } for(let i = 0; i < this.current.daily.data.length; i++) { c = this.current.daily.data[i]; @@ -166,9 +168,7 @@ let WEATHER_ICONS = { export class WeatherIcon { constructor() { } - onChange(data) { - console.log('Weather icon onchange', data); - + onAllChangesDone(data) { var icon = this.icon; if(icon in WEATHER_ICONS) { @@ -273,6 +273,33 @@ export class CurrentWeather { } } } + +@Component({ + selector: 'background-cycler', + properties: [ + 'image' + ] +}) +@View({ + template: '
' +}) +export class BackgroundCycler { + constructor(elementRef: ElementRef) { + this.elementRef = elementRef; + this.el = elementRef.nativeElement; + } + onInit() { + this.imageEl = this.el.children[0]; + } + onAllChangesDone() { + var item = this.image; + if(item) { + var url = "http://farm"+ item.farm +".static.flickr.com/"+ item.server +"/"+ item.id +"_"+ item.secret + "_z.jpg"; + this.imageEl.style.backgroundImage = 'url(' + url + ')'; + } + } +} + /* .directive('weatherBox', function($timeout) { return { @@ -317,50 +344,5 @@ export class CurrentWeather { } }) -.directive('backgroundCycler', function($compile, $animate) { - var animate = function($scope, $element, newImageUrl) { - var child = $element.children()[0]; - - var scope = $scope.$new(); - scope.url = newImageUrl; - var img = $compile('