Merge lp:~mttronchetti/novacut/bin into lp:novacut

Proposed by Matteo Ronchetti
Status: Merged
Merged at revision: 281
Proposed branch: lp:~mttronchetti/novacut/bin
Merge into: lp:novacut
Diff against target: 336 lines (+162/-50)
2 files modified
ui/projects.html (+93/-33)
ui/projects.js (+69/-17)
To merge this branch: bzr merge lp:~mttronchetti/novacut/bin
Reviewer Review Type Date Requested Status
Jason Gerard DeRose Approve
Review via email: mp+115151@code.launchpad.net

Description of the change

I did some improvements related to the ex history menu:
1)Calling it history was a bad idea so I removed history name and I've replaced it with a bin icon.In my opinion is easy to understand what this icon stands for so it is good.The small problem is that I have drawn the icon so it is OK but nothing amazing but easy to understand
2)I have made the bin menu looking like this:
      if there aren't removed projects display a simple description of the menu as suggested in this bug https://bugs.launchpad.net/novacut/+bug/1023766
      if there are less than 5 projects show them
      if there are more than 5 projects show the first 5 and also a real time search bar(really cool)
3)To make more understandable where removed projects go I added an animation
4)The small cross that allows you to remove projects now shows you that it is clickable by changing its transparency on mouse over
5)The menu is already shown by onmouseover but I have improved usability using an invisible div that makes easier to move the mouse from the bin icon to the menu.In my opinion it is better than open the menu with a click

I' m very proud of my work but if you don't agree with something tell it to me so we can talk about this and improve novacut :P

P.S. I have done some usability tests with my sister and they went good

To post a comment you must log in.
lp:~mttronchetti/novacut/bin updated
283. By Matteo Ronchetti

small bugfix

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

I love the new feature. You just need to fix the needless chmod changes, please, and then I'll merge this.

just chmod +x on the scripts you see in the diff, and then commit.

review: Needs Fixing
lp:~mttronchetti/novacut/bin updated
284. By Matteo Ronchetti

fix execute permissions

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

Looks great, thanks!

A lovely feature that I'm sure will be a crowd pleaser :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gen-random-project.py' (properties changed: +x to -x)
2=== added file 'ui/bin2.png'
3Binary files ui/bin2.png 1970-01-01 00:00:00 +0000 and ui/bin2.png 2012-07-16 17:50:27 +0000 differ
4=== modified file 'ui/projects.html'
5--- ui/projects.html 2012-06-19 16:57:22 +0000
6+++ ui/projects.html 2012-07-16 17:50:27 +0000
7@@ -15,22 +15,38 @@
8 ev.dataTransfer.effectAllowed = 'move';
9 }
10 function enter(ev){
11- ev.target.setAttribute("style","background-color: rgba(255,255,255,0.15); height: 2000px;width = 2000px;");
12+ ev.preventDefault();
13+ //ev.target.setAttribute("style","cursor: ;");
14 return false;
15 }
16 function leave(ev){
17- ev.target.setAttribute("style","height: 2000px;width = 2000px");
18 return false;
19 }
20 function d(ev){
21 ev.preventDefault();
22- ev.target.setAttribute("style","height: 2000px;width = 2000px;");
23 var data=ev.dataTransfer.getData("Text");
24 Hub.send('sos_project', data);
25 element = document.getElementById(data);
26 element.parentNode.removeChild(element);
27 var doc = novacut.get_sync(data)
28 UI.add_item(data,doc.title,doc.time,countFiles(data));
29+ var old = UI.removed.length;
30+ for(var b in UI.removed){//remove the project from the list
31+ if(UI.removed[b][0] == data){
32+ UI.removed.splice(b,1);
33+ break;
34+ }
35+ }
36+ if(UI.removed.length == 0)document.getElementById("cont").innerHTML=UI.binDesc;
37+ else if(UI.removed.length > UI.binMax)UI.add_history(UI.removed[UI.binMax-1][0],UI.removed[UI.binMax-1][1],UI.removed[UI.binMax-1][2],UI.removed[UI.binMax-1][3]);
38+ if(UI.removed.length == UI.binMax){
39+ document.getElementById("cont").innerHTML="";
40+ document.getElementById("list").innerHTML="";
41+ for(var b = 0;b<UI.binMax;b++){
42+ var a = UI.removed[b];
43+ UI.add_history(a[0],a[1],a[2],a[3]);
44+ }
45+ }
46 return false;
47 }
48 function over(ev){
49@@ -48,6 +64,15 @@
50 cursor: default;
51 }
52
53+#menu img{
54+width: 31px;
55+margin-top: -7px;
56+margin-right: -8px;
57+-webkit-animation-duration: .8s;
58+ -webkit-animation-iteration-count: 1;
59+ -webkit-animation-timing-function: linear;
60+
61+}
62 #menu li{
63 float: left;
64 padding: 0 0 10px 0;
65@@ -57,48 +82,79 @@
66 #menu li:hover > a{
67 color: #fafafa;
68 }
69-#menu li:hover > ul{
70+#menu li:hover > #bi{
71 display: block;
72 }
73
74-#menu ul{ /*container*/
75- min-width: 320px;
76- min-height: 26px;
77- list-style: none;
78- margin: 0px -269px;
79- padding: 4px;
80- display: none;
81- position: absolute;
82- top: 35px;
83- left: 0;
84- z-index: 99999;
85- background: #444;
86- border-radius: 10px;
87- box-shadow: 1px 1px 10px rgba(0,0,0,0.5);
88-}
89-#menu ul li{ /* projects*/
90+#bi{ /*container*/
91+ min-width: 320px;
92+ min-height: 26px;
93+ list-style: none;
94+ margin: 0px -302px;
95+ padding: 4px;
96+ display: none;
97+ position: absolute;
98+ top: 39px;
99+ left: 0;
100+ z-index: 99999;
101+ background: -webkit-linear-gradient(top,rgb(87,87,87),rgb(65,65,65));
102+ border-radius: 10px;
103+ box-shadow: 1px 1px 10px rgba(0,0,0,0.5);
104+}
105+
106+#menu input{
107+ width: 282px;
108+ margin: 6px 3px 2px 5px;
109+ border-radius: 15px;
110+ background: -webkit-linear-gradient(top,#E6E6E6,#FAFAFA);
111+ border: solid 1px rgba(0, 0, 0, 0.72);
112+ box-shadow: none;
113+ padding-left: 28px;
114+ color: black;
115+}
116+
117+#lens{
118+margin-left: -313px;
119+margin-bottom: -11px;
120+}
121+#menu ul ul li{ /* projects*/
122 float: none;
123 margin: 10px;
124 padding: 0;
125 display: block;
126 cursor: move;
127 }
128-#menu ul:after{
129- content: '';
130- position: absolute;
131- left: 284px;
132- top: -15px;
133- width: 0;
134- height: 0;
135- border-left: 10px solid transparent;
136- border-right: 10px solid transparent;
137- border-bottom: 15px solid;
138-}
139
140 #menu ul:after{
141 border-bottom-color: #444;
142 }
143
144+.project{
145+-webkit-animation-duration: 0.3s;
146+ -webkit-animation-iteration-count: 1;
147+ -webkit-animation-timing-function: cubic-bezier(0.4,0,0.8,1);
148+}
149+
150+.project img{
151+opacity: 0.7;
152+}
153+
154+.project img:hover{
155+opacity: 1;
156+}
157+
158+#cont p{
159+margin: 5px;
160+margin-left: 7px;
161+text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
162+}
163+
164+#inv{/*invisible div used to make bin menu easier to use*/
165+height:60px;
166+width:300px;
167+margin-top:-60px;
168+}
169+
170 </style>
171 </head>
172 <body>
173@@ -107,11 +163,15 @@
174 <input placeholder="New project name" type="text" class="grid_4" autofocus>
175 <button class="grid_4" disabled>Create Project</button>
176 <ul id="menu"><li>
177- <a>History</a>
178+ <img src="bin2.png" class="ico" id="ico"/>
179+ <ul id="bi">
180+ <div id="inv"></div>
181+ <div id="cont"></div>
182 <ul id="list"></ul>
183+ </ul>
184 </li></ul>
185 </div>
186 </form>
187-<ul style="height: 200px;width = 200px;" id="projects" ondragenter="enter(event)" ondragleave="leave(event)" ondrop="d(event)" ondragover="over(event);"></ul>
188+<ul style="height: 800px;width = 800px;" id="projects" ondragenter="enter(event)" ondragleave="leave(event)" ondrop="d(event)" ondragover="over(event);"></ul>
189 </body>
190 </html>
191
192=== modified file 'ui/projects.js'
193--- ui/projects.js 2012-06-19 16:57:22 +0000
194+++ ui/projects.js 2012-07-16 17:50:27 +0000
195@@ -1,6 +1,5 @@
196 "use strict";
197
198-
199 function open_project(project_id) {
200 window.location.assign('cutter.html#' + project_id);
201 }
202@@ -16,24 +15,47 @@
203 return filecount;
204 }
205
206+function getOffset( el ) {//get the coordinates of an element
207+ var _x = 0;
208+ var _y = 0;
209+ while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
210+ _x += el.offsetLeft - el.scrollLeft;
211+ _y += el.offsetTop - el.scrollTop;
212+ el = el.offsetParent;
213+ }
214+ return { y: _y, x: _x };
215+}
216+
217+function generateAnimation(x,y){//generate the animation for the elimination of a project
218+ var keyframeprefix = "-webkit-";
219+ var keyframes = '@' + keyframeprefix + 'keyframes arg { '+'0% {' + keyframeprefix + 'transform:scale(1)}'+'100% {' + keyframeprefix + 'transform:translatex('+x+'px) translatey('+y+'px) scale(0.001)}'+'}';
220+ var s = document.createElement( 'style' );
221+ s.innerHTML = keyframes;
222+ document.getElementsByTagName( 'head' )[ 0 ].appendChild( s );
223+}
224+
225 var UI = {
226 init: function() {
227 UI.form = $('new_project');
228 UI.input = UI.form.getElementsByTagName('input')[0];
229 UI.button = UI.form.getElementsByTagName('button')[0];
230- //UI.project = new Project(novacut);
231- //UI.items = new Items('projects');
232
233 UI.form.onsubmit = UI.on_submit;
234 UI.input.oninput = UI.on_input;
235
236 UI.hist = document.getElementById('list');
237 UI.proj = document.getElementById('projects');
238+
239+
240+ UI.binDesc ="<p>Here you can find your removed projects<br>Click on <img style=\"width:13px;\" src=\"delete.png\"></img>&nbsp;&nbsp;&nbsp;to remove a project<br>Drag a project out of here to restore it</p>";
241+ UI.binMax = 5;
242+ UI.binSearch = "<input id=\"s\" onkeyup=\"UI.Search()\"><img id=\"lens\" src=\"search.png\"></img></input>";
243+
244+ UI.removed = new Array();
245 UI.load_items();
246 },
247
248 load_items: function() {
249- //UI.add_history("qwe","nome",3333,3);
250 console.log('load_items');
251 novacut.view(UI.on_items, 'project', 'title');
252 },
253@@ -42,18 +64,41 @@
254 var rows = req.read().rows;
255 console.log(rows.length);
256 for(var b in rows){
257- var a = rows[b]
258- var pdb = new couch.Database("novacut-0-" + a.id.toLowerCase());
259- try{
260- var filecount = pdb.view_sync('doc', 'type', {key: 'dmedia/file'}).rows[0].value;
261- }
262- catch(e){
263- var filecount = 0;
264- }
265- var doc = novacut.get_sync(a.id)
266+ var a = rows[b];
267+ var filecount = countFiles(a.id);
268+ var doc = novacut.get_sync(a.id);
269 if(!doc.isdeleted) UI.add_item(a.id,a.key,a.value,filecount);
270- else UI.add_history(a.id,a.key,a.value,filecount);
271+ else UI.removed.push(Array(a.id,a.key,a.value,filecount));
272 }
273+ if(UI.removed.length == 0){
274+ document.getElementById("cont").innerHTML=UI.binDesc;
275+ }else if(UI.removed.length <= UI.binMax){
276+ for(var b in UI.removed){
277+ var a = UI.removed[b];
278+ UI.add_history(a[0],a[1],a[2],a[3]);
279+ }
280+
281+ }else{
282+ document.getElementById("cont").innerHTML = UI.binSearch;
283+ for(var b = 0;b<UI.binMax;b++){
284+ var a = UI.removed[b];
285+ UI.add_history(a[0],a[1],a[2],a[3]);
286+ }
287+ }
288+ },
289+
290+ Search: function(){
291+ var text = document.getElementById("s").value;
292+ UI.hist.innerHTML = "";
293+ var count = 0;
294+ for(var b in UI.removed){
295+ var a = UI.removed[b];
296+ if(a[1].indexOf(text) != -1){
297+ count++;
298+ UI.add_history(a[0],a[1],a[2],a[3]);
299+ if(count == UI.binMax)break;
300+ }
301+ }
302 },
303
304 add_history: function(id,name,date,filecount){
305@@ -80,7 +125,6 @@
306 li.appendChild(info);
307 UI.hist.appendChild(li);
308 },
309-
310 add_item: function(id,name,date,filecount) {
311 var li = $el('li', {'class': 'project', 'id': id});
312 var thumb = $el('div', {'class': 'thumbnail'});
313@@ -105,10 +149,18 @@
314 del.setAttribute('src', 'delete.png');
315 del.setAttribute('align', 'right');
316 del.onclick = function(){
317- this.parentNode.parentNode.removeChild(this.parentNode);
318+ var pos = getOffset(this.parentNode);
319+ var end = getOffset( document.getElementById("ico"));
320+ generateAnimation(end.x-pos.x,end.y-pos.y-30);
321+ this.parentNode.style.webkitAnimationName = "arg";
322+ var s = this;
323+ setTimeout(function(){s.parentNode.parentNode.removeChild(s.parentNode)},320,s);
324 Hub.send('delete_project', id)
325 var doc = novacut.get_sync(id)
326- UI.add_history(id,doc.title,doc.time,countFiles(id));
327+ UI.removed.push(Array(id,doc.title,doc.time,countFiles(id)));
328+ document.getElementById("cont").innerHTML = "";
329+ if (UI.removed.length > UI.binMax) document.getElementById("cont").innerHTML = UI.binSearch;
330+ else UI.add_history(id,doc.title,doc.time,countFiles(id));
331 }
332 li.appendChild(del);
333 thumb.onclick = function() {
334
335=== added file 'ui/search.png'
336Binary files ui/search.png 1970-01-01 00:00:00 +0000 and ui/search.png 2012-07-16 17:50:27 +0000 differ

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: