1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/08580f127c03/ Changeset: 08580f127c03 User: carlfeberhard Date: 2014-08-13 19:43:09 Summary: Paired collection creator: better notifications, style tweaks Affected #: 6 files diff -r 3e7e8a3f1b7085a6a1b6beea0ca40260fa7287d7 -r 08580f127c031810c14c23e622700185ea582ccd 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 @@ -1,7 +1,8 @@ define([ + "utils/levenshtein", "mvc/base-mvc", "utils/localization" -], function( baseMVC, _l ){ +], function( levelshteinDistance, baseMVC, _l ){ //============================================================================= /** An interface for building collections of paired datasets. */ @@ -600,7 +601,10 @@ 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; } // create the dataset dom arrays @@ -615,10 +619,15 @@ $fwd = split[0].map( function( dataset ){ return creator._renderUnpairedDataset( dataset ); }); + + if( !$fwd.length && !$rev.length ){ + this._renderUnpairedNotShown(); + return; + } // add to appropo cols //TODO: not the best way to render this.$( '.unpaired-columns .column-datasets' ).empty(); - return this.$( '.unpaired-columns .forward-column .column-datasets' ).append( $fwd ) + 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 ) ); }, @@ -652,6 +661,14 @@ this.$( '.unpaired-columns .paired-column .column-datasets' ).prepend( $msg ); return $msg; }, + /** a message to display when no unpaired can be shown with the current filters */ + _renderUnpairedNotShown : function(){ + //console.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' ).prepend( $msg ); + return $msg; + }, /** render the paired section and update counts of paired datasets */ _renderPaired : function( speed, callback ){ @@ -774,6 +791,7 @@ //TODO: ideally only re-render the columns (or even elements) involved this._renderUnpaired(); this._renderPaired(); + this.splitView(); }); this.on( 'filter-change', function(){ @@ -788,6 +806,19 @@ this.on( 'autopair', function(){ this._renderUnpaired(); this._renderPaired(); + + var message, msgClass = null; + if( this.paired.length ){ + msgClass = 'alert-success'; + message = this.paired.length + ' ' + _l( 'pairs created' ); + if( !this.unpaired.length ){ + message += ': ' + _l( 'all datasets have been successfully paired' ); + this.hideUnpaired(); + } + } else { + message = _l( 'Could not automatically create any pairs from the given dataset names' ); + } + this._showAlert( message, msgClass ); }); //this.on( 'all', function(){ @@ -840,14 +871,12 @@ // ........................................................................ header /** expand help */ _clickMoreHelp : function( ev ){ - this.$( '.main-help' ).css( 'max-height', 'none' ); - this.$( '.main-help .help-content p:first-child' ).css( 'white-space', 'normal' ); + this.$( '.main-help' ).addClass( 'expanded' ); this.$( '.more-help' ).hide(); }, /** collapse help */ _clickLessHelp : function( ev ){ - this.$( '.main-help' ).css( 'max-height', '' ); - this.$( '.main-help .help-content p:first-child' ).css( 'white-space', '' ); + this.$( '.main-help' ).removeClass( 'expanded' ); this.$( '.more-help' ).show(); }, @@ -1192,231 +1221,189 @@ //TODO: better way of localizing text-nodes in long strings /** underscore template fns attached to class */ PairedCollectionCreator.templates = PairedCollectionCreator.templates || { -/** the skeleton */ -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('')), -/** the header (not including help text) */ -header : _.template([ - '<div class="main-help well clear">', - '<a class="more-help" href="javascript:void(0);">', _l( 'More help' ), '</a>', - '<div class="help-content">', - '<a class="less-help" href="javascript:void(0);">', _l( 'Less' ), '</a>', + /** the skeleton */ + 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('')), + + /** the header (not including help text) */ + header : _.template([ + '<div class="main-help well clear">', + '<a class="more-help" href="javascript:void(0);">', _l( 'More help' ), '</a>', + '<div class="help-content">', + '<a class="less-help" href="javascript:void(0);">', _l( 'Less' ), '</a>', + '</div>', '</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="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">', _l( '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="', _l( 'Filter this list' ), '" />', + '<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">', _l( '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="', _l( '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)">', + _l( 'Choose filters' ), + '</a>', + '<a class="clear-filters-link" href="javascript:void(0);">', + _l( 'Clear filters' ), + '</a><br />', + '<a class="autopair-link" href="javascript:void(0);">', + _l( 'Auto-pair' ), + '</a>', + '</div>', + '</div>', + '<div class="reverse-column flex-column column">', + '<div class="column-header">', + '<div class="column-title">', + '<span class="title">', _l( '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="', _l( 'Filter this list' ), '" />', + '</div>', + '</div>', + '</div>', + '</div>' + ].join('')), + + /** the middle: unpaired, divider, and paired */ + middle : _.template([ + // contains two flex rows (rows that fill available space) and a divider btwn + '<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="paired-column flex-column no-flex column">', + '<div class="flexible-partition">', + '<div class="flexible-partition-drag"></div>', '<div class="column-header">', - '<a class="choose-filters-link" href="javascript:void(0)">', - _l( 'Choose filters' ), - '</a>', - '<a class="clear-filters-link" href="javascript:void(0);">', - _l( 'Clear filters' ), - '</a><br />', - '<a class="autopair-link" href="javascript:void(0);">', - _l( 'Auto-pair' ), + '<div class="column-title paired-column-title">', + '<span class="title"></span>', + '</div>', + '<a class="unpair-all-link" href="javascript:void(0);">', + _l( 'Unpair all' ), '</a>', '</div>', '</div>', - '<div class="reverse-column flex-column column">', - '<div class="column-header">', - '<div class="column-title">', - '<span class="title">', _l( '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="', _l( 'Filter this list' ), '" />', + '<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('')), + + /** creation and cancel controls */ + footer : _.template([ + '<div class="attributes clear">', + '<input class="collection-name form-control pull-right" ', + 'placeholder="', _l( 'Enter a name for your new list' ), '" />', + '<div class="collection-name-prompt pull-right">', _l( 'Name' ), ':</div>', + '</div>', + + '<div class="actions clear vertically-spaced">', + '<div class="other-options pull-left">', + '<button class="cancel-create btn" tabindex="-1">', _l( 'Cancel' ), '</button>', + '<div class="create-other btn-group dropup">', + '<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">', + _l( 'Create a different kind of collection' ), + ' <span class="caret"></span>', + '</button>', + '<ul class="dropdown-menu" role="menu">', + '<li><a href="#">', _l( 'Create a <i>single</i> pair' ), '</a></li>', + '<li><a href="#">', _l( 'Create a list of <i>unpaired</i> datasets' ), '</a></li>', + '</ul>', '</div>', '</div>', - '</div>', - '</div>' -].join('')), -/** the middle: unpaired, divider, and paired */ -middle : _.template([ - // contains two flex rows (rows that fill available space) and a divider btwn - '<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 class="main-options pull-right">', + '<button class="create-collection btn btn-primary">', _l( 'Create list' ), '</button>', '</div>', - '<a class="unpair-all-link" href="javascript:void(0);">', - _l( '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('')), + '</div>' + ].join('')), -/** creation and cancel controls */ -footer : _.template([ - '<div class="attributes clear">', - '<input class="collection-name form-control pull-right" ', - 'placeholder="', _l( 'Enter a name for your new list' ), '" />', - '<div class="collection-name-prompt pull-right">', _l( 'Name' ), ':</div>', - '</div>', - - '<div class="actions clear vertically-spaced">', - '<div class="other-options pull-left">', - '<button class="cancel-create btn" tabindex="-1">', _l( 'Cancel' ), '</button>', - '<div class="create-other btn-group dropup">', - '<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">', - _l( 'Create a different kind of collection' ), - ' <span class="caret"></span>', - '</button>', - '<ul class="dropdown-menu" role="menu">', - '<li><a href="#">', _l( 'Create a <i>single</i> pair' ), '</a></li>', - '<li><a href="#">', _l( '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">', _l( 'Create list' ), '</button>', - '</div>', - '</div>' -].join('')), - -/** help content */ -helpContent : _.template([ - '<p>', _l([ - 'Collections of paired datasets are ordered lists of dataset pairs (often forward and reverse ', - 'reads) that can be passed to tools and workflows in order to have analyses done on 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>', _l([ - '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>', _l([ - '<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>Clearing the filters by clicking the ', - '<i data-target=".clear-filters-link">"Clear filters" link</i>.', - '</li>', - '</ul>' - ].join( '' )), '</p>', - '<p>', _l([ - '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>', _l([ - '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('')) -} - -//============================================================================= -//TODO: to own file -/* -(Imported for edit distance algorith. From: https://gist.github.com/andrei-m/982927) -Copyright (c) 2011 Andrei Mackenzie -*/ -// Compute the edit distance between the two given strings -//exports.getEditDistance = function(a, b){ -function levenshteinDistance(a, b){ - if(a.length === 0){ return b.length; } - if(b.length === 0){ return a.length; } - - var matrix = []; - - // increment along the first column of each row - var i; - for(i = 0; i <= b.length; i++){ - matrix[i] = [i]; - } - - // increment each column in the first row - var j; - for(j = 0; j <= a.length; j++){ - matrix[0][j] = j; - } - - // Fill in the rest of the matrix - for(i = 1; i <= b.length; i++){ - for(j = 1; j <= a.length; j++){ - if(b.charAt(i-1) === a.charAt(j-1)){ - matrix[i][j] = matrix[i-1][j-1]; - } else { - matrix[i][j] = Math.min(matrix[i-1][j-1] + 1, // substitution - Math.min(matrix[i][j-1] + 1, // insertion - matrix[i-1][j] + 1)); // deletion - } - } - } - - //console.debug( '\t\t levenshteinDistance', a, b, matrix[b.length][a.length] ); - return matrix[b.length][a.length]; -} + /** help content */ + 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 ', + '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>', _l([ + '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>', _l([ + '<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>Clearing the filters by clicking the ', + '<i data-target=".clear-filters-link">"Clear filters" link</i>.', + '</li>', + '</ul>' + ].join( '' )), '</p>', + '<p>', _l([ + '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>', _l([ + '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('')) +}; //============================================================================= @@ -1451,7 +1438,6 @@ //============================================================================= -//TODO: to own file /** a modal version of the paired collection creator */ var pairedCollectionCreatorModal = function _pairedCollectionCreatorModal( datasets, options ){ options = _.defaults( options || {}, { @@ -1476,6 +1462,7 @@ closing_events: true }); //TODO: remove modal header + window.PCC = creator; return creator; }; diff -r 3e7e8a3f1b7085a6a1b6beea0ca40260fa7287d7 -r 08580f127c031810c14c23e622700185ea582ccd 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(["mvc/base-mvc","utils/localization"],function(a,e){var f=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.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(g){return g.name.indexOf(this.filters[0])>=0},_filterRevFn:function(g){return g.name.indexOf(this.filters[1])>=0},_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=d(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){var h=this._naiveStartingAndEndingLCS(i.name.replace(this.filters[0],""),g.name.replace(this.filters[1],""));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",data:JSON.stringify(g)}).fail(function(m,j,l){console.error(m,j,l);var k=e("An error occurred while creating this collection");if(m){if(m.readyState===0&&m.status===0){k+=": "+e("Galaxy could not be reached and may be updating.")+e(" Try again in a few minutes.")}else{if(m.responseJSON){k+="<br /><pre>"+JSON.stringify(m.responseJSON)+"</pre>"}else{k+=": "+l}}}i._showAlert(k,"alert-danger")}).done(function(j,k,l){i.trigger("collection:created",j,k,l);if(typeof i.oncreate==="function"){i.oncreate.call(this,j,k,l)}})},render:function(g,h){this.$el.empty().html(f.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(f.templates.header()).find(".help-content").prepend($(f.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(f.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,e("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,e("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()}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)});this.$(".unpaired-columns .column-datasets").empty();return 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," ",e("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(e("Pair these datasets")))},_renderUnpairedEmpty:function(){var g=$('<div class="empty-message"></div>').text("("+e("no remaining unpaired datasets")+")");this.$(".unpaired-columns .paired-column .column-datasets").prepend(g);return g},_renderPaired:function(j,k){var i=[],g=[],h=[];this.$(".paired-column-title .title").text([this.paired.length,e("paired")].join(" "));this.$(".unpair-all-link").toggle(this.paired.length!==0);if(this.paired.length===0){this._renderPairedEmpty()}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",e("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("("+e("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(f.templates.footer());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,'">',e("Forward"),": ",k,", ",e("Reverse"),": ",j,"</button>"].join("")}var i=$(_.template(['<div class="choose-filters">','<div class="help">',e("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.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()});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","click .unpair-btn":"_clickUnpair","mouseover .dataset.paired":"_hoverPaired","mouseout .dataset.paired":"_hoverOutPaired","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").css("max-height","none");this.$(".main-help .help-content p:first-child").css("white-space","normal");this.$(".more-help").hide()},_clickLessHelp:function(g){this.$(".main-help").css("max-height","");this.$(".main-help .help-content p:first-child").css("white-space","");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;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")},_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"}});f.templates=f.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);">',e("More help"),"</a>",'<div class="help-content">','<a class="less-help" href="javascript:void(0);">',e("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">',e("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="',e("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)">',e("Choose filters"),"</a>",'<a class="clear-filters-link" href="javascript:void(0);">',e("Clear filters"),"</a><br />",'<a class="autopair-link" href="javascript:void(0);">',e("Auto-pair"),"</a>","</div>","</div>",'<div class="reverse-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',e("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="',e("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);">',e("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">','<input class="collection-name form-control pull-right" ','placeholder="',e("Enter a name for your new list"),'" />','<div class="collection-name-prompt pull-right">',e("Name"),":</div>","</div>",'<div class="actions clear vertically-spaced">','<div class="other-options pull-left">','<button class="cancel-create btn" tabindex="-1">',e("Cancel"),"</button>",'<div class="create-other btn-group dropup">','<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">',e("Create a different kind of collection"),' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">','<li><a href="#">',e("Create a <i>single</i> pair"),"</a></li>",'<li><a href="#">',e("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">',e("Create list"),"</button>","</div>","</div>"].join("")),helpContent:_.template(["<p>",e(["Collections of paired datasets are ordered lists of dataset pairs (often forward and reverse ","reads) that can be passed to tools and workflows in order to have analyses done on 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>",e(['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>",e(["<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>Clearing the filters by clicking the ",'<i data-target=".clear-filters-link">"Clear filters" link</i>.',"</li>","</ul>"].join("")),"</p>","<p>",e(["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>",e(['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 d(h,g){if(h.length===0){return g.length}if(g.length===0){return h.length}var k=[];var m;for(m=0;m<=g.length;m++){k[m]=[m]}var l;for(l=0;l<=h.length;l++){k[0][l]=l}for(m=1;m<=g.length;m++){for(l=1;l<=h.length;l++){if(g.charAt(m-1)===h.charAt(l-1)){k[m][l]=k[m-1][l-1]}else{k[m][l]=Math.min(k[m-1][l-1]+1,Math.min(k[m][l-1]+1,k[m-1][l]+1))}}}return k[g.length][h.length]}(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 f(g).render();Galaxy.modal.show({title:"Create a collection of paired datasets",body:h.$el,width:"80%",height:"700px",closing_events:true});return h};return{PairedCollectionCreator:f,pairedCollectionCreatorModal:b}}); \ No newline at end of file +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.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(g){return g.name.indexOf(this.filters[0])>=0},_filterRevFn:function(g){return g.name.indexOf(this.filters[1])>=0},_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){var h=this._naiveStartingAndEndingLCS(i.name.replace(this.filters[0],""),g.name.replace(this.filters[1],""));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",data:JSON.stringify(g)}).fail(function(m,j,l){console.error(m,j,l);var k=d("An error occurred while creating this collection");if(m){if(m.readyState===0&&m.status===0){k+=": "+d("Galaxy could not be reached and may be updating.")+d(" Try again in a few minutes.")}else{if(m.responseJSON){k+="<br /><pre>"+JSON.stringify(m.responseJSON)+"</pre>"}else{k+=": "+l}}}i._showAlert(k,"alert-danger")}).done(function(j,k,l){i.trigger("collection:created",j,k,l);if(typeof i.oncreate==="function"){i.oncreate.call(this,j,k,l)}})},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").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").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()}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());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","click .unpair-btn":"_clickUnpair","mouseover .dataset.paired":"_hoverPaired","mouseout .dataset.paired":"_hoverOutPaired","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;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")},_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">','<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 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>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(['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 diff -r 3e7e8a3f1b7085a6a1b6beea0ca40260fa7287d7 -r 08580f127c031810c14c23e622700185ea582ccd static/scripts/packed/utils/levenshtein.js --- /dev/null +++ b/static/scripts/packed/utils/levenshtein.js @@ -0,0 +1,1 @@ +define([],function(){function a(d,c){if(d.length===0){return c.length}if(c.length===0){return d.length}var e=[];var g;for(g=0;g<=c.length;g++){e[g]=[g]}var f;for(f=0;f<=d.length;f++){e[0][f]=f}for(g=1;g<=c.length;g++){for(f=1;f<=d.length;f++){if(c.charAt(g-1)===d.charAt(f-1)){e[g][f]=e[g-1][f-1]}else{e[g][f]=Math.min(e[g-1][f-1]+1,Math.min(e[g][f-1]+1,e[g-1][f]+1))}}}return e[c.length][d.length]}return a}); \ No newline at end of file diff -r 3e7e8a3f1b7085a6a1b6beea0ca40260fa7287d7 -r 08580f127c031810c14c23e622700185ea582ccd static/scripts/utils/levenshtein.js --- /dev/null +++ b/static/scripts/utils/levenshtein.js @@ -0,0 +1,60 @@ +define([ +], function(){ +//============================================================================= +/** +(Imported for edit distance algorith. From: https://gist.github.com/andrei-m/982927) +Copyright (c) 2011 Andrei Mackenzie + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +// Compute the edit distance between the two given strings +//exports.getEditDistance = function(a, b){ +function levenshteinDistance(a, b){ + if(a.length === 0){ return b.length; } + if(b.length === 0){ return a.length; } + + var matrix = []; + + // increment along the first column of each row + var i; + for(i = 0; i <= b.length; i++){ + matrix[i] = [i]; + } + + // increment each column in the first row + var j; + for(j = 0; j <= a.length; j++){ + matrix[0][j] = j; + } + + // Fill in the rest of the matrix + for(i = 1; i <= b.length; i++){ + for(j = 1; j <= a.length; j++){ + if(b.charAt(i-1) === a.charAt(j-1)){ + matrix[i][j] = matrix[i-1][j-1]; + } else { + matrix[i][j] = Math.min(matrix[i-1][j-1] + 1, // substitution + Math.min(matrix[i][j-1] + 1, // insertion + matrix[i-1][j] + 1)); // deletion + } + } + } + + //console.debug( '\t\t levenshteinDistance', a, b, matrix[b.length][a.length] ); + return matrix[b.length][a.length]; +} + +//============================================================================= + return levenshteinDistance; +}); diff -r 3e7e8a3f1b7085a6a1b6beea0ca40260fa7287d7 -r 08580f127c031810c14c23e622700185ea582ccd static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -1821,9 +1821,11 @@ .collection-creator .column-title .title{font-weight:bold} .collection-creator .column-title .title-info{color:grey}.collection-creator .column-title .title-info:before{content:' - '} .collection-creator .paired-column{text-align:center;width:22%} -.collection-creator .header{padding-bottom:8px}.collection-creator .header .main-help{max-height:36px;margin-bottom:16px;overflow:hidden;padding:8px;background:#f8f8f8}.collection-creator .header .main-help .help-content i{cursor:help;border-bottom:1px dotted grey;font-style:normal} +.collection-creator .header{padding-bottom:8px}.collection-creator .header .main-help{margin-bottom:17px;overflow:hidden;padding:15px;background:#f8f8f8}.collection-creator .header .main-help:not(.expanded){max-height:49px}.collection-creator .header .main-help:not(.expanded) .help-content p:first-child{overflow:hidden;white-space:nowrap;text-overflow:ellipsis} +.collection-creator .header .main-help:not(.expanded) .help-content>*:not(:first-child){display:none} +.collection-creator .header .main-help.expanded{max-height:none} +.collection-creator .header .main-help .help-content i{cursor:help;border-bottom:1px dotted grey;font-style:normal} .collection-creator .header .main-help .help-content ul,.collection-creator .header .main-help .help-content li{list-style:circle;margin-left:16px} -.collection-creator .header .main-help .help-content p:first-child{overflow:hidden;white-space:nowrap;text-overflow:ellipsis} .collection-creator .header .main-help .help-content .less-help{display:inline-block;width:100%;text-align:right} .collection-creator .header .main-help .more-help{float:right} .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} diff -r 3e7e8a3f1b7085a6a1b6beea0ca40260fa7287d7 -r 08580f127c031810c14c23e622700185ea582ccd 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 @@ -142,11 +142,29 @@ padding-bottom: 8px; .main-help { - max-height: 36px; - margin-bottom: 16px; + margin-bottom: 17px; overflow: hidden; - padding: 8px; + padding: 15px; background: #f8f8f8; + + &:not(.expanded) { + // chosen to match alert - dependent on line height and .alert padding + max-height: 49px; + .help-content { + p:first-child { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + > *:not(:first-child) { + display: none; + } + } + } + &.expanded { + max-height: none; + } + .help-content { i { cursor: help; @@ -160,18 +178,13 @@ list-style: circle; margin-left: 16px; } - p:first-child { - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } .less-help { display: inline-block; width: 100%; text-align: right; } } - .more-help { + .more-help { //display: inline-block; float: right; } 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.