Skip to content

Commit

Permalink
T3Layout: List all positions in all templates and database to user
Browse files Browse the repository at this point in the history
  • Loading branch information
joomlart committed Aug 2, 2013
1 parent c83b384 commit c60808f
Show file tree
Hide file tree
Showing 5 changed files with 330 additions and 159 deletions.
8 changes: 4 additions & 4 deletions source/plg_system_t3/admin/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,13 @@ var T3Admin = window.T3Admin || {};

var jgroup = jinput.closest('.control-group'),
jpane = jgroup.closest('.tab-pane'),
chretain = Math.max(0, (jgroup.data('chretain') || 0) + (eq ? -1 : 1));
chretain = Math.max(0, (jgroup.data('chretain') || 0) + (!eq && jinput.data('included') ? 0 : (eq ? -1 : 1)));

jgroup.data('chretain', chretain)
[chretain ? 'addClass' : 'removeClass']('t3-changed');
jgroup.data('chretain', chretain).toggleClass('t3-changed', !!(chretain));

$('.t3-admin-nav .nav li').eq(jpane.index())[(!eq || jpane.find('.t3-changed').length) ? 'addClass' : 'removeClass']('t3-changed');
$('.t3-admin-nav .nav li').eq(jpane.index()).toggleClass('t3-changed', !!(!eq || jpane.find('.t3-changed').length));

jinput.data('included', !eq);
});
}, 500);
},
Expand Down
44 changes: 25 additions & 19 deletions source/plg_system_t3/admin/layout/js/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ var T3AdminLayout = window.T3AdminLayout || {};
T3AdminLayout.jselect = jselect.appendTo(document.body).on('click', function(e){ return false; });
T3AdminLayout.jallpos = jselect.find('select');

jselect.find('select').on('change', function(){
T3AdminLayout.jallpos.on('change', function(){

var curspan = T3AdminLayout.curspan;

if(curspan){
Expand All @@ -150,11 +151,16 @@ var T3AdminLayout = window.T3AdminLayout || {};
}

$(this)
.next('.t3-admin-layout-rmvbtn')[this.value ? 'removeClass' : 'addClass']('disabled')
.next('.t3-admin-layout-defbtn')[this.value != $(curspan).closest('[data-original]').attr('data-original') ? 'removeClass' : 'addClass']('disabled');
.next('.t3-admin-layout-rmvbtn').toggleClass('disabled', !this.value)
.next('.t3-admin-layout-defbtn').toggleClass('disabled', this.value == $(curspan).closest('[data-original]').attr('data-original'));
}

return false;
}).on('mousedown', 'optgroup', function(e){

if(e.target && e.target.tagName.toLowerCase() == 'optgroup'){
return false;
}
});

jselect.find('.t3-admin-layout-rmvbtn, .t3-admin-layout-defbtn')
Expand Down Expand Up @@ -197,9 +203,9 @@ var T3AdminLayout = window.T3AdminLayout || {};
if(!jgroup.data('chretain')){
var eq = JSON.stringify(T3AdminLayout.t3getlayoutdata()) == T3AdminLayout.curconfig;

jgroup[eq ? 'removeClass' : 'addClass']('t3-changed');
jgroup.toggleClass('t3-changed', !eq);

jtab[!eq || jpane.find('.t3-changed').length ? 'addClass' : 'removeClass']('t3-changed');
jtab.toggleClass('t3-changed', !!(!eq || jpane.find('.t3-changed').length));
}

T3AdminLayout.chsid = setTimeout(check, 1500);
Expand Down Expand Up @@ -849,17 +855,17 @@ var T3AdminLayout = window.T3AdminLayout || {};
jvis.closest('.t3-admin-layout-unit')[state == 0 ? 'show' : 'hide']();

var jhiddenpos = jdata.nextAll('.t3-admin-layout-hiddenpos');
jhiddenpos.children().eq(idx)[state == 0 ? 'addClass' : 'removeClass']('hide');
jhiddenpos[jhiddenpos.children().not('.hide, .t3-hide').length ? 'addClass' : 'removeClass']('has-pos');
jhiddenpos.children().eq(idx).toggleClass('hide', state == 0);
jhiddenpos.toggleClass('has-pos', !!(jhiddenpos.children().not('.hide, .t3-hide').length));
} else {
var jhiddenpos = jpos.next('.t3-admin-layout-hiddenpos');
if(jhiddenpos.length){
jhiddenpos[state == 0 ? 'removeClass' : 'addClass']('has-pos');
jpos[state == 0 ? 'removeClass' : 'addClass']('hide');
jhiddenpos.toggleClass('has-pos', state != 0);
jpos.toggleClass('hide', state != 0);
}
}

jvis.parent()[state == 1 && T3AdminLayout.layout.mode ? 'addClass' : 'removeClass']('pos-hidden');
jvis.parent().toggleClass('pos-hidden', state == 1 && T3AdminLayout.layout.mode);
jvis.children().removeClass('icon-eye-close icon-eye-open').addClass(state == 1 ? 'icon-eye-close' : 'icon-eye-open');
},

Expand Down Expand Up @@ -1060,7 +1066,7 @@ var T3AdminLayout = window.T3AdminLayout || {};

$(this).find('.t3-admin-layout-pos').each(function(idx){
if(original[idx] != undefined){
$(this)[original[idx] == T3Admin.langs.emptyLayoutPosition ? 'addClass' : 'removeClass']('pos-off')
$(this).toggleClass('pos-off', original[idx] == T3Admin.langs.emptyLayoutPosition)
.find('.t3-admin-layout-posname')
.html(original[idx]);

Expand Down Expand Up @@ -1098,8 +1104,8 @@ var T3AdminLayout = window.T3AdminLayout || {};
jvis.closest('.t3-admin-layout-unit')[state == 0 ? 'show' : 'hide']();

var jhiddenpos = jdata.nextAll('.t3-admin-layout-hiddenpos');
jhiddenpos.children().eq(idx)[state == 0 ? 'addClass' : 'removeClass']('hide');
jhiddenpos[jhiddenpos.children().not('.hide, .t3-hide').length ? 'addClass' : 'removeClass']('has-pos');
jhiddenpos.children().eq(idx).toggleClass('hide', state == 0);
jhiddenpos.toggleClass('has-pos', !!(jhiddenpos.children().not('.hide, .t3-hide').length));

var visibleIdxs = [];
for(var i = 0, il = junits.length; i < il; i++){
Expand All @@ -1123,12 +1129,12 @@ var T3AdminLayout = window.T3AdminLayout || {};
} else {
var jhiddenpos = jpos.next('.t3-admin-layout-hiddenpos');
if(jhiddenpos.length){
jhiddenpos[state == 0 ? 'removeClass' : 'addClass']('has-pos');
jpos[state == 0 ? 'removeClass' : 'addClass']('hide');
jhiddenpos.toggleClass('has-pos', state != 0);
jpos.toggleClass('hide', state != 0);
}
}

jpos[state == 1 ? 'addClass' : 'removeClass']('pos-hidden');
jpos.toggleClass('pos-hidden', state == 1);
jvis.children().removeClass('icon-eye-close icon-eye-open').addClass(state == 1 ? 'icon-eye-close' : 'icon-eye-open');

visible[idx] = state;
Expand Down Expand Up @@ -1262,8 +1268,8 @@ var T3AdminLayout = window.T3AdminLayout || {};
}).show()
.find('select')
.val(jspan.siblings('h3').html())
.next('.t3-admin-layout-rmvbtn')[jallpos.val() ? 'removeClass' : 'addClass']('disabled')
.next('.t3-admin-layout-defbtn')[jspan.siblings('h3').html() != jspan.closest('[data-original]').attr('data-original') ? 'removeClass' : 'addClass']('disabled');
.next('.t3-admin-layout-rmvbtn').toggleClass('disabled', !jallpos.val())
.next('.t3-admin-layout-defbtn').toggleClass('disabled', jspan.siblings('h3').html() == jspan.closest('[data-original]').attr('data-original'));

jallpos.scrollTop(Math.min(jallpos.prop('scrollHeight') - jallpos.height(), jallpos.prop('selectedIndex') * (jallpos.prop('scrollHeight') / jallpos[0].options.length)));

Expand Down Expand Up @@ -1329,7 +1335,7 @@ var T3AdminLayout = window.T3AdminLayout || {};
jhcols = jhides.children();

for(var i = 0; i < T3AdminLayout.layout.maxcols; i++){
jhcols.eq(i)[i < numpos ? 'removeClass' : 'addClass']('t3-hide');
jhcols.eq(i).toggleClass('t3-hide', i >= numpos);
}

//temporary calculate the widths for each devices size
Expand Down
2 changes: 1 addition & 1 deletion source/plg_system_t3/admin/layout/layout.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<div class="arrow"></div>
<h3 class="popover-title"><?php echo JTexT::_('T3_LAYOUT_POPOVER_TITLE') ?></h3>
<div class="popover-content">
<?php echo T3AdminLayout::getTplPositions() ?>
<?php echo T3AdminLayout::getPositions() ?>
<button class="t3-admin-layout-rmvbtn btn btn-small"><i class="icon-remove"></i><?php echo JTexT::_('T3_LAYOUT_EMPTY_POSITION') ?></button>
<button class="t3-admin-layout-defbtn btn btn-small btn-success"><i class="icon-ok-circle"></i><?php echo JTexT::_('JDEFAULT') ?></button>
</div>
Expand Down
Loading

0 comments on commit c60808f

Please sign in to comment.