Skip to content

Commit

Permalink
add config Option to add jquery asset
Browse files Browse the repository at this point in the history
add Frontmatter Variable lang to allow override of language for page
  • Loading branch information
wernerjoss committed Jun 14, 2021
1 parent a8dddd2 commit 5042036
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v0.2.10
## 06/14/2021

1. [](#new)
* add config Option to add jquery asset in case the used Theme does not.
* add Frontmatter Variable lang to allow override of language for page

# v0.2.9
## 05/20/2021

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ Here is the default configuration and an explanation of available options:
```yaml

enabled: true
colors: #3a87ad # see additional Note on custom colors in the Changelog
colors: "#3a87ad" # see additional Note on custom colors in the Changelog, be sure to use single or double quotes around list !
showlegend: false # set to true to show calendar File Name(s) as Legend below grid
weekNumbers: false # set to true to show Week Numbers
cors_api_url: # the default value is now empty as the formerly used external proxy, https://cors-anywhere.herokuapp.com/ , will no longer work
addJquery: false # Add Jquery asset in case your Theme does not do this

```
Expand Down
2 changes: 1 addition & 1 deletion assets/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// gets Parameters via DOM, see below

jQuery(document).ready(function () {
var verbose = false;
var verbose = true;
var defaultLocale = 'en';
var cfgWeekNums = jQuery('#weeknums').text(); // get Paramter from DOM
weekNums = false;
Expand Down
13 changes: 11 additions & 2 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: FullCalendar
version: 0.2.9
version: 0.2.10
description: show Calendar Widget from ICS File(s), based on fullcalendar.io
icon: calendar
author:
Expand Down Expand Up @@ -46,11 +46,20 @@ form:
type: text
size: large
label: Calendar(s) Colors
help: Comma separated List of valid html Colors, e.g. Red,LightBlue or '#DEFFAB,#GADEEF
help: Comma separated List of valid html Colors, e.g. Red,LightBlue or '#DEFFAB,#GADEEF'
cors_api_url:
type: text
size: large
label: local Cors API URL
default:
help: leave this empty if you are not sure - it will be evaluated automatically and mostly work ! - see README
addJquery:
type: toggle
label: Add Jquery
help: Add Jquery asset in case your Theme does not do this
highlight: 1
default: 0
options:
1: Enabled
0: Disabled

17 changes: 17 additions & 0 deletions fullcalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ private function addAssets()
{
/** @var Assets */
$assets = $this->grav['assets'];
$config = $this->config->get('plugins.fullcalendar');
if ($config['addJquery'])
$assets->add('jquery', 100); // add jquery on demand (in case Theme does not do this)
$assets->addJs('plugins://' . $this->name . '/assets/jquery.ajax-cross-origin.min.js', ['group' => 'bottom']); // 12.05.21 - so gehts !!!
$assets->addJs('plugins://' . $this->name . '/assets/ical.js/build/ical.min.js', ['group' => 'bottom']); // see also reamde.txt file there
// for Tooltip:
Expand All @@ -60,7 +63,21 @@ private function addAssets()
$assets->addJs('plugins://' . $this->name . '/assets/calendar.js', ['group' => 'bottom']);
$assets->addCss('plugins://' . $this->name . '/assets/daygrid.css'); // default CSS for #calendar
$language = $this->grav['language']->getLanguage();
// dump($language);
$assets->addJs('plugins://' . $this->name . '/fc4/packages/core/locales/'.$language.'.js', ['group' => 'bottom']);
$languages = $this->config->get('system.languages.supported');
// $languages = ['en','it'];
// dump($languages);
foreach ($languages as $lang) {
// dump($lang);
if ($lang != $language) {
$asset = 'plugins://' . $this->name . '/fc4/packages/core/locales/'.$lang.'.js';
// dump($asset);
$assets->addJs('plugins://' . $this->name . '/fc4/packages/core/locales/'.$lang.'.js', ['group' => 'bottom']);
}
}
/*
*/
}

public function onTwigTemplatePaths()
Expand Down
11 changes: 11 additions & 0 deletions templates/calendar.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
{% if (num_mpics|int) >= 12 %} {# 12 pics sollten für 1 Jahr reichen :-) #}
<div id='actMonth'></div>
{% endif %}

{% set lang = grav.language.getLanguage %}
{#
<span>{{ lang }}</span>
<span>{{ page.header.lang }}</span>
#}
{% if page.header.lang|length > 0 %}
{% set lang = page.header.lang %}
{% endif %}
<div id='cfgLocale' style='display:none;'>{{ lang }}</div>

{% if (numcalendars|int) > 0 %} {# write local page calendars to DOM, json encoded #}
<div id='pagecalendars' style='display:none;'>{{ calendars|json_encode() }}</div>
{% endif %}
Expand Down
3 changes: 2 additions & 1 deletion templates/partials/fullcalendar.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<div id='cfgFilestring' style='display:none;'>{{ icsfile }}</div>
<div id='BgColstring' style='display:none;'>{{ config.plugins.fullcalendar.colors }}</div>
<div id='CorsUrl' style='display:none;'>{{ config.plugins.fullcalendar.cors_api_url }}</div>
<div id='cfgLocale' style='display:none;'>{{ grav.language.getLanguage }}</div>
{# hat keinen Zugriff auf page header !!!
#}
<div id='showlegend' style='display:none;'>{{ config.plugins.fullcalendar.showlegend }}</div>
<div id='tzoffset' style='display:none;'>{{ config.plugins.fullcalendar.tz_offset }}</div>

0 comments on commit 5042036

Please sign in to comment.