fe 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +16 -36
- data/app/assets/javascripts/fe/admin.js +0 -1
- data/app/assets/javascripts/fe/fe.admin.js +40 -16
- data/app/assets/javascripts/fe/fe.common.js +48 -14
- data/app/assets/javascripts/fe/fe.public.js +1 -414
- data/app/assets/javascripts/fe/fe.public.nojquery.js +450 -0
- data/app/assets/javascripts/fe/jquery.validate.pack.js +3 -15
- data/app/assets/stylesheets/360front.css +0 -0
- data/app/assets/stylesheets/fe/fe.screen.css.scss.erb +69 -10
- data/app/controllers/fe/admin/elements_controller.rb +64 -48
- data/app/controllers/fe/admin/email_templates_controller.rb +2 -2
- data/app/controllers/fe/admin/question_pages_controller.rb +1 -1
- data/app/controllers/fe/admin/question_sheets_controller.rb +2 -103
- data/app/controllers/fe/concerns/admin/question_sheets_controller_concern.rb +112 -0
- data/app/controllers/fe/concerns/answer_pages_controller_concern.rb +2 -1
- data/app/controllers/fe/concerns/answer_sheets_controller_concern.rb +1 -1
- data/app/controllers/fe/concerns/application_controller_concern.rb +13 -0
- data/app/controllers/fe/reference_sheets_controller.rb +2 -0
- data/app/controllers/fe/references_controller.rb +1 -0
- data/app/helpers/fe/application_helper.rb +5 -0
- data/app/mailers/fe/notifier.rb +11 -4
- data/app/models/answer_sheet.rb +2 -0
- data/app/models/fe/application.rb +2 -1
- data/app/models/fe/concerns/answer_pages_presenter_concern.rb +10 -1
- data/app/models/fe/concerns/answer_sheet_concern.rb +38 -8
- data/app/models/fe/concerns/choice_field_concern.rb +17 -10
- data/app/models/fe/date_field.rb +1 -1
- data/app/models/fe/element.rb +105 -31
- data/app/models/fe/page.rb +52 -20
- data/app/models/fe/page_element.rb +6 -1
- data/app/models/fe/page_link.rb +6 -3
- data/app/models/fe/person.rb +11 -8
- data/app/models/fe/question.rb +2 -6
- data/app/models/fe/question_grid.rb +1 -1
- data/app/models/fe/question_grid_with_total.rb +15 -0
- data/app/models/fe/question_set.rb +1 -1
- data/app/models/fe/question_sheet.rb +15 -13
- data/app/models/fe/reference_question.rb +0 -10
- data/app/models/fe/reference_sheet.rb +17 -13
- data/app/models/staff.rb +2 -0
- data/app/validators/email_validator.rb +11 -0
- data/app/views/fe/admin/elements/create.js.erb +1 -0
- data/app/views/fe/admin/elements/drop.js.erb +1 -0
- data/app/views/fe/admin/elements/duplicate.js.erb +1 -0
- data/app/views/fe/admin/panels/_advanced_options.html.erb +9 -3
- data/app/views/fe/admin/panels/_common_fields.html.erb +19 -5
- data/app/views/fe/admin/panels/_page.html.erb +1 -1
- data/app/views/fe/admin/panels/_prop_choice_field.html.erb +20 -11
- data/app/views/fe/admin/panels/_prop_element.html.erb +2 -9
- data/app/views/fe/admin/panels/_prop_page.html.erb +8 -3
- data/app/views/fe/admin/panels/_prop_paragraph.html.erb +38 -24
- data/app/views/fe/admin/panels/_prop_section.html.erb +8 -2
- data/app/views/fe/admin/panels/_prop_sheet.html.erb +4 -1
- data/app/views/fe/admin/question_pages/_element.html.erb +11 -1
- data/app/views/fe/answer_pages/_answer_page.html.erb +9 -8
- data/app/views/fe/answer_pages/_element.html.erb +6 -7
- data/app/views/fe/answer_pages/_page_name.html.erb +1 -0
- data/app/views/fe/answer_pages/update.js.erb +3 -3
- data/app/views/fe/answer_sheets/_answer_sheet.html.erb +3 -3
- data/app/views/fe/answer_sheets/_element.html.erb +52 -34
- data/app/views/fe/answer_sheets/_incomplete.html.erb +1 -1
- data/app/views/fe/answer_sheets/_page_link.html.erb +2 -2
- data/app/views/fe/answer_sheets/_pages_list.html.erb +3 -3
- data/app/views/fe/answer_sheets/_submit_to.html.erb +1 -0
- data/app/views/fe/answer_sheets/edit.html.erb +14 -14
- data/app/views/fe/answer_sheets/incomplete.js.erb +3 -0
- data/app/views/fe/answer_sheets/index.html.erb +3 -3
- data/app/views/fe/answer_sheets/show.html.erb +1 -1
- data/app/views/fe/applications/_logout.html.erb +1 -0
- data/app/views/fe/applications/show.html.erb +1 -0
- data/app/views/fe/questions/fe/_acceptance.html.erb +3 -3
- data/app/views/fe/questions/fe/_attachment_field.html.erb +7 -3
- data/app/views/fe/questions/fe/_checkbox_field.html.erb +26 -24
- data/app/views/fe/questions/fe/_date_field.html.erb +1 -2
- data/app/views/fe/questions/fe/_date_field_mmyy.html.erb +2 -2
- data/app/views/fe/questions/fe/_drop_down_field.html.erb +3 -2
- data/app/views/fe/questions/fe/_paragraph.html.erb +1 -1
- data/app/views/fe/questions/fe/_question_grid.html.erb +14 -9
- data/app/views/fe/questions/fe/_question_grid_with_total.html.erb +21 -14
- data/app/views/fe/questions/fe/_questions.html.erb +2 -2
- data/app/views/fe/questions/fe/_radio_button_field.html.erb +12 -11
- data/app/views/fe/questions/fe/_rating.html.erb +9 -8
- data/app/views/fe/questions/fe/_reference_discipler.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_friend.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_parent.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_peer.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_question.html.erb +22 -15
- data/app/views/fe/questions/fe/_reference_roommate.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_spiritual.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_staff.html.erb +1 -1
- data/app/views/fe/questions/fe/_section.html.erb +1 -1
- data/app/views/fe/questions/fe/_text_area_field.html.erb +10 -3
- data/app/views/fe/questions/fe/_text_field.html.erb +1 -1
- data/app/views/fe/questions/fe/_yes_no_field.erb +3 -3
- data/app/views/fe/reference_pages/_reference.html.erb +11 -11
- data/app/views/fe/reference_pages/edit.html.erb +7 -7
- data/app/views/fe/reference_sheets/done.html.erb +2 -2
- data/app/views/fe/reference_sheets/not_found.html.erb +4 -4
- data/app/views/fe/references/edit.html.erb +6 -6
- data/app/views/fe/references/show.html.erb +7 -7
- data/app/views/fe/references/submit.js.erb +1 -1
- data/app/views/fe/submit_pages/_thankyou.html.erb +1 -1
- data/app/views/fe/submit_pages/edit.html.erb +9 -9
- data/app/views/layouts/fe/_error_messages_for.html.erb +7 -0
- data/app/views/layouts/fe/application.html.erb +1 -1
- data/config/routes.rb +0 -36
- data/db/migrate/20131003044250_create_reference_sheets.rb +1 -0
- data/db/migrate/20140623153424_create_fe_people.rb +1 -1
- data/db/migrate/20140624180246_create_fe_addresses.rb +1 -1
- data/db/migrate/20140624182216_create_fe_phone_numbers.rb +16 -0
- data/db/migrate/20140625160545_create_fe_users.rb +1 -1
- data/db/migrate/20150504221439_add_all_element_ids_to_pages.rb +5 -0
- data/db/migrate/20150713022326_add_locale_columns.rb +9 -0
- data/db/migrate/20150714220730_add_locale_to_answer_sheet.rb +5 -0
- data/db/migrate/20150928085325_change_pages_all_element_ids_to_text.rb +5 -0
- data/db/migrate/20150930191538_add_locale_to_reference_sheets.rb +5 -0
- data/lib/access_key_generator.rb +12 -0
- data/lib/distinct_distinct_patch.rb +20 -0
- data/lib/fe.rb +4 -0
- data/lib/fe/engine.rb +16 -4
- data/lib/fe/version.rb +1 -1
- data/spec/controllers/fe/admin/elements_controller_spec.rb +201 -1
- data/spec/controllers/fe/admin/email_templates_controller_spec.rb +26 -1
- data/spec/controllers/fe/admin/question_pages_controller_spec.rb +8 -1
- data/spec/controllers/fe/admin/question_sheets_controller_spec.rb +48 -1
- data/spec/controllers/fe/answer_pages_controller_spec.rb +73 -1
- data/spec/controllers/fe/answer_sheets_controller_spec.rb +80 -1
- data/spec/controllers/fe/reference_pages_controller.rb +4 -0
- data/spec/controllers/fe/references_controller_spec.rb +4 -0
- data/spec/controllers/fe/submit_pages_controller_spec.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +9 -0
- data/spec/dummy/app/models/application.rb +3 -0
- data/spec/dummy/app/models/person.rb +11 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/config/application.rb +2 -1
- data/spec/dummy/config/database.yml +20 -17
- data/spec/dummy/config/environments/production.rb +1 -5
- data/spec/dummy/config/environments/test.rb +3 -1
- data/spec/dummy/config/initializers/fast_gettext.rb +5 -0
- data/spec/dummy/config/secrets.yml +2 -2
- data/spec/dummy/db/migrate/20141203214017_core.fe_engine.rb +92 -0
- data/spec/dummy/db/migrate/20141203214018_create_reference_sheets.fe_engine.rb +25 -0
- data/spec/dummy/db/migrate/20141203214019_add_element_and_answer_fields.fe_engine.rb +11 -0
- data/spec/dummy/db/migrate/20141203214020_create_email_templates.fe_engine.rb +18 -0
- data/spec/dummy/db/migrate/20141203214021_add_max_lengths.fe_engine.rb +9 -0
- data/spec/dummy/db/migrate/20141203214022_create_join_table.fe_engine.rb +12 -0
- data/spec/dummy/db/migrate/20141203214023_remove_question_id_from_element.fe_engine.rb +10 -0
- data/spec/dummy/db/migrate/20141203214024_create_fe_people.fe_engine.rb +13 -0
- data/spec/dummy/db/migrate/20141203214025_create_fe_addresses.fe_engine.rb +21 -0
- data/{db/migrate/20140624182216_create_create_fe_phone_numbers.rb → spec/dummy/db/migrate/20141203214026_create_create_fe_phone_numbers.fe_engine.rb} +1 -0
- data/spec/dummy/db/migrate/20141203214027_create_fe_users.fe_engine.rb +13 -0
- data/spec/dummy/db/migrate/20141203214028_add_conditional_type_to_elements.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20141203214029_add_conditional_answer_to_elements.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20141203214030_remove_short_value_column.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20141203214031_move_conditional_ids_used_for_choice_field_to_their_own_column.fe_engine.rb +8 -0
- data/spec/dummy/db/migrate/20150123215803_create_users.rb +9 -0
- data/spec/dummy/db/migrate/20150504222619_add_all_element_ids_to_pages.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20150930190001_create_fe_phone_numbers.fe_engine.rb +20 -0
- data/spec/dummy/db/migrate/20150930190002_add_locale_columns.fe_engine.rb +10 -0
- data/spec/dummy/db/migrate/20150930190003_add_locale_to_answer_sheet.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20150930190004_change_pages_all_element_ids_to_text.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20150930191756_add_locale_to_reference_sheets.fe_engine.rb +6 -0
- data/spec/dummy/db/schema.rb +50 -20
- data/spec/dummy/log/development.log +5 -0
- data/spec/factories/applications.rb +0 -1
- data/spec/factories/dummy_applications.rb +6 -0
- data/spec/factories/dummy_people.rb +6 -0
- data/spec/factories/dummy_users.rb +6 -0
- data/spec/factories/elements.rb +28 -3
- data/spec/factories/email_templates.rb +5 -0
- data/spec/factories/fe_email_templates.rb +9 -0
- data/spec/factories/fe_people.rb +0 -2
- data/spec/factories/fe_user.rb +6 -0
- data/spec/factories/question_sheet.rb +1 -1
- data/spec/factories/reference_sheets.rb +9 -0
- data/spec/mailers/fe/notifier_spec.rb +39 -0
- data/spec/models/fe/choice_field_spec.rb +20 -0
- data/spec/models/fe/element_spec.rb +185 -0
- data/spec/models/fe/page_spec.rb +112 -0
- data/spec/models/fe/question_sheet_spec.rb +106 -0
- data/spec/models/fe/reference_sheet_spec.rb +20 -0
- data/spec/rails_helper.rb +41 -13
- data/spec/support/choices.xml +6 -0
- metadata +136 -48
- data/app/assets/javascripts/fe/rails.extra.js +0 -6
- data/app/controllers/fe/applications_controller.rb +0 -183
- data/app/controllers/fe/payments_controller.rb +0 -184
- data/app/models/fe/payment.rb +0 -77
- data/app/models/fe/payment_question.rb +0 -22
- data/app/views/fe/admin/panels/_prop_payment_question.html.erb +0 -1
- data/app/views/fe/application/_logout.html.erb +0 -1
- data/app/views/fe/payment_pages/_credit.html.erb +0 -47
- data/app/views/fe/payment_pages/_mail.html.erb +0 -27
- data/app/views/fe/payment_pages/_payment.html.erb +0 -6
- data/app/views/fe/payment_pages/_staff.html.erb +0 -25
- data/app/views/fe/payment_pages/_staff_results.html.erb +0 -17
- data/app/views/fe/payment_pages/edit.html.erb +0 -75
- data/app/views/fe/payment_pages/staff_search.js.erb +0 -2
- data/app/views/fe/payments/_credit.html.erb +0 -47
- data/app/views/fe/payments/_errors.html.erb +0 -1
- data/app/views/fe/payments/_payment.html.erb +0 -13
- data/app/views/fe/payments/_staff.html.erb +0 -21
- data/app/views/fe/payments/_staff_results.html.erb +0 -18
- data/app/views/fe/payments/approve.js.erb +0 -3
- data/app/views/fe/payments/create.js.erb +0 -19
- data/app/views/fe/payments/destroy.js.erb +0 -7
- data/app/views/fe/payments/edit.html.erb +0 -56
- data/app/views/fe/payments/error.js.erb +0 -3
- data/app/views/fe/payments/no_access.html.erb +0 -7
- data/app/views/fe/payments/staff_search.js.erb +0 -1
- data/app/views/fe/payments/update.html.erb +0 -24
- data/app/views/fe/questions/fe/_payment_question.html.erb +0 -70
- data/db/migrate/20140828045339_create_payments.rb +0 -13
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/factories/payments.rb +0 -7
- data/spec/models/fe/payment_question_spec.rb +0 -65
@@ -0,0 +1,450 @@
|
|
1
|
+
//= require fe/fe.common.js
|
2
|
+
|
3
|
+
// used by answer sheets
|
4
|
+
|
5
|
+
(function($) {
|
6
|
+
//debugger;
|
7
|
+
$(function() {
|
8
|
+
|
9
|
+
$(document).on('click', '.save_button', function() {
|
10
|
+
$.fe.pageHandler.savePage($(this).closest('.answer-page'), true);
|
11
|
+
});
|
12
|
+
|
13
|
+
$(document).on('click', '.reference_send_invite', function() {
|
14
|
+
var el = this;
|
15
|
+
var data = $(el).closest('form').serializeArray();
|
16
|
+
|
17
|
+
data.push({name: 'answer_sheet_type', value: answer_sheet_type});
|
18
|
+
$.ajax({url: $(el).attr('href'), data: data, dataType: 'script', type: 'POST',
|
19
|
+
beforeSend: function (xhr) {
|
20
|
+
$('body').trigger('ajax:loading', xhr);
|
21
|
+
},
|
22
|
+
complete: function (xhr) {
|
23
|
+
$('body').trigger('ajax:complete', xhr);
|
24
|
+
},
|
25
|
+
error: function (xhr, status, error) {
|
26
|
+
$('body').trigger('ajax:failure', [xhr, status, error]);
|
27
|
+
}
|
28
|
+
});
|
29
|
+
return false;
|
30
|
+
});
|
31
|
+
$(document).on('focus', 'textarea[maxlength]', function() {
|
32
|
+
var max = parseInt($(this).attr('maxlength'));
|
33
|
+
$(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
|
34
|
+
}).on('keyup', 'textarea[maxlength]', function(){
|
35
|
+
var max = parseInt($(this).attr('maxlength'));
|
36
|
+
if($(this).val().length > max){
|
37
|
+
$(this).val($(this).val().substr(0, $(this).attr('maxlength')));
|
38
|
+
}
|
39
|
+
$(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
|
40
|
+
}).on('blur', 'textarea[maxlength]', function() {
|
41
|
+
$(this).parent().find('.charsRemaining').html('');
|
42
|
+
});
|
43
|
+
});
|
44
|
+
|
45
|
+
$.fe = {};
|
46
|
+
$.fe.pageHandler = {
|
47
|
+
initialize : function(page) {
|
48
|
+
this.auto_save_frequency = 30; // seconds
|
49
|
+
this.timer_id = null;
|
50
|
+
|
51
|
+
this.current_page = page;
|
52
|
+
$('#' + page).data('form_data', this.captureForm($('#' + page)));
|
53
|
+
this.registerAutoSave();
|
54
|
+
|
55
|
+
this.page_validation = {}; // validation objects for each page
|
56
|
+
this.enableValidation(page);
|
57
|
+
|
58
|
+
$(document).trigger('feShowPage'); // allow other code to handle show page event by using $(document).on('feShowPage', function() { ... });
|
59
|
+
|
60
|
+
// this.background_load = false;
|
61
|
+
// this.final_submission = false;
|
62
|
+
},
|
63
|
+
|
64
|
+
// swap to a different page
|
65
|
+
showPage : function(page) {
|
66
|
+
// hide the old
|
67
|
+
$('#' + this.current_page + '-li').removeClass('active');
|
68
|
+
$('#' + this.current_page).hide();
|
69
|
+
|
70
|
+
// HACK: Need to clear the main error message when returning to the submit page
|
71
|
+
// It is very confusing to users to be there when they revisit the page
|
72
|
+
if ((page=='submit_page') && ($('#submit_message')[0] != null)) $('#submit_message').hide();
|
73
|
+
if ((page=='submit_page') && ($('#application_errors')[0] != null)) $('#application_errors').html('');
|
74
|
+
|
75
|
+
// show the new
|
76
|
+
// $('#' + page + '-li').removeClass('incomplete');
|
77
|
+
// $('#' + page + '-li').removeClass('valid');
|
78
|
+
$('#' + page + '-li').addClass('active');
|
79
|
+
$('#' + page).show();
|
80
|
+
this.current_page = page;
|
81
|
+
this.registerAutoSave(page);
|
82
|
+
fixGridColumnWidths();
|
83
|
+
$(document).trigger('feShowPage'); // allow other code to handle show page event by using $(document).on('feShowPage', function() { ... });
|
84
|
+
},
|
85
|
+
|
86
|
+
// callback onSuccess
|
87
|
+
pageLoadedBackground : function(response, textStatus, jqXHR) {
|
88
|
+
//this.pageLoaded(response, textStatus, jqXHR, true)
|
89
|
+
$.fe.pageHandler.pageLoaded(response, textStatus, jqXHR, true)
|
90
|
+
},
|
91
|
+
|
92
|
+
// callback onSuccess
|
93
|
+
pageLoaded : function(response, textStatus, jqXHR, background_load) {
|
94
|
+
background_load = typeof background_load !== 'undefined' ? background_load : false;
|
95
|
+
|
96
|
+
// var response = new String(transport.responseText);
|
97
|
+
var match = response.match(/<div id=\"(.*?)\"/i); // what did I just load? parse out the first div id
|
98
|
+
if( match != null )
|
99
|
+
{
|
100
|
+
var page = match[1];
|
101
|
+
if ($('#'+page).length > 0) {
|
102
|
+
$('#'+page).replaceWith(response);
|
103
|
+
} else {
|
104
|
+
$('#preview').append(response);
|
105
|
+
}
|
106
|
+
|
107
|
+
if (!background_load) { $.fe.pageHandler.showPage(page); } // show after load, unless loading in background
|
108
|
+
setUpJsHelpers();
|
109
|
+
$.fe.pageHandler.enableValidation(page);
|
110
|
+
if (background_load) { $.fe.pageHandler.validatePage(page, true); }
|
111
|
+
$('#' + page).data('form_data', $.fe.pageHandler.captureForm($('#' + page)));
|
112
|
+
}
|
113
|
+
$('#page_ajax_spinner').hide();
|
114
|
+
$('.reference_send_invite').button();
|
115
|
+
updateTotals();
|
116
|
+
$(document).trigger('fePageLoaded'); // allow other code to handle page load event by using $(document).on('fePageLoaded', function() { ... });
|
117
|
+
},
|
118
|
+
|
119
|
+
loadPage : function(page, url, background_load) {
|
120
|
+
background_load = typeof background_load !== 'undefined' ? background_load : false;
|
121
|
+
|
122
|
+
this.unregisterAutoSave(); // don't auto-save while loading/saving
|
123
|
+
// will register auto-save on new page once loaded/shown
|
124
|
+
|
125
|
+
this.validatePage(this.current_page); // mark current page as valid (or not) as we're leaving
|
126
|
+
this.savePage();
|
127
|
+
|
128
|
+
if (!background_load) {
|
129
|
+
if ($('a[name="main"]').length == 1) {
|
130
|
+
$.scrollTo('a[name="main"]');
|
131
|
+
} else {
|
132
|
+
$.scrollTo('#main');
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
if ($.fe.pageHandler.isPageLoaded(page) && page.match('no_cache') == null) {
|
137
|
+
// if already loaded (element exists) excluding pages that need reloading
|
138
|
+
if (!background_load) { $.fe.pageHandler.showPage(page); }
|
139
|
+
$('#page_ajax_spinner').hide();
|
140
|
+
} else {
|
141
|
+
$.ajax({
|
142
|
+
url: url,
|
143
|
+
type: 'GET',
|
144
|
+
data: {'answer_sheet_type':answer_sheet_type},
|
145
|
+
success: background_load ? $.fe.pageHandler.pageLoadedBackground : $.fe.pageHandler.pageLoaded,
|
146
|
+
error: function (xhr, status, error) {
|
147
|
+
alert("There was a problem loading that page. We've been notified and will fix it as soon as possible. To work on other pages, please refresh the website.");
|
148
|
+
document.location = document.location;
|
149
|
+
},
|
150
|
+
beforeSend: function (xhr) {
|
151
|
+
$('body').trigger('ajax:loading', xhr);
|
152
|
+
},
|
153
|
+
complete: function (xhr) {
|
154
|
+
$('body').trigger('ajax:complete', xhr);
|
155
|
+
}
|
156
|
+
});
|
157
|
+
}
|
158
|
+
},
|
159
|
+
|
160
|
+
// save form if any changes were made
|
161
|
+
savePage : function(page, force) {
|
162
|
+
if (page == null) page = $('#' + this.current_page);
|
163
|
+
// don't save more than once per second
|
164
|
+
timeNow = new Date();
|
165
|
+
if (typeof(lastSave) != "undefined" && lastSave && !force && (timeNow - lastSave < 1000)) {
|
166
|
+
return true;
|
167
|
+
}
|
168
|
+
lastSave = timeNow;
|
169
|
+
form_data = this.captureForm(page);
|
170
|
+
if( form_data ) {
|
171
|
+
if( page.data('form_data') == null || page.data('form_data').data !== form_data.data || force === true) { // if any changes
|
172
|
+
page.data('form_data', form_data);
|
173
|
+
$.ajax({url: form_data.url, type: 'put', data: form_data.data,
|
174
|
+
beforeSend: function (xhr) {
|
175
|
+
$('#spinner_' + page.attr('id')).show();
|
176
|
+
},
|
177
|
+
complete: function (xhr) {
|
178
|
+
$('#spinner_' + page.attr('id')).hide();
|
179
|
+
},
|
180
|
+
success: function (xhr) {
|
181
|
+
page.data('save_fails', 0)
|
182
|
+
},
|
183
|
+
error: function() {
|
184
|
+
save_fails = page.data('save_fails') == null ? 0 : page.data('save_fails');
|
185
|
+
save_fails += 1;
|
186
|
+
page.data('save_fails', save_fails)
|
187
|
+
|
188
|
+
if (save_fails >= 3) {
|
189
|
+
alert("There was a problem saving that page. We've been notified and will fix it as soon as possible. This might happen if you logged out on another tab. The page will now reload.");
|
190
|
+
document.location = document.location;
|
191
|
+
} else {
|
192
|
+
page.data('save_fails', save_fails + 1)
|
193
|
+
page.data('form_data', null); // on error, force save for next call to save
|
194
|
+
// WARNING: race conditions with load & show?
|
195
|
+
// sort of a mess if save fails while another page is already loading!!
|
196
|
+
}
|
197
|
+
}});
|
198
|
+
}
|
199
|
+
}
|
200
|
+
// Update last saved stamp
|
201
|
+
},
|
202
|
+
|
203
|
+
savePages : function(force) {
|
204
|
+
$('.answer-page').each(function() {$.fe.pageHandler.savePage(null, force)})
|
205
|
+
},
|
206
|
+
|
207
|
+
// setup a timer to auto-save (only one timer, for the page being viewed)
|
208
|
+
registerAutoSave: function(page) {
|
209
|
+
this.timer_id = setInterval(this.savePages, this.auto_save_frequency * 1000);
|
210
|
+
},
|
211
|
+
|
212
|
+
unregisterAutoSave: function() {
|
213
|
+
if( this.timer_id != null )
|
214
|
+
{
|
215
|
+
clearInterval(this.timer_id);
|
216
|
+
this.timer_id = null;
|
217
|
+
}
|
218
|
+
},
|
219
|
+
|
220
|
+
// serialize form data and extract url to post to
|
221
|
+
captureForm : function(page) {
|
222
|
+
form_el = $('#' + page.attr('id') + '-form');
|
223
|
+
if( form_el[0] == null ) return null;
|
224
|
+
return {url: form_el.attr('action'), data: form_el.serialize() + '&answer_sheet_type=' + answer_sheet_type};
|
225
|
+
},
|
226
|
+
|
227
|
+
|
228
|
+
// enable form validation (when form is loaded)
|
229
|
+
enableValidation : function(page) {
|
230
|
+
$('#' + page + '-form').validate({onsubmit:false, focusInvalid:true, onfocusout: function(element) { this.element(element);}});
|
231
|
+
$('#' + page + '-form :input').change(function() {
|
232
|
+
$.fe.pageHandler.validatePage(page, true);
|
233
|
+
});
|
234
|
+
},
|
235
|
+
|
236
|
+
validatePage : function(page, page_classes_only) {
|
237
|
+
page_classes_only = typeof page_classes_only !== 'undefined' ? page_classes_only : false;
|
238
|
+
|
239
|
+
try {
|
240
|
+
var li = $('#' + page + '-li');
|
241
|
+
var form = $('#' + page + '-form');
|
242
|
+
|
243
|
+
valid = form.valid();
|
244
|
+
|
245
|
+
if (!page_classes_only) {
|
246
|
+
// Move radio button errors up
|
247
|
+
$('input[type=radio].error').closest('tr').addClass('error');
|
248
|
+
$('.choice_field input[type=radio].error').removeClass('error')
|
249
|
+
.closest('.choice_field')
|
250
|
+
.addClass('error');
|
251
|
+
$('div.yesno label.error').hide();
|
252
|
+
}
|
253
|
+
|
254
|
+
if (valid) {
|
255
|
+
li.removeClass('incomplete');
|
256
|
+
li.addClass('complete');
|
257
|
+
$(document).trigger('fePageValid', page); // allow other code to handle show page event by using $(document).on('fePageValid', function() { ... });
|
258
|
+
} else {
|
259
|
+
li.removeClass('complete');
|
260
|
+
li.addClass('incomplete');
|
261
|
+
$(document).trigger('fePageInvalid', page); // allow other code to handle show page event by using $(document).on('fePageInvalid', function() { ... });
|
262
|
+
}
|
263
|
+
return valid;
|
264
|
+
}
|
265
|
+
catch(err) {
|
266
|
+
|
267
|
+
// If the user clicks too quickly, sometimes the page element isn't properly defined yet.
|
268
|
+
// If we don't catch the error, js stops execution. If we catch it, the user just has to click again.
|
269
|
+
}
|
270
|
+
$('page_ajax_spinner').hide();
|
271
|
+
},
|
272
|
+
|
273
|
+
// callback when falls to 0 active Ajax requests
|
274
|
+
completeAll : function()
|
275
|
+
{
|
276
|
+
$('#submit_button').attr('disabled', true)
|
277
|
+
$('#submit_message').html('');
|
278
|
+
$('#submit_message').hide();
|
279
|
+
// validate all the pages
|
280
|
+
$('.page_link').each(function(index, page) {
|
281
|
+
$.fe.pageHandler.validatePage($(page).attr('data-page-id'));
|
282
|
+
});
|
283
|
+
var all_valid = ($('#list-pages li.incomplete').length == 0);
|
284
|
+
|
285
|
+
// Make sure any necessary payments are made
|
286
|
+
var payments_made = $('.payment_question.required').length <= $('.payment').length
|
287
|
+
|
288
|
+
|
289
|
+
if( payments_made)
|
290
|
+
{
|
291
|
+
this.savePage($('#' + $.fe.pageHandler.current_page)); // in case any input fields on submit_page
|
292
|
+
|
293
|
+
// submit the application
|
294
|
+
if($('#submit_to')[0] != null)
|
295
|
+
{
|
296
|
+
url = $('#submit_to').val();
|
297
|
+
// clear out pages array to force reload. This enables "frozen" apps
|
298
|
+
// immediately after submission - :onSuccess (for USCM which stays in the application vs. redirecting to the dashboard)
|
299
|
+
var curr = $.fe.pageHandler.current_page;
|
300
|
+
$.ajax({url: url, dataType:'script',
|
301
|
+
data: {answer_sheet_type: answer_sheet_type, a: $('input[type=hidden][name=a]').val()},
|
302
|
+
type:'post',
|
303
|
+
beforeSend: function(xhr) {
|
304
|
+
$('body').trigger('ajax:loading', xhr);
|
305
|
+
},
|
306
|
+
success: function(xhr) {
|
307
|
+
$('#list-pages a').each(function() {
|
308
|
+
if ($(this).attr('data-page-id') != curr) $('#' + $(this).attr('data-page-id')).remove();
|
309
|
+
})
|
310
|
+
},
|
311
|
+
complete: function(xhr) {
|
312
|
+
$('body').trigger('ajax:complete', xhr);
|
313
|
+
var btn = $('#submit_button');
|
314
|
+
if (btn) { btn.attr('disabled', false); }
|
315
|
+
}
|
316
|
+
});
|
317
|
+
}
|
318
|
+
}
|
319
|
+
else
|
320
|
+
{
|
321
|
+
// some pages aren't valid
|
322
|
+
$('#submit_message').html("Please make a payment");
|
323
|
+
$('#submit_message').show();
|
324
|
+
|
325
|
+
var btn = $('#submit_button'); if (btn) { btn.attr('disabled', false); }
|
326
|
+
}
|
327
|
+
},
|
328
|
+
|
329
|
+
// is page loaded? (useful for toggling enabled state of questions)
|
330
|
+
isPageLoaded : function(page)
|
331
|
+
{
|
332
|
+
return $('#' + page)[0] != null
|
333
|
+
},
|
334
|
+
|
335
|
+
checkConditional : function($element) {
|
336
|
+
matchable_answers = String($element.data('conditional_answer')).split(',').map(function(s) { return s.trim(); })
|
337
|
+
if ($element.hasClass('fe_choicefield') && $element.hasClass('style_yes-no')) {
|
338
|
+
if ($(matchable_answers).filter([1, '1', true, 'true', 'yes', 'Yes']).length > 0) {
|
339
|
+
matchable_answers = [1, '1', true, 'true', 'yes', 'Yes'];
|
340
|
+
}
|
341
|
+
if ($(matchable_answers).filter([0, '0', false, 'false', 'no', 'No']).length > 0) {
|
342
|
+
matchable_answers = [0, '0', false, 'false', 'no', 'No'];
|
343
|
+
}
|
344
|
+
vals = $([$element.find("input[type=radio]:checked").val()]);
|
345
|
+
} else if ($element.hasClass('fe_choicefield') && $element.hasClass('checkbox')) {
|
346
|
+
vals = $element.find("input[type=checkbox]:checked").map(function(i, el) { return $(el).val(); });
|
347
|
+
} else {
|
348
|
+
vals = $([$element.find("input:visible, select:visible").val()]);
|
349
|
+
}
|
350
|
+
match = $(matchable_answers).filter(vals).length > 0 || (matchable_answers == "" && vals.length == 0);
|
351
|
+
|
352
|
+
switch ($element.data('conditional_type')) {
|
353
|
+
case 'Fe::Element':
|
354
|
+
if (match) {
|
355
|
+
$("#element_" + $element.data('conditional_id')).show();
|
356
|
+
} else {
|
357
|
+
$("#element_" + $element.data('conditional_id')).hide();
|
358
|
+
}
|
359
|
+
break;
|
360
|
+
case 'Fe::Page':
|
361
|
+
prefix = $element.data('answer_sheet_id_prefix');
|
362
|
+
pg = prefix + '_' + $element.data('application_id') + '-fe_page_' + $element.data('conditional_id');
|
363
|
+
li_id = 'li#'+pg+'-li';
|
364
|
+
|
365
|
+
if (match) {
|
366
|
+
$(li_id).show();
|
367
|
+
// load the page (in the background) to determine validity
|
368
|
+
this.loadPage(pg, $(li_id).find('a').attr('href'), true);
|
369
|
+
} else {
|
370
|
+
$(li_id).hide();
|
371
|
+
}
|
372
|
+
break;
|
373
|
+
}
|
374
|
+
},
|
375
|
+
|
376
|
+
next : function() {
|
377
|
+
curr_page_link = $('#'+$.fe.pageHandler.current_page+"-link");
|
378
|
+
//$.fe.pageHandler.loadPage('application_22544-fe_page_165-no_cache','/fe/answer_sheets/22544/page/165/edit'); return false;
|
379
|
+
page_link = curr_page_link
|
380
|
+
.parents('.application_section')
|
381
|
+
.nextAll()
|
382
|
+
.filter(function() { return $(this).find('a.page_link:visible').length > 0 })
|
383
|
+
.first()
|
384
|
+
.find('a.page_link');
|
385
|
+
$(".answer-page:visible div.buttons button").prop("disabled", true)
|
386
|
+
$.fe.pageHandler.loadPage(page_link.data('page-id'), page_link.attr('href'));
|
387
|
+
},
|
388
|
+
|
389
|
+
prev : function() {
|
390
|
+
curr_page_link = $('#'+$.fe.pageHandler.current_page+"-link");
|
391
|
+
//$.fe.pageHandler.loadPage('application_22544-fe_page_165-no_cache','/fe/answer_sheets/22544/page/165/edit'); return false;
|
392
|
+
page_link = curr_page_link
|
393
|
+
.parents('.application_section')
|
394
|
+
.prevAll()
|
395
|
+
.filter(function() { return $(this).find('a.page_link:visible').length > 0 })
|
396
|
+
.first()
|
397
|
+
.find('a.page_link');
|
398
|
+
$(".answer-page:visible div.buttons button").prop("disabled", true)
|
399
|
+
$.fe.pageHandler.loadPage(page_link.data('page-id'), page_link.attr('href'));
|
400
|
+
}
|
401
|
+
|
402
|
+
};
|
403
|
+
|
404
|
+
$(document).on('click', ".conditional input, .conditional select", function() {
|
405
|
+
$.fe.pageHandler.checkConditional($(this).closest('.conditional'));
|
406
|
+
});
|
407
|
+
$(document).on('keyup', ".conditional input, .conditional select", function() { $(this).click(); });
|
408
|
+
$(document).on('blug', ".conditional input, .conditional select", function() { $(this).click(); });
|
409
|
+
$(document).on('change', ".conditional select", function() { $(this).click(); });
|
410
|
+
|
411
|
+
$(document).on('keyup', 'textarea[maxlength]', function() {
|
412
|
+
maxlength = parseInt($(this).attr('maxlength'));
|
413
|
+
remaining = maxlength - $(this).val().length;
|
414
|
+
$('#'+$(this).attr('id')+'_count').val(remaining);
|
415
|
+
});
|
416
|
+
})(jQuery);
|
417
|
+
|
418
|
+
$(function() {
|
419
|
+
fixGridColumnWidths();
|
420
|
+
setUpCalendars();
|
421
|
+
});
|
422
|
+
|
423
|
+
|
424
|
+
function updateTotal(id) {
|
425
|
+
try {
|
426
|
+
total = 0;
|
427
|
+
$(".col_" + id).each(function(index, el) {
|
428
|
+
total += Number($(el).val());
|
429
|
+
});
|
430
|
+
$('#total_' + id).val(total).trigger('totalChanged');
|
431
|
+
} catch(e) {
|
432
|
+
}
|
433
|
+
}
|
434
|
+
|
435
|
+
function submitToFrame(id, url) {
|
436
|
+
form = $('<form method="post" action="'+url+'.js" endtype="multipart/form-data"></form>')
|
437
|
+
var csrf_token = $('meta[name=csrf-token]').attr('content'),
|
438
|
+
csrf_param = $('meta[name=csrf-param]').attr('content'),
|
439
|
+
dom_id = '#attachment_field_' + id,
|
440
|
+
metadata_input = '<input name="'+csrf_param+'" value="'+csrf_token+'" type="hidden" />',
|
441
|
+
file_field = '<input type="file" name="answers['+ id + ']>';
|
442
|
+
if ($(dom_id).val() == '') return;
|
443
|
+
form.hide()
|
444
|
+
.append(metadata_input)
|
445
|
+
.append(file_field)
|
446
|
+
.appendTo('body');
|
447
|
+
$(dom_id + "-spinner").show();
|
448
|
+
form.submit();
|
449
|
+
return false
|
450
|
+
}
|
@@ -1,15 +1,3 @@
|
|
1
|
-
|
2
|
-
* jQuery validation plug-in 1.7
|
3
|
-
|
4
|
-
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
|
5
|
-
* http://docs.jquery.com/Plugins/Validation
|
6
|
-
*
|
7
|
-
* Copyright (c) 2006 - 2008 Jörn Zaefferer
|
8
|
-
*
|
9
|
-
* $Id: jquery.validate.js 6403 2009-06-17 14:27:16Z joern.zaefferer $
|
10
|
-
*
|
11
|
-
* Dual licensed under the MIT and GPL licenses:
|
12
|
-
* http://www.opensource.org/licenses/mit-license.php
|
13
|
-
* http://www.gnu.org/licenses/gpl.html
|
14
|
-
*/
|
15
|
-
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(7($){$.H($.2L,{17:7(d){l(!6.F){d&&d.2q&&2T.1z&&1z.52("3y 3p, 4L\'t 17, 64 3y");8}p c=$.19(6[0],\'v\');l(c){8 c}c=2w $.v(d,6[0]);$.19(6[0],\'v\',c);l(c.q.3x){6.3s("1w, 3i").1o(".4E").3e(7(){c.3b=w});l(c.q.35){6.3s("1w, 3i").1o(":2s").3e(7(){c.1Z=6})}6.2s(7(b){l(c.q.2q)b.5J();7 1T(){l(c.q.35){l(c.1Z){p a=$("<1w 1V=\'5r\'/>").1s("u",c.1Z.u).33(c.1Z.Z).51(c.U)}c.q.35.V(c,c.U);l(c.1Z){a.3D()}8 N}8 w}l(c.3b){c.3b=N;8 1T()}l(c.L()){l(c.1b){c.1l=w;8 N}8 1T()}12{c.2l();8 N}})}8 c},J:7(){l($(6[0]).2W(\'L\')){8 6.17().L()}12{p b=w;p a=$(6[0].L).17();6.P(7(){b&=a.I(6)});8 b}},4D:7(c){p d={},$I=6;$.P(c.1I(/\\s/),7(a,b){d[b]=$I.1s(b);$I.6d(b)});8 d},1i:7(h,k){p f=6[0];l(h){p i=$.19(f.L,\'v\').q;p d=i.1i;p c=$.v.36(f);23(h){1e"1d":$.H(c,$.v.1X(k));d[f.u]=c;l(k.G)i.G[f.u]=$.H(i.G[f.u],k.G);31;1e"3D":l(!k){T d[f.u];8 c}p e={};$.P(k.1I(/\\s/),7(a,b){e[b]=c[b];T c[b]});8 e}}p g=$.v.41($.H({},$.v.3Y(f),$.v.3V(f),$.v.3T(f),$.v.36(f)),f);l(g.15){p j=g.15;T g.15;g=$.H({15:j},g)}8 g}});$.H($.5p[":"],{5n:7(a){8!$.1p(""+a.Z)},5g:7(a){8!!$.1p(""+a.Z)},5f:7(a){8!a.4h}});$.v=7(b,a){6.q=$.H(w,{},$.v.3d,b);6.U=a;6.3I()};$.v.W=7(c,b){l(R.F==1)8 7(){p a=$.3F(R);a.4V(c);8 $.v.W.1Q(6,a)};l(R.F>2&&b.2c!=3B){b=$.3F(R).4Q(1)}l(b.2c!=3B){b=[b]}$.P(b,7(i,n){c=c.1u(2w 3t("\\\\{"+i+"\\\\}","g"),n)});8 c};$.H($.v,{3d:{G:{},2a:{},1i:{},1c:"3r",28:"J",2F:"4P",2l:w,3o:$([]),2D:$([]),3x:w,3l:[],3k:N,4O:7(a){6.3U=a;l(6.q.4K&&!6.4J){6.q.1K&&6.q.1K.V(6,a,6.q.1c,6.q.28);6.1M(a).2A()}},4C:7(a){l(!6.1E(a)&&(a.u 11 6.1a||!6.K(a))){6.I(a)}},6c:7(a){l(a.u 11 6.1a||a==6.4A){6.I(a)}},68:7(a){l(a.u 11 6.1a)6.I(a);12 l(a.4x.u 11 6.1a)6.I(a.4x)},39:7(a,c,b){$(a).22(c).2v(b)},1K:7(a,c,b){$(a).2v(c).22(b)}},63:7(a){$.H($.v.3d,a)},G:{15:"61 4r 2W 15.",1q:"M 2O 6 4r.",1J:"M O a J 1J 5X.",1B:"M O a J 5W.",1A:"M O a J 1A.",2j:"M O a J 1A (5Q).",1G:"M O a J 1G.",1P:"M O 5O 1P.",2f:"M O a J 5L 5I 1G.",2o:"M O 47 5F Z 5B.",43:"M O a Z 5z a J 5x.",18:$.v.W("M O 3K 5v 2X {0} 2V."),1y:$.v.W("M O 5t 5s {0} 2V."),2i:$.v.W("M O a Z 3W {0} 3O {1} 2V 5o."),2r:$.v.W("M O a Z 3W {0} 3O {1}."),1C:$.v.W("M O a Z 5j 2X 46 3M 3L {0}."),1t:$.v.W("M O a Z 5d 2X 46 3M 3L {0}.")},3J:N,5a:{3I:7(){6.24=$(6.q.2D);6.4t=6.24.F&&6.24||$(6.U);6.2x=$(6.q.3o).1d(6.q.2D);6.1a={};6.54={};6.1b=0;6.1h={};6.1f={};6.21();p f=(6.2a={});$.P(6.q.2a,7(d,c){$.P(c.1I(/\\s/),7(a,b){f[b]=d})});p e=6.q.1i;$.P(e,7(b,a){e[b]=$.v.1X(a)});7 2N(a){p b=$.19(6[0].L,"v"),3c="4W"+a.1V.1u(/^17/,"");b.q[3c]&&b.q[3c].V(b,6[0])}$(6.U).2K(":3E, :4U, :4T, 2e, 4S","2d 2J 4R",2N).2K(":3C, :3A, 2e, 3z","3e",2N);l(6.q.3w)$(6.U).2I("1f-L.17",6.q.3w)},L:7(){6.3v();$.H(6.1a,6.1v);6.1f=$.H({},6.1v);l(!6.J())$(6.U).3u("1f-L",[6]);6.1m();8 6.J()},3v:7(){6.2H();Q(p i=0,14=(6.2b=6.14());14[i];i++){6.29(14[i])}8 6.J()},I:7(a){a=6.2G(a);6.4A=a;6.2P(a);6.2b=$(a);p b=6.29(a);l(b){T 6.1f[a.u]}12{6.1f[a.u]=w}l(!6.3q()){6.13=6.13.1d(6.2x)}6.1m();8 b},1m:7(b){l(b){$.H(6.1v,b);6.S=[];Q(p c 11 b){6.S.27({1j:b[c],I:6.26(c)[0]})}6.1n=$.3n(6.1n,7(a){8!(a.u 11 b)})}6.q.1m?6.q.1m.V(6,6.1v,6.S):6.3m()},2S:7(){l($.2L.2S)$(6.U).2S();6.1a={};6.2H();6.2Q();6.14().2v(6.q.1c)},3q:7(){8 6.2k(6.1f)},2k:7(a){p b=0;Q(p i 11 a)b++;8 b},2Q:7(){6.2C(6.13).2A()},J:7(){8 6.3j()==0},3j:7(){8 6.S.F},2l:7(){l(6.q.2l){3Q{$(6.3h()||6.S.F&&6.S[0].I||[]).1o(":4N").3g().4M("2d")}3f(e){}}},3h:7(){p a=6.3U;8 a&&$.3n(6.S,7(n){8 n.I.u==a.u}).F==1&&a},14:7(){p a=6,2B={};8 $([]).1d(6.U.14).1o(":1w").1L(":2s, :21, :4I, [4H]").1L(6.q.3l).1o(7(){!6.u&&a.q.2q&&2T.1z&&1z.3r("%o 4G 3K u 4F",6);l(6.u 11 2B||!a.2k($(6).1i()))8 N;2B[6.u]=w;8 w})},2G:7(a){8 $(a)[0]},2z:7(){8 $(6.q.2F+"."+6.q.1c,6.4t)},21:7(){6.1n=[];6.S=[];6.1v={};6.1k=$([]);6.13=$([]);6.2b=$([])},2H:7(){6.21();6.13=6.2z().1d(6.2x)},2P:7(a){6.21();6.13=6.1M(a)},29:7(d){d=6.2G(d);l(6.1E(d)){d=6.26(d.u)[0]}p a=$(d).1i();p c=N;Q(Y 11 a){p b={Y:Y,2n:a[Y]};3Q{p f=$.v.1N[Y].V(6,d.Z.1u(/\\r/g,""),d,b.2n);l(f=="1S-1Y"){c=w;6g}c=N;l(f=="1h"){6.13=6.13.1L(6.1M(d));8}l(!f){6.4B(d,b);8 N}}3f(e){6.q.2q&&2T.1z&&1z.6f("6e 6b 6a 69 I "+d.4z+", 29 47 \'"+b.Y+"\' Y",e);67 e;}}l(c)8;l(6.2k(a))6.1n.27(d);8 w},4y:7(a,b){l(!$.1H)8;p c=6.q.3a?$(a).1H()[6.q.3a]:$(a).1H();8 c&&c.G&&c.G[b]},4w:7(a,b){p m=6.q.G[a];8 m&&(m.2c==4v?m:m[b])},4u:7(){Q(p i=0;i<R.F;i++){l(R[i]!==20)8 R[i]}8 20},2u:7(a,b){8 6.4u(6.4w(a.u,b),6.4y(a,b),!6.q.3k&&a.62||20,$.v.G[b],"<4s>60: 5Z 1j 5Y Q "+a.u+"</4s>")},4B:7(b,a){p c=6.2u(b,a.Y),37=/\\$?\\{(\\d+)\\}/g;l(1g c=="7"){c=c.V(6,a.2n,b)}12 l(37.16(c)){c=1F.W(c.1u(37,\'{$1}\'),a.2n)}6.S.27({1j:c,I:b});6.1v[b.u]=c;6.1a[b.u]=c},2C:7(a){l(6.q.2t)a=a.1d(a.4q(6.q.2t));8 a},3m:7(){Q(p i=0;6.S[i];i++){p a=6.S[i];6.q.39&&6.q.39.V(6,a.I,6.q.1c,6.q.28);6.2E(a.I,a.1j)}l(6.S.F){6.1k=6.1k.1d(6.2x)}l(6.q.1x){Q(p i=0;6.1n[i];i++){6.2E(6.1n[i])}}l(6.q.1K){Q(p i=0,14=6.4p();14[i];i++){6.q.1K.V(6,14[i],6.q.1c,6.q.28)}}6.13=6.13.1L(6.1k);6.2Q();6.2C(6.1k).4o()},4p:7(){8 6.2b.1L(6.4n())},4n:7(){8 $(6.S).4m(7(){8 6.I})},2E:7(a,c){p b=6.1M(a);l(b.F){b.2v().22(6.q.1c);b.1s("4l")&&b.4k(c)}12{b=$("<"+6.q.2F+"/>").1s({"Q":6.34(a),4l:w}).22(6.q.1c).4k(c||"");l(6.q.2t){b=b.2A().4o().5V("<"+6.q.2t+"/>").4q()}l(!6.24.5S(b).F)6.q.4j?6.q.4j(b,$(a)):b.5R(a)}l(!c&&6.q.1x){b.3E("");1g 6.q.1x=="1D"?b.22(6.q.1x):6.q.1x(b)}6.1k=6.1k.1d(b)},1M:7(a){p b=6.34(a);8 6.2z().1o(7(){8 $(6).1s(\'Q\')==b})},34:7(a){8 6.2a[a.u]||(6.1E(a)?a.u:a.4z||a.u)},1E:7(a){8/3C|3A/i.16(a.1V)},26:7(d){p c=6.U;8 $(4i.5P(d)).4m(7(a,b){8 b.L==c&&b.u==d&&b||4g})},1O:7(a,b){23(b.4f.4e()){1e\'2e\':8 $("3z:3p",b).F;1e\'1w\':l(6.1E(b))8 6.26(b.u).1o(\':4h\').F}8 a.F},4d:7(b,a){8 6.32[1g b]?6.32[1g b](b,a):w},32:{"5N":7(b,a){8 b},"1D":7(b,a){8!!$(b,a.L).F},"7":7(b,a){8 b(a)}},K:7(a){8!$.v.1N.15.V(6,$.1p(a.Z),a)&&"1S-1Y"},4c:7(a){l(!6.1h[a.u]){6.1b++;6.1h[a.u]=w}},4b:7(a,b){6.1b--;l(6.1b<0)6.1b=0;T 6.1h[a.u];l(b&&6.1b==0&&6.1l&&6.L()){$(6.U).2s();6.1l=N}12 l(!b&&6.1b==0&&6.1l){$(6.U).3u("1f-L",[6]);6.1l=N}},2h:7(a){8 $.19(a,"2h")||$.19(a,"2h",{2M:4g,J:w,1j:6.2u(a,"1q")})}},1R:{15:{15:w},1J:{1J:w},1B:{1B:w},1A:{1A:w},2j:{2j:w},4a:{4a:w},1G:{1G:w},49:{49:w},1P:{1P:w},2f:{2f:w}},48:7(a,b){a.2c==4v?6.1R[a]=b:$.H(6.1R,a)},3V:7(b){p a={};p c=$(b).1s(\'5H\');c&&$.P(c.1I(\' \'),7(){l(6 11 $.v.1R){$.H(a,$.v.1R[6])}});8 a},3T:7(c){p a={};p d=$(c);Q(Y 11 $.v.1N){p b=d.1s(Y);l(b){a[Y]=b}}l(a.18&&/-1|5G|5C/.16(a.18)){T a.18}8 a},3Y:7(a){l(!$.1H)8{};p b=$.19(a.L,\'v\').q.3a;8 b?$(a).1H()[b]:$(a).1H()},36:7(b){p a={};p c=$.19(b.L,\'v\');l(c.q.1i){a=$.v.1X(c.q.1i[b.u])||{}}8 a},41:7(d,e){$.P(d,7(c,b){l(b===N){T d[c];8}l(b.2R||b.2p){p a=w;23(1g b.2p){1e"1D":a=!!$(b.2p,e.L).F;31;1e"7":a=b.2p.V(e,e);31}l(a){d[c]=b.2R!==20?b.2R:w}12{T d[c]}}});$.P(d,7(a,b){d[a]=$.44(b)?b(e):b});$.P([\'1y\',\'18\',\'1t\',\'1C\'],7(){l(d[6]){d[6]=2Z(d[6])}});$.P([\'2i\',\'2r\'],7(){l(d[6]){d[6]=[2Z(d[6][0]),2Z(d[6][1])]}});l($.v.3J){l(d.1t&&d.1C){d.2r=[d.1t,d.1C];T d.1t;T d.1C}l(d.1y&&d.18){d.2i=[d.1y,d.18];T d.1y;T d.18}}l(d.G){T d.G}8 d},1X:7(a){l(1g a=="1D"){p b={};$.P(a.1I(/\\s/),7(){b[6]=w});a=b}8 a},5A:7(c,a,b){$.v.1N[c]=a;$.v.G[c]=b!=20?b:$.v.G[c];l(a.F<3){$.v.48(c,$.v.1X(c))}},1N:{15:7(c,d,a){l(!6.4d(a,d))8"1S-1Y";23(d.4f.4e()){1e\'2e\':p b=$(d).33();8 b&&b.F>0;1e\'1w\':l(6.1E(d))8 6.1O(c,d)>0;5y:8 $.1p(c).F>0}},1q:7(f,h,j){l(6.K(h))8"1S-1Y";p g=6.2h(h);l(!6.q.G[h.u])6.q.G[h.u]={};g.40=6.q.G[h.u].1q;6.q.G[h.u].1q=g.1j;j=1g j=="1D"&&{1B:j}||j;l(g.2M!==f){g.2M=f;p k=6;6.4c(h);p i={};i[h.u]=f;$.2U($.H(w,{1B:j,3Z:"2Y",3X:"17"+h.u,5w:"5u",19:i,1x:7(d){k.q.G[h.u].1q=g.40;p b=d===w;l(b){p e=k.1l;k.2P(h);k.1l=e;k.1n.27(h);k.1m()}12{p a={};p c=(g.1j=d||k.2u(h,"1q"));a[h.u]=$.44(c)?c(f):c;k.1m(a)}g.J=b;k.4b(h,b)}},j));8"1h"}12 l(6.1h[h.u]){8"1h"}8 g.J},1y:7(b,c,a){8 6.K(c)||6.1O($.1p(b),c)>=a},18:7(b,c,a){8 6.K(c)||6.1O($.1p(b),c)<=a},2i:7(b,d,a){p c=6.1O($.1p(b),d);8 6.K(d)||(c>=a[0]&&c<=a[1])},1t:7(b,c,a){8 6.K(c)||b>=a},1C:7(b,c,a){8 6.K(c)||b<=a},2r:7(b,c,a){8 6.K(c)||(b>=a[0]&&b<=a[1])},1J:7(a,b){8 6.K(b)||/^((([a-z]|\\d|[!#\\$%&\'\\*\\+\\-\\/=\\?\\^X`{\\|}~]|[\\E-\\B\\C-\\x\\A-\\y])+(\\.([a-z]|\\d|[!#\\$%&\'\\*\\+\\-\\/=\\?\\^X`{\\|}~]|[\\E-\\B\\C-\\x\\A-\\y])+)*)|((\\3S)((((\\2m|\\1W)*(\\30\\3R))?(\\2m|\\1W)+)?(([\\3P-\\5q\\45\\42\\5D-\\5E\\3N]|\\5m|[\\5l-\\5k]|[\\5i-\\5K]|[\\E-\\B\\C-\\x\\A-\\y])|(\\\\([\\3P-\\1W\\45\\42\\30-\\3N]|[\\E-\\B\\C-\\x\\A-\\y]))))*(((\\2m|\\1W)*(\\30\\3R))?(\\2m|\\1W)+)?(\\3S)))@((([a-z]|\\d|[\\E-\\B\\C-\\x\\A-\\y])|(([a-z]|\\d|[\\E-\\B\\C-\\x\\A-\\y])([a-z]|\\d|-|\\.|X|~|[\\E-\\B\\C-\\x\\A-\\y])*([a-z]|\\d|[\\E-\\B\\C-\\x\\A-\\y])))\\.)+(([a-z]|[\\E-\\B\\C-\\x\\A-\\y])|(([a-z]|[\\E-\\B\\C-\\x\\A-\\y])([a-z]|\\d|-|\\.|X|~|[\\E-\\B\\C-\\x\\A-\\y])*([a-z]|[\\E-\\B\\C-\\x\\A-\\y])))\\.?$/i.16(a)},1B:7(a,b){8 6.K(b)||/^(5h?|5M):\\/\\/(((([a-z]|\\d|-|\\.|X|~|[\\E-\\B\\C-\\x\\A-\\y])|(%[\\1U-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:)*@)?(((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]))|((([a-z]|\\d|[\\E-\\B\\C-\\x\\A-\\y])|(([a-z]|\\d|[\\E-\\B\\C-\\x\\A-\\y])([a-z]|\\d|-|\\.|X|~|[\\E-\\B\\C-\\x\\A-\\y])*([a-z]|\\d|[\\E-\\B\\C-\\x\\A-\\y])))\\.)+(([a-z]|[\\E-\\B\\C-\\x\\A-\\y])|(([a-z]|[\\E-\\B\\C-\\x\\A-\\y])([a-z]|\\d|-|\\.|X|~|[\\E-\\B\\C-\\x\\A-\\y])*([a-z]|[\\E-\\B\\C-\\x\\A-\\y])))\\.?)(:\\d*)?)(\\/((([a-z]|\\d|-|\\.|X|~|[\\E-\\B\\C-\\x\\A-\\y])|(%[\\1U-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)+(\\/(([a-z]|\\d|-|\\.|X|~|[\\E-\\B\\C-\\x\\A-\\y])|(%[\\1U-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)*)*)?)?(\\?((([a-z]|\\d|-|\\.|X|~|[\\E-\\B\\C-\\x\\A-\\y])|(%[\\1U-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)|[\\5e-\\5T]|\\/|\\?)*)?(\\#((([a-z]|\\d|-|\\.|X|~|[\\E-\\B\\C-\\x\\A-\\y])|(%[\\1U-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)|\\/|\\?)*)?$/i.16(a)},1A:7(a,b){8 6.K(b)||!/5U|5c/.16(2w 5b(a))},2j:7(a,b){8 6.K(b)||/^\\d{4}[\\/-]\\d{1,2}[\\/-]\\d{1,2}$/.16(a)},1G:7(a,b){8 6.K(b)||/^-?(?:\\d+|\\d{1,3}(?:,\\d{3})+)(?:\\.\\d+)?$/.16(a)},1P:7(a,b){8 6.K(b)||/^\\d+$/.16(a)},2f:7(b,e){l(6.K(e))8"1S-1Y";l(/[^0-9-]+/.16(b))8 N;p a=0,d=0,2g=N;b=b.1u(/\\D/g,"");Q(p n=b.F-1;n>=0;n--){p c=b.59(n);p d=58(c,10);l(2g){l((d*=2)>9)d-=9}a+=d;2g=!2g}8(a%10)==0},43:7(b,c,a){a=1g a=="1D"?a.1u(/,/g,\'|\'):"57|56?g|55";8 6.K(c)||b.65(2w 3t(".("+a+")$","i"))},2o:7(c,d,a){p b=$(a).66(".17-2o").2I("3H.17-2o",7(){$(d).J()});8 c==b.33()}}});$.W=$.v.W})(1F);(7($){p c=$.2U;p d={};$.2U=7(a){a=$.H(a,$.H({},$.53,a));p b=a.3X;l(a.3Z=="2Y"){l(d[b]){d[b].2Y()}8(d[b]=c.1Q(6,R))}8 c.1Q(6,R)}})(1F);(7($){l(!1F.1r.38.2d&&!1F.1r.38.2J&&4i.3G){$.P({3g:\'2d\',3H:\'2J\'},7(b,a){$.1r.38[a]={50:7(){6.3G(b,2y,w)},4Z:7(){6.4Y(b,2y,w)},2y:7(e){R[0]=$.1r.2O(e);R[0].1V=a;8 $.1r.1T.1Q(6,R)}};7 2y(e){e=$.1r.2O(e);e.1V=a;8 $.1r.1T.V(6,e)}})};$.H($.2L,{2K:7(d,e,c){8 6.2I(e,7(a){p b=$(a.4X);l(b.2W(d)){8 c.1Q(b,R)}})}})})(1F);',62,389,'||||||this|function|return|||||||||||||if||||var|settings||||name|validator|true|uFDCF|uFFEF||uFDF0|uD7FF|uF900||u00A0|length|messages|extend|element|valid|optional|form|Please|false|enter|each|for|arguments|errorList|delete|currentForm|call|format|_|method|value||in|else|toHide|elements|required|test|validate|maxlength|data|submitted|pendingRequest|errorClass|add|case|invalid|typeof|pending|rules|message|toShow|formSubmitted|showErrors|successList|filter|trim|remote|event|attr|min|replace|errorMap|input|success|minlength|console|date|url|max|string|checkable|jQuery|number|metadata|split|email|unhighlight|not|errorsFor|methods|getLength|digits|apply|classRuleSettings|dependency|handle|da|type|x09|normalizeRule|mismatch|submitButton|undefined|reset|addClass|switch|labelContainer||findByName|push|validClass|check|groups|currentElements|constructor|focusin|select|creditcard|bEven|previousValue|rangelength|dateISO|objectLength|focusInvalid|x20|parameters|equalTo|depends|debug|range|submit|wrapper|defaultMessage|removeClass|new|containers|handler|errors|hide|rulesCache|addWrapper|errorLabelContainer|showLabel|errorElement|clean|prepareForm|bind|focusout|validateDelegate|fn|old|delegate|fix|prepareElement|hideErrors|param|resetForm|window|ajax|characters|is|than|abort|Number|x0d|break|dependTypes|val|idOrName|submitHandler|staticRules|theregex|special|highlight|meta|cancelSubmit|eventType|defaults|click|catch|focus|findLastActive|button|size|ignoreTitle|ignore|defaultShowErrors|grep|errorContainer|selected|numberOfInvalids|error|find|RegExp|triggerHandler|checkForm|invalidHandler|onsubmit|nothing|option|checkbox|Array|radio|remove|text|makeArray|addEventListener|blur|init|autoCreateRanges|no|to|equal|x7f|and|x01|try|x0a|x22|attributeRules|lastActive|classRules|between|port|metadataRules|mode|originalMessage|normalizeRules|x0c|accept|isFunction|x0b|or|the|addClassRules|numberDE|dateDE|stopRequest|startRequest|depend|toLowerCase|nodeName|null|checked|document|errorPlacement|html|generated|map|invalidElements|show|validElements|parent|field|strong|errorContext|findDefined|String|customMessage|parentNode|customMetaMessage|id|lastElement|formatAndAdd|onfocusout|removeAttrs|cancel|assigned|has|disabled|image|blockFocusCleanup|focusCleanup|can|trigger|visible|onfocusin|label|slice|keyup|textarea|file|password|unshift|on|target|removeEventListener|teardown|setup|appendTo|warn|ajaxSettings|valueCache|gif|jpe|png|parseInt|charAt|prototype|Date|NaN|greater|uE000|unchecked|filled|https|x5d|less|x5b|x23|x21|blank|long|expr|x08|hidden|least|at|json|more|dataType|extension|default|with|addMethod|again|524288|x0e|x1f|same|2147483647|class|card|preventDefault|x7e|credit|ftp|boolean|only|getElementsByName|ISO|insertAfter|append|uF8FF|Invalid|wrap|URL|address|defined|No|Warning|This|title|setDefaults|returning|match|unbind|throw|onclick|checking|when|occured|onkeyup|removeAttr|exception|log|continue'.split('|'),0,{}))
|
1
|
+
/*! jQuery Validation Plugin - v1.11.1 - 3/22/2013\n* https://github.com/jzaefferer/jquery-validation
|
2
|
+
* Copyright (c) 2013 Jörn Zaefferer; Licensed MIT */(function(t){t.extend(t.fn,{validate:function(e){if(!this.length)return e&&e.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing."),void 0;var i=t.data(this[0],"validator");return i?i:(this.attr("novalidate","novalidate"),i=new t.validator(e,this[0]),t.data(this[0],"validator",i),i.settings.onsubmit&&(this.validateDelegate(":submit","click",function(e){i.settings.submitHandler&&(i.submitButton=e.target),t(e.target).hasClass("cancel")&&(i.cancelSubmit=!0),void 0!==t(e.target).attr("formnovalidate")&&(i.cancelSubmit=!0)}),this.submit(function(e){function s(){var s;return i.settings.submitHandler?(i.submitButton&&(s=t("<input type='hidden'/>").attr("name",i.submitButton.name).val(t(i.submitButton).val()).appendTo(i.currentForm)),i.settings.submitHandler.call(i,i.currentForm,e),i.submitButton&&s.remove(),!1):!0}return i.settings.debug&&e.preventDefault(),i.cancelSubmit?(i.cancelSubmit=!1,s()):i.form()?i.pendingRequest?(i.formSubmitted=!0,!1):s():(i.focusInvalid(),!1)})),i)},valid:function(){if(t(this[0]).is("form"))return this.validate().form();var e=!0,i=t(this[0].form).validate();return this.each(function(){e=e&&i.element(this)}),e},removeAttrs:function(e){var i={},s=this;return t.each(e.split(/\s/),function(t,e){i[e]=s.attr(e),s.removeAttr(e)}),i},rules:function(e,i){var s=this[0];if(e){var r=t.data(s.form,"validator").settings,n=r.rules,a=t.validator.staticRules(s);switch(e){case"add":t.extend(a,t.validator.normalizeRule(i)),delete a.messages,n[s.name]=a,i.messages&&(r.messages[s.name]=t.extend(r.messages[s.name],i.messages));break;case"remove":if(!i)return delete n[s.name],a;var u={};return t.each(i.split(/\s/),function(t,e){u[e]=a[e],delete a[e]}),u}}var o=t.validator.normalizeRules(t.extend({},t.validator.classRules(s),t.validator.attributeRules(s),t.validator.dataRules(s),t.validator.staticRules(s)),s);if(o.required){var l=o.required;delete o.required,o=t.extend({required:l},o)}return o}}),t.extend(t.expr[":"],{blank:function(e){return!t.trim(""+t(e).val())},filled:function(e){return!!t.trim(""+t(e).val())},unchecked:function(e){return!t(e).prop("checked")}}),t.validator=function(e,i){this.settings=t.extend(!0,{},t.validator.defaults,e),this.currentForm=i,this.init()},t.validator.format=function(e,i){return 1===arguments.length?function(){var i=t.makeArray(arguments);return i.unshift(e),t.validator.format.apply(this,i)}:(arguments.length>2&&i.constructor!==Array&&(i=t.makeArray(arguments).slice(1)),i.constructor!==Array&&(i=[i]),t.each(i,function(t,i){e=e.replace(RegExp("\\{"+t+"\\}","g"),function(){return i})}),e)},t.extend(t.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:!0,errorContainer:t([]),errorLabelContainer:t([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(t){this.lastActive=t,this.settings.focusCleanup&&!this.blockFocusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,t,this.settings.errorClass,this.settings.validClass),this.addWrapper(this.errorsFor(t)).hide())},onfocusout:function(t){this.checkable(t)||!(t.name in this.submitted)&&this.optional(t)||this.element(t)},onkeyup:function(t,e){(9!==e.which||""!==this.elementValue(t))&&(t.name in this.submitted||t===this.lastElement)&&this.element(t)},onclick:function(t){t.name in this.submitted?this.element(t):t.parentNode.name in this.submitted&&this.element(t.parentNode)},highlight:function(e,i,s){"radio"===e.type?this.findByName(e.name).addClass(i).removeClass(s):t(e).addClass(i).removeClass(s)},unhighlight:function(e,i,s){"radio"===e.type?this.findByName(e.name).removeClass(i).addClass(s):t(e).removeClass(i).addClass(s)}},setDefaults:function(e){t.extend(t.validator.defaults,e)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",maxlength:t.validator.format("Please enter no more than {0} characters."),minlength:t.validator.format("Please enter at least {0} characters."),rangelength:t.validator.format("Please enter a value between {0} and {1} characters long."),range:t.validator.format("Please enter a value between {0} and {1}."),max:t.validator.format("Please enter a value less than or equal to {0}."),min:t.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:!1,prototype:{init:function(){function e(e){var i=t.data(this[0].form,"validator"),s="on"+e.type.replace(/^validate/,"");i.settings[s]&&i.settings[s].call(i,this[0],e)}this.labelContainer=t(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||t(this.currentForm),this.containers=t(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var i=this.groups={};t.each(this.settings.groups,function(e,s){"string"==typeof s&&(s=s.split(/\s/)),t.each(s,function(t,s){i[s]=e})});var s=this.settings.rules;t.each(s,function(e,i){s[e]=t.validator.normalizeRule(i)}),t(this.currentForm).validateDelegate(":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",e).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",e),this.settings.invalidHandler&&t(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),t.extend(this.submitted,this.errorMap),this.invalid=t.extend({},this.errorMap),this.valid()||t(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var t=0,e=this.currentElements=this.elements();e[t];t++)this.check(e[t]);return this.valid()},element:function(e){e=this.validationTargetFor(this.clean(e)),this.lastElement=e,this.prepareElement(e),this.currentElements=t(e);var i=this.check(e)!==!1;return i?delete this.invalid[e.name]:this.invalid[e.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),i},showErrors:function(e){if(e){t.extend(this.errorMap,e),this.errorList=[];for(var i in e)this.errorList.push({message:e[i],element:this.findByName(i)[0]});this.successList=t.grep(this.successList,function(t){return!(t.name in e)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){t.fn.resetForm&&t(this.currentForm).resetForm(),this.submitted={},this.lastElement=null,this.prepareForm(),this.hideErrors(),this.elements().removeClass(this.settings.errorClass).removeData("previousValue")},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(t){var e=0;for(var i in t)e++;return e},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{t(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(e){}},findLastActive:function(){var e=this.lastActive;return e&&1===t.grep(this.errorList,function(t){return t.element.name===e.name}).length&&e},elements:function(){var e=this,i={};return t(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){return!this.name&&e.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.name in i||!e.objectLength(t(this).rules())?!1:(i[this.name]=!0,!0)})},clean:function(e){return t(e)[0]},errors:function(){var e=this.settings.errorClass.replace(" ",".");return t(this.settings.errorElement+"."+e,this.errorContext)},reset:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=t([]),this.toHide=t([]),this.currentElements=t([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(t){this.reset(),this.toHide=this.errorsFor(t)},elementValue:function(e){var i=t(e).attr("type"),s=t(e).val();return"radio"===i||"checkbox"===i?t("input[name='"+t(e).attr("name")+"']:checked").val():"string"==typeof s?s.replace(/\r/g,""):s},check:function(e){e=this.validationTargetFor(this.clean(e));var i,s=t(e).rules(),r=!1,n=this.elementValue(e);for(var a in s){var u={method:a,parameters:s[a]};try{if(i=t.validator.methods[a].call(this,n,e,u.parameters),"dependency-mismatch"===i){r=!0;continue}if(r=!1,"pending"===i)return this.toHide=this.toHide.not(this.errorsFor(e)),void 0;if(!i)return this.formatAndAdd(e,u),!1}catch(o){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+e.id+", check the '"+u.method+"' method.",o),o}}return r?void 0:(this.objectLength(s)&&this.successList.push(e),!0)},customDataMessage:function(e,i){return t(e).data("msg-"+i.toLowerCase())||e.attributes&&t(e).attr("data-msg-"+i.toLowerCase())},customMessage:function(t,e){var i=this.settings.messages[t];return i&&(i.constructor===String?i:i[e])},findDefined:function(){for(var t=0;arguments.length>t;t++)if(void 0!==arguments[t])return arguments[t];return void 0},defaultMessage:function(e,i){return this.findDefined(this.customMessage(e.name,i),this.customDataMessage(e,i),!this.settings.ignoreTitle&&e.title||void 0,t.validator.messages[i],"<strong>Warning: No message defined for "+e.name+"</strong>")},formatAndAdd:function(e,i){var s=this.defaultMessage(e,i.method),r=/\$?\{(\d+)\}/g;"function"==typeof s?s=s.call(this,i.parameters,e):r.test(s)&&(s=t.validator.format(s.replace(r,"{$1}"),i.parameters)),this.errorList.push({message:s,element:e}),this.errorMap[e.name]=s,this.submitted[e.name]=s},addWrapper:function(t){return this.settings.wrapper&&(t=t.add(t.parent(this.settings.wrapper))),t},defaultShowErrors:function(){var t,e;for(t=0;this.errorList[t];t++){var i=this.errorList[t];this.settings.highlight&&this.settings.highlight.call(this,i.element,this.settings.errorClass,this.settings.validClass),this.showLabel(i.element,i.message)}if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(t=0;this.successList[t];t++)this.showLabel(this.successList[t]);if(this.settings.unhighlight)for(t=0,e=this.validElements();e[t];t++)this.settings.unhighlight.call(this,e[t],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return t(this.errorList).map(function(){return this.element})},showLabel:function(e,i){var s=this.errorsFor(e);s.length?(s.removeClass(this.settings.validClass).addClass(this.settings.errorClass),s.html(i)):(s=t("<"+this.settings.errorElement+">").attr("for",this.idOrName(e)).addClass(this.settings.errorClass).html(i||""),this.settings.wrapper&&(s=s.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.append(s).length||(this.settings.errorPlacement?this.settings.errorPlacement(s,t(e)):s.insertAfter(e))),!i&&this.settings.success&&(s.text(""),"string"==typeof this.settings.success?s.addClass(this.settings.success):this.settings.success(s,e)),this.toShow=this.toShow.add(s)},errorsFor:function(e){var i=this.idOrName(e);return this.errors().filter(function(){return t(this).attr("for")===i})},idOrName:function(t){return this.groups[t.name]||(this.checkable(t)?t.name:t.id||t.name)},validationTargetFor:function(t){return this.checkable(t)&&(t=this.findByName(t.name).not(this.settings.ignore)[0]),t},checkable:function(t){return/radio|checkbox/i.test(t.type)},findByName:function(e){return t(this.currentForm).find("[name='"+e+"']")},getLength:function(e,i){switch(i.nodeName.toLowerCase()){case"select":return t("option:selected",i).length;case"input":if(this.checkable(i))return this.findByName(i.name).filter(":checked").length}return e.length},depend:function(t,e){return this.dependTypes[typeof t]?this.dependTypes[typeof t](t,e):!0},dependTypes:{"boolean":function(t){return t},string:function(e,i){return!!t(e,i.form).length},"function":function(t,e){return t(e)}},optional:function(e){var i=this.elementValue(e);return!t.validator.methods.required.call(this,i,e)&&"dependency-mismatch"},startRequest:function(t){this.pending[t.name]||(this.pendingRequest++,this.pending[t.name]=!0)},stopRequest:function(e,i){this.pendingRequest--,0>this.pendingRequest&&(this.pendingRequest=0),delete this.pending[e.name],i&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(t(this.currentForm).submit(),this.formSubmitted=!1):!i&&0===this.pendingRequest&&this.formSubmitted&&(t(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(e){return t.data(e,"previousValue")||t.data(e,"previousValue",{old:null,valid:!0,message:this.defaultMessage(e,"remote")})}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(e,i){e.constructor===String?this.classRuleSettings[e]=i:t.extend(this.classRuleSettings,e)},classRules:function(e){var i={},s=t(e).attr("class");return s&&t.each(s.split(" "),function(){this in t.validator.classRuleSettings&&t.extend(i,t.validator.classRuleSettings[this])}),i},attributeRules:function(e){var i={},s=t(e),r=s[0].getAttribute("type");for(var n in t.validator.methods){var a;"required"===n?(a=s.get(0).getAttribute(n),""===a&&(a=!0),a=!!a):a=s.attr(n),/min|max/.test(n)&&(null===r||/number|range|text/.test(r))&&(a=Number(a)),a?i[n]=a:r===n&&"range"!==r&&(i[n]=!0)}return i.maxlength&&/-1|2147483647|524288/.test(i.maxlength)&&delete i.maxlength,i},dataRules:function(e){var i,s,r={},n=t(e);for(i in t.validator.methods)s=n.data("rule-"+i.toLowerCase()),void 0!==s&&(r[i]=s);return r},staticRules:function(e){var i={},s=t.data(e.form,"validator");return s.settings.rules&&(i=t.validator.normalizeRule(s.settings.rules[e.name])||{}),i},normalizeRules:function(e,i){return t.each(e,function(s,r){if(r===!1)return delete e[s],void 0;if(r.param||r.depends){var n=!0;switch(typeof r.depends){case"string":n=!!t(r.depends,i.form).length;break;case"function":n=r.depends.call(i,i)}n?e[s]=void 0!==r.param?r.param:!0:delete e[s]}}),t.each(e,function(s,r){e[s]=t.isFunction(r)?r(i):r}),t.each(["minlength","maxlength"],function(){e[this]&&(e[this]=Number(e[this]))}),t.each(["rangelength","range"],function(){var i;e[this]&&(t.isArray(e[this])?e[this]=[Number(e[this][0]),Number(e[this][1])]:"string"==typeof e[this]&&(i=e[this].split(/[\s,]+/),e[this]=[Number(i[0]),Number(i[1])]))}),t.validator.autoCreateRanges&&(e.min&&e.max&&(e.range=[e.min,e.max],delete e.min,delete e.max),e.minlength&&e.maxlength&&(e.rangelength=[e.minlength,e.maxlength],delete e.minlength,delete e.maxlength)),e},normalizeRule:function(e){if("string"==typeof e){var i={};t.each(e.split(/\s/),function(){i[this]=!0}),e=i}return e},addMethod:function(e,i,s){t.validator.methods[e]=i,t.validator.messages[e]=void 0!==s?s:t.validator.messages[e],3>i.length&&t.validator.addClassRules(e,t.validator.normalizeRule(e))},methods:{required:function(e,i,s){if(!this.depend(s,i))return"dependency-mismatch";if("select"===i.nodeName.toLowerCase()){var r=t(i).val();return r&&r.length>0}return this.checkable(i)?this.getLength(e,i)>0:t.trim(e).length>0},email:function(t,e){return this.optional(e)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(t)},url:function(t,e){return this.optional(e)||/^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(t)},date:function(t,e){return this.optional(e)||!/Invalid|NaN/.test(""+new Date(t))},dateISO:function(t,e){return this.optional(e)||/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(t)},number:function(t,e){return this.optional(e)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(t)},digits:function(t,e){return this.optional(e)||/^\d+$/.test(t)},creditcard:function(t,e){if(this.optional(e))return"dependency-mismatch";if(/[^0-9 \-]+/.test(t))return!1;var i=0,s=0,r=!1;t=t.replace(/\D/g,"");for(var n=t.length-1;n>=0;n--){var a=t.charAt(n);s=parseInt(a,10),r&&(s*=2)>9&&(s-=9),i+=s,r=!r}return 0===i%10},minlength:function(e,i,s){var r=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||r>=s},maxlength:function(e,i,s){var r=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||s>=r},rangelength:function(e,i,s){var r=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||r>=s[0]&&s[1]>=r},min:function(t,e,i){return this.optional(e)||t>=i},max:function(t,e,i){return this.optional(e)||i>=t},range:function(t,e,i){return this.optional(e)||t>=i[0]&&i[1]>=t},equalTo:function(e,i,s){var r=t(s);return this.settings.onfocusout&&r.unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){t(i).valid()}),e===r.val()},remote:function(e,i,s){if(this.optional(i))return"dependency-mismatch";var r=this.previousValue(i);if(this.settings.messages[i.name]||(this.settings.messages[i.name]={}),r.originalMessage=this.settings.messages[i.name].remote,this.settings.messages[i.name].remote=r.message,s="string"==typeof s&&{url:s}||s,r.old===e)return r.valid;r.old=e;var n=this;this.startRequest(i);var a={};return a[i.name]=e,t.ajax(t.extend(!0,{url:s,mode:"abort",port:"validate"+i.name,dataType:"json",data:a,success:function(s){n.settings.messages[i.name].remote=r.originalMessage;var a=s===!0||"true"===s;if(a){var u=n.formSubmitted;n.prepareElement(i),n.formSubmitted=u,n.successList.push(i),delete n.invalid[i.name],n.showErrors()}else{var o={},l=s||n.defaultMessage(i,"remote");o[i.name]=r.message=t.isFunction(l)?l(e):l,n.invalid[i.name]=!0,n.showErrors(o)}r.valid=a,n.stopRequest(i,a)}},s)),"pending"}}}),t.format=t.validator.format})(jQuery),function(t){var e={};if(t.ajaxPrefilter)t.ajaxPrefilter(function(t,i,s){var r=t.port;"abort"===t.mode&&(e[r]&&e[r].abort(),e[r]=s)});else{var i=t.ajax;t.ajax=function(s){var r=("mode"in s?s:t.ajaxSettings).mode,n=("port"in s?s:t.ajaxSettings).port;return"abort"===r?(e[n]&&e[n].abort(),e[n]=i.apply(this,arguments),e[n]):i.apply(this,arguments)}}}(jQuery),function(t){t.extend(t.fn,{validateDelegate:function(e,i,s){return this.bind(i,function(i){var r=t(i.target);return r.is(e)?s.apply(r,arguments):void 0})}})}(jQuery);
|
3
|
+
|