mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
clean up js files
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import {Component} from 'angular2/angular2';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
|
||||
import {IonicView} from 'ionic/ionic';
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import {NgFor, Injector, DomRenderer, ElementRef} from 'angular2/angular2';
|
||||
import {Ancestor} from 'angular2/src/core/annotations_impl/visibility';
|
||||
import {Component, Directive} from 'angular2/angular2';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
import {NgFor, Injector, DomRenderer, ElementRef, Ancestor} from 'angular2/angular2';
|
||||
import {Component, Directive, View} from 'angular2/angular2';
|
||||
import {FormBuilder, Validators, formDirectives, Control, ControlGroup} from 'angular2/forms';
|
||||
|
||||
import {Segment, SegmentButton, List, Item, ActionMenu, Modal, ModalRef,
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import {Http} from 'ionic/net/http';
|
||||
|
||||
let FLICKR_API_KEY = '504fd7414f6275eb5b657ddbfba80a2c';
|
||||
|
||||
let baseUrl = 'https://api.flickr.com/services/rest/';
|
||||
|
||||
export class Flickr {
|
||||
constructor() {
|
||||
|
||||
/*
|
||||
var flickrSearch = $resource(baseUrl, {
|
||||
method: 'flickr.groups.pools.getPhotos',
|
||||
group_id: '1463451@N25',
|
||||
safe_search: 1,
|
||||
jsoncallback: 'JSON_CALLBACK',
|
||||
api_key: FLICKR_API_KEY,
|
||||
format: 'json'
|
||||
}, {
|
||||
get: {
|
||||
method: 'JSONP'
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
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 + '&jsoncallback=JSON_CALLBACK&format=json&tags=' + tags + '&lat=' + lat + '&lng=' + lng, {
|
||||
method: 'jsonp'
|
||||
}).then((val) => {
|
||||
resolve(val);
|
||||
}, (err) => {
|
||||
reject(httpResponse);
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
export class Geo {
|
||||
static reverseGeocode(lat, lng) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
let geocoder = new google.maps.Geocoder();
|
||||
|
||||
geocoder.geocode({
|
||||
'latLng': new google.maps.LatLng(lat, lng)
|
||||
}, (results, status) => {
|
||||
|
||||
if (status == google.maps.GeocoderStatus.OK) {
|
||||
|
||||
console.log('Reverse', results);
|
||||
|
||||
if(results.length > 1) {
|
||||
var r = results[1];
|
||||
var a, types;
|
||||
var parts = [];
|
||||
var foundLocality = false;
|
||||
var foundState = false;
|
||||
|
||||
for(var i = 0; i < r.address_components.length; i++) {
|
||||
a = r.address_components[i];
|
||||
types = a.types;
|
||||
for(var j = 0; j < types.length; j++) {
|
||||
if(!foundLocality && types[j] == 'locality') {
|
||||
foundLocality = true;
|
||||
parts.push(a.long_name);
|
||||
} else if(!foundState && types[j] == 'administrative_area_level_1') {
|
||||
foundState = true;
|
||||
parts.push(a.short_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Reverse', parts);
|
||||
resolve(parts.join(', '));
|
||||
}
|
||||
} else {
|
||||
console.log('reverse fail', results, status);
|
||||
reject(results);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static getLocation() {
|
||||
return new Promise((resolve, reject) => {
|
||||
navigator.geolocation.getCurrentPosition((position) => {
|
||||
resolve(position);
|
||||
}, (error) => {
|
||||
reject(error);
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,376 +0,0 @@
|
||||
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
import {NgIf, NgFor, CSSClass, ElementRef} from 'angular2/angular2';
|
||||
import {FormBuilder, Control, ControlGroup, Validators, formDirectives} from 'angular2/forms';
|
||||
|
||||
import {IonicView, Animation, Content, Scroll, Modal, NavController, NavParams, IonicComponent} from 'ionic/ionic';
|
||||
|
||||
import {Geo} from './geo';
|
||||
import {Weather} from './weather';
|
||||
import {Flickr} from './flickr';
|
||||
|
||||
@Component({
|
||||
selector: 'ion-app',
|
||||
appInjector: [Modal]
|
||||
})
|
||||
@View({
|
||||
templateUrl: 'main.html',
|
||||
directives: [NgIf, NgFor, Content, Scroll, CurrentWeather, WeatherIcon, BackgroundCycler]
|
||||
})
|
||||
class WeatherApp {
|
||||
constructor(Modal: Modal) {
|
||||
this.Modal = Modal;
|
||||
|
||||
this.currentLocationString = 'Madison, WI';
|
||||
|
||||
this.activeBgImageIndex = 0;
|
||||
|
||||
/*
|
||||
$ionicPlatform.ready(function() {
|
||||
// Hide the status bar
|
||||
if(window.StatusBar) {
|
||||
StatusBar.hide();
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
onInit() {
|
||||
this.refreshData();
|
||||
}
|
||||
|
||||
showSettings() {
|
||||
this.Modal.open(SettingsModal).then((settingsModal) => {
|
||||
this.settingsModal = settingsModal;
|
||||
});
|
||||
}
|
||||
|
||||
getBackgroundImage(lat, lng, locString) {
|
||||
Flickr.search(locString, lat, lng).then((resp) => {
|
||||
let photos = resp.photos;
|
||||
if(photos.photo.length) {
|
||||
this.bgImages = photos.photo;
|
||||
this.cycleBgImages();
|
||||
}
|
||||
}, (error) => {
|
||||
console.error('Unable to get Flickr images', error);
|
||||
});
|
||||
}
|
||||
|
||||
getCurrent(lat, lng, locString) {
|
||||
Weather.getAtLocation(lat, lng).then((resp) => {
|
||||
this.current = resp;
|
||||
|
||||
// TODO: This should be in a custom pipe
|
||||
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);
|
||||
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];
|
||||
let max = c.temperatureMax;
|
||||
let min = c.temperatureMin;
|
||||
c.temperatureMax = Math.floor(max);
|
||||
c.temperatureMin = Math.floor(min);
|
||||
c.time_date = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][new Date(c.time*1000).getDay()];
|
||||
}
|
||||
console.log('GOT CURRENT', this.current);
|
||||
}, (error) => {
|
||||
alert('Unable to get current conditions');
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
cycleBgImages() {
|
||||
setTimeout(() => {
|
||||
if(this.bgImages) {
|
||||
this.activeBgImage = this.bgImages[this.activeBgImageIndex++ % this.bgImages.length];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
refreshData() {
|
||||
Geo.getLocation().then((position) => {
|
||||
let lat = position.coords.latitude;
|
||||
let lng = position.coords.longitude;
|
||||
|
||||
Geo.reverseGeocode(lat, lng).then((locString) => {
|
||||
this.currentLocationString = locString;
|
||||
this.getBackgroundImage(lat, lng, locString);
|
||||
});
|
||||
|
||||
this.getCurrent(lat, lng);
|
||||
}, (error) => {
|
||||
alert('Unable to get current location: ' + error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
.controller('SettingsCtrl', function($scope, Settings) {
|
||||
$scope.settings = Settings.getSettings();
|
||||
|
||||
// Watch deeply for settings changes, and save them
|
||||
// if necessary
|
||||
$scope.$watch('settings', function(v) {
|
||||
Settings.save();
|
||||
}, true);
|
||||
|
||||
$scope.closeSettings = function() {
|
||||
$scope.modal.hide();
|
||||
};
|
||||
|
||||
});
|
||||
*/
|
||||
|
||||
@IonicComponent(Modal)
|
||||
@IonicView({
|
||||
template: `<ion-view id="settings-modal">
|
||||
<ion-toolbar>
|
||||
<ion-title>Settings</ion-title>
|
||||
</ion-toolbar>
|
||||
<ion-content padding>
|
||||
<form (^submit)="doSubmit($event)" [ng-form-model]="settingsForm">
|
||||
<ion-list>
|
||||
<ion-input ion-item>
|
||||
<ion-label>Units</ion-label>
|
||||
<!--
|
||||
<ion-segment ng-control="units">
|
||||
<ion-segment-button value="standard" button>
|
||||
°F
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="standard" button>
|
||||
°C
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
-->
|
||||
</ion-input>
|
||||
</ion-list>
|
||||
</form>
|
||||
</ion-content>
|
||||
</ion-view>`,
|
||||
directives: [formDirectives]
|
||||
})
|
||||
export class SettingsModal extends Modal {
|
||||
constructor(fb: FormBuilder) {
|
||||
this.settingsForm = fb.group({
|
||||
mapStyle: ['hybrid', Validators.required]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function main(ionicBootstrap) {
|
||||
ionicBootstrap(WeatherApp);
|
||||
}
|
||||
|
||||
|
||||
let WEATHER_ICONS = {
|
||||
'partlycloudy': 'ion-ios-partlysunny-outline',
|
||||
'mostlycloudy': 'ion-ios-partlysunny-outline',
|
||||
'cloudy': 'ion-ios-cloudy-outline',
|
||||
'rain': 'ion-ios-rainy-outline',
|
||||
'tstorms': 'ion-ios-thunderstorm-outline',
|
||||
'sunny': 'ion-ios-sunny-outline',
|
||||
'clear-day': 'ion-ios-sunny-outline',
|
||||
'nt_clear': 'ion-ios-moon-outline',
|
||||
'clear-night': 'ion-ios-moon-outline'
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'weather-icon',
|
||||
properties: [
|
||||
'icon'
|
||||
]
|
||||
})
|
||||
@View({
|
||||
template: '<i class="icon" [class]="weatherIcon"></i>',
|
||||
directives: [CSSClass]
|
||||
})
|
||||
export class WeatherIcon {
|
||||
constructor() {
|
||||
}
|
||||
onAllChangesDone(data) {
|
||||
var icon = this.icon;
|
||||
|
||||
if(icon in WEATHER_ICONS) {
|
||||
this.weatherIcon = WEATHER_ICONS[icon];
|
||||
} else {
|
||||
this.weatherIcon = WEATHER_ICONS['cloudy'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'current-time',
|
||||
properties: [
|
||||
'localtz'
|
||||
]
|
||||
})
|
||||
@View({
|
||||
template: '<span class="current-time">{{currentTime}}</span>',
|
||||
})
|
||||
export class CurrentTime {
|
||||
constructor() {
|
||||
}
|
||||
onInit() {
|
||||
if(this.localtz) {
|
||||
this.currentTime = new Date();
|
||||
//this.currentTime = //$filter('date')(+(new Date), 'h:mm') + $scope.localtz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'current-weather',
|
||||
properties: [
|
||||
'current'
|
||||
]
|
||||
})
|
||||
@View({
|
||||
templateUrl: 'current-weather.html',
|
||||
directives: [NgIf]
|
||||
})
|
||||
export class CurrentWeather {
|
||||
constructor(elementRef: ElementRef) {
|
||||
this.elementRef = elementRef;
|
||||
|
||||
/*
|
||||
$rootScope.$on('settings.changed', function(settings) {
|
||||
var units = Settings.get('tempUnits');
|
||||
|
||||
if($scope.forecast) {
|
||||
|
||||
var forecast = $scope.forecast;
|
||||
var current = $scope.current;
|
||||
|
||||
if(units == 'f') {
|
||||
$scope.highTemp = forecast.forecastday[0].high.fahrenheit;
|
||||
$scope.lowTemp = forecast.forecastday[0].low.fahrenheit;
|
||||
$scope.currentTemp = Math.floor(current.temp_f);
|
||||
} else {
|
||||
$scope.highTemp = forecast.forecastday[0].high.celsius;
|
||||
$scope.lowTemp = forecast.forecastday[0].low.celsius;
|
||||
$scope.currentTemp = Math.floor(current.temp_c);
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
// Delay so we are in the DOM and can calculate sizes
|
||||
}
|
||||
|
||||
onInit() {
|
||||
var windowHeight = window.innerHeight;
|
||||
var thisHeight = this.elementRef.nativeElement.offsetHeight;
|
||||
var headerHeight = document.querySelector('#header').offsetHeight;
|
||||
this.elementRef.nativeElement.style.paddingTop = (windowHeight - 250) + 'px';
|
||||
/*
|
||||
document.querySelector('.content')).css('-webkit-overflow-scrolling', 'auto');
|
||||
$timeout(function() {
|
||||
angular.element(document.querySelector('.content')).css('-webkit-overflow-scrolling', 'touch');
|
||||
}, 50);
|
||||
*/
|
||||
}
|
||||
onAllChangesDone() {
|
||||
var units = 'f';//Settings.get('tempUnits');
|
||||
|
||||
let current = this.current;
|
||||
|
||||
console.log('ALL CHANGES DONE', current);
|
||||
|
||||
if(current && current.currently) {
|
||||
if(units == 'f') {
|
||||
this.currentTemp = Math.floor(current.currently.temperature);
|
||||
} else {
|
||||
this.currentTemp = Math.floor(current.currently.temperature);
|
||||
}
|
||||
if(units == 'f') {
|
||||
this.highTemp = Math.floor(current.daily.data[0].temperatureMax);
|
||||
this.lowTemp = Math.floor(current.daily.data[0].temperatureMin);
|
||||
} else {
|
||||
this.highTemp = Math.floor(current.daily.data[0].temperatureMax);
|
||||
this.lowTemp = Math.floor(current.daily.data[0].temperatureMin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'background-cycler',
|
||||
properties: [
|
||||
'image'
|
||||
]
|
||||
})
|
||||
@View({
|
||||
template: '<div class="bg-image"></div>'
|
||||
})
|
||||
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 {
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
transclude: true,
|
||||
scope: {
|
||||
title: '@'
|
||||
},
|
||||
template: '<div class="weather-box"><h4 class="title">{{title}}</h4><div ng-transclude></div></div>',
|
||||
link: function($scope, $element, $attr) {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
.directive('scrollEffects', function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function($scope, $element, $attr) {
|
||||
var amt, st, header;
|
||||
var bg = document.querySelector('.bg-image');
|
||||
$element.bind('scroll', function(e) {
|
||||
if(!header) {
|
||||
header = document.getElementById('header');
|
||||
}
|
||||
st = e.detail.scrollTop;
|
||||
if(st >= 0) {
|
||||
header.style.webkitTransform = 'translate3d(0, 0, 0)';
|
||||
} else if(st < 0) {
|
||||
header.style.webkitTransform = 'translate3d(0, ' + -st + 'px, 0)';
|
||||
}
|
||||
amt = Math.min(0.6, st / 1000);
|
||||
|
||||
ionic.requestAnimationFrame(function() {
|
||||
header.style.opacty = 1 - amt;
|
||||
if(bg) {
|
||||
bg.style.opacity = 1 - amt;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
*/
|
||||
@@ -1,28 +1,25 @@
|
||||
import {Component, Directive} from 'angular2/angular2';
|
||||
import {Component, Directive, View} from 'angular2/angular2';
|
||||
import {NgIf, NgFor, CSSClass, ElementRef} from 'angular2/angular2';
|
||||
import {FormBuilder, Control, ControlGroup, Validators, formDirectives} from 'angular2/forms';
|
||||
|
||||
import {IonicView, Animation, Modal, NavController, NavParams, IonicComponent} from 'ionic/ionic';
|
||||
import {IonicView, Animation, Content, Scroll, Modal, NavController, NavParams, IonicComponent} from 'ionic/ionic';
|
||||
|
||||
import {Geo} from './geo';
|
||||
import {Weather} from './weather';
|
||||
import {Flickr} from './flickr';
|
||||
|
||||
console.log('Imported', Geo, Weather, Flickr);
|
||||
|
||||
@Component({
|
||||
selector: 'ion-app',
|
||||
selector: 'ion-app'
|
||||
})
|
||||
@IonicView({
|
||||
templateUrl: 'main.html'
|
||||
@View({
|
||||
templateUrl: 'main.html',
|
||||
directives: [NgIf, NgFor, Content, Scroll, CurrentWeather, WeatherIcon, BackgroundCycler]
|
||||
})
|
||||
class WeatherApp {
|
||||
constructor(modal: Modal) {
|
||||
this.modal = Modal;
|
||||
this.modal = modal;
|
||||
|
||||
this.currentLocationString = 'Madison, WI';
|
||||
this.current = {
|
||||
local_tz_short: 'CDT'
|
||||
};
|
||||
|
||||
this.activeBgImageIndex = 0;
|
||||
|
||||
@@ -61,7 +58,27 @@ class WeatherApp {
|
||||
|
||||
getCurrent(lat, lng, locString) {
|
||||
Weather.getAtLocation(lat, lng).then((resp) => {
|
||||
this.current = resp.data;
|
||||
this.current = resp;
|
||||
|
||||
// TODO: This should be in a custom pipe
|
||||
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);
|
||||
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];
|
||||
let max = c.temperatureMax;
|
||||
let min = c.temperatureMin;
|
||||
c.temperatureMax = Math.floor(max);
|
||||
c.temperatureMin = Math.floor(min);
|
||||
c.time_date = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][new Date(c.time*1000).getDay()];
|
||||
}
|
||||
console.log('GOT CURRENT', this.current);
|
||||
}, (error) => {
|
||||
alert('Unable to get current conditions');
|
||||
@@ -112,12 +129,245 @@ class WeatherApp {
|
||||
*/
|
||||
|
||||
@IonicView({
|
||||
template: '<ion-view id="settings-modal"><ion-content padding><button primary (click)="close()">Close</button></ion-content></ion-view>'
|
||||
template: `<ion-view id="settings-modal">
|
||||
<ion-toolbar>
|
||||
<ion-title>Settings</ion-title>
|
||||
</ion-toolbar>
|
||||
<ion-content padding>
|
||||
<form (^submit)="doSubmit($event)" [ng-form-model]="settingsForm">
|
||||
<ion-list>
|
||||
<ion-input ion-item>
|
||||
<ion-label>Units</ion-label>
|
||||
<!--
|
||||
<ion-segment ng-control="units">
|
||||
<ion-segment-button value="standard" button>
|
||||
°F
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="standard" button>
|
||||
°C
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
-->
|
||||
</ion-input>
|
||||
</ion-list>
|
||||
</form>
|
||||
</ion-content>
|
||||
</ion-view>`,
|
||||
directives: [formDirectives]
|
||||
})
|
||||
export class SettingsModal {
|
||||
|
||||
constructor(fb: FormBuilder) {
|
||||
this.settingsForm = fb.group({
|
||||
mapStyle: ['hybrid', Validators.required]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function main(ionicBootstrap) {
|
||||
ionicBootstrap(WeatherApp);
|
||||
}
|
||||
|
||||
|
||||
let WEATHER_ICONS = {
|
||||
'partlycloudy': 'ion-ios-partlysunny-outline',
|
||||
'mostlycloudy': 'ion-ios-partlysunny-outline',
|
||||
'cloudy': 'ion-ios-cloudy-outline',
|
||||
'rain': 'ion-ios-rainy-outline',
|
||||
'tstorms': 'ion-ios-thunderstorm-outline',
|
||||
'sunny': 'ion-ios-sunny-outline',
|
||||
'clear-day': 'ion-ios-sunny-outline',
|
||||
'nt_clear': 'ion-ios-moon-outline',
|
||||
'clear-night': 'ion-ios-moon-outline'
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'weather-icon',
|
||||
properties: [
|
||||
'icon'
|
||||
]
|
||||
})
|
||||
@View({
|
||||
template: '<i class="icon" [class]="weatherIcon"></i>',
|
||||
directives: [CSSClass]
|
||||
})
|
||||
export class WeatherIcon {
|
||||
constructor() {
|
||||
}
|
||||
onAllChangesDone(data) {
|
||||
var icon = this.icon;
|
||||
|
||||
if(icon in WEATHER_ICONS) {
|
||||
this.weatherIcon = WEATHER_ICONS[icon];
|
||||
} else {
|
||||
this.weatherIcon = WEATHER_ICONS['cloudy'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'current-time',
|
||||
properties: [
|
||||
'localtz'
|
||||
]
|
||||
})
|
||||
@View({
|
||||
template: '<span class="current-time">{{currentTime}}</span>',
|
||||
})
|
||||
export class CurrentTime {
|
||||
constructor() {
|
||||
}
|
||||
onInit() {
|
||||
if(this.localtz) {
|
||||
this.currentTime = new Date();
|
||||
//this.currentTime = //$filter('date')(+(new Date), 'h:mm') + $scope.localtz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'current-weather',
|
||||
properties: [
|
||||
'current'
|
||||
]
|
||||
})
|
||||
@View({
|
||||
templateUrl: 'current-weather.html',
|
||||
directives: [NgIf]
|
||||
})
|
||||
export class CurrentWeather {
|
||||
constructor(elementRef: ElementRef) {
|
||||
this.elementRef = elementRef;
|
||||
|
||||
/*
|
||||
$rootScope.$on('settings.changed', function(settings) {
|
||||
var units = Settings.get('tempUnits');
|
||||
|
||||
if($scope.forecast) {
|
||||
|
||||
var forecast = $scope.forecast;
|
||||
var current = $scope.current;
|
||||
|
||||
if(units == 'f') {
|
||||
$scope.highTemp = forecast.forecastday[0].high.fahrenheit;
|
||||
$scope.lowTemp = forecast.forecastday[0].low.fahrenheit;
|
||||
$scope.currentTemp = Math.floor(current.temp_f);
|
||||
} else {
|
||||
$scope.highTemp = forecast.forecastday[0].high.celsius;
|
||||
$scope.lowTemp = forecast.forecastday[0].low.celsius;
|
||||
$scope.currentTemp = Math.floor(current.temp_c);
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
// Delay so we are in the DOM and can calculate sizes
|
||||
}
|
||||
|
||||
onInit() {
|
||||
var windowHeight = window.innerHeight;
|
||||
var thisHeight = this.elementRef.nativeElement.offsetHeight;
|
||||
var headerHeight = document.querySelector('#header').offsetHeight;
|
||||
this.elementRef.nativeElement.style.paddingTop = (windowHeight - 250) + 'px';
|
||||
/*
|
||||
document.querySelector('.content')).css('-webkit-overflow-scrolling', 'auto');
|
||||
$timeout(function() {
|
||||
angular.element(document.querySelector('.content')).css('-webkit-overflow-scrolling', 'touch');
|
||||
}, 50);
|
||||
*/
|
||||
}
|
||||
onAllChangesDone() {
|
||||
var units = 'f';//Settings.get('tempUnits');
|
||||
|
||||
let current = this.current;
|
||||
|
||||
console.log('ALL CHANGES DONE', current);
|
||||
|
||||
if(current && current.currently) {
|
||||
if(units == 'f') {
|
||||
this.currentTemp = Math.floor(current.currently.temperature);
|
||||
} else {
|
||||
this.currentTemp = Math.floor(current.currently.temperature);
|
||||
}
|
||||
if(units == 'f') {
|
||||
this.highTemp = Math.floor(current.daily.data[0].temperatureMax);
|
||||
this.lowTemp = Math.floor(current.daily.data[0].temperatureMin);
|
||||
} else {
|
||||
this.highTemp = Math.floor(current.daily.data[0].temperatureMax);
|
||||
this.lowTemp = Math.floor(current.daily.data[0].temperatureMin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'background-cycler',
|
||||
properties: [
|
||||
'image'
|
||||
]
|
||||
})
|
||||
@View({
|
||||
template: '<div class="bg-image"></div>'
|
||||
})
|
||||
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 {
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
transclude: true,
|
||||
scope: {
|
||||
title: '@'
|
||||
},
|
||||
template: '<div class="weather-box"><h4 class="title">{{title}}</h4><div ng-transclude></div></div>',
|
||||
link: function($scope, $element, $attr) {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
.directive('scrollEffects', function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function($scope, $element, $attr) {
|
||||
var amt, st, header;
|
||||
var bg = document.querySelector('.bg-image');
|
||||
$element.bind('scroll', function(e) {
|
||||
if(!header) {
|
||||
header = document.getElementById('header');
|
||||
}
|
||||
st = e.detail.scrollTop;
|
||||
if(st >= 0) {
|
||||
header.style.webkitTransform = 'translate3d(0, 0, 0)';
|
||||
} else if(st < 0) {
|
||||
header.style.webkitTransform = 'translate3d(0, ' + -st + 'px, 0)';
|
||||
}
|
||||
amt = Math.min(0.6, st / 1000);
|
||||
|
||||
ionic.requestAnimationFrame(function() {
|
||||
header.style.opacty = 1 - amt;
|
||||
if(bg) {
|
||||
bg.style.opacity = 1 - amt;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import {Http} from 'ionic/net/http';
|
||||
|
||||
let WUNDERGROUND_API_KEY = '1cc2d3de40fa5af0';
|
||||
|
||||
let FORECASTIO_KEY = '4cd3c5673825a361eb5ce108103ee84a';
|
||||
|
||||
export class Weather {
|
||||
static getAtLocation(lat, lng) {
|
||||
let url = 'https://api.forecast.io/forecast/' + FORECASTIO_KEY + '/';
|
||||
return Http.get(url + lat + ',' + lng + '?callback=JSON_CALLBACK', {
|
||||
method: 'jsonp'
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ let FORECASTIO_KEY = '4cd3c5673825a361eb5ce108103ee84a';
|
||||
export class Weather {
|
||||
static getAtLocation(lat, lng) {
|
||||
let url = 'https://api.forecast.io/forecast/' + FORECASTIO_KEY + '/';
|
||||
return Http.get(url + lat + ',' + lng);
|
||||
return Http.get(url + lat + ',' + lng + '?callback=JSON_CALLBACK', {
|
||||
method: 'jsonp'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import {ElementRef} from 'angular2/angular2'
|
||||
import {Component} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
|
||||
import {Ion} from '../ion';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'ion-content'
|
||||
})
|
||||
@View({
|
||||
template: `<div class="scroll-content"><content></content></div>`
|
||||
})
|
||||
export class Content extends Ion {
|
||||
constructor(elementRef: ElementRef) {
|
||||
super(elementRef);
|
||||
|
||||
setTimeout(() => {
|
||||
this.scrollElement = elementRef.nativeElement.children[0];
|
||||
});
|
||||
}
|
||||
|
||||
addScrollEventListener(handler) {
|
||||
if(!this.scrollElement) { return; }
|
||||
|
||||
this.scrollElement.addEventListener('scroll', handler);
|
||||
|
||||
return () => {
|
||||
this.scrollElement.removeEventListener('scroll', handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import {Component, Directive} from 'angular2/angular2';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
import {Component, Directive, View} from 'angular2/angular2';
|
||||
|
||||
import {FormBuilder, Validators, formDirectives, ControlGroup} from 'angular2/forms';
|
||||
//import {Switch, Form, List, Label, Item, Input, Content} from 'ionic/ionic';
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* Base class for all Ionic components. Exposes some common functionality
|
||||
* that all Ionic components need, such as accessing underlying native elements and
|
||||
* sending/receiving app-level events.
|
||||
*/
|
||||
export class Ion {
|
||||
constructor(elementRef: ElementRef) {
|
||||
console.log('ION INIT', elementRef);
|
||||
this.elementRef = elementRef;
|
||||
}
|
||||
|
||||
getNativeElement() {
|
||||
return this.elementRef.nativeElement;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,6 @@
|
||||
import {ElementRef, ComponentRef, onDestroy} from 'angular2/angular2';
|
||||
import {bind, Injector} from 'angular2/di';
|
||||
import {Component, Directive} from 'angular2/angular2';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
import {Parent, Ancestor} from 'angular2/src/core/annotations_impl/visibility';
|
||||
import {Component} from 'angular2/angular2';
|
||||
|
||||
import {IonicView, IonicConfig, Platform} from 'ionic/ionic';
|
||||
|
||||
import {IonicComponent} from 'ionic/ionic';
|
||||
import {IonicComponent, IonicView, IonicConfig, Platform} from 'ionic/ionic';
|
||||
import {Modal, NavController, NavParams, Animation, ActionMenu} from 'ionic/ionic';
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import {Component, Directive, onInit} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
import {Parent} from 'angular2/src/core/annotations_impl/visibility';
|
||||
import {Optional} from 'angular2/src/di/annotations_impl';
|
||||
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
|
||||
import {Injector} from 'angular2/di';
|
||||
import {Component, Directive, View, ElementRef, Parent, Optional, Injector, onInit, forwardRef} from 'angular2/angular2';
|
||||
|
||||
import {ViewController} from '../view/view-controller';
|
||||
|
||||
@@ -17,7 +12,7 @@ import {ViewController} from '../view/view-controller';
|
||||
})
|
||||
@View({
|
||||
template: '<template pane-anchor></template>',
|
||||
directives: [PaneAnchor]
|
||||
directives: [forwardRef(() => PaneAnchor)]
|
||||
})
|
||||
export class Nav extends ViewController {
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
|
||||
|
||||
import {IonicView} from 'ionic/ionic';
|
||||
|
||||
|
||||
@Component({ selector: 'ion-app' })
|
||||
@IonicView({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class IonicApp {
|
||||
constructor() {
|
||||
console.log('IonicApp Start')
|
||||
}
|
||||
doRefresh() {
|
||||
console.log('DOREFRESH')
|
||||
}
|
||||
}
|
||||
|
||||
export function main(ionicBootstrap) {
|
||||
ionicBootstrap(IonicApp);
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import {Directive} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
|
||||
import {Optional} from 'angular2/src/di/annotations_impl'
|
||||
|
||||
import {ViewItem} from './view-item';
|
||||
|
||||
import {Ion} from '../ion';
|
||||
|
||||
@Directive({
|
||||
selector: 'ion-view',
|
||||
})
|
||||
export class IonView extends Ion {
|
||||
constructor(@Optional() item: ViewItem, elementRef: ElementRef) {
|
||||
super(elementRef);
|
||||
this.ele = elementRef.nativeElement;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user