surveyor_gui 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +44 -0
- data/.travis.yml +17 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/MIT-LICENSE +20 -0
- data/README.md +159 -0
- data/Rakefile +66 -0
- data/app/controllers/answers_controller.rb +3 -0
- data/app/controllers/application_controller.rb +3 -0
- data/app/controllers/dependencys_controller.rb +286 -0
- data/app/controllers/question_groups_controller.rb +84 -0
- data/app/controllers/questions_controller.rb +187 -0
- data/app/controllers/survey_sections_controller.rb +80 -0
- data/app/controllers/surveyforms_controller.rb +4 -0
- data/app/controllers/surveyor_controller.rb +89 -0
- data/app/controllers/surveyor_gui/reports_controller.rb +339 -0
- data/app/controllers/surveyor_gui/responses_controller.rb +39 -0
- data/app/controllers/surveyor_gui/survey_controller.rb +16 -0
- data/app/facades/report_formatter.rb +44 -0
- data/app/facades/report_preview_wrapper.rb +11 -0
- data/app/facades/report_response_generator.rb +147 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/helpers/dependency_helper.rb +5 -0
- data/app/helpers/question_helper.rb +22 -0
- data/app/helpers/surveyform_helper.rb +179 -0
- data/app/helpers/surveyor_gui/report_helper.rb +19 -0
- data/app/helpers/surveyor_helper.rb +4 -0
- data/app/inputs/currency_input.rb +5 -0
- data/app/inputs/date_picker_input.rb +7 -0
- data/app/inputs/datetime_picker_input.rb +5 -0
- data/app/inputs/percent_input.rb +5 -0
- data/app/inputs/time_picker_input.rb +5 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/answer.rb +4 -0
- data/app/models/column.rb +3 -0
- data/app/models/dependency.rb +4 -0
- data/app/models/dependency_condition.rb +4 -0
- data/app/models/permitted_params_decorator.rb +80 -0
- data/app/models/question.rb +4 -0
- data/app/models/question_group.rb +4 -0
- data/app/models/question_type.rb +7 -0
- data/app/models/response.rb +4 -0
- data/app/models/response_set.rb +4 -0
- data/app/models/row.rb +3 -0
- data/app/models/survey.rb +4 -0
- data/app/models/survey_section.rb +4 -0
- data/app/models/surveyform.rb +103 -0
- data/app/uploaders/blob_uploader.rb +48 -0
- data/app/views/dependencys/_column.html.erb +1 -0
- data/app/views/dependencys/_dependency.html.erb +22 -0
- data/app/views/dependencys/_dependency_condition_fields.html.erb +48 -0
- data/app/views/dependencys/_form.html.erb +20 -0
- data/app/views/dependencys/blank.html.erb +0 -0
- data/app/views/dependencys/edit.html.erb +1 -0
- data/app/views/dependencys/new.html.erb +1 -0
- data/app/views/layouts/application.html.erb +14 -0
- data/app/views/layouts/surveyor_gui_blank.html.erb +12 -0
- data/app/views/layouts/surveyor_gui_default.html.erb +16 -0
- data/app/views/layouts/surveyor_modified.html.erb +14 -0
- data/app/views/partials/_answer.html.haml +33 -0
- data/app/views/partials/_question.html.haml +33 -0
- data/app/views/partials/_question_group.html.haml +73 -0
- data/app/views/partials/_section.html.haml +13 -0
- data/app/views/question_groups/_form.html.erb +56 -0
- data/app/views/question_groups/_group_inline_field.html.erb +21 -0
- data/app/views/question_groups/_group_inline_fields.html.erb +25 -0
- data/app/views/question_groups/blank.html.erb +0 -0
- data/app/views/question_groups/edit.html.erb +1 -0
- data/app/views/question_groups/new.html.erb +1 -0
- data/app/views/questions/_answer_fields.html.erb +23 -0
- data/app/views/questions/_answer_options.html.erb +28 -0
- data/app/views/questions/_form.html.erb +65 -0
- data/app/views/questions/_grid_dropdown_columns.html.erb +10 -0
- data/app/views/questions/_grid_dropdown_fields.html.erb +42 -0
- data/app/views/questions/_grid_fields.html.erb +9 -0
- data/app/views/questions/_no_picks.html.erb +29 -0
- data/app/views/questions/_pick.html +21 -0
- data/app/views/questions/_picks.html.erb +12 -0
- data/app/views/questions/blank.html.erb +0 -0
- data/app/views/questions/edit.html.erb +1 -0
- data/app/views/questions/new.html.erb +1 -0
- data/app/views/survey_sections/_form.html.erb +13 -0
- data/app/views/survey_sections/blank.html.erb +0 -0
- data/app/views/survey_sections/edit.html.erb +1 -0
- data/app/views/survey_sections/new.html.erb +1 -0
- data/app/views/surveyforms/_form.html.erb +50 -0
- data/app/views/surveyforms/_question_field.html.erb +148 -0
- data/app/views/surveyforms/_question_group.html.erb +116 -0
- data/app/views/surveyforms/_question_group_fields.html.erb +3 -0
- data/app/views/surveyforms/_question_name_and_number.html.erb +6 -0
- data/app/views/surveyforms/_question_section.html.erb +15 -0
- data/app/views/surveyforms/_question_wrapper.html.erb +109 -0
- data/app/views/surveyforms/_survey_section_fields.html.erb +138 -0
- data/app/views/surveyforms/clone_survey.html.erb +13 -0
- data/app/views/surveyforms/edit.html.erb +5 -0
- data/app/views/surveyforms/index.html.erb +40 -0
- data/app/views/surveyforms/new.html.erb +1 -0
- data/app/views/surveyforms/show.html.erb +5 -0
- data/app/views/surveyor_gui/reports/_graphs.html.haml +21 -0
- data/app/views/surveyor_gui/reports/_grid.html.haml +42 -0
- data/app/views/surveyor_gui/reports/_grid_dropdown.html.haml +56 -0
- data/app/views/surveyor_gui/reports/_repeater.html.haml +28 -0
- data/app/views/surveyor_gui/reports/_show_report.html.haml +33 -0
- data/app/views/surveyor_gui/reports/_single_question.html.haml +70 -0
- data/app/views/surveyor_gui/reports/show.html.erb +14 -0
- data/app/views/surveyor_gui/responses/_grid.html.haml +20 -0
- data/app/views/surveyor_gui/responses/_grid_dropdown.html.haml +20 -0
- data/app/views/surveyor_gui/responses/_repeater.html.haml +22 -0
- data/app/views/surveyor_gui/responses/_survey_results.html.haml +40 -0
- data/app/views/surveyor_gui/responses/index.html.haml +24 -0
- data/app/views/surveyor_gui/responses/show.html.haml +42 -0
- data/app/views/surveyor_gui/shared/_grid_comments.html.haml +10 -0
- data/app/views/surveyor_gui/shared/_new_line.html.haml +2 -0
- data/app/views/surveyor_gui/shared/_pick_comments.html.haml +15 -0
- data/app/views/surveyor_gui/shared/_question_number.html.haml +9 -0
- data/app/views/surveyor_gui/shared/_report_data.html.haml +24 -0
- data/app/views/surveyor_gui/shared/_stars_report_data.html.haml +14 -0
- data/config.ru +4 -0
- data/config/environment.rb +0 -0
- data/config/routes.rb +71 -0
- data/db/migrate/20140307204049_add_template_to_surveys.rb +5 -0
- data/db/migrate/20140307235607_add_test_data_to_response_sets.rb +5 -0
- data/db/migrate/20140308171947_add_original_choice_to_answers.rb +5 -0
- data/db/migrate/20140308172118_add_blob_to_responses.rb +5 -0
- data/db/migrate/20140308172417_add_modifiable_to_survey_section.rb +5 -0
- data/db/migrate/20140308174532_add_modifiable_to_question.rb +5 -0
- data/db/migrate/20140308175305_add_dynamically_generate_to_questions.rb +5 -0
- data/db/migrate/20140311032923_add_dummy_blob_to_questions.rb +5 -0
- data/db/migrate/20140311160609_add_dynamic_source_to_questions.rb +5 -0
- data/db/migrate/20140311161714_add_report_code_to_questions.rb +5 -0
- data/db/migrate/20140530181134_add_is_comment_to_questions.rb +5 -0
- data/db/migrate/20140531012006_add_is_comment_to_answers.rb +5 -0
- data/db/migrate/20140531225529_create_rows.rb +9 -0
- data/db/migrate/20140601011151_create_columns.rb +11 -0
- data/db/migrate/20140602030330_add_column_id_to_answers.rb +5 -0
- data/db/migrate/20140603155606_add_column_id_to_responses.rb +5 -0
- data/db/migrate/20140606023527_add_column_id_to_dependency_conditions.rb +5 -0
- data/db/migrate/20140815165307_add_user_id_to_survey.rb +5 -0
- data/lib/assets/.gitkeep +0 -0
- data/lib/assets/images/addicon.png +0 -0
- data/lib/assets/images/datepicker.gif +0 -0
- data/lib/assets/images/delete.gif +0 -0
- data/lib/assets/images/delete.png +0 -0
- data/lib/assets/images/images/border.png +0 -0
- data/lib/assets/images/images/controls.png +0 -0
- data/lib/assets/images/images/loading.gif +0 -0
- data/lib/assets/images/images/loading_background.png +0 -0
- data/lib/assets/images/images/overlay.png +0 -0
- data/lib/assets/images/rails.png +0 -0
- data/lib/assets/images/star.gif +0 -0
- data/lib/assets/javascripts/.gitkeep +0 -0
- data/lib/assets/javascripts/surveyor_gui/jquery.MetaData.js +121 -0
- data/lib/assets/javascripts/surveyor_gui/jquery.blockUI.js +619 -0
- data/lib/assets/javascripts/surveyor_gui/jquery.rating.js +377 -0
- data/lib/assets/javascripts/surveyor_gui/jquery.validate.js +1188 -0
- data/lib/assets/javascripts/surveyor_gui/surveyor_add_ons.js +10 -0
- data/lib/assets/javascripts/surveyor_gui/surveyor_gui.js +1417 -0
- data/lib/assets/stylesheets/.gitkeep +0 -0
- data/lib/assets/stylesheets/surveyor_gui/jquery.rating.css +12 -0
- data/lib/assets/stylesheets/surveyor_gui/surveyor_add_ons.css +3 -0
- data/lib/assets/stylesheets/surveyor_gui/surveyor_gui.sass +650 -0
- data/lib/enumerable_extenders.rb +31 -0
- data/lib/generators/surveyor_gui/install_generator.rb +57 -0
- data/lib/generators/surveyor_gui/templates/app/assets/javascripts/surveyor_add_ons.js +2 -0
- data/lib/generators/surveyor_gui/templates/app/assets/javascripts/surveyor_gui_all.js +24 -0
- data/lib/generators/surveyor_gui/templates/app/assets/stylesheets/surveyor_add_ons.css.sass +1 -0
- data/lib/generators/surveyor_gui/templates/app/assets/stylesheets/surveyor_gui_all.css.sass +8 -0
- data/lib/generators/surveyor_gui/templates/app/helpers/surveyor_helper.rb +4 -0
- data/lib/generators/surveyor_gui/templates/app/models/response_set_user.rb +13 -0
- data/lib/generators/surveyor_gui/templates/app/views/layouts/surveyor_gui_default.html.erb +16 -0
- data/lib/generators/surveyor_gui/templates/config/initializers/simple_form.rb +140 -0
- data/lib/generators/surveyor_gui/templates/config/locales/en.yml +5 -0
- data/lib/surveyor_gui.rb +17 -0
- data/lib/surveyor_gui/engine.rb +30 -0
- data/lib/surveyor_gui/helpers/surveyor_helper_methods.rb +19 -0
- data/lib/surveyor_gui/models/answer_methods.rb +24 -0
- data/lib/surveyor_gui/models/column_methods.rb +43 -0
- data/lib/surveyor_gui/models/dependency_condition_methods.rb +53 -0
- data/lib/surveyor_gui/models/dependency_methods.rb +83 -0
- data/lib/surveyor_gui/models/question_and_group_shared_methods.rb +11 -0
- data/lib/surveyor_gui/models/question_group_methods.rb +55 -0
- data/lib/surveyor_gui/models/question_methods.rb +435 -0
- data/lib/surveyor_gui/models/question_type_methods.rb +493 -0
- data/lib/surveyor_gui/models/response_methods.rb +67 -0
- data/lib/surveyor_gui/models/response_set_methods.rb +54 -0
- data/lib/surveyor_gui/models/row_methods.rb +11 -0
- data/lib/surveyor_gui/models/survey_methods.rb +32 -0
- data/lib/surveyor_gui/models/survey_section_methods.rb +32 -0
- data/lib/surveyor_gui/surveyforms_controller_methods.rb +258 -0
- data/lib/surveyor_gui/version.rb +3 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/surveyor_gui_tasks.rake +4 -0
- data/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/spec/controllers/surveyforms_controller_spec.rb +361 -0
- data/spec/controllers/surveyor_controller_spec.rb +303 -0
- data/spec/factories.rb +181 -0
- data/spec/features/create_survey_spec.rb +418 -0
- data/spec/features/dependencies_spec.rb +61 -0
- data/spec/features/rearrange_survey_spec.rb +118 -0
- data/spec/features/ui_spec.rb +469 -0
- data/spec/fixtures/REDCapDemoDatabase_DataDictionary.csv +127 -0
- data/spec/fixtures/chinese_survey.rb +14 -0
- data/spec/fixtures/everything.rb +215 -0
- data/spec/fixtures/favorites-ish.rb +22 -0
- data/spec/fixtures/favorites.rb +22 -0
- data/spec/fixtures/feelings.rb +38 -0
- data/spec/fixtures/lifestyle.rb +55 -0
- data/spec/fixtures/numbers.rb +21 -0
- data/spec/fixtures/redcap_new_headers.csv +1 -0
- data/spec/fixtures/redcap_siblings.csv +1 -0
- data/spec/fixtures/redcap_whitespace.csv +1 -0
- data/spec/helpers/formtastic_custom_input_spec.rb +15 -0
- data/spec/helpers/surveyor_helper_spec.rb +116 -0
- data/spec/lib/common_spec.rb +37 -0
- data/spec/lib/parser_spec.rb +393 -0
- data/spec/lib/rake_kitchen_sink.rb +42 -0
- data/spec/lib/redcap_parser_spec.rb +129 -0
- data/spec/lib/unparser_spec.rb +126 -0
- data/spec/models/answer_spec.rb +144 -0
- data/spec/models/dependency_condition_spec.rb +428 -0
- data/spec/models/dependency_spec.rb +90 -0
- data/spec/models/question_group_spec.rb +66 -0
- data/spec/models/question_spec.rb +176 -0
- data/spec/models/response_set_spec.rb +452 -0
- data/spec/models/response_spec.rb +208 -0
- data/spec/models/survey_section_spec.rb +58 -0
- data/spec/models/survey_spec.rb +155 -0
- data/spec/models/surveyor_gui/question_spec.rb +60 -0
- data/spec/models/surveyor_gui/question_type_spec.rb +268 -0
- data/spec/models/validation_condition_spec.rb +98 -0
- data/spec/models/validation_spec.rb +64 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +119 -0
- data/spec/support/scenario_outline_helper.rb +39 -0
- data/spec/support/shared.rb +10 -0
- data/spec/support/surveyforms_creation_helpers.rb +312 -0
- data/spec/support/surveyforms_rearrangement_helpers.rb +170 -0
- data/spec/support/surveyor_api_helpers.rb +15 -0
- data/spec/support/surveyor_ui_helpers.rb +108 -0
- data/spec/support/wait_for_ajax.rb +11 -0
- data/spec/views/questions/edit.html.erb_spec.rb +73 -0
- data/spec/views/surveyforms/edit.html.erb_spec.rb +126 -0
- data/surveyor_gui.gemspec +52 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/surveyor-gui_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/custom.sass +5 -0
- data/vendor/plugins/.gitkeep +0 -0
- metadata +664 -0
data/lib/assets/.gitkeep
ADDED
File without changes
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
File without changes
|
@@ -0,0 +1,121 @@
|
|
1
|
+
/*
|
2
|
+
* Metadata - jQuery plugin for parsing metadata from elements
|
3
|
+
*
|
4
|
+
* Copyright (c) 2006 John Resig, Yehuda Katz, Jörn Zaefferer, Paul McLanahan
|
5
|
+
*
|
6
|
+
* Dual licensed under the MIT and GPL licenses:
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
* http://www.gnu.org/licenses/gpl.html
|
9
|
+
*
|
10
|
+
* Revision: $Id$
|
11
|
+
*
|
12
|
+
*/
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Sets the type of metadata to use. Metadata is encoded in JSON, and each property
|
16
|
+
* in the JSON will become a property of the element itself.
|
17
|
+
*
|
18
|
+
* There are three supported types of metadata storage:
|
19
|
+
*
|
20
|
+
* attr: Inside an attribute. The name parameter indicates *which* attribute.
|
21
|
+
*
|
22
|
+
* class: Inside the class attribute, wrapped in curly braces: { }
|
23
|
+
*
|
24
|
+
* elem: Inside a child element (e.g. a script tag). The
|
25
|
+
* name parameter indicates *which* element.
|
26
|
+
*
|
27
|
+
* The metadata for an element is loaded the first time the element is accessed via jQuery.
|
28
|
+
*
|
29
|
+
* As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
|
30
|
+
* matched by expr, then redefine the metadata type and run another $(expr) for other elements.
|
31
|
+
*
|
32
|
+
* @name $.metadata.setType
|
33
|
+
*
|
34
|
+
* @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
|
35
|
+
* @before $.metadata.setType("class")
|
36
|
+
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
|
37
|
+
* @desc Reads metadata from the class attribute
|
38
|
+
*
|
39
|
+
* @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
|
40
|
+
* @before $.metadata.setType("attr", "data")
|
41
|
+
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
|
42
|
+
* @desc Reads metadata from a "data" attribute
|
43
|
+
*
|
44
|
+
* @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
|
45
|
+
* @before $.metadata.setType("elem", "script")
|
46
|
+
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
|
47
|
+
* @desc Reads metadata from a nested script element
|
48
|
+
*
|
49
|
+
* @param String type The encoding type
|
50
|
+
* @param String name The name of the attribute to be used to get metadata (optional)
|
51
|
+
* @cat Plugins/Metadata
|
52
|
+
* @descr Sets the type of encoding to be used when loading metadata for the first time
|
53
|
+
* @type undefined
|
54
|
+
* @see metadata()
|
55
|
+
*/
|
56
|
+
|
57
|
+
(function($) {
|
58
|
+
|
59
|
+
$.extend({
|
60
|
+
metadata : {
|
61
|
+
defaults : {
|
62
|
+
type: 'class',
|
63
|
+
name: 'metadata',
|
64
|
+
cre: /({.*})/,
|
65
|
+
single: 'metadata'
|
66
|
+
},
|
67
|
+
setType: function( type, name ){
|
68
|
+
this.defaults.type = type;
|
69
|
+
this.defaults.name = name;
|
70
|
+
},
|
71
|
+
get: function( elem, opts ){
|
72
|
+
var settings = $.extend({},this.defaults,opts);
|
73
|
+
// check for empty string in single property
|
74
|
+
if ( !settings.single.length ) settings.single = 'metadata';
|
75
|
+
|
76
|
+
var data = $.data(elem, settings.single);
|
77
|
+
// returned cached data if it already exists
|
78
|
+
if ( data ) return data;
|
79
|
+
|
80
|
+
data = "{}";
|
81
|
+
|
82
|
+
if ( settings.type == "class" ) {
|
83
|
+
var m = settings.cre.exec( elem.className );
|
84
|
+
if ( m )
|
85
|
+
data = m[1];
|
86
|
+
} else if ( settings.type == "elem" ) {
|
87
|
+
if( !elem.getElementsByTagName ) return;
|
88
|
+
var e = elem.getElementsByTagName(settings.name);
|
89
|
+
if ( e.length )
|
90
|
+
data = $.trim(e[0].innerHTML);
|
91
|
+
} else if ( elem.getAttribute != undefined ) {
|
92
|
+
var attr = elem.getAttribute( settings.name );
|
93
|
+
if ( attr )
|
94
|
+
data = attr;
|
95
|
+
}
|
96
|
+
|
97
|
+
if ( data.indexOf( '{' ) <0 )
|
98
|
+
data = "{" + data + "}";
|
99
|
+
|
100
|
+
data = eval("(" + data + ")");
|
101
|
+
|
102
|
+
$.data( elem, settings.single, data );
|
103
|
+
return data;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
});
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Returns the metadata object for the first member of the jQuery object.
|
110
|
+
*
|
111
|
+
* @name metadata
|
112
|
+
* @descr Returns element's metadata object
|
113
|
+
* @param Object opts An object contianing settings to override the defaults
|
114
|
+
* @type jQuery
|
115
|
+
* @cat Plugins/Metadata
|
116
|
+
*/
|
117
|
+
$.fn.metadata = function( opts ){
|
118
|
+
return $.metadata.get( this[0], opts );
|
119
|
+
};
|
120
|
+
|
121
|
+
})(jQuery);
|
@@ -0,0 +1,619 @@
|
|
1
|
+
/*!
|
2
|
+
* jQuery blockUI plugin
|
3
|
+
* Version 2.66.0-2013.10.09
|
4
|
+
* Requires jQuery v1.7 or later
|
5
|
+
*
|
6
|
+
* Examples at: http://malsup.com/jquery/block/
|
7
|
+
* Copyright (c) 2007-2013 M. Alsup
|
8
|
+
* Dual licensed under the MIT and GPL licenses:
|
9
|
+
* http://www.opensource.org/licenses/mit-license.php
|
10
|
+
* http://www.gnu.org/licenses/gpl.html
|
11
|
+
*
|
12
|
+
* Thanks to Amir-Hossein Sobhi for some excellent contributions!
|
13
|
+
*/
|
14
|
+
|
15
|
+
;(function() {
|
16
|
+
/*jshint eqeqeq:false curly:false latedef:false */
|
17
|
+
"use strict";
|
18
|
+
|
19
|
+
function setup($) {
|
20
|
+
$.fn._fadeIn = $.fn.fadeIn;
|
21
|
+
|
22
|
+
var noOp = $.noop || function() {};
|
23
|
+
|
24
|
+
// this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
|
25
|
+
// confusing userAgent strings on Vista)
|
26
|
+
var msie = /MSIE/.test(navigator.userAgent);
|
27
|
+
var ie6 = /MSIE 6.0/.test(navigator.userAgent) && ! /MSIE 8.0/.test(navigator.userAgent);
|
28
|
+
var mode = document.documentMode || 0;
|
29
|
+
var setExpr = $.isFunction( document.createElement('div').style.setExpression );
|
30
|
+
|
31
|
+
// global $ methods for blocking/unblocking the entire page
|
32
|
+
$.blockUI = function(opts) { install(window, opts); };
|
33
|
+
$.unblockUI = function(opts) { remove(window, opts); };
|
34
|
+
|
35
|
+
// convenience method for quick growl-like notifications (http://www.google.com/search?q=growl)
|
36
|
+
$.growlUI = function(title, message, timeout, onClose) {
|
37
|
+
var $m = $('<div class="growlUI"></div>');
|
38
|
+
if (title) $m.append('<h1>'+title+'</h1>');
|
39
|
+
if (message) $m.append('<h2>'+message+'</h2>');
|
40
|
+
if (timeout === undefined) timeout = 3000;
|
41
|
+
|
42
|
+
// Added by konapun: Set timeout to 30 seconds if this growl is moused over, like normal toast notifications
|
43
|
+
var callBlock = function(opts) {
|
44
|
+
opts = opts || {};
|
45
|
+
|
46
|
+
$.blockUI({
|
47
|
+
message: $m,
|
48
|
+
fadeIn : typeof opts.fadeIn !== 'undefined' ? opts.fadeIn : 700,
|
49
|
+
fadeOut: typeof opts.fadeOut !== 'undefined' ? opts.fadeOut : 1000,
|
50
|
+
timeout: typeof opts.timeout !== 'undefined' ? opts.timeout : timeout,
|
51
|
+
centerY: false,
|
52
|
+
showOverlay: false,
|
53
|
+
onUnblock: onClose,
|
54
|
+
css: $.blockUI.defaults.growlCSS
|
55
|
+
});
|
56
|
+
};
|
57
|
+
|
58
|
+
callBlock();
|
59
|
+
var nonmousedOpacity = $m.css('opacity');
|
60
|
+
$m.mouseover(function() {
|
61
|
+
callBlock({
|
62
|
+
fadeIn: 0,
|
63
|
+
timeout: 30000
|
64
|
+
});
|
65
|
+
|
66
|
+
var displayBlock = $('.blockMsg');
|
67
|
+
displayBlock.stop(); // cancel fadeout if it has started
|
68
|
+
displayBlock.fadeTo(300, 1); // make it easier to read the message by removing transparency
|
69
|
+
}).mouseout(function() {
|
70
|
+
$('.blockMsg').fadeOut(1000);
|
71
|
+
});
|
72
|
+
// End konapun additions
|
73
|
+
};
|
74
|
+
|
75
|
+
// plugin method for blocking element content
|
76
|
+
$.fn.block = function(opts) {
|
77
|
+
if ( this[0] === window ) {
|
78
|
+
$.blockUI( opts );
|
79
|
+
return this;
|
80
|
+
}
|
81
|
+
var fullOpts = $.extend({}, $.blockUI.defaults, opts || {});
|
82
|
+
this.each(function() {
|
83
|
+
var $el = $(this);
|
84
|
+
if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked'))
|
85
|
+
return;
|
86
|
+
$el.unblock({ fadeOut: 0 });
|
87
|
+
});
|
88
|
+
|
89
|
+
return this.each(function() {
|
90
|
+
if ($.css(this,'position') == 'static') {
|
91
|
+
this.style.position = 'relative';
|
92
|
+
$(this).data('blockUI.static', true);
|
93
|
+
}
|
94
|
+
this.style.zoom = 1; // force 'hasLayout' in ie
|
95
|
+
install(this, opts);
|
96
|
+
});
|
97
|
+
};
|
98
|
+
|
99
|
+
// plugin method for unblocking element content
|
100
|
+
$.fn.unblock = function(opts) {
|
101
|
+
if ( this[0] === window ) {
|
102
|
+
$.unblockUI( opts );
|
103
|
+
return this;
|
104
|
+
}
|
105
|
+
return this.each(function() {
|
106
|
+
remove(this, opts);
|
107
|
+
});
|
108
|
+
};
|
109
|
+
|
110
|
+
$.blockUI.version = 2.66; // 2nd generation blocking at no extra cost!
|
111
|
+
|
112
|
+
// override these in your code to change the default behavior and style
|
113
|
+
$.blockUI.defaults = {
|
114
|
+
// message displayed when blocking (use null for no message)
|
115
|
+
message: '<h1>Please wait...</h1>',
|
116
|
+
|
117
|
+
title: null, // title string; only used when theme == true
|
118
|
+
draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded)
|
119
|
+
|
120
|
+
theme: false, // set to true to use with jQuery UI themes
|
121
|
+
|
122
|
+
// styles for the message when blocking; if you wish to disable
|
123
|
+
// these and use an external stylesheet then do this in your code:
|
124
|
+
// $.blockUI.defaults.css = {};
|
125
|
+
css: {
|
126
|
+
padding: 0,
|
127
|
+
margin: 0,
|
128
|
+
width: '30%',
|
129
|
+
top: '40%',
|
130
|
+
left: '35%',
|
131
|
+
textAlign: 'center',
|
132
|
+
color: '#000',
|
133
|
+
border: '3px solid #aaa',
|
134
|
+
backgroundColor:'#fff',
|
135
|
+
cursor: 'wait'
|
136
|
+
},
|
137
|
+
|
138
|
+
// minimal style set used when themes are used
|
139
|
+
themedCSS: {
|
140
|
+
width: '30%',
|
141
|
+
top: '40%',
|
142
|
+
left: '35%'
|
143
|
+
},
|
144
|
+
|
145
|
+
// styles for the overlay
|
146
|
+
overlayCSS: {
|
147
|
+
backgroundColor: '#000',
|
148
|
+
opacity: 0.6,
|
149
|
+
cursor: 'wait'
|
150
|
+
},
|
151
|
+
|
152
|
+
// style to replace wait cursor before unblocking to correct issue
|
153
|
+
// of lingering wait cursor
|
154
|
+
cursorReset: 'default',
|
155
|
+
|
156
|
+
// styles applied when using $.growlUI
|
157
|
+
growlCSS: {
|
158
|
+
width: '350px',
|
159
|
+
top: '10px',
|
160
|
+
left: '',
|
161
|
+
right: '10px',
|
162
|
+
border: 'none',
|
163
|
+
padding: '5px',
|
164
|
+
opacity: 0.6,
|
165
|
+
cursor: 'default',
|
166
|
+
color: '#fff',
|
167
|
+
backgroundColor: '#000',
|
168
|
+
'-webkit-border-radius':'10px',
|
169
|
+
'-moz-border-radius': '10px',
|
170
|
+
'border-radius': '10px'
|
171
|
+
},
|
172
|
+
|
173
|
+
// IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
|
174
|
+
// (hat tip to Jorge H. N. de Vasconcelos)
|
175
|
+
/*jshint scripturl:true */
|
176
|
+
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
|
177
|
+
|
178
|
+
// force usage of iframe in non-IE browsers (handy for blocking applets)
|
179
|
+
forceIframe: false,
|
180
|
+
|
181
|
+
// z-index for the blocking overlay
|
182
|
+
baseZ: 1000,
|
183
|
+
|
184
|
+
// set these to true to have the message automatically centered
|
185
|
+
centerX: true, // <-- only effects element blocking (page block controlled via css above)
|
186
|
+
centerY: true,
|
187
|
+
|
188
|
+
// allow body element to be stetched in ie6; this makes blocking look better
|
189
|
+
// on "short" pages. disable if you wish to prevent changes to the body height
|
190
|
+
allowBodyStretch: true,
|
191
|
+
|
192
|
+
// enable if you want key and mouse events to be disabled for content that is blocked
|
193
|
+
bindEvents: true,
|
194
|
+
|
195
|
+
// be default blockUI will supress tab navigation from leaving blocking content
|
196
|
+
// (if bindEvents is true)
|
197
|
+
constrainTabKey: true,
|
198
|
+
|
199
|
+
// fadeIn time in millis; set to 0 to disable fadeIn on block
|
200
|
+
fadeIn: 200,
|
201
|
+
|
202
|
+
// fadeOut time in millis; set to 0 to disable fadeOut on unblock
|
203
|
+
fadeOut: 400,
|
204
|
+
|
205
|
+
// time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
|
206
|
+
timeout: 0,
|
207
|
+
|
208
|
+
// disable if you don't want to show the overlay
|
209
|
+
showOverlay: true,
|
210
|
+
|
211
|
+
// if true, focus will be placed in the first available input field when
|
212
|
+
// page blocking
|
213
|
+
focusInput: true,
|
214
|
+
|
215
|
+
// elements that can receive focus
|
216
|
+
focusableElements: ':input:enabled:visible',
|
217
|
+
|
218
|
+
// suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
|
219
|
+
// no longer needed in 2012
|
220
|
+
// applyPlatformOpacityRules: true,
|
221
|
+
|
222
|
+
// callback method invoked when fadeIn has completed and blocking message is visible
|
223
|
+
onBlock: null,
|
224
|
+
|
225
|
+
// callback method invoked when unblocking has completed; the callback is
|
226
|
+
// passed the element that has been unblocked (which is the window object for page
|
227
|
+
// blocks) and the options that were passed to the unblock call:
|
228
|
+
// onUnblock(element, options)
|
229
|
+
onUnblock: null,
|
230
|
+
|
231
|
+
// callback method invoked when the overlay area is clicked.
|
232
|
+
// setting this will turn the cursor to a pointer, otherwise cursor defined in overlayCss will be used.
|
233
|
+
onOverlayClick: null,
|
234
|
+
|
235
|
+
// don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
|
236
|
+
quirksmodeOffsetHack: 4,
|
237
|
+
|
238
|
+
// class name of the message block
|
239
|
+
blockMsgClass: 'blockMsg',
|
240
|
+
|
241
|
+
// if it is already blocked, then ignore it (don't unblock and reblock)
|
242
|
+
ignoreIfBlocked: false
|
243
|
+
};
|
244
|
+
|
245
|
+
// private data and functions follow...
|
246
|
+
|
247
|
+
var pageBlock = null;
|
248
|
+
var pageBlockEls = [];
|
249
|
+
|
250
|
+
function install(el, opts) {
|
251
|
+
var css, themedCSS;
|
252
|
+
var full = (el == window);
|
253
|
+
var msg = (opts && opts.message !== undefined ? opts.message : undefined);
|
254
|
+
opts = $.extend({}, $.blockUI.defaults, opts || {});
|
255
|
+
|
256
|
+
if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked'))
|
257
|
+
return;
|
258
|
+
|
259
|
+
opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
|
260
|
+
css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
|
261
|
+
if (opts.onOverlayClick)
|
262
|
+
opts.overlayCSS.cursor = 'pointer';
|
263
|
+
|
264
|
+
themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
|
265
|
+
msg = msg === undefined ? opts.message : msg;
|
266
|
+
|
267
|
+
// remove the current block (if there is one)
|
268
|
+
if (full && pageBlock)
|
269
|
+
remove(window, {fadeOut:0});
|
270
|
+
|
271
|
+
// if an existing element is being used as the blocking content then we capture
|
272
|
+
// its current place in the DOM (and current display style) so we can restore
|
273
|
+
// it when we unblock
|
274
|
+
if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
|
275
|
+
var node = msg.jquery ? msg[0] : msg;
|
276
|
+
var data = {};
|
277
|
+
$(el).data('blockUI.history', data);
|
278
|
+
data.el = node;
|
279
|
+
data.parent = node.parentNode;
|
280
|
+
data.display = node.style.display;
|
281
|
+
data.position = node.style.position;
|
282
|
+
if (data.parent)
|
283
|
+
data.parent.removeChild(node);
|
284
|
+
}
|
285
|
+
|
286
|
+
$(el).data('blockUI.onUnblock', opts.onUnblock);
|
287
|
+
var z = opts.baseZ;
|
288
|
+
|
289
|
+
// blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
|
290
|
+
// layer1 is the iframe layer which is used to supress bleed through of underlying content
|
291
|
+
// layer2 is the overlay layer which has opacity and a wait cursor (by default)
|
292
|
+
// layer3 is the message content that is displayed while blocking
|
293
|
+
var lyr1, lyr2, lyr3, s;
|
294
|
+
if (msie || opts.forceIframe)
|
295
|
+
lyr1 = $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>');
|
296
|
+
else
|
297
|
+
lyr1 = $('<div class="blockUI" style="display:none"></div>');
|
298
|
+
|
299
|
+
if (opts.theme)
|
300
|
+
lyr2 = $('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+ (z++) +';display:none"></div>');
|
301
|
+
else
|
302
|
+
lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
|
303
|
+
|
304
|
+
if (opts.theme && full) {
|
305
|
+
s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:fixed">';
|
306
|
+
if ( opts.title ) {
|
307
|
+
s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || ' ')+'</div>';
|
308
|
+
}
|
309
|
+
s += '<div class="ui-widget-content ui-dialog-content"></div>';
|
310
|
+
s += '</div>';
|
311
|
+
}
|
312
|
+
else if (opts.theme) {
|
313
|
+
s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:absolute">';
|
314
|
+
if ( opts.title ) {
|
315
|
+
s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || ' ')+'</div>';
|
316
|
+
}
|
317
|
+
s += '<div class="ui-widget-content ui-dialog-content"></div>';
|
318
|
+
s += '</div>';
|
319
|
+
}
|
320
|
+
else if (full) {
|
321
|
+
s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage" style="z-index:'+(z+10)+';display:none;position:fixed"></div>';
|
322
|
+
}
|
323
|
+
else {
|
324
|
+
s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement" style="z-index:'+(z+10)+';display:none;position:absolute"></div>';
|
325
|
+
}
|
326
|
+
lyr3 = $(s);
|
327
|
+
|
328
|
+
// if we have a message, style it
|
329
|
+
if (msg) {
|
330
|
+
if (opts.theme) {
|
331
|
+
lyr3.css(themedCSS);
|
332
|
+
lyr3.addClass('ui-widget-content');
|
333
|
+
}
|
334
|
+
else
|
335
|
+
lyr3.css(css);
|
336
|
+
}
|
337
|
+
|
338
|
+
// style the overlay
|
339
|
+
if (!opts.theme /*&& (!opts.applyPlatformOpacityRules)*/)
|
340
|
+
lyr2.css(opts.overlayCSS);
|
341
|
+
lyr2.css('position', full ? 'fixed' : 'absolute');
|
342
|
+
|
343
|
+
// make iframe layer transparent in IE
|
344
|
+
if (msie || opts.forceIframe)
|
345
|
+
lyr1.css('opacity',0.0);
|
346
|
+
|
347
|
+
//$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
|
348
|
+
var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el);
|
349
|
+
$.each(layers, function() {
|
350
|
+
this.appendTo($par);
|
351
|
+
});
|
352
|
+
|
353
|
+
if (opts.theme && opts.draggable && $.fn.draggable) {
|
354
|
+
lyr3.draggable({
|
355
|
+
handle: '.ui-dialog-titlebar',
|
356
|
+
cancel: 'li'
|
357
|
+
});
|
358
|
+
}
|
359
|
+
|
360
|
+
// ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
|
361
|
+
var expr = setExpr && (!$.support.boxModel || $('object,embed', full ? null : el).length > 0);
|
362
|
+
if (ie6 || expr) {
|
363
|
+
// give body 100% height
|
364
|
+
if (full && opts.allowBodyStretch && $.support.boxModel)
|
365
|
+
$('html,body').css('height','100%');
|
366
|
+
|
367
|
+
// fix ie6 issue when blocked element has a border width
|
368
|
+
if ((ie6 || !$.support.boxModel) && !full) {
|
369
|
+
var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
|
370
|
+
var fixT = t ? '(0 - '+t+')' : 0;
|
371
|
+
var fixL = l ? '(0 - '+l+')' : 0;
|
372
|
+
}
|
373
|
+
|
374
|
+
// simulate fixed position
|
375
|
+
$.each(layers, function(i,o) {
|
376
|
+
var s = o[0].style;
|
377
|
+
s.position = 'absolute';
|
378
|
+
if (i < 2) {
|
379
|
+
if (full)
|
380
|
+
s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"');
|
381
|
+
else
|
382
|
+
s.setExpression('height','this.parentNode.offsetHeight + "px"');
|
383
|
+
if (full)
|
384
|
+
s.setExpression('width','jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"');
|
385
|
+
else
|
386
|
+
s.setExpression('width','this.parentNode.offsetWidth + "px"');
|
387
|
+
if (fixL) s.setExpression('left', fixL);
|
388
|
+
if (fixT) s.setExpression('top', fixT);
|
389
|
+
}
|
390
|
+
else if (opts.centerY) {
|
391
|
+
if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
|
392
|
+
s.marginTop = 0;
|
393
|
+
}
|
394
|
+
else if (!opts.centerY && full) {
|
395
|
+
var top = (opts.css && opts.css.top) ? parseInt(opts.css.top, 10) : 0;
|
396
|
+
var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';
|
397
|
+
s.setExpression('top',expression);
|
398
|
+
}
|
399
|
+
});
|
400
|
+
}
|
401
|
+
|
402
|
+
// show the message
|
403
|
+
if (msg) {
|
404
|
+
if (opts.theme)
|
405
|
+
lyr3.find('.ui-widget-content').append(msg);
|
406
|
+
else
|
407
|
+
lyr3.append(msg);
|
408
|
+
if (msg.jquery || msg.nodeType)
|
409
|
+
$(msg).show();
|
410
|
+
}
|
411
|
+
|
412
|
+
if ((msie || opts.forceIframe) && opts.showOverlay)
|
413
|
+
lyr1.show(); // opacity is zero
|
414
|
+
if (opts.fadeIn) {
|
415
|
+
var cb = opts.onBlock ? opts.onBlock : noOp;
|
416
|
+
var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
|
417
|
+
var cb2 = msg ? cb : noOp;
|
418
|
+
if (opts.showOverlay)
|
419
|
+
lyr2._fadeIn(opts.fadeIn, cb1);
|
420
|
+
if (msg)
|
421
|
+
lyr3._fadeIn(opts.fadeIn, cb2);
|
422
|
+
}
|
423
|
+
else {
|
424
|
+
if (opts.showOverlay)
|
425
|
+
lyr2.show();
|
426
|
+
if (msg)
|
427
|
+
lyr3.show();
|
428
|
+
if (opts.onBlock)
|
429
|
+
opts.onBlock();
|
430
|
+
}
|
431
|
+
|
432
|
+
// bind key and mouse events
|
433
|
+
bind(1, el, opts);
|
434
|
+
|
435
|
+
if (full) {
|
436
|
+
pageBlock = lyr3[0];
|
437
|
+
pageBlockEls = $(opts.focusableElements,pageBlock);
|
438
|
+
if (opts.focusInput)
|
439
|
+
setTimeout(focus, 20);
|
440
|
+
}
|
441
|
+
else
|
442
|
+
center(lyr3[0], opts.centerX, opts.centerY);
|
443
|
+
|
444
|
+
if (opts.timeout) {
|
445
|
+
// auto-unblock
|
446
|
+
var to = setTimeout(function() {
|
447
|
+
if (full)
|
448
|
+
$.unblockUI(opts);
|
449
|
+
else
|
450
|
+
$(el).unblock(opts);
|
451
|
+
}, opts.timeout);
|
452
|
+
$(el).data('blockUI.timeout', to);
|
453
|
+
}
|
454
|
+
}
|
455
|
+
|
456
|
+
// remove the block
|
457
|
+
function remove(el, opts) {
|
458
|
+
var count;
|
459
|
+
var full = (el == window);
|
460
|
+
var $el = $(el);
|
461
|
+
var data = $el.data('blockUI.history');
|
462
|
+
var to = $el.data('blockUI.timeout');
|
463
|
+
if (to) {
|
464
|
+
clearTimeout(to);
|
465
|
+
$el.removeData('blockUI.timeout');
|
466
|
+
}
|
467
|
+
opts = $.extend({}, $.blockUI.defaults, opts || {});
|
468
|
+
bind(0, el, opts); // unbind events
|
469
|
+
|
470
|
+
if (opts.onUnblock === null) {
|
471
|
+
opts.onUnblock = $el.data('blockUI.onUnblock');
|
472
|
+
$el.removeData('blockUI.onUnblock');
|
473
|
+
}
|
474
|
+
|
475
|
+
var els;
|
476
|
+
if (full) // crazy selector to handle odd field errors in ie6/7
|
477
|
+
els = $('body').children().filter('.blockUI').add('body > .blockUI');
|
478
|
+
else
|
479
|
+
els = $el.find('>.blockUI');
|
480
|
+
|
481
|
+
// fix cursor issue
|
482
|
+
if ( opts.cursorReset ) {
|
483
|
+
if ( els.length > 1 )
|
484
|
+
els[1].style.cursor = opts.cursorReset;
|
485
|
+
if ( els.length > 2 )
|
486
|
+
els[2].style.cursor = opts.cursorReset;
|
487
|
+
}
|
488
|
+
|
489
|
+
if (full)
|
490
|
+
pageBlock = pageBlockEls = null;
|
491
|
+
|
492
|
+
if (opts.fadeOut) {
|
493
|
+
count = els.length;
|
494
|
+
els.stop().fadeOut(opts.fadeOut, function() {
|
495
|
+
if ( --count === 0)
|
496
|
+
reset(els,data,opts,el);
|
497
|
+
});
|
498
|
+
}
|
499
|
+
else
|
500
|
+
reset(els, data, opts, el);
|
501
|
+
}
|
502
|
+
|
503
|
+
// move blocking element back into the DOM where it started
|
504
|
+
function reset(els,data,opts,el) {
|
505
|
+
var $el = $(el);
|
506
|
+
if ( $el.data('blockUI.isBlocked') )
|
507
|
+
return;
|
508
|
+
|
509
|
+
els.each(function(i,o) {
|
510
|
+
// remove via DOM calls so we don't lose event handlers
|
511
|
+
if (this.parentNode)
|
512
|
+
this.parentNode.removeChild(this);
|
513
|
+
});
|
514
|
+
|
515
|
+
if (data && data.el) {
|
516
|
+
data.el.style.display = data.display;
|
517
|
+
data.el.style.position = data.position;
|
518
|
+
if (data.parent)
|
519
|
+
data.parent.appendChild(data.el);
|
520
|
+
$el.removeData('blockUI.history');
|
521
|
+
}
|
522
|
+
|
523
|
+
if ($el.data('blockUI.static')) {
|
524
|
+
$el.css('position', 'static'); // #22
|
525
|
+
}
|
526
|
+
|
527
|
+
if (typeof opts.onUnblock == 'function')
|
528
|
+
opts.onUnblock(el,opts);
|
529
|
+
|
530
|
+
// fix issue in Safari 6 where block artifacts remain until reflow
|
531
|
+
var body = $(document.body), w = body.width(), cssW = body[0].style.width;
|
532
|
+
body.width(w-1).width(w);
|
533
|
+
body[0].style.width = cssW;
|
534
|
+
}
|
535
|
+
|
536
|
+
// bind/unbind the handler
|
537
|
+
function bind(b, el, opts) {
|
538
|
+
var full = el == window, $el = $(el);
|
539
|
+
|
540
|
+
// don't bother unbinding if there is nothing to unbind
|
541
|
+
if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
|
542
|
+
return;
|
543
|
+
|
544
|
+
$el.data('blockUI.isBlocked', b);
|
545
|
+
|
546
|
+
// don't bind events when overlay is not in use or if bindEvents is false
|
547
|
+
if (!full || !opts.bindEvents || (b && !opts.showOverlay))
|
548
|
+
return;
|
549
|
+
|
550
|
+
// bind anchors and inputs for mouse and key events
|
551
|
+
var events = 'mousedown mouseup keydown keypress keyup touchstart touchend touchmove';
|
552
|
+
if (b)
|
553
|
+
$(document).bind(events, opts, handler);
|
554
|
+
else
|
555
|
+
$(document).unbind(events, handler);
|
556
|
+
|
557
|
+
// former impl...
|
558
|
+
// var $e = $('a,:input');
|
559
|
+
// b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
|
560
|
+
}
|
561
|
+
|
562
|
+
// event handler to suppress keyboard/mouse events when blocking
|
563
|
+
function handler(e) {
|
564
|
+
// allow tab navigation (conditionally)
|
565
|
+
if (e.type === 'keydown' && e.keyCode && e.keyCode == 9) {
|
566
|
+
if (pageBlock && e.data.constrainTabKey) {
|
567
|
+
var els = pageBlockEls;
|
568
|
+
var fwd = !e.shiftKey && e.target === els[els.length-1];
|
569
|
+
var back = e.shiftKey && e.target === els[0];
|
570
|
+
if (fwd || back) {
|
571
|
+
setTimeout(function(){focus(back);},10);
|
572
|
+
return false;
|
573
|
+
}
|
574
|
+
}
|
575
|
+
}
|
576
|
+
var opts = e.data;
|
577
|
+
var target = $(e.target);
|
578
|
+
if (target.hasClass('blockOverlay') && opts.onOverlayClick)
|
579
|
+
opts.onOverlayClick(e);
|
580
|
+
|
581
|
+
// allow events within the message content
|
582
|
+
if (target.parents('div.' + opts.blockMsgClass).length > 0)
|
583
|
+
return true;
|
584
|
+
|
585
|
+
// allow events for content that is not being blocked
|
586
|
+
return target.parents().children().filter('div.blockUI').length === 0;
|
587
|
+
}
|
588
|
+
|
589
|
+
function focus(back) {
|
590
|
+
if (!pageBlockEls)
|
591
|
+
return;
|
592
|
+
var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
|
593
|
+
if (e)
|
594
|
+
e.focus();
|
595
|
+
}
|
596
|
+
|
597
|
+
function center(el, x, y) {
|
598
|
+
var p = el.parentNode, s = el.style;
|
599
|
+
var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
|
600
|
+
var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
|
601
|
+
if (x) s.left = l > 0 ? (l+'px') : '0';
|
602
|
+
if (y) s.top = t > 0 ? (t+'px') : '0';
|
603
|
+
}
|
604
|
+
|
605
|
+
function sz(el, p) {
|
606
|
+
return parseInt($.css(el,p),10)||0;
|
607
|
+
}
|
608
|
+
|
609
|
+
}
|
610
|
+
|
611
|
+
|
612
|
+
/*global define:true */
|
613
|
+
if (typeof define === 'function' && define.amd && define.amd.jQuery) {
|
614
|
+
define(['jquery'], setup);
|
615
|
+
} else {
|
616
|
+
setup(jQuery);
|
617
|
+
}
|
618
|
+
|
619
|
+
})();
|