Skip to content

Commit

Permalink
added advanced fieldset behaviour for fiber admin page form
Browse files Browse the repository at this point in the history
  • Loading branch information
Niels van Dijk committed Jun 4, 2012
1 parent 23edbbf commit 7967774
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 5 deletions.
6 changes: 4 additions & 2 deletions fiber/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ def __init__(self, *args, **kwargs):
# remove template choices if there are no choices
if len(TEMPLATE_CHOICES) == 0:
self.fieldsets = (
(None, {'fields': ('title', 'url', 'redirect_page')}),
(None, {'fields': ('title', 'url', )}),
(_('Advanced options'), {'fields': ('redirect_page', 'show_in_menu', 'is_public', )}),
)
else:
self.fieldsets = (
(None, {'fields': ('title', 'url', 'template_name', 'redirect_page')}),
(None, {'fields': ('title', 'url', 'template_name', )}),
(_('Advanced options'), {'fields': ('redirect_page', 'show_in_menu', 'is_public', )}),
)

def save_model(self, request, obj, form, change):
Expand Down
48 changes: 46 additions & 2 deletions fiber/static/fiber/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,11 @@ div.ui-dialog form select,
clear: none;
}

div.ui-dialog form input[type="checkbox"] {
float: left;
margin-left: 0;
}

div.ui-dialog form select {
font-size: 13px;
padding: 3px;
Expand Down Expand Up @@ -449,6 +454,30 @@ div.ui-dialog form h2 {
font-size: 100%;
}

.ui-dialog form .advanced-button {
display: block;
margin: 0 -15px;
padding: 3px 15px;
font-weight: bold;
line-height: 21px;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.ui-dialog form .advanced-button .toggler {
display: block;
float: left;
margin: 7px 4px;
width: 8px;
height: 8px;
background: transparent url(../images/arrow-down.png) no-repeat left top;
text-indent: -9000px;
}

.ui-dialog form .advanced-button.closed .toggler {
margin-top: 6px;
background-image: url(../images/arrow-right.png);
}

.ui-dialog .hide-label {
margin: 0;
}
Expand Down Expand Up @@ -564,6 +593,21 @@ span.nobr {
}

.df-admin #page_form {
overflow: hidden;
padding: 0 15px;
width: 295px;
}

.df-admin #page_form fieldset {
margin: 0;
padding: 10px 0;
}

.df-admin #page_form fieldset p.help {
margin: 0;
}

.df-admin #page_form fieldset input[type="text"] {
width: 287px;
}

Expand Down Expand Up @@ -616,7 +660,7 @@ span.nobr {
text-indent: -9999px;
}

.ui-dialog-content ul.tree .toggler {
.ui-dialog-content ul.tree .toggler {
background-position: 0 6px;
}

Expand Down Expand Up @@ -656,7 +700,7 @@ ul.tree .toggler.closed,
background-image: url(../js/jqtree/treeRightTriangleBlack.png);
}

ul.tree .toggler.closed {
ul.tree .toggler.closed {
background-position: 0 5px;
}

Expand Down
Binary file added fiber/static/fiber/images/arrow-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fiber/static/fiber/images/arrow-right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 35 additions & 1 deletion fiber/static/fiber/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Fiber.enhance_jsontextarea = function(textarea) {
current_json = {};
}
if ($(this).val()) {
current_json[$(this).parent('td').parent('tr').attr('key-data')] = $(this).val();
current_json[$(this).parent('td').parent('tr').attr('key-data')] = $(this).val();
} else {
delete current_json[$(this).parent('td').parent('tr').attr('key-data')];
}
Expand Down Expand Up @@ -208,6 +208,39 @@ var AdminDialog = Class.extend({
this.uiDialog.dialog('option', 'position', ['center', 40]);
},

advanced_fieldset_behaviour: function() {
var advancedFieldsets = this.admin_form.form.find('fieldset:not(fieldset:first-child)');
if (advancedFieldsets.length > 0) {

advancedFieldsets.each(function() {
var fieldset = $(this),
button = $('<a>');

fieldset
.addClass('advanced-fieldset')
.hide();

button
.attr('href', '#')
.text(fieldset.find('h2').text())
.addClass('ui-dialog-buttonpane advanced-button closed')
.click(function(e) {
e.preventDefault();
$(this).toggleClass('closed')
fieldset.slideToggle('fast');
})
.insertBefore(fieldset);

$('<span>')
.text('»')
.addClass('toggler')
.prependTo(button);

fieldset.find('h2').remove();
});
}
},

cancel_click: function() {
this.close();
},
Expand Down Expand Up @@ -466,6 +499,7 @@ var ChangeFormDialog = AdminFormDialog.extend({
});
this.admin_form.admin_form_load_success = $.proxy(function() {
this.append_form();
this.advanced_fieldset_behaviour();
this.redraw();
}, this);
this.admin_form.load();
Expand Down

0 comments on commit 7967774

Please sign in to comment.