Skip to content

Commit

Permalink
Loading indicator for "more options" buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Dec 13, 2012
1 parent 7e46290 commit aed58a5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
10 changes: 6 additions & 4 deletions admin/css/screen.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 24 additions & 9 deletions admin/javascript/LeftAndMain.ActionTabSet.js
Expand Up @@ -24,6 +24,19 @@
this.tabs({'collapsible': true, 'active': false});
},

onremove: function() {
// Remove all bound events.
// This guards against an edge case where the click handlers are not unbound
// because the panel is still open when the ajax edit form reloads.
var frame = $('.cms').find('iframe');
frame.each(function(index, iframe){
$(iframe).contents().off('click.ss-ui-action-tabset');
});
$(document).off('click.ss-ui-action-tabset');

this._super();
},

/**
* Deal with available vertical space
*/
Expand Down Expand Up @@ -53,27 +66,29 @@
var panel, frame;
panel = $(event.target).closest('.ss-ui-action-tabset .ui-tabs-panel');

// If anything except the ui-nav button is clicked,
// close panel and remove handler
if (!$(event.target).closest(that).length || $(panel).length) {
// If anything except the ui-nav button or panel is clicked,
// close panel and remove handler. We can't close if click was
// within panel, as it might've caused a button action,
// and we need to show its loading indicator.
if (!$(event.target).closest(that).length && !panel.length) {
that.tabs('option', 'active', false); // close tabs

// remove click event from objects it is bound to (iframe's and document)
frame = $('.cms').find('iframe');
frame.each(function(index, iframe){
$(iframe).contents().off('click', closeHandler);
$(iframe).contents().off('click.ss-ui-action-tabset', closeHandler);
});
$(document).off('click', closeHandler);
$(document).off('click.ss-ui-action-tabset', closeHandler);
}
};

// Bind click event to document, and use closeHandler to handle the event
$(document).on('click', closeHandler);
$(document).on('click.ss-ui-action-tabset', closeHandler);
// Make sure iframe click also closes tab
// iframe needs a special case, else the click event will not register here
if(frame.length > 0){
frame.each(function(index, iframe) {
$(iframe).contents().on('click', closeHandler);
$(iframe).contents().on('click.ss-ui-action-tabset', closeHandler);
});
}
},
Expand Down Expand Up @@ -131,7 +146,7 @@
*/
'ontabsbeforeactivate': function(event, ui) {
this._super(event, ui);
//Set the position of the opening tab (if it exists)
//Set the position of the opening tab (if it exists)
if($(ui.newPanel).length > 0){
$(ui.newPanel).css('left', ui.newTab.position().left+"px");
}
Expand Down Expand Up @@ -211,7 +226,7 @@
this._super(event, ui);
// Reset position of tabs, else anyone going between the large
// and the small sitetree will see broken tabs
// Apply styles with .css, to avoid overriding currently applied styles
// Apply styles with .css, to avoid overriding currently applied styles
$(ui.newPanel).css({'left': 'auto', 'right': 'auto'});

if($(ui.newPanel).length > 0){
Expand Down
2 changes: 1 addition & 1 deletion admin/scss/_actionTabs.scss
Expand Up @@ -302,7 +302,7 @@ $border: 1px solid darken(#D9D9D9, 15%);
}
}
button.ss-ui-button{
width:100%;
width: 100%;
&:hover, &:focus, &:active{
@include box-shadow(none);
background-color: darken($tab-panel-texture-color,4%);
Expand Down
8 changes: 8 additions & 0 deletions admin/scss/_forms.scss
Expand Up @@ -313,6 +313,14 @@ form.small .field, .field.small {
background:none;
border:none;
}
&.loading {
background: transparent url(../../images/network-save.gif) no-repeat $grid-x center;
.ui-button-text {
padding-left: 16px /* icon */ + ($grid-x/2);
}


}
}
}

Expand Down

0 comments on commit aed58a5

Please sign in to comment.