// [img]
data = data.replace(/\[img\]([^"]+?)\[\/img\]/gi,'<img src="$1" />');
- data = data.replace(/\[img='?([^"]*?)'?,'?(left|right)'?\]\[\/img\]/gi,'<img src="$1" style="float: $2" />');
- data = data.replace(/\[img='?([^"]*?)'?,'?(left|right|none)'?,'?(\d+)'?\]\[\/img\]/gi, '<img src="$1" style="float: $2; width: $3px" />');
+ data = data.replace(/\[img='?([^"]*?)'?,'?(left|right)'?\]\[\/img\]/gi, function(match, src, float, width) {
+ var $style = 'float: ' + float + ';';
+ if (float === 'left') {
+ $style += 'margin: 0 15px 7px 0';
+ }
+ else {
+ $style += 'margin: 0 0 7px 15px';
+ }
+
+ return '<img src="' + src + '" style="' + $style + '" />';
+ });
+ data = data.replace(/\[img='?([^"]*?)'?,'?(left|right|none)'?,'?(\d+)'?\]\[\/img\]/gi, function(match, src, float, width) {
+ var $style = 'float: ' + float + '; width: ' + width + 'px';
+ if (float === 'left') {
+ $style += 'margin: 0 15px 7px 0';
+ }
+ else {
+ $style += 'margin: 0 0 7px 15px';
+ }
+
+ return '<img src="' + src + '" style="' + $style + '" />';
+ });
data = data.replace(/\[img='?([^"]*?)'?\]\[\/img\]/gi,'<img src="$1" />');
// [size]
var $style = '';
if (alignment === 'left' || alignment === 'right') {
$style = 'float: ' + alignment + ';';
+
+ if (alignment === 'left') {
+ $style += 'margin: 0 15px 7px 0';
+ }
+ else {
+ $style += 'margin: 0 0 7px 15px';
+ }
}
$style = ' style="' + $style + '"';
var $style = 'width: ' + width + 'px; max-height: ' + $imageAttachments[attachmentID].height + 'px; max-width: ' + $imageAttachments[attachmentID].width + 'px;';
if (alignment === 'left' || alignment === 'right') {
$style += 'float: ' + alignment + ';';
+
+ if (alignment === 'left') {
+ $style += 'margin: 0 15px 7px 0';
+ }
+ else {
+ $style += 'margin: 0 0 7px 15px';
+ }
}
$style = ' style="' + $style + '"';
}).bind(this);
// image.update
+ var $moveImage = (function(image) {
+ var $parent = image.parent();
+ image = image.detach();
+ image.prependTo($parent);
+
+ this.caret.setAfter(image);
+ }).bind(this);
+
this.image.update = (function(image) {
this.image.hideResize();
this.buffer.set();
image.attr('src', $('#redactor-image-link-source').val());
this.image.setFloating(image);
+ $moveImage(image);
this.modal.close();
this.observe.images();
'<fieldset id="redactor-modal-link">'
+ '<dl>'
+ '<dt><label for="redactor-link-url" />URL</label></dt>' /* TODO: use a phrase instead of hardcoding it! */
- + '<dd><input type="url" id="redactor-link-url" /></dd>'
+ + '<dd><input type="url" id="redactor-link-url" class="long" /></dd>'
+ '</dl>'
+ '<dl>'
+ '<dt><label for="redactor-link-url-text">' + this.lang.get('text') + '</label></dt>'
- + '<dd><input type="text" id="redactor-link-url-text" /></dd>'
+ + '<dd><input type="text" id="redactor-link-url-text" class="long" /></dd>'
+ '</dl>'
+ '</fieldset>';