Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
uncloud
files_readmemd
Commits
a4ed65ae
Commit
a4ed65ae
authored
Dec 14, 2018
by
Matthieu Le Corre
Browse files
checkbox bug
parent
44c2c1f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
css/style.css
View file @
a4ed65ae
...
@@ -11,8 +11,10 @@
...
@@ -11,8 +11,10 @@
}
}
.headermd
{
.headermd
{
padding
:
2
em
;
padding
:
1
em
;
border-bottom
:
1px
solid
silver
;
border-bottom
:
1px
solid
silver
;
margin-bottom
:
1em
;
}
}
.down
{
margin-top
:
70px
;
}
js/script.js
View file @
a4ed65ae
...
@@ -7,6 +7,7 @@ OCA.ReadmeMD = {};
...
@@ -7,6 +7,7 @@ OCA.ReadmeMD = {};
* @namespace OCA.IndexMD.App
* @namespace OCA.IndexMD.App
*/
*/
OCA
.
ReadmeMD
.
App
=
{
OCA
.
ReadmeMD
.
App
=
{
/**
/**
* Holds the MDs objects
* Holds the MDs objects
*/
*/
...
@@ -17,6 +18,9 @@ OCA.ReadmeMD.App = {
...
@@ -17,6 +18,9 @@ OCA.ReadmeMD.App = {
* Setup on page load
* Setup on page load
*/
*/
initialize
:
function
(
header
,
readme
)
{
initialize
:
function
(
header
,
readme
)
{
var
self
=
this
;
// Don't load if not in the files app
// Don't load if not in the files app
if
(
!
$
(
'
#content.app-files
'
).
length
)
{
if
(
!
$
(
'
#content.app-files
'
).
length
)
{
return
;
return
;
...
@@ -28,19 +32,28 @@ OCA.ReadmeMD.App = {
...
@@ -28,19 +32,28 @@ OCA.ReadmeMD.App = {
return
;
return
;
}
}
//initialise MD renderer
OCA
.
Files_Texteditor
.
previewPlugins
[
"
text/markdown
"
].
init
()
;
// trigger on filetable
$
(
"
#filestable
"
).
on
(
'
updated
'
,
this
.
checkMD
);
// container creation
// container creation
this
.
header
=
header
;
this
.
header
=
header
;
this
.
readme
=
readme
;
this
.
readme
=
readme
;
this
.
createContainer
(
this
.
header
)
;
this
.
createContainer
(
this
.
header
)
;
this
.
createContainer
(
this
.
readme
)
;
this
.
createContainer
(
this
.
readme
)
;
//initialise MD renderer
this
.
PromiseMDinit
=
OCA
.
Files_Texteditor
.
previewPlugins
[
"
text/markdown
"
].
init
()
// then trigger on filetable to check if README/HEADER are present
$
(
"
#filestable
"
)
.
on
(
'
updated
'
,
function
()
{
self
.
checkMD
()
;
})
//trigger on multiselect to handle the infamous fixed position toolsbar
$
(
"
#filestable
"
).
on
(
'
updated
'
,
function
()
{
$
(
"
#filestable input:checkbox
"
).
change
(
function
()
{
self
.
handleMultiselect
()
;
});
});
},
},
...
@@ -48,19 +61,27 @@ OCA.ReadmeMD.App = {
...
@@ -48,19 +61,27 @@ OCA.ReadmeMD.App = {
* check MD handler
* check MD handler
*/
*/
checkMD
:
function
()
{
checkMD
:
function
()
{
OCA
.
ReadmeMD
.
header
.
container
.
addClass
(
"
hidden
"
)
;
OCA
.
ReadmeMD
.
readme
.
container
.
addClass
(
"
hidden
"
)
;
//cleanup "old" MDs before checking for new ones
this
.
header
.
container
.
addClass
(
"
hidden
"
)
;
this
.
header
.
container
.
children
().
remove
()
;
this
.
header
.
content
=
null
;
this
.
readme
.
container
.
addClass
(
"
hidden
"
)
;
this
.
readme
.
container
.
children
().
remove
()
;
this
.
readme
.
content
=
null
;
//list file from current dir and check
for
(
var
filenum
in
OCA
.
Files
.
App
.
fileList
.
files
)
{
for
(
var
filenum
in
OCA
.
Files
.
App
.
fileList
.
files
)
{
if
(
OCA
.
Files
.
App
.
fileList
.
files
[
filenum
].
name
==
OCA
.
ReadmeMD
.
header
.
filename
)
{
if
(
OCA
.
Files
.
App
.
fileList
.
files
[
filenum
].
name
==
this
.
header
.
filename
)
{
OCA
.
ReadmeMD
.
header
.
container
.
removeClass
(
"
hidden
"
)
;
this
.
header
.
container
.
removeClass
(
"
hidden
"
)
;
OCA
.
ReadmeMD
.
fillContainer
(
OCA
.
ReadmeMD
.
header
)
;
this
.
fillContainer
(
OCA
.
ReadmeMD
.
header
)
;
}
;
}
;
if
(
OCA
.
Files
.
App
.
fileList
.
files
[
filenum
].
name
==
OCA
.
ReadmeMD
.
readme
.
filename
)
{
if
(
OCA
.
Files
.
App
.
fileList
.
files
[
filenum
].
name
==
this
.
readme
.
filename
)
{
OCA
.
ReadmeMD
.
readme
.
container
.
removeClass
(
"
hidden
"
)
;
this
.
readme
.
container
.
removeClass
(
"
hidden
"
)
;
OCA
.
ReadmeMD
.
fillContainer
(
OCA
.
ReadmeMD
.
readme
)
;
this
.
fillContainer
(
OCA
.
ReadmeMD
.
readme
)
;
}
;
}
;
}
;
}
;
...
@@ -84,52 +105,53 @@ OCA.ReadmeMD.App = {
...
@@ -84,52 +105,53 @@ OCA.ReadmeMD.App = {
* fill contant
* fill contant
*/
*/
fillContainer
:
function
(
zone
)
{
fillContainer
:
function
(
zone
)
{
dir
=
OCA
.
Files
.
App
.
fileList
.
_currentDirectory
;
i
var
self
=
this
;
if
(
zone
.
position
===
"
before
"
)
{
dir
=
OCA
.
Files
.
App
.
fileList
.
_currentDirectory
;
$
.
get
(
//load header file via texteditor apps
OC
.
generateUrl
(
'
/apps/files_texteditor/ajax/loadfile
'
),
$
.
get
(
{
OC
.
generateUrl
(
'
/apps/files_texteditor/ajax/loadfile
'
),
filename
:
zone
.
filename
,
{
dir
:
dir
filename
:
zone
.
filename
,
}
dir
:
dir
).
done
(
function
(
data
,
textStatus
,
jqXHR
)
{
}
OCA
.
ReadmeMD
.
header
.
content
=
data
.
filecontents
;
).
done
(
function
(
data
)
{
OCA
.
ReadmeMD
.
renderMD
(
OCA
.
ReadmeMD
.
header
)
;
//promise solved -> render MarkDown
})
;
zone
.
content
=
data
.
filecontents
;
};
self
.
renderMD
(
zone
)
;
})
;
if
(
zone
.
position
===
"
after
"
)
{
$
.
get
(
OC
.
generateUrl
(
'
/apps/files_texteditor/ajax/loadfile
'
),
{
filename
:
zone
.
filename
,
dir
:
dir
}
).
done
(
function
(
data
,
textStatus
,
jqXHR
)
{
OCA
.
ReadmeMD
.
readme
.
content
=
data
.
filecontents
;
OCA
.
ReadmeMD
.
renderMD
(
OCA
.
ReadmeMD
.
readme
)
;
})
;
};
},
},
/**
/**
* Render Markdown
* Render Markdown
**/
**/
renderMD
:
function
(
zone
)
{
renderMD
:
function
(
zone
)
{
//cleanup old content
zone
.
container
.
children
().
remove
();
//render MD
//render MD
OCA
.
Files_Texteditor
.
previewPlugins
[
"
text/markdown
"
].
renderer
.
renderText
(
OCA
.
Files_Texteditor
.
previewPlugins
[
"
text/markdown
"
].
renderer
.
renderText
(
zone
.
content
,
zone
.
content
,
zone
.
container
zone
.
container
).
done
(
function
(
data
)
{
).
done
(
function
(
data
)
{
$
(
"
#filestable > tfoot > tr
"
).
height
(
"
auto
"
)
;
$
(
"
#filestable > tfoot > tr
"
).
height
(
"
auto
"
)
;
});
});
}
},
/**
* Handle Multiselect
**/
handleMultiselect
:
function
()
{
// on checkbox change on filestable, check the multiselect class to hide header
// and move footer 70px down, see css
if
(
$
(
"
#filestable input:checked
"
).
size
()
>
0
)
{
this
.
header
.
container
.
addClass
(
"
hidden
"
)
;
this
.
readme
.
container
.
addClass
(
"
down
"
)
;
}
else
{
if
(
this
.
header
.
content
!=
null
)
{
this
.
header
.
container
.
removeClass
(
"
hidden
"
)
;
}
this
.
readme
.
container
.
removeClass
(
"
down
"
)
;
}
}
};
};
...
...
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