Skip to content

Commit

Permalink
Replaced the custom "xsplit" function with the standard JavaScript sp…
Browse files Browse the repository at this point in the history
…lit function
  • Loading branch information
mweimerskirch committed Feb 25, 2015
1 parent cea594a commit a99b112
Showing 1 changed file with 9 additions and 30 deletions.
39 changes: 9 additions & 30 deletions admin/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ qtranxj_split = function(text)
result[lang] = '';
}
var split_regex = /(<!--:[a-z]{2}-->|<!--:-->|\[:[a-z]{2}\]|\[:\])/gi;
var blocks = text.xsplit(split_regex);
var blocks = text.split(split_regex);
if(!qtranxj_isArray(blocks))
return result;
if(blocks.length==1){//no language separator found, enter it to all languages
Expand Down Expand Up @@ -173,27 +173,6 @@ function qtranxj_get_cookie(cname)
return '';
}

String.prototype.xsplit = function(_regEx){
// Most browsers can do this properly, so let them work, they'll do it faster
if ('a~b'.split(/(~)/).length === 3){ return this.split(_regEx); }

if (!_regEx.global)
{ _regEx = new RegExp(_regEx.source, 'g' + (_regEx.ignoreCase ? 'i' : '')); }

// IE (and any other browser that can't capture the delimiter)
// will, unfortunately, have to be slowed down
var start = 0, arr=[];
var result;
while((result = _regEx.exec(this)) != null){
arr.push(this.slice(start, result.index));
if(result.length > 1) arr.push(result[1]);
start = _regEx.lastIndex;
}
if(start < this.length) arr.push(this.slice(start));
if(start == this.length) arr.push(''); //delim at the end
return arr;
};

function qtranxj_isArray(obj){ return obj.constructor.toString().indexOf('Array') >= 0; }

function qtranxj_ce(tagName, props, pNode, isFirst)
Expand Down Expand Up @@ -498,7 +477,7 @@ var qTranslateX=function(pg)
if(frm.form){
form = document.getElementById(frm.form.id);
}else{
form = this.getWrapForm();
form = this.getWrapForm();
}
//co('form=',form);
//c('frm.fields.length='+frm.fields.length);
Expand All @@ -511,11 +490,11 @@ var qTranslateX=function(pg)
var containers=[];
if(fld.container_id){
var container = document.getElementById(fld.container_id);
if(container) containers.push(container);
if(container) containers.push(container);
}else if(fld.container_class){
containers = document.getElementsByClassName(fld.container_class);
containers = document.getElementsByClassName(fld.container_class);
}else if(form){
containers.push(form);
containers.push(form);
}
var sep = fld.encode;
switch( sep ){
Expand Down Expand Up @@ -562,13 +541,13 @@ var qTranslateX=function(pg)
}
}
}else{
continue;
continue;
}
break;
}
}
}
return true;
return true;
}

this.addContentHooksTinyMCE=function()
Expand Down Expand Up @@ -665,8 +644,8 @@ var qTranslateX=function(pg)
for(var i=0; i < qTranslateConfig.page_config.anchors.length; ++i){
var anchor = qTranslateConfig.page_config.anchors[i];
var f = document.getElementById(anchor);
if(f) anchors.push(f);
}
if(f) anchors.push(f);
}
}
if(!anchors.length){
var f=pg.langSwitchWrapAnchor;
Expand Down

0 comments on commit a99b112

Please sign in to comment.