Skip to content

Commit

Permalink
continued
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel Nitzschner committed Jan 16, 2012
1 parent 5b9ddc6 commit eda5508
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 38 deletions.
6 changes: 5 additions & 1 deletion app/webroot/css/html5sortable/jquery.html5sortable.css
@@ -1,5 +1,9 @@
.html5sortable-state-highlight {
border-left: 1px solid rgba(255, 255, 0, 0.8);
border-left: 0px solid;
background-color: rgba(255, 255, 0, 0.1);
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
float: left;
}
.html5sortable-state-highlight-horizontal {
Expand Down
1 change: 1 addition & 0 deletions app/webroot/js/spine/app/director/application.coffee
Expand Up @@ -128,6 +128,7 @@ class App extends Spine.Controller
event = e.originalEvent
if Spine.dragItem?.closest
Spine.dragItem.closest.removeClass('over nodrop')
Spine.sortItem?.splitter.remove()
e.stopPropagation() unless event.dataTransfer.files.length
e.preventDefault()

Expand Down
8 changes: 6 additions & 2 deletions app/webroot/js/spine/app/director/application.js
Expand Up @@ -122,7 +122,8 @@ App = (function() {
this.appManager.change(this.loaderView);
this.slideshowOptions = {
canvas: false,
backdrop: true
backdrop: true,
slideshow: 0
};
this.initializeSlideshow();
this.initializeFileupload();
Expand All @@ -145,12 +146,15 @@ App = (function() {
}
};
App.prototype.drop = function(e) {
var event, _ref;
var event, _ref, _ref2;
console.log('App::drop');
event = e.originalEvent;
if ((_ref = Spine.dragItem) != null ? _ref.closest : void 0) {
Spine.dragItem.closest.removeClass('over nodrop');
}
if ((_ref2 = Spine.sortItem) != null) {
_ref2.splitter.remove();
}
if (!event.dataTransfer.files.length) {
e.stopPropagation();
}
Expand Down
Expand Up @@ -240,7 +240,7 @@ class SidebarList extends Spine.Controller

e.stopPropagation()
e.preventDefault()
false
# false

click: (e) ->
console.log 'SidebarList::click'
Expand All @@ -253,7 +253,7 @@ class SidebarList extends Spine.Controller

e.stopPropagation()
e.preventDefault()
false
# false

dblclick: (e) ->
console.log 'SidebarList::dblclick'
Expand All @@ -264,7 +264,7 @@ class SidebarList extends Spine.Controller

e.stopPropagation()
e.preventDefault()
false
# false

expandExpander: (e) ->
clearTimeout Spine.timer
Expand Down Expand Up @@ -295,13 +295,13 @@ class SidebarList extends Spine.Controller

e.stopPropagation()
e.preventDefault()
false
# false

show: (e) ->
App.contentManager.change App.showView
e.stopPropagation()
e.preventDefault()
false
# false


module?.exports = SidebarList
15 changes: 5 additions & 10 deletions app/webroot/js/spine/app/director/controllers/sidebar_list.js
Expand Up @@ -309,8 +309,7 @@ SidebarList = (function() {
Spine.trigger('show:allPhotos', true);
}
e.stopPropagation();
e.preventDefault();
return false;
return e.preventDefault();
};
SidebarList.prototype.click = function(e) {
var item;
Expand All @@ -320,17 +319,15 @@ SidebarList = (function() {
Spine.trigger('change:toolbar', ['Gallery']);
App.contentManager.change(App.showView);
e.stopPropagation();
e.preventDefault();
return false;
return e.preventDefault();
};
SidebarList.prototype.dblclick = function(e) {
var item;
console.log('SidebarList::dblclick');
item = $(e.target).item();
this.change(item, 'edit', e);
e.stopPropagation();
e.preventDefault();
return false;
return e.preventDefault();
};
SidebarList.prototype.expandExpander = function(e) {
var closest, el, expander;
Expand Down Expand Up @@ -366,14 +363,12 @@ SidebarList = (function() {
content.hide();
}
e.stopPropagation();
e.preventDefault();
return false;
return e.preventDefault();
};
SidebarList.prototype.show = function(e) {
App.contentManager.change(App.showView);
e.stopPropagation();
e.preventDefault();
return false;
return e.preventDefault();
};
return SidebarList;
})();
Expand Down
1 change: 0 additions & 1 deletion app/webroot/js/spine/app/director/plugins/drag.coffee
Expand Up @@ -32,7 +32,6 @@ Controller.Drag =
clearTimeout Spine.timer
Spine.timer = setTimeout(func, 1000)
Spine.trigger('drag:enter', e, @)
clearTimeout Spine.timer

dragover: (e, data) ->
console.log 'Drag::dragover'
Expand Down
3 changes: 1 addition & 2 deletions app/webroot/js/spine/app/director/plugins/drag.js
Expand Up @@ -35,8 +35,7 @@ Controller.Drag = {
};
clearTimeout(Spine.timer);
Spine.timer = setTimeout(func, 1000);
Spine.trigger('drag:enter', e, this);
return clearTimeout(Spine.timer);
return Spine.trigger('drag:enter', e, this);
},
dragover: function(e, data) {
var event;
Expand Down
26 changes: 18 additions & 8 deletions app/webroot/js/spine/app/director/plugins/sort.coffee
Expand Up @@ -16,10 +16,15 @@ $.Html5Sortable = ->
css: (source) ->
el = ($(source).prev('li') or $(source).next('li'))
'height' : el.css 'height'
'width' : el.css 'width'
'padding-top' : el.css 'padding-top'
'padding-right' : el.css 'padding-right'
'padding-bottom': el.css 'padding-bottom'
'padding-left' : el.css 'padding-left'
'margin-top' : el.css 'margin-top'
'margin-right' : el.css 'margin-right'
'margin-bottom' : el.css 'margin-bottom'
'margin-left' : el.css 'margin-left'
klass: (source) -> 'html5sortable-state-highlight'
splitter: (source) -> ($($('li.'+@klass())[0] or $('<li class="'+@klass()+'"></li>'))).css @css source
type: $.Html5Sortable.DRAGANDDROP_DEFAULT_TYPE,
Expand All @@ -43,6 +48,7 @@ $.fn.Html5Sortable = (opts) ->
Spine.sortItem = {}
Spine.sortItem.data = el.data()
Spine.sortItem.dataTransfer = e.originalEvent.dataTransfer
Spine.sortItem.splitter = options.splitter(@)

Spine.sortItem.dataTransfer.setData "Text", JSON.stringify
html: options.text(el)
Expand All @@ -53,7 +59,7 @@ $.fn.Html5Sortable = (opts) ->
el.addClass('_dragging')

Spine.trigger('drag:start', e, @)
return true
# return true

.bind 'dragend', (e) ->
$('._dragging').removeClass('_dragging')
Expand All @@ -63,6 +69,8 @@ $.fn.Html5Sortable = (opts) ->
return true
catch e
return true

Spine.sortItem.splitter.remove()

.bind 'dragenter', (e) ->
try
Expand All @@ -71,10 +79,12 @@ $.fn.Html5Sortable = (opts) ->
catch e
return true


if (e.pageY - $(this).position().top > $(@).height())
options.splitter(@).insertAfter @
Spine.sortItem.splitter.insertAfter @
else
options.splitter(@).insertBefore @
Spine.sortItem.splitter.insertBefore @

Spine.trigger('drag:enter', e, @)

.bind 'dragleave', (e) ->
Expand All @@ -83,7 +93,7 @@ $.fn.Html5Sortable = (opts) ->
return true;
catch e
return true

Spine.trigger('drag:leave', e, @)

.bind 'drop', (e) ->
Expand All @@ -94,7 +104,7 @@ $.fn.Html5Sortable = (opts) ->
return true

sourceEl = $('._dragging')
options.splitter(@).remove()
Spine.sortItem.splitter.remove()

it = $(JSON.parse(Spine.sortItem.dataTransfer.getData('Text')).html).hide()
it.data Spine.sortItem.data
Expand Down Expand Up @@ -122,12 +132,12 @@ $.fn.Html5Sortable = (opts) ->
catch e
return true

options.splitter(@).remove()
Spine.sortItem.splitter.remove()

if (e.pageY - $(this).position().top > $(@).height())
options.splitter(@).insertAfter @
Spine.sortItem.splitter.insertAfter @
else
options.splitter(@).insertBefore @
Spine.sortItem.splitter.insertBefore @

Spine.trigger('drag:over_', e, @)
return false
Expand Down
24 changes: 15 additions & 9 deletions app/webroot/js/spine/app/director/plugins/sort.js
Expand Up @@ -23,10 +23,15 @@ $.Html5Sortable.defaultOptions = {
el = $(source).prev('li') || $(source).next('li');
return {
'height': el.css('height'),
'width': el.css('width'),
'padding-top': el.css('padding-top'),
'padding-right': el.css('padding-right'),
'padding-bottom': el.css('padding-bottom'),
'padding-left': el.css('padding-left'),
'margin-top': el.css('margin-top'),
'margin-bottom': el.css('margin-bottom')
'margin-right': el.css('margin-right'),
'margin-bottom': el.css('margin-bottom'),
'margin-left': el.css('margin-left')
};
},
klass: function(source) {
Expand Down Expand Up @@ -55,14 +60,14 @@ $.fn.Html5Sortable = function(opts) {
Spine.sortItem = {};
Spine.sortItem.data = el.data();
Spine.sortItem.dataTransfer = e.originalEvent.dataTransfer;
Spine.sortItem.splitter = options.splitter(this);
Spine.sortItem.dataTransfer.setData("Text", JSON.stringify({
html: options.text(el),
type: options.type
}));
$('._dragging').removeClass('_dragging');
el.addClass('_dragging');
Spine.trigger('drag:start', e, this);
return true;
return Spine.trigger('drag:start', e, this);
}).bind('dragend', function(e) {
$('._dragging').removeClass('_dragging');
try {
Expand All @@ -72,6 +77,7 @@ $.fn.Html5Sortable = function(opts) {
} catch (e) {
return true;
}
return Spine.sortItem.splitter.remove();
}).bind('dragenter', function(e) {
try {
if (!(Spine.sortItem.dataTransfer.getData("Text") && JSON.parse(Spine.sortItem.dataTransfer.getData("Text")).type === options.type)) {
Expand All @@ -81,9 +87,9 @@ $.fn.Html5Sortable = function(opts) {
return true;
}
if (e.pageY - $(this).position().top > $(this).height()) {
options.splitter(this).insertAfter(this);
Spine.sortItem.splitter.insertAfter(this);
} else {
options.splitter(this).insertBefore(this);
Spine.sortItem.splitter.insertBefore(this);
}
return Spine.trigger('drag:enter', e, this);
}).bind('dragleave', function(e) {
Expand All @@ -105,7 +111,7 @@ $.fn.Html5Sortable = function(opts) {
return true;
}
sourceEl = $('._dragging');
options.splitter(this).remove();
Spine.sortItem.splitter.remove();
it = $(JSON.parse(Spine.sortItem.dataTransfer.getData('Text')).html).hide();
it.data(Spine.sortItem.data);
if (e.pageY - $(this).position().top > $(this).height()) {
Expand All @@ -128,11 +134,11 @@ $.fn.Html5Sortable = function(opts) {
} catch (e) {
return true;
}
options.splitter(this).remove();
Spine.sortItem.splitter.remove();
if (e.pageY - $(this).position().top > $(this).height()) {
options.splitter(this).insertAfter(this);
Spine.sortItem.splitter.insertAfter(this);
} else {
options.splitter(this).insertBefore(this);
Spine.sortItem.splitter.insertBefore(this);
}
Spine.trigger('drag:over_', e, this);
return false;
Expand Down

0 comments on commit eda5508

Please sign in to comment.