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 23-28 Link Here
23
    [% t("Koha") | html %]
23
    [% t("Koha") | html %]
24
[% END %]</title>
24
[% END %]</title>
25
[% INCLUDE 'doc-head-close.inc' %]
25
[% INCLUDE 'doc-head-close.inc' %]
26
[% Asset.css("lib/codemirror/codemirror.min.css") | $raw %]
27
[% Asset.css("lib/codemirror/lint.min.css") | $raw %]
26
</head>
28
</head>
27
29
28
<body id="admin_branches" class="admin">
30
<body id="admin_branches" class="admin">
Lines 286-291 Link Here
286
                    </select>
288
                    </select>
287
                    <div class="hint">Set to 'yes' to show this library as a search option and on the libraries page in the OPAC.</div>
289
                    <div class="hint">Set to 'yes' to show this library as a search option and on the libraries page in the OPAC.</div>
288
                </li>
290
                </li>
291
                <li>
292
                    <label for="UserJS">UserJS: </label>
293
                    <div style="display:flex; flex-direction:column;">
294
                        <a class="expand-textarea" id="expand_userjs" data-target="userjs" data-syntax="javascript" href="#">Click to edit</a>
295
                        <textarea style="display:none" name="userjs" id="userjs" class="codemirror" rows="10" cols="40">[% library.userjs %]</textarea>
296
                        <a class="collapse-textarea" id="collapse_userjs" data-target="userjs" data-syntax="javascript" style="display:none" href="#">Click to collapse</br></a>
297
                    </div>
298
                </li>
299
                <li>
300
                    <label for="UserCSS">UserCSS: </label>
301
                    <div style="display:flex; flex-direction:column;">
302
                        <a class="expand-textarea" id="expand_usercss" data-target="usercss" data-syntax="css" href="#">Click to edit</a>
303
                        <textarea style="display:none" name="usercss" id="usercss" class="" rows="10" cols="40">[% library.usercss %]</textarea>
304
                        <a class="collapse-textarea" id="collapse_usercss" data-target="usercss" data-syntax="css" style="display:none" href="#">Click to collapse</br></a>
305
                    </div>
306
                </li>
307
                </li>
289
            </ol>
308
            </ol>
290
        </fieldset>
309
        </fieldset>
291
        <fieldset class="action">
310
        <fieldset class="action">
Lines 486-492 Link Here
486
    [% INCLUDE 'datatables.inc' %]
505
    [% INCLUDE 'datatables.inc' %]
487
    [% INCLUDE 'columns_settings.inc' %]
506
    [% INCLUDE 'columns_settings.inc' %]
488
    [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
507
    [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
508
    [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
509
    [% Asset.js( "lib/codemirror/css.min.js" ) | $raw %]
510
    [% Asset.js( "lib/codemirror/javascript.min.js" ) | $raw %]
511
    [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %]
512
    [% Asset.js( "lib/codemirror/yaml.min.js" ) | $raw %]
513
    [% Asset.js( "lib/codemirror/lint.min.js" ) | $raw %]
514
    [% Asset.js( "lib/linters/jshint.min.js" ) | $raw %]
515
    [% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %]
516
    [% Asset.js( "lib/linters/csslint.min.js" ) | $raw %]
517
    [% Asset.js( "lib/linters/js-yaml.min.js" ) | $raw %]
518
    [% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %]
519
    [% Asset.js( "lib/codemirror/javascript-lint.min.js" ) | $raw %]
520
    [% Asset.js( "lib/codemirror/css-lint.min.js" ) | $raw %]
521
    [% Asset.js( "lib/codemirror/yaml-lint.min.js" ) | $raw %]
522
    [% Asset.css("lib/codemirror/codemirror.css") | $raw %]
489
    [% INCLUDE 'str/tinymce_i18n.inc' %]
523
    [% INCLUDE 'str/tinymce_i18n.inc' %]
524
    <style>
525
        .CodeMirror {
526
            border: 1px solid #EEE;
527
            margin: 1em, 1em, 1em, 0;
528
            resize: vertical;
529
            width: 50em;
530
        }
531
    </style>
490
    <script>
532
    <script>
491
        var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
533
        var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
492
        var saved_table = localStorage.getItem("DataTables_libraries_/cgi-bin/koha/admin/branches.pl");
534
        var saved_table = localStorage.getItem("DataTables_libraries_/cgi-bin/koha/admin/branches.pl");
Lines 685-701 Link Here
685
            [% END %]
727
            [% END %]
686
        });
728
        });
687
729
688
        tinyMCE.init({
730
        $( ".expand-textarea" ).on("click", function(e){
689
            branding : false,
731
            e.preventDefault();
690
            relative_urls : false,
732
            $(this).hide();
691
            content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
733
            var target = $(this).data("target");
692
            menubar : "file edit view insert format tools table",
734
            var syntax = $(this).data("syntax");
693
            mode : "specific_textareas",
735
            $("#collapse_" + target ).show();
694
            plugins : "autoresize table hr link image charmap lists code emoticons",
736
            if( syntax ){
695
            toolbar : [
737
                var editor = CodeMirror.fromTextArea( document.getElementById( target ), {
696
                "formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr",
738
                    lineNumbers: true,
697
                "table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code"
739
                    mode: syntax,
698
            ],
740
                    lineWrapping: true,
741
                    viewportMargin: Infinity,
742
                    gutters: ["CodeMirror-lint-markers"],
743
                    lint: true
744
                });
745
                editor.on("blur", function(){
746
                    editor.save();
747
                });
748
            } else {
749
                $( target ).show();
750
            }
751
        });
752
753
        $( ".collapse-textarea" ).on("click", function(e){
754
            e.preventDefault();
755
            $(this).hide();
756
            var target = $(this).data("target");
757
            var syntax = $(this).data("syntax");
758
            $("#expand_" + target ).show();
759
            if( syntax ){
760
                var editor = $( "#" + target ).next(".CodeMirror")[0].CodeMirror;
761
                editor.toTextArea();
762
            }
763
            $( "#" + target ).hide();
699
        });
764
        });
700
    </script>
765
    </script>
701
[% END %]
766
[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc (+5 lines)
Lines 44-49 Link Here
44
[% IF ( Koha.Preference('OPACUserCSS') ) %]
44
[% IF ( Koha.Preference('OPACUserCSS') ) %]
45
    <style>[% Koha.Preference('OPACUserCSS') | $raw %]</style>
45
    <style>[% Koha.Preference('OPACUserCSS') | $raw %]</style>
46
[% END %]
46
[% END %]
47
[% IF Branches.GetBranchSpecificCSS( Branches.GetLoggedInBranchcode() || default_branch) %]
48
    <style>
49
        [% Branches.GetBranchSpecificCSS( Branches.GetLoggedInBranchcode() || default_branch) | $raw %]
50
    </style>
51
[% END %]
47
[% IF SCO_login %]
52
[% IF SCO_login %]
48
    [% SET SCOUserCSS = Koha.Preference('SCOUserCSS') %]
53
    [% SET SCOUserCSS = Koha.Preference('SCOUserCSS') %]
49
    [% IF SCOUserCSS %]
54
    [% 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 307-312 $(document).ready(function() { Link Here
307
        [% Koha.Preference('OPACUserJS') | $raw %]
308
        [% Koha.Preference('OPACUserJS') | $raw %]
308
    </script>
309
    </script>
309
[% END %]
310
[% END %]
311
[% IF Branches.GetBranchSpecificJS( Branches.GetLoggedInBranchcode() || default_branch) %]
312
    <script>
313
        [% Branches.GetBranchSpecificJS( Branches.GetLoggedInBranchcode() || default_branch) | $raw %]
314
    </script>
315
[% END %]
310
[% IF SCO_login %]
316
[% IF SCO_login %]
311
    [% SET SCOUserJS = Koha.Preference('SCOUserJS') %]
317
    [% SET SCOUserJS = Koha.Preference('SCOUserJS') %]
312
    [% IF ( SCOUserJS ) %]
318
    [% IF ( SCOUserJS ) %]
313
- 

Return to bug 32721