@@ -86,7 +86,7 @@ var ZoomerPrototype = function()
8686 this . _set_up_overlay_ele = function ( )
8787 {
8888 this . _overlay_ele = document . createElement ( "div" ) ;
89- this . _overlay_ele . classList . add ( "zoomer-overlay" ) ;
89+ this . _overlay_ele . className = "zoomer-overlay" ;
9090 this . _overlay_handle_left_ele = document . createElement ( "div" ) ;
9191 this . _overlay_handle_right_ele = document . createElement ( "div" ) ;
9292 this . _overlay_handle_left_ele . className = "zoomer-overlay-handle zoomer-overlay-handle-left" ;
@@ -132,7 +132,7 @@ var ZoomerPrototype = function()
132132
133133 this . zoomer_ele_onmousemove = function ( event )
134134 {
135- this . _zoomer_ele . classList . add ( "overlay-size-change" ) ;
135+ document . documentElement . classList . add ( "overlay-size-change" ) ;
136136 var mouse_x = event . clientX - this . _zoomer_ele_left ;
137137 var diff = mouse_x - this . _overlay_start_left ;
138138 if ( diff < 0 )
@@ -164,7 +164,7 @@ var ZoomerPrototype = function()
164164
165165 this . zoomer_ele_onmouseup = function ( event )
166166 {
167- this . _zoomer_ele . classList . remove ( "overlay-size-change" ) ;
167+ document . documentElement . classList . remove ( "overlay-size-change" ) ;
168168 document . removeEventListener ( "mousemove" ,
169169 this . _zoomer_ele_onmousemove_bound ) ;
170170 document . removeEventListener ( "mouseup" ,
@@ -213,7 +213,7 @@ var ZoomerPrototype = function()
213213 {
214214 if ( event . which != 1 )
215215 return ;
216- this . _zoomer_ele . classList . add ( "overlay-drag" ) ;
216+ document . documentElement . classList . add ( "overlay-drag" ) ;
217217 document . addEventListener ( "mousemove" ,
218218 this . _overlay_ele_onmousemove_bound ) ;
219219 document . addEventListener ( "mouseup" ,
@@ -269,7 +269,7 @@ var ZoomerPrototype = function()
269269
270270 this . overlay_ele_onmouseup = function ( event )
271271 {
272- this . _zoomer_ele . classList . remove ( "overlay-drag" ) ;
272+ document . documentElement . classList . remove ( "overlay-drag" ) ;
273273 document . removeEventListener ( "mousemove" ,
274274 this . _overlay_ele_onmousemove_bound ) ;
275275 document . removeEventListener ( "mouseup" ,
@@ -286,7 +286,7 @@ var ZoomerPrototype = function()
286286 {
287287 if ( event . which != 1 )
288288 return ;
289- this . _zoomer_ele . classList . add ( "overlay-size-change" ) ;
289+ document . documentElement . classList . add ( "overlay-size-change" ) ;
290290 document . addEventListener ( "mousemove" ,
291291 this . _overlay_handle_ele_onmousemove_bound ) ;
292292 document . addEventListener ( "mouseup" ,
@@ -365,7 +365,7 @@ var ZoomerPrototype = function()
365365
366366 this . overlay_handle_ele_onmouseup = function ( event )
367367 {
368- this . _zoomer_ele . classList . remove ( "overlay-size-change" ) ;
368+ document . documentElement . classList . remove ( "overlay-size-change" ) ;
369369 document . removeEventListener ( "mousemove" ,
370370 this . _overlay_handle_ele_onmousemove_bound ) ;
371371 document . removeEventListener ( "mouseup" ,
@@ -387,7 +387,7 @@ var ZoomerPrototype = function()
387387 var time_since_last_update = now - this . _last_update ;
388388 if ( time_since_last_update > UPDATE_THRESHOLD )
389389 {
390- var ms_unit = this . _model_duration / this . _model_ele_width ;
390+ var ms_unit = this . _model . get_duration ( ) / this . _model . get_model_element_width ( ) ;
391391 var x0 = this . _overlay_left * ms_unit ;
392392 var x1 = this . _to_right_x ( this . _overlay_right ) * ms_unit ;
393393 this . _model . set_area ( x0 , x1 ) ;
@@ -397,7 +397,7 @@ var ZoomerPrototype = function()
397397 // Set a timeout to set the area. This makes sure that the last update
398398 // always happens, even if it was within the UPDATE_THRESHOLD.
399399 this . _update_timeout = window . setTimeout ( function ( ) {
400- var ms_unit = this . _model_duration / this . _model_ele_width ;
400+ var ms_unit = this . _model . get_duration ( ) / this . _model . get_model_element_width ( ) ;
401401 var x0 = this . _overlay_left * ms_unit ;
402402 var x1 = this . _to_right_x ( this . _overlay_right ) * ms_unit ;
403403 this . _model . set_area ( x0 , x1 ) ;
@@ -409,7 +409,7 @@ var ZoomerPrototype = function()
409409 // Set a timeout to set the area. This makes sure that the last update
410410 // always happens, even if it was within the UPDATE_THRESHOLD.
411411 this . _update_timeout = window . setTimeout ( function ( ) {
412- var ms_unit = this . _model_duration / this . _model_ele_width ;
412+ var ms_unit = this . _model . get_duration ( ) / this . _model . get_model_element_width ( ) ;
413413 var x0 = this . _overlay_left * ms_unit ;
414414 var x1 = this . _to_right_x ( this . _overlay_right ) * ms_unit ;
415415 this . _model . set_area ( x0 , x1 ) ;
@@ -437,7 +437,7 @@ var ZoomerPrototype = function()
437437 */
438438 this . set_current_area = function ( )
439439 {
440- var ms_unit = this . _zoomer_ele_width / this . _model_duration ;
440+ var ms_unit = this . _model . get_model_element_width ( ) / this . _model . get_duration ( ) ;
441441 var area = this . _model . get_current_area ( ) ;
442442 this . _overlay_left = Math . floor ( area . x0 * ms_unit ) ;
443443 this . _overlay_right = this . _to_right_x ( Math . floor ( area . x1 * ms_unit ) ) ;
@@ -477,21 +477,23 @@ var ZoomerPrototype = function()
477477 this . _overlay_ele . style . right = right_pos + "px" ;
478478 } ;
479479
480- this . set_zoomer_ele = function ( ele )
480+ /**
481+ * Sets the zoomer element.
482+ */
483+ this . set_zoomer_element = function ( ele )
481484 {
482485 this . _zoomer_ele = ele ;
483486 this . _set_up_zoomer_ele ( ) ;
484487 this . _set_up_overlay_ele ( ) ;
485488 } ;
486489
487- this . set_model_ele_width = function ( width )
488- {
489- this . _model_ele_width = width ;
490- } ;
491-
492- this . set_model_duration = function ( duration )
490+ /**
491+ * Re-adds the overlay element in case it has been overwritten by other
492+ * content in the zoomer element.
493+ */
494+ this . attach_overlay_element = function ( )
493495 {
494- this . _model_duration = duration ;
496+ this . _zoomer_ele . appendChild ( this . _overlay_ele ) ;
495497 } ;
496498} ;
497499
0 commit comments