• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Web Design and Development |OT| Pixel perfect is dead, long live responsive design

Somnid

Member
I don't understand what I'm doing wrong here. I have two divs side by side, with a full width div underneath it. Like so:
Jfizzle: https://jsfiddle.net/WanderingWind/1sLdc3b8/


Looks fine on desktop. On mobile, it does this:



I absolutely must have those two side by side elements remain the same height on mobile, without losing any of the text. I can't shrink the text or the element on mobile. I don't even understand what's happening. The second div starts with the second 'lorem.' I'd really, really appreciate any help here.

I can't entirely tell what you are trying to do. It might be as simple as floating the box instead of using inline block (float is used to present things like images with content but is more often used as a general hack for horizontal layouts). But from your description this is what I came up with:

https://jsfiddle.net/mrmjyv4v/
 

WanderingWind

Mecklemore Is My Favorite Wrapper
I may be wrong as I've had a bad day in the office and I can't think properly, but try removing the float:left from the text and add a float:right to the red box.

I wish. :( That keeps the same problem.

I can't entirely tell what you are trying to do. It might be as simple as floating the box instead of using inline block (float is used to present things like images with content but is more often used as a general hack for horizontal layouts). But from your description this is what I came up with:

https://jsfiddle.net/mrmjyv4v/

Ah, so my bad. The red box represents a fixed size element. It contains a picture, so I can't expand it. Basically, the text is the text of an article and the red box represents a 'read related articles' I ginned up with the Slick slider plugin. I tried it with a plain image and obviously a plain div with a background color.
 

Tathanen

Get Inside Her!
I don't understand what I'm doing wrong here. I have two divs side by side, with a full width div underneath it. Like so:
Jfizzle: https://jsfiddle.net/WanderingWind/1sLdc3b8/


Looks fine on desktop. On mobile, it does this:



I absolutely must have those two side by side elements remain the same height on mobile, without losing any of the text. I can't shrink the text or the element on mobile. I don't even understand what's happening. The second div starts with the second 'lorem.' I'd really, really appreciate any help here.

On mobile you have less horizontal space, so your text is wrapping sooner. As such, it takes up more lines. The solution depends on what you want to actually have happen here. Do you want the text to be smaller when the window gets smaller, so the two columns remain the same height? Do you want the red column to get taller along with the left column when there's more text wrapping? Do you want the text to be chopped at the bottom of the red box even if it means hiding the text?

[Edit] Oh you said you can't do a couple of those things already. In that case I.. don't know what you want to have happen here. Do you just want the entire site to scale down proportionately on mobile?

Do you have a meta viewport tag? Something like this:

Code:
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0, width=device-width">

What's in it, if so?
 

WanderingWind

Mecklemore Is My Favorite Wrapper
I really am sorry for not explaining my dumb assery well. I updated the fiddle with the complete code.

On mobile, how do I get the text to wrap below the slider? Not the giant red box lol. I even tried a table. A TABLE LIZ LEMON.

Edit: ok so I updated the fork and didn't save it. I am going to set my head on fire brb

EDIT 2: I smell of burnt hair and frustration: https://jsfiddle.net/WanderingWind/1sLdc3b8/4/
 

Somnid

Member

Tathanen

Get Inside Her!
I had to leave my computer with access to the CMS (it's 10pm here), but this looks exactly right. Does this do the same thing on mobile? And how the holy fuck does that work? I don't get it. I mean, I could just copy it, but what makes that work?

What you needed to do is float the red box to the right of the text. Not to the right of one text area, with a second text area beneath it. To the right of ALL the text. Text will flow around and beneath a floated element that precedes it, if there's enough text to reach that far.
 

WanderingWind

Mecklemore Is My Favorite Wrapper
What you needed to do is float the red box to the right of the text. Not to the right of one text area, with a second text area beneath it. To the right of ALL the text. Text will flow around and beneath a floated element that precedes it, if there's enough text to reach that far.

Well, that explains why I was able to do it before. I really need to cultivate a snippet library, don't I? Fucks sake, I stared at that for 3 hours. Honestly, guys, thanks. I have no sounding boards and I work completely alone. I have nobody buy y'all to bounce shit off from. I am going through books, online resources and I Google every issue before resorting to asking for help.

But goddamn, 3 hours. I'm just going to assume it looks the same in mobile as it does on desktop because that'll make my Monday morning so much brighter and cheerier.
 

diaspora

Member
Why do people hide their navigation on desktop sites? I mean wtf, it's not even hidden in a hamburger menu, you have the click the logo of these guys to go to a nav page, then click on where you want to go. Surprisingly elegant on mobile but weird as shit on desktop/tablet/laptops.
 

vern

Member
Hey guys I'm back again with another newb question hope that you can answer me.

dhZ9Sx6


Link to image here in case it's broken...I dont know wtf I'm doing lol:

http://imgur.com/gallery/dhZ9Sx6/


I'm using a wordpress template and can't figure out how to remove the word "blog" from here and move everything up. I'd imagine this is simple right? Anyone wanna walk me through it? I'll pay you whatever your hourly rate is, prorated if you can do it for me. Shit is driving me crazy.
 

Nelo Ice

Banned
I'm so bad with CSS lol. Working on contract work for a friend and I drew a mockup that I'm now trying to implement in code. This is going to make me pull my hair out. And I'm even thinking about adding a reload button already even though I'm having a helluva time trying to implement my mockup as is.
 

Copons

Member
Hey guys I'm back again with another newb question hope that you can answer me.

dhZ9Sx6


Link to image here in case it's broken...I dont know wtf I'm doing lol:

http://imgur.com/gallery/dhZ9Sx6/


I'm using a wordpress template and can't figure out how to remove the word "blog" from here and move everything up. I'd imagine this is simple right? Anyone wanna walk me through it? I'll pay you whatever your hourly rate is, prorated if you can do it for me. Shit is driving me crazy.

Removing the blog word and its container should be extremely easy, to the point of just adding a quick and dirty
Code:
style="display: none;"
on the container.

Problem would be, that the blog word looks like a link to the homepage, so outright removing it could break your navigation.
 

Chariot

Member
Hello! A PHP question.
I want to do a search that looks in different columns of the mysql table depending on keywords, but I have no idea how to do that.

column1:searchtermA column2:searchtermB

If a user put this into the search field the query should look for seachtermA only on column 1 and for searchtermB in column2. I think the mysql query isn't a problem, but how do I can I fetch the search terms out of this to put them there for the right columns?
 

diaspora

Member
I'm so bad with CSS lol. Working on contract work for a friend and I drew a mockup that I'm now trying to implement in code. This is going to make me pull my hair out. And I'm even thinking about adding a reload button already even though I'm having a helluva time trying to implement my mockup as is.
Learn SASS
 

Copons

Member
Hello! A PHP question.
I want to do a search that looks in different columns of the mysql table depending on keywords, but I have no idea how to do that.

column1:searchtermA column2:searchtermB

If a user put this into the search field the query should look for seachtermA only on column 1 and for searchtermB in column2. I think the mysql query isn't a problem, but how do I can I fetch the search terms out of this to put them there for the right columns?

I kinda didn't understand.

You have one search field, and the user actually writes in a sort of special string written exactly like "first_column_name COLON first_search_term SPACE second_column_name COLON second_search_term"?

In this case, you should divide the string at the space, and again divide each one of the two new string at their colon.
Ie.
Code:
$original_search = 'column1:searchtermA column2:searchtermB';
$separate_searches = explode(' ', $original_search);
$first_search = explode(':', $separate_searches[0]);
$second_search = explode(':', $separate_searches[1]);

// $first_search[0] is column1
// $first_search[1] is searchtermA
// $second_search[0] is column2
// $second_search[1] is searchtermB

At that point, you can build your SQL query as you want.
Ie. (totally unsafe!!)
Code:
SELECT * FROM table WHERE $first_search[0] = $first_search[1] AND $second_search[0] = $second_search[1]
 

WanderingWind

Mecklemore Is My Favorite Wrapper
I feel like your mind is about to be blown

lol it sort of was

I love you people. Do you have any idea how much time I just saved during this project mult-classing stuff? It's almost 3pm and I'm done with today's milestone. I wasn't planning on leaving until 7-8. I owe you all a beer.

And then I couldn't figure out the original usage for floats. :/
 

Chariot

Member
I kinda didn't understand.

You have one search field, and the user actually writes in a sort of special string written exactly like "first_column_name COLON first_search_term SPACE second_column_name COLON second_search_term"?

In this case, you should divide the string at the space, and again divide each one of the two new string at their colon.
Ie.
Code:
$original_search = 'column1:searchtermA column2:searchtermB';
$separate_searches = explode(' ', $original_search);
$first_search = explode(':', $separate_searches[0]);
$second_search = explode(':', $separate_searches[1]);

// $first_search[0] is column1
// $first_search[1] is searchtermA
// $second_search[0] is column2
// $second_search[1] is searchtermB

At that point, you can build your SQL query as you want.
Ie. (totally unsafe!!)
Code:
SELECT * FROM table WHERE $first_search[0] = $first_search[1] AND $second_search[0] = $second_search[1]
Your example of exploding is super helpful and what was missing me. Thank you very much! :)
 

Daffy Duck

Member
Hypothetically speaking:

Company you work for make a website, it gets hacked because it's old code and there's holes in it, to sort it out and shore up the holes do you invoice the client for that or do you absorb the cost?
 

Tathanen

Get Inside Her!
Hypothetically speaking:

Company you work for make a website, it gets hacked because it's old code and there's holes in it, to sort it out and shore up the holes do you invoice the client for that or do you absorb the cost?

Depends on if you had a maintenance contract, and what was in the original statement of work. No one can promise a website that's secure forever, if the issue is a new one you couldn't have forseen and the client did not pay for ongoing support, they should be billed for fixes. If the holes that are there were security holes when it was first written though (SQL injection via non-escaped forms or some crap), and not some sort of new thing that has emerged, they could probably sue you into making the fixes. The original contract likely includes "this site is not a piece of crap" or something similar. Maybe worth doing them for free then.
 

Daffy Duck

Member
Let's assume there is no maintenance agreement in place and also the hack was done via an sql injection.

There would also be no such paperwork that says what and to what standard what would be provided.

But it seems you are singing from the same hymn sheet as me as to the responsibility.
 

Tathanen

Get Inside Her!
Let's assume there is no maintenance agreement in place and also the hack was done via an sql injection.

There would also be no such paperwork that says what and to what standard what would be provided.

But it seems you are singing from the same hymn sheet as me as to the responsibility.

Yeah, contract or not, I think you're kinda obligated as a developer to.. not make a website with obvious holes in it. It's a slippery slope tho, fixing for free could be seen as tacit admission that it's your company's fault, which may also implicate you as the blame-holding party for the hack itself. They could come after you for more than just a fix.
 

Somnid

Member
The company should do security testing when it's built and hold you to fixing those issues. You as the developer should do good work but you are not responsible for anything the client signed off on after they signed off on it. Do not ever do work for free, even if it was your fault they have a responsibility to QA your work.
 

jokkir

Member
Alright, will try to look for a job again. I'm going to try and get some help from my school now too. Maybe something is messed up with my resume or something or maybe they'll know more resources to landing a position.
 

Copons

Member
And just when you think your day couldn't get any worse after the Bowie thing, here I find a creepily weird thing in every directive used as input fields templates in the project I'm currently helping to bugfix.

The bug was that some textarea models weren't bound to their variables in a controller.

I work my way into a 6700 lines controller and even though it was written really bad (you can't even begin to imagine how many different $scopes can be defined in a 6700 lines controller!), it didn't seem to have any issue related to the bug.

So I go check the directive. Template was fine. Function was... well, I don't know.
I'll just leave it here for your amusement (and sorry for the non-Angular crowd, who won't understand what's going on), just stripped down of the non-pertinent things.

First, the directive gets included like this:
Code:
<textarea-field model="notes"></textarea-field>

Which trasforms into:
Code:
<textarea ng-model="textareaField" ng-change="change()"></textarea>

You may have noticed that the directive attribute is called "model", but the actual ng-model is "textareaField".
And there is also a function that gets triggered on change.

And this is why:

Code:
app.directive('textareaField', function() {

return {
  scope : {
    model : '=model'
  },
  link : function ($scope, $element, $attrs) {

    $scope.$watch('model', function() {
      if ($scope.model != undefined)
        $scope.textareaField = $scope.model;
    });

    $scope.change = function() {
      $scope.model = $scope.textareaField;
    }

  }
};

});

Now I don't know the bug is triggered by the directive link (but I replaced the directive with a simple textarea and it works properly).
But... what the heck happens there?

Is it like a clunky attempt to rewrite Angular's 2-way data binding?
I mean: it watches the original model which, at every change, updates a new scope variables which, at every change, updates the original model.
Am I reading it right? :D

(also funny: renaming the scope.model as scope.model :D )
 
[angular hell]

Yeah it looks like they are trying to bind the 2 models together. If one changes the other should change with it. It looks like this should create an infinite loop, or is Angular doing some magic so ng-change or $watch doesn't fire if the value is updated with the same value...

Did the directive do anything extra or was this it? If so yeah remove the directive.
 

Copons

Member
Yeah it looks like they are trying to bind the 2 models together. If one changes the other should change with it. It looks like this should create an infinite loop, or is Angular doing some magic so ng-change or $watch doesn't fire if the value is updated with the same value...

Did the directive do anything extra or was this it? If so yeah remove the directive.

Aside adding some additional attributes on the textarea (ie. required, placeholder), the directive doesn't do anything more than what I wrote.

Anyway, I solved that one bug replacing the directive with a normal textarea, but I just can't do anything else as every single input type has its own directive, doing the exact same model juggle.
This app is a fucking worms nest, it's quite unbelievable that most of it is working and with decent performances.

What is clear though, is that whoever wrote it doesn't know the slightest thing about Angular, but just glanced through the official docs and put together something with inevitably half assed knowledges about it.
I mean, rewriting the 2-way binding could only mean two things: or the original programmer (who, btw, as I discovered recently, quit the job, and I was called to take on his work) never got to the second paragraph of every single Angular tutorial, or he's a madman and should be institutionalized for crimes against humanity.


omg every time I see Angular I get remembered why I never used it for more than examples :)

Damn you React cool kids! :p
 

Copons

Member
to be fair, I could show you some React code that is as bad as this :)

Oh but I'm sure! With the added complexity of potentially having both bad JS code and bad HTML code inside!

And yes, any code can be bad, it's just kinda rare to see someone trying to rewrite the #1 selling point of a language/framework. :D
 

grmlin

Member
Every rant about code beginning with "that 6000 loc thing..." does not need a specific framework to be the horror.

At least these type of files are really rare in react, as you are forced to modularize everything. In React, the worst code is written by developers that learned "a little" js and have no idea about html. Urgh.
 

WanderingWind

Mecklemore Is My Favorite Wrapper
Does anybody have a good tutorial for drop.js? The documentation for it suuuuucks. I'm still working on the popovers. Sadly, jquery fucks with the legacy jquery integration on my site, so any basic Jquery plugin and/or Bootstrap popover integration fails hard. I can get those to work on my own page just fine, but it basically shuts everything down. I even cut everything from the Bootstrap file (holy hell at the size of that .css doc, btw). Something in the .js fights hard with the legacy crapware...err...bloat....
 
Does anybody have a good tutorial for drop.js? The documentation for it suuuuucks. I'm still working on the popovers. Sadly, jquery fucks with the legacy jquery integration on my site, so any basic Jquery plugin and/or Bootstrap popover integration fails hard. I can get those to work on my own page just fine, but it basically shuts everything down. I even cut everything from the Bootstrap file (holy hell at the size of that .css doc, btw). Something in the .js fights hard with the legacy crapware...err...bloat....
Where's the problem exactly? Is it because of the $ namespace? Have you tried using noConflict() and a custom selector?

Also, did you try your luck with jQuery migrate?
 

WanderingWind

Mecklemore Is My Favorite Wrapper
Where's the problem exactly? Is it because of the $ namespace? Have you tried using noConflict() and a custom selector?

Also, did you try your luck with jQuery migrate?

Now, obviously, I'm learning javascript right now, but it seemed that migrate would actually change the implementation of jquery on other components on the page. As for noConflict, I started to look into that, but I got lost.

Here is what I'm using to initialize everything. The .lightbox is the one component out of my control. Both slicks depend on jquery 1.11.0 (same as the bottom element) and they break nothing. But the lightbox breaks when I initialize the bottom element (which is just a popover plugin). It won't initialize at all.

Code:
 jQuery(function () {
    jQuery('[data-hook=derp]').lightBox({
      options: options
    });
  });
  $('.fade').slick({
   options: options
  });
  $('.carousel').slick({
   options: options
  });
  $('.pins').webuiPopover({
    options: options
  });

I tried noConflict like so
Code:
$.noConflict();
jQuery( document ).ready(function( $ ) {
  jQuery('[data-hook=derp]').lightBox({
      options: options
    });
  });
  $('.fade').slick({
   options: options
  });
  $('.carousel').slick({
   options: options
  });
  $('.pins').webuiPopover({
    options: options
  });
});

But that was a hilarious failure. The console basically just showed me a big ass middle finger when I went to inspect.
 

Somnid

Member
Now, obviously, I'm learning javascript right now, but it seemed that migrate would actually change the implementation of jquery on other components on the page. As for noConflict, I started to look into that, but I got lost.

Here is what I'm using to initialize everything. The .lightbox is the one component out of my control. Both slicks depend on jquery 1.11.0 (same as the bottom element) and they break nothing. But the lightbox breaks when I initialize the bottom element (which is just a popover plugin). It won't initialize at all.

But that was a hilarious failure. The console basically just showed me a big ass middle finger when I went to inspect.

First, you probably need to calm down. I don't know if you're trying to be hyperbolic but it's easier to understand if you give clear explanations. What exactly is in the console? If you need to use an older version of jquery you'll need to call noConflict(true) which will migrate all the global cruft jquery has. Most likely you want something like

Code:
var newJquery = $.noConflict(true);

where newJquery is now a reference to the new version and $ is a reference to the old version. Depending on the plugin it might not like that, in which case you may have to manually hold on to references and restore them which will be a giant pain-in-the-ass. Ideally you can see if you can upgrade the existing jquery, maybe not to the most recent version but to something new enough not to have issues.
 

WanderingWind

Mecklemore Is My Favorite Wrapper
Eh, this is why I do what I do instead of telling jokes. The console is of no help because there isn't anything that is showing as an error. If I had to hazard a guess as to what the problem is, is there is an old version of jquery being used globally across the site and it whatever version of it is being used causes conflicts. I've run into that problem and have been able to work around it (I know I ask a ton of questions, but I promise I solve dozens more on my own).

What happens now seems to break logic for what I understand. All of the elements play nice, until I try to initialize both the lightbox and the webuiPopover script. I have tried several plugins in place of the webuiPopover one, but the issue remains. Both of those are dependent on jQuery. The webuiPopover is dependent on at least 1.11.0.
 

WanderingWind

Mecklemore Is My Favorite Wrapper
Why do you init the other elements after the lightbox outside the document.ready-handler?

This is what it looks like now.

Code:
  jQuery(function () {
    jQuery('[data-hook=derp]').lightBox({
      option: stuff
    });
  });
    jQuery('.fade').slick({
      option: stuff
    });
    jQuery('.carousel').slick({
      option: stuff
    });
    jQuery('[data-toggle=popover]').popover({
      option: stuff
    });

But it should look like this, is what you're saying?
Code:
jQuery(function () {
    jQuery('[data-hook=derp]').lightBox({
      option: stuff
    });
    jQuery('.fade').slick({
      option: stuff
    });
    jQuery('.carousel').slick({
      option: stuff
    });
    jQuery('[data-toggle=popover]').popover({
      option: stuff
    });
  });
 

grmlin

Member
Yes.

When calling your jquery plugins inside the the ready handler you can be sure that the DOM was parsed and all elements inside are available. Otherwise it's possible that the elements you try to address with your plugin are not available yet.

It will not help with your problem though I think :-(
 

WanderingWind

Mecklemore Is My Favorite Wrapper
That was what I thought to do initially. However, that causes none of the elements to fire. I'm glad that it looks wrong to more experienced eyes, that actually makes me feel a wee bit less thick. I wish I knew why it breaks it to do it correctly.
 

grmlin

Member
That's weird. If you want to write your dom manipulating code in the most robust way, all of it should be called after document ready.

How many jQuery's do you include? I would strongly recommend to use only one version, everything else is a pain. You better use another plugin, if one is not working properly.



Did you debug the code?

- do the selectors return empty jQuery objects?
- If you include multiple versions of jQuery it could be possible, that the plugins are registered with one version of it, while, after the document got ready, another jQuery version could try to use them.
 

WanderingWind

Mecklemore Is My Favorite Wrapper
Here is the fun part. The slick sliders depend on jQuery. But I have to remove jQuery entirely because the global jQuery that I cannot access causes redundancy errors (I don't know if that's what it's called when you have 2 jQuery instances going, but you get the idea) if I do. But no problem, as the global jQuery causes the sliders to work.

It also allows for the popover element to fire, unless I try to run it on the same page as anything else that requires jQuery. Then the popovers will fire, but the lightbox will break.

As for debugging, all I know to do is to open up the JS console and check for errors. I don't get any errors except for "jquery(...).lightBox is not a function" which according to Google Fu, points to a path problem or multiple instances of jQuery running. Neither is the case. I may be a novice, but I know how to delete one of four script links and reload. And obviously, I check the path to ensure no mistypes.
 

grmlin

Member
So,
one of the plugins you use comes bundled with some version of jQuery? Maybe there is a version without one?

It's pretty uncommon, that a plugin includes jQuery, normally you include is as the first script yourself.


The "jquery(...).lightBox is not a function" clearly indicates, that you have to deal with multiple instances of jQuery, which, as I said, is a pain.
 

nicoga3000

Saint Nic
So does anyone here do freelance work? My company wants to redo our website...

If you've got experience with professional web development for business and are possibly looking for some work, we should talk. We have a quote from one company, but we SUPER thrilled with their example sites they provided.
 

WanderingWind

Mecklemore Is My Favorite Wrapper
I'm using slick.js and the most recent attempt is Bootstrap's popover.js. The only other one is lightbox, which is the only one I don't and can't control. I have no other plugins or scripts whatsoever.

If I put just a naked slick slider on a blank page, without migrate or jQuery, it'll still fire. That seems to tell me that there is a global jQuery that each page inherits. If this is stupid person talk, I do apologize. I'm learning as I go, here.

I thought maybe Bootstrap was including some instance somewhere, as I'm learning that...uh, this week apparently, but I went ahead and nuked everything in the css that didn't say .popover and still had the same issue.

But I do agree that I might be better served moving to another method to get popovers. I was hoping drop.js would be it, but the documentation for that assumes a level of ability that I do not, as yet, posses. And it's fairly new, so there isn't much ancillary documentation on it. Nobody even made a YouTube video. lol
 
Top Bottom