From 8b860665b0d5129fb687ea493d9235b78b4028e2 Mon Sep 17 00:00:00 2001 From: joomlart Date: Sat, 30 Nov 2013 18:14:05 +0700 Subject: [PATCH] ThemeMagic: Fix custom font --- .../admin/thememagic/js/thememagic.js | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/source/plg_system_t3/admin/thememagic/js/thememagic.js b/source/plg_system_t3/admin/thememagic/js/thememagic.js index 9df2b2bb31..a552ce2c3f 100644 --- a/source/plg_system_t3/admin/thememagic/js/thememagic.js +++ b/source/plg_system_t3/admin/thememagic/js/thememagic.js @@ -366,6 +366,15 @@ var T3Theme = window.T3Theme || {}; return vals; }, + + elmsFrom: function(name){ + var el = document.adminForm[name]; + if(!el){ + el = document.adminForm[name + '[]']; + } + + return $(el); + }, setValues: function(el, vals){ var jel = $(el); @@ -374,7 +383,25 @@ var T3Theme = window.T3Theme || {}; jel.val(vals); if($.makeArray(jel.val())[0] != vals[0]){ - jel.val('-1'); + + if(T3Theme.placeholder && T3Theme.data.base[T3Theme.getName(el)] == vals[0]){ + jel.val('-1'); + } else { + var name = T3Theme.getName(el), + celm = T3Theme.elmsFrom('t3form[thememagic][' + name + '-custom]'); + + if(!celm.length){ + celm = T3Theme.elmsFrom('t3form[thememagic][' + name + '_custom]'); + } + + if(celm.length){ + jel.val('undefined').trigger('change.depend'); + + //T3Theme.setValues(celm, vals); + } else { + jel.val('-1'); + } + } } }else { if(jel.prop('type') == 'checkbox' || jel.prop('type') == 'radio'){ @@ -486,7 +513,7 @@ var T3Theme = window.T3Theme || {}; }, getName: function(el){ - var matches = el.name.match('t3form\\[thememagic\\]\\[([^\\]]*)\\]'); + var matches = (el.name || el[0].name).match('t3form\\[thememagic\\]\\[([^\\]]*)\\]'); if (matches){ return matches[1]; }