html/js/edit_area/autocompletion.js in unageanu-jiji-1.1.4 vs html/js/edit_area/autocompletion.js in unageanu-jiji-1.2.1
- old
+ new
@@ -72,12 +72,12 @@
this.container = document.createElement('div');
this.container.id = "auto_completion_area";
editArea.container.insertBefore( this.container, editArea.container.firstChild );
// add event detection for hiding suggestion box
- editArea.add_event( document, "click", function(){ editArea.plugins['autocompletion']._hide();} );
- editArea.add_event( editArea.textarea, "blur", function(){ editArea.plugins['autocompletion']._hide();} );
+ parent.editAreaLoader.add_event( document, "click", function(){ editArea.plugins['autocompletion']._hide();} );
+ parent.editAreaLoader.add_event( editArea.textarea, "blur", function(){ editArea.plugins['autocompletion']._hide();} );
}
/**
* Is called each time the user touch a keyboard key.
@@ -138,11 +138,11 @@
}
// show current suggestion list and do autoSelect if possible (no matter it's shown or hidden)
if( letter=="Space" && CtrlPressed(e) )
{
- parent.console.log('SHOW SUGGEST');
+ //parent.console.log('SHOW SUGGEST');
this.forceDisplay = true;
this.autoSelectIfOneResult = true;
this._checkLetter();
return false;
}
@@ -249,12 +249,11 @@
}
,_select: function( content )
{
cursor_forced_position = content.indexOf( '{@}' );
content = content.replace(/{@}/g, '' );
- if(editArea.nav['isIE'])
- editArea.getIESelection();
+ editArea.getIESelection();
// retrive the number of matching characters
var start_index = Math.max( 0, editArea.textarea.selectionEnd - content.length );
line_string = editArea.textarea.value.substring( start_index, editArea.textarea.selectionEnd + 1);
@@ -306,11 +305,11 @@
tmp["prefix_separator"]= datas["REGEXP"]["prefix_separator"];
tmp["match_prefix_separator"]= new RegExp( datas["REGEXP"]["prefix_separator"] +"$", tmp["modifiers"]);
tmp["match_word"]= new RegExp("(?:"+ datas["REGEXP"]["before_word"] +")("+ datas["REGEXP"]["possible_words_letters"] +")$", tmp["modifiers"]);
tmp["match_next_letter"]= new RegExp("^("+ datas["REGEXP"]["letter_after_word_must_match"] +")$", tmp["modifiers"]);
tmp["keywords"]= {};
- console.log( datas["KEYWORDS"] );
+ //console.log( datas["KEYWORDS"] );
for( var prefix in datas["KEYWORDS"] )
{
tmp["keywords"][prefix]= {
prefix: prefix,
prefix_name: prefix,
@@ -350,23 +349,22 @@
{
if( !parent.editAreaLoader.syntax[editArea.settings['syntax']]['autocompletion'] )
this._parseSyntaxAutoCompletionDatas();
this.curr_syntax= parent.editAreaLoader.syntax[editArea.settings['syntax']]['autocompletion'];
this.curr_syntax_str = editArea.settings['syntax'];
- console.log( this.curr_syntax );
+ //console.log( this.curr_syntax );
}
if( editArea.is_editable )
{
time=new Date;
t1= time.getTime();
- if(editArea.nav['isIE'])
- editArea.getIESelection();
+ editArea.getIESelection();
this.selectIndex = -1;
start=editArea.textarea.selectionStart;
var str = editArea.textarea.value;
- var results= new Array();
+ var results= [];
for(var i in this.curr_syntax)
{
var last_chars = str.substring(Math.max(0, start-this.curr_syntax[i]["max_text_length"]), start);
@@ -383,11 +381,11 @@
//console.log( match_word );
if( match_word )
{
var begin_word= match_word[1];
var match_curr_word= new RegExp("^"+ parent.editAreaLoader.get_escaped_regexp( begin_word ), this.curr_syntax[i]["modifiers"]);
- console.log( match_curr_word );
+ //console.log( match_curr_word );
for(var prefix in this.curr_syntax[i]["keywords"])
{
// parent.console.log( this.curr_syntax[i]["keywords"][prefix] );
for(var j=0; j<this.curr_syntax[i]["keywords"][prefix]['datas'].length; j++)
{
@@ -449,11 +447,11 @@
}
// there is only one result, and we can select it automatically
if( results.length == 1 && this.autoSelectIfOneResult )
{
- console.log( results );
+ // console.log( results );
this._select( results[0][1]['replace_with'] );
}
else if( results.length == 0 )
{
this._hide();
@@ -471,10 +469,10 @@
lines[lines.length]=line;
}
// sort results
this.container.innerHTML = '<ul>'+ lines.sort().join('') +'</ul>';
- var cursor = $("cursor_pos");
+ var cursor = _$("cursor_pos");
this.container.style.top = ( cursor.cursor_top + editArea.lineHeight ) +"px";
this.container.style.left = ( cursor.cursor_left + 8 ) +"px";
this._show();
}
\ No newline at end of file