File galleria-1.4.2.js
has 4395 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Galleria v 1.4.2 2014-08-07
* http://galleria.io
*
* Licensed under the MIT license
Function Utils
has 401 lines of code (exceeds 25 allowed). Consider refactoring. Open
Utils = (function() {
return {
// legacy support for clearTimer
Function _init
has 341 lines of code (exceeds 25 allowed). Consider refactoring. Open
_init: function() {
var self = this,
options = this._options;
Function Finger
has 195 lines of code (exceeds 25 allowed). Consider refactoring. Open
Galleria.Finger = (function() {
var abs = M.abs;
// test for translate3d support
Function _show
has 182 lines of code (exceeds 25 allowed). Consider refactoring. Open
_show : function() {
// shortcuts
var self = this,
queue = this._queue[ 0 ],
Function _createThumbnails
has 177 lines of code (exceeds 25 allowed). Consider refactoring. Open
_createThumbnails : function( push ) {
this.get( 'total' ).innerHTML = this.getDataLength();
var src,
Function scale
has 152 lines of code (exceeds 25 allowed). Consider refactoring. Open
scale: function( options ) {
var self = this;
// extend some defaults
Function init
has 140 lines of code (exceeds 25 allowed). Consider refactoring. Open
init: function( target, options ) {
options = _legacyOptions( options );
// save the original ingredients
Function _enter
has 136 lines of code (exceeds 25 allowed). Consider refactoring. Open
_enter: function( callback ) {
fullscreen.active = true;
if ( IFRAME ) {
Function _transitions
has 128 lines of code (exceeds 25 allowed). Consider refactoring. Open
_transitions = (function() {
var _slide = function(params, complete, fade, door) {
var easing = this.getOptions('easing'),
Function animate
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
animate : (function() {
// detect transition
var transition = (function( style ) {
var props = 'transition WebkitTransition MozTransition OTransition'.split(' '),
Function load
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
load: function(src, size, callback) {
if ( typeof size == 'function' ) {
callback = size;
size = null;
Function _run
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
_run : function() {
var self = this;
self._createThumbnails();
Function complete
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
var complete = (function( data, next, active, queue, thumb ) {
return function() {
var win;
Function init
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
init : function() {
if ( lightbox.initialized ) {
return;
}
Function success
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
success: function() {
// calculate some cropping
var newWidth = ( width - options.margin * 2 ) / self.original.width,
newHeight = ( height - options.margin * 2 ) / self.original.height,
Function show
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
show: function(index) {
lightbox.active = index = typeof index === 'number' ? index : self.getIndex() || 0;
if ( !lightbox.initialized ) {
Function success
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
success: function() {
// save the instance
_galleries.push( self );
Function show
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
show : function( index, rewind, _history ) {
var swipe = this._options.swipe;
// do nothing queue is long || index is false || queue is false and transition is in progress
Function load
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
load : function( source, selector, config ) {
var self = this,
o = this._options;
Function _parseData
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
_parseData : function( callback ) {
var self = this,
current,
ready = false,
Function addPan
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
addPan : function( img ) {
if ( this._options.imageCrop === false ) {
return;
}
Function loadCSS
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
loadCSS : function( href, id, callback ) {
var link,
length;
Function add
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
add: function(handleObj) {
var getCoords = function(e) {
if ( e.touches && e.touches.length ) {
var touch = e.touches[0];
Function Finger
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Finger = function(elem, options) {
// default options
this.config = {
start: 0,
Function _exit
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
_exit: function( callback ) {
fullscreen.active = false;
var inBrowser = !self._options.trueFullscreen || !_nativeFullscreen.support,
Function addTheme
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Galleria.addTheme = function( theme ) {
// make sure we have a name
if ( !theme.name ) {
Galleria.raise('No theme name specified');
Function complete
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
complete: function( next ) {
// toggle low quality for IE
if ( 'image' in active ) {
Utils.toggleQuality( active.image, false );
Function _slide
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
var _slide = function(params, complete, fade, door) {
var easing = this.getOptions('easing'),
distance = this.getStageWidth(),
from = { left: distance * ( params.rewind ? -1 : 1 ) },
Function onThumbLoad
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
onThumbLoad = function( thumb, callback ) {
// scale when ready
thumb.scale({
width: thumb.data.width,
Function onload
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
onload = (function( self, callback, src ) {
return function() {
var complete = function() {
Function raise
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Galleria.raise = function( msg, fatal ) {
var type = fatal ? 'Fatal error' : 'Error',
css = {
Function bind
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
bind: function( elem, value ) {
// todo: revise if alternative tooltip is needed for mobile devices
if (Galleria.TOUCH) {
return;
Function _scaleImage
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
_scaleImage : function( image, options ) {
image = image || this._controls.getActive();
// janpub (JH) fix:
Function enter
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
enter: function( callback ) {
fullscreen.beforeEnter(function() {
callback = fullscreen.parseCallback( callback, true );
Function rescale
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
rescale : function( width, height, complete ) {
var self = this;
// allow rescale(fn)
Function Video
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Video = function( type, id ) {
for( var i=0; i<_video._inst.length; i++ ) {
if ( _video._inst[i].id === id && _video._inst[i].type == type ) {
return _video._inst[i];
Function loop
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
loop: function() {
var distance = this.to - this.pos,
factor = 1;
Function complete
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
complete: function( thumb ) {
// shrink thumbnails to fit
var top = ['left', 'top'],
arr = ['Width', 'Height'],
Function add
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
add: function(elem, to, from, hide) {
if ( !elem || Galleria.TOUCH ) {
return;
}
if (!idle.bound) {
Function rescale
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
rescale: function(event) {
// calculate
var width = M.min( $win.width()-40, lightbox.width ),
height = M.min( $win.height()-60, lightbox.height ),
Function bindControls
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
bindControls: function() {
var i;
carousel.next.on( 'click:fast', function(e) {
Function galleria
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fn.galleria = function( options ) {
var selector = this.selector;
// try domReady if element not found
Function show
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
show : function( elem, speed, callback ) {
callback = callback || F;
var $elem = $(elem);
Function _getWH
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getWH : function() {
var $container = this.$( 'container' ),
$target = this.$( 'target' ),
self = this,
Function lazyLoadChunks
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
lazyLoadChunks: function( size, delay ) {
var len = this.getDataLength(),
i = 0,
n = 0,
Function wait
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
wait : function(options) {
Galleria._waiters = Galleria._waiters || [];
options = $.extend({
Function _playCheck
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
_playCheck : function() {
var self = this,
played = 0,
interval = 20,
now = Utils.timestamp(),
Function flash
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
flash: function(params, complete) {
$(params.next).css({
opacity: 0,
left: 0
});
Function scale
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
var scale = function() {
// set stagewidth
self._stageWidth = width || self.$( 'stage' ).width();
self._stageHeight = height || self.$( 'stage' ).height();
Function hide
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
hide : function( elem, speed, callback ) {
callback = callback || F;
var $elem = $(elem);
Avoid deeply nested control flow statements. Open
if ( type == 'image' && !current.big ) {
current.big = current.image;
}
Function galleria
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
galleria: function (_, t, b, c, d) {
Function galleriaOut
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
galleriaOut: function (_, t, b, c, d) {
Function complete
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
var complete = (function( data, next, active, queue, thumb ) {
Function galleriaIn
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
galleriaIn: function (_, t, b, c, d) {
Function easing
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
easing: function(x,t,b,c,d) {
Function easeout
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
this.easeout = function (x, t, b, c, d) {
Identical blocks of code found in 2 locations. Consider refactoring. Open
(function( $, window, Galleria, undef ) {
/*global jQuery, navigator, Image, module, define */
// some references
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 47583.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76