Skip to content

Rebase and flatpickr #1412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions assets/admin.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
import './styles/admin.scss';
import 'eonasdan-bootstrap-datetimepicker';
import 'typeahead.js';
import Bloodhound from "bloodhound-js";
import 'bootstrap-tagsinput';

$(function() {
// Datetime picker initialization.
// See https://eonasdan.github.io/bootstrap-datetimepicker/
$('[data-toggle="datetimepicker"]').datetimepicker({
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-check-circle-o',
clear: 'fa fa-trash',
close: 'fa fa-remove'
}
});

// Bootstrap-tagsinput initialization
// https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/
var $input = $('input[data-toggle="tagsinput"]');
Expand Down Expand Up @@ -57,7 +40,7 @@ $(document).on('submit', 'form[data-confirmation]', function (event) {
.on('click', '#btnYes', function () {
$confirm.data('result', 'yes');
$form.find('input[type="submit"]').attr('disabled', 'disabled');
$form.submit();
$form.trigger('submit');
})
.modal('show');
}
Expand Down
11 changes: 6 additions & 5 deletions assets/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import './styles/app.scss';

// loads the Bootstrap jQuery plugins
import 'bootstrap-sass/assets/javascripts/bootstrap/transition.js';
import 'bootstrap-sass/assets/javascripts/bootstrap/alert.js';
import 'bootstrap-sass/assets/javascripts/bootstrap/collapse.js';
import 'bootstrap-sass/assets/javascripts/bootstrap/dropdown.js';
import 'bootstrap-sass/assets/javascripts/bootstrap/modal.js';
import 'bootstrap/js/dist/alert';
import 'bootstrap/js/dist/collapse';
import 'bootstrap/js/dist/dropdown';
import 'bootstrap/js/dist/modal';
import 'jquery'

// loads the code syntax highlighting library
Expand All @@ -16,3 +15,5 @@ import './js/doclinks.js';

// start the Stimulus application
import './bootstrap';

import './js/flatpicker';
33 changes: 33 additions & 0 deletions assets/js/flatpicker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'flatpickr';
import 'flatpickr/dist/flatpickr.css';
import l10n from "flatpickr/dist/l10n";

flatpickr.defaultConfig.animate = window.navigator.userAgent.indexOf('MSIE') === -1;
let lang = document.documentElement.getAttribute('lang') || 'en';
const Locale = l10n[`${lang}`] || l10n.default;
flatpickr.localize(Locale);
const configs = {
standard: {
enableTime: true,
dateFormat: "Y-m-d H:i",
allowInput: true,
time_24hr: true,
defaultHour: 24,
parseDate: (datestr, format) => {
return flatpickr.parseDate(datestr, format);
},
formatDate: (date, format, locale) => {
return flatpickr.formatDate(date, format);
}
}
};

const flatpickrs = document.querySelectorAll(".flatpickr");
for (let i = 0; i < flatpickrs.length; i++) {
let element = flatpickrs[i];
let configValue = configs[element.getAttribute("data-flatpickr-class")] || {};
// Overrides the default format with the one sent by data attribute
configValue.dateFormat = element.getAttribute("data-date-format") || 'Y-m-d H:i';
// ...and then initialize the flatpickr
flatpickr(element, configValue);
}
30 changes: 30 additions & 0 deletions assets/styles/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// setting the value of this variable to an empty data URL is the only working solution
// to load the Bootswatch web fonts locally and avoid loading them from Google servers
// see https://github.com/thomaspark/bootswatch/issues/55#issuecomment-298093182
$web-font-path: 'data:text/css;base64,';

// Make sure the bootstrap-sass and lato fonts are resolved correctly
//$icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/";
$lato-font-path: '~lato-font/fonts';

$font-default: 19px;

$font-heading: 2.5rem;
$font-title: 2rem;
$font-subtitle: 1.5rem;

$secondary-color: #ecf0f1;
$gray-7500: #e9ecec;

$navbar-margin-bottom: 21px;

$table-cell-padding: 0.5rem;

$btn-padding-y-lg: 21px;
$btn-padding-x-lg: 14px;
$btn-padding-y: 15px;
$btn-padding-x: 10px;
$btn-padding-y-sm: 9px;
$btn-padding-x-sm: 6px;

@import "~bootswatch/dist/flatly/variables";
13 changes: 11 additions & 2 deletions assets/styles/admin.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import "~bootswatch/flatly/variables";
@import "~eonasdan-bootstrap-datetimepicker/src/sass/bootstrap-datetimepicker-build.scss";
@import "variables";
// @import "~eonasdan-bootstrap-datetimepicker/src/sass/bootstrap-datetimepicker-build.scss";
@import "bootstrap-tagsinput.scss";

/* Page: 'Backend post index'
Expand All @@ -24,3 +24,12 @@ body#admin_post_show .post-tags .label-default {
body#admin_post_show .post-tags .label-default i {
color: #95A6A7;
}

.form-control {
border-width: .125rem;

&:focus {
color: $blue;
box-shadow: none;
}
}
Loading