forked from stephan-fischer/jQuery-LiveUrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
178 lines (145 loc) · 7.68 KB
/
index.html
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="description" content="" />
<meta name="author" content="Stephan Fischer" />
<title>Live Url</title>
<link rel="stylesheet" href="liveurl.css" />
</head>
<body>
<textarea style="width: 300px; height: 100px;" placeholder="write here"></textarea>
<div class="liveurl-loader"></div>
<div class="liveurl">
<div class="close" title="Entfernen"></div>
<div class="inner">
<div class="image"> </div>
<div class="details">
<div class="info">
<div class="title"> </div>
<div class="description"> </div>
<div class="url"> </div>
</div>
<div class="thumbnail">
<div class="pictures">
<div class="controls">
<div class="prev button inactive"></div>
<div class="next button inactive"></div>
<div class="count">
<span class="current">0</span><span> von </span><span class="max">0</span>
</div>
</div>
</div>
</div>
<div class="video"></div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" > </script>
<script src="jquery.liveurl.js"> </script>
<script>
var curImages = new Array();
$('textarea').liveUrl({
loadStart : function(){
$('.liveurl-loader').show();
},
loadEnd : function(){
$('.liveurl-loader').hide();
},
success : function(data)
{
var output = $('.liveurl');
output.find('.title').text(data.title);
output.find('.description').text(data.description);
output.find('.url').text(data.url);
output.find('.image').empty();
output.find('.close').one('click', function()
{
var liveUrl = $(this).parent();
liveUrl.hide('fast');
liveUrl.find('.video').html('').hide();
liveUrl.find('.image').html('');
liveUrl.find('.controls .prev').addClass('inactive');
liveUrl.find('.controls .next').addClass('inactive');
liveUrl.find('.thumbnail').hide();
liveUrl.find('.image').hide();
$('textarea').trigger('clear');
curImages = new Array();
});
output.show('fast');
if (data.video != null) {
var ratioW = data.video.width /350;
data.video.width = 350;
data.video.height = data.video.height / ratioW;
var video =
'<object width="' + data.video.width + '" height="' + data.video.height + '">' +
'<param name="movie"' +
'value="' + data.video.file + '"></param>' +
'<param name="allowScriptAccess" value="always"></param>' +
'<embed src="' + data.video.file + '"' +
'type="application/x-shockwave-flash"' +
'allowscriptaccess="always"' +
'width="' + data.video.width + '" height="' + data.video.height + '"></embed>' +
'</object>';
output.find('.video').html(video).show();
}
},
addImage : function(image)
{
var output = $('.liveurl');
var jqImage = $(image);
jqImage.attr('alt', 'Preview');
if ((image.width / image.height) > 7
|| (image.height / image.width) > 4 ) {
// we dont want extra large images...
return false;
}
curImages.push(jqImage.attr('src'));
output.find('.image').append(jqImage);
if (curImages.length == 1) {
// first image...
output.find('.thumbnail .current').text('1');
output.find('.thumbnail').show();
output.find('.image').show();
jqImage.addClass('active');
}
if (curImages.length == 2) {
output.find('.controls .next').removeClass('inactive');
}
output.find('.thumbnail .max').text(curImages.length);
}
});
$('.liveurl ').on('click', '.controls .button', function()
{
var self = $(this);
var liveUrl = $(this).parents('.liveurl');
var content = liveUrl.find('.image');
var images = $('img', content);
var activeImage = $('img.active', content);
if (self.hasClass('next'))
var elem = activeImage.next("img");
else var elem = activeImage.prev("img");
if (elem.length > 0) {
activeImage.removeClass('active');
elem.addClass('active');
liveUrl.find('.thumbnail .current').text(elem.index() +1);
if (elem.index() +1 == images.length || elem.index()+1 == 1) {
self.addClass('inactive');
}
}
if (self.hasClass('next'))
var other = elem.prev("img");
else var other = elem.next("img");
if (other.length > 0) {
if (self.hasClass('next'))
self.prev().removeClass('inactive');
else self.next().removeClass('inactive');
} else {
if (self.hasClass('next'))
self.prev().addClass('inactive');
else self.next().addClass('inactive');
}
});
</script>
</body>
</html>