| 1 | efrain | 1 | {{!
 | 
        
           |  |  | 2 |     This file is part of Moodle - http://moodle.org/
 | 
        
           |  |  | 3 |   | 
        
           |  |  | 4 |     Moodle is free software: you can redistribute it and/or modify
 | 
        
           |  |  | 5 |     it under the terms of the GNU General Public License as published by
 | 
        
           |  |  | 6 |     the Free Software Foundation, either version 3 of the License, or
 | 
        
           |  |  | 7 |     (at your option) any later version.
 | 
        
           |  |  | 8 |   | 
        
           |  |  | 9 |     Moodle is distributed in the hope that it will be useful,
 | 
        
           |  |  | 10 |     but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
        
           |  |  | 11 |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
        
           |  |  | 12 |     GNU General Public License for more details.
 | 
        
           |  |  | 13 |   | 
        
           |  |  | 14 |     You should have received a copy of the GNU General Public License
 | 
        
           |  |  | 15 |     along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 | 
        
           |  |  | 16 | }}
 | 
        
           |  |  | 17 | {{!
 | 
        
           |  |  | 18 |     @template core/local/dropdown/dialog
 | 
        
           |  |  | 19 |   | 
        
           |  |  | 20 |     Displays a dropdown dialog component.
 | 
        
           |  |  | 21 |   | 
        
           |  |  | 22 |     Classes required for JS:
 | 
        
           |  |  | 23 |     * none
 | 
        
           |  |  | 24 |   | 
        
           |  |  | 25 |     Context variables required for this template:
 | 
        
           |  |  | 26 |     * buttoncontent String - the dropdown trigger button content.
 | 
        
           |  |  | 27 |     * dialogcontent String - the dropdown dialog content.
 | 
        
           |  |  | 28 |   | 
        
           |  |  | 29 |     Optional blocks:
 | 
        
           |  |  | 30 |     * dropdownclasses - additional classes for the dropdown.
 | 
        
           |  |  | 31 |     * buttonclasses - additional classes for the dropdown trigger button.
 | 
        
           |  |  | 32 |     * dialogclasses - additional classes for the dropdown dialog.
 | 
        
           |  |  | 33 |     * dialogcontent - the dropdown dialog content.
 | 
        
           |  |  | 34 |     * buttoncontent - the dropdown trigger button content.
 | 
        
           |  |  | 35 |     * extras - custom HTML attributes for the component.
 | 
        
           |  |  | 36 |     * dropdownid - the dropdown id (will be auto-generate if no id is passed).
 | 
        
           |  |  | 37 |   | 
        
           |  |  | 38 |     Example context (json):
 | 
        
           |  |  | 39 |     {
 | 
        
           |  |  | 40 |         "dropdownid": "internaldropdownid",
 | 
        
           |  |  | 41 |         "buttonid": "internalbuttonid",
 | 
        
           |  |  | 42 |         "buttoncontent": "Trigger button",
 | 
        
           |  |  | 43 |         "dialogcontent": "<a href=\"#\">Moodle</a>",
 | 
        
           |  |  | 44 |         "extras": [
 | 
        
           |  |  | 45 |             {
 | 
        
           |  |  | 46 |                 "attribute": "data-example",
 | 
        
           |  |  | 47 |                 "value": "stickyfooter"
 | 
        
           |  |  | 48 |             }
 | 
        
           |  |  | 49 |         ],
 | 
        
           |  |  | 50 |         "buttonclasses": "extraclasses",
 | 
        
           |  |  | 51 |         "dialogclasses": "extraclasses",
 | 
        
           |  |  | 52 |         "disabledbutton": false,
 | 
        
           |  |  | 53 |         "classes": "extraclasses"
 | 
        
           |  |  | 54 |     }
 | 
        
           |  |  | 55 | }}
 | 
        
           |  |  | 56 | <div
 | 
        
           |  |  | 57 |     class="dropdown {{!
 | 
        
           |  |  | 58 |         }} {{$ dropdownclasses }} {{!
 | 
        
           |  |  | 59 |             }} {{#classes}} {{classes}} {{/classes}} {{!
 | 
        
           |  |  | 60 |         }} {{/ dropdownclasses }}"
 | 
        
           |  |  | 61 |     id="{{$ dropdownid }}{{!
 | 
        
           |  |  | 62 |             }}{{#dropdownid}}{{dropdownid}}{{/dropdownid}}{{!
 | 
        
           |  |  | 63 |             }}{{^dropdownid}}dropdownDialog_{{uniqid}}{{/dropdownid}}{{!
 | 
        
           |  |  | 64 |         }}{{/ dropdownid }}"
 | 
        
           |  |  | 65 |     {{$ extras }}
 | 
        
           |  |  | 66 |         {{#extras}}
 | 
        
           |  |  | 67 |             {{attribute}}="{{value}}"
 | 
        
           |  |  | 68 |         {{/extras}}
 | 
        
           |  |  | 69 |     {{/ extras }}
 | 
        
           |  |  | 70 | >
 | 
        
           |  |  | 71 |     <button
 | 
        
           |  |  | 72 |         class="{{$ buttonclasses }} {{!
 | 
        
           |  |  | 73 |                 }} {{^buttonclasses}} btn btn-light btn-outline-secondary dropdown-toggle {{/buttonclasses}} {{!
 | 
        
           |  |  | 74 |                 }} {{#buttonclasses}} {{buttonclasses}} {{/buttonclasses}} {{!
 | 
        
           |  |  | 75 |             }} {{/ buttonclasses }}"
 | 
        
           |  |  | 76 |         type="button"
 | 
        
           | 1441 | ariadna | 77 |         role="button"
 | 
        
           | 1 | efrain | 78 |         id="{{#buttonid}}{{buttonid}}{{/buttonid}}{{^buttonid}}dropdownDialog{{uniqid}}{{/buttonid}}"
 | 
        
           | 1441 | ariadna | 79 |         data-bs-toggle="dropdown"
 | 
        
           |  |  | 80 |         data-bs-auto-close="{{#autoclose}}{{autoclose}}{{/autoclose}}{{^autoclose}}true{{/autoclose}}"
 | 
        
           | 1 | efrain | 81 |         aria-haspopup="true"
 | 
        
           |  |  | 82 |         aria-expanded="false"
 | 
        
           |  |  | 83 |         data-for="dropdowndialog_button"
 | 
        
           |  |  | 84 |         {{#disabledbutton}} disabled {{/disabledbutton}}
 | 
        
           |  |  | 85 |     >
 | 
        
           |  |  | 86 |         {{$ buttoncontent }}
 | 
        
           |  |  | 87 |             {{{ buttoncontent }}}
 | 
        
           |  |  | 88 |         {{/ buttoncontent }}
 | 
        
           |  |  | 89 |     </button>
 | 
        
           |  |  | 90 |     <div
 | 
        
           |  |  | 91 |         class="dropdown-menu {{!
 | 
        
           |  |  | 92 |             }} {{#position}} {{position}} {{/position}} {{!
 | 
        
           |  |  | 93 |             }} {{$ dialogclasses }} {{!
 | 
        
           |  |  | 94 |                 }} {{#dialogclasses}} {{dialogclasses}} {{/dialogclasses}} {{!
 | 
        
           |  |  | 95 |             }} {{/ dialogclasses }}"
 | 
        
           |  |  | 96 |         aria-labelledby="{{#buttonid}}{{buttonid}}{{/buttonid}}{{^buttonid}}dropdownDialog{{uniqid}}{{/buttonid}}"
 | 
        
           |  |  | 97 |         data-for="dropdowndialog_dialog"
 | 
        
           |  |  | 98 |     >
 | 
        
           |  |  | 99 |         <div class="p-2" data-for="dropdowndialog_content">
 | 
        
           |  |  | 100 |             {{$ dialogcontent }}
 | 
        
           |  |  | 101 |                 {{{dialogcontent}}}
 | 
        
           |  |  | 102 |             {{/ dialogcontent }}
 | 
        
           |  |  | 103 |         </div>
 | 
        
           |  |  | 104 |     </div>
 | 
        
           |  |  | 105 | </div>
 | 
        
           |  |  | 106 | {{#js}}
 | 
        
           |  |  | 107 |     require(['core/local/dropdown/dialog'], function(Module) {
 | 
        
           |  |  | 108 |         Module.init('#' + '{{$ dropdownid }}{{!
 | 
        
           |  |  | 109 |             }}{{#dropdownid}}{{dropdownid}}{{/dropdownid}}{{!
 | 
        
           |  |  | 110 |             }}{{^dropdownid}}dropdownDialog_{{uniqid}}{{/dropdownid}}{{!
 | 
        
           |  |  | 111 |         }}{{/ dropdownid }}');
 | 
        
           |  |  | 112 |     });
 | 
        
           |  |  | 113 | {{/js}}
 |