-
Posts
579 -
Joined
-
Last visited
Everything posted by Drongo_III
-
haha sorry, maybe I'm not explaining this. What I dont understand is why the child elements activate the click function. Doesn't the selector only target the selector element?
-
The code here is stripped down but it's got the issue I am talking about. Let me explain this more clearly. The div with the id '#popUp' has inside it a link and an image. My expectation from the code is that if you click the div with the ID '#popUp' the click function will fire. But I don't understand why if you click the link for 'close', the click funciton also fires. This is what doesn't make sense to me. The selector is surely the div and not the child elements within the div. OR is that the way the selector works? Am i misunderstanding something?
-
Hi That's not how I intended it to work though :/ Why would it target everything in the div? Since the selector is for '#popUp' - doesn't that mean the click function should only fire on clicking the div with that ID? I guess what I am saying is, why would the child elements active the click function when they aren't part of the selector?
-
Hi Guys Having an issue with jquery that I've never had before. It was my expectation that with the code below (stripped down the code for this example) if you click the div with the ID '#popUp' the click function will run. What I dont understand is why when you click anything in the div (as the link or the image) the click function also runs. That's never happened before so I am really confused. Using jquery 1.8.2 Can anyone point out what I've done wrong? Mighty confused and been staring at this particular website for quite some hours so probably missing something obvious :/ Any help would be very welcome. Thanks, Drongo <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title></title> <meta name="description" content="" /> <meta name="keywords" content="" /> <script type="text/javascript" src="jquery182.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#popUp').click(function(){ $('#popUp').fadeOut(600, function(){ $('#popUp img').remove(); $('#blackout').css('display','none'); }); }); }); </script> <style> #popUp{ position: absolute; z-index: 601; padding: 20px; margin-left: 300px; background-color: #000; } .close{ position: absolute; z-index: 630; right: 20px; bottom: 1px; color: #fff; } </style> </head> <body> <div id="popUp"> <img src="https://www.google.co.uk/images/srpr/logo3w.png"/> <a href="#" class="close" >Close</a> </div> </body> </html>
-
Hi Guys I am making a simple lightbox style popup div. What I want is for the div to popup (containing an image) and then scale to 100%. But I want it to scale so it essentially looks like the parent div is opening from the center out. I've seen this effect on lightboxes in the past. The problem I have is that the div appears to only scale from the top left - which you can see because the container's image in the example below shows from the top left. I've tried to play about the various parameters you can set but none seem to achieve what i want. So... a.) Is it possible at all? b.) Is there just some css trickery I am not taking into account? Thanks, Drongo. Simplified example follows: <!DOCTYPE html> <html> <head> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <style type="text/css"> div { margin: 0px; width: 275px; height: 100px; background: green; border: 1px solid black; position: absolute; left: 200px; top: 200px; overflow: hidden; padding: 20px; display: inline-block; display: none; </style> <script> $(document).ready(function() { $("#clicks").click(function () { $('div').show("scale", {direction: 'both', scale: 'both'}, 1000); //alert(1); }); }); </script> </head> <body > <a href="#" id="clicks">Show Div</a> <div> <img src="http://www.google.co.uk/images/srpr/logo3w.png" /> </div> </body> </html>
-
Ha! See this is why I asked That's great. Thank you pik.
-
Hi Guys Simple question but as I dont tend to work with dates much I figured I'd get some advice. I have a DB table and one of the fields is the 'date of publish' in the format 'YYYY-MM-DD' and based on whether the date is in the future or the past I need to display the row data. What I was wondering is whether a method as simple as the following is a viable method to determine whether the date from the db is in the future or not: strtotime() on date from database Get current time() use the php min function to determine if the date in the database is larger than current time - which would indicate it's in the future. Or is that too simplistic and stupid? The other option I am playing with is DateTime::diff but as I need to evaluate a large number of values in this way it seems a bit heavy. Any opinions on whether i am on the right track, and if so, which you'd advise? Thanks, Drongo
-
As above. Set the parent div to be margin: 0px auto; And it most definitely does work in IE!
-
Yes I have I think you misunderstood me. It's not the window.open function I have an issue with. The issue is I don't have access to the site that opens the popup window. The only bit I control is the content of the popup window. I need to change that content but the new content is bigger than the dimensions of hte popup window and the popup also has no scroll set. So I need a way to change the scrollbar property of the window from within the popup. Hope that makes more sense
-
Trigger Onblur Event Even With Very Fast Clicking?
Drongo_III replied to akphidelt2007's topic in Javascript Help
As there's no code I would suggest one of the following: Set a flag when an input box is opened. Then at the start of your click function do a check to see if that flag is true and if it is then don't continue running the click function. So this way you constrain the user to only having one input active at any one time. Then on blur you can reset the flag. Another option might be to set a timer so that the function cannot be run again until say 1-2 seconds has elapsed. Hope those suggestions help a bit! -
Hi Guys Strange request but stick with me. I have a site that I can't currently access that opens a popup window targeted at another site i can access. I need to change the content of that popup which is straight forward enough except for that the function that opens the popup window has the new window set to a small size with no scroll. Resizing the window is easy enough with an onload function. But I need the window to be scrollable. So if a window is opened using window.open(), but the window is not opened with a scrollbar, is it possible to subsequently add the scrollbar dynamically - i.e. through an onload function? This is purely as a temporary solution. I've googled for an hour and tried varies snippets of code but none work :/ So a definitive answer as to whether this is possible would be amazing! Drongo
-
Hi Guys Working on tricky site at the mo and what I really need is to be able to do something like: background : url('images/side_shadows.png') 0px 150px repeat-y; I need this because I want the background shadow to start some distance down the div on which it's applied. But this doesn't appear to work (by which i mean nothing happens and it just tiles down the y-axis as normal). Is it just a fact that this doesn't work or is there something I'm missing? Thanks Drongo
-
Hi Guys Bit stuck on this. I have a textarea and as part of validating it I want to run a regex to ensure it matches my criteria. The problem is everytime I introduce a literal fullstop the check fails - even though it should be one of the acceptable characters. The regex is as follows: $pattern3 = '/^[a-zA-Z0-9"\'\.]{3,}$/'; if(!preg_match($pattern3, $posts['message'])){ $errorsArray[] = 'Please provide a short description of your problem.'; } Anyone point me in the right direction please?
-
Well that worked perfectly Thank you! I will spend some time deciphering that regex too...i'll have it cracked by sometime next month
-
That doesn't seem to match replace the plain text links as links. And I won't lie, I don't follow half of that! If I just wanted to rtrim the reference how can I do that? Is that possible to do?
-
Hi Guys I'm retrieving a twitter feed as json but I have a slight issue. The feed outputs as text and so links in tweets come through as plain text, e.g.: I've used preg_replace to reform the links into html links using the following code: $twitterFeed = file_get_contents('https://api.twitter.com/1/statuses/user_timeline.json?screen_name=twitter&count=4'); $feedArray = json_decode($twitterFeed, true); //Pattern to correct date format $pattern = '/\+[0-9\s\b]+$/'; $replacement = ''; //$linkPattern = '/(http:\/\/[^\s]+)(?!\.)$/'; // This was my shot at forward reference // Pattern to match links $linkPattern = '/(http:\/\/[^\s]+)/'; $linkReplace = "<a href=\"$1\">$1</a>"; // Replacement pattern to create a link foreach($feedArray as $k=>$v){ $date = preg_replace($pattern, $replacement, $v['created_at']); $text = preg_replace($linkPattern, $linkReplace , $v['text']); echo $date . "<br/>" . $text."<br/><br/>"; } The problem is that the linkPattern also captures the trailing full stop at the end of the sentence (seen in example above). So the resultant link ends up as a 404 because that full stop shouldn't be part of the link. Therefore can anyone suggest either: 1) how the linkPattern can be adjusted so that it doesn't capture the trailing full stop 2) how I can rtrim the capture reference if it's a full stop Or do I just need to do another preg_replace? Thanks!
-
Mysql_Pconnect And General Bad Practice...
Drongo_III replied to Drongo_III's topic in PHP Coding Help
Hi Yes there are queries that aren;t even used on every page. It's clearly some sort of 'catch all' solution that doesn't have much regard for efficiency. I think I have my work cut out for me...there is a LOT to fix. -
Mysql_Pconnect And General Bad Practice...
Drongo_III replied to Drongo_III's topic in PHP Coding Help
Not entirely sure about this as I have only just taken over from the last person. It's definitely the only connection being made but whether it's being utilised properly is another matter. So the upshot from that would suggest that it's the way to go - given the site volume. -
Mysql_Pconnect And General Bad Practice...
Drongo_III replied to Drongo_III's topic in PHP Coding Help
Thanks for your reply Kevin Sorry I got the site visitors bit wrong - it's 700-800,000 per month - brain was elsewhere as i was writing :/ . I've never really seen mysql_pconect before - hence why I felt the need to get a second opinion. Do you think with those kind of visitor figures that mysql_pconnect is worth using? Or should I really just drop mysql for mysqli going forward? And the multiple query/fetch statements - where most of them aren't even used on every page - seemed plain wrong too. -
Sorry I realise this is all a bit abstract. I had hoped it would be a known issue with a known solution. The problem is even if I did re-detect the element's position, and reset it, the actual scroll event simply doesnt work when you click back. This is a toughy :/ as even the simple jquery alert in my example didn't work. Do you think I'd have more luck with straight javascript? Would an onload function get preserved perhaps? I realise the ready event is similar. hmmm
-
Thanks christian. That's a possible solution but it's more complicated than that...for instance it can't be allowed to overlap the footer or header. Hence the jquery. Any ideas on how to get around the forward/Back issue?
-
Hi Guys I have recently taken up a new job. I am noticing a lot of bad practices, at least that's how they occur to me, and i was hoping to get your opinion on the following: Is it worth using mysql_pconnect ? I know php.net doesnt advise using it. The site gets a lot of visitors - typically around 700-800 hits a week - so would this justify using mysql_pconnect? And should you therefore use it on sites where you get a lot of traffic to reduce overhead? Or is it just pointless and would it be ok ot just use mysqli connect? A lot of the code is very procedural. One of the include files connects to the database using the method above and then there are mutliple lines lines of mysqli_query, mysql_fetch_assoc (30 plus lines of this). But none of these are surrounded by any logic so it would appear that everytime the include is called all of these statements are executed and all result sets retrieved. Would I be correct in thinking this is a tragically bad approach? OR is this something that works ok because they'ved used mysql_pconnect? Thanks... drongo
-
Hi Guys I wonder if someone can help. Essentially it's a jquery script that makes a scrolling div track the page. So when you scroll down the page the div follows you. That works fine. The issue is that if a user clicks back, or forward on the iPad the jquery seems to simply fail and the scroll event stops working. I tried to strip the page down to test this with just a straight alert as follows: $(document).ready(function(){ alert(1); }); This code fires fine on page load and alerts 1, but if I then navigate away, and then click back, the alert doesnt fire. I am guessing this is a caching issue but I was wondering if anyone had encountered this problem and what the best solution is? Any advice welcome as iPad design is all very new to me. Drongo
-
Hi Guys I hardly ever touch mod rewrite so I am stuck on something very simple. I am using a htaccess file and mod rewrite so that if someone targets a particular url (which is acutally a directory) they will be served a specific file in the directory but the new url will have a query string defining where they came from. So can anyone tell me why this doesn't work please? RewriteEngine On RewriteRule /tester http://localhost/HTACCESS/tester/tester.php?source=google As i said, the goal is if someone hits up my site on the directory '/tester' I want them to be servered a specific file in that directory - i.e. tester.php with a query string. What am i doing wrong? Oh and incidentally when i say it 'doesn't work' specifically I am just getting the directory listing for the 'tester' directory.
-
Hi Guys I hope someone can help with this as I have been banging my head against the wall for three hours and nothing is working :/ Here's what I am trying to do. I have a div that moves with the scroll bar but I want to constrain it to certain dimensions so it can't overlap the footer or header. This semi works but... There are two issues: 1) If I scroll down to the bottom abruptly then the scrolling div simply zooms to the bottom and seems to completely bypass the evaluation of it's position that happens in: if(elementOffset.top > maxScroll){ scrollTopVar = maxScroll -1; //set to -1 to stop this evaluating to true on next scroll } 2) Then when i do scroll down slowly, and the evaluation works, the scrolling div simply gets stuck in the position set in the code above - even though it shouldn't evaluate to true because it's actually one less than the max scroll allowed. Anyway here is the simplified code and I am sure someone better at jquery will instantly point out how easy this can be... <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Slide Div</title> <script type="text/javascript" src="jquery1.8.js"></script> <script> $(document).ready(function(){ var windowHeight = $(window).height(); var docHeight = $(document).height(); var headHeight = 85; //px value for header height - this will be dynamic var footHeight = 400; //px value for footer height - this will be dynamic var currentPos = 30; // This is just a padding value used in the animation so animated div has breathing space from window top var elementHeight = $('#scrollingDiv').height(); //Dynamically get height of scrolling div var maxScroll = docHeight - (80 + 400 + elementHeight); //sets max allowed scrolling limit. var scrollingDiv = $("#scrollingDiv"); // selector for scrolling div // alert(maxScroll); $(window).scroll(function () { var scrollTopVar = $(window).scrollTop(); // defines scrolled distance -i.e. whats slipped under top nav window var elementOffset = $('#scrollingDiv').offset(); //defines the distance to the top of the document from the scrolling element top // First check to see if scroll bar is at top. if(scrollTopVar == 0){ currentPos = 0; } else{ currentPos = 30; } if(elementOffset.top > maxScroll){ scrollTopVar = maxScroll -1; //set to -1 to stop this evaluating to true on next scroll } if(elementOffset.top < maxScroll){ scrollTopVar = $(window).scrollTop(); } // Then based on the evaluation above animate the div scrollingDiv.stop(true).animate({"marginTop": (scrollTopVar + currentPos) + "px"}, "slow" ); }); }); </script> <style type="text/css"> #header {width: 100%; height: 80px; border: 2px dashed red;} #scrollingDiv {width: 300px; min-height: 300px; border: 2px dashed #000; position: absolute; z-index: 100; left: 0px; top: 90px;} #content {height: 1200px; width: 100%;} #footer {height: 400px; width: 100%; border: 2px dashed green;} </style> </head> <body> <div id="header"></div> <div id="scrollingDiv"> <h3>I AM THE SLIDING DIV ME</h3> </div> <div id="content"></div> <div id="footer"></div> </body> </html>