View | Details | Raw Unified | Return to bug 32721
Collapse All | Expand All

(-)a/Koha/Template/Plugin/Branches.pm (+22 lines)
Lines 153-156 sub pickup_locations { Link Here
153
    return \@libraries;
153
    return \@libraries;
154
}
154
}
155
155
156
sub GetBranchSpecificJS {
157
    my ($self, $branchcode) = @_;
158
159
    return q{} unless defined $branchcode;
160
161
    my $library = Koha::Libraries->find($branchcode);
162
    my $userjs = $library ? $library->userjs : q{};
163
164
    return $userjs
165
}
166
167
sub GetBranchSpecificCSS {
168
    my ($self, $branchcode) = @_;
169
170
    return q{} unless defined $branchcode;
171
172
    my $library = Koha::Libraries->find($branchcode);
173
    my $usercss = $library ? $library->usercss : q{};
174
175
    return $usercss
176
}
177
156
1;
178
1;
(-)a/admin/branches.pl (+2 lines)
Lines 81-86 if ( $op eq 'add_form' ) { Link Here
81
      marcorgcode
81
      marcorgcode
82
      pickup_location
82
      pickup_location
83
      public
83
      public
84
      userjs
85
      usercss
84
    );
86
    );
85
    my $is_a_modif = $input->param('is_a_modif');
87
    my $is_a_modif = $input->param('is_a_modif');
86
88
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (-11 / +76 lines)
Lines 17-22 Link Here
17
Libraries › Administration › Koha
17
Libraries › Administration › Koha
18
</title>
18
</title>
19
[% INCLUDE 'doc-head-close.inc' %]
19
[% INCLUDE 'doc-head-close.inc' %]
20
[% Asset.css("lib/codemirror/codemirror.min.css") | $raw %]
21
[% Asset.css("lib/codemirror/lint.min.css") | $raw %]
20
</head>
22
</head>
21
23
22
<body id="admin_branches" class="admin">
24
<body id="admin_branches" class="admin">
Lines 288-293 Libraries &rsaquo; Administration &rsaquo; Koha Link Here
288
                    </select>
290
                    </select>
289
                    <div class="hint">Set to 'yes' to show this library as a search option and on the Libraries page in the OPAC.</div>
291
                    <div class="hint">Set to 'yes' to show this library as a search option and on the Libraries page in the OPAC.</div>
290
                </li>
292
                </li>
293
                <li>
294
                    <label for="UserJS">UserJS: </label>
295
                    <div style="display:flex; flex-direction:column;">
296
                        <a class="expand-textarea" id="expand_userjs" data-target="userjs" data-syntax="javascript" href="#">Click to edit</a>
297
                        <textarea style="display:none" name="userjs" id="userjs" class="codemirror" rows="10" cols="40">[% library.userjs %]</textarea>
298
                        <a class="collapse-textarea" id="collapse_userjs" data-target="userjs" data-syntax="javascript" style="display:none" href="#">Click to collapse</br></a>
299
                    </div>
300
                </li>
301
                <li>
302
                    <label for="UserCSS">UserCSS: </label>
303
                    <div style="display:flex; flex-direction:column;">
304
                        <a class="expand-textarea" id="expand_usercss" data-target="usercss" data-syntax="css" href="#">Click to edit</a>
305
                        <textarea style="display:none" name="usercss" id="usercss" class="" rows="10" cols="40">[% library.usercss %]</textarea>
306
                        <a class="collapse-textarea" id="collapse_usercss" data-target="usercss" data-syntax="css" style="display:none" href="#">Click to collapse</br></a>
307
                    </div>
308
                </li>
309
                </li>
291
            </ol>
310
            </ol>
292
        </fieldset>
311
        </fieldset>
293
        <fieldset class="action">
312
        <fieldset class="action">
Lines 488-494 Libraries &rsaquo; Administration &rsaquo; Koha Link Here
488
    [% INCLUDE 'datatables.inc' %]
507
    [% INCLUDE 'datatables.inc' %]
489
    [% INCLUDE 'columns_settings.inc' %]
508
    [% INCLUDE 'columns_settings.inc' %]
490
    [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
509
    [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
510
    [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
511
    [% Asset.js( "lib/codemirror/css.min.js" ) | $raw %]
512
    [% Asset.js( "lib/codemirror/javascript.min.js" ) | $raw %]
513
    [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %]
514
    [% Asset.js( "lib/codemirror/yaml.min.js" ) | $raw %]
515
    [% Asset.js( "lib/codemirror/lint.min.js" ) | $raw %]
516
    [% Asset.js( "lib/linters/jshint.min.js" ) | $raw %]
517
    [% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %]
518
    [% Asset.js( "lib/linters/csslint.min.js" ) | $raw %]
519
    [% Asset.js( "lib/linters/js-yaml.min.js" ) | $raw %]
520
    [% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %]
521
    [% Asset.js( "lib/codemirror/javascript-lint.min.js" ) | $raw %]
522
    [% Asset.js( "lib/codemirror/css-lint.min.js" ) | $raw %]
523
    [% Asset.js( "lib/codemirror/yaml-lint.min.js" ) | $raw %]
524
    [% Asset.css("lib/codemirror/codemirror.css") | $raw %]
491
    [% INCLUDE 'str/tinymce_i18n.inc' %]
525
    [% INCLUDE 'str/tinymce_i18n.inc' %]
526
    <style>
527
        .CodeMirror {
528
            border: 1px solid #EEE;
529
            margin: 1em, 1em, 1em, 0;
530
            resize: vertical;
531
            width: 50em;
532
        }
533
    </style>
492
    <script>
534
    <script>
493
        var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
535
        var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
494
        var saved_table = localStorage.getItem("DataTables_libraries_/cgi-bin/koha/admin/branches.pl");
536
        var saved_table = localStorage.getItem("DataTables_libraries_/cgi-bin/koha/admin/branches.pl");
Lines 687-703 Libraries &rsaquo; Administration &rsaquo; Koha Link Here
687
            [% END %]
729
            [% END %]
688
        });
730
        });
689
731
690
        tinyMCE.init({
732
        $( ".expand-textarea" ).on("click", function(e){
691
            branding : false,
733
            e.preventDefault();
692
            relative_urls : false,
734
            $(this).hide();
693
            content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
735
            var target = $(this).data("target");
694
            menubar : "file edit view insert format tools table",
736
            var syntax = $(this).data("syntax");
695
            mode : "specific_textareas",
737
            $("#collapse_" + target ).show();
696
            plugins : "autoresize table hr link image charmap lists code emoticons",
738
            if( syntax ){
697
            toolbar : [
739
                var editor = CodeMirror.fromTextArea( document.getElementById( target ), {
698
                "formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr",
740
                    lineNumbers: true,
699
                "table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code"
741
                    mode: syntax,
700
            ],
742
                    lineWrapping: true,
743
                    viewportMargin: Infinity,
744
                    gutters: ["CodeMirror-lint-markers"],
745
                    lint: true
746
                });
747
                editor.on("blur", function(){
748
                    editor.save();
749
                });
750
            } else {
751
                $( target ).show();
752
            }
753
        });
754
755
        $( ".collapse-textarea" ).on("click", function(e){
756
            e.preventDefault();
757
            $(this).hide();
758
            var target = $(this).data("target");
759
            var syntax = $(this).data("syntax");
760
            $("#expand_" + target ).show();
761
            if( syntax ){
762
                var editor = $( "#" + target ).next(".CodeMirror")[0].CodeMirror;
763
                editor.toTextArea();
764
            }
765
            $( "#" + target ).hide();
701
        });
766
        });
702
    </script>
767
    </script>
703
[% END %]
768
[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc (+5 lines)
Lines 48-53 Link Here
48
[% IF ( Koha.Preference('OPACUserCSS') ) %]
48
[% IF ( Koha.Preference('OPACUserCSS') ) %]
49
    <style>[% Koha.Preference('OPACUserCSS') | $raw %]</style>
49
    <style>[% Koha.Preference('OPACUserCSS') | $raw %]</style>
50
[% END %]
50
[% END %]
51
[% IF Branches.GetBranchSpecificCSS( Branches.GetLoggedInBranchcode() || default_branch) %]
52
    <style>
53
        [% Branches.GetBranchSpecificCSS( Branches.GetLoggedInBranchcode() || default_branch) | $raw %]
54
    </style>
55
[% END %]
51
[% IF SCO_login %]
56
[% IF SCO_login %]
52
    [% SET SCOUserCSS = Koha.Preference('SCOUserCSS') %]
57
    [% SET SCOUserCSS = Koha.Preference('SCOUserCSS') %]
53
    [% IF SCOUserCSS %]
58
    [% IF SCOUserCSS %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (-1 / +6 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE Branches %]
3
[% USE AdditionalContents %]
4
[% USE AdditionalContents %]
4
[%- USE KohaPlugins -%]
5
[%- USE KohaPlugins -%]
5
[% USE Asset %]
6
[% USE Asset %]
Lines 294-299 $(document).ready(function() { Link Here
294
        [% Koha.Preference('OPACUserJS') | $raw %]
295
        [% Koha.Preference('OPACUserJS') | $raw %]
295
    </script>
296
    </script>
296
[% END %]
297
[% END %]
298
[% IF Branches.GetBranchSpecificJS( Branches.GetLoggedInBranchcode() || default_branch) %]
299
    <script>
300
        [% Branches.GetBranchSpecificJS( Branches.GetLoggedInBranchcode() || default_branch) | $raw %]
301
    </script>
302
[% END %]
297
[% IF SCO_login %]
303
[% IF SCO_login %]
298
    [% SET SCOUserJS = Koha.Preference('SCOUserJS') %]
304
    [% SET SCOUserJS = Koha.Preference('SCOUserJS') %]
299
    [% IF ( SCOUserJS ) %]
305
    [% IF ( SCOUserJS ) %]
300
- 

Return to bug 32721