Commit 3a69a04c authored by merlinofchaos's avatar merlinofchaos

UI is really getting there now.

parent d3b06159
/* $Id$ */
.views-tabset {
background: #E0E5E8;
}
.views-tabset .views-tab fieldset {
margin-top: 0;
}
......@@ -7,7 +11,7 @@
.views-tabset .views-tabs ul {
list-style-type: none !important;
list-style-image: none !important;
border: 1px solid black;
border-bottom: #5C707E 1px solid;
margin: 0;
padding: 0;
}
......@@ -15,19 +19,27 @@
.views-tabset .views-tabs ul li {
list-style-type: none;
list-style-image: none;
background: none;
margin-left: 0;
background: #B3BEC6;
border-top: #5C707E 1px solid;
border-right: #5C707E 1px solid;
border-left: #5C707E 1px solid;
margin: 0;
padding: 3px 3px 3px 6px;
}
.views-tabset .views-tabs ul li.active {
background: #ccc;
background: #fff;
border-top: #5C707E 2px solid;
border-right: 0;
border-bottom: #5C707E 1px solid;
margin-left: 0;
font-weight: bold;
}
.views-tabset .views-tabs {
float: left;
width: 120px;
width: 119px;
}
.views-tabset .extra {
......@@ -39,9 +51,9 @@
}
.views-tabset .views-display {
border: 1px solid black;
margin-left: 119px; /* 120 -1 causes borders to overlap */
min-height: 300px;
border: #5C707E 1px solid;
margin-left: 118px; /* 120 -1 causes borders to overlap */
min-height: 302px;
_height: 300px; /* stupid IE hack */
}
.views-tabset .views-display-deleted {
......@@ -49,20 +61,23 @@
}
.views-display .top {
padding: 2px 5px;
border-left: 1px solid black;
border-right: 1px solid black;
border-bottom: 2px solid black;
padding: 0.5em 0em 0em 1em;
background: #fff;
}
.views-display .top .display-title {
font-weight: bold;
}
.views-display .top .display-description {
margin-left: 1em;
font-style: italic;
overflow: hide;
white-space: nowrap;
font-size: 90%;
}
.views-display .tab-section {
background: #fff;
width: 33%;
padding: 0;
margin: 0;
......@@ -79,6 +94,8 @@
.views-display .tab-section .links {
float: right;
font-size: 6pt;
position: relative;
display: inline;
}
.views-display .tab-section .links a {
......@@ -93,11 +110,13 @@
.views-display #views-add-display-form {
float: right;
margin-bottom: 0;
margin-right: 0.5em;
}
.views-display .middle {
width: 34%;
background-color: #ccc;
}
.views-display dl {
......@@ -105,28 +124,65 @@
}
.views-basic-info {
border: 1px solid black;
padding: 2px 5px;
background-color: #eee;
margin-top: 0.75em;
padding: 0.25em;
font-weight: bold;
background: #E0E5E8;
}
.views-display dl {
margin: 0.25em;
display: block;
padding: 0.25em 0.5em 0.5em 0.25em;
background: #F0F2F4;
}
.views-display dt {
font-weight: bold;
padding: 0 0 0em 0.5em;
}
.views-display dd,
.views-display dd a {
font-size: 8pt;
line-height: 12pt;
}
.views-display dd {
padding: 0 0 0 1.7em;
margin: 0;
text-indent: -1em;
}
#views-ajax-pad {
border: 1px solid black;
margin-top: 10px;
background: #E0E5E8;
margin-top: 0px;
min-height: 200px;
_height: 200px; /* stupid IE */
padding: 5px;
}
#views-ajax-pad .message {
margin-top: 75px;
padding-top: 75px;
text-align: center;
}
#views-ajax-pad form {
background: #ffd;
margin-left: 118px;
border: #5C707E 1px solid;
border-top: #D1D8DD 4px solid;
}
#views-ajax-pad .form-buttons {
float: right;
margin: 0;
padding: 0;
padding: 0.5em 1em;
border-top: #E0E5E8 1px solid;
background: #fff;
clear: left;
}
#views-ajax-pad .form-buttons .form-submit {
......@@ -135,13 +191,29 @@
}
#views-ajax-pad .form-item {
margin-top: 0;
margin: 0.5em;
padding: 0em 0.5em;
}
#views-ajax-pad {
display: none;
}
#views-ajax-title {
margin-left: 118px;
padding-left: 5px;
border-left: 1px solid black;
border-right: 1px solid black;
height: 1.5em;
white-space: nowrap;
overflow: hide;
font-weight: bold;
}
#views-ajax-form {
background-color: #E0E5E8;
}
html.js #views-ajax-pad {
display: block;
}
......@@ -189,3 +261,80 @@ html.js #views-ajax-pad {
overflow: auto;
max-height: 180px;
}
a.views-button-configure,
a.views-button-add,
a.views-button-rearrange,
a.views-button-remove {
background:transparent url(../images/sprites.png);
display: inline-block;
float: right;
height: 12px;
width: 16px;
margin: 2px 0px 1px 0px;
border: #666 1px solid;
}
a.views-button-remove {
background-position: 0px -72px;
position: relative;
top: -4px;
}
a.views-button-remove:hover {
background-position: 0px -84px;
}
a.views-button-configure {
background-position: 0px -48px;
margin: 0;
}
a.views-button-configure:hover {
background-position: 0px -60px;
}
a.views-button-add {
background-position: 0px -24px;
}
a.views-button-add:hover {
background-position: 0px -36px;
}
a.views-button-rearrange {
background-position: 0px 0px;
}
a.views-button-rearrange:hover {
background-position: 0px -12px;
}
a.views-button-remove span,
a.views-button-rearrange span,
a.views-button-configure span,
a.views-button-add span {
display: none;
}
html.js #arrange thead {
display: none;
}
html.js .views-remove-checkbox {
display: none;
}
a.views-button-remove {
display: none;
}
html.js a.views-button-remove {
display: inline;
}
#arrange tr.even,
#arrange tr.odd,
#arrange td {
padding-top: 0;
padding-bottom: 0;
}
#arrange .form-item {
padding: 0;
}
\ No newline at end of file
This diff is collapsed.
......@@ -13,7 +13,7 @@
/**
* Simple render function to make sure output is what we want.
*/
function views_ajax_render($output = NULL, $title = NULL, $url = NULL) {
function views_ajax_render($output = NULL, $title = NULL, $url = NULL, $js = NULL) {
if (empty($output)) {
$output->display = t('Server reports invalid input error.');
$output->title = t('Error');
......@@ -25,6 +25,10 @@ function views_ajax_render($output = NULL, $title = NULL, $url = NULL) {
$temp->url = $url;
$output = $temp;
}
if (!empty($js)) {
$output->js = $js;
}
drupal_set_header('Content-Type: text/javascript; charset=utf-8');
print drupal_to_js($output);
exit;
......@@ -89,7 +93,9 @@ function views_ajax_form($form_id) {
$output .= drupal_render_form($form_id, $form);
$title = empty($form['#title']) ? '' : $form['#title'];
$url = empty($form['#url']) ? url($_GET['q'], array('absolute' => TRUE)) : $form['#url'];
views_ajax_render($output, $title, $url);
$js = empty($form['#js']) ? NULL : $form['#js'];
views_ajax_render($output, $title, $url, $js);
}
/**
......
This diff is collapsed.
This diff is collapsed.
......@@ -866,6 +866,69 @@ class views_db_object {
$this->display[$id] = $display;
return $id;
}
/**
* Add an item with a handler to the view.
*
* These items may be fields, filters, sort criteria, or arguments.
*/
function add_item($display_id, $type, $table, $field) {
$types = views_object_types();
$this->init_display($display_id);
$fields = $this->display[$display_id]->handler->get_option($types[$type]['plural']);
$count = 0;
$id = $field;
while (!empty($fields[$id])) {
$id = $field . '_' . ++$count;
}
$object = new $types[$type]['object'];
$object->id = $id;
$object->table = $table;
$object->field = $field;
$handler = views_get_handler($table, $field, $type);
$handler->options($object);
$fields[$id] = $object;
$this->display[$display_id]->handler->set_option($types[$type]['plural'], $fields);
return $id;
}
/**
* Get the configuration of an item (field/sort/filter/etc) on a given
* display.
*/
function get_item($display_id, $type, $id) {
// Get info about the types so we can get the right data.
$types = views_object_types();
// Initialize the display
$this->init_display($display_id);
// Get the existing configuration
$fields = $this->display[$display_id]->handler->get_option($types[$type]['plural']);
return isset($fields[$id]) ? $fields[$id] : NULL;
}
/**
* Get the configuration of an item (field/sort/filter/etc) on a given
* display.
*/
function set_item($display_id, $type, $id, $item) {
// Get info about the types so we can get the right data.
$types = views_object_types();
// Initialize the display
$this->init_display($display_id);
// Get the existing configuration
$fields = $this->display[$display_id]->handler->get_option($types[$type]['plural']);
$fields[$id] = $item;
// Store.
$this->display[$display_id]->handler->set_option($types[$type]['plural'], $fields);
}
}
/**
......
......@@ -32,6 +32,13 @@ Drupal.Views.Ajax.ajaxResponse = function(data) {
alert(data.debug);
}
// See if we have any settings to extend. Do this first so that behaviors
// can access the new settings easily.
if (data.js) {
$.extend(Drupal.settings, data.js);
}
// Check the 'display' for data.
if (data.display) {
Drupal.Views.Ajax.setForm(data.title, data.display);
......@@ -89,8 +96,10 @@ Drupal.Views.Ajax.ajaxResponse = function(data) {
// Go through and add any requested tabs
if (data.tab) {
for (id in data.tab) {
console.log(data.tab[id]['title']);
$('#views-tabset').addTab(id, data.tab[id]['title'], 0);
$(id).html(data.tab[id]['body']);
$(id).addClass('views-tab');
Drupal.attachBehaviors(id);
// This is kind of annoying, but we have to actually to find where the new
......@@ -141,6 +150,6 @@ Drupal.behaviors.ViewsAjaxLinks = function() {
});
return false;
});
});
}
......@@ -8,4 +8,13 @@ Drupal.behaviors.viewsTabs = function (context) {
$('#views-tabset:not(.views-processed)').addClass('views-processed').tabs({
selectedClass: 'active'
});
$('a.views-remove-link')
.addClass('views-processed')
.click(function() {
var id = $(this).attr('id').replace('views-remove-link-', '');
$('#views-row-' + id).hide();
$('#views-removed-' + id).attr('checked', true);
return false;
});
}
......@@ -74,7 +74,7 @@ function node_views_data() {
),
// Information for accepting a nid as a filter
'filter' => array(
'handler' => 'views_handler_filter',
'handler' => 'views_handler_filter_equality',
),
// Information for sorting on a nid.
'sort' => array(
......@@ -222,7 +222,7 @@ class views_handler_field_node extends views_handler_field {
*/
function init(&$view, &$data) {
parent::init($view, $data);
if (isset($data->options['link_to_node']) && $view->base_table != 'node') {
if (isset($data->data->link_to_node) && $view->base_table != 'node') {
$this->additional_fields[] = $nid;
$this->nid_field = 'node_nid';
}
......@@ -234,16 +234,16 @@ class views_handler_field_node extends views_handler_field {
/**
* Provide link to node option
*/
function options_form(&$form) {
function options_form(&$form, &$form_state) {
$form['link_to_node'] = array(
'#title' => t('Link this field to its node'),
'#type' => 'checkbox',
'#default_value' => $this->data->options['link_to_node'],
'#default_value' => !empty($this->data->link_to_node),
);
}
function render_link($data, $values) {
if (!empty($this->data->options['link_to_node'])) {
if (!empty($this->data->link_to_node)) {
return l($data, "node/" . $values->{$this->node_field}, array('html' => TRUE));
}
else {
......@@ -324,6 +324,89 @@ class views_handler_argument_node_nid extends views_handler_argument {
}
}
/**
* Argument handler for a year (CCYY)
*/
class views_handler_argument_node_date_year extends views_handler_argument_formula {
/**
* Constructor implementation
*
* @todo node.created should instead know about table aliases otherwise this
* will explode in relationships.
*/
function construct() {
$timezone = views_get_timezone();
$this->formula = "YEAR(FROM_UNIXTIME(node.created+$timezone))";
}
/**
* Provide a link to the next level of the view
*/
function summary_link($data, $url) {
$value = $data->{$this->base_alias};
return l($value, "$url/$value");
}
}
/**
* Argument handler for a year plus month (CCYYMM)
*/
class views_handler_argument_date_year_month extends views_handler_argument_formula {
/**
* Constructor implementation
*/
function construct() {
$timezone = views_get_timezone();
$this->formula = "DATE_FORMAT(FROM_UNIXTIME(node.created+$timezone), '%Y%m')";
$this->format = 'F, Y';
}
/**
* Provide a link to the next level of the view
*/
function summary_link($data, $url) {
$value = $data->{$this->base_alias};
$created = $data->{$this->name_alias};
return l(format_date($created, 'custom', $this->format), "$url/$value");
}
/**
* Provide a link to the next level of the view
*/
function title($data, $url) {
return format_date(strtotime($this->argument . "15"), 'custom', $this->format, 0);
}
}
/**
* Argument handler for a month (MM)
*/
class views_handler_argument_date_month extends views_handler_argument_formula {
/**
* Constructor implementation
*/
function construct() {
$timezone = views_get_timezone();
$this->formula = "MONTH(FROM_UNIXTIME(node.created+$timezone))";
$this->format = 'F';
}
/**
* Provide a link to the next level of the view
*/
function summary_link($data, $url) {
$value = $data->{$this->base_alias};
$created = $data->{$this->name_alias};
return l(format_date($created, 'custom', $this->format), "$url/$value");
}
/**
* Provide a link to the next level of the view
*/
function title($data, $url) {
return format_date(strtotime("2005" . $this->argument . "15"), 'custom', $this->format, 0);
}
}
/**
* Implementation of hook_views_plugins
......
......@@ -447,29 +447,22 @@ function views_get_plugin($type, $plugin) {
* A keyed array of in the form of 'base_table' => 'Description'.
*/
function views_fetch_plugin_names($type, $key = NULL, $empty = FALSE) {
static $plugins = array();
if (empty($plugins)) {
$data = views_fetch_plugin_data();
foreach ($data as $plugin_type => $plugs) {
// Skip some info data
if (!is_array($plugs)) {
continue;
}
foreach ($plugs as $id => $plugin) {
// Skip plugins that don't conform to our key.
if ($key && (($empty && empty($plugin[$key])) || (!$empty && !empty($plugin[$key])))) {
continue;
}
if (empty($plugin['no ui'])) {
$plugins[$plugin_type][$id] = $plugin['title'];
}
}
asort($plugins[$plugin_type]);
$data = views_fetch_plugin_data();
$plugins[$type] = array();
foreach ($data[$type] as $id => $plugin) {
// Skip plugins that don't conform to our key.
if ($key && (($empty && empty($plugin[$key])) || (!$empty && !empty($plugin[$key])))) {
continue;
}
if (empty($plugin['no ui'])) {
$plugins[$type][$id] = $plugin['title'];
}
}
if (!empty($plugins[$type])) {
asort($plugins[$type]);
return $plugins[$type];
}
// fall-through
......@@ -708,4 +701,39 @@ function vsm($message) {
if (module_exists('devel')) {
dsm($message);
}
}
\ No newline at end of file
}
function views_object_types() {
return array(
'field' => array(
'title' => t('Fields'),
'stitle' => t('Field'),
'plural' => 'fields',
'object' => 'views_field',
),
'argument' => array(
'title' => t('Arguments'),
'stitle' => t('Argument'),
'plural' => 'arguments',
'object' => 'views_argument',
),
'sort' => array(
'title' => t('Sort criteria'),
'stitle' => t('Sort criterion'),
'plural' => 'sorts',
'object' => 'views_sort',
),
'filter' => array(
'title' => t('Filters'),
'stitle' => t('Filter'),
'plural' => 'filters',
'object' => 'views_filter',
),
'relationship' => array(
'title' => t('Relationships'),
'stitle' => t('Relationship'),
'plural' => 'relationships',
'object' => 'views_relationship',
),
);
}
......@@ -78,18 +78,31 @@ function views_ui_menu() {
'page arguments' => array(3, 5),
);
$items['admin/build/views/%views_ui_js/rearrange/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_rearrange_section',
'page callback' => 'views_ui_rearrange_type',
'page arguments' => array(3, 5),
);
$items['admin/build/views/%views_ui_js/add-item/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_add_item',
'page arguments' => array(3, 5),
);
$items['admin/build/views/%views_ui_js/config-item/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_config_item',
'page arguments' => array(3, 5),
);
// display specific parameters
$items['admin/build/views/%views_ui_js/display/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_edit_display',
'page arguments' => array(3, 5),
);
// Special style plugin stuff for arguments
$items['admin/build/views/%views_ui_js/change-style/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_change_style',
'page arguments' => array(3, 5),
);
$items['admin/build/views/%views_ui_js/config-style/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_config_style',
'page arguments' => array(3, 5),
);
return $items;
}
......@@ -106,6 +119,10 @@ function views_ui_theme() {
'arguments' => array('form'),
'file' => '/includes/admin.inc',
),
'views_ui_rearrange_form' => array(
'arguments' => array('form'),
'file' => '/includes/admin.inc',
),
'views_tabset' => array(
'arguments' => array('tabs'),
'file' => '/includes/tabs.inc',
......
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