parent
58f538f495
commit
8118a45953
|
@ -1,5 +1,7 @@
|
||||||
(function($) {
|
(function($) {
|
||||||
|
|
||||||
|
var cocoon_element_counter = 0;
|
||||||
|
|
||||||
function replace_in_content(content, regexp_str, with_str) {
|
function replace_in_content(content, regexp_str, with_str) {
|
||||||
reg_exp = new RegExp(regexp_str);
|
reg_exp = new RegExp(regexp_str);
|
||||||
content.replace(reg_exp, with_str);
|
content.replace(reg_exp, with_str);
|
||||||
|
@ -22,20 +24,20 @@
|
||||||
insertionMethod = $this.data('association-insertion-method') || $this.data('association-insertion-position') || 'before';
|
insertionMethod = $this.data('association-insertion-method') || $this.data('association-insertion-position') || 'before';
|
||||||
insertionNode = $this.data('association-insertion-node'),
|
insertionNode = $this.data('association-insertion-node'),
|
||||||
insertionTraversal = $this.data('association-insertion-traversal'),
|
insertionTraversal = $this.data('association-insertion-traversal'),
|
||||||
regexp_braced = new RegExp('\\[new_' + assoc + '\\]', 'g'),
|
regexp_braced = new RegExp('\\[new_' + assoc + '\\](.*?\\s)', 'g'),
|
||||||
regexp_underscord = new RegExp('_new_' + assoc + '_', 'g'),
|
regexp_underscord = new RegExp('_new_' + assoc + '_(\\w*)', 'g'),
|
||||||
new_id = new Date().getTime(),
|
new_id = new Date().getTime() + cocoon_element_counter++,
|
||||||
newcontent_braced = '[' + new_id + ']',
|
newcontent_braced = '[' + new_id + ']',
|
||||||
newcontent_underscord = '_' + new_id + '_',
|
newcontent_underscord = '_' + new_id + '_',
|
||||||
new_content = content.replace(regexp_braced, '[' + new_id + ']');
|
new_content = content.replace(regexp_braced, '[' + new_id + ']$1');
|
||||||
|
|
||||||
if (new_content == content) {
|
if (new_content == content) {
|
||||||
regexp_braced = new RegExp('\\[new_' + assocs + '\\]', 'g');
|
regexp_braced = new RegExp('\\[new_' + assocs + '\\](.*?\\s)', 'g');
|
||||||
regexp_underscord = new RegExp('_new_' + assocs + '_', 'g');
|
regexp_underscord = new RegExp('_new_' + assocs + '_(\\w*)', 'g');
|
||||||
new_content = content.replace(regexp_braced, '[' + new_id + ']');
|
new_content = content.replace(regexp_braced, '[' + new_id + ']$1');
|
||||||
}
|
}
|
||||||
|
|
||||||
new_content = new_content.replace(regexp_underscord, newcontent_underscord);
|
new_content = new_content.replace(regexp_underscord, newcontent_underscord + "$1");
|
||||||
|
|
||||||
if (insertionNode){
|
if (insertionNode){
|
||||||
if (insertionTraversal){
|
if (insertionTraversal){
|
||||||
|
|
Loading…
Reference in New Issue