Friday, September 19, 2014

How to imitate bootstrap's tooltip without bootstrap

Working with my next project, I had to come up with an idea to imitate tooltip bootstrap style without bootstrap. So, I did some research and found excellent resource. This example gave the idea how create fully-customized tooltip for my project.  Here's an example how I used the sample:


HTML:

<div id="top-menu-bar-buttons">
                  <div class="button1 icon-location-left"><button class="btn-secondary tooltips" type="button">Cancel<span class="width60">Cancel</span></button></div>
                  <div class="button2 icon-location-left"><button class="btn-secondary tooltips" type="button">Preview<span class="width60">Preview</span></button></div>
                  <div class="button3 icon-location-left"><button class="btn-primary tooltips" type="button"><div id="top-menu-bar-button3-text">Review Job</div><i class="fa fa-chevron-right fa-lg"></i><span class="width75">Review Job</span></button></div>
</div>

CSS:

button.tooltips {
  position: relative;
  display: inline;
}
button.tooltips span {
  position: absolute;
  color: #FFFFFF;
  background: #000000;
  height: 19px;
  line-height: 18px;
  text-align: center;
  visibility: hidden;
  border-radius: 6px;
  font-size: 12px;
  font-weight: normal;
}

button.tooltips span:after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-left: -8px;
  width: 0; height: 0;
  border-bottom: 8px solid #000000;
  border-right: 8px solid transparent;
  border-left: 8px solid transparent;
}

button:hover.tooltips span {
  visibility: visible;
  opacity: 0.8;
  top: 40px;
  bottom: 30px;
  left: 100%;
  margin-left: -76px;
  z-index: 999;
}

.width60 {
    width: 60px;
}

.width75 {
    width: 75px;
}

Wednesday, June 11, 2014

CSS: Default values

Every CSS style has a natural default value. It's just not always none.

Some may be 0 (as in zero).

Some may be auto.

Sometimes inherit is the best option.

Colours can be set to transparent.

If you're unsure what the default is, try creating a dummy page with just a plain unstyled element, and use the browser dev tools to see what the styles are set to.

Thursday, May 22, 2014

Starting with LESS in .NET environment.

Researching the topic above I did not find anything useful for my project. Therefore my team lead and I found out pretty good way to implement LESS in out Bootstrap-Knockout environment.

1. Download less-1.7.0.min.js from LESS site and add to your scripts folder.

2. Open HTML file and add the line.
<script src="Scripts/less-1.7.0.min.js"></script>

3. Using Visual studio, create .less file and add line to HTML file before js-files.
<link rel="stylesheet/less" type="text/css" href="Content/custom/css/hello1.less">

4. Open web.config file and after(underneath) <system.web> add
<system.webServer>
    <staticContent>
      <mimeMap fileExtension=".less" mimeType="text/css" />
    </staticContent>
  </system.webServer>

Now you can play with .less files in .NET environment.

Friday, April 18, 2014

Border around inputs

Working on my project, I had problems with Chrome presentation of some elements. It creates border automatically around many elements. I had to find a cure for the problem. The answer is in such a good article. It works and removes border around elements in Chrome and Safari.

Tuesday, April 15, 2014

Disabled Tooltip

My last project runs on Bootstrap-Knockout platform.  I'm learning a lot about presenting elements in this environment. One of the major problem is to hide tooltip for Mobile views.
I searched the Internet and did not find a lot of information about such problem. One of the articles was particularly good, but I still have to find my original solution. My code disables the tooltip for Mobile users and save button functionality.
Here's what I did.

HTML:
<button class="btn btn-default btn-primary" type="button" data-bind="text: RequiresConfig == true ? 'Create' : 'Add to Cart',tooltip: { title: RequiresConfig == true ? 'Create' : 'Add to Cart', placement: 'bottom', disable: false }"></button>

Javascript/jQuery (accompanies HTML).
<script type='text/javascript'>
        jQuery(function ($) {
            if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
                ko.bindingHandlers.tooltip = {
                    options: {
                        disable: true
                    }
                };
                ko.applyBindings({});
            }
        });
    </script>

Friday, April 11, 2014

It's not a bug!

This time QA was right. They discovered some differences in landscape and portrait views in iPhone. It's only Safari and only iPhone does this. It re-sizes the font and images going from portrait to landscape. It's not a bug, it's a iPhone feature. To fix the issue, I found an article and patched my code. Very simple line of code fixes the feature.

html {-webkit-text-size-adjust: auto;}

It was a very good learning experience for me.

Friday, March 28, 2014

How create gradient color without images...

Working on a new assignment, I had to find a way to generate gradient color.  I decided to educate myself and learn online gradient generator. First of all, I found a good one, for a second, using online tool, I generated a nice piece of code for my project.