tandem 0.2.0.rc → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tandem/version.rb +1 -1
- data/vendor/assets/javascripts/tandem/jquery-fileupload/index.js +2 -0
- data/vendor/assets/javascripts/tandem/jquery-fileupload/jquery.fileupload.js +852 -0
- data/vendor/assets/javascripts/tandem/jquery-fileupload/jquery.iframe-transport.js +165 -0
- data/vendor/assets/javascripts/tandem/jquery.colorbox.js +888 -0
- data/vendor/assets/javascripts/tandem/jquery.ui.widget.js +282 -0
- data/vendor/assets/javascripts/tandem/modernizr-2.5.3.min.js +4 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-article.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-aside.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-blockquote.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-command.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-details.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-figcaption.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-figure.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-footer.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-h1.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-h2.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-h3.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-h4.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-h5.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-h6.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-header.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-hgroup.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-mark.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-meter.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-nav.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-p.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-pre.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-progress.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-rp.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-rt.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-ruby.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-section.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-summary.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/lbl-time.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/readme.md +1 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/wymiframe.css +98 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/wymiframe.css.scss +98 -0
- data/vendor/assets/javascripts/tandem/wymeditor/iframe/default/wymiframe.html +26 -0
- data/vendor/assets/javascripts/tandem/wymeditor/jquery.wymeditor.min.js +34 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/bg.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/ca.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/cs.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/cy.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/de.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/en.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/es.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/fa.js +46 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/fi.js +44 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/fr.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/gl.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/he.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/hr.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/hu.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/it.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/ja.js +44 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/lt.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/nb.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/nl.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/nn.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/pl.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/pt-br.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/pt.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/ru.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/sv.js +46 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/tr.js +45 -0
- data/vendor/assets/javascripts/tandem/wymeditor/lang/zh_cn.js +47 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/embed/jquery.wymeditor.embed.js +82 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/fullscreen/icon_fullscreen.gif +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/fullscreen/jquery.wymeditor.fullscreen.js +124 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/hovertools/jquery.wymeditor.hovertools.js +49 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/list/jquery.wymeditor.list.js +60 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/rdfa/jquery.wymeditor.rdfa.js +186 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/resizable/jquery.wymeditor.resizable.js +77 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/resizable/readme.txt +124 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/table/jquery.wymeditor.table.js +721 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/table/table_delete_column.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/table/table_delete_row.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/table/table_insert_column.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/table/table_insert_row.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/table/table_join_row.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/tidy/README +19 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/tidy/jquery.wymeditor.tidy.js +78 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/tidy/tidy.php +58 -0
- data/vendor/assets/javascripts/tandem/wymeditor/plugins/tidy/wand.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/compact/icons.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/compact/skin.css +134 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/compact/skin.js +37 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/default/icons.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/default/skin.css +136 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/default/skin.js +40 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/minimal/images/bg.header.gif +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/minimal/images/bg.selector.silver.gif +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/minimal/images/bg.wymeditor.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/minimal/images/icons.silver.gif +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/minimal/skin.css +131 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/minimal/skin.js +30 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/silver/COPYING +674 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/silver/README +27 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/silver/images/bg.header.gif +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/silver/images/bg.selector.silver.gif +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/silver/images/bg.wymeditor.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/silver/images/icons.silver.gif +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/silver/skin.css +297 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/silver/skin.js +61 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/twopanels/icons.png +0 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/twopanels/skin.css +134 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/twopanels/skin.js +39 -0
- data/vendor/assets/javascripts/tandem/wymeditor/skins/wymeditor_icon.png +0 -0
- metadata +112 -4
@@ -0,0 +1,165 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery Iframe Transport Plugin 1.3
|
3
|
+
* https://github.com/blueimp/jQuery-File-Upload
|
4
|
+
*
|
5
|
+
* Copyright 2011, Sebastian Tschan
|
6
|
+
* https://blueimp.net
|
7
|
+
*
|
8
|
+
* Licensed under the MIT license:
|
9
|
+
* http://www.opensource.org/licenses/MIT
|
10
|
+
*/
|
11
|
+
|
12
|
+
/*jslint unparam: true, nomen: true */
|
13
|
+
/*global define, window, document */
|
14
|
+
|
15
|
+
(function (factory) {
|
16
|
+
'use strict';
|
17
|
+
if (typeof define === 'function' && define.amd) {
|
18
|
+
// Register as an anonymous AMD module:
|
19
|
+
define(['jquery'], factory);
|
20
|
+
} else {
|
21
|
+
// Browser globals:
|
22
|
+
factory(window.jQuery);
|
23
|
+
}
|
24
|
+
}(function ($) {
|
25
|
+
'use strict';
|
26
|
+
|
27
|
+
// Helper variable to create unique names for the transport iframes:
|
28
|
+
var counter = 0;
|
29
|
+
|
30
|
+
// The iframe transport accepts three additional options:
|
31
|
+
// options.fileInput: a jQuery collection of file input fields
|
32
|
+
// options.paramName: the parameter name for the file form data,
|
33
|
+
// overrides the name property of the file input field(s)
|
34
|
+
// options.formData: an array of objects with name and value properties,
|
35
|
+
// equivalent to the return data of .serializeArray(), e.g.:
|
36
|
+
// [{name: 'a', value: 1}, {name: 'b', value: 2}]
|
37
|
+
$.ajaxTransport('iframe', function (options) {
|
38
|
+
if (options.async && (options.type === 'POST' || options.type === 'GET')) {
|
39
|
+
var form,
|
40
|
+
iframe;
|
41
|
+
return {
|
42
|
+
send: function (_, completeCallback) {
|
43
|
+
form = $('<form style="display:none;"></form>');
|
44
|
+
// javascript:false as initial iframe src
|
45
|
+
// prevents warning popups on HTTPS in IE6.
|
46
|
+
// IE versions below IE8 cannot set the name property of
|
47
|
+
// elements that have already been added to the DOM,
|
48
|
+
// so we set the name along with the iframe HTML markup:
|
49
|
+
iframe = $(
|
50
|
+
'<iframe src="javascript:false;" name="iframe-transport-' +
|
51
|
+
(counter += 1) + '"></iframe>'
|
52
|
+
).bind('load', function () {
|
53
|
+
var fileInputClones;
|
54
|
+
iframe
|
55
|
+
.unbind('load')
|
56
|
+
.bind('load', function () {
|
57
|
+
var response;
|
58
|
+
// Wrap in a try/catch block to catch exceptions thrown
|
59
|
+
// when trying to access cross-domain iframe contents:
|
60
|
+
try {
|
61
|
+
response = iframe.contents();
|
62
|
+
// Google Chrome and Firefox do not throw an
|
63
|
+
// exception when calling iframe.contents() on
|
64
|
+
// cross-domain requests, so we unify the response:
|
65
|
+
if (!response.length || !response[0].firstChild) {
|
66
|
+
throw new Error();
|
67
|
+
}
|
68
|
+
} catch (e) {
|
69
|
+
response = undefined;
|
70
|
+
}
|
71
|
+
// The complete callback returns the
|
72
|
+
// iframe content document as response object:
|
73
|
+
completeCallback(
|
74
|
+
200,
|
75
|
+
'success',
|
76
|
+
{'iframe': response}
|
77
|
+
);
|
78
|
+
// Fix for IE endless progress bar activity bug
|
79
|
+
// (happens on form submits to iframe targets):
|
80
|
+
$('<iframe src="javascript:false;"></iframe>')
|
81
|
+
.appendTo(form);
|
82
|
+
form.remove();
|
83
|
+
});
|
84
|
+
form
|
85
|
+
.prop('target', iframe.prop('name'))
|
86
|
+
.prop('action', options.url)
|
87
|
+
.prop('method', options.type);
|
88
|
+
if (options.formData) {
|
89
|
+
$.each(options.formData, function (index, field) {
|
90
|
+
$('<input type="hidden"/>')
|
91
|
+
.prop('name', field.name)
|
92
|
+
.val(field.value)
|
93
|
+
.appendTo(form);
|
94
|
+
});
|
95
|
+
}
|
96
|
+
if (options.fileInput && options.fileInput.length &&
|
97
|
+
options.type === 'POST') {
|
98
|
+
fileInputClones = options.fileInput.clone();
|
99
|
+
// Insert a clone for each file input field:
|
100
|
+
options.fileInput.after(function (index) {
|
101
|
+
return fileInputClones[index];
|
102
|
+
});
|
103
|
+
if (options.paramName) {
|
104
|
+
options.fileInput.each(function () {
|
105
|
+
$(this).prop('name', options.paramName);
|
106
|
+
});
|
107
|
+
}
|
108
|
+
// Appending the file input fields to the hidden form
|
109
|
+
// removes them from their original location:
|
110
|
+
form
|
111
|
+
.append(options.fileInput)
|
112
|
+
.prop('enctype', 'multipart/form-data')
|
113
|
+
// enctype must be set as encoding for IE:
|
114
|
+
.prop('encoding', 'multipart/form-data');
|
115
|
+
}
|
116
|
+
form.submit();
|
117
|
+
// Insert the file input fields at their original location
|
118
|
+
// by replacing the clones with the originals:
|
119
|
+
if (fileInputClones && fileInputClones.length) {
|
120
|
+
options.fileInput.each(function (index, input) {
|
121
|
+
var clone = $(fileInputClones[index]);
|
122
|
+
$(input).prop('name', clone.prop('name'));
|
123
|
+
clone.replaceWith(input);
|
124
|
+
});
|
125
|
+
}
|
126
|
+
});
|
127
|
+
form.append(iframe).appendTo(document.body);
|
128
|
+
},
|
129
|
+
abort: function () {
|
130
|
+
if (iframe) {
|
131
|
+
// javascript:false as iframe src aborts the request
|
132
|
+
// and prevents warning popups on HTTPS in IE6.
|
133
|
+
// concat is used to avoid the "Script URL" JSLint error:
|
134
|
+
iframe
|
135
|
+
.unbind('load')
|
136
|
+
.prop('src', 'javascript'.concat(':false;'));
|
137
|
+
}
|
138
|
+
if (form) {
|
139
|
+
form.remove();
|
140
|
+
}
|
141
|
+
}
|
142
|
+
};
|
143
|
+
}
|
144
|
+
});
|
145
|
+
|
146
|
+
// The iframe transport returns the iframe content document as response.
|
147
|
+
// The following adds converters from iframe to text, json, html, and script:
|
148
|
+
$.ajaxSetup({
|
149
|
+
converters: {
|
150
|
+
'iframe text': function (iframe) {
|
151
|
+
return $(iframe[0].body).text();
|
152
|
+
},
|
153
|
+
'iframe json': function (iframe) {
|
154
|
+
return $.parseJSON($(iframe[0].body).text());
|
155
|
+
},
|
156
|
+
'iframe html': function (iframe) {
|
157
|
+
return $(iframe[0].body).html();
|
158
|
+
},
|
159
|
+
'iframe script': function (iframe) {
|
160
|
+
return $.globalEval($(iframe[0].body).text());
|
161
|
+
}
|
162
|
+
}
|
163
|
+
});
|
164
|
+
|
165
|
+
}));
|
@@ -0,0 +1,888 @@
|
|
1
|
+
// ColorBox v1.3.19 - jQuery lightbox plugin
|
2
|
+
// (c) 2011 Jack Moore - jacklmoore.com
|
3
|
+
// License: http://www.opensource.org/licenses/mit-license.php
|
4
|
+
(function ($, document, window) {
|
5
|
+
var
|
6
|
+
// Default settings object.
|
7
|
+
// See http://jacklmoore.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
|
+
reposition: true,
|
38
|
+
loop: true,
|
39
|
+
slideshow: false,
|
40
|
+
slideshowAuto: true,
|
41
|
+
slideshowSpeed: 2500,
|
42
|
+
slideshowStart: "start slideshow",
|
43
|
+
slideshowStop: "stop slideshow",
|
44
|
+
onOpen: false,
|
45
|
+
onLoad: false,
|
46
|
+
onComplete: false,
|
47
|
+
onCleanup: false,
|
48
|
+
onClosed: false,
|
49
|
+
overlayClose: true,
|
50
|
+
escKey: true,
|
51
|
+
arrowKey: true,
|
52
|
+
top: false,
|
53
|
+
bottom: false,
|
54
|
+
left: false,
|
55
|
+
right: false,
|
56
|
+
fixed: false,
|
57
|
+
data: undefined
|
58
|
+
},
|
59
|
+
|
60
|
+
// Abstracting the HTML and event identifiers for easy rebranding
|
61
|
+
colorbox = 'colorbox',
|
62
|
+
prefix = 'cbox',
|
63
|
+
boxElement = prefix + 'Element',
|
64
|
+
|
65
|
+
// Events
|
66
|
+
event_open = prefix + '_open',
|
67
|
+
event_load = prefix + '_load',
|
68
|
+
event_complete = prefix + '_complete',
|
69
|
+
event_cleanup = prefix + '_cleanup',
|
70
|
+
event_closed = prefix + '_closed',
|
71
|
+
event_purge = prefix + '_purge',
|
72
|
+
|
73
|
+
// Special Handling for IE
|
74
|
+
isIE = !$.support.opacity && !$.support.style, // IE7 & IE8
|
75
|
+
isIE6 = isIE && !window.XMLHttpRequest, // IE6
|
76
|
+
event_ie6 = prefix + '_IE6',
|
77
|
+
|
78
|
+
// Cached jQuery Object Variables
|
79
|
+
$overlay,
|
80
|
+
$box,
|
81
|
+
$wrap,
|
82
|
+
$content,
|
83
|
+
$topBorder,
|
84
|
+
$leftBorder,
|
85
|
+
$rightBorder,
|
86
|
+
$bottomBorder,
|
87
|
+
$related,
|
88
|
+
$window,
|
89
|
+
$loaded,
|
90
|
+
$loadingBay,
|
91
|
+
$loadingOverlay,
|
92
|
+
$title,
|
93
|
+
$current,
|
94
|
+
$slideshow,
|
95
|
+
$next,
|
96
|
+
$prev,
|
97
|
+
$close,
|
98
|
+
$groupControls,
|
99
|
+
|
100
|
+
// Variables for cached values or use across multiple functions
|
101
|
+
settings,
|
102
|
+
interfaceHeight,
|
103
|
+
interfaceWidth,
|
104
|
+
loadedHeight,
|
105
|
+
loadedWidth,
|
106
|
+
element,
|
107
|
+
index,
|
108
|
+
photo,
|
109
|
+
open,
|
110
|
+
active,
|
111
|
+
closing,
|
112
|
+
loadingTimer,
|
113
|
+
publicMethod,
|
114
|
+
div = "div",
|
115
|
+
init;
|
116
|
+
|
117
|
+
// ****************
|
118
|
+
// HELPER FUNCTIONS
|
119
|
+
// ****************
|
120
|
+
|
121
|
+
// Convience function for creating new jQuery objects
|
122
|
+
function $tag(tag, id, css) {
|
123
|
+
var element = document.createElement(tag);
|
124
|
+
|
125
|
+
if (id) {
|
126
|
+
element.id = prefix + id;
|
127
|
+
}
|
128
|
+
|
129
|
+
if (css) {
|
130
|
+
element.style.cssText = css;
|
131
|
+
}
|
132
|
+
|
133
|
+
return $(element);
|
134
|
+
}
|
135
|
+
|
136
|
+
// Determine the next and previous members in a group.
|
137
|
+
function getIndex(increment) {
|
138
|
+
var
|
139
|
+
max = $related.length,
|
140
|
+
newIndex = (index + increment) % max;
|
141
|
+
|
142
|
+
return (newIndex < 0) ? max + newIndex : newIndex;
|
143
|
+
}
|
144
|
+
|
145
|
+
// Convert '%' and 'px' values to integers
|
146
|
+
function setSize(size, dimension) {
|
147
|
+
return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : $window.height()) / 100) : 1) * parseInt(size, 10));
|
148
|
+
}
|
149
|
+
|
150
|
+
// Checks an href to see if it is a photo.
|
151
|
+
// There is a force photo option (photo: true) for hrefs that cannot be matched by this regex.
|
152
|
+
function isImage(url) {
|
153
|
+
return settings.photo || /\.(gif|png|jpe?g|bmp|ico)((#|\?).*)?$/i.test(url);
|
154
|
+
}
|
155
|
+
|
156
|
+
// Assigns function results to their respective properties
|
157
|
+
function makeSettings() {
|
158
|
+
var i;
|
159
|
+
settings = $.extend({}, $.data(element, colorbox));
|
160
|
+
|
161
|
+
for (i in settings) {
|
162
|
+
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.
|
163
|
+
settings[i] = settings[i].call(element);
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
settings.rel = settings.rel || element.rel || 'nofollow';
|
168
|
+
settings.href = settings.href || $(element).attr('href');
|
169
|
+
settings.title = settings.title || element.title;
|
170
|
+
|
171
|
+
if (typeof settings.href === "string") {
|
172
|
+
settings.href = $.trim(settings.href);
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
function trigger(event, callback) {
|
177
|
+
$.event.trigger(event);
|
178
|
+
if (callback) {
|
179
|
+
callback.call(element);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
// Slideshow functionality
|
184
|
+
function slideshow() {
|
185
|
+
var
|
186
|
+
timeOut,
|
187
|
+
className = prefix + "Slideshow_",
|
188
|
+
click = "click." + prefix,
|
189
|
+
start,
|
190
|
+
stop,
|
191
|
+
clear;
|
192
|
+
|
193
|
+
if (settings.slideshow && $related[1]) {
|
194
|
+
start = function () {
|
195
|
+
$slideshow
|
196
|
+
.text(settings.slideshowStop)
|
197
|
+
.unbind(click)
|
198
|
+
.bind(event_complete, function () {
|
199
|
+
if (settings.loop || $related[index + 1]) {
|
200
|
+
timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
|
201
|
+
}
|
202
|
+
})
|
203
|
+
.bind(event_load, function () {
|
204
|
+
clearTimeout(timeOut);
|
205
|
+
})
|
206
|
+
.one(click + ' ' + event_cleanup, stop);
|
207
|
+
$box.removeClass(className + "off").addClass(className + "on");
|
208
|
+
timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
|
209
|
+
};
|
210
|
+
|
211
|
+
stop = function () {
|
212
|
+
clearTimeout(timeOut);
|
213
|
+
$slideshow
|
214
|
+
.text(settings.slideshowStart)
|
215
|
+
.unbind([event_complete, event_load, event_cleanup, click].join(' '))
|
216
|
+
.one(click, function () {
|
217
|
+
publicMethod.next();
|
218
|
+
start();
|
219
|
+
});
|
220
|
+
$box.removeClass(className + "on").addClass(className + "off");
|
221
|
+
};
|
222
|
+
|
223
|
+
if (settings.slideshowAuto) {
|
224
|
+
start();
|
225
|
+
} else {
|
226
|
+
stop();
|
227
|
+
}
|
228
|
+
} else {
|
229
|
+
$box.removeClass(className + "off " + className + "on");
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
function launch(target) {
|
234
|
+
if (!closing) {
|
235
|
+
|
236
|
+
element = target;
|
237
|
+
|
238
|
+
makeSettings();
|
239
|
+
|
240
|
+
$related = $(element);
|
241
|
+
|
242
|
+
index = 0;
|
243
|
+
|
244
|
+
if (settings.rel !== 'nofollow') {
|
245
|
+
$related = $('.' + boxElement).filter(function () {
|
246
|
+
var relRelated = $.data(this, colorbox).rel || this.rel;
|
247
|
+
return (relRelated === settings.rel);
|
248
|
+
});
|
249
|
+
index = $related.index(element);
|
250
|
+
|
251
|
+
// Check direct calls to ColorBox.
|
252
|
+
if (index === -1) {
|
253
|
+
$related = $related.add(element);
|
254
|
+
index = $related.length - 1;
|
255
|
+
}
|
256
|
+
}
|
257
|
+
|
258
|
+
if (!open) {
|
259
|
+
open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
|
260
|
+
|
261
|
+
$box.show();
|
262
|
+
|
263
|
+
if (settings.returnFocus) {
|
264
|
+
$(element).blur().one(event_closed, function () {
|
265
|
+
$(this).focus();
|
266
|
+
});
|
267
|
+
}
|
268
|
+
|
269
|
+
// +settings.opacity avoids a problem in IE when using non-zero-prefixed-string-values, like '.5'
|
270
|
+
$overlay.css({"opacity": +settings.opacity, "cursor": settings.overlayClose ? "pointer" : "auto"}).show();
|
271
|
+
|
272
|
+
// Opens inital empty ColorBox prior to content being loaded.
|
273
|
+
settings.w = setSize(settings.initialWidth, 'x');
|
274
|
+
settings.h = setSize(settings.initialHeight, 'y');
|
275
|
+
publicMethod.position();
|
276
|
+
|
277
|
+
if (isIE6) {
|
278
|
+
$window.bind('resize.' + event_ie6 + ' scroll.' + event_ie6, function () {
|
279
|
+
$overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()});
|
280
|
+
}).trigger('resize.' + event_ie6);
|
281
|
+
}
|
282
|
+
|
283
|
+
trigger(event_open, settings.onOpen);
|
284
|
+
|
285
|
+
$groupControls.add($title).hide();
|
286
|
+
|
287
|
+
$close.html(settings.close).show();
|
288
|
+
}
|
289
|
+
|
290
|
+
publicMethod.load(true);
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
// ColorBox's markup needs to be added to the DOM prior to being called
|
295
|
+
// so that the browser will go ahead and load the CSS background images.
|
296
|
+
function appendHTML() {
|
297
|
+
if (!$box && document.body) {
|
298
|
+
init = false;
|
299
|
+
|
300
|
+
$window = $(window);
|
301
|
+
$box = $tag(div).attr({id: colorbox, 'class': isIE ? prefix + (isIE6 ? 'IE6' : 'IE') : ''});
|
302
|
+
$overlay = $tag(div, "Overlay", isIE6 ? 'position:absolute' : '').hide();
|
303
|
+
$wrap = $tag(div, "Wrapper");
|
304
|
+
$content = $tag(div, "Content").append(
|
305
|
+
$loaded = $tag(div, "LoadedContent", 'width:0; height:0; overflow:hidden'),
|
306
|
+
$loadingOverlay = $tag(div, "LoadingOverlay").add($tag(div, "LoadingGraphic")),
|
307
|
+
$title = $tag(div, "Title"),
|
308
|
+
$current = $tag(div, "Current"),
|
309
|
+
$next = $tag(div, "Next"),
|
310
|
+
$prev = $tag(div, "Previous"),
|
311
|
+
$slideshow = $tag(div, "Slideshow").bind(event_open, slideshow),
|
312
|
+
$close = $tag(div, "Close")
|
313
|
+
);
|
314
|
+
|
315
|
+
$wrap.append( // The 3x3 Grid that makes up ColorBox
|
316
|
+
$tag(div).append(
|
317
|
+
$tag(div, "TopLeft"),
|
318
|
+
$topBorder = $tag(div, "TopCenter"),
|
319
|
+
$tag(div, "TopRight")
|
320
|
+
),
|
321
|
+
$tag(div, false, 'clear:left').append(
|
322
|
+
$leftBorder = $tag(div, "MiddleLeft"),
|
323
|
+
$content,
|
324
|
+
$rightBorder = $tag(div, "MiddleRight")
|
325
|
+
),
|
326
|
+
$tag(div, false, 'clear:left').append(
|
327
|
+
$tag(div, "BottomLeft"),
|
328
|
+
$bottomBorder = $tag(div, "BottomCenter"),
|
329
|
+
$tag(div, "BottomRight")
|
330
|
+
)
|
331
|
+
).find('div div').css({'float': 'left'});
|
332
|
+
|
333
|
+
$loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none');
|
334
|
+
|
335
|
+
$groupControls = $next.add($prev).add($current).add($slideshow);
|
336
|
+
|
337
|
+
$(document.body).append($overlay, $box.append($wrap, $loadingBay));
|
338
|
+
}
|
339
|
+
}
|
340
|
+
|
341
|
+
// Add ColorBox's event bindings
|
342
|
+
function addBindings() {
|
343
|
+
if ($box) {
|
344
|
+
if (!init) {
|
345
|
+
init = true;
|
346
|
+
|
347
|
+
// Cache values needed for size calculations
|
348
|
+
interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();//Subtraction needed for IE6
|
349
|
+
interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
|
350
|
+
loadedHeight = $loaded.outerHeight(true);
|
351
|
+
loadedWidth = $loaded.outerWidth(true);
|
352
|
+
|
353
|
+
// Setting padding to remove the need to do size conversions during the animation step.
|
354
|
+
$box.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth}).hide();
|
355
|
+
|
356
|
+
// Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly.
|
357
|
+
$next.click(function () {
|
358
|
+
publicMethod.next();
|
359
|
+
});
|
360
|
+
$prev.click(function () {
|
361
|
+
publicMethod.prev();
|
362
|
+
});
|
363
|
+
$close.click(function () {
|
364
|
+
publicMethod.close();
|
365
|
+
});
|
366
|
+
$overlay.click(function () {
|
367
|
+
if (settings.overlayClose) {
|
368
|
+
publicMethod.close();
|
369
|
+
}
|
370
|
+
});
|
371
|
+
|
372
|
+
// Key Bindings
|
373
|
+
$(document).bind('keydown.' + prefix, function (e) {
|
374
|
+
var key = e.keyCode;
|
375
|
+
if (open && settings.escKey && key === 27) {
|
376
|
+
e.preventDefault();
|
377
|
+
publicMethod.close();
|
378
|
+
}
|
379
|
+
if (open && settings.arrowKey && $related[1]) {
|
380
|
+
if (key === 37) {
|
381
|
+
e.preventDefault();
|
382
|
+
$prev.click();
|
383
|
+
} else if (key === 39) {
|
384
|
+
e.preventDefault();
|
385
|
+
$next.click();
|
386
|
+
}
|
387
|
+
}
|
388
|
+
});
|
389
|
+
|
390
|
+
$('.' + boxElement, document).live('click', function (e) {
|
391
|
+
// ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt.
|
392
|
+
// See: http://jacklmoore.com/notes/click-events/
|
393
|
+
if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey)) {
|
394
|
+
e.preventDefault();
|
395
|
+
launch(this);
|
396
|
+
}
|
397
|
+
});
|
398
|
+
}
|
399
|
+
return true;
|
400
|
+
}
|
401
|
+
return false;
|
402
|
+
}
|
403
|
+
|
404
|
+
// Don't do anything if ColorBox already exists.
|
405
|
+
if ($.colorbox) {
|
406
|
+
return;
|
407
|
+
}
|
408
|
+
|
409
|
+
// Append the HTML when the DOM loads
|
410
|
+
$(appendHTML);
|
411
|
+
|
412
|
+
|
413
|
+
// ****************
|
414
|
+
// PUBLIC FUNCTIONS
|
415
|
+
// Usage format: $.fn.colorbox.close();
|
416
|
+
// Usage from within an iframe: parent.$.fn.colorbox.close();
|
417
|
+
// ****************
|
418
|
+
|
419
|
+
publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
|
420
|
+
var $this = this;
|
421
|
+
|
422
|
+
options = options || {};
|
423
|
+
|
424
|
+
appendHTML();
|
425
|
+
|
426
|
+
if (addBindings()) {
|
427
|
+
if (!$this[0]) {
|
428
|
+
if ($this.selector) { // if a selector was given and it didn't match any elements, go ahead and exit.
|
429
|
+
return $this;
|
430
|
+
}
|
431
|
+
// if no selector was given (ie. $.colorbox()), create a temporary element to work with
|
432
|
+
$this = $('<a/>');
|
433
|
+
options.open = true; // assume an immediate open
|
434
|
+
}
|
435
|
+
|
436
|
+
if (callback) {
|
437
|
+
options.onComplete = callback;
|
438
|
+
}
|
439
|
+
|
440
|
+
$this.each(function () {
|
441
|
+
$.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options));
|
442
|
+
}).addClass(boxElement);
|
443
|
+
|
444
|
+
if (($.isFunction(options.open) && options.open.call($this)) || options.open) {
|
445
|
+
launch($this[0]);
|
446
|
+
}
|
447
|
+
}
|
448
|
+
|
449
|
+
return $this;
|
450
|
+
};
|
451
|
+
|
452
|
+
publicMethod.position = function (speed, loadedCallback) {
|
453
|
+
var
|
454
|
+
top = 0,
|
455
|
+
left = 0,
|
456
|
+
offset = $box.offset(),
|
457
|
+
scrollTop = $window.scrollTop(),
|
458
|
+
scrollLeft = $window.scrollLeft();
|
459
|
+
|
460
|
+
$window.unbind('resize.' + prefix);
|
461
|
+
|
462
|
+
// remove the modal so that it doesn't influence the document width/height
|
463
|
+
$box.css({top: -9e4, left: -9e4});
|
464
|
+
|
465
|
+
if (settings.fixed && !isIE6) {
|
466
|
+
offset.top -= scrollTop;
|
467
|
+
offset.left -= scrollLeft;
|
468
|
+
$box.css({position: 'fixed'});
|
469
|
+
} else {
|
470
|
+
top = scrollTop;
|
471
|
+
left = scrollLeft;
|
472
|
+
$box.css({position: 'absolute'});
|
473
|
+
}
|
474
|
+
|
475
|
+
// keeps the top and left positions within the browser's viewport.
|
476
|
+
if (settings.right !== false) {
|
477
|
+
left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0);
|
478
|
+
} else if (settings.left !== false) {
|
479
|
+
left += setSize(settings.left, 'x');
|
480
|
+
} else {
|
481
|
+
left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2);
|
482
|
+
}
|
483
|
+
|
484
|
+
if (settings.bottom !== false) {
|
485
|
+
top += Math.max($window.height() - settings.h - loadedHeight - interfaceHeight - setSize(settings.bottom, 'y'), 0);
|
486
|
+
} else if (settings.top !== false) {
|
487
|
+
top += setSize(settings.top, 'y');
|
488
|
+
} else {
|
489
|
+
top += Math.round(Math.max($window.height() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
|
490
|
+
}
|
491
|
+
|
492
|
+
$box.css({top: offset.top, left: offset.left});
|
493
|
+
|
494
|
+
// setting the speed to 0 to reduce the delay between same-sized content.
|
495
|
+
speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed || 0;
|
496
|
+
|
497
|
+
// this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
|
498
|
+
// but it has to be shrank down around the size of div#colorbox when it's done. If not,
|
499
|
+
// it can invoke an obscure IE bug when using iframes.
|
500
|
+
$wrap[0].style.width = $wrap[0].style.height = "9999px";
|
501
|
+
|
502
|
+
function modalDimensions(that) {
|
503
|
+
$topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
|
504
|
+
$content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
|
505
|
+
}
|
506
|
+
|
507
|
+
$box.dequeue().animate({width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: top, left: left}, {
|
508
|
+
duration: speed,
|
509
|
+
complete: function () {
|
510
|
+
modalDimensions(this);
|
511
|
+
|
512
|
+
active = false;
|
513
|
+
|
514
|
+
// shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
|
515
|
+
$wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
|
516
|
+
$wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
|
517
|
+
|
518
|
+
if (settings.reposition) {
|
519
|
+
setTimeout(function () { // small delay before binding onresize due to an IE8 bug.
|
520
|
+
$window.bind('resize.' + prefix, publicMethod.position);
|
521
|
+
}, 1);
|
522
|
+
}
|
523
|
+
|
524
|
+
if (loadedCallback) {
|
525
|
+
loadedCallback();
|
526
|
+
}
|
527
|
+
},
|
528
|
+
step: function () {
|
529
|
+
modalDimensions(this);
|
530
|
+
}
|
531
|
+
});
|
532
|
+
};
|
533
|
+
|
534
|
+
publicMethod.resize = function (options) {
|
535
|
+
if (open) {
|
536
|
+
options = options || {};
|
537
|
+
|
538
|
+
if (options.width) {
|
539
|
+
settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth;
|
540
|
+
}
|
541
|
+
if (options.innerWidth) {
|
542
|
+
settings.w = setSize(options.innerWidth, 'x');
|
543
|
+
}
|
544
|
+
$loaded.css({width: settings.w});
|
545
|
+
|
546
|
+
if (options.height) {
|
547
|
+
settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight;
|
548
|
+
}
|
549
|
+
if (options.innerHeight) {
|
550
|
+
settings.h = setSize(options.innerHeight, 'y');
|
551
|
+
}
|
552
|
+
if (!options.innerHeight && !options.height) {
|
553
|
+
$loaded.css({height: "auto"});
|
554
|
+
settings.h = $loaded.height();
|
555
|
+
}
|
556
|
+
$loaded.css({height: settings.h});
|
557
|
+
|
558
|
+
publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
|
559
|
+
}
|
560
|
+
};
|
561
|
+
|
562
|
+
publicMethod.prep = function (object) {
|
563
|
+
if (!open) {
|
564
|
+
return;
|
565
|
+
}
|
566
|
+
|
567
|
+
var callback, speed = settings.transition === "none" ? 0 : settings.speed;
|
568
|
+
|
569
|
+
$loaded.remove();
|
570
|
+
$loaded = $tag(div, 'LoadedContent').append(object);
|
571
|
+
|
572
|
+
function getWidth() {
|
573
|
+
settings.w = settings.w || $loaded.width();
|
574
|
+
settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
|
575
|
+
return settings.w;
|
576
|
+
}
|
577
|
+
function getHeight() {
|
578
|
+
settings.h = settings.h || $loaded.height();
|
579
|
+
settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
|
580
|
+
return settings.h;
|
581
|
+
}
|
582
|
+
|
583
|
+
$loaded.hide()
|
584
|
+
.appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
|
585
|
+
.css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
|
586
|
+
.css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
|
587
|
+
.prependTo($content);
|
588
|
+
|
589
|
+
$loadingBay.hide();
|
590
|
+
|
591
|
+
// 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.
|
592
|
+
//$(photo).css({'float': 'none', marginLeft: 'auto', marginRight: 'auto'});
|
593
|
+
|
594
|
+
$(photo).css({'float': 'none'});
|
595
|
+
|
596
|
+
// Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
|
597
|
+
if (isIE6) {
|
598
|
+
$('select').not($box.find('select')).filter(function () {
|
599
|
+
return this.style.visibility !== 'hidden';
|
600
|
+
}).css({'visibility': 'hidden'}).one(event_cleanup, function () {
|
601
|
+
this.style.visibility = 'inherit';
|
602
|
+
});
|
603
|
+
}
|
604
|
+
|
605
|
+
callback = function () {
|
606
|
+
var preload, i, total = $related.length, iframe, frameBorder = 'frameBorder', allowTransparency = 'allowTransparency', complete, src, img;
|
607
|
+
|
608
|
+
if (!open) {
|
609
|
+
return;
|
610
|
+
}
|
611
|
+
|
612
|
+
function removeFilter() {
|
613
|
+
if (isIE) {
|
614
|
+
$box[0].style.removeAttribute('filter');
|
615
|
+
}
|
616
|
+
}
|
617
|
+
|
618
|
+
complete = function () {
|
619
|
+
clearTimeout(loadingTimer);
|
620
|
+
$loadingOverlay.hide();
|
621
|
+
trigger(event_complete, settings.onComplete);
|
622
|
+
};
|
623
|
+
|
624
|
+
if (isIE) {
|
625
|
+
//This fadeIn helps the bicubic resampling to kick-in.
|
626
|
+
if (photo) {
|
627
|
+
$loaded.fadeIn(100);
|
628
|
+
}
|
629
|
+
}
|
630
|
+
|
631
|
+
$title.html(settings.title).add($loaded).show();
|
632
|
+
|
633
|
+
if (total > 1) { // handle grouping
|
634
|
+
if (typeof settings.current === "string") {
|
635
|
+
$current.html(settings.current.replace('{current}', index + 1).replace('{total}', total)).show();
|
636
|
+
}
|
637
|
+
|
638
|
+
$next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
|
639
|
+
$prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous);
|
640
|
+
|
641
|
+
if (settings.slideshow) {
|
642
|
+
$slideshow.show();
|
643
|
+
}
|
644
|
+
|
645
|
+
// Preloads images within a rel group
|
646
|
+
if (settings.preloading) {
|
647
|
+
preload = [
|
648
|
+
getIndex(-1),
|
649
|
+
getIndex(1)
|
650
|
+
];
|
651
|
+
while (i = $related[preload.pop()]) {
|
652
|
+
src = $.data(i, colorbox).href || i.href;
|
653
|
+
if ($.isFunction(src)) {
|
654
|
+
src = src.call(i);
|
655
|
+
}
|
656
|
+
if (isImage(src)) {
|
657
|
+
img = new Image();
|
658
|
+
img.src = src;
|
659
|
+
}
|
660
|
+
}
|
661
|
+
}
|
662
|
+
} else {
|
663
|
+
$groupControls.hide();
|
664
|
+
}
|
665
|
+
|
666
|
+
if (settings.iframe) {
|
667
|
+
iframe = $tag('iframe')[0];
|
668
|
+
|
669
|
+
if (frameBorder in iframe) {
|
670
|
+
iframe[frameBorder] = 0;
|
671
|
+
}
|
672
|
+
if (allowTransparency in iframe) {
|
673
|
+
iframe[allowTransparency] = "true";
|
674
|
+
}
|
675
|
+
// give the iframe a unique name to prevent caching
|
676
|
+
iframe.name = prefix + (+new Date());
|
677
|
+
if (settings.fastIframe) {
|
678
|
+
complete();
|
679
|
+
} else {
|
680
|
+
$(iframe).one('load', complete);
|
681
|
+
}
|
682
|
+
iframe.src = settings.href;
|
683
|
+
if (!settings.scrolling) {
|
684
|
+
iframe.scrolling = "no";
|
685
|
+
}
|
686
|
+
$(iframe).addClass(prefix + 'Iframe').appendTo($loaded).one(event_purge, function () {
|
687
|
+
iframe.src = "//about:blank";
|
688
|
+
});
|
689
|
+
} else {
|
690
|
+
complete();
|
691
|
+
}
|
692
|
+
|
693
|
+
if (settings.transition === 'fade') {
|
694
|
+
$box.fadeTo(speed, 1, removeFilter);
|
695
|
+
} else {
|
696
|
+
removeFilter();
|
697
|
+
}
|
698
|
+
};
|
699
|
+
|
700
|
+
if (settings.transition === 'fade') {
|
701
|
+
$box.fadeTo(speed, 0, function () {
|
702
|
+
publicMethod.position(0, callback);
|
703
|
+
});
|
704
|
+
} else {
|
705
|
+
publicMethod.position(speed, callback);
|
706
|
+
}
|
707
|
+
};
|
708
|
+
|
709
|
+
publicMethod.load = function (launched) {
|
710
|
+
var href, setResize, prep = publicMethod.prep;
|
711
|
+
|
712
|
+
active = true;
|
713
|
+
|
714
|
+
photo = false;
|
715
|
+
|
716
|
+
element = $related[index];
|
717
|
+
|
718
|
+
if (!launched) {
|
719
|
+
makeSettings();
|
720
|
+
}
|
721
|
+
|
722
|
+
trigger(event_purge);
|
723
|
+
|
724
|
+
trigger(event_load, settings.onLoad);
|
725
|
+
|
726
|
+
settings.h = settings.height ?
|
727
|
+
setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
|
728
|
+
settings.innerHeight && setSize(settings.innerHeight, 'y');
|
729
|
+
|
730
|
+
settings.w = settings.width ?
|
731
|
+
setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
|
732
|
+
settings.innerWidth && setSize(settings.innerWidth, 'x');
|
733
|
+
|
734
|
+
// Sets the minimum dimensions for use in image scaling
|
735
|
+
settings.mw = settings.w;
|
736
|
+
settings.mh = settings.h;
|
737
|
+
|
738
|
+
// Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
|
739
|
+
// If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
|
740
|
+
if (settings.maxWidth) {
|
741
|
+
settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
|
742
|
+
settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
|
743
|
+
}
|
744
|
+
if (settings.maxHeight) {
|
745
|
+
settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
|
746
|
+
settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
|
747
|
+
}
|
748
|
+
|
749
|
+
href = settings.href;
|
750
|
+
|
751
|
+
loadingTimer = setTimeout(function () {
|
752
|
+
$loadingOverlay.show();
|
753
|
+
}, 100);
|
754
|
+
|
755
|
+
if (settings.inline) {
|
756
|
+
// Inserts an empty placeholder where inline content is being pulled from.
|
757
|
+
// An event is bound to put inline content back when ColorBox closes or loads new content.
|
758
|
+
$tag(div).hide().insertBefore($(href)[0]).one(event_purge, function () {
|
759
|
+
$(this).replaceWith($loaded.children());
|
760
|
+
});
|
761
|
+
prep($(href));
|
762
|
+
} else if (settings.iframe) {
|
763
|
+
// IFrame element won't be added to the DOM until it is ready to be displayed,
|
764
|
+
// to avoid problems with DOM-ready JS that might be trying to run in that iframe.
|
765
|
+
prep(" ");
|
766
|
+
} else if (settings.html) {
|
767
|
+
prep(settings.html);
|
768
|
+
} else if (isImage(href)) {
|
769
|
+
$(photo = new Image())
|
770
|
+
.addClass(prefix + 'Photo')
|
771
|
+
.error(function () {
|
772
|
+
settings.title = false;
|
773
|
+
prep($tag(div, 'Error').text('This image could not be loaded'));
|
774
|
+
})
|
775
|
+
.load(function () {
|
776
|
+
var percent;
|
777
|
+
photo.onload = null; //stops animated gifs from firing the onload repeatedly.
|
778
|
+
|
779
|
+
if (settings.scalePhotos) {
|
780
|
+
setResize = function () {
|
781
|
+
photo.height -= photo.height * percent;
|
782
|
+
photo.width -= photo.width * percent;
|
783
|
+
};
|
784
|
+
if (settings.mw && photo.width > settings.mw) {
|
785
|
+
percent = (photo.width - settings.mw) / photo.width;
|
786
|
+
setResize();
|
787
|
+
}
|
788
|
+
if (settings.mh && photo.height > settings.mh) {
|
789
|
+
percent = (photo.height - settings.mh) / photo.height;
|
790
|
+
setResize();
|
791
|
+
}
|
792
|
+
}
|
793
|
+
|
794
|
+
if (settings.h) {
|
795
|
+
photo.style.marginTop = Math.max(settings.h - photo.height, 0) / 2 + 'px';
|
796
|
+
}
|
797
|
+
|
798
|
+
if ($related[1] && (settings.loop || $related[index + 1])) {
|
799
|
+
photo.style.cursor = 'pointer';
|
800
|
+
photo.onclick = function () {
|
801
|
+
publicMethod.next();
|
802
|
+
};
|
803
|
+
}
|
804
|
+
|
805
|
+
if (isIE) {
|
806
|
+
photo.style.msInterpolationMode = 'bicubic';
|
807
|
+
}
|
808
|
+
|
809
|
+
setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise.
|
810
|
+
prep(photo);
|
811
|
+
}, 1);
|
812
|
+
});
|
813
|
+
|
814
|
+
setTimeout(function () { // A pause because Opera 10.6+ will sometimes not run the onload function otherwise.
|
815
|
+
photo.src = href;
|
816
|
+
}, 1);
|
817
|
+
} else if (href) {
|
818
|
+
$loadingBay.load(href, settings.data, function (data, status, xhr) {
|
819
|
+
prep(status === 'error' ? $tag(div, 'Error').text('Request unsuccessful: ' + xhr.statusText) : $(this).contents());
|
820
|
+
});
|
821
|
+
}
|
822
|
+
};
|
823
|
+
|
824
|
+
// Navigates to the next page/image in a set.
|
825
|
+
publicMethod.next = function () {
|
826
|
+
if (!active && $related[1] && (settings.loop || $related[index + 1])) {
|
827
|
+
index = getIndex(1);
|
828
|
+
publicMethod.load();
|
829
|
+
}
|
830
|
+
};
|
831
|
+
|
832
|
+
publicMethod.prev = function () {
|
833
|
+
if (!active && $related[1] && (settings.loop || index)) {
|
834
|
+
index = getIndex(-1);
|
835
|
+
publicMethod.load();
|
836
|
+
}
|
837
|
+
};
|
838
|
+
|
839
|
+
// Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
|
840
|
+
publicMethod.close = function () {
|
841
|
+
if (open && !closing) {
|
842
|
+
|
843
|
+
closing = true;
|
844
|
+
|
845
|
+
open = false;
|
846
|
+
|
847
|
+
trigger(event_cleanup, settings.onCleanup);
|
848
|
+
|
849
|
+
$window.unbind('.' + prefix + ' .' + event_ie6);
|
850
|
+
|
851
|
+
$overlay.fadeTo(200, 0);
|
852
|
+
|
853
|
+
$box.stop().fadeTo(300, 0, function () {
|
854
|
+
|
855
|
+
$box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
|
856
|
+
|
857
|
+
trigger(event_purge);
|
858
|
+
|
859
|
+
$loaded.remove();
|
860
|
+
|
861
|
+
setTimeout(function () {
|
862
|
+
closing = false;
|
863
|
+
trigger(event_closed, settings.onClosed);
|
864
|
+
}, 1);
|
865
|
+
});
|
866
|
+
}
|
867
|
+
};
|
868
|
+
|
869
|
+
// Removes changes ColorBox made to the document, but does not remove the plugin
|
870
|
+
// from jQuery.
|
871
|
+
publicMethod.remove = function () {
|
872
|
+
$([]).add($box).add($overlay).remove();
|
873
|
+
$box = null;
|
874
|
+
$('.' + boxElement)
|
875
|
+
.removeData(colorbox)
|
876
|
+
.removeClass(boxElement)
|
877
|
+
.die();
|
878
|
+
};
|
879
|
+
|
880
|
+
// A method for fetching the current element ColorBox is referencing.
|
881
|
+
// returns a jQuery object.
|
882
|
+
publicMethod.element = function () {
|
883
|
+
return $(element);
|
884
|
+
};
|
885
|
+
|
886
|
+
publicMethod.settings = defaults;
|
887
|
+
|
888
|
+
}(jQuery, document, this));
|