MDL-44826 Atto: Remove most of the image alignment options

Just keep the simple ones and put some default padding on images.
This commit is contained in:
Damyon Wiese
2014-04-11 12:55:28 +08:00
parent 0adadbf00b
commit 2e8cbbb3ac
6 changed files with 74 additions and 99 deletions
@@ -23,15 +23,10 @@
*/
$string['alignment'] = 'Alignment';
$string['alignment_baseline'] = 'Default (baseline)';
$string['alignment_bottom'] = 'Bottom';
$string['alignment_left'] = 'Left';
$string['alignment_middle'] = 'Middle';
$string['alignment_right'] = 'Right';
$string['alignment_sub'] = 'Subscript';
$string['alignment_super'] = 'Superscript';
$string['alignment_textbottom'] = 'Text bottom';
$string['alignment_texttop'] = 'Text top';
$string['alignment_top'] = 'Top';
$string['browserepositories'] = 'Browse repositories...';
$string['constrain'] = 'Keep ratio';
-5
View File
@@ -32,15 +32,10 @@ function atto_image_strings_for_js() {
$strings = array(
'alignment',
'alignment_baseline',
'alignment_bottom',
'alignment_left',
'alignment_middle',
'alignment_right',
'alignment_sub',
'alignment_super',
'alignment_textbottom',
'alignment_texttop',
'alignment_top',
'browserepositories',
'constrain',
@@ -50,48 +50,33 @@ var CSS = {
ALIGNMENTS = [
// Vertical alignment.
{
name: 'baseline',
str: 'alignment_baseline',
value: 'vertical-align'
}, {
name: 'sub',
str: 'alignment_sub',
value: 'vertical-align'
}, {
name: 'super',
str: 'alignment_super',
value: 'vertical-align'
}, {
name: 'top',
str: 'alignment_top',
value: 'vertical-align'
}, {
name: 'text-top',
str: 'alignment_texttop',
value: 'vertical-align'
str: 'alignment_top',
value: 'vertical-align',
margin: '0 .5em'
}, {
name: 'middle',
str: 'alignment_middle',
value: 'vertical-align'
}, {
name: 'bottom',
str: 'alignment_bottom',
value: 'vertical-align'
value: 'vertical-align',
margin: '0 .5em'
}, {
name: 'text-bottom',
str: 'alignment_textbottom',
value: 'vertical-align'
str: 'alignment_bottom',
value: 'vertical-align',
margin: '0 .5em'
},
// Floats.
{
name: 'left',
str: 'alignment_left',
value: 'float'
value: 'float',
margin: '0 .5em 0 0'
}, {
name: 'right',
str: 'alignment_right',
value: 'float'
value: 'float',
margin: '0 0 .5em 0'
}
];
@@ -160,7 +145,7 @@ var COMPONENTNAME = 'atto_image',
'{{#if width}}width="{{width}}" {{/if}}' +
'{{#if height}}height="{{height}}" {{/if}}' +
'{{#if presentation}}role="presentation" {{/if}}' +
'{{#if alignment}}style="{{alignment}}" {{/if}}' +
'style="{{alignment}}{{margin}}"' +
'/>';
Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
@@ -551,8 +536,10 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
width = form.one('.' + CSS.INPUTWIDTH).get('value'),
height = form.one('.' + CSS.INPUTHEIGHT).get('value'),
alignment = form.one('.' + CSS.INPUTALIGNMENT).get('value'),
margin = '',
presentation = form.one('.' + CSS.IMAGEPRESENTATION).get('checked'),
imagehtml,
i,
host = this.get('host');
e.preventDefault();
@@ -574,6 +561,13 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
} else {
host.setSelection(this._currentSelection);
}
for (i in ALIGNMENTS) {
css = ALIGNMENTS[i].value + ':' + ALIGNMENTS[i].name + ';';
if (alignment === css) {
margin = ' margin: ' + ALIGNMENTS[i].margin + ';';
}
}
template = Y.Handlebars.compile(IMAGETEMPLATE);
imagehtml = template({
url: url,
@@ -581,7 +575,8 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
width: width,
height: height,
presentation: presentation,
alignment: alignment
alignment: alignment,
margin: margin
});
this.get('host').insertContentAtFocusPoint(imagehtml);
File diff suppressed because one or more lines are too long
@@ -50,48 +50,33 @@ var CSS = {
ALIGNMENTS = [
// Vertical alignment.
{
name: 'baseline',
str: 'alignment_baseline',
value: 'vertical-align'
}, {
name: 'sub',
str: 'alignment_sub',
value: 'vertical-align'
}, {
name: 'super',
str: 'alignment_super',
value: 'vertical-align'
}, {
name: 'top',
str: 'alignment_top',
value: 'vertical-align'
}, {
name: 'text-top',
str: 'alignment_texttop',
value: 'vertical-align'
str: 'alignment_top',
value: 'vertical-align',
margin: '0 .5em'
}, {
name: 'middle',
str: 'alignment_middle',
value: 'vertical-align'
}, {
name: 'bottom',
str: 'alignment_bottom',
value: 'vertical-align'
value: 'vertical-align',
margin: '0 .5em'
}, {
name: 'text-bottom',
str: 'alignment_textbottom',
value: 'vertical-align'
str: 'alignment_bottom',
value: 'vertical-align',
margin: '0 .5em'
},
// Floats.
{
name: 'left',
str: 'alignment_left',
value: 'float'
value: 'float',
margin: '0 .5em 0 0'
}, {
name: 'right',
str: 'alignment_right',
value: 'float'
value: 'float',
margin: '0 0 .5em 0'
}
];
@@ -160,7 +145,7 @@ var COMPONENTNAME = 'atto_image',
'{{#if width}}width="{{width}}" {{/if}}' +
'{{#if height}}height="{{height}}" {{/if}}' +
'{{#if presentation}}role="presentation" {{/if}}' +
'{{#if alignment}}style="{{alignment}}" {{/if}}' +
'style="{{alignment}}{{margin}}"' +
'/>';
Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
@@ -551,8 +536,10 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
width = form.one('.' + CSS.INPUTWIDTH).get('value'),
height = form.one('.' + CSS.INPUTHEIGHT).get('value'),
alignment = form.one('.' + CSS.INPUTALIGNMENT).get('value'),
margin = '',
presentation = form.one('.' + CSS.IMAGEPRESENTATION).get('checked'),
imagehtml,
i,
host = this.get('host');
e.preventDefault();
@@ -574,6 +561,13 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
} else {
host.setSelection(this._currentSelection);
}
for (i in ALIGNMENTS) {
css = ALIGNMENTS[i].value + ':' + ALIGNMENTS[i].name + ';';
if (alignment === css) {
margin = ' margin: ' + ALIGNMENTS[i].margin + ';';
}
}
template = Y.Handlebars.compile(IMAGETEMPLATE);
imagehtml = template({
url: url,
@@ -581,7 +575,8 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
width: width,
height: height,
presentation: presentation,
alignment: alignment
alignment: alignment,
margin: margin
});
this.get('host').insertContentAtFocusPoint(imagehtml);
+24 -29
View File
@@ -48,48 +48,33 @@ var CSS = {
ALIGNMENTS = [
// Vertical alignment.
{
name: 'baseline',
str: 'alignment_baseline',
value: 'vertical-align'
}, {
name: 'sub',
str: 'alignment_sub',
value: 'vertical-align'
}, {
name: 'super',
str: 'alignment_super',
value: 'vertical-align'
}, {
name: 'top',
str: 'alignment_top',
value: 'vertical-align'
}, {
name: 'text-top',
str: 'alignment_texttop',
value: 'vertical-align'
str: 'alignment_top',
value: 'vertical-align',
margin: '0 .5em'
}, {
name: 'middle',
str: 'alignment_middle',
value: 'vertical-align'
}, {
name: 'bottom',
str: 'alignment_bottom',
value: 'vertical-align'
value: 'vertical-align',
margin: '0 .5em'
}, {
name: 'text-bottom',
str: 'alignment_textbottom',
value: 'vertical-align'
str: 'alignment_bottom',
value: 'vertical-align',
margin: '0 .5em'
},
// Floats.
{
name: 'left',
str: 'alignment_left',
value: 'float'
value: 'float',
margin: '0 .5em 0 0'
}, {
name: 'right',
str: 'alignment_right',
value: 'float'
value: 'float',
margin: '0 0 .5em 0'
}
];
@@ -158,7 +143,7 @@ var COMPONENTNAME = 'atto_image',
'{{#if width}}width="{{width}}" {{/if}}' +
'{{#if height}}height="{{height}}" {{/if}}' +
'{{#if presentation}}role="presentation" {{/if}}' +
'{{#if alignment}}style="{{alignment}}" {{/if}}' +
'style="{{alignment}}{{margin}}"' +
'/>';
Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
@@ -549,8 +534,10 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
width = form.one('.' + CSS.INPUTWIDTH).get('value'),
height = form.one('.' + CSS.INPUTHEIGHT).get('value'),
alignment = form.one('.' + CSS.INPUTALIGNMENT).get('value'),
margin = '',
presentation = form.one('.' + CSS.IMAGEPRESENTATION).get('checked'),
imagehtml,
i,
host = this.get('host');
e.preventDefault();
@@ -572,6 +559,13 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
} else {
host.setSelection(this._currentSelection);
}
for (i in ALIGNMENTS) {
css = ALIGNMENTS[i].value + ':' + ALIGNMENTS[i].name + ';';
if (alignment === css) {
margin = ' margin: ' + ALIGNMENTS[i].margin + ';';
}
}
template = Y.Handlebars.compile(IMAGETEMPLATE);
imagehtml = template({
url: url,
@@ -579,7 +573,8 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
width: width,
height: height,
presentation: presentation,
alignment: alignment
alignment: alignment,
margin: margin
});
this.get('host').insertContentAtFocusPoint(imagehtml);