app/assets/javascripts/sufia.js in sufia-0.1.0 vs app/assets/javascripts/sufia.js in sufia-1.0.0
- old
+ new
@@ -39,10 +39,13 @@
//= require terms_of_service
//= require fileupload
//= require sufia/permissions
//= require sufia/tabs
//= require sufia/trophy
+//= require sufia/batch_select_all
+//= require sufia/multiForm
+//= require sufia/edit_metadata
//over ride the blacklight default to submit
//form when sort by or show per page change
Blacklight.do_select_submit = function() {
$(Blacklight.do_select_submit.selector).each(function() {
@@ -84,124 +87,9 @@
range.moveStart('character', start);
range.select();
}
});
};
- // there are two levels of vocabulary auto complete.
- // currently we have this externally hosted vocabulary
- // for geonames. I'm not going to make these any easier
- // to implement for an external url (it's all hard coded)
- // because I'm guessing we'll get away from the hard coding
- var cities_autocomplete_opts = {
- source: function( request, response ) {
- $.ajax( {
- url: "http://ws.geonames.org/searchJSON",
- dataType: "jsonp",
- data: {
- featureClass: "P",
- style: "full",
- maxRows: 12,
- name_startsWith: request.term
- },
- success: function( data ) { response( $.map( data.geonames, function( item ) {
- return {
- label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
- value: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName
- };
- }));
- },
- });
- },
- minLength: 2
- };
- $("#generic_file_based_near").autocomplete(get_autocomplete_opts("location"));
-
-
- function get_autocomplete_opts(field) {
- var autocomplete_opts = {
- minLength: 2,
- source: function( request, response ) {
- $.getJSON( "/authorities/generic_files/" + field, {
- q: request.term
- }, response );
- },
- focus: function() {
- // prevent value inserted on focus
- return false;
- },
- complete: function(event) {
- $('.ui-autocomplete-loading').removeClass("ui-autocomplete-loading");
- }
- };
- return autocomplete_opts;
- }
-
- var autocomplete_vocab = new Object();
-
- autocomplete_vocab.url_var = ['subject', 'language']; // the url variable to pass to determine the vocab to attach to
- autocomplete_vocab.field_name = new Array(); // the form name to attach the event for autocomplete
- autocomplete_vocab.add_btn_id = new Array(); // the id of the button pressed when adding an additional form element
-
- // loop over the autocomplete fields and attach the
- // events for autocomplete and create other array values for autocomplete
- for (var i=0; i < autocomplete_vocab.url_var.length; i++) {
- autocomplete_vocab.field_name.push('generic_file_' + autocomplete_vocab.url_var[i]);
- autocomplete_vocab.add_btn_id.push('additional_' + autocomplete_vocab.url_var[i] + '_submit');
- // autocompletes
- $("#" + autocomplete_vocab.field_name[i])
- // don't navigate away from the field on tab when selecting an item
- .bind( "keydown", function( event ) {
- if ( event.keyCode === $.ui.keyCode.TAB &&
- $( this ).data( "autocomplete" ).menu.active ) {
- event.preventDefault();
- }
- })
- .autocomplete( get_autocomplete_opts(autocomplete_vocab.url_var[i]) );
-
- }
-
- /*
- * adds additional metadata elements
- */
- $('.adder').click(function() {
- var cloneId = this.id.replace("submit", "clone");
- var newId = this.id.replace("submit", "elements");
- var cloneElem = $('#'+cloneId).clone();
- // change the add button to a remove button
- var plusbttn = cloneElem.find('#'+this.id);
- plusbttn.html('-<span class="accessible-hidden">remove this '+ this.name.replace("_", " ") +'</span>');
- plusbttn.on('click',removeField);
-
- // remove the help tag on subsequent added fields
- cloneElem.find('.formHelp').remove();
- cloneElem.find('i').remove();
- cloneElem.find('.modal-div').remove();
-
- //clear out the value for the element being appended
- //so the new element has a blank value
- cloneElem.find('input[type=text]').attr("value", "");
- cloneElem.find('input[type=text]').attr("required", false);
-
- // should we attach an auto complete based on the input
- if (this.id == 'additional_based_near_submit') {
- cloneElem.find('input[type=text]').autocomplete(cities_autocomplete_opts);
- }
- else if ( (index = $.inArray(this.id, autocomplete_vocab.add_btn_id)) != -1 ) {
- cloneElem.find('input[type=text]').autocomplete(get_autocomplete_opts(autocomplete_vocab.url_var[index]));
- }
-
- $('#'+newId).append(cloneElem);
- cloneElem.find('input[type=text]').focus();
- return false;
- });
-
- $('.remover').click(removeField);
-
- function removeField () {
- // get parent and remove it
- $(this).parent().remove();
- return false;
- }
// show/hide more information on the dashboard when clicking
// plus/minus
$('.icon-plus').on('click', function() {
//this.id format: "expand_NNNNNNNNNN"