@@ -26,6 +26,8 @@ container_id = '#jquery-fullsizable'
2626image_holder_id = ' #fullsized_image_holder'
2727next_id = ' #fullsized_go_next'
2828prev_id = ' #fullsized_go_prev'
29+ close_id = ' #fullsized_close'
30+ fullscreen_id = ' #fullsized_fullscreen'
2931spinner_class = ' fullsized_spinner'
3032$image_holder = $ (' <div id="jquery-fullsizable"><div id="fullsized_wrapper"><div id="fullsized_holder"><div id="fullsized_image_holder"></div></div></div></div>' )
3133$caption_holder = $ (' <div id="fullsized_caption_holder"></div>' )
@@ -51,11 +53,9 @@ resizeImage = ->
5153keyPressed = (e ) ->
5254 closeViewer () if e .keyCode == 27
5355
54- if e .keyCode == 37
55- prevImage (true )
56-
57- if e .keyCode == 39
58- nextImage (true )
56+ if options .navigation
57+ prevImage (true ) if e .keyCode == 37
58+ nextImage (true ) if e .keyCode == 39
5959
6060prevImage = (shouldHideChrome = false ) ->
6161 if current_image > 0
@@ -152,13 +152,13 @@ makeFullsizable = ->
152152 images .push image
153153
154154 if options .openOnClick
155- $this .click (e) ->
155+ $this .unbind ( " click " ). click (e) ->
156156 e .preventDefault ()
157157 makeFullsizable () if options .reloadOnOpen
158158 openViewer (image, this )
159159
160160prepareCurtain = ->
161- if options .navigation
161+ if options .navigation and $image_holder . find (prev_id). length == 0
162162 $image_holder .append (' <button id="fullsized_go_prev" type="button" title="Previous"></button><button id="fullsized_go_next" type="button" title="Next"></button>' )
163163 $ (document ).on ' click' , prev_id, (e ) ->
164164 e .preventDefault ()
@@ -169,16 +169,16 @@ prepareCurtain = ->
169169 e .stopPropagation ()
170170 nextImage ()
171171
172- if options .closeButton
172+ if options .closeButton and $image_holder . find (close_id). length == 0
173173 $image_holder .append (' <button id="fullsized_close" type="button" title="Close"></button>' )
174- $ (document ).on ' click' , ' #fullsized_close ' , (e ) ->
174+ $ (document ).on ' click' , close_id , (e ) ->
175175 e .preventDefault ()
176176 e .stopPropagation ()
177177 closeViewer ()
178178
179- if options .fullscreenButton and hasFullscreenSupport ()
179+ if options .fullscreenButton and hasFullscreenSupport () and $image_holder . find (fullscreen_id). length == 0
180180 $image_holder .append (' <button id="fullsized_fullscreen" type="button" title="Toggle fullscreen"></button>' )
181- $ (document ).on ' click' , ' #fullsized_fullscreen ' , (e ) ->
181+ $ (document ).on ' click' , fullscreen_id , (e ) ->
182182 e .preventDefault ()
183183 e .stopPropagation ()
184184 toggleFullscreen ()
@@ -193,14 +193,16 @@ prepareCurtain = ->
193193
194194bindCurtainEvents = ->
195195 $ (document ).bind ' keydown' , keyPressed
196- $ (document ).bind ' fullsizable:next' , -> nextImage (true )
197- $ (document ).bind ' fullsizable:prev' , -> prevImage (true )
196+ if options .navigation
197+ $ (document ).bind ' fullsizable:next' , -> nextImage (true )
198+ $ (document ).bind ' fullsizable:prev' , -> prevImage (true )
198199 $ (document ).bind ' fullsizable:close' , closeViewer
199200
200201unbindCurtainEvents = ->
201202 $ (document ).unbind ' keydown' , keyPressed
202- $ (document ).unbind ' fullsizable:next'
203- $ (document ).unbind ' fullsizable:prev'
203+ if options .navigation
204+ $ (document ).unbind ' fullsizable:next'
205+ $ (document ).unbind ' fullsizable:prev'
204206 $ (document ).unbind ' fullsizable:close'
205207
206208hideChrome = ->
@@ -221,7 +223,7 @@ mouseMovement = (event) ->
221223
222224showChrome = ->
223225 $caption_holder .toggle (true );
224- $ (' #fullsized_close, #fullsized_fullscreen ' ).toggle (true )
226+ $ (close_id + ' , ' + fullscreen_id ).toggle (true )
225227 if options .loop
226228 $ (prev_id).show ()
227229 $ (next_id).show ()
0 commit comments