Bug Tracker

Modify

Ticket #2895 (closed bug: invalid)

Opened 6 years ago

Last modified 5 years ago

function coord(el,prop) in JQuerySpinBtn.js not work properly in IE

Reported by: Aray Owned by:
Priority: major Milestone: 1.2.4
Component: plugin Version: 1.2.3
Keywords: spin button Cc: jeresig@…
Blocking: Blocked by:

Description

The plugin Spin Button is greate, It is very usefull to me. Thank you for your greate work.

But there were a little problem in JQuerySpinBtn.js, wich I download from  http://www.softwareunity.com/sandbox/jqueryspinbtn/JQuerySpinBtn.js.

the function coord(el,prop) not work properly in IE if document.body's padding or margin is not ZERO.

Following is the offcial release of code

function coord(el,prop) {

var c = el[prop], b = document.body;

while ((el = el.offsetParent) && (el != b)) {

if (!$.browser.msie
(el.currentStyle.position != 'relative'))

c += el[prop];

}

return c;

}

Maybe it should be change to like following:

function coord(el,prop) {

var c = el[prop], b = document.body;

while ((el = el.offsetParent) /*&& (el != b)*/) {

if (!$.browser.msie
(el.currentStyle.position != 'relative'))

c += el[prop];

} if(el == b)

break;

return c;

}

The attachment SpinButton.zip contain two demon to show the problem, their files are all the same, except JQuerySpinBtn.js

Attachments

SpinButton.zip Download (30.2 KB) - added by Aray 6 years ago.

Change History

Changed 6 years ago by Aray

comment:1 in reply to: ↑ description Changed 6 years ago by Aray

Replying to Aray:

The plugin Spin Button is greate, It is very usefull to me. Thank you for your greate work.

But there were a little problem in JQuerySpinBtn.js, wich I download from  http://www.softwareunity.com/sandbox/jqueryspinbtn/JQuerySpinBtn.js.

the function coord(el,prop) not work properly in IE if document.body's padding or margin is not ZERO.

Following is the offcial release of code

function coord(el,prop) {

var c = el[prop], b = document.body;

while ((el = el.offsetParent) && (el != b)) {

if (!$.browser.msie
(el.currentStyle.position != 'relative'))

c += el[prop];

}

return c;

}

Maybe it should be change to like following:

function coord(el,prop) {

var c = el[prop], b = document.body;

while ((el = el.offsetParent) /*&& (el != b)*/) {

if (!$.browser.msie
(el.currentStyle.position != 'relative'))

c += el[prop];

} if(el == b)

break;

return c;

}

I am so sorry that I have made a mistake, to fix the problem, the correct code should be as following.

function coord(el,prop) {

var c = el[prop], b = document.body;

while ((el = el.offsetParent) /*&& (el != b)*/) {

if (!$.browser.msie
(el.currentStyle.position != 'relative'))

c += el[prop];

if(el == b)

break;

}

return c;

}

The attachment SpinButton.zip contain two demon to show the problem, their files are all the same, except JQuerySpinBtn.js

comment:2 Changed 6 years ago by Aray

I found another problem when using IE. if the IE window have a scroll bar, and the scroll bar are note in Top or in Left position. It will not work properly

The reason is that, In IE, the Event.y is the distance of document top to mouse point, this distance is NOT including the scroll bar position. so does the Event.x.

To solve this problem, find line "var y = e.pageY
e.y;" in JQuerySpinBtn.js, add following code below this line

if($.browser.msie) {

x += document.documentElement.scrollLeft;

y += document.documentElement.scrollTop;

}

I don't have enough knowledge of compatibility of JavaScript between IE,Firefox, blabla. The code may make some change.

comment:4 Changed 5 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

This is not a jQuery core bug. Please report plugin bugs to the plugin's author, or ask on the jQuery forums. jQuery UI bugs should be reported on the UI bug tracker,  http://dev.jqueryui.com .

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.