Changeset 1356075
- Timestamp:
- 02/22/2016 09:34:40 PM (10 years ago)
- Location:
- click-tweet/trunk
- Files:
-
- 3 edited
-
assets/css/click-and-tweet-editor.css (modified) (3 diffs)
-
assets/js/click-and-tweet-tinymce-plugin.js (modified) (7 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
click-tweet/trunk/assets/css/click-and-tweet-editor.css
r1325871 r1356075 168 168 } 169 169 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 170 185 .click-and-tweet-tooltip .panel .more-link{ 171 186 font-size: 1.6em; … … 176 191 bottom: 0px; 177 192 right: 10px; 193 cursor: pointer; 178 194 } 179 195 … … 186 202 bottom: 0px; 187 203 left: 10px; 204 cursor: pointer; 188 205 } 189 206 -
click-tweet/trunk/assets/js/click-and-tweet-tinymce-plugin.js
r1352221 r1356075 1 1 (function($) { 2 2 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; 4 5 5 6 var defaults = { … … 35 36 image: click_and_tweet.pluginUrl + '/assets/img/twitter-logo.png', 36 37 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(); 65 39 } 66 40 }); … … 70 44 */ 71 45 ed.on('click', function(e) { 46 removeTweet(e); 72 47 toggleTooltip(e); 73 48 togglePanel(e); … … 155 130 //////////// 156 131 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 } 157 163 /** 158 164 * The template for the tooltip … … 176 182 '<input type="text" name="related" class="click-and-tweet-related mceEditable" contenteditable="true" placeholder="@relatedUsername">' + 177 183 '</div>' + 184 '<a class="remove" title="remove">Remove</a>' + 178 185 '<a class="toggle-panel more-link" data-panel="more" title="More">···</a>' + 179 186 '</div>' + … … 224 231 * Close the tooltip 225 232 */ 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) { 229 236 $(e.target).closest('.click-and-tweet-tooltip').remove(); 230 237 activeShortcode = ''; … … 443 450 } 444 451 } 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 } 445 472 }); 446 473 -
click-tweet/trunk/readme.txt
r1352878 r1356075 47 47 48 48 == Changelog == 49 = 0.8.3 = 50 * Added a way to remove tweets from the popover. 51 49 52 = 0.8.2 = 50 53 * Fixed a bug with toggling
Note: See TracChangeset
for help on using the changeset viewer.