Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
342fcd1
Added support for marking as today. Added the date property so the d…
SpikedKira Jan 13, 2016
4582b5a
changed the init method from .on to short notation. Added support for…
SpikedKira Jan 13, 2016
99ce56b
support for day knowing which date it is
SpikedKira Jan 13, 2016
0f10a5e
removed unnecessary class. added two properties for testing.
SpikedKira Jan 13, 2016
fb510c4
Merge branch 'v0.11.0' of https://github.com/softlayer/sl-ember-compo…
SpikedKira Jan 13, 2016
eea0801
Modified demo console log event to be more verbose. Changed some cale…
SpikedKira Jan 14, 2016
8f7748a
**CALENDAR**
SpikedKira Jan 19, 2016
ea0eba2
Commented out bootstrap-datepicker css include.
SpikedKira Jan 20, 2016
32b6904
Merge branch 'v0.11.0' of https://github.com/softlayer/sl-ember-compo…
SpikedKira Jan 20, 2016
cdd4358
First run at styling for new calendar system.
SpikedKira Jan 22, 2016
672f1c7
Commiting before opimizations.
SpikedKira Jan 25, 2016
109a54e
Clean up and optimization.
SpikedKira Jan 25, 2016
c3e362d
First pass at test cleanup.
SpikedKira Jan 26, 2016
fbad2b6
Test cleanup.
SpikedKira Jan 27, 2016
3608872
lint clean up
SpikedKira Jan 28, 2016
8f161a3
Added integration test for sl-calendar-day.
SpikedKira Jan 29, 2016
a861ea1
Removed several unnecessary tests. Stubbed out needed tests. Fixed …
SpikedKira Jan 30, 2016
a90dd2f
Various tests and test cleanup.
SpikedKira Feb 2, 2016
8421d33
Additional tests and functionality.
SpikedKira Feb 3, 2016
88a46de
updated docblocks and documentation.
SpikedKira Feb 3, 2016
54f3154
lint cleanup
SpikedKira Feb 3, 2016
d23d635
Last push and clean up.
SpikedKira Feb 4, 2016
e55ff25
removed documentation on bootstrap-datepicker
SpikedKira Feb 4, 2016
c5614e3
removed note about bootstrap-datepicker from readme
SpikedKira Feb 4, 2016
954b323
Updated the demo examples
SpikedKira Feb 4, 2016
06217db
jshint fixes
SpikedKira Feb 5, 2016
0745008
small fixes
SpikedKira May 5, 2016
b69a1c0
Merge branch 'master' of https://github.com/softlayer/sl-ember-compon…
SpikedKira May 5, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ Apply a loading indicator to an element. See the [Loading Indicator section](#l
All of this functionality is provided through a combination of leveraging the best-of-breed of other component offerings as well as our own implementations when the existing offerings were deficient. Existing offerings that were leveraged include:

* [Twitter Bootstrap](http://getbootstrap.com/)
* [Bootstrap-Datepicker](http://bootstrap-datepicker.readthedocs.org/en/release/#)
* [Highcharts](http://www.highcharts.com/)
* [Select2](http://ivaynberg.github.io/select2/)
* [typeahead.js](https://twitter.github.io/typeahead.js/)
Expand All @@ -112,9 +111,6 @@ All of this functionality is provided through a combination of leveraging the be
While this library is MIT licensed not all of the third-party component libraries are. Specifically, Highcharts is only free for non-commercial use and requires a license for any other use. See
[this FAQ page](http://shop.highsoft.com/faq/non-commercial#what-is-commercial-website) for more information.

Other libraries that are not MIT licensed, though it should not pose a problem, are:

* [Bootstrap-Datepicker](https://github.com/eternicode/bootstrap-datepicker/blob/release/LICENSE)



Expand Down
153 changes: 136 additions & 17 deletions addon/components/sl-calendar-day.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Ember from 'ember';
import layout from '../templates/components/sl-calendar-day';

/**
* @module
Expand All @@ -13,59 +12,101 @@ export default Ember.Component.extend({
// -------------------------------------------------------------------------
// Attributes

/** @type {String[]} */
attributeBindings: [
'ariaSelected:aria-selected',
'tabIndex'
],

/** @type {String[]} */
classNameBindings: [
'active',
'active:selected',
'new',
'old'
'old',
'isToday:today',
'restricted:disabled',
'hasEvents'
],

/** @type {String[]} */
classNames: [
'day'
],

/** @type {Object} */
layout,

/** @type {String} */
tagName: 'td',

// -------------------------------------------------------------------------
// Actions

/** @type {Object} */
actions: {},

// -------------------------------------------------------------------------
// Events

/**
* @function
* Send the click event up to sl-calendar
*
* @returns {undefined}
*/
click() {
const content = this.get( 'content' );
const events = this.get( 'events' );
const date = this.get( 'date' );

if ( content ) {
this.sendAction( 'action', content );
}
this.sendAction( 'action', date, events );
},

/**
* Focus this date on insert.
* Needed for keyboard navigation across months.
*
* @returns {undefined}
*/
didInsertElement() {
this._super( ...arguments );

this.focus();
},

// -------------------------------------------------------------------------
// Properties

/**
* Whether the calendar day this cell represents is actively selected day
* Whether the calendar day this cell represents is actively selected
*
* @type {Boolean}
*/
active: false,

/**
* The various data representing the day (created and passed in through
* sl-calendar)
* The role attribute to apply
*
* @private
* @type {String}
*/
ariaRole: 'gridcell',

/**
* The specific moment date that this cell represents
*
* @type {?moment}
*/
date: null,

/**
* An array of events bound to the date this cell represents
*
* @type {?Object}
* @type {Object[]}
*/
content: null,
events: [],

/**
* Whether this day is currently focused by keyboard navigation
*
* @type {Boolean}
*/
focused: false,

/**
* Whether the calendar day this cell represents is part of the next month
Expand All @@ -81,12 +122,90 @@ export default Ember.Component.extend({
*
* @type {Boolean}
*/
old: false
old: false,

/**
* Whether the calendar day this cell represents is restricted by parent
* calendar's selectConstraint
*
* @type {Boolean}
*/
restricted: false,

// -------------------------------------------------------------------------
// Observers

/**
* When tabIndex changes, check if we should apply focus.
*
* @function
* @returns {undefined}
*/
focus: Ember.observer(
'tabIndex',
function() {
if ( this.get( 'focused' ) ) {
Ember.run.scheduleOnce( 'afterRender', this, function() {
this.$().get( 0 ).focus();
});
}
}
),

// -------------------------------------------------------------------------
// Methods

/**
* Sets aria-selected attribute when active state is true.
*
* @function
* @returns {?Boolean}
*/
ariaSelected: Ember.computed(
'active',
function() {
const active = this.get( 'active' );
return active ? active : null;
}
),

/**
* Whether there are events bound to this date.
*
* @function
* @returns {Boolean}
*/
hasEvents: Ember.computed(
'events',
function() {
return !Ember.isEmpty( this.get( 'events' ) );
}
),

/**
* Calculate if this day is today's date.
*
* @function
* @returns {Boolean}
*/
isToday: Ember.computed(
'date',
function() {
return window.moment().isSame( this.get( 'date' ), 'day' );
}
),

/**
* Sets tabIndex attribute based on focused property.
*
* @function
* @returns {Number}
*/
tabIndex: Ember.computed(
'focused',
function() {
return this.get( 'focused' ) ? 0 : -1;
}
)

});
41 changes: 10 additions & 31 deletions addon/components/sl-calendar-month.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Ember from 'ember';
import layout from '../templates/components/sl-calendar-month';

/**
* @module
Expand All @@ -15,14 +14,16 @@ export default Ember.Component.extend({

/** @type {String[]} */
classNameBindings: [
'active'
'active:selected'
],

/** @type {Object} */
layout,
/** @type {String[]} */
classNames: [
'month'
],

/** @type {String} */
tagName: 'span',
tagName: 'td',

// -------------------------------------------------------------------------
// Actions
Expand All @@ -31,7 +32,8 @@ export default Ember.Component.extend({
// Events

/**
* @function
* Send the click event up to sl-calendar
*
* @returns {undefined}
*/
click() {
Expand All @@ -42,46 +44,23 @@ export default Ember.Component.extend({
// Properties

/**
* Whether the month that this component represents is selected by the
* overall calendar component
* Whether the month that this component represents is actively selected
*
* @type {Boolean}
*/
active: false,

/**
* The locale string to use for moment dates
*
* @type {String}
*/
locale: 'en',

/**
* The number of the month (1-12)
*
* @type {?Number}
*/
month: null,
month: null

// -------------------------------------------------------------------------
// Observers

// -------------------------------------------------------------------------
// Methods

/**
* The short string name of the represented month
*
* @function
* @returns {String}
*/
shortName: Ember.computed(
'month',
function() {
return window.moment([ 1, this.get( 'month' ) - 1 ])
.locale( this.get( 'locale' ) )
.format( 'MMM' );
}
)

});
15 changes: 10 additions & 5 deletions addon/components/sl-calendar-year.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@ export default Ember.Component.extend({

/** @type {String[]} */
classNameBindings: [
'active',
'active:selected',
'new',
'old'
],

/** @type {String[]} */
classNames: [
'year'
],

/** @type {Object} */
layout,

/** @type {String} */
tagName: 'span',
tagName: 'td',

// -------------------------------------------------------------------------
// Actions
Expand All @@ -33,7 +38,8 @@ export default Ember.Component.extend({
// Events

/**
* @function
* Send the click event up to sl-calendar
*
* @returns {undefined}
*/
click() {
Expand All @@ -44,8 +50,7 @@ export default Ember.Component.extend({
// Properties

/**
* Whether the year this component represents is the currently active year
* of the parent calendar component
* Whether the year this component represents is actively selected
*
* @type {Boolean}
*/
Expand Down
Loading