Input: An Object containing a structure like : { src : url type : mimetype } or string that just contains the src url alone . * var SourceObject = { src : http : // ex . com / video . mp4 type : video / mp4 } ; var SourceString = http : // example . com / some - video . mp4 ; [CODESPLIT] function createTrackHelper ( self , kind , label , language ) { var options = arguments . length > 4 && arguments [ 4 ] !== undefined ? arguments [ 4 ] : { } ; var tracks = self . textTracks ( ) ; options . kind = kind ; if ( label ) { options . label = label ; } if ( language ) { options . language = language ; } options . tech = self ; var track = new ALL . text . TrackClass ( options ) ; tracks . addTrack ( track ) ; return track ; }


Input: Create an instance of this Tech . [CODESPLIT] function Tech ( ) { var options = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ; var ready = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : function ( ) { } ; classCallCheck ( this , Tech ) ; // we don't want the tech to report user activity automatically. // This is done manually in addControlsListeners options . reportTouchActivity = false ; // keep track of whether the current source has played at all to // implement a very limited played() var _this = possibleConstructorReturn ( this , _Component . call ( this , null , options , ready ) ) ; _this . hasStarted_ = false ; _this . on ( 'playing' , function ( ) { this . hasStarted_ = true ; } ) ; _this . on ( 'loadstart' , function ( ) { this . hasStarted_ = false ; } ) ; ALL . names . forEach ( function ( name ) { var props = ALL [ name ] ; if ( options && options [ props . getterName ] ) { _this [ props . privateName ] = options [ props . getterName ] ; } } ) ; // Manually track progress in cases where the browser/flash player doesn't report it. if ( ! _this . featuresProgressEvents ) { _this . manualProgressOn ( ) ; } // Manually track timeupdates in cases where the browser/flash player doesn't report it. if ( ! _this . featuresTimeupdateEvents ) { _this . manualTimeUpdatesOn ( ) ; } [ 'Text' , 'Audio' , 'Video' ] . forEach ( function ( track ) { if ( options [ 'native' + track + 'Tracks' ] === false ) { _this [ 'featuresNative' + track + 'Tracks' ] = false ; } } ) ; if ( options . nativeCaptions === false || options . nativeTextTracks === false ) { _this . featuresNativeTextTracks = false ; } else if ( options . nativeCaptions === true || options . nativeTextTracks === true ) { _this . featuresNativeTextTracks = true ; } if ( ! _this . featuresNativeTextTracks ) { _this . emulateTextTracks ( ) ; } _this . autoRemoteTextTracks_ = new ALL . text . ListClass ( ) ; _this . initTrackListeners ( ) ; // Turn on component tap events only if not using native controls if ( ! options . nativeControlsForTouch ) { _this . emitTapEvents ( ) ; } if ( _this . constructor ) { _this . name_ = _this . constructor . name || 'Unknown Tech' ; } return _this ; }


Input: @module filter - source Filter out single bad source objects or multiple source objects in an array . Also flattens nested source object arrays into a 1 dimensional array of source objects . [CODESPLIT] function filterSource ( src ) { // traverse array if ( Array . isArray ( src ) ) { var newsrc = [ ] ; src . forEach ( function ( srcobj ) { srcobj = filterSource ( srcobj ) ; if ( Array . isArray ( srcobj ) ) { newsrc = newsrc . concat ( srcobj ) ; } else if ( isObject ( srcobj ) ) { newsrc . push ( srcobj ) ; } } ) ; src = newsrc ; } else if ( typeof src === 'string' && src . trim ( ) ) { // convert string into object src = [ { src : src } ] ; } else if ( isObject ( src ) && typeof src . src === 'string' && src . src && src . src . trim ( ) ) { // src is already valid src = [ src ] ; } else { // invalid source, turn it into an empty array src = [ ] ; } return src ; }


Input: Creates an instance of this class . [CODESPLIT] function ClickableComponent ( player , options ) { classCallCheck ( this , ClickableComponent ) ; var _this = possibleConstructorReturn ( this , _Component . call ( this , player , options ) ) ; _this . emitTapEvents ( ) ; _this . enable ( ) ; return _this ; }


Input: Create an instance of this class . [CODESPLIT] function PosterImage ( player , options ) { classCallCheck ( this , PosterImage ) ; var _this = possibleConstructorReturn ( this , _ClickableComponent . call ( this , player , options ) ) ; _this . update ( ) ; player . on ( 'posterchange' , bind ( _this , _this . update ) ) ; return _this ; }


Input: Construct an rgba color from a given hex color code . [CODESPLIT] function constructColor ( color , opacity ) { return 'rgba(' + // color looks like "#f0e" parseInt ( color [ 1 ] + color [ 1 ] , 16 ) + ',' + parseInt ( color [ 2 ] + color [ 2 ] , 16 ) + ',' + parseInt ( color [ 3 ] + color [ 3 ] , 16 ) + ',' + opacity + ')' ; }


Input: Creates an instance of this class . [CODESPLIT] function TextTrackDisplay ( player , options , ready ) { classCallCheck ( this , TextTrackDisplay ) ; var _this = possibleConstructorReturn ( this , _Component . call ( this , player , options , ready ) ) ; player . on ( 'loadstart' , bind ( _this , _this . toggleDisplay ) ) ; player . on ( 'texttrackchange' , bind ( _this , _this . updateDisplay ) ) ; player . on ( 'loadstart' , bind ( _this , _this . preselectTrack ) ) ; // This used to be called during player init, but was causing an error // if a track should show by default and the display hadn't loaded yet. // Should probably be moved to an external track loader when we support // tracks that don't need a display. player . ready ( bind ( _this , function ( ) { if ( player . tech_ && player . tech_ . featuresNativeTextTracks ) { this . hide ( ) ; return ; } player . on ( 'fullscreenchange' , bind ( this , this . updateDisplay ) ) ; var tracks = this . options_ . playerOptions . tracks || [ ] ; for ( var i = 0 ; i < tracks . length ; i ++ ) { this . player_ . addRemoteTextTrack ( tracks [ i ] , true ) ; } this . preselectTrack ( ) ; } ) ) ; return _this ; }


Input: Creates an instance of the this class . [CODESPLIT] function CloseButton ( player , options ) { classCallCheck ( this , CloseButton ) ; var _this = possibleConstructorReturn ( this , _Button . call ( this , player , options ) ) ; _this . controlText ( options && options . controlText || _this . localize ( 'Close' ) ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function PlayToggle ( player , options ) { classCallCheck ( this , PlayToggle ) ; var _this = possibleConstructorReturn ( this , _Button . call ( this , player , options ) ) ; _this . on ( player , 'play' , _this . handlePlay ) ; _this . on ( player , 'pause' , _this . handlePause ) ; _this . on ( player , 'ended' , _this . handleEnded ) ; return _this ; }


Input: @file format - time . js @module Format - time Format seconds as a time string H : MM : SS or M : SS . Supplying a guide ( in seconds ) will force a number of leading zeros to cover the length of the guide . [CODESPLIT] function formatTime ( seconds ) { var guide = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : seconds ; seconds = seconds < 0 ? 0 : seconds ; var s = Math . floor ( seconds % 60 ) ; var m = Math . floor ( seconds / 60 % 60 ) ; var h = Math . floor ( seconds / 3600 ) ; var gm = Math . floor ( guide / 60 % 60 ) ; var gh = Math . floor ( guide / 3600 ) ; // handle invalid times if ( isNaN ( seconds ) || seconds === Infinity ) { // '-' is false for all relational operators (e.g. <, >=) so this setting // will add the minimum number of fields specified by the guide h = m = s = '-' ; } // Check if we need to show hours h = h > 0 || gh > 0 ? h + ':' : '' ; // If hours are showing, we may need to add a leading zero. // Always show at least one digit of minutes. m = ( ( h || gm >= 10 ) && m < 10 ? '0' + m : m ) + ':' ; // Check if leading zero is need for seconds s = s < 10 ? '0' + s : s ; return h + m + s ; }


Input: Creates an instance of this class . [CODESPLIT] function RemainingTimeDisplay ( player , options ) { classCallCheck ( this , RemainingTimeDisplay ) ; var _this = possibleConstructorReturn ( this , _Component . call ( this , player , options ) ) ; _this . throttledUpdateContent = throttle ( bind ( _this , _this . updateContent ) , 25 ) ; _this . on ( player , [ 'timeupdate' , 'durationchange' ] , _this . throttledUpdateContent ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function LiveDisplay ( player , options ) { classCallCheck ( this , LiveDisplay ) ; var _this = possibleConstructorReturn ( this , _Component . call ( this , player , options ) ) ; _this . updateShowing ( ) ; _this . on ( _this . player ( ) , 'durationchange' , _this . updateShowing ) ; return _this ; }


Input: Create an instance of this class [CODESPLIT] function Slider ( player , options ) { classCallCheck ( this , Slider ) ; // Set property names to bar to match with the child Slider class is looking for var _this = possibleConstructorReturn ( this , _Component . call ( this , player , options ) ) ; _this . bar = _this . getChild ( _this . options_ . barName ) ; // Set a horizontal or vertical class on the slider depending on the slider type _this . vertical ( ! ! _this . options_ . vertical ) ; _this . on ( 'mousedown' , _this . handleMouseDown ) ; _this . on ( 'touchstart' , _this . handleMouseDown ) ; _this . on ( 'focus' , _this . handleFocus ) ; _this . on ( 'blur' , _this . handleBlur ) ; _this . on ( 'click' , _this . handleClick ) ; _this . on ( player , 'controlsvisible' , _this . update ) ; if ( _this . playerEvent ) { _this . on ( player , _this . playerEvent , _this . update ) ; } return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function LoadProgressBar ( player , options ) { classCallCheck ( this , LoadProgressBar ) ; var _this = possibleConstructorReturn ( this , _Component . call ( this , player , options ) ) ; _this . partEls_ = [ ] ; _this . on ( player , 'progress' , _this . update ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function MouseTimeDisplay ( player , options ) { classCallCheck ( this , MouseTimeDisplay ) ; var _this = possibleConstructorReturn ( this , _Component . call ( this , player , options ) ) ; _this . update = throttle ( bind ( _this , _this . update ) , 25 ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function SeekBar ( player , options ) { classCallCheck ( this , SeekBar ) ; var _this = possibleConstructorReturn ( this , _Slider . call ( this , player , options ) ) ; _this . update = throttle ( bind ( _this , _this . update ) , 50 ) ; _this . on ( player , [ 'timeupdate' , 'ended' ] , _this . update ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function ProgressControl ( player , options ) { classCallCheck ( this , ProgressControl ) ; var _this = possibleConstructorReturn ( this , _Component . call ( this , player , options ) ) ; _this . handleMouseMove = throttle ( bind ( _this , _this . handleMouseMove ) , 25 ) ; _this . on ( _this . el_ , 'mousemove' , _this . handleMouseMove ) ; _this . throttledHandleMouseSeek = throttle ( bind ( _this , _this . handleMouseSeek ) , 25 ) ; _this . on ( [ 'mousedown' , 'touchstart' ] , _this . handleMouseDown ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function FullscreenToggle ( player , options ) { classCallCheck ( this , FullscreenToggle ) ; var _this = possibleConstructorReturn ( this , _Button . call ( this , player , options ) ) ; _this . on ( player , 'fullscreenchange' , _this . handleFullscreenChange ) ; return _this ; }


Input: Check if volume control is supported and if it isn t hide the Component that was passed using the vjs - hidden class . [CODESPLIT] function checkVolumeSupport ( self , player ) { // hide volume controls when they're not supported by the current tech if ( player . tech_ && ! player . tech_ . featuresVolumeControl ) { self . addClass ( 'vjs-hidden' ) ; } self . on ( player , 'loadstart' , function ( ) { if ( ! player . tech_ . featuresVolumeControl ) { self . addClass ( 'vjs-hidden' ) ; } else { self . removeClass ( 'vjs-hidden' ) ; } } ) ; }


Input: Creates an instance of this class . [CODESPLIT] function VolumeBar ( player , options ) { classCallCheck ( this , VolumeBar ) ; var _this = possibleConstructorReturn ( this , _Slider . call ( this , player , options ) ) ; _this . on ( 'slideractive' , _this . updateLastVolume_ ) ; _this . on ( player , 'volumechange' , _this . updateARIAAttributes ) ; player . ready ( function ( ) { return _this . updateARIAAttributes ( ) ; } ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function VolumeControl ( player ) { var options = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ; classCallCheck ( this , VolumeControl ) ; options . vertical = options . vertical || false ; // Pass the vertical option down to the VolumeBar if // the VolumeBar is turned on. if ( typeof options . volumeBar === 'undefined' || isPlain ( options . volumeBar ) ) { options . volumeBar = options . volumeBar || { } ; options . volumeBar . vertical = options . vertical ; } // hide this control if volume support is missing var _this = possibleConstructorReturn ( this , _Component . call ( this , player , options ) ) ; checkVolumeSupport ( _this , player ) ; _this . throttledHandleMouseMove = throttle ( bind ( _this , _this . handleMouseMove ) , 25 ) ; _this . on ( 'mousedown' , _this . handleMouseDown ) ; _this . on ( 'touchstart' , _this . handleMouseDown ) ; // while the slider is active (the mouse has been pressed down and // is dragging) or in focus we do not want to hide the VolumeBar _this . on ( _this . volumeBar , [ 'focus' , 'slideractive' ] , function ( ) { _this . volumeBar . addClass ( 'vjs-slider-active' ) ; _this . addClass ( 'vjs-slider-active' ) ; _this . trigger ( 'slideractive' ) ; } ) ; _this . on ( _this . volumeBar , [ 'blur' , 'sliderinactive' ] , function ( ) { _this . volumeBar . removeClass ( 'vjs-slider-active' ) ; _this . removeClass ( 'vjs-slider-active' ) ; _this . trigger ( 'sliderinactive' ) ; } ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function MuteToggle ( player , options ) { classCallCheck ( this , MuteToggle ) ; // hide this control if volume support is missing var _this = possibleConstructorReturn ( this , _Button . call ( this , player , options ) ) ; checkVolumeSupport ( _this , player ) ; _this . on ( player , [ 'loadstart' , 'volumechange' ] , _this . update ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function VolumePanel ( player ) { var options = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ; classCallCheck ( this , VolumePanel ) ; if ( typeof options . inline !== 'undefined' ) { options . inline = options . inline ; } else { options . inline = true ; } // pass the inline option down to the VolumeControl as vertical if // the VolumeControl is on. if ( typeof options . volumeControl === 'undefined' || isPlain ( options . volumeControl ) ) { options . volumeControl = options . volumeControl || { } ; options . volumeControl . vertical = ! options . inline ; } // hide this control if volume support is missing var _this = possibleConstructorReturn ( this , _Component . call ( this , player , options ) ) ; checkVolumeSupport ( _this , player ) ; // while the slider is active (the mouse has been pressed down and // is dragging) or in focus we do not want to hide the VolumeBar _this . on ( _this . volumeControl , [ 'slideractive' ] , _this . sliderActive_ ) ; _this . on ( _this . muteToggle , 'focus' , _this . sliderActive_ ) ; _this . on ( _this . volumeControl , [ 'sliderinactive' ] , _this . sliderInactive_ ) ; _this . on ( _this . muteToggle , 'blur' , _this . sliderInactive_ ) ; return _this ; }


Input: Create an instance of this class . [CODESPLIT] function Menu ( player , options ) { classCallCheck ( this , Menu ) ; var _this = possibleConstructorReturn ( this , _Component . call ( this , player , options ) ) ; if ( options ) { _this . menuButton_ = options . menuButton ; } _this . focusedChild_ = - 1 ; _this . on ( 'keydown' , _this . handleKeyPress ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function MenuButton ( player ) { var options = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ; classCallCheck ( this , MenuButton ) ; var _this = possibleConstructorReturn ( this , _Component . call ( this , player , options ) ) ; _this . menuButton_ = new Button ( player , options ) ; _this . menuButton_ . controlText ( _this . controlText_ ) ; _this . menuButton_ . el_ . setAttribute ( 'aria-haspopup' , 'true' ) ; // Add buildCSSClass values to the button, not the wrapper var buttonClass = Button . prototype . buildCSSClass ( ) ; _this . menuButton_ . el_ . className = _this . buildCSSClass ( ) + ' ' + buttonClass ; _this . menuButton_ . removeClass ( 'vjs-control' ) ; _this . addChild ( _this . menuButton_ ) ; _this . update ( ) ; _this . enabled_ = true ; _this . on ( _this . menuButton_ , 'tap' , _this . handleClick ) ; _this . on ( _this . menuButton_ , 'click' , _this . handleClick ) ; _this . on ( _this . menuButton_ , 'focus' , _this . handleFocus ) ; _this . on ( _this . menuButton_ , 'blur' , _this . handleBlur ) ; _this . on ( 'keydown' , _this . handleSubmenuKeyPress ) ; return _this ; }


Input: Creates an instance of the this class . [CODESPLIT] function MenuItem ( player , options ) { classCallCheck ( this , MenuItem ) ; var _this = possibleConstructorReturn ( this , _ClickableComponent . call ( this , player , options ) ) ; _this . selectable = options . selectable ; _this . selected ( options . selected ) ; if ( _this . selectable ) { // TODO: May need to be either menuitemcheckbox or menuitemradio, //       and may need logical grouping of menu items. _this . el_ . setAttribute ( 'role' , 'menuitemcheckbox' ) ; } else { _this . el_ . setAttribute ( 'role' , 'menuitem' ) ; } return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function TextTrackMenuItem ( player , options ) { classCallCheck ( this , TextTrackMenuItem ) ; var track = options . track ; var tracks = player . textTracks ( ) ; // Modify options for parent MenuItem class's init. options . label = track . label || track . language || 'Unknown' ; options . selected = track . mode === 'showing' ; var _this = possibleConstructorReturn ( this , _MenuItem . call ( this , player , options ) ) ; _this . track = track ; var changeHandler = bind ( _this , _this . handleTracksChange ) ; var selectedLanguageChangeHandler = bind ( _this , _this . handleSelectedLanguageChange ) ; player . on ( [ 'loadstart' , 'texttrackchange' ] , changeHandler ) ; tracks . addEventListener ( 'change' , changeHandler ) ; tracks . addEventListener ( 'selectedlanguagechange' , selectedLanguageChangeHandler ) ; _this . on ( 'dispose' , function ( ) { tracks . removeEventListener ( 'change' , changeHandler ) ; tracks . removeEventListener ( 'selectedlanguagechange' , selectedLanguageChangeHandler ) ; } ) ; // iOS7 doesn't dispatch change events to TextTrackLists when an // associated track's mode changes. Without something like // Object.observe() (also not present on iOS7), it's not // possible to detect changes to the mode attribute and polyfill // the change event. As a poor substitute, we manually dispatch // change events whenever the controls modify the mode. if ( tracks . onchange === undefined ) { var event = void 0 ; _this . on ( [ 'tap' , 'click' ] , function ( ) { if ( _typeof ( window . Event ) !== 'object' ) { // Android 2.3 throws an Illegal Constructor error for window.Event try { event = new window . Event ( 'change' ) ; } catch ( err ) { // continue regardless of error } } if ( ! event ) { event = document . createEvent ( 'Event' ) ; event . initEvent ( 'change' , true , true ) ; } tracks . dispatchEvent ( event ) ; } ) ; } return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function OffTextTrackMenuItem ( player , options ) { classCallCheck ( this , OffTextTrackMenuItem ) ; // Create pseudo track info // Requires options['kind'] options . track = { player : player , kind : options . kind , kinds : options . kinds , 'default' : false , mode : 'disabled' } ; if ( ! options . kinds ) { options . kinds = [ options . kind ] ; } if ( options . label ) { options . track . label = options . label ; } else { options . track . label = options . kinds . join ( ' and ' ) + ' off' ; } // MenuItem is selectable options . selectable = true ; var _this = possibleConstructorReturn ( this , _TextTrackMenuItem . call ( this , player , options ) ) ; _this . selected ( true ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function TextTrackButton ( player ) { var options = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ; classCallCheck ( this , TextTrackButton ) ; options . tracks = player . textTracks ( ) ; return possibleConstructorReturn ( this , _TrackButton . call ( this , player , options ) ) ; }


Input: Creates an instance of this class . [CODESPLIT] function ChaptersTrackMenuItem ( player , options ) { classCallCheck ( this , ChaptersTrackMenuItem ) ; var track = options . track ; var cue = options . cue ; var currentTime = player . currentTime ( ) ; // Modify options for parent MenuItem class's init. options . selectable = true ; options . label = cue . text ; options . selected = cue . startTime <= currentTime && currentTime < cue . endTime ; var _this = possibleConstructorReturn ( this , _MenuItem . call ( this , player , options ) ) ; _this . track = track ; _this . cue = cue ; track . addEventListener ( 'cuechange' , bind ( _this , _this . update ) ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function ChaptersButton ( player , options , ready ) { classCallCheck ( this , ChaptersButton ) ; return possibleConstructorReturn ( this , _TextTrackButton . call ( this , player , options , ready ) ) ; }


Input: Creates an instance of this class . [CODESPLIT] function DescriptionsButton ( player , options , ready ) { classCallCheck ( this , DescriptionsButton ) ; var _this = possibleConstructorReturn ( this , _TextTrackButton . call ( this , player , options , ready ) ) ; var tracks = player . textTracks ( ) ; var changeHandler = bind ( _this , _this . handleTracksChange ) ; tracks . addEventListener ( 'change' , changeHandler ) ; _this . on ( 'dispose' , function ( ) { tracks . removeEventListener ( 'change' , changeHandler ) ; } ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function SubtitlesButton ( player , options , ready ) { classCallCheck ( this , SubtitlesButton ) ; return possibleConstructorReturn ( this , _TextTrackButton . call ( this , player , options , ready ) ) ; }


Input: Creates an instance of this class . [CODESPLIT] function CaptionSettingsMenuItem ( player , options ) { classCallCheck ( this , CaptionSettingsMenuItem ) ; options . track = { player : player , kind : options . kind , label : options . kind + ' settings' , selectable : false , 'default' : false , mode : 'disabled' } ; // CaptionSettingsMenuItem has no concept of 'selected' options . selectable = false ; options . name = 'CaptionSettingsMenuItem' ; var _this = possibleConstructorReturn ( this , _TextTrackMenuItem . call ( this , player , options ) ) ; _this . addClass ( 'vjs-texttrack-settings' ) ; _this . controlText ( ', opens ' + options . kind + ' settings dialog' ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function CaptionsButton ( player , options , ready ) { classCallCheck ( this , CaptionsButton ) ; return possibleConstructorReturn ( this , _TextTrackButton . call ( this , player , options , ready ) ) ; }


Input: Creates an instance of this class . [CODESPLIT] function AudioTrackMenuItem ( player , options ) { classCallCheck ( this , AudioTrackMenuItem ) ; var track = options . track ; var tracks = player . audioTracks ( ) ; // Modify options for parent MenuItem class's init. options . label = track . label || track . language || 'Unknown' ; options . selected = track . enabled ; var _this = possibleConstructorReturn ( this , _MenuItem . call ( this , player , options ) ) ; _this . track = track ; var changeHandler = bind ( _this , _this . handleTracksChange ) ; tracks . addEventListener ( 'change' , changeHandler ) ; _this . on ( 'dispose' , function ( ) { tracks . removeEventListener ( 'change' , changeHandler ) ; } ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function AudioTrackButton ( player ) { var options = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ; classCallCheck ( this , AudioTrackButton ) ; options . tracks = player . audioTracks ( ) ; return possibleConstructorReturn ( this , _TrackButton . call ( this , player , options ) ) ; }


Input: Creates an instance of this class . [CODESPLIT] function PlaybackRateMenuItem ( player , options ) { classCallCheck ( this , PlaybackRateMenuItem ) ; var label = options . rate ; var rate = parseFloat ( label , 10 ) ; // Modify options for parent MenuItem class's init. options . label = label ; options . selected = rate === 1 ; options . selectable = true ; var _this = possibleConstructorReturn ( this , _MenuItem . call ( this , player , options ) ) ; _this . label = label ; _this . rate = rate ; _this . on ( player , 'ratechange' , _this . update ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function PlaybackRateMenuButton ( player , options ) { classCallCheck ( this , PlaybackRateMenuButton ) ; var _this = possibleConstructorReturn ( this , _MenuButton . call ( this , player , options ) ) ; _this . updateVisibility ( ) ; _this . updateLabel ( ) ; _this . on ( player , 'loadstart' , _this . updateVisibility ) ; _this . on ( player , 'ratechange' , _this . updateLabel ) ; return _this ; }


Input: Creates an instance of this class . [CODESPLIT] function ErrorDisplay ( player , options ) { classCallCheck ( this , ErrorDisplay ) ; var _this = possibleConstructorReturn ( this , _ModalDialog . call ( this , player , options ) ) ; _this . on ( player , 'error' , _this . open ) ; return _this ; }


Input: Get the actual value of an option . [CODESPLIT] function parseOptionValue ( value , parser ) { if ( parser ) { value = parser ( value ) ; } if ( value && value !== 'none' ) { return value ; } }


Input: Gets the value of the selected <option > element within a <select > element . [CODESPLIT] function getSelectedOptionValue ( el , parser ) { var value = el . options [ el . options . selectedIndex ] . value ; return parseOptionValue ( value , parser ) ; }


Input: Sets the selected <option > element within a <select > element based on a given value . [CODESPLIT] function setSelectedOption ( el , value , parser ) { if ( ! value ) { return ; } for ( var i = 0 ; i < el . options . length ; i ++ ) { if ( parseOptionValue ( el . options [ i ] . value , parser ) === value ) { el . selectedIndex = i ; break ; } } }


Input: Creates an instance of this class . [CODESPLIT] function TextTrackSettings ( player , options ) { classCallCheck ( this , TextTrackSettings ) ; options . temporary = false ; var _this = possibleConstructorReturn ( this , _ModalDialog . call ( this , player , options ) ) ; _this . updateDisplay = bind ( _this , _this . updateDisplay ) ; // fill the modal and pretend we have opened it _this . fill ( ) ; _this . hasBeenOpened_ = _this . hasBeenFilled_ = true ; _this . endDialog = createEl ( 'p' , { className : 'vjs-control-text' , textContent : _this . localize ( 'End of dialog window.' ) } ) ; _this . el ( ) . appendChild ( _this . endDialog ) ; _this . setDefaults ( ) ; // Grab `persistTextTrackSettings` from the player options if not passed in child options if ( options . persistTextTrackSettings === undefined ) { _this . options_ . persistTextTrackSettings = _this . options_ . playerOptions . persistTextTrackSettings ; } _this . on ( _this . $ ( '.vjs-done-button' ) , 'click' , function ( ) { _this . saveSettings ( ) ; _this . close ( ) ; } ) ; _this . on ( _this . $ ( '.vjs-default-button' ) , 'click' , function ( ) { _this . setDefaults ( ) ; _this . updateDisplay ( ) ; } ) ; each ( selectConfigs , function ( config ) { _this . on ( _this . $ ( config . selector ) , 'change' , _this . updateDisplay ) ; } ) ; if ( _this . options_ . persistTextTrackSettings ) { _this . restoreSettings ( ) ; } return _this ; }


Input: Create an instance of this Tech . [CODESPLIT] function Html5 ( options , ready ) { classCallCheck ( this , Html5 ) ; var _this = possibleConstructorReturn ( this , _Tech . call ( this , options , ready ) ) ; var source = options . source ; var crossoriginTracks = false ; // Set the source if one is provided // 1) Check if the source is new (if not, we want to keep the original so playback isn't interrupted) // 2) Check to see if the network state of the tag was failed at init, and if so, reset the source // anyway so the error gets fired. if ( source && ( _this . el_ . currentSrc !== source . src || options . tag && options . tag . initNetworkState_ === 3 ) ) { _this . setSource ( source ) ; } else { _this . handleLateInit_ ( _this . el_ ) ; } if ( _this . el_ . hasChildNodes ( ) ) { var nodes = _this . el_ . childNodes ; var nodesLength = nodes . length ; var removeNodes = [ ] ; while ( nodesLength -- ) { var node = nodes [ nodesLength ] ; var nodeName = node . nodeName . toLowerCase ( ) ; if ( nodeName === 'track' ) { if ( ! _this . featuresNativeTextTracks ) { // Empty video tag tracks so the built-in player doesn't use them also. // This may not be fast enough to stop HTML5 browsers from reading the tags // so we'll need to turn off any default tracks if we're manually doing // captions and subtitles. videoElement.textTracks removeNodes . push ( node ) ; } else { // store HTMLTrackElement and TextTrack to remote list _this . remoteTextTrackEls ( ) . addTrackElement_ ( node ) ; _this . remoteTextTracks ( ) . addTrack ( node . track ) ; _this . textTracks ( ) . addTrack ( node . track ) ; if ( ! crossoriginTracks && ! _this . el_ . hasAttribute ( 'crossorigin' ) && isCrossOrigin ( node . src ) ) { crossoriginTracks = true ; } } } } for ( var i = 0 ; i < removeNodes . length ; i ++ ) { _this . el_ . removeChild ( removeNodes [ i ] ) ; } } _this . proxyNativeTracks_ ( ) ; if ( _this . featuresNativeTextTracks && crossoriginTracks ) { log$1 . warn ( tsml ( _templateObject$2 ) ) ; } // Determine if native controls should be used // Our goal should be to get the custom controls on mobile solid everywhere // so we can remove this all together. Right now this will block custom // controls on touch enabled laptops like the Chrome Pixel if ( ( TOUCH_ENABLED || IS_IPHONE || IS_NATIVE_ANDROID ) && options . nativeControlsForTouch === true ) { _this . setControls ( true ) ; } // on iOS, we want to proxy `webkitbeginfullscreen` and `webkitendfullscreen` // into a `fullscreenchange` event _this . proxyWebkitFullscreen_ ( ) ; _this . triggerReady ( ) ; return _this ; }


Input: Wait for the first timeupdate with currentTime > 0 - there may be several with 0 [CODESPLIT] function checkProgress ( ) { if ( _this3 . el_ . currentTime > 0 ) { // Trigger durationchange for genuinely live video if ( _this3 . el_ . duration === Infinity ) { _this3 . trigger ( 'durationchange' ) ; } _this3 . off ( 'timeupdate' , checkProgress ) ; } }


Input:
Create an instance of this class . [CODESPLIT] function Player ( tag , options , ready ) { classCallCheck ( this , Player ) ; // Make sure tag ID exists tag . id = tag . id || 'vjs_video_' + newGUID ( ) ; // Set Options // The options argument overrides options set in the video tag // which overrides globally set options. // This latter part coincides with the load order // (tag must exist before Player) options = assign ( Player . getTagSettings ( tag ) , options ) ; // Delay the initialization of children because we need to set up // player properties first, and can't use `this` before `super()` options . initChildren = false ; // Same with creating the element options . createEl = false ; // we don't want the player to report touch activity on itself // see enableTouchActivity in Component options . reportTouchActivity = false ; // If language is not set, get the closest lang attribute if ( ! options . language ) { if ( typeof tag . closest === 'function' ) { var closest = tag . closest ( '[lang]' ) ; if ( closest ) { options . language = closest . getAttribute ( 'lang' ) ; } } else { var element = tag ; while ( element && element . nodeType === 1 ) { if ( getAttributes ( element ) . hasOwnProperty ( 'lang' ) ) { options . language = element . getAttribute ( 'lang' ) ; break ; } element = element . parentNode ; } } } // Run base component initializing with new options // Turn off API access because we're loading a new tech that might load asynchronously var _this = possibleConstructorReturn ( this , _Component . call ( this , null , options , ready ) ) ; _this . isReady_ = false ; // if the global option object was accidentally blown away by // someone, bail early with an informative error if ( ! _this . options_ || ! _this . options_ . techOrder || ! _this . options_ . techOrder . length ) { throw new Error ( 'No techOrder specified. Did you overwrite ' + 'videojs.options instead of just changing the ' + 'properties you want to override?' ) ; } // Store the original tag used to set options _this . tag = tag ; // Store the tag attributes used to restore html5 element _this . tagAttributes = tag && getAttributes ( tag ) ; // Update current language _this . language ( _this . options_ . language ) ; // Update Supported Languages if ( options . languages ) { // Normalise player option languages to lowercase var languagesToLower = { } ; Object . getOwnPropertyNames ( options . languages ) . forEach ( function ( name$$1 ) { languagesToLower [ name$$1 . toLowerCase ( ) ] = options . languages [ name$$1 ] ; } ) ; _this . languages_ = languagesToLower ; } else { _this . languages_ = Player . prototype . options_ . languages ; } // Cache for video property values. _this . cache_ = { } ; // Set poster _this . poster_ = options . poster || '' ; // Set controls _this . controls_ = ! ! options . controls ; // Set default values for lastVolume _this . cache_ . lastVolume = 1 ; // Original tag settings stored in options // now remove immediately so native controls don't flash. // May be turned back on by HTML5 tech if nativeControlsForTouch is true tag . controls = false ; /*
     * Store the internal state of scrubbing
     *
     * @private
     * @return {Boolean} True if the user is scrubbing
     */ _this . scrubbing_ = false ; _this . el_ = _this . createEl ( ) ; // Make this an evented object and use `el_` as its event bus. evented ( _this , { eventBusKey : 'el_' } ) ; // We also want to pass the original player options to each component and plugin // as well so they don't need to reach back into the player for options later. // We also need to do another copy of this.options_ so we don't end up with // an infinite loop. var playerOptionsCopy = mergeOptions ( _this . options_ ) ; // Load plugins if ( options . plugins ) { var plugins = options . plugins ; Object . keys ( plugins ) . forEach ( function ( name$$1 ) { if ( typeof this [ name$$1 ] === 'function' ) { this [ name$$1 ] ( plugins [ name$$1 ] ) ; } else { throw new Error ( 'plugin "' + name$$1 + '" does not exist' ) ; } } , _this ) ; } _this . options_ . playerOptions = playerOptionsCopy ; _this . middleware_ = [ ] ; _this . initChildren ( ) ; // Set isAudio based on whether or not an audio tag was used _this . isAudio ( tag . nodeName . toLowerCase ( ) === 'audio' ) ; // Update controls className. Can't do this when the controls are initially // set because the element doesn't exist yet. if ( _this . controls ( ) ) { _this . addClass ( 'vjs-controls-enabled' ) ; } else { _this . addClass ( 'vjs-controls-disabled' ) ; } // Set ARIA label and region role depending on player type _this . el_ . setAttribute ( 'role' , 'region' ) ; if ( _this . isAudio ( ) ) { _this . el_ . setAttribute ( 'aria-label' , _this . localize ( 'Audio Player' ) ) ; } else { _this . el_ . setAttribute ( 'aria-label' , _this . localize ( 'Video Player' ) ) ; } if ( _this . isAudio ( ) ) { _this . addClass ( 'vjs-audio' ) ; } if ( _this . flexNotSupported_ ( ) ) { _this . addClass ( 'vjs-no-flex' ) ; } // TODO: Make this smarter. Toggle user state between touching/mousing // using events, since devices can have both touch and mouse events. // if (browser.TOUCH_ENABLED) { //   this.addClass('vjs-touch-enabled'); // } // iOS Safari has broken hover handling if ( ! IS_IOS ) { _this . addClass ( 'vjs-workinghover' ) ; } // Make player easily findable by ID Player . players [ _this . id_ ] = _this ; // Add a major version class to aid css in plugins var majorVersion = version . split ( '.' ) [ 0 ] ; _this . addClass ( 'vjs-v' + majorVersion ) ; // When the player is first initialized, trigger activity so components // like the control bar show themselves if needed _this . userActive ( true ) ; _this . reportUserActivity ( ) ; _this . listenForUserActivity_ ( ) ; _this . on ( 'fullscreenchange' , _this . handleFullscreenChange_ ) ; _this . on ( 'stageclick' , _this . handleStageClick_ ) ; _this . changingSrc_ = false ; return _this ; }


Input: Iterate over each innerArray element once per outerArray element and execute tester with both . If tester returns a non - falsy value exit early and return that value . [CODESPLIT] function findFirstPassingTechSourcePair ( outerArray , innerArray , tester ) { var found = void 0 ; outerArray . some ( function ( outerChoice ) { return innerArray . some ( function ( innerChoice ) { found = tester ( outerChoice , innerChoice ) ; if ( found ) { return true ; } } ) ; } ) ; return found ; }


Input: Marks a plugin as active on a player . [CODESPLIT] function markPluginAsActive ( player , name ) { player [ PLUGIN_CACHE_KEY ] = player [ PLUGIN_CACHE_KEY ] || { } ; player [ PLUGIN_CACHE_KEY ] [ name ] = true ; }


Input: Triggers a pair of plugin setup events . [CODESPLIT] function triggerSetupEvent ( player , hash , before ) { var eventName = ( before ? 'before' : '' ) + 'pluginsetup' ; player . trigger ( eventName , hash ) ; player . trigger ( eventName + ':' + hash . name , hash ) ; }


Input: Takes a basic plugin function and returns a wrapper function which marks on the player that the plugin has been activated . [CODESPLIT] function createBasicPlugin ( name , plugin ) { var basicPluginWrapper = function basicPluginWrapper ( ) { // We trigger the "beforepluginsetup" and "pluginsetup" events on the player // regardless, but we want the hash to be consistent with the hash provided // for advanced plugins. // // The only potentially counter-intuitive thing here is the `instance` in // the "pluginsetup" event is the value returned by the `plugin` function. triggerSetupEvent ( this , { name : name , plugin : plugin , instance : null } , true ) ; var instance = plugin . apply ( this , arguments ) ; markPluginAsActive ( this , name ) ; triggerSetupEvent ( this , { name : name , plugin : plugin , instance : instance } ) ; return instance ; } ; Object . keys ( plugin ) . forEach ( function ( prop ) { basicPluginWrapper [ prop ] = plugin [ prop ] ; } ) ; return basicPluginWrapper ; }


Input: Takes a plugin sub - class and returns a factory function for generating instances of it . [CODESPLIT] function createPluginFactory ( name , PluginSubClass ) { // Add a `name` property to the plugin prototype so that each plugin can // refer to itself by name. PluginSubClass . prototype . name = name ; return function ( ) { triggerSetupEvent ( this , { name : name , plugin : PluginSubClass , instance : null } , true ) ; for ( var _len = arguments . length , args = Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) { args [ _key ] = arguments [ _key ] ; } var instance = new ( Function . prototype . bind . apply ( PluginSubClass , [ null ] . concat ( [ this ] . concat ( args ) ) ) ) ( ) ; // The plugin is replaced by a function that returns the current instance. this [ name ] = function ( ) { return instance ; } ; triggerSetupEvent ( this , instance . getEventHash ( ) ) ; return instance ; } ; }


Input: Creates an instance of this class . [CODESPLIT] function Plugin ( player ) { classCallCheck ( this , Plugin ) ; if ( this . constructor === Plugin ) { throw new Error ( 'Plugin must be sub-classed; not directly instantiated.' ) ; } this . player = player ; // Make this object evented, but remove the added `trigger` method so we // use the prototype version instead. evented ( this ) ; delete this . trigger ; stateful ( this , this . constructor . defaultState ) ; markPluginAsActive ( player , this . name ) ; // Auto-bind the dispose method so we can use it as a listener and unbind // it later easily. this . dispose = bind ( this , this . dispose ) ; // If the player is disposed, dispose the plugin. player . on ( 'dispose' , this . dispose ) ; }


Input: Doubles as the main function for users to create a player instance and also the main library object . The videojs function can be used to initialize or retrieve a player . [CODESPLIT] function videojs ( id , options , ready ) { var tag = void 0 ; // Allow for element or ID to be passed in // String ID if ( typeof id === 'string' ) { var players = videojs . getPlayers ( ) ; // Adjust for jQuery ID syntax if ( id . indexOf ( '#' ) === 0 ) { id = id . slice ( 1 ) ; } // If a player instance has already been created for this ID return it. if ( players [ id ] ) { // If options or ready function are passed, warn if ( options ) { log$1 . warn ( 'Player "' + id + '" is already initialised. Options will not be applied.' ) ; } if ( ready ) { players [ id ] . ready ( ready ) ; } return players [ id ] ; } // Otherwise get element for ID tag = $ ( '#' + id ) ; // ID is a media element } else { tag = id ; } // Check for a useable element // re: nodeName, could be a box div also if ( ! tag || ! tag . nodeName ) { throw new TypeError ( 'The element or ID supplied is not valid. (videojs)' ) ; } // Element may have a player attr referring to an already created player instance. // If so return that otherwise set up a new player below if ( tag . player || Player . players [ tag . playerId ] ) { return tag . player || Player . players [ tag . playerId ] ; } options = options || { } ; videojs . hooks ( 'beforesetup' ) . forEach ( function ( hookFunction ) { var opts = hookFunction ( tag , mergeOptions ( options ) ) ; if ( ! isObject ( opts ) || Array . isArray ( opts ) ) { log$1 . error ( 'please return an object in beforesetup hooks' ) ; return ; } options = mergeOptions ( options , opts ) ; } ) ; var PlayerComponent = Component . getComponent ( 'Player' ) ; // If not, set up a new player var player = new PlayerComponent ( tag , options , ready ) ; videojs . hooks ( 'setup' ) . forEach ( function ( hookFunction ) { return hookFunction ( player ) ; } ) ; return player ; }


Input: / [CODESPLIT] function ( component , name , animation ) { var html5 = exports var transition = { property : html5 . getPrefixedName ( 'transition-property' ) , delay : html5 . getPrefixedName ( 'transition-delay' ) , duration : html5 . getPrefixedName ( 'transition-duration' ) , timing : html5 . getPrefixedName ( 'transition-timing-function' ) } var element = component . element element . forceLayout ( ) //flush styles before setting transition name = html5 . getPrefixedName ( name ) || name //replace transform: <prefix>rotate hack var transitions = element . _transitions var property = transitions [ transition . property ] || [ ] var duration = transitions [ transition . duration ] || [ ] var timing = transitions [ transition . timing ] || [ ] var delay = transitions [ transition . delay ] || [ ] var idx = property . indexOf ( name ) if ( idx === - 1 ) { //if property not set if ( animation ) { property . push ( name ) duration . push ( animation . duration + 'ms' ) timing . push ( animation . easing ) delay . push ( animation . delay + 'ms' ) } } else { //property already set, adjust the params if ( animation && animation . active ( ) ) { duration [ idx ] = animation . duration + 'ms' timing [ idx ] = animation . easing delay [ idx ] = animation . delay + 'ms' } else { property . splice ( idx , 1 ) duration . splice ( idx , 1 ) timing . splice ( idx , 1 ) delay . splice ( idx , 1 ) } } transitions [ transition . property ] = property transitions [ transition . duration ] = duration transitions [ transition . timing ] = timing transitions [ transition . delay ] = delay //FIXME: orsay animation is not working without this shit =( if ( component . _context . system . os === 'orsay' || component . _context . system . os === 'netcast' ) { transitions [ "transition-property" ] = property transitions [ "transition-duration" ] = duration transitions [ "transition-delay" ] = delay transitions [ "transition-timing-function" ] = timing } component . style ( transitions ) return true }


Input: Comment out if you didn t npm install lz - string [CODESPLIT] function byteCount ( testName , len , baseLen ) { console . log ( testName + " Byte Count: " + len + ( baseLen ? ', ' + Math . round ( len / baseLen * 100 ) + '%' : '' ) ) ; }


Input:
The number of bytes of data that have been queued using calls to send () but not yet transmitted to the network . This value resets to zero once all queued data has been sent . This value does not reset to zero when the connection is closed ; if you keep calling send () this will continue to climb . Read only [CODESPLIT] function ( ) { var bytes = this . _messageQueue . reduce ( function ( acc , message ) { if ( typeof message === 'string' ) { acc += message . length ; // not byte size
 } else if ( message instanceof Blob ) { acc += message . size ; } else { acc += message . byteLength ; } return acc ; } , 0 ) ; return bytes + ( this . _ws ? this . _ws . bufferedAmount : 0 ) ; }


Input: Randomizes whatever colors are currently being used . [CODESPLIT] function ( ) { var colors = [ ] var trs = _$sortableDataList . find ( "li" ) ; for ( var i = 0 ; i < trs . length ; i ++ ) { colors . push ( utils . rgb2hex ( $ ( trs [ i ] ) . find ( ".segmentColor" ) . css ( "background-color" ) ) ) ; } colors = utils . shuffleArray ( colors ) ; _setColors ( colors ) ; }


Input: Publishes a message to anyone who s subscribed to it . [CODESPLIT] function ( moduleID , message , data ) { if ( C . DEBUG ) { console . log ( "[" + moduleID + "] publish(): " , message , data ) ; } for ( var i in _modules ) { var subscriptions = _modules [ i ] . subscriptions ; // if this module has subscribed to this event, call the callback function if ( subscriptions . hasOwnProperty ( message ) ) { subscriptions [ message ] ( { sender : moduleID , data : data } ) ; } } }


Input: this catches ALL nav clicks not just in the main navbar [CODESPLIT] function ( ) { $ ( document ) . on ( "click" , ".selectPage" , function ( e ) { e . preventDefault ( ) ; _selectPage ( this . hash ) ; } ) ; $ ( window ) . on ( "resize" , function ( ) { var width = $ ( window ) . width ( ) ; var height = $ ( window ) . height ( ) ; var breakPoint = _updateBodySizeClass ( width ) ; mediator . publish ( _MODULE_ID , C . EVENT . PAGE . RESIZE , { width : width , height : height , breakPoint : breakPoint } ) ; } ) ; }


Input: This was added to get around some CSS nonsense with the homepage slider script . It adds a class to the body element that specifies the current viewport width . [CODESPLIT] function ( width ) { var breakPointIndex = null ; for ( var i = 0 ; i < C . OTHER . BREAKPOINTS . length ; i ++ ) { if ( width >= C . OTHER . BREAKPOINTS [ i ] ) { breakPointIndex = i ; } } $ ( "body" ) . removeClass ( "size768 size992 size1200" ) ; var breakPoint = null ; if ( breakPointIndex !== null ) { breakPoint = C . OTHER . BREAKPOINTS [ breakPointIndex ] ; $ ( "body" ) . addClass ( "size" + breakPoint ) ; } return breakPoint ; }


Input: Our main hideous navigation function . This accepts a page identifier ( string ) listed in the _pages array above . This function validates the page string and fade in / out the appropriate page . [CODESPLIT] function ( pageCandidate ) { // remove any hashes that may be there var pageCandidateNoHash = pageCandidate . replace ( / # / , "" ) ; var hashParts = pageCandidateNoHash . split ( "-" ) ; var page = hashParts [ 0 ] ; // check the page is valid. If not, default to the About page page = ( $ . inArray ( page , _pages ) !== - 1 ) ? page : "about" ; if ( pageCandidate === _currentPageHash ) { return ; } var publishData = { page : page , prevPage : _currentPage , pageHash : pageCandidateNoHash } ; if ( page !== _currentPage ) { // fade out the old page, if one was selected (not the case for first load) if ( _currentPage ) { _$topNav . find ( ".active" ) . removeClass ( "active" ) ; $ ( "#" + _currentPage ) . removeClass ( "hidden fadeIn" ) . addClass ( "fadeOut" ) ; ( function ( cp ) { setTimeout ( function ( ) { $ ( "#" + cp ) . addClass ( "hidden" ) . removeClass ( "fadeOut" ) ; // show the new one. Good lord. Nested setTimeouts? What the gibbering fuck... setTimeout ( function ( ) { _$topNav . find ( "a[href=#" + page + "]" ) . closest ( "li" ) . addClass ( "active" ) ; // select the tab $ ( "#" + page ) . removeClass ( "hidden fadeOut" ) . addClass ( "fadeIn" ) ; // select the page mediator . publish ( _MODULE_ID , C . EVENT . PAGE . LOAD , publishData ) ; } , 10 ) ; } , C . OTHER . PAGE_LOAD_SPEED ) ; } ) ( _currentPage ) ; } else { _$topNav . find ( "a[href=#" + page + "]" ) . closest ( "li" ) . addClass ( "active" ) ; // select the tab $ ( "#" + page ) . removeClass ( "hidden fadeOut" ) ; // weird, we need the timeout for the initial page load otherwise it doesn't fade in setTimeout ( function ( ) { $ ( "#" + page ) . addClass ( "fadeIn" ) ; mediator . publish ( _MODULE_ID , C . EVENT . PAGE . LOAD , publishData ) ; } , 10 ) ; } } else { mediator . publish ( _MODULE_ID , C . EVENT . PAGE . LOAD , publishData ) ; } window . location . hash = pageCandidate ; // store the current page & full hash _currentPage = page ; _currentPageHash = pageCandidate ; }


Input: TODO : Remove this line and break up compilePartial [CODESPLIT] function template ( templateSpec , env ) { if ( ! env ) { throw new Exception ( "No environment passed to template" ) ; } // Note: Using env.VM references rather than local var references throughout this section to allow // for external users to override these as psuedo-supported APIs. var invokePartialWrapper = function ( partial , name , context , helpers , partials , data ) { var result = env . VM . invokePartial . apply ( this , arguments ) ; if ( result != null ) { return result ; } if ( env . compile ) { var options = { helpers : helpers , partials : partials , data : data } ; partials [ name ] = env . compile ( partial , { data : data !== undefined } , env ) ; return partials [ name ] ( context , options ) ; } else { throw new Exception ( "The partial " + name + " could not be compiled when running in runtime-only mode" ) ; } } ; // Just add water var container = { escapeExpression : Utils . escapeExpression , invokePartial : invokePartialWrapper , programs : [ ] , program : function ( i , fn , data ) { var programWrapper = this . programs [ i ] ; if ( data ) { programWrapper = program ( i , fn , data ) ; } else if ( ! programWrapper ) { programWrapper = this . programs [ i ] = program ( i , fn ) ; } return programWrapper ; } , merge : function ( param , common ) { var ret = param || common ; if ( param && common && ( param !== common ) ) { ret = { } ; Utils . extend ( ret , common ) ; Utils . extend ( ret , param ) ; } return ret ; } , programWithDepth : env . VM . programWithDepth , noop : env . VM . noop , compilerInfo : null } ; return function ( context , options ) { options = options || { } ; var namespace = options . partial ? options : env , helpers , partials ; if ( ! options . partial ) { helpers = options . helpers ; partials = options . partials ; } var result = templateSpec . call ( container , namespace , context , helpers , partials , options . data ) ; if ( ! options . partial ) { env . VM . checkRevision ( container . compilerInfo ) ; } return result ; } ; }


Input: Note : Using env . VM references rather than local var references throughout this section to allow for external users to override these as psuedo - supported APIs . [CODESPLIT] function ( partial , name , context , helpers , partials , data ) { var result = env . VM . invokePartial . apply ( this , arguments ) ; if ( result != null ) { return result ; } if ( env . compile ) { var options = { helpers : helpers , partials : partials , data : data } ; partials [ name ] = env . compile ( partial , { data : data !== undefined } , env ) ; return partials [ name ] ( context , options ) ; } else { throw new Exception ( "The partial " + name + " could not be compiled when running in runtime-only mode" ) ; } }


Input: For compatibility and usage outside of module systems make the Handlebars object a namespace [CODESPLIT] function ( ) { var hb = new base . HandlebarsEnvironment ( ) ; Utils . extend ( hb , base ) ; hb . SafeString = SafeString ; hb . Exception = Exception ; hb . Utils = Utils ; hb . VM = runtime ; hb . template = function ( spec ) { return runtime . template ( spec , hb ) ; } ; return hb ; }


Input: PUBLIC API : You can override these methods in a subclass to provide alternative compiled forms for name lookup and buffering semantics [CODESPLIT] function ( parent , name /* , type*/ ) { var wrap , ret ; if ( parent . indexOf ( 'depth' ) === 0 ) { wrap = true ; } if ( / ^[0-9]+$ / . test ( name ) ) { ret = parent + "[" + name + "]" ; } else if ( JavaScriptCompiler . isValidJavaScriptVariableName ( name ) ) { ret = parent + "." + name ; } else { ret = parent + "['" + name + "']" ; } if ( wrap ) { return '(' + parent + ' && ' + ret + ')' ; } else { return ret ; } }


Input: END PUBLIC API [CODESPLIT] function ( environment , options , context , asObject ) { this . environment = environment ; this . options = options || { } ; log ( 'debug' , this . environment . disassemble ( ) + "\n\n" ) ; this . name = this . environment . name ; this . isChild = ! ! context ; this . context = context || { programs : [ ] , environments : [ ] , aliases : { } } ; this . preamble ( ) ; this . stackSlot = 0 ; this . stackVars = [ ] ; this . registers = { list : [ ] } ; this . hashes = [ ] ; this . compileStack = [ ] ; this . inlineStack = [ ] ; this . compileChildren ( environment , options ) ; var opcodes = environment . opcodes , opcode ; this . i = 0 ; for ( var l = opcodes . length ; this . i < l ; this . i ++ ) { opcode = opcodes [ this . i ] ; if ( opcode . opcode === 'DECLARE' ) { this [ opcode . name ] = opcode . value ; } else { this [ opcode . opcode ] . apply ( this , opcode . args ) ; } // Reset the stripNext flag if it was not set by this operation. if ( opcode . opcode !== this . stripNext ) { this . stripNext = false ; } } // Flush any trailing content that might be pending. this . pushSource ( '' ) ; if ( this . stackSlot || this . inlineStack . length || this . compileStack . length ) { throw new Exception ( 'Compile completed with content left on stack' ) ; } return this . createFunctionContext ( asObject ) ; }


Input: [ ambiguousBlockValue ] On stack before : hash inverse program value Compiler value before : lastHelper = value of last found helper if any On stack after if no lastHelper : same as [ blockValue ] On stack after if lastHelper : value [CODESPLIT] function ( ) { this . context . aliases . blockHelperMissing = 'helpers.blockHelperMissing' ; var params = [ "depth0" ] ; this . setupParams ( 0 , params ) ; var current = this . topStack ( ) ; params . splice ( 1 , 0 , current ) ; this . pushSource ( "if (!" + this . lastHelper + ") { " + current + " = blockHelperMissing.call(" + params . join ( ", " ) + "); }" ) ; }


Input: [ appendContent ] On stack before : ... On stack after : ... Appends the string value of content to the current buffer [CODESPLIT] function ( content ) { if ( this . pendingContent ) { content = this . pendingContent + content ; } if ( this . stripNext ) { content = content . replace ( / ^\s+ / , '' ) ; } this . pendingContent = content ; }


Input: [ pushStringParam ] On stack before : ... On stack after : string currentContext ... This opcode is designed for use in string mode which provides the string value of a parameter along with its depth rather than resolving it immediately . [CODESPLIT] function ( string , type ) { this . pushStackLiteral ( 'depth' + this . lastContext ) ; this . pushString ( type ) ; // If it's a subexpression, the string result // will be pushed after this opcode. if ( type !== 'sexpr' ) { if ( typeof string === 'string' ) { this . pushString ( string ) ; } else { this . pushStackLiteral ( string ) ; } } }


Input: [ invokeHelper ] On stack before : hash inverse program params ... ... On stack after : result of helper invocation Pops off the helper s parameters invokes the helper and pushes the helper s return value onto the stack . If the helper is not found helperMissing is called . [CODESPLIT] function ( paramSize , name , isRoot ) { this . context . aliases . helperMissing = 'helpers.helperMissing' ; this . useRegister ( 'helper' ) ; var helper = this . lastHelper = this . setupHelper ( paramSize , name , true ) ; var nonHelper = this . nameLookup ( 'depth' + this . lastContext , name , 'context' ) ; var lookup = 'helper = ' + helper . name + ' || ' + nonHelper ; if ( helper . paramsInit ) { lookup += ',' + helper . paramsInit ; } this . push ( '(' + lookup + ',helper ' + '? helper.call(' + helper . callParams + ') ' + ': helperMissing.call(' + helper . helperMissingParams + '))' ) ; // Always flush subexpressions. This is both to prevent the compounding size issue that // occurs when the code has to be duplicated for inlining and also to prevent errors // due to the incorrect options object being passed due to the shared register. if ( ! isRoot ) { this . flushInline ( ) ; } }


Input: [ invokeKnownHelper ] On stack before : hash inverse program params ... ... On stack after : result of helper invocation This operation is used when the helper is known to exist so a helperMissing fallback is not required . [CODESPLIT] function ( paramSize , name ) { var helper = this . setupHelper ( paramSize , name ) ; this . push ( helper . name + ".call(" + helper . callParams + ")" ) ; }


Input: [ invokeAmbiguous ] On stack before : hash inverse program params ... ... On stack after : result of disambiguation This operation is used when an expression like {{ foo }} is provided but we don t know at compile - time whether it is a helper or a path . This operation emits more code than the other options and can be avoided by passing the knownHelpers and knownHelpersOnly flags at compile - time . [CODESPLIT] function ( name , helperCall ) { this . context . aliases . functionType = '"function"' ; this . useRegister ( 'helper' ) ; this . emptyHash ( ) ; var helper = this . setupHelper ( 0 , name , helperCall ) ; var helperName = this . lastHelper = this . nameLookup ( 'helpers' , name , 'helper' ) ; var nonHelper = this . nameLookup ( 'depth' + this . lastContext , name , 'context' ) ; var nextStack = this . nextStack ( ) ; if ( helper . paramsInit ) { this . pushSource ( helper . paramsInit ) ; } this . pushSource ( 'if (helper = ' + helperName + ') { ' + nextStack + ' = helper.call(' + helper . callParams + '); }' ) ; this . pushSource ( 'else { helper = ' + nonHelper + '; ' + nextStack + ' = typeof helper === functionType ? helper.call(' + helper . callParams + ') : helper; }' ) ; }


Input: [ assignToHash ] On stack before : value hash ... On stack after : hash ... Pops a value and hash off the stack assigns hash [ key ] = value and pushes the hash back onto the stack . [CODESPLIT] function ( key ) { var value = this . popStack ( ) , context , type ; if ( this . options . stringParams ) { type = this . popStack ( ) ; context = this . popStack ( ) ; } var hash = this . hash ; if ( context ) { hash . contexts . push ( "'" + key + "': " + context ) ; } if ( type ) { hash . types . push ( "'" + key + "': " + type ) ; } hash . values . push ( "'" + key + "': (" + value + ")" ) ; }


Input: the params and contexts arguments are passed in arrays to fill in [CODESPLIT] function ( paramSize , params , useRegister ) { var options = '{' + this . setupOptions ( paramSize , params ) . join ( ',' ) + '}' ; if ( useRegister ) { this . useRegister ( 'options' ) ; params . push ( 'options' ) ; return 'options=' + options ; } else { params . push ( options ) ; return '' ; } }


Input: Listen for data changes so we can keep track of the current canvas size . [CODESPLIT] function ( msg ) { _canvasWidth = msg . data . config . size . canvasWidth ; _canvasHeight = msg . data . config . size . canvasHeight ; }


Input: -------------------------------------------------------------------------------------------- [CODESPLIT] function ( ) { var scope = this ; THREE . Geometry . call ( this ) ; v ( 5 , 0 , 0 ) ; v ( - 5 , - 2 , 1 ) ; v ( - 5 , 0 , 0 ) ; v ( - 5 , - 2 , - 1 ) ; v ( 0 , 2 , - 6 ) ; v ( 0 , 2 , 6 ) ; v ( 2 , 0 , 0 ) ; v ( - 3 , 0 , 0 ) ; f3 ( 0 , 2 , 1 ) ; f3 ( 4 , 7 , 6 ) ; f3 ( 5 , 6 , 7 ) ; this . computeCentroids ( ) ; this . computeFaceNormals ( ) ; function v ( x , y , z ) { scope . vertices . push ( new THREE . Vector3 ( x , y , z ) ) ; } function f3 ( a , b , c ) { scope . faces . push ( new THREE . Face3 ( a , b , c ) ) ; } }


Input: Based on http : // www . openprocessing . org / visuals / ?visualID = 6910 [CODESPLIT] function ( ) { var vector = new THREE . Vector3 ( ) , _acceleration , _width = 500 , _height = 500 , _depth = 200 , _goal , _neighborhoodRadius = 100 , _maxSpeed = 4 , _maxSteerForce = 0.1 , _avoidWalls = false ; this . position = new THREE . Vector3 ( ) ; this . velocity = new THREE . Vector3 ( ) ; _acceleration = new THREE . Vector3 ( ) ; this . setGoal = function ( target ) { _goal = target ; } ; this . setAvoidWalls = function ( value ) { _avoidWalls = value ; } ; this . setWorldSize = function ( width , height , depth ) { _width = width ; _height = height ; _depth = depth ; } ; this . run = function ( boids ) { if ( _avoidWalls ) { vector . set ( - _width , this . position . y , this . position . z ) ; vector = this . avoid ( vector ) ; vector . multiplyScalar ( 5 ) ; _acceleration . add ( vector ) ; vector . set ( _width , this . position . y , this . position . z ) ; vector = this . avoid ( vector ) ; vector . multiplyScalar ( 5 ) ; _acceleration . add ( vector ) ; vector . set ( this . position . x , - _height , this . position . z ) ; vector = this . avoid ( vector ) ; vector . multiplyScalar ( 5 ) ; _acceleration . add ( vector ) ; vector . set ( this . position . x , _height , this . position . z ) ; vector = this . avoid ( vector ) ; vector . multiplyScalar ( 5 ) ; _acceleration . add ( vector ) ; vector . set ( this . position . x , this . position . y , - _depth ) ; vector = this . avoid ( vector ) ; vector . multiplyScalar ( 5 ) ; _acceleration . add ( vector ) ; vector . set ( this . position . x , this . position . y , _depth ) ; vector = this . avoid ( vector ) ; vector . multiplyScalar ( 5 ) ; _acceleration . add ( vector ) ; } if ( Math . random ( ) > 0.5 ) { this . flock ( boids ) ; } this . move ( ) ; } this . flock = function ( boids ) { if ( _goal ) { _acceleration . add ( this . reach ( _goal , 0.005 ) ) ; } _acceleration . add ( this . alignment ( boids ) ) ; _acceleration . add ( this . cohesion ( boids ) ) ; _acceleration . add ( this . separation ( boids ) ) ; } this . move = function ( ) { this . velocity . add ( _acceleration ) ; var l = this . velocity . length ( ) ; if ( l > _maxSpeed ) { this . velocity . divideScalar ( l / _maxSpeed ) ; } this . position . add ( this . velocity ) ; _acceleration . set ( 0 , 0 , 0 ) ; } this . checkBounds = function ( ) { if ( this . position . x > _width ) this . position . x = - _width ; if ( this . position . x < - _width ) this . position . x = _width ; if ( this . position . y > _height ) this . position . y = - _height ; if ( this . position . y < - _height ) this . position . y = _height ; if ( this . position . z > _depth ) this . position . z = - _depth ; if ( this . position . z < - _depth ) this . position . z = _depth ; } this . avoid = function ( target ) { var steer = new THREE . Vector3 ( ) ; steer . copy ( this . position ) ; steer . sub ( target ) ; steer . multiplyScalar ( 1 / this . position . distanceToSquared ( target ) ) ; return steer ; } this . repulse = function ( target ) { var distance = this . position . distanceTo ( target ) ; if ( distance < 150 ) { var steer = new THREE . Vector3 ( ) ; steer . subVectors ( this . position , target ) ; steer . multiplyScalar ( 0.5 / distance ) ; _acceleration . add ( steer ) ; } } this . reach = function ( target , amount ) { var steer = new THREE . Vector3 ( ) ; steer . subVectors ( target , this . position ) ; steer . multiplyScalar ( amount ) ; return steer ; } this . alignment = function ( boids ) { var boid , velSum = new THREE . Vector3 ( ) , count = 0 ; for ( var i = 0 , il = boids . length ; i < il ; i ++ ) { if ( Math . random ( ) > 0.6 ) continue ; boid = boids [ i ] ; distance = boid . position . distanceTo ( this . position ) ; if ( distance > 0 && distance <= _neighborhoodRadius ) { velSum . add ( boid . velocity ) ; count ++ ; } } if ( count > 0 ) { velSum . divideScalar ( count ) ; var l = velSum . length ( ) ; if ( l > _maxSteerForce ) { velSum . divideScalar ( l / _maxSteerForce ) ; } } return velSum ; } this . cohesion = function ( boids ) { var boid , distance , posSum = new THREE . Vector3 ( ) , steer = new THREE . Vector3 ( ) , count = 0 ; for ( var i = 0 , il = boids . length ; i < il ; i ++ ) { if ( Math . random ( ) > 0.6 ) continue ; boid = boids [ i ] ; distance = boid . position . distanceTo ( this . position ) ; if ( distance > 0 && distance <= _neighborhoodRadius ) { posSum . add ( boid . position ) ; count ++ ; } } if ( count > 0 ) { posSum . divideScalar ( count ) ; } steer . subVectors ( posSum , this . position ) ; var l = steer . length ( ) ; if ( l > _maxSteerForce ) { steer . divideScalar ( l / _maxSteerForce ) ; } return steer ; } this . separation = function ( boids ) { var boid , distance , posSum = new THREE . Vector3 ( ) , repulse = new THREE . Vector3 ( ) ; for ( var i = 0 , il = boids . length ; i < il ; i ++ ) { if ( Math . random ( ) > 0.6 ) continue ; boid = boids [ i ] ; distance = boid . position . distanceTo ( this . position ) ; if ( distance > 0 && distance <= _neighborhoodRadius ) { repulse . subVectors ( this . position , boid . position ) ; repulse . normalize ( ) ; repulse . divideScalar ( distance ) ; posSum . add ( repulse ) ; } } return posSum ; } }


Input: a bit fussy but unavoidable . Whenever a page changes we need to re - draw the pies IFF ( if and only if ) the initial page load wasn t the about page [CODESPLIT] function ( msg ) { if ( ! _firstPageLoaded ) { _firstPage = msg . data . page ; _firstPageLoaded = true ; if ( _firstPage === "about" ) { setTimeout ( function ( ) { _renderContent ( ) ; var width = $ ( window ) . width ( ) ; var breakPointIndex = null ; for ( var i = 0 ; i < C . OTHER . BREAKPOINTS . length ; i ++ ) { if ( width >= C . OTHER . BREAKPOINTS [ i ] ) { breakPointIndex = i ; } } if ( breakPointIndex === null ) { _handleViewport ( "small" ) ; } } , 10 ) ; } return ; } if ( msg . data . page === "about" ) { if ( ! _isRendered ) { _renderContent ( ) ; } $ ( "#aboutPageSlides" ) . slidesjs ( "refresh" ) ; } }


Input: bah! God this plugin sucks . Doesn t even pass in the slide number we re going TO . [CODESPLIT] function ( number ) { switch ( number ) { case 1 : _demoPie2 . redraw ( ) ; _demoPie3 . redraw ( ) ; break ; case 2 : _demoPie1 . redraw ( ) ; _demoPie3 . redraw ( ) ; break ; case 3 : _demoPie1 . redraw ( ) ; _demoPie2 . redraw ( ) ; break ; } }


Input: The first step of the build process . This sets various settings in the main grunt config for the current build environment . These govern how the subsequent tasks behave . [CODESPLIT] function ( ) { config . template . indexFile . options . data . C = _CONSTANTS . DEV ; config . template . indexFile . options . data . D3PIE_VERSION = packageFile . version ; config . template . devRequireConfig . options . data . handlebarsLib = _CONSTANTS . DEV . HANDLEBARS_LIB ; config . template . devRequireConfig . options . data . baseUrl = _CONSTANTS . DEV . BASE_URL ; var lines = [ ] ; for ( var i in _requireJSModulePaths ) { var file = _requireJSModulePaths [ i ] . replace ( / \.js$ / , "" ) ; lines . push ( '\t\t"' + i + '": "' + file + '"' ) ; } config . template . devRequireConfig . options . data . moduleStr = lines . join ( ",\n" ) ; config . template . constants . options . data . VERSION = packageFile . version ; config . template . constants . options . data . MINIMIZED = _CONSTANTS . DEV . MINIMIZED ; config . template . constants . options . data . DEBUG = _CONSTANTS . DEV . DEBUG ; }


Input: Our initialization function . Called on page load . [CODESPLIT] function ( ) { mediator . register ( _MODULE_ID ) ; var subscriptions = { } ; subscriptions [ C . EVENT . DEMO_PIE . SEND_DATA ] = _onSelectTab ; mediator . subscribe ( _MODULE_ID , subscriptions ) ; }


Input: yikes . The reason for all this hideousness is that we want to construct the * smallest * config object that we can . So each field needs to be examined separately . I looked into object diffing scripts but honestly there was too much custom stuff needed to be done with many properties - ensuring they re the right types etc . This is prime real estate for later refactoring but right now it s near the end of the project and I want this thing out the door ... don t judge me . ; - ) [CODESPLIT] function ( allSettings ) { var finalObj = { } ; // header title var headerTitleTextDiff = allSettings . header . title . text != defaultSettings . header . title . text ; var headerTitleColorDiff = allSettings . header . title . color != defaultSettings . header . title . color ; var headerTitleFontSizeDiff = allSettings . header . title . fontSize != defaultSettings . header . title . fontSize ; var headerTitleFontDiff = allSettings . header . title . font != defaultSettings . header . title . font ; if ( headerTitleTextDiff || headerTitleColorDiff || headerTitleFontSizeDiff || headerTitleFontDiff ) { finalObj . header = { title : { } } ; if ( headerTitleTextDiff ) { finalObj . header . title . text = allSettings . header . title . text ; } if ( headerTitleColorDiff ) { finalObj . header . title . color = allSettings . header . title . color ; } if ( headerTitleFontSizeDiff ) { finalObj . header . title . fontSize = parseInt ( allSettings . header . title . fontSize , 10 ) ; } if ( headerTitleFontDiff ) { finalObj . header . title . font = allSettings . header . title . font ; } } // header subtitle var headerSubtitleTextDiff = allSettings . header . subtitle . text != defaultSettings . header . subtitle . text ; var headerSubtitleColorDiff = allSettings . header . subtitle . color != defaultSettings . header . subtitle . color ; var headerSubtitleFontSizeDiff = allSettings . header . subtitle . fontSize != defaultSettings . header . subtitle . fontSize ; var headerSubtitleFontDiff = allSettings . header . subtitle . font != defaultSettings . header . subtitle . font ; if ( headerSubtitleTextDiff || headerSubtitleColorDiff || headerSubtitleFontSizeDiff || headerSubtitleFontDiff ) { if ( ! finalObj . hasOwnProperty ( "header" ) ) { finalObj . header = { } ; } finalObj . header . subtitle = { } ; if ( headerSubtitleTextDiff ) { finalObj . header . subtitle . text = allSettings . header . subtitle . text ; } if ( headerSubtitleColorDiff ) { finalObj . header . subtitle . color = allSettings . header . subtitle . color ; } if ( headerSubtitleFontSizeDiff ) { finalObj . header . subtitle . fontSize = parseInt ( allSettings . header . subtitle . fontSize , 10 ) ; } if ( headerSubtitleFontDiff ) { finalObj . header . subtitle . font = allSettings . header . subtitle . font ; } } if ( allSettings . header . location != defaultSettings . header . location ) { if ( ! finalObj . hasOwnProperty ( "header" ) ) { finalObj . header = { } ; } finalObj . header . location = allSettings . header . location ; } if ( allSettings . header . titleSubtitlePadding != defaultSettings . header . titleSubtitlePadding ) { if ( ! finalObj . hasOwnProperty ( "header" ) ) { finalObj . header = { } ; } finalObj . header . titleSubtitlePadding = parseInt ( allSettings . header . titleSubtitlePadding , 10 ) ; } // footer var footerTextDiff = allSettings . footer . text != defaultSettings . footer . text ; var footerColorDiff = allSettings . footer . color != defaultSettings . footer . color ; var footerFontSizeDiff = allSettings . footer . fontSize != defaultSettings . footer . fontSize ; var footerFontDiff = allSettings . footer . font != defaultSettings . footer . font ; var footerLocationDiff = allSettings . footer . font != defaultSettings . footer . location ; if ( footerTextDiff || footerColorDiff || footerFontSizeDiff || footerFontDiff ) { finalObj . footer = { } ; if ( footerTextDiff ) { finalObj . footer . text = allSettings . footer . text ; } if ( footerColorDiff ) { finalObj . footer . color = allSettings . footer . color ; } if ( footerFontSizeDiff ) { finalObj . footer . fontSize = parseInt ( allSettings . footer . fontSize , 10 ) ; } if ( footerFontDiff ) { finalObj . footer . font = allSettings . footer . font ; } if ( footerLocationDiff ) { finalObj . footer . location = allSettings . footer . location ; } } // size var canvasHeightDiff = allSettings . size . canvasHeight != defaultSettings . size . canvasHeight ; var canvasWidthDiff = allSettings . size . canvasWidth != defaultSettings . size . canvasWidth ; var pieInnerRadiusDiff = allSettings . size . pieInnerRadius != defaultSettings . size . pieInnerRadius ; var pieOuterRadiusDiff = allSettings . size . pieOuterRadius != defaultSettings . size . pieOuterRadius ; if ( canvasHeightDiff || canvasWidthDiff || pieInnerRadiusDiff || pieOuterRadiusDiff ) { finalObj . size = { } ; if ( canvasHeightDiff ) { finalObj . size . canvasHeight = parseFloat ( allSettings . size . canvasHeight , 10 ) ; } if ( canvasWidthDiff ) { finalObj . size . canvasWidth = parseFloat ( allSettings . size . canvasWidth , 10 ) ; } if ( pieInnerRadiusDiff ) { finalObj . size . pieInnerRadius = allSettings . size . pieInnerRadius ; } if ( pieOuterRadiusDiff ) { finalObj . size . pieOuterRadius = allSettings . size . pieOuterRadius ; } } // data finalObj . data = { } ; if ( allSettings . data . sortOrder != defaultSettings . data . sortOrder ) { finalObj . data . sortOrder = allSettings . data . sortOrder ; } var smallSegmentGroupingEnabledDiff = allSettings . data . smallSegmentGrouping . enabled != defaultSettings . data . smallSegmentGrouping . enabled ; if ( smallSegmentGroupingEnabledDiff ) { finalObj . data . smallSegmentGrouping = { } ; finalObj . data . smallSegmentGrouping . enabled = allSettings . data . smallSegmentGrouping . enabled ; var smallSegmentGroupingValDiff = allSettings . data . smallSegmentGrouping . value != defaultSettings . data . smallSegmentGrouping . value ; var smallSegmentGroupingValTypeDiff = allSettings . data . smallSegmentGrouping . valueType != defaultSettings . data . smallSegmentGrouping . valueType ; var smallSegmentGroupingLabelDiff = allSettings . data . smallSegmentGrouping . label != defaultSettings . data . smallSegmentGrouping . label ; var smallSegmentGroupingColorDiff = allSettings . data . smallSegmentGrouping . color != defaultSettings . data . smallSegmentGrouping . color ; if ( smallSegmentGroupingValDiff ) { finalObj . data . smallSegmentGrouping . value = allSettings . data . smallSegmentGrouping . value ; } if ( smallSegmentGroupingValTypeDiff ) { finalObj . data . smallSegmentGrouping . valueType = allSettings . data . smallSegmentGrouping . valueType ; } if ( smallSegmentGroupingLabelDiff ) { finalObj . data . smallSegmentGrouping . label = allSettings . data . smallSegmentGrouping . label ; } if ( smallSegmentGroupingColorDiff ) { finalObj . data . smallSegmentGrouping . color = allSettings . data . smallSegmentGrouping . color ; } } finalObj . data . content = allSettings . data . content ; // outer labels var outerLabelFormatDiff = allSettings . labels . outer . format != defaultSettings . labels . outer . format ; var outerLabelHideDiff = allSettings . labels . outer . hideWhenLessThanPercentage != defaultSettings . labels . outer . hideWhenLessThanPercentage ; var outerLabelPieDistDiff = allSettings . labels . outer . pieDistance != defaultSettings . labels . outer . pieDistance ; if ( outerLabelFormatDiff || outerLabelHideDiff || outerLabelPieDistDiff ) { finalObj . labels = { outer : { } } ; if ( outerLabelFormatDiff ) { finalObj . labels . outer . format = allSettings . labels . outer . format ; } if ( outerLabelHideDiff ) { finalObj . labels . outer . hideWhenLessThanPercentage = parseFloat ( allSettings . labels . outer . hideWhenLessThanPercentage ) ; } if ( outerLabelPieDistDiff ) { finalObj . labels . outer . pieDistance = allSettings . labels . outer . pieDistance ; } } var innerLabelFormatDiff = allSettings . labels . inner . format != defaultSettings . labels . inner . format ; var innerLabelHideDiff = allSettings . labels . inner . hideWhenLessThanPercentage != defaultSettings . labels . inner . hideWhenLessThanPercentage ; if ( innerLabelFormatDiff || innerLabelHideDiff ) { if ( ! finalObj . hasOwnProperty ( "labels" ) ) { finalObj . labels = { } ; } finalObj . labels . inner = { } ; if ( innerLabelFormatDiff ) { finalObj . labels . inner . format = allSettings . labels . inner . format ; } if ( innerLabelHideDiff ) { finalObj . labels . inner . hideWhenLessThanPercentage = parseFloat ( allSettings . labels . inner . hideWhenLessThanPercentage ) ; } } var mainLabelColorDiff = allSettings . labels . mainLabel . color != defaultSettings . labels . mainLabel . color ; var mainLabelFontDiff = allSettings . labels . mainLabel . font != defaultSettings . labels . mainLabel . font ; var mainLabelFontSizeDiff = allSettings . labels . mainLabel . fontSize != defaultSettings . labels . mainLabel . fontSize ; if ( mainLabelColorDiff || mainLabelFontDiff || mainLabelFontSizeDiff ) { if ( ! finalObj . hasOwnProperty ( "labels" ) ) { finalObj . labels = { } ; } finalObj . labels . mainLabel = { } ; if ( mainLabelColorDiff ) { finalObj . labels . mainLabel . color = allSettings . labels . mainLabel . color ; } if ( mainLabelFontDiff ) { finalObj . labels . mainLabel . font = allSettings . labels . mainLabel . font ; } if ( mainLabelFontSizeDiff ) { finalObj . labels . mainLabel . fontSize = parseInt ( allSettings . labels . mainLabel . fontSize , 10 ) ; } } var percentageColorDiff = allSettings . labels . percentage . color != defaultSettings . labels . percentage . color ; var percentageFontDiff = allSettings . labels . percentage . font != defaultSettings . labels . percentage . font ; var percentageFontSizeDiff = allSettings . labels . percentage . fontSize != defaultSettings . labels . percentage . fontSize ; var percentageDecimalDiff = allSettings . labels . percentage . decimalPlaces != defaultSettings . labels . percentage . decimalPlaces ; if ( percentageColorDiff || percentageFontDiff || percentageFontSizeDiff || percentageDecimalDiff ) { if ( ! finalObj . hasOwnProperty ( "labels" ) ) { finalObj . labels = { } ; } finalObj . labels . percentage = { } ; if ( percentageColorDiff ) { finalObj . labels . percentage . color = allSettings . labels . percentage . color ; } if ( percentageFontDiff ) { finalObj . labels . percentage . font = allSettings . labels . percentage . font ; } if ( percentageFontSizeDiff ) { finalObj . labels . percentage . fontSize = parseInt ( allSettings . labels . percentage . fontSize , 10 ) ; } if ( percentageColorDiff ) { finalObj . labels . percentage . decimalPlaces = parseInt ( allSettings . labels . percentage . decimalPlaces , 10 ) ; } } var valueColorDiff = allSettings . labels . value . color != defaultSettings . labels . value . color ; var valueFontDiff = allSettings . labels . value . font != defaultSettings . labels . value . font ; var valueFontSizeDiff = allSettings . labels . value . fontSize != defaultSettings . labels . value . fontSize ; if ( valueColorDiff || valueFontDiff || valueFontSizeDiff ) { if ( ! finalObj . hasOwnProperty ( "labels" ) ) { finalObj . labels = { } ; } finalObj . labels . value = { } ; if ( valueColorDiff ) { finalObj . labels . value . color = allSettings . labels . value . color ; } if ( valueFontDiff ) { finalObj . labels . value . font = allSettings . labels . value . font ; } if ( valueFontSizeDiff ) { finalObj . labels . value . fontSize = parseInt ( allSettings . labels . value . fontSize , 10 ) ; } } // label lines var labelLinesDiff = allSettings . labels . lines . enabled != defaultSettings . labels . lines . enabled ; if ( ! labelLinesDiff ) { if ( ! finalObj . hasOwnProperty ( "labels" ) ) { finalObj . labels = { } ; } finalObj . labels . lines = { enabled : allSettings . labels . lines . enabled } ; if ( allSettings . labels . lines . style != defaultSettings . labels . lines . style ) { finalObj . labels . lines . style = allSettings . labels . lines . style ; } if ( allSettings . labels . lines . color != defaultSettings . labels . lines . color ) { finalObj . labels . lines . color = allSettings . labels . lines . color ; } } // label truncation var labelTruncationDiff = allSettings . labels . truncation . enabled != defaultSettings . labels . truncation . enabled ; if ( labelTruncationDiff ) { if ( ! finalObj . hasOwnProperty ( "labels" ) ) { finalObj . labels = { } ; } finalObj . labels . truncation = { enabled : allSettings . labels . truncation . enabled } ; if ( allSettings . labels . truncation . truncateLength != defaultSettings . labels . truncation . truncateLength ) { finalObj . labels . truncation . truncateLength = allSettings . labels . truncation . truncateLength ; } } // tooltips var tooltipsDiff = allSettings . tooltips . enabled != defaultSettings . tooltips . enabled ; if ( tooltipsDiff ) { finalObj . tooltips = { enabled : allSettings . tooltips . enabled , type : "placeholder" , string : allSettings . tooltips . string } ; if ( allSettings . tooltips . styles . fadeInSpeed !== defaultSettings . tooltips . styles . fadeInSpeed ) { if ( ! finalObj . tooltips . hasOwnProperty ( "styles" ) ) { finalObj . tooltips . styles = { } ; } finalObj . tooltips . styles . fadeInSpeed = allSettings . tooltips . styles . fadeInSpeed ; } if ( allSettings . tooltips . styles . backgroundColor !== defaultSettings . tooltips . styles . backgroundColor ) { if ( ! finalObj . tooltips . hasOwnProperty ( "styles" ) ) { finalObj . tooltips . styles = { } ; } finalObj . tooltips . styles . backgroundColor = allSettings . tooltips . styles . backgroundColor ; } if ( allSettings . tooltips . styles . backgroundOpacity !== defaultSettings . tooltips . styles . backgroundOpacity ) { if ( ! finalObj . tooltips . hasOwnProperty ( "styles" ) ) { finalObj . tooltips . styles = { } ; } finalObj . tooltips . styles . backgroundOpacity = allSettings . tooltips . styles . backgroundOpacity ; } if ( allSettings . tooltips . styles . color !== defaultSettings . tooltips . styles . color ) { if ( ! finalObj . tooltips . hasOwnProperty ( "styles" ) ) { finalObj . tooltips . styles = { } ; } finalObj . tooltips . styles . color = allSettings . tooltips . styles . color ; } if ( allSettings . tooltips . styles . borderRadius !== defaultSettings . tooltips . styles . borderRadius ) { if ( ! finalObj . tooltips . hasOwnProperty ( "styles" ) ) { finalObj . tooltips . styles = { } ; } finalObj . tooltips . styles . borderRadius = allSettings . tooltips . styles . borderRadius ; } if ( allSettings . tooltips . styles . font !== defaultSettings . tooltips . styles . font ) { if ( ! finalObj . tooltips . hasOwnProperty ( "styles" ) ) { finalObj . tooltips . styles = { } ; } finalObj . tooltips . styles . font = allSettings . tooltips . styles . font ; } if ( allSettings . tooltips . styles . fontSize !== defaultSettings . tooltips . styles . fontSize ) { if ( ! finalObj . tooltips . hasOwnProperty ( "styles" ) ) { finalObj . tooltips . styles = { } ; } finalObj . tooltips . styles . fontSize = allSettings . tooltips . styles . fontSize ; } if ( allSettings . tooltips . styles . padding !== defaultSettings . tooltips . styles . padding ) { if ( ! finalObj . tooltips . hasOwnProperty ( "styles" ) ) { finalObj . tooltips . styles = { } ; } finalObj . tooltips . styles . padding = allSettings . tooltips . styles . padding ; } } // effects var effectsLoadDiff = allSettings . effects . load . effect != defaultSettings . effects . load . effect ; var effectsSpeedDiff = allSettings . effects . load . speed != defaultSettings . effects . load . speed ; if ( effectsLoadDiff || effectsSpeedDiff ) { if ( ! finalObj . hasOwnProperty ( "effects" ) ) { finalObj . effects = { } ; } finalObj . effects . load = { } ; if ( effectsLoadDiff ) { finalObj . effects . load . effect = allSettings . effects . load . effect ; } if ( effectsSpeedDiff ) { finalObj . effects . load . speed = parseInt ( allSettings . effects . load . speed , 10 ) ; } } var effectsPullOutDiff = allSettings . effects . pullOutSegmentOnClick . effect != defaultSettings . effects . pullOutSegmentOnClick . effect ; var effectsPullOutSpeedDiff = allSettings . effects . pullOutSegmentOnClick . speed != defaultSettings . effects . pullOutSegmentOnClick . speed ; var effectsPullOutSizeDiff = allSettings . effects . pullOutSegmentOnClick . size != defaultSettings . effects . pullOutSegmentOnClick . size ; if ( effectsPullOutDiff || effectsPullOutSpeedDiff || effectsPullOutSizeDiff ) { if ( ! finalObj . hasOwnProperty ( "effects" ) ) { finalObj . effects = { } ; } finalObj . effects . pullOutSegmentOnClick = { } ; if ( effectsPullOutDiff ) { finalObj . effects . pullOutSegmentOnClick . effect = allSettings . effects . pullOutSegmentOnClick . effect ; } if ( effectsPullOutSpeedDiff ) { finalObj . effects . pullOutSegmentOnClick . speed = parseInt ( allSettings . effects . pullOutSegmentOnClick . speed , 10 ) ; } if ( effectsPullOutSizeDiff ) { finalObj . effects . pullOutSegmentOnClick . size = parseInt ( allSettings . effects . pullOutSegmentOnClick . size , 10 ) ; } } if ( allSettings . effects . highlightSegmentOnMouseover != defaultSettings . effects . highlightSegmentOnMouseover ) { if ( ! finalObj . hasOwnProperty ( "effects" ) ) { finalObj . effects = { } ; } finalObj . effects . highlightSegmentOnMouseover = allSettings . effects . highlightSegmentOnMouseover ; if ( allSettings . effects . highlightLuminosity != defaultSettings . effects . highlightLuminosity ) { finalObj . effects . highlightLuminosity = parseFloat ( allSettings . effects . highlightLuminosity , 10 ) ; } } // misc var miscColorBgDiff = allSettings . misc . colors . background != defaultSettings . misc . colors . background ; // N.B. It's not possible in the generator to generate the misc.colors.segments property. This is missing on purpose. var miscSegmentStrokeDiff = allSettings . misc . colors . segmentStroke != defaultSettings . misc . colors . segmentStroke ; if ( miscColorBgDiff || miscSegmentStrokeDiff ) { if ( ! finalObj . hasOwnProperty ( "misc" ) ) { finalObj . misc = { } ; } finalObj . misc . colors = { } ; if ( miscColorBgDiff ) { finalObj . misc . colors . background = allSettings . misc . colors . background ; } if ( miscSegmentStrokeDiff ) { finalObj . misc . colors . segmentStroke = allSettings . misc . colors . segmentStroke ; } } var gradientEnabledDiff = allSettings . misc . gradient . enabled != defaultSettings . misc . gradient . enabled ; if ( gradientEnabledDiff ) { if ( ! finalObj . hasOwnProperty ( "misc" ) ) { finalObj . misc = { } ; } finalObj . misc . gradient = { enabled : true } ; var gradientPercentageDiff = allSettings . misc . gradient . percentage != defaultSettings . misc . gradient . percentage ; var gradientColorDiff = allSettings . misc . gradient . color != defaultSettings . misc . gradient . color ; if ( gradientPercentageDiff ) { finalObj . misc . gradient . percentage = parseInt ( allSettings . misc . gradient . percentage , 10 ) ; } if ( gradientColorDiff ) { finalObj . misc . gradient . color = allSettings . misc . gradient . color ; } } var canvasPaddingTopDiff = allSettings . misc . canvasPadding . top != defaultSettings . misc . canvasPadding . top ; var canvasPaddingRightDiff = allSettings . misc . canvasPadding . right != defaultSettings . misc . canvasPadding . right ; var canvasPaddingBottomDiff = allSettings . misc . canvasPadding . bottom != defaultSettings . misc . canvasPadding . bottom ; var canvasPaddingLeftDiff = allSettings . misc . canvasPadding . left != defaultSettings . misc . canvasPadding . left ; if ( canvasPaddingTopDiff || canvasPaddingRightDiff || canvasPaddingBottomDiff || canvasPaddingLeftDiff ) { if ( ! finalObj . hasOwnProperty ( "misc" ) ) { finalObj . misc = { } ; } finalObj . misc . canvasPadding = { } ; if ( canvasPaddingTopDiff ) { finalObj . misc . canvasPadding . top = parseInt ( allSettings . misc . canvasPadding . top , 10 ) ; } if ( canvasPaddingRightDiff ) { finalObj . misc . canvasPadding . right = parseInt ( allSettings . misc . canvasPadding . right , 10 ) ; } if ( canvasPaddingBottomDiff ) { finalObj . misc . canvasPadding . bottom = parseInt ( allSettings . misc . canvasPadding . bottom , 10 ) ; } if ( canvasPaddingTopDiff ) { finalObj . misc . canvasPadding . left = parseInt ( allSettings . misc . canvasPadding . left , 10 ) ; } } var pieCenterOffsetXDiff = allSettings . misc . pieCenterOffset . x != defaultSettings . misc . pieCenterOffset . x ; var pieCenterOffsetYDiff = allSettings . misc . pieCenterOffset . y != defaultSettings . misc . pieCenterOffset . y ; if ( pieCenterOffsetXDiff || pieCenterOffsetYDiff ) { if ( ! finalObj . hasOwnProperty ( "misc" ) ) { finalObj . misc = { } ; } finalObj . misc . pieCenterOffset = { } ; if ( pieCenterOffsetXDiff ) { finalObj . misc . pieCenterOffset . x = parseInt ( allSettings . misc . pieCenterOffset . x , 10 ) ; } if ( pieCenterOffsetYDiff ) { finalObj . misc . pieCenterOffset . y = parseInt ( allSettings . misc . pieCenterOffset . y , 10 ) ; } } var miscPrefixDiff = allSettings . misc . cssPrefix != defaultSettings . misc . cssPrefix ; if ( miscPrefixDiff ) { if ( ! finalObj . hasOwnProperty ( "misc" ) ) { finalObj . misc = { } ; } finalObj . misc . cssPrefix = allSettings . misc . cssPrefix ; } var callbackOnloadDiff = allSettings . callbacks . onload != defaultSettings . callbacks . onload ; var callbackOnmouseoverDiff = allSettings . callbacks . onMouseoverSegment != defaultSettings . callbacks . onMouseoverSegment ; var callbackOnmouseoutDiff = allSettings . callbacks . onMouseoutSegment != defaultSettings . callbacks . onMouseoutSegment ; var callbackOnclickDiff = allSettings . callbacks . onClickSegment != defaultSettings . callbacks . onClickSegment ; if ( callbackOnloadDiff || callbackOnmouseoverDiff || callbackOnmouseoutDiff || callbackOnclickDiff ) { finalObj . callbacks = { } ; if ( callbackOnloadDiff ) { finalObj . callbacks . onload = allSettings . callbacks . onload ; } if ( callbackOnloadDiff ) { finalObj . callbacks . onMouseoverSegment = allSettings . callbacks . onMouseoverSegment ; } if ( callbackOnloadDiff ) { finalObj . callbacks . onMouseoutSegment = allSettings . callbacks . onMouseoutSegment ; } if ( callbackOnloadDiff ) { finalObj . callbacks . onClickSegment = allSettings . callbacks . onClickSegment ; } } return finalObj ; }


Input: Our initialization function . Called on page load . [CODESPLIT] function ( ) { _addTabEventHandlers ( ) ; var config = { hideMainContent : false } ; if ( document . location . hash === "#generator-result" ) { config = { hideMainContent : true } } $ ( "#generator" ) . html ( generatorPageTemplate ( config ) ) ; // now fade in the three sections: nav, main content & footer row $ ( "#generatorTabs,#mainContent,#footerRow" ) . hide ( ) . removeClass ( "hidden" ) . fadeIn ( 400 ) ; // always initialize the sidebar with whatever's in the selected example (always first item right now) var index = pageHelper . getDemoPieChartIndex ( EXAMPLE_PIES ) ; _loadDemoPie ( EXAMPLE_PIES [ index ] ) ; // focus on the title field, just to be nice $ ( "#pieTitle" ) . focus ( ) ; var subscriptions = { } ; subscriptions [ C . EVENT . DEMO_PIE . LOAD ] = _onRequestLoadDemoPie ; subscriptions [ C . EVENT . DEMO_PIE . RENDER . NO_ANIMATION ] = _renderWithNoAnimation ; subscriptions [ C . EVENT . DEMO_PIE . RENDER . WITH_ANIMATION ] = _renderWithAnimation ; subscriptions [ C . EVENT . DEMO_PIE . RENDER . UPDATE_PROP ] = _updateProperty ; subscriptions [ C . EVENT . DEMO_PIE . SELECT_SEGMENT ] = _selectPieSegment ; subscriptions [ C . EVENT . PAGE . LOAD ] = _onPageSelected ; subscriptions [ C . EVENT . PAGE . RESIZE ] = _onPageResize ; mediator . subscribe ( _MODULE_ID , subscriptions ) ; }


Input: Parses the generator fields and get the latest values . [CODESPLIT] function ( ) { return { header : titleTab . getTabData ( ) , footer : footerTab . getTabData ( ) , size : sizeTab . getTabData ( ) , data : dataTab . getTabData ( ) , labels : labelsTab . getTabData ( ) , tooltips : tooltipsTab . getTabData ( ) , effects : effectsTab . getTabData ( ) , callbacks : eventsTab . getTabData ( ) , misc : miscTab . getTabData ( ) } ; }


Input: Bloody awful function! This is called whenever the page / tab is changed . It got way out of control . Nav should be moved to a single top - level area . [CODESPLIT] function ( msg ) { if ( ! _firstPageLoaded ) { if ( msg . data . pageHash !== "generator-result" ) { _firstPage = msg . data . page ; } _firstPageLoaded = true ; } if ( msg . data . page !== "generator" ) { return ; } var pageHash = msg . data . pageHash ; var tab = ( _currentTab ) ? _currentTab : "generator-start" ; if ( $ . inArray ( pageHash , _tabs ) !== - 1 ) { tab = pageHash ; } if ( pageHash === "generator-result" ) { _sendDemoPieData ( ) ; $ ( "#sidebar,#pieChartDiv" ) . addClass ( "fadeOut" ) ; setTimeout ( function ( ) { $ ( "#sidebar,#pieChartDiv" ) . addClass ( "hidden" ) . removeClass ( "fadeOut" ) ; $ ( "#generator-result" ) . removeClass ( "hidden fadeOut" ) . addClass ( "fadeIn" ) ; } , C . OTHER . PAGE_LOAD_SPEED ) ; } else if ( pageHash === "generator" && tab === "generator-result" ) { // do nothing. This happens when a user's on the generator-result tab, goes to // another page (not tab), then clicks back to the generator tab } else { // if the previous tab was generator-result if ( _currentTab === "generator-result" ) { $ ( "#generator-result" ) . addClass ( "fadeOut" ) ; setTimeout ( function ( ) { $ ( "#generator-result" ) . addClass ( "hidden" ) . removeClass ( "fadeOut" ) ; _renderWithNoAnimation ( ) ; $ ( "#sidebar,#pieChartDiv" ) . removeClass ( "hidden fadeOut" ) . addClass ( "fadeIn" ) ; } , C . OTHER . PAGE_LOAD_SPEED ) ; } } if ( msg . data . pageHash . match ( / pie\d$ / ) ) { var index = pageHelper . getDemoPieChartIndex ( EXAMPLE_PIES ) ; _loadDemoPie ( EXAMPLE_PIES [ index ] ) ; } var $generatorTabs = $ ( "#generatorTabs" ) ; // now show the appropriate tab if ( _currentTab === null ) { $generatorTabs . find ( "a[href=#" + tab + "]" ) . closest ( "li" ) . addClass ( "active" ) ; $ ( "#" + tab ) . removeClass ( "fadeOut hidden" ) . addClass ( "fadeIn" ) ; _renderWithAnimation ( ) ; } else { $generatorTabs . find ( "a[href=#" + _currentTab + "]" ) . closest ( "li" ) . removeClass ( "active" ) ; $generatorTabs . find ( "a[href=#" + tab + "]" ) . closest ( "li" ) . addClass ( "active" ) ; $ ( "#" + _currentTab ) . removeClass ( "hidden fadeIn" ) . addClass ( "fadeOut" ) ; // another klutzy workaround if ( pageHash === "generator" && tab === "generator-result" ) { $ ( "#" + tab ) . removeClass ( "hidden fadeOut" ) ; } else { ( function ( ct ) { setTimeout ( function ( ) { $ ( "#" + ct ) . addClass ( "hidden" ) . removeClass ( "fadeOut" ) ; $ ( "#" + tab ) . removeClass ( "hidden fadeOut" ) . addClass ( "fadeIn" ) ; } , C . OTHER . PAGE_LOAD_SPEED ) ; } ) ( _currentTab ) ; } } _currentTab = tab ; }


Input: Return options . prop if obj . prop is undefined otherwise return obj . prop [CODESPLIT] function getOrDef ( obj , prop ) { return obj [ prop ] === undefined ? options [ prop ] : obj [ prop ] ; }


Input: Process function / object event handler [CODESPLIT] function triggerEvent ( event , $el ) { var handler = options [ 'on' + event ] ; if ( handler ) { if ( $isFunction ( handler ) ) { handler . call ( $el [ 0 ] ) ; } else { if ( handler . addClass ) { $el . addClass ( handler . addClass ) ; } if ( handler . removeClass ) { $el . removeClass ( handler . removeClass ) ; } } } $el . trigger ( 'lazy' + event , [ $el ] ) ; // queue next check as images may be resized after loading of actual file queueCheckLazyElements ( ) ; }


Input: Load visible elements [CODESPLIT] function checkLazyElements ( force ) { if ( ! elements . length ) { return ; } force = force || options . forceLoad ; topLazy = Infinity ; var viewportTop = scrollTop ( ) , viewportHeight = window . innerHeight || docElement . clientHeight , viewportWidth = window . innerWidth || docElement . clientWidth , i , length ; for ( i = 0 , length = elements . length ; i < length ; i ++ ) { var $el = elements [ i ] , el = $el [ 0 ] , objData = $el [ lazyLoadXT ] , removeNode = false , visible = force || $data ( el , dataLazied ) < 0 , topEdge ; // remove items that are not in DOM if ( ! $ . contains ( docElement , el ) ) { removeNode = true ; } else if ( force || ! objData . visibleOnly || el . offsetWidth || el . offsetHeight ) { if ( ! visible ) { var elPos = el . getBoundingClientRect ( ) , edgeX = objData . edgeX , edgeY = objData . edgeY ; topEdge = ( elPos . top + viewportTop - edgeY ) - viewportHeight ; visible = ( topEdge <= viewportTop && elPos . bottom > - edgeY && elPos . left <= viewportWidth + edgeX && elPos . right > - edgeX ) ; } if ( visible ) { $el . on ( load_error , triggerLoadOrError ) ; triggerEvent ( 'show' , $el ) ; var srcAttr = objData . srcAttr , src = $isFunction ( srcAttr ) ? srcAttr ( $el ) : el . getAttribute ( srcAttr ) ; if ( src ) { el . src = src ; } removeNode = true ; } else { if ( topEdge < topLazy ) { topLazy = topEdge ; } } } if ( removeNode ) { $data ( el , dataLazied , 0 ) ; elements . splice ( i -- , 1 ) ; length -- ; } } if ( ! length ) { triggerEvent ( 'complete' , $ ( docElement ) ) ; } }


Input: Queue check of lazy elements because of event e [CODESPLIT] function queueCheckLazyElements ( e ) { if ( ! elements . length ) { return ; } // fast check for scroll event without new visible elements if ( e && e . type === 'scroll' && e . currentTarget === window ) { if ( topLazy >= scrollTop ( ) ) { return ; } } if ( ! waitingMode ) { setTimeout ( timeoutLazyElements , 0 ) ; } waitingMode = 2 ; }