mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2025-12-12 07:40:26 -08:00
Remove old files using jquery
This commit is contained in:
committed by
Matthieu Baumann
parent
826ef4fdb7
commit
02c6b6e468
218
src/js/Box.js
218
src/js/Box.js
@@ -1,218 +0,0 @@
|
||||
// Copyright 2013-2017 - UDS/CNRS
|
||||
// The Aladin Lite program is distributed under the terms
|
||||
// of the GNU General Public License version 3.
|
||||
//
|
||||
// This file is part of Aladin Lite.
|
||||
//
|
||||
// Aladin Lite is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 3 of the License.
|
||||
//
|
||||
// Aladin Lite is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// The GNU General Public License is available in COPYING file
|
||||
// along with Aladin Lite.
|
||||
//
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Aladin Lite project
|
||||
*
|
||||
* File Box
|
||||
*
|
||||
* A Box instance is a GUI element providing a div nested
|
||||
* in Aladin Lite parent div
|
||||
*
|
||||
* Author: Thomas Boch [CDS]
|
||||
*
|
||||
*****************************************************************************/
|
||||
import $ from 'jquery';
|
||||
|
||||
Box = (function() {
|
||||
|
||||
// constructor
|
||||
var Box = function(properties) {
|
||||
|
||||
this.$parentDiv = $('<div>');
|
||||
this.$parentDiv.addClass('aladin-box');
|
||||
|
||||
properties = properties || {};
|
||||
|
||||
this.css = properties.css || {padding: '4px'};
|
||||
|
||||
this.position = properties.position || 'bottom'; // position can be bottom, left, top or right
|
||||
if (this.position=='right') {
|
||||
this.css['left'] = 'unset';
|
||||
}
|
||||
this.css[this.position] = '4px';
|
||||
|
||||
this.contentCss = properties.contentCss || {};
|
||||
|
||||
this.title = properties.title || undefined;
|
||||
|
||||
this.content = properties.content || undefined;
|
||||
|
||||
this.showHandler = properties.showHandler !== undefined ? properties.showHandler : true;
|
||||
|
||||
this.openCallback = properties.openCallback || undefined; // callback called when the user opens the panel
|
||||
this.closeCallback = properties.closeCallback || undefined; // callback called when the user closes the panel
|
||||
|
||||
this.changingDim = 'width';
|
||||
if (this.position=='top' || this.position=='bottom') {
|
||||
this.changingDim = 'height';
|
||||
}
|
||||
|
||||
|
||||
this.open = false;
|
||||
this._render();
|
||||
this.$parentDiv.show();
|
||||
this.open = true;
|
||||
this.hide();
|
||||
};
|
||||
|
||||
Box.prototype = {
|
||||
|
||||
show: function() {
|
||||
if (this.open) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.open = true;
|
||||
this.$parentDiv.show();
|
||||
this._updateChevron();
|
||||
|
||||
if (this.changingDim=='width') {
|
||||
this.$parentDiv.find('.aladin-box-title-label').show();
|
||||
}
|
||||
var self = this;
|
||||
var options = {};
|
||||
options[this.changingDim] = 'show';
|
||||
var delay = this.changingDim=='width' ? 0 : 400;
|
||||
this.$parentDiv.find('.aladin-box-content').animate(options, delay, function() {
|
||||
self.css[self.position] = '4px';
|
||||
self.updateStyle(self.css);
|
||||
|
||||
typeof self.openCallback === 'function' && self.openCallback();
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
if (! this.open) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.open = false;
|
||||
this._updateChevron();
|
||||
|
||||
if (this.changingDim=='width') {
|
||||
this.$parentDiv.find('.aladin-box-title-label').hide();
|
||||
}
|
||||
var self = this;
|
||||
var options = {};
|
||||
options[this.changingDim] = 'hide';
|
||||
var delay = this.changingDim=='width' ? 0 : 400;
|
||||
this.$parentDiv.find('.aladin-box-content').animate(options, delay, function() {
|
||||
self.css[self.position] = '0px';
|
||||
self.updateStyle(self.css);
|
||||
|
||||
typeof self.closeCallback === 'function' && self.closeCallback();
|
||||
});
|
||||
},
|
||||
|
||||
// complety hide parent div
|
||||
realHide: function() {
|
||||
this.open = false;
|
||||
this.$parentDiv.hide();
|
||||
},
|
||||
|
||||
updateStyle: function(css) {
|
||||
this.css = css;
|
||||
this.$parentDiv.css(css);
|
||||
},
|
||||
|
||||
setContent: function(content) {
|
||||
this.content = content;
|
||||
this._render();
|
||||
},
|
||||
|
||||
setTitle: function(title) {
|
||||
this.title = title;
|
||||
this._render();
|
||||
},
|
||||
|
||||
enable: function() {
|
||||
this.$parentDiv.enable();
|
||||
},
|
||||
|
||||
disable: function() {
|
||||
this.$parentDiv.disable();
|
||||
},
|
||||
|
||||
// fill $parentDiv with HTML corresponding to current state
|
||||
_render: function() {
|
||||
var self = this;
|
||||
|
||||
this.$parentDiv.empty();
|
||||
this.$parentDiv.off();
|
||||
|
||||
var titleDiv = $('<div class="aladin-box-title">');
|
||||
if (this.showHandler) {
|
||||
var chevron = $('<span class="aladin-chevron">');
|
||||
titleDiv.append(chevron);
|
||||
}
|
||||
if (this.title) {
|
||||
titleDiv.append(' <span class="aladin-box-title-label">' + this.title + '</span>');
|
||||
}
|
||||
this.$parentDiv.append(titleDiv);
|
||||
var $content = $('<div class="aladin-box-content">' + (this.content?this.content:'') + '</div>');
|
||||
$content.css(this.contentCss);
|
||||
this.$parentDiv.append($content);
|
||||
|
||||
this._updateChevron();
|
||||
this.updateStyle(this.css);
|
||||
|
||||
titleDiv.on('click', function() {
|
||||
if (self.open) {
|
||||
self.hide();
|
||||
}
|
||||
else {
|
||||
self.show();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_updateChevron: function() {
|
||||
this.$parentDiv.find('.aladin-chevron').removeClass().addClass('aladin-chevron ' + getChevronClass(this.position, this.open))
|
||||
.attr('title', 'Click to ' + (this.open?'hide ':'show ') + (this.title?this.title:'') + ' panel');
|
||||
}
|
||||
};
|
||||
|
||||
// return the jquery object corresponding to the given position and open/close state
|
||||
var getChevronClass = function(position, isOpen) {
|
||||
if (position=='top' && isOpen || position=='bottom' && !isOpen) {
|
||||
return 'aladin-chevron-up';
|
||||
}
|
||||
if (position=='bottom' && isOpen || position=='top' && !isOpen) {
|
||||
return 'aladin-chevron-down';
|
||||
}
|
||||
if (position=='right' && isOpen || position=='left' && !isOpen) {
|
||||
return 'aladin-chevron-right';
|
||||
}
|
||||
if (position=='left' && isOpen || position=='right' && !isOpen) {
|
||||
return 'aladin-chevron-left';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
return Box;
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
/*!
|
||||
* jQuery Mousewheel 3.1.13
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
(function (factory) {
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS style for Browserify
|
||||
module.exports = factory;
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
|
||||
var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
|
||||
toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
|
||||
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
|
||||
slice = Array.prototype.slice,
|
||||
nullLowestDeltaTimeout, lowestDelta;
|
||||
|
||||
if ( $.event.fixHooks ) {
|
||||
for ( var i = toFix.length; i; ) {
|
||||
$.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
|
||||
}
|
||||
}
|
||||
|
||||
var special = $.event.special.mousewheel = {
|
||||
version: '3.1.12',
|
||||
|
||||
setup: function() {
|
||||
if ( this.addEventListener ) {
|
||||
for ( var i = toBind.length; i; ) {
|
||||
this.addEventListener( toBind[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = handler;
|
||||
}
|
||||
// Store the line height and page height for this particular element
|
||||
$.data(this, 'mousewheel-line-height', special.getLineHeight(this));
|
||||
$.data(this, 'mousewheel-page-height', special.getPageHeight(this));
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
if ( this.removeEventListener ) {
|
||||
for ( var i = toBind.length; i; ) {
|
||||
this.removeEventListener( toBind[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = null;
|
||||
}
|
||||
// Clean up the data we added to the element
|
||||
$.removeData(this, 'mousewheel-line-height');
|
||||
$.removeData(this, 'mousewheel-page-height');
|
||||
},
|
||||
|
||||
getLineHeight: function(elem) {
|
||||
var $elem = $(elem),
|
||||
$parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
|
||||
if (!$parent.length) {
|
||||
$parent = $('body');
|
||||
}
|
||||
return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
|
||||
},
|
||||
|
||||
getPageHeight: function(elem) {
|
||||
return $(elem).height();
|
||||
},
|
||||
|
||||
settings: {
|
||||
adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
|
||||
normalizeOffset: true // calls getBoundingClientRect for each event
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.extend({
|
||||
mousewheel: function(fn) {
|
||||
return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
|
||||
},
|
||||
|
||||
unmousewheel: function(fn) {
|
||||
return this.unbind('mousewheel', fn);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function handler(event) {
|
||||
var orgEvent = event || window.event,
|
||||
args = slice.call(arguments, 1),
|
||||
delta = 0,
|
||||
deltaX = 0,
|
||||
deltaY = 0,
|
||||
absDelta = 0,
|
||||
offsetX = 0,
|
||||
offsetY = 0;
|
||||
event = $.event.fix(orgEvent);
|
||||
event.type = 'mousewheel';
|
||||
|
||||
// Old school scrollwheel delta
|
||||
if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
|
||||
if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
|
||||
if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
|
||||
if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
|
||||
|
||||
// Firefox < 17 horizontal scrolling related to DOMMouseScroll event
|
||||
if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
|
||||
deltaX = deltaY * -1;
|
||||
deltaY = 0;
|
||||
}
|
||||
|
||||
// Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
|
||||
delta = deltaY === 0 ? deltaX : deltaY;
|
||||
|
||||
// New school wheel delta (wheel event)
|
||||
if ( 'deltaY' in orgEvent ) {
|
||||
deltaY = orgEvent.deltaY * -1;
|
||||
delta = deltaY;
|
||||
}
|
||||
if ( 'deltaX' in orgEvent ) {
|
||||
deltaX = orgEvent.deltaX;
|
||||
if ( deltaY === 0 ) { delta = deltaX * -1; }
|
||||
}
|
||||
|
||||
// No change actually happened, no reason to go any further
|
||||
if ( deltaY === 0 && deltaX === 0 ) { return; }
|
||||
|
||||
// Need to convert lines and pages to pixels if we aren't already in pixels
|
||||
// There are three delta modes:
|
||||
// * deltaMode 0 is by pixels, nothing to do
|
||||
// * deltaMode 1 is by lines
|
||||
// * deltaMode 2 is by pages
|
||||
if ( orgEvent.deltaMode === 1 ) {
|
||||
var lineHeight = $.data(this, 'mousewheel-line-height');
|
||||
delta *= lineHeight;
|
||||
deltaY *= lineHeight;
|
||||
deltaX *= lineHeight;
|
||||
} else if ( orgEvent.deltaMode === 2 ) {
|
||||
var pageHeight = $.data(this, 'mousewheel-page-height');
|
||||
delta *= pageHeight;
|
||||
deltaY *= pageHeight;
|
||||
deltaX *= pageHeight;
|
||||
}
|
||||
|
||||
// Store lowest absolute delta to normalize the delta values
|
||||
absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
|
||||
|
||||
if ( !lowestDelta || absDelta < lowestDelta ) {
|
||||
lowestDelta = absDelta;
|
||||
|
||||
// Adjust older deltas if necessary
|
||||
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
|
||||
lowestDelta /= 40;
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust older deltas if necessary
|
||||
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
|
||||
// Divide all the things by 40!
|
||||
delta /= 40;
|
||||
deltaX /= 40;
|
||||
deltaY /= 40;
|
||||
}
|
||||
|
||||
// Get a whole, normalized value for the deltas
|
||||
delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
|
||||
deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
|
||||
deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
|
||||
|
||||
// Normalise offsetX and offsetY properties
|
||||
if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
|
||||
var boundingRect = this.getBoundingClientRect();
|
||||
offsetX = event.clientX - boundingRect.left;
|
||||
offsetY = event.clientY - boundingRect.top;
|
||||
}
|
||||
|
||||
// Add information to the event object
|
||||
event.deltaX = deltaX;
|
||||
event.deltaY = deltaY;
|
||||
event.deltaFactor = lowestDelta;
|
||||
event.offsetX = offsetX;
|
||||
event.offsetY = offsetY;
|
||||
// Go ahead and set deltaMode to 0 since we converted to pixels
|
||||
// Although this is a little odd since we overwrite the deltaX/Y
|
||||
// properties with normalized deltas.
|
||||
event.deltaMode = 0;
|
||||
|
||||
// Add event and delta to the front of the arguments
|
||||
args.unshift(event, delta, deltaX, deltaY);
|
||||
|
||||
// Clearout lowestDelta after sometime to better
|
||||
// handle multiple device types that give different
|
||||
// a different lowestDelta
|
||||
// Ex: trackpad = 3 and mouse wheel = 120
|
||||
if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
|
||||
nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
|
||||
|
||||
return ($.event.dispatch || $.event.handle).apply(this, args);
|
||||
}
|
||||
|
||||
function nullLowestDelta() {
|
||||
lowestDelta = null;
|
||||
}
|
||||
|
||||
function shouldAdjustOldDeltas(orgEvent, absDelta) {
|
||||
// If this is an older event and the delta is divisable by 120,
|
||||
// then we are assuming that the browser is treating this as an
|
||||
// older mouse wheel event and that we should divide the deltas
|
||||
// by 40 to try and get a more usable deltaFactor.
|
||||
// Side note, this actually impacts the reported scroll distance
|
||||
// in older browsers and can cause scrolling to be slower than native.
|
||||
// Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
|
||||
return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
|
||||
}
|
||||
|
||||
}));
|
||||
Reference in New Issue
Block a user