Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
63
gaia/apps/calendar/js/views/view_selector.js
Executable file
63
gaia/apps/calendar/js/views/view_selector.js
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
define(function(require, exports, module) {
|
||||
'use strict';
|
||||
|
||||
var View = require('view');
|
||||
var core = require('core');
|
||||
var nextTick = require('common/next_tick');
|
||||
var timeObserver = require('time_observer');
|
||||
|
||||
function ViewSelector(opts) {
|
||||
View.call(this, opts);
|
||||
this._showTodayDate = this._showTodayDate.bind(this);
|
||||
}
|
||||
module.exports = ViewSelector;
|
||||
|
||||
ViewSelector.prototype = {
|
||||
__proto__: View.prototype,
|
||||
|
||||
selectors: {
|
||||
element: '#view-selector'
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this._showTodayDate();
|
||||
this.delegate(this.element, 'click', 'a', this);
|
||||
timeObserver.on('day', this._showTodayDate);
|
||||
},
|
||||
|
||||
handleEvent: function(event, target) {
|
||||
if (target.matches('[role="tab"]')) {
|
||||
this._toggleActiveTabOnClick(event);
|
||||
} else {
|
||||
this._moveToTodayOnClick(event);
|
||||
}
|
||||
},
|
||||
|
||||
_moveToTodayOnClick: function(event) {
|
||||
var date = new Date();
|
||||
core.timeController.move(date);
|
||||
core.timeController.selectedDay = date;
|
||||
|
||||
event.preventDefault();
|
||||
},
|
||||
|
||||
// FIXME: this should be handled by the router (Bug 1021445)
|
||||
// Handle aria-selected attribute for tabs.
|
||||
_toggleActiveTabOnClick: function(event) {
|
||||
var tabs = this.element.querySelectorAll('[role="tab"]');
|
||||
Array.from(tabs).forEach(tab => {
|
||||
if (tab !== event.target) {
|
||||
tab.setAttribute('aria-selected', false);
|
||||
return;
|
||||
}
|
||||
nextTick(() => tab.setAttribute('aria-selected', true));
|
||||
});
|
||||
},
|
||||
|
||||
_showTodayDate: function() {
|
||||
var icon = this.element.querySelector('.icon-calendar-today');
|
||||
icon.innerHTML = (new Date()).getDate();
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue