Skip to content

Commit

Permalink
change class structure
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasJang committed Jan 26, 2016
1 parent d419f8c commit d89230a
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 84 deletions.
4 changes: 3 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
> calendar
## setConfig()
`setConfig([options])`
`setConfig([options])`

**Easy Way - without setConfig**
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ exactly the path.
```html
<html>
<head>
<link rel="stylesheet" type="text/css" href="bower_components/bootstrap-ax5calendar/dist/ax5calendar.css" />
<link rel="stylesheet" type="text/css"
href="bower_components/bootstrap-ax5calendar/dist/ax5calendar.css" />
<script type="text/javascript" src="bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="bower_components/ax5core/dist/ax5core.min.js"></script>
<script type="text/javascript" src="bower_components/bootstrap-ax5calendar/dist/ax5calendar.min.js"></script>
<script type="text/javascript"
src="bower_components/bootstrap-ax5calendar/dist/ax5calendar.min.js"></script>
</head>
<body>
....
Expand All @@ -45,8 +47,7 @@ exactly the path.

### Basic Usages
```js
var myCalendar = new ax5.ui.calendar();
myCalendar.setConfig({
var myCalendar = new ax5.ui.calendar({
target: document.getElementById("calendar-target"),
displayDate: (new Date()),
onClick: function () {
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-ax5calendar",
"version": "0.2.0",
"version": "0.3.0",
"authors": [
"ThomasJ <[email protected]>"
],
Expand Down
71 changes: 37 additions & 34 deletions dist/ax5calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,42 @@

//== UI Class
var axClass = function () {
if (_SUPER_) _SUPER_.call(this); // 부모호출

var
self = this,
cfg,
aDay = 1000 * 60 * 60 * 24,
selectableCount = 1
;

// 클래스 생성자
this.main = (function () {
if (_SUPER_) _SUPER_.call(this); // 부모호출
this.config = {
clickEventName: "click",
theme: 'default',
mode: 'day', // day|month|year,
dateFormat: 'yyyy-mm-dd',
displayDate: (new Date()),
animateTime: 250,
dimensions: {
controlHeight: '40px',
controlButtonWidth: '40px',
itemPadding: 2
},
lang: {
yearHeading: "Choose the year",
monthHeading: "Choose the month",
year: "%s",
month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
day: "%s"
},
multipleSelect: false
};
}).apply(this, arguments);


this.target = null;
this.selection = [];
cfg = this.config;

this.printedDay = {
start: "", end: ""
};
this.config = {
clickEventName: "click",
theme: 'default',
mode: 'day', // day|month|year,
dateFormat: 'yyyy-mm-dd',
displayDate: (new Date()),
animateTime: 250,
dimensions: {
controlHeight: '40px',
controlButtonWidth: '40px',
itemPadding: 2
},
lang: {
yearHeading: "Choose the year",
monthHeading: "Choose the month",
year: "%s",
month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
day: "%s"
},
multipleSelect: false
};
cfg = this.config;

/**
* Preferences of calendar UI
Expand All @@ -74,8 +70,7 @@
//== class body start
this.init = function () {
// after setConfig();
if (!cfg.target)
{
if (!cfg.target) {
console.log(ax5.info.getError("ax5calendar", "401", "setConfig"));
}
this.target = jQuery(cfg.target);
Expand Down Expand Up @@ -624,7 +619,7 @@
selectableCount = (cfg.multipleSelect) ? (U.isNumber(cfg.multipleSelect)) ? cfg.multipleSelect : 2 : 1;
this.selection = selection.splice(0, selectableCount);
this.selection.forEach(function (d) {
self.$["body"].find('[data-calendar-item-date="' + U.date(d, {"return": cfg.dateFormat}) + '"]').addClass("selected");
self.$["body"].find('[data-calendar-item-date="' + U.date(d, {"return": cfg.dateFormat}) + '"]').addClass("selected-day");
});

return this;
Expand All @@ -636,12 +631,20 @@
this.getSelection = function () {
return this.selection;
};

// 클래스 생성자
this.main = (function () {
if(arguments && U.isObject(arguments[0])) {
this.setConfig(arguments[0]);
}
}).apply(this, arguments);
};
//== UI Class



//== ui class 공통 처리 구문
if (U.isFunction(_SUPER_)) axClass.prototype = new _SUPER_(); // 상속
root.calendar = axClass; // ax5.ui에 연결
//== ui class 공통 처리 구문

})(ax5.ui, ax5.ui.root);
2 changes: 1 addition & 1 deletion dist/ax5calendar.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-ax5calendar",
"version": "0.2.0",
"version": "0.3.0",
"description": "A calendar plugin that works with Bootstrap & jQuery",
"license": "MIT",
"repository": {
Expand Down
71 changes: 37 additions & 34 deletions src/ax5calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,42 @@

//== UI Class
var axClass = function () {
if (_SUPER_) _SUPER_.call(this); // 부모호출

var
self = this,
cfg,
aDay = 1000 * 60 * 60 * 24,
selectableCount = 1
;

// 클래스 생성자
this.main = (function () {
if (_SUPER_) _SUPER_.call(this); // 부모호출
this.config = {
clickEventName: "click",
theme: 'default',
mode: 'day', // day|month|year,
dateFormat: 'yyyy-mm-dd',
displayDate: (new Date()),
animateTime: 250,
dimensions: {
controlHeight: '40px',
controlButtonWidth: '40px',
itemPadding: 2
},
lang: {
yearHeading: "Choose the year",
monthHeading: "Choose the month",
year: "%s",
month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
day: "%s"
},
multipleSelect: false
};
}).apply(this, arguments);


this.target = null;
this.selection = [];
cfg = this.config;

this.printedDay = {
start: "", end: ""
};
this.config = {
clickEventName: "click",
theme: 'default',
mode: 'day', // day|month|year,
dateFormat: 'yyyy-mm-dd',
displayDate: (new Date()),
animateTime: 250,
dimensions: {
controlHeight: '40px',
controlButtonWidth: '40px',
itemPadding: 2
},
lang: {
yearHeading: "Choose the year",
monthHeading: "Choose the month",
year: "%s",
month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
day: "%s"
},
multipleSelect: false
};
cfg = this.config;

/**
* Preferences of calendar UI
Expand All @@ -74,8 +70,7 @@
//== class body start
this.init = function () {
// after setConfig();
if (!cfg.target)
{
if (!cfg.target) {
console.log(ax5.info.getError("ax5calendar", "401", "setConfig"));
}
this.target = jQuery(cfg.target);
Expand Down Expand Up @@ -624,7 +619,7 @@
selectableCount = (cfg.multipleSelect) ? (U.isNumber(cfg.multipleSelect)) ? cfg.multipleSelect : 2 : 1;
this.selection = selection.splice(0, selectableCount);
this.selection.forEach(function (d) {
self.$["body"].find('[data-calendar-item-date="' + U.date(d, {"return": cfg.dateFormat}) + '"]').addClass("selected");
self.$["body"].find('[data-calendar-item-date="' + U.date(d, {"return": cfg.dateFormat}) + '"]').addClass("selected-day");
});

return this;
Expand All @@ -636,12 +631,20 @@
this.getSelection = function () {
return this.selection;
};

// 클래스 생성자
this.main = (function () {
if(arguments && U.isObject(arguments[0])) {
this.setConfig(arguments[0]);
}
}).apply(this, arguments);
};
//== UI Class



//== ui class 공통 처리 구문
if (U.isFunction(_SUPER_)) axClass.prototype = new _SUPER_(); // 상속
root.calendar = axClass; // ax5.ui에 연결
//== ui class 공통 처리 구문

})(ax5.ui, ax5.ui.root);
15 changes: 7 additions & 8 deletions test/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>ㅔ목
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" type="text/css" href="../dist/ax5calendar.css"/>
Expand Down Expand Up @@ -35,8 +35,7 @@
{label: "토"}
];

var myCalendar = new ax5.ui.calendar();
myCalendar.setConfig({
var myCalendar = new ax5.ui.calendar({
control: {
left: 'P',
yearTmpl: '%s',
Expand All @@ -47,15 +46,15 @@

/*
dimensions: {
itemPadding: 2,
height: 250
itemPadding: 2,
height: 250
},
*/
/*
lang: {
year: "%s",
month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
day: "%s"
year: "%s",
month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
day: "%s"
},
*/

Expand Down

0 comments on commit d89230a

Please sign in to comment.