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

Improved ML button styling #73

Merged
merged 52 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
14ca220
Improved ML button styling
AIC-BV Oct 3, 2023
8ea49d2
Compile multilingual.less
AIC-BV Oct 3, 2023
52b48e4
Fix markdown ML button position
AIC-BV Oct 3, 2023
c4d5435
Fix markdown ML button
AIC-BV Oct 3, 2023
3310076
Fix ML button color
AIC-BV Oct 3, 2023
d1b7871
Remove height, reset box shadow and add bottom
AIC-BV Oct 3, 2023
204ee73
fix oopsie
AIC-BV Oct 3, 2023
b14c93c
Compile multilingual.less
AIC-BV Oct 3, 2023
ac18545
Move markdowneditor ML button inside the toolbar
AIC-BV Oct 4, 2023
ba7bdde
Compile multilingual.less
AIC-BV Oct 4, 2023
ad9670b
Fix richeditor ML button
AIC-BV Oct 4, 2023
fbb910c
Compile multilingual.less
AIC-BV Oct 4, 2023
a543e7e
fixes for ML buttons
AIC-BV Oct 5, 2023
be58cb9
Compile multilingual.less
AIC-BV Oct 5, 2023
15afd6e
Fix textarea and mediafinder
AIC-BV Oct 5, 2023
0cefe01
Compile multilingual.less
AIC-BV Oct 5, 2023
719fb5c
Cleanup
AIC-BV Oct 5, 2023
ab5f5f1
Compile multilingual.less
AIC-BV Oct 5, 2023
f889107
fix richeditor
AIC-BV Oct 5, 2023
1fdda7e
Compile multilingual.less
AIC-BV Oct 5, 2023
2076df2
Remove .ml-btn 6px margin
AIC-BV Oct 16, 2023
f047491
Only set top if height is > 0
AIC-BV Oct 16, 2023
8db7c62
Set correct richeditor default .ml-element values
AIC-BV Oct 16, 2023
4082615
Compile multilingual.less
AIC-BV Oct 16, 2023
3a4e069
[fix] mlricheditor .ml-btn
AIC-BV Oct 17, 2023
de68bf2
[fix] mlrepeater padding
AIC-BV Oct 17, 2023
132c6fd
[fix] mlricheditor compile multilingual.less
AIC-BV Oct 17, 2023
90dc182
[fix] mlricheditor padding
AIC-BV Oct 17, 2023
52b7b77
[fix] mlricheditor rounding exception
AIC-BV Oct 17, 2023
f5584b4
[fix] mlricheditor scrollbar
AIC-BV Oct 18, 2023
244b156
[fix] toolbar check
AIC-BV Oct 18, 2023
979453a
Merge keydown & keyup event in one '.on()' function
AIC-BV Oct 18, 2023
756a248
[fix] markdown margin<->padding
AIC-BV Oct 18, 2023
2b399a8
Compile multilingual.less
AIC-BV Oct 18, 2023
b432072
Support markdown splitmode
AIC-BV Oct 18, 2023
5c329f0
Compile multilingual.less
AIC-BV Oct 18, 2023
3d037cc
[fix] Markdowneditor ML button position
AIC-BV Oct 18, 2023
233576a
Update multilingual.less
AIC-BV Oct 18, 2023
8d26595
Update multilingual.css
AIC-BV Oct 18, 2023
64081ef
Create mltextarea.js
AIC-BV Oct 19, 2023
04a6f34
Update _mltextarea.htm
AIC-BV Oct 19, 2023
4883c8c
Update MLTextarea.php
AIC-BV Oct 19, 2023
c2e37e2
Update mltextarea.js
AIC-BV Oct 19, 2023
0c97349
Update mltextarea.js
AIC-BV Oct 19, 2023
ff5b87a
[fix] button radius with scrollbar
AIC-BV Oct 19, 2023
29294b9
[fix] indentation
AIC-BV Oct 19, 2023
6e0672f
[fix] indentation
AIC-BV Oct 19, 2023
748004d
[fix] previewmode
AIC-BV Oct 19, 2023
19d88c6
remove logs
AIC-BV Oct 19, 2023
c25bb08
[fix] previewmode mlmarkdowneditor.js
AIC-BV Oct 27, 2023
b068ed7
update on input
mjauvin Mar 18, 2024
c9eff71
[fix] markdowneditor
AIC-BV Mar 19, 2024
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
38 changes: 15 additions & 23 deletions assets/css/multilingual.css
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
.field-multilingual{position:relative}
.field-multilingual .ml-btn{background:transparent;position:absolute;color:#7b7b7b;text-transform:uppercase;font-size:11px;letter-spacing:1px;width:44px;padding-right:0;-webkit-box-shadow:none;box-shadow:none;text-shadow:none;z-index:2}
.field-multilingual .ml-btn{z-index:2;position:absolute;top:1px;bottom:1px;right:1px;width:auto;max-width:44px;max-height:38px;color:#7b7b7b;background-color:#F8F6F3;box-shadow:none;font-size:11px;letter-spacing:1px;text-transform:uppercase;margin:0 !important;padding:0 12px;border-top-left-radius:0;border-bottom-left-radius:0;transition:color 420ms ease}
.field-multilingual .ml-btn:hover{color:#555}
.field-multilingual.field-multilingual-text .form-control{padding-right:44px}
.field-multilingual.field-multilingual-text .ml-btn{right:4px;top:50%;margin-top:-44px;height:88px}
.field-multilingual.field-multilingual-textarea textarea{padding-right:30px}
.field-multilingual.field-multilingual-textarea .ml-btn{right:13px;top:5px;width:24px;text-align:right;padding-left:4px}
.field-multilingual.field-multilingual-textarea .ml-dropdown-menu{top:39px;right:1px}
.field-multilingual.field-multilingual-richeditor .ml-btn{top:43px;right:25px;text-align:right}
.field-multilingual.field-multilingual-richeditor .ml-dropdown-menu{top:74px;right:12px}
.field-multilingual.field-multilingual-markdowneditor .ml-btn{top:43px;right:25px;text-align:right}
.field-multilingual.field-multilingual-markdowneditor .ml-dropdown-menu{top:74px !important;right:12px}
.field-multilingual.field-multilingual-repeater .ml-btn,
.field-multilingual.field-multilingual-nestedform .ml-btn{top:-27px;right:11px;text-align:right}
.field-multilingual.field-multilingual-repeater .ml-btn{top:3px;bottom:auto;height:auto;transform:translateY(-100%);border-radius:.375rem}
.field-multilingual.field-multilingual-textarea textarea{padding-right:2rem}
.field-multilingual.field-multilingual-textarea .ml-btn{border-bottom-right-radius:0;border-bottom-left-radius:.375rem}
.field-multilingual.field-multilingual-textarea .ml-dropdown-menu{top:28px;right:1px}
.field-multilingual.field-multilingual-richeditor .ml-btn{border-radius:0;border-bottom-left-radius:.375rem}
.field-multilingual.field-multilingual-richeditor .ml-dropdown-menu{top:28px;right:1px}
.field-multilingual.field-multilingual-markdowneditor .mode-tab .editor-write{padding-right:2rem}
.field-multilingual.field-multilingual-markdowneditor .mode-split .editor-preview{padding-right:2rem}
.field-multilingual.field-multilingual-markdowneditor .editor-code{padding-right:inherit}
.field-multilingual.field-multilingual-markdowneditor .ml-btn{border-radius:0;border-bottom-left-radius:.375rem}
.field-multilingual.field-multilingual-markdowneditor .ml-dropdown-menu{top:28px;right:1px}
.field-multilingual.field-multilingual-repeater .ml-dropdown-menu,
.field-multilingual.field-multilingual-nestedform .ml-dropdown-menu{top:0;right:0}
.field-multilingual.field-multilingual-repeater.is-empty,
.field-multilingual.field-multilingual-nestedform.is-empty{padding-top:5px}
.field-multilingual.field-multilingual-repeater.is-empty .ml-btn,
.field-multilingual.field-multilingual-nestedform.is-empty .ml-btn{top:-10px;right:5px;text-align:right}
.field-multilingual.field-multilingual-repeater.is-empty .ml-dropdown-menu,
.field-multilingual.field-multilingual-nestedform.is-empty .ml-dropdown-menu{top:15px;right:-7px}
.fancy-layout .form-tabless-fields .field-multilingual .ml-btn{color:rgba(255,255,255,0.8)}
.fancy-layout .form-tabless-fields .field-multilingual .ml-btn:hover{color:#fff}
.fancy-layout .field-multilingual-text input.form-control{padding-right:44px}
.help-block.before-field + .field-multilingual.field-multilingual-textarea .ml-btn{top:-41px}
.field-multilingual.field-multilingual-nestedform .ml-dropdown-menu{top:2px;right:0}
.field-multilingual.field-multilingual-mediafinder .ml-btn{border-radius:.375rem}
.fancy-layout .form-tabless-fields .field-multilingual .ml-btn{background-color:rgba(248,246,243,0.75)}
133 changes: 64 additions & 69 deletions assets/less/multilingual.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,128 +6,123 @@
position: relative;

.ml-btn {
background: transparent;
z-index: 2;
position: absolute;
top: 1px;
bottom: 1px;
right: 1px;

width: auto;
max-width: 44px;
max-height: 38px;

color: lighten(@multilingual-btn-color, 15%);
text-transform: uppercase;
background-color: #F8F6F3;
box-shadow: none;

font-size: 11px;
letter-spacing: 1px;
width: 44px;
padding-right: 0;
.box-shadow(none);
text-shadow: none;
z-index: 2;
text-transform: uppercase;

margin: 0 !important;
padding: 0 12px;

border-top-left-radius: 0;
border-bottom-left-radius: 0;

transition: color 420ms ease;

&:hover {
color: @multilingual-btn-color;
}
}

&.field-multilingual-text {
.form-control {
padding-right: 44px;
}
.ml-btn {
right: 4px;
top: 50%;
margin-top: -44px;
height: 88px;
}
&.field-multilingual-repeater .ml-btn {
top: 3px;
bottom: auto;
height: auto;
transform: translateY(-100%);
border-radius: .375rem;
}

&.field-multilingual-textarea {
textarea {
// increase padding on the right so that the textarea content does not overlap with the language button
padding-right: 30px;
padding-right: 2rem;
}

.ml-btn {
right: 13px;
top: 5px;
width: 24px;
text-align: right;
padding-left: 4px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: .375rem;
}

.ml-dropdown-menu {
top: 39px;
top: 28px;
right: 1px;
}
}

&.field-multilingual-richeditor {
.ml-btn {
top: 43px;
right: 25px;
text-align: right;
border-radius: 0;
border-bottom-left-radius: .375rem;
}

.ml-dropdown-menu {
top: 74px;
right: 12px;
top: 28px;
right: 1px;
}
}

&.field-multilingual-markdowneditor {
.mode-tab .editor-write {
padding-right: 2rem;
}

.mode-split .editor-preview {
padding-right: 2rem;
}

.editor-code {
padding-right: inherit;
}

.ml-btn {
top: 43px;
right: 25px;
text-align: right;
border-radius: 0;
border-bottom-left-radius: .375rem;
}

.ml-dropdown-menu {
top: 74px !important;
right: 12px;
top: 28px;
right: 1px;
}
}

&.field-multilingual-repeater,
&.field-multilingual-nestedform {
.ml-btn {
top: -27px;
right: 11px;
text-align: right;
}

.ml-dropdown-menu {
top: 0;
top: 2px;
right: 0;
}
}

&.is-empty {
padding-top: 5px;

.ml-btn {
top: -10px;
right: 5px;
text-align: right;
}

.ml-dropdown-menu {
top: 15px;
right: -7px;
}
&.field-multilingual-mediafinder {
.ml-btn {
border-radius: .375rem;
}
}
}

.fancy-layout {
.form-tabless-fields .field-multilingual {
.ml-btn {
color: rgba(255,255,255,.8);

&:hover {
color: rgba(255,255,255,1);
}
background-color: rgba(248, 246, 243, 0.75)
}
}
.field-multilingual-text input.form-control {
padding-right: 44px;
}
}

.help-block.before-field + .field-multilingual.field-multilingual-textarea {
.ml-btn {
top: -41px;
}
}
// ?? CHECK THIS
// .help-block.before-field + .field-multilingual.field-multilingual-textarea {
// .ml-btn {
// top: -41px;
// }
// }
1 change: 1 addition & 0 deletions formwidgets/MLTextarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function getSaveValue($value)
protected function loadAssets()
{
$this->loadLocaleAssets();
$this->addJs('js/mltextarea.js');
}

}
69 changes: 69 additions & 0 deletions formwidgets/mlmarkdowneditor/assets/js/mlmarkdowneditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@
this.$el.on('setLocale.oc.multilingual', this.proxy(this.onSetLocale))
this.$textarea.on('changeContent.oc.markdowneditor', this.proxy(this.onChangeContent))

this.updateLayout()

$(window).on('resize', this.proxy(this.updateLayout))
$(window).on('oc.updateUi', this.proxy(this.updateLayout))
this.$el.one('dispose-control', this.proxy(this.dispose))

}

MLMarkdownEditor.prototype.dispose = function() {
Expand Down Expand Up @@ -75,6 +80,64 @@
this.$el.multiLingual('setLocaleValue', value)
}

MLMarkdownEditor.prototype.updateLayout = function() {
var $toolbar = $('.control-toolbar', this.$el),
$btn = $('.ml-btn[data-active-locale]:first', this.$el),
$dropdown = $('.ml-dropdown-menu[data-locale-dropdown]:first', this.$el),
$container = $('.editor-write', this.$el),
$scrollbar = $('.ace_scrollbar', this.$el),
$input = $('.ace_text-input', this.$el)

if ($toolbar.length) {
var height = $toolbar.outerHeight(true)
if (height) {
$btn.css('top', height + 0.5)
$dropdown.css('top', height + 34)
}
}

// set ML button position
var $container = $('.editor-write', this.$el),
$previewContainer = $('.editor-preview', this.$el),
$scrollbar = $('.ace_scrollbar', this.$el),
$input = $('.ace_text-input', this.$el)

// fix exit fullscreen
setTimeout(function() {
setMLButtonPosition()
}, 0)

// input listener
$input.on('keydown keyup', setMLButtonPosition)

function setMLButtonPosition() {

// make sure container is displayed (fix previewmode)
$container.css('display', 'initial')

var scrollbarWidth = $scrollbar[0].offsetWidth - 5
if (scrollbarWidth === -5) scrollbarWidth = $previewContainer[0].offsetWidth - $previewContainer[0].clientWidth

if (scrollbarWidth >= 0) {
$container.css('padding-right', scrollbarWidth + 23)
$btn.css('right', scrollbarWidth - 1)
$dropdown.css('right', scrollbarWidth - 2)
} else {
$container.css('padding-right', '')
$btn.css('right', '')
$dropdown.css('right', '')
}

// reset container
$container.css('display', '')

}

}

// MLMARKDOWNEDITOR PLUGIN DEFINITION
// ============================

var old = $.fn.mlMarkdownEditor

$.fn.mlMarkdownEditor = function (option) {
Expand All @@ -94,11 +157,17 @@

$.fn.mlMarkdownEditor.Constructor = MLMarkdownEditor;

// MLMARKDOWNEDITOR NO CONFLICT
// =================

$.fn.mlMarkdownEditor.noConflict = function () {
$.fn.mlMarkdownEditor = old
return this
}

// MLMARKDOWNEDITOR DATA-API
// ===============

$(document).render(function (){
$('[data-control="mlmarkdowneditor"]').mlMarkdownEditor()
})
Expand Down
45 changes: 38 additions & 7 deletions formwidgets/mlricheditor/assets/js/mlricheditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,46 @@
MLRichEditor.prototype.updateLayout = function() {
var $toolbar = $('.fr-toolbar', this.$el),
$btn = $('.ml-btn[data-active-locale]:first', this.$el),
$dropdown = $('.ml-dropdown-menu[data-locale-dropdown]:first', this.$el)

if (!$toolbar.length) {
return
$dropdown = $('.ml-dropdown-menu[data-locale-dropdown]:first', this.$el),
$element = $('.fr-element', this.$el)

if ($toolbar.length) {
var height = $toolbar.outerHeight(true)
if (height) {
$btn.css('top', height)
$dropdown.css('top', height + 34)
}
}

var height = $toolbar.outerHeight(true)
$btn.css('top', height + 6)
$dropdown.css('top', height + 40)
// set ML button position
var hasScrollbar = false
var scrollbarWidth = 0
var elementHeight = $element.outerHeight()

setMLButtonPosition()
$element.on('keydown keyup', setMLButtonPosition)

function setMLButtonPosition() {
var scrollHeight = $element[0].scrollHeight
var showScrollbar = scrollHeight > elementHeight

if (!hasScrollbar && showScrollbar) {

hasScrollbar = true
if (!scrollbarWidth) scrollbarWidth = $element[0].offsetWidth - $element[0].clientWidth

$element.css('padding-right', scrollbarWidth + 23)
$btn.css('right', scrollbarWidth - 1)
$dropdown.css('right', scrollbarWidth - 2)

} else if (hasScrollbar && !showScrollbar) {
hasScrollbar = false
$element.css('padding-right', '')
$btn.css('right', '')
$dropdown.css('right', '')
}
}

}

// MLRICHEDITOR PLUGIN DEFINITION
Expand Down
Loading
Loading