Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

116 fix select2 #139

Merged
merged 6 commits into from
Dec 31, 2015
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions churchinfo/Include/Header-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,10 @@ function Header_body_menu() {
</div>
<!-- search form -->
<form action="#" method="get" class="sidebar-form">
<div class="input-group">
<input type="text" class="form-control multiSearch" placeholder="Search..." onfocus="ClearFieldOnce(this);"/>
<span class="input-group-btn">
<button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i></button>
</span>
</div>

<select class="form-control multiSearch" style="width:100%">
</select>

</form>
<!-- /.search form -->
<!-- sidebar menu: : style can be found in sidebar.less -->
Expand Down
9 changes: 8 additions & 1 deletion churchinfo/Include/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="<?= $sURLPath; ?>/vendor/AdminLTE/dist/css/skins/_all-skins.min.css">


<link rel="stylesheet" href="/vendor/AdminLTE/plugins/select2/select2.min.css">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to prefix with the sURLPath... as we may not be always at the root of the server...



<!-- jQuery 2.1.4 -->
<script src="<?= $sURLPath; ?>/vendor/AdminLTE/plugins/jQuery/jQuery-2.1.4.min.js"></script>

<!-- jQuery 2.1.4 -->
<script src="<?= $sURLPath; ?>/vendor/AdminLTE/plugins/jQueryUI/jquery-ui.min.js"></script>

<!-- AdminLTE Select2 -->
<script src="/vendor/AdminLTE/plugins/select2/select2.full.min.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same




<?php Header_head_metatag(); ?>
Expand Down
73 changes: 38 additions & 35 deletions churchinfo/js/Footer.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
$.widget( "custom.catcomplete", $.ui.autocomplete, {
_create: function() {
this._super();
this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
},
_renderMenu: function( ul, items ) {
var that = this;
$.each(items, function( index, item ) {
var li;
ul.append( "<li class='ui-autocomplete-category'>" + Object.keys(item)[0]+ "</li>" );
$.each(item[Object.keys(item)[0]], function (subindex,subitem) {
li = that._renderItemData( ul, {label: subitem.displayName,value: subitem.uri} );
});
});
}
});


$("document").ready(function(){
$(".multiSearch").catcomplete({
source: function (request, response) {
$.ajax({
url: 'api/search/'+request.term,
dataType: 'json',
type: 'GET',
success: function (data) {
response(data);
}
})
},
minLength: 2,
select: function (event, ui) {
console.log("selected");
var location = ui.item.value;
window.location.replace(location);
return false;

$(".multiSearch").select2({
minimumInputLength: 2,
ajax: {
url: function (params){
return "api/search/"+params.term;
},
dataType: 'json',
delay: 250,
data: "",
processResults: function (data, params) {
var idKey = 1;
var results = new Array();
$.each(data, function (key,value) {
var groupName = Object.keys(value)[0];
var ckeys = value[groupName];
var resultGroup = {
id: key,
text: groupName,
children:[]
};
idKey++;
var children = new Array();
$.each(ckeys, function (ckey,cvalue) {
var childObject = {
id: idKey,
text: cvalue.displayName,
uri: cvalue.uri
};
idKey++;
resultGroup.children.push(childObject);
});
results.push(resultGroup);
});
return {results: results};
},
cache: true
}
});
$(".multiSearch").on("select2:select",function (e) { window.location.href= e.params.data.uri;});

$(".searchPerson").autocomplete({
source: function (request, response) {
Expand Down