umlaut 3.0.0alpha5 → 3.0.0alpha6
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/umlaut/update_html.js +21 -0
- data/app/assets/javascripts/umlaut_ui.js +15 -0
- data/app/helpers/resolve_helper.rb +14 -4
- data/app/views/resolve/api.xml.builder +10 -14
- data/lib/#Untitled-1# +14 -0
- data/lib/umlaut/routes.rb +14 -1
- data/lib/umlaut/version.rb +1 -1
- data/lib/umlaut.rb +12 -9
- data/test/dummy/tmp/cache/assets/C5F/340/sprockets%2F99692920160b7a279b86a80415b79db7 +0 -0
- data/test/dummy/tmp/cache/assets/C70/4D0/sprockets%2F034ad2036e623081bd352800786dfe80 +0 -0
- data/test/dummy/tmp/cache/assets/CBB/9C0/sprockets%2F706f28923fb754cad04b9107c89986a1 +31 -0
- data/test/dummy/tmp/cache/assets/CBF/B60/sprockets%2F08ca89671549936265dcb673bf02e36f +0 -0
- data/test/dummy/tmp/cache/assets/CC9/9F0/sprockets%2F306166316e2cafd13c15e62b51a2339d +0 -0
- data/test/dummy/tmp/cache/assets/CF7/2B0/sprockets%2F25a7c73655bd3598173b39d9f98bcd46 +880 -0
- data/test/dummy/tmp/cache/assets/CFE/080/sprockets%2F37fe9f4255baddbd549a659914929398 +0 -0
- data/test/dummy/tmp/cache/assets/D0B/E10/sprockets%2F1444763abc4444a8e129efdb9a43235f +378 -0
- data/test/dummy/tmp/cache/assets/D1F/830/sprockets%2Fe6a7a907a8e9b43780a80fe69a92913d +11773 -0
- data/test/dummy/tmp/cache/assets/D22/060/sprockets%2F9aec77b768e91a802d284271c58e2f7e +21361 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D33/6D0/sprockets%2F500129c57f1146e556ec3aacd6cd38c1 +158 -0
- data/test/dummy/tmp/cache/assets/D50/7B0/sprockets%2F6df95fb9a4189df351c1c88546c84a1d +394 -0
- data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +877 -0
- data/test/dummy/tmp/cache/assets/D69/820/sprockets%2F55a4f1a7c4918d71c0d4fb5b7dd4c055 +9272 -0
- data/test/dummy/tmp/cache/assets/D71/6B0/sprockets%2Fde558b71b494cf09b1bf055c8dff0353 +53 -0
- data/test/dummy/tmp/cache/assets/D72/610/sprockets%2Fa8c708eeb30ef93de34d755d4f45d023 +864 -0
- data/test/dummy/tmp/cache/assets/D76/AD0/sprockets%2Fe2158cde93188cf5ab6457bc6d6602ec +41 -0
- data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +21744 -0
- data/test/dummy/tmp/cache/assets/D9B/770/sprockets%2F8aacf02eb7dbb0949704b28f27b87e0b +39 -0
- data/test/dummy/tmp/cache/assets/DD0/140/sprockets%2F1656d1d8f4c13fe42aff6553c6cdcda7 +11789 -0
- data/test/dummy/tmp/cache/assets/DE8/790/sprockets%2Fd1333bde2b9aafcc712d11dd09ab35d8 +0 -0
- data/test/dummy/tmp/cache/assets/DF1/AA0/sprockets%2Fedd37b0fdb6157fccb2297a8a10acc90 +9288 -0
- data/test/dummy/tmp/cache/assets/E03/570/sprockets%2F493bdc0ac14cd4f57fdfe4253f992bde +14 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E5F/960/sprockets%2Fdc007b6cad5c7ef08e33ec28cfff0ef6 +0 -0
- metadata +200 -98
- data/test/dummy/config/database-jhu.yml +0 -44
- data/test/dummy/config/database.yml +0 -53
Binary file
|
@@ -0,0 +1,158 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1325695618.015408:@value{ I"length:EFi�I"digest;
|
2
|
+
F"%4775385d891e5e7438555bff76d4cb96I"source;
|
3
|
+
FI"�/* update_html.js: Provide functions to update content on page with background responses from Umlaut. Used by Umlaut itself, as well as by third party callers.*/
|
4
|
+
|
5
|
+
(function($) {
|
6
|
+
|
7
|
+
function SectionTarget(config) {
|
8
|
+
//Add properties from config to ourself
|
9
|
+
$.extend(this, config);
|
10
|
+
|
11
|
+
//Defaults
|
12
|
+
if (this.selector == undefined)
|
13
|
+
this.selector = "#" + this.umlaut_section_id;
|
14
|
+
if (this.position == undefined)
|
15
|
+
this.position = "html";
|
16
|
+
|
17
|
+
}
|
18
|
+
//Callback default to no-op function please.
|
19
|
+
var noop = function() {};
|
20
|
+
SectionTarget.prototype.before_update = noop;
|
21
|
+
SectionTarget.prototype.after_update = noop;
|
22
|
+
SectionTarget.prototype.complete = noop;
|
23
|
+
|
24
|
+
SectionTarget.prototype.ensure_placement_destination = function() {
|
25
|
+
if ( this.selector == undefined) {
|
26
|
+
return null;
|
27
|
+
}
|
28
|
+
|
29
|
+
//Already have it cached?
|
30
|
+
if ( this.host_div_element ) {
|
31
|
+
return this.host_div_element;
|
32
|
+
}
|
33
|
+
|
34
|
+
var new_div = $('<div class="umlaut" style="display:none"></div>');
|
35
|
+
// Find the first thing matched by selector, and call the
|
36
|
+
// method specified in "action" string on it, giving it our
|
37
|
+
// HTML to replace. This works because our actions are
|
38
|
+
// all arguments that will take one method: html, before, after, append,
|
39
|
+
// prepend.
|
40
|
+
$(this.selector).eq(0)[ this.position ]( new_div );
|
41
|
+
|
42
|
+
//Cache for later
|
43
|
+
this.host_div_element = new_div;
|
44
|
+
return this.host_div_element;
|
45
|
+
};
|
46
|
+
|
47
|
+
|
48
|
+
// Define an object constructor on the global window object
|
49
|
+
// For our UmlautHtmlUpdater object.
|
50
|
+
function HtmlUpdater(umlaut_base, context_object) {
|
51
|
+
if (context_object == undefined)
|
52
|
+
context_object = "";
|
53
|
+
|
54
|
+
umlaut_base = umlaut_base.replace(/\/$/,'');
|
55
|
+
this.umlaut_uri = umlaut_base + '/resolve/partial_html_sections?umlaut.response_format=json&' + context_object;
|
56
|
+
|
57
|
+
this.section_targets = [];
|
58
|
+
|
59
|
+
this.add_section_target = function(config) {
|
60
|
+
this.section_targets.push( new SectionTarget(config) );
|
61
|
+
};
|
62
|
+
|
63
|
+
//default no-op call-backs
|
64
|
+
this.complete = function() {};
|
65
|
+
|
66
|
+
//Code for seeing if a URI is same origin or not borrowed from jQuery
|
67
|
+
this.is_remote_url = function(url) {
|
68
|
+
var regexp = /^(\w+:)?\/\/([^\/?#]+)/;
|
69
|
+
var parts = regexp.exec( url );
|
70
|
+
return (parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host));
|
71
|
+
}
|
72
|
+
|
73
|
+
this.update = function() {
|
74
|
+
// Need to capture because we won't have 'this' inside the ajax
|
75
|
+
// success handler.
|
76
|
+
var myself = this;
|
77
|
+
var dataType = this.is_remote_url( this.umlaut_uri ) ? "jsonp" : "json";
|
78
|
+
$.ajax({
|
79
|
+
url: myself.umlaut_uri,
|
80
|
+
dataType: dataType,
|
81
|
+
jsonp: "umlaut.jsonp",
|
82
|
+
error: function() {
|
83
|
+
$.error("Problem loading background elements.");
|
84
|
+
},
|
85
|
+
success: function(umlaut_response) {
|
86
|
+
for (var i = 0; i < myself.section_targets.length; i++) {
|
87
|
+
var section_target = myself.section_targets[i];
|
88
|
+
|
89
|
+
var umlaut_html_section = myself.find_umlaut_response_section(umlaut_response, section_target.umlaut_section_id);
|
90
|
+
|
91
|
+
if (umlaut_html_section == undefined) {
|
92
|
+
continue;
|
93
|
+
}
|
94
|
+
var count = null;
|
95
|
+
if (typeof umlaut_html_section.response_count != "undefined") {
|
96
|
+
count = parseInt(umlaut_html_section.response_count.value);
|
97
|
+
}
|
98
|
+
var existing_element = section_target.ensure_placement_destination();
|
99
|
+
var new_element = $('<div class="umlaut" style="display:none" class="' + section_target.umlaut_section_id +'"></div>');
|
100
|
+
new_element.html(umlaut_html_section.html_content);
|
101
|
+
|
102
|
+
|
103
|
+
var should_continue = section_target.before_update(new_element, count, section_target);
|
104
|
+
|
105
|
+
if (should_continue != false) {
|
106
|
+
existing_element.replaceWith(new_element);
|
107
|
+
|
108
|
+
section_target.host_div_element = new_element;
|
109
|
+
|
110
|
+
new_element.show();
|
111
|
+
|
112
|
+
section_target.after_update(new_element, count, section_target)
|
113
|
+
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
//Do we need to update again?
|
118
|
+
if (umlaut_response.partial_html_sections.in_progress) {
|
119
|
+
//Fix our update URI to be the one umlaut suggests
|
120
|
+
//Except strip out the umlaut.jsonp parameter, jquery is
|
121
|
+
//going to add that back in as desired.
|
122
|
+
myself.umlaut_uri =
|
123
|
+
umlaut_response.partial_html_sections.in_progress.refresh_url.replace(/[?;&]umlaut\.jsonp=[^;&]+/, '');
|
124
|
+
|
125
|
+
|
126
|
+
var refresh_seconds =
|
127
|
+
umlaut_response.partial_html_sections.in_progress.requested_wait_seconds;
|
128
|
+
window.setTimeout(function() { myself.update(); }, refresh_seconds * 1000);
|
129
|
+
|
130
|
+
} else {
|
131
|
+
myself.complete();
|
132
|
+
for (var i = 0; i < myself.section_targets.length; i++) {
|
133
|
+
var section_target = myself.section_targets[i];
|
134
|
+
section_target.complete(section_target);
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
}
|
139
|
+
});
|
140
|
+
};
|
141
|
+
this.find_umlaut_response_section = function(response, id) {
|
142
|
+
return $.grep(response.partial_html_sections.html_section, function(section) {
|
143
|
+
return section.id == id;
|
144
|
+
})[0];
|
145
|
+
};
|
146
|
+
|
147
|
+
};
|
148
|
+
|
149
|
+
//Put it in a global object, leave space for other things in "Umlaut" later.
|
150
|
+
if (window.Umlaut == undefined)
|
151
|
+
window.Umlaut = new Object();
|
152
|
+
window.Umlaut.HtmlUpdater = HtmlUpdater;
|
153
|
+
|
154
|
+
})(jQuery);
|
155
|
+
|
156
|
+
;
|
157
|
+
FI"
|
158
|
+
F"%e01f1933a5de5f5b1741d03facf2ea6a
|
@@ -0,0 +1,394 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1325695617.943021:@value{I"
|
2
|
+
class:EFI"BundledAsset;
|
3
|
+
FI"id;
|
4
|
+
F"%38b60d4d32b4009c6d62176a75903c4cI"logical_path;
|
5
|
+
F"jquery_ujs.jsI"
|
6
|
+
F"l/home/rochkind/.rvm/gems/ruby-1.9.3-p0/gems/jquery-rails-1.0.19/vendor/assets/javascripts/jquery_ujs.jsI"content_type;
|
7
|
+
FI"application/javascript;
|
8
|
+
FI"
|
9
|
+
mtime;
|
10
|
+
FI"2012-01-03T17:59:30-05:00;
|
11
|
+
FI" body;
|
12
|
+
FI"�;(function($, undefined) {
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Unobtrusive scripting adapter for jQuery
|
16
|
+
*
|
17
|
+
* Requires jQuery 1.6.0 or later.
|
18
|
+
* https://github.com/rails/jquery-ujs
|
19
|
+
|
20
|
+
* Uploading file using rails.js
|
21
|
+
* =============================
|
22
|
+
*
|
23
|
+
* By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
|
24
|
+
* in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
|
25
|
+
*
|
26
|
+
* The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
|
27
|
+
*
|
28
|
+
* Ex:
|
29
|
+
* $('form').live('ajax:aborted:file', function(event, elements){
|
30
|
+
* // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
|
31
|
+
* // Returning false in this handler tells rails.js to disallow standard form submission
|
32
|
+
* return false;
|
33
|
+
* });
|
34
|
+
*
|
35
|
+
* The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
|
36
|
+
*
|
37
|
+
* Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
|
38
|
+
* techniques like the iframe method to upload the file instead.
|
39
|
+
*
|
40
|
+
* Required fields in rails.js
|
41
|
+
* ===========================
|
42
|
+
*
|
43
|
+
* If any blank required inputs (required="required") are detected in the remote form, the whole form submission
|
44
|
+
* is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
|
45
|
+
*
|
46
|
+
* The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
|
47
|
+
*
|
48
|
+
* !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
|
49
|
+
* get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
|
50
|
+
*
|
51
|
+
* Ex:
|
52
|
+
* $('form').live('ajax:aborted:required', function(event, elements){
|
53
|
+
* // Returning false in this handler tells rails.js to submit the form anyway.
|
54
|
+
* // The blank required inputs are passed to this function in `elements`.
|
55
|
+
* return ! confirm("Would you like to submit the form with missing info?");
|
56
|
+
* });
|
57
|
+
*/
|
58
|
+
|
59
|
+
// Shorthand to make it a little easier to call public rails functions from within rails.js
|
60
|
+
var rails;
|
61
|
+
|
62
|
+
$.rails = rails = {
|
63
|
+
// Link elements bound by jquery-ujs
|
64
|
+
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
|
65
|
+
|
66
|
+
// Select elements bound by jquery-ujs
|
67
|
+
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
|
68
|
+
|
69
|
+
// Form elements bound by jquery-ujs
|
70
|
+
formSubmitSelector: 'form',
|
71
|
+
|
72
|
+
// Form input elements bound by jquery-ujs
|
73
|
+
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not(button[type])',
|
74
|
+
|
75
|
+
// Form input elements disabled during form submission
|
76
|
+
disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
|
77
|
+
|
78
|
+
// Form input elements re-enabled after form submission
|
79
|
+
enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
|
80
|
+
|
81
|
+
// Form required input elements
|
82
|
+
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
|
83
|
+
|
84
|
+
// Form file input elements
|
85
|
+
fileInputSelector: 'input:file',
|
86
|
+
|
87
|
+
// Link onClick disable selector with possible reenable after remote submission
|
88
|
+
linkDisableSelector: 'a[data-disable-with]',
|
89
|
+
|
90
|
+
// Make sure that every Ajax request sends the CSRF token
|
91
|
+
CSRFProtection: function(xhr) {
|
92
|
+
var token = $('meta[name="csrf-token"]').attr('content');
|
93
|
+
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
|
94
|
+
},
|
95
|
+
|
96
|
+
// Triggers an event on an element and returns false if the event result is false
|
97
|
+
fire: function(obj, name, data) {
|
98
|
+
var event = $.Event(name);
|
99
|
+
obj.trigger(event, data);
|
100
|
+
return event.result !== false;
|
101
|
+
},
|
102
|
+
|
103
|
+
// Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
|
104
|
+
confirm: function(message) {
|
105
|
+
return confirm(message);
|
106
|
+
},
|
107
|
+
|
108
|
+
// Default ajax function, may be overridden with custom function in $.rails.ajax
|
109
|
+
ajax: function(options) {
|
110
|
+
return $.ajax(options);
|
111
|
+
},
|
112
|
+
|
113
|
+
// Submits "remote" forms and links with ajax
|
114
|
+
handleRemote: function(element) {
|
115
|
+
var method, url, data,
|
116
|
+
crossDomain = element.data('cross-domain') || null,
|
117
|
+
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType),
|
118
|
+
options;
|
119
|
+
|
120
|
+
if (rails.fire(element, 'ajax:before')) {
|
121
|
+
|
122
|
+
if (element.is('form')) {
|
123
|
+
method = element.attr('method');
|
124
|
+
url = element.attr('action');
|
125
|
+
data = element.serializeArray();
|
126
|
+
// memoized value from clicked submit button
|
127
|
+
var button = element.data('ujs:submit-button');
|
128
|
+
if (button) {
|
129
|
+
data.push(button);
|
130
|
+
element.data('ujs:submit-button', null);
|
131
|
+
}
|
132
|
+
} else if (element.is(rails.inputChangeSelector)) {
|
133
|
+
method = element.data('method');
|
134
|
+
url = element.data('url');
|
135
|
+
data = element.serialize();
|
136
|
+
if (element.data('params')) data = data + "&" + element.data('params');
|
137
|
+
} else {
|
138
|
+
method = element.data('method');
|
139
|
+
url = element.attr('href');
|
140
|
+
data = element.data('params') || null;
|
141
|
+
}
|
142
|
+
|
143
|
+
options = {
|
144
|
+
type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
|
145
|
+
// stopping the "ajax:beforeSend" event will cancel the ajax request
|
146
|
+
beforeSend: function(xhr, settings) {
|
147
|
+
if (settings.dataType === undefined) {
|
148
|
+
xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
|
149
|
+
}
|
150
|
+
return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
|
151
|
+
},
|
152
|
+
success: function(data, status, xhr) {
|
153
|
+
element.trigger('ajax:success', [data, status, xhr]);
|
154
|
+
},
|
155
|
+
complete: function(xhr, status) {
|
156
|
+
element.trigger('ajax:complete', [xhr, status]);
|
157
|
+
},
|
158
|
+
error: function(xhr, status, error) {
|
159
|
+
element.trigger('ajax:error', [xhr, status, error]);
|
160
|
+
}
|
161
|
+
};
|
162
|
+
// Only pass url to `ajax` options if not blank
|
163
|
+
if (url) { options.url = url; }
|
164
|
+
|
165
|
+
return rails.ajax(options);
|
166
|
+
} else {
|
167
|
+
return false;
|
168
|
+
}
|
169
|
+
},
|
170
|
+
|
171
|
+
// Handles "data-method" on links such as:
|
172
|
+
// <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
|
173
|
+
handleMethod: function(link) {
|
174
|
+
var href = link.attr('href'),
|
175
|
+
method = link.data('method'),
|
176
|
+
target = link.attr('target'),
|
177
|
+
csrf_token = $('meta[name=csrf-token]').attr('content'),
|
178
|
+
csrf_param = $('meta[name=csrf-param]').attr('content'),
|
179
|
+
form = $('<form method="post" action="' + href + '"></form>'),
|
180
|
+
metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
|
181
|
+
|
182
|
+
if (csrf_param !== undefined && csrf_token !== undefined) {
|
183
|
+
metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
|
184
|
+
}
|
185
|
+
|
186
|
+
if (target) { form.attr('target', target); }
|
187
|
+
|
188
|
+
form.hide().append(metadata_input).appendTo('body');
|
189
|
+
form.submit();
|
190
|
+
},
|
191
|
+
|
192
|
+
/* Disables form elements:
|
193
|
+
- Caches element value in 'ujs:enable-with' data store
|
194
|
+
- Replaces element text with value of 'data-disable-with' attribute
|
195
|
+
- Sets disabled property to true
|
196
|
+
*/
|
197
|
+
disableFormElements: function(form) {
|
198
|
+
form.find(rails.disableSelector).each(function() {
|
199
|
+
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
200
|
+
element.data('ujs:enable-with', element[method]());
|
201
|
+
element[method](element.data('disable-with'));
|
202
|
+
element.prop('disabled', true);
|
203
|
+
});
|
204
|
+
},
|
205
|
+
|
206
|
+
/* Re-enables disabled form elements:
|
207
|
+
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
|
208
|
+
- Sets disabled property to false
|
209
|
+
*/
|
210
|
+
enableFormElements: function(form) {
|
211
|
+
form.find(rails.enableSelector).each(function() {
|
212
|
+
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
213
|
+
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
|
214
|
+
element.prop('disabled', false);
|
215
|
+
});
|
216
|
+
},
|
217
|
+
|
218
|
+
/* For 'data-confirm' attribute:
|
219
|
+
- Fires `confirm` event
|
220
|
+
- Shows the confirmation dialog
|
221
|
+
- Fires the `confirm:complete` event
|
222
|
+
|
223
|
+
Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
|
224
|
+
Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
|
225
|
+
Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
|
226
|
+
return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
|
227
|
+
*/
|
228
|
+
allowAction: function(element) {
|
229
|
+
var message = element.data('confirm'),
|
230
|
+
answer = false, callback;
|
231
|
+
if (!message) { return true; }
|
232
|
+
|
233
|
+
if (rails.fire(element, 'confirm')) {
|
234
|
+
answer = rails.confirm(message);
|
235
|
+
callback = rails.fire(element, 'confirm:complete', [answer]);
|
236
|
+
}
|
237
|
+
return answer && callback;
|
238
|
+
},
|
239
|
+
|
240
|
+
// Helper function which checks for blank inputs in a form that match the specified CSS selector
|
241
|
+
blankInputs: function(form, specifiedSelector, nonBlank) {
|
242
|
+
var inputs = $(), input,
|
243
|
+
selector = specifiedSelector || 'input,textarea';
|
244
|
+
form.find(selector).each(function() {
|
245
|
+
input = $(this);
|
246
|
+
// Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
|
247
|
+
if (nonBlank ? input.val() : !input.val()) {
|
248
|
+
inputs = inputs.add(input);
|
249
|
+
}
|
250
|
+
});
|
251
|
+
return inputs.length ? inputs : false;
|
252
|
+
},
|
253
|
+
|
254
|
+
// Helper function which checks for non-blank inputs in a form that match the specified CSS selector
|
255
|
+
nonBlankInputs: function(form, specifiedSelector) {
|
256
|
+
return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
|
257
|
+
},
|
258
|
+
|
259
|
+
// Helper function, needed to provide consistent behavior in IE
|
260
|
+
stopEverything: function(e) {
|
261
|
+
$(e.target).trigger('ujs:everythingStopped');
|
262
|
+
e.stopImmediatePropagation();
|
263
|
+
return false;
|
264
|
+
},
|
265
|
+
|
266
|
+
// find all the submit events directly bound to the form and
|
267
|
+
// manually invoke them. If anyone returns false then stop the loop
|
268
|
+
callFormSubmitBindings: function(form, event) {
|
269
|
+
var events = form.data('events'), continuePropagation = true;
|
270
|
+
if (events !== undefined && events['submit'] !== undefined) {
|
271
|
+
$.each(events['submit'], function(i, obj){
|
272
|
+
if (typeof obj.handler === 'function') return continuePropagation = obj.handler(event);
|
273
|
+
});
|
274
|
+
}
|
275
|
+
return continuePropagation;
|
276
|
+
},
|
277
|
+
|
278
|
+
// replace element's html with the 'data-disable-with' after storing original html
|
279
|
+
// and prevent clicking on it
|
280
|
+
disableElement: function(element) {
|
281
|
+
element.data('ujs:enable-with', element.html()); // store enabled state
|
282
|
+
element.html(element.data('disable-with')); // set to disabled state
|
283
|
+
element.bind('click.railsDisable', function(e) { // prevent further clicking
|
284
|
+
return rails.stopEverything(e)
|
285
|
+
});
|
286
|
+
},
|
287
|
+
|
288
|
+
// restore element to its original state which was disabled by 'disableElement' above
|
289
|
+
enableElement: function(element) {
|
290
|
+
if (element.data('ujs:enable-with') !== undefined) {
|
291
|
+
element.html(element.data('ujs:enable-with')); // set to old enabled state
|
292
|
+
// this should be element.removeData('ujs:enable-with')
|
293
|
+
// but, there is currently a bug in jquery which makes hyphenated data attributes not get removed
|
294
|
+
element.data('ujs:enable-with', false); // clean up cache
|
295
|
+
}
|
296
|
+
element.unbind('click.railsDisable'); // enable element
|
297
|
+
}
|
298
|
+
|
299
|
+
};
|
300
|
+
|
301
|
+
$.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
|
302
|
+
|
303
|
+
$(document).delegate(rails.linkDisableSelector, 'ajax:complete', function() {
|
304
|
+
rails.enableElement($(this));
|
305
|
+
});
|
306
|
+
|
307
|
+
$(document).delegate(rails.linkClickSelector, 'click.rails', function(e) {
|
308
|
+
var link = $(this), method = link.data('method'), data = link.data('params');
|
309
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
310
|
+
|
311
|
+
if (link.is(rails.linkDisableSelector)) rails.disableElement(link);
|
312
|
+
|
313
|
+
if (link.data('remote') !== undefined) {
|
314
|
+
if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
|
315
|
+
|
316
|
+
if (rails.handleRemote(link) === false) { rails.enableElement(link); }
|
317
|
+
return false;
|
318
|
+
|
319
|
+
} else if (link.data('method')) {
|
320
|
+
rails.handleMethod(link);
|
321
|
+
return false;
|
322
|
+
}
|
323
|
+
});
|
324
|
+
|
325
|
+
$(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) {
|
326
|
+
var link = $(this);
|
327
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
328
|
+
|
329
|
+
rails.handleRemote(link);
|
330
|
+
return false;
|
331
|
+
});
|
332
|
+
|
333
|
+
$(document).delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
|
334
|
+
var form = $(this),
|
335
|
+
remote = form.data('remote') !== undefined,
|
336
|
+
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
|
337
|
+
nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
|
338
|
+
|
339
|
+
if (!rails.allowAction(form)) return rails.stopEverything(e);
|
340
|
+
|
341
|
+
// skip other logic when required values are missing or file upload is present
|
342
|
+
if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
|
343
|
+
return rails.stopEverything(e);
|
344
|
+
}
|
345
|
+
|
346
|
+
if (remote) {
|
347
|
+
if (nonBlankFileInputs) {
|
348
|
+
return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
|
349
|
+
}
|
350
|
+
|
351
|
+
// If browser does not support submit bubbling, then this live-binding will be called before direct
|
352
|
+
// bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
|
353
|
+
if (!$.support.submitBubbles && $().jquery < '1.7' && rails.callFormSubmitBindings(form, e) === false) return rails.stopEverything(e);
|
354
|
+
|
355
|
+
rails.handleRemote(form);
|
356
|
+
return false;
|
357
|
+
|
358
|
+
} else {
|
359
|
+
// slight timeout so that the submit button gets properly serialized
|
360
|
+
setTimeout(function(){ rails.disableFormElements(form); }, 13);
|
361
|
+
}
|
362
|
+
});
|
363
|
+
|
364
|
+
$(document).delegate(rails.formInputClickSelector, 'click.rails', function(event) {
|
365
|
+
var button = $(this);
|
366
|
+
|
367
|
+
if (!rails.allowAction(button)) return rails.stopEverything(event);
|
368
|
+
|
369
|
+
// register the pressed submit button
|
370
|
+
var name = button.attr('name'),
|
371
|
+
data = name ? {name:name, value:button.val()} : null;
|
372
|
+
|
373
|
+
button.closest('form').data('ujs:submit-button', data);
|
374
|
+
});
|
375
|
+
|
376
|
+
$(document).delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) {
|
377
|
+
if (this == event.target) rails.disableFormElements($(this));
|
378
|
+
});
|
379
|
+
|
380
|
+
$(document).delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
|
381
|
+
if (this == event.target) rails.enableFormElements($(this));
|
382
|
+
});
|
383
|
+
|
384
|
+
})( jQuery );
|
385
|
+
;
|
386
|
+
FI"asset_paths;
|
387
|
+
F["l/home/rochkind/.rvm/gems/ruby-1.9.3-p0/gems/jquery-rails-1.0.19/vendor/assets/javascripts/jquery_ujs.jsI"dependency_paths;
|
388
|
+
F[{I" path;
|
389
|
+
F"l/home/rochkind/.rvm/gems/ruby-1.9.3-p0/gems/jquery-rails-1.0.19/vendor/assets/javascripts/jquery_ujs.jsI"
|
390
|
+
mtime;
|
391
|
+
FIu: Time
|
392
|
+
T:offseti���I"hexdigest;
|
393
|
+
F"%2caafa0c2617f9985c1a0b07ebaefadfI"
|
394
|
+
F"%46dde6621c301f4928e3b34efee9e3b5
|