ajax 1.0.8 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -3
- data/Gemfile.lock +34 -8
- data/README.rdoc +76 -63
- data/Rakefile +3 -1
- data/VERSION +1 -1
- data/app/controllers/ajax_controller.rb +6 -0
- data/init.rb +6 -0
- data/lib/ajax.rb +13 -24
- data/lib/ajax/action_controller.rb +120 -65
- data/lib/ajax/application.rb +62 -0
- data/lib/ajax/helpers/request_helper.rb +2 -2
- data/lib/ajax/helpers/task_helper.rb +2 -2
- data/lib/ajax/railtie.rb +25 -1
- data/lib/ajax/routes.rb +7 -3
- data/lib/ajax/rspec.rb +2 -0
- data/lib/ajax/{spec → rspec}/extension.rb +4 -11
- data/lib/ajax/{spec → rspec}/helpers.rb +10 -10
- data/lib/ajax/rspec/integration.rb +24 -0
- data/lib/rack-ajax.rb +1 -1
- data/lib/rack-ajax/parser.rb +2 -2
- data/public/javascripts/{jquery.address-1.2rc.js → jquery.address-1.3.js} +340 -197
- data/public/javascripts/jquery.address-1.3.min.js +32 -0
- data/rails/init.rb +1 -4
- data/rails/install.rb +1 -1
- data/rails/routes.rb +6 -0
- data/tasks/ajax_tasks.rake +11 -2
- metadata +41 -25
- data/app/views/ajax/_redirect_with_fragment.html.erb +0 -19
- data/public/javascripts/jquery.address-1.1.js +0 -450
- data/public/javascripts/jquery.address-1.1.min.js +0 -11
- data/public/javascripts/jquery.address-1.2.js +0 -528
- data/public/javascripts/jquery.address-1.2.min.js +0 -25
- data/public/javascripts/jquery.address-1.2rc.min.js +0 -27
- data/rails/uninstall.rb +0 -1
- data/spec/ajax/ajax_spec.rb +0 -23
- data/spec/ajax/helpers_spec.rb +0 -121
- data/spec/ajax/request_helper_spec.rb +0 -52
- data/spec/ajax/tasks_spec.rb +0 -48
- data/spec/integration/ajax_spec.rb +0 -146
- data/spec/rack-ajax/parser_spec.rb +0 -62
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -17
- data/spec/support/file_macros.rb +0 -28
- data/spec/support/query_count.rb +0 -0
- data/spec/support/response_helpers.rb +0 -7
@@ -1,11 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* jQuery Address Plugin v1.1
|
3
|
-
* http://www.asual.com/jquery/address/
|
4
|
-
*
|
5
|
-
* Copyright (c) 2009 Rostislav Hristov
|
6
|
-
* Dual licensed under the MIT and GPL licenses.
|
7
|
-
* http://docs.jquery.com/License
|
8
|
-
*
|
9
|
-
* Date: 2009-12-23 14:27:00 +0200 (Wed, 23 Dec 2009)
|
10
|
-
*/
|
11
|
-
(function(a){a.address=(function(){var c=function(i){a(this).trigger(a.extend(a.Event(i),(function(){var ah={value:this.value(),path:this.path(),pathNames:this.pathNames(),parameterNames:this.parameterNames(),parameters:{},queryString:this.queryString()};for(var ag=0,p=ah.parameterNames.length;ag<p;ag++){ah.parameters[ah.parameterNames[ag]]=this.parameter(ah.parameterNames[ag])}return ah}).call(this)))};var V=function(){c.call(a.address,"init")};var o=function(){c.call(a.address,"change")};var P=function(){var i=U.href.indexOf("#");return i!=-1?ae(q(U.href.substr(i+1))):""};var h=function(){try{return top.document!=undefined?top:window}catch(i){return window}};var F=function(p,i){if(C.strict){p=i?(p.substr(0,1)!="/"?"/"+p:p):(p==""?"/":p)}return p};var r=function(i,p){return(j&&U.protocol=="file:")?(p?Q.replace(/\?/,"%3F"):Q.replace(/%253F/,"?")):i};var af=function(ai){for(var ag=0,p=ai.childNodes.length,ah;ag<p;ag++){if(ai.childNodes[ag].src){l=String(ai.childNodes[ag].src)}if(ah=af(ai.childNodes[ag])){return ah}}};var X=function(){if(!t){var p=P();var i=!(Q==p);if(u&&s<523){if(E!=Y.length){E=Y.length;if(typeof z[E-1]!=G){Q=z[E-1]}T(false)}}else{if(j&&s<7&&i){U.reload()}else{if(i){Q=p;T(false)}}}}};var T=function(i){o();if(i){c.call(a.address,"internalChange")}else{c.call(a.address,"externalChange")}n(w,10)};var w=function(){var p=(U.pathname+(/\/$/.test(U.pathname)?"":"/")+D.value()).replace(/\/\//,"/").replace(/^\/$/,"");var i=window[C.tracker];if(typeof i==g){i(p)}else{if(typeof pageTracker!=G&&typeof pageTracker._trackPageview==g){pageTracker._trackPageview(p)}else{if(typeof urchinTracker==g){urchinTracker(p)}}}};var e=function(){var i=f.contentWindow.document;i.open();i.write("<html><head><title>"+ac.title+"</title><script>var "+x+' = "'+P()+'";<\/script></head></html>');i.close()};var N=function(){if(!S){S=B;if(j&&s<8){var i=ac.getElementsByTagName("frameset")[0];f=ac.createElement((i?"":"i")+"frame");if(i){i.insertAdjacentElement("beforeEnd",f);i[i.cols?"cols":"rows"]+=",0";f.src="javascript:false";f.noResize=true;f.frameBorder=f.frameSpacing=0}else{f.src="javascript:false";f.style.display="none";ac.body.insertAdjacentElement("afterBegin",f)}n(function(){a(f).bind("load",function(){var p=f.contentWindow;var ag=p.location.href;Q=(typeof p[x]!=G?p[x]:"");if(Q!=P()){T(false);U.hash=r(Q,B)}});if(typeof f.contentWindow[x]==G){e()}},50)}else{if(u){if(s<418){a(ac.body).append('<form id="'+x+'" style="position:absolute;top:-9999px;" method="get"></form>');J=ac.getElementById(x)}if(typeof U[x]==G){U[x]={}}if(typeof U[x][U.pathname]!=G){z=U[x][U.pathname].split(",")}}}n(function(){V();T(false)},1);if(j&&s>=8){ac.body.onhashchange=X}else{v(X,50)}a("a[rel*=address:]").address()}};var D={baseURL:function(){var i=U.href;if(i.indexOf("#")!=-1){i=i.substr(0,i.indexOf("#"))}if(i.substr(i.length-1)=="/"){i=i.substr(0,i.length-1)}return i},strict:function(){return C.strict},history:function(){return C.history},tracker:function(){return C.tracker},title:function(){return ac.title},value:function(){if(!ab){return null}return q(F(r(Q,Z),Z))},path:function(){var i=this.value();return(i.indexOf("?")!=-1)?i.split("?")[0]:i},pathNames:function(){var p=this.path();var i=p.split("/");if(p.substr(0,1)=="/"||p.length==0){i.splice(0,1)}if(p.substr(p.length-1,1)=="/"){i.splice(i.length-1,1)}return i},queryString:function(){var p=this.value();var i=p.indexOf("?");if(i!=-1&&i<p.length){return p.substr(i+1)}},parameter:function(am){var aj=this.value();var ag=aj.indexOf("?");if(ag!=-1){aj=aj.substr(ag+1);var al=aj.split("&");var ak,ah=al.length,ai=[];while(ah--){ak=al[ah].split("=");if(ak[0]==am){ai.push(ak[1])}}if(ai.length!=0){return ai.length!=1?ai:ai[0]}}},parameterNames:function(){var ah=this.value();var p=ah.indexOf("?");var ai=[];if(p!=-1){ah=ah.substr(p+1);if(ah!=""&&ah.indexOf("=")!=-1){var aj=ah.split("&");var ag=0;while(ag<aj.length){ai.push(aj[ag].split("=")[0]);ag++}}}return ai}};var H={strict:function(i){C.strict=i},history:function(i){C.history=i},tracker:function(i){C.tracker=i},title:function(i){i=q(i);n(function(){I=ac.title=i;if(K&&f&&f.contentWindow&&f.contentWindow.document){f.contentWindow.document.title=i;K=Z}if(!M&&aa){U.replace(U.href.indexOf("#")!=-1?U.href:U.href+"#")}M=Z},50)},value:function(ag){ag=ae(q(F(ag,B)));if(ag=="/"){ag=""}if(Q==ag){return}M=B;Q=ag;t=B;T(true);z[Y.length]=Q;if(u){if(C.history){U[x][U.pathname]=z.toString();E=Y.length+1;if(s<418){if(U.search==""){J.action="#"+Q;J.submit()}}else{if(s<523||Q==""){var i=ac.createEvent("MouseEvents");i.initEvent("click",B,B);var p=ac.createElement("a");p.href="#"+Q;p.dispatchEvent(i)}else{U.hash="#"+Q}}}else{U.replace("#"+Q)}}else{if(Q!=P()){if(C.history){U.hash="#"+r(Q,B)}else{U.replace("#"+Q)}}}if((j&&s<8)&&C.history){n(e,50)}if(u){n(function(){t=Z},1)}else{t=Z}}};var x="jQueryAddress",g="function",G="undefined",B=true,Z=false,A=a.browser,s=parseFloat(a.browser.version),aa=A.mozilla,j=A.msie,L=A.opera,u=A.safari,ab=Z,O=h(),ac=O.document,Y=O.history,U=O.location,v=setInterval,n=setTimeout,q=decodeURI,ae=encodeURI,ad=navigator.userAgent,f,J,l,I=ac.title,E=Y.length,t=Z,S=Z,M=B,K=B,z=[],y={},Q=P(),k={},C={history:B,strict:B};if(j){s=parseFloat(ad.substr(ad.indexOf("MSIE")+4));if(ac.documentMode&&ac.documentMode!=s){s=ac.documentMode!=8?7:8}}ab=(aa&&s>=1)||(j&&s>=6)||(L&&s>=9.5)||(u&&s>=312);if(ab){for(var W=1;W<E;W++){z.push("")}z.push(P());if(j&&U.hash!=P()){U.hash="#"+r(P(),B)}if(L){history.navigationMode="compatible"}af(document);var b=l.indexOf("?");if(l&&b>-1){var m,d=l.substr(b+1).split("&");for(var W=0,R;R=d[W];W++){m=R.split("=");if(/^(history|strict)$/.test(m[0])){C[m[0]]=(isNaN(m[1])?/^(true|yes)$/i.test(m[1]):(parseInt(m[1])!=0))}if(/^tracker$/.test(m[0])){C[m[0]]=m[1]}}}a(N)}else{if((!ab&&U.href.indexOf("#")!=-1)||(u&&s<418&&U.href.indexOf("#")!=-1&&U.search!="")){ac.open();ac.write('<html><head><meta http-equiv="refresh" content="0;url='+U.href.substr(0,U.href.indexOf("#"))+'" /></head></html>');ac.close()}else{w()}}a.each(("init,change,internalChange,externalChange").split(","),function(ag,p){k[p]=function(ah,i){a(a.address).bind(p,i||ah,i&&ah);return this}});a.each(("strict,history,tracker,title,value").split(","),function(ag,p){k[p]=function(i){if(typeof i!="undefined"){if(ab){H[p](i)}return a.address}else{return D[p]()}}});a.each(("baseURL,path,pathNames,queryString,parameter,parameterNames").split(","),function(ag,p){k[p]=function(i){return D[p](i)}});return k})();a.fn.address=function(b){a(this).click(function(){var c=b?b.call(this):/address:/.test(a(this).attr("rel"))?a(this).attr("rel").split("address:")[1].split(" ")[0]:a(this).attr("href").replace(/^#/,"");a.address.value(c);return false})}}(jQuery));
|
@@ -1,528 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* jQuery Address Plugin v1.2
|
3
|
-
* http://www.asual.com/jquery/address/
|
4
|
-
*
|
5
|
-
* Copyright (c) 2009-2010 Rostislav Hristov
|
6
|
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
7
|
-
* http://jquery.org/license
|
8
|
-
*
|
9
|
-
* Date: 2010-03-03 21:24:30 +0200 (Wed, 03 Mar 2010)
|
10
|
-
*/
|
11
|
-
(function ($) {
|
12
|
-
|
13
|
-
$.address = (function () {
|
14
|
-
|
15
|
-
var _trigger = function(name) {
|
16
|
-
$($.address).trigger(
|
17
|
-
$.extend($.Event(name),
|
18
|
-
(function() {
|
19
|
-
var parameters = {},
|
20
|
-
parameterNames = $.address.parameterNames();
|
21
|
-
for (var i = 0, l = parameterNames.length; i < l; i++) {
|
22
|
-
parameters[parameterNames[i]] = $.address.parameter(parameterNames[i]);
|
23
|
-
}
|
24
|
-
return {
|
25
|
-
value: $.address.value(),
|
26
|
-
path: $.address.path(),
|
27
|
-
pathNames: $.address.pathNames(),
|
28
|
-
parameterNames: parameterNames,
|
29
|
-
parameters: parameters,
|
30
|
-
queryString: $.address.queryString()
|
31
|
-
};
|
32
|
-
}).call($.address)
|
33
|
-
)
|
34
|
-
);
|
35
|
-
},
|
36
|
-
_bind = function(value, data, fn) {
|
37
|
-
if (fn || data) {
|
38
|
-
$($.address).bind(value, fn || data, fn && data);
|
39
|
-
}
|
40
|
-
return $.address;
|
41
|
-
},
|
42
|
-
_hash = function() {
|
43
|
-
var index = _l.href.indexOf('#');
|
44
|
-
return index != -1 ? _ec(_dc(_l.href.substr(index + 1))) : '';
|
45
|
-
},
|
46
|
-
_window = function() {
|
47
|
-
try {
|
48
|
-
return top.document !== undefined ? top : window;
|
49
|
-
} catch (e) {
|
50
|
-
return window;
|
51
|
-
}
|
52
|
-
},
|
53
|
-
_js = function() {
|
54
|
-
return 'javascript';
|
55
|
-
},
|
56
|
-
_strict = function(value, force) {
|
57
|
-
if (_opts.strict) {
|
58
|
-
value = force ? (value.substr(0, 1) != '/' ? '/' + value : value) : (value == '' ? '/' : value);
|
59
|
-
}
|
60
|
-
return value;
|
61
|
-
},
|
62
|
-
_local = function(value, direction) {
|
63
|
-
return (_msie && _l.protocol == 'file:') ?
|
64
|
-
(direction ? _value.replace(/\?/, '%3F') : _value.replace(/%253F/, '?')) : value;
|
65
|
-
},
|
66
|
-
_search = function(el) {
|
67
|
-
var url, s;
|
68
|
-
for (var i = 0, l = el.childNodes.length; i < l; i++) {
|
69
|
-
if (el.childNodes[i].src) {
|
70
|
-
url = String(el.childNodes[i].src);
|
71
|
-
}
|
72
|
-
s = _search(el.childNodes[i]);
|
73
|
-
if (s) {
|
74
|
-
url = s;
|
75
|
-
}
|
76
|
-
}
|
77
|
-
return url;
|
78
|
-
},
|
79
|
-
_listen = function() {
|
80
|
-
if (!_silent) {
|
81
|
-
var hash = _hash(),
|
82
|
-
diff = _value != hash;
|
83
|
-
if (_safari && _version < 523) {
|
84
|
-
if (_length != _h.length) {
|
85
|
-
_length = _h.length;
|
86
|
-
if (typeof _stack[_length - 1] != UNDEFINED) {
|
87
|
-
_value = _stack[_length - 1];
|
88
|
-
}
|
89
|
-
_update(FALSE);
|
90
|
-
}
|
91
|
-
} else if (_msie && _version < 7 && diff) {
|
92
|
-
_l.reload();
|
93
|
-
} else if (diff) {
|
94
|
-
_value = hash;
|
95
|
-
_update(FALSE);
|
96
|
-
}
|
97
|
-
}
|
98
|
-
},
|
99
|
-
_update = function(internal) {
|
100
|
-
_trigger('change');
|
101
|
-
_trigger(internal ? 'internalChange' : 'externalChange');
|
102
|
-
_st(_track, 10);
|
103
|
-
},
|
104
|
-
_track = function() {
|
105
|
-
var value = (_l.pathname + (/\/$/.test(_l.pathname) ? '' : '/') + $.address.value()).replace(/\/\//, '/').replace(/^\/$/, ''),
|
106
|
-
fn = window[_opts.tracker];
|
107
|
-
if (typeof fn == FUNCTION) {
|
108
|
-
fn(value);
|
109
|
-
} else if (typeof _gaq != UNDEFINED && typeof _gaq.push == FUNCTION) {
|
110
|
-
_gaq.push(['_trackPageview', value]);
|
111
|
-
} else if (typeof pageTracker != UNDEFINED && typeof pageTracker._trackPageview == FUNCTION) {
|
112
|
-
pageTracker._trackPageview(value);
|
113
|
-
} else if (typeof urchinTracker == FUNCTION) {
|
114
|
-
urchinTracker(value);
|
115
|
-
}
|
116
|
-
},
|
117
|
-
_html = function() {
|
118
|
-
var doc = _frame.contentWindow.document;
|
119
|
-
doc.open();
|
120
|
-
doc.write('<html><head><title>' + _d.title + '</title><script>var ' + ID + ' = "' + _hash() + '";</' + 'script></head></html>');
|
121
|
-
doc.close();
|
122
|
-
},
|
123
|
-
_load = function() {
|
124
|
-
if (!_loaded) {
|
125
|
-
_loaded = TRUE;
|
126
|
-
if (_msie && _version < 8) {
|
127
|
-
var frameset = _d.getElementsByTagName('frameset')[0];
|
128
|
-
_frame = _d.createElement((frameset ? '' : 'i') + 'frame');
|
129
|
-
if (frameset) {
|
130
|
-
frameset.insertAdjacentElement('beforeEnd', _frame);
|
131
|
-
frameset[frameset.cols ? 'cols' : 'rows'] += ',0';
|
132
|
-
_frame.src = _js() + ':' + FALSE;
|
133
|
-
_frame.noResize = TRUE;
|
134
|
-
_frame.frameBorder = _frame.frameSpacing = 0;
|
135
|
-
} else {
|
136
|
-
_frame.src = _js() + ':' + FALSE;
|
137
|
-
_frame.style.display = 'none';
|
138
|
-
_d.body.insertAdjacentElement('afterBegin', _frame);
|
139
|
-
}
|
140
|
-
_st(function() {
|
141
|
-
$(_frame).bind('load', function() {
|
142
|
-
var win = _frame.contentWindow;
|
143
|
-
var src = win.location.href;
|
144
|
-
_value = (typeof win[ID] != UNDEFINED ? win[ID] : '');
|
145
|
-
if (_value != _hash()) {
|
146
|
-
_update(FALSE);
|
147
|
-
_l.hash = _local(_value, TRUE);
|
148
|
-
}
|
149
|
-
});
|
150
|
-
if (typeof _frame.contentWindow[ID] == UNDEFINED) {
|
151
|
-
_html();
|
152
|
-
}
|
153
|
-
}, 50);
|
154
|
-
} else if (_safari) {
|
155
|
-
if (_version < 418) {
|
156
|
-
$(_d.body).append('<form id="' + ID + '" style="position:absolute;top:-9999px;" method="get"></form>');
|
157
|
-
_form = _d.getElementById(ID);
|
158
|
-
}
|
159
|
-
if (typeof _l[ID] == UNDEFINED) {
|
160
|
-
_l[ID] = {};
|
161
|
-
}
|
162
|
-
if (typeof _l[ID][_l.pathname] != UNDEFINED) {
|
163
|
-
_stack = _l[ID][_l.pathname].split(',');
|
164
|
-
}
|
165
|
-
}
|
166
|
-
|
167
|
-
_st(function() {
|
168
|
-
_trigger('init');
|
169
|
-
_update(FALSE);
|
170
|
-
}, 1);
|
171
|
-
|
172
|
-
if ((_msie && _version > 7) || (!_msie && ('on' + HASH_CHANGE) in _t)) {
|
173
|
-
if (_t.addEventListener) {
|
174
|
-
_t.addEventListener(HASH_CHANGE, _listen, false);
|
175
|
-
} else if (_t.attachEvent) {
|
176
|
-
_t.attachEvent('on' + HASH_CHANGE, _listen);
|
177
|
-
}
|
178
|
-
} else {
|
179
|
-
_si(_listen, 50);
|
180
|
-
}
|
181
|
-
$('a[rel*=address:]').address();
|
182
|
-
}
|
183
|
-
},
|
184
|
-
_unload = function() {
|
185
|
-
if (_t.removeEventListener) {
|
186
|
-
_t.removeEventListener(HASH_CHANGE, _listen, false);
|
187
|
-
} else if (_t.detachEvent) {
|
188
|
-
_t.detachEvent('on' + HASH_CHANGE, _listen);
|
189
|
-
}
|
190
|
-
},
|
191
|
-
ID = 'jQueryAddress',
|
192
|
-
FUNCTION = 'function',
|
193
|
-
UNDEFINED = 'undefined',
|
194
|
-
HASH_CHANGE = 'hashchange',
|
195
|
-
TRUE = true,
|
196
|
-
FALSE = false,
|
197
|
-
_browser = $.browser,
|
198
|
-
_version = parseFloat($.browser.version),
|
199
|
-
_mozilla = _browser.mozilla,
|
200
|
-
_msie = _browser.msie,
|
201
|
-
_opera = _browser.opera,
|
202
|
-
_safari = _browser.safari,
|
203
|
-
_supported = FALSE,
|
204
|
-
_t = _window(),
|
205
|
-
_d = _t.document,
|
206
|
-
_h = _t.history,
|
207
|
-
_l = _t.location,
|
208
|
-
_si = setInterval,
|
209
|
-
_st = setTimeout,
|
210
|
-
_dc = decodeURI,
|
211
|
-
_ec = encodeURI,
|
212
|
-
_agent = navigator.userAgent,
|
213
|
-
_frame,
|
214
|
-
_form,
|
215
|
-
_url = _search(document),
|
216
|
-
_qi = _url ? _url.indexOf('?') : -1,
|
217
|
-
_title = _d.title,
|
218
|
-
_length = _h.length,
|
219
|
-
_silent = FALSE,
|
220
|
-
_loaded = FALSE,
|
221
|
-
_justset = TRUE,
|
222
|
-
_juststart = TRUE,
|
223
|
-
_updating = FALSE,
|
224
|
-
_stack = [],
|
225
|
-
_listeners = {},
|
226
|
-
_value = _hash(),
|
227
|
-
_api = {},
|
228
|
-
_opts = {autoUpdate: TRUE, history: TRUE, strict: TRUE};
|
229
|
-
|
230
|
-
if (_msie) {
|
231
|
-
_version = parseFloat(_agent.substr(_agent.indexOf('MSIE') + 4));
|
232
|
-
if (_d.documentMode && _d.documentMode != _version) {
|
233
|
-
_version = _d.documentMode != 8 ? 7 : 8;
|
234
|
-
}
|
235
|
-
}
|
236
|
-
|
237
|
-
_supported =
|
238
|
-
(_mozilla && _version >= 1) ||
|
239
|
-
(_msie && _version >= 6) ||
|
240
|
-
(_opera && _version >= 9.5) ||
|
241
|
-
(_safari && _version >= 312);
|
242
|
-
|
243
|
-
if (_supported) {
|
244
|
-
|
245
|
-
for (var i = 1; i < _length; i++) {
|
246
|
-
_stack.push('');
|
247
|
-
}
|
248
|
-
|
249
|
-
_stack.push(_value);
|
250
|
-
|
251
|
-
if (_msie && _l.hash != _value) {
|
252
|
-
_l.hash = '#' + _local(_value, TRUE);
|
253
|
-
}
|
254
|
-
|
255
|
-
if (_opera) {
|
256
|
-
history.navigationMode = 'compatible';
|
257
|
-
}
|
258
|
-
|
259
|
-
if (_url && _qi != -1) {
|
260
|
-
var param, params = _url.substr(_qi + 1).split('&');
|
261
|
-
for (i = 0; i < params.length; i++) {
|
262
|
-
param = params[i].split('=');
|
263
|
-
if (/^(autoUpdate|history|strict)$/.test(param[0])) {
|
264
|
-
_opts[param[0]] = (isNaN(param[1]) ? /^(true|yes)$/i.test(param[1]) : (parseInt(param[1], 10) !== 0));
|
265
|
-
}
|
266
|
-
if (/^tracker$/.test(param[0])) {
|
267
|
-
_opts[param[0]] = param[1];
|
268
|
-
}
|
269
|
-
}
|
270
|
-
}
|
271
|
-
|
272
|
-
if (document.readyState == 'complete') {
|
273
|
-
_load();
|
274
|
-
}
|
275
|
-
$(_load);
|
276
|
-
$(window).bind('unload', _unload);
|
277
|
-
|
278
|
-
} else if ((!_supported && _l.href.indexOf('#') != -1) ||
|
279
|
-
(_safari && _version < 418 && _l.href.indexOf('#') != -1 && _l.search != '')) {
|
280
|
-
_d.open();
|
281
|
-
_d.write('<html><head><meta http-equiv="refresh" content="0;url=' +
|
282
|
-
_l.href.substr(0, _l.href.indexOf('#')) + '" /></head></html>');
|
283
|
-
_d.close();
|
284
|
-
} else {
|
285
|
-
_track();
|
286
|
-
}
|
287
|
-
|
288
|
-
return {
|
289
|
-
init: function(data, fn) {
|
290
|
-
return _bind('init', data, fn);
|
291
|
-
},
|
292
|
-
change: function(data, fn) {
|
293
|
-
return _bind('change', data, fn);
|
294
|
-
},
|
295
|
-
internalChange: function(data, fn) {
|
296
|
-
return _bind('internalChange', data, fn);
|
297
|
-
},
|
298
|
-
externalChange: function(data, fn) {
|
299
|
-
return _bind('externalChange', data, fn);
|
300
|
-
},
|
301
|
-
baseURL: function() {
|
302
|
-
var url = _l.href;
|
303
|
-
if (url.indexOf('#') != -1) {
|
304
|
-
url = url.substr(0, url.indexOf('#'));
|
305
|
-
}
|
306
|
-
if (url.substr(url.length - 1) == '/') {
|
307
|
-
url = url.substr(0, url.length - 1);
|
308
|
-
}
|
309
|
-
return url;
|
310
|
-
},
|
311
|
-
strict: function(value) {
|
312
|
-
if (value !== undefined) {
|
313
|
-
_opts.strict = value;
|
314
|
-
return this;
|
315
|
-
}
|
316
|
-
return _opts.strict;
|
317
|
-
},
|
318
|
-
autoUpdate: function(value) {
|
319
|
-
if (value !== undefined) {
|
320
|
-
_opts.autoUpdate = value;
|
321
|
-
return this;
|
322
|
-
}
|
323
|
-
return _opts.autoUpdate;
|
324
|
-
},
|
325
|
-
update: function() {
|
326
|
-
_updating = TRUE;
|
327
|
-
this.value(_value);
|
328
|
-
_updating = FALSE;
|
329
|
-
return this;
|
330
|
-
},
|
331
|
-
history: function(value) {
|
332
|
-
if (value !== undefined) {
|
333
|
-
_opts.history = value;
|
334
|
-
return this;
|
335
|
-
}
|
336
|
-
return _opts.history;
|
337
|
-
},
|
338
|
-
tracker: function(value) {
|
339
|
-
if (value !== undefined) {
|
340
|
-
_opts.tracker = value;
|
341
|
-
return this;
|
342
|
-
}
|
343
|
-
return _opts.tracker;
|
344
|
-
},
|
345
|
-
title: function(value) {
|
346
|
-
if (value !== undefined) {
|
347
|
-
value = _dc(value);
|
348
|
-
_st(function() {
|
349
|
-
_title = _d.title = value;
|
350
|
-
if (_juststart && _frame && _frame.contentWindow && _frame.contentWindow.document) {
|
351
|
-
_frame.contentWindow.document.title = value;
|
352
|
-
_juststart = FALSE;
|
353
|
-
}
|
354
|
-
if (!_justset && _mozilla) {
|
355
|
-
_l.replace(_l.href.indexOf('#') != -1 ? _l.href : _l.href + '#');
|
356
|
-
}
|
357
|
-
_justset = FALSE;
|
358
|
-
}, 50);
|
359
|
-
return this;
|
360
|
-
}
|
361
|
-
return _d.title;
|
362
|
-
},
|
363
|
-
value: function(value) {
|
364
|
-
if (value !== undefined) {
|
365
|
-
value = _ec(_dc(_strict(value, TRUE)));
|
366
|
-
if (value == '/') {
|
367
|
-
value = '';
|
368
|
-
}
|
369
|
-
if (_value == value && !_updating) {
|
370
|
-
return;
|
371
|
-
}
|
372
|
-
_justset = TRUE;
|
373
|
-
_value = value;
|
374
|
-
if (_opts.autoUpdate || _updating) {
|
375
|
-
_silent = TRUE;
|
376
|
-
_update(TRUE);
|
377
|
-
_stack[_h.length] = _value;
|
378
|
-
if (_safari) {
|
379
|
-
if (_opts.history) {
|
380
|
-
_l[ID][_l.pathname] = _stack.toString();
|
381
|
-
_length = _h.length + 1;
|
382
|
-
if (_version < 418) {
|
383
|
-
if (_l.search == '') {
|
384
|
-
_form.action = '#' + _value;
|
385
|
-
_form.submit();
|
386
|
-
}
|
387
|
-
} else if (_version < 523 || _value == '') {
|
388
|
-
var evt = _d.createEvent('MouseEvents');
|
389
|
-
evt.initEvent('click', TRUE, TRUE);
|
390
|
-
var anchor = _d.createElement('a');
|
391
|
-
anchor.href = '#' + _value;
|
392
|
-
anchor.dispatchEvent(evt);
|
393
|
-
} else {
|
394
|
-
_l.hash = '#' + _value;
|
395
|
-
}
|
396
|
-
} else {
|
397
|
-
_l.replace('#' + _value);
|
398
|
-
}
|
399
|
-
} else if (_value != _hash()) {
|
400
|
-
if (_opts.history) {
|
401
|
-
_l.hash = '#' + _local(_value, TRUE);
|
402
|
-
} else {
|
403
|
-
_l.replace('#' + _value);
|
404
|
-
}
|
405
|
-
}
|
406
|
-
if ((_msie && _version < 8) && _opts.history) {
|
407
|
-
_st(_html, 50);
|
408
|
-
}
|
409
|
-
if (_safari) {
|
410
|
-
_st(function(){ _silent = FALSE; }, 1);
|
411
|
-
} else {
|
412
|
-
_silent = FALSE;
|
413
|
-
}
|
414
|
-
}
|
415
|
-
return this;
|
416
|
-
}
|
417
|
-
if (!_supported) {
|
418
|
-
return null;
|
419
|
-
}
|
420
|
-
return _dc(_strict(_local(_value, FALSE), FALSE));
|
421
|
-
},
|
422
|
-
path: function(value) {
|
423
|
-
if (value !== undefined) {
|
424
|
-
var qs = this.queryString();
|
425
|
-
this.value(value + (qs ? '?' + qs : ''));
|
426
|
-
return this;
|
427
|
-
}
|
428
|
-
value = this.value();
|
429
|
-
return (value.indexOf('?') != -1) ? value.split('?')[0] : value;
|
430
|
-
},
|
431
|
-
queryString: function(value) {
|
432
|
-
if (value !== undefined) {
|
433
|
-
this.value(this.path() + (value ? '?' + value : ''));
|
434
|
-
return this;
|
435
|
-
}
|
436
|
-
value = this.value();
|
437
|
-
var index = value.indexOf('?');
|
438
|
-
if (index != -1 && index < value.length) {
|
439
|
-
return value.substr(index + 1);
|
440
|
-
}
|
441
|
-
},
|
442
|
-
parameter: function(name, value, append) {
|
443
|
-
var i, params;
|
444
|
-
if (value !== undefined) {
|
445
|
-
var names = this.parameterNames();
|
446
|
-
params = [];
|
447
|
-
for (i = 0; i < names.length; i++) {
|
448
|
-
var n = names[i],
|
449
|
-
v = this.parameter(n);
|
450
|
-
if (typeof v == 'string') {
|
451
|
-
v = [v];
|
452
|
-
}
|
453
|
-
if (n == name) {
|
454
|
-
v = (value === null || value == '') ? [] :
|
455
|
-
(append ? v.concat([value]) : [value]);
|
456
|
-
}
|
457
|
-
for (var j = 0; j < v.length; j++) {
|
458
|
-
params.push(n + '=' + v[j]);
|
459
|
-
}
|
460
|
-
}
|
461
|
-
if ($.inArray(name, names) == -1) {
|
462
|
-
params.push(name + '=' + value);
|
463
|
-
}
|
464
|
-
this.queryString(params.join('&'));
|
465
|
-
return this;
|
466
|
-
}
|
467
|
-
value = this.value();
|
468
|
-
var index = value.indexOf('?');
|
469
|
-
if (index != -1) {
|
470
|
-
value = value.substr(index + 1);
|
471
|
-
params = value.split('&');
|
472
|
-
var r = [];
|
473
|
-
for (i = 0; i < params.length; i++) {
|
474
|
-
var p = params[i].split('=');
|
475
|
-
if (p[0] == name) {
|
476
|
-
r.push(p[1]);
|
477
|
-
}
|
478
|
-
}
|
479
|
-
if (r.length !== 0) {
|
480
|
-
return r.length != 1 ? r : r[0];
|
481
|
-
}
|
482
|
-
}
|
483
|
-
},
|
484
|
-
pathNames: function() {
|
485
|
-
var path = this.path(),
|
486
|
-
names = path.split('/');
|
487
|
-
if (path.substr(0, 1) == '/' || path.length === 0) {
|
488
|
-
names.splice(0, 1);
|
489
|
-
}
|
490
|
-
if (path.substr(path.length - 1, 1) == '/') {
|
491
|
-
names.splice(names.length - 1, 1);
|
492
|
-
}
|
493
|
-
return names;
|
494
|
-
},
|
495
|
-
parameterNames: function() {
|
496
|
-
var value = this.value(),
|
497
|
-
index = value.indexOf('?'),
|
498
|
-
names = [];
|
499
|
-
if (index != -1) {
|
500
|
-
value = value.substr(index + 1);
|
501
|
-
if (value != '' && value.indexOf('=') != -1) {
|
502
|
-
var params = value.split('&');
|
503
|
-
for (var i = 0; i < params.length; i++) {
|
504
|
-
var name = params[i].split('=')[0];
|
505
|
-
if ($.inArray(name, names) == -1) {
|
506
|
-
names.push(name);
|
507
|
-
}
|
508
|
-
}
|
509
|
-
}
|
510
|
-
}
|
511
|
-
return names;
|
512
|
-
}
|
513
|
-
};
|
514
|
-
|
515
|
-
})();
|
516
|
-
|
517
|
-
$.fn.address = function (fn) {
|
518
|
-
var f = function() {
|
519
|
-
var value = fn ? fn.call(this) :
|
520
|
-
/address:/.test($(this).attr('rel')) ? $(this).attr('rel').split('address:')[1].split(' ')[0] :
|
521
|
-
$(this).attr('href').replace(/^#/, '');
|
522
|
-
$.address.value(value);
|
523
|
-
return false;
|
524
|
-
};
|
525
|
-
$(this).click(f).live('click', f);
|
526
|
-
};
|
527
|
-
|
528
|
-
}(jQuery));
|