-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from BrightspaceUI/jstefaniuk/hybridize
Jstefaniuk/hybridize
- Loading branch information
Showing
18 changed files
with
609 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf8 | ||
end_of_line = lf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[{package.json,.travis.yml}] | ||
indent_style = space | ||
indent_size = 2 | ||
root = true | ||
|
||
[*] | ||
charset = utf8 | ||
end_of_line = lf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[{*.json,*.yml}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "brightspace/polymer-config", | ||
"globals": { | ||
"d2lIntl": true, | ||
"fastdom": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
bower_components | ||
bower_components-1.x | ||
bower-1.x.json | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
language: node_js | ||
node_js: node | ||
before_script: | ||
- npm install -g polymer-cli | ||
- polymer install --variants | ||
node_js: 9 | ||
script: | ||
- npm run test:lint | ||
- npm run lint | ||
- polymer test --skip-plugin local | ||
env: | ||
global: | ||
- SAUCE_USERNAME: Desire2Learn | ||
- secure: R9nrpeyuMcZTHnBcVAuMn+q/Fp9ti9K31tYlkBFhXtJc+rM/TYERiN195SRgbk2Gy6fK4exUXIWZtJW+cxuRwDoBIcSGWRwHWmkDc5k13kLaW/BcdWAfI/yFEkAwzrO1AfQOsB1qdbfYle9pP724BebfQHlqAxH9zNWlQdek+Gr02WKKXMWWhl2bH4P2QbNQItD5X6+xQTbnbmZnUECap9mQXbCzPVNU2MwvPRLuYuJmjcNBdC39iGfZNBY/+N1Ix3y6yFa41VD773KiqTZhVOM1TvVJz/lb+Dm25qSZdKixC0987eDY5zHiCigHIjJxo1bDwJz4xJ/DsnIo+hk0LvrOPvoxBp6tFNhGQgIUkwk0Lz6FsNQcH5l5QLh1ROq4isNx9BVEOHb+W1PdFzFlvoKf9+WS/ysSw19B/GFhtLJGTmGkaxnEBxhJ+DyiVnV5APV+cE4AEA4yB/Vz7cKOrBlLbZdZFb8x9DtHamKvyoZh7RVun6BHSmMNAlPD83oxF9HZ7GjhKeC1EpvIdSrZAh6NKgklt0slwSumWU6VfJeoT4STNfiP39DzHHtWqscwTTAG9Rp4UFxDRsz6jCWaPf7AfYe85fXp+EwBRC0RYikQz43IFnKoGpz69qNh4vap6HNPQmM2uctZeWbhtDSq2FzN5fbheSV5QlFeq88O4S8= |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @alogan519 @d2l-pbrown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
<link rel="import" href="../polymer/polymer.html"> | ||
<link rel="import" href="../d2l-fastdom-import/fastdom.html"> | ||
<link rel="import" href="localize-behavior.html"> | ||
|
||
<script> | ||
window.D2L = window.D2L || {}; | ||
window.D2L.PolymerBehaviors = window.D2L.PolymerBehaviors || {}; | ||
window.D2L.PolymerBehaviors.DatePicker = window.D2L.PolymerBehaviors.DatePicker || {}; | ||
|
||
/** @polymerBehavior D2L.PolymerBehaviors.DatePicker.DatePickerBehavior */ | ||
D2L.PolymerBehaviors.DatePicker.DatePickerBehaviorImpl = { | ||
properties: { | ||
_target: { | ||
type: Object | ||
}, | ||
_descriptionId: { | ||
type: String | ||
}, | ||
placeholder: { | ||
type: String | ||
}, | ||
min: { | ||
type: String | ||
}, | ||
max: { | ||
type: String | ||
}, | ||
label: { | ||
type: String | ||
}, | ||
hideLabel: { | ||
type: Boolean, | ||
value: false, | ||
reflectToAttribute: true | ||
}, | ||
description:{ | ||
type: String | ||
}, | ||
locale: { | ||
type: String, | ||
value: 'en' | ||
}, | ||
firstDayOfWeek: { | ||
type: Number, | ||
value: 0 | ||
}, | ||
value: { | ||
type: String, | ||
reflectToAttribute: true, | ||
notify: true | ||
}, | ||
customOverlayStyle: { | ||
type: Boolean, | ||
reflectToAttribute: true, | ||
value: false | ||
} | ||
}, | ||
|
||
observers: [ | ||
'_updateDatePickeri18n( locale, localize, firstDayOfWeek )', | ||
'_localeChanged( locale )' | ||
], | ||
|
||
ready: function() { | ||
this._descriptionId = D2L.Id.getUniqueId(); | ||
this._handleValueChanged = this._handleValueChanged.bind(this); | ||
|
||
if (this._isPolymer2()) { | ||
this._setUpChangeEventListenerPolymer2(); | ||
} | ||
}, | ||
|
||
attached: function() { | ||
var buttons = document.getElementsByClassName('vaadin-date-picker-overlay paper-button-0'); | ||
|
||
fastdom.mutate(function() { | ||
for (var i = 0; i < buttons.length; i++) { | ||
buttons[i].style.fontFamily = 'inherit'; | ||
} | ||
}); | ||
}, | ||
|
||
detached: function() { | ||
if (this._isPolymer2()) { | ||
this.removeEventListener('value-changed', this._handleValueChanged); | ||
} | ||
this._changeListener = null; | ||
}, | ||
|
||
_setUpChangeEventListenerPolymer2: function() { | ||
// on-value-changed got removed for the Polymer2 version of vaadin-date-picker, | ||
// so for Polymer2 we'll set our own event | ||
this.addEventListener('value-changed', this._handleValueChanged); | ||
}, | ||
|
||
_isPolymer2: function() { | ||
return !!Polymer.Element; | ||
}, | ||
|
||
_handleValueChangedPolymer1: function(e) { | ||
// using the `value-changed` listener sometimes sends 2 events in the | ||
// Polymer 1 vaadin-date-picker when in shadyDom, so this function listens to | ||
// on-value-changed from the vaadin-date-picker (removed in Polymer 2) | ||
if (this._isPolymer2()) { | ||
return; | ||
} | ||
this._handleValueChanged(e); | ||
}, | ||
|
||
_handleValueChanged: function(e) { | ||
this.dispatchEvent(new CustomEvent('d2l-date-picker-value-changed', { | ||
detail: e.detail, | ||
bubbles: true | ||
})); | ||
}, | ||
|
||
_handleTap: function() { | ||
var datepicker = this.$$('vaadin-date-picker-light'); | ||
if (!datepicker.opened) { | ||
datepicker._focusOverlayOnOpen = true; | ||
} | ||
}, | ||
|
||
onEnter: function(e) { | ||
var datepicker = this.$$('vaadin-date-picker-light'); | ||
if (!datepicker.opened) { | ||
// A better solution is to add a boolean to the 3rd party open function | ||
datepicker._focusOverlayOnOpen = true; | ||
datepicker.open(); | ||
e.detail.keyboardEvent.preventDefault(); | ||
e.detail.keyboardEvent.stopPropagation(); | ||
} | ||
|
||
}, | ||
|
||
onUpDown: function(e) { | ||
var datepicker = this.$$('vaadin-date-picker-light'); | ||
if (!datepicker.opened) { | ||
e.detail.keyboardEvent.preventDefault(); | ||
e.detail.keyboardEvent.stopPropagation(); | ||
} | ||
}, | ||
|
||
_handleFocus: function() { | ||
// in shady DOM the input's "focus" event does not bubble, | ||
// so no need to fire it | ||
if (!Polymer.Settings.useShadow) { | ||
this.dispatchEvent(new CustomEvent( | ||
'focus', | ||
{ bubbles: true, composed: false } | ||
)); | ||
} | ||
}, | ||
|
||
_localeChanged: function(locale) { | ||
this.language = locale; | ||
}, | ||
|
||
_updateDatePickeri18n: function() { | ||
var locale = d2lIntl.LocaleProvider(this.locale); | ||
|
||
var datePicker = this.$$('vaadin-date-picker-light'); | ||
var localeOverrides = { | ||
monthNames: locale.date.calendar.months.long, | ||
weekdays: locale.date.calendar.days.long, | ||
weekdaysShort: locale.date.calendar.days.short, | ||
firstDayOfWeek: this.firstDayOfWeek ? this.firstDayOfWeek : locale.date.calendar.firstDayOfWeek, | ||
today: this.localize('today'), | ||
cancel: this.localize('cancel'), | ||
formatDate: function(date) { | ||
return this.formatDate(date); | ||
}.bind(this), | ||
parseDate: function(dateString) { | ||
try { | ||
return this.parseDate(dateString); | ||
} catch (exception) { | ||
return null; | ||
} | ||
}.bind(this) | ||
}; | ||
var datePickerLocale = this._merge(datePicker.i18n, localeOverrides); | ||
datePicker.i18n = {}; // reassign to have Polymer refresh | ||
datePicker.i18n = datePickerLocale; | ||
}, | ||
|
||
_merge: function(obj1, obj2) { | ||
if (obj2 === undefined || obj2 === null || typeof(obj2) !== 'object') { | ||
return obj1; | ||
} | ||
Object.keys(obj2).forEach(function(i) { | ||
if (obj1.hasOwnProperty(i)) { | ||
if (typeof(obj2[i]) === 'object' && typeof(obj1[i]) === 'object') { | ||
this._merge(obj1[i], obj2[i]); | ||
} else { | ||
obj1[i] = obj2[i]; | ||
} | ||
} | ||
}.bind(this)); | ||
return obj1; | ||
} | ||
}; | ||
|
||
/** @polymerBehavior D2L.PolymerBehaviors.DatePicker.DatePickerBehavior */ | ||
D2L.PolymerBehaviors.DatePicker.DatePickerBehavior = [ | ||
D2L.PolymerBehaviors.DatePicker.LocalizeBehavior, | ||
D2L.PolymerBehaviors.DatePicker.DatePickerBehaviorImpl | ||
]; | ||
</script> |
Oops, something went wrong.