muck-commerce 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/active_record/acts/muck_order_transaction.rb +1 -0
- data/muck-commerce.gemspec +26 -4
- data/test/rails_root/Gemfile +47 -0
- data/test/rails_root/config/boot.rb +14 -0
- data/test/rails_root/config/environment.rb +0 -21
- data/test/rails_root/config/preinitializer.rb +20 -0
- data/test/rails_root/public/javascripts/jquery/fg.menu.js +517 -0
- data/test/rails_root/public/javascripts/jquery/jquery.easing.js +45 -71
- data/test/rails_root/public/javascripts/jquery/jquery.form.js +45 -30
- data/test/rails_root/public/javascripts/jquery/jquery.timers.js +138 -0
- data/test/rails_root/public/javascripts/muck-src.js +147 -0
- data/test/rails_root/public/javascripts/muck.js +7 -89
- data/test/rails_root/public/javascripts/muck_admin.js +13 -0
- data/test/rails_root/public/stylesheets/admin.css +12 -0
- data/test/rails_root/public/stylesheets/fgmenu/fg.menu.css +114 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-bg_flat_0_eeeeee_40x100.png +0 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-bg_flat_55_ffffff_40x100.png +0 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-bg_highlight-soft_100_f6f6f6_1x100.png +0 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-bg_highlight-soft_25_0073ea_1x100.png +0 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-bg_highlight-soft_50_dddddd_1x100.png +0 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-icons_0073ea_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-icons_454545_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-icons_666666_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-icons_ff0084_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/flick/images/ui-icons_ffffff_256x240.png +0 -0
- data/test/rails_root/public/stylesheets/flick/jquery-ui-1.8.1.custom.css +486 -0
- metadata +41 -4
|
@@ -1,72 +1,46 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
/* This lib is to support fancybox. The default compressed version causes errors with Rails caching.
|
|
2
|
+
This version is compressed with http://closure-compiler.appspot.com/home
|
|
3
|
+
*
|
|
4
|
+
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
|
|
5
|
+
*
|
|
6
|
+
* Uses the built in easing capabilities added In jQuery 1.1
|
|
7
|
+
* to offer multiple easing options
|
|
8
|
+
*
|
|
9
|
+
* TERMS OF USE - jQuery Easing
|
|
10
|
+
*
|
|
11
|
+
* Open source under the BSD License.
|
|
12
|
+
*
|
|
13
|
+
* Copyright © 2008 George McGinley Smith
|
|
14
|
+
* All rights reserved.
|
|
15
|
+
*
|
|
16
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
|
17
|
+
* are permitted provided that the following conditions are met:
|
|
18
|
+
*
|
|
19
|
+
* Redistributions of source code must retain the above copyright notice, this list of
|
|
20
|
+
* conditions and the following disclaimer.
|
|
21
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
|
22
|
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
23
|
+
* provided with the distribution.
|
|
24
|
+
*
|
|
25
|
+
* Neither the name of the author nor the names of contributors may be used to endorse
|
|
26
|
+
* or promote products derived from this software without specific prior written permission.
|
|
27
|
+
*
|
|
28
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
29
|
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
30
|
+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
31
|
+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
32
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
33
|
+
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
34
|
+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
35
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
36
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37
|
+
*
|
|
36
38
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* Open source under the BSD License.
|
|
46
|
-
*
|
|
47
|
-
* Copyright © 2001 Robert Penner
|
|
48
|
-
* All rights reserved.
|
|
49
|
-
*
|
|
50
|
-
* Redistribution and use in source and binary forms, with or without modification,
|
|
51
|
-
* are permitted provided that the following conditions are met:
|
|
52
|
-
*
|
|
53
|
-
* Redistributions of source code must retain the above copyright notice, this list of
|
|
54
|
-
* conditions and the following disclaimer.
|
|
55
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list
|
|
56
|
-
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
57
|
-
* provided with the distribution.
|
|
58
|
-
*
|
|
59
|
-
* Neither the name of the author nor the names of contributors may be used to endorse
|
|
60
|
-
* or promote products derived from this software without specific prior written permission.
|
|
61
|
-
*
|
|
62
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
63
|
-
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
64
|
-
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
65
|
-
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
66
|
-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
67
|
-
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
68
|
-
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
69
|
-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
70
|
-
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
71
|
-
*
|
|
72
|
-
*/
|
|
39
|
+
jQuery.easing.jswing=jQuery.easing.swing;
|
|
40
|
+
jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,a,c,b,d){return jQuery.easing[jQuery.easing.def](e,a,c,b,d)},easeInQuad:function(e,a,c,b,d){return b*(a/=d)*a+c},easeOutQuad:function(e,a,c,b,d){return-b*(a/=d)*(a-2)+c},easeInOutQuad:function(e,a,c,b,d){if((a/=d/2)<1)return b/2*a*a+c;return-b/2*(--a*(a-2)-1)+c},easeInCubic:function(e,a,c,b,d){return b*(a/=d)*a*a+c},easeOutCubic:function(e,a,c,b,d){return b*((a=a/d-1)*a*a+1)+c},easeInOutCubic:function(e,a,c,b,d){if((a/=d/2)<1)return b/
|
|
41
|
+
2*a*a*a+c;return b/2*((a-=2)*a*a+2)+c},easeInQuart:function(e,a,c,b,d){return b*(a/=d)*a*a*a+c},easeOutQuart:function(e,a,c,b,d){return-b*((a=a/d-1)*a*a*a-1)+c},easeInOutQuart:function(e,a,c,b,d){if((a/=d/2)<1)return b/2*a*a*a*a+c;return-b/2*((a-=2)*a*a*a-2)+c},easeInQuint:function(e,a,c,b,d){return b*(a/=d)*a*a*a*a+c},easeOutQuint:function(e,a,c,b,d){return b*((a=a/d-1)*a*a*a*a+1)+c},easeInOutQuint:function(e,a,c,b,d){if((a/=d/2)<1)return b/2*a*a*a*a*a+c;return b/2*((a-=2)*a*a*a*a+2)+c},easeInSine:function(e,
|
|
42
|
+
a,c,b,d){return-b*Math.cos(a/d*(Math.PI/2))+b+c},easeOutSine:function(e,a,c,b,d){return b*Math.sin(a/d*(Math.PI/2))+c},easeInOutSine:function(e,a,c,b,d){return-b/2*(Math.cos(Math.PI*a/d)-1)+c},easeInExpo:function(e,a,c,b,d){return a==0?c:b*Math.pow(2,10*(a/d-1))+c},easeOutExpo:function(e,a,c,b,d){return a==d?c+b:b*(-Math.pow(2,-10*a/d)+1)+c},easeInOutExpo:function(e,a,c,b,d){if(a==0)return c;if(a==d)return c+b;if((a/=d/2)<1)return b/2*Math.pow(2,10*(a-1))+c;return b/2*(-Math.pow(2,-10*--a)+2)+c},
|
|
43
|
+
easeInCirc:function(e,a,c,b,d){return-b*(Math.sqrt(1-(a/=d)*a)-1)+c},easeOutCirc:function(e,a,c,b,d){return b*Math.sqrt(1-(a=a/d-1)*a)+c},easeInOutCirc:function(e,a,c,b,d){if((a/=d/2)<1)return-b/2*(Math.sqrt(1-a*a)-1)+c;return b/2*(Math.sqrt(1-(a-=2)*a)+1)+c},easeInElastic:function(e,a,c,b,d){e=1.70158;var f=0,g=b;if(a==0)return c;if((a/=d)==1)return c+b;f||(f=d*0.3);if(g<Math.abs(b)){g=b;e=f/4}else e=f/(2*Math.PI)*Math.asin(b/g);return-(g*Math.pow(2,10*(a-=1))*Math.sin((a*d-e)*2*Math.PI/f))+c},easeOutElastic:function(e,
|
|
44
|
+
a,c,b,d){e=1.70158;var f=0,g=b;if(a==0)return c;if((a/=d)==1)return c+b;f||(f=d*0.3);if(g<Math.abs(b)){g=b;e=f/4}else e=f/(2*Math.PI)*Math.asin(b/g);return g*Math.pow(2,-10*a)*Math.sin((a*d-e)*2*Math.PI/f)+b+c},easeInOutElastic:function(e,a,c,b,d){e=1.70158;var f=0,g=b;if(a==0)return c;if((a/=d/2)==2)return c+b;f||(f=d*0.3*1.5);if(g<Math.abs(b)){g=b;e=f/4}else e=f/(2*Math.PI)*Math.asin(b/g);if(a<1)return-0.5*g*Math.pow(2,10*(a-=1))*Math.sin((a*d-e)*2*Math.PI/f)+c;return g*Math.pow(2,-10*(a-=1))*Math.sin((a*
|
|
45
|
+
d-e)*2*Math.PI/f)*0.5+b+c},easeInBack:function(e,a,c,b,d,f){if(f==undefined)f=1.70158;return b*(a/=d)*a*((f+1)*a-f)+c},easeOutBack:function(e,a,c,b,d,f){if(f==undefined)f=1.70158;return b*((a=a/d-1)*a*((f+1)*a+f)+1)+c},easeInOutBack:function(e,a,c,b,d,f){if(f==undefined)f=1.70158;if((a/=d/2)<1)return b/2*a*a*(((f*=1.525)+1)*a-f)+c;return b/2*((a-=2)*a*(((f*=1.525)+1)*a+f)+2)+c},easeInBounce:function(e,a,c,b,d){return b-jQuery.easing.easeOutBounce(e,d-a,0,b,d)+c},easeOutBounce:function(e,a,c,b,d){return(a/=
|
|
46
|
+
d)<1/2.75?b*7.5625*a*a+c:a<2/2.75?b*(7.5625*(a-=1.5/2.75)*a+0.75)+c:a<2.5/2.75?b*(7.5625*(a-=2.25/2.75)*a+0.9375)+c:b*(7.5625*(a-=2.625/2.75)*a+0.984375)+c},easeInOutBounce:function(e,a,c,b,d){if(a<d/2)return jQuery.easing.easeInBounce(e,a*2,0,b,d)*0.5+c;return jQuery.easing.easeOutBounce(e,a*2-d,0,b,d)*0.5+b*0.5+c}});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
2
|
* jQuery Form Plugin
|
|
3
|
-
* version: 2.
|
|
4
|
-
* @requires jQuery v1.2
|
|
3
|
+
* version: 2.43 (12-MAR-2010)
|
|
4
|
+
* @requires jQuery v1.3.2 or later
|
|
5
5
|
*
|
|
6
6
|
* Examples and documentation at: http://malsup.com/jquery/form/
|
|
7
7
|
* Dual licensed under the MIT and GPL licenses:
|
|
@@ -124,15 +124,16 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
124
124
|
if (!options.dataType && options.target) {
|
|
125
125
|
var oldSuccess = options.success || function(){};
|
|
126
126
|
callbacks.push(function(data) {
|
|
127
|
-
|
|
127
|
+
var fn = options.replaceTarget ? 'replaceWith' : 'html';
|
|
128
|
+
$(options.target)[fn](data).each(oldSuccess, arguments);
|
|
128
129
|
});
|
|
129
130
|
}
|
|
130
131
|
else if (options.success)
|
|
131
132
|
callbacks.push(options.success);
|
|
132
133
|
|
|
133
|
-
options.success = function(data, status) {
|
|
134
|
+
options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
|
|
134
135
|
for (var i=0, max=callbacks.length; i < max; i++)
|
|
135
|
-
callbacks[i].apply(options, [data, status, $form]);
|
|
136
|
+
callbacks[i].apply(options, [data, status, xhr || $form, $form]);
|
|
136
137
|
};
|
|
137
138
|
|
|
138
139
|
// are there files to upload?
|
|
@@ -177,7 +178,7 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
177
178
|
var s = $.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts);
|
|
178
179
|
|
|
179
180
|
var id = 'jqFormIO' + (new Date().getTime());
|
|
180
|
-
var $io = $('<iframe id="' + id + '" name="' + id + '" src="'+ opts.iframeSrc +'" />');
|
|
181
|
+
var $io = $('<iframe id="' + id + '" name="' + id + '" src="'+ opts.iframeSrc +'" onload="(jQuery(this).data(\'form-plugin-onload\'))()" />');
|
|
181
182
|
var io = $io[0];
|
|
182
183
|
|
|
183
184
|
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
|
|
@@ -209,7 +210,7 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
209
210
|
if (xhr.aborted)
|
|
210
211
|
return;
|
|
211
212
|
|
|
212
|
-
var cbInvoked =
|
|
213
|
+
var cbInvoked = false;
|
|
213
214
|
var timedOut = 0;
|
|
214
215
|
|
|
215
216
|
// add submitting element to data if we know it
|
|
@@ -217,17 +218,17 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
217
218
|
if (sub) {
|
|
218
219
|
var n = sub.name;
|
|
219
220
|
if (n && !sub.disabled) {
|
|
220
|
-
|
|
221
|
-
|
|
221
|
+
opts.extraData = opts.extraData || {};
|
|
222
|
+
opts.extraData[n] = sub.value;
|
|
222
223
|
if (sub.type == "image") {
|
|
223
|
-
|
|
224
|
-
|
|
224
|
+
opts.extraData[n+'.x'] = form.clk_x;
|
|
225
|
+
opts.extraData[n+'.y'] = form.clk_y;
|
|
225
226
|
}
|
|
226
227
|
}
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
// take a breath so that pending repaints get some cpu time before the upload starts
|
|
230
|
-
|
|
231
|
+
function doSubmit() {
|
|
231
232
|
// make sure form attrs are set
|
|
232
233
|
var t = $form.attr('target'), a = $form.attr('action');
|
|
233
234
|
|
|
@@ -239,7 +240,7 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
239
240
|
form.setAttribute('action', opts.url);
|
|
240
241
|
|
|
241
242
|
// ie borks in some cases when setting encoding
|
|
242
|
-
if (!
|
|
243
|
+
if (! opts.skipEncodingOverride) {
|
|
243
244
|
$form.attr({
|
|
244
245
|
encoding: 'multipart/form-data',
|
|
245
246
|
enctype: 'multipart/form-data'
|
|
@@ -253,15 +254,15 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
253
254
|
// add "extra" data to form if provided in options
|
|
254
255
|
var extraInputs = [];
|
|
255
256
|
try {
|
|
256
|
-
if (
|
|
257
|
-
for (var n in
|
|
257
|
+
if (opts.extraData)
|
|
258
|
+
for (var n in opts.extraData)
|
|
258
259
|
extraInputs.push(
|
|
259
|
-
$('<input type="hidden" name="'+n+'" value="'+
|
|
260
|
+
$('<input type="hidden" name="'+n+'" value="'+opts.extraData[n]+'" />')
|
|
260
261
|
.appendTo(form)[0]);
|
|
261
262
|
|
|
262
263
|
// add iframe to doc and submit the form
|
|
263
264
|
$io.appendTo('body');
|
|
264
|
-
io.
|
|
265
|
+
$io.data('form-plugin-onload', cb);
|
|
265
266
|
form.submit();
|
|
266
267
|
}
|
|
267
268
|
finally {
|
|
@@ -270,14 +271,18 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
270
271
|
t ? form.setAttribute('target', t) : $form.removeAttr('target');
|
|
271
272
|
$(extraInputs).remove();
|
|
272
273
|
}
|
|
273
|
-
}
|
|
274
|
+
};
|
|
274
275
|
|
|
275
|
-
|
|
276
|
+
if (opts.forceSync)
|
|
277
|
+
doSubmit();
|
|
278
|
+
else
|
|
279
|
+
setTimeout(doSubmit, 10); // this lets dom updates render
|
|
280
|
+
|
|
281
|
+
var domCheckCount = 100;
|
|
276
282
|
|
|
277
283
|
function cb() {
|
|
278
|
-
if (cbInvoked
|
|
279
|
-
|
|
280
|
-
io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
|
|
284
|
+
if (cbInvoked)
|
|
285
|
+
return;
|
|
281
286
|
|
|
282
287
|
var ok = true;
|
|
283
288
|
try {
|
|
@@ -293,14 +298,16 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
293
298
|
if (--domCheckCount) {
|
|
294
299
|
// in some browsers (Opera) the iframe DOM is not always traversable when
|
|
295
300
|
// the onload callback fires, so we loop a bit to accommodate
|
|
296
|
-
|
|
297
|
-
setTimeout(cb,
|
|
301
|
+
log('requeing onLoad callback, DOM not available');
|
|
302
|
+
setTimeout(cb, 250);
|
|
298
303
|
return;
|
|
299
304
|
}
|
|
300
|
-
log('Could not access iframe DOM after
|
|
305
|
+
log('Could not access iframe DOM after 100 tries.');
|
|
301
306
|
return;
|
|
302
307
|
}
|
|
303
308
|
|
|
309
|
+
log('response detected');
|
|
310
|
+
cbInvoked = true;
|
|
304
311
|
xhr.responseText = doc.body ? doc.body.innerHTML : null;
|
|
305
312
|
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
|
|
306
313
|
xhr.getResponseHeader = function(header){
|
|
@@ -326,7 +333,9 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
326
333
|
data = $.httpData(xhr, opts.dataType);
|
|
327
334
|
}
|
|
328
335
|
catch(e){
|
|
336
|
+
log('error caught:',e);
|
|
329
337
|
ok = false;
|
|
338
|
+
xhr.error = e;
|
|
330
339
|
$.handleError(opts, xhr, 'error', e);
|
|
331
340
|
}
|
|
332
341
|
|
|
@@ -341,6 +350,7 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
341
350
|
|
|
342
351
|
// clean up
|
|
343
352
|
setTimeout(function() {
|
|
353
|
+
$io.removeData('form-plugin-onload');
|
|
344
354
|
$io.remove();
|
|
345
355
|
xhr.responseXML = null;
|
|
346
356
|
}, 100);
|
|
@@ -375,9 +385,9 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
375
385
|
* the form itself.
|
|
376
386
|
*/
|
|
377
387
|
$.fn.ajaxForm = function(options) {
|
|
378
|
-
return this.ajaxFormUnbind().bind('submit.form-plugin', function() {
|
|
388
|
+
return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
|
|
389
|
+
e.preventDefault();
|
|
379
390
|
$(this).ajaxSubmit(options);
|
|
380
|
-
return false;
|
|
381
391
|
}).bind('click.form-plugin', function(e) {
|
|
382
392
|
var target = e.target;
|
|
383
393
|
var $el = $(target);
|
|
@@ -653,8 +663,13 @@ $.fn.selected = function(select) {
|
|
|
653
663
|
// helper fn for console logging
|
|
654
664
|
// set $.fn.ajaxSubmit.debug to true to enable debug logging
|
|
655
665
|
function log() {
|
|
656
|
-
if ($.fn.ajaxSubmit.debug
|
|
657
|
-
|
|
666
|
+
if ($.fn.ajaxSubmit.debug) {
|
|
667
|
+
var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
|
|
668
|
+
if (window.console && window.console.log)
|
|
669
|
+
window.console.log(msg);
|
|
670
|
+
else if (window.opera && window.opera.postError)
|
|
671
|
+
window.opera.postError(msg);
|
|
672
|
+
}
|
|
658
673
|
};
|
|
659
674
|
|
|
660
675
|
})(jQuery);
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jQuery.timers - Timer abstractions for jQuery
|
|
3
|
+
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
|
|
4
|
+
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
|
|
5
|
+
* Date: 2009/10/16
|
|
6
|
+
*
|
|
7
|
+
* @author Blair Mitchelmore
|
|
8
|
+
* @version 1.2
|
|
9
|
+
*
|
|
10
|
+
**/
|
|
11
|
+
|
|
12
|
+
jQuery.fn.extend({
|
|
13
|
+
everyTime: function(interval, label, fn, times) {
|
|
14
|
+
return this.each(function() {
|
|
15
|
+
jQuery.timer.add(this, interval, label, fn, times);
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
oneTime: function(interval, label, fn) {
|
|
19
|
+
return this.each(function() {
|
|
20
|
+
jQuery.timer.add(this, interval, label, fn, 1);
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
stopTime: function(label, fn) {
|
|
24
|
+
return this.each(function() {
|
|
25
|
+
jQuery.timer.remove(this, label, fn);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
jQuery.extend({
|
|
31
|
+
timer: {
|
|
32
|
+
global: [],
|
|
33
|
+
guid: 1,
|
|
34
|
+
dataKey: "jQuery.timer",
|
|
35
|
+
regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,
|
|
36
|
+
powers: {
|
|
37
|
+
// Yeah this is major overkill...
|
|
38
|
+
'ms': 1,
|
|
39
|
+
'cs': 10,
|
|
40
|
+
'ds': 100,
|
|
41
|
+
's': 1000,
|
|
42
|
+
'das': 10000,
|
|
43
|
+
'hs': 100000,
|
|
44
|
+
'ks': 1000000
|
|
45
|
+
},
|
|
46
|
+
timeParse: function(value) {
|
|
47
|
+
if (value == undefined || value == null)
|
|
48
|
+
return null;
|
|
49
|
+
var result = this.regex.exec(jQuery.trim(value.toString()));
|
|
50
|
+
if (result[2]) {
|
|
51
|
+
var num = parseFloat(result[1]);
|
|
52
|
+
var mult = this.powers[result[2]] || 1;
|
|
53
|
+
return num * mult;
|
|
54
|
+
} else {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
add: function(element, interval, label, fn, times) {
|
|
59
|
+
var counter = 0;
|
|
60
|
+
|
|
61
|
+
if (jQuery.isFunction(label)) {
|
|
62
|
+
if (!times)
|
|
63
|
+
times = fn;
|
|
64
|
+
fn = label;
|
|
65
|
+
label = interval;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interval = jQuery.timer.timeParse(interval);
|
|
69
|
+
|
|
70
|
+
if (typeof interval != 'number' || isNaN(interval) || interval < 0)
|
|
71
|
+
return;
|
|
72
|
+
|
|
73
|
+
if (typeof times != 'number' || isNaN(times) || times < 0)
|
|
74
|
+
times = 0;
|
|
75
|
+
|
|
76
|
+
times = times || 0;
|
|
77
|
+
|
|
78
|
+
var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {});
|
|
79
|
+
|
|
80
|
+
if (!timers[label])
|
|
81
|
+
timers[label] = {};
|
|
82
|
+
|
|
83
|
+
fn.timerID = fn.timerID || this.guid++;
|
|
84
|
+
|
|
85
|
+
var handler = function() {
|
|
86
|
+
if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
|
|
87
|
+
jQuery.timer.remove(element, label, fn);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
handler.timerID = fn.timerID;
|
|
91
|
+
|
|
92
|
+
if (!timers[label][fn.timerID])
|
|
93
|
+
timers[label][fn.timerID] = window.setInterval(handler,interval);
|
|
94
|
+
|
|
95
|
+
this.global.push( element );
|
|
96
|
+
|
|
97
|
+
},
|
|
98
|
+
remove: function(element, label, fn) {
|
|
99
|
+
var timers = jQuery.data(element, this.dataKey), ret;
|
|
100
|
+
|
|
101
|
+
if ( timers ) {
|
|
102
|
+
|
|
103
|
+
if (!label) {
|
|
104
|
+
for ( label in timers )
|
|
105
|
+
this.remove(element, label, fn);
|
|
106
|
+
} else if ( timers[label] ) {
|
|
107
|
+
if ( fn ) {
|
|
108
|
+
if ( fn.timerID ) {
|
|
109
|
+
window.clearInterval(timers[label][fn.timerID]);
|
|
110
|
+
delete timers[label][fn.timerID];
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
for ( var fn in timers[label] ) {
|
|
114
|
+
window.clearInterval(timers[label][fn]);
|
|
115
|
+
delete timers[label][fn];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
for ( ret in timers[label] ) break;
|
|
120
|
+
if ( !ret ) {
|
|
121
|
+
ret = null;
|
|
122
|
+
delete timers[label];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
for ( ret in timers ) break;
|
|
127
|
+
if ( !ret )
|
|
128
|
+
jQuery.removeData(element, this.dataKey);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
jQuery(window).bind("unload", function() {
|
|
135
|
+
jQuery.each(jQuery.timer.global, function(index, item) {
|
|
136
|
+
jQuery.timer.remove(item);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// compress with http://closure-compiler.appspot.com/home
|
|
2
|
+
//jQuery.noConflict();
|
|
3
|
+
jQuery(document).ajaxSend(function(event, request, settings) {
|
|
4
|
+
add_headers(request);
|
|
5
|
+
if (settings.type.toUpperCase() == 'GET' || typeof(AUTH_TOKEN) == "undefined") return; // for details see: http://www.justinball.com/2009/07/08/jquery-ajax-get-in-firefox-post-in-internet-explorer/
|
|
6
|
+
// settings.data is a serialized string like "foo=bar&baz=boink" (or null)
|
|
7
|
+
settings.data = settings.data || "";
|
|
8
|
+
if (typeof(AUTH_TOKEN) != "undefined")
|
|
9
|
+
settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
function apply_ajax_forms() {
|
|
13
|
+
jQuery('form.ajax').ajaxForm({
|
|
14
|
+
dataType: 'script',
|
|
15
|
+
beforeSend: add_headers
|
|
16
|
+
});
|
|
17
|
+
jQuery('form.ajax').append('<input type="hidden" name="format" value="js" />');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function add_headers(xhr){
|
|
21
|
+
xhr.setRequestHeader("Accept", "text/javascript");
|
|
22
|
+
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
jQuery(document).ready(function() {
|
|
26
|
+
|
|
27
|
+
jQuery('a.ajax-delete').live('click', function() {
|
|
28
|
+
var title = jQuery(this).attr('title');
|
|
29
|
+
var do_delete = true;
|
|
30
|
+
if(title.length > 0){
|
|
31
|
+
do_delete = confirm(title);
|
|
32
|
+
}
|
|
33
|
+
if (do_delete){
|
|
34
|
+
jQuery.post(this.href, { _method: 'delete', format: 'js' }, null, "script");
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
jQuery('a.ajax-update').live('click', function() {
|
|
40
|
+
jQuery.post(this.href, { _method: 'put', format: 'js' }, null, "script");
|
|
41
|
+
return false;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
jQuery(".submit-form").click(function() {
|
|
45
|
+
jQuery(this).parent('form').submit();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
apply_ajax_forms();
|
|
49
|
+
|
|
50
|
+
jQuery('a.dialog-pop').live('click', function() {
|
|
51
|
+
var d = jQuery('<div class="dialog"></div>').appendTo("body");
|
|
52
|
+
d.dialog({ modal: true, autoOpen: false, width: 'auto', title: jQuery(this).attr('title') });
|
|
53
|
+
d.load(jQuery(this).attr('href'), '', function(){
|
|
54
|
+
d.dialog("open");
|
|
55
|
+
apply_ajax_forms();
|
|
56
|
+
});
|
|
57
|
+
return false;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
jQuery(".submit-delete").live('click', function() {
|
|
61
|
+
jQuery(this).parents('.delete-container').fadeOut();
|
|
62
|
+
var form = jQuery(this).parents('form');
|
|
63
|
+
jQuery.post(form.attr('action') + '.json', form.serialize(),
|
|
64
|
+
function(data){
|
|
65
|
+
var json = eval('(' + data + ')');
|
|
66
|
+
if(!json.success){
|
|
67
|
+
jQuery.jGrowl.info(json.message);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return false;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
jQuery(".submit-delete-js").live('click', function() {
|
|
74
|
+
jQuery(this).parents('.delete-container').fadeOut();
|
|
75
|
+
var form = jQuery(this).parents('form');
|
|
76
|
+
jQuery.post(form.attr('action') + '.js', form.serialize(),
|
|
77
|
+
function(data){
|
|
78
|
+
});
|
|
79
|
+
return false;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
jQuery(document).ready(function() {
|
|
83
|
+
jQuery('.waiting').hide();
|
|
84
|
+
jQuery(".wait-button").live('click', function() {
|
|
85
|
+
jQuery(this).siblings('.waiting').show();
|
|
86
|
+
jQuery(this).hide();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// String list methods. These are handy for dealing with comma delimited lists
|
|
93
|
+
// in text boxes such as a list of emails or tags.
|
|
94
|
+
// Given a comma delimited string add a new item if it isn't in the string
|
|
95
|
+
function add_to_list(items_string, new_item){
|
|
96
|
+
var items = split_list(items_string);
|
|
97
|
+
var add = true;
|
|
98
|
+
for(i=0;i<items.length;i++){
|
|
99
|
+
if(items[i] == new_item){ add = false; }
|
|
100
|
+
}
|
|
101
|
+
if(add){
|
|
102
|
+
items.push(new_item);
|
|
103
|
+
}
|
|
104
|
+
return items.join(', ');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Given a comma delimited list remove an item from the string
|
|
108
|
+
function remove_from_list(items_string, remove_item){
|
|
109
|
+
var items = split_list(items_string);
|
|
110
|
+
var cleaned = [];
|
|
111
|
+
for(i=0;i<items.length;i++){
|
|
112
|
+
if(items[i] != remove_item){
|
|
113
|
+
cleaned.push(items[i]);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return cleaned.join(', ');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Split a string on commas
|
|
120
|
+
function split_list(items_string){
|
|
121
|
+
if(undefined != items_string && items_string.length > 0){
|
|
122
|
+
var items = items_string.split(',');
|
|
123
|
+
} else {
|
|
124
|
+
var items = [];
|
|
125
|
+
}
|
|
126
|
+
var cleaned = [];
|
|
127
|
+
for(i=0;i<items.length;i++){
|
|
128
|
+
var cleaned_item = jQuery.trim(items[i]);
|
|
129
|
+
if(cleaned_item.length > 0){
|
|
130
|
+
cleaned.push(cleaned_item);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return cleaned;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function isEncodedHtml(str) {
|
|
137
|
+
if(str.search(/&/g) != -1 || str.search(/</g) != -1 || str.search(/>/g) != -1)
|
|
138
|
+
return true;
|
|
139
|
+
else
|
|
140
|
+
return false;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
function decodeHtml(str){
|
|
144
|
+
if(isEncodedHtml(str))
|
|
145
|
+
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
146
|
+
return str;
|
|
147
|
+
}
|