Skip to content

Commit

Permalink
Merge pull request #3766 from Spuds/Mydevelopment
Browse files Browse the repository at this point in the history
JS updates and directory structure
  • Loading branch information
Spuds committed Mar 5, 2024
2 parents 4788c56 + b338360 commit b1bef70
Show file tree
Hide file tree
Showing 54 changed files with 271 additions and 235 deletions.
4 changes: 2 additions & 2 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_modules
**/jquery*
**/*.min.js
themes/default/scripts/qrcode.js
themes/default/scripts/sha256.js
themes/default/scripts/ext/qrcode.js
themes/default/scripts/ext/sha256.js
themes/default/scripts/bbcode.js
vendor/**/*.js
2 changes: 1 addition & 1 deletion SSI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ function ssi_login($redirect_to = '', $output_method = 'echo')
$context['default_username'] = isset($_POST['user']) ? preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', htmlspecialchars($_POST['user'], ENT_COMPAT, 'UTF-8')) : '';

echo '
<script src="', $settings['default_theme_url'], '/scripts/sha256.js"></script>';
<script src="', $settings['default_theme_url'], '/scripts/ext/sha256.js"></script>';

echo '
<form action="', $scripturl, '?action=login2" name="frmLogin" id="frmLogin" method="post" accept-charset="UTF-8" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/AdminController/ManageFeatures.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ private function _notificationsSettings()
global $txt, $modSettings;

Txt::load('Profile+UserNotifications');
loadJavascriptFile('jquery.multiselect.min.js');
loadJavascriptFile('ext/jquery.multiselect.min.js');
theme()->addInlineJavascript('
$(\'.select_multiple\').multiselect({\'language_strings\': {\'Select all\': ' . JavascriptEscape($txt['notify_select_all']) . '}});', true);
loadCSSFile('multiselect.css');
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/AdminController/ManageRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function action_register()
}

// Basic stuff.
loadJavascriptFile('mailcheck.min.js');
loadJavascriptFile('ext/mailcheck.min.js');
theme()->addInlineJavascript('disableAutoComplete();
$("input[type=email]").on("blur", function(event) {
$(this).mailcheck({
Expand Down
8 changes: 4 additions & 4 deletions sources/ElkArte/Controller/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function action_login()
}

theme()->getTemplates()->load('Login');
loadJavascriptFile('sha256.js', array('defer' => true));
loadJavascriptFile('ext/sha256.js', array('defer' => true));
$context['sub_template'] = 'login';

// Get the template ready.... not really much else to do.
Expand Down Expand Up @@ -170,7 +170,7 @@ public function action_login2()

// Load the template stuff
theme()->getTemplates()->load('Login');
loadJavascriptFile('sha256.js', array('defer' => true));
loadJavascriptFile('ext/sha256.js', array('defer' => true));
$context['sub_template'] = 'login';

// Set up the default/fallback stuff.
Expand Down Expand Up @@ -645,7 +645,7 @@ public function action_kickguest()

Txt::load('Login');
theme()->getTemplates()->load('Login');
loadJavascriptFile('sha256.js', array('defer' => true));
loadJavascriptFile('ext/sha256.js', array('defer' => true));
createToken('login');

// Never redirect to an attachment
Expand Down Expand Up @@ -673,7 +673,7 @@ public function action_maintenance_mode()

Txt::load('Login');
theme()->getTemplates()->load('Login');
loadJavascriptFile('sha256.js', array('defer' => true));
loadJavascriptFile('ext/sha256.js', array('defer' => true));
createToken('login');

// Send a 503 header, so search engines don't bother indexing while we're in maintenance mode.
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/Controller/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public function action_display()
// Quick reply & modify enabled?
if ($context['can_reply'] && !empty($options['display_quick_reply']))
{
loadJavascriptFile(['mentioning.js', 'quickQuote.js'], ['defer' => true]);
loadJavascriptFile(['editor/mentioning.js', 'quickQuote.js'], ['defer' => true]);
$this->_template_layers->addBefore('quickreply', 'moderation_buttons');
theme()->addInlineJavascript("
document.addEventListener('DOMContentLoaded', () => new Elk_QuickQuote(), false);", true
Expand Down
6 changes: 3 additions & 3 deletions sources/ElkArte/Controller/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function action_register()
// Show the user the right form.
$context['sub_template'] = $current_step === 1 ? 'registration_agreement' : 'registration_form';
$context['page_title'] = $current_step === 1 ? $txt['registration_agreement'] : $txt['registration_form'];
loadJavascriptFile(array('register.js', 'mailcheck.min.js'));
loadJavascriptFile(array('register.js', 'ext/mailcheck.min.js'));

// Add the register chain to the link tree.
$context['linktree'][] = array(
Expand Down Expand Up @@ -848,7 +848,7 @@ public function action_activate()

Txt::load('Login');
theme()->getTemplates()->load('Login');
loadJavascriptFile('sha256.js', array('defer' => true));
loadJavascriptFile('ext/sha256.js', array('defer' => true));

// Need a user id to activate
if (empty($this->_req->query->u) && empty($this->_req->post->user))
Expand Down Expand Up @@ -1232,7 +1232,7 @@ public function action_contact()
}
else
{
loadJavascriptFile('mailcheck.min.js');
loadJavascriptFile('ext/mailcheck.min.js');
$context['sub_template'] = 'contact_form';
$context['page_title'] = $txt['admin_contact_form'];

Expand Down
4 changes: 2 additions & 2 deletions sources/ElkArte/Controller/Reminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function action_setpassword2()
call_integration_hook('integrate_reset_pass', array($member['member_name'], $member['member_name'], $this->_req->post->passwrd1));

theme()->getTemplates()->load('Login');
loadJavascriptFile('sha256.js', array('defer' => true));
loadJavascriptFile('ext/sha256.js', array('defer' => true));
$context += array(
'page_title' => $txt['reminder_password_set'],
'sub_template' => 'login',
Expand Down Expand Up @@ -357,7 +357,7 @@ public function action_secret2()

// Tell them it went fine.
theme()->getTemplates()->load('Login');
loadJavascriptFile('sha256.js', array('defer' => true));
loadJavascriptFile('ext/sha256.js', array('defer' => true));
$context += array(
'page_title' => $txt['reminder_password_set'],
'sub_template' => 'login',
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/Controller/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function action_stats()
// Stats it is
Txt::load('Stats');
theme()->getTemplates()->load('Stats');
loadJavascriptFile(['stats.js', 'chart.min.js', 'elk_chart.js']);
loadJavascriptFile(['stats.js', 'ext/chart.min.js', 'elk_chart.js']);

// Build the link tree......
$context['linktree'][] = [
Expand Down
4 changes: 2 additions & 2 deletions sources/ElkArte/EmojiIntegrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public static function integrate_editor_plugins($editor_id)
if (empty($context['mentions_enabled']))
{
loadCSSFile('jquery.atwho.css');
loadJavascriptFile(['jquery.atwho.min.js', 'jquery.caret.min.js', 'emoji.plugin.js'], ['defer' => true]);
loadJavascriptFile(['editor/jquery.atwho.min.js', 'editor/jquery.caret.min.js', 'editor/emoji.plugin.js'], ['defer' => true]);
}
else
{
loadJavascriptFile(['emoji.plugin.js'], ['defer' => true]);
loadJavascriptFile(['editor/emoji.plugin.js'], ['defer' => true]);
}

// Add the emoji plugin to the editor
Expand Down
31 changes: 0 additions & 31 deletions sources/ElkArte/Helper/HttpReq.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,42 +111,11 @@ private function _loadParsed()
$cleaned = array_intersect_key($_REQUEST, $this->_derived_post);
$this->_derived_post = array_merge($this->_derived_post, $cleaned);

// Load any json into _derived_post
$this->_loadJson();

// Make the $_GET $_POST super globals available as R/W properties
$this->post = new \ArrayObject($this->_derived_post, \ArrayObject::ARRAY_AS_PROPS);
$this->query = new \ArrayObject($derived_get, \ArrayObject::ARRAY_AS_PROPS);
}

/**
* Looks for the post value "jsonString" and expands values to POST
*
* What it does:
*
* - Looks for jsonString passed in post
* - json decodes the string and loads its values in to POST
* - Does *not* overwrite any existing keys
*/
private function _loadJson()
{
// Was the magic json value posted?
if (!empty($this->_derived_post['jsonString']))
{
$json = json_decode($this->_derived_post['jsonString'], true);

// Valid decode
if (!empty($json))
{
// Maintain the original keys only add new ones
$json = array_diff_key($json, $this->_derived_post);
$this->_derived_post = array_merge($this->_derived_post, $json);
}

unset($this->_derived_post['jsonString']);
}
}

/**
* Generic fetch access for values contained in the super globals
*
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/Modules/Drafts/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function prepare_context($use_quick_reply, &$editorOptions, $board)
'value' => empty($context['id_draft']) ? 0 : $context['id_draft'],
];

loadJavascriptFile('drafts.plugin.js', ['defer' => true]);
loadJavascriptFile('editor/drafts.plugin.js', ['defer' => true]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/Modules/Drafts/PersonalMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function prepare_send_context(&$editorOptions)
bPM: true
}';

loadJavascriptFile('drafts.plugin.js', ['defer' => true]);
loadJavascriptFile('editor/drafts.plugin.js', ['defer' => true]);
Txt::load('Post');

// Our not so concise shortcut line
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/Modules/Drafts/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function finalize_post_form(&$editorOptions, $board, $topic, $template_la
id_draft: ' . (empty($context['id_draft']) ? 0 : $context['id_draft']) . '
}';

loadJavascriptFile('drafts.plugin.js', ['defer' => true]);
loadJavascriptFile('editor/drafts.plugin.js', ['defer' => true]);
}

$context['shortcuts_text'] = $context['shortcuts_text'] ?? $txt['shortcuts_drafts'];
Expand Down
4 changes: 2 additions & 2 deletions sources/ElkArte/Notifications/UserNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function _addFaviconNumbers($number)
{
call_integration_hook('integrate_adjust_favicon_number', [&$number]);

loadJavascriptFile('favico.js', ['defer' => true]);
loadJavascriptFile('ext/favico.js', ['defer' => true]);

$notif_opt = [];
$rules = [
Expand Down Expand Up @@ -126,7 +126,7 @@ protected function settingExists($key)
*/
protected function _addDesktopNotifications()
{
loadJavascriptFile(['push.min.js', 'desktop-notify.js'], ['defer' => true]);
loadJavascriptFile(['ext/push.min.js', 'desktop-notify.js'], ['defer' => true]);
theme()->addInlineJavascript('
$(function() {
Push.config({serviceWorker: "./elkServiceWorker.min.js"});
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/Profile/ProfileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ public function action_statPanel()
global $txt, $context, $modSettings;

require_once(SUBSDIR . '/Stats.subs.php');
loadJavascriptFile(['chart.min.js', 'elk_chart.js']);
loadJavascriptFile(['ext/chart.min.js', 'elk_chart.js']);

$context['page_title'] = $txt['statPanel_showStats'] . ' ' . $this->_profile['real_name'];

Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/Profile/ProfileOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public function action_account()
$fields = self::getFields('account_otp');
setupProfileContext($fields['fields'], $fields['hook']);

loadJavascriptFile('qrcode.js');
loadJavascriptFile('ext/qrcode.js');
$context['load_google_authenticator'] = true;
}
else
Expand Down
8 changes: 4 additions & 4 deletions sources/ElkArte/Themes/Javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ public function templateJquery()
// Just use the local file
case 'local':
echo '
<script src="', $settings['default_theme_url'], '/scripts/jquery-' . $jquery_version . '.min.js" id="jquery"></script>',
<script src="', $settings['default_theme_url'], '/scripts/ext/jquery-' . $jquery_version . '.min.js" id="jquery"></script>',
(empty($modSettings['jquery_include_ui']) ? '' : '
<script src="' . $settings['default_theme_url'] . '/scripts/jquery-ui-' . $jqueryui_version . '.min.js" id="jqueryui"></script>');
<script src="' . $settings['default_theme_url'] . '/scripts/ext/jquery-ui-' . $jqueryui_version . '.min.js" id="jqueryui"></script>');
break;
// CDN with local fallback
case 'auto':
Expand All @@ -136,9 +136,9 @@ public function templateJquery()
<script src="' . $jqueryui_cdn . '" id="jqueryui"></script>');
echo '
<script>
window.jQuery || document.write(\'<script src="', $settings['default_theme_url'], '/scripts/jquery-' . $jquery_version . '.min.js"><\/script>\');',
window.jQuery || document.write(\'<script src="', $settings['default_theme_url'], '/scripts/ext/jquery-' . $jquery_version . '.min.js"><\/script>\');',
(empty($modSettings['jquery_include_ui']) ? '' : '
window.jQuery.ui || document.write(\'<script src="' . $settings['default_theme_url'] . '/scripts/jquery-ui-' . $jqueryui_version . '.min.js"><\/script>\')'), '
window.jQuery.ui || document.write(\'<script src="' . $settings['default_theme_url'] . '/scripts/ext/jquery-ui-' . $jqueryui_version . '.min.js"><\/script>\')'), '
</script>';
break;
}
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/Themes/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public function addCodePrettify()
if (!empty($modSettings['enableCodePrettify']))
{
$this->loadVariant('prettify');
loadJavascriptFile('prettify.min.js', ['defer' => true]);
loadJavascriptFile('ext/prettify.min.js', ['defer' => true]);

$this->addInlineJavascript('
document.addEventListener("DOMContentLoaded", () => {
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/Themes/ThemeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ private function showLoginBar()

$context['show_login_bar'] = true;
$context['theme_header_callbacks'][] = 'login_bar';
loadJavascriptFile('sha256.js', ['defer' => true]);
loadJavascriptFile('ext/sha256.js', ['defer' => true]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion sources/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function is_not_guest($message = '', $is_fatal = true)
else
{
theme()->getTemplates()->load('Login');
loadJavascriptFile('sha256.js', ['defer' => true]);
loadJavascriptFile('ext/sha256.js', ['defer' => true]);
createToken('login');
$context['sub_template'] = 'kick_guest';
$context['robot_no_index'] = true;
Expand Down
2 changes: 1 addition & 1 deletion sources/subs/Auth.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function adminLogin($type = 'admin')

Txt::load('Admin');
theme()->getTemplates()->load('Login');
loadJavascriptFile('sha256.js', array('defer' => true));
loadJavascriptFile('ext/sha256.js', array('defer' => true));

// Validate what type of session check this is.
$types = array();
Expand Down
16 changes: 8 additions & 8 deletions sources/subs/Editor.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ function create_control_richedit($editorOptions)

// JS makes the editor go round
loadJavascriptFile([
'jquery.sceditor.bbcode.min.js',
'jquery.sceditor.elkarte.js',
'editor/jquery.sceditor.bbcode.min.js',
'editor/jquery.sceditor.elkarte.js',
'post.js',
'dropAttachments.js'
'editor/dropAttachments.js'
]);

theme()->addJavascriptVar([
Expand Down Expand Up @@ -184,30 +184,30 @@ function loadEditorPlugins($editor_context)
$neededCSS = [];

$plugins[] = 'initialLoad';
$neededJS[] = 'initialLoad.plugin.js';
$neededJS[] = 'editor/initialLoad.plugin.js';

if (!empty($modSettings['enableSplitTag']))
{
$plugins[] = 'splittag';
$neededJS[] = 'splittag.plugin.js';
$neededJS[] = 'editor/splittag.plugin.js';
}

if (!empty($modSettings['enableUndoRedo']))
{
$plugins[] = 'undo';
$neededJS[] = 'undo.plugin.min.js';
$neededJS[] = 'editor/undo.plugin.min.js';
}

if (!empty($modSettings['mentions_enabled']))
{
$plugins[] = 'mention';
$neededJS = array_merge($neededJS, ['jquery.atwho.min.js', 'jquery.caret.min.js', 'mentioning.plugin.js']);
$neededJS = array_merge($neededJS, ['editor/jquery.atwho.min.js', 'editor/jquery.caret.min.js', 'editor/mentioning.plugin.js']);
}

if (!empty($modSettings['enableGiphy']))
{
$plugins[] = 'giphy';
$neededJS[] = 'giphy.plugin.js';
$neededJS[] = 'editor/giphy.plugin.js';
$neededCSS[] = 'sceditor.giphy.css';
}

Expand Down
2 changes: 1 addition & 1 deletion themes/default/ProfileOptions.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function template_ProfileOptions_init()

if (!empty($context['menu_item_selected']) && $context['menu_item_selected'] === 'notification')
{
loadJavascriptFile('jquery.multiselect.min.js');
loadJavascriptFile('ext/jquery.multiselect.min.js');
theme()->addInlineJavascript('
$(\'.select_multiple\').multiselect({\'language_strings\': {\'Select all\': ' . JavascriptEscape($txt['notify_select_all']) . '}});'
, true);
Expand Down

0 comments on commit b1bef70

Please sign in to comment.