Skip to content

Instantly share code, notes, and snippets.

@croisillon
Last active June 4, 2019 14:59
Show Gist options
  • Save croisillon/7464507 to your computer and use it in GitHub Desktop.
Save croisillon/7464507 to your computer and use it in GitHub Desktop.
// Before
if ( self.data('branches') ) {
checked_stack.push( this );
} else {
var len = checked_stack.length;
if ( this.checked === true ) {
checked_stack.push( this );
if ( checked_stack.length > max_selected ) {
checked_stack.shift().checked = false;
}
} else {
var arr = [];
while ( len-- ) {
if ( this.id !== checked_stack[len]['id'] ) {
arr.push(checked_stack[len]);
}
}
checked_stack = arr.reverse();
}
}
// After
(self.data('branches')
&& (
checked_stack.push(this)
)
) ||
(self.data('branches')
|| (
(this.checked === true
&& (
checked_stack.push(this),
(checked_stack.length > max_selected
&& (
checked_stack.shift().checked = false
)
)
)
) ||
(this.checked === true
|| (
checked_stack = (function (len) {
var arr = [];
while ( len-- ) {
this.id !== checked_stack[len]['id'] && arr.push(checked_stack[len]);
}
return arr;
} (checked_stack.length) ).reverse()
)
)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment