Searching the Internet for something suitable for my assignment I did not find anything interesting. Some sites are closed, some - not. I came out with my own code, which works in MVC/Bootstrap/Knockout environment.
HTML:
<div class="btn searchcontainer" id="searchcontainer" style="margin-top: 50px; margin-right: 25px; border: 1px solid @(string.IsNullOrEmpty(ViewBag.productListJSON) ? "red" : "#D7D7D7");">
<input type="search" value="@(string.IsNullOrEmpty(ViewBag.SearchWord) ?"Search Catalog... ":ViewBag.SearchWord)" onclick="if(this.value=='Search Catalog... '){this.value=''; this.style.color = '#000000';}" onblur="if(this.value==''){this.value='Search Catalog... '; this.style.color = '#D7D7D7';}" style="@(string.IsNullOrEmpty(ViewBag.SearchWord) ?"width:15em; border: 0px; color:#D7D7D7;": "width:15em; border: 0px; color:#000000;")" rel="popover" data-placement="left" data-content="No Records Found" data-original-title="Alert" name="searchKeyword" id="searchKeyword" required/><a id="btn-search">Go ></a>
</div>
Javascript:
<script type='text/javascript'>
var productList = @Html.Raw(Json.Encode(@ViewBag.productListJSON))
$(window).load(function() {
if (productList == "") {
$("#searchKeyword").popover('show');
}
});
</script>
What it does: it displays a popover only when search return empty set:
Thursday, December 19, 2013
Dynamic Bootstrap Popover on empty search
Friday, December 13, 2013
Search box with a link inside
Doing a project, I had to implement a search-box with link inside in knockout-bootstrap environment. Before doing something like this, I Googled the Internet and found out that there is no solution on popular sites. So, I decided to write by myself. It a very easy and very elegant piece of code.
Here it is:
<div class="row">
<div class="btn searchcontainer" id="searchcontainer"><input type="search" placeholder="Search Catalog..." style="width:15em; border: 0px;" name="searchKeyword" id="searchKeyword" required/><a id="btn-search">Go ></a></div>
</div>
Couple days later... Placeholder does not work in IE9. I had to come up with some different code and I did:
<div class="btn searchcontainer" id="searchcontainer" style="margin-top: 50px; margin-right: 25px;">
<input type="search" value="@(string.IsNullOrEmpty(ViewBag.SearchWord) ?"Search Catalog... ":ViewBag.SearchWord)" onclick="if(this.value=='Search Catalog... '){this.value=''; this.style.color = '#000000';}" onblur="if(this.value==''){this.value='Search Catalog... '; this.style.color = '#D7D7D7';}" style="@(string.IsNullOrEmpty(ViewBag.SearchWord) ?"width:15em; border: 0px; color:#D7D7D7;": "width:15em; border: 0px; color:#000000;")" name="searchKeyword" id="searchKeyword" required/><a id="btn-search">Go ></a>
</div>
I think, it will work for IE 9 and IE 10 (cross the fingers)
Here it is:
<div class="row">
<div class="btn searchcontainer" id="searchcontainer"><input type="search" placeholder="Search Catalog..." style="width:15em; border: 0px;" name="searchKeyword" id="searchKeyword" required/><a id="btn-search">Go ></a></div>
</div>
Couple days later... Placeholder does not work in IE9. I had to come up with some different code and I did:
<div class="btn searchcontainer" id="searchcontainer" style="margin-top: 50px; margin-right: 25px;">
<input type="search" value="@(string.IsNullOrEmpty(ViewBag.SearchWord) ?"Search Catalog... ":ViewBag.SearchWord)" onclick="if(this.value=='Search Catalog... '){this.value=''; this.style.color = '#000000';}" onblur="if(this.value==''){this.value='Search Catalog... '; this.style.color = '#D7D7D7';}" style="@(string.IsNullOrEmpty(ViewBag.SearchWord) ?"width:15em; border: 0px; color:#D7D7D7;": "width:15em; border: 0px; color:#000000;")" name="searchKeyword" id="searchKeyword" required/><a id="btn-search">Go ></a>
</div>
I think, it will work for IE 9 and IE 10 (cross the fingers)
Thursday, December 12, 2013
Knockout-Bootstrap
Working in Bootstrap-Knockout environment, I have to create some elements to enhance the application. I found it's not easy to work in this environment because Knockout dominates all the time. Therefore, I found a very good piece of software which work for me.
The code is in http://billpull.github.io/knockout-bootstrap/js/knockout-bootstrap.min.js
It's much easier to work with this library than raw bootstrap and knockout.
The code is in http://billpull.github.io/knockout-bootstrap/js/knockout-bootstrap.min.js
It's much easier to work with this library than raw bootstrap and knockout.
Wednesday, December 4, 2013
Changing appearance of Bootstrap ToolTip
Today I worked on Bootstrap tooltips. I needed to set up several different tooltips on one page. The problem was with width of the Tooltips. I can not have the same width for all of them and had to set up different width for different tooltips. Thanks article, I found the way to set up the different width.
Each division has an unique class name (business_name and business_description) and I changed tooltip set up only this class (css)
/*specially for this template I changed Bootstrap tooltip width to handle a Product name*/
.business_name + .tooltip > .tooltip-inner {
width: 350px;
}
/*specially for this template I changed Bootstrap tooltip width to handle a Product description*/
.business_description + .tooltip > .tooltip-inner {
width: 350px;
}
These definitions overwrite Bootstrap tooltip and create a new setup.
Each division has an unique class name (business_name and business_description) and I changed tooltip set up only this class (css)
/*specially for this template I changed Bootstrap tooltip width to handle a Product name*/
.business_name + .tooltip > .tooltip-inner {
width: 350px;
}
/*specially for this template I changed Bootstrap tooltip width to handle a Product description*/
.business_description + .tooltip > .tooltip-inner {
width: 350px;
}
These definitions overwrite Bootstrap tooltip and create a new setup.
Tuesday, November 19, 2013
A list of Font Awesome icons and their CSS content values
Today, I'm proud of myself. Instead doing a lot of tweaks and coding and found the way to satisfy my customer. I think, all of us, who work with Font Awesome, bootstrap and jQuery must know about article. It's absolutely clear, that the article will save many hours of coding and finding a right solution. I hope, to you the article as much as I can.
Friday, November 15, 2013
Text-overflow
Today I learned something new and quite interesting. Usually text-truncation is done with some javascript. Nowadays we can do using text-overflow. It very elegant and simple solution and it work just fine in all browsers. We just have to add text to a div or paragraph and create a class. For example:
HTML:
<div class="oneline" title="text">text</div>
CSS: .oneline { text-overflow : ellipsis; white-space : nowrap; width : 100%; overflow : hidden; padding: 0px; margin: 0px; }
This combination will truncate the long lines in div and gives a very good tooltip. I think, it's the most elegant solution I saw in a last time I work with HTML.
HTML:
<div class="oneline" title="text">text</div>
CSS: .oneline { text-overflow : ellipsis; white-space : nowrap; width : 100%; overflow : hidden; padding: 0px; margin: 0px; }
This combination will truncate the long lines in div and gives a very good tooltip. I think, it's the most elegant solution I saw in a last time I work with HTML.
Tuesday, November 5, 2013
LESS
I'm starting to work with LESS. For those who has no clue what is this, I can recommend some sites
1. http://getbootstrap.com/customize/
2. http://coding.smashingmagazine.com/2013/03/12/customizing-bootstrap/
3. http://blog.teamtreehouse.com/customize-an-html5-webpage-using-the-bootstrap-framework
4. http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/get-into-less-the-programmable-stylesheet-language/
My job as a developer to learn how to use this wonderful environment for my application. Actually, it's going to be my first interaction with built-in CSS environment. I hope, it's going to give me less coding work as it used to be.
1. http://getbootstrap.com/customize/
2. http://coding.smashingmagazine.com/2013/03/12/customizing-bootstrap/
3. http://blog.teamtreehouse.com/customize-an-html5-webpage-using-the-bootstrap-framework
4. http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/get-into-less-the-programmable-stylesheet-language/
My job as a developer to learn how to use this wonderful environment for my application. Actually, it's going to be my first interaction with built-in CSS environment. I hope, it's going to give me less coding work as it used to be.
Subscribe to:
Posts (Atom)

