1function init(container) { 2 var instance; 3 if(window.jQuery) { 4 var $ = window.jQuery, jDoc = $(container[0].ownerDocument), view = container.find('.view'), canvas = view.find('canvas'); 5 6 function toggleMenu(e) { 7 e.preventDefault(); 8 e.stopPropagation(); 9 var el = $(e.target); 10 while(!el.hasClass('menu-toggle')) { 11 el = $(el[0].parentNode); 12 } 13 var menu = $(el[0].parentNode).find('.v-menu'); 14 if(menu.hasClass('hidden')) { 15 menu.removeClass('hidden'); 16 el.addClass('active'); 17 } 18 else { 19 menu.addClass('hidden'); 20 el.removeClass('active'); 21 } 22 } 23 function hideDropMenu() { 24 container.find('.v-menu').addClass('hidden'); 25 container.find('.menu-toggle').removeClass('active'); 26 } 27 28 function pickFloatWnd(e) { 29 if(instance.pos) { 30 dropFloatWnd(); 31 } 32 else { 33 instance.floatWnd = $(e.target); 34 while(!instance.floatWnd.hasClass('float-wnd')) { 35 instance.floatWnd = $(instance.floatWnd[0].parentNode); 36 } 37 instance.pos = { 38 x: e.pageX, 39 y: e.pageY 40 }; 41 } 42 } 43 function moveFloatWnd(e) { 44 if(instance.pos) { 45 e.preventDefault(); 46 var dv = { 47 x: e.pageX-instance.pos.x, 48 y: e.pageY-instance.pos.y 49 }, old = { 50 x: parseInt(instance.floatWnd.css('left')), 51 y: parseInt(instance.floatWnd.css('top')) 52 }; 53 instance.floatWnd.css('left', old.x+dv.x+'px').css('top', old.y+dv.y+'px'); 54 instance.pos = { 55 x: e.pageX, 56 y: e.pageY 57 }; 58 } 59 } 60 function dropFloatWnd() { 61 delete instance.pos; 62 delete instance.floatWnd; 63 } 64 65 instance = { 66 dispose: function() { 67 container.find('.menu-toggle').off('click', toggleMenu); 68 jDoc.off('click', hideDropMenu); 69 70 jDoc.off('mousemove', moveFloatWnd); 71 jDoc.off('mouseup', dropFloatWnd); 72 container.find('.float-wnd .head').off('mousedown', pickFloatWnd); 73 }, 74 appLoaded: function(scene) { 75 var hoverHeight = scene.view.getStyleData()['hover-height'] || 0; 76 if(hoverHeight) { 77 scene.ctrl.bookWatcher.setPadding((container.find('.tbox').css('bottom')==='10px'? -1: 1)*(hoverHeight+20)); 78 } 79 }, 80 linkLoaded: function(link) { 81 } 82 }; 83 84 container.find('.menu-toggle').on('click', toggleMenu); 85 jDoc.on('click', hideDropMenu); 86 87 jDoc.on('mousemove', moveFloatWnd); 88 jDoc.on('mouseup', dropFloatWnd); 89 container.find('.float-wnd .head').on('mousedown', pickFloatWnd); 90 } 91 else { 92 instance = { 93 dispose: function() { 94 } 95 }; 96 console.error('jQuery is not found'); 97 } 98 return instance; 99} init
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.