click handler logic for menus

This commit is contained in:
Max Ogden
2011-07-02 16:06:19 -07:00
parent 770210a45b
commit 9ce27dddda
12 changed files with 72 additions and 118 deletions

View File

@@ -4,6 +4,31 @@ var removalist = function() {
return (parseFloat(bytes)/1024/1024).toString().substr(0,4) + "MB"
}
function handleMenuClick() {
$( '.menu .csv' ).click(function( e ) {
window.location.href = app.csvUrl;
e.preventDefault();
})
$( '.menu .transform' ).click(function( e ) {
$('.dialog-overlay').show();
$('.dialog-container').show();
util.render('bulkEdit', 'dialog-content');
$('.cancelButton').click(function(e) {
$('.dialog-overlay').hide();
$('.dialog-container').hide();
})
$('.menu').hide();
$('.menu-overlay').hide();
e.preventDefault();
})
$( '.menu li' ).click(function() {
$('.menu').hide();
$('.menu-overlay').hide();
})
}
function renderRows(response) {
var rows = response.rows;
@@ -125,6 +150,7 @@ var removalist = function() {
return {
formatDiskSize: formatDiskSize,
handleMenuClick: handleMenuClick,
bootstrap: bootstrap,
fetchRows: fetchRows,
activateControls: activateControls,

View File

@@ -15,24 +15,6 @@ app.handler = function(route) {
app.routes = {
home: function() {
removalist.bootstrap();
$( '.csv' ).live('click', ( function( e ) {
window.location.href = app.csvUrl;
e.preventDefault();
}))
$( '.transform' ).live('click', ( function( e ) {
$('.dialog-overlay').show();
$('.dialog-container').show();
util.render('bulkEdit', 'dialog-content');
$('.cancelButton').click(function(e) {
$('.dialog-overlay').hide();
$('.dialog-container').hide();
})
$('.menu').hide();
$('.menu-overlay').hide();
e.preventDefault();
}))
},
page: function(id) {
removalist.getPageSize();
@@ -44,15 +26,19 @@ app.after = {
removalist.activateControls();
},
dataTable: function() {
$('.column-header-menu').click(function(e) {
var offset = $(e.target).offset();
$('.menu-overlay').show().click(function(e) {
$(e.target).hide();
$('.menu').hide();
});
$('.menu').show().css({top: offset.top + 20, left: offset.left});
})
}
$('.column-header-menu').click(function(e) {
util.show('menu', e);
util.render('columnActions', 'menu');
});
},
actions: function() {
$('.button').click(function(e) {
util.show('menu', e, {left: -60});
util.render('exportActions', 'menu');
});
},
exportActions: removalist.handleMenuClick,
columnActions: removalist.handleMenuClick
}
app.sammy = $.sammy(function () {

View File

@@ -23,6 +23,19 @@ var util = function() {
}
return exists;
}
function show( thing, elem, offset ) {
var position = $(elem.target).offset();
if (offset) {
if (offset.top) position.top += offset.top;
if (offset.left) position.left += offset.left;
}
$('.' + thing + '-overlay').show().click(function(e) {
$(e.target).hide();
$('.' + thing).hide();
});
$('.' + thing).show().css({top: position.top + $(elem.target).height(), left: position.left});
}
function render( template, target, options ) {
if ( !options ) options = {data: {}};
@@ -122,6 +135,7 @@ var util = function() {
return {
inURL: inURL,
show: show,
render: render,
formatMetadata:formatMetadata,
getBaseURL:getBaseURL,