Skip to content

Commit

Permalink
ax5calendar 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasJang committed Feb 1, 2016
1 parent 0ed9e54 commit f301f23
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 57 deletions.
11 changes: 7 additions & 4 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ Type: `Array|Object`
selectable: ['2016-01-01', '2016-01-02']
// Date array
selectable: [new Date(2016, 0, 1), new Date(2016, 0, 2)]
// range
selectable: { range: [{from: '2016-01-01', to: '2016-01-02'}] }
selectable: { range: [{from: new Date(2016, 0, 1), to: new Date(2016, 0, 2)}] }
// Object
selectable: {from: '2016-01-01', to: '2016-01-02'}
selectable: {from: new Date(2016, 0, 1), to: new Date(2016, 0, 2)}
selectable: { '2016-01-01': true, '2016-01-02': true }
```


Expand Down Expand Up @@ -230,7 +232,8 @@ Set the date / year / month that can be selected from the `Calendar`.
```js
myCalendar.setSelectable(['2016-01-01', ...]);
myCalendar.setSelectable([new Date(), ...]);
myCalendar.setSelectable({from: '2016-01-01', to: '2016-01-10'});
myCalendar.setSelectable({from: new Date(), to: new Date()});
myCalendar.setSelectable({ range: [{from: '2016-01-01', to: '2016-01-10'}] });
myCalendar.setSelectable({ range: [{from: new Date(), to: new Date()}] });
myCalendar.setSelectable({ '2016-01-01': true, '2016-01-02': true });
```

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.5.1",
"version": "0.6.0",
"authors": [
"ThomasJ <[email protected]>"
],
Expand Down
86 changes: 61 additions & 25 deletions dist/ax5calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
po.push('</tr>');
po.push('</thead>');
po.push('<tbody>');

loopDate = tableStartDate;
i = 0;
while (i < 6)
Expand Down Expand Up @@ -736,44 +737,79 @@
return this.selection;
};

this.setSelectable = function (selectable, isPrint) {
// collect selectableMap
if (cfg.selectable = selectable) {
var
_seltb = cfg.selectable;
this.selectableMap = {}; // clear selectableMap

if (U.isArray(_seltb)) {
_seltb.forEach(function (n) {
this.setSelectable = (function () {
this.selectableMap = {};
var processor = {
'arr': function (v, map) {
map = {};
if(!U.isArray(v)) return map;
v.forEach(function (n) {
if (U.isDate(n))
n = U.date(n, {'return': cfg.dateFormat});
self.selectableMap[n] = true;
map[n] = true;
});
}
else if (U.isObject(_seltb)) {
if (_seltb["from"] && _seltb["to"]) {
if (U.isDateFormat(_seltb["from"]) && U.isDateFormat(_seltb["to"])) {
for (var d = U.date(_seltb["from"]); d <= U.date(_seltb["to"]); d.setDate(d.getDate() + 1)) {
self.selectableMap[U.date(d, {"return": cfg.dateFormat})] = true;
return map;
},
'obj': function (v, map) {
map = {};
if(U.isArray(v)) return map;
if(v.range) return map;
for (var k in v) {
map[k] = v[k];
}
return map;
},
'range': function (v, map) {
map = {};
if(U.isArray(v)) return map;
if(!v.range) return map;

v.range.forEach(function (n) {
if (U.isDateFormat(n.from) && U.isDateFormat(n.to)) {
for (var d = U.date(n.from); d <= U.date(n.to); d.setDate(d.getDate() + 1)) {
map[U.date(d, {"return": cfg.dateFormat})] = true;
}
}
else {
for (var i = _seltb["from"]; i <= _seltb["to"]; i++) {
self.selectableMap[i] = true;
for (var i = n.from; i <= n.to; i++) {
map[i] = true;
}
}
});

return map;
}
};

return function (selectable, isPrint) {

var
key,
result = {}
;

if (cfg.selectable = selectable) {
if (U.isArray(selectable)) {
result = processor.arr(selectable);
}
else if(!_seltb["from"] && !_seltb["to"]) {
for (var k in _seltb) {
self.selectableMap[k] = _seltb[k];
else {
for (key in processor) {
if (selectable[key]) {
result = processor[key](selectable);
break;
}
}
if(Object.keys(result).length === 0){
result = processor.obj(selectable);
}
}
}
}

// 변경내용 적용하여 출력
if(isPrint !== false) this.changeMode();
};
this.selectableMap = result;
// 변경내용 적용하여 출력
if (isPrint !== false) this.changeMode();
};
})();

// 클래스 생성자
this.main = (function () {
Expand Down
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.5.1",
"version": "0.6.0",
"description": "A calendar plugin that works with Bootstrap & jQuery",
"license": "MIT",
"repository": {
Expand Down
86 changes: 61 additions & 25 deletions src/ax5calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
po.push('</tr>');
po.push('</thead>');
po.push('<tbody>');

loopDate = tableStartDate;
i = 0;
while (i < 6)
Expand Down Expand Up @@ -736,44 +737,79 @@
return this.selection;
};

this.setSelectable = function (selectable, isPrint) {
// collect selectableMap
if (cfg.selectable = selectable) {
var
_seltb = cfg.selectable;
this.selectableMap = {}; // clear selectableMap

if (U.isArray(_seltb)) {
_seltb.forEach(function (n) {
this.setSelectable = (function () {
this.selectableMap = {};
var processor = {
'arr': function (v, map) {
map = {};
if(!U.isArray(v)) return map;
v.forEach(function (n) {
if (U.isDate(n))
n = U.date(n, {'return': cfg.dateFormat});
self.selectableMap[n] = true;
map[n] = true;
});
}
else if (U.isObject(_seltb)) {
if (_seltb["from"] && _seltb["to"]) {
if (U.isDateFormat(_seltb["from"]) && U.isDateFormat(_seltb["to"])) {
for (var d = U.date(_seltb["from"]); d <= U.date(_seltb["to"]); d.setDate(d.getDate() + 1)) {
self.selectableMap[U.date(d, {"return": cfg.dateFormat})] = true;
return map;
},
'obj': function (v, map) {
map = {};
if(U.isArray(v)) return map;
if(v.range) return map;
for (var k in v) {
map[k] = v[k];
}
return map;
},
'range': function (v, map) {
map = {};
if(U.isArray(v)) return map;
if(!v.range) return map;

v.range.forEach(function (n) {
if (U.isDateFormat(n.from) && U.isDateFormat(n.to)) {
for (var d = U.date(n.from); d <= U.date(n.to); d.setDate(d.getDate() + 1)) {
map[U.date(d, {"return": cfg.dateFormat})] = true;
}
}
else {
for (var i = _seltb["from"]; i <= _seltb["to"]; i++) {
self.selectableMap[i] = true;
for (var i = n.from; i <= n.to; i++) {
map[i] = true;
}
}
});

return map;
}
};

return function (selectable, isPrint) {

var
key,
result = {}
;

if (cfg.selectable = selectable) {
if (U.isArray(selectable)) {
result = processor.arr(selectable);
}
else if(!_seltb["from"] && !_seltb["to"]) {
for (var k in _seltb) {
self.selectableMap[k] = _seltb[k];
else {
for (key in processor) {
if (selectable[key]) {
result = processor[key](selectable);
break;
}
}
if(Object.keys(result).length === 0){
result = processor.obj(selectable);
}
}
}
}

// 변경내용 적용하여 출력
if(isPrint !== false) this.changeMode();
};
this.selectableMap = result;
// 변경내용 적용하여 출력
if (isPrint !== false) this.changeMode();
};
})();

// 클래스 생성자
this.main = (function () {
Expand Down

0 comments on commit f301f23

Please sign in to comment.