source: main/trunk/greenstone3/web/interfaces/oran/js/jquery-ui-1.8rc1/demos/tabs/manipulation.html@ 24245

Last change on this file since 24245 was 24245, checked in by sjb48, 13 years ago

Oran code for supporting format changes to document.

  • Property svn:executable set to *
File size: 4.3 KB
Line 
1<!doctype html>
2<html lang="en">
3<head>
4 <title>jQuery UI Tabs - Simple manipulation</title>
5 <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
6 <script type="text/javascript" src="../../jquery-1.4.1.js"></script>
7 <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
8 <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
9 <script type="text/javascript" src="../../ui/jquery.ui.button.js"></script>
10 <script type="text/javascript" src="../../ui/jquery.ui.tabs.js"></script>
11 <script type="text/javascript" src="../../ui/jquery.ui.dialog.js"></script>
12 <link type="text/css" href="../demos.css" rel="stylesheet" />
13 <style type="text/css">
14 #dialog label, #dialog input { display:block; }
15 #dialog label { margin-top: 0.5em; }
16 #dialog input, #dialog textarea { width: 95%; }
17 #tabs { margin-top: 1em; }
18 #tabs li .ui-icon-close { float: left; margin: 0.4em 0.2em 0 0; cursor: pointer; }
19 #add_tab { cursor: pointer; }
20 </style>
21 <script type="text/javascript">
22 $(function() {
23 var $tab_title_input = $('#tab_title'), $tab_content_input = $('#tab_content');
24 var tab_counter = 2;
25
26 // tabs init with a custom tab template and an "add" callback filling in the content
27 var $tabs = $('#tabs').tabs({
28 tabTemplate: '<li><a href="#{href}">#{label}</a> <span class="ui-icon ui-icon-close">Remove Tab</span></li>',
29 add: function(event, ui) {
30 var tab_content = $tab_content_input.val() || 'Tab '+tab_counter+' content.';
31 $(ui.panel).append('<p>'+tab_content+'</p>');
32 }
33 });
34
35 // modal dialog init: custom buttons and a "close" callback reseting the form inside
36 var $dialog = $('#dialog').dialog({
37 autoOpen: false,
38 modal: true,
39 buttons: {
40 'Add': function() {
41 addTab();
42 $(this).dialog('close');
43 },
44 'Cancel': function() {
45 $(this).dialog('close');
46 }
47 },
48 open: function() {
49 $tab_title_input.focus();
50 },
51 close: function() {
52 $form[0].reset();
53 }
54 });
55
56 // addTab form: calls addTab function on submit and closes the dialog
57 var $form = $('form',$dialog).submit(function() {
58 addTab();
59 $dialog.dialog('close');
60 return false;
61 });
62
63 // actual addTab function: adds new tab using the title input from the form above
64 function addTab() {
65 var tab_title = $tab_title_input.val() || 'Tab '+tab_counter;
66 $tabs.tabs('add', '#tabs-'+tab_counter, tab_title);
67 tab_counter++;
68 }
69
70 // addTab button: just opens the dialog
71 $('#add_tab')
72 .button()
73 .click(function() {
74 $dialog.dialog('open');
75 });
76
77 // close icon: removing the tab on click
78 // note: closable tabs gonna be an option in the future - see http://dev.jqueryui.com/ticket/3924
79 $('#tabs span.ui-icon-close').live('click', function() {
80 var index = $('li',$tabs).index($(this).parent());
81 $tabs.tabs('remove', index);
82 });
83 });
84 </script>
85</head>
86<body>
87
88<div class="demo">
89
90 <div id="dialog" title="Tab data">
91 <form>
92 <fieldset class="ui-helper-reset">
93 <label for="tab_title">Title</label>
94 <input type="text" name="tab_title" id="tab_title" value="" class="ui-widget-content ui-corner-all" />
95 <label for="tab_content">Content</label>
96 <textarea name="tab_content" id="tab_content" class="ui-widget-content ui-corner-all"></textarea>
97 </fieldset>
98 </form>
99 </div>
100
101 <button id="add_tab">Add Tab</button>
102
103 <div id="tabs">
104 <ul>
105 <li><a href="#tabs-1">Nunc tincidunt</a> <span class="ui-icon ui-icon-close">Remove Tab</span></li>
106 </ul>
107 <div id="tabs-1">
108 <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>
109 </div>
110 </div>
111
112</div><!-- End demo -->
113
114<div class="demo-description">
115 <p>Simple tabs adding and removing.</p>
116</div><!-- End demo-description -->
117
118</body>
119</html>
Note: See TracBrowser for help on using the repository browser.