Plugin Directory

Changeset 1356075


Ignore:
Timestamp:
02/22/2016 09:34:40 PM (10 years ago)
Author:
Space_Studio
Message:

0.8.3

Location:
click-tweet/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • click-tweet/trunk/assets/css/click-and-tweet-editor.css

    r1325871 r1356075  
    168168}
    169169
     170.click-and-tweet-tooltip .panel .remove{
     171    font-size: 0.8em;
     172    text-align: left;
     173    color: #FFF;
     174    text-decoration: none;
     175    position: absolute;
     176    bottom: 10px;
     177    left: 10px;
     178    cursor: pointer;
     179}
     180
     181.click-and-tweet-tooltip .panel .remove:hover{
     182    color: red;
     183}
     184
    170185.click-and-tweet-tooltip .panel .more-link{
    171186    font-size: 1.6em;
     
    176191    bottom: 0px;
    177192    right: 10px;
     193    cursor: pointer;
    178194}
    179195
     
    186202    bottom: 0px;
    187203    left: 10px;
     204    cursor: pointer;
    188205}
    189206
  • click-tweet/trunk/assets/js/click-and-tweet-tinymce-plugin.js

    r1352221 r1356075  
    11(function($) {
    22    tinymce.PluginManager.add('click_and_tweet', function(ed, url) {
    3         var activeShortcode, editorEditable = true, shortcodeAdded = false, activeSpan;
     3        var activeShortcode, editorEditable = true, shortcodeAdded = false, activeSpan,
     4            activeSelection;
    45
    56        var defaults = {
     
    3536            image: click_and_tweet.pluginUrl + '/assets/img/twitter-logo.png',
    3637            onclick: function() {
    37                 //Toggle click to tweet shorcode when selected
    38                 var body = ed.getBody();
    39                 var text = ed.selection.getContent();
    40                 var newText = '';
    41                 if (text.match(/click-and-tweet-shortcode/g)) {
    42                     newText = $(text).contents().filter(function() {
    43                         return this.nodeType == Node.TEXT_NODE;
    44                     }).text();
    45                 }else{
    46                     if((newText = newText.match(/\[clickandtweet.*?\](.*?)\[\/clickandtweet\]/))){
    47                         newText = newText[1];
    48                     }else {
    49                         newText = wp.shortcode.string({
    50                             tag : 'clickandtweet',
    51                             single : 'false',
    52                             content : text
    53                         });
    54                         shortcodeAdded = true;
    55                     }
    56                 }
    57 
    58                 if (!text.length) return;
    59 
    60                 //Replace the selected text, replace all conent and set caret.
    61                 ed.selection.setContent(newText);
    62                 var bookmark = ed.selection.getBookmark();
    63                 ed.setContent($(body).html());
    64                 ed.selection.moveToBookmark(bookmark);
     38                toggleClickTweet();
    6539            }
    6640        });
     
    7044         */
    7145        ed.on('click', function(e) {
     46            removeTweet(e);
    7247            toggleTooltip(e);
    7348            togglePanel(e);
     
    155130        ////////////
    156131
     132        //Toggle click to tweet shorcode when selected
     133        function toggleClickTweet(){
     134            var body = ed.getBody();
     135            var text = ed.selection.getContent();
     136
     137            var newText = '';
     138            if (text.match(/click-and-tweet-shortcode/g)) {
     139                newText = $(text).contents().filter(function() {
     140                    return this.nodeType == Node.TEXT_NODE;
     141                }).text();
     142            }else{
     143                if((newText = newText.match(/\[clickandtweet.*?\](.*?)\[\/clickandtweet\]/))){
     144                    newText = newText[1];
     145                }else {
     146                    newText = wp.shortcode.string({
     147                        tag : 'clickandtweet',
     148                        single : 'false',
     149                        content : text
     150                    });
     151                    shortcodeAdded = true;
     152                }
     153            }
     154
     155            if (!text.length) return;
     156
     157            //Replace the selected text, replace all content and set caret.
     158            ed.selection.setContent(newText);
     159            var bookmark = ed.selection.getBookmark();
     160            ed.setContent($(body).html());
     161            ed.selection.moveToBookmark(bookmark);
     162        }
    157163        /**
    158164         * The template for the tooltip
     
    176182                                    '<input type="text" name="related" class="click-and-tweet-related mceEditable" contenteditable="true" placeholder="@relatedUsername">' +
    177183                                '</div>' +
     184                                '<a class="remove" title="remove">Remove</a>' +
    178185                                '<a class="toggle-panel more-link" data-panel="more" title="More">&middot;&middot;&middot;</a>' +
    179186                            '</div>' +
     
    224231         * Close the tooltip
    225232         */
    226         function closeToolTip(e)
    227         {
    228             if ($(e.target)[0].className == 'close') {
     233        function closeToolTip(e, force)
     234        {
     235            if ($(e.target)[0].className == 'close' || force) {
    229236                $(e.target).closest('.click-and-tweet-tooltip').remove();
    230237                activeShortcode = '';
     
    443450            }
    444451        }
     452
     453        /**
     454         * Remove a tweet from the editor
     455         */
     456        function removeTweet(e)
     457        {
     458            if ($(e.target)[0].className == 'remove' && activeShortcode) {
     459                var body = ed.getBody();
     460                var shortcode = $(body).find(activeShortcode);
     461                var newText = '';
     462                newText = $(shortcode).contents().filter(function() {
     463                    return this.nodeType == Node.TEXT_NODE;
     464                }).text();
     465
     466                shortcode.replaceWith(newText);
     467
     468                closeToolTip(e, true);
     469
     470            }
     471        }
    445472    });
    446473
  • click-tweet/trunk/readme.txt

    r1352878 r1356075  
    4747
    4848== Changelog ==
     49= 0.8.3 =
     50* Added a way to remove tweets from the popover.
     51
    4952= 0.8.2 =
    5053* Fixed a bug with toggling
Note: See TracChangeset for help on using the changeset viewer.