Skip to content

Commit

Permalink
Refactoring coffee
Browse files Browse the repository at this point in the history
  • Loading branch information
rumidier committed Nov 28, 2012
1 parent d7b85a3 commit ca20e90
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 127 deletions.
69 changes: 10 additions & 59 deletions root/static/scripts/list.coffee
@@ -1,68 +1,19 @@
$ ->
$('#head_checkbox').click ->
cbs = $(":checkbox")
for cb,i in cbs
if cbs[i].type is "checkbox"
cbs[i].checked = $(@).is(':checked')

$('#do_delete').click ->
selected_charges = []

$('#charge_list tr').filter(':has(:checkbox:checked)').each ->
if $(@).attr('id') isnt undefined
selected_charges.push($(@).attr('id'))

location.href = '/list/delete/' + selected_charges

$('#do_approval').click ->
selected_charges = []

$('#charge_list tr').filter(':has(:checkbox:checked)').each ->
if $(@).attr('id') isnt undefined
selected_charges.push($(@).attr('id'))

location.href = '/list/approval/' + selected_charges

$('#do_refuse').click ->
selected_charges = []

$('#charge_list tr').filter(':has(:checkbox:checked)').each ->
if $(@).attr('id') isnt undefined
selected_charges.push($(@).attr('id'))

location.href = '/list/refuse/' + selected_charges

$('#do_deposit').click ->
selected_charges = []

$('#charge_list tr').filter(':has(:checkbox:checked)').each ->
if $(@).attr('id') isnt undefined
selected_charges.push($(@).attr('id'))

location.href = '/list/deposit/' + selected_charges

$('#do_export').click ->
selected_charges = []

$('#charge_list tr').filter(':has(:checkbox:checked)').each ->
if $(@).attr('id') isnt undefined
selected_charges.push($(@).attr('id'))

location.href = '/list/export/' + selected_charges

$('#do_cancel').click ->
$('#head_checkobx').click ->
flag = $(@).is(':checked')
$(':checkbox').each ->
if flag then $(@).attr('checked', 'checked')
else $(@).removeAttr('checked')

$('.btn').click ->
select_id = $(@).attr("id").substring(3)
selected_charges = []

$('#charge_list tr').filter(':has(:checkbox:checked)').each ->
if $(@).attr('id') isnt undefined
selected_charges.push($(@).attr('id'))

location.href = '/list/cancel/' + selected_charges

window.prettyPrint and prettyPrint()
$('#start_date').datepicker
format: 'yyyy-mm-dd'
location.href = "/list/#{select_id}/#{selected_charges}"

window.prettyPrint and prettyPrint()
$('#end_date').datepicker
$('#start_date, #end_date').datepicker
format: 'yyyy-mm-dd'
80 changes: 12 additions & 68 deletions root/static/scripts/list.js

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

0 comments on commit ca20e90

Please sign in to comment.