[jQuery] .css('top') for absolutely positioned items?
With absolutely positioned elements in FF, .css('top|left|right|bottom') is returning a calculated pixel value for items without any styling or class. In IE7, .css(...) returns 'auto' which is the correct value if no value has been supplied. How can I determine if an absolutely positioned object's top,left,right, or bottom has not been supplied? ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] .css('top') for absolutely positioned items
With absolutely positioned elements in FF, .css('top|left|right|bottom') is returning a calculated pixel value for items without any styling or class. In IE7, .css(...) returns 'auto' which is the correct value if no value has been supplied. How can I determine if an absolutely positioned object's top,left,right, or bottom have not been supplied? ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] .callMethod( method )
Doh! I just figured out what you were referring to Dave. Instead of using x["method"].call( ... ), I could just x["method"]( ... ). For some reason, I thought you were suggesting to use .attr() but again, doh! Initially I had stored the method reference in a variable to get the parameter footprint. That's why I was using .call() to reattach the method to its object. Again, thanks for your feedback and sorry for my confusion! ;-) -Original Message----- From: Antonio Collins [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 16, 2007 7:41 PM To: 'jQuery Discussion.' Subject: RE: [jQuery] .callMethod( method ) I don't quite follow your example: jQuery["attr"]("id") I assume this is what you're speaking of: $("#identifier")["attr"]("id") If so, is this not equivalent to $("#identifer")["id"]? Also, ["attr"] does not appear to provide access to methods so it is not a replacement for object['method-name'].call( object, parm, ... ); I realize that .callMethod() could be rewritten as: jQuery.fn.callMethod = function( method ) { try { return eval("this."+ method ); } catch (e) { return this; } } But we bar the use of eval() and consider it a security risk (or at least a wildcard that we don't want to deal with). Using eval() the following could be executed: $('#xyz').callMethod("hide();document.location.href='new url'") .callMethod() using the parsing technique at least ensures that any execution is limited to methods on the current jQuery collection. The parameter passing deficiencies could be addressed with a bit morecode, but for our purposes number conversion is sufficient. -Original Message- From: Dave Methvin [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 16, 2007 5:39 PM To: 'jQuery Discussion.' Subject: Re: [jQuery] .callMethod( method ) > I don't know if jQuery already has a way to do this (or if anyone else > would find it useful), but here's a simple extension to call a method > (with or with > parameters) via a string. Javascript lets you call a method directly with a string: jQuery["attr"]("id") gets the id for example. Instead of passing a string of arguments and parsing it you could just eval the attribute in the examples you gave. Ad-hoc parsing often will get you into trouble; for example the code you have will not process arglists that have strings with embedded commas. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] .callMethod( method )
I don't quite follow your example: jQuery["attr"]("id") I assume this is what you're speaking of: $("#identifier")["attr"]("id") If so, is this not equivalent to $("#identifer")["id"]? Also, ["attr"] does not appear to provide access to methods so it is not a replacement for object['method-name'].call( object, parm, ... ); I realize that .callMethod() could be rewritten as: jQuery.fn.callMethod = function( method ) { try { return eval("this."+ method ); } catch (e) { return this; } } But we bar the use of eval() and consider it a security risk (or at least a wildcard that we don't want to deal with). Using eval() the following could be executed: $('#xyz').callMethod("hide();document.location.href='new url'") .callMethod() using the parsing technique at least ensures that any execution is limited to methods on the current jQuery collection. The parameter passing deficiencies could be addressed with a bit morecode, but for our purposes number conversion is sufficient. -Original Message- From: Dave Methvin [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 16, 2007 5:39 PM To: 'jQuery Discussion.' Subject: Re: [jQuery] .callMethod( method ) > I don't know if jQuery already has a way to do this (or if anyone else > would find it useful), but here's a simple extension to call a method > (with or with > parameters) via a string. Javascript lets you call a method directly with a string: jQuery["attr"]("id") gets the id for example. Instead of passing a string of arguments and parsing it you could just eval the attribute in the examples you gave. Ad-hoc parsing often will get you into trouble; for example the code you have will not process arglists that have strings with embedded commas. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] .callMethod( method )
I don't know if jQuery already has a way to do this (or if anyone else would find it useful), but here's a simple extension to call a method (with or with parameters) via a string. jQuery.fn.callMethod = function( method ) { // calls any method of the object via the passed string; // parameters are optional and comma-delimited; any spaces are preserved; // multiple methods are delimited by a period following the parameter list (e.g.: show().hide()) if (typeof(method) != "string") return this; var a = []; if (method.indexOf(").") > -1) a = method.split(")."); else a = [method]; var self = this; for (var i = 0; i < a.length; i++) { method = a[i]; var j = (method + "(").indexOf( "(" ); var m = method.substr(0, j).replace(/(^\s*)|(\s*$)/g, ""); if (typeof(self[m]) != "function") return self; // tolerate invalid methods j++; var k = (method + ")").lastIndexOf( ")" ) - 1; var p = method.substr( j, (k - j) ); if (p == "") p = []; else { p = p.split(","); for (var k = 0; k < p.length; k++) if (!isNaN(p[k])) p[k] = Number(p[k]); } self = self[m].call( self, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9] ); } return self; } jQuery.fn.callMethodInAttribute = function( attribute, defaultMethod ) { return this.each( function() { jQuery(this).callMethod( this[attribute] ? this[attribute] : defaultMethod ); } ); } I find .callMethod() very helpful in debugging/testing but I also use it in production apps. We use a lot of declarative programming techniques and specify an object's behavior based namedspaced attributes. For example, with dozens of snazzy effects available, some 'designers' (aka managers) can't decide which to use. So we use an attribute to determine the hide/show effect. ... I currently have a storyboarded presentation that applies sequenced effects to various elements on a timeline. Trying to manage the effects procedurally is a chore, but with .callMethod() its as simple as adding time and actions to the element: ... ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] fadeIn/fadeOut question
Thanks for looking at this for me Alex. I've fixed the problem in interface elements. They overwrote jQuery's fx() to support their enhancements. Since interface elements hasn't been updated since Oct '06, their fx() had the same opacity issues that jQuery dealt with in recent releases. So, I just merged their changes with the latest jQuery fx() and everything is cool. I 'spose I'll go through their code base and look for any other overwrites that should be updated. -Original Message- From: Alex Cook [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 11, 2007 3:04 PM To: jQuery Discussion. Subject: Re: [jQuery] fadeIn/fadeOut question Sorry but I have no experience with Interface... it broke when I first tried it many moons ago and I've never gone back... I should give it another poke... sorry I can't help you here Tony... anyone else? -Original Message- From: Antonio Collins [mailto:[EMAIL PROTECTED] On Behalf Of Tony Collins Sent: Thursday, January 11, 2007 2:36 PM To: 'jQuery Discussion.' Subject: RE: [jQuery] fadeIn/fadeOut question I found the source of the problem. The interface elements plugin is the culprit: http://interface.eyecon.ro/about When its FX functionality is included, .fadeIn() won't restore an element that has had .fadeOut() applied under IE7. (ALEX: When I published the example, I removed that script tag and that's why the example did not exhibit the problem.) + Based on this behavior, does anyone have quick ideas as to what the bug in interface elements might be? + Does anyone have experience with Interface Elements? Should I just dump it and move to something else? + Can anyone suggest an alternative? The effects I'm interested in are slide, drop, pulsate, shake, grow, shrink, and puff (which can be seen at http://interface.eyecon.ro/demos). Example file: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml";> fadeIn/Out example var controller = { } controller.show = function () { var now = (new Date()).toString(); $("#test").html( now ).fadeIn(); window.setTimeout( controller.hide, 4000 ); if (!controller.log) controller.log = document.getElementById("log"); controller.log.value = now + "\n"+ controller.log.value; } controller.hide = function () { $("#test").fadeOut(); // changing this to .hide() will fix the problem } $(document).ready( function() { window.setInterval( controller.show, 5000 ); } ); HTML, BODY { overflow: hidden; } BODY { background-color: black; } Test -Original Message- From: Antonio Collins [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 10, 2007 8:05 PM To: discuss@jquery.com Subject: Re: [jQuery] fadeIn/fadeOut question > Hrm, what version of IE7? The box is working fine for me, and looks > exactly the same in FF and IE7... > > -ALEX Maybe I am going crazy. It's working fine for me now too! But I swear the barebones example WAS NOT working properly. I guess that's crazy talk... ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] fadeIn/fadeOut question
> Hrm, what version of IE7? The box is working fine for me, and looks > exactly the same in FF and IE7... > > -ALEX Maybe I am going crazy. It's working fine for me now too! But I swear the barebones example WAS NOT working properly. I guess that's crazy talk... ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] fadeIn/fadeOut question
Here's a barebones example page. While making the example, I've discovered that this is a quirks-mode issue. When the doctype is omitted, the box reappears in IE7 but its sized incorrectly. So, how can I get it to work as desired with the xhtml doctype? http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml";> fadeIn/Out example var controller = { } controller.show = function () { var now = (new Date()).toString(); $("#test").html( now ).fadeIn(); window.setTimeout( controller.hide, 4000 ); if (!controller.log) controller.log = document.getElementById("log"); controller.log.value = now + "\n"+ controller.log.value; } controller.hide = function () { $("#test").fadeOut(); // changing this to .hide() will fix the problem } $(document).ready( function() { window.setInterval( controller.show, 5000 ); } ); HTML, BODY { overflow: hidden; } BODY { background-color: black; } Test ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] fadeIn/fadeOut question
I have a div that should fadeIn/Out as its content is changed on a 15 second schedule. The desired behavior is: Div is displayed via .fadeIn() 14 secs later it is hidden via .fadeOut() and its content updated 1 sec later the cycle starts again The div fails to reappear after the first cycle. Using .hide() instead of .fadeOut() corrects the problem but I prefer the .fadeOut() effect. The div has background-color:transparent and must allow its underlying content to show through. Does anyone know what the problem is? (Target browser is IE7 using jQuery 1.0.3.) ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] jQuery support for namespace attributes
Hello all, Are there any plans to add support for namespace qualified attribute selectors? This would would allow the following code to work with the example xhtml doc. Script: $('[EMAIL PROTECTED]:data-url]'); Doc: http://www.w3.org/1999/xhtml"; xmlns:my="urn:my-stuff"> ... ... In the example above, the table is rendered on-the-fly from the results of my:data-url and the column TDs are populated using the expressions in my:field-expr. I've got my own code that can handle the qualified attributes (and works around an issue with table tags and IE6), but I can't figure out how the regexp filter for attributes in jQuery work. Since namespacing is the preferred method to combine custom data with an established xml format (like html), I think this would be a great addition to jQuery's XML support. Antonio Collins ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Question on jQuery 1.0.2
Second parameter is search type. vAttrValue = object.getAttribute(sAttrName [, iFlags]) sAttrName Required. String that specifies the name of the attribute. iFlags Optional. Integer that specifies one or more of the following flags: 0 Default. Performs a property search that is not case-sensitive, and returns an interpolated value if the property is found. 1 Performs a case-sensitive property search. To find a match, the uppercase and lowercase letters in sAttrName must exactly match those in the attribute name. 2 Returns the value exactly as it was set in script or in the source document. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brandon Aaron Sent: Tuesday, October 10, 2006 8:24 AM To: jQuery Discussion. Subject: Re: [jQuery] Question on jQuery 1.0.2 I would also like to know what the 2 is for. I didn't know getAttribute() could take a second param. -- Brandon Aaron On 10/9/06, Stephen Woodbridge <[EMAIL PROTECTED]> wrote: > Hi all, > > I was testing and found some very strange behavior in IE6 and Opera 9 > but works fine on FF 1.0.5. It looks like the problem is pointing to: > > line: 704 > return elem.getAttribute( name, 2 ); > > in this block of code: > > ... > } else if ( elem.getAttribute != undefined ) { alert(name + " > = " + value); > if ( value != undefined ) elem.setAttribute( name, value ); > return elem.getAttribute( name, 2 ); > } else { > ... > > > > Is this correct? > What does the 2nd argument do? > > -Steve > > ___ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] New plugin: toXML (XML serializer)
Hi John, My objections are mostly from a philosophical standpoint. Since it may sometimes return valid xml and sometimes return a doc fragment, what can you do with it? You can't load it in a document, you can't post it to a web service... you'd have to manually parse it to figure out what it includes and therefore what it could be used for. I think it could be improved if it wrapped its results in its own root element or was renamed to .toXmlMarkup(). Tony Collins -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Resig Sent: Thursday, October 05, 2006 8:20 PM To: jQuery Discussion. Subject: Re: [jQuery] New plugin: toXML (XML serializer) Tony - It's not, necessarily, implied that this plugin will return valid XML for an entire XML Document - instead, it's returning valid XML for an XML Document Fragment - which is perfectly "ok". I mean, you can't expect $([ item1, item2 ]).toXML() to give you a valid XML document - and forcefully wrapping itself seems foolhardy. If it was so much of a concern, maybe there could be a .toXMLDocument() which returned a valid XML document instead of just a fragment. --John On 10/5/06, Antonio Collins <[EMAIL PROTECTED]> wrote: > I'm sorry but I don't agree with this plugin's name or usage. It > simply appends multiple valid xml together so the result could be > invalid xml and include multiple root elements. In my opinion, the > result of any method named .toXML() should be valid xml and the > following tests should result in valid XML documents. > > IE: domDoc.loadXML( $([ item1, item2 ]).toXML() ); > FF: (new DOMParser()).parseFromString( $([ item1, item2 ]).toXML(), > "text/xml" ); > > Tony Collins > > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On Behalf Of Christof Donat > Sent: Thursday, October 05, 2006 10:02 AM > To: jQuery Discussion. > Subject: Re: [jQuery] New plugin: toXML (XML serializer) > > Hi, > > > The thing is, the main use case for a toXML() call is to send XML > > data via an ajax request. > > Well, I could imagine that there may be other usecases as well, like > doing search and replace operations on the string representation of a > XML which is reparsed afterwards. It was just a joke, but you may look at that "use case" > > which could be usefull for XML-Data as well: > > http://dean.edwards.name/weblog/2006/07/erlaubt/#comment7262 > > > The duration of the request greatly overshadows any optimisation > > that could be applied to toXML. > > Well, there are also use cases, where you can assume a really fast > network connections (inhouse with 1GB-Ethernet e.g.) and thus work > with huge datasets on the client side. Then suddenly the time, the > client and server need to process the request becomes the dominating factor. > > I think that jQuery could also be really usefull for Applications > using XULrunner (I haven't tried yet) and thus there are many other > use cases like e.g. working with RDF-Data, etc. - OK, we don't need to > emulate XMLSerializer then. > > > Also, I don't think it is a good idea to attempt to implement an > > XMLSerializer object for the sake of it, especially when the full > > interface isn't being implemented > > You are right here of course. I was too lazy to look for the > XMLSerializer-interface and see if the other functions can also be > simulated so easy. > > > As a rule I live by the KISS principle, and never optimise code > > unless it becomes a bottleneck, and then only do so under profiling conditions. > > Well, KISS is an optimization strategy :-) Most of the time code is > fast when it is simple, but "most of the time" is not "always". > > Christof > > ___ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > > > ___ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > -- John Resig http://ejohn.org/ [EMAIL PROTECTED] ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] New plugin: toXML (XML serializer)
I'm sorry but I don't agree with this plugin's name or usage. It simply appends multiple valid xml together so the result could be invalid xml and include multiple root elements. In my opinion, the result of any method named .toXML() should be valid xml and the following tests should result in valid XML documents. IE: domDoc.loadXML( $([ item1, item2 ]).toXML() ); FF: (new DOMParser()).parseFromString( $([ item1, item2 ]).toXML(), "text/xml" ); Tony Collins -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Christof Donat Sent: Thursday, October 05, 2006 10:02 AM To: jQuery Discussion. Subject: Re: [jQuery] New plugin: toXML (XML serializer) Hi, > The thing is, the main use case for a toXML() call is to send XML data > via an ajax request. Well, I could imagine that there may be other usecases as well, like doing search and replace operations on the string representation of a XML which is reparsed afterwards. It was just a joke, but you may look at that "use case" which could be usefull for XML-Data as well: http://dean.edwards.name/weblog/2006/07/erlaubt/#comment7262 > The duration of the request greatly overshadows any optimisation that > could be applied to toXML. Well, there are also use cases, where you can assume a really fast network connections (inhouse with 1GB-Ethernet e.g.) and thus work with huge datasets on the client side. Then suddenly the time, the client and server need to process the request becomes the dominating factor. I think that jQuery could also be really usefull for Applications using XULrunner (I haven't tried yet) and thus there are many other use cases like e.g. working with RDF-Data, etc. - OK, we don't need to emulate XMLSerializer then. > Also, I don't think it is a good idea to attempt to implement an > XMLSerializer object for the sake of it, especially when the full > interface isn't being implemented You are right here of course. I was too lazy to look for the XMLSerializer-interface and see if the other functions can also be simulated so easy. > As a rule I live by the KISS principle, and never optimise code unless > it becomes a bottleneck, and then only do so under profiling conditions. Well, KISS is an optimization strategy :-) Most of the time code is fast when it is simple, but "most of the time" is not "always". Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] .toggleClass()
Thanks for your reply. One other question though. Since the docs that I know of (jquery.com/docs and jquery.com/images/jQuery-Map.png) made no mention of .toggleClass(), is additional documentation available at another location? I don't like to start calling methods based on the source code since a) I can't distinguish between published API methods and internal-use-only methods which might be subject to change b) I might misinterpret the purpose/usage of a method. However, is doing so a reasonable approach to learn jQuery's full capabilities? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dave Methvin Sent: Tuesday, August 08, 2006 6:03 PM To: 'jQuery Discussion.' Subject: Re: [jQuery] .toggleClass() > Is a .toggleClass( className ) method (or similar) available? Yes, toggleClass is there and has been for some time. Please check before posting to keep the list traffic manageable. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] .toggleClass()
Hello, Is a .toggleClass( className ) method (or similar) available? The behavior is/would be similar to .toggle() and quite simple: if the className is present, remove it; if its absent, add it. This method would make it easy to handle objects with two visual states (e.g.: active/inactive). ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/