Commit cf171091 authored by Emmanuel Raviart's avatar Emmanuel Raviart

Add other social buttons.

parent e8582f6b
......@@ -278,6 +278,18 @@ update msg ({ editedProperty } as model) authentication language =
in
( newModel, Cmd.none )
ShareOnFacebook url ->
( model, Ports.shareOnFacebook url )
ShareOnGooglePlus url ->
( model, Ports.shareOnGooglePlus url )
ShareOnLinkedIn url ->
( model, Ports.shareOnLinkedIn url )
ShareOnTwitter url ->
( model, Ports.shareOnTwitter url )
SubmitValue selectedField ->
let
( cardId, keyId ) =
......@@ -306,9 +318,6 @@ update msg ({ editedProperty } as model) authentication language =
in
( model, cmd )
Tweet twitterUrl ->
( model, Ports.tweet twitterUrl )
VotePropertyDown propertyId ->
let
cmd =
......
......@@ -39,8 +39,11 @@ type InternalMsg
| PropertyPosted (Result Http.Error DataIdBody)
| RatingPosted (Result Http.Error DataIdBody)
| SelectField Field
| ShareOnFacebook String
| ShareOnGooglePlus String
| ShareOnLinkedIn String
| ShareOnTwitter String
| SubmitValue Field
| Tweet String
| VotePropertyDown String
| VotePropertyUp String
......
......@@ -2,6 +2,7 @@ module Card.View exposing (..)
import Card.Types exposing (..)
import Configuration
import Constants
import Dict exposing (Dict)
import Html exposing (..)
import Html.Attributes exposing (..)
......@@ -1138,36 +1139,77 @@ viewSidebar language card values =
cardName =
I18n.getName language card values
imageUrl =
getOneString language imageUrlPathKeys card values
|> Maybe.withDefault Constants.logoUrl
url =
Urls.fullUrl
(Routes.makeUrlWithLanguage language (Routes.urlPathForCard card))
facebookUrl =
"http://www.facebook.com/sharer.php?s=100&p[title]="
++ Http.encodeUri cardName
++ "&p[summary]="
++ Http.encodeUri (I18n.translate language (I18n.TweetMessage cardName url))
++ "&p[url]="
++ Http.encodeUri url
++ "&p[images][0]="
++ Http.encodeUri imageUrl
googlePlusUrl =
"https://plus.google.com/share?url=" ++ Http.encodeUri url
linkedInUrl =
"https://www.linkedin.com/shareArticle?mini=true&url="
++ Http.encodeUri url
++ "&title="
++ Http.encodeUri cardName
++ "&summary="
++ Http.encodeUri (I18n.translate language (I18n.TweetMessage cardName url))
++ "&source="
++ Http.encodeUri "OGP Toolbox"
twitterUrl =
"https://twitter.com/intent/tweet?text="
++ Http.encodeUri (I18n.translate language (I18n.TweetMessage cardName url))
in
-- [ button [ class "btn btn-default btn-action btn-round", type' "button" ]
-- [ i [ attribute "aria-hidden" "true", class "fa fa-facebook" ]
-- []
-- ]
[ a
[ class "btn btn-default btn-action btn-round"
, href facebookUrl
, onWithOptions
"click"
{ stopPropagation = True, preventDefault = True }
(Decode.succeed (ForSelf <| ShareOnFacebook facebookUrl))
]
[ i [ attribute "aria-hidden" "true", class "fa fa-facebook" ] [] ]
, a
[ class "btn btn-default btn-action btn-round"
, href googlePlusUrl
, onWithOptions
"click"
{ stopPropagation = True, preventDefault = True }
(Decode.succeed (ForSelf <| ShareOnGooglePlus googlePlusUrl))
]
[ i [ attribute "aria-hidden" "true", class "fa fa-google-plus" ] [] ]
, a
[ class "btn btn-default btn-action btn-round"
, href linkedInUrl
, onWithOptions
"click"
{ stopPropagation = True, preventDefault = True }
(Decode.succeed (ForSelf <| ShareOnLinkedIn linkedInUrl))
]
[ i [ attribute "aria-hidden" "true", class "fa fa-linkedin" ] [] ]
, a
[ class "btn btn-default btn-action btn-round"
, href twitterUrl
, onWithOptions
"click"
{ stopPropagation = True, preventDefault = True }
(Decode.succeed (ForSelf <| Tweet twitterUrl))
-- , onClick (ForSelf <| Tweet twitterUrl)
(Decode.succeed (ForSelf <| ShareOnTwitter twitterUrl))
]
[ i [ attribute "aria-hidden" "true", class "fa fa-twitter" ] [] ]
-- , button [ class "btn btn-default btn-action btn-round", type' "button" ]
-- [ i [ attribute "aria-hidden" "true", class "fa fa-google-plus" ]
-- []
-- ]
-- , button [ class "btn btn-default btn-action btn-round", type' "button" ]
-- [ i [ attribute "aria-hidden" "true", class "fa fa-linkedin" ]
-- []
-- ]
]
)
]
......
......@@ -48,7 +48,7 @@ update msg model authentication language =
Ports.setDocumentMetadata
{ description = collection.description
, imageUrl =
(collection.logo |> Maybe.withDefault Constants.logoUrl)
collection.logo |> Maybe.withDefault Constants.logoUrl
, title = collection.name
}
in
......@@ -65,5 +65,14 @@ update msg model authentication language =
in
( newModel, cmd )
Tweet twitterUrl ->
( model, Ports.tweet twitterUrl )
ShareOnFacebook url ->
( model, Ports.shareOnFacebook url )
ShareOnGooglePlus url ->
( model, Ports.shareOnGooglePlus url )
ShareOnLinkedIn url ->
( model, Ports.shareOnLinkedIn url )
ShareOnTwitter url ->
( model, Ports.shareOnTwitter url )
......@@ -16,7 +16,10 @@ type ExternalMsg
type InternalMsg
= GotCollection (Result Http.Error DataIdBody)
| LoadCollection String
| Tweet String
| ShareOnFacebook String
| ShareOnGooglePlus String
| ShareOnLinkedIn String
| ShareOnTwitter String
type Msg
......
module Collection.View exposing (..)
import Collection.Types exposing (..)
import Constants
import Dict exposing (Dict)
import Html exposing (..)
import Html.Attributes exposing (..)
......@@ -140,32 +141,75 @@ viewCollectionContent language user collection cards values =
Urls.fullUrl
(Routes.makeUrlWithLanguage language ("/collections/" ++ collection.id))
imageUrl =
collection.logo |> Maybe.withDefault Constants.logoUrl
facebookUrl =
"http://www.facebook.com/sharer.php?s=100&p[title]="
++ Http.encodeUri collection.name
++ "&p[summary]="
++ Http.encodeUri
(I18n.translate language (I18n.TweetMessage collection.name url))
++ "&p[url]="
++ Http.encodeUri url
++ "&p[images][0]="
++ Http.encodeUri imageUrl
googlePlusUrl =
"https://plus.google.com/share?url=" ++ Http.encodeUri url
linkedInUrl =
"https://www.linkedin.com/shareArticle?mini=true&url="
++ Http.encodeUri url
++ "&title="
++ Http.encodeUri collection.name
++ "&summary="
++ Http.encodeUri
(I18n.translate language (I18n.TweetMessage collection.name url))
++ "&source="
++ Http.encodeUri "OGP Toolbox"
twitterUrl =
"https://twitter.com/intent/tweet?text="
++ Http.encodeUri (I18n.translate language (I18n.TweetMessage collection.name url))
++ Http.encodeUri
(I18n.translate language (I18n.TweetMessage collection.name url))
in
-- [ button [ class "btn btn-default btn-action btn-round", type' "button" ]
-- [ i [ attribute "aria-hidden" "true", class "fa fa-facebook" ]
-- []
-- ]
[ a
[ class "btn btn-default btn-action btn-round"
, href facebookUrl
, onWithOptions
"click"
{ stopPropagation = True, preventDefault = True }
(Decode.succeed (ForSelf <| ShareOnFacebook facebookUrl))
]
[ i [ attribute "aria-hidden" "true", class "fa fa-facebook" ] [] ]
, a
[ class "btn btn-default btn-action btn-round"
, href googlePlusUrl
, onWithOptions
"click"
{ stopPropagation = True, preventDefault = True }
(Decode.succeed (ForSelf <| ShareOnGooglePlus googlePlusUrl))
]
[ i [ attribute "aria-hidden" "true", class "fa fa-google-plus" ] [] ]
, a
[ class "btn btn-default btn-action btn-round"
, href linkedInUrl
, onWithOptions
"click"
{ stopPropagation = True, preventDefault = True }
(Decode.succeed (ForSelf <| ShareOnLinkedIn linkedInUrl))
]
[ i [ attribute "aria-hidden" "true", class "fa fa-linkedin" ] [] ]
, a
[ class "btn btn-default btn-action btn-round"
, href twitterUrl
, onWithOptions
"click"
{ stopPropagation = True, preventDefault = True }
(Decode.succeed (ForSelf <| Tweet twitterUrl))
-- , onClick (ForSelf <| Tweet twitterUrl)
(Decode.succeed (ForSelf <| ShareOnTwitter twitterUrl))
]
[ i [ attribute "aria-hidden" "true", class "fa fa-twitter" ] [] ]
-- , button [ class "btn btn-default btn-action btn-round", type' "button" ]
-- [ i [ attribute "aria-hidden" "true", class "fa fa-google-plus" ]
-- []
-- ]
-- , button [ class "btn btn-default btn-action btn-round", type' "button" ]
-- [ i [ attribute "aria-hidden" "true", class "fa fa-linkedin" ]
-- []
-- ]
]
)
]
......
......@@ -97,7 +97,16 @@ port fileContentRead : (ImagePortData -> msg) -> Sub msg
-- TWITTER
-- SHARERS
port tweet : String -> Cmd msg
port shareOnFacebook : String -> Cmd msg
port shareOnGooglePlus : String -> Cmd msg
port shareOnLinkedIn : String -> Cmd msg
port shareOnTwitter : String -> Cmd msg
......@@ -162,16 +162,51 @@ main.ports.setDocumentMetatags.subscribe(function (metatags) {
});
main.ports.storeAuthentication.subscribe(function (authentication) {
if (authentication) {
window.localStorage.setItem('authentication', JSON.stringify(authentication, null, 2));
} else {
window.localStorage.removeItem('authentication');
main.ports.shareOnFacebook.subscribe(function (url) {
var height = 350,
width = 520,
winHeight = screen.height,
winWidth = screen.width;
var left = Math.round((winWidth / 2) - (width / 2)),
top = 0;
if (winHeight > height) {
top = Math.round((winHeight / 2) - (height / 2));
}
window.open(url, 'facebook', 'status=no,toolbar=no,resizable=yes,scrollbars=yes,width=' + width +
',height=' + height + ',left=' + left + ',top=' + top);
});
main.ports.shareOnGooglePlus.subscribe(function (url) {
var height = 600,
width = 600,
winHeight = screen.height,
winWidth = screen.width;
var left = Math.round((winWidth / 2) - (width / 2)),
top = 0;
if (winHeight > height) {
top = Math.round((winHeight / 2) - (height / 2));
}
window.open(url, 'google+', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=' + width +
',height=' + height + ',left=' + left + ',top=' + top);
});
main.ports.tweet.subscribe(function (url) {
main.ports.shareOnLinkedIn.subscribe(function (url) {
var height = 570,
width = 520,
winHeight = screen.height,
winWidth = screen.width;
var left = Math.round((winWidth / 2) - (width / 2)),
top = 0;
if (winHeight > height) {
top = Math.round((winHeight / 2) - (height / 2));
}
window.open(url, 'linkedin', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=' + width +
',height=' + height + ',left=' + left + ',top=' + top);
});
main.ports.shareOnTwitter.subscribe(function (url) {
var height = 420,
width = 550,
winHeight = screen.height,
......@@ -181,6 +216,15 @@ main.ports.tweet.subscribe(function (url) {
if (winHeight > height) {
top = Math.round((winHeight / 2) - (height / 2));
}
window.open(url, 'intent', 'scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=' + width +
window.open(url, 'twitter', 'scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=' + width +
',height=' + height + ',left=' + left + ',top=' + top);
});
main.ports.storeAuthentication.subscribe(function (authentication) {
if (authentication) {
window.localStorage.setItem('authentication', JSON.stringify(authentication, null, 2));
} else {
window.localStorage.removeItem('authentication');
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment