summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/shortcut/shortcut.css24
-rw-r--r--modules/shortcut/shortcut.module43
-rw-r--r--modules/shortcut/shortcut.pngbin0 -> 624 bytes
-rw-r--r--modules/toolbar/toolbar.css8
-rw-r--r--modules/toolbar/toolbar.pngbin1075 -> 590 bytes
-rw-r--r--themes/seven/page.tpl.php2
-rw-r--r--themes/seven/style.css6
7 files changed, 58 insertions, 25 deletions
diff --git a/modules/shortcut/shortcut.css b/modules/shortcut/shortcut.css
index 6a2797e2a..3fc45148e 100644
--- a/modules/shortcut/shortcut.css
+++ b/modules/shortcut/shortcut.css
@@ -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;
diff --git a/modules/shortcut/shortcut.module b/modules/shortcut/shortcut.module
index 84b66948f..9d7f18e46 100644
--- a/modules/shortcut/shortcut.module
+++ b/modules/shortcut/shortcut.module
@@ -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']);
}
}
diff --git a/modules/shortcut/shortcut.png b/modules/shortcut/shortcut.png
new file mode 100644
index 000000000..e5b33873a
--- /dev/null
+++ b/modules/shortcut/shortcut.png
Binary files differ
diff --git a/modules/toolbar/toolbar.css b/modules/toolbar/toolbar.css
index c20fcd545..a2fc955a1 100644
--- a/modules/toolbar/toolbar.css
+++ b/modules/toolbar/toolbar.css
@@ -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 {
diff --git a/modules/toolbar/toolbar.png b/modules/toolbar/toolbar.png
index 391d2e750..17ce9409b 100644
--- a/modules/toolbar/toolbar.png
+++ b/modules/toolbar/toolbar.png
Binary files differ
diff --git a/themes/seven/page.tpl.php b/themes/seven/page.tpl.php
index 71e7e0bf7..503537c0d 100644
--- a/themes/seven/page.tpl.php
+++ b/themes/seven/page.tpl.php
@@ -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>
diff --git a/themes/seven/style.css b/themes/seven/style.css
index 22c972b24..df4dd1046 100644
--- a/themes/seven/style.css
+++ b/themes/seven/style.css
@@ -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;
}