Permalink
Browse files

fixed #28 issue

  • Loading branch information...
1 parent 7981d3e commit b1535edb46ad5c54188ce8c653b30e5b6902edf6 @ninoseki committed Mar 2, 2013
View
@@ -51,7 +51,8 @@
<!-- /main -->
<!-- modal -->
-<div id="modal" class="modal hide fade"></div>
+<div id="timer-modal" class="modal hide fade"></div>
+<div id="stats-modal" class="modal hide fade"></div>
<!-- modal -->
View
@@ -26,7 +26,7 @@
<!-- main -->
<div id ="main">
<div class="container">
- <div id="modal" class="modal">
+ <div id="options-modal" class="modal">
</div>
</div>
@@ -3,10 +3,11 @@ TimerConfig = require '../models/timer_config'
module.exports = class MainRouter extends Backbone.Router
routes :
- "home" : "home"
- "working" : "working"
- "resting/:rest_type" : "resting"
- "stats" : "stats"
+ "home" :"home"
+ "home/:type" :"home"
+ "working" : "working"
+ "resting/:restType" : "resting"
+ "stats" : "stats"
"small-timer" : "smallTimer"
initialize: ->
@@ -32,13 +33,13 @@ module.exports = class MainRouter extends Backbone.Router
duration = @timerConfig.get restType + 'BreakDuration'
application.restingView.startTimer(if application.development == true then 10 else duration * 60)
- application.states.setCurrentStateName('resting/' + rest_type)
+ application.states.setCurrentStateName('resting/' + restType)
stats: ->
application.pomodoros.fetch()
application.statsView.render()
smallTimer: ->
- $("#modal").modal("show")
+ $("#timer-modal").modal("show")
- application.router.navigate 'home/onWorking', true
+ application.router.navigate 'home/onWorking', true
@@ -4,7 +4,7 @@ template = require './templates/options'
module.exports = class OptionsView extends View
template: template
- el: "#modal"
+ el: "#options-modal"
events:
"click #update": "update"
@@ -4,7 +4,7 @@ template = require './templates/timer'
module.exports = class RestingView extends View
template: template
- el: "#modal"
+ el: "#timer-modal"
events:
"click #cancel": "resetTimer"
@@ -4,7 +4,7 @@ template = require './templates/stats'
module.exports = class StatsView extends View
template: template
- el: "#modal"
+ el: "#stats-modal"
id: "stats"
events:
@@ -59,4 +59,8 @@ module.exports = class StatsView extends View
# hide modal
@$el.modal('hide')
- application.router.navigate 'home', true
+ currentStateName = application.states.getCurrentStateName()
+ if currentStateName == "working"
+ application.router.navigate 'home/onWorking', true
+ else
+ application.router.navigate 'home', true
@@ -1,4 +1,4 @@
-#modal
+#timer-modal, #stats-modal, #options-modal
.modal-header
#cancel
text-align right
@@ -4,7 +4,7 @@ template = require './templates/timer'
module.exports = class WorkingView extends View
template: template
- el: "#modal"
+ el: "#timer-modal"
events:
"click #cancel": "resetTimer"
@@ -16,7 +16,7 @@ module.exports = class WorkingView extends View
}
afterRender: ->
- $('#hide').show()
+ @$el.find('#hide').show()
@$el.modal(backdrop: 'static', show: true)
this
@@ -37,14 +37,11 @@ module.exports = class WorkingView extends View
# hide modal
$("#small-timer-container").hide()
@$el.modal('hide')
- application.router.navigate 'home', true
# add pomodoro
application.pomodoros.create created_at: new Date().getTime()
-
# ring alarm
application.audios.alarm.play()
-
# show notification
notification = webkitNotifications.createNotification(
'images/tomato_32.png',
@@ -53,6 +50,8 @@ module.exports = class WorkingView extends View
)
notification.show()
+ application.router.navigate 'home', true
+
hideTimer: ->
@$el.modal('hide')
$("#small-timer-container").show()
View
@@ -1,6 +1,6 @@
{
"name": "Pomodoro Daisuki",
- "version": "0.50",
+ "version": "0.51",
"manifest_version": 2,
"description": "Tool for Pomodoro Technique",
"icons": {
View
@@ -51,7 +51,8 @@
<!-- /main -->
<!-- modal -->
-<div id="modal" class="modal hide fade"></div>
+<div id="timer-modal" class="modal hide fade"></div>
+<div id="stats-modal" class="modal hide fade"></div>
<!-- modal -->
View
@@ -494,8 +494,9 @@ window.require.define({"routers/main_router": function(exports, require, module)
MainRouter.prototype.routes = {
"home": "home",
+ "home/:type": "home",
"working": "working",
- "resting/:rest_type": "resting",
+ "resting/:restType": "resting",
"stats": "stats",
"small-timer": "smallTimer"
};
@@ -526,7 +527,7 @@ window.require.define({"routers/main_router": function(exports, require, module)
application.restingView.render();
duration = this.timerConfig.get(restType + 'BreakDuration');
application.restingView.startTimer(application.development === true ? 10 : duration * 60);
- return application.states.setCurrentStateName('resting/' + rest_type);
+ return application.states.setCurrentStateName('resting/' + restType);
};
MainRouter.prototype.stats = function() {
@@ -535,7 +536,7 @@ window.require.define({"routers/main_router": function(exports, require, module)
};
MainRouter.prototype.smallTimer = function() {
- $("#modal").modal("show");
+ $("#timer-modal").modal("show");
return application.router.navigate('home/onWorking', true);
};
@@ -1016,7 +1017,7 @@ window.require.define({"views/options_view": function(exports, require, module)
OptionsView.prototype.template = template;
- OptionsView.prototype.el = "#modal";
+ OptionsView.prototype.el = "#options-modal";
OptionsView.prototype.events = {
"click #update": "update"
@@ -1071,7 +1072,7 @@ window.require.define({"views/resting_view": function(exports, require, module)
RestingView.prototype.template = template;
- RestingView.prototype.el = "#modal";
+ RestingView.prototype.el = "#timer-modal";
RestingView.prototype.events = {
"click #cancel": "resetTimer"
@@ -1145,7 +1146,7 @@ window.require.define({"views/stats_view": function(exports, require, module) {
StatsView.prototype.template = template;
- StatsView.prototype.el = "#modal";
+ StatsView.prototype.el = "#stats-modal";
StatsView.prototype.id = "stats";
@@ -1231,8 +1232,14 @@ window.require.define({"views/stats_view": function(exports, require, module) {
};
StatsView.prototype.close = function() {
+ var currentStateName;
this.$el.modal('hide');
- return application.router.navigate('home', true);
+ currentStateName = application.states.getCurrentStateName();
+ if (currentStateName === "working") {
+ return application.router.navigate('home/onWorking', true);
+ } else {
+ return application.router.navigate('home', true);
+ }
};
return StatsView;
@@ -1850,7 +1857,7 @@ window.require.define({"views/working_view": function(exports, require, module)
WorkingView.prototype.template = template;
- WorkingView.prototype.el = "#modal";
+ WorkingView.prototype.el = "#timer-modal";
WorkingView.prototype.events = {
"click #cancel": "resetTimer",
@@ -1864,7 +1871,7 @@ window.require.define({"views/working_view": function(exports, require, module)
};
WorkingView.prototype.afterRender = function() {
- $('#hide').show();
+ this.$el.find('#hide').show();
this.$el.modal({
backdrop: 'static',
show: true
@@ -1889,13 +1896,13 @@ window.require.define({"views/working_view": function(exports, require, module)
var notification;
$("#small-timer-container").hide();
this.$el.modal('hide');
- application.router.navigate('home', true);
application.pomodoros.create({
created_at: new Date().getTime()
});
application.audios.alarm.play();
notification = webkitNotifications.createNotification('images/tomato_32.png', 'notification', 'pomodoro is done!');
- return notification.show();
+ notification.show();
+ return application.router.navigate('home', true);
};
WorkingView.prototype.hideTimer = function() {
View
@@ -26,7 +26,7 @@
<!-- main -->
<div id ="main">
<div class="container">
- <div id="modal" class="modal">
+ <div id="options-modal" class="modal">
</div>
</div>
View
@@ -6676,21 +6676,29 @@ body #main #add-column {
body #main #add-column:hover {
opacity: 0.5;
}
-#modal .modal-header #cancel {
+#timer-modal .modal-header #cancel,
+#stats-modal .modal-header #cancel,
+#options-modal .modal-header #cancel {
text-align: right;
}
-#modal .modal-body {
+#timer-modal .modal-body,
+#stats-modal .modal-body,
+#options-modal .modal-body {
min-height: 100px;
margin-top: 40px;
text-align: center;
font-family: "Lucida Sans Unicode" "Lucida Grande" sans-serif;
}
-#modal .modal-body #timer {
+#timer-modal .modal-body #timer,
+#stats-modal .modal-body #timer,
+#options-modal .modal-body #timer {
margin: 5px 0px 0px 5px;
font-size: 80px;
text-shadow: 4px 4px 5px #d3d3d3;
}
-#modal .modal-body #stats {
+#timer-modal .modal-body #stats,
+#stats-modal .modal-body #stats,
+#options-modal .modal-body #stats {
font-size: 24px;
text-shadow: none;
}

0 comments on commit b1535ed

Please sign in to comment.