From 89a3a119da4d161f2e03647c40cedf092ba5f0f3 Mon Sep 17 00:00:00 2001
From: rlx <0x0073@0x2620.org>
Date: Sun, 5 Feb 2012 11:08:56 +0000
Subject: [PATCH] honor layer showInfo flag and display creator as part of
tooltip (fixes #332)
---
source/Ox.UI/js/Form/Ox.ArrayEditable.js | 11 ++++--
source/Ox.UI/js/Video/Ox.AnnotationFolder.js | 8 +++--
source/Ox.UI/js/Video/Ox.AnnotationPanel.js | 36 +++++++++-----------
source/Ox.UI/js/Video/Ox.VideoEditor.js | 5 ++-
4 files changed, 33 insertions(+), 27 deletions(-)
diff --git a/source/Ox.UI/js/Form/Ox.ArrayEditable.js b/source/Ox.UI/js/Form/Ox.ArrayEditable.js
index 1b75389d..7374396f 100644
--- a/source/Ox.UI/js/Form/Ox.ArrayEditable.js
+++ b/source/Ox.UI/js/Form/Ox.ArrayEditable.js
@@ -21,6 +21,7 @@ Ox.ArrayEditable = function(options, self) {
separator: ',',
sort: [],
submitOnBlur: true,
+ tooltip: '',
type: 'input',
width: 256
})
@@ -117,8 +118,14 @@ Ox.ArrayEditable = function(options, self) {
highlight: self.options.highlight,
maxHeight: self.options.maxHeight,
submitOnBlur: self.options.submitOnBlur,
- tooltip: 'Click to select' + (
- item.editable ? ', doubleclick to edit' : ''
+ tooltip: (
+ self.options.tooltipText
+ ? Ox.formatString(self.options.tooltipText, item) + '
'
+ : ''
+ ) + 'Click to select' + (
+ item.editable
+ ? ', doubleclick to edit'
+ : ''
),
type: self.options.type,
value: item.value,
diff --git a/source/Ox.UI/js/Video/Ox.AnnotationFolder.js b/source/Ox.UI/js/Video/Ox.AnnotationFolder.js
index 3bb462e0..6afc7279 100644
--- a/source/Ox.UI/js/Video/Ox.AnnotationFolder.js
+++ b/source/Ox.UI/js/Video/Ox.AnnotationFolder.js
@@ -34,6 +34,7 @@ Ox.AnnotationFolder = function(options, self) {
position: 0,
range: 'all',
selected: '',
+ showInfo: false,
showWidget: false,
sort: 'position',
title: '',
@@ -225,6 +226,7 @@ Ox.AnnotationFolder = function(options, self) {
separator: ';',
sort: self.sort,
submitOnBlur: false,
+ tooltipText: self.options.showInfo ? '{user}, {modified}' : '',
width: self.options.width,
maxHeight: self.options.type == 'text' ? Infinity : void 0,
type: self.options.type == 'text' ? 'textarea' : 'input'
@@ -327,7 +329,7 @@ Ox.AnnotationFolder = function(options, self) {
}
function getAnnotations() {
- return self.options.items.filter(function(item) {
+ return Ox.map(self.options.items, function(item) {
return self.editing && item.id == self.options.selected || (
(
self.options.range == 'all' || (
@@ -343,7 +345,9 @@ Ox.AnnotationFolder = function(options, self) {
self.options.users == 'all'
|| self.options.users.indexOf(item.user) > -1
)
- );
+ ) ? Ox.extend({
+ date: Ox.formatDate(item.modified.substr(0, 10), '%B %e, %Y')
+ }, item) : null;
});
}
diff --git a/source/Ox.UI/js/Video/Ox.AnnotationPanel.js b/source/Ox.UI/js/Video/Ox.AnnotationPanel.js
index 77612304..d52cc59b 100644
--- a/source/Ox.UI/js/Video/Ox.AnnotationPanel.js
+++ b/source/Ox.UI/js/Video/Ox.AnnotationPanel.js
@@ -261,27 +261,23 @@ Ox.AnnotationPanel = function(options, self) {
}
function scrollToSelected(type) {
- //try {
- var $item = that.find('.OxEditableElement.OxSelected'),
- itemHeight = $item.height() + (type == 'text' ? 8 : 0),
- itemTop = $item.offset().top,
- itemBottom = itemTop + itemHeight,
- height = self.$folders.height(),
- scrollTop = self.$folders.scrollTop(),
- top = self.$folders.offset().top;
- if (itemTop < top || itemBottom > top + height) {
- if (itemTop < top) {
- scrollTop += itemTop - top;
- } else {
- scrollTop += itemBottom - top - height;
- }
- self.$folders.animate({
- scrollTop: scrollTop + 'px'
- }, 0);
+ var $item = that.find('.OxEditableElement.OxSelected'),
+ itemHeight = $item.height() + (type == 'text' ? 8 : 0),
+ itemTop = $item.offset().top,
+ itemBottom = itemTop + itemHeight,
+ height = self.$folders.height(),
+ scrollTop = self.$folders.scrollTop(),
+ top = self.$folders.offset().top;
+ if (itemTop < top || itemBottom > top + height) {
+ if (itemTop < top) {
+ scrollTop += itemTop - top;
+ } else {
+ scrollTop += itemBottom - top - height;
}
- //} catch(e) {
- // Ox.print('THIS SHOULD NOT HAPPEN');
- //}
+ self.$folders.animate({
+ scrollTop: scrollTop + 'px'
+ }, 0);
+ }
}
function selectAnnotation(data, index) {
diff --git a/source/Ox.UI/js/Video/Ox.VideoEditor.js b/source/Ox.UI/js/Video/Ox.VideoEditor.js
index 4f421894..45f3b5af 100644
--- a/source/Ox.UI/js/Video/Ox.VideoEditor.js
+++ b/source/Ox.UI/js/Video/Ox.VideoEditor.js
@@ -181,9 +181,8 @@ Ox.VideoEditor = function(options, self) {
}
});
- Ox.loop(1, self.options.layers.length + 1, function(i) {
- that.bindEvent('key_' + i, function() {
- var layer = self.options.layers[i - 1];
+ self.options.layers.forEach(function(layer, i) {
+ that.bindEvent('key_' + (i + 1), function() {
layer.editable
? addAnnotation(layer.id)
: that.triggerEvent('info', {layer: layer.id});