| 1 |
/* |
| 2 |
iSlide.js |
| 3 |
|
| 4 |
iSlideMaker |
| 5 |
http://sourceforge.jp/projects/islidemaker/simple/ |
| 6 |
|
| 7 |
Copyright(c) 2010, Isao Hara, isao-hara@users.sourceforge.jp |
| 8 |
|
| 9 |
All rights reserved. This program is made available under the terms of the |
| 10 |
Eclipse Public License v1.0 which accompanies this distribution, and is |
| 11 |
available at http://www.eclipse.org/legal/epl-v10.html |
| 12 |
|
| 13 |
Contributors: Isao Hara. |
| 14 |
|
| 15 |
*/ |
| 16 |
|
| 17 |
//////////////// |
| 18 |
var Slide; |
| 19 |
var touchX; |
| 20 |
var touchY; |
| 21 |
var touchMX; |
| 22 |
var touchMY; |
| 23 |
var orientation; |
| 24 |
|
| 25 |
/////////////// |
| 26 |
|
| 27 |
function iSlide_init(){ |
| 28 |
Slide = new iSlide(); |
| 29 |
Slide.showSlideByIndex(0); |
| 30 |
} |
| 31 |
|
| 32 |
function setSlideIndex(n){ |
| 33 |
Slide.showSlideByIndex(n); |
| 34 |
} |
| 35 |
|
| 36 |
function hasClass(element, className) { |
| 37 |
if (!element.className) return false; |
| 38 |
return (element.className.search('(^|\\s)' + className + '(\\s|$)') != -1); |
| 39 |
} |
| 40 |
|
| 41 |
function hasValue(element, value) { |
| 42 |
if (!element) return false; |
| 43 |
return (element.search('(^|\\s)' + value + '(\\s|$)') != -1); |
| 44 |
} |
| 45 |
|
| 46 |
function removeClass(element,className) { |
| 47 |
if (!element) return; |
| 48 |
element.className = element.className.replace(new RegExp('(^|\\s)'+className+'(\\s|$)'), RegExp.$1+RegExp.$2); |
| 49 |
} |
| 50 |
|
| 51 |
function addClass(element,className) { |
| 52 |
if (!element || hasClass(element, className)) return; |
| 53 |
if (element.className) { |
| 54 |
element.className += ' '+className; |
| 55 |
} else { |
| 56 |
element.className = className; |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
function GetElementsWithClassName(top, elementName,className) { |
| 61 |
|
| 62 |
var allElements = top.getElementsByTagName(elementName); |
| 63 |
var elemColl = new Array(); |
| 64 |
for (var i = 0; i< allElements.length; i++) { |
| 65 |
if (hasClass(allElements[i], className)) { |
| 66 |
elemColl[elemColl.length] = allElements[i]; |
| 67 |
} |
| 68 |
} |
| 69 |
return elemColl; |
| 70 |
} |
| 71 |
|
| 72 |
function isParentOrSelf(element, id) { |
| 73 |
if (element == null || element.nodeName=='BODY') return false; |
| 74 |
else if (element.id == id) return true; |
| 75 |
else return isParentOrSelf(element.parentNode, id); |
| 76 |
} |
| 77 |
|
| 78 |
function getSlideId(element) { |
| 79 |
if (element == null || element.nodeName=='BODY') return null; |
| 80 |
else if (element.id != null && element.id.substr(0,5) == 'slide') return element.id; |
| 81 |
else return getSlideId(element.parentNode); |
| 82 |
} |
| 83 |
|
| 84 |
function nodeValue(node) { |
| 85 |
var result = ""; |
| 86 |
if (node.nodeType == 1) { |
| 87 |
var children = node.childNodes; |
| 88 |
for (var i = 0; i < children.length; ++i) { |
| 89 |
result += nodeValue(children[i]); |
| 90 |
} |
| 91 |
} |
| 92 |
else if (node.nodeType == 3) { |
| 93 |
result = node.nodeValue; |
| 94 |
} |
| 95 |
return(result); |
| 96 |
} |
| 97 |
|
| 98 |
//////// iSlide Class |
| 99 |
var iSlide = function(){ |
| 100 |
if(window.innerWidth>window.innerHeight){ |
| 101 |
orientation = 'landscape'; |
| 102 |
this.WinWidth=window.innerWidth; |
| 103 |
this.WinHeight=window.innerHeight; |
| 104 |
this.scale = 1; |
| 105 |
}else{ |
| 106 |
orientation = 'portrate'; |
| 107 |
this.WinWidth=window.innerHeight; |
| 108 |
this.WinHeight=window.innerWidth; |
| 109 |
this.scale = window.innerWidth/ window.innerHeight; |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
this.current_incs=0; |
| 114 |
this.thumbMaxX=5; |
| 115 |
this.current_slide_index = -1; |
| 116 |
this.current_slide_id = null; |
| 117 |
this.mode; |
| 118 |
this.slides=null; |
| 119 |
this.incrementals=null; |
| 120 |
this.header=null; |
| 121 |
this.footer=null; |
| 122 |
this.num_slides=0; |
| 123 |
|
| 124 |
this.initSlide(); |
| 125 |
} |
| 126 |
|
| 127 |
iSlide.prototype.initSlide=function(){ |
| 128 |
var top = document.getElementById('presentation'); |
| 129 |
if(!top){ |
| 130 |
alert('No presentation dvi...'); |
| 131 |
return; |
| 132 |
} |
| 133 |
|
| 134 |
this.slides = GetElementsWithClassName(top, 'div', 'slide'); |
| 135 |
this.num_slides=this.slides.length; |
| 136 |
this.incrementals = this.createIncrementals(); |
| 137 |
|
| 138 |
this.createControls(); |
| 139 |
this.slideLabel(); |
| 140 |
|
| 141 |
this.header = document.getElementById('header'); |
| 142 |
this.header.setAttribute('class','header'); |
| 143 |
this.footer = document.getElementById('footer'); |
| 144 |
this.footer.setAttribute('class','footer'); |
| 145 |
this.num_slides=this.slides.length; |
| 146 |
|
| 147 |
for(var i=0;i<this.slides.length; i++){ |
| 148 |
var header = this.header.cloneNode(true); |
| 149 |
var footer = this.footer.cloneNode(true); |
| 150 |
var obj = this.slides[i]; |
| 151 |
|
| 152 |
obj.setAttribute('id', 'slide'+i); |
| 153 |
header.setAttribute('id',''); |
| 154 |
footer.setAttribute('id',''); |
| 155 |
|
| 156 |
obj.insertBefore(header, obj.childNodes[0]); |
| 157 |
obj.appendChild(footer); |
| 158 |
|
| 159 |
if(navigator.userAgent.match("iPad")){ |
| 160 |
|
| 161 |
obj.addEventListener('touchstart', selectSlide, false); |
| 162 |
obj.addEventListener('touchmove', moveEventHandle, false); |
| 163 |
obj.addEventListener('touchend', touchSlide, false); |
| 164 |
|
| 165 |
}else{ |
| 166 |
document.onmousedown=selectSlideWithMouse; |
| 167 |
document.onmousemove=moveEventHandleWithMouse; |
| 168 |
document.onmouseup=touchSlideWithMouse; |
| 169 |
} |
| 170 |
|
| 171 |
obj.style.width=this.WinWidth+'px'; |
| 172 |
obj.style.height=this.WinHeight+'px'; |
| 173 |
obj.style.position='absolute'; |
| 174 |
obj.style.display='none'; |
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
iSlide.prototype.updateOrientation=function() { |
| 179 |
if(window.innerWidth > window.innerHeight){ |
| 180 |
orientation = 'landscape'; |
| 181 |
this.WinWidth=window.innerWidth; |
| 182 |
this.WinHeight=window.innerHeight; |
| 183 |
this.scale = 1; |
| 184 |
}else{ |
| 185 |
orientation = 'portrate'; |
| 186 |
this.WinWidth=window.innerHeight; |
| 187 |
this.WinHeight=window.innerWidth; |
| 188 |
this.scale = window.innerWidth/ window.innerHeight; |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
iSlide.prototype.slideLabel=function() { |
| 193 |
var list = document.getElementById('jumplist'); |
| 194 |
smax = this.num_slides; |
| 195 |
for (var n = 0; n < smax; n++) { |
| 196 |
var obj = this.slides[n]; |
| 197 |
|
| 198 |
var did = 'slide' + n.toString(); |
| 199 |
obj.setAttribute('id',did); |
| 200 |
|
| 201 |
var otext = ''; |
| 202 |
var menu = obj.firstChild; |
| 203 |
if (!menu) continue; |
| 204 |
while (menu && menu.nodeType == 3) { |
| 205 |
menu = menu.nextSibling; |
| 206 |
} |
| 207 |
if (!menu) continue; |
| 208 |
|
| 209 |
var menunodes = menu.childNodes; |
| 210 |
for (var o = 0; o < menunodes.length; o++) { |
| 211 |
otext += nodeValue(menunodes[o]); |
| 212 |
} |
| 213 |
|
| 214 |
list.options[list.length] = new Option(n + ' : ' + otext, n); |
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
iSlide.prototype.createControls = function() { |
| 219 |
var controlsDiv = document.getElementById("controls"); |
| 220 |
var hideDiv, hideList = ''; |
| 221 |
|
| 222 |
if (!controlsDiv) return; |
| 223 |
|
| 224 |
controlsDiv.innerHTML = '<div id="navLinks">' + |
| 225 |
'<button onClick="hideAllSlides();fileSelector();">End<\/button>'+ |
| 226 |
'<button onClick="hideAllSlides();editCurrentSlide();">Edit<\/button>'+ |
| 227 |
'<button onClick="showThumbnail();">Thumb<\/button>'+ |
| 228 |
'<select id="jumplist" onchange="jumpSlide();"><\/select>' + |
| 229 |
'<\/div>'; |
| 230 |
|
| 231 |
controlsDiv.style.display='none'; |
| 232 |
} |
| 233 |
|
| 234 |
iSlide.prototype.displaySlide = function(idx, scale, x, y, frame){ |
| 235 |
var obj = this.slides[idx]; |
| 236 |
var x0=this.WinWidth*scale; |
| 237 |
var y0=this.WinHeight*scale; |
| 238 |
var xx = (this.WinWidth/2) * scale - this.WinWidth/2 + 5 + (5+x0)*x; |
| 239 |
var yy = (this.WinHeight/2) * scale - this.WinHeight/2 + 5+ (5+y0)*y; |
| 240 |
|
| 241 |
obj.style.webkitTransform='scale('+scale+')'; |
| 242 |
|
| 243 |
if (frame){ |
| 244 |
obj.style.border="1px solid black"; |
| 245 |
}else{ |
| 246 |
xx=xx-5; |
| 247 |
yy=yy-5; |
| 248 |
obj.style.border="1px none black"; |
| 249 |
} |
| 250 |
|
| 251 |
obj.style.left = xx+'px'; |
| 252 |
obj.style.top = yy+'px'; |
| 253 |
|
| 254 |
obj.style.display='block'; |
| 255 |
} |
| 256 |
|
| 257 |
iSlide.prototype.showThumbnail = function(){ |
| 258 |
var maxX = this.thumbMaxX; |
| 259 |
if(this.slides == null) return; |
| 260 |
|
| 261 |
this.mode='thumbnail'; |
| 262 |
this.current_slide_index = -1; |
| 263 |
|
| 264 |
scale = (this.WinWidth - 10)/maxX/this.WinWidth; |
| 265 |
|
| 266 |
var y = 0; |
| 267 |
var x = 0; |
| 268 |
|
| 269 |
for(var i=0;i<this.num_slides;i++){ |
| 270 |
y = Math.floor(i/maxX); |
| 271 |
x = i % maxX; |
| 272 |
this.displaySlide(i, scale, x, y, true); |
| 273 |
} |
| 274 |
|
| 275 |
var svg_objs = document.getElementsByTagName('object'); |
| 276 |
for(var i=0;i<svg_objs.length;i++){ |
| 277 |
svg_objs[i].style.display='none'; |
| 278 |
} |
| 279 |
} |
| 280 |
|
| 281 |
iSlide.prototype.currentSlide = function() { |
| 282 |
var cs = document.getElementById('currentSlide'); |
| 283 |
cs.innerHTML = '<span id="csHere">' + this.current_slide_index + '<\/span> ' + |
| 284 |
'<span id="csSep">\/<\/span> ' + |
| 285 |
'<span id="csTotal">' + (this.num_slides-1) + '<\/span>'; |
| 286 |
if (this.current_slide_index == 0) { cs.style.visibility = 'hidden'; } |
| 287 |
else { cs.style.visibility = 'visible'; } |
| 288 |
} |
| 289 |
|
| 290 |
iSlide.prototype.getIncrementals=function(obj) { |
| 291 |
var incrs = new Array(); |
| 292 |
|
| 293 |
if (!obj) return incrs; |
| 294 |
|
| 295 |
var children = obj.childNodes; |
| 296 |
|
| 297 |
for (var i = 0; i < children.length; i++) { |
| 298 |
var child = children[i]; |
| 299 |
if (hasClass(child, 'incremental')) { |
| 300 |
if (child.nodeName == 'OL' || child.nodeName == 'UL') { |
| 301 |
removeClass(child, 'incremental'); |
| 302 |
for (var j = 0; j < child.childNodes.length; j++) { |
| 303 |
if (child.childNodes[j].nodeType == 1) { |
| 304 |
addClass(child.childNodes[j], 'incremental'); |
| 305 |
} |
| 306 |
} |
| 307 |
} else { |
| 308 |
incrs[incrs.length] = child; |
| 309 |
removeClass(child,'incremental'); |
| 310 |
} |
| 311 |
} |
| 312 |
if (hasClass(child, 'show-first')) { |
| 313 |
if (child.nodeName == 'OL' || child.nodeName == 'UL') { |
| 314 |
removeClass(child, 'show-first'); |
| 315 |
if (child.childNodes[isGe].nodeType == 1) { |
| 316 |
removeClass(child.childNodes[isGe], 'incremental'); |
| 317 |
} |
| 318 |
} else { |
| 319 |
incrs[incrs.length] = child; |
| 320 |
} |
| 321 |
} |
| 322 |
incrs = incrs.concat(this.getIncrementals(child)); |
| 323 |
} |
| 324 |
return incrs; |
| 325 |
} |
| 326 |
|
| 327 |
iSlide.prototype.createIncrementals=function() { |
| 328 |
this.incrementals = new Array(); |
| 329 |
for (var i = 0; i < this.num_slides; i++) { |
| 330 |
this.incrementals[i] = this.getIncrementals(this.slides[i]); |
| 331 |
} |
| 332 |
return this.incrementals; |
| 333 |
} |
| 334 |
|
| 335 |
iSlide.prototype.jumpSlide=function(){ |
| 336 |
var jl = document.getElementById('jumplist'); |
| 337 |
var pos = parseInt(jl.value); |
| 338 |
this.showSlideByIndex(pos); |
| 339 |
} |
| 340 |
|
| 341 |
iSlide.prototype.showSlideByIndex=function(idx){ |
| 342 |
if(!this.slides) return false; |
| 343 |
|
| 344 |
var incs = this.incrementals[idx]; |
| 345 |
|
| 346 |
for(var i=0;i < incs.length;i++){ |
| 347 |
removeClass(incs[i], "current"); |
| 348 |
addClass(incs[i], "incremental"); |
| 349 |
} |
| 350 |
this.current_incs = 0; |
| 351 |
this.showSlide(idx); |
| 352 |
} |
| 353 |
|
| 354 |
iSlide.prototype.showSlide=function(idx){ |
| 355 |
var svg_objs = document.getElementsByTagName('object'); |
| 356 |
for(var i=0;i<svg_objs.length;i++){ svg_objs[i].style.display='block'; } |
| 357 |
|
| 358 |
for(var i=0; i<this.num_slides; i++){ |
| 359 |
if(i != idx) this.slides[i].style.display='none'; |
| 360 |
} |
| 361 |
hideControls(); |
| 362 |
this.current_slide_index = idx; |
| 363 |
this.displaySlide(idx, this.scale, 0, 0, false); |
| 364 |
this.currentSlide(); |
| 365 |
// drawCanvas(this.slides[idx]); |
| 366 |
this.mode='presentation'; |
| 367 |
} |
| 368 |
|
| 369 |
iSlide.prototype.hideAllSlides=function(){ |
| 370 |
for(i in this.slides){ |
| 371 |
this.slides[i].style.display='none'; |
| 372 |
} |
| 373 |
hideControls(); |
| 374 |
} |
| 375 |
|
| 376 |
iSlide.prototype.nextSlide=function(){ |
| 377 |
if(this.current_slide_index < 0 || this.current_slide_index == this.num_slides -1 ) return false; |
| 378 |
this.current_incs = 0; |
| 379 |
this.showSlideByIndex(this.current_slide_index + 1); |
| 380 |
} |
| 381 |
|
| 382 |
iSlide.prototype.prevSlide=function(){ |
| 383 |
if(this.current_slide_index <= 0 ) return false; |
| 384 |
this.current_incs = 0; |
| 385 |
this.showSlideByIndex(this.current_slide_index -1); |
| 386 |
} |
| 387 |
|
| 388 |
iSlide.prototype.modeEditFile=function(){ |
| 389 |
this.mode = 'editfile'; |
| 390 |
} |
| 391 |
|
| 392 |
iSlide.prototype.showCurrentSlide=function(){ |
| 393 |
if(this.current_slide_index >= 0 && this.current_slide_index < this.num_slides) |
| 394 |
this.showSlideByIndex(this.current_slide_index); |
| 395 |
} |
| 396 |
|
| 397 |
iSlide.prototype.nextStep=function(){ |
| 398 |
var incs = this.incrementals[this.current_slide_index]; |
| 399 |
|
| 400 |
if(incs.length == 0 || incs.length < this.current_incs){ |
| 401 |
this.nextSlide(); |
| 402 |
}else if(incs.length > Slide.current_incs){ |
| 403 |
if(this.current_incs > 0) removeClass(incs[this.current_incs-1], "current"); |
| 404 |
removeClass(incs[this.current_incs], "incremental"); |
| 405 |
addClass(incs[this.current_incs], "current"); |
| 406 |
this.current_incs += 1; |
| 407 |
}else if(incs.length == this.current_incs){ |
| 408 |
if(this.current_incs > 0) removeClass(incs[this.current_incs-1], "current"); |
| 409 |
this.current_incs += 1; |
| 410 |
} |
| 411 |
} |
| 412 |
|
| 413 |
////// |
| 414 |
function hideControls(){ |
| 415 |
var controlsDiv = document.getElementById("controls"); |
| 416 |
controlsDiv.style.display='none'; |
| 417 |
} |
| 418 |
|
| 419 |
function hideAllSlides(){ |
| 420 |
Slide.hideAllSlides(); |
| 421 |
} |
| 422 |
|
| 423 |
function jumpSlide(){ |
| 424 |
Slide.jumpSlide(); |
| 425 |
} |
| 426 |
function modeEditFile(){ |
| 427 |
Slide.modeEditFile(); |
| 428 |
} |
| 429 |
|
| 430 |
function showThumbnail(){ |
| 431 |
Slide.showThumbnail(); |
| 432 |
hideControls(); |
| 433 |
} |
| 434 |
|
| 435 |
function editCurrentSlide(){ |
| 436 |
if(Slide.current_slide_index < 0) return; |
| 437 |
editSlideByIndex(Slide.current_slide_index); |
| 438 |
Slide.mode = 'EditSlide'; |
| 439 |
} |
| 440 |
|
| 441 |
//// Event Handler |
| 442 |
function selectSlide(e){ |
| 443 |
if(e.touches.length != 1) return false; |
| 444 |
|
| 445 |
e.preventDefault(); |
| 446 |
|
| 447 |
touchMX=touchX=e.touches[0].clientX; |
| 448 |
touchMY=touchY=e.touches[0].clientY; |
| 449 |
|
| 450 |
if(Slide.mode != 'thumbnail') return false; |
| 451 |
|
| 452 |
var current_slide_id = getSlideId(e.touches[0].target); |
| 453 |
|
| 454 |
if( current_slide_id !== null){ |
| 455 |
Slide.current_slide_index = parseInt(current_slide_id.substr(5)); |
| 456 |
}else { |
| 457 |
Slide.current_slide_index = -1; |
| 458 |
} |
| 459 |
|
| 460 |
return false; |
| 461 |
} |
| 462 |
|
| 463 |
|
| 464 |
function touchSlide(e){ |
| 465 |
e.preventDefault(); |
| 466 |
|
| 467 |
var controlsDiv = document.getElementById("controls"); |
| 468 |
|
| 469 |
if(controlsDiv.style.display != 'none'){ |
| 470 |
controlsDiv.style.display='none'; |
| 471 |
return false; |
| 472 |
} |
| 473 |
|
| 474 |
if(Slide.mode == 'thumbnail') { |
| 475 |
Slide.showCurrentSlide(); |
| 476 |
return false; |
| 477 |
} |
| 478 |
|
| 479 |
if(Slide.mode != 'presentation' && Slide.mode != 'editfile') return false; |
| 480 |
|
| 481 |
if(touchX < Slide.scale*Slide.WinWidth*0.1 && touchY > Slide.scale*Slide.WinHeight*0.9 ){ |
| 482 |
if(Slide.mode == 'editfile'){ |
| 483 |
hideItemById('presentation'); |
| 484 |
showItemById('menuDiv'); |
| 485 |
showItemById('editDiv'); |
| 486 |
return false; |
| 487 |
}else{ |
| 488 |
showThumbnail(); |
| 489 |
return false; |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
var deltaX = touchMX - touchX; |
| 494 |
var deltaY = touchMY - touchY; |
| 495 |
|
| 496 |
if(deltaX > Slide.scale*Slide.WinWidth*0.1){ |
| 497 |
Slide.nextSlide(); |
| 498 |
}else if(deltaX < -Slide.scale*Slide.WinWidth*0.1){ |
| 499 |
Slide.prevSlide(); |
| 500 |
}else if(touchY > Slide.scale*Slide.WinHeight - 20){ |
| 501 |
if(Slide.mode == 'editfile'){ |
| 502 |
hideItemById('presentation'); |
| 503 |
showItemById('menuDiv'); |
| 504 |
showItemById('editDiv'); |
| 505 |
}else{ |
| 506 |
controlsDiv.style.display='block'; |
| 507 |
} |
| 508 |
}else { |
| 509 |
Slide.nextStep(); |
| 510 |
} |
| 511 |
|
| 512 |
} |
| 513 |
function moveEventHandle(e){ |
| 514 |
if(e.touches.length != 1) return false; |
| 515 |
e.preventDefault(); |
| 516 |
|
| 517 |
touchMX=e.touches[0].clientX; |
| 518 |
touchMY=e.touches[0].clientY; |
| 519 |
return false; |
| 520 |
} |
| 521 |
|
| 522 |
function selectSlideWithMouse(e){ |
| 523 |
touchMX=touchX=e.pageX; |
| 524 |
touchMY=touchY=e.pageY; |
| 525 |
|
| 526 |
if(Slide.mode != 'thumbnail') return false; |
| 527 |
|
| 528 |
var current_slide_id = getSlideId(e.target); |
| 529 |
|
| 530 |
if( current_slide_id !== null){ |
| 531 |
Slide.current_slide_index = parseInt(current_slide_id.substr(5)); |
| 532 |
}else { |
| 533 |
current_slide_index = -1; |
| 534 |
} |
| 535 |
|
| 536 |
return false; |
| 537 |
} |
| 538 |
|
| 539 |
function touchSlideWithMouse(e){ |
| 540 |
var controlsDiv = document.getElementById("controls"); |
| 541 |
|
| 542 |
if(controlsDiv.style.display != 'none'){ |
| 543 |
controlsDiv.style.display='none'; |
| 544 |
return false; |
| 545 |
} |
| 546 |
|
| 547 |
if(Slide.mode == 'thumbnail') { |
| 548 |
Slide.showCurrentSlide(); |
| 549 |
return false; |
| 550 |
} |
| 551 |
|
| 552 |
if(Slide.mode != 'presentation' && Slide.mode != 'editfile') return false; |
| 553 |
|
| 554 |
if(touchX < Slide.scale*Slide.WinWidth*0.1 && touchY > Slide.scale*Slide.WinHeight*0.9 ){ |
| 555 |
if(Slide.mode == 'editfile'){ |
| 556 |
hideItemById('presentation'); |
| 557 |
showItemById('menuDiv'); |
| 558 |
showItemById('editDiv'); |
| 559 |
return false; |
| 560 |
}else{ |
| 561 |
showThumbnail(); |
| 562 |
return false; |
| 563 |
} |
| 564 |
} |
| 565 |
|
| 566 |
var deltaX = touchMX - touchX; |
| 567 |
var deltaY = touchMY - touchY; |
| 568 |
|
| 569 |
if(deltaX > Slide.scale*Slide.WinWidth*0.1){ |
| 570 |
Slide.nextSlide(); |
| 571 |
}else if(deltaX < -Slide.scale*Slide.WinWidth*0.1){ |
| 572 |
Slide.prevSlide(); |
| 573 |
}else if(touchY > Slide.scale*Slide.WinHeight - 20){ |
| 574 |
if(Slide.mode == 'editfile'){ |
| 575 |
hideItemById('presentation'); |
| 576 |
showItemById('menuDiv'); |
| 577 |
showItemById('editDiv'); |
| 578 |
}else{ |
| 579 |
controlsDiv.style.display='block'; |
| 580 |
} |
| 581 |
}else { |
| 582 |
Slide.nextStep(); |
| 583 |
} |
| 584 |
|
| 585 |
} |
| 586 |
|
| 587 |
function moveEventHandleWithMouse(e){ |
| 588 |
touchMX=e.pageX; |
| 589 |
touchMY=e.pageY; |
| 590 |
return false; |
| 591 |
} |
| 592 |
|
| 593 |
|
| 594 |
//////// |
| 595 |
function updateOrientation(){ |
| 596 |
Slide.updateOrientation(); |
| 597 |
|
| 598 |
if(Slide.mode=='thumbnail'){ |
| 599 |
showThumbnail(); |
| 600 |
}else if(Slide.mode=='presentation'){ |
| 601 |
Slide.showCurrentSlide(); |
| 602 |
} |
| 603 |
} |
| 604 |
|
| 605 |
function toSVGElement(str, w, h){ |
| 606 |
var xmlsvg = "xmlns:svg=\"http://www.w3.org/2000/svg\"" |
| 607 |
var parser = new DOMParser(); |
| 608 |
var header = "<svg:svg width=\""+w+"\" height=\""+h+"\" "+xmlsvg+">" |
| 609 |
var footer = "</svg:svg>"; |
| 610 |
var xmlDoc = parser.parseFromString(header+str+footer, "text/xml"); |
| 611 |
var ele = document.importNode(xmlDoc.documentElement,true); |
| 612 |
return ele; |
| 613 |
} |
| 614 |
|
| 615 |
/////// |
| 616 |
window.addEventListener('orientationchange', updateOrientation, false); |