This repository has been archived by the owner on Sep 24, 2021. It is now read-only.
/
view.js
58 lines (49 loc) · 1.56 KB
/
view.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function View() { this.initialize.apply(this, _slice.call(arguments)); }
$.extend(View.prototype, {
initialize: function(object) {
var options = arguments[1] || {},
data = {};
// string -> element
if ($.type(object) === 'string') {
// turn the string into an element
object = { url: object };
}
// element -> object
else if (object && object.nodeType === 1) {
var element = $(object);
object = {
element: element[0],
url: element.attr('href'),
caption: element.attr('data-strip-caption'),
group: element.attr('data-strip-group'),
extension: element.attr('data-strip-extension'),
type: element.attr('data-strip-type'),
options: (element.attr('data-strip-options') && eval('({' + element.attr('data-strip-options') + '})')) || {}
};
}
if (object) {
// detect type if none is set
if (!object.extension) {
object.extension = detectExtension(object.url);
}
if (!object.type) {
var data = getURIData(object.url);
object._data = data;
object.type = data.type;
}
}
if (!object._data) {
object._data = getURIData(object.url);
}
if (object && object.options) {
object.options = $.extend(true, $.extend({}, options), $.extend({}, object.options));
} else {
object.options = $.extend({}, options);
}
// extend the options
object.options = Options.create(object.options, object.type, object._data);
// extend this with data
$.extend(this, object);
return this;
}
});