Skip to content

Commit

Permalink
upgrade the new builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Atanas Atanasov committed Nov 25, 2018
1 parent 21a5268 commit 23b95e0
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 40 deletions.
77 changes: 58 additions & 19 deletions dist/combined/js/gijgo.js
Original file line number Diff line number Diff line change
Expand Up @@ -14359,6 +14359,38 @@ gj.datepicker.config = {
*/
footer: false,

/** If set to true, show datepicker on input focus.
* @type Boolean
* @default true
* @example True <!-- datepicker -->
* <input id="datepicker" width="312" />
* <script>
* $('#datepicker').datepicker({ showOnFocus: true, showRightIcon: false });
* </script>
* @example False <!-- datepicker -->
* <input id="datepicker" width="312" />
* <script>
* $('#datepicker').datepicker({ showOnFocus: false });
* </script>
*/
showOnFocus: true,

/** If set to true, show datepicker icon on the right side of the input.
* @type Boolean
* @default true
* @example False <!-- datepicker -->
* <input id="datepicker" width="312" />
* <script>
* $('#datepicker').datepicker({ showOnFocus: true, showRightIcon: false });
* </script>
* @example True <!-- datepicker -->
* <input id="datepicker" width="312" />
* <script>
* $('#datepicker').datepicker({ showRightIcon: true });
* </script>
*/
showRightIcon: true,

style: {
modal: 'gj-modal',
wrapper: 'gj-datepicker gj-datepicker-md gj-unselectable',
Expand Down Expand Up @@ -14421,15 +14453,6 @@ gj.datepicker.methods = {
var $calendar, $rightIcon,
$wrapper = $datepicker.parent('div[role="wrapper"]');

if (data.uiLibrary === 'bootstrap') {
$rightIcon = $('<span class="input-group-addon">' + data.icons.rightIcon + '</span>');
} else if (data.uiLibrary === 'bootstrap4') {
$rightIcon = $('<span class="input-group-append"><button class="btn btn-outline-secondary border-left-0" type="button">' + data.icons.rightIcon + '</button></span>');
} else {
$rightIcon = $(data.icons.rightIcon);
}

$rightIcon.attr('role', 'right-icon');
if ($wrapper.length === 0) {
$wrapper = $('<div role="wrapper" />').addClass(data.style.wrapper); // The css class needs to be added before the wrapping, otherwise doesn't work.
$datepicker.wrap($wrapper);
Expand Down Expand Up @@ -14460,15 +14483,31 @@ gj.datepicker.methods = {
}
}

$rightIcon.on('click', function (e) {
var $calendar = $('body').find('[role="calendar"][guid="' + $datepicker.attr('data-guid') + '"]');
if ($calendar.is(':visible')) {
gj.datepicker.methods.close($datepicker);
if (data.showRightIcon) {
if (data.uiLibrary === 'bootstrap') {
$rightIcon = $('<span class="input-group-addon">' + data.icons.rightIcon + '</span>');
} else if (data.uiLibrary === 'bootstrap4') {
$rightIcon = $('<span class="input-group-append"><button class="btn btn-outline-secondary border-left-0" type="button">' + data.icons.rightIcon + '</button></span>');
} else {
gj.datepicker.methods.open($datepicker, data);
$rightIcon = $(data.icons.rightIcon);
}
});
$wrapper.append($rightIcon);
$rightIcon.attr('role', 'right-icon');
$rightIcon.on('click', function (e) {
var $calendar = $('body').find('[role="calendar"][guid="' + $datepicker.attr('data-guid') + '"]');
if ($calendar.is(':visible')) {
gj.datepicker.methods.close($datepicker);
} else {
gj.datepicker.methods.open($datepicker, data);
}
});
$wrapper.append($rightIcon);
}

if (data.showOnFocus) {
$datepicker.on('focus', function () {
gj.datepicker.methods.open($datepicker, data);
});
}

$calendar = gj.datepicker.methods.createCalendar($datepicker, data);

Expand All @@ -14480,12 +14519,12 @@ gj.datepicker.methods = {
});
$calendar.mousedown(function () {
clearTimeout($datepicker.timeout);
$datepicker.focus();
document.activeElement !== $datepicker[0] && $datepicker.focus();
return false;
});
$calendar.on('click', function () {
clearTimeout($datepicker.timeout);
$datepicker.focus();
document.activeElement !== $datepicker[0] && $datepicker.focus();
});
}

Expand Down Expand Up @@ -15063,7 +15102,7 @@ gj.datepicker.methods = {
gj.core.center($calendar);
} else {
gj.core.setChildPosition($datepicker[0], $calendar[0]);
$datepicker.focus();
document.activeElement !== $datepicker[0] && $datepicker.focus();
}
clearTimeout($datepicker.timeout);
gj.datepicker.events.open($datepicker);
Expand Down
2 changes: 1 addition & 1 deletion dist/combined/js/gijgo.min.js

Large diffs are not rendered by default.

49 changes: 30 additions & 19 deletions dist/modular/js/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ gj.datepicker.config = {

/** If set to true, add footer with ok and cancel buttons to the datepicker. */ footer: false,

/** If set to true, show datepicker on input focus. */ showOnFocus: true,

/** If set to true, show datepicker icon on the right side of the input. */ showRightIcon: true,

style: {
modal: 'gj-modal',
wrapper: 'gj-datepicker gj-datepicker-md gj-unselectable',
Expand Down Expand Up @@ -123,15 +127,6 @@ gj.datepicker.methods = {
var $calendar, $rightIcon,
$wrapper = $datepicker.parent('div[role="wrapper"]');

if (data.uiLibrary === 'bootstrap') {
$rightIcon = $('<span class="input-group-addon">' + data.icons.rightIcon + '</span>');
} else if (data.uiLibrary === 'bootstrap4') {
$rightIcon = $('<span class="input-group-append"><button class="btn btn-outline-secondary border-left-0" type="button">' + data.icons.rightIcon + '</button></span>');
} else {
$rightIcon = $(data.icons.rightIcon);
}

$rightIcon.attr('role', 'right-icon');
if ($wrapper.length === 0) {
$wrapper = $('<div role="wrapper" />').addClass(data.style.wrapper); // The css class needs to be added before the wrapping, otherwise doesn't work.
$datepicker.wrap($wrapper);
Expand Down Expand Up @@ -162,15 +157,31 @@ gj.datepicker.methods = {
}
}

$rightIcon.on('click', function (e) {
var $calendar = $('body').find('[role="calendar"][guid="' + $datepicker.attr('data-guid') + '"]');
if ($calendar.is(':visible')) {
gj.datepicker.methods.close($datepicker);
if (data.showRightIcon) {
if (data.uiLibrary === 'bootstrap') {
$rightIcon = $('<span class="input-group-addon">' + data.icons.rightIcon + '</span>');
} else if (data.uiLibrary === 'bootstrap4') {
$rightIcon = $('<span class="input-group-append"><button class="btn btn-outline-secondary border-left-0" type="button">' + data.icons.rightIcon + '</button></span>');
} else {
gj.datepicker.methods.open($datepicker, data);
$rightIcon = $(data.icons.rightIcon);
}
});
$wrapper.append($rightIcon);
$rightIcon.attr('role', 'right-icon');
$rightIcon.on('click', function (e) {
var $calendar = $('body').find('[role="calendar"][guid="' + $datepicker.attr('data-guid') + '"]');
if ($calendar.is(':visible')) {
gj.datepicker.methods.close($datepicker);
} else {
gj.datepicker.methods.open($datepicker, data);
}
});
$wrapper.append($rightIcon);
}

if (data.showOnFocus) {
$datepicker.on('focus', function () {
gj.datepicker.methods.open($datepicker, data);
});
}

$calendar = gj.datepicker.methods.createCalendar($datepicker, data);

Expand All @@ -182,12 +193,12 @@ gj.datepicker.methods = {
});
$calendar.mousedown(function () {
clearTimeout($datepicker.timeout);
$datepicker.focus();
document.activeElement !== $datepicker[0] && $datepicker.focus();
return false;
});
$calendar.on('click', function () {
clearTimeout($datepicker.timeout);
$datepicker.focus();
document.activeElement !== $datepicker[0] && $datepicker.focus();
});
}

Expand Down Expand Up @@ -765,7 +776,7 @@ gj.datepicker.methods = {
gj.core.center($calendar);
} else {
gj.core.setChildPosition($datepicker[0], $calendar[0]);
$datepicker.focus();
document.activeElement !== $datepicker[0] && $datepicker.focus();
}
clearTimeout($datepicker.timeout);
gj.datepicker.events.open($datepicker);
Expand Down
Loading

0 comments on commit 23b95e0

Please sign in to comment.