Commit 6f2a878f authored by webchick's avatar webchick
Browse files

#609100 by bleen18, seutje, and David_Rothstein: Should not be able to re-add...

#609100 by bleen18, seutje, and David_Rothstein: Should not be able to re-add same shortcut to same set twice.
parent d5f071f8
......@@ -27,7 +27,7 @@ div#toolbar div.toolbar-shortcuts ul li a.active:focus {
div#toolbar div.toolbar-shortcuts ul li a.active:hover,
div#toolbar div.toolbar-shortcuts ul li a.active {
background: url(../toolbar/toolbar.png) 0 -20px repeat-x;
background: #000;
}
div#toolbar div.toolbar-shortcuts span.icon {
......@@ -40,26 +40,36 @@ div#toolbar div.toolbar-shortcuts span.icon {
-webkit-border-radius: 5px;
}
div.add-to-shortcuts a span.icon {
div.add-or-remove-shortcuts {
padding-top: 5px;
}
div.add-or-remove-shortcuts a span.icon {
display: block;
width: 12px;
background: url(../toolbar/toolbar.png) no-repeat -50px -60px;
background: transparent url(shortcut.png) no-repeat scroll 0 0;
height: 12px;
float: left;
margin-left:8px;
}
div.add-to-shortcuts a:hover span.icon {
background-position: -50px -72px;
div.add-shortcut a:hover span.icon {
background-position: 0 -12px;
}
div.remove-shortcut a span.icon {
background-position: -12px 0;
}
div.remove-shortcut a:hover span.icon {
background-position: -12px -12px;
}
div.add-to-shortcuts a span.text {
div.add-or-remove-shortcuts a span.text {
float: left;
padding-left:10px;
display: none;
}
div.add-to-shortcuts a:hover span.text {
div.add-or-remove-shortcuts a:hover span.text {
font-size: 10px;
line-height: 12px;
color: #fff;
......
......@@ -378,14 +378,18 @@ function shortcut_current_displayed_set($account = NULL) {
// If none was found, try to find a shortcut set that is explicitly assigned
// to this user.
$query = db_select('shortcut_set', 's');
$query->fields('s');
$query->addField('s', 'set_name');
$query->join('shortcut_set_users', 'u', 's.set_name = u.set_name');
$query->condition('u.uid', $account->uid);
$shortcut_set = $query->execute()->fetchObject();
$shortcut_set_name = $query->execute()->fetchField();
if ($shortcut_set_name) {
$shortcut_set = shortcut_set_load($shortcut_set_name);
}
// Otherwise, use the default set.
if (!$shortcut_set) {
else {
$shortcut_set = shortcut_default_set($account);
}
$shortcut_sets[$account->uid] = $shortcut_set;
return $shortcut_set;
}
......@@ -516,17 +520,36 @@ function shortcut_page_build(&$page) {
$query = array(
'link' => $link,
'name' => drupal_get_title(),
'token' => drupal_get_token('shortcut-add-link'),
);
$query += drupal_get_destination();
$shortcut_set = shortcut_current_displayed_set();
$link_text = shortcut_set_switch_access() ? t('Add to %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Add to shortcuts');
$page['add_to_shortcuts'] = array(
'#prefix' => '<div class="add-to-shortcuts">',
// Check if $link is already a shortcut and set $link_mode accordingly.
foreach ($shortcut_set->links as $shortcut) {
if ($link == $shortcut['link_path']) {
$mlid = $shortcut['mlid'];
break;
}
}
$link_mode = isset($mlid) ? "remove" : "add";
if ($link_mode == "add") {
$query['token'] = drupal_get_token('shortcut-add-link');
$link_text = shortcut_set_switch_access() ? t('Add to %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Add to shortcuts');
$link_path = 'admin/config/system/shortcut/' . $shortcut_set->set_name . '/add-link-inline';
}
else {
$query['mlid'] = $mlid;
$link_text = shortcut_set_switch_access() ? t('Remove from %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Remove from shortcuts');
$link_path = 'admin/config/system/shortcut/link/' . $mlid . '/delete';
}
$page['add_or_remove_shortcut'] = array(
'#prefix' => '<div class="add-or-remove-shortcuts ' . $link_mode . '-shortcut">',
'#type' => 'link',
'#title' => '<span class="icon"></span><span class="text">' . $link_text . '</span>',
'#href' => 'admin/config/system/shortcut/' . $shortcut_set->set_name . '/add-link-inline',
'#href' => $link_path,
'#options' => array('query' => $query, 'html' => TRUE),
'#suffix' => '</div>',
);
......@@ -559,7 +582,7 @@ function shortcut_page_build(&$page) {
* Implement hook_preprocess_page().
*/
function shortcut_preprocess_page(&$variables) {
if (isset($variables['page']['add_to_shortcuts'])) {
$variables['add_to_shortcuts'] = drupal_render($variables['page']['add_to_shortcuts']);
if (isset($variables['page']['add_or_remove_shortcut'])) {
$variables['add_or_remove_shortcut'] = drupal_render($variables['page']['add_or_remove_shortcut']);
}
}
......@@ -49,7 +49,7 @@ div#toolbar div.shadow {
right: 0;
bottom: -15px;
height: 15px;
background: url(toolbar.png) 0 -85px repeat-x;
background: url(toolbar.png) 0 -45px repeat-x;
}
div#toolbar a {
......@@ -66,7 +66,7 @@ div#toolbar ul li a {
* Administration menu.
*/
div#toolbar div.toolbar-menu {
background: url(toolbar.png) 0 -20px repeat-x;
background: #000;
height: 25px;
line-height: 20px;
padding: 5px 10px 0;
......@@ -88,7 +88,7 @@ div#toolbar div.toolbar-menu span.toggle {
position: absolute;
right: 10px;
cursor: pointer;
background: url(toolbar.png) 0 -60px no-repeat;
background: url(toolbar.png) 0 -20px no-repeat;
text-indent: -9999px;
overflow: hidden;
width: 25px;
......@@ -96,7 +96,7 @@ div#toolbar div.toolbar-menu span.toggle {
}
div#toolbar div.toolbar-menu span.toggle-active {
background-position: -25px -60px;
background-position: -25px -20px;
}
div#toolbar div.toolbar-menu ul li a {
......
modules/toolbar/toolbar.png

1.05 KB | W: | H:

modules/toolbar/toolbar.png

590 Bytes | W: | H:

modules/toolbar/toolbar.png
modules/toolbar/toolbar.png
modules/toolbar/toolbar.png
modules/toolbar/toolbar.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -4,7 +4,7 @@
<div id="branding" class="clearfix">
<?php print $breadcrumb; ?>
<?php if ($title): ?><h1 class="page-title"><?php print $title; ?></h1><?php endif; ?>
<?php if (isset($add_to_shortcuts)): ?><?php print $add_to_shortcuts; ?><?php endif; ?>
<?php if (isset($add_or_remove_shortcut)): ?><?php print $add_or_remove_shortcut; ?><?php endif; ?>
<?php if ($primary_local_tasks): ?><ul class="tabs primary"><?php print render($primary_local_tasks); ?></ul><?php endif; ?>
</div>
......
......@@ -737,8 +737,8 @@ body.overlay #block-system-main {
}
/* Shortcut theming */
div.add-to-shortcuts {
div.add-or-remove-shortcuts {
float: left;
margin-left: 6px;
margin-top: 6px;
padding-top: 6px;
padding-left: 6px;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment