Merge lp:~jamesmr/dmedia/browser-merge into lp:dmedia

Proposed by James Raymond
Status: Merged
Merged at revision: 449
Proposed branch: lp:~jamesmr/dmedia/browser-merge
Merge into: lp:dmedia
Diff against target: 470 lines (+406/-8)
3 files modified
ui/browser2.css (+143/-0)
ui/dmedia.js (+244/-2)
ui/index.html (+19/-6)
To merge this branch: bzr merge lp:~jamesmr/dmedia/browser-merge
Reviewer Review Type Date Requested Status
Jason Gerard DeRose Approve
Review via email: mp+120308@code.launchpad.net

Description of the change

Pulled the browser code from the external browser app into the main dmedia window.

To post a comment you must log in.
Revision history for this message
Jason Gerard DeRose (jderose) wrote :

I'm on Quantal testing this, but it seems rather broken. Are you sure all your files are committed?

review: Approve
lp:~jamesmr/dmedia/browser-merge updated
452. By James Raymond

Changed thumbnails to <img> from <div>

Revision history for this message
Jason Gerard DeRose (jderose) wrote :

Looks good, things are working under Quantal now that you're using <img> instead of <div> for the thumbnails. WebKitGtk bug, it seems.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'ui/browser2.css'
--- ui/browser2.css 1970-01-01 00:00:00 +0000
+++ ui/browser2.css 2012-08-21 18:23:28 +0000
@@ -0,0 +1,143 @@
1#browser_target{
2 position:fixed;
3 top:40px;
4 left:0px;
5 right:0px;
6 bottom:0px;
7}
8
9#content {
10 position: absolute;
11 top: 40px;
12 bottom: 170px;
13 left: 0;
14 right: 210px;
15 background-color: black;
16 overflow-x: auto;
17 overflow-y: auto;
18}
19
20#lower {
21 position: absolute;
22 height: 170px;
23 bottom: 0;
24 left: 0;
25 right: 210px;
26 overflow-x: auto;
27 overflow-y: visible;
28 background: -webkit-linear-gradient(top, #222, #333);
29 border-top:1px solid #444;
30}
31
32#right {
33 position: absolute;
34 top: 40px;
35 bottom: 0;
36 width: 210px;
37 right: 0;
38 background-color: #333;
39 border-left: 1px solid #444;
40 color: white;
41 overflow-y: scroll;
42 overflow-x: hidden;
43 z-index: 200;
44}
45
46img.thumbnail{
47 font-size:0px;
48 line-height:0px;
49}
50
51#right .thumbnail {
52 width: 192px;
53 height: 108px;
54 border: 2px solid black;
55 border-top: 2px solid #111;
56 overflow: hidden;
57 background-position: center center;
58 background-size: cover;
59}
60
61#right .thumbnail.selected {
62 border-color: #e81f3b;
63}
64
65.large #content {
66 right: 260px;
67}
68
69.large #lower {
70 right: 260px;
71}
72
73.large #right {
74 width: 260px;
75}
76
77.large .thumbnail {
78 width: 240px;
79 height: 135px;
80}
81
82#player {
83 position: absolute;
84 top: 0px;
85 left: 0px;
86 width: 100%;
87 height: 100%;
88}
89
90ul.matches {
91 list-style: none;
92 color: white;
93 background: -webkit-linear-gradient(top, #666, #555);
94 box-shadow: 0px 2px 5px 1px rgba(0,0,0,0.3);
95 border-bottom-left-radius: 3px;
96 border-bottom-right-radius: 3px;
97 overflow: hidden;
98}
99
100ul.matches li {
101 padding: 0px 5px;
102 white-space: nowrap;
103 cursor: default;
104 -webkit-user-select: none;
105}
106
107ul.matches li:hover {
108 background-color: rgba(255,255,255,0.2);
109}
110
111ul.matches li.selected {
112 background-color: #e81f3b;
113}
114
115
116ul.tags {
117 font-size: 0;
118 list-style: none;
119
120 height: 150px;
121 padding: 2px;
122}
123
124ul.tags li {
125 margin-left: 4px;
126 margin-top:4px;
127 padding-left: 4px;
128 background: -webkit-linear-gradient(top, #eee, #ccc);
129 display: inline-block;
130 cursor: default;
131 color:#333;
132 border-radius: 3px;
133}
134
135ul.tags li a {
136 text-decoration: none;
137 display: inline-block;
138 color: #d12;
139 font-weight: bold;
140 text-align: center;
141 cursor: pointer;
142 width: 1.5em;
143}
0144
=== modified file 'ui/dmedia.js'
--- ui/dmedia.js 2012-02-27 15:03:45 +0000
+++ ui/dmedia.js 2012-08-21 18:23:28 +0000
@@ -8,6 +8,9 @@
8 UI.tabinit[id] = true;8 UI.tabinit[id] = true;
9 UI['init_' + id]();9 UI['init_' + id]();
10 }10 }
11 if (UI.player){
12 UI.player.pause();
13 }
11 },14 },
1215
13 init_import: function() {16 init_import: function() {
@@ -19,15 +22,68 @@
19 },22 },
2023
21 init_browser: function() {24 init_browser: function() {
22 console.log('init_browser');25 UI.player = $el('video', {'id': 'player'});
26 UI.player.addEventListener('click', UI.player_click);
27 $("content").appendChild(UI.player);
28 UI.browser = new Browser(UI.importer.project, UI.player, 'right');
29 //console.log('init_browser');
23 },30 },
2431
25 init_storage: function() {32 init_storage: function() {
26 console.log('init_storage'); 33 console.log('init_storage');
27 },34 },
35
36 player_click: function(event){
37 if (!UI.player.paused) {
38 UI.player.pause();
39 }
40 else {
41 UI.player.play();
42 }
43 },
28 44
29}45}
3046
47function make_tag_li(remove, doc, id) {
48 var id = id || doc._id;
49 var li = $el('li', {textContent: doc.value});
50 var a = $el('a', {textContent: 'x', title: 'Click to remove tag'});
51 li.appendChild(a);
52 a.onclick = function() {
53 remove(id, li);
54 }
55 return li;
56}
57
58
59function wheel_delta(event) {
60 var delta = event.wheelDeltaY;
61 if (delta == 0) {
62 return 0;
63 }
64 var scale = (event.shiftKey) ? -10 : -1;
65 return scale * (delta / Math.abs(delta));
66}
67
68
69function set_flag(div, review) {
70 if (!review) {
71 return;
72 }
73 div.appendChild(
74 $el('img', {'src': review + '.png'})
75 );
76}
77
78
79function reset_flag(id, review) {
80 var div = $(id);
81 if (!div) {
82 return;
83 }
84 div.innerHTML = null;
85 set_flag(div, review);
86}
3187
32function Importer() {88function Importer() {
33 this.create_button = $('create_project');89 this.create_button = $('create_project');
@@ -133,7 +189,193 @@
133189
134}190}
135191
136192function Browser(project, player, items) {
193 this.player = $(player);
194 this.tags = $('tags');
195 this.doc = null;
196
197 this.items = new Items(items);
198 this.items.onchange = $bind(this.on_item_change, this);
199 this.items.parent.onmousewheel = $bind(this.on_mousewheel, this);
200
201 this.project = project;
202
203 this.tagger = new Tagger(this.project, 'tag_form');
204 this.tagger.ontag = $bind(this.on_tag, this);
205
206 window.addEventListener('keydown', $bind(this.on_window_keydown, this));
207 window.addEventListener('keypress', $bind(this.on_window_keypress, this));
208
209 this.load_items();
210}
211Browser.prototype = {
212 _review: function(value) {
213 this.doc.review = value;
214 this.project.db.save(this.doc);
215 reset_flag(this.doc._id, value);
216 },
217
218 accept: function() {
219 if (!this.doc) {
220 return;
221 }
222 this._review('accept');
223 },
224
225 reject: function() {
226 if (!this.doc) {
227 return;
228 }
229 this._review('reject');
230 this.next();
231 },
232
233 next_needing_review: function() {
234 var rows = this.project.db.view_sync('user', 'video_needsreview', {'limit': 1}).rows;
235 if (rows.length == 1) {
236 this.items.select(rows[0].id);
237 }
238 },
239
240 next: function() {
241 this.items.next();
242 },
243
244 previous: function() {
245 this.items.previous();
246 },
247
248 load_items: function() {
249 var callback = $bind(this.on_items, this);
250 this.project.db.view(callback, 'user', 'video');
251 },
252
253 on_items: function(req) {
254 var self = this;
255 var callback = function(row) {
256 var id = row.id;
257 var child = $el('img',
258 {
259 'class': 'thumbnail',
260 'id': row.id,
261 'src': self.project.att_url(row.id),
262 //'textContent': row.id,
263 }
264 );
265 child.onclick = function() {
266 self.items.select(id);
267 }
268 //child.style.backgroundImage = self.project.att_css_url(row.id);
269
270 child.draggable = true;
271 child.ondragstart = function(e) {
272 e.dataTransfer.effectAllowed = 'copy';
273 e.dataTransfer.setData('Text', self.project.db.name + "/" + id);
274 var img = $el('img', {'src': self.project.att_url(id)});
275 e.dataTransfer.setDragImage(img, 0, 0);
276 }
277
278 if (row.value) {
279 set_flag(child, row.value);
280 }
281 return child;
282 }
283 this.items.replace(req.read().rows, callback);
284 this.next_needing_review();
285 },
286
287 on_item_change: function(id) {
288 if (!id) {
289 this.doc = null;
290 this.player.pause();
291 this.player.src = null;
292 return;
293 }
294 this.player.src = 'dmedia:' + id;
295 this.player.play();
296 this.tagger.reset();
297 this.tags.innerHTML = null;
298 this.project.db.get($bind(this.on_doc, this), id);
299 },
300
301 on_doc: function(req) {
302 this.doc = req.read();
303 var keys = Object.keys(this.doc.tags);
304 var remove = $bind(this.on_tag_remove, this);
305 keys.forEach(function(key) {
306 this.tags.appendChild
307 (make_tag_li(remove, this.doc.tags[key], key)
308 );
309 }, this);
310 },
311
312 on_tag: function(tag) {
313 //console.log(tag);
314 if (!this.doc) {
315 return;
316 }
317 if (!this.doc.tags) {
318 this.doc.tags = {};
319 }
320 if (!this.doc.tags[tag._id]) {
321 var remove = $bind(this.on_tag_remove, this);
322 $prepend(make_tag_li(remove, tag), this.tags);
323 this.doc.tags[tag._id] = {key: tag.key, value: tag.value};
324 }
325 else {
326 this.doc.tags[tag._id].key = tag.key;
327 this.doc.tags[tag._id].value = tag.value;
328 }
329 this.project.db.save(this.doc);
330 },
331
332 on_tag_remove: function(id, li) {
333 this.tags.removeChild(li);
334 if (this.doc && this.doc.tags) {
335 delete this.doc.tags[id];
336 this.project.db.save(this.doc);
337 }
338 },
339
340 on_mousewheel: function(event) {
341 event.preventDefault();
342 var delta = wheel_delta(event) * 112; // 108px height + 2px border
343 this.items.parent.scrollTop += delta;
344 },
345
346
347 on_window_keydown: function(event) {
348 var keyID = event.keyIdentifier;
349 if (['Up', 'Down', 'Enter', 'U+007F'].indexOf(keyID) > -1 && !this.tagger.input.value) {
350 event.preventDefault();
351 event.stopPropagation();
352 if (keyID == 'Up') {
353 this.previous();
354 }
355 else if (keyID == 'Down') {
356 this.next();
357 }
358 else if (keyID == 'Enter') {
359 this.accept();
360 }
361 else { // Delete
362 this.reject();
363 }
364 }
365 },
366
367 on_window_keypress: function(event) {
368 //console.log(['window keypress', event.which, event.keyCode].join(', '));
369 if (this.tagger.isfocused) {
370 return;
371 }
372 // Don't focus on Backspace, Enter, Spacebar, or Delete
373 if ([8, 13, 32, 127].indexOf(event.keyCode) == -1) {
374 this.tagger.focus();
375 }
376 },
377
378}
137379
138window.onload = function() {380window.onload = function() {
139 UI.progressbar = new ProgressBar('progress');381 UI.progressbar = new ProgressBar('progress');
140382
=== modified file 'ui/index.html'
--- ui/index.html 2012-04-24 11:41:08 +0000
+++ ui/index.html 2012-08-21 18:23:28 +0000
@@ -4,6 +4,7 @@
4 <link rel="stylesheet" href="grid.css"></link>4 <link rel="stylesheet" href="grid.css"></link>
5 <link rel="stylesheet" href="style.css"></link>5 <link rel="stylesheet" href="style.css"></link>
6 <link rel="stylesheet" href="common.css"></link>6 <link rel="stylesheet" href="common.css"></link>
7 <link rel="stylesheet" href="browser2.css"></link>
7 <script src="/_apps/userwebkit/couch.js"></script>8 <script src="/_apps/userwebkit/couch.js"></script>
8 <script src="/_apps/userwebkit/base.js"></script>9 <script src="/_apps/userwebkit/base.js"></script>
9 <script src="common.js"></script>10 <script src="common.js"></script>
@@ -65,13 +66,25 @@
65 </div>66 </div>
66 </div>67 </div>
67 <div id="browser_target" class="hide">68 <div id="browser_target" class="hide">
68 <div class="grid_row darkbar">69 <div class="grid_row darkbar">
69 <select id="browser_projects" class="grid_1"></select>70 <select id="browser_projects" class="grid_1"></select>
70 <input id="tag" class="grid_2" type="text"></input>71 <input id="tag" class="grid_2" type="text"></input>
71 <ul id="tag_matches"></ul>72 <ul id="tag_matches"></ul>
73 </div>
74 <div id="content"></div>
75
76 <form id="tag_form">
77 <div id="lower" class="grid_row">
78 <div id="add_tag" class="grid_3 grid_cell">
79 <input id="tag_value"></input>
80 <ul class="matches" id="tag_matches"></ul>
81 </div>
82 <button id="tag_button" class="grid_1 arrow" disabled>Tag &rarr;</button>
83 <ul id="tags" class="grid_5 tags inset"></ul>
72 </div>84 </div>
73 <video width="640" height="360" id="player"></video>85 </form>
74 <div id="tray"></div>86
87 <div id="right"></div>
75 </div>88 </div>
76 <div id="storage_target" class="hide">89 <div id="storage_target" class="hide">
77 <div class="grid_row darkbar">90 <div class="grid_row darkbar">

Subscribers

People subscribed via source and target branches

to all changes: