Skip to content

Commit

Permalink
fix(md-datepicker): fix closeOnSelect closing on month/year switching
Browse files Browse the repository at this point in the history
  • Loading branch information
acamilleri committed Jun 28, 2016
1 parent 9608fab commit ed2664d
Show file tree
Hide file tree
Showing 15 changed files with 338 additions and 338 deletions.
40 changes: 20 additions & 20 deletions dist/amd/aurelia-materialize-bridge.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,6 @@ declare module 'aurelia-materialize-bridge' {
export class InstructionFilterValueConverter {
toView(navigationInstructions: any): any;
}
export class MdCard {
mdImage: any;
mdReveal: any;
mdSize: any;
mdTitle: any;
constructor(element: any);
attached(): any;
}
export class MdButton {
disabled: any;
flat: any;
Expand All @@ -140,6 +132,14 @@ declare module 'aurelia-materialize-bridge' {
disabledChanged(newValue: any): any;
flatChanged(newValue: any): any;
}
export class MdCard {
mdImage: any;
mdReveal: any;
mdSize: any;
mdTitle: any;
constructor(element: any);
attached(): any;
}

// @customElement('md-carousel-item')
export class MdCarouselItem {
Expand All @@ -159,6 +159,10 @@ declare module 'aurelia-materialize-bridge' {
attached(): any;
detached(): any;
}
export class MdChip {
mdClose: any;
attached(): any;
}
export class MdCheckbox {
static id: any;
mdChecked: any;
Expand All @@ -171,10 +175,6 @@ declare module 'aurelia-materialize-bridge' {
mdCheckedChanged(newValue: any): any;
mdDisabledChanged(newValue: any): any;
}
export class MdChip {
mdClose: any;
attached(): any;
}
export class MdCollapsible {
constructor(element: any);
attached(): any;
Expand All @@ -200,14 +200,6 @@ declare module 'aurelia-materialize-bridge' {
isSelectedChanged(newValue: any): any;
}

/* eslint-enable */
export class DarkenValueConverter {
toView(value: any, steps: any): any;
}
export class LightenValueConverter {
toView(value: any, steps: any): any;
}

/**
* Adds css classes to a given element only if these classes are not already
* present. Keeps a record of css classes which actually have been added.
Expand Down Expand Up @@ -243,6 +235,14 @@ declare module 'aurelia-materialize-bridge' {
* @param data Addition data to attach to an event
*/
export function fireMaterializeEvent(element: Element, name: string, data?: any): any;

/* eslint-enable */
export class DarkenValueConverter {
toView(value: any, steps: any): any;
}
export class LightenValueConverter {
toView(value: any, steps: any): any;
}
export class MdDatePicker {
container: any;
translation: any;
Expand Down
2 changes: 1 addition & 1 deletion dist/amd/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ define(['exports', 'aurelia-templating', 'aurelia-binding', 'aurelia-task-queue'
};

MdDatePicker.prototype.onSet = function onSet(value) {
if (this.options && this.options.closeOnSelect) {
if (this.options && this.options.closeOnSelect && value.select) {
this.picker.close();
}
};
Expand Down
40 changes: 20 additions & 20 deletions dist/aurelia-materialize-bridge.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,6 @@ declare module 'aurelia-materialize-bridge' {
export class InstructionFilterValueConverter {
toView(navigationInstructions: any): any;
}
export class MdCard {
mdImage: any;
mdReveal: any;
mdSize: any;
mdTitle: any;
constructor(element: any);
attached(): any;
}
export class MdButton {
disabled: any;
flat: any;
Expand All @@ -140,6 +132,14 @@ declare module 'aurelia-materialize-bridge' {
disabledChanged(newValue: any): any;
flatChanged(newValue: any): any;
}
export class MdCard {
mdImage: any;
mdReveal: any;
mdSize: any;
mdTitle: any;
constructor(element: any);
attached(): any;
}

// @customElement('md-carousel-item')
export class MdCarouselItem {
Expand All @@ -159,6 +159,10 @@ declare module 'aurelia-materialize-bridge' {
attached(): any;
detached(): any;
}
export class MdChip {
mdClose: any;
attached(): any;
}
export class MdCheckbox {
static id: any;
mdChecked: any;
Expand All @@ -171,10 +175,6 @@ declare module 'aurelia-materialize-bridge' {
mdCheckedChanged(newValue: any): any;
mdDisabledChanged(newValue: any): any;
}
export class MdChip {
mdClose: any;
attached(): any;
}
export class MdCollapsible {
constructor(element: any);
attached(): any;
Expand All @@ -200,14 +200,6 @@ declare module 'aurelia-materialize-bridge' {
isSelectedChanged(newValue: any): any;
}

/* eslint-enable */
export class DarkenValueConverter {
toView(value: any, steps: any): any;
}
export class LightenValueConverter {
toView(value: any, steps: any): any;
}

/**
* Adds css classes to a given element only if these classes are not already
* present. Keeps a record of css classes which actually have been added.
Expand Down Expand Up @@ -243,6 +235,14 @@ declare module 'aurelia-materialize-bridge' {
* @param data Addition data to attach to an event
*/
export function fireMaterializeEvent(element: Element, name: string, data?: any): any;

/* eslint-enable */
export class DarkenValueConverter {
toView(value: any, steps: any): any;
}
export class LightenValueConverter {
toView(value: any, steps: any): any;
}
export class MdDatePicker {
container: any;
translation: any;
Expand Down
144 changes: 72 additions & 72 deletions dist/aurelia-materialize-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,31 +390,6 @@ export class InstructionFilterValueConverter {
}
}

@customElement('md-card')
@inject(Element)
export class MdCard {
@bindable({
defaultBindingMode: bindingMode.oneTime
}) mdImage = null;
@bindable({
defaultBindingMode: bindingMode.oneTime
}) mdReveal = false;
@bindable({
defaultBindingMode: bindingMode.oneWay
}) mdSize = '';
@bindable({
defaultBindingMode: bindingMode.oneTime
}) mdTitle;
constructor(element) {
this.element = element;
}
attached() {
this.mdReveal = getBooleanFromAttributeValue(this.mdReveal);
}
}
@customAttribute('md-button')
@inject(Element)
export class MdButton {
Expand Down Expand Up @@ -477,6 +452,31 @@ export class MdButton {
}
}

@customElement('md-card')
@inject(Element)
export class MdCard {
@bindable({
defaultBindingMode: bindingMode.oneTime
}) mdImage = null;
@bindable({
defaultBindingMode: bindingMode.oneTime
}) mdReveal = false;
@bindable({
defaultBindingMode: bindingMode.oneWay
}) mdSize = '';
@bindable({
defaultBindingMode: bindingMode.oneTime
}) mdTitle;
constructor(element) {
this.element = element;
}
attached() {
this.mdReveal = getBooleanFromAttributeValue(this.mdReveal);
}
}
// @customElement('md-carousel-item')
@inject(Element)
export class MdCarouselItem {
Expand Down Expand Up @@ -548,6 +548,16 @@ export class MdCharCounter {
}
}
@customElement('md-chip')
@inject(Element)
export class MdChip {
@bindable() mdClose = false;
attached() {
this.mdClose = getBooleanFromAttributeValue(this.mdClose);
}
}
@customElement('md-checkbox')
@inject(Element)
export class MdCheckbox {
Expand Down Expand Up @@ -603,16 +613,6 @@ export class MdCheckbox {
}
}
@customElement('md-chip')
@inject(Element)
export class MdChip {
@bindable() mdClose = false;
attached() {
this.mdClose = getBooleanFromAttributeValue(this.mdClose);
}
}
@customAttribute('md-collapsible')
@bindable({ name: 'accordion', defaultValue: false })
@bindable({ name: 'popout', defaultValue: false })
Expand Down Expand Up @@ -702,42 +702,6 @@ export class MdlListSelector {
}
}
/* eslint-disable */
// http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color-or-rgb-and-blend-colors
function shadeBlendConvert(p, from, to) {
if(typeof(p)!="number"||p<-1||p>1||typeof(from)!="string"||(from[0]!='r'&&from[0]!='#')||(typeof(to)!="string"&&typeof(to)!="undefined"))return null; //ErrorCheck
// if(!this.sbcRip)this.sbcRip=function(d){
let sbcRip=function(d){
var l=d.length,RGB=new Object();
if(l>9){
d=d.split(",");
if(d.length<3||d.length>4)return null;//ErrorCheck
RGB[0]=i(d[0].slice(4)),RGB[1]=i(d[1]),RGB[2]=i(d[2]),RGB[3]=d[3]?parseFloat(d[3]):-1;
}else{
switch(l){case 8:case 6:case 3:case 2:case 1:return null;} //ErrorCheck
if(l<6)d="#"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3]+(l>4?d[4]+""+d[4]:""); //3 digit
d=i(d.slice(1),16),RGB[0]=d>>16&255,RGB[1]=d>>8&255,RGB[2]=d&255,RGB[3]=l==9||l==5?r(((d>>24&255)/255)*10000)/10000:-1;
}
return RGB;}
var i=parseInt,r=Math.round,h=from.length>9,h=typeof(to)=="string"?to.length>9?true:to=="c"?!h:false:h,b=p<0,p=b?p*-1:p,to=to&&to!="c"?to:b?"#000000":"#FFFFFF",f=sbcRip(from),t=sbcRip(to);
if(!f||!t)return null; //ErrorCheck
if(h)return "rgb("+r((t[0]-f[0])*p+f[0])+","+r((t[1]-f[1])*p+f[1])+","+r((t[2]-f[2])*p+f[2])+(f[3]<0&&t[3]<0?")":","+(f[3]>-1&&t[3]>-1?r(((t[3]-f[3])*p+f[3])*10000)/10000:t[3]<0?f[3]:t[3])+")");
else return "#"+(0x100000000+(f[3]>-1&&t[3]>-1?r(((t[3]-f[3])*p+f[3])*255):t[3]>-1?r(t[3]*255):f[3]>-1?r(f[3]*255):255)*0x1000000+r((t[0]-f[0])*p+f[0])*0x10000+r((t[1]-f[1])*p+f[1])*0x100+r((t[2]-f[2])*p+f[2])).toString(16).slice(f[3]>-1||t[3]>-1?1:3);
}
/* eslint-enable */
export class DarkenValueConverter {
toView(value, steps) {
return shadeBlendConvert(-0.3 * parseFloat(steps, 10), value);
}
}
export class LightenValueConverter {
toView(value, steps) {
return shadeBlendConvert(0.3 * parseFloat(steps, 10), value);
}
}
/**
* Adds css classes to a given element only if these classes are not already
* present. Keeps a record of css classes which actually have been added.
Expand Down Expand Up @@ -847,6 +811,42 @@ export function fireMaterializeEvent(element: Element, name: string, data? = {})
return fireEvent(element, `${constants.eventPrefix}${name}`, data);
}

/* eslint-disable */
// http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color-or-rgb-and-blend-colors
function shadeBlendConvert(p, from, to) {
if(typeof(p)!="number"||p<-1||p>1||typeof(from)!="string"||(from[0]!='r'&&from[0]!='#')||(typeof(to)!="string"&&typeof(to)!="undefined"))return null; //ErrorCheck
// if(!this.sbcRip)this.sbcRip=function(d){
let sbcRip=function(d){
var l=d.length,RGB=new Object();
if(l>9){
d=d.split(",");
if(d.length<3||d.length>4)return null;//ErrorCheck
RGB[0]=i(d[0].slice(4)),RGB[1]=i(d[1]),RGB[2]=i(d[2]),RGB[3]=d[3]?parseFloat(d[3]):-1;
}else{
switch(l){case 8:case 6:case 3:case 2:case 1:return null;} //ErrorCheck
if(l<6)d="#"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3]+(l>4?d[4]+""+d[4]:""); //3 digit
d=i(d.slice(1),16),RGB[0]=d>>16&255,RGB[1]=d>>8&255,RGB[2]=d&255,RGB[3]=l==9||l==5?r(((d>>24&255)/255)*10000)/10000:-1;
}
return RGB;}
var i=parseInt,r=Math.round,h=from.length>9,h=typeof(to)=="string"?to.length>9?true:to=="c"?!h:false:h,b=p<0,p=b?p*-1:p,to=to&&to!="c"?to:b?"#000000":"#FFFFFF",f=sbcRip(from),t=sbcRip(to);
if(!f||!t)return null; //ErrorCheck
if(h)return "rgb("+r((t[0]-f[0])*p+f[0])+","+r((t[1]-f[1])*p+f[1])+","+r((t[2]-f[2])*p+f[2])+(f[3]<0&&t[3]<0?")":","+(f[3]>-1&&t[3]>-1?r(((t[3]-f[3])*p+f[3])*10000)/10000:t[3]<0?f[3]:t[3])+")");
else return "#"+(0x100000000+(f[3]>-1&&t[3]>-1?r(((t[3]-f[3])*p+f[3])*255):t[3]>-1?r(t[3]*255):f[3]>-1?r(f[3]*255):255)*0x1000000+r((t[0]-f[0])*p+f[0])*0x10000+r((t[1]-f[1])*p+f[1])*0x100+r((t[2]-f[2])*p+f[2])).toString(16).slice(f[3]>-1||t[3]>-1?1:3);
}
/* eslint-enable */

export class DarkenValueConverter {
toView(value, steps) {
return shadeBlendConvert(-0.3 * parseFloat(steps, 10), value);
}
}

export class LightenValueConverter {
toView(value, steps) {
return shadeBlendConvert(0.3 * parseFloat(steps, 10), value);
}
}

@inject(Element, TaskQueue)
@customAttribute('md-datepicker')
export class MdDatePicker {
Expand Down Expand Up @@ -973,7 +973,7 @@ export class MdDatePicker {

onSet(value) {
//handle this ourselves since Dogfalo removed this functionality from the original plugin
if (this.options && this.options.closeOnSelect) {
if (this.options && this.options.closeOnSelect && value.select) {
this.picker.close();
}
// this.value = new Date(value.select);
Expand Down
Loading

0 comments on commit ed2664d

Please sign in to comment.