|
Alright I'm at a brick wall, basically I've been fiddling around with making a simple menu system. http://jsfiddle.net/IRSMARTLIKEROCK/xkXQD/12/ But in IE, when you go to a shorter article content, it doesn't redraw the wrapper element. All the other browsers are fine. I made a temporary fix of: http://jsfiddle.net/IRSMARTLIKEROCK/xkXQD/13/ Is there any way to avoid the initial problem?
|
# ? Nov 18, 2010 21:40 |
|
|
# ? Apr 26, 2024 07:23 |
|
I've got one script that injects an element into the page in document.ready():code:
|
# ? Nov 24, 2010 22:06 |
|
Dromio posted:I've got one script that injects an element into the page in document.ready(): code:
code:
Lumpy fucked around with this message at 22:16 on Nov 24, 2010 |
# ? Nov 24, 2010 22:13 |
|
I follow what you did in the first example, but I need for the second script to be completely separate from the first. I need to add an element into the player from a completely new .js file, loaded independently from the one that created the player element in the first place. So now I have loadplayer.js : code:
code:
|
# ? Nov 24, 2010 22:30 |
|
Dromio posted:I follow what you did in the first example, but I need for the second script to be completely separate from the first. I need to add an element into the player from a completely new .js file, loaded independently from the one that created the player element in the first place. Why does addcaption.js need to run instantly on page load? Create an object that you instantiate on page load, but don't call the function / method that adds the caption to the player DIV until you actually create and put said DIV into the DOM: code:
if loadplayer.js can't "know" about any other files or something, you could rig up a cheesy timer: code:
Lumpy fucked around with this message at 17:12 on Nov 26, 2010 |
# ? Nov 25, 2010 01:16 |
|
Yeah, I'd rather loadplayer.js have no knowledge of addcaption.js at all. We're going to be adding more things to the player, and I'd really like to be able to have them all separated like this where I can simply add a new .js file to the page to have the extra functionality added. Cheesy timer kind of sucks, but I don't have a lot of other options, do I?
|
# ? Nov 26, 2010 21:33 |
|
Dromio posted:Yeah, I'd rather loadplayer.js have no knowledge of addcaption.js at all. We're going to be adding more things to the player, and I'd really like to be able to have them all separated like this where I can simply add a new .js file to the page to have the extra functionality added. Cheesy timer kind of sucks, but I don't have a lot of other options, do I? Write a real Player class with a documented API and program to it?
|
# ? Nov 27, 2010 00:04 |
|
Lumpy posted:Write a real Player class with a documented API and program to it? This doesn't sound SO bad really. I'd make a Player class with an init method that does the injection. Then in document.ready() I'd call that init method. Then I just need some way to add methods to be called after the init() from the outside. So by captions.js would just add it's init method after the player's. Unfortunately, my javascript isn't strong enough to know exactly how to do that part. How would I add a method to a list like that?
|
# ? Nov 29, 2010 15:20 |
|
I'm falling out of the realm of jQuery and into just javascript, but I wanted to continue the discussion here. Here's what I've hacked up so far: In player.js code:
code:
|
# ? Nov 29, 2010 20:34 |
|
Dromio posted:I'm falling out of the realm of jQuery and into just javascript, but I wanted to continue the discussion here. What happens when somebody includes caption.js before player.js ??
|
# ? Nov 29, 2010 22:23 |
|
Lumpy posted:What happens when somebody includes caption.js before player.js ?? It won't work then. I don't have a good answer for that.
|
# ? Nov 29, 2010 22:35 |
|
Dromio posted:It won't work then. I don't have a good answer for that. And thus the " make an API for a player class / object" I'll post some ramblings on it tomorrow when I am somewhat awake.
|
# ? Nov 30, 2010 06:34 |
|
OK, so long winded reply ahoy! I'm not saying this *is* the way to do it, but I'm just banging out something to think about while i have my coffee. Don't think of "the player" as the DIV that the player sits in. Think of the player as an abstract thing, and it has a view that happens to be a DIV. We can then "do stuff" with our player, even if no DIV exists yet, and check for the view existing when we need to reference it. So let's make a SupaPlaya object that has an init method, and a displayCaptions method, and we shall see how we can make it so we can call the captioning stuff first in case things are "out of order" and not break anything. code:
Again, this is not "the" way to do it. Just a way of doing it to show how you could create a class for your player. This is good for a couple reasons: your player code is one place, so you don't have to try and figure out wtf functionality is in what file, and you have a consistent way of doing things that you can share with others, instead of saying "hey, there's a DIV with this ID, do poo poo to it!!!" you can say "To display captions, use SupaPlaya.displayCaptions(). To make the player flurf, use SupaPlaya.flurf()" and so on. Lumpy fucked around with this message at 20:32 on Nov 30, 2010 |
# ? Nov 30, 2010 17:13 |
|
Wow. I've never seen an object generated that way, but it looks something I want to start using in my own code. If I'm parsing your SupaPlaya correctly, view and getView are essentially private properties bound by a self-executing closure to a returned object that contains the "public" methods init and displayCaptions. That's totally rad. Did you come up with that yourself, or is that technique documented somewhere? I'd love to read more about it, either way. Also, what is the purpose of the commas trailing the code:
code:
|
# ? Nov 30, 2010 20:09 |
|
Haystack posted:Wow. I've never seen an object generated that way, but it looks something I want to start using in my own code. That was stolen from the Man himself, Crockford. Hah, the one after getView() is a typo... that should be a semi-colon. The one after 'view' is there because.... code:
|
# ? Nov 30, 2010 20:30 |
|
Lumpy posted:And I do that these days because I run all my js through http://www.jslint.com/ with "the good parts" toggled on, and it only allows one var statement per function. I always did one var per line for readability and avoided comma delimited var - what's the advantage to this. Is it simply a speed thing? Also: "Disallow ++ and --"? Why does Herr Crockford suggest this? - Is code:
It's not covered here: http://javascript.crockford.com/code.html
|
# ? Dec 1, 2010 03:23 |
|
geeves posted:I always did one var per line for readability and avoided comma delimited var - what's the advantage to this. Is it simply a speed thing? I guess as a reminder that JS does variable hoisting, and you should declare them all together at once. geeves posted:Also: "Disallow ++ and --"? Why does Herr Crockford suggest this? - Is No, he wants i = i + 1 ( or i+= 1 ) instead of using the auto increment operator. Mainly for readability / clarity. At the 1:09 mark in this: http://developer.yahoo.com/yui/theater/video.php?v=crockonjs-5 he talks about it. Lumpy fucked around with this message at 06:54 on Dec 1, 2010 |
# ? Dec 1, 2010 06:44 |
|
Can anyone suggest a super simple treeview example for jQuery? It'll be embedded in an HTML file generated by a tool, along with jQuery minified inline. The data is all static, I just want to be able to expand/collapse branches, and possibly provide an Expand All button. The examples I've found online are all super complicated with fancy art and 18 Javascript files, etc.
|
# ? Dec 1, 2010 18:16 |
|
I'm using jsTree. It's all documented, but it takes a bit to figure it out. If your HTML is just nested lists, it's pretty easy to turn it into a tree.
|
# ? Dec 1, 2010 18:31 |
|
Doctor rear end in a top hat posted:I'm using jsTree. It's all documented, but it takes a bit to figure it out. If your HTML is just nested lists, it's pretty easy to turn it into a tree. Awesome, I can make the HTML look like whatever I want, so this looks like it might work well since it's one file that I can easily cram between some script tags. The themes are also small so I can inline them (including the art). Should work out well, thanks!
|
# ? Dec 1, 2010 18:59 |
|
Here's a third party jQuery custom app that's basically a juiced up slideshow: http://www.lonnymag.com/issues/10-october-november/pages/1#p111 Is there a package floating around that providers similar functionality? We're setting up a meeting with the devs who built this but it might be out of our price range. Another related question: Is there an iPad friendly best practice for converting PDFs? For the web, we've used FlashPaper for ages but yea, no Flash for iPad. Basically, I need a iPad-friendly method of posting PDFs and the link above is the best I can find so far. UPDATE for those that care: ScribD has a HTML5 pub coming out soon. Boosh! fucked around with this message at 16:17 on Dec 3, 2010 |
# ? Dec 1, 2010 21:08 |
|
I made this jQuery plugin: http://plugins.jquery.com/project/digirain I already have good advice for 1.1, but what do you guys think?
|
# ? Dec 10, 2010 07:06 |
|
_areaman posted:I made this jQuery plugin: Looks cool, but you should get it actually rendering mirrored Katakana
|
# ? Dec 10, 2010 18:03 |
|
I have been working hard recently to create a new personal webpage for myself. I've done a lot with JQuery, especially the BBQ plugin (for awesome hashchanging AJAX+back button functionality). However, in my attempt to get everything working, I'm afraid it is a little hackish these days. I've also attempted to make sure the site stays relatively functional without JavaScript enabled. Anyways, I was hoping you geniuses could take a look at my site and give me some recommendations/best practices to do things differently if I'm doing something rear end backwards. I'm relatively proficient in Javascript, CSS, PHP, and all that jazz, but I'm mainly self-taught, so there are some things I only know how to do "my way." Thanks! Let me know what you think! http://www.davenadel.com edit: some things I'm wondering about : whether my decision to dynamically load the scripts I need for each page is correct (i.e. to enable the tabs on the resume page and the like), as well as whether I should cache what URLs map to my hash values, and anything else you may find! DankTamagachi fucked around with this message at 23:38 on Dec 13, 2010 |
# ? Dec 13, 2010 23:34 |
|
I've been getting into the habit of organizing my jQuery-based javascript code into widgets. Regardless of how reusable the code it supposed to be, it just seems like better separation to me. Do y'all concur, or is this overengineering? I'm also wondering specifically about event handling. Basically my internal widgets conceptually do have widget-specific events to them that need to have some defined behavior internally. What I've been doing is having internal widget methods that provide the default behavior for the event and then fire off this._trigger(). For example, a task list widget has an onTaskEdited method which does the actual business of a task having been edited (data formatting, persistence, closing the edit ui) and at the end goes this._trigger('edited'). I think i'm ok with this but it strikes me as a little off that the event's i'm firing won't actually ever be used (as there's no reason to use them internally and the widgets are very app-specific and not really meant for redistribution). I guess the idea is that another internal page or widget may want to hook into those events to do things involving the other widget without becoming a locked-down dependency? Or is this, again, a bit of overengineering and I should maybe minimize the number of events I send out? Also wonder if the nomenclature of the methods is actually apt.... should it maybe be "this.editTask()" rather then "this.onEditTask()" ... i mean it's the thing that makes the actual change happen and is the source of the event, it's not actually an event handler. The main reason I went with onEventName anyway is that the methods end up having event-handler signatures anyway since they'll almost always be called by an event handler (and they'll need to pass the event object on to the widget-specific event they trigger).
|
# ? Dec 14, 2010 01:05 |
|
DankTamagachi posted:I have been working hard recently to create a new personal webpage for myself. I've done a lot with JQuery, especially the BBQ plugin (for awesome hashchanging AJAX+back button functionality). However, in my attempt to get everything working, I'm afraid it is a little hackish these days. I've also attempted to make sure the site stays relatively functional without JavaScript enabled. Functionally I think it's decent and all parts appear to be well-integrated. Nice work! Call me an rear end in a top hat, but people are going to like looking at your site a lot more if you remove the backgrounds on #main and #spiral. Also, the yellow -> transparent highlight fade is unnecessary and kind of jarring. Just my two cents, hope you find it helpful. And I can't really comment on anything PHP related, but here's a comment about the java script: code:
|
# ? Dec 14, 2010 03:38 |
|
Mr. Wynand posted:I've been getting into the habit of organizing my jQuery-based javascript code into widgets. Regardless of how reusable the code it supposed to be, it just seems like better separation to me. Do y'all concur, or is this overengineering?
|
# ? Dec 14, 2010 04:37 |
|
smug forum rear end in a top hat posted:Functionally I think it's decent and all parts appear to be well-integrated. Nice work! I have combined those two methods, thanks! Didn't even think of it. I also changed the "highlight" function to a slightly more subtle one. Now, I'm struggling with a race condition issue. I used to have the "loading" gif show up after info was submitted to the contact form. However, if the ajax request completes too quickly, the show() for the loading div isn't complete before hide() is called and it is never hidden. Frustrating! Suggestions, anyone?
|
# ? Dec 14, 2010 04:54 |
|
DankTamagachi posted:I have combined those two methods, thanks! Didn't even think of it. I haven't looked at your code, but using callbacks will make sure that everything happens in the order you intend. Most of the built-in jQuery ajax functions have callbacks.
|
# ? Dec 14, 2010 05:01 |
Can anybody recommend me a jQuery polling plugin? Is that the right word for it? I want to do an xhr every half second. If one of the requests never gets a response for some reason, I want it to continue to issue them. If the old request ends up coming back after a new one has been issued, ignore it. It seems simple enough to just code it myself, but I would have guessed there would be a nice jQuery plugin I could use. The search results I'm seeing do not look very promising at all though.
|
|
# ? Dec 30, 2010 03:26 |
|
You really should just wrap this up yourself, it's extremely trivial for the simplest of use cases and for more difficult things it should still be relatively terse.code:
See: http://api.jquery.com/jQuery.ajax/
|
# ? Dec 30, 2010 04:32 |
|
yeah, what entro0py said. Nobody's written any timer/timeout jQuery plugins probably because the DOM honestly handles all that ish as straightforward as possible. Now what *is* p.swee handled by a jQuery plugin is http://dev.seankoole.com/jquery/ui-effect/text.html
|
# ? Dec 30, 2010 05:04 |
|
How do you think they did this: http://beta.gawker.com/ I really want to mimic it.
|
# ? Dec 30, 2010 17:41 |
|
Bobx66 posted:How do you think they did this: What, the fixed right bar? It's just CSS. code:
|
# ? Dec 30, 2010 18:01 |
|
Haystack posted:What, the fixed right bar? It's just CSS. Looks like that is only half of it, you can scroll in the right bar, independent of the main site.
|
# ? Dec 30, 2010 18:03 |
|
Ah, I see. That is neat. They appear to be using a .mousewheel() event handler. See line 31 of the relevent javascript file Edit: There's also some keyboard navigation stuff bound to the keydown event. Haystack fucked around with this message at 18:20 on Dec 30, 2010 |
# ? Dec 30, 2010 18:15 |
|
Bobx66 posted:How do you think they did this: Is that what they were working on instead of security?? In a vaguely similar vien, I finished my "It scrolls to the top, then switches to fixed" plugin a while back, and in typical me fashion, never did anything with it. Example: http://www.chmoddesign.com/testbed/jquery/scrollToFixed/scrollExample.html Grab it if you so desire: http://www.chmoddesign.com/stuff/jquery_scroll_to_fixed
|
# ? Dec 30, 2010 18:48 |
|
Lumpy posted:Is that what they were working on instead of security?? That is fantastic! Thank you for sharing Lumpy.
|
# ? Dec 31, 2010 01:54 |
|
I just inherited wordpress site thats broken. Looks like all the blog posts from 6 months again and earlier have broken images. Apparently the old wordpress was on a different domain so the links all goto code:
code:
|
# ? Jan 3, 2011 22:49 |
|
|
# ? Apr 26, 2024 07:23 |
|
rugbert posted:I just inherited wordpress site thats broken. Looks like all the blog posts from 6 months again and earlier have broken images. Apparently the old wordpress was on a different domain so the links all goto You can do something like: code:
|
# ? Jan 3, 2011 22:56 |