Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

fix layout issue when drop from archive #188

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 50 additions & 47 deletions assets/javascripts/aqpb.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ jQuery(document).ready(function($){
minWidth: 104,
resize: function(event, ui) {
ui.helper.css("position", "relative"); // bug
ui.helper.css("height", "inherit");
ui.helper.css("top", "0"); // bug
ui.helper.css("left", "0"); // bug
ui.helper.css("margin-left", ui.position.left + 20 + "px");
ui.helper.css("height", "inherit");
ui.helper.css("top", "0"); // bug
ui.helper.css("left", "0"); // bug
ui.helper.css("margin-left", ui.position.left + 20 + "px");
},
stop: function(event, ui) {
ui.helper.css('left', ui.originalPosition.left);
ui.helper.removeClass (function (index, css) {
return (css.match (/\bspan\S+/g) || []).join(' ');
return (css.match (/\bspan\S+/g) || []).join(' ');
}).addClass(block_size( $(ui.helper).css('width') ));
ui.helper.find('> div > .size').val(block_size( $(ui.helper).css('width') ));
ui.helper.css("margin-left", "");
Expand All @@ -49,13 +49,13 @@ jQuery(document).ready(function($){
/** create unique id **/
function makeid()
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

for( var i=0; i < 5; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
for( var i=0; i < 5; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));

return text;
return text;
}

/** Get correct class for block size **/
Expand Down Expand Up @@ -223,42 +223,45 @@ jQuery(document).ready(function($){

//if coming from archive
if (ui.item.hasClass('ui-draggable')) {


// set height to auto
ui.item.css('height', 'auto');

//remove draggable class
ui.item.removeClass('ui-draggable');
//set random block id
block_number = makeid();
//replace id
ui.item.html(ui.item.html().replace(/<[^<>]+>/g, function(obj) {
return obj.replace(/__i__|%i%/g, block_number)
}));
ui.item.attr("id", block_archive.replace("__i__", block_number));
//if column, remove handle bar
if(ui.item.hasClass('block-container')) {
ui.item.find('.block-bar').remove();
ui.item.find('.block-settings').removeClass('block-settings').addClass('block-settings-column');
}
//init resize on newly added block
ui.item.resizable(resizable_args);
//set dynamic width for blocks inside columns
resizable_dynamic_width(ui.item.attr('id'));
//trigger resize
ui.item.trigger("resize");
ui.item.trigger("resizestop");
//open on drop
ui.item.find('a.block-edit').click();
//disable resizable on .not-resizable blocks
$(".ui-resizable.not-resizable").resizable("destroy");
ui.item.removeClass('ui-draggable');
//set random block id
block_number = makeid();
//replace id
ui.item.html(ui.item.html().replace(/<[^<>]+>/g, function(obj) {
return obj.replace(/__i__|%i%/g, block_number)
}));
ui.item.attr("id", block_archive.replace("__i__", block_number));
//if column, remove handle bar
if(ui.item.hasClass('block-container')) {
ui.item.find('.block-bar').remove();
ui.item.find('.block-settings').removeClass('block-settings').addClass('block-settings-column');
}
//init resize on newly added block
ui.item.resizable(resizable_args);
//set dynamic width for blocks inside columns
resizable_dynamic_width(ui.item.attr('id'));
//trigger resize
ui.item.trigger("resize");
ui.item.trigger("resizestop");
//open on drop
ui.item.find('a.block-edit').click();
//disable resizable on .not-resizable blocks
$(".ui-resizable.not-resizable").resizable("destroy");
}

//if moving column inside column, cancel it
Expand Down Expand Up @@ -294,8 +297,8 @@ jQuery(document).ready(function($){
ui.draggable.parent().find('.placeholder').show();
},
drop: function(ev, ui) {
ui.draggable.remove();
$(this).find('#removing-block').fadeOut('fast');
ui.draggable.remove();
$(this).find('#removing-block').fadeOut('fast');
}
});

Expand Down