Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

indent change. (tab -> space)

  • Loading branch information...
commit 1d6c424b9aa95bb470fc68d2568530fb676a1faf 1 parent c98e1b6
@fujikky authored
View
2  index.html
@@ -71,7 +71,7 @@
<script src="/js/app-transitions.js"></script>
<script src="/js/app.js"></script>
<script>
- Y = YUI().use('forecast-app', function (Y) {
+ YUI().use('forecast-app', function (Y) {
new Y.Forecast.App({
html5: true,
root: '/',
View
104 js/app-transitions.js
@@ -1,58 +1,58 @@
YUI.add('forecast-app-transitions', function (Y) {
- var duration = 0.35;
+ var duration = 0.35;
- Y.mix(Y.Transition.fx, {
- 'app:slideCenterToLeft': {
- duration : duration,
- transform: 'translateX(-100%)',
- on: {
- start: function () {
- },
- end: function () {
- this.setStyle('transform', 'none');
- }
- }
- },
- 'app:slideRightToCenter': {
- duration : duration,
- transform: 'translateX(0)',
- on: {
- start: function () {
- this.setStyle('transform', 'translateX(100%)');
- },
- end: function () {
- this.setStyle('transform', 'none');
- }
- }
- },
- 'app:slideCenterToRight': {
- duration : duration,
- transform: 'translateX(100%)',
- on: {
- start: function () {
- },
- end: function () {
- this.setStyle('transform', 'none');
- }
- }
- },
- 'app:slideLeftToCenter': {
- duration : duration,
- transform: 'translateX(0)',
- on: {
- start: function () {
- this.setStyle('transform', 'translateX(-100%)');
- },
- end: function () {
- this.setStyle('transform', 'none');
- }
- }
- }
- }, true);
+ Y.mix(Y.Transition.fx, {
+ 'app:slideCenterToLeft': {
+ duration : duration,
+ transform: 'translateX(-100%)',
+ on: {
+ start: function () {
+ },
+ end: function () {
+ this.setStyle('transform', 'none');
+ }
+ }
+ },
+ 'app:slideRightToCenter': {
+ duration : duration,
+ transform: 'translateX(0)',
+ on: {
+ start: function () {
+ this.setStyle('transform', 'translateX(100%)');
+ },
+ end: function () {
+ this.setStyle('transform', 'none');
+ }
+ }
+ },
+ 'app:slideCenterToRight': {
+ duration : duration,
+ transform: 'translateX(100%)',
+ on: {
+ start: function () {
+ },
+ end: function () {
+ this.setStyle('transform', 'none');
+ }
+ }
+ },
+ 'app:slideLeftToCenter': {
+ duration : duration,
+ transform: 'translateX(0)',
+ on: {
+ start: function () {
+ this.setStyle('transform', 'translateX(-100%)');
+ },
+ end: function () {
+ this.setStyle('transform', 'none');
+ }
+ }
+ }
+ }, true);
}, '1.0.0', {
- requires: [
- 'transition'
- ]
+ requires: [
+ 'transition'
+ ]
});
View
276 js/app.js
@@ -1,143 +1,143 @@
YUI.add('forecast-app', function (Y) {
- var Forecast = Y.namespace('Forecast');
-
- Forecast.App = Y.Base.create('forecastApp', Y.App, [], {
-
- views: {
- areaView: {
- type: Forecast.AreaView
- },
- prefView: {
- type: Forecast.PrefView,
- parent: 'areaView'
- },
- cityView: {
- type: Forecast.CityView,
- parent: 'prefView'
- },
- weatherView: {
- type: Forecast.WeatherView,
- parent: 'cityView'
- }
- },
-
- initializer: function () {
-
- this.once('ready', function () {
- if (this.hasRoute(this.getPath())) {
- this.dispatch();
- } else {
- this.navigate('/');
- }
- Y.config.win.scrollTo(0, 0);
- });
-
- },
-
- handleArea: function (req, res, next) {
- var area = this.get('area');
- area.load(function () {
- req.area = area;
- next();
- });
- },
-
- handleWeather: function (req, res, next) {
- var weather = this.get('weather');
- weather.load({city: req.params.city}, function () {
- req.weather = weather;
- next();
- });
- },
-
- showAreaView: function (req) {
- this.showView('areaView', {
- model: req.area
- });
- },
-
- showPrefView: function (req) {
- this.showView('prefView', {
- model: req.area,
- area: req.params.area
- });
- },
-
- showCityView: function (req) {
- this.showView('cityView', {
- model: req.area,
- area: req.params.area,
- pref: req.params.pref
- });
- },
-
- showWeatherView: function (req) {
- this.showView('weatherView', {
- areaModel: req.area,
- model: req.weather,
- area: req.params.area,
- pref: req.params.pref,
- city: req.params.city
- });
- },
-
- transitions: {
- navigate: {
- viewIn : 'app:fadeIn',
- viewOut: 'app:fadeOut'
- },
- toChild: {
- viewIn : 'app:slideRightToCenter',
- viewOut: 'app:slideCenterToLeft'
- },
- toParent: {
- viewIn : 'app:slideLeftToCenter',
- viewOut: 'app:slideCenterToRight'
- }
- }
-
- }, {
-
- ATTRS: {
-
- // models
- area: {value: new Forecast.Area()},
- weather: {value: new Forecast.Weather()},
-
- routes: {
- value: [
-
- {path: '/', callback: 'handleArea'},
- {path: '/', callback: 'showAreaView'},
-
- {path: '/:area', callback: 'handleArea'},
- {path: '/:area', callback: 'showPrefView'},
-
- {path: '/:area/:pref', callback: 'handleArea'},
- {path: '/:area/:pref', callback: 'showCityView'},
-
- {path: '/:area/:pref/:city', callback: 'handleArea'},
- {path: '/:area/:pref/:city', callback: 'handleWeather'},
- {path: '/:area/:pref/:city', callback: 'showWeatherView'}
-
- ]
- }
- }
-
- });
+ var Forecast = Y.namespace('Forecast');
+
+ Forecast.App = Y.Base.create('forecastApp', Y.App, [], {
+
+ views: {
+ areaView: {
+ type: Forecast.AreaView
+ },
+ prefView: {
+ type: Forecast.PrefView,
+ parent: 'areaView'
+ },
+ cityView: {
+ type: Forecast.CityView,
+ parent: 'prefView'
+ },
+ weatherView: {
+ type: Forecast.WeatherView,
+ parent: 'cityView'
+ }
+ },
+
+ initializer: function () {
+
+ this.once('ready', function () {
+ if (this.hasRoute(this.getPath())) {
+ this.dispatch();
+ } else {
+ this.navigate('/');
+ }
+ Y.config.win.scrollTo(0, 0);
+ });
+
+ },
+
+ handleArea: function (req, res, next) {
+ var area = this.get('area');
+ area.load(function () {
+ req.area = area;
+ next();
+ });
+ },
+
+ handleWeather: function (req, res, next) {
+ var weather = this.get('weather');
+ weather.load({city: req.params.city}, function () {
+ req.weather = weather;
+ next();
+ });
+ },
+
+ showAreaView: function (req) {
+ this.showView('areaView', {
+ model: req.area
+ });
+ },
+
+ showPrefView: function (req) {
+ this.showView('prefView', {
+ model: req.area,
+ area: req.params.area
+ });
+ },
+
+ showCityView: function (req) {
+ this.showView('cityView', {
+ model: req.area,
+ area: req.params.area,
+ pref: req.params.pref
+ });
+ },
+
+ showWeatherView: function (req) {
+ this.showView('weatherView', {
+ areaModel: req.area,
+ model: req.weather,
+ area: req.params.area,
+ pref: req.params.pref,
+ city: req.params.city
+ });
+ },
+
+ transitions: {
+ navigate: {
+ viewIn : 'app:fadeIn',
+ viewOut: 'app:fadeOut'
+ },
+ toChild: {
+ viewIn : 'app:slideRightToCenter',
+ viewOut: 'app:slideCenterToLeft'
+ },
+ toParent: {
+ viewIn : 'app:slideLeftToCenter',
+ viewOut: 'app:slideCenterToRight'
+ }
+ }
+
+ }, {
+
+ ATTRS: {
+
+ // models
+ area: {value: new Forecast.Area()},
+ weather: {value: new Forecast.Weather()},
+
+ routes: {
+ value: [
+
+ {path: '/', callback: 'handleArea'},
+ {path: '/', callback: 'showAreaView'},
+
+ {path: '/:area', callback: 'handleArea'},
+ {path: '/:area', callback: 'showPrefView'},
+
+ {path: '/:area/:pref', callback: 'handleArea'},
+ {path: '/:area/:pref', callback: 'showCityView'},
+
+ {path: '/:area/:pref/:city', callback: 'handleArea'},
+ {path: '/:area/:pref/:city', callback: 'handleWeather'},
+ {path: '/:area/:pref/:city', callback: 'showWeatherView'}
+
+ ]
+ }
+ }
+
+ });
}, '1.0.0', {
- requires: [
- 'app',
- 'app-transitions',
- 'transition',
- 'forecast-app-transitions',
- 'forecast-model-area',
- 'forecast-model-weather',
- 'forecast-view-area',
- 'forecast-view-pref',
- 'forecast-view-city',
- 'forecast-view-weather'
- ]
+ requires: [
+ 'app',
+ 'app-transitions',
+ 'transition',
+ 'forecast-app-transitions',
+ 'forecast-model-area',
+ 'forecast-model-weather',
+ 'forecast-view-area',
+ 'forecast-view-pref',
+ 'forecast-view-city',
+ 'forecast-view-weather'
+ ]
});
View
162 js/models/area.js
@@ -1,86 +1,86 @@
YUI.add('forecast-model-area', function (Y) {
- var YArray = Y.Array,
- YLang = Y.Lang;
-
- Y.namespace('Forecast').Area = Y.Base.create('area', Y.Model, [Y.ModelSync.YQL], {
-
- cache: new Y.CacheOffline,
- query: 'SELECT * FROM xml WHERE url="http://weather.livedoor.com/forecast/rss/forecastmap.xml"',
- parse: function (results) {
- return results.rss.channel.source;
- },
-
- getAreas: function () {
- return YArray.map(this.get('area'), function (area, index) {
- return {
- id: (index + 1),
- title: area.title
- };
- });
- },
-
- getAreaName: function (areaId) {
- var areas = this.getAreas();
- return areas[areaId - 1].title;
- },
-
- getPrefs: function (areaId) {
-
- var area = this.get('area')[areaId - 1],
- prefs = area.pref;
-
- prefs = YLang.isArray(prefs) ? prefs : [prefs];
-
- return YArray.map(prefs, function (pref, index) {
- return {
- id: (index + 1),
- title: pref.title
- }
- });
-
- },
-
- getPrefName: function (areaId, prefId) {
- var prefs = this.getPrefs(areaId);
- return prefs[prefId - 1].title;
- },
-
- getCities: function (areaId, prefId) {
-
- var area = this.get('area')[areaId - 1],
- prefs = area.pref,
- cities;
-
- prefs = YLang.isArray(prefs) ? prefs : [prefs];
-
- return YArray.map(prefs[prefId - 1].city, function (city, index) {
- return {
- id: city.id,
- title: city.title
- }
- });
-
- },
-
- getCityName: function (areaId, prefId, cityId) {
- var cities = this.getCities(areaId, prefId),
- city = YArray.find(cities, function (city) {
- return (city.id === cityId);
- });
- return city.title || '';
- }
-
- }, {
- ATTRS: {
- area: {value: null}
- }
- });
+ var YArray = Y.Array,
+ YLang = Y.Lang;
+
+ Y.namespace('Forecast').Area = Y.Base.create('area', Y.Model, [Y.ModelSync.YQL], {
+
+ cache: new Y.CacheOffline,
+ query: 'SELECT * FROM xml WHERE url="http://weather.livedoor.com/forecast/rss/forecastmap.xml"',
+ parse: function (results) {
+ return results.rss.channel.source;
+ },
+
+ getAreas: function () {
+ return YArray.map(this.get('area'), function (area, index) {
+ return {
+ id: (index + 1),
+ title: area.title
+ };
+ });
+ },
+
+ getAreaName: function (areaId) {
+ var areas = this.getAreas();
+ return areas[areaId - 1].title;
+ },
+
+ getPrefs: function (areaId) {
+
+ var area = this.get('area')[areaId - 1],
+ prefs = area.pref;
+
+ prefs = YLang.isArray(prefs) ? prefs : [prefs];
+
+ return YArray.map(prefs, function (pref, index) {
+ return {
+ id: (index + 1),
+ title: pref.title
+ }
+ });
+
+ },
+
+ getPrefName: function (areaId, prefId) {
+ var prefs = this.getPrefs(areaId);
+ return prefs[prefId - 1].title;
+ },
+
+ getCities: function (areaId, prefId) {
+
+ var area = this.get('area')[areaId - 1],
+ prefs = area.pref,
+ cities;
+
+ prefs = YLang.isArray(prefs) ? prefs : [prefs];
+
+ return YArray.map(prefs[prefId - 1].city, function (city, index) {
+ return {
+ id: city.id,
+ title: city.title
+ }
+ });
+
+ },
+
+ getCityName: function (areaId, prefId, cityId) {
+ var cities = this.getCities(areaId, prefId),
+ city = YArray.find(cities, function (city) {
+ return (city.id === cityId);
+ });
+ return city.title || '';
+ }
+
+ }, {
+ ATTRS: {
+ area: {value: null}
+ }
+ });
}, '1.0.0', {
- requires: [
- 'model',
- 'gallery-model-sync-yql',
- 'cache-offline'
- ]
+ requires: [
+ 'model',
+ 'gallery-model-sync-yql',
+ 'cache-offline'
+ ]
});
View
64 js/models/weather.js
@@ -1,41 +1,41 @@
YUI.add('forecast-model-weather', function (Y) {
- Y.namespace('Forecast').Weather = Y.Base.create('weather', Y.Model, [Y.ModelSync.YQL], {
+ Y.namespace('Forecast').Weather = Y.Base.create('weather', Y.Model, [Y.ModelSync.YQL], {
- cache: new Y.CacheOffline,
- query: 'SELECT * FROM xml WHERE url="http://weather.livedoor.com/forecast/webservice/rest/v1?city={city}&amp;day={day}"',
+ cache: new Y.CacheOffline,
+ query: 'SELECT * FROM xml WHERE url="http://weather.livedoor.com/forecast/webservice/rest/v1?city={city}&amp;day={day}"',
- buildQuery: function (options) {
- options || (options = {});
- return Y.Lang.sub(this.query, {
- city: options.city || 63, // tokyo
- day: options.day || 'today'
- });
- },
+ buildQuery: function (options) {
+ options || (options = {});
+ return Y.Lang.sub(this.query, {
+ city: options.city || 63, // tokyo
+ day: options.day || 'today'
+ });
+ },
- parse: function (results) {
- return results.lwws;
- }
+ parse: function (results) {
+ return results.lwws;
+ }
- }, {
- ATTRS: {
- location: {value: null},
- title: {value: null},
- forecastday: {value: null},
- day: {value: null},
- forecastdate: {value: null},
- telop: {value: null},
- description: {value: null},
- image: {value: null},
- temperature: {value: null},
- link: {value: null}
- }
- });
+ }, {
+ ATTRS: {
+ location: {value: null},
+ title: {value: null},
+ forecastday: {value: null},
+ day: {value: null},
+ forecastdate: {value: null},
+ telop: {value: null},
+ description: {value: null},
+ image: {value: null},
+ temperature: {value: null},
+ link: {value: null}
+ }
+ });
}, '1.0.0', {
- requires: [
- 'model',
- 'gallery-model-sync-yql',
- 'cache-offline'
- ]
+ requires: [
+ 'model',
+ 'gallery-model-sync-yql',
+ 'cache-offline'
+ ]
});
View
24 js/views/area.js
@@ -1,22 +1,22 @@
YUI.add('forecast-view-area', function (Y) {
- Y.namespace('Forecast').AreaView = Y.Base.create('areaView', Y.View, [], {
+ Y.namespace('Forecast').AreaView = Y.Base.create('areaView', Y.View, [], {
- template: Y.Handlebars.compile(Y.one('#area-view').getContent()),
+ template: Y.Handlebars.compile(Y.one('#area-view').getContent()),
- render: function () {
+ render: function () {
- var content = this.template({areas: this.get('model').getAreas()});
- this.get('container').setContent(content);
+ var content = this.template({areas: this.get('model').getAreas()});
+ this.get('container').setContent(content);
- return this;
- }
+ return this;
+ }
- });
+ });
}, '1.0.0', {
- requires: [
- 'view',
- 'handlebars'
- ]
+ requires: [
+ 'view',
+ 'handlebars'
+ ]
});
View
68 js/views/city.js
@@ -1,47 +1,47 @@
YUI.add('forecast-view-city', function (Y) {
- Y.namespace('Forecast').CityView = Y.Base.create('cityView', Y.View, [], {
+ Y.namespace('Forecast').CityView = Y.Base.create('cityView', Y.View, [], {
- template: Y.Handlebars.compile(Y.one('#city-view').getContent()),
+ template: Y.Handlebars.compile(Y.one('#city-view').getContent()),
- initializer: function (options) {
- this.setAttrs({
- area: options.area,
- pref: options.pref
- });
- },
+ initializer: function (options) {
+ this.setAttrs({
+ area: options.area,
+ pref: options.pref
+ });
+ },
- events: {
- '.list-view a': {
- click: function (e) {
- e.target.addClass('loading');
- }
- }
- },
+ events: {
+ '.list-view a': {
+ click: function (e) {
+ e.target.addClass('loading');
+ }
+ }
+ },
- render: function () {
+ render: function () {
- var areaId = this.get('area'),
- prefId = this.get('pref'),
- model = this.get('model'),
- content = this.template({
- areaId: areaId,
- areaName: model.getAreaName(areaId),
- prefId: prefId,
- prefName: model.getPrefName(areaId, prefId),
- cities: model.getCities(areaId, prefId)
- });
+ var areaId = this.get('area'),
+ prefId = this.get('pref'),
+ model = this.get('model'),
+ content = this.template({
+ areaId: areaId,
+ areaName: model.getAreaName(areaId),
+ prefId: prefId,
+ prefName: model.getPrefName(areaId, prefId),
+ cities: model.getCities(areaId, prefId)
+ });
- this.get('container').setContent(content);
+ this.get('container').setContent(content);
- return this;
- }
+ return this;
+ }
- });
+ });
}, '1.0.0', {
- requires: [
- 'view',
- 'handlebars'
- ]
+ requires: [
+ 'view',
+ 'handlebars'
+ ]
});
View
69 js/views/pref.js
@@ -1,46 +1,33 @@
YUI.add('forecast-view-pref', function (Y) {
- Y.namespace('Forecast').PrefView = Y.Base.create('prefView', Y.View, [], {
-
- template: Y.Handlebars.compile(Y.one('#pref-view').getContent()),
-
- initializer: function (options) {
- this.set('area', options.area);
- },
-
- render: function () {
-
- var areaId = this.get('area'),
- model = this.get('model'),
- /*
- area = this.get('model').getArea(areaId),
- prefObj = area.pref,
- pref = Y.Lang.isArray(prefObj) ? Y.Array.map(area.pref, function (a, index) {
- return {
- id: (index + 1),
- title: a.title
- };
- }) : [{
- id: 1,
- title: prefObj.title
- }],
- */
- content = this.template({
- areaId: areaId,
- areaName: model.getAreaName(areaId),
- prefs: model.getPrefs(areaId)
- });
-
- this.get('container').setContent(content);
-
- return this;
- }
-
- });
+ Y.namespace('Forecast').PrefView = Y.Base.create('prefView', Y.View, [], {
+
+ template: Y.Handlebars.compile(Y.one('#pref-view').getContent()),
+
+ initializer: function (options) {
+ this.set('area', options.area);
+ },
+
+ render: function () {
+
+ var areaId = this.get('area'),
+ model = this.get('model'),
+ content = this.template({
+ areaId: areaId,
+ areaName: model.getAreaName(areaId),
+ prefs: model.getPrefs(areaId)
+ });
+
+ this.get('container').setContent(content);
+
+ return this;
+ }
+
+ });
}, '1.0.0', {
- requires: [
- 'view',
- 'handlebars'
- ]
+ requires: [
+ 'view',
+ 'handlebars'
+ ]
});
View
62 js/views/weather.js
@@ -1,44 +1,44 @@
YUI.add('forecast-view-weather', function (Y) {
- Y.namespace('Forecast').WeatherView = Y.Base.create('weatherView', Y.View, [], {
+ Y.namespace('Forecast').WeatherView = Y.Base.create('weatherView', Y.View, [], {
- template: Y.Handlebars.compile(Y.one('#weather-view').getContent()),
+ template: Y.Handlebars.compile(Y.one('#weather-view').getContent()),
- initializer: function (options) {
- this.setAttrs({
- areaModel: options.areaModel,
- area: options.area,
- pref: options.pref,
- city: options.city
- });
- },
+ initializer: function (options) {
+ this.setAttrs({
+ areaModel: options.areaModel,
+ area: options.area,
+ pref: options.pref,
+ city: options.city
+ });
+ },
- render: function () {
+ render: function () {
- var areaModel = this.get('areaModel'),
- areaId = this.get('area'),
- prefId = this.get('pref'),
- cityId = this.get('city'),
- context = Y.mix({
- areaId: areaId,
- prefId: prefId,
- prefName: areaModel.getPrefName(areaId, prefId),
- cityId: cityId,
- cityName: areaModel.getCityName(areaId, prefId, cityId)
- }, this.get('model').toJSON()),
+ var areaModel = this.get('areaModel'),
+ areaId = this.get('area'),
+ prefId = this.get('pref'),
+ cityId = this.get('city'),
+ context = Y.mix({
+ areaId: areaId,
+ prefId: prefId,
+ prefName: areaModel.getPrefName(areaId, prefId),
+ cityId: cityId,
+ cityName: areaModel.getCityName(areaId, prefId, cityId)
+ }, this.get('model').toJSON()),
- content = this.template(context);
+ content = this.template(context);
- this.get('container').setContent(content);
+ this.get('container').setContent(content);
- return this;
- }
+ return this;
+ }
- });
+ });
}, '1.0.0', {
- requires: [
- 'view',
- 'handlebars'
- ]
+ requires: [
+ 'view',
+ 'handlebars'
+ ]
});
Please sign in to comment.
Something went wrong with that request. Please try again.