Re: [jQuery] Sorting items in jQuery pseudo-array
I'd guess it's because arguments isn't really an array (it has a length property, but none of Array's methods). Something like this might do the trick: jQuery.fn.sort = function() { for(var i = 0, args = []; i arguments.length; i++) args.push(i); return this.pushStack( [].sort.apply( this, args ), []); }; Luke Bruce McKenzie wrote: There was a thread on this list in October which indicates (if I read it right) that I ought to be able to rearrange some paragraphs as follows: script type=text/javascript $(function(){ jQuery.fn.sort = function() { return this.pushStack( [].sort.apply( this, arguments ), []); }; $(p.items).sort(function(a,b){ return a.innerHTML b.innerHTML ? 1 : -1; }).appendTo(#Foo); }); /script/head body div id='Foo' p class='items'C/p p class='items'B/p p class='items'A/p /div /body /html But this error results: error: second argument to Function.prototype.apply must be an array Is it me -- or does the sort function need to be adjusted for jQuery 1.1.1 (and how would a person do that :-) ? -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Function.call() and xss?
I got an email today that one of my plugins might be a cross-site scripting/security risk because the plugin uses the Function.call() method, like so: $.fn.plugin = function(elem, options, callback) { callback.call(elem, options); }; Has anyone heard of or dealt with this problem? If it is a security risk, wouldn't Function.apply also be an issue? Thanks, Luke ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Function.call() and xss?
I thought Function.call/Function.apply were pretty common, so until I see some documentation, I'm assuming it's FUD. I asked the person who mentioned it if he knew of any documentation, but I haven't heard back yet... Luke John Resig wrote: I don't know about that... are there any specifics relating to this, or is it just FUD? I mean, there's tons of ways to do XSS stuff - triggering a function call seems hardly worthy of additional attention. Plus, if you're in a situation where XSS may be a factor, this is probably the least of your worries. --John On 3/23/07, Luke Lutman [EMAIL PROTECTED] wrote: I got an email today that one of my plugins might be a cross-site scripting/security risk because the plugin uses the Function.call() method, like so: $.fn.plugin = function(elem, options, callback) { callback.call(elem, options); }; Has anyone heard of or dealt with this problem? If it is a security risk, wouldn't Function.apply also be an issue? Thanks, Luke ___ 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] jquery.de
Why not see if you can get involved with the 'official' effort? John Resig mentioned at SXSW that part of what's taking time is getting things translated, and finding people who speak the language (German in this case) to help organize and maintain the non-english versions. Maybe you could help? Luke Yansky wrote: I'd say go for it. There's already a Chinese one http://bbs.jquery.org.cn/ Michael Fuerst wrote: Hi, sorry, this is could a little of topic: Maybe some of you already found jquery.de and wondered what's it all about and why there isn't happening anything: I registered jquery.de a year ago, just befor jquery got really popular. As I'm not a big mailing list fan I thought it would be nice to have a german speaking jQuery forum. I contacted John and told him about my plans and he thought it was okay, but told me, that he is also working on a multi language webpage based on Drupal for jQuery and we could also link jquery.de to the German part of his new webpage. We agreed to wait until his page is ready and not go on with a seperate forum. Unfortunately almost one year hast past now and nothing happend. I was contacted by Paul Bakaus of the jQuery developing team two month ago, but all attempts to get in touch again faild. So I was wandering what you poeple think about this. Should we wait until hopefully one day the multi language page will be ready, or should we go on and try to create a German speaking support forum on our own? Don't get me wrong, I do not plan to create competition for this mailing list or something where I get money out of it. Nor is this ment to be any critcism for the development team or John. I simply want to know, how to go on with jquery.de Best regards, Michael ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Find first parent element with certain style
Daemach2 wrote: Try doing console.log($(this).css(backgroundColor)) in the second function to see what those background colors are showing up as. Watch out for Safari, it sometimes returns 'rgba(0,0,0,0)' instead of 'transparent' ... Luke -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Find first parent element with certain style
Yansky wrote: I'm having a bit of trouble figuring out how to do this. What I'd like to do is find the first parent element that has a background color that is not transparent. This is what I've tried so far, but with no success: $('.elemToFade:first').parents([EMAIL PROTECTED] != 'transparent']:first); this also didn't work: $('#theDiv').parents().each(function(i){ if($(this).css(backgroundColor) != transparent){ return.this[0];} }); Here's a snippet I've used in the past: var bgcolor = function(el) { var color = jQuery(el).css('background-color'); if(/^(rgba|transparent)/.test(color) el.parentNode) return arguments.callee(el.parentNode); return color; }; Use it like this: var mybgcolor = bgcolor($('#myelement')[0]); Luke -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQuery at SXSW?
Monday sounds good to me :-) Luke On 11-Mar-07, at 12:30 AM, John Resig wrote: Absolutely. Let's try for Monday, I'll make a post to the jQuery blog and see if we can drum up some more people. I already talked with a bunch today, so I know that there's more out there! Looking forward to seeing everyone! --John On 3/10/07, Luke Lutman [EMAIL PROTECTED] wrote: Are there any other jQuery folks at SXSW this weekend? Apparently John Resig was at the Web Vector graphics panel this afternoon, but I missed him. Anyone interested in grabbing a beer in Austin to toast jQuery? :-) Maybe during the lunch break on Sunday... Rawk! Luke ___ 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/
[jQuery] jQuery at SXSW?
Are there any other jQuery folks at SXSW this weekend? Apparently John Resig was at the Web Vector graphics panel this afternoon, but I missed him. Anyone interested in grabbing a beer in Austin to toast jQuery? :-) Maybe during the lunch break on Sunday... Rawk! Luke ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jquery flash sIFR fla file
I should've replied earlier ... I've sent Sam a Flash 7 version of the fla. The filters are just to make the text look better (adding an invisible drop shadow gets rid of the colour artifacts produced by 'anti-alias for readability' in Flash 8). Everything should work fine without the filters :-) Luke Schnuck wrote: i was about to resave this in flash 7 for you but it gives me a warning that filters will get lost by doing so - i take that as the whole thing will be nonfunctional afterwards. sorry. On 04/03/07, Sam Sherlock [EMAIL PROTECTED] wrote: I am playing around with the flash plugin for jquery trying to get the sIFR woking within a site. I have downloaded the fla file but it does not open in my flash 7 http://jquery.lukelutman.com/plugins/flash/jfr.fla I was hoping that either Luke or someone might be able either send me a fla (that works with flash mx 2004 off list) or provide some instruction on how to customise the sIFR 2 flash files. thanks - S ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQuery and Rails
Yehuda Katz wrote: 1) Are you using Rails? Yes :-) 3) Would you prefer an approach that generated JS by writing Ruby helpers that generated jQuery code, or an approach that made is easier to link up existing jQuery code into Rails? 4) If you've used jQuery with Rails, what issues have you run into I'd prefer not to have helpers that generate js -- I can write javascript myself. I'd rather see the integration issues solved. One of the best things about rails is that it lets you bypass all the magic when you need to. Helpers (i.e. form_remote, etc.) can't handle every situation, so having accessible building blocks is crucial to me. I realize there is a group of people who'd like to just write everything in Ruby (i.e. get to use javascript without having to know javascript), but I think that's a red herring. Plus, those concerns can be addressed by more complicated helpers, built on the more basic ones. Here are the main issues I've run into: + unobtrusively including js specific to a view + targeting elements on a page without adding ID's all over the place + concatenation, compression and caching (i.e. cache the packed version of a bunch of scripts) I think what I'd like (ideally) would be a basic helper (that wouldn't even need to be jQuery-specific) that I could call from any view which would concatenate, compress, and cache (fragment cache? page cache?) bits of javascript or javascript files, and add a script src=.../script tag to the head. If you have a plugin (or some custom code in an external file) that you only use in a few places, you could include it alongside inline script (if it was more widely used, it would go in your application-wide js file). So, in whatever.rhtml, do something like: % javascript :file = 'path/to/plugin.js' % % javascript :text = %{ $('p').css('color','blue'); } % pWhatever.../p % javascript :text = %{ $('p').css('font-size', '2em'); }% % And get: html head script type=text/javascript src=whatever.js/script /head body pWhatever.../p /body /html In a way, what I'm picturing is very jQuery-centric -- there's a core utility, plus plugins (i.e. more complex, task-specific helpers). Luke ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQuery and Rails
Klaus Hartl wrote: Luke, have you tried to use the AssetPackager plugin? It is not totally automatic as you have to define the scripts to be packed in one yml, but thats okay for me. I think merging whatever JavaScript there is into a file is not always good for files that are only included in special views, because that would result in a file that would not be loaded from cache because of the (minor) differences. -- Klaus I hadn't seen AssetPackager before ... thanks for the tip! And I agree, the contatenation and caching would be tricky to get right. Luke -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQuery.flash plugin and ExternalInterface
I don't think you need window[] or document[], try: $('#flash_id')[0].callback(); Luke spinnach wrote: Hi, i'm using the jQuery flash plugin to embed a flash movie to a webpage, and the ExternalInterface to communicate between flash and javascript.. in firefox everything's working as expected, but i can't get it to work in ie.. these are the as and javascript snippets: flash: import flash.external.*; ExternalInterface.addCallback('callback', this, callback); js: flash = ($.browser.msie) ? window['flash_id'] : document['flash_id']; flash.callback(); tnx.. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Google's Summer of Code
John Resig wrote: - Add jQuery support to a popular CMS/Framework jQuery for Ruby On Rails would be fantastic :-) Luke ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQuery.flash plugin and ExternalInterface
If it's an object vs. embed issue, you could overwrite jQuery.fn.flash.transform with a function that returns an object tag for IE. Getting object to work is a bit tricky, but this A List Apart article (http://alistapart.com/articles/flashembedcagematch) describes the known issues. Luke spinnach wrote: ..i switched from swfobject to jquery.flash, to avoid redundancy, and this plugin uses swfobject.. but if it won't work any other way, i'll use it :).. thanks anyway.. Benjamin Sterling wrote: I had the same issue a while back and got it to work using this plugin http://malsup.com/jquery/media/. -- Benjamin Sterling http://www.KenzoMedia.com http://www.KenzoHosting.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQuery Design Decisions? Comparison to MooTools?
Matt Kruse wrote: 1) There seems to be a lot of emphasis on using selectors and pseudo-selectors to access everything. It makes code short and simple, but is it really the most efficient? Reusing selectors helps performance. You can reuse a selection by storing selected elements in a variable, like this: var $p = $('p'); You can then run as many operations as you like on $p, without any more selections. Most of the time, you can take it a step further, and hang onto selections across multiple elements/function invocations using closures: $(document).ready(function(){ var $p = $('p'); $('a').bind('click', function(){ $p.doSomething(); }); }); This way, unless the dom changes, you only have to make the selection once. :-) Luke ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Bug: jQuery/Packer/ActiveX
# Background Inserting an ActiveX control (i.e. flash movie, quicktime movie) with an external javascript (i.e. jQuery) should avoid the ugly grey box and having to click to activate. See: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/activating_activex.asp # Bug ActiveX controls inserted using the **packed version of jQuery** have the grey box and must be activated. See: jQuery/Packer/ActiveX Bug for more info. See: http://www.nabble.com/Packer-and-ActiveX-...-tf2649396.html http://jquery.com/dev/bugs/bug/930/ http://jquery.lukelutman.com/plugins/flash/activex/ # Fix (Klaus Hartl suggested this fix: http://jquery.com/discuss/2006-August/009778/, but that doesn't work for me using the packed version of jQuery.) I've narrowed the problem down to the jQuery.clean method, which uses a temporary div's innerHTML to convert html strings into DOM elements. Doing the conversion from unpacked code fixes the problem, so I'd like to suggest adding a convert hook inside jQuery.clean (see http://jquery.com/dev/bugs/bug/930/ for patch). Without the hook, the entire jQuery.clean method has to be overwritten. With the hook, the bug could be fixed by overwriting jQuery.clean.convert from outside of the packed code (i.e. via a plugin, or by copying and pasting jQuery.clean.convert = function(html) {...} at the bottom of jquery-latest.packed.js). Luke ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Embedding Flash -- Troubles with jQuery.ready() SWFObject?
It is now time to let the fanciness commence ;) But of course ;-) Why not fight fancyness with fancyness? In your flash movie, try this actionscript on the first frame: getURL(javascript:$('#FP').doWhatever('abc',123);); If you wanted to do that for multiple flash movies, you'd just have to pass in the appropriate id as a flashvar :-) Cheers, Luke P.S. A bit of shameless self-promo here ... why not use the jQuery Flash plugin (http://jquery.lukelutman.com/plugins/flash)? Brice Burgess wrote: Luke, Sam - Thank you for clarifying the issue for me. It's always the simple things that take the longest to debug ;( Another thing I learned is that if the DOM element containing the embedded flash is hidden (display: none), I cannot send commands/interact with the SWF via Javascript. I would get [method name] is not a method errors. There is apparently a small delay when showing/hiding/creating the flash videos -- which is related to my $().ready() issue. To get around this, I wrote a simple queue plugin which continually tries to execute a method until it is successful. Here's the code; (function($) { $.fn.fq = function(o) { var i=this[0].id; $.fq.q(i,o,0); return this; } $.fq = { q: function(i,o,c) { if(c20) return; var e=$('#'+i)[0]; (e[o]) ? e[o]() : setTimeout($.fq.q('+i+','+o+',+(c+1)+);,350); return; } }; })(jQuery); Example use; div id=fp/div ... var fo = new SWFObject(flowplayer/FlowPlayer.swf, FP, 730, 510, 7); ... fo.write(fp); $('#FP').fq('DoPlay'); // Continually try to execute the DoPlay method on the DOM element created by SWFObject. NOTE: I think my method queue function doesn't work in opera. The whole thing may be garbage [quick hack on no sleep] ;) Also.. for some reason in seems that if I cache the element ($('#'+i)[0]) it will never detect the new method.. so I perform the getElementByID() function per loop cycle. Luke Lutman wrote: Since you're not doing anything fancy, why not just pass the config as flashvars and save yourself a world of hurt? ;-) It is now time to let the fanciness commence ;) ~ Brice ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Embedding Flash -- Troubles with jQuery.ready() SWFObject?
Sorry, forgot to mention you'd also need a bit of javascript to go with that: jQuery.fn.doWhatever = function(foo,bar) { ... } Luke Luke Lutman wrote: It is now time to let the fanciness commence ;) But of course ;-) Why not fight fancyness with fancyness? In your flash movie, try this actionscript on the first frame: getURL(javascript:$('#FP').doWhatever('abc',123);); If you wanted to do that for multiple flash movies, you'd just have to pass in the appropriate id as a flashvar :-) Cheers, Luke P.S. A bit of shameless self-promo here ... why not use the jQuery Flash plugin (http://jquery.lukelutman.com/plugins/flash)? Brice Burgess wrote: Luke, Sam - Thank you for clarifying the issue for me. It's always the simple things that take the longest to debug ;( Another thing I learned is that if the DOM element containing the embedded flash is hidden (display: none), I cannot send commands/interact with the SWF via Javascript. I would get [method name] is not a method errors. There is apparently a small delay when showing/hiding/creating the flash videos -- which is related to my $().ready() issue. To get around this, I wrote a simple queue plugin which continually tries to execute a method until it is successful. Here's the code; (function($) { $.fn.fq = function(o) { var i=this[0].id; $.fq.q(i,o,0); return this; } $.fq = { q: function(i,o,c) { if(c20) return; var e=$('#'+i)[0]; (e[o]) ? e[o]() : setTimeout($.fq.q('+i+','+o+',+(c+1)+);,350); return; } }; })(jQuery); Example use; div id=fp/div ... var fo = new SWFObject(flowplayer/FlowPlayer.swf, FP, 730, 510, 7); ... fo.write(fp); $('#FP').fq('DoPlay'); // Continually try to execute the DoPlay method on the DOM element created by SWFObject. NOTE: I think my method queue function doesn't work in opera. The whole thing may be garbage [quick hack on no sleep] ;) Also.. for some reason in seems that if I cache the element ($('#'+i)[0]) it will never detect the new method.. so I perform the getElementByID() function per loop cycle. Luke Lutman wrote: Since you're not doing anything fancy, why not just pass the config as flashvars and save yourself a world of hurt? ;-) It is now time to let the fanciness commence ;) ~ Brice ___ 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] image preloading
Ok, did a quick test in FF and Safari :-) - The function doesn't wait, it makes all the requests at once (more or less). - The variable gets overwritten. - It doesn't interrupt the download. One thing I did find was that if I do: var img = new Image(); img.onload = function(){ var that = this; } img.src = arguments[i]; Then the variable 'that' will point to window, not img. However, if I do: var img = document.createElement('img'); img.onload = function(){ var that = this; } img.src = arguments[i]; Then the variable 'that' will point to img, and the event handler will work as expected. Luke PragueExpat wrote: Luke, this is a great technique - thanks! As far as my original question, I am still curious to find out the following: With the following preload function: $.preloadImages = function() { for(var i = 0; iarguments.length; i++) { img = new Image(); img.src = arguments[i]; } } does the browser completely download each image before the script changes the source and begins the next download or is/can the image download be interrupted by the variable being reassigned? Anyone? ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Embedding Flash -- Troubles with jQuery.ready() SWFObject?
Ahh, I missed that it was an open-source player. I'll shut up now ;-) Luke Brice Burgess wrote: Luke Lutman wrote: In your flash movie, try this actionscript on the first frame: getURL(javascript:$('#FP').doWhatever('abc',123);); Correct me if I am wrong.. but I *think* you're hinting at altering the actual SWF -- which I theoretically could because it's an open source project (flowplayer), although haven't setup the development bed yet. I do not know if it is necessary? Here is what I am trying to accomplish; Embed flowplayer in a hidden div (display:none). When you click a trigger, the div is made visible ($(div).show()) the movie plays. Using the fq method queueing system I was more or less able to accomplish this with code similar to; MARKUP; div style=display:nonediv id=fp/div/div JS; var fo = new SWFObject(flowplayer/FlowPlayer.swf, FP, 730, 510); ... fo.write(fp); $('div:hidden').show().find('#FP').fq('DoPlay'); NOTE; Flowplayer allows you to interact with the SWF via JS (e.g. the DoPlay() method). You cannot interact with the movie, however, if it is hidden (display:none). Is it *common* behavior to stop a flash movie when its container is hidden? Is this cross browser/platform behavior? why not use the jQuery Flash plugin (http://jquery.lukelutman.com/plugins/flash)? The only reason I've used SWFObject is that was what the author's examples used. I'll be switching to your jQ Flash plugin as soon as I get this sorted out. Thanks! ~ Brice ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] New Plugin: Pseudo (:before and :after in IE)
Hi Everyone, I was frustrated today with IE not supporting the :before and :after CSS2 selectors, so I've written a plugin that (more or less) enables them :-) http://jquery.lukelutman.com/plugins/pseudo/ Luke P.S. Fun fact: the plugin hacks IE with it's own proprietary junk, like so: * { behavior: expression(...); } Take that, Internet Exploderer! ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Embedding Flash -- Troubles with jQuery.ready() SWFObject?
I've run into this before too... Calling a method (i.e. setConfig(), setVariable()) of the flash player (in Firefox it's an NPObject, in IE it's an ActiveX object) before the swf has loaded will throw an error. The ready event fires before your swf has loaded, which throws an error. The load event doesn't fire until the swf (and everything else) has finished loading, hence, no error. Since you're not doing anything fancy, why not just pass the config as flashvars and save yourself a world of hurt? ;-) Luke Sam Collett wrote: On 04/02/07, Brice Burgess [EMAIL PROTECTED] wrote: I am trying to embed flowplayer; http://flowplayer.sourceforge.net/ For some reason I cannot access an embedded SWFObject within a $().ready function. FF errors out with invalid access to a NPObject, or that the setConf method is not found? I am not sure what this means.. but I do know that if I switch from $().ready to window.onload, the problem goes away. Here's one of my examples; div id=fpholder ...get flash text /div script type=text/javascript var fo = new SWFObject(FlowPlayer.swf, FlowPlayer, 500, 560, 7, #ff, true); fo.addParam(allowScriptAccess, always); fo.addParam(flashVars, config={configInject: true}); fo.write(fpholder); function init() { var fpConf = { videoHeight: 320, hideControls: false }; var fp=$(#FlowPlayer)[0]; fp.setConfig(fpConf); } // $().ready(function(){ init(); }); -- DOES NOT WORK // window.onload = init; -- WORKS /script I have tried many, many combinations.. but can't seem to figure out what is causing this issue. Perhaps someone with deeper knowledge of the .ready() function, or SWFObject experience will have an idea? Thanks! ~ Brice Did you try using load instead of ready? $().load(function(){ init(); }); ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] image preloading
Here's what I use: $(window).bind('load', function(){ var preload = [ '/images/assets/file/1.gif', '/images/assets/file/2.gif', '/images/assets/file/3.gif' ]; $(document.createElement('img')).bind('load', function(){ if(preload[0]) this.src = preload.shift(); }).trigger('load'); }); This loads the images sequentially, so you don't have to worry interrupting one image with another. It's much nicer to your server too, because there won't be a barrage of image requests all at once. I'd also suggest waiting to start preloading until the page has finished loading. Right now, you're preloading at the same time the page is loading, which will make the page feel slow (especially if you're preloading a lot of images). Cheers, Luke PragueExpat wrote: Using the method below to preload images, I have a simple question: The same variable (in this case 'img') is being used for all preloaded images. Img.src is used to tell the browser to make a call to the server to fetch the image What if the connection to the server is slow (or the image is large) - does the script wait until the image is loaded before continuing or is there a chance that the variable will be overwritten (because of the loop) and its source set to the next image before the first image is fully downloaded? I use this script and it works fine, but I would like to find out if a potentially slow client might have different results. Thanks. Sam Collett wrote: Perhaps you could use something like this: $.preloadImages = function() { for(var i = 0; iarguments.length; i++) { img = new Image(); img.src = arguments[i]; } } Then you call it as soon as possible (it doesn't have to be in $(document).ready): $.preloadImages(foo.gif, bar.gif); $(document).ready(function() { ... }); On 28/09/06, Aljosa Mohorovic [EMAIL PROTECTED] wrote: is there a preferred way to preload images when site uses jquery? how do you usually preload images? Aljosa Mohorovic ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] image preloading
Ⓙⓐⓚⓔ wrote: making all the requests and at the top mimics the normal image load ... the only case where sequencing might help is when the server is configured strangely , or just can't handle the requests... (as in thousands of large graphics??). The page I wrote that snippet for was an image gallery (about full size image, plus thumbnails). The thumbnails and one image are visible when the page loads, and the other full-size images are shown when you click on the corresponding thumbnail. If I preloaded the 29 hidden full-size images on document ready, the page felt ry slow because it loaded all the hidden images before loading the ones that were visible! As far as the server benefits, imagine the page above being loaded by 30 users at the same time. Preloading the images sequentially only takes up 30 connections at any given time. Preloading them all at once could take up 870 connections! It might not make much difference, but it doesn't hurt, either ;-) But I do like the technique! Does that actually load , wait and repeat? and you don't have to re-trigger? Yep, you got it :-) Luke On 2/5/07, *Luke Lutman* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Here's what I use: $(window).bind('load', function(){ var preload = [ '/images/assets/file/1.gif', '/images/assets/file/2.gif', '/images/assets/file/3.gif' ]; $(document.createElement('img')).bind('load', function(){ if(preload[0]) this.src = preload.shift(); }).trigger('load'); }); This loads the images sequentially, so you don't have to worry interrupting one image with another. It's much nicer to your server too, because there won't be a barrage of image requests all at once. I'd also suggest waiting to start preloading until the page has finished loading. Right now, you're preloading at the same time the page is loading, which will make the page feel slow (especially if you're preloading a lot of images). Cheers, Luke PragueExpat wrote: Using the method below to preload images, I have a simple question: The same variable (in this case 'img') is being used for all preloaded images. Img.src is used to tell the browser to make a call to the server to fetch the image What if the connection to the server is slow (or the image is large) - does the script wait until the image is loaded before continuing or is there a chance that the variable will be overwritten (because of the loop) and its source set to the next image before the first image is fully downloaded? I use this script and it works fine, but I would like to find out if a potentially slow client might have different results. Thanks. Sam Collett wrote: Perhaps you could use something like this: $.preloadImages = function() { for(var i = 0; iarguments.length; i++) { img = new Image(); img.src = arguments[i]; } } Then you call it as soon as possible (it doesn't have to be in $(document).ready): $.preloadImages(foo.gif, bar.gif); $(document).ready(function() { ... }); On 28/09/06, Aljosa Mohorovic [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: is there a preferred way to preload images when site uses jquery? how do you usually preload images? Aljosa Mohorovic ___ jQuery mailing list discuss@jquery.com mailto:discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com mailto:discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com http://www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com mailto:discuss@jquery.com http://jquery.com/discuss/ -- Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] image preloading
Ⓙⓐⓚⓔ wrote: I love the brevity of your solution!! $(document.createElement('img')).bind('load', function(){ if(preload[0]) this.src = preload.shift(); }).trigger('load'); Thanks ;-) It works because the onload handler gets reused -- it fires after the image finishes loading, which starts the next image loading, which triggers the onload handler, which starts the next image ... and so on :-) Luke ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Fontsize in SIFR
Unfortunately not. sIFR measures the element that's being replaced, then scales the font to fit, so unless the html font and the flash font are very similar, the sizes will be different (and difficult to predict). I've been working on a text-replacement plugin that takes the opposite approach -- set the flash text at a specific size/line-height and then use javascript to resize the swf -- but it's not quite ready for primetime yet :-( Luke Olivier Percebois-Garve wrote: Hi I am currently implementing sifr, and the fontsize is changing quite randomly. (I know alkready that sifr is doing some sort of calculation of the available space, and that it is being done better in the v3) Is it possible to force the size once for all ? Olivier ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Equal Height DT/DDs
There's actually already a text-resize plugin for jQuery, called jQEm: http://davecardwell.co.uk/geekery/javascript/jquery/jqem/ I've got a stripped down version of the above that I use: http://jquery.lukelutman.com/plugins/emchange/jquery.emchange.js Have fun :-) Luke Will Mo wrote: Thank you Sam. Reading it now. On 1/26/07, *Sam Collett* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: A List Apart has an article on text-resize detection that may be of some use: http://alistapart.com/articles/fontresizing ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] SWFObject Embed
Here's the link to my plugin: http://jquery.lukelutman.com/plugins/flash Luke Sam Sherlock wrote: have you tried Luke Lutmans flash plugin? Its inspired by sIFR, swfObject UFO. using the flash plugin in place of swfObject. On 10/01/07, * xmrcivicboix* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi guys, I having an issue with SWFObject embed in IEs. Firefox works like a charm but IE does not show up any thing. Not even when i do a dom inspection. Here is the code. createCDE: function() { $(body).append('div id=CDE style=position:absolute; z-index:1; overflow:hidden; top:0px; left:0px;/div'); $(#CDE).after('script type=text/javascript \n' + 'var flex_tag = new SWFObject(flash/CopyDeckEditor.swf, editor, 100px, 100px, 9, #ff); \n' + 'flex_tag.addParam(menu, false); \n' + 'flex_tag.addParam(quality, high); \n' + 'flex_tag.addParam(wmode, transparent); \n' + 'flex_tag.addParam(allowScriptAccess,sameDomain); \n' + 'flex_tag.write(CDE); \n' + '/script'); } When I use firebug to navigate the dom, it actually shows that the flash is embedded but not in IE. -- View this message in context: http://www.nabble.com/SWFObject-Embed-tf2955498.html#a8267524 Sent from the JQuery mailing list archive at Nabble.com http://Nabble.com. ___ jQuery mailing list discuss@jquery.com mailto: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] SWFObject Embed
The plugin just inserts a swf, so you can do whatever you like -- drop shadows or other flash 8 filters -- inside the swf :-) Luke xmrcivicboix wrote: wow very cool. I just searched around to see if you can do filters (drop shadow). Any chance this plugin will let you do drop shadows and stuff? Luke Lutman wrote: Here's the link to my plugin: http://jquery.lukelutman.com/plugins/flash Luke Sam Sherlock wrote: have you tried Luke Lutmans flash plugin? Its inspired by sIFR, swfObject UFO. using the flash plugin in place of swfObject. On 10/01/07, * xmrcivicboix* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi guys, I having an issue with SWFObject embed in IEs. Firefox works like a charm but IE does not show up any thing. Not even when i do a dom inspection. Here is the code. createCDE: function() { $(body).append('div id=CDE style=position:absolute; z-index:1; overflow:hidden; top:0px; left:0px;/div'); $(#CDE).after('script type=text/javascript \n' + 'var flex_tag = new SWFObject(flash/CopyDeckEditor.swf, editor, 100px, 100px, 9, #ff); \n' + 'flex_tag.addParam(menu, false); \n' + 'flex_tag.addParam(quality, high); \n' + 'flex_tag.addParam(wmode, transparent); \n' + 'flex_tag.addParam(allowScriptAccess,sameDomain); \n' + 'flex_tag.write(CDE); \n' + '/script'); } When I use firebug to navigate the dom, it actually shows that the flash is embedded but not in IE. -- View this message in context: http://www.nabble.com/SWFObject-Embed-tf2955498.html#a8267524 Sent from the JQuery mailing list archive at Nabble.com http://Nabble.com. ___ jQuery mailing list discuss@jquery.com mailto: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/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] .css() px vs. em
I've run into the same problem with IE :-( I did more or less what Dave suggested (untested, of course!): var $tmp = $('#some-element') .append('div style=position: absolute; width: ' + $('#some-element').css('font-size') + '; /') .find(':last-child') var fontSizeInPx = $tmp.width(); $tmp.remove(); This would work for other units (i.e. in, pt) and other properties (text-indent, line-height) too. Some things to watch out for: * the element you want to measure must be able to have children (i.e. not br /, img /) * this method makes the browser to two extra re-flows (I think?) * make sure the appended div doesn't pick-up any funny business from the cascade. Luke Dave Methvin wrote: Firefox is returning the value in pixels while IE6 is returning the value in ems. Is this a bug? It's just IE being IE. Other browsers have getComputedStyle which tells you the dimensions in pixels. IE has currentStyle; although that does tell you the current style (taking the CSS cascade into effect) it returns whatever dimensions were given in the style rule. jQuery's .css() method uses whatever it's dealt by the browser. I think I've seen IE hacks where you can put a box around a character and then measure the box in pixels to get the font size, but my Google-fu is weak at the moment. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] .css() px vs. em
Here it is as a plugin (I don't have IE handy, but it the IE part of the code works in FireFox): Example: $('#example').px('font-size'); - '12px' Plugin: (function($){ var $px = $(document.createElement('div')).css({ position: 'absolute' }); $.fn.px = function(prop) { var val; if($.browser.msie) { $px .clone() .css('width', this.css(prop)) .appendTo(this[0]) .each(function(){ val = $(this).width() + 'px'; }) .remove(); } else { val = this.css(prop); } return val; }; })(jQuery); Luke Luke Lutman wrote: I've run into the same problem with IE :-( I did more or less what Dave suggested (untested, of course!): var $tmp = $('#some-element') .append('div style=position: absolute; width: ' + $('#some-element').css('font-size') + '; /') .find(':last-child') var fontSizeInPx = $tmp.width(); $tmp.remove(); This would work for other units (i.e. in, pt) and other properties (text-indent, line-height) too. Some things to watch out for: * the element you want to measure must be able to have children (i.e. not br /, img /) * this method makes the browser to two extra re-flows (I think?) * make sure the appended div doesn't pick-up any funny business from the cascade. Luke Dave Methvin wrote: Firefox is returning the value in pixels while IE6 is returning the value in ems. Is this a bug? It's just IE being IE. Other browsers have getComputedStyle which tells you the dimensions in pixels. IE has currentStyle; although that does tell you the current style (taking the CSS cascade into effect) it returns whatever dimensions were given in the style rule. jQuery's .css() method uses whatever it's dealt by the browser. I think I've seen IE hacks where you can put a box around a character and then measure the box in pixels to get the font size, but my Google-fu is weak at the moment. ___ 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] Jquery Flash Plugin the FlashBlock Extension
Agreed, Klaus ... but Sam's not trying to get around it ;-) He just wants alternate content to show when flash is blocked, rather than the big ugly 'click to play the flash movie' placeholder that FlashBlock stuffs in. FWIW, I think FlashBlock is pretty silly... Luke Klaus Hartl wrote: Sam Sherlock schrieb: I have noticed that the flash plugin does not work with the flashBlock firefox extension whereas the both swfObject, UFO sIFR do work with the extension. In firefox with flashBlock installed and blocking flash content the flash is not displayed nor is the content that it replaces. I have looked at the source but its a bit beyond me. Would this be complicated to build into the plugin? My €0.02: If a user uses flashbock he actually *wants* to block flash, so why should one try to get around this? Why pissing off the user? -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] buildStyleString
I had to do something similar recently. What I did was overload the css and curCSS functions in jQuery to accept an array (of css property names), and return an object whose toString method builds the inline css string. For example: $('#single').css('font-size'); - 12px $('multi').css(['font-size','line-height']).toString(); - font-size: 12px; line-height: normal; I've packaged it up as a (not very thoroughly tested) plugin here: http://jquery.lukelutman.com/plugins/css/ http://jquery.lukelutman.com/plugins/css/jquery.css.js Cheers, Luke Yehuda Katz wrote: I'm looking for some help in building a plugin that would get the computed styles of an element and build an inline style string for that element. I assume it'd be something like looping through jQuery(el).css(styleName) and sticking the results together. Any more specific ideas? -- Yehuda Katz Web Developer | Wycats Designs (ph) 718.877.1325 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Flash plugin and ExternalInterface
I haven't used ExternalInterface before, but I have used: getURL(javascript:myfunction(123,'abc');); To call a javascript function from flash. This works like a charm if passing numbers and strings (or JSON strings) to the function will suffice, and is backwards compatible (as far as Flash 6, I think). Luke Kelvin Luck wrote: Hi, I'm using the really nice jQuery Flash Plugin( http://jquery.lukelutman.com/plugins/flash/ ) to embed some Flash in a page I'm building. This Flash needs to communicate with JS through Flash's ExternalInterface. When embedded with the plugin IE fires a JS error (a very useful Syntax error!). If I embed a different swf which doesn't use ExternalInterface all is fine. And of course everything is fine in Firefox. Has anyone run into any problems like this before? Cheers, Kelvin :) ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Jquery Flash Plugin the FlashBlock Extension
Hi Sam, I had a look, and FlashBlock blocked UFO and SWFObject movies, and sIFR showed the alternate content, so I'm guessing that by 'works with flashblock', you mean that the alternate content is show when flashblock is on, correct? From what I can tell, Flashblock looks for two things specific to sIFR: - element class=sIFR-replaced.../element, which it hides with inline styles (can be any element). - span class=sIFR-alternate.../span, and it shows with inline styles (has to be a span). To get the same behavior with the jQuery Flash Plugin, you can change the default replace function, like so: jQuery.fn.flash.replace = function(htmlOptions) { this.innerHTML = 'span class=alt sIFR-alternate'+this.innerHTML+'/span'; jQuery(this) .addClass('flash-replaced') .addClass('sIFR-replaced') .prepend($$.transform(htmlOptions)); }; Here's an example: http://jquery.lukelutman.com/plugins/flash/example-flashblock.html Luke Sam Sherlock wrote: I have noticed that the flash plugin does not work with the flashBlock firefox extension whereas the both swfObject, UFO sIFR do work with the extension. In firefox with flashBlock installed and blocking flash content the flash is not displayed nor is the content that it replaces. I have looked at the source but its a bit beyond me. Would this be complicated to build into the plugin? ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Efforts to Convert Folks to jQuery
Dave Methvin wrote: You start with 10 lines of jQuery that would have been 20 lines of tedious DOM Javascript. By the time you are done it's down to two or three lines and it couldn't get any shorter unless it read your mind. I think that should be the first paragraph on the homepage! It's concise, friendly (no buzzwords!), and highlights jQuery's biggest strength. Luke ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] How to get $.css values in px in Opera?
Hi jQuerians, I ran into a bit of an odd problem this morning: $.css returns values in whatever units they were set with in the stylesheet (Safari and Firefox both return values in px regardless of how they were defined). For example: p style=font-size: 12px; letter-spacing: 1emTesting, Testing, 123.../p In Safari and Firefox, $('p').css('letter-spacing') returns the string '12px'. But in Opera, it returns '1em', which isn't useful for calculating anything. As a workaround, I'm inserting an element: div style=position: absolute; visibility: hidden; width: 1em;x/div Then measuring it: var one_em = $('div').width(); Then fixing non-px values: var px = parseFloat($('p').css('letter-spacing')) * one_em + 'px'; Is there a better way of getting pixel values fox css properties in Opera? Thanks, Luke -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] How to get $.css values in px in Opera?
Ok, I did a little bit of digging, and it looks like this is actually a bug. In the curCSS function, on line 452 (r627), there's a check for elem.currentStyle : } else if(elem.currentStyle) { // stuff only ie should see } Apparently, this property exists in Opera, but contains the bogus values. If that check is changed to: } else if(elem.currentStyle !window.opera) { Then opera will use getComputedStyle and return the correct values, in pixels :-) I've submitted a ticket here: http://jquery.com/dev/bugs/bug/476/ Luke Dave Methvin wrote: I ran into a bit of an odd problem this morning: $.css returns values in whatever units they were set with in the stylesheet (Safari and Firefox both return values in px regardless of how they were defined). ... As a workaround, I'm inserting an element ... Then measuring it Is there a better way of getting pixel values fox css properties in Opera? I have run into the problem with IE and css properties like padding-left or border-right-width. Your trick of measuring an element's width only works if there is no padding on the element. Even then it doesn't work if a parent element is currently hidden, rendering the measured element hidden as well. So, as far as I know there is no jQuery core solution to this issue. Long ago, I played with mods to .css() to get reliable pixel measurements for all those properties, but it got complicated and seemed like a performance nightmare. A simple call like .css(border-left-width) could be very slow, and often you'd be making several calls to get all four borders. Brandon later built the dimensions plugin and its approach of getting multiple properties at once seems like the right way. It's probably best to extend dimensions.js if this is widely needed functionality. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Packer and ActiveX ...
Hi everyone :-) I've run into a bit of an odd problem with my flash plugin (http://jquery.lukelutman.com/plugins/flash) in IE. The standard workaround for the ActiveX control activation/Eolas/greybox issue in IE is to insert flash movies using an *external* javascript file. Using the uncompressed version of jQuery, everything works as expected (i.e. you don't have to 'click to activate' flash movies). However, using the packed version of jQuery, the workaround fails and the dreaded 'click-to-activate' is back :-( From what I can tell, IE doesn't seem to think the eval()'d jQuery code comes from an 'external' javascript file anymore. Using JSMin (http://www.crockford.com/javascript/jsmin.html) instead of Packer solves the problem ... but it's extra work. Does anyone have suggestions on how to preserve the 'externalness' of the packed version of jQuery? Thanks, Luke Lutman ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Extend a Plug-In
Jörn Zaefferer wrote: As far as I know, that is yet an unresearched topic. So far there is a nice guide and tons of example code for writing plugins, but not for extending them. So far someone extends his local copy for his own needs and trie to contribute them back to the original. Or they start their own version. Thickbox is a good example for this: There has been contributions in both forms. If I'd write a plugin that is flexible enough to be extended in every aspect, it would contain lots of code only to allow that flexibility, I wouldn't want that in most cases. As a plugin author (http://jquery.lukelutman.com/plugins/flash/index.html), I think there are a few ways you may be able to make it easy for other developers to build on top of your code. ## Store functions that depend on or generate markup where they can be overwritten. For example, instead of: $.fn.plugin = function(options){ this.each(function(){ // munge html here }); }; Use: $.fn.plugin = function(options){ this.each($.fn.plugin.munge,[options]); }; $.fn.plugin.munge = function(options){ // munge html here }; ## Allow blocks to be passed (temporarily replacing the default) when the method is called. For example: $.fn.plugin = function(options, munge) { this.each(munge || $.fn.plugin.munge, [options]); }; $.fn.plugin.munge = function(options){ // do stuff }; Could be called like this: $('.normal').plugin({ foo: 'bar'}); Or: $('.custom').plugin({ foo: 'bar' }, function(options){ // do custom stuff }); That way, another author can change how the html gets munged (by passing a block function or overwriting $.fn.plugin.munge), without having to change the source of the original plugin. It doesn't really add much extra code, and makes your plugin less dependent on a specific markup structure :-) Luke -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Extend a Plug-In
Jörn Zaefferer wrote: Good example. But I think the same effect can be achieved by simply using the standard settings/options mechanism. You can just define a certain function as default and override it via options. Yep, that would work nicely, as long as the default settings/options were exposed -- i.e. $.fn.plugin.settings = { ... } instead of a closure or local var. The challenge is to indentify the functions that can be extracted and replaced. Definitely. It's easy to go a bit crazy and make everything overwritable, which makes the code messy. It's a fine balance :-) Luke -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Media plugins
Just to make sure I'm understanding the problem, you want to hide the contents of #hdr (i.e. the html version of the nav, etc.) after the flash is inserted, right? If so, then all you should need to do is: $('#hdr').flash(sharkOptions.ufo, {version: 7}).find('embed').each(function(){ fc = new JSFCommunicator(this); sharkOptions.page.isFC = true; }).end(); And add the following to your stylesheet: .flash-replaced .alt { display: none; } The 'function(htmlOptions){...}' in the text-replacement example is used by jQuery.fn.flash() -- instead of the default, jQuery.fn.flash.replace -- to measure the content that's being replaced. You could use something similar if you want to literally replace the content of #hdr (instead of prepending into #hdr), like this: $('#hdr').flash(sharkOptions.ufo, {version:7}, function(htmlOptions){ $(this).html(jQuery.fn.flash.transform(htmlOptions)); }).find('embed').each(function(){ fc = new JSFCommunicator(this); sharkOptions.page.isFC = true; }).end(); Luke Sam Sherlock wrote: solved it myself, just whilst collecting the code to post. Late night early morning splurge of coding to excited to sleep after see this wonderful code yep thats solved but I would like to be able to hide replace code in the nested div looking at the sifr example I see that after the version object you have a function(htmlOptions) {...} when I try this // $('#hdr').flash(sharkOptions.ufo, {version: 7}).find('embed').each(function(){ fc = new JSFCommunicator(this); $('#hdr').addClass('flash-replaced'); sharkOptions.page.isFC = true; }).end(); it works though this is different from the sifr example since the class is added to the #hdr from within the each call that might not be crucial anyway - just perplexing - would like to know more to further my understanding though. thx -S On 11/11/06, *Luke Lutman* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Can you post the code (or a link to it)? What error does it throw? ... Also, my text-replacement example (http://jquery.lukelutman.com/plugins/flash/example-text-replacement.html http://jquery.lukelutman.com/plugins/flash/example-text-replacement.html) isn't fully cooked yet -- it's functional, but I'm planning to develop it as a proper plugin (soon, hopefully!). If you do want to try it, make sure you grab the fla, as that's custom too -- css (flash 7) and better anti-aliasing (flash 8). Luke Sam Sherlock wrote: astonishing stuff!!! That works a treat! I am also using the sifr jquery plugin (really feature filled site this) and have tried to alter the code to use your flash plugin instead. I guess its one stage at a time!! However I am unable to set the version it aways throws an error whatever I do!?! I updated to jquery 1.0.3 (had to make other changes json - getJSON) this did not solve the issue any idea about that? I think the issue with the version setting is causing some issue with using it instead of the sifr thingy since I need to have a htmloptions callback function ___ jQuery mailing list discuss@jquery.com mailto: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] Media plugins
Hey Sam, Thanks for all the kind words :-) I've (been lucky?) never to need to communicate between flash and javascript, so I'm a bit out of the loop on how that whole process works. If it's simply needing access to the embed / element after it's inserted into the dom, it should be pretty simple (off the top of my head): $('#hello').flash(...).find('embed').each(function(){ // do stuff }).end(); If you need to wait until the flash movie has fully loaded before creating your object, that's a whole 'nother ballgame. Could you call an javascript function from within the flash movie that creates the object you need? Something like: - load page - insert flash movie - flash movie preloads itself - flash movie calls someFunction() in javascript - someFunction() creates the object that talks to flash - - Profit! ;-) That'd probably work ok if you only have one flash movie calling someFunction(), but would get a little hairy otherwise because someFunction() wouldn't know which element in the DOM called it. If embed / or object / fire onload events, it'd be possible to add a callback function -- but I'm pretty skeptical that they'd fire the event with any sort of consistency across browsers (if at all). You could use an Image object to preload your swf (if it's small), so that it'd come from the cache when inserted into the page (using the Image object's onload event to trigger the $().flash call). Last but not least, you could wait for window.onload (instead of document.ready), but there might be quite a gap between when the flash movie finishes loading and window.onload is called Hope that helps! Luke Sam Sherlock wrote: I am astounded Luke remarkable stuff. Looks like I might be able to reduce my script over heads quite a bit with this. At first glance (through tired eyes n with fatigued mind) it appears to handle text replacement better than the existing sifr jquery plugin. I am working away on a project at mo that makes call into and out of flash using Flash version 7 (flash 8 has extended interface which sounds great), to work this I am using JSFC (JavaScript FlashCommmunicator - it works well in all browser I have tested so far) I have had some jip with creating the object to talk to flash, as it needs to be created after the flash is full placed in page (which can be sometime after document.ready fires) - would your plugin be able to aide me here? 1) Either by being able to call function within flash? (Previous points have been aired claiming that this is best not done with jquery) 2) Could a call back be made to fire when flash is set in the page? In any case the script is piece of sheer wonderment -S ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Media plugins
Interesting... :-) It would be pretty easy to use those libraries alongside my plugin, but replicating what they do is probably beyond the scope of my plugin (a separate one, maybe?). Try this (with JSFC): var fc; $('#element').flash(...).find('embed').each(function(){ fc = new JSFCommunicator(this); }).end(); Then you should be able to use fc in the same way. Note that this would only work for a single flash movie, but it could be setup for multiple flash movies (by pushing the JSFCommunicator objects into an Array?) if that's what your after. Luke Sam Sherlock wrote: Hi Luke, here is the state of play: jsfc - http://www.abdulqabiz.com/files/JSFC/example.html (src available to) also theres this - http://weblogs.macromedia.com/flashjavascript/readme.html (mike chambers again!!) Its not when its fully loaded! but its also not when document.ready either. Its a pain!!! For flash8 theres extendedinterface though - which looks great! would be interesting to see what you make of the above -S On 10/11/06, *Luke Lutman* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hey Sam, Thanks for all the kind words :-) I've (been lucky?) never to need to communicate between flash and javascript, so I'm a bit out of the loop on how that whole process works. If it's simply needing access to the embed / element after it's inserted into the dom, it should be pretty simple (off the top of my head): $('#hello').flash(...).find('embed').each(function(){ // do stuff }).end(); If you need to wait until the flash movie has fully loaded before creating your object, that's a whole 'nother ballgame. Could you call an javascript function from within the flash movie that creates the object you need? Something like: - load page - insert flash movie - flash movie preloads itself - flash movie calls someFunction() in javascript - someFunction() creates the object that talks to flash - - Profit! ;-) That'd probably work ok if you only have one flash movie calling someFunction(), but would get a little hairy otherwise because someFunction() wouldn't know which element in the DOM called it. If embed / or object / fire onload events, it'd be possible to add a callback function -- but I'm pretty skeptical that they'd fire the event with any sort of consistency across browsers (if at all). You could use an Image object to preload your swf (if it's small), so that it'd come from the cache when inserted into the page (using the Image object's onload event to trigger the $().flash call). Last but not least, you could wait for window.onload (instead of document.ready), but there might be quite a gap between when the flash movie finishes loading and window.onload is called Hope that helps! Luke Sam Sherlock wrote: I am astounded Luke remarkable stuff. Looks like I might be able to reduce my script over heads quite a bit with this. At first glance (through tired eyes n with fatigued mind) it appears to handle text replacement better than the existing sifr jquery plugin. I am working away on a project at mo that makes call into and out of flash using Flash version 7 (flash 8 has extended interface which sounds great), to work this I am using JSFC (JavaScript FlashCommmunicator - it works well in all browser I have tested so far) I have had some jip with creating the object to talk to flash, as it needs to be created after the flash is full placed in page (which can be sometime after document.ready fires) - would your plugin be able to aide me here? 1) Either by being able to call function within flash? (Previous points have been aired claiming that this is best not done with jquery) 2) Could a call back be made to fire when flash is set in the page? In any case the script is piece of sheer wonderment -S ___ jQuery mailing list discuss@jquery.com mailto:discuss@jquery.com http://jquery.com/discuss/ http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] new jQuery API draft
I'm loving the full index :-) A couple of suggestions come to mind ... having all of the parameter types and names in the left-hand column makes the list much harder to scan. Maybe it's just a styling issue -- like making the parameter types and names less prominent (smaller, faded out) -- but my personal preference would be to keep the index as a navigation mechanism, rather than part navigation part information. Without the paramter types and names, method names would always fit on one line, and the bullets could probably be dropped too :-) I also find having $. at the beginning of some names gets in the way of scanning. Something like this (using a fixed-width font for the method names) might be nice: trigger() $.trim() unbind() One other small thing: I'd be really nice to have a bit more line-spacing overall. I find that ascenders and descenders really crammed in a few places (the index and text for examples in particular). I'd rather scroll a bit more for the sake of legibility :-) Luke Jörn Zaefferer wrote: Hi jQueryians, I'd like to present you a first draft for a new stylesheet for the jQuery API: http://joern.jquery.com/api-draft/cat.xml There is still lot's of work to do, but the main concern, a new concept for the navigation, is already functional. Both Alphabetical and Category lists will be provided as exapandable trees. Please don't waste your time checking it with IE, the draft works so far only with Firefox. Please post your opinions and ideas, I'm sure there are many. Regards Jörn -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Media plugins
Can you post the code (or a link to it)? What error does it throw? ... Also, my text-replacement example (http://jquery.lukelutman.com/plugins/flash/example-text-replacement.html) isn't fully cooked yet -- it's functional, but I'm planning to develop it as a proper plugin (soon, hopefully!). If you do want to try it, make sure you grab the fla, as that's custom too -- css (flash 7) and better anti-aliasing (flash 8). Luke Sam Sherlock wrote: astonishing stuff!!! That works a treat! I am also using the sifr jquery plugin (really feature filled site this) and have tried to alter the code to use your flash plugin instead. I guess its one stage at a time!! However I am unable to set the version it aways throws an error whatever I do!?! I updated to jquery 1.0.3 (had to make other changes json - getJSON) this did not solve the issue any idea about that? I think the issue with the version setting is causing some issue with using it instead of the sifr thingy since I need to have a htmloptions callback function ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Media plugins
Dang! You beat me to the punch, Mike. I've been working on (more or less) the same thing, and was just finishing up my documentation and examples last night when you posted yours... too bad we didn't find out sooner. Here's my version: http://jquery.lukelutman.com/plugins/flash/ I've re-written the flash detection and embedding for jQuery (so SWFObject isn't necessary), and tried to build it to be as flexible as possible in terms of how the replacements are done. Like yours, basic replacements look like: $('#hello').flash({ src: 'hello.swf', width: 320, height: 240 }); For more complicated stuff (like sIFR or your method of reading data from classnames), you can pass a custom function, like so (off the top of my head): $('[EMAIL PROTECTED]swf]').flash(null, null, function(htmlOptions){ $this = $(this); htmlOptions.src = $this.attr('href'); htmlOptions.width = this.className.match(/w\:(\d+/))[1]; htmlOptions.height = this.className.match(/h\:(\d+/))[1]; $this.before($.fn.flash.transform(htmlOptions)); }); Or you can change the default: $.fn.flash.replace = function(htmlOptions) { // custom code here ... }; I'm curious to know what you think :-) Cheers, Luke Mike Alsup wrote: I've just posted some convenience plugins for dealing with Quicktime, Flash, and mp3 media. Source and demos can be found here: http://malsup.com/jquery/media/ Mike ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] does jQuery has support for parameter handling ?
escape() and unescape() have always worked for me :-) i.e. escape('The quick brown fox') - The%20quick%20brown%20fox unescape('The%20quick%20brown%20fox') - The quick brown fox Luke Truppe Steven wrote: Mark Gibson schrieb: Javascript has the functions: decodeURI(s) and decodeURIComponent(s) I get a string like this: Stumpf+einer+Palme%2C+ausgeh%F6hlt%2C+geschliffen+und+mit+Perlmutteinlegearbeiten+verziert If this string is inside the variable test and i do: var newtest = decodeURIComponent(test); I get the error malformed URI sequence. I've looked documentation on http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference but there i don't see much about that function... Thanks for the fast reply! What am i doing wrong ? best regards, Truppe Steven ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jquery incompatible with adsense?
Hmmm... Your test page looks fine (no errors) in Firefox and Safari for me. Luke Mark D.B.D wrote: I upgraded first to revision 522 and after to 524 and both doesn´t work. I get the following error on thinkbox.js: $(document).ready is not a function on line 11 Here is the test page: http://markdbd.com/proyectos/jquery_test/ Regards, On 11/6/06, *Luke Lutman* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I had a similar problem, Mark. Upgrading to the latest revision of jQuery (522 at the time) solved the problem :-) Luke Mark D.B.D wrote: Hi all, When I finished my little project with jquery I decided to add my adsense code. After this I saw there is something that makes jquery incompatible with the adsense script. I don't know what it is so I created a little test page so you all can check it: http://www.markdbd.com/proyectos/jquery_test/ http://www.markdbd.com/proyectos/jquery_test/ Just click on the image to get the error, I think it only happens on firefox. I am using the thinkbox plugin but If I am right the bug is in jquery.js. Regards, -- -- Mark D.B.D http://www.markdbd.com [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -- ___ jQuery mailing list discuss@jquery.com mailto:discuss@jquery.com http://jquery.com/discuss/ http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com mailto:discuss@jquery.com http://jquery.com/discuss/ -- -- Mark D.B.D http://www.markdbd.com [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -- ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jquery incompatible with adsense?
I had a similar problem, Mark. Upgrading to the latest revision of jQuery (522 at the time) solved the problem :-) Luke Mark D.B.D wrote: Hi all, When I finished my little project with jquery I decided to add my adsense code. After this I saw there is something that makes jquery incompatible with the adsense script. I don't know what it is so I created a little test page so you all can check it: http://www.markdbd.com/proyectos/jquery_test/ Just click on the image to get the error, I think it only happens on firefox. I am using the thinkbox plugin but If I am right the bug is in jquery.js. Regards, -- -- Mark D.B.D http://www.markdbd.com [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -- ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] 1.0 to 1.0.3 upgrade issues
I noticed the same problem when trying to wrap new 'embed' and 'object' elements, but didn't have time to write it up. I only get the errors in Firefox (v2) -- Safari 2 and Opera 9 are fine. // this works $(function(){ $(document.createElement('div')); }); // error: f.apply is not a function - jquery.js (line 1166) $(function(){ $(document.createElement('object')); }); // error: f.apply is not a function - jquery.js (line 1166) $(function(){ $(document.createElement('embed')); }); Luke Dave Methvin wrote: I recently upgraded to jquery 1.0.3 and one of my plugins is having some issues. ... I could possibly post a URL if that is necessary. Definitely post a sample page and let us know which browsers you used. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Function to enumerate the querystring?
The attr() method returns a string, rather than the jQuery object, so you won't be able to chain it. You could modifiy the $.query function and pass in the value of q ... like so: jQuery.query = function(q) { var r = {}; q = q.replace(/^\?/,''); // remove the leading ? q = q.replace(/\$/,''); // remove the trailing jQuery.each(q.split(''), function(){ var key = this.split('=')[0]; var val = this.split('=')[1]; // convert floats if(/^[0-9.]+$/.test(val)) val = parseFloat(val); // ingnore empty values if(val) r[key] = val; }); return r; }; Then call it like this: q = $.query($(this).attr('href')); Luke Chris W. Parker wrote: On Tuesday, October 31, 2006 10:46 AM Luke Lutman said: Have a look at this recent thread :-) http://www.nabble.com/method-plugin-for-getting-query-string-vars--tf248 1232.html#a6919130 I read through this and tried to implement your first suggestion but I notice that everything takes location.search and parses that. I want to use it in the following way: theHref = $(this).attr(href).query(); Your function is: jQuery.query = function() { var r = {}; var q = location.search; q = q.replace(/^\?/,''); // remove the leading ? q = q.replace(/\$/,''); // remove the trailing jQuery.each(q.split(''), function(){ var key = this.split('=')[0]; var val = this.split('=')[1]; // convert floats if(/^[0-9.]+$/.test(val)) val = parseFloat(val); // ingnore empty values if(val) r[key] = val; }); return r; }; I'm not sure how to modify that function to do what I want (considering my current lack of JS/jQuery syntax). Would you mind showing me what to do? Thank you, Chris. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Function to enumerate the querystring?
Klaus Hartl wrote: That won't work for two reasons: $(this).attr('href') most likely returns a complete url, thus there is no leading ?. Oops! Yes, of course. Secondly if you have a parameter like number=0, it won't be put into the hash because after parseFloat val == 0 which evaluates to false. Ahh, I missed that one -- good eye :-) Luke ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Access to flash object
You make a good point about mobile devices, etc. Klaus -- point taken. I'm still not convinced about using object / though -- for me it's got a number of cons: * It's messy -- you need different code for different browsers. All the browsers support object /, but IE wants a different object / than the rest. * It doesn't work *properly* everywhere -- IE doesn't stream object /-only swfs, and the whole flash-satay setup is pretty ugly. * You still need non-standard markup -- the only way I've been able to get Safari to recognize flashvars is to add a flashvars=... attribute to the object / (as well as a separate param name=flashvars ... /), which breaks validation. (If I'm wrong about any of the above, please correct me). Using javascript to detect flash and insert the embed tag solves the alternate content problem. In my mind, the only con of using embed / is that it's not written in the spec. But, since it's centralized in one place (the function that does the replacements), it's pretty easy to swap out in the future if necessary. Luke Klaus Hartl wrote: I wonder who is sticking the sand in the head? In 2006 there's really no need to stick to embed. A proper and even valid object is also supported by all browsers on jQuerys support list (and more). See it the other way round. Sooner or later the legacy embed tag will not be supported anymore by newer browsers as the web moves on. Think of mobile devices etc. With object you can also have a reasonable fallback in case the plugin is not supported: object ... pa href=...Download plugin/a/p /object Or even better: object ... pa href=some.mp3Download MP3/a/p /object -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] method/plugin for getting query string vars?
The 'trick' is the brackets after Jorn's function definition. (function(){ ... })(); -- notice the brackets It's an anonymous function that gets invoked immediately, then is gone to the big garbage collector in the sky. It's not necessary to attach the function to jQuery or invoke the function later (since the query string won't change) -- we can just store the object it returns on jQuery for later :-) Running all the code inside an anonymous function avoids potential naming conflicts by keeping all the variables from cluttering out of the global namespace (i.e. q is local to the function, and doesn't hang around as window.q, etc.) Hope that helps, Luke Stephen Woodbridge wrote: Hi Jörn, I seem to be missing something (so much to learn!). Your note creates an anonymous function that assigns its result to jQuery.query, but where does the function get attached and how does it get invoked, like in Luke's example. Thanks, -Steve Jörn Zaefferer wrote: Luke Lutman schrieb: I was thinking of something a little fancier ;-) jQuery.query = function() { var r = {}; var q = location.search; q = q.replace(/^\?/,''); // remove the leading ? q = q.replace(/\$/,''); // remove the trailing jQuery.each(q.split(''), function(){ var key = this.split('=')[0]; var val = this.split('=')[1]; // convert floats if(/^[0-9.]+$/.test(val)) val = parseFloat(val); // ingnore empty values if(val) r[key] = val; }); return r; }; Then you could use it like so: http://www.bork.com?foo=helloworldbar=0.333; $.query()['foo']; // helloworld (string) $.query()['bar']; // 0.333 (number) In that case, you should just assign the result to jQuery.query, eg: (function() { jQuery.query = r = {}; var q = location.search; q = q.replace(/^\?/,''); // remove the leading ? q = q.replace(/\$/,''); // remove the trailing jQuery.each(q.split(''), function(){ var key = this.split('=')[0]; var val = this.split('=')[1]; // convert floats if(/^[0-9.]+$/.test(val)) val = parseFloat(val); // ingnore empty values if(val) r[key] = val; }); })(); Considering that location.search does not change. I hope I'm not confusing something. -- Jörn ___ 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] method/plugin for getting query string vars?
Good points about the zip code, and running $.query() all the time, Mike. Maybe the two approaches can be combined? Run the code to munge the query string the first time $.query() is called. Cache two sets of results -- a 'raw' set and a 'type cast' set -- in a closure, and return one of the cached objects on subsequent calls to $.query() (function(){ var after_type_cast = {}; var before_type_cast = {}; var cached = false; jQuery.query = function(cast) { if(!cached) { // remove leading ? and trailing var q = location.search.replace(/^\?/,'').replace(/\$/,'').split(''); for( var i = q.length - 1; i = 0; i-- ) { var p = q[i].split('='), key = p[0], val = p[1]; before_type_cast[key] = val; // convert floats if(/^[0-9.]+$/.test(val)) val = parseFloat(val); // convert booleans if(/^(true|false)$/.test(val)) val = (val == 'true'); // ingnore empty values if(val) after_type_cast[key] = val; } cached = true; } return cast === false ? before_type_cast : after_type_cast; }; })(); I haven't tested the above, and it can probably be condensed/simplified a bit, but you get the idea ... So, for http://www.example.com/test?special=zip=00125, pass false to $.query() to get the raw values ... $.query().zip - 125 (number) $.query(false).zip - 00125 (string) $.query().hasOwnProperty('special') - false $.query(false).hasOwnProperty('special') - true Luke Michael Geary wrote: In Jörn's version of the code, you wouldn't call $.query() at all. Instead, $.query would be the resulting object that you would then use directly. Note that jQuery and $ are references to the same object, so jQuery.query and $.query are the same thing. I'm not sure I like this idea since it means the query parsing would be done whether you need it or not. But maybe it doesn't take enough time to worry about. If it does run all the time, it would be worth optimizing the code by using a conventional for loop instead of jQuery.each and combining the repeated split calls. I'd also remove the code that does the float conversion and ignores empty values. Consider this URL: http://www.example.com/test?special=zip=00125 I may want to know about that special parameter, and I probably don't want the Zip code turned into the number 125. Here's how I would code it... For the jQuery.query is an object version: (function() { var r = jQuery.query = {}; var params = location.search.replace(/^\?/,'').split(''); for( var i = params.length-1; i = 0; i-- ) { var p = params[i].split('='), key = p[0]; if( key ) r[key] = p[1]; } })(); For the jQuery.query is a function: jQuery.query = function() { var r = {}; var params = location.search.replace(/^\?/,'').split(''); for( var i = params.length-1; i = 0; i-- ) { var p = params[i].split('='), key = p[0]; if( key ) r[key] = p[1]; } return r; }; All untested, of course. :-) -Mike ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] method/plugin for getting query string vars?
Is there a jQuery method or plugin for parsing the browser's query string into an object? I looked through the api and did a bit of searching around, but no luck ... Thanks, Luke -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Highlighting jQuery
Looks interesting, but the example pages crash Safari (2.0.4, OSX 10.4) :-( Luke Andrea Ercolino wrote: Hola. I just released Chili, a free syntax highlighter script, written in jQuery, and based on the Dan Webb's Code Highlighter, which I found a couple of weeks ago thanks to a link on the jQuery site. Chili is compatible with Code Highlighter's language definition files, but it is othwerwise a new piece of software (re-engineered and fixed), fully documented, and really based on jQuery functionalities. I posted a zip file with all inside and put the manual and two examples one click away. http://www.mondotondo.com/aercolino/noteslog/?cat=8 The example Chili highlighting jQuery shows how Chili can be used for highlighting jQuery scripts. Hasta pronto, Andrea ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Append body
Are you running your code before the dom is ready? Try this: $(document).ready(function(){ $(body).append('div id=ajaxBusy class=ajaxBusy.../div'); }); Luke -- zinc Roe Design www.zincroe.com (647) 477-6016 sdkester wrote: Thank you for the suggestion. I tried that and get an operation aborted error from IE and it won't let me load the page. Any other ideas? Klaus Hartl wrote: sdkester schrieb: I tried appending the body with a div using the following in a js file: $(body).append('div id=ajaxBusy class=ajaxBusyp ../../loading2.gif nbsp;nbsp;/p/div'); It is not working. Maybe I'm going about it wrong. I simply want to insert the above html anywhere in the body. Is my code wrong and/or am I approching it from the wrong angle. I once had strange problems with 'body' in IE. The following then worked for me: $(document.body).append( ... ); -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Best way for storing user preferences?
I'd go for something like option 4, but instead of the custom attribute/DTD stuff, just give it a classname. i.e.: div class=closed/div Luke Raffael Luthiger wrote: Hi, I've seen searching lately for a good way of storing preferences which a jQuery script needs later on. The specific information the script needs is the starting state of a div element (either open or closed). The preferences are stored in a DB and sent from there somehow to the browser. The sent and storing part is now the part I am searching for. After searching around for a while I found several ideas/solutions. But none seems to be perfect for me. So I wanted to ask you what is the best way to do it: 1) Store the information in an invincible div at the end of the page. And then parse this div. E.g: div id=prefs var1: value1; var2: value2; /div 2) The js-script gets generated each time the page is called. And the corresponding vars are set in there. 3) Every time the page is loaded the js-script asks the server for a XML (or JSON) file with the preferences in there. 4) Write a XHTML DTD module in order to extend the div element with a state-attribute. E.g: div state=closed 5) More (and better) ideas? To say is that those pages are often reloaded. From my point of view 3) generates to much traffic on the net. 1) is just a hack and therefor not really a good solution. I have my jQuery scripts already in an external file. This way they can be cached by the browser and don't have to be sent every time. So I don't really like 2) either. Right now I would go with 4) unless someone has a better idea. Does anybody have a better solution? Raffael ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- zinc Roe Design www.zincroe.com (647) 477-6016 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Remove elements with a particular first-child from matches?
Hi all, I'm having trouble removing a div from a set of matches if the div has a particular first-child element. ##Here's what I've got: div123/div divspanabc/spanxyz/div divspandef/spanghi/div I have a $() object matching all divs (i.e. $('div')), but I only want to process divs which don't have a span as their first child element. I should only end up processing one div (the first one). ##Here's what I've tried: $('//span/../div') XPath with parent axis. Doesn't match anything. $('div').not('div/span/../div') jQuery object filtered with XPath with parent axis. Doesn't match anything $('div').not(('div span').parent()[0]) Only removes divspanabc/spanxyz/div, leaving two matches. $('div').each(function(){ if($('span:first-child', this).size()) return; alert(this); }); This works, but it's kinda oogly. ##My question(s): Am I missing something with the XPath parent axis selectors? Shouldn't they be matching something? Is there a better way to do this than the last method? I'd rather not iterate over unnecessary elements. Thanks, Luke Lutman P.S. This is my first post to the list, so please be gentle ;-) ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Remove elements with a particular first-child from matches?
Hey John, Thanks for the reply, it's much appreciated. I played around with using $(span:first-child).parent(div), but it selects the opposite of what I need (divs *with* a span:first-child rather than divs *without* a span:first-child). Is there a way to remove the above from a larger set of matches -- say, find all divs, then remove divs with a span:first-child? I've been trying filter() and not(), but without any luck. Thanks, Luke John Resig wrote: Hi Luke - I was able to get what you wanted, working using: $(span:first-child).parent(div) Right now, in jQuery, doing the XPath /../ is broken (since it's just a cheap XPath - CSS conversion). However, it's recommended that you use methods like .parent() instead. All that being said, normally you'd just be able to do: $(div:not([span:first-child])) but that doesn't seem to be working correctly either. Ugh. Sorry for the hassle :-/ --John ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/