/** * Resize function without multiple trigger * * Usage: * $(window).smartresize(function(){ * code here * }); */ (function ($, sr) { var debounce = function (func, threshold, execAsap) { var timeout; return function debounced () { var obj = this, args = arguments; function delayed () { if (!execAsap) func.apply(obj, args); timeout = null; } if (timeout) clearTimeout(timeout); else if (execAsap) func.apply(obj, args); timeout = setTimeout(delayed, threshold || 100); }; }; jQuery.fn[sr] = function (fn) { return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; })(jQuery, 'smartresize'); jQuery(document).ready(function ($) { if (typeof $.fn.datepicker.dates === 'undefined') { $.fn.datepicker.dates = {'en': []}; } $.fn.datepicker.dates['en'] = { days: [ upstream.langs.LB_SUNDAY, upstream.langs.LB_MONDAY, upstream.langs.LB_TUESDAY, upstream.langs.LB_WEDNESDAY, upstream.langs.LB_THURSDAY, upstream.langs.LB_FRIDAY, upstream.langs.LB_SATURDAY ], daysShort: [ upstream.langs.LB_SUN, upstream.langs.LB_MON, upstream.langs.LB_TUE, upstream.langs.LB_WED, upstream.langs.LB_THU, upstream.langs.LB_FRI, upstream.langs.LB_SAT ], daysMin: [ upstream.langs.LB_SU, upstream.langs.LB_MO, upstream.langs.LB_TU, upstream.langs.LB_WE, upstream.langs.LB_TH, upstream.langs.LB_FR, upstream.langs.LB_SA ], months: [ upstream.langs.LB_JANUARY, upstream.langs.LB_FEBRUARY, upstream.langs.LB_MARCH, upstream.langs.LB_APRIL, upstream.langs.LB_MAY, upstream.langs.LB_JUNE, upstream.langs.LB_JULY, upstream.langs.LB_AUGUST, upstream.langs.LB_SEPTEMBER, upstream.langs.LB_OCTOBER, upstream.langs.LB_NOVEMBER, upstream.langs.LB_DECEMBER ], monthsShort: [ upstream.langs.LB_JAN, upstream.langs.LB_FEB, upstream.langs.LB_MAR, upstream.langs.LB_APR, upstream.langs.LB_MAY, upstream.langs.LB_JUN, upstream.langs.LB_JUL, upstream.langs.LB_AUG, upstream.langs.LB_SEP, upstream.langs.LB_OCT, upstream.langs.LB_NOV, upstream.langs.LB_DEC ], today: upstream.langs.LB_TODAY, clear: upstream.langs.LB_CLEAR, format: 'mm/dd/yyyy', titleFormat: 'MM yyyy', /* Leverages same syntax as 'format' */ weekStart: 0 }; $('[data-toggle="tooltip"]').tooltip(); var setContentHeight = function () { $('.right_col').css('min-height', $(window).height()); var bodyHeight = $('body').outerHeight(), footerHeight = $('body').hasClass('footer_fixed') ? -10 : $('footer').height(), leftColHeight = $('.left_col').eq(1).height() + $('.sidebar-footer').height(), contentHeight = bodyHeight < leftColHeight ? leftColHeight : bodyHeight; contentHeight -= $('.nav_menu').height() + footerHeight; $('.right_col').css('min-height', contentHeight); }; window.setContentHeight = setContentHeight; $('#sidebar-menu').find('a').on('click', function (ev) { var $li = $(this).parent(); if ($li.is('.active')) { $li.removeClass('active active-sm'); $('ul:first', $li).slideUp(function () { setContentHeight(); }); } else { if (!$li.parent().is('.child_menu')) { $('#sidebar-menu').find('li').removeClass('active active-sm'); $('#sidebar-menu').find('li ul').slideUp(); } $li.addClass('active'); $('ul:first', $li).slideDown(function () { setContentHeight(); }); } }); $('#menu_toggle').on('click', function () { if ($('body').hasClass('nav-md')) { $('#sidebar-menu').find('li.active ul').hide(); $('#sidebar-menu').find('li.active').addClass('active-sm').removeClass('active'); } else { $('#sidebar-menu').find('li.active-sm ul').show(); $('#sidebar-menu').find('li.active-sm').addClass('active').removeClass('active-sm'); } $('body').toggleClass('nav-md nav-sm'); setContentHeight(); }); var cmp = window.location.href; $('#sidebar-menu').find('a[href="' + window.location.href.split('?')[0] + '"]').parent('li').addClass('current-page'); $('#sidebar-menu').find('a').filter(function () { return this.href == window.location.href.split('?')[0]; }).parent('li').addClass('current-page').parents('ul').slideDown(function () { setContentHeight(); }).parent().addClass('active'); $(window).smartresize(function () { setContentHeight(); }); setContentHeight(); if ($.fn.mCustomScrollbar) { $('.menu_fixed').mCustomScrollbar({ autoHideScrollbar: true, theme: 'minimal', mouseWheel: {preventDefault: true} }); } $(window).trigger('upstream-sidebar'); }); jQuery(document).ready(function ($) { $('.collapse-link').on('click', function () { var $boxPanel = $(this).closest('.x_panel'), $icon = $(this).find('i'), $boxContent = $boxPanel.find('.x_content'); if ($boxPanel.attr('style')) { $boxContent.slideToggle(200, function () { $boxPanel.removeAttr('style'); }); } else { $boxContent.slideToggle(200); $boxPanel.css('height', 'auto'); } $icon.toggleClass('fa-chevron-up fa-chevron-down'); var state = $icon.hasClass('fa-chevron-up') ? 'opened' : 'closed', section = $boxPanel.data('section'); $.ajax({ url: upstream.ajaxurl, type: 'post', data: { action: 'upstream_collapse_update', nonce: upstream.security, section: section, state: state } }); }); $('.close-link').click(function () { var $boxPanel = $(this).closest('.x_panel'); $boxPanel.remove(); }); $('#project-dashboard.sortable').sortable({ placeholder: 'ui-state-highlight', cancel: 'input,textarea,button,select,option,.ui-state-disabled,.navbar-right', handle: '.x_title i.sortable_handler', update: function (event, ui) { var rows = $('#project-dashboard').sortable('toArray'); $.ajax({ url: upstream.ajaxurl, type: 'post', data: { action: 'upstream_panel_order_update', nonce: upstream.security, rows: rows } }); } }); $('#project-dashboard.sortable .x_title').disableSelection(); }); (function (window, document, $, NProgress, undefined) { if (!NProgress) return; NProgress.start(); $(window).on('load', function () { NProgress.done(); }); })(window, window.document, jQuery, NProgress || null); (function (window, document, $, undefined) { $(document).ready(function () { $('.c-discussion').on('click', '.o-comment[data-id] a[data-action="comment.go_to_reply"]', function (e) { e.preventDefault(); var targetComment = $($(this).attr('href')); if (targetComment.length === 0) { console.error('Comment not found.'); return; } var wrapper = $(targetComment.parents('.c-discussion')); wrapper.animate({ scrollTop: targetComment.get(0).offsetTop }, function () { targetComment.addClass('s-highlighted'); setTimeout(function () { targetComment.removeClass('s-highlighted'); }, 750); }); }); function highlighComment (comment_selector) { var comment = $(comment_selector); if (comment.length === 0) return; var wrapper = $($(comment.parents('.c-comments')).get(0)); if (wrapper.length === 0) return; var SCROLL_DURATION = 250; var HIGHLIGH_CLASS = 's-highlighted'; var scrollElToOffset = function (subject, offset, onSuccessCallback) { subject.animate({ scrollTop: offset, duration: SCROLL_DURATION }, onSuccessCallback); }; var doHighlighComment = function (comment) { comment.addClass(HIGHLIGH_CLASS); setTimeout(function () { comment.removeClass(HIGHLIGH_CLASS); }, 750); }; var wrapperDataType = wrapper.attr('data-type'); if (wrapperDataType === 'project') { var bodyHasScrolled = false; scrollElToOffset($('html, body'), comment.offset().top, function () { if (bodyHasScrolled) return; bodyHasScrolled = true; scrollElToOffset(wrapper, comment.get(0).offsetTop, function () { doHighlighComment(comment); }); }); } else { var tr = $($(wrapper.parents('tr')).get(0)); $('> td[data-name]', tr).trigger('click'); var bodyHasScrolled = false; scrollElToOffset($('html, body'), tr.offset().top, function () { if (bodyHasScrolled) return; bodyHasScrolled = true; comment = $('tr.child ' + comment_selector, tr.parent()); wrapper = $($(comment.parents('.c-comments')).get(0)); scrollElToOffset(wrapper, comment.get(0).offsetTop - comment.height(), function () { doHighlighComment(comment); }); }); } } setTimeout(function () { var commentIdRegexp = new RegExp(/^\#comment\-\d+/i); if (commentIdRegexp.test(window.location.hash)) { highlighComment(window.location.hash); } }, 250); }); })(window, window.document, jQuery || {}); (function (window, document, $, $data, TableExport, undefined) { $(document).ready(function () { $('.o-data-table tr[data-id] a[data-toggle="up-modal"]').on('click', function (e) { e.preventDefault(); e.stopPropagation(); var self = $(this); var tr = self.parents('tr[data-id]'); var modal = new Modal({ el: self.attr('data-up-target') }); modal.on('show', function (modal, e) { $('[data-column]', tr).each(function () { var columnEl = $(this); var columnName = $(this).attr('data-column'); if (['notes', 'description', 'comments'].indexOf(columnName) >= 0) { $('[data-column="' + columnName + '"]', modal.el).html(columnEl.html()); } else { $('[data-column="' + columnName + '"]', modal.el).text(columnEl.text()); } }); }); modal.on('hidden', function (modal, e) { $('[data-column]', modal.el).html(''); }); modal.show(); }); function createOrderDirectionEl (direction) { var span = $('', { class: 'pull-right o-order-direction' }); span.append($('', { class: 'fa fa-sort' + (!direction ? '' : (direction === 'ASC' ? '-asc' : '-desc')) })); return span; } function orderTable (columnName, direction, table) { var trs = $('> tbody > tr[data-id]', table); if (trs.length === 0) return; var data = []; var tr, columnValue; var data = []; trs.each(function (trIndex) { var tr = $(this); if ($('[data-column="' + columnName + '"]', tr).attr('data-order')) { columnValue = $('[data-column="' + columnName + '"]', tr).attr('data-order'); } else { columnValue = $('[data-column="' + columnName + '"]', tr).attr('data-value') || ''; } data.push({ index: trIndex, value: columnValue.toUpperCase(), children: $('> tbody > tr[data-parent="' + tr.attr('data-id') + '"]', table).clone() }); }); data.sort(function (a, b) { var comparison = a.value.localeCompare(b.value); if (direction === 'DESC' && comparison !== 0) { comparison *= -1; } return comparison; }); $('> tbody > tr', table).remove(); $.each(data, function (trNewIndex) { var tr = $(trs.get(this.index), table); tr.removeClass('t-row-odd t-row-even'); if ((trNewIndex + 1) % 2 === 0) { tr.addClass('t-row-even'); } else { tr.addClass('t-row-odd'); } $('> tbody', table).append(tr); if (this.children.length > 0) { $('> tbody', table).append(this.children); } }); table.attr('data-order-dir', direction) .attr('data-ordered-by', columnName); var th = $('thead tr th[data-column="' + columnName + '"]', table); $('.o-order-direction', th).remove(); th.append(createOrderDirectionEl(direction)); } $('.o-data-table').on('click', 'thead th.is-orderable[role="button"]', function (e) { e.preventDefault(); var self = $(this); var wrapper = $(self.parent()); var table = wrapper.parents('table'); var column = self.attr('data-column'); $('.o-order-direction', wrapper).remove(); $('th.is-orderable[role="button"]', wrapper).append(createOrderDirectionEl(null)); $('.o-order-direction', self).remove(); if (self.hasClass('is-ordered')) { var orderDir = (self.attr('data-order-dir') || 'DESC').toUpperCase(); var newOrderDir = orderDir === 'DESC' ? 'ASC' : 'DESC'; } else { $('.is-ordered', wrapper).removeClass('is-ordered'); $('th[data-order-dir]', wrapper).attr('data-order-dir', null); var newOrderDir = 'ASC'; } self.attr('data-order-dir', newOrderDir); self.append(createOrderDirectionEl(newOrderDir)); self.addClass('is-ordered'); orderTable(column, newOrderDir, $(self.parents('table.o-data-table'))); $.ajax({ url: upstream.ajaxurl, type: 'post', data: { action: 'upstream_ordering_update', nonce: upstream.security, column: column, orderDir: newOrderDir, tableId: table.attr('id') } }); }); function sortTable (columnName, columnValue, filtersWrapper) { var table = $(filtersWrapper.attr('data-target')); var filtersMap = []; var filters = $('[data-column]', filtersWrapper); filters.each(function () { var self = $(this); var value = self.val(); if (typeof value === 'string') { value = value.trim(); } else if (value) { value = value.filter(function (elValue) { return elValue.length > 0; }); } else { value = ''; } filtersMap[self.attr('data-column')] = value.length > 0 ? value : null; filtersMap.push({ column: self.attr('data-column'), value: value.length > 0 ? value : null, comparator: self.attr('data-compare-operator') || 'exact' }); }); $('tbody tr[data-empty-row]', table).remove(); var filtersHasChanged = false; var trs = $('tbody tr[data-id]', table); trs.removeClass('is-filtered'); trs.each(function (trIndex) { var tr = $(this); var shouldDisplay = true; var filter, filterIndex, filterColumnValue, columnValue, comparator, dataWrapper; for (filterIndex = 0; filterIndex < filtersMap.length; filterIndex++) { filter = filtersMap[filterIndex]; if (filter.value === null) { continue; } dataWrapper = $('[data-column="' + filter.column + '"]', tr); if (dataWrapper.length === 0) { dataWrapper = $('[data-column="' + filter.column + '"]', $('tbody tr[data-parent="' + tr.attr('data-id') + '"]')); if (dataWrapper.length === 0) { continue; } else { dataWrapper = $('[data-value]', dataWrapper); } } columnValue = dataWrapper.attr('data-value'); if (filter.comparator === 'contains') { if (typeof filter.value === 'string') { comparator = new RegExp(filter.value, 'i'); if (!comparator.test(columnValue)) { shouldDisplay = false; break; } } else { for (var valueIndex in filter.value) { comparator = new RegExp(filter.value[valueIndex], 'i'); var found = false; if (filter.value[valueIndex] === '__none__') { if (!columnValue || columnValue === '__none__') { found = true; break; } } else { if (comparator.test(columnValue)) { found = true; break; } if (!found) { shouldDisplay = false; break; } } } } } else if (filter.comparator === 'exact') { if (typeof filter.value === 'string') { if (columnValue != filter.value) { shouldDisplay = false; break; } } else { var found = false; for (var valueIndex in filter.value) { if (filter.value[valueIndex] === '__none__') { if (!columnValue || columnValue === '__none__') { found = true; break; } } else { if (columnValue === filter.value[valueIndex] || columnValue.split(',').indexOf(filter.value[valueIndex]) >= 0) { found = true; break; } } } if (!found) { shouldDisplay = false; break; } } } else if (filter.comparator === '>') { if (columnValue <= filter.value) { shouldDisplay = false; break; } } else if (filter.comparator === '>=') { if (columnValue < filter.value) { shouldDisplay = false; break; } } else if (filter.comparator === '<') { if (columnValue >= filter.value) { shouldDisplay = false; break; } } else if (filter.comparator === '<=') { if (columnValue > filter.value) { shouldDisplay = false; break; } } else if (filter.value === '__none__') { if (columnValue && columnValue != '__none__') { shouldDisplay = false; break; } } else { if (typeof filter.value === 'string') { if (columnValue.localeCompare(filter.value) != 0) { shouldDisplay = false; break; } } else { var found = false; for (var valueIndex in filter.value) { if (filter.value[valueIndex] === '__none__') { if (!columnValue || columnValue === '__none__') { found = true; break; } } else { if (columnValue.localeCompare(filter.value[valueIndex]) != 0) { found = true; break; } } if (!found) { shouldDisplay = false; break; } } } } if (!shouldDisplay) { break; } } if (shouldDisplay) { tr.addClass('is-filtered').show(); } else { tr.hide(); } }); var filteredRows = $('tbody tr[data-id]:visible', table); if (filteredRows.length === 0) { var thsCount = $('thead th', table).length; var tr = $('