refactoring show/hide/position functions

This commit is contained in:
Max Ogden 2011-07-02 16:28:59 -07:00
parent a9d4117b24
commit f48f8dbffa
5 changed files with 24 additions and 20 deletions

View File

@ -37,7 +37,7 @@
</div> </div>
<div class="dialog-overlay" style="display: none; z-index: 101; ">&nbsp;</div> <div class="dialog-overlay" style="display: none; z-index: 101; ">&nbsp;</div>
<div class="dialog-container ui-draggable" style="display: none; z-index: 102; top: 101px; "> <div class="dialog ui-draggable" style="display: none; z-index: 102; top: 101px; ">
<div class="dialog-frame" style="width: 700px; visibility: visible; "> <div class="dialog-frame" style="width: 700px; visibility: visible; ">
<div id="dialog-content" class="dialog-border"> <div id="dialog-content" class="dialog-border">
@ -76,7 +76,7 @@
<script type='text/mustache' id="exportActionsTemplate"> <script type='text/mustache' id="exportActionsTemplate">
<li><a class="csv" href="JavaScript:void(0);">CSV</a></li> <li><a class="csv" href="JavaScript:void(0);">CSV</a></li>
<li><a class="csv" href="JavaScript:void(0);">JSON</a></li> <li><a class="json" href="JavaScript:void(0);">JSON</a></li>
</script> </script>
<script type='text/mustache' id="columnActionsTemplate"> <script type='text/mustache' id="columnActionsTemplate">

View File

@ -7,29 +7,21 @@ var removalist = function() {
function handleMenuClick() { function handleMenuClick() {
$( '.menu li' ).click(function(e) { $( '.menu li' ).click(function(e) {
if ($(e.target).hasClass('transform')) { if ($(e.target).hasClass('transform')) {
$('.dialog-overlay').show(); util.show('dialog');
$('.dialog-container').show();
util.render('bulkEdit', 'dialog-content'); util.render('bulkEdit', 'dialog-content');
$('.cancelButton').click(function(e) { $('.cancelButton').click(function(e) {
$('.dialog-overlay').hide(); util.hide('dialog');
$('.dialog-container').hide();
}) })
$('.menu').hide(); util.hide('menu');
$('.menu-overlay').hide();
} }
if ($(e.target).hasClass('csv')) { if ($(e.target).hasClass('csv')) window.location.href = app.csvUrl;
window.location.href = app.csvUrl;
}
if ($(e.target).hasClass('json')) { if ($(e.target).hasClass('json')) window.location.href = "_rewrite/api/json";
window.location.href = app.csvUrl;
}
e.preventDefault(); e.preventDefault();
$('.menu').hide(); util.hide('menu');
$('.menu-overlay').hide();
}) })
} }

View File

@ -27,13 +27,13 @@ app.after = {
}, },
dataTable: function() { dataTable: function() {
$('.column-header-menu').click(function(e) { $('.column-header-menu').click(function(e) {
util.show('menu', e); util.position('menu', e);
util.render('columnActions', 'menu'); util.render('columnActions', 'menu');
}); });
}, },
actions: function() { actions: function() {
$('.button').click(function(e) { $('.button').click(function(e) {
util.show('menu', e, {left: -60}); util.position('menu', e, {left: -60});
util.render('exportActions', 'menu'); util.render('exportActions', 'menu');
}); });
}, },

View File

@ -24,7 +24,17 @@ var util = function() {
return exists; return exists;
} }
function show( thing, elem, offset ) { function show( thing ) {
$('.' + thing ).show();
$('.' + thing + '-overlay').show();
}
function hide( thing ) {
$('.' + thing ).hide();
$('.' + thing + '-overlay').hide();
}
function position( thing, elem, offset ) {
var position = $(elem.target).offset(); var position = $(elem.target).offset();
if (offset) { if (offset) {
if (offset.top) position.top += offset.top; if (offset.top) position.top += offset.top;
@ -136,6 +146,8 @@ var util = function() {
return { return {
inURL: inURL, inURL: inURL,
show: show, show: show,
hide: hide,
position: position,
render: render, render: render,
formatMetadata:formatMetadata, formatMetadata:formatMetadata,
getBaseURL:getBaseURL, getBaseURL:getBaseURL,

View File

@ -877,7 +877,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
opacity: 0.5; opacity: 0.5;
} }
.dialog-container { .dialog {
position: fixed; position: fixed;
left: 0; left: 0;
width: 100%; width: 100%;