enju_leaf 1.1.0.rc7 → 1.1.0.rc8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +7 -4
  3. data/app/assets/javascripts/jquery.mobile-1.4.2.js +15056 -0
  4. data/app/assets/javascripts/mobile.js +1 -1
  5. data/app/assets/javascripts/profiles.js +2 -0
  6. data/app/assets/stylesheets/enju.css +1 -1
  7. data/app/assets/stylesheets/jquery.mobile-1.4.2.css +4698 -0
  8. data/app/assets/stylesheets/mobile.css +1 -1
  9. data/app/assets/stylesheets/normalize.css +406 -0
  10. data/app/assets/stylesheets/profiles.css +4 -0
  11. data/app/controllers/user_import_files_controller.rb +93 -0
  12. data/app/controllers/user_import_results_controller.rb +15 -0
  13. data/app/controllers/users_controller.rb +2 -2
  14. data/app/helpers/profiles_helper.rb +2 -0
  15. data/app/models/enju_leaf/ability.rb +12 -2
  16. data/app/models/profile.rb +15 -0
  17. data/app/models/user_import_file.rb +171 -0
  18. data/app/models/user_import_result.rb +9 -0
  19. data/app/views/kaminari/{_first_page.mobile.erb → enju_leaf_mobile/_first_page.html.erb} +0 -0
  20. data/app/views/kaminari/{_gap.mobile.erb → enju_leaf_mobile/_gap.html.erb} +0 -0
  21. data/app/views/kaminari/{_last_page.mobile.erb → enju_leaf_mobile/_last_page.html.erb} +0 -0
  22. data/app/views/kaminari/{_next_page.mobile.erb → enju_leaf_mobile/_next_page.html.erb} +0 -0
  23. data/app/views/kaminari/{_page.mobile.erb → enju_leaf_mobile/_page.html.erb} +0 -0
  24. data/app/views/kaminari/{_paginator.mobile.erb → enju_leaf_mobile/_paginator.html.erb} +0 -0
  25. data/app/views/kaminari/{_prev_page.mobile.erb → enju_leaf_mobile/_prev_page.html.erb} +0 -0
  26. data/app/views/page/_footer.html.erb +3 -3
  27. data/app/views/page/_menu.html.erb +1 -1
  28. data/app/views/page/about.en.html.erb +2 -2
  29. data/app/views/page/about.ja.html.erb +2 -2
  30. data/app/views/page/configuration.html.erb +12 -0
  31. data/app/views/page/import.html.erb +6 -5
  32. data/app/views/profiles/_form.html.erb +53 -0
  33. data/app/views/profiles/edit.html.erb +6 -0
  34. data/app/views/profiles/index.html.erb +43 -0
  35. data/app/views/profiles/new.html.erb +14 -0
  36. data/app/views/profiles/show.html.erb +54 -0
  37. data/app/views/user_groups/_form.html.erb +1 -1
  38. data/app/views/user_import_files/_form.html.erb +61 -0
  39. data/app/views/user_import_files/edit.html.erb +6 -0
  40. data/app/views/user_import_files/index.html.erb +43 -0
  41. data/app/views/user_import_files/new.html.erb +35 -0
  42. data/app/views/user_import_files/show.html.erb +59 -0
  43. data/app/views/user_import_results/_form.html.erb +29 -0
  44. data/app/views/user_import_results/index.html.erb +31 -0
  45. data/app/views/user_import_results/show.html.erb +19 -0
  46. data/app/views/users/new.html.erb +4 -4
  47. data/config/locales/translation_en.yml +17 -6
  48. data/config/locales/translation_ja.yml +17 -1
  49. data/config/routes.rb +8 -0
  50. data/db/migrate/20140110122216_create_user_import_files.rb +19 -0
  51. data/db/migrate/20140110131010_create_user_import_results.rb +11 -0
  52. data/db/migrate/20140122054321_create_profiles.rb +21 -0
  53. data/lib/enju_leaf/engine.rb +1 -0
  54. data/lib/enju_leaf/user.rb +6 -3
  55. data/lib/enju_leaf/version.rb +1 -1
  56. data/lib/generators/enju_leaf/setup/setup_generator.rb +3 -1
  57. data/lib/generators/enju_leaf/setup/templates/Procfile +3 -0
  58. data/lib/generators/enju_leaf/setup/templates/config/application.yml +1 -1
  59. data/lib/generators/enju_leaf/setup/templates/config/schedule.rb +1 -2
  60. data/spec/controllers/user_import_files_controller_spec.rb +294 -0
  61. data/spec/controllers/user_import_results_controller_spec.rb +137 -0
  62. data/spec/dummy/db/development.sqlite3 +0 -0
  63. data/spec/dummy/db/schema.rb +25 -1
  64. data/spec/dummy/db/test.sqlite3 +0 -0
  65. data/spec/dummy/private/system/user_import_files/user_imports/980/190/963/original/user_delete_file.tsv +4 -0
  66. data/spec/dummy/private/system/user_import_files/user_imports/980/190/963/original/user_import_file_sample.tsv +5 -0
  67. data/spec/dummy/private/system/user_import_files/user_imports/980/190/963/original/user_update_file.tsv +4 -0
  68. data/spec/dummy/private/system/user_import_files/user_imports/980/190/964/original/user_delete_file.tsv +4 -0
  69. data/spec/dummy/solr/default/data/index/segments.gen +0 -0
  70. data/spec/dummy/solr/default/data/index/segments_1la +0 -0
  71. data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000000063 → tlog.0000000000000002051} +0 -0
  72. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002052 +0 -0
  73. data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000000065 → tlog.0000000000000002053} +0 -0
  74. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002054 +0 -0
  75. data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000000067 → tlog.0000000000000002055} +0 -0
  76. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002056 +0 -0
  77. data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000000069 → tlog.0000000000000002057} +0 -0
  78. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002058 +0 -0
  79. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002059 +0 -0
  80. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002060 +0 -0
  81. data/spec/dummy/tmp/cache/4F7/F90/default_role +0 -0
  82. data/spec/dummy/tmp/cache/ACB/B20/manifestation_search_total +0 -0
  83. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  84. data/spec/dummy/tmp/cache/assets/test/sprockets/154f7b83f2da0e86effbe25f32135177 +0 -0
  85. data/spec/dummy/tmp/cache/assets/test/sprockets/1b984bdbd3204a51a82d0e01a1569e2d +0 -0
  86. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  87. data/spec/dummy/tmp/cache/assets/test/sprockets/3054c50144654f9c7e57bb0639a276e9 +0 -0
  88. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  89. data/spec/dummy/tmp/cache/assets/test/sprockets/3bd7a263237ba366f64d938fe5303757 +0 -0
  90. data/spec/dummy/tmp/cache/assets/test/sprockets/62899096da1a3e67660f3b88068be8c9 +0 -0
  91. data/spec/dummy/tmp/cache/assets/test/sprockets/65b2e4f67eab21b30217e29075f433b2 +0 -0
  92. data/spec/dummy/tmp/cache/assets/test/sprockets/87d24a3f43f175d4d17babe9203c79a7 +0 -0
  93. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  94. data/spec/dummy/tmp/cache/assets/test/sprockets/d38d8658b30de1d068603968227680d4 +0 -0
  95. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  96. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  97. data/spec/fixtures/user_import_files.yml +27 -0
  98. data/spec/fixtures/user_import_results.yml +13 -0
  99. data/spec/models/user_import_file_spec.rb +64 -0
  100. data/spec/models/user_import_result_spec.rb +7 -0
  101. data/vendor/assets/javascripts/jquery.colorbox.js +220 -213
  102. data/vendor/assets/stylesheets/colorbox.css +1 -1
  103. metadata +224 -150
  104. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_valid_params/assigns_a_newly_created_import_request_as_import_request.yml +0 -620
  105. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_valid_params/redirects_to_the_created_import_request.yml +0 -620
  106. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Librarian/with_valid_params/assigns_a_newly_created_import_request_as_import_request.yml +0 -620
  107. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Librarian/with_valid_params/redirects_to_the_created_import_request.yml +0 -620
  108. data/spec/cassette_library/Manifestation/should_import_isbn.yml +0 -537
  109. data/spec/cassette_library/Question/test_should_get_crd_search.yml +0 -437
  110. data/spec/dummy/solr/default/data/index/_z.fdt +0 -0
  111. data/spec/dummy/solr/default/data/index/_z.fdx +0 -0
  112. data/spec/dummy/solr/default/data/index/_z.fnm +0 -0
  113. data/spec/dummy/solr/default/data/index/_z.nvd +0 -0
  114. data/spec/dummy/solr/default/data/index/_z.nvm +0 -0
  115. data/spec/dummy/solr/default/data/index/_z.si +0 -0
  116. data/spec/dummy/solr/default/data/index/_z_Lucene41_0.doc +0 -0
  117. data/spec/dummy/solr/default/data/index/_z_Lucene41_0.pos +0 -0
  118. data/spec/dummy/solr/default/data/index/_z_Lucene41_0.tim +0 -0
  119. data/spec/dummy/solr/default/data/index/_z_Lucene41_0.tip +0 -0
  120. data/spec/dummy/solr/default/data/index/segments_21 +0 -0
  121. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000062 +0 -0
  122. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000064 +0 -0
  123. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000066 +0 -0
  124. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000068 +0 -0
  125. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000070 +0 -0
  126. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000071 +0 -0
@@ -0,0 +1,137 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe UserImportResultsController do
5
+ fixtures :all
6
+
7
+ describe "GET index" do
8
+ describe "When logged in as Administrator" do
9
+ login_admin
10
+
11
+ it "assigns all user_import_results as @user_import_results" do
12
+ get :index
13
+ assigns(:user_import_results).should eq(UserImportResult.page(1))
14
+ end
15
+ end
16
+
17
+ describe "When logged in as Librarian" do
18
+ login_librarian
19
+
20
+ it "assigns all user_import_results as @user_import_results" do
21
+ get :index
22
+ assigns(:user_import_results).should eq(UserImportResult.page(1))
23
+ end
24
+ end
25
+
26
+ describe "When logged in as User" do
27
+ login_user
28
+
29
+ it "assigns empty as @user_import_results" do
30
+ get :index
31
+ assigns(:user_import_results).should be_empty
32
+ response.should be_forbidden
33
+ end
34
+ end
35
+
36
+ describe "When not logged in" do
37
+ it "assigns empty as @user_import_results" do
38
+ get :index
39
+ assigns(:user_import_results).should be_empty
40
+ response.should redirect_to(new_user_session_url)
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "GET show" do
46
+ describe "When logged in as Administrator" do
47
+ login_admin
48
+
49
+ it "assigns the requested user_import_result as @user_import_result" do
50
+ get :show, :id => 1
51
+ assigns(:user_import_result).should eq(UserImportResult.find(1))
52
+ end
53
+ end
54
+
55
+ describe "When logged in as Librarian" do
56
+ login_librarian
57
+
58
+ it "assigns the requested user_import_result as @user_import_result" do
59
+ get :show, :id => 1
60
+ assigns(:user_import_result).should eq(UserImportResult.find(1))
61
+ end
62
+ end
63
+
64
+ describe "When logged in as User" do
65
+ login_user
66
+
67
+ it "assigns the requested user_import_result as @user_import_result" do
68
+ get :show, :id => 1
69
+ assigns(:user_import_result).should eq(UserImportResult.find(1))
70
+ end
71
+ end
72
+
73
+ describe "When not logged in" do
74
+ it "assigns the requested user_import_result as @user_import_result" do
75
+ get :show, :id => 1
76
+ assigns(:user_import_result).should eq(UserImportResult.find(1))
77
+ response.should redirect_to(new_user_session_url)
78
+ end
79
+ end
80
+ end
81
+
82
+ describe "DELETE destroy" do
83
+ before(:each) do
84
+ @user_import_result = user_import_results(:one)
85
+ end
86
+
87
+ describe "When logged in as Administrator" do
88
+ login_admin
89
+
90
+ it "destroys the requested user_import_result" do
91
+ delete :destroy, :id => @user_import_result.id
92
+ end
93
+
94
+ it "should be forbidden" do
95
+ delete :destroy, :id => @user_import_result.id
96
+ response.should be_forbidden
97
+ end
98
+ end
99
+
100
+ describe "When logged in as Librarian" do
101
+ login_librarian
102
+
103
+ it "destroys the requested user_import_result" do
104
+ delete :destroy, :id => @user_import_result.id
105
+ end
106
+
107
+ it "should be forbidden" do
108
+ delete :destroy, :id => @user_import_result.id
109
+ response.should be_forbidden
110
+ end
111
+ end
112
+
113
+ describe "When logged in as User" do
114
+ login_user
115
+
116
+ it "destroys the requested user_import_result" do
117
+ delete :destroy, :id => @user_import_result.id
118
+ end
119
+
120
+ it "should be forbidden" do
121
+ delete :destroy, :id => @user_import_result.id
122
+ response.should be_forbidden
123
+ end
124
+ end
125
+
126
+ describe "When not logged in" do
127
+ it "destroys the requested user_import_result" do
128
+ delete :destroy, :id => @user_import_result.id
129
+ end
130
+
131
+ it "should be forbidden" do
132
+ delete :destroy, :id => @user_import_result.id
133
+ response.should redirect_to(new_user_session_url)
134
+ end
135
+ end
136
+ end
137
+ end
Binary file
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20130221154434) do
14
+ ActiveRecord::Schema.define(:version => 20140110131010) do
15
15
 
16
16
  create_table "accepts", :force => true do |t|
17
17
  t.integer "basket_id"
@@ -767,6 +767,30 @@ ActiveRecord::Schema.define(:version => 20130221154434) do
767
767
  add_index "user_has_roles", ["role_id"], :name => "index_user_has_roles_on_role_id"
768
768
  add_index "user_has_roles", ["user_id"], :name => "index_user_has_roles_on_user_id"
769
769
 
770
+ create_table "user_import_files", :force => true do |t|
771
+ t.integer "user_id"
772
+ t.text "note"
773
+ t.datetime "executed_at"
774
+ t.string "state"
775
+ t.string "user_import_file_name"
776
+ t.string "user_import_content_type"
777
+ t.string "user_import_file_size"
778
+ t.datetime "user_import_updated_at"
779
+ t.string "user_import_fingerprint"
780
+ t.string "edit_mode"
781
+ t.text "error_message"
782
+ t.datetime "created_at", :null => false
783
+ t.datetime "updated_at", :null => false
784
+ end
785
+
786
+ create_table "user_import_results", :force => true do |t|
787
+ t.integer "user_import_file_id"
788
+ t.integer "user_id"
789
+ t.text "body"
790
+ t.datetime "created_at", :null => false
791
+ t.datetime "updated_at", :null => false
792
+ end
793
+
770
794
  create_table "users", :force => true do |t|
771
795
  t.string "email", :default => "", :null => false
772
796
  t.string "encrypted_password", :default => "", :null => false
Binary file
@@ -0,0 +1,4 @@
1
+ username email role user_group expired_at note
2
+ user001 user001@example.jp Administrator test
3
+ user002 User 2013-12-01
4
+ user003 user003@example.jp Librarian テストユーザ
@@ -0,0 +1,5 @@
1
+ username email user_number role user_group expired_at password note dummy
2
+ user001 user001@example.jp 001001 Administrator user test
3
+ user002 001002 User faculty 2013-12-01
4
+ user003 user003@example.jp 001003 Librarian user 4NsxXPLy テストユーザ
5
+ user004 001004 user t
@@ -0,0 +1,4 @@
1
+ username email role user_group expired_at note
2
+ user001 user001@example.jp Administrator test
3
+ user002 User 2013-12-01
4
+ user003 user003@example.jp Librarian テストユーザ
@@ -0,0 +1,4 @@
1
+ username email role user_group expired_at note
2
+ user001 user001@example.jp Administrator test
3
+ user002 User 2013-12-01
4
+ user003 user003@example.jp Librarian テストユーザ
@@ -0,0 +1,27 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ user_id: 1
5
+ note: MyText
6
+ executed_at: 2014-01-10 21:22:16
7
+ state: pending
8
+ user_import_file_name: MyString
9
+ user_import_content_type: text/csv
10
+ user_import_file_size: 1
11
+ user_import_updated_at: 2014-01-10 21:22:16
12
+ user_import_fingerprint: MyString
13
+ edit_mode: MyString
14
+ error_message: MyText
15
+
16
+ two:
17
+ user_id: 1
18
+ note: MyText
19
+ executed_at: 2014-01-10 21:22:16
20
+ state: pending
21
+ user_import_file_name: MyString
22
+ user_import_content_type: text/csv
23
+ user_import_file_size: 1
24
+ user_import_updated_at: 2014-01-10 21:22:16
25
+ user_import_fingerprint: MyString
26
+ edit_mode: MyString
27
+ error_message: MyText
@@ -0,0 +1,13 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ id: 1
5
+ user_import_file_id: 1
6
+ user_id: 1
7
+ body: MyText
8
+
9
+ two:
10
+ id: 2
11
+ user_import_file_id: 1
12
+ user_id: 2
13
+ body: MyText
@@ -0,0 +1,64 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe UserImportFile do
5
+ fixtures :all
6
+
7
+ describe "when its mode is 'create'" do
8
+ before(:each) do
9
+ @file = UserImportFile.new :user_import => File.new("#{Rails.root.to_s}/../../examples/user_import_file_sample.tsv")
10
+ @file.user = users(:admin)
11
+ @file.save
12
+ end
13
+
14
+ it "should be imported" do
15
+ old_users_count = User.count
16
+ old_import_results_count = UserImportResult.count
17
+ @file.state.should eq 'pending'
18
+ @file.import_start.should eq({:user_imported => 3, :user_found => 0, :failed => 0})
19
+ User.order('id DESC')[1].username.should eq 'user002'
20
+ User.order('id DESC')[2].username.should eq 'user001'
21
+ User.count.should eq old_users_count + 3
22
+
23
+ user002 = User.where(:username => 'user002').first
24
+ user002.user_number.should eq '001002'
25
+ user002.user_group.name.should eq 'faculty'
26
+ user002.expired_at.to_i.should eq Time.zone.parse('2013-12-01').end_of_day.to_i
27
+ user002.valid_password?('4NsxXPLy')
28
+
29
+ user003 = User.where(:username => 'user003').first
30
+ user002.user_number.should eq '001002'
31
+ user003.note.should eq 'テストユーザ'
32
+ user003.role.name.should eq 'Librarian'
33
+ user003.user_number.should eq '001003'
34
+ User.where(:username => 'user000').first.should be_nil
35
+ UserImportResult.count.should eq old_import_results_count + 4
36
+
37
+ @file.user_import_fingerprint.should be_true
38
+ @file.executed_at.should be_true
39
+ end
40
+ end
41
+
42
+ describe "when its mode is 'update'" do
43
+ it "should update users" do
44
+ @file = UserImportFile.create :user_import => File.new("#{Rails.root.to_s}/../../examples/user_update_file.tsv")
45
+ @file.modify
46
+ end
47
+ end
48
+
49
+ describe "when its mode is 'destroy'" do
50
+ before(:each) do
51
+ @file = UserImportFile.new :user_import => File.new("#{Rails.root.to_s}/../../examples/user_import_file_sample.tsv")
52
+ @file.user = users(:admin)
53
+ @file.save
54
+ @file.import_start
55
+ end
56
+
57
+ it "should remove users" do
58
+ old_count = User.count
59
+ @file = UserImportFile.create :user_import => File.new("#{Rails.root.to_s}/../../examples/user_delete_file.tsv")
60
+ @file.remove
61
+ User.count.should eq old_count - 3
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,7 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe UserImportResult do
5
+ #pending "add some examples to (or delete) #{__FILE__}"
6
+
7
+ end
@@ -1,7 +1,7 @@
1
1
  /*!
2
- Colorbox v1.4.33 - 2013-10-31
2
+ Colorbox v1.5.4 - 2014-03-07
3
3
  jQuery lightbox and modal window plugin
4
- (c) 2013 Jack Moore - http://www.jacklmoore.com/colorbox
4
+ (c) 2014 Jack Moore - http://www.jacklmoore.com/colorbox
5
5
  license: http://www.opensource.org/licenses/mit-license.php
6
6
  */
7
7
  (function ($, document, window) {
@@ -29,9 +29,6 @@
29
29
  maxHeight: false,
30
30
  scalePhotos: true,
31
31
  scrolling: true,
32
- href: false,
33
- title: false,
34
- rel: false,
35
32
  opacity: 0.9,
36
33
  preloading: true,
37
34
  className: false,
@@ -54,7 +51,7 @@
54
51
  slideshowSpeed: 2500,
55
52
  slideshowStart: "start slideshow",
56
53
  slideshowStop: "stop slideshow",
57
- photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp)((#|\?).*)?$/i,
54
+ photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i,
58
55
 
59
56
  // alternate image paths for high-res displays
60
57
  retinaImage: false,
@@ -78,9 +75,21 @@
78
75
  onLoad: false,
79
76
  onComplete: false,
80
77
  onCleanup: false,
81
- onClosed: false
78
+ onClosed: false,
79
+
80
+ rel: function() {
81
+ return this.rel;
82
+ },
83
+ href: function() {
84
+ // Using .attr() so that the href can also be used to provide a selector for inline content
85
+ return $(this).attr('href');
86
+ },
87
+ title: function() {
88
+ return this.title;
89
+ }
82
90
  },
83
-
91
+
92
+
84
93
  // Abstracting the HTML and event identifiers for easy rebranding
85
94
  colorbox = 'colorbox',
86
95
  prefix = 'cbox',
@@ -115,7 +124,7 @@
115
124
  $prev,
116
125
  $close,
117
126
  $groupControls,
118
- $events = $('<a/>'), // $([]) would be prefered, but there is an issue with jQuery 1.4.2
127
+ $events = $('<a/>'), // $({}) would be prefered, but there is an issue with jQuery 1.4.2
119
128
 
120
129
  // Variables for cached values or use across multiple functions
121
130
  settings,
@@ -123,7 +132,6 @@
123
132
  interfaceWidth,
124
133
  loadedHeight,
125
134
  loadedWidth,
126
- element,
127
135
  index,
128
136
  photo,
129
137
  open,
@@ -132,7 +140,6 @@
132
140
  loadingTimer,
133
141
  publicMethod,
134
142
  div = "div",
135
- className,
136
143
  requests = 0,
137
144
  previousCSS = {},
138
145
  init;
@@ -162,6 +169,38 @@
162
169
  return window.innerHeight ? window.innerHeight : $(window).height();
163
170
  }
164
171
 
172
+ function Settings(element, options) {
173
+ if (options !== Object(options)) {
174
+ options = {};
175
+ }
176
+
177
+ this.cache = {};
178
+ this.el = element;
179
+
180
+ this.value = function(key) {
181
+ var dataAttr;
182
+
183
+ if (this.cache[key] === undefined) {
184
+ dataAttr = $(this.el).attr('data-cbox-'+key);
185
+
186
+ if (dataAttr !== undefined) {
187
+ this.cache[key] = dataAttr;
188
+ } else if (options[key] !== undefined) {
189
+ this.cache[key] = options[key];
190
+ } else if (defaults[key] !== undefined) {
191
+ this.cache[key] = defaults[key];
192
+ }
193
+ }
194
+
195
+ return this.cache[key];
196
+ };
197
+
198
+ this.get = function(key) {
199
+ var value = this.value(key);
200
+ return $.isFunction(value) ? value.call(this.el, this) : value;
201
+ };
202
+ }
203
+
165
204
  // Determine the next and previous members in a group.
166
205
  function getIndex(increment) {
167
206
  var
@@ -179,62 +218,55 @@
179
218
  // Checks an href to see if it is a photo.
180
219
  // There is a force photo option (photo: true) for hrefs that cannot be matched by the regex.
181
220
  function isImage(settings, url) {
182
- return settings.photo || settings.photoRegex.test(url);
221
+ return settings.get('photo') || settings.get('photoRegex').test(url);
183
222
  }
184
223
 
185
224
  function retinaUrl(settings, url) {
186
- return settings.retinaUrl && window.devicePixelRatio > 1 ? url.replace(settings.photoRegex, settings.retinaSuffix) : url;
225
+ return settings.get('retinaUrl') && window.devicePixelRatio > 1 ? url.replace(settings.get('photoRegex'), settings.get('retinaSuffix')) : url;
187
226
  }
188
227
 
189
228
  function trapFocus(e) {
190
- if ('contains' in $box[0] && !$box[0].contains(e.target)) {
229
+ if ('contains' in $box[0] && !$box[0].contains(e.target) && e.target !== $overlay[0]) {
191
230
  e.stopPropagation();
192
231
  $box.focus();
193
232
  }
194
233
  }
195
234
 
196
- // Assigns function results to their respective properties
197
- function makeSettings() {
198
- var i,
199
- data = $.data(element, colorbox);
200
-
201
- if (data == null) {
202
- settings = $.extend({}, defaults);
203
- if (console && console.log) {
204
- console.log('Error: cboxElement missing settings object');
205
- }
206
- } else {
207
- settings = $.extend({}, data);
235
+ function setClass(str) {
236
+ if (setClass.str !== str) {
237
+ $box.add($overlay).removeClass(setClass.str).addClass(str);
238
+ setClass.str = str;
208
239
  }
240
+ }
241
+
242
+ function getRelated() {
243
+ index = 0;
209
244
 
210
- for (i in settings) {
211
- if ($.isFunction(settings[i]) && i.slice(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time.
212
- settings[i] = settings[i].call(element);
245
+ if (rel && rel !== 'nofollow') {
246
+ $related = $('.' + boxElement).filter(function () {
247
+ var options = $.data(this, colorbox);
248
+ var settings = new Settings(this, options);
249
+ return (settings.get('rel') === rel);
250
+ });
251
+ index = $related.index(settings.el);
252
+
253
+ // Check direct calls to Colorbox.
254
+ if (index === -1) {
255
+ $related = $related.add(settings.el);
256
+ index = $related.length - 1;
213
257
  }
214
- }
215
-
216
- settings.rel = settings.rel || element.rel || $(element).data('rel') || 'nofollow';
217
- settings.href = settings.href || $(element).attr('href');
218
- settings.title = settings.title || element.title;
219
-
220
- if (typeof settings.href === "string") {
221
- settings.href = $.trim(settings.href);
258
+ } else {
259
+ $related = $(settings.el);
222
260
  }
223
261
  }
224
262
 
225
- function trigger(event, callback) {
263
+ function trigger(event) {
226
264
  // for external use
227
265
  $(document).trigger(event);
228
-
229
266
  // for internal use
230
267
  $events.triggerHandler(event);
231
-
232
- if ($.isFunction(callback)) {
233
- callback.call(element);
234
- }
235
268
  }
236
269
 
237
-
238
270
  var slideshow = (function(){
239
271
  var active,
240
272
  className = prefix + "Slideshow_",
@@ -246,15 +278,15 @@
246
278
  }
247
279
 
248
280
  function set() {
249
- if (settings.loop || $related[index + 1]) {
281
+ if (settings.get('loop') || $related[index + 1]) {
250
282
  clear();
251
- timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
283
+ timeOut = setTimeout(publicMethod.next, settings.get('slideshowSpeed'));
252
284
  }
253
285
  }
254
286
 
255
287
  function start() {
256
288
  $slideshow
257
- .html(settings.slideshowStop)
289
+ .html(settings.get('slideshowStop'))
258
290
  .unbind(click)
259
291
  .one(click, stop);
260
292
 
@@ -273,7 +305,7 @@
273
305
  .unbind(event_load, clear);
274
306
 
275
307
  $slideshow
276
- .html(settings.slideshowStart)
308
+ .html(settings.get('slideshowStart'))
277
309
  .unbind(click)
278
310
  .one(click, function () {
279
311
  publicMethod.next();
@@ -295,15 +327,15 @@
295
327
 
296
328
  return function(){
297
329
  if (active) {
298
- if (!settings.slideshow) {
330
+ if (!settings.get('slideshow')) {
299
331
  $events.unbind(event_cleanup, reset);
300
332
  reset();
301
333
  }
302
334
  } else {
303
- if (settings.slideshow && $related[1]) {
335
+ if (settings.get('slideshow') && $related[1]) {
304
336
  active = true;
305
337
  $events.one(event_cleanup, reset);
306
- if (settings.slideshowAuto) {
338
+ if (settings.get('slideshowAuto')) {
307
339
  start();
308
340
  } else {
309
341
  stop();
@@ -316,65 +348,28 @@
316
348
  }());
317
349
 
318
350
 
319
- function launch(target) {
351
+ function launch(element) {
352
+ var options;
353
+
320
354
  if (!closing) {
321
-
322
- element = target;
323
-
324
- makeSettings();
325
-
326
- $related = $(element);
327
-
328
- index = 0;
329
-
330
- if (settings.rel !== 'nofollow') {
331
- $related = $('.' + boxElement).filter(function () {
332
- var data = $.data(this, colorbox),
333
- relRelated;
334
355
 
335
- if (data) {
336
- relRelated = $(this).data('rel') || data.rel || this.rel;
337
- }
338
-
339
- return (relRelated === settings.rel);
340
- });
341
- index = $related.index(element);
342
-
343
- // Check direct calls to Colorbox.
344
- if (index === -1) {
345
- $related = $related.add(element);
346
- index = $related.length - 1;
347
- }
348
- }
349
-
350
- $overlay.css({
351
- opacity: parseFloat(settings.opacity),
352
- cursor: settings.overlayClose ? "pointer" : "auto",
353
- visibility: 'visible'
354
- }).show();
355
-
356
+ options = $(element).data('colorbox');
356
357
 
357
- if (className) {
358
- $box.add($overlay).removeClass(className);
359
- }
360
- if (settings.className) {
361
- $box.add($overlay).addClass(settings.className);
362
- }
363
- className = settings.className;
358
+ settings = new Settings(element, options);
364
359
 
365
- if (settings.closeButton) {
366
- $close.html(settings.close).appendTo($content);
367
- } else {
368
- $close.appendTo('<div/>');
369
- }
360
+ rel = settings.get('rel');
361
+
362
+ getRelated();
370
363
 
371
364
  if (!open) {
372
365
  open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
366
+
367
+ setClass(settings.get('className'));
373
368
 
374
369
  // Show colorbox so the sizes can be calculated in older versions of jQuery
375
370
  $box.css({visibility:'hidden', display:'block'});
376
371
 
377
- $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden');
372
+ $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden; visibility:hidden');
378
373
  $content.css({width:'', height:''}).append($loaded);
379
374
 
380
375
  // Cache values needed for size calculations
@@ -384,18 +379,19 @@
384
379
  loadedWidth = $loaded.outerWidth(true);
385
380
 
386
381
  // Opens inital empty Colorbox prior to content being loaded.
387
- settings.w = setSize(settings.initialWidth, 'x');
388
- settings.h = setSize(settings.initialHeight, 'y');
382
+ settings.w = setSize(settings.get('initialWidth'), 'x');
383
+ settings.h = setSize(settings.get('initialHeight'), 'y');
389
384
  $loaded.css({width:'', height:settings.h});
390
385
  publicMethod.position();
391
386
 
392
- trigger(event_open, settings.onOpen);
393
-
387
+ trigger(event_open);
388
+ settings.get('onOpen');
389
+
394
390
  $groupControls.add($title).hide();
395
391
 
396
392
  $box.focus();
397
393
 
398
- if (settings.trapFocus) {
394
+ if (settings.get('trapFocus')) {
399
395
  // Confine focus to the modal
400
396
  // Uses event capturing that is not supported in IE8-
401
397
  if (document.addEventListener) {
@@ -409,12 +405,25 @@
409
405
  }
410
406
 
411
407
  // Return focus on closing
412
- if (settings.returnFocus) {
408
+ if (settings.get('returnFocus')) {
413
409
  $events.one(event_closed, function () {
414
- $(element).focus();
410
+ $(settings.el).focus();
415
411
  });
416
412
  }
417
413
  }
414
+
415
+ $overlay.css({
416
+ opacity: parseFloat(settings.get('opacity')),
417
+ cursor: settings.get('overlayClose') ? "pointer" : "auto",
418
+ visibility: 'visible'
419
+ }).show();
420
+
421
+ if (settings.get('closeButton')) {
422
+ $close.html(settings.get('close')).appendTo($content);
423
+ } else {
424
+ $close.appendTo('<div/>'); // replace with .detach() when dropping jQuery < 1.4
425
+ }
426
+
418
427
  load();
419
428
  }
420
429
  }
@@ -497,7 +506,7 @@
497
506
  publicMethod.close();
498
507
  });
499
508
  $overlay.click(function () {
500
- if (settings.overlayClose) {
509
+ if (settings.get('overlayClose')) {
501
510
  publicMethod.close();
502
511
  }
503
512
  });
@@ -505,11 +514,11 @@
505
514
  // Key Bindings
506
515
  $(document).bind('keydown.' + prefix, function (e) {
507
516
  var key = e.keyCode;
508
- if (open && settings.escKey && key === 27) {
517
+ if (open && settings.get('escKey') && key === 27) {
509
518
  e.preventDefault();
510
519
  publicMethod.close();
511
520
  }
512
- if (open && settings.arrowKey && $related[1] && !e.altKey) {
521
+ if (open && settings.get('arrowKey') && $related[1] && !e.altKey) {
513
522
  if (key === 37) {
514
523
  e.preventDefault();
515
524
  $prev.click();
@@ -551,34 +560,44 @@
551
560
  // ****************
552
561
 
553
562
  publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
554
- var $this = this;
555
-
563
+ var settings;
564
+ var $obj = this;
565
+
556
566
  options = options || {};
567
+
568
+ if ($.isFunction($obj)) { // assume a call to $.colorbox
569
+ $obj = $('<a/>');
570
+ options.open = true;
571
+ } else if (!$obj[0]) { // colorbox being applied to empty collection
572
+ return $obj;
573
+ }
574
+
575
+
576
+ if (!$obj[0]) { // colorbox being applied to empty collection
577
+ return $obj;
578
+ }
557
579
 
558
580
  appendHTML();
559
581
 
560
582
  if (addBindings()) {
561
- if ($.isFunction($this)) { // assume a call to $.colorbox
562
- $this = $('<a/>');
563
- options.open = true;
564
- } else if (!$this[0]) { // colorbox being applied to empty collection
565
- return $this;
566
- }
567
-
583
+
568
584
  if (callback) {
569
585
  options.onComplete = callback;
570
586
  }
571
-
572
- $this.each(function () {
573
- $.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options));
587
+
588
+ $obj.each(function () {
589
+ var old = $.data(this, colorbox) || {};
590
+ $.data(this, colorbox, $.extend(old, options));
574
591
  }).addClass(boxElement);
592
+
593
+ settings = new Settings($obj[0], options);
575
594
 
576
- if (($.isFunction(options.open) && options.open.call($this)) || options.open) {
577
- launch($this[0]);
595
+ if (settings.get('open')) {
596
+ launch($obj[0]);
578
597
  }
579
598
  }
580
599
 
581
- return $this;
600
+ return $obj;
582
601
  };
583
602
 
584
603
  publicMethod.position = function (speed, loadedCallback) {
@@ -598,7 +617,7 @@
598
617
  scrollTop = $window.scrollTop();
599
618
  scrollLeft = $window.scrollLeft();
600
619
 
601
- if (settings.fixed) {
620
+ if (settings.get('fixed')) {
602
621
  offset.top -= scrollTop;
603
622
  offset.left -= scrollLeft;
604
623
  $box.css({position: 'fixed'});
@@ -609,18 +628,18 @@
609
628
  }
610
629
 
611
630
  // keeps the top and left positions within the browser's viewport.
612
- if (settings.right !== false) {
613
- left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0);
614
- } else if (settings.left !== false) {
615
- left += setSize(settings.left, 'x');
631
+ if (settings.get('right') !== false) {
632
+ left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.get('right'), 'x'), 0);
633
+ } else if (settings.get('left') !== false) {
634
+ left += setSize(settings.get('left'), 'x');
616
635
  } else {
617
636
  left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2);
618
637
  }
619
638
 
620
- if (settings.bottom !== false) {
621
- top += Math.max(winheight() - settings.h - loadedHeight - interfaceHeight - setSize(settings.bottom, 'y'), 0);
622
- } else if (settings.top !== false) {
623
- top += setSize(settings.top, 'y');
639
+ if (settings.get('bottom') !== false) {
640
+ top += Math.max(winheight() - settings.h - loadedHeight - interfaceHeight - setSize(settings.get('bottom'), 'y'), 0);
641
+ } else if (settings.get('top') !== false) {
642
+ top += setSize(settings.get('top'), 'y');
624
643
  } else {
625
644
  top += Math.round(Math.max(winheight() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
626
645
  }
@@ -668,7 +687,7 @@
668
687
  $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
669
688
  $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
670
689
 
671
- if (settings.reposition) {
690
+ if (settings.get('reposition')) {
672
691
  setTimeout(function () { // small delay before binding onresize due to an IE8 bug.
673
692
  $window.bind('resize.' + prefix, publicMethod.position);
674
693
  }, 1);
@@ -718,7 +737,7 @@
718
737
  $loaded.scrollTop(scrolltop);
719
738
  }
720
739
 
721
- publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
740
+ publicMethod.position(settings.get('transition') === "none" ? 0 : settings.get('speed'));
722
741
  }
723
742
  };
724
743
 
@@ -727,9 +746,9 @@
727
746
  return;
728
747
  }
729
748
 
730
- var callback, speed = settings.transition === "none" ? 0 : settings.speed;
749
+ var callback, speed = settings.get('transition') === "none" ? 0 : settings.get('speed');
731
750
 
732
- $loaded.empty().remove(); // Using empty first may prevent some IE7 issues.
751
+ $loaded.remove();
733
752
 
734
753
  $loaded = $tag(div, 'LoadedContent').append(object);
735
754
 
@@ -746,7 +765,7 @@
746
765
 
747
766
  $loaded.hide()
748
767
  .appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
749
- .css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
768
+ .css({width: getWidth(), overflow: settings.get('scrolling') ? 'auto' : 'hidden'})
750
769
  .css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
751
770
  .prependTo($content);
752
771
 
@@ -756,18 +775,18 @@
756
775
 
757
776
  $(photo).css({'float': 'none'});
758
777
 
778
+ setClass(settings.get('className'));
779
+
759
780
  callback = function () {
760
781
  var total = $related.length,
761
782
  iframe,
762
- frameBorder = 'frameBorder',
763
- allowTransparency = 'allowTransparency',
764
783
  complete;
765
784
 
766
785
  if (!open) {
767
786
  return;
768
787
  }
769
788
 
770
- function removeFilter() { // Needed for IE7 & IE8 in versions of jQuery prior to 1.7.2
789
+ function removeFilter() { // Needed for IE8 in versions of jQuery prior to 1.7.2
771
790
  if ($.support.opacity === false) {
772
791
  $box[0].style.removeAttribute('filter');
773
792
  }
@@ -776,41 +795,34 @@
776
795
  complete = function () {
777
796
  clearTimeout(loadingTimer);
778
797
  $loadingOverlay.hide();
779
- trigger(event_complete, settings.onComplete);
798
+ trigger(event_complete);
799
+ settings.get('onComplete');
780
800
  };
781
801
 
782
802
 
783
- $title.html(settings.title).add($loaded).show();
803
+ $title.html(settings.get('title')).show();
804
+ $loaded.show();
784
805
 
785
806
  if (total > 1) { // handle grouping
786
- if (typeof settings.current === "string") {
787
- $current.html(settings.current.replace('{current}', index + 1).replace('{total}', total)).show();
807
+ if (typeof settings.get('current') === "string") {
808
+ $current.html(settings.get('current').replace('{current}', index + 1).replace('{total}', total)).show();
788
809
  }
789
810
 
790
- $next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
791
- $prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous);
811
+ $next[(settings.get('loop') || index < total - 1) ? "show" : "hide"]().html(settings.get('next'));
812
+ $prev[(settings.get('loop') || index) ? "show" : "hide"]().html(settings.get('previous'));
792
813
 
793
814
  slideshow();
794
815
 
795
816
  // Preloads images within a rel group
796
- if (settings.preloading) {
817
+ if (settings.get('preloading')) {
797
818
  $.each([getIndex(-1), getIndex(1)], function(){
798
- var src,
799
- img,
819
+ var img,
800
820
  i = $related[this],
801
- data = $.data(i, colorbox);
802
-
803
- if (data && data.href) {
804
- src = data.href;
805
- if ($.isFunction(src)) {
806
- src = src.call(i);
807
- }
808
- } else {
809
- src = $(i).attr('href');
810
- }
821
+ settings = new Settings(i, $.data(i, colorbox)),
822
+ src = settings.get('href');
811
823
 
812
- if (src && isImage(data, src)) {
813
- src = retinaUrl(data, src);
824
+ if (src && isImage(settings, src)) {
825
+ src = retinaUrl(settings, src);
814
826
  img = document.createElement('img');
815
827
  img.src = src;
816
828
  }
@@ -820,29 +832,27 @@
820
832
  $groupControls.hide();
821
833
  }
822
834
 
823
- if (settings.iframe) {
824
- iframe = $tag('iframe')[0];
835
+ if (settings.get('iframe')) {
836
+ iframe = document.createElement('iframe');
825
837
 
826
- if (frameBorder in iframe) {
827
- iframe[frameBorder] = 0;
838
+ if ('frameBorder' in iframe) {
839
+ iframe.frameBorder = 0;
828
840
  }
829
841
 
830
- if (allowTransparency in iframe) {
831
- iframe[allowTransparency] = "true";
842
+ if ('allowTransparency' in iframe) {
843
+ iframe.allowTransparency = "true";
832
844
  }
833
845
 
834
- if (!settings.scrolling) {
846
+ if (!settings.get('scrolling')) {
835
847
  iframe.scrolling = "no";
836
848
  }
837
849
 
838
850
  $(iframe)
839
851
  .attr({
840
- src: settings.href,
852
+ src: settings.get('href'),
841
853
  name: (new Date()).getTime(), // give the iframe a unique name to prevent caching
842
854
  'class': prefix + 'Iframe',
843
- allowFullScreen : true, // allow HTML5 video to go fullscreen
844
- webkitAllowFullScreen : true,
845
- mozallowfullscreen : true
855
+ allowFullScreen : true // allow HTML5 video to go fullscreen
846
856
  })
847
857
  .one('load', complete)
848
858
  .appendTo($loaded);
@@ -851,21 +861,21 @@
851
861
  iframe.src = "//about:blank";
852
862
  });
853
863
 
854
- if (settings.fastIframe) {
864
+ if (settings.get('fastIframe')) {
855
865
  $(iframe).trigger('load');
856
866
  }
857
867
  } else {
858
868
  complete();
859
869
  }
860
870
 
861
- if (settings.transition === 'fade') {
871
+ if (settings.get('transition') === 'fade') {
862
872
  $box.fadeTo(speed, 1, removeFilter);
863
873
  } else {
864
874
  removeFilter();
865
875
  }
866
876
  };
867
877
 
868
- if (settings.transition === 'fade') {
878
+ if (settings.get('transition') === 'fade') {
869
879
  $box.fadeTo(speed, 0, function () {
870
880
  publicMethod.position(0, callback);
871
881
  });
@@ -881,21 +891,17 @@
881
891
 
882
892
  photo = false;
883
893
 
884
- element = $related[index];
885
-
886
- makeSettings();
887
-
888
894
  trigger(event_purge);
895
+ trigger(event_load);
896
+ settings.get('onLoad');
889
897
 
890
- trigger(event_load, settings.onLoad);
898
+ settings.h = settings.get('height') ?
899
+ setSize(settings.get('height'), 'y') - loadedHeight - interfaceHeight :
900
+ settings.get('innerHeight') && setSize(settings.get('innerHeight'), 'y');
891
901
 
892
- settings.h = settings.height ?
893
- setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
894
- settings.innerHeight && setSize(settings.innerHeight, 'y');
895
-
896
- settings.w = settings.width ?
897
- setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
898
- settings.innerWidth && setSize(settings.innerWidth, 'x');
902
+ settings.w = settings.get('width') ?
903
+ setSize(settings.get('width'), 'x') - loadedWidth - interfaceWidth :
904
+ settings.get('innerWidth') && setSize(settings.get('innerWidth'), 'x');
899
905
 
900
906
  // Sets the minimum dimensions for use in image scaling
901
907
  settings.mw = settings.w;
@@ -903,22 +909,22 @@
903
909
 
904
910
  // Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
905
911
  // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
906
- if (settings.maxWidth) {
907
- settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
912
+ if (settings.get('maxWidth')) {
913
+ settings.mw = setSize(settings.get('maxWidth'), 'x') - loadedWidth - interfaceWidth;
908
914
  settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
909
915
  }
910
- if (settings.maxHeight) {
911
- settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
916
+ if (settings.get('maxHeight')) {
917
+ settings.mh = setSize(settings.get('maxHeight'), 'y') - loadedHeight - interfaceHeight;
912
918
  settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
913
919
  }
914
920
 
915
- href = settings.href;
921
+ href = settings.get('href');
916
922
 
917
923
  loadingTimer = setTimeout(function () {
918
924
  $loadingOverlay.show();
919
925
  }, 100);
920
926
 
921
- if (settings.inline) {
927
+ if (settings.get('inline')) {
922
928
  // Inserts an empty placeholder where inline content is being pulled from.
923
929
  // An event is bound to put inline content back when Colorbox closes or loads new content.
924
930
  $inline = $tag(div).hide().insertBefore($(href)[0]);
@@ -928,12 +934,12 @@
928
934
  });
929
935
 
930
936
  prep($(href));
931
- } else if (settings.iframe) {
937
+ } else if (settings.get('iframe')) {
932
938
  // IFrame element won't be added to the DOM until it is ready to be displayed,
933
939
  // to avoid problems with DOM-ready JS that might be trying to run in that iframe.
934
940
  prep(" ");
935
- } else if (settings.html) {
936
- prep(settings.html);
941
+ } else if (settings.get('html')) {
942
+ prep(settings.get('html'));
937
943
  } else if (isImage(settings, href)) {
938
944
 
939
945
  href = retinaUrl(settings, href);
@@ -943,8 +949,7 @@
943
949
  $(photo)
944
950
  .addClass(prefix + 'Photo')
945
951
  .bind('error',function () {
946
- settings.title = false;
947
- prep($tag(div, 'Error').html(settings.imgError));
952
+ prep($tag(div, 'Error').html(settings.get('imgError')));
948
953
  })
949
954
  .one('load', function () {
950
955
  var percent;
@@ -954,18 +959,18 @@
954
959
  }
955
960
 
956
961
  $.each(['alt', 'longdesc', 'aria-describedby'], function(i,val){
957
- var attr = $(element).attr(val) || $(element).attr('data-'+val);
962
+ var attr = $(settings.el).attr(val) || $(settings.el).attr('data-'+val);
958
963
  if (attr) {
959
964
  photo.setAttribute(val, attr);
960
965
  }
961
966
  });
962
967
 
963
- if (settings.retinaImage && window.devicePixelRatio > 1) {
968
+ if (settings.get('retinaImage') && window.devicePixelRatio > 1) {
964
969
  photo.height = photo.height / window.devicePixelRatio;
965
970
  photo.width = photo.width / window.devicePixelRatio;
966
971
  }
967
972
 
968
- if (settings.scalePhotos) {
973
+ if (settings.get('scalePhotos')) {
969
974
  setResize = function () {
970
975
  photo.height -= photo.height * percent;
971
976
  photo.width -= photo.width * percent;
@@ -984,7 +989,7 @@
984
989
  photo.style.marginTop = Math.max(settings.mh - photo.height, 0) / 2 + 'px';
985
990
  }
986
991
 
987
- if ($related[1] && (settings.loop || $related[index + 1])) {
992
+ if ($related[1] && (settings.get('loop') || $related[index + 1])) {
988
993
  photo.style.cursor = 'pointer';
989
994
  photo.onclick = function () {
990
995
  publicMethod.next();
@@ -1003,9 +1008,9 @@
1003
1008
  photo.src = href;
1004
1009
  }, 1);
1005
1010
  } else if (href) {
1006
- $loadingBay.load(href, settings.data, function (data, status) {
1011
+ $loadingBay.load(href, settings.get('data'), function (data, status) {
1007
1012
  if (request === requests) {
1008
- prep(status === 'error' ? $tag(div, 'Error').html(settings.xhrError) : $(this).contents());
1013
+ prep(status === 'error' ? $tag(div, 'Error').html(settings.get('xhrError')) : $(this).contents());
1009
1014
  }
1010
1015
  });
1011
1016
  }
@@ -1013,14 +1018,14 @@
1013
1018
 
1014
1019
  // Navigates to the next page/image in a set.
1015
1020
  publicMethod.next = function () {
1016
- if (!active && $related[1] && (settings.loop || $related[index + 1])) {
1021
+ if (!active && $related[1] && (settings.get('loop') || $related[index + 1])) {
1017
1022
  index = getIndex(1);
1018
1023
  launch($related[index]);
1019
1024
  }
1020
1025
  };
1021
1026
 
1022
1027
  publicMethod.prev = function () {
1023
- if (!active && $related[1] && (settings.loop || index)) {
1028
+ if (!active && $related[1] && (settings.get('loop') || index)) {
1024
1029
  index = getIndex(-1);
1025
1030
  launch($related[index]);
1026
1031
  }
@@ -1034,23 +1039,25 @@
1034
1039
 
1035
1040
  open = false;
1036
1041
 
1037
- trigger(event_cleanup, settings.onCleanup);
1042
+ trigger(event_cleanup);
1043
+ settings.get('onCleanup');
1038
1044
 
1039
1045
  $window.unbind('.' + prefix);
1040
1046
 
1041
- $overlay.fadeTo(settings.fadeOut || 0, 0);
1047
+ $overlay.fadeTo(settings.get('fadeOut') || 0, 0);
1042
1048
 
1043
- $box.stop().fadeTo(settings.fadeOut || 0, 0, function () {
1049
+ $box.stop().fadeTo(settings.get('fadeOut') || 0, 0, function () {
1044
1050
 
1045
1051
  $box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
1046
1052
 
1047
1053
  trigger(event_purge);
1048
1054
 
1049
- $loaded.empty().remove(); // Using empty first may prevent some IE7 issues.
1055
+ $loaded.remove();
1050
1056
 
1051
1057
  setTimeout(function () {
1052
1058
  closing = false;
1053
- trigger(event_closed, settings.onClosed);
1059
+ trigger(event_closed);
1060
+ settings.get('onClosed');
1054
1061
  }, 1);
1055
1062
  });
1056
1063
  }
@@ -1076,7 +1083,7 @@
1076
1083
  // A method for fetching the current element Colorbox is referencing.
1077
1084
  // returns a jQuery object.
1078
1085
  publicMethod.element = function () {
1079
- return $(element);
1086
+ return $(settings.el);
1080
1087
  };
1081
1088
 
1082
1089
  publicMethod.settings = defaults;