Changeset 471


Ignore:
Timestamp:
Mar 20, 2014 1:47:43 AM (10 years ago)
Author:
anonymous
Message:

improved css/js strip whitespace methods.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/js/Msg.js

    r469 r471  
    9595Strangecode.Msg.prototype.clear = function() {
    9696    // Append this raised message to the sc-msg stack.
    97     msg_class = (typeof msg_class === 'undefined') ? 'sc-msg-error' : msg_class;
     97    var msg_class = (typeof msg_class === 'undefined') ? 'sc-msg-error' : msg_class;
    9898    $(this.o.container).find('.sc-js-msg').remove();
    9999};
  • trunk/lib/CSS.inc.php

    r468 r471  
    169169            if ($this->getParam('strip_whitespace')) {
    170170                // Strip whitespace and print file.
    171                 echo preg_replace('/[ \t\n\r]+/', ' ', file_get_contents($file, true));
     171                echo preg_replace(
     172                    array('!/\*.*?\*/!s', '/[\n\r]+/', '/([;:])\s+/m', '/\s*}[ \t]*/', '/\s*{\s*/', '/[ \t\n\r]*,[ \t\n\r]*/', '/^\s+/'),
     173                    array('', "\n", '$1', '}', '{', ',', ''), file_get_contents($file, true)
     174                );
    172175            } else {
    173176                // Include file as is.
  • trunk/lib/JS.inc.php

    r469 r471  
    169169            if ($this->getParam('strip_whitespace')) {
    170170                // Strip whitespace and print file.
    171                 echo preg_replace(array('@^\s*//.*$@m', '@/\*.*?\*/@s', '/[ \t\n\r]+/'), ' ', file_get_contents($file, true));
     171                echo preg_replace(
     172                    array('!^\s*//.*$!m', '!/\*.*?\*/!s', '/[\n\r]+/', '/[ \t]*}[ \t]*/', '/\s*{\s*/', '/\s*=\s*/', '/^\s+/m'),
     173                    array('', '', "\n", '}', '{', '=', ''), file_get_contents($file, true)
     174                );
    172175            } else {
    173176                // Include file as is.
Note: See TracChangeset for help on using the changeset viewer.