|
195 | 195 | var wrappedElement = $(element).css("position", "absolute");
|
196 | 196 | createImageSlideControls(element, wrappedElement.parent(), settings);
|
197 | 197 | debug(settings.debug, "Setting timeout for element [" + element + "]");
|
| 198 | + updateCurrentSlideElement(settings, settings.current); |
198 | 199 | settings.timerId = setTimeout(timeoutEvent, settings.transitionDelay, element, settings);
|
199 | 200 | }
|
200 | 201 |
|
|
226 | 227 | var imageOffset = parseInt(id.match(/-image(\d+)/)[1]);
|
227 | 228 | settings.current = imageOffset + 1;
|
228 | 229 | $(element).css("background-image", "url(" + settings.images[imageOffset] + ")");
|
| 230 | + updateCurrentSlideElement(settings, settings.current - 1); |
229 | 231 | console.log("clicked on [" + $(this).attr("id") + "]");
|
230 | 232 | });
|
231 | 233 | }
|
232 | 234 | }
|
233 | 235 |
|
| 236 | + /** |
| 237 | + * Given an element, if it has a id attribute, then return it otherwise create a unique |
| 238 | + * id and return it. |
| 239 | + */ |
234 | 240 | function getUniqueId(element) {
|
235 | 241 | var id = $(element).attr("id");
|
236 | 242 | if (!id) {
|
|
239 | 245 | return id;
|
240 | 246 | }
|
241 | 247 |
|
| 248 | + /** |
| 249 | + * Generate a unique id based on random character and current date in ms. |
| 250 | + */ |
242 | 251 | function generateUniqueId() {
|
243 | 252 | var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
244 | 253 | var rval = characters.charAt(Math.floor(Math.random() * characters.length)) + Date.now();
|
|
310 | 319 | if (settings.eventHandlers.afterChange) {
|
311 | 320 | settings.eventHandlers.afterChange(element, settings, nextImage);
|
312 | 321 | }
|
| 322 | + updateCurrentSlideElement(settings, settings.current); |
313 | 323 | settings.timerId = setTimeout(timeoutEvent, settings.transitionDelay, element, settings);
|
314 | 324 | });
|
315 | 325 | }
|
316 | 326 |
|
| 327 | + function updateCurrentSlideElement(settings, current) { |
| 328 | + if (settings.slideControls.enabled) { |
| 329 | + var id = "#" + settings.uniqueId + "-image" + current; |
| 330 | + $("[id^='" + settings.uniqueId + "-image']").removeClass("jquery-bg-slideshow-list-control-image-active-element"); |
| 331 | + $(id).addClass("jquery-bg-slideshow-list-control-image-active-element"); |
| 332 | + } |
| 333 | + } |
| 334 | + |
317 | 335 | /**
|
318 | 336 | * Preload all of the images so that there will be no delay in showing
|
319 | 337 | * the background.
|
|
0 commit comments