zfben_rails_assets 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -4
- data/Gemfile +11 -1
- data/README.rdoc +0 -8
- data/Rakefile +13 -0
- data/app/controllers/assets_controller.rb +32 -0
- data/app/helpers/assets_helper.rb +64 -0
- data/app/models/asset_format.rb +103 -0
- data/app/models/asset_format/css.rb +19 -0
- data/app/models/asset_format/js.rb +13 -0
- data/config/routes.rb +10 -0
- data/lib/{zfben_rails_assets/tasks.rb → tasks/tasks.rake} +0 -0
- data/lib/zfben_rails_assets.rb +3 -9
- data/test/assets_test.rb +145 -0
- data/{example → test/dummy}/Rakefile +2 -2
- data/test/dummy/app/assets/blank.css +1 -0
- data/test/dummy/app/assets/blank.js +1 -0
- data/test/dummy/app/assets/coffee.coffee +1 -0
- data/test/dummy/app/assets/import.css +1 -0
- data/test/dummy/app/assets/import.js +1 -0
- data/test/dummy/app/assets/import_404.css +1 -0
- data/test/dummy/app/assets/import_404.js +1 -0
- data/test/dummy/app/assets/import_iteration.css +1 -0
- data/test/dummy/app/assets/import_iteration.js +1 -0
- data/test/dummy/app/assets/import_twice.css +2 -0
- data/test/dummy/app/assets/import_twice.js +2 -0
- data/test/dummy/app/assets/sass.sass +2 -0
- data/test/dummy/app/assets/scss.scss +3 -0
- data/{example → test/dummy}/app/controllers/application_controller.rb +0 -0
- data/{example → test/dummy}/app/helpers/application_helper.rb +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/{example → test/dummy}/config.ru +1 -1
- data/test/dummy/config/application.rb +20 -0
- data/test/dummy/config/boot.rb +10 -0
- data/{example → test/dummy}/config/database.yml +0 -3
- data/{example → test/dummy}/config/environment.rb +1 -1
- data/{example → test/dummy}/config/environments/development.rb +4 -5
- data/{example → test/dummy}/config/environments/production.rb +13 -16
- data/{example → test/dummy}/config/environments/test.rb +2 -16
- data/{example → test/dummy}/config/initializers/backtrace_silencers.rb +0 -0
- data/{example → test/dummy}/config/initializers/inflections.rb +0 -0
- data/{example → test/dummy}/config/initializers/mime_types.rb +0 -0
- data/{example → test/dummy}/config/initializers/secret_token.rb +1 -1
- data/{example → test/dummy}/config/initializers/session_store.rb +2 -2
- data/{example → test/dummy}/config/locales/en.yml +1 -1
- data/test/dummy/config/routes.rb +58 -0
- data/{example → test/dummy}/public/404.html +0 -0
- data/{example → test/dummy}/public/422.html +0 -0
- data/{example → test/dummy}/public/500.html +0 -0
- data/{example → test/dummy}/public/favicon.ico +0 -0
- data/test/dummy/public/javascripts/application.js +2 -0
- data/test/dummy/public/javascripts/controls.js +965 -0
- data/test/dummy/public/javascripts/dragdrop.js +974 -0
- data/test/dummy/public/javascripts/effects.js +1123 -0
- data/test/dummy/public/javascripts/prototype.js +6001 -0
- data/test/dummy/public/javascripts/rails.js +202 -0
- data/{example/app/mailers → test/dummy/public/stylesheets}/.gitkeep +0 -0
- data/{example → test/dummy}/script/rails +0 -0
- data/test/dummy/tmp/assets/blank.css +1 -0
- data/test/dummy/tmp/assets/blank.js +1 -0
- data/test/dummy/tmp/assets/coffee.js +2 -0
- data/test/dummy/tmp/assets/import.css +4 -0
- data/test/dummy/tmp/assets/import.js +4 -0
- data/{example/app/models/.gitkeep → test/dummy/tmp/assets/import_404.css} +0 -0
- data/{example/db/development.sqlite3 → test/dummy/tmp/assets/import_404.js} +0 -0
- data/test/dummy/tmp/assets/import_iteration.css +11 -0
- data/test/dummy/tmp/assets/import_iteration.js +11 -0
- data/{example/lib/tasks/.gitkeep → test/dummy/tmp/assets/import_iteration.min.css} +0 -0
- data/{example/test/fixtures/.gitkeep → test/dummy/tmp/assets/import_iteration.min.js} +0 -0
- data/test/dummy/tmp/assets/import_twice.css +8 -0
- data/test/dummy/tmp/assets/import_twice.js +8 -0
- data/test/dummy/tmp/assets/sass.css +3 -0
- data/test/dummy/tmp/assets/scss.css +3 -0
- data/test/dummy/tmp/assets/simple.sass +3 -0
- data/test/test_helper.rb +10 -0
- data/zfben_rails_assets.gemspec +14 -4
- metadata +136 -133
- data/example/.gitignore +0 -7
- data/example/.sass-cache/686d48c4bb3405df08bdcc662a0722bb96d63df5/test.sassc +0 -0
- data/example/.sass-cache/7a5615116aa96cc45242210dec5b677975f46879/reset.sassc +0 -0
- data/example/Gemfile +0 -8
- data/example/README +0 -261
- data/example/app/assets/images/rails.png +0 -0
- data/example/app/assets/javascripts/application.js +0 -9
- data/example/app/assets/javascripts/test.js +0 -1
- data/example/app/assets/stylesheets/application.css +0 -7
- data/example/app/assets/stylesheets/test.css +0 -1
- data/example/app/controllers/test_controller.rb +0 -7
- data/example/app/views/test/index.haml +0 -12
- data/example/config/application.rb +0 -49
- data/example/config/boot.rb +0 -6
- data/example/config/initializers/wrap_parameters.rb +0 -12
- data/example/config/routes.rb +0 -3
- data/example/db/seeds.rb +0 -7
- data/example/doc/README_FOR_APP +0 -2
- data/example/public/robots.txt +0 -5
- data/example/test/functional/.gitkeep +0 -0
- data/example/test/integration/.gitkeep +0 -0
- data/example/test/performance/browsing_test.rb +0 -12
- data/example/test/test_helper.rb +0 -13
- data/example/test/unit/.gitkeep +0 -0
- data/example/vendor/assets/javascripts/zff.js +0 -0
- data/example/vendor/assets/javascripts/zff/core.js +0 -1
- data/example/vendor/assets/javascripts/zff/core/core.js +0 -57
- data/example/vendor/assets/javascripts/zff/lib/jquery/core.js +0 -8936
- data/example/vendor/assets/javascripts/zff/lib/jquery/grid.js +0 -467
- data/example/vendor/assets/javascripts/zff/lib/jquery/ui.js +0 -11631
- data/example/vendor/assets/javascripts/zff/lib/underscore/core.js +0 -807
- data/example/vendor/assets/javascripts/zff/spec.js +0 -2
- data/example/vendor/assets/javascripts/zff/spec/core.js +0 -38
- data/example/vendor/assets/javascripts/zff/spec/qunit.js +0 -1448
- data/example/vendor/assets/stylesheets/zff/lib/qunit.css +0 -225
- data/example/vendor/assets/stylesheets/zff/reset.sass +0 -1
- data/example/vendor/assets/stylesheets/zff/spec.css +0 -1
- data/example/vendor/plugins/.gitkeep +0 -0
- data/lib/zfben_rails_assets/Gemfile +0 -13
- data/lib/zfben_rails_assets/assets/javascripts/zff/core.js +0 -1
- data/lib/zfben_rails_assets/assets/javascripts/zff/core/0_config.js +0 -5
- data/lib/zfben_rails_assets/assets/javascripts/zff/core/1_jquery.js +0 -5
- data/lib/zfben_rails_assets/assets/javascripts/zff/core/2_load.js +0 -53
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/colorbox.js +0 -872
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/contextmenu.js +0 -144
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/core.js +0 -8936
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/grid.js +0 -2
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/grid/addons.js +0 -704
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/grid/core.js +0 -10913
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/grid/i18n/cn.js +0 -132
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/grid/i18n/en.js +0 -128
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/grid/postext.js +0 -64
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/grid/setcolumns.js +0 -126
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/qunit.js +0 -1448
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/searchFilter.js +0 -716
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/tablednd.js +0 -383
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/ui.js +0 -11631
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/jquery/ui/multiselect.js +0 -314
- data/lib/zfben_rails_assets/assets/javascripts/zff/lib/underscore/core.js +0 -807
- data/lib/zfben_rails_assets/assets/javascripts/zff/spec.js +0 -3
- data/lib/zfben_rails_assets/assets/javascripts/zff/spec/core.js +0 -38
- data/lib/zfben_rails_assets/assets/stylesheets/zff/lib/jquery/grid/grid.css +0 -140
- data/lib/zfben_rails_assets/assets/stylesheets/zff/lib/jquery/qunit/qunit.css +0 -225
- data/lib/zfben_rails_assets/assets/stylesheets/zff/lib/jquery/ui/multiselect.css +0 -30
- data/lib/zfben_rails_assets/assets/stylesheets/zff/reset.sass +0 -1
- data/lib/zfben_rails_assets/assets/stylesheets/zff/spec.css +0 -1
- data/lib/zfben_rails_assets/version.rb +0 -3
@@ -1,225 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* QUnit - A JavaScript Unit Testing Framework
|
3
|
-
*
|
4
|
-
* http://docs.jquery.com/QUnit
|
5
|
-
*
|
6
|
-
* Copyright (c) 2011 John Resig, Jörn Zaefferer
|
7
|
-
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
8
|
-
* or GPL (GPL-LICENSE.txt) licenses.
|
9
|
-
*/
|
10
|
-
|
11
|
-
/** Font Family and Sizes */
|
12
|
-
|
13
|
-
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
14
|
-
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
|
15
|
-
}
|
16
|
-
|
17
|
-
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
18
|
-
#qunit-tests { font-size: smaller; }
|
19
|
-
|
20
|
-
|
21
|
-
/** Resets */
|
22
|
-
|
23
|
-
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
|
24
|
-
margin: 0;
|
25
|
-
padding: 0;
|
26
|
-
}
|
27
|
-
|
28
|
-
|
29
|
-
/** Header */
|
30
|
-
|
31
|
-
#qunit-header {
|
32
|
-
padding: 0.5em 0 0.5em 1em;
|
33
|
-
|
34
|
-
color: #8699a4;
|
35
|
-
background-color: #0d3349;
|
36
|
-
|
37
|
-
font-size: 1.5em;
|
38
|
-
line-height: 1em;
|
39
|
-
font-weight: normal;
|
40
|
-
|
41
|
-
border-radius: 15px 15px 0 0;
|
42
|
-
-moz-border-radius: 15px 15px 0 0;
|
43
|
-
-webkit-border-top-right-radius: 15px;
|
44
|
-
-webkit-border-top-left-radius: 15px;
|
45
|
-
}
|
46
|
-
|
47
|
-
#qunit-header a {
|
48
|
-
text-decoration: none;
|
49
|
-
color: #c2ccd1;
|
50
|
-
}
|
51
|
-
|
52
|
-
#qunit-header a:hover,
|
53
|
-
#qunit-header a:focus {
|
54
|
-
color: #fff;
|
55
|
-
}
|
56
|
-
|
57
|
-
#qunit-banner {
|
58
|
-
height: 5px;
|
59
|
-
}
|
60
|
-
|
61
|
-
#qunit-testrunner-toolbar {
|
62
|
-
padding: 0.5em 0 0.5em 2em;
|
63
|
-
color: #5E740B;
|
64
|
-
background-color: #eee;
|
65
|
-
}
|
66
|
-
|
67
|
-
#qunit-userAgent {
|
68
|
-
padding: 0.5em 0 0.5em 2.5em;
|
69
|
-
background-color: #2b81af;
|
70
|
-
color: #fff;
|
71
|
-
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
72
|
-
}
|
73
|
-
|
74
|
-
|
75
|
-
/** Tests: Pass/Fail */
|
76
|
-
|
77
|
-
#qunit-tests {
|
78
|
-
list-style-position: inside;
|
79
|
-
}
|
80
|
-
|
81
|
-
#qunit-tests li {
|
82
|
-
padding: 0.4em 0.5em 0.4em 2.5em;
|
83
|
-
border-bottom: 1px solid #fff;
|
84
|
-
list-style-position: inside;
|
85
|
-
}
|
86
|
-
|
87
|
-
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
|
88
|
-
display: none;
|
89
|
-
}
|
90
|
-
|
91
|
-
#qunit-tests li strong {
|
92
|
-
cursor: pointer;
|
93
|
-
}
|
94
|
-
|
95
|
-
#qunit-tests li a {
|
96
|
-
padding: 0.5em;
|
97
|
-
color: #c2ccd1;
|
98
|
-
text-decoration: none;
|
99
|
-
}
|
100
|
-
#qunit-tests li a:hover,
|
101
|
-
#qunit-tests li a:focus {
|
102
|
-
color: #000;
|
103
|
-
}
|
104
|
-
|
105
|
-
#qunit-tests ol {
|
106
|
-
margin-top: 0.5em;
|
107
|
-
padding: 0.5em;
|
108
|
-
|
109
|
-
background-color: #fff;
|
110
|
-
|
111
|
-
border-radius: 15px;
|
112
|
-
-moz-border-radius: 15px;
|
113
|
-
-webkit-border-radius: 15px;
|
114
|
-
|
115
|
-
box-shadow: inset 0px 2px 13px #999;
|
116
|
-
-moz-box-shadow: inset 0px 2px 13px #999;
|
117
|
-
-webkit-box-shadow: inset 0px 2px 13px #999;
|
118
|
-
}
|
119
|
-
|
120
|
-
#qunit-tests table {
|
121
|
-
border-collapse: collapse;
|
122
|
-
margin-top: .2em;
|
123
|
-
}
|
124
|
-
|
125
|
-
#qunit-tests th {
|
126
|
-
text-align: right;
|
127
|
-
vertical-align: top;
|
128
|
-
padding: 0 .5em 0 0;
|
129
|
-
}
|
130
|
-
|
131
|
-
#qunit-tests td {
|
132
|
-
vertical-align: top;
|
133
|
-
}
|
134
|
-
|
135
|
-
#qunit-tests pre {
|
136
|
-
margin: 0;
|
137
|
-
white-space: pre-wrap;
|
138
|
-
word-wrap: break-word;
|
139
|
-
}
|
140
|
-
|
141
|
-
#qunit-tests del {
|
142
|
-
background-color: #e0f2be;
|
143
|
-
color: #374e0c;
|
144
|
-
text-decoration: none;
|
145
|
-
}
|
146
|
-
|
147
|
-
#qunit-tests ins {
|
148
|
-
background-color: #ffcaca;
|
149
|
-
color: #500;
|
150
|
-
text-decoration: none;
|
151
|
-
}
|
152
|
-
|
153
|
-
/*** Test Counts */
|
154
|
-
|
155
|
-
#qunit-tests b.counts { color: black; }
|
156
|
-
#qunit-tests b.passed { color: #5E740B; }
|
157
|
-
#qunit-tests b.failed { color: #710909; }
|
158
|
-
|
159
|
-
#qunit-tests li li {
|
160
|
-
margin: 0.5em;
|
161
|
-
padding: 0.4em 0.5em 0.4em 0.5em;
|
162
|
-
background-color: #fff;
|
163
|
-
border-bottom: none;
|
164
|
-
list-style-position: inside;
|
165
|
-
}
|
166
|
-
|
167
|
-
/*** Passing Styles */
|
168
|
-
|
169
|
-
#qunit-tests li li.pass {
|
170
|
-
color: #5E740B;
|
171
|
-
background-color: #fff;
|
172
|
-
border-left: 26px solid #C6E746;
|
173
|
-
}
|
174
|
-
|
175
|
-
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
176
|
-
#qunit-tests .pass .test-name { color: #366097; }
|
177
|
-
|
178
|
-
#qunit-tests .pass .test-actual,
|
179
|
-
#qunit-tests .pass .test-expected { color: #999999; }
|
180
|
-
|
181
|
-
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
182
|
-
|
183
|
-
/*** Failing Styles */
|
184
|
-
|
185
|
-
#qunit-tests li li.fail {
|
186
|
-
color: #710909;
|
187
|
-
background-color: #fff;
|
188
|
-
border-left: 26px solid #EE5757;
|
189
|
-
}
|
190
|
-
|
191
|
-
#qunit-tests > li:last-child {
|
192
|
-
border-radius: 0 0 15px 15px;
|
193
|
-
-moz-border-radius: 0 0 15px 15px;
|
194
|
-
-webkit-border-bottom-right-radius: 15px;
|
195
|
-
-webkit-border-bottom-left-radius: 15px;
|
196
|
-
}
|
197
|
-
|
198
|
-
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
199
|
-
#qunit-tests .fail .test-name,
|
200
|
-
#qunit-tests .fail .module-name { color: #000000; }
|
201
|
-
|
202
|
-
#qunit-tests .fail .test-actual { color: #EE5757; }
|
203
|
-
#qunit-tests .fail .test-expected { color: green; }
|
204
|
-
|
205
|
-
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
206
|
-
|
207
|
-
|
208
|
-
/** Result */
|
209
|
-
|
210
|
-
#qunit-testresult {
|
211
|
-
padding: 0.5em 0.5em 0.5em 2.5em;
|
212
|
-
|
213
|
-
color: #2b81af;
|
214
|
-
background-color: #D2E0E6;
|
215
|
-
|
216
|
-
border-bottom: 1px solid white;
|
217
|
-
}
|
218
|
-
|
219
|
-
/** Fixture */
|
220
|
-
|
221
|
-
#qunit-fixture {
|
222
|
-
position: absolute;
|
223
|
-
top: -10000px;
|
224
|
-
left: -10000px;
|
225
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
@import compass/reset
|
@@ -1 +0,0 @@
|
|
1
|
-
/*= require zff/lib/qunit */
|
File without changes
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# html
|
2
|
-
gem 'haml'
|
3
|
-
gem 'haml-coderay'
|
4
|
-
gem 'coderay_bash'
|
5
|
-
|
6
|
-
# css
|
7
|
-
gem 'sass-rails', :git => 'git://github.com/rails/sass-rails.git'
|
8
|
-
gem 'compass', :git => 'https://github.com/chriseppstein/compass.git', :branch => 'rails31'
|
9
|
-
|
10
|
-
# js
|
11
|
-
gem 'therubyracer'
|
12
|
-
gem 'coffee-script'
|
13
|
-
gem 'uglifier'
|
@@ -1 +0,0 @@
|
|
1
|
-
//= require_tree ./core
|
@@ -1,53 +0,0 @@
|
|
1
|
-
// load module
|
2
|
-
// $.load(module_name, success_function)
|
3
|
-
// $.load(module_name, ajax_options)
|
4
|
-
|
5
|
-
(function($){
|
6
|
-
|
7
|
-
var info = {};
|
8
|
-
|
9
|
-
$.load = function(module, opts){
|
10
|
-
opts = opts || {};
|
11
|
-
|
12
|
-
if($.isFunction(opts)){
|
13
|
-
opts = {
|
14
|
-
success: opts
|
15
|
-
};
|
16
|
-
}
|
17
|
-
|
18
|
-
if(typeof info[module] === 'undefined'){
|
19
|
-
var defaults = {
|
20
|
-
url: $.zff.config.load + '/' + module + '.js',
|
21
|
-
dataType: 'script'
|
22
|
-
};
|
23
|
-
|
24
|
-
opts = $.extend(defaults, opts);
|
25
|
-
|
26
|
-
var xhr = $.ajax(opts).success(function(){
|
27
|
-
info[module].state = 200;
|
28
|
-
}).error(function(){
|
29
|
-
info[module].state = 500;
|
30
|
-
});
|
31
|
-
|
32
|
-
info[module] = {
|
33
|
-
state: 202,
|
34
|
-
xhr: xhr
|
35
|
-
};
|
36
|
-
}else{
|
37
|
-
if(info[module].state === 200){
|
38
|
-
if($.isFunction(opts.success)){
|
39
|
-
opts.success();
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
if(info[module].state === 202){
|
44
|
-
$.each(['success', 'error', 'complete', 'statusCode'], function(i, type){
|
45
|
-
if($.isFunction(opts[type])){
|
46
|
-
info[module].xhr = info[module].xhr[type](opts[type]);
|
47
|
-
}
|
48
|
-
});
|
49
|
-
}
|
50
|
-
}
|
51
|
-
return info[module].state;
|
52
|
-
};
|
53
|
-
})($);
|
@@ -1,872 +0,0 @@
|
|
1
|
-
// ColorBox v1.3.17.1 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
|
2
|
-
// Copyright (c) 2011 Jack Moore - jack@colorpowered.com
|
3
|
-
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
4
|
-
(function ($, document, window) {
|
5
|
-
var
|
6
|
-
// ColorBox Default Settings.
|
7
|
-
// See http://colorpowered.com/colorbox for details.
|
8
|
-
defaults = {
|
9
|
-
transition: "elastic",
|
10
|
-
speed: 300,
|
11
|
-
width: false,
|
12
|
-
initialWidth: "600",
|
13
|
-
innerWidth: false,
|
14
|
-
maxWidth: false,
|
15
|
-
height: false,
|
16
|
-
initialHeight: "450",
|
17
|
-
innerHeight: false,
|
18
|
-
maxHeight: false,
|
19
|
-
scalePhotos: true,
|
20
|
-
scrolling: true,
|
21
|
-
inline: false,
|
22
|
-
html: false,
|
23
|
-
iframe: false,
|
24
|
-
fastIframe: true,
|
25
|
-
photo: false,
|
26
|
-
href: false,
|
27
|
-
title: false,
|
28
|
-
rel: false,
|
29
|
-
opacity: 0.9,
|
30
|
-
preloading: true,
|
31
|
-
current: "image {current} of {total}",
|
32
|
-
previous: "previous",
|
33
|
-
next: "next",
|
34
|
-
close: "close",
|
35
|
-
open: false,
|
36
|
-
returnFocus: true,
|
37
|
-
loop: true,
|
38
|
-
slideshow: false,
|
39
|
-
slideshowAuto: true,
|
40
|
-
slideshowSpeed: 2500,
|
41
|
-
slideshowStart: "start slideshow",
|
42
|
-
slideshowStop: "stop slideshow",
|
43
|
-
onOpen: false,
|
44
|
-
onLoad: false,
|
45
|
-
onComplete: false,
|
46
|
-
onCleanup: false,
|
47
|
-
onClosed: false,
|
48
|
-
overlayClose: true,
|
49
|
-
escKey: true,
|
50
|
-
arrowKey: true,
|
51
|
-
top: false,
|
52
|
-
bottom: false,
|
53
|
-
left: false,
|
54
|
-
right: false,
|
55
|
-
fixed: false,
|
56
|
-
data: false
|
57
|
-
},
|
58
|
-
|
59
|
-
// Abstracting the HTML and event identifiers for easy rebranding
|
60
|
-
colorbox = 'colorbox',
|
61
|
-
prefix = 'cbox',
|
62
|
-
|
63
|
-
// Events
|
64
|
-
event_open = prefix + '_open',
|
65
|
-
event_load = prefix + '_load',
|
66
|
-
event_complete = prefix + '_complete',
|
67
|
-
event_cleanup = prefix + '_cleanup',
|
68
|
-
event_closed = prefix + '_closed',
|
69
|
-
event_purge = prefix + '_purge',
|
70
|
-
|
71
|
-
// Special Handling for IE
|
72
|
-
isIE = $.browser.msie && !$.support.opacity, // Detects IE6,7,8. IE9 supports opacity. Feature detection alone gave a false positive on at least one phone browser and on some development versions of Chrome, hence the user-agent test.
|
73
|
-
isIE6 = isIE && $.browser.version < 7,
|
74
|
-
event_ie6 = prefix + '_IE6',
|
75
|
-
|
76
|
-
// Cached jQuery Object Variables
|
77
|
-
$overlay,
|
78
|
-
$box,
|
79
|
-
$wrap,
|
80
|
-
$content,
|
81
|
-
$topBorder,
|
82
|
-
$leftBorder,
|
83
|
-
$rightBorder,
|
84
|
-
$bottomBorder,
|
85
|
-
$related,
|
86
|
-
$window,
|
87
|
-
$loaded,
|
88
|
-
$loadingBay,
|
89
|
-
$loadingOverlay,
|
90
|
-
$title,
|
91
|
-
$current,
|
92
|
-
$slideshow,
|
93
|
-
$next,
|
94
|
-
$prev,
|
95
|
-
$close,
|
96
|
-
$groupControls,
|
97
|
-
|
98
|
-
// Variables for cached values or use across multiple functions
|
99
|
-
settings = {},
|
100
|
-
interfaceHeight,
|
101
|
-
interfaceWidth,
|
102
|
-
loadedHeight,
|
103
|
-
loadedWidth,
|
104
|
-
element,
|
105
|
-
index,
|
106
|
-
photo,
|
107
|
-
open,
|
108
|
-
active,
|
109
|
-
closing,
|
110
|
-
handler,
|
111
|
-
loadingTimer,
|
112
|
-
|
113
|
-
publicMethod,
|
114
|
-
boxElement = prefix + 'Element';
|
115
|
-
|
116
|
-
// ****************
|
117
|
-
// HELPER FUNCTIONS
|
118
|
-
// ****************
|
119
|
-
|
120
|
-
// jQuery object generator to reduce code size
|
121
|
-
function $div(id, cssText) {
|
122
|
-
var div = document.createElement('div');
|
123
|
-
if (id) {
|
124
|
-
div.id = prefix + id;
|
125
|
-
}
|
126
|
-
div.style.cssText = cssText || '';
|
127
|
-
return $(div);
|
128
|
-
}
|
129
|
-
|
130
|
-
// Convert % values to pixels
|
131
|
-
function setSize(size, dimension) {
|
132
|
-
dimension = dimension === 'x' ? $window.width() : $window.height();
|
133
|
-
return (typeof size === 'string') ? Math.round((/%/.test(size) ? (dimension / 100) * parseInt(size, 10) : parseInt(size, 10))) : size;
|
134
|
-
}
|
135
|
-
|
136
|
-
// Checks an href to see if it is a photo.
|
137
|
-
// There is a force photo option (photo: true) for hrefs that cannot be matched by this regex.
|
138
|
-
function isImage(url) {
|
139
|
-
return settings.photo || /\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(url);
|
140
|
-
}
|
141
|
-
|
142
|
-
// Assigns function results to their respective settings. This allows functions to be used as values.
|
143
|
-
function process(settings) {
|
144
|
-
for (var i in settings) {
|
145
|
-
if ($.isFunction(settings[i]) && i.substring(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time.
|
146
|
-
settings[i] = settings[i].call(element);
|
147
|
-
}
|
148
|
-
}
|
149
|
-
|
150
|
-
settings.rel = settings.rel || element.rel || 'nofollow';
|
151
|
-
settings.href = settings.href || $(element).attr('href');
|
152
|
-
settings.title = settings.title || element.title;
|
153
|
-
|
154
|
-
if (typeof settings.href === "string") {
|
155
|
-
settings.href = $.trim(settings.href);
|
156
|
-
}
|
157
|
-
}
|
158
|
-
|
159
|
-
function trigger(event, callback) {
|
160
|
-
if (callback) {
|
161
|
-
callback.call(element);
|
162
|
-
}
|
163
|
-
$.event.trigger(event);
|
164
|
-
}
|
165
|
-
|
166
|
-
// Slideshow functionality
|
167
|
-
function slideshow() {
|
168
|
-
var
|
169
|
-
timeOut,
|
170
|
-
className = prefix + "Slideshow_",
|
171
|
-
click = "click." + prefix,
|
172
|
-
start,
|
173
|
-
stop,
|
174
|
-
clear;
|
175
|
-
|
176
|
-
if (settings.slideshow && $related[1]) {
|
177
|
-
start = function () {
|
178
|
-
$slideshow
|
179
|
-
.text(settings.slideshowStop)
|
180
|
-
.unbind(click)
|
181
|
-
.bind(event_complete, function () {
|
182
|
-
if (index < $related.length - 1 || settings.loop) {
|
183
|
-
timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
|
184
|
-
}
|
185
|
-
})
|
186
|
-
.bind(event_load, function () {
|
187
|
-
clearTimeout(timeOut);
|
188
|
-
})
|
189
|
-
.one(click + ' ' + event_cleanup, stop);
|
190
|
-
$box.removeClass(className + "off").addClass(className + "on");
|
191
|
-
timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
|
192
|
-
};
|
193
|
-
|
194
|
-
stop = function () {
|
195
|
-
clearTimeout(timeOut);
|
196
|
-
$slideshow
|
197
|
-
.text(settings.slideshowStart)
|
198
|
-
.unbind([event_complete, event_load, event_cleanup, click].join(' '))
|
199
|
-
.one(click, start);
|
200
|
-
$box.removeClass(className + "on").addClass(className + "off");
|
201
|
-
};
|
202
|
-
|
203
|
-
if (settings.slideshowAuto) {
|
204
|
-
start();
|
205
|
-
} else {
|
206
|
-
stop();
|
207
|
-
}
|
208
|
-
} else {
|
209
|
-
$box.removeClass(className + "off " + className + "on");
|
210
|
-
}
|
211
|
-
}
|
212
|
-
|
213
|
-
function launch(elem) {
|
214
|
-
if (!closing) {
|
215
|
-
|
216
|
-
element = elem;
|
217
|
-
|
218
|
-
process($.extend(settings, $.data(element, colorbox)));
|
219
|
-
|
220
|
-
$related = $(element);
|
221
|
-
|
222
|
-
index = 0;
|
223
|
-
|
224
|
-
if (settings.rel !== 'nofollow') {
|
225
|
-
$related = $('.' + boxElement).filter(function () {
|
226
|
-
var relRelated = $.data(this, colorbox).rel || this.rel;
|
227
|
-
return (relRelated === settings.rel);
|
228
|
-
});
|
229
|
-
index = $related.index(element);
|
230
|
-
|
231
|
-
// Check direct calls to ColorBox.
|
232
|
-
if (index === -1) {
|
233
|
-
$related = $related.add(element);
|
234
|
-
index = $related.length - 1;
|
235
|
-
}
|
236
|
-
}
|
237
|
-
|
238
|
-
if (!open) {
|
239
|
-
open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
|
240
|
-
|
241
|
-
$box.show();
|
242
|
-
|
243
|
-
if (settings.returnFocus) {
|
244
|
-
try {
|
245
|
-
element.blur();
|
246
|
-
$(element).one(event_closed, function () {
|
247
|
-
try {
|
248
|
-
this.focus();
|
249
|
-
} catch (e) {
|
250
|
-
// do nothing
|
251
|
-
}
|
252
|
-
});
|
253
|
-
} catch (e) {
|
254
|
-
// do nothing
|
255
|
-
}
|
256
|
-
}
|
257
|
-
|
258
|
-
// +settings.opacity avoids a problem in IE when using non-zero-prefixed-string-values, like '.5'
|
259
|
-
$overlay.css({"opacity": +settings.opacity, "cursor": settings.overlayClose ? "pointer" : "auto"}).show();
|
260
|
-
|
261
|
-
// Opens inital empty ColorBox prior to content being loaded.
|
262
|
-
settings.w = setSize(settings.initialWidth, 'x');
|
263
|
-
settings.h = setSize(settings.initialHeight, 'y');
|
264
|
-
publicMethod.position(0);
|
265
|
-
|
266
|
-
if (isIE6) {
|
267
|
-
$window.bind('resize.' + event_ie6 + ' scroll.' + event_ie6, function () {
|
268
|
-
$overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()});
|
269
|
-
}).trigger('resize.' + event_ie6);
|
270
|
-
}
|
271
|
-
|
272
|
-
trigger(event_open, settings.onOpen);
|
273
|
-
|
274
|
-
$groupControls.add($title).hide();
|
275
|
-
|
276
|
-
$close.html(settings.close).show();
|
277
|
-
}
|
278
|
-
|
279
|
-
publicMethod.load(true);
|
280
|
-
}
|
281
|
-
}
|
282
|
-
|
283
|
-
// ****************
|
284
|
-
// PUBLIC FUNCTIONS
|
285
|
-
// Usage format: $.fn.colorbox.close();
|
286
|
-
// Usage from within an iframe: parent.$.fn.colorbox.close();
|
287
|
-
// ****************
|
288
|
-
|
289
|
-
publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
|
290
|
-
var $this = this, autoOpen;
|
291
|
-
|
292
|
-
if (!$this[0] && $this.selector) { // if a selector was given and it didn't match any elements, go ahead and exit.
|
293
|
-
return $this;
|
294
|
-
}
|
295
|
-
|
296
|
-
options = options || {};
|
297
|
-
|
298
|
-
if (callback) {
|
299
|
-
options.onComplete = callback;
|
300
|
-
}
|
301
|
-
|
302
|
-
if (!$this[0] || $this.selector === undefined) { // detects $.colorbox() and $.fn.colorbox()
|
303
|
-
$this = $('<a/>');
|
304
|
-
options.open = true; // assume an immediate open
|
305
|
-
}
|
306
|
-
|
307
|
-
$this.each(function () {
|
308
|
-
$.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options));
|
309
|
-
$(this).addClass(boxElement);
|
310
|
-
});
|
311
|
-
|
312
|
-
autoOpen = options.open;
|
313
|
-
|
314
|
-
if ($.isFunction(autoOpen)) {
|
315
|
-
autoOpen = autoOpen.call($this);
|
316
|
-
}
|
317
|
-
|
318
|
-
if (autoOpen) {
|
319
|
-
launch($this[0]);
|
320
|
-
}
|
321
|
-
|
322
|
-
return $this;
|
323
|
-
};
|
324
|
-
|
325
|
-
// Initialize ColorBox: store common calculations, preload the interface graphics, append the html.
|
326
|
-
// This preps colorbox for a speedy open when clicked, and lightens the burdon on the browser by only
|
327
|
-
// having to run once, instead of each time colorbox is opened.
|
328
|
-
publicMethod.init = function () {
|
329
|
-
// Create & Append jQuery Objects
|
330
|
-
$window = $(window);
|
331
|
-
$box = $div().attr({id: colorbox, 'class': isIE ? prefix + (isIE6 ? 'IE6' : 'IE') : ''});
|
332
|
-
$overlay = $div("Overlay", isIE6 ? 'position:absolute' : '').hide();
|
333
|
-
|
334
|
-
$wrap = $div("Wrapper");
|
335
|
-
$content = $div("Content").append(
|
336
|
-
$loaded = $div("LoadedContent", 'width:0; height:0; overflow:hidden'),
|
337
|
-
$loadingOverlay = $div("LoadingOverlay").add($div("LoadingGraphic")),
|
338
|
-
$title = $div("Title"),
|
339
|
-
$current = $div("Current"),
|
340
|
-
$next = $div("Next"),
|
341
|
-
$prev = $div("Previous"),
|
342
|
-
$slideshow = $div("Slideshow").bind(event_open, slideshow),
|
343
|
-
$close = $div("Close")
|
344
|
-
);
|
345
|
-
$wrap.append( // The 3x3 Grid that makes up ColorBox
|
346
|
-
$div().append(
|
347
|
-
$div("TopLeft"),
|
348
|
-
$topBorder = $div("TopCenter"),
|
349
|
-
$div("TopRight")
|
350
|
-
),
|
351
|
-
$div(false, 'clear:left').append(
|
352
|
-
$leftBorder = $div("MiddleLeft"),
|
353
|
-
$content,
|
354
|
-
$rightBorder = $div("MiddleRight")
|
355
|
-
),
|
356
|
-
$div(false, 'clear:left').append(
|
357
|
-
$div("BottomLeft"),
|
358
|
-
$bottomBorder = $div("BottomCenter"),
|
359
|
-
$div("BottomRight")
|
360
|
-
)
|
361
|
-
).children().children().css({'float': 'left'});
|
362
|
-
|
363
|
-
$loadingBay = $div(false, 'position:absolute; width:9999px; visibility:hidden; display:none');
|
364
|
-
|
365
|
-
$('body').prepend($overlay, $box.append($wrap, $loadingBay));
|
366
|
-
|
367
|
-
$content.children()
|
368
|
-
.hover(function () {
|
369
|
-
$(this).addClass('hover');
|
370
|
-
}, function () {
|
371
|
-
$(this).removeClass('hover');
|
372
|
-
}).addClass('hover');
|
373
|
-
|
374
|
-
// Cache values needed for size calculations
|
375
|
-
interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();//Subtraction needed for IE6
|
376
|
-
interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
|
377
|
-
loadedHeight = $loaded.outerHeight(true);
|
378
|
-
loadedWidth = $loaded.outerWidth(true);
|
379
|
-
|
380
|
-
// Setting padding to remove the need to do size conversions during the animation step.
|
381
|
-
$box.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth}).hide();
|
382
|
-
|
383
|
-
// Setup button events.
|
384
|
-
$next.click(function () {
|
385
|
-
publicMethod.next();
|
386
|
-
});
|
387
|
-
$prev.click(function () {
|
388
|
-
publicMethod.prev();
|
389
|
-
});
|
390
|
-
$close.click(function () {
|
391
|
-
publicMethod.close();
|
392
|
-
});
|
393
|
-
|
394
|
-
$groupControls = $next.add($prev).add($current).add($slideshow);
|
395
|
-
|
396
|
-
// Adding the 'hover' class allowed the browser to load the hover-state
|
397
|
-
// background graphics. The class can now can be removed.
|
398
|
-
$content.children().removeClass('hover');
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
$overlay.click(function () {
|
404
|
-
if (settings.overlayClose) {
|
405
|
-
publicMethod.close();
|
406
|
-
}
|
407
|
-
});
|
408
|
-
|
409
|
-
// Set Navigation Key Bindings
|
410
|
-
$(document).bind('keydown.' + prefix, function (e) {
|
411
|
-
var key = e.keyCode;
|
412
|
-
if (open && settings.escKey && key === 27) {
|
413
|
-
e.preventDefault();
|
414
|
-
publicMethod.close();
|
415
|
-
}
|
416
|
-
if (open && settings.arrowKey && $related[1]) {
|
417
|
-
if (key === 37) {
|
418
|
-
e.preventDefault();
|
419
|
-
$prev.click();
|
420
|
-
} else if (key === 39) {
|
421
|
-
e.preventDefault();
|
422
|
-
$next.click();
|
423
|
-
}
|
424
|
-
}
|
425
|
-
});
|
426
|
-
};
|
427
|
-
|
428
|
-
publicMethod.remove = function () {
|
429
|
-
$box.add($overlay).remove();
|
430
|
-
$('.' + boxElement).removeData(colorbox).removeClass(boxElement);
|
431
|
-
};
|
432
|
-
|
433
|
-
publicMethod.position = function (speed, loadedCallback) {
|
434
|
-
var animate_speed, top = 0, left = 0;
|
435
|
-
|
436
|
-
// remove the modal so that it doesn't influence the document width/height
|
437
|
-
$box.hide();
|
438
|
-
|
439
|
-
if (settings.fixed && !isIE6) {
|
440
|
-
$box.css({position: 'fixed'});
|
441
|
-
} else {
|
442
|
-
top = $window.scrollTop();
|
443
|
-
left = $window.scrollLeft();
|
444
|
-
$box.css({position: 'absolute'});
|
445
|
-
}
|
446
|
-
|
447
|
-
// keeps the top and left positions within the browser's viewport.
|
448
|
-
if (settings.right !== false) {
|
449
|
-
left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0);
|
450
|
-
} else if (settings.left !== false) {
|
451
|
-
left += setSize(settings.left, 'x');
|
452
|
-
} else {
|
453
|
-
left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2;
|
454
|
-
}
|
455
|
-
|
456
|
-
if (settings.bottom !== false) {
|
457
|
-
top += Math.max(document.documentElement.clientHeight - settings.h - loadedHeight - interfaceHeight - setSize(settings.bottom, 'y'), 0);
|
458
|
-
} else if (settings.top !== false) {
|
459
|
-
top += setSize(settings.top, 'y');
|
460
|
-
} else {
|
461
|
-
top += Math.max(document.documentElement.clientHeight - settings.h - loadedHeight - interfaceHeight, 0) / 2;
|
462
|
-
}
|
463
|
-
|
464
|
-
$box.show();
|
465
|
-
|
466
|
-
// setting the speed to 0 to reduce the delay between same-sized content.
|
467
|
-
animate_speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed;
|
468
|
-
|
469
|
-
// this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
|
470
|
-
// but it has to be shrank down around the size of div#colorbox when it's done. If not,
|
471
|
-
// it can invoke an obscure IE bug when using iframes.
|
472
|
-
$wrap[0].style.width = $wrap[0].style.height = "9999px";
|
473
|
-
|
474
|
-
function modalDimensions(that) {
|
475
|
-
// loading overlay height has to be explicitly set for IE6.
|
476
|
-
$topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
|
477
|
-
$loadingOverlay[0].style.height = $loadingOverlay[1].style.height = $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
|
478
|
-
}
|
479
|
-
|
480
|
-
$box.dequeue().animate({width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: top, left: left}, {
|
481
|
-
duration: animate_speed,
|
482
|
-
complete: function () {
|
483
|
-
modalDimensions(this);
|
484
|
-
|
485
|
-
active = false;
|
486
|
-
|
487
|
-
// shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
|
488
|
-
$wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
|
489
|
-
$wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
|
490
|
-
|
491
|
-
if (loadedCallback) {
|
492
|
-
loadedCallback();
|
493
|
-
}
|
494
|
-
},
|
495
|
-
step: function () {
|
496
|
-
modalDimensions(this);
|
497
|
-
}
|
498
|
-
});
|
499
|
-
};
|
500
|
-
|
501
|
-
publicMethod.resize = function (options) {
|
502
|
-
if (open) {
|
503
|
-
options = options || {};
|
504
|
-
|
505
|
-
if (options.width) {
|
506
|
-
settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth;
|
507
|
-
}
|
508
|
-
if (options.innerWidth) {
|
509
|
-
settings.w = setSize(options.innerWidth, 'x');
|
510
|
-
}
|
511
|
-
$loaded.css({width: settings.w});
|
512
|
-
|
513
|
-
if (options.height) {
|
514
|
-
settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight;
|
515
|
-
}
|
516
|
-
if (options.innerHeight) {
|
517
|
-
settings.h = setSize(options.innerHeight, 'y');
|
518
|
-
}
|
519
|
-
if (!options.innerHeight && !options.height) {
|
520
|
-
var $child = $loaded.wrapInner("<div style='overflow:auto'></div>").children(); // temporary wrapper to get an accurate estimate of just how high the total content should be.
|
521
|
-
settings.h = $child.height();
|
522
|
-
$child.replaceWith($child.children()); // ditch the temporary wrapper div used in height calculation
|
523
|
-
}
|
524
|
-
$loaded.css({height: settings.h});
|
525
|
-
|
526
|
-
publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
|
527
|
-
}
|
528
|
-
};
|
529
|
-
|
530
|
-
publicMethod.prep = function (object) {
|
531
|
-
if (!open) {
|
532
|
-
return;
|
533
|
-
}
|
534
|
-
|
535
|
-
var speed = settings.transition === "none" ? 0 : settings.speed;
|
536
|
-
|
537
|
-
$window.unbind('resize.' + prefix);
|
538
|
-
$loaded.remove();
|
539
|
-
$loaded = $div('LoadedContent').html(object);
|
540
|
-
|
541
|
-
function getWidth() {
|
542
|
-
settings.w = settings.w || $loaded.width();
|
543
|
-
settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
|
544
|
-
return settings.w;
|
545
|
-
}
|
546
|
-
function getHeight() {
|
547
|
-
settings.h = settings.h || $loaded.height();
|
548
|
-
settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
|
549
|
-
return settings.h;
|
550
|
-
}
|
551
|
-
|
552
|
-
$loaded.hide()
|
553
|
-
.appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
|
554
|
-
.css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
|
555
|
-
.css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
|
556
|
-
.prependTo($content);
|
557
|
-
|
558
|
-
$loadingBay.hide();
|
559
|
-
|
560
|
-
// floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width.
|
561
|
-
//$(photo).css({'float': 'none', marginLeft: 'auto', marginRight: 'auto'});
|
562
|
-
|
563
|
-
$(photo).css({'float': 'none'});
|
564
|
-
|
565
|
-
// Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
|
566
|
-
if (isIE6) {
|
567
|
-
$('select').not($box.find('select')).filter(function () {
|
568
|
-
return this.style.visibility !== 'hidden';
|
569
|
-
}).css({'visibility': 'hidden'}).one(event_cleanup, function () {
|
570
|
-
this.style.visibility = 'inherit';
|
571
|
-
});
|
572
|
-
}
|
573
|
-
|
574
|
-
function setPosition(s) {
|
575
|
-
publicMethod.position(s, function () {
|
576
|
-
var prev, prevSrc, next, nextSrc, total = $related.length, iframe, complete;
|
577
|
-
|
578
|
-
if (!open) {
|
579
|
-
return;
|
580
|
-
}
|
581
|
-
|
582
|
-
function removeFilter() {
|
583
|
-
if (isIE) {
|
584
|
-
$box[0].style.removeAttribute('filter');
|
585
|
-
}
|
586
|
-
}
|
587
|
-
|
588
|
-
complete = function () {
|
589
|
-
clearTimeout(loadingTimer);
|
590
|
-
$loadingOverlay.hide();
|
591
|
-
trigger(event_complete, settings.onComplete);
|
592
|
-
};
|
593
|
-
|
594
|
-
if (isIE) {
|
595
|
-
//This fadeIn helps the bicubic resampling to kick-in.
|
596
|
-
if (photo) {
|
597
|
-
$loaded.fadeIn(100);
|
598
|
-
}
|
599
|
-
}
|
600
|
-
|
601
|
-
$title.html(settings.title).add($loaded).show();
|
602
|
-
|
603
|
-
if (total > 1) { // handle grouping
|
604
|
-
if (typeof settings.current === "string") {
|
605
|
-
$current.html(settings.current.replace(/\{current\}/, index + 1).replace(/\{total\}/, total)).show();
|
606
|
-
}
|
607
|
-
|
608
|
-
$next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
|
609
|
-
$prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous);
|
610
|
-
|
611
|
-
prev = index ? $related[index - 1] : $related[total - 1];
|
612
|
-
next = index < total - 1 ? $related[index + 1] : $related[0];
|
613
|
-
|
614
|
-
if (settings.slideshow) {
|
615
|
-
$slideshow.show();
|
616
|
-
}
|
617
|
-
|
618
|
-
// Preloads images within a rel group
|
619
|
-
if (settings.preloading) {
|
620
|
-
nextSrc = $.data(next, colorbox).href || next.href;
|
621
|
-
prevSrc = $.data(prev, colorbox).href || prev.href;
|
622
|
-
|
623
|
-
nextSrc = $.isFunction(nextSrc) ? nextSrc.call(next) : nextSrc;
|
624
|
-
prevSrc = $.isFunction(prevSrc) ? prevSrc.call(prev) : prevSrc;
|
625
|
-
|
626
|
-
if (isImage(nextSrc)) {
|
627
|
-
$('<img/>')[0].src = nextSrc;
|
628
|
-
}
|
629
|
-
|
630
|
-
if (isImage(prevSrc)) {
|
631
|
-
$('<img/>')[0].src = prevSrc;
|
632
|
-
}
|
633
|
-
}
|
634
|
-
} else {
|
635
|
-
$groupControls.hide();
|
636
|
-
}
|
637
|
-
|
638
|
-
if (settings.iframe) {
|
639
|
-
iframe = $('<iframe/>').addClass(prefix + 'Iframe')[0];
|
640
|
-
|
641
|
-
if (settings.fastIframe) {
|
642
|
-
complete();
|
643
|
-
} else {
|
644
|
-
$(iframe).one('load', complete);
|
645
|
-
}
|
646
|
-
iframe.name = prefix + (+new Date());
|
647
|
-
iframe.src = settings.href;
|
648
|
-
|
649
|
-
if (!settings.scrolling) {
|
650
|
-
iframe.scrolling = "no";
|
651
|
-
}
|
652
|
-
|
653
|
-
if (isIE) {
|
654
|
-
iframe.frameBorder = 0;
|
655
|
-
iframe.allowTransparency = "true";
|
656
|
-
}
|
657
|
-
|
658
|
-
$(iframe).appendTo($loaded).one(event_purge, function () {
|
659
|
-
iframe.src = "//about:blank";
|
660
|
-
});
|
661
|
-
} else {
|
662
|
-
complete();
|
663
|
-
}
|
664
|
-
|
665
|
-
if (settings.transition === 'fade') {
|
666
|
-
$box.fadeTo(speed, 1, removeFilter);
|
667
|
-
} else {
|
668
|
-
removeFilter();
|
669
|
-
}
|
670
|
-
|
671
|
-
$window.bind('resize.' + prefix, function () {
|
672
|
-
publicMethod.position(0);
|
673
|
-
});
|
674
|
-
});
|
675
|
-
}
|
676
|
-
|
677
|
-
if (settings.transition === 'fade') {
|
678
|
-
$box.fadeTo(speed, 0, function () {
|
679
|
-
setPosition(0);
|
680
|
-
});
|
681
|
-
} else {
|
682
|
-
setPosition(speed);
|
683
|
-
}
|
684
|
-
};
|
685
|
-
|
686
|
-
publicMethod.load = function (launched) {
|
687
|
-
var href, setResize, prep = publicMethod.prep;
|
688
|
-
|
689
|
-
active = true;
|
690
|
-
|
691
|
-
photo = false;
|
692
|
-
|
693
|
-
element = $related[index];
|
694
|
-
|
695
|
-
if (!launched) {
|
696
|
-
process($.extend(settings, $.data(element, colorbox)));
|
697
|
-
}
|
698
|
-
|
699
|
-
trigger(event_purge);
|
700
|
-
|
701
|
-
trigger(event_load, settings.onLoad);
|
702
|
-
|
703
|
-
settings.h = settings.height ?
|
704
|
-
setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
|
705
|
-
settings.innerHeight && setSize(settings.innerHeight, 'y');
|
706
|
-
|
707
|
-
settings.w = settings.width ?
|
708
|
-
setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
|
709
|
-
settings.innerWidth && setSize(settings.innerWidth, 'x');
|
710
|
-
|
711
|
-
// Sets the minimum dimensions for use in image scaling
|
712
|
-
settings.mw = settings.w;
|
713
|
-
settings.mh = settings.h;
|
714
|
-
|
715
|
-
// Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
|
716
|
-
// If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
|
717
|
-
if (settings.maxWidth) {
|
718
|
-
settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
|
719
|
-
settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
|
720
|
-
}
|
721
|
-
if (settings.maxHeight) {
|
722
|
-
settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
|
723
|
-
settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
|
724
|
-
}
|
725
|
-
|
726
|
-
href = settings.href;
|
727
|
-
|
728
|
-
loadingTimer = setTimeout(function () {
|
729
|
-
$loadingOverlay.show();
|
730
|
-
}, 100);
|
731
|
-
|
732
|
-
if (settings.inline) {
|
733
|
-
// Inserts an empty placeholder where inline content is being pulled from.
|
734
|
-
// An event is bound to put inline content back when ColorBox closes or loads new content.
|
735
|
-
$div().hide().insertBefore($(href)[0]).one(event_purge, function () {
|
736
|
-
$(this).replaceWith($loaded.children());
|
737
|
-
});
|
738
|
-
prep($(href));
|
739
|
-
} else if (settings.iframe) {
|
740
|
-
// IFrame element won't be added to the DOM until it is ready to be displayed,
|
741
|
-
// to avoid problems with DOM-ready JS that might be trying to run in that iframe.
|
742
|
-
prep(" ");
|
743
|
-
} else if (settings.html) {
|
744
|
-
prep(settings.html);
|
745
|
-
} else if (isImage(href)) {
|
746
|
-
$(photo = new Image())
|
747
|
-
.addClass(prefix + 'Photo')
|
748
|
-
.error(function () {
|
749
|
-
settings.title = false;
|
750
|
-
prep($div('Error').text('This image could not be loaded'));
|
751
|
-
})
|
752
|
-
.load(function () {
|
753
|
-
var percent;
|
754
|
-
photo.onload = null; //stops animated gifs from firing the onload repeatedly.
|
755
|
-
|
756
|
-
if (settings.scalePhotos) {
|
757
|
-
setResize = function () {
|
758
|
-
photo.height -= photo.height * percent;
|
759
|
-
photo.width -= photo.width * percent;
|
760
|
-
};
|
761
|
-
if (settings.mw && photo.width > settings.mw) {
|
762
|
-
percent = (photo.width - settings.mw) / photo.width;
|
763
|
-
setResize();
|
764
|
-
}
|
765
|
-
if (settings.mh && photo.height > settings.mh) {
|
766
|
-
percent = (photo.height - settings.mh) / photo.height;
|
767
|
-
setResize();
|
768
|
-
}
|
769
|
-
}
|
770
|
-
|
771
|
-
if (settings.h) {
|
772
|
-
photo.style.marginTop = Math.max(settings.h - photo.height, 0) / 2 + 'px';
|
773
|
-
}
|
774
|
-
|
775
|
-
if ($related[1] && (index < $related.length - 1 || settings.loop)) {
|
776
|
-
photo.style.cursor = 'pointer';
|
777
|
-
photo.onclick = function () {
|
778
|
-
publicMethod.next();
|
779
|
-
};
|
780
|
-
}
|
781
|
-
|
782
|
-
if (isIE) {
|
783
|
-
photo.style.msInterpolationMode = 'bicubic';
|
784
|
-
}
|
785
|
-
|
786
|
-
setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise.
|
787
|
-
prep(photo);
|
788
|
-
}, 1);
|
789
|
-
});
|
790
|
-
|
791
|
-
setTimeout(function () { // A pause because Opera 10.6+ will sometimes not run the onload function otherwise.
|
792
|
-
photo.src = href;
|
793
|
-
}, 1);
|
794
|
-
} else if (href) {
|
795
|
-
$loadingBay.load(href, settings.data, function (data, status, xhr) {
|
796
|
-
prep(status === 'error' ? $div('Error').text('Request unsuccessful: ' + xhr.statusText) : $(this).contents());
|
797
|
-
});
|
798
|
-
}
|
799
|
-
};
|
800
|
-
|
801
|
-
// Navigates to the next page/image in a set.
|
802
|
-
publicMethod.next = function () {
|
803
|
-
if (!active && $related[1] && (index < $related.length - 1 || settings.loop)) {
|
804
|
-
index = index < $related.length - 1 ? index + 1 : 0;
|
805
|
-
publicMethod.load();
|
806
|
-
}
|
807
|
-
};
|
808
|
-
|
809
|
-
publicMethod.prev = function () {
|
810
|
-
if (!active && $related[1] && (index || settings.loop)) {
|
811
|
-
index = index ? index - 1 : $related.length - 1;
|
812
|
-
publicMethod.load();
|
813
|
-
}
|
814
|
-
};
|
815
|
-
|
816
|
-
// Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
|
817
|
-
publicMethod.close = function () {
|
818
|
-
if (open && !closing) {
|
819
|
-
|
820
|
-
closing = true;
|
821
|
-
|
822
|
-
open = false;
|
823
|
-
|
824
|
-
trigger(event_cleanup, settings.onCleanup);
|
825
|
-
|
826
|
-
$window.unbind('.' + prefix + ' .' + event_ie6);
|
827
|
-
|
828
|
-
$overlay.fadeTo(200, 0);
|
829
|
-
|
830
|
-
$box.stop().fadeTo(300, 0, function () {
|
831
|
-
|
832
|
-
$box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
|
833
|
-
|
834
|
-
trigger(event_purge);
|
835
|
-
|
836
|
-
$loaded.remove();
|
837
|
-
|
838
|
-
setTimeout(function () {
|
839
|
-
closing = false;
|
840
|
-
trigger(event_closed, settings.onClosed);
|
841
|
-
}, 1);
|
842
|
-
});
|
843
|
-
}
|
844
|
-
};
|
845
|
-
|
846
|
-
// A method for fetching the current element ColorBox is referencing.
|
847
|
-
// returns a jQuery object.
|
848
|
-
publicMethod.element = function () {
|
849
|
-
return $(element);
|
850
|
-
};
|
851
|
-
|
852
|
-
publicMethod.settings = defaults;
|
853
|
-
|
854
|
-
// Bind the live event before DOM-ready for maximum performance in IE6 & 7.
|
855
|
-
handler = function (e) {
|
856
|
-
// checks to see if it was a non-left mouse-click and for clicks modified with ctrl, shift, or alt.
|
857
|
-
if (!((e.button !== 0 && typeof e.button !== 'undefined') || e.ctrlKey || e.shiftKey || e.altKey)) {
|
858
|
-
e.preventDefault();
|
859
|
-
launch(this);
|
860
|
-
}
|
861
|
-
};
|
862
|
-
|
863
|
-
if ($.fn.delegate) {
|
864
|
-
$(document).delegate('.' + boxElement, 'click', handler);
|
865
|
-
} else {
|
866
|
-
$('.' + boxElement).live('click', handler);
|
867
|
-
}
|
868
|
-
|
869
|
-
// Initializes ColorBox when the DOM has loaded
|
870
|
-
$(publicMethod.init);
|
871
|
-
|
872
|
-
}(jQuery, document, this));
|