BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
440ff838
Unverified
Commit
440ff838
authored
Apr 10, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tidy balsamiq viewer and remove unused Vue
parent
e1b0ed39
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
49 deletions
+94
-49
balsamiq_viewer.js
app/assets/javascripts/blob/balsamiq/balsamiq_viewer.js
+89
-0
index.js
app/assets/javascripts/blob/balsamiq/index.js
+0
-42
balsamiq_viewer.js
app/assets/javascripts/blob/balsamiq_viewer.js
+4
-4
_bmpr.html.haml
app/views/projects/blob/_bmpr.html.haml
+1
-3
No files found.
app/assets/javascripts/blob/balsamiq/balsamiq_viewer.js
0 → 100644
View file @
440ff838
/* global Flash */
import
sqljs
from
'sql.js'
;
class
BalsamiqViewer
{
constructor
(
viewer
)
{
this
.
viewer
=
viewer
;
this
.
endpoint
=
this
.
viewer
.
dataset
.
endpoint
;
}
loadFile
()
{
const
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
'GET'
,
this
.
endpoint
,
true
);
xhr
.
responseType
=
'arraybuffer'
;
xhr
.
onload
=
this
.
renderFile
.
bind
(
this
);
xhr
.
onerror
=
BalsamiqViewer
.
onError
;
xhr
.
send
();
}
renderFile
(
loadEvent
)
{
const
container
=
document
.
createElement
(
'ul'
);
this
.
initDatabase
(
loadEvent
.
target
.
response
);
const
previews
=
this
.
getPreviews
();
const
renderedPreviews
=
previews
.
map
(
preview
=>
this
.
renderPreview
(
preview
,
container
));
container
.
innerHTML
=
renderedPreviews
.
join
(
''
);
container
.
classList
.
add
(
'list-inline'
);
this
.
viewer
.
appendChild
(
container
);
}
initDatabase
(
data
)
{
const
previewBinary
=
new
Uint8Array
(
data
);
this
.
database
=
new
sqljs
.
Database
(
previewBinary
);
}
getPreviews
()
{
const
thumnails
=
this
.
database
.
exec
(
'SELECT * FROM thumbnails'
);
return
thumnails
[
0
].
values
.
map
(
BalsamiqViewer
.
parsePreview
);
}
renderPreview
(
preview
)
{
const
previewElement
=
document
.
createElement
(
'li'
);
previewElement
.
innerHTML
=
this
.
renderTemplate
(
preview
);
return
previewElement
.
outerHTML
;
}
renderTemplate
(
preview
)
{
let
template
=
BalsamiqViewer
.
PREVIEW_TEMPLATE
;
const
title
=
this
.
database
.
exec
(
`SELECT * FROM resources WHERE id = '
${
preview
.
resourceID
}
'`
);
const
name
=
JSON
.
parse
(
title
[
0
].
values
[
0
][
2
]).
name
;
const
image
=
preview
.
image
;
template
=
template
.
replace
(
/{{name}}/
,
name
).
replace
(
/{{image}}/
,
image
);
return
template
;
}
static
parsePreview
(
preview
)
{
return
JSON
.
parse
(
preview
[
1
]);
}
static
onError
()
{
const
flash
=
new
Flash
(
'Balsamiq file could not be loaded.'
);
return
flash
;
}
}
BalsamiqViewer
.
PREVIEW_TEMPLATE
=
`
<div class="panel panel-default">
<div class="panel-heading">{{name}}</div>
<div class="panel-body">
<img class="img-thumbnail" src="data:image/png;base64,{{image}}"/>
</div>
</div>
`
;
export
default
BalsamiqViewer
;
app/assets/javascripts/blob/balsamiq/index.js
deleted
100644 → 0
View file @
e1b0ed39
import
Vue
from
'vue'
;
import
sqljs
from
'sql.js'
;
export
default
class
BalsamiqViewer
{
constructor
(
el
)
{
this
.
el
=
el
;
this
.
loadSqlFile
();
}
loadSqlFile
()
{
var
xhr
=
new
XMLHttpRequest
();
var
self
=
this
;
xhr
.
open
(
'GET'
,
this
.
el
.
dataset
.
endpoint
,
true
);
xhr
.
responseType
=
'arraybuffer'
;
xhr
.
onload
=
function
(
e
)
{
var
list
=
document
.
createElement
(
'ul'
);
var
uInt8Array
=
new
Uint8Array
(
this
.
response
);
var
db
=
new
SQL
.
Database
(
uInt8Array
);
var
contents
=
db
.
exec
(
"SELECT * FROM thumbnails"
);
var
previews
=
contents
[
0
].
values
.
map
((
i
)
=>
{
return
JSON
.
parse
(
i
[
1
])});
previews
.
forEach
((
prev
)
=>
{
var
li
=
document
.
createElement
(
'li'
);
var
title
=
db
.
exec
(
`select * from resources where id = '
${
prev
.
resourceID
}
'`
)
var
template
=
`<div class="panel panel-default">
<div class="panel-heading">
${
JSON
.
parse
(
title
[
0
].
values
[
0
][
2
]).
name
}
</div>
<div class="panel-body">
<img class="img-thumbnail" src="data:image/png;base64,
${
prev
.
image
}
"/>
</div>
</div>`
;
li
.
innerHTML
=
template
;
list
.
appendChild
(
li
);
});
list
.
classList
+=
'list-inline'
;
self
.
el
.
appendChild
(
list
);
};
xhr
.
send
();
}
}
\ No newline at end of file
app/assets/javascripts/blob/balsamiq_viewer.js
View file @
440ff838
import
BalsamiqViewer
from
'./balsamiq'
;
import
BalsamiqViewer
from
'./balsamiq
/balsamiq_viewer
'
;
document
.
addEventListener
(
'DOMContentLoaded'
,
()
=>
{
new
BalsamiqViewer
(
document
.
getElementById
(
'js-balsamiq-viewer'
));
});
\ No newline at end of file
const
balsamiqViewer
=
new
BalsamiqViewer
(
document
.
getElementById
(
'js-balsamiq-viewer'
));
balsamiqViewer
.
loadFile
();
});
app/views/projects/blob/_bmpr.html.haml
View file @
440ff838
-
content_for
:page_specific_javascripts
do
=
page_specific_javascript_bundle_tag
(
'common_vue'
)
=
page_specific_javascript_bundle_tag
(
'balsamiq_viewer'
)
.file-content
#js-balsamiq-viewer
{
data:
{
endpoint:
namespace_project_raw_path
(
@project
.
namespace
,
@project
,
@id
)
}
}
\ No newline at end of file
.file-content
#js-balsamiq-viewer
{
data:
{
endpoint:
namespace_project_raw_path
(
@project
.
namespace
,
@project
,
@id
)
}
}
Write
Preview
Markdown
is supported
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