Lines 19-27
Link Here
|
19 |
#course_instructors { |
19 |
#course_instructors { |
20 |
float: left; |
20 |
float: left; |
21 |
} |
21 |
} |
22 |
.instructor_line { |
|
|
23 |
padding: 0.3em; |
24 |
} |
25 |
fieldset.rows label[for="find_instructor"] { |
22 |
fieldset.rows label[for="find_instructor"] { |
26 |
text-align: left; |
23 |
text-align: left; |
27 |
margin: 0; |
24 |
margin: 0; |
Lines 131-143
Link Here
|
131 |
<div id="course_instructors"> |
128 |
<div id="course_instructors"> |
132 |
<div id="instructors"> |
129 |
<div id="instructors"> |
133 |
[% FOREACH i IN instructors %] |
130 |
[% FOREACH i IN instructors %] |
134 |
<div class="instructor_line" id="borrower_[% i.borrowernumber | html %]"> |
131 |
<div class="patron-detail-autocomplete-selection" id="patron-detail-[% i.borrowernumber | html %]"> |
135 |
[% INCLUDE 'patron-title.inc' patron=i no_cardnumber=1 %] (<a href="#" class="removeInstructor"><i class="fa fa-trash-can"></i> Remove </a>) |
132 |
[% INCLUDE 'patron-title.inc' patron=i no_cardnumber=1 %] (<a href="#" class="removePatron"><i class="fa fa-trash-can"></i> Remove </a>) |
136 |
<input type="hidden" name="instructors" value="[% i.borrowernumber | html %]" /> |
133 |
<input type="hidden" name="instructors" value="[% i.borrowernumber | html %]" /> |
137 |
</div> |
134 |
</div> |
138 |
[% END %] |
135 |
[% END %] |
139 |
</div> |
136 |
</div> |
140 |
<div id="instructor_search" class="instructor_line"> |
137 |
<div id="instructor_search" class="patron-detail-autocomplete-selection"> |
141 |
<label for="find_instructor">Instructor search:</label> |
138 |
<label for="find_instructor">Instructor search:</label> |
142 |
<input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit" /> |
139 |
<input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit" /> |
143 |
</div> |
140 |
</div> |
Lines 198-245
Link Here
|
198 |
<script> |
195 |
<script> |
199 |
$(document).ready(function () { |
196 |
$(document).ready(function () { |
200 |
patron_autocomplete($("#find_instructor"), { |
197 |
patron_autocomplete($("#find_instructor"), { |
|
|
198 |
"on-select-add-to": { container: $("#instructors"), input_name: "instructors" }, |
201 |
"on-select-callback": function (event, ui) { |
199 |
"on-select-callback": function (event, ui) { |
202 |
AddInstructor($patron_to_html(ui.item, { display_cardnumber: false }), ui.item.patron_id); |
200 |
$("#find_instructor").val("").focus(); |
203 |
return false; |
|
|
204 |
}, |
201 |
}, |
205 |
}); |
202 |
}); |
206 |
|
203 |
$(".removePatron").on("click", function (e) { |
207 |
if (!$("#instructors").html()) { |
|
|
208 |
$("#course_instructors").hide(); |
209 |
} |
210 |
|
211 |
$("body").on("click", ".removeInstructor", function (e) { |
212 |
e.preventDefault(); |
204 |
e.preventDefault(); |
213 |
var divid = $(this).parent().attr("id"); |
205 |
$(this).closest('div[id^="patron-detail-"]').remove(); |
214 |
var borrowernumber = divid.replace("borrower_", ""); |
|
|
215 |
RemoveInstructor(borrowernumber); |
216 |
}); |
206 |
}); |
217 |
}); |
207 |
}); |
218 |
|
|
|
219 |
function AddInstructor(name, borrowernumber) { |
220 |
div = |
221 |
"<div class='instructor_line' id='borrower_" + |
222 |
borrowernumber + |
223 |
"'>" + |
224 |
(name ? name.escapeHtml() : "") + |
225 |
" ( <a href='#' class='removeInstructor'><i class='fa fa-trash-can'></i> " + |
226 |
_("Remove") + |
227 |
" </a> ) <input type='hidden' name='instructors' value='" + |
228 |
borrowernumber + |
229 |
"' /></div>"; |
230 |
$("#instructors").append(div); |
231 |
|
232 |
$("#find_instructor").val("").focus(); |
233 |
$("#course_instructors").show(); |
234 |
} |
235 |
|
236 |
function RemoveInstructor(borrowernumber) { |
237 |
$("#borrower_" + borrowernumber).remove(); |
238 |
|
239 |
if (!$("#instructors").html()) { |
240 |
$("#course_instructors").hide(800); |
241 |
} |
242 |
} |
243 |
</script> |
208 |
</script> |
244 |
[% END %] |
209 |
[% END %] |
245 |
[% END %] |
210 |
[% END %] |