Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qfq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
typo3
qfq
Commits
d354a561
Commit
d354a561
authored
6 years ago
by
bbaer
Browse files
Options
Downloads
Patches
Plain Diff
History for undo redo added
parent
23b8b74d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!129
Undo
Pipeline
#1665
passed
6 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
javascript/src/History.js
+76
-0
76 additions, 0 deletions
javascript/src/History.js
javascript/src/Plugins/qfq.fabric.js
+1
-0
1 addition, 0 deletions
javascript/src/Plugins/qfq.fabric.js
with
77 additions
and
0 deletions
javascript/src/History.js
0 → 100644
+
76
−
0
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
This diff is collapsed.
Click to expand it.
javascript/src/Plugins/qfq.fabric.js
+
1
−
0
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
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment