fix some bugs in insert html dialog

This commit is contained in:
rlx 2012-02-16 18:04:25 +00:00
parent e1d8e2aeea
commit 7d4fd8f706
2 changed files with 33 additions and 8 deletions

View file

@ -12,6 +12,9 @@ Ox.InsertHTMLDialog = function(options, self) {
start: 0
}, options || {});
self.type = self.options.selection.indexOf('\n') > -1
? 'textarea' : 'input';
self.items = [
{id: 'img', title: 'Image'},
{id: 'a', title: 'Link'},
@ -48,12 +51,15 @@ Ox.InsertHTMLDialog = function(options, self) {
} else if (item.id == 'a') {
form = [
Ox.Input({
height: 104,
id: 'text',
label: 'Text',
labelWidth: 128,
type: self.type,
width: 384,
value: self.options.selection
}),
})
.css({background: 'transparent'}),
Ox.Input({
id: 'url',
label: 'URL',
@ -80,6 +86,7 @@ Ox.InsertHTMLDialog = function(options, self) {
id: 'items',
label: 'Items',
max: 10,
value: self.options.selection.split('\n'),
width: 384
})
];
@ -91,12 +98,15 @@ Ox.InsertHTMLDialog = function(options, self) {
} else if (['p', 'blockquote', 'div'].indexOf(item.id) > -1) {
form = [
Ox.Input({
id: 'text',
height: 128,
id: 'text',
label: 'Text',
labelWidth: 128,
type: 'textarea',
width: 384,
value: self.options.selection
value: self.options.selection,
width: 384
})
.css({background: 'transparent'})
];
format = function(values) {
return '<' + item.id + (
@ -104,14 +114,18 @@ Ox.InsertHTMLDialog = function(options, self) {
) + '>' + values.text + '</' + item.id + '>';
};
} else if (['h1', 'b', 'i', 'code', 's', 'sub', 'sup', 'u'].indexOf(item.id) > -1) {
Ox.print(self.options.selection.indexOf('\n'), '?????????')
form = [
Ox.Input({
height: 128,
id: 'text',
label: 'Text',
labelWidth: 128,
width: 384,
value: self.options.selection
type: self.type,
value: self.options.selection,
width: 384
})
.css({background: 'transparent'})
];
format = function(values) {
return '<' + item.id + '>' + values.text + '</' + item.id + '>';
@ -164,7 +178,6 @@ Ox.InsertHTMLDialog = function(options, self) {
})
.bindEvent({
click: function() {
Ox.print('SFV:::::', self.$form.values())
var item = Ox.getObjectById(self.items, self.$select.value()),
value = item.format(
item.form.length ? self.$form.values() : void 0
@ -179,6 +192,7 @@ Ox.InsertHTMLDialog = function(options, self) {
}
})
],
closeButton: true,
content: self.$content,
height: 184,
keys: {enter: 'insert', escape: 'cancel'},
@ -188,6 +202,7 @@ Ox.InsertHTMLDialog = function(options, self) {
function renderForm() {
var items = Ox.getObjectById(self.items, self.$select.value()).form;
Ox.print('??::""""????', self.$select.value())
self.$form && self.$form.remove();
if (items.length) {
self.$form = Ox.Form({

View file

@ -258,6 +258,7 @@ Ox.AnnotationPanel = function(options, self) {
}
function insert(data) {
Ox.print('insert', data);
var id = data.id;
Ox.InsertHTMLDialog(Ox.extend({
callback: function(data) {
@ -334,7 +335,16 @@ Ox.AnnotationPanel = function(options, self) {
} else if (data.id == 'findannotations') {
that.triggerEvent('findannotations', {key: key, value: value});
} else if (data.id == 'insert') {
insert({});
var id = $('.OxEditableElement div.OxInput').data('oxid'),
element = $('.OxEditableElement textarea.OxInput')[0];
insert({
end: element.selectionEnd,
id: id,
selection: element.value
.substr(element.selectionStart, element.selectionEnd),
start: element.selectionStart,
value: element.value
});
} else if (data.id == 'manage') {
that.triggerEvent('define', {
id: self.options.selected,