1+ <?php
2+ /*
3+ * The MIT License (MIT)
4+ *
5+ * Copyright (c) 2018 TwelveTone LLC
6+ *
7+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8+ * of this software and associated documentation files (the "Software"), to deal
9+ * in the Software without restriction, including without limitation the rights
10+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+ * copies of the Software, and to permit persons to whom the Software is
12+ * furnished to do so, subject to the following conditions:
13+ *
14+ * The above copyright notice and this permission notice shall be included in all
15+ * copies or substantial portions of the Software.
16+ *
17+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+ * SOFTWARE.
24+ */
25+
26+ use Twelvetone \Common \ServiceManager ;
27+
28+ {
29+ $ manager = ServiceManager::getInstance ();
30+ $ grav = \Grav \Common \Grav::instance ();
31+ $ twig = $ grav ['twig ' ];
32+
33+ $ manager ->registerService ("renderer " , [
34+ "caption " => "Delete " ,
35+ "scope " => ["edit:section " ],
36+ "order " => "last " ,
37+ "render " => function () {
38+ return "<a class='button' onclick='_doDelete(); return false;'><i class='fa fa-trash'></i>Delete</a> " ;
39+ },
40+ ]);
41+
42+ $ manager ->registerService ("renderer " , [
43+ "caption " => "Fullscreen " ,
44+ "scope " => ["edit:section " ],
45+ "order " => "last " ,
46+ "render " => function () use ($ twig ) {
47+ return $ twig ->processTemplate ("fullscreen.html.twig " , ["targetSelector " => "#edit-area " ]);
48+ },
49+ ]);
50+
51+ $ manager ->registerService ("renderer " , [
52+ "caption " => "Save+Back " ,
53+ "scope " => ["edit:section " ],
54+ "order " => "first " ,
55+ "render " => function ($ context ) use ($ twig ) {
56+ return '<a class="button" onclick="_doSave();window.history.back();return false;"><i class="fa fa-reply"></i>Save+Back</a> ' ;
57+ }
58+ ]);
59+
60+ $ manager ->registerService ("renderer " , [
61+ "caption " => "Back And Refresh " ,
62+ "scope " => ["edit:section " ],
63+ "order " => "first " ,
64+ "render " => function ($ context ) use ($ twig ) {
65+ // This will go back with refreshing but loose scroll position
66+ // return '<a class="button" onclick="window.location = document.referrer;"><i class="fa fa-reply"></i>Back</a>';
67+ // This will go back without refreshing but retain scroll position
68+ return '<a class="button" onclick="window.history.back()"><i class="fa fa-reply"></i>Back</a> ' ;
69+ }
70+ ]);
71+ $ manager ->registerService ("renderer " , [
72+ "caption " => "Save " ,
73+ "scope " => ["edit:section " ],
74+ "order " => "last " ,
75+ "render " => function () {
76+ return "<a class='button' onclick='_doSave(); return false;'><i class='fa fa-save'></i>Save</a> " ;
77+ },
78+ ]);
79+ }
0 commit comments