Autocomplete for local links, fix uploads in Opera

master
vitalif 2012-12-16 12:21:04 +00:00 committed by Vitaliy Filippov
parent 85d98ee333
commit 168b93f6af
5 changed files with 106 additions and 48 deletions

View File

@ -1245,53 +1245,6 @@ var nicEditorFontFormatSelect = nicEditorSelect.extend({
nicEditors.registerPlugin(nicPlugin,nicSelectOptions);
/** nicLink */
/* START CONFIG */
var nicLinkOptions = {
buttons : {
'link' : {name : __('Add Link'), type : 'nicLinkButton', tags : ['A']},
'unlink' : {name : __('Remove Link'), command : 'unlink', noActive : true}
}
};
/* END CONFIG */
var nicLinkButton = nicEditorAdvancedButton.extend({
addPane : function() {
this.ln = this.ne.selectedInstance.selElm().parentTag('A');
this.addForm({
'' : {type : 'title', txt : __('Add/Edit Link')},
'href' : {type : 'text', txt : 'URL', value : 'http://', style : {width: '150px'}},
'title' : {type : 'text', txt : __('Hint')},
'target' : {type : 'select', txt : __('Open In'), options : {'' : __('Current Window'), '_blank' : __('New Window')},style : {width : '100px'}}
},this.ln);
},
submit : function(e) {
var url = this.inputs['href'].value;
if(url == "http://" || url == "") {
alert(__("You must enter a URL to Create a Link"));
return false;
}
this.removePane();
if(!this.ln) {
var tmp = 'javascript:nicTemp();';
this.ne.nicCommand("createlink",tmp);
this.ln = this.findElm('A','href',tmp);
}
if(this.ln) {
this.ln.setAttributes({
href : this.inputs['href'].value,
title : this.inputs['title'].value,
target : this.inputs['target'].options[this.inputs['target'].selectedIndex].value
});
}
}
});
nicEditors.registerPlugin(nicPlugin,nicLinkOptions);
/** nicColors */
/* START CONFIG */

View File

@ -35,7 +35,7 @@ var nicImageUploadGTButton = nicEditorAdvancedButton.extend({
s = this.inputs['upload'];
this.inputs['fileName'] = new bkElement('input').setStyle({width: '150px', height: '20px'}).setAttributes({type: 'button', value: __('Select file')}).appendTo(s);
this.inputs['fileName'].addEvent('click', function() { self.inputs['file'].click(); });
this.inputs['file'] = new bkElement('input').setStyle({width: '150px', display: 'none'}).setAttributes({type: 'file', size: 5}).appendTo(s);
this.inputs['file'] = new bkElement('input').setStyle({ width: '150px', position: 'absolute', left: '0', top: '-100px' }).setAttributes({type: 'file', size: 5}).appendTo(s);
this.inputs['file'].addEvent('change', this.onFileChange.closure(this));
new bkElement('br').appendTo(s);
this.inputs['progress'] = new bkElement('progress')

46
nicLink.js Normal file
View File

@ -0,0 +1,46 @@
/** nicLink */
/* START CONFIG */
var nicLinkOptions = {
buttons : {
'link' : {name : __('Add Link'), type : 'nicLinkButton', tags : ['A']},
'unlink' : {name : __('Remove Link'), command : 'unlink', noActive : true}
}
};
/* END CONFIG */
var nicLinkButton = nicEditorAdvancedButton.extend({
addPane : function() {
this.ln = this.ne.selectedInstance.selElm().parentTag('A');
this.addForm({
'' : {type : 'title', txt : __('Add/Edit Link')},
'href' : {type : 'text', txt : 'URL', value : 'http://', style : {width: '150px'}},
'title' : {type : 'text', txt : __('Hint')},
'target' : {type : 'select', txt : __('Open In'), options : {'' : __('Current Window'), '_blank' : __('New Window')},style : {width : '100px'}}
},this.ln);
},
submit : function(e) {
var url = this.inputs['href'].value;
if(url == "http://" || url == "") {
alert(__("You must enter a URL to Create a Link"));
return false;
}
this.removePane();
if(!this.ln) {
var tmp = 'javascript:nicTemp();';
this.ne.nicCommand("createlink",tmp);
this.ln = this.findElm('A','href',tmp);
}
if(this.ln) {
this.ln.setAttributes({
href : this.inputs['href'].value,
title : this.inputs['title'].value,
target : this.inputs['target'].options[this.inputs['target'].selectedIndex].value
});
}
}
});
nicEditors.registerPlugin(nicPlugin,nicLinkOptions);

58
nicLinkGT.js Normal file
View File

@ -0,0 +1,58 @@
/** nicLink */
/* START CONFIG */
var nicLinkGTOptions = {
buttons : {
'link' : {name : __('Add Link'), type : 'nicLinkGTButton', tags : ['A']},
'unlink' : {name : __('Remove Link'), command : 'unlink', noActive : true}
}
};
/* END CONFIG */
var nicLinkGTButton = nicEditorAdvancedButton.extend({
addPane: function() {
this.ln = this.ne.selectedInstance.selElm().parentTag('A');
this.addForm({
'': {type: 'title', txt: __('Add/Edit Link')},
'href': {type: 'text', txt: __('URL or Page'), value: '', style: {width: '150px'}},
'title': {type: 'text', txt: __('Hint')},
'target': {type: 'select', txt: __('Open In'), options: {'' : __('Current Window'), '_blank': __('New Window')}, style: {width: '100px'}}
},this.ln);
this.hinter = new SimpleAutocomplete(this.inputs['href'], this.gtLoadData.closure(this), null, null, null, false, true);
},
gtLoadData: function(hint, value) {
POST(GT.domain+'/api.php?action=listpages&format=json', {value: value}, function(r){
try { hint.replaceItems(JSON.parse(r.responseText)); }
catch(e) {}
});
},
submit: function(e) {
var url = this.inputs['href'].value;
if(url == "http://" || url == "") {
alert(__("You must enter a URL to Create a Link"));
return false;
}
var gtId = /^#(\S+)\s+-\s+/.exec(url);
if (gtId) {
url = 'page.php?alias='+gtId[1];
}
this.removePane();
if(!this.ln) {
var tmp = 'javascript:nicTemp();';
this.ne.nicCommand("createlink",tmp);
this.ln = this.findElm('A','href',tmp);
}
if(this.ln) {
this.ln.setAttributes({
href: url,
title: this.inputs['title'].value,
target: this.inputs['target'].options[this.inputs['target'].selectedIndex].value
});
}
}
});
nicEditors.registerPlugin(nicPlugin,nicLinkGTOptions);

View File

@ -50,6 +50,7 @@ var nicRu = {
'Save this content': 'Сохранить',
'Add Link': 'Вставить ссылку',
'URL or Page': 'URL или страница',
'Remove Link': 'Убрать ссылку',
'Add/Edit Link': 'Ссылка',
'Hint': 'Подсказка',