Другие технические решения: различия между версиями

Материал из Вики проекта PascalABC.NET
Перейти к навигацииПерейти к поиску
Строка 67: Строка 67:
<source lang="JavaScript">
<source lang="JavaScript">
"EA.Ä.get_currFileTitle=Ã(id){return Á.files[id]['title']};"
"EA.Ä.get_currFileTitle=Ã(id){return Á.files[id]['title']};"
</source>
== Переход на вкладку ==
В <tt>EAL.prototype</tt> добавлен метод <tt>switchToFile</tt>.
<source lang="javascript">
switchToFile : function(id, newFileID) {
    this.execCommand(id, 'switch_to_file', newFileID);
},
</source>
</source>

Версия от 21:42, 15 августа 2009

Мультифайловость в редакторе

Описание

Работа с несколькими файлами одновременно вещь весьма полезная. Выбранный редактор с подсветкой синтаксиса EditArea эту возможность предоставляет. Однако, задать заголовок вкладки в нем можно только при её первом открытии, что, конечно, неудобно. В связи с этим в файл edit_area_full.js были внесены поправки и добавлен метод для изменения не только содержимого вкладки, но и её заголовка.

changeFile

В EAL.prototype добавлен метод changeFile.

changeFile : function(id, newFile) {
    var curID = this.execCommand(id, 'curr_file')
        
    this.execCommand(id, 'change_curFileTabParams', newFile);
    this.setValue(id, newFile['text']);
},

change_curFileTabParams

В содержимое editAreaLoader.iframe_script, например, перед update_file:

"EA.Ä.change_curFileTabParams=Ã(new_Ês){var curID = this.curr_file; this.update_file(curID, new_Ês); var elem=document.getElementById(this.files[curID]['html_id']); var html_curID='tab_file_'+encodeURIComponent(curID); this.filesIdAssoc[html_curID]=curID; this.files[curID]['html_id']= html_curID; var close=\"<img src=\\\"\"+È.eAL.baseURL+\"images/close.gif\\\" title=\\\"\"+Á.get_translation('close_tab','word')+\"\\\" onclick=\\\"eA.execCommand('close_file',eA.filesIdAssoc['\"+html_curID+\"']);return Ì;\\\" class=\\\"hidden\\\" onmouseover=\\\"Á.className=''\\\" onmouseout=\\\"Á.className='hidden'\\\" />\";elem.innerHTML=\"<a onclick=\\\"javascript:eA.execCommand('switch_to_file',eA.filesIdAssoc['\"+html_curID+\"']);\\\" selec=\\\"none\\\"><b><span><strong class=\\\"edited\\\">*</strong>\"+Á.files[curID]['title']+close+\"</span></b></a>\";};"

Или, если работаете не с edit_area_full.js, в edit_area_functions.js:

EditArea.prototype.change_curFileTabParams = function(new_Ês){
    var curID = this.curr_file;
    this.update_file(curID, new_Ês);

    var elem = document.getElementById(this.files[curID]['html_id']);
    var html_curID = 'tab_file_' + encodeURIComponent(curID);
    this.filesIdAssoc[html_curID] = curID;
    this.files[curID]['html_id'] = html_curID;
    
    var close = "<img src=\""+ parent.editAreaLoader.baseURL +"images/close.gif\" title=\""+ this.get_translation('close_tab', 'word') +"\" onclick=\"editArea.execCommand('close_file', editArea.filesIdAssoc['"+ html_id +"']);return false;\" class=\"hidden\" onmouseover=\"this.className=''\" onmouseout=\"this.className='hidden'\" />";
    elem.innerHTML = "<a onclick=\"javascript:editArea.execCommand('switch_to_file', editArea.filesIdAssoc['"+ html_id +"']);\" selec=\"none\"><b><span><strong class=\"edited\">*</strong>"+ this.files[id]['title'] + close +"</span></b></a>";
}

Регулировка высоты редактора

Изначально в редакторе отсутствует возможность менять размер после загрузки страницы (кроме как воспользоваться кнопкой полного экрана).

changeHeight

В EAL.prototype добавлен метод changeHeight .

changeHeight : function(id, newHeight) {
    this.execCommand(id, 'change_Height', newHeight);
},

change_curFileTabParams

В содержимое editAreaLoader.iframe_script, например, после update_size:

"EA.Ä.change_Height=Ã(newHeight){var d=document,pd=È.document; if(typeof eAs !='undefined'&&eAs[eA.id]&&eAs[eA.id][\"displayed\"]==Ë){pd.getElementById(\"frame_\"+eA.id).Ç.height=newHeight;};};"

Заголовок текущей вкладки

getCurrFileTitle

В EAL.prototype добавлен метод getCurrFileTitle.

getCurrFileTitle : function (id) {
    var curID = this.execCommand(id, 'curr_file')
    return this.execCommand(id, 'get_currFileTitle', curID);
},

get_currFileTitle

В содержимое editAreaLoader.iframe_script:

"EA.Ä.get_currFileTitle=Ã(id){return Á.files[id]['title']};"

Переход на вкладку

В EAL.prototype добавлен метод switchToFile.

switchToFile : function(id, newFileID) {
    this.execCommand(id, 'switch_to_file', newFileID);
},