From 4dd2c5706d9ad9098565149f3cf64a23803bc4b3 Mon Sep 17 00:00:00 2001
From: rlx <0x0073@0x2620.org>
Date: Thu, 16 Feb 2012 16:35:59 +0000
Subject: [PATCH] add InsertHTMLDialog to VideoEditor
---
source/Ox.UI/js/Form/Ox.ArrayEditable.js | 3 +
source/Ox.UI/js/Form/Ox.Editable.js | 3 +
source/Ox.UI/js/Form/Ox.Input.js | 14 +-
source/Ox.UI/js/Form/Ox.InsertHTMLDialog.js | 203 +++++++++++++++++++
source/Ox.UI/js/Video/Ox.AnnotationFolder.js | 3 +
source/Ox.UI/js/Video/Ox.AnnotationPanel.js | 19 +-
source/Ox.UI/js/Video/Ox.VideoEditor.js | 12 +-
7 files changed, 249 insertions(+), 8 deletions(-)
create mode 100644 source/Ox.UI/js/Form/Ox.InsertHTMLDialog.js
diff --git a/source/Ox.UI/js/Form/Ox.ArrayEditable.js b/source/Ox.UI/js/Form/Ox.ArrayEditable.js
index 37b6384c..0a221257 100644
--- a/source/Ox.UI/js/Form/Ox.ArrayEditable.js
+++ b/source/Ox.UI/js/Form/Ox.ArrayEditable.js
@@ -168,6 +168,9 @@ Ox.ArrayEditable = function(options, self) {
self.editing = true;
that.triggerEvent('edit', data);
},
+ insert: function(data) {
+ that.triggerEvent('insert', data);
+ },
submit: function(data) {
self.editing = false;
that.gainFocus();
diff --git a/source/Ox.UI/js/Form/Ox.Editable.js b/source/Ox.UI/js/Form/Ox.Editable.js
index e7252b7a..0607adf1 100644
--- a/source/Ox.UI/js/Form/Ox.Editable.js
+++ b/source/Ox.UI/js/Form/Ox.Editable.js
@@ -120,6 +120,9 @@ Ox.Editable = function(options, self) {
blur: self.options.submitOnBlur ? submit : blur,
cancel: cancel,
change: change,
+ insert: function(data) {
+ that.triggerEvent('insert', data);
+ },
submit: submit
})
.appendTo(that.$element);
diff --git a/source/Ox.UI/js/Form/Ox.Input.js b/source/Ox.UI/js/Form/Ox.Input.js
index 5e87b182..5390a960 100644
--- a/source/Ox.UI/js/Form/Ox.Input.js
+++ b/source/Ox.UI/js/Form/Ox.Input.js
@@ -117,7 +117,7 @@ Ox.Input = function(options, self) {
.bindEvent(Ox.extend(self.options.type != 'textarea' ? {
key_enter: submit
} : {}, {
- key_control_v: paste,
+ key_control_i: insert,
key_escape: cancel,
key_shift_enter: submit
}));
@@ -719,6 +719,17 @@ Ox.Input = function(options, self) {
- (self.options.style == 'rounded' ? 14 : 6);
}
+ function insert() {
+ var input = self.$input[0];
+ that.triggerEvent('insert', {
+ end: input.selectionEnd,
+ id: that.id,
+ selection: input.value.substring(input.selectionStart, input.selectionEnd),
+ start: input.selectionStart,
+ value: input.value
+ });
+ }
+
function keydown(event) {
var oldCursor = cursor(),
oldValue = self.options.value,
@@ -758,6 +769,7 @@ Ox.Input = function(options, self) {
}
function paste() {
+ // fixme: unused
var data = Ox.Clipboard.paste();
data.text && self.$input.val(data.text);
}
diff --git a/source/Ox.UI/js/Form/Ox.InsertHTMLDialog.js b/source/Ox.UI/js/Form/Ox.InsertHTMLDialog.js
new file mode 100644
index 00000000..b38ccfb9
--- /dev/null
+++ b/source/Ox.UI/js/Form/Ox.InsertHTMLDialog.js
@@ -0,0 +1,203 @@
+'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.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({
+ id: 'text',
+ label: 'Text',
+ labelWidth: 128,
+ width: 384,
+ value: self.options.selection
+ }),
+ 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,
+ width: 384
+ })
+ ];
+ format = function(values) {
+ return '<' + values.style + '>\n' + values.items.map(function(value) {
+ return '