Skip to content

Commit

Permalink
Refactor app.js and theme.php to set default country code on telephon…
Browse files Browse the repository at this point in the history
…e country code picker

Signed-off-by: Sam <[email protected]>
  • Loading branch information
sampoyigi committed Jun 2, 2023
1 parent 71638ec commit df44259
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 40 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/compile-assets.yml

This file was deleted.

2 changes: 1 addition & 1 deletion assets/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/app.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions assets/src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $.fn.tabs = function () {
/*
* Ensure the CSRF token is added to all AJAX requests.
*/
$.ajaxPrefilter(function(options) {
$.ajaxPrefilter(function (options) {
var token = $('meta[name="csrf-token"]').attr('content')

if (token) {
Expand Down Expand Up @@ -73,15 +73,15 @@ $(function () {

if (days) {
var date = new Date()
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))
expires = '; expires=' + date.toGMTString()
date.setTime(date.getTime()+(days * 24 * 60 * 60 * 1000))
expires = '; expires='+date.toGMTString()
}

document.cookie = name + "=" + value + expires + "; path=/"
document.cookie = name+"="+value+expires+"; path=/"
}

function checkCookie(name) {
var nameEQ = name + "=",
var nameEQ = name+"=",
ca = document.cookie.split(';')

for (var i = 0; i < ca.length; i++) {
Expand Down Expand Up @@ -123,7 +123,7 @@ $(function () {
$(document).find('[data-control="country-code-picker"]').each(function () {
var $this = $(this),
options = $.extend({
initialCountry: 'gb',
initialCountry: (app.country.iso_code_2 || '').toLowerCase(),
separateDialCode: true,
utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/11.0.4/js/utils.js"
}, $this.data()),
Expand Down
9 changes: 8 additions & 1 deletion theme.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<?php

// add currency helper
$defaultCountry = \System\Models\Countries_model::getDefault();
$defaultCurrency = app('currency')->getDefault();
Assets::putJsVars([
'country' => [
'name' => $defaultCountry->country_name,
'iso_code_2' => $defaultCountry->iso_code_2,
'iso_code_3' => $defaultCountry->iso_code_3,
'format' => $defaultCountry->format,
],
// add currency helper
'currency' => [
'symbol' => $defaultCurrency->currency_symbol,
'symbol_position' => $defaultCurrency->symbol_position,
Expand Down

0 comments on commit df44259

Please sign in to comment.