', {
id: this.element.attr('id')+'_sorthelper',
});
}
this.helper.css('height', (item.height()+12)+"px");
this.helper.attr('class', item.hasClass('draggable') ? 'draggable' : 'something');
this.helper.empty();
},
_checkScroll: function(event) {
// Custom Scrollbars ONLY
var scrolled = false;
if (this.options.scroll) {
if (event.pageY < this.bbox.top + this.options.scrollzone) {
$(this.options.scrollparent).mCustomScrollbar('scrollTo', '+='+this.options.scrollspeed, {scrollInertia: 100, scrollEasing: "easeOut"});
scrolled = true;
} else if (event.pageY > this.bbox.bottom - this.options.scrollzone) {
$(this.options.scrollparent).mCustomScrollbar('scrollTo', '-='+this.options.scrollspeed, {scrollInertia: 100, scrollEasing: "easeOut"});
scrolled = true;
}
}
return scrolled;
},
_checkMouseHover: function() {
this.do_intersect_stuff(this._mouseEvent, this._item);
},
dragleave: function() {
if (this.helper) this.helper.remove();
this.helper = null;
clearTimeout(this._scrollcheck);
},
dropped: function(event) {
// This is called when something from OUTSIDE the list has been dropped onto us
debug.log("STL","Dropped",event);
clearTimeout(this._scrollcheck);
if (this.helper) {
this.options.outsidedrop(event, this.helper);
}
},
// Local dragging functions
_findDraggable: function(event) {
var el = $(event.target);
while (!el.hasClass(this.options.items.replace(/^\./,'')) && el != this.element) {
el = el.parent();
}
return el;
},
_mouseStart: function(event) {
debug.log("SORTABLE","Mouse Start",event);
var dragged = this._findDraggable(event);
if (dragged.prev().length == 0) {
this.dragged_original_before = dragged.next();
this.dragged_original_after = false;
} else {
this.dragged_original_before = false;
this.dragged_original_after = dragged.prev();
}
this.dragged_original_pos = dragged.prev();
if (this.dragger) this.dragger.remove();
this.dragger = dragged.clone().appendTo('body');
this.dragger.find('.icon-cancel-circled').remove();
if (this.dragger.is('tr')) {
this.dragger.wrap('
');
}
this.dragger.css({
position: 'absolute',
top: dragged.offset().top + 'px',
left: dragged.offset().left + 'px',
width: dragged.width() + 'px',
'z-index': 1500
});
this.drag_x_offset = event.pageX - this.dragger.offset().left;
this.dragger.addClass('dropshadow');
if (this.helper) this.helper.remove();
this.helper = null;
this._checkHelper(dragged);
this.helper.detach().insertAfter(dragged);
this.original = dragged.detach();
this.dragstart();
this.dragging = true;
return true;
},
_mouseDrag: function(event) {
clearTimeout(this._scrollcheck);
if (this.dragging) {
if ((event.pageX > this.bbox.right || event.pageX < this.bbox.left) &&
this.options.allowdragout)
{
clearTimeout(this._scrollcheck);
this.dragging = false;
this.draggingout = true;
var pos = {top: event.pageY - 12, left: event.pageX - this.drag_x_offset};
this.dragger.css({top: pos.top+"px", left: pos.left+"px"});
if (!this.dragged_original_after) {
this.original.insertBefore(this.dragged_original_before);
} else {
this.original.insertAfter(this.dragged_original_after);
}
$('.selected').removeClass('selected');
this.original.addClass('selected');
if (this.helper) {
this.helper.detach();
}
this.dragger.attr('id','dragger');
this.dragger.css('z-index', 1500);
this.dragger.addClass('draggable');
$('.trackacceptor').acceptDroppedTracks('dragstart');
} else {
var pos = {top: event.pageY - 12, left: event.pageX - this.drag_x_offset};
if (pos.top > this.bbox.top && pos.top < this.bbox.bottom) {
this.dragger.css('top',pos.top+'px');
if (this.options.allowdragout) {
this.dragger.css('left',pos.left+'px');
}
this.do_intersect_stuff(event, this.dragger);
}
}
} else if (this.draggingout) {
var pos = {top: event.pageY - 12, left: event.pageX - this.drag_x_offset};
this.dragger.css({top: pos.top+"px", left: pos.left+"px"});
$('.trackacceptor').each(function() {
if ($(this).acceptDroppedTracks('checkMouseOver', event)) {
// Break out of the each loop
return false;
}
});
}
return true;
},
_mouseStop: function(event) {
clearTimeout(this._scrollcheck);
if (this.dragging) {
this.dragger.remove();
this.original.insertAfter(this.helper);
this.helper.remove();
this.helper = null;
this.dragging = false;
if (this.options.insidedrop) {
this.options.insidedrop(event, this.original);
}
} else if (this.draggingout) {
debug.log("STL","Dragged out and onto something else");
this.dragger.remove();
this.draggedout = false;
if (this.helper) this.helper.remove();
this.helper = null;
$('.trackacceptor').each(function() {
if ($(this).acceptDroppedTracks('dragstop', event)) {
return false;
}
});
}
return true;
}
});
$.widget("rompr.resizeHandle", $.ui.mouse, {
widgetEventPrefix: "resize",
options: {
adjusticons: [],
side: 'left'
},
_create: function() {
this.dragging = false;
this._mouseInit();
this.element.css({cursor: "move"});
},
_mouseCapture: function(event) {
this.dragging = true;
this.startX = event.clientX;
this.elementStartX = this.element.offset().left;
this.winsize = getWindowSize();
this.widthadjust = this.element.outerWidth(true)/2;
return true;
},
_mouseStart: function(event) {
return true;
},
_mouseDrag: function(event) {
if (this.dragging) {
var distance = event.clientX - this.startX;
if (this.options.side == 'left') {
var size = Math.max(this.elementStartX + distance + this.widthadjust, 120);
prefs.sourceswidthpercent = (size/this.winsize.x)*100;
} else {
var size = Math.max(this.winsize.x - (this.elementStartX + distance + this.widthadjust), 120);
prefs.playlistwidthpercent = (size/this.winsize.x)*100;
}
if (prefs.sourceswidthpercent + prefs.playlistwidthpercent > 100 || prefs.hidebrowser) {
if (this.options.side == 'left') {
prefs.playlistwidthpercent = 100 - prefs.sourceswidthpercent;
} else {
prefs.sourceswidthpercent = 100 - prefs.playlistwidthpercent;
}
}
this.options.donefunc();
}
return true;
},
_mouseStop: function(event) {
this.dragging = false;
browser.rePoint();
prefs.save({sourceswidthpercent: prefs.sourceswidthpercent});
prefs.save({playlistwidthpercent: prefs.playlistwidthpercent});
return true;
}
});
$.widget("rompr.rangechooser", $.ui.mouse, {
options: {
range: 1,
ends: ['min','max'],
allowed_min: 0,
onstop: null,
whiledragging: null,
orientation: 'horizontal',
startmin: 0,
startmax: 1,
interactive: true,
animate: false
},
_create: function() {
this.dragging = false;
var extraclass = (this.options.interactive) ? ' moveable' : '';
switch (this.options.orientation) {
case "horizontal":
this.element.addClass('rangechooser progressbar'+extraclass);
break;
case "vertical":
this.element.addClass('rangechooser progressbar_v'+extraclass);
break;
default:
debug.error("RANGECHOOSER","Invalid orientation",this.options.orientation);
break;
}
// if (this.options.animate) {
// this.element.addClass('animated');
// }
this.min = this.options.startmin;
this.max = this.options.startmax;
if (this.options.interactive) {
this._mouseInit();
}
this.fill();
},
_mouseCapture: function(event) {
this.dragging = true;
this.dragWhich(event);
this.update(event);
if (this.options.onstop) {
this.options.onstop(this.getRange());
}
return true;
},
_mouseDrag: function(event) {
if (this.dragging) {
this.update(event);
if (this.options.whiledragging) {
this.options.whiledragging(this.getRange());
}
return true;
}
},
_mouseStop: function(event) {
this.dragging = false;
if (this.options.onstop) {
this.options.onstop(this.getRange());
}
return true;
},
update: function(event) {
var position, fraction;
if (this.options.orientation == "horizontal") {
position = event.clientX - this.element.offset().left;
fraction = position/this.element.width();
} else {
position = this.element.height()-(event.clientY - this.element.offset().top);
fraction = position/this.element.height();
}
this[this.draggedElement] = fraction;
if (this.max <= this.min) {
this.max = this.min + 0.1;
}
if (this.min >= this.max) {
this.min = this.max - 0.1;
}
this.min = Math.max(this.min, 0);
this.max = Math.min(this.max, 1);
this.max = Math.max(this.max, this.options.allowed_min);
this.fill();
},
fill: function() {
var gradients = new Array();
// if (this.options.animate) {
// var rgbs = getrgbs(100,0);
// } else {
var rgbs = getrgbs(this.max*100,this.min*100);
// }
if (this.max == this.min || isNaN(this.min) || isNaN(this.max)) {
gradients.push('transparent');
} else if (this.options.orientation == "horizontal") {
gradients.push("linear-gradient(to right, "+rgbs);
} else {
gradients.push("linear-gradient(to top, "+rgbs);
}
for (var i in gradients) {
this.element.css("background", gradients[i]);
}
// if (this.options.animate) {
// if (this.max == this.min || isNaN(this.min) || isNaN(this.max) || this.max == 0) {
// var pos = 0;
// } else {
// var pos = (this.element.width()*this.max)-this.element.width();
// }
// this.element.css({'background-position-x': pos+'px', 'background-repeat': 'no-repeat'});
// }
},
dragWhich: function(event) {
var position, fraction;
if (this.options.ends.length == 1) {
this.draggedElement = this.options.ends[0];
return true;
}
if (this.options.orientation == "horizontal") {
position = event.clientX - this.element.offset().left;
fraction = position/this.element.outerWidth(true);
} else {
position = event.clientY - this.element.offset().top;
fraction = position/this.element.outerHeight(true);
}
var distanceFromMax = Math.abs(fraction - this.max);
var distanceFromMin = Math.abs(fraction - this.min);
if (distanceFromMax > distanceFromMin) {
this.draggedElement = "min";
} else {
this.draggedElement = "max";
}
},
getRange: function() {
return { min: this.min * this.options.range,
max: this.max * this.options.range
};
},
setRange: function(r) {
var malarkey = {min: r.min / this.options.range, max: r.max / this.options.range}
if (malarkey.min != this.min || malarkey.max != this.max) {
this.min = malarkey.min;
this.max = malarkey.max;
this.fill();
}
},
setOptions: function(o) {
for (var i in o) {
this.options[i] = o[i];
}
},
setProgress: function(p) {
var malarkey = {min: 0, max: p / this.options.range}
if (malarkey.max != this.max) {
this.min = 0;
this.max = malarkey.max;
this.fill();
}
}
});
$.widget("rompr.floatingMenu", $.ui.mouse, {
options: {
handleClass: null,
addClassTo: null,
siblings: '',
handleshow: true,
movecallback: null
},
_create: function() {
var self = this;
this.dragging = false;
this._mouseInit();
if (this.options.addClassTo) {
this.element.find('.'+this.options.addClassTo).first().addClass(this.options.handleClass)
.append('');
var hl = this.element.find('input.helplink');
if (hl.length > 0) {
this.element.find('.'+this.options.addClassTo).first()
.append('
');
}
}
if (self.options.handleshow) {
this._parent = this.element.parent();
this.element.find('.closemenu').on('click', $.proxy(self.toggleMenu, self));
this._parent.on('click', function(event) {
debug.log("FRUITBAT",event);
if (!event.target.className.match('progressbar')) {
$.proxy(self.toggleMenu, self)();
}
});
}
},
_mouseCapture: function(event) {
return true;
},
_findSourceElement: function(event) {
var el = $(event.target);
while (!el.hasClass(this.options.handleClass) && !el.hasClass('topdropmenu') && el != this.element)
{
el = el.parent();
}
if (el.hasClass(this.options.handleClass)) {
return true;
} else {
return false;
}
},
_mouseStart: function(event) {
if (this.options.handleClass && this._findSourceElement(event) === false) {
return false;
}
this.dragging = true;
this.drag_x_offset = event.pageX - this.element.offset().left;
this.drag_y_offset = event.pageY - this.element.offset().top;
this.element.detach().appendTo('body');
this._mouseDrag(event);
return true;
},
_mouseDrag: function(event) {
if (this.dragging) {
var pos = {top: event.pageY - this.drag_y_offset, left: event.pageX - this.drag_x_offset};
this.element.css({top: pos.top+"px", left: pos.left+"px"});
if (this.options.movecallback) {
this.options.movecallback(pos);
}
}
return true;
},
_mouseStop: function(event) {
this.dragging = false;
return true;
},
toggleMenu: function() {
var self = this;
if (this.element.is(':visible')) {
this.element.slideToggle('fast', function() {
self.element.css({left: "", top: ""}).detach().appendTo(self._parent);
});
} else {
if (this.options.handleClass == null) {
var height = self._parent.height()+2;
self.element.css({top: height+"px"});
}
$(self.options.siblings).each(function() {
if ($(this).is(':visible') && $(this) != self.element && !$(this).parent().is('body')) {
$(this).slideToggle('fast');
}
});
if (this.element.hasClass('useasfixed')) {
var top = parseInt(this.element.parent().offset().top) + this.element.parent().outerHeight(true);
this.element.css({
top: top+'px',
left: this.element.parent().offset().left+'px'
});
this.element.detach().appendTo('body');
}
this.element.slideToggle('fast', function() {
$(this).fanoogleMenus();
});
}
}
});
// VVVVVVV IMPORTANT!!!!!
// DO NOT use fancy effects eg fades or slidetoggle or any of that
// on things where masonry is in use, as they fuck up Masonry's size
// calculations big time. Just use hide() and show()
// Spent many hours seeking this out, so tkae note!
// The parent container on which this is called ought to have an id attribute
// as it's used to separate things if there are more than one of these
$.widget('rompr.spotifyAlbumThing', {
options: {
classes: 'tagholder2 selecotron',
itemselector: 'tagholder2',
swapclass: 'tagholder2',
sub: '',
showbiogs: false,
layoutcallback: null,
maxwidth: 640,
is_plugin: false,
imageclass: 'masochist',
masonified: false,
showlistenlater: true,
showremovebutton: false,
removecallback: null,
data: []
},
_create: function() {
var self = this;
var ids = new Array();
this.options.id = this.element.attr('id');
this.element.empty();
this.element.append('
');
for (var i in this.options.data) {
var a = this.options.data[i];
debug.debug("SPOTIALBUM","Index is",i,"data is",a);
if (this.options.sub && a.hasOwnProperty(this.options.sub)) {
if (a.rompr_index) {
var b = a.rompr_index;
}
a = a[this.options.sub];
a.rompr_index = b;
}
if (ids.indexOf(a.id) > -1) {
debug.mark("SPALBUM","Duplicate album ID",a.id);
continue;
}
ids.push(a.id);
// Create the HTML for the album
var x = $('
', {class: this.options.classes+' clearfix albumwidget'}).appendTo(this.element);
var clickclass = (this.options.is_plugin) ? ' plugclickable' : '';
var trackclass = (player.canPlay('spotify')) ? ' playable draggable' : '';
var cx = (this.options.showbiogs) ? ' tleft' : '';
var y = $('
', {class: 'helpfulalbum fullwidth notthere'+cx}).appendTo(x);
var html;
var appendto;
if (layoutProcessor.openOnImage) {
appendto = $('
').appendTo(y);
appendto.append($('
', {
class: this.options.imageclass+clickclass+' menu infoclick clickopenalbum clickspotifywidget',
src: self._getImage(a),
name: self.options.id+'dropper_'+a.id
}));
html = '
'+
'