Git Product home page Git Product logo

ms-dropdown's Introduction

Help

v4.0.3 update: 13 Oct, 2021

  • Fixed bootstrap modal issue

v4.0.2 update: 21 Sep, 2021

  • Safari blue border on focus removed
  • selectedIndex can be set as an array if "<select>" is multiple.
    • Example: element.msDropdown.selectedIndex = [1, 4];
  • imagePosition:'right' is added. Default value is left.
  • showFilterAlways functionality is added.
  • Little bit code refactoring

v4.0.1 update: 15 Sep, 2021

  • Fixed List zIndex issue

v4.0 update: 09 Sep, 2021

  • Written in ES6 (class) Style
  • Remove jQuery dependency
  • Performance improvement
  • Reactive properties
  • 'required' attributes works too
  • 'required' message can be customized. Default is 'Please select an item from this list'
  • Works better than original dropdown, i guess :)

v3.5.2 updates: 13 July, 2013

  • height bug fixed.
  • multiple indexes can be set via object. ie. var oDropdown = $("#element").msDropdown().data("dd"); oDropdown.set("selectedIndex", [1,4]);
  • checkbox selection is fixed when setting index via object.
  • css .arrow class is changed to .ddArrow (it was too common)

v3.5.1 updates:

  • (used for my personal project - did not get the chance to update - Sorry!)

v3.5 updates: 3 June, 2013

  • conflict edit in source js file fixed
  • autofilter is now configurable - it can be enable/disable by setting params or data-enableautofilter="true" attribute.
  • next/previous bug fixed when autofilter is on.
  • Bug fixed when item opens upward after autofilter.

v3.4 updates: 31 May, 2013

  • refresh method is back. you can refresh your dropdown to update the UI and value with the original dropdown or by the msdropdown object. i.e: $("#dropdownid").msDropdown().data("dd").refresh(); //or document.getElementById("dropdownid").refresh();
  • removed underscore from the all the variables and methods name - for the sake of jslint
  • reverseMode - reverseMode settings param is true... When you update your original dropdown it will update the msdropdown UI and value. This is usefull when you use knockoutjs or other library
  • Now you can set open direction to always down by settings params in settings or data {openDirection:"alwaysdown"}

v3.3 updates: 02 Feb, 2013

  • $.browser - jQuery 1.9 version fixed
  • Keyboard navigation issue has been fixed
  • destory is now destroy - oops typo error

v3.2 updates: 26 Nov, 2012

  • All setting parameters can passed throught element's data- attributes. ie. data-maincss="blue"
  • zIndex bug fixed for list and dropdown if both on the same page.
  • Added setIndexByValue method. However same can be done by - handler.set("value", value)
  • Added "append" and "prepend" in setting params. append is used to append the element to the childdiv and prepend do as the name suggest.
  • Added one more help file for objected oriented approach.

v3.1.1 updates:

  • chrome onchange bug fixed
  • zindex bug fixed for msie
  • add method bug fixed for msie

v3.1 updates:

  • Child width can be alter
  • New multiple is introduced. Its multiple but with the checkbox.
  • Bonus: elementname_mscheck will be posted along with the form post/get. i.e. if element name is "tech" checkbox tech_mscheck[] is created. However you can set the suffix using 'checkboxNameSuffix' parameter.

v3.0 updates:

  • Written from scratch
  • Improved performance and UI
  • Improved auto filter experience
  • Added data- support in attributes for image, description, title, imagecss, text and value
  • Event can be bind/unbind through object
  • Organized folder structure
  • Old style (with title attribute) is also working.
  • Country dropdown with flags as a bonus
v2.38 updates:
  • document keydown/keyup method unbind
  • added json support in title. {image:'', title:''}
  • onchange bug on onclose
  • CSS style declaration problem
  • jQuery 1.7.1 compatibility issue
  • IE8 sprite
v2.37.5 updates:
  • Fixed an ie6 error.
v2.37 updates:
  • values are updated properly when it opens upwards
  • Now works with jQuery 1.6.1.
  • Improved performance
  • Added quick selection. Filter options on key press
v2.36 updates:
  • Onchange bug has been fixed. Finally :)
  • No more id is required.
v2.35 updates:
  • Now works in FF4.
  • Onchange bug has been fixed.
  • DropUp when your dropdown is showing at bottom of the page.
  • Some minor ui changes
v2.3 updates:
  • CSS sprite chrome bug has been fixed.

License

You may use msDropDown under the terms of either the MIT License or the Gnu General Public License (GPL) Version 2.

The MIT License is recommended for most projects. It is simple and easy to understand, and it places almost no restrictions on what you can do with msDropDown.

If the GPL suits your project better, you are also free to use msDropDown under that license.

You don't have to do anything special to choose one license or the other, and you don't have to notify anyone which license you are using.

ms-dropdown's People

Contributors

manfer avatar marghoobsuleman avatar sulemanmarghoob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ms-dropdown's Issues

enable/disable option

when i do enable/disable for select option it is not reflecting in ul, disabled li are not enabled , plz help me., am using jquery

if (jQuery.inArray($thisOption.val(), my_array) <= 0) {
if ($thisOption.val() != 'NULL') {
$thisOption.attr('disabled', 'disabled'); $thisOption.hide();
}
}

How can we select an item by value?

How do I select an item by value if I don't keep a variable of the instance of the created element?

Even if I use the set index, the documentation indicates:

oDropdown.set("selectedIndex", 2);

how do I get oDropDown?

Thanks

Feature alwaysDown

I've used your library for a number of small tweaks on websites, for the first time I ran into a serious issue today.

Basically with fairly large images (150-200 px tall) and enough of them (>20), the drop down behaves as expected on the first click, but then every other click afterwards behaves as if I set the feature 'alwaysUp' to True. This besides being annoying really upset the client.

I imagine theres' some sort of edge case having to do with the case where the child element UL/LI is taller than the screen real-estate. Didn't have time to wait for an answer for this case, so I hacked the _adjustOpen() function, adding an
if ('alwaysdown' == _settings.openDirection.toLowerCase()) before the complicated decider if (about line 1067 on the 3.3 version of the code).

And used the same code that's in the trailing else:

$("#" + childid).css({top: top + "px", zIndex: _settings.zIndex});
$("#" + id).removeClass("borderRadius borderRadiusBtm").addClass("borderRadiusTp");

Then I invoked the ms-dropdown with a { openDirection: 'alwaysDown' }

This worked well enough for my clients. So I'm explaining what I did for you, in the off chance that others complain about this, or need an 'alwaysDown' to work just like the existing 'alwaysUp'.

If you like I can check in the code change I made but it's small enough you might just do it yourself ... or not.

Typo this.close function

You made a error with the unbinding of the keyup and mouseup events, they are switched.

Current situation:
this.close = function () {
...
setTitleImageSprite();
$(document).unbind("keydown", d_onkeydown);
$(document).unbind("keyup", d_onmouseup);
$(document).unbind("mouseup", d_onkeyup);
...
};

Should become:
this.close = function () {
...
setTitleImageSprite();
$(document).unbind("keydown", d_onkeydown);
$(document).unbind("keyup", d_onkeyup);
$(document).unbind("mouseup", d_onmouseup);
...
};

Css Sprites & IE 9

I have problem with CSS Sprites & IE9, the sprites display correctly in the dropdown menu, but the sprite was not updated correctly for the selected field.

My solution for running correctly is change this :

if(backgroundPosition == undefined){
   backgroundPosition = $("#"+id).css("background-position-x") + " " + $("#"+id).css("background-position-y");
};      

by

if( backgroundPosition == "0% 0%" || backgroundPosition == null){
   backgroundPosition = $("#"+id).css("background-position-x") + " " + $("#"+id).css("background-position-y");
};

Help with Android and Default Browser

Hi,
I'm using the last version of JQuery msdropdown menu and works fine but on Android Tablet don't work. Appear but not open the list of elements.
The strange thing is that on Android Samnsung Galaxy SIII mini works but on an Asus Tablet and on another Samsung Galaxy Tablet don't work. Both have Jelly Bean.
Someone have some idea.
Thanks in advance for your help.
Luca

event does not fire

onchange event does not fired first time when first option contains null value

How to scroll automatically to selected item?

Hi, I'm using the ms-Dropdown plugin and really like it.
But I have a case, where I need to display on drop down children elements (select options) starting from selected item.

For example, let's take a look at this image: http://s54.radikal.ru/i143/1206/df/d56b4b98b760.jpg
Here you can see, that it's automatically selected to current date, 15 june, 2012.

When I click on "day select", on drop down method, it starts from 1st day, but I need to start showing days starting from tomorrow.... 16, 17, 18 and etc. And when I scroll up, the previous days show up..

Is that even possible with your plugin?
Thanks : )

JS Lint Errors

-got rid of almost all the JS Lint errors.

!!!!! JS Lint still complains about this function as having undefined values.

~Line 75:

var matchIndex = function (index) {
    var selectedIndex = $("#"+elementid+" option:selected");
    if(selectedIndex.length>1) {
        for(var i=0;i<selectedIndex.length;i++) {
            if(index == selectedIndex[i].index) {
                return true;
            };
        };
    } else if(selectedIndex.length==1) {
        if(selectedIndex[0].index==index) {
            return true;
        };
    };
    return false;
};

!!!!!

Other little changes I made in my branch...

-used numeric minification on the updated uncompressed code.
--the minified code result is slightly bigger that the previous minified code.

-added jquery-1.7.2.min.js to the msdropdown/js/ folder.

-updated the example code to reflect the js min filename changes.

-made a few minor edits to make capitalization more consistent.

Everything works on current Linux64 versions of Firefox, Chromium, & Opera as well as it did before the edits.

Thanks again for your hard work. The code works beautifully.

Opera 11.62 throw message

Hi . Last night Opera updated to 11.62 and I found that the plugin is throwing an error:" set to what?"
I've searched through the code and I found that

this.set = function(prop, val, isLocal) {

// alert("- set " + prop + " : "+val);
if(prop==undefined || val==undefined) throw {message:"set to what? "};

the val value is undefined on a function. Not really sure why opera sees this as undefined, because when I alert the val value I see something like "function(){ [native code] }"

Anyway might not be a javascript problem, but an opera problem... unless there is something strict about javascript standard that was used wrong in the code.

jQuery 1.8

Since the .data("events") method has been dropped in jQuery 1.8 the following line has to be changed in the has_handler function (in uncompressed.jquery.dd.js) in order to make sure the ms-Dropdown events work correctly with jQuery 1.8.

    //var evs = $("#"+elementid).data("events");                     //jQuery 1.7
    var evs = $._data($("#"+elementid).get(0), "events");     //jQuery 1.8

I only use the uncompressed stuff so I haven't looked at the minified jquery.dd.js yet.

IE7 dropdown box shrinks on every open event

There seems to be a problem in IE7 in getting a accurate "oldHeight" value causing continual shrinkage of the dropdown box:

oldHeight = $("#"+childid).height();

I guess this should be accurately calculated with the number of visibleRows instead of taking a precalculated DOM height.
Maybe it is caused by the animation?

Preselection of an option

When preselecting another "option" than the first one in the dropdown, the first change in the selection will do nothing and will fail. Only the second attempt will work. I had to sort my list around in order to have the item I wanted in first position in order to avoir de bug.

Refresh options from underlying <select>

Hi,

Am attempting to select a different option in the dropdown using the following:

$("#dropdownID").val("MyValue");

This changes the underlying control, however does not update the msDropDown instance. In previous versions there was the ability to call .refresh: document.getElementById('dropdownID').refresh(); However this method has been removed and is no longer available in v3.2! Is there an alternative to get the front end to update? Thanks.

$.browser has been removed from jquery 1.9

When updating to the latest version of jquery, the msdropdown no longer displays the dropdown box, giving an error of "cannot read property 'msie' of undefined." This is because $.browser, currently appearing on line 1065 of jquery.dd.js is no longer supported in jquery 1.9.

While I'm a pretty big novice at javascript, I don't like issuing a bug without giving a fix. You probably know better ways, but this function is a quick and dirty way to get the MSIE version number:

function getMSIEVersion()
{
var tokens = navigator.userAgent.split(' ');
var msieIndex = tokens.indexOf("MSIE");
if (msieIndex == -1)
{
return null;
}
return tokens[msieIndex + 1].substr(0, tokens[msieIndex + 1].length - 1);
}

Mouse events sample broken

included script msdropdown/js/jquery.js
but in msdropdown/ js/ directory exists only jquery-1.6.1.min.js
not so hard to fix btw)

multiple .msDropDown calls

Hello there
Since I started using the 2.38.4 release I'm experiencing problems when I make multiple calls to the .msDropDown function. The dropdown child div doesn't show up when I make the call more than once.

In my application I fill my combo's dynamically, based on user input. When the original select control is extended with new options I make a .msDropDown call to represent the new options in the child div. This used to work properly in earlier versions.

Am I doing something wrong or is this a bug/feature?

Kind regards,
Kirk Olson

Menu not scrolling when used with Foundation CSS

When used in conjunction with Foundation (downloadable here: http://foundation.zurb.com/download.php ), the dropdown div isn't scrolling.
I assume the select has more than 7 options, since the dd menu shows 7 items by default.

Using firebug (Firefox) or developer tools (Chrome), you can see that the containing div has a markup like this:

    ...

    if the "overflow:hidden" is removed, it reverts to a div scrolling correctly.

Anything over 4 options not showing in Webkit Browsers

For some reason, selects that have more than a certain number of options aren't rendering in Webkit Browsers (tested in both Chrome and Safari with failure and tested with expected - working - results on Firefox and IE).

Working on helping debug the problem, but haven't come up with anything just yet.

Chrome (select with 4 options):
Screen Shot 2013-03-29 at 11 56 14 PM
Chrome (select with 8 options --- I know it looks like nothing's happening, but this is the result of clicking on the top dropdown --- there's just a bottom border added to the element):
Screen Shot 2013-03-29 at 11 55 59 PM
Firefox (select with 8 options):
Screen Shot 2013-03-29 at 11 55 26 PM

Items filtering with menu opened upward

Hi marghoobsuleman,

It's rather small issue, but when the menu is open upward and you start typing to filter, not-matching items are removed from list from the bottom instead from the top of list.

For example, on your demo page with samples, when you open "By Json Data" list (when it's close to the bottom edge of the screen - so it opens upwards) and type "am", the filtered Amex card is displayed far from the list: almost at the top of the screen.

I believe it's much more expected by a user, that it's displayed next to the list he started filtering - similar as when list is open downwards.

Best regards

Disabled function: 'keyup', 'keydown', 'mouseup' becomes unbinded

Hi, thanks for your work.

When I call the disabled function to disable the DD, the events in title will be unbinded from document.
I bind some jQuery UI events to other controls in my pages (drag&drop, sorting, etc) and after the call of the disabled function they stop working.

Can you fix this issue?

Thanks

IE9 Drop Down Error

Very nice control and it works perfectly under Chrome and Firefox. Though in IE9 when clicked for selection the control drop down list remains open even after selecting a new valiue. It will be very nice if I can fix that bug.

This error demo code uploaded here: http://digest.travel/BWPLUS.htm

I am using
jquery-1.3.2.min.js
because with later versions the drop down list does not pop up at all.

doesn't work in JQuery UI Accordion

Not sure of the reason, but there seems to be issues with msDropDown rendering in a JQuery UI Accordion and tab if the drop down is not in the first visible element.

It renders a box that is about 1px wide.

Keydown event when list is long

I have a list that is rather long (about 600 elements), presented within a jQuery ui dialog.

When I open this dropdown, and then hit V on my keyboard, the dropdown list is presented above the dropdown selector, and then the top part of the list is out of view (I can provide screenshots, if you like). To me it looks like this is caused by a combination of the assumption that when you hit a character to truncate the list, there is always room for it (so height is set to auto), and the assumption that when there isn't room for the list below the selector, there is always room for it above the selector.

I managed to fix this by altering the "d_onkeydown" function slightly (marked with a comment):

var d_onkeydown = function(event) {
/* Code snipped */
            default:
                if(keyCode>46) {
                    inputText += String.fromCharCode(keyCode);
                };
                var ind = in_array(inputText);
                if(ind != -1) {
                    // MK: Line below commented out to fix positioning problem
                    //$("#"+childid).css({height:'auto'});
                    $("#"+childid +" a").hide();
                    $(ind).show();                                                              
                    var wf = shouldOpenOpposite();
                    $("#"+childid).css(wf.css);
                    $("#"+childid).css({display:'block'});
                } else {
                    $("#"+childid +" a").show();
                    $("#"+childid).css({height:oldHeight+'px'});
                };
            break;
/* Code snipped */

If my simple fix doesn't look right to you, I would suggest some kind of system where you check if there is actually room for the list below, then above. If there isn't, us a set height for the list, like when first opened.

Thanks for a good plugin.

Morten Krane

Arrow CSS Class

Finally I found the bugtracker, you already received a mail from me.

You are using the global css class '.arrow', this conflicts in same cases with others code.

A better way would be a prefix like 'jsDropdownImageArrow' or something like this.

Regards
Michael

Cant show the dropDown without a selected item

Hi,
i'm using the .set('onchange', myFunction); do detect if a user clicks on an element in the dropdown. If any element is already selected, and the user clicks on that specific element, the event will not go off, being already selected.. So i tried to use .set('selectedIndex', -1) after calling the .open() function, but this doesnt not seem to work.. If instead of -1 i enter a valid index, it works, but i cant seem to set it to a value such that no element is selected..
any suggetions?
thanks in advance
Paolo

Css Sprites & IE 8-

The css sprites don't work in IE 8 on down. Specifically - when you select an item - the image doesn't change to correspond w/ the selected image.

I can't help trouble shoot as the uncompressed version in github doesn't even work correctly in FF so's I don't know where to start.

Dropdown height incorrectly calculated

Thanks for writing this great control. I appreciate it. I'm using your dropdown with 16x16 images and I'm noticing that the first time i open the dropdown the height is incorrect. Then i open it again and it seems appropriately sized. What controls the size and number of rows displayed? Is this a bug?

Problem with jquery-1.7.min.js

Checked this with jquery-1.6.1.min.js NO PROBLEM, working good.

Downloaded jquery-1.7.min.js and got problem: dropdown opening only first time. You can't select anymore after you choose once.

Issues with the keyboard navigation

When you select an option using the mouse, the selected index changes to the one currently selected.

When you use the keyboard arrows to navigate and press enter to make a selection, the selected index stays the same.

This can easily be tested in the demo (http://www.marghoobsuleman.com/mywork/jcomponents/image-dropdown/samples/examples/object-oriented-approach-more.html)

The onChange function does not fire when the selected index is changed using the keyboard arrows and enter.

There should be an option to disable keyboard use

Select first option not possible

I have a bare select with 140 options and nothing selected. After applying ms-Dropdown on the select box, the first option becomes "selected enabled" and refuses to fire a change event when clicked upon. Hence you cannot select the first option directly, only after having selected another option.
Tested with jQuery 1.7.1 and latest jquery.dd.js with the same result in Firefox and Safari (OS X Lion).

Force the pull down to always go down...

Currently the drop down checks if there's room below the element to show the drop down and, if not, slides up instead.

Can this be turned off so that the drop down always slides down?

Thanks
Leander

Length of the drop down

When opening the dropdown for the first time, its size is really small.
The second time the size is decent.

This is quite disturbing with big lists.

100% width. is it possible?

is it easy to change the plugin to adapt to 100% width of it's parent container, so when the browser window changes, the width of the select also changes?
regards

copying style sets style to [object CSSStyleDeclaration]

Source:
` 0 `

Firefox 9.0.1:
<a id="s_sever_msa_1" style="" class="enabled" href="javascript:void(0);"> <img align="absmiddle" src="./img/marker.png"> <span class="ddTitleText">1</span></a>

Chrome 16.0.912.75:
<a href="javascript:void(0);" class="enabled" style="[object CSSStyleDeclaration]" id="s_sever_msa_1"> <img src="./img/marker.png" align="absmiddle"> <span class="ddTitleText">1</span></a>

Looking at uncompressed.jquery.dd.js 2.37.5, the issue's with getOptionsProperties.

After much reading, I got this patch for getOptionsProperties:
69,70c69,70
< var styles = $(currentOption).prop("style");
< return styles;
`---
> var styles = $(currentOption).prop("style");
> return styles.cssText;

I tested in IE8, Firefox and Chrome and it looks good.

Sorry about all the buggered markdown. Still learning.

Small issue

Hi,

I have noticed that the page that i put this menu on can be zoomed in iOS (have only tested on iOS6) - is there a reason for this I am missing? I poured through the code but didn't notice anything.

Do you have a clue for me?

Thanks you very much,

David

Fixed width of the box, but can not activate box everywhere

Heya we have a annoying issue.
Since our dd box was breaking the first option "select color" into two line, we gave it a fixed width.

Do now the box is in one line, but the focus seems not to be on the dropdown box itself, but sticks with the text of the first option. And we can not find the line to change this?!?

Any ideas?

Not working on multiple select boxes on same page with same name

Im working on wordpress theme and in one of my addons i found best way to show images is ms-dropdown but i run on an issue with using it with multiple select boxes on same page.

Well it works fine on first dropdown but on second and third dropdown it's not loading.
I use dynamic loading of select fields so all select fields have same name id and class
sshot-2

List automatically scrolls to top on mouseup

To reproduce:

  • Create a Dropdown with many elements (say 50).
  • Click on the handle to drop the list down.
  • Grab the scrolling bar to scroll down, then release it.

Result:
List scrolls back to top automatically

Expected result:
List should remain where it was scrolled to

'keyup', 'keydown', 'mouseup' unbinded from document

these events won't fire once you clicked into the dropdown list.

a small solution: delete these 3 lines (Line 787):

$(document).unbind("keydown");
$(document).unbind("keyup");
$(document).unbind("mouseup");

It will generate some warning messages, but at least you can still trigger these events

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.