"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Upload/jscripts/bbcodes_sceditor.js" between
mybb_1822.zip and mybb_1823.zip

About: MyBB is a multilingual, standards-compliant and free forum (discussion board) software.

bbcodes_sceditor.js  (mybb_1822):bbcodes_sceditor.js  (mybb_1823)
skipping to change at line 258 skipping to change at line 258
if (attrs.dateline) if (attrs.dateline)
data += ' data-dateline="' + attrs.dateline + '"' ; data += ' data-dateline="' + attrs.dateline + '"' ;
if (typeof attrs.defaultattr !== "undefined") if (typeof attrs.defaultattr !== "undefined")
content = '<cite>' + attrs.defaultattr.replace(/ /g, '&nbsp;') + '</cite>' + content; content = '<cite>' + attrs.defaultattr.replace(/ /g, '&nbsp;') + '</cite>' + content;
return '<blockquote' + data + '>' + content + '</blockquo te>'; return '<blockquote' + data + '>' + content + '</blockquo te>';
}, },
quoteType: function (val, name) { quoteType: function (val, name) {
return "'" + val.replace("'", "\\'") + "'"; var quoteChar = val.indexOf('"') !== -1 ? "'" : '"';
return quoteChar + val + quoteChar;
}, },
breakStart: true, breakStart: true,
breakEnd: true breakEnd: true
}); });
// Update font tag to allow limiting to only first in stack // Update font tag to allow limiting to only first in stack
$.sceditor.formats.bbcode.set('font', { $.sceditor.formats.bbcode.set('font', {
format: function (element, content) { format: function (element, content) {
var font; var font;
if (element.nodeName.toLowerCase() !== 'font' || !(font = $(element).attr('face'))) if (element.nodeName.toLowerCase() !== 'font' || !(font = $(element).attr('face')))
skipping to change at line 305 skipping to change at line 307
}); });
$.sceditor.command.set("php", { $.sceditor.command.set("php", {
_dropDown: function (editor, caller) { _dropDown: function (editor, caller) {
var $content; var $content;
$content = $( $content = $(
'<div>' + '<div>' +
'<div>' + '<div>' +
'<label for="php">' + editor._('PHP') + ':</label > ' + '<label for="php">' + editor._('PHP') + ':</label > ' +
'<textarea type="text" id="php" />' + '<textarea type="text" id="php"></textarea>' +
'</div>' + '</div>' +
'<div><input type="button" class="button" value=" ' + editor._('Insert') + '" /></div>' + '<div><input type="button" class="button" value=" ' + editor._('Insert') + '" /></div>' +
'</div>' '</div>'
); );
setTimeout(function () { setTimeout(function () {
$content.find('#php').trigger('focus'); $content.find('#php').trigger('focus');
}, 100); }, 100);
$content.find('.button').on('click', function (e) { $content.find('.button').on('click', function (e) {
skipping to change at line 368 skipping to change at line 370
}); });
$.sceditor.command.set("code", { $.sceditor.command.set("code", {
_dropDown: function (editor, caller) { _dropDown: function (editor, caller) {
var $content; var $content;
$content = $( $content = $(
'<div>' + '<div>' +
'<div>' + '<div>' +
'<label for="code">' + editor._('Code') + ':</lab el> ' + '<label for="code">' + editor._('Code') + ':</lab el> ' +
'<textarea type="text" id="code" />' + '<textarea type="text" id="code"></textarea>' +
'</div>' + '</div>' +
'<div><input type="button" class="button" value=" ' + editor._('Insert') + '" /></div>' + '<div><input type="button" class="button" value=" ' + editor._('Insert') + '" /></div>' +
'</div>' '</div>'
); );
setTimeout(function () { setTimeout(function () {
$content.find('#code').trigger('focus'); $content.find('#code').trigger('focus');
}, 100); }, 100);
$content.find('.button').on('click', function (e) { $content.find('.button').on('click', function (e) {
skipping to change at line 468 skipping to change at line 470
'data-mybb-vt': null 'data-mybb-vt': null
} }
}, },
format: function ($element, content) { format: function ($element, content) {
return '[video=' + $($element).data('mybb-vt') + ']' + $( $element).data('mybb-vsrc') + '[/video]'; return '[video=' + $($element).data('mybb-vt') + ']' + $( $element).data('mybb-vsrc') + '[/video]';
}, },
html: function (token, attrs, content) { html: function (token, attrs, content) {
var params = mybbCmd.video[Object.keys(mybbCmd.video).fin d(key => key.toLowerCase() === attrs.defaultattr)]; var params = mybbCmd.video[Object.keys(mybbCmd.video).fin d(key => key.toLowerCase() === attrs.defaultattr)];
var matches, url; var matches, url;
var n = (attrs.defaultattr == 'dailymotion') ? 2 : 1; var n = (attrs.defaultattr == 'dailymotion') ? 2 : 1;
if (params['html']) { if (typeof params !== "undefined") {
matches = content.match(params['match']); matches = content.match(params['match']);
url = matches ? params['url'] + matches[n] : fals e; url = matches ? params['url'] + matches[n] : fals e;
} }
if (url) { if (url) {
return params['html'].replace('{url}', url).repla ce('{src}', content).replace('{type}', attrs.defaultattr); return params['html'].replace('{url}', url).repla ce('{src}', content).replace('{type}', attrs.defaultattr);
} }
return $.sceditor.escapeEntities(token.val + content + (t oken.closing ? token.closing.val : '')); return $.sceditor.escapeEntities(token.val + content + (t oken.closing ? token.closing.val : ''));
} }
}); });
skipping to change at line 522 skipping to change at line 524
}, },
exec: function (caller) { exec: function (caller) {
$.sceditor.command.get('video')._dropDown(this, caller); $.sceditor.command.get('video')._dropDown(this, caller);
}, },
txtExec: function (caller) { txtExec: function (caller) {
$.sceditor.command.get('video')._dropDown(this, caller); $.sceditor.command.get('video')._dropDown(this, caller);
}, },
tooltip: 'Insert a video' tooltip: 'Insert a video'
}); });
// Update image command to support MyBB syntax
$.sceditor.formats.bbcode.set('img', {
format: function (element, content) {
if ($(element).data('sceditor-emoticon'))
return content;
var url = $(element).attr('src'),
width = $(element).attr('width'),
height = $(element).attr('height'),
align = $(element).data('scealign');
var attrs = width !== undefined && height !== undefined &
& width > 0 && height > 0
? '=' + width + 'x' + height
: ''
;
if (align === 'left' || align === 'right')
attrs += ' align='+align
return '[img' + attrs + ']' + url + '[/img]';
},
html: function (token, attrs, content) {
var width, height, match,
align = attrs.align,
attribs = '';
// handle [img=340x240]url[/img]
if (attrs.defaultattr) {
match = attrs.defaultattr.split(/x/i);
width = match[0];
height = (match.length === 2 ? match[1] : match[0
]);
if (width !== undefined && height !== undefined &
& width > 0 && height > 0) {
attribs +=
' width="' + $.sceditor.escapeEnt
ities(width, true) + '"' +
' height="' + $.sceditor.escapeEn
tities(height, true) + '"';
}
}
if (align === 'left' || align === 'right')
attribs += ' style="float: ' + align + '" data-sc
ealign="' + align + '"';
return '<img' + attribs +
' src="' + $.sceditor.escapeUriScheme(content) +
'" />';
}
})
$.sceditor.command.set('image', {
_dropDown: function (editor, caller) {
var $content;
$content = $(
'<div>' +
'<div>' +
'<label for="image">' + editor._('URL') + ':</lab
el> ' +
'<input type="text" id="image" placeholder="https
://" />' +
'</div>' +
'<div>' +
'<label for="width">' + editor._('Width (optional
)') + ':</label> ' +
'<input type="text" id="width" size="2" />' +
'</div>' +
'<div>' +
'<label for="height">' + editor._('Height (option
al)') + ':</label> ' +
'<input type="text" id="height" size="2" />' +
'</div>' +
'<div>' +
'<input type="button" class="button" value="' + e
ditor._('Insert') + '" />' +
'</div>' +
'</div>'
);
$content.find('.button').on('click', function (e) {
var url = $content.find('#image').val(),
width = $content.find('#width').val(),
height = $content.find('#height').val()
;
var attrs = width !== undefined && height !== und
efined && width > 0 && height > 0
? '=' + width + 'x' + height
: ''
;
if (url)
editor.insert('[img' + attrs + ']' + url
+ '[/img]');
editor.closeDropDown(true);
e.preventDefault();
});
editor.createDropDown(caller, 'insertimage', $content.get
(0));
},
exec: function (caller) {
$.sceditor.command.get('image')._dropDown(this, caller);
},
txtExec: function (caller) {
$.sceditor.command.get('image')._dropDown(this, caller);
},
});
// Remove last bits of table, superscript/subscript, youtube and ltr/rtl support // Remove last bits of table, superscript/subscript, youtube and ltr/rtl support
$.sceditor.command $.sceditor.command
.remove('table').remove('subscript').remove('superscript').remove ('youtube').remove('ltr').remove('rtl'); .remove('table').remove('subscript').remove('superscript').remove ('youtube').remove('ltr').remove('rtl');
$.sceditor.formats.bbcode $.sceditor.formats.bbcode
.remove('table').remove('tr').remove('th').remove('td').remove('s ub').remove('sup').remove('youtube').remove('ltr').remove('rtl'); .remove('table').remove('tr').remove('th').remove('td').remove('s ub').remove('sup').remove('youtube').remove('ltr').remove('rtl');
// Remove code and quote if in partial mode // Remove code and quote if in partial mode
if (partialmode) { if (partialmode) {
$.sceditor.formats.bbcode.remove('code').remove('php').remove('qu ote').remove('video').remove('img'); $.sceditor.formats.bbcode.remove('code').remove('php').remove('qu ote').remove('video').remove('img');
$.sceditor.command $.sceditor.command
.set('image', {
exec: function (caller) {
var editor = this,
content = $(this._('<form><div><l
abel for="link">{0}</label> <input type="text" id="image" value="http://" /></di
v>' +
'<div><label for="width">
{1}</label> <input type="text" id="width" size="2" /></div>' +
'<div><label for="height"
>{2}</label> <input type="text" id="height" size="2" /></div></form>',
this._("URL:"),
this._("Width (optional):
"),
this._("Height (optional)
:")
))
.submit(function () {
return false;
});
content.append($(this._('<div><input type
="button" class="button" value="Insert" /></div>',
this._("Insert")
)).on('click', function (e) {
var $form = $(this).parent('form'
),
val = $form.find('#image'
).val(),
width = $form.find('#widt
h').val(),
height = $form.find('#hei
ght').val(),
attrs = '';
if (width && height) {
attrs = '=' + width + 'x'
+ height;
}
if (val && val !== 'http://') {
editor.wysiwygEditorInser
tHtml('[img' + attrs + ']' + val + '[/img]');
}
editor.closeDropDown(true);
e.preventDefault();
}));
editor.createDropDown(caller, 'insertimag
e', content.get(0));
}
})
.set('quote', { .set('quote', {
exec: function () { exec: function () {
this.insert('[quote]', '[/quote]'); this.insert('[quote]', '[/quote]');
} }
}); });
} }
// Fix url code // Fix url code
$.sceditor.formats.bbcode.set('url', { $.sceditor.formats.bbcode.set('url', {
html: function (token, attrs, content) { html: function (token, attrs, content) {
 End of changes. 6 change blocks. 
56 lines changed or deleted 121 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)