/ Published in: JavaScript
This is a simple tabbed content setup with a little CSS supplied for styling and proof of concept. Each "div" inside the "navBar" element has it's own unique ID, and that tab's respective content should have an ID of it's tab's ID plus "_data". For Example:
tab id: generalData tab's content's id: generalData_data
this uses the Prototype/Scriptaculous framework and is required to run.
Expand |
Embed | Plain Text
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Add/Edit Job</title> <script type="text/javascript" src="lib/prototype.js"></script> <script type="text/javascript" src="lib/scriptaculous.js"></script> <script type="text/javascript"> <!-- var fordmJobs = { tabContainerID: "navBar", tabs: new Array(), initialize: function() { }, createTabs: function() { var classObject = this; this.tabs = $$("#navBar div"); this.tabs.each(function(el) { Event.observe($(el), "click", function() { classObject.switchTab(el); }); }); this.switchTab($(this.tabs[0])); }, switchTab: function(tab) { content = $(tab.id + "_data"); if (content) { this.tabs.pluck("id").each(function(elid) { $(elid).className = ""; $(elid + "_data").hide(); }); tab.className = "activeTab"; content.show(); } else {} } }; document.observe("dom:loaded", function() { fordmJobs.createTabs(); }); --> </script> <style type="text/css"> <!-- .header { font-size: 24px; text-align: right; padding-right: 100px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #3399CC; color: #3399FF; margin-bottom: 20px; } .navBar div { display: inline; margin-right: 5px; margin-left: 5px; background-color: #DEDEDE; padding-right: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #666666; border-right-color: #666666; border-bottom-color: #3399CC; border-left-color: #666666; cursor: pointer; } .navBar .activeTab { background-color: #BCBCBC; font-weight: bold; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #BCBCBC; } .navBar { border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #3399CC; margin-bottom: 20px; } .jobEntity .title { font-weight: bold; float: left; width: 100px; text-align: right; margin-right: 20px; } .jobEntity .data { } .jobEntity { margin-left: 50px; display: block; margin-bottom: 15px; } .container { margin-right: auto; margin-left: auto; width: 600px; border: 3px double #3399CC; } .navBar div:hover { background-color: #CECECE; cursor: pointer; } --> </style> </head> <body> <div class="container"> <div class="header">Create A Job</div> <div class="navBar" id="navBar"> <div id="e0">Required</div> <div id="e1">Properties</div> <div id="e2">Transformations</div> </div> <div id="e0_data">Required Fields </div> <div id="e1_data">Properties Fields</div> <div id="e2_data">Transformation Fields</div> </div> </body> </html>
You need to login to post a comment.
