Commit 6ed3d3407c74ad6d9f12063e4056483743c97907
1 parent
b46e14b5
Exists in
master
and in
7 other branches
incluida a biblioteca richdraw para criação de figuras geométricas via SVG ou VML
Showing
19 changed files
with
2316 additions
and
0 deletions
Show diff stats
918 Bytes
... | ... | @@ -0,0 +1,126 @@ |
1 | +<?php | |
2 | +/* | |
3 | +Title: Compacta js e css do diretório pacotes/richdraw | |
4 | + | |
5 | +Compacta os arquivos js utilizados pelo I3Geo. | |
6 | + | |
7 | +Deve ser executado sempre que forem feitas alterações nos arquivos javascript existentes em classesjs ou nos arquivos de estilo existentes em css. | |
8 | + | |
9 | +About: Licença | |
10 | + | |
11 | +I3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
12 | + | |
13 | +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
14 | +Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br | |
15 | + | |
16 | +Este programa é software livre; você pode redistribuí-lo | |
17 | +e/ou modificá-lo sob os termos da Licença Pública Geral | |
18 | +GNU conforme publicada pela Free Software Foundation; | |
19 | +tanto a versão 2 da Licença. | |
20 | +Este programa é distribuído na expectativa de que seja útil, | |
21 | +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
22 | +de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | |
23 | +Consulte a Licença Pública Geral do GNU para mais detalhes. | |
24 | +Você deve ter recebido uma cópia da Licença Pública Geral do | |
25 | +GNU junto com este programa; se não, escreva para a | |
26 | +Free Software Foundation, Inc., no endereço | |
27 | +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
28 | + | |
29 | +File: compactajs.php | |
30 | + | |
31 | +19/7/2007 | |
32 | + | |
33 | +*/ | |
34 | +// | |
35 | +//compacta os arquivos do i3geo | |
36 | +//gera um arquivo compactado para cada um | |
37 | +// | |
38 | +//packer("prototype.js","prototype_compacto.js","High ASCII"); | |
39 | +packer("richdraw.js","richdraw_compacto.js","High ASCII"); | |
40 | +packer("svgrenderer.js","svgrenderer_compacto.js","High ASCII"); | |
41 | +packer("vmlrenderer.js","vmlrenderer_compacto.js","High ASCII"); | |
42 | +//packer("prototype.js","prototype_compacto.js","High ASCII"); | |
43 | + | |
44 | +$s = inicia("prototype.js"); | |
45 | +$abre = fopen("prototype_compacto.js", "wt"); | |
46 | +$escreve = fwrite ($abre,$s); | |
47 | +$fecha = fclose ($abre); | |
48 | + | |
49 | +// | |
50 | +//gera um único js | |
51 | +// | |
52 | +$jsfiles = array( | |
53 | +"richdraw_compacto.js", | |
54 | +"svgrenderer_compacto.js", | |
55 | +"vmlrenderer_compacto.js" | |
56 | +); | |
57 | +$buffer = ""; | |
58 | +//junta todos os js em um unico | |
59 | +foreach ($jsfiles as $f) | |
60 | +{ | |
61 | + $abre = fopen($f, "r"); | |
62 | + while (!feof($abre)) | |
63 | + {$buffer .= fgets($abre);} | |
64 | + fclose($abre); | |
65 | + $buffer .= "\n"; | |
66 | +} | |
67 | +$abre = fopen("richdraw_tudo_compacto.js", "wt"); | |
68 | +$escreve = fwrite ($abre,$buffer); | |
69 | +$fecha = fclose ($abre); | |
70 | +chmod("richdraw_tudo_compacto.js",0777); | |
71 | +function packer($src,$out,$tipo="None") | |
72 | +{ | |
73 | +//packer | |
74 | +//$src = 'temp.js'; | |
75 | +//$out = 'i3geo_tudo_compacto.js'; | |
76 | +require_once '../../classesjs/packer/class.JavaScriptPacker.php'; | |
77 | +$script = file_get_contents($src); | |
78 | +$t1 = microtime(true); | |
79 | +$packer = new JavaScriptPacker($script, $tipo, true, false); | |
80 | +$packed = $packer->pack(); | |
81 | +$t2 = microtime(true); | |
82 | +$time = sprintf('%.4f', ($t2 - $t1) ); | |
83 | +echo 'script ', $src, ' packed in ' , $out, ', in ', $time, ' s.', "\n"; | |
84 | +file_put_contents($out, $packed); | |
85 | +chmod($out,0777); | |
86 | +} | |
87 | +function inicia($arquivo) | |
88 | +{ | |
89 | + $abre = fopen($arquivo, "r"); | |
90 | + while (!feof($abre)) | |
91 | + { | |
92 | + $buffer = fgets($abre); | |
93 | + $maparray[] = $buffer."kkkk"; | |
94 | + } | |
95 | + fclose($abre); | |
96 | + $c = compress(implode("",$maparray)); | |
97 | + $c = str_replace("kkkk","\n",$c); | |
98 | + $c = str_replace("kkk","",$c); | |
99 | + $c = str_replace(";\n",";",$c); | |
100 | + $c = str_replace("{\n","{",$c); | |
101 | + $c = str_replace("\n}","}",$c); | |
102 | + $c = str_replace(")\n",")",$c); | |
103 | + $c = str_replace(" \n","",$c); | |
104 | + $c = str_replace("\n}","}\n",$c); | |
105 | + return $c; | |
106 | +} | |
107 | +function compress($code) | |
108 | +{ // Remove multiline comment | |
109 | +$mlcomment = '/\/\*(?!-)[\x00-\xff]*?\*\//'; | |
110 | +$code = preg_replace($mlcomment,"",$code); | |
111 | + | |
112 | +// Remove single line comment | |
113 | +$slcomment = '/[^:]\/\/.*/'; | |
114 | +$code = preg_replace($slcomment,"",$code); | |
115 | + | |
116 | +// Remove extra spaces | |
117 | +$extra_space = '/\s+/'; | |
118 | +$code = preg_replace($extra_space," ",$code); | |
119 | + | |
120 | +// Remove spaces that can be removed | |
121 | +$removable_space = '/\s?([\{\};\=\(\)\\\/\+\*-])\s?/'; | |
122 | +$code = preg_replace('/\s?([\{\};\=\(\)\/\+\*-])\s?/',"\\1",$code); | |
123 | +return $code; | |
124 | +} | |
125 | + | |
126 | +?> | |
0 | 127 | \ No newline at end of file | ... | ... |
955 Bytes
864 Bytes
... | ... | @@ -0,0 +1,1118 @@ |
1 | +/* Prototype JavaScript framework, version 1.4.0 | |
2 | + * (c) 2005 Sam Stephenson <sam@conio.net> | |
3 | + * | |
4 | + * THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff | |
5 | + * against the source tree, available from the Prototype darcs repository. | |
6 | + * | |
7 | + * Prototype is freely distributable under the terms of an MIT-style license. | |
8 | + * | |
9 | + * For details, see the Prototype web site: http://prototype.conio.net/ | |
10 | + * | |
11 | +/*--------------------------------------------------------------------------*/ | |
12 | + | |
13 | +var Prototype = { | |
14 | + Version: '1.4.0', | |
15 | + ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', | |
16 | + | |
17 | + emptyFunction: function() {}, | |
18 | + K: function(x) {return x} | |
19 | +}; | |
20 | + | |
21 | +var Class = { | |
22 | + create: function() { | |
23 | + return function() { | |
24 | + this.initialize.apply(this, arguments); | |
25 | + } | |
26 | + } | |
27 | +}; | |
28 | + | |
29 | +var Abstract = new Object(); | |
30 | + | |
31 | +Object.extend = function(destination, source) { | |
32 | + for (property in source) { | |
33 | + destination[property] = source[property]; | |
34 | + } | |
35 | + return destination; | |
36 | +}; | |
37 | + | |
38 | +Object.inspect = function(object) { | |
39 | + try { | |
40 | + if (object == undefined) return 'undefined'; | |
41 | + if (object == null) return 'null'; | |
42 | + return object.inspect ? object.inspect() : object.toString(); | |
43 | + } catch (e) { | |
44 | + if (e instanceof RangeError) return '...'; | |
45 | + throw e; | |
46 | + } | |
47 | +}; | |
48 | + | |
49 | +Function.prototype.bind = function() { | |
50 | + var __method = this, args = $A(arguments), object = args.shift(); | |
51 | + return function() { | |
52 | + return __method.apply(object, args.concat($A(arguments))); | |
53 | + } | |
54 | +}; | |
55 | + | |
56 | +Function.prototype.bindAsEventListener = function(object) { | |
57 | + var __method = this; | |
58 | + return function(event) { | |
59 | + return __method.call(object, event || window.event); | |
60 | + } | |
61 | +}; | |
62 | + | |
63 | +Object.extend(Number.prototype, { | |
64 | + toColorPart: function() { | |
65 | + var digits = this.toString(16); | |
66 | + if (this < 16) return '0' + digits; | |
67 | + return digits; | |
68 | + }, | |
69 | + | |
70 | + succ: function() { | |
71 | + return this + 1; | |
72 | + }, | |
73 | + | |
74 | + times: function(iterator) { | |
75 | + $R(0, this, true).each(iterator); | |
76 | + return this; | |
77 | + } | |
78 | +}); | |
79 | + | |
80 | +var Try = { | |
81 | + these: function() { | |
82 | + var returnValue; | |
83 | + | |
84 | + for (var i = 0; i < arguments.length; i++) { | |
85 | + var lambda = arguments[i]; | |
86 | + try { | |
87 | + returnValue = lambda(); | |
88 | + break; | |
89 | + } catch (e) {} | |
90 | + } | |
91 | + | |
92 | + return returnValue; | |
93 | + } | |
94 | +}; | |
95 | + | |
96 | +/*--------------------------------------------------------------------------*/ | |
97 | + | |
98 | +function $() { | |
99 | + var elements = new Array(); | |
100 | + | |
101 | + for (var i = 0; i < arguments.length; i++) { | |
102 | + var element = arguments[i]; | |
103 | + if (typeof element == 'string') | |
104 | + element = document.getElementById(element); | |
105 | + | |
106 | + if (arguments.length == 1) | |
107 | + return element; | |
108 | + | |
109 | + elements.push(element); | |
110 | + } | |
111 | + | |
112 | + return elements; | |
113 | +} | |
114 | +Object.extend(String.prototype, { | |
115 | + stripTags: function() { | |
116 | + return this.replace(/<\/?[^>]+>/gi, ''); | |
117 | + }, | |
118 | + | |
119 | + stripScripts: function() { | |
120 | + return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); | |
121 | + }, | |
122 | + | |
123 | + extractScripts: function() { | |
124 | + var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); | |
125 | + var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); | |
126 | + return (this.match(matchAll) || []).map(function(scriptTag) { | |
127 | + return (scriptTag.match(matchOne) || ['', ''])[1]; | |
128 | + }); | |
129 | + }, | |
130 | + | |
131 | + evalScripts: function() { | |
132 | + return this.extractScripts().map(eval); | |
133 | + }, | |
134 | + | |
135 | + escapeHTML: function() { | |
136 | + var div = document.createElement('div'); | |
137 | + var text = document.createTextNode(this); | |
138 | + div.appendChild(text); | |
139 | + return div.innerHTML; | |
140 | + }, | |
141 | + | |
142 | + unescapeHTML: function() { | |
143 | + var div = document.createElement('div'); | |
144 | + div.innerHTML = this.stripTags(); | |
145 | + return div.childNodes[0] ? div.childNodes[0].nodeValue : ''; | |
146 | + }, | |
147 | + | |
148 | + toQueryParams: function() { | |
149 | + var pairs = this.match(/^\??(.*)$/)[1].split('&'); | |
150 | + return pairs.inject({}, function(params, pairString) { | |
151 | + var pair = pairString.split('='); | |
152 | + params[pair[0]] = pair[1]; | |
153 | + return params; | |
154 | + }); | |
155 | + }, | |
156 | + | |
157 | + toArray: function() { | |
158 | + return this.split(''); | |
159 | + }, | |
160 | + | |
161 | + camelize: function() { | |
162 | + var oStringList = this.split('-'); | |
163 | + if (oStringList.length == 1) return oStringList[0]; | |
164 | + | |
165 | + var camelizedString = this.indexOf('-') == 0 | |
166 | + ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) | |
167 | + : oStringList[0]; | |
168 | + | |
169 | + for (var i = 1, len = oStringList.length; i < len; i++) { | |
170 | + var s = oStringList[i]; | |
171 | + camelizedString += s.charAt(0).toUpperCase() + s.substring(1); | |
172 | + } | |
173 | + | |
174 | + return camelizedString; | |
175 | + }, | |
176 | + | |
177 | + inspect: function() { | |
178 | + return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'"; | |
179 | + } | |
180 | +}); | |
181 | + | |
182 | +String.prototype.parseQuery = String.prototype.toQueryParams; | |
183 | + | |
184 | +var $break = new Object(); | |
185 | +var $continue = new Object(); | |
186 | + | |
187 | +var Enumerable = { | |
188 | + each: function(iterator) { | |
189 | + var index = 0; | |
190 | + try { | |
191 | + this._each(function(value) { | |
192 | + try { | |
193 | + iterator(value, index++); | |
194 | + } catch (e) { | |
195 | + if (e != $continue) throw e; | |
196 | + } | |
197 | + }); | |
198 | + } catch (e) { | |
199 | + if (e != $break) throw e; | |
200 | + } | |
201 | + }, | |
202 | + | |
203 | + all: function(iterator) { | |
204 | + var result = true; | |
205 | + this.each(function(value, index) { | |
206 | + result = result && !!(iterator || Prototype.K)(value, index); | |
207 | + if (!result) throw $break; | |
208 | + }); | |
209 | + return result; | |
210 | + }, | |
211 | + | |
212 | + any: function(iterator) { | |
213 | + var result = true; | |
214 | + this.each(function(value, index) { | |
215 | + if (result = !!(iterator || Prototype.K)(value, index)) | |
216 | + throw $break; | |
217 | + }); | |
218 | + return result; | |
219 | + }, | |
220 | + | |
221 | + collect: function(iterator) { | |
222 | + var results = []; | |
223 | + this.each(function(value, index) { | |
224 | + results.push(iterator(value, index)); | |
225 | + }); | |
226 | + return results; | |
227 | + }, | |
228 | + | |
229 | + detect: function (iterator) { | |
230 | + var result; | |
231 | + this.each(function(value, index) { | |
232 | + if (iterator(value, index)) { | |
233 | + result = value; | |
234 | + throw $break; | |
235 | + } | |
236 | + }); | |
237 | + return result; | |
238 | + }, | |
239 | + | |
240 | + findAll: function(iterator) { | |
241 | + var results = []; | |
242 | + this.each(function(value, index) { | |
243 | + if (iterator(value, index)) | |
244 | + results.push(value); | |
245 | + }); | |
246 | + return results; | |
247 | + }, | |
248 | + | |
249 | + grep: function(pattern, iterator) { | |
250 | + var results = []; | |
251 | + this.each(function(value, index) { | |
252 | + var stringValue = value.toString(); | |
253 | + if (stringValue.match(pattern)) | |
254 | + results.push((iterator || Prototype.K)(value, index)); | |
255 | + }); | |
256 | + return results; | |
257 | + }, | |
258 | + | |
259 | + include: function(object) { | |
260 | + var found = false; | |
261 | + this.each(function(value) { | |
262 | + if (value == object) { | |
263 | + found = true; | |
264 | + throw $break; | |
265 | + } | |
266 | + }); | |
267 | + return found; | |
268 | + }, | |
269 | + | |
270 | + inject: function(memo, iterator) { | |
271 | + this.each(function(value, index) { | |
272 | + memo = iterator(memo, value, index); | |
273 | + }); | |
274 | + return memo; | |
275 | + }, | |
276 | + | |
277 | + invoke: function(method) { | |
278 | + var args = $A(arguments).slice(1); | |
279 | + return this.collect(function(value) { | |
280 | + return value[method].apply(value, args); | |
281 | + }); | |
282 | + }, | |
283 | + | |
284 | + max: function(iterator) { | |
285 | + var result; | |
286 | + this.each(function(value, index) { | |
287 | + value = (iterator || Prototype.K)(value, index); | |
288 | + if (value >= (result || value)) | |
289 | + result = value; | |
290 | + }); | |
291 | + return result; | |
292 | + }, | |
293 | + | |
294 | + min: function(iterator) { | |
295 | + var result; | |
296 | + this.each(function(value, index) { | |
297 | + value = (iterator || Prototype.K)(value, index); | |
298 | + if (value <= (result || value)) | |
299 | + result = value; | |
300 | + }); | |
301 | + return result; | |
302 | + }, | |
303 | + | |
304 | + partition: function(iterator) { | |
305 | + var trues = [], falses = []; | |
306 | + this.each(function(value, index) { | |
307 | + ((iterator || Prototype.K)(value, index) ? | |
308 | + trues : falses).push(value); | |
309 | + }); | |
310 | + return [trues, falses]; | |
311 | + }, | |
312 | + | |
313 | + pluck: function(property) { | |
314 | + var results = []; | |
315 | + this.each(function(value, index) { | |
316 | + results.push(value[property]); | |
317 | + }); | |
318 | + return results; | |
319 | + }, | |
320 | + | |
321 | + reject: function(iterator) { | |
322 | + var results = []; | |
323 | + this.each(function(value, index) { | |
324 | + if (!iterator(value, index)) | |
325 | + results.push(value); | |
326 | + }); | |
327 | + return results; | |
328 | + }, | |
329 | + | |
330 | + sortBy: function(iterator) { | |
331 | + return this.collect(function(value, index) { | |
332 | + return {value: value, criteria: iterator(value, index)}; | |
333 | + }).sort(function(left, right) { | |
334 | + var a = left.criteria, b = right.criteria; | |
335 | + return a < b ? -1 : a > b ? 1 : 0; | |
336 | + }).pluck('value'); | |
337 | + }, | |
338 | + | |
339 | + toArray: function() { | |
340 | + return this.collect(Prototype.K); | |
341 | + }, | |
342 | + | |
343 | + zip: function() { | |
344 | + var iterator = Prototype.K, args = $A(arguments); | |
345 | + if (typeof args.last() == 'function') | |
346 | + iterator = args.pop(); | |
347 | + | |
348 | + var collections = [this].concat(args).map($A); | |
349 | + return this.map(function(value, index) { | |
350 | + iterator(value = collections.pluck(index)); | |
351 | + return value; | |
352 | + }); | |
353 | + }, | |
354 | + | |
355 | + inspect: function() { | |
356 | + return '#<Enumerable:' + this.toArray().inspect() + '>'; | |
357 | + } | |
358 | +}; | |
359 | + | |
360 | +Object.extend(Enumerable, { | |
361 | + map: Enumerable.collect, | |
362 | + find: Enumerable.detect, | |
363 | + select: Enumerable.findAll, | |
364 | + member: Enumerable.include, | |
365 | + entries: Enumerable.toArray | |
366 | +}); | |
367 | +var $A = Array.from = function(iterable) { | |
368 | + if (!iterable) return []; | |
369 | + if (iterable.toArray) { | |
370 | + return iterable.toArray(); | |
371 | + } else { | |
372 | + var results = []; | |
373 | + for (var i = 0; i < iterable.length; i++) | |
374 | + results.push(iterable[i]); | |
375 | + return results; | |
376 | + } | |
377 | +}; | |
378 | + | |
379 | +Object.extend(Array.prototype, Enumerable); | |
380 | + | |
381 | +Array.prototype._reverse = Array.prototype.reverse; | |
382 | + | |
383 | +Object.extend(Array.prototype, { | |
384 | + _each: function(iterator) { | |
385 | + for (var i = 0; i < this.length; i++) | |
386 | + iterator(this[i]); | |
387 | + }, | |
388 | + | |
389 | + clear: function() { | |
390 | + this.length = 0; | |
391 | + return this; | |
392 | + }, | |
393 | + | |
394 | + first: function() { | |
395 | + return this[0]; | |
396 | + }, | |
397 | + | |
398 | + last: function() { | |
399 | + return this[this.length - 1]; | |
400 | + }, | |
401 | + | |
402 | + compact: function() { | |
403 | + return this.select(function(value) { | |
404 | + return value != undefined || value != null; | |
405 | + }); | |
406 | + }, | |
407 | + | |
408 | + flatten: function() { | |
409 | + return this.inject([], function(array, value) { | |
410 | + return array.concat(value.constructor == Array ? | |
411 | + value.flatten() : [value]); | |
412 | + }); | |
413 | + }, | |
414 | + | |
415 | + without: function() { | |
416 | + var values = $A(arguments); | |
417 | + return this.select(function(value) { | |
418 | + return !values.include(value); | |
419 | + }); | |
420 | + }, | |
421 | + | |
422 | + indexOf: function(object) { | |
423 | + for (var i = 0; i < this.length; i++) | |
424 | + if (this[i] == object) return i; | |
425 | + return -1; | |
426 | + }, | |
427 | + | |
428 | + reverse: function(inline) { | |
429 | + return (inline !== false ? this : this.toArray())._reverse(); | |
430 | + }, | |
431 | + | |
432 | + shift: function() { | |
433 | + var result = this[0]; | |
434 | + for (var i = 0; i < this.length - 1; i++) | |
435 | + this[i] = this[i + 1]; | |
436 | + this.length--; | |
437 | + return result; | |
438 | + }, | |
439 | + | |
440 | + inspect: function() { | |
441 | + return '[' + this.map(Object.inspect).join(', ') + ']'; | |
442 | + } | |
443 | +}); | |
444 | +var Hash = { | |
445 | + _each: function(iterator) { | |
446 | + for (key in this) { | |
447 | + var value = this[key]; | |
448 | + if (typeof value == 'function') continue; | |
449 | + | |
450 | + var pair = [key, value]; | |
451 | + pair.key = key; | |
452 | + pair.value = value; | |
453 | + iterator(pair); | |
454 | + } | |
455 | + }, | |
456 | + | |
457 | + keys: function() { | |
458 | + return this.pluck('key'); | |
459 | + }, | |
460 | + | |
461 | + values: function() { | |
462 | + return this.pluck('value'); | |
463 | + }, | |
464 | + | |
465 | + merge: function(hash) { | |
466 | + return $H(hash).inject($H(this), function(mergedHash, pair) { | |
467 | + mergedHash[pair.key] = pair.value; | |
468 | + return mergedHash; | |
469 | + }); | |
470 | + }, | |
471 | + | |
472 | + toQueryString: function() { | |
473 | + return this.map(function(pair) { | |
474 | + return pair.map(encodeURIComponent).join('='); | |
475 | + }).join('&'); | |
476 | + }, | |
477 | + | |
478 | + inspect: function() { | |
479 | + return '#<Hash:{' + this.map(function(pair) { | |
480 | + return pair.map(Object.inspect).join(': '); | |
481 | + }).join(', ') + '}>'; | |
482 | + } | |
483 | +}; | |
484 | + | |
485 | +function $H(object) { | |
486 | + var hash = Object.extend({}, object || {}); | |
487 | + Object.extend(hash, Enumerable); | |
488 | + Object.extend(hash, Hash); | |
489 | + return hash; | |
490 | +} | |
491 | + | |
492 | +ObjectRange = Class.create(); | |
493 | +Object.extend(ObjectRange.prototype, Enumerable); | |
494 | +Object.extend(ObjectRange.prototype, { | |
495 | + initialize: function(start, end, exclusive) { | |
496 | + this.start = start; | |
497 | + this.end = end; | |
498 | + this.exclusive = exclusive; | |
499 | + }, | |
500 | + | |
501 | + _each: function(iterator) { | |
502 | + var value = this.start; | |
503 | + do { | |
504 | + iterator(value); | |
505 | + value = value.succ(); | |
506 | + } while (this.include(value)); | |
507 | + }, | |
508 | + | |
509 | + include: function(value) { | |
510 | + if (value < this.start) | |
511 | + return false; | |
512 | + if (this.exclusive) | |
513 | + return value < this.end; | |
514 | + return value <= this.end; | |
515 | + } | |
516 | +}); | |
517 | + | |
518 | +var $R = function(start, end, exclusive) { | |
519 | + return new ObjectRange(start, end, exclusive); | |
520 | +}; | |
521 | + | |
522 | +document.getElementsByClassName = function(className, parentElement) { | |
523 | + var children = ($(parentElement) || document.body).getElementsByTagName('*'); | |
524 | + return $A(children).inject([], function(elements, child) { | |
525 | + if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) | |
526 | + elements.push(child); | |
527 | + return elements; | |
528 | + }); | |
529 | +}; | |
530 | + | |
531 | +/*--------------------------------------------------------------------------*/ | |
532 | + | |
533 | +var Form = { | |
534 | + serialize: function(form) { | |
535 | + var elements = Form.getElements($(form)); | |
536 | + var queryComponents = new Array(); | |
537 | + | |
538 | + for (var i = 0; i < elements.length; i++) { | |
539 | + var queryComponent = Form.Element.serialize(elements[i]); | |
540 | + if (queryComponent) | |
541 | + queryComponents.push(queryComponent); | |
542 | + } | |
543 | + | |
544 | + return queryComponents.join('&'); | |
545 | + }, | |
546 | + | |
547 | + getElements: function(form) { | |
548 | + form = $(form); | |
549 | + var elements = new Array(); | |
550 | + | |
551 | + for (tagName in Form.Element.Serializers) { | |
552 | + var tagElements = form.getElementsByTagName(tagName); | |
553 | + for (var j = 0; j < tagElements.length; j++) | |
554 | + elements.push(tagElements[j]); | |
555 | + } | |
556 | + return elements; | |
557 | + }, | |
558 | + | |
559 | + getInputs: function(form, typeName, name) { | |
560 | + form = $(form); | |
561 | + var inputs = form.getElementsByTagName('input'); | |
562 | + | |
563 | + if (!typeName && !name) | |
564 | + return inputs; | |
565 | + | |
566 | + var matchingInputs = new Array(); | |
567 | + for (var i = 0; i < inputs.length; i++) { | |
568 | + var input = inputs[i]; | |
569 | + if ((typeName && input.type != typeName) || | |
570 | + (name && input.name != name)) | |
571 | + continue; | |
572 | + matchingInputs.push(input); | |
573 | + } | |
574 | + | |
575 | + return matchingInputs; | |
576 | + }, | |
577 | + | |
578 | + disable: function(form) { | |
579 | + var elements = Form.getElements(form); | |
580 | + for (var i = 0; i < elements.length; i++) { | |
581 | + var element = elements[i]; | |
582 | + element.blur(); | |
583 | + element.disabled = 'true'; | |
584 | + } | |
585 | + }, | |
586 | + | |
587 | + enable: function(form) { | |
588 | + var elements = Form.getElements(form); | |
589 | + for (var i = 0; i < elements.length; i++) { | |
590 | + var element = elements[i]; | |
591 | + element.disabled = ''; | |
592 | + } | |
593 | + }, | |
594 | + | |
595 | + findFirstElement: function(form) { | |
596 | + return Form.getElements(form).find(function(element) { | |
597 | + return element.type != 'hidden' && !element.disabled && | |
598 | + ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); | |
599 | + }); | |
600 | + }, | |
601 | + | |
602 | + focusFirstElement: function(form) { | |
603 | + Field.activate(Form.findFirstElement(form)); | |
604 | + }, | |
605 | + | |
606 | + reset: function(form) { | |
607 | + $(form).reset(); | |
608 | + } | |
609 | +}; | |
610 | + | |
611 | +Form.Element = { | |
612 | + serialize: function(element) { | |
613 | + element = $(element); | |
614 | + var method = element.tagName.toLowerCase(); | |
615 | + var parameter = Form.Element.Serializers[method](element); | |
616 | + | |
617 | + if (parameter) { | |
618 | + var key = encodeURIComponent(parameter[0]); | |
619 | + if (key.length == 0) return; | |
620 | + | |
621 | + if (parameter[1].constructor != Array) | |
622 | + parameter[1] = [parameter[1]]; | |
623 | + | |
624 | + return parameter[1].map(function(value) { | |
625 | + return key + '=' + encodeURIComponent(value); | |
626 | + }).join('&'); | |
627 | + } | |
628 | + }, | |
629 | + | |
630 | + getValue: function(element) { | |
631 | + element = $(element); | |
632 | + var method = element.tagName.toLowerCase(); | |
633 | + var parameter = Form.Element.Serializers[method](element); | |
634 | + | |
635 | + if (parameter) | |
636 | + return parameter[1]; | |
637 | + } | |
638 | +}; | |
639 | + | |
640 | +Form.Element.Serializers = { | |
641 | + input: function(element) { | |
642 | + switch (element.type.toLowerCase()) { | |
643 | + case 'submit': | |
644 | + case 'hidden': | |
645 | + case 'password': | |
646 | + case 'text': | |
647 | + return Form.Element.Serializers.textarea(element); | |
648 | + case 'checkbox': | |
649 | + case 'radio': | |
650 | + return Form.Element.Serializers.inputSelector(element); | |
651 | + } | |
652 | + return false; | |
653 | + }, | |
654 | + | |
655 | + inputSelector: function(element) { | |
656 | + if (element.checked) | |
657 | + return [element.name, element.value]; | |
658 | + }, | |
659 | + | |
660 | + textarea: function(element) { | |
661 | + return [element.name, element.value]; | |
662 | + }, | |
663 | + | |
664 | + select: function(element) { | |
665 | + return Form.Element.Serializers[element.type == 'select-one' ? | |
666 | + 'selectOne' : 'selectMany'](element); | |
667 | + }, | |
668 | + | |
669 | + selectOne: function(element) { | |
670 | + var value = '', opt, index = element.selectedIndex; | |
671 | + if (index >= 0) { | |
672 | + opt = element.options[index]; | |
673 | + value = opt.value; | |
674 | + if (!value && !('value' in opt)) | |
675 | + value = opt.text; | |
676 | + } | |
677 | + return [element.name, value]; | |
678 | + }, | |
679 | + | |
680 | + selectMany: function(element) { | |
681 | + var value = new Array(); | |
682 | + for (var i = 0; i < element.length; i++) { | |
683 | + var opt = element.options[i]; | |
684 | + if (opt.selected) { | |
685 | + var optValue = opt.value; | |
686 | + if (!optValue && !('value' in opt)) | |
687 | + optValue = opt.text; | |
688 | + value.push(optValue); | |
689 | + } | |
690 | + } | |
691 | + return [element.name, value]; | |
692 | + } | |
693 | +}; | |
694 | + | |
695 | +/*--------------------------------------------------------------------------*/ | |
696 | + | |
697 | +var $F = Form.Element.getValue; | |
698 | + | |
699 | +/*--------------------------------------------------------------------------*/ | |
700 | + | |
701 | +Abstract.TimedObserver = function() {}; | |
702 | +Abstract.TimedObserver.prototype = { | |
703 | + initialize: function(element, frequency, callback) { | |
704 | + this.frequency = frequency; | |
705 | + this.element = $(element); | |
706 | + this.callback = callback; | |
707 | + | |
708 | + this.lastValue = this.getValue(); | |
709 | + this.registerCallback(); | |
710 | + }, | |
711 | + | |
712 | + registerCallback: function() { | |
713 | + setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); | |
714 | + }, | |
715 | + | |
716 | + onTimerEvent: function() { | |
717 | + var value = this.getValue(); | |
718 | + if (this.lastValue != value) { | |
719 | + this.callback(this.element, value); | |
720 | + this.lastValue = value; | |
721 | + } | |
722 | + } | |
723 | +}; | |
724 | + | |
725 | +Form.Element.Observer = Class.create(); | |
726 | +Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { | |
727 | + getValue: function() { | |
728 | + return Form.Element.getValue(this.element); | |
729 | + } | |
730 | +}); | |
731 | + | |
732 | +Form.Observer = Class.create(); | |
733 | +Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { | |
734 | + getValue: function() { | |
735 | + return Form.serialize(this.element); | |
736 | + } | |
737 | +}); | |
738 | + | |
739 | +/*--------------------------------------------------------------------------*/ | |
740 | + | |
741 | +Abstract.EventObserver = function() {} | |
742 | +Abstract.EventObserver.prototype = { | |
743 | + initialize: function(element, callback) { | |
744 | + this.element = $(element); | |
745 | + this.callback = callback; | |
746 | + | |
747 | + this.lastValue = this.getValue(); | |
748 | + if (this.element.tagName.toLowerCase() == 'form') | |
749 | + this.registerFormCallbacks(); | |
750 | + else | |
751 | + this.registerCallback(this.element); | |
752 | + }, | |
753 | + | |
754 | + onElementEvent: function() { | |
755 | + var value = this.getValue(); | |
756 | + if (this.lastValue != value) { | |
757 | + this.callback(this.element, value); | |
758 | + this.lastValue = value; | |
759 | + } | |
760 | + }, | |
761 | + | |
762 | + registerFormCallbacks: function() { | |
763 | + var elements = Form.getElements(this.element); | |
764 | + for (var i = 0; i < elements.length; i++) | |
765 | + this.registerCallback(elements[i]); | |
766 | + }, | |
767 | + | |
768 | + registerCallback: function(element) { | |
769 | + if (element.type) { | |
770 | + switch (element.type.toLowerCase()) { | |
771 | + case 'checkbox': | |
772 | + case 'radio': | |
773 | + Event.observe(element, 'click', this.onElementEvent.bind(this)); | |
774 | + break; | |
775 | + case 'password': | |
776 | + case 'text': | |
777 | + case 'textarea': | |
778 | + case 'select-one': | |
779 | + case 'select-multiple': | |
780 | + Event.observe(element, 'change', this.onElementEvent.bind(this)); | |
781 | + break; | |
782 | + } | |
783 | + } | |
784 | + } | |
785 | +}; | |
786 | + | |
787 | +Form.Element.EventObserver = Class.create(); | |
788 | +Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { | |
789 | + getValue: function() { | |
790 | + return Form.Element.getValue(this.element); | |
791 | + } | |
792 | +}); | |
793 | + | |
794 | +Form.EventObserver = Class.create(); | |
795 | +Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { | |
796 | + getValue: function() { | |
797 | + return Form.serialize(this.element); | |
798 | + } | |
799 | +}); | |
800 | +if (!window.Event) { | |
801 | + var Event = new Object(); | |
802 | +} | |
803 | + | |
804 | +Object.extend(Event, { | |
805 | + KEY_BACKSPACE: 8, | |
806 | + KEY_TAB: 9, | |
807 | + KEY_RETURN: 13, | |
808 | + KEY_ESC: 27, | |
809 | + KEY_LEFT: 37, | |
810 | + KEY_UP: 38, | |
811 | + KEY_RIGHT: 39, | |
812 | + KEY_DOWN: 40, | |
813 | + KEY_DELETE: 46, | |
814 | + | |
815 | + element: function(event) { | |
816 | + return event.target || event.srcElement; | |
817 | + }, | |
818 | + | |
819 | + isLeftClick: function(event) { | |
820 | + return (((event.which) && (event.which == 1)) || | |
821 | + ((event.button) && (event.button == 1))); | |
822 | + }, | |
823 | + | |
824 | + pointerX: function(event) { | |
825 | + return event.pageX || (event.clientX + | |
826 | + (document.documentElement.scrollLeft || document.body.scrollLeft)); | |
827 | + }, | |
828 | + | |
829 | + pointerY: function(event) { | |
830 | + return event.pageY || (event.clientY + | |
831 | + (document.documentElement.scrollTop || document.body.scrollTop)); | |
832 | + }, | |
833 | + | |
834 | + stop: function(event) { | |
835 | + if (event.preventDefault) { | |
836 | + event.preventDefault(); | |
837 | + event.stopPropagation(); | |
838 | + } else { | |
839 | + event.returnValue = false; | |
840 | + event.cancelBubble = true; | |
841 | + } | |
842 | + }, | |
843 | + | |
844 | + // find the first node with the given tagName, starting from the | |
845 | + // node the event was triggered on; traverses the DOM upwards | |
846 | + findElement: function(event, tagName) { | |
847 | + var element = Event.element(event); | |
848 | + while (element.parentNode && (!element.tagName || | |
849 | + (element.tagName.toUpperCase() != tagName.toUpperCase()))) | |
850 | + element = element.parentNode; | |
851 | + return element; | |
852 | + }, | |
853 | + | |
854 | + observers: false, | |
855 | + | |
856 | + _observeAndCache: function(element, name, observer, useCapture) { | |
857 | + if (!this.observers) this.observers = []; | |
858 | + if (element.addEventListener) { | |
859 | + this.observers.push([element, name, observer, useCapture]); | |
860 | + element.addEventListener(name, observer, useCapture); | |
861 | + } else if (element.attachEvent) { | |
862 | + this.observers.push([element, name, observer, useCapture]); | |
863 | + element.attachEvent('on' + name, observer); | |
864 | + } | |
865 | + }, | |
866 | + | |
867 | + unloadCache: function() { | |
868 | + if (!Event.observers) return; | |
869 | + for (var i = 0; i < Event.observers.length; i++) { | |
870 | + Event.stopObserving.apply(this, Event.observers[i]); | |
871 | + Event.observers[i][0] = null; | |
872 | + } | |
873 | + Event.observers = false; | |
874 | + }, | |
875 | + | |
876 | + observe: function(element, name, observer, useCapture) { | |
877 | + var element = $(element); | |
878 | + useCapture = useCapture || false; | |
879 | + | |
880 | + if (name == 'keypress' && | |
881 | + (navigator.appVersion.match(/Konqueror|Safari|KHTML/) | |
882 | + || element.attachEvent)) | |
883 | + name = 'keydown'; | |
884 | + | |
885 | + this._observeAndCache(element, name, observer, useCapture); | |
886 | + }, | |
887 | + | |
888 | + stopObserving: function(element, name, observer, useCapture) { | |
889 | + var element = $(element); | |
890 | + useCapture = useCapture || false; | |
891 | + | |
892 | + if (name == 'keypress' && | |
893 | + (navigator.appVersion.match(/Konqueror|Safari|KHTML/) | |
894 | + || element.detachEvent)) | |
895 | + name = 'keydown'; | |
896 | + | |
897 | + if (element.removeEventListener) { | |
898 | + element.removeEventListener(name, observer, useCapture); | |
899 | + } else if (element.detachEvent) { | |
900 | + element.detachEvent('on' + name, observer); | |
901 | + } | |
902 | + } | |
903 | +}); | |
904 | + | |
905 | +/* prevent memory leaks in IE */ | |
906 | +Event.observe(window, 'unload', Event.unloadCache, false); | |
907 | +var Position = { | |
908 | + // set to true if needed, warning: firefox performance problems | |
909 | + // NOT neeeded for page scrolling, only if draggable contained in | |
910 | + // scrollable elements | |
911 | + includeScrollOffsets: false, | |
912 | + | |
913 | + // must be called before calling withinIncludingScrolloffset, every time the | |
914 | + // page is scrolled | |
915 | + prepare: function() { | |
916 | + this.deltaX = window.pageXOffset | |
917 | + || document.documentElement.scrollLeft | |
918 | + || document.body.scrollLeft | |
919 | + || 0; | |
920 | + this.deltaY = window.pageYOffset | |
921 | + || document.documentElement.scrollTop | |
922 | + || document.body.scrollTop | |
923 | + || 0; | |
924 | + }, | |
925 | + | |
926 | + realOffset: function(element) { | |
927 | + var valueT = 0, valueL = 0; | |
928 | + do { | |
929 | + valueT += element.scrollTop || 0; | |
930 | + valueL += element.scrollLeft || 0; | |
931 | + element = element.parentNode; | |
932 | + } while (element); | |
933 | + return [valueL, valueT]; | |
934 | + }, | |
935 | + | |
936 | + cumulativeOffset: function(element) { | |
937 | + var valueT = 0, valueL = 0; | |
938 | + do { | |
939 | + valueT += element.offsetTop || 0; | |
940 | + valueL += element.offsetLeft || 0; | |
941 | + element = element.offsetParent; | |
942 | + } while (element); | |
943 | + return [valueL, valueT]; | |
944 | + }, | |
945 | + | |
946 | + positionedOffset: function(element) { | |
947 | + var valueT = 0, valueL = 0; | |
948 | + do { | |
949 | + valueT += element.offsetTop || 0; | |
950 | + valueL += element.offsetLeft || 0; | |
951 | + element = element.offsetParent; | |
952 | + if (element) { | |
953 | + p = Element.getStyle(element, 'position'); | |
954 | + if (p == 'relative' || p == 'absolute') break; | |
955 | + } | |
956 | + } while (element); | |
957 | + return [valueL, valueT]; | |
958 | + }, | |
959 | + | |
960 | + offsetParent: function(element) { | |
961 | + if (element.offsetParent) return element.offsetParent; | |
962 | + if (element == document.body) return element; | |
963 | + | |
964 | + while ((element = element.parentNode) && element != document.body) | |
965 | + if (Element.getStyle(element, 'position') != 'static') | |
966 | + return element; | |
967 | + | |
968 | + return document.body; | |
969 | + }, | |
970 | + | |
971 | + // caches x/y coordinate pair to use with overlap | |
972 | + within: function(element, x, y) { | |
973 | + if (this.includeScrollOffsets) | |
974 | + return this.withinIncludingScrolloffsets(element, x, y); | |
975 | + this.xcomp = x; | |
976 | + this.ycomp = y; | |
977 | + this.offset = this.cumulativeOffset(element); | |
978 | + | |
979 | + return (y >= this.offset[1] && | |
980 | + y < this.offset[1] + element.offsetHeight && | |
981 | + x >= this.offset[0] && | |
982 | + x < this.offset[0] + element.offsetWidth); | |
983 | + }, | |
984 | + | |
985 | + withinIncludingScrolloffsets: function(element, x, y) { | |
986 | + var offsetcache = this.realOffset(element); | |
987 | + | |
988 | + this.xcomp = x + offsetcache[0] - this.deltaX; | |
989 | + this.ycomp = y + offsetcache[1] - this.deltaY; | |
990 | + this.offset = this.cumulativeOffset(element); | |
991 | + | |
992 | + return (this.ycomp >= this.offset[1] && | |
993 | + this.ycomp < this.offset[1] + element.offsetHeight && | |
994 | + this.xcomp >= this.offset[0] && | |
995 | + this.xcomp < this.offset[0] + element.offsetWidth); | |
996 | + }, | |
997 | + | |
998 | + // within must be called directly before | |
999 | + overlap: function(mode, element) { | |
1000 | + if (!mode) return 0; | |
1001 | + if (mode == 'vertical') | |
1002 | + return ((this.offset[1] + element.offsetHeight) - this.ycomp) / | |
1003 | + element.offsetHeight; | |
1004 | + if (mode == 'horizontal') | |
1005 | + return ((this.offset[0] + element.offsetWidth) - this.xcomp) / | |
1006 | + element.offsetWidth; | |
1007 | + }, | |
1008 | + | |
1009 | + clone: function(source, target) { | |
1010 | + source = $(source); | |
1011 | + target = $(target); | |
1012 | + target.style.position = 'absolute'; | |
1013 | + var offsets = this.cumulativeOffset(source); | |
1014 | + target.style.top = offsets[1] + 'px'; | |
1015 | + target.style.left = offsets[0] + 'px'; | |
1016 | + target.style.width = source.offsetWidth + 'px'; | |
1017 | + target.style.height = source.offsetHeight + 'px'; | |
1018 | + }, | |
1019 | + | |
1020 | + page: function(forElement) { | |
1021 | + var valueT = 0, valueL = 0; | |
1022 | + | |
1023 | + var element = forElement; | |
1024 | + do { | |
1025 | + valueT += element.offsetTop || 0; | |
1026 | + valueL += element.offsetLeft || 0; | |
1027 | + | |
1028 | + // Safari fix | |
1029 | + if (element.offsetParent==document.body) | |
1030 | + if (Element.getStyle(element,'position')=='absolute') break; | |
1031 | + | |
1032 | + } while (element = element.offsetParent); | |
1033 | + | |
1034 | + element = forElement; | |
1035 | + do { | |
1036 | + valueT -= element.scrollTop || 0; | |
1037 | + valueL -= element.scrollLeft || 0; | |
1038 | + } while (element = element.parentNode); | |
1039 | + | |
1040 | + return [valueL, valueT]; | |
1041 | + }, | |
1042 | + | |
1043 | + clone: function(source, target) { | |
1044 | + var options = Object.extend({ | |
1045 | + setLeft: true, | |
1046 | + setTop: true, | |
1047 | + setWidth: true, | |
1048 | + setHeight: true, | |
1049 | + offsetTop: 0, | |
1050 | + offsetLeft: 0 | |
1051 | + }, arguments[2] || {}); | |
1052 | + | |
1053 | + // find page position of source | |
1054 | + source = $(source); | |
1055 | + var p = Position.page(source); | |
1056 | + | |
1057 | + // find coordinate system to use | |
1058 | + target = $(target); | |
1059 | + var delta = [0, 0]; | |
1060 | + var parent = null; | |
1061 | + // delta [0,0] will do fine with position: fixed elements, | |
1062 | + // position:absolute needs offsetParent deltas | |
1063 | + if (Element.getStyle(target,'position') == 'absolute') { | |
1064 | + parent = Position.offsetParent(target); | |
1065 | + delta = Position.page(parent); | |
1066 | + } | |
1067 | + | |
1068 | + // correct by body offsets (fixes Safari) | |
1069 | + if (parent == document.body) { | |
1070 | + delta[0] -= document.body.offsetLeft; | |
1071 | + delta[1] -= document.body.offsetTop; | |
1072 | + } | |
1073 | + | |
1074 | + // set position | |
1075 | + if(options.setLeft) target.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; | |
1076 | + if(options.setTop) target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; | |
1077 | + if(options.setWidth) target.style.width = source.offsetWidth + 'px'; | |
1078 | + if(options.setHeight) target.style.height = source.offsetHeight + 'px'; | |
1079 | + }, | |
1080 | + | |
1081 | + absolutize: function(element) { | |
1082 | + element = $(element); | |
1083 | + if (element.style.position == 'absolute') return; | |
1084 | + Position.prepare(); | |
1085 | + | |
1086 | + var offsets = Position.positionedOffset(element); | |
1087 | + var top = offsets[1]; | |
1088 | + var left = offsets[0]; | |
1089 | + var width = element.clientWidth; | |
1090 | + var height = element.clientHeight; | |
1091 | + | |
1092 | + element._originalLeft = left - parseFloat(element.style.left || 0); | |
1093 | + element._originalTop = top - parseFloat(element.style.top || 0); | |
1094 | + element._originalWidth = element.style.width; | |
1095 | + element._originalHeight = element.style.height; | |
1096 | + | |
1097 | + element.style.position = 'absolute'; | |
1098 | + element.style.top = top + 'px';; | |
1099 | + element.style.left = left + 'px';; | |
1100 | + element.style.width = width + 'px';; | |
1101 | + element.style.height = height + 'px';; | |
1102 | + }, | |
1103 | + | |
1104 | + relativize: function(element) { | |
1105 | + element = $(element); | |
1106 | + if (element.style.position == 'relative') return; | |
1107 | + Position.prepare(); | |
1108 | + | |
1109 | + element.style.position = 'relative'; | |
1110 | + var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); | |
1111 | + var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); | |
1112 | + | |
1113 | + element.style.top = top + 'px'; | |
1114 | + element.style.left = left + 'px'; | |
1115 | + element.style.height = element._originalHeight; | |
1116 | + element.style.width = element._originalWidth; | |
1117 | + } | |
1118 | +}; | |
0 | 1119 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,27 @@ |
1 | +var Prototype={ Version: '1.4.0', ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', emptyFunction: function(){}, K: function(x){return x}};var Class={ create: function(){ return function(){ this.initialize.apply(this, arguments);}}};var Abstract=new Object();Object.extend=function(destination, source){ for(property in source){ destination[property]=source[property];} | |
2 | + return destination;};Object.inspect=function(object){ try{ if(object==undefined)return 'undefined'; if(object==null)return 'null'; return object.inspect ? object.inspect(): object.toString();}catch(e){ if(e instanceof RangeError)return '...'; throw e;}};Function.prototype.bind=function(){ var __method=this, args=$A(arguments), object=args.shift(); return function(){ return __method.apply(object, args.concat($A(arguments)));}};Function.prototype.bindAsEventListener=function(object){ var __method=this; return function(event){ return __method.call(object, event || window.event);}};Object.extend(Number.prototype,{ toColorPart: function(){ var digits=this.toString(16); if(this < 16)return '0'+digits; return digits;}, succ: function(){ return this+1;}, times: function(iterator){ $R(0, this, true).each(iterator); return this;}});var Try={ these: function(){ var returnValue; for(var i=0;i < arguments.length;i++){ var lambda=arguments[i]; try{ returnValue=lambda(); break;}catch(e){}} | |
3 | + return returnValue;}};/*--------------------------------------------------------------------------*/ | |
4 | +function $(){ var elements=new Array(); for(var i=0;i < arguments.length;i++){ var element=arguments[i]; if(typeof element=='string') element=document.getElementById(element); if(arguments.length==1) return element; elements.push(element);} | |
5 | + return elements;} | |
6 | +Object.extend(String.prototype,{ stripTags: function(){ return this.replace(/<\/?[^>]+>/gi, '');}, stripScripts: function(){ return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');}, extractScripts: function(){ var matchAll=new RegExp(Prototype.ScriptFragment, 'img'); var matchOne=new RegExp(Prototype.ScriptFragment, 'im'); return(this.match(matchAll)|| []).map(function(scriptTag){ return(scriptTag.match(matchOne)|| ['', ''])[1];});}, evalScripts: function(){ return this.extractScripts().map(eval);}, escapeHTML: function(){ var div=document.createElement('div'); var text=document.createTextNode(this); div.appendChild(text); return div.innerHTML;}, unescapeHTML: function(){ var div=document.createElement('div'); div.innerHTML=this.stripTags(); return div.childNodes[0] ? div.childNodes[0].nodeValue : '';}, toQueryParams: function(){ var pairs=this.match(/^\??(.*)$/)[1].split('&'); return pairs.inject({}, function(params, pairString){ var pair=pairString.split('='); params[pair[0]]=pair[1]; return params;});}, toArray: function(){ return this.split('');}, camelize: function(){ var oStringList=this.split('-'); if(oStringList.length==1)return oStringList[0]; var camelizedString=this.indexOf('-')==0 ? oStringList[0].charAt(0).toUpperCase()+oStringList[0].substring(1) : oStringList[0]; for(var i=1, len=oStringList.length;i < len;i++){ var s=oStringList[i]; camelizedString+=s.charAt(0).toUpperCase()+s.substring(1);} | |
7 | + return camelizedString;}, inspect: function(){ return "'"+this.replace('\\', '\\\\').replace("'", '\\\'')+"'";}});String.prototype.parseQuery=String.prototype.toQueryParams;var $break=new Object();var $continue=new Object();var Enumerable={ each: function(iterator){ var index=0; try{ this._each(function(value){ try{ iterator(value, index++);}catch(e){ if(e !=$continue)throw e;}});}catch(e){ if(e !=$break)throw e;}}, all: function(iterator){ var result=true; this.each(function(value, index){ result=result && !!(iterator || Prototype.K)(value, index); if(!result)throw $break;}); return result;}, any: function(iterator){ var result=true; this.each(function(value, index){ if(result=!!(iterator || Prototype.K)(value, index)) throw $break;}); return result;}, collect: function(iterator){ var results=[]; this.each(function(value, index){ results.push(iterator(value, index));}); return results;}, detect: function(iterator){ var result; this.each(function(value, index){ if(iterator(value, index)){ result=value; throw $break;}}); return result;}, findAll: function(iterator){ var results=[]; this.each(function(value, index){ if(iterator(value, index)) results.push(value);}); return results;}, grep: function(pattern, iterator){ var results=[]; this.each(function(value, index){ var stringValue=value.toString(); if(stringValue.match(pattern)) results.push((iterator || Prototype.K)(value, index));}); return results;}, include: function(object){ var found=false; this.each(function(value){ if(value==object){ found=true; throw $break;}}); return found;}, inject: function(memo, iterator){ this.each(function(value, index){ memo=iterator(memo, value, index);}); return memo;}, invoke: function(method){ var args=$A(arguments).slice(1); return this.collect(function(value){ return value[method].apply(value, args);});}, max: function(iterator){ var result; this.each(function(value, index){ value=(iterator || Prototype.K)(value, index); if(value >=(result || value)) result=value;}); return result;}, min: function(iterator){ var result; this.each(function(value, index){ value=(iterator || Prototype.K)(value, index); if(value <=(result || value)) result=value;}); return result;}, partition: function(iterator){ var trues=[], falses=[]; this.each(function(value, index){((iterator || Prototype.K)(value, index)? trues : falses).push(value);}); return [trues, falses];}, pluck: function(property){ var results=[]; this.each(function(value, index){ results.push(value[property]);}); return results;}, reject: function(iterator){ var results=[]; this.each(function(value, index){ if(!iterator(value, index)) results.push(value);}); return results;}, sortBy: function(iterator){ return this.collect(function(value, index){ return{value: value, criteria: iterator(value, index)};}).sort(function(left, right){ var a=left.criteria, b=right.criteria; return a < b ?-1 : a > b ? 1 : 0;}).pluck('value');}, toArray: function(){ return this.collect(Prototype.K);}, zip: function(){ var iterator=Prototype.K, args=$A(arguments); if(typeof args.last()=='function') iterator=args.pop(); var collections=[this].concat(args).map($A); return this.map(function(value, index){ iterator(value=collections.pluck(index)); return value;});}, inspect: function(){ return '#<Enumerable:'+this.toArray().inspect()+'>';}};Object.extend(Enumerable,{ map: Enumerable.collect, find: Enumerable.detect, select: Enumerable.findAll, member: Enumerable.include, entries: Enumerable.toArray });var $A=Array.from=function(iterable){ if(!iterable)return []; if(iterable.toArray){ return iterable.toArray();}else{ var results=[]; for(var i=0;i < iterable.length;i++) results.push(iterable[i]); return results;}};Object.extend(Array.prototype, Enumerable);Array.prototype._reverse=Array.prototype.reverse;Object.extend(Array.prototype,{ _each: function(iterator){ for(var i=0;i < this.length;i++) iterator(this[i]);}, clear: function(){ this.length=0; return this;}, first: function(){ return this[0];}, last: function(){ return this[this.length-1];}, compact: function(){ return this.select(function(value){ return value !=undefined || value !=null;});}, flatten: function(){ return this.inject([], function(array, value){ return array.concat(value.constructor==Array ? value.flatten(): [value]);});}, without: function(){ var values=$A(arguments); return this.select(function(value){ return !values.include(value);});}, indexOf: function(object){ for(var i=0;i < this.length;i++) if(this[i]==object)return i; return-1;}, reverse: function(inline){ return(inline !==false ? this : this.toArray())._reverse();}, shift: function(){ var result=this[0]; for(var i=0;i < this.length-1;i++) this[i]=this[i+1]; this.length--; return result;}, inspect: function(){ return '['+this.map(Object.inspect).join(', ')+']';}});var Hash={ _each: function(iterator){ for(key in this){ var value=this[key]; if(typeof value=='function')continue; var pair=[key, value]; pair.key=key; pair.value=value; iterator(pair);}}, keys: function(){ return this.pluck('key');}, values: function(){ return this.pluck('value');}, merge: function(hash){ return $H(hash).inject($H(this), function(mergedHash, pair){ mergedHash[pair.key]=pair.value; return mergedHash;});}, toQueryString: function(){ return this.map(function(pair){ return pair.map(encodeURIComponent).join('=');}).join('&');}, inspect: function(){ return '#<Hash:{'+this.map(function(pair){ return pair.map(Object.inspect).join(': ');}).join(', ')+'}>';}};function $H(object){ var hash=Object.extend({}, object ||{}); Object.extend(hash, Enumerable); Object.extend(hash, Hash); return hash;} | |
8 | +ObjectRange=Class.create();Object.extend(ObjectRange.prototype, Enumerable);Object.extend(ObjectRange.prototype,{ initialize: function(start, end, exclusive){ this.start=start; this.end=end; this.exclusive=exclusive;}, _each: function(iterator){ var value=this.start; do{ iterator(value); value=value.succ();}while(this.include(value));}, include: function(value){ if(value < this.start) return false; if(this.exclusive) return value < this.end; return value <=this.end;}});var $R=function(start, end, exclusive){ return new ObjectRange(start, end, exclusive);};document.getElementsByClassName=function(className, parentElement){ var children=($(parentElement)|| document.body).getElementsByTagName('*'); return $A(children).inject([], function(elements, child){ if(child.className.match(new RegExp("(^|\\s)"+className+"(\\s|$)"))) elements.push(child); return elements;});};/*--------------------------------------------------------------------------*/ | |
9 | +var Form={ serialize: function(form){ var elements=Form.getElements($(form)); var queryComponents=new Array(); for(var i=0;i < elements.length;i++){ var queryComponent=Form.Element.serialize(elements[i]); if(queryComponent) queryComponents.push(queryComponent);} | |
10 | + return queryComponents.join('&');}, getElements: function(form){ form=$(form); var elements=new Array(); for(tagName in Form.Element.Serializers){ var tagElements=form.getElementsByTagName(tagName); for(var j=0;j < tagElements.length;j++) elements.push(tagElements[j]);} | |
11 | + return elements;}, getInputs: function(form, typeName, name){ form=$(form); var inputs=form.getElementsByTagName('input'); if(!typeName && !name) return inputs; var matchingInputs=new Array(); for(var i=0;i < inputs.length;i++){ var input=inputs[i]; if((typeName && input.type !=typeName)||(name && input.name !=name)) continue; matchingInputs.push(input);} | |
12 | + return matchingInputs;}, disable: function(form){ var elements=Form.getElements(form); for(var i=0;i < elements.length;i++){ var element=elements[i]; element.blur(); element.disabled='true';}}, enable: function(form){ var elements=Form.getElements(form); for(var i=0;i < elements.length;i++){ var element=elements[i]; element.disabled='';}}, findFirstElement: function(form){ return Form.getElements(form).find(function(element){ return element.type !='hidden' && !element.disabled && ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());});}, focusFirstElement: function(form){ Field.activate(Form.findFirstElement(form));}, reset: function(form){ $(form).reset();}};Form.Element={ serialize: function(element){ element=$(element); var method=element.tagName.toLowerCase(); var parameter=Form.Element.Serializers[method](element); if(parameter){ var key=encodeURIComponent(parameter[0]); if(key.length==0)return; if(parameter[1].constructor !=Array) parameter[1]=[parameter[1]]; return parameter[1].map(function(value){ return key+'='+encodeURIComponent(value);}).join('&');}}, getValue: function(element){ element=$(element); var method=element.tagName.toLowerCase(); var parameter=Form.Element.Serializers[method](element); if(parameter) return parameter[1];}};Form.Element.Serializers={ input: function(element){ switch(element.type.toLowerCase()){ case 'submit': case 'hidden': case 'password': case 'text': return Form.Element.Serializers.textarea(element); case 'checkbox': case 'radio': return Form.Element.Serializers.inputSelector(element);} | |
13 | + return false;}, inputSelector: function(element){ if(element.checked) return [element.name, element.value];}, textarea: function(element){ return [element.name, element.value];}, select: function(element){ return Form.Element.Serializers[element.type=='select-one' ? 'selectOne' : 'selectMany'](element);}, selectOne: function(element){ var value='', opt, index=element.selectedIndex; if(index >=0){ opt=element.options[index]; value=opt.value; if(!value && !('value' in opt)) value=opt.text;} | |
14 | + return [element.name, value];}, selectMany: function(element){ var value=new Array(); for(var i=0;i < element.length;i++){ var opt=element.options[i]; if(opt.selected){ var optValue=opt.value; if(!optValue && !('value' in opt)) optValue=opt.text; value.push(optValue);}} | |
15 | + return [element.name, value];}};/*--------------------------------------------------------------------------*/ | |
16 | +var $F=Form.Element.getValue;/*--------------------------------------------------------------------------*/ | |
17 | +Abstract.TimedObserver=function(){};Abstract.TimedObserver.prototype={ initialize: function(element, frequency, callback){ this.frequency=frequency; this.element=$(element); this.callback=callback; this.lastValue=this.getValue(); this.registerCallback();}, registerCallback: function(){ setInterval(this.onTimerEvent.bind(this), this.frequency*1000);}, onTimerEvent: function(){ var value=this.getValue(); if(this.lastValue !=value){ this.callback(this.element, value); this.lastValue=value;}}};Form.Element.Observer=Class.create();Form.Element.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{ getValue: function(){ return Form.Element.getValue(this.element);}});Form.Observer=Class.create();Form.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{ getValue: function(){ return Form.serialize(this.element);}});/*--------------------------------------------------------------------------*/ | |
18 | +Abstract.EventObserver=function(){} | |
19 | +Abstract.EventObserver.prototype={ initialize: function(element, callback){ this.element=$(element); this.callback=callback; this.lastValue=this.getValue(); if(this.element.tagName.toLowerCase()=='form') this.registerFormCallbacks(); else this.registerCallback(this.element);}, onElementEvent: function(){ var value=this.getValue(); if(this.lastValue !=value){ this.callback(this.element, value); this.lastValue=value;}}, registerFormCallbacks: function(){ var elements=Form.getElements(this.element); for(var i=0;i < elements.length;i++) this.registerCallback(elements[i]);}, registerCallback: function(element){ if(element.type){ switch(element.type.toLowerCase()){ case 'checkbox': case 'radio': Event.observe(element, 'click', this.onElementEvent.bind(this)); break; case 'password': case 'text': case 'textarea': case 'select-one': case 'select-multiple': Event.observe(element, 'change', this.onElementEvent.bind(this)); break;}}}};Form.Element.EventObserver=Class.create();Form.Element.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{ getValue: function(){ return Form.Element.getValue(this.element);}});Form.EventObserver=Class.create();Form.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{ getValue: function(){ return Form.serialize(this.element);}});if(!window.Event){ var Event=new Object();} | |
20 | +Object.extend(Event,{ KEY_BACKSPACE: 8, KEY_TAB: 9, KEY_RETURN: 13, KEY_ESC: 27, KEY_LEFT: 37, KEY_UP: 38, KEY_RIGHT: 39, KEY_DOWN: 40, KEY_DELETE: 46, element: function(event){ return event.target || event.srcElement;}, isLeftClick: function(event){ return(((event.which)&&(event.which==1))||((event.button)&&(event.button==1)));}, pointerX: function(event){ return event.pageX ||(event.clientX+ | |
21 | +(document.documentElement.scrollLeft || document.body.scrollLeft));}, pointerY: function(event){ return event.pageY ||(event.clientY+ | |
22 | +(document.documentElement.scrollTop || document.body.scrollTop));}, stop: function(event){ if(event.preventDefault){ event.preventDefault(); event.stopPropagation();}else{ event.returnValue=false; event.cancelBubble=true;}}, findElement: function(event, tagName){ var element=Event.element(event); while(element.parentNode &&(!element.tagName ||(element.tagName.toUpperCase()!=tagName.toUpperCase()))) element=element.parentNode; return element;}, observers: false, _observeAndCache: function(element, name, observer, useCapture){ if(!this.observers)this.observers=[]; if(element.addEventListener){ this.observers.push([element, name, observer, useCapture]); element.addEventListener(name, observer, useCapture);}else if(element.attachEvent){ this.observers.push([element, name, observer, useCapture]); element.attachEvent('on'+name, observer);}}, unloadCache: function(){ if(!Event.observers)return; for(var i=0;i < Event.observers.length;i++){ Event.stopObserving.apply(this, Event.observers[i]); Event.observers[i][0]=null;} | |
23 | + Event.observers=false;}, observe: function(element, name, observer, useCapture){ var element=$(element); useCapture=useCapture || false; if(name=='keypress' &&(navigator.appVersion.match(/Konqueror|Safari|KHTML/) || element.attachEvent)) name='keydown'; this._observeAndCache(element, name, observer, useCapture);}, stopObserving: function(element, name, observer, useCapture){ var element=$(element); useCapture=useCapture || false; if(name=='keypress' &&(navigator.appVersion.match(/Konqueror|Safari|KHTML/) || element.detachEvent)) name='keydown'; if(element.removeEventListener){ element.removeEventListener(name, observer, useCapture);}else if(element.detachEvent){ element.detachEvent('on'+name, observer);}}});Event.observe(window, 'unload', Event.unloadCache, false);var Position={ includeScrollOffsets: false, prepare: function(){ this.deltaX=window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0; this.deltaY=window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;}, realOffset: function(element){ var valueT=0, valueL=0; do{ valueT+=element.scrollTop || 0; valueL+=element.scrollLeft || 0; element=element.parentNode;}while(element); return [valueL, valueT];}, cumulativeOffset: function(element){ var valueT=0, valueL=0; do{ valueT+=element.offsetTop || 0; valueL+=element.offsetLeft || 0; element=element.offsetParent;}while(element); return [valueL, valueT];}, positionedOffset: function(element){ var valueT=0, valueL=0; do{ valueT+=element.offsetTop || 0; valueL+=element.offsetLeft || 0; element=element.offsetParent; if(element){ p=Element.getStyle(element, 'position'); if(p=='relative' || p=='absolute')break;}}while(element); return [valueL, valueT];}, offsetParent: function(element){ if(element.offsetParent)return element.offsetParent; if(element==document.body)return element; while((element=element.parentNode)&& element !=document.body) if(Element.getStyle(element, 'position')!='static') return element; return document.body;}, within: function(element, x, y){ if(this.includeScrollOffsets) return this.withinIncludingScrolloffsets(element, x, y); this.xcomp=x; this.ycomp=y; this.offset=this.cumulativeOffset(element); return(y >=this.offset[1] && y < this.offset[1]+element.offsetHeight && x >=this.offset[0] && x < this.offset[0]+element.offsetWidth);}, withinIncludingScrolloffsets: function(element, x, y){ var offsetcache=this.realOffset(element); this.xcomp=x+offsetcache[0]-this.deltaX; this.ycomp=y+offsetcache[1]-this.deltaY; this.offset=this.cumulativeOffset(element); return(this.ycomp >=this.offset[1] && this.ycomp < this.offset[1]+element.offsetHeight && this.xcomp >=this.offset[0] && this.xcomp < this.offset[0]+element.offsetWidth);}, overlap: function(mode, element){ if(!mode)return 0; if(mode=='vertical') return((this.offset[1]+element.offsetHeight)-this.ycomp)/ | |
24 | + element.offsetHeight; if(mode=='horizontal') return((this.offset[0]+element.offsetWidth)-this.xcomp)/ | |
25 | + element.offsetWidth;}, clone: function(source, target){ source=$(source); target=$(target); target.style.position='absolute'; var offsets=this.cumulativeOffset(source); target.style.top=offsets[1]+'px'; target.style.left=offsets[0]+'px'; target.style.width=source.offsetWidth+'px'; target.style.height=source.offsetHeight+'px';}, page: function(forElement){ var valueT=0, valueL=0; var element=forElement; do{ valueT+=element.offsetTop || 0; valueL+=element.offsetLeft || 0; if(element.offsetParent==document.body) if(Element.getStyle(element,'position')=='absolute')break; }while(element=element.offsetParent); element=forElement; do{ valueT-=element.scrollTop || 0; valueL-=element.scrollLeft || 0;}while(element=element.parentNode); return [valueL, valueT];}, clone: function(source, target){ var options=Object.extend({ setLeft: true, setTop: true, setWidth: true, setHeight: true, offsetTop: 0, offsetLeft: 0 }, arguments[2] ||{}); source=$(source); var p=Position.page(source); target=$(target); var delta=[0, 0]; var parent=null; if(Element.getStyle(target,'position')=='absolute'){ parent=Position.offsetParent(target); delta=Position.page(parent);} | |
26 | + if(parent==document.body){ delta[0]-=document.body.offsetLeft; delta[1]-=document.body.offsetTop;} | |
27 | + if(options.setLeft)target.style.left=(p[0]-delta[0]+options.offsetLeft)+'px'; if(options.setTop)target.style.top=(p[1]-delta[1]+options.offsetTop)+'px'; if(options.setWidth)target.style.width=source.offsetWidth+'px'; if(options.setHeight)target.style.height=source.offsetHeight+'px';}, absolutize: function(element){ element=$(element); if(element.style.position=='absolute')return; Position.prepare(); var offsets=Position.positionedOffset(element); var top=offsets[1]; var left=offsets[0]; var width=element.clientWidth; var height=element.clientHeight; element._originalLeft=left-parseFloat(element.style.left || 0); element._originalTop=top-parseFloat(element.style.top || 0); element._originalWidth=element.style.width; element._originalHeight=element.style.height; element.style.position='absolute'; element.style.top=top+'px';; element.style.left=left+'px';; element.style.width=width+'px';; element.style.height=height+'px';;}, relativize: function(element){ element=$(element); if(element.style.position=='relative')return; Position.prepare(); element.style.position='relative'; var top=parseFloat(element.style.top || 0)-(element._originalTop || 0); var left=parseFloat(element.style.left || 0)-(element._originalLeft || 0); element.style.top=top+'px'; element.style.left=left+'px'; element.style.height=element._originalHeight; element.style.width=element._originalWidth;}}; | |
0 | 28 | \ No newline at end of file | ... | ... |
865 Bytes
... | ... | @@ -0,0 +1,322 @@ |
1 | +/*---------------------------------------------------------------------------- | |
2 | + RICHDRAW 1.0 | |
3 | + Vector Graphics Drawing Script | |
4 | + ----------------------------------------------------------------------------- | |
5 | + Created by Mark Finkle (mark.finkle@gmail.com) | |
6 | + Implementation of simple vector graphic drawing control using SVG or VML. | |
7 | + ----------------------------------------------------------------------------- | |
8 | + Copyright (c) 2006 Mark Finkle | |
9 | + | |
10 | + This program is free software; you can redistribute it and/or modify it | |
11 | + under the terms of the MIT License. | |
12 | + | |
13 | + Permission is hereby granted, free of charge, to any person obtaining a | |
14 | + copy of this software and associated documentation files (the "Software"), | |
15 | + to deal in the Software without restriction, including without limitation | |
16 | + the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
17 | + and/or sell copies of the Software, and to permit persons to whom the | |
18 | + Software is furnished to do so, subject to the following conditions: | |
19 | + The above copyright notice and this permission notice shall be included in | |
20 | + all copies or substantial portions of the Software. | |
21 | + | |
22 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
23 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
24 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
25 | + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
26 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
27 | + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
28 | + DEALINGS IN THE SOFTWARE. | |
29 | + ----------------------------------------------------------------------------- | |
30 | + Dependencies: (SVG or VML rendering implementations) | |
31 | + History: | |
32 | + 2006-04-05 | Created | |
33 | + --------------------------------------------------------------------------*/ | |
34 | + | |
35 | + | |
36 | +function RichDrawEditor(elem, renderer) { | |
37 | + this.container = elem; | |
38 | + this.gridX = 10; | |
39 | + this.gridY = 10; | |
40 | + this.mouseDownX = 0; | |
41 | + this.mouseDownY = 0; | |
42 | + this.mode = ''; | |
43 | + this.fillColor = ''; | |
44 | + this.lineColor = ''; | |
45 | + this.lineWidth = ''; | |
46 | + this.selected = null; | |
47 | + this.selectedBounds = { x:0, y:0, width:0, height: 0 }; | |
48 | + | |
49 | + this.onselect = function() {}; | |
50 | + this.onunselect = function() {}; | |
51 | + | |
52 | + this.renderer = renderer; | |
53 | + this.renderer.init(this.container); | |
54 | + this.fecha = function() | |
55 | + { | |
56 | + pontosdistobj = new pontosdist(); | |
57 | + elem.innerHTML = ""; | |
58 | + elem.style.display="none"; | |
59 | + mudaiconf("pan"); | |
60 | + if(document.getElementById("mostradistancia")) | |
61 | + {document.getElementById("mostradistancia").style.display="none";} | |
62 | + } | |
63 | + | |
64 | +/* | |
65 | + //this.onMouseDownListener = this.onMouseDown.bindAsEventListener(this); | |
66 | + this.onClickListener = this.onClick.bindAsEventListener(this); | |
67 | + this.onMouseUpListener = this.onMouseUp.bindAsEventListener(this); | |
68 | + this.onDragListener = this.onDrag.bindAsEventListener(this); | |
69 | + this.onResizeListener = this.onResize.bindAsEventListener(this); | |
70 | + this.onDrawListener = this.onDraw.bindAsEventListener(this); | |
71 | + | |
72 | + this.onHitListener = this.onHit.bindAsEventListener(this); | |
73 | + | |
74 | + this.onSelectStartListener = this.onSelectStart.bindAsEventListener(this); | |
75 | + | |
76 | + //Event.observe(this.container, "mousedown", this.onMouseDownListener); | |
77 | + Event.observe(this.container, "mouseclick", this.onClickListener); | |
78 | + Event.observe(this.container, "mouseup", this.onMouseUpListener); | |
79 | + Event.observe(this.container, "selectstart", this.onSelectStartListener); | |
80 | +*/ | |
81 | +} | |
82 | + | |
83 | + | |
84 | +RichDrawEditor.prototype.clearWorkspace = function() { | |
85 | + this.container.innerHTML = ''; | |
86 | +}; | |
87 | + | |
88 | + | |
89 | +RichDrawEditor.prototype.deleteSelection = function() { | |
90 | + if (this.selected) { | |
91 | + this.renderer.remove(this.container.ownerDocument.getElementById('tracker')); | |
92 | + this.renderer.remove(this.selected); | |
93 | + this.selected = null; | |
94 | + } | |
95 | +}; | |
96 | + | |
97 | + | |
98 | +RichDrawEditor.prototype.select = function(elem) { | |
99 | + if (elem == this.selected) | |
100 | + return; | |
101 | + | |
102 | + this.selected = elem; | |
103 | + this.renderer.showTracker(this.selected); | |
104 | + this.onselect(this); | |
105 | +}; | |
106 | + | |
107 | + | |
108 | +RichDrawEditor.prototype.unselect = function() { | |
109 | + if (this.selected) { | |
110 | + this.renderer.remove(this.container.ownerDocument.getElementById('tracker')); | |
111 | + this.selected = null; | |
112 | + this.onunselect(this); | |
113 | + } | |
114 | +}; | |
115 | + | |
116 | + | |
117 | +RichDrawEditor.prototype.getSelectedElement = function() { | |
118 | + return this.selected; | |
119 | +}; | |
120 | + | |
121 | + | |
122 | +RichDrawEditor.prototype.setGrid = function(horizontal, vertical) { | |
123 | + this.gridX = horizontal; | |
124 | + this.gridY = vertical; | |
125 | +}; | |
126 | + | |
127 | + | |
128 | +RichDrawEditor.prototype.editCommand = function(cmd, value) | |
129 | +{ | |
130 | + if (cmd == 'mode') { | |
131 | + this.mode = value; | |
132 | + } | |
133 | + else if (this.selected == null) { | |
134 | + if (cmd == 'fillcolor') { | |
135 | + this.fillColor = value; | |
136 | + } | |
137 | + else if (cmd == 'linecolor') { | |
138 | + this.lineColor = value; | |
139 | + } | |
140 | + else if (cmd == 'linewidth') { | |
141 | + this.lineWidth = parseInt(value) + 'px'; | |
142 | + } | |
143 | + } | |
144 | + else { | |
145 | + this.renderer.editCommand(this.selected, cmd, value); | |
146 | + } | |
147 | +}; | |
148 | + | |
149 | + | |
150 | +RichDrawEditor.prototype.queryCommand = function(cmd) | |
151 | +{ | |
152 | + if (cmd == 'mode') { | |
153 | + return this.mode; | |
154 | + } | |
155 | + else if (this.selected == null) { | |
156 | + if (cmd == 'fillcolor') { | |
157 | + return this.fillColor; | |
158 | + } | |
159 | + else if (cmd == 'linecolor') { | |
160 | + return this.lineColor; | |
161 | + } | |
162 | + else if (cmd == 'linewidth') { | |
163 | + return this.lineWidth; | |
164 | + } | |
165 | + } | |
166 | + else { | |
167 | + return this.renderer.queryCommand(this.selected, cmd); | |
168 | + } | |
169 | +}; | |
170 | + | |
171 | + | |
172 | +RichDrawEditor.prototype.onSelectStart = function(event) { | |
173 | + return false; | |
174 | +}; | |
175 | + | |
176 | +RichDrawEditor.prototype.onClick = function(event) { | |
177 | + var offset = Position.cumulativeOffset(this.container); | |
178 | + var snappedX = Math.round((Event.pointerX(event) - offset[0]) / this.gridX) * this.gridX; | |
179 | + var snappedY = Math.round((Event.pointerY(event) - offset[1]) / this.gridY) * this.gridY; | |
180 | + if (this.mode != 'select') { | |
181 | + this.unselect(); | |
182 | + this.mouseDownX = snappedX; | |
183 | + this.mouseDownY = snappedY; | |
184 | + this.selected = this.renderer.create(this.mode, this.fillColor, this.lineColor, this.lineWidth, this.mouseDownX, this.mouseDownY, 1, 1); | |
185 | + this.selected.id = 'shape:' + createUUID(); | |
186 | + Event.observe(this.selected, "mousemove", this.onHitListener); | |
187 | + Event.observe(this.container, "mousemove", this.onDrawListener); | |
188 | + | |
189 | + } | |
190 | + else { | |
191 | + if (this.mouseDownX != snappedX || this.mouseDownY != snappedY) | |
192 | + this.unselect(); | |
193 | + } | |
194 | + | |
195 | + return false; | |
196 | +}; | |
197 | + | |
198 | + | |
199 | +RichDrawEditor.prototype.onMouseDown = function(event) { | |
200 | + var offset = Position.cumulativeOffset(this.container); | |
201 | + var snappedX = Math.round((Event.pointerX(event) - offset[0]) / this.gridX) * this.gridX; | |
202 | + var snappedY = Math.round((Event.pointerY(event) - offset[1]) / this.gridY) * this.gridY; | |
203 | + if (this.mode != 'select') { | |
204 | + this.unselect(); | |
205 | + this.mouseDownX = snappedX; | |
206 | + this.mouseDownY = snappedY; | |
207 | + this.selected = this.renderer.create(this.mode, this.fillColor, this.lineColor, this.lineWidth, this.mouseDownX, this.mouseDownY, 1, 1); | |
208 | + this.selected.id = 'shape:' + createUUID(); | |
209 | + Event.observe(this.selected, "mousedown", this.onHitListener); | |
210 | + Event.observe(this.container, "mousemove", this.onDrawListener); | |
211 | + } | |
212 | + else { | |
213 | + if (this.mouseDownX != snappedX || this.mouseDownY != snappedY) | |
214 | + this.unselect(); | |
215 | + } | |
216 | + | |
217 | + return false; | |
218 | +}; | |
219 | + | |
220 | + | |
221 | +RichDrawEditor.prototype.onMouseUp = function(event) { | |
222 | + Event.stopObserving(this.container, "mouseup", this.onDrawListener); | |
223 | + Event.stopObserving(this.container, "mouseup", this.onDragListener); | |
224 | + | |
225 | + if (this.mode != 'select') { | |
226 | + this.selected = null; | |
227 | + } | |
228 | +}; | |
229 | + | |
230 | + | |
231 | +RichDrawEditor.prototype.onDrag = function(event) { | |
232 | + var offset = Position.cumulativeOffset(this.container); | |
233 | + var snappedX = Math.round((Event.pointerX(event) - offset[0]) / this.gridX) * this.gridX; | |
234 | + var snappedY = Math.round((Event.pointerY(event) - offset[1]) / this.gridY) * this.gridY; | |
235 | + | |
236 | + var deltaX = snappedX - this.mouseDownX; | |
237 | + var deltaY = snappedY - this.mouseDownY; | |
238 | + this.renderer.move(this.selected, this.selectedBounds.x + deltaX, this.selectedBounds.y + deltaY); | |
239 | + // Update selection tracker | |
240 | + this.renderer.showTracker(this.selected); | |
241 | +// hide_tracker(); | |
242 | +}; | |
243 | + | |
244 | + | |
245 | +RichDrawEditor.prototype.onResize = function(event) { | |
246 | + var offset = Position.cumulativeOffset(this.container); | |
247 | + var snappedX = Math.round((Event.pointerX(event) - offset[0]) / this.gridX) * this.gridX; | |
248 | + var snappedY = Math.round((Event.pointerY(event) - offset[1]) / this.gridY) * this.gridY; | |
249 | + | |
250 | + var deltaX = snappedX - this.mouseDownX; | |
251 | + var deltaY = snappedY - this.mouseDownY; | |
252 | + | |
253 | + this.renderer.track(handle, deltaX, deltaY); | |
254 | + | |
255 | + // Update selection tracker | |
256 | + show_tracker(); | |
257 | +// hide_tracker(); | |
258 | +}; | |
259 | + | |
260 | +// | |
261 | +//o elemento está sendo desenhado | |
262 | +// | |
263 | +RichDrawEditor.prototype.onDraw = function(event) { | |
264 | + if (this.selected == null) | |
265 | + return; | |
266 | + | |
267 | + var offset = Position.cumulativeOffset(this.container); | |
268 | + var snappedX = Math.round((Event.pointerX(event) - offset[0]) / this.gridX) * this.gridX; | |
269 | + var snappedY = Math.round((Event.pointerY(event) - offset[1]) / this.gridY) * this.gridY; | |
270 | + this.renderer.resize(this.selected, this.mouseDownX, this.mouseDownY, snappedX, snappedY); | |
271 | +}; | |
272 | + | |
273 | + | |
274 | +RichDrawEditor.prototype.onHit = function(event) { | |
275 | + if (this.mode == 'select') { | |
276 | + this.select(Event.element(event)); | |
277 | + this.selectedBounds = this.renderer.bounds(this.selected); | |
278 | + | |
279 | + var offset = Position.cumulativeOffset(this.container); | |
280 | + this.mouseDownX = Math.round((Event.pointerX(event) - offset[0]) / this.gridX) * this.gridX; | |
281 | + this.mouseDownY = Math.round((Event.pointerY(event) - offset[1]) / this.gridY) * this.gridY; | |
282 | + | |
283 | + Event.observe(this.container, "mousemove", this.onDragListener); | |
284 | + } | |
285 | +}; | |
286 | + | |
287 | + | |
288 | +function createUUID() | |
289 | +{ | |
290 | + return [4, 2, 2, 2, 6].map(function(length) { | |
291 | + var uuidpart = ""; | |
292 | + for (var i=0; i<length; i++) { | |
293 | + var uuidchar = parseInt((Math.random() * 256)).toString(16); | |
294 | + if (uuidchar.length == 1) | |
295 | + uuidchar = "0" + uuidchar; | |
296 | + uuidpart += uuidchar; | |
297 | + } | |
298 | + return uuidpart; | |
299 | + }).join('-'); | |
300 | +} | |
301 | + | |
302 | +//---------------------------------------------------------------------------- | |
303 | +// AbstractRenderer | |
304 | +// | |
305 | +// Abstract base class defining the drawing API. Can not be used directly. | |
306 | +//---------------------------------------------------------------------------- | |
307 | + | |
308 | +function AbstractRenderer() { | |
309 | + | |
310 | +}; | |
311 | + | |
312 | +AbstractRenderer.prototype.init = function(elem) {}; | |
313 | +AbstractRenderer.prototype.bounds = function(shape) { return { x:0, y:0, width:0, height: 0 }; }; | |
314 | +AbstractRenderer.prototype.create = function(shape, fillColor, lineColor, lineWidth, left, top, width, height) {}; | |
315 | +AbstractRenderer.prototype.remove = function(shape) {}; | |
316 | +AbstractRenderer.prototype.move = function(shape, left, top) {}; | |
317 | +AbstractRenderer.prototype.track = function(shape) {}; | |
318 | +AbstractRenderer.prototype.resize = function(shape, fromX, fromY, toX, toY) {}; | |
319 | +AbstractRenderer.prototype.editCommand = function(shape, cmd, value) {}; | |
320 | +AbstractRenderer.prototype.queryCommand = function(shape, cmd) {}; | |
321 | +AbstractRenderer.prototype.showTracker = function(shape) {}; | |
322 | +AbstractRenderer.prototype.getMarkup = function() { return null; }; | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(c/a))+String.fromCharCode(c%a+161)};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\[\xa1-\xff]+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp(e(c),'g'),k[c])}}return p}('¢ ª(¼,«){¡.¬=¼;¡.¯=ë;¡.®=ë;¡.¸=0;¡.¶=0;¡.·=\'\';¡.Ä=\'\';¡.Å=\'\';¡.Á=\'\';¡.¤=»;¡.Í={x:0,y:0,Ï:0,Ö:0};¡.Ü=¢(){};¡.ï=¢(){};¡.«=«;¡.«.ê(¡.¬);¡.¢¡=¢(){þ=ÿ ý();¼.Þ="";¼.í.ö="õ";ú("ù");¦(ì.Ê("Ý")){ì.Ê("Ý").í.ö="õ"}}}ª.£.û=¢(){¡.¬.Þ=\'\'};ª.£.ü=¢(){¦(¡.¤){¡.«.Î(¡.¬.Û.Ê(\'å\'));¡.«.Î(¡.¤);¡.¤=»}};ª.£.À=¢(¼){¦(¼==¡.¤);¡.¤=¼;¡.«.Ø(¡.¤);¡.Ü(¡)};ª.£.Ç=¢(){¦(¡.¤){¡.«.Î(¡.¬.Û.Ê(\'å\'));¡.¤=»;¡.ï(¡)}};ª.£.ø=¢(){ ¡.¤};ª.£.÷=¢(Ú,î){¡.¯=Ú;¡.®=î};ª.£.Ð=¢(°,½){¦(°==\'·\'){¡.·=½}º ¦(¡.¤==»){¦(°==\'ñ\'){¡.Ä=½}º ¦(°==\'ò\'){¡.Å=½}º ¦(°==\'ß\'){¡.Á=ç(½)+\'¢º\'}}º{¡.«.Ð(¡.¤,°,½)}};ª.£.Ò=¢(°){¦(°==\'·\'){ ¡.·}º ¦(¡.¤==»){¦(°==\'ñ\'){ ¡.Ä}º ¦(°==\'ò\'){ ¡.Å}º ¦(°==\'ß\'){ ¡.Á}}º{ ¡.«.Ò(¡.¤,°)}};ª.£.¢³=¢(§){ Ô};ª.£.¢²=¢(§){¥ ©=¾.¿(¡.¬);¥ ´=±.µ((¨.Ã(§)-©[0])/¡.¯)*¡.¯;¥ ³=±.µ((¨.Â(§)-©[1])/¡.®)*¡.®;¦(¡.·!=\'À\'){¡.Ç();¡.¸=´;¡.¶=³;¡.¤=¡.«.Ó(¡.·,¡.Ä,¡.Å,¡.Á,¡.¸,¡.¶,1,1);¡.¤.â=\'¹:\'+×();¨.È(¡.¤,"Ë",¡.ã);¨.È(¡.¬,"Ë",¡.Õ)}º{¦(¡.¸!=´||¡.¶!=³)¡.Ç()} Ô};ª.£.¢±=¢(§){¥ ©=¾.¿(¡.¬);¥ ´=±.µ((¨.Ã(§)-©[0])/¡.¯)*¡.¯;¥ ³=±.µ((¨.Â(§)-©[1])/¡.®)*¡.®;¦(¡.·!=\'À\'){¡.Ç();¡.¸=´;¡.¶=³;¡.¤=¡.«.Ó(¡.·,¡.Ä,¡.Å,¡.Á,¡.¸,¡.¶,1,1);¡.¤.â=\'¹:\'+×();¨.È(¡.¤,"¢°",¡.ã);¨.È(¡.¬,"Ë",¡.Õ)}º{¦(¡.¸!=´||¡.¶!=³)¡.Ç()} Ô};ª.£.¢´=¢(§){¨.á(¡.¬,"à",¡.Õ);¨.á(¡.¬,"à",¡.ä);¦(¡.·!=\'À\'){¡.¤=»}};ª.£.¢µ=¢(§){¥ ©=¾.¿(¡.¬);¥ ´=±.µ((¨.Ã(§)-©[0])/¡.¯)*¡.¯;¥ ³=±.µ((¨.Â(§)-©[1])/¡.®)*¡.®;¥ É=´-¡.¸;¥ Ì=³-¡.¶;¡.«.æ(¡.¤,¡.Í.x+É,¡.Í.y+Ì);¡.«.Ø(¡.¤)};ª.£.¢¹=¢(§){¥ ©=¾.¿(¡.¬);¥ ´=±.µ((¨.Ã(§)-©[0])/¡.¯)*¡.¯;¥ ³=±.µ((¨.Â(§)-©[1])/¡.®)*¡.®;¥ É=´-¡.¸;¥ Ì=³-¡.¶;¡.«.ð(¢¸,É,Ì);¢·()};ª.£.¢¶=¢(§){¦(¡.¤==»);¥ ©=¾.¿(¡.¬);¥ ´=±.µ((¨.Ã(§)-©[0])/¡.¯)*¡.¯;¥ ³=±.µ((¨.Â(§)-©[1])/¡.®)*¡.®;¡.«.é(¡.¤,¡.¸,¡.¶,´,³)};ª.£.¢¯=¢(§){¦(¡.·==\'À\'){¡.À(¨.¢®(§));¡.Í=¡.«.ô(¡.¤);¥ ©=¾.¿(¡.¬);¡.¸=±.µ((¨.Ã(§)-©[0])/¡.¯)*¡.¯;¡.¶=±.µ((¨.Â(§)-©[1])/¡.®)*¡.®;¨.È(¡.¬,"Ë",¡.ä)}};¢ ×(){[4,2,2,2,6].¢¤(¢(Ù){¥ Ñ="";¢¨(¥ i=0;i<Ù;i++){¥ Æ=ç((±.¢©()*¢)).¢¬(¢«);¦(Æ.Ù==1)Æ="0"+Æ;Ñ+=Æ} Ñ}).¢ª(\'-\')}¢ ²(){};².£.ê=¢(¼){};².£.ô=¢(¹){{x:0,y:0,Ï:0,Ö:0}};².£.Ó=¢(¹,Ä,Å,Á,è,ó,Ï,Ö){};².£.Î=¢(¹){};².£.æ=¢(¹,è,ó){};².£.ð=¢(¹){};².£.é=¢(¹,¢£,¢¥,¢¦,¢§){};².£.Ð=¢(¹,°,½){};².£.Ò=¢(¹,°){};².£.Ø=¢(¹){};².£.¢¢=¢(){ »};',95,121,'this|function|prototype|selected|var|if|event|Event|offset|RichDrawEditor|renderer|container|return|gridY|gridX|cmd|Math|AbstractRenderer|snappedY|snappedX|round|mouseDownY|mode|mouseDownX|shape|else|null|elem|value|Position|cumulativeOffset|select|lineWidth|pointerY|pointerX|fillColor|lineColor|uuidchar|unselect|observe|deltaX|getElementById|mousemove|deltaY|selectedBounds|remove|width|editCommand|uuidpart|queryCommand|create|false|onDrawListener|height|createUUID|showTracker|length|horizontal|ownerDocument|onselect|mostradistancia|innerHTML|linewidth|mouseup|stopObserving|id|onHitListener|onDragListener|tracker|move|parseInt|left|resize|init|10|document|style|vertical|onunselect|track|fillcolor|linecolor|top|bounds|none|display|setGrid|getSelectedElement|pan|mudaiconf|clearWorkspace|deleteSelection|pontosdist|pontosdistobj|new|fecha|getMarkup|fromX|map|fromY|toX|toY|for|random|join|16|toString|256|element|onHit|mousedown|onMouseDown|onClick|onSelectStart|onMouseUp|onDrag|onDraw|show_tracker|handle|onResize|px'.split('|'),0,{})) | ... | ... |
... | ... | @@ -0,0 +1,158 @@ |
1 | +<html> | |
2 | +<head> | |
3 | + <title>RichDraw Demo</title> | |
4 | + <!-- | |
5 | + <script type="text/javascript" src="prototype.js"></script> | |
6 | + <script type="text/javascript" src="richdraw.js"></script> | |
7 | + <script type="text/javascript" src="svgrenderer_compacto.js"></script> | |
8 | + <script type="text/javascript" src="vmlrenderer.js"></script> | |
9 | +--> | |
10 | + <script type="text/javascript" src="richdraw_tudo_compacto.js"></script> | |
11 | + | |
12 | + <script type="text/javascript"> | |
13 | + var c; | |
14 | + function demo() { | |
15 | + var renderer; | |
16 | + | |
17 | + ie = navigator.appVersion.match(/MSIE (\d\.\d)/); | |
18 | + opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1); | |
19 | + if ((!ie) || (opera)) { | |
20 | + renderer = new SVGRenderer(); | |
21 | + } | |
22 | + else { | |
23 | + renderer = new VMLRenderer(); | |
24 | + } | |
25 | + | |
26 | + c = new RichDrawEditor(document.getElementById('richdraw'), renderer); | |
27 | + c.onselect = onSelect; | |
28 | + c.onunselect = onUnselect; | |
29 | + | |
30 | + c.editCommand('fillcolor', 'red'); | |
31 | + c.editCommand('linecolor', 'black'); | |
32 | + c.editCommand('linewidth', '1px'); | |
33 | + setMode('rect', 'Rectangle'); | |
34 | + | |
35 | + $('fillcolor').style.backgroundColor = 'red'; | |
36 | + $('linecolor').style.backgroundColor = 'black'; | |
37 | + } | |
38 | + | |
39 | + function setMode(mode, status) { | |
40 | + c.editCommand('mode', mode); | |
41 | + | |
42 | + var imgs = $('toolbar').getElementsByTagName('img'); | |
43 | + for (var i=0; i<imgs.length; i++) { | |
44 | + imgs[i].style.backgroundColor = ''; | |
45 | + } | |
46 | + $(mode).style.backgroundColor = 'orange'; | |
47 | + | |
48 | + if (mode == 'select') | |
49 | + $('status').innerHTML = 'Mode: Select/Move' ; | |
50 | + else | |
51 | + $('status').innerHTML = 'Mode: Draw ' + status; | |
52 | + } | |
53 | + | |
54 | + function deleteShape() { | |
55 | + c.deleteSelection(); | |
56 | + } | |
57 | + | |
58 | + function setFillColor(colors) { | |
59 | + var color = colors.options[colors.selectedIndex].value; | |
60 | + colors.style.backgroundColor = color; | |
61 | + | |
62 | + c.editCommand('fillcolor', color); | |
63 | + } | |
64 | + | |
65 | + function setLineColor(colors) { | |
66 | + var color = colors.options[colors.selectedIndex].value; | |
67 | + colors.style.backgroundColor = color; | |
68 | + | |
69 | + c.editCommand('linecolor', color); | |
70 | + } | |
71 | + | |
72 | + function setLineWidth(widths) { | |
73 | + var width = widths.options[widths.selectedIndex].value; | |
74 | + c.editCommand('linewidth', width); | |
75 | + } | |
76 | + | |
77 | + function getOptionByValue(select, value) | |
78 | + { | |
79 | + for (var i=0; i<select.length; i++) { | |
80 | + if (select.options[i].value == value) { | |
81 | + return i; | |
82 | + } | |
83 | + } | |
84 | + return -1; | |
85 | + } | |
86 | + | |
87 | + function showMarkup() { | |
88 | + alert(c.renderer.getMarkup()); | |
89 | + } | |
90 | + | |
91 | + function onSelect() { | |
92 | + $('fillcolor').selectedIndex = getOptionByValue($('fillcolor'), c.queryCommand('fillcolor')); | |
93 | + $('fillcolor').style.backgroundColor = c.queryCommand('fillcolor'); | |
94 | + $('linecolor').selectedIndex = getOptionByValue($('linecolor'), c.queryCommand('linecolor')); | |
95 | + $('linecolor').style.backgroundColor = c.queryCommand('linecolor'); | |
96 | + $('linewidth').selectedIndex = getOptionByValue($('linewidth'), c.queryCommand('linewidth')); | |
97 | + } | |
98 | + | |
99 | + function onUnselect() { | |
100 | + $('fillcolor').selectedIndex = getOptionByValue($('fillcolor'), c.queryCommand('fillcolor')); | |
101 | + $('fillcolor').style.backgroundColor = c.queryCommand('fillcolor'); | |
102 | + $('linecolor').selectedIndex = getOptionByValue($('linecolor'), c.queryCommand('linecolor')); | |
103 | + $('linecolor').style.backgroundColor = c.queryCommand('linecolor'); | |
104 | + $('linewidth').selectedIndex = getOptionByValue($('linewidth'), c.queryCommand('linewidth')); | |
105 | + } | |
106 | + </script> | |
107 | + <style> | |
108 | + body { font-family:verdana,arial; font-size:10pt; } | |
109 | + div * { vertical-align: middle; } | |
110 | + div img { padding:2px; border:2px solid orange;} | |
111 | + </style> | |
112 | +</head> | |
113 | +<body onload="demo();"> | |
114 | + <h2>RichDraw Demo</h2> | |
115 | + <div id="toolbar" style="width:700px; padding:5px; margin-bottom:5px; background-color:wheat;"> | |
116 | + <img id="select" title="Select shapes" onclick="setMode('select', 'Selection');" src="select.gif" /> | |
117 | + <span> | </span> | |
118 | + <img id="rect" title="Draw a rectangle" onclick="setMode('rect', 'Rectangle');" src="rectangle.gif" /> | |
119 | + <img id="roundrect" title="Draw a rounded rectangle" onclick="setMode('roundrect', 'Rounded Rectangle');" src="roundrect.gif" /> | |
120 | + <img id="ellipse" title="Draw an ellipse" onclick="setMode('ellipse', 'Ellipse / Circle');" src="circle.gif" /> | |
121 | + <img id="line" title="Draw a line" onclick="setMode('line', 'Line');" src="line.gif" /> | |
122 | + <span> | </span> | |
123 | + <img id="delete" title="Delete selected shape" onclick="deleteShape();" src="delete.gif" /> | |
124 | + <span> | </span> | |
125 | + <img id="showmarkup" title="Show the raw markup" onclick="showMarkup();" src="viewcode.gif" /> | |
126 | + <span> | </span> | |
127 | + <span>Fill:</span> | |
128 | + <select id="fillcolor" onchange="setFillColor(this);"> | |
129 | + <option style="background-color:red;" value="red"></option> | |
130 | + <option style="background-color:blue;" value="blue"></option> | |
131 | + <option style="background-color:green;" value="green"></option> | |
132 | + <option style="background-color:yellow;" value="yellow"></option> | |
133 | + <option style="background-color:aqua;" value="aqua"></option> | |
134 | + <option style="background-color:white;" value="">None</option> | |
135 | + </select> | |
136 | + <span>Line:</span> | |
137 | + <select id="linecolor" onchange="setLineColor(this);"> | |
138 | + <option style="background-color:black;" value="black"></option> | |
139 | + <option style="background-color:red;" value="red"></option> | |
140 | + <option style="background-color:blue;" value="blue"></option> | |
141 | + <option style="background-color:green;" value="green"></option> | |
142 | + <option style="background-color:yellow;" value="yellow"></option> | |
143 | + <option style="background-color:aqua;" value="aqua"></option> | |
144 | + <option style="background-color:white;" value="">None</option> | |
145 | + </select> | |
146 | + <select id="linewidth" onchange="setLineWidth(this);"> | |
147 | + <option value="1px">1px</option> | |
148 | + <option value="2px">2px</option> | |
149 | + <option value="3px">3px</option> | |
150 | + <option value="5px">5px</option> | |
151 | + <option value="7px">7px</option> | |
152 | + </select> | |
153 | + </div> | |
154 | + <div id="richdraw" style="position:relative; width:700px; height:500px; border:1px solid black;"> | |
155 | + </div> | |
156 | + <div id="status" style="width:700px; padding:5px; margin-top:5px; background-color:wheat;">Mode: Draw Rectangle</div> | |
157 | +</body> | |
158 | +</html> | ... | ... |
... | ... | @@ -0,0 +1,6 @@ |
1 | +eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(c/a))+String.fromCharCode(c%a+161)};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\[\xa1-\xff]+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp(e(c),'g'),k[c])}}return p}('¢ ª(¼,«){¡.¬=¼;¡.¯=ë;¡.®=ë;¡.¸=0;¡.¶=0;¡.·=\'\';¡.Ä=\'\';¡.Å=\'\';¡.Á=\'\';¡.¤=»;¡.Í={x:0,y:0,Ï:0,Ö:0};¡.Ü=¢(){};¡.ï=¢(){};¡.«=«;¡.«.ê(¡.¬);¡.¢¡=¢(){þ=ÿ ý();¼.Þ="";¼.í.ö="õ";ú("ù");¦(ì.Ê("Ý")){ì.Ê("Ý").í.ö="õ"}}}ª.£.û=¢(){¡.¬.Þ=\'\'};ª.£.ü=¢(){¦(¡.¤){¡.«.Î(¡.¬.Û.Ê(\'å\'));¡.«.Î(¡.¤);¡.¤=»}};ª.£.À=¢(¼){¦(¼==¡.¤);¡.¤=¼;¡.«.Ø(¡.¤);¡.Ü(¡)};ª.£.Ç=¢(){¦(¡.¤){¡.«.Î(¡.¬.Û.Ê(\'å\'));¡.¤=»;¡.ï(¡)}};ª.£.ø=¢(){ ¡.¤};ª.£.÷=¢(Ú,î){¡.¯=Ú;¡.®=î};ª.£.Ð=¢(°,½){¦(°==\'·\'){¡.·=½}º ¦(¡.¤==»){¦(°==\'ñ\'){¡.Ä=½}º ¦(°==\'ò\'){¡.Å=½}º ¦(°==\'ß\'){¡.Á=ç(½)+\'¢º\'}}º{¡.«.Ð(¡.¤,°,½)}};ª.£.Ò=¢(°){¦(°==\'·\'){ ¡.·}º ¦(¡.¤==»){¦(°==\'ñ\'){ ¡.Ä}º ¦(°==\'ò\'){ ¡.Å}º ¦(°==\'ß\'){ ¡.Á}}º{ ¡.«.Ò(¡.¤,°)}};ª.£.¢³=¢(§){ Ô};ª.£.¢²=¢(§){¥ ©=¾.¿(¡.¬);¥ ´=±.µ((¨.Ã(§)-©[0])/¡.¯)*¡.¯;¥ ³=±.µ((¨.Â(§)-©[1])/¡.®)*¡.®;¦(¡.·!=\'À\'){¡.Ç();¡.¸=´;¡.¶=³;¡.¤=¡.«.Ó(¡.·,¡.Ä,¡.Å,¡.Á,¡.¸,¡.¶,1,1);¡.¤.â=\'¹:\'+×();¨.È(¡.¤,"Ë",¡.ã);¨.È(¡.¬,"Ë",¡.Õ)}º{¦(¡.¸!=´||¡.¶!=³)¡.Ç()} Ô};ª.£.¢±=¢(§){¥ ©=¾.¿(¡.¬);¥ ´=±.µ((¨.Ã(§)-©[0])/¡.¯)*¡.¯;¥ ³=±.µ((¨.Â(§)-©[1])/¡.®)*¡.®;¦(¡.·!=\'À\'){¡.Ç();¡.¸=´;¡.¶=³;¡.¤=¡.«.Ó(¡.·,¡.Ä,¡.Å,¡.Á,¡.¸,¡.¶,1,1);¡.¤.â=\'¹:\'+×();¨.È(¡.¤,"¢°",¡.ã);¨.È(¡.¬,"Ë",¡.Õ)}º{¦(¡.¸!=´||¡.¶!=³)¡.Ç()} Ô};ª.£.¢´=¢(§){¨.á(¡.¬,"à",¡.Õ);¨.á(¡.¬,"à",¡.ä);¦(¡.·!=\'À\'){¡.¤=»}};ª.£.¢µ=¢(§){¥ ©=¾.¿(¡.¬);¥ ´=±.µ((¨.Ã(§)-©[0])/¡.¯)*¡.¯;¥ ³=±.µ((¨.Â(§)-©[1])/¡.®)*¡.®;¥ É=´-¡.¸;¥ Ì=³-¡.¶;¡.«.æ(¡.¤,¡.Í.x+É,¡.Í.y+Ì);¡.«.Ø(¡.¤)};ª.£.¢¹=¢(§){¥ ©=¾.¿(¡.¬);¥ ´=±.µ((¨.Ã(§)-©[0])/¡.¯)*¡.¯;¥ ³=±.µ((¨.Â(§)-©[1])/¡.®)*¡.®;¥ É=´-¡.¸;¥ Ì=³-¡.¶;¡.«.ð(¢¸,É,Ì);¢·()};ª.£.¢¶=¢(§){¦(¡.¤==»);¥ ©=¾.¿(¡.¬);¥ ´=±.µ((¨.Ã(§)-©[0])/¡.¯)*¡.¯;¥ ³=±.µ((¨.Â(§)-©[1])/¡.®)*¡.®;¡.«.é(¡.¤,¡.¸,¡.¶,´,³)};ª.£.¢¯=¢(§){¦(¡.·==\'À\'){¡.À(¨.¢®(§));¡.Í=¡.«.ô(¡.¤);¥ ©=¾.¿(¡.¬);¡.¸=±.µ((¨.Ã(§)-©[0])/¡.¯)*¡.¯;¡.¶=±.µ((¨.Â(§)-©[1])/¡.®)*¡.®;¨.È(¡.¬,"Ë",¡.ä)}};¢ ×(){[4,2,2,2,6].¢¤(¢(Ù){¥ Ñ="";¢¨(¥ i=0;i<Ù;i++){¥ Æ=ç((±.¢©()*¢)).¢¬(¢«);¦(Æ.Ù==1)Æ="0"+Æ;Ñ+=Æ} Ñ}).¢ª(\'-\')}¢ ²(){};².£.ê=¢(¼){};².£.ô=¢(¹){{x:0,y:0,Ï:0,Ö:0}};².£.Ó=¢(¹,Ä,Å,Á,è,ó,Ï,Ö){};².£.Î=¢(¹){};².£.æ=¢(¹,è,ó){};².£.ð=¢(¹){};².£.é=¢(¹,¢£,¢¥,¢¦,¢§){};².£.Ð=¢(¹,°,½){};².£.Ò=¢(¹,°){};².£.Ø=¢(¹){};².£.¢¢=¢(){ »};',95,121,'this|function|prototype|selected|var|if|event|Event|offset|RichDrawEditor|renderer|container|return|gridY|gridX|cmd|Math|AbstractRenderer|snappedY|snappedX|round|mouseDownY|mode|mouseDownX|shape|else|null|elem|value|Position|cumulativeOffset|select|lineWidth|pointerY|pointerX|fillColor|lineColor|uuidchar|unselect|observe|deltaX|getElementById|mousemove|deltaY|selectedBounds|remove|width|editCommand|uuidpart|queryCommand|create|false|onDrawListener|height|createUUID|showTracker|length|horizontal|ownerDocument|onselect|mostradistancia|innerHTML|linewidth|mouseup|stopObserving|id|onHitListener|onDragListener|tracker|move|parseInt|left|resize|init|10|document|style|vertical|onunselect|track|fillcolor|linecolor|top|bounds|none|display|setGrid|getSelectedElement|pan|mudaiconf|clearWorkspace|deleteSelection|pontosdist|pontosdistobj|new|fecha|getMarkup|fromX|map|fromY|toX|toY|for|random|join|16|toString|256|element|onHit|mousedown|onMouseDown|onClick|onSelectStart|onMouseUp|onDrag|onDraw|show_tracker|handle|onResize|px'.split('|'),0,{})) | |
2 | + | |
3 | +eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(c/a))+String.fromCharCode(c%a+161)};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\[\xa1-\xff]+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp(e(c),'g'),k[c])}}return p}('° ¬(){©.ë=ç;©.Á=¡}¬.®=ä ç;¬.®.ê=°(â){©.¸=â;©.¸.è.é=\'¹\'; º=\'Ø://Ö.Õ.Ò/Ó/¤\';©.Á=©.¸.¿.½(º,"¤");©.¸.×(©.Á)};¬.®.í=°(¢){ µ=ä ï(); ¶=¢.¼();µ[\'x\']=¶.x;µ[\'y\']=¶.y;µ[\'§\']=¶.§;µ[\'ª\']=¶.ª;É µ};¬.®.î=°(¢,È,Æ,ã,±,³,§,ª){ º=\'Ø://Ö.Õ.Ò/Ó/¤\'; ¤;¦(¢==\'µ\'){¤=©.¸.¿.½(º,\'µ\');¤.£(¡,\'x\',±+\'¥\');¤.£(¡,\'y\',³+\'¥\');¤.£(¡,\'§\',§+\'¥\');¤.£(¡,\'ª\',ª+\'¥\')}¨ ¦(¢==\'Ç\'){¤=©.¸.¿.½(º,\'Ç\');¤.£(¡,\'Ã\',(±+§/2)+\'¥\');¤.£(¡,\'Ð\',(³+ª/2)+\'¥\');¤.£(¡,\'Ï\',(§/2)+\'¥\');¤.£(¡,\'Ê\',(ª/2)+\'¥\')}¨ ¦(¢==\'ð\'){¤=©.¸.¿.½(º,\'µ\');¤.£(¡,\'x\',±+\'¥\');¤.£(¡,\'y\',³+\'¥\');¤.£(¡,\'Ï\',\'Ú\');¤.£(¡,\'Ê\',\'Ú\');¤.£(¡,\'§\',§+\'¥\');¤.£(¡,\'ª\',ª+\'¥\')}¨ ¦(¢==\'Î\'){¤=©.¸.¿.½(º,\'Î\');¤.£(¡,\'á\',±+\'¥\');¤.£(¡,\'Ù\',³+\'¥\');¤.£(¡,\'Ñ\',±+\'¥\');¤.£(¡,\'Ô\',³+\'¥\')}¤.è.ì=\'ÿ\';¦(È.Þ==0)È=\'¹\';¤.£(¡,\'À\',È);¦(Æ.Þ==0)Æ=\'¹\';¤.£(¡,\'·\',Æ);¤.£(¡,\'·-§\',ã);©.Á.×(¤);É ¤};¬.®.Ý=°(¢){¢.û.ú(¢)};¬.®.ü=°(¢,±,³){¦(¢.Â==\'Î\'){ ²=¢.¼().§; ´=¢.¼().ª;¢.£(¡,\'á\',±);¢.£(¡,\'Ù\',³);¢.£(¡,\'Ñ\',±+²);¢.£(¡,\'Ô\',³+´)}¨ ¦(¢.Â==\'Ç\'){¢.£(¡,\'Ã\',±+(¢.¼().§/2));¢.£(¡,\'Ð\',³+(¢.¼().ª/2))}¨{¢.£(¡,\'x\',±);¢.£(¡,\'y\',³)}};¬.®.ý=°(¢){};¬.®.þ=°(¢,Ä,Ë,Ì,Í){ ²=Ì-Ä; ´=Í-Ë;¦(¢.Â==\'Î\'){¢.£(¡,\'Ñ\',Ì);¢.£(¡,\'Ô\',Í)}¨ ¦(¢.Â==\'Ç\'){¦(²<0){¢.£(¡,\'Ã\',(Ä+²/2)+\'¥\');¢.£(¡,\'Ï\',(-²/2)+\'¥\')}¨{¢.£(¡,\'Ã\',(Ä+²/2)+\'¥\');¢.£(¡,\'Ï\',(²/2)+\'¥\')}¦(´<0){¢.£(¡,\'Ð\',(Ë+´/2)+\'¥\');¢.£(¡,\'Ê\',(-´/2)+\'¥\')}¨{¢.£(¡,\'Ð\',(Ë+´/2)+\'¥\');¢.£(¡,\'Ê\',(´/2)+\'¥\')}}¨{¦(²<0){¢.£(¡,\'x\',Ì+\'¥\');¢.£(¡,\'§\',-²+\'¥\')}¨{¢.£(¡,\'§\',²+\'¥\')}¦(´<0){¢.£(¡,\'y\',Í+\'¥\');¢.£(¡,\'ª\',-´+\'¥\')}¨{¢.£(¡,\'ª\',´+\'¥\')}}};¬.®.ù=°(¢,»,¾){¦(¢!=¡){¦(»==\'å\'){¦(¾!=\'\')¢.£(¡,\'À\',¾);¨ ¢.£(¡,\'À\',\'¹\')}¨ ¦(»==\'æ\'){¦(¾!=\'\')¢.£(¡,\'·\',¾);¨ ¢.£(¡,\'·\',\'¹\')}¨ ¦(»==\'Û\'){¢.£(¡,\'·-§\',ø(¾)+\'¥\')}}};¬.®.ñ=°(¢,»){ ¯=\'\';¦(¢!=¡){¦(»==\'å\'){¯=¢.Å(¡,\'À\');¦(¯==\'¹\')¯=\'\'}¨ ¦(»==\'æ\'){¯=¢.Å(¡,\'·\');¦(¯==\'¹\')¯=\'\'}¨ ¦(»==\'Û\'){¯=¢.Å(¡,\'·\');¦(¯==\'¹\')¯=\'\';¨ ¯=¢.Å(¡,\'·-§\')}}É ¯};¬.®.ò=°(¢){ ¶=¢.¼(); «=Ü.ô(\'«\');¦(«){©.Ý(«)} º=\'Ø://Ö.Õ.Ò/Ó/¤\';«=Ü.½(º,\'µ\');«.£(¡,\'õ\',\'«\');«.£(¡,\'x\',¶.x-ß);«.£(¡,\'y\',¶.y-ß);«.£(¡,\'§\',¶.§+à);«.£(¡,\'ª\',¶.ª+à);«.£(¡,\'À\',\'¹\');«.£(¡,\'·\',\'÷\');«.£(¡,\'·-§\',\'1\');©.Á.×(«)};¬.®.ö=°(){É ©.¸.ó};',95,95,'null|shape|setAttributeNS|svg|px|if|width|else|this|height|tracker|SVGRenderer|var|prototype|result|function|left|deltaX|top|deltaY|rect|box|stroke|container|none|svgNamespace|cmd|getBBox|createElementNS|value|ownerDocument|fill|svgRoot|tagName|cx|fromX|getAttributeNS|lineColor|ellipse|fillColor|return|ry|fromY|toX|toY|line|rx|cy|x2|org|2000|y2|w3|www|appendChild|http|y1|20px|linewidth|document|remove|length|10|20|x1|elem|lineWidth|new|fillcolor|linecolor|AbstractRenderer|style|MozUserSelect|init|base|position|bounds|create|Object|roundrect|queryCommand|showTracker|innerHTML|getElementById|id|getMarkup|blue|parseInt|editCommand|removeChild|parentNode|move|track|resize|absolute'.split('|'),0,{})) | |
4 | + | |
5 | +eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(c/a))+String.fromCharCode(c%a+161)};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\[\xa1-\xff]+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp(e(c),'g'),k[c])}}return p}('¬ ª(){©.é=Í}ª.«=Ì Í;ª.«.ç=¬(Â){©.¯=Â;©.¯.£.å=\'æ\';Â.·.ê.ë("v","ï:î-í-ä:¤");¸ £=Â.·.ð();£.à(\'v\\\\:*\',"Ü: Û(#ß#á);")};ª.«.Õ=¬(¡){¸ ±=Ì â();±[\'x\']=¡.Þ;±[\'y\']=¡.Ý;±[\'³\']=¡.ì;±[\'µ\']=¡.¢©;° ±};ª.«.¢¢=¬(¡,È,Ç,Ð,,®,³,µ){¸ ¤;¢(¡==\'±\'){¤=©.¯.·.¿(\'v:±\')}¥ ¢(¡==\'Ë\'){¤=©.¯.·.¿(\'v:Ë\')}¥ ¢(¡==\'ñ\'){¤=©.¯.·.¿(\'v:þ\')}¥ ¢(¡==\'½\'){¤=©.¯.·.¿(\'v:½\')}¢(¡!=\'½\'){¤.£.Ê=\'É\';¤.£.=;¤.£.®=®;¤.£.³=³;¤.£.µ=µ;¢(È!=\'\'){¤.¨(\'¹\',\'º\');¤.¨(\'¼\',È)}¥{¤.¨(\'¹\',\'´\')}}¥{¤.£.Ê=\'É\';¤.¨(\'Ò\',+\'§,\'+®+\'§\');¤.¨(\'¢£\',+\'§,\'+®+\'§\')}¢(Ç!=\'\'){¤.¨(\'¶\',\'º\');¤.¨(\'¾\',Ç);¤.¨(\'Ã\',Ð)}¥{¤.¨(\'¶\',\'´\')}©.¯.×(¤);° ¤};ª.«.Ö=¬(¡){¡.¢¨(º)};ª.«.¢§=¬(¡,,®){¢(¡.Ñ==\'½\'){¡.£.¢¦=;¡.£.¢¥=®}¥{¡.£.=;¡.£.®=®}};ª.«.ý=¬(¡){};ª.«.ü=¬(¡,Ï,Î,Æ,Á){¸ Ä=Æ-Ï;¸ Å=Á-Î;¢(¡.Ñ==\'½\'){¡.¨(\'Ò\',Æ+\'§,\'+Á+\'§\')}¥{¢(Ä<0){¡.£.=Æ+\'§\';¡.£.³=-Ä+\'§\'}¥{¡.£.³=Ä+\'§\'}¢(Å<0){¡.£.®=Á+\'§\';¡.£.µ=-Å+\'§\'}¥{¡.£.µ=Å+\'§\'}}};ª.«.ú=¬(¡,²,»){¢(¡!=Ó){¢(²==\'¼\'){¢(»!=\'\'){¡.¹=\'º\';¡.¼=»}¥{¡.¹=\'´\';¡.¼=\'\'}}¥ ¢(²==\'Ú\'){¢(»!=\'\'){¡.¶=\'º\';¡.¾=»}¥{¡.¶=\'´\';¡.¾=\'\'}}¥ ¢(²==\'Ø\'){¡.Ã=ù(»)+\'§\'}}};ª.«.ø=¬(¡,²){¢(¡!=Ó){¢(²==\'¼\'){¢(¡.¹==\'´\')°\'\';¥ ° ¡.¼}¥ ¢(²==\'Ú\'){¢(¡.¶==\'´\')°\'\';¥ ° ¡.¾}¥ ¢(²==\'Ø\'){¢(¡.¶==\'´\'){°\'\'}¥{°(û(¡.Ã)*(÷.ö/ò))+\'§\'}}}};ª.«.ó=¬(¡){¸ À=©.Õ(¡);¸ ¦=ô.õ(\'¦\');¢(¦){©.Ö(¦)}¦=©.¯.·.¿(\'v:±\');¦.¢¤=\'¦\';¦.£.Ê=\'É\';¦.£.=À.x-Ô;¦.£.®=À.y-Ô;¦.£.³=À.³+Ù;¦.£.µ=À.µ+Ù;¦.¨(\'¹\',\'´\');¦.¨(\'¶\',\'º\');¦.¨(\'¾\',\'¢¡\');¦.¨(\'Ã\',\'ã\');©.¯.×(¦)};ª.«.è=¬(){° ©.¯.ÿ};',95,104,'shape|if|style|vml|else|tracker|px|setAttribute|this|VMLRenderer|prototype|function|left|top|container|return|rect|cmd|width|false|height|stroked|ownerDocument|var|filled|true|value|fillcolor|line|strokecolor|createElement|box|toY|elem|strokeweight|deltaX|deltaY|toX|lineColor|fillColor|absolute|position|roundrect|new|AbstractRenderer|fromY|fromX|lineWidth|tagName|from|null|10|bounds|remove|appendChild|linewidth|20|linecolor|url|behavior|offsetTop|offsetLeft|default|addRule|VML|Object|1px|com|overflow|hidden|init|getMarkup|base|namespaces|add|offsetWidth|microsoft|schemas|urn|createStyleSheet|ellipse|72|showTracker|document|getElementById|logicalXDPI|screen|queryCommand|parseInt|editCommand|parseFloat|resize|track|oval|innerHTML|blue|create|to|id|marginTop|marginLeft|move|removeNode|offsetHeight'.split('|'),0,{})) | |
6 | + | ... | ... |
893 Bytes
877 Bytes
... | ... | @@ -0,0 +1,271 @@ |
1 | +/*---------------------------------------------------------------------------- | |
2 | + SVGRENDERER 1.0 | |
3 | + SVG Renderer For RichDraw | |
4 | + ----------------------------------------------------------------------------- | |
5 | + Created by Mark Finkle (mark.finkle@gmail.com) | |
6 | + Implementation of SVG based renderer. | |
7 | + ----------------------------------------------------------------------------- | |
8 | + Copyright (c) 2006 Mark Finkle | |
9 | + | |
10 | + This program is free software; you can redistribute it and/or modify it | |
11 | + under the terms of the MIT License. | |
12 | + | |
13 | + Permission is hereby granted, free of charge, to any person obtaining a | |
14 | + copy of this software and associated documentation files (the "Software"), | |
15 | + to deal in the Software without restriction, including without limitation | |
16 | + the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
17 | + and/or sell copies of the Software, and to permit persons to whom the | |
18 | + Software is furnished to do so, subject to the following conditions: | |
19 | + The above copyright notice and this permission notice shall be included in | |
20 | + all copies or substantial portions of the Software. | |
21 | + | |
22 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
23 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
24 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
25 | + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
26 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
27 | + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
28 | + DEALINGS IN THE SOFTWARE. | |
29 | + ----------------------------------------------------------------------------- | |
30 | + Dependencies: | |
31 | + History: | |
32 | + 2006-04-05 | Created | |
33 | + --------------------------------------------------------------------------*/ | |
34 | + | |
35 | + | |
36 | +function SVGRenderer() { | |
37 | + this.base = AbstractRenderer; | |
38 | + this.svgRoot = null; | |
39 | +} | |
40 | + | |
41 | + | |
42 | +SVGRenderer.prototype = new AbstractRenderer; | |
43 | + | |
44 | + | |
45 | +SVGRenderer.prototype.init = function(elem) { | |
46 | + this.container = elem; | |
47 | + | |
48 | + this.container.style.MozUserSelect = 'none'; | |
49 | + | |
50 | + var svgNamespace = 'http://www.w3.org/2000/svg'; | |
51 | + this.svgRoot = this.container.ownerDocument.createElementNS(svgNamespace, "svg"); | |
52 | + this.container.appendChild(this.svgRoot); | |
53 | +}; | |
54 | + | |
55 | + | |
56 | +SVGRenderer.prototype.bounds = function(shape) { | |
57 | + var rect = new Object(); | |
58 | + var box = shape.getBBox(); | |
59 | + rect['x'] = box.x; | |
60 | + rect['y'] = box.y; | |
61 | + rect['width'] = box.width; | |
62 | + rect['height'] = box.height; | |
63 | + return rect; | |
64 | +}; | |
65 | + | |
66 | + | |
67 | +SVGRenderer.prototype.create = function(shape, fillColor, lineColor, lineWidth, left, top, width, height) { | |
68 | + var svgNamespace = 'http://www.w3.org/2000/svg'; | |
69 | + var svg; | |
70 | + | |
71 | + if (shape == 'rect') { | |
72 | + svg = this.container.ownerDocument.createElementNS(svgNamespace, 'rect'); | |
73 | + svg.setAttributeNS(null, 'x', left + 'px'); | |
74 | + svg.setAttributeNS(null, 'y', top + 'px'); | |
75 | + svg.setAttributeNS(null, 'width', width + 'px'); | |
76 | + svg.setAttributeNS(null, 'height', height + 'px'); | |
77 | + } | |
78 | + else if (shape == 'ellipse') { | |
79 | + svg = this.container.ownerDocument.createElementNS(svgNamespace, 'ellipse'); | |
80 | + svg.setAttributeNS(null, 'cx', (left + width / 2) + 'px'); | |
81 | + svg.setAttributeNS(null, 'cy', (top + height / 2) + 'px'); | |
82 | + svg.setAttributeNS(null, 'rx', (width / 2) + 'px'); | |
83 | + svg.setAttributeNS(null, 'ry', (height / 2) + 'px'); | |
84 | + } | |
85 | + else if (shape == 'roundrect') { | |
86 | + svg = this.container.ownerDocument.createElementNS(svgNamespace, 'rect'); | |
87 | + svg.setAttributeNS(null, 'x', left + 'px'); | |
88 | + svg.setAttributeNS(null, 'y', top + 'px'); | |
89 | + svg.setAttributeNS(null, 'rx', '20px'); | |
90 | + svg.setAttributeNS(null, 'ry', '20px'); | |
91 | + svg.setAttributeNS(null, 'width', width + 'px'); | |
92 | + svg.setAttributeNS(null, 'height', height + 'px'); | |
93 | + } | |
94 | + else if (shape == 'line') { | |
95 | + svg = this.container.ownerDocument.createElementNS(svgNamespace, 'line'); | |
96 | + svg.setAttributeNS(null, 'x1', left + 'px'); | |
97 | + svg.setAttributeNS(null, 'y1', top + 'px'); | |
98 | + svg.setAttributeNS(null, 'x2', left + 'px'); | |
99 | + svg.setAttributeNS(null, 'y2', top + 'px'); | |
100 | + } | |
101 | + | |
102 | + svg.style.position = 'absolute'; | |
103 | + | |
104 | + if (fillColor.length == 0) | |
105 | + fillColor = 'none'; | |
106 | + svg.setAttributeNS(null, 'fill', fillColor); | |
107 | + | |
108 | + if (lineColor.length == 0) | |
109 | + lineColor = 'none'; | |
110 | + svg.setAttributeNS(null, 'stroke', lineColor); | |
111 | + svg.setAttributeNS(null, 'stroke-width', lineWidth); | |
112 | + | |
113 | + this.svgRoot.appendChild(svg); | |
114 | + | |
115 | + return svg; | |
116 | +}; | |
117 | + | |
118 | + | |
119 | +SVGRenderer.prototype.remove = function(shape) { | |
120 | + shape.parentNode.removeChild(shape); | |
121 | +}; | |
122 | + | |
123 | + | |
124 | +SVGRenderer.prototype.move = function(shape, left, top) { | |
125 | + if (shape.tagName == 'line') { | |
126 | + var deltaX = shape.getBBox().width; | |
127 | + var deltaY = shape.getBBox().height; | |
128 | + shape.setAttributeNS(null, 'x1', left); | |
129 | + shape.setAttributeNS(null, 'y1', top); | |
130 | + shape.setAttributeNS(null, 'x2', left + deltaX); | |
131 | + shape.setAttributeNS(null, 'y2', top + deltaY); | |
132 | + } | |
133 | + else if (shape.tagName == 'ellipse') { | |
134 | + shape.setAttributeNS(null, 'cx', left + (shape.getBBox().width / 2)); | |
135 | + shape.setAttributeNS(null, 'cy', top + (shape.getBBox().height / 2)); | |
136 | + } | |
137 | + else { | |
138 | + shape.setAttributeNS(null, 'x', left); | |
139 | + shape.setAttributeNS(null, 'y', top); | |
140 | + } | |
141 | +}; | |
142 | + | |
143 | + | |
144 | +SVGRenderer.prototype.track = function(shape) { | |
145 | + // TODO | |
146 | +}; | |
147 | + | |
148 | + | |
149 | +SVGRenderer.prototype.resize = function(shape, fromX, fromY, toX, toY) { | |
150 | + var deltaX = toX - fromX; | |
151 | + var deltaY = toY - fromY; | |
152 | + | |
153 | + if (shape.tagName == 'line') { | |
154 | + shape.setAttributeNS(null, 'x2', toX); | |
155 | + shape.setAttributeNS(null, 'y2', toY); | |
156 | + } | |
157 | + else if (shape.tagName == 'ellipse') { | |
158 | + if (deltaX < 0) { | |
159 | + shape.setAttributeNS(null, 'cx', (fromX + deltaX / 2) + 'px'); | |
160 | + shape.setAttributeNS(null, 'rx', (-deltaX / 2) + 'px'); | |
161 | + } | |
162 | + else { | |
163 | + shape.setAttributeNS(null, 'cx', (fromX + deltaX / 2) + 'px'); | |
164 | + shape.setAttributeNS(null, 'rx', (deltaX / 2) + 'px'); | |
165 | + } | |
166 | + | |
167 | + if (deltaY < 0) { | |
168 | + shape.setAttributeNS(null, 'cy', (fromY + deltaY / 2) + 'px'); | |
169 | + shape.setAttributeNS(null, 'ry', (-deltaY / 2) + 'px'); | |
170 | + } | |
171 | + else { | |
172 | + shape.setAttributeNS(null, 'cy', (fromY + deltaY / 2) + 'px'); | |
173 | + shape.setAttributeNS(null, 'ry', (deltaY / 2) + 'px'); | |
174 | + } | |
175 | + } | |
176 | + else { | |
177 | + if (deltaX < 0) { | |
178 | + shape.setAttributeNS(null, 'x', toX + 'px'); | |
179 | + shape.setAttributeNS(null, 'width', -deltaX + 'px'); | |
180 | + } | |
181 | + else { | |
182 | + shape.setAttributeNS(null, 'width', deltaX + 'px'); | |
183 | + } | |
184 | + | |
185 | + if (deltaY < 0) { | |
186 | + shape.setAttributeNS(null, 'y', toY + 'px'); | |
187 | + shape.setAttributeNS(null, 'height', -deltaY + 'px'); | |
188 | + } | |
189 | + else { | |
190 | + shape.setAttributeNS(null, 'height', deltaY + 'px'); | |
191 | + } | |
192 | + } | |
193 | +}; | |
194 | + | |
195 | + | |
196 | +SVGRenderer.prototype.editCommand = function(shape, cmd, value) | |
197 | +{ | |
198 | + if (shape != null) { | |
199 | + if (cmd == 'fillcolor') { | |
200 | + if (value != '') | |
201 | + shape.setAttributeNS(null, 'fill', value); | |
202 | + else | |
203 | + shape.setAttributeNS(null, 'fill', 'none'); | |
204 | + } | |
205 | + else if (cmd == 'linecolor') { | |
206 | + if (value != '') | |
207 | + shape.setAttributeNS(null, 'stroke', value); | |
208 | + else | |
209 | + shape.setAttributeNS(null, 'stroke', 'none'); | |
210 | + } | |
211 | + else if (cmd == 'linewidth') { | |
212 | + shape.setAttributeNS(null, 'stroke-width', parseInt(value) + 'px'); | |
213 | + } | |
214 | + } | |
215 | +}; | |
216 | + | |
217 | + | |
218 | +SVGRenderer.prototype.queryCommand = function(shape, cmd) | |
219 | +{ | |
220 | + var result = ''; | |
221 | + | |
222 | + if (shape != null) { | |
223 | + if (cmd == 'fillcolor') { | |
224 | + result = shape.getAttributeNS(null, 'fill'); | |
225 | + if (result == 'none') | |
226 | + result = ''; | |
227 | + } | |
228 | + else if (cmd == 'linecolor') { | |
229 | + result = shape.getAttributeNS(null, 'stroke'); | |
230 | + if (result == 'none') | |
231 | + result = ''; | |
232 | + } | |
233 | + else if (cmd == 'linewidth') { | |
234 | + result = shape.getAttributeNS(null, 'stroke'); | |
235 | + if (result == 'none') | |
236 | + result = ''; | |
237 | + else | |
238 | + result = shape.getAttributeNS(null, 'stroke-width'); | |
239 | + } | |
240 | + } | |
241 | + | |
242 | + return result; | |
243 | +}; | |
244 | + | |
245 | + | |
246 | +SVGRenderer.prototype.showTracker = function(shape) { | |
247 | + var box = shape.getBBox(); | |
248 | + | |
249 | + var tracker = document.getElementById('tracker'); | |
250 | + if (tracker) { | |
251 | + this.remove(tracker); | |
252 | + } | |
253 | + | |
254 | + var svgNamespace = 'http://www.w3.org/2000/svg'; | |
255 | + | |
256 | + tracker = document.createElementNS(svgNamespace, 'rect'); | |
257 | + tracker.setAttributeNS(null, 'id', 'tracker'); | |
258 | + tracker.setAttributeNS(null, 'x', box.x - 10); | |
259 | + tracker.setAttributeNS(null, 'y', box.y - 10); | |
260 | + tracker.setAttributeNS(null, 'width', box.width + 20); | |
261 | + tracker.setAttributeNS(null, 'height', box.height + 20); | |
262 | + tracker.setAttributeNS(null, 'fill', 'none'); | |
263 | + tracker.setAttributeNS(null, 'stroke', 'blue'); | |
264 | + tracker.setAttributeNS(null, 'stroke-width', '1'); | |
265 | + this.svgRoot.appendChild(tracker); | |
266 | +}; | |
267 | + | |
268 | + | |
269 | +SVGRenderer.prototype.getMarkup = function() { | |
270 | + return this.container.innerHTML; | |
271 | +}; | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(c/a))+String.fromCharCode(c%a+161)};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\[\xa1-\xff]+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp(e(c),'g'),k[c])}}return p}('° ¬(){©.ë=ç;©.Á=¡}¬.®=ä ç;¬.®.ê=°(â){©.¸=â;©.¸.è.é=\'¹\'; º=\'Ø://Ö.Õ.Ò/Ó/¤\';©.Á=©.¸.¿.½(º,"¤");©.¸.×(©.Á)};¬.®.í=°(¢){ µ=ä ï(); ¶=¢.¼();µ[\'x\']=¶.x;µ[\'y\']=¶.y;µ[\'§\']=¶.§;µ[\'ª\']=¶.ª;É µ};¬.®.î=°(¢,È,Æ,ã,±,³,§,ª){ º=\'Ø://Ö.Õ.Ò/Ó/¤\'; ¤;¦(¢==\'µ\'){¤=©.¸.¿.½(º,\'µ\');¤.£(¡,\'x\',±+\'¥\');¤.£(¡,\'y\',³+\'¥\');¤.£(¡,\'§\',§+\'¥\');¤.£(¡,\'ª\',ª+\'¥\')}¨ ¦(¢==\'Ç\'){¤=©.¸.¿.½(º,\'Ç\');¤.£(¡,\'Ã\',(±+§/2)+\'¥\');¤.£(¡,\'Ð\',(³+ª/2)+\'¥\');¤.£(¡,\'Ï\',(§/2)+\'¥\');¤.£(¡,\'Ê\',(ª/2)+\'¥\')}¨ ¦(¢==\'ð\'){¤=©.¸.¿.½(º,\'µ\');¤.£(¡,\'x\',±+\'¥\');¤.£(¡,\'y\',³+\'¥\');¤.£(¡,\'Ï\',\'Ú\');¤.£(¡,\'Ê\',\'Ú\');¤.£(¡,\'§\',§+\'¥\');¤.£(¡,\'ª\',ª+\'¥\')}¨ ¦(¢==\'Î\'){¤=©.¸.¿.½(º,\'Î\');¤.£(¡,\'á\',±+\'¥\');¤.£(¡,\'Ù\',³+\'¥\');¤.£(¡,\'Ñ\',±+\'¥\');¤.£(¡,\'Ô\',³+\'¥\')}¤.è.ì=\'ÿ\';¦(È.Þ==0)È=\'¹\';¤.£(¡,\'À\',È);¦(Æ.Þ==0)Æ=\'¹\';¤.£(¡,\'·\',Æ);¤.£(¡,\'·-§\',ã);©.Á.×(¤);É ¤};¬.®.Ý=°(¢){¢.û.ú(¢)};¬.®.ü=°(¢,±,³){¦(¢.Â==\'Î\'){ ²=¢.¼().§; ´=¢.¼().ª;¢.£(¡,\'á\',±);¢.£(¡,\'Ù\',³);¢.£(¡,\'Ñ\',±+²);¢.£(¡,\'Ô\',³+´)}¨ ¦(¢.Â==\'Ç\'){¢.£(¡,\'Ã\',±+(¢.¼().§/2));¢.£(¡,\'Ð\',³+(¢.¼().ª/2))}¨{¢.£(¡,\'x\',±);¢.£(¡,\'y\',³)}};¬.®.ý=°(¢){};¬.®.þ=°(¢,Ä,Ë,Ì,Í){ ²=Ì-Ä; ´=Í-Ë;¦(¢.Â==\'Î\'){¢.£(¡,\'Ñ\',Ì);¢.£(¡,\'Ô\',Í)}¨ ¦(¢.Â==\'Ç\'){¦(²<0){¢.£(¡,\'Ã\',(Ä+²/2)+\'¥\');¢.£(¡,\'Ï\',(-²/2)+\'¥\')}¨{¢.£(¡,\'Ã\',(Ä+²/2)+\'¥\');¢.£(¡,\'Ï\',(²/2)+\'¥\')}¦(´<0){¢.£(¡,\'Ð\',(Ë+´/2)+\'¥\');¢.£(¡,\'Ê\',(-´/2)+\'¥\')}¨{¢.£(¡,\'Ð\',(Ë+´/2)+\'¥\');¢.£(¡,\'Ê\',(´/2)+\'¥\')}}¨{¦(²<0){¢.£(¡,\'x\',Ì+\'¥\');¢.£(¡,\'§\',-²+\'¥\')}¨{¢.£(¡,\'§\',²+\'¥\')}¦(´<0){¢.£(¡,\'y\',Í+\'¥\');¢.£(¡,\'ª\',-´+\'¥\')}¨{¢.£(¡,\'ª\',´+\'¥\')}}};¬.®.ù=°(¢,»,¾){¦(¢!=¡){¦(»==\'å\'){¦(¾!=\'\')¢.£(¡,\'À\',¾);¨ ¢.£(¡,\'À\',\'¹\')}¨ ¦(»==\'æ\'){¦(¾!=\'\')¢.£(¡,\'·\',¾);¨ ¢.£(¡,\'·\',\'¹\')}¨ ¦(»==\'Û\'){¢.£(¡,\'·-§\',ø(¾)+\'¥\')}}};¬.®.ñ=°(¢,»){ ¯=\'\';¦(¢!=¡){¦(»==\'å\'){¯=¢.Å(¡,\'À\');¦(¯==\'¹\')¯=\'\'}¨ ¦(»==\'æ\'){¯=¢.Å(¡,\'·\');¦(¯==\'¹\')¯=\'\'}¨ ¦(»==\'Û\'){¯=¢.Å(¡,\'·\');¦(¯==\'¹\')¯=\'\';¨ ¯=¢.Å(¡,\'·-§\')}}É ¯};¬.®.ò=°(¢){ ¶=¢.¼(); «=Ü.ô(\'«\');¦(«){©.Ý(«)} º=\'Ø://Ö.Õ.Ò/Ó/¤\';«=Ü.½(º,\'µ\');«.£(¡,\'õ\',\'«\');«.£(¡,\'x\',¶.x-ß);«.£(¡,\'y\',¶.y-ß);«.£(¡,\'§\',¶.§+à);«.£(¡,\'ª\',¶.ª+à);«.£(¡,\'À\',\'¹\');«.£(¡,\'·\',\'÷\');«.£(¡,\'·-§\',\'1\');©.Á.×(«)};¬.®.ö=°(){É ©.¸.ó};',95,95,'null|shape|setAttributeNS|svg|px|if|width|else|this|height|tracker|SVGRenderer|var|prototype|result|function|left|deltaX|top|deltaY|rect|box|stroke|container|none|svgNamespace|cmd|getBBox|createElementNS|value|ownerDocument|fill|svgRoot|tagName|cx|fromX|getAttributeNS|lineColor|ellipse|fillColor|return|ry|fromY|toX|toY|line|rx|cy|x2|org|2000|y2|w3|www|appendChild|http|y1|20px|linewidth|document|remove|length|10|20|x1|elem|lineWidth|new|fillcolor|linecolor|AbstractRenderer|style|MozUserSelect|init|base|position|bounds|create|Object|roundrect|queryCommand|showTracker|innerHTML|getElementById|id|getMarkup|blue|parseInt|editCommand|removeChild|parentNode|move|track|resize|absolute'.split('|'),0,{})) | ... | ... |
... | ... | @@ -0,0 +1,36 @@ |
1 | +<html> | |
2 | +<head> | |
3 | + <title>RichDraw Demo</title> | |
4 | + <!-- | |
5 | + <script type="text/javascript" src="prototype_compacto.js"></script> | |
6 | + <script type="text/javascript" src="richdraw_compacto.js"></script> | |
7 | + <script type="text/javascript" src="svgrenderer_compacto.js"></script> | |
8 | + <script type="text/javascript" src="vmlrenderer_compacto.js"></script> | |
9 | +--> | |
10 | + <script type="text/javascript" src="richdraw_tudo_compacto.js"></script> | |
11 | + | |
12 | + | |
13 | +</head> | |
14 | +<body > | |
15 | + <div id="richdraw" style="position:relative; width:700px; height:500px; border:1px solid black;"> | |
16 | + </div> | |
17 | +</body> | |
18 | + <script type="text/javascript"> | |
19 | + var c; | |
20 | + | |
21 | + var renderer; | |
22 | + | |
23 | + ie = navigator.appVersion.match(/MSIE (\d\.\d)/); | |
24 | + opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1); | |
25 | + if ((!ie) || (opera)) {renderer = new SVGRenderer();} | |
26 | + else {renderer = new VMLRenderer();} | |
27 | + | |
28 | + c = new RichDrawEditor(document.getElementById('richdraw'), renderer); | |
29 | + c.editCommand('fillcolor', 'red'); | |
30 | + c.editCommand('linecolor', 'black'); | |
31 | + c.editCommand('linewidth', '1px'); | |
32 | + //setMode('line', 'Line') | |
33 | + c.editCommand('mode', 'line'); | |
34 | + | |
35 | + </script> | |
36 | +</html> | ... | ... |
1009 Bytes
... | ... | @@ -0,0 +1,249 @@ |
1 | +/*---------------------------------------------------------------------------- | |
2 | + VMLRENDERER 1.0 | |
3 | + VML Renderer For RichDraw | |
4 | + ----------------------------------------------------------------------------- | |
5 | + Created by Mark Finkle (mark.finkle@gmail.com) | |
6 | + Implementation of VML based renderer. | |
7 | + ----------------------------------------------------------------------------- | |
8 | + Copyright (c) 2006 Mark Finkle | |
9 | + | |
10 | + This program is free software; you can redistribute it and/or modify it | |
11 | + under the terms of the MIT License. | |
12 | + | |
13 | + Permission is hereby granted, free of charge, to any person obtaining a | |
14 | + copy of this software and associated documentation files (the "Software"), | |
15 | + to deal in the Software without restriction, including without limitation | |
16 | + the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
17 | + and/or sell copies of the Software, and to permit persons to whom the | |
18 | + Software is furnished to do so, subject to the following conditions: | |
19 | + The above copyright notice and this permission notice shall be included in | |
20 | + all copies or substantial portions of the Software. | |
21 | + | |
22 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
23 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
24 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
25 | + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
26 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
27 | + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
28 | + DEALINGS IN THE SOFTWARE. | |
29 | + ----------------------------------------------------------------------------- | |
30 | + Dependencies: | |
31 | + History: | |
32 | + 2006-04-05 | Created | |
33 | + --------------------------------------------------------------------------*/ | |
34 | + | |
35 | + | |
36 | +function VMLRenderer() { | |
37 | + this.base = AbstractRenderer; | |
38 | +} | |
39 | + | |
40 | + | |
41 | +VMLRenderer.prototype = new AbstractRenderer; | |
42 | + | |
43 | + | |
44 | +VMLRenderer.prototype.init = function(elem) { | |
45 | + this.container = elem; | |
46 | + | |
47 | + this.container.style.overflow = 'hidden'; | |
48 | + | |
49 | + // Add VML includes and namespace | |
50 | + elem.ownerDocument.namespaces.add("v", "urn:schemas-microsoft-com:vml"); | |
51 | + | |
52 | + var style = elem.ownerDocument.createStyleSheet(); | |
53 | + style.addRule('v\\:*', "behavior: url(#default#VML);"); | |
54 | +}; | |
55 | + | |
56 | + | |
57 | +VMLRenderer.prototype.bounds = function(shape) { | |
58 | + var rect = new Object(); | |
59 | + rect['x'] = shape.offsetLeft; | |
60 | + rect['y'] = shape.offsetTop; | |
61 | + rect['width'] = shape.offsetWidth; | |
62 | + rect['height'] = shape.offsetHeight; | |
63 | + return rect; | |
64 | +}; | |
65 | + | |
66 | + | |
67 | +VMLRenderer.prototype.create = function(shape, fillColor, lineColor, lineWidth, left, top, width, height) { | |
68 | + var vml; | |
69 | + if (shape == 'rect') { | |
70 | + vml = this.container.ownerDocument.createElement('v:rect'); | |
71 | + } | |
72 | + else if (shape == 'roundrect') { | |
73 | + vml = this.container.ownerDocument.createElement('v:roundrect'); | |
74 | + } | |
75 | + else if (shape == 'ellipse') { | |
76 | + vml = this.container.ownerDocument.createElement('v:oval'); | |
77 | + } | |
78 | + else if (shape == 'line') { | |
79 | + vml = this.container.ownerDocument.createElement('v:line'); | |
80 | + } | |
81 | + | |
82 | + if (shape != 'line') { | |
83 | + vml.style.position = 'absolute'; | |
84 | + vml.style.left = left; | |
85 | + vml.style.top = top; | |
86 | + vml.style.width = width; | |
87 | + vml.style.height = height; | |
88 | + | |
89 | + if (fillColor != '') { | |
90 | + vml.setAttribute('filled', 'true'); | |
91 | + vml.setAttribute('fillcolor', fillColor); | |
92 | + } | |
93 | + else { | |
94 | + vml.setAttribute('filled', 'false'); | |
95 | + } | |
96 | + } | |
97 | + else { | |
98 | + vml.style.position = 'absolute'; | |
99 | + vml.setAttribute('from', left + 'px,' + top + 'px'); | |
100 | + vml.setAttribute('to', left + 'px,' + top + 'px'); | |
101 | + } | |
102 | + | |
103 | + if (lineColor != '') { | |
104 | + vml.setAttribute('stroked', 'true'); | |
105 | + vml.setAttribute('strokecolor', lineColor); | |
106 | + vml.setAttribute('strokeweight', lineWidth); | |
107 | + } | |
108 | + else { | |
109 | + vml.setAttribute('stroked', 'false'); | |
110 | + } | |
111 | + | |
112 | + this.container.appendChild(vml); | |
113 | + | |
114 | + return vml; | |
115 | +}; | |
116 | + | |
117 | + | |
118 | +VMLRenderer.prototype.remove = function(shape) { | |
119 | + shape.removeNode(true); | |
120 | +}; | |
121 | + | |
122 | + | |
123 | +VMLRenderer.prototype.move = function(shape, left, top) { | |
124 | + if (shape.tagName == 'line') { | |
125 | + shape.style.marginLeft = left; | |
126 | + shape.style.marginTop = top; | |
127 | + } | |
128 | + else { | |
129 | + shape.style.left = left; | |
130 | + shape.style.top = top; | |
131 | + } | |
132 | +}; | |
133 | + | |
134 | + | |
135 | +VMLRenderer.prototype.track = function(shape) { | |
136 | + // TODO | |
137 | +}; | |
138 | + | |
139 | + | |
140 | +VMLRenderer.prototype.resize = function(shape, fromX, fromY, toX, toY) { | |
141 | + var deltaX = toX - fromX; | |
142 | + var deltaY = toY - fromY; | |
143 | + if (shape.tagName == 'line') { | |
144 | + //shape.setAttribute('from', fromX + 'px,' + fromY + 'px'); | |
145 | + shape.setAttribute('from', toX + 'px,' + toY + 'px'); | |
146 | + } | |
147 | + else { | |
148 | + if (deltaX < 0) { | |
149 | + shape.style.left = toX + 'px'; | |
150 | + shape.style.width = -deltaX + 'px'; | |
151 | + } | |
152 | + else { | |
153 | + shape.style.width = deltaX + 'px'; | |
154 | + } | |
155 | + | |
156 | + if (deltaY < 0) { | |
157 | + shape.style.top = toY + 'px'; | |
158 | + shape.style.height = -deltaY + 'px'; | |
159 | + } | |
160 | + else { | |
161 | + shape.style.height = deltaY + 'px'; | |
162 | + } | |
163 | + } | |
164 | +}; | |
165 | + | |
166 | +VMLRenderer.prototype.editCommand = function(shape, cmd, value) | |
167 | +{ | |
168 | + if (shape != null) { | |
169 | + if (cmd == 'fillcolor') { | |
170 | + if (value != '') { | |
171 | + shape.filled = 'true'; | |
172 | + shape.fillcolor = value; | |
173 | + } | |
174 | + else { | |
175 | + shape.filled = 'false'; | |
176 | + shape.fillcolor = ''; | |
177 | + } | |
178 | + } | |
179 | + else if (cmd == 'linecolor') { | |
180 | + if (value != '') { | |
181 | + shape.stroked = 'true'; | |
182 | + shape.strokecolor = value; | |
183 | + } | |
184 | + else { | |
185 | + shape.stroked = 'false'; | |
186 | + shape.strokecolor = ''; | |
187 | + } | |
188 | + } | |
189 | + else if (cmd == 'linewidth') { | |
190 | + shape.strokeweight = parseInt(value) + 'px'; | |
191 | + } | |
192 | + } | |
193 | +}; | |
194 | + | |
195 | + | |
196 | +VMLRenderer.prototype.queryCommand = function(shape, cmd) | |
197 | +{ | |
198 | + if (shape != null) { | |
199 | + if (cmd == 'fillcolor') { | |
200 | + if (shape.filled == 'false') | |
201 | + return ''; | |
202 | + else | |
203 | + return shape.fillcolor; | |
204 | + } | |
205 | + else if (cmd == 'linecolor') { | |
206 | + if (shape.stroked == 'false') | |
207 | + return ''; | |
208 | + else | |
209 | + return shape.strokecolor; | |
210 | + } | |
211 | + else if (cmd == 'linewidth') { | |
212 | + if (shape.stroked == 'false') { | |
213 | + return ''; | |
214 | + } | |
215 | + else { | |
216 | + // VML always transforms the pixels to points, so we have to convert them back | |
217 | + return (parseFloat(shape.strokeweight) * (screen.logicalXDPI / 72)) + 'px'; | |
218 | + } | |
219 | + } | |
220 | + } | |
221 | +}; | |
222 | + | |
223 | + | |
224 | +VMLRenderer.prototype.showTracker = function(shape) { | |
225 | + var box = this.bounds(shape); | |
226 | + | |
227 | + var tracker = document.getElementById('tracker'); | |
228 | + if (tracker) { | |
229 | + this.remove(tracker); | |
230 | + } | |
231 | + | |
232 | + tracker = this.container.ownerDocument.createElement('v:rect'); | |
233 | + tracker.id = 'tracker'; | |
234 | + tracker.style.position = 'absolute'; | |
235 | + tracker.style.left = box.x - 10; | |
236 | + tracker.style.top = box.y - 10; | |
237 | + tracker.style.width = box.width + 20; | |
238 | + tracker.style.height = box.height + 20; | |
239 | + tracker.setAttribute('filled', 'false'); | |
240 | + tracker.setAttribute('stroked', 'true'); | |
241 | + tracker.setAttribute('strokecolor', 'blue'); | |
242 | + tracker.setAttribute('strokeweight', '1px'); | |
243 | + this.container.appendChild(tracker); | |
244 | +}; | |
245 | + | |
246 | + | |
247 | +VMLRenderer.prototype.getMarkup = function() { | |
248 | + return this.container.innerHTML; | |
249 | +}; | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(c/a))+String.fromCharCode(c%a+161)};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\[\xa1-\xff]+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp(e(c),'g'),k[c])}}return p}('¬ ª(){©.é=Í}ª.«=Ì Í;ª.«.ç=¬(Â){©.¯=Â;©.¯.£.å=\'æ\';Â.·.ê.ë("v","ï:î-í-ä:¤");¸ £=Â.·.ð();£.à(\'v\\\\:*\',"Ü: Û(#ß#á);")};ª.«.Õ=¬(¡){¸ ±=Ì â();±[\'x\']=¡.Þ;±[\'y\']=¡.Ý;±[\'³\']=¡.ì;±[\'µ\']=¡.¢©;° ±};ª.«.¢¢=¬(¡,È,Ç,Ð,,®,³,µ){¸ ¤;¢(¡==\'±\'){¤=©.¯.·.¿(\'v:±\')}¥ ¢(¡==\'Ë\'){¤=©.¯.·.¿(\'v:Ë\')}¥ ¢(¡==\'ñ\'){¤=©.¯.·.¿(\'v:þ\')}¥ ¢(¡==\'½\'){¤=©.¯.·.¿(\'v:½\')}¢(¡!=\'½\'){¤.£.Ê=\'É\';¤.£.=;¤.£.®=®;¤.£.³=³;¤.£.µ=µ;¢(È!=\'\'){¤.¨(\'¹\',\'º\');¤.¨(\'¼\',È)}¥{¤.¨(\'¹\',\'´\')}}¥{¤.£.Ê=\'É\';¤.¨(\'Ò\',+\'§,\'+®+\'§\');¤.¨(\'¢£\',+\'§,\'+®+\'§\')}¢(Ç!=\'\'){¤.¨(\'¶\',\'º\');¤.¨(\'¾\',Ç);¤.¨(\'Ã\',Ð)}¥{¤.¨(\'¶\',\'´\')}©.¯.×(¤);° ¤};ª.«.Ö=¬(¡){¡.¢¨(º)};ª.«.¢§=¬(¡,,®){¢(¡.Ñ==\'½\'){¡.£.¢¦=;¡.£.¢¥=®}¥{¡.£.=;¡.£.®=®}};ª.«.ý=¬(¡){};ª.«.ü=¬(¡,Ï,Î,Æ,Á){¸ Ä=Æ-Ï;¸ Å=Á-Î;¢(¡.Ñ==\'½\'){¡.¨(\'Ò\',Æ+\'§,\'+Á+\'§\')}¥{¢(Ä<0){¡.£.=Æ+\'§\';¡.£.³=-Ä+\'§\'}¥{¡.£.³=Ä+\'§\'}¢(Å<0){¡.£.®=Á+\'§\';¡.£.µ=-Å+\'§\'}¥{¡.£.µ=Å+\'§\'}}};ª.«.ú=¬(¡,²,»){¢(¡!=Ó){¢(²==\'¼\'){¢(»!=\'\'){¡.¹=\'º\';¡.¼=»}¥{¡.¹=\'´\';¡.¼=\'\'}}¥ ¢(²==\'Ú\'){¢(»!=\'\'){¡.¶=\'º\';¡.¾=»}¥{¡.¶=\'´\';¡.¾=\'\'}}¥ ¢(²==\'Ø\'){¡.Ã=ù(»)+\'§\'}}};ª.«.ø=¬(¡,²){¢(¡!=Ó){¢(²==\'¼\'){¢(¡.¹==\'´\')°\'\';¥ ° ¡.¼}¥ ¢(²==\'Ú\'){¢(¡.¶==\'´\')°\'\';¥ ° ¡.¾}¥ ¢(²==\'Ø\'){¢(¡.¶==\'´\'){°\'\'}¥{°(û(¡.Ã)*(÷.ö/ò))+\'§\'}}}};ª.«.ó=¬(¡){¸ À=©.Õ(¡);¸ ¦=ô.õ(\'¦\');¢(¦){©.Ö(¦)}¦=©.¯.·.¿(\'v:±\');¦.¢¤=\'¦\';¦.£.Ê=\'É\';¦.£.=À.x-Ô;¦.£.®=À.y-Ô;¦.£.³=À.³+Ù;¦.£.µ=À.µ+Ù;¦.¨(\'¹\',\'´\');¦.¨(\'¶\',\'º\');¦.¨(\'¾\',\'¢¡\');¦.¨(\'Ã\',\'ã\');©.¯.×(¦)};ª.«.è=¬(){° ©.¯.ÿ};',95,104,'shape|if|style|vml|else|tracker|px|setAttribute|this|VMLRenderer|prototype|function|left|top|container|return|rect|cmd|width|false|height|stroked|ownerDocument|var|filled|true|value|fillcolor|line|strokecolor|createElement|box|toY|elem|strokeweight|deltaX|deltaY|toX|lineColor|fillColor|absolute|position|roundrect|new|AbstractRenderer|fromY|fromX|lineWidth|tagName|from|null|10|bounds|remove|appendChild|linewidth|20|linecolor|url|behavior|offsetTop|offsetLeft|default|addRule|VML|Object|1px|com|overflow|hidden|init|getMarkup|base|namespaces|add|offsetWidth|microsoft|schemas|urn|createStyleSheet|ellipse|72|showTracker|document|getElementById|logicalXDPI|screen|queryCommand|parseInt|editCommand|parseFloat|resize|track|oval|innerHTML|blue|create|to|id|marginTop|marginLeft|move|removeNode|offsetHeight'.split('|'),0,{})) | ... | ... |