startPre.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952
  1. // 8.0.0.3372. Generated 2/5/2018 11:05:16 PM UTC
  2. //***** splitter.js *****//
  3. /*
  4. * jQuery.splitter.js - two-pane splitter window plugin
  5. *
  6. * version 1.51 (2009/01/09)
  7. *
  8. * Dual licensed under the MIT and GPL licenses:
  9. * http://www.opensource.org/licenses/mit-license.php
  10. * http://www.gnu.org/licenses/gpl.html
  11. */
  12. /**
  13. * The splitter() plugin implements a two-pane resizable splitter window.
  14. * The selected elements in the jQuery object are converted to a splitter;
  15. * each selected element should have two child elements, used for the panes
  16. * of the splitter. The plugin adds a third child element for the splitbar.
  17. *
  18. * For more details see: http://methvin.com/splitter/
  19. *
  20. *
  21. * @example $('#MySplitter').splitter();
  22. * @desc Create a vertical splitter with default settings
  23. *
  24. * @example $('#MySplitter').splitter({type: 'h', accessKey: 'M'});
  25. * @desc Create a horizontal splitter resizable via Alt+Shift+M
  26. *
  27. * @name splitter
  28. * @type jQuery
  29. * @param Object options Options for the splitter (not required)
  30. * @cat Plugins/Splitter
  31. * @return jQuery
  32. * @author Dave Methvin (dave.methvin@gmail.com)
  33. */
  34. ;(function($){
  35. $.fn.splitter = function(args){
  36. args = args || {};
  37. return this.each(function() {
  38. var zombie; // left-behind splitbar for outline resizes
  39. function startSplitMouse(evt) {
  40. if ( opts.outline )
  41. zombie = zombie || bar.clone(false).insertAfter(A);
  42. panes.css("-webkit-user-select", "none"); // Safari selects A/B text on a move
  43. bar.addClass(opts.activeClass);
  44. $('<div class="splitterMask"></div>').insertAfter(bar);
  45. A._posSplit = A[0][opts.pxSplit] - evt[opts.eventPos];
  46. $(document)
  47. .bind("mousemove", doSplitMouse)
  48. .bind("mouseup", endSplitMouse);
  49. }
  50. function doSplitMouse(evt) {
  51. var newPos = A._posSplit+evt[opts.eventPos];
  52. if ( opts.outline ) {
  53. newPos = Math.max(0, Math.min(newPos, splitter._DA - bar._DA));
  54. bar.css(opts.origin, newPos);
  55. } else
  56. resplit(newPos);
  57. }
  58. function endSplitMouse(evt) {
  59. $('div.splitterMask').remove();
  60. bar.removeClass(opts.activeClass);
  61. var newPos = A._posSplit+evt[opts.eventPos];
  62. if ( opts.outline ) {
  63. zombie.remove(); zombie = null;
  64. resplit(newPos);
  65. }
  66. panes.css("-webkit-user-select", "text"); // let Safari select text again
  67. $(document)
  68. .unbind("mousemove", doSplitMouse)
  69. .unbind("mouseup", endSplitMouse);
  70. }
  71. function resplit(newPos) {
  72. // Constrain new splitbar position to fit pane size limits
  73. newPos = Math.max(A._min, splitter._DA - B._max,
  74. Math.min(newPos, A._max, splitter._DA - bar._DA - B._min));
  75. // Resize/position the two panes
  76. bar._DA = bar[0][opts.pxSplit]; // bar size may change during dock
  77. var posOffset = bar.is(':visible') ? bar._DA - 1 : 0;
  78. bar.css(opts.origin, newPos - posOffset).css(opts.fixed, splitter._DF);
  79. A.css(opts.origin, 0).css(opts.split, newPos).css(opts.fixed, splitter._DF);
  80. B.css(opts.origin, newPos + bar._DA - posOffset)
  81. .css(opts.split, splitter._DA-bar._DA-newPos).css(opts.fixed, splitter._DF);
  82. // IE fires resize for us; all others pay cash
  83. if ( !IE_10_AND_BELOW )
  84. panes.trigger("resize");
  85. }
  86. function dimSum(jq, dims) {
  87. // Opera returns -1 for missing min/max width, turn into 0
  88. var sum = 0;
  89. for ( var i=1; i < arguments.length; i++ )
  90. sum += Math.max(parseInt(jq.css(arguments[i])) || 0, 0);
  91. return sum;
  92. }
  93. // Determine settings based on incoming opts, element classes, and defaults
  94. var vh = (args.splitHorizontal? 'h' : args.splitVertical? 'v' : args.type) || 'v';
  95. var opts = $.extend({
  96. activeClass: 'active', // class name for active splitter
  97. pxPerKey: 8, // splitter px moved per keypress
  98. tabIndex: 0, // tab order indicator
  99. accessKey: '' // accessKey for splitbar
  100. },{
  101. v: { // Vertical splitters:
  102. keyLeft: 39, keyRight: 37, cursor: "col-resize",
  103. splitbarClass: "vsplitbar", outlineClass: "voutline",
  104. type: 'v', eventPos: "pageX", origin: "left",
  105. split: "width", pxSplit: "offsetWidth", side1: "Left", side2: "Right",
  106. fixed: "height", pxFixed: "offsetHeight", side3: "Top", side4: "Bottom"
  107. },
  108. h: { // Horizontal splitters:
  109. keyTop: 40, keyBottom: 38, cursor: "row-resize",
  110. splitbarClass: "hsplitbar", outlineClass: "houtline",
  111. type: 'h', eventPos: "pageY", origin: "top",
  112. split: "height", pxSplit: "offsetHeight", side1: "Top", side2: "Bottom",
  113. fixed: "width", pxFixed: "offsetWidth", side3: "Left", side4: "Right"
  114. }
  115. }[vh], args);
  116. // Create jQuery object closures for splitter and both panes
  117. var splitter = $(this).css({position: "relative"});
  118. var panes = $(">*", splitter[0]).css({
  119. position: "absolute", // positioned inside splitter container
  120. "z-index": "1", // splitbar is positioned above
  121. "-moz-outline-style": "none" // don't show dotted outline
  122. });
  123. var A = $(panes[0]); // left or top
  124. var B = $(panes[1]); // right or bottom
  125. // Focuser element, provides keyboard support; title is shown by Opera accessKeys
  126. var focuser = $('<a href="javascript:void(0)"></a>')
  127. .attr({accessKey: opts.accessKey, tabIndex: opts.tabIndex, title: opts.splitbarClass})
  128. .bind($.browser.opera?"click":"focus", function(){ this.focus(); bar.addClass(opts.activeClass) })
  129. .bind("keydown", function(e){
  130. var key = e.which || e.keyCode;
  131. var dir = key==opts["key"+opts.side1]? 1 : key==opts["key"+opts.side2]? -1 : 0;
  132. if ( dir )
  133. resplit(A[0][opts.pxSplit]+dir*opts.pxPerKey, false);
  134. })
  135. .bind("blur", function(){ bar.removeClass(opts.activeClass) });
  136. // Splitbar element, can be already in the doc or we create one
  137. var bar = $(panes[2] || '<div></div>')
  138. .insertAfter(A).css("z-index", "100").append(focuser)
  139. .attr({"class": opts.splitbarClass, unselectable: "on"})
  140. .css({position: "absolute", "user-select": "none", "-webkit-user-select": "none",
  141. "-khtml-user-select": "none", "-moz-user-select": "none", "top": "0px"})
  142. .bind("mousedown", startSplitMouse);
  143. // Use our cursor unless the style specifies a non-default cursor
  144. if ( /^(auto|default|)$/.test(bar.css("cursor")) )
  145. bar.css("cursor", opts.cursor);
  146. // Cache several dimensions for speed, rather than re-querying constantly
  147. bar._DA = bar[0][opts.pxSplit];
  148. splitter._PBF = $.boxModel? dimSum(splitter, "border"+opts.side3+"Width", "border"+opts.side4+"Width") : 0;
  149. splitter._PBA = $.boxModel? dimSum(splitter, "border"+opts.side1+"Width", "border"+opts.side2+"Width") : 0;
  150. A._pane = opts.side1;
  151. B._pane = opts.side2;
  152. $.each([A,B], function(){
  153. this._min = opts["min"+this._pane] || dimSum(this, "min-"+opts.split);
  154. this._max = opts["max"+this._pane] || dimSum(this, "max-"+opts.split) || 9999;
  155. this._init = opts["size"+this._pane]===true ?
  156. parseInt($.curCSS(this[0],opts.split)) : opts["size"+this._pane];
  157. });
  158. // Determine initial position, get from cookie if specified
  159. var initPos = A._init;
  160. if ( !isNaN(B._init) ) // recalc initial B size as an offset from the top or left side
  161. initPos = splitter[0][opts.pxSplit] - splitter._PBA - B._init - bar._DA;
  162. if ( opts.cookie ) {
  163. if ( !$.cookie )
  164. alert('jQuery.splitter(): jQuery cookie plugin required');
  165. var ckpos = parseInt($.cookie(opts.cookie));
  166. if ( !isNaN(ckpos) )
  167. initPos = ckpos;
  168. $(window).bind("unload", function(){
  169. var state = String(bar.css(opts.origin)); // current location of splitbar
  170. $.cookie(opts.cookie, state, {expires: opts.cookieExpires || 365,
  171. path: opts.cookiePath || document.location.pathname});
  172. });
  173. }
  174. if ( isNaN(initPos) ) // King Solomon's algorithm
  175. initPos = Math.round((splitter[0][opts.pxSplit] - splitter._PBA - bar._DA)/2);
  176. // Resize event propagation and splitter sizing
  177. if ( opts.anchorToWindow ) {
  178. // Account for margin or border on the splitter container and enforce min height
  179. splitter._hadjust = dimSum(splitter, "borderTopWidth", "borderBottomWidth", "marginBottom");
  180. splitter._hmin = Math.max(dimSum(splitter, "minHeight"), 20);
  181. $(window).bind("resize", function(){
  182. var top = splitter.offset().top;
  183. var wh = $(window).height();
  184. splitter.css("height", Math.max(wh-top-splitter._hadjust, splitter._hmin)+"px");
  185. if ( !IE_10_AND_BELOW ) splitter.trigger("resize");
  186. }).trigger("resize");
  187. }
  188. else if ( opts.resizeToWidth && !IE_10_AND_BELOW )
  189. $(window).bind("resize", function(){
  190. splitter.trigger("resize");
  191. });
  192. // Resize event handler; triggered immediately to set initial position
  193. splitter.bind("resize", function(e, size){
  194. // Custom events bubble in jQuery 1.3; don't Yo Dawg
  195. if ( e.target != this ) return;
  196. // Determine new width/height of splitter container
  197. splitter._DF = splitter[0][opts.pxFixed] - splitter._PBF;
  198. splitter._DA = splitter[0][opts.pxSplit] - splitter._PBA;
  199. // Bail if splitter isn't visible or content isn't there yet
  200. if ( splitter._DF <= 0 || splitter._DA <= 0 ) return;
  201. // Re-divvy the adjustable dimension; maintain size of the preferred pane
  202. resplit(!isNaN(size)? size : (!(opts.sizeRight||opts.sizeBottom)? A[0][opts.pxSplit] :
  203. splitter._DA-B[0][opts.pxSplit]-bar._DA));
  204. }).trigger("resize" , [initPos]);
  205. });
  206. };
  207. })(jQuery);
  208. //***** axutils.js *****//
  209. /*
  210. *
  211. *
  212. *
  213. *
  214. */
  215. (function() {
  216. // define the root namespace object
  217. if(!window.$axure) window.$axure = {};
  218. $axure.utils = {};
  219. // ------------------------------------------------------------------------
  220. // Makes an object bindable
  221. // ------------------------------------------------------------------------
  222. $axure.utils.makeBindable = function(obj, events) {
  223. if(obj.registeredBindings != null) return;
  224. // copy the events
  225. obj.bindableEvents = events.slice();
  226. obj.registeredBindings = {};
  227. obj.bind = function(eventName, fn) {
  228. var binding = {};
  229. binding.eventName = eventName;
  230. binding.action = fn;
  231. var bindingList = this.registeredBindings[eventName];
  232. if(bindingList == null) {
  233. bindingList = [];
  234. this.registeredBindings[eventName] = bindingList;
  235. }
  236. bindingList[bindingList.length] = binding;
  237. };
  238. obj.unbind = function(eventName) {
  239. if(eventName.indexOf('.') >= 0) {
  240. this.registeredBindings[eventName] = null;
  241. } else {
  242. var event = eventName.split('.')[0];
  243. for(var bindingKey in this.registeredBindings) {
  244. if(bindingKey.split('.')[0] == event) {
  245. this.registeredBindings[bindingKey] = null;
  246. }
  247. }
  248. }
  249. };
  250. obj.triggerEvent = function(eventName, arg) {
  251. for(var bindingKey in this.registeredBindings) {
  252. if(bindingKey.split('.')[0] == eventName) {
  253. var bindings = this.registeredBindings[bindingKey];
  254. for(var i = 0; i < bindings.length; i++) {
  255. if(arg == null) {
  256. bindings[i].action();
  257. } else {
  258. bindings[i].action(arg);
  259. }
  260. }
  261. }
  262. }
  263. };
  264. };
  265. $axure.utils.loadCSS = function(url) {
  266. $('head').append('<link text="text/css" href="' + url + '" rel="Stylesheet" />');
  267. };
  268. $axure.utils.loadJS = function(url) {
  269. $('head').append('<script text="text/javascript" language="JavaScript" src="' + url + '"></script>');
  270. };
  271. $axure.utils.curry = function(fn) {
  272. var curriedArgs = Array.prototype.slice.call(arguments, [1]);
  273. return function() {
  274. fn.apply(this, curriedArgs.concat(Array.prototype.slice.call(arguments)));
  275. };
  276. };
  277. $axure.utils.succeeded = function(result) {
  278. return result && result.success;
  279. };
  280. $axure.utils.createUniqueTag = function() {
  281. return Math.random().toString().substring(2) +
  282. Math.random().toString().substring(2) +
  283. Math.random().toString().substring(2) +
  284. Math.random().toString().substring(2);
  285. };
  286. $axure.utils.formatDate = function(date) {
  287. var months = [
  288. "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  289. "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
  290. var hours = date.getHours();
  291. var amPm = (hours > 11 ? 'PM' : 'AM');
  292. hours = hours % 12;
  293. if(hours == '0') hours = '12';
  294. var minutes = date.getMinutes() + '';
  295. if(minutes.length == 1) {
  296. minutes = '0' + minutes;
  297. }
  298. return [
  299. months[date.getMonth()], ' ', date.getDate(), ' ', date.getFullYear(), ' ',
  300. hours, ':', minutes, ' ', amPm].join('');
  301. };
  302. $axure.utils.quickObject = function() {
  303. var returnVal = {};
  304. for(var i = 0; i < arguments.length; i += 2) {
  305. returnVal[arguments[i]] = arguments[i + 1];
  306. }
  307. return returnVal;
  308. };
  309. var matrixBase = {
  310. mul: function(val) {
  311. if(val.x !== undefined) {
  312. return $axure.utils.Vector2D(
  313. this.m11 * val.x + this.m12 * val.y + this.tx,
  314. this.m21 * val.x + this.m22 * val.y + this.ty);
  315. } else if(val.m11) {
  316. return $axure.utils.Matrix2D(
  317. this.m11 * val.m11 + this.m12 * val.m21,
  318. this.m11 * val.m12 + this.m12 * val.m22,
  319. this.m21 * val.m11 + this.m22 * val.m21,
  320. this.m21 * val.m12 + this.m22 * val.m22,
  321. val.tx + this.tx * val.m11 + this.ty * val.m21,
  322. val.ty + this.tx * val.m12 + this.ty * val.m22
  323. );
  324. } else if(Number(val)) {
  325. var num = Number(val);
  326. return $axure.utils.Matrix2D(this.m11 * num, this.m12 * num,
  327. this.m21 * num, this.m22 * num,
  328. this.tx * num, this.ty * num);
  329. } else return undefined;
  330. },
  331. rotate: function(angle) {
  332. var angleRad = angle * Math.PI / 180;
  333. var c = Math.cos(angleRad);
  334. var s = Math.sin(angleRad);
  335. return this.mul($axure.utils.Matrix2D(c, -s, s, c));
  336. },
  337. translate: function(tx, ty) {
  338. return this.mul($axure.utils.Matrix2D(1, 0, 0, 1, tx, ty));
  339. }
  340. };
  341. $axure.utils.Matrix2D = function(m11, m12, m21, m22, tx, ty) {
  342. return $.extend({
  343. m11: m11 || 0,
  344. m12: m12 || 0,
  345. m21: m21 || 0,
  346. m22: m22 || 0,
  347. tx: tx || 0,
  348. ty: ty || 0
  349. }, matrixBase);
  350. };
  351. $axure.utils.Vector2D = function(x, y) {
  352. return { x: x || 0, y: y || 0 };
  353. };
  354. $axure.utils.Matrix2D.identity = function() {
  355. return $axure.utils.Matrix2D(1, 0, 0, 1, 0, 0);
  356. };
  357. $axure.utils.fixPng = function(png) {
  358. if(!(/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32")) return;
  359. var src = png.src;
  360. if(!png.style.width) { png.style.width = $(png).width(); }
  361. if(!png.style.height) { png.style.height = $(png).height(); }
  362. png.onload = function() { };
  363. png.src = $axure.utils.getTransparentGifPath();
  364. png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
  365. };
  366. })();
  367. // TODO: [mas] simplify this
  368. if(window.$axure && window.$axure.internal) {
  369. $axure.internal(function($ax) { $ax.utils = $axure.utils; });
  370. }
  371. // Its too much of a pain to escape everything and use regular expresions, just replace manually
  372. (function () {
  373. var original = String.prototype.replace;
  374. // TODO: maybe use flags or object instead to pass options in
  375. String.prototype.replace = function (search, newVal, replaceFirst, ignoreCase) {
  376. // Use original is some cases
  377. if (search instanceof RegExp) return original.apply(this, arguments);
  378. search = String(search);
  379. var searchCompare = ignoreCase ? this.toLowerCase() : this;
  380. if (ignoreCase) search = search.toLowerCase();
  381. var searchLength = search.length;
  382. var thisLength = this.length;
  383. var index = 0;
  384. var retVal = '';
  385. while (index != -1) {
  386. var nextIndex = searchCompare.indexOf(search, index);
  387. if (nextIndex != -1) {
  388. retVal += this.substring(index, nextIndex) + newVal;
  389. index = nextIndex + searchLength;
  390. if (index >= thisLength) index = -1;
  391. } else {
  392. retVal += this.substring(index);
  393. index = -1;
  394. }
  395. if (replaceFirst) break;
  396. }
  397. return retVal;
  398. };
  399. if (!Array.prototype.indexOf) {
  400. Array.prototype.indexOf = function (elt /*, from*/) {
  401. var len = this.length >>> 0;
  402. var from = trunc(Number(arguments[1]) || 0);
  403. if(from < 0) from += len;
  404. for(; from < len; from++) {
  405. if(from in this && this[from] === elt) return from;
  406. }
  407. return -1;
  408. };
  409. }
  410. var trunc = function(num) {
  411. return num < 0 ? Math.ceil(num) : Math.floor(num);
  412. };
  413. })();
  414. //***** axplayer.js *****//
  415. if (!window.$axure) window.$axure = function () { };
  416. if (typeof console == 'undefined') console = {
  417. log: function () { }
  418. };
  419. if(window._axUtils) $axure.utils = _axUtils;
  420. $axure.loadDocument = function(document) {
  421. $axure.document = document;
  422. };
  423. function setUpController() {
  424. //$axure.utils = _axUtils;
  425. var _page = {};
  426. $axure.page = _page;
  427. $axure.utils.makeBindable(_page, ['load']);
  428. var _player = function() {
  429. };
  430. $axure.player = _player;
  431. //-----------------------------------------
  432. //Global Var array, getLinkUrl function and setGlobalVar listener are
  433. //for use in setting global vars in page url string when clicking a
  434. //page in the sitemap
  435. //-----------------------------------------
  436. var _globalVars = {};
  437. //-----------------------------------------
  438. //Used by getLinkUrl below to check if local server is running
  439. //in order to send back the global variables as a query string
  440. //in the page url
  441. //-----------------------------------------
  442. var _shouldSendVarsToServer = function () {
  443. //If exception occurs (due to page in content frame being from a different domain, etc)
  444. //then run the check without the url (which will end up checking against sitemap url)
  445. try {
  446. var mainFrame = document.getElementById("mainFrame");
  447. return $axure.shouldSendVarsToServer(mainFrame.contentWindow.location.href);
  448. } catch (e) {
  449. return $axure.shouldSendVarsToServer();
  450. }
  451. };
  452. var _getLinkUrl = function (baseUrl) {
  453. var toAdd = '';
  454. for(var globalVarName in _globalVars) {
  455. var val = _globalVars[globalVarName];
  456. if(val != null) {
  457. if(toAdd.length > 0) toAdd += '&';
  458. toAdd += globalVarName + '=' + encodeURIComponent(val);
  459. }
  460. }
  461. return toAdd.length > 0 ? baseUrl + (_shouldSendVarsToServer() ? '?' : '#') + toAdd + "&CSUM=1" : baseUrl;
  462. };
  463. $axure.getLinkUrlWithVars = _getLinkUrl;
  464. $axure.messageCenter.addMessageListener(function(message, data) {
  465. if (message == 'setGlobalVar'){
  466. _globalVars[data.globalVarName] = data.globalVarValue;
  467. }
  468. });
  469. $axure.messageCenter.addStateListener('page.data', function (key, value) {
  470. for (var subKey in value) {
  471. _page[subKey] = value[subKey];
  472. }
  473. $axure.page.triggerEvent('load');
  474. });
  475. // ---------------------------------------------
  476. // Navigates the main frame (setting the currently visible page). If the link is relative,
  477. // this method should test if it is actually a axure rp page being loaded and properly set
  478. // up all the controller for the page if it is
  479. // ---------------------------------------------
  480. _page.navigate = function (url, includeVariables) {
  481. var mainFrame = document.getElementById("mainFrame");
  482. //var mainFrame = window.parent.mainFrame;
  483. // if this is a relative url...
  484. var urlToLoad;
  485. if (url.indexOf(':') < 0 || url[0] == '/') {
  486. var winHref = window.location.href;
  487. var page = winHref.substring(0, winHref.lastIndexOf('/') + 1) + url;
  488. urlToLoad = page;
  489. } else {
  490. urlToLoad = url;
  491. }
  492. if (!includeVariables) {
  493. mainFrame.contentWindow.location.href = urlToLoad;
  494. return;
  495. }
  496. var urlWithVars = $axure.getLinkUrlWithVars(urlToLoad);
  497. var currentData = $axure.messageCenter.getState('page.data');
  498. var currentUrl = currentData && currentData.location;
  499. if(currentUrl && currentUrl.indexOf('#') != -1) currentUrl = currentUrl.substring(0, currentUrl.indexOf('#'))
  500. // this is so we can make sure the current frame reloads if the variables have changed
  501. // by default, if the location is the same but the hash code is different, the browser will not
  502. // trigger a reload
  503. mainFrame.contentWindow.location.href =
  504. currentUrl && urlToLoad.toLowerCase() != currentUrl.toLowerCase()
  505. ? urlWithVars
  506. : 'resources/reload.html#' + encodeURI(urlWithVars);
  507. };
  508. var pluginIds = [];
  509. var plugins = {};
  510. var currentVisibleHostId = null;
  511. // ---------------------------------------------
  512. // Adds a tool box frame from a url to the interface. This is useful for loading plugins
  513. // settings is an object that supports the following properties:
  514. // - id : the id of the element for the plugin
  515. // - context : the context to create the plugin host for
  516. // - title : the user-visible caption for the plugin
  517. // ---------------------------------------------
  518. _player.createPluginHost = function (settings) {
  519. // right now we only understand an interface context
  520. if (!(!settings.context || settings.context === 'interface')) {
  521. throw ('unknown context type');
  522. }
  523. if (!settings.id) throw ('each plugin host needs an id');
  524. var host = $('<div id=' + settings.id + '></div>')
  525. .appendTo('#interfaceControlFrameHostContainer');
  526. host.hide();
  527. var headerLink = $('<a pluginId="' + settings.id + '" >' + settings.title.toUpperCase() + '</a>');
  528. headerLink
  529. .click($axure.utils.curry(interfaceControlHeaderButton_click, settings.id)).wrap('<li id="' + settings.id + 'Btn">');
  530. if((settings.id == 'feedbackHost' || settings.id == 'feedbackContainer') && pluginIds[pluginIds.length - 1] == 'debugHost') headerLink.parent().insertBefore('#debugHostBtn');
  531. else headerLink.parent().appendTo('#interfaceControlFrameHeader');
  532. pluginIds[pluginIds.length] = settings.id;
  533. plugins[settings.id] = settings;
  534. $(document).trigger('pluginCreated', [settings.gid]);
  535. };
  536. // private methods
  537. var interfaceControlHeaderButton_click = function (id) {
  538. var clickedPlugin = $('#interfaceControlFrameHeader a[pluginId=' + id + ']');
  539. if(clickedPlugin.hasClass('selected')) {
  540. clickedPlugin.removeClass('selected');
  541. $('#' + id).hide();
  542. _player.collapseToBar();
  543. $(document).trigger('pluginShown',['']);
  544. } else {
  545. $('#interfaceControlFrameHeader a').removeClass('selected');
  546. clickedPlugin.addClass('selected');
  547. $('#' + currentVisibleHostId).hide();
  548. $('#' + id).show();
  549. currentVisibleHostId = id;
  550. _player.expandFromBar();
  551. $(document).trigger('pluginShown', [plugins[id].gid]);
  552. }
  553. $(document).trigger('ContainerHeightChange');
  554. };
  555. $axure.player.showPlugin = function(gid) {
  556. for(var id in plugins) {
  557. if(plugins[id].gid == gid) {
  558. $('a[pluginId="' + id + '"]').click();
  559. break;
  560. }
  561. }
  562. };
  563. }
  564. function setUpDocumentStateManager() {
  565. var mgr = $axure.prototype.documentStateManager = {};
  566. $axure.utils.makeBindable(mgr, ['globalVariableChanged']);
  567. mgr.globalVariableValues = {};
  568. mgr.setGlobalVariable = function(varname, value, source) {
  569. var arg = {};
  570. arg.variableName = varname;
  571. arg.newValue = value;
  572. arg.oldValue = this.getGlobalVariable(varname);
  573. arg.source = source;
  574. mgr.globalVariableValues[varname] = value;
  575. this.triggerEvent('globalVariableChanged', arg);
  576. };
  577. mgr.getGlobalVariable = function(varname) {
  578. return mgr.globalVariableValues[varname];
  579. };
  580. }
  581. function setUpPageStateManager() {
  582. var mgr = $axure.prototype.pageStateManager = {};
  583. mgr.panelToStateIds = {};
  584. }
  585. //***** messagecenter.js *****//
  586. if (typeof console == 'undefined') console = {
  587. log: function () { }
  588. };
  589. // sniff chrome
  590. var CHROME_5_LOCAL = false;
  591. var CHROME = false;
  592. var SAFARI = false;
  593. var FIREFOX = false;
  594. var WEBKIT = false;
  595. var OS_MAC = false;
  596. var IOS = false;
  597. var ANDROID = false;
  598. var MOBILE_DEVICE = false;
  599. var IE = false;
  600. var IE_10_AND_BELOW = false; //ie 10 and lower
  601. var IE_11_AND_ABOVE = false; //ie 11 and above
  602. var BROWSER_VERSION = 5000;
  603. (function () {
  604. if(!window.$axure) window.$axure = function() {};
  605. var useragent = window.navigator.userAgent;
  606. var edgeRegex = /Edge\/([0-9]+)/g;
  607. var edgeMatch = edgeRegex.exec(useragent);
  608. $axure.browser = { isEdge: Boolean(edgeMatch) };
  609. if(!$axure.browser.isEdge) {
  610. var chromeRegex = /Chrome\/([0-9]+).([0-9]+)/g;
  611. var chromeMatch = chromeRegex.exec(useragent);
  612. CHROME = Boolean(chromeMatch);
  613. CHROME_5_LOCAL = chromeMatch &&
  614. Number(chromeMatch[1]) >= 5 &&
  615. location.href.indexOf('file://') >= 0;
  616. }
  617. var safariRegex = /Safari\/([0-9]+)/g;
  618. var safariMatch = safariRegex.exec(useragent);
  619. SAFARI = Boolean(safariMatch) && !CHROME; //because chrome also inserts safari string into user agent
  620. var webkitRegex = /WebKit\//g ;
  621. WEBKIT = Boolean(webkitRegex.exec(useragent));
  622. FIREFOX = useragent.toLowerCase().indexOf('firefox') > -1;
  623. var macRegex = /Mac/g ;
  624. OS_MAC = Boolean(macRegex.exec(window.navigator.platform));
  625. IOS = useragent.match(/iPhone/i) || useragent.match(/iPad/i) || useragent.match(/iPod/i);
  626. ANDROID = useragent.match(/Android/i);
  627. MOBILE_DEVICE = ANDROID || IOS
  628. || navigator.userAgent.match(/webOS/i)
  629. || navigator.userAgent.match(/BlackBerry/i)
  630. || navigator.userAgent.match(/Tablet PC/i)
  631. || navigator.userAgent.match(/Windows Phone/i);
  632. if($.browser) {
  633. if($.browser.msie) IE_10_AND_BELOW = true;
  634. else IE_11_AND_ABOVE = useragent.toLowerCase().indexOf('trident') > -1;
  635. BROWSER_VERSION = $.browser.version;
  636. }
  637. IE = IE_10_AND_BELOW || IE_11_AND_ABOVE;
  638. //Used by sitemap and variables.js getLinkUrl functions so that they know
  639. //whether to embed global variables in URL as query string or hash string
  640. //_shouldSendVars persists the value for sitemap instead of re-checking every time
  641. var _shouldSendVars;
  642. var _shouldSendVarsToServer = function(url) {
  643. if(typeof _shouldSendVars != 'undefined') {
  644. return _shouldSendVars;
  645. }
  646. if(SAFARI || (IE_10_AND_BELOW && BROWSER_VERSION < 10)) {
  647. var urlToCheck = typeof url != 'undefined' ? url : window.location.href;
  648. var serverRegex = /http:\/\/127\.0\.0\.1:[0-9]{5}/g;
  649. var serverMatch = serverRegex.exec(urlToCheck);
  650. var previewRegex = /[0-9]{2}\.[0-9]{2}\.[0-9]{2}/g;
  651. var previewMatch = previewRegex.exec(urlToCheck);
  652. if(Boolean(serverMatch) && Boolean(previewMatch)) {
  653. _shouldSendVars = true;
  654. return _shouldSendVars;
  655. }
  656. }
  657. _shouldSendVars = false;
  658. return _shouldSendVars;
  659. };
  660. $axure.shouldSendVarsToServer = _shouldSendVarsToServer;
  661. })();
  662. (function() {
  663. var _topMessageCenter;
  664. var _messageCenter = {};
  665. var _listeners = [];
  666. var _stateListeners = [];
  667. var _state = {};
  668. var _eventObject = null;
  669. var _queuedMessages = [];
  670. var _initialized = false;
  671. // this is for the non Chrome 5 local scenarios. The "top" message center will dispatch to all the bottom ones
  672. var _childrenMessageCenters = [];
  673. // create $axure if it hasn't been created
  674. if (!window.$axure) window.$axure = function() {};
  675. $axure.messageCenter = _messageCenter;
  676. // isolate scope, and initialize _topMessageCenter.
  677. (function() {
  678. if (!CHROME_5_LOCAL) {
  679. var topAxureWindow = window;
  680. try {
  681. while(topAxureWindow.parent && topAxureWindow.parent !== topAxureWindow
  682. && topAxureWindow.parent.$axure) topAxureWindow = topAxureWindow.parent;
  683. } catch(e) {}
  684. _topMessageCenter = topAxureWindow.$axure.messageCenter;
  685. }
  686. })();
  687. $(window.document).ready(function() {
  688. if (CHROME_5_LOCAL) {
  689. $('body').append("<div id='axureEventReceiverDiv' style='display:none'></div>" +
  690. "<div id='axureEventSenderDiv' style='display:none'></div>");
  691. _eventObject = window.document.createEvent('Event');
  692. _eventObject.initEvent('axureMessageSenderEvent', true, true);
  693. $('#axureEventReceiverDiv').bind('axureMessageReceiverEvent', function () {
  694. var request = JSON.parse($(this).text());
  695. _handleRequest(request);
  696. });
  697. } else {
  698. if (_topMessageCenter != _messageCenter) {
  699. _topMessageCenter.addChildMessageCenter(_messageCenter);
  700. console.log('adding from ' + window.location.toString());
  701. }
  702. }
  703. });
  704. var _handleRequest = function (request) {
  705. // route the request to all the listeners
  706. for(var i = 0; i < _listeners.length; i++) _listeners[i](request.message, request.data);
  707. // now handle the queued messages if we're initializing
  708. if (request.message == 'initialize') {
  709. _initialized = true;
  710. // send all the queued messages and return
  711. for (var i = 0; i < _queuedMessages.length; i++) {
  712. var qRequest = _queuedMessages[i];
  713. _messageCenter.postMessage(qRequest.message, qRequest.data);
  714. }
  715. _queuedMessages = [];
  716. }
  717. // and then handle the set state messages, if necessary
  718. if (request.message == 'setState') {
  719. _state[request.data.key] = request.data.value;
  720. for (var i = 0; i < _stateListeners.length; i++) {
  721. var keyListener = _stateListeners[i];
  722. // if thep passed a null or empty value, always post the message
  723. if (!keyListener.key || keyListener.key == request.data.key) {
  724. keyListener.listener(request.data.key, request.data.value);
  725. }
  726. }
  727. }
  728. };
  729. // -----------------------------------------------------------------------------------------
  730. // This method allows for dispatching messages in the non-chromelocal scenario.
  731. // Each child calls this on _topMessageCenter
  732. // -----------------------------------------------------------------------------------------
  733. _messageCenter.addChildMessageCenter = function(messageCenter) {
  734. _childrenMessageCenters[_childrenMessageCenters.length] = messageCenter;
  735. };
  736. // -----------------------------------------------------------------------------------------
  737. // This method allows for dispatching messages in the non-chromelocal scenario.
  738. // Each child calls this on _topMessageCenter
  739. // -----------------------------------------------------------------------------------------
  740. _messageCenter.dispatchMessage = function(message, data) {
  741. _handleRequest({
  742. message: message,
  743. data: data
  744. });
  745. };
  746. // -----------------------------------------------------------------------------------------
  747. // -----------------------------------------------------------------------------------------
  748. _messageCenter.dispatchMessageRecursively = function(message, data) {
  749. console.log("dispatched to " + window.location.toString());
  750. // dispatch to the top center first
  751. _messageCenter.dispatchMessage(message, data);
  752. $('iframe').each(function(index, frame) {
  753. //try,catch to handle permissions error in FF when loading pages from another domain
  754. try {
  755. if (frame.contentWindow.$axure && frame.contentWindow.$axure.messageCenter) {
  756. frame.contentWindow.$axure.messageCenter.dispatchMessageRecursively(message, data);
  757. }
  758. }catch(e) {}
  759. });
  760. };
  761. var _combineEventMessages = false;
  762. var _compositeEventMessageData = [];
  763. _messageCenter.startCombineEventMessages = function() {
  764. _combineEventMessages = true;
  765. }
  766. _messageCenter.endCombineEventMessages = function () {
  767. _messageCenter.sendCompositeEventMessage();
  768. _combineEventMessages = false;
  769. }
  770. _messageCenter.sendCompositeEventMessage = function () {
  771. _messageCenter.postMessage('axCompositeEventMessage', _compositeEventMessageData);
  772. _compositeEventMessageData = [];
  773. }
  774. _messageCenter.postMessage = function (message, data) {
  775. if(_combineEventMessages) {
  776. if(message == 'axEvent' || message == 'axCase' || message == 'axAction' || message == 'axEventComplete') {
  777. _compositeEventMessageData.push({ 'message': message, 'data': data });
  778. if(_compositeEventMessageData.length >= 10) _messageCenter.sendCompositeEventMessage();
  779. return;
  780. }
  781. }
  782. if(!CHROME_5_LOCAL) {
  783. _topMessageCenter.dispatchMessageRecursively(message, data);
  784. } else {
  785. var request = {
  786. message: message,
  787. data: data
  788. };
  789. if(_initialized) {
  790. var senderDiv = window.document.getElementById('axureEventSenderDiv');
  791. var messageText = JSON.stringify(request);
  792. // console.log('sending event: ' + messageText);
  793. senderDiv.innerText = messageText;
  794. senderDiv.dispatchEvent(_eventObject);
  795. // console.log('event sent');
  796. } else {
  797. _queuedMessages[_queuedMessages.length] = request;
  798. }
  799. }
  800. };
  801. _messageCenter.setState = function(key, value) {
  802. var data = {
  803. key: key,
  804. value: value
  805. };
  806. _messageCenter.postMessage('setState', data);
  807. };
  808. _messageCenter.getState = function(key) {
  809. return _state[key];
  810. };
  811. _messageCenter.addMessageListener = function(listener) {
  812. _listeners[_listeners.length] = listener;
  813. };
  814. _messageCenter.addStateListener = function(key, listener) {
  815. _stateListeners[_stateListeners.length] = {
  816. key: key,
  817. listener: listener
  818. };
  819. };
  820. })();