{I"
class:ETI"BundledAsset; FI"logical_path; TI"(type_station/editables/move_page.js; FI"
pathname; TI"n/Users/richardadams/github/type_station/app/assets/javascripts/type_station/editables/move_page.js.coffee; FI"content_type; TI"application/javascript; TI"
mtime; Tl+lOÛTI"length; Ti™I"digest; TI"%4cb0deb83c13e97596d95b9b52ee619c; FI"source; TI"™(function() {
window.TS.MovePage = (function() {
function MovePage(_at_elements) {
var $left_arrow, $right_arrow, self;
this.elements = _at_elements;
self = this;
self.parent_distance = parseInt(this.elements.first().data('ts-moveable-distance')) || 1;
$left_arrow = $('').addClass('fa fa-arrow-left fa-fw ts-move ts-move-left').data({
'ts-direction': 'up'
}).hide();
$right_arrow = $('').addClass('fa fa-arrow-right fa-fw ts-move ts-move-right').data({
'ts-direction': 'down'
}).hide();
self.elements.each(function() {
return $(this).append($left_arrow.clone(true)).append($right_arrow.clone(true));
});
}
MovePage.prototype.enable = function() {
var self;
self = this;
return self.elements.find('.ts-move').show().on('click', function() {
var $button, direction, id, parent;
console.log('hee');
$button = $(this);
id = $button.parent().data('ts-id');
direction = $button.data('ts-direction');
parent = $button.parents().eq(self.parent_distance);
return self.update(id, direction, parent);
});
};
MovePage.prototype.disable = function() {
return this.elements.find('.ts-move').off('click');
};
MovePage.prototype.update = function(id, direction, parent) {
return $.ajax({
method: 'GET',
url: window.TS.ADMIN_MOVE_PAGES_URL,
dataType: 'json',
contentType: 'application/json',
data: {
id: id,
direction: direction
},
success: function(data, status) {
if (data.success) {
if (direction === 'up') {
return parent.insertBefore(parent.prev());
} else {
return parent.insertAfter(parent.next());
}
}
}
});
};
return MovePage;
})();
}).call(this);
; TI"required_assets_digest; TI"%b5791ff5165456cf45aad79b65ce8ebf; FI"
_version; TI"%64e62ddc273c2f5847f30d698ca14b67; F