init.temp.js.orig 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. $axure.internal(function($ax) {
  2. $(window.document).ready(function() {
  3. var readyStart = (new Date()).getTime();
  4. //this is because the page id is not formatted as a guid
  5. var pageId = $ax.pageData.page.packageId;
  6. var pageData = {
  7. id: pageId,
  8. pageName: $ax.pageData.page.name,
  9. location: window.location.toString(),
  10. notes: $ax.pageData.page.notes
  11. };
  12. //only trigger the page.data setting if the window is on the mainframe
  13. try {
  14. if(window.name == 'mainFrame' ||
  15. (!CHROME_5_LOCAL && window.parent.$ && window.parent.$('#mainFrame').length > 0)) {
  16. $axure.messageCenter = $axure.messageCenter;
  17. $axure.messageCenter.setState('page.data', pageData);
  18. }
  19. } catch(e) {}
  20. // $ax(function(diagramObject) {
  21. // return diagramObject.style.opacity && !diagramObject.isContained;
  22. // }).each(function(diagramObject, elementId) {
  23. // $ax.style.applyOpacityFromStyle(elementId, diagramObject.style);
  24. // });
  25. var start = (new Date()).getTime();
  26. var end = (new Date()).getTime();
  27. //window.alert('elapsed ' + (end - start));
  28. $('input[type=text], input[type=password], textarea').focus(function() {
  29. window.lastFocusedControl = this;
  30. });
  31. $('iframe').each(function() {
  32. var origSrc = $(this).attr('basesrc');
  33. if(origSrc) {
  34. var newSrcUrl = origSrc.toLowerCase().indexOf('http://') == -1 ? $ax.globalVariableProvider.getLinkUrl(origSrc) : origSrc;
  35. $(this).attr('src', newSrcUrl);
  36. }
  37. });
  38. $axure.messageCenter.addMessageListener(function(message, data) {
  39. if(message == 'setGlobalVar') {
  40. $ax.globalVariableProvider.setVariableValue(data.globalVarName, data.globalVarValue, true);
  41. }
  42. });
  43. var lastFocusedClickable;
  44. var shouldOutline = true;
  45. $ax(function(dObj) { return dObj.tabbable; }).each(function(dObj, elementId) {
  46. var focusableId = $ax.event.getFocusableWidgetOrChildId(elementId);
  47. $('#' + focusableId).attr("tabIndex", 0);
  48. });
  49. $('div[tabIndex=0], img[tabIndex=0]').bind($ax.features.eventNames.mouseDownName, function() {
  50. shouldOutline = false;
  51. });
  52. $(window.document).bind($ax.features.eventNames.mouseUpName, function() {
  53. shouldOutline = true;
  54. });
  55. $('div[tabIndex=0], img[tabIndex=0], a').focus(function() {
  56. if(shouldOutline) {
  57. $(this).css('outline', '');
  58. } else {
  59. $(this).css('outline', 'none');
  60. }
  61. lastFocusedClickable = this;
  62. });
  63. $('div[tabIndex=0], img[tabIndex=0], a').blur(function() {
  64. if(lastFocusedClickable == this) lastFocusedClickable = null;
  65. });
  66. $(window.document).bind('keyup', function(e) {
  67. if(e.keyCode == '13' || e.keyCode == '32') {
  68. if(lastFocusedClickable) $(lastFocusedClickable).click();
  69. }
  70. });
  71. if($ax.document.configuration.hideAddress) {
  72. $(window).load(function() {
  73. window.setTimeout(function() {
  74. window.scrollTo(0, 0.9);
  75. }, 0);
  76. });
  77. }
  78. $(window).load(function() {
  79. $ax.style.initializeObjectTextAlignment($ax('*'));
  80. });
  81. if($ax.document.configuration.preventScroll) {
  82. $(window.document).bind('touchmove', function(e) {
  83. var inScrollable = $ax.legacy.GetScrollable(e.target) != window.document.body;
  84. if(!inScrollable) {
  85. e.preventDefault();
  86. }
  87. });
  88. $ax(function(diagramObject) {
  89. return diagramObject.type == 'dynamicPanel' && diagramObject.scrollbars != 'none';
  90. }).$().children().bind('touchstart', function() {
  91. var target = this;
  92. var top = target.scrollTop;
  93. if(top <= 0) target.scrollTop = 1;
  94. if(top + target.offsetHeight >= target.scrollHeight) target.scrollTop = target.scrollHeight - target.offsetHeight - 1;
  95. });
  96. }
  97. if(OS_MAC && WEBKIT) {
  98. $ax(function(diagramObject) {
  99. return diagramObject.type == 'comboBox';
  100. }).each(function(obj, id) {
  101. $jobj($ax.INPUT(id)).css('-webkit-appearance', 'menulist-button').css('border-color', '#999999');
  102. });
  103. }
  104. $ax.legacy.BringFixedToFront();
  105. $ax.event.initialize();
  106. $ax.style.initialize();
  107. $ax.visibility.initialize();
  108. $ax.dynamicPanelManager.initialize(); //needs to be called after visibility is initialized
  109. $ax.adaptive.initialize();
  110. $ax.loadDynamicPanelsAndMasters();
  111. $ax.adaptive.loadFinished();
  112. $ax.repeater.init();
  113. $ax.style.prefetch();
  114. var readyEnd = (new Date()).getTime();
  115. //window.alert('elapsed ' + (readyEnd - readyStart));
  116. });
  117. });
  118. /* extend canvas */
  119. var gv_hasCanvas = false;
  120. (function() {
  121. var _canvas = document.createElement('canvas'), proto, abbrev;
  122. if(gv_hasCanvas = !!(_canvas.getContext && _canvas.getContext('2d')) && typeof (CanvasGradient) !== 'undefined') {
  123. function chain(func) {
  124. return function() {
  125. return func.apply(this, arguments) || this;
  126. };
  127. }
  128. with(proto = CanvasRenderingContext2D.prototype) for(var func in abbrev = {
  129. a: arc,
  130. b: beginPath,
  131. n: clearRect,
  132. c: clip,
  133. p: closePath,
  134. g: createLinearGradient,
  135. f: fill,
  136. j: fillRect,
  137. z: function(s) { this.fillStyle = s; },
  138. l: lineTo,
  139. w: function(w) { this.lineWidth = w; },
  140. m: moveTo,
  141. q: quadraticCurveTo,
  142. h: rect,
  143. r: restore,
  144. o: rotate,
  145. s: save,
  146. x: scale,
  147. y: function(s) { this.strokeStyle = s; },
  148. u: setTransform,
  149. k: stroke,
  150. i: strokeRect,
  151. t: translate
  152. }) proto[func] = chain(abbrev[func]);
  153. CanvasGradient.prototype.a = chain(CanvasGradient.prototype.addColorStop);
  154. }
  155. })();