Skip to content

Instantly share code, notes, and snippets.

View dropdowns.js
$(document).click(function(e) {
if ($(e.target).closest('.toggle').length > 0){
e.preventDefault();
var target = target.closest('.toggle');
if (target.hasClass('menuOn')){
$('.toggle').removeClass('menuOn');
target.closest('.dropdown').find('.menu').hide('fast');
} else {
$('.toggle').removeClass('menuOn');
$('.dropdown .menu').hide();
@lou
lou / uninstall all gems
Created Jul 7, 2011
uninstall all gems
View uninstall all gems
for i in `gem list --no-versions`; do gem uninstall -Ia $i; done
@lou
lou / multiselect-collapse
Created Aug 24, 2011
multiselect optgroup collapsable
View multiselect-collapse
$('#ms-YOUR_SELECT_ID .ms-selectable').find('li.ms-elem-selectable').hide();
$('.ms-optgroup-label').click(function(){
$(this).nextAll('li').toggle();
});
@lou
lou / searchable-multiselect.js
Created Sep 14, 2011
searchable multiselect
View searchable-multiselect.js
$('#searchable-form').multiSelect({
selectableHeader : '<input type="text" id="search" />'
});
$('input#search').quicksearch('#ms-searchable-form .ms-selectable li');
@lou
lou / deactivate-selected-elem.js
Created Sep 28, 2011
deactivate selected element in multiselect
View deactivate-selected-elem.js
$('.multiselect').multiSelect({
afterSelect: function(value){
if (1 == 1){
var selectedLi = $('.ms-elem-selected[ms-value="'+value+'"]').first();
selectedLi.unbind('click');
selectedLi.addClass('beautiful-disabled-class');
}
}
});
@lou
lou / searchable.js
Created Apr 3, 2012
multiselect searchable
View searchable.js
$('#searchable-form').multiSelect({
selectableHeader : '<input type="text" id="search" autocomplete = "off" />'
});
$('input#search').quicksearch('#ms-searchable-form .ms-selectable li');
@lou
lou / searchable.hmtl
Created Apr 3, 2012
searchable multiselect
View searchable.hmtl
<body>
<select name="countries[]" multiple="multiple" id="searchable-select">
<option value="fr" selected="selected">France</option>
<option value="ca">Canada</option>
<option value="ar">Argentina</option>
<option value="pt">Portugal</option>
<option value="us">United States</option>
<option value="gb">United Kingdom</option>
<option value="au">Australia</option>
<option value="ao">Angola</option>
View multiselect-usage.js
$('#countries').multiSelect({
afterSelect: function(value, text){}, // Function to call after one item is selected
afterDeselect: function(value, text){}, // Function to call after one item is deselected
selectableHeader: null, // Text or HTML to display on the selectable container
selectedHeader: null, // Text or HTML to display on the selected container
disabledClass: 'disabled' // CSS class for disabled items
});
@lou
lou / multiselect-usage.html
Created Apr 22, 2012
multiselect usage html
View multiselect-usage.html
<select multiple="multiple" id="countries" name="countries[]">
<option value="fr">France</option>
<option value="uk">United Kingdom</option>
<option value="us">United States</option>
<option value="ch">China</option>
</select>
@lou
lou / multiselect-callbacks.js
Created Apr 22, 2012
multiselect callbacks
View multiselect-callbacks.js
// You must init the multiple select with $('#my-select').multiSelect() before calling one of the following methods
$('#countries').multiSelect('select', 'value'); // Select the item with the value given in parameter
$('#countries').multiSelect('deselect', 'value'); // Deselect the item with the value given in parameter
$('#countries').multiSelect('select_all', true); // Select all elements. If parameter visible set to true, it will select only visible items. Otherwise it will also select hidden items.
$('#countries').multiSelect('deselect_all'); // Deselect all items previously selected