Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resize handlers to sides of widgets #394

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
dragboardCover.style.top = "0";
dragboardCover.style.left = "0";
dragboardCover.style.width = "100%";
dragboardCover.style.cursor = handleElement.dataset.cursor;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep the cursor when resizing, I need a way to pass the cursor type to the cover. This solution might not be the cleanest but I found that better than passing it through 3 levels

dragboardCover.style.height = dragboard.scrollHeight + "px";

scrollStart = dragboard.scrollTop;
Expand Down
8 changes: 8 additions & 0 deletions src/wirecloud/commons/utils/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,14 @@ def bottom_left_handle(self):
@property
def bottom_right_handle(self):
return WebElementTester(self.testcase, self.find_element(".wc-bottom-right-resize-handle"))

@property
def left_side_handle(self):
return WebElementTester(self.testcase, self.find_element(".wc-left-side-resize-handle"))

@property
def right_side_handle(self):
return WebElementTester(self.testcase, self.find_element(".wc-right-side-resize-handle"))

@property
def content(self):
Expand Down
84 changes: 50 additions & 34 deletions src/wirecloud/defaulttheme/static/css/workspace/widget.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,44 +106,60 @@
}
}

.wc-widget .wc-bottom-resize-handle {
position: absolute;
height: 12px;
bottom: -6px;
left: 34px;
right: 34px;
cursor: s-resize;
}
.wc-widget {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just nested the resize elements

.wc-bottom-resize-handle {
position: absolute;
height: 12px;
bottom: -6px;
left: 34px;
right: 34px;
cursor: s-resize;
}

.wc-widget .wc-bottom-left-resize-handle {
position: absolute;
width: 40px;
height: 12px;
bottom: -6px;
left: -6px;
cursor: sw-resize;
.wc-bottom-left-resize-handle {
position: absolute;
height: 12px;
width: 40px;
bottom: -6px;
left: -6px;
cursor: sw-resize;
}

&.inUse {
right: 0px;
top: 0px;
bottom: auto;
left: auto;
.wc-bottom-right-resize-handle {
position: absolute;
height: 12px;
width: 40px;
bottom: -6px;
right: -6px;
cursor: se-resize;
}

.wc-right-side-resize-handle {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and new styles for the side handlers

position: absolute;
width: 12px;
height: 100%;
right: -6px;
cursor: e-resize;
}
}

.wc-widget .wc-bottom-right-resize-handle {
position: absolute;
width: 40px;
height: 12px;
bottom: -6px;
right: -6px;
cursor: se-resize;

&.inUse {
left: 0px;
top: 0px;
bottom: auto;
right: auto;
.wc-left-side-resize-handle {
position: absolute;
width: 12px;
height: 100%;
left: -6px;
cursor: w-resize;
}

.wc-bottom-left-resize-handle,
.wc-bottom-right-resize-handle,
.wc-right-side-resize-handle,
.wc-left-side-resize-handle {
&.inUse {
right: 0px;
top: 0px;
bottom: auto;
left: auto;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="fade panel panel-default">
<div class="wc-widget-heading panel-heading"><h4 class="panel-title"><t:title/></h4><div class="wc-widget-infobuttons"><t:errorbutton/></div><div class="wc-widget-buttons"><t:minimizebutton/><t:menubutton/><t:closebutton/></div></div>
<div class="wc-widget-body"><t:iframe/></div>
<t:leftsideresizehandle/><t:rightsideresizehandle/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put them outside the body because the body has overflow: hidden so the 6px outside would not work. This seems to work pretty well

<div class="wc-widget-footer panel-footer"><t:leftresizehandle/><t:bottomresizehandle/><t:rightresizehandle/></div>
</div>
</s:styledgui>
36 changes: 27 additions & 9 deletions src/wirecloud/platform/static/js/wirecloud/ui/WidgetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@

handle.addClassName("wc-bottom-resize-handle");
handle.setDisabled(!view.model.isAllowed('resize'));
handle.get().dataset.cursor = 's-resize';
view.bottomresizehandle = handle;
return handle;
},
Expand All @@ -177,6 +178,7 @@

handle.addClassName("wc-bottom-left-resize-handle");
handle.setDisabled(!view.model.isAllowed('resize'));
handle.get().dataset.cursor = 'sw-resize';
view.leftresizehandle = handle;
return handle;
},
Expand All @@ -185,23 +187,39 @@

handle.addClassName("wc-bottom-right-resize-handle");
handle.setDisabled(!view.model.isAllowed('resize'));
handle.get().dataset.cursor = 'se-resize';
view.rightresizehandle = handle;
return handle;
},
'leftsideresizehandle': function (options, tcomponents, view) {
var handle = new Wirecloud.ui.WidgetViewResizeHandle(view, {resizeLeftSide: true, fixHeight: true});

handle.addClassName("wc-left-side-resize-handle");
handle.setDisabled(!view.model.isAllowed('resize'));
handle.get().dataset.cursor = 'w-resize';
view.leftsideresizehandle = handle;
return handle;
},
'rightsideresizehandle': function (options, tcomponents, view) {
var handle = new Wirecloud.ui.WidgetViewResizeHandle(view, {resizeLeftSide: false, fixHeight: true});

handle.addClassName("wc-right-side-resize-handle");
handle.setDisabled(!view.model.isAllowed('resize'));
handle.get().dataset.cursor = 'e-resize';
view.rightsideresizehandle = handle;
return handle;
},
'iframe': function (options, tcomponents, view) {
return view.model.wrapperElement;
}
}, this).children[1];

if ('bottomresizehandle' in this) {
this.bottomresizehandle.setResizableElement(this.wrapperElement);
}
if ('leftresizehandle' in this) {
this.leftresizehandle.setResizableElement(this.wrapperElement);
}
if ('rightresizehandle' in this) {
this.rightresizehandle.setResizableElement(this.wrapperElement);
}
['bottomresizehandle', 'leftresizehandle', 'rightresizehandle',
'rightsideresizehandle', 'leftsideresizehandle'].forEach(handle => {
if (handle in this) {
this[handle].setResizableElement(this.wrapperElement);
}
});

this.wrapperElement.classList.add("wc-widget");
this.wrapperElement.setAttribute('data-id', model.id);
Expand Down