'use strict';
Ox.InsertHTMLDialog = function(options, self) {
var that;
self = self || {};
self.options = Ox.extend({
callback: void 0,
end: 0,
selection: '',
start: 0
}, options || {});
self.type = self.options.selection.indexOf('\n') > -1
? 'textarea' : 'input';
self.items = [
{id: 'img', title: 'Image'},
{id: 'a', title: 'Link'},
{id: 'li', title: 'List'},
{},
{id: 'blockquote', title: 'Blockquote'},
{id: 'h1', title: 'Headline'},
{id: 'p', title: 'Paragraph'},
{id: 'div', title: 'Right-to-Left'},
{},
{id: 'b', title: 'Bold'},
{id: 'i', title: 'Italic'},
{id: 'code', title: 'Monospace'},
{id: 's', title: 'Strike'},
{id: 'sub', title: 'Subscript'},
{id: 'sup', title: 'Superscript'},
{id: 'u', title: 'Underline'},
{},
{id: 'br', title: 'Linebreak'}
].map(function(item, i) {
var form, format;
if (item.id == 'img') {
form = [
Ox.Input({
id: 'url',
label: 'URL',
labelWidth: 128,
width: 384
})
];
format = function(values) {
return '';
};
} 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',
labelWidth: 128,
width: 384
})
];
format = function(values) {
return '' + values.text + '';
};
} else if (item.id == 'li') {
form = [
Ox.Select({
id: 'style',
items: [
{id: 'ul', title: 'Bullets'},
{id: 'ol', title: 'Numbers'}
],
label: 'Style',
labelWidth: 128,
width: 384
}),
Ox.ArrayInput({
id: 'items',
label: 'Items',
max: 10,
value: self.options.selection.split('\n'),
width: 384
})
];
format = function(values) {
return '<' + values.style + '>\n' + values.items.map(function(value) {
return '