Giter Site home page Giter Site logo

ready's Issues

Multiple DatepickerPulldowns Overlap

First - nice tool, much better than the silly HTML date popup!
I have form that has two date fields, on two different lines. If someone opens popup on one, then on the other, they overlap. So, I tweaked code a bit to close any that may be open already when another is opened. Here is what I did, followed by the affected existing code:
`
..
function closeDatePickers(idOfTextBox) // dlc added
// fixes problem where multiple datepickers open
{
var datepickers = document.getElementsByClassName('datepicker');
var textbox;
var any = false;
var me = false;

for(var ix=0; ix< datepickers.length; ix++)
{
textbox = document.getElementById(datepickers[ix].id);
div = textbox.parentNode.getElementsByTagName('div');
for (jx=0;jx<div.length;jx++)
{
if (div[jx].getAttribute('class')=='datepickerdropdown')
{
textbox.parentNode.removeChild(div[jx]);
if (datepickers[ix].id == idOfTextBox) me = true;
any = true;
}
}
}
return me;
}

// This is called when they click the icon next to the date inputbox
function showDatePicker(idOfTextbox) {
var textbox = document.getElementById(idOfTextbox);

if (closeDatePickers(idOfTextbox)) return false; // just closing this one
/*
// See if the date picker is already there, if so, remove it
x = textbox.parentNode.getElementsByTagName('div');
for (i=0;i<x.length;i++) {
if (x[i].getAttribute('class')=='datepickerdropdown') {
textbox.parentNode.removeChild(x[i]);
return false;
}
}
*/

// Grab the date, or use the current date if not valid
..`

Unnecessary checks

The check() function runs everytime I register a new selector.
I see that's needed to detect for elements already present at the page, but why do you need to run through all listeners, instead of just the selector being registered? Running through the other listeners seems to be unnecessary, and could have a noticeable perform impact as the listeners list grows.

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.