diff --git a/include/ajax.search.php b/include/ajax.search.php index e6e362552c8c67417d3fe4a76097b74d1412b588..5ab4feeab0982581295ade316cde365b76cb3f4b 100644 --- a/include/ajax.search.php +++ b/include/ajax.search.php @@ -336,11 +336,22 @@ class SearchAjaxAPI extends AjaxController { foreach ($queues as $queue) { $Q = $queue->getBasicQuery(); - $query->aggregate(array( - 'q'.$queue->id => SqlAggregate::COUNT( - SqlCase::N()->when(new SqlExpr(new Q($Q->constraints)), 1) - ), - )); + if (count($Q->extra) || $Q->isWindowed()) { + // Nothing extra in the select clause, or this will break + unset($Q->extra['select']); + // XXX: This doesn't work + $query->annotate(array( + 'q'.$queue->id => $Q->values_flat() + ->filter(array('ticket_id' => new SqlField('ticket_id', 1))) + ->aggregate(array('count' => SqlAggregate::COUNT('ticket_id'))) + )); + } + else { + $expr = SqlCase::N()->when(new SqlExpr(new Q($Q->constraints)), 1); + $query->aggregate(array( + 'q'.$queue->id => SqlAggregate::COUNT($expr) + )); + } } Http::response(200, false, 'application/json'); diff --git a/include/class.orm.php b/include/class.orm.php index e22b09e72fa655a84e96662ec07feb5a062edbd8..5b047ab05629e387d9fdfcbea5ccf7b7684d3012 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -2902,8 +2902,13 @@ class MySqlCompiler extends SqlCompiler { foreach ($queryset->values as $alias=>$v) { list($f) = $this->getField($v, $model); $unaliased = $f; - if ($f instanceof SqlFunction) + if ($f instanceof SqlFunction) { $fields[$f->toSql($this, $model, $alias)] = true; + if ($f instanceof SqlAggregate) { + // Don't group_by aggregate expressions + continue; + } + } else { if (!is_int($alias)) $f .= ' AS '.$this->quote($alias); diff --git a/include/class.queue.php b/include/class.queue.php index 0acca703c642a6ce689dd9ada06b3e8ef6db54d2..143e37ba0b8063184e1b0e7a45ab95786e8a23a4 100644 --- a/include/class.queue.php +++ b/include/class.queue.php @@ -147,6 +147,7 @@ class CustomQueue extends SavedSearch { // Set basic queue information $this->filter = $vars['filter']; + $this->path = $this->buildPath(); $this->setFlag(self::FLAG_INHERIT_CRITERIA, $this->parent_id > 0 && isset($vars['inherit'])); diff --git a/include/class.search.php b/include/class.search.php index 59fff7df7ade48a0d0b1d6eb7dda052a3c05e445..5435c7cd5a268237213a2618710dc49e4b065ef2 100644 --- a/include/class.search.php +++ b/include/class.search.php @@ -708,14 +708,18 @@ class SavedSearch extends VerySimpleModel { } function getRoot() { - return 'Ticket'; + switch ($this->root) { + case 'T': + default: + return 'Ticket'; + } } function getPath() { return $this->path ?: $this->buildPath(); } - function getCriteria() { + function getCriteria($include_parent=false) { if (!isset($this->criteria)) { $old = @$this->config[0] === '{'; $this->criteria = is_string($this->config) @@ -727,13 +731,18 @@ class SavedSearch extends VerySimpleModel { $this->criteria = $this->isolateCriteria($this->criteria); } } - return $this->criteria ?: array(); + $criteria = $this->criteria ?: array(); + if ($include_parent && $this->parent_id && $this->parent) { + $criteria = array_merge($this->parent->getCriteria(true), + $criteria); + } + return $criteria; } function describeCriteria($criteria=false){ $all = $this->getSupportedMatches($this->getRoot()); $items = array(); - $criteria = $criteria ?: $this->getCriteria(); + $criteria = $criteria ?: $this->getCriteria(true); foreach ($criteria as $C) { list($path, $method, $value) = $C; if (!isset($all[$path])) @@ -741,7 +750,7 @@ class SavedSearch extends VerySimpleModel { list($label, $field) = $all[$path]; $items[] = $field->describeSearch($method, $value, $label); } - return implode(', ', $items); + return implode("\nAND ", $items); } /** @@ -788,6 +797,12 @@ class SavedSearch extends VerySimpleModel { if (!$source) { foreach ($this->getCriteria() as $I) { list($path, $method, $value) = $I; + if ($path == ':keywords' && $method === null) { + if ($F = $form->getField($path)) + $F->value = $value; + continue; + } + if (!($F = $form->getField("{$path}+search"))) continue; $F->value = true; @@ -830,9 +845,12 @@ class SavedSearch extends VerySimpleModel { $all = $this->getSupportedMatches(); $core = array(); - foreach ($basic[$this->getRoot()] as $path) - if (isset($all[$path])) - $core[$path] = $all[$path]; + + // Include basic fields for new searches + if (!isset($this->id)) + foreach ($basic[$this->getRoot()] as $path) + if (isset($all[$path])) + $core[$path] = $all[$path]; // Add others from current configuration foreach ($this->getCriteria() as $C) { @@ -1053,6 +1071,9 @@ class SavedSearch extends VerySimpleModel { $items[] = array($name, $method, $value); } } + if (isset($criteria[':keywords'])) { + $items[] = array(':keywords', null, $criteria[':keywords']); + } return $items; } @@ -1126,7 +1147,7 @@ class SavedSearch extends VerySimpleModel { // Apply column, annotations and conditions additions foreach ($this->getColumns() as $C) { - $query = $C->mangleQuery($query); + $query = $C->mangleQuery($query, $this->getRoot()); } return $query; } @@ -1142,7 +1163,7 @@ class SavedSearch extends VerySimpleModel { // Consider keyword searching if ($name === ':keywords') { global $ost; - $qs = $ost->searcher->find($keywords, $qs); + $qs = $ost->searcher->find($value, $qs); } else { // XXX: Move getOrmPath to be more of a utility @@ -1259,6 +1280,16 @@ class SavedSearch extends VerySimpleModel { } function update($vars, $form=false, &$errors=array()) { + // Set basic search information + if (!$vars['name']) + $errors['name'] = __('A title is required'); + + $this->title = $vars['name']; + $this->parent_id = @$vars['parent_id'] ?: 0; + $this->path = $this->buildPath(); + // Personal queues _always_ inherit from their parent + $this->setFlag(self::FLAG_INHERIT_CRITERIA, $this->parent_id > 0); + // TODO: Move this to SavedSearch::update() and adjust // AjaxSearch::_saveSearch() $form = $form ?: $this->getForm($vars); @@ -1270,15 +1301,6 @@ class SavedSearch extends VerySimpleModel { $this->isolateCriteria($form->getClean())); } - // Set basic search information - if (!$vars['name']) - $errors['name'] = __('A title is required'); - - $this->title = $vars['name']; - $this->parent_id = @$vars['parent_id'] ?: 0; - $this->path = $this->buildPath(); - // Personal queues _always_ inherit from their parent - $this->setFlag(self::FLAG_INHERIT_CRITERIA, $this->parent_id > 0); return count($errors) === 0; } diff --git a/include/staff/queue.inc.php b/include/staff/queue.inc.php index 1967c3cf106ca504d9f2b241b9e1b235cf46dd0c..afaed941a412b49787d4b44e720f8699c6b2a5df 100644 --- a/include/staff/queue.inc.php +++ b/include/staff/queue.inc.php @@ -65,7 +65,7 @@ else { <span id="parent_q_crit" class="faded"> <i class="icon-caret-right"></i> <br/><?php - echo $queue->parent->describeCriteria(); + echo nl2br(Format::htmlchars($queue->parent->describeCriteria())); ?></span> <?php } ?> </label> diff --git a/include/staff/templates/advanced-search.tmpl.php b/include/staff/templates/advanced-search.tmpl.php index 454ef70d100529dfc10a966c5e16fee69a0d2143..7fae3244ac2b854de14a55f6043218af7a9dc9c6 100644 --- a/include/staff/templates/advanced-search.tmpl.php +++ b/include/staff/templates/advanced-search.tmpl.php @@ -17,9 +17,8 @@ if ($parent_id <option value="0" <?php if (!$parent_id) echo 'selected="selected"'; ?>><?php echo '—'.__("My Searches").'—'; ?></option> - <?php foreach (CustomQueue::queues() - ->filter(array('parent_id' => 0)) - as $q) { ?> + <?php +foreach (CustomQueue::queues()->order_by('sort', 'title') as $q) { ?> <option value="<?php echo $q->id; ?>" <?php if ($parent_id == $q->id) echo 'selected="selected"'; ?> ><?php echo $q->getFullName(); ?></option> @@ -36,6 +35,16 @@ if ($parent_id <hr/> <div class="flex row"> <div class="span12"> +<?php if ($queue && $queue->parent) { ?> + <div class="faded" style="margin-bottom: 1em"> + <div> + <strong><?php echo __('Inherited Criteria'); ?></strong> + </div> + <div> + <?php echo nl2br(Format::htmlchars($queue->describeCriteria())); ?> + </div> + </div> +<?php } ?> <input type="hidden" name="a" value="search"> <?php include STAFFINC_DIR . 'templates/advanced-search-criteria.tmpl.php'; ?> </div> diff --git a/include/staff/templates/queue-navigation.tmpl.php b/include/staff/templates/queue-navigation.tmpl.php index 1631ba67d3fa2bd20dd7b3fd9b7c830f52f09d38..478d1d89671d20ef707045788b223f6e363d6e8c 100644 --- a/include/staff/templates/queue-navigation.tmpl.php +++ b/include/staff/templates/queue-navigation.tmpl.php @@ -12,6 +12,20 @@ $selected = $_REQUEST['queue'] == $this_queue->getId(); <a href="<?php echo $this_queue->getHref(); ?>"><i class="icon-sort-down pull-right"></i><?php echo $this_queue->getName(); ?></a> <div class="customQ-dropdown"> <ul class="scroll-height"> + <!-- Add top-level queue (with count) --> + <li class="top-level"> + <span class="pull-right newItemQ queue-count" + data-queue-id="<?php echo $q->id; ?>"><span class="faded-more">-</span> + </span> + + <a class="truncate <?php if ($selected) echo ' active'; ?>" href="<?php echo $q->getHref(); + ?>" title="<?php echo Format::htmlchars($q->getName()); ?>"> + <?php + echo Format::htmlchars($q->getName()); ?> + </a> + </h4> + </li> + <!-- Start Dropdown and child queues --> <?php foreach ($this_queue->getPublicChildren() as $q) { include 'queue-subnavigation.tmpl.php'; diff --git a/include/staff/templates/queue-savedsearches-nav.tmpl.php b/include/staff/templates/queue-savedsearches-nav.tmpl.php index d7d32a8a3a0f523fd707bb195805145ca2ae65f5..81646edf71d6440fd0369374fd991a3aedc3840a 100644 --- a/include/staff/templates/queue-savedsearches-nav.tmpl.php +++ b/include/staff/templates/queue-savedsearches-nav.tmpl.php @@ -5,7 +5,7 @@ // $child_selected - <bool> true if the selected queue is a descendent // $adhoc - not FALSE if an adhoc advanced search exists ?> -<li class="item <?php if ($child_selected) echo ''; ?>"> +<li class="primary-only item <?php if ($child_selected) echo ''; ?>"> <?php $href = 'href="tickets.php?queue=adhoc"'; if (!isset($_SESSION['advsearch'])) @@ -25,10 +25,12 @@ )) as $q) { include 'queue-subnavigation.tmpl.php'; } ?> + <?php if (isset($_SESSION['advsearch']) + && count($_SESSION['advsearch'])) { ?> <li> <h4><?php echo __('Recent Searches'); ?></h4> </li> - <?php if (isset($_SESSION['advsearch'])) { + <?php foreach ($_SESSION['advsearch'] as $token=>$criteria) { $q = new SavedSearch(array('root' => 'T')); $q->id = 'adhoc,'.$token; diff --git a/include/staff/templates/queue-subnavigation.tmpl.php b/include/staff/templates/queue-subnavigation.tmpl.php index fd6a3aef4e49291bc0e2321e4bd7a524b302ae44..ddf345cfba5871cb18ea242f20ec9553d661d768 100644 --- a/include/staff/templates/queue-subnavigation.tmpl.php +++ b/include/staff/templates/queue-subnavigation.tmpl.php @@ -3,44 +3,19 @@ // $q - <CustomQueue> object for this navigation entry $queue = $q; $children = $queue instanceof CustomQueue ? $queue->getPublicChildren() : array(); -$hasChildren = count($children) > 0; +$subq_searches = $queue instanceof CustomQueue ? $queue->getMyChildren() : array(); +$hasChildren = count($children) + count($subq_searches) > 0; $selected = $_REQUEST['queue'] == $q->getId(); global $thisstaff; ?> <!-- SubQ class: only if top level Q has subQ --> <li <?php if ($hasChildren) echo 'class="subQ"'; ?>> -<?php - if ($thisstaff->isAdmin() || $q->isPrivate()) { ?> - <!-- Edit Queue --> - <div class="controlQ"> - <div class="editQ pull-right"> - <i class="icon-cog"></i> - <div class="manageQ"> - <ul> - <li> - <a href="<?php - echo $queue->isPrivate() - ? sprintf('#" data-dialog="ajax.php/tickets/search/%s', - urlencode($queue->getId())) - : sprintf('queues.php?id=%d', $queue->getId()); ?>"> - <i class="icon-fixed-width icon-pencil"></i> - <?php echo __('Edit'); ?></a> - </li> - <li class="danger"> - <a href="#"><i class="icon-fixed-width icon-trash"></i><?php echo __('Delete'); ?></a> - </li> - </ul> - </div> - </div> - </div> - <?php } ?> - <span class="<?php if ($thisstaff->isAdmin() || $q->isPrivate()) echo 'personalQmenu'; ?> - pull-right newItemQ queue-count" - data-queue-id="<?php echo $q->id; ?>"><span class="faded-more">-</span> - </span> + <span class="<?php if ($thisstaff->isAdmin() || $q->isPrivate()) echo 'personalQmenu'; ?> + pull-right newItemQ queue-count" + data-queue-id="<?php echo $q->id; ?>"><span class="faded-more">-</span> + </span> - <!-- End Edit Queue --> <a class="truncate <?php if ($selected) echo ' active'; ?>" href="<?php echo $queue->getHref(); ?>" title="<?php echo Format::htmlchars($q->getName()); ?>"> <?php @@ -51,11 +26,27 @@ global $thisstaff; <?php } ?> </a> - <?php if ($hasChildren) { - echo '<ul class="subMenuQ">'; - foreach ($children as $q) { + <?php + $closure_include = function($q) use ($thisstaff, $ost, $cfg) { + global $thisstaff, $ost, $cfg; include __FILE__; - } - echo '</ul>'; + }; + if ($hasChildren) { ?> + <ul class="subMenuQ"> + <?php + foreach ($children as $q) + $closure_include($q); + + // Include personal sub-queues + $first_child = true; + foreach ($subq_searches as $q) { + if ($first_child) { + $first_child = false; + echo '<li class="personalQ"></li>'; + } + $closure_include($q); + } ?> + </ul> +<?php } ?> </li> diff --git a/include/staff/templates/queue-tickets.tmpl.php b/include/staff/templates/queue-tickets.tmpl.php index dff0083d79af0fe0667c8e808f7f8e088ec51403..bd41e7fdbc523cc3c9c19845dd51f725eac6b8e8 100644 --- a/include/staff/templates/queue-tickets.tmpl.php +++ b/include/staff/templates/queue-tickets.tmpl.php @@ -98,15 +98,46 @@ return false;"> <i class="icon-cog"></i> <div class="noclick-dropdown anchor-left"> <ul> +<?php +if ($queue->isPrivate()) { ?> <li> - <a class="no-pjax tickets-action" href="#" ><i class="icon-fixed-width icon-save"></i> Save Queue</a> + <a class="no-pjax" href="#" + data-dialog="ajax.php/tickets/search/<?php echo + $queue->id; ?>"><i + class="icon-fixed-width icon-save"></i> + <?php echo __('Edit'); ?></a> </li> +<?php } +else { + if ($thisstaff->isAdmin()) { ?> <li> - <a class="no-pjax tickets-action" href="#"><i class="icon-fixed-width icon-pencil"></i> Edit</a> + <a class="no-pjax" + href="queues.php?id=<?php echo $queue->id; ?>"><i + class="icon-fixed-width icon-pencil"></i> + <?php echo __('Edit'); ?></a> </li> +<?php } +# Anyone has permission to create personal sub-queues +?> + <li> + <a class="no-pjax" href="#" + data-dialog="ajax.php/tickets/search?parent_id=<?php + echo $queue->id; ?>"><i + class="icon-fixed-width icon-plus-sign"></i> + <?php echo __('Add Personal Queue'); ?></a> + </li> +<?php +} +if ( + ($thisstaff->isAdmin() && $queue->parent_id) + || $queue->isPrivate() +) { ?> <li class="danger"> - <a class="no-pjax tickets-action" href="#"><i class="icon-fixed-width icon-trash"></i> Delete</a> + <a class="no-pjax" href="#"><i + class="icon-fixed-width icon-trash"></i> + <?php echo __('Delete'); ?></a> </li> +<?php } ?> </ul> </div> </div> diff --git a/scp/css/scp.css b/scp/css/scp.css index 61d9729ef6694a1463cde0d288c72ee492f7379d..379db451cdaa0f6ee30e837b049e01960badb760 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -373,7 +373,7 @@ a time { } #sub_nav a.active, #sub_nav li.active > a, -#customQ_nav .jb-overflowmenu-menu-primary li.item > a.active { +#customQ_nav .jb-overflowmenu-menu li.active.item > a { font-weight:bold; } @@ -429,13 +429,16 @@ a time { list-style-image: none; } -.customQ-dropdown li h4 { - padding:2px 8px; +.customQ-dropdown li h4, +.customQ-dropdown li.top-level { margin:0; background-color:#eee; color:#bbb; text-align:left; } +.customQ-dropdown li h4 { + padding:2px 8px; +} .customQ-dropdown li.personalQ { font-size:1px; border-bottom:2px dashed #eee; @@ -527,6 +530,21 @@ a time { } /************ Custom Queue Button with Sub Queues *************/ +.subMenuQ:before, .subMenuQ:after { + content: ""; + position: absolute; + display: block; + height: 10px; + width: 100%; + background: transparent; +} +.subMenuQ:before { + bottom: 100%; +} +.subMenuQ:after { + top: 100%; +} + .customQ-dropdown ul li.subQ > a i { padding:2px 6px 0; display:inline-block; @@ -584,9 +602,6 @@ a time { .customQ-dropdown ul li > span.newItemQ { padding:1px 8px 0 0; } -.customQ-dropdown ul li > span.personalQmenu.newItemQ { - margin-right:20px; -} /************ Custom Queue Add/Save a Queue Button *************/ .customQ-dropdown .add-queue a { @@ -711,6 +726,7 @@ a time { .jb-overflowmenu { position: relative; height:35px; + width: 960px; } @@ -748,9 +764,14 @@ a time { /******** Overflow menu and Dropdown *********/ .jb-overflowmenu .jb-overflowmenu-container { - display: inline; left: auto; - bottom: 0px; + bottom: 0; + right: 0; + top: 0; + border-bottom: 1px solid #bebebe; + border-left:1px solid #bebebe; + border-right: 1px solid #aaa; + background-color: #eee; } .jb-overflowmenu .jb-overflowmenu-menu-secondary-handle { @@ -763,9 +784,8 @@ a time { .jb-overflowmenu .jb-overflowmenu-container > a.jb-overflowmenu-menu-secondary-handle { color:#666; - padding:10px; + padding:9px; background-color:#eee; - border-left:1px solid #bebebe; } .jb-overflowmenu .jb-overflowmenu-container > a.jb-overflowmenu-menu-secondary-handle:hover { color:#000; @@ -791,17 +811,17 @@ a time { } /*** Overflow Dropdown ***/ -#sub_nav .jb-overflowmenu-menu-secondary li.item:before { +.jb-overflowmenu-menu-secondary li.item:before { font-family: "FontAwesome"; content:"\F0D9"; padding:5px; } -#sub_nav .jb-overflowmenu-menu-secondary li.item a > i { +.jb-overflowmenu-menu-secondary li.item a > i { margin-top:5px; } -#sub_nav .jb-overflowmenu-menu-secondary li.item { +.jb-overflowmenu-menu-secondary li.item { position:relative; padding:0px 10px; display: inline-block; @@ -809,9 +829,10 @@ a time { border-top-left-radius: 0; border-bottom:1px solid #bebebe; white-space:nowrap; + list-style:none; } -#sub_nav .jb-overflowmenu-menu-secondary li.item > a { +.jb-overflowmenu-menu-secondary li.item > a { display:inline-block; padding:5px 10px 5px 21px; background-position:0 50%; @@ -819,7 +840,7 @@ a time { color:#000; } -#sub_nav .jb-overflowmenu-menu-secondary li.item:hover { +.jb-overflowmenu-menu-secondary li.item:hover { padding:0 10px; color:#E65524; background-color: #fff; @@ -828,14 +849,11 @@ a time { border-right:none; } -#sub_nav .jb-overflowmenu-menu-secondary li.item:hover > a { +.jb-overflowmenu-menu-secondary li.item:hover > a { color:#E65524; text-decoration: none; } -#sub_nav .jb-overflowmenu-menu-secondary li.item > a.active { - font-weight:bold; -} .jb-overflowmenu-menu-secondary div.customQ-dropdown { border-top-left-radius:6px; border-top-right-radius:0px; diff --git a/scp/js/jb.overflow.menu.js b/scp/js/jb.overflow.menu.js index cc1b61166e373533138f721ba88dc4d456d3ca03..bfa365833039dc01325668be776df10d5f496321 100755 --- a/scp/js/jb.overflow.menu.js +++ b/scp/js/jb.overflow.menu.js @@ -51,7 +51,7 @@ $.widget( "jb.overflowmenu", { this.primaryMenu = this.element .children( this.options.itemsParentTag ) - .addClass( 'jb-overflowmenu-menu-primary jb-overflowmenu-helper-postion' ); + .addClass( 'jb-overflowmenu-menu jb-overflowmenu-menu-primary jb-overflowmenu-helper-postion' ); this._setHeight(); @@ -60,7 +60,7 @@ $.widget( "jb.overflowmenu", { [ '<div class="jb-overflowmenu-container jb-overflowmenu-helper-postion">', '<a href="javascript://" class="jb-overflowmenu-menu-secondary-handle"></a>', - '<' + this.options.itemsParentTag + ' class="jb-overflowmenu-menu-secondary jb-overflowmenu-helper-postion"></' + this.options.itemsParentTag + '>', + '<' + this.options.itemsParentTag + ' class="jb-overflowmenu-menu jb-overflowmenu-menu-secondary jb-overflowmenu-helper-postion"></' + this.options.itemsParentTag + '>', '</div>' ].join('') ) @@ -109,13 +109,36 @@ $.widget( "jb.overflowmenu", { var vHeight = this.primaryMenuHeight, - //get the items, filter out the the visible ones + hWidth = this.secondaryMenuContainer.find('.jb-overflowmenu-menu-secondary-handle') + .outerWidth(), + vWidth = this.primaryMenuWidth - hWidth, + previousRight = this.primaryMenu.offset().left; + + // Items classed 'primary-only' should always be primary + this._getItems() + .each(function() { + var $this = $(this); + if ($this.hasClass('primary-only')) + vWidth -= $this.outerWidth(true); + }); + + //get the items, filter out the visible ones itemsToHide = this._getItems() - .filter(function(){ - return this.offsetTop + $(this).height() > vHeight; - }) + .filter(function() { + var $this = $(this), + left = $this.offset().left, + dLeft = Math.max(0, left - previousRight); + previousRight = left + $this.width(); - itemsToHide.appendTo( this.secondaryMenu ); + if ($this.hasClass('primary-only')) + return false; + + vWidth -= dLeft + $this.outerWidth(true); + return vWidth < 1; + }); + + itemsToHide.appendTo( this.secondaryMenu ) + .find('i.icon-sort-down').remove('i.icon-sort-down'); if( itemsToHide.length == 0 ){ @@ -162,6 +185,8 @@ $.widget( "jb.overflowmenu", { }else{ this.primaryMenuHeight = this.element.innerHeight(); } + this.primaryMenuWidth = this.options.width || + this.element.innerWidth(); }, _setOption: function( key, value ) { diff --git a/scp/js/scp.js b/scp/js/scp.js index 647d5d9cdad28cfa2f580d0ba31a3040d79893be..780b038fa55bbdbc18011838e090e36c8f9bd68f 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -476,28 +476,11 @@ var scp_prep = function() { .on('focus', function() { $(this).parent().addClass('focus'); }) .on('blur', function() { $(this).parent().removeClass('focus'); }) - $('#customQ_nav').overflowmenu({ - guessHeight: false, - change: function( e, ui ) { - var handle = ui.container.find('.jb-overflowmenu-menu-secondary-handle'); - if ( ui.secondary.children().length > 0 ) { - // necessary? - ui.primary.css('right', ui.secondary.width()); - handle.css('display', 'inline-block') - } - else { - ui.primary.css('right', 0); - handle.css('display', 'none') - } - } - }); - - $(function() { // whenever we hover over a menu item that has a submenu $('.subQ').on('mouseover', function() { var $menuItem = $(this), - $submenuWrapper = $('.subMenuQ', $menuItem); + $submenuWrapper = $('> .subMenuQ', $menuItem); // grab the menu item's position relative to its positioned parent var menuItemPos = $menuItem.position(); @@ -508,6 +491,16 @@ var scp_prep = function() { left: menuItemPos.left + Math.round($menuItem.outerWidth()) }); }); + // Ensure the "new ticket" link is never in the drop-down menu + $('#new-ticket').parent('li').addClass('primary-only'); + $('#customQ_nav').overflowmenu({ + guessHeight: false, + // items: 'li.top-queue', + change: function( e, ui ) { + var handle = ui.container.find('.jb-overflowmenu-menu-secondary-handle'); + handle.toggle( ui.secondary.children().length > 0 ); + } + }); }); // Auto fetch queue counts @@ -522,7 +515,6 @@ var scp_prep = function() { success: function(json) { $('li > span.queue-count').each(function(i, e) { var $e = $(e); - console.log(json['q' + $e.data('queueId')]); $e.text(json['q' + $e.data('queueId')]); }); } @@ -531,25 +523,6 @@ var scp_prep = function() { }); }; -/* Custom Queues Dropdown */ -/* $(function() { - // whenever we hover over a menu item that has a submenu - $('.editQ').on('mouseover', function() { - var $menuItem = $(this), - $submenuWrapper = $('.manageQ', $menuItem); - - // grab the menu item's position relative to its positioned parent - var menuItemPos = $menuItem.position(); - - // place the submenu in the correct position relevant to the menu item - $submenuWrapper.css({ - top: menuItemPos.top - 41, - left: menuItemPos.left + Math.round($menuItem.outerWidth() * 0) - }); - }); - }); -};*/ - $(document).ready(scp_prep); $(document).on('pjax:end', scp_prep); var fixupDatePickers = function() {