-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from codeforamerica/admin-interface
Add Admin interface to API app
- Loading branch information
Showing
218 changed files
with
5,411 additions
and
492 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
var main = (function () { | ||
"use strict"; | ||
|
||
var NUM_LEVELS = 2; | ||
|
||
// initalize the application | ||
function init() | ||
{ | ||
var checkboxes = $('#categories input'); | ||
|
||
var currentCheckbox; | ||
for (var i=0; i < checkboxes.length; i++) | ||
{ | ||
currentCheckbox = checkboxes[i]; | ||
_checkState('depth',0,currentCheckbox); | ||
} | ||
|
||
var lnks = $('#categories input'); | ||
|
||
var curr; | ||
for (var l=0; l < lnks.length; l++) | ||
{ | ||
curr = lnks[l]; | ||
$(curr).click(_linkClickedHandler) | ||
} | ||
} | ||
|
||
function _linkClickedHandler(evt) | ||
{ | ||
var el = evt.target; | ||
if (el.nodeName == 'INPUT') | ||
{ | ||
_checkState('depth',0,el); | ||
} | ||
|
||
} | ||
|
||
function _checkState(prefix,depth,checkbox) | ||
{ | ||
var item = $(checkbox).parent(); // parent li item | ||
var id = prefix+String(depth); | ||
while(!item.hasClass(id)) | ||
{ | ||
depth++; | ||
id = prefix+String(depth); | ||
} | ||
|
||
id = 'li.'+prefix+String(depth+1); | ||
var lnks = $(id,item); | ||
var curr; | ||
for (var l=0; l < lnks.length; l++) | ||
{ | ||
curr = lnks[l]; | ||
if (checkbox.checked) | ||
{ | ||
$(curr).removeClass('hide'); | ||
} | ||
else | ||
{ | ||
$(curr).addClass('hide'); | ||
checkbox = $('input',$(curr)) | ||
checkbox.prop('checked', false); | ||
_checkState(prefix,depth,checkbox) | ||
} | ||
} | ||
|
||
} | ||
|
||
// return internally scoped var as value of globally scoped object | ||
return { | ||
init:init | ||
}; | ||
|
||
})(); | ||
|
||
$(document).ready(function(){ | ||
main.init(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ | |
//= require jquery | ||
//= require jquery_ujs | ||
//= require bootstrap | ||
//= require bootstrap-modal | ||
//= require_tree . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
jQuery -> | ||
$('.edit_entry').on 'click', '.delete_association', (event) -> | ||
$(this).prevAll('input[type=hidden]').val('1') | ||
$(this).closest('fieldset').hide() | ||
event.preventDefault() | ||
|
||
$('.edit_entry').on 'click', '.delete_attribute', (event) -> | ||
$(this).closest('fieldset').find('input').val('') | ||
$(this).closest('fieldset').hide() | ||
event.preventDefault() | ||
|
||
$('.edit_entry').on 'click', '.add_fields', (event) -> | ||
time = new Date().getTime() | ||
regexp = new RegExp($(this).data('id'), 'g') | ||
$(this).before($(this).data('fields').replace(regexp, time)) | ||
event.preventDefault() | ||
|
||
$('.edit_entry').on 'click', '.add_array_fields', (event) -> | ||
time = new Date().getTime() | ||
$(this).before($(this).data('fields')) | ||
inputs = $(this).parent().find('input') | ||
inputs[inputs.length - 1].setAttribute('id', time) | ||
event.preventDefault() |
Oops, something went wrong.