Ticket #6569: 6569.js-only.patch
File 6569.js-only.patch, 15.5 KB (added by , 9 years ago) |
---|
-
src/bp-templates/bp-legacy/buddypress-functions.php
diff --git src/bp-templates/bp-legacy/buddypress-functions.php src/bp-templates/bp-legacy/buddypress-functions.php index 28d2c22..0dbf04d 100644
class BP_Legacy extends BP_Theme_Compat { 278 278 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 279 279 280 280 // Locate the BP JS file. 281 $ asset= $this->locate_asset_in_stack( "buddypress{$min}.js", 'js' );281 $js = $this->locate_asset_in_stack( "buddypress{$min}.js", 'js' ); 282 282 283 283 // Enqueue the global JS, if found - AJAX will not work 284 284 // without it. 285 if ( isset( $ asset['location'], $asset['handle'] ) ) {286 wp_enqueue_script( $ asset['handle'], $asset['location'], bp_core_get_js_dependencies(), $this->version );285 if ( isset( $js['location'], $js['handle'] ) ) { 286 wp_enqueue_script( $js['handle'], $js['location'], bp_core_get_js_dependencies(), $this->version ); 287 287 } 288 288 289 289 /** … … class BP_Legacy extends BP_Theme_Compat { 308 308 'unsaved_changes' => __( 'Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress' ), 309 309 'view' => __( 'View', 'buddypress' ), 310 310 ) ); 311 wp_localize_script( $ asset['handle'], 'BP_DTheme', $params );311 wp_localize_script( $js['handle'], 'BP_DTheme', $params ); 312 312 313 313 // Maybe enqueue comment reply JS. 314 314 if ( is_singular() && bp_is_blog_page() && get_option( 'thread_comments' ) ) { 315 315 wp_enqueue_script( 'comment-reply' ); 316 316 } 317 317 318 /** 319 * Enqueues Autosize 3.0.13. 320 * 321 * @link https://github.com/jackmoore/autosize 322 * @license MIT 323 */ 324 if ( bp_is_active( 'activity' ) ) { 325 // @todo locate_asset_in_stack() should allow us to omit child theme checks... 326 $asset = $this->locate_asset_in_stack( "autosize{$min}.js", 'js', 'bp-legacy-autosize' ); 327 328 wp_enqueue_script( $asset['handle'], $asset['location'], array( $js['handle'] ), '3.0.13' ); 329 } 330 318 331 // Maybe enqueue password verify JS (register page or user settings page). 319 332 if ( bp_is_register_page() || ( function_exists( 'bp_is_user_settings_general' ) && bp_is_user_settings_general() ) ) { 320 333 … … class BP_Legacy extends BP_Theme_Compat { 331 344 332 345 // Star private messages. 333 346 if ( bp_is_active( 'messages', 'star' ) && bp_is_user_messages() ) { 334 wp_localize_script( $ asset['handle'], 'BP_PM_Star', array(347 wp_localize_script( $js['handle'], 'BP_PM_Star', array( 335 348 'strings' => array( 336 349 'text_unstar' => __( 'Unstar', 'buddypress' ), 337 350 'text_star' => __( 'Star', 'buddypress' ), -
src/bp-templates/bp-legacy/css/buddypress.css
diff --git src/bp-templates/bp-legacy/css/buddypress.css src/bp-templates/bp-legacy/css/buddypress.css index d0a4a01..d144b47 100644
Hello, this is the BuddyPress Legacy stylesheet. 129 129 font-family: inherit; 130 130 font-size: medium; 131 131 height: 20px; 132 overflow: hidden; 132 133 padding: 6px; 134 resize: none; 133 135 width: 98%; 134 136 } 135 137 body.no-js #buddypress form#whats-new-form textarea { 136 138 height: 50px; 139 overflow: auto; 137 140 } 138 141 #buddypress form#whats-new-form #whats-new-options select { 139 142 max-width: 200px; … … body.no-js #buddypress form#whats-new-form textarea { 143 146 float: right; 144 147 margin-top: 12px; 145 148 } 146 #buddypress #whats-new-options { 147 overflow: auto; 148 height: 0; 149 #buddypress #whats-new-options:after { 150 clear: both; 151 content: ''; 152 display: table; 149 153 } 150 154 body.no-js #buddypress #whats-new-options { 151 155 height: auto; … … body.no-js #buddypress #whats-new-options { 155 159 outline-color: rgba(31, 179, 221, 0.9); 156 160 } 157 161 162 /* Autosize.js hack for IE10-11 - avoids jumpiness */ 163 @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { 164 #buddypress form#whats-new-form textarea { 165 padding-bottom: 22px; 166 } 167 } 168 158 169 /*-------------------------------------------------------------- 159 170 3.1.1 - Activity Listing 160 171 --------------------------------------------------------------*/ -
new file src/bp-templates/bp-legacy/js/autosize.js
diff --git src/bp-templates/bp-legacy/js/autosize.js src/bp-templates/bp-legacy/js/autosize.js new file mode 100644 index 0000000..70dd07c
- + 1 /*! 2 Autosize 3.0.13 3 license: MIT 4 http://www.jacklmoore.com/autosize 5 */ 6 (function (global, factory) { 7 if (typeof define === 'function' && define.amd) { 8 define(['exports', 'module'], factory); 9 } else if (typeof exports !== 'undefined' && typeof module !== 'undefined') { 10 factory(exports, module); 11 } else { 12 var mod = { 13 exports: {} 14 }; 15 factory(mod.exports, mod); 16 global.autosize = mod.exports; 17 } 18 })(this, function (exports, module) { 19 'use strict'; 20 21 var set = typeof Set === 'function' ? new Set() : (function () { 22 var list = []; 23 24 return { 25 has: function has(key) { 26 return Boolean(list.indexOf(key) > -1); 27 }, 28 add: function add(key) { 29 list.push(key); 30 }, 31 'delete': function _delete(key) { 32 list.splice(list.indexOf(key), 1); 33 } }; 34 })(); 35 36 function assign(ta) { 37 var _ref = arguments[1] === undefined ? {} : arguments[1]; 38 39 var _ref$setOverflowX = _ref.setOverflowX; 40 var setOverflowX = _ref$setOverflowX === undefined ? true : _ref$setOverflowX; 41 var _ref$setOverflowY = _ref.setOverflowY; 42 var setOverflowY = _ref$setOverflowY === undefined ? true : _ref$setOverflowY; 43 44 if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || set.has(ta)) return; 45 46 var heightOffset = null; 47 var overflowY = null; 48 var clientWidth = ta.clientWidth; 49 50 function init() { 51 var style = window.getComputedStyle(ta, null); 52 53 overflowY = style.overflowY; 54 55 if (style.resize === 'vertical') { 56 ta.style.resize = 'none'; 57 } else if (style.resize === 'both') { 58 ta.style.resize = 'horizontal'; 59 } 60 61 if (style.boxSizing === 'content-box') { 62 heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)); 63 } else { 64 heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth); 65 } 66 // Fix when a textarea is not on document body and heightOffset is Not a Number 67 if (isNaN(heightOffset)) { 68 heightOffset = 0; 69 } 70 71 update(); 72 } 73 74 function changeOverflow(value) { 75 { 76 // Chrome/Safari-specific fix: 77 // When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space 78 // made available by removing the scrollbar. The following forces the necessary text reflow. 79 var width = ta.style.width; 80 ta.style.width = '0px'; 81 // Force reflow: 82 /* jshint ignore:start */ 83 ta.offsetWidth; 84 /* jshint ignore:end */ 85 ta.style.width = width; 86 } 87 88 overflowY = value; 89 90 if (setOverflowY) { 91 ta.style.overflowY = value; 92 } 93 94 resize(); 95 } 96 97 function resize() { 98 var htmlTop = window.pageYOffset; 99 var bodyTop = document.body.scrollTop; 100 var originalHeight = ta.style.height; 101 102 ta.style.height = 'auto'; 103 104 var endHeight = ta.scrollHeight + heightOffset; 105 106 if (ta.scrollHeight === 0) { 107 // If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM. 108 ta.style.height = originalHeight; 109 return; 110 } 111 112 ta.style.height = endHeight + 'px'; 113 114 // used to check if an update is actually necessary on window.resize 115 clientWidth = ta.clientWidth; 116 117 // prevents scroll-position jumping 118 document.documentElement.scrollTop = htmlTop; 119 document.body.scrollTop = bodyTop; 120 } 121 122 function update() { 123 var startHeight = ta.style.height; 124 125 resize(); 126 127 var style = window.getComputedStyle(ta, null); 128 129 if (style.height !== ta.style.height) { 130 if (overflowY !== 'visible') { 131 changeOverflow('visible'); 132 } 133 } else { 134 if (overflowY !== 'hidden') { 135 changeOverflow('hidden'); 136 } 137 } 138 139 if (startHeight !== ta.style.height) { 140 var evt = document.createEvent('Event'); 141 evt.initEvent('autosize:resized', true, false); 142 ta.dispatchEvent(evt); 143 } 144 } 145 146 var pageResize = function pageResize() { 147 if (ta.clientWidth !== clientWidth) { 148 update(); 149 } 150 }; 151 152 var destroy = (function (style) { 153 window.removeEventListener('resize', pageResize); 154 ta.removeEventListener('input', update); 155 ta.removeEventListener('keyup', update); 156 ta.removeEventListener('autosize:destroy', destroy); 157 set['delete'](ta); 158 159 Object.keys(style).forEach(function (key) { 160 ta.style[key] = style[key]; 161 }); 162 }).bind(ta, { 163 height: ta.style.height, 164 resize: ta.style.resize, 165 overflowY: ta.style.overflowY, 166 overflowX: ta.style.overflowX, 167 wordWrap: ta.style.wordWrap }); 168 169 ta.addEventListener('autosize:destroy', destroy); 170 171 // IE9 does not fire onpropertychange or oninput for deletions, 172 // so binding to onkeyup to catch most of those events. 173 // There is no way that I know of to detect something like 'cut' in IE9. 174 if ('onpropertychange' in ta && 'oninput' in ta) { 175 ta.addEventListener('keyup', update); 176 } 177 178 window.addEventListener('resize', pageResize); 179 ta.addEventListener('input', update); 180 ta.addEventListener('autosize:update', update); 181 set.add(ta); 182 183 if (setOverflowX) { 184 ta.style.overflowX = 'hidden'; 185 ta.style.wordWrap = 'break-word'; 186 } 187 188 init(); 189 } 190 191 function destroy(ta) { 192 if (!(ta && ta.nodeName && ta.nodeName === 'TEXTAREA')) return; 193 var evt = document.createEvent('Event'); 194 evt.initEvent('autosize:destroy', true, false); 195 ta.dispatchEvent(evt); 196 } 197 198 function update(ta) { 199 if (!(ta && ta.nodeName && ta.nodeName === 'TEXTAREA')) return; 200 var evt = document.createEvent('Event'); 201 evt.initEvent('autosize:update', true, false); 202 ta.dispatchEvent(evt); 203 } 204 205 var autosize = null; 206 207 // Do nothing in Node.js environment and IE8 (or lower) 208 if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') { 209 autosize = function (el) { 210 return el; 211 }; 212 autosize.destroy = function (el) { 213 return el; 214 }; 215 autosize.update = function (el) { 216 return el; 217 }; 218 } else { 219 autosize = function (el, options) { 220 if (el) { 221 Array.prototype.forEach.call(el.length ? el : [el], function (x) { 222 return assign(x, options); 223 }); 224 } 225 return el; 226 }; 227 autosize.destroy = function (el) { 228 if (el) { 229 Array.prototype.forEach.call(el.length ? el : [el], destroy); 230 } 231 return el; 232 }; 233 autosize.update = function (el) { 234 if (el) { 235 Array.prototype.forEach.call(el.length ? el : [el], update); 236 } 237 return el; 238 }; 239 } 240 241 module.exports = autosize; 242 }); 243 No newline at end of file -
src/bp-templates/bp-legacy/js/buddypress.js
diff --git src/bp-templates/bp-legacy/js/buddypress.js src/bp-templates/bp-legacy/js/buddypress.js index d0eb3d2..3a8ea5f 100644
jq(document).ready( function() { 28 28 /* Object filter and scope set. */ 29 29 bp_init_objects( objects ); 30 30 31 /* Textarea auto-resize */ 32 $whats_new.attr('rows', '1'); 33 autosize( $whats_new ); 34 31 35 /* @mention Compose Scrolling */ 32 36 if ( $whats_new.length && bp_get_querystring('r') ) { 33 37 var $member_nicename = $whats_new.val(); 34 38 35 jq('#whats-new-options').animate({ 36 height:'50px' 37 }); 38 39 $whats_new.animate({ 40 height:'50px' 41 }); 39 jq('#whats-new-options').slideDown(); 42 40 43 41 jq.scrollTo( $whats_new, 500, { 44 42 offset:-125, … … jq(document).ready( function() { 46 44 } ); 47 45 48 46 $whats_new.val('').focus().val( $member_nicename ); 47 } else { 48 jq('#whats-new-options').hide(); 49 49 } 50 50 51 51 /**** Activity Posting ********************************************************/ 52 52 53 53 /* Textarea focus */ 54 54 $whats_new.focus( function(){ 55 jq('#whats-new-options').animate({ 56 height:'50px' 57 }); 58 jq('#whats-new-form textarea').animate({ 59 height:'50px' 60 }); 55 jq( '#whats-new-options' ).slideDown(); 56 61 57 jq('#aw-whats-new-submit').prop('disabled', false); 62 58 59 jq( this ).parent().addClass( 'active' ); 63 60 jq( '#whats-new-content' ).addClass( 'active' ); 64 61 65 62 var $whats_new_form = jq('form#whats-new-form'), … … jq(document).ready( function() { 83 80 } 84 81 }); 85 82 86 /* On blur, shrink if it's empty*/87 $whats_new.blur( function(){88 if ( document.activeElement !== this ) {89 if (!this.value.match(/\S+/)) { 90 this.value = '';91 jq('#whats-new-options').animate({92 height:'0'93 });94 jq( 'form#whats-new-form textarea').animate({95 height:'20px' 96 });97 jq('#aw-whats-new-submit').prop('disabled', true); 83 /* For the "What's New" form, do the following on focusout. */ 84 jq( '#whats-new-form' ).on( 'focusout', function( e ) { 85 var elem = jq( this ); 86 87 // Let child hover actions passthrough. 88 // This allows click events to go through without focusout. 89 setTimeout( function () { 90 if ( ! elem.find(':hover').length ) { 91 jq( '#whats-new-options' ).slideUp(); 92 93 jq('#aw-whats-new-submit').prop( 'disabled', true ); 94 98 95 jq( '#whats-new-content' ).removeClass( 'active' ); 96 $whats_new.parent().removeClass( 'active' ); 99 97 } 100 } 101 } );98 }, 0 ); 99 } ); 102 100 103 101 /* New posts */ 104 102 jq('#aw-whats-new-submit').on( 'click', function() { 105 103 var last_date_recorded = 0, 106 104 button = jq(this), 107 form = button.closest('form#whats-new-form'); 105 form = button.closest('form#whats-new-form'), 106 inputs = {}, post_data; 107 108 // Get all inputs and organize them into an object {name: value} 109 jq.each( form.serializeArray(), function( key, input ) { 110 // Only include public extra data 111 if ( '_' !== input.name.substr( 0, 1 ) && 'whats-new' !== input.name.substr( 0, 9 ) ) { 112 if ( ! inputs[ input.name ] ) { 113 inputs[ input.name ] = input.value; 114 } else { 115 // Checkboxes/dropdown list can have multiple selected value 116 if ( ! jq.isArray( inputs[ input.name ] ) ) { 117 inputs[ input.name ] = new Array( inputs[ input.name ], input.value ); 118 } else { 119 inputs[ input.name ].push( input.value ); 120 } 121 } 122 } 123 } ); 108 124 109 form. children().each( function() {110 if ( jq.nodeName( this, 'textarea') || jq.nodeName(this, 'input') ) {125 form.find( '*' ).each( function() { 126 if ( jq.nodeName( this, 'textarea' ) || jq.nodeName( this, 'input' ) ) { 111 127 jq(this).prop( 'disabled', true ); 112 128 } 113 } );129 } ); 114 130 115 131 /* Remove any errors */ 116 132 jq('div.error').remove(); … … jq(document).ready( function() { 145 161 object = jq('#whats-new-post-object').val(); 146 162 } 147 163 148 jq.post( ajaxurl,{164 post_data = jq.extend( { 149 165 action: 'post_update', 150 166 'cookie': bp_get_cookies(), 151 167 '_wpnonce_post_update': jq('#_wpnonce_post_update').val(), … … jq(document).ready( function() { 154 170 'item_id': item_id, 155 171 'since': last_date_recorded, 156 172 '_bp_as_nonce': jq('#_bp_as_nonce').val() || '' 157 }, 158 function(response) { 173 }, inputs ); 159 174 160 form.children().each( function() { 161 if ( jq.nodeName(this, 'textarea') || jq.nodeName(this, 'input') ) { 175 jq.post( ajaxurl, post_data, function( response ) { 176 form.find( '*' ).each( function() { 177 if ( jq.nodeName( this, 'textarea' ) || jq.nodeName( this, 'input' ) ) { 162 178 jq(this).prop( 'disabled', false ); 163 179 } 164 180 }); … … jq(document).ready( function() { 205 221 jq('li.new-update').hide().slideDown( 300 ); 206 222 jq('li.new-update').removeClass( 'new-update' ); 207 223 jq('#whats-new').val(''); 224 form.get(0).reset(); 208 225 209 226 // reset vars to get newest activities 210 227 newest_activities = ''; 211 228 activity_last_recorded = 0; 212 229 } 213 230 214 jq('#whats-new-options').animate({ 215 height:'0px' 216 }); 231 jq('#whats-new-options').slideUp(); 217 232 jq('#whats-new-form textarea').animate({ 218 233 height:'20px' 219 234 });