/*jslint nomen: true*/
-/*global $, GraphSchedule, confirm, range, history, setTimeout */
+/*global $, GraphSchedule, range, history, setTimeout */
function UI() {
"use strict";
}
});
};
+ UI.prototype.popup = function (text, callback) {
+ var i, popup = $("#popup"),
+ buttons = {'Close': function () { $("#popup").popup('close') }};
+ // to hide default button give {'Close': false} in callback
+
+ for (i in callback) {
+ if (callback.hasOwnProperty(i)) {
+ buttons[i] = callback[i];
+ }
+ }
+
+ $(".ui-popup-button-bg", popup).empty();
+ for (i in buttons) {
+ if (buttons.hasOwnProperty(i)) {
+ if (buttons[i]) {
+ $('<a/>')
+ .text(i)
+ .attr({'data-role': 'button', 'data-inline': 'true'})
+ .bind('tap', buttons[i])
+ .appendTo($(".ui-popup-button-bg", popup));
+ }
+ }
+ }
+ $(".text", popup).text(text);
+
+ popup.trigger("create");
+ popup.popup('open', {positionTo: 'window'});
+ };
+
UI.prototype.clearTabbars = function () {
$('[data-role = "tabbar"] li > a').removeClass('ui-focus, ui-btn-active');
};
$('#availableTime').listview().listview('refresh');
$('#availableTime :jqmData(name=edit)').on('tap', function (e) {
if (self.app.config.trainingEnabled) {
- alert('You should stop the training first');
+ self.popup('You should stop the training first');
} else {
e.preventDefault();
e.stopPropagation();
});
$('#availableTime :jqmData(name=disable)').on('tap', function (e) {
if (self.app.config.trainingEnabled) {
- alert('You should stop the training first');
+ self.popup('You should stop the training first');
} else {
e.stopPropagation();
self.app.disableTimeRange($(this).data('val'));
var value = $(this).data('val');
e.stopPropagation();
if (self.app.config.trainingEnabled) {
- alert('You should stop the training first');
+ self.popup('You should stop the training first');
return;
}
- setTimeout(function () {
- if (confirm('Are you sure?')) {
+ self.popup('Are you sure?', {
+ 'Delete': function () {
self.app.deleteTimeRange(value);
+ $("#popup").popup('close');
}
- }, 20);
+ });
});
};
var self = this;
// bind events;
+ $("#popup").popup();
+
$('#one .ui-btn-back').on('tap', this.app.exit.bind(this.app));
$('#ok').on('tap', self.app.ok.bind(self.app));
$('#addTimeRange').on('tap', function (e) {
if (self.app.config.trainingEnabled) {
- alert('You should stop the training first');
+ self.popup('You should stop the training first');
} else {
self.editTimeRange(-1, e);
}
});
$('#customExercises').on('pageinit', function (page, options) {
- $('#btnNewExercise').on('tap', function (e) {
+ $('#btnNewExercise').on('vmousedown', function (e) {
e.preventDefault();
e.stopPropagation();
if ($(this).data('disabled') !== true) {