Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

442 theme_essential: added custom slide size proof-of-concept #445

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
$THEME->sheets[] = 'moodle-rtl';
$THEME->sheets[] = 'bootstrap-pix';
$THEME->sheets[] = 'moodle-pix';
$THEME->sheets[] = 'essential';
$THEME->sheets[] = 'essential-pix';
$THEME->sheets[] = 'essential-settings';
$THEME->sheets[] = 'fontawesome';

if ((get_config('theme_essential', 'enablealternativethemecolors1')) ||
(get_config('theme_essential', 'enablealternativethemecolors2')) ||
(get_config('theme_essential', 'enablealternativethemecolors3'))
) {
(get_config('theme_essential', 'enablealternativethemecolors3'))) {
$THEME->sheets[] = 'essential-alternative';
}

Expand Down
10 changes: 10 additions & 0 deletions lang/en/theme_essential.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,13 @@
$string['blogpreferences'] = 'Blog preferences';
$string['badgepreferences'] = 'Badge preferences';
$string['messagepreferences'] = 'Message preferences';

// Slide show size
$string['slidesize'] = 'Slide show size';
$string['slidesizedesc'] = 'The height of the slide show. Full corresponds to 368 pixel at full screen, Very small corresonds fo 36 pixel at full screen';
$string['slide10percent'] = 'Very small';
$string['slide25percent'] = 'Small';
$string['slide50percent'] = 'Medium';
$string['slide75percent'] = 'Big';
$string['slide100percent'] = 'Full';

2 changes: 1 addition & 1 deletion layout/includes/guniversal.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function insert_analytics_tracking()
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '" . $trackingid . "', {'siteSpeedSampleRate': 50});
ga('send', " . $addition . ");

</script>
";
}
Expand Down
2 changes: 1 addition & 1 deletion less/essential/carousel.less

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,55 @@ function theme_essential_hex2rgba($hex, $opacity) {
return "rgba($r, $g, $b, $opacity)";
}

/**
* theme_essential_set_slide_size
*
* @param string $css The original CSS.
* @param string $slideheight The slide height in percent.
* @return string The modified CSS.
*/
function theme_essential_set_slide_size($css, $slidesize) {
// global $CFG;

if ($slidesize > 100) {
$slidesize = 100;
}

$slidesize /= 100;

$cases = range(1, 4);
foreach ($cases as $case) {
$tagbase = '[[setting:slidesize_case'."$case";
switch ($case) {
case 1:
$slideheight = $slidesize * 200;
break;
case 2:
$slideheight = $slidesize * 260;
break;
case 3:
$slideheight = $slidesize * 328;
break;
case 4:
$slideheight = $slidesize * 368;
break;
}
$tag = $tagbase.']]';
$replacement = intval($slideheight);
$css = str_replace($tag, $replacement . 'px', $css);

$tag = $tagbase.'_90percent]]';
$replacement = intval($slideheight * 0.9);
$css = str_replace($tag, $replacement . 'px', $css);

$tag = $tagbase.'_135percent]]';
$replacement = intval($slideheight * 1.35);
$css = str_replace($tag, $replacement . 'px', $css);
}

return $css;
}

/**
* Adds any custom CSS to the CSS before it is cached.
*
Expand Down Expand Up @@ -417,6 +466,10 @@ function theme_essential_process_css($css, $theme) {
$css = theme_essential_set_fontfiles($css, 'heading', $headingfont);
$css = theme_essential_set_fontfiles($css, 'body', $bodyfont);

// Set the slide size.
$slidesize = theme_essential_get_setting('slidesize');
$css = theme_essential_set_slide_size($css, $slidesize);

// Set the theme colour.
$themecolor = theme_essential_get_setting('themecolor');
$css = theme_essential_set_color($css, $themecolor, '[[setting:themecolor]]', '#30ADD1');
Expand Down
2 changes: 1 addition & 1 deletion renderers/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ public function render_slide($i, $captionoptions, $theme = null) {
if ($captionoptions == 0) {
$slide .= '<div class="container-fluid">';
$slide .= '<div class="row-fluid">';

if ($slidetitle || $slidecaption) {
$slide .= '<div class="span5 the-side-caption">';
$slide .= '<div class="the-side-caption-content">';
Expand Down
16 changes: 16 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,22 @@
$setting->set_updatedcallback('theme_reset_all_caches');
$temp->add($setting);

// Slide size.
$name = 'theme_essential/slidesize';
$title = get_string('slidesize', 'theme_essential');
$description = get_string('slidesizedesc', 'theme_essential');
$default = '100';
$choices = array(
10 => get_string('slide10percent', 'theme_essential'),
25 => get_string('slide25percent', 'theme_essential'),
50 => get_string('slide50percent', 'theme_essential'),
75 => get_string('slide75percent', 'theme_essential'),
100 => get_string('slide100percent', 'theme_essential'),
);
$setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
$setting->set_updatedcallback('theme_reset_all_caches');
$temp->add($setting);

// Slide Text colour setting.
$name = 'theme_essential/slidecolor';
$title = get_string('slidecolor', 'theme_essential');
Expand Down
48 changes: 24 additions & 24 deletions style/essential-rtl.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading