| 25380 |
amit.gupta |
1 |
<style>
|
|
|
2 |
.table-striped > tbody > tr:nth-child(odd) > td{
|
|
|
3 |
background: white;
|
|
|
4 |
background-color: white;
|
|
|
5 |
}
|
|
|
6 |
.table-striped > tbody > tr:nth-child(even) > td{
|
|
|
7 |
background: white;
|
|
|
8 |
background-color:white;
|
|
|
9 |
}
|
|
|
10 |
.table-striped > tbody > tr:hover > td,
|
|
|
11 |
.table-striped > tbody > tr:hover {
|
|
|
12 |
background-color: #e98c8f;
|
|
|
13 |
color:white;
|
|
|
14 |
}
|
|
|
15 |
.btn:hover{
|
|
|
16 |
color: grey;
|
|
|
17 |
text-decoration: none;
|
|
|
18 |
}
|
|
|
19 |
.btn-primary:hover{
|
|
|
20 |
color: grey;
|
|
|
21 |
text-decoration: none;
|
|
|
22 |
}
|
|
|
23 |
.thumb-image-container{
|
|
|
24 |
float:left;position:relative;padding:5px;
|
|
|
25 |
}
|
|
|
26 |
.thumb-image{
|
|
|
27 |
float:left;width:250px;position:relative;padding:5px;
|
|
|
28 |
}
|
|
|
29 |
.selectedItem{border:2px solid blue;}
|
|
|
30 |
</style>
|
|
|
31 |
|
|
|
32 |
<section class="wrapper">
|
|
|
33 |
<div class="row">
|
|
|
34 |
<div class="col-lg-12">
|
|
|
35 |
<h3 class="page-header"><i class="icon_document_alt"></i>CONTENT</h3>
|
|
|
36 |
<ol class="breadcrumb">
|
|
|
37 |
<li><i class="fa fa-home"></i><a href="${rc.contextPath}/dashboard">Home</a></li>
|
|
|
38 |
<li><i class="icon_document_alt"></i>CONTENT</li>
|
|
|
39 |
</ol>
|
|
|
40 |
</div>
|
|
|
41 |
</div>
|
|
|
42 |
<div id="upload-table">
|
|
|
43 |
<div class="row">
|
|
|
44 |
<form class="form-horizontal">
|
|
|
45 |
<label class="control-label col-sm-2" for="excelfile">CSV File:</label>
|
|
|
46 |
<div class="col-lg-3">
|
|
|
47 |
<div class="input-group">
|
|
|
48 |
<input class="form-control" type="file" id="entityupload" name="uploadfile" value="Upload Images">
|
|
|
49 |
<span class="input-group-btn">
|
|
|
50 |
<button class="btn btn-default entityfileupload">
|
|
|
51 |
Uplaod
|
|
|
52 |
</button>
|
|
|
53 |
</span>
|
|
|
54 |
</div>
|
|
|
55 |
</div>
|
|
|
56 |
<div class="col-lg-2">
|
|
|
57 |
<a class="btn btn-default" href="${rc.contextPath}/content/template.csv">
|
|
|
58 |
Download Tempate
|
|
|
59 |
</a>
|
|
|
60 |
</div>
|
|
|
61 |
</form>
|
|
|
62 |
</div>
|
|
|
63 |
</div>
|
|
|
64 |
<div id="wrapper" style="margin-top: 20px;" class="row">
|
|
|
65 |
<form class="form-horizontal" id="mediaForm" method="POST" action="content/media/upload" enctype="multipart/form-data">
|
|
|
66 |
<div class="row container">
|
|
|
67 |
<div class="col-lg-4">
|
|
|
68 |
<div class="input-group">
|
|
|
69 |
<input type="text" class="form-control typeahead" id="entityData" placeholder="Search for Entity">
|
|
|
70 |
<span class="input-group-btn">
|
|
|
71 |
<button id="loadImages" class="btn btn-default" type="button">Load Images</button>
|
|
|
72 |
</span>
|
|
|
73 |
</div><!-- /input-group -->
|
|
|
74 |
</div><!-- /.col-lg-6 -->
|
|
|
75 |
<div class="col-lg-3">
|
|
|
76 |
<div>
|
|
|
77 |
<input id="fileUpload" multiple="multiple" type="file" class="form-control"/>
|
|
|
78 |
</div>
|
|
|
79 |
</div>
|
|
|
80 |
<div class="col-lg-2">
|
|
|
81 |
<input type="submit" class="btn btn-default" value="Upload Images">
|
|
|
82 |
</div>
|
|
|
83 |
<div class="col-lg-2">
|
|
|
84 |
<button id="btnDelete" class="btn btn-default">Delete Selected</button>
|
|
|
85 |
</div>
|
|
|
86 |
</div>
|
|
|
87 |
<div id="image-holder">
|
|
|
88 |
</div>
|
|
|
89 |
</form>
|
|
|
90 |
</div>
|
|
|
91 |
</section>
|
|
|
92 |
<script type="text/javascript">
|
|
|
93 |
$(document).ready(function(){
|
|
|
94 |
$('button.entityfileupload').on('click', function() {
|
|
|
95 |
var fileSelector = $('#entityupload')[0];
|
|
|
96 |
if(fileSelector != undefined && fileSelector.files[0] != undefined) {
|
|
|
97 |
if(confirm("Confirm Upload?")) {
|
|
|
98 |
doAjaxUploadRequestHandler("${rc.contextPath}/content/upload", "POST", fileSelector.files[0], function(response){
|
|
|
99 |
if(response) {
|
|
|
100 |
alert("Content updated successfully");
|
|
|
101 |
}
|
|
|
102 |
});
|
|
|
103 |
}
|
|
|
104 |
} else {
|
|
|
105 |
alert("Please upload file!");
|
|
|
106 |
}
|
|
|
107 |
return false;
|
|
|
108 |
});
|
|
|
109 |
});
|
|
|
110 |
$(document).ready(function() {
|
|
|
111 |
$("#image-holder").on('click','.thumb-image',function(){
|
|
|
112 |
$(this).closest('.thumb-image-container').toggleClass("selectedItem");
|
|
|
113 |
});
|
|
|
114 |
$("#btnDelete").on("click",function(){
|
|
|
115 |
$(".selectedItem").remove();
|
|
|
116 |
return false;
|
|
|
117 |
});
|
|
|
118 |
$("#loadImages").on('click', function() {
|
|
|
119 |
doGetAjaxRequestHandler(context + "/content/media?entityId=" + entityId, function(response) {
|
|
|
120 |
debugger;
|
| 25415 |
amit.gupta |
121 |
if(response){
|
|
|
122 |
response = JSON.parse(response);
|
| 25416 |
amit.gupta |
123 |
response.mediaPojos.each(function(index, value){
|
| 25415 |
amit.gupta |
124 |
var checked = index==response.defaultImageIndex;
|
|
|
125 |
var reader = new FileReader();
|
|
|
126 |
reader.value = value;
|
|
|
127 |
reader.checked = checked;
|
|
|
128 |
reader.onload = function(e) {
|
|
|
129 |
var divObj =
|
|
|
130 |
$(`<div class="thumb-image-container">
|
|
|
131 |
<div class="radio">
|
|
|
132 |
<label>
|
|
|
133 |
<input type="radio" name="optionsRadios">
|
|
|
134 |
Set as default
|
|
|
135 |
</label>
|
|
|
136 |
</div>
|
|
|
137 |
<div><input type="text" name="descriptions[]" placeholder="Image Description"/></div>
|
|
|
138 |
</div>`).appendTo(image_holder);
|
|
|
139 |
$("<img />", {
|
|
|
140 |
"src": e.target.result,
|
|
|
141 |
"class": "thumb-image"
|
|
|
142 |
}).appendTo(divObj);
|
|
|
143 |
divObj.find('input[type=text]').val(this.value.title);
|
|
|
144 |
divObj.find('input:radio').prop("checked", checked);
|
|
|
145 |
}
|
|
|
146 |
reader.readAsDataURL(value.url);
|
| 25416 |
amit.gupta |
147 |
});
|
| 25380 |
amit.gupta |
148 |
}
|
|
|
149 |
});
|
|
|
150 |
});
|
|
|
151 |
$("#mediaForm").on("submit",function(){
|
|
|
152 |
debugger;
|
|
|
153 |
returnedValue="";
|
|
|
154 |
if(!$("input:radio[name='optionsRadios']").is(":checked")){
|
|
|
155 |
alert("Please check default image!");
|
|
|
156 |
} else if(confirm("Are you sure?")) {
|
|
|
157 |
var jsonObject = {};
|
|
|
158 |
jsonObject.entityId = entityId;
|
|
|
159 |
jsonObject.mediaPojos = [];
|
|
|
160 |
$('#image-holder .thumb-image-container').each(function(index, ele){
|
|
|
161 |
var title = $(ele).find("input:text").val().trim();
|
|
|
162 |
if(title.length == 0) {
|
|
|
163 |
alert("Descriptions are required!");
|
|
|
164 |
} else {
|
|
|
165 |
var mediaPojo={};
|
|
|
166 |
mediaPojo.title = title;
|
|
|
167 |
mediaPojo.imageData = $(ele).find("img").attr("src");
|
|
|
168 |
debugger;
|
|
|
169 |
jsonObject.mediaPojos.push(mediaPojo);
|
|
|
170 |
if($(ele).find("input:radio:checked").length>0) {
|
|
|
171 |
jsonObject.defaultImageIndex = index;
|
|
|
172 |
}
|
|
|
173 |
}
|
|
|
174 |
});
|
|
|
175 |
doPostAjaxRequestWithJsonHandler("/content/media/upload", JSON.stringify(jsonObject), function(response){
|
|
|
176 |
bootbox.alert("Images uploaded successfully");
|
|
|
177 |
});
|
|
|
178 |
|
|
|
179 |
}
|
|
|
180 |
$(".selectedItem");
|
|
|
181 |
return false;
|
|
|
182 |
});
|
|
|
183 |
|
|
|
184 |
$("#fileUpload").on('change', function() {
|
|
|
185 |
//Get count of selected files
|
|
|
186 |
var countFiles = this.files.length;
|
|
|
187 |
var imgPath = this.value;
|
|
|
188 |
var extn = imgPath.substring(imgPath.lastIndexOf('.') + 1).toLowerCase();
|
|
|
189 |
var image_holder = $("#image-holder");
|
|
|
190 |
image_holder.remove(".new");
|
|
|
191 |
if (extn == "gif" || extn == "png" || extn == "jpg" || extn == "jpeg") {
|
|
|
192 |
if (typeof(FileReader) != "undefined") {
|
|
|
193 |
//loop for each file selected for uploaded.
|
|
|
194 |
for (var i = 0; i < countFiles; i++)
|
|
|
195 |
{
|
|
|
196 |
var reader = new FileReader();
|
|
|
197 |
var filename = this.files[i].name
|
|
|
198 |
reader.description = filename.substring(0, filename.lastIndexOf('.'));
|
|
|
199 |
reader.onload = function(e) {
|
|
|
200 |
var divObj =
|
|
|
201 |
$(`<div class="thumb-image-container new">
|
|
|
202 |
<div class="radio">
|
|
|
203 |
<label>
|
|
|
204 |
<input type="radio" name="optionsRadios">
|
|
|
205 |
Set as default
|
|
|
206 |
</label>
|
|
|
207 |
</div>
|
|
|
208 |
<div><input type="text" name="descriptions[]" placeholder="Image Description"/></div>
|
|
|
209 |
</div>`).appendTo(image_holder);
|
|
|
210 |
$("<img />", {
|
|
|
211 |
"src": e.target.result,
|
|
|
212 |
"class": "thumb-image"
|
|
|
213 |
}).appendTo(divObj);
|
|
|
214 |
divObj.find('input[type=text]').val(this.description);
|
|
|
215 |
}
|
|
|
216 |
reader.readAsDataURL(this.files[i]);
|
|
|
217 |
}
|
|
|
218 |
} else {
|
|
|
219 |
alert("This browser does not support FileReader.");
|
|
|
220 |
}
|
|
|
221 |
}
|
|
|
222 |
else {
|
|
|
223 |
alert("Pls select only images");
|
|
|
224 |
}
|
|
|
225 |
});
|
|
|
226 |
getEntityAheadOptions($("#entityData"), function(selectedEntity){
|
|
|
227 |
entityId = selectedEntity.catalogId_i;
|
|
|
228 |
});
|
|
|
229 |
});
|
|
|
230 |
</script>
|
|
|
231 |
|