axplayer.js 142 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427
  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 = 290;
  12. var lastLeftPanelWidthDefault = 220;
  13. var lastRightPanelWidthDefault = 290;
  14. var toolBarOnly = true;
  15. // isolate scope
  16. (function () {
  17. // replace hash to query
  18. if (window.location.hash) {
  19. replaceHashToQuery();
  20. }
  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. }else {
  36. $("#topPanel").css('display', '');
  37. }
  38. $axure.loadDocument = function (document) {
  39. $axure.document = document;
  40. var configuration = $axure.document.configuration;
  41. var _settings = {};
  42. _settings.projectId = configuration.prototypeId;
  43. _settings.projectName = configuration.projectName;
  44. _settings.isAxshare = configuration.isAxshare;
  45. _settings.isExpo = configuration.isExpo == null ? false : configuration.isExpo;
  46. _settings.loadSitemap = configuration.loadSitemap;
  47. _settings.loadFeedbackPlugin = configuration.loadFeedbackPlugin;
  48. var cHash = getHashStringVar(SITEMAP_COLLAPSE_VAR_NAME);
  49. _settings.startCollapsed = cHash == SITEMAP_COLLAPSE_VALUE;
  50. if (cHash == SITEMAP_CLOSE_VALUE) closePlayer();
  51. var gHash = getHashStringVar(PLUGIN_VAR_NAME);
  52. _settings.startPluginGid = gHash;
  53. $axure.player.settings = _settings;
  54. var additionalJs = $axure.document.additionalJs;
  55. if (additionalJs != null) {
  56. var total = additionalJs.length;
  57. if (total > 0) $.holdReady(true);
  58. $.each(additionalJs, function (index, value) {
  59. var script = window.document.createElement("script");
  60. script.type = "text/javascript";
  61. script.src = value;
  62. script.async = false;
  63. script.onload = script.onreadystatechange = function (e) {
  64. if (!script.readyState || /loaded|complete/.test(script.readyState)) {
  65. script.onload = script.onreadystatechange = null;
  66. script = undefined;
  67. }
  68. if (--total == 0) $.holdReady(false);
  69. }
  70. window.document.head.appendChild(script);
  71. });
  72. }
  73. var additionalCss = $axure.document.additionalCss;
  74. if(additionalCss != null) {
  75. $.each(additionalCss, function(index, value) {
  76. var style = window.document.createElement('link');
  77. style.type = "text/css";
  78. style.rel = "stylesheet";
  79. style.href = value;
  80. window.document.head.appendChild(style);
  81. });
  82. }
  83. if(_settings.isExpo && configuration.isMobile) {
  84. initializeDeviceFrame();
  85. }
  86. // Pseudo-indicator that the document has been loaded
  87. $axure.document.isLoaded = true;
  88. };
  89. $(window).bind('load', function () {
  90. if ((CHROME && BROWSER_VERSION < 64) || // First 2018 release
  91. (SAFARI && BROWSER_VERSION < 602) || // Minor version 10
  92. (FIREFOX && BROWSER_VERSION < 57) || // Support Quantum
  93. ($axure.browser.isEdge && BROWSER_VERSION < 15) || // 15 for mobile devices (else could go 16, possibly 17)
  94. (!$axure.browser.isEdge && IE)) {
  95. if (!QQ && !UC) appendOutOfDateNotification();
  96. }
  97. if (CHROME_5_LOCAL && !$('body').attr('pluginDetected')) {
  98. window.location = 'resources/chrome/chrome.html';
  99. }
  100. if (FIREFOX && BROWSER_VERSION >= 68 && document.location.href.indexOf('file://') >= 0) { //detecting firefox and local
  101. window.location = 'resources/chrome/firefox.html';
  102. }
  103. });
  104. $(window).on('hashchange', function() {
  105. window.location.reload();
  106. });
  107. function replaceHashToQuery() {
  108. var urlObj = new URL(window.location.href);
  109. // add parameters from hash to query
  110. const vars = urlObj.hash.substring(1).split("&");
  111. for (let i = 0; i < vars.length; i++) {
  112. const pair = vars[i].split("=");
  113. urlObj.searchParams.set(pair[0], pair[1]);
  114. }
  115. // remove hash from url
  116. urlObj.hash = "";
  117. if (typeof window.history.replaceState != 'undefined') {
  118. try {
  119. window.history.replaceState("", "", urlObj.href);
  120. } catch (ex) { }
  121. } else {
  122. window.location.replace(urlObj.href);
  123. }
  124. }
  125. function appendOutOfDateNotification() {
  126. var toAppend = '';
  127. toAppend += '<div id="browserOutOfDateNotification">';
  128. toAppend += ' <div style="font-size: 24px; text-align: center; color: #FFFFFF;">LOOKS LIKE YOUR BROWSER IS OUT OF DATE</div>';
  129. 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>';
  130. toAppend += ' <div id="supportedBrowsersListContainer">';
  131. toAppend += ' <div class="browserContainer">';
  132. toAppend += ' <div class="browserName">Google Chrome</div><div class="browserSupportedVersion">v64 and later</div>';
  133. toAppend += ' </div>';
  134. toAppend += ' <div class="browserContainer">';
  135. toAppend += ' <div class="browserName">Mozilla Firefox</div><div class="browserSupportedVersion">v57 and later</div>';
  136. toAppend += ' </div>';
  137. toAppend += ' <div class="browserContainer">';
  138. toAppend += ' <div class="browserName">Microsoft Edge</div><div class="browserSupportedVersion">v15 and later</div>';
  139. toAppend += ' </div>';
  140. toAppend += ' <div class="browserContainer">';
  141. toAppend += ' <div class="browserName">Apple Safari</div><div class="browserSupportedVersion">v10 and later</div>';
  142. toAppend += ' </div>';
  143. toAppend += ' </div>';
  144. toAppend += ' <div id="browserOutOfDateNotificationButtons">'
  145. if (!MOBILE_DEVICE) {
  146. toAppend += ' <div style="margin-right: 36px"><a href="http://outdatedbrowser.com/en" id="updateBrowserButton">UPDATE BROWSER</a></div>';
  147. toAppend += ' <div style="flex: 0 1 45%;"><a id="continueToPrototypeButton">Continue viewing prototype anyway</a></div>';
  148. } else {
  149. toAppend += ' <div style="width: 100%; text-align:center"><a id="continueToPrototypeButton">Continue viewing prototype anyway</a></div>';
  150. }
  151. toAppend += ' </div>';
  152. toAppend += '</div>';
  153. $('body').prepend(toAppend);
  154. $('#continueToPrototypeButton').on('click', function () {
  155. var $message = $('#browserOutOfDateNotification');
  156. $message.children().hide();
  157. $message.css('padding-top', '0px');
  158. $message.animate({ 'height': '0px' }, { duration: 400, complete: function () { $message.hide(); } });
  159. });
  160. }
  161. $axure.page.bind('load.start', mainFrame_onload);
  162. $axure.messageCenter.addMessageListener(messageCenter_message);
  163. var suppressPluginVarUpdate = false;
  164. $(document).on('pluginShown', function (event, data) {
  165. if (!suppressPluginVarUpdate) $axure.player.setVarInCurrentUrlHash(PLUGIN_VAR_NAME, data ? data : '');
  166. });
  167. $(document).on('pluginCreated', function (event, data) {
  168. if (!$axure.player.isMobileMode() && $axure.player.settings.startPluginGid.indexOf(data) > -1) {
  169. suppressPluginVarUpdate = true;
  170. $axure.player.showPlugin(data);
  171. suppressPluginVarUpdate = false;
  172. }
  173. if (data == '1') {
  174. $('#interfaceControlFrame').animate({ opacity: 1 }, 200);
  175. }
  176. if ($axure.player.settings.isExpo) {
  177. // TODO: Do this only if expo is a mobile device
  178. // TODO: Figure out better way to deal with this issue
  179. $axure.messageCenter.postMessage('setDeviceMode', { device: false });
  180. $axure.messageCenter.postMessage('setDeviceMode', { device: true });
  181. //$axure.player.refreshViewPort();
  182. }
  183. });
  184. function initializeEvents() {
  185. $('#interfaceControlFrameMinimizeContainer').on('click', collapse);
  186. $('#interfaceControlFrameCloseButton').on('click', closePlayer);
  187. $('#interfacePageNameContainer').on($axure.eventNames.mouseDownName, toggleSitemap);
  188. $('#interfaceAdaptiveViewsContainer').on($axure.eventNames.mouseDownName, toggleAdaptiveViewsPopup);
  189. $('#overflowMenuButton').on($axure.eventNames.mouseDownName, toggleOverflowMenuPopup);
  190. $('#scaleMenuButton').on($axure.eventNames.mouseDownName, toggleScaleMenuPopup);
  191. if (!MOBILE_DEVICE) {
  192. $('#maximizePanel').mouseenter(function () {
  193. $(this).addClass('maximizePanelOver');
  194. });
  195. $('#maximizePanel').mouseleave(function () {
  196. if ($(this).hasClass('maximizePanelOver')) {
  197. $(this).animate(isMobileMode() ? {
  198. top: '-' + $('#maximizePanel').height() + 'px'
  199. } : {
  200. left: '-' + $('#maximizePanel').width() + 'px'
  201. }, 300);
  202. }
  203. $(this).removeClass('maximizePanelOver');
  204. });
  205. $('#maximizePanelOver').mouseenter(function () {
  206. $('#maximizePanel').animate(isMobileMode() ? {
  207. top: '0px'
  208. } : {
  209. left: '0px'
  210. }, 100);
  211. });
  212. }
  213. $minimizeContainer = $('#interfaceControlFrameMinimizeContainer');
  214. $minimizeContainer.mouseenter(function () { $minimizeContainer.addClass('collapseHovered') });
  215. $minimizeContainer.mouseleave(function () { $minimizeContainer.removeClass('collapseHovered') });
  216. $maximizeContainer = $('#maximizePanelContainer');
  217. $maximizeContainer.mouseenter(function () { if(!MOBILE_DEVICE) $minimizeContainer.addClass('expandHovered') });
  218. $maximizeContainer.mouseleave(function () { if(!MOBILE_DEVICE) $minimizeContainer.removeClass('expandHovered') });
  219. $('#maximizePanel').click(function () {
  220. $(this).removeClass('maximizePanelOver');
  221. $('#maximizePanelContainer').hide();
  222. $axure.messageCenter.postMessage('expandFrame');
  223. });
  224. $('#mHideSidebar').on($axure.eventNames.mouseDownName, function (e) { startM(e); });
  225. $('#lsplitbar').on($axure.eventNames.mouseDownName, startLeftSplit);
  226. $('#rsplitbar').on($axure.eventNames.mouseDownName, startRightSplit);
  227. if ($axure.mobileSupport.mobile) {
  228. var touchCount = 0;
  229. var lastTouch = Date.now();
  230. $('#mainPanel').on('touchstart',
  231. (function (e) {
  232. var now = Date.now();
  233. if (now - lastTouch < 375) {
  234. if (++touchCount === 3) {
  235. if ($axure.player.isMobileMode() || MOBILE_DEVICE) expand();
  236. touchCount = 0;
  237. e.preventDefault();
  238. };
  239. } else {
  240. touchCount = 1;
  241. }
  242. lastTouch = now;
  243. }));
  244. }
  245. $(window).resize(function () {
  246. $axure.player.resizeContent();
  247. });
  248. $(window).on("orientationchange", function () {
  249. // IOS often does not complete updating innerHeight and innerWidth
  250. // until after calling orientation changed and resized window
  251. // Also, cannot use $(window).height() call since iOS11 needs padding amount
  252. if (IOS && isMobileMode()) setTimeout(function () { $axure.player.resizeContent(true); }, 250);
  253. });
  254. $('#mainPanel').scroll(function () {
  255. repositionClippingBoundsScroll();
  256. });
  257. }
  258. function initializeMainFrame() {
  259. var legacyQString = getQueryString("Page");
  260. if (legacyQString.length > 0) {
  261. location.href = location.href.substring(0, location.href.indexOf("?")) + "?" + PAGE_URL_NAME + "=" + legacyQString;
  262. return;
  263. }
  264. var mainFrame = document.getElementById("mainFrame");
  265. //if it's local file on safari, test if we can access mainframe after its loaded
  266. if (SAFARI && document.location.href.indexOf('file://') >= 0) {
  267. $(mainFrame).on('load', function () {
  268. var canAccess;
  269. try {
  270. var mainFrameWindow = mainFrame.contentWindow || mainFrame.contentDocument;
  271. mainFrameWindow['safari_file_CORS'] = 'Y';
  272. canAccess = mainFrameWindow['safari_file_CORS'] === 'Y';
  273. } catch (err) {
  274. canAccess = false;
  275. }
  276. if (!canAccess) window.location = 'resources/chrome/safari.html';
  277. });
  278. }
  279. if($axure.player.settings != null && !$axure.player.settings.isExpo) {
  280. const linkUrlWithVars = $axure.getLinkUrlWithVars(getInitialUrl());
  281. mainFrame.contentWindow.location.href = linkUrlWithVars;
  282. }
  283. }
  284. function initializeDeviceFrame() {
  285. // TODO: Load device bezel and necessary overlays if applicable
  286. // - Need to determine if device has a frame/overlay
  287. // - Determine where to store said assets
  288. // - Determine sizing, positioning, orientation, and styling for HTML containers
  289. // - Verify that it stays consistent for every state (expo)
  290. var expo = $axure.expo;
  291. var project = expo.project;
  292. var device = project.Platform.Device;
  293. // in expo.ts, Web is 12
  294. if (device === 12) {
  295. // Hide containers
  296. $('#deviceFrameContainer').hide();
  297. $('#bezelOverlay').hide();
  298. return;
  299. }
  300. // map devices to their corresponding frame/bezel/overlays
  301. }
  302. var wasMobile = false;
  303. var isMobileMode = $axure.player.isMobileMode = function () { return $axure.utils.isShareApp() || (MOBILE_DEVICE && $(window).width() < 420); }
  304. var isMobileTextEntry = false;
  305. var isViewOverridden = $axure.player.isViewOverridden = function() {
  306. return getHashStringVar(ADAPTIVE_VIEW_VAR_NAME).length > 0;
  307. }
  308. function toggleSitemapMobileMode() {
  309. var $container = $('#sitemapHost');
  310. if (!$container.length) return;
  311. var $header = $container.find('.pluginNameHeader');
  312. var projectName = $axure.player.getProjectName();
  313. if (isMobileMode()) {
  314. $header.text('PROJECT PAGES');
  315. $container.addClass('mobileMode');
  316. $container.find('.sitemapPageName').addClass('mobileText');
  317. // Give sitemapHost left-margin so it does not collide with projectOptionsHost
  318. if (MOBILE_DEVICE) $container.css('margin-left', '13px');
  319. } else {
  320. $container.removeClass('mobileMode');
  321. $header.text(projectName ? projectName : 'Pages');
  322. $container.find('.sitemapPageName').removeClass('mobileText');
  323. if (MOBILE_DEVICE) $container.css('margin-left', '');
  324. }
  325. }
  326. function togglePageNotesMobileMode() {
  327. var $container = $('#pageNotesHost');
  328. if (!$container.length) return;
  329. if (isMobileMode()) {
  330. $container.addClass('mobileMode');
  331. $container.find('.notesPageNameHeader').addClass('mobileSubHeader');
  332. $container.find('.pageNote').addClass('mobileText');
  333. $container.find('.emptyStateTitle').addClass('mobileSubHeader');
  334. $container.find('.emptyStateContent').addClass('mobileText');
  335. } else {
  336. $container.removeClass('mobileMode');
  337. $container.find('.notesPageNameHeader').removeClass('mobileSubHeader');
  338. $container.find('.pageNote').removeClass('mobileText');
  339. $container.find('.emptyStateTitle').removeClass('mobileSubHeader');
  340. $container.find('.emptyStateContent').removeClass('mobileText');
  341. }
  342. }
  343. function toggleFeedbackMobileMode() {
  344. var $container = $('#feedbackHost');
  345. if (!$container.length) return;
  346. if (isMobileMode()) {
  347. $container.addClass('mobileMode');
  348. } else {
  349. $container.removeClass('mobileMode');
  350. }
  351. }
  352. $axure.player.updatePlugins = function updatePlugins() {
  353. if (MOBILE_DEVICE && !$axure.utils.isShareApp()) {
  354. var hostPanelPadding = isMobileMode() ? '8px 15px 0px 15px' : '';
  355. $('.rightPanel .leftPanel .mobileOnlyPanel').css('padding', hostPanelPadding);
  356. }
  357. if (isMobileMode()) {
  358. $('body').addClass('mobileMode');
  359. if ($('#debugHost').length) $('#debugHost').hide();
  360. if ($('#handoffHost').length) $('#handoffHost').hide();
  361. } else $('body').removeClass('mobileMode');
  362. toggleSitemapMobileMode();
  363. togglePageNotesMobileMode();
  364. toggleFeedbackMobileMode();
  365. }
  366. // TODO: this is done for IOS and Android (check what can be done for Pixel, etc)
  367. $axure.player.setIsMobileModeTextEntry = function (isTextEntry) {
  368. isMobileTextEntry = isTextEntry;
  369. if (IOS && isTextEntry) {
  370. activateMobileTextEntry()
  371. } else if (IOS) {
  372. setTimeout(deactivateMobileTextEntry, 150);
  373. }
  374. }
  375. function deactivateMobileTextEntry() {
  376. newHeight = window.innerHeight;
  377. var newControlHeight = newHeight - (!$axure.utils.isShareApp() ? 140 : IOS ? 157 : 138);
  378. if (!$('.leftPanel').hasClass('popup')) {
  379. $('.leftPanel').height(newControlHeight);
  380. }
  381. $('.rightPanel').height(newControlHeight);
  382. $('.mobileOnlyPanel').height(newControlHeight);
  383. $('#mobileControlFrameContainer').show();
  384. }
  385. function activateMobileTextEntry() {
  386. $('#mobileControlFrameContainer').hide();
  387. newHeight = window.innerHeight;
  388. var newControlHeight = newHeight - (!$axure.utils.isShareApp() ? 140 : IOS ? 157 : 138);
  389. newControlHeight = newControlHeight + (!$axure.utils.isShareApp() ? 61 : IOS ? 72 : 60);
  390. if (!$('.leftPanel').hasClass('popup')) {
  391. $('.leftPanel').height(newControlHeight);
  392. }
  393. $('.rightPanel').height(newControlHeight);
  394. $('.mobileOnlyPanel').height(newControlHeight);
  395. }
  396. function setAdaptiveView() {
  397. if (typeof noViewport == 'undefined') {
  398. // Block during animation -- end of animation will call resizeContent once completed with isAnimating equal to false
  399. if (!isViewOverridden() && !isAnimating) $axure.messageCenter.postMessage('setAdaptiveViewForSize', { 'width': $('#mainPanel').width(), 'height': $('#mainPanel').height() });
  400. //if (!isViewOverridden()) $axure.messageCenter.postMessage('setAdaptiveViewForSize', { 'width': $('#mainPanel').width(), 'height': $('#mainPanel').height() });
  401. $axure.player.refreshViewPort();
  402. if ($axure.player.updateAdaptiveViewHeader != null) $axure.player.updateAdaptiveViewHeader();
  403. }
  404. }
  405. $axure.player.resizeContent = function (noViewport) {
  406. var isMobile = isMobileMode();
  407. if (wasMobile && !isMobile) {
  408. $('#clippingBoundsScrollContainer').show();
  409. $('#outerContainer').prepend($('.leftPanel'));
  410. $('#outerContainer').append($('.rightPanel'));
  411. $axure.player.updatePlugins();
  412. $('#mHideSidebar').hide();
  413. $('#mobileBrowserControlFrame').hide();
  414. $('#nativeAppControlFrame').hide();
  415. if ($('#topPanel').is(':visible')) {
  416. $('#maximizePanelContainer').hide();
  417. $axure.player.restorePlugins();
  418. } else {
  419. $('.leftPanel').hide();
  420. $('.rightPanel').hide();
  421. if (!MOBILE_DEVICE) $('#maximizePanelContainer').show();
  422. }
  423. $('.leftPanel').css({ 'top': '', 'left': '' });
  424. $('.rightPanel').css({ 'top': '', 'left': '' });
  425. } else if (!wasMobile && isMobile) {
  426. $('#clippingBoundsScrollContainer').hide();
  427. $axure.player.closePopup();
  428. $('#lsplitbar').hide();
  429. $('#rsplitbar').hide();
  430. $('.leftPanel').show();
  431. $('.rightPanel').show();
  432. $axure.player.updatePlugins();
  433. $('#mHideSidebar').append($('.leftPanel'));
  434. $('#mHideSidebar').append($('.rightPanel'));
  435. if (MOBILE_DEVICE) $('#maximizePanelContainer').hide();
  436. $axure.messageCenter.postMessage('collapseFrameOnLoad');
  437. }
  438. var newHeight = 0;
  439. var newWidth = 0;
  440. if (IOS && $axure.utils.isShareApp()) {
  441. // Hack for Iphone X
  442. newHeight = iosInnerHeight();
  443. newWidth = $(window).width();
  444. } else {
  445. // 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)
  446. //var newHeight = $(window).height() - ((!isMobile && $('#topPanel').is(':visible'))? $('#topPanel').height() : 0);
  447. newHeight = window.innerHeight - ((!isMobile && $('#topPanel').is(':visible')) ? $('#topPanel').height() : 0);
  448. newWidth = $(window).width();
  449. }
  450. $('#outerContainer').height(newHeight).width(newWidth);
  451. $('#mainPanel').height(newHeight);
  452. $('#clippingBounds').height(newHeight);
  453. if (isMobile) {
  454. $('#mobileControlFrameContainer').height(newHeight);
  455. $('#mobileControlFrameContainer').width(newWidth);
  456. var newControlHeight = newHeight - (!MOBILE_DEVICE ? 112 : !$axure.utils.isShareApp() ? 140 : IOS ? 157 : 138);
  457. // Screen resize is only way through browser to catch mobile device keyboard expand and collapse
  458. if ($('#mHideSidebar').is(':visible') && !$('#mobileControlFrameContainer').is(':visible')) {
  459. $('#mobileControlFrameContainer').delay(150).show();
  460. } else if (isMobileTextEntry) {
  461. newControlHeight = newControlHeight + (!$axure.utils.isShareApp() ? 61 : IOS ? 72 : 60);
  462. $('#mobileControlFrameContainer').hide();
  463. }
  464. if(!$('.leftPanel').hasClass('popup')) {
  465. $('.leftPanel').height(newControlHeight);
  466. }
  467. $('.rightPanel').height(newControlHeight);
  468. $('.mobileOnlyPanel').height(newControlHeight);
  469. } else {
  470. if (!$('.leftPanel').hasClass('popup')) {
  471. $('.leftPanel').css('height','');
  472. }
  473. $('.rightPanel').css('height', '');
  474. if ($('.rightPanel').is(':visible')) {
  475. var lastRightPanelWidthDefaultSub = ($(window).width() - lastRightPanelWidthDefault || 0);
  476. var rightPanelWidth = ($('.rightPanel').width() || 0);
  477. var leftPanelPanelWidthSub = ($(window).width() - $('.leftPanel').width()) || 0;
  478. var newWidth = Math.min(lastRightPanelWidthDefaultSub, rightPanelWidth, leftPanelPanelWidthSub);
  479. lastRightPanelWidth = Math.max(lastRightPanelWidthDefault, newWidth);
  480. $('.rightPanel').width(lastRightPanelWidth ? lastRightPanelWidth : lastRightPanelWidthDefault);
  481. $('#rsplitbar').css('left', $(window).width() - $('.rightPanel').width());
  482. }
  483. if ($('.leftPanel').is(':visible')) {
  484. var lastLeftPanelWidthSub = ($(window).width() - lastLeftPanelWidthDefault || 0);
  485. var leftPanelWidth = ($('.leftPanel').width() || 0);
  486. var rightPanelWidthSub = ($(window).width() - $('.rightPanel').width()) || 0;
  487. var newWidth = Math.min(lastLeftPanelWidthSub, leftPanelWidth, rightPanelWidthSub);
  488. lastLeftPanelWidth = Math.max(lastLeftPanelWidthDefault, newWidth);
  489. $('.leftPanel').width(lastLeftPanelWidth ? lastLeftPanelWidth : lastLeftPanelWidthDefault);
  490. $('#lsplitbar').css('left', $('.leftPanel').width() - 4);
  491. }
  492. }
  493. if (isMobile) {
  494. var newControlWidth = newWidth - 80;
  495. $('.leftPanel').css({ 'width': newControlWidth + 'px' });
  496. $('.rightPanel').css({ 'width': newControlWidth + 'px' });
  497. $('.mobileOnlyPanel').css({ 'width': newControlWidth + 'px' });
  498. adjustM('left');
  499. }
  500. updateClippingBoundsWidth();
  501. repositionClippingBoundsScroll();
  502. setAdaptiveView();
  503. wasMobile = isMobile;
  504. }
  505. function contentDocument_onload() {
  506. (function setRepositionWhenReady() {
  507. var $iframe = $('#mainFrame')[0];
  508. if ($($iframe.contentWindow.document.body).length === 0 || $iframe.contentWindow.document.URL === "about:blank") {
  509. setTimeout(setRepositionWhenReady, 50);
  510. } else {
  511. var $iframe = $($('#mainFrame')[0].contentWindow.document);
  512. $iframe.scroll(function () {
  513. repositionClippingBoundsScroll();
  514. });
  515. }
  516. common_contentDocument_onload();
  517. })();
  518. }
  519. // self-destruction timeouts
  520. var dragOverlayTimeout;
  521. var zoomOverlayTimeout;
  522. var selfDestructionTimeoutDuration = 1000; // ms
  523. var forcePanZoomDisabled = false;
  524. function disablePanZoomFeature() {
  525. forcePanZoomDisabled = true;
  526. $('.vpZoomValue').remove();
  527. $('#scaleValue').text('Scale');
  528. }
  529. function panAndZoomKeydownHandler(e) {
  530. // if space key down
  531. if (e.key == " ") {
  532. var $iframe = $('#mainFrame')[0];
  533. var iframeBody = $iframe.contentWindow.document.body;
  534. var dimStr = $('.currentAdaptiveView').attr('data-dim');
  535. var dim = dimStr ? dimStr.split('x') : { w: '0', h: '0' };
  536. var isDevice = dim[1] != '0' ? true : false;
  537. var focusableElements = ["textarea", "input", "button", "select"];
  538. if ((e.target !== iframeBody
  539. && (iframeBody.contains(e.target) || tabbableElements.lastIndexOf(e.target.tagName.toLowerCase()) !== -1))
  540. || isDevice
  541. ) {
  542. return;
  543. }
  544. e.preventDefault();
  545. // clear self-destruction timeout if exist
  546. if (dragOverlayTimeout) {
  547. clearTimeout(dragOverlayTimeout);
  548. }
  549. toggleDragMode(true);
  550. // self-destruction
  551. dragOverlayTimeout = setTimeout(function() {toggleDragMode(false)}, selfDestructionTimeoutDuration);
  552. }
  553. // if hotkey zooming
  554. if (e.ctrlKey || e.metaKey) {
  555. if (e.key == "+" || e.key == "=") {
  556. e.preventDefault();
  557. zoomIn();
  558. }
  559. if (e.key == "-") {
  560. e.preventDefault();
  561. zoomOut();
  562. }
  563. if (e.key == "0") {
  564. e.preventDefault();
  565. dropScaleAndZoomPage(100);
  566. }
  567. }
  568. // if ctrl key down
  569. if (e.key == "Control" || e.key == "Meta") {
  570. // clear self-destruction timeout if exist
  571. if (zoomOverlayTimeout) {
  572. clearTimeout(zoomOverlayTimeout);
  573. }
  574. toggleZoomOverlay(true);
  575. // self-destruction
  576. zoomOverlayTimeout = setTimeout(function() {toggleZoomOverlay(false)}, selfDestructionTimeoutDuration);
  577. }
  578. };
  579. function panAndZoomKeyupHandler(e) {
  580. // if space key up
  581. if (e.key == " ") {
  582. // clear self-destruction timeout if exist
  583. if (dragOverlayTimeout) {
  584. clearTimeout(dragOverlayTimeout);
  585. }
  586. toggleDragMode(false);
  587. }
  588. // if ctrl key up
  589. if (e.key == "Control" || e.key == "Meta") {
  590. // clear self-destruction timeout if exist
  591. if (zoomOverlayTimeout) {
  592. clearTimeout(zoomOverlayTimeout);
  593. }
  594. toggleZoomOverlay(false);
  595. }
  596. };
  597. var zoomLastTimestamp = 0;
  598. var zoomLastDirection = 0;
  599. var disableChunkedZoomEvents = false;
  600. function zoomWheelHandler(event) {
  601. if (event.ctrlKey || event.metaKey) {
  602. event.stopPropagation();
  603. event.preventDefault();
  604. const wheelEvent = event.originalEvent ? event.originalEvent : event;
  605. if (wheelEvent) {
  606. const { deltaY } = normalizeZoomWheelEvent(wheelEvent);
  607. let timestamp = wheelEvent.timeStamp / 1e3;
  608. const direction = Math.sign(deltaY);
  609. if (disableChunkedZoomEvents && timestamp - zoomLastTimestamp < .4 && direction == zoomLastDirection) {
  610. // ignore chunked events
  611. return;
  612. } else {
  613. // disable stickiness
  614. disableChunkedZoomEvents = false;
  615. }
  616. zoomLastTimestamp = timestamp;
  617. zoomLastDirection = direction;
  618. const zoom = getCurrentZoom();
  619. const zoomStep = deltaY < 0 ? zoom * 0.0409 + 0.0415 : zoom * 0.0394 + 0.0367;
  620. let newZoom = roundZoomValue(zoom + zoomStep * -deltaY);
  621. if ((zoom > 100 && newZoom <= 100) || (zoom < 100 && newZoom >= 100)) {
  622. // enable stickiness
  623. newZoom = 100;
  624. disableChunkedZoomEvents = true;
  625. }
  626. const zoomPositionX = wheelEvent.clientX * zoom / 100 - zoom / 100;
  627. const zoomPositionY = wheelEvent.clientY * zoom / 100 - zoom / 100;
  628. const zoomPosition = { x: zoomPositionX, y: zoomPositionY };
  629. dropScaleAndZoomPage(newZoom, zoomPosition);
  630. }
  631. }
  632. }
  633. var gestureStartZoom = 0;
  634. var gesturePrevZoom = 0;
  635. var gestureRaf;
  636. function zoomGestureStart(e) {
  637. e.preventDefault();
  638. gestureStartZoom = gesturePrevZoom = getCurrentZoom();
  639. };
  640. function zoomGestureChange(e) {
  641. e.preventDefault();
  642. if (gestureRaf !== undefined) {
  643. cancelAnimationFrame(gestureRaf)
  644. }
  645. gestureRaf = requestAnimationFrame(function () {
  646. let timestamp = e.timeStamp / 1e3;
  647. const direction = Math.sign(e.scale - 1);
  648. if (disableChunkedZoomEvents && timestamp - zoomLastTimestamp < .5 && direction == zoomLastDirection) {
  649. // ignore chunked events
  650. return;
  651. } else {
  652. // disable stickiness
  653. disableChunkedZoomEvents = false;
  654. }
  655. zoomLastTimestamp = timestamp;
  656. zoomLastDirection = direction;
  657. var zoom = roundZoomValue(gestureStartZoom * e.scale);
  658. if ((gesturePrevZoom > 100 && zoom <= 100) || (gesturePrevZoom < 100 && zoom >= 100)) {
  659. // enable stickiness
  660. zoom = 100;
  661. disableChunkedZoomEvents = true;
  662. }
  663. gesturePrevZoom = zoom;
  664. var zoomPosition = { x: e.pageX, y: e.pageY };
  665. dropScaleAndZoomPage(zoom, zoomPosition);
  666. });
  667. }
  668. var zoomGestureEnd = function (e) {
  669. e.preventDefault();
  670. }
  671. function scrollWheelHandler(event) {
  672. if (!event.ctrlKey && !event.metaKey) {
  673. var dimStr = $('.currentAdaptiveView').attr('data-dim');
  674. var dim = dimStr ? dimStr.split('x') : { w: '0', h: '0' };
  675. var isDevice = dim[1] != '0' ? true : false;
  676. if (!isDevice) return;
  677. // we should scroll iframe programmatically for custom devices
  678. // if wheel event fires outside of the iframe
  679. const wheelEvent = event.originalEvent ? event.originalEvent : event;
  680. if (wheelEvent) {
  681. event.preventDefault();
  682. const scrollStep = isTrackPadDetected(event) ? 13 : 100;
  683. const deltaFactor = getDeltaWheelFactor();
  684. let deltaY = wheelEvent.deltaY ? -wheelEvent.deltaY * deltaFactor * scrollStep : 0;
  685. let deltaX = wheelEvent.deltaX ? -wheelEvent.deltaX * deltaFactor * scrollStep : 0;
  686. if (wheelEvent.shiftKey) {
  687. const temp = deltaX;
  688. deltaX = deltaY;
  689. deltaY = temp;
  690. }
  691. let pagePosition = getPagePosition();
  692. pagePosition.x += deltaX;
  693. pagePosition.y += deltaY;
  694. setPagePosition({ x: pagePosition.x, y: pagePosition.y });
  695. }
  696. }
  697. }
  698. function panAndZoomMouseUpHandler() {
  699. stopDrag();
  700. };
  701. function common_contentDocument_onload() {
  702. (function bindHandlersWhenReady() {
  703. var $iframe = $('#mainFrame')[0];
  704. currentIframeHtml = null;
  705. // Intentionally disable pan/zoom for mobile mode.
  706. // That's to not interfere with native gesture interactions.
  707. if (isMobileMode()) {
  708. disablePanZoomFeature();
  709. return;
  710. }
  711. // Check for locally running prototype.
  712. // Disable pan and zoom feature if not supported.
  713. try {
  714. var _iframeDocument = $iframe.contentWindow.document;
  715. }
  716. catch(ex) {
  717. disablePanZoomFeature();
  718. return;
  719. }
  720. if ($($iframe.contentWindow.document.body).length === 0 || $iframe.contentWindow.document.URL === "about:blank") {
  721. setTimeout(bindHandlersWhenReady, 50);
  722. } else {
  723. const mainPanel = $('#mainPanel')[0];
  724. const iframeWindow = $('#mainFrame')[0].contentWindow;
  725. // remove already added listeners
  726. window.removeEventListener("mouseup", panAndZoomMouseUpHandler);
  727. window.removeEventListener("keydown", panAndZoomKeydownHandler);
  728. window.removeEventListener("keyup", panAndZoomKeyupHandler);
  729. mainPanel.removeEventListener("keydown", panAndZoomKeydownHandler);
  730. mainPanel.removeEventListener("keyup", panAndZoomKeyupHandler);
  731. mainPanel.removeEventListener("wheel", zoomWheelHandler, { passive: false });
  732. mainPanel.removeEventListener("wheel", scrollWheelHandler, { passive: false });
  733. // add pan and zoom listeners
  734. window.addEventListener("mouseup", panAndZoomMouseUpHandler);
  735. window.addEventListener("keydown", panAndZoomKeydownHandler);
  736. window.addEventListener("keyup", panAndZoomKeyupHandler);
  737. mainPanel.addEventListener("keydown", panAndZoomKeydownHandler);
  738. mainPanel.addEventListener("keyup", panAndZoomKeyupHandler);
  739. mainPanel.addEventListener("wheel", zoomWheelHandler, { passive: false });
  740. mainPanel.addEventListener("wheel", scrollWheelHandler, { passive: false });
  741. iframeWindow.addEventListener("keydown", panAndZoomKeydownHandler);
  742. iframeWindow.addEventListener("keyup", panAndZoomKeyupHandler);
  743. iframeWindow.addEventListener("wheel", zoomWheelHandler, { passive: false, capture: true });
  744. if (iframeWindow) {
  745. // Safari specific
  746. // Safari emit gesture event instead of wheel event if touchpad used.
  747. // remove already added listeners
  748. window.removeEventListener("gesturestart", zoomGestureStart, { capture: true });
  749. window.removeEventListener("gesturechange", zoomGestureChange, { capture: true });
  750. window.removeEventListener("gestureend", zoomGestureEnd, { capture: true });
  751. // attaching to both window and iframeWindow as sometimes events
  752. // this is because how weirdly iframe is positioned in Safari
  753. // and doesn't occupy the full space, thus gesture events trigger only on parent window
  754. window.addEventListener("gesturestart", zoomGestureStart, { capture: true });
  755. window.addEventListener("gesturechange", zoomGestureChange, { capture: true });
  756. window.addEventListener("gestureend", zoomGestureEnd, { capture: true });
  757. iframeWindow.addEventListener("gesturestart", zoomGestureStart, { capture: true });
  758. iframeWindow.addEventListener("gesturechange", zoomGestureChange, { capture: true });
  759. iframeWindow.addEventListener("gestureend", zoomGestureEnd, { capture: true });
  760. }
  761. }
  762. })();
  763. }
  764. var zoomValues = $axure.player.zoomValues = [25, 50, 75, 100, 150, 200, 250, 300, 400];
  765. var roundZoomValue = function(value) {
  766. let zoom = Math.round(value);
  767. if (zoom < zoomValues[0]) {
  768. [zoom] = zoomValues;
  769. } else if (zoom > zoomValues[zoomValues.length - 1]) {
  770. zoom = zoomValues[zoomValues.length - 1];
  771. }
  772. return zoom;
  773. }
  774. var getPageSize = function () {
  775. const currentZoom = getCurrentZoom() / 100;
  776. var documentContainer = $($('#mainFrame')[0].contentDocument);
  777. return {
  778. height: (documentContainer.height() || 0) * currentZoom,
  779. width: ($($('#mainFrame')[0].contentDocument).find("body").width() || 0) * currentZoom,
  780. }
  781. }
  782. var getPagePosition = $axure.player.getPagePosition = function() {
  783. const currentZoom = getCurrentZoom() / 100;
  784. var viewerContainer = $('#mainPanel');
  785. const viewerSize = {
  786. height: viewerContainer.height() || 0,
  787. width: viewerContainer.width() || 0,
  788. };
  789. const pageSize = getPageSize();
  790. var screenContainerPosition = getPageScrollPosition();
  791. var pageX = -screenContainerPosition.x * currentZoom - (viewerSize.width > pageSize.width ? pageSize.width / 2 : viewerSize.width / 2);
  792. var pageY = -screenContainerPosition.y * currentZoom - viewerSize.height / 2;
  793. return { x: pageX, y: pageY };
  794. }
  795. var setPagePosition = $axure.player.setPagePosition = function (position) {
  796. const currentZoom = getCurrentZoom() / 100;
  797. var viewerContainer = $('#mainPanel');
  798. const viewerSize = {
  799. height: viewerContainer.height() || 0,
  800. width: viewerContainer.width() || 0,
  801. };
  802. const screenContainerLeft = (viewerSize.width / 2 > Math.abs(position.x) ? 0 : -position.x - viewerSize.width / 2);
  803. const screenContainerTop = -position.y - viewerSize.height / 2;
  804. setPageScrollPosition({ x: screenContainerLeft / currentZoom, y: screenContainerTop / currentZoom } );
  805. }
  806. var roundValueByArrayOfSteps = function(value, array, toSmaller) {
  807. let resultIndex = 0;
  808. for (let i = 0; i < array.length; i++) {
  809. if (array[i] < value) {
  810. const nextValue = array[i + 1];
  811. if (!nextValue) {
  812. resultIndex = i;
  813. break;
  814. } else if (nextValue < value) {
  815. continue;
  816. } else if (nextValue === value) {
  817. resultIndex = i + 1;
  818. break;
  819. } else if (toSmaller) {
  820. resultIndex = i;
  821. break;
  822. } else {
  823. resultIndex = i + 1;
  824. }
  825. } else if (i === 0) {
  826. break;
  827. }
  828. }
  829. return array[resultIndex];
  830. }
  831. // point on page for zooming
  832. var zoomIn = function (position) {
  833. const nextZoom = getNextStepOfZoom(1);
  834. dropScaleAndZoomPage(nextZoom, position);
  835. }
  836. // point on page for zooming
  837. var zoomOut = function (position) {
  838. const nextZoom = getNextStepOfZoom(-1);
  839. dropScaleAndZoomPage(nextZoom, position);
  840. }
  841. var getNextStepOfZoom = function (offset) {
  842. var zoom = getCurrentZoom();
  843. const nearZoom = roundValueByArrayOfSteps(zoom, zoomValues, offset < 0);
  844. let nextZoomOffset = offset;
  845. if (zoom !== nearZoom) {
  846. nextZoomOffset += nextZoomOffset > 0 ? -1 : 1;
  847. }
  848. const currentZoomIndex = zoomValues.findIndex(function(value) { return value === nearZoom }) || 0;
  849. const nextZoomIndex = currentZoomIndex + nextZoomOffset;
  850. let nextZoom = zoom;
  851. if (zoomValues[nextZoomIndex]) {
  852. nextZoom = zoomValues[nextZoomIndex];
  853. }
  854. return nextZoom;
  855. }
  856. var getCurrentZoom = function () {
  857. var zoomValue = getIframeHtml().attr("zoom");
  858. if (zoomValue) {
  859. return parseInt(zoomValue, 10);
  860. }
  861. return 100;
  862. }
  863. var currentIframeHtml = null;
  864. function getIframeHtml() {
  865. if (currentIframeHtml) return currentIframeHtml;
  866. currentIframeHtml = $($('#mainFrame')[0].contentDocument).find("html");
  867. return currentIframeHtml;
  868. }
  869. // zoom value
  870. // point on page for zooming
  871. var zoomPage = $axure.player.zoomPage = function(zoom, position) {
  872. if (forcePanZoomDisabled) return;
  873. getIframeHtml().toggleClass("hideScroll", zoom != 100);
  874. const currentZoom = getCurrentZoom();
  875. const nextZoom = zoom;
  876. var viewerContainer = $('#mainPanel');
  877. const containerSize = {
  878. height: viewerContainer.height() || 0,
  879. width: viewerContainer.width() || 0,
  880. };
  881. const pageSize = getPageSize();
  882. let newPageX = 0;
  883. let newPageY = 0;
  884. if (
  885. containerSize.width <= (pageSize.width * nextZoom) / currentZoom ||
  886. containerSize.height <= (pageSize.height * nextZoom) / currentZoom
  887. ) {
  888. const mouseX = position ? position.x : containerSize.width / 2;
  889. const mouseY = position ? position.y : containerSize.height / 2;
  890. // get current page position
  891. const pagePosition = getPagePosition();
  892. // calculate new page position after zoom
  893. let mousePageX = mouseX - containerSize.width / 2 - pagePosition.x;
  894. let mousePageY = mouseY - containerSize.height / 2 - pagePosition.y;
  895. const newMousePageX = (mousePageX * nextZoom) / currentZoom;
  896. const newMousePageY = (mousePageY * nextZoom) / currentZoom;
  897. newPageX = pagePosition.x - (newMousePageX - mousePageX);
  898. newPageY = pagePosition.y - (newMousePageY - mousePageY);
  899. }
  900. // resize page
  901. // set zoom
  902. getIframeHtml().attr("zoom", zoom);
  903. $axure.player.refreshViewPort();
  904. // set new page position
  905. setPagePosition({ x: newPageX, y: newPageY });
  906. repositionClippingBoundsScroll();
  907. }
  908. var dropScaleAndZoomPage = function (zoom, position) {
  909. var selectedScale = $('.vpScaleOption').find('.selectedRadioButton');
  910. var scaleVal = $(selectedScale).parent().attr('val');
  911. if (scaleVal != 3) {
  912. $axure.player.selectScaleOption(3);
  913. }
  914. zoomPage(zoom, position);
  915. }
  916. var didInitPlatformInfo = false;
  917. var isMacFlag = false;
  918. var isWindowsFlag = false;
  919. function initPlatformInfo() {
  920. if (didInitPlatformInfo) {
  921. return;
  922. }
  923. var platform = self.navigator.platform;
  924. isMacFlag = /Mac/.test(platform);
  925. if (!isMacFlag) {
  926. isWindowsFlag = /Win/.test(platform);
  927. }
  928. didInitPlatformInfo = true;
  929. }
  930. function isWindows() {
  931. initPlatformInfo();
  932. return isWindowsFlag
  933. }
  934. function isMac() {
  935. initPlatformInfo();
  936. return isMacFlag;
  937. }
  938. var lastMultiplier = 0;
  939. var lastTimestamp = 0;
  940. var lastDirectionX = 0;
  941. var lastDirectionY = 0;
  942. function normalizeZoomWheelEvent(e) {
  943. const DOM_DELTA_PIXELS = 0;
  944. const DOM_DELTA_LINES = 1;
  945. const DOM_DELTA_PAGES = 2;
  946. let deltaMode = e.deltaMode;
  947. let deltaX = e.deltaX;
  948. let deltaY = e.deltaY;
  949. let wheelDeltaX = 0;
  950. let wheelDeltaY = 0;
  951. var isWheelDeltaSupported = e.wheelDeltaY != undefined;
  952. if (isWheelDeltaSupported) {
  953. wheelDeltaX = e.wheelDeltaX;
  954. wheelDeltaY = e.wheelDeltaY;
  955. }
  956. const devicePixelRatio = window.devicePixelRatio;
  957. if (CHROME) {
  958. deltaX /= devicePixelRatio;
  959. deltaY /= devicePixelRatio;
  960. wheelDeltaX /= devicePixelRatio;
  961. wheelDeltaY /= devicePixelRatio
  962. }
  963. if (isMac()) {
  964. if (CHROME) {
  965. // check for speed-wheeling
  966. // trackpad wheelDelta == 120 independent of speed
  967. if (Math.abs(wheelDeltaX) > 120 || Math.abs(wheelDeltaY) > 120) {
  968. // decrease lowres mouse speed-wheeling
  969. deltaX /= 80;
  970. deltaY /= 80;
  971. } else {
  972. // decrease trackpad speed
  973. deltaX /= 4;
  974. deltaY /= 4;
  975. }
  976. } else if (FIREFOX) {
  977. deltaX /= 3;
  978. deltaY /= 3;
  979. } else if (SAFARI) {
  980. // check for speed-wheeling
  981. if (Math.abs(wheelDeltaX) > 12 || Math.abs(wheelDeltaY) > 12) {
  982. // decrease lowres mouse speed-wheeling
  983. deltaX /= 80;
  984. deltaY /= 80;
  985. } else {
  986. // single wheel event
  987. deltaX /= 4;
  988. deltaY /= 4;
  989. }
  990. }
  991. } else if (isWindows()) {
  992. let lowResMouse = false;
  993. let lowResCutoff = 120 - 1;
  994. if (CHROME || $axure.browser.isEdge) {
  995. deltaX = -wheelDeltaX;
  996. deltaY = -wheelDeltaY;
  997. lowResMouse = Math.abs(deltaX) >= lowResCutoff || Math.abs(deltaY) >= lowResCutoff;
  998. if (lowResMouse) {
  999. deltaX /= 120;
  1000. deltaY /= 120
  1001. }
  1002. } else if (FIREFOX) {
  1003. if (deltaMode === DOM_DELTA_LINES || deltaMode === DOM_DELTA_PAGES) {
  1004. deltaX *= 40;
  1005. deltaY *= 40
  1006. }
  1007. lowResCutoff = 100 - 1;
  1008. lowResMouse = Math.abs(deltaX) >= lowResCutoff || Math.abs(deltaY) >= lowResCutoff;
  1009. if (lowResMouse) {
  1010. deltaX /= 120;
  1011. deltaY /= 120
  1012. } else {
  1013. var numLinesToScroll = 1;
  1014. deltaX /= numLinesToScroll;
  1015. deltaY /= numLinesToScroll
  1016. }
  1017. }
  1018. if (lowResMouse) {
  1019. let timestamp = e.timeStamp / 1e3;
  1020. const directionX = Math.sign(deltaX);
  1021. const directionY = Math.sign(deltaY);
  1022. let multiplier = 1;
  1023. if (timestamp - lastTimestamp < .05 && directionX == lastDirectionX && directionY == lastDirectionY) {
  1024. multiplier = lastMultiplier * 1.25;
  1025. }
  1026. deltaX *= multiplier;
  1027. deltaY *= multiplier;
  1028. const max = 120;
  1029. var lengthSquared = deltaX * deltaX + deltaY * deltaY;
  1030. if (lengthSquared > max * max) {
  1031. deltaX *= max / Math.sqrt(lengthSquared);
  1032. deltaY *= max / Math.sqrt(lengthSquared)
  1033. }
  1034. lastMultiplier = multiplier;
  1035. lastTimestamp = timestamp;
  1036. lastDirectionX = directionX;
  1037. lastDirectionY = directionY
  1038. }
  1039. }
  1040. return {
  1041. deltaX,
  1042. deltaY,
  1043. deltaMode,
  1044. }
  1045. }
  1046. var getDeltaWheelFactor = function () {
  1047. let deltaFactor = 0.01;
  1048. if (isMac()) {
  1049. if (!FIREFOX) {
  1050. deltaFactor *= 8;
  1051. }
  1052. }
  1053. if (FIREFOX) {
  1054. deltaFactor *= 100 / 3;
  1055. }
  1056. return deltaFactor;
  1057. }
  1058. function isTrackPadDetected(e) {
  1059. var isTrackpad = false;
  1060. if (e.wheelDeltaY || e.wheelDeltaX) {
  1061. if (
  1062. (e.wheelDeltaY && e.wheelDeltaY === (e.deltaY * -3))
  1063. || (e.wheelDeltaX && e.wheelDeltaX === (e.deltaX * -3))
  1064. ) {
  1065. isTrackpad = true;
  1066. }
  1067. } else if (e.deltaMode === 0) {
  1068. isTrackpad = true;
  1069. }
  1070. return isTrackpad;
  1071. }
  1072. var toggleZoomOverlay = function (value) {
  1073. var $body = $($('#mainFrame')[0].contentDocument).find("body");
  1074. if (!value) {
  1075. $body.find('#zoomOverlay').remove();
  1076. } else if ($body.find('#zoomOverlay').length <= 0) {
  1077. $body.append($('<div id="zoomOverlay"/>'));
  1078. }
  1079. }
  1080. var isDragModeEnabled = false;
  1081. var toggleDragMode = function(value) {
  1082. if (isDragModeEnabled === value) {
  1083. return;
  1084. }
  1085. var viewer = $($('#mainFrame')[0].contentWindow);
  1086. var $body = $($('#mainFrame')[0].contentDocument).find("body");
  1087. if (!value) {
  1088. $body.find('#dragOverlay').remove();
  1089. } else if ($body.find('#dragOverlay').length <= 0) {
  1090. $body.append($('<div id="dragOverlay"/>'));
  1091. }
  1092. if (value) {
  1093. viewer.on("mousedown.drag", function(event) { startDrag(event) });
  1094. } else {
  1095. if (isDragModeEnabled) {
  1096. stopDrag();
  1097. }
  1098. viewer.off("mousedown.drag");
  1099. }
  1100. isDragModeEnabled = value;
  1101. }
  1102. var startDrag = function (event) {
  1103. event.preventDefault();
  1104. var viewer = $($('#mainFrame')[0].contentWindow);
  1105. if (event.clientX === undefined || event.clientY === undefined) return;
  1106. let mouseX = event.clientX;
  1107. let mouseY = event.clientY;
  1108. function move({ clientX, clientY }) {
  1109. if (clientX === undefined || clientY === undefined) return;
  1110. const changeX = clientX - mouseX;
  1111. const changeY = clientY - mouseY;
  1112. let pagePosition = getPageScrollPosition();
  1113. pagePosition.x -= changeX ;
  1114. pagePosition.y -= changeY ;
  1115. setPageScrollPosition({ x: pagePosition.x, y: pagePosition.y });
  1116. mouseX = clientX;
  1117. mouseY = clientY;
  1118. };
  1119. $($('#mainFrame')[0].contentDocument).find('#dragOverlay').toggleClass("dragging__start", true);
  1120. viewer.on("mouseup.drag", function() { stopDrag(); });
  1121. viewer.on("mouseout.drag mousemove.drag", function(e) { move(e); });
  1122. }
  1123. var stopDrag = function () {
  1124. var viewer = $($('#mainFrame')[0].contentWindow);
  1125. $($('#mainFrame')[0].contentDocument).find("#dragOverlay").toggleClass("dragging__start", false);
  1126. viewer.off("mouseup.drag");
  1127. viewer.off("mouseout.drag mousemove.drag");
  1128. }
  1129. var getPageScrollPosition = function () {
  1130. var $iframe = $($('#mainFrame')[0].contentWindow);
  1131. return {
  1132. x: $iframe.scrollLeft(),
  1133. y: $iframe.scrollTop()
  1134. }
  1135. }
  1136. var setPageScrollPosition = function (position) {
  1137. if (forcePanZoomDisabled) return;
  1138. var $iframe = $($('#mainFrame')[0].contentWindow);
  1139. $iframe.scrollTop(position.y);
  1140. $iframe.scrollLeft(position.x);
  1141. }
  1142. // This is the full width and height of the prototype (beyond the window width and height)
  1143. var determineIframeDimensions = function () {
  1144. var $iframe = $($('#mainFrame')[0].contentWindow);
  1145. return {
  1146. width: $iframe.width(),
  1147. height: $iframe.height()
  1148. };
  1149. };
  1150. // Position of this (upper left hand corner) should match the existingPinPanel position
  1151. var determineIframePosition = function () {
  1152. var dimensions = determineIframeDimensions();
  1153. var $iframe = $($('#mainFrame')[0].contentWindow);
  1154. var $body = $($iframe[0].document.body);
  1155. var bodyWidth = $body.offset().left !== 0 ? $body.width() : dimensions.width;
  1156. if (FIREFOX) {
  1157. var left = $body[0].getBoundingClientRect().left;
  1158. bodyWidth = left !== 0 ? $body.width() : dimensions.width;
  1159. }
  1160. return {
  1161. top: 0,// Math.max(0, (dimensions.height - $($iframe[0].document.body).height()) / 2),
  1162. left: Math.max(0, (dimensions.width - bodyWidth) / 2)
  1163. };
  1164. };
  1165. // Return iframe scroll top and scroll left
  1166. var determineIframeScroll = function () {
  1167. var $iframe = $($('#mainFrame')[0].contentWindow);
  1168. return {
  1169. scrollTop: $iframe.scrollTop(),
  1170. scrollLeft: $iframe.scrollLeft()
  1171. };
  1172. };
  1173. function calculateClippingBoundsWidth(panelSize, isLeftPanel) {
  1174. var $leftPanel = $('.leftPanel:visible');
  1175. var leftPanelOffset = (!isMobileMode() && $leftPanel.length > 0 && !$leftPanel.hasClass('popup')) ? $leftPanel.width() : 0;
  1176. var $rightPanel = $('.rightPanel:visible');
  1177. var rightPanelOffset = (!isMobileMode() && $rightPanel.length > 0) ? $rightPanel.width() : 0;
  1178. // Replace current panel size with panel size after animation for expand or collapse completes
  1179. if (typeof panelSize !== 'undefined') {
  1180. if (isLeftPanel) leftPanelOffset = panelSize;
  1181. else rightPanelOffset = panelSize;
  1182. }
  1183. return $(window).width() - rightPanelOffset - leftPanelOffset;
  1184. }
  1185. var updateClippingBoundsWidth = $axure.player.updateClippingBoundsWidth = function () {
  1186. if ($('.leftPanel').is(':visible')) $('#clippingBounds').css('left', $('.leftPanel').width());
  1187. else $('#clippingBounds').css('left', '0px');
  1188. $('#clippingBounds').width(calculateClippingBoundsWidth());
  1189. }
  1190. var contentLeftOfOriginOffset = 0;
  1191. function calculateClippingBoundsScrollPosition() {
  1192. // Adjust for mainPanelContainer scaling (scale should be "none" for scaleVal == 0 or scaleVal == 1)
  1193. var $iframe = $($('#mainFrame')[0].contentWindow);
  1194. var selectedScale = $('.vpScaleOption').find('.selectedRadioButton');
  1195. var scaleVal = $(selectedScale).parent().attr('val');
  1196. var dimStr = $('.currentAdaptiveView').attr('data-dim');
  1197. var dim = dimStr ? dimStr.split('x') : { w: '0', h: '0' };
  1198. var isDevice = dim[1] != '0' ? true : false;
  1199. // This line is necessary for right handling DEFAULT SCALE
  1200. // Because default scale relates to scale-to-fit item for device projects
  1201. if (scaleVal == '0' && isDevice) scaleVal = 2;
  1202. var scale = $('#mainPanelContainer').css('transform');;
  1203. scale = (scale == "none") ? 1 : Number(scale.substring(scale.indexOf('(') + 1, scale.indexOf(',')));
  1204. // Iframe and Main Panel Positioning
  1205. var iframeScroll = determineIframeScroll();
  1206. var iframePos = determineIframePosition();
  1207. var viewablePanelLeftMargin = parseInt($('#mainPanelContainer').css('margin-left'));
  1208. var viewablePanelTop = parseInt($('#mainPanelContainer').css('top'));
  1209. if (isNaN(viewablePanelTop)) viewablePanelTop = 0;
  1210. if (scaleVal == 2) {
  1211. // Scale to Fit (account for main panel container scale) -- needed for device mode in Scale to Fit
  1212. viewablePanelLeftMargin = ($('#mainPanel').width() - ($('#mainPanelContainer').width() * scale)) / 2
  1213. viewablePanelTop = ($('#mainPanel').height() - ($('#mainPanelContainer').height() * scale)) / 2
  1214. }
  1215. if (scaleVal == 3) {
  1216. // Scale to Fit (account for main panel container scale) -- needed for device mode in Scale to Fit
  1217. viewablePanelLeftMargin = ($('#mainPanel').width() - ($('#mainPanelContainer').width() * scale)) / 2;
  1218. if (viewablePanelLeftMargin < 0) {
  1219. viewablePanelLeftMargin = 0;
  1220. }
  1221. }
  1222. // left and top positioning
  1223. var leftPos = viewablePanelLeftMargin + (iframePos.left - iframeScroll.scrollLeft) * scale;
  1224. var topPos = viewablePanelTop - iframeScroll.scrollTop * scale;
  1225. // Special cases for Centered Page
  1226. var isCentered = $($iframe[0].document.body).css('position') == 'relative';
  1227. if (isCentered && scaleVal == 1) leftPos = 0;
  1228. else if (isCentered && scaleVal == 2) leftPos = $('#mainPanelContainer').width() * scale / 2.0 - contentLeftOfOriginOffset;
  1229. // Include clipFrameScroll offset in mainPanelContainer
  1230. topPos += (parseFloat($('#clipFrameScroll').css("top")) || 0) * scale;
  1231. return {
  1232. left: leftPos,
  1233. top: topPos
  1234. }
  1235. }
  1236. function repositionClippingBoundsScroll() {
  1237. if (!$axure.player.settings.isAxshare) return;
  1238. (function repositionWhenReady() {
  1239. if ($($('#mainFrame')[0].contentWindow.document.body).length === 0) {
  1240. setTimeout(repositionWhenReady, 50);
  1241. } else {
  1242. var position = calculateClippingBoundsScrollPosition();
  1243. // Adding mainPanel scroll here, since it does not work well with calculating animation left position
  1244. position.left = position.left - $('#mainPanel').scrollLeft() - $('#clipFrameScroll').scrollLeft();
  1245. position.top = position.top - $('#mainPanel').scrollTop() - $('#clipFrameScroll').scrollTop();
  1246. $('#clippingBoundsScrollContainer').css('left', position.left + 'px');
  1247. $('#clippingBoundsScrollContainer').css('top', position.top + 'px');
  1248. }
  1249. })();
  1250. }
  1251. function calculateScrollLeftWithOffset(offset, isLeftPanel) {
  1252. if (!$axure.player.settings.isAxshare) return;
  1253. if ($($('#mainFrame')[0].contentWindow.document.body).length === 0) return;
  1254. var scaleVal = $('.vpScaleOption').find('.selectedRadioButton').parent().attr('val');
  1255. if (scaleVal == 2) return;
  1256. var $iframe = $($('#mainFrame')[0].contentWindow);
  1257. var $body = $($iframe[0].document.body);
  1258. var dimStr = $('.currentAdaptiveView').attr('data-dim');
  1259. var hasFrame = (!dimStr ? false : dimStr.split('x')[1] != '0') && !$axure.player.noFrame;
  1260. var isCentered = $body.css('position') == 'relative'; //body position is always static while page is still loading (thus false, if called on intial load)
  1261. var isCollapsing = offset > 0; //offset is positive when collapsing since we are gaining offset more space for content viewing
  1262. // Base case left positioning
  1263. var leftPos = calculateClippingBoundsScrollPosition().left;
  1264. // If maintaining view options requires a left adjustment not equivalent to panel size (which has already being added in leftPos above)
  1265. var viewAdjustment = 0;
  1266. // Mobile Frame adjustment
  1267. if (hasFrame) {
  1268. var viewablePanelLeftMargin = parseInt($('#mainPanelContainer').css('margin-left'));
  1269. var viewablePanelRightMargin = parseInt($('#mainPanelContainer').css('margin-right'));
  1270. // Cases
  1271. // 0) Adaptive view frame doesn't fit in viewable bounds (viewablePanelLeftMargin is zero) -- use entire offset of panel (no adjustment needed)
  1272. // 1) Adaptive view frame fits in bounds -- then half of incoming panel will be split left and half right (offset / 2)
  1273. // 2) and 3) View Frame either fits in bounds before animation and no longer will after, or vice versa. Mix of previous two cases
  1274. if (isCollapsing) {
  1275. if (viewablePanelLeftMargin != 0) {
  1276. viewAdjustment = offset / 2;
  1277. } else if (-viewablePanelRightMargin < offset) {
  1278. viewAdjustment = ((offset + viewablePanelRightMargin) / 2);
  1279. }
  1280. } else if (viewablePanelLeftMargin != 0) {
  1281. viewAdjustment = Math.max(offset / 2, -viewablePanelLeftMargin)
  1282. }
  1283. }
  1284. // Centered Page adjustment
  1285. if (isCentered) {
  1286. // Width of content not able to fit inside current viewable frame
  1287. var clippedContentWidth = $body.width() - calculateClippingBoundsWidth(Math.abs(offset), isLeftPanel);
  1288. // Cases
  1289. // 0) Content never fits in bounds -- then entire offset of panel will move content left value (no adjustment needed as already handled)
  1290. // 1) Content fits in bounds -- then half of incoming panel offset will be split left and half right (offset / 2)
  1291. // 2) and 3) Content either fits in bounds before animation and no longer will after, or vice versa. Mix of previous two cases
  1292. if (clippedContentWidth <= 0) {
  1293. viewAdjustment = offset / 2;
  1294. } else if (isCollapsing && clippedContentWidth < offset) {
  1295. viewAdjustment = (offset - clippedContentWidth) / 2;
  1296. } else if (!isCollapsing && clippedContentWidth < -offset) {
  1297. viewAdjustment = (clippedContentWidth + offset) / 2;
  1298. }
  1299. }
  1300. return leftPos + viewAdjustment;
  1301. }
  1302. // Set to true when left panel or right panel are being expanded/collapsed
  1303. // returns to false when lsplitbar (switched to clippingBounds) finishes animation (thus panels will be fully expanded or retracted at this point)
  1304. var isAnimating = $axure.player.isAnimating = false;
  1305. $axure.player.collapseToBar = function (context, hostId) {
  1306. lastLeftPanelWidth = $('.leftPanel').width();
  1307. lastRightPanelWidth = $('.rightPanel').width();
  1308. if (context === 'project' || context === 'all') {
  1309. if(!isMobileMode()) {
  1310. isAnimating = true;
  1311. var newWidth = lastLeftPanelWidth != 0 ? lastLeftPanelWidth : lastLeftPanelWidthDefault;
  1312. var clippingWidth = calculateClippingBoundsWidth(0, true);
  1313. var newLeft = calculateScrollLeftWithOffset(newWidth, true);
  1314. $('.leftPanel').animate({ 'margin-left': -newWidth + 'px' },
  1315. { duration: 200, complete: function() { $('.leftPanel').width(0).hide().css({ 'marginLeft': '' }); } });
  1316. $('#lsplitbar').animate({ left: '-4px' },
  1317. { duration: 200, complete: function() { $('#lsplitbar').hide(); } });
  1318. $('#clippingBounds').animate({ left: '', width: clippingWidth + 'px' }, { duration: 200 });
  1319. $('#clippingBoundsScrollContainer').animate({ left: newLeft + 'px' },
  1320. { duration: 200, complete: function () {
  1321. isAnimating = false;
  1322. $axure.player.resizeContent();
  1323. $axure.player.pluginVisibleChanged(hostId, false);
  1324. }});
  1325. } else {
  1326. $('.leftPanel').width(0);
  1327. $('#lsplitbar').hide();
  1328. }
  1329. }
  1330. if (context === 'inspect' || context === 'all') {
  1331. if (!isMobileMode()) {
  1332. isAnimating = true;
  1333. var newWidth = lastRightPanelWidth != 0 ? lastRightPanelWidth : lastRightPanelWidthDefault;
  1334. var clippingWidth = calculateClippingBoundsWidth(0, false);
  1335. var newLeft = calculateScrollLeftWithOffset(newWidth, false);
  1336. $('.rightPanel').animate({ 'margin-right': -newWidth + 'px' },
  1337. { duration: 200, complete: function () { $('.rightPanel').width(0).hide().css({ 'marginRight': '' }); } });
  1338. $('#rsplitbar').animate({ left: $(window).width() + 'px' },
  1339. { duration: 200, complete: function () { $('#rsplitbar').hide(); } });
  1340. $('#clippingBounds').animate({ width: clippingWidth + 'px' }, { duration: 200 });
  1341. $('#clippingBoundsScrollContainer').animate({ left: newLeft + 'px' },
  1342. { duration: 200, complete: function () {
  1343. isAnimating = false;
  1344. $axure.player.resizeContent();
  1345. $axure.player.pluginVisibleChanged(hostId, false);
  1346. }});
  1347. } else {
  1348. $('.rightPanel').width(0);
  1349. $('#rsplitbar').hide();
  1350. }
  1351. }
  1352. $(window).resize();
  1353. toolBarOnly = true;
  1354. }
  1355. $axure.player.expandFromBar = function (hostId, context, isFinalPluginToRestore) {
  1356. if (context === 'project') {
  1357. if ($('#lsplitbar').is(':visible')) return;
  1358. $('.leftPanel').removeClass('popup');
  1359. if(!isMobileMode()) {
  1360. isAnimating = true;
  1361. var newWidth = (lastLeftPanelWidth ? lastLeftPanelWidth : lastLeftPanelWidthDefault);
  1362. var clippingWidth = calculateClippingBoundsWidth(newWidth, true);
  1363. var newLeft = calculateScrollLeftWithOffset(-newWidth, true);
  1364. $('.leftPanel').width(newWidth);
  1365. $('.leftPanel').css('margin-left', -newWidth + 'px').show();
  1366. $('.leftPanel').animate({ 'margin-left': '0px' }, { duration: 200, complete: function () { $('.leftPanel').css({ 'marginLeft': '' }); } });
  1367. $('#lsplitbar').css('left', '-4px');
  1368. $('#lsplitbar').show();
  1369. $('#lsplitbar').animate({ left: newWidth - 4 + 'px' }, { duration: 200 });
  1370. $('#clippingBounds').animate({ left: newWidth + 'px', width: clippingWidth + 'px' }, { duration: 200 });
  1371. $('#clippingBoundsScrollContainer').animate({ left: newLeft + 'px' },
  1372. { duration: 200, complete: function () {
  1373. isAnimating = false;
  1374. $axure.player.resizeContent();
  1375. if (isFinalPluginToRestore) $('#clippingBoundsScrollContainer').show();
  1376. $axure.player.pluginVisibleChanged(hostId, true);
  1377. }});
  1378. }
  1379. } else {
  1380. if ($('#rsplitbar').is(':visible')) {
  1381. // update width of rightPanel plugin
  1382. var newWidth = lastRightPanelWidth ? lastRightPanelWidth : lastRightPanelWidthDefault;
  1383. $('#' + hostId).width(newWidth);
  1384. $('#' + hostId).show();
  1385. $axure.player.pluginVisibleChanged(hostId, true);
  1386. return;
  1387. }
  1388. if (!isMobileMode()) {
  1389. isAnimating = true;
  1390. var newWidth = lastRightPanelWidth ? lastRightPanelWidth : lastRightPanelWidthDefault;
  1391. var clippingWidth = calculateClippingBoundsWidth(newWidth, false);
  1392. var newLeft = calculateScrollLeftWithOffset(-newWidth, false);
  1393. $('.rightPanel').width(newWidth);
  1394. $('.rightPanel').css('margin-right', -newWidth + 'px');
  1395. $('#' + hostId).show();
  1396. $('.rightPanel').animate({ 'margin-right': '0px' }, { duration: 200, complete: function () { $('.rightPanel').css({ 'marginRight': '' }); } });
  1397. $('#rsplitbar').css('left', $(window).width());
  1398. $('#rsplitbar').show();
  1399. $('#rsplitbar').animate({ left: $(window).width() - $('.rightPanel').width() + 'px' }, { duration: 200 });
  1400. $('#clippingBounds').animate({ width: clippingWidth + 'px' }, { duration: 200 });
  1401. $('#clippingBoundsScrollContainer').animate({ left: newLeft + 'px' },
  1402. { duration: 200, complete: function () {
  1403. isAnimating = false;
  1404. $axure.player.resizeContent();
  1405. if (isFinalPluginToRestore) $('#clippingBoundsScrollContainer').show();
  1406. $axure.player.pluginVisibleChanged(hostId, true);
  1407. }});
  1408. }
  1409. }
  1410. $(window).resize();
  1411. toolBarOnly = false;
  1412. if (isMobileMode()) {
  1413. $('#mHideSidebar').show();
  1414. $('#nativeAppControlFrame').show();
  1415. }
  1416. }
  1417. var suspendRefreshViewPort = $axure.player.suspendRefreshViewPort = false;
  1418. $axure.player.refreshViewPort = function () {
  1419. if (suspendRefreshViewPort) return;
  1420. var dimStr = $('.currentAdaptiveView').attr('data-dim');
  1421. var dim = dimStr ? dimStr.split('x') : { w: '0', h: '0' };
  1422. var w = dim[0] != '0' ? dim[0] : '';
  1423. var h = dim[1] != '0' ? dim[1] : '';
  1424. var cursor = $('.currentAdaptiveView').attr('cursor');
  1425. var scaleVal = $('.vpScaleOption').find('.selectedRadioButton').parent().attr('val');
  1426. var selectedScaleValue = scaleVal;
  1427. $axure.player.noFrame = false;
  1428. if (h && scaleVal == 1) $axure.player.noFrame = true;
  1429. $('#mainPanelContainer').attr({
  1430. "data-scale-n": scaleVal,
  1431. "data-page-dimensions-type": h ? "device" : w ? "web" : "auto",
  1432. "data-scale-shift-x": null,
  1433. "data-scale-shift-y": null,
  1434. });
  1435. var clipToView = h && !$axure.player.noFrame;
  1436. var isDevice = h;
  1437. var mainPanelWidth = $('#mainPanel').width();
  1438. var mainPanelHeight = $('#mainPanel').height();
  1439. if (!w || !clipToView) w = mainPanelWidth;
  1440. if (!h || !clipToView) h = mainPanelHeight;
  1441. if (MOBILE_DEVICE && h > mainPanelHeight) h = mainPanelHeight;
  1442. if (MOBILE_DEVICE && w > mainPanelWidth) w = mainPanelWidth;
  1443. const mainFrameHeight = h;
  1444. const mainFrameWidth = w;
  1445. if (clipToView) {
  1446. if (!MOBILE_DEVICE && scaleVal == '0') scaleVal = 2;
  1447. w = Number(w);
  1448. h = Number(h);
  1449. $('#mainFrame').width(w);
  1450. $('#clipFrameScroll').width(w);
  1451. $('#clipFrameScroll').height(h);
  1452. var topPadding = MOBILE_DEVICE ? 0 : 10;
  1453. var leftPadding = 0;
  1454. var rightPadding = 0;
  1455. var bottomPadding = MOBILE_DEVICE ? 0 : 10;
  1456. if (scaleVal == 3) {
  1457. topPadding = 0;
  1458. bottomPadding = 0;
  1459. }
  1460. w = w + leftPadding + rightPadding;
  1461. h = h + topPadding + bottomPadding;
  1462. var x = (mainPanelWidth - w) / 2;
  1463. var y = (mainPanelHeight - h) / 2 - 1;
  1464. if (scaleVal != 2) {
  1465. x = Math.max(0, x);
  1466. y = Math.max(0, y);
  1467. }
  1468. $('#mainPanelContainer').attr({
  1469. "data-scale-shift-x": x,
  1470. "data-scale-shift-y": y,
  1471. });
  1472. $('#mainPanelContainer').css({
  1473. 'margin': 'auto',
  1474. 'top': y + 'px',
  1475. 'left': (x < 0 ? x + 'px' : 'auto')
  1476. });
  1477. $('#clipFrameScroll').css({
  1478. 'left': leftPadding + 'px',
  1479. 'top': topPadding + 'px'
  1480. });
  1481. $('#mainPanelContainer').width(w);
  1482. $('#mainPanelContainer').height(h);
  1483. } else {
  1484. $('#mainFrame').width('100%');
  1485. $('#clipFrameScroll').width('100%');
  1486. $('#clipFrameScroll').height(h);
  1487. $('#clipFrameScroll').css({ 'left': '', 'top': '' });
  1488. $('#mainPanelContainer').height(h);
  1489. $('#mainPanelContainer').css({
  1490. 'left': '',
  1491. 'margin': '',
  1492. 'top': ''
  1493. });
  1494. }
  1495. $axure.messageCenter.postMessage('setDeviceMode', { device: isDevice, width: w, scaleToWidth: (scaleVal == "1"), cursor: +cursor });
  1496. $(".vpScaleOption").show();
  1497. var prevScaleN = $('#mainPanelContainer').css('transform');
  1498. prevScaleN = (prevScaleN == "none") ? 1 : Number(prevScaleN.substring(prevScaleN.indexOf('(') + 1, prevScaleN.indexOf(',')));
  1499. $('#mainPanelContainer').css({
  1500. 'transform': '',
  1501. 'transformOrigin': ''
  1502. });
  1503. var $leftPanel = $('.leftPanel:visible');
  1504. var leftPanelOffset = (!isMobileMode() && $leftPanel.length > 0) ? $leftPanel.width() : 0;
  1505. var $rightPanel = $('.rightPanel:visible');
  1506. var rightPanelOffset = (!isMobileMode() && $rightPanel.length > 0) ? $rightPanel.width() : 0;
  1507. var vpScaleData = {
  1508. scale: scaleVal,
  1509. prevScaleN: prevScaleN,
  1510. mainFrameHeight,
  1511. mainFrameWidth,
  1512. viewportHeight: h,
  1513. viewportWidth: w,
  1514. panelWidthOffset: leftPanelOffset + rightPanelOffset,
  1515. clipToView: clipToView
  1516. };
  1517. $axure.messageCenter.postMessage('getScale', vpScaleData);
  1518. $axure.messageCenter.postMessage('cloud_ScaleValueChanged', {
  1519. scale: selectedScaleValue,
  1520. });
  1521. if (scaleVal == '0' && clipToView) $('#mainPanel').css('overflow', 'auto');
  1522. else $('#mainPanel').css('overflow', '');
  1523. }
  1524. $axure.player.getProjectName = function getProjectName() {
  1525. if (typeof PREVIEW_INFO !== 'undefined') {
  1526. // default decodeURI may decode some chars wrong in case when the string was not decoded in the same browser
  1527. return new URLSearchParams("a=" + PREVIEW_INFO.fileName).get("a");
  1528. } else if(typeof $axure.player.settings.projectName !== 'undefined') {
  1529. return $axure.player.settings.projectName;
  1530. } else return false;
  1531. }
  1532. function initializeLogo() {
  1533. if(typeof PREVIEW_INFO !== 'undefined') {
  1534. $('#previewNotice').show();
  1535. }
  1536. //if (typeof PREVIEW_INFO !== 'undefined') {
  1537. // $('#interfaceControlFrameLogoCaptionContainer').html(PREVIEW_INFO.fileName);
  1538. //} else if (typeof $axure.player.settings.projectName !== 'undefined') {
  1539. // $('#interfaceControlFrameLogoCaptionContainer').html($axure.player.settings.projectName);
  1540. //} else {
  1541. // $('#interfaceControlFrameLogoCaptionContainer').hide();
  1542. //}
  1543. //if ($axure.document.configuration.logoImagePath) {
  1544. // var image = new Image();
  1545. // //image.onload = function () {
  1546. // // //$('#logoImage').css('max-width', this.width + 'px');
  1547. // // $('#interfaceControlFrameContainer').css('margin-left', '-' + $('#logoImage').width() / 2 + 'px');
  1548. // // //$axure.player.resizeContent();
  1549. // //};
  1550. // image.src = $axure.document.configuration.logoImagePath;
  1551. // $('#interfaceControlFrameLogoImageContainer').html('<img id="logoImage" src="" />');
  1552. // $('#logoImage').attr('src', $axure.document.configuration.logoImagePath);//.on('load', function () { $axure.player.resizeContent(); });
  1553. //} else $('#interfaceControlFrameLogoImageContainer').hide();
  1554. //if ($axure.document.configuration.logoImageCaption) {
  1555. // $('#interfaceControlFrameLogoCaptionContainer').html($axure.document.configuration.logoImageCaption);
  1556. //} else $('#interfaceControlFrameLogoCaptionContainer').hide();
  1557. //if(!$('#interfaceControlFrameLogoImageContainer').is(':visible') && !$('#interfaceControlFrameLogoCaptionContainer').is(':visible')) {
  1558. // $('#interfaceControlFrameLogoContainer').hide();
  1559. //}
  1560. }
  1561. function initializePreview() {
  1562. if (typeof PREVIEW_INFO !== 'undefined') {
  1563. $('#separatorContainer').addClass('hasLeft');
  1564. $('#overflowMadeWith').addClass('preview');
  1565. var callback = undefined;
  1566. $('#publishButton').click(function () {
  1567. $.ajax({
  1568. type: 'GET',
  1569. url: 'publish',
  1570. data: {},
  1571. success: function (response) {
  1572. if (callback) callback(response);
  1573. },
  1574. error: function (response) {
  1575. if (callback) callback(response);
  1576. },
  1577. dataType: 'jsonp'
  1578. });
  1579. });
  1580. }
  1581. }
  1582. var iosInnerHeight = (function () {
  1583. if (!navigator.userAgent.match(/iphone|ipod|ipad/i)) {
  1584. /**
  1585. * Avoids conditional logic in the implementation
  1586. * @return {number} - window's innerHeight measurement in pixels
  1587. */
  1588. return function () {
  1589. return window.innerHeight;
  1590. };
  1591. }
  1592. // Store initial orientation
  1593. var axis = Math.abs(window.orientation);
  1594. // And hoist cached dimensions
  1595. var dims = { w: 0, h: 0 };
  1596. /**
  1597. * Creates an element with a height of 100vh since iOS accurately
  1598. * reports vp height (but not window.innerHeight). Then destroy it.
  1599. */
  1600. var createRuler = function () {
  1601. var ruler = document.createElement('div');
  1602. ruler.style.position = 'fixed';
  1603. ruler.style.height = '100vh';
  1604. ruler.style.width = 0;
  1605. ruler.style.top = 0;
  1606. document.documentElement.appendChild(ruler);
  1607. // Set cache conscientious of device orientation
  1608. dims.w = axis === 90 ? ruler.offsetHeight : window.innerWidth;
  1609. dims.h = axis === 90 ? window.innerWidth : ruler.offsetHeight;
  1610. // Clean up after ourselves
  1611. document.documentElement.removeChild(ruler);
  1612. ruler = null;
  1613. };
  1614. // Measure once
  1615. createRuler();
  1616. /**
  1617. * Returns window's cached innerHeight measurement
  1618. * based on viewport height and device orientation
  1619. * @return {number} - window's innerHeight measurement in pixels
  1620. */
  1621. return function () {
  1622. if (Math.abs(window.orientation) !== 90) {
  1623. return dims.h;
  1624. }
  1625. return dims.w;
  1626. };
  1627. }());
  1628. function includeTokens(ajaxData, excludeUser) {
  1629. //If the authCookieValue is set (a password-protected local prototype), then send the
  1630. //token as well (because cookies don't always get sent to external domains)
  1631. if (authCookieValue) {
  1632. $.extend(ajaxData, { token: authCookieValue });
  1633. }
  1634. if (!excludeUser && userCookieValue) {
  1635. $.extend(ajaxData, { utoken: userCookieValue });
  1636. }
  1637. }
  1638. function setUserLoggedInStatus(response, safariAuthResponseProfile) {
  1639. if (!response.success) {
  1640. userAcct.isUsingAxureAcct = false;
  1641. } else {
  1642. if (safariAuthResponseProfile) response = safariAuthResponseProfile;
  1643. userAcct.userId = response.userId;
  1644. if (safariAuthResponseProfile)
  1645. userAcct.userName = response.username == null || response.username.trim() === '' ? response.userEmail : response.username.trim();
  1646. else
  1647. userAcct.userName = response.nickname == null || response.nickname.trim() === '' ? response.userEmail : response.nickname.trim();
  1648. userAcct.userEmail = response.userEmail;
  1649. userAcct.userProfileImg = response.profileImageUrl;
  1650. userAcct.isUsingAxureAcct = true;
  1651. if (response.authToken != null) {
  1652. $axshare.setAuthCookie(response.authToken);
  1653. userCookieValue = response.authToken;
  1654. }
  1655. }
  1656. // If feedback is loaded, update feedback with new account information
  1657. if (typeof feedback !== 'undefined') feedback.updateUserAccountInfo(userAcct, authCookieValue, userCookieValue);
  1658. }
  1659. // TODO: for on prem, we need to use an ajax call directly to share instead of accounts
  1660. // Verify authentication against axure accounts
  1661. $axure.player.axureAuth = function axureAuth(callback) {
  1662. if (window.$axshare != null) {
  1663. $axshare.auth(function (response) {
  1664. if (response.success) {
  1665. setUserLoggedInStatus(response);
  1666. } else {
  1667. if (isSafari()) {
  1668. var ajaxData = {
  1669. userId: userAcct.isUsingAxureAcct ? userAcct.userId : ""
  1670. };
  1671. includeTokens(ajaxData);
  1672. $.ajax({
  1673. type: 'GET',
  1674. url: feedbackServiceUrl + '/safariAuth',
  1675. data: ajaxData,
  1676. success: function (response) {
  1677. if (!response.success) {
  1678. setUserLoggedInStatus(response);
  1679. } else {
  1680. setUserLoggedInStatus(response, response.data.profile[userAcct.userId]);
  1681. if (callback != null) {
  1682. callback(response);
  1683. }
  1684. }
  1685. },
  1686. dataType: 'jsonp'
  1687. });
  1688. } else {
  1689. setUserLoggedInStatus(response);
  1690. }
  1691. }
  1692. if (callback != null) {
  1693. callback(response);
  1694. }
  1695. });
  1696. }
  1697. }
  1698. // TODO: for on prem, we need to use an ajax call directly to share instead of accounts
  1699. // Log into axure accounts
  1700. $axure.player.axureLogin = function axureLogin(email, password, success, failure, saml) {
  1701. if (window.$axshare != null) {
  1702. password = password === passHint ? "" : password;
  1703. $axshare.login(email, password, false, function (response) {
  1704. if (response.redirecturl !== "" && response.redirecturl != null) {
  1705. saml(response);
  1706. return;
  1707. }
  1708. if (response.success && (response.verified || isSubInstance)) {
  1709. if (isSafari()) setUserLoggedInStatus(response);
  1710. $axure.player.axureAuth(success);
  1711. } else {
  1712. failure(response);
  1713. }
  1714. }, window.ON_PREM_LDAP_ENABLED);
  1715. } else {
  1716. failure();
  1717. }
  1718. }
  1719. function playerLogout() {
  1720. userAcct.isUsingAxureAcct = false;
  1721. userAcct.userId = '';
  1722. userAcct.userProfileImg = '';
  1723. // If feedback is loaded, update feedback with new account information
  1724. if (typeof feedback !== 'undefined') feedback.updateUserAccountInfo(userAcct);
  1725. }
  1726. $axure.player.logout = function (feedbackLogout) {
  1727. var completeLogout = playerLogout;
  1728. if (feedbackLogout) {
  1729. completeLogout = function () {
  1730. feedbackLogout();
  1731. playerLogout();
  1732. }
  1733. }
  1734. if (window.$axshare != null) {
  1735. $axshare.logout(completeLogout);
  1736. } else {
  1737. completeLogout();
  1738. }
  1739. }
  1740. /*
  1741. * TODO: Start of Login/Account Mgmt UI, which will need to be updated (currenly uses feedback9.css often)
  1742. */
  1743. function buildAccountLoginPopup() {
  1744. return [
  1745. '<div class="axClearMsgBubble_Player axureLoginBubble_Player">',
  1746. ' <div class="axureLoginBubbleContainer_Player">',
  1747. ' <span style="font-weight: bold; font-size: 10px;">Login into your Axure Cloud account</span>',
  1748. ' <input type="text" autocapitalize="none" name="email" class="axureEmail" style="margin-top: 7px;"/>',
  1749. ' <input name="password" autocapitalize="none" class="axurePassword" />',
  1750. ' <div class="feedbackGreenBtn_Player">LOG IN</div>',
  1751. ' <div class="errorMessage"></div>',
  1752. ' <div id="playerSignUpLink" style="text-align: right; margin-top: 5px; font-size: 10px;">',
  1753. ' <span>No account? <a class="axureSignUpLink" href="', window.AXSHARE_HOST_SECURE_URL, '" target="_blank">Sign Up</a></span>',
  1754. ' </div>',
  1755. ' </div>',
  1756. '</div>'
  1757. ].join("");
  1758. }
  1759. // Bind events to axure login speech bubble (watermark, login, errors, click outside)
  1760. function bindAxureLoginContainerEvent() {
  1761. var $container = $("#accountLoginContainer");
  1762. $container.find('input[name="email"]').addClass("watermark").val(emailHint).focus(function () {
  1763. if ($(this).val() === emailHint) {
  1764. $(this).removeClass("watermark").val("");
  1765. }
  1766. }).blur(function () {
  1767. if ($(this).val() === "") {
  1768. $(this).addClass("watermark").val(emailHint);
  1769. }
  1770. $container.find('.errorMessage').text('');
  1771. $container.find('.errorMessage').hide();
  1772. }).keyup(function (event) {
  1773. if (event.keyCode == 13) {
  1774. $container.find('.feedbackGreenBtn').click();
  1775. }
  1776. });
  1777. $container.find('input[name="password"]').addClass("watermark").val(passHint).focus(function () {
  1778. if ($(this).val() === passHint) {
  1779. $(this).removeClass("watermark").val("");
  1780. //$(this).removeClass("watermark").val("").attr("type", "password");
  1781. // Note: this might be an issue since jquery doesn't like it. Test in IE
  1782. $(this)[0].setAttribute('type', 'password');
  1783. }
  1784. }).blur(function () {
  1785. if ($(this).val() === "") {
  1786. $(this).val(passHint).addClass("watermark");
  1787. //$(this).val(passHint).addClass("watermark").removeAttr("type");
  1788. // Note: this might be an issue since jquery doesn't like it. Test in IE
  1789. $(this)[0].setAttribute('type', 'text');
  1790. }
  1791. $container.find('.errorMessage').text('');
  1792. $container.find('.errorMessage').hide();
  1793. }).keyup(function (event) {
  1794. if (event.keyCode == 13) {
  1795. $container.find('.feedbackGreenBtn_Player').click();
  1796. }
  1797. });
  1798. // Login Submit Event
  1799. $container.find('.feedbackGreenBtn_Player').click(function (e) {
  1800. var email = $container.find('.axureEmail').val();
  1801. var password = $container.find('.axurePassword').val();
  1802. $axure.player.axureLogin(email, password, function (response) {
  1803. // Success
  1804. // Clear out fields
  1805. $container.find('.axureEmail').val(emailHint).addClass("watermark");
  1806. $container.find('.axurePassword').val(passHint).addClass("watermark");
  1807. $container.find('.axurePassword')[0].setAttribute('type', 'text');
  1808. closePopup();
  1809. }, function (response) {
  1810. // Failure
  1811. $container.find('.errorMessage').text(response != null && response.message ? response.message : "There was an error connecting to the server, please try again later.");
  1812. $container.find('.errorMessage').show();
  1813. }, function (response) {
  1814. // SAML User
  1815. $container.find('.errorMessage').empty();
  1816. $container.find('.errorMessage').append("Please <a class='refreshLink' style='text-decoration: underline;'>refresh</a> this page after logging in via your identity provider.");
  1817. $container.find('.errorMessage').show();
  1818. window.open(response.redirecturl, '_blank');
  1819. $container.find('.errorMessage').find('.refreshLink').click(function () {
  1820. location.reload(true);
  1821. });
  1822. });
  1823. });
  1824. };
  1825. function initializeSignIn() {
  1826. if (typeof PREVIEW_INFO === 'undefined' && $axure.player.settings.isAxshare) {
  1827. (function finishInit() {
  1828. if (window.$axshare == null || $axshare.auth == null || $axshare.login == null) {
  1829. setTimeout(finishInit, 50);
  1830. } else {
  1831. // Call to set readOnlyMode, readOnlyMessage, and isSubinstance (readOnlyMode/Message currently only used for feedback9)
  1832. $.ajax({
  1833. type: 'GET',
  1834. url: feedbackServiceUrl + '/GetShareStatus',
  1835. data: {},
  1836. success: function (response) {
  1837. //readOnlyMode = response.readOnlyMode;
  1838. //readOnlyMessage = response.readOnlyMessage;
  1839. isSubInstance = response.isSubInstance;
  1840. if (isSubInstance) $('#accountLoginContainer').find("#playerSignUpLink").hide();
  1841. // For now, calling methods to set these values in feedback on start (could later make a general method to retrieve these values from player)
  1842. if (typeof feedback !== 'undefined') {
  1843. feedback.setReadOnlyModeAndMessage(response.readOnlyMode, response.readOnlyMessage);
  1844. feedback.setIsSubInstance(isSubInstance);
  1845. }
  1846. },
  1847. dataType: 'jsonp'
  1848. });
  1849. // Login container
  1850. $("#accountLoginContainer").append(buildAccountLoginPopup());
  1851. bindAxureLoginContainerEvent();
  1852. // Attempt to auth and acquire account information, then update top panel
  1853. $axure.player.axureAuth();
  1854. }
  1855. })();
  1856. }
  1857. }
  1858. function overflowProvidesScroll(node) {
  1859. var style = getComputedStyle(node);
  1860. var overflowIsHidden = style.overflow === 'hidden' || (style.overflowX === 'hidden' && style.overflowY === 'hidden');
  1861. var overflowIsVisible = style.overflow === 'visible'|| (style.overflowX === 'visible' && style.overflowY === 'visible');
  1862. var mozTextareaOverflowVisible = FIREFOX && overflowIsVisible && node instanceof HTMLTextAreaElement;
  1863. return !overflowIsHidden && !overflowIsVisible || mozTextareaOverflowVisible;
  1864. }
  1865. function findNearestScrollableParent(firstNode) {
  1866. var node = firstNode;
  1867. var scrollable = null;
  1868. while (!scrollable && node) {
  1869. if (node.scrollWidth > node.clientWidth || node.scrollHeight > node.clientHeight) {
  1870. if (overflowProvidesScroll(node) || $(node).css('-webkit-overflow-scrolling') === 'touch') {
  1871. scrollable = node;
  1872. }
  1873. }
  1874. node = node.parentNode;
  1875. }
  1876. return scrollable;
  1877. }
  1878. function getScrollOwner(target) {
  1879. var owner = findNearestScrollableParent(target);
  1880. if (!owner || owner === document.documentElement || owner === document.body || $(owner).parents('#topPanel').length || owner == document.getElementById('forwardSlash')) {
  1881. return null;
  1882. }
  1883. return owner;
  1884. }
  1885. function removeElasticScrollFromIframe() {
  1886. var $iframe = $($('#mainFrame')[0].contentWindow);
  1887. $iframe[0].document.body.addEventListener('touchmove', function (event) {
  1888. if (!getScrollOwner(event.target)) {
  1889. event.preventDefault();
  1890. }
  1891. }, { passive: false });
  1892. }
  1893. $(document).ready(function () {
  1894. (function finishPlayerInit() {
  1895. if ($axure.player.settings.isAxshare) {
  1896. $axure.page.bind('load.start', contentDocument_onload);
  1897. if ($axure.player.settings.loadFeedbackPlugin) {
  1898. $axure.utils.loadJS('/Scripts/plugins/feedback/feedback9.js');
  1899. /******* DEBUG: Allows for debugging/viewing feedback9.js in browser inspect mode ******/
  1900. //var hdr = document.createElement('script');
  1901. //hdr.type = "text/javascript"
  1902. //hdr.src = '/Scripts/plugins/feedback/feedback9.js';
  1903. //document.head.appendChild(hdr);
  1904. }
  1905. } else {
  1906. $axure.page.bind('load.start', common_contentDocument_onload);
  1907. }
  1908. initializeEvents();
  1909. initializeMainFrame();
  1910. $('.leftPanel').width(0);
  1911. $('#maximizePanelContainer').hide();
  1912. if ($axure.player.settings.startCollapsed) {
  1913. collapse();
  1914. $('.leftPanel').width(0);
  1915. var maxPanelWidth = $('#maximizePanel').width();
  1916. setTimeout(function() {
  1917. $('#maximizePanel').animate({
  1918. left:'-' + maxPanelWidth + 'px'
  1919. }, 300);
  1920. }, 2000);
  1921. }
  1922. if (MOBILE_DEVICE) {
  1923. $('body').removeClass('hashover');
  1924. if (SAFARI) {
  1925. // Stop pinch zoom (stopping all gestures for now)
  1926. // Gesturestart is only supported in Safari
  1927. document.addEventListener("gesturestart", function (e) {
  1928. e.preventDefault();
  1929. });
  1930. }
  1931. if (IOS) {
  1932. // Attempt at removing elastic scroll while in mobile menu
  1933. var touching = false;
  1934. var pageYStart = 0;
  1935. var pageYOffset = 0;
  1936. document.body.addEventListener('touchend', function (event) {
  1937. if (getScrollOwner(event.target)) {
  1938. touching = false;
  1939. }
  1940. }, { passive: false });
  1941. document.body.addEventListener('touchmove', function (event) {
  1942. var owner = getScrollOwner(event.target)
  1943. if (!owner) {
  1944. event.preventDefault();
  1945. } else {
  1946. if ($(owner).scrollTop() == 0) {
  1947. if (touching) {
  1948. if (event.pageY >= pageYStart) {
  1949. event.preventDefault();
  1950. }
  1951. }
  1952. }
  1953. if ($(owner).scrollTop() + $(owner).height() == owner.scrollHeight) {
  1954. if (touching) {
  1955. if (event.pageY <= pageYStart) {
  1956. event.preventDefault();
  1957. }
  1958. }
  1959. }
  1960. }
  1961. }, { passive: false });
  1962. document.body.addEventListener('touchstart', function (event) {
  1963. var owner = getScrollOwner(event.target);
  1964. if (owner) {
  1965. if ($(owner).scrollTop() == 0) {
  1966. touching = true;
  1967. pageYStart = event.pageY;
  1968. pageYOffset = event.pageY;
  1969. }
  1970. if ($(owner).scrollTop() + $(owner).height() == owner.scrollHeight) {
  1971. touching = true;
  1972. pageYStart = event.pageY;
  1973. pageYOffset = event.pageY;
  1974. }
  1975. }
  1976. }, { passive: false });
  1977. removeElasticScrollFromIframe();
  1978. $('html').css('-webkit-tap-highlight-color', 'transparent');
  1979. // Stop iOS from automatically scaling parts of the mobile player
  1980. // Could stop automatic scaling on Ipads as well that we actually want, but for now, seems fine
  1981. $('body').css('-webkit-text-size-adjust', '100%');
  1982. window.addEventListener("orientationchange", function () {
  1983. var viewport = document.querySelector("meta[name=viewport]");
  1984. //so iOS doesn't zoom when switching back to portrait
  1985. if (IOS) {
  1986. viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, viewport-fit=cover');
  1987. viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, viewport-fit=cover');
  1988. } else {
  1989. viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0');
  1990. viewport.setAttribute('content', 'width=device-width, initial-scale=1.0');
  1991. }
  1992. $axure.player.resizeContent();
  1993. }, false);
  1994. $axure.page.bind('load.start', function () {
  1995. $axure.player.resizeContent();
  1996. });
  1997. }
  1998. // Always append both mobile browser menu and native menu, as app might not have returned value signifying native at this point
  1999. appendNativePrototypeControlFrame();
  2000. appendMobileBrowserControlFrame();
  2001. appendProjectOptions();
  2002. }
  2003. initializeLogo();
  2004. initializePreview();
  2005. $axure.player.resizeContent(true);
  2006. $axure.messageCenter.postMessage('finishInit');
  2007. })();
  2008. });
  2009. function appendProjectOptions() {
  2010. var toAppend = '';
  2011. toAppend += '<div id="projectOptionsHost" class="mobileOnlyPanel mobileMode">';
  2012. toAppend += ' <div class="pluginNameHeader">PROJECT OPTIONS</div>';
  2013. toAppend += ' <div id="projectOptionsScrollContainer">';
  2014. toAppend += ' <div class="mobileSubHeader">Hotspots</div>';
  2015. toAppend += ' <div id="projectOptionsShowHotspots" class="mobileText projectOptionsHotspotsRow" style="border-bottom: solid 1px #c7c7c7">';
  2016. toAppend += ' <div id="projectOptionsHotspotsCheckbox"></div>';
  2017. toAppend += ' Show hotspots</div> ';
  2018. toAppend += ' <div class="mobileSubHeader" style="margin-top: 16px">Scale</div>';
  2019. toAppend += ' <div id="projectOptionsScaleContainer" class="mobileText"></div>';
  2020. toAppend += ' <div id="projectOptionsAdaptiveViewsHeader" class="mobileSubHeader" style="margin-top: 16px">Adaptive views</div>';
  2021. toAppend += ' <div id="projectOptionsAdaptiveViewsContainer" class="mobileText"></div>'
  2022. toAppend += ' </div>'
  2023. toAppend += '</div>';
  2024. $('#mHideSidebar').prepend(toAppend);
  2025. $(('#projectOptionsHost')).click(function (e) { e.stopPropagation(); });
  2026. if (isMobileMode()) $axure.player.resizeContent();
  2027. }
  2028. function appendMobileBrowserControlFrame() {
  2029. var toAppend = "";
  2030. toAppend += '<div id="mobileBrowserControlFrame" class="mobilePrototypeControlFrame">';
  2031. toAppend += ' <div id="return" style="width:100%; position:relative; top:-15px; float:left">';
  2032. toAppend += ' <div id="closeBackground" class="circleBackground">';
  2033. toAppend += ' <div id="forwardSlash" class="closeIconSlash"><div id="backwardSlash" class="closeIconSlash"></div></div>';
  2034. toAppend += ' </div>';
  2035. toAppend += ' </div>';
  2036. toAppend += '</div>';
  2037. $('#mobileControlFrameContainer').append(toAppend);
  2038. $('#closeBackground').click(collapse);
  2039. // iOS will do incorrect click position / content bounds calculation which results in scroll getting reset to (0, 0)
  2040. if (IOS) $('#mobileControlFrameContainer').on($axure.eventNames.mouseDownName, function (e) { e.stopPropagation(); });
  2041. }
  2042. function appendNativePrototypeControlFrame() {
  2043. var toAppend = "";
  2044. toAppend += '<div id="nativeAppControlFrame" class="mobilePrototypeControlFrame">';
  2045. toAppend += ' <ul id="nativeMenuBlueBackground">';
  2046. toAppend += ' <li style="width:30%; float:left;">';
  2047. toAppend += ' <div id="exit" class="nativePrototypeButton" >';
  2048. toAppend += ' <div>';
  2049. toAppend += ' <div id="exitIcon"></div>';
  2050. toAppend += ' <div id="exitText" class="nativeMenuText">Exit</div>';
  2051. toAppend += ' </div>';
  2052. toAppend += ' </div>';
  2053. toAppend += ' </li>';
  2054. toAppend += ' <li id="return" style="width:40%; position:relative; top:-15px; float:left">';
  2055. toAppend += ' <div id="returnBackground" class="circleBackground">';
  2056. toAppend += ' <div id="returnIcon"></div>';
  2057. toAppend += ' </div>';
  2058. toAppend += ' <div id="returnText" class="nativeMenuText">Return to Prototype</div>';
  2059. toAppend += ' </li>';
  2060. toAppend += ' <li style="width:30%; float:right;">';
  2061. toAppend += ' <div id="refresh" class="nativePrototypeButton" >';
  2062. toAppend += ' <div>';
  2063. toAppend += ' <div id="refreshIcon"></div>';
  2064. toAppend += ' <div id="refreshText" class="nativeMenuText">Refresh</div>';
  2065. toAppend += ' </div>';
  2066. toAppend += ' </div>';
  2067. toAppend += ' </li>';
  2068. toAppend += ' </ul>';
  2069. toAppend += '</div>';
  2070. $('#mobileControlFrameContainer').append(toAppend);
  2071. var barHeight = IOS ? '72px' : '60px';
  2072. var returnIconDisplacement = IOS ? '-15px': '-20px';
  2073. var iconTopMargin = IOS ? '14px': '7px';
  2074. var returnTextTopMargin = IOS ? '9px': '7px';
  2075. document.getElementById('nativeAppControlFrame').style.height = barHeight;
  2076. document.getElementById('nativeMenuBlueBackground').style.height = barHeight;
  2077. document.getElementById('return').style.top = returnIconDisplacement;
  2078. document.getElementById('returnText').style.marginTop = returnTextTopMargin;
  2079. document.getElementById('refreshIcon').style.marginTop = iconTopMargin;
  2080. document.getElementById('exitIcon').style.marginTop = iconTopMargin;
  2081. addAppButtonClickListener("exit");
  2082. addAppButtonClickListener("refresh");
  2083. $('#returnBackground').click(collapse);
  2084. $('#nativeAppControlFrame').on('touchmove', function (e) {
  2085. e.stopPropagation();
  2086. }, false);
  2087. }
  2088. function addAppButtonClickListener(id) {
  2089. var func = function () { IOS ? window.webkit.messageHandlers.prototypeMenuButtonClick.postMessage(id) : ShareApp.PrototypeMenuButtonClick(id); };
  2090. document.getElementById(id).addEventListener("click", func, false);
  2091. }
  2092. function toggleSitemap() {
  2093. $axure.player.showPlugin(1);
  2094. }
  2095. function closePopup() {
  2096. var $container = $('.popup');
  2097. $container.removeClass('popup');
  2098. $('#overflowMenuButton').removeClass('selected');
  2099. $('#scaleMenuButton').removeClass('selected');
  2100. $('#interfaceAdaptiveViewsContainer').removeClass('selected');
  2101. $container.hide();
  2102. $('div.splitterMask').unbind($axure.eventNames.mouseDownName, closePopup);
  2103. $('div.splitterMask').remove();
  2104. }
  2105. $axure.player.closePopup = closePopup;
  2106. function showPopup($container) {
  2107. if ($('#browserOutOfDateNotification').is(":visible")) return;
  2108. $container.addClass('popup');
  2109. $container.show();
  2110. $('<div class="splitterMask"></div>').insertAfter($container);
  2111. $('div.splitterMask').bind($axure.eventNames.mouseDownName, closePopup);
  2112. }
  2113. $axure.player.showPopup = showPopup;
  2114. function toggleAdaptiveViewsPopup() {
  2115. if (($('#interfaceAdaptiveViewsListContainer').hasClass('popup'))) {
  2116. closePopup();
  2117. } else {
  2118. $('#interfaceAdaptiveViewsContainer').addClass('selected');
  2119. var leftVal = $('#interfaceAdaptiveViewsContainer').offset().left;
  2120. $('#interfaceAdaptiveViewsListContainer').css('left', leftVal + 'px');
  2121. showPopup($('#interfaceAdaptiveViewsListContainer'));
  2122. }
  2123. }
  2124. function toggleOverflowMenuPopup() {
  2125. if (($('#overflowMenuContainer').hasClass('popup'))) {
  2126. closePopup();
  2127. } else {
  2128. $('#overflowMenuButton').addClass('selected');
  2129. showPopup($('#overflowMenuContainer'));
  2130. }
  2131. }
  2132. function toggleScaleMenuPopup() {
  2133. if (($('#scaleMenuContainer').hasClass('popup'))) {
  2134. closePopup();
  2135. } else {
  2136. $('#scaleMenuButton').addClass('selected');
  2137. $('.vpZoomValue').removeClass('selected');
  2138. $('.vpZoomValue[val="' + getCurrentZoom() + '"]').addClass('selected');
  2139. var rightVal = $(window).width() - $('#scaleMenuButton').offset().left - $('#scaleMenuButton').width() - 12;
  2140. $('#scaleMenuContainer').css('right', rightVal + 'px');
  2141. showPopup($('#scaleMenuContainer'));
  2142. }
  2143. }
  2144. $axure.player.toggleScaleMenuPopup = toggleScaleMenuPopup;
  2145. var startSplitX;
  2146. var startSplitWidth;
  2147. function startLeftSplit() {
  2148. startSplitX = window.event.pageX;
  2149. startSplitWidth = lastLeftPanelWidth;
  2150. var $left = $('#lsplitbar');
  2151. $left.addClass('active');
  2152. $('<div class="splitterMask"></div>').insertAfter($left);
  2153. $(document).bind($axure.eventNames.mouseMoveName, doLeftSplitMove).bind($axure.eventNames.mouseUpName, endLeftSplitMove);
  2154. }
  2155. function startRightSplit() {
  2156. startSplitX = window.event.pageX;
  2157. startSplitWidth = lastRightPanelWidth;
  2158. var $left = $('#rsplitbar');
  2159. $left.addClass('active');
  2160. $('<div class="splitterMask"></div>').insertAfter($left);
  2161. $(document).bind($axure.eventNames.mouseMoveName, doRightSplitMove).bind($axure.eventNames.mouseUpName, endRightSplitMove);
  2162. }
  2163. function doLeftSplitMove() {
  2164. var currentX = window.event.pageX;
  2165. var newWidth = Math.min(startSplitWidth + currentX - startSplitX, $(window).width() - $('.rightPanel').width(), $(window).width() - lastRightPanelWidthDefault);
  2166. lastLeftPanelWidth = Math.max(lastLeftPanelWidthDefault, newWidth);
  2167. $('.leftPanel').width(lastLeftPanelWidth ? lastLeftPanelWidth : lastLeftPanelWidthDefault);
  2168. $('#lsplitbar').css('left', $('.leftPanel').width() - 4);
  2169. $axure.player.updateClippingBoundsWidth();
  2170. $axure.player.refreshViewPort();
  2171. }
  2172. function doRightSplitMove() {
  2173. var currentX = window.event.pageX;
  2174. var newWidth = Math.min(startSplitWidth - currentX + startSplitX, $(window).width() - $('.leftPanel').width(), $(window).width() - lastLeftPanelWidthDefault);
  2175. lastRightPanelWidth = Math.max(lastRightPanelWidthDefault, newWidth);
  2176. $('.rightPanel').width(lastRightPanelWidth ? lastRightPanelWidth : lastRightPanelWidthDefault);
  2177. $('#rsplitbar').css('left', $(window).width() - $('.rightPanel').width());
  2178. $axure.player.updateClippingBoundsWidth();
  2179. $axure.player.refreshViewPort();
  2180. }
  2181. function endLeftSplitMove() {
  2182. $('div.splitterMask').remove();
  2183. var $left = $('#lsplitbar');
  2184. $left.removeClass('active');
  2185. $(document).unbind($axure.eventNames.mouseMoveName, doLeftSplitMove).unbind($axure.eventNames.mouseUpName, endLeftSplitMove);
  2186. setAdaptiveView()
  2187. }
  2188. function endRightSplitMove() {
  2189. $('div.splitterMask').remove();
  2190. var $left = $('#rsplitbar');
  2191. $left.removeClass('active');
  2192. $(document).unbind($axure.eventNames.mouseMoveName, doRightSplitMove).unbind($axure.eventNames.mouseUpName, endRightSplitMove);
  2193. setAdaptiveView()
  2194. }
  2195. var startMX;
  2196. var startMLeft;
  2197. var startMElement;
  2198. var maxMLeft;
  2199. var getMaxMLeft = function () {
  2200. if ($('.rightPanel.mobileMode').length == 0) return $('.leftPanel.mobileMode').last().position().left + 100;
  2201. return $('.rightPanel.mobileMode').last().position().left + 100;
  2202. }
  2203. function startM(e) {
  2204. // Android touch event does not define pageX directly
  2205. if(window.event.pageX) {
  2206. startMX = window.event.pageX;
  2207. } else {
  2208. startMX = window.event.touches[0].pageX;
  2209. }
  2210. startMElement = window.event.target.id;
  2211. var $m = $('#mHideSidebar');
  2212. startMLeft = Number($m.css('left').replace('px', ''));
  2213. $(document).bind($axure.eventNames.mouseMoveName, doMMove).bind($axure.eventNames.mouseUpName, endMMove);
  2214. // Must stop propagation on iOS; otherwise scroll position of content will be reset to (0, 0)
  2215. // (likely due to position of click being calculated as out of bounds for outerContainer -- iOS is not adding scroll offset to bounds)
  2216. if (IOS) { e.stopPropagation() };
  2217. }
  2218. function doMMove() {
  2219. var $m = $('#mHideSidebar');
  2220. if(window.event.pageX) {
  2221. currentX = window.event.pageX;
  2222. } else {
  2223. currentX = window.event.touches[0].pageX;
  2224. }
  2225. var deltaX = currentX - startMX;
  2226. if (Math.abs(deltaX) > 0 && $('.splitterMask').length == 0) {
  2227. $('<div class="splitterMask"></div>').insertAfter($m);
  2228. }
  2229. var newLeft = startMLeft + deltaX;
  2230. newLeft = Math.min(0, newLeft);
  2231. newLeft = Math.max(-getMaxMLeft(), newLeft);
  2232. $m.css('left', newLeft + 'px');
  2233. }
  2234. function endMMove(e) {
  2235. $('div.splitterMask').remove();
  2236. $(document).unbind($axure.eventNames.mouseMoveName, doMMove).unbind($axure.eventNames.mouseUpName, endMMove);
  2237. e.stopPropagation();
  2238. var $m = $('#mHideSidebar');
  2239. if(window.event.pageX) {
  2240. currentX = window.event.pageX;
  2241. } else {
  2242. currentX = window.event.changedTouches[0].pageX;
  2243. }
  2244. var deltaX = currentX - startMX;
  2245. if (deltaX != 0 || startMElement != 'mHideSidebar') {
  2246. adjustM(currentX < startMX ? 'left' : 'right', true);
  2247. }
  2248. }
  2249. function adjustM(direction, animate) {
  2250. var $m = $('#mHideSidebar');
  2251. var duration = animate ? 100 : 0;
  2252. var newLeft = Number($m.css('left').replace('px', ''));
  2253. if (!$m.is(':visible') || newLeft > -100) {
  2254. $m.animate({ 'left': '-60px' }, duration);
  2255. } else if (newLeft < -getMaxMLeft() + 100) {
  2256. $m.animate({ 'left': (-getMaxMLeft() + 125) + 'px' }, duration);
  2257. } else if (direction == 'left') {
  2258. var handled = false;
  2259. var $panels = $('.rightPanel.mobileMode, .leftPanel.mobileMode');
  2260. $panels.each(function () {
  2261. var panelX = $(this).position().left;
  2262. if (panelX > -newLeft) {
  2263. $m.animate({ 'left': (-panelX + 25) + 'px' }, duration);
  2264. handled = true;
  2265. return false;
  2266. }
  2267. });
  2268. if (!handled) {
  2269. $m.animate({ 'left': (-$panels.last().position().left + 25) + 'px' }, duration);
  2270. }
  2271. } else if (direction == 'right') {
  2272. var handled = false;
  2273. var $panels = $('.rightPanel.mobileMode, .leftPanel.mobileMode');
  2274. $($panels.get().reverse()).each(function () {
  2275. var panelRight = $(this).position().left + $(this).width();
  2276. if (panelRight < -newLeft + $(window).width()) {
  2277. $m.animate({ 'left': (-$(this).position().left + 25) + 'px' }, duration);
  2278. handled = true;
  2279. return false;
  2280. }
  2281. });
  2282. if (!handled) {
  2283. $m.animate({ 'left': '-60px' }, duration);
  2284. }
  2285. }
  2286. }
  2287. function repositionPinsOnScaleChange(data) {
  2288. var $pins = $('#existingPinsOverlay').children();
  2289. for (var i = 0; i < $pins.length; i++) {
  2290. // calculate new position of pin
  2291. const left = parseFloat($($pins[i]).attr('data-x'));
  2292. const top = parseFloat($($pins[i]).attr('data-y'));
  2293. const width = $($pins[i]).width();
  2294. const height = $($pins[i]).height();
  2295. // Get current scale of mainPanelContainer
  2296. // MainPanelContainer scaled without setContentScale message
  2297. var scale = $('#mainPanelContainer').css('transform');
  2298. scale = (scale == "none") ? 1 : Number(scale.substring(scale.indexOf('(') + 1, scale.indexOf(',')));
  2299. const scaledLeft = (left * scale) - (width / 2);
  2300. const scaledTop = (top * scale) - (height / 2);
  2301. $($pins[i]).css('left', scaledLeft + 'px');
  2302. $($pins[i]).css('top', scaledTop + 'px');
  2303. }
  2304. // Distance from left of project content to origin (used for pins positioning when on a centered page in Scale to Fit mode)
  2305. if (typeof data.contentOriginOffset !== "undefined") contentLeftOfOriginOffset = data.contentOriginOffset;
  2306. }
  2307. function messageCenter_message(message, data) {
  2308. if (message == 'expandFrame') expand();
  2309. else if (message == 'getCollapseFrameOnLoad' && $axure.player.settings.startCollapsed && !MOBILE_DEVICE) $axure.messageCenter.postMessage('collapseFrameOnLoad');
  2310. else if (message == 'tripleClick') {
  2311. if ($axure.player.isMobileMode() || MOBILE_DEVICE) expand();
  2312. } else if (message == 'setContentScale') {
  2313. var resultScale = data.scaleN;
  2314. if (data.clipToView) {
  2315. var scaleVal = $('.vpScaleOption').find('.selectedRadioButton').parent().attr('val');
  2316. if (scaleVal == '2' || (!MOBILE_DEVICE && scaleVal == '0')) {
  2317. var scaleN = $('#mainPanel').width() / data.viewportWidth;
  2318. var hScaleN = ($('#mainPanel').height()) / data.viewportHeight;
  2319. if (hScaleN < scaleN) scaleN = hScaleN;
  2320. if (scaleVal == '0') scaleN = Math.min(1, scaleN);
  2321. resultScale = scaleN;
  2322. var scale = 'scale(' + scaleN + ')';
  2323. $('#mainPanelContainer').css({
  2324. 'transform': scale,
  2325. 'transformOrigin': ''
  2326. });
  2327. $('#mainFrame').height(data.mainFrameHeight);
  2328. } else {
  2329. var scale = 'scale(' + data.scaleN + ')';
  2330. $('#mainPanelContainer').css({
  2331. 'transform': scale,
  2332. 'transformOrigin': Number($('#mainPanelContainer').css('width').replace('px', '')) / 2 + 'px 0px',
  2333. });
  2334. var mainPanelHeight = Number($('#mainPanel').css('height').replace('px', ''));
  2335. var mainPanelContainerHeight = Number($('#mainPanelContainer').css('height').replace('px', ''));
  2336. var height = (mainPanelHeight / data.scaleN > mainPanelContainerHeight ? mainPanelContainerHeight : mainPanelHeight / data.scaleN);
  2337. var y = (mainPanelHeight - (mainPanelHeight > mainPanelContainerHeight * data.scaleN ? mainPanelContainerHeight * data.scaleN : mainPanelHeight)) / 2;
  2338. $('#mainPanelContainer').css("top", y);
  2339. height += 'px';
  2340. $('#clipFrameScroll').height(height);
  2341. $('#mainFrame').height(height);
  2342. var mainPanelWidth = Number($('#mainPanel').css('width').replace('px', ''));
  2343. var mainPanelContainerWidth = Number($('#mainPanelContainer').css('width').replace('px', ''));
  2344. var width = mainPanelWidth / data.scaleN > mainPanelContainerWidth ? mainPanelContainerWidth : mainPanelWidth / data.scaleN;
  2345. var x = (mainPanelContainerWidth - (mainPanelWidth / data.scaleN > mainPanelContainerWidth ? mainPanelContainerWidth : mainPanelWidth / data.scaleN)) / 2;
  2346. $('#mainPanelContainer').css("left", x* data.scaleN);
  2347. width += 'px';
  2348. $('#clipFrameScroll').width(width);
  2349. $('#mainFrame').width(width);
  2350. }
  2351. } else {
  2352. if (data.scaleN != 1) {
  2353. var scale = 'scale(' + data.scaleN + ')';
  2354. var width = 100 / data.scaleN + '%';
  2355. var height = Number($('#mainPanelContainer').css('height').replace('px', '')) / data.scaleN + 'px';
  2356. $('#mainPanelContainer').css({
  2357. 'transform': scale,
  2358. 'transformOrigin': '0px 0px',
  2359. 'width': width,
  2360. 'height': height
  2361. });
  2362. $('#clipFrameScroll').height(height);
  2363. $('#mainFrame').height(height);
  2364. } else {
  2365. $('#mainFrame').height(data.mainFrameHeight);
  2366. $('#mainPanelContainer').width('100%');
  2367. }
  2368. }
  2369. var scaleValue = Math.round(resultScale * 100, 0);
  2370. var scaleValueText = scaleValue + "%";
  2371. if (forcePanZoomDisabled) {
  2372. scaleValueText = 'Scale';
  2373. } else {
  2374. getIframeHtml().attr("zoom", scaleValue);
  2375. $axure.messageCenter.postMessage("cloud_SetPageScale", { scale: resultScale });
  2376. }
  2377. $("#scaleValue").text(scaleValueText);
  2378. repositionPinsOnScaleChange(data);
  2379. repositionClippingBoundsScroll();
  2380. // Fix for edge not redrawing content after scale change
  2381. if ($axure.browser.isEdge) {
  2382. newHeight = window.innerHeight - ((!isMobileMode() && $('#topPanel').is(':visible')) ? $('#topPanel').height() : 0);
  2383. newWidth = $(window).width();
  2384. $('#outerContainer').height(newHeight).width(newWidth);
  2385. $('#mainPanel').height(newHeight);
  2386. $('#clippingBounds').height(newHeight);
  2387. }
  2388. }
  2389. }
  2390. function loadVariablesFromUrl(removeVarFromUrl) {
  2391. let originalQueryValues = window.location.href.substr(window.location.href.indexOf('?')) || '';
  2392. let variables = {};
  2393. const query = (originalQueryValues.split(GLOBAL_VAR_NAME)[1] || '');
  2394. if (query.length > 0) {
  2395. $axure.utils.parseGlobalVars(query, function (varName, varValue) {
  2396. variables[varName] = varValue;
  2397. });
  2398. if (removeVarFromUrl) {
  2399. originalQueryValues = originalQueryValues.replace(GLOBAL_VAR_NAME, "").replace(query, "");
  2400. replaceHash(originalQueryValues);
  2401. }
  2402. }
  2403. return variables;
  2404. }
  2405. function getInitialUrl() {
  2406. var shortId = getHashStringVar(PAGE_ID_NAME);
  2407. var foundById = [];
  2408. if (shortId.length > 0) {
  2409. getPageUrlsById(shortId, foundById, undefined);
  2410. if (foundById.length == 1) return foundById[0];
  2411. }
  2412. var pageName = getHashStringVar(PAGE_URL_NAME);
  2413. if (pageName.length > 0) return pageName + ".html";
  2414. else {
  2415. if (foundById.length > 0) return foundById[0];
  2416. var url = getFirstPageUrl($axure.document.sitemap.rootNodes);
  2417. return (url ? url : "about:blank");
  2418. }
  2419. }
  2420. var getPageUrlsById = $axure.player.getPageUrlsById = function (packageId, foundById, nodes) {
  2421. if (!nodes) nodes = $axure.document.sitemap.rootNodes;
  2422. for (var i = 0; i < nodes.length; i++) {
  2423. var node = nodes[i];
  2424. if (node.id == packageId) foundById.push(node.url);
  2425. var hasChildren = (node.children && node.children.length > 0);
  2426. if (hasChildren) {
  2427. getPageUrlsById(packageId, foundById, node.children);
  2428. }
  2429. }
  2430. }
  2431. var getPageIdByUrl = $axure.player.getPageIdByUrl = function(url, nodes) {
  2432. if (!nodes) nodes = $axure.document.sitemap.rootNodes;
  2433. for (var i = 0; i < nodes.length; i++) {
  2434. var node = nodes[i];
  2435. if (node.url == url) return node.id;
  2436. else {
  2437. var hasChildren = (node.children && node.children.length > 0);
  2438. if (hasChildren) {
  2439. var id = getPageIdByUrl(url, node.children);
  2440. if (id) return id;
  2441. }
  2442. }
  2443. }
  2444. return null;
  2445. }
  2446. function getFirstPageUrl(nodes) {
  2447. for (var i = 0; i < nodes.length; i++) {
  2448. var node = nodes[i];
  2449. if (node.url) return node.url;
  2450. else {
  2451. var hasChildren = (node.children && node.children.length > 0);
  2452. if (hasChildren) {
  2453. var url = getFirstPageUrl(node.children);
  2454. if (url) return url;
  2455. }
  2456. }
  2457. }
  2458. return null;
  2459. }
  2460. function closePlayer() {
  2461. if ($axure.page.location) window.location.href = $axure.page.location;
  2462. else {
  2463. var pageFile = getInitialUrl();
  2464. var currentLocation = window.location.toString();
  2465. window.location.href = currentLocation.substr(0, currentLocation.lastIndexOf("/") + 1) + pageFile;
  2466. }
  2467. }
  2468. function replaceHash(newQuery) {
  2469. var currentLocWithoutQuery = window.location.toString().split('?')[0];
  2470. //We use replace so that every hash change doesn't get appended to the history stack.
  2471. //We use replaceState in browsers that support it, else replace the location
  2472. if (typeof window.history.replaceState != 'undefined') {
  2473. try {
  2474. //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.
  2475. //try catch breaks the url adjusting nicely when the sitemap is open, but all interactions and forward and back buttons work.
  2476. //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'.
  2477. window.history.replaceState(null, null, currentLocWithoutQuery + newQuery);
  2478. } catch (ex) { }
  2479. } else {
  2480. window.location.replace(currentLocWithoutQuery + newQuery);
  2481. }
  2482. }
  2483. function collapse() {
  2484. if (IOS) {
  2485. $('body').off('touchstart');
  2486. $('body').off('touchend');
  2487. }
  2488. if ($axure.player.isMobileMode()) {
  2489. $('#mHideSidebar').hide();
  2490. $('#nativeAppControlFrame').hide();
  2491. $('#mobileBrowserControlFrame').hide();
  2492. } else {
  2493. $axure.player.deleteVarFromCurrentUrlHash('g');
  2494. $axure.player.setVarInCurrentUrlHash('c', 1);
  2495. if (!MOBILE_DEVICE) $('#maximizePanelContainer').show();
  2496. lastLeftPanelWidth = $('.leftPanel').width();
  2497. lastRightPanelWidth = $('.rightPanel').width();
  2498. $('.leftPanel').hide();
  2499. $('.rightPanel').hide();
  2500. $('#topPanel').hide();
  2501. $('.splitbar').hide();
  2502. $('#mainPanel').width($(window).width());
  2503. $('#clippingBounds').width($(window).width());
  2504. $('#clippingBounds').css('left', '0px');
  2505. $(window).resize();
  2506. $(document).trigger('sidebarCollapse');
  2507. $('#maximizeButton').addClass('rotated');
  2508. }
  2509. }
  2510. function expand() {
  2511. if ($axure.player.isMobileMode()) {
  2512. $('#mHideSidebar').show();
  2513. $('#mobileControlFrameContainer').show();
  2514. $axure.utils.isShareApp() ? $('#nativeAppControlFrame').show() : $('#mobileBrowserControlFrame').show();
  2515. } else {
  2516. $minimizeContainer = $('#interfaceControlFrameMinimizeContainer');
  2517. $minimizeContainer.removeClass('collapseHovered');
  2518. $axure.player.deleteVarFromCurrentUrlHash('c');
  2519. $('#maximizeButton').removeClass('rotated');
  2520. $('#maximizePanelContainer').hide();
  2521. $axure.player.restorePlugins();
  2522. $('#topPanel').show();
  2523. $(window).resize();
  2524. $(document).trigger('sidebarExpanded');
  2525. }
  2526. }
  2527. function mainFrame_onload() {
  2528. if ($axure.page.pageName) document.title = $axure.page.pageName;
  2529. }
  2530. function getQueryString(query) {
  2531. var qstring = self.location.href.split("?");
  2532. if (qstring.length < 2) return "";
  2533. return GetParameter(qstring, query);
  2534. }
  2535. function GetParameter(qstring, query) {
  2536. var prms = qstring[1].split("&");
  2537. var frmelements = new Array();
  2538. var currprmeter, querystr = "";
  2539. for (var i = 0; i < prms.length; i++) {
  2540. currprmeter = prms[i].split("=");
  2541. frmelements[i] = new Array();
  2542. frmelements[i][0] = currprmeter[0];
  2543. frmelements[i][1] = currprmeter[1];
  2544. }
  2545. for (j = 0; j < frmelements.length; j++) {
  2546. if (frmelements[j][0].toLowerCase() == query.toLowerCase()) {
  2547. querystr = frmelements[j][1];
  2548. break;
  2549. }
  2550. }
  2551. return querystr;
  2552. }
  2553. $axure.player.setVarInCurrentUrlHash = function (varName, varVal) {
  2554. var newQuery = $axure.utils.setHashStringVar(window.location.search, varName, varVal);
  2555. if (newQuery != null) {
  2556. replaceHash(newQuery);
  2557. }
  2558. }
  2559. function deleteHashStringVar(currentQuery, varName) {
  2560. var varWithEqual = varName + '=';
  2561. var pageIndex = currentQuery.indexOf('?' + varWithEqual);
  2562. if (pageIndex == -1) pageIndex = currentQuery.indexOf('&' + varWithEqual);
  2563. if (pageIndex != -1) {
  2564. var newQuery = currentQuery.substring(0, pageIndex);
  2565. var ampIndex = currentQuery.indexOf('&', pageIndex + 1);
  2566. //IF begin of string....if none blank, ELSE # instead of & and rest
  2567. //IF in string....prefix + if none blank, ELSE &-rest
  2568. if (newQuery == '') { //beginning of string
  2569. newQuery = ampIndex != -1 ? '?' + currentQuery.substring(ampIndex + 1) : '';
  2570. } else { //somewhere in the middle
  2571. newQuery = newQuery + (ampIndex != -1 ? currentQuery.substring(ampIndex) : '');
  2572. }
  2573. return newQuery;
  2574. }
  2575. return null;
  2576. }
  2577. $axure.player.deleteVarFromCurrentUrlHash = function (varName) {
  2578. var newQuery = deleteHashStringVar(window.location.search, varName);
  2579. if (newQuery != null) {
  2580. replaceHash(newQuery);
  2581. }
  2582. };
  2583. function setUpController() {
  2584. //$axure.utils = _axUtils;
  2585. var _page = {};
  2586. $axure.page = _page;
  2587. $axure.utils.makeBindable(_page, ['load']);
  2588. var _player = function () {
  2589. };
  2590. $axure.player = _player;
  2591. //-----------------------------------------
  2592. //Global Var array, getLinkUrl function and setGlobalVar listener are
  2593. //for use in setting global vars in page url string when clicking a
  2594. //page in the sitemap
  2595. //NEW: this is now also used when navigating to a new window/popup,
  2596. //if there are global variables on the urls
  2597. //-----------------------------------------
  2598. var _globalVars = loadVariablesFromUrl(true);
  2599. var _getLinkUrl = function (baseUrl) {
  2600. var toAdd = '';
  2601. for (var globalVarName in _globalVars) {
  2602. var val = _globalVars[globalVarName];
  2603. if (val != null) {
  2604. if (toAdd.length > 0) toAdd += '&';
  2605. toAdd += globalVarName + '=' + encodeURIComponent(val);
  2606. }
  2607. }
  2608. return toAdd.length > 0 ? baseUrl + '?' + toAdd + "&CSUM=1" : baseUrl;
  2609. };
  2610. $axure.getLinkUrlWithVars = _getLinkUrl;
  2611. $axure.messageCenter.addMessageListener(function (message, data) {
  2612. if (message == 'setGlobalVar') {
  2613. _globalVars[data.globalVarName] = data.globalVarValue;
  2614. }
  2615. });
  2616. $axure.messageCenter.addStateListener('page.data', function (key, value) {
  2617. for (var subKey in value) {
  2618. _page[subKey] = value[subKey];
  2619. }
  2620. $axure.page.triggerEvent('load');
  2621. });
  2622. // ---------------------------------------------
  2623. // Navigates the main frame (setting the currently visible page). If the link is relative,
  2624. // this method should test if it is actually a axure rp page being loaded and properly set
  2625. // up all the controller for the page if it is
  2626. // ---------------------------------------------
  2627. _page.navigate = function (url, includeVariables) {
  2628. var mainFrame = document.getElementById("mainFrame");
  2629. //var mainFrame = window.parent.mainFrame;
  2630. // if this is a relative url...
  2631. var urlToLoad;
  2632. if (url.indexOf(':') < 0 || url[0] == '/') {
  2633. var winHref = window.location.href;
  2634. var page = winHref.substring(0, winHref.lastIndexOf('/') + 1) + url;
  2635. urlToLoad = page;
  2636. } else {
  2637. urlToLoad = url;
  2638. }
  2639. if (!includeVariables) {
  2640. mainFrame.contentWindow.location.href = urlToLoad;
  2641. return;
  2642. }
  2643. var urlWithVars = $axure.getLinkUrlWithVars(urlToLoad);
  2644. mainFrame.contentWindow.location.href = urlWithVars;
  2645. // update the URL string immediately when the page changes so user doesn't have to wait for the page to load. RP-2895
  2646. $axure.player.setVarInCurrentUrlHash(PAGE_ID_NAME, getPageIdByUrl(url));
  2647. $axure.player.setVarInCurrentUrlHash(PAGE_URL_NAME, url.substring(0, url.lastIndexOf('.html')));
  2648. };
  2649. var pluginIds = [];
  2650. var plugins = {};
  2651. var currentVisibleHostId = {};
  2652. // ---------------------------------------------
  2653. // Adds a tool box frame from a url to the interface. This is useful for loading plugins
  2654. // settings is an object that supports the following properties:
  2655. // - id : the id of the element for the plugin
  2656. // - context : the context to create the plugin host for
  2657. // - title : the user-visible caption for the plugin
  2658. // ---------------------------------------------
  2659. _player.createPluginHost = function (settings) {
  2660. if (!settings.context || !(settings.context === 'project' || settings.context === 'inspect')) {
  2661. //throw ('unknown context type');
  2662. return false;
  2663. }
  2664. if (settings.id == 'feedbackHost')
  2665. $('#overflowMenuContainer').prepend('<div id="showCommentsOption" class="showOption" style="order: 2"><div class="overflowOptionCheckbox"></div>Show comments</div>');
  2666. if (!settings.id) throw ('each plugin host needs an id');
  2667. if (typeof PREVIEW_INFO === 'undefined') {
  2668. // Share-Hosted Prototype
  2669. if (settings.id == 'debugHost') { return false; }
  2670. if (settings.id == 'handoffHost') { $('#handoffControlFrameHeaderContainer').show(); }
  2671. } else {
  2672. // Preview Mode
  2673. if (settings.id == 'handoffHost') { return false; }
  2674. }
  2675. pluginIds[pluginIds.length] = settings.id;
  2676. plugins[settings.id] = settings;
  2677. var hostContainerId = settings.context + 'ControlFrameHostContainer';
  2678. hostContainerId = _player.isMobileMode() ? 'mHideSidebar' : 'outerContainer';
  2679. var panelClass = 'rightPanel';
  2680. var host;
  2681. if (settings.context == 'project') {
  2682. panelClass = 'leftPanel';
  2683. if (_player.isMobileMode() && $('#' + hostContainerId).find('#projectOptionsHost').length > 0) {
  2684. host = $('<div id="' + settings.id + '" class="' + panelClass + '"></div>')
  2685. .insertAfter('#projectOptionsHost');
  2686. } else {
  2687. host = $('<div id="' + settings.id + '" class="' + panelClass + '"></div>')
  2688. .prependTo('#' + hostContainerId);
  2689. }
  2690. } else {
  2691. if (!$('#separatorContainer').hasClass('hasLeft')) $('#separatorContainer').addClass('hasLeft');
  2692. var closeButtonContainer = settings.id == 'feedbackHost' ? $('<div class="closeButtonContainerFb"></div>') : $('<div class="closeButtonContainer"></div>');
  2693. var closeButton = $('<button></button>');
  2694. closeButton.on('click', function () {
  2695. $axure.player.pluginClose(settings.id);
  2696. });
  2697. closeButton.appendTo(closeButtonContainer);
  2698. host = $('<div id="' + settings.id + '" class="' + panelClass + '"></div>');
  2699. closeButtonContainer.appendTo(host);
  2700. host.appendTo('#' + hostContainerId);
  2701. }
  2702. $(('#' + settings.id)).click(function (e) { e.stopPropagation(); });
  2703. var controlContainerId = getControlContainerId(settings.id);
  2704. if (!_player.isMobileMode()) host.hide();
  2705. else _player.updatePlugins();
  2706. // TODO: border radius in ie and edge causes image to be blurry (for now, just remove border-radius)
  2707. var style = (IE || $axure.browser.isEdge) ? '" style="border-radius: 0': '';
  2708. var headerLink = $('<a pluginId="' + settings.id + '" title="' + settings.title + style + '" >' + (settings.context === 'inspect' ? ('<span>' + '</span>'): '&nbsp;') + '</a>');
  2709. headerLink.mousedown($axure.utils.curry(interfaceControlHeaderButton_click, settings.id)).wrap('<li id="' + settings.id + 'Btn"' + (settings.id == "handoffHost" ? ' style="display: none"' : '') + '>');
  2710. headerLink.parent().appendTo('#' + controlContainerId);
  2711. if (_player.isMobileMode()) $axure.player.resizeContent();
  2712. $(document).trigger('pluginCreated', [settings.gid]);
  2713. };
  2714. var getControlContainerId = function (id) {
  2715. return plugins[id].context + 'ControlFrameHeader';
  2716. }
  2717. var getVisiblePlugins = function () {
  2718. var ids = '';
  2719. for (var id in plugins) {
  2720. var context = plugins[id].context;
  2721. if (currentVisibleHostId[context] == id) {
  2722. ids += plugins[id].gid;
  2723. }
  2724. }
  2725. return ids;
  2726. }
  2727. _player.pluginVisibleChanged = function(hostId, visible) {
  2728. if (plugins[hostId]) {
  2729. $axure.messageCenter.postMessage('pluginVisibleChanged', { id: hostId, gid: plugins[hostId].gid, visible: visible });
  2730. }
  2731. }
  2732. var interfaceControlHeaderButton_click = function (id) {
  2733. if (_player.isAnimating) { return; }
  2734. $axure.player.closePopup();
  2735. var controlContainerId = getControlContainerId(id);
  2736. var context = plugins[id].context;
  2737. var clickedPlugin = $('#' + controlContainerId + ' a[pluginId=' + id + ']');
  2738. if (currentVisibleHostId[context] == id) {
  2739. clickedPlugin.removeClass('selected');
  2740. if (id == "sitemapHost") { $('#sitemapControlFrameContainer').removeClass('selected'); }
  2741. currentVisibleHostId[context] = -1;
  2742. _player.collapseToBar(context, id);
  2743. $(document).trigger('pluginShown', [getVisiblePlugins()]);
  2744. } else {
  2745. $('#' + controlContainerId + ' a').removeClass('selected');
  2746. clickedPlugin.addClass('selected');
  2747. if (id == "sitemapHost") { $('#sitemapControlFrameContainer').addClass('selected'); }
  2748. $('#' + currentVisibleHostId[context]).hide();
  2749. $axure.player.pluginVisibleChanged(currentVisibleHostId[context], false);
  2750. currentVisibleHostId[context] = id;
  2751. _player.expandFromBar(id, context);
  2752. $(document).trigger('pluginShown', [getVisiblePlugins()]);
  2753. $axure.messageCenter.postMessage('openPlugin', id);
  2754. }
  2755. };
  2756. _player.pluginClose = function (id) {
  2757. var controlContainerId = getControlContainerId(id);
  2758. var context = plugins[id].context;
  2759. var clickedPlugin = $('#' + controlContainerId + ' a[pluginId=' + id + ']');
  2760. if (!clickedPlugin.hasClass('selected')) { return; }
  2761. clickedPlugin.removeClass('selected');
  2762. currentVisibleHostId[context] = -1;
  2763. _player.collapseToBar(context, id);
  2764. $(document).trigger('pluginShown', [getVisiblePlugins()]);
  2765. };
  2766. _player.showPlugin = function (gid) {
  2767. for (var id in plugins) {
  2768. if (plugins[id].gid == gid) {
  2769. interfaceControlHeaderButton_click(id);
  2770. break;
  2771. }
  2772. }
  2773. };
  2774. _player.restorePlugins = function () {
  2775. var selectedPluginsCount = 0;
  2776. for (var id in plugins) {
  2777. var clickedPlugin = $('#' + getControlContainerId(id) + ' a[pluginId=' + id + ']');
  2778. if (clickedPlugin.hasClass('selected')) selectedPluginsCount++;
  2779. }
  2780. if ($axure.player.settings.isAxshare && selectedPluginsCount != 0) $('#clippingBoundsScrollContainer').hide();
  2781. var selectedPluginsSeen = 0;
  2782. for (var id in plugins) {
  2783. var controlContainerId = getControlContainerId(id);
  2784. var context = plugins[id].context;
  2785. var clickedPlugin = $('#' + controlContainerId + ' a[pluginId=' + id + ']');
  2786. if (clickedPlugin.hasClass('selected')) {
  2787. //_player.showPlugin(id);
  2788. // TODO: handoffHost would need center inspect icon highlighted and rightFrameIcon set to visible
  2789. //if (id == 'handoffHost') { }
  2790. //$('#' + id).show();
  2791. selectedPluginsSeen++;
  2792. _player.expandFromBar(id, context, selectedPluginsCount == selectedPluginsSeen);
  2793. } else {
  2794. $('#' + id).hide();
  2795. }
  2796. }
  2797. $(document).trigger('pluginShown', [getVisiblePlugins()]);
  2798. };
  2799. _player.navigateToIssue = function (issueId) {
  2800. if (typeof feedback !== 'undefined') {
  2801. feedback.navigateToIssue(issueId);
  2802. }
  2803. };
  2804. _player.isPanZoomEnabled = function () {
  2805. return !forcePanZoomDisabled;
  2806. }
  2807. _player.handleKeyboardEvent = function (eventName) {
  2808. switch (eventName) {
  2809. case 'ctrlOrCmdPlus':
  2810. zoomIn();
  2811. break;
  2812. case 'ctrlOrCmdMinus':
  2813. zoomOut();
  2814. break;
  2815. case 'ctrlOrCmdZero':
  2816. dropScaleAndZoomPage(100);
  2817. break;
  2818. case 'spaceBarDown':
  2819. toggleDragMode(true);
  2820. break;
  2821. case 'spaceBarUp':
  2822. toggleDragMode(false);
  2823. break
  2824. default:
  2825. break;
  2826. }
  2827. }
  2828. }
  2829. $axure.player.hideAllPlayerControllers = function(isVisible) {
  2830. // TOOD: Verify that the containers are set to the right state after re-enabling them
  2831. if(isVisible) {
  2832. $('#topPanel').css('display', '');
  2833. $('#popupContainer').css('display', '');
  2834. $('#maximizePanelContainer').css('display', '');
  2835. $('#mobileControlFrameContainer').css('display', '');
  2836. } else {
  2837. $('#topPanel').hide();
  2838. $('#popupContainer').hide();
  2839. $('#maximizePanelContainer').hide(); // TODO: This needs to have a function where it prevents itself from showing up externally
  2840. $('#mobileControlFrameContainer').hide();
  2841. }
  2842. }
  2843. // TODO: General function to add bezels/overlays if applicable
  2844. $axure.player.addDeviceFraming = function (project, isEdit) {
  2845. // Temporary
  2846. var devices = {
  2847. iPhone8: 0,
  2848. iPhone8Plus: 1,
  2849. iPhoneSE: 2,
  2850. iPhoneX: 3,
  2851. iPad4: 4,
  2852. GalaxyS8: 5,
  2853. Pixel2: 6,
  2854. Pixel2XL: 7,
  2855. Mobile: 8,
  2856. Tablet9: 9,
  2857. Tablet7: 10,
  2858. Custom: 11,
  2859. Web: 12
  2860. };
  2861. // TODO: Need to bring over some platform functionality -> function might not be present
  2862. if (!$axure.player.settings.isExpo || project.Platform.Device === 12) { return; }
  2863. // TODO: Generate html for overlay and bezel containers
  2864. // TODO: Determine if preview player or full prototype player to establish where containers will be stored
  2865. var currDevice = project.Platform.Device;
  2866. var rootPath = '../../Scripts/Expo/StaticContent/resources/images/mobile/';
  2867. var framePath, overlayPath;
  2868. var $overlayParent = $(window.parent.parent.document).find('#previewPlayerDiv');
  2869. $overlayParent = isEdit && $overlayParent.length !== 0 ? $overlayParent : $('#mainPanelContainer');
  2870. $overlayParent.css('overflow', 'visible');
  2871. // TODO: Import enum of Device types -> import via TS definitions. WILL NEED TO REMEMBER THAT WE NEED TO SYNC SERVER AND CLIENT SIDE
  2872. // TODO: Create mapping of required images to device type
  2873. // images will be stored in ../../images/mobile
  2874. // TODO: Manage resizing
  2875. // TODO: Manage pointer clicks
  2876. // TODO: Status bar -> Default or via settings
  2877. // TODO: Establish img paths
  2878. switch (currDevice) {
  2879. case devices.iPhone8:
  2880. case devices.iPhone8Plus:
  2881. framePath = rootPath + 'iphone.svg';
  2882. overlayPath = "";
  2883. break;
  2884. case devices.iPhoneSE:
  2885. break;
  2886. case devices.iPhoneX:
  2887. framePath = "";
  2888. overlayPath = "";
  2889. break;
  2890. case devices.iPad4:
  2891. break;
  2892. case devices.Pixel2:
  2893. break;
  2894. case devices.Pixel2XL:
  2895. break;
  2896. case devices.GalaxyS8:
  2897. break;
  2898. case devices.Mobile:
  2899. case devices.Tablet7:
  2900. case devices.Tablet9:
  2901. case devices.Custom:
  2902. default:
  2903. break;
  2904. }
  2905. // TODO: Append images
  2906. // TODO: Position and initial dimensions
  2907. // TODO: Add resize handlers (?)
  2908. // TODO: Add pointer event handers (?)
  2909. if (framePath != undefined) {
  2910. $overlayParent.prepend(genFrameContainer());
  2911. var $fContainer = $overlayParent.find('#deviceFrameContainer');
  2912. var $frame = $fContainer.find('#deviceFrame');
  2913. $frame.css('background-image', "url('" + framePath + "')");
  2914. $frame.css('height', '');
  2915. $frame.css('width', '');
  2916. $frame.css('top', '');
  2917. $frame.css('left', '');
  2918. if(isEdit) {
  2919. $fContainer.css('z-index', -1);
  2920. }
  2921. }
  2922. if (overlayPath != undefined) {
  2923. // TODO: Update for edit mode
  2924. // $overlayParent.append(genOverlayContainer());
  2925. var $oContainer = $overlayParent.find('#deviceOverlayContainer');
  2926. var $overlay = $oContainer.find('#deviceOverlay');
  2927. $overlay.css('background-image', "url('" + overlayPath + "')");
  2928. }
  2929. }
  2930. function genFrameContainer(bezelPath) {
  2931. var container = [
  2932. '<div id="deviceFrameContainer">',
  2933. ' <div id="deviceFrame">',
  2934. ' </div>',
  2935. '</div>'
  2936. ].join("");
  2937. return container;
  2938. }
  2939. })();