[TASK] Load autosize via bower 41/38341/2
authorWouter Wolters <typo3@wouterwolters.nl>
Sun, 29 Mar 2015 20:16:39 +0000 (22:16 +0200)
committerBenjamin Mack <benni@typo3.org>
Mon, 30 Mar 2015 10:26:53 +0000 (12:26 +0200)
The autosize library previously located in "typo3/contrib/jquery" is now
fetched via bower and copied to the public JavaScript folder via Grunt.

Resolves: #66123
Releases: master
Change-Id: I15639deb92f595c64251569b20a307448203afda
Reviewed-on: http://review.typo3.org/38341
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Daniel Sattler <sattler@b13.de>
Tested-by: Daniel Sattler <sattler@b13.de>
Reviewed-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
Build/Gruntfile.js
Build/bower.json
typo3/contrib/jquery/jquery.autosize.js [deleted file]
typo3/contrib/jquery/jquery.autosize.min.js [deleted file]
typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js
typo3/sysext/core/Classes/Page/PageRenderer.php
typo3/sysext/core/Resources/Public/JavaScript/Contrib/autosize.js [new file with mode: 0644]

index db8b5b4..9e8829c 100644 (file)
@@ -50,6 +50,7 @@ module.exports = function(grunt) {
                                        '<%= paths.core %>Public/JavaScript/Contrib/require.js': '/requirejs/require.js',
                                        '<%= paths.core %>Public/JavaScript/Contrib/moment.js': '/moment/moment.js',
                                        '<%= paths.core %>Public/JavaScript/Contrib/bootstrap-datetimepicker.js': '/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
+                                       '<%= paths.core %>Public/JavaScript/Contrib/autosize.js': '/autosize/dest/autosize.min.js',
                                        /**
                                         * copy needed files of scriptaculous
                                         */
index eb1185d..3afa2e5 100644 (file)
@@ -33,6 +33,7 @@
     "eonasdan-bootstrap-datetimepicker": "3.1.3",
     "moment": "2.8.3",
     "nprogress": "0.1.6",
-    "datatables": "1.10.5"
+    "datatables": "1.10.5",
+    "autosize": "2.0.0"
   }
 }
diff --git a/typo3/contrib/jquery/jquery.autosize.js b/typo3/contrib/jquery/jquery.autosize.js
deleted file mode 100644 (file)
index 4fa5790..0000000
+++ /dev/null
@@ -1,285 +0,0 @@
-/*!
-       Autosize 1.18.17 as UMD module
-       license: MIT
-       http://www.jacklmoore.com/autosize
-       derived: https://github.com/bmack/autosize
-*/
-(function (factory) {
-       if (typeof define === 'function' && define.amd) {
-               // AMD
-               define(['jquery'], factory);
-       } else if (typeof exports === 'object') {
-               // CommonJS
-               factory(require('jquery'));
-       } else {
-               // Browser globals
-               factory(jQuery);
-       }
-}(function ($) {
-       var
-       defaults = {
-               className: 'autosizejs',
-               id: 'autosizejs',
-               append: '\n',
-               callback: false,
-               resizeDelay: 10,
-               placeholder: true
-       },
-
-       // border:0 is unnecessary, but avoids a bug in Firefox on OSX
-       copy = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',
-
-       // line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
-       typographyStyles = [
-               'fontFamily',
-               'fontSize',
-               'fontWeight',
-               'fontStyle',
-               'letterSpacing',
-               'textTransform',
-               'wordSpacing',
-               'textIndent',
-               'whiteSpace'
-       ],
-
-       // to keep track which textarea is being mirrored when adjust() is called.
-       mirrored,
-
-       // the mirror element, which is used to calculate what size the mirrored element should be.
-       mirror = $(copy).data('autosize', true)[0];
-
-       // test that line-height can be accurately copied.
-       mirror.style.lineHeight = '99px';
-       if ($(mirror).css('lineHeight') === '99px') {
-               typographyStyles.push('lineHeight');
-       }
-       mirror.style.lineHeight = '';
-
-       $.fn.autosize = function (options) {
-               if (!this.length) {
-                       return this;
-               }
-
-               options = $.extend({}, defaults, options || {});
-
-               if (mirror.parentNode !== document.body) {
-                       $(document.body).append(mirror);
-               }
-
-               return this.each(function () {
-                       var
-                       ta = this,
-                       $ta = $(ta),
-                       maxHeight,
-                       minHeight,
-                       boxOffset = 0,
-                       callback = $.isFunction(options.callback),
-                       originalStyles = {
-                               height: ta.style.height,
-                               overflow: ta.style.overflow,
-                               overflowY: ta.style.overflowY,
-                               wordWrap: ta.style.wordWrap,
-                               resize: ta.style.resize
-                       },
-                       timeout,
-                       width = $ta.width(),
-                       taResize = $ta.css('resize');
-
-                       if ($ta.data('autosize')) {
-                               // exit if autosize has already been applied, or if the textarea is the mirror element.
-                               return;
-                       }
-                       $ta.data('autosize', true);
-
-                       if ($ta.css('box-sizing') === 'border-box' || $ta.css('-moz-box-sizing') === 'border-box' || $ta.css('-webkit-box-sizing') === 'border-box'){
-                               boxOffset = $ta.outerHeight() - $ta.height();
-                       }
-
-                       // IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
-                       minHeight = Math.max(parseFloat($ta.css('minHeight')) - boxOffset || 0, $ta.height());
-
-                       $ta.css({
-                               overflow: 'hidden',
-                               overflowY: 'hidden',
-                               wordWrap: 'break-word' // horizontal overflow is hidden, so break-word is necessary for handling words longer than the textarea width
-                       });
-
-                       if (taResize === 'vertical') {
-                               $ta.css('resize','none');
-                       } else if (taResize === 'both') {
-                               $ta.css('resize', 'horizontal');
-                       }
-
-                       // getComputedStyle is preferred here because it preserves sub-pixel values, while jQuery's .width() rounds to an integer.
-                       function setWidth() {
-                               var width;
-                               var style = window.getComputedStyle ? window.getComputedStyle(ta, null) : null;
-
-                               if (style) {
-                                       width = parseFloat(style.width);
-                                       if (style.boxSizing === 'border-box' || style.webkitBoxSizing === 'border-box' || style.mozBoxSizing === 'border-box') {
-                                               $.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){
-                                                       width -= parseFloat(style[val]);
-                                               });
-                                       }
-                               } else {
-                                       width = $ta.width();
-                               }
-
-                               mirror.style.width = Math.max(width,0) + 'px';
-                       }
-
-                       function initMirror() {
-                               var styles = {};
-
-                               mirrored = ta;
-                               mirror.className = options.className;
-                               mirror.id = options.id;
-                               maxHeight = parseFloat($ta.css('maxHeight'));
-
-                               // mirror is a duplicate textarea located off-screen that
-                               // is automatically updated to contain the same text as the
-                               // original textarea.  mirror always has a height of 0.
-                               // This gives a cross-browser supported way getting the actual
-                               // height of the text, through the scrollTop property.
-                               $.each(typographyStyles, function(i,val){
-                                       styles[val] = $ta.css(val);
-                               });
-
-                               $(mirror).css(styles).attr('wrap', $ta.attr('wrap'));
-
-                               setWidth();
-
-                               // Chrome-specific fix:
-                               // When the textarea y-overflow is hidden, Chrome doesn't reflow the text to account for the space
-                               // made available by removing the scrollbar. This workaround triggers the reflow for Chrome.
-                               if (window.chrome) {
-                                       var width = ta.style.width;
-                                       ta.style.width = '0px';
-                                       var ignore = ta.offsetWidth;
-                                       ta.style.width = width;
-                               }
-                       }
-
-                       // Using mainly bare JS in this function because it is going
-                       // to fire very often while typing, and needs to very efficient.
-                       function adjust() {
-                               var height, originalHeight;
-
-                               if (mirrored !== ta) {
-                                       initMirror();
-                               } else {
-                                       setWidth();
-                               }
-
-                               if (!ta.value && options.placeholder) {
-                                       // If the textarea is empty, copy the placeholder text into
-                                       // the mirror control and use that for sizing so that we
-                                       // don't end up with placeholder getting trimmed.
-                                       mirror.value = ($ta.attr("placeholder") || '');
-                               } else {
-                                       mirror.value = ta.value;
-                               }
-
-                               mirror.value += options.append || '';
-                               mirror.style.overflowY = ta.style.overflowY;
-                               originalHeight = parseFloat(ta.style.height) || 0;
-
-                               // Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied
-                               mirror.scrollTop = 0;
-
-                               mirror.scrollTop = 9e4;
-
-                               // Using scrollTop rather than scrollHeight because scrollHeight is non-standard and includes padding.
-                               height = mirror.scrollTop;
-
-                               if (maxHeight && height > maxHeight) {
-                                       ta.style.overflowY = 'scroll';
-                                       height = maxHeight;
-                               } else {
-                                       ta.style.overflowY = 'hidden';
-                                       if (height < minHeight) {
-                                               height = minHeight;
-                                       }
-                               }
-
-                               height += boxOffset;
-
-                               if (Math.abs(originalHeight - height) > 1/100) {
-                                       ta.style.height = height + 'px';
-
-                                       // Trigger a repaint for IE8 for when ta is nested 2 or more levels inside an inline-block
-                                       mirror.className = mirror.className;
-
-                                       if (callback) {
-                                               options.callback.call(ta,ta);
-                                       }
-                                       $ta.trigger('autosize.resized');
-                               }
-                       }
-
-                       function resize () {
-                               clearTimeout(timeout);
-                               timeout = setTimeout(function(){
-                                       var newWidth = $ta.width();
-
-                                       if (newWidth !== width) {
-                                               width = newWidth;
-                                               adjust();
-                                       }
-                               }, parseInt(options.resizeDelay,10));
-                       }
-
-                       if ('onpropertychange' in ta) {
-                               if ('oninput' in ta) {
-                                       // Detects IE9.  IE9 does not fire onpropertychange or oninput for deletions,
-                                       // so binding to onkeyup to catch most of those occasions.  There is no way that I
-                                       // know of to detect something like 'cut' in IE9.
-                                       $ta.on('input.autosize keyup.autosize', adjust);
-                               } else {
-                                       // IE7 / IE8
-                                       $ta.on('propertychange.autosize', function(){
-                                               if(event.propertyName === 'value'){
-                                                       adjust();
-                                               }
-                                       });
-                               }
-                       } else {
-                               // Modern Browsers
-                               $ta.on('input.autosize', adjust);
-                       }
-
-                       // Set options.resizeDelay to false if using fixed-width textarea elements.
-                       // Uses a timeout and width check to reduce the amount of times adjust needs to be called after window resize.
-
-                       if (options.resizeDelay !== false) {
-                               $(window).on('resize.autosize', resize);
-                       }
-
-                       // Event for manual triggering if needed.
-                       // Should only be needed when the value of the textarea is changed through JavaScript rather than user input.
-                       $ta.on('autosize.resize', adjust);
-
-                       // Event for manual triggering that also forces the styles to update as well.
-                       // Should only be needed if one of typography styles of the textarea change, and the textarea is already the target of the adjust method.
-                       $ta.on('autosize.resizeIncludeStyle', function() {
-                               mirrored = null;
-                               adjust();
-                       });
-
-                       $ta.on('autosize.destroy', function(){
-                               mirrored = null;
-                               clearTimeout(timeout);
-                               $(window).off('resize', resize);
-                               $ta
-                                       .off('autosize')
-                                       .off('.autosize')
-                                       .css(originalStyles)
-                                       .removeData('autosize');
-                       });
-
-                       // Call adjust in case the textarea already contains text.
-                       adjust();
-               });
-       };
-}));
diff --git a/typo3/contrib/jquery/jquery.autosize.min.js b/typo3/contrib/jquery/jquery.autosize.min.js
deleted file mode 100644 (file)
index d4b805f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-/*!
-       Autosize 1.18.17 as UMD module
-       license: MIT
-       http://www.jacklmoore.com/autosize
-       derived: https://github.com/bmack/autosize
-*/
-(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a);}else{if(typeof exports==="object"){a(require("jquery"));}else{a(jQuery);}}}(function(b){var e={className:"autosizejs",id:"autosizejs",append:"\n",callback:false,resizeDelay:10,placeholder:true},f='<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',a=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","whiteSpace"],d,c=b(f).data("autosize",true)[0];c.style.lineHeight="99px";if(b(c).css("lineHeight")==="99px"){a.push("lineHeight");}c.style.lineHeight="";b.fn.autosize=function(g){if(!this.length){return this;}g=b.extend({},e,g||{});if(c.parentNode!==document.body){b(document.body).append(c);}return this.each(function(){var m=this,l=b(m),s,u,k=0,t=b.isFunction(g.callback),n={height:m.style.height,overflow:m.style.overflow,overflowY:m.style.overflowY,wordWrap:m.style.wordWrap,resize:m.style.resize},p,h=l.width(),j=l.css("resize");if(l.data("autosize")){return;}l.data("autosize",true);if(l.css("box-sizing")==="border-box"||l.css("-moz-box-sizing")==="border-box"||l.css("-webkit-box-sizing")==="border-box"){k=l.outerHeight()-l.height();}u=Math.max(parseFloat(l.css("minHeight"))-k||0,l.height());l.css({overflow:"hidden",overflowY:"hidden",wordWrap:"break-word"});if(j==="vertical"){l.css("resize","none");}else{if(j==="both"){l.css("resize","horizontal");}}function o(){var w;var v=window.getComputedStyle?window.getComputedStyle(m,null):null;if(v){w=parseFloat(v.width);if(v.boxSizing==="border-box"||v.webkitBoxSizing==="border-box"||v.mozBoxSizing==="border-box"){b.each(["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"],function(x,y){w-=parseFloat(v[y]);});}}else{w=l.width();}c.style.width=Math.max(w,0)+"px";}function r(){var w={};d=m;c.className=g.className;c.id=g.id;s=parseFloat(l.css("maxHeight"));b.each(a,function(y,z){w[z]=l.css(z);});b(c).css(w).attr("wrap",l.attr("wrap"));o();if(window.chrome){var v=m.style.width;m.style.width="0px";var x=m.offsetWidth;m.style.width=v;}}function q(){var v,w;if(d!==m){r();}else{o();}if(!m.value&&g.placeholder){c.value=(l.attr("placeholder")||"");}else{c.value=m.value;}c.value+=g.append||"";c.style.overflowY=m.style.overflowY;w=parseFloat(m.style.height)||0;c.scrollTop=0;c.scrollTop=90000;v=c.scrollTop;if(s&&v>s){m.style.overflowY="scroll";v=s;}else{m.style.overflowY="hidden";if(v<u){v=u;}}v+=k;if(Math.abs(w-v)>1/100){m.style.height=v+"px";c.className=c.className;if(t){g.callback.call(m,m);}l.trigger("autosize.resized");}}function i(){clearTimeout(p);p=setTimeout(function(){var v=l.width();if(v!==h){h=v;q();}},parseInt(g.resizeDelay,10));}if("onpropertychange" in m){if("oninput" in m){l.on("input.autosize keyup.autosize",q);}else{l.on("propertychange.autosize",function(){if(event.propertyName==="value"){q();}});}}else{l.on("input.autosize",q);}if(g.resizeDelay!==false){b(window).on("resize.autosize",i);}l.on("autosize.resize",q);l.on("autosize.resizeIncludeStyle",function(){d=null;q();});l.on("autosize.destroy",function(){d=null;clearTimeout(p);b(window).off("resize",i);l.off("autosize").off(".autosize").css(n).removeData("autosize");});q();});};}));
index 61dc6ec..4d4d09f 100644 (file)
@@ -694,8 +694,8 @@ define('TYPO3/CMS/Backend/FormEngine', ['jquery'], function ($) {
        FormEngine.convertTextareasResizable = function() {
                var $elements = $('.t3js-formengine-textarea');
                if (TYPO3.settings.Textarea && TYPO3.settings.Textarea.autosize && $elements.length) {
-                       require(['jquery/jquery.autosize.min'], function() {
-                               $elements.autosize();
+                       require(['autosize'], function(autosize) {
+                               autosize($elements);
                        });
                }
        };
index 61ec622..d47fdad 100644 (file)
@@ -1592,6 +1592,7 @@ class PageRenderer implements \TYPO3\CMS\Core\SingletonInterface {
                                'moment' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/moment',
                                'bootstrap' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap/bootstrap',
                                'twbs/bootstrap-datetimepicker' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap-datetimepicker',
+                               'autosize' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/autosize',
                        );
                        // get all extensions that are loaded
                        $loadedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
diff --git a/typo3/sysext/core/Resources/Public/JavaScript/Contrib/autosize.js b/typo3/sysext/core/Resources/Public/JavaScript/Contrib/autosize.js
new file mode 100644 (file)
index 0000000..c289310
--- /dev/null
@@ -0,0 +1,6 @@
+/*!
+       Autosize 2.0.0
+       license: MIT
+       http://www.jacklmoore.com/autosize
+*/
+!function(e,t){"use strict";"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.autosize=t()}(this,function(){function e(e){function t(){var t=window.getComputedStyle(e,null);"vertical"===t.resize?e.style.resize="none":"both"===t.resize&&(e.style.resize="horizontal"),e.style.wordWrap="break-word";var i=e.style.width;e.style.width="0px",e.offsetWidth,e.style.width=i,n="none"!==t.maxHeight?parseFloat(t.maxHeight):!1,r="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),o()}function o(){var t=e.style.height,o=document.documentElement.scrollTop,i=document.body.scrollTop;e.style.height="auto";var s=e.scrollHeight+r;if(n!==!1&&s>n?(s=n,"scroll"!==e.style.overflowY&&(e.style.overflowY="scroll")):"hidden"!==e.style.overflowY&&(e.style.overflowY="hidden"),e.style.height=s+"px",document.documentElement.scrollTop=o,document.body.scrollTop=i,t!==e.style.height){var d=document.createEvent("Event");d.initEvent("autosize.resized",!0,!1),e.dispatchEvent(d)}}if(e&&e.nodeName&&"TEXTAREA"===e.nodeName&&!e.hasAttribute("data-autosize-on")){var n,r;"onpropertychange"in e&&"oninput"in e&&e.addEventListener("keyup",o),window.addEventListener("resize",o),e.addEventListener("input",o),e.addEventListener("autosize.update",o),e.addEventListener("autosize.destroy",function(t){window.removeEventListener("resize",o),e.removeEventListener("input",o),e.removeEventListener("keyup",o),e.removeEventListener("autosize.destroy"),Object.keys(t).forEach(function(o){e.style[o]=t[o]}),e.removeAttribute("data-autosize-on")}.bind(e,{height:e.style.height,overflow:e.style.overflow,overflowY:e.style.overflowY,wordWrap:e.style.wordWrap,resize:e.style.resize})),e.setAttribute("data-autosize-on",!0),e.style.overflow="hidden",e.style.overflowY="hidden",t()}}return"function"!=typeof window.getComputedStyle?function(e){return e}:function(t){return t&&t.length?Array.prototype.forEach.call(t,e):t&&t.nodeName&&e(t),t}});
\ No newline at end of file