ramaze 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/doc/AUTHORS +2 -0
- data/doc/CHANGELOG +173 -0
- data/doc/changes.txt +4184 -0
- data/doc/changes.xml +4186 -0
- data/doc/meta/announcement.txt +22 -25
- data/doc/meta/internals.txt +146 -9
- data/examples/blog/template/index.xhtml +5 -2
- data/examples/fcgi.rb +13 -0
- data/examples/wiktacular/main.rb +8 -0
- data/examples/wiktacular/mkd/link/2007-07-20_19-45-51.mkd +1 -0
- data/examples/wiktacular/mkd/link/current.mkd +1 -0
- data/examples/wiktacular/mkd/main/2007-07-20_16-31-33.mkd +1 -0
- data/examples/wiktacular/mkd/main/2007-07-20_19-21-12.mkd +1 -0
- data/examples/wiktacular/mkd/main/2007-07-20_19-23-10.mkd +2 -0
- data/examples/wiktacular/mkd/main/2007-07-20_19-45-07.mkd +2 -0
- data/examples/wiktacular/mkd/main/current.mkd +2 -0
- data/examples/wiktacular/mkd/markdown/current.mkd +3 -0
- data/examples/wiktacular/mkd/testing/2007-07-20_16-43-46.mkd +2 -0
- data/examples/wiktacular/mkd/testing/2007-07-20_19-43-50.mkd +3 -0
- data/examples/wiktacular/mkd/testing/2007-07-21_18-46-01.mkd +11 -0
- data/examples/wiktacular/mkd/testing/2007-07-21_18-46-32.mkd +13 -0
- data/examples/wiktacular/mkd/testing/2007-07-21_18-47-08.mkd +17 -0
- data/examples/wiktacular/mkd/testing/2007-07-21_18-47-54.mkd +17 -0
- data/examples/wiktacular/mkd/testing/current.mkd +17 -0
- data/examples/wiktacular/public/favicon.ico +0 -0
- data/examples/wiktacular/public/screen.css +72 -0
- data/examples/wiktacular/src/controller.rb +44 -0
- data/examples/wiktacular/src/model.rb +92 -0
- data/examples/wiktacular/src/page.rb +66 -0
- data/examples/wiktacular/template/edit.xhtml +7 -0
- data/examples/wiktacular/template/index.xhtml +11 -0
- data/examples/wiktacular/template/new.xhtml +7 -0
- data/lib/proto/main.rb +2 -0
- data/lib/proto/public/error.zmr +3 -0
- data/lib/proto/public/js/jquery.js +1755 -1334
- data/lib/proto/template/index.xhtml +2 -2
- data/lib/ramaze.rb +8 -3
- data/lib/ramaze/action/render.rb +11 -0
- data/lib/ramaze/adapter/base.rb +11 -7
- data/lib/ramaze/cache.rb +25 -10
- data/lib/ramaze/cache/memcached.rb +16 -1
- data/lib/ramaze/cache/yaml_store.rb +10 -0
- data/lib/ramaze/controller.rb +12 -2
- data/lib/ramaze/controller/error.rb +9 -3
- data/lib/ramaze/controller/resolve.rb +20 -18
- data/lib/ramaze/dispatcher.rb +13 -4
- data/lib/ramaze/dispatcher/action.rb +7 -3
- data/lib/ramaze/dispatcher/error.rb +24 -2
- data/lib/ramaze/dispatcher/file.rb +12 -6
- data/lib/ramaze/global.rb +0 -3
- data/lib/ramaze/global/dsl.rb +9 -0
- data/lib/ramaze/global/globalstruct.rb +7 -1
- data/lib/ramaze/helper/aspect.rb +4 -2
- data/lib/ramaze/helper/cgi.rb +2 -2
- data/lib/ramaze/helper/file.rb +3 -0
- data/lib/ramaze/helper/link.rb +20 -0
- data/lib/ramaze/helper/markaby.rb +3 -0
- data/lib/ramaze/helper/pager.rb +10 -17
- data/lib/ramaze/helper/partial.rb +9 -3
- data/lib/ramaze/inform/analogger.rb +14 -0
- data/lib/ramaze/inform/growl.rb +7 -0
- data/lib/ramaze/inform/hub.rb +9 -0
- data/lib/ramaze/inform/informer.rb +9 -3
- data/lib/ramaze/inform/informing.rb +9 -3
- data/lib/ramaze/inform/knotify.rb +5 -1
- data/lib/ramaze/inform/syslog.rb +3 -0
- data/lib/ramaze/inform/xosd.rb +12 -0
- data/lib/ramaze/template.rb +3 -0
- data/lib/ramaze/template/amrita2.rb +2 -0
- data/lib/ramaze/template/erubis.rb +1 -0
- data/lib/ramaze/template/ezamar.rb +1 -0
- data/lib/ramaze/template/ezamar/element.rb +17 -11
- data/lib/ramaze/template/ezamar/engine.rb +5 -0
- data/lib/ramaze/template/ezamar/render_partial.rb +4 -2
- data/lib/ramaze/template/haml.rb +4 -0
- data/lib/ramaze/template/liquid.rb +4 -0
- data/lib/ramaze/template/markaby.rb +4 -0
- data/lib/ramaze/template/remarkably.rb +4 -0
- data/lib/ramaze/tool.rb +10 -0
- data/lib/ramaze/tool/localize.rb +1 -1
- data/lib/ramaze/trinity/session.rb +8 -1
- data/lib/ramaze/version.rb +1 -1
- data/rake_tasks/maintaince.rake +2 -2
- data/spec/ramaze/action/basics.rb +1 -1
- data/spec/ramaze/cache.rb +11 -0
- data/spec/ramaze/controller.rb +0 -14
- data/spec/ramaze/dispatcher/file.rb +5 -5
- data/spec/ramaze/dispatcher/public/favicon.ico +0 -0
- data/spec/ramaze/dispatcher/public/test_download.css +141 -0
- data/spec/ramaze/error.rb +21 -7
- data/spec/ramaze/helper/link.rb +15 -0
- data/spec/ramaze/helper/pager.rb +26 -3
- data/spec/ramaze/helper/partial.rb +2 -2
- metadata +43 -4
- data/doc/COPYING.ja +0 -51
@@ -0,0 +1,44 @@
|
|
1
|
+
class MainController < Ramaze::Controller
|
2
|
+
def index handle = "main"
|
3
|
+
@handle = handle
|
4
|
+
@entry = WikiEntry.new(handle)
|
5
|
+
if @entry.exists?
|
6
|
+
@text = EntryView.render(@entry.content)
|
7
|
+
@history = @entry.history.map{|f|
|
8
|
+
DateTime.strptime(File.basename(f, ".mkd"),
|
9
|
+
"%Y-%m-%d_%H-%M-%S")
|
10
|
+
}.join("<br />\n")
|
11
|
+
else
|
12
|
+
@text = "No Entry"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def edit handle
|
17
|
+
@handle = handle
|
18
|
+
@entry = WikiEntry[handle]
|
19
|
+
@text = @entry.content
|
20
|
+
end
|
21
|
+
|
22
|
+
def revert handle
|
23
|
+
WikiEntry[handle].revert
|
24
|
+
redirect Rs(handle)
|
25
|
+
end
|
26
|
+
|
27
|
+
def unrevert handle
|
28
|
+
WikiEntry[handle].unrevert
|
29
|
+
redirect Rs(handle)
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete handle
|
33
|
+
WikiEntry[handle].delete
|
34
|
+
redirect_referer
|
35
|
+
end
|
36
|
+
|
37
|
+
def save
|
38
|
+
redirect_referer unless request.post?
|
39
|
+
handle = request['handle']
|
40
|
+
entry = WikiEntry[handle]
|
41
|
+
entry.save(request['text'])
|
42
|
+
redirect Rs(:index, handle)
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'cgi'
|
3
|
+
|
4
|
+
class WikiEntry
|
5
|
+
class << self
|
6
|
+
def [](name)
|
7
|
+
new(name)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :history, :current, :name
|
12
|
+
|
13
|
+
def initialize(name)
|
14
|
+
# avoid tampering with the path
|
15
|
+
@name = File.basename(File.expand_path(name))
|
16
|
+
update
|
17
|
+
end
|
18
|
+
|
19
|
+
def update
|
20
|
+
@current = "#{base}/current.mkd"
|
21
|
+
@history = Dir["#{base}/*_*.mkd"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def save newtext
|
25
|
+
FileUtils.mkdir_p(base)
|
26
|
+
|
27
|
+
if content != newtext
|
28
|
+
history_name = "#{base}/#{timestamp}.mkd"
|
29
|
+
FileUtils.mv(@current, history_name) if exists?
|
30
|
+
File.open(@current, "w+"){|fp| fp.print(newtext) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def rename to
|
35
|
+
FileUtils.mv(base, "mkd/#{to}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete
|
39
|
+
FileUtils.rm_rf(base)
|
40
|
+
end
|
41
|
+
|
42
|
+
def revert
|
43
|
+
return if not exists? or @history.empty?
|
44
|
+
FileUtils.mv(@current, @current + ".bak")
|
45
|
+
FileUtils.mv(@history.last, @current) unless @history.empty?
|
46
|
+
update
|
47
|
+
end
|
48
|
+
|
49
|
+
def unrevert
|
50
|
+
bakfile = @current + '.bak'
|
51
|
+
return unless File.exists?(bakfile)
|
52
|
+
FileUtils.mv(bakfile, @current)
|
53
|
+
update
|
54
|
+
end
|
55
|
+
|
56
|
+
def exists?
|
57
|
+
File.exists?(@current)
|
58
|
+
end
|
59
|
+
|
60
|
+
def base
|
61
|
+
"mkd/#@name"
|
62
|
+
end
|
63
|
+
|
64
|
+
def content
|
65
|
+
CGI.unescapeHTML(File.read(@current)) if exists?
|
66
|
+
end
|
67
|
+
|
68
|
+
def timestamp
|
69
|
+
Time.now.strftime("%Y-%m-%d_%H-%M-%S")
|
70
|
+
end
|
71
|
+
|
72
|
+
def escape_path(path)
|
73
|
+
File.basename(File.expand_path(path))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class EntryView
|
78
|
+
class << self
|
79
|
+
def render content
|
80
|
+
mkd2html(content || "No Entry")
|
81
|
+
end
|
82
|
+
|
83
|
+
def mkd2html text
|
84
|
+
html = BlueCloth.new(text).to_html
|
85
|
+
html.gsub!(/\[\[(.*?)\]\]/) do |m|
|
86
|
+
exists = WikiEntry[$1] ? 'exists' : 'nonexists'
|
87
|
+
%{<a href="/#{CGI.escape($1)}" class="#{exists}">#{$1}</a>}
|
88
|
+
end
|
89
|
+
html
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class Page < Ezamar::Element
|
2
|
+
def head
|
3
|
+
%{
|
4
|
+
<html>
|
5
|
+
<head>
|
6
|
+
<title>Wiktacular</title>
|
7
|
+
<link rel="stylesheet" type="text/css" media="screen" href="/screen.css" />
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def menu
|
14
|
+
%{
|
15
|
+
<div id="menu">
|
16
|
+
<a href="/main">Home</a>
|
17
|
+
<a href="/new">New Entry</a>
|
18
|
+
</div>
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def navigation
|
23
|
+
nodes = Dir['mkd/*'].map{|f|
|
24
|
+
name = File.basename(f)
|
25
|
+
%[<a href="/#{name}">#{name}</a>]
|
26
|
+
}.join("\n")
|
27
|
+
%{
|
28
|
+
<div id="navigation">
|
29
|
+
<div id="nodes">
|
30
|
+
#{nodes}
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def main
|
37
|
+
%{
|
38
|
+
<div id="manipulate">
|
39
|
+
<a href="/edit/\#@handle">Edit</a>
|
40
|
+
<a href="/delete/\#@handle">Delete</a>
|
41
|
+
<a href="/revert/\#@handle">Revert</a>
|
42
|
+
<a href="/unrevert/\#@handle">Unrevert</a>
|
43
|
+
</div>
|
44
|
+
<div id="content">
|
45
|
+
#{content}
|
46
|
+
</div>
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def render
|
51
|
+
head +
|
52
|
+
menu +
|
53
|
+
navigation +
|
54
|
+
main +
|
55
|
+
footer
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def footer
|
60
|
+
%{
|
61
|
+
<div id="copyright">Wiktacular is powered by <a href="http://ramaze.rubyforge.org/">Ramaze</a></div>
|
62
|
+
</body>
|
63
|
+
</html>
|
64
|
+
}
|
65
|
+
end
|
66
|
+
end
|
data/lib/proto/main.rb
CHANGED
data/lib/proto/public/error.zmr
CHANGED
@@ -7,6 +7,9 @@
|
|
7
7
|
<body>
|
8
8
|
<h1>#{@title}</h1>
|
9
9
|
|
10
|
+
<p>The backtrace gives filenames and line numbers for all parts of the call stack.<br />
|
11
|
+
Click on any of them to view the surrounding source code.</p>
|
12
|
+
|
10
13
|
<table class="main">
|
11
14
|
<tr class="head">
|
12
15
|
<td>File</td><td>Line</td><td>Method</td>
|
@@ -1,91 +1,92 @@
|
|
1
|
-
|
1
|
+
// prevent execution of jQuery if included more than once
|
2
2
|
if(typeof window.jQuery == "undefined") {
|
3
3
|
/*
|
4
|
-
* jQuery 1.
|
4
|
+
* jQuery 1.1.3.1 - New Wave Javascript
|
5
5
|
*
|
6
|
-
* Copyright (c)
|
6
|
+
* Copyright (c) 2007 John Resig (jquery.com)
|
7
7
|
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
8
8
|
* and GPL (GPL-LICENSE.txt) licenses.
|
9
9
|
*
|
10
|
-
* $Date:
|
11
|
-
* $Rev:
|
10
|
+
* $Date: 2007-07-05 00:43:24 -0400 (Thu, 05 Jul 2007) $
|
11
|
+
* $Rev: 2243 $
|
12
12
|
*/
|
13
13
|
|
14
14
|
// Global undefined variable
|
15
15
|
window.undefined = window.undefined;
|
16
|
-
jQuery = function(a,c) {
|
17
|
-
|
18
|
-
// Shortcut for document ready (because $(document).each() is silly)
|
19
|
-
if ( a && typeof a == "function" && jQuery.fn.ready )
|
20
|
-
return jQuery(document).ready(a);
|
21
|
-
|
22
|
-
// Make sure that a selection was provided
|
23
|
-
a = a || jQuery.context || document;
|
24
|
-
|
25
|
-
// Watch for when a jQuery object is passed as the selector
|
26
|
-
if ( a.jquery )
|
27
|
-
return jQuery( jQuery.merge( a, [] ) );
|
28
|
-
|
29
|
-
// Watch for when a jQuery object is passed at the context
|
30
|
-
if ( c && c.jquery )
|
31
|
-
return jQuery( c ).find(a);
|
32
|
-
|
16
|
+
var jQuery = function(a,c) {
|
33
17
|
// If the context is global, return a new object
|
34
|
-
if ( window == this )
|
18
|
+
if ( window == this || !this.init )
|
35
19
|
return new jQuery(a,c);
|
36
|
-
|
37
|
-
|
38
|
-
var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
|
39
|
-
if ( m ) a = jQuery.clean( [ m[1] ] );
|
40
|
-
|
41
|
-
// Watch for when an array is passed in
|
42
|
-
this.get( a.constructor == Array || a.length && !a.nodeType && a[0] != undefined && a[0].nodeType ?
|
43
|
-
// Assume that it is an array of DOM Elements
|
44
|
-
jQuery.merge( a, [] ) :
|
45
|
-
|
46
|
-
// Find the matching elements and save them for later
|
47
|
-
jQuery.find( a, c ) );
|
48
|
-
|
49
|
-
// See if an extra function was provided
|
50
|
-
var fn = arguments[ arguments.length - 1 ];
|
51
|
-
|
52
|
-
// If so, execute it in context
|
53
|
-
if ( fn && typeof fn == "function" )
|
54
|
-
this.each(fn);
|
20
|
+
|
21
|
+
return this.init(a,c);
|
55
22
|
};
|
56
23
|
|
57
24
|
// Map over the $ in case of overwrite
|
58
25
|
if ( typeof $ != "undefined" )
|
59
26
|
jQuery._$ = $;
|
60
|
-
|
27
|
+
|
61
28
|
// Map the jQuery namespace to the '$' one
|
62
29
|
var $ = jQuery;
|
63
30
|
|
64
31
|
jQuery.fn = jQuery.prototype = {
|
65
|
-
|
32
|
+
init: function(a,c) {
|
33
|
+
// Make sure that a selection was provided
|
34
|
+
a = a || document;
|
35
|
+
|
36
|
+
// HANDLE: $(function)
|
37
|
+
// Shortcut for document ready
|
38
|
+
if ( jQuery.isFunction(a) )
|
39
|
+
return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a );
|
40
|
+
|
41
|
+
// Handle HTML strings
|
42
|
+
if ( typeof a == "string" ) {
|
43
|
+
// HANDLE: $(html) -> $(array)
|
44
|
+
var m = /^[^<]*(<(.|\s)+>)[^>]*$/.exec(a);
|
45
|
+
if ( m )
|
46
|
+
a = jQuery.clean( [ m[1] ] );
|
47
|
+
|
48
|
+
// HANDLE: $(expr)
|
49
|
+
else
|
50
|
+
return new jQuery( c ).find( a );
|
51
|
+
}
|
52
|
+
|
53
|
+
return this.setArray(
|
54
|
+
// HANDLE: $(array)
|
55
|
+
a.constructor == Array && a ||
|
56
|
+
|
57
|
+
// HANDLE: $(arraylike)
|
58
|
+
// Watch for when an array-like object is passed as the selector
|
59
|
+
(a.jquery || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType) && jQuery.makeArray( a ) ||
|
60
|
+
|
61
|
+
// HANDLE: $(*)
|
62
|
+
[ a ] );
|
63
|
+
},
|
64
|
+
jquery: "1.1.3.1",
|
66
65
|
|
67
66
|
size: function() {
|
68
67
|
return this.length;
|
69
68
|
},
|
69
|
+
|
70
|
+
length: 0,
|
70
71
|
|
71
72
|
get: function( num ) {
|
72
|
-
|
73
|
-
if ( num && num.constructor == Array ) {
|
73
|
+
return num == undefined ?
|
74
74
|
|
75
|
-
//
|
76
|
-
|
77
|
-
this.length = 0;
|
78
|
-
[].push.apply( this, num );
|
75
|
+
// Return a 'clean' array
|
76
|
+
jQuery.makeArray( this ) :
|
79
77
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
78
|
+
// Return just the object
|
79
|
+
this[num];
|
80
|
+
},
|
81
|
+
pushStack: function( a ) {
|
82
|
+
var ret = jQuery(a);
|
83
|
+
ret.prevObject = this;
|
84
|
+
return ret;
|
85
|
+
},
|
86
|
+
setArray: function( a ) {
|
87
|
+
this.length = 0;
|
88
|
+
[].push.apply( this, a );
|
89
|
+
return this;
|
89
90
|
},
|
90
91
|
each: function( fn, args ) {
|
91
92
|
return jQuery.each( this, fn, args );
|
@@ -99,52 +100,56 @@ jQuery.fn = jQuery.prototype = {
|
|
99
100
|
},
|
100
101
|
|
101
102
|
attr: function( key, value, type ) {
|
103
|
+
var obj = key;
|
104
|
+
|
105
|
+
// Look for the case where we're accessing a style value
|
106
|
+
if ( key.constructor == String )
|
107
|
+
if ( value == undefined )
|
108
|
+
return this.length && jQuery[ type || "attr" ]( this[0], key ) || undefined;
|
109
|
+
else {
|
110
|
+
obj = {};
|
111
|
+
obj[ key ] = value;
|
112
|
+
}
|
113
|
+
|
102
114
|
// Check to see if we're setting style values
|
103
|
-
return
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
prop, key[prop]
|
112
|
-
);
|
113
|
-
|
114
|
-
// See if we're setting a single key/value style
|
115
|
-
else
|
116
|
-
jQuery.attr(
|
117
|
-
type ? this.style : this,
|
118
|
-
key, value
|
119
|
-
);
|
120
|
-
}) :
|
121
|
-
|
122
|
-
// Look for the case where we're accessing a style value
|
123
|
-
jQuery[ type || "attr" ]( this[0], key );
|
115
|
+
return this.each(function(index){
|
116
|
+
// Set all the styles
|
117
|
+
for ( var prop in obj )
|
118
|
+
jQuery.attr(
|
119
|
+
type ? this.style : this,
|
120
|
+
prop, jQuery.prop(this, obj[prop], type, index, prop)
|
121
|
+
);
|
122
|
+
});
|
124
123
|
},
|
125
124
|
|
126
125
|
css: function( key, value ) {
|
127
126
|
return this.attr( key, value, "curCSS" );
|
128
127
|
},
|
128
|
+
|
129
129
|
text: function(e) {
|
130
|
-
|
130
|
+
if ( typeof e == "string" )
|
131
|
+
return this.empty().append( document.createTextNode( e ) );
|
132
|
+
|
131
133
|
var t = "";
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
}
|
134
|
+
jQuery.each( e || this, function(){
|
135
|
+
jQuery.each( this.childNodes, function(){
|
136
|
+
if ( this.nodeType != 8 )
|
137
|
+
t += this.nodeType != 1 ?
|
138
|
+
this.nodeValue : jQuery.fn.text([ this ]);
|
139
|
+
});
|
140
|
+
});
|
139
141
|
return t;
|
140
142
|
},
|
141
143
|
|
142
144
|
wrap: function() {
|
143
145
|
// The elements to wrap the target around
|
144
|
-
var a =
|
146
|
+
var a, args = arguments;
|
145
147
|
|
146
148
|
// Wrap each of the matched elements individually
|
147
149
|
return this.each(function(){
|
150
|
+
if ( !a )
|
151
|
+
a = jQuery.clean(args, this.ownerDocument);
|
152
|
+
|
148
153
|
// Clone the structure that we're using to wrap
|
149
154
|
var b = a[0].cloneNode(true);
|
150
155
|
|
@@ -159,215 +164,216 @@ jQuery.fn = jQuery.prototype = {
|
|
159
164
|
b.appendChild( this );
|
160
165
|
});
|
161
166
|
},
|
162
|
-
|
163
167
|
append: function() {
|
164
168
|
return this.domManip(arguments, true, 1, function(a){
|
165
169
|
this.appendChild( a );
|
166
170
|
});
|
167
171
|
},
|
168
|
-
|
169
172
|
prepend: function() {
|
170
173
|
return this.domManip(arguments, true, -1, function(a){
|
171
174
|
this.insertBefore( a, this.firstChild );
|
172
175
|
});
|
173
176
|
},
|
174
|
-
|
175
177
|
before: function() {
|
176
178
|
return this.domManip(arguments, false, 1, function(a){
|
177
179
|
this.parentNode.insertBefore( a, this );
|
178
180
|
});
|
179
181
|
},
|
180
|
-
|
181
182
|
after: function() {
|
182
183
|
return this.domManip(arguments, false, -1, function(a){
|
183
184
|
this.parentNode.insertBefore( a, this.nextSibling );
|
184
185
|
});
|
185
186
|
},
|
186
187
|
end: function() {
|
187
|
-
return this.
|
188
|
+
return this.prevObject || jQuery([]);
|
188
189
|
},
|
189
190
|
find: function(t) {
|
190
|
-
|
191
|
-
|
192
|
-
|
191
|
+
var data = jQuery.map(this, function(a){ return jQuery.find(t,a); });
|
192
|
+
return this.pushStack( /[^+>] [^+>]/.test( t ) || t.indexOf("..") > -1 ?
|
193
|
+
jQuery.unique( data ) : data );
|
193
194
|
},
|
194
195
|
clone: function(deep) {
|
195
|
-
|
196
|
+
// Need to remove events on the element and its descendants
|
197
|
+
var $this = this.add(this.find("*"));
|
198
|
+
$this.each(function() {
|
199
|
+
this._$events = {};
|
200
|
+
for (var type in this.$events)
|
201
|
+
this._$events[type] = jQuery.extend({},this.$events[type]);
|
202
|
+
}).unbind();
|
203
|
+
|
204
|
+
// Do the clone
|
205
|
+
var r = this.pushStack( jQuery.map( this, function(a){
|
196
206
|
return a.cloneNode( deep != undefined ? deep : true );
|
197
|
-
})
|
207
|
+
}) );
|
208
|
+
|
209
|
+
// Add the events back to the original and its descendants
|
210
|
+
$this.each(function() {
|
211
|
+
var events = this._$events;
|
212
|
+
for (var type in events)
|
213
|
+
for (var handler in events[type])
|
214
|
+
jQuery.event.add(this, type, events[type][handler], events[type][handler].data);
|
215
|
+
this._$events = null;
|
216
|
+
});
|
217
|
+
|
218
|
+
// Return the cloned set
|
219
|
+
return r;
|
198
220
|
},
|
199
221
|
|
200
222
|
filter: function(t) {
|
201
223
|
return this.pushStack(
|
202
|
-
|
203
|
-
jQuery.
|
204
|
-
|
205
|
-
if ( jQuery.filter(t[i],[a]).r.length )
|
206
|
-
return a;
|
224
|
+
jQuery.isFunction( t ) &&
|
225
|
+
jQuery.grep(this, function(el, index){
|
226
|
+
return t.apply(el, [index])
|
207
227
|
}) ||
|
208
228
|
|
209
|
-
t
|
210
|
-
( t ? this.get() : [] ) ||
|
211
|
-
|
212
|
-
typeof t == "function" &&
|
213
|
-
jQuery.grep( this, t ) ||
|
214
|
-
|
215
|
-
jQuery.filter(t,this).r, arguments );
|
229
|
+
jQuery.multiFilter(t,this) );
|
216
230
|
},
|
217
231
|
|
218
232
|
not: function(t) {
|
219
|
-
return this.pushStack(
|
220
|
-
|
221
|
-
jQuery.
|
233
|
+
return this.pushStack(
|
234
|
+
t.constructor == String &&
|
235
|
+
jQuery.multiFilter(t, this, true) ||
|
236
|
+
|
237
|
+
jQuery.grep(this, function(a) {
|
238
|
+
return ( t.constructor == Array || t.jquery )
|
239
|
+
? jQuery.inArray( a, t ) < 0
|
240
|
+
: a != t;
|
241
|
+
})
|
242
|
+
);
|
222
243
|
},
|
223
244
|
|
224
245
|
add: function(t) {
|
225
|
-
return this.pushStack( jQuery.merge(
|
226
|
-
|
246
|
+
return this.pushStack( jQuery.merge(
|
247
|
+
this.get(),
|
248
|
+
t.constructor == String ?
|
249
|
+
jQuery(t).get() :
|
250
|
+
t.length != undefined && (!t.nodeName || t.nodeName == "FORM") ?
|
251
|
+
t : [t] )
|
252
|
+
);
|
227
253
|
},
|
228
254
|
is: function(expr) {
|
229
|
-
return expr ? jQuery.
|
255
|
+
return expr ? jQuery.multiFilter(expr,this).length > 0 : false;
|
256
|
+
},
|
257
|
+
|
258
|
+
val: function( val ) {
|
259
|
+
return val == undefined ?
|
260
|
+
( this.length ? this[0].value : null ) :
|
261
|
+
this.attr( "value", val );
|
262
|
+
},
|
263
|
+
|
264
|
+
html: function( val ) {
|
265
|
+
return val == undefined ?
|
266
|
+
( this.length ? this[0].innerHTML : null ) :
|
267
|
+
this.empty().append( val );
|
230
268
|
},
|
231
269
|
domManip: function(args, table, dir, fn){
|
232
|
-
var clone = this.
|
233
|
-
var a = jQuery.clean(args);
|
270
|
+
var clone = this.length > 1, a;
|
234
271
|
|
235
272
|
return this.each(function(){
|
273
|
+
if ( !a ) {
|
274
|
+
a = jQuery.clean(args, this.ownerDocument);
|
275
|
+
if ( dir < 0 )
|
276
|
+
a.reverse();
|
277
|
+
}
|
278
|
+
|
236
279
|
var obj = this;
|
237
280
|
|
238
|
-
if ( table &&
|
239
|
-
|
281
|
+
if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") )
|
282
|
+
obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
|
240
283
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
} else
|
245
|
-
obj = tbody[0];
|
246
|
-
}
|
284
|
+
jQuery.each( a, function(){
|
285
|
+
fn.apply( obj, [ clone ? this.cloneNode(true) : this ] );
|
286
|
+
});
|
247
287
|
|
248
|
-
for ( var i = ( dir < 0 ? a.length - 1 : 0 );
|
249
|
-
i != ( dir < 0 ? dir : a.length ); i += dir ) {
|
250
|
-
fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );
|
251
|
-
}
|
252
288
|
});
|
253
|
-
}
|
254
|
-
|
255
|
-
var fn = args && args[args.length-1];
|
256
|
-
var fn2 = args && args[args.length-2];
|
257
|
-
|
258
|
-
if ( fn && fn.constructor != Function ) fn = null;
|
259
|
-
if ( fn2 && fn2.constructor != Function ) fn2 = null;
|
260
|
-
|
261
|
-
if ( !fn ) {
|
262
|
-
if ( !this.stack ) this.stack = [];
|
263
|
-
this.stack.push( this.get() );
|
264
|
-
this.get( a );
|
265
|
-
} else {
|
266
|
-
var old = this.get();
|
267
|
-
this.get( a );
|
289
|
+
}
|
290
|
+
};
|
268
291
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
this.get( old ).each( fn );
|
273
|
-
}
|
292
|
+
jQuery.extend = jQuery.fn.extend = function() {
|
293
|
+
// copy reference to target object
|
294
|
+
var target = arguments[0], a = 1;
|
274
295
|
|
275
|
-
|
296
|
+
// extend jQuery itself if only one argument is passed
|
297
|
+
if ( arguments.length == 1 ) {
|
298
|
+
target = this;
|
299
|
+
a = 0;
|
276
300
|
}
|
277
|
-
|
301
|
+
var prop;
|
302
|
+
while ( (prop = arguments[a++]) != null )
|
303
|
+
// Extend the base object
|
304
|
+
for ( var i in prop ) target[i] = prop[i];
|
278
305
|
|
279
|
-
|
280
|
-
|
281
|
-
for ( var i in prop ) obj[i] = prop[i];
|
282
|
-
return obj;
|
306
|
+
// Return the modified object
|
307
|
+
return target;
|
283
308
|
};
|
284
309
|
|
285
310
|
jQuery.extend({
|
286
|
-
|
287
|
-
jQuery.
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
var ret = jQuery.map(this,n);
|
292
|
-
if ( a && a.constructor == String )
|
293
|
-
ret = jQuery.filter(a,ret).r;
|
294
|
-
return this.pushStack( ret, arguments );
|
295
|
-
};
|
296
|
-
});
|
297
|
-
|
298
|
-
jQuery.each( jQuery.macros.to, function(i,n){
|
299
|
-
jQuery.fn[ i ] = function(){
|
300
|
-
var a = arguments;
|
301
|
-
return this.each(function(){
|
302
|
-
for ( var j = 0; j < a.length; j++ )
|
303
|
-
jQuery(a[j])[n]( this );
|
304
|
-
});
|
305
|
-
};
|
306
|
-
});
|
307
|
-
|
308
|
-
jQuery.each( jQuery.macros.each, function(i,n){
|
309
|
-
jQuery.fn[ i ] = function() {
|
310
|
-
return this.each( n, arguments );
|
311
|
-
};
|
312
|
-
});
|
313
|
-
|
314
|
-
jQuery.each( jQuery.macros.filter, function(i,n){
|
315
|
-
jQuery.fn[ n ] = function(num,fn) {
|
316
|
-
return this.filter( ":" + n + "(" + num + ")", fn );
|
317
|
-
};
|
318
|
-
});
|
319
|
-
|
320
|
-
jQuery.each( jQuery.macros.attr, function(i,n){
|
321
|
-
n = n || i;
|
322
|
-
jQuery.fn[ i ] = function(h) {
|
323
|
-
return h == undefined ?
|
324
|
-
this.length ? this[0][n] : null :
|
325
|
-
this.attr( n, h );
|
326
|
-
};
|
327
|
-
});
|
311
|
+
noConflict: function() {
|
312
|
+
if ( jQuery._$ )
|
313
|
+
$ = jQuery._$;
|
314
|
+
return jQuery;
|
315
|
+
},
|
328
316
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
317
|
+
// This may seem like some crazy code, but trust me when I say that this
|
318
|
+
// is the only cross-browser way to do this. --John
|
319
|
+
isFunction: function( fn ) {
|
320
|
+
return !!fn && typeof fn != "string" && !fn.nodeName &&
|
321
|
+
fn.constructor != Array && /function/i.test( fn + "" );
|
322
|
+
},
|
323
|
+
|
324
|
+
// check if an element is in a XML document
|
325
|
+
isXMLDoc: function(elem) {
|
326
|
+
return elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
|
327
|
+
},
|
336
328
|
|
329
|
+
nodeName: function( elem, name ) {
|
330
|
+
return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
|
337
331
|
},
|
332
|
+
// args is for internal usage only
|
338
333
|
each: function( obj, fn, args ) {
|
339
334
|
if ( obj.length == undefined )
|
340
335
|
for ( var i in obj )
|
341
336
|
fn.apply( obj[i], args || [i, obj[i]] );
|
342
337
|
else
|
343
|
-
for ( var i = 0
|
344
|
-
fn.apply( obj[i], args || [i, obj[i]] );
|
338
|
+
for ( var i = 0, ol = obj.length; i < ol; i++ )
|
339
|
+
if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
|
345
340
|
return obj;
|
346
341
|
},
|
342
|
+
|
343
|
+
prop: function(elem, value, type, index, prop){
|
344
|
+
// Handle executable functions
|
345
|
+
if ( jQuery.isFunction( value ) )
|
346
|
+
value = value.call( elem, [index] );
|
347
|
+
|
348
|
+
// exclude the following css properties to add px
|
349
|
+
var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
|
350
|
+
|
351
|
+
// Handle passing in a number to a CSS property
|
352
|
+
return value && value.constructor == Number && type == "curCSS" && !exclude.test(prop) ?
|
353
|
+
value + "px" :
|
354
|
+
value;
|
355
|
+
},
|
347
356
|
|
348
357
|
className: {
|
349
|
-
|
350
|
-
|
351
|
-
|
358
|
+
// internal only, use addClass("class")
|
359
|
+
add: function( elem, c ){
|
360
|
+
jQuery.each( c.split(/\s+/), function(i, cur){
|
361
|
+
if ( !jQuery.className.has( elem.className, cur ) )
|
362
|
+
elem.className += ( elem.className ? " " : "" ) + cur;
|
363
|
+
});
|
352
364
|
},
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
classes.splice(i, 1);
|
361
|
-
break;
|
362
|
-
}
|
363
|
-
}
|
364
|
-
o.className = classes.join(' ');
|
365
|
-
}
|
365
|
+
|
366
|
+
// internal only, use removeClass("class")
|
367
|
+
remove: function( elem, c ){
|
368
|
+
elem.className = c != undefined ?
|
369
|
+
jQuery.grep( elem.className.split(/\s+/), function(cur){
|
370
|
+
return !jQuery.className.has( c, cur );
|
371
|
+
}).join(" ") : "";
|
366
372
|
},
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
return
|
373
|
+
|
374
|
+
// internal only, use is(".class")
|
375
|
+
has: function( t, c ) {
|
376
|
+
return jQuery.inArray( c, (t.className || t).toString().split(/\s+/) ) > -1;
|
371
377
|
}
|
372
378
|
},
|
373
379
|
swap: function(e,o,f) {
|
@@ -384,28 +390,30 @@ jQuery.extend({
|
|
384
390
|
if ( p == "height" || p == "width" ) {
|
385
391
|
var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
|
386
392
|
|
387
|
-
|
388
|
-
old["padding" +
|
389
|
-
old["border" +
|
390
|
-
}
|
393
|
+
jQuery.each( d, function(){
|
394
|
+
old["padding" + this] = 0;
|
395
|
+
old["border" + this + "Width"] = 0;
|
396
|
+
});
|
391
397
|
|
392
398
|
jQuery.swap( e, old, function() {
|
393
|
-
if (jQuery
|
399
|
+
if ( jQuery(e).is(':visible') ) {
|
394
400
|
oHeight = e.offsetHeight;
|
395
401
|
oWidth = e.offsetWidth;
|
396
402
|
} else {
|
397
|
-
e = jQuery(e.cloneNode(true))
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
+
e = jQuery(e.cloneNode(true))
|
404
|
+
.find(":radio").removeAttr("checked").end()
|
405
|
+
.css({
|
406
|
+
visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
|
407
|
+
}).appendTo(e.parentNode)[0];
|
408
|
+
|
409
|
+
var parPos = jQuery.css(e.parentNode,"position") || "static";
|
410
|
+
if ( parPos == "static" )
|
403
411
|
e.parentNode.style.position = "relative";
|
404
412
|
|
405
413
|
oHeight = e.clientHeight;
|
406
414
|
oWidth = e.clientWidth;
|
407
415
|
|
408
|
-
if ( parPos == "
|
416
|
+
if ( parPos == "static" )
|
409
417
|
e.parentNode.style.position = "static";
|
410
418
|
|
411
419
|
e.parentNode.removeChild(e);
|
@@ -420,434 +428,218 @@ jQuery.extend({
|
|
420
428
|
|
421
429
|
curCSS: function(elem, prop, force) {
|
422
430
|
var ret;
|
423
|
-
|
424
|
-
if (prop == 'opacity' && jQuery.browser.msie)
|
425
|
-
return jQuery.attr(elem.style, 'opacity');
|
426
431
|
|
427
|
-
if (
|
432
|
+
if (prop == "opacity" && jQuery.browser.msie) {
|
433
|
+
ret = jQuery.attr(elem.style, "opacity");
|
434
|
+
return ret == "" ? "1" : ret;
|
435
|
+
}
|
436
|
+
|
437
|
+
if (prop.match(/float/i))
|
438
|
+
prop = jQuery.styleFloat;
|
428
439
|
|
440
|
+
if (!force && elem.style[prop])
|
429
441
|
ret = elem.style[prop];
|
430
442
|
|
431
|
-
|
432
|
-
|
433
|
-
var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
|
434
|
-
ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
|
443
|
+
else if (document.defaultView && document.defaultView.getComputedStyle) {
|
435
444
|
|
436
|
-
|
445
|
+
if (prop.match(/float/i))
|
446
|
+
prop = "float";
|
437
447
|
|
438
448
|
prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
|
439
449
|
var cur = document.defaultView.getComputedStyle(elem, null);
|
440
450
|
|
441
451
|
if ( cur )
|
442
452
|
ret = cur.getPropertyValue(prop);
|
443
|
-
else if ( prop ==
|
444
|
-
ret =
|
453
|
+
else if ( prop == "display" )
|
454
|
+
ret = "none";
|
445
455
|
else
|
446
|
-
jQuery.swap(elem, { display:
|
447
|
-
|
456
|
+
jQuery.swap(elem, { display: "block" }, function() {
|
457
|
+
var c = document.defaultView.getComputedStyle(this, "");
|
458
|
+
ret = c && c.getPropertyValue(prop) || "";
|
448
459
|
});
|
449
460
|
|
461
|
+
} else if (elem.currentStyle) {
|
462
|
+
var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
|
463
|
+
ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
|
450
464
|
}
|
451
465
|
|
452
466
|
return ret;
|
453
467
|
},
|
454
|
-
|
455
|
-
clean: function(a) {
|
468
|
+
|
469
|
+
clean: function(a, doc) {
|
456
470
|
var r = [];
|
457
|
-
|
458
|
-
if ( a[i].constructor == String ) {
|
459
|
-
// trim whitespace, otherwise indexOf won't work as expected
|
460
|
-
a[i] = jQuery.trim(a[i]);
|
461
|
-
|
462
|
-
var table = "";
|
463
|
-
|
464
|
-
if ( !a[i].indexOf("<thead") || !a[i].indexOf("<tbody") ) {
|
465
|
-
table = "thead";
|
466
|
-
a[i] = "<table>" + a[i] + "</table>";
|
467
|
-
} else if ( !a[i].indexOf("<tr") ) {
|
468
|
-
table = "tr";
|
469
|
-
a[i] = "<table>" + a[i] + "</table>";
|
470
|
-
} else if ( !a[i].indexOf("<td") || !a[i].indexOf("<th") ) {
|
471
|
-
table = "td";
|
472
|
-
a[i] = "<table><tbody><tr>" + a[i] + "</tr></tbody></table>";
|
473
|
-
}
|
474
|
-
|
475
|
-
var div = document.createElement("div");
|
476
|
-
div.innerHTML = a[i];
|
477
|
-
|
478
|
-
if ( table ) {
|
479
|
-
div = div.firstChild;
|
480
|
-
if ( table != "thead" ) div = div.firstChild;
|
481
|
-
if ( table == "td" ) div = div.firstChild;
|
482
|
-
}
|
483
|
-
|
484
|
-
for ( var j = 0; j < div.childNodes.length; j++ )
|
485
|
-
r.push( div.childNodes[j] );
|
486
|
-
} else if ( a[i].jquery || a[i].length && !a[i].nodeType )
|
487
|
-
for ( var k = 0; k < a[i].length; k++ )
|
488
|
-
r.push( a[i][k] );
|
489
|
-
else if ( a[i] !== null )
|
490
|
-
r.push( a[i].nodeType ? a[i] : document.createTextNode(a[i].toString()) );
|
491
|
-
}
|
492
|
-
return r;
|
493
|
-
},
|
494
|
-
|
495
|
-
expr: {
|
496
|
-
"": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
|
497
|
-
"#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]",
|
498
|
-
":": {
|
499
|
-
// Position Checks
|
500
|
-
lt: "i<m[3]-0",
|
501
|
-
gt: "i>m[3]-0",
|
502
|
-
nth: "m[3]-0==i",
|
503
|
-
eq: "m[3]-0==i",
|
504
|
-
first: "i==0",
|
505
|
-
last: "i==r.length-1",
|
506
|
-
even: "i%2==0",
|
507
|
-
odd: "i%2",
|
508
|
-
|
509
|
-
// Child Checks
|
510
|
-
"nth-child": "jQuery.sibling(a,m[3]).cur",
|
511
|
-
"first-child": "jQuery.sibling(a,0).cur",
|
512
|
-
"last-child": "jQuery.sibling(a,0).last",
|
513
|
-
"only-child": "jQuery.sibling(a).length==1",
|
514
|
-
|
515
|
-
// Parent Checks
|
516
|
-
parent: "a.childNodes.length",
|
517
|
-
empty: "!a.childNodes.length",
|
518
|
-
|
519
|
-
// Text Check
|
520
|
-
contains: "(a.innerText||a.innerHTML).indexOf(m[3])>=0",
|
521
|
-
|
522
|
-
// Visibility
|
523
|
-
visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
|
524
|
-
hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",
|
525
|
-
|
526
|
-
// Form attributes
|
527
|
-
enabled: "!a.disabled",
|
528
|
-
disabled: "a.disabled",
|
529
|
-
checked: "a.checked",
|
530
|
-
selected: "a.selected || jQuery.attr(a, 'selected')",
|
531
|
-
|
532
|
-
// Form elements
|
533
|
-
text: "a.type=='text'",
|
534
|
-
radio: "a.type=='radio'",
|
535
|
-
checkbox: "a.type=='checkbox'",
|
536
|
-
file: "a.type=='file'",
|
537
|
-
password: "a.type=='password'",
|
538
|
-
submit: "a.type=='submit'",
|
539
|
-
image: "a.type=='image'",
|
540
|
-
reset: "a.type=='reset'",
|
541
|
-
button: "a.type=='button'",
|
542
|
-
input: "a.nodeName.toLowerCase().match(/input|select|textarea|button/)"
|
543
|
-
},
|
544
|
-
".": "jQuery.className.has(a,m[2])",
|
545
|
-
"@": {
|
546
|
-
"=": "z==m[4]",
|
547
|
-
"!=": "z!=m[4]",
|
548
|
-
"^=": "z && !z.indexOf(m[4])",
|
549
|
-
"$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]",
|
550
|
-
"*=": "z && z.indexOf(m[4])>=0",
|
551
|
-
"": "z"
|
552
|
-
},
|
553
|
-
"[": "jQuery.find(m[2],a).length"
|
554
|
-
},
|
471
|
+
doc = doc || document;
|
555
472
|
|
556
|
-
|
557
|
-
|
558
|
-
">|/", "jQuery.sibling(a.firstChild)",
|
559
|
-
"\\+", "jQuery.sibling(a).next",
|
560
|
-
"~", function(a){
|
561
|
-
var r = [];
|
562
|
-
var s = jQuery.sibling(a);
|
563
|
-
if ( s.n > 0 )
|
564
|
-
for ( var i = s.n; i < s.length; i++ )
|
565
|
-
r.push( s[i] );
|
566
|
-
return r;
|
567
|
-
}
|
568
|
-
],
|
569
|
-
find: function( t, context ) {
|
570
|
-
// Make sure that the context is a DOM Element
|
571
|
-
if ( context && context.nodeType == undefined )
|
572
|
-
context = null;
|
573
|
-
|
574
|
-
// Set the correct context (if none is provided)
|
575
|
-
context = context || jQuery.context || document;
|
576
|
-
|
577
|
-
if ( t.constructor != String ) return [t];
|
578
|
-
|
579
|
-
if ( !t.indexOf("//") ) {
|
580
|
-
context = context.documentElement;
|
581
|
-
t = t.substr(2,t.length);
|
582
|
-
} else if ( !t.indexOf("/") ) {
|
583
|
-
context = context.documentElement;
|
584
|
-
t = t.substr(1,t.length);
|
585
|
-
// FIX Assume the root element is right :(
|
586
|
-
if ( t.indexOf("/") >= 1 )
|
587
|
-
t = t.substr(t.indexOf("/"),t.length);
|
588
|
-
}
|
589
|
-
|
590
|
-
var ret = [context];
|
591
|
-
var done = [];
|
592
|
-
var last = null;
|
593
|
-
|
594
|
-
while ( t.length > 0 && last != t ) {
|
595
|
-
var r = [];
|
596
|
-
last = t;
|
597
|
-
|
598
|
-
t = jQuery.trim(t).replace( /^\/\//i, "" );
|
599
|
-
|
600
|
-
var foundToken = false;
|
601
|
-
|
602
|
-
for ( var i = 0; i < jQuery.token.length; i += 2 ) {
|
603
|
-
if ( foundToken ) continue;
|
473
|
+
jQuery.each( a, function(i,arg){
|
474
|
+
if ( !arg ) return;
|
604
475
|
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
476
|
+
if ( arg.constructor == Number )
|
477
|
+
arg = arg.toString();
|
478
|
+
|
479
|
+
// Convert html string into DOM nodes
|
480
|
+
if ( typeof arg == "string" ) {
|
481
|
+
// Trim whitespace, otherwise indexOf won't work as expected
|
482
|
+
var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb = [];
|
483
|
+
|
484
|
+
var wrap =
|
485
|
+
// option or optgroup
|
486
|
+
!s.indexOf("<opt") &&
|
487
|
+
[1, "<select>", "</select>"] ||
|
488
|
+
|
489
|
+
!s.indexOf("<leg") &&
|
490
|
+
[1, "<fieldset>", "</fieldset>"] ||
|
491
|
+
|
492
|
+
(!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot") || !s.indexOf("<colg")) &&
|
493
|
+
[1, "<table>", "</table>"] ||
|
494
|
+
|
495
|
+
!s.indexOf("<tr") &&
|
496
|
+
[2, "<table><tbody>", "</tbody></table>"] ||
|
497
|
+
|
498
|
+
// <thead> matched above
|
499
|
+
(!s.indexOf("<td") || !s.indexOf("<th")) &&
|
500
|
+
[3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
|
501
|
+
|
502
|
+
!s.indexOf("<col") &&
|
503
|
+
[2, "<table><colgroup>", "</colgroup></table>"] ||
|
504
|
+
|
505
|
+
[0,"",""];
|
614
506
|
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
507
|
+
// Go to html and back, then peel off extra wrappers
|
508
|
+
div.innerHTML = wrap[1] + arg + wrap[2];
|
509
|
+
|
510
|
+
// Move to the right depth
|
511
|
+
while ( wrap[0]-- )
|
512
|
+
div = div.firstChild;
|
513
|
+
|
514
|
+
// Remove IE's autoinserted <tbody> from table fragments
|
515
|
+
if ( jQuery.browser.msie ) {
|
516
|
+
|
517
|
+
// String was a <table>, *may* have spurious <tbody>
|
518
|
+
if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 )
|
519
|
+
tb = div.firstChild && div.firstChild.childNodes;
|
520
|
+
|
521
|
+
// String was a bare <thead> or <tfoot>
|
522
|
+
else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
|
523
|
+
tb = div.childNodes;
|
624
524
|
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
t = t.replace( re2, "" );
|
630
|
-
} else {
|
631
|
-
if ( !m[2] || m[1] == "." ) m[2] = "*";
|
632
|
-
|
633
|
-
for ( var i = 0; i < ret.length; i++ )
|
634
|
-
r = jQuery.merge( r,
|
635
|
-
m[2] == "*" ?
|
636
|
-
jQuery.getAll(ret[i]) :
|
637
|
-
ret[i].getElementsByTagName(m[2])
|
638
|
-
);
|
639
|
-
}
|
525
|
+
for ( var n = tb.length-1; n >= 0 ; --n )
|
526
|
+
if ( jQuery.nodeName(tb[n], "tbody") && !tb[n].childNodes.length )
|
527
|
+
tb[n].parentNode.removeChild(tb[n]);
|
528
|
+
|
640
529
|
}
|
641
|
-
|
530
|
+
|
531
|
+
arg = jQuery.makeArray( div.childNodes );
|
642
532
|
}
|
643
533
|
|
644
|
-
if (
|
645
|
-
|
646
|
-
ret = r = val.r;
|
647
|
-
t = jQuery.trim(val.t);
|
648
|
-
}
|
649
|
-
}
|
534
|
+
if ( 0 === arg.length && (!jQuery.nodeName(arg, "form") && !jQuery.nodeName(arg, "select")) )
|
535
|
+
return;
|
650
536
|
|
651
|
-
|
652
|
-
|
537
|
+
if ( arg[0] == undefined || jQuery.nodeName(arg, "form") || arg.options )
|
538
|
+
r.push( arg );
|
539
|
+
else
|
540
|
+
r = jQuery.merge( r, arg );
|
653
541
|
|
654
|
-
|
655
|
-
},
|
542
|
+
});
|
656
543
|
|
657
|
-
getAll: function(o,r) {
|
658
|
-
r = r || [];
|
659
|
-
var s = o.childNodes;
|
660
|
-
for ( var i = 0; i < s.length; i++ )
|
661
|
-
if ( s[i].nodeType == 1 ) {
|
662
|
-
r.push( s[i] );
|
663
|
-
jQuery.getAll( s[i], r );
|
664
|
-
}
|
665
544
|
return r;
|
666
545
|
},
|
667
|
-
|
546
|
+
|
668
547
|
attr: function(elem, name, value){
|
669
|
-
var fix = {
|
670
|
-
"for": "htmlFor",
|
671
|
-
"class": "className",
|
672
|
-
"float": "cssFloat",
|
673
|
-
innerHTML: "innerHTML",
|
674
|
-
className: "className",
|
675
|
-
value: "value",
|
676
|
-
disabled: "disabled",
|
677
|
-
checked: "checked"
|
678
|
-
};
|
679
|
-
|
680
|
-
// IE actually uses filters for opacity ... elem is actually elem.style
|
681
|
-
if (name == "opacity" && jQuery.browser.msie && value != undefined) {
|
682
|
-
// IE has trouble with opacity if it does not have layout
|
683
|
-
// Would prefer to check element.hasLayout first but don't have access to the element here
|
684
|
-
elem['zoom'] = 1;
|
685
|
-
if (value == 1) // Remove filter to avoid more IE weirdness
|
686
|
-
return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"");
|
687
|
-
else
|
688
|
-
return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"") + "alpha(opacity=" + value * 100 + ")";
|
689
|
-
} else if (name == "opacity" && jQuery.browser.msie) {
|
690
|
-
return elem["filter"] ? parseFloat( elem["filter"].match(/alpha\(opacity=(.*)\)/)[1] )/100 : 1;
|
691
|
-
}
|
548
|
+
var fix = jQuery.isXMLDoc(elem) ? {} : jQuery.props;
|
692
549
|
|
693
|
-
//
|
694
|
-
if (name == "opacity" && jQuery.browser.mozilla && value == 1) value = 0.9999;
|
695
|
-
|
550
|
+
// Certain attributes only work when accessed via the old DOM 0 way
|
696
551
|
if ( fix[name] ) {
|
697
552
|
if ( value != undefined ) elem[fix[name]] = value;
|
698
553
|
return elem[fix[name]];
|
699
|
-
|
554
|
+
|
555
|
+
} else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName(elem, "form") && (name == "action" || name == "method") )
|
700
556
|
return elem.getAttributeNode(name).nodeValue;
|
701
|
-
|
557
|
+
|
558
|
+
// IE elem.getAttribute passes even for style
|
559
|
+
else if ( elem.tagName ) {
|
560
|
+
|
561
|
+
|
702
562
|
if ( value != undefined ) elem.setAttribute( name, value );
|
703
|
-
|
563
|
+
if ( jQuery.browser.msie && /href|src/.test(name) && !jQuery.isXMLDoc(elem) )
|
564
|
+
return elem.getAttribute( name, 2 );
|
565
|
+
return elem.getAttribute( name );
|
566
|
+
|
567
|
+
// elem is actually elem.style ... set the style
|
704
568
|
} else {
|
569
|
+
// IE actually uses filters for opacity
|
570
|
+
if ( name == "opacity" && jQuery.browser.msie ) {
|
571
|
+
if ( value != undefined ) {
|
572
|
+
// IE has trouble with opacity if it does not have layout
|
573
|
+
// Force it by setting the zoom level
|
574
|
+
elem.zoom = 1;
|
575
|
+
|
576
|
+
// Set the alpha filter to set the opacity
|
577
|
+
elem.filter = (elem.filter || "").replace(/alpha\([^)]*\)/,"") +
|
578
|
+
(parseFloat(value).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
|
579
|
+
}
|
580
|
+
|
581
|
+
return elem.filter ?
|
582
|
+
(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : "";
|
583
|
+
}
|
705
584
|
name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
|
706
585
|
if ( value != undefined ) elem[name] = value;
|
707
586
|
return elem[name];
|
708
587
|
}
|
709
588
|
},
|
589
|
+
trim: function(t){
|
590
|
+
return t.replace(/^\s+|\s+$/g, "");
|
591
|
+
},
|
710
592
|
|
711
|
-
|
712
|
-
|
713
|
-
// Match: [@value='test'], [@foo]
|
714
|
-
"\\[ *(@)S *([!*$^=]*) *('?\"?)(.*?)\\4 *\\]",
|
715
|
-
|
716
|
-
// Match: [div], [div p]
|
717
|
-
"(\\[)\s*(.*?)\s*\\]",
|
593
|
+
makeArray: function( a ) {
|
594
|
+
var r = [];
|
718
595
|
|
719
|
-
//
|
720
|
-
|
596
|
+
// Need to use typeof to fight Safari childNodes crashes
|
597
|
+
if ( typeof a != "array" )
|
598
|
+
for ( var i = 0, al = a.length; i < al; i++ )
|
599
|
+
r.push( a[i] );
|
600
|
+
else
|
601
|
+
r = a.slice( 0 );
|
721
602
|
|
722
|
-
|
723
|
-
|
724
|
-
],
|
603
|
+
return r;
|
604
|
+
},
|
725
605
|
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
|
732
|
-
|
733
|
-
var p = jQuery.parse;
|
734
|
-
|
735
|
-
for ( var i = 0; i < p.length; i++ ) {
|
736
|
-
|
737
|
-
// Look for, and replace, string-like sequences
|
738
|
-
// and finally build a regexp out of it
|
739
|
-
var re = new RegExp(
|
740
|
-
"^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" );
|
741
|
-
|
742
|
-
var m = re.exec( t );
|
743
|
-
|
744
|
-
if ( m ) {
|
745
|
-
// Re-organize the first match
|
746
|
-
if ( !i )
|
747
|
-
m = ["",m[1], m[3], m[2], m[5]];
|
748
|
-
|
749
|
-
// Remove what we just matched
|
750
|
-
t = t.replace( re, "" );
|
751
|
-
|
752
|
-
break;
|
753
|
-
}
|
754
|
-
}
|
755
|
-
|
756
|
-
// :not() is a special case that can be optimized by
|
757
|
-
// keeping it out of the expression list
|
758
|
-
if ( m[1] == ":" && m[2] == "not" )
|
759
|
-
r = jQuery.filter(m[3],r,false).r;
|
760
|
-
|
761
|
-
// Otherwise, find the expression to execute
|
762
|
-
else {
|
763
|
-
var f = jQuery.expr[m[1]];
|
764
|
-
if ( f.constructor != String )
|
765
|
-
f = jQuery.expr[m[1]][m[2]];
|
766
|
-
|
767
|
-
// Build a custom macro to enclose it
|
768
|
-
eval("f = function(a,i){" +
|
769
|
-
( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) +
|
770
|
-
"return " + f + "}");
|
771
|
-
|
772
|
-
// Execute it against the current filter
|
773
|
-
r = g( r, f );
|
774
|
-
}
|
775
|
-
}
|
776
|
-
|
777
|
-
// Return an array of filtered elements (r)
|
778
|
-
// and the modified expression string (t)
|
779
|
-
return { r: r, t: t };
|
780
|
-
},
|
781
|
-
trim: function(t){
|
782
|
-
return t.replace(/^\s+|\s+$/g, "");
|
606
|
+
inArray: function( b, a ) {
|
607
|
+
for ( var i = 0, al = a.length; i < al; i++ )
|
608
|
+
if ( a[i] == b )
|
609
|
+
return i;
|
610
|
+
return -1;
|
783
611
|
},
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
var
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
for ( var i = 0; i < siblings.length; i++ ) {
|
799
|
-
if ( not === true && siblings[i] == elem ) continue;
|
800
|
-
|
801
|
-
if ( siblings[i].nodeType == 1 )
|
802
|
-
elems.push( siblings[i] );
|
803
|
-
if ( siblings[i] == elem )
|
804
|
-
elems.n = elems.length - 1;
|
612
|
+
merge: function(first, second) {
|
613
|
+
// We have to loop this way because IE & Opera overwrite the length
|
614
|
+
// expando of getElementsByTagName
|
615
|
+
for ( var i = 0; second[i]; i++ )
|
616
|
+
first.push(second[i]);
|
617
|
+
return first;
|
618
|
+
},
|
619
|
+
unique: function(first) {
|
620
|
+
var r = [], num = jQuery.mergeNum++;
|
621
|
+
|
622
|
+
for ( var i = 0, fl = first.length; i < fl; i++ )
|
623
|
+
if ( num != first[i].mergeNum ) {
|
624
|
+
first[i].mergeNum = num;
|
625
|
+
r.push(first[i]);
|
805
626
|
}
|
806
|
-
}
|
807
627
|
|
808
|
-
return
|
809
|
-
last: elems.n == elems.length - 1,
|
810
|
-
cur: pos == "even" && elems.n % 2 == 0 || pos == "odd" && elems.n % 2 || elems[pos] == elem,
|
811
|
-
prev: elems[elems.n - 1],
|
812
|
-
next: elems[elems.n + 1]
|
813
|
-
});
|
628
|
+
return r;
|
814
629
|
},
|
815
|
-
merge: function(first, second) {
|
816
|
-
var result = [];
|
817
630
|
|
818
|
-
|
819
|
-
// StaticNodeList instances)
|
820
|
-
for ( var k = 0; k < first.length; k++ )
|
821
|
-
result[k] = first[k];
|
822
|
-
|
823
|
-
// Now check for duplicates between a and b and only
|
824
|
-
// add the unique items
|
825
|
-
for ( var i = 0; i < second.length; i++ ) {
|
826
|
-
var noCollision = true;
|
827
|
-
|
828
|
-
// The collision-checking process
|
829
|
-
for ( var j = 0; j < first.length; j++ )
|
830
|
-
if ( second[i] == first[j] )
|
831
|
-
noCollision = false;
|
832
|
-
|
833
|
-
// If the item is unique, add it
|
834
|
-
if ( noCollision )
|
835
|
-
result.push( second[i] );
|
836
|
-
}
|
837
|
-
|
838
|
-
return result;
|
839
|
-
},
|
631
|
+
mergeNum: 0,
|
840
632
|
grep: function(elems, fn, inv) {
|
841
633
|
// If a string is passed in for the function, make a function
|
842
634
|
// for it (a handy shortcut)
|
843
|
-
if ( fn
|
635
|
+
if ( typeof fn == "string" )
|
844
636
|
fn = new Function("a","i","return " + fn);
|
845
637
|
|
846
638
|
var result = [];
|
847
639
|
|
848
640
|
// Go through the array, only saving the items
|
849
641
|
// that pass the validator function
|
850
|
-
for ( var i = 0
|
642
|
+
for ( var i = 0, el = elems.length; i < el; i++ )
|
851
643
|
if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
|
852
644
|
result.push( elems[i] );
|
853
645
|
|
@@ -856,295 +648,866 @@ jQuery.extend({
|
|
856
648
|
map: function(elems, fn) {
|
857
649
|
// If a string is passed in for the function, make a function
|
858
650
|
// for it (a handy shortcut)
|
859
|
-
if ( fn
|
651
|
+
if ( typeof fn == "string" )
|
860
652
|
fn = new Function("a","return " + fn);
|
861
653
|
|
862
654
|
var result = [];
|
863
655
|
|
864
656
|
// Go through the array, translating each of the items to their
|
865
657
|
// new value (or values).
|
866
|
-
for ( var i = 0
|
658
|
+
for ( var i = 0, el = elems.length; i < el; i++ ) {
|
867
659
|
var val = fn(elems[i],i);
|
868
660
|
|
869
661
|
if ( val !== null && val != undefined ) {
|
870
662
|
if ( val.constructor != Array ) val = [val];
|
871
|
-
result =
|
663
|
+
result = result.concat( val );
|
872
664
|
}
|
873
665
|
}
|
874
666
|
|
875
667
|
return result;
|
668
|
+
}
|
669
|
+
});
|
670
|
+
|
671
|
+
/*
|
672
|
+
* Whether the W3C compliant box model is being used.
|
673
|
+
*
|
674
|
+
* @property
|
675
|
+
* @name $.boxModel
|
676
|
+
* @type Boolean
|
677
|
+
* @cat JavaScript
|
678
|
+
*/
|
679
|
+
new function() {
|
680
|
+
var b = navigator.userAgent.toLowerCase();
|
681
|
+
|
682
|
+
// Figure out what browser is being used
|
683
|
+
jQuery.browser = {
|
684
|
+
version: (b.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
|
685
|
+
safari: /webkit/.test(b),
|
686
|
+
opera: /opera/.test(b),
|
687
|
+
msie: /msie/.test(b) && !/opera/.test(b),
|
688
|
+
mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
|
689
|
+
};
|
690
|
+
|
691
|
+
// Check to see if the W3C box model is being used
|
692
|
+
jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
|
693
|
+
|
694
|
+
jQuery.styleFloat = jQuery.browser.msie ? "styleFloat" : "cssFloat",
|
695
|
+
|
696
|
+
jQuery.props = {
|
697
|
+
"for": "htmlFor",
|
698
|
+
"class": "className",
|
699
|
+
"float": jQuery.styleFloat,
|
700
|
+
cssFloat: jQuery.styleFloat,
|
701
|
+
styleFloat: jQuery.styleFloat,
|
702
|
+
innerHTML: "innerHTML",
|
703
|
+
className: "className",
|
704
|
+
value: "value",
|
705
|
+
disabled: "disabled",
|
706
|
+
checked: "checked",
|
707
|
+
readonly: "readOnly",
|
708
|
+
selected: "selected",
|
709
|
+
maxlength: "maxLength"
|
710
|
+
};
|
711
|
+
};
|
712
|
+
|
713
|
+
jQuery.each({
|
714
|
+
parent: "a.parentNode",
|
715
|
+
parents: "jQuery.parents(a)",
|
716
|
+
next: "jQuery.nth(a,2,'nextSibling')",
|
717
|
+
prev: "jQuery.nth(a,2,'previousSibling')",
|
718
|
+
siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
|
719
|
+
children: "jQuery.sibling(a.firstChild)"
|
720
|
+
}, function(i,n){
|
721
|
+
jQuery.fn[ i ] = function(a) {
|
722
|
+
var ret = jQuery.map(this,n);
|
723
|
+
if ( a && typeof a == "string" )
|
724
|
+
ret = jQuery.multiFilter(a,ret);
|
725
|
+
return this.pushStack( ret );
|
726
|
+
};
|
727
|
+
});
|
728
|
+
|
729
|
+
jQuery.each({
|
730
|
+
appendTo: "append",
|
731
|
+
prependTo: "prepend",
|
732
|
+
insertBefore: "before",
|
733
|
+
insertAfter: "after"
|
734
|
+
}, function(i,n){
|
735
|
+
jQuery.fn[ i ] = function(){
|
736
|
+
var a = arguments;
|
737
|
+
return this.each(function(){
|
738
|
+
for ( var j = 0, al = a.length; j < al; j++ )
|
739
|
+
jQuery(a[j])[n]( this );
|
740
|
+
});
|
741
|
+
};
|
742
|
+
});
|
743
|
+
|
744
|
+
jQuery.each( {
|
745
|
+
removeAttr: function( key ) {
|
746
|
+
jQuery.attr( this, key, "" );
|
747
|
+
this.removeAttribute( key );
|
748
|
+
},
|
749
|
+
addClass: function(c){
|
750
|
+
jQuery.className.add(this,c);
|
751
|
+
},
|
752
|
+
removeClass: function(c){
|
753
|
+
jQuery.className.remove(this,c);
|
876
754
|
},
|
755
|
+
toggleClass: function( c ){
|
756
|
+
jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
|
757
|
+
},
|
758
|
+
remove: function(a){
|
759
|
+
if ( !a || jQuery.filter( a, [this] ).r.length )
|
760
|
+
this.parentNode.removeChild( this );
|
761
|
+
},
|
762
|
+
empty: function() {
|
763
|
+
while ( this.firstChild )
|
764
|
+
this.removeChild( this.firstChild );
|
765
|
+
}
|
766
|
+
}, function(i,n){
|
767
|
+
jQuery.fn[ i ] = function() {
|
768
|
+
return this.each( n, arguments );
|
769
|
+
};
|
770
|
+
});
|
877
771
|
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
//
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
// Init the event handler queue
|
906
|
-
handlers = element.events[type] = {};
|
907
|
-
|
908
|
-
// Remember an existing handler, if it's already there
|
909
|
-
if (element["on" + type])
|
910
|
-
handlers[0] = element["on" + type];
|
911
|
-
}
|
772
|
+
jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){
|
773
|
+
jQuery.fn[ n ] = function(num,fn) {
|
774
|
+
return this.filter( ":" + n + "(" + num + ")", fn );
|
775
|
+
};
|
776
|
+
});
|
777
|
+
|
778
|
+
jQuery.each( [ "height", "width" ], function(i,n){
|
779
|
+
jQuery.fn[ n ] = function(h) {
|
780
|
+
return h == undefined ?
|
781
|
+
( this.length ? jQuery.css( this[0], n ) : null ) :
|
782
|
+
this.css( n, h.constructor == String ? h : h + "px" );
|
783
|
+
};
|
784
|
+
});
|
785
|
+
jQuery.extend({
|
786
|
+
expr: {
|
787
|
+
"": "m[2]=='*'||jQuery.nodeName(a,m[2])",
|
788
|
+
"#": "a.getAttribute('id')==m[2]",
|
789
|
+
":": {
|
790
|
+
// Position Checks
|
791
|
+
lt: "i<m[3]-0",
|
792
|
+
gt: "i>m[3]-0",
|
793
|
+
nth: "m[3]-0==i",
|
794
|
+
eq: "m[3]-0==i",
|
795
|
+
first: "i==0",
|
796
|
+
last: "i==r.length-1",
|
797
|
+
even: "i%2==0",
|
798
|
+
odd: "i%2",
|
912
799
|
|
913
|
-
//
|
914
|
-
|
800
|
+
// Child Checks
|
801
|
+
"first-child": "a.parentNode.getElementsByTagName('*')[0]==a",
|
802
|
+
"last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a",
|
803
|
+
"only-child": "!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')",
|
915
804
|
|
916
|
-
//
|
917
|
-
|
805
|
+
// Parent Checks
|
806
|
+
parent: "a.firstChild",
|
807
|
+
empty: "!a.firstChild",
|
918
808
|
|
919
|
-
//
|
920
|
-
|
921
|
-
this.global[type] = [];
|
922
|
-
this.global[type].push( element );
|
923
|
-
},
|
809
|
+
// Text Check
|
810
|
+
contains: "(a.textContent||a.innerText||'').indexOf(m[3])>=0",
|
924
811
|
|
925
|
-
|
926
|
-
|
812
|
+
// Visibility
|
813
|
+
visible: '"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
|
814
|
+
hidden: '"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',
|
927
815
|
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
816
|
+
// Form attributes
|
817
|
+
enabled: "!a.disabled",
|
818
|
+
disabled: "a.disabled",
|
819
|
+
checked: "a.checked",
|
820
|
+
selected: "a.selected||jQuery.attr(a,'selected')",
|
821
|
+
|
822
|
+
// Form elements
|
823
|
+
text: "'text'==a.type",
|
824
|
+
radio: "'radio'==a.type",
|
825
|
+
checkbox: "'checkbox'==a.type",
|
826
|
+
file: "'file'==a.type",
|
827
|
+
password: "'password'==a.type",
|
828
|
+
submit: "'submit'==a.type",
|
829
|
+
image: "'image'==a.type",
|
830
|
+
reset: "'reset'==a.type",
|
831
|
+
button: '"button"==a.type||jQuery.nodeName(a,"button")',
|
832
|
+
input: "/input|select|textarea|button/i.test(a.nodeName)"
|
940
833
|
},
|
834
|
+
"[": "jQuery.find(m[2],a).length"
|
835
|
+
},
|
836
|
+
|
837
|
+
// The regular expressions that power the parsing engine
|
838
|
+
parse: [
|
839
|
+
// Match: [@value='test'], [@foo]
|
840
|
+
/^\[ *(@)([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
|
941
841
|
|
942
|
-
|
943
|
-
|
944
|
-
data = data || [];
|
842
|
+
// Match: [div], [div p]
|
843
|
+
/^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,
|
945
844
|
|
946
|
-
|
947
|
-
|
948
|
-
var g = this.global[type];
|
949
|
-
if ( g )
|
950
|
-
for ( var i = 0; i < g.length; i++ )
|
951
|
-
this.trigger( type, data, g[i] );
|
845
|
+
// Match: :contains('foo')
|
846
|
+
/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
|
952
847
|
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
848
|
+
// Match: :even, :last-chlid, #id, .class
|
849
|
+
new RegExp("^([:.#]*)(" +
|
850
|
+
( jQuery.chars = jQuery.browser.safari && jQuery.browser.version < "3.0.0" ? "\\w" : "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)" ) + "+)")
|
851
|
+
],
|
957
852
|
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
853
|
+
multiFilter: function( expr, elems, not ) {
|
854
|
+
var old, cur = [];
|
855
|
+
|
856
|
+
while ( expr && expr != old ) {
|
857
|
+
old = expr;
|
858
|
+
var f = jQuery.filter( expr, elems, not );
|
859
|
+
expr = f.t.replace(/^\s*,\s*/, "" );
|
860
|
+
cur = not ? elems = f.r : jQuery.merge( cur, f.r );
|
861
|
+
}
|
862
|
+
|
863
|
+
return cur;
|
864
|
+
},
|
865
|
+
find: function( t, context ) {
|
866
|
+
// Quickly handle non-string expressions
|
867
|
+
if ( typeof t != "string" )
|
868
|
+
return [ t ];
|
869
|
+
|
870
|
+
// Make sure that the context is a DOM Element
|
871
|
+
if ( context && !context.nodeType )
|
872
|
+
context = null;
|
873
|
+
|
874
|
+
// Set the correct context (if none is provided)
|
875
|
+
context = context || document;
|
876
|
+
|
877
|
+
// Handle the common XPath // expression
|
878
|
+
if ( !t.indexOf("//") ) {
|
879
|
+
context = context.documentElement;
|
880
|
+
t = t.substr(2,t.length);
|
881
|
+
|
882
|
+
// And the / root expression
|
883
|
+
} else if ( !t.indexOf("/") && !context.ownerDocument ) {
|
884
|
+
context = context.documentElement;
|
885
|
+
t = t.substr(1,t.length);
|
886
|
+
if ( t.indexOf("/") >= 1 )
|
887
|
+
t = t.substr(t.indexOf("/"),t.length);
|
888
|
+
}
|
962
889
|
|
963
|
-
|
964
|
-
|
890
|
+
// Initialize the search
|
891
|
+
var ret = [context], done = [], last;
|
892
|
+
|
893
|
+
// Continue while a selector expression exists, and while
|
894
|
+
// we're no longer looping upon ourselves
|
895
|
+
while ( t && last != t ) {
|
896
|
+
var r = [];
|
897
|
+
last = t;
|
965
898
|
|
966
|
-
|
899
|
+
t = jQuery.trim(t).replace( /^\/\//, "" );
|
967
900
|
|
968
|
-
|
969
|
-
if ( !event ) return;
|
901
|
+
var foundToken = false;
|
970
902
|
|
971
|
-
|
903
|
+
// An attempt at speeding up child selectors that
|
904
|
+
// point to a specific element tag
|
905
|
+
var re = new RegExp("^[/>]\\s*(" + jQuery.chars + "+)");
|
906
|
+
var m = re.exec(t);
|
972
907
|
|
973
|
-
|
908
|
+
if ( m ) {
|
909
|
+
var nodeName = m[1].toUpperCase();
|
974
910
|
|
975
|
-
|
976
|
-
|
911
|
+
// Perform our own iteration and filter
|
912
|
+
for ( var i = 0; ret[i]; i++ )
|
913
|
+
for ( var c = ret[i].firstChild; c; c = c.nextSibling )
|
914
|
+
if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName.toUpperCase()) )
|
915
|
+
r.push( c );
|
977
916
|
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
917
|
+
ret = r;
|
918
|
+
t = t.replace( re, "" );
|
919
|
+
if ( t.indexOf(" ") == 0 ) continue;
|
920
|
+
foundToken = true;
|
921
|
+
} else {
|
922
|
+
re = /^((\/?\.\.)|([>\/+~]))\s*([a-z]*)/i;
|
923
|
+
|
924
|
+
if ( (m = re.exec(t)) != null ) {
|
925
|
+
r = [];
|
926
|
+
|
927
|
+
var nodeName = m[4], mergeNum = jQuery.mergeNum++;
|
928
|
+
m = m[1];
|
929
|
+
|
930
|
+
for ( var j = 0, rl = ret.length; j < rl; j++ )
|
931
|
+
if ( m.indexOf("..") < 0 ) {
|
932
|
+
var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
|
933
|
+
for ( ; n; n = n.nextSibling )
|
934
|
+
if ( n.nodeType == 1 ) {
|
935
|
+
if ( m == "~" && n.mergeNum == mergeNum ) break;
|
936
|
+
|
937
|
+
if (!nodeName || n.nodeName.toUpperCase() == nodeName.toUpperCase() ) {
|
938
|
+
if ( m == "~" ) n.mergeNum = mergeNum;
|
939
|
+
r.push( n );
|
940
|
+
}
|
941
|
+
|
942
|
+
if ( m == "+" ) break;
|
943
|
+
}
|
944
|
+
} else
|
945
|
+
r.push( ret[j].parentNode );
|
946
|
+
|
947
|
+
ret = r;
|
948
|
+
|
949
|
+
// And remove the token
|
950
|
+
t = jQuery.trim( t.replace( re, "" ) );
|
951
|
+
foundToken = true;
|
983
952
|
}
|
984
953
|
}
|
985
954
|
|
986
|
-
|
987
|
-
|
955
|
+
// See if there's still an expression, and that we haven't already
|
956
|
+
// matched a token
|
957
|
+
if ( t && !foundToken ) {
|
958
|
+
// Handle multiple expressions
|
959
|
+
if ( !t.indexOf(",") ) {
|
960
|
+
// Clean the result set
|
961
|
+
if ( context == ret[0] ) ret.shift();
|
962
|
+
|
963
|
+
// Merge the result sets
|
964
|
+
done = jQuery.merge( done, ret );
|
965
|
+
|
966
|
+
// Reset the context
|
967
|
+
r = ret = [context];
|
968
|
+
|
969
|
+
// Touch up the selector string
|
970
|
+
t = " " + t.substr(1,t.length);
|
971
|
+
|
972
|
+
} else {
|
973
|
+
// Optomize for the case nodeName#idName
|
974
|
+
var re2 = new RegExp("^(" + jQuery.chars + "+)(#)(" + jQuery.chars + "+)");
|
975
|
+
var m = re2.exec(t);
|
976
|
+
|
977
|
+
// Re-organize the results, so that they're consistent
|
978
|
+
if ( m ) {
|
979
|
+
m = [ 0, m[2], m[3], m[1] ];
|
980
|
+
|
981
|
+
} else {
|
982
|
+
// Otherwise, do a traditional filter check for
|
983
|
+
// ID, class, and element selectors
|
984
|
+
re2 = new RegExp("^([#.]?)(" + jQuery.chars + "*)");
|
985
|
+
m = re2.exec(t);
|
986
|
+
}
|
987
|
+
|
988
|
+
m[2] = m[2].replace(/\\/g, "");
|
989
|
+
|
990
|
+
var elem = ret[ret.length-1];
|
991
|
+
|
992
|
+
// Try to do a global search by ID, where we can
|
993
|
+
if ( m[1] == "#" && elem && elem.getElementById ) {
|
994
|
+
// Optimization for HTML document case
|
995
|
+
var oid = elem.getElementById(m[2]);
|
996
|
+
|
997
|
+
// Do a quick check for the existence of the actual ID attribute
|
998
|
+
// to avoid selecting by the name attribute in IE
|
999
|
+
// also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
|
1000
|
+
if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
|
1001
|
+
oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
|
1002
|
+
|
1003
|
+
// Do a quick check for node name (where applicable) so
|
1004
|
+
// that div#foo searches will be really fast
|
1005
|
+
ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
|
1006
|
+
} else {
|
1007
|
+
// We need to find all descendant elements
|
1008
|
+
for ( var i = 0; ret[i]; i++ ) {
|
1009
|
+
// Grab the tag name being searched for
|
1010
|
+
var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
|
1011
|
+
|
1012
|
+
// Handle IE7 being really dumb about <object>s
|
1013
|
+
if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" )
|
1014
|
+
tag = "param";
|
1015
|
+
|
1016
|
+
r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
|
1017
|
+
}
|
1018
|
+
|
1019
|
+
// It's faster to filter by class and be done with it
|
1020
|
+
if ( m[1] == "." )
|
1021
|
+
r = jQuery.classFilter( r, m[2] );
|
1022
|
+
|
1023
|
+
// Same with ID filtering
|
1024
|
+
if ( m[1] == "#" ) {
|
1025
|
+
var tmp = [];
|
1026
|
+
|
1027
|
+
// Try to find the element with the ID
|
1028
|
+
for ( var i = 0; r[i]; i++ )
|
1029
|
+
if ( r[i].getAttribute("id") == m[2] ) {
|
1030
|
+
tmp = [ r[i] ];
|
1031
|
+
break;
|
1032
|
+
}
|
988
1033
|
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
1034
|
+
r = tmp;
|
1035
|
+
}
|
1036
|
+
|
1037
|
+
ret = r;
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
t = t.replace( re2, "" );
|
1041
|
+
}
|
994
1042
|
|
995
|
-
event.stopPropagation = function() {
|
996
|
-
this.cancelBubble = true;
|
997
|
-
};
|
998
1043
|
}
|
999
1044
|
|
1000
|
-
|
1045
|
+
// If a selector string still exists
|
1046
|
+
if ( t ) {
|
1047
|
+
// Attempt to filter it
|
1048
|
+
var val = jQuery.filter(t,r);
|
1049
|
+
ret = r = val.r;
|
1050
|
+
t = jQuery.trim(val.t);
|
1051
|
+
}
|
1001
1052
|
}
|
1002
1053
|
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1054
|
+
// An error occurred with the selector;
|
1055
|
+
// just return an empty set instead
|
1056
|
+
if ( t )
|
1057
|
+
ret = [];
|
1007
1058
|
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
opera: /opera/.test(b),
|
1012
|
-
msie: /msie/.test(b) && !/opera/.test(b),
|
1013
|
-
mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
|
1014
|
-
};
|
1059
|
+
// Remove the root context
|
1060
|
+
if ( ret && context == ret[0] )
|
1061
|
+
ret.shift();
|
1015
1062
|
|
1016
|
-
|
1017
|
-
|
1018
|
-
};
|
1063
|
+
// And combine the results
|
1064
|
+
done = jQuery.merge( done, ret );
|
1019
1065
|
|
1020
|
-
|
1021
|
-
to: {
|
1022
|
-
appendTo: "append",
|
1023
|
-
prependTo: "prepend",
|
1024
|
-
insertBefore: "before",
|
1025
|
-
insertAfter: "after"
|
1066
|
+
return done;
|
1026
1067
|
},
|
1027
1068
|
|
1028
|
-
|
1069
|
+
classFilter: function(r,m,not){
|
1070
|
+
m = " " + m + " ";
|
1071
|
+
var tmp = [];
|
1072
|
+
for ( var i = 0; r[i]; i++ ) {
|
1073
|
+
var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
|
1074
|
+
if ( !not && pass || not && !pass )
|
1075
|
+
tmp.push( r[i] );
|
1076
|
+
}
|
1077
|
+
return tmp;
|
1078
|
+
},
|
1029
1079
|
|
1030
|
-
filter:
|
1080
|
+
filter: function(t,r,not) {
|
1081
|
+
var last;
|
1031
1082
|
|
1032
|
-
|
1083
|
+
// Look for common filter expressions
|
1084
|
+
while ( t && t != last ) {
|
1085
|
+
last = t;
|
1033
1086
|
|
1034
|
-
|
1087
|
+
var p = jQuery.parse, m;
|
1035
1088
|
|
1036
|
-
|
1089
|
+
for ( var i = 0; p[i]; i++ ) {
|
1090
|
+
m = p[i].exec( t );
|
1037
1091
|
|
1038
|
-
|
1092
|
+
if ( m ) {
|
1093
|
+
// Remove what we just matched
|
1094
|
+
t = t.substring( m[0].length );
|
1039
1095
|
|
1040
|
-
|
1096
|
+
m[2] = m[2].replace(/\\/g, "");
|
1097
|
+
break;
|
1098
|
+
}
|
1099
|
+
}
|
1041
1100
|
|
1042
|
-
|
1101
|
+
if ( !m )
|
1102
|
+
break;
|
1043
1103
|
|
1044
|
-
|
1104
|
+
// :not() is a special case that can be optimized by
|
1105
|
+
// keeping it out of the expression list
|
1106
|
+
if ( m[1] == ":" && m[2] == "not" )
|
1107
|
+
r = jQuery.filter(m[3], r, true).r;
|
1108
|
+
|
1109
|
+
// We can get a big speed boost by filtering by class here
|
1110
|
+
else if ( m[1] == "." )
|
1111
|
+
r = jQuery.classFilter(r, m[2], not);
|
1112
|
+
|
1113
|
+
else if ( m[1] == "@" ) {
|
1114
|
+
var tmp = [], type = m[3];
|
1115
|
+
|
1116
|
+
for ( var i = 0, rl = r.length; i < rl; i++ ) {
|
1117
|
+
var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
|
1118
|
+
|
1119
|
+
if ( z == null || /href|src/.test(m[2]) )
|
1120
|
+
z = jQuery.attr(a,m[2]) || '';
|
1121
|
+
|
1122
|
+
if ( (type == "" && !!z ||
|
1123
|
+
type == "=" && z == m[5] ||
|
1124
|
+
type == "!=" && z != m[5] ||
|
1125
|
+
type == "^=" && z && !z.indexOf(m[5]) ||
|
1126
|
+
type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
|
1127
|
+
(type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
|
1128
|
+
tmp.push( a );
|
1129
|
+
}
|
1130
|
+
|
1131
|
+
r = tmp;
|
1132
|
+
|
1133
|
+
// We can get a speed boost by handling nth-child here
|
1134
|
+
} else if ( m[1] == ":" && m[2] == "nth-child" ) {
|
1135
|
+
var num = jQuery.mergeNum++, tmp = [],
|
1136
|
+
test = /(\d*)n\+?(\d*)/.exec(
|
1137
|
+
m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
|
1138
|
+
!/\D/.test(m[3]) && "n+" + m[3] || m[3]),
|
1139
|
+
first = (test[1] || 1) - 0, last = test[2] - 0;
|
1140
|
+
|
1141
|
+
for ( var i = 0, rl = r.length; i < rl; i++ ) {
|
1142
|
+
var node = r[i], parentNode = node.parentNode;
|
1143
|
+
|
1144
|
+
if ( num != parentNode.mergeNum ) {
|
1145
|
+
var c = 1;
|
1146
|
+
|
1147
|
+
for ( var n = parentNode.firstChild; n; n = n.nextSibling )
|
1148
|
+
if ( n.nodeType == 1 )
|
1149
|
+
n.nodeIndex = c++;
|
1150
|
+
|
1151
|
+
parentNode.mergeNum = num;
|
1152
|
+
}
|
1153
|
+
|
1154
|
+
var add = false;
|
1155
|
+
|
1156
|
+
if ( first == 1 ) {
|
1157
|
+
if ( last == 0 || node.nodeIndex == last )
|
1158
|
+
add = true;
|
1159
|
+
} else if ( (node.nodeIndex + last) % first == 0 )
|
1160
|
+
add = true;
|
1161
|
+
|
1162
|
+
if ( add ^ not )
|
1163
|
+
tmp.push( node );
|
1164
|
+
}
|
1165
|
+
|
1166
|
+
r = tmp;
|
1167
|
+
|
1168
|
+
// Otherwise, find the expression to execute
|
1169
|
+
} else {
|
1170
|
+
var f = jQuery.expr[m[1]];
|
1171
|
+
if ( typeof f != "string" )
|
1172
|
+
f = jQuery.expr[m[1]][m[2]];
|
1173
|
+
|
1174
|
+
// Build a custom macro to enclose it
|
1175
|
+
eval("f = function(a,i){return " + f + "}");
|
1045
1176
|
|
1046
|
-
|
1177
|
+
// Execute it against the current filter
|
1178
|
+
r = jQuery.grep( r, f, not );
|
1179
|
+
}
|
1180
|
+
}
|
1047
1181
|
|
1048
|
-
|
1182
|
+
// Return an array of filtered elements (r)
|
1183
|
+
// and the modified expression string (t)
|
1184
|
+
return { r: r, t: t };
|
1049
1185
|
},
|
1186
|
+
parents: function( elem ){
|
1187
|
+
var matched = [];
|
1188
|
+
var cur = elem.parentNode;
|
1189
|
+
while ( cur && cur != document ) {
|
1190
|
+
matched.push( cur );
|
1191
|
+
cur = cur.parentNode;
|
1192
|
+
}
|
1193
|
+
return matched;
|
1194
|
+
},
|
1195
|
+
nth: function(cur,result,dir,elem){
|
1196
|
+
result = result || 1;
|
1197
|
+
var num = 0;
|
1050
1198
|
|
1051
|
-
|
1199
|
+
for ( ; cur; cur = cur[dir] )
|
1200
|
+
if ( cur.nodeType == 1 && ++num == result )
|
1201
|
+
break;
|
1052
1202
|
|
1053
|
-
|
1203
|
+
return cur;
|
1204
|
+
},
|
1205
|
+
sibling: function( n, elem ) {
|
1206
|
+
var r = [];
|
1054
1207
|
|
1055
|
-
|
1208
|
+
for ( ; n; n = n.nextSibling ) {
|
1209
|
+
if ( n.nodeType == 1 && (!elem || n != elem) )
|
1210
|
+
r.push( n );
|
1211
|
+
}
|
1056
1212
|
|
1057
|
-
|
1213
|
+
return r;
|
1214
|
+
}
|
1215
|
+
});
|
1216
|
+
/*
|
1217
|
+
* A number of helper functions used for managing events.
|
1218
|
+
* Many of the ideas behind this code orignated from
|
1219
|
+
* Dean Edwards' addEvent library.
|
1220
|
+
*/
|
1221
|
+
jQuery.event = {
|
1222
|
+
|
1223
|
+
// Bind an event to an element
|
1224
|
+
// Original by Dean Edwards
|
1225
|
+
add: function(element, type, handler, data) {
|
1226
|
+
// For whatever reason, IE has trouble passing the window object
|
1227
|
+
// around, causing it to be cloned in the process
|
1228
|
+
if ( jQuery.browser.msie && element.setInterval != undefined )
|
1229
|
+
element = window;
|
1230
|
+
|
1231
|
+
// Make sure that the function being executed has a unique ID
|
1232
|
+
if ( !handler.guid )
|
1233
|
+
handler.guid = this.guid++;
|
1234
|
+
|
1235
|
+
// if data is passed, bind to handler
|
1236
|
+
if( data != undefined ) {
|
1237
|
+
// Create temporary function pointer to original handler
|
1238
|
+
var fn = handler;
|
1239
|
+
|
1240
|
+
// Create unique handler function, wrapped around original handler
|
1241
|
+
handler = function() {
|
1242
|
+
// Pass arguments and context to original handler
|
1243
|
+
return fn.apply(this, arguments);
|
1244
|
+
};
|
1058
1245
|
|
1059
|
-
|
1246
|
+
// Store data in unique handler
|
1247
|
+
handler.data = data;
|
1060
1248
|
|
1061
|
-
|
1249
|
+
// Set the guid of unique handler to the same of original handler, so it can be removed
|
1250
|
+
handler.guid = fn.guid;
|
1251
|
+
}
|
1062
1252
|
|
1063
|
-
|
1253
|
+
// Init the element's event structure
|
1254
|
+
if (!element.$events)
|
1255
|
+
element.$events = {};
|
1256
|
+
|
1257
|
+
if (!element.$handle)
|
1258
|
+
element.$handle = function() {
|
1259
|
+
// returned undefined or false
|
1260
|
+
var val;
|
1261
|
+
|
1262
|
+
// Handle the second event of a trigger and when
|
1263
|
+
// an event is called after a page has unloaded
|
1264
|
+
if ( typeof jQuery == "undefined" || jQuery.event.triggered )
|
1265
|
+
return val;
|
1266
|
+
|
1267
|
+
val = jQuery.event.handle.apply(element, arguments);
|
1268
|
+
|
1269
|
+
return val;
|
1270
|
+
};
|
1064
1271
|
|
1065
|
-
|
1272
|
+
// Get the current list of functions bound to this event
|
1273
|
+
var handlers = element.$events[type];
|
1274
|
+
|
1275
|
+
// Init the event handler queue
|
1276
|
+
if (!handlers) {
|
1277
|
+
handlers = element.$events[type] = {};
|
1278
|
+
|
1279
|
+
// And bind the global event handler to the element
|
1280
|
+
if (element.addEventListener)
|
1281
|
+
element.addEventListener(type, element.$handle, false);
|
1282
|
+
else
|
1283
|
+
element.attachEvent("on" + type, element.$handle);
|
1284
|
+
}
|
1285
|
+
|
1286
|
+
// Add the function to the element's handler list
|
1287
|
+
handlers[handler.guid] = handler;
|
1288
|
+
|
1289
|
+
// Remember the function in a global list (for triggering)
|
1290
|
+
if (!this.global[type])
|
1291
|
+
this.global[type] = [];
|
1292
|
+
// Only add the element to the global list once
|
1293
|
+
if (jQuery.inArray(element, this.global[type]) == -1)
|
1294
|
+
this.global[type].push( element );
|
1066
1295
|
},
|
1067
1296
|
|
1068
|
-
|
1069
|
-
|
1070
|
-
this.removeAttribute( key );
|
1071
|
-
},
|
1072
|
-
show: function(){
|
1073
|
-
this.style.display = this.oldblock ? this.oldblock : "";
|
1074
|
-
if ( jQuery.css(this,"display") == "none" )
|
1075
|
-
this.style.display = "block";
|
1076
|
-
},
|
1077
|
-
hide: function(){
|
1078
|
-
this.oldblock = this.oldblock || jQuery.css(this,"display");
|
1079
|
-
if ( this.oldblock == "none" )
|
1080
|
-
this.oldblock = "block";
|
1081
|
-
this.style.display = "none";
|
1082
|
-
},
|
1083
|
-
toggle: function(){
|
1084
|
-
jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );
|
1085
|
-
},
|
1086
|
-
addClass: function(c){
|
1087
|
-
jQuery.className.add(this,c);
|
1088
|
-
},
|
1089
|
-
removeClass: function(c){
|
1090
|
-
jQuery.className.remove(this,c);
|
1091
|
-
},
|
1092
|
-
toggleClass: function( c ){
|
1093
|
-
jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this,c);
|
1094
|
-
},
|
1297
|
+
guid: 1,
|
1298
|
+
global: {},
|
1095
1299
|
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
},
|
1100
|
-
empty: function(){
|
1101
|
-
while ( this.firstChild )
|
1102
|
-
this.removeChild( this.firstChild );
|
1103
|
-
},
|
1104
|
-
bind: function( type, fn ) {
|
1105
|
-
if ( fn.constructor == String )
|
1106
|
-
fn = new Function("e", ( !fn.indexOf(".") ? "jQuery(this)" : "return " ) + fn);
|
1107
|
-
jQuery.event.add( this, type, fn );
|
1108
|
-
},
|
1300
|
+
// Detach an event or set of events from an element
|
1301
|
+
remove: function(element, type, handler) {
|
1302
|
+
var events = element.$events, ret, index;
|
1109
1303
|
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1304
|
+
if ( events ) {
|
1305
|
+
// type is actually an event object here
|
1306
|
+
if ( type && type.type ) {
|
1307
|
+
handler = type.handler;
|
1308
|
+
type = type.type;
|
1309
|
+
}
|
1310
|
+
|
1311
|
+
if ( !type ) {
|
1312
|
+
for ( type in events )
|
1313
|
+
this.remove( element, type );
|
1314
|
+
|
1315
|
+
} else if ( events[type] ) {
|
1316
|
+
// remove the given handler for the given type
|
1317
|
+
if ( handler )
|
1318
|
+
delete events[type][handler.guid];
|
1319
|
+
|
1320
|
+
// remove all handlers for the given type
|
1321
|
+
else
|
1322
|
+
for ( handler in element.$events[type] )
|
1323
|
+
delete events[type][handler];
|
1324
|
+
|
1325
|
+
// remove generic event handler if no more handlers exist
|
1326
|
+
for ( ret in events[type] ) break;
|
1327
|
+
if ( !ret ) {
|
1328
|
+
if (element.removeEventListener)
|
1329
|
+
element.removeEventListener(type, element.$handle, false);
|
1330
|
+
else
|
1331
|
+
element.detachEvent("on" + type, element.$handle);
|
1332
|
+
ret = null;
|
1333
|
+
delete events[type];
|
1334
|
+
|
1335
|
+
// Remove element from the global event type cache
|
1336
|
+
while ( this.global[type] && ( (index = jQuery.inArray(element, this.global[type])) >= 0 ) )
|
1337
|
+
delete this.global[type][index];
|
1338
|
+
}
|
1339
|
+
}
|
1340
|
+
|
1341
|
+
// Remove the expando if it's no longer used
|
1342
|
+
for ( ret in events ) break;
|
1343
|
+
if ( !ret )
|
1344
|
+
element.$handle = element.$events = null;
|
1345
|
+
}
|
1346
|
+
},
|
1347
|
+
|
1348
|
+
trigger: function(type, data, element) {
|
1349
|
+
// Clone the incoming data, if any
|
1350
|
+
data = jQuery.makeArray(data || []);
|
1351
|
+
|
1352
|
+
// Handle a global trigger
|
1353
|
+
if ( !element )
|
1354
|
+
jQuery.each( this.global[type] || [], function(){
|
1355
|
+
jQuery.event.trigger( type, data, this );
|
1356
|
+
});
|
1357
|
+
|
1358
|
+
// Handle triggering a single element
|
1359
|
+
else {
|
1360
|
+
var val, ret, fn = jQuery.isFunction( element[ type ] || null );
|
1361
|
+
|
1362
|
+
// Pass along a fake event
|
1363
|
+
data.unshift( this.fix({ type: type, target: element }) );
|
1364
|
+
|
1365
|
+
// Trigger the event
|
1366
|
+
if ( jQuery.isFunction(element.$handle) && (val = element.$handle.apply( element, data )) !== false )
|
1367
|
+
this.triggered = true;
|
1368
|
+
|
1369
|
+
if ( fn && val !== false && !jQuery.nodeName(element, 'a') )
|
1370
|
+
element[ type ]();
|
1371
|
+
|
1372
|
+
this.triggered = false;
|
1373
|
+
}
|
1374
|
+
},
|
1375
|
+
|
1376
|
+
handle: function(event) {
|
1377
|
+
// returned undefined or false
|
1378
|
+
var val;
|
1379
|
+
|
1380
|
+
// Empty object is for triggered events with no data
|
1381
|
+
event = jQuery.event.fix( event || window.event || {} );
|
1382
|
+
|
1383
|
+
var c = this.$events && this.$events[event.type], args = [].slice.call( arguments, 1 );
|
1384
|
+
args.unshift( event );
|
1385
|
+
|
1386
|
+
for ( var j in c ) {
|
1387
|
+
// Pass in a reference to the handler function itself
|
1388
|
+
// So that we can later remove it
|
1389
|
+
args[0].handler = c[j];
|
1390
|
+
args[0].data = c[j].data;
|
1391
|
+
|
1392
|
+
if ( c[j].apply( this, args ) === false ) {
|
1393
|
+
event.preventDefault();
|
1394
|
+
event.stopPropagation();
|
1395
|
+
val = false;
|
1396
|
+
}
|
1397
|
+
}
|
1398
|
+
|
1399
|
+
// Clean up added properties in IE to prevent memory leak
|
1400
|
+
if (jQuery.browser.msie)
|
1401
|
+
event.target = event.preventDefault = event.stopPropagation =
|
1402
|
+
event.handler = event.data = null;
|
1403
|
+
|
1404
|
+
return val;
|
1405
|
+
},
|
1406
|
+
|
1407
|
+
fix: function(event) {
|
1408
|
+
// store a copy of the original event object
|
1409
|
+
// and clone to set read-only properties
|
1410
|
+
var originalEvent = event;
|
1411
|
+
event = jQuery.extend({}, originalEvent);
|
1412
|
+
|
1413
|
+
// add preventDefault and stopPropagation since
|
1414
|
+
// they will not work on the clone
|
1415
|
+
event.preventDefault = function() {
|
1416
|
+
// if preventDefault exists run it on the original event
|
1417
|
+
if (originalEvent.preventDefault)
|
1418
|
+
return originalEvent.preventDefault();
|
1419
|
+
// otherwise set the returnValue property of the original event to false (IE)
|
1420
|
+
originalEvent.returnValue = false;
|
1421
|
+
};
|
1422
|
+
event.stopPropagation = function() {
|
1423
|
+
// if stopPropagation exists run it on the original event
|
1424
|
+
if (originalEvent.stopPropagation)
|
1425
|
+
return originalEvent.stopPropagation();
|
1426
|
+
// otherwise set the cancelBubble property of the original event to true (IE)
|
1427
|
+
originalEvent.cancelBubble = true;
|
1428
|
+
};
|
1429
|
+
|
1430
|
+
// Fix target property, if necessary
|
1431
|
+
if ( !event.target && event.srcElement )
|
1432
|
+
event.target = event.srcElement;
|
1433
|
+
|
1434
|
+
// check if target is a textnode (safari)
|
1435
|
+
if (jQuery.browser.safari && event.target.nodeType == 3)
|
1436
|
+
event.target = originalEvent.target.parentNode;
|
1437
|
+
|
1438
|
+
// Add relatedTarget, if necessary
|
1439
|
+
if ( !event.relatedTarget && event.fromElement )
|
1440
|
+
event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
|
1441
|
+
|
1442
|
+
// Calculate pageX/Y if missing and clientX/Y available
|
1443
|
+
if ( event.pageX == null && event.clientX != null ) {
|
1444
|
+
var e = document.documentElement, b = document.body;
|
1445
|
+
event.pageX = event.clientX + (e && e.scrollLeft || b.scrollLeft);
|
1446
|
+
event.pageY = event.clientY + (e && e.scrollTop || b.scrollTop);
|
1115
1447
|
}
|
1448
|
+
|
1449
|
+
// Add which for key events
|
1450
|
+
if ( !event.which && (event.charCode || event.keyCode) )
|
1451
|
+
event.which = event.charCode || event.keyCode;
|
1452
|
+
|
1453
|
+
// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
1454
|
+
if ( !event.metaKey && event.ctrlKey )
|
1455
|
+
event.metaKey = event.ctrlKey;
|
1456
|
+
|
1457
|
+
// Add which for click: 1 == left; 2 == middle; 3 == right
|
1458
|
+
// Note: button is not normalized, so don't use it
|
1459
|
+
if ( !event.which && event.button )
|
1460
|
+
event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
|
1461
|
+
|
1462
|
+
return event;
|
1116
1463
|
}
|
1117
1464
|
};
|
1118
1465
|
|
1119
|
-
jQuery.init();
|
1120
1466
|
jQuery.fn.extend({
|
1467
|
+
bind: function( type, data, fn ) {
|
1468
|
+
return type == "unload" ? this.one(type, data, fn) : this.each(function(){
|
1469
|
+
jQuery.event.add( this, type, fn || data, fn && data );
|
1470
|
+
});
|
1471
|
+
},
|
1472
|
+
one: function( type, data, fn ) {
|
1473
|
+
return this.each(function(){
|
1474
|
+
jQuery.event.add( this, type, function(event) {
|
1475
|
+
jQuery(this).unbind(event);
|
1476
|
+
return (fn || data).apply( this, arguments);
|
1477
|
+
}, fn && data);
|
1478
|
+
});
|
1479
|
+
},
|
1480
|
+
unbind: function( type, fn ) {
|
1481
|
+
return this.each(function(){
|
1482
|
+
jQuery.event.remove( this, type, fn );
|
1483
|
+
});
|
1484
|
+
},
|
1485
|
+
trigger: function( type, data ) {
|
1486
|
+
return this.each(function(){
|
1487
|
+
jQuery.event.trigger( type, data, this );
|
1488
|
+
});
|
1489
|
+
},
|
1490
|
+
toggle: function() {
|
1491
|
+
// Save reference to arguments for access in closure
|
1492
|
+
var a = arguments;
|
1121
1493
|
|
1122
|
-
|
1123
|
-
// remember it for later
|
1124
|
-
_toggle: jQuery.fn.toggle,
|
1125
|
-
toggle: function(a,b) {
|
1126
|
-
// If two functions are passed in, we're
|
1127
|
-
// toggling on a click
|
1128
|
-
return a && b && a.constructor == Function && b.constructor == Function ? this.click(function(e){
|
1494
|
+
return this.click(function(e) {
|
1129
1495
|
// Figure out which function to execute
|
1130
|
-
this.
|
1496
|
+
this.lastToggle = 0 == this.lastToggle ? 1 : 0;
|
1131
1497
|
|
1132
1498
|
// Make sure that clicks stop
|
1133
1499
|
e.preventDefault();
|
1134
1500
|
|
1135
1501
|
// and execute the function
|
1136
|
-
return this.
|
1137
|
-
})
|
1138
|
-
|
1139
|
-
// Otherwise, execute the old toggle function
|
1140
|
-
this._toggle.apply( this, arguments );
|
1502
|
+
return a[this.lastToggle].apply( this, [e] ) || false;
|
1503
|
+
});
|
1141
1504
|
},
|
1142
1505
|
hover: function(f,g) {
|
1143
1506
|
|
1144
|
-
// A private function for
|
1507
|
+
// A private function for handling mouse 'hovering'
|
1145
1508
|
function handleHover(e) {
|
1146
1509
|
// Check if mouse(over|out) are still within the same parent element
|
1147
|
-
var p =
|
1510
|
+
var p = e.relatedTarget;
|
1148
1511
|
|
1149
1512
|
// Traverse up the tree
|
1150
1513
|
while ( p && p != this ) try { p = p.parentNode } catch(e) { p = this; };
|
@@ -1163,13 +1526,12 @@ jQuery.fn.extend({
|
|
1163
1526
|
// If the DOM is already ready
|
1164
1527
|
if ( jQuery.isReady )
|
1165
1528
|
// Execute the function immediately
|
1166
|
-
f.apply( document );
|
1529
|
+
f.apply( document, [jQuery] );
|
1167
1530
|
|
1168
1531
|
// Otherwise, remember the function for later
|
1169
|
-
else
|
1532
|
+
else
|
1170
1533
|
// Add the function to the wait list
|
1171
|
-
jQuery.readyList.push( f );
|
1172
|
-
}
|
1534
|
+
jQuery.readyList.push( function() { return f.apply(this, [jQuery]) } );
|
1173
1535
|
|
1174
1536
|
return this;
|
1175
1537
|
}
|
@@ -1192,67 +1554,45 @@ jQuery.extend({
|
|
1192
1554
|
// If there are functions bound, to execute
|
1193
1555
|
if ( jQuery.readyList ) {
|
1194
1556
|
// Execute all of them
|
1195
|
-
|
1196
|
-
|
1557
|
+
jQuery.each( jQuery.readyList, function(){
|
1558
|
+
this.apply( document );
|
1559
|
+
});
|
1197
1560
|
|
1198
1561
|
// Reset the list of functions
|
1199
1562
|
jQuery.readyList = null;
|
1200
1563
|
}
|
1201
|
-
// Remove event
|
1564
|
+
// Remove event listener to avoid memory leak
|
1202
1565
|
if ( jQuery.browser.mozilla || jQuery.browser.opera )
|
1203
1566
|
document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
|
1567
|
+
|
1568
|
+
// Remove script element used by IE hack
|
1569
|
+
if( !window.frames.length ) // don't remove if frames are present (#1187)
|
1570
|
+
jQuery(window).load(function(){ jQuery("#__ie_init").remove(); });
|
1204
1571
|
}
|
1205
1572
|
}
|
1206
1573
|
});
|
1207
1574
|
|
1208
1575
|
new function(){
|
1209
1576
|
|
1210
|
-
|
1211
|
-
"mousedown,mouseup,mousemove,mouseover,mouseout,change,
|
1212
|
-
"submit,keydown,keypress,keyup,error").split(",")
|
1213
|
-
|
1214
|
-
// Go through all the event names, but make sure that
|
1215
|
-
// it is enclosed properly
|
1216
|
-
for ( var i = 0; i < e.length; i++ ) new function(){
|
1217
|
-
|
1218
|
-
var o = e[i];
|
1577
|
+
jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
|
1578
|
+
"mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
|
1579
|
+
"submit,keydown,keypress,keyup,error").split(","), function(i,o){
|
1219
1580
|
|
1220
1581
|
// Handle event binding
|
1221
1582
|
jQuery.fn[o] = function(f){
|
1222
1583
|
return f ? this.bind(o, f) : this.trigger(o);
|
1223
1584
|
};
|
1224
|
-
|
1225
|
-
// Handle event unbinding
|
1226
|
-
jQuery.fn["un"+o] = function(f){ return this.unbind(o, f); };
|
1227
|
-
|
1228
|
-
// Finally, handle events that only fire once
|
1229
|
-
jQuery.fn["one"+o] = function(f){
|
1230
|
-
// Attach the event listener
|
1231
|
-
return this.each(function(){
|
1232
|
-
|
1233
|
-
var count = 0;
|
1234
|
-
|
1235
|
-
// Add the event
|
1236
|
-
jQuery.event.add( this, o, function(e){
|
1237
|
-
// If this function has already been executed, stop
|
1238
|
-
if ( count++ ) return;
|
1239
|
-
|
1240
|
-
// And execute the bound function
|
1241
|
-
return f.apply(this, [e]);
|
1242
|
-
});
|
1243
|
-
});
|
1244
|
-
};
|
1245
1585
|
|
1246
|
-
};
|
1586
|
+
});
|
1247
1587
|
|
1248
1588
|
// If Mozilla is used
|
1249
|
-
if ( jQuery.browser.mozilla || jQuery.browser.opera )
|
1589
|
+
if ( jQuery.browser.mozilla || jQuery.browser.opera )
|
1250
1590
|
// Use the handy event callback
|
1251
1591
|
document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
|
1252
1592
|
|
1253
1593
|
// If IE is used, use the excellent hack by Matthias Miller
|
1254
1594
|
// http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
|
1255
|
-
|
1595
|
+
else if ( jQuery.browser.msie ) {
|
1256
1596
|
|
1257
1597
|
// Only works if you document.write() it
|
1258
1598
|
document.write("<scr" + "ipt id=__ie_init defer=true " +
|
@@ -1260,17 +1600,19 @@ new function(){
|
|
1260
1600
|
|
1261
1601
|
// Use the defer script hack
|
1262
1602
|
var script = document.getElementById("__ie_init");
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1603
|
+
|
1604
|
+
// script does not exist if jQuery is loaded dynamically
|
1605
|
+
if ( script )
|
1606
|
+
script.onreadystatechange = function() {
|
1607
|
+
if ( this.readyState != "complete" ) return;
|
1608
|
+
jQuery.ready();
|
1609
|
+
};
|
1268
1610
|
|
1269
1611
|
// Clear from memory
|
1270
1612
|
script = null;
|
1271
1613
|
|
1272
1614
|
// If Safari is used
|
1273
|
-
} else if ( jQuery.browser.safari )
|
1615
|
+
} else if ( jQuery.browser.safari )
|
1274
1616
|
// Continually check to see if the document.readyState is valid
|
1275
1617
|
jQuery.safariTimer = setInterval(function(){
|
1276
1618
|
// loaded and complete are both valid states
|
@@ -1284,8 +1626,7 @@ new function(){
|
|
1284
1626
|
// and execute any waiting functions
|
1285
1627
|
jQuery.ready();
|
1286
1628
|
}
|
1287
|
-
}, 10);
|
1288
|
-
}
|
1629
|
+
}, 10);
|
1289
1630
|
|
1290
1631
|
// A fallback to window.onload, that will always work
|
1291
1632
|
jQuery.event.add( window, "load", jQuery.ready );
|
@@ -1293,72 +1634,483 @@ new function(){
|
|
1293
1634
|
};
|
1294
1635
|
|
1295
1636
|
// Clean up after IE to avoid memory leaks
|
1296
|
-
if (jQuery.browser.msie)
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1637
|
+
if (jQuery.browser.msie)
|
1638
|
+
jQuery(window).one("unload", function() {
|
1639
|
+
var global = jQuery.event.global;
|
1640
|
+
for ( var type in global ) {
|
1641
|
+
var els = global[type], i = els.length;
|
1642
|
+
if ( i && type != 'unload' )
|
1643
|
+
do
|
1644
|
+
els[i-1] && jQuery.event.remove(els[i-1], type);
|
1645
|
+
while (--i);
|
1646
|
+
}
|
1647
|
+
});
|
1648
|
+
jQuery.fn.extend({
|
1649
|
+
loadIfModified: function( url, params, callback ) {
|
1650
|
+
this.load( url, params, callback, 1 );
|
1651
|
+
},
|
1652
|
+
load: function( url, params, callback, ifModified ) {
|
1653
|
+
if ( jQuery.isFunction( url ) )
|
1654
|
+
return this.bind("load", url);
|
1655
|
+
|
1656
|
+
callback = callback || function(){};
|
1657
|
+
|
1658
|
+
// Default to a GET request
|
1659
|
+
var type = "GET";
|
1660
|
+
|
1661
|
+
// If the second parameter was provided
|
1662
|
+
if ( params )
|
1663
|
+
// If it's a function
|
1664
|
+
if ( jQuery.isFunction( params ) ) {
|
1665
|
+
// We assume that it's the callback
|
1666
|
+
callback = params;
|
1667
|
+
params = null;
|
1668
|
+
|
1669
|
+
// Otherwise, build a param string
|
1670
|
+
} else {
|
1671
|
+
params = jQuery.param( params );
|
1672
|
+
type = "POST";
|
1673
|
+
}
|
1674
|
+
|
1675
|
+
var self = this;
|
1676
|
+
|
1677
|
+
// Request the remote document
|
1678
|
+
jQuery.ajax({
|
1679
|
+
url: url,
|
1680
|
+
type: type,
|
1681
|
+
data: params,
|
1682
|
+
ifModified: ifModified,
|
1683
|
+
complete: function(res, status){
|
1684
|
+
if ( status == "success" || !ifModified && status == "notmodified" )
|
1685
|
+
// Inject the HTML into all the matched elements
|
1686
|
+
self.attr("innerHTML", res.responseText)
|
1687
|
+
// Execute all the scripts inside of the newly-injected HTML
|
1688
|
+
.evalScripts()
|
1689
|
+
// Execute callback
|
1690
|
+
.each( callback, [res.responseText, status, res] );
|
1691
|
+
else
|
1692
|
+
callback.apply( self, [res.responseText, status, res] );
|
1693
|
+
}
|
1694
|
+
});
|
1695
|
+
return this;
|
1696
|
+
},
|
1697
|
+
serialize: function() {
|
1698
|
+
return jQuery.param( this );
|
1699
|
+
},
|
1700
|
+
evalScripts: function() {
|
1701
|
+
return this.find("script").each(function(){
|
1702
|
+
if ( this.src )
|
1703
|
+
jQuery.getScript( this.src );
|
1704
|
+
else
|
1705
|
+
jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" );
|
1706
|
+
}).end();
|
1301
1707
|
}
|
1708
|
+
|
1302
1709
|
});
|
1303
|
-
jQuery.fn.extend({
|
1304
1710
|
|
1305
|
-
|
1306
|
-
_show: jQuery.fn.show,
|
1711
|
+
// Attach a bunch of functions for handling common AJAX events
|
1307
1712
|
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1713
|
+
jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
|
1714
|
+
jQuery.fn[o] = function(f){
|
1715
|
+
return this.bind(o, f);
|
1716
|
+
};
|
1717
|
+
});
|
1718
|
+
|
1719
|
+
jQuery.extend({
|
1720
|
+
get: function( url, data, callback, type, ifModified ) {
|
1721
|
+
// shift arguments if data argument was ommited
|
1722
|
+
if ( jQuery.isFunction( data ) ) {
|
1723
|
+
callback = data;
|
1724
|
+
data = null;
|
1725
|
+
}
|
1726
|
+
|
1727
|
+
return jQuery.ajax({
|
1728
|
+
type: "GET",
|
1729
|
+
url: url,
|
1730
|
+
data: data,
|
1731
|
+
success: callback,
|
1732
|
+
dataType: type,
|
1733
|
+
ifModified: ifModified
|
1734
|
+
});
|
1735
|
+
},
|
1736
|
+
getIfModified: function( url, data, callback, type ) {
|
1737
|
+
return jQuery.get(url, data, callback, type, 1);
|
1738
|
+
},
|
1739
|
+
getScript: function( url, callback ) {
|
1740
|
+
return jQuery.get(url, null, callback, "script");
|
1741
|
+
},
|
1742
|
+
getJSON: function( url, data, callback ) {
|
1743
|
+
return jQuery.get(url, data, callback, "json");
|
1744
|
+
},
|
1745
|
+
post: function( url, data, callback, type ) {
|
1746
|
+
if ( jQuery.isFunction( data ) ) {
|
1747
|
+
callback = data;
|
1748
|
+
data = {};
|
1749
|
+
}
|
1750
|
+
|
1751
|
+
return jQuery.ajax({
|
1752
|
+
type: "POST",
|
1753
|
+
url: url,
|
1754
|
+
data: data,
|
1755
|
+
success: callback,
|
1756
|
+
dataType: type
|
1757
|
+
});
|
1758
|
+
},
|
1759
|
+
ajaxTimeout: function( timeout ) {
|
1760
|
+
jQuery.ajaxSettings.timeout = timeout;
|
1761
|
+
},
|
1762
|
+
ajaxSetup: function( settings ) {
|
1763
|
+
jQuery.extend( jQuery.ajaxSettings, settings );
|
1764
|
+
},
|
1765
|
+
|
1766
|
+
ajaxSettings: {
|
1767
|
+
global: true,
|
1768
|
+
type: "GET",
|
1769
|
+
timeout: 0,
|
1770
|
+
contentType: "application/x-www-form-urlencoded",
|
1771
|
+
processData: true,
|
1772
|
+
async: true,
|
1773
|
+
data: null
|
1774
|
+
},
|
1775
|
+
|
1776
|
+
// Last-Modified header cache for next request
|
1777
|
+
lastModified: {},
|
1778
|
+
ajax: function( s ) {
|
1779
|
+
// TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
|
1780
|
+
s = jQuery.extend({}, jQuery.ajaxSettings, s);
|
1781
|
+
|
1782
|
+
// if data available
|
1783
|
+
if ( s.data ) {
|
1784
|
+
// convert data if not already a string
|
1785
|
+
if (s.processData && typeof s.data != "string")
|
1786
|
+
s.data = jQuery.param(s.data);
|
1787
|
+
// append data to url for get requests
|
1788
|
+
if( s.type.toLowerCase() == "get" ) {
|
1789
|
+
// "?" + data or "&" + data (in case there are already params)
|
1790
|
+
s.url += ((s.url.indexOf("?") > -1) ? "&" : "?") + s.data;
|
1791
|
+
// IE likes to send both get and post data, prevent this
|
1792
|
+
s.data = null;
|
1793
|
+
}
|
1794
|
+
}
|
1795
|
+
|
1796
|
+
// Watch for a new set of requests
|
1797
|
+
if ( s.global && ! jQuery.active++ )
|
1798
|
+
jQuery.event.trigger( "ajaxStart" );
|
1799
|
+
|
1800
|
+
var requestDone = false;
|
1801
|
+
|
1802
|
+
// Create the request object; Microsoft failed to properly
|
1803
|
+
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
|
1804
|
+
var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
|
1805
|
+
|
1806
|
+
// Open the socket
|
1807
|
+
xml.open(s.type, s.url, s.async);
|
1808
|
+
|
1809
|
+
// Set the correct header, if data is being sent
|
1810
|
+
if ( s.data )
|
1811
|
+
xml.setRequestHeader("Content-Type", s.contentType);
|
1812
|
+
|
1813
|
+
// Set the If-Modified-Since header, if ifModified mode.
|
1814
|
+
if ( s.ifModified )
|
1815
|
+
xml.setRequestHeader("If-Modified-Since",
|
1816
|
+
jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
|
1817
|
+
|
1818
|
+
// Set header so the called script knows that it's an XMLHttpRequest
|
1819
|
+
xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
1820
|
+
|
1821
|
+
// Allow custom headers/mimetypes
|
1822
|
+
if( s.beforeSend )
|
1823
|
+
s.beforeSend(xml);
|
1824
|
+
|
1825
|
+
if ( s.global )
|
1826
|
+
jQuery.event.trigger("ajaxSend", [xml, s]);
|
1827
|
+
|
1828
|
+
// Wait for a response to come back
|
1829
|
+
var onreadystatechange = function(isTimeout){
|
1830
|
+
// The transfer is complete and the data is available, or the request timed out
|
1831
|
+
if ( xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
|
1832
|
+
requestDone = true;
|
1833
|
+
|
1834
|
+
// clear poll interval
|
1835
|
+
if (ival) {
|
1836
|
+
clearInterval(ival);
|
1837
|
+
ival = null;
|
1838
|
+
}
|
1839
|
+
|
1840
|
+
var status;
|
1841
|
+
try {
|
1842
|
+
status = jQuery.httpSuccess( xml ) && isTimeout != "timeout" ?
|
1843
|
+
s.ifModified && jQuery.httpNotModified( xml, s.url ) ? "notmodified" : "success" : "error";
|
1844
|
+
// Make sure that the request was successful or notmodified
|
1845
|
+
if ( status != "error" ) {
|
1846
|
+
// Cache Last-Modified header, if ifModified mode.
|
1847
|
+
var modRes;
|
1848
|
+
try {
|
1849
|
+
modRes = xml.getResponseHeader("Last-Modified");
|
1850
|
+
} catch(e) {} // swallow exception thrown by FF if header is not available
|
1851
|
+
|
1852
|
+
if ( s.ifModified && modRes )
|
1853
|
+
jQuery.lastModified[s.url] = modRes;
|
1854
|
+
|
1855
|
+
// process the data (runs the xml through httpData regardless of callback)
|
1856
|
+
var data = jQuery.httpData( xml, s.dataType );
|
1857
|
+
|
1858
|
+
// If a local callback was specified, fire it and pass it the data
|
1859
|
+
if ( s.success )
|
1860
|
+
s.success( data, status );
|
1861
|
+
|
1862
|
+
// Fire the global callback
|
1863
|
+
if( s.global )
|
1864
|
+
jQuery.event.trigger( "ajaxSuccess", [xml, s] );
|
1865
|
+
} else
|
1866
|
+
jQuery.handleError(s, xml, status);
|
1867
|
+
} catch(e) {
|
1868
|
+
status = "error";
|
1869
|
+
jQuery.handleError(s, xml, status, e);
|
1870
|
+
}
|
1871
|
+
|
1872
|
+
// The request was completed
|
1873
|
+
if( s.global )
|
1874
|
+
jQuery.event.trigger( "ajaxComplete", [xml, s] );
|
1875
|
+
|
1876
|
+
// Handle the global AJAX counter
|
1877
|
+
if ( s.global && ! --jQuery.active )
|
1878
|
+
jQuery.event.trigger( "ajaxStop" );
|
1879
|
+
|
1880
|
+
// Process result
|
1881
|
+
if ( s.complete )
|
1882
|
+
s.complete(xml, status);
|
1883
|
+
|
1884
|
+
// Stop memory leaks
|
1885
|
+
if(s.async)
|
1886
|
+
xml = null;
|
1887
|
+
}
|
1888
|
+
};
|
1889
|
+
|
1890
|
+
// don't attach the handler to the request, just poll it instead
|
1891
|
+
var ival = setInterval(onreadystatechange, 13);
|
1892
|
+
|
1893
|
+
// Timeout checker
|
1894
|
+
if ( s.timeout > 0 )
|
1895
|
+
setTimeout(function(){
|
1896
|
+
// Check to see if the request is still happening
|
1897
|
+
if ( xml ) {
|
1898
|
+
// Cancel the request
|
1899
|
+
xml.abort();
|
1900
|
+
|
1901
|
+
if( !requestDone )
|
1902
|
+
onreadystatechange( "timeout" );
|
1903
|
+
}
|
1904
|
+
}, s.timeout);
|
1905
|
+
|
1906
|
+
// Send the data
|
1907
|
+
try {
|
1908
|
+
xml.send(s.data);
|
1909
|
+
} catch(e) {
|
1910
|
+
jQuery.handleError(s, xml, null, e);
|
1911
|
+
}
|
1912
|
+
|
1913
|
+
// firefox 1.5 doesn't fire statechange for sync requests
|
1914
|
+
if ( !s.async )
|
1915
|
+
onreadystatechange();
|
1916
|
+
|
1917
|
+
// return XMLHttpRequest to allow aborting the request etc.
|
1918
|
+
return xml;
|
1919
|
+
},
|
1920
|
+
|
1921
|
+
handleError: function( s, xml, status, e ) {
|
1922
|
+
// If a local callback was specified, fire it
|
1923
|
+
if ( s.error ) s.error( xml, status, e );
|
1924
|
+
|
1925
|
+
// Fire the global callback
|
1926
|
+
if ( s.global )
|
1927
|
+
jQuery.event.trigger( "ajaxError", [xml, s, e] );
|
1928
|
+
},
|
1929
|
+
|
1930
|
+
// Counter for holding the number of active queries
|
1931
|
+
active: 0,
|
1932
|
+
|
1933
|
+
// Determines if an XMLHttpRequest was successful or not
|
1934
|
+
httpSuccess: function( r ) {
|
1935
|
+
try {
|
1936
|
+
return !r.status && location.protocol == "file:" ||
|
1937
|
+
( r.status >= 200 && r.status < 300 ) || r.status == 304 ||
|
1938
|
+
jQuery.browser.safari && r.status == undefined;
|
1939
|
+
} catch(e){}
|
1940
|
+
return false;
|
1941
|
+
},
|
1942
|
+
|
1943
|
+
// Determines if an XMLHttpRequest returns NotModified
|
1944
|
+
httpNotModified: function( xml, url ) {
|
1945
|
+
try {
|
1946
|
+
var xmlRes = xml.getResponseHeader("Last-Modified");
|
1947
|
+
|
1948
|
+
// Firefox always returns 200. check Last-Modified date
|
1949
|
+
return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
|
1950
|
+
jQuery.browser.safari && xml.status == undefined;
|
1951
|
+
} catch(e){}
|
1952
|
+
return false;
|
1953
|
+
},
|
1954
|
+
|
1955
|
+
/* Get the data out of an XMLHttpRequest.
|
1956
|
+
* Return parsed XML if content-type header is "xml" and type is "xml" or omitted,
|
1957
|
+
* otherwise return plain text.
|
1958
|
+
* (String) data - The type of data that you're expecting back,
|
1959
|
+
* (e.g. "xml", "html", "script")
|
1960
|
+
*/
|
1961
|
+
httpData: function( r, type ) {
|
1962
|
+
var ct = r.getResponseHeader("content-type");
|
1963
|
+
var data = !type && ct && ct.indexOf("xml") >= 0;
|
1964
|
+
data = type == "xml" || data ? r.responseXML : r.responseText;
|
1965
|
+
|
1966
|
+
// If the type is "script", eval it in global context
|
1967
|
+
if ( type == "script" )
|
1968
|
+
jQuery.globalEval( data );
|
1969
|
+
|
1970
|
+
// Get the JavaScript object, if JSON is used.
|
1971
|
+
if ( type == "json" )
|
1972
|
+
data = eval("(" + data + ")");
|
1973
|
+
|
1974
|
+
// evaluate scripts within html
|
1975
|
+
if ( type == "html" )
|
1976
|
+
jQuery("<div>").html(data).evalScripts();
|
1977
|
+
|
1978
|
+
return data;
|
1979
|
+
},
|
1980
|
+
|
1981
|
+
// Serialize an array of form elements or a set of
|
1982
|
+
// key/values into a query string
|
1983
|
+
param: function( a ) {
|
1984
|
+
var s = [];
|
1985
|
+
|
1986
|
+
// If an array was passed in, assume that it is an array
|
1987
|
+
// of form elements
|
1988
|
+
if ( a.constructor == Array || a.jquery )
|
1989
|
+
// Serialize the form elements
|
1990
|
+
jQuery.each( a, function(){
|
1991
|
+
s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
|
1992
|
+
});
|
1993
|
+
|
1994
|
+
// Otherwise, assume that it's an object of key/value pairs
|
1995
|
+
else
|
1996
|
+
// Serialize the key/values
|
1997
|
+
for ( var j in a )
|
1998
|
+
// If the value is an array then the key names need to be repeated
|
1999
|
+
if ( a[j] && a[j].constructor == Array )
|
2000
|
+
jQuery.each( a[j], function(){
|
2001
|
+
s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
|
2002
|
+
});
|
2003
|
+
else
|
2004
|
+
s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );
|
2005
|
+
|
2006
|
+
// Return the resulting serialization
|
2007
|
+
return s.join("&");
|
1312
2008
|
},
|
1313
2009
|
|
1314
|
-
//
|
1315
|
-
|
2010
|
+
// evalulates a script in global context
|
2011
|
+
// not reliable for safari
|
2012
|
+
globalEval: function( data ) {
|
2013
|
+
if ( window.execScript )
|
2014
|
+
window.execScript( data );
|
2015
|
+
else if ( jQuery.browser.safari )
|
2016
|
+
// safari doesn't provide a synchronous global eval
|
2017
|
+
window.setTimeout( data, 0 );
|
2018
|
+
else
|
2019
|
+
eval.call( window, data );
|
2020
|
+
}
|
2021
|
+
|
2022
|
+
});
|
2023
|
+
jQuery.fn.extend({
|
2024
|
+
|
2025
|
+
show: function(speed,callback){
|
2026
|
+
return speed ?
|
2027
|
+
this.animate({
|
2028
|
+
height: "show", width: "show", opacity: "show"
|
2029
|
+
}, speed, callback) :
|
2030
|
+
|
2031
|
+
this.filter(":hidden").each(function(){
|
2032
|
+
this.style.display = this.oldblock ? this.oldblock : "";
|
2033
|
+
if ( jQuery.css(this,"display") == "none" )
|
2034
|
+
this.style.display = "block";
|
2035
|
+
}).end();
|
2036
|
+
},
|
1316
2037
|
|
1317
2038
|
hide: function(speed,callback){
|
1318
|
-
return speed ?
|
1319
|
-
|
1320
|
-
|
2039
|
+
return speed ?
|
2040
|
+
this.animate({
|
2041
|
+
height: "hide", width: "hide", opacity: "hide"
|
2042
|
+
}, speed, callback) :
|
2043
|
+
|
2044
|
+
this.filter(":visible").each(function(){
|
2045
|
+
this.oldblock = this.oldblock || jQuery.css(this,"display");
|
2046
|
+
if ( this.oldblock == "none" )
|
2047
|
+
this.oldblock = "block";
|
2048
|
+
this.style.display = "none";
|
2049
|
+
}).end();
|
1321
2050
|
},
|
1322
2051
|
|
2052
|
+
// Save the old toggle function
|
2053
|
+
_toggle: jQuery.fn.toggle,
|
2054
|
+
toggle: function( fn, fn2 ){
|
2055
|
+
return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
|
2056
|
+
this._toggle( fn, fn2 ) :
|
2057
|
+
fn ?
|
2058
|
+
this.animate({
|
2059
|
+
height: "toggle", width: "toggle", opacity: "toggle"
|
2060
|
+
}, fn, fn2) :
|
2061
|
+
this.each(function(){
|
2062
|
+
jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
|
2063
|
+
});
|
2064
|
+
},
|
1323
2065
|
slideDown: function(speed,callback){
|
1324
2066
|
return this.animate({height: "show"}, speed, callback);
|
1325
2067
|
},
|
1326
|
-
|
1327
2068
|
slideUp: function(speed,callback){
|
1328
2069
|
return this.animate({height: "hide"}, speed, callback);
|
1329
2070
|
},
|
1330
|
-
|
1331
|
-
|
1332
|
-
return this.each(function(){
|
1333
|
-
var state = jQuery(this).is(":hidden") ? "show" : "hide";
|
1334
|
-
jQuery(this).animate({height: state}, speed, callback);
|
1335
|
-
});
|
2071
|
+
slideToggle: function(speed, callback){
|
2072
|
+
return this.animate({height: "toggle"}, speed, callback);
|
1336
2073
|
},
|
1337
|
-
|
1338
|
-
fadeIn: function(speed,callback){
|
2074
|
+
fadeIn: function(speed, callback){
|
1339
2075
|
return this.animate({opacity: "show"}, speed, callback);
|
1340
2076
|
},
|
1341
|
-
|
1342
|
-
fadeOut: function(speed,callback){
|
2077
|
+
fadeOut: function(speed, callback){
|
1343
2078
|
return this.animate({opacity: "hide"}, speed, callback);
|
1344
2079
|
},
|
1345
|
-
|
1346
2080
|
fadeTo: function(speed,to,callback){
|
1347
2081
|
return this.animate({opacity: to}, speed, callback);
|
1348
2082
|
},
|
1349
|
-
animate: function(prop,speed,callback) {
|
2083
|
+
animate: function( prop, speed, easing, callback ) {
|
1350
2084
|
return this.queue(function(){
|
1351
|
-
|
1352
|
-
|
2085
|
+
var hidden = jQuery(this).is(":hidden"),
|
2086
|
+
opt = jQuery.speed(speed, easing, callback),
|
2087
|
+
self = this;
|
1353
2088
|
|
1354
2089
|
for ( var p in prop ) {
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
2090
|
+
if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
|
2091
|
+
return jQuery.isFunction(opt.complete) && opt.complete.apply(this);
|
2092
|
+
|
2093
|
+
if ( p == "height" || p == "width" ) {
|
2094
|
+
// Store display property
|
2095
|
+
opt.display = jQuery.css(this, "display");
|
2096
|
+
|
2097
|
+
// Make sure that nothing sneaks out
|
2098
|
+
opt.overflow = this.style.overflow;
|
2099
|
+
}
|
1360
2100
|
}
|
2101
|
+
|
2102
|
+
if ( opt.overflow != null )
|
2103
|
+
this.style.overflow = "hidden";
|
2104
|
+
|
2105
|
+
this.curAnim = jQuery.extend({}, prop);
|
1361
2106
|
|
2107
|
+
jQuery.each( prop, function(name, val){
|
2108
|
+
var e = new jQuery.fx( self, opt, name );
|
2109
|
+
if ( val.constructor == Number )
|
2110
|
+
e.custom( e.cur(), val );
|
2111
|
+
else
|
2112
|
+
e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
|
2113
|
+
});
|
1362
2114
|
});
|
1363
2115
|
},
|
1364
2116
|
queue: function(type,fn){
|
@@ -1384,53 +2136,37 @@ jQuery.fn.extend({
|
|
1384
2136
|
});
|
1385
2137
|
|
1386
2138
|
jQuery.extend({
|
1387
|
-
|
1388
|
-
setAuto: function(e,p) {
|
1389
|
-
if ( e.notAuto ) return;
|
1390
|
-
|
1391
|
-
if ( p == "height" && e.scrollHeight != parseInt(jQuery.curCSS(e,p)) ) return;
|
1392
|
-
if ( p == "width" && e.scrollWidth != parseInt(jQuery.curCSS(e,p)) ) return;
|
1393
|
-
|
1394
|
-
// Remember the original height
|
1395
|
-
var a = e.style[p];
|
1396
|
-
|
1397
|
-
// Figure out the size of the height right now
|
1398
|
-
var o = jQuery.curCSS(e,p,1);
|
1399
|
-
|
1400
|
-
if ( p == "height" && e.scrollHeight != o ||
|
1401
|
-
p == "width" && e.scrollWidth != o ) return;
|
1402
|
-
|
1403
|
-
// Set the height to auto
|
1404
|
-
e.style[p] = e.currentStyle ? "" : "auto";
|
1405
|
-
|
1406
|
-
// See what the size of "auto" is
|
1407
|
-
var n = jQuery.curCSS(e,p,1);
|
1408
|
-
|
1409
|
-
// Revert back to the original size
|
1410
|
-
if ( o != n && n != "auto" ) {
|
1411
|
-
e.style[p] = a;
|
1412
|
-
e.notAuto = true;
|
1413
|
-
}
|
1414
|
-
},
|
1415
2139
|
|
1416
|
-
speed: function(
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
2140
|
+
speed: function(speed, easing, fn) {
|
2141
|
+
var opt = speed && speed.constructor == Object ? speed : {
|
2142
|
+
complete: fn || !fn && easing ||
|
2143
|
+
jQuery.isFunction( speed ) && speed,
|
2144
|
+
duration: speed,
|
2145
|
+
easing: fn && easing || easing && easing.constructor != Function && easing || (jQuery.easing.swing ? "swing" : "linear")
|
2146
|
+
};
|
2147
|
+
|
2148
|
+
opt.duration = (opt.duration && opt.duration.constructor == Number ?
|
2149
|
+
opt.duration :
|
2150
|
+
{ slow: 600, fast: 200 }[opt.duration]) || 400;
|
1424
2151
|
|
1425
2152
|
// Queueing
|
1426
|
-
|
1427
|
-
|
2153
|
+
opt.old = opt.complete;
|
2154
|
+
opt.complete = function(){
|
1428
2155
|
jQuery.dequeue(this, "fx");
|
1429
|
-
if (
|
1430
|
-
|
2156
|
+
if ( jQuery.isFunction( opt.old ) )
|
2157
|
+
opt.old.apply( this );
|
1431
2158
|
};
|
1432
2159
|
|
1433
|
-
return
|
2160
|
+
return opt;
|
2161
|
+
},
|
2162
|
+
|
2163
|
+
easing: {
|
2164
|
+
linear: function( p, n, firstNum, diff ) {
|
2165
|
+
return firstNum + diff * p;
|
2166
|
+
},
|
2167
|
+
swing: function( p, n, firstNum, diff ) {
|
2168
|
+
return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
|
2169
|
+
}
|
1434
2170
|
},
|
1435
2171
|
|
1436
2172
|
queue: {},
|
@@ -1449,6 +2185,8 @@ jQuery.extend({
|
|
1449
2185
|
}
|
1450
2186
|
},
|
1451
2187
|
|
2188
|
+
timers: [],
|
2189
|
+
|
1452
2190
|
/*
|
1453
2191
|
* I originally wrote fx() as a clone of moo.fx and in the process
|
1454
2192
|
* of making it small in size the code became illegible to sane
|
@@ -1456,468 +2194,151 @@ jQuery.extend({
|
|
1456
2194
|
*/
|
1457
2195
|
|
1458
2196
|
fx: function( elem, options, prop ){
|
1459
|
-
|
2197
|
+
|
1460
2198
|
var z = this;
|
1461
|
-
|
1462
|
-
// The users options
|
1463
|
-
z.o = {
|
1464
|
-
duration: options.duration || 400,
|
1465
|
-
complete: options.complete,
|
1466
|
-
step: options.step
|
1467
|
-
};
|
1468
|
-
|
1469
|
-
// The element
|
1470
|
-
z.el = elem;
|
1471
|
-
|
2199
|
+
|
1472
2200
|
// The styles
|
1473
|
-
var y =
|
1474
|
-
|
2201
|
+
var y = elem.style;
|
2202
|
+
|
1475
2203
|
// Simple function for setting a style value
|
1476
2204
|
z.a = function(){
|
1477
2205
|
if ( options.step )
|
1478
2206
|
options.step.apply( elem, [ z.now ] );
|
1479
|
-
|
2207
|
+
|
1480
2208
|
if ( prop == "opacity" )
|
1481
2209
|
jQuery.attr(y, "opacity", z.now); // Let attr handle opacity
|
1482
|
-
else
|
2210
|
+
else {
|
1483
2211
|
y[prop] = parseInt(z.now) + "px";
|
1484
|
-
|
1485
|
-
|
2212
|
+
y.display = "block"; // Set display property to block for animation
|
2213
|
+
}
|
1486
2214
|
};
|
1487
|
-
|
2215
|
+
|
1488
2216
|
// Figure out the maximum number to run to
|
1489
2217
|
z.max = function(){
|
1490
|
-
return parseFloat( jQuery.css(
|
2218
|
+
return parseFloat( jQuery.css(elem,prop) );
|
1491
2219
|
};
|
1492
|
-
|
2220
|
+
|
1493
2221
|
// Get the current size
|
1494
2222
|
z.cur = function(){
|
1495
|
-
var r = parseFloat( jQuery.curCSS(
|
2223
|
+
var r = parseFloat( jQuery.curCSS(elem, prop) );
|
1496
2224
|
return r && r > -10000 ? r : z.max();
|
1497
2225
|
};
|
1498
|
-
|
2226
|
+
|
1499
2227
|
// Start an animation from one number to another
|
1500
2228
|
z.custom = function(from,to){
|
1501
2229
|
z.startTime = (new Date()).getTime();
|
1502
2230
|
z.now = from;
|
1503
2231
|
z.a();
|
1504
|
-
|
1505
|
-
|
1506
|
-
z.step(from, to);
|
1507
|
-
}
|
2232
|
+
|
2233
|
+
jQuery.timers.push(function(){
|
2234
|
+
return z.step(from, to);
|
2235
|
+
});
|
2236
|
+
|
2237
|
+
if ( jQuery.timers.length == 1 ) {
|
2238
|
+
var timer = setInterval(function(){
|
2239
|
+
var timers = jQuery.timers;
|
2240
|
+
|
2241
|
+
for ( var i = 0; i < timers.length; i++ )
|
2242
|
+
if ( !timers[i]() )
|
2243
|
+
timers.splice(i--, 1);
|
2244
|
+
|
2245
|
+
if ( !timers.length )
|
2246
|
+
clearInterval( timer );
|
2247
|
+
}, 13);
|
2248
|
+
}
|
1508
2249
|
};
|
1509
|
-
|
2250
|
+
|
1510
2251
|
// Simple 'show' function
|
1511
|
-
z.show = function(
|
1512
|
-
if ( !
|
2252
|
+
z.show = function(){
|
2253
|
+
if ( !elem.orig ) elem.orig = {};
|
1513
2254
|
|
1514
2255
|
// Remember where we started, so that we can go back to it later
|
1515
|
-
|
1516
|
-
|
2256
|
+
elem.orig[prop] = jQuery.attr( elem.style, prop );
|
2257
|
+
|
2258
|
+
options.show = true;
|
2259
|
+
|
1517
2260
|
// Begin the animation
|
1518
|
-
|
1519
|
-
z.custom(z.el.orig[prop], 1);
|
1520
|
-
else
|
1521
|
-
z.custom(0, z.el.orig[prop]);
|
2261
|
+
z.custom(0, this.cur());
|
1522
2262
|
|
1523
|
-
//
|
2263
|
+
// Make sure that we start at a small width/height to avoid any
|
2264
|
+
// flash of content
|
1524
2265
|
if ( prop != "opacity" )
|
1525
2266
|
y[prop] = "1px";
|
2267
|
+
|
2268
|
+
// Start by showing the element
|
2269
|
+
jQuery(elem).show();
|
1526
2270
|
};
|
1527
|
-
|
2271
|
+
|
1528
2272
|
// Simple 'hide' function
|
1529
2273
|
z.hide = function(){
|
1530
|
-
if ( !
|
2274
|
+
if ( !elem.orig ) elem.orig = {};
|
1531
2275
|
|
1532
2276
|
// Remember where we started, so that we can go back to it later
|
1533
|
-
|
2277
|
+
elem.orig[prop] = jQuery.attr( elem.style, prop );
|
1534
2278
|
|
1535
|
-
|
2279
|
+
options.hide = true;
|
1536
2280
|
|
1537
2281
|
// Begin the animation
|
1538
|
-
z.custom(
|
2282
|
+
z.custom(this.cur(), 0);
|
1539
2283
|
};
|
1540
|
-
|
1541
|
-
// Remember the overflow of the element
|
1542
|
-
if ( !z.el.oldOverlay )
|
1543
|
-
z.el.oldOverflow = jQuery.css( z.el, "overflow" );
|
1544
|
-
|
1545
|
-
// Make sure that nothing sneaks out
|
1546
|
-
y.overflow = "hidden";
|
1547
|
-
|
2284
|
+
|
1548
2285
|
// Each step of an animation
|
1549
2286
|
z.step = function(firstNum, lastNum){
|
1550
2287
|
var t = (new Date()).getTime();
|
1551
|
-
|
1552
|
-
if (t > z.o.duration + z.startTime) {
|
1553
|
-
// Stop the timer
|
1554
|
-
clearInterval(z.timer);
|
1555
|
-
z.timer = null;
|
1556
2288
|
|
2289
|
+
if (t > options.duration + z.startTime) {
|
1557
2290
|
z.now = lastNum;
|
1558
2291
|
z.a();
|
1559
2292
|
|
1560
|
-
|
1561
|
-
|
2293
|
+
if (elem.curAnim) elem.curAnim[ prop ] = true;
|
2294
|
+
|
1562
2295
|
var done = true;
|
1563
|
-
for ( var i in
|
1564
|
-
if (
|
2296
|
+
for ( var i in elem.curAnim )
|
2297
|
+
if ( elem.curAnim[i] !== true )
|
1565
2298
|
done = false;
|
1566
|
-
|
2299
|
+
|
1567
2300
|
if ( done ) {
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
// Hide the element if the "hide" operation was done
|
1572
|
-
if ( z.o.hide )
|
1573
|
-
y.display = 'none';
|
2301
|
+
if ( options.display != null ) {
|
2302
|
+
// Reset the overflow
|
2303
|
+
y.overflow = options.overflow;
|
1574
2304
|
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
jQuery.attr(y, p, z.el.orig[p]);
|
1580
|
-
else
|
1581
|
-
y[ p ] = z.el.orig[p] + "px";
|
1582
|
-
|
1583
|
-
// set its height and/or width to auto
|
1584
|
-
if ( p == 'height' || p == 'width' )
|
1585
|
-
jQuery.setAuto( z.el, p );
|
1586
|
-
}
|
2305
|
+
// Reset the display
|
2306
|
+
y.display = options.display;
|
2307
|
+
if ( jQuery.css(elem, "display") == "none" )
|
2308
|
+
y.display = "block";
|
1587
2309
|
}
|
2310
|
+
|
2311
|
+
// Hide the element if the "hide" operation was done
|
2312
|
+
if ( options.hide )
|
2313
|
+
y.display = "none";
|
2314
|
+
|
2315
|
+
// Reset the properties, if the item has been hidden or shown
|
2316
|
+
if ( options.hide || options.show )
|
2317
|
+
for ( var p in elem.curAnim )
|
2318
|
+
jQuery.attr(y, p, elem.orig[p]);
|
1588
2319
|
}
|
1589
2320
|
|
1590
2321
|
// If a callback was provided, execute it
|
1591
|
-
if( done &&
|
2322
|
+
if ( done && jQuery.isFunction( options.complete ) )
|
1592
2323
|
// Execute the complete function
|
1593
|
-
|
2324
|
+
options.complete.apply( elem );
|
2325
|
+
|
2326
|
+
return false;
|
1594
2327
|
} else {
|
2328
|
+
var n = t - this.startTime;
|
1595
2329
|
// Figure out where in the animation we are and set the number
|
1596
|
-
var p =
|
1597
|
-
|
1598
|
-
|
2330
|
+
var p = n / options.duration;
|
2331
|
+
|
2332
|
+
// Perform the easing function, defaults to swing
|
2333
|
+
z.now = jQuery.easing[options.easing](p, n, firstNum, (lastNum-firstNum), options.duration);
|
2334
|
+
|
1599
2335
|
// Perform the next step of the animation
|
1600
2336
|
z.a();
|
1601
2337
|
}
|
1602
|
-
};
|
1603
|
-
|
1604
|
-
}
|
1605
|
-
|
1606
|
-
});
|
1607
|
-
jQuery.fn.extend({
|
1608
|
-
loadIfModified: function( url, params, callback ) {
|
1609
|
-
this.load( url, params, callback, 1 );
|
1610
|
-
},
|
1611
|
-
load: function( url, params, callback, ifModified ) {
|
1612
|
-
if ( url.constructor == Function )
|
1613
|
-
return this.bind("load", url);
|
1614
|
-
|
1615
|
-
callback = callback || function(){};
|
1616
|
-
|
1617
|
-
// Default to a GET request
|
1618
|
-
var type = "GET";
|
1619
|
-
|
1620
|
-
// If the second parameter was provided
|
1621
|
-
if ( params ) {
|
1622
|
-
// If it's a function
|
1623
|
-
if ( params.constructor == Function ) {
|
1624
|
-
// We assume that it's the callback
|
1625
|
-
callback = params;
|
1626
|
-
params = null;
|
1627
|
-
|
1628
|
-
// Otherwise, build a param string
|
1629
|
-
} else {
|
1630
|
-
params = jQuery.param( params );
|
1631
|
-
type = "POST";
|
1632
|
-
}
|
1633
|
-
}
|
1634
|
-
|
1635
|
-
var self = this;
|
1636
|
-
|
1637
|
-
// Request the remote document
|
1638
|
-
jQuery.ajax( type, url, params,function(res, status){
|
1639
|
-
|
1640
|
-
if ( status == "success" || !ifModified && status == "notmodified" ) {
|
1641
|
-
// Inject the HTML into all the matched elements
|
1642
|
-
self.html(res.responseText).each( callback, [res.responseText, status] );
|
1643
|
-
|
1644
|
-
// Execute all the scripts inside of the newly-injected HTML
|
1645
|
-
jQuery("script", self).each(function(){
|
1646
|
-
if ( this.src )
|
1647
|
-
jQuery.getScript( this.src );
|
1648
|
-
else
|
1649
|
-
eval.call( window, this.text || this.textContent || this.innerHTML || "" );
|
1650
|
-
});
|
1651
|
-
} else
|
1652
|
-
callback.apply( self, [res.responseText, status] );
|
1653
|
-
|
1654
|
-
}, ifModified);
|
1655
|
-
|
1656
|
-
return this;
|
1657
|
-
},
|
1658
|
-
serialize: function() {
|
1659
|
-
return jQuery.param( this );
|
1660
|
-
}
|
1661
|
-
|
1662
|
-
});
|
1663
|
-
|
1664
|
-
// If IE is used, create a wrapper for the XMLHttpRequest object
|
1665
|
-
if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
|
1666
|
-
XMLHttpRequest = function(){
|
1667
|
-
return new ActiveXObject(
|
1668
|
-
navigator.userAgent.indexOf("MSIE 5") >= 0 ?
|
1669
|
-
"Microsoft.XMLHTTP" : "Msxml2.XMLHTTP"
|
1670
|
-
);
|
1671
|
-
};
|
1672
|
-
|
1673
|
-
// Attach a bunch of functions for handling common AJAX events
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
new function(){
|
1678
|
-
var e = "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess".split(",");
|
1679
|
-
|
1680
|
-
for ( var i = 0; i < e.length; i++ ) new function(){
|
1681
|
-
var o = e[i];
|
1682
|
-
jQuery.fn[o] = function(f){
|
1683
|
-
return this.bind(o, f);
|
1684
|
-
};
|
1685
|
-
};
|
1686
|
-
};
|
1687
|
-
|
1688
|
-
jQuery.extend({
|
1689
|
-
get: function( url, data, callback, type, ifModified ) {
|
1690
|
-
if ( data.constructor == Function ) {
|
1691
|
-
type = callback;
|
1692
|
-
callback = data;
|
1693
|
-
data = null;
|
1694
|
-
}
|
1695
|
-
|
1696
|
-
// append ? + data or & + data, in case there are already params
|
1697
|
-
if ( data ) url += ((url.indexOf("?") > -1) ? "&" : "?") + jQuery.param(data);
|
1698
|
-
|
1699
|
-
// Build and start the HTTP Request
|
1700
|
-
jQuery.ajax( "GET", url, null, function(r, status) {
|
1701
|
-
if ( callback ) callback( jQuery.httpData(r,type), status );
|
1702
|
-
}, ifModified);
|
1703
|
-
},
|
1704
|
-
getIfModified: function( url, data, callback, type ) {
|
1705
|
-
jQuery.get(url, data, callback, type, 1);
|
1706
|
-
},
|
1707
|
-
getScript: function( url, callback ) {
|
1708
|
-
jQuery.get(url, callback, "script");
|
1709
|
-
},
|
1710
|
-
getJSON: function( url, data, callback ) {
|
1711
|
-
if(callback)
|
1712
|
-
jQuery.get(url, data, callback, "json");
|
1713
|
-
else {
|
1714
|
-
jQuery.get(url, data, "json");
|
1715
|
-
}
|
1716
|
-
},
|
1717
|
-
post: function( url, data, callback, type ) {
|
1718
|
-
// Build and start the HTTP Request
|
1719
|
-
jQuery.ajax( "POST", url, jQuery.param(data), function(r, status) {
|
1720
|
-
if ( callback ) callback( jQuery.httpData(r,type), status );
|
1721
|
-
});
|
1722
|
-
},
|
1723
|
-
|
1724
|
-
// timeout (ms)
|
1725
|
-
timeout: 0,
|
1726
|
-
ajaxTimeout: function(timeout) {
|
1727
|
-
jQuery.timeout = timeout;
|
1728
|
-
},
|
1729
|
-
|
1730
|
-
// Last-Modified header cache for next request
|
1731
|
-
lastModified: {},
|
1732
|
-
ajax: function( type, url, data, ret, ifModified ) {
|
1733
|
-
// If only a single argument was passed in,
|
1734
|
-
// assume that it is a object of key/value pairs
|
1735
|
-
if ( !url ) {
|
1736
|
-
ret = type.complete;
|
1737
|
-
var success = type.success;
|
1738
|
-
var error = type.error;
|
1739
|
-
var dataType = type.dataType;
|
1740
|
-
var global = typeof type.global == "boolean" ? type.global : true;
|
1741
|
-
var timeout = typeof type.timeout == "number" ? type.timeout : jQuery.timeout;
|
1742
|
-
var ifModified = type.ifModified || false;
|
1743
|
-
data = type.data;
|
1744
|
-
url = type.url;
|
1745
|
-
type = type.type;
|
1746
|
-
}
|
1747
|
-
|
1748
|
-
// Watch for a new set of requests
|
1749
|
-
if ( global && ! jQuery.active++ )
|
1750
|
-
jQuery.event.trigger( "ajaxStart" );
|
1751
|
-
|
1752
|
-
var requestDone = false;
|
1753
|
-
|
1754
|
-
// Create the request object
|
1755
|
-
var xml = new XMLHttpRequest();
|
1756
|
-
|
1757
|
-
// Open the socket
|
1758
|
-
xml.open(type || "GET", url, true);
|
1759
|
-
|
1760
|
-
// Set the correct header, if data is being sent
|
1761
|
-
if ( data )
|
1762
|
-
xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
1763
|
-
|
1764
|
-
// Set the If-Modified-Since header, if ifModified mode.
|
1765
|
-
if ( ifModified )
|
1766
|
-
xml.setRequestHeader("If-Modified-Since",
|
1767
|
-
jQuery.lastModified[url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
|
1768
|
-
|
1769
|
-
// Set header so the called script knows that it's an XMLHttpRequest
|
1770
|
-
xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
1771
|
-
|
1772
|
-
// Make sure the browser sends the right content length
|
1773
|
-
if ( xml.overrideMimeType )
|
1774
|
-
xml.setRequestHeader("Connection", "close");
|
1775
|
-
|
1776
|
-
// Wait for a response to come back
|
1777
|
-
var onreadystatechange = function(istimeout){
|
1778
|
-
// The transfer is complete and the data is available, or the request timed out
|
1779
|
-
if ( xml && (xml.readyState == 4 || istimeout == "timeout") ) {
|
1780
|
-
requestDone = true;
|
1781
2338
|
|
1782
|
-
|
1783
|
-
ifModified && jQuery.httpNotModified( xml, url ) ? "notmodified" : "success" : "error";
|
1784
|
-
|
1785
|
-
// Make sure that the request was successful or notmodified
|
1786
|
-
if ( status != "error" ) {
|
1787
|
-
// Cache Last-Modified header, if ifModified mode.
|
1788
|
-
var modRes;
|
1789
|
-
try {
|
1790
|
-
modRes = xml.getResponseHeader("Last-Modified");
|
1791
|
-
} catch(e) {} // swallow exception thrown by FF if header is not available
|
1792
|
-
|
1793
|
-
if ( ifModified && modRes )
|
1794
|
-
jQuery.lastModified[url] = modRes;
|
1795
|
-
|
1796
|
-
// If a local callback was specified, fire it
|
1797
|
-
if ( success )
|
1798
|
-
success( jQuery.httpData( xml, dataType ), status );
|
1799
|
-
|
1800
|
-
// Fire the global callback
|
1801
|
-
if( global )
|
1802
|
-
jQuery.event.trigger( "ajaxSuccess" );
|
1803
|
-
|
1804
|
-
// Otherwise, the request was not successful
|
1805
|
-
} else {
|
1806
|
-
// If a local callback was specified, fire it
|
1807
|
-
if ( error ) error( xml, status );
|
1808
|
-
|
1809
|
-
// Fire the global callback
|
1810
|
-
if( global )
|
1811
|
-
jQuery.event.trigger( "ajaxError" );
|
1812
|
-
}
|
1813
|
-
|
1814
|
-
// The request was completed
|
1815
|
-
if( global )
|
1816
|
-
jQuery.event.trigger( "ajaxComplete" );
|
1817
|
-
|
1818
|
-
// Handle the global AJAX counter
|
1819
|
-
if ( global && ! --jQuery.active )
|
1820
|
-
jQuery.event.trigger( "ajaxStop" );
|
1821
|
-
|
1822
|
-
// Process result
|
1823
|
-
if ( ret ) ret(xml, status);
|
1824
|
-
|
1825
|
-
// Stop memory leaks
|
1826
|
-
xml.onreadystatechange = function(){};
|
1827
|
-
xml = null;
|
1828
|
-
|
1829
|
-
}
|
2339
|
+
return true;
|
1830
2340
|
};
|
1831
|
-
xml.onreadystatechange = onreadystatechange;
|
1832
|
-
|
1833
|
-
// Timeout checker
|
1834
|
-
if(timeout > 0)
|
1835
|
-
setTimeout(function(){
|
1836
|
-
// Check to see if the request is still happening
|
1837
|
-
if (xml) {
|
1838
|
-
// Cancel the request
|
1839
|
-
xml.abort();
|
1840
|
-
|
1841
|
-
if ( !requestDone ) onreadystatechange( "timeout" );
|
1842
|
-
|
1843
|
-
// Clear from memory
|
1844
|
-
xml = null;
|
1845
|
-
}
|
1846
|
-
}, timeout);
|
1847
|
-
|
1848
|
-
// Send the data
|
1849
|
-
xml.send(data);
|
1850
|
-
},
|
1851
|
-
|
1852
|
-
// Counter for holding the number of active queries
|
1853
|
-
active: 0,
|
1854
|
-
|
1855
|
-
// Determines if an XMLHttpRequest was successful or not
|
1856
|
-
httpSuccess: function(r) {
|
1857
|
-
try {
|
1858
|
-
return !r.status && location.protocol == "file:" ||
|
1859
|
-
( r.status >= 200 && r.status < 300 ) || r.status == 304 ||
|
1860
|
-
jQuery.browser.safari && r.status == undefined;
|
1861
|
-
} catch(e){}
|
1862
|
-
|
1863
|
-
return false;
|
1864
|
-
},
|
1865
|
-
|
1866
|
-
// Determines if an XMLHttpRequest returns NotModified
|
1867
|
-
httpNotModified: function(xml, url) {
|
1868
|
-
try {
|
1869
|
-
var xmlRes = xml.getResponseHeader("Last-Modified");
|
1870
|
-
|
1871
|
-
// Firefox always returns 200. check Last-Modified date
|
1872
|
-
return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
|
1873
|
-
jQuery.browser.safari && xml.status == undefined;
|
1874
|
-
} catch(e){}
|
1875
|
-
|
1876
|
-
return false;
|
1877
|
-
},
|
1878
|
-
|
1879
|
-
/* Get the data out of an XMLHttpRequest.
|
1880
|
-
* Return parsed XML if content-type header is "xml" and type is "xml" or omitted,
|
1881
|
-
* otherwise return plain text.
|
1882
|
-
* (String) data - The type of data that you're expecting back,
|
1883
|
-
* (e.g. "xml", "html", "script")
|
1884
|
-
*/
|
1885
|
-
httpData: function(r,type) {
|
1886
|
-
var ct = r.getResponseHeader("content-type");
|
1887
|
-
var data = !type && ct && ct.indexOf("xml") >= 0;
|
1888
|
-
data = type == "xml" || data ? r.responseXML : r.responseText;
|
1889
|
-
|
1890
|
-
// If the type is "script", eval it
|
1891
|
-
if ( type == "script" ) eval.call( window, data );
|
1892
|
-
|
1893
|
-
// Get the JavaScript object, if JSON is used.
|
1894
|
-
if ( type == "json" ) eval( "data = " + data );
|
1895
|
-
|
1896
|
-
return data;
|
1897
|
-
},
|
1898
2341
|
|
1899
|
-
// Serialize an array of form elements or a set of
|
1900
|
-
// key/values into a query string
|
1901
|
-
param: function(a) {
|
1902
|
-
var s = [];
|
1903
|
-
|
1904
|
-
// If an array was passed in, assume that it is an array
|
1905
|
-
// of form elements
|
1906
|
-
if ( a.constructor == Array || a.jquery ) {
|
1907
|
-
// Serialize the form elements
|
1908
|
-
for ( var i = 0; i < a.length; i++ )
|
1909
|
-
s.push( a[i].name + "=" + encodeURIComponent( a[i].value ) );
|
1910
|
-
|
1911
|
-
// Otherwise, assume that it's an object of key/value pairs
|
1912
|
-
} else {
|
1913
|
-
// Serialize the key/values
|
1914
|
-
for ( var j in a )
|
1915
|
-
s.push( j + "=" + encodeURIComponent( a[j] ) );
|
1916
|
-
}
|
1917
|
-
|
1918
|
-
// Return the resulting serialization
|
1919
|
-
return s.join("&");
|
1920
2342
|
}
|
1921
|
-
|
1922
2343
|
});
|
1923
|
-
}
|
2344
|
+
}
|