Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
bookshare
Commits
374c2666
Commit
374c2666
authored
Apr 19, 2015
by
Daniel W Bond
Browse files
added initial work on course autocompletion js
parent
193aaab2
Changes
3
Hide whitespace changes
Inline
Side-by-side
bookshare/static/js/courses.js
0 → 100644
View file @
374c2666
// fancy autopopulation widget
$
.
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
,
currentDepartment
=
""
;
$
.
each
(
items
,
function
(
index
,
item
)
{
var
li
;
if
(
item
.
department
!=
currentDepartment
)
{
ul
.
append
(
"
<li class='ui-autocomplete-category'>
"
+
item
.
department
+
"
</li>
"
);
currentDepartment
=
item
.
department
;
}
li
=
that
.
_renderItemData
(
ul
,
item
);
if
(
item
.
department
)
{
li
.
attr
(
"
aria-label
"
,
item
.
department
+
"
:
"
+
item
.
course
);
}
});
}
});
// autopopulation
$
(
function
()
{
var
course_data
=
$
.
getJSON
(
"
/static/js/mason_courses.json
"
);
// course_data is an object
console
.
log
(
course_data
);
// yet despite this showing everything in the browser, it is 'undefined'
// for this below?????
console
.
log
(
course_data
.
responseText
);
$
(
'
#id_course_abbr
'
).
on
(
'
input
'
,
function
(
e
)
{
e
.
preventDefault
();
$
(
"
#id_course_abbr
"
).
catcomplete
({
delay
:
0
,
source
:
course_data
});
});
});
bookshare/static/js/mason_courses.json
0 → 100644
View file @
374c2666
This source diff could not be displayed because it is too large. You can
view the blob
instead.
bookshare/trades/templates/create_listing.html
View file @
374c2666
...
...
@@ -38,5 +38,17 @@ SRCT Bookshare • Create Listing
{% block javascript %}
{% load static from staticfiles %}
<!-- jQueryUI =/= jQuery -->
<link
rel=
"stylesheet"
href=
"https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css"
>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/isbn.js' %}"
></script>
<style>
.ui-autocomplete-category
{
font-weight
:
bold
;
padding
:
.2em
.4em
;
margin
:
.8em
0
.2em
;
line-height
:
1.5
;
}
</style>
<script
type=
"text/javascript"
src=
"{% static 'js/courses.js' %}"
></script>
{% endblock javascript %}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment