Birth Calculator
HTML
<div class="birth-calc"></div>
CSS
.ac-birthcalc-dates-container{
padding:20px;
border-radius:10px;
background:lightgreen;
}
JavaScript
;(function ( $, window, document, undefined ) {
var pluginName = 'acBirthCalc';
var defaults = {
itemClass: 'item',
itemWidth: 200
};
// Constructor
function acBirthCalc(element, options)
{
this.element = element;
this.options = $.extend({}, defaults, options);
this._defaults = defaults;
this._name = pluginName;
this.init();
}
acBirthCalc.prototype.init = function()
{
console.log('init');
this.createResultBlock();
this.createDateSelectors();
};
acBirthCalc.prototype.createDateSelectors = function()
{
console.log('createDateSelectors');
var date = new Date();
this.datesContainer = $('<div />').prependTo(this.element);
$(this.datesContainer).addClass('ac-birthcalc-dates-container');
this.createDaySelector();
this.createMonthSelector();
this.createYearSelector();
this.createCalcButton();
};
acBirthCalc.prototype.createYearSelector = function()
{
console.log('createYearSelector');
var date = new Date();
var selYears = $('<select />').appendTo(this.datesContainer);
$(selYears).addClass('ac-birthcalc-year');
for (var curYear = date.getFullYear(), i = curYear - 1, lastYear = curYear + 50; i < lastYear; i++) {
var option = $('<option />').appendTo(selYears);
option.attr('value', i).text(i);
}
};
acBirthCalc.prototype.createMonthSelector = function()
{
console.log('createMonthSelector');
var arMonthNames = [
'Январь',
'Февраль',
'Март',
'Апрель',
'Май',
'Июнь',
'Июль',
'Август',
'Сентябрь',
'Октябрь',
'Ноябрь',
'Декабрь'
];
var select = $('<select />').appendTo(this.datesContainer);
$(select).addClass('ac-birthcalc-month');
for (var i = 0; i < 12; i++) {
var option = $('<option />').appendTo(select);
...