Added tweet buttons

This commit is contained in:
benweet 2014-02-02 21:00:05 +00:00
parent cab8a636f0
commit be7710a872
8 changed files with 87 additions and 4 deletions

View File

@ -197,7 +197,7 @@ You can insert a table of contents using the marker `[TOC]`:
### Comments
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

View File

@ -12,6 +12,7 @@ define([
"extensions/partialRendering",
"extensions/buttonMarkdownSyntax",
"extensions/googleAnalytics",
"extensions/twitter",
"extensions/dialogAbout",
"extensions/dialogManagePublication",
"extensions/dialogManageSynchronization",
@ -136,6 +137,10 @@ define([
eventMgr.onSaveSettings = function(newExtensionSettings, event) {
logger.log("onSaveSettings");
_.each(extensionList, function(extension) {
if(window.lightMode === true && extension.disableInLight === true) {
newExtensionSettings[extension.extensionId] = extension.config;
return;
}
var newExtensionConfig = _.extend({}, extension.defaultConfig);
newExtensionConfig.enabled = utils.getInputChecked("#input-enable-extension-" + extension.extensionId);
var isChecked;
@ -208,6 +213,10 @@ define([
// Operation on ACE
addEventHook("onAceCreated");
// Refresh twitter buttons
addEventHook("onTweet");
var onPreviewFinished = createEventHook("onPreviewFinished");
var onAsyncPreviewListenerList = getExtensionListenerList("onAsyncPreview");

View File

@ -7,6 +7,11 @@ define([
var dialogManageSharing = new Extension("dialogManageSharing", 'Button "Share"', false, true);
var eventMgr;
dialogManageSharing.onEventMgrCreated = function(eventMgrParam) {
eventMgr = eventMgrParam;
};
var fileDesc;
var shareListElt;
var $msgShareListElt;
@ -19,13 +24,16 @@ define([
var linkListHtml = _.reduce(fileDesc.publishLocations, function(result, attributes) {
if(attributes.sharingLink) {
result += _.template(dialogManageSharingLocationHTML, {
link: attributes.sharingLink
link: attributes.sharingLink,
title: fileDesc.title
});
}
return result;
}, '');
shareListElt.innerHTML = linkListHtml;
eventMgr.onTweet();
$msgShareListElt.toggleClass('hide', linkListHtml.length === 0);
$msgNoShareElt.toggleClass('hide', linkListHtml.length !== 0);
};
@ -35,7 +43,14 @@ define([
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.onReady = function() {

View 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;
});

View File

@ -7,6 +7,11 @@ define([
], function(_, $, storage, Extension, Tour) {
var welcomeTour = new Extension('welcomeTour', 'Welcome tour', false, true);
var eventMgr;
welcomeTour.onEventMgrCreated = function(eventMgrParam) {
eventMgr = eventMgrParam;
};
welcomeTour.onReady = function() {
var tour = new Tour({
@ -103,9 +108,13 @@ define([
element: '.navbar-inner',
title: 'Happy StackWriting!',
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(""),
placement: 'bottom',
onShown: function() {
eventMgr.onTweet();
}
},
]);
if(!_.has(storage, 'welcomeTour')) {

View File

@ -6,6 +6,9 @@
height="64" />
</div>
<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>
<dt>About:</dt>
<dd>

View File

@ -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">
<a href="<%= link %>" class="input-group-addon" title="Sharing location"><i
class="icon-provider-stackedit"></i></a> <input class="form-control" type="text"

View File

@ -1295,6 +1295,11 @@ input[type="file"] {
white-space: inherit;
}
.sharing-tweet {
float: left;
margin: 5px 10px 0 0;
}
/*********************
* Bootstrap tour