├── .gitignore ├── COPYING ├── LICENSE ├── README.textile ├── Rakefile ├── closure-compiler.gemspec ├── lib ├── closure-compiler-20180506.jar ├── closure-compiler.rb └── closure │ └── compiler.rb └── test ├── fixtures ├── file1-file2-compiled.js ├── file1.js ├── file2.js ├── precompressed-compiled.js └── precompressed.js ├── test_helper.rb └── unit └── closure_compiler_test.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .yardoc 2 | *.gem 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | closure-compiler.jar 191 | Copyright 2010 Google Inc. 192 | 193 | "closure-compiler" RubyGem 194 | Copyright 2010 DocumentCloud Inc. 195 | 196 | Licensed under the Apache License, Version 2.0 (the "License"); 197 | you may not use this file except in compliance with the License. 198 | You may obtain a copy of the License at 199 | 200 | http://www.apache.org/licenses/LICENSE-2.0 201 | 202 | Unless required by applicable law or agreed to in writing, software 203 | distributed under the License is distributed on an "AS IS" BASIS, 204 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 205 | See the License for the specific language governing permissions and 206 | limitations under the License. 207 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * closure-compiler.jar 3 | * Copyright 2010 Google Inc. 4 | * 5 | * "closure-compiler" RubyGem 6 | * Copyright 2010 DocumentCloud Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ -------------------------------------------------------------------------------- /README.textile: -------------------------------------------------------------------------------- 1 | h1. The Closure Compiler (as a Ruby Gem) 2 | 3 | The *closure-compiler* gem is a svelte wrapper around the "Google Closure Compiler":https://developers.google.com/closure/compiler/ for JavaScript compression. 4 | 5 | Latest Version: *"1.1.14":https://rubygems.org/gems/closure-compiler* 6 | 7 | The Closure Compiler's *2018-05-06* JAR-file is included with the gem. 8 | 9 | h2. Installation 10 | 11 |
12 | sudo gem install closure-compiler
13 | 
14 | 15 | h2. Usage 16 | 17 | The @Closure::Compiler@ has a @compile@ method, which can be passed a string or an open @IO@ object, and returns the compiled JavaScript. The result is returned as a string, or, if a block is passed, yields as an @IO@ object for streaming writes. 18 | 19 |
20 | require 'rubygems'
21 | require 'closure-compiler'
22 | Closure::Compiler.new.compile(File.open('underscore.js', 'r'))
23 | 
24 | => "(function(){var j=this,m=j._;function i(a){......
25 | 
26 | 27 | The @Closure::Compiler@ also has @compile_file@ and @compile_files@ methods, which can be passed a file path or an array of file paths respectively. The files are concatenated and compiled and, like the @compile@ method, the result is returned as a string or, if block is passed, yields an @IO@ object. 28 | 29 |
30 | require 'rubygems'
31 | require 'closure-compiler'
32 | Closure::Compiler.new.compile_files(['underscore.js', 'jasmine.js']))
33 | 
34 | => "(function(){var j=this,m=j._;function i(a){......
35 | 
36 | 37 | When creating a @Closure::Compiler@, you can pass "any options that the command-line compiler accepts":https://developers.google.com/closure/compiler/docs/gettingstarted_app to the initializer and they'll be forwarded. For example, to raise the compilation level up a notch: 38 | 39 |
40 | closure = Closure::Compiler.new(:compilation_level => 'ADVANCED_OPTIMIZATIONS')
41 | closure.compile(File.open('underscore.js', 'r'))
42 | 
43 | => "(function(){var j=this,m=j.h;function i(a){......
44 | 
45 | 46 | The default values of all the compiler flags are identical to the command-line version. The default *compilation_level* is "SIMPLE_OPTIMIZATIONS". 47 | 48 | A @Closure::Error@ exception will be raised, explaining the JavaScript syntax error, if compilation fails for any reason. 49 | 50 | h2. YUI Compressor Compatibility 51 | 52 | Effort has been made to make the "closure-compiler" gem a drop-in alternative to the "ruby-yui-compressor". To that end, @Closure::Compiler#compile@ has been aliased as @compress@, and can take the same string or IO argument that a @YUI::JavaScriptCompressor#compress@ can. In addition, the @Closure::Compiler@ initializer can take @java@ and @jar_file@ options, overriding the location of the Java command and the Closure Compiler JAR file, respectively. 53 | 54 |
55 | compiler = Closure::Compiler.new(
56 |   :java     => '/usr/local/bin/java16',
57 |   :jar_file => '/usr/src/closure/build/latest.jar'
58 | )
59 | 
60 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "rake/testtask" 2 | 3 | Rake::TestTask.new do |t| 4 | t.libs += ["lib", "test"] 5 | t.test_files = FileList["test/**/*_test.rb"] 6 | t.verbose = true 7 | end 8 | 9 | namespace :gem do 10 | 11 | desc 'Build and install the closure-compiler gem' 12 | task :install do 13 | sh "gem build closure-compiler.gemspec" 14 | sh "gem install #{Dir['*.gem'].join(' ')} --local --no-ri --no-rdoc" 15 | end 16 | 17 | desc 'Uninstall the closure-compiler gem' 18 | task :uninstall do 19 | sh "gem uninstall -x closure-compiler" 20 | end 21 | 22 | end 23 | 24 | task :default => :test 25 | -------------------------------------------------------------------------------- /closure-compiler.gemspec: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), 'lib', 'closure-compiler') 2 | 3 | Gem::Specification.new do |s| 4 | s.name = 'closure-compiler' 5 | s.version = Closure::VERSION 6 | s.date = '2018-05-31' 7 | s.license = 'Apache-2.0' 8 | 9 | s.homepage = "http://github.com/documentcloud/closure-compiler/" 10 | s.summary = "Ruby Wrapper for the Google Closure Compiler" 11 | s.description = <<-EOS 12 | A Ruby Wrapper for the Google Closure Compiler. 13 | EOS 14 | 15 | s.rubyforge_project = "closure-compiler" 16 | s.authors = ['Jeremy Ashkenas', 'Jordan Brough'] 17 | s.email = 'opensource@documentcloud.org' 18 | 19 | s.require_paths = ['lib'] 20 | 21 | s.rdoc_options << '--title' << 'Ruby Closure Compiler' << 22 | '--exclude' << 'test' << 23 | '--all' 24 | 25 | s.files = Dir['lib/**/*', 'vendor/**/*', 'closure-compiler.gemspec', 'README.textile', 'LICENSE', 'COPYING'] 26 | 27 | end 28 | -------------------------------------------------------------------------------- /lib/closure-compiler-20180506.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentcloud/closure-compiler/984ab892e1bd901a5d24d79577f2ea6afcc2a0c3/lib/closure-compiler-20180506.jar -------------------------------------------------------------------------------- /lib/closure-compiler.rb: -------------------------------------------------------------------------------- 1 | module Closure 2 | 3 | VERSION = "1.1.14" 4 | 5 | COMPILER_VERSION = "20180506" 6 | 7 | JAVA_COMMAND = 'java' 8 | 9 | COMPILER_ROOT = File.expand_path(File.dirname(__FILE__)) 10 | 11 | COMPILER_JAR = File.join(COMPILER_ROOT, "closure-compiler-#{COMPILER_VERSION}.jar") 12 | 13 | end 14 | 15 | require 'closure/compiler' 16 | -------------------------------------------------------------------------------- /lib/closure/compiler.rb: -------------------------------------------------------------------------------- 1 | require 'stringio' 2 | require 'tempfile' 3 | 4 | module Closure 5 | 6 | # We raise a Closure::Error when compilation fails for any reason. 7 | class Error < StandardError; end 8 | 9 | # The Closure::Compiler is a basic wrapper around the actual JAR. There's not 10 | # much to see here. 11 | class Compiler 12 | 13 | attr_accessor :options 14 | 15 | DEFAULT_OPTIONS = { 16 | :warning_level => 'QUIET', 17 | :language_in => 'ECMASCRIPT5' 18 | } 19 | 20 | # When you create a Compiler, pass in the flags and options. 21 | def initialize(options={}) 22 | @java = options.delete(:java) || JAVA_COMMAND 23 | @jar = options.delete(:jar_file) || COMPILER_JAR 24 | @options = DEFAULT_OPTIONS.merge(options) 25 | end 26 | 27 | # Can compile a JavaScript string or open IO object. Returns the compiled 28 | # JavaScript as a string or yields an IO object containing the response to a 29 | # block, for streaming. 30 | def compile(io) 31 | tempfile = Tempfile.new('closure_compiler') 32 | if io.respond_to? :read 33 | while buffer = io.read(4096) do 34 | tempfile.write(buffer) 35 | end 36 | else 37 | tempfile.write(io.to_s) 38 | end 39 | tempfile.flush 40 | 41 | begin 42 | result = compile_files(tempfile.path) 43 | rescue Exception => e 44 | raise e 45 | ensure 46 | tempfile.close! 47 | end 48 | 49 | yield(StringIO.new(result)) if block_given? 50 | result 51 | end 52 | alias_method :compress, :compile 53 | 54 | # Takes an array of javascript file paths or a single path. Returns the 55 | # resulting JavaScript as a string or yields an IO object containing the 56 | # response to a block, for streaming. 57 | def compile_files(files) 58 | @options.merge!(:js => files) 59 | 60 | begin 61 | redirect_stderr = "2>&1" if !Gem.win_platform? 62 | result = `#{command} #{redirect_stderr}` 63 | rescue Exception 64 | raise Error, "compression failed: #{result}" 65 | end 66 | 67 | unless $?.exitstatus.zero? 68 | raise Error, result 69 | end 70 | 71 | yield(StringIO.new(result)) if block_given? 72 | result 73 | end 74 | alias_method :compile_file, :compile_files 75 | 76 | private 77 | 78 | # Serialize hash options to the command-line format. 79 | def serialize_options(options) 80 | options.map do |k, v| 81 | if (v.is_a?(Array)) 82 | v.map {|v2| ["--#{k}", v2.to_s]} 83 | else 84 | ["--#{k}", v.to_s] 85 | end 86 | end.flatten 87 | end 88 | 89 | def command 90 | [@java, '-jar', "\"#{@jar}\"", serialize_options(@options)].flatten.join(' ') 91 | end 92 | 93 | end 94 | end 95 | -------------------------------------------------------------------------------- /test/fixtures/file1.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2008, Yahoo! Inc. All rights reserved. 3 | Code licensed under the BSD License: 4 | http://developer.yahoo.net/yui/license.txt 5 | version: 2.5.2 6 | */ 7 | if(typeof YAHOO=="undefined"||!YAHOO){var YAHOO={};}YAHOO.namespace=function(){var A=arguments,E=null,C,B,D;for(C=0;C0)?A.dump(D[F],I-1):L);}else{K.push(D[F]);}K.push(J);}if(K.length>1){K.pop();}K.push("]");}else{K.push("{");for(F in D){if(A.hasOwnProperty(D,F)){K.push(F+G);if(A.isObject(D[F])){K.push((I>0)?A.dump(D[F],I-1):L);}else{K.push(D[F]);}K.push(J);}}if(K.length>1){K.pop();}K.push("}");}return K.join("");},substitute:function(S,E,L){var I,H,G,O,P,R,N=[],F,J="dump",M=" ",D="{",Q="}";for(;;){I=S.lastIndexOf(D);if(I<0){break;}H=S.indexOf(Q,I);if(I+1>=H){break;}F=S.substring(I+1,H);O=F;R=null;G=O.indexOf(M);if(G>-1){R=O.substring(G+1);O=O.substring(0,G);}P=E[O];if(L){P=L(O,P,R);}if(A.isObject(P)){if(A.isArray(P)){P=A.dump(P,parseInt(R,10));}else{R=R||"";var K=R.indexOf(J);if(K>-1){R=R.substring(4);}if(P.toString===Object.prototype.toString||K>-1){P=A.dump(P,parseInt(R,10));}else{P=P.toString();}}}else{if(!A.isString(P)&&!A.isNumber(P)){P="~-"+N.length+"-~";N[N.length]=F;}}S=S.substring(0,I)+P+S.substring(H+1);}for(I=N.length-1;I>=0;I=I-1){S=S.replace(new RegExp("~-"+I+"-~"),"{"+N[I]+"}","g");}return S;},trim:function(D){try{return D.replace(/^\s+|\s+$/g,"");}catch(E){return D;}},merge:function(){var G={},E=arguments;for(var F=0,D=E.length;F=this.left&&A.right<=this.right&&A.top>=this.top&&A.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(E){var C=Math.max(this.top,E.top);var D=Math.min(this.right,E.right);var A=Math.min(this.bottom,E.bottom);var B=Math.max(this.left,E.left);if(A>=C&&D>=B){return new YAHOO.util.Region(C,D,A,B);}else{return null;}};YAHOO.util.Region.prototype.union=function(E){var C=Math.min(this.top,E.top);var D=Math.max(this.right,E.right);var A=Math.max(this.bottom,E.bottom);var B=Math.min(this.left,E.left);return new YAHOO.util.Region(C,D,A,B);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};YAHOO.util.Region.getRegion=function(D){var F=YAHOO.util.Dom.getXY(D);var C=F[1];var E=F[0]+D.offsetWidth;var A=F[1]+D.offsetHeight;var B=F[0];return new YAHOO.util.Region(C,E,A,B);};YAHOO.util.Point=function(A,B){if(YAHOO.lang.isArray(A)){B=A[1];A=A[0];}this.x=this.right=this.left=this[0]=A;this.y=this.top=this.bottom=this[1]=B;};YAHOO.util.Point.prototype=new YAHOO.util.Region();YAHOO.register("dom",YAHOO.util.Dom,{version:"2.5.2",build:"1076"});YAHOO.util.CustomEvent=function(D,B,C,A){this.type=D;this.scope=B||window;this.silent=C;this.signature=A||YAHOO.util.CustomEvent.LIST;this.subscribers=[];if(!this.silent){}var E="_YUICEOnSubscribe";if(D!==E){this.subscribeEvent=new YAHOO.util.CustomEvent(E,this,true);}this.lastError=null;};YAHOO.util.CustomEvent.LIST=0;YAHOO.util.CustomEvent.FLAT=1;YAHOO.util.CustomEvent.prototype={subscribe:function(B,C,A){if(!B){throw new Error("Invalid callback for subscriber to '"+this.type+"'");}if(this.subscribeEvent){this.subscribeEvent.fire(B,C,A);}this.subscribers.push(new YAHOO.util.Subscriber(B,C,A));},unsubscribe:function(D,F){if(!D){return this.unsubscribeAll();}var E=false;for(var B=0,A=this.subscribers.length;B0){B=I[0];}try{G=M.fn.call(L,B,M.obj);}catch(F){this.lastError=F;if(A){throw F;}}}else{try{G=M.fn.call(L,this.type,I,M.obj);}catch(H){this.lastError=H;if(A){throw H;}}}if(false===G){if(!this.silent){}break;}}}return(G!==false);},unsubscribeAll:function(){for(var A=this.subscribers.length-1;A>-1;A--){this._delete(A);}this.subscribers=[];return A;},_delete:function(A){var B=this.subscribers[A];if(B){delete B.fn;delete B.obj;}this.subscribers.splice(A,1);},toString:function(){return"CustomEvent: "+"'"+this.type+"', "+"scope: "+this.scope;}};YAHOO.util.Subscriber=function(B,C,A){this.fn=B;this.obj=YAHOO.lang.isUndefined(C)?null:C;this.override=A;};YAHOO.util.Subscriber.prototype.getScope=function(A){if(this.override){if(this.override===true){return this.obj;}else{return this.override;}}return A;};YAHOO.util.Subscriber.prototype.contains=function(A,B){if(B){return(this.fn==A&&this.obj==B);}else{return(this.fn==A);}};YAHOO.util.Subscriber.prototype.toString=function(){return"Subscriber { obj: "+this.obj+", override: "+(this.override||"no")+" }";};if(!YAHOO.util.Event){YAHOO.util.Event=function(){var H=false;var I=[];var J=[];var G=[];var E=[];var C=0;var F=[];var B=[];var A=0;var D={63232:38,63233:40,63234:37,63235:39,63276:33,63277:34,25:9};return{POLL_RETRYS:2000,POLL_INTERVAL:20,EL:0,TYPE:1,FN:2,WFN:3,UNLOAD_OBJ:3,ADJ_SCOPE:4,OBJ:5,OVERRIDE:6,lastError:null,isSafari:YAHOO.env.ua.webkit,webkit:YAHOO.env.ua.webkit,isIE:YAHOO.env.ua.ie,_interval:null,_dri:null,DOMReady:false,throwErrors:false,startInterval:function(){if(!this._interval){var K=this;var L=function(){K._tryPreloadAttach();};this._interval=setInterval(L,this.POLL_INTERVAL);}},onAvailable:function(P,M,Q,O,N){var K=(YAHOO.lang.isString(P))?[P]:P;for(var L=0;L-1;O--){U=(this.removeListener(L[O],K,T)&&U);}return U;}}if(!T||!T.call){return this.purgeElement(L,false,K);}if("unload"==K){for(O=J.length-1;O>-1;O--){V=J[O];if(V&&V[0]==L&&V[1]==K&&V[2]==T){J.splice(O,1);return true;}}return false;}var P=null;var Q=arguments[3];if("undefined"===typeof Q){Q=this._getCacheIndex(L,K,T);}if(Q>=0){P=I[Q];}if(!L||!P){return false;}if(this.useLegacyEvent(L,K)){var N=this.getLegacyIndex(L,K);var M=E[N];if(M){for(O=0,R=M.length;O0&&F.length>0);}var P=[];var R=function(T,U){var S=T;if(U.override){if(U.override===true){S=U.obj;}else{S=U.override;}}U.fn.call(S,U.obj);};var L,K,O,N,M=[];for(L=0,K=F.length;L-1;L--){O=F[L];if(!O||!O.id){F.splice(L,1);}}this.startInterval();}else{clearInterval(this._interval);this._interval=null;}this.locked=false;},purgeElement:function(O,P,R){var M=(YAHOO.lang.isString(O))?this.getEl(O):O;var Q=this.getListeners(M,R),N,K;if(Q){for(N=Q.length-1;N>-1;N--){var L=Q[N];this.removeListener(M,L.type,L.fn);}}if(P&&M&&M.childNodes){for(N=0,K=M.childNodes.length;N-1;M--){L=I[M];if(L){K.removeListener(L[K.EL],L[K.TYPE],L[K.FN],M);}}L=null;}G=null;K._simpleRemove(window,"unload",K._unload);},_getScrollLeft:function(){return this._getScroll()[1];},_getScrollTop:function(){return this._getScroll()[0];},_getScroll:function(){var K=document.documentElement,L=document.body;if(K&&(K.scrollTop||K.scrollLeft)){return[K.scrollTop,K.scrollLeft];}else{if(L){return[L.scrollTop,L.scrollLeft];}else{return[0,0];}}},regCE:function(){},_simpleAdd:function(){if(window.addEventListener){return function(M,N,L,K){M.addEventListener(N,L,(K));};}else{if(window.attachEvent){return function(M,N,L,K){M.attachEvent("on"+N,L);};}else{return function(){};}}}(),_simpleRemove:function(){if(window.removeEventListener){return function(M,N,L,K){M.removeEventListener(N,L,(K));};}else{if(window.detachEvent){return function(L,M,K){L.detachEvent("on"+M,K);};}else{return function(){};}}}()};}();(function(){var EU=YAHOO.util.Event;EU.on=EU.addListener; 10 | /* DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller */ 11 | if(EU.isIE){YAHOO.util.Event.onDOMReady(YAHOO.util.Event._tryPreloadAttach,YAHOO.util.Event,true);var n=document.createElement("p");EU._dri=setInterval(function(){try{n.doScroll("left");clearInterval(EU._dri);EU._dri=null;EU._ready();n=null;}catch(ex){}},EU.POLL_INTERVAL);}else{if(EU.webkit&&EU.webkit<525){EU._dri=setInterval(function(){var rs=document.readyState;if("loaded"==rs||"complete"==rs){clearInterval(EU._dri);EU._dri=null;EU._ready();}},EU.POLL_INTERVAL);}else{EU._simpleAdd(document,"DOMContentLoaded",EU._ready);}}EU._simpleAdd(window,"load",EU._load);EU._simpleAdd(window,"unload",EU._unload);EU._tryPreloadAttach();})();}YAHOO.util.EventProvider=function(){};YAHOO.util.EventProvider.prototype={__yui_events:null,__yui_subscribers:null,subscribe:function(A,C,F,E){this.__yui_events=this.__yui_events||{};var D=this.__yui_events[A];if(D){D.subscribe(C,F,E);}else{this.__yui_subscribers=this.__yui_subscribers||{};var B=this.__yui_subscribers;if(!B[A]){B[A]=[];}B[A].push({fn:C,obj:F,override:E});}},unsubscribe:function(C,E,G){this.__yui_events=this.__yui_events||{};var A=this.__yui_events;if(C){var F=A[C];if(F){return F.unsubscribe(E,G);}}else{var B=true;for(var D in A){if(YAHOO.lang.hasOwnProperty(A,D)){B=B&&A[D].unsubscribe(E,G);}}return B;}return false;},unsubscribeAll:function(A){return this.unsubscribe(A);},createEvent:function(G,D){this.__yui_events=this.__yui_events||{};var A=D||{};var I=this.__yui_events; 12 | if(I[G]){}else{var H=A.scope||this;var E=(A.silent);var B=new YAHOO.util.CustomEvent(G,H,E,YAHOO.util.CustomEvent.FLAT);I[G]=B;if(A.onSubscribeCallback){B.subscribeEvent.subscribe(A.onSubscribeCallback);}this.__yui_subscribers=this.__yui_subscribers||{};var F=this.__yui_subscribers[G];if(F){for(var C=0;Cthis.clickPixelThresh||C>this.clickPixelThresh){this.startDrag(this.startX,this.startY);}}if(this.dragThreshMet){if(B&&B.events.b4Drag){B.b4Drag(E);B.fireEvent("b4DragEvent",{e:E});}if(B&&B.events.drag){B.onDrag(E);B.fireEvent("dragEvent",{e:E});}if(B){this.fireEvents(E,false);}}this.stopEvent(E);}},fireEvents:function(U,K){var Z=this.dragCurrent;if(!Z||Z.isLocked()||Z.dragOnly){return ;}var M=YAHOO.util.Event.getPageX(U),L=YAHOO.util.Event.getPageY(U),O=new YAHOO.util.Point(M,L),J=Z.getTargetCoord(O.x,O.y),E=Z.getDragEl(),D=["out","over","drop","enter"],T=new YAHOO.util.Region(J.y,J.x+E.offsetWidth,J.y+E.offsetHeight,J.x),H=[],C={},P=[],a={outEvts:[],overEvts:[],dropEvts:[],enterEvts:[]};for(var R in this.dragOvers){var c=this.dragOvers[R];if(!this.isTypeOfDD(c)){continue;}if(!this.isOverTarget(O,c,this.mode,T)){a.outEvts.push(c);}H[R]=true;delete this.dragOvers[R];}for(var Q in Z.groups){if("string"!=typeof Q){continue;}for(R in this.ids[Q]){var F=this.ids[Q][R];if(!this.isTypeOfDD(F)){continue;}if(F.isTarget&&!F.isLocked()&&F!=Z){if(this.isOverTarget(O,F,this.mode,T)){C[Q]=true;if(K){a.dropEvts.push(F);}else{if(!H[F.id]){a.enterEvts.push(F);}else{a.overEvts.push(F);}this.dragOvers[F.id]=F;}}}}}this.interactionInfo={out:a.outEvts,enter:a.enterEvts,over:a.overEvts,drop:a.dropEvts,point:O,draggedRegion:T,sourceRegion:this.locationCache[Z.id],validDrop:K};for(var B in C){P.push(B);}if(K&&!a.dropEvts.length){this.interactionInfo.validDrop=false;if(Z.events.invalidDrop){Z.onInvalidDrop(U);Z.fireEvent("invalidDropEvent",{e:U});}}for(R=0;R2000){}else{setTimeout(B._addListeners,10);if(document&&document.body){B._timeoutCount+=1;}}}},handleWasClicked:function(B,D){if(this.isHandle(D,B.id)){return true;}else{var C=B.parentNode;while(C){if(this.isHandle(D,C.id)){return true;}else{C=C.parentNode;}}}return false;}};}();YAHOO.util.DDM=YAHOO.util.DragDropMgr;YAHOO.util.DDM._addListeners();}(function(){var A=YAHOO.util.Event;var B=YAHOO.util.Dom;YAHOO.util.DragDrop=function(E,C,D){if(E){this.init(E,C,D);}};YAHOO.util.DragDrop.prototype={events:null,on:function(){this.subscribe.apply(this,arguments);},id:null,config:null,dragElId:null,handleElId:null,invalidHandleTypes:null,invalidHandleIds:null,invalidHandleClasses:null,startPageX:0,startPageY:0,groups:null,locked:false,lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isTarget:true,padding:null,dragOnly:false,_domRef:null,__ygDragDrop:true,constrainX:false,constrainY:false,minX:0,maxX:0,minY:0,maxY:0,deltaX:0,deltaY:0,maintainOffset:false,xTicks:null,yTicks:null,primaryButtonOnly:true,available:false,hasOuterHandles:false,cursorIsOver:false,overlap:null,b4StartDrag:function(C,D){},startDrag:function(C,D){},b4Drag:function(C){},onDrag:function(C){},onDragEnter:function(C,D){},b4DragOver:function(C){},onDragOver:function(C,D){},b4DragOut:function(C){},onDragOut:function(C,D){},b4DragDrop:function(C){},onDragDrop:function(C,D){},onInvalidDrop:function(C){},b4EndDrag:function(C){},endDrag:function(C){},b4MouseDown:function(C){},onMouseDown:function(C){},onMouseUp:function(C){},onAvailable:function(){},getEl:function(){if(!this._domRef){this._domRef=B.get(this.id);}return this._domRef;},getDragEl:function(){return B.get(this.dragElId);},init:function(F,C,D){this.initTarget(F,C,D);A.on(this._domRef||this.id,"mousedown",this.handleMouseDown,this,true);for(var E in this.events){this.createEvent(E+"Event");}},initTarget:function(E,C,D){this.config=D||{};this.events={};this.DDM=YAHOO.util.DDM;this.groups={};if(typeof E!=="string"){this._domRef=E;E=B.generateId(E);}this.id=E;this.addToGroup((C)?C:"default");this.handleElId=E;A.onAvailable(E,this.handleOnAvailable,this,true);this.setDragElId(E);this.invalidHandleTypes={A:"A"};this.invalidHandleIds={};this.invalidHandleClasses=[];this.applyConfig();},applyConfig:function(){this.events={mouseDown:true,b4MouseDown:true,mouseUp:true,b4StartDrag:true,startDrag:true,b4EndDrag:true,endDrag:true,drag:true,b4Drag:true,invalidDrop:true,b4DragOut:true,dragOut:true,dragEnter:true,b4DragOver:true,dragOver:true,b4DragDrop:true,dragDrop:true};if(this.config.events){for(var C in this.config.events){if(this.config.events[C]===false){this.events[C]=false;}}}this.padding=this.config.padding||[0,0,0,0];this.isTarget=(this.config.isTarget!==false);this.maintainOffset=(this.config.maintainOffset);this.primaryButtonOnly=(this.config.primaryButtonOnly!==false);this.dragOnly=((this.config.dragOnly===true)?true:false); 22 | },handleOnAvailable:function(){this.available=true;this.resetConstraints();this.onAvailable();},setPadding:function(E,C,F,D){if(!C&&0!==C){this.padding=[E,E,E,E];}else{if(!F&&0!==F){this.padding=[E,C,E,C];}else{this.padding=[E,C,F,D];}}},setInitPosition:function(F,E){var G=this.getEl();if(!this.DDM.verifyEl(G)){if(G&&G.style&&(G.style.display=="none")){}else{}return ;}var D=F||0;var C=E||0;var H=B.getXY(G);this.initPageX=H[0]-D;this.initPageY=H[1]-C;this.lastPageX=H[0];this.lastPageY=H[1];this.setStartPosition(H);},setStartPosition:function(D){var C=D||B.getXY(this.getEl());this.deltaSetXY=null;this.startPageX=C[0];this.startPageY=C[1];},addToGroup:function(C){this.groups[C]=true;this.DDM.regDragDrop(this,C);},removeFromGroup:function(C){if(this.groups[C]){delete this.groups[C];}this.DDM.removeDDFromGroup(this,C);},setDragElId:function(C){this.dragElId=C;},setHandleElId:function(C){if(typeof C!=="string"){C=B.generateId(C);}this.handleElId=C;this.DDM.regHandle(this.id,C);},setOuterHandleElId:function(C){if(typeof C!=="string"){C=B.generateId(C);}A.on(C,"mousedown",this.handleMouseDown,this,true);this.setHandleElId(C);this.hasOuterHandles=true;},unreg:function(){A.removeListener(this.id,"mousedown",this.handleMouseDown);this._domRef=null;this.DDM._remove(this);},isLocked:function(){return(this.DDM.isLocked()||this.locked);},handleMouseDown:function(H,G){var D=H.which||H.button;if(this.primaryButtonOnly&&D>1){return ;}if(this.isLocked()){return ;}var C=this.b4MouseDown(H);if(this.events.b4MouseDown){C=this.fireEvent("b4MouseDownEvent",H);}var E=this.onMouseDown(H);if(this.events.mouseDown){E=this.fireEvent("mouseDownEvent",H);}if((C===false)||(E===false)){return ;}this.DDM.refreshCache(this.groups);var F=new YAHOO.util.Point(A.getPageX(H),A.getPageY(H));if(!this.hasOuterHandles&&!this.DDM.isOverTarget(F,this)){}else{if(this.clickValidator(H)){this.setStartPosition();this.DDM.handleMouseDown(H,this);this.DDM.stopEvent(H);}else{}}},clickValidator:function(D){var C=YAHOO.util.Event.getTarget(D);return(this.isValidHandleChild(C)&&(this.id==this.handleElId||this.DDM.handleWasClicked(C,this.id)));},getTargetCoord:function(E,D){var C=E-this.deltaX;var F=D-this.deltaY;if(this.constrainX){if(Cthis.maxX){C=this.maxX;}}if(this.constrainY){if(Fthis.maxY){F=this.maxY;}}C=this.getTick(C,this.xTicks);F=this.getTick(F,this.yTicks);return{x:C,y:F};},addInvalidHandleType:function(C){var D=C.toUpperCase();this.invalidHandleTypes[D]=D;},addInvalidHandleId:function(C){if(typeof C!=="string"){C=B.generateId(C);}this.invalidHandleIds[C]=C;},addInvalidHandleClass:function(C){this.invalidHandleClasses.push(C);},removeInvalidHandleType:function(C){var D=C.toUpperCase();delete this.invalidHandleTypes[D];},removeInvalidHandleId:function(C){if(typeof C!=="string"){C=B.generateId(C);}delete this.invalidHandleIds[C];},removeInvalidHandleClass:function(D){for(var E=0,C=this.invalidHandleClasses.length;E=this.minX;D=D-C){if(!E[D]){this.xTicks[this.xTicks.length]=D;E[D]=true;}}for(D=this.initPageX;D<=this.maxX;D=D+C){if(!E[D]){this.xTicks[this.xTicks.length]=D;E[D]=true;}}this.xTicks.sort(this.DDM.numericSort);},setYTicks:function(F,C){this.yTicks=[];this.yTickSize=C;var E={};for(var D=this.initPageY;D>=this.minY;D=D-C){if(!E[D]){this.yTicks[this.yTicks.length]=D;E[D]=true;}}for(D=this.initPageY;D<=this.maxY;D=D+C){if(!E[D]){this.yTicks[this.yTicks.length]=D;E[D]=true;}}this.yTicks.sort(this.DDM.numericSort);},setXConstraint:function(E,D,C){this.leftConstraint=parseInt(E,10);this.rightConstraint=parseInt(D,10);this.minX=this.initPageX-this.leftConstraint;this.maxX=this.initPageX+this.rightConstraint;if(C){this.setXTicks(this.initPageX,C);}this.constrainX=true;},clearConstraints:function(){this.constrainX=false;this.constrainY=false;this.clearTicks();},clearTicks:function(){this.xTicks=null;this.yTicks=null;this.xTickSize=0;this.yTickSize=0;},setYConstraint:function(C,E,D){this.topConstraint=parseInt(C,10);this.bottomConstraint=parseInt(E,10);this.minY=this.initPageY-this.topConstraint;this.maxY=this.initPageY+this.bottomConstraint;if(D){this.setYTicks(this.initPageY,D);}this.constrainY=true;},resetConstraints:function(){if(this.initPageX||this.initPageX===0){var D=(this.maintainOffset)?this.lastPageX-this.initPageX:0;var C=(this.maintainOffset)?this.lastPageY-this.initPageY:0;this.setInitPosition(D,C);}else{this.setInitPosition();}if(this.constrainX){this.setXConstraint(this.leftConstraint,this.rightConstraint,this.xTickSize);}if(this.constrainY){this.setYConstraint(this.topConstraint,this.bottomConstraint,this.yTickSize);}},getTick:function(I,F){if(!F){return I;}else{if(F[0]>=I){return F[0];}else{for(var D=0,C=F.length;D=I){var H=I-F[D];var G=F[E]-I;return(G>H)?F[D]:F[E];}}return F[F.length-1];}}},toString:function(){return("DragDrop "+this.id);}};YAHOO.augment(YAHOO.util.DragDrop,YAHOO.util.EventProvider);})();YAHOO.util.DD=function(C,A,B){if(C){this.init(C,A,B);}};YAHOO.extend(YAHOO.util.DD,YAHOO.util.DragDrop,{scroll:true,autoOffset:function(C,B){var A=C-this.startPageX;var D=B-this.startPageY;this.setDelta(A,D);},setDelta:function(B,A){this.deltaX=B;this.deltaY=A;},setDragElPos:function(C,B){var A=this.getDragEl();this.alignElWithMouse(A,C,B);},alignElWithMouse:function(C,G,F){var E=this.getTargetCoord(G,F);if(!this.deltaSetXY){var H=[E.x,E.y];YAHOO.util.Dom.setXY(C,H);var D=parseInt(YAHOO.util.Dom.getStyle(C,"left"),10);var B=parseInt(YAHOO.util.Dom.getStyle(C,"top"),10);this.deltaSetXY=[D-E.x,B-E.y]; 23 | }else{YAHOO.util.Dom.setStyle(C,"left",(E.x+this.deltaSetXY[0])+"px");YAHOO.util.Dom.setStyle(C,"top",(E.y+this.deltaSetXY[1])+"px");}this.cachePosition(E.x,E.y);var A=this;setTimeout(function(){A.autoScroll.call(A,E.x,E.y,C.offsetHeight,C.offsetWidth);},0);},cachePosition:function(B,A){if(B){this.lastPageX=B;this.lastPageY=A;}else{var C=YAHOO.util.Dom.getXY(this.getEl());this.lastPageX=C[0];this.lastPageY=C[1];}},autoScroll:function(J,I,E,K){if(this.scroll){var L=this.DDM.getClientHeight();var B=this.DDM.getClientWidth();var N=this.DDM.getScrollTop();var D=this.DDM.getScrollLeft();var H=E+I;var M=K+J;var G=(L+N-I-this.deltaY);var F=(B+D-J-this.deltaX);var C=40;var A=(document.all)?80:30;if(H>L&&G0&&I-NB&&F0&&J-D0)?A.dump(D[F],I-1):L);}else{K.push(D[F]);}K.push(J);}if(K.length>1){K.pop();}K.push("]");}else{K.push("{");for(F in D){if(A.hasOwnProperty(D,F)){K.push(F+G);if(A.isObject(D[F])){K.push((I>0)?A.dump(D[F],I-1):L);}else{K.push(D[F]);}K.push(J);}}if(K.length>1){K.pop();}K.push("}");}return K.join("");},substitute:function(S,E,L){var I,H,G,O,P,R,N=[],F,J="dump",M=" ",D="{",Q="}";for(;;){I=S.lastIndexOf(D);if(I<0){break;}H=S.indexOf(Q,I);if(I+1>=H){break;}F=S.substring(I+1,H);O=F;R=null;G=O.indexOf(M);if(G>-1){R=O.substring(G+1);O=O.substring(0,G);}P=E[O];if(L){P=L(O,P,R);}if(A.isObject(P)){if(A.isArray(P)){P=A.dump(P,parseInt(R,10));}else{R=R||"";var K=R.indexOf(J);if(K>-1){R=R.substring(4);}if(P.toString===Object.prototype.toString||K>-1){P=A.dump(P,parseInt(R,10));}else{P=P.toString();}}}else{if(!A.isString(P)&&!A.isNumber(P)){P="~-"+N.length+"-~";N[N.length]=F;}}S=S.substring(0,I)+P+S.substring(H+1);}for(I=N.length-1;I>=0;I=I-1){S=S.replace(new RegExp("~-"+I+"-~"),"{"+N[I]+"}","g");}return S;},trim:function(D){try{return D.replace(/^\s+|\s+$/g,"");}catch(E){return D;}},merge:function(){var G={},E=arguments;for(var F=0,D=E.length;F=this.left&&A.right<=this.right&&A.top>=this.top&&A.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(E){var C=Math.max(this.top,E.top);var D=Math.min(this.right,E.right);var A=Math.min(this.bottom,E.bottom);var B=Math.max(this.left,E.left);if(A>=C&&D>=B){return new YAHOO.util.Region(C,D,A,B);}else{return null;}};YAHOO.util.Region.prototype.union=function(E){var C=Math.min(this.top,E.top);var D=Math.max(this.right,E.right);var A=Math.max(this.bottom,E.bottom);var B=Math.min(this.left,E.left);return new YAHOO.util.Region(C,D,A,B);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};YAHOO.util.Region.getRegion=function(D){var F=YAHOO.util.Dom.getXY(D);var C=F[1];var E=F[0]+D.offsetWidth;var A=F[1]+D.offsetHeight;var B=F[0];return new YAHOO.util.Region(C,E,A,B);};YAHOO.util.Point=function(A,B){if(YAHOO.lang.isArray(A)){B=A[1];A=A[0];}this.x=this.right=this.left=this[0]=A;this.y=this.top=this.bottom=this[1]=B;};YAHOO.util.Point.prototype=new YAHOO.util.Region();YAHOO.register("dom",YAHOO.util.Dom,{version:"2.5.2",build:"1076"});YAHOO.util.CustomEvent=function(D,B,C,A){this.type=D;this.scope=B||window;this.silent=C;this.signature=A||YAHOO.util.CustomEvent.LIST;this.subscribers=[];if(!this.silent){}var E="_YUICEOnSubscribe";if(D!==E){this.subscribeEvent=new YAHOO.util.CustomEvent(E,this,true);}this.lastError=null;};YAHOO.util.CustomEvent.LIST=0;YAHOO.util.CustomEvent.FLAT=1;YAHOO.util.CustomEvent.prototype={subscribe:function(B,C,A){if(!B){throw new Error("Invalid callback for subscriber to '"+this.type+"'");}if(this.subscribeEvent){this.subscribeEvent.fire(B,C,A);}this.subscribers.push(new YAHOO.util.Subscriber(B,C,A));},unsubscribe:function(D,F){if(!D){return this.unsubscribeAll();}var E=false;for(var B=0,A=this.subscribers.length;B0){B=I[0];}try{G=M.fn.call(L,B,M.obj);}catch(F){this.lastError=F;if(A){throw F;}}}else{try{G=M.fn.call(L,this.type,I,M.obj);}catch(H){this.lastError=H;if(A){throw H;}}}if(false===G){if(!this.silent){}break;}}}return(G!==false);},unsubscribeAll:function(){for(var A=this.subscribers.length-1;A>-1;A--){this._delete(A);}this.subscribers=[];return A;},_delete:function(A){var B=this.subscribers[A];if(B){delete B.fn;delete B.obj;}this.subscribers.splice(A,1);},toString:function(){return"CustomEvent: "+"'"+this.type+"', "+"scope: "+this.scope;}};YAHOO.util.Subscriber=function(B,C,A){this.fn=B;this.obj=YAHOO.lang.isUndefined(C)?null:C;this.override=A;};YAHOO.util.Subscriber.prototype.getScope=function(A){if(this.override){if(this.override===true){return this.obj;}else{return this.override;}}return A;};YAHOO.util.Subscriber.prototype.contains=function(A,B){if(B){return(this.fn==A&&this.obj==B);}else{return(this.fn==A);}};YAHOO.util.Subscriber.prototype.toString=function(){return"Subscriber { obj: "+this.obj+", override: "+(this.override||"no")+" }";};if(!YAHOO.util.Event){YAHOO.util.Event=function(){var H=false;var I=[];var J=[];var G=[];var E=[];var C=0;var F=[];var B=[];var A=0;var D={63232:38,63233:40,63234:37,63235:39,63276:33,63277:34,25:9};return{POLL_RETRYS:2000,POLL_INTERVAL:20,EL:0,TYPE:1,FN:2,WFN:3,UNLOAD_OBJ:3,ADJ_SCOPE:4,OBJ:5,OVERRIDE:6,lastError:null,isSafari:YAHOO.env.ua.webkit,webkit:YAHOO.env.ua.webkit,isIE:YAHOO.env.ua.ie,_interval:null,_dri:null,DOMReady:false,throwErrors:false,startInterval:function(){if(!this._interval){var K=this;var L=function(){K._tryPreloadAttach();};this._interval=setInterval(L,this.POLL_INTERVAL);}},onAvailable:function(P,M,Q,O,N){var K=(YAHOO.lang.isString(P))?[P]:P;for(var L=0;L-1;O--){U=(this.removeListener(L[O],K,T)&&U);}return U;}}if(!T||!T.call){return this.purgeElement(L,false,K);}if("unload"==K){for(O=J.length-1;O>-1;O--){V=J[O];if(V&&V[0]==L&&V[1]==K&&V[2]==T){J.splice(O,1);return true;}}return false;}var P=null;var Q=arguments[3];if("undefined"===typeof Q){Q=this._getCacheIndex(L,K,T);}if(Q>=0){P=I[Q];}if(!L||!P){return false;}if(this.useLegacyEvent(L,K)){var N=this.getLegacyIndex(L,K);var M=E[N];if(M){for(O=0,R=M.length;O0&&F.length>0);}var P=[];var R=function(T,U){var S=T;if(U.override){if(U.override===true){S=U.obj;}else{S=U.override;}}U.fn.call(S,U.obj);};var L,K,O,N,M=[];for(L=0,K=F.length;L-1;L--){O=F[L];if(!O||!O.id){F.splice(L,1);}}this.startInterval();}else{clearInterval(this._interval);this._interval=null;}this.locked=false;},purgeElement:function(O,P,R){var M=(YAHOO.lang.isString(O))?this.getEl(O):O;var Q=this.getListeners(M,R),N,K;if(Q){for(N=Q.length-1;N>-1;N--){var L=Q[N];this.removeListener(M,L.type,L.fn);}}if(P&&M&&M.childNodes){for(N=0,K=M.childNodes.length;N-1;M--){L=I[M];if(L){K.removeListener(L[K.EL],L[K.TYPE],L[K.FN],M);}}L=null;}G=null;K._simpleRemove(window,"unload",K._unload);},_getScrollLeft:function(){return this._getScroll()[1];},_getScrollTop:function(){return this._getScroll()[0];},_getScroll:function(){var K=document.documentElement,L=document.body;if(K&&(K.scrollTop||K.scrollLeft)){return[K.scrollTop,K.scrollLeft];}else{if(L){return[L.scrollTop,L.scrollLeft];}else{return[0,0];}}},regCE:function(){},_simpleAdd:function(){if(window.addEventListener){return function(M,N,L,K){M.addEventListener(N,L,(K));};}else{if(window.attachEvent){return function(M,N,L,K){M.attachEvent("on"+N,L);};}else{return function(){};}}}(),_simpleRemove:function(){if(window.removeEventListener){return function(M,N,L,K){M.removeEventListener(N,L,(K));};}else{if(window.detachEvent){return function(L,M,K){L.detachEvent("on"+M,K);};}else{return function(){};}}}()};}();(function(){var EU=YAHOO.util.Event;EU.on=EU.addListener; 10 | /* DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller */ 11 | if(EU.isIE){YAHOO.util.Event.onDOMReady(YAHOO.util.Event._tryPreloadAttach,YAHOO.util.Event,true);var n=document.createElement("p");EU._dri=setInterval(function(){try{n.doScroll("left");clearInterval(EU._dri);EU._dri=null;EU._ready();n=null;}catch(ex){}},EU.POLL_INTERVAL);}else{if(EU.webkit&&EU.webkit<525){EU._dri=setInterval(function(){var rs=document.readyState;if("loaded"==rs||"complete"==rs){clearInterval(EU._dri);EU._dri=null;EU._ready();}},EU.POLL_INTERVAL);}else{EU._simpleAdd(document,"DOMContentLoaded",EU._ready);}}EU._simpleAdd(window,"load",EU._load);EU._simpleAdd(window,"unload",EU._unload);EU._tryPreloadAttach();})();}YAHOO.util.EventProvider=function(){};YAHOO.util.EventProvider.prototype={__yui_events:null,__yui_subscribers:null,subscribe:function(A,C,F,E){this.__yui_events=this.__yui_events||{};var D=this.__yui_events[A];if(D){D.subscribe(C,F,E);}else{this.__yui_subscribers=this.__yui_subscribers||{};var B=this.__yui_subscribers;if(!B[A]){B[A]=[];}B[A].push({fn:C,obj:F,override:E});}},unsubscribe:function(C,E,G){this.__yui_events=this.__yui_events||{};var A=this.__yui_events;if(C){var F=A[C];if(F){return F.unsubscribe(E,G);}}else{var B=true;for(var D in A){if(YAHOO.lang.hasOwnProperty(A,D)){B=B&&A[D].unsubscribe(E,G);}}return B;}return false;},unsubscribeAll:function(A){return this.unsubscribe(A);},createEvent:function(G,D){this.__yui_events=this.__yui_events||{};var A=D||{};var I=this.__yui_events; 12 | if(I[G]){}else{var H=A.scope||this;var E=(A.silent);var B=new YAHOO.util.CustomEvent(G,H,E,YAHOO.util.CustomEvent.FLAT);I[G]=B;if(A.onSubscribeCallback){B.subscribeEvent.subscribe(A.onSubscribeCallback);}this.__yui_subscribers=this.__yui_subscribers||{};var F=this.__yui_subscribers[G];if(F){for(var C=0;Cthis.clickPixelThresh||C>this.clickPixelThresh){this.startDrag(this.startX,this.startY);}}if(this.dragThreshMet){if(B&&B.events.b4Drag){B.b4Drag(E);B.fireEvent("b4DragEvent",{e:E});}if(B&&B.events.drag){B.onDrag(E);B.fireEvent("dragEvent",{e:E});}if(B){this.fireEvents(E,false);}}this.stopEvent(E);}},fireEvents:function(U,K){var Z=this.dragCurrent;if(!Z||Z.isLocked()||Z.dragOnly){return ;}var M=YAHOO.util.Event.getPageX(U),L=YAHOO.util.Event.getPageY(U),O=new YAHOO.util.Point(M,L),J=Z.getTargetCoord(O.x,O.y),E=Z.getDragEl(),D=["out","over","drop","enter"],T=new YAHOO.util.Region(J.y,J.x+E.offsetWidth,J.y+E.offsetHeight,J.x),H=[],C={},P=[],a={outEvts:[],overEvts:[],dropEvts:[],enterEvts:[]};for(var R in this.dragOvers){var c=this.dragOvers[R];if(!this.isTypeOfDD(c)){continue;}if(!this.isOverTarget(O,c,this.mode,T)){a.outEvts.push(c);}H[R]=true;delete this.dragOvers[R];}for(var Q in Z.groups){if("string"!=typeof Q){continue;}for(R in this.ids[Q]){var F=this.ids[Q][R];if(!this.isTypeOfDD(F)){continue;}if(F.isTarget&&!F.isLocked()&&F!=Z){if(this.isOverTarget(O,F,this.mode,T)){C[Q]=true;if(K){a.dropEvts.push(F);}else{if(!H[F.id]){a.enterEvts.push(F);}else{a.overEvts.push(F);}this.dragOvers[F.id]=F;}}}}}this.interactionInfo={out:a.outEvts,enter:a.enterEvts,over:a.overEvts,drop:a.dropEvts,point:O,draggedRegion:T,sourceRegion:this.locationCache[Z.id],validDrop:K};for(var B in C){P.push(B);}if(K&&!a.dropEvts.length){this.interactionInfo.validDrop=false;if(Z.events.invalidDrop){Z.onInvalidDrop(U);Z.fireEvent("invalidDropEvent",{e:U});}}for(R=0;R2000){}else{setTimeout(B._addListeners,10);if(document&&document.body){B._timeoutCount+=1;}}}},handleWasClicked:function(B,D){if(this.isHandle(D,B.id)){return true;}else{var C=B.parentNode;while(C){if(this.isHandle(D,C.id)){return true;}else{C=C.parentNode;}}}return false;}};}();YAHOO.util.DDM=YAHOO.util.DragDropMgr;YAHOO.util.DDM._addListeners();}(function(){var A=YAHOO.util.Event;var B=YAHOO.util.Dom;YAHOO.util.DragDrop=function(E,C,D){if(E){this.init(E,C,D);}};YAHOO.util.DragDrop.prototype={events:null,on:function(){this.subscribe.apply(this,arguments);},id:null,config:null,dragElId:null,handleElId:null,invalidHandleTypes:null,invalidHandleIds:null,invalidHandleClasses:null,startPageX:0,startPageY:0,groups:null,locked:false,lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isTarget:true,padding:null,dragOnly:false,_domRef:null,__ygDragDrop:true,constrainX:false,constrainY:false,minX:0,maxX:0,minY:0,maxY:0,deltaX:0,deltaY:0,maintainOffset:false,xTicks:null,yTicks:null,primaryButtonOnly:true,available:false,hasOuterHandles:false,cursorIsOver:false,overlap:null,b4StartDrag:function(C,D){},startDrag:function(C,D){},b4Drag:function(C){},onDrag:function(C){},onDragEnter:function(C,D){},b4DragOver:function(C){},onDragOver:function(C,D){},b4DragOut:function(C){},onDragOut:function(C,D){},b4DragDrop:function(C){},onDragDrop:function(C,D){},onInvalidDrop:function(C){},b4EndDrag:function(C){},endDrag:function(C){},b4MouseDown:function(C){},onMouseDown:function(C){},onMouseUp:function(C){},onAvailable:function(){},getEl:function(){if(!this._domRef){this._domRef=B.get(this.id);}return this._domRef;},getDragEl:function(){return B.get(this.dragElId);},init:function(F,C,D){this.initTarget(F,C,D);A.on(this._domRef||this.id,"mousedown",this.handleMouseDown,this,true);for(var E in this.events){this.createEvent(E+"Event");}},initTarget:function(E,C,D){this.config=D||{};this.events={};this.DDM=YAHOO.util.DDM;this.groups={};if(typeof E!=="string"){this._domRef=E;E=B.generateId(E);}this.id=E;this.addToGroup((C)?C:"default");this.handleElId=E;A.onAvailable(E,this.handleOnAvailable,this,true);this.setDragElId(E);this.invalidHandleTypes={A:"A"};this.invalidHandleIds={};this.invalidHandleClasses=[];this.applyConfig();},applyConfig:function(){this.events={mouseDown:true,b4MouseDown:true,mouseUp:true,b4StartDrag:true,startDrag:true,b4EndDrag:true,endDrag:true,drag:true,b4Drag:true,invalidDrop:true,b4DragOut:true,dragOut:true,dragEnter:true,b4DragOver:true,dragOver:true,b4DragDrop:true,dragDrop:true};if(this.config.events){for(var C in this.config.events){if(this.config.events[C]===false){this.events[C]=false;}}}this.padding=this.config.padding||[0,0,0,0];this.isTarget=(this.config.isTarget!==false);this.maintainOffset=(this.config.maintainOffset);this.primaryButtonOnly=(this.config.primaryButtonOnly!==false);this.dragOnly=((this.config.dragOnly===true)?true:false); 22 | },handleOnAvailable:function(){this.available=true;this.resetConstraints();this.onAvailable();},setPadding:function(E,C,F,D){if(!C&&0!==C){this.padding=[E,E,E,E];}else{if(!F&&0!==F){this.padding=[E,C,E,C];}else{this.padding=[E,C,F,D];}}},setInitPosition:function(F,E){var G=this.getEl();if(!this.DDM.verifyEl(G)){if(G&&G.style&&(G.style.display=="none")){}else{}return ;}var D=F||0;var C=E||0;var H=B.getXY(G);this.initPageX=H[0]-D;this.initPageY=H[1]-C;this.lastPageX=H[0];this.lastPageY=H[1];this.setStartPosition(H);},setStartPosition:function(D){var C=D||B.getXY(this.getEl());this.deltaSetXY=null;this.startPageX=C[0];this.startPageY=C[1];},addToGroup:function(C){this.groups[C]=true;this.DDM.regDragDrop(this,C);},removeFromGroup:function(C){if(this.groups[C]){delete this.groups[C];}this.DDM.removeDDFromGroup(this,C);},setDragElId:function(C){this.dragElId=C;},setHandleElId:function(C){if(typeof C!=="string"){C=B.generateId(C);}this.handleElId=C;this.DDM.regHandle(this.id,C);},setOuterHandleElId:function(C){if(typeof C!=="string"){C=B.generateId(C);}A.on(C,"mousedown",this.handleMouseDown,this,true);this.setHandleElId(C);this.hasOuterHandles=true;},unreg:function(){A.removeListener(this.id,"mousedown",this.handleMouseDown);this._domRef=null;this.DDM._remove(this);},isLocked:function(){return(this.DDM.isLocked()||this.locked);},handleMouseDown:function(H,G){var D=H.which||H.button;if(this.primaryButtonOnly&&D>1){return ;}if(this.isLocked()){return ;}var C=this.b4MouseDown(H);if(this.events.b4MouseDown){C=this.fireEvent("b4MouseDownEvent",H);}var E=this.onMouseDown(H);if(this.events.mouseDown){E=this.fireEvent("mouseDownEvent",H);}if((C===false)||(E===false)){return ;}this.DDM.refreshCache(this.groups);var F=new YAHOO.util.Point(A.getPageX(H),A.getPageY(H));if(!this.hasOuterHandles&&!this.DDM.isOverTarget(F,this)){}else{if(this.clickValidator(H)){this.setStartPosition();this.DDM.handleMouseDown(H,this);this.DDM.stopEvent(H);}else{}}},clickValidator:function(D){var C=YAHOO.util.Event.getTarget(D);return(this.isValidHandleChild(C)&&(this.id==this.handleElId||this.DDM.handleWasClicked(C,this.id)));},getTargetCoord:function(E,D){var C=E-this.deltaX;var F=D-this.deltaY;if(this.constrainX){if(Cthis.maxX){C=this.maxX;}}if(this.constrainY){if(Fthis.maxY){F=this.maxY;}}C=this.getTick(C,this.xTicks);F=this.getTick(F,this.yTicks);return{x:C,y:F};},addInvalidHandleType:function(C){var D=C.toUpperCase();this.invalidHandleTypes[D]=D;},addInvalidHandleId:function(C){if(typeof C!=="string"){C=B.generateId(C);}this.invalidHandleIds[C]=C;},addInvalidHandleClass:function(C){this.invalidHandleClasses.push(C);},removeInvalidHandleType:function(C){var D=C.toUpperCase();delete this.invalidHandleTypes[D];},removeInvalidHandleId:function(C){if(typeof C!=="string"){C=B.generateId(C);}delete this.invalidHandleIds[C];},removeInvalidHandleClass:function(D){for(var E=0,C=this.invalidHandleClasses.length;E=this.minX;D=D-C){if(!E[D]){this.xTicks[this.xTicks.length]=D;E[D]=true;}}for(D=this.initPageX;D<=this.maxX;D=D+C){if(!E[D]){this.xTicks[this.xTicks.length]=D;E[D]=true;}}this.xTicks.sort(this.DDM.numericSort);},setYTicks:function(F,C){this.yTicks=[];this.yTickSize=C;var E={};for(var D=this.initPageY;D>=this.minY;D=D-C){if(!E[D]){this.yTicks[this.yTicks.length]=D;E[D]=true;}}for(D=this.initPageY;D<=this.maxY;D=D+C){if(!E[D]){this.yTicks[this.yTicks.length]=D;E[D]=true;}}this.yTicks.sort(this.DDM.numericSort);},setXConstraint:function(E,D,C){this.leftConstraint=parseInt(E,10);this.rightConstraint=parseInt(D,10);this.minX=this.initPageX-this.leftConstraint;this.maxX=this.initPageX+this.rightConstraint;if(C){this.setXTicks(this.initPageX,C);}this.constrainX=true;},clearConstraints:function(){this.constrainX=false;this.constrainY=false;this.clearTicks();},clearTicks:function(){this.xTicks=null;this.yTicks=null;this.xTickSize=0;this.yTickSize=0;},setYConstraint:function(C,E,D){this.topConstraint=parseInt(C,10);this.bottomConstraint=parseInt(E,10);this.minY=this.initPageY-this.topConstraint;this.maxY=this.initPageY+this.bottomConstraint;if(D){this.setYTicks(this.initPageY,D);}this.constrainY=true;},resetConstraints:function(){if(this.initPageX||this.initPageX===0){var D=(this.maintainOffset)?this.lastPageX-this.initPageX:0;var C=(this.maintainOffset)?this.lastPageY-this.initPageY:0;this.setInitPosition(D,C);}else{this.setInitPosition();}if(this.constrainX){this.setXConstraint(this.leftConstraint,this.rightConstraint,this.xTickSize);}if(this.constrainY){this.setYConstraint(this.topConstraint,this.bottomConstraint,this.yTickSize);}},getTick:function(I,F){if(!F){return I;}else{if(F[0]>=I){return F[0];}else{for(var D=0,C=F.length;D=I){var H=I-F[D];var G=F[E]-I;return(G>H)?F[D]:F[E];}}return F[F.length-1];}}},toString:function(){return("DragDrop "+this.id);}};YAHOO.augment(YAHOO.util.DragDrop,YAHOO.util.EventProvider);})();YAHOO.util.DD=function(C,A,B){if(C){this.init(C,A,B);}};YAHOO.extend(YAHOO.util.DD,YAHOO.util.DragDrop,{scroll:true,autoOffset:function(C,B){var A=C-this.startPageX;var D=B-this.startPageY;this.setDelta(A,D);},setDelta:function(B,A){this.deltaX=B;this.deltaY=A;},setDragElPos:function(C,B){var A=this.getDragEl();this.alignElWithMouse(A,C,B);},alignElWithMouse:function(C,G,F){var E=this.getTargetCoord(G,F);if(!this.deltaSetXY){var H=[E.x,E.y];YAHOO.util.Dom.setXY(C,H);var D=parseInt(YAHOO.util.Dom.getStyle(C,"left"),10);var B=parseInt(YAHOO.util.Dom.getStyle(C,"top"),10);this.deltaSetXY=[D-E.x,B-E.y]; 23 | }else{YAHOO.util.Dom.setStyle(C,"left",(E.x+this.deltaSetXY[0])+"px");YAHOO.util.Dom.setStyle(C,"top",(E.y+this.deltaSetXY[1])+"px");}this.cachePosition(E.x,E.y);var A=this;setTimeout(function(){A.autoScroll.call(A,E.x,E.y,C.offsetHeight,C.offsetWidth);},0);},cachePosition:function(B,A){if(B){this.lastPageX=B;this.lastPageY=A;}else{var C=YAHOO.util.Dom.getXY(this.getEl());this.lastPageX=C[0];this.lastPageY=C[1];}},autoScroll:function(J,I,E,K){if(this.scroll){var L=this.DDM.getClientHeight();var B=this.DDM.getClientWidth();var N=this.DDM.getScrollTop();var D=this.DDM.getScrollLeft();var H=E+I;var M=K+J;var G=(L+N-I-this.deltaY);var F=(B+D-J-this.deltaX);var C=40;var A=(document.all)?80:30;if(H>L&&G0&&I-NB&&F0&&J-D "),c.isObject(a[f])?e.push(0d)break;f=a.indexOf("}",d);if(d+1>=f)break;n=p=a.substring(d+1,f);h=null;l=n.indexOf(" ");-1=this.left&&c.right<=this.right&&c.top>=this.top&&c.bottom<=this.bottom}; 30 | YAHOO.util.Region.prototype.getArea=function(){return(this.bottom-this.top)*(this.right-this.left)};YAHOO.util.Region.prototype.intersect=function(c){var b=Math.max(this.top,c.top),a=Math.min(this.right,c.right),d=Math.min(this.bottom,c.bottom);c=Math.max(this.left,c.left);return d>=b&&a>=c?new YAHOO.util.Region(b,a,d,c):null}; 31 | YAHOO.util.Region.prototype.union=function(c){return new YAHOO.util.Region(Math.min(this.top,c.top),Math.max(this.right,c.right),Math.max(this.bottom,c.bottom),Math.min(this.left,c.left))};YAHOO.util.Region.prototype.toString=function(){return"Region {top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}"};YAHOO.util.Region.getRegion=function(c){var b=YAHOO.util.Dom.getXY(c);return new YAHOO.util.Region(b[1],b[0]+c.offsetWidth,b[1]+c.offsetHeight,b[0])}; 32 | YAHOO.util.Point=function(c,b){YAHOO.lang.isArray(c)&&(b=c[1],c=c[0]);this.x=this.right=this.left=this[0]=c;this.y=this.top=this.bottom=this[1]=b};YAHOO.util.Point.prototype=new YAHOO.util.Region;YAHOO.register("dom",YAHOO.util.Dom,{version:"2.5.2",build:"1076"}); 33 | YAHOO.util.CustomEvent=function(c,b,a,d){this.type=c;this.scope=b||window;this.silent=a;this.signature=d||YAHOO.util.CustomEvent.LIST;this.subscribers=[];"_YUICEOnSubscribe"!==c&&(this.subscribeEvent=new YAHOO.util.CustomEvent("_YUICEOnSubscribe",this,!0));this.lastError=null};YAHOO.util.CustomEvent.LIST=0;YAHOO.util.CustomEvent.FLAT=1; 34 | YAHOO.util.CustomEvent.prototype={subscribe:function(c,b,a){if(!c)throw Error("Invalid callback for subscriber to '"+this.type+"'");this.subscribeEvent&&this.subscribeEvent.fire(c,b,a);this.subscribers.push(new YAHOO.util.Subscriber(c,b,a))},unsubscribe:function(c,b){if(!c)return this.unsubscribeAll();for(var a=!1,d=0,f=this.subscribers.length;da)?!0:!1},removeListener:function(c,d,e,k){var h,g,m;if("string"==typeof c)c=this.getEl(c);else if(this._isValidCollection(c)){k=!0;for(h=c.length-1;-1c.webkit?c._dri=setInterval(function(){var a=document.readyState;if("loaded"==a||"complete"==a)clearInterval(c._dri),c._dri=null,c._ready()},c.POLL_INTERVAL):c._simpleAdd(document,"DOMContentLoaded",c._ready);c._simpleAdd(window,"load",c._load);c._simpleAdd(window,"unload",c._unload);c._tryPreloadAttach()}());YAHOO.util.EventProvider=function(){}; 54 | YAHOO.util.EventProvider.prototype={__yui_events:null,__yui_subscribers:null,subscribe:function(c,b,a,d){this.__yui_events=this.__yui_events||{};var f=this.__yui_events[c];f?f.subscribe(b,a,d):(f=this.__yui_subscribers=this.__yui_subscribers||{},f[c]||(f[c]=[]),f[c].push({fn:b,obj:a,override:d}))},unsubscribe:function(c,b,a){var d=this.__yui_events=this.__yui_events||{};if(c){if(d=d[c])return d.unsubscribe(b,a)}else{c=!0;for(var f in d)YAHOO.lang.hasOwnProperty(d,f)&&(c=c&&d[f].unsubscribe(b,a)); 55 | return c}return!1},unsubscribeAll:function(c){return this.unsubscribe(c)},createEvent:function(c,b){this.__yui_events=this.__yui_events||{};var a=b||{};b=this.__yui_events;if(!b[c]){var d=new YAHOO.util.CustomEvent(c,a.scope||this,a.silent,YAHOO.util.CustomEvent.FLAT);b[c]=d;a.onSubscribeCallback&&d.subscribeEvent.subscribe(a.onSubscribeCallback);this.__yui_subscribers=this.__yui_subscribers||{};if(a=this.__yui_subscribers[c])for(var f=0;fthis.clickPixelThresh||f>this.clickPixelThresh)&&this.startDrag(this.startX,this.startY)}this.dragThreshMet&&(a&&a.events.b4Drag&&(a.b4Drag(b),a.fireEvent("b4DragEvent",{e:b})),a&&a.events.drag&&(a.onDrag(b),a.fireEvent("dragEvent",{e:b})),a&&this.fireEvents(b,!1));this.stopEvent(b)}},fireEvents:function(b,a){var c=this.dragCurrent;if(c&&!c.isLocked()&&!c.dragOnly){var f=YAHOO.util.Event.getPageX(b),g=YAHOO.util.Event.getPageY(b),e=new YAHOO.util.Point(f, 69 | g),g=c.getTargetCoord(e.x,e.y),k=c.getDragEl(),f=["out","over","drop","enter"],l=new YAHOO.util.Region(g.y,g.x+k.offsetWidth,g.y+k.offsetHeight,g.x),n=[],h={},g=[],k={outEvts:[],overEvts:[],dropEvts:[],enterEvts:[]},m;for(m in this.dragOvers){var p=this.dragOvers[m];this.isTypeOfDD(p)&&(this.isOverTarget(e,p,this.mode,l)||k.outEvts.push(p),n[m]=!0,delete this.dragOvers[m])}for(var t in c.groups)if("string"==typeof t)for(m in this.ids[t])p=this.ids[t][m],this.isTypeOfDD(p)&&p.isTarget&&!p.isLocked()&& 70 | p!=c&&this.isOverTarget(e,p,this.mode,l)&&(h[t]=!0,a?k.dropEvts.push(p):(n[p.id]?k.overEvts.push(p):k.enterEvts.push(p),this.dragOvers[p.id]=p));this.interactionInfo={out:k.outEvts,enter:k.enterEvts,over:k.overEvts,drop:k.dropEvts,point:e,draggedRegion:l,sourceRegion:this.locationCache[c.id],validDrop:a};for(var q in h)g.push(q);a&&!k.dropEvts.length&&(this.interactionInfo.validDrop=!1,c.events.invalidDrop&&(c.onInvalidDrop(b),c.fireEvent("invalidDropEvent",{e:b})));for(m=0;mthis.maxX&&(a=this.maxX));this.constrainY&&(bthis.maxY&&(b=this.maxY));a=this.getTick(a,this.xTicks);b=this.getTick(b,this.yTicks); 88 | return{x:a,y:b}},addInvalidHandleType:function(a){a=a.toUpperCase();this.invalidHandleTypes[a]=a},addInvalidHandleId:function(a){"string"!==typeof a&&(a=b.generateId(a));this.invalidHandleIds[a]=a},addInvalidHandleClass:function(a){this.invalidHandleClasses.push(a)},removeInvalidHandleType:function(a){a=a.toUpperCase();delete this.invalidHandleTypes[a]},removeInvalidHandleId:function(a){"string"!==typeof a&&(a=b.generateId(a));delete this.invalidHandleIds[a]},removeInvalidHandleClass:function(a){for(var b= 89 | 0,c=this.invalidHandleClasses.length;b=this.minX;c-=b)a[c]|| 90 | (this.xTicks[this.xTicks.length]=c,a[c]=!0);for(c=this.initPageX;c<=this.maxX;c+=b)a[c]||(this.xTicks[this.xTicks.length]=c,a[c]=!0);this.xTicks.sort(this.DDM.numericSort)},setYTicks:function(a,b){this.yTicks=[];this.yTickSize=b;a={};for(var c=this.initPageY;c>=this.minY;c-=b)a[c]||(this.yTicks[this.yTicks.length]=c,a[c]=!0);for(c=this.initPageY;c<=this.maxY;c+=b)a[c]||(this.yTicks[this.yTicks.length]=c,a[c]=!0);this.yTicks.sort(this.DDM.numericSort)},setXConstraint:function(a,b,c){this.leftConstraint= 91 | parseInt(a,10);this.rightConstraint=parseInt(b,10);this.minX=this.initPageX-this.leftConstraint;this.maxX=this.initPageX+this.rightConstraint;c&&this.setXTicks(this.initPageX,c);this.constrainX=!0},clearConstraints:function(){this.constrainY=this.constrainX=!1;this.clearTicks()},clearTicks:function(){this.yTicks=this.xTicks=null;this.yTickSize=this.xTickSize=0},setYConstraint:function(a,b,c){this.topConstraint=parseInt(a,10);this.bottomConstraint=parseInt(b,10);this.minY=this.initPageY-this.topConstraint; 92 | this.maxY=this.initPageY+this.bottomConstraint;c&&this.setYTicks(this.initPageY,c);this.constrainY=!0},resetConstraints:function(){this.initPageX||0===this.initPageX?this.setInitPosition(this.maintainOffset?this.lastPageX-this.initPageX:0,this.maintainOffset?this.lastPageY-this.initPageY:0):this.setInitPosition();this.constrainX&&this.setXConstraint(this.leftConstraint,this.rightConstraint,this.xTickSize);this.constrainY&&this.setYConstraint(this.topConstraint,this.bottomConstraint,this.yTickSize)}, 93 | getTick:function(a,b){if(b){if(b[0]>=a)return b[0];for(var c=0,d=b.length;c=a)return b[e]-a>a-b[c]?b[c]:b[e]}return b[b.length-1]}return a},toString:function(){return"DragDrop "+this.id}};YAHOO.augment(YAHOO.util.DragDrop,YAHOO.util.EventProvider)})();YAHOO.util.DD=function(c,b,a){c&&this.init(c,b,a)}; 94 | YAHOO.extend(YAHOO.util.DD,YAHOO.util.DragDrop,{scroll:!0,autoOffset:function(c,b){this.setDelta(c-this.startPageX,b-this.startPageY)},setDelta:function(c,b){this.deltaX=c;this.deltaY=b},setDragElPos:function(c,b){var a=this.getDragEl();this.alignElWithMouse(a,c,b)},alignElWithMouse:function(c,b,a){var d=this.getTargetCoord(b,a);this.deltaSetXY?(YAHOO.util.Dom.setStyle(c,"left",d.x+this.deltaSetXY[0]+"px"),YAHOO.util.Dom.setStyle(c,"top",d.y+this.deltaSetXY[1]+"px")):(YAHOO.util.Dom.setXY(c,[d.x, 95 | d.y]),b=parseInt(YAHOO.util.Dom.getStyle(c,"left"),10),a=parseInt(YAHOO.util.Dom.getStyle(c,"top"),10),this.deltaSetXY=[b-d.x,a-d.y]);this.cachePosition(d.x,d.y);var f=this;setTimeout(function(){f.autoScroll.call(f,d.x,d.y,c.offsetHeight,c.offsetWidth)},0)},cachePosition:function(c,b){c?(this.lastPageX=c,this.lastPageY=b):(c=YAHOO.util.Dom.getXY(this.getEl()),this.lastPageX=c[0],this.lastPageY=c[1])},autoScroll:function(c,b,a,d){if(this.scroll){var f=this.DDM.getClientHeight(),g=this.DDM.getClientWidth(), 96 | e=this.DDM.getScrollTop(),k=this.DDM.getScrollLeft();d+=c;var l=f+e-b-this.deltaY,n=g+k-c-this.deltaX,h=document.all?80:30;a+b>f&&40>l&&window.scrollTo(k,e+h);bb-e&&window.scrollTo(k,e-h);d>g&&40>n&&window.scrollTo(k+h,e);cc-k&&window.scrollTo(k-h,e)}},applyConfig:function(){YAHOO.util.DD.superclass.applyConfig.call(this);this.scroll=!1!==this.config.scroll},b4MouseDown:function(c){this.setStartPosition();this.autoOffset(YAHOO.util.Event.getPageX(c),YAHOO.util.Event.getPageY(c))}, 97 | b4Drag:function(c){this.setDragElPos(YAHOO.util.Event.getPageX(c),YAHOO.util.Event.getPageY(c))},toString:function(){return"DD "+this.id}});YAHOO.util.DDProxy=function(c,b,a){c&&(this.init(c,b,a),this.initFrame())};YAHOO.util.DDProxy.dragElId="ygddfdiv"; 98 | YAHOO.extend(YAHOO.util.DDProxy,YAHOO.util.DD,{resizeFrame:!0,centerFrame:!1,createFrame:function(){var c=this,b=document.body;if(b&&b.firstChild){var a=this.getDragEl(),d=YAHOO.util.Dom;if(!a){a=document.createElement("div");a.id=this.dragElId;var f=a.style;f.position="absolute";f.visibility="hidden";f.cursor="move";f.border="2px solid #aaa";f.zIndex=999;f.height="25px";f.width="25px";f=document.createElement("div");d.setStyle(f,"height","100%");d.setStyle(f,"width","100%");d.setStyle(f,"background-color", 99 | "#ccc");d.setStyle(f,"opacity","0");a.appendChild(f);YAHOO.env.ua.ie&&(f=document.createElement("iframe"),f.setAttribute("src","javascript:"),f.setAttribute("scrolling","no"),f.setAttribute("frameborder","0"),a.insertBefore(f,a.firstChild),d.setStyle(f,"height","100%"),d.setStyle(f,"width","100%"),d.setStyle(f,"position","absolute"),d.setStyle(f,"top","0"),d.setStyle(f,"left","0"),d.setStyle(f,"opacity","0"),d.setStyle(f,"zIndex","-1"),d.setStyle(f.nextSibling,"zIndex","2"));b.insertBefore(a,b.firstChild)}}else setTimeout(function(){c.createFrame()}, 100 | 50)},initFrame:function(){this.createFrame()},applyConfig:function(){YAHOO.util.DDProxy.superclass.applyConfig.call(this);this.resizeFrame=!1!==this.config.resizeFrame;this.centerFrame=this.config.centerFrame;this.setDragElId(this.config.dragElId||YAHOO.util.DDProxy.dragElId)},showFrame:function(c,b){this.getEl();var a=this.getDragEl(),d=a.style;this._resizeProxy();this.centerFrame&&this.setDelta(Math.round(parseInt(d.width,10)/2),Math.round(parseInt(d.height,10)/2));this.setDragElPos(c,b);YAHOO.util.Dom.setStyle(a, 101 | "visibility","visible")},_resizeProxy:function(){if(this.resizeFrame){var c=YAHOO.util.Dom,b=this.getEl(),a=this.getDragEl(),d=parseInt(c.getStyle(a,"borderTopWidth"),10),f=parseInt(c.getStyle(a,"borderRightWidth"),10),g=parseInt(c.getStyle(a,"borderBottomWidth"),10),e=parseInt(c.getStyle(a,"borderLeftWidth"),10);isNaN(d)&&(d=0);isNaN(f)&&(f=0);isNaN(g)&&(g=0);isNaN(e)&&(e=0);d=Math.max(0,b.offsetHeight-d-g);c.setStyle(a,"width",Math.max(0,b.offsetWidth-f-e)+"px");c.setStyle(a,"height",d+"px")}}, 102 | b4MouseDown:function(c){this.setStartPosition();var b=YAHOO.util.Event.getPageX(c);c=YAHOO.util.Event.getPageY(c);this.autoOffset(b,c)},b4StartDrag:function(c,b){this.showFrame(c,b)},b4EndDrag:function(c){YAHOO.util.Dom.setStyle(this.getDragEl(),"visibility","hidden")},endDrag:function(c){c=YAHOO.util.Dom;var b=this.getEl(),a=this.getDragEl();c.setStyle(a,"visibility","");c.setStyle(b,"visibility","hidden");YAHOO.util.DDM.moveToEl(b,a);c.setStyle(a,"visibility","hidden");c.setStyle(b,"visibility", 103 | "")},toString:function(){return"DDProxy "+this.id}});YAHOO.util.DDTarget=function(c,b,a){c&&this.initTarget(c,b,a)};YAHOO.extend(YAHOO.util.DDTarget,YAHOO.util.DragDrop,{toString:function(){return"DDTarget "+this.id}});YAHOO.register("dragdrop",YAHOO.util.DragDropMgr,{version:"2.5.2",build:"1076"});YAHOO.util.Attribute=function(c,b){b&&(this.owner=b,this.configure(c,!0))}; 104 | YAHOO.util.Attribute.prototype={name:void 0,value:null,owner:null,readOnly:!1,writeOnce:!1,_initialConfig:null,_written:!1,method:null,validator:null,getValue:function(){return this.value},setValue:function(c,b){var a=this.owner,d=this.name,f={type:d,prevValue:this.getValue(),newValue:c};if(this.readOnly||this.writeOnce&&this._written||this.validator&&!this.validator.call(a,c))return!1;if(!b){var g=a.fireBeforeChangeEvent(f);if(!1===g)return!1}this.method&&this.method.call(a,c);this.value=c;this._written= 105 | !0;f.type=d;b||this.owner.fireChangeEvent(f);return!0},configure:function(c,b){c=c||{};this._written=!1;this._initialConfig=this._initialConfig||{};for(var a in c)a&&YAHOO.lang.hasOwnProperty(c,a)&&(this[a]=c[a],b&&(this._initialConfig[a]=c[a]))},resetValue:function(){return this.setValue(this._initialConfig.value)},resetConfig:function(){this.configure(this._initialConfig)},refresh:function(c){this.setValue(this.value,c)}}; 106 | (function(){var c=YAHOO.util.Lang;YAHOO.util.AttributeProvider=function(){};YAHOO.util.AttributeProvider.prototype={_configs:null,get:function(b){this._configs=this._configs||{};if(b=this._configs[b])return b.value},set:function(b,a,c){this._configs=this._configs||{};return(b=this._configs[b])?b.setValue(a,c):!1},getAttributeKeys:function(){this._configs=this._configs;var b=[],a;for(a in this._configs){var d=this._configs[a];c.hasOwnProperty(this._configs,a)&&!c.isUndefined(d)&&(b[b.length]=a)}return b}, 107 | setAttributes:function(b,a){for(var d in b)c.hasOwnProperty(b,d)&&this.set(d,b[d],a)},resetValue:function(b,a){this._configs=this._configs||{};return this._configs[b]?(this.set(b,this._configs[b]._initialConfig.value,a),!0):!1},refresh:function(b,a){this._configs=this._configs;b=(c.isString(b)?[b]:b)||this.getAttributeKeys();for(var d=0,f=b.length;d "WHITESPACE_ONLY").compile(ORIGINAL).strip 25 | assert_equal js, COMPILED_WHITESPACE 26 | end 27 | 28 | def test_simple_compression 29 | js = Compiler.new.compile(ORIGINAL).strip 30 | assert_equal js, COMPILED_SIMPLE 31 | end 32 | 33 | def test_advanced_compression 34 | js = Compiler.new(:compilation_level => "ADVANCED_OPTIMIZATIONS").compile(ORIGINAL).strip 35 | assert_equal js, COMPILED_ADVANCED 36 | end 37 | 38 | def test_block_syntax 39 | result = '' 40 | Compiler.new(:compilation_level => "ADVANCED_OPTIMIZATIONS").compile(ORIGINAL) do |code| 41 | while buffer = code.read(3) 42 | result << buffer 43 | end 44 | end 45 | assert_equal result.strip, COMPILED_ADVANCED 46 | end 47 | 48 | def test_jar_and_java_specifiation 49 | jar = Dir['vendor/closure-compiler-*.jar'].first 50 | unless java = ( `which java` rescue nil ) 51 | java = `where java` rescue nil # works on newer windows 52 | end 53 | if java 54 | compiler = Compiler.new(:java => java.strip, :jar_file => jar) 55 | assert_equal compiler.compress(ORIGINAL).strip, COMPILED_SIMPLE 56 | else 57 | puts "could not `which/where java` skipping test" 58 | end 59 | end 60 | 61 | def test_exceptions 62 | assert_raises(Closure::Error) do 63 | Compiler.new.compile('1++') 64 | end 65 | assert_raises(Closure::Error) do 66 | Compiler.new.compile('obj = [1 2, 3]') 67 | end 68 | end 69 | 70 | def test_stderr_reading 71 | js = Compiler.new.compile(File.read('test/fixtures/precompressed.js')) 72 | assert js == File.read('test/fixtures/precompressed-compiled.js') 73 | end 74 | 75 | def test_permissions 76 | assert File.executable?(COMPILER_JAR) 77 | end 78 | 79 | def test_serialize_options 80 | options = { 'externs' => 'library1.js', "compilation_level" => "ADVANCED_OPTIMIZATIONS" } 81 | # ["--externs", "library1.js", "--compilation_level", "ADVANCED_OPTIMIZATIONS"] 82 | # although Hash in 1.8 might change the order to : 83 | # ["--compilation_level", "ADVANCED_OPTIMIZATIONS", "--externs", "library1.js"] 84 | expected_options = options.to_a.map { |arr| [ "--#{arr[0]}", arr[1] ] }.flatten 85 | assert_equal expected_options, Closure::Compiler.new.send(:serialize_options, options) 86 | end 87 | 88 | def test_serialize_options_for_arrays 89 | compiler = Closure::Compiler.new('externs' => ['library1.js', "library2.js"]) 90 | assert_equal ["--externs", "library1.js", "--externs", "library2.js"], compiler.send(:serialize_options, 'externs' => ['library1.js', "library2.js"]) 91 | end 92 | 93 | def test_compiling_array_of_file_paths 94 | files = ['test/fixtures/file1.js', 'test/fixtures/file2.js'] 95 | result = Closure::Compiler.new().compile_files(files) 96 | 97 | assert_equal result, File.read('test/fixtures/file1-file2-compiled.js') 98 | end 99 | end 100 | --------------------------------------------------------------------------------