# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006- Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. module Redmine module CodesetUtil def self.replace_invalid_utf8(str) return nil if str.nil? str = str.dup str.force_encoding('UTF-8') unless str.valid_encoding? str = str.encode("UTF-16LE", :invalid => :replace, :undef => :replace, :replace => '?').encode("UTF-8") end str end def self.to_utf8(str, encoding) return if str.nil? str = str.b if str.empty? str.force_encoding("UTF-8") return str end enc = encoding.blank? ? "UTF-8" : encoding if enc.casecmp("UTF-8") != 0 str.force_encoding(enc) str = str.encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => '?') else str = replace_invalid_utf8(str) end str end def self.to_utf8_by_setting(str) return if str.nil? str = str.dup self.to_utf8_by_setting_internal(str).force_encoding('UTF-8') end def self.to_utf8_by_setting_internal(str) return if str.nil? str = str.b return str if str.empty? return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match?(str) # for us-ascii str.force_encoding('UTF-8') encodings = Setting.repositories_encodings.split(',').collect(&:strip) encodings.each do |encoding| begin str.force_encoding(encoding) utf8 = str.encode('UTF-8') return utf8 if utf8.valid_encoding? rescue # do nothing here and try the next encoding end end self.replace_invalid_utf8(str).force_encoding('UTF-8') end def self.from_utf8(str, encoding) return if str.nil? str = str.dup str ||= '' str.force_encoding('UTF-8') if encoding.casecmp('UTF-8') != 0 str = str.encode(encoding, :invalid => :replace, :undef => :replace, :replace => '?') else str = self.replace_invalid_utf8(str) end end def self.guess_encoding(str) return if str.nil? str = str.dup encodings = Setting.repositories_encodings.split(',').collect(&:strip) encodings = encodings.presence || ['UTF-8'] encodings.each do |encoding| begin str.force_encoding(encoding) rescue Encoding::ConverterNotFoundError # ignore if the encoding name is invalid end return encoding if str.valid_encoding? end nil end end end 6825cb4d3dc9fb477b41204fac46b13c'>treecommitdiffstats
path: root/demos/index.html
blob: 270372e048afee950fcf92aa97aff8af64575d83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<!doctype html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>jQuery UI Demos</title>
	<link type="text/css" href="../themes/base/ui.all.css" rel="stylesheet" />
	<link type="text/css" href="demos.css" rel="stylesheet" />
	<script type="text/javascript" src="../jquery-1.3.1.js"></script>
	<script type="text/javascript" src="../external/bgiframe/jquery.bgiframe.js"></script>
	<script type="text/javascript" src="../ui/ui.core.js"></script>
	<script type="text/javascript" src="../ui/ui.accordion.js"></script>
	<script type="text/javascript" src="../ui/ui.datepicker.js"></script>
	<script type="text/javascript" src="../ui/ui.dialog.js"></script>
	<script type="text/javascript" src="../ui/ui.draggable.js"></script>
	<script type="text/javascript" src="../ui/ui.droppable.js"></script>
	<script type="text/javascript" src="../ui/ui.progressbar.js"></script>
	<script type="text/javascript" src="../ui/ui.resizable.js"></script>
	<script type="text/javascript" src="../ui/ui.selectable.js"></script>
	<script type="text/javascript" src="../ui/ui.slider.js"></script>
	<script type="text/javascript" src="../ui/ui.sortable.js"></script>
	<script type="text/javascript" src="../ui/ui.tabs.js"></script>
	<script type="text/javascript" src="../ui/effects.core.js"></script>
	<script type="text/javascript" src="../ui/effects.blind.js"></script>
	<script type="text/javascript" src="../ui/effects.bounce.js"></script>
	<script type="text/javascript" src="../ui/effects.clip.js"></script>
	<script type="text/javascript" src="../ui/effects.drop.js"></script>
	<script type="text/javascript" src="../ui/effects.explode.js"></script>
	<script type="text/javascript" src="../ui/effects.fold.js"></script>
	<script type="text/javascript" src="../ui/effects.highlight.js"></script>
	<script type="text/javascript" src="../ui/effects.pulsate.js"></script>
	<script type="text/javascript" src="../ui/effects.scale.js"></script>
	<script type="text/javascript" src="../ui/effects.shake.js"></script>
	<script type="text/javascript" src="../ui/effects.slide.js"></script>
	<script type="text/javascript" src="../ui/effects.transfer.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-ar.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-bg.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-ca.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-cs.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-da.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-de.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-el.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-eo.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-es.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-fa.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-fi.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-fr.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-he.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-hr.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-hu.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-hy.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-id.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-is.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-it.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-ja.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-ko.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-lt.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-lv.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-ms.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-nl.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-no.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-pl.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-pt-BR.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-ro.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-ru.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-sk.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-sl.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-sq.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-sv.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-th.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-tr.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-uk.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-zh-CN.js"></script>
	<script type="text/javascript" src="../ui/i18n/ui.datepicker-zh-TW.js"></script>
	<script type="text/javascript">
	jQuery(function($) {
		
		$('.left-nav a').click(function(ev) {
			window.location.hash = this.href.replace(/.+\/([^\/]+)\/index\.html/,'$1') + '|default';
			loadPage(this.href);
			$('.left-nav a.selected').removeClass('selected');
			$(this).addClass('selected');
			ev.preventDefault();
		});
		
		if (window.location.hash) {
			if (window.location.hash.indexOf('|') === -1) {
				window.location.hash += '|default';	
			}			
			var path = window.location.href.replace(/(index\.html)?#/,'');
			path = path.replace('\|','/') + '.html';
			loadPage(path);
		}		

		function loadPage(path) {			
			var section = path.replace(/\/[^\/]+\.html/,'');
			var header = section.replace(/.+\/([^\/]+)/,'$1').replace(/_/, ' ');
			
			$('td.normal div.normal')
				.empty()
				.append('<h4 class="demo-subheader">Functional demo:</h4>')
				.append('<h3 class="demo-header">'+ header +'</h3>')
				.append('<div id="demo-config"></div>')
				.find('#demo-config')
					.append('<div id="demo-frame"></div><div id="demo-config-menu"></div><div id="demo-link"><a class="demoWindowLink" href="#"><span class="ui-icon ui-icon-newwin"></span>Open demo in a new window</a></div>')
					.find('#demo-config-menu')
						.load(section + '/index.html .demos-nav', function() {
							$('#demo-config-menu a').each(function() {
								this.setAttribute('href', section + '/' + this.getAttribute('href').replace(/.+\/([^\/]+)/,'$1'));
								$(this).attr('target', 'demo-frame');
								$(this).click(function() {

									resetDemos();
									
									$(this).parents('ul').find('li').removeClass('demo-config-on');
									$(this).parent().addClass('demo-config-on');
									$('#demo-notes').fadeOut();

									//Set the hash to the actual page without ".html"
									window.location.hash = header + '|' + this.getAttribute('href').match((/\/([^\/\\]+)\.html/))[1];

									loadDemo(this.getAttribute('href'));

									return false;
								});
							});

							if (window.location.hash) {
								var demo = window.location.hash.split('|')[1];
								$('#demo-config-menu a').each(function(){
									if (this.href.indexOf(demo + '.html') !== -1) {
										$(this).parents('ul').find('li').removeClass('demo-config-on');
										$(this).parent().addClass('demo-config-on');									
										loadDemo(this.href);										
									}
								});
							}

							updateDemoNotes();
						})
					.end()
					.find('#demo-link a')
						.bind('click', function(ev){
							window.open(this.href);
							ev.preventDefault();
						})
					.end()
				.end()
			;
			
			resetDemos();
		}
				
		function loadDemo(path) {
			var directory = path.match(/([^\/]+)\/[^\/\.]+\.html$/)[1];
			$.get(path, function(data) {
				var source = data;
				data = data.replace(/<script.*>.*<\/script>/ig,""); // Remove script tags
				data = data.replace(/<\/?link.*>/ig,""); //Remove link tags
				data = data.replace(/<\/?html.*>/ig,""); //Remove html tag
				data = data.replace(/<\/?body.*>/ig,""); //Remove body tag
				data = data.replace(/<\/?head.*>/ig,""); //Remove head tag
				data = data.replace(/<\/?!doctype.*>/ig,""); //Remove doctype
				data = data.replace(/<title.*>.*<\/title>/ig,""); // Remove title tags
				data = data.replace(/((href|src)=["'])(?!(http|#))/ig, "$1" + directory + "/");

				$('#demo-style').remove();
				$('#demo-frame').empty().html(data);
				$('#demo-frame style').clone().appendTo('head').attr('id','demo-style');
				$('#demo-link a').attr('href', path);
				updateDemoNotes();
				updateDemoSource(source);
				
				if (/default.html$/.test(path)) {
					$.get("documentation/docs-" + path.match(/demos\/(.+)\//)[1] + ".html", function(html) {
						$("#demo-source").after(html);
						$("#widget-docs").tabs();
						$(".param-header").click(function() {
							$(this).parent().toggleClass("param-open").end().next().toggle();
						});
						$(".docs-list-header").each(function() {
							var header = $(this);
							var details = header.next().find(".param-details").hide();
							$("a:first", header).click(function() {
								details.show().parent().addClass("param-open");
								return false;
							});
							$("a:last", header).click(function() {
								details.hide().parent().removeClass("param-open");
								return false;
							});
						});
					});
				}
			});
		}

		function updateDemoNotes() {
			var notes = $('#demo-frame .demo-description');
			if ($('#demo-notes').length == 0) {
				$('<div id="demo-notes"></div>').insertAfter('#demo-config');
			}
			$('#demo-notes').hide().empty().html(notes.html());
			$('#demo-notes').show();
			notes.hide();
		}
		
		function updateDemoSource(source) {
			if ($('#demo-source').length == 0) {
				$('<div id="demo-source"><a href="#" class="source-closed">View Source</a><div><pre><code></code></pre></div></div>').insertAfter('#demo-notes');
				$('#demo-source').find(">a").click(function() {
					$(this).toggleClass("source-closed").toggleClass("source-open").next().toggle();
					return false;
				}).end().find(">div").hide();
			}
			var cleanedSource = source
				.replace('themes/base/ui.all.css', 'theme/ui.all.css')
				.replace(/\s*\x3Clink.*demos\x2Ecss.*\x3E\s*/, '\r\n\t')
				.replace(/\x2E\x2E\x2F\x2E\x2E\x2F/g, '');

			$('#demo-source code').empty().text(cleanedSource);
		}
		
		function resetDemos() {
			$.datepicker.setDefaults($.extend({showMonthAfterYear: false}, $.datepicker.regional['']));
			$(".ui-dialog-content").remove();			
		}
				
	});
	</script>
</head>
<body>

<table class="layout-grid" cellspacing="0" cellpadding="0">
	<tr>
		<td class="left-nav">
			<dl class="demos-nav">
				<dt>Interactions</dt>
					<dd><a href="draggable/index.html">Draggable</a></dd>
					<dd><a href="droppable/index.html">Droppable</a></dd>
					<dd><a href="resizable/index.html">Resizable</a></dd>
					<dd><a href="selectable/index.html">Selectable</a></dd>
					<dd><a href="sortable/index.html">Sortable</a></dd>
				<dt>Widgets</dt>
					<dd><a href="accordion/index.html">Accordion</a></dd>
					<dd><a href="datepicker/index.html">Datepicker</a></dd>
					<dd><a href="dialog/index.html">Dialog</a></dd>
					<dd><a href="progressbar/index.html">Progressbar</a></dd>
					<dd><a href="slider/index.html">Slider</a></dd>
					<dd><a href="tabs/index.html">Tabs</a></dd>
					
					<dt>Effects</dt>
					<dd><a href="effects_general/index.html">General</a></dd>
					<dd><a href="effects_showhide/index.html">Show/Hide</a></dd>

				<!-- Add back in when 1.6 final is released
				<dt>Effects</dt>
					<dd><a href="http://ui.jquery.com/docs/Effects/Methods">Effect Methods</dd>
					<dd><a href="http://ui.jquery.com/docs/Effects/Types">Effect Types</a></dd>
				<dt>About jQuery UI</dt>
					<dd><a href="http://ui.jquery.com/docs/Developer_Guide">UI Developer Guidelines</a></dd>
					<dd><a href="http://ui.jquery.com/docs/Changelog">Changelog</a></dd>
					<dd><a href="http://ui.jquery.com/docs/Roadmap">Roadmap</a></dd>
					<dd><a href="http://ui.jquery.com/docs/Subversion">Subversion Access</a></dd>
				<dt>Theming</dt>
					<dd><a href="http://ui.jquery.com/docs/Theming">Theming jQuery UI</a></dd>
					<dd><a href="http://ui.jquery.com/docs/Theming/API">jQuery UI CSS framework</a></dd>
					<dd><a href="http://ui.jquery.com/docs/Theming/Themeroller">ThemeRoller application</a></dd>
					<dd><a href="http://ui.jquery.com/docs/Theming/ThemeSwitcher">Theme Switcher Widget</a></dd>
					-->
			</dl>
		</td>
		<td class="normal">

			<div class="normal">

					<h3>Instructions</h3>
					<p>
						These demos showcase some common uses of each jQuery UI plugin. Simply copy and paste code from the demos to get started. Have fun playing with them.
					</p>
				
			</div>

		</td>
	</tr>
</table>
</body>
</html>