Skip to content

Commit c51e4af

Browse files
committed
Make upload responsive
1 parent 752eba1 commit c51e4af

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

css/cropper/cropper-ui.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.cropper-actions {
22
margin-top: 0.5em;
3-
margin-left: 20px;
43
}
54

65
.cropper-actions label {
@@ -18,6 +17,7 @@
1817
overflow-x: auto;
1918
white-space: nowrap;
2019
scrollbar-width: thin;
20+
margin-bottom: 10px;
2121
}
2222

2323
.cropper-nav-link {
@@ -47,3 +47,11 @@
4747
.cropper-nav-link-hover span {
4848
padding: 2px;
4949
}
50+
51+
.cropper-editor {
52+
width: 100%;
53+
}
54+
55+
.cropper-image {
56+
background-image: url(\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC\');
57+
}

src/WebApp/BootstrapTheme/NewImageUploadRenderer.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace WebApp\BootstrapTheme;
44

5+
use TgI18n\I18N;
56
use WebApp\Utils;
67

78
class NewImageUploadRenderer extends \WebApp\DefaultTheme\DivRenderer {
@@ -46,8 +47,8 @@ public function renderEditor() {
4647
}
4748
$width = $this->component->getWidth();
4849
$height = $this->component->getHeight();
49-
$rc = '<div class="cropper-editor" style="max-width: '.$width.'px; max-height: '.$height.'px; margin: 20px;">'.
50-
'<img data-imgid="'.$did.'" class="cropper-image" style="background-image: url(\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC\'); width: '.$width.'px; height: '.$height.'px;" src="'.$src.'">'.
50+
$rc = '<div class="cropper-editor">'.
51+
'<img data-imgid="'.$did.'" class="cropper-image img-fluid" src="'.$src.'">'.
5152
//$this->renderDocToggles().
5253
'</div>'.
5354
$this->renderActions();
@@ -63,45 +64,45 @@ public function renderActions() {
6364
// '</div>'.
6465
// Mouse Mode
6566
'<div class="btn-group">'.
66-
$this->renderActionButton('cropperUI.setDragMode(this,\'move\');', 'Move', 'Move Help', 'fa fa-arrows-alt').
67-
$this->renderActionButton('cropperUI.setDragMode(this,\'crop\');', 'Crop', 'Crop Help', 'fa fa-crop-alt').
67+
$this->renderActionButton('cropperUI.setDragMode(this,\'move\');', 'move', 'fa fa-arrows-alt').
68+
$this->renderActionButton('cropperUI.setDragMode(this,\'crop\');', 'crop', 'fa fa-crop-alt').
6869
'</div>'.
6970
// No move into directions (yet)!
7071
// Rotate
7172
'<div class="btn-group">'.
72-
$this->renderActionButton('cropperUI.rotate(this,-90);', 'Rotate Left', 'Rotate Help', 'fa fa-undo-alt').
73-
$this->renderActionButton('cropperUI.rotate(this,90);', 'Rotate Right', 'Rotate Help', 'fa fa-redo-alt').
73+
$this->renderActionButton('cropperUI.rotate(this,-90);', 'rotate_left', 'fa fa-undo-alt').
74+
$this->renderActionButton('cropperUI.rotate(this,90);', 'rotate_right', 'fa fa-redo-alt').
7475
'</div>'.
7576
// Flip
7677
'<div class="btn-group">'.
77-
$this->renderActionButton('cropperUI.scaleX(this,-1);', 'Flip Horizontally', 'Flip Help', 'fa fa-arrows-alt-h').
78-
$this->renderActionButton('cropperUI.scaleY(this,-1);', 'Flip Vertically', 'Flip Help', 'fa fa-arrows-alt-v').
78+
$this->renderActionButton('cropperUI.scaleX(this,-1);', 'flip_horizontally', 'fa fa-arrows-alt-h').
79+
$this->renderActionButton('cropperUI.scaleY(this,-1);', 'flip_vertically', 'fa fa-arrows-alt-v').
7980
'</div>'.
8081
// Finish / Cancel
8182
'<div class="btn-group">'.
82-
'<label class="btn btn-primary btn-upload" for="inputImage" title="Upload image file">'.
83+
'<label class="btn btn-primary btn-upload" for="inputImage" title="'.htmlentities(I18N::_('upload_import_help')).'">'.
8384
'<input type="file" class="sr-only" id="inputImage" name="file" accept="image/*">'.
84-
'<span class="docs-tooltip" data-toggle="tooltip" title="" data-original-title="Import image">'.
85+
'<span class="docs-tooltip" data-toggle="tooltip" title="" data-original-title="'.htmlentities(I18N::_('upload_import_help')).'">'.
8586
'<span class="fa fa-upload"></span>'.
8687
'</span>'.
8788
'</label>'.
88-
$this->renderActionButton('cropperUI.reset(this);', 'Reset Changes', 'Reset Help', 'fa fa-trash-restore-alt').
89+
$this->renderActionButton('cropperUI.reset(this);', 'reset', 'fa fa-trash-restore-alt').
8990
'</div>'.
9091
// Delete
9192
'<div class="btn-group">'.
92-
$this->renderActionButton('cropperUI.delete(this);', 'Delete', 'Delete Help', 'fa fa-trash-alt', 'danger').
93+
$this->renderActionButton('cropperUI.delete(this);', 'delete', 'fa fa-trash-alt', 'danger').
9394
'</div>'.
9495
'<div class="btn-group">'.
95-
// $this->renderActionButton('cropperUI.info(this);', 'Info', 'Info Help', 'fa fa-info', 'secondary').
96-
$this->renderActionButton('cropperUI.save(this);', 'Save', 'Save Help', 'fa fa-save', 'success').
96+
// $this->renderActionButton('cropperUI.info(this);', 'Info', 'fa fa-info', 'secondary').
97+
$this->renderActionButton('cropperUI.save(this);', 'save', 'fa fa-save', 'success').
9798
'</div>'.
9899
'</div>';
99100
return $rc;
100101
}
101102

102-
public function renderActionButton($click, $title, $help, $icon, $type = 'primary') {
103-
$rc = '<button type="button" class="btn btn-'.$type.'" onClick="'.$click.'" title="'.htmlentities($title).'">'.
104-
'<span class="docs-tooltip" data-toggle="tooltip" title="" data-original-title="'.htmlentities($help).'">'.
103+
public function renderActionButton($click, $title, $icon, $type = 'primary') {
104+
$rc = '<button type="button" class="btn btn-'.$type.'" onClick="'.$click.'" title="'.htmlentities(I18N::_('upload_'.$title.'_help')).'">'.
105+
'<span class="docs-tooltip" data-toggle="tooltip" title="" data-original-title="'.htmlentities(I18N::_('upload_'.$title.'_help')).'">'.
105106
'<span class="'.$icon.'"></span>'.
106107
'</span>'.
107108
'</button>';

0 commit comments

Comments
 (0)