/*** jQuery UI droppable performance tune for elFinder ***/
var origin = $.ui.ddmanager.prepareOffsets;
$.ui.ddmanager.prepareOffsets = function( t, event ) {
var isOutView = function(elem) {
if (elem.is(':hidden')) {
var rect = elem[0].getBoundingClientRect();
return document.elementFromPoint(rect.left, rect.top) || document.elementFromPoint(rect.left + rect.width, rect.top + rect.height)? false : true;
if (event.type === 'mousedown' || t.options.elfRefresh) {
m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
for ( i = 0; i < l; i++ ) {
if (d.options.autoDisable && (!d.options.disabled || d.options.autoDisable > 1)) {
d.options.disabled = isOutView(d.element);
d.options.autoDisable = d.options.disabled? 2 : 1;
return origin( t, event );
* @description. jQuery ajax transport for making binary data type requests.
(function($, undefined) {
// use this transport for "binary" data type
$.ajaxTransport("+binary", function(options, originalOptions, jqXHR) {
// check for conditions and support for blob / arraybuffer response type
if (window.FormData && ((options.dataType && (options.dataType == 'binary')) || (options.data && ((window.ArrayBuffer && options.data instanceof ArrayBuffer) || (window.Blob && options.data instanceof Blob))))) {
// Cross domain only allowed if supported through XMLHttpRequest
send: function( headers, complete ) {
dataType = options.responseType || "blob",
// Apply custom fields if provided
if ( options.xhrFields ) {
for ( i in options.xhrFields ) {
xhr[ i ] = options.xhrFields[ i ];
// Override mime type if needed
if ( options.mimeType && xhr.overrideMimeType ) {
xhr.overrideMimeType( options.mimeType );
// X-Requested-With header
// For cross-domain requests, seeing as conditions for a preflight are
// akin to a jigsaw puzzle, we simply never set it to be sure.
// (it can always be set on a per-request basis or even using ajaxSetup)
// For same-domain requests, won't change header if already provided.
if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
headers[ "X-Requested-With" ] = "XMLHttpRequest";
xhr.setRequestHeader( i, headers[ i ] );
callback = function( type ) {
callback = xhr.onload = xhr.onerror = xhr.onabort = xhr.ontimeout = null;
if ( type === "abort" ) {
} else if ( type === "error" ) {
data[options.dataType] = xhr.response;
xhr.getAllResponseHeaders()
xhr.onabort = xhr.onerror = xhr.ontimeout = callback( "error" );
// Create the abort callback
callback = callback( "abort" );
xhr.responseType = dataType;
// Do send the request (this may raise an exception)
xhr.send( options.data || null );
* jQuery UI Touch Punch 0.2.3
* Copyright 2011–2014, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
$.support.touch = 'ontouchend' in document;
// Ignore browsers without touch support
var mouseProto = $.ui.mouse.prototype,
_mouseInit = mouseProto._mouseInit,
_mouseDestroy = mouseProto._mouseDestroy,
* Simulate a mouse event based on a corresponding touch event
* @param {Object} event A touch event
* @param {String} simulatedType The corresponding mouse event
function simulateMouseEvent (event, simulatedType) {
// Ignore multi-touch events
if (event.originalEvent.touches.length > 1) {
if (! $(event.currentTarget).hasClass('touch-punch-keep-default')) {
var touch = event.originalEvent.changedTouches[0],
simulatedEvent = document.createEvent('MouseEvents');
// Initialize the simulated mouse event using the touch event's coordinates
simulatedEvent.initMouseEvent(
touch.screenX, // screenX
touch.screenY, // screenY
touch.clientX, // clientX
touch.clientY, // clientY
// Dispatch the simulated event to the target element
event.target.dispatchEvent(simulatedEvent);
* Handle the jQuery UI widget's touchstart events
* @param {Object} event The widget element's touchstart event
mouseProto._touchStart = function (event) {
// Ignore the event if another widget is already being handled
if (touchHandled || !self._mouseCapture(event.originalEvent.changedTouches[0])) {
// Track element position to avoid "false" move
posX = event.originalEvent.changedTouches[0].screenX.toFixed(0);
posY = event.originalEvent.changedTouches[0].screenY.toFixed(0);
// Set the flag to prevent other widgets from inheriting the touch event
// Track movement to determine if interaction was a click
self._touchMoved = false;
// Simulate the mouseover event
simulateMouseEvent(event, 'mouseover');
// Simulate the mousemove event
simulateMouseEvent(event, 'mousemove');
// Simulate the mousedown event
simulateMouseEvent(event, 'mousedown');
* Handle the jQuery UI widget's touchmove events
* @param {Object} event The document's touchmove event
mouseProto._touchMove = function (event) {
// Ignore event if not handled
// Ignore if it's a "false" move (position not changed)
var x = event.originalEvent.changedTouches[0].screenX.toFixed(0);
var y = event.originalEvent.changedTouches[0].screenY.toFixed(0);
// Ignore if it's a "false" move (position not changed)
if (Math.abs(posX - x) <= 4 && Math.abs(posY - y) <= 4) {
// Interaction was not a click
// Simulate the mousemove event
simulateMouseEvent(event, 'mousemove');
* Handle the jQuery UI widget's touchend events
* @param {Object} event The document's touchend event
mouseProto._touchEnd = function (event) {
// Ignore event if not handled
// Simulate the mouseup event
simulateMouseEvent(event, 'mouseup');
// Simulate the mouseout event
simulateMouseEvent(event, 'mouseout');
// If the touch interaction did not move, it should trigger a click
// Simulate the click event
simulateMouseEvent(event, 'click');
// Unset the flag to allow other widgets to inherit the touch event
this._touchMoved = false;
* A duck punch of the $.ui.mouse _mouseInit method to support touch events.
* This method extends the widget with bound touch event handlers that
* translate touch events to mouse events and pass them to the widget's
* original mouse event handling methods.
mouseProto._mouseInit = function () {
if (self.element.hasClass('touch-punch')) {
// Delegate the touch handlers to the widget's element
touchstart: $.proxy(self, '_touchStart'),
touchmove: $.proxy(self, '_touchMove'),
touchend: $.proxy(self, '_touchEnd')
// Call the original $.ui.mouse init method
* Remove the touch event handlers
mouseProto._mouseDestroy = function () {
if (self.element.hasClass('touch-punch')) {
// Delegate the touch handlers to the widget's element
touchstart: $.proxy(self, '_touchStart'),
touchmove: $.proxy(self, '_touchMove'),
touchend: $.proxy(self, '_touchEnd')
// Call the original $.ui.mouse destroy method
_mouseDestroy.call(self);
$.fn.elfinder = function(o, o2) {
return this.getElFinder();
} else if (o === 'ondemand') {
return this.each(function() {
var cmd = typeof o === 'string' ? o : '',
bootCallback = typeof o2 === 'function'? o2 : void(0),
elfinder = this.elfinder,
if ($.isPlainObject(o)) {
new elFinder(this, o, bootCallback);
opts = $.extend(true, elfinder.options, $.isPlainObject(o2)? o2 : {});
bootCallback = elfinder.bootCallback;
if (elfinder.reloadCallback && $.isFunction(elfinder.reloadCallback)) {
elfinder.reloadCallback(opts, bootCallback);
new elFinder(this, opts, bootCallback);
$.fn.getElFinder = function() {
instance = this.elfinder;
$.fn.elfUiWidgetInstance = function(name) {
return this[name]('instance');
// fallback for jQuery UI < 1.11
var data = this.data('ui-' + name);
if (data && typeof data === 'object' && data.widgetFullName === 'ui-' + name) {
if (! $.fn.scrollRight) {
scrollRight: function (val) {
return Math.max(0, node.scrollWidth - (node.scrollLeft + node.clientWidth));
return this.scrollLeft(node.scrollWidth - node.clientWidth - val);
if (! $.fn.scrollBottom) {
scrollBottom: function(val) {
return Math.max(0, node.scrollHeight - (node.scrollTop + node.clientHeight));
return this.scrollTop(node.scrollHeight - node.clientHeight - val);