1 <!DOCTYPE HTML> 2 <html i18n-values="dir:textdirection;"> 3 <head> 4 <meta charset="utf-8"> 5 <title>Slideshow</title> 6 <style> 7 8 body { 9 overflow: hidden; 10 background: black; 11 } 12 13 #glow { 14 left: 0; 15 right: 0; 16 bottom: 30px; 17 height: 8px; 18 opacity: .4; 19 position: absolute; 20 background: -webkit-linear-gradient(transparent, white); 21 } 22 23 #main { 24 position: absolute; 25 left: 0; 26 right:0; 27 top: 0; 28 bottom: 30px; 29 overflow: hidden; 30 } 31 32 #playercontrols { 33 bottom: 0; 34 left: 0; 35 z-index: 999; 36 height: 30px; 37 opacity: .9; 38 right: 0; 39 align:center; 40 -webkit-box-align: center; 41 -webkit-box-pack: center; 42 display: -webkit-box; 43 position: absolute; 44 background: -webkit-linear-gradient(#323232, #070707); 45 } 46 47 #prevbutton > div { 48 background: url('chrome://resources/images/mediaplayer_prev.png'); 49 background-repeat: no-repeat; 50 background-position: 4px 8px; 51 width: 100%; 52 height: 30px; 53 z-index: 9999; 54 } 55 56 .currentpicture { 57 width: 100%; 58 height: 100%; 59 position: absolute; 60 top: 0; 61 -webkit-transition-property: left; 62 -webkit-transition-duration: 1s; 63 display: -webkit-box; 64 -webkit-box-align: center; 65 -webkit-box-pack: center; 66 pointer-events: none; 67 } 68 69 .comingfromleft { 70 left: -100%; 71 } 72 73 .comingfromright { 74 left: 100%; 75 } 76 77 #nextbutton > div { 78 background: url('chrome://resources/images/mediaplayer_next.png'); 79 background-repeat: no-repeat; 80 background-position: 4px 8px; 81 width: 100%; 82 height: 30px; 83 z-index: 9999; 84 } 85 86 button { 87 z-index: 9999; 88 cursor: pointer; 89 width: 28px; 90 height: 30px; 91 webkit-appearance: none; 92 padding: 0; 93 border: 0; 94 background: transparent; 95 } 96 97 button:hover { 98 background: -webkit-linear-gradient(#6a7eac, #000000); 99 } 100 101 </style> 102 <script src="chrome://resources/js/local_strings.js"></script> 103 <script src="chrome://resources/js/media_common.js"></script> 104 <script> 105 106 document.addEventListener('DOMContentLoaded', load); 107 108 document.onselectstart = function(e) { 109 e.preventDefault(); 110 }; 111 112 function $(o) { 113 return document.getElementById(o); 114 } 115 116 /////////////////////////////////////////////////////////////////////////////// 117 // Document Functions: 118 119 var currentPicture = null; 120 var prevPicture = null; 121 var currentFileOffset = 0; 122 var filelist = []; 123 var moveRight = false; 124 var lastimg = null; 125 126 function loadedPicture() { 127 if (prevPicture) { 128 if (moveRight) { 129 prevPicture.style.left = '-100%'; 130 } else { 131 prevPicture.style.left = '100%'; 132 } 133 } 134 if (window.innerHeight < lastimg.height || 135 window.innerWidth < lastimg.width) { 136 if (lastimg.width > lastimg.height) { 137 lastimg.style.height = 'auto'; 138 lastimg.style.width = '100%'; 139 } else { 140 lastimg.style.width = 'auto'; 141 lastimg.style.height = '100%'; 142 } 143 } 144 setTimeout(function() { 145 currentPicture.style.left = '0'; 146 }, 10); 147 } 148 149 function transitionTo(filePath, fromTheRight) { 150 if (currentPicture) { 151 if (prevPicture) { 152 $('main').removeChild(prevPicture); 153 } 154 prevPicture = currentPicture; 155 } 156 157 currentPicture = document.createElement('div'); 158 159 $('main').appendChild(currentPicture); 160 if (fromTheRight) { 161 currentPicture.className = 'currentpicture comingfromright'; 162 } else { 163 currentPicture.className = 'currentpicture comingfromleft'; 164 } 165 var image = document.createElement('img'); 166 lastimg = image; 167 image.onload = loadedPicture; 168 image.onerror = loadedPicture; 169 image.src = filePath; 170 currentPicture.appendChild(image); 171 moveRight = fromTheRight; 172 } 173 174 function browseFileResult() { 175 currentFileOffset = 0; 176 if (filelist.length > 0) { 177 transitionTo(filelist[currentFileOffset], true); 178 } 179 } 180 181 function keyPressed(e) { 182 // Left Pressed 183 if (e.keyCode == 37) { 184 if (currentFileOffset > 0) { 185 currentFileOffset--; 186 transitionTo(filelist[currentFileOffset], false); 187 } 188 } 189 // Right Pressed 190 if (e.keyCode == 39) { 191 if (currentFileOffset < (filelist.length - 1)) { 192 currentFileOffset++; 193 transitionTo(filelist[currentFileOffset], true); 194 } 195 } 196 } 197 198 function load() { 199 localStrings = new LocalStrings(); 200 201 var views = chrome.extension.getViews(); 202 for (var i = 0; i < views.length; i++) { 203 if (views[i].g_slideshow_data) { 204 filelist = views[i].g_slideshow_data; 205 views[i].g_slideshow_data = null; 206 } 207 } 208 209 browseFileResult(); 210 } 211 212 function prevButtonClick() { 213 if (currentFileOffset > 0) { 214 currentFileOffset--; 215 transitionTo(filelist[currentFileOffset], false); 216 } 217 } 218 219 function nextButtonClick() { 220 if (currentFileOffset < (filelist.length - 1)) { 221 currentFileOffset++; 222 transitionTo(filelist[currentFileOffset], true); 223 } 224 } 225 226 </script> 227 <body onkeydown="keyPressed(event)"> 228 <div id="main"></div> 229 <div id="glow"></div> 230 <div id="playercontrols"> 231 <button id="prevbutton" onclick="prevButtonClick()"> 232 <div></div> 233 </button> 234 <button id="nextbutton" onclick="nextButtonClick()"> 235 <div></div> 236 </button> 237 </div> 238 </body> 239 </html> 240