Skip to content

Commit e3868fb

Browse files
committed
Editor consistant, restore button added & mode set
CSS and JS files added plus settings added to make consistant with main editor Restore as new version button added Load in new partial JS file to set the correct mode
1 parent 410ef38 commit e3868fb

1 file changed

Lines changed: 48 additions & 6 deletions

File tree

lib/backup-versions.php

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,25 @@
2424
.CodeMirror {position: absolute; width: 409px; height: 180px; font-size: <?php echo $ICEcoder["fontSize"];?>}
2525
.CodeMirror-scroll {overflow: hidden}
2626
/* Make sure this next one remains the 3rd item, updated with JS */
27-
.cm-tab {border-left-width: <?php echo $ICEcoder["visibleTabs"] ? "1px" : "0";?>; margin-left: <?php echo $ICEcoder["visibleTabs"] ? "-1px" : "0";?>; border-left-style: solid; border-left-color: rgba(255,255,255,0.2)}
27+
.cm-tab {border-left-width: <?php echo $ICEcoder["visibleTabs"] ? "1px" : "0";?>; margin-left: <?php echo $ICEcoder["visibleTabs"] ? "-1px" : "0";?>; border-left-style: solid; border-left-color: rgba(255,255,255,0.15)}
28+
.cm-trailingspace {
29+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAYAAAB/qH1jAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QUXCToH00Y1UgAAACFJREFUCNdjPMDBUc/AwNDAAAFMTAwMDA0OP34wQgX/AQBYgwYEx4f9lQAAAABJRU5ErkJggg==);
30+
background-position: bottom left;
31+
background-repeat: repeat-x;
32+
}
33+
.CodeMirror-foldmarker {font-family: arial; line-height: .3; color: #b00; cursor: pointer;
34+
text-shadow: #fff 1px 1px 2px, #fff -1px -1px 2px, #fff 1px -1px 2px, #fff -1px 1px 2px;
35+
}
36+
.CodeMirror-foldgutter {display: inline-block; width: 13px}
37+
.CodeMirror-foldgutter-open, .CodeMirror-foldgutter-folded {position: absolute; display: inline-block; width: 13px; height: 13px; font-size: 14px; text-align: center; cursor: pointer}
38+
.CodeMirror-foldgutter-open {background: rgba(255,255,255,0.04); color: #666}
39+
.CodeMirror-foldgutter-open:after {position: relative; top: -2px}
40+
.CodeMirror-foldgutter-folded {background: #800; color: #ddd}
41+
.CodeMirror-foldgutter-folded:after {position: relative; top: -3px}
2842
</style>
43+
<script src="../<?php echo $ICEcoder["codeMirrorDir"]; ?>/addon/fold/foldcode.js?microtime=<?php echo microtime(true);?>"></script>
44+
<script src="../<?php echo $ICEcoder["codeMirrorDir"]; ?>/addon/fold/foldgutter.js?microtime=<?php echo microtime(true);?>"></script>
45+
<link rel="stylesheet" href="../<?php echo $ICEcoder["codeMirrorDir"]; ?>/addon/fold/foldgutter.css?microtime=<?php echo microtime(true);?>">
2946
<link rel="stylesheet" href="editor.css?microtime=<?php echo microtime(true);?>">
3047
<?php
3148
$themeArray = array();
@@ -74,9 +91,7 @@
7491
<div style="display: none; width: 180px; margin-left: 30px" id="buttonsContainer">
7592
<div class="button" onclick="openNew()">Open in new tab</div>
7693
<div class="button" onclick="openDiff()">Open in diff mode</div>
77-
<!--
78-
<div class="button" onclick="alert('Function not available yet - Coming in v5.4')">Restore as new version</div>
79-
//-->
94+
<div class="button" onclick="restoreVersion()">Restore as new version</div>
8095
<div id="infoContainer"></div>
8196
</div>
8297
<div style="display: none">
@@ -93,12 +108,27 @@
93108
}
94109
}
95110

111+
<?php
112+
echo "fileName = '".basename($file)."';";
113+
include(dirname(__FILE__)."/language-modes-partial.js");
114+
?>
115+
96116
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
117+
mode: mode,
97118
lineNumbers: top.ICEcoder.lineNumbers,
98-
readOnly: "nocursor",
119+
gutters: ["CodeMirror-foldgutter","CodeMirror-lint-markers","CodeMirror-linenumbers"],
120+
foldGutter: {gutter: "CodeMirror-foldgutter"},
121+
foldOptions: {minFoldSize: 1},
122+
lineWrapping: top.ICEcoder.lineWrapping,
123+
indentWithTabs: top.ICEcoder.indentWithTabs,
99124
indentUnit: top.ICEcoder.indentSize,
100125
tabSize: top.ICEcoder.indentSize,
101-
mode: "javascript",
126+
matchBrackets: top.ICEcoder.matchBrackets,
127+
electricChars: false,
128+
highlightSelectionMatches: true,
129+
showTrailingSpace: top.ICEcoder.showTrailingSpace,
130+
lint: false,
131+
readOnly: "nocursor",
102132
theme: "<?php echo $ICEcoder["theme"]=="default" ? 'icecoder' : $ICEcoder["theme"];?>"
103133
});
104134
editor.setSize("480px","500px");
@@ -121,6 +151,18 @@
121151
top.ICEcoder.focus('diff');
122152
cMDiff.setValue(editor.getValue());
123153
}
154+
155+
var restoreVersion = function() {
156+
var cM;
157+
158+
if (top.ICEcoder.ask("To confirm - this will paste the displayed backup content to your current tab and save, OK?")) {
159+
top.ICEcoder.showHide('hide',top.document.getElementById('blackMask'))
160+
cM = top.ICEcoder.getcMInstance();
161+
top.ICEcoder.focus();
162+
cM.setValue(editor.getValue());
163+
top.ICEcoder.saveFile();
164+
}
165+
}
124166
</script>
125167

126168
</body>

0 commit comments

Comments
 (0)