PageRenderTime 67ms CodeModel.GetById 39ms RepoModel.GetById 0ms app.codeStats 0ms

/files_all/js/js_nIq8fZoOMFxdhIBsCIVOMYq0aMc3JIVCVyjJM1y5sWY.js

https://bitbucket.org/serveis_populetic/pe-www-main
JavaScript | 271 lines | 195 code | 29 blank | 47 comment | 32 complexity | 300adda3144fa2431915bfaf0a5e524d MD5 | raw file
  1. (function ($) {
  2. Drupal.behaviors.textarea = {
  3. attach: function (context, settings) {
  4. $('.form-textarea-wrapper.resizable', context).once('textarea', function () {
  5. var staticOffset = null;
  6. var textarea = $(this).addClass('resizable-textarea').find('textarea');
  7. var grippie = $('<div class="grippie"></div>').mousedown(startDrag);
  8. grippie.insertAfter(textarea);
  9. function startDrag(e) {
  10. staticOffset = textarea.height() - e.pageY;
  11. textarea.css('opacity', 0.25);
  12. $(document).mousemove(performDrag).mouseup(endDrag);
  13. return false;
  14. }
  15. function performDrag(e) {
  16. textarea.height(Math.max(32, staticOffset + e.pageY) + 'px');
  17. return false;
  18. }
  19. function endDrag(e) {
  20. $(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag);
  21. textarea.css('opacity', 1);
  22. }
  23. });
  24. }
  25. };
  26. })(jQuery);
  27. ;
  28. (function ($) {
  29. /**
  30. * Toggle the visibility of a fieldset using smooth animations.
  31. */
  32. Drupal.toggleFieldset = function (fieldset) {
  33. var $fieldset = $(fieldset);
  34. if ($fieldset.is('.collapsed')) {
  35. var $content = $('> .fieldset-wrapper', fieldset).hide();
  36. $fieldset
  37. .removeClass('collapsed')
  38. .trigger({ type: 'collapsed', value: false })
  39. .find('> legend span.fieldset-legend-prefix').html(Drupal.t('Hide'));
  40. $content.slideDown({
  41. duration: 'fast',
  42. easing: 'linear',
  43. complete: function () {
  44. Drupal.collapseScrollIntoView(fieldset);
  45. fieldset.animating = false;
  46. },
  47. step: function () {
  48. // Scroll the fieldset into view.
  49. Drupal.collapseScrollIntoView(fieldset);
  50. }
  51. });
  52. }
  53. else {
  54. $fieldset.trigger({ type: 'collapsed', value: true });
  55. $('> .fieldset-wrapper', fieldset).slideUp('fast', function () {
  56. $fieldset
  57. .addClass('collapsed')
  58. .find('> legend span.fieldset-legend-prefix').html(Drupal.t('Show'));
  59. fieldset.animating = false;
  60. });
  61. }
  62. };
  63. /**
  64. * Scroll a given fieldset into view as much as possible.
  65. */
  66. Drupal.collapseScrollIntoView = function (node) {
  67. var h = document.documentElement.clientHeight || document.body.clientHeight || 0;
  68. var offset = document.documentElement.scrollTop || document.body.scrollTop || 0;
  69. var posY = $(node).offset().top;
  70. var fudge = 55;
  71. if (posY + node.offsetHeight + fudge > h + offset) {
  72. if (node.offsetHeight > h) {
  73. window.scrollTo(0, posY);
  74. }
  75. else {
  76. window.scrollTo(0, posY + node.offsetHeight - h + fudge);
  77. }
  78. }
  79. };
  80. Drupal.behaviors.collapse = {
  81. attach: function (context, settings) {
  82. $('fieldset.collapsible', context).once('collapse', function () {
  83. var $fieldset = $(this);
  84. // Expand fieldset if there are errors inside, or if it contains an
  85. // element that is targeted by the URI fragment identifier.
  86. var anchor = location.hash && location.hash != '#' ? ', ' + location.hash : '';
  87. if ($fieldset.find('.error' + anchor).length) {
  88. $fieldset.removeClass('collapsed');
  89. }
  90. var summary = $('<span class="summary"></span>');
  91. $fieldset.
  92. bind('summaryUpdated', function () {
  93. var text = $.trim($fieldset.drupalGetSummary());
  94. summary.html(text ? ' (' + text + ')' : '');
  95. })
  96. .trigger('summaryUpdated');
  97. // Turn the legend into a clickable link, but retain span.fieldset-legend
  98. // for CSS positioning.
  99. var $legend = $('> legend .fieldset-legend', this);
  100. $('<span class="fieldset-legend-prefix element-invisible"></span>')
  101. .append($fieldset.hasClass('collapsed') ? Drupal.t('Show') : Drupal.t('Hide'))
  102. .prependTo($legend)
  103. .after(' ');
  104. // .wrapInner() does not retain bound events.
  105. var $link = $('<a class="fieldset-title" href="#"></a>')
  106. .prepend($legend.contents())
  107. .appendTo($legend)
  108. .click(function () {
  109. var fieldset = $fieldset.get(0);
  110. // Don't animate multiple times.
  111. if (!fieldset.animating) {
  112. fieldset.animating = true;
  113. Drupal.toggleFieldset(fieldset);
  114. }
  115. return false;
  116. });
  117. $legend.append(summary);
  118. });
  119. }
  120. };
  121. })(jQuery);
  122. ;
  123. (function ($) {
  124. /**
  125. * Attaches sticky table headers.
  126. */
  127. Drupal.behaviors.tableHeader = {
  128. attach: function (context, settings) {
  129. if (!$.support.positionFixed) {
  130. return;
  131. }
  132. $('table.sticky-enabled', context).once('tableheader', function () {
  133. $(this).data("drupal-tableheader", new Drupal.tableHeader(this));
  134. });
  135. }
  136. };
  137. /**
  138. * Constructor for the tableHeader object. Provides sticky table headers.
  139. *
  140. * @param table
  141. * DOM object for the table to add a sticky header to.
  142. */
  143. Drupal.tableHeader = function (table) {
  144. var self = this;
  145. this.originalTable = $(table);
  146. this.originalHeader = $(table).children('thead');
  147. this.originalHeaderCells = this.originalHeader.find('> tr > th');
  148. this.displayWeight = null;
  149. // React to columns change to avoid making checks in the scroll callback.
  150. this.originalTable.bind('columnschange', function (e, display) {
  151. // This will force header size to be calculated on scroll.
  152. self.widthCalculated = (self.displayWeight !== null && self.displayWeight === display);
  153. self.displayWeight = display;
  154. });
  155. // Clone the table header so it inherits original jQuery properties. Hide
  156. // the table to avoid a flash of the header clone upon page load.
  157. this.stickyTable = $('<table class="sticky-header"/>')
  158. .insertBefore(this.originalTable)
  159. .css({ position: 'fixed', top: '0px' });
  160. this.stickyHeader = this.originalHeader.clone(true)
  161. .hide()
  162. .appendTo(this.stickyTable);
  163. this.stickyHeaderCells = this.stickyHeader.find('> tr > th');
  164. this.originalTable.addClass('sticky-table');
  165. $(window)
  166. .bind('scroll.drupal-tableheader', $.proxy(this, 'eventhandlerRecalculateStickyHeader'))
  167. .bind('resize.drupal-tableheader', { calculateWidth: true }, $.proxy(this, 'eventhandlerRecalculateStickyHeader'))
  168. // Make sure the anchor being scrolled into view is not hidden beneath the
  169. // sticky table header. Adjust the scrollTop if it does.
  170. .bind('drupalDisplaceAnchor.drupal-tableheader', function () {
  171. window.scrollBy(0, -self.stickyTable.outerHeight());
  172. })
  173. // Make sure the element being focused is not hidden beneath the sticky
  174. // table header. Adjust the scrollTop if it does.
  175. .bind('drupalDisplaceFocus.drupal-tableheader', function (event) {
  176. if (self.stickyVisible && event.clientY < (self.stickyOffsetTop + self.stickyTable.outerHeight()) && event.$target.closest('sticky-header').length === 0) {
  177. window.scrollBy(0, -self.stickyTable.outerHeight());
  178. }
  179. })
  180. .triggerHandler('resize.drupal-tableheader');
  181. // We hid the header to avoid it showing up erroneously on page load;
  182. // we need to unhide it now so that it will show up when expected.
  183. this.stickyHeader.show();
  184. };
  185. /**
  186. * Event handler: recalculates position of the sticky table header.
  187. *
  188. * @param event
  189. * Event being triggered.
  190. */
  191. Drupal.tableHeader.prototype.eventhandlerRecalculateStickyHeader = function (event) {
  192. var self = this;
  193. var calculateWidth = event.data && event.data.calculateWidth;
  194. // Reset top position of sticky table headers to the current top offset.
  195. this.stickyOffsetTop = Drupal.settings.tableHeaderOffset ? eval(Drupal.settings.tableHeaderOffset + '()') : 0;
  196. this.stickyTable.css('top', this.stickyOffsetTop + 'px');
  197. // Save positioning data.
  198. var viewHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
  199. if (calculateWidth || this.viewHeight !== viewHeight) {
  200. this.viewHeight = viewHeight;
  201. this.vPosition = this.originalTable.offset().top - 4 - this.stickyOffsetTop;
  202. this.hPosition = this.originalTable.offset().left;
  203. this.vLength = this.originalTable[0].clientHeight - 100;
  204. calculateWidth = true;
  205. }
  206. // Track horizontal positioning relative to the viewport and set visibility.
  207. var hScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
  208. var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - this.vPosition;
  209. this.stickyVisible = vOffset > 0 && vOffset < this.vLength;
  210. this.stickyTable.css({ left: (-hScroll + this.hPosition) + 'px', visibility: this.stickyVisible ? 'visible' : 'hidden' });
  211. // Only perform expensive calculations if the sticky header is actually
  212. // visible or when forced.
  213. if (this.stickyVisible && (calculateWidth || !this.widthCalculated)) {
  214. this.widthCalculated = true;
  215. var $that = null;
  216. var $stickyCell = null;
  217. var display = null;
  218. var cellWidth = null;
  219. // Resize header and its cell widths.
  220. // Only apply width to visible table cells. This prevents the header from
  221. // displaying incorrectly when the sticky header is no longer visible.
  222. for (var i = 0, il = this.originalHeaderCells.length; i < il; i += 1) {
  223. $that = $(this.originalHeaderCells[i]);
  224. $stickyCell = this.stickyHeaderCells.eq($that.index());
  225. display = $that.css('display');
  226. if (display !== 'none') {
  227. cellWidth = $that.css('width');
  228. // Exception for IE7.
  229. if (cellWidth === 'auto') {
  230. cellWidth = $that[0].clientWidth + 'px';
  231. }
  232. $stickyCell.css({'width': cellWidth, 'display': display});
  233. }
  234. else {
  235. $stickyCell.css('display', 'none');
  236. }
  237. }
  238. this.stickyTable.css('width', this.originalTable.css('width'));
  239. }
  240. };
  241. })(jQuery);
  242. ;