-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 484 - Combine Connectors and Contexts into a single column #537
Changes from 39 commits
c3ad7bc
2b89941
528c0ac
20e0279
c6bbc92
e4fe942
cf78ce8
f62ab59
bedfa00
0634271
fdf9ffa
9699974
35d29de
1110f99
0f2d0f7
9ef5b84
e2c8958
f8e6d0a
3d528c1
ff54cdb
7b57177
54d4c84
5e9b200
18b1dd4
07abd2f
f8ffb67
851d5ff
f902e63
4ecb17d
2461cf4
1e56427
539d24f
6555b6a
9d1c548
cb5466f
14efe8b
dc80669
a82feb8
1fe78a8
a2d6a28
9138e19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,10 @@ jQuery(function($){ | |
$elem = $(record.element), | ||
icon = ''; | ||
|
||
if ( '- ' === record.text.substring( 0, 2 ) ) { | ||
record.text = record.text.substring( 2 ); | ||
} | ||
|
||
if ( undefined !== record.icon ) { | ||
icon = record.icon; | ||
} else if ( undefined !== $elem.attr('data-icon') ) { | ||
|
@@ -23,12 +27,18 @@ jQuery(function($){ | |
container.attr('title', $elem.attr('title')); | ||
|
||
return result; | ||
}, | ||
formatSelection = function( record ) { | ||
if ( '- ' === record.text.substring( 0, 2 ) ) { | ||
record.text = record.text.substring( 2 ); | ||
} | ||
return record.text; | ||
}; | ||
|
||
if ( $(el).find('option').length > 0 ) { | ||
args = { | ||
minimumResultsForSearch: 10, | ||
formatResult: formatResult, | ||
formatSelection: formatSelection, | ||
allowClear: true, | ||
width: '165px' | ||
}; | ||
|
@@ -52,6 +62,7 @@ jQuery(function($){ | |
} | ||
}, | ||
formatResult: formatResult, | ||
formatSelection: formatSelection, | ||
initSelection: function (element, callback) { | ||
var id = $(element).val(); | ||
if(id !== '') { | ||
|
@@ -75,7 +86,28 @@ jQuery(function($){ | |
}; | ||
} | ||
|
||
$(el).select2( args ); | ||
$( el ).select2( args ); | ||
}); | ||
|
||
var $queryVars = $.getQueryParameters(); | ||
var $contextInput = $( '.toplevel_page_wp_stream :input.chosen-select[name=context]' ); | ||
|
||
if ( ( 'undefined' === typeof $queryVars.context || '' === $queryVars.context ) && 'undefined' !== typeof $queryVars.connector ) { | ||
$contextInput.select2( 'val', 'group-' + $queryVars.connector ); | ||
} | ||
|
||
$('#record-filter-form').submit( function() { | ||
var $context = $( '.toplevel_page_wp_stream :input.chosen-select[name=context]' ), | ||
$option = $context.find( 'option:selected' ), | ||
$connector = $context.parent().find( '.record-filter-connector' ), | ||
optionConnector = $option.data( 'group' ), | ||
optionClass = $option.prop( 'class' ); | ||
|
||
$connector.val( optionConnector ); | ||
|
||
if ( 'level-1' === optionClass ) { | ||
$option.val(''); | ||
} | ||
}); | ||
|
||
var stream_select2_change_handler = function (e, input) { | ||
|
@@ -756,3 +788,9 @@ jQuery(function($){ | |
intervals.init( $('.date-interval') ); | ||
}); | ||
}); | ||
|
||
jQuery.extend({ | ||
getQueryParameters : function( str ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lukecarbis Do you think we should prefix this function name? Copy pasta straight from: http://css-tricks.com/snippets/jquery/get-query-params-object/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes! Good pickup. |
||
return (str || document.location.search).replace(/(^\?)/,'').split('&').map(function(n){return n = n.split('='),this[n[0]] = n[1],this;}.bind({}))[0]; | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukecarbis Is this dependent on there being children or shouldn't top level items always be classified as groups?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's 6 vs ½ × 12.
I think it makes the dom a bit cleaner to leave
data-group
out where it's not needed. I'm not that fussed though, if you wanted to change it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK we'll just leave as-is.