1(function (doc) { 2 3 var 4 pollute = true, 5 api, vendor, 6 apis = { 7 // http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html 8 w3: { 9 enabled: "fullscreenEnabled", 10 element: "fullscreenElement", 11 request: "requestFullscreen", 12 exit: "exitFullscreen", 13 events: { 14 change: "fullscreenchange", 15 error: "fullscreenerror" 16 } 17 }, 18 webkit: { 19 enabled: "webkitIsFullScreen", 20 element: "webkitCurrentFullScreenElement", 21 request: "webkitRequestFullScreen", 22 exit: "webkitCancelFullScreen", 23 events: { 24 change: "webkitfullscreenchange", 25 error: "webkitfullscreenerror" 26 } 27 }, 28 moz: { 29 enabled: "mozFullScreen", 30 element: "mozFullScreenElement", 31 request: "mozRequestFullScreen", 32 exit: "mozCancelFullScreen", 33 events: { 34 change: "mozfullscreenchange", 35 error: "mozfullscreenerror" 36 } 37 } 38 }, 39 w3 = apis.w3; 40 41 // Loop through each vendor's specific API 42 for (vendor in apis) { 43 // Check if document has the "enabled" property 44 if (apis[vendor].enabled in doc) { 45 // It seems this browser support the fullscreen API 46 api = apis[vendor]; 47 break; 48 } 49 } 50 51 function dispatch(type, target) { 52 var event = doc.createEvent("Event"); 53 event.initEvent(type, true, false); 54 target.dispatchEvent(event); 55 } // end of dispatch() 56 57 function handleChange(e) { 58 // Recopy the enabled and element values 59 doc[w3.enabled] = doc[api.enabled]; 60 doc[w3.element] = doc[api.element]; 61 62 dispatch(w3.events.change, e.target); 63 } // end of handleChange() 64 65 function handleError(e) { 66 dispatch(w3.events.error, e.target); 67 } // end of handleError() 68 69 if (pollute && api && vendor !== "w3") { 70 // Add listeners for fullscreen events 71 doc.addEventListener(api.events.change, handleChange, false); 72 doc.addEventListener(api.events.error, handleError, false); 73 74 // Copy the default value 75 doc[w3.enabled] = doc[api.enabled]; 76 doc[w3.element] = doc[api.element]; 77 78 // Match the reference for exitFullscreen 79 doc[w3.exit] = doc[api.exit]; 80 81 // Add the request method to the Element's prototype 82 Element.prototype[w3.request] = function () { 83 return this[api.request].apply(this, arguments); 84 }; 85 } 86 87 // Return the API found (or undefined if the Fullscreen API is unavailable) 88 return api; 89 90}(document));
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.