|
Lines 569-575
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 569 |
editor.refresh(); |
569 |
editor.refresh(); |
| 570 |
break; |
570 |
break; |
| 571 |
case 'macros': |
571 |
case 'macros': |
| 572 |
showSavedMacros(); |
572 |
// Macros loaded on first show of modal |
| 573 |
break; |
573 |
break; |
| 574 |
case 'selected_search_targets': |
574 |
case 'selected_search_targets': |
| 575 |
$.each( z3950Servers, function( server_id, server ) { |
575 |
$.each( z3950Servers, function( server_id, server ) { |
|
Lines 735-748
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 735 |
position: function (elt) { $(elt).insertAfter('#toolbar') }, |
735 |
position: function (elt) { $(elt).insertAfter('#toolbar') }, |
| 736 |
} ); |
736 |
} ); |
| 737 |
|
737 |
|
| 738 |
macroEditor = CodeMirror( |
|
|
| 739 |
$('#macro-editor')[0], |
| 740 |
{ |
| 741 |
mode: 'null', |
| 742 |
lineNumbers: true, |
| 743 |
} |
| 744 |
); |
| 745 |
|
| 746 |
// Automatically detect resizes and change the height of the editor and position of modals. |
738 |
// Automatically detect resizes and change the height of the editor and position of modals. |
| 747 |
var resizeTimer = null; |
739 |
var resizeTimer = null; |
| 748 |
$( window ).resize( function() { |
740 |
$( window ).resize( function() { |
|
Lines 765-770
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 765 |
|
757 |
|
| 766 |
} ).resize(); |
758 |
} ).resize(); |
| 767 |
|
759 |
|
|
|
760 |
$( '#macro-ui' ).on( 'shown', function() { |
| 761 |
if ( macroEditor ) return; |
| 762 |
|
| 763 |
macroEditor = CodeMirror( |
| 764 |
$('#macro-editor')[0], |
| 765 |
{ |
| 766 |
mode: 'null', |
| 767 |
lineNumbers: true, |
| 768 |
} |
| 769 |
); |
| 770 |
var saveTimeout; |
| 771 |
macroEditor.on( 'change', function( cm, change ) { |
| 772 |
$('#macro-save-message').empty(); |
| 773 |
if ( change.origin == 'setValue' ) return; |
| 774 |
|
| 775 |
if ( saveTimeout ) clearTimeout( saveTimeout ); |
| 776 |
saveTimeout = setTimeout( function() { |
| 777 |
saveMacro(); |
| 778 |
|
| 779 |
saveTimeout = null; |
| 780 |
}, 500 ); |
| 781 |
} ); |
| 782 |
|
| 783 |
showSavedMacros(); |
| 784 |
} ); |
| 785 |
|
| 768 |
var saveableBackends = []; |
786 |
var saveableBackends = []; |
| 769 |
$.each( backends, function( id, backend ) { |
787 |
$.each( backends, function( id, backend ) { |
| 770 |
if ( backend.save ) saveableBackends.push( [ backend.saveLabel, id ] ); |
788 |
if ( backend.save ) saveableBackends.push( [ backend.saveLabel, id ] ); |
|
Lines 805-810
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 805 |
case 'noIndicators': |
823 |
case 'noIndicators': |
| 806 |
editor.addError( error.line, _("Invalid indicators") ); |
824 |
editor.addError( error.line, _("Invalid indicators") ); |
| 807 |
break; |
825 |
break; |
|
|
826 |
case 'noSubfields': |
| 827 |
editor.addError( error.line, _("Tag has no subfields") ); |
| 828 |
break; |
| 808 |
case 'missingTag': |
829 |
case 'missingTag': |
| 809 |
editor.addError( null, _("Missing mandatory tag: ") + error.tag ); |
830 |
editor.addError( null, _("Missing mandatory tag: ") + error.tag ); |
| 810 |
break; |
831 |
break; |
|
Lines 854-862
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 854 |
reader.onload = function() { |
875 |
reader.onload = function() { |
| 855 |
var record = new MARC.Record(); |
876 |
var record = new MARC.Record(); |
| 856 |
|
877 |
|
| 857 |
if ( /\.mrc$/.test( file.name ) ) { |
878 |
if ( /\.(mrc|marc|iso|iso2709|marcstd)$/.test( file.name ) ) { |
| 858 |
record.loadISO2709( reader.result ); |
879 |
record.loadISO2709( reader.result ); |
| 859 |
} else if ( /\.xml$/.test( file.name ) ) { |
880 |
} else if ( /\.(xml|marcxml)$/.test( file.name ) ) { |
| 860 |
record.loadMARCXML( reader.result ); |
881 |
record.loadMARCXML( reader.result ); |
| 861 |
} else { |
882 |
} else { |
| 862 |
humanMsg.displayAlert( _("Unknown record type, cannot import"), { className: 'humanError' } ); |
883 |
humanMsg.displayAlert( _("Unknown record type, cannot import"), { className: 'humanError' } ); |
|
Lines 914-932
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 914 |
return false; |
935 |
return false; |
| 915 |
} ); |
936 |
} ); |
| 916 |
|
937 |
|
| 917 |
var saveTimeout; |
|
|
| 918 |
macroEditor.on( 'change', function( cm, change ) { |
| 919 |
$('#macro-save-message').empty(); |
| 920 |
if ( change.origin == 'setValue' ) return; |
| 921 |
|
| 922 |
if ( saveTimeout ) clearTimeout( saveTimeout ); |
| 923 |
saveTimeout = setTimeout( function() { |
| 924 |
saveMacro(); |
| 925 |
|
| 926 |
saveTimeout = null; |
| 927 |
}, 500 ); |
| 928 |
} ); |
| 929 |
|
| 930 |
$( '#switch-editor' ).click( function() { |
938 |
$( '#switch-editor' ).click( function() { |
| 931 |
if ( !confirm( _("Any changes will not be saved. Continue?") ) ) return; |
939 |
if ( !confirm( _("Any changes will not be saved. Continue?") ) ) return; |
| 932 |
|
940 |
|