产品原型
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2600 lines
113 KiB

4 years ago
  1. var PLUGIN_VAR_NAME = 'g';
  2. var FOOTNOTES_VAR_NAME = 'fn';
  3. var ADAPTIVE_VIEW_VAR_NAME = 'view';
  4. var SCALE_VAR_NAME = 'sc';
  5. var DIM_VAR_NAME = 'dm';
  6. var ROT_VAR_NAME = 'r';
  7. var CLOUD_VAR_NAME = 'cl';
  8. var TRACE_VAR_NAME = 'tr';
  9. var RP_VERSION = 9;
  10. var lastLeftPanelWidth = 220;
  11. var lastRightPanelWidth = 220;
  12. var lastLeftPanelWidthDefault = 220;
  13. var lastRightPanelWidthDefault = 220;
  14. var toolBarOnly = true;
  15. // TODO: need to find a way to get rid of iphone X hacks!!!
  16. // - could possibly have app detect iphone and send information back to player, but currently, that information would arrive too late
  17. var iphoneX = false;
  18. var iphoneXFirstPass = true;
  19. // isolate scope
  20. (function () {
  21. if (!window.$axure) window.$axure = function () { };
  22. if (typeof console == 'undefined') console = {
  23. log: function () { }
  24. };
  25. if (window._axUtils) $axure.utils = _axUtils;
  26. setUpController();
  27. var getHashStringVar = $axure.player.getHashStringVar = function (query) {
  28. var qstring = self.location.href.split("#");
  29. if (qstring.length < 2) return "";
  30. return GetParameter(qstring, query);
  31. }
  32. var isCloud = $axure.player.isCloud = getHashStringVar(CLOUD_VAR_NAME);
  33. if (isCloud) {
  34. $("#topPanel").css('display', 'none');
  35. lastRightPanelWidthDefault = 290;
  36. }else {
  37. $("#topPanel").css('display', '');
  38. }
  39. $axure.loadDocument = function (document) {
  40. $axure.document = document;
  41. var configuration = $axure.document.configuration;
  42. var _settings = {};
  43. _settings.projectId = configuration.prototypeId;
  44. _settings.projectName = configuration.projectName;
  45. _settings.isAxshare = configuration.isAxshare;
  46. _settings.isExpo = configuration.isExpo == null ? false : configuration.isExpo;
  47. _settings.loadSitemap = configuration.loadSitemap;
  48. _settings.loadFeedbackPlugin = configuration.loadFeedbackPlugin;
  49. var cHash = getHashStringVar(SITEMAP_COLLAPSE_VAR_NAME);
  50. _settings.startCollapsed = cHash == SITEMAP_COLLAPSE_VALUE;
  51. if (cHash == SITEMAP_CLOSE_VALUE) closePlayer();
  52. var gHash = getHashStringVar(PLUGIN_VAR_NAME);
  53. _settings.startPluginGid = gHash;
  54. $axure.player.settings = _settings;
  55. var additionalJs = $axure.document.additionalJs;
  56. if (additionalJs != null) {
  57. var total = additionalJs.length;
  58. if (total > 0) $.holdReady(true);
  59. $.each(additionalJs, function (index, value) {
  60. var script = window.document.createElement("script");
  61. script.type = "text/javascript";
  62. script.src = value;
  63. script.async = false;
  64. script.onload = script.onreadystatechange = function (e) {
  65. if (!script.readyState || /loaded|complete/.test(script.readyState)) {
  66. script.onload = script.onreadystatechange = null;
  67. script = undefined;
  68. }
  69. if (--total == 0) $.holdReady(false);
  70. }
  71. window.document.head.appendChild(script);
  72. });
  73. }
  74. var additionalCss = $axure.document.additionalCss;
  75. if(additionalCss != null) {
  76. $.each(additionalCss, function(index, value) {
  77. var style = window.document.createElement('link');
  78. style.type = "text/css";
  79. style.rel = "stylesheet";
  80. style.href = value;
  81. window.document.head.appendChild(style);
  82. });
  83. }
  84. if(_settings.isExpo && configuration.isMobile) {
  85. initializeDeviceFrame();
  86. }
  87. // Pseudo-indicator that the document has been loaded
  88. $axure.document.isLoaded = true;
  89. };
  90. $(window).bind('load', function () {
  91. if ((CHROME && BROWSER_VERSION < 64) || // First 2018 release
  92. (SAFARI && BROWSER_VERSION < 602) || // Minor version 10
  93. (FIREFOX && BROWSER_VERSION < 57) || // Support Quantum
  94. ($axure.browser.isEdge && BROWSER_VERSION < 15) || // 15 for mobile devices (else could go 16, possibly 17)
  95. (!$axure.browser.isEdge && IE)) {
  96. if (!QQ && !UC) appendOutOfDateNotification();
  97. }
  98. if (CHROME_5_LOCAL && !$('body').attr('pluginDetected')) {
  99. window.location = 'resources/chrome/chrome.html';
  100. }
  101. if (FIREFOX && BROWSER_VERSION >= 68 && document.location.href.indexOf('file://') >= 0) { //detecting firefox and local
  102. window.location = 'resources/chrome/firefox.html';
  103. }
  104. });
  105. function appendOutOfDateNotification() {
  106. var toAppend = '';
  107. toAppend += '<div id="browserOutOfDateNotification">';
  108. toAppend += ' <div style="font-size: 24px; text-align: center; color: #FFFFFF;">LOOKS LIKE YOUR BROWSER IS OUT OF DATE</div>';
  109. toAppend += ' <div style="font-size: 14px; text-align: center; color: #FFFFFF; margin-bottom: 16px;">This prototype may not look or function correctly until you update your browser</div>';
  110. toAppend += ' <div id="supportedBrowsersListContainer">';
  111. toAppend += ' <div class="browserContainer">';
  112. toAppend += ' <div class="browserName">Google Chrome</div><div class="browserSupportedVersion">v64 and later</div>';
  113. toAppend += ' </div>';
  114. toAppend += ' <div class="browserContainer">';
  115. toAppend += ' <div class="browserName">Mozilla Firefox</div><div class="browserSupportedVersion">v57 and later</div>';
  116. toAppend += ' </div>';
  117. toAppend += ' <div class="browserContainer">';
  118. toAppend += ' <div class="browserName">Microsoft Edge</div><div class="browserSupportedVersion">v15 and later</div>';
  119. toAppend += ' </div>';
  120. toAppend += ' <div class="browserContainer">';
  121. toAppend += ' <div class="browserName">Apple Safari</div><div class="browserSupportedVersion">v10 and later</div>';
  122. toAppend += ' </div>';
  123. toAppend += ' </div>';
  124. toAppend += ' <div id="browserOutOfDateNotificationButtons">'
  125. if (!MOBILE_DEVICE) {
  126. toAppend += ' <div style="margin-right: 36px"><a href="http://outdatedbrowser.com/en" id="updateBrowserButton">UPDATE BROWSER</a></div>';
  127. toAppend += ' <div style="flex: 0 1 45%;"><a id="continueToPrototypeButton">Continue viewing prototype anyway</a></div>';
  128. } else {
  129. toAppend += ' <div style="width: 100%; text-align:center"><a id="continueToPrototypeButton">Continue viewing prototype anyway</a></div>';
  130. }
  131. toAppend += ' </div>';
  132. toAppend += '</div>';
  133. $('body').prepend(toAppend);
  134. $('#continueToPrototypeButton').on('click', function () {
  135. var $message = $('#browserOutOfDateNotification');
  136. $message.children().hide();
  137. $message.css('padding-top', '0px');
  138. $message.animate({ 'height': '0px' }, { duration: 400, complete: function () { $message.hide(); } });
  139. });
  140. }
  141. $axure.page.bind('load.start', mainFrame_onload);
  142. $axure.messageCenter.addMessageListener(messageCenter_message);
  143. var suppressPluginVarUpdate = false;
  144. $(document).on('pluginShown', function (event, data) {
  145. if (!suppressPluginVarUpdate) $axure.player.setVarInCurrentUrlHash(PLUGIN_VAR_NAME, data ? data : '');
  146. });
  147. $(document).on('pluginCreated', function (event, data) {
  148. if (!$axure.player.isMobileMode() && $axure.player.settings.startPluginGid.indexOf(data) > -1) {
  149. suppressPluginVarUpdate = true;
  150. $axure.player.showPlugin(data);
  151. suppressPluginVarUpdate = false;
  152. }
  153. if (data == '1') {
  154. $('#interfaceControlFrame').animate({ opacity: 1 }, 200);
  155. }
  156. if ($axure.player.settings.isExpo) {
  157. // TODO: Do this only if expo is a mobile device
  158. // TODO: Figure out better way to deal with this issue
  159. $axure.messageCenter.postMessage('setDeviceMode', { device: false });
  160. $axure.messageCenter.postMessage('setDeviceMode', { device: true });
  161. //$axure.player.refreshViewPort();
  162. }
  163. });
  164. function initializeEvents() {
  165. $('#interfaceControlFrameMinimizeContainer').on('click', collapse);
  166. $('#interfaceControlFrameCloseButton').on('click', closePlayer);
  167. $('#interfacePageNameContainer').on($axure.eventNames.mouseDownName, toggleSitemap);
  168. $('#interfaceAdaptiveViewsContainer').on($axure.eventNames.mouseDownName, toggleAdaptiveViewsPopup);
  169. $('#overflowMenuButton').on($axure.eventNames.mouseDownName, toggleOverflowMenuPopup);
  170. if (!MOBILE_DEVICE) {
  171. $('#maximizePanel').mouseenter(function () {
  172. $(this).addClass('maximizePanelOver');
  173. });
  174. $('#maximizePanel').mouseleave(function () {
  175. if ($(this).hasClass('maximizePanelOver')) {
  176. $(this).animate(isMobileMode() ? {
  177. top: '-' + $('#maximizePanel').height() + 'px'
  178. } : {
  179. left: '-' + $('#maximizePanel').width() + 'px'
  180. }, 300);
  181. }
  182. $(this).removeClass('maximizePanelOver');
  183. });
  184. $('#maximizePanelOver').mouseenter(function () {
  185. $('#maximizePanel').animate(isMobileMode() ? {
  186. top: '0px'
  187. } : {
  188. left: '0px'
  189. }, 100);
  190. });
  191. }
  192. $minimizeContainer = $('#interfaceControlFrameMinimizeContainer');
  193. $minimizeContainer.mouseenter(function () { $minimizeContainer.addClass('collapseHovered') });
  194. $minimizeContainer.mouseleave(function () { $minimizeContainer.removeClass('collapseHovered') });
  195. $maximizeContainer = $('#maximizePanelContainer');
  196. $maximizeContainer.mouseenter(function () { if(!MOBILE_DEVICE) $minimizeContainer.addClass('expandHovered') });
  197. $maximizeContainer.mouseleave(function () { if(!MOBILE_DEVICE) $minimizeContainer.removeClass('expandHovered') });
  198. $('#maximizePanel').click(function () {
  199. $(this).removeClass('maximizePanelOver');
  200. $('#maximizePanelContainer').hide();
  201. $axure.messageCenter.postMessage('expandFrame');
  202. });
  203. $('#mHideSidebar').on($axure.eventNames.mouseDownName, function (e) { startM(e); });
  204. $('#lsplitbar').on($axure.eventNames.mouseDownName, startLeftSplit);
  205. $('#rsplitbar').on($axure.eventNames.mouseDownName, startRightSplit);
  206. if ($axure.mobileSupport.mobile) {
  207. var touchCount = 0;
  208. var lastTouch = Date.now();
  209. $('#mainPanel').on('touchstart',
  210. (function (e) {
  211. var now = Date.now();
  212. if (now - lastTouch < 375) {
  213. if (++touchCount === 3) {
  214. if ($axure.player.isMobileMode() || MOBILE_DEVICE) expand();
  215. touchCount = 0;
  216. e.preventDefault();
  217. };
  218. } else {
  219. touchCount = 1;
  220. }
  221. lastTouch = now;
  222. }));
  223. }
  224. $(window).resize(function () {
  225. $axure.player.resizeContent();
  226. });
  227. $(window).on("orientationchange", function () {
  228. // IOS often does not complete updating innerHeight and innerWidth
  229. // until after calling orientation changed and resized window
  230. // Also, cannot use $(window).height() call since iOS11 needs padding amount
  231. iphoneXFirstPass = false
  232. if (IOS && isMobileMode()) setTimeout(function () { $axure.player.resizeContent(true); }, 250);
  233. });
  234. $('#mainPanel').scroll(function () {
  235. repositionClippingBoundsScroll();
  236. });
  237. }
  238. function initializeMainFrame() {
  239. var legacyQString = getQueryString("Page");
  240. if (legacyQString.length > 0) {
  241. location.href = location.href.substring(0, location.href.indexOf("?")) + "#" + PAGE_URL_NAME + "=" + legacyQString;
  242. return;
  243. }
  244. var mainFrame = document.getElementById("mainFrame");
  245. //if it's local file on safari, test if we can access mainframe after its loaded
  246. if (SAFARI && document.location.href.indexOf('file://') >= 0) {
  247. $(mainFrame).on('load', function () {
  248. var canAccess;
  249. try {
  250. var mainFrameWindow = mainFrame.contentWindow || mainFrame.contentDocument;
  251. mainFrameWindow['safari_file_CORS'] = 'Y';
  252. canAccess = mainFrameWindow['safari_file_CORS'] === 'Y';
  253. } catch (err) {
  254. canAccess = false;
  255. }
  256. if (!canAccess) window.location = 'resources/chrome/safari.html';
  257. });
  258. }
  259. if($axure.player.settings != null && !$axure.player.settings.isExpo) {
  260. const linkUrlWithVars = $axure.getLinkUrlWithVars(getInitialUrl());
  261. mainFrame.contentWindow.location.href = linkUrlWithVars;
  262. }
  263. }
  264. function initializeDeviceFrame() {
  265. // TODO: Load device bezel and necessary overlays if applicable
  266. // - Need to determine if device has a frame/overlay
  267. // - Determine where to store said assets
  268. // - Determine sizing, positioning, orientation, and styling for HTML containers
  269. // - Verify that it stays consistent for every state (expo)
  270. var expo = $axure.expo;
  271. var project = expo.project;
  272. var device = project.Platform.Device;
  273. // in expo.ts, Web is 12
  274. if (device === 12) {
  275. // Hide containers
  276. $('#deviceFrameContainer').hide();
  277. $('#bezelOverlay').hide();
  278. return;
  279. }
  280. // map devices to their corresponding frame/bezel/overlays
  281. }
  282. var wasMobile = false;
  283. var isMobileMode = $axure.player.isMobileMode = function () { return $axure.utils.isShareApp() || (MOBILE_DEVICE && $(window).width() < 420); }
  284. var isMobileTextEntry = false;
  285. var isViewOverridden = $axure.player.isViewOverridden = function() {
  286. return getHashStringVar(ADAPTIVE_VIEW_VAR_NAME).length > 0;
  287. }
  288. function toggleSitemapMobileMode() {
  289. var $container = $('#sitemapHost');
  290. if (!$container.length) return;
  291. var $header = $container.find('.pluginNameHeader');
  292. var projectName = $axure.player.getProjectName();
  293. if (isMobileMode()) {
  294. $header.text('PROJECT PAGES');
  295. $container.addClass('mobileMode');
  296. $container.find('.sitemapPageName').addClass('mobileText');
  297. // Give sitemapHost left-margin so it does not collide with projectOptionsHost
  298. if (MOBILE_DEVICE) $container.css('margin-left', '13px');
  299. } else {
  300. $container.removeClass('mobileMode');
  301. $header.text(projectName ? projectName : 'Pages');
  302. $container.find('.sitemapPageName').removeClass('mobileText');
  303. if (MOBILE_DEVICE) $container.css('margin-left', '');
  304. }
  305. }
  306. function togglePageNotesMobileMode() {
  307. var $container = $('#pageNotesHost');
  308. if (!$container.length) return;
  309. if (isMobileMode()) {
  310. $container.addClass('mobileMode');
  311. $('#pageNotesSectionHeader').text('PAGE NOTES');
  312. $('#widgetNotesSectionHeader').text('WIDGET NOTES');
  313. $container.find('.notesPageNameHeader').addClass('mobileSubHeader');
  314. $container.find('.pageNote').addClass('mobileText');
  315. $container.find('.emptyStateTitle').addClass('mobileSubHeader');
  316. $container.find('.emptyStateContent').addClass('mobileText');
  317. } else {
  318. $container.removeClass('mobileMode');
  319. $('#pageNotesSectionHeader').text('Page Notes');
  320. $('#widgetNotesSectionHeader').text('Widget Notes');
  321. $container.find('.notesPageNameHeader').removeClass('mobileSubHeader');
  322. $container.find('.pageNote').removeClass('mobileText');
  323. $container.find('.emptyStateTitle').removeClass('mobileSubHeader');
  324. $container.find('.emptyStateContent').removeClass('mobileText');
  325. }
  326. }
  327. function toggleFeedbackMobileMode() {
  328. var $container = $('#feedbackHost');
  329. if (!$container.length) return;
  330. if (isMobileMode()) {
  331. $container.addClass('mobileMode');
  332. } else {
  333. $container.removeClass('mobileMode');
  334. }
  335. }
  336. $axure.player.updatePlugins = function updatePlugins() {
  337. if (MOBILE_DEVICE && !$axure.utils.isShareApp()) {
  338. var hostPanelPadding = isMobileMode() ? '8px 15px 0px 15px' : '';
  339. $('.rightPanel .leftPanel .mobileOnlyPanel').css('padding', hostPanelPadding);
  340. }
  341. if (isMobileMode()) {
  342. $('body').addClass('mobileMode');
  343. if ($('#debugHost').length) $('#debugHost').hide();
  344. if ($('#handoffHost').length) $('#handoffHost').hide();
  345. } else $('body').removeClass('mobileMode');
  346. toggleSitemapMobileMode();
  347. togglePageNotesMobileMode();
  348. toggleFeedbackMobileMode();
  349. }
  350. // TODO: this is done for IOS and Android (check what can be done for Pixel, etc)
  351. $axure.player.setIsMobileModeTextEntry = function (isTextEntry) {
  352. isMobileTextEntry = isTextEntry;
  353. if (IOS && isTextEntry) {
  354. activateMobileTextEntry()
  355. } else if (IOS) {
  356. setTimeout(deactivateMobileTextEntry, 150);
  357. }
  358. }
  359. function deactivateMobileTextEntry() {
  360. newHeight = window.innerHeight;
  361. var newControlHeight = newHeight - (!$axure.utils.isShareApp() ? 140 : IOS ? 157 : 138);
  362. if (!$('.leftPanel').hasClass('popup')) {
  363. $('.leftPanel').height(newControlHeight);
  364. }
  365. $('.rightPanel').height(newControlHeight);
  366. $('.mobileOnlyPanel').height(newControlHeight);
  367. $('#mobileControlFrameContainer').show();
  368. }
  369. function activateMobileTextEntry() {
  370. $('#mobileControlFrameContainer').hide();
  371. newHeight = window.innerHeight;
  372. var newControlHeight = newHeight - (!$axure.utils.isShareApp() ? 140 : IOS ? 157 : 138);
  373. newControlHeight = newControlHeight + (!$axure.utils.isShareApp() ? 61 : IOS ? 72 : 60);
  374. if (!$('.leftPanel').hasClass('popup')) {
  375. $('.leftPanel').height(newControlHeight);
  376. }
  377. $('.rightPanel').height(newControlHeight);
  378. $('.mobileOnlyPanel').height(newControlHeight);
  379. }
  380. function setAdaptiveView() {
  381. if (typeof noViewport == 'undefined') {
  382. // Block during animation -- end of animation will call resizeContent once completed with isAnimating equal to false
  383. if (!isViewOverridden() && !isAnimating) $axure.messageCenter.postMessage('setAdaptiveViewForSize', { 'width': $('#mainPanel').width(), 'height': $('#mainPanel').height() });
  384. //if (!isViewOverridden()) $axure.messageCenter.postMessage('setAdaptiveViewForSize', { 'width': $('#mainPanel').width(), 'height': $('#mainPanel').height() });
  385. $axure.player.refreshViewPort();
  386. if ($axure.player.updateAdaptiveViewHeader != null) $axure.player.updateAdaptiveViewHeader();
  387. }
  388. }
  389. $axure.player.resizeContent = function (noViewport) {
  390. var isMobile = isMobileMode();
  391. if (wasMobile && !isMobile) {
  392. $('#clippingBoundsScrollContainer').show();
  393. $('#outerContainer').prepend($('.leftPanel'));
  394. $('#outerContainer').append($('.rightPanel'));
  395. $axure.player.updatePlugins();
  396. $('#mHideSidebar').hide();
  397. $('#mobileBrowserControlFrame').hide();
  398. $('#nativeAppControlFrame').hide();
  399. if ($('#topPanel').is(':visible')) {
  400. $('#maximizePanelContainer').hide();
  401. $axure.player.restorePlugins();
  402. } else {
  403. $('.leftPanel').hide();
  404. $('.rightPanel').hide();
  405. if (!MOBILE_DEVICE) $('#maximizePanelContainer').show();
  406. }
  407. $('.leftPanel').css({ 'top': '', 'left': '' });
  408. $('.rightPanel').css({ 'top': '', 'left': '' });
  409. } else if (!wasMobile && isMobile) {
  410. $('#clippingBoundsScrollContainer').hide();
  411. $axure.player.closePopup();
  412. $('#lsplitbar').hide();
  413. $('#rsplitbar').hide();
  414. $('.leftPanel').show();
  415. $('.rightPanel').show();
  416. $axure.player.updatePlugins();
  417. $('#mHideSidebar').append($('.leftPanel'));
  418. $('#mHideSidebar').append($('.rightPanel'));
  419. if (MOBILE_DEVICE) $('#maximizePanelContainer').hide();
  420. $axure.messageCenter.postMessage('collapseFrameOnLoad');
  421. }
  422. var newHeight = 0;
  423. var newWidth = 0;
  424. if (iphoneX && $axure.utils.isShareApp()) {
  425. // Hack for Iphone X
  426. newHeight = $(window).height() - ((!isMobile && $('#topPanel').is(':visible')) ? $('#topPanel').height() : 0);
  427. newWidth = $(window).width();
  428. // This does not need to make sense, since it is Iphone X
  429. var notchAndHomeOffsetPortrait = iphoneXFirstPass ? 35 : 5;
  430. var notchOffsetLandscape = iphoneXFirstPass ? 45 : 10;
  431. var homeButtonOffsetLandscape = iphoneXFirstPass ? 21 : 10;
  432. if (newHeight > newWidth) {
  433. newHeight = newHeight + notchAndHomeOffsetPortrait;
  434. } else {
  435. newWidth = newWidth + notchOffsetLandscape * 2;
  436. newHeight = newHeight + homeButtonOffsetLandscape;
  437. }
  438. } else {
  439. // innerHeight includes padding for window -- needed in iOS 11 to have prototype stretch to bottom of screen (could put in -- if (iOS) -- block if needed)
  440. //var newHeight = $(window).height() - ((!isMobile && $('#topPanel').is(':visible'))? $('#topPanel').height() : 0);
  441. newHeight = window.innerHeight - ((!isMobile && $('#topPanel').is(':visible')) ? $('#topPanel').height() : 0);
  442. newWidth = $(window).width();
  443. }
  444. $('#outerContainer').height(newHeight).width(newWidth);
  445. $('#mainPanel').height(newHeight);
  446. $('#clippingBounds').height(newHeight);
  447. if (isMobile) {
  448. $('#mobileControlFrameContainer').height(newHeight);
  449. $('#mobileControlFrameContainer').width(newWidth);
  450. var newControlHeight = newHeight - (!MOBILE_DEVICE ? 112 : !$axure.utils.isShareApp() ? 140 : IOS ? 157 : 138);
  451. // Screen resize is only way through browser to catch mobile device keyboard expand and collapse
  452. if ($('#mHideSidebar').is(':visible') && !$('#mobileControlFrameContainer').is(':visible')) {
  453. $('#mobileControlFrameContainer').delay(150).show();
  454. } else if (isMobileTextEntry) {
  455. newControlHeight = newControlHeight + (!$axure.utils.isShareApp() ? 61 : IOS ? 72 : 60);
  456. $('#mobileControlFrameContainer').hide();
  457. }
  458. if(!$('.leftPanel').hasClass('popup')) {
  459. $('.leftPanel').height(newControlHeight);
  460. }
  461. $('.rightPanel').height(newControlHeight);
  462. $('.mobileOnlyPanel').height(newControlHeight);
  463. } else {
  464. if (!$('.leftPanel').hasClass('popup')) {
  465. $('.leftPanel').css('height','');
  466. }
  467. $('.rightPanel').css('height', '');
  468. if ($('.rightPanel').is(':visible')) {
  469. var lastRightPanelWidthDefaultSub = ($(window).width() - lastRightPanelWidthDefault || 0);
  470. var rightPanelWidth = ($('.rightPanel').width() || 0);
  471. var leftPanelPanelWidthSub = ($(window).width() - $('.leftPanel').width()) || 0;
  472. var newWidth = Math.min(lastRightPanelWidthDefaultSub, rightPanelWidth, leftPanelPanelWidthSub);
  473. lastRightPanelWidth = Math.max(lastRightPanelWidthDefault, newWidth);
  474. $('.rightPanel').width(lastRightPanelWidth ? lastRightPanelWidth : lastRightPanelWidthDefault);
  475. $('#rsplitbar').css('left', $(window).width() - $('.rightPanel').width());
  476. }
  477. if ($('.leftPanel').is(':visible')) {
  478. var lastLeftPanelWidthSub = ($(window).width() - lastLeftPanelWidthDefault || 0);
  479. var leftPanelWidth = ($('.leftPanel').width() || 0);
  480. var rightPanelWidthSub = ($(window).width() - $('.rightPanel').width()) || 0;
  481. var newWidth = Math.min(lastLeftPanelWidthSub, leftPanelWidth, rightPanelWidthSub);
  482. lastLeftPanelWidth = Math.max(lastLeftPanelWidthDefault, newWidth);
  483. $('.leftPanel').width(lastLeftPanelWidth ? lastLeftPanelWidth : lastLeftPanelWidthDefault);
  484. $('#lsplitbar').css('left', $('.leftPanel').width() - 4);
  485. }
  486. }
  487. if (isMobile) {
  488. var newControlWidth = newWidth - 80;
  489. $('.leftPanel').css({ 'width': newControlWidth + 'px' });
  490. $('.rightPanel').css({ 'width': newControlWidth + 'px' });
  491. $('.mobileOnlyPanel').css({ 'width': newControlWidth + 'px' });
  492. adjustM('left');
  493. }
  494. updateClippingBoundsWidth();
  495. repositionClippingBoundsScroll();
  496. setAdaptiveView();
  497. wasMobile = isMobile;
  498. }
  499. function contentDocument_onload() {
  500. (function setRepositionWhenReady() {
  501. var $iframe = $('#mainPanel').find('iframe')[0];
  502. if ($($iframe.contentWindow.document.body).length === 0 || $iframe.contentWindow.document.URL === "about:blank") {
  503. setTimeout(setRepositionWhenReady, 50);
  504. } else {
  505. var $iframe = $($('#mainPanel').find('iframe')[0].contentWindow.document);
  506. $iframe.scroll(function () {
  507. repositionClippingBoundsScroll();
  508. });
  509. }
  510. })();
  511. }
  512. // This is the full width and height of the prototype (beyond the window width and height)
  513. var determineIframeDimensions = function () {
  514. var $iframe = $($('#mainPanel').find('iframe')[0].contentWindow);
  515. return {
  516. width: $iframe.width(),
  517. height: $iframe.height()
  518. };
  519. };
  520. // Position of this (upper left hand corner) should match the existingPinPanel position
  521. var determineIframePosition = function () {
  522. var dimensions = determineIframeDimensions();
  523. var $iframe = $($('#mainPanel').find('iframe')[0].contentWindow);
  524. var $body = $($iframe[0].document.body);
  525. var bodyWidth = $body.offset().left !== 0 ? $body.width() : dimensions.width;
  526. if (FIREFOX) {
  527. var left = $body[0].getBoundingClientRect().left;
  528. bodyWidth = left !== 0 ? $body.width() : dimensions.width;
  529. }
  530. return {
  531. top: 0,// Math.max(0, (dimensions.height - $($iframe[0].document.body).height()) / 2),
  532. left: Math.max(0, (dimensions.width - bodyWidth) / 2)
  533. };
  534. };
  535. // Return iframe scroll top and scroll left
  536. var determineIframeScroll = function () {
  537. var $iframe = $($('#mainPanel').find('iframe')[0].contentWindow);
  538. return {
  539. scrollTop: $iframe.scrollTop(),
  540. scrollLeft: $iframe.scrollLeft()
  541. };
  542. };
  543. function calculateClippingBoundsWidth(panelSize, isLeftPanel) {
  544. var $leftPanel = $('.leftPanel:visible');
  545. var leftPanelOffset = (!isMobileMode() && $leftPanel.length > 0 && !$leftPanel.hasClass('popup')) ? $leftPanel.width() : 0;
  546. var $rightPanel = $('.rightPanel:visible');
  547. var rightPanelOffset = (!isMobileMode() && $rightPanel.length > 0) ? $rightPanel.width() : 0;
  548. // Replace current panel size with panel size after animation for expand or collapse completes
  549. if (typeof panelSize !== 'undefined') {
  550. if (isLeftPanel) leftPanelOffset = panelSize;
  551. else rightPanelOffset = panelSize;
  552. }
  553. return $(window).width() - rightPanelOffset - leftPanelOffset;
  554. }
  555. var updateClippingBoundsWidth = $axure.player.updateClippingBoundsWidth = function () {
  556. if ($('.leftPanel').is(':visible')) $('#clippingBounds').css('left', $('.leftPanel').width());
  557. else $('#clippingBounds').css('left', '0px');
  558. $('#clippingBounds').width(calculateClippingBoundsWidth());
  559. }
  560. var contentLeftOfOriginOffset = 0;
  561. function calculateClippingBoundsScrollPosition() {
  562. // Adjust for mainPanelContainer scaling (scale should be "none" for scaleVal == 0 or scaleVal == 1)
  563. var $iframe = $($('#mainPanel').find('iframe')[0].contentWindow);
  564. var selectedScale = $('.vpScaleOption').find('.selectedRadioButton');
  565. var scaleVal = $(selectedScale).parent().attr('val');
  566. var dimStr = $('.currentAdaptiveView').attr('data-dim');
  567. var dim = dimStr ? dimStr.split('x') : { w: '0', h: '0' };
  568. var isDevice = dim[1] != '0' ? true : false;
  569. // This line is necessary for right handling DEFAULT SCALE
  570. // Because default scale relates to scale-to-fit item for device projects
  571. if (scaleVal == '0' && isDevice) scaleVal = 2;
  572. var scale = $('#mainPanelContainer').css('transform');;
  573. scale = (scale == "none") ? 1 : Number(scale.substring(scale.indexOf('(') + 1, scale.indexOf(',')));
  574. // Iframe and Main Panel Positioning
  575. var iframeScroll = determineIframeScroll();
  576. var iframePos = determineIframePosition();
  577. var viewablePanelLeftMargin = parseInt($('#mainPanelContainer').css('margin-left'));
  578. var viewablePanelTop = parseInt($('#mainPanelContainer').css('top'));
  579. if (isNaN(viewablePanelTop)) viewablePanelTop = 0;
  580. if (scaleVal == 2) {
  581. // Scale to Fit (account for main panel container scale) -- needed for device mode in Scale to Fit
  582. viewablePanelLeftMargin = ($('#mainPanel').width() - ($('#mainPanelContainer').width() * scale)) / 2
  583. viewablePanelTop = ($('#mainPanel').height() - ($('#mainPanelContainer').height() * scale)) / 2
  584. }
  585. // left and top positioning
  586. var leftPos = viewablePanelLeftMargin + (iframePos.left - iframeScroll.scrollLeft) * scale;
  587. var topPos = viewablePanelTop - iframeScroll.scrollTop * scale;
  588. // Special cases for Centered Page
  589. var isCentered = $($iframe[0].document.body).css('position') == 'relative';
  590. if (isCentered && scaleVal == 1) leftPos = 0;
  591. else if (isCentered && scaleVal == 2) leftPos = $('#mainPanelContainer').width() * scale / 2.0 - contentLeftOfOriginOffset;
  592. // Include clipFrameScroll offset in mainPanelContainer
  593. topPos += (parseFloat($('#clipFrameScroll').css("top")) || 0) * scale;
  594. return {
  595. left: leftPos,
  596. top: topPos
  597. }
  598. }
  599. function repositionClippingBoundsScroll() {
  600. if (!$axure.player.settings.isAxshare) return;
  601. (function repositionWhenReady() {
  602. if ($($('#mainPanel').find('iframe')[0].contentWindow.document.body).length === 0) {
  603. setTimeout(repositionWhenReady, 50);
  604. } else {
  605. var position = calculateClippingBoundsScrollPosition();
  606. // Adding mainPanel scroll here, since it does not work well with calculating animation left position
  607. position.left = position.left - $('#mainPanel').scrollLeft() - $('#clipFrameScroll').scrollLeft();
  608. position.top = position.top - $('#mainPanel').scrollTop() - $('#clipFrameScroll').scrollTop();
  609. $('#clippingBoundsScrollContainer').css('left', position.left + 'px');
  610. $('#clippingBoundsScrollContainer').css('top', position.top + 'px');
  611. }
  612. })();
  613. }
  614. function calculateScrollLeftWithOffset(offset, isLeftPanel) {
  615. if (!$axure.player.settings.isAxshare) return;
  616. if ($($('#mainPanel').find('iframe')[0].contentWindow.document.body).length === 0) return;
  617. var scaleVal = $('.vpScaleOption').find('.selectedRadioButton').parent().attr('val');
  618. if (scaleVal == 2) return;
  619. var $iframe = $($('#mainPanel').find('iframe')[0].contentWindow);
  620. var $body = $($iframe[0].document.body);
  621. var dimStr = $('.currentAdaptiveView').attr('data-dim');
  622. var hasFrame = (!dimStr ? false : dimStr.split('x')[1] != '0') && !$axure.player.noFrame;
  623. var isCentered = $body.css('position') == 'relative'; //body position is always static while page is still loading (thus false, if called on intial load)
  624. var isCollapsing = offset > 0; //offset is positive when collapsing since we are gaining offset more space for content viewing
  625. // Base case left positioning
  626. var leftPos = calculateClippingBoundsScrollPosition().left;
  627. // If maintaining view options requires a left adjustment not equivalent to panel size (which has already being added in leftPos above)
  628. var viewAdjustment = 0;
  629. // Mobile Frame adjustment
  630. if (hasFrame) {
  631. var viewablePanelLeftMargin = parseInt($('#mainPanelContainer').css('margin-left'));
  632. var viewablePanelRightMargin = parseInt($('#mainPanelContainer').css('margin-right'));
  633. // Cases
  634. // 0) Adaptive view frame doesn't fit in viewable bounds (viewablePanelLeftMargin is zero) -- use entire offset of panel (no adjustment needed)
  635. // 1) Adaptive view frame fits in bounds -- then half of incoming panel will be split left and half right (offset / 2)
  636. // 2) and 3) View Frame either fits in bounds before animation and no longer will after, or vice versa. Mix of previous two cases
  637. if (isCollapsing) {
  638. if (viewablePanelLeftMargin != 0) {
  639. viewAdjustment = offset / 2;
  640. } else if (-viewablePanelRightMargin < offset) {
  641. viewAdjustment = ((offset + viewablePanelRightMargin) / 2);
  642. }
  643. } else if (viewablePanelLeftMargin != 0) {
  644. viewAdjustment = Math.max(offset / 2, -viewablePanelLeftMargin)
  645. }
  646. }
  647. // Centered Page adjustment
  648. if (isCentered) {
  649. // Width of content not able to fit inside current viewable frame
  650. var clippedContentWidth = $body.width() - calculateClippingBoundsWidth(Math.abs(offset), isLeftPanel);
  651. // Cases
  652. // 0) Content never fits in bounds -- then entire offset of panel will move content left value (no adjustment needed as already handled)
  653. // 1) Content fits in bounds -- then half of incoming panel offset will be split left and half right (offset / 2)
  654. // 2) and 3) Content either fits in bounds before animation and no longer will after, or vice versa. Mix of previous two cases
  655. if (clippedContentWidth <= 0) {
  656. viewAdjustment = offset / 2;
  657. } else if (isCollapsing && clippedContentWidth < offset) {
  658. viewAdjustment = (offset - clippedContentWidth) / 2;
  659. } else if (!isCollapsing && clippedContentWidth < -offset) {
  660. viewAdjustment = (clippedContentWidth + offset) / 2;
  661. }
  662. }
  663. return leftPos + viewAdjustment;
  664. }
  665. // Set to true when left panel or right panel are being expanded/collapsed
  666. // returns to false when lsplitbar (switched to clippingBounds) finishes animation (thus panels will be fully expanded or retracted at this point)
  667. var isAnimating = $axure.player.isAnimating = false;
  668. $axure.player.collapseToBar = function (context, hostId) {
  669. lastLeftPanelWidth = $('.leftPanel').width();
  670. lastRightPanelWidth = $('.rightPanel').width();
  671. if (context === 'project' || context === 'all') {
  672. if(!isMobileMode()) {
  673. isAnimating = true;
  674. var newWidth = lastLeftPanelWidth != 0 ? lastLeftPanelWidth : lastLeftPanelWidthDefault;
  675. var clippingWidth = calculateClippingBoundsWidth(0, true);
  676. var newLeft = calculateScrollLeftWithOffset(newWidth, true);
  677. $('.leftPanel').animate({ 'margin-left': -newWidth + 'px' },
  678. { duration: 200, complete: function() { $('.leftPanel').width(0).hide().css({ 'margin-left': '' }); } });
  679. $('#lsplitbar').animate({ left: '-4px' },
  680. { duration: 200, complete: function() { $('#lsplitbar').hide(); } });
  681. $('#clippingBounds').animate({ left: '', width: clippingWidth + 'px' }, { duration: 200 });
  682. $('#clippingBoundsScrollContainer').animate({ left: newLeft + 'px' },
  683. { duration: 200, complete: function () {
  684. isAnimating = false;
  685. $axure.player.resizeContent();
  686. $axure.player.pluginVisibleChanged(hostId, false);
  687. }});
  688. } else {
  689. $('.leftPanel').width(0);
  690. $('#lsplitbar').hide();
  691. }
  692. }
  693. if (context === 'inspect' || context === 'all') {
  694. if (!isMobileMode()) {
  695. isAnimating = true;
  696. var newWidth = lastRightPanelWidth != 0 ? lastRightPanelWidth : lastRightPanelWidthDefault;
  697. var clippingWidth = calculateClippingBoundsWidth(0, false);
  698. var newLeft = calculateScrollLeftWithOffset(newWidth, false);
  699. $('.rightPanel').animate({ 'margin-right': -newWidth + 'px' },
  700. { duration: 200, complete: function () { $('.rightPanel').width(0).hide().css({ 'margin-right': '' }); } });
  701. $('#rsplitbar').animate({ left: $(window).width() + 'px' },
  702. { duration: 200, complete: function () { $('#rsplitbar').hide(); } });
  703. $('#clippingBounds').animate({ width: clippingWidth + 'px' }, { duration: 200 });
  704. $('#clippingBoundsScrollContainer').animate({ left: newLeft + 'px' },
  705. { duration: 200, complete: function () {
  706. isAnimating = false;
  707. $axure.player.resizeContent();
  708. $axure.player.pluginVisibleChanged(hostId, false);
  709. }});
  710. } else {
  711. $('.rightPanel').width(0);
  712. $('#rsplitbar').hide();
  713. }
  714. }
  715. $(window).resize();
  716. toolBarOnly = true;
  717. }
  718. $axure.player.expandFromBar = function (hostId, context, isFinalPluginToRestore) {
  719. if (context === 'project') {
  720. if ($('#lsplitbar').is(':visible')) return;
  721. $('.leftPanel').removeClass('popup');
  722. if(!isMobileMode()) {
  723. isAnimating = true;
  724. var newWidth = (lastLeftPanelWidth ? lastLeftPanelWidth : lastLeftPanelWidthDefault);
  725. var clippingWidth = calculateClippingBoundsWidth(newWidth, true);
  726. var newLeft = calculateScrollLeftWithOffset(-newWidth, true);
  727. $('.leftPanel').width(newWidth);
  728. $('.leftPanel').css('margin-left', -newWidth + 'px').show();
  729. $('.leftPanel').animate({ 'margin-left': '0px' }, { duration: 200, complete: function () { $('.leftPanel').css({ 'margin-left': '' }); } });
  730. $('#lsplitbar').css('left', '-4px');
  731. $('#lsplitbar').show();
  732. $('#lsplitbar').animate({ left: newWidth - 4 + 'px' }, { duration: 200 });
  733. $('#clippingBounds').animate({ left: newWidth + 'px', width: clippingWidth + 'px' }, { duration: 200 });
  734. $('#clippingBoundsScrollContainer').animate({ left: newLeft + 'px' },
  735. { duration: 200, complete: function () {
  736. isAnimating = false;
  737. $axure.player.resizeContent();
  738. if (isFinalPluginToRestore) $('#clippingBoundsScrollContainer').show();
  739. $axure.player.pluginVisibleChanged(hostId, true);
  740. }});
  741. }
  742. } else {
  743. if ($('#rsplitbar').is(':visible')) {
  744. // update width of rightPanel plugin
  745. var newWidth = lastRightPanelWidth ? lastRightPanelWidth : lastRightPanelWidthDefault;
  746. $('#' + hostId).width(newWidth);
  747. $('#' + hostId).show();
  748. $axure.player.pluginVisibleChanged(hostId, true);
  749. return;
  750. }
  751. if (!isMobileMode()) {
  752. isAnimating = true;
  753. var newWidth = lastRightPanelWidth ? lastRightPanelWidth : lastRightPanelWidthDefault;
  754. var clippingWidth = calculateClippingBoundsWidth(newWidth, false);
  755. var newLeft = calculateScrollLeftWithOffset(-newWidth, false);
  756. $('.rightPanel').width(newWidth);
  757. $('.rightPanel').css('margin-right', -newWidth + 'px');
  758. $('#' + hostId).show();
  759. $('.rightPanel').animate({ 'margin-right': '0px' }, { duration: 200, complete: function () { $('.rightPanel').css({ 'margin-right': '' }); } });
  760. $('#rsplitbar').css('left', $(window).width());
  761. $('#rsplitbar').show();
  762. $('#rsplitbar').animate({ left: $(window).width() - $('.rightPanel').width() + 'px' }, { duration: 200 });
  763. $('#clippingBounds').animate({ width: clippingWidth + 'px' }, { duration: 200 });
  764. $('#clippingBoundsScrollContainer').animate({ left: newLeft + 'px' },
  765. { duration: 200, complete: function () {
  766. isAnimating = false;
  767. $axure.player.resizeContent();
  768. if (isFinalPluginToRestore) $('#clippingBoundsScrollContainer').show();
  769. $axure.player.pluginVisibleChanged(hostId, true);
  770. }});
  771. }
  772. }
  773. $(window).resize();
  774. toolBarOnly = false;
  775. if (isMobileMode()) {
  776. $('#mHideSidebar').show();
  777. $('#nativeAppControlFrame').show();
  778. }
  779. }
  780. var suspendRefreshViewPort = $axure.player.suspendRefreshViewPort = false;
  781. $axure.player.refreshViewPort = function () {
  782. if (suspendRefreshViewPort) return;
  783. var dimStr = $('.currentAdaptiveView').attr('data-dim');
  784. var dim = dimStr ? dimStr.split('x') : { w: '0', h: '0' };
  785. var w = dim[0] != '0' ? dim[0] : '';
  786. var h = dim[1] != '0' ? dim[1] : '';
  787. var scaleVal = $('.vpScaleOption').find('.selectedRadioButton').parent().attr('val');
  788. var selectedScaleValue = scaleVal;
  789. $axure.player.noFrame = false;
  790. if (h && scaleVal == 1) $axure.player.noFrame = true;
  791. $('#mainPanelContainer').attr({
  792. "data-scale-n": scaleVal,
  793. "data-page-dimensions-type": h ? "device" : w ? "web" : "auto",
  794. "data-scale-shift-x": null,
  795. "data-scale-shift-y": null,
  796. });
  797. var clipToView = h && !$axure.player.noFrame;
  798. var isDevice = h;
  799. var mainPanelWidth = $('#mainPanel').width();
  800. var mainPanelHeight = $('#mainPanel').height();
  801. if (!w || !clipToView) w = mainPanelWidth;
  802. if (!h || !clipToView) h = mainPanelHeight;
  803. if (MOBILE_DEVICE && h > mainPanelHeight) h = mainPanelHeight;
  804. if (MOBILE_DEVICE && w > mainPanelWidth) w = mainPanelWidth;
  805. if (clipToView) {
  806. if (!MOBILE_DEVICE && scaleVal == '0') scaleVal = 2;
  807. w = Number(w);
  808. h = Number(h);
  809. $('#mainFrame').width(w);
  810. $('#clipFrameScroll').width(w);
  811. $('#mainFrame').height(h);
  812. $('#clipFrameScroll').height(h);
  813. var topPadding = MOBILE_DEVICE ? 0 : 10;
  814. var leftPadding = 0;
  815. var rightPadding = 0;
  816. var bottomPadding = MOBILE_DEVICE ? 0 : 10;
  817. w = w + leftPadding + rightPadding;
  818. h = h + topPadding + bottomPadding;
  819. var x = (mainPanelWidth - w) / 2;
  820. var y = (mainPanelHeight - h) / 2 - 1;
  821. if (scaleVal != 2) {
  822. x = Math.max(0, x);
  823. y = Math.max(0, y);
  824. }
  825. $('#mainPanelContainer').attr({
  826. "data-scale-shift-x": x,
  827. "data-scale-shift-y": y,
  828. });
  829. $('#mainPanelContainer').css({
  830. 'margin': 'auto',
  831. 'top': y + 'px',
  832. 'left': (x < 0 ? x + 'px' : 'auto')
  833. });
  834. $('#clipFrameScroll').css({
  835. 'left': leftPadding + 'px',
  836. 'top': topPadding + 'px'
  837. });
  838. $('#mainPanelContainer').width(w);
  839. $('#mainPanelContainer').height(h);
  840. } else {
  841. $('#mainFrame').width('100%');
  842. $('#mainFrame').height(h);
  843. $('#clipFrameScroll').width('100%');
  844. $('#clipFrameScroll').height(h);
  845. $('#clipFrameScroll').css({ 'left': '', 'top': '' });
  846. $('#mainPanelContainer').width('100%');
  847. $('#mainPanelContainer').height(h);
  848. $('#mainPanelContainer').css({
  849. 'left': '',
  850. 'margin': '',
  851. 'top': ''
  852. });
  853. }
  854. $axure.messageCenter.postMessage('setDeviceMode', { device: isDevice, width: w, scaleToWidth: (scaleVal == "1") });
  855. $(".vpScaleOption").show();
  856. var prevScaleN = $('#mainPanelContainer').css('transform');
  857. prevScaleN = (prevScaleN == "none") ? 1 : Number(prevScaleN.substring(prevScaleN.indexOf('(') + 1, prevScaleN.indexOf(',')));
  858. var newScaleN = 1;
  859. $('#mainPanelContainer').css({
  860. 'transform': '',
  861. 'transform-origin': ''
  862. });
  863. var $leftPanel = $('.leftPanel:visible');
  864. var leftPanelOffset = (!isMobileMode() && $leftPanel.length > 0) ? $leftPanel.width() : 0;
  865. var $rightPanel = $('.rightPanel:visible');
  866. var rightPanelOffset = (!isMobileMode() && $rightPanel.length > 0) ? $rightPanel.width() : 0;
  867. var vpScaleData = {
  868. scale: scaleVal,
  869. prevScaleN: prevScaleN,
  870. viewportHeight: h,
  871. viewportWidth: w,
  872. panelWidthOffset: leftPanelOffset + rightPanelOffset,
  873. clipToView: clipToView
  874. };
  875. $axure.messageCenter.postMessage('getScale', vpScaleData);
  876. $axure.messageCenter.postMessage('cloud_ScaleValueChanged', {
  877. scale: selectedScaleValue,
  878. });
  879. if (scaleVal == '0' && clipToView) $('#mainPanel').css('overflow', 'auto');
  880. else $('#mainPanel').css('overflow', '');
  881. }
  882. $axure.player.getProjectName = function getProjectName() {
  883. if (typeof PREVIEW_INFO !== 'undefined') {
  884. return PREVIEW_INFO.fileName;
  885. } else if(typeof $axure.player.settings.projectName !== 'undefined') {
  886. return $axure.player.settings.projectName;
  887. } else return false;
  888. }
  889. function initializeLogo() {
  890. if(typeof PREVIEW_INFO !== 'undefined') {
  891. $('#previewNotice').show();
  892. }
  893. //if (typeof PREVIEW_INFO !== 'undefined') {
  894. // $('#interfaceControlFrameLogoCaptionContainer').html(PREVIEW_INFO.fileName);
  895. //} else if (typeof $axure.player.settings.projectName !== 'undefined') {
  896. // $('#interfaceControlFrameLogoCaptionContainer').html($axure.player.settings.projectName);
  897. //} else {
  898. // $('#interfaceControlFrameLogoCaptionContainer').hide();
  899. //}
  900. //if ($axure.document.configuration.logoImagePath) {
  901. // var image = new Image();
  902. // //image.onload = function () {
  903. // // //$('#logoImage').css('max-width', this.width + 'px');
  904. // // $('#interfaceControlFrameContainer').css('margin-left', '-' + $('#logoImage').width() / 2 + 'px');
  905. // // //$axure.player.resizeContent();
  906. // //};
  907. // image.src = $axure.document.configuration.logoImagePath;
  908. // $('#interfaceControlFrameLogoImageContainer').html('<img id="logoImage" src="" />');
  909. // $('#logoImage').attr('src', $axure.document.configuration.logoImagePath);//.on('load', function () { $axure.player.resizeContent(); });
  910. //} else $('#interfaceControlFrameLogoImageContainer').hide();
  911. //if ($axure.document.configuration.logoImageCaption) {
  912. // $('#interfaceControlFrameLogoCaptionContainer').html($axure.document.configuration.logoImageCaption);
  913. //} else $('#interfaceControlFrameLogoCaptionContainer').hide();
  914. //if(!$('#interfaceControlFrameLogoImageContainer').is(':visible') && !$('#interfaceControlFrameLogoCaptionContainer').is(':visible')) {
  915. // $('#interfaceControlFrameLogoContainer').hide();
  916. //}
  917. }
  918. function initializePreview() {
  919. if (typeof PREVIEW_INFO !== 'undefined') {
  920. $('#separatorContainer').addClass('hasLeft');
  921. $('#overflowMadeWith').addClass('preview');
  922. var callback = undefined;
  923. $('#publishButton').click(function () {
  924. $.ajax({
  925. type: 'GET',
  926. url: 'publish',
  927. data: {},
  928. success: function (response) {
  929. if (callback) callback(response);
  930. },
  931. error: function (response) {
  932. if (callback) callback(response);
  933. },
  934. dataType: 'jsonp'
  935. });
  936. });
  937. }
  938. }
  939. var userAcct = {
  940. userId: '',
  941. userName: '',
  942. userEmail: '',
  943. userProfileImg: '',
  944. isUsingAxureAcct: false,
  945. }
  946. var authCookieValue = null;
  947. var userCookieValue = null;
  948. var isSubInstance = false;
  949. //var readOnlyMode = false;
  950. //var readOnlyMessage = '';
  951. // Watermark hints
  952. // NOTE: The trailing characters serve to be a distinguishing element in case the user actually does use text similar to the hint.
  953. var emailHint = "Email ";
  954. var passHint = "Password ";
  955. var feedbackServiceUrl = (window.AXSHARE_HOST_SECURE_URL || 'https://share.axure.com') + '/issue';
  956. // Look at creating a new location to have GetShareStatus(FbEnabled replacement) and SafariAuth since they are more general calls that are not solely for feedback now
  957. //var prototypeControlUrl = (window.AXSHARE_HOST_SECURE_URL || 'https://share.axure.com') + '/prototype';
  958. // Checks if the browser is Safari 3.0+
  959. // https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
  960. function isSafari() {
  961. // Safari 3.0+ "[object HTMLElementConstructor]"
  962. var liveSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification));
  963. return liveSafari || SAFARI || (IOS && $axure.utils.isShareApp());
  964. };
  965. function includeTokens(ajaxData, excludeUser) {
  966. //If the authCookieValue is set (a password-protected local prototype), then send the
  967. //token as well (because cookies don't always get sent to external domains)
  968. if (authCookieValue) {
  969. $.extend(ajaxData, { token: authCookieValue });
  970. }
  971. if (!excludeUser && userCookieValue) {
  972. $.extend(ajaxData, { utoken: userCookieValue });
  973. }
  974. }
  975. function setUserLoggedInStatus(response, safariAuthResponseProfile) {
  976. if (!response.success) {
  977. userAcct.isUsingAxureAcct = false;
  978. } else {
  979. if (safariAuthResponseProfile) response = safariAuthResponseProfile;
  980. userAcct.userId = response.userId;
  981. if (safariAuthResponseProfile)
  982. userAcct.userName = response.username == null || response.username.trim() === '' ? response.userEmail : decodeURIComponent(response.username.trim());
  983. else
  984. userAcct.userName = response.nickname == null || response.nickname.trim() === '' ? response.userEmail : decodeURIComponent(response.nickname.trim());
  985. userAcct.userEmail = response.userEmail;
  986. userAcct.userProfileImg = response.profileImageUrl;
  987. userAcct.isUsingAxureAcct = true;
  988. if (response.authToken != null) {
  989. $axshare.setAuthCookie(response.authToken);
  990. userCookieValue = response.authToken;
  991. }
  992. }
  993. // If feedback is loaded, update feedback with new account information
  994. if (typeof feedback !== 'undefined') feedback.updateUserAccountInfo(userAcct, authCookieValue, userCookieValue);
  995. }
  996. // TODO: for on prem, we need to use an ajax call directly to share instead of accounts
  997. // Verify authentication against axure accounts
  998. $axure.player.axureAuth = function axureAuth(callback) {
  999. if (window.$axshare != null) {
  1000. $axshare.auth(function (response) {
  1001. if (response.success) {
  1002. setUserLoggedInStatus(response);
  1003. } else {
  1004. if (isSafari()) {
  1005. var ajaxData = {
  1006. userId: userAcct.isUsingAxureAcct ? userAcct.userId : ""
  1007. };
  1008. includeTokens(ajaxData);
  1009. $.ajax({
  1010. type: 'GET',
  1011. url: feedbackServiceUrl + '/safariAuth',
  1012. data: ajaxData,
  1013. success: function (response) {
  1014. if (!response.success) {
  1015. setUserLoggedInStatus(response);
  1016. } else {
  1017. setUserLoggedInStatus(response, response.data.profile[userAcct.userId]);
  1018. if (callback != null) {
  1019. callback(response);
  1020. }
  1021. }
  1022. },
  1023. dataType: 'jsonp'
  1024. });
  1025. } else {
  1026. setUserLoggedInStatus(response);
  1027. }
  1028. }
  1029. if (callback != null) {
  1030. callback(response);
  1031. }
  1032. });
  1033. }
  1034. }
  1035. // TODO: for on prem, we need to use an ajax call directly to share instead of accounts
  1036. // Log into axure accounts
  1037. $axure.player.axureLogin = function axureLogin(email, password, success, failure, saml) {
  1038. if (window.$axshare != null) {
  1039. password = password === passHint ? "" : password;
  1040. $axshare.login(email, password, false, function (response) {
  1041. if (response.redirecturl !== "" && response.redirecturl != null) {
  1042. saml(response);
  1043. return;
  1044. }
  1045. if (response.success && (response.verified || isSubInstance)) {
  1046. if (isSafari()) setUserLoggedInStatus(response);
  1047. $axure.player.axureAuth(success);
  1048. } else {
  1049. failure(response);
  1050. }
  1051. }, window.ON_PREM_LDAP_ENABLED);
  1052. } else {
  1053. failure();
  1054. }
  1055. }
  1056. function playerLogout() {
  1057. userAcct.isUsingAxureAcct = false;
  1058. userAcct.userId = '';
  1059. userAcct.userProfileImg = '';
  1060. // If feedback is loaded, update feedback with new account information
  1061. if (typeof feedback !== 'undefined') feedback.updateUserAccountInfo(userAcct);
  1062. }
  1063. $axure.player.logout = function (feedbackLogout) {
  1064. var completeLogout = playerLogout;
  1065. if (feedbackLogout) {
  1066. completeLogout = function () {
  1067. feedbackLogout();
  1068. playerLogout();
  1069. }
  1070. }
  1071. if (window.$axshare != null) {
  1072. $axshare.logout(completeLogout);
  1073. } else {
  1074. completeLogout();
  1075. }
  1076. }
  1077. /*
  1078. * TODO: Start of Login/Account Mgmt UI, which will need to be updated (currenly uses feedback9.css often)
  1079. */
  1080. function buildAccountLoginPopup() {
  1081. return [
  1082. '<div class="axClearMsgBubble_Player axureLoginBubble_Player">',
  1083. ' <div class="axureLoginBubbleContainer_Player">',
  1084. ' <span style="font-weight: bold; font-size: 10px;">Login into your Axure Cloud account</span>',
  1085. ' <input type="text" autocapitalize="none" name="email" class="axureEmail" style="margin-top: 7px;"/>',
  1086. ' <input name="password" autocapitalize="none" class="axurePassword" />',
  1087. ' <div class="feedbackGreenBtn_Player">LOG IN</div>',
  1088. ' <div class="errorMessage"></div>',
  1089. ' <div id="playerSignUpLink" style="text-align: right; margin-top: 5px; font-size: 10px;">',
  1090. ' <span>No account? <a class="axureSignUpLink" href="', window.AXSHARE_HOST_SECURE_URL, '" target="_blank">Sign Up</a></span>',
  1091. ' </div>',
  1092. ' </div>',
  1093. '</div>'
  1094. ].join("");
  1095. }
  1096. // Bind events to axure login speech bubble (watermark, login, errors, click outside)
  1097. function bindAxureLoginContainerEvent() {
  1098. var $container = $("#accountLoginContainer");
  1099. $container.find('input[name="email"]').addClass("watermark").val(emailHint).focus(function () {
  1100. if ($(this).val() === emailHint) {
  1101. $(this).removeClass("watermark").val("");
  1102. }
  1103. }).blur(function () {
  1104. if ($(this).val() === "") {
  1105. $(this).addClass("watermark").val(emailHint);
  1106. }
  1107. $container.find('.errorMessage').text('');
  1108. $container.find('.errorMessage').hide();
  1109. }).keyup(function (event) {
  1110. if (event.keyCode == 13) {
  1111. $container.find('.feedbackGreenBtn').click();
  1112. }
  1113. });
  1114. $container.find('input[name="password"]').addClass("watermark").val(passHint).focus(function () {
  1115. if ($(this).val() === passHint) {
  1116. $(this).removeClass("watermark").val("");
  1117. //$(this).removeClass("watermark").val("").attr("type", "password");
  1118. // Note: this might be an issue since jquery doesn't like it. Test in IE
  1119. $(this)[0].setAttribute('type', 'password');
  1120. }
  1121. }).blur(function () {
  1122. if ($(this).val() === "") {
  1123. $(this).val(passHint).addClass("watermark");
  1124. //$(this).val(passHint).addClass("watermark").removeAttr("type");
  1125. // Note: this might be an issue since jquery doesn't like it. Test in IE
  1126. $(this)[0].setAttribute('type', 'text');
  1127. }
  1128. $container.find('.errorMessage').text('');
  1129. $container.find('.errorMessage').hide();
  1130. }).keyup(function (event) {
  1131. if (event.keyCode == 13) {
  1132. $container.find('.feedbackGreenBtn_Player').click();
  1133. }
  1134. });
  1135. // Login Submit Event
  1136. $container.find('.feedbackGreenBtn_Player').click(function (e) {
  1137. var email = $container.find('.axureEmail').val();
  1138. var password = $container.find('.axurePassword').val();
  1139. $axure.player.axureLogin(email, password, function (response) {
  1140. // Success
  1141. // Clear out fields
  1142. $container.find('.axureEmail').val(emailHint).addClass("watermark");
  1143. $container.find('.axurePassword').val(passHint).addClass("watermark");
  1144. $container.find('.axurePassword')[0].setAttribute('type', 'text');
  1145. closePopup();
  1146. }, function (response) {
  1147. // Failure
  1148. $container.find('.errorMessage').text(response != null && response.message ? response.message : "There was an error connecting to the server, please try again later.");
  1149. $container.find('.errorMessage').show();
  1150. }, function (response) {
  1151. // SAML User
  1152. $container.find('.errorMessage').empty();
  1153. $container.find('.errorMessage').append("Please <a class='refreshLink' style='text-decoration: underline;'>refresh</a> this page after logging in via your identity provider.");
  1154. $container.find('.errorMessage').show();
  1155. window.open(response.redirecturl, '_blank');
  1156. $container.find('.errorMessage').find('.refreshLink').click(function () {
  1157. location.reload(true);
  1158. });
  1159. });
  1160. });
  1161. };
  1162. function initializeSignIn() {
  1163. if (typeof PREVIEW_INFO === 'undefined' && $axure.player.settings.isAxshare) {
  1164. (function finishInit() {
  1165. if (window.$axshare == null || $axshare.auth == null || $axshare.login == null) {
  1166. setTimeout(finishInit, 50);
  1167. } else {
  1168. // Call to set readOnlyMode, readOnlyMessage, and isSubinstance (readOnlyMode/Message currently only used for feedback9)
  1169. $.ajax({
  1170. type: 'GET',
  1171. url: feedbackServiceUrl + '/GetShareStatus',
  1172. data: {},
  1173. success: function (response) {
  1174. //readOnlyMode = response.readOnlyMode;
  1175. //readOnlyMessage = response.readOnlyMessage;
  1176. isSubInstance = response.isSubInstance;
  1177. if (isSubInstance) $('#accountLoginContainer').find("#playerSignUpLink").hide();
  1178. // For now, calling methods to set these values in feedback on start (could later make a general method to retrieve these values from player)
  1179. if (typeof feedback !== 'undefined') {
  1180. feedback.setReadOnlyModeAndMessage(response.readOnlyMode, response.readOnlyMessage);
  1181. feedback.setIsSubInstance(isSubInstance);
  1182. }
  1183. },
  1184. dataType: 'jsonp'
  1185. });
  1186. // Login container
  1187. $("#accountLoginContainer").append(buildAccountLoginPopup());
  1188. bindAxureLoginContainerEvent();
  1189. // Attempt to auth and acquire account information, then update top panel
  1190. $axure.player.axureAuth();
  1191. }
  1192. })();
  1193. }
  1194. }
  1195. function overflowIsHidden(node) {
  1196. var style = getComputedStyle(node);
  1197. return style.overflow === 'hidden' || style.overflowX === 'hidden' || style.overflowY === 'hidden';
  1198. }
  1199. function findNearestScrollableParent(firstNode) {
  1200. var node = firstNode;
  1201. var scrollable = null;
  1202. while (!scrollable && node) {
  1203. if (node.scrollWidth > node.clientWidth || node.scrollHeight > node.clientHeight) {
  1204. if (!overflowIsHidden(node) || $(node).css('-webkit-overflow-scrolling') === 'touch') {
  1205. scrollable = node;
  1206. }
  1207. }
  1208. node = node.parentNode;
  1209. }
  1210. return scrollable;
  1211. }
  1212. function getScrollOwner(target) {
  1213. var owner = findNearestScrollableParent(target);
  1214. if (!owner || owner === document.documentElement || owner === document.body || $(owner).parents('#topPanel').length || owner == document.getElementById('forwardSlash')) {
  1215. return null;
  1216. }
  1217. return owner;
  1218. }
  1219. function removeElasticScrollFromIframe() {
  1220. var $iframe = $($('#mainPanel').find('iframe')[0].contentWindow);
  1221. $iframe[0].document.body.addEventListener('touchmove', function (event) {
  1222. if (!getScrollOwner(event.target)) {
  1223. event.preventDefault();
  1224. }
  1225. }, { passive: false });
  1226. }
  1227. $(document).ready(function () {
  1228. (function finishPlayerInit() {
  1229. if ($axure.player.settings.isAxshare) {
  1230. $axure.page.bind('load.start', contentDocument_onload);
  1231. if ($axure.player.settings.loadFeedbackPlugin) {
  1232. $axure.utils.loadJS('/Scripts/plugins/feedback/feedback9.js');
  1233. /******* DEBUG: Allows for debugging/viewing feedback9.js in browser inspect mode ******/
  1234. //var hdr = document.createElement('script');
  1235. //hdr.type = "text/javascript"
  1236. //hdr.src = '/Scripts/plugins/feedback/feedback9.js';
  1237. //document.head.appendChild(hdr);
  1238. }
  1239. }
  1240. initializeEvents();
  1241. initializeMainFrame();
  1242. $('.leftPanel').width(0);
  1243. $('#maximizePanelContainer').hide();
  1244. if ($axure.player.settings.startCollapsed) {
  1245. collapse();
  1246. $('.leftPanel').width(0);
  1247. var maxPanelWidth = $('#maximizePanel').width();
  1248. setTimeout(function() {
  1249. $('#maximizePanel').animate({
  1250. left:'-' + maxPanelWidth + 'px'
  1251. }, 300);
  1252. }, 2000);
  1253. }
  1254. if (MOBILE_DEVICE) {
  1255. $('body').removeClass('hashover');
  1256. if (SAFARI) {
  1257. // Stop pinch zoom (stopping all gestures for now)
  1258. // Gesturestart is only supported in Safari
  1259. document.addEventListener("gesturestart", function (e) {
  1260. e.preventDefault();
  1261. });
  1262. }
  1263. if (IOS) {
  1264. // Attempt at removing elastic scroll while in mobile menu
  1265. var touching = false;
  1266. var pageYStart = 0;
  1267. var pageYOffset = 0;
  1268. document.body.addEventListener('touchend', function (event) {
  1269. if (getScrollOwner(event.target)) {
  1270. touching = false;
  1271. }
  1272. }, { passive: false });
  1273. document.body.addEventListener('touchmove', function (event) {
  1274. var owner = getScrollOwner(event.target)
  1275. if (!owner) {
  1276. event.preventDefault();
  1277. } else {
  1278. if ($(owner).scrollTop() == 0) {
  1279. if (touching) {
  1280. if (event.pageY >= pageYStart) {
  1281. event.preventDefault();
  1282. }
  1283. }
  1284. }
  1285. if ($(owner).scrollTop() + $(owner).height() == owner.scrollHeight) {
  1286. if (touching) {
  1287. if (event.pageY <= pageYStart) {
  1288. event.preventDefault();
  1289. }
  1290. }
  1291. }
  1292. }
  1293. }, { passive: false });
  1294. document.body.addEventListener('touchstart', function (event) {
  1295. var owner = getScrollOwner(event.target);
  1296. if (owner) {
  1297. if ($(owner).scrollTop() == 0) {
  1298. touching = true;
  1299. pageYStart = event.pageY;
  1300. pageYOffset = event.pageY;
  1301. }
  1302. if ($(owner).scrollTop() + $(owner).height() == owner.scrollHeight) {
  1303. touching = true;
  1304. pageYStart = event.pageY;
  1305. pageYOffset = event.pageY;
  1306. }
  1307. }
  1308. }, { passive: false });
  1309. removeElasticScrollFromIframe();
  1310. $('html').css('-webkit-tap-highlight-color', 'transparent');
  1311. // Stop iOS from automatically scaling parts of the mobile player
  1312. // Could stop automatic scaling on Ipads as well that we actually want, but for now, seems fine
  1313. $('body').css('-webkit-text-size-adjust', '100%');
  1314. // Prepare for Iphone X hacks
  1315. // Link for dimensions: https://kapeli.com/cheat_sheets/iOS_Design.docset/Contents/Resources/Documents/index
  1316. var ratio = window.devicePixelRatio || 1;
  1317. // Regular iphoneX
  1318. if (IOS && window.screen.width * ratio == 1125 && window.screen.height * ratio === 2436) {
  1319. iphoneX = true;
  1320. }
  1321. // Iphone XS Max and Iphone XR
  1322. if (IOS && window.screen.width == 414 && window.screen.height === 896) {
  1323. iphoneX = true;
  1324. }
  1325. window.addEventListener("orientationchange", function () {
  1326. var viewport = document.querySelector("meta[name=viewport]");
  1327. //so iOS doesn't zoom when switching back to portrait
  1328. if (iphoneX) {
  1329. viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, viewport-fit=cover');
  1330. viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, viewport-fit=cover');
  1331. } else {
  1332. viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0');
  1333. viewport.setAttribute('content', 'width=device-width, initial-scale=1.0');
  1334. }
  1335. $axure.player.resizeContent();
  1336. }, false);
  1337. $axure.page.bind('load.start', function () {
  1338. $axure.player.resizeContent();
  1339. });
  1340. }
  1341. // Always append both mobile browser menu and native menu, as app might not have returned value signifying native at this point
  1342. appendNativePrototypeControlFrame();
  1343. appendMobileBrowserControlFrame();
  1344. appendProjectOptions();
  1345. }
  1346. initializeLogo();
  1347. initializePreview();
  1348. $axure.player.resizeContent(true);
  1349. // Has timeout to keep waiting to build sign in controls while axAccount is still loading
  1350. initializeSignIn();
  1351. })();
  1352. });
  1353. function appendProjectOptions() {
  1354. var toAppend = '';
  1355. toAppend += '<div id="projectOptionsHost" class="mobileOnlyPanel mobileMode">';
  1356. toAppend += ' <div class="pluginNameHeader">PROJECT OPTIONS</div>';
  1357. toAppend += ' <div id="projectOptionsScrollContainer">';
  1358. toAppend += ' <div class="mobileSubHeader">Hotspots</div>';
  1359. toAppend += ' <div id="projectOptionsShowHotspots" class="mobileText projectOptionsHotspotsRow" style="border-bottom: solid 1px #c7c7c7">';
  1360. toAppend += ' <div id="projectOptionsHotspotsCheckbox"></div>';
  1361. toAppend += ' Show Hotspots</div> ';
  1362. toAppend += ' <div class="mobileSubHeader" style="margin-top: 16px">Scale</div>';
  1363. toAppend += ' <div id="projectOptionsScaleContainer" class="mobileText"></div>';
  1364. toAppend += ' <div id="projectOptionsAdaptiveViewsHeader" class="mobileSubHeader" style="margin-top: 16px">Adaptive Views</div>';
  1365. toAppend += ' <div id="projectOptionsAdaptiveViewsContainer" class="mobileText"></div>'
  1366. toAppend += ' </div>'
  1367. toAppend += '</div>';
  1368. $('#mHideSidebar').prepend(toAppend);
  1369. $(('#projectOptionsHost')).click(function (e) { e.stopPropagation(); });
  1370. if (isMobileMode()) $axure.player.resizeContent();
  1371. }
  1372. function appendMobileBrowserControlFrame() {
  1373. var toAppend = "";
  1374. toAppend += '<div id="mobileBrowserControlFrame" class="mobilePrototypeControlFrame">';
  1375. toAppend += ' <div id="return" style="width:100%; position:relative; top:-15px; float:left">';
  1376. toAppend += ' <div id="closeBackground" class="circleBackground">';
  1377. toAppend += ' <div id="forwardSlash" class="closeIconSlash"><div id="backwardSlash" class="closeIconSlash"></div></div>';
  1378. toAppend += ' </div>';
  1379. toAppend += ' </div>';
  1380. toAppend += '</div>';
  1381. $('#mobileControlFrameContainer').append(toAppend);
  1382. $('#closeBackground').click(collapse);
  1383. // iOS will do incorrect click position / content bounds calculation which results in scroll getting reset to (0, 0)
  1384. if (IOS) $('#mobileControlFrameContainer').on($axure.eventNames.mouseDownName, function (e) { e.stopPropagation(); });
  1385. }
  1386. function appendNativePrototypeControlFrame() {
  1387. var toAppend = "";
  1388. toAppend += '<div id="nativeAppControlFrame" class="mobilePrototypeControlFrame">';
  1389. toAppend += ' <ul id="nativeMenuBlueBackground">';
  1390. toAppend += ' <li style="width:30%; float:left;">';
  1391. toAppend += ' <div id="exit" class="nativePrototypeButton" >';
  1392. toAppend += ' <div>';
  1393. toAppend += ' <div id="exitIcon"></div>';
  1394. toAppend += ' <div id="exitText" class="nativeMenuText">Exit</div>';
  1395. toAppend += ' </div>';
  1396. toAppend += ' </div>';
  1397. toAppend += ' </li>';
  1398. toAppend += ' <li id="return" style="width:40%; position:relative; top:-15px; float:left">';
  1399. toAppend += ' <div id="returnBackground" class="circleBackground">';
  1400. toAppend += ' <div id="returnIcon"></div>';
  1401. toAppend += ' </div>';
  1402. toAppend += ' <div id="returnText" class="nativeMenuText">Return to Prototype</div>';
  1403. toAppend += ' </li>';
  1404. toAppend += ' <li style="width:30%; float:right;">';
  1405. toAppend += ' <div id="refresh" class="nativePrototypeButton" >';
  1406. toAppend += ' <div>';
  1407. toAppend += ' <div id="refreshIcon"></div>';
  1408. toAppend += ' <div id="refreshText" class="nativeMenuText">Refresh</div>';
  1409. toAppend += ' </div>';
  1410. toAppend += ' </div>';
  1411. toAppend += ' </li>';
  1412. toAppend += ' </ul>';
  1413. toAppend += '</div>';
  1414. $('#mobileControlFrameContainer').append(toAppend);
  1415. var barHeight = IOS ? (iphoneX ? '82px' : '72px') : '60px';
  1416. var returnIconDisplacement = IOS ? '-15px': '-20px';
  1417. var iconTopMargin = IOS ? '14px': '7px';
  1418. var returnTextTopMargin = IOS ? '9px': '7px';
  1419. document.getElementById('nativeAppControlFrame').style.height = barHeight;
  1420. document.getElementById('nativeMenuBlueBackground').style.height = barHeight;
  1421. document.getElementById('return').style.top = returnIconDisplacement;
  1422. document.getElementById('returnText').style.marginTop = returnTextTopMargin;
  1423. document.getElementById('refreshIcon').style.marginTop = iconTopMargin;
  1424. document.getElementById('exitIcon').style.marginTop = iconTopMargin;
  1425. addAppButtonClickListener("exit");
  1426. addAppButtonClickListener("refresh");
  1427. $('#returnBackground').click(collapse);
  1428. $('#nativeAppControlFrame').on('touchmove', function (e) {
  1429. e.stopPropagation();
  1430. }, false);
  1431. }
  1432. function addAppButtonClickListener(id) {
  1433. var func = function () { IOS ? window.webkit.messageHandlers.prototypeMenuButtonClick.postMessage(id) : ShareApp.PrototypeMenuButtonClick(id); };
  1434. document.getElementById(id).addEventListener("click", func, false);
  1435. }
  1436. function toggleSitemap() {
  1437. $axure.player.showPlugin(1);
  1438. }
  1439. function closePopup() {
  1440. var $container = $('.popup');
  1441. var isLeftPanel = $container.hasClass('leftPanel');
  1442. $container.removeClass('popup');
  1443. $('#overflowMenuButton').removeClass('selected');
  1444. $('#interfaceAdaptiveViewsContainer').removeClass('selected');
  1445. $container.hide();
  1446. $('div.splitterMask').unbind($axure.eventNames.mouseDownName, closePopup);
  1447. $('div.splitterMask').remove();
  1448. }
  1449. $axure.player.closePopup = closePopup;
  1450. function showPopup($container) {
  1451. if ($('#browserOutOfDateNotification').is(":visible")) return;
  1452. $container.addClass('popup');
  1453. $container.show();
  1454. $('<div class="splitterMask"></div>').insertAfter($container);
  1455. $('div.splitterMask').bind($axure.eventNames.mouseDownName, closePopup);
  1456. }
  1457. $axure.player.showPopup = showPopup;
  1458. function toggleAdaptiveViewsPopup() {
  1459. if (($('#interfaceAdaptiveViewsListContainer').hasClass('popup'))) {
  1460. closePopup();
  1461. } else {
  1462. $('#interfaceAdaptiveViewsContainer').addClass('selected');
  1463. showPopup($('#interfaceAdaptiveViewsListContainer'));
  1464. }
  1465. }
  1466. function toggleOverflowMenuPopup() {
  1467. if (($('#overflowMenuContainer').hasClass('popup'))) {
  1468. closePopup();
  1469. } else {
  1470. $('#overflowMenuButton').addClass('selected');
  1471. showPopup($('#overflowMenuContainer'));
  1472. }
  1473. }
  1474. var startSplitX;
  1475. var startSplitWidth;
  1476. function startLeftSplit() {
  1477. startSplitX = window.event.pageX;
  1478. startSplitWidth = lastLeftPanelWidth;
  1479. var $left = $('#lsplitbar');
  1480. $left.addClass('active');
  1481. $('<div class="splitterMask"></div>').insertAfter($left);
  1482. $(document).bind($axure.eventNames.mouseMoveName, doLeftSplitMove).bind($axure.eventNames.mouseUpName, endLeftSplitMove);
  1483. }
  1484. function startRightSplit() {
  1485. startSplitX = window.event.pageX;
  1486. startSplitWidth = lastRightPanelWidth;
  1487. var $left = $('#rsplitbar');
  1488. $left.addClass('active');
  1489. $('<div class="splitterMask"></div>').insertAfter($left);
  1490. $(document).bind($axure.eventNames.mouseMoveName, doRightSplitMove).bind($axure.eventNames.mouseUpName, endRightSplitMove);
  1491. }
  1492. function doLeftSplitMove() {
  1493. var currentX = window.event.pageX;
  1494. var newWidth = Math.min(startSplitWidth + currentX - startSplitX, $(window).width() - $('.rightPanel').width(), $(window).width() - lastRightPanelWidthDefault);
  1495. lastLeftPanelWidth = Math.max(lastLeftPanelWidthDefault, newWidth);
  1496. $('.leftPanel').width(lastLeftPanelWidth ? lastLeftPanelWidth : lastLeftPanelWidthDefault);
  1497. $('#lsplitbar').css('left', $('.leftPanel').width() - 4);
  1498. $axure.player.updateClippingBoundsWidth();
  1499. $axure.player.refreshViewPort();
  1500. }
  1501. function doRightSplitMove() {
  1502. var currentX = window.event.pageX;
  1503. var newWidth = Math.min(startSplitWidth - currentX + startSplitX, $(window).width() - $('.leftPanel').width(), $(window).width() - lastLeftPanelWidthDefault);
  1504. lastRightPanelWidth = Math.max(lastRightPanelWidthDefault, newWidth);
  1505. $('.rightPanel').width(lastRightPanelWidth ? lastRightPanelWidth : lastRightPanelWidthDefault);
  1506. $('#rsplitbar').css('left', $(window).width() - $('.rightPanel').width());
  1507. $axure.player.updateClippingBoundsWidth();
  1508. $axure.player.refreshViewPort();
  1509. }
  1510. function endLeftSplitMove() {
  1511. $('div.splitterMask').remove();
  1512. var $left = $('#lsplitbar');
  1513. $left.removeClass('active');
  1514. $(document).unbind($axure.eventNames.mouseMoveName, doLeftSplitMove).unbind($axure.eventNames.mouseUpName, endLeftSplitMove);
  1515. setAdaptiveView()
  1516. }
  1517. function endRightSplitMove() {
  1518. $('div.splitterMask').remove();
  1519. var $left = $('#rsplitbar');
  1520. $left.removeClass('active');
  1521. $(document).unbind($axure.eventNames.mouseMoveName, doRightSplitMove).unbind($axure.eventNames.mouseUpName, endRightSplitMove);
  1522. setAdaptiveView()
  1523. }
  1524. var startMX;
  1525. var startMLeft;
  1526. var startMElement;
  1527. var maxMLeft;
  1528. var getMaxMLeft = function () {
  1529. if ($('.rightPanel.mobileMode').length == 0) return $('.leftPanel.mobileMode').last().position().left + 100;
  1530. return $('.rightPanel.mobileMode').last().position().left + 100;
  1531. }
  1532. function startM(e) {
  1533. // Android touch event does not define pageX directly
  1534. if(window.event.pageX) {
  1535. startMX = window.event.pageX;
  1536. } else {
  1537. startMX = window.event.touches[0].pageX;
  1538. }
  1539. startMElement = window.event.target.id;
  1540. var $m = $('#mHideSidebar');
  1541. startMLeft = Number($m.css('left').replace('px', ''));
  1542. $(document).bind($axure.eventNames.mouseMoveName, doMMove).bind($axure.eventNames.mouseUpName, endMMove);
  1543. // Must stop propagation on iOS; otherwise scroll position of content will be reset to (0, 0)
  1544. // (likely due to position of click being calculated as out of bounds for outerContainer -- iOS is not adding scroll offset to bounds)
  1545. if (IOS) { e.stopPropagation() };
  1546. }
  1547. function doMMove() {
  1548. var $m = $('#mHideSidebar');
  1549. if(window.event.pageX) {
  1550. currentX = window.event.pageX;
  1551. } else {
  1552. currentX = window.event.touches[0].pageX;
  1553. }
  1554. var deltaX = currentX - startMX;
  1555. if (Math.abs(deltaX) > 0 && $('.splitterMask').length == 0) {
  1556. $('<div class="splitterMask"></div>').insertAfter($m);
  1557. }
  1558. var newLeft = startMLeft + deltaX;
  1559. newLeft = Math.min(0, newLeft);
  1560. newLeft = Math.max(-getMaxMLeft(), newLeft);
  1561. $m.css('left', newLeft + 'px');
  1562. }
  1563. function endMMove(e) {
  1564. $('div.splitterMask').remove();
  1565. $(document).unbind($axure.eventNames.mouseMoveName, doMMove).unbind($axure.eventNames.mouseUpName, endMMove);
  1566. e.stopPropagation();
  1567. var $m = $('#mHideSidebar');
  1568. if(window.event.pageX) {
  1569. currentX = window.event.pageX;
  1570. } else {
  1571. currentX = window.event.changedTouches[0].pageX;
  1572. }
  1573. var deltaX = currentX - startMX;
  1574. if (deltaX != 0 || startMElement != 'mHideSidebar') {
  1575. adjustM(currentX < startMX ? 'left' : 'right', true);
  1576. }
  1577. }
  1578. function adjustM(direction, animate) {
  1579. var $m = $('#mHideSidebar');
  1580. var duration = animate ? 100 : 0;
  1581. var newLeft = Number($m.css('left').replace('px', ''));
  1582. if (!$m.is(':visible') || newLeft > -100) {
  1583. $m.animate({ 'left': '-60px' }, duration);
  1584. } else if (newLeft < -getMaxMLeft() + 100) {
  1585. $m.animate({ 'left': (-getMaxMLeft() + 125) + 'px' }, duration);
  1586. } else if (direction == 'left') {
  1587. var handled = false;
  1588. var $panels = $('.rightPanel.mobileMode, .leftPanel.mobileMode');
  1589. $panels.each(function () {
  1590. var panelX = $(this).position().left;
  1591. if (panelX > -newLeft) {
  1592. $m.animate({ 'left': (-panelX + 25) + 'px' }, duration);
  1593. handled = true;
  1594. return false;
  1595. }
  1596. });
  1597. if (!handled) {
  1598. $m.animate({ 'left': (-$panels.last().position().left + 25) + 'px' }, duration);
  1599. }
  1600. } else if (direction == 'right') {
  1601. var handled = false;
  1602. var $panels = $('.rightPanel.mobileMode, .leftPanel.mobileMode');
  1603. $($panels.get().reverse()).each(function () {
  1604. var panelRight = $(this).position().left + $(this).width();
  1605. if (panelRight < -newLeft + $(window).width()) {
  1606. $m.animate({ 'left': (-$(this).position().left + 25) + 'px' }, duration);
  1607. handled = true;
  1608. return false;
  1609. }
  1610. });
  1611. if (!handled) {
  1612. $m.animate({ 'left': '-60px' }, duration);
  1613. }
  1614. }
  1615. }
  1616. function repositionPinsOnScaleChange(data) {
  1617. var $pins = $('#existingPinsOverlay').children();
  1618. for (var i = 0; i < $pins.length; i++) {
  1619. // calculate new position of pin
  1620. const left = parseFloat($($pins[i]).attr('data-x'));
  1621. const top = parseFloat($($pins[i]).attr('data-y'));
  1622. const width = $($pins[i]).width();
  1623. const height = $($pins[i]).height();
  1624. // Get current scale of mainPanelContainer
  1625. // MainPanelContainer scaled without setContentScale message
  1626. var scale = $('#mainPanelContainer').css('transform');
  1627. scale = (scale == "none") ? 1 : Number(scale.substring(scale.indexOf('(') + 1, scale.indexOf(',')));
  1628. const scaledLeft = (left * scale) - (width / 2);
  1629. const scaledTop = (top * scale) - (height / 2);
  1630. $($pins[i]).css('left', scaledLeft + 'px');
  1631. $($pins[i]).css('top', scaledTop + 'px');
  1632. }
  1633. // Distance from left of project content to origin (used for pins positioning when on a centered page in Scale to Fit mode)
  1634. if (typeof data.contentOriginOffset !== "undefined") contentLeftOfOriginOffset = data.contentOriginOffset;
  1635. }
  1636. function messageCenter_message(message, data) {
  1637. if (message == 'expandFrame') expand();
  1638. else if (message == 'getCollapseFrameOnLoad' && $axure.player.settings.startCollapsed && !MOBILE_DEVICE) $axure.messageCenter.postMessage('collapseFrameOnLoad');
  1639. else if (message == 'tripleClick') {
  1640. if ($axure.player.isMobileMode() || MOBILE_DEVICE) expand();
  1641. } else if (message == 'setContentScale') {
  1642. if (data.clipToView) {
  1643. var scaleVal = $('.vpScaleOption').find('.selectedRadioButton').parent().attr('val');
  1644. if (scaleVal == '2' || (!MOBILE_DEVICE && scaleVal == '0')) {
  1645. var scaleN = newScaleN = $('#mainPanel').width() / data.viewportWidth;
  1646. var hScaleN = ($('#mainPanel').height()) / data.viewportHeight;
  1647. if (hScaleN < scaleN) scaleN = newScaleN = hScaleN;
  1648. if(scaleVal == '0') scaleN = Math.min(1, scaleN);
  1649. var scale = 'scale(' + scaleN + ')';
  1650. $('#mainPanelContainer').css({
  1651. 'transform': scale,
  1652. 'transform-origin': ''
  1653. });
  1654. }
  1655. } else {
  1656. if (data.scaleN != 1) {
  1657. var scale = 'scale(' + data.scaleN + ')';
  1658. var width = 100 / data.scaleN + '%';
  1659. var height = Number($('#mainPanelContainer').css('height').replace('px', '')) / data.scaleN + 'px';
  1660. $('#mainPanelContainer').css({
  1661. 'transform': scale,
  1662. 'transform-origin': '0px 0px',
  1663. 'width': width,
  1664. 'height': height
  1665. });
  1666. //$('#clipFrameScroll').css('height' , height + 'px');
  1667. //$('#mainFrame').css('height' , height + 'px');
  1668. $('#clipFrameScroll').height(height);
  1669. $('#mainFrame').height(height);
  1670. }
  1671. }
  1672. repositionPinsOnScaleChange(data);
  1673. repositionClippingBoundsScroll();
  1674. // Fix for edge not redrawing content after scale change
  1675. if ($axure.browser.isEdge) {
  1676. newHeight = window.innerHeight - ((!isMobileMode() && $('#topPanel').is(':visible')) ? $('#topPanel').height() : 0);
  1677. newWidth = $(window).width();
  1678. $('#outerContainer').height(newHeight).width(newWidth);
  1679. $('#mainPanel').height(newHeight);
  1680. $('#clippingBounds').height(newHeight);
  1681. }
  1682. }
  1683. }
  1684. function loadVariablesFromUrl(removeVarFromUrl) {
  1685. let originalHashValues = window.location.href.substr(window.location.href.indexOf('#')) || '';
  1686. let variables = {};
  1687. const query = (originalHashValues.split(GLOBAL_VAR_NAME)[1] || '');
  1688. if(query.length > 0) {
  1689. $axure.utils.parseGlobalVars(query, function(varName, varValue) {
  1690. variables[varName] = varValue;
  1691. });
  1692. if(removeVarFromUrl) {
  1693. originalHashValues = originalHashValues.replace(GLOBAL_VAR_NAME, "").replace(query, "");
  1694. replaceHash(originalHashValues);
  1695. }
  1696. }
  1697. return variables;
  1698. }
  1699. function getInitialUrl() {
  1700. var shortId = getHashStringVar(PAGE_ID_NAME);
  1701. var foundById = [];
  1702. if (shortId.length > 0) {
  1703. getPageUrlsById(shortId, foundById, undefined);
  1704. if (foundById.length == 1) return foundById[0];
  1705. }
  1706. var pageName = getHashStringVar(PAGE_URL_NAME);
  1707. if (pageName.length > 0) return pageName + ".html";
  1708. else {
  1709. if (foundById.length > 0) return foundById[0];
  1710. var url = getFirstPageUrl($axure.document.sitemap.rootNodes);
  1711. return (url ? url : "about:blank");
  1712. }
  1713. }
  1714. var getPageUrlsById = $axure.player.getPageUrlsById = function (packageId, foundById, nodes) {
  1715. if (!nodes) nodes = $axure.document.sitemap.rootNodes;
  1716. for (var i = 0; i < nodes.length; i++) {
  1717. var node = nodes[i];
  1718. if (node.id == packageId) foundById.push(node.url);
  1719. var hasChildren = (node.children && node.children.length > 0);
  1720. if (hasChildren) {
  1721. getPageUrlsById(packageId, foundById, node.children);
  1722. }
  1723. }
  1724. }
  1725. var getPageIdByUrl = $axure.player.getPageIdByUrl = function(url, nodes) {
  1726. if (!nodes) nodes = $axure.document.sitemap.rootNodes;
  1727. for (var i = 0; i < nodes.length; i++) {
  1728. var node = nodes[i];
  1729. if (node.url == url) return node.id;
  1730. else {
  1731. var hasChildren = (node.children && node.children.length > 0);
  1732. if (hasChildren) {
  1733. var id = getPageIdByUrl(url, node.children);
  1734. if (id) return id;
  1735. }
  1736. }
  1737. }
  1738. return null;
  1739. }
  1740. function getFirstPageUrl(nodes) {
  1741. for (var i = 0; i < nodes.length; i++) {
  1742. var node = nodes[i];
  1743. if (node.url) return node.url;
  1744. else {
  1745. var hasChildren = (node.children && node.children.length > 0);
  1746. if (hasChildren) {
  1747. var url = getFirstPageUrl(node.children);
  1748. if (url) return url;
  1749. }
  1750. }
  1751. }
  1752. return null;
  1753. }
  1754. function closePlayer() {
  1755. if ($axure.page.location) window.location.href = $axure.page.location;
  1756. else {
  1757. var pageFile = getInitialUrl();
  1758. var currentLocation = window.location.toString();
  1759. window.location.href = currentLocation.substr(0, currentLocation.lastIndexOf("/") + 1) + pageFile;
  1760. }
  1761. }
  1762. function replaceHash(newHash) {
  1763. var currentLocWithoutHash = window.location.toString().split('#')[0];
  1764. //We use replace so that every hash change doesn't get appended to the history stack.
  1765. //We use replaceState in browsers that support it, else replace the location
  1766. if (typeof window.history.replaceState != 'undefined') {
  1767. try {
  1768. //Chrome 45 (Version 45.0.2454.85 m) started throwing an error here when generated locally (this only happens with sitemap open) which broke all interactions.
  1769. //try catch breaks the url adjusting nicely when the sitemap is open, but all interactions and forward and back buttons work.
  1770. //Uncaught SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///C:/Users/Ian/Documents/Axure/HTML/Untitled/start.html#p=home' cannot be created in a document with origin 'null'.
  1771. window.history.replaceState(null, null, currentLocWithoutHash + newHash);
  1772. } catch (ex) { }
  1773. } else {
  1774. window.location.replace(currentLocWithoutHash + newHash);
  1775. }
  1776. }
  1777. function collapse() {
  1778. if (IOS) {
  1779. $('body').off('touchstart');
  1780. $('body').off('touchend');
  1781. }
  1782. if ($axure.player.isMobileMode()) {
  1783. $('#mHideSidebar').hide();
  1784. $('#nativeAppControlFrame').hide();
  1785. $('#mobileBrowserControlFrame').hide();
  1786. } else {
  1787. $axure.player.deleteVarFromCurrentUrlHash('g');
  1788. $axure.player.setVarInCurrentUrlHash('c', 1);
  1789. if (!MOBILE_DEVICE) $('#maximizePanelContainer').show();
  1790. lastLeftPanelWidth = $('.leftPanel').width();
  1791. lastRightPanelWidth = $('.rightPanel').width();
  1792. $('.leftPanel').hide();
  1793. $('.rightPanel').hide();
  1794. $('#topPanel').hide();
  1795. $('.splitbar').hide();
  1796. $('#mainPanel').width($(window).width());
  1797. $('#clippingBounds').width($(window).width());
  1798. $('#clippingBounds').css('left', '0px');
  1799. $(window).resize();
  1800. $(document).trigger('sidebarCollapse');
  1801. $('#maximizeButton').addClass('rotated');
  1802. }
  1803. }
  1804. function expand() {
  1805. if ($axure.player.isMobileMode()) {
  1806. $('#mHideSidebar').show();
  1807. $('#mobileControlFrameContainer').show();
  1808. $axure.utils.isShareApp() ? $('#nativeAppControlFrame').show() : $('#mobileBrowserControlFrame').show();
  1809. } else {
  1810. $minimizeContainer = $('#interfaceControlFrameMinimizeContainer');
  1811. $minimizeContainer.removeClass('collapseHovered');
  1812. $axure.player.deleteVarFromCurrentUrlHash('c');
  1813. $('#maximizeButton').removeClass('rotated');
  1814. $('#maximizePanelContainer').hide();
  1815. $axure.player.restorePlugins();
  1816. $('#topPanel').show();
  1817. $(window).resize();
  1818. $(document).trigger('sidebarExpanded');
  1819. }
  1820. }
  1821. function mainFrame_onload() {
  1822. if ($axure.page.pageName) document.title = $axure.page.pageName;
  1823. }
  1824. function getQueryString(query) {
  1825. var qstring = self.location.href.split("?");
  1826. if (qstring.length < 2) return "";
  1827. return GetParameter(qstring, query);
  1828. }
  1829. function GetParameter(qstring, query) {
  1830. var prms = qstring[1].split("&");
  1831. var frmelements = new Array();
  1832. var currprmeter, querystr = "";
  1833. for (var i = 0; i < prms.length; i++) {
  1834. currprmeter = prms[i].split("=");
  1835. frmelements[i] = new Array();
  1836. frmelements[i][0] = currprmeter[0];
  1837. frmelements[i][1] = currprmeter[1];
  1838. }
  1839. for (j = 0; j < frmelements.length; j++) {
  1840. if (frmelements[j][0].toLowerCase() == query.toLowerCase()) {
  1841. querystr = frmelements[j][1];
  1842. break;
  1843. }
  1844. }
  1845. return querystr;
  1846. }
  1847. $axure.player.setVarInCurrentUrlHash = function(varName, varVal) {
  1848. var newHash = $axure.utils.setHashStringVar(window.location.hash, varName, varVal);
  1849. if (newHash != null) {
  1850. replaceHash(newHash);
  1851. }
  1852. }
  1853. function deleteHashStringVar(currentHash, varName) {
  1854. var varWithEqual = varName + '=';
  1855. var pageIndex = currentHash.indexOf('#' + varWithEqual);
  1856. if (pageIndex == -1) pageIndex = currentHash.indexOf('&' + varWithEqual);
  1857. if (pageIndex != -1) {
  1858. var newHash = currentHash.substring(0, pageIndex);
  1859. var ampIndex = currentHash.indexOf('&', pageIndex + 1);
  1860. //IF begin of string....if none blank, ELSE # instead of & and rest
  1861. //IF in string....prefix + if none blank, ELSE &-rest
  1862. if (newHash == '') { //beginning of string
  1863. newHash = ampIndex != -1 ? '#' + currentHash.substring(ampIndex + 1) : '';
  1864. } else { //somewhere in the middle
  1865. newHash = newHash + (ampIndex != -1 ? currentHash.substring(ampIndex) : '');
  1866. }
  1867. return newHash;
  1868. }
  1869. return null;
  1870. }
  1871. $axure.player.deleteVarFromCurrentUrlHash = function(varName) {
  1872. var newHash = deleteHashStringVar(window.location.hash, varName);
  1873. if (newHash != null) {
  1874. replaceHash(newHash);
  1875. }
  1876. };
  1877. function setUpController() {
  1878. //$axure.utils = _axUtils;
  1879. var _page = {};
  1880. $axure.page = _page;
  1881. $axure.utils.makeBindable(_page, ['load']);
  1882. var _player = function () {
  1883. };
  1884. $axure.player = _player;
  1885. //-----------------------------------------
  1886. //Global Var array, getLinkUrl function and setGlobalVar listener are
  1887. //for use in setting global vars in page url string when clicking a
  1888. //page in the sitemap
  1889. //NEW: this is now also used when navigating to a new window/popup,
  1890. //if there are global variables on the urls
  1891. //-----------------------------------------
  1892. var _globalVars = loadVariablesFromUrl(true);
  1893. //-----------------------------------------
  1894. //Used by getLinkUrl below to check if local server is running
  1895. //in order to send back the global variables as a query string
  1896. //in the page url
  1897. //-----------------------------------------
  1898. var _shouldSendVarsToServer = function () {
  1899. //If exception occurs (due to page in content frame being from a different domain, etc)
  1900. //then run the check without the url (which will end up checking against sitemap url)
  1901. try {
  1902. var mainFrame = document.getElementById("mainFrame");
  1903. return $axure.shouldSendVarsToServer(mainFrame.contentWindow.location.href);
  1904. } catch (e) {
  1905. return $axure.shouldSendVarsToServer();
  1906. }
  1907. };
  1908. var _getLinkUrl = function (baseUrl) {
  1909. var toAdd = '';
  1910. for (var globalVarName in _globalVars) {
  1911. var val = _globalVars[globalVarName];
  1912. if (val != null) {
  1913. if (toAdd.length > 0) toAdd += '&';
  1914. toAdd += globalVarName + '=' + encodeURIComponent(val);
  1915. }
  1916. }
  1917. return toAdd.length > 0 ? baseUrl + (_shouldSendVarsToServer() ? '?' : '#') + toAdd + "&CSUM=1" : baseUrl;
  1918. };
  1919. $axure.getLinkUrlWithVars = _getLinkUrl;
  1920. $axure.messageCenter.addMessageListener(function (message, data) {
  1921. if (message == 'setGlobalVar') {
  1922. _globalVars[data.globalVarName] = data.globalVarValue;
  1923. }
  1924. });
  1925. $axure.messageCenter.addStateListener('page.data', function (key, value) {
  1926. for (var subKey in value) {
  1927. _page[subKey] = value[subKey];
  1928. }
  1929. $axure.page.triggerEvent('load');
  1930. });
  1931. // ---------------------------------------------
  1932. // Navigates the main frame (setting the currently visible page). If the link is relative,
  1933. // this method should test if it is actually a axure rp page being loaded and properly set
  1934. // up all the controller for the page if it is
  1935. // ---------------------------------------------
  1936. _page.navigate = function (url, includeVariables) {
  1937. var mainFrame = document.getElementById("mainFrame");
  1938. //var mainFrame = window.parent.mainFrame;
  1939. // if this is a relative url...
  1940. var urlToLoad;
  1941. if (url.indexOf(':') < 0 || url[0] == '/') {
  1942. var winHref = window.location.href;
  1943. var page = winHref.substring(0, winHref.lastIndexOf('/') + 1) + url;
  1944. urlToLoad = page;
  1945. } else {
  1946. urlToLoad = url;
  1947. }
  1948. if (!includeVariables) {
  1949. mainFrame.contentWindow.location.href = urlToLoad;
  1950. return;
  1951. }
  1952. var urlWithVars = $axure.getLinkUrlWithVars(urlToLoad);
  1953. var currentData = $axure.messageCenter.getState('page.data');
  1954. var currentUrl = currentData && currentData.location;
  1955. if (currentUrl && currentUrl.indexOf('#') != -1) currentUrl = currentUrl.substring(0, currentUrl.indexOf('#'))
  1956. // this is so we can make sure the current frame reloads if the variables have changed
  1957. // by default, if the location is the same but the hash code is different, the browser will not
  1958. // trigger a reload
  1959. mainFrame.contentWindow.location.href =
  1960. currentUrl && urlToLoad.toLowerCase() != currentUrl.toLowerCase()
  1961. ? urlWithVars
  1962. : 'resources/reload.html#' + encodeURI(urlWithVars);
  1963. };
  1964. var pluginIds = [];
  1965. var plugins = {};
  1966. var currentVisibleHostId = {};
  1967. // ---------------------------------------------
  1968. // Adds a tool box frame from a url to the interface. This is useful for loading plugins
  1969. // settings is an object that supports the following properties:
  1970. // - id : the id of the element for the plugin
  1971. // - context : the context to create the plugin host for
  1972. // - title : the user-visible caption for the plugin
  1973. // ---------------------------------------------
  1974. _player.createPluginHost = function (settings) {
  1975. if (!settings.context || !(settings.context === 'project' || settings.context === 'inspect')) {
  1976. //throw ('unknown context type');
  1977. return false;
  1978. }
  1979. if (settings.id == 'feedbackHost')
  1980. $('#overflowMenuContainer').prepend('<div id="showCommentsOption" class="showOption" style="order: 2"><div class="overflowOptionCheckbox"></div>Show Comments</div>');
  1981. if (!settings.id) throw ('each plugin host needs an id');
  1982. if (typeof PREVIEW_INFO === 'undefined') {
  1983. // Share-Hosted Prototype
  1984. if (settings.id == 'debugHost') { return false; }
  1985. if (settings.id == 'handoffHost') { $('#handoffControlFrameHeaderContainer').show(); }
  1986. } else {
  1987. // Preview Mode
  1988. if (settings.id == 'handoffHost') { return false; }
  1989. }
  1990. pluginIds[pluginIds.length] = settings.id;
  1991. plugins[settings.id] = settings;
  1992. var hostContainerId = settings.context + 'ControlFrameHostContainer';
  1993. hostContainerId = _player.isMobileMode() ? 'mHideSidebar' : 'outerContainer';
  1994. var panelClass = 'rightPanel';
  1995. var host;
  1996. if (settings.context == 'project') {
  1997. panelClass = 'leftPanel';
  1998. if (_player.isMobileMode() && $('#' + hostContainerId).find('#projectOptionsHost').length > 0) {
  1999. host = $('<div id="' + settings.id + '" class="' + panelClass + '"></div>')
  2000. .insertAfter('#projectOptionsHost');
  2001. } else {
  2002. host = $('<div id="' + settings.id + '" class="' + panelClass + '"></div>')
  2003. .prependTo('#' + hostContainerId);
  2004. }
  2005. } else {
  2006. if (!$('#separatorContainer').hasClass('hasLeft')) $('#separatorContainer').addClass('hasLeft');
  2007. host = $('<div id="' + settings.id + '" class="' + panelClass + '"></div>')
  2008. .appendTo('#' + hostContainerId);
  2009. }
  2010. $(('#' + settings.id)).click(function (e) { e.stopPropagation(); });
  2011. var controlContainerId = getControlContainerId(settings.id);
  2012. if (!_player.isMobileMode()) host.hide();
  2013. else _player.updatePlugins();
  2014. // TODO: border radius in ie and edge causes image to be blurry (for now, just remove border-radius)
  2015. var style = (IE || $axure.browser.isEdge) ? '" style="border-radius: 0': '';
  2016. var headerLink = $('<a pluginId="' + settings.id + '" title="' + settings.title + style + '" >' + (settings.context === 'inspect' ? ('<span>' + '</span>'): '&nbsp;') + '</a>');
  2017. headerLink.mousedown($axure.utils.curry(interfaceControlHeaderButton_click, settings.id)).wrap('<li id="' + settings.id + 'Btn"' + (settings.id == "handoffHost" ? ' style="display: none"' : '') + '>');
  2018. headerLink.parent().appendTo('#' + controlContainerId);
  2019. if (_player.isMobileMode()) $axure.player.resizeContent();
  2020. $(document).trigger('pluginCreated', [settings.gid]);
  2021. };
  2022. var getControlContainerId = function (id) {
  2023. return plugins[id].context + 'ControlFrameHeader';
  2024. }
  2025. var getVisiblePlugins = function () {
  2026. var ids = '';
  2027. for (var id in plugins) {
  2028. var context = plugins[id].context;
  2029. if (currentVisibleHostId[context] == id) {
  2030. ids += plugins[id].gid;
  2031. }
  2032. }
  2033. return ids;
  2034. }
  2035. _player.pluginVisibleChanged = function(hostId, visible) {
  2036. if (plugins[hostId]) {
  2037. $axure.messageCenter.postMessage('pluginVisibleChanged', { id: hostId, gid: plugins[hostId].gid, visible: visible });
  2038. }
  2039. }
  2040. var interfaceControlHeaderButton_click = function (id) {
  2041. if (_player.isAnimating) { return; }
  2042. $axure.player.closePopup();
  2043. var controlContainerId = getControlContainerId(id);
  2044. var context = plugins[id].context;
  2045. var clickedPlugin = $('#' + controlContainerId + ' a[pluginId=' + id + ']');
  2046. if (currentVisibleHostId[context] == id) {
  2047. clickedPlugin.removeClass('selected');
  2048. if (id == "sitemapHost") { $('#sitemapControlFrameContainer').removeClass('selected'); }
  2049. currentVisibleHostId[context] = -1;
  2050. _player.collapseToBar(context, id);
  2051. $(document).trigger('pluginShown', [getVisiblePlugins()]);
  2052. } else {
  2053. $('#' + controlContainerId + ' a').removeClass('selected');
  2054. clickedPlugin.addClass('selected');
  2055. if (id == "sitemapHost") { $('#sitemapControlFrameContainer').addClass('selected'); }
  2056. $('#' + currentVisibleHostId[context]).hide();
  2057. $axure.player.pluginVisibleChanged(currentVisibleHostId[context], false);
  2058. currentVisibleHostId[context] = id;
  2059. _player.expandFromBar(id, context);
  2060. $(document).trigger('pluginShown', [getVisiblePlugins()]);
  2061. }
  2062. };
  2063. _player.pluginClose = function (id) {
  2064. var controlContainerId = getControlContainerId(id);
  2065. var context = plugins[id].context;
  2066. var clickedPlugin = $('#' + controlContainerId + ' a[pluginId=' + id + ']');
  2067. if (!clickedPlugin.hasClass('selected')) { return; }
  2068. clickedPlugin.removeClass('selected');
  2069. currentVisibleHostId[context] = -1;
  2070. _player.collapseToBar(context, id);
  2071. $(document).trigger('pluginShown', [getVisiblePlugins()]);
  2072. };
  2073. _player.showPlugin = function (gid) {
  2074. for (var id in plugins) {
  2075. if (plugins[id].gid == gid) {
  2076. interfaceControlHeaderButton_click(id);
  2077. break;
  2078. }
  2079. }
  2080. };
  2081. _player.restorePlugins = function () {
  2082. var selectedPluginsCount = 0;
  2083. for (var id in plugins) {
  2084. var clickedPlugin = $('#' + getControlContainerId(id) + ' a[pluginId=' + id + ']');
  2085. if (clickedPlugin.hasClass('selected')) selectedPluginsCount++;
  2086. }
  2087. if ($axure.player.settings.isAxshare && selectedPluginsCount != 0) $('#clippingBoundsScrollContainer').hide();
  2088. var selectedPluginsSeen = 0;
  2089. for (var id in plugins) {
  2090. var controlContainerId = getControlContainerId(id);
  2091. var context = plugins[id].context;
  2092. var clickedPlugin = $('#' + controlContainerId + ' a[pluginId=' + id + ']');
  2093. if (clickedPlugin.hasClass('selected')) {
  2094. //_player.showPlugin(id);
  2095. // TODO: handoffHost would need center inspect icon highlighted and rightFrameIcon set to visible
  2096. //if (id == 'handoffHost') { }
  2097. //$('#' + id).show();
  2098. selectedPluginsSeen++;
  2099. _player.expandFromBar(id, context, selectedPluginsCount == selectedPluginsSeen);
  2100. } else {
  2101. $('#' + id).hide();
  2102. }
  2103. }
  2104. $(document).trigger('pluginShown', [getVisiblePlugins()]);
  2105. };
  2106. _player.navigateToIssue = function (issueId) {
  2107. if (typeof feedback !== 'undefined') {
  2108. feedback.navigateToIssue(issueId);
  2109. }
  2110. };
  2111. }
  2112. $axure.player.hideAllPlayerControllers = function(isVisible) {
  2113. // TOOD: Verify that the containers are set to the right state after re-enabling them
  2114. if(isVisible) {
  2115. $('#topPanel').css('display', '');
  2116. $('#popupContainer').css('display', '');
  2117. $('#maximizePanelContainer').css('display', '');
  2118. $('#mobileControlFrameContainer').css('display', '');
  2119. } else {
  2120. $('#topPanel').hide();
  2121. $('#popupContainer').hide();
  2122. $('#maximizePanelContainer').hide(); // TODO: This needs to have a function where it prevents itself from showing up externally
  2123. $('#mobileControlFrameContainer').hide();
  2124. }
  2125. }
  2126. // TODO: General function to add bezels/overlays if applicable
  2127. $axure.player.addDeviceFraming = function (project, isEdit) {
  2128. // Temporary
  2129. var devices = {
  2130. iPhone8: 0,
  2131. iPhone8Plus: 1,
  2132. iPhoneSE: 2,
  2133. iPhoneX: 3,
  2134. iPad4: 4,
  2135. GalaxyS8: 5,
  2136. Pixel2: 6,
  2137. Pixel2XL: 7,
  2138. Mobile: 8,
  2139. Tablet9: 9,
  2140. Tablet7: 10,
  2141. Custom: 11,
  2142. Web: 12
  2143. };
  2144. // TODO: Need to bring over some platform functionality -> function might not be present
  2145. if (!$axure.player.settings.isExpo || project.Platform.Device === 12) { return; }
  2146. // TODO: Generate html for overlay and bezel containers
  2147. // TODO: Determine if preview player or full prototype player to establish where containers will be stored
  2148. var currDevice = project.Platform.Device;
  2149. var rootPath = '../../Scripts/Expo/StaticContent/resources/images/mobile/';
  2150. var framePath, overlayPath;
  2151. var $overlayParent = $(window.parent.parent.document).find('#previewPlayerDiv');
  2152. $overlayParent = isEdit && $overlayParent.length !== 0 ? $overlayParent : $('#mainPanelContainer');
  2153. $overlayParent.css('overflow', 'visible');
  2154. // TODO: Import enum of Device types -> import via TS definitions. WILL NEED TO REMEMBER THAT WE NEED TO SYNC SERVER AND CLIENT SIDE
  2155. // TODO: Create mapping of required images to device type
  2156. // images will be stored in ../../images/mobile
  2157. // TODO: Manage resizing
  2158. // TODO: Manage pointer clicks
  2159. // TODO: Status bar -> Default or via settings
  2160. // TODO: Establish img paths
  2161. switch (currDevice) {
  2162. case devices.iPhone8:
  2163. case devices.iPhone8Plus:
  2164. framePath = rootPath + 'iphone.svg';
  2165. overlayPath = "";
  2166. break;
  2167. case devices.iPhoneSE:
  2168. break;
  2169. case devices.iPhoneX:
  2170. framePath = "";
  2171. overlayPath = "";
  2172. break;
  2173. case devices.iPad4:
  2174. break;
  2175. case devices.Pixel2:
  2176. break;
  2177. case devices.Pixel2XL:
  2178. break;
  2179. case devices.GalaxyS8:
  2180. break;
  2181. case devices.Mobile:
  2182. case devices.Tablet7:
  2183. case devices.Tablet9:
  2184. case devices.Custom:
  2185. default:
  2186. break;
  2187. }
  2188. // TODO: Append images
  2189. // TODO: Position and initial dimensions
  2190. // TODO: Add resize handlers (?)
  2191. // TODO: Add pointer event handers (?)
  2192. if (framePath != undefined) {
  2193. $overlayParent.prepend(genFrameContainer());
  2194. var $fContainer = $overlayParent.find('#deviceFrameContainer');
  2195. var $frame = $fContainer.find('#deviceFrame');
  2196. $frame.css('background-image', "url('" + framePath + "')");
  2197. $frame.css('height', '');
  2198. $frame.css('width', '');
  2199. $frame.css('top', '');
  2200. $frame.css('left', '');
  2201. if(isEdit) {
  2202. $fContainer.css('z-index', -1);
  2203. }
  2204. }
  2205. if (overlayPath != undefined) {
  2206. // TODO: Update for edit mode
  2207. // $overlayParent.append(genOverlayContainer());
  2208. var $oContainer = $overlayParent.find('#deviceOverlayContainer');
  2209. var $overlay = $oContainer.find('#deviceOverlay');
  2210. $overlay.css('background-image', "url('" + overlayPath + "')");
  2211. }
  2212. }
  2213. function genFrameContainer(bezelPath) {
  2214. var container = [
  2215. '<div id="deviceFrameContainer">',
  2216. ' <div id="deviceFrame">',
  2217. ' </div>',
  2218. '</div>'
  2219. ].join("");
  2220. return container;
  2221. }
  2222. })();