Commit 2a9211b3 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Robert Lyon

Bug 1813987: removing helper functions to reorder cells in old layout

they won't be needed anymore

also remove use of properties
private $dirtyrows;
private $dirtycolumns;

Change-Id: I31e0c8296e72e9dd6b2381170864bdc52af766b7
parent 5f57b602
...@@ -839,10 +839,6 @@ class BlockInstance { ...@@ -839,10 +839,6 @@ class BlockInstance {
private $row; private $row;
private $column; private $column;
private $order; private $order;
private $canmoveleft;
private $canmoveright;
private $canmoveup;
private $canmovedown;
private $maxorderincolumn; private $maxorderincolumn;
private $artefacts = array(); private $artefacts = array();
private $temp = array(); private $temp = array();
...@@ -1150,7 +1146,6 @@ class BlockInstance { ...@@ -1150,7 +1146,6 @@ class BlockInstance {
global $USER; global $USER;
safe_require('blocktype', $this->get('blocktype')); safe_require('blocktype', $this->get('blocktype'));
$movecontrols = array();
$this->inedit = true; $this->inedit = true;
$blocktypeclass = generate_class_name('blocktype', $this->get('blocktype')); $blocktypeclass = generate_class_name('blocktype', $this->get('blocktype'));
try { try {
...@@ -1193,45 +1188,6 @@ class BlockInstance { ...@@ -1193,45 +1188,6 @@ class BlockInstance {
$js = ''; $js = '';
$css = ''; $css = '';
} }
if (!defined('JSON') && !$jsreply) {
if ($this->get('canmoveleft')) {
$movecontrols[] = array(
'column' => $this->get('column') - 1,
'order' => $this->get('order'),
'title' => $title == '' ? get_string('movethisblockleft', 'view') : get_string('moveblockleft', 'view', "'$title'"),
'arrow' => "icon icon-long-arrow-alt-left",
'dir' => 'left',
);
}
if ($this->get('canmovedown')) {
$movecontrols[] = array(
'column' => $this->get('column'),
'order' => $this->get('order') + 1,
'title' => $title == '' ? get_string('movethisblockdown', 'view') : get_string('moveblockdown', 'view', "'$title'"),
'arrow' => 'icon icon-long-arrow-alt-down',
'dir' => 'down',
);
}
if ($this->get('canmoveup')) {
$movecontrols[] = array(
'column' => $this->get('column'),
'order' => $this->get('order') - 1,
'title' => $title == '' ? get_string('movethisblockup', 'view') : get_string('moveblockup', 'view', "'$title'"),
'arrow' => 'icon icon-long-arrow-alt-up',
'dir' => 'up',
);
}
if ($this->get('canmoveright')) {
$movecontrols[] = array(
'column' => $this->get('column') + 1,
'order' => $this->get('order'),
'title' => $title == '' ? get_string('movethisblockright', 'view') : get_string('moveblockright', 'view', "'$title'"),
'arrow' => 'icon icon-long-arrow-alt-right',
'dir' => 'right',
);
}
}
} }
$configtitle = $title == '' ? call_static_method($blocktypeclass, 'get_title') : $title; $configtitle = $title == '' ? call_static_method($blocktypeclass, 'get_title') : $title;
...@@ -1245,7 +1201,6 @@ class BlockInstance { ...@@ -1245,7 +1201,6 @@ class BlockInstance {
$smarty->assign('column', $this->get('column')); $smarty->assign('column', $this->get('column'));
$smarty->assign('order', $this->get('order')); $smarty->assign('order', $this->get('order'));
$smarty->assign('blocktype', $this->get('blocktype')); $smarty->assign('blocktype', $this->get('blocktype'));
$smarty->assign('movecontrols', $movecontrols);
$smarty->assign('configurable', call_static_method($blocktypeclass, 'has_instance_config')); $smarty->assign('configurable', call_static_method($blocktypeclass, 'has_instance_config'));
$smarty->assign('configure', $configure); // Used by the javascript to rewrite the block, wider. $smarty->assign('configure', $configure); // Used by the javascript to rewrite the block, wider.
$smarty->assign('configtitle', $configtitle); $smarty->assign('configtitle', $configtitle);
......
...@@ -275,16 +275,10 @@ ...@@ -275,16 +275,10 @@
// Rewrite the delete buttons to be ajax // Rewrite the delete buttons to be ajax
rewriteDeleteButtons(); rewriteDeleteButtons();
// Show the keyboard-accessible ajax move buttons
rewriteMoveButtons();
// Setup the 'add block' dialog // Setup the 'add block' dialog
setupPositionBlockDialog(); setupPositionBlockDialog();
showColumnBackgroundsOnSort();
makeNewBlocksDraggable(); makeNewBlocksDraggable();
makeExistingBlocksSortable();
$(workspace).show(); $(workspace).show();
...@@ -357,7 +351,6 @@ ...@@ -357,7 +351,6 @@
sendjsonrequest(config['wwwroot'] + 'view/blocks.json.php', pd, 'POST', function(data) { sendjsonrequest(config['wwwroot'] + 'view/blocks.json.php', pd, 'POST', function(data) {
$(category).html(data.data); $(category).html(data.data);
makeNewBlocksDraggable(); makeNewBlocksDraggable();
showColumnBackgroundsOnSort();
// the column has changed size, pass on to listeners // the column has changed size, pass on to listeners
$(window).trigger('colresize'); $(window).trigger('colresize');
...@@ -429,7 +422,6 @@ ...@@ -429,7 +422,6 @@
$('.blocktype-drag').draggable({ $('.blocktype-drag').draggable({
start: function(event, ui) { start: function(event, ui) {
showColumnBackgrounds();
$(window).trigger('colresize'); $(window).trigger('colresize');
}, },
helper: function(event) { helper: function(event) {
...@@ -445,8 +437,6 @@ ...@@ -445,8 +437,6 @@
}, },
connectToSortable: '.js-col-row .column .column-content', connectToSortable: '.js-col-row .column .column-content',
stop: function(event, ui) { stop: function(event, ui) {
// see also showColumnBackgroundsOnSort for clicking in place without dragging
hideColumnBackgrounds();
}, },
appendTo: 'body' appendTo: 'body'
}); });
...@@ -489,75 +479,6 @@ ...@@ -489,75 +479,6 @@
} }
} }
function makeExistingBlocksSortable() {
// Make existing and new blocks sortable
$('.column .column-content').sortable({
handle: '.js-heading',
items: '.js-blockinstance',
cursorAt: {left: 100, top: 10},
connectWith: '.js-col-row .column .column-content',
placeholder: 'block-placeholder',
tolerance: "pointer",
activate: function(event, ui) {
// Fix for dragging blocks to narrow divs:
// Wide elements must be centred on narrow divs to make droppable.
// This is not always evident to the user.
// Instead set a standard small width when starting to sort.
// Dynamically setting width on over event doesn't work, as
// Sortable seems to cache helper proportions.
// Also if height of dragging block is greater than height
// row(s) above it then it can't be dropped in that row.
// Could use a custom version of Sortable in future?
ui.helper.width(200);
ui.helper.height('auto');
},
beforeStop: function(event, ui) {
var whereTo = getBlockinstanceCoordinates(ui.helper);
if (ui.helper.find('.blocktype-radio').length) {
addNewBlock(whereTo, ui.helper.find('input.blocktype-radio').val());
$('.ui-draggable-dragging').remove();
} else {
//move existing block
var uihId = ui.helper.attr('id'),
blockinstanceId = uihId.substr(uihId.lastIndexOf('_') + 1);
moveBlock(whereTo, blockinstanceId);
}
window.setTimeout(function(){
$(window).trigger('colresize');
}, 300);
},
update: function(event, ui) {
$('.js-col-row .column-content').each(function() {
$(this).css('min-height', '');
});
},
start: function(event, ui) {
// Fix for dragging blocks to narrow divs:
// Wide elements must be centred on narrow divs to make droppable.
// This is not always evident to the user.
// Instead set a standard small width when starting to sort.
// Dynamically setting width on over event doesn't work, as
// Sortable seems to cache helper proportions.
// Also if height of dragging block is greater than height
// row(s) above it then it can't be dropped in that row.
// Could use a custom version of Sortable in future?
ui.helper.width($(this).outerWidth());
ui.helper.height($(this).find('.drag-handle').outerHeight());
}
});
} // end of makeNewBlocksSortable()
function cellChanged() { function cellChanged() {
$(this).closest('.js-cell-chooser').find('.active').removeClass('active'); $(this).closest('.js-cell-chooser').find('.active').removeClass('active');
...@@ -629,25 +550,6 @@ ...@@ -629,25 +550,6 @@
}); });
} }
function showColumnBackgrounds() {
$('.js-col-row .column-content').addClass('block-drop-on', 100);
}
function hideColumnBackgrounds() {
$('.js-col-row .column-content').removeClass('block-drop-on', 500);
}
function showColumnBackgroundsOnSort() {
$('.blockinstance .blockinstance-header, .blocktype-list .blocktype').on("mousedown", function() {
showColumnBackgrounds();
});
$('.blockinstance .blockinstance-header, .blocktype-list .blocktype').on("mouseup", function() {
hideColumnBackgrounds();
});
}
function insertBlockStub(newblock, whereTo) { function insertBlockStub(newblock, whereTo) {
var columnContent = $('#row_'+whereTo['row']+'_column_'+whereTo['column']).find('div.column-content'); var columnContent = $('#row_'+whereTo['row']+'_column_'+whereTo['column']).find('div.column-content');
if (whereTo['order'] == 1) { if (whereTo['order'] == 1) {
...@@ -755,84 +657,6 @@ ...@@ -755,84 +657,6 @@
}); });
} }
/*
* Shows all keyboard-accessible ajax move buttons
*/
function rewriteMoveButtons() {
rewriteMoveButton(workspace.find('.keyboardmovebutton'));
}
/*
* Shows and sets up one keyboard-accessible ajax move button
*
*/
function rewriteMoveButton(button) {
button.removeClass('d-none');
button.on('click', function(e) {
e.stopPropagation();
e.preventDefault();
computeColumnInputs($('#newblock'));
var self = $(this),
addblockdialog = $('#newblock').removeClass('d-none');
prevcell = self.closest('.column-content'),
order = prevcell.children().index(self.closest('.blockinstance')),
row = workspace.find('.js-col-row').index(self.closest('.js-col-row')),
column = self.closest('.js-col-row').children().index(self.closest('.column')),
radio = addblockdialog.find('.cell-chooser').children().eq(row).find('input').eq(column),
changefunction = function() {
if (radio.prop('checked')) {
$('#newblock_position option').eq(order + 1).remove();
}
};
radio.on('change', changefunction);
radio.prop('checked', true).trigger('change');
$('#newblock_position').prop('selectedIndex', order);
addblockdialog.one('dialog.end', function(event, options) {
if (options.saved) {
var blockinstanceId = self.attr('data-id'),
newcell,
currentblock,
lastindex;
moveBlock(options, blockinstanceId);
newcell = workspace.find('.js-col-row').eq(options['row'] - 1)
.find('.column-content').eq(options['column'] - 1);
currentblock = self.closest('.blockinstance');
lastindex = newcell.children().length;
if (newcell[0] == prevcell[0]) {
lastindex -= 1;
}
newcell.append(currentblock);
options['order'] -= 1;
if (options['order'] < lastindex) {
newcell.children().eq(options['order']).before(newcell.children().last());
}
}
radio.off('change', changefunction);
self.trigger("focus");
});
addblockdialog.find('h4.modal-title').text(self.attr('alt'));
addblockdialog.find('.deletebutton').trigger("focus");
keytabbinginadialog(addblockdialog, addblockdialog.find('.deletebutton'), addblockdialog.find('.cancel'));
});
}
function computeColumnInputs(dialog) { function computeColumnInputs(dialog) {
var inputcontainer = dialog.find('.blockinstance-content #newblock_cellchooser_container'), var inputcontainer = dialog.find('.blockinstance-content #newblock_cellchooser_container'),
result = $('<div>').addClass('cell-chooser js-cell-chooser'), result = $('<div>').addClass('cell-chooser js-cell-chooser'),
...@@ -911,7 +735,6 @@ ...@@ -911,7 +735,6 @@
if (data.data.html) { if (data.data.html) {
$('#blockinstance_' + instanceId + ' .blockinstance-content').html(data.data.html); $('#blockinstance_' + instanceId + ' .blockinstance-content').html(data.data.html);
} }
hideColumnBackgrounds();
}); });
} }
......
...@@ -108,7 +108,6 @@ $string['notinthesamegroup'] = 'You cannot view this user\'s profile because you ...@@ -108,7 +108,6 @@ $string['notinthesamegroup'] = 'You cannot view this user\'s profile because you
$string['notinthesameinstitution'] = 'You cannot view this user\'s profile because you are not members of the same institution.'; $string['notinthesameinstitution'] = 'You cannot view this user\'s profile because you are not members of the same institution.';
$string['notinstitutionmember'] = 'You cannot view this page because you are not a member of the institution to which this page belongs.'; $string['notinstitutionmember'] = 'You cannot view this page because you are not a member of the institution to which this page belongs.';
$string['invalidlayoutselection'] = 'You tried to select a layout that doesn\'t exist.'; $string['invalidlayoutselection'] = 'You tried to select a layout that doesn\'t exist.';
$string['invalidnumrows'] = 'You have tried to create a layout with more than the allowed maximum number of rows. (This should not be possible; please notify your site\'s administrator.)';
$string['previewimagegenerationfailed'] = 'Sorry, there was a problem generating the preview image.'; $string['previewimagegenerationfailed'] = 'Sorry, there was a problem generating the preview image.';
$string['viewtemplatenotfound'] = 'Default page template not found.'; $string['viewtemplatenotfound'] = 'Default page template not found.';
...@@ -126,8 +125,6 @@ $string['invalidviewaction'] = 'Invalid page control action: %s'; ...@@ -126,8 +125,6 @@ $string['invalidviewaction'] = 'Invalid page control action: %s';
$string['invaliduser'] = 'Invalid user selected'; $string['invaliduser'] = 'Invalid user selected';
$string['missingparamblocktype'] = 'Try selecting a block type to add first.'; $string['missingparamblocktype'] = 'Try selecting a block type to add first.';
$string['missingparamcolumn'] = 'Missing column specification';
$string['missingparamrow'] = 'Missing row specification';
$string['missingparamorder'] = 'Missing order specification'; $string['missingparamorder'] = 'Missing order specification';
$string['missingparamid'] = 'Missing id'; $string['missingparamid'] = 'Missing id';
......
...@@ -326,14 +326,6 @@ $string['add'] = 'Add'; ...@@ -326,14 +326,6 @@ $string['add'] = 'Add';
$string['addcolumn'] = 'Add column'; $string['addcolumn'] = 'Add column';
$string['remove'] = 'Remove'; $string['remove'] = 'Remove';
$string['removecolumn'] = 'Remove this column'; $string['removecolumn'] = 'Remove this column';
$string['moveblockleft'] = "Move %s block left";
$string['movethisblockleft'] = "Move this block left";
$string['moveblockdown'] = "Move %s block down";
$string['movethisblockdown'] = "Move this block down";
$string['moveblockup'] = "Move %s block up";
$string['movethisblockup'] = "Move this block up";
$string['moveblockright'] = "Move %s block right";
$string['movethisblockright'] = "Move this block right";
$string['moveblock2'] = 'Move block'; $string['moveblock2'] = 'Move block';
$string['moveblock'] = 'Move %s block'; $string['moveblock'] = 'Move %s block';
$string['movethisblock'] = 'Move this block'; $string['movethisblock'] = 'Move this block';
...@@ -350,7 +342,6 @@ $string['celltitle'] = 'Cell'; ...@@ -350,7 +342,6 @@ $string['celltitle'] = 'Cell';
$string['basicoptions'] = 'Basic options'; $string['basicoptions'] = 'Basic options';
$string['advancedoptions'] = 'Advanced options'; $string['advancedoptions'] = 'Advanced options';
$string['changecolumnlayoutfailed'] = 'Could not change the column layout. Someone else may have been editing the layout at the same time. Please try again later.';
$string['Row'] = 'Row'; $string['Row'] = 'Row';
$string['layoutpreviewimage'] = 'Layout preview image'; $string['layoutpreviewimage'] = 'Layout preview image';
...@@ -368,8 +359,6 @@ $string['column'] = 'column'; ...@@ -368,8 +359,6 @@ $string['column'] = 'column';
$string['row'] = 'row'; $string['row'] = 'row';
$string['columns'] = 'columns'; $string['columns'] = 'columns';
$string['rows'] = 'rows'; $string['rows'] = 'rows';
$string['cantaddcolumn'] = 'You cannot add any more columns to this page.';
$string['cantremovecolumn'] = 'You cannot remove the last column from this page.';
$string['blocktypecategory.external'] = 'External'; $string['blocktypecategory.external'] = 'External';
$string['blocktypecategory.fileimagevideo'] = 'Media'; $string['blocktypecategory.fileimagevideo'] = 'Media';
......
This diff is collapsed.
...@@ -12,11 +12,6 @@ ...@@ -12,11 +12,6 @@
<button class="keyboardmovebutton btn btn-secondary d-none sr-only" name="action_moveblockinstance_id_{$id}" alt="{$strmovetitletext}" data-id="{$id}"> <button class="keyboardmovebutton btn btn-secondary d-none sr-only" name="action_moveblockinstance_id_{$id}" alt="{$strmovetitletext}" data-id="{$id}">
{$strmovetitletext} {$strmovetitletext}
</button> </button>
{foreach from=$movecontrols item=item}
<button class="movebutton d-none" name="action_moveblockinstance_id_{$id}_row_{$row}_column_{$item.column}_order_{$item.order}" data-id="{$id}">
{$item.title}
</button>
{/foreach}
<span class="float-right btn-group btn-group-top"> <span class="float-right btn-group btn-group-top">
{if $configurable && !$configure} {if $configurable && !$configure}
<button class="configurebutton btn btn-inverse btn-sm" name="action_configureblockinstance_id_{$id}" alt="{$strconfigtitletext}" data-id="{$id}"> <button class="configurebutton btn btn-inverse btn-sm" name="action_configureblockinstance_id_{$id}" alt="{$strconfigtitletext}" data-id="{$id}">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment