iqvoc 3.3.1 → 3.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +101 -0
- data/app/assets/javascripts/framework.js +1 -0
- data/app/assets/stylesheets/framework.css +2 -0
- data/app/views/layouts/application.html.erb +2 -11
- data/iqvoc.gemspec +2 -1
- data/lib/iqvoc.rb +0 -3
- data/lib/iqvoc/version.rb +1 -1
- data/public/assets/blueprint/ie-0761b92d02baf44f0b2011e3009e6aa9.css.gz +0 -0
- data/public/assets/blueprint/ie.css.gz +0 -0
- data/public/assets/iqvoc/ie_fixes-7a001f31445ddfb2e0668c419f81742f.css.gz +0 -0
- data/public/assets/iqvoc/ie_fixes.css.gz +0 -0
- data/public/assets/manifest-6f0772f7ec93cc20de428ae859353e92.js +21 -0
- data/public/assets/manifest-6f0772f7ec93cc20de428ae859353e92.js.gz +0 -0
- data/public/assets/manifest-d52be2520b68121c73695e4026876a98.css +1421 -0
- data/public/assets/manifest-d52be2520b68121c73695e4026876a98.css.gz +0 -0
- data/public/assets/manifest.css +295 -0
- data/public/assets/manifest.css.gz +0 -0
- data/public/assets/manifest.js +2 -2
- data/public/assets/manifest.js.gz +0 -0
- data/public/assets/manifest.yml +2 -5
- data/vendor/assets/images/ajax-loader.gif +0 -0
- data/vendor/assets/images/file.gif +0 -0
- data/vendor/assets/images/folder-closed.gif +0 -0
- data/vendor/assets/images/folder.gif +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_55_fbec88_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_glass_85_dfeffc_1x400.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_217bc0_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_2e83ff_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_469bdd_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_6da8d5_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_cd0a0a_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_d8e7f3_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_f9bd01_256x240.png +0 -0
- data/vendor/assets/images/minus.gif +0 -0
- data/vendor/assets/images/plus.gif +0 -0
- data/vendor/assets/images/treeview-black-line.gif +0 -0
- data/vendor/assets/images/treeview-black.gif +0 -0
- data/vendor/assets/images/treeview-default-line.gif +0 -0
- data/vendor/assets/images/treeview-default.gif +0 -0
- data/vendor/assets/images/treeview-famfamfam-line.gif +0 -0
- data/vendor/assets/images/treeview-famfamfam.gif +0 -0
- data/vendor/assets/images/treeview-gray-line.gif +0 -0
- data/vendor/assets/images/treeview-gray.gif +0 -0
- data/vendor/assets/images/treeview-red-line.gif +0 -0
- data/vendor/assets/images/treeview-red.gif +0 -0
- data/vendor/assets/javascripts/excanvas.js +35 -0
- data/vendor/assets/javascripts/jit_rgraph.js +153 -0
- data/vendor/assets/javascripts/jquery-1.7.1.js +9266 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.16.custom.js +3269 -0
- data/vendor/assets/javascripts/jquery-ui.datepicker-de.js +22 -0
- data/vendor/assets/javascripts/jquery.treeview.async.js +82 -0
- data/vendor/assets/javascripts/jquery.treeview.js +251 -0
- data/vendor/assets/javascripts/json2.js +485 -0
- data/vendor/assets/javascripts/rails.js +373 -0
- data/vendor/assets/javascripts/storage.js +122 -0
- data/vendor/assets/stylesheets/blueprint/ie.css +35 -0
- data/vendor/assets/stylesheets/blueprint/print.css +33 -0
- data/vendor/assets/stylesheets/blueprint/screen.css +262 -0
- data/vendor/assets/stylesheets/jquery-ui-1.8.16.custom.css +410 -0
- data/vendor/assets/stylesheets/jquery.treeview.css.erb +75 -0
- metadata +68 -17
@@ -0,0 +1,373 @@
|
|
1
|
+
(function($, undefined) {
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Unobtrusive scripting adapter for jQuery
|
5
|
+
*
|
6
|
+
* Requires jQuery 1.6.0 or later.
|
7
|
+
* https://github.com/rails/jquery-ujs
|
8
|
+
|
9
|
+
* Uploading file using rails.js
|
10
|
+
* =============================
|
11
|
+
*
|
12
|
+
* By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
|
13
|
+
* in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
|
14
|
+
*
|
15
|
+
* The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
|
16
|
+
*
|
17
|
+
* Ex:
|
18
|
+
* $('form').live('ajax:aborted:file', function(event, elements){
|
19
|
+
* // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
|
20
|
+
* // Returning false in this handler tells rails.js to disallow standard form submission
|
21
|
+
* return false;
|
22
|
+
* });
|
23
|
+
*
|
24
|
+
* The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
|
25
|
+
*
|
26
|
+
* Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
|
27
|
+
* techniques like the iframe method to upload the file instead.
|
28
|
+
*
|
29
|
+
* Required fields in rails.js
|
30
|
+
* ===========================
|
31
|
+
*
|
32
|
+
* If any blank required inputs (required="required") are detected in the remote form, the whole form submission
|
33
|
+
* is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
|
34
|
+
*
|
35
|
+
* The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
|
36
|
+
*
|
37
|
+
* !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
|
38
|
+
* get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
|
39
|
+
*
|
40
|
+
* Ex:
|
41
|
+
* $('form').live('ajax:aborted:required', function(event, elements){
|
42
|
+
* // Returning false in this handler tells rails.js to submit the form anyway.
|
43
|
+
* // The blank required inputs are passed to this function in `elements`.
|
44
|
+
* return ! confirm("Would you like to submit the form with missing info?");
|
45
|
+
* });
|
46
|
+
*/
|
47
|
+
|
48
|
+
// Shorthand to make it a little easier to call public rails functions from within rails.js
|
49
|
+
var rails;
|
50
|
+
|
51
|
+
$.rails = rails = {
|
52
|
+
// Link elements bound by jquery-ujs
|
53
|
+
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
|
54
|
+
|
55
|
+
// Select elements bound by jquery-ujs
|
56
|
+
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
|
57
|
+
|
58
|
+
// Form elements bound by jquery-ujs
|
59
|
+
formSubmitSelector: 'form',
|
60
|
+
|
61
|
+
// Form input elements bound by jquery-ujs
|
62
|
+
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not(button[type])',
|
63
|
+
|
64
|
+
// Form input elements disabled during form submission
|
65
|
+
disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
|
66
|
+
|
67
|
+
// Form input elements re-enabled after form submission
|
68
|
+
enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
|
69
|
+
|
70
|
+
// Form required input elements
|
71
|
+
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
|
72
|
+
|
73
|
+
// Form file input elements
|
74
|
+
fileInputSelector: 'input:file',
|
75
|
+
|
76
|
+
// Link onClick disable selector with possible reenable after remote submission
|
77
|
+
linkDisableSelector: 'a[data-disable-with]',
|
78
|
+
|
79
|
+
// Make sure that every Ajax request sends the CSRF token
|
80
|
+
CSRFProtection: function(xhr) {
|
81
|
+
var token = $('meta[name="csrf-token"]').attr('content');
|
82
|
+
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
|
83
|
+
},
|
84
|
+
|
85
|
+
// Triggers an event on an element and returns false if the event result is false
|
86
|
+
fire: function(obj, name, data) {
|
87
|
+
var event = $.Event(name);
|
88
|
+
obj.trigger(event, data);
|
89
|
+
return event.result !== false;
|
90
|
+
},
|
91
|
+
|
92
|
+
// Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
|
93
|
+
confirm: function(message) {
|
94
|
+
return confirm(message);
|
95
|
+
},
|
96
|
+
|
97
|
+
// Default ajax function, may be overridden with custom function in $.rails.ajax
|
98
|
+
ajax: function(options) {
|
99
|
+
return $.ajax(options);
|
100
|
+
},
|
101
|
+
|
102
|
+
// Submits "remote" forms and links with ajax
|
103
|
+
handleRemote: function(element) {
|
104
|
+
var method, url, data,
|
105
|
+
crossDomain = element.data('cross-domain') || null,
|
106
|
+
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType),
|
107
|
+
options;
|
108
|
+
|
109
|
+
if (rails.fire(element, 'ajax:before')) {
|
110
|
+
|
111
|
+
if (element.is('form')) {
|
112
|
+
method = element.attr('method');
|
113
|
+
url = element.attr('action');
|
114
|
+
data = element.serializeArray();
|
115
|
+
// memoized value from clicked submit button
|
116
|
+
var button = element.data('ujs:submit-button');
|
117
|
+
if (button) {
|
118
|
+
data.push(button);
|
119
|
+
element.data('ujs:submit-button', null);
|
120
|
+
}
|
121
|
+
} else if (element.is(rails.inputChangeSelector)) {
|
122
|
+
method = element.data('method');
|
123
|
+
url = element.data('url');
|
124
|
+
data = element.serialize();
|
125
|
+
if (element.data('params')) data = data + "&" + element.data('params');
|
126
|
+
} else {
|
127
|
+
method = element.data('method');
|
128
|
+
url = element.attr('href');
|
129
|
+
data = element.data('params') || null;
|
130
|
+
}
|
131
|
+
|
132
|
+
options = {
|
133
|
+
type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
|
134
|
+
// stopping the "ajax:beforeSend" event will cancel the ajax request
|
135
|
+
beforeSend: function(xhr, settings) {
|
136
|
+
if (settings.dataType === undefined) {
|
137
|
+
xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
|
138
|
+
}
|
139
|
+
return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
|
140
|
+
},
|
141
|
+
success: function(data, status, xhr) {
|
142
|
+
element.trigger('ajax:success', [data, status, xhr]);
|
143
|
+
},
|
144
|
+
complete: function(xhr, status) {
|
145
|
+
element.trigger('ajax:complete', [xhr, status]);
|
146
|
+
},
|
147
|
+
error: function(xhr, status, error) {
|
148
|
+
element.trigger('ajax:error', [xhr, status, error]);
|
149
|
+
}
|
150
|
+
};
|
151
|
+
// Only pass url to `ajax` options if not blank
|
152
|
+
if (url) { options.url = url; }
|
153
|
+
|
154
|
+
return rails.ajax(options);
|
155
|
+
} else {
|
156
|
+
return false;
|
157
|
+
}
|
158
|
+
},
|
159
|
+
|
160
|
+
// Handles "data-method" on links such as:
|
161
|
+
// <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
|
162
|
+
handleMethod: function(link) {
|
163
|
+
var href = link.attr('href'),
|
164
|
+
method = link.data('method'),
|
165
|
+
target = link.attr('target'),
|
166
|
+
csrf_token = $('meta[name=csrf-token]').attr('content'),
|
167
|
+
csrf_param = $('meta[name=csrf-param]').attr('content'),
|
168
|
+
form = $('<form method="post" action="' + href + '"></form>'),
|
169
|
+
metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
|
170
|
+
|
171
|
+
if (csrf_param !== undefined && csrf_token !== undefined) {
|
172
|
+
metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
|
173
|
+
}
|
174
|
+
|
175
|
+
if (target) { form.attr('target', target); }
|
176
|
+
|
177
|
+
form.hide().append(metadata_input).appendTo('body');
|
178
|
+
form.submit();
|
179
|
+
},
|
180
|
+
|
181
|
+
/* Disables form elements:
|
182
|
+
- Caches element value in 'ujs:enable-with' data store
|
183
|
+
- Replaces element text with value of 'data-disable-with' attribute
|
184
|
+
- Sets disabled property to true
|
185
|
+
*/
|
186
|
+
disableFormElements: function(form) {
|
187
|
+
form.find(rails.disableSelector).each(function() {
|
188
|
+
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
189
|
+
element.data('ujs:enable-with', element[method]());
|
190
|
+
element[method](element.data('disable-with'));
|
191
|
+
element.prop('disabled', true);
|
192
|
+
});
|
193
|
+
},
|
194
|
+
|
195
|
+
/* Re-enables disabled form elements:
|
196
|
+
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
|
197
|
+
- Sets disabled property to false
|
198
|
+
*/
|
199
|
+
enableFormElements: function(form) {
|
200
|
+
form.find(rails.enableSelector).each(function() {
|
201
|
+
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
202
|
+
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
|
203
|
+
element.prop('disabled', false);
|
204
|
+
});
|
205
|
+
},
|
206
|
+
|
207
|
+
/* For 'data-confirm' attribute:
|
208
|
+
- Fires `confirm` event
|
209
|
+
- Shows the confirmation dialog
|
210
|
+
- Fires the `confirm:complete` event
|
211
|
+
|
212
|
+
Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
|
213
|
+
Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
|
214
|
+
Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
|
215
|
+
return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
|
216
|
+
*/
|
217
|
+
allowAction: function(element) {
|
218
|
+
var message = element.data('confirm'),
|
219
|
+
answer = false, callback;
|
220
|
+
if (!message) { return true; }
|
221
|
+
|
222
|
+
if (rails.fire(element, 'confirm')) {
|
223
|
+
answer = rails.confirm(message);
|
224
|
+
callback = rails.fire(element, 'confirm:complete', [answer]);
|
225
|
+
}
|
226
|
+
return answer && callback;
|
227
|
+
},
|
228
|
+
|
229
|
+
// Helper function which checks for blank inputs in a form that match the specified CSS selector
|
230
|
+
blankInputs: function(form, specifiedSelector, nonBlank) {
|
231
|
+
var inputs = $(), input,
|
232
|
+
selector = specifiedSelector || 'input,textarea';
|
233
|
+
form.find(selector).each(function() {
|
234
|
+
input = $(this);
|
235
|
+
// Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
|
236
|
+
if (nonBlank ? input.val() : !input.val()) {
|
237
|
+
inputs = inputs.add(input);
|
238
|
+
}
|
239
|
+
});
|
240
|
+
return inputs.length ? inputs : false;
|
241
|
+
},
|
242
|
+
|
243
|
+
// Helper function which checks for non-blank inputs in a form that match the specified CSS selector
|
244
|
+
nonBlankInputs: function(form, specifiedSelector) {
|
245
|
+
return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
|
246
|
+
},
|
247
|
+
|
248
|
+
// Helper function, needed to provide consistent behavior in IE
|
249
|
+
stopEverything: function(e) {
|
250
|
+
$(e.target).trigger('ujs:everythingStopped');
|
251
|
+
e.stopImmediatePropagation();
|
252
|
+
return false;
|
253
|
+
},
|
254
|
+
|
255
|
+
// find all the submit events directly bound to the form and
|
256
|
+
// manually invoke them. If anyone returns false then stop the loop
|
257
|
+
callFormSubmitBindings: function(form, event) {
|
258
|
+
var events = form.data('events'), continuePropagation = true;
|
259
|
+
if (events !== undefined && events['submit'] !== undefined) {
|
260
|
+
$.each(events['submit'], function(i, obj){
|
261
|
+
if (typeof obj.handler === 'function') return continuePropagation = obj.handler(event);
|
262
|
+
});
|
263
|
+
}
|
264
|
+
return continuePropagation;
|
265
|
+
},
|
266
|
+
|
267
|
+
// replace element's html with the 'data-disable-with' after storing original html
|
268
|
+
// and prevent clicking on it
|
269
|
+
disableElement: function(element) {
|
270
|
+
element.data('ujs:enable-with', element.html()); // store enabled state
|
271
|
+
element.html(element.data('disable-with')); // set to disabled state
|
272
|
+
element.bind('click.railsDisable', function(e) { // prevent further clicking
|
273
|
+
return rails.stopEverything(e)
|
274
|
+
});
|
275
|
+
},
|
276
|
+
|
277
|
+
// restore element to its original state which was disabled by 'disableElement' above
|
278
|
+
enableElement: function(element) {
|
279
|
+
if (element.data('ujs:enable-with') !== undefined) {
|
280
|
+
element.html(element.data('ujs:enable-with')); // set to old enabled state
|
281
|
+
// this should be element.removeData('ujs:enable-with')
|
282
|
+
// but, there is currently a bug in jquery which makes hyphenated data attributes not get removed
|
283
|
+
element.data('ujs:enable-with', false); // clean up cache
|
284
|
+
}
|
285
|
+
element.unbind('click.railsDisable'); // enable element
|
286
|
+
}
|
287
|
+
|
288
|
+
};
|
289
|
+
|
290
|
+
$.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
|
291
|
+
|
292
|
+
$(document).delegate(rails.linkDisableSelector, 'ajax:complete', function() {
|
293
|
+
rails.enableElement($(this));
|
294
|
+
});
|
295
|
+
|
296
|
+
$(document).delegate(rails.linkClickSelector, 'click.rails', function(e) {
|
297
|
+
var link = $(this), method = link.data('method'), data = link.data('params');
|
298
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
299
|
+
|
300
|
+
if (link.is(rails.linkDisableSelector)) rails.disableElement(link);
|
301
|
+
|
302
|
+
if (link.data('remote') !== undefined) {
|
303
|
+
if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
|
304
|
+
|
305
|
+
if (rails.handleRemote(link) === false) { rails.enableElement(link); }
|
306
|
+
return false;
|
307
|
+
|
308
|
+
} else if (link.data('method')) {
|
309
|
+
rails.handleMethod(link);
|
310
|
+
return false;
|
311
|
+
}
|
312
|
+
});
|
313
|
+
|
314
|
+
$(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) {
|
315
|
+
var link = $(this);
|
316
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
317
|
+
|
318
|
+
rails.handleRemote(link);
|
319
|
+
return false;
|
320
|
+
});
|
321
|
+
|
322
|
+
$(document).delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
|
323
|
+
var form = $(this),
|
324
|
+
remote = form.data('remote') !== undefined,
|
325
|
+
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
|
326
|
+
nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
|
327
|
+
|
328
|
+
if (!rails.allowAction(form)) return rails.stopEverything(e);
|
329
|
+
|
330
|
+
// skip other logic when required values are missing or file upload is present
|
331
|
+
if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
|
332
|
+
return rails.stopEverything(e);
|
333
|
+
}
|
334
|
+
|
335
|
+
if (remote) {
|
336
|
+
if (nonBlankFileInputs) {
|
337
|
+
return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
|
338
|
+
}
|
339
|
+
|
340
|
+
// If browser does not support submit bubbling, then this live-binding will be called before direct
|
341
|
+
// bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
|
342
|
+
if (!$.support.submitBubbles && $().jquery < '1.7' && rails.callFormSubmitBindings(form, e) === false) return rails.stopEverything(e);
|
343
|
+
|
344
|
+
rails.handleRemote(form);
|
345
|
+
return false;
|
346
|
+
|
347
|
+
} else {
|
348
|
+
// slight timeout so that the submit button gets properly serialized
|
349
|
+
setTimeout(function(){ rails.disableFormElements(form); }, 13);
|
350
|
+
}
|
351
|
+
});
|
352
|
+
|
353
|
+
$(document).delegate(rails.formInputClickSelector, 'click.rails', function(event) {
|
354
|
+
var button = $(this);
|
355
|
+
|
356
|
+
if (!rails.allowAction(button)) return rails.stopEverything(event);
|
357
|
+
|
358
|
+
// register the pressed submit button
|
359
|
+
var name = button.attr('name'),
|
360
|
+
data = name ? {name:name, value:button.val()} : null;
|
361
|
+
|
362
|
+
button.closest('form').data('ujs:submit-button', data);
|
363
|
+
});
|
364
|
+
|
365
|
+
$(document).delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) {
|
366
|
+
if (this == event.target) rails.disableFormElements($(this));
|
367
|
+
});
|
368
|
+
|
369
|
+
$(document).delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
|
370
|
+
if (this == event.target) rails.enableFormElements($(this));
|
371
|
+
});
|
372
|
+
|
373
|
+
})( jQuery );
|
@@ -0,0 +1,122 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2010 Remy Sharp, http://remysharp.com
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
*/
|
23
|
+
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
|
24
|
+
|
25
|
+
var Storage = function (type) {
|
26
|
+
function createCookie(name, value, days) {
|
27
|
+
var date, expires;
|
28
|
+
|
29
|
+
if (days) {
|
30
|
+
date = new Date();
|
31
|
+
date.setTime(date.getTime()+(days*24*60*60*1000));
|
32
|
+
expires = "; expires="+date.toGMTString();
|
33
|
+
} else {
|
34
|
+
expires = "";
|
35
|
+
}
|
36
|
+
document.cookie = name+"="+value+expires+"; path=/";
|
37
|
+
}
|
38
|
+
|
39
|
+
function readCookie(name) {
|
40
|
+
var nameEQ = name + "=",
|
41
|
+
ca = document.cookie.split(';'),
|
42
|
+
i, c;
|
43
|
+
|
44
|
+
for (i=0; i < ca.length; i++) {
|
45
|
+
c = ca[i];
|
46
|
+
while (c.charAt(0)==' ') {
|
47
|
+
c = c.substring(1,c.length);
|
48
|
+
}
|
49
|
+
|
50
|
+
if (c.indexOf(nameEQ) == 0) {
|
51
|
+
return c.substring(nameEQ.length,c.length);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
return null;
|
55
|
+
}
|
56
|
+
|
57
|
+
function setData(data) {
|
58
|
+
data = JSON.stringify(data);
|
59
|
+
if (type == 'session') {
|
60
|
+
window.name = data;
|
61
|
+
} else {
|
62
|
+
createCookie('localStorage', data, 365);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
function clearData() {
|
67
|
+
if (type == 'session') {
|
68
|
+
window.name = '';
|
69
|
+
} else {
|
70
|
+
createCookie('localStorage', '', 365);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
function getData() {
|
75
|
+
var data = type == 'session' ? window.name : readCookie('localStorage');
|
76
|
+
try {
|
77
|
+
return data ? JSON.parse(data) : {};
|
78
|
+
} catch(exc) { // bad cookie data -- XXX: hack by FND
|
79
|
+
return {}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
// initialise if there's already data
|
85
|
+
var data = getData();
|
86
|
+
|
87
|
+
return {
|
88
|
+
length: 0,
|
89
|
+
clear: function () {
|
90
|
+
data = {};
|
91
|
+
this.length = 0;
|
92
|
+
clearData();
|
93
|
+
},
|
94
|
+
getItem: function (key) {
|
95
|
+
return data[key] === undefined ? null : data[key];
|
96
|
+
},
|
97
|
+
key: function (i) {
|
98
|
+
// not perfect, but works
|
99
|
+
var ctr = 0;
|
100
|
+
for (var k in data) {
|
101
|
+
if (ctr == i) return k;
|
102
|
+
else ctr++;
|
103
|
+
}
|
104
|
+
return null;
|
105
|
+
},
|
106
|
+
removeItem: function (key) {
|
107
|
+
delete data[key];
|
108
|
+
this.length--;
|
109
|
+
setData(data);
|
110
|
+
},
|
111
|
+
setItem: function (key, value) {
|
112
|
+
data[key] = value+''; // forces the value to a string
|
113
|
+
this.length++;
|
114
|
+
setData(data);
|
115
|
+
}
|
116
|
+
};
|
117
|
+
};
|
118
|
+
|
119
|
+
if (typeof window.localStorage == 'undefined') window.localStorage = new Storage('local');
|
120
|
+
if (typeof window.sessionStorage == 'undefined') window.sessionStorage = new Storage('session');
|
121
|
+
|
122
|
+
})();
|