|
134 | 134 | var item = items[i]; |
135 | 135 |
|
136 | 136 | var li = $('<li></li>'); |
| 137 | + var leftColumn = $('<div class="left-column"></div>'); |
| 138 | + li.append(leftColumn); |
| 139 | + var rightColumn = $('<div class="right-column"></div>'); |
| 140 | + li.append(rightColumn); |
137 | 141 |
|
138 | 142 | // description |
139 | 143 | var description = item.description; |
|
146 | 150 | // link |
147 | 151 | var uri = item.documentBadge.uri; |
148 | 152 | var link = $('<a href="' + uri + '" target="_blank" title="' + description + '"></a>'); |
149 | | - li.append(link); |
| 153 | + leftColumn.append(link); |
150 | 154 |
|
151 | 155 | // item containers |
152 | 156 | var contentDiv = $('<div class="result-content"></div>'); |
|
163 | 167 | } |
164 | 168 | contentDiv.append($('<span class="result-title">' + title + '</span>')); |
165 | 169 |
|
| 170 | + // insert link buttons |
| 171 | + var insertAsLinkButton = $( |
| 172 | + '<div class="image-button">' + |
| 173 | + '<img title="<?!= msg('SEARCH_RESULT_LIST_INSERT_LINK') ?>" src="http://www.dimis.fim.uni-passau.de/eexcess/link.png">' + |
| 174 | + '</div>'); |
| 175 | + insertAsLinkButton.data('uri', uri); |
| 176 | + insertAsLinkButton.data('title', title); |
| 177 | + insertAsLinkButton.click(function() { |
| 178 | + google.script.run.insertLink($(this).data('uri'), $(this).data('title')); |
| 179 | + }); |
| 180 | + rightColumn.append(insertAsLinkButton); |
| 181 | + |
166 | 182 | // type |
167 | 183 | var mediaType = item.mediaType; |
168 | 184 | if (typeof mediaType === 'undefined' || mediaType === '') { |
|
176 | 192 | var image = item.previewImage; |
177 | 193 | if (typeof image === 'undefined' || image === '') { |
178 | 194 | image = "http://eexcess-dev.joanneum.at/eexcess-federated-recommender-web-service-1.0-SNAPSHOT/recommender/getPreviewImage?type=" + mediaType; |
179 | | - } else { // add item to image gallery |
| 195 | + } else { // add item to image gallery and insert button |
180 | 196 | this._addImageToGallery(image, title, uri); |
| 197 | + |
| 198 | + // insert image button |
| 199 | + var insertImageButton = $( |
| 200 | + '<div class="image-button result-btn-insert-image">' + |
| 201 | + '<img title="<?!= msg('SEARCH_RESULT_LIST_INSERT_IMAGE') ?>" src="http://www.dimis.fim.uni-passau.de/eexcess/photo.png">' + |
| 202 | + '</div>'); |
| 203 | + insertImageButton.data('uri', image); |
| 204 | + insertImageButton.click(function() { |
| 205 | + google.script.run.insertImage($(this).data('uri')); |
| 206 | + }); |
| 207 | + rightColumn.append(insertImageButton); |
181 | 208 | } |
182 | 209 | var img = $('<img align="left" class="result-image" mediatype="' + mediaType + '" src="' + image + '"/>'); |
183 | 210 | contentDiv.prepend(img); |
|
279 | 306 | * @param uri recommendation's uri |
280 | 307 | */ |
281 | 308 | SearchResultList.prototype._addImageToGallery = function(image, title, uri) { |
| 309 | + var div = $('<div class="gallery-item"></div>'); |
| 310 | + |
| 311 | + // add image |
282 | 312 | var link = $('<a title="<?!= msg('SEARCH_RESULT_LIST_TITLE') ?>:\n' + title + '" href="' + uri + '" target="_blank"></a>'); |
| 313 | + div.append(link); |
283 | 314 | var img = document.createElement('img'); |
284 | 315 | img.className = 'gallery-img'; |
285 | 316 | link.append(img); |
286 | 317 |
|
287 | 318 | var _this = this; |
288 | 319 | img.onload = function(){ |
289 | 320 | if (_this._galleryLeftHeight > _this._galleryRightHeight) { |
290 | | - _this._galleryRight.append(link); |
| 321 | + _this._galleryRight.append(div); |
291 | 322 | _this._galleryRightHeight += this.height; |
292 | 323 | } else { |
293 | | - _this._galleryLeft.append(link); |
| 324 | + _this._galleryLeft.append(div); |
294 | 325 | _this._galleryLeftHeight += this.height; |
295 | 326 | } |
296 | 327 | }; |
297 | 328 |
|
298 | 329 | img.src = image; |
| 330 | + |
| 331 | + // add insert button |
| 332 | + var insertButton = $( |
| 333 | + '<div class="image-button gallery-btn-insert-image">' + |
| 334 | + '<img title="<?!= msg('SEARCH_RESULT_LIST_INSERT_IMAGE') ?>" src="http://www.dimis.fim.uni-passau.de/eexcess/photo.png">' + |
| 335 | + '</div>'); |
| 336 | + insertButton.data('uri', image); |
| 337 | + insertButton.click(function() { |
| 338 | + google.script.run.insertImage($(this).data('uri')); |
| 339 | + }); |
| 340 | + div.append(insertButton); |
299 | 341 | }; |
300 | 342 |
|
301 | 343 | /** |
|
0 commit comments