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 18-23 Link Here
18
Libraries › Administration › Koha
18
Libraries › Administration › Koha
19
</title>
19
</title>
20
[% INCLUDE 'doc-head-close.inc' %]
20
[% INCLUDE 'doc-head-close.inc' %]
21
[% Asset.css("lib/codemirror/codemirror.min.css") | $raw %]
22
[% Asset.css("lib/codemirror/lint.min.css") | $raw %]
21
</head>
23
</head>
22
24
23
<body id="admin_branches" class="admin">
25
<body id="admin_branches" class="admin">
Lines 275-280 Libraries &rsaquo; Administration &rsaquo; Koha Link Here
275
                    </select>
277
                    </select>
276
                    <div class="hint">Set to 'yes' to show this library as a search option and on the libraries page in the OPAC.</div>
278
                    <div class="hint">Set to 'yes' to show this library as a search option and on the libraries page in the OPAC.</div>
277
                </li>
279
                </li>
280
                <li>
281
                    <label for="UserJS">UserJS: </label>
282
                    <div style="display:flex; flex-direction:column;">
283
                        <a class="expand-textarea" id="expand_userjs" data-target="userjs" data-syntax="javascript" href="#">Click to edit</a>
284
                        <textarea style="display:none" name="userjs" id="userjs" class="codemirror" rows="10" cols="40">[% library.userjs %]</textarea>
285
                        <a class="collapse-textarea" id="collapse_userjs" data-target="userjs" data-syntax="javascript" style="display:none" href="#">Click to collapse</br></a>
286
                    </div>
287
                </li>
288
                <li>
289
                    <label for="UserCSS">UserCSS: </label>
290
                    <div style="display:flex; flex-direction:column;">
291
                        <a class="expand-textarea" id="expand_usercss" data-target="usercss" data-syntax="css" href="#">Click to edit</a>
292
                        <textarea style="display:none" name="usercss" id="usercss" class="" rows="10" cols="40">[% library.usercss %]</textarea>
293
                        <a class="collapse-textarea" id="collapse_usercss" data-target="usercss" data-syntax="css" style="display:none" href="#">Click to collapse</br></a>
294
                    </div>
295
                </li>
296
                </li>
278
            </ol>
297
            </ol>
279
        </fieldset>
298
        </fieldset>
280
        <fieldset class="action">
299
        <fieldset class="action">
Lines 475-481 Libraries &rsaquo; Administration &rsaquo; Koha Link Here
475
    [% INCLUDE 'datatables.inc' %]
494
    [% INCLUDE 'datatables.inc' %]
476
    [% INCLUDE 'columns_settings.inc' %]
495
    [% INCLUDE 'columns_settings.inc' %]
477
    [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
496
    [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
497
    [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
498
    [% Asset.js( "lib/codemirror/css.min.js" ) | $raw %]
499
    [% Asset.js( "lib/codemirror/javascript.min.js" ) | $raw %]
500
    [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %]
501
    [% Asset.js( "lib/codemirror/yaml.min.js" ) | $raw %]
502
    [% Asset.js( "lib/codemirror/lint.min.js" ) | $raw %]
503
    [% Asset.js( "lib/linters/jshint.min.js" ) | $raw %]
504
    [% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %]
505
    [% Asset.js( "lib/linters/csslint.min.js" ) | $raw %]
506
    [% Asset.js( "lib/linters/js-yaml.min.js" ) | $raw %]
507
    [% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %]
508
    [% Asset.js( "lib/codemirror/javascript-lint.min.js" ) | $raw %]
509
    [% Asset.js( "lib/codemirror/css-lint.min.js" ) | $raw %]
510
    [% Asset.js( "lib/codemirror/yaml-lint.min.js" ) | $raw %]
511
    [% Asset.css("lib/codemirror/codemirror.css") | $raw %]
478
    [% INCLUDE 'str/tinymce_i18n.inc' %]
512
    [% INCLUDE 'str/tinymce_i18n.inc' %]
513
    <style>
514
        .CodeMirror {
515
            border: 1px solid #EEE;
516
            margin: 1em, 1em, 1em, 0;
517
            resize: vertical;
518
            width: 50em;
519
        }
520
    </style>
479
    <script>
521
    <script>
480
        var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
522
        var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
481
        var saved_table = localStorage.getItem("DataTables_libraries_/cgi-bin/koha/admin/branches.pl");
523
        var saved_table = localStorage.getItem("DataTables_libraries_/cgi-bin/koha/admin/branches.pl");
Lines 674-690 Libraries &rsaquo; Administration &rsaquo; Koha Link Here
674
            [% END %]
716
            [% END %]
675
        });
717
        });
676
718
677
        tinyMCE.init({
719
        $( ".expand-textarea" ).on("click", function(e){
678
            branding : false,
720
            e.preventDefault();
679
            relative_urls : false,
721
            $(this).hide();
680
            content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
722
            var target = $(this).data("target");
681
            menubar : "file edit view insert format tools table",
723
            var syntax = $(this).data("syntax");
682
            mode : "specific_textareas",
724
            $("#collapse_" + target ).show();
683
            plugins : "autoresize table hr link image charmap lists code emoticons",
725
            if( syntax ){
684
            toolbar : [
726
                var editor = CodeMirror.fromTextArea( document.getElementById( target ), {
685
                "formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr",
727
                    lineNumbers: true,
686
                "table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code"
728
                    mode: syntax,
687
            ],
729
                    lineWrapping: true,
730
                    viewportMargin: Infinity,
731
                    gutters: ["CodeMirror-lint-markers"],
732
                    lint: true
733
                });
734
                editor.on("blur", function(){
735
                    editor.save();
736
                });
737
            } else {
738
                $( target ).show();
739
            }
740
        });
741
742
        $( ".collapse-textarea" ).on("click", function(e){
743
            e.preventDefault();
744
            $(this).hide();
745
            var target = $(this).data("target");
746
            var syntax = $(this).data("syntax");
747
            $("#expand_" + target ).show();
748
            if( syntax ){
749
                var editor = $( "#" + target ).next(".CodeMirror")[0].CodeMirror;
750
                editor.toTextArea();
751
            }
752
            $( "#" + target ).hide();
688
        });
753
        });
689
    </script>
754
    </script>
690
[% END %]
755
[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc (+5 lines)
Lines 43-48 Link Here
43
[% IF ( Koha.Preference('OPACUserCSS') ) %]
43
[% IF ( Koha.Preference('OPACUserCSS') ) %]
44
    <style>[% Koha.Preference('OPACUserCSS') | $raw %]</style>
44
    <style>[% Koha.Preference('OPACUserCSS') | $raw %]</style>
45
[% END %]
45
[% END %]
46
[% IF Branches.GetBranchSpecificCSS( Branches.GetLoggedInBranchcode() || default_branch) %]
47
    <style>
48
        [% Branches.GetBranchSpecificCSS( Branches.GetLoggedInBranchcode() || default_branch) | $raw %]
49
    </style>
50
[% END %]
46
[% IF SCO_login %]
51
[% IF SCO_login %]
47
    [% SET SCOUserCSS = Koha.Preference('SCOUserCSS') %]
52
    [% SET SCOUserCSS = Koha.Preference('SCOUserCSS') %]
48
    [% IF SCOUserCSS %]
53
    [% 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 296-301 $(document).ready(function() { Link Here
296
        [% Koha.Preference('OPACUserJS') | $raw %]
297
        [% Koha.Preference('OPACUserJS') | $raw %]
297
    </script>
298
    </script>
298
[% END %]
299
[% END %]
300
[% IF Branches.GetBranchSpecificJS( Branches.GetLoggedInBranchcode() || default_branch) %]
301
    <script>
302
        [% Branches.GetBranchSpecificJS( Branches.GetLoggedInBranchcode() || default_branch) | $raw %]
303
    </script>
304
[% END %]
299
[% IF SCO_login %]
305
[% IF SCO_login %]
300
    [% SET SCOUserJS = Koha.Preference('SCOUserJS') %]
306
    [% SET SCOUserJS = Koha.Preference('SCOUserJS') %]
301
    [% IF ( SCOUserJS ) %]
307
    [% IF ( SCOUserJS ) %]
302
- 

Return to bug 32721