Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
d354a561
Commit
d354a561
authored
Mar 04, 2019
by
bbaer
Browse files
History for undo redo added
parent
23b8b74d
Pipeline
#1665
passed with stage
in 2 minutes and 13 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
javascript/src/History.js
0 → 100644
View file @
d354a561
/**
* @author Benjamin Baer <benjamin.baer@math.uzh.ch>
*/
/* global $ */
/**
* Qfq Namespace
*
* @namespace QfqNS
*/
var
QfqNS
=
QfqNS
||
{};
(
function
(
n
)
{
'
use strict
'
;
/**
* A custom history to use for undo and redo functionality.
**/
n
.
History
=
function
()
{
this
.
history
=
[];
this
.
pointer
=
0
;
};
n
.
History
.
prototype
.
put
=
function
(
object
)
{
if
(
this
.
pointerAtCurrent
())
{
this
.
_removeForwardHistory
();
}
this
.
history
.
push
(
object
);
this
.
pointer
=
this
.
history
.
length
-
1
;
};
n
.
History
.
prototype
.
back
=
function
()
{
if
(
this
.
canGoBack
())
{
this
.
pointer
--
;
return
this
.
history
[
this
.
pointer
];
}
else
{
console
.
log
(
"
At the beginning of history
"
);
return
false
;
}
};
n
.
History
.
prototype
.
forward
=
function
()
{
if
(
this
.
canGoForward
())
{
this
.
pointer
++
;
return
this
.
history
[
this
.
pointer
];
}
else
{
console
.
log
(
"
At the end of history
"
);
return
false
;
}
};
n
.
History
.
prototype
.
canGoBack
=
function
()
{
return
this
.
pointer
>
0
;
};
n
.
History
.
prototype
.
canGoForward
=
function
()
{
return
this
.
pointer
<
this
.
history
.
length
-
1
;
};
n
.
History
.
prototype
.
pointerAtCurrent
=
function
()
{
return
this
.
pointer
===
this
.
history
.
length
-
1
;
};
n
.
History
.
prototype
.
_removeForwardHistory
=
function
()
{
var
tempPointer
=
this
.
history
.
length
-
1
;
while
(
tempPointer
>
this
.
pointer
&&
this
.
history
.
length
>
0
)
{
this
.
history
.
pop
();
tempPointer
--
;
}
};
})(
QfqNS
);
\ No newline at end of file
javascript/src/Plugins/qfq.fabric.js
View file @
d354a561
...
...
@@ -63,6 +63,7 @@ $(function (n) {
this
.
mouseInsideCanvas
=
false
;
this
.
imageOutput
=
''
;
this
.
localStore
=
new
n
.
LocalStorage
(
"
fabric
"
);
this
.
history
=
new
n
.
History
();
// Handles button states and generation of said buttons. Should be renamed.
function
ModeSettings
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment