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

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

View File

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

View File

@@ -24,7 +24,17 @@ var util = function() {
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();
if (offset) {
if (offset.top) position.top += offset.top;
@@ -136,6 +146,8 @@ var util = function() {
return {
inURL: inURL,
show: show,
hide: hide,
position: position,
render: render,
formatMetadata:formatMetadata,
getBaseURL:getBaseURL,