Fixed stats and toc
This commit is contained in:
parent
019ae6a3bf
commit
8ec72de663
@ -490,6 +490,14 @@ div.dropdown-menu i {
|
|||||||
z-index: 1050 !important;
|
z-index: 1050 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#modal-settings .modal-header {
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal-settings .form-horizontal {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
#modal-settings textarea {
|
#modal-settings textarea {
|
||||||
height: 80px;
|
height: 80px;
|
||||||
max-width: 206px;
|
max-width: 206px;
|
||||||
@ -526,19 +534,24 @@ div.dropdown-menu i {
|
|||||||
margin: 0 10px;
|
margin: 0 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.accordion-toggle {
|
#modal-settings .accordion-toggle {
|
||||||
cursor: help;
|
cursor: help;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#modal-settings .tab-pane-button-container {
|
||||||
|
width: 200px;
|
||||||
|
margin: 10px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal-settings .nav-tabs {
|
||||||
|
border-bottom: 1px solid transparent;
|
||||||
|
margin: 20px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
.nav-tabs > .active > a, .nav-tabs > .active > a:hover, .nav-tabs > .active > a:focus {
|
.nav-tabs > .active > a, .nav-tabs > .active > a:hover, .nav-tabs > .active > a:focus {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: #777;
|
background-color: #777;
|
||||||
border-color: #777;
|
border-color: #777;
|
||||||
border-bottom-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-tabs {
|
|
||||||
border-bottom-color: #eee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav > li > a:hover,
|
.nav > li > a:hover,
|
||||||
@ -551,6 +564,11 @@ div.dropdown-menu i {
|
|||||||
border-color: #eee;
|
border-color: #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tooltip-inner {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Table style */
|
||||||
table {
|
table {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
@ -510,8 +510,6 @@
|
|||||||
<button type="button" class="close" data-dismiss="modal"
|
<button type="button" class="close" data-dismiss="modal"
|
||||||
aria-hidden="true">×</button>
|
aria-hidden="true">×</button>
|
||||||
<h3>Settings</h3>
|
<h3>Settings</h3>
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<li class="active"><a class="action-load-settings"
|
<li class="active"><a class="action-load-settings"
|
||||||
href="#tabpane-settings-editor" data-toggle="tab">Editor</a></li>
|
href="#tabpane-settings-editor" data-toggle="tab">Editor</a></li>
|
||||||
@ -522,6 +520,8 @@
|
|||||||
<li><a class="action-load-settings"
|
<li><a class="action-load-settings"
|
||||||
href="#tabpane-settings-utils" data-toggle="tab">Utils</a></li>
|
href="#tabpane-settings-utils" data-toggle="tab">Utils</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane active" id="tabpane-settings-editor">
|
<div class="tab-pane active" id="tabpane-settings-editor">
|
||||||
@ -608,7 +608,7 @@
|
|||||||
your own extension...</a></span>
|
your own extension...</a></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="tabpane-settings-utils">
|
<div class="tab-pane" id="tabpane-settings-utils">
|
||||||
<div style="width: 200px; margin: 10px auto;">
|
<div class="tab-pane-button-container">
|
||||||
<a href="#" class="btn btn-block btn-primary action-welcome-file"
|
<a href="#" class="btn btn-block btn-primary action-welcome-file"
|
||||||
data-dismiss="modal">Welcome document</a> <a href="#"
|
data-dismiss="modal">Welcome document</a> <a href="#"
|
||||||
class="btn btn-block btn-primary action-default-settings"
|
class="btn btn-block btn-primary action-default-settings"
|
||||||
|
@ -89,6 +89,7 @@ define([
|
|||||||
addHook("onFileMgrCreated");
|
addHook("onFileMgrCreated");
|
||||||
addHook("onSynchronizerCreated");
|
addHook("onSynchronizerCreated");
|
||||||
addHook("onPublisherCreated");
|
addHook("onPublisherCreated");
|
||||||
|
addHook("onExtensionMgrCreated");
|
||||||
|
|
||||||
// Operations on files
|
// Operations on files
|
||||||
addHook("onFileCreated");
|
addHook("onFileCreated");
|
||||||
@ -177,5 +178,7 @@ define([
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// For extensions that need to call other extensions
|
||||||
|
extensionMgr.onExtensionMgrCreated(extensionMgr);
|
||||||
return extensionMgr;
|
return extensionMgr;
|
||||||
});
|
});
|
@ -14,7 +14,7 @@ define([
|
|||||||
name2: "Characters",
|
name2: "Characters",
|
||||||
value2: "\\S",
|
value2: "\\S",
|
||||||
name3: "Paragraphs",
|
name3: "Paragraphs",
|
||||||
value3: ".+",
|
value3: "\\S.*",
|
||||||
},
|
},
|
||||||
settingsBloc: [
|
settingsBloc: [
|
||||||
'<p>Adds a "Document statistics" button in the navigation bar.</p>',
|
'<p>Adds a "Document statistics" button in the navigation bar.</p>',
|
||||||
@ -35,18 +35,29 @@ define([
|
|||||||
' <input id="input-stat-name3" type="text" class="input-small">',
|
' <input id="input-stat-name3" type="text" class="input-small">',
|
||||||
' <label class="label-text" for="input-stat-value3">RegExp</label>',
|
' <label class="label-text" for="input-stat-value3">RegExp</label>',
|
||||||
' <input id="input-stat-value3" type="text" class="span2">',
|
' <input id="input-stat-value3" type="text" class="span2">',
|
||||||
'</div></p>'].join("")
|
'</div></p>'
|
||||||
|
].join("")
|
||||||
};
|
};
|
||||||
|
|
||||||
buttonStat.onLoadSettings = function() {
|
buttonStat.onLoadSettings = function() {
|
||||||
_.each(buttonStat.defaultConfig, function(value, key) {
|
_.each([
|
||||||
utils.setInputValue("#input-stat-" + key, buttonStat.config[key]);
|
1,
|
||||||
|
2,
|
||||||
|
3
|
||||||
|
], function(index) {
|
||||||
|
utils.setInputValue("#input-stat-name" + index, buttonStat.config["name" + index]);
|
||||||
|
utils.setInputValue("#input-stat-value" + index, buttonStat.config["value" + index]);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
buttonStat.onSaveSettings = function(newConfig, event) {
|
buttonStat.onSaveSettings = function(newConfig, event) {
|
||||||
_.each(buttonStat.defaultConfig, function(value, key) {
|
_.each([
|
||||||
newConfig[key] = utils.getInputTextValue("#input-stat-" + key, event);
|
1,
|
||||||
|
2,
|
||||||
|
3
|
||||||
|
], function(index) {
|
||||||
|
newConfig["name" + index] = utils.getInputTextValue("#input-stat-name" + index, event);
|
||||||
|
newConfig["value" + index] = utils.getInputRegExpValue("#input-stat-value" + index, event);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,10 +78,10 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
buttonStat.onPreviewFinished = function() {
|
buttonStat.onPreviewFinished = function() {
|
||||||
var text = $("#wmd-preview").text();
|
var text = $("#wmd-preview").clone().find("script").remove().end().text();
|
||||||
$("#span-stat-value1").text(text.match(new RegExp(buttonStat.config.value1, "g")).length);
|
$("#span-stat-value1").text((text.match(new RegExp(buttonStat.config.value1, "g")) || []).length);
|
||||||
$("#span-stat-value2").text(text.match(new RegExp(buttonStat.config.value2, "g")).length);
|
$("#span-stat-value2").text((text.match(new RegExp(buttonStat.config.value2, "g")) || []).length);
|
||||||
$("#span-stat-value3").text(text.match(new RegExp(buttonStat.config.value3, "g")).length);
|
$("#span-stat-value3").text((text.match(new RegExp(buttonStat.config.value3, "g")) || []).length);
|
||||||
};
|
};
|
||||||
|
|
||||||
return buttonStat;
|
return buttonStat;
|
||||||
|
@ -4,7 +4,7 @@ define(function() {
|
|||||||
extensionId: "emailConverter",
|
extensionId: "emailConverter",
|
||||||
extensionName: "Email Converter",
|
extensionName: "Email Converter",
|
||||||
optional: true,
|
optional: true,
|
||||||
settingsBloc: '<p>Converts email adresses in the form <email@example.com> into a clickable links.</p>'
|
settingsBloc: '<p>Converts email adresses in the form <email@example.com> into clickable links.</p>'
|
||||||
};
|
};
|
||||||
|
|
||||||
emailConverter.onEditorConfigure = function(editor) {
|
emailConverter.onEditorConfigure = function(editor) {
|
||||||
|
@ -8,9 +8,30 @@ define([
|
|||||||
extensionId: "toc",
|
extensionId: "toc",
|
||||||
extensionName: "Table of content",
|
extensionName: "Table of content",
|
||||||
optional: true,
|
optional: true,
|
||||||
settingsBloc: '<p>Generates a table of content when a [TOC] marker is found.</p>'
|
defaultConfig: {
|
||||||
|
marker: "\\[(TOC|toc)\\]"
|
||||||
|
},
|
||||||
|
settingsBloc: [
|
||||||
|
'<p>Generates a table of content when a [TOC] marker is found.</p>',
|
||||||
|
'<div class="form-horizontal">',
|
||||||
|
' <div class="control-group">',
|
||||||
|
' <label class="control-label" for="input-toc-marker">Marker RegExp</label>',
|
||||||
|
' <div class="controls">',
|
||||||
|
' <input type="text" id="input-toc-marker" class="span2">',
|
||||||
|
' </div>',
|
||||||
|
' </div>',
|
||||||
|
'</div>'
|
||||||
|
].join("")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
toc.onLoadSettings = function() {
|
||||||
|
utils.setInputValue("#input-toc-marker", toc.config.marker);
|
||||||
|
};
|
||||||
|
|
||||||
|
toc.onSaveSettings = function(newConfig, event) {
|
||||||
|
newConfig.marker = utils.getInputRegExpValue("#input-toc-marker", event);
|
||||||
|
};
|
||||||
|
|
||||||
// TOC element description
|
// TOC element description
|
||||||
function TocElement(tagName, anchor, text) {
|
function TocElement(tagName, anchor, text) {
|
||||||
this.tagName = tagName;
|
this.tagName = tagName;
|
||||||
@ -97,9 +118,9 @@ define([
|
|||||||
toc.onEditorConfigure = function(editor) {
|
toc.onEditorConfigure = function(editor) {
|
||||||
// Run TOC generation when conversion is finished directly on HTML
|
// Run TOC generation when conversion is finished directly on HTML
|
||||||
editor.hooks.chain("onPreviewRefresh", function() {
|
editor.hooks.chain("onPreviewRefresh", function() {
|
||||||
var toc = buildToc();
|
var htmlToc = buildToc();
|
||||||
var html = $("#wmd-preview").html();
|
var html = $("#wmd-preview").html();
|
||||||
html = html.replace(/<p>\[TOC\]<\/p>/g, toc);
|
html = html.replace(new RegExp("<p>" + toc.config.marker + "<\\/p>", "g"), htmlToc);
|
||||||
$("#wmd-preview").html(html);
|
$("#wmd-preview").html(html);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -2,10 +2,11 @@ define([
|
|||||||
"underscore",
|
"underscore",
|
||||||
"core",
|
"core",
|
||||||
"utils",
|
"utils",
|
||||||
|
"settings",
|
||||||
"extension-manager",
|
"extension-manager",
|
||||||
"file-manager",
|
"file-manager",
|
||||||
"google-helper"
|
"google-helper"
|
||||||
], function(_, core, utils, extensionMgr, fileMgr, googleHelper) {
|
], function(_, core, utils, settings, extensionMgr, fileMgr, googleHelper) {
|
||||||
|
|
||||||
var PROVIDER_GDRIVE = "gdrive";
|
var PROVIDER_GDRIVE = "gdrive";
|
||||||
|
|
||||||
@ -250,7 +251,7 @@ define([
|
|||||||
localStorage.removeItem(PROVIDER_GDRIVE + ".state");
|
localStorage.removeItem(PROVIDER_GDRIVE + ".state");
|
||||||
state = JSON.parse(state);
|
state = JSON.parse(state);
|
||||||
if(state.action == "create") {
|
if(state.action == "create") {
|
||||||
googleHelper.upload(undefined, state.folderId, GDRIVE_DEFAULT_FILE_TITLE, "", undefined, function(error, file) {
|
googleHelper.upload(undefined, state.folderId, GDRIVE_DEFAULT_FILE_TITLE, settings.defaultContent, undefined, function(error, file) {
|
||||||
if(error) {
|
if(error) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,7 @@ define([
|
|||||||
if(response && response.id) {
|
if(response && response.id) {
|
||||||
// Upload success
|
// Upload success
|
||||||
result = response;
|
result = response;
|
||||||
|
result.content = content;
|
||||||
task.chain();
|
task.chain();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
17
js/utils.js
17
js/utils.js
@ -77,6 +77,23 @@ define([
|
|||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Return input value and check that it's a valid RegExp
|
||||||
|
utils.getInputRegExpValue = function(element, event) {
|
||||||
|
element = jqElt(element);
|
||||||
|
var value = utils.getInputTextValue(element, event);
|
||||||
|
if(value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
new RegExp(value);
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
inputError(element, event);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
// Return checkbox boolean value
|
// Return checkbox boolean value
|
||||||
utils.getInputChecked = function(element) {
|
utils.getInputChecked = function(element) {
|
||||||
element = jqElt(element);
|
element = jqElt(element);
|
||||||
|
@ -23,7 +23,7 @@ input[readonly], select[readonly], textarea[readonly] {
|
|||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
textarea, input, .dropdown-menu, .modal {
|
#wmd-input, input, .dropdown-menu, .modal {
|
||||||
background: #111;
|
background: #111;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
@ -176,15 +176,14 @@ input[type="color"]:focus,
|
|||||||
box-shadow: inset 0 1px 1px rgba(255, 134, 97, 0), 0 0 8px rgba(255, 255, 255, 1) !important;
|
box-shadow: inset 0 1px 1px rgba(255, 134, 97, 0), 0 0 8px rgba(255, 255, 255, 1) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#modal-settings .accordion-group {
|
||||||
|
border-bottom-color: #222;
|
||||||
|
}
|
||||||
|
|
||||||
.nav-tabs > .active > a, .nav-tabs > .active > a:hover, .nav-tabs > .active > a:focus {
|
.nav-tabs > .active > a, .nav-tabs > .active > a:hover, .nav-tabs > .active > a:focus {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
border-color: #333;
|
border-color: #333;
|
||||||
border-bottom-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-tabs {
|
|
||||||
border-bottom-color: #222;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav > li > a:hover,
|
.nav > li > a:hover,
|
||||||
|
Loading…
Reference in New Issue
Block a user