Skip to content

Commit

Permalink
V29.1.8 - Update to ES6 module.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Sep 15, 2024
1 parent a923c84 commit 3b34b41
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 56 deletions.
3 changes: 3 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Version Information
===================
Version 29.1.8
1. Update to ES6 module.

Version 29.1.7
1. Tested on Moodle 4.4

Expand Down
14 changes: 13 additions & 1 deletion amd/build/block_theme_selector.min.js

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

113 changes: 60 additions & 53 deletions amd/src/block_theme_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,65 +16,72 @@
/**
* Theme selector block.
*
* @package block
* @subpackage theme_selector
* @module block_theme_selector
* @copyright © 2015-onwards G J Barnard in respect to modifications of original code:
* https://github.com/johntron/moodle-theme-selector-block by John Tron, see:
* https://github.com/johntron/moodle-theme-selector-block/issues/1.
* @author G J Barnard - {@link http://moodle.org/user/profile.php?id=442195}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/* jshint ignore:start */
define(['jquery', 'core/log'], function ($, log) {
import $ from 'jquery';
import log from 'core/log';

"use strict"; // jshint ;_;

log.debug('Block Theme Selector jQuery AMD');

return {
init: function () {
log.debug('Block Theme Selector AMD init initialised');
/**
* Selector.
*/
const selector = () => {
$('.block_theme_selector select').on('change', function (e) {
var $select = $(e.target);
var choose = $select.find(':selected').val();
var urlswitch = $select.data('urlswitch');
if (urlswitch == 2) {
var changeparam;
var urlparams = $select.data('urlparams');
if (urlparams == 1) {
changeparam = '?';
} else {
changeparam = '&';
}
changeparam += 'theme=' + choose;
window.location = $select.data('url') + changeparam;
} else {
var params = {
'sesskey': $select.data('sesskey'),
'device': $select.data('device'),
'choose': choose
};
window.location = '/theme/index.php?' + $.param(params);
}
});

$(document).ready(function () {
$('.block_theme_selector select').on('change', function (e) {
var $select = $(e.target);
var choose = $select.find(':selected').val();
var urlswitch = $select.data('urlswitch');
if (urlswitch == 2) {
var changeparam;
var urlparams = $select.data('urlparams');
if (urlparams == 1) {
changeparam = '?';
} else {
changeparam = '&';
}
changeparam += 'theme=' + choose;
window.location = $select.data('url') + changeparam;
} else {
var params = {
'sesskey': $select.data('sesskey'),
'device': $select.data('device'),
'choose': choose
};
window.location = '/theme/index.php?' + $.param(params);
}
});
if ($('.themeselectorwindow').length) {
$('input[name="themeselectorwindowwidth"]').val(window.innerWidth);
$('input[name="themeselectorwindowheight"]').val(window.innerHeight);
$('#themeselectorcreatewindow').click(function (e) {
e.preventDefault();
var width = $('input[name="themeselectorwindowwidth"]').val();
var height = $('input[name="themeselectorwindowheight"]').val();
var mywindow = window.open(window.location.href, "",
"scrollbars=yes, toolbar=yes, width=" + width + ", height=" + height);
mywindow.focus();
});
}
};

if ($('.themeselectorwindow').length) {
$('input[name="themeselectorwindowwidth"]').val(window.innerWidth);
$('input[name="themeselectorwindowheight"]').val(window.innerHeight);
$('#themeselectorcreatewindow').click(function (e) {
e.preventDefault();
var width = $('input[name="themeselectorwindowwidth"]').val();
var height = $('input[name="themeselectorwindowheight"]').val();
var mywindow = window.open(window.location.href, "",
"scrollbars=yes, toolbar=yes, width=" + width + ", height=" + height);
mywindow.focus();
});
}
});
}
};
});
/* jshint ignore:end */
/**
* Init.
*/
export const init = () => {
log.debug('Block Theme Selector ES6 Selector init');
if (document.readyState !== 'loading') {
log.debug("Block Theme Selector ES6 Selector init DOM content already loaded");
selector();
} else {
log.debug("Block Theme Selector ES6 Selector init JS DOM content not loaded");
document.addEventListener('DOMContentLoaded', function () {
log.debug("Block Theme Selector ES6 Selector init JS DOM content loaded");
selector();
});
}
};
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

defined('MOODLE_INTERNAL') || die;

$plugin->release = '29.1.7';
$plugin->version = 2015082109;
$plugin->release = '29.1.8';
$plugin->version = 2015082110;
$plugin->requires = 2015051100.00; // M2.9 (Build: 20150511).
$plugin->supported = [29, 404]; // Supported Moodle version.
$plugin->maturity = MATURITY_STABLE;
Expand Down

0 comments on commit 3b34b41

Please sign in to comment.