-<script src="/intranet-tmpl/lib/codemirror/codemirror-compressed.js"></script>
-<script src="/intranet-tmpl/lib/filesaver.js"></script>
-<script src="/intranet-tmpl/lib/koha/cateditor/marc-mode.js"></script>
-<script src="/intranet-tmpl/lib/require.js"></script>
+[% Asset.js("lib/codemirror/codemirror-compressed.js") %]
+[% Asset.js("lib/filesaver.js") %]
+[% Asset.js("lib/koha/cateditor/marc-mode.js") %]
+[% Asset.js("lib/require.js") %]
<script>
+ var authInfo = {
+ [%- FOREACH authtag = authtags -%]
+ [% authtag.tagfield %]: {
+ subfield: '[% authtag.tagsubfield %]',
+ authtypecode: '[% authtag.authtypecode %]',
+ },
+ [%- END -%]
+ };
require.config( {
- baseUrl: '/intranet-tmpl/lib/koha/cateditor/',
+ baseUrl: '[% interface %]/lib/koha/cateditor/',
config: {
resources: {
marcflavour: '[% marcflavour %]',
// The columns that should show up in a search, in order, and keyed by the corresponding <metadata> tag in the XSL and Pazpar2 config
var z3950Labels = [
- [ "local_number", _("Local number") ],
- [ "title", _("Title") ],
- [ "series", _("Series title") ],
- [ "author", _("Author") ],
- [ "lccn", _("LCCN") ],
- [ "isbn", _("ISBN") ],
- [ "issn", _("ISSN") ],
- [ "medium", _("Medium") ],
- [ "edition", _("Edition") ],
- [ "notes", _("Notes") ],
+ [ "local_number", _("Local number") ],
+ [ "title", _("Title") ],
+ [ "series", _("Series title") ],
+ [ "author", _("Author") ],
+ [ "lccn", _("LCCN") ],
+ [ "isbn", _("ISBN") ],
+ [ "issn", _("ISSN") ],
+ [ "medium", _("Medium") ],
+ [ "edition", _("Edition") ],
+ [ "notes", _("Notes") ],
];
var state = {
return $result[0];
},
postCreate: function() {
- this.setText( defaultvalue );
+ var value = defaultvalue;
+ var widget = this;
+
+ $.each( authvals, function() {
+ if ( this.value == widget.text ) {
+ value = this.value;
+ }
+ } );
+
+ this.setText( value );
$( '<select></select>' ).appendTo( this.node );
var $node = $( this.node ).find( 'select' );
$.each( authvals, function( undef, authval ) {
- $node.append( '<option value="' + authval.value + '"' + (authval.value == defaultvalue ? ' selected="selected"' : '') + '>' + authval.lib + '</option>' );
+ $node.append( '<option value="' + authval.value + '"' + (authval.value == value ? ' selected="selected"' : '') + '>' + authval.lib + '</option>' );
} );
$node.val( this.text );
[% IF ( marcflavour == 'MARC21' ) %]
if ( tag == '000' ) {
return "http://www.loc.gov/marc/bibliographic/bdleader.html";
+ } else if ( tag >= '090' && tag < '100' ) {
+ return "http://www.loc.gov/marc/bibliographic/bd09x.html";
} else if ( tag < '900' ) {
return "http://www.loc.gov/marc/bibliographic/bd" + tag + ".html";
} else {
}
function showResultsBox(data) {
- $('#search-top-pages, #search-bottom-pages').find('.pagination').empty();
+ $('#search-top-pages, #search-bottom-pages').find('nav').empty();
$('#searchresults thead tr').empty();
$('#searchresults tbody').empty();
$('#search-serversinfo').empty().append('<li>' + _("Loading...") + '</li>');
var max_page = Math.ceil( data.total_fetched / data.page_size ) - 1;
if ( cur_page != 0 ) {
- pages.push( '<li><a class="search-nav" href="#" data-offset="' + (data.offset - data.page_size) + '">« ' + _("Previous") + '</a></li>' );
+ pages.push( '<li><a class="search-nav" href="#" data-offset="' + (data.offset - data.page_size) + '"><span aria-hidden="true">«</span> ' + _("Previous") + '</a></li>' );
}
for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) {
}
if ( cur_page < max_page ) {
- pages.push( ' <li><a class="search-nav" href="#" data-offset="' + (data.offset + data.page_size) + '">' + _("Next") + ' »</a></li>' );
+ pages.push( ' <li><a class="search-nav" href="#" data-offset="' + (data.offset + data.page_size) + '">' + _("Next") + ' <span aria-hidden="true">»</span></a></li>' );
}
- if ( pages.length > 1 ) $( '#search-top-pages, #search-bottom-pages' ).find( '.pagination' ).html( '<ul>' + pages.join( '' ) + '</ul>');
+ $( '#search-top-pages, #search-bottom-pages' ).find( 'nav' ).html( pages.length > 1 ? ( '<ul class="pagination pagination-sm">' + pages.join( '' ) + '</ul>' ) : '' );
var $overlay = $('#search-overlay');
$overlay.find('span').text(_("Loading"));
invalidateSearchResults();
Search.Reconnect();
} else {
- humanMsg.displayMsg( _("<h3>Internal search error</h3>") + '<p>' + error + '</p>' + _("<p>Please <b>refresh</b> the page and try again."), { className: 'humanError' } );
+ humanMsg.displayMsg( '<h3>' + _("Internal search error") + '</h3><p>' + error + '</p><p>' + _("Please refresh the page and try again.") + '</p>', { className: 'humanError' } );
}
}
$( sel ).on( event, function (e) {
e.preventDefault();
handler( e, Preferences.user[pref] );
- Preferences.Save( [% USER_INFO.0.borrowernumber %] );
+ Preferences.Save( [% USER_INFO.borrowernumber %] );
showPreference(pref);
} );
}
$( document ).on( 'change', 'input.search-toggle-server', function() {
var server_id = $( this ).closest('li').data('server-id');
Preferences.user.selected_search_targets[server_id] = this.checked;
- Preferences.Save( [% USER_INFO.0.borrowernumber %] );
+ Preferences.Save( [% USER_INFO.borrowernumber %] );
} );
break;
}
$( '#macro-list li[data-name="' + name + '"]' ).addClass( 'active' );
var macro = Preferences.user.macros[name];
macroEditor.setValue( macro.contents );
+ macroEditor.setOption( 'readOnly', false );
$( '#macro-format' ).val( macro.format || 'its' );
if ( macro.history ) macroEditor.setHistory( macro.history );
}
delete Preferences.user.macros[name];
}
- Preferences.Save( [% USER_INFO.0.borrowernumber %] );
+ Preferences.Save( [% USER_INFO.borrowernumber %] );
}
function showSavedMacros( macros ) {
// Automatically detect resizes and change the height of the editor and position of modals.
var resizeTimer = null;
- $( window ).resize( function() {
+ function onResize() {
if ( resizeTimer == null ) resizeTimer = setTimeout( function() {
resizeTimer = null;
$(this).height( $(window).height() * .8 - $(this).prevAll('.modal-header').height() );
} );
}, 100);
+ }
- $("#advanced-search-ui, #search-results-ui, #macro-ui").css( {
- marginLeft: function() {
- return -($(this).width() / 2);
- }
- } );
-
- } ).resize();
-
- $( '#macro-ui' ).on( 'shown', function() {
+ $( '#macro-ui' ).on( 'shown.bs.modal', function() {
if ( macroEditor ) return;
macroEditor = CodeMirror(
$('#macro-editor')[0],
{
+ extraKeys: {
+ 'Ctrl-D': function( cm ) {
+ var cur = cm.getCursor();
+
+ cm.replaceRange( "‡", cur, null );
+ },
+ },
mode: 'null',
lineNumbers: true,
+ readOnly: true,
}
);
var saveTimeout;
// Click bindings
$( '#save-record, #save-dropdown a' ).click( function() {
- $( '#save-record' ).find('i').attr( 'class', 'icon-loading' ).siblings( 'span' ).text( _("Saving...") );
+ $( '#save-record' ).find('i').attr( 'class', 'fa fa-spinner' ).siblings( 'span' ).text( _("Saving...") );
function finishCb(result) {
if ( result.error == 'syntax' ) {
}
} );
- $( '#save-record' ).find('i').attr( 'class', 'icon-hdd' );
+ $( '#save-record' ).find('i').attr( 'class', 'fa fa-hdd-o' );
if ( result.error ) {
// Reset backend info
return;
}
+ if (record.marc8_corrupted) humanMsg.displayMsg( '<h3>' + _("Possible record corruption") + '</h3><p>' + _("Record not marked as UTF-8, may be corrupted") + '</p>', { className: 'humanError' } );
+
editor.displayRecord( record );
};
if ( !result.errors.length ) {
$('#macro-ui').modal('hide');
+ editor.focus(); //Return cursor to editor after macro run
return false;
}
errors.push(error);
} );
- humanMsg.displayMsg( _("<h3>Failed to run macro:</h3>") + '<ul><li>' + errors.join('</li><li>') + '</li></ul>', { className: 'humanError' } );
+ humanMsg.displayMsg( '<h3>' + _("Failed to run macro:") + '</h3><ul><li>' + errors.join('</li><li>') + '</li></ul>', { className: 'humanError' } );
return false;
} );
$( '#switch-editor' ).click( function() {
if ( !confirm( _("Any changes will not be saved. Continue?") ) ) return;
- $.cookie( 'catalogue_editor_[% USER_INFO.0.borrowernumber %]', 'basic', { expires: 365, path: '/' } );
+ $.cookie( 'catalogue_editor_[% USER_INFO.borrowernumber %]', 'basic', { expires: 365, path: '/' } );
if ( state.backend == 'catalog' ) {
window.location = '/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=' + state.recordID;
return false;
} );
+ window.onbeforeunload = function() {
+ if(editor.modified )
+ { return 1; }
+ else
+ { return undef; }
+ };
+
// Start editor
- Preferences.Load( [% USER_INFO.0.borrowernumber || 0 %] );
+ Preferences.Load( [% USER_INFO.borrowernumber || 0 %] );
displayPreferences(editor);
makeAuthorisedValueWidgets( '' );
Search.Init( {
Resources.GetAll().done( function() {
$("#loading").hide();
+ $( window ).resize( onResize ).resize();
editor.focus();
} );
}