diff options
-rw-r--r-- | js/lib/ui.widgets.js | 2 | ||||
-rw-r--r-- | languages/en.php | 1 | ||||
-rw-r--r-- | mod/friends/start.php | 2 | ||||
-rw-r--r-- | views/default/css.php | 12 | ||||
-rw-r--r-- | views/default/layouts/widgets.php | 7 | ||||
-rw-r--r-- | views/default/widgets/add_panel.php | 30 |
6 files changed, 33 insertions, 21 deletions
diff --git a/js/lib/ui.widgets.js b/js/lib/ui.widgets.js index ebece5a59..73b7f46cc 100644 --- a/js/lib/ui.widgets.js +++ b/js/lib/ui.widgets.js @@ -33,7 +33,7 @@ elgg.ui.widgets.init = function() { event.preventDefault();
});
- $('.widgets_add_panel a').bind('click', function(event) {
+ $('.widgets_add_panel li.widget_available').bind('click', function(event) {
elgg.action('widgets/add', {
data: {
handler: $(this).attr('id'),
diff --git a/languages/en.php b/languages/en.php index 3d6885e8a..9ca58e736 100644 --- a/languages/en.php +++ b/languages/en.php @@ -230,6 +230,7 @@ $english = array( 'widgets:add' => 'Add widgets', 'widgets:add:description' => "Click on any widget button below to add it to your page.", 'widgets:position:fixed' => '(Fixed position on page)', + 'widget:unavailable' => 'You have already added this widget', 'widgets' => "Widgets", 'widget' => "Widget", diff --git a/mod/friends/start.php b/mod/friends/start.php index fe6a40c75..0da095b96 100644 --- a/mod/friends/start.php +++ b/mod/friends/start.php @@ -8,7 +8,7 @@ */ function friends_init() { - add_widget_type('friends', elgg_echo("friends"), elgg_echo('friends:widget:description')); + add_widget_type('friends', elgg_echo("friends"), elgg_echo('friends:widget:description'), 'profile'); } elgg_register_event_handler('init', 'system', 'friends_init'); diff --git a/views/default/css.php b/views/default/css.php index 286beeece..e0be90b2b 100644 --- a/views/default/css.php +++ b/views/default/css.php @@ -894,13 +894,19 @@ li.navigation_more ul li { float: left; margin: 2px 10px; list-style: none; -} -.widgets_add_panel li a { - display: block; width: 200px; padding: 4px; background-color: #cccccc; } +.widgets_add_panel li a { + display: block; +} +.widget_available { + cursor: pointer; +} +.widget_unavailable { + color: #888888; +} .widget { background-color: #dedede; padding: 2px; diff --git a/views/default/layouts/widgets.php b/views/default/layouts/widgets.php index 149e3d327..4b097dcf6 100644 --- a/views/default/layouts/widgets.php +++ b/views/default/layouts/widgets.php @@ -4,7 +4,7 @@ * * @uses $vars['box'] Optional display box at the top of layout * @uses $vars['num_columns'] Number of widget columns for this layout - * @uses $vars['show_add_widgets'] Display the add widgets button + * @uses $vars['show_add_widgets'] Display the add widgets button and panel */ $box = elgg_get_array_value('box', $vars, ''); @@ -28,8 +28,6 @@ if (elgg_can_edit_widget_layout($context)) { echo elgg_view('widgets/add_panel', $params); } -echo '<div class="widget_layout">'; - echo $vars['box']; $widget_class = "widget_{$num_columns}_columns"; @@ -45,7 +43,4 @@ for ($column_index = 1; $column_index <= $num_columns; $column_index++) { echo '</div>'; } -echo '<div class="clearfloat"></div>'; -echo '</div>'; - elgg_pop_context();
\ No newline at end of file diff --git a/views/default/widgets/add_panel.php b/views/default/widgets/add_panel.php index 70d80f41c..09511487c 100644 --- a/views/default/widgets/add_panel.php +++ b/views/default/widgets/add_panel.php @@ -1,10 +1,17 @@ <?php $widgets = $vars['widgets']; -$widget_types = elgg_get_widget_types(); - $context = $vars['context']; +$widget_types = elgg_get_widget_types($context); + +$current_handlers = array(); +foreach ($widgets as $column_widgets) { + foreach ($column_widgets as $widget) { + $current_handlers[] = $widget->handler; + } +} + ?> <div class="widgets_add_panel hidden"> <p> @@ -12,14 +19,17 @@ $context = $vars['context']; </p> <ul> <?php - foreach ($widget_types as $handler => $widget_type) { - $options = array( - 'text' => $widget_type->name, - 'href' => '#', - 'internalid' => $handler, - ); - $link = elgg_view('output/url', $options); - echo "<li>$link</li>"; + foreach ($widget_types as $handler => $widget_type) { + // check if widget added and only one instance allowed + if ($widget_type->multiple == false && in_array($handler, $current_handlers)) { + $class = 'widget_unavailable'; + $tooltip = elgg_echo('widget:unavailable'); + } else { + $class = 'widget_available'; + $tooltip = $widget_type->description; + } + + echo "<li title=\"$tooltip\" id=\"$handler\" class=\"$class\">$widget_type->name</li>"; } ?> </ul> |