commit/galaxy-central: carlfeberhard: UI, Paired collection creator: refactoring of paired HTML and fixes to draggable partition, add brush selection to unpaired
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7c566a68d2d0/ Changeset: 7c566a68d2d0 User: carlfeberhard Date: 2014-08-26 22:30:46 Summary: UI, Paired collection creator: refactoring of paired HTML and fixes to draggable partition, add brush selection to unpaired Affected #: 6 files diff -r ece8ef90a8289399bf9faca6a3265696da7e0beb -r 7c566a68d2d07375c53006191671dfed04332f55 static/scripts/mvc/collection/paired-collection-creator.js --- a/static/scripts/mvc/collection/paired-collection-creator.js +++ b/static/scripts/mvc/collection/paired-collection-creator.js @@ -3,7 +3,38 @@ "mvc/base-mvc", "utils/localization" ], function( levelshteinDistance, baseMVC, _l ){ -//============================================================================= +/* ============================================================================ +TODO: + + +PROGRAMMATICALLY: +h = Galaxy.currHistoryPanel; h.showSelectors(); h.selectAllDatasets(); _.last( h.actionsPopup.options ).func() + +============================================================================ */ +/** A view for paired datasets in the collections creator. + */ +var PairView = Backbone.View.extend( baseMVC.LoggableMixin ).extend({ + + tagName : 'li', + className : 'dataset paired', + + initialize : function( attributes ){ + this.pair = attributes.pair || {}; + }, + + render : function(){ + this.$el.attr( 'draggable', true ) + .html( _.template([ + '<span class="forward-dataset-name flex-column"><%= pair.forward.name %></span>', + '<span class="pair-name flex-column"><%= pair.name %></span>', + '<span class="reverse-dataset-name flex-column"><%= pair.reverse.name %></span>' + ].join(''), { pair: this.pair })) + .addClass( 'flex-column-container' ); + return this; + } + +}); + /** An interface for building collections of paired datasets. */ var PairedCollectionCreator = Backbone.View.extend( baseMVC.LoggableMixin ).extend({ @@ -12,11 +43,12 @@ /** set up initial options, instance vars, behaviors, and autopair (if set to do so) */ initialize : function( attributes ){ - //console.debug( '-- PairedCollectionCreator:', attributes ); + //this.debug( '-- PairedCollectionCreator:', attributes ); attributes = _.defaults( attributes, { datasets : [], filters : this.DEFAULT_FILTERS, + //automaticallyPair : false, automaticallyPair : true, matchPercentage : 1.0, //matchPercentage : 0.9, @@ -24,7 +56,7 @@ //strategy : 'levenshtein' strategy : 'lcs' }); - //console.debug( 'attributes now:', attributes ); + //this.debug( 'attributes now:', attributes ); /** unordered, original list */ this.initialList = attributes.datasets; @@ -89,7 +121,7 @@ // ------------------------------------------------------------------------ process raw list /** set up main data: cache initialList, sort, and autopair */ _dataSetUp : function(){ - //console.debug( '-- _dataSetUp' ); + //this.debug( '-- _dataSetUp' ); this.paired = []; this.unpaired = []; @@ -110,7 +142,7 @@ /** sort initial list */ _sortInitialList : function(){ - //console.debug( '-- _sortInitialList' ); + //this.debug( '-- _sortInitialList' ); this._sortDatasetList( this.initialList ); //this._printList( this.unpaired ); }, @@ -192,14 +224,14 @@ */ autoPair : function( strategy ){ strategy = strategy || this.strategy; - //console.debug( '-- autoPair', strategy ); + //this.debug( '-- autoPair', strategy ); this.simpleAutoPair(); return this[ strategy ].call( this ); }, /** attempts to pair forward with reverse when names exactly match (after removing filters) */ simpleAutoPair : function(){ - //console.debug( '-- simpleAutoPair' ); + //this.debug( '-- simpleAutoPair' ); // simplified auto pair that moves down unpaired lists *in order*, // removes filters' strings from fwd and rev, // and, if names w/o filters *exactly* match, creates a pair @@ -215,18 +247,18 @@ var fwd = fwdList[ i ]; //TODO: go through the filterFwdFn fwdName = fwd.name.replace( this.filters[0], '' ); - //console.debug( i, 'fwd:', fwdName ); + //this.debug( i, 'fwd:', fwdName ); matchFound = false; for( j=0; j<revList.length; j++ ){ var rev = revList[ j ]; revName = rev.name.replace( this.filters[1], '' ); - //console.debug( '\t ', j, 'rev:', revName ); + //this.debug( '\t ', j, 'rev:', revName ); if( fwd !== rev && fwdName === revName ){ matchFound = true; // if it is a match, keep i at current, pop fwd, pop rev and break - //console.debug( '---->', fwdName, revName ); + //this.debug( '---->', fwdName, revName ); this._pair( fwdList.splice( i, 1 )[0], revList.splice( j, 1 )[0], @@ -237,17 +269,17 @@ } if( !matchFound ){ i += 1; } } - //console.debug( 'remaining Forward:' ); + //this.debug( 'remaining Forward:' ); //this._printList( this.unpairedForward ); - //console.debug( 'remaining Reverse:' ); + //this.debug( 'remaining Reverse:' ); //this._printList( this.unpairedReverse ); - //console.debug( '' ); + //this.debug( '' ); }, /** attempt to autopair using edit distance between forward and reverse (after removing filters) */ autoPairLevenshtein : function(){ //precondition: filters are set, both lists are not empty, and all filenames.length > filters[?].length - //console.debug( '-- autoPairLevenshtein' ); + //this.debug( '-- autoPairLevenshtein' ); var i = 0, j, split = this._splitByFilters(), fwdList = split[0], @@ -259,34 +291,34 @@ var fwd = fwdList[ i ]; //TODO: go through the filterFwdFn fwdName = fwd.name.replace( this.filters[0], '' ); - //console.debug( i, 'fwd:', fwdName ); + //this.debug( i, 'fwd:', fwdName ); bestDist = Number.MAX_VALUE; for( j=0; j<revList.length; j++ ){ var rev = revList[ j ]; revName = rev.name.replace( this.filters[1], '' ); - //console.debug( '\t ', j, 'rev:', revName ); + //this.debug( '\t ', j, 'rev:', revName ); if( fwd !== rev ){ if( fwdName === revName ){ - //console.debug( '\t\t exactmatch:', fwdName, revName ); + //this.debug( '\t\t exactmatch:', fwdName, revName ); bestIndex = j; bestDist = 0; break; } distance = levenshteinDistance( fwdName, revName ); - //console.debug( '\t\t distance:', distance, 'bestDist:', bestDist ); + //this.debug( '\t\t distance:', distance, 'bestDist:', bestDist ); if( distance < bestDist ){ bestIndex = j; bestDist = distance; } } } - //console.debug( '---->', fwd.name, bestIndex, bestDist ); - //console.debug( '---->', fwd.name, revList[ bestIndex ].name, bestDist ); + //this.debug( '---->', fwd.name, bestIndex, bestDist ); + //this.debug( '---->', fwd.name, revList[ bestIndex ].name, bestDist ); var percentage = 1.0 - ( bestDist / ( Math.max( fwdName.length, revName.length ) ) ); - //console.debug( '----> %', percentage * 100 ); + //this.debug( '----> %', percentage * 100 ); if( percentage >= this.matchPercentage ){ this._pair( @@ -301,17 +333,17 @@ i += 1; } } - //console.debug( 'remaining Forward:' ); + //this.debug( 'remaining Forward:' ); //this._printList( this.unpairedForward ); - //console.debug( 'remaining Reverse:' ); + //this.debug( 'remaining Reverse:' ); //this._printList( this.unpairedReverse ); - //console.debug( '' ); + //this.debug( '' ); }, /** attempt to auto pair using common substrings from both front and back (after removing filters) */ autoPairLCSs : function(){ //precondition: filters are set, both lists are not empty - //console.debug( '-- autoPairLCSs' ); + //this.debug( '-- autoPairLCSs' ); var i = 0, j, split = this._splitByFilters(), fwdList = split[0], @@ -319,39 +351,39 @@ fwdName, revName, currMatch, bestIndex, bestMatch; if( !fwdList.length || !revList.length ){ return; } - //console.debug( fwdList, revList ); + //this.debug( fwdList, revList ); while( i<fwdList.length ){ var fwd = fwdList[ i ]; fwdName = fwd.name.replace( this.filters[0], '' ); - //console.debug( i, 'fwd:', fwdName ); + //this.debug( i, 'fwd:', fwdName ); bestMatch = 0; for( j=0; j<revList.length; j++ ){ var rev = revList[ j ]; revName = rev.name.replace( this.filters[1], '' ); - //console.debug( '\t ', j, 'rev:', revName ); + //this.debug( '\t ', j, 'rev:', revName ); if( fwd !== rev ){ if( fwdName === revName ){ - //console.debug( '\t\t exactmatch:', fwdName, revName ); + //this.debug( '\t\t exactmatch:', fwdName, revName ); bestIndex = j; bestMatch = fwdName.length; break; } var match = this._naiveStartingAndEndingLCS( fwdName, revName ); currMatch = match.length; - //console.debug( '\t\t match:', match, 'currMatch:', currMatch, 'bestMatch:', bestMatch ); + //this.debug( '\t\t match:', match, 'currMatch:', currMatch, 'bestMatch:', bestMatch ); if( currMatch > bestMatch ){ bestIndex = j; bestMatch = currMatch; } } } - //console.debug( '---->', i, fwd.name, bestIndex, revList[ bestIndex ].name, bestMatch ); + //this.debug( '---->', i, fwd.name, bestIndex, revList[ bestIndex ].name, bestMatch ); var percentage = bestMatch / ( Math.min( fwdName.length, revName.length ) ); - //console.debug( '----> %', percentage * 100 ); + //this.debug( '----> %', percentage * 100 ); if( percentage >= this.matchPercentage ){ this._pair( @@ -366,11 +398,11 @@ i += 1; } } - //console.debug( 'remaining Forward:' ); + //this.debug( 'remaining Forward:' ); //this._printList( this.unpairedForward ); - //console.debug( 'remaining Reverse:' ); + //this.debug( 'remaining Reverse:' ); //this._printList( this.unpairedReverse ); - //console.debug( '' ); + //this.debug( '' ); }, /** return the concat'd longest common prefix and suffix from two strings */ @@ -406,7 +438,7 @@ _pair : function( fwd, rev, options ){ options = options || {}; //TODO: eventing, options - //console.debug( '_pair:', fwd, rev ); + //this.debug( '_pair:', fwd, rev ); var pair = this._createPair( fwd, rev, options.name ); this.paired.push( pair ); this.unpaired = _.without( this.unpaired, fwd, rev ); @@ -524,7 +556,7 @@ return creator._pairToJSON( pair ); }) }; - //console.debug( JSON.stringify( ajaxData ) ); + //this.debug( JSON.stringify( ajaxData ) ); return jQuery.ajax( url, { type : 'POST', contentType : 'application/json', @@ -535,7 +567,7 @@ creator._ajaxErrHandler( xhr, status, message ); }) .done( function( response, message, xhr ){ - //console.info( 'ok', response, message, xhr ); + //this.info( 'ok', response, message, xhr ); creator.trigger( 'collection:created', response, message, xhr ); if( typeof creator.oncreate === 'function' ){ creator.oncreate.call( this, response, message, xhr ); @@ -545,7 +577,7 @@ /** handle ajax errors with feedback and details to the user (if available) */ _ajaxErrHandler : function( xhr, status, message ){ - console.error( xhr, status, message ); + this.error( xhr, status, message ); var content = _l( 'An error occurred while creating this collection' ); if( xhr ){ if( xhr.readyState === 0 && xhr.status === 0 ){ @@ -563,7 +595,7 @@ // ------------------------------------------------------------------------ rendering /** render the entire interface */ render : function( speed, callback ){ - //console.debug( '-- _render' ); + //this.debug( '-- _render' ); //this.$el.empty().html( PairedCollectionCreator.templates.main() ); this.$el.empty().html( PairedCollectionCreator.templates.main() ); this._renderHeader( speed ); @@ -575,7 +607,7 @@ /** render the header section */ _renderHeader : function( speed, callback ){ - //console.debug( '-- _renderHeader' ); + //this.debug( '-- _renderHeader' ); var $header = this.$( '.header' ).empty().html( PairedCollectionCreator.templates.header() ) .find( '.help-content' ).prepend( $( PairedCollectionCreator.templates.helpContent() ) ); @@ -606,7 +638,7 @@ }, /** render the unpaired section, showing datasets accrd. to filters, update the unpaired counts */ _renderUnpaired : function( speed, callback ){ - //console.debug( '-- _renderUnpaired' ); + //this.debug( '-- _renderUnpaired' ); var creator = this, $fwd, $rev, $prd = [], split = this._splitByFilters(); @@ -620,16 +652,17 @@ this.$( '.reverse-column .unpaired-info' ) .text( this._renderUnpairedDisplayStr( this.unpaired.length - split[1].length ) ); + this.$( '.unpaired-columns .column-datasets' ).empty(); + // show/hide the auto pair button if any unpaired are left this.$( '.autopair-link' ).toggle( this.unpaired.length !== 0 ); if( this.unpaired.length === 0 ){ this._renderUnpairedEmpty(); - //this.$( '.unpaired-columns .paired-column .column-datasets' ) - // .append( this._renderUnpairedEmpty() ); - //TODO: would be best to return here (the $columns) return; } + //this.$( '.unpaired-columns .forward-column' ).lassoable({}); + // create the dataset dom arrays $rev = split[1].map( function( dataset, i ){ // if there'll be a fwd dataset across the way, add a button to pair the row @@ -649,7 +682,6 @@ } // add to appropo cols //TODO: not the best way to render - this.$( '.unpaired-columns .column-datasets' ).empty(); this.$( '.unpaired-columns .forward-column .column-datasets' ).append( $fwd ) .add( this.$( '.unpaired-columns .paired-column .column-datasets' ).append( $prd ) ) .add( this.$( '.unpaired-columns .reverse-column .column-datasets' ).append( $rev ) ); @@ -678,7 +710,7 @@ }, /** a message to display when no unpaired left */ _renderUnpairedEmpty : function(){ - //console.debug( '-- renderUnpairedEmpty' ); + //this.debug( '-- renderUnpairedEmpty' ); var $msg = $( '<div class="empty-message"></div>' ) .text( '(' + _l( 'no remaining unpaired datasets' ) + ')' ); this.$( '.unpaired-columns .paired-column .column-datasets' ).empty().prepend( $msg ); @@ -686,7 +718,7 @@ }, /** a message to display when no unpaired can be shown with the current filters */ _renderUnpairedNotShown : function(){ - //console.debug( '-- renderUnpairedEmpty' ); + //this.debug( '-- renderUnpairedEmpty' ); var $msg = $( '<div class="empty-message"></div>' ) .text( '(' + _l( 'no datasets were found matching the current filters' ) + ')' ); this.$( '.unpaired-columns .paired-column .column-datasets' ).empty().prepend( $msg ); @@ -695,44 +727,39 @@ /** render the paired section and update counts of paired datasets */ _renderPaired : function( speed, callback ){ - //console.debug( '-- _renderPaired' ); - var $fwd = [], - $prd = [], - $rev = []; - + //this.debug( '-- _renderPaired' ); this.$( '.paired-column-title .title' ).text([ this.paired.length, _l( 'paired' ) ].join( ' ' ) ); // show/hide the unpair all link this.$( '.unpair-all-link' ).toggle( this.paired.length !== 0 ); if( this.paired.length === 0 ){ this._renderPairedEmpty(); + return; //TODO: would be best to return here (the $columns) } else { // show/hide 'remove extensions link' when any paired and they seem to have extensions this.$( '.remove-extensions-link' ).show(); } + this.$( '.paired-columns .column-datasets' ).empty(); + var creator = this; this.paired.forEach( function( pair, i ){ - $fwd.push( $( '<li/>').addClass( 'dataset paired' ) - .append( $( '<span/>' ).addClass( 'dataset-name' ).text( pair.forward.name ) ) ); - $prd.push( $( '<li/>').addClass( 'dataset paired' ) - .append( $( '<span/>' ).addClass( 'dataset-name' ).text( pair.name ) ) ); - $rev.push( $( '<li/>').addClass( 'dataset paired' ) - .append( $( '<span/>' ).addClass( 'dataset-name' ).text( pair.reverse.name ) ) ); - $rev.push( $( '<button/>' ).addClass( 'unpair-btn' ) - .append( $( '<span/>' ).addClass( 'fa fa-unlink' ).attr( 'title', _l( 'Unpair' ) ) ) ); +//TODO: cache these? + var pairView = new PairView({ pair: pair }); + creator.$( '.paired-columns .column-datasets' ) + .append( pairView.render().$el ) + .append([ +//TODO: data-index="i" + '<button class="unpair-btn">', + '<span class="fa fa-unlink" title="', _l( 'Unpair' ), '"></span>', + '</button>' + ].join( '' )); }); - - //TODO: better as one swell foop (instead of 4 repaints) - this.$( '.paired-columns .column-datasets' ).empty(); - return this.$( '.paired-columns .forward-column .column-datasets' ).prepend( $fwd ) - .add( this.$( '.paired-columns .paired-column .column-datasets' ).prepend( $prd ) ) - .add( this.$( '.paired-columns .reverse-column .column-datasets' ).prepend( $rev ) ); }, /** a message to display when none paired */ _renderPairedEmpty : function(){ var $msg = $( '<div class="empty-message"></div>' ) .text( '(' + _l( 'no paired datasets yet' ) + ')' ); - this.$( '.paired-columns .paired-column .column-datasets' ).prepend( $msg ); + this.$( '.paired-columns .column-datasets' ).empty().prepend( $msg ); return $msg; }, @@ -749,7 +776,7 @@ /** add any jQuery/bootstrap/custom plugins to elements rendered */ _addPluginComponents : function(){ this._chooseFiltersPopover( '.choose-filters-link' ); - this.$( '.help-content i' ).hoverhighlight( '.collection-creator', 'rgba( 192, 255, 255, 1.0 )' ); + this.$( '.help-content i' ).hoverhighlight( '.collection-creator', 'rgba( 64, 255, 255, 1.0 )' ); }, /** build a filter selection popover allowing selection of common filter pairs */ @@ -811,7 +838,7 @@ // may have to do with improper flex columns //var $pairedView = this.$( '.paired-columns' ); //$pairedView.scrollTop( $pairedView.innerHeight() ); - //console.debug( $pairedView.height() ) + //this.debug( $pairedView.height() ) this.$( '.paired-columns' ).scrollTop( 8000000 ); }); this.on( 'pair:unpair', function( pairs ){ @@ -849,7 +876,7 @@ }); //this.on( 'all', function(){ - // console.info( arguments ); + // this.info( arguments ); //}); return this; }, @@ -875,13 +902,12 @@ 'click .reverse-column .dataset.unpaired' : '_clickUnpairedDataset', 'click .paired-column .dataset.unpaired' : '_clickPairRow', 'click .unpaired-columns' : 'clearSelectedUnpaired', + 'mousedown .unpaired-columns .dataset' : '_mousedownUnpaired', // divider 'click .paired-column-title' : '_clickShowOnlyPaired', 'mousedown .flexible-partition-drag' : '_startPartitionDrag', // paired - 'click .paired-columns .paired-column .dataset-name' : '_clickPairName', - 'mouseover .dataset.paired' : '_hoverPaired', - 'mouseout .dataset.paired' : '_hoverOutPaired', + 'click .paired-columns .pair-name' : '_clickPairName', 'click .unpair-btn' : '_clickUnpair', // footer @@ -892,7 +918,7 @@ this.oncancel.call( this ); } }, - 'click .create-collection' : '_clickCreate' + 'click .create-collection' : '_clickCreate'//, }, // ........................................................................ header @@ -923,7 +949,7 @@ //TODO: consolidate these /** toggle between showing only unpaired and split view */ _clickShowOnlyUnpaired : function( ev ){ - //console.debug( 'click unpaired', ev.currentTarget ); + //this.debug( 'click unpaired', ev.currentTarget ); if( this.$( '.paired-columns' ).is( ':visible' ) ){ this.hidePaired(); } else { @@ -932,7 +958,7 @@ }, /** toggle between showing only paired and split view */ _clickShowOnlyPaired : function( ev ){ - //console.debug( 'click paired' ); + //this.debug( 'click paired' ); if( this.$( '.unpaired-columns' ).is( ':visible' ) ){ this.hideUnpaired(); } else { @@ -972,7 +998,7 @@ /** attempt to autopair */ _clickAutopair : function( ev ){ var paired = this.autoPair(); - //console.debug( 'autopaired', paired ); + //this.debug( 'autopaired', paired ); //TODO: an indication of how many pairs were found - if 0, assist this.trigger( 'autopair', paired ); }, @@ -1016,7 +1042,7 @@ options = options || {}; var dataset = $dataset.data( 'dataset' ), select = options.force !== undefined? options.force: !$dataset.hasClass( 'selected' ); - //console.debug( id, options.force, $dataset, dataset ); + //this.debug( id, options.force, $dataset, dataset ); if( !$dataset.size() || dataset === undefined ){ return $dataset; } if( select ){ @@ -1047,8 +1073,8 @@ revs.push( $( this ).data( 'dataset' ) ); }); fwds.length = revs.length = Math.min( fwds.length, revs.length ); - //console.debug( fwds ); - //console.debug( revs ); + //this.debug( fwds ); + //this.debug( revs ); fwds.forEach( function( fwd, i ){ try { pairs.push( creator._pair( fwd, revs[i], { silent: true }) ); @@ -1056,7 +1082,7 @@ } catch( err ){ //TODO: preserve selected state of those that couldn't be paired //TODO: warn that some could not be paired - console.error( err ); + creator.error( err ); } }); if( pairs.length && !options.silent ){ @@ -1070,35 +1096,56 @@ this.$( '.unpaired-columns .dataset.selected' ).removeClass( 'selected' ); }, + /** when holding down the shift key on a click, 'paint' the moused over datasets as selected */ + _mousedownUnpaired : function( ev ){ + if( ev.shiftKey ){ + var creator = this, + $startTarget = $( ev.target ).addClass( 'selected' ), + moveListener = function( ev ){ + creator.$( ev.target ).filter( '.dataset' ).addClass( 'selected' ); + }; + $startTarget.parent().on( 'mousemove', moveListener ); + + // on any mouseup, stop listening to the move and try to pair any selected + $( document ).one( 'mouseup', function( ev ){ + $startTarget.parent().off( 'mousemove', moveListener ); + creator.pairAllSelected(); + }); + } + }, + /** attempt to pair two datasets directly across from one another */ _clickPairRow : function( ev ){ //if( !ev.currentTarget ){ return true; } var rowIndex = $( ev.currentTarget ).index(), fwd = $( '.unpaired-columns .forward-column .dataset' ).eq( rowIndex ).data( 'dataset' ), rev = $( '.unpaired-columns .reverse-column .dataset' ).eq( rowIndex ).data( 'dataset' ); - //console.debug( 'row:', rowIndex, fwd, rev ); + //this.debug( 'row:', rowIndex, fwd, rev ); //TODO: animate this._pair( fwd, rev ); }, // ........................................................................ divider/partition +//TODO: simplify /** start dragging the visible divider/partition between unpaired and paired panes */ _startPartitionDrag : function( ev ){ var creator = this, startingY = ev.pageY; - //console.debug( 'partition drag START:', ev ); + //this.debug( 'partition drag START:', ev ); $( 'body' ).css( 'cursor', 'ns-resize' ); creator.$( '.flexible-partition-drag' ).css( 'color', 'black' ); function endDrag( ev ){ - //console.debug( 'partition drag STOP:', ev ); + //creator.debug( 'partition drag STOP:', ev ); // doing this by an added class didn't really work well - kept flashing still creator.$( '.flexible-partition-drag' ).css( 'color', '' ); $( 'body' ).css( 'cursor', '' ).unbind( 'mousemove', trackMouse ); } function trackMouse( ev ){ var offset = ev.pageY - startingY; + //creator.debug( 'partition:', startingY, offset ); if( !creator.adjPartition( offset ) ){ + //creator.debug( 'mouseup triggered' ); $( 'body' ).trigger( 'mouseup' ); } startingY += offset; @@ -1113,25 +1160,34 @@ $paired = this.$( '.paired-columns' ), unpairedHi = parseInt( $unpaired.css( 'height' ), 10 ), pairedHi = parseInt( $paired.css( 'height' ), 10 ); - //console.debug( adj, 'hi\'s:', unpairedHi, pairedHi, unpairedHi + adj, pairedHi - adj ); + //this.debug( adj, 'hi\'s:', unpairedHi, pairedHi, unpairedHi + adj, pairedHi - adj ); unpairedHi = Math.max( 10, unpairedHi + adj ); pairedHi = pairedHi - adj; + //TODO: seems like shouldn't need this (it should be part of the hide/show/splitView) if( unpairedHi <= 10 ){ - this.hideUnpaired(); - return false; - } else if( !$unpaired.is( 'visible' ) ){ + if( !this.unpairedPanelHidden ){ + this.hideUnpaired(); + return false; + } + + } else if( this.unpairedPanelHidden ){ $unpaired.show(); - //this.$( '.unpaired-filter' ).show(); + this.unpairedPanelHidden = false; } + // when the divider gets close to the bottom - lock into hiding the paired section if( pairedHi <= 15 ){ - this.hidePaired(); - if( pairedHi < 10 ){ return false; } + if( !this.pairedPanelHidden ){ + this.hidePaired(); + if( pairedHi < 5 ){ return false; } + } - } else if( !$paired.is( 'visible' ) ){ + // when the divider gets close to the bottom and the paired section is hidden + } else if( this.pairedPanelHidden ){ $paired.show(); + this.pairedPanelHidden = false; } $unpaired.css({ @@ -1162,47 +1218,11 @@ //if( !ev.currentTarget ){ return true; } //TODO: this is a hack bc each paired rev now has two elems (dataset, button) var pairIndex = Math.floor( $( ev.currentTarget ).index() / 2 ); - //console.debug( 'pair:', pairIndex ); + //this.debug( 'pair:', pairIndex ); //TODO: animate this._unpair( this.paired[ pairIndex ] ); }, - //TODO: the following is ridiculous - _hoverPaired : function( ev ){ - var $target = $( ev.currentTarget ), - index = $target.index(); - //TODO: this is a hack bc each paired rev now has two elems (dataset, button) - if( $target.parents( '.reverse-column' ).size() ){ - index = Math.floor( index / 2 ); - } - //console.debug( 'index:', index ); - this.emphasizePair( index ); - }, - _hoverOutPaired : function( ev ){ - var $target = $( ev.currentTarget ), - index = $target.index(); - //TODO: this is a hack bc each paired rev now has two elems (dataset, button) - if( $target.parents( '.reverse-column' ).size() ){ - index = Math.floor( index / 2 ); - } - //console.debug( 'index:', index ); - this.deemphasizePair( index ); - }, - emphasizePair : function( index ){ - //console.debug( 'emphasizePairedBorder:', index ); - this.$( '.paired-columns .forward-column .dataset.paired' ).eq( index ) - .add( this.$( '.paired-columns .paired-column .dataset.paired' ).eq( index ) ) - .add( this.$( '.paired-columns .reverse-column .dataset.paired' ).eq( index ) ) - .addClass( 'emphasized' ); - }, - deemphasizePair : function( index ){ - //console.debug( 'deemphasizePairedBorder:', index ); - this.$( '.paired-columns .forward-column .dataset.paired' ).eq( index ) - .add( this.$( '.paired-columns .paired-column .dataset.paired' ).eq( index ) ) - .add( this.$( '.paired-columns .reverse-column .dataset.paired' ).eq( index ) ) - .removeClass( 'emphasized' ); - }, - // ........................................................................ footer toggleExtensions : function( force ){ var creator = this; @@ -1246,14 +1266,14 @@ if( list === creator.paired ){ creator._printPair( e ); } else { - //console.debug( e ); + //creator.debug( e ); } }); }, /** print a pair Object */ _printPair : function( pair ){ - console.debug( pair.forward.name, pair.reverse.name, ': ->', pair.name ); + this.debug( pair.forward.name, pair.reverse.name, ': ->', pair.name ); }, /** string rep */ @@ -1341,7 +1361,7 @@ '</div>', '</div>', '<div class="flexible-partition">', - '<div class="flexible-partition-drag"></div>', + '<div class="flexible-partition-drag" title="', _l( 'Drag to change' ), '"></div>', '<div class="column-header">', '<div class="column-title paired-column-title">', '<span class="title"></span>', @@ -1352,15 +1372,7 @@ '</div>', '</div>', '<div class="paired-columns flex-column-container scroll-container flex-row">', - '<div class="forward-column flex-column column">', - '<ol class="column-datasets"></ol>', - '</div>', - '<div class="paired-column flex-column no-flex column">', - '<ol class="column-datasets"></ol>', - '</div>', - '<div class="reverse-column flex-column column">', - '<ol class="column-datasets"></ol>', - '</div>', + '<ol class="column-datasets"></ol>', '</div>' ].join('')), @@ -1405,7 +1417,7 @@ helpContent : _.template([ '<p>', _l([ 'Collections of paired datasets are ordered lists of dataset pairs (often forward and reverse reads). ', - 'These collections can be passed to tools and workflows in order to have analyses done each member of ', + 'These collections can be passed to tools and workflows in order to have analyses done on each member of ', 'the entire group. This interface allows you to create a collection, choose which datasets are paired, ', 'and re-order the final collection.' ].join( '' )), '</p>', @@ -1520,7 +1532,7 @@ title : 'Create a collection of paired datasets', body : creator.$el, width : '80%', - height : '700px', + height : '800px', closing_events: true }); //TODO: remove modal header diff -r ece8ef90a8289399bf9faca6a3265696da7e0beb -r 7c566a68d2d07375c53006191671dfed04332f55 static/scripts/mvc/history/history-panel-edit.js --- a/static/scripts/mvc/history/history-panel-edit.js +++ b/static/scripts/mvc/history/history-panel-edit.js @@ -187,7 +187,7 @@ } // set up the pupup for actions available when multi selecting - this._setUpDatasetActionsPopup( $where ); + this.actionsPopup = this._setUpDatasetActionsPopup( $where ); // anon users shouldn't have access to any of the following if( ( !Galaxy.currUser || Galaxy.currUser.isAnonymous() ) diff -r ece8ef90a8289399bf9faca6a3265696da7e0beb -r 7c566a68d2d07375c53006191671dfed04332f55 static/scripts/packed/mvc/collection/paired-collection-creator.js --- a/static/scripts/packed/mvc/collection/paired-collection-creator.js +++ b/static/scripts/packed/mvc/collection/paired-collection-creator.js @@ -1,1 +1,1 @@ -define(["utils/levenshtein","mvc/base-mvc","utils/localization"],function(f,a,d){var e=Backbone.View.extend(a.LoggableMixin).extend({className:"collection-creator flex-row-container",initialize:function(g){g=_.defaults(g,{datasets:[],filters:this.DEFAULT_FILTERS,automaticallyPair:true,matchPercentage:1,strategy:"lcs"});this.initialList=g.datasets;this.historyId=g.historyId;this.filters=this.commonFilters[g.filters]||this.commonFilters[this.DEFAULT_FILTERS];if(_.isArray(g.filters)){this.filters=g.filters}this.automaticallyPair=g.automaticallyPair;this.matchPercentage=g.matchPercentage;this.strategy=this.strategies[g.strategy]||this.strategies[this.DEFAULT_STRATEGY];if(_.isFunction(g.strategy)){this.strategy=g.strategy}this.removeExtensions=true;this.oncancel=g.oncancel;this.oncreate=g.oncreate;this.unpairedPanelHidden=false;this.pairedPanelHidden=false;this._dataSetUp();this._setUpBehaviors()},commonFilters:{none:["",""],illumina:["_1","_2"]},DEFAULT_FILTERS:"illumina",strategies:{lcs:"autoPairLCSs",levenshtein:"autoPairLevenshtein"},DEFAULT_STRATEGY:"lcs",_dataSetUp:function(){this.paired=[];this.unpaired=[];this.selectedIds=[];this._sortInitialList();this._ensureIds();this.unpaired=this.initialList.slice(0);if(this.automaticallyPair){this.autoPair()}},_sortInitialList:function(){this._sortDatasetList(this.initialList)},_sortDatasetList:function(g){g.sort(function(i,h){return naturalSort(i.name,h.name)});return g},_ensureIds:function(){this.initialList.forEach(function(g){if(!g.hasOwnProperty("id")){g.id=_.uniqueId()}});return this.initialList},_splitByFilters:function(i){var h=[],g=[];this.unpaired.forEach(function(j){if(this._filterFwdFn(j)){h.push(j)}if(this._filterRevFn(j)){g.push(j)}}.bind(this));return[h,g]},_filterFwdFn:function(h){var g=new RegExp(this.filters[0]);return g.test(h.name)},_filterRevFn:function(h){var g=new RegExp(this.filters[1]);return g.test(h.name)},_addToUnpaired:function(h){var g=function(i,k){if(i===k){return i}var j=Math.floor((k-i)/2)+i,l=naturalSort(h.name,this.unpaired[j].name);if(l<0){return g(i,j)}else{if(l>0){return g(j+1,k)}}while(this.unpaired[j]&&this.unpaired[j].name===h.name){j++}return j}.bind(this);this.unpaired.splice(g(0,this.unpaired.length),0,h)},autoPair:function(g){g=g||this.strategy;this.simpleAutoPair();return this[g].call(this)},simpleAutoPair:function(){var m=0,k,q=this._splitByFilters(),g=q[0],p=q[1],o,r,h=false;while(m<g.length){var l=g[m];o=l.name.replace(this.filters[0],"");h=false;for(k=0;k<p.length;k++){var n=p[k];r=n.name.replace(this.filters[1],"");if(l!==n&&o===r){h=true;this._pair(g.splice(m,1)[0],p.splice(k,1)[0],{silent:true});break}}if(!h){m+=1}}},autoPairLevenshtein:function(){var n=0,l,s=this._splitByFilters(),g=s[0],q=s[1],p,u,h,r,k;while(n<g.length){var m=g[n];p=m.name.replace(this.filters[0],"");k=Number.MAX_VALUE;for(l=0;l<q.length;l++){var o=q[l];u=o.name.replace(this.filters[1],"");if(m!==o){if(p===u){r=l;k=0;break}h=levenshteinDistance(p,u);if(h<k){r=l;k=h}}}var t=1-(k/(Math.max(p.length,u.length)));if(t>=this.matchPercentage){this._pair(g.splice(n,1)[0],q.splice(r,1)[0],{silent:true});if(g.length<=0||q.length<=0){return}}else{n+=1}}},autoPairLCSs:function(){var l=0,h,s=this._splitByFilters(),g=s[0],q=s[1],p,v,u,r,n;if(!g.length||!q.length){return}while(l<g.length){var k=g[l];p=k.name.replace(this.filters[0],"");n=0;for(h=0;h<q.length;h++){var o=q[h];v=o.name.replace(this.filters[1],"");if(k!==o){if(p===v){r=h;n=p.length;break}var m=this._naiveStartingAndEndingLCS(p,v);u=m.length;if(u>n){r=h;n=u}}}var t=n/(Math.min(p.length,v.length));if(t>=this.matchPercentage){this._pair(g.splice(l,1)[0],q.splice(r,1)[0],{silent:true});if(g.length<=0||q.length<=0){return}}else{l+=1}}},_naiveStartingAndEndingLCS:function(l,h){var m="",n="",k=0,g=0;while(k<l.length&&k<h.length){if(l[k]!==h[k]){break}m+=l[k];k+=1}if(k===l.length){return l}if(k===h.length){return h}k=(l.length-1);g=(h.length-1);while(k>=0&&g>=0){if(l[k]!==h[g]){break}n=[l[k],n].join("");k-=1;g-=1}return m+n},_pair:function(i,g,h){h=h||{};var j=this._createPair(i,g,h.name);this.paired.push(j);this.unpaired=_.without(this.unpaired,i,g);if(!h.silent){this.trigger("pair:new",j)}return j},_createPair:function(i,g,h){if(!(i&&g)||(i===g)){throw new Error("Bad pairing: "+[JSON.stringify(i),JSON.stringify(g)])}h=h||this._guessNameForPair(i,g);return{forward:i,name:h,reverse:g}},_guessNameForPair:function(i,g,j){j=(j!==undefined)?(j):(this.removeExtensions);var h=this._naiveStartingAndEndingLCS(i.name.replace(this.filters[0],""),g.name.replace(this.filters[1],""));if(j){var k=h.lastIndexOf(".");if(k>0){h=h.slice(0,k)}}return h||(i.name+" & "+g.name)},_unpair:function(h,g){g=g||{};if(!h){throw new Error("Bad pair: "+JSON.stringify(h))}this.paired=_.without(this.paired,h);this._addToUnpaired(h.forward);this._addToUnpaired(h.reverse);if(!g.silent){this.trigger("pair:unpair",[h])}return h},unpairAll:function(){var g=[];while(this.paired.length){g.push(this._unpair(this.paired[0],{silent:true}))}this.trigger("pair:unpair",g)},_pairToJSON:function(g){return{collection_type:"paired",src:"new_collection",name:g.name,element_identifiers:[{name:"forward",id:g.forward.id,src:"hda"},{name:"reverse",id:g.reverse.id,src:"hda"}]}},createList:function(){var i=this,h;if(i.historyId){h="/api/histories/"+this.historyId+"/contents/dataset_collections"}var g={type:"dataset_collection",collection_type:"list:paired",name:_.escape(i.$(".collection-name").val()),element_identifiers:i.paired.map(function(j){return i._pairToJSON(j)})};return jQuery.ajax(h,{type:"POST",contentType:"application/json",dataType:"json",data:JSON.stringify(g)}).fail(function(l,j,k){i._ajaxErrHandler(l,j,k)}).done(function(j,k,l){i.trigger("collection:created",j,k,l);if(typeof i.oncreate==="function"){i.oncreate.call(this,j,k,l)}})},_ajaxErrHandler:function(j,g,i){console.error(j,g,i);var h=d("An error occurred while creating this collection");if(j){if(j.readyState===0&&j.status===0){h+=": "+d("Galaxy could not be reached and may be updating.")+d(" Try again in a few minutes.")}else{if(j.responseJSON){h+="<br /><pre>"+JSON.stringify(j.responseJSON)+"</pre>"}else{h+=": "+i}}}creator._showAlert(h,"alert-danger")},render:function(g,h){this.$el.empty().html(e.templates.main());this._renderHeader(g);this._renderMiddle(g);this._renderFooter(g);this._addPluginComponents();return this},_renderHeader:function(h,i){var g=this.$(".header").empty().html(e.templates.header()).find(".help-content").prepend($(e.templates.helpContent()));this._renderFilters();return g},_renderFilters:function(){return this.$(".forward-column .column-header input").val(this.filters[0]).add(this.$(".reverse-column .column-header input").val(this.filters[1]))},_renderMiddle:function(h,i){var g=this.$(".middle").empty().html(e.templates.middle());if(this.unpairedPanelHidden){this.$(".unpaired-columns").hide()}else{if(this.pairedPanelHidden){this.$(".paired-columns").hide()}}this._renderUnpaired();this._renderPaired();return g},_renderUnpaired:function(l,m){var j=this,k,h,g=[],i=this._splitByFilters();this.$(".forward-column .title").text([i[0].length,d("unpaired forward")].join(" "));this.$(".forward-column .unpaired-info").text(this._renderUnpairedDisplayStr(this.unpaired.length-i[0].length));this.$(".reverse-column .title").text([i[1].length,d("unpaired reverse")].join(" "));this.$(".reverse-column .unpaired-info").text(this._renderUnpairedDisplayStr(this.unpaired.length-i[1].length));this.$(".autopair-link").toggle(this.unpaired.length!==0);if(this.unpaired.length===0){this._renderUnpairedEmpty();return}h=i[1].map(function(o,n){if((i[0][n]!==undefined)&&(i[0][n]!==o)){g.push(j._renderPairButton())}return j._renderUnpairedDataset(o)});k=i[0].map(function(n){return j._renderUnpairedDataset(n)});if(!k.length&&!h.length){this._renderUnpairedNotShown();return}this.$(".unpaired-columns .column-datasets").empty();this.$(".unpaired-columns .forward-column .column-datasets").append(k).add(this.$(".unpaired-columns .paired-column .column-datasets").append(g)).add(this.$(".unpaired-columns .reverse-column .column-datasets").append(h))},_renderUnpairedDisplayStr:function(g){return["(",g," ",d("filtered out"),")"].join("")},_renderUnpairedDataset:function(g){return $("<li/>").attr("id","dataset-"+g.id).addClass("dataset unpaired").attr("draggable",true).addClass(g.selected?"selected":"").append($("<span/>").addClass("dataset-name").text(g.name)).data("dataset",g)},_renderPairButton:function(){return $("<li/>").addClass("dataset unpaired").append($("<span/>").addClass("dataset-name").text(d("Pair these datasets")))},_renderUnpairedEmpty:function(){var g=$('<div class="empty-message"></div>').text("("+d("no remaining unpaired datasets")+")");this.$(".unpaired-columns .paired-column .column-datasets").empty().prepend(g);return g},_renderUnpairedNotShown:function(){var g=$('<div class="empty-message"></div>').text("("+d("no datasets were found matching the current filters")+")");this.$(".unpaired-columns .paired-column .column-datasets").empty().prepend(g);return g},_renderPaired:function(j,k){var i=[],g=[],h=[];this.$(".paired-column-title .title").text([this.paired.length,d("paired")].join(" "));this.$(".unpair-all-link").toggle(this.paired.length!==0);if(this.paired.length===0){this._renderPairedEmpty()}else{this.$(".remove-extensions-link").show()}this.paired.forEach(function(m,l){i.push($("<li/>").addClass("dataset paired").append($("<span/>").addClass("dataset-name").text(m.forward.name)));g.push($("<li/>").addClass("dataset paired").append($("<span/>").addClass("dataset-name").text(m.name)));h.push($("<li/>").addClass("dataset paired").append($("<span/>").addClass("dataset-name").text(m.reverse.name)));h.push($("<button/>").addClass("unpair-btn").append($("<span/>").addClass("fa fa-unlink").attr("title",d("Unpair"))))});this.$(".paired-columns .column-datasets").empty();return this.$(".paired-columns .forward-column .column-datasets").prepend(i).add(this.$(".paired-columns .paired-column .column-datasets").prepend(g)).add(this.$(".paired-columns .reverse-column .column-datasets").prepend(h))},_renderPairedEmpty:function(){var g=$('<div class="empty-message"></div>').text("("+d("no paired datasets yet")+")");this.$(".paired-columns .paired-column .column-datasets").prepend(g);return g},_renderFooter:function(h,i){var g=this.$(".footer").empty().html(e.templates.footer());this.$(".remove-extensions").prop("checked",this.removeExtensions);if(typeof this.oncancel==="function"){this.$(".cancel-create.btn").show()}return g},_addPluginComponents:function(){this._chooseFiltersPopover(".choose-filters-link");this.$(".help-content i").hoverhighlight(".collection-creator","rgba( 192, 255, 255, 1.0 )")},_chooseFiltersPopover:function(g){function h(k,j){return['<button class="filter-choice btn" ','data-forward="',k,'" data-reverse="',j,'">',d("Forward"),": ",k,", ",d("Reverse"),": ",j,"</button>"].join("")}var i=$(_.template(['<div class="choose-filters">','<div class="help">',d("Choose from the following filters to change which unpaired reads are shown in the display"),":</div>",h("_1","_2"),h("_R1","_R2"),"</div>"].join(""),{}));return this.$(g).popover({container:".collection-creator",placement:"bottom",html:true,content:i})},_validationWarning:function(h,g){var i="validation-warning";if(h==="name"){h=this.$(".collection-name").add(this.$(".collection-name-prompt"));this.$(".collection-name").focus().select()}if(g){h=h||this.$("."+i);h.removeClass(i)}else{h.addClass(i)}},_setUpBehaviors:function(){this.on("pair:new",function(){this._renderUnpaired();this._renderPaired();this.$(".paired-columns").scrollTop(8000000)});this.on("pair:unpair",function(g){this._renderUnpaired();this._renderPaired();this.splitView()});this.on("filter-change",function(){this.filters=[this.$(".forward-unpaired-filter input").val(),this.$(".reverse-unpaired-filter input").val()];this._renderFilters();this._renderUnpaired()});this.on("autopair",function(){this._renderUnpaired();this._renderPaired();var g,h=null;if(this.paired.length){h="alert-success";g=this.paired.length+" "+d("pairs created");if(!this.unpaired.length){g+=": "+d("all datasets have been successfully paired");this.hideUnpaired()}}else{g=d("Could not automatically create any pairs from the given dataset names")}this._showAlert(g,h)});return this},events:{"click .more-help":"_clickMoreHelp","click .less-help":"_clickLessHelp","click .header .alert button":"_hideAlert","click .forward-column .column-title":"_clickShowOnlyUnpaired","click .reverse-column .column-title":"_clickShowOnlyUnpaired","click .unpair-all-link":"_clickUnpairAll","change .forward-unpaired-filter input":function(g){this.trigger("filter-change")},"focus .forward-unpaired-filter input":function(g){$(g.currentTarget).select()},"click .autopair-link":"_clickAutopair","click .choose-filters .filter-choice":"_clickFilterChoice","click .clear-filters-link":"_clearFilters","change .reverse-unpaired-filter input":function(g){this.trigger("filter-change")},"focus .reverse-unpaired-filter input":function(g){$(g.currentTarget).select()},"click .forward-column .dataset.unpaired":"_clickUnpairedDataset","click .reverse-column .dataset.unpaired":"_clickUnpairedDataset","click .paired-column .dataset.unpaired":"_clickPairRow","click .unpaired-columns":"clearSelectedUnpaired","click .paired-column-title":"_clickShowOnlyPaired","mousedown .flexible-partition-drag":"_startPartitionDrag","click .paired-columns .paired-column .dataset-name":"_clickPairName","mouseover .dataset.paired":"_hoverPaired","mouseout .dataset.paired":"_hoverOutPaired","click .unpair-btn":"_clickUnpair","change .remove-extensions":function(g){this.toggleExtensions()},"change .collection-name":"_changeName","click .cancel-create":function(g){if(typeof this.oncancel==="function"){this.oncancel.call(this)}},"click .create-collection":"_clickCreate"},_clickMoreHelp:function(g){this.$(".main-help").addClass("expanded");this.$(".more-help").hide()},_clickLessHelp:function(g){this.$(".main-help").removeClass("expanded");this.$(".more-help").show()},_showAlert:function(h,g){g=g||"alert-danger";this.$(".main-help").hide();this.$(".header .alert").attr("class","alert alert-dismissable").addClass(g).show().find(".alert-message").html(h)},_hideAlert:function(g){this.$(".main-help").show();this.$(".header .alert").hide()},_clickShowOnlyUnpaired:function(g){if(this.$(".paired-columns").is(":visible")){this.hidePaired()}else{this.splitView()}},_clickShowOnlyPaired:function(g){if(this.$(".unpaired-columns").is(":visible")){this.hideUnpaired()}else{this.splitView()}},hideUnpaired:function(g,h){g=g||0;this.$(".unpaired-columns").hide(g,h);this.$(".paired-columns").show(g).css("flex","1 0 auto");this.unpairedPanelHidden=true},hidePaired:function(g,h){g=g||0;this.$(".unpaired-columns").show(g).css("flex","1 0 auto");this.$(".paired-columns").hide(g,h);this.pairedPanelHidden=true},splitView:function(g,h){g=g||0;this.unpairedPanelHidden=this.pairedPanelHidden=false;this._renderMiddle(g);return this},_clickUnpairAll:function(g){this.unpairAll()},_clickAutopair:function(h){var g=this.autoPair();this.trigger("autopair",g)},_clickFilterChoice:function(h){var g=$(h.currentTarget);this.$(".forward-unpaired-filter input").val(g.data("forward"));this.$(".reverse-unpaired-filter input").val(g.data("reverse"));this._hideChooseFilters();this.trigger("filter-change")},_hideChooseFilters:function(){this.$(".choose-filters-link").popover("hide");this.$(".popover").css("display","none")},_clearFilters:function(g){this.$(".forward-unpaired-filter input").val("");this.$(".reverse-unpaired-filter input").val("");this.trigger("filter-change")},_clickUnpairedDataset:function(g){g.stopPropagation();return this.toggleSelectUnpaired($(g.currentTarget))},toggleSelectUnpaired:function(i,h){h=h||{};var j=i.data("dataset"),g=h.force!==undefined?h.force:!i.hasClass("selected");if(!i.size()||j===undefined){return i}if(g){i.addClass("selected");if(!h.waitToPair){this.pairAllSelected()}}else{i.removeClass("selected")}return i},pairAllSelected:function(h){h=h||{};var i=this,j=[],g=[],k=[];i.$(".unpaired-columns .forward-column .dataset.selected").each(function(){j.push($(this).data("dataset"))});i.$(".unpaired-columns .reverse-column .dataset.selected").each(function(){g.push($(this).data("dataset"))});j.length=g.length=Math.min(j.length,g.length);j.forEach(function(m,l){try{k.push(i._pair(m,g[l],{silent:true}))}catch(n){console.error(n)}});if(k.length&&!h.silent){this.trigger("pair:new",k)}return k},clearSelectedUnpaired:function(){this.$(".unpaired-columns .dataset.selected").removeClass("selected")},_clickPairRow:function(i){var j=$(i.currentTarget).index(),h=$(".unpaired-columns .forward-column .dataset").eq(j).data("dataset"),g=$(".unpaired-columns .reverse-column .dataset").eq(j).data("dataset");this._pair(h,g)},_startPartitionDrag:function(h){var g=this,k=h.pageY;$("body").css("cursor","ns-resize");g.$(".flexible-partition-drag").css("color","black");function j(l){g.$(".flexible-partition-drag").css("color","");$("body").css("cursor","").unbind("mousemove",i)}function i(l){var m=l.pageY-k;if(!g.adjPartition(m)){$("body").trigger("mouseup")}k+=m}$("body").mousemove(i);$("body").one("mouseup",j)},adjPartition:function(h){var g=this.$(".unpaired-columns"),i=this.$(".paired-columns"),j=parseInt(g.css("height"),10),k=parseInt(i.css("height"),10);j=Math.max(10,j+h);k=k-h;if(j<=10){this.hideUnpaired();return false}else{if(!g.is("visible")){g.show()}}if(k<=15){this.hidePaired();if(k<10){return false}}else{if(!i.is("visible")){i.show()}}g.css({height:j+"px",flex:"0 0 auto"});return true},_clickPairName:function(i){var h=$(i.currentTarget),j=this.paired[h.parent().index()],g=prompt("Enter a new name for the pair:",j.name);if(g){j.name=g;j.customizedName=true;h.text(j.name)}},_clickUnpair:function(h){var g=Math.floor($(h.currentTarget).index()/2);this._unpair(this.paired[g])},_hoverPaired:function(i){var g=$(i.currentTarget),h=g.index();if(g.parents(".reverse-column").size()){h=Math.floor(h/2)}this.emphasizePair(h)},_hoverOutPaired:function(i){var g=$(i.currentTarget),h=g.index();if(g.parents(".reverse-column").size()){h=Math.floor(h/2)}this.deemphasizePair(h)},emphasizePair:function(g){this.$(".paired-columns .forward-column .dataset.paired").eq(g).add(this.$(".paired-columns .paired-column .dataset.paired").eq(g)).add(this.$(".paired-columns .reverse-column .dataset.paired").eq(g)).addClass("emphasized")},deemphasizePair:function(g){this.$(".paired-columns .forward-column .dataset.paired").eq(g).add(this.$(".paired-columns .paired-column .dataset.paired").eq(g)).add(this.$(".paired-columns .reverse-column .dataset.paired").eq(g)).removeClass("emphasized")},toggleExtensions:function(h){var g=this;g.removeExtensions=(h!==undefined)?(h):(!g.removeExtensions);_.each(g.paired,function(i){if(i.customizedName){return}i.name=g._guessNameForPair(i.forward,i.reverse)});g._renderPaired();g._renderFooter()},_changeName:function(g){this._validationWarning("name",!!this._getName())},_getName:function(){return _.escape(this.$(".collection-name").val())},_clickCreate:function(h){var g=this._getName();if(!g){this._validationWarning("name")}else{this.createList()}},_printList:function(h){var g=this;_.each(h,function(i){if(h===g.paired){g._printPair(i)}else{}})},_printPair:function(g){console.debug(g.forward.name,g.reverse.name,": ->",g.name)},toString:function(){return"PairedCollectionCreator"}});e.templates=e.templates||{main:_.template(['<div class="header flex-row no-flex"></div>','<div class="middle flex-row flex-row-container"></div>','<div class="footer flex-row no-flex">'].join("")),header:_.template(['<div class="main-help well clear">','<a class="more-help" href="javascript:void(0);">',d("More help"),"</a>",'<div class="help-content">','<a class="less-help" href="javascript:void(0);">',d("Less"),"</a>","</div>","</div>",'<div class="alert alert-dismissable">','<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>','<span class="alert-message"></span>',"</div>",'<div class="column-headers vertically-spaced flex-column-container">','<div class="forward-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',d("Unpaired forward"),"</span>",'<span class="title-info unpaired-info"></span>',"</div>",'<div class="unpaired-filter forward-unpaired-filter pull-left">','<input class="search-query" placeholder="',d("Filter this list"),'" />',"</div>","</div>","</div>",'<div class="paired-column flex-column no-flex column">','<div class="column-header">','<a class="choose-filters-link" href="javascript:void(0)">',d("Choose filters"),"</a>",'<a class="clear-filters-link" href="javascript:void(0);">',d("Clear filters"),"</a><br />",'<a class="autopair-link" href="javascript:void(0);">',d("Auto-pair"),"</a>","</div>","</div>",'<div class="reverse-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',d("Unpaired reverse"),"</span>",'<span class="title-info unpaired-info"></span>',"</div>",'<div class="unpaired-filter reverse-unpaired-filter pull-left">','<input class="search-query" placeholder="',d("Filter this list"),'" />',"</div>","</div>","</div>","</div>"].join("")),middle:_.template(['<div class="unpaired-columns flex-column-container scroll-container flex-row">','<div class="forward-column flex-column column">','<ol class="column-datasets"></ol>',"</div>",'<div class="paired-column flex-column no-flex column">','<ol class="column-datasets"></ol>',"</div>",'<div class="reverse-column flex-column column">','<ol class="column-datasets"></ol>',"</div>","</div>",'<div class="flexible-partition">','<div class="flexible-partition-drag"></div>','<div class="column-header">','<div class="column-title paired-column-title">','<span class="title"></span>',"</div>",'<a class="unpair-all-link" href="javascript:void(0);">',d("Unpair all"),"</a>","</div>","</div>",'<div class="paired-columns flex-column-container scroll-container flex-row">','<div class="forward-column flex-column column">','<ol class="column-datasets"></ol>',"</div>",'<div class="paired-column flex-column no-flex column">','<ol class="column-datasets"></ol>',"</div>",'<div class="reverse-column flex-column column">','<ol class="column-datasets"></ol>',"</div>","</div>"].join("")),footer:_.template(['<div class="attributes clear">','<div class="clear">','<label class="remove-extensions-prompt pull-right">',d("Remove file extensions from pair names"),"?",'<input class="remove-extensions pull-right" type="checkbox" />',"</label>","</div>",'<div class="clear">','<input class="collection-name form-control pull-right" ','placeholder="',d("Enter a name for your new list"),'" />','<div class="collection-name-prompt pull-right">',d("Name"),":</div>","</div>","</div>",'<div class="actions clear vertically-spaced">','<div class="other-options pull-left">','<button class="cancel-create btn" tabindex="-1">',d("Cancel"),"</button>",'<div class="create-other btn-group dropup">','<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">',d("Create a different kind of collection"),' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">','<li><a href="#">',d("Create a <i>single</i> pair"),"</a></li>",'<li><a href="#">',d("Create a list of <i>unpaired</i> datasets"),"</a></li>","</ul>","</div>","</div>",'<div class="main-options pull-right">','<button class="create-collection btn btn-primary">',d("Create list"),"</button>","</div>","</div>"].join("")),helpContent:_.template(["<p>",d(["Collections of paired datasets are ordered lists of dataset pairs (often forward and reverse reads). ","These collections can be passed to tools and workflows in order to have analyses done each member of ","the entire group. This interface allows you to create a collection, choose which datasets are paired, ","and re-order the final collection."].join("")),"</p>","<p>",d(['Unpaired datasets are shown in the <i data-target=".unpaired-columns">unpaired section</i> ',"(hover over the underlined words to highlight below). ",'Paired datasets are shown in the <i data-target=".paired-columns">paired section</i>.',"<ul>To pair datasets, you can:","<li>Click a dataset in the ",'<i data-target=".unpaired-columns .forward-column .column-datasets,','.unpaired-columns .forward-column">forward column</i> ',"to select it then click a dataset in the ",'<i data-target=".unpaired-columns .reverse-column .column-datasets,','.unpaired-columns .reverse-column">reverse column</i>.',"</li>",'<li>Click one of the "Pair these datasets" buttons in the ','<i data-target=".unpaired-columns .paired-column .column-datasets,','.unpaired-columns .paired-column">middle column</i> ',"to pair the datasets in a particular row.","</li>",'<li>Click <i data-target=".autopair-link">"Auto-pair"</i> ',"to have your datasets automatically paired based on name.","</li>","</ul>"].join("")),"</p>","<p>",d(["<ul>You can filter what is shown in the unpaired sections by:","<li>Entering partial dataset names in either the ",'<i data-target=".forward-unpaired-filter input">forward filter</i> or ','<i data-target=".reverse-unpaired-filter input">reverse filter</i>.',"</li>","<li>Choosing from a list of preset filters by clicking the ",'<i data-target=".choose-filters-link">"Choose filters" link</i>.',"</li>","<li>Entering regular expressions to match dataset names. See: ",'<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expres..."',' target="_blank">MDN\'s JavaScript Regular Expression Tutorial</a>. ',"Note: forward slashes (\\) are not needed.","</li>","<li>Clearing the filters by clicking the ",'<i data-target=".clear-filters-link">"Clear filters" link</i>.',"</li>","</ul>"].join("")),"</p>","<p>",d(["To unpair individual dataset pairs, click the ",'<i data-target=".unpair-btn">unpair buttons ( <span class="fa fa-unlink"></span> )</i>. ','Click the <i data-target=".unpair-all-link">"Unpair all" link</i> to unpair all pairs.'].join("")),"</p>","<p>",d(['You can include or remove the file extensions (e.g. ".fastq") from your pair names by toggling the ','<i data-target=".remove-extensions-prompt">"Remove file extensions from pair names?"</i> control.'].join("")),"</p>","<p>",d(['Once your collection is complete, enter a <i data-target=".collection-name">name</i> and ','click <i data-target=".create-collection">"Create list"</i>. ',"(Note: you do not have to pair all unpaired datasets to finish.)"].join("")),"</p>"].join(""))};(function(){jQuery.fn.extend({hoverhighlight:function g(i,h){i=i||"body";if(!this.size()){return this}$(this).each(function(){var k=$(this),j=k.data("target");if(j){k.mouseover(function(l){$(j,i).css({background:h})}).mouseout(function(l){$(j).css({background:""})})}});return this}})}());var b=function c(i,g){g=_.defaults(g||{},{datasets:i,oncancel:function(){Galaxy.modal.hide()},oncreate:function(){Galaxy.modal.hide();Galaxy.currHistoryPanel.refreshContents()}});if(!window.Galaxy||!Galaxy.modal){throw new Error("Galaxy or Galaxy.modal not found")}var h=new e(g).render();Galaxy.modal.show({title:"Create a collection of paired datasets",body:h.$el,width:"80%",height:"700px",closing_events:true});window.PCC=h;return h};return{PairedCollectionCreator:e,pairedCollectionCreatorModal:b}}); \ No newline at end of file +define(["utils/levenshtein","mvc/base-mvc","utils/localization"],function(g,a,d){var f=Backbone.View.extend(a.LoggableMixin).extend({tagName:"li",className:"dataset paired",initialize:function(h){this.pair=h.pair||{}},render:function(){this.$el.attr("draggable",true).html(_.template(['<span class="forward-dataset-name flex-column"><%= pair.forward.name %></span>','<span class="pair-name flex-column"><%= pair.name %></span>','<span class="reverse-dataset-name flex-column"><%= pair.reverse.name %></span>'].join(""),{pair:this.pair})).addClass("flex-column-container");return this}});var e=Backbone.View.extend(a.LoggableMixin).extend({className:"collection-creator flex-row-container",initialize:function(h){h=_.defaults(h,{datasets:[],filters:this.DEFAULT_FILTERS,automaticallyPair:true,matchPercentage:1,strategy:"lcs"});this.initialList=h.datasets;this.historyId=h.historyId;this.filters=this.commonFilters[h.filters]||this.commonFilters[this.DEFAULT_FILTERS];if(_.isArray(h.filters)){this.filters=h.filters}this.automaticallyPair=h.automaticallyPair;this.matchPercentage=h.matchPercentage;this.strategy=this.strategies[h.strategy]||this.strategies[this.DEFAULT_STRATEGY];if(_.isFunction(h.strategy)){this.strategy=h.strategy}this.removeExtensions=true;this.oncancel=h.oncancel;this.oncreate=h.oncreate;this.unpairedPanelHidden=false;this.pairedPanelHidden=false;this._dataSetUp();this._setUpBehaviors()},commonFilters:{none:["",""],illumina:["_1","_2"]},DEFAULT_FILTERS:"illumina",strategies:{lcs:"autoPairLCSs",levenshtein:"autoPairLevenshtein"},DEFAULT_STRATEGY:"lcs",_dataSetUp:function(){this.paired=[];this.unpaired=[];this.selectedIds=[];this._sortInitialList();this._ensureIds();this.unpaired=this.initialList.slice(0);if(this.automaticallyPair){this.autoPair()}},_sortInitialList:function(){this._sortDatasetList(this.initialList)},_sortDatasetList:function(h){h.sort(function(j,i){return naturalSort(j.name,i.name)});return h},_ensureIds:function(){this.initialList.forEach(function(h){if(!h.hasOwnProperty("id")){h.id=_.uniqueId()}});return this.initialList},_splitByFilters:function(j){var i=[],h=[];this.unpaired.forEach(function(k){if(this._filterFwdFn(k)){i.push(k)}if(this._filterRevFn(k)){h.push(k)}}.bind(this));return[i,h]},_filterFwdFn:function(i){var h=new RegExp(this.filters[0]);return h.test(i.name)},_filterRevFn:function(i){var h=new RegExp(this.filters[1]);return h.test(i.name)},_addToUnpaired:function(i){var h=function(j,l){if(j===l){return j}var k=Math.floor((l-j)/2)+j,m=naturalSort(i.name,this.unpaired[k].name);if(m<0){return h(j,k)}else{if(m>0){return h(k+1,l)}}while(this.unpaired[k]&&this.unpaired[k].name===i.name){k++}return k}.bind(this);this.unpaired.splice(h(0,this.unpaired.length),0,i)},autoPair:function(h){h=h||this.strategy;this.simpleAutoPair();return this[h].call(this)},simpleAutoPair:function(){var n=0,l,r=this._splitByFilters(),h=r[0],q=r[1],p,s,k=false;while(n<h.length){var m=h[n];p=m.name.replace(this.filters[0],"");k=false;for(l=0;l<q.length;l++){var o=q[l];s=o.name.replace(this.filters[1],"");if(m!==o&&p===s){k=true;this._pair(h.splice(n,1)[0],q.splice(l,1)[0],{silent:true});break}}if(!k){n+=1}}},autoPairLevenshtein:function(){var o=0,m,t=this._splitByFilters(),h=t[0],r=t[1],q,v,k,s,l;while(o<h.length){var n=h[o];q=n.name.replace(this.filters[0],"");l=Number.MAX_VALUE;for(m=0;m<r.length;m++){var p=r[m];v=p.name.replace(this.filters[1],"");if(n!==p){if(q===v){s=m;l=0;break}k=levenshteinDistance(q,v);if(k<l){s=m;l=k}}}var u=1-(l/(Math.max(q.length,v.length)));if(u>=this.matchPercentage){this._pair(h.splice(o,1)[0],r.splice(s,1)[0],{silent:true});if(h.length<=0||r.length<=0){return}}else{o+=1}}},autoPairLCSs:function(){var m=0,k,t=this._splitByFilters(),h=t[0],r=t[1],q,w,v,s,o;if(!h.length||!r.length){return}while(m<h.length){var l=h[m];q=l.name.replace(this.filters[0],"");o=0;for(k=0;k<r.length;k++){var p=r[k];w=p.name.replace(this.filters[1],"");if(l!==p){if(q===w){s=k;o=q.length;break}var n=this._naiveStartingAndEndingLCS(q,w);v=n.length;if(v>o){s=k;o=v}}}var u=o/(Math.min(q.length,w.length));if(u>=this.matchPercentage){this._pair(h.splice(m,1)[0],r.splice(s,1)[0],{silent:true});if(h.length<=0||r.length<=0){return}}else{m+=1}}},_naiveStartingAndEndingLCS:function(m,k){var n="",o="",l=0,h=0;while(l<m.length&&l<k.length){if(m[l]!==k[l]){break}n+=m[l];l+=1}if(l===m.length){return m}if(l===k.length){return k}l=(m.length-1);h=(k.length-1);while(l>=0&&h>=0){if(m[l]!==k[h]){break}o=[m[l],o].join("");l-=1;h-=1}return n+o},_pair:function(j,h,i){i=i||{};var k=this._createPair(j,h,i.name);this.paired.push(k);this.unpaired=_.without(this.unpaired,j,h);if(!i.silent){this.trigger("pair:new",k)}return k},_createPair:function(j,h,i){if(!(j&&h)||(j===h)){throw new Error("Bad pairing: "+[JSON.stringify(j),JSON.stringify(h)])}i=i||this._guessNameForPair(j,h);return{forward:j,name:i,reverse:h}},_guessNameForPair:function(j,h,k){k=(k!==undefined)?(k):(this.removeExtensions);var i=this._naiveStartingAndEndingLCS(j.name.replace(this.filters[0],""),h.name.replace(this.filters[1],""));if(k){var l=i.lastIndexOf(".");if(l>0){i=i.slice(0,l)}}return i||(j.name+" & "+h.name)},_unpair:function(i,h){h=h||{};if(!i){throw new Error("Bad pair: "+JSON.stringify(i))}this.paired=_.without(this.paired,i);this._addToUnpaired(i.forward);this._addToUnpaired(i.reverse);if(!h.silent){this.trigger("pair:unpair",[i])}return i},unpairAll:function(){var h=[];while(this.paired.length){h.push(this._unpair(this.paired[0],{silent:true}))}this.trigger("pair:unpair",h)},_pairToJSON:function(h){return{collection_type:"paired",src:"new_collection",name:h.name,element_identifiers:[{name:"forward",id:h.forward.id,src:"hda"},{name:"reverse",id:h.reverse.id,src:"hda"}]}},createList:function(){var j=this,i;if(j.historyId){i="/api/histories/"+this.historyId+"/contents/dataset_collections"}var h={type:"dataset_collection",collection_type:"list:paired",name:_.escape(j.$(".collection-name").val()),element_identifiers:j.paired.map(function(k){return j._pairToJSON(k)})};return jQuery.ajax(i,{type:"POST",contentType:"application/json",dataType:"json",data:JSON.stringify(h)}).fail(function(m,k,l){j._ajaxErrHandler(m,k,l)}).done(function(k,l,m){j.trigger("collection:created",k,l,m);if(typeof j.oncreate==="function"){j.oncreate.call(this,k,l,m)}})},_ajaxErrHandler:function(k,h,j){this.error(k,h,j);var i=d("An error occurred while creating this collection");if(k){if(k.readyState===0&&k.status===0){i+=": "+d("Galaxy could not be reached and may be updating.")+d(" Try again in a few minutes.")}else{if(k.responseJSON){i+="<br /><pre>"+JSON.stringify(k.responseJSON)+"</pre>"}else{i+=": "+j}}}creator._showAlert(i,"alert-danger")},render:function(h,i){this.$el.empty().html(e.templates.main());this._renderHeader(h);this._renderMiddle(h);this._renderFooter(h);this._addPluginComponents();return this},_renderHeader:function(i,j){var h=this.$(".header").empty().html(e.templates.header()).find(".help-content").prepend($(e.templates.helpContent()));this._renderFilters();return h},_renderFilters:function(){return this.$(".forward-column .column-header input").val(this.filters[0]).add(this.$(".reverse-column .column-header input").val(this.filters[1]))},_renderMiddle:function(i,j){var h=this.$(".middle").empty().html(e.templates.middle());if(this.unpairedPanelHidden){this.$(".unpaired-columns").hide()}else{if(this.pairedPanelHidden){this.$(".paired-columns").hide()}}this._renderUnpaired();this._renderPaired();return h},_renderUnpaired:function(m,n){var k=this,l,i,h=[],j=this._splitByFilters();this.$(".forward-column .title").text([j[0].length,d("unpaired forward")].join(" "));this.$(".forward-column .unpaired-info").text(this._renderUnpairedDisplayStr(this.unpaired.length-j[0].length));this.$(".reverse-column .title").text([j[1].length,d("unpaired reverse")].join(" "));this.$(".reverse-column .unpaired-info").text(this._renderUnpairedDisplayStr(this.unpaired.length-j[1].length));this.$(".unpaired-columns .column-datasets").empty();this.$(".autopair-link").toggle(this.unpaired.length!==0);if(this.unpaired.length===0){this._renderUnpairedEmpty();return}i=j[1].map(function(p,o){if((j[0][o]!==undefined)&&(j[0][o]!==p)){h.push(k._renderPairButton())}return k._renderUnpairedDataset(p)});l=j[0].map(function(o){return k._renderUnpairedDataset(o)});if(!l.length&&!i.length){this._renderUnpairedNotShown();return}this.$(".unpaired-columns .forward-column .column-datasets").append(l).add(this.$(".unpaired-columns .paired-column .column-datasets").append(h)).add(this.$(".unpaired-columns .reverse-column .column-datasets").append(i))},_renderUnpairedDisplayStr:function(h){return["(",h," ",d("filtered out"),")"].join("")},_renderUnpairedDataset:function(h){return $("<li/>").attr("id","dataset-"+h.id).addClass("dataset unpaired").attr("draggable",true).addClass(h.selected?"selected":"").append($("<span/>").addClass("dataset-name").text(h.name)).data("dataset",h)},_renderPairButton:function(){return $("<li/>").addClass("dataset unpaired").append($("<span/>").addClass("dataset-name").text(d("Pair these datasets")))},_renderUnpairedEmpty:function(){var h=$('<div class="empty-message"></div>').text("("+d("no remaining unpaired datasets")+")");this.$(".unpaired-columns .paired-column .column-datasets").empty().prepend(h);return h},_renderUnpairedNotShown:function(){var h=$('<div class="empty-message"></div>').text("("+d("no datasets were found matching the current filters")+")");this.$(".unpaired-columns .paired-column .column-datasets").empty().prepend(h);return h},_renderPaired:function(i,j){this.$(".paired-column-title .title").text([this.paired.length,d("paired")].join(" "));this.$(".unpair-all-link").toggle(this.paired.length!==0);if(this.paired.length===0){this._renderPairedEmpty();return}else{this.$(".remove-extensions-link").show()}this.$(".paired-columns .column-datasets").empty();var h=this;this.paired.forEach(function(m,k){var l=new f({pair:m});h.$(".paired-columns .column-datasets").append(l.render().$el).append(['<button class="unpair-btn">','<span class="fa fa-unlink" title="',d("Unpair"),'"></span>',"</button>"].join(""))})},_renderPairedEmpty:function(){var h=$('<div class="empty-message"></div>').text("("+d("no paired datasets yet")+")");this.$(".paired-columns .column-datasets").empty().prepend(h);return h},_renderFooter:function(i,j){var h=this.$(".footer").empty().html(e.templates.footer());this.$(".remove-extensions").prop("checked",this.removeExtensions);if(typeof this.oncancel==="function"){this.$(".cancel-create.btn").show()}return h},_addPluginComponents:function(){this._chooseFiltersPopover(".choose-filters-link");this.$(".help-content i").hoverhighlight(".collection-creator","rgba( 64, 255, 255, 1.0 )")},_chooseFiltersPopover:function(h){function i(l,k){return['<button class="filter-choice btn" ','data-forward="',l,'" data-reverse="',k,'">',d("Forward"),": ",l,", ",d("Reverse"),": ",k,"</button>"].join("")}var j=$(_.template(['<div class="choose-filters">','<div class="help">',d("Choose from the following filters to change which unpaired reads are shown in the display"),":</div>",i("_1","_2"),i("_R1","_R2"),"</div>"].join(""),{}));return this.$(h).popover({container:".collection-creator",placement:"bottom",html:true,content:j})},_validationWarning:function(i,h){var j="validation-warning";if(i==="name"){i=this.$(".collection-name").add(this.$(".collection-name-prompt"));this.$(".collection-name").focus().select()}if(h){i=i||this.$("."+j);i.removeClass(j)}else{i.addClass(j)}},_setUpBehaviors:function(){this.on("pair:new",function(){this._renderUnpaired();this._renderPaired();this.$(".paired-columns").scrollTop(8000000)});this.on("pair:unpair",function(h){this._renderUnpaired();this._renderPaired();this.splitView()});this.on("filter-change",function(){this.filters=[this.$(".forward-unpaired-filter input").val(),this.$(".reverse-unpaired-filter input").val()];this._renderFilters();this._renderUnpaired()});this.on("autopair",function(){this._renderUnpaired();this._renderPaired();var h,i=null;if(this.paired.length){i="alert-success";h=this.paired.length+" "+d("pairs created");if(!this.unpaired.length){h+=": "+d("all datasets have been successfully paired");this.hideUnpaired()}}else{h=d("Could not automatically create any pairs from the given dataset names")}this._showAlert(h,i)});return this},events:{"click .more-help":"_clickMoreHelp","click .less-help":"_clickLessHelp","click .header .alert button":"_hideAlert","click .forward-column .column-title":"_clickShowOnlyUnpaired","click .reverse-column .column-title":"_clickShowOnlyUnpaired","click .unpair-all-link":"_clickUnpairAll","change .forward-unpaired-filter input":function(h){this.trigger("filter-change")},"focus .forward-unpaired-filter input":function(h){$(h.currentTarget).select()},"click .autopair-link":"_clickAutopair","click .choose-filters .filter-choice":"_clickFilterChoice","click .clear-filters-link":"_clearFilters","change .reverse-unpaired-filter input":function(h){this.trigger("filter-change")},"focus .reverse-unpaired-filter input":function(h){$(h.currentTarget).select()},"click .forward-column .dataset.unpaired":"_clickUnpairedDataset","click .reverse-column .dataset.unpaired":"_clickUnpairedDataset","click .paired-column .dataset.unpaired":"_clickPairRow","click .unpaired-columns":"clearSelectedUnpaired","mousedown .unpaired-columns .dataset":"_mousedownUnpaired","click .paired-column-title":"_clickShowOnlyPaired","mousedown .flexible-partition-drag":"_startPartitionDrag","click .paired-columns .pair-name":"_clickPairName","click .unpair-btn":"_clickUnpair","change .remove-extensions":function(h){this.toggleExtensions()},"change .collection-name":"_changeName","click .cancel-create":function(h){if(typeof this.oncancel==="function"){this.oncancel.call(this)}},"click .create-collection":"_clickCreate"},_clickMoreHelp:function(h){this.$(".main-help").addClass("expanded");this.$(".more-help").hide()},_clickLessHelp:function(h){this.$(".main-help").removeClass("expanded");this.$(".more-help").show()},_showAlert:function(i,h){h=h||"alert-danger";this.$(".main-help").hide();this.$(".header .alert").attr("class","alert alert-dismissable").addClass(h).show().find(".alert-message").html(i)},_hideAlert:function(h){this.$(".main-help").show();this.$(".header .alert").hide()},_clickShowOnlyUnpaired:function(h){if(this.$(".paired-columns").is(":visible")){this.hidePaired()}else{this.splitView()}},_clickShowOnlyPaired:function(h){if(this.$(".unpaired-columns").is(":visible")){this.hideUnpaired()}else{this.splitView()}},hideUnpaired:function(h,i){h=h||0;this.$(".unpaired-columns").hide(h,i);this.$(".paired-columns").show(h).css("flex","1 0 auto");this.unpairedPanelHidden=true},hidePaired:function(h,i){h=h||0;this.$(".unpaired-columns").show(h).css("flex","1 0 auto");this.$(".paired-columns").hide(h,i);this.pairedPanelHidden=true},splitView:function(h,i){h=h||0;this.unpairedPanelHidden=this.pairedPanelHidden=false;this._renderMiddle(h);return this},_clickUnpairAll:function(h){this.unpairAll()},_clickAutopair:function(i){var h=this.autoPair();this.trigger("autopair",h)},_clickFilterChoice:function(i){var h=$(i.currentTarget);this.$(".forward-unpaired-filter input").val(h.data("forward"));this.$(".reverse-unpaired-filter input").val(h.data("reverse"));this._hideChooseFilters();this.trigger("filter-change")},_hideChooseFilters:function(){this.$(".choose-filters-link").popover("hide");this.$(".popover").css("display","none")},_clearFilters:function(h){this.$(".forward-unpaired-filter input").val("");this.$(".reverse-unpaired-filter input").val("");this.trigger("filter-change")},_clickUnpairedDataset:function(h){h.stopPropagation();return this.toggleSelectUnpaired($(h.currentTarget))},toggleSelectUnpaired:function(j,i){i=i||{};var k=j.data("dataset"),h=i.force!==undefined?i.force:!j.hasClass("selected");if(!j.size()||k===undefined){return j}if(h){j.addClass("selected");if(!i.waitToPair){this.pairAllSelected()}}else{j.removeClass("selected")}return j},pairAllSelected:function(i){i=i||{};var j=this,k=[],h=[],l=[];j.$(".unpaired-columns .forward-column .dataset.selected").each(function(){k.push($(this).data("dataset"))});j.$(".unpaired-columns .reverse-column .dataset.selected").each(function(){h.push($(this).data("dataset"))});k.length=h.length=Math.min(k.length,h.length);k.forEach(function(n,m){try{l.push(j._pair(n,h[m],{silent:true}))}catch(o){j.error(o)}});if(l.length&&!i.silent){this.trigger("pair:new",l)}return l},clearSelectedUnpaired:function(){this.$(".unpaired-columns .dataset.selected").removeClass("selected")},_mousedownUnpaired:function(j){if(j.shiftKey){var i=this,h=$(j.target).addClass("selected"),k=function(l){i.$(l.target).filter(".dataset").addClass("selected")};h.parent().on("mousemove",k);$(document).one("mouseup",function(l){h.parent().off("mousemove",k);i.pairAllSelected()})}},_clickPairRow:function(j){var k=$(j.currentTarget).index(),i=$(".unpaired-columns .forward-column .dataset").eq(k).data("dataset"),h=$(".unpaired-columns .reverse-column .dataset").eq(k).data("dataset");this._pair(i,h)},_startPartitionDrag:function(i){var h=this,l=i.pageY;$("body").css("cursor","ns-resize");h.$(".flexible-partition-drag").css("color","black");function k(m){h.$(".flexible-partition-drag").css("color","");$("body").css("cursor","").unbind("mousemove",j)}function j(m){var n=m.pageY-l;if(!h.adjPartition(n)){$("body").trigger("mouseup")}l+=n}$("body").mousemove(j);$("body").one("mouseup",k)},adjPartition:function(i){var h=this.$(".unpaired-columns"),j=this.$(".paired-columns"),k=parseInt(h.css("height"),10),l=parseInt(j.css("height"),10);k=Math.max(10,k+i);l=l-i;if(k<=10){if(!this.unpairedPanelHidden){this.hideUnpaired();return false}}else{if(this.unpairedPanelHidden){h.show();this.unpairedPanelHidden=false}}if(l<=15){if(!this.pairedPanelHidden){this.hidePaired();if(l<5){return false}}}else{if(this.pairedPanelHidden){j.show();this.pairedPanelHidden=false}}h.css({height:k+"px",flex:"0 0 auto"});return true},_clickPairName:function(j){var i=$(j.currentTarget),k=this.paired[i.parent().index()],h=prompt("Enter a new name for the pair:",k.name);if(h){k.name=h;k.customizedName=true;i.text(k.name)}},_clickUnpair:function(i){var h=Math.floor($(i.currentTarget).index()/2);this._unpair(this.paired[h])},toggleExtensions:function(i){var h=this;h.removeExtensions=(i!==undefined)?(i):(!h.removeExtensions);_.each(h.paired,function(j){if(j.customizedName){return}j.name=h._guessNameForPair(j.forward,j.reverse)});h._renderPaired();h._renderFooter()},_changeName:function(h){this._validationWarning("name",!!this._getName())},_getName:function(){return _.escape(this.$(".collection-name").val())},_clickCreate:function(i){var h=this._getName();if(!h){this._validationWarning("name")}else{this.createList()}},_printList:function(i){var h=this;_.each(i,function(j){if(i===h.paired){h._printPair(j)}else{}})},_printPair:function(h){this.debug(h.forward.name,h.reverse.name,": ->",h.name)},toString:function(){return"PairedCollectionCreator"}});e.templates=e.templates||{main:_.template(['<div class="header flex-row no-flex"></div>','<div class="middle flex-row flex-row-container"></div>','<div class="footer flex-row no-flex">'].join("")),header:_.template(['<div class="main-help well clear">','<a class="more-help" href="javascript:void(0);">',d("More help"),"</a>",'<div class="help-content">','<a class="less-help" href="javascript:void(0);">',d("Less"),"</a>","</div>","</div>",'<div class="alert alert-dismissable">','<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>','<span class="alert-message"></span>',"</div>",'<div class="column-headers vertically-spaced flex-column-container">','<div class="forward-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',d("Unpaired forward"),"</span>",'<span class="title-info unpaired-info"></span>',"</div>",'<div class="unpaired-filter forward-unpaired-filter pull-left">','<input class="search-query" placeholder="',d("Filter this list"),'" />',"</div>","</div>","</div>",'<div class="paired-column flex-column no-flex column">','<div class="column-header">','<a class="choose-filters-link" href="javascript:void(0)">',d("Choose filters"),"</a>",'<a class="clear-filters-link" href="javascript:void(0);">',d("Clear filters"),"</a><br />",'<a class="autopair-link" href="javascript:void(0);">',d("Auto-pair"),"</a>","</div>","</div>",'<div class="reverse-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',d("Unpaired reverse"),"</span>",'<span class="title-info unpaired-info"></span>',"</div>",'<div class="unpaired-filter reverse-unpaired-filter pull-left">','<input class="search-query" placeholder="',d("Filter this list"),'" />',"</div>","</div>","</div>","</div>"].join("")),middle:_.template(['<div class="unpaired-columns flex-column-container scroll-container flex-row">','<div class="forward-column flex-column column">','<ol class="column-datasets"></ol>',"</div>",'<div class="paired-column flex-column no-flex column">','<ol class="column-datasets"></ol>',"</div>",'<div class="reverse-column flex-column column">','<ol class="column-datasets"></ol>',"</div>","</div>",'<div class="flexible-partition">','<div class="flexible-partition-drag" title="',d("Drag to change"),'"></div>','<div class="column-header">','<div class="column-title paired-column-title">','<span class="title"></span>',"</div>",'<a class="unpair-all-link" href="javascript:void(0);">',d("Unpair all"),"</a>","</div>","</div>",'<div class="paired-columns flex-column-container scroll-container flex-row">','<ol class="column-datasets"></ol>',"</div>"].join("")),footer:_.template(['<div class="attributes clear">','<div class="clear">','<label class="remove-extensions-prompt pull-right">',d("Remove file extensions from pair names"),"?",'<input class="remove-extensions pull-right" type="checkbox" />',"</label>","</div>",'<div class="clear">','<input class="collection-name form-control pull-right" ','placeholder="',d("Enter a name for your new list"),'" />','<div class="collection-name-prompt pull-right">',d("Name"),":</div>","</div>","</div>",'<div class="actions clear vertically-spaced">','<div class="other-options pull-left">','<button class="cancel-create btn" tabindex="-1">',d("Cancel"),"</button>",'<div class="create-other btn-group dropup">','<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">',d("Create a different kind of collection"),' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">','<li><a href="#">',d("Create a <i>single</i> pair"),"</a></li>",'<li><a href="#">',d("Create a list of <i>unpaired</i> datasets"),"</a></li>","</ul>","</div>","</div>",'<div class="main-options pull-right">','<button class="create-collection btn btn-primary">',d("Create list"),"</button>","</div>","</div>"].join("")),helpContent:_.template(["<p>",d(["Collections of paired datasets are ordered lists of dataset pairs (often forward and reverse reads). ","These collections can be passed to tools and workflows in order to have analyses done on each member of ","the entire group. This interface allows you to create a collection, choose which datasets are paired, ","and re-order the final collection."].join("")),"</p>","<p>",d(['Unpaired datasets are shown in the <i data-target=".unpaired-columns">unpaired section</i> ',"(hover over the underlined words to highlight below). ",'Paired datasets are shown in the <i data-target=".paired-columns">paired section</i>.',"<ul>To pair datasets, you can:","<li>Click a dataset in the ",'<i data-target=".unpaired-columns .forward-column .column-datasets,','.unpaired-columns .forward-column">forward column</i> ',"to select it then click a dataset in the ",'<i data-target=".unpaired-columns .reverse-column .column-datasets,','.unpaired-columns .reverse-column">reverse column</i>.',"</li>",'<li>Click one of the "Pair these datasets" buttons in the ','<i data-target=".unpaired-columns .paired-column .column-datasets,','.unpaired-columns .paired-column">middle column</i> ',"to pair the datasets in a particular row.","</li>",'<li>Click <i data-target=".autopair-link">"Auto-pair"</i> ',"to have your datasets automatically paired based on name.","</li>","</ul>"].join("")),"</p>","<p>",d(["<ul>You can filter what is shown in the unpaired sections by:","<li>Entering partial dataset names in either the ",'<i data-target=".forward-unpaired-filter input">forward filter</i> or ','<i data-target=".reverse-unpaired-filter input">reverse filter</i>.',"</li>","<li>Choosing from a list of preset filters by clicking the ",'<i data-target=".choose-filters-link">"Choose filters" link</i>.',"</li>","<li>Entering regular expressions to match dataset names. See: ",'<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expres..."',' target="_blank">MDN\'s JavaScript Regular Expression Tutorial</a>. ',"Note: forward slashes (\\) are not needed.","</li>","<li>Clearing the filters by clicking the ",'<i data-target=".clear-filters-link">"Clear filters" link</i>.',"</li>","</ul>"].join("")),"</p>","<p>",d(["To unpair individual dataset pairs, click the ",'<i data-target=".unpair-btn">unpair buttons ( <span class="fa fa-unlink"></span> )</i>. ','Click the <i data-target=".unpair-all-link">"Unpair all" link</i> to unpair all pairs.'].join("")),"</p>","<p>",d(['You can include or remove the file extensions (e.g. ".fastq") from your pair names by toggling the ','<i data-target=".remove-extensions-prompt">"Remove file extensions from pair names?"</i> control.'].join("")),"</p>","<p>",d(['Once your collection is complete, enter a <i data-target=".collection-name">name</i> and ','click <i data-target=".create-collection">"Create list"</i>. ',"(Note: you do not have to pair all unpaired datasets to finish.)"].join("")),"</p>"].join(""))};(function(){jQuery.fn.extend({hoverhighlight:function h(j,i){j=j||"body";if(!this.size()){return this}$(this).each(function(){var l=$(this),k=l.data("target");if(k){l.mouseover(function(m){$(k,j).css({background:i})}).mouseout(function(m){$(k).css({background:""})})}});return this}})}());var b=function c(j,h){h=_.defaults(h||{},{datasets:j,oncancel:function(){Galaxy.modal.hide()},oncreate:function(){Galaxy.modal.hide();Galaxy.currHistoryPanel.refreshContents()}});if(!window.Galaxy||!Galaxy.modal){throw new Error("Galaxy or Galaxy.modal not found")}var i=new e(h).render();Galaxy.modal.show({title:"Create a collection of paired datasets",body:i.$el,width:"80%",height:"800px",closing_events:true});window.PCC=i;return i};return{PairedCollectionCreator:e,pairedCollectionCreatorModal:b}}); \ No newline at end of file diff -r ece8ef90a8289399bf9faca6a3265696da7e0beb -r 7c566a68d2d07375c53006191671dfed04332f55 static/scripts/packed/mvc/history/history-panel-edit.js --- a/static/scripts/packed/mvc/history/history-panel-edit.js +++ b/static/scripts/packed/mvc/history/history-panel-edit.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-panel","mvc/history/history-contents","mvc/dataset/states","mvc/history/hda-model","mvc/history/hda-li-edit","mvc/history/hdca-li-edit","mvc/tags","mvc/annotations","utils/localization"],function(f,h,k,d,c,g,j,a,b){var i=f.ReadOnlyHistoryPanel;var e=i.extend({HDAViewClass:c.HDAListItemEdit,HDCAViewClass:g.HDCAListItemEdit,initialize:function(l){l=l||{};this.selectedHdaIds=[];this.lastSelectedViewId=null;this.tagsEditor=null;this.annotationEditor=null;this.purgeAllowed=l.purgeAllowed||false;this.selecting=l.selecting||false;this.annotationEditorShown=l.annotationEditorShown||false;this.tagsEditorShown=l.tagsEditorShown||false;i.prototype.initialize.call(this,l)},_setUpModelEventHandlers:function(){i.prototype._setUpModelEventHandlers.call(this);this.model.on("change:nice_size",this.updateHistoryDiskSize,this);this.model.contents.on("change:deleted",this._handleHdaDeletionChange,this);this.model.contents.on("change:visible",this._handleHdaVisibleChange,this);this.model.contents.on("change:purged",function(l){this.model.fetch()},this)},renderModel:function(){var l=$("<div/>");l.append(e.templates.historyPanel(this.model.toJSON()));this.$emptyMessage(l).text(this.emptyMsg);if(Galaxy&&Galaxy.currUser&&Galaxy.currUser.id&&Galaxy.currUser.id===this.model.get("user_id")){this._renderTags(l);this._renderAnnotation(l)}l.find(".history-secondary-actions").prepend(this._renderSelectButton());l.find(".history-dataset-actions").toggle(this.selecting);l.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(l);this.renderHdas(l);return l},_renderTags:function(l){var m=this;this.tagsEditor=new j.TagsEditor({model:this.model,el:l.find(".history-controls .tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){m.toggleHDATagEditors(true,m.fxSpeed)},onhide:function(){m.toggleHDATagEditors(false,m.fxSpeed)},$activator:faIconButton({title:b("Edit history tags"),classes:"history-tag-btn",faIcon:"fa-tags"}).appendTo(l.find(".history-secondary-actions"))})},_renderAnnotation:function(l){var m=this;this.annotationEditor=new a.AnnotationEditor({model:this.model,el:l.find(".history-controls .annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){m.toggleHDAAnnotationEditors(true,m.fxSpeed)},onhide:function(){m.toggleHDAAnnotationEditors(false,m.fxSpeed)},$activator:faIconButton({title:b("Edit history annotation"),classes:"history-annotate-btn",faIcon:"fa-comment"}).appendTo(l.find(".history-secondary-actions"))})},_renderSelectButton:function(l){return faIconButton({title:b("Operations on multiple datasets"),classes:"history-select-btn",faIcon:"fa-check-square-o"})},_setUpBehaviours:function(l){l=l||this.$el;i.prototype._setUpBehaviours.call(this,l);if(!this.model){return}this._setUpDatasetActionsPopup(l);if((!Galaxy.currUser||Galaxy.currUser.isAnonymous())||(Galaxy.currUser.id!==this.model.get("user_id"))){return}var m=this;l.find(".history-name").attr("title",b("Click to rename history")).tooltip({placement:"bottom"}).make_text_editable({on_finish:function(n){var o=m.model.get("name");if(n&&n!==o){m.$el.find(".history-name").text(n);m.model.save({name:n}).fail(function(){m.$el.find(".history-name").text(m.model.previous("name"))})}else{m.$el.find(".history-name").text(o)}}})},_setUpDatasetActionsPopup:function(l){var m=this,n=[{html:b("Hide datasets"),func:function(){var o=d.HistoryDatasetAssociation.prototype.hide;m.getSelectedHdaCollection().ajaxQueue(o)}},{html:b("Unhide datasets"),func:function(){var o=d.HistoryDatasetAssociation.prototype.unhide;m.getSelectedHdaCollection().ajaxQueue(o)}},{html:b("Delete datasets"),func:function(){var o=d.HistoryDatasetAssociation.prototype["delete"];m.getSelectedHdaCollection().ajaxQueue(o)}},{html:b("Undelete datasets"),func:function(){var o=d.HistoryDatasetAssociation.prototype.undelete;m.getSelectedHdaCollection().ajaxQueue(o)}}];if(m.purgeAllowed){n.push({html:b("Permanently delete datasets"),func:function(){if(confirm(b("This will permanently remove the data in your datasets. Are you sure?"))){var o=d.HistoryDatasetAssociation.prototype.purge;m.getSelectedHdaCollection().ajaxQueue(o)}}})}n.push({html:b("Build Dataset List (Experimental)"),func:function(){m.getSelectedHdaCollection().promoteToHistoryDatasetCollection(m.model,"list")}});n.push({html:b("Build Dataset Pair (Experimental)"),func:function(){m.getSelectedHdaCollection().promoteToHistoryDatasetCollection(m.model,"paired")}});n.push({html:b("Build List of Dataset Pairs (Experimental)"),func:_.bind(m._showPairedCollectionModal,m)});return new PopupMenu(l.find(".history-dataset-action-popup-btn"),n)},_showPairedCollectionModal:function(){var l=this,m=l.getSelectedHdaCollection().toJSON().filter(function(n){return n.history_content_type==="dataset"&&n.state===k.OK});if(m.length){require(["mvc/collection/paired-collection-creator"],function(n){window.creator=n.pairedCollectionCreatorModal(m,{historyId:l.model.id})})}else{}},_handleHdaDeletionChange:function(l){if(l.get("deleted")&&!this.storage.get("show_deleted")){this.removeHdaView(this.hdaViews[l.id])}},_handleHdaVisibleChange:function(l){if(l.hidden()&&!this.storage.get("show_hidden")){this.removeHdaView(this.hdaViews[l.id])}},_getContentOptions:function(m){var l=i.prototype._getContentOptions.call(this,m);_.extend(l,{selectable:this.selecting,purgeAllowed:this.purgeAllowed,tagsEditorShown:(this.tagsEditor&&!this.tagsEditor.hidden),annotationEditorShown:(this.annotationEditor&&!this.annotationEditor.hidden)});return l},_setUpHdaListeners:function(m){var l=this;i.prototype._setUpHdaListeners.call(this,m);m.on("selected",function(p,o){if(!o){return}var n=[];if((o.shiftKey)&&(l.lastSelectedViewId&&_.has(l.hdaViews,l.lastSelectedViewId))){var r=l.hdaViews[l.lastSelectedViewId];n=l.selectDatasetRange(p,r).map(function(s){return s.model.id})}else{var q=p.model.id;l.lastSelectedViewId=q;n=[q]}l.selectedHdaIds=_.union(l.selectedHdaIds,n)});m.on("de-selected",function(o,n){var p=o.model.id;l.selectedHdaIds=_.without(l.selectedHdaIds,p)})},toggleHDATagEditors:function(l){var m=arguments;_.each(this.hdaViews,function(n){if(n.tagsEditor){n.tagsEditor.toggle.apply(n.tagsEditor,m)}})},toggleHDAAnnotationEditors:function(l){var m=arguments;_.each(this.hdaViews,function(n){if(n.annotationEditor){n.annotationEditor.toggle.apply(n.annotationEditor,m)}})},removeHdaView:function(m){if(!m){return}var l=this;m.$el.fadeOut(l.fxSpeed,function(){m.off();m.remove();delete l.hdaViews[m.model.id];if(_.isEmpty(l.hdaViews)){l.trigger("empty-history",l);l._renderEmptyMsg()}})},events:_.extend(_.clone(i.prototype.events),{"click .history-select-btn":"toggleSelectors","click .history-select-all-datasets-btn":"selectAllDatasets","click .history-deselect-all-datasets-btn":"deselectAllDatasets"}),updateHistoryDiskSize:function(){this.$el.find(".history-size").text(this.model.get("nice_size"))},showSelectors:function(l){l=(l!==undefined)?(l):(this.fxSpeed);this.selecting=true;this.$(".history-dataset-actions").slideDown(l);_.each(this.hdaViews,function(m){m.showSelector()});this.selectedHdaIds=[];this.lastSelectedViewId=null},hideSelectors:function(l){l=(l!==undefined)?(l):(this.fxSpeed);this.selecting=false;this.$(".history-dataset-actions").slideUp(l);_.each(this.hdaViews,function(m){m.hideSelector()});this.selectedHdaIds=[];this.lastSelectedViewId=null},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAllDatasets:function(l){_.each(this.hdaViews,function(m){m.select(l)})},deselectAllDatasets:function(l){this.lastSelectedViewId=null;_.each(this.hdaViews,function(m){m.deselect(l)})},selectDatasetRange:function(n,m){var l=this.hdaViewRange(n,m);_.each(l,function(o){o.select()});return l},getSelectedHdaViews:function(){return _.filter(this.hdaViews,function(l){return l.selected})},getSelectedHdaCollection:function(){return new h.HistoryContents(_.map(this.getSelectedHdaViews(),function(l){return l.model}),{historyId:this.model.id})},toString:function(){return"HistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});return{HistoryPanel:e}}); \ No newline at end of file +define(["mvc/history/history-panel","mvc/history/history-contents","mvc/dataset/states","mvc/history/hda-model","mvc/history/hda-li-edit","mvc/history/hdca-li-edit","mvc/tags","mvc/annotations","utils/localization"],function(f,h,k,d,c,g,j,a,b){var i=f.ReadOnlyHistoryPanel;var e=i.extend({HDAViewClass:c.HDAListItemEdit,HDCAViewClass:g.HDCAListItemEdit,initialize:function(l){l=l||{};this.selectedHdaIds=[];this.lastSelectedViewId=null;this.tagsEditor=null;this.annotationEditor=null;this.purgeAllowed=l.purgeAllowed||false;this.selecting=l.selecting||false;this.annotationEditorShown=l.annotationEditorShown||false;this.tagsEditorShown=l.tagsEditorShown||false;i.prototype.initialize.call(this,l)},_setUpModelEventHandlers:function(){i.prototype._setUpModelEventHandlers.call(this);this.model.on("change:nice_size",this.updateHistoryDiskSize,this);this.model.contents.on("change:deleted",this._handleHdaDeletionChange,this);this.model.contents.on("change:visible",this._handleHdaVisibleChange,this);this.model.contents.on("change:purged",function(l){this.model.fetch()},this)},renderModel:function(){var l=$("<div/>");l.append(e.templates.historyPanel(this.model.toJSON()));this.$emptyMessage(l).text(this.emptyMsg);if(Galaxy&&Galaxy.currUser&&Galaxy.currUser.id&&Galaxy.currUser.id===this.model.get("user_id")){this._renderTags(l);this._renderAnnotation(l)}l.find(".history-secondary-actions").prepend(this._renderSelectButton());l.find(".history-dataset-actions").toggle(this.selecting);l.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(l);this.renderHdas(l);return l},_renderTags:function(l){var m=this;this.tagsEditor=new j.TagsEditor({model:this.model,el:l.find(".history-controls .tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){m.toggleHDATagEditors(true,m.fxSpeed)},onhide:function(){m.toggleHDATagEditors(false,m.fxSpeed)},$activator:faIconButton({title:b("Edit history tags"),classes:"history-tag-btn",faIcon:"fa-tags"}).appendTo(l.find(".history-secondary-actions"))})},_renderAnnotation:function(l){var m=this;this.annotationEditor=new a.AnnotationEditor({model:this.model,el:l.find(".history-controls .annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){m.toggleHDAAnnotationEditors(true,m.fxSpeed)},onhide:function(){m.toggleHDAAnnotationEditors(false,m.fxSpeed)},$activator:faIconButton({title:b("Edit history annotation"),classes:"history-annotate-btn",faIcon:"fa-comment"}).appendTo(l.find(".history-secondary-actions"))})},_renderSelectButton:function(l){return faIconButton({title:b("Operations on multiple datasets"),classes:"history-select-btn",faIcon:"fa-check-square-o"})},_setUpBehaviours:function(l){l=l||this.$el;i.prototype._setUpBehaviours.call(this,l);if(!this.model){return}this.actionsPopup=this._setUpDatasetActionsPopup(l);if((!Galaxy.currUser||Galaxy.currUser.isAnonymous())||(Galaxy.currUser.id!==this.model.get("user_id"))){return}var m=this;l.find(".history-name").attr("title",b("Click to rename history")).tooltip({placement:"bottom"}).make_text_editable({on_finish:function(n){var o=m.model.get("name");if(n&&n!==o){m.$el.find(".history-name").text(n);m.model.save({name:n}).fail(function(){m.$el.find(".history-name").text(m.model.previous("name"))})}else{m.$el.find(".history-name").text(o)}}})},_setUpDatasetActionsPopup:function(l){var m=this,n=[{html:b("Hide datasets"),func:function(){var o=d.HistoryDatasetAssociation.prototype.hide;m.getSelectedHdaCollection().ajaxQueue(o)}},{html:b("Unhide datasets"),func:function(){var o=d.HistoryDatasetAssociation.prototype.unhide;m.getSelectedHdaCollection().ajaxQueue(o)}},{html:b("Delete datasets"),func:function(){var o=d.HistoryDatasetAssociation.prototype["delete"];m.getSelectedHdaCollection().ajaxQueue(o)}},{html:b("Undelete datasets"),func:function(){var o=d.HistoryDatasetAssociation.prototype.undelete;m.getSelectedHdaCollection().ajaxQueue(o)}}];if(m.purgeAllowed){n.push({html:b("Permanently delete datasets"),func:function(){if(confirm(b("This will permanently remove the data in your datasets. Are you sure?"))){var o=d.HistoryDatasetAssociation.prototype.purge;m.getSelectedHdaCollection().ajaxQueue(o)}}})}n.push({html:b("Build Dataset List (Experimental)"),func:function(){m.getSelectedHdaCollection().promoteToHistoryDatasetCollection(m.model,"list")}});n.push({html:b("Build Dataset Pair (Experimental)"),func:function(){m.getSelectedHdaCollection().promoteToHistoryDatasetCollection(m.model,"paired")}});n.push({html:b("Build List of Dataset Pairs (Experimental)"),func:_.bind(m._showPairedCollectionModal,m)});return new PopupMenu(l.find(".history-dataset-action-popup-btn"),n)},_showPairedCollectionModal:function(){var l=this,m=l.getSelectedHdaCollection().toJSON().filter(function(n){return n.history_content_type==="dataset"&&n.state===k.OK});if(m.length){require(["mvc/collection/paired-collection-creator"],function(n){window.creator=n.pairedCollectionCreatorModal(m,{historyId:l.model.id})})}else{}},_handleHdaDeletionChange:function(l){if(l.get("deleted")&&!this.storage.get("show_deleted")){this.removeHdaView(this.hdaViews[l.id])}},_handleHdaVisibleChange:function(l){if(l.hidden()&&!this.storage.get("show_hidden")){this.removeHdaView(this.hdaViews[l.id])}},_getContentOptions:function(m){var l=i.prototype._getContentOptions.call(this,m);_.extend(l,{selectable:this.selecting,purgeAllowed:this.purgeAllowed,tagsEditorShown:(this.tagsEditor&&!this.tagsEditor.hidden),annotationEditorShown:(this.annotationEditor&&!this.annotationEditor.hidden)});return l},_setUpHdaListeners:function(m){var l=this;i.prototype._setUpHdaListeners.call(this,m);m.on("selected",function(p,o){if(!o){return}var n=[];if((o.shiftKey)&&(l.lastSelectedViewId&&_.has(l.hdaViews,l.lastSelectedViewId))){var r=l.hdaViews[l.lastSelectedViewId];n=l.selectDatasetRange(p,r).map(function(s){return s.model.id})}else{var q=p.model.id;l.lastSelectedViewId=q;n=[q]}l.selectedHdaIds=_.union(l.selectedHdaIds,n)});m.on("de-selected",function(o,n){var p=o.model.id;l.selectedHdaIds=_.without(l.selectedHdaIds,p)})},toggleHDATagEditors:function(l){var m=arguments;_.each(this.hdaViews,function(n){if(n.tagsEditor){n.tagsEditor.toggle.apply(n.tagsEditor,m)}})},toggleHDAAnnotationEditors:function(l){var m=arguments;_.each(this.hdaViews,function(n){if(n.annotationEditor){n.annotationEditor.toggle.apply(n.annotationEditor,m)}})},removeHdaView:function(m){if(!m){return}var l=this;m.$el.fadeOut(l.fxSpeed,function(){m.off();m.remove();delete l.hdaViews[m.model.id];if(_.isEmpty(l.hdaViews)){l.trigger("empty-history",l);l._renderEmptyMsg()}})},events:_.extend(_.clone(i.prototype.events),{"click .history-select-btn":"toggleSelectors","click .history-select-all-datasets-btn":"selectAllDatasets","click .history-deselect-all-datasets-btn":"deselectAllDatasets"}),updateHistoryDiskSize:function(){this.$el.find(".history-size").text(this.model.get("nice_size"))},showSelectors:function(l){l=(l!==undefined)?(l):(this.fxSpeed);this.selecting=true;this.$(".history-dataset-actions").slideDown(l);_.each(this.hdaViews,function(m){m.showSelector()});this.selectedHdaIds=[];this.lastSelectedViewId=null},hideSelectors:function(l){l=(l!==undefined)?(l):(this.fxSpeed);this.selecting=false;this.$(".history-dataset-actions").slideUp(l);_.each(this.hdaViews,function(m){m.hideSelector()});this.selectedHdaIds=[];this.lastSelectedViewId=null},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAllDatasets:function(l){_.each(this.hdaViews,function(m){m.select(l)})},deselectAllDatasets:function(l){this.lastSelectedViewId=null;_.each(this.hdaViews,function(m){m.deselect(l)})},selectDatasetRange:function(n,m){var l=this.hdaViewRange(n,m);_.each(l,function(o){o.select()});return l},getSelectedHdaViews:function(){return _.filter(this.hdaViews,function(l){return l.selected})},getSelectedHdaCollection:function(){return new h.HistoryContents(_.map(this.getSelectedHdaViews(),function(l){return l.model}),{historyId:this.model.id})},toString:function(){return"HistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});return{HistoryPanel:e}}); \ No newline at end of file diff -r ece8ef90a8289399bf9faca6a3265696da7e0beb -r 7c566a68d2d07375c53006191671dfed04332f55 static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -1851,23 +1851,27 @@ .collection-creator .header .column-headers .column-header .unpaired-filter{width:100%}.collection-creator .header .column-headers .column-header .unpaired-filter .search-query{width:100%;height:22px} .collection-creator .header .paired-column a:not(:last-child){margin-right:8px} .collection-creator .header .reverse-column .column-title{text-align:right} -.collection-creator .unpaired-columns,.collection-creator .paired-columns{height:0;border:1px solid lightgrey;border-width:1px 0 1px 0;padding:4px} +.collection-creator .unpaired-columns,.collection-creator .paired-columns{height:0;border:1px solid lightgrey;border-width:1px 0 1px 0} .collection-creator .paired-columns{margin-bottom:8px} -.collection-creator .column-datasets{list-style:none;overflow:hidden}.collection-creator .column-datasets .dataset{height:32px;margin-bottom:2px;border:1px solid lightgrey;border-radius:3px;padding:0 8px 0 8px;line-height:28px;cursor:pointer;overflow:hidden}.collection-creator .column-datasets .dataset:last-child{margin-bottom:4px} -.collection-creator .unpaired-columns .dataset.unpaired{border-color:grey}.collection-creator .unpaired-columns .dataset.unpaired:hover{border-color:black} +.collection-creator .column-datasets{list-style:none;overflow:hidden}.collection-creator .column-datasets .dataset{height:32px;margin-bottom:2px;border:1px solid lightgrey;border-radius:3px;padding:0 8px 0 8px;line-height:28px;cursor:pointer}.collection-creator .column-datasets .dataset:last-child{margin-bottom:4px} +.collection-creator .unpaired-columns .dataset.unpaired{margin-top:2px;border-color:grey}.collection-creator .unpaired-columns .dataset.unpaired:hover{border-color:black} .collection-creator .unpaired-columns .dataset.unpaired.selected{border-color:black;background:black;color:white} .collection-creator .unpaired-columns .forward-column .dataset.unpaired{margin-right:32px} .collection-creator .unpaired-columns .paired-column .dataset.unpaired{border-color:lightgrey;color:lightgrey}.collection-creator .unpaired-columns .paired-column .dataset.unpaired:hover{border-color:black;color:black} .collection-creator .unpaired-columns .reverse-column .dataset.unpaired{text-align:right;margin-left:32px} -.collection-creator .flexible-partition .flexible-partition-drag{width:100%;height:8px;cursor:ns-resize}.collection-creator .flexible-partition .flexible-partition-drag:hover{background:lightgrey} +.collection-creator .flexible-partition .flexible-partition-drag{width:100%;height:8px;cursor:ns-resize;line-height:2px;text-align:center;color:lightgrey}.collection-creator .flexible-partition .flexible-partition-drag:before{content:'...'} +.collection-creator .flexible-partition .flexible-partition-drag:hover{background:lightgrey;color:black} .collection-creator .flexible-partition .column-header{width:100%;text-align:center}.collection-creator .flexible-partition .column-header .column-title{display:inline} .collection-creator .flexible-partition .column-header>*:not(:last-child){margin-right:8px} .collection-creator .flexible-partition .column-header .remove-extensions-link{display:none} -.collection-creator .paired-columns .dataset.paired{background:#AFF1AF;border-color:grey;border-width:2px}.collection-creator .paired-columns .dataset.paired:hover,.collection-creator .paired-columns .dataset.paired.emphasized{border-color:black} -.collection-creator .paired-columns .forward-column .dataset.paired{margin-left:32px;border-radius:3px 0 0 3px;border-right-color:grey;border-right-width:1px;text-align:right}.collection-creator .paired-columns .forward-column .dataset.paired:after{margin-left:8px;font-family:FontAwesome;content:'\f061'} -.collection-creator .paired-columns .paired-column .dataset.paired{border-radius:0;border-width:2px 0 2px 0}.collection-creator .paired-columns .paired-column .dataset.paired .dataset-name:hover{text-decoration:underline} -.collection-creator .paired-columns .reverse-column .dataset.paired{margin-right:32px;border-radius:0 3px 3px 0;border-left-color:grey;border-left-width:1px}.collection-creator .paired-columns .reverse-column .dataset.paired:before{margin-right:8px;font-family:FontAwesome;content:'\f060'} -.collection-creator .paired-columns .reverse-column .unpair-btn{float:right;margin-top:-34px;width:31px;height:32px;border-color:transparent;background:transparent;font-size:120%}.collection-creator .paired-columns .reverse-column .unpair-btn:hover{border-color:#BFBFBF;background:#DEDEDE} +.collection-creator .paired-columns .column-datasets{width:100%;overflow:auto}.collection-creator .paired-columns .column-datasets .dataset.paired{margin:0px 34px 2px 34px;border-radius:3px;border:2px solid grey;background:#AFF1AF}.collection-creator .paired-columns .column-datasets .dataset.paired:first-child{margin-top:2px} +.collection-creator .paired-columns .column-datasets .dataset.paired:hover,.collection-creator .paired-columns .column-datasets .dataset.paired.emphasized{border-color:black} +.collection-creator .paired-columns .column-datasets .dataset.paired span{display:inline-block;overflow:hidden} +.collection-creator .paired-columns .column-datasets .dataset.paired .forward-dataset-name{text-align:right;border-right:1px solid grey;padding-right:8px}.collection-creator .paired-columns .column-datasets .dataset.paired .forward-dataset-name:after{margin-left:8px;font-family:FontAwesome;content:'\f061'} +.collection-creator .paired-columns .column-datasets .dataset.paired .pair-name{display:inline-block;text-align:center}.collection-creator .paired-columns .column-datasets .dataset.paired .pair-name:hover{text-decoration:underline} +.collection-creator .paired-columns .column-datasets .dataset.paired .reverse-dataset-name{display:inline-block;border-left:1px solid grey;padding-left:8px}.collection-creator .paired-columns .column-datasets .dataset.paired .reverse-dataset-name:before{margin-right:8px;font-family:FontAwesome;content:'\f060'} +.collection-creator .paired-columns .unpair-btn{float:right;margin-top:-34px;width:31px;height:32px;border-color:transparent;background:transparent;font-size:120%}.collection-creator .paired-columns .unpair-btn:hover{border-color:#BFBFBF;background:#DEDEDE} +.collection-creator .paired-columns .empty-message{text-align:center} .collection-creator .footer{padding-bottom:8px}.collection-creator .footer .attributes .remove-extensions-prompt{line-height:32px}.collection-creator .footer .attributes .remove-extensions-prompt .remove-extensions{display:inline-block;width:24px;height:24px} .collection-creator .footer .attributes .collection-name-prompt{margin:5px 4px 0 0} .collection-creator .footer .attributes .collection-name-prompt.validation-warning:before{content:'(required)';margin-right:4px;color:red} diff -r ece8ef90a8289399bf9faca6a3265696da7e0beb -r 7c566a68d2d07375c53006191671dfed04332f55 static/style/src/less/ui/paired-collection-creator.less --- a/static/style/src/less/ui/paired-collection-creator.less +++ b/static/style/src/less/ui/paired-collection-creator.less @@ -221,8 +221,6 @@ border: 1px solid lightgrey; border-width: 1px 0 1px 0; - //overflow-y: auto; - padding: 4px; } // ------------------------------------------------------------------------ unpaired .paired-columns { @@ -243,7 +241,7 @@ padding: 0 8px 0 8px; line-height: 28px; cursor: pointer; - overflow: hidden; + //overflow: hidden; &:last-child { margin-bottom: 4px; } @@ -253,6 +251,7 @@ // ---- unpaired .unpaired-columns { .dataset.unpaired { + margin-top: 2px; border-color: grey; &:hover { border-color: black; @@ -292,8 +291,15 @@ width: 100%; height: 8px; cursor: ns-resize; + &:before { + content: '...'; + } + line-height: 2px; + text-align: center; + color: lightgrey; &:hover { background: lightgrey; + color: black; } } .column-header { @@ -313,65 +319,76 @@ // ---- paired datasets .paired-columns { - .dataset.paired { - background: #AFF1AF; - border-color: grey; - border-width: 2px; - &:hover, - &.emphasized { - border-color: black; - } - } - .forward-column { + .column-datasets { + width: 100%; + overflow: auto; + .dataset.paired { - margin-left: 32px; - border-radius: 3px 0 0 3px; - border-right-color: grey; - border-right-width: 1px; - text-align: right; - &:after { - margin-left: 8px; - font-family: FontAwesome; - content: '\f061'; + &:first-child { + margin-top: 2px; + } + margin: 0px 34px 2px 34px; + + border-radius: 3px; + border: 2px solid grey; + + background: #AFF1AF; + + &:hover, + &.emphasized { + border-color: black; + } + + span { + display: inline-block; + overflow: hidden; + } + .forward-dataset-name { + text-align: right; + border-right: 1px solid grey; + padding-right: 8px; + &:after { + margin-left: 8px; + font-family: FontAwesome; + content: '\f061'; + } + } + .pair-name { + display: inline-block; + text-align: center; + &:hover { + text-decoration: underline; + } + } + .reverse-dataset-name { + display: inline-block; + border-left: 1px solid grey; + padding-left: 8px; + &:before { + margin-right: 8px; + font-family: FontAwesome; + content: '\f060'; + } } } } - .paired-column { - .dataset.paired { - border-radius: 0; - border-width: 2px 0 2px 0; - .dataset-name:hover { - text-decoration: underline; - } + .unpair-btn { + float: right; + margin-top: -34px; + width: 31px; + height: 32px; + //z-index: 1; + border-color: transparent; + //border-color: #BFBFBF; + background: transparent; + font-size: 120%; + &:hover { + border-color: #BFBFBF; + background: #DEDEDE; } } - .reverse-column { - .dataset.paired { - margin-right: 32px; - border-radius: 0 3px 3px 0; - border-left-color: grey; - border-left-width: 1px; - &:before { - margin-right: 8px; - font-family: FontAwesome; - content: '\f060'; - } - } - .unpair-btn { - float: right; - margin-top: -34px; - width: 31px; - height: 32px; - //z-index: 1; - border-color: transparent; - //border-color: #BFBFBF; - background: transparent; - font-size: 120%; - &:hover { - border-color: #BFBFBF; - background: #DEDEDE; - } - } + .empty-message { + text-align: center; } } Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org