-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
John Laniba
committed
Aug 23, 2011
1 parent
a8f3d22
commit 10b42ec
Showing
11 changed files
with
457 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
class Autopopulate extends CI_Controller { | ||
|
||
function index() | ||
{ | ||
$this->load->model('Populate'); | ||
|
||
$query = $this->Populate->get(null, 'blank'); | ||
$data['tests'] = $this->formatArrayToIdName($query->result_array()); | ||
|
||
$this->load->view('autopopulate', $data); | ||
} | ||
|
||
function json() { | ||
$this->load->model('Populate'); | ||
|
||
$id = $this->uri->segment(4); | ||
$id = explode('-', $id); | ||
|
||
$query = $this->Populate->get(null, $id); | ||
$data['content'] = $this->formatArrayToIdName($query->result_array()); | ||
$this->load->view('json', $data); | ||
} | ||
|
||
private function formatArrayToIdName($data) { | ||
$result = array(); | ||
foreach ($data as $row) { | ||
$result[$row['id']] = $row['name']; | ||
} | ||
return $result; | ||
} | ||
|
||
function page_not_found() | ||
{ | ||
show_404('page'); | ||
} | ||
|
||
} | ||
?> |
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,39 @@ | ||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); | ||
class Populate extends CI_Model | ||
{ | ||
function _construct() | ||
{ | ||
parent::_construct(); | ||
} | ||
|
||
function get($id = null, $parent = null) | ||
{ | ||
|
||
if ($id) { | ||
if (is_array($id)) { | ||
$this->db->where_in('id', $id); | ||
} else { | ||
$this->db->where('id', $id); | ||
} | ||
} | ||
|
||
if ($parent) { | ||
//get data if parent is null | ||
if ($parent == 'blank') { | ||
$condition = null; | ||
} else { | ||
$condition = $parent; | ||
} | ||
|
||
if (is_array($condition)) { | ||
$this->db->where_in('parent_id', $condition); | ||
} else { | ||
$this->db->where('parent_id', $condition); | ||
} | ||
} | ||
|
||
return $this->db->get('autopopulate'); | ||
} | ||
|
||
} | ||
?> |
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,103 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>jQuery Auto Populate Box</title> | ||
<base href="<?php echo substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], "/")+1); ?>" /> | ||
<link href="css/demo.css" rel="stylesheet" type="text/css" /> | ||
<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script> | ||
<script src="js/jquery.autopopulatebox.js" type="text/javascript"></script> | ||
</head> | ||
<body> | ||
|
||
<h1>jQuery Auto Populate Box!</h1> | ||
|
||
<h3 style="padding-bottom: 20px;">Sample 1</h3> | ||
|
||
<div class="input clearfix"> | ||
<label for="tests">Tests</label> | ||
<select id="tests" name="test"> | ||
<option value="">(select)</option> | ||
<?php foreach ($tests as $key => $test): ?> | ||
<option value="<?php echo $key; ?>"> <?php echo $test; ?> </option> | ||
<?php endforeach; ?> | ||
</select> | ||
</div> | ||
|
||
<div class="input clearfix"> | ||
<label for="categories">Categories</label> | ||
<select id="categories" name="category"> | ||
<option value="">(select)</option> | ||
</select> | ||
</div> | ||
|
||
<div class="input clearfix"> | ||
<label for="contents">Contents</label> | ||
<select id="contents" name="content"> | ||
<option value="">(select)</option> | ||
</select> | ||
</div> | ||
<script> | ||
jQuery(function($) { | ||
$('#tests').autoPopulateBox({ | ||
emptyLabel: '(select)', | ||
url: 'index.php/autopopulate/json/', | ||
allSeparator: '/', | ||
change: 'category', | ||
|
||
category: { | ||
target: '#categories', | ||
change: 'content' | ||
}, | ||
content: { | ||
target: '#contents' | ||
} | ||
}); | ||
}); | ||
</script> | ||
<br /><br /> | ||
|
||
|
||
<h3 style="padding-bottom: 20px;" id="sample2">Sample 2</h3> | ||
|
||
<div class="clearfix"> | ||
<div class="multiple"> | ||
<label for="tests2">Tests</label> | ||
<select id="tests2" name="test2" multiple="multiple"> | ||
<?php foreach ($tests as $key => $test): ?> | ||
<option value="<?php echo $key; ?>"> <?php echo $test; ?> </option> | ||
<?php endforeach; ?> | ||
</select> | ||
</div> | ||
|
||
<div class="multiple"> | ||
<label for="categories2">Categories</label> | ||
<select id="categories2" name="category" multiple="multiple"></select> | ||
</div> | ||
|
||
<div class="multiple"> | ||
<label for="contents2">Contents</label> | ||
<select id="contents2" name="content" multiple="multiple"></select> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
jQuery(function($) { | ||
$('#tests2').autoPopulateBox({ | ||
url: 'index.php/autopopulate/json/', | ||
allSeparator: '/', | ||
change: 'category2', | ||
|
||
category2: { | ||
target: '#categories2', | ||
change: 'content2' | ||
}, | ||
content2: { | ||
target: '#contents2' | ||
} | ||
}); | ||
}); | ||
</script> | ||
|
||
</body> | ||
</html> |
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 @@ | ||
<?php echo json_encode($content); ?> |
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,80 @@ | ||
body { | ||
background-color: #fff; | ||
margin: 40px; | ||
font-family: Lucida Grande, Verdana, Sans-serif; | ||
font-size: 14px; | ||
color: #4F5155; | ||
} | ||
|
||
a { | ||
color: #003399; | ||
background-color: transparent; | ||
font-weight: normal; | ||
} | ||
|
||
h1 { | ||
color: #444; | ||
background-color: transparent; | ||
border-bottom: 1px solid #D0D0D0; | ||
font-size: 16px; | ||
font-weight: bold; | ||
margin: 24px 0 2px 0; | ||
padding: 5px 0 6px 0; | ||
} | ||
|
||
code { | ||
font-family: Monaco, Verdana, Sans-serif; | ||
font-size: 12px; | ||
background-color: #f9f9f9; | ||
border: 1px solid #D0D0D0; | ||
color: #002166; | ||
display: block; | ||
margin: 14px 0 14px 0; | ||
padding: 12px 10px 12px 10px; | ||
} | ||
|
||
.input { | ||
font-size: 1.2em; | ||
line-height: 1em; | ||
padding-bottom: 10px; | ||
} | ||
.input label { | ||
float: left; | ||
display: block; | ||
width: 120px; | ||
} | ||
.input select { | ||
float: left; | ||
display: block; | ||
} | ||
|
||
.multiple { | ||
float: left; | ||
} | ||
.multiple label { | ||
display: block; | ||
width: 140px; | ||
} | ||
.multiple select { | ||
min-width: 120px; | ||
} | ||
|
||
/* clearfix */ | ||
.clearfix:after { | ||
content: "."; | ||
display: block; | ||
height: 0; | ||
clear: both; | ||
visibility: hidden; | ||
} | ||
.clearfix { | ||
display: inline-block; | ||
} | ||
/* required comment for clearfix to work in Opera \*/ | ||
* html .clearfix { | ||
height:1%; | ||
} | ||
.clearfix { | ||
display:block; | ||
} | ||
/* end clearfix */ |
Oops, something went wrong.