Skip to content

Commit

Permalink
Merge pull request #407 from templaza/v3
Browse files Browse the repository at this point in the history
Version 3.0.2
  • Loading branch information
sonvnn authored Oct 19, 2023
2 parents 46576bf + 76947eb commit 27e2875
Show file tree
Hide file tree
Showing 16 changed files with 195 additions and 53 deletions.
2 changes: 1 addition & 1 deletion assets/vendor/manager/dist/index.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/vendor/manager/dist/index.html

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions assets/vendor/manager/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/vendor/manager/fonts_ajax.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/vendor/manager/index.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/vendor/manager/src/assets/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
--as-pre-bg: #1b1f22;
--as-btn-image-border: #a04aec;
--as-btn-image-hover-border: #b773f2;
--bs-tertiary-bg: #2b3035;
}

.nav {
Expand Down
80 changes: 79 additions & 1 deletion assets/vendor/manager/src/components/Main.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup>
import { onBeforeMount, ref } from 'vue';
import { onBeforeMount, ref, reactive } from 'vue';
import axios from "axios";
import Fields from './helpers/Fields.vue'
const props = defineProps({
Expand Down Expand Up @@ -66,12 +67,68 @@ function updateContentLayout(index, value) {
$scope.value['astroidcontentlayouts'] = tmp.join(',');
}
const presets = ref([]);
const toast_msg = reactive({
header: '',
body:'',
icon: '',
color:'darkviolet'
});
function loadPreset(value) {
let tmp = JSON.parse(value);
Object.keys(tmp).forEach(key => {
$scope.value[key] = tmp[key];
})
}
function getPreset(value) {
presets.value = value;
}
function selectPreset(event, group) {
if (event.target.value !== '' & confirm('Your current configure will be lost and overwritten by new data. Are you sure?')) {
const toastAstroidMsg = document.getElementById('loadGroupPreset');
const toastBootstrap = Toast.getOrCreateInstance(toastAstroidMsg);
let url = 'index.php?t='+Math.random().toString(36).substring(7);
if (process.env.NODE_ENV === 'development') {
url = "preset_ajax.txt?ts="+Date.now();
}
const formData = new FormData(); // pass data as a form
formData.append(props.config.astroid_lib.astroid_admin_token, 1);
formData.append('name', event.target.value);
formData.append('astroid', 'loadpreset');
formData.append('option', 'com_ajax');
formData.append('template', props.config.astroid_lib.tpl_template_name);
axios.post(url, formData, {
headers: {
"Content-Type": "multipart/form-data",
},
})
.then((response) => {
if (response.data.status === 'success') {
const tmp = JSON.parse(response.data.data);
group.fields.forEach(field => {
if (typeof tmp[field.name] !== 'undefined') {
$scope.value[field.name] = tmp[field.name]
}
});
toast_msg.icon = 'fa-solid fa-rocket';
toast_msg.header = 'Preset '+group.title+' Applied.';
toast_msg.body = 'Please click "Save" button to save your changes!';
toast_msg.color = 'green';
toastBootstrap.show();
} else {
toast_msg.icon = 'fa-regular fa-face-sad-tear';
toast_msg.header = 'Preset '+group.title+' is not Applied.';
toast_msg.body = response.data.message;
toast_msg.color = 'red';
toastBootstrap.show();
}
event.target.value = '';
})
.catch((err) => {
console.error(err);
});
}
}
</script>
<template>
<main class="as-main order-1">
Expand All @@ -81,6 +138,13 @@ function loadPreset(value) {
<div :id="`astroid-page-`+index" class="as-content" v-if="Object.keys(fieldSet.childs).length > 0" v-for="(group, index) in fieldSet.childs" :key="index" v-show="checkShowGroup(group.fields)">
<h3 v-if="group.title !== ''">{{ group.title }}</h3>
<p v-if="group.description !== ''">{{ group.description }}</p>
<div class="input-group mb-3">
<label :for="`preset_`+fieldSet.name+`_`+index" class="input-group-text">Load default configure</label>
<select class="form-select" :id="`preset_`+fieldSet.name+`_`+index" @change="selectPreset($event, group)">
<option value="">Select a preset</option>
<option v-for="(preset, preset_idx) in presets" :key="preset_idx" :value="preset.name">{{ preset.title }}</option>
</select>
</div>
<div v-if="group.fields.length > 0" class="as-group-content">
<div :class="(idx !== 0 && field.input.type !== 'astroidhidden' && field.input.type !== 'hidden' ? 'mt-3 pt-3 border-top': '')" v-for="(field, idx) in group.fields" :key="field.id" v-show="checkShow(field)">
<div class="row">
Expand All @@ -100,6 +164,7 @@ function loadPreset(value) {
:constant="props.config.astroid_lib"
@update:contentlayout="updateContentLayout"
@update:loadPreset="loadPreset"
@update:getPreset="getPreset"
/>
</div>
<div v-else v-html="field.input"></div>
Expand All @@ -110,5 +175,18 @@ function loadPreset(value) {
</div>
</div>
</form>
<div class="toast-container position-fixed bottom-0 end-0 p-3">
<div id="loadGroupPreset" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<i class="me-2" :class="toast_msg.icon" :style="{color: toast_msg.color}"></i>
<strong class="me-auto">{{ toast_msg.header }}</strong>
<small>1 second ago</small>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
{{ toast_msg.body }}
</div>
</div>
</div>
</main>
</template>
4 changes: 2 additions & 2 deletions assets/vendor/manager/src/components/helpers/Fields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import DatePicker from './DatePicker.vue';
import Colors from './Colors.vue';
import Presets from './Presets.vue';
const emit = defineEmits(['update:contentlayout', 'update:loadPreset']);
const emit = defineEmits(['update:contentlayout', 'update:loadPreset', 'update:getPreset']);
const props = defineProps({
field: { type: Object, default: null },
scope: { type: Object, default: null },
Expand Down Expand Up @@ -139,7 +139,7 @@ function updateContentLayout() {
<DatePicker v-model="props.scope[props.field.name]" :field="props.field" />
</div>
<div v-else-if="props.field.input.type === `astroidpreset`" class="astroid-preset">
<Presets :field="props.field" :config="props.constant" @update:loadPreset="(value) => {emit('update:loadPreset', value)}" />
<Presets :field="props.field" :config="props.constant" @update:loadPreset="(value) => {emit('update:loadPreset', value)}" @update:getPreset="(value) => {emit('update:getPreset', value)}" />
</div>
<div v-else-if="props.field.input.type === `astroidheading`" class="astroid-heading">
<h3>{{ props.field.input.title }}</h3>
Expand Down
3 changes: 2 additions & 1 deletion assets/vendor/manager/src/components/helpers/Presets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import axios from "axios";
import { onBeforeMount, ref, reactive, onMounted } from 'vue';
const emit = defineEmits(['update:loadPreset']);
const emit = defineEmits(['update:loadPreset', 'update:getPreset']);
const props = defineProps({
field: { type: Object, default: null },
config: { type: Object, default: null },
Expand All @@ -17,6 +17,7 @@ const list = ref([]);
const key_bg = ['#ffcdd2','#e1bee7','#bbdefb','#b2dfdb','#ffcc80'];
onBeforeMount(() => {
list.value = props.field.input.value;
emit('update:getPreset', props.field.input.value);
})
onMounted(()=>{
Expand Down
73 changes: 62 additions & 11 deletions assets/vendor/manager/src/components/helpers/Typography.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { onMounted, onUpdated, ref, watch, inject } from 'vue';
import { onMounted, onUpdated, ref, watch, inject, reactive } from 'vue';
import axios from "axios";
import { ModelListSelect } from "vue-search-select"
import TypoResponsive from './TypoResponsive.vue';
Expand All @@ -13,29 +13,67 @@ const font_styles = [
{'value':'italic', 'text':'<em>Italic</em>'},
{'value':'underline', 'text':'<span class="typography-underline">Underline</span>'},
]
const options= ref([]);
const system_fonts = {
"Arial, Helvetica, sans-serif" : 'Arial, Helvetica',
"Arial Black, Gadget, sans-serif" : 'Arial Black, Gadget',
"Bookman Old Style, serif" : 'Bookman Old Style',
"Comic Sans MS, cursive" : 'Comic Sans MS',
"Courier, monospace" : 'Courier',
"Garamond, serif" : 'Garamond',
"Georgia, serif" : 'Georgia',
"Impact, Charcoal, sans-serif" : 'Impact, Charcoal',
"Lucida Console, Monaco, monospace" : 'Lucida Console, Monaco',
"Lucida Sans Unicode, sans-serif" : 'Lucida Sans Unicode',
"MS Sans Serif, Geneva, sans-serif" : 'MS Sans Serif, Geneva',
"MS Serif, New York, sans-serif" : 'MS Serif, New York',
"Palatino Linotype, Book Antiqua, Palatino, serif" : 'Palatino Linotype, Book Antiqua, Palatino',
"Tahoma, Geneva, sans-serif" : 'Tahoma, Geneva',
"Times New Roman, Times, serif" : 'Times New Roman, Times',
"Trebuchet MS, Helvetica, sans-serif" : 'Trebuchet MS, Helvetica',
"Verdana, Geneva, sans-serif" : 'Verdana, Geneva'
}
const options= reactive({
'system': [],
'google': [],
'local' : [],
});
const fontSelected= ref({
value: "",
text: "",
});
const fonttypes = ref(['system','google'])
const font_type = ref('google');
const currentDevice = ref('desktop');
function getFontType(font_face) {
if (font_face.search(/^library-font-/) !== -1) {
font_type.value = 'local';
} else if (typeof system_fonts[font_face] !== 'undefined') {
font_type.value = 'system';
} else {
font_type.value = 'google';
}
}
onMounted(()=>{
let url = props.constant.site_url+"administrator/index.php?option=com_ajax&astroid=google-fonts&template="+props.constant.template_name+"&ts="+Date.now();
if (process.env.NODE_ENV === 'development') {
url = "fonts_ajax.txt?ts="+Date.now();
}
Object.keys(props.field.input.value).forEach(key => {
props.modelValue[key] = props.field.input.value[key];
})
getFontType(props.field.input.value.font_face);
axios.get(url)
.then(function (response) {
if (response.status === 200) {
options.value = response.data;
response.data.forEach(element => {
options.system = response.data.system;
options.google = response.data.google;
options.local = response.data.local;
if (options.local.length > 1) {
fonttypes.value.push('local');
}
response.data[font_type.value].forEach(element => {
if (props.modelValue['font_face'] === element.value) {
fontSelected.value = element;
}
Expand Down Expand Up @@ -65,7 +103,8 @@ onMounted(()=>{
onUpdated(()=>{
if (fontSelected.value.value !== '' && fontSelected.value.value !== props.modelValue['font_face']) {
fontSelected.value = options.value.find((option) => option.value === props.modelValue['font_face']);
getFontType(props.modelValue['font_face']);
fontSelected.value = options[font_type.value].find((option) => option.value === props.modelValue['font_face']);
}
})
Expand Down Expand Up @@ -95,13 +134,25 @@ function changeColor(color) {
}
</script>
<template>
<div class="row row-cols-lg-2 row-cols-xl-3 g-4">
<div class="row row-cols-lg-2 row-cols-xl-3 g-4">
<div>
<div class="row row-cols-1 g-4">
<div v-if="props.field.input.options.fontpicker">
<label :for="props.field.input.id+`_font_face_search`" class="form-label">{{ props.field.input.lang.font_family }}</label>
<div class="row g-3 mb-2 justify-content-center">
<div class="col col-auto">
<label :for="props.field.input.id+`_font_face_search`" class="form-label m-0">{{ props.field.input.lang.font_family }}</label>
</div>
<div class="col">
<div class="astroid-btn-group text-end">
<span v-for="fonttype in fonttypes" :key="fonttype">
<input type="radio" class="btn-check" v-model="font_type" :id="props.field.input.id+`_font_type_`+fonttype" :value="fonttype" autocomplete="off">
<label class="btn btn-sm btn-outline-primary btn-as-outline-primary text-capitalize" :for="props.field.input.id+`_font_type_`+fonttype">{{ fonttype }}</label>
</span>
</div>
</div>
</div>
<model-list-select
:list="options"
:list="options[font_type]"
v-model="fontSelected"
option-value="value"
option-text="text"
Expand Down
2 changes: 1 addition & 1 deletion astroid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<libraryname>astroid</libraryname>
<author>Astroid Framework Team</author>
<creationDate>October 2023</creationDate>
<version>3.0.1</version>
<version>3.0.2</version>
<url>https://astroidframe.work/</url>
<copyright>Copyright (C) 2023 TemPlaza, Inc. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
Expand Down
4 changes: 2 additions & 2 deletions astroid_framework.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<updates>
<update>
<name>Astroid Framework</name>
<version>3.0.1</version>
<version>3.0.2</version>
<infourl title="Astroid Framework">https://astroidframe.work/</infourl>
<element>astroid</element>
<type>library</type>
<client>0</client>
<downloads>
<downloadurl type="full" format="zip">https://github.com/templaza/astroid-framework/releases/download/v3.0.1/astroid-framework-3.0.1.zip</downloadurl>
<downloadurl type="full" format="zip">https://github.com/templaza/astroid-framework/releases/download/v3.0.2/astroid-framework-3.0.2.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
Expand Down
4 changes: 2 additions & 2 deletions framework/library/astroid/Element/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function __construct($data, $section, $row)
{
$this->section = $section;
$this->row = $row;
if (is_int($data['size'])) {
$tmp = $data['size'];
if (is_int($data['size']) || is_string($data['size'])) {
$tmp = intval($data['size']);
$this->size = [
'xxl' => $tmp,
'xl' => $tmp,
Expand Down
2 changes: 1 addition & 1 deletion framework/library/astroid/Helper/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Constants
{
public static $astroid_version = '3.0.1';
public static $astroid_version = '3.0.2';
public static $fontawesome_version = '6.4.2';
public static $animatecss_version = '3.7.0';
public static $forum_link = 'https://github.com/templaza/astroid-framework/issues';
Expand Down
25 changes: 18 additions & 7 deletions framework/library/astroid/Helper/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,23 @@ public static function getAllFonts()
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$googleFonts = self::googleFonts();
$rt_fonts = array([
'value' => '__default',
'text' => \JText::_('TPL_ASTROID_OPTIONS_DEFAULT')
]);
$rt_fonts = array(
'system' => array([
'value' => '__default',
'text' => \JText::_('TPL_ASTROID_OPTIONS_DEFAULT')
]),
'google' => array([
'value' => '__default',
'text' => \JText::_('TPL_ASTROID_OPTIONS_DEFAULT')
]),
'local' => array([
'value' => '__default',
'text' => \JText::_('TPL_ASTROID_OPTIONS_DEFAULT')
])
);

foreach (self::$system_fonts as $name => $system_font) {
$rt_fonts[] = [
$rt_fonts['system'][] = [
'value' => $name,
'text' => $system_font
];
Expand All @@ -88,7 +99,7 @@ public static function getAllFonts()

if (!empty($uploadedFonts)) {
foreach ($uploadedFonts as $uploaded_font) {
$rt_fonts[] = [
$rt_fonts['local'][] = [
'value' => $uploaded_font['id'],
'text' => $uploaded_font['name']
];
Expand All @@ -97,7 +108,7 @@ public static function getAllFonts()

foreach ($googleFonts as $group => $fonts) {
foreach ($fonts as $fontValue => $font) {
$rt_fonts[] = [
$rt_fonts['google'][] = [
'value' => $fontValue,
'text' => $font
];
Expand Down
4 changes: 2 additions & 2 deletions plugins/astroid/astroid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<extension version="3.1" type="plugin" method="upgrade" group="system">
<name>Astroid Plugin</name>
<author>Astroid Framework Team</author>
<creationDate>June 2023</creationDate>
<version>2.6.6</version>
<creationDate>October 2023</creationDate>
<version>3.0.2</version>
<url>https://www.astroidframe.work</url>
<copyright>Copyright (C) 2023 TemPlaza, Inc. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
Expand Down

0 comments on commit 27e2875

Please sign in to comment.