|
113 | 113 |
|
114 | 114 | // Path to root directory of Able Player code |
115 | 115 | if ($(media).data('root-path') !== undefined) { |
116 | | - // remove trailing slashes if there are any |
117 | | - this.rootPath = $(media).data('root-path').replace(/\/+$/, ""); |
118 | | - this.scriptPath = this.rootPath; |
| 116 | + // add a trailing slash if there is none |
| 117 | + this.rootPath = $(media).data('root-path').replace(/\/?$/, '/'); |
119 | 118 | } |
120 | 119 | else { |
121 | | - this.rootPath = this.getRootWebSitePath(); |
122 | | - this.scriptPath = this.getScriptPath(); |
| 120 | + this.rootPath = this.getRootPath(); |
123 | 121 | } |
124 | 122 |
|
125 | 123 | // Volume |
|
340 | 338 | this.fallbackPath = $(media).data('fallback-path'); |
341 | 339 | } |
342 | 340 | else { |
343 | | - this.fallbackPath = this.rootPath + '/thirdparty/'; |
| 341 | + this.fallbackPath = this.rootPath + 'thirdparty/'; |
344 | 342 | } |
345 | 343 |
|
346 | 344 | if ($(media).data('test-fallback') !== undefined && $(media).data('test-fallback') !== "false") { |
|
453 | 451 | this.setButtonImages(); |
454 | 452 | }; |
455 | 453 |
|
456 | | - AblePlayer.prototype.getRootWebSitePath = function() { |
| 454 | + AblePlayer.prototype.getRootPath = function() { |
457 | 455 |
|
458 | | - var _location = document.location.toString(); |
459 | | - var domainNameIndex = _location.indexOf('/', _location.indexOf('://') + 3); |
460 | | - var domainName = _location.substring(0, domainNameIndex) + '/'; |
461 | | - var webFolderIndex = _location.indexOf('/', _location.indexOf(domainName) + domainName.length); |
462 | | - var webFolderFullPath = _location.substring(0, webFolderIndex); |
463 | | - return webFolderFullPath; |
464 | | - }; |
465 | | - |
466 | | - AblePlayer.prototype.getScriptPath = function() { |
467 | | - |
468 | | - // returns path to Able Player JavaScript file |
469 | | - var scripts= document.getElementsByTagName('script'); |
470 | | - var path= scripts[scripts.length-1].src.split('?')[0]; // remove any ?query |
471 | | - var ableDir= path.split('/').slice(0, -1).join('/')+'/'; // remove last filename part of path |
472 | | - return ableDir; |
473 | | - }; |
| 456 | + // returns Able Player root path (assumes ableplayer.js is in /build, one directory removed from root) |
| 457 | + var scripts, i, scriptSrc, scriptFile, fullPath, ablePath, parentFolderIndex, rootPath; |
| 458 | + scripts= document.getElementsByTagName('script'); |
| 459 | + for (i=0; i < scripts.length; i++) { |
| 460 | + scriptSrc = scripts[i].src; |
| 461 | + scriptFile = scriptSrc.substr(scriptSrc.lastIndexOf('/')); |
| 462 | + if (scriptFile.indexOf('ableplayer') !== -1) { |
| 463 | + // this is the ableplayerscript |
| 464 | + fullPath = scriptSrc.split('?')[0]; // remove any ? params |
| 465 | + break; |
| 466 | + } |
| 467 | + } |
| 468 | + ablePath= fullPath.split('/').slice(0, -1).join('/'); // remove last filename part of path |
| 469 | + parentFolderIndex = ablePath.lastIndexOf('/'); |
| 470 | + rootPath = ablePath.substring(0, parentFolderIndex) + '/'; |
| 471 | + return rootPath; |
| 472 | + } |
474 | 473 |
|
475 | 474 | AblePlayer.prototype.setIconColor = function() { |
476 | 475 |
|
|
527 | 526 | AblePlayer.prototype.setButtonImages = function() { |
528 | 527 |
|
529 | 528 | // NOTE: volume button images are now set dynamically within volume.js |
530 | | - this.imgPath = this.rootPath + '/button-icons/' + this.iconColor + '/'; |
| 529 | + this.imgPath = this.rootPath + 'button-icons/' + this.iconColor + '/'; |
531 | 530 | this.playButtonImg = this.imgPath + 'play.png'; |
532 | 531 | this.pauseButtonImg = this.imgPath + 'pause.png'; |
533 | 532 |
|
|
3742 | 3741 | } |
3743 | 3742 | else { |
3744 | 3743 | var pipeImg = $('<img>', { |
3745 | | - src: this.rootPath + '/button-icons/' + this.iconColor + '/pipe.png', |
| 3744 | + src: this.rootPath + 'button-icons/' + this.iconColor + '/pipe.png', |
3746 | 3745 | alt: '', |
3747 | 3746 | role: 'presentation' |
3748 | 3747 | }); |
|
3753 | 3752 | else { |
3754 | 3753 | // this control is a button |
3755 | 3754 | if (control === 'volume') { |
3756 | | - buttonImgSrc = this.rootPath + '/button-icons/' + this.iconColor + '/' + this.volumeButton + '.png'; |
| 3755 | + buttonImgSrc = this.rootPath + 'button-icons/' + this.iconColor + '/' + this.volumeButton + '.png'; |
3757 | 3756 | } |
3758 | 3757 | else if (control === 'fullscreen') { |
3759 | | - buttonImgSrc = this.rootPath + '/button-icons/' + this.iconColor + '/fullscreen-expand.png'; |
| 3758 | + buttonImgSrc = this.rootPath + 'button-icons/' + this.iconColor + '/fullscreen-expand.png'; |
3760 | 3759 | } |
3761 | 3760 | else if (control === 'slower') { |
3762 | 3761 | if (this.speedIcons === 'animals') { |
3763 | | - buttonImgSrc = this.rootPath + '/button-icons/' + this.iconColor + '/turtle.png'; |
| 3762 | + buttonImgSrc = this.rootPath + 'button-icons/' + this.iconColor + '/turtle.png'; |
3764 | 3763 | } |
3765 | 3764 | else { |
3766 | | - buttonImgSrc = this.rootPath + '/button-icons/' + this.iconColor + '/slower.png'; |
| 3765 | + buttonImgSrc = this.rootPath + 'button-icons/' + this.iconColor + '/slower.png'; |
3767 | 3766 | } |
3768 | 3767 | } |
3769 | 3768 | else if (control === 'faster') { |
3770 | 3769 | if (this.speedIcons === 'animals') { |
3771 | | - buttonImgSrc = this.rootPath + '/button-icons/' + this.iconColor + '/rabbit.png'; |
| 3770 | + buttonImgSrc = this.rootPath + 'button-icons/' + this.iconColor + '/rabbit.png'; |
3772 | 3771 | } |
3773 | 3772 | else { |
3774 | | - buttonImgSrc = this.rootPath + '/button-icons/' + this.iconColor + '/faster.png'; |
| 3773 | + buttonImgSrc = this.rootPath + 'button-icons/' + this.iconColor + '/faster.png'; |
3775 | 3774 | } |
3776 | 3775 | } |
3777 | 3776 | else { |
3778 | | - buttonImgSrc = this.rootPath + '/button-icons/' + this.iconColor + '/' + control + '.png'; |
| 3777 | + buttonImgSrc = this.rootPath + 'button-icons/' + this.iconColor + '/' + control + '.png'; |
3779 | 3778 | } |
3780 | 3779 | buttonTitle = this.getButtonTitle(control); |
3781 | 3780 |
|
|
3864 | 3863 | 'class': iconClass |
3865 | 3864 | }); |
3866 | 3865 | buttonUse = $('<use>',{ |
3867 | | - 'xlink:href': this.rootPath + '/icons/able-icons.svg#' + iconClass |
| 3866 | + 'xlink:href': this.rootPath + 'icons/able-icons.svg#' + iconClass |
3868 | 3867 | }); |
3869 | 3868 | buttonIcon.append(buttonUse); |
3870 | 3869 | newButton.html(buttonIcon); |
|
10473 | 10472 | } |
10474 | 10473 | else { |
10475 | 10474 | // use image |
10476 | | - buttonImgSrc = this.rootPath + '/button-icons/' + this.toolbarIconColor + '/preferences.png'; |
| 10475 | + buttonImgSrc = this.rootPath + 'button-icons/' + this.toolbarIconColor + '/preferences.png'; |
10477 | 10476 | $buttonImg = $('<img>',{ |
10478 | 10477 | 'src': buttonImgSrc, |
10479 | 10478 | 'alt': '', |
|
11976 | 11975 | } |
11977 | 11976 | } |
11978 | 11977 | } |
11979 | | - |
11980 | | - // this.scriptPath is location of AblePlayer JavaScript file (default: /build) |
11981 | | - translationFile = this.scriptPath + '../translations/' + this.lang + '.js'; |
| 11978 | + translationFile = this.rootPath + 'translations/' + this.lang + '.js'; |
11982 | 11979 | this.importTranslationFile(translationFile).then(function(result) { |
11983 | 11980 | thisObj.tt = eval(thisObj.lang); |
11984 | 11981 | deferred.resolve(); |
|
0 commit comments