Debian Codegraph @

docs/example-widget-filter-selectmenu.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0 - Filter Widget + jQuery UI Selectmenu</title>
6
7 <!-- jQuery -->
8 <script src="js/jquery-latest.min.js"></script>
9
10 <!-- Demo stuff -->
11 <link class="ui-theme" rel="stylesheet" href="css/jquery-ui.min.css">
12 <script src="js/jquery-ui.min.js"></script>
13 <link rel="stylesheet" href="css/jq.css">
14 <link href="css/prettify.css" rel="stylesheet">
15 <script src="js/prettify.js"></script>
16 <script src="js/docs.js"></script>
17 <style>
18 th { width: 50%; }
19 </style>
20
21 <!-- Tablesorter: required -->
22 <link rel="stylesheet" href="../css/theme.blue.css">
23 <script src="../js/jquery.tablesorter.js"></script>
24 <script src="../js/widgets/widget-filter.js"></script>
25
26 <script id="js">$( function() {
27
28 // modified from http://jqueryui.com/selectmenu/#custom_render
29 $.widget( 'custom.iconselectmenu', $.ui.selectmenu, {
30 _renderItem: function( ul, item ) {
31 var hasClass,
32 li = $( '<li>' ),
33 wrapper = $( "<div>", {
34 // empty strings don't work, pass a &nbsp;
35 text: item.label || '\xA0'
36 });
37 if ( item.disabled ) {
38 li.addClass( 'ui-state-disabled' );
39 }
40 hasClass = item.element.attr( 'data-class' );
41 $( '<span>', {
42 style : item.element.attr( 'data-style' ),
43 'class' : hasClass ? 'ui-icon ' + item.element.attr( 'data-class' ) : ''
44 })
45 .appendTo( wrapper );
46 return li.append( wrapper ).appendTo( ul );
47 }
48 });
49
50 var $table = $( '#table' ),
51 selectmenuClass = 'selectmenu';
52
53 // reinitialize on "updateComplete" just-in-case an "updateAll" was called
54 $table.bind( 'tablesorter-initialized updateComplete', function() {
55 $table
56 .find( '.' + selectmenuClass )
57 .iconselectmenu({
58 change: function() {
59 // start a new search
60 $table.trigger( 'search' );
61 }
62 })
63 .iconselectmenu( 'menuWidget' )
64 .addClass( 'ui-menu-icons customicons' );
65 });
66
67 $table.tablesorter({
68 theme : 'blue',
69 widthFixed : true,
70 widgets : [ 'zebra', 'filter' ],
71 ignoreCase : false,
72 widgetOptions : {
73 // add 'selectmenu' class name to first filter
74 filter_cssFilter: [ selectmenuClass ],
75 filter_selectSource : {
76 0 : [
77 { value : '/\\.js$/', 'data-class' : 'ui-icon-script', text : 'javascript' },
78 { value : '/\\.(jpg|png|gif)$/', 'data-class' : 'ui-icon-image', text : 'Image' },
79 // plain strings are also acceptable - the string is added to both the text & value attribute
80 // 'foobar',
81 { value : '.css', 'data-class' : 'ui-icon-note', text : 'CSS' },
82 { value : '.html', 'data-class' : 'ui-icon-document', text : 'HTML page' },
83 { value : '/\\.(json|txt|md)$/', 'data-class' : 'ui-icon-help', text : 'Misc' }
84 ]
85 }
86 }
87 });
88
89 });</script>
90
91 </head>
92 <body>
93 <div id="banner">
94 <h1>table<em>sorter</em></h1>
95 <h2>Filter Widget + jQuery UI Selectmenu</h2>
96 <h3>Flexible client-side table sorting</h3>
97 <a href="index.html">Back to documentation</a>
98 </div>
99 <div id="main">
100
101 <p class="tip">
102 <em>NOTE!</em>
103 </p>
104 <ul>
105 <li>Updated <span class="version">v2.28.12</span>:
106 <ul>
107 <li>Fix issue with the selectmenu rendering with jQuery UI v1.12.1.</li>
108 <li>Fixed a filter widget issue with regular expression settings being ignored since select filters are set to exactly match the content (modified in <span class="version">v2.25.4</span>)</li>
109 <li><span class="label warning">*NOTE*</span> "filter-match" *must* be added to header since the default select behavior is to exactly match settings and this demo uses a combination of select value using partial matches and regular expressions.</li>
110 </ul>
111 </li>
112 <li>Demo added <span class="version">v2.24.4</span>, to demonstrate how to use <a href="http://jqueryui.com/selectmenu/#custom_render">jQuery UI Selectmenu widget</a> on a filter row select.</li>
113 <li><span class="label warning">*NOTE*</span> - Selectmenu will not work properly in all circumstances:
114 <ul>
115 <li>When an "updateAll" method is triggered on the table, the filter row is removed &amp; replaced due to the possibility of a column being added or removed. Selectmenu initialization will need to be performed again.</li>
116 <li>If using selectmenu along with a widget that constantly removes & rebuilds extra table headers &amp; filter rows (e.g. the scroller widget), the selectmenu initialization will need to be performed again, or just avoid using those widgets.</li>
117 </ul>
118 </li>
119 </ul>
120
121 <h1>Demo</h1>
122
123 <div id="demo">
124 <table id="table" class="tablesorter">
125 <thead>
126 <tr>
127 <th class="filter-select filter-match">File Name</th>
128 <th>Updated</th>
129 </tr>
130 </thead>
131 <tbody>
132 <tr><td>jquery.js</td><td>11/5/2015</td></tr>
133 <tr><td>jquery-ui.js</td><td>11/5/2015</td></tr>
134 <tr><td>map.jpg</td><td>10/22/2015</td></tr>
135 <tr><td>tooltips.js</td><td>8/5/2015</td></tr>
136 <tr><td>jquery-ui.css</td><td>11/5/2015</td></tr>
137 <tr><td>index.html</td><td>11/9/2015</td></tr>
138 <tr><td>smiley.gif</td><td>8/14/2015</td></tr>
139 <tr><td>demo.html</td><td>11/7/2015</td></tr>
140 <tr><td>theme.blue.css</td><td>10/17/2015</td></tr>
141 <tr><td>tablesorter.js</td><td>11/9/2015</td></tr>
142 <tr><td>readme.md</td><td>11/9/2015</td></tr>
143 <tr><td>package.json</td><td>11/8/2015</td></tr>
144 <tr><td>contributions.md</td><td>10/8/2015</td></tr>
145 <tr><td>license.txt</td><td>10/2/2015</td></tr>
146 <tr><td>logo.png</td><td>11/1/2015</td></tr>
147 </tbody>
148 </table></div>
149
150 <h1>Page Header</h1>
151 <div>
152 <pre class="prettyprint lang-html">&lt;!-- jQuery & jQuery UI --&gt;
153 &lt;link rel=&quot;stylesheet&quot; href=&quot;css/jquery-ui.min.css&quot;&gt;
154 &lt;script src=&quot;js/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
155 &lt;script src=&quot;js/jquery-ui.min.js&quot;&gt;&lt;/script&gt;
156
157 &lt;!-- tablesorter plugin --&gt;
158 &lt;link rel=&quot;stylesheet&quot; href=&quot;css/theme.blue.css&quot;&gt;
159 &lt;script src=&quot;js/jquery.tablesorter.js&quot;&gt;&lt;/script&gt;
160
161 &lt;!-- tablesorter filter widget - loaded after the plugin --&gt;
162 &lt;script src=&quot;/js/widgets/widget-filter.js&quot;&gt;&lt;/script&gt;</pre>
163 </div>
164
165 <h1>Javascript</h1>
166 <div id="javascript">
167 <pre class="prettyprint lang-javascript"></pre>
168 </div>
169
170 <h1>HTML</h1>
171 <div id="html">
172 <pre class="prettyprint lang-html"></pre>
173 </div>
174
175 </div>
176
177 </body>
178 </html>