Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform Smiles to HTML while wrapped #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions jquery.wysibb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2124,22 +2124,27 @@ wbbdebug=true;
return $wrap.html();
},
getHTMLSmiles: function(rel) {
$(rel).contents().filter(function() {return this.nodeType==3}).each($.proxy(this.smileRPL,this));
$(rel).contents().filter(function() {return this.nodeType==3 || this.nodeType==1}).each($.proxy(this.smileRPL,this));
},
smileRPL: function(i,el) {
var ndata = el.data;
$.each(this.options.smileList,$.proxy(function(i,row) {
var fidx = ndata.indexOf(row.bbcode);
if (fidx!=-1) {
var afternode_txt = ndata.substring(fidx+row.bbcode.length,ndata.length);
var afternode = document.createTextNode(afternode_txt);
el.data = ndata = el.data.substr(0,fidx);
$(el).after(afternode).after(this.strf(row.img,this.options));
this.getHTMLSmiles(el.parentNode);
return false;
}
this.getHTMLSmiles(el);
},this));
if(el.nodeType==1){
//recursive edit
$(el).contents().filter(function() {return this.nodeType==3 || this.nodeType==1}).each($.proxy(this.smileRPL,this));
}else{
var ndata = el.data;
$.each(this.options.smileList,$.proxy(function(i,row) {
var fidx = ndata.indexOf(row.bbcode);
if (fidx!=-1) {
var afternode_txt = ndata.substring(fidx+row.bbcode.length,ndata.length);
var afternode = document.createTextNode(afternode_txt);
el.data = ndata = el.data.substr(0,fidx);
$(el).after(afternode).after(this.strf(row.img,this.options));
this.getHTMLSmiles(el.parentNode);
return false;
}
this.getHTMLSmiles(el);
},this));
}
},
//UTILS
setUID: function(el,attr) {
Expand Down Expand Up @@ -3023,4 +3028,4 @@ wbbdebug=true;
this.$block.find(".upl-error").remove().end().append('<span class="upl-error">'+msg+'</span>').addClass("wbbm-brdred");
}
}
})(jQuery);
})(jQuery);