-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{% if S_PLUPLOAD %}{% include 'rineditor_plupload.html' %}{% endif %} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script type="text/javascript"> | ||
phpbb.plupload.updateBbcode = function(action, index) { | ||
var text = CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].getData(), | ||
removal = (action === 'removal'); | ||
|
||
// Return if the bbcode isn't used at all. | ||
if (text.indexOf('[attachment=') === -1) { | ||
return; | ||
} | ||
|
||
function runUpdate(i) { | ||
var regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g'); | ||
text = text.replace(regex, function updateBbcode(_, fileName) { | ||
// Remove the bbcode if the file was removed. | ||
if (removal && index === i) { | ||
return ''; | ||
} | ||
var newIndex = i + ((removal) ? -1 : 1); | ||
return '[attachment=' + newIndex + ']' + fileName + '[/attachment]'; | ||
}); | ||
} | ||
|
||
// Loop forwards when removing and backwards when adding ensures we don't | ||
// corrupt the bbcode index. | ||
var i; | ||
if (removal) { | ||
for (i = index; i < phpbb.plupload.ids.length; i++) { | ||
runUpdate(i); | ||
} | ||
} else { | ||
for (i = phpbb.plupload.ids.length - 1; i >= index; i--) { | ||
runUpdate(i); | ||
} | ||
} | ||
|
||
CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].setData(text); | ||
}; | ||
</script> |