Added tweet buttons
This commit is contained in:
parent
cab8a636f0
commit
be7710a872
@ -197,7 +197,7 @@ You can insert a table of contents using the marker `[TOC]`:
|
|||||||
### Comments
|
### Comments
|
||||||
|
|
||||||
Usually, comments in Markdown are just standard HTML comments. <!-- like this -->
|
Usually, comments in Markdown are just standard HTML comments. <!-- like this -->
|
||||||
**StackEdit** extends HTML comments in order to produce useful, highlighted comments in the preview but not in your exported documents. <!--- This is very useful for collecting feedback from other users in a collaborative document. -->
|
**StackEdit** extends HTML comments in order to produce useful, highlighted comments in the preview but not in your exported documents. <!--- This is very useful for collecting feedback in a collaborative document. -->
|
||||||
|
|
||||||
|
|
||||||
### MathJax
|
### MathJax
|
||||||
|
@ -12,6 +12,7 @@ define([
|
|||||||
"extensions/partialRendering",
|
"extensions/partialRendering",
|
||||||
"extensions/buttonMarkdownSyntax",
|
"extensions/buttonMarkdownSyntax",
|
||||||
"extensions/googleAnalytics",
|
"extensions/googleAnalytics",
|
||||||
|
"extensions/twitter",
|
||||||
"extensions/dialogAbout",
|
"extensions/dialogAbout",
|
||||||
"extensions/dialogManagePublication",
|
"extensions/dialogManagePublication",
|
||||||
"extensions/dialogManageSynchronization",
|
"extensions/dialogManageSynchronization",
|
||||||
@ -136,6 +137,10 @@ define([
|
|||||||
eventMgr.onSaveSettings = function(newExtensionSettings, event) {
|
eventMgr.onSaveSettings = function(newExtensionSettings, event) {
|
||||||
logger.log("onSaveSettings");
|
logger.log("onSaveSettings");
|
||||||
_.each(extensionList, function(extension) {
|
_.each(extensionList, function(extension) {
|
||||||
|
if(window.lightMode === true && extension.disableInLight === true) {
|
||||||
|
newExtensionSettings[extension.extensionId] = extension.config;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var newExtensionConfig = _.extend({}, extension.defaultConfig);
|
var newExtensionConfig = _.extend({}, extension.defaultConfig);
|
||||||
newExtensionConfig.enabled = utils.getInputChecked("#input-enable-extension-" + extension.extensionId);
|
newExtensionConfig.enabled = utils.getInputChecked("#input-enable-extension-" + extension.extensionId);
|
||||||
var isChecked;
|
var isChecked;
|
||||||
@ -208,6 +213,10 @@ define([
|
|||||||
|
|
||||||
// Operation on ACE
|
// Operation on ACE
|
||||||
addEventHook("onAceCreated");
|
addEventHook("onAceCreated");
|
||||||
|
|
||||||
|
// Refresh twitter buttons
|
||||||
|
addEventHook("onTweet");
|
||||||
|
|
||||||
|
|
||||||
var onPreviewFinished = createEventHook("onPreviewFinished");
|
var onPreviewFinished = createEventHook("onPreviewFinished");
|
||||||
var onAsyncPreviewListenerList = getExtensionListenerList("onAsyncPreview");
|
var onAsyncPreviewListenerList = getExtensionListenerList("onAsyncPreview");
|
||||||
|
@ -7,6 +7,11 @@ define([
|
|||||||
|
|
||||||
var dialogManageSharing = new Extension("dialogManageSharing", 'Button "Share"', false, true);
|
var dialogManageSharing = new Extension("dialogManageSharing", 'Button "Share"', false, true);
|
||||||
|
|
||||||
|
var eventMgr;
|
||||||
|
dialogManageSharing.onEventMgrCreated = function(eventMgrParam) {
|
||||||
|
eventMgr = eventMgrParam;
|
||||||
|
};
|
||||||
|
|
||||||
var fileDesc;
|
var fileDesc;
|
||||||
var shareListElt;
|
var shareListElt;
|
||||||
var $msgShareListElt;
|
var $msgShareListElt;
|
||||||
@ -19,13 +24,16 @@ define([
|
|||||||
var linkListHtml = _.reduce(fileDesc.publishLocations, function(result, attributes) {
|
var linkListHtml = _.reduce(fileDesc.publishLocations, function(result, attributes) {
|
||||||
if(attributes.sharingLink) {
|
if(attributes.sharingLink) {
|
||||||
result += _.template(dialogManageSharingLocationHTML, {
|
result += _.template(dialogManageSharingLocationHTML, {
|
||||||
link: attributes.sharingLink
|
link: attributes.sharingLink,
|
||||||
|
title: fileDesc.title
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}, '');
|
}, '');
|
||||||
shareListElt.innerHTML = linkListHtml;
|
shareListElt.innerHTML = linkListHtml;
|
||||||
|
|
||||||
|
eventMgr.onTweet();
|
||||||
|
|
||||||
$msgShareListElt.toggleClass('hide', linkListHtml.length === 0);
|
$msgShareListElt.toggleClass('hide', linkListHtml.length === 0);
|
||||||
$msgNoShareElt.toggleClass('hide', linkListHtml.length !== 0);
|
$msgNoShareElt.toggleClass('hide', linkListHtml.length !== 0);
|
||||||
};
|
};
|
||||||
@ -35,7 +43,14 @@ define([
|
|||||||
refreshDocumentSharing(fileDescParameter);
|
refreshDocumentSharing(fileDescParameter);
|
||||||
};
|
};
|
||||||
|
|
||||||
dialogManageSharing.onNewPublishSuccess = refreshDocumentSharing;
|
dialogManageSharing.onNewPublishSuccess = function(fileDescParameter, publishAttributes) {
|
||||||
|
refreshDocumentSharing(fileDescParameter);
|
||||||
|
if(publishAttributes.sharingLink) {
|
||||||
|
$('.modal').modal('hide');
|
||||||
|
$('.modal-manage-sharing').modal('show');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
dialogManageSharing.onPublishRemoved = refreshDocumentSharing;
|
dialogManageSharing.onPublishRemoved = refreshDocumentSharing;
|
||||||
|
|
||||||
dialogManageSharing.onReady = function() {
|
dialogManageSharing.onReady = function() {
|
||||||
|
39
public/res/extensions/twitter.js
Normal file
39
public/res/extensions/twitter.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*globals _gaq */
|
||||||
|
define([
|
||||||
|
"jquery",
|
||||||
|
"underscore",
|
||||||
|
"constants",
|
||||||
|
"utils",
|
||||||
|
"classes/Extension",
|
||||||
|
"settings",
|
||||||
|
], function($, _, constants, utils, Extension, settings) {
|
||||||
|
|
||||||
|
var twitter = new Extension("twitter", "Twitter", false, true);
|
||||||
|
|
||||||
|
var isLoaded = false;
|
||||||
|
var isOffline = false;
|
||||||
|
|
||||||
|
var init = function() {
|
||||||
|
if(isLoaded === false && isOffline === false) {
|
||||||
|
$.ajax({
|
||||||
|
url: 'http://platform.twitter.com/widgets.js',
|
||||||
|
dataType: "script"
|
||||||
|
}).done(function() {
|
||||||
|
isLoaded = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
twitter.onReady = function() {
|
||||||
|
init();
|
||||||
|
};
|
||||||
|
twitter.onOfflineChanged = function(isOfflineParam) {
|
||||||
|
isOffline = isOfflineParam;
|
||||||
|
init();
|
||||||
|
};
|
||||||
|
twitter.onTweet = function() {
|
||||||
|
isLoaded && window.twttr.widgets.load();
|
||||||
|
};
|
||||||
|
|
||||||
|
return twitter;
|
||||||
|
});
|
@ -7,6 +7,11 @@ define([
|
|||||||
], function(_, $, storage, Extension, Tour) {
|
], function(_, $, storage, Extension, Tour) {
|
||||||
|
|
||||||
var welcomeTour = new Extension('welcomeTour', 'Welcome tour', false, true);
|
var welcomeTour = new Extension('welcomeTour', 'Welcome tour', false, true);
|
||||||
|
|
||||||
|
var eventMgr;
|
||||||
|
welcomeTour.onEventMgrCreated = function(eventMgrParam) {
|
||||||
|
eventMgr = eventMgrParam;
|
||||||
|
};
|
||||||
|
|
||||||
welcomeTour.onReady = function() {
|
welcomeTour.onReady = function() {
|
||||||
var tour = new Tour({
|
var tour = new Tour({
|
||||||
@ -103,9 +108,13 @@ define([
|
|||||||
element: '.navbar-inner',
|
element: '.navbar-inner',
|
||||||
title: 'Happy StackWriting!',
|
title: 'Happy StackWriting!',
|
||||||
content: [
|
content: [
|
||||||
'Enjoy, and don\'t forget to rate <b>StackEdit</b> on <a target="_blank" href="https://chrome.google.com/webstore/detail/stackedit/iiooodelglhkcpgbajoejffhijaclcdg/reviews">Chrome Web Store</a>...',
|
'<p>Enjoy, and don\'t forget to rate <b>StackEdit</b> on <a target="_blank" href="https://chrome.google.com/webstore/detail/stackedit/iiooodelglhkcpgbajoejffhijaclcdg/reviews">Chrome Web Store</a>...</p>',
|
||||||
|
'<a href="https://twitter.com/share" class="twitter-share-button" data-url="https://stackedit.io" data-text="StackEdit – markdown editor" data-via="stackedit" data-size="large"></a>',
|
||||||
].join(""),
|
].join(""),
|
||||||
placement: 'bottom',
|
placement: 'bottom',
|
||||||
|
onShown: function() {
|
||||||
|
eventMgr.onTweet();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
if(!_.has(storage, 'welcomeTour')) {
|
if(!_.has(storage, 'welcomeTour')) {
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
height="64" />
|
height="64" />
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
<div class="pull-right">
|
||||||
|
<a href="https://twitter.com/share" class="twitter-share-button" data-url="https://stackedit.io" data-text="StackEdit – markdown editor" data-via="stackedit" data-size="large"></a>
|
||||||
|
</div>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>About:</dt>
|
<dt>About:</dt>
|
||||||
<dd>
|
<dd>
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
<div class="sharing-tweet">
|
||||||
|
<a href="https://twitter.com/share" class="twitter-share-button" data-url="<%= link %>" data-text="<%- title %>" data-via="stackedit" data-size="large" data-count="none"></a>
|
||||||
|
</div>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<a href="<%= link %>" class="input-group-addon" title="Sharing location"><i
|
<a href="<%= link %>" class="input-group-addon" title="Sharing location"><i
|
||||||
class="icon-provider-stackedit"></i></a> <input class="form-control" type="text"
|
class="icon-provider-stackedit"></i></a> <input class="form-control" type="text"
|
||||||
|
@ -1295,6 +1295,11 @@ input[type="file"] {
|
|||||||
white-space: inherit;
|
white-space: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sharing-tweet {
|
||||||
|
float: left;
|
||||||
|
margin: 5px 10px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* Bootstrap tour
|
* Bootstrap tour
|
||||||
|
Loading…
Reference in New Issue
Block a user