summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorji.ji <ji.ji@samsung.com>2013-07-09 19:20:36 +0900
committerji.ji <ji.ji@samsung.com>2013-07-09 19:20:36 +0900
commitee8c837e71c3d1251711620d169d651c7eb9a645 (patch)
treecdb533f799b074ddaaca027de75d0e06510ea24d
parent699a70d00280620e71c938b86ad7a5bf5646f32e (diff)
downloadEventManager-ee8c837e71c3d1251711620d169d651c7eb9a645.tar.gz
EventManager-ee8c837e71c3d1251711620d169d651c7eb9a645.tar.bz2
EventManager-ee8c837e71c3d1251711620d169d651c7eb9a645.zip
[EventManager]Updated Private -> RSA
Change-Id: I5780590c0e40f287148bf05980173d33afc833d7
-rw-r--r--config.xml2
-rw-r--r--css/style.css10
-rw-r--r--index.html4
-rw-r--r--js/app.js5
-rw-r--r--js/app.model.js21
-rw-r--r--js/app.ui.js328
-rw-r--r--templates/alarm.tpl2
-rw-r--r--templates/home.tpl5
-rw-r--r--templates/new_event.tpl31
9 files changed, 202 insertions, 206 deletions
diff --git a/config.xml b/config.xml
index 82c92ee..b60702f 100644
--- a/config.xml
+++ b/config.xml
@@ -6,7 +6,7 @@
package="VJTVhzmnwf" required_version="2.2" />
<content src="index.html" />
<icon src="icon.png" />
- <name>EventManager</name>
+ <name>Event manager</name>
<tizen:privilege name="http://tizen.org/privilege/application.launch" />
<tizen:privilege name="http://tizen.org/privilege/calendar.read" />
<tizen:privilege name="http://tizen.org/privilege/calendar.write" />
diff --git a/css/style.css b/css/style.css
index c6780ef..3934f96 100644
--- a/css/style.css
+++ b/css/style.css
@@ -82,10 +82,6 @@ li.event .ui-li-aside {
[data-role="footer"] {
display: block !important;
}
-.ui-tabbar:not(.ui-tabbar-persist) a.ui-btn-active, .ui-tabbar:not(.ui-tabbar-persist) .ui-btn-show-style {
- color:#999;
- border:none;
-}
.ui-tabbar:not(.ui-tabbar-persist) a.ui-btn-active .ui-btn-text, .ui-tabbar:not(.ui-tabbar-persist) .ui-btn-show-style .ui-btn-text {
border:none;
}
@@ -98,4 +94,8 @@ li.event .ui-li-aside {
}
.ui-datefield .ui-datefield-month {
line-height: 46px;
-} \ No newline at end of file
+}
+
+.ui-btn-back {
+ visibility:hidden;
+}
diff --git a/index.html b/index.html
index 837733e..617895f 100644
--- a/index.html
+++ b/index.html
@@ -2,10 +2,10 @@
<html>
<head>
<meta charset="utf-8"/>
- <meta name="description" content="EventManager"/>
+ <meta name="description" content="Event manager"/>
<meta name="viewport" content="width=360, user-scalable=no"/>
- <title>Event Manager</title>
+ <title>Event manager</title>
<script src="/usr/share/tizen-web-ui-fw/latest/js/jquery.min.js"></script>
<script src="/usr/share/tizen-web-ui-fw/latest/js/tizen-web-ui-fw-libs.min.js"></script>
diff --git a/js/app.js b/js/app.js
index 5859cb3..ec0f46c 100644
--- a/js/app.js
+++ b/js/app.js
@@ -89,6 +89,7 @@ var App = null;
switchAlarm: function switchAlarm() {
var duration = -1;
duration = this.ui.alarm.getDuration();
+ this.ui.alarm.updateDurationLabel(true);
if (duration != -1) {
this.alarmN = this.model.getCalendarAlarm(duration, "EventManager Reminder");
@@ -210,10 +211,12 @@ var App = null;
endDate = new Date(endDate);
if (fullDay) {
+ startDate.setHours(0, 0, 0, 0);
+ endDate.setHours(0, 0, 0, 0);
+
oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
diffDays = Math.round(Math.abs((startDate.getTime() - endDate.getTime())/(oneDay)));
- diffDays = (diffDays < 1 ? 1 : diffDays); //minimum 1 day duration
duration = diffDays * 60 * 24;
} else {
// needs duration in minutes;
diff --git a/js/app.model.js b/js/app.model.js
index bdec790..e8cf4c5 100644
--- a/js/app.model.js
+++ b/js/app.model.js
@@ -78,25 +78,12 @@ var Model = function Model() {
* @param {function} onError error callback
*/
getEventsFromDefaultCalendar: function Model_getEventsFromDefaultCalendar(date, onSuccess, onError) {
- var
- /**
- * @type {Calendar}
- */
- calendar = null,
- /**
- * @type {AttributeRangeFilter}
- */
- filter = null;
-
+ var calendar = null, filter = null;
calendar = this.getCalendar();
- if (date) {
- // events on 'date''
- filter = this.getStartDateFilter(new Date(date));
- } else {
- // all future events
- filter = this.getStartDateFilter(new Date(), true);
- }
+
+ // show all events
+ //filter = this.getStartDateFilter(new Date(), true);
calendar.find(onSuccess, onError, filter);
},
diff --git a/js/app.ui.js b/js/app.ui.js
index 529f778..b5a2faf 100644
--- a/js/app.ui.js
+++ b/js/app.ui.js
@@ -52,15 +52,31 @@ function Ui() {
this.home.init();
this.alarm.init();
- this.new_event.init();
+
+ if (!app.ui.new_event.initialized) {
+ app.ui.new_event.init();
+ }
+
+ $(":jqmData(role='tabbar')").first().delegate( "a", "vmouseup", function ( event ) {
+ $(this).removeClass( $.mobile.activeBtnClass );
+ });
+
+ $("#new_event").on('pagebeforeshow', function () {
+ app.ui.new_event.updateDateFormat();
+ app.ui.new_event.setStartDate();
+ app.ui.new_event.setEndDate();
+ $('#add-event-btn').removeClass('disabled');
+ // workaround for N_SE-43733
+ $(".ui-datefield-selected").removeClass('ui-datefield-selected');
+ $(".ui-popupwindow").hide();
+ });
document.addEventListener('webkitvisibilitychange', function (event) {
- $('input').blur();
$(".ui-popup").popup('close');
- if ($.mobile.activePage.attr('id') !== "new_event") {
- if (document.webkitVisibilityState === 'visible') {
- app.loadEvents();
- app.ui.checkTimeFormat();
+ app.ui.new_event.updateDateFormat();
+ if (document.webkitVisibilityState === 'visible') {
+ app.loadEvents();
+ if ($.mobile.activePage.attr('id') === "new_event") {
if (app.eventId !== 0) {
app.model.isEventExists(app.eventId, null, function () {
$.mobile.changePage('#home');
@@ -70,16 +86,41 @@ function Ui() {
}
});
+ $("input.customDuration").on("input", function(e) {
+ var val = parseInt($(this).val().replace(/[^0-9]*/, ''), 10),
+ max = parseInt($(this).attr("max"), 10),
+ min = parseInt($(this).attr("min"), 10);
+
+ if (isNaN(val)) {
+ this.value = 0;
+ return;
+ }
+
+ val = parseInt($(this).val(), 10)
+ if (val > max){
+ alert('Alarm can not be set above '+ max +' minutes');
+ $(this).val(max);
+ app.ui.alarm.updateDurationLabel();
+ } else if (val < min) {
+ alert('Alarm can not be set below ' + min +
+ ' minute (Off)');
+ $(this).val(min);
+ }
+ });
+
$(window).on('softkeyboardchange', function (e) {
+ app.ui.alarm.selectOption(parseInt($("input.customDuration").val(), 10));
if (e.originalEvent.state === "off") {
$("input:radio").checkboxradio("refresh");
}
});
- document.addEventListener('tizenhwkey', function(e) {
+ window.addEventListener('tizenhwkey', function(e) {
if (e.keyName == "back") {
if ($.mobile.activePage.attr('id') === 'home') {
tizen.application.getCurrentApplication().exit();
+ } else if ($.mobile.activePage.attr('id') === 'new_event') {
+ $.mobile.changePage("#home");
} else {
history.back();
}
@@ -90,25 +131,6 @@ function Ui() {
},
/**
- * Contains method related to time format 12/24h
- * @namespace
- */
- checkTimeFormat: function UI_checkTimeFormat () {
- var date = tizen.time.getDateFormat(true),
- time = tizen.time.getTimeFormat();
- if (time === "h:m:s") {
- //(h:m:s) 24hours format and (ap h:m:s) 12hours format
- $("#demo-date-1, #demo-date-2").datetimepicker("option",
- "format",
- "MMM dd yyyy HH:mm");
- } else {
- $("#demo-date-1, #demo-date-2").datetimepicker("option",
- "format",
- "MMM dd yyyy hh:mm tt");
- }
- },
-
- /**
* Contains methods related to the #home page
* @namespace
*/
@@ -116,6 +138,9 @@ function Ui() {
init: function UI_home_init() {
var app = this.context.app, self = this, alarm = this.context.alarm;
+ $("#demo-date-1, #demo-date-2").datetimepicker();
+ $("#allDay").slider();
+
$('#exit_btn').on('tap', app.exit.bind(app));
$("input:radio").checkboxradio();
alarm.selectOption();
@@ -134,7 +159,7 @@ function Ui() {
duration,
key,
properties = ['summary', 'startDate', 'endDate'];
- app.ui.new_event.dateResetLock(true);
+
app.eventId = eventId;
properties.forEach(function(element){
if (event.hasOwnProperty(element)) {
@@ -144,8 +169,6 @@ function Ui() {
if (field.attr('type') === 'datetime') {
date = self.TZD2Date(event[element]);
field.datetimepicker('value', date);
- field.datetimepicker();
- app.ui.new_event.setSelectAllDay(event.isAllDay);
} else {
field.val(event[element]);
}
@@ -153,7 +176,7 @@ function Ui() {
}
});
- $('#new_event h1').text('Edit Event');
+ $('#new_event h1').text('Edit event');
if (event.alarms.length !== 0) {
duration = app.retrieveTimeDurationInMinutes(event.alarms[0].before);
@@ -165,20 +188,18 @@ function Ui() {
alarm.selectOption(alarm.getValue(duration || 0));
$.mobile.changePage("#new_event");
-
// set select allDay property
app.ui.new_event.setSelectAllDay(event.isAllDay);
+ app.ui.new_event.updateDateFormat();
});
$('#newEventBtn').on('tap', function () {
- app.ui.new_event.dateResetLock(false);
app.eventId = 0;
- $("#demo-date-1, #demo-date-2").datetimepicker();
- $("#demo-date-1, #demo-date-2").datetimepicker(new Date());
- // workaround - if just inietied once agan, datepickers remembers the date
- $('#new_event h1').text('New Event');
+ // workaround - if just initied once again, datepickers remembers the date
+ $('#new_event h1').text('New event');
$('#title').val('');
app.ui.new_event.setSelectAllDay(false);
+ app.ui.new_event.updateDateFormat();
alarm.selectOption();
});
@@ -345,6 +366,8 @@ function Ui() {
* @param {Array} events
*/
onEventSearchSuccess: function UI_home_onEventSearchSuccess(events) {
+ events.reverse();
+
var i = 0, j = 0,
str = "",
event,
@@ -404,6 +427,7 @@ function Ui() {
alarm: {
init: function UI_alarm_init() {
var self = this;
+
$("input.customDuration").on('change', function () {
var tmpChecked,
val = $("input.customDuration").val() || 0;
@@ -416,13 +440,11 @@ function Ui() {
}
});
self.getValue(val);
- app.switchAlarm();
self.updateDurationLabel();
});
$('#new_alarm input:radio').on('change', function () {
$("input.customDuration").val($(this).val());
self.getValue($(this).val());
- app.switchAlarm();
self.updateDurationLabel();
});
},
@@ -462,7 +484,7 @@ function Ui() {
*
* @returns {string} Label
*/
- updateDurationLabel: function () {
+ updateDurationLabel: function (eventAndAlarm) {
var label = parseInt($("input.customDuration").val(), 10);
if (label === -1) {
label = "Off";
@@ -470,7 +492,10 @@ function Ui() {
label += " minutes before";
}
$("label.customDuration span.customDurationSpan").text(label);
- $('#alarm').text(label);
+ if (eventAndAlarm === true) {
+ $('#alarm').text(label);
+ }
+ $("input:radio").checkboxradio("refresh");
return label;
}
},
@@ -480,157 +505,135 @@ function Ui() {
* @namespace
*/
new_event: {
- init: function UI_newEvent_init() {
- var app = this.context.app,
- self = this;
-
- $("#demo-date-1, #demo-date-2").datetimepicker();
- app.ui.checkTimeFormat();
-
- $("#demo-date-1").bind("date-changed", function UI_newEvent_onDateChanged(e, newStartDate) {
- var startOptions = $(this).data('datetimepicker').options,
- that = $(this),
- oldStartDate,
- today = new Date(),
- setter1 = $("#demo-date-1").datetimepicker("value"),
- setter2 = $("#demo-date-2").datetimepicker("value");
-
- if ( setter1 > setter2 ) {
- $("#demo-date-2").datetimepicker("value", newStartDate);
- }
+ initialized: false,
+
+ init: function () {
+ this.assignFields();
+ this.updateDateFormat();
+ this.setStartDate();
+ this.setEndDate();
+ this.addEvents();
+ this.initialized = true;
+ },
- // get the old date
- oldStartDate = startOptions.oldDate;
- startOptions.oldDate = newStartDate;
-
- if (!oldStartDate) {
- console.warn('date-changed handler: old date empty');
- return;
- } else if (newStartDate - today < 0) {
- that.datetimepicker('value', today);
- that.datetimepicker();
- newStartDate = today;
- }
- });
+ addEvents: function () {
+ var self = this;
- $("#demo-date-2").bind("date-changed", function (e, newEndDate) {
- var endOptions = $(this).data('datetimepicker').options,
- that = $(this), f = Math.floor,
- setter1 = $("#demo-date-1").datetimepicker("value"),
- startDate = $("#demo-date-1").data('datetimepicker').options.date;
- if ((f(new Date(newEndDate).getTime()/1000/60)
- - f(new Date(startDate).getTime()/1000/60)) < 0) {
- alert('End date cannot be earlier than initial date');
- setTimeout(function() {
- that.datetimepicker('value', startDate);
- }, 200);
- } else {
- endOptions.oldDate = newEndDate;
- }
- });
+ this.allday.change(this.updateDateFormat.bind(this));
+ this.start.change(this.validStart.bind(this));
+ this.end.change(this.validEnd.bind(this));
- $("select#allDay").bind("change", function () {
- $('.ui-datefield-hour, .ui-datefield-min, .ui-datefield-period, span[data-pat=":"]')
- .toggle();
+ /* old events */
+ $('#add-event-btn').on('tap', this.addEvent.bind(this));
+ $('#add-event-cancel-btn').on('tap', this.cancel.bind(this));
+ //alarm selection confirm
+ $('#add-alarm').on('tap', app.switchAlarm.bind(app));
+ // go to alarm selection
+ $('#add_alarm').on('tap', function (e) {
+ e.preventDefault();
+ $.mobile.changePage('#new_alarm');
});
+ },
- $('#new_event').on('pageshow', function UI_newEvent_onPageShow(event) {
- var startOptions = $("#demo-date-1").data('datetimepicker').options,
- date2 = $("#demo-date-2"),
- tmpDate;
- // get the start date
- tmpDate = new Date(startOptions.date.getTime());
+ validStart: function () {
+ this.setStartDate();
+ if (this.startDate > this.endDate) {
+ this.end.datetimepicker("value", this.startDate);
+ this.setEndDate();
+ }
+ },
- // store it for future use
- startOptions.oldDate = new Date(startOptions.date.getTime());
+ validEnd: function () {
+ if (this.startDate > this.getDateFromPicker(this.end)) {
+ this.setDateValue(this.end, this.endDate)
+ this.showWarning('End date cannot be earlier than initial date');
+ } else {
+ this.setEndDate();
+ }
+ },
- if (self.dateResetLock() !== true) {
- if (typeof date2.datetimepicker === 'function') {
- // set end date
- date2.datetimepicker('value', tmpDate);
- } else {
- console.warn('pageinit: cant set end time');
- }
- }
+ validAll: function () {
+ this.validStart();
+ this.validEnd();
+ },
- $('#add-event-btn').removeClass('disabled');
- // enable OK button
+ showWarning: function (text) {
+ this.popup.children('p').text(text);
+ this.popup.popup('open', {
+ positionTo: "window"
});
+ },
- $('#switch-1').on('changed', app.switchFullDay.bind(app));
-
- $('#add-event-btn').on('tap', this.addEvent.bind(this));
-
- $('#add-event-btn').on('tap', function (e) {
- var setter1 = $("#demo-date-1").datetimepicker("value"),
- today = new Date();
+ assignFields: function () {
+ this.allday = $("#allDay");
+ this.start = $("#demo-date-1");
+ this.end = $("#demo-date-2");
+ this.popup = $("#popup");
+ },
- if ( setter1 > today ) {
- $('#add-event-btn').addClass('disabled');
+ updateDateFormat: function () {
+ var date = tizen.time.getDateFormat(true),
+ time = tizen.time.getTimeFormat();
+ if (this.allday.val() === '1') {
+ this.format = "MMM dd yyyy";
+ this.end.parent().parent().hide();
+ this.end.parent().parent().prev().hide();
+ } else {
+ if (time === "h:m:s") {
+ this.format = "MMM dd yyyy HH:mm";
+ } else {
+ this.format = "MMM dd yyyy hh:mm tt";
}
- $('#add-event-btn').removeClass('disabled');
- });
-
- $('#add-event-cancel-btn').on('tap', this.cancel.bind(this));
+ this.end.parent().parent().show();
+ this.end.parent().parent().prev().show();
+ }
+ this.setDateFormat(this.start);
+ this.setDateFormat(this.end);
+ },
- //alarm selection confirm
- $('#add-alarm').on('tap', app.switchAlarm.bind(app));
+ setDateFormat: function (field) {
+ field.datetimepicker("option", "format", this.format)
+ .datetimepicker();
+ },
- // go to alarm selection
- $('#add_alarm').on('tap', function (e) {
- e.preventDefault();
- self.dateResetLock(true);
- $.mobile.changePage('#new_alarm');
+ setDateValue: function (field, date) {
+ var sp = field.next().find('span').not('.ui-datefield-seperator');
+ field.datetimepicker("value", date);
+ sp.animationComplete(function () {
+ setTimeout(function () {
+ field.datetimepicker("value", date);
+ }, 700);
+ sp.off('animationComplete');
});
+ },
- $('#new_event').on('tap', '[data-role="content"]', function (e) {
- e.stopPropagation();
- });
+ setStartDate: function () {
+ this.startDate = this.getDateFromPicker(this.start);
},
- /**
- * Select an alarm value
- */
- switchAlarm: function Ui_newEvent_switchAlarm(e) {
- this.dateResetLock(false);
- this.context.app.switchAlarm(e);
+ setEndDate: function () {
+ this.endDate = this.getDateFromPicker(this.end);
},
- /**
- * Set reset lock (true - locked, false - unlocked)
- * If no or undefined value given, return the current value
- * @param {bool} value
- * @returns {bool}
- */
- dateResetLock: function Ui_newEvent_dateResetLock(value) {
- if (value === undefined) {
- return $("#demo-date-2").data('resetLock');
- }
- $("#demo-date-2").data('resetLock', value);
- return value;
+ getDateFromPicker: function (field) {
+ return field.data('datetimepicker').options.date;
},
+ /* methods before new event refactor */
+
setSelectAllDay: function (value) {
- var select = $('select#allDay');
- if (value) {
- select[0].selectedIndex = 1;
- $('.ui-datefield-hour, .ui-datefield-min, .ui-datefield-period, span[data-pat=":"]')
- .hide();
- } else {
- select[0].selectedIndex = 0;
- $('.ui-datefield-hour, .ui-datefield-min, .ui-datefield-period, span[data-pat=":"]')
- .show();
- }
- try {
- select.slider("refresh");
- } catch (e){}
+ value = value ? 1 : 0;
+ app.ui.new_event.allday.find("option")
+ .attr('selected', false);
+ app.ui.new_event.allday.find("option[value='" + value + "']")
+ .attr('selected', true);
+ app.ui.new_event.allday.slider("refresh");
},
addEvent: function Ui_newEvent_addEvent(e) {
e.preventDefault();
e.stopPropagation();
var button = $('#add-event-btn');
- this.dateResetLock(false);
if (!button.hasClass('disabled')) {
button.addClass('disabled');
if (app.eventId === 0) {
@@ -649,7 +652,6 @@ function Ui() {
e.preventDefault();
e.stopPropagation();
$.mobile.changePage('#home');
- this.dateResetLock(false);
}
},
diff --git a/templates/alarm.tpl b/templates/alarm.tpl
index 3607626..ce54bf1 100644
--- a/templates/alarm.tpl
+++ b/templates/alarm.tpl
@@ -2,7 +2,7 @@
<div data-role="page" id="new_alarm" data-add-back-btn="true">
<div data-role="header" data-position="fixed">
- <h1>Set Alarm</h1>
+ <h1>Set alarm</h1>
</div><!-- /header -->
<div data-role="content">
diff --git a/templates/home.tpl b/templates/home.tpl
index e92510d..4154616 100644
--- a/templates/home.tpl
+++ b/templates/home.tpl
@@ -1,7 +1,7 @@
<!-- Start of first page: #home -->
<div data-role="page" id="home" data-add-back-btn="false">
<div data-role="header">
- <h1>Event Manager</h1>
+ <h1>Event manager</h1>
</div>
<div data-role="content">
<div id="events_list">
@@ -18,6 +18,5 @@
<li><a href="javascript:void(0)" id="exit_btn">Exit</a></li>
</ul>
</div>
- </div><!-- /footer -->
-
+ </div><!-- /footer -->
</div><!-- /home -->
diff --git a/templates/new_event.tpl b/templates/new_event.tpl
index 43ee648..78c9bef 100644
--- a/templates/new_event.tpl
+++ b/templates/new_event.tpl
@@ -2,7 +2,7 @@
<div data-role="page" id="new_event">
<div data-role="header" data-position="fixed">
- <h1>New Event</h1>
+ <h1>New event</h1>
</div><!-- /header -->
<div data-role="content">
@@ -11,6 +11,15 @@
<label for="title">Title</label>
<div><input type="text" name="summary" id="title" maxlength="9"/></div>
+ <label for="dataAllDay">Type</label>
+ <div id="dataAllDay" data-role="dataAllDay">
+ <span class="allDaySwitcher">
+ <select id="allDay" data-role="slider">
+ <option value="1">All day</option>
+ <option value="0">Period</option>
+ </select>
+ </div>
+
<label for="demo-date-1">Start</label>
<div id="date-1">
<span class="ui-li-text-main">
@@ -30,17 +39,6 @@
<span id="alarm">0 minutes before</span> <a id="add_alarm" data-inline="true" data-role="button">change</a>
</div>
- <div data-role="dataAllDay">
- <span class="allDaySwitcherTitle">
- All day?
- </span>
- <span class="allDaySwitcher">
- <select data-role="slider" id="allDay">
- <option value="0"></option>
- <option value="1"></option>
- </select>
- </span>
- </div>
</fieldset>
</div><!-- /content -->
@@ -54,7 +52,14 @@
</div><!-- /controlbar -->
</div><!-- /footer -->
- <div id="center_info" data-role="popupwindow" data-style="center_info">
+ <div data-role="popup" id="popup">
+ <p></p>
+ <div>
+ <a href="#" data-rel="back" data-role="button">Close</a>
+ </div>
+ </div>
+
+ <div id="center_info" data-role="popup" data-style="center_info">
<div data-role="text"><p>
Pop-up dialog box, a child
window that blocks user inter-