Skip to content

Commit 460ea18

Browse files
committed
Merge branch 'master' of git://github.com/swannodette/shiftspace
2 parents f7e2719 + 0fb9a09 commit 460ea18

File tree

13 files changed

+294
-121
lines changed

13 files changed

+294
-121
lines changed

client/core/ShiftFunctions.js

+15-9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ function SSGetShift(id)
1515
return p;
1616
}
1717

18+
function SSGetShiftInstance(id)
19+
{
20+
var shift = SSGetShift(id);
21+
return SSSpaceForName(shift.space.name).getShift(id);
22+
}
23+
1824
/*
1925
Function: SSInitShift
2026
Creates a new shift on the page.
@@ -191,7 +197,7 @@ var SSEditShift = function(space, shiftId)
191197
{
192198
var content = shift.content;
193199
SSFocusSpace(space, (content && content.position) || null);
194-
var controlp = !space.hasShift(shiftId) ? space.addShift(shift, space.shiftUI()) : null;
200+
var controlp = !space.hasShift(shiftId) ? space.addShift(shift) : null;
195201
(function(controlp) {
196202
space.editShift(shiftId);
197203
space.onShiftEdit(shiftId);
@@ -205,17 +211,17 @@ var SSEditShift = function(space, shiftId)
205211
}
206212
}.future();
207213

214+
/*
215+
Function: SSEditExitShift
216+
Exit the editing of a shift.
208217
218+
Parameters:
219+
space - a space instance.
220+
shiftId - a shift id.
221+
*/
209222
function SSEditExitShift(space, shiftId)
210223
{
211-
var shift = SSGetShift(shiftId);
212-
if(space &&
213-
!Promise.isPromise(space) &&
214-
space.hasShift(shiftId) &&
215-
space.shiftIsVisible(shiftId))
216-
{
217-
space.editExitShift(shiftId);
218-
}
224+
space.editExitShift(shiftId);
219225
SSPostNotification('onShiftLeaveEdit', shiftId);
220226
SSSetShiftBeingEdited(null);
221227
}

client/core/SpaceFunctions.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ function SSRegisterSpace(instance)
169169
SSPostNotification('onShiftFocus', id);
170170
});
171171
instance.addEvent('onShiftSave', function(id) {
172+
SSPostNotification("onShiftSave", id);
173+
});
174+
instance.addEvent("onShiftDestroy", function(id) {
175+
SSPostNotification("onShiftDestroy", id);
172176
});
173177

174178
return instance;
@@ -211,7 +215,7 @@ function SSLoadDefaultSpacesAttributes()
211215
SSLog("Loaded attributes for", spaceName, SSLogSystem);
212216
defaultSpaces[spaceName] = attrs;
213217
defaultSpaces[spaceName].position = i;
214-
if(i == (__defaultSpacesList.length-1))
218+
if(i == (__defaultSpacesList.length-1))
215219
{
216220
SSInitDefaultSpaces(defaultSpaces);
217221
SSPostNotification("onDefaultSpacesAttributesLoad", defaultSpaces);

client/user/Shift.js

+17
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,23 @@ var ShiftSpaceShift = new Class({
342342
this.fireEvent('onShiftHide', this.getId());
343343
},
344344

345+
/*
346+
Function: cancel
347+
Function to cancel the editing of a shift as
348+
well destroying a newly created shift.
349+
*/
350+
cancel: function()
351+
{
352+
if(this.isNewShift())
353+
{
354+
this.destroy();
355+
}
356+
else
357+
{
358+
this.getParentSpace().hideShift(this.getId());
359+
}
360+
},
361+
345362
/*
346363
Function: manageElement
347364
Sets the main view of the shift. This lets ShiftSpace now what the main display

client/views/SSListView/SSListView.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -1280,10 +1280,16 @@ var SSListView = new Class({
12801280
var theData = this.data(), len = theData.length, cell = this.cell();
12811281
if(!$type(startIndex))
12821282
{
1283-
this.element.getElements("li").destroy();
1283+
this.element.getElements("li:not(.SSPreserve)").destroy();
12841284
}
12851285
if(len > 0 && cell)
12861286
{
1287+
if(this.options.preserveBottom)
1288+
{
1289+
var otherEls = this.element.getElements(".SSPreserve").map(function(x) {
1290+
return x.dispose();
1291+
});
1292+
}
12871293
var perPage = (this.pageControl() && this.pageControl().perPage()) || len;
12881294
if(this.options.horizontal && this.options.cellSize)
12891295
{
@@ -1302,6 +1308,12 @@ var SSListView = new Class({
13021308
}
13031309
this.onAddCellNode(cellNode);
13041310
}, this);
1311+
if(this.options.preserveBottom && otherEls)
1312+
{
1313+
otherEls.each(function(x) {
1314+
this.element.grab(x);
1315+
}.bind(this));
1316+
}
13051317
this.setNeedsDisplay(false);
13061318
this.initSortables();
13071319
}

client/views/SSNotifierView/SSNotifierView.js

+38-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ var SSNotifierView = new Class({
2323
SSAddObserver(this, 'onSpaceMenuHide', this.onSpaceMenuHide.bind(this));
2424
SSAddObserver(this, 'onNewShiftSave', this.onNewShiftSave.bind(this));
2525
SSAddObserver(this, 'onShiftEdit', this.onShiftEdit.bind(this));
26+
SSAddObserver(this, 'onShiftHide', this.onShiftHide.bind(this));
27+
SSAddObserver(this, 'onShiftDestroy', this.onShiftDestroy.bind(this));
2628
SSAddObserver(this, 'onShiftLeaveEdit', this.onShiftLeaveEdit.bind(this));
2729
SSAddObserver(this, 'onShiftCheck', this.onShiftCheck.bind(this));
2830
SSAddObserver(this, 'onShiftUncheck', this.onShiftUncheck.bind(this));
@@ -79,8 +81,9 @@ var SSNotifierView = new Class({
7981
},
8082

8183

82-
onShiftEdit: function()
84+
onShiftEdit: function(shiftId)
8385
{
86+
SSLog("onShiftEdit", shiftId, SSLogForce);
8487
this.fireEvent('edit');
8588
},
8689

@@ -91,6 +94,16 @@ var SSNotifierView = new Class({
9194
},
9295

9396

97+
onShiftHide: function(shiftId)
98+
{
99+
},
100+
101+
102+
onShiftDestroy: function(shiftId)
103+
{
104+
},
105+
106+
94107
currentListView: function()
95108
{
96109
return this.__currentListView;
@@ -420,12 +433,17 @@ var SSNotifierView = new Class({
420433

421434
this.SSQPCancel.addEvent("click", function(evt) {
422435
evt = new Event(evt);
423-
var id = this.currentListView().checkedItemIds()[0];
424-
if(SSIsNewShift(id))
436+
var itemIds = (this.currentListView()) ? this.currentListView().checkedItemIds() : [];
437+
if(itemIds.length == 0 && this.__newShiftId)
425438
{
439+
// NOTE: might be breaking encapsulation a little too much - David 9/5/10
440+
SSGetShiftInstance(this.__newShiftId).destroy();
441+
this.hideQuickPane();
426442
}
427443
else
428444
{
445+
SSLog("showQuickEditPane", SSLogForce);
446+
var id = itemIds[0];
429447
SSEditExitShift(SSSpaceForShift(id), id);
430448
this.hideQuickPane();
431449
this.showQuickEditPane();
@@ -441,10 +459,12 @@ var SSNotifierView = new Class({
441459

442460
this.SSQEPEdit.addEvent("click", function(evt) {
443461
evt = new Event(evt);
444-
var id = this.currentListView().checkedItemIds()[0];
462+
var id = this.currentListView().checkedItemIds()[0],
463+
idx = this.currentListView().checkedItemIndices()[0];
445464
SSEditShift(SSSpaceForShift(id), id);
446465
this.hideQuickEditPane();
447466
this.showQuickPane(SSGetShift(id));
467+
this.currentListView().selectRow(idx);
448468
}.bind(this));
449469

450470
this.SSQEPShare.addEvent("click", function(evt) {
@@ -455,6 +475,7 @@ var SSNotifierView = new Class({
455475
this.SSQEPDelete.addEvent("click", function(evt) {
456476
evt = new Event(evt);
457477
var ids = this.currentListView().checkedItemIds();
478+
458479
ids.each($comp(SSDeleteShift, $msg('realize')));
459480
}.bind(this));
460481
},
@@ -663,6 +684,7 @@ var SSNotifierView = new Class({
663684

664685
onNewShiftShow: function(id, status)
665686
{
687+
this.__newShiftId = id;
666688
this.showQuickPane(SSGetShift(id));
667689
},
668690

@@ -692,6 +714,12 @@ var SSNotifierView = new Class({
692714
{
693715
this.SSQuickPane.addClass("SSDisplayNone");
694716
},
717+
718+
719+
isQuickPaneVisible: function()
720+
{
721+
return !this.SSQuickPane.hasClass("SSDisplayNone");
722+
},
695723

696724

697725
showQuickEditPane: function()
@@ -705,6 +733,12 @@ var SSNotifierView = new Class({
705733
this.SSQuickEditPane.addClass("SSDisplayNone");
706734
},
707735

736+
737+
isQuickEditPaneVisible: function(args)
738+
{
739+
return !this.SSQuickEditPane.hasClass("SSDisplayNone");
740+
},
741+
708742

709743
buildInterface: function()
710744
{

client/views/SSNotifierView/SSNotifierViewFrame.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
height: 44px;
88
overflow: hidden;
99
width: 40px;
10-
z-index: 1000001;
10+
z-index: 1000004;
1111
}
1212

1313
.SSNotifierHidden

0 commit comments

Comments
 (0)