Skip to content

Commit

Permalink
Fixed v-alignment issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ayanonly1 committed Dec 30, 2016
1 parent 663d02a commit b5c137c
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 77 deletions.
25 changes: 13 additions & 12 deletions dist/fc-calendar-es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
padding: '0',
margin: 0
},
minHeight = 200,
minHeight = 300,
minWidth = 300,
PX = 'px',
SP = ' ',
Expand All @@ -477,13 +477,13 @@ daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
SLASH = '/',
vAlignMultiplier = {
top: 0,
middle: 0.5,
bottom: 1
middle: -0.5,
bottom: -1
},
hAlignMultiplier = {
left: 0,
center: 0.5,
right: 1
center: -0.5,
right: -1
},

// get id for container
Expand Down Expand Up @@ -981,19 +981,14 @@ var Calendar = function () {
style.width = temp + PX;
positioningChanged = true;
}
if (config.vAlignment && (temp = config.vAlignment.toLowerCase()) && hAlignMultiplier[temp] !== UNDEFINED) {
if (config.vAlignment && (temp = config.vAlignment.toLowerCase()) && vAlignMultiplier[temp] !== UNDEFINED) {
info.vAlignment = temp;
positioningChanged = true;
}
if (config.hAlignment && (temp = config.hAlignment.toLowerCase()) && vAlignMultiplier[temp] !== UNDEFINED) {
if (config.hAlignment && (temp = config.hAlignment.toLowerCase()) && hAlignMultiplier[temp] !== UNDEFINED) {
info.hAlignment = temp;
positioningChanged = true;
}
if (positioningChanged) {
style.left = info.posX + info.width * (hAlignMultiplier[info.hAlignment] || 0) + PX;
style.top = info.posY + info.height * (vAlignMultiplier[info.vAlignment] || 0) + PX;
setStyle(graphic.container, style);
}

// set events on date, month and year change
if (userEvents) {
Expand Down Expand Up @@ -1068,6 +1063,12 @@ var Calendar = function () {
}
// set calendar to the desired date
doRepaint && displayMonth(calendar);
if (positioningChanged) {
style.left = info.posX + info.width * (hAlignMultiplier[info.hAlignment] || 0) + PX;
info.height = graphic.container && graphic.container.offsetHeight || minHeight;
style.top = info.posY + info.height * (vAlignMultiplier[info.vAlignment] || 0) + PX;
setStyle(graphic.container, style);
}
}
// call show function show calendar

Expand Down
4 changes: 2 additions & 2 deletions dist/fc-calendar-es5.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ function updateLink(linkElement, obj) {
"use strict";
Object.defineProperty(exports,'__esModule',{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError('Cannot call a class as a function')}__webpack_require__(0);var idNo=0,UNDEFINED=void 0,// basic calendar configaration
daysInMonth=[31,28,31,30,31,30,31,31,30,31,30,31],weekLabel=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],monthLabel=['January','February','March','April','May','June','July','August','September','October','November','December'],classNames={container:'fc-cal-container',header:'fc-cal-header',month:'fc-cal-month-header',year:'fc-cal-year-header',monthName:'fc-cal-month',yearName:'fc-cal-year',nav:'fc-cal-nav',navPrev:'fc-cal-nav-prev',navNext:'fc-cal-nav-next',navInactive:'fc-cal-nav-inactive',navMonth:'fc-cal-nav-month',navYear:'fc-cal-nav-year',subHeader:'fc-cal-sub-header',days:'fc-cal-day',indexedDays:'fc-cal-day-',// Index will be added at the end
body:'fc-cal-body',date:'fc-cal-date',dateLI:'fc-cal-date-li',selectedDate:'fc-cal-date-selected',disabledDate:'fc-cal-date-disabled',enabledDate:'fc-cal-date-enabled',highlightedDate:'fc-cal-date-highlight',dayCol:'fc-cal-day-col'},ulPadZeroStyle={padding:'0',margin:0},minHeight=200,minWidth=300,PX='px',SP=' ',BLANK='',SPACE='&nbsp;',DASH='-',SLASH='/',vAlignMultiplier={top:0,middle:0.5,bottom:1},hAlignMultiplier={left:0,center:0.5,right:1},// get id for container
body:'fc-cal-body',date:'fc-cal-date',dateLI:'fc-cal-date-li',selectedDate:'fc-cal-date-selected',disabledDate:'fc-cal-date-disabled',enabledDate:'fc-cal-date-enabled',highlightedDate:'fc-cal-date-highlight',dayCol:'fc-cal-day-col'},ulPadZeroStyle={padding:'0',margin:0},minHeight=300,minWidth=300,PX='px',SP=' ',BLANK='',SPACE='&nbsp;',DASH='-',SLASH='/',vAlignMultiplier={top:0,middle:-0.5,bottom:-1},hAlignMultiplier={left:0,center:-0.5,right:-1},// get id for container
getuid=function getuid(){return'fc_calendar-'+idNo++},// check if the year is leap year or not
checkLeapYear=function checkLeapYear(a){return 0==a%4&&0!=a%100||0==a%400},// apply custom style to the container
setStyle=function setStyle(a,b){if(b&&a&&a.style)for(var _c in b)b.hasOwnProperty(_c)&&(a.style[_c]=b[_c])},remoVeClassName=function remoVeClassName(a,b){var c=b&&b.className;c&&a&&(b.className=c.replace(new RegExp('(?:^|\\s*)'+a.trim()+'(?:\\s*|$)'),' '))},removeClassInChilds=function removeClassInChilds(a,b){var c=void 0,d=void 0,e=void 0,f=void 0,g=void 0;if(a&&a.getElementsByClassName)for(g=b.trim().split(SP),e=0,f=g.length;e<f;e+=1)for(b=g[e],c=a.getElementsByClassName(b),d=c.length-1;0<=d;d--)remoVeClassName(b,c[d])},// this function will update the calendar
Expand All @@ -443,7 +443,7 @@ validateActiveStart=function validateActiveStart(a,b){var c=a.day,d=a.month,e=a.
validateActiveEnd=function validateActiveEnd(a,b){var c=a.day,d=a.month,e=a.year;return!(b&&(b.year<e||b.year===e&&(b.month<d||b.month===d&&b.day<c)))};// calendar constructor
var Calendar=function(){function Calendar(a){_classCallCheck(this,Calendar);var b=this,c=new Date,d={day:c.getDate(),month:c.getMonth()+1,year:c.getFullYear()};b.graphic={parentElement:document.body,dateElements:[],dayElements:[]},b.style={position:'absolute',top:'0px',left:'0px',width:minWidth+PX,// height: minHeight + PX,
overflow:'hidden'},b.id=getuid(),b.events={},b.info={selectedDate:d,active:{month:d.month,year:d.year},weekLabel:[].concat(weekLabel),monthLabel:[].concat(monthLabel),weekStartingDay:0,posX:0,posY:0,height:minHeight,width:minWidth,vAlignment:'top',hAlignment:'left',highlightClasses:[]},init(b),b.configure(a,!0)}// configure calendar
return _createClass(Calendar,[{key:'configure',value:function configure(a,b){var c=this,d=c.graphic,e=c.events,f=c.info,g=c.style,h=a&&a.events,k=void 0,m=void 0,n=!1;a&&(a.container&&(k=document.getElementById(a.container))&&(d.parentElement=k,k.appendChild(d.container)),a.style&&a.style.position&&(g.position=a.style.position,setStyle(d.container,g)),!isNaN(m=+a.posX)&&(f.posX=m,n=!0),!isNaN(m=+a.posY)&&(f.posY=m,n=!0),!isNaN(m=+a.width)&&m>minWidth&&(f.width=m,g.width=m+PX,n=!0),a.vAlignment&&(m=a.vAlignment.toLowerCase())&&hAlignMultiplier[m]!==UNDEFINED&&(f.vAlignment=m,n=!0),a.hAlignment&&(m=a.hAlignment.toLowerCase())&&vAlignMultiplier[m]!==UNDEFINED&&(f.hAlignment=m,n=!0),n&&(g.left=f.posX+f.width*(hAlignMultiplier[f.hAlignment]||0)+PX,g.top=f.posY+f.height*(vAlignMultiplier[f.vAlignment]||0)+PX,setStyle(d.container,g)),h&&('function'==typeof h.onDateChange&&(e.onDateChange=h.onDateChange),'function'==typeof h.onYearChange&&(e.onYearChange=h.onYearChange),'function'==typeof h.onMonthChange&&(e.onMonthChange=h.onMonthChange)),a.highlight?(f.highlight=a.highlight,b=!0):null===a.highlight&&(delete f.highlight,b=!0),(m=a.selectedDate)&&!isNaN(Date.parse(m.month+SLASH+m.day+SLASH+m.year))&&(f.selectedDate=a.selectedDate,f.active.month=f.selectedDate.month,f.active.year=f.selectedDate.year,b=!0),a.showInactiveMonths!==UNDEFINED&&(f.showInactiveMonths=!!a.showInactiveMonths),a.active&&(m={month:a.active.month||f.active.month,year:a.active.year||f.active.year},(f.active.month!==m.month||f.active.year!==m.year)&&(f.showInactiveMonths||validateActiveStart(m,f.rangeStart)&&validateActiveEnd(m,f.rangeEnd))&&(f.active.month=m.month,f.active.year=m.year,b=!0)),a.monthLabel&&12===a.monthLabel.length&&(f.monthLabel=a.monthLabel,b=!0),a.weekLabel&&7===a.weekLabel.length&&(f.weekLabel=a.weekLabel,disPlayDays(c)),a.weekStart!==UNDEFINED&&f.weekStartingDay!==a.weekStart&&(f.weekStartingDay=a.weekStart,disPlayDays(c)),a.rangeStart&&validateActiveStart(f.selectedDate,a.rangeStart)?(f.rangeStart=a.rangeStart,b=!0):null===a.rangeStart&&(delete f.rangeStart,b=!0),a.rangeEnd&&validateActiveEnd(f.selectedDate,a.rangeEnd)?(f.rangeEnd=a.rangeEnd,b=!0):null===a.rangeEnd&&(delete f.rangeEnd,b=!0),b&&displayMonth(c))}// call show function show calendar
return _createClass(Calendar,[{key:'configure',value:function configure(a,b){var c=this,d=c.graphic,e=c.events,f=c.info,g=c.style,h=a&&a.events,k=void 0,m=void 0,n=!1;a&&(a.container&&(k=document.getElementById(a.container))&&(d.parentElement=k,k.appendChild(d.container)),a.style&&a.style.position&&(g.position=a.style.position,setStyle(d.container,g)),!isNaN(m=+a.posX)&&(f.posX=m,n=!0),!isNaN(m=+a.posY)&&(f.posY=m,n=!0),!isNaN(m=+a.width)&&m>minWidth&&(f.width=m,g.width=m+PX,n=!0),a.vAlignment&&(m=a.vAlignment.toLowerCase())&&vAlignMultiplier[m]!==UNDEFINED&&(f.vAlignment=m,n=!0),a.hAlignment&&(m=a.hAlignment.toLowerCase())&&hAlignMultiplier[m]!==UNDEFINED&&(f.hAlignment=m,n=!0),h&&('function'==typeof h.onDateChange&&(e.onDateChange=h.onDateChange),'function'==typeof h.onYearChange&&(e.onYearChange=h.onYearChange),'function'==typeof h.onMonthChange&&(e.onMonthChange=h.onMonthChange)),a.highlight?(f.highlight=a.highlight,b=!0):null===a.highlight&&(delete f.highlight,b=!0),(m=a.selectedDate)&&!isNaN(Date.parse(m.month+SLASH+m.day+SLASH+m.year))&&(f.selectedDate=a.selectedDate,f.active.month=f.selectedDate.month,f.active.year=f.selectedDate.year,b=!0),a.showInactiveMonths!==UNDEFINED&&(f.showInactiveMonths=!!a.showInactiveMonths),a.active&&(m={month:a.active.month||f.active.month,year:a.active.year||f.active.year},(f.active.month!==m.month||f.active.year!==m.year)&&(f.showInactiveMonths||validateActiveStart(m,f.rangeStart)&&validateActiveEnd(m,f.rangeEnd))&&(f.active.month=m.month,f.active.year=m.year,b=!0)),a.monthLabel&&12===a.monthLabel.length&&(f.monthLabel=a.monthLabel,b=!0),a.weekLabel&&7===a.weekLabel.length&&(f.weekLabel=a.weekLabel,disPlayDays(c)),a.weekStart!==UNDEFINED&&f.weekStartingDay!==a.weekStart&&(f.weekStartingDay=a.weekStart,disPlayDays(c)),a.rangeStart&&validateActiveStart(f.selectedDate,a.rangeStart)?(f.rangeStart=a.rangeStart,b=!0):null===a.rangeStart&&(delete f.rangeStart,b=!0),a.rangeEnd&&validateActiveEnd(f.selectedDate,a.rangeEnd)?(f.rangeEnd=a.rangeEnd,b=!0):null===a.rangeEnd&&(delete f.rangeEnd,b=!0),b&&displayMonth(c),n&&(g.left=f.posX+f.width*(hAlignMultiplier[f.hAlignment]||0)+PX,f.height=d.container&&d.container.offsetHeight||minHeight,g.top=f.posY+f.height*(vAlignMultiplier[f.vAlignment]||0)+PX,setStyle(d.container,g)))}// call show function show calendar
},{key:'show',value:function show(){var a=this,b=a.graphic.container;b.style.visibility='visible',b.style.opacity='1'}// call hide function to hide calendar
},{key:'hide',value:function hide(){var a=this,b=a.graphic.container;b.style.visibility='hidden',b.style.opacity='0'}// returns the current or selected date
},{key:'getDate',value:function getDate(){return this.info.selectedDate}// add custom funcion on click
Expand Down
25 changes: 13 additions & 12 deletions dist/fc-calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ const UNDEFINED = undefined,
padding: '0',
margin: 0
},
minHeight = 200,
minHeight = 300,
minWidth = 300,
PX = 'px',
SP = ' ',
Expand All @@ -468,13 +468,13 @@ const UNDEFINED = undefined,
SLASH = '/',
vAlignMultiplier = {
top: 0,
middle: 0.5,
bottom: 1
middle: -0.5,
bottom: -1
},
hAlignMultiplier = {
left: 0,
center: 0.5,
right: 1
center: -0.5,
right: -1
},
// get id for container
getuid = () => `fc_calendar-${idNo++}`,
Expand Down Expand Up @@ -916,19 +916,14 @@ class Calendar {
style.width = temp + PX;
positioningChanged = true;
}
if (config.vAlignment && (temp = config.vAlignment.toLowerCase()) && (hAlignMultiplier[temp] !== UNDEFINED)) {
if (config.vAlignment && (temp = config.vAlignment.toLowerCase()) && (vAlignMultiplier[temp] !== UNDEFINED)) {
info.vAlignment = temp;
positioningChanged = true;
}
if (config.hAlignment && (temp = config.hAlignment.toLowerCase()) && (vAlignMultiplier[temp] !== UNDEFINED)) {
if (config.hAlignment && (temp = config.hAlignment.toLowerCase()) && (hAlignMultiplier[temp] !== UNDEFINED)) {
info.hAlignment = temp;
positioningChanged = true;
}
if (positioningChanged) {
style.left = (info.posX + (info.width * (hAlignMultiplier[info.hAlignment] || 0))) + PX;
style.top = (info.posY + (info.height * (vAlignMultiplier[info.vAlignment] || 0))) + PX;
setStyle(graphic.container, style);
}

// set events on date, month and year change
if (userEvents) {
Expand Down Expand Up @@ -1003,6 +998,12 @@ class Calendar {
}
// set calendar to the desired date
doRepaint && displayMonth(calendar);
if (positioningChanged) {
style.left = (info.posX + (info.width * (hAlignMultiplier[info.hAlignment] || 0))) + PX;
info.height = (graphic.container && graphic.container.offsetHeight) || minHeight;
style.top = (info.posY + (info.height * (vAlignMultiplier[info.vAlignment] || 0))) + PX;
setStyle(graphic.container, style);
}
}
// call show function show calendar
show () {
Expand Down
Loading

0 comments on commit b5c137c

Please sign in to comment.