Hi,
I'm creating a simple page showing 3-4 tabs. Implemented jquery Sortable to sort the tabs and jEditable for edit the tab name in place.
The script works but acts a little strangely in Firefox. If I double click on my editable span it will be replaced with the input field. It will then disappear if I focus on some other element EXCEPT another editable span.
Here, is the page script
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TabExample1.aspx.cs" Inherits="TabStrip.TabExample1" %>
<!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">
<head runat="server">
<title></title>
<style type="text/css">
.tab_container
{
border: 1px solid #999;
border-top: none;
overflow: hidden;
clear: both;
float: left;
width: 100%;
background: #fff;
}
.tab_content
{
padding: 20px;
font-size: 1.2em;
}
ul.tabs
{
margin: 0;
padding: 0;
float: left;
list-style: none;
height: 32px; /*--Set height of tabs--*/
border-bottom: 1px solid #999;
border-left: 1px solid #999;
width: 100%;
}
ul.tabs li
{
float: left;
margin: 0;
padding: 0;
height: 31px; /*--Subtract 1px from the height of the unordered list--*/
line-height: 31px; /*--Vertically aligns the text within the tab--*/
border: 1px solid #999;
border-left: none;
margin-bottom: -1px; /*--Pull the list item down 1px--*/
overflow: hidden;
position: relative;
background: #e0e0e0;
}
ul.tabs li a
{
text-decoration: none;
color: #000;
display: block;
font-size: 1.2em;
padding: 0 20px;
border: 1px solid #fff; /*--Gives the bevel look with a 1px white border inside the list item--*/
outline: none;
}
ul.tabs li a:hover
{
background: #ccc;
}
html ul.tabs li.active, html ul.tabs li.active a:hover
{
/*--Makes sure that the active tab does not listen to the hover properties--*/
background: #fff;
border-bottom: 1px solid #fff; /*--Makes the active tab look like it's connected with its content--*/
}
</style>
<link type="text/css" href="jquery-ui-1.8.1.custom.css" rel="stylesheet" />
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.8.custom.min.js"></script>
<script src="jquery.jeditable.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$('.edit').editable(function(value, settings) {
return value;
}, {
type: 'text',
event: 'dblclick',
width: '70px',
onblur: 'cancel'
});
$("#sortable").sortable({
items: 'li:not(.ui-add-tab)'
});
//When page loads...
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active ID content
return false;
});
});
</script>
</head>
<body>
<ul id="sortable" class="tabs">
<li class="ui-state-default"><a class="edit" href="#tab1">Tab1</a>a</li>
<li class="ui-state-default"><a class="edit" href="#tab2">Tab2</a>a</li>
<li class="ui-state-default"><a class="edit" href="#tab3">Tab3</a>a</li>
<li class="ui-state-default"><a class="edit" href="#tab4">Tab4</a>a</li>
<li class="ui-add-tab"><a href="#addtab">Add Tab</a></li>
</ul>
</body>
</html>