{I"
class:ETI"ProcessedAsset; FI"logical_path; TI"curate/link_users.js; FI"
pathname; TI"[/Users/jfriesen/Repositories/curate/app/assets/javascripts/curate/link_users.js.coffee; FI"content_type; TI"application/javascript; TI"
mtime; Tl+Þ$aRI"length; TikI"digest; TI"%d7f200e8a0d820eae1cf59e9c3288fc2; FI"source; TI"k(function() {
(function($, window, document) {
var $this, methods, _adder, _internals, _remover, _settings;
$this = void 0;
_settings = {
"default": 'cool!'
};
_remover = $("");
_adder = $("");
methods = {
init: function(options) {
$this = $(this);
$.extend(_settings, options || {});
$this.each(function(index, el) {
$('.autocomplete-users').each(function(index, el) {
return _internals.autocompleteUsers(el);
});
$('.field-wrapper:not(:last-child) .field-controls', $this).append(_remover);
$('.field-controls:last', $this).append(_adder);
$(el).on('click', 'button.add', function(e) {
return _internals.addToList(this);
});
return $(el).on('click', 'button.remove', function(e) {
return _internals.removeFromList(this);
});
});
return $this;
},
destroy: function() {
return $this;
}
};
_internals = {
addToList: function(el) {
var $activeControls, $listing, $removeControl;
$activeControls = $(el).closest('.field-controls');
$listing = $activeControls.closest('.listing');
$('.add', $activeControls).remove();
$removeControl = _remover.clone();
$activeControls.prepend($removeControl);
_internals.newRow($listing);
return false;
},
newRow: function($listing) {
$listing.append(_internals.newListItem($('li', $listing).size()));
return _internals.autocompleteUsers($('.autocomplete-users:last', $listing));
},
removeFromList: function(el) {
var $currentUser, $listing;
$currentUser = $(el).closest('li');
$listing = $currentUser.closest('.listing');
$currentUser.hide();
$('input:not([value])', $currentUser).val('true');
return false;
},
newListItem: function(index) {
var source, template;
source = $("#entry-template").html();
template = Handlebars.compile(source);
return template({
index: index
});
},
addExistingUser: function($listItem, value, label) {
var $list, source, template;
source = $("#existing-user-template").html();
template = Handlebars.compile(source);
$list = $listItem.closest('ul');
$('input[required]', $list).removeAttr('required');
$listItem.replaceWith(template({
index: $('li', $list).index($listItem),
value: value,
label: label
}));
return _internals.newRow($list);
},
autocompleteUsers: function(el) {
var $targetElement;
$targetElement = $(el);
return $targetElement.autocomplete({
source: function(request, response) {
$targetElement.data('url');
return $.getJSON($targetElement.data('url'), {
q: request.term
}, function(data, status, xhr) {
var matches;
matches = [];
$.each(data.response.docs, function(idx, val) {
return matches.push({
label: val['desc_metadata__name_tesim'][0],
value: val['id']
});
});
return response(matches);
});
},
minLength: 2,
focus: function(event, ui) {
$targetElement.val(ui.item.label);
return event.preventDefault();
},
select: function(event, ui) {
_internals.addExistingUser($targetElement.closest('li'), ui.item.value, ui.item.label);
$targetElement.val('');
return event.preventDefault();
}
});
}
};
return $.fn.linkUsers = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return methods.init.apply(this, arguments);
} else {
return $.error("Method " + method + " does not exist on jquery.linkUsers");
}
};
})(jQuery, window, document);
}).call(this);
; TI"dependency_digest; TI"%4dd76a3230fba851b73efe6bae0445b4; FI"required_paths; T[I"[/Users/jfriesen/Repositories/curate/app/assets/javascripts/curate/link_users.js.coffee; FI"dependency_paths; T[{I" path; TI"[/Users/jfriesen/Repositories/curate/app/assets/javascripts/curate/link_users.js.coffee; FI"
mtime; TI"2013-10-18T08:09:02-04:00; TI"digest; TI"%ada294f76ddb006b9de7a65d96881d9e; FI"
_version; TI"%2cf3622cbba861b85d33ffabfa420c13; F