mizugumo 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -8,4 +8,5 @@ group :development do
8
8
  gem 'haml'
9
9
  gem "jeweler", "~> 1.5.2"
10
10
  gem "rcov", ">= 0"
11
+ gem 'ruby-debug19'
11
12
  end
@@ -1,6 +1,8 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ archive-tar-minitar (0.5.2)
5
+ columnize (0.3.4)
4
6
  diff-lcs (1.1.2)
5
7
  git (1.2.5)
6
8
  haml (3.0.25)
@@ -8,6 +10,8 @@ GEM
8
10
  bundler (~> 1.0.0)
9
11
  git (>= 1.2.5)
10
12
  rake
13
+ linecache19 (0.5.12)
14
+ ruby_core_source (>= 0.1.4)
11
15
  rake (0.8.7)
12
16
  rcov (0.9.9)
13
17
  rspec (2.4.0)
@@ -18,6 +22,16 @@ GEM
18
22
  rspec-expectations (2.4.0)
19
23
  diff-lcs (~> 1.1.2)
20
24
  rspec-mocks (2.4.0)
25
+ ruby-debug-base19 (0.11.25)
26
+ columnize (>= 0.3.1)
27
+ linecache19 (>= 0.5.11)
28
+ ruby_core_source (>= 0.1.4)
29
+ ruby-debug19 (0.11.6)
30
+ columnize (>= 0.3.1)
31
+ linecache19 (>= 0.5.11)
32
+ ruby-debug-base19 (>= 0.11.19)
33
+ ruby_core_source (0.1.5)
34
+ archive-tar-minitar (>= 0.5.2)
21
35
 
22
36
  PLATFORMS
23
37
  ruby
@@ -28,3 +42,4 @@ DEPENDENCIES
28
42
  jeweler (~> 1.5.2)
29
43
  rcov
30
44
  rspec (>= 1.5)
45
+ ruby-debug19
@@ -21,9 +21,6 @@ working. The installer will copy a jQuery-compatible version of rails.js that y
21
21
  use instead if you depend on Rails' default (semi-obtrusive) approaches to AJAX,
22
22
  link_to with :confirm =>'Are you sure?' and similar things working.
23
23
 
24
- In addition, NinjaScript currently requires jQuery 1.4.2. It is NOT compatible with the current version of jQuery, 1.5.
25
- We are eagerly working on a fix.
26
-
27
24
  == Features
28
25
 
29
26
  Mizugumo's main features are:
@@ -45,24 +42,37 @@ Second, install Mizugumo files:
45
42
 
46
43
  rails generate mizugumo:install
47
44
 
48
- Third, link to jQuery and NinjaScript in your application layout, plus the optional ninjascript.css. If using ERB, add these lines:
45
+ The next step depends on whether you are running Rails 3.0.x or 3.1.x.
46
+
47
+ === Rails 3.0.x
48
+
49
+ For 3.0.x, mizugumo will assume you are putting most of your application javascript code in public/javascripts/application.js. The installer will have created a Ninja.orders() block in which to place Ninjascript behavior. The last line of this block will be Ninja.go(), and that must remain the last line.
50
+
51
+ You will need to link to jQuery and NinjaScript in your application layout, and you may include the optional mizugumo.css. (a SASS version is installed to public/stylesheets/sass/mizugumo.sass).
49
52
 
50
- <%= javascript_include_tag 'jquery-1.4.2.js' %>
53
+ Add these lines to your layout (in ERB):
54
+
55
+ <%= javascript_include_tag 'jquery-1.6.4.js' %>
51
56
  <%= javascript_include_tag 'jquery.ninja_script.js' %>
52
57
  <%= javascript_include_tag 'application.js' %>
53
- <%= stylesheet_link_tag 'ninjascript' %>
58
+ <%= stylesheet_link_tag 'mizugumo' %>
54
59
 
55
60
  If using Haml, add these instead:
56
61
 
57
- = javascript_include_tag 'jquery-1.4.2.js'
62
+ = javascript_include_tag 'jquery-1.6.4.js'
58
63
  = javascript_include_tag 'jquery.ninja_script.js'
59
64
  = javascript_include_tag 'application.js'
60
- = stylesheet_link_tag 'ninjascript'
65
+ = stylesheet_link_tag 'mizugumo'
61
66
 
62
67
  NOTE: If you still have javascript_include_tag :defaults, you probably want to remove it.
63
68
  Ninjascript is meant to work with jQuery, and we don't know what happens if you try to run it
64
69
  side-by-side with Prototype.
65
70
 
71
+ === Rails 3.1.x
72
+
73
+ For 3.1.x, mizugumo uses the rails asset packager, so there is less for you to do. ninjascript.js, mizugumo.js, and a file called ninja_go.js are added to your app/assets/javascripts directory, and lines are added to you manifest (app/assets/javascripts/application.js) to ensure that they are loaded in the right order.
74
+
75
+
66
76
  == Graceful degradation of :method => 'delete' (or PUT, or POST) links
67
77
 
68
78
  Rails' concept of REST runs headlong into the desire to make a site degrade
@@ -121,6 +131,7 @@ For ERB views:
121
131
  config.generators do |g|
122
132
  g.scaffold_controller 'mizugumo:scaffold_controller'
123
133
  g.template_engine 'mizugumo:erb'
134
+ g.assets 'mizugumo:js_assets' # Only needed for Rails 3.1, omit for Rails 3.0
124
135
  end
125
136
 
126
137
  For Haml views:
@@ -128,8 +139,34 @@ For Haml views:
128
139
  config.generators do |g|
129
140
  g.scaffold_controller 'mizugumo:scaffold_controller'
130
141
  g.template_engine 'mizugumo:haml'
142
+ g.assets 'mizugumo:js_assets' # Only needed for Rails 3.1, omit for Rails 3.0
131
143
  end
132
144
 
145
+ Run the scaffold generator as you would with any other Rails app. Mizugumo will
146
+ generate both HTML views (in ERB or HAML), and JavaScript views (action.js.rb) for
147
+ the actions in each controller, and will generate the NinjaScript code to allow your
148
+ scaffold to function as an AJAX scaffold when Javascript is available.
149
+
150
+ In Rails 3.0, the NinjaScript code is injected into public/javascripts/application.js,
151
+ inside the Ninja.orders() block created by the installer. In Rails 3.1, a new file
152
+ with the code is created in app/assets/javascripts/<controller_name>.js.
153
+
154
+ == FAQ
155
+
156
+ === What is Ninja.orders()?
157
+
158
+ NinjaScript's development is modularized using the RequireJS library. One unfortunate
159
+ side effect of RequireJS is that modules get loaded asynchronously, and so even if
160
+ a file is required first, its code is not guaranteed to be available when you load
161
+ a subsjquent file. So, if you required NinjaScript.js, and then began defining Ninja
162
+ behaviors like so:
163
+
164
+ Ninja.behavior({ 'selector': Ninja.someCoolBehavior } )
165
+
166
+ It is possible that Ninja's behaviors are not fully loaded, because RequireJS hasn't
167
+ finished loading them. Boo! So, Ninja.orders() is defined so to queue up all commands
168
+ (behaviors and the "go") command, so that they will get executed as soon as
169
+ NinjaScript has finished loading.
133
170
 
134
171
  == Contributing to Mizugumo
135
172
 
@@ -151,5 +188,7 @@ Use the GitHub issue tracker.
151
188
  Copyright (c) 2011 Evan Dorn and Logical Reality Design. See LICENSE.txt for
152
189
  further details.
153
190
 
191
+ NinjaScript is copyright (c) 2011 Judson Lester and Logical Reality Design.
192
+
154
193
  Web Development by Logical Reality Design: http://LRDesign.com
155
194
 
data/Rakefile CHANGED
@@ -17,9 +17,18 @@ namespace :update do
17
17
 
18
18
  desc "get the most up-to-date version of NinjaScript"
19
19
  task :ninja_script do
20
- sh 'cd ../NinjaScript; git checkout master; git pull'
21
- cp File.join(File.dirname(__FILE__), '..', 'NinjaScript', 'javascript', 'jquery.ninja_script.js'),
22
- File.join(File.dirname(__FILE__), 'lib', 'generators', 'mizugumo', 'install', 'templates', 'javascripts')
20
+ #sh 'cd ../NinjaScript; git checkout master; git pull'
21
+ #cp File.join(File.dirname(__FILE__), '..', 'NinjaScript', 'javascript', 'jquery.ninja_script.js'),
22
+ #File.join(File.dirname(__FILE__), 'lib', 'generators', 'mizugumo', 'install', 'templates', 'javascripts')
23
+ mkdir_p 'temp'
24
+ sh 'rm -f temp/ninjascript.zip'
25
+ sh 'cd temp; wget --no-check-certificate https://github.com/downloads/LRDesign/NinjaScript/ninjascript.zip'
26
+ sh 'cd temp; unzip ninjascript.zip'
27
+ cwd = File.dirname(__FILE__)
28
+ cp File.join(cwd, 'temp', 'generated', 'javascript', 'ninjascript.js'),
29
+ File.join(cwd, 'lib', 'generators', 'mizugumo', 'install', 'templates', 'javascripts')
30
+ cp File.join(cwd, 'temp', 'generated', 'javascript', 'ns.min.js'),
31
+ File.join(cwd, 'lib', 'generators', 'mizugumo', 'install', 'templates', 'javascripts')
23
32
  end
24
33
 
25
34
  task :ns => :ninja_script
@@ -12,39 +12,75 @@ DESC
12
12
  end
13
13
 
14
14
  def copy_files
15
- directory 'images', 'public/images'
16
- directory 'javascripts', 'public/javascripts'
17
- directory 'stylesheets', 'public/stylesheets'
15
+ if Mizugumo::RAILS_31
16
+ directory 'images', 'public/images'
17
+ copy_file 'javascripts/ninjascript.js', 'app/assets/javascripts/ninjascript.js'
18
+ copy_file 'javascripts/mizugumo.js', 'app/assets/javascripts/mizugumo.js'
19
+ copy_file 'javascripts/ninja_go.js', 'app/assets/javascripts/ninja_go.js'
20
+ directory 'stylesheets', 'app/assets/stylesheets'
21
+ @manifest = 'app/assets/javascripts/application.js'
22
+ insert_into_file(@manifest, :after => '//= require jquery_ujs') do
23
+ "\n//= require ninjascript" +
24
+ "\n//= require mizugumo"
25
+ end
26
+ append_to_file(@manifest){ '//= require ninja_go' }
27
+ else
28
+ directory 'images', 'public/images'
29
+ copy_file 'javascripts/jquery-1.6.4.min.js', 'public/javascripts/jquery-1.6.4.min.js'
30
+ copy_file 'javascripts/ninjascript.js', 'public/javascripts/ninjascript.js'
31
+ directory 'stylesheets', 'public/stylesheets'
32
+ end
18
33
  end
19
34
 
20
- def add_javascript
35
+ def add_javascript_rails_3_0
36
+ return if Mizugumo::RAILS_31
37
+
21
38
  file = File.join("public", "javascripts", "application.js")
39
+
40
+ mg_file = File.open(File.join(InstallGenerator.source_root, "javascripts", "mizugumo.js"))
22
41
  append_to_file(file) do
23
- <<ADDITIONAL_JS
24
-
25
- // Generated by mizugumo install script
26
- Ninja.behavior({
27
- // This line enables the NH behavior of graceful degradation of method links
28
- // to forms and back again
29
- '.mizugumo_graceful_form': Ninja.becomesLink
30
- })
31
- ADDITIONAL_JS
42
+ mg_file.read
32
43
  end
44
+ mg_file.close
45
+ insert_into_file(file, :after => '});') do
46
+ "\n Ninja.go(); // This must be the last line of your NinjaScript definitions!"
47
+ end
33
48
  end
34
49
 
35
50
  def reminder
36
- say (<<NOTICE
51
+ if Mizugumo::RAILS_31
52
+ say (<<NOTICE )
53
+
54
+ Mizugumo is installed!
55
+
56
+ Javascript files have been added to your app/assets/javascripts directory. You may need to check them for compatibility with your
57
+ other JS files.
58
+
59
+ A few default style rules have been added as well as app/assets/stylesheets/mizugumo.sass.
60
+
61
+ If you want to use the Mizugumo AJAX scaffold generators, add this to your application.rb:
62
+
63
+ config.generators do |g|
64
+ g.scaffold_controller 'mizugumo:scaffold_controller'
65
+ g.template_engine 'mizugumo:erb'
66
+ # g.template_engine 'mizugumo:haml' # If you prefer Haml over ERB
67
+ g.assets 'mizugumo:js_assets'
68
+ end
69
+
70
+ NOTICE
71
+ else
72
+ say (<<NOTICE
37
73
 
38
74
  Mizugumo is installed!
39
- Remember to remove the default JS and link to the jQuery/NinjaScript script and CSS files by adding these to your application layout:
75
+ Remember to remove the default JS and link to the jQuery/NinjaScript script and CSS files by adding these to your application layout. Note: it is important that ninjascript load after jquery, but before your application.js or any mizugumo-related code you write!
40
76
 
41
77
  <%= stylesheet_link_tag 'mizugumo.css' %>
42
- <%= javascript_include_tag 'jquery-1.4.2.js' %>
43
- <%= javascript_include_tag 'jquery.ninja_script.js' %>
78
+ <%= javascript_include_tag 'jquery-1.6.4.min.js' %>
79
+ <%= javascript_include_tag 'ninjascript.js' %>
44
80
  <%= javascript_include_tag 'rails.js' %>
45
81
  <%= javascript_include_tag 'application.js' %>
46
82
 
47
- The included rails.js is a jQuery-1.4.2 compatible implementation of rails.js, and should replace the default rails.js.
83
+ The included rails.js is a jQuery compatible implementation of rails.js, and should replace the default rails.js.
48
84
  If you want to use the Mizugumo AJAX scaffold generators, add this to your application.rb:
49
85
 
50
86
  config.generators do |g|
@@ -55,6 +91,7 @@ If you want to use the Mizugumo AJAX scaffold generators, add this to your appli
55
91
 
56
92
  NOTICE
57
93
  )
94
+ end
58
95
  end
59
96
  end
60
97
  end
@@ -0,0 +1,109 @@
1
+ /*
2
+ * NinjaScript - 0.9
3
+ * written by and copyright 2010-2011 Judson Lester and Logical Reality Design
4
+ * Licensed under the MIT license
5
+ *
6
+ * 06-29-2011
7
+ */
8
+ /*
9
+ RequireJS 0.24.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
10
+ Available via the MIT or new BSD license.
11
+ see: http://github.com/jrburke/requirejs for details
12
+ */
13
+ var require,define;
14
+ (function(){function i(b){return s.call(b)==="[object Function]"}function l(b){return s.call(b)==="[object Array]"}function c(b,a,k){for(var h in a)if(!(h in d)&&(!(h in b)||k))b[h]=a[h];return j}function e(b,d,a){var h,k,c;for(h=0;c=d[h];h++){c=typeof c==="string"?{name:c}:c;k=c.location;if(a&&(!k||k.indexOf("/")!==0&&k.indexOf(":")===-1))k=a+"/"+(k||c.name);b[c.name]={name:c.name,location:k||c.name,lib:c.lib||"lib",main:(c.main||"lib/main").replace(q,"").replace(m,"")}}}function a(a){function k(b){var d,a;
15
+ for(d=0;a=b[d];d++)if(a===".")b.splice(d,1),d-=1;else if(a==="..")if(d===1&&(b[2]===".."||b[0]===".."))break;else d>0&&(b.splice(d-1,2),d-=2)}function g(b,d){var a,h;b.charAt(0)==="."&&d&&(w.pkgs[d]?d=[d]:(d=d.split("/"),d=d.slice(0,d.length-1)),b=d.concat(b.split("/")),k(b),h=w.pkgs[a=b[0]],b=b.join("/"),h&&b===a+"/"+h.main&&(b=a));return b}function y(b,d){var a=b?b.indexOf("!"):-1,k=null,h=d?d.name:null,c=b,o,f;a!==-1&&(k=b.substring(0,a),b=b.substring(a+1,b.length));k&&(k=g(k,h));b&&(o=k?(a=u[k])?
16
+ a.normalize?a.normalize(b,function(b){return g(b,h)}):g(b,h):"__$p"+h+"@"+b:g(b,h),f=N[o],f||(f=j.toModuleUrl?j.toModuleUrl(n,b,d):n.nameToUrl(b,null,d),N[o]=f));return{prefix:k,name:o,parentMap:d,url:f,originalName:c,fullName:k?k+"!"+o:o}}function f(){var b=!0,d=w.priorityWait,a,k;if(d){for(k=0;a=d[k];k++)if(!B[a]){b=!1;break}b&&delete w.priorityWait}return b}function m(b){return function(d){b.exports=d}}function s(b,d,a){return function(){var k=[].concat(x.call(arguments,0)),h;if(a&&i(h=k[k.length-
17
+ 1]))h.__requireJsBuild=!0;k.push(d);return b.apply(null,k)}}function p(b,d){var a=s(n.require,b,d);c(a,{nameToUrl:s(n.nameToUrl,b),toUrl:s(n.toUrl,b),isDefined:s(n.isDefined,b),ready:j.ready,isBrowser:j.isBrowser});if(j.paths)a.paths=j.paths;return a}function q(b){var d=b.prefix,a=b.fullName;H[a]||a in u||(d&&!O[d]&&(O[d]=void 0,(S[d]||(S[d]=[])).push(b),(C[d]||(C[d]=[])).push({onDep:function(b){if(b===d){var a,k,h,K,c,o,g=S[d];if(g)for(h=0;a=g[h];h++)if(b=a.fullName,a=y(a.originalName,a.parentMap),
18
+ a=a.fullName,k=C[b]||[],K=C[a],a!==b){b in H&&(delete H[b],H[a]=!0);C[a]=K?K.concat(k):k;delete C[b];for(K=0;K<k.length;K++){o=k[K].depArray;for(c=0;c<o.length;c++)o[c]===b&&(o[c]=a)}}delete S[d]}}}),q(y(d))),n.paused.push(b))}function r(b){var d,a,k;d=b.callback;var h=b.fullName;k=[];var c=b.depArray;if(d&&i(d)){if(c)for(d=0;d<c.length;d++)k.push(b.deps[c[d]]);a=j.execCb(h,b.callback,k);if(h)if(b.usingExports&&a===void 0&&(!b.cjsModule||!("exports"in b.cjsModule)))a=u[h];else if(b.cjsModule&&"exports"in
19
+ b.cjsModule)a=u[h]=b.cjsModule.exports;else{if(h in u&&!b.usingExports)return j.onError(Error(h+" has already been defined"));u[h]=a}}else h&&(a=u[h]=d);if(h&&(k=C[h])){for(d=0;d<k.length;d++)k[d].onDep(h,a);delete C[h]}if(L[b.waitId])delete L[b.waitId],b.isDone=!0,n.waitCount-=1,n.waitCount===0&&(G=[])}function P(d,a,k,h){var d=y(d,h),c=d.name,o=d.fullName,g={},j={waitId:c||b+U++,depCount:0,depMax:0,prefix:d.prefix,name:c,fullName:o,deps:{},depArray:a,callback:k,onDep:function(b,d){b in j.deps||
20
+ (j.deps[b]=d,j.depCount+=1,j.depCount===j.depMax&&r(j))}},f,e;if(o){if(o in u||B[o]===!0)return;H[o]=!0;B[o]=!0;n.jQueryDef=o==="jquery"}for(k=0;k<a.length;k++)if(f=a[k])f=y(f,c?d:h),e=f.fullName,a[k]=e,e==="require"?j.deps[e]=p(d):e==="exports"?(j.deps[e]=u[o]={},j.usingExports=!0):e==="module"?(j.cjsModule=f=j.deps[e]={id:c,uri:c?n.nameToUrl(c,null,h):void 0},f.setExports=m(f)):e in u&&!(e in L)?j.deps[e]=u[e]:g[e]||(j.depMax+=1,q(f),(C[e]||(C[e]=[])).push(j),g[e]=!0);j.depCount===j.depMax?r(j):
21
+ (L[j.waitId]=j,G.push(j),n.waitCount+=1)}function l(b){P.apply(null,b);B[b[0]]=!0}function A(b){if(!n.jQuery&&(b=b||(typeof jQuery!=="undefined"?jQuery:null))&&"readyWait"in b)if(n.jQuery=b,l(["jquery",[],function(){return jQuery}]),n.scriptCount)b.readyWait+=1,n.jQueryIncremented=!0}function E(b,d){if(!b.isDone){var a=b.fullName,k=b.depArray,h,c;if(a){if(d[a])return u[a];d[a]=!0}for(c=0;c<k.length;c++)if((h=k[c])&&!b.deps[h]&&L[h])b.onDep(h,E(L[h],d));return a?u[a]:void 0}}function F(){var b=w.waitSeconds*
22
+ 1E3,a=b&&n.startTime+b<(new Date).getTime(),b="",k=!1,h=!1,c;if(!(n.pausedCount>0)){if(w.priorityWait)if(f())z();else return;for(c in B)if(!(c in d)&&(k=!0,!B[c]))if(a)b+=c+" ";else{h=!0;break}if(k||n.waitCount){if(a&&b)return c=Error("require.js load timeout for modules: "+b),c.requireType="timeout",c.requireModules=b,j.onError(c);if(h||n.scriptCount)(t||T)&&setTimeout(F,50);else if(n.waitCount){for(M=0;b=G[M];M++)E(b,{});F()}else j.checkReadyState()}}}function J(b,d){var a=d.name,k=d.fullName,h;
23
+ if(!(k in u||k in B))O[b]||(O[b]=u[b]),B[k]||(B[k]=!1),h=function(h){if(require.onPluginLoad)require.onPluginLoad(n,b,a,h);r({prefix:d.prefix,name:d.name,fullName:d.fullName,callback:function(){return h}});B[k]=!0},h.fromText=function(b,d){var a=o;n.loaded[b]=!1;n.scriptCount+=1;a&&(o=!1);eval(d);a&&(o=!0);n.completeLoad(b)},O[b].load(a,p(d.parentMap,!0),h,w)}function Q(b){b.prefix&&b.name.indexOf("__$p")===0&&u[b.prefix]&&(b=y(b.originalName,b.parentMap));var d=b.prefix,a=b.fullName;!H[a]&&!B[a]&&
24
+ (H[a]=!0,d?u[d]?J(d,b):(R[d]||(R[d]=[],(C[d]||(C[d]=[])).push({onDep:function(b){if(b===d){for(var a,k=R[d],b=0;b<k.length;b++)a=k[b],J(d,y(a.originalName,a.parentMap));delete R[d]}}})),R[d].push(b)):j.load(n,a,b.url))}var n,z,w={waitSeconds:7,baseUrl:v.baseUrl||"./",paths:{},pkgs:{}},D=[],H={require:!0,exports:!0,module:!0},N={},u={},B={},L={},G=[],U=0,C={},O={},R={},V=0,S={};z=function(){var b,d,a;V+=1;if(n.scriptCount<=0)n.scriptCount=0;for(;D.length;)if(b=D.shift(),b[0]===null)return j.onError(Error("Mismatched anonymous require.def modules"));
25
+ else l(b);if(!w.priorityWait||f())for(;n.paused.length;){a=n.paused;n.pausedCount+=a.length;n.paused=[];for(d=0;b=a[d];d++)Q(b);n.startTime=(new Date).getTime();n.pausedCount-=a.length}V===1&&F();V-=1};n={contextName:a,config:w,defQueue:D,waiting:L,waitCount:0,specified:H,loaded:B,urlMap:N,scriptCount:0,urlFetched:{},defined:u,paused:[],pausedCount:0,plugins:O,managerCallbacks:C,makeModuleMap:y,normalize:g,configure:function(b){var a,k,h;b.baseUrl&&b.baseUrl.charAt(b.baseUrl.length-1)!=="/"&&(b.baseUrl+=
26
+ "/");a=w.paths;h=w.pkgs;c(w,b,!0);if(b.paths){for(k in b.paths)k in d||(a[k]=b.paths[k]);w.paths=a}if((a=b.packagePaths)||b.packages){if(a)for(k in a)k in d||e(h,a[k],k);b.packages&&e(h,b.packages);w.pkgs=h}if(b.priority)k=n.requireWait,n.requireWait=!1,n.takeGlobalQueue(),z(),n.require(b.priority),z(),n.requireWait=k,w.priorityWait=b.priority;if(b.deps||b.callback)n.require(b.deps||[],b.callback);b.ready&&j.ready(b.ready)},isDefined:function(b,d){return y(b,d).fullName in u},require:function(b,d,
27
+ k){if(typeof b==="string"){if(j.get)return j.get(n,b,d);d=y(b,d);b=u[d.fullName];return b===void 0?j.onError(Error("require: module name '"+d.fullName+"' has not been loaded yet for context: "+a)):b}P(null,b,d,k);if(!n.requireWait)for(;!n.scriptCount&&n.paused.length;)z()},takeGlobalQueue:function(){h.length&&(I.apply(n.defQueue,[n.defQueue.length-1,0].concat(h)),h=[])},completeLoad:function(b){var d;for(n.takeGlobalQueue();D.length;)if(d=D.shift(),d[0]===null){d[0]=b;break}else if(d[0]===b)break;
28
+ else l(d),d=null;d?l(d):l([b,[],b==="jquery"&&typeof jQuery!=="undefined"?function(){return jQuery}:null]);B[b]=!0;A();j.isAsync&&(n.scriptCount-=1);z();j.isAsync||(n.scriptCount-=1)},toUrl:function(b,d){var a=b.lastIndexOf("."),k=null;a!==-1&&(k=b.substring(a,b.length),b=b.substring(0,a));return n.nameToUrl(b,k,d)},nameToUrl:function(b,d,a){var h,c,o,f,e=n.config;if(b.indexOf("./")===0||b.indexOf("../")===0)a=a&&a.url?a.url.split("/"):[],a.length&&a.pop(),a=a.concat(b.split("/")),k(a),d=a.join("/")+
29
+ (d?d:j.jsExtRegExp.test(b)?"":".js");else if(b=g(b,a),j.jsExtRegExp.test(b))d=b+(d?d:"");else{h=e.paths;c=e.pkgs;a=b.split("/");for(f=a.length;f>0;f--)if(o=a.slice(0,f).join("/"),h[o]){a.splice(0,f,h[o]);break}else if(o=c[o]){b=b===o.name?o.location+"/"+o.main:o.location+"/"+o.lib;a.splice(0,f,b);break}d=a.join("/")+(d||".js");d=(d.charAt(0)==="/"||d.match(/^\w+:/)?"":e.baseUrl)+d}return e.urlArgs?d+((d.indexOf("?")===-1?"?":"&")+e.urlArgs):d}};n.jQueryCheck=A;n.resume=z;return n}function f(){var b,
30
+ d,a;if(y&&y.readyState==="interactive")return y;b=document.getElementsByTagName("script");for(d=b.length-1;d>-1&&(a=b[d]);d--)if(a.readyState==="interactive")return y=a;return null}var p=/(\/\*([\s\S]*?)\*\/|\/\/(.*)$)/mg,r=/require\(["']([^'"\s]+)["']\)/g,q=/^\.\//,m=/\.js$/,s=Object.prototype.toString,g=Array.prototype,x=g.slice,I=g.splice,t=!!(typeof window!=="undefined"&&navigator&&document),T=!t&&typeof importScripts!=="undefined",F=t&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,
31
+ G=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",b="_r@@",d={},k={},h=[],y=null,o=!1,j,g={},P,v,z,Q,E,J,A,M,N,U,D;if(typeof require!=="undefined")if(i(require))return;else g=require;j=require=function(b,d,h){var c="_",o;!l(b)&&typeof b!=="string"&&(o=b,l(d)?(b=d,d=h):b=[]);if(o&&o.context)c=o.context;h=k[c]||(k[c]=a(c));o&&h.configure(o);return h.require(b,d)};j.version="0.24.0";j.isArray=l;j.isFunction=i;j.mixin=c;j.jsExtRegExp=/^\/|:|\?|\.js$/;v=j.s={contexts:k,skipAsync:{},isPageLoaded:!t,
32
+ readyCalls:[]};if(j.isAsync=j.isBrowser=t)if(z=v.head=document.getElementsByTagName("head")[0],Q=document.getElementsByTagName("base")[0])z=v.head=Q.parentNode;j.onError=function(b){throw b;};j.load=function(b,d,a){var k=b.contextName,h=b.urlFetched,c=b.loaded;c[d]||(c[d]=!1);if(!h[a]&&(b.scriptCount+=1,j.attach(a,k,d),h[a]=!0,b.jQuery&&!b.jQueryIncremented))b.jQuery.readyWait+=1,b.jQueryIncremented=!0};define=j.def=function(b,d,a){var c;typeof b!=="string"&&(a=d,d=b,b=null);j.isArray(d)||(a=d,d=
33
+ []);!b&&!d.length&&j.isFunction(a)&&a.length&&(a.toString().replace(p,"").replace(r,function(b,a){d.push(a)}),d=["require","exports","module"].concat(d));if(o){c=P||f();if(!c)return j.onError(Error("ERROR: No matching script interactive for "+a));b||(b=c.getAttribute("data-requiremodule"));c=k[c.getAttribute("data-requirecontext")]}(c?c.defQueue:h).push([b,d,a])};define.amd={multiversion:!0,plugins:!0};j.execCb=function(b,d,a){return d.apply(null,a)};j.onScriptLoad=function(b){var d=b.currentTarget||
34
+ b.srcElement,a;if(b.type==="load"||F.test(d.readyState))y=null,b=d.getAttribute("data-requirecontext"),a=d.getAttribute("data-requiremodule"),k[b].completeLoad(a),d.detachEvent&&!G?d.detachEvent("onreadystatechange",j.onScriptLoad):d.removeEventListener("load",j.onScriptLoad,!1)};j.attach=function(b,d,a,h,c){var f;if(t)return h=h||j.onScriptLoad,f=document.createElement("script"),f.type=c||"text/javascript",f.charset="utf-8",f.async=!v.skipAsync[b],f.setAttribute("data-requirecontext",d),f.setAttribute("data-requiremodule",
35
+ a),f.attachEvent&&!G?(o=!0,f.attachEvent("onreadystatechange",h)):f.addEventListener("load",h,!1),f.src=b,P=f,Q?z.insertBefore(f,Q):z.appendChild(f),P=null,f;else if(T)h=k[d],d=h.loaded,d[a]=!1,importScripts(b),h.completeLoad(a);return null};if(t){E=document.getElementsByTagName("script");for(M=E.length-1;M>-1&&(J=E[M]);M--){if(!z)z=J.parentNode;if(A=J.getAttribute("data-main")){if(!g.baseUrl)E=A.split("/"),J=E.pop(),E=E.length?E.join("/")+"/":"./",g.baseUrl=E,A=J.replace(m,"");g.deps=g.deps?g.deps.concat(A):
36
+ [A];break}}}v.baseUrl=g.baseUrl;j.pageLoaded=function(){if(!v.isPageLoaded){v.isPageLoaded=!0;N&&clearInterval(N);if(U)document.readyState="complete";j.callReady()}};j.checkReadyState=function(){var b=v.contexts,a;for(a in b)if(!(a in d)&&b[a].waitCount)return;v.isDone=!0;j.callReady()};j.callReady=function(){var b=v.readyCalls,a,k,h;if(v.isPageLoaded&&v.isDone){if(b.length){v.readyCalls=[];for(a=0;k=b[a];a++)k()}b=v.contexts;for(h in b)if(!(h in d)&&(a=b[h],a.jQueryIncremented))a.jQuery.ready(!0),
37
+ a.jQueryIncremented=!1}};j.ready=function(b){v.isPageLoaded&&v.isDone?b():v.readyCalls.push(b);return j};if(t){if(document.addEventListener){if(document.addEventListener("DOMContentLoaded",j.pageLoaded,!1),window.addEventListener("load",j.pageLoaded,!1),!document.readyState)U=!0,document.readyState="loading"}else window.attachEvent&&(window.attachEvent("onload",j.pageLoaded),self===self.top&&(N=setInterval(function(){try{document.body&&(document.documentElement.doScroll("left"),j.pageLoaded())}catch(b){}},
38
+ 30)));document.readyState==="complete"&&j.pageLoaded()}j(g);if(j.isAsync&&typeof setTimeout!=="undefined")D=v.contexts[g.context||"_"],D.requireWait=!0,setTimeout(function(){D.requireWait=!1;D.takeGlobalQueue();D.jQueryCheck();D.scriptCount||D.resume();j.checkReadyState()},0)})();
39
+ define("utils",["require","exports","module"],function(){return{log:function(){},isArray:function(i){return i.constructor==Array},forEach:function(i,l,c){if(typeof i.forEach=="function")return i.forEach(l,c);else if(typeof Array.prototype.forEach=="function")return Array.prototype.forEach.call(i,l,c);else for(var e=Number(i.length),a=0;a<e;a+=1)typeof i[a]!="undefined"&&l.call(c,i[a],a,i)}}});define("ninja/exceptions",["require","exports","module"],function(){return{CouldntChoose:function(){},TransformFailed:function(){}}});
40
+ define("ninja/behaviors",["ninja/exceptions"],function(i){var l=i.CouldntChoose,i={meta:function(c,e){c(this);this.chooser=e}};i.meta.prototype={choose:function(c){var e=this.chooser(c);if(e!==void 0)return e.choose(c);else throw new l;}};i.select=function(c){this.menu=c};i.select.prototype={choose:function(c){for(var e in this.menu)if(jQuery(c).is(e))return this.menu[e].choose(c);return null}};i.base=function(c){this.helpers={};this.eventHandlers=[];this.priority=this.lexicalOrder=0;if(typeof c.transform==
41
+ "function")this.transform=c.transform,delete c.transform;if(typeof c.helpers!="undefined")this.helpers=c.helpers,delete c.helpers;if(typeof c.priority!="undefined")this.priority=c.priority;delete c.priority;this.eventHandlers=typeof c.events!="undefined"?c.events:c;return this};i.base.prototype={apply:function(c){var e=this.inContext({}),c=this.applyTransform(e,c);jQuery(c).data("ninja-visited",e);this.applyEventHandlers(e,c);return c},priority:function(c){this.priority=c;return this},choose:function(){return this},
42
+ inContext:function(c){function e(){}e.prototype=c;return Ninja.tools.enrich(new e,this.helpers)},applyTransform:function(c,e){var a=this.transform.call(c,e);return a===void 0?e:a},applyEventHandlers:function(c,e){for(var a in this.eventHandlers){var f=this.eventHandlers[a];jQuery(e).bind(a,this.makeHandler.call(c,f))}return e},recordEventHandlers:function(c,e){for(var a in this.eventHandlers)c.recordHandler(this,a,function(c){return this.makeHandler.call(e,this.eventHandlers[a],c)})},buildHandler:function(c,
43
+ e,a){var f,p=!0,r=!0,q=!1,m=!1,e=this.eventHandlers[e];if(typeof e=="function")f=e;else{f=e[0];for(var e=e.slice(1,e.length),s=e.length,g=0;g<s;g++){if(e[g]=="andDoDefault"||e[g]=="allowDefault")p=!1;if(e[g]=="allowPropagate"||e[g]=="dontStopPropagation")r=!1;e[g]=="andDoOthers"&&(q=!1);e[g]=="changesDOM"&&(m=!0)}}e=function(g){f.call(c,g,this,a);return!p};p&&(e=this.prependAction(e,function(a){a.preventDefault()}));r&&(e=this.prependAction(e,function(a){a.stopPropagation()}));q&&(e=this.prependAction(e,
44
+ function(a){a.stopImmediatePropagation()}));m&&(e=this.appendAction(e,function(){Ninja.tools.fireMutationEvent()}));return e},prependAction:function(c,e){return function(a){e.call(this,a);return c.call(this,a)}},appendAction:function(c,e){return function(a){var f=c.call(this,a);e.call(this,a);return f}},transform:function(c){return c}};return i});
45
+ define("sizzle-1.0",["require","exports","module"],function(){function i(b){for(var d="",a,h=0;b[h];h++)a=b[h],a.nodeType===3||a.nodeType===4?d+=a.nodeValue:a.nodeType!==8&&(d+=i(a.childNodes));return d}function l(b,d,a,h,c,o){for(var c=0,f=h.length;c<f;c++){var g=h[c];if(g){for(var g=g[b],e=!1;g;){if(g.sizcache===a){e=h[g.sizset];break}if(g.nodeType===1&&!o)g.sizcache=a,g.sizset=c;if(g.nodeName.toLowerCase()===d){e=g;break}g=g[b]}h[c]=e}}}function c(b,d,a,h,c,o){for(var c=0,f=h.length;c<f;c++){var g=
46
+ h[c];if(g){for(var g=g[b],e=!1;g;){if(g.sizcache===a){e=h[g.sizset];break}if(g.nodeType===1){if(!o)g.sizcache=a,g.sizset=c;if(typeof d!=="string"){if(g===d){e=!0;break}}else if(q.filter(d,[g]).length>0){e=g;break}}g=g[b]}h[c]=e}}}var e=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,a=0,f=Object.prototype.toString,p=!1,r=!0;[0,0].sort(function(){r=!1;return 0});var q=function(b,d,a,h){var a=a||[],c=d=d||document;if(d.nodeType!==
47
+ 1&&d.nodeType!==9)return[];if(!b||typeof b!=="string")return a;for(var g=[],j,p,r,i,l=!0,t=F(d),I=b;(e.exec(""),j=e.exec(I))!==null;)if(I=j[3],g.push(j[1]),j[2]){i=j[3];break}if(g.length>1&&s.exec(b))if(g.length===2&&m.relative[g[0]])p=G(g[0]+g[1],d);else for(p=m.relative[g[0]]?[d]:q(g.shift(),d);g.length;)b=g.shift(),m.relative[b]&&(b+=g.shift()),p=G(b,p);else if(!h&&g.length>1&&d.nodeType===9&&!t&&m.match.ID.test(g[0])&&!m.match.ID.test(g[g.length-1])&&(j=q.find(g.shift(),d,t),d=j.expr?q.filter(j.expr,
48
+ j.set)[0]:j.set[0]),d){j=h?{expr:g.pop(),set:x(h)}:q.find(g.pop(),g.length===1&&(g[0]==="~"||g[0]==="+")&&d.parentNode?d.parentNode:d,t);p=j.expr?q.filter(j.expr,j.set):j.set;for(g.length>0?r=x(p):l=!1;g.length;){var A=g.pop();j=A;m.relative[A]?j=g.pop():A="";j==null&&(j=d);m.relative[A](r,j,t)}}else r=[];r||(r=p);r||q.error(A||b);if(f.call(r)==="[object Array]")if(l)if(d&&d.nodeType===1)for(b=0;r[b]!=null;b++)r[b]&&(r[b]===!0||r[b].nodeType===1&&T(d,r[b]))&&a.push(p[b]);else for(b=0;r[b]!=null;b++)r[b]&&
49
+ r[b].nodeType===1&&a.push(p[b]);else a.push.apply(a,r);else x(r,a);i&&(q(i,c,a,h),q.uniqueSort(a));return a};q.uniqueSort=function(b){if(t&&(p=r,b.sort(t),p))for(var d=1;d<b.length;d++)b[d]===b[d-1]&&b.splice(d--,1);return b};q.matches=function(b,d){return q(b,null,null,d)};q.find=function(b,d,a){var h,c;if(!b)return[];for(var g=0,f=m.order.length;g<f;g++){var e=m.order[g];if(c=m.leftMatch[e].exec(b)){var s=c[1];c.splice(1,1);if(s.substr(s.length-1)!=="\\"&&(c[1]=(c[1]||"").replace(/\\/g,""),h=m.find[e](c,
50
+ d,a),h!=null)){b=b.replace(m.match[e],"");break}}}h||(h=d.getElementsByTagName("*"));return{set:h,expr:b}};q.filter=function(b,d,a,h){for(var c=b,g=[],f=d,e,s,r=d&&d[0]&&F(d[0]);b&&d.length;){for(var p in m.filter)if((e=m.leftMatch[p].exec(b))!=null&&e[2]){var i=m.filter[p],l,x;x=e[1];s=!1;e.splice(1,1);if(x.substr(x.length-1)!=="\\"){f===g&&(g=[]);if(m.preFilter[p])if(e=m.preFilter[p](e,f,a,g,h,r)){if(e===!0)continue}else s=l=!0;if(e)for(var t=0;(x=f[t])!=null;t++)if(x){l=i(x,e,t,f);var I=h^!!l;
51
+ a&&l!=null?I?s=!0:f[t]=!1:I&&(g.push(x),s=!0)}if(l!==void 0){a||(f=g);b=b.replace(m.match[p],"");if(!s)return[];break}}}if(b===c)if(s==null)q.error(b);else break;c=b}return f};q.error=function(b){throw"Syntax error, unrecognized expression: "+b;};var m=q.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
52
+ TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(b){return b.getAttribute("href")}},relative:{"+":function(b,d){var a=typeof d==="string",h=a&&!/\W/.test(d),a=a&&!h;h&&(d=d.toLowerCase());for(var h=0,c=b.length,
53
+ g;h<c;h++)if(g=b[h]){for(;(g=g.previousSibling)&&g.nodeType!==1;);b[h]=a||g&&g.nodeName.toLowerCase()===d?g||!1:g===d}a&&q.filter(d,b,!0)},">":function(b,d){var a=typeof d==="string";if(a&&!/\W/.test(d))for(var d=d.toLowerCase(),h=0,c=b.length;h<c;h++){var g=b[h];if(g)a=g.parentNode,b[h]=a.nodeName.toLowerCase()===d?a:!1}else{h=0;for(c=b.length;h<c;h++)(g=b[h])&&(b[h]=a?g.parentNode:g.parentNode===d);a&&q.filter(d,b,!0)}},"":function(b,d,g){var h=a++,f=c;if(typeof d==="string"&&!/\W/.test(d))var e=
54
+ d=d.toLowerCase(),f=l;f("parentNode",d,h,b,e,g)},"~":function(b,d,g){var h=a++,f=c;if(typeof d==="string"&&!/\W/.test(d))var e=d=d.toLowerCase(),f=l;f("previousSibling",d,h,b,e,g)}},find:{ID:function(b,d,a){if(typeof d.getElementById!=="undefined"&&!a)return(b=d.getElementById(b[1]))?[b]:[]},NAME:function(b,d){if(typeof d.getElementsByName!=="undefined"){for(var a=[],h=d.getElementsByName(b[1]),c=0,g=h.length;c<g;c++)h[c].getAttribute("name")===b[1]&&a.push(h[c]);return a.length===0?null:a}},TAG:function(b,
55
+ d){return d.getElementsByTagName(b[1])}},preFilter:{CLASS:function(b,d,a,h,c,g){b=" "+b[1].replace(/\\/g,"")+" ";if(g)return b;for(var g=0,f;(f=d[g])!=null;g++)f&&(c^(f.className&&(" "+f.className+" ").replace(/[\t\n]/g," ").indexOf(b)>=0)?a||h.push(f):a&&(d[g]=!1));return!1},ID:function(b){return b[1].replace(/\\/g,"")},TAG:function(b){return b[1].toLowerCase()},CHILD:function(b){if(b[1]==="nth"){var d=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(b[2]==="even"&&"2n"||b[2]==="odd"&&"2n+1"||!/\D/.test(b[2])&&"0n+"+
56
+ b[2]||b[2]);b[2]=d[1]+(d[2]||1)-0;b[3]=d[3]-0}b[0]=a++;return b},ATTR:function(b,d,a,h,c,g){d=b[1].replace(/\\/g,"");!g&&m.attrMap[d]&&(b[1]=m.attrMap[d]);b[2]==="~="&&(b[4]=" "+b[4]+" ");return b},PSEUDO:function(b,d,a,h,c){if(b[1]==="not")if((e.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=q(b[3],null,null,d);else return b=q.filter(b[3],d,a,1^c),a||h.push.apply(h,b),!1;else if(m.match.POS.test(b[0])||m.match.CHILD.test(b[0]))return!0;return b},POS:function(b){b.unshift(!0);return b}},filters:{enabled:function(b){return b.disabled===
57
+ !1&&b.type!=="hidden"},disabled:function(b){return b.disabled===!0},checked:function(b){return b.checked===!0},selected:function(b){return b.selected===!0},parent:function(b){return!!b.firstChild},empty:function(b){return!b.firstChild},has:function(b,d,a){return!!q(a[3],b).length},header:function(b){return/h\d/i.test(b.nodeName)},text:function(b){return"text"===b.type},radio:function(b){return"radio"===b.type},checkbox:function(b){return"checkbox"===b.type},file:function(b){return"file"===b.type},
58
+ password:function(b){return"password"===b.type},submit:function(b){return"submit"===b.type},image:function(b){return"image"===b.type},reset:function(b){return"reset"===b.type},button:function(b){return"button"===b.type||b.nodeName.toLowerCase()==="button"},input:function(b){return/input|select|textarea|button/i.test(b.nodeName)}},setFilters:{first:function(b,d){return d===0},last:function(b,d,a,h){return d===h.length-1},even:function(b,d){return d%2===0},odd:function(b,d){return d%2===1},lt:function(b,
59
+ d,a){return d<a[3]-0},gt:function(b,a,c){return a>c[3]-0},nth:function(b,a,c){return c[3]-0===a},eq:function(b,a,c){return c[3]-0===a}},filter:{PSEUDO:function(b,a,c,h){var g=a[1],f=m.filters[g];if(f)return f(b,c,a,h);else if(g==="contains")return(b.textContent||b.innerText||i([b])||"").indexOf(a[3])>=0;else if(g==="not"){a=a[3];c=0;for(h=a.length;c<h;c++)if(a[c]===b)return!1;return!0}else q.error("Syntax error, unrecognized expression: "+g)},CHILD:function(b,a){var c=a[1],h=b;switch(c){case "only":case "first":for(;h=
60
+ h.previousSibling;)if(h.nodeType===1)return!1;if(c==="first")return!0;h=b;case "last":for(;h=h.nextSibling;)if(h.nodeType===1)return!1;return!0;case "nth":var c=a[2],g=a[3];if(c===1&&g===0)return!0;var f=a[0],e=b.parentNode;if(e&&(e.sizcache!==f||!b.nodeIndex)){for(var s=0,h=e.firstChild;h;h=h.nextSibling)if(h.nodeType===1)h.nodeIndex=++s;e.sizcache=f}h=b.nodeIndex-g;return c===0?h===0:h%c===0&&h/c>=0}},ID:function(b,a){return b.nodeType===1&&b.getAttribute("id")===a},TAG:function(b,a){return a===
61
+ "*"&&b.nodeType===1||b.nodeName.toLowerCase()===a},CLASS:function(b,a){return(" "+(b.className||b.getAttribute("class"))+" ").indexOf(a)>-1},ATTR:function(b,a){var c=a[1],c=m.attrHandle[c]?m.attrHandle[c](b):b[c]!=null?b[c]:b.getAttribute(c),g=c+"",f=a[2],e=a[4];return c==null?f==="!=":f==="="?g===e:f==="*="?g.indexOf(e)>=0:f==="~="?(" "+g+" ").indexOf(e)>=0:!e?g&&c!==!1:f==="!="?g!==e:f==="^="?g.indexOf(e)===0:f==="$="?g.substr(g.length-e.length)===e:f==="|="?g===e||g.substr(0,e.length+1)===e+"-":
62
+ !1},POS:function(b,a,c,g){var f=m.setFilters[a[2]];if(f)return f(b,c,a,g)}}},s=m.match.POS,g;for(g in m.match)m.match[g]=RegExp(m.match[g].source+/(?![^\[]*\])(?![^\(]*\))/.source),m.leftMatch[g]=RegExp(/(^(?:.|\r|\n)*?)/.source+m.match[g].source.replace(/\\(\d+)/g,function(b,a){return"\\"+(a-0+1)}));var x=function(b,a){b=Array.prototype.slice.call(b,0);return a?(a.push.apply(a,b),a):b};try{Array.prototype.slice.call(document.documentElement.childNodes,0)}catch(I){x=function(b,a){var c=a||[];if(f.call(b)===
63
+ "[object Array]")Array.prototype.push.apply(c,b);else if(typeof b.length==="number")for(var g=0,e=b.length;g<e;g++)c.push(b[g]);else for(g=0;b[g];g++)c.push(b[g]);return c}}var t;document.documentElement.compareDocumentPosition?t=function(b,a){if(!b.compareDocumentPosition||!a.compareDocumentPosition)return b==a&&(p=!0),b.compareDocumentPosition?-1:1;var c=b.compareDocumentPosition(a)&4?-1:b===a?0:1;c===0&&(p=!0);return c}:"sourceIndex"in document.documentElement?t=function(b,a){if(!b.sourceIndex||
64
+ !a.sourceIndex)return b==a&&(p=!0),b.sourceIndex?-1:1;var c=b.sourceIndex-a.sourceIndex;c===0&&(p=!0);return c}:document.createRange&&(t=function(b,a){if(!b.ownerDocument||!a.ownerDocument)return b==a&&(p=!0),b.ownerDocument?-1:1;var c=b.ownerDocument.createRange(),g=a.ownerDocument.createRange();c.setStart(b,0);c.setEnd(b,0);g.setStart(a,0);g.setEnd(a,0);c=c.compareBoundaryPoints(Range.START_TO_END,g);c===0&&(p=!0);return c});(function(){var b=document.createElement("div"),a="script"+(new Date).getTime();
65
+ b.innerHTML="<a name='"+a+"'/>";var c=document.documentElement;c.insertBefore(b,c.firstChild);if(document.getElementById(a))m.find.ID=function(b,a,d){if(typeof a.getElementById!=="undefined"&&!d)return(a=a.getElementById(b[1]))?a.id===b[1]||typeof a.getAttributeNode!=="undefined"&&a.getAttributeNode("id").nodeValue===b[1]?[a]:void 0:[]},m.filter.ID=function(b,a){var d=typeof b.getAttributeNode!=="undefined"&&b.getAttributeNode("id");return b.nodeType===1&&d&&d.nodeValue===a};c.removeChild(b);c=b=
66
+ null})();(function(){var b=document.createElement("div");b.appendChild(document.createComment(""));if(b.getElementsByTagName("*").length>0)m.find.TAG=function(b,a){var c=a.getElementsByTagName(b[1]);if(b[1]==="*"){for(var g=[],f=0;c[f];f++)c[f].nodeType===1&&g.push(c[f]);c=g}return c};b.innerHTML="<a href='#'></a>";if(b.firstChild&&typeof b.firstChild.getAttribute!=="undefined"&&b.firstChild.getAttribute("href")!=="#")m.attrHandle.href=function(b){return b.getAttribute("href",2)};b=null})();document.querySelectorAll&&
67
+ function(){var b=q,a=document.createElement("div");a.innerHTML="<p class='TEST'></p>";if(!(a.querySelectorAll&&a.querySelectorAll(".TEST").length===0)){q=function(a,d,c,g){d=d||document;if(!g&&d.nodeType===9&&!F(d))try{return x(d.querySelectorAll(a),c)}catch(f){}return b(a,d,c,g)};for(var c in b)q[c]=b[c];a=null}}();(function(){var b=document.createElement("div");b.innerHTML="<div class='test e'></div><div class='test'></div>";if(b.getElementsByClassName&&b.getElementsByClassName("e").length!==0&&
68
+ (b.lastChild.className="e",b.getElementsByClassName("e").length!==1))m.order.splice(1,0,"CLASS"),m.find.CLASS=function(b,a,c){if(typeof a.getElementsByClassName!=="undefined"&&!c)return a.getElementsByClassName(b[1])},b=null})();var T=document.compareDocumentPosition?function(b,a){return!!(b.compareDocumentPosition(a)&16)}:function(b,a){return b!==a&&(b.contains?b.contains(a):!0)},F=function(b){return(b=(b?b.ownerDocument||b:0).documentElement)?b.nodeName!=="HTML":!1},G=function(b,a){for(var c=[],
69
+ g="",f,e=a.nodeType?[a]:a;f=m.match.PSEUDO.exec(b);)g+=f[0],b=b.replace(m.match.PSEUDO,"");b=m.relative[b]?b+"*":b;f=0;for(var s=e.length;f<s;f++)q(b,e[f],c);return q.filter(g,c)};return q});
70
+ define("ninja/event-scribe",["require","exports","module"],function(){function i(){this.handlers={};this.currentElement=null}i.prototype={makeHandlersRemove:function(i){for(var c in this.handlers){var e=this.handlers[c];this.handlers[c]=function(a){e.call(this,a);jQuery(i).remove()}}},recordEventHandlers:function(i,c){if(this.currentElement!==i.element){if(this.currentElement!==null)this.makeHandlersRemove(this.currentElement),this.applyEventHandlers(this.currentElement),this.handlers={};this.currentElement=
71
+ i.element}for(var e in c.eventHandlers){var a=this.handlers[e];typeof a=="undefined"&&(a=function(){return!0});this.handlers[e]=c.buildHandler(i,e,a)}},applyEventHandlers:function(i){for(var c in this.handlers)jQuery(i).bind(c,this.handlers[c])}};return i});
72
+ define("ninja/behavior-collection",["sizzle-1.0","ninja/behaviors","utils","ninja/event-scribe","ninja/exceptions"],function(i,l,c,e,a){function f(a){this.lexicalCount=0;this.eventQueue=[];this.behaviors={};this.selectors=[];this.mutationTargets=[];this.tools=a;return this}var p=c.forEach,r=c.log,q=a.TransformFailed,m=a.CouldntChoose;f.prototype={addBehavior:function(a,g){c.isArray(g)?p(g,function(c){this.addBehavior(a,c)},this):g instanceof l.base?this.insertBehavior(a,g):g instanceof l.select?this.insertBehavior(a,
73
+ g):g instanceof l.meta?this.insertBehavior(a,g):typeof g=="function"?this.addBehavior(a,g()):(g=new l.base(g),this.addBehavior(a,g))},insertBehavior:function(a,c){c.lexicalOrder=this.lexicalCount;this.lexicalCount+=1;this.behaviors[a]===void 0?(this.selectors.push(a),this.behaviors[a]=[c]):this.behaviors[a].push(c)},addMutationTargets:function(a){this.mutationTargets=this.mutationTargets.concat(a)},fireMutationEvent:function(){var a=this.mutationTargets;if(a.length>0)for(var c=a[0];a.length>0;c=a.shift())jQuery(c).trigger("thisChangedDOM");
74
+ else this.tools.getRootOfDocument().trigger("thisChangedDOM")},mutationEventTriggered:function(a){this.eventQueue.length==0?(r("mutation event - first"),this.enqueueEvent(a),this.handleQueue()):(r("mutation event - queueing"),this.enqueueEvent(a))},enqueueEvent:function(a){var c=!1,f=[];p(this.eventQueue,function(e){c=c||jQuery.contains(e.target,a.target);jQuery.contains(a.target,e.target)||f.push(e)});if(!c)f.unshift(a),this.eventQueue=f},handleQueue:function(){for(;this.eventQueue.length!=0;)this.applyAll(this.eventQueue[0].target),
75
+ this.eventQueue.shift()},applyBehaviorsTo:function(a,c){return this.applyBehaviorsInContext(new this.tools.behaviorContext,a,c)},applyBehaviorsInContext:function(a,c,f){var m,i=new e;this.tools.enrich(i.handlers,a.eventHandlerSet);f=f.sort(function(a,c){return a.priority!=c.priority?a.priority===void 0?-1:c.priority===void 0?1:a.priority-c.priority:a.lexicalOrder-c.lexicalOrder});p(f,function(f){try{m=f.inContext(a),c=f.applyTransform(m,c),a=m,a.element=c,i.recordEventHandlers(a,f)}catch(e){if(e instanceof
76
+ q)r("!!! Transform failed");else throw r(e),e;}});jQuery(c).data("ninja-visited",a);i.applyEventHandlers(c);this.tools.enrich(a.eventHandlerSet,i.handlers);this.fireMutationEvent();return c},collectBehaviors:function(a,c,f){p(f,function(f){try{c.push(f.choose(a))}catch(e){if(e instanceof m)r("!!! couldn't choose");else throw r(e),e;}})},apply:function(a,c,f){var e=[],m=this.selectors.length;this.collectBehaviors(a,e,c);if(c=jQuery(a).data("ninja-visited"))c.unbindHandlers(),this.applyBehaviorsInContext(c,
77
+ a,e);else{for(typeof f=="undefined"&&(f=0);f<m;f++)jQuery(a).is(this.selectors[f])&&this.collectBehaviors(a,e,this.behaviors[this.selectors[f]]);this.applyBehaviorsTo(a,e)}},applyAll:function(a){for(var c=this.selectors.length,f=0;f<c;f++){var e=this;p(i(this.selectors[f],a),function(a){jQuery(a).data("ninja-visited")||e.apply(a,[],f)})}}};return f});
78
+ define("ninja/root-context",["utils"],function(i){var l=i.forEach;return function(c){function e(){this.stashedElements=[];this.eventHandlerSet={}}e.prototype=c.enrich(c,{stash:function(a){this.stashedElements.unshift(a)},unstash:function(){return this.stashedElements.shift()},clearStash:function(){this.stashedElements=[]},cascadeEvent:function(a){var c=Ninja.tools.hiddenDiv();l(this.stashedElements,function(e){e=jQuery(e);e.data("ninja-visited",this);jQuery(c).append(e);e.trigger(a)})},unbindHandlers:function(){var a=
79
+ jQuery(this.element);for(eventName in this.eventHandlerSet)a.unbind(eventName,this.eventHandlerSet[eventName])}});return e}});
80
+ define("ninja/tools",["ninja/behaviors","ninja/behavior-collection","ninja/exceptions","utils","ninja/root-context"],function(i,l,c,e,a){function f(c){this.ninja=c;this.behaviorContext=a(this)}var p=e.log;f.prototype={forEach:e.forEach,enrich:function(a,c){return jQuery.extend(a,c)},ensureDefaults:function(a,c){a instanceof Object||(a={});for(var f in c)typeof a[f]=="undefined"&&(typeof this.ninja.config[f]!="undefined"?a[f]=this.ninja.config[f]:typeof c[f]!="undefined"&&(a[f]=c[f]));return a},getRootOfDocument:function(){return jQuery("html")},
81
+ clearRootCollection:function(){this.ninja.behavior=this.ninja.goodBehavior;this.getRootOfDocument().data("ninja-behavior",null)},getRootCollection:function(){var a=this.getRootOfDocument();if(a.data("ninja-behavior")instanceof l)return a.data("ninja-behavior");var c=new l(this);a.data("ninja-behavior",c);return c},addMutationTargets:function(a){this.getRootCollection().addMutationTargets(a)},fireMutationEvent:function(){this.getRootCollection().fireMutationEvent()},detachSyntheticMutationEvents:function(){this.getRootCollection().fireMutationEvent=
82
+ function(){};this.getRootCollection().addMutationTargets=function(){}},copyAttributes:function(a,c,f){var e=RegExp("^"+f.join("$|^")+"$"),c=jQuery(c);this.forEach(a.attributes,function(a){e.test(a.nodeName)&&c.attr(a.nodeName,a.nodeValue)})},deriveElementsFrom:function(a,c){switch(typeof c){case "undefined":return a;case "string":return jQuery(c);case "function":return c(a)}},extractMethod:function(a,c){if(a.dataset!==void 0&&a.dataset.method!==void 0&&a.dataset.method.length>0)return p("Override via dataset: "+
83
+ a.dataset.method),a.dataset.method;if(a.dataset===void 0&&jQuery(a).attr("data-method")!==void 0)return p("Override via data-method: "+jQuery(a).attr("data-method")),jQuery(a).attr("data-method");if(typeof c!=="undefined")for(var f=0,e=c.length;f<e;f++)if(c[f].name=="Method")return p("Override via Method: "+c[f].value),c[f].value;return typeof a.method!=="undefined"?a.method:"GET"},cantTransform:function(){throw new TransformFailedException;},applyBehaviors:function(a,c){this.getRootCollection().apply(a,
84
+ c)},message:function(a,c){var f=this.ninja.config.messageWrapping(a,c);jQuery(this.ninja.config.messageList).append(f)},hiddenDiv:function(){var a=jQuery("div#ninja-hide");if(a.length>0)return a[0];a=jQuery("<div id='ninja-hide'></div>").css("display","none");jQuery("body").append(a);this.getRootCollection().applyBehaviorsTo(a,[this.ninja.suppressChangeEvents()]);return a}};return f});
85
+ define("ninja/configuration",["require","exports","module"],function(){return{messageWrapping:function(i,l){return"<div class='flash "+l+"'><p>"+i+"</p></div>"},messageList:"#messages",busyLaziness:200}});
86
+ define("ninja",["utils","ninja/tools","ninja/behaviors","ninja/configuration"],function(i,l,c,e){function a(){this.config=e;this.behavior=this.goodBehavior;this.tools=new l(this)}var f=i.log;a.prototype={packageBehaviors:function(a){result=a({does:c.base,chooses:c.meta,selects:c.select});this.tools.enrich(this,result)},packageTools:function(a){this.tools.enrich(l.prototype,a)},configure:function(a){this.tools.enrich(this.config,a)},goodBehavior:function(a){var c=this.tools.getRootCollection(),e;for(e in a)typeof a[e]==
87
+ "undefined"?f("Selector "+e+" not properly defined - ignoring"):c.addBehavior(e,a[e]);jQuery(window).load(function(){Ninja.go()})},badBehavior:function(){throw Error("Called Ninja.behavior() after Ninja.go() - don't do that. 'Go' means 'I'm done, please proceed'");},go:function(){function a(f){c.tools.getRootCollection().mutationEventTriggered(f)}var c=this;if(this.behavior!=this.misbehavior){var f=this.tools.getRootOfDocument();f.bind("DOMSubtreeModified DOMNodeInserted thisChangedDOM",a);f.one("DOMSubtreeModified DOMNodeInserted",
88
+ function(){c.tools.detachSyntheticMutationEvents()});this.behavior=this.badBehavior;this.tools.fireMutationEvent()}}};return new a});define("ninja/behaviors/utility",["ninja"],function(i){i.packageBehaviors(function(i){return{suppressChangeEvents:function(){return new i.does({events:{DOMSubtreeModified:function(){},DOMNodeInserted:function(){}}})}}})});
89
+ define("ninja/behaviors/standard",["ninja","utils"],function(i,l){var c=l.log;i.packageBehaviors(function(e){return{submitsAsAjax:function(a){return new e.chooses(function(c){c.asLink=i.submitsAsAjaxLink(a);c.asForm=i.submitsAsAjaxForm(a)},function(a){switch(a.tagName.toLowerCase()){case "a":return this.asLink;case "form":return this.asForm}})},submitsAsAjaxLink:function(a){a=i.tools.ensureDefaults(a,{busyElement:function(a){return $(a).parents("address,blockquote,body,dd,div,p,dl,dt,table,form,ol,ul,tr")[0]}});
90
+ return new e.does({priority:10,helpers:{findOverlay:function(c){return this.deriveElementsFrom(c,a.busyElement)}},events:{click:function(c){this.overlayAndSubmit(c.target,c.target.href,a.actions)}}})},submitsAsAjaxForm:function(a){a=i.tools.ensureDefaults(a,{busyElement:void 0});return new e.does({priority:20,helpers:{findOverlay:function(c){return this.deriveElementsFrom(c,a.busyElement)}},events:{submit:function(c){this.overlayAndSubmit(c.target,c.target.action,a.actions)}}})},becomesAjaxLink:function(a){a=
91
+ i.tools.ensureDefaults(a,{busyElement:void 0,retainedFormAttributes:["id","class","lang","dir","title","data-.*"]});return[i.submitsAsAjax(a),i.becomesLink(a)]},becomesLink:function(a){a=i.tools.ensureDefaults(a,{retainedFormAttributes:["id","class","lang","dir","title","rel","data-.*"]});return new e.does({priority:30,transform:function(f){var e;(images=jQuery("input[type=image]",f)).size()>0?(image=images[0],e="<img src='"+image.src+"' alt='"+image.alt+"'"):(submits=jQuery("input[type=submit]",
92
+ f)).size()>0?(submit=submits[0],submits.size()>1&&c("Multiple submits. Using: "+submit),e=submit.value):(c("Couldn't find a submit input in form"),this.cantTransform());e=jQuery("<a rel='nofollow' href='#'>"+e+"</a>");this.copyAttributes(f,e,a.retainedFormAttributes);this.stash(jQuery(f).replaceWith(e));return e},events:{click:function(){this.cascadeEvent("submit")}}})},decays:function(a){a=i.tools.ensureDefaults(a,{lifetime:1E4,diesFor:600});return new e.does({priority:100,transform:function(c){jQuery(c).delay(a.lifetime).slideUp(a.diesFor,
93
+ function(){jQuery(c).remove();i.tools.fireMutationEvent()})},events:{click:[function(){jQuery(this.element).remove()},"changesDOM"]}})}}})});
94
+ define("ninja/behaviors/placeholder",["ninja"],function(i){i.packageBehaviors(function(l){function c(a){return new l.does({priority:1E3,submit:[function(c,g,f){a.prepareForSubmit();f(c)},"andDoDefault"]})}function e(a){a=i.tools.ensureDefaults(a,{textElementSelector:function(a){return"*[data-for="+a.id+"]"},findTextElement:function(c){c=$(a.textElementSelector(c));return c.length==0?null:c[0]}});return new l.does({priority:-10,transform:function(c){var g=$(a.findTextElement(c));g===null&&this.cantTransform();
95
+ this.placeholderText=g.text();$(c).attr("placeholder",g.text());this.stash(g.detach())}})}var a=!!("placeholder"in document.createElement("input")),f=!!("placeholder"in document.createElement("textarea"));if(!a)var p=function(a,f){return new l.does({helpers:{prepareForSubmit:function(){$(this.element).val("")}},transform:function(){this.applyBehaviors(f,[c(this)])},events:{focus:function(){var c=$(this.element),f=c.attr("id");c.attr("id","");c.replaceWith(a);a.attr("id",f);a.focus()}}})},r=function(a){a=
96
+ i.tools.ensureDefaults(a,{findParentForm:function(a){return a.parents("form")[0]},retainedInputAttributes:["name","class","style","title","lang","dir","size","maxlength","alt","tabindex","accesskey","data-.*"]});return new l.does({priority:1E3,helpers:{swapInAlternate:function(){var a=$(this.element),c=a.attr("id");a.val()==""&&(a.attr("id",""),a.replaceWith(this.placeholderTextInput),this.placeholderTextInput.attr("id",c))}},transform:function(c){var f,e=$(c);f=$('<input type="text">');this.copyAttributes(c,
97
+ f,a.retainedInputAttributes);f.addClass("ninja_placeholder");f.val(this.placeholderText);e=p(e,a.findParentForm(e));this.applyBehaviors(f,[e]);this.placeholderTextInput=f;this.swapInAlternate();return c},events:{blur:function(){this.swapInAlternate()}}})};if(!a||!f)var q=function(a){a=i.tools.ensureDefaults(a,{findParentForm:function(a){return a.parents("form")[0]}});return new l.does({priority:1E3,helpers:{prepareForSubmit:function(){$(this.element).hasClass("ninja_placeholder")&&$(this.element).val("")}},
98
+ transform:function(f){var e=$(f);e.addClass("ninja_placeholder");e.val(this.placeholderText);this.applyBehaviors(a.findParentForm(e),[c(this)]);return f},events:{focus:function(){$(this.element).hasClass("ninja_placeholder")&&$(this.element).removeClass("ninja_placeholder").val("")},blur:function(){$(this.element).val()==""&&$(this.element).addClass("ninja_placeholder").val(this.placeholderText)}}})};return{hasPlaceholder:function(c){var i=[e(c)];(!a||!f)&&i.push(new l.chooses(function(e){a?(e.asTextInput=
99
+ null,e.asPassword=null):(e.asTextInput=q(c),e.asPassword=r(c));e.asTextArea=f?null:q(c)},function(a){a=$(a);if(a.is("input[type=text]"))return this.asTextInput;else if(a.is("textarea"))return this.asTextArea;else if(a.is("input[type=password]"))return this.asPassword}));return i}}})});
100
+ define("ninja/behaviors/trigger-on",["ninja"],function(i){i.packageBehaviors(function(l){return{triggersOnSelect:function(c){var e=c=i.tools.ensureDefaults(c,{busyElement:void 0,placeholderText:"Select to go",placeholderValue:"instructions"});if(typeof c.actions==="object")e=c.actions;return new l.does({priority:20,helpers:{findOverlay:function(a){return this.deriveElementsFrom(a,c.busyElement)}},transform:function(a){var f=$(a).find("select").first();typeof f=="undefined"&&this.cantTransform();f.prepend("<option value='"+
101
+ c.placeholderValue+"'> "+c.placeholderText+"</option>");f.val(c.placeholderValue);$(a).find("input[type='submit']").remove();return a},events:{change:[function(a,c){this.overlayAndSubmit(c,c.action,e)},"andDoDefault"]}})}}})});define("ninja/behaviors/all",["./utility","./standard","./placeholder","./trigger-on"],function(){});
102
+ define("ninja/tools/overlay",["utils","ninja"],function(i,l){function c(a){a=this.convertToElementArray(a);this.laziness=0;var c=this;this.set=jQuery(jQuery.map(a,function(a){return c.buildOverlayFor(a)}))}var e=i.forEach;c.prototype={convertToElementArray:function(a){var c=this;switch(typeof a){case "undefined":return[];case "boolean":return[];case "string":return c.convertToElementArray(jQuery(a));case "function":return c.convertToElementArray(a());case "object":if("focus"in a&&"blur"in a&&!("jquery"in
103
+ a))return[a];else if("length"in a&&"0"in a){var i=[];e(a,function(a){i=i.concat(c.convertToElementArray(a))});return i}else return[]}},buildOverlayFor:function(a){var c=jQuery(document.createElement("div")),a=jQuery(a),e=a.offset();c.css("position","absolute");c.css("top",e.top);c.css("left",e.left);c.width(a.outerWidth());c.height(a.outerHeight());c.css("zIndex","2");c.css("display","none");return c[0]},affix:function(){this.set.appendTo(jQuery("body"));overlaySet=this.set;window.setTimeout(function(){overlaySet.css("display",
104
+ "block")},this.laziness)},remove:function(){this.set.remove()}};l.packageTools({overlay:function(){return new c(jQuery.makeArray(arguments))},busyOverlay:function(a){a=this.overlay(a);a.set.addClass("ninja_busy");a.laziness=this.ninja.config.busyLaziness;return a},buildOverlayFor:function(a){var c=jQuery(document.createElement("div")),a=jQuery(a),e=a.offset();c.css("position","absolute");c.css("top",e.top);c.css("left",e.left);c.width(a.outerWidth());c.height(a.outerHeight());c.css("zIndex","2");
105
+ return c}});return c});define("ninja/tools/json-handler",["ninja"],function(i){function l(c){this.desc=c}l.prototype={receive:function(c){this.compose([],c,this.desc);return null},compose:function(c,e,a){for(var f in e)e.hasOwnProperty(f)&&f in a&&(typeof a[f]=="function"?a[f].call(this,e[f]):this.compose(c+[f],e[f],a[f]));return null}};i.packageTools({jsonHandler:function(c){return new l(c)}});return l});
106
+ define("ninja/tools/ajax-submitter",["ninja","utils","./json-handler","./overlay"],function(i,l){function c(){this.formData=[];this.action="/";this.method="GET";this.dataType="script";return this}var e=l.log;c.prototype={submit:function(){e("Computed method: "+this.method);jQuery.ajax(this.ajaxData())},sourceForm:function(a){this.formData=jQuery(a).serializeArray()},ajaxData:function(){return{data:this.formData,dataType:this.dataType,url:this.action,type:this.method,complete:this.responseHandler(),
107
+ success:this.successHandler(),error:this.onError}},successHandler:function(){var a=this;return function(c,e,i){a.onSuccess(i,e,c)}},responseHandler:function(){var a=this;return function(c,e){a.onResponse(c,e);i.tools.fireMutationEvent()}},onResponse:function(){},onSuccess:function(){},onError:function(a){e(a.responseText);i.tools.message("Server error: "+a.statusText,"error")}};i.packageTools({ajaxSubmitter:function(){return new c},ajaxToJson:function(a){var c=this.jsonHandler(a),a=this.ajaxSubmitter();
108
+ a.dataType="json";a.onSuccess=function(a,e,i){c.receive(i)};return a},overlayAndSubmit:function(a,c,e){var i=this.busyOverlay(this.findOverlay(a)),e=typeof e=="undefined"?this.ajaxSubmitter():this.ajaxToJson(e);e.sourceForm(a);e.action=c;e.method=this.extractMethod(a,e.formData);e.onResponse=function(){i.remove()};i.affix();e.submit()}});return c});define("ninja/tools/all",["./overlay","./ajax-submitter","./json-handler"],function(){});
109
+ define("ninja/jquery",["ninja"],function(i){jQuery.extend({ninja:i,behavior:i.behavior})});require(["ninja","ninja/behaviors/all","ninja/tools/all","ninja/jquery"],function(i){window.Ninja=i;i.behavior=i.behavior});define("main",function(){});
@@ -0,0 +1,332 @@
1
+ /**
2
+ * Unobtrusive scripting adapter for jQuery
3
+ *
4
+ * Requires jQuery 1.6.0 or later.
5
+ * https://github.com/rails/jquery-ujs
6
+
7
+ * Uploading file using rails.js
8
+ * =============================
9
+ *
10
+ * By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
11
+ * in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
12
+ *
13
+ * The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
14
+ *
15
+ * Ex:
16
+ * $('form').live('ajax:aborted:file', function(event, elements){
17
+ * // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
18
+ * // Returning false in this handler tells rails.js to disallow standard form submission
19
+ * return false;
20
+ * });
21
+ *
22
+ * The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
23
+ *
24
+ * Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
25
+ * techniques like the iframe method to upload the file instead.
26
+ *
27
+ * Required fields in rails.js
28
+ * ===========================
29
+ *
30
+ * If any blank required inputs (required="required") are detected in the remote form, the whole form submission
31
+ * is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
32
+ *
33
+ * The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
34
+ *
35
+ * !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
36
+ * get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
37
+ *
38
+ * Ex:
39
+ * $('form').live('ajax:aborted:required', function(event, elements){
40
+ * // Returning false in this handler tells rails.js to submit the form anyway.
41
+ * // The blank required inputs are passed to this function in `elements`.
42
+ * return ! confirm("Would you like to submit the form with missing info?");
43
+ * });
44
+ */
45
+
46
+ (function($, undefined) {
47
+ // Shorthand to make it a little easier to call public rails functions from within rails.js
48
+ var rails;
49
+
50
+ $.rails = rails = {
51
+ // Link elements bound by jquery-ujs
52
+ linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]',
53
+
54
+ // Select elements bound by jquery-ujs
55
+ selectChangeSelector: 'select[data-remote]',
56
+
57
+ // Form elements bound by jquery-ujs
58
+ formSubmitSelector: 'form',
59
+
60
+ // Form input elements bound by jquery-ujs
61
+ formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])',
62
+
63
+ // Form input elements disabled during form submission
64
+ disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
65
+
66
+ // Form input elements re-enabled after form submission
67
+ enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
68
+
69
+ // Form required input elements
70
+ requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
71
+
72
+ // Form file input elements
73
+ fileInputSelector: 'input:file',
74
+
75
+ // Make sure that every Ajax request sends the CSRF token
76
+ CSRFProtection: function(xhr) {
77
+ var token = $('meta[name="csrf-token"]').attr('content');
78
+ if (token) xhr.setRequestHeader('X-CSRF-Token', token);
79
+ },
80
+
81
+ // Triggers an event on an element and returns false if the event result is false
82
+ fire: function(obj, name, data) {
83
+ var event = $.Event(name);
84
+ obj.trigger(event, data);
85
+ return event.result !== false;
86
+ },
87
+
88
+ // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
89
+ confirm: function(message) {
90
+ return confirm(message);
91
+ },
92
+
93
+ // Default ajax function, may be overridden with custom function in $.rails.ajax
94
+ ajax: function(options) {
95
+ return $.ajax(options);
96
+ },
97
+
98
+ // Submits "remote" forms and links with ajax
99
+ handleRemote: function(element) {
100
+ var method, url, data,
101
+ crossDomain = element.data('cross-domain') || null,
102
+ dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType),
103
+ options;
104
+
105
+ if (rails.fire(element, 'ajax:before')) {
106
+
107
+ if (element.is('form')) {
108
+ method = element.attr('method');
109
+ url = element.attr('action');
110
+ data = element.serializeArray();
111
+ // memoized value from clicked submit button
112
+ var button = element.data('ujs:submit-button');
113
+ if (button) {
114
+ data.push(button);
115
+ element.data('ujs:submit-button', null);
116
+ }
117
+ } else if (element.is('select')) {
118
+ method = element.data('method');
119
+ url = element.data('url');
120
+ data = element.serialize();
121
+ if (element.data('params')) data = data + "&" + element.data('params');
122
+ } else {
123
+ method = element.data('method');
124
+ url = element.attr('href');
125
+ data = element.data('params') || null;
126
+ }
127
+
128
+ options = {
129
+ type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
130
+ // stopping the "ajax:beforeSend" event will cancel the ajax request
131
+ beforeSend: function(xhr, settings) {
132
+ if (settings.dataType === undefined) {
133
+ xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
134
+ }
135
+ return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
136
+ },
137
+ success: function(data, status, xhr) {
138
+ element.trigger('ajax:success', [data, status, xhr]);
139
+ },
140
+ complete: function(xhr, status) {
141
+ element.trigger('ajax:complete', [xhr, status]);
142
+ },
143
+ error: function(xhr, status, error) {
144
+ element.trigger('ajax:error', [xhr, status, error]);
145
+ }
146
+ };
147
+ // Only pass url to `ajax` options if not blank
148
+ if (url) { options.url = url; }
149
+
150
+ rails.ajax(options);
151
+ }
152
+ },
153
+
154
+ // Handles "data-method" on links such as:
155
+ // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
156
+ handleMethod: function(link) {
157
+ var href = link.attr('href'),
158
+ method = link.data('method'),
159
+ csrf_token = $('meta[name=csrf-token]').attr('content'),
160
+ csrf_param = $('meta[name=csrf-param]').attr('content'),
161
+ form = $('<form method="post" action="' + href + '"></form>'),
162
+ metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
163
+
164
+ if (csrf_param !== undefined && csrf_token !== undefined) {
165
+ metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
166
+ }
167
+
168
+ form.hide().append(metadata_input).appendTo('body');
169
+ form.submit();
170
+ },
171
+
172
+ /* Disables form elements:
173
+ - Caches element value in 'ujs:enable-with' data store
174
+ - Replaces element text with value of 'data-disable-with' attribute
175
+ - Adds disabled=disabled attribute
176
+ */
177
+ disableFormElements: function(form) {
178
+ form.find(rails.disableSelector).each(function() {
179
+ var element = $(this), method = element.is('button') ? 'html' : 'val';
180
+ element.data('ujs:enable-with', element[method]());
181
+ element[method](element.data('disable-with'));
182
+ element.attr('disabled', 'disabled');
183
+ });
184
+ },
185
+
186
+ /* Re-enables disabled form elements:
187
+ - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
188
+ - Removes disabled attribute
189
+ */
190
+ enableFormElements: function(form) {
191
+ form.find(rails.enableSelector).each(function() {
192
+ var element = $(this), method = element.is('button') ? 'html' : 'val';
193
+ if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
194
+ element.removeAttr('disabled');
195
+ });
196
+ },
197
+
198
+ /* For 'data-confirm' attribute:
199
+ - Fires `confirm` event
200
+ - Shows the confirmation dialog
201
+ - Fires the `confirm:complete` event
202
+
203
+ Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
204
+ Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
205
+ Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
206
+ return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
207
+ */
208
+ allowAction: function(element) {
209
+ var message = element.data('confirm'),
210
+ answer = false, callback;
211
+ if (!message) { return true; }
212
+
213
+ if (rails.fire(element, 'confirm')) {
214
+ answer = rails.confirm(message);
215
+ callback = rails.fire(element, 'confirm:complete', [answer]);
216
+ }
217
+ return answer && callback;
218
+ },
219
+
220
+ // Helper function which checks for blank inputs in a form that match the specified CSS selector
221
+ blankInputs: function(form, specifiedSelector, nonBlank) {
222
+ var inputs = $(), input,
223
+ selector = specifiedSelector || 'input,textarea';
224
+ form.find(selector).each(function() {
225
+ input = $(this);
226
+ // Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
227
+ if (nonBlank ? input.val() : !input.val()) {
228
+ inputs = inputs.add(input);
229
+ }
230
+ });
231
+ return inputs.length ? inputs : false;
232
+ },
233
+
234
+ // Helper function which checks for non-blank inputs in a form that match the specified CSS selector
235
+ nonBlankInputs: function(form, specifiedSelector) {
236
+ return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
237
+ },
238
+
239
+ // Helper function, needed to provide consistent behavior in IE
240
+ stopEverything: function(e) {
241
+ $(e.target).trigger('ujs:everythingStopped');
242
+ e.stopImmediatePropagation();
243
+ return false;
244
+ },
245
+
246
+ // find all the submit events directly bound to the form and
247
+ // manually invoke them. If anyone returns false then stop the loop
248
+ callFormSubmitBindings: function(form) {
249
+ var events = form.data('events'), continuePropagation = true;
250
+ if (events !== undefined && events['submit'] !== undefined) {
251
+ $.each(events['submit'], function(i, obj){
252
+ if (typeof obj.handler === 'function') return continuePropagation = obj.handler(obj.data);
253
+ });
254
+ }
255
+ return continuePropagation;
256
+ }
257
+ };
258
+
259
+ $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
260
+
261
+ $(rails.linkClickSelector).live('click.rails', function(e) {
262
+ var link = $(this);
263
+ if (!rails.allowAction(link)) return rails.stopEverything(e);
264
+
265
+ if (link.data('remote') !== undefined) {
266
+ rails.handleRemote(link);
267
+ return false;
268
+ } else if (link.data('method')) {
269
+ rails.handleMethod(link);
270
+ return false;
271
+ }
272
+ });
273
+
274
+ $(rails.selectChangeSelector).live('change.rails', function(e) {
275
+ var link = $(this);
276
+ if (!rails.allowAction(link)) return rails.stopEverything(e);
277
+
278
+ rails.handleRemote(link);
279
+ return false;
280
+ });
281
+
282
+ $(rails.formSubmitSelector).live('submit.rails', function(e) {
283
+ var form = $(this),
284
+ remote = form.data('remote') !== undefined,
285
+ blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
286
+ nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
287
+
288
+ if (!rails.allowAction(form)) return rails.stopEverything(e);
289
+
290
+ // skip other logic when required values are missing or file upload is present
291
+ if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
292
+ return rails.stopEverything(e);
293
+ }
294
+
295
+ if (remote) {
296
+ if (nonBlankFileInputs) {
297
+ return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
298
+ }
299
+
300
+ // If browser does not support submit bubbling, then this live-binding will be called before direct
301
+ // bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
302
+ if (!$.support.submitBubbles && rails.callFormSubmitBindings(form) === false) return rails.stopEverything(e);
303
+
304
+ rails.handleRemote(form);
305
+ return false;
306
+ } else {
307
+ // slight timeout so that the submit button gets properly serialized
308
+ setTimeout(function(){ rails.disableFormElements(form); }, 13);
309
+ }
310
+ });
311
+
312
+ $(rails.formInputClickSelector).live('click.rails', function(event) {
313
+ var button = $(this);
314
+
315
+ if (!rails.allowAction(button)) return rails.stopEverything(event);
316
+
317
+ // register the pressed submit button
318
+ var name = button.attr('name'),
319
+ data = name ? {name:name, value:button.val()} : null;
320
+
321
+ button.closest('form').data('ujs:submit-button', data);
322
+ });
323
+
324
+ $(rails.formSubmitSelector).live('ajax:beforeSend.rails', function(event) {
325
+ if (this == event.target) rails.disableFormElements($(this));
326
+ });
327
+
328
+ $(rails.formSubmitSelector).live('ajax:complete.rails', function(event) {
329
+ if (this == event.target) rails.enableFormElements($(this));
330
+ });
331
+
332
+ })( jQuery );