source: main/trunk/greenstone3/web/interfaces/oran/js/jquery-ui-1.8.15/demos/tabs/manipulation.html@ 24421

Last change on this file since 24421 was 24421, checked in by sjm84, 13 years ago

Adding a new version of jquery

  • Property svn:executable set to *
File size: 4.1 KB
Line 
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>jQuery UI Tabs - Simple manipulation</title>
6 <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
7 <script src="../../jquery-1.6.2.js"></script>
8 <script src="../../ui/jquery.ui.position.js"></script>
9 <script src="../../ui/jquery.ui.core.js"></script>
10 <script src="../../ui/jquery.ui.widget.js"></script>
11 <script src="../../ui/jquery.ui.button.js"></script>
12 <script src="../../ui/jquery.ui.tabs.js"></script>
13 <script src="../../ui/jquery.ui.dialog.js"></script>
14 <link rel="stylesheet" href="../demos.css">
15 <style>
16 #dialog label, #dialog input { display:block; }
17 #dialog label { margin-top: 0.5em; }
18 #dialog input, #dialog textarea { width: 95%; }
19 #tabs { margin-top: 1em; }
20 #tabs li .ui-icon-close { float: left; margin: 0.4em 0.2em 0 0; cursor: pointer; }
21 #add_tab { cursor: pointer; }
22 </style>
23 <script>
24 $(function() {
25 var $tab_title_input = $( "#tab_title"),
26 $tab_content_input = $( "#tab_content" );
27 var tab_counter = 2;
28
29 // tabs init with a custom tab template and an "add" callback filling in the content
30 var $tabs = $( "#tabs").tabs({
31 tabTemplate: "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
32 add: function( event, ui ) {
33 var tab_content = $tab_content_input.val() || "Tab " + tab_counter + " content.";
34 $( ui.panel ).append( "<p>" + tab_content + "</p>" );
35 }
36 });
37
38 // modal dialog init: custom buttons and a "close" callback reseting the form inside
39 var $dialog = $( "#dialog" ).dialog({
40 autoOpen: false,
41 modal: true,
42 buttons: {
43 Add: function() {
44 addTab();
45 $( this ).dialog( "close" );
46 },
47 Cancel: function() {
48 $( this ).dialog( "close" );
49 }
50 },
51 open: function() {
52 $tab_title_input.focus();
53 },
54 close: function() {
55 $form[ 0 ].reset();
56 }
57 });
58
59 // addTab form: calls addTab function on submit and closes the dialog
60 var $form = $( "form", $dialog ).submit(function() {
61 addTab();
62 $dialog.dialog( "close" );
63 return false;
64 });
65
66 // actual addTab function: adds new tab using the title input from the form above
67 function addTab() {
68 var tab_title = $tab_title_input.val() || "Tab " + tab_counter;
69 $tabs.tabs( "add", "#tabs-" + tab_counter, tab_title );
70 tab_counter++;
71 }
72
73 // addTab button: just opens the dialog
74 $( "#add_tab" )
75 .button()
76 .click(function() {
77 $dialog.dialog( "open" );
78 });
79
80 // close icon: removing the tab on click
81 // note: closable tabs gonna be an option in the future - see http://dev.jqueryui.com/ticket/3924
82 $( "#tabs span.ui-icon-close" ).live( "click", function() {
83 var index = $( "li", $tabs ).index( $( this ).parent() );
84 $tabs.tabs( "remove", index );
85 });
86 });
87 </script>
88</head>
89<body>
90
91<div class="demo">
92
93 <div id="dialog" title="Tab data">
94 <form>
95 <fieldset class="ui-helper-reset">
96 <label for="tab_title">Title</label>
97 <input type="text" name="tab_title" id="tab_title" value="" class="ui-widget-content ui-corner-all" />
98 <label for="tab_content">Content</label>
99 <textarea name="tab_content" id="tab_content" class="ui-widget-content ui-corner-all"></textarea>
100 </fieldset>
101 </form>
102 </div>
103
104 <button id="add_tab">Add Tab</button>
105
106 <div id="tabs">
107 <ul>
108 <li><a href="#tabs-1">Nunc tincidunt</a> <span class="ui-icon ui-icon-close">Remove Tab</span></li>
109 </ul>
110 <div id="tabs-1">
111 <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
112 </div>
113 </div>
114
115</div><!-- End demo -->
116
117
118
119<div class="demo-description">
120<p>Simple tabs adding and removing.</p>
121</div><!-- End demo-description -->
122
123</body>
124</html>
Note: See TracBrowser for help on using the repository browser.