G$earch

Web Design: Getting Started With Chrome Developer Tools

Posted by Harshad

Web Design: Getting Started With Chrome Developer Tools


Web Design: Getting Started With Chrome Developer Tools

Posted: 13 May 2013 08:01 AM PDT

Google Chrome is a (relatively) new kid on the block who quickly gain good market share in the browser niche, and it’s is equipped with a Handy Tool for Developers.

In this post, we are going to explore it and utilize some of its features that might help you during the web development process.

To get to the Chrome Developers Tool, go to Tools > Developers Tool.

Alternatively, you can also right-click on the web page and choose Inspect Element and If you are using Google Chrome in Windows, you can also hit the F12 key.

Using Elements Tab

We will start off with the Elements tab. In this tab we can view the webpage markup as well as the styles that affect the page, which can be used to inspect what went wrong in HTML and’ CSS.

Editing Document Structure

If we right-click on one of the elements, we will find a few handy options to Add and Edit the Attribute, Copy and Edit the HTML markup and even view the element state to see what will happen when it is in :hover, :focus and :active.

This feature is very useful in cases like when we need to make a change but somehow do not have direct access to the source file, for instance in my case, I use this when asked by a friend to help debug their webpage.

Another little trick we can use is to also drag and drop the elements. Hold your click to one element and move it up and down, then you can see the impact instantly.

In this example, we slightly swap the Facebook header structure and see what happens.

Editing the CSS

When you have selected an element, you will see the styles that affect that element on the right. We can see what are the styles that are applied, we can also add or remove the styles.

Furthermore, the Chrome Developer Tool is also equipped with a color-picker to adjust the element colors seamlessly; just click on the color box and you will see it popping up, like so.

In terms of color format, the browser will typically show the Hex format. Now, in case you need the RGB or HSL format we can also do the change this way: Click on the Setting icon at the right under the Styles tab.

As you can see, we have the color format options there, you can now change it the way you need.

Adding CSS

As I have mentioned, we can add styles and here is how to do it. First, select the HTML element that we want to add the styles to, then in the Styles tab, find the plus (+) sign, click on it and it will generate the proper selector automatically.

Now, you can add the styles upon this selector right from the browser.

Viewing the Console

In the Console tab, we can see log events for Errors and Warnings. This notification below from the Console shows that one of our files cannot be loaded and this is the place where you might need to check where your website went wrong.

If we are working with jQuery, we can also send the log of our script event to the console using console.log. This example shows how we grab the value of an input element and send the result to the Console just to ensure the data is correct.

HTML

 <input type="text" value="Hi There!"> 

jQuery

 var val = $('input').val(); console.log(val) 

When we reload the page, here is what we get in the Console.

Changing User Agent

Assuming that you are developing a website you probably want to see how it may turn out in particular devices. In that case, we can change the User Agent.

Here is how to do it in Chrome. In Developer Tools, you will find a Setting type of icon at the bottom right. Click on it, and an overlay option will pop up, like so.

Next, go to the Overrides tab. In this tab, we will find User Agent options and by default Google Chrome has provided a few user agents ready, such as for iPhone, Android, Blackberry, and etc.

Just in case, you can’t find your required environment here, you can go to User Agent String to pick-up the one you need.

On the option list, select Other and put the User Agent that has you just been copied in the input field next to it.

Conclusion

There are a lot more functionality in the Chrome Developer Tool, but it would take a really long post to document it all.

Ultimately, I hope this post can benefit you and improve your productivity in web development and if you have anything to add something that we may have missed here, feel free to share it in the comment box below.

    


5 Common Types of Bosses (And How to Deal With Them)

Posted: 13 May 2013 06:01 AM PDT

My years of experience working for a financial company have led me to face many types of bosses. Some were very hard to deal with, but I was fortunate that I had mostly good ones to look after me. As I moved into sales and marketing, I noticed that bosses were particularly more inclined to build a good rapport with the sales guys.

angry boss

It may be because they thought that sales teams were the crux of a firm, and therefore, bosses made sure that the sales team members were well looked after. That doesn’t mean that the sales department had it all hunky-dory; it’s also the sales team members who had to bear the brunt of a boss’s wrath. When things don’t go their way, that’s where you come across the real side of the boss.

Managing Your Boss

Bosses (not leaders – there is a difference) are humans too and they have their preferences and dislikes and if you play your cards well, you will be able to work not only for them, but also with them. There have been employees I knew personally, who never performed that well, but still they manage to keep their jobs because they knew how to be in the boss’s good books.

Learning how to deal or manage your boss is a significant and transferable skill, and will indefinitely decide how far you progress. While I wouldn’t go so far as to say that all bosses in the world fall only into these 5 categories, but if yours does, I have suggestions on how you can stay in the organization.

1. The boss With the Superiority Complex

He loves screaming and he looks for opportunities to shout at others. A high-pitched boss has a superiority complex, and believes that others are wrong. A very edgy character by nature, he doesn’t like to dwell on a reason behind a problem, but instead takes solace from the fact that he has scolded someone, and hence, he has prevented the mistake from re-occurring. Many of you may have certainly come across such bosses.

angry boss

You will notice that they are also edgy in their appearance, not just by the way they talk, but also by the way they sit. Peep inside his office chamber, and you will find that he is always shifting in his seat. Even before he has said a word, he has already made you edgy and worried about what he is going to say next.

How to Deal with It:

Dealing with such bosses is easy only if you are prepared to take verbal blows from him. A high-pitched boss gets satisfaction from watching his subordinates take his nonsense. And if you can do exactly that, then you have dealt with him.

Never give an impression that you are fed up with taking his nonsense, the more you accept his verbal blows, the more he believes he is right.

By doing so, you will stay on his good side. But if you try to show that you are smarter than him by opposing him or getting into an argument with him, you perhaps risk your growth in the company and will probably do better with another type of boss.

2. The Boss who Brandishes his Power

He takes great pride in waving his power and authority around, not just in office but sometimes also at home. A power-brandishing boss loves wearing the mask of a boss, and believes that bosses are the highest-regarded professionals in the world.

He is overtly possessive of his post and always wants to give an impression that he is completely in control of the situation, even when in reality he is not.

He is insecure, and too preoccupied with trying to always have things under his control. At times, the employees may have committed mistakes, yet he pretends to have not seen them and says little of their mistakes.

How to Deal with It:

This type of boss gives significance to discipline, rather than performance, and is of the opinion that employees should be self-disciplined. His motto is that with discipline, employees will eventually perform.

Even if you find such bosses to be lenient, you should not break the rules too often; and even if you do so, make sure that you don’t bring it to his notice. Show him respect him, and make him feel that he is the big boss and you will be able to go about your duties undisturbed.

3. The Boss Who Doesn’t Belong

This boss gives you an impression that he has been thrown into a post that he is not fit for. This boss is possibly an employee in the company who had been promoted to be a ‘boss’ without the relevant qualities. He is someone management had to fall back on because there are no other options.

You will notice that half of his motivational speeches in office meetings will contain a list of his past achievements, and the rest is utter claptrap. He stresses a lot on performance, but lacks the management skills to get them. Employees may make fun of him behind is back even though in truth he is hardworking.

He tries to learn, and also makes amends if he has committed mistakes. Nonetheless, he lacks confidence and doesn’t stick to a plan especially when things do not work as planned.

How to Deal with It:

This type of boss will welcome advice that will help him get his bearings, and if you can offer him substantial help, you can easily befriend him. Just don’t expect him to be lenient in the office, he has a reputation to build and maintain and he can’t make any false moves, or tolerate mistakes by his team members.

Give it enough time and you find that he will eventually be a good boss as he is eager to learn and will collect the tricks of the trade with time.

4. The boss who Intimidates

An intimidating boss is a no-nonsense boss, aggressive by nature, and tries to get things done by issuing commands. He has an ego, and keeps it with him while he is in the office. Sometimes you will feel that he is trying to run the show as if he is running a criminal gang.

angry boss

On the one hand, he threatens his employees, but on the other hand, he doesn’t go overboard because he is insecure, and doesn’t wish to lose his effect on the employees.

He believes that too much of intimidation will lessen his grip on his employees, and that’s the reason he sometimes overlooks mistakes by his employees.He keeps to his own space, and is reserved by nature.

How to Deal with It:

The best way for employees to handle this boss would be to respect his privacy, and don’t interact with him unnecessarily. If you are smart enough, and know how to break his defences, you can even befriend him, and will be able to take some liberties in the office.

However, don’t go overboard otherwise, he’d also be the one who throws you out of the office.

5. The boss Who Excels and Influences

Ideally, he is the best boss to have running a company as he handles both the management and his employees efficiently. The company prefers such bosses because they have positive vibes about themselves, and make the company believe that they can produce results even in the midst of a crisis.

They are not particularly harsh on employees, but they mean business. Not all influential bosses are inspiring, but they have the guile to make others perform to their limits. An influential boss is highly professional, and expects employees to behave similarly.

How to Deal with It:

Dealing with him is never a problem if you perform your duties well enough. However, beware of such bosses, as they are highly determined to rise in the hierarchy. If he feels that you are a threat to his goals, he will have you removed from the company.

An influential boss also forms his own core group, even within the same organization, who may inform him of what happens in the office while he is away. Therefore, be careful and mind your own business, and you will always stay in his good books.

Conclusion

We may not have the luck of working with good leaders but we indefinitely have to work with a boss, the head of an organization or the manager of a group of workers. They get groups of people to do things that contribute to the company objectives and at the end of the day, employees don’t leave jobs or organizations, they leave their bosses.

So what is your boss like, and how do you deal with your boss?

    


How to Style Google Maps

Posted: 13 May 2013 03:01 AM PDT

Google Maps is one of the best services you can get from Google. It’s a free tool that allows you to easily embed interactive and information-rich maps on your website. However, one disadvantage that comes from using free services is that eventually they all look the same.

The good news is Google launched the API that controls the map styles. So, in this post, we will see how to use the API, and make your map be more distinctive.

Google Maps Library

The first thing that we need to do is to include the Google Maps JavaScript library inside the document’s <head> tag, so that we can use the API.

 <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> 

Google Maps Components

There are three components to style the Google Maps: the feautureTypes, the elementTypes, and the Sytlers.

featureTypes is used to select the geographical objects on the map, such as the road, the water, and the parks, so it basically works like the CSS selectors. For your convenience, we have listed a few featureTypes that we can use to control the map.

FeatureTypes Description
water Select all the water objects on the map including the sea, the lake and the river.
road Select all the roads on the map.
landscape Select the landscapes on the map.
poi Select the point of interests, areas like schools, business districts, and parks.
transit Select all the public transit like bus stations, the train stations and the airports.
administrative Select the administrative areas.

For more, you can head over to the following API reference: Google Maps feature type specification.

elementTypes is used to target the element that is part of the geographical objects, such as the object shape, the fill, the stroke, and the object labels.

stylers is an array of properties to adjust the object colors and its visibility. Google Maps accepts HSL (Hue, Saturation, Lightness) and Hexadecimal for the color format.

Basic Usage

First of all, we need to add a <div> element that is assigned with an id to contain the map.

 <div id="surabaya"></div> 

The styles in Google Maps are declared with JavaScript objects. So, all the styles are nested under the <script> tag – this is the JavaScript 101. Additionally, you can place the scripts before the body close tag, or at the head tag with the window.onload function, like so.

 window.onload = function () { // add the scripts here } 

Create a variable to contain the map style rules. In this case, I would like to name it as styles.

 window.onload = function () { var styles = [ // we will add the style rules here. ]; }; 

Then, display the map to the <div> container with the following functions.

 window.onload = function () { var styles = [ // we will add the style rules here. ]; var options = { mapTypeControlOptions: { mapTypeIds: ['Styled'] }, center: new google.maps.LatLng(-7.245217594087794, 112.74455556869509), zoom: 16, disableDefaultUI: true, mapTypeId: 'Styled' }; var div = document.getElementById('surabaya'); var map = new google.maps.Map(div, options); var styledMapType = new google.maps.StyledMapType(styles, { name: 'Styled' }); map.mapTypes.set('Styled', styledMapType); }; 

At this point, the map should have appeared on your page, as follows.

In this example, I would like to change the color of the water. To do so, we can write the style rules in this way, within the styles variable.

 var styles = [ { featureType: 'water', elementType: 'geometry.fill', stylers: [ { color: '#adc9b8' } ] } ]; 

The code above changes the fill color of the water element on the map to color #adc9b8, and here how it turns out.

Next, let’s change the landscape’s color, and this time we will use the HSL color format so that we can adjust the color lightness, like so.

 var styles = [ { featureType: 'water', elementType: 'geometry.fill', stylers: [ { color: '#adc9b8' } ] },{ featureType: 'landscape.natural', elementType: 'all', stylers: [ { hue: '#809f80' }, { lightness: -35 } ] } ]; 

This code addition gives us the following result.

Furthermore, these are the style rules for several other objects on the map.

 { featureType: 'poi', elementType: 'geometry', stylers: [ { hue: '#f9e0b7' }, { lightness: 30 } ] },{ featureType: 'road', elementType: 'geometry', stylers: [ { hue: '#d5c18c' }, { lightness: 14 } ] },{ featureType: 'road.local', elementType: 'all', stylers: [ { hue: '#ffd7a6' }, { saturation: 100 }, { lightness: -12 } ] } 

Here is how the final look of the map.

You can head over to the demo page to see the final result in detail.

Google Maps Styling Tools

In addition, if you prefer working GUI rather than manually writing the script, here are the tools for you to try out.

Further Resources

Further on implementing Google Maps API for map styling, you can head over to the following references.

    


0 comments:

Post a Comment