-
Notifications
You must be signed in to change notification settings - Fork 1
/
samplepopup.html
343 lines (254 loc) · 9.31 KB
/
samplepopup.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!-- This code is written by Aarushi Agarwal.A web based image editor using Javascript and Cloudinary services. -->
<!doctype html>
<html>
<head>
<!-- <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> -->
<!-- <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css"> -->
<!-- <link rel="stylesheet" href="./jquery.imgareaselect-0.9.10/css/imgareaselect-animated.css"> -->
<!-- <link rel="stylesheet" href="upload/lightslider-master/src/css/lightslider.css"/> -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="http://10.106.8.119/styleguide/css/combinedStyles.css" rel="stylesheet" />
<link rel="stylesheet" href="http://10.106.8.119/styleguide/css/img_editor/bootstrap.min.css">
<link rel="stylesheet" href="http://10.106.8.119/styleguide/css/img_editor/bootstrap-theme.min.css">
<link rel="stylesheet" href="http://10.106.8.119/styleguide/css/img_editor/imgareaselect-animated.css">
<link rel="stylesheet" href="http://10.106.8.119/styleguide/css/img_editor/lightslider.css"/>
<link rel="stylesheet" href="http://10.106.8.119/styleguide/css/img_editor/sample.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="jquery.cloudinary.js"></script>
<script src="./upload/jquery.imgareaselect-0.9.10/scripts/jquery.imgareaselect.min.js"></script>
<script src="./upload/jquery.imgareaselect-0.9.10/scripts/jquery.imgareaselect.pack.js"></script>
<script src="lightslider-master/src/js/lightslider.js"></script>
</head>
<body>
<h4 style="text-align: center; font-size: 20px; color:blue;"> SAMPLE TEST </h4>
<div style="width: 100%; float: left; text-align: center; padding-top: 30px; margin-top: 20px;">
<button type="button" class="blue" style="font-size: 15px;" onclick="showPopup('pop1');">Click Me!</button>
</div>
<div class="popModal zoom xlarge popShow" id="pop1" style="max-width: 900px;">
<div class="popContent">
<a href="javascript:void(0)" class="fr icon-close font12Lt popClose" onclick="closePopup();"></a>
<h4 class="popHdr" style="text-align: center;">HELLO</h4>
<div class="popBody">
<script>
// Slider styling
$(document).ready(function() {
var slider = $('#image-gallery').lightSlider({
gallery:true,
item:1,
thumbItem:8,
slideMargin: 0,
speed:50,
// auto:true,
loop:false,
keyPress:true,
adaptiveHeight: false,
verticalHeight: 300,
onSliderLoad: function(el) {
container = $(el),
container.find('img').height(300);
container.find('img').width(300);
var num = 1;
image_id = num.toString();
getURl(imgArray[(slider.getCurrentSlideCount() - 1)].src);
$('#image-gallery').removeClass('cS-hidden');
},
onAfterSlide: function()
{
image_id = (slider.getCurrentSlideCount()).toString();
getURl(imgArray[(slider.getCurrentSlideCount() - 1)].src);
}
});
});
</script>
<!-- <h1 align ="center" style="font size:100px" style="font-family:courier;"> Image Editor </h1> -->
<div class="menu">
<ul>
<li><button id="button1" ><img src="icons/rotate_left.jpg" ></button></li>
<li><button id="button2" ><img src="icons/rotate_right.000.jpg" ></button></li>
<li><button id="button3" ><img src="icons/Crop.2.513.jpg" ></button></li>
<li><button id="button4" ><img src="icons/Status_check_mark_yes_circle.04.512.jpg" ></button></li>
<li><button id="button5" ><img src="icons/Status_check_mark_no.512.jpg" ></button></li>
<li><button id="button6" ><img src="icons/undo.000.jpg" ></button></li>
</ul>
</div>
<div class="demo">
<div class="item">
<div class="clearfix">
<ul id="image-gallery" class="gallery list-unstyled cS-hidden">
</ul>
</div>
</div>
</div>
<div class="row" id="parent">
</div>
<script type="text/javascript">
var cloud ; //cloud name for the Cloudinary Account
var string;
var prev_string;
var string_img;
var width;
var height;
var x1;
var y1;
var counter = 0;
var count = 1;
var id;
var image_id;
var scale ="h_300,w_300/" ;
//Set the credetials of the associated cloudinary account
function set_credentials(cloud_name, api_key, api_secret)
{
$.cloudinary.config({
cloud_name: cloud_name,
api_key: api_key,
api_secret: api_secret
});
cloud = cloud_name;
}
//Add image to the slider
function create_thumbnail(src)
{
var li = document.createElement("li");
id = count.toString();
li.setAttribute("data-thumb",src);
let x = document.createElement("IMG");
x.setAttribute("src", src);
x.setAttribute("id", id);
li.appendChild(x);
document.getElementById("image-gallery").appendChild(li);
count = count + 1;
}
//function for uploading the image on cloudinary platform
function upload(parameter1)
{
$.cloudinary.image(parameter1, {type: "fetch"});
}
// Upload the image to cloudinary
function getURl(parameter1)
{
document.getElementById(image_id).src = parameter1;
string = "http://res.cloudinary.com/" + cloud + "/image/fetch/"+scale;
prev_string = string;
string_img = parameter1;
}
//Rotate the image 90 degrees anticlockwise
function rotateleft()
{
if(counter == 0)
{
prev_string = string ;
string = string + "a_"+ 270 +"/" ;
document.getElementById(image_id).src = string + string_img;
var num = parseInt(image_id);
imgArray[num-1].src = document.getElementById(image_id).src ;
}
}
//Rotate the image 90 degrees clockwise
function rotateright()
{
if(counter == 0)
{
prev_string = string ;
string = string + "a_"+ 90 +"/" ;
document.getElementById(image_id).src = string + string_img;
var num = parseInt(image_id);
imgArray[num-1].src = document.getElementById(image_id).src ;
}
}
//Function to select the crop area of image
function crop()
{
$("#"+image_id).imgAreaSelect({
handles: true,
onSelectEnd: function (img, selection)
{
counter = 1;
width = selection.x2 - selection.x1;
height = selection.y2 - selection.y1;
x1 = selection.x1;
y1 = selection.y1;
}
});
}
// Crop the selected area
function accept()
{
if(counter == 1)
{
$('#'+image_id).imgAreaSelect({remove:true});
prev_string = string ;
string = string + "x_"+ x1 + ",y_"+ y1+",w_"+width+",h_"+height+",c_crop/";
document.getElementById(image_id).src = string + string_img;
counter = 0;
var num = parseInt(image_id);
imgArray[num-1].src = document.getElementById(image_id).src ;
}
}
//Deselect the selected cropped area
function cancel()
{
counter = 0;
$('#'+image_id).imgAreaSelect({remove:true});
}
//Take the image to the just previous state
function undo()
{
if(counter==0)
{
document.getElementById(image_id).src = prev_string + string_img;
string = prev_string;
var num = parseInt(image_id);
imgArray[num-1].src = document.getElementById(image_id).src ;
}
}
</script>
<script type="text/javascript">
set_credentials('diukn5sr6', '335317579573276', 'phSrYWbXf_TNYDToLyqzptrnU88');
//Array to contain all the images. Each time we get a new image, store it in imgArray.
var imgArray = new Array();
for(i=0; i<9 ;i++)
{
imgArray[i] = new Image();
if(i%2==0)
{
var src = 'http://res.cloudinary.com/diukn5sr6/image/upload/domokun.jpg';
upload(src);
imgArray[i].src = src ;
create_thumbnail(src) ;
}
else
{
var src = 'http://mdb.ibcdn.com/665f4c54621811e6890f40f2e9694aa0.jfif';
upload(src);
imgArray[i].src = src ;
create_thumbnail(src) ;
}
}
document.getElementById("button1").onclick = function() {rotateleft()}; //var angle = 0 ;
document.getElementById("button2").onclick = function() {rotateright()};
document.getElementById("button3").onclick = function() {crop()};
document.getElementById("button4").onclick = function() {accept()};
document.getElementById("button5").onclick = function() {cancel()};
document.getElementById("button6").onclick = function() {undo()};
</script>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('.popOverlay').click(function(){
closePopup();
});
});
function showPopup(elid){
$('.popOverlay').addClass('popShow');
$('#'+elid+'.popModal').addClass('popShow');
}
function closePopup(){
$('.popOverlay').removeClass('popShow');
$('.popModal').removeClass('popShow');
}
</script>
</body>
</html>