<commit_before>/**
 * jqPlot
 * Pure JavaScript plotting plugin using jQuery
 *
 * Version: @VERSION
 *
 * Copyright (c) 2009-2011 Chris Leonello
 * jqPlot is currently available for use in all personal or commercial projects
 * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
 * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
 * choose the license that best suits your project and use it accordingly.
 *
 * Although not required, the author would appreciate an email letting him
 * know of any substantial use of jqPlot.  You can reach the author at:
 * chris at jqplot dot com or see http://www.jqplot.com/info.php .
 *
 * If you are feeling kind and generous, consider supporting the project by
 * making a donation at: http://www.jqplot.com/donate.php .
 *
 * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
 *
 *     version 2007.04.27
 *     author Ash Searle
 *     http://hexmen.com/blog/2007/03/printf-sprintf/
 *     http://hexmen.com/js/sprintf.js
 *     The author (Ash Searle) has placed this code in the public domain:
 *     "This code is unrestricted: you are free to use it however you like."
 *
 */
(function($) {
    /**
     * JavaScript printf/sprintf functions.
     *
     * This code has been adapted from the publicly available sprintf methods
     * by Ash Searle. His original header follows:
     *
     *     This code is unrestricted: you are free to use it however you like.
     *
     *     The functions should work as expected, performing left or right alignment,
     *     truncating strings, outputting numbers with a required precision etc.
     *
     *     For complex cases, these functions follow the Perl implementations of
     *     (s)printf, allowing arguments to be passed out-of-order, and to set the
     *     precision or length of the output based on arguments instead of fixed
     *     numbers.
     *
     *     See http://perldoc.perl.org/functions/sprintf.html for more information.
     *
     *     Implemented:
     *     - zero and space-padding
     *     - right and left-alignment,
     *     - base X prefix (binary, octal and hex)
     *     - positive number prefix
     *     - (minimum) width
     *     - precision / truncation / maximum width
     *     - out of order arguments
     *
     *     Not implemented (yet):
     *     - vector flag
     *     - size (bytes, words, long-words etc.)
     *
     *     Will not implement:
     *     - %n or %p (no pass-by-reference in JavaScript)
     *
     *     @version 2007.04.27
     *     @author Ash Searle
     *
     * You can see the original work and comments on his blog:
     * http://hexmen.com/blog/2007/03/printf-sprintf/
     * http://hexmen.com/js/sprintf.js
     */

     /**
      * @Modifications 2009.05.26
      * @author Chris Leonello
      *
      * Added %p %P specifier
      * Acts like %g or %G but will not add more significant digits to the output than present in the input.
      * Example:
      * Format: '%.3p', Input: 0.012, Output: 0.012
      * Format: '%.3g', Input: 0.012, Output: 0.0120
      * Format: '%.4p', Input: 12.0, Output: 12.0
      * Format: '%.4g', Input: 12.0, Output: 12.00
      * Format: '%.4p', Input: 4.321e-5, Output: 4.321e-5
      * Format: '%.4g', Input: 4.321e-5, Output: 4.3210e-5
      *
      * Example:
      * >>> $.jqplot.sprintf('%.2f, %d', 23.3452, 43.23)
      * "23.35, 43"
      */
    $.jqplot.sprintf = function() {
        function pad(str, len, chr, leftJustify) {
            var padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr);
            return leftJustify ? str + padding : padding + str;

        }

        function thousand_separate(value) {
            var value_str = new String(value);
            for (var i=10; i>0; i--) {
                if (value_str == (value_str = value_str.replace(/^(\d+)(\d{3})/, "$1"+$.jqplot.sprintf.thousandsSeparator+"$2"))) break;
            }
            return value_str;
        }

        function justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace) {
            var diff = minWidth - value.length;
            if (diff > 0) {
                var spchar = ' ';
                if (htmlSpace) { spchar = ' '; }
                if (leftJustify || !zeroPad) {
                    value = pad(value, minWidth, spchar, leftJustify);
                } else {
                    value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length);
                }
            }
            return value;
        }

        function formatBaseX(value, base, prefix, leftJustify, minWidth, precision, zeroPad, htmlSpace) {
            // Note: casts negative numbers to positive ones
            var number = value >>> 0;
            prefix = prefix && number && {'2': '0b', '8': '0', '16': '0x'}[base] || '';
            value = prefix + pad(number.toString(base), precision || 0, '0', false);
            return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace);
        }

        function formatString(value, leftJustify, minWidth, precision, zeroPad, htmlSpace) {
            if (precision != null) {
                value = value.slice(0, precision);
            }
            return justify(value, '', leftJustify, minWidth, zeroPad, htmlSpace);
        }

        var a = arguments, i = 0, format = a[i++];

        return format.replace($.jqplot.sprintf.regex, function(substring, valueIndex, flags, minWidth, _, precision, type) {
            if (substring == '%%') { return '%'; }

            // parse flags
            var leftJustify = false, positivePrefix = '', zeroPad = false, prefixBaseX = false, htmlSpace = false, thousandSeparation = false;
            for (var j = 0; flags && j < flags.length; j++) switch (flags.charAt(j)) {
                case ' ': positivePrefix = ' '; break;
                case '+': positivePrefix = '+'; break;
                case '-': leftJustify = true; break;
                case '0': zeroPad = true; break;
                case '#': prefixBaseX = true; break;
                case '&': htmlSpace = true; break;
                case '\'': thousandSeparation = true; break;
            }

            // parameters may be null, undefined, empty-string or real valued
            // we want to ignore null, undefined and empty-string values

            if (!minWidth) {
                minWidth = 0;
            }
            else if (minWidth == '*') {
                minWidth = +a[i++];
            }
            else if (minWidth.charAt(0) == '*') {
                minWidth = +a[minWidth.slice(1, -1)];
            }
            else {
                minWidth = +minWidth;
            }

            // Note: undocumented perl feature:
            if (minWidth < 0) {
                minWidth = -minWidth;
                leftJustify = true;
            }

            if (!isFinite(minWidth)) {
                throw new Error('$.jqplot.sprintf: (minimum-)width must be finite');
            }

            if (!precision) {
                precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type == 'd') ? 0 : void(0);
            }
            else if (precision == '*') {
                precision = +a[i++];
            }
            else if (precision.charAt(0) == '*') {
                precision = +a[precision.slice(1, -1)];
            }
            else {
                precision = +precision;
            }

            // grab value using valueIndex if required?
            var value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++];

            switch (type) {
            case 's': {
                if (value == null) {
                    return '';
                }
                return formatString(String(value), leftJustify, minWidth, precision, zeroPad, htmlSpace);
            }
            case 'c': return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad, htmlSpace);
            case 'b': return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad,htmlSpace);
            case 'o': return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace);
            case 'x': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace);
            case 'X': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace).toUpperCase();
            case 'u': return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace);
            case 'i': {
              var number = parseInt(+value, 10);
              if (isNaN(number)) {
                return '';
              }
              var prefix = number < 0 ? '-' : positivePrefix;
              var number_str = thousandSeparation ? thousand_separate(String(Math.abs(number))): String(Math.abs(number));
              value = prefix + pad(number_str, precision, '0', false);
              //value = prefix + pad(String(Math.abs(number)), precision, '0', false);
              return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace);
                  }
            case 'd': {
              var number = Math.round(+value);
              if (isNaN(number)) {
                return '';
              }
              var prefix = number < 0 ? '-' : positivePrefix;
              var number_str = thousandSeparation ? thousand_separate(String(Math.abs(number))): String(Math.abs(number));
              value = prefix + pad(number_str, precision, '0', false);
              return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace);
                  }
            case 'e':
            case 'E':
            case 'f':
            case 'F':
            case 'g':
            case 'G':
                      {
                      var number = +value;
                      if (isNaN(number)) {
                          return '';
                      }
                      var prefix = number < 0 ? '-' : positivePrefix;
                      var method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())];
                      var textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2];
                      var number_str = Math.abs(number)[method](precision);
                      number_str = thousandSeparation ? thousand_separate(number_str): number_str;
                      value = prefix + number_str;
                      return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace)[textTransform]();
                  }
            case 'p':
            case 'P':
            {
                // make sure number is a number
                var number = +value;
                if (isNaN(number)) {
                    return '';
                }
                var prefix = number < 0 ? '-' : positivePrefix;

                var parts = String(Number(Math.abs(number)).toExponential()).split(/e|E/);
                var sd = (parts[0].indexOf('.') != -1) ? parts[0].length - 1 : parts[0].length;
                var zeros = (parts[1] < 0) ? -parts[1] - 1 : 0;

                if (Math.abs(number) < 1) {
                    if (sd + zeros  <= precision) {
                        value = prefix + Math.abs(number).toPrecision(sd);
                    }
                    else {
                        if (sd  <= precision - 1) {
                            value = prefix + Math.abs(number).toExponential(sd-1);
                        }
                        else {
                            value = prefix + Math.abs(number).toExponential(precision-1);
                        }
                    }
                }
                else {
                    var prec = (sd <= precision) ? sd : precision;
                    value = prefix + Math.abs(number).toPrecision(prec);
                }
                var textTransform = ['toString', 'toUpperCase']['pP'.indexOf(type) % 2];
                return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace)[textTransform]();
            }
            case 'n': return '';
            default: return substring;
            }
        });
    };

    $.jqplot.sprintf.thousandsSeparator = ',';

    $.jqplot.sprintf.regex = /%%|%(\d+\$)?([-+#0&\' ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([nAscboxXuidfegpEGP])/g;

    $.jqplot.getSignificantFigures = function(number) {
        var parts = String(Number(Math.abs(number)).toExponential()).split(/e|E/);
        // total significant digits
        var sd = (parts[0].indexOf('.') != -1) ? parts[0].length - 1 : parts[0].length;
        var zeros = (parts[1] < 0) ? -parts[1] - 1 : 0;
        // exponent
        var expn = parseInt(parts[1]);
        // digits to the left of the decimal place
        var dleft = (expn + 1 > 0) ? expn + 1 : 0;
        // digits to the right of the decimal place
        var dright = (sd <= dleft) ? 0 : sd - expn - 1;
        return {significantDigits: sd, digitsLeft: dleft, digitsRight: dright, zeros: zeros, exponent: expn} ;
    };

    $.jqplot.getPrecision = function(number) {
        var arr = $.jqplot.getSignificantFigures(number);
        var p = arr[1] - 1 - parseInt(arr[0][1]);
        return p;
    };

})(jQuery);
<commit_msg>Added example of sprintf code to skip value and use thousands separator.<commit_after>/**
 * jqPlot
 * Pure JavaScript plotting plugin using jQuery
 *
 * Version: @VERSION
 *
 * Copyright (c) 2009-2011 Chris Leonello
 * jqPlot is currently available for use in all personal or commercial projects
 * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
 * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
 * choose the license that best suits your project and use it accordingly.
 *
 * Although not required, the author would appreciate an email letting him
 * know of any substantial use of jqPlot.  You can reach the author at:
 * chris at jqplot dot com or see http://www.jqplot.com/info.php .
 *
 * If you are feeling kind and generous, consider supporting the project by
 * making a donation at: http://www.jqplot.com/donate.php .
 *
 * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
 *
 *     version 2007.04.27
 *     author Ash Searle
 *     http://hexmen.com/blog/2007/03/printf-sprintf/
 *     http://hexmen.com/js/sprintf.js
 *     The author (Ash Searle) has placed this code in the public domain:
 *     "This code is unrestricted: you are free to use it however you like."
 *
 */
(function($) {
    /**
     * JavaScript printf/sprintf functions.
     *
     * This code has been adapted from the publicly available sprintf methods
     * by Ash Searle. His original header follows:
     *
     *     This code is unrestricted: you are free to use it however you like.
     *
     *     The functions should work as expected, performing left or right alignment,
     *     truncating strings, outputting numbers with a required precision etc.
     *
     *     For complex cases, these functions follow the Perl implementations of
     *     (s)printf, allowing arguments to be passed out-of-order, and to set the
     *     precision or length of the output based on arguments instead of fixed
     *     numbers.
     *
     *     See http://perldoc.perl.org/functions/sprintf.html for more information.
     *
     *     Implemented:
     *     - zero and space-padding
     *     - right and left-alignment,
     *     - base X prefix (binary, octal and hex)
     *     - positive number prefix
     *     - (minimum) width
     *     - precision / truncation / maximum width
     *     - out of order arguments
     *
     *     Not implemented (yet):
     *     - vector flag
     *     - size (bytes, words, long-words etc.)
     *
     *     Will not implement:
     *     - %n or %p (no pass-by-reference in JavaScript)
     *
     *     @version 2007.04.27
     *     @author Ash Searle
     *
     * You can see the original work and comments on his blog:
     * http://hexmen.com/blog/2007/03/printf-sprintf/
     * http://hexmen.com/js/sprintf.js
     */

     /**
      * @Modifications 2009.05.26
      * @author Chris Leonello
      *
      * Added %p %P specifier
      * Acts like %g or %G but will not add more significant digits to the output than present in the input.
      * Example:
      * Format: '%.3p', Input: 0.012, Output: 0.012
      * Format: '%.3g', Input: 0.012, Output: 0.0120
      * Format: '%.4p', Input: 12.0, Output: 12.0
      * Format: '%.4g', Input: 12.0, Output: 12.00
      * Format: '%.4p', Input: 4.321e-5, Output: 4.321e-5
      * Format: '%.4g', Input: 4.321e-5, Output: 4.3210e-5
      *
      * Example:
      * >>> $.jqplot.sprintf('%.2f, %d', 23.3452, 43.23)
      * "23.35, 43"
      * >>> $.jqplot.sprintf("no value: %n, decimal with thousands separator: %'d", 23.3452, 433524)
      * "no value: , decimal with thousands separator: 433,524"
      */
    $.jqplot.sprintf = function() {
        function pad(str, len, chr, leftJustify) {
            var padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr);
            return leftJustify ? str + padding : padding + str;

        }

        function thousand_separate(value) {
            var value_str = new String(value);
            for (var i=10; i>0; i--) {
                if (value_str == (value_str = value_str.replace(/^(\d+)(\d{3})/, "$1"+$.jqplot.sprintf.thousandsSeparator+"$2"))) break;
            }
            return value_str;
        }

        function justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace) {
            var diff = minWidth - value.length;
            if (diff > 0) {
                var spchar = ' ';
                if (htmlSpace) { spchar = ' '; }
                if (leftJustify || !zeroPad) {
                    value = pad(value, minWidth, spchar, leftJustify);
                } else {
                    value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length);
                }
            }
            return value;
        }

        function formatBaseX(value, base, prefix, leftJustify, minWidth, precision, zeroPad, htmlSpace) {
            // Note: casts negative numbers to positive ones
            var number = value >>> 0;
            prefix = prefix && number && {'2': '0b', '8': '0', '16': '0x'}[base] || '';
            value = prefix + pad(number.toString(base), precision || 0, '0', false);
            return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace);
        }

        function formatString(value, leftJustify, minWidth, precision, zeroPad, htmlSpace) {
            if (precision != null) {
                value = value.slice(0, precision);
            }
            return justify(value, '', leftJustify, minWidth, zeroPad, htmlSpace);
        }

        var a = arguments, i = 0, format = a[i++];

        return format.replace($.jqplot.sprintf.regex, function(substring, valueIndex, flags, minWidth, _, precision, type) {
            if (substring == '%%') { return '%'; }

            // parse flags
            var leftJustify = false, positivePrefix = '', zeroPad = false, prefixBaseX = false, htmlSpace = false, thousandSeparation = false;
            for (var j = 0; flags && j < flags.length; j++) switch (flags.charAt(j)) {
                case ' ': positivePrefix = ' '; break;
                case '+': positivePrefix = '+'; break;
                case '-': leftJustify = true; break;
                case '0': zeroPad = true; break;
                case '#': prefixBaseX = true; break;
                case '&': htmlSpace = true; break;
                case '\'': thousandSeparation = true; break;
            }

            // parameters may be null, undefined, empty-string or real valued
            // we want to ignore null, undefined and empty-string values

            if (!minWidth) {
                minWidth = 0;
            }
            else if (minWidth == '*') {
                minWidth = +a[i++];
            }
            else if (minWidth.charAt(0) == '*') {
                minWidth = +a[minWidth.slice(1, -1)];
            }
            else {
                minWidth = +minWidth;
            }

            // Note: undocumented perl feature:
            if (minWidth < 0) {
                minWidth = -minWidth;
                leftJustify = true;
            }

            if (!isFinite(minWidth)) {
                throw new Error('$.jqplot.sprintf: (minimum-)width must be finite');
            }

            if (!precision) {
                precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type == 'd') ? 0 : void(0);
            }
            else if (precision == '*') {
                precision = +a[i++];
            }
            else if (precision.charAt(0) == '*') {
                precision = +a[precision.slice(1, -1)];
            }
            else {
                precision = +precision;
            }

            // grab value using valueIndex if required?
            var value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++];

            switch (type) {
            case 's': {
                if (value == null) {
                    return '';
                }
                return formatString(String(value), leftJustify, minWidth, precision, zeroPad, htmlSpace);
            }
            case 'c': return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad, htmlSpace);
            case 'b': return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad,htmlSpace);
            case 'o': return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace);
            case 'x': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace);
            case 'X': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace).toUpperCase();
            case 'u': return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace);
            case 'i': {
              var number = parseInt(+value, 10);
              if (isNaN(number)) {
                return '';
              }
              var prefix = number < 0 ? '-' : positivePrefix;
              var number_str = thousandSeparation ? thousand_separate(String(Math.abs(number))): String(Math.abs(number));
              value = prefix + pad(number_str, precision, '0', false);
              //value = prefix + pad(String(Math.abs(number)), precision, '0', false);
              return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace);
                  }
            case 'd': {
              var number = Math.round(+value);
              if (isNaN(number)) {
                return '';
              }
              var prefix = number < 0 ? '-' : positivePrefix;
              var number_str = thousandSeparation ? thousand_separate(String(Math.abs(number))): String(Math.abs(number));
              value = prefix + pad(number_str, precision, '0', false);
              return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace);
                  }
            case 'e':
            case 'E':
            case 'f':
            case 'F':
            case 'g':
            case 'G':
                      {
                      var number = +value;
                      if (isNaN(number)) {
                          return '';
                      }
                      var prefix = number < 0 ? '-' : positivePrefix;
                      var method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())];
                      var textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2];
                      var number_str = Math.abs(number)[method](precision);
                      number_str = thousandSeparation ? thousand_separate(number_str): number_str;
                      value = prefix + number_str;
                      return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace)[textTransform]();
                  }
            case 'p':
            case 'P':
            {
                // make sure number is a number
                var number = +value;
                if (isNaN(number)) {
                    return '';
                }
                var prefix = number < 0 ? '-' : positivePrefix;

                var parts = String(Number(Math.abs(number)).toExponential()).split(/e|E/);
                var sd = (parts[0].indexOf('.') != -1) ? parts[0].length - 1 : parts[0].length;
                var zeros = (parts[1] < 0) ? -parts[1] - 1 : 0;

                if (Math.abs(number) < 1) {
                    if (sd + zeros  <= precision) {
                        value = prefix + Math.abs(number).toPrecision(sd);
                    }
                    else {
                        if (sd  <= precision - 1) {
                            value = prefix + Math.abs(number).toExponential(sd-1);
                        }
                        else {
                            value = prefix + Math.abs(number).toExponential(precision-1);
                        }
                    }
                }
                else {
                    var prec = (sd <= precision) ? sd : precision;
                    value = prefix + Math.abs(number).toPrecision(prec);
                }
                var textTransform = ['toString', 'toUpperCase']['pP'.indexOf(type) % 2];
                return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace)[textTransform]();
            }
            case 'n': return '';
            default: return substring;
            }
        });
    };

    $.jqplot.sprintf.thousandsSeparator = ',';

    $.jqplot.sprintf.regex = /%%|%(\d+\$)?([-+#0&\' ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([nAscboxXuidfegpEGP])/g;

    $.jqplot.getSignificantFigures = function(number) {
        var parts = String(Number(Math.abs(number)).toExponential()).split(/e|E/);
        // total significant digits
        var sd = (parts[0].indexOf('.') != -1) ? parts[0].length - 1 : parts[0].length;
        var zeros = (parts[1] < 0) ? -parts[1] - 1 : 0;
        // exponent
        var expn = parseInt(parts[1]);
        // digits to the left of the decimal place
        var dleft = (expn + 1 > 0) ? expn + 1 : 0;
        // digits to the right of the decimal place
        var dright = (sd <= dleft) ? 0 : sd - expn - 1;
        return {significantDigits: sd, digitsLeft: dleft, digitsRight: dright, zeros: zeros, exponent: expn} ;
    };

    $.jqplot.getPrecision = function(number) {
        var arr = $.jqplot.getSignificantFigures(number);
        var p = arr[1] - 1 - parseInt(arr[0][1]);
        return p;
    };

})(jQuery);
<|endoftext|>


<commit_before>import gulp from 'gulp';
import sass from 'gulp-sass';
import gutil from 'gulp-util';
import babelify from 'babelify';
import jshint from 'gulp-jshint';
import browserify from 'browserify';
import stylish from 'jshint-stylish';
import source from 'vinyl-source-stream';
import autoprefixer from 'gulp-autoprefixer';

const SCRIPTS_DIR = 'resources/assets/scripts';
const STYLES_DIR = 'resources/assets/sass';

/**
 * Handle error reporting
 * @param  object error
 */
function handleError(error){
  gutil.log(gutil.colors.red('Error: ' + error.message));
  this.emit('end');
}

// Lint javascript files
gulp.task('lint', () => {
  return gulp.src(SCRIPTS_DIR+'/**/*.js')
    .pipe(jshint({'esnext': true}))
    .pipe(jshint.reporter(stylish))
    .pipe(jshint.reporter('fail'));
});

// Use ES6 modules in the browser
gulp.task('browserify', () => {
  return browserify(SCRIPTS_DIR+'/main.js')
    .transform(babelify, { stage: 0 })
    .bundle()
    .on('error', handleError)
    .pipe(source('bundle.js'))
    .pipe(gulp.dest('./public/js'));
});

// Compile SASS to regular CSS
gulp.task('sass', () => {
  return gulp.src(STYLES_DIR+'/style.scss')
    .pipe(sass().on('error', handleError))
    .pipe(autoprefixer('last 10 versions'))
    .pipe(gulp.dest('./public/css'));
});

// Recompile files when saved
gulp.task('watch', ['lint', 'browserify', 'sass'], () => {
  gulp.watch(SCRIPTS_DIR+'/**/*.js', ['lint', 'browserify']);
  gulp.watch(STYLES_DIR+'/**/*.scss', ['sass']);
});

// Default gulp task
gulp.task('default', ['watch']);
<commit_msg>updated comments in gulpfile<commit_after>import gulp from 'gulp';
import sass from 'gulp-sass';
import gutil from 'gulp-util';
import babelify from 'babelify';
import jshint from 'gulp-jshint';
import browserify from 'browserify';
import stylish from 'jshint-stylish';
import source from 'vinyl-source-stream';
import autoprefixer from 'gulp-autoprefixer';

const SCRIPTS_DIR = 'resources/assets/scripts';
const STYLES_DIR = 'resources/assets/sass';

/**
 * Handle error reporting
 * @param  object error
 */
function handleError(error){
  gutil.log(gutil.colors.red('Error: ' + error.message));
  this.emit('end');
}

// Lint javascript files
gulp.task('lint', () => {
  return gulp.src(SCRIPTS_DIR+'/**/*.js')
    .pipe(jshint({'esnext': true}))
    .pipe(jshint.reporter(stylish))
    .pipe(jshint.reporter('fail'));
});

// Compile node modules for use in the browser
gulp.task('browserify', () => {
  return browserify(SCRIPTS_DIR+'/main.js')
    .transform(babelify, { stage: 0 })
    .bundle()
    .on('error', handleError)
    .pipe(source('bundle.js'))
    .pipe(gulp.dest('./public/js'));
});

// Compile SASS and add vendor prefixes
gulp.task('sass', () => {
  return gulp.src(STYLES_DIR+'/style.scss')
    .pipe(sass().on('error', handleError))
    .pipe(autoprefixer('last 10 versions'))
    .pipe(gulp.dest('./public/css'));
});

// Watch files for changes
gulp.task('watch', ['lint', 'browserify', 'sass'], () => {
  gulp.watch(SCRIPTS_DIR+'/**/*.js', ['lint', 'browserify']);
  gulp.watch(STYLES_DIR+'/**/*.scss', ['sass']);
});

// Default gulp task
gulp.task('default', ['watch']);
<|endoftext|>


<commit_before>(function($) {

    $.fn.jqplotChildText = function() {
        return $(this).contents().filter(function() {
            return this.nodeType == 3;  // Node.TEXT_NODE not defined in I7
        }).text();
    };

    // Returns font style as abbreviation for "font" property.
    $.fn.jqplotGetComputedFontStyle = function() {
        var css = window.getComputedStyle ?  window.getComputedStyle(this[0]) : this[0].currentStyle;;
        var attrs = css['font-style']
            ? ['font-style', 'font-weight', 'font-size', 'font-family']
            : ['fontStyle', 'fontWeight', 'fontSize', 'fontFamily'];
        var style = [];

        for (var i=0 ; i < attrs.length; ++i) {
            var attr = String(css[attrs[i]]);

            if (attr && attr != 'normal') {
                style.push(attr);
            }
        }
        return style.join(' ');
    };

    $.fn.jqplotToImage = function(x_offset, y_offset) {

        x_offset = (x_offset == null) ? 0 : x_offset;
        y_offset = (y_offset == null) ? 0 : y_offset;

        if ($(this).width() == 0 || $(this).height() == 0) {
            return null;
        }

        // excanvas and hence IE < 9 do not support toDataURL and cannot export images.
        if (!$.jqplot.support_canvas) {
            return null;
        }

        var newCanvas = document.createElement("canvas");
        var h = $(this).outerHeight(true);
        var w = $(this).outerWidth(true);
        var plotleft = $(this).offset().left;
        var plottop = $(this).offset().top;
        var transx = 0, transy = 0;
        // console.log("chart: height: %s, width: %s, left: %s, top: %s, transx: %s, transy: %s", h, w, plotleft, plottop, transx, transy);

        // have to check if any elements are hanging outside of plot area before rendering,
        // since changing width of canvas will erase canvas.

        var clses = ['jqplot-table-legend', 'jqplot-xaxis-tick', 'jqplot-x2axis-tick', 'jqplot-yaxis-tick', 'jqplot-y2axis-tick', 'jqplot-y3axis-tick',
        'jqplot-y4axis-tick', 'jqplot-y5axis-tick', 'jqplot-y6axis-tick', 'jqplot-y7axis-tick', 'jqplot-y8axis-tick', 'jqplot-y9axis-tick',
        'jqplot-xaxis-label', 'jqplot-x2axis-label', 'jqplot-yaxis-label', 'jqplot-y2axis-label', 'jqplot-y3axis-label', 'jqplot-y4axis-label',
        'jqplot-y5axis-label', 'jqplot-y6axis-label', 'jqplot-y7axis-label', 'jqplot-y8axis-label', 'jqplot-y9axis-label' ];

        var temptop, templeft, tempbottom, tempright;

        for (i in clses) {
            $(this).find('.'+clses[i]).each(function() {
                temptop = $(this).offset().top - plottop;
                templeft = $(this).offset().left - plotleft;
                tempright = templeft + $(this).outerWidth(true);
                tempbottom = temptop + $(this).outerHeight(true);
                if (templeft < -transx) {
                    w = w - transx - templeft;
                    transx = -templeft;
                }
                if (temptop < -transy) {
                    h = h - transy - temptop;
                    transy = - temptop;
                }
                if (tempright > w) {
                    w = tempright;
                }
                if (tempbottom > h) {
                    h =  tempbottom;
                }
            })
        }
        // console.log("chart: height: %s, width: %s, left: %s, top: %s, transx: %s, transy: %s", h, w, plotleft, plottop, transx, transy);

        newCanvas.width = w + Number(x_offset);
        newCanvas.height = h + Number(y_offset);

        var newContext = newCanvas.getContext("2d");
        newContext.translate(transx, transy);
        newContext.textAlign = 'left';
        newContext.textBaseline = 'top';

        function _jqpToImage(el, x_offset, y_offset) {
            var tagname = el.tagName.toLowerCase();
            var p = $(el).position();
            var css = window.getComputedStyle ?  window.getComputedStyle(el) : el.currentStyle; // for IE < 9
            var left = x_offset + p.left + parseInt(css.marginLeft) + parseInt(css.borderLeftWidth) + parseInt(css.paddingLeft);
            var top = y_offset + p.top + parseInt(css.marginTop) + parseInt(css.borderTopWidth)+ parseInt(css.paddingTop);
            // var left = x_offset + p.left + $(el).css('marginLeft') + $(el).css('borderLeftWidth')

            if ((tagname == 'div' || tagname == 'span') && !$(el).hasClass('jqplot-highlighter-tooltip')) {
                $(el).children().each(function() {
                    _jqpToImage(this, left, top);
                });
                var text = $(el).jqplotChildText();

                if (text) {
                    newContext.font = $(el).jqplotGetComputedFontStyle();
                    newContext.fillStyle = $(el).css('color');
                    // center text if necessary
                    if ($(el).css('textAlign') === 'center') {
                        left += (newCanvas.width - newContext.measureText(text).width)/2  - transx;
                    }
                    newContext.fillText(text, left, top);
                }
            }

            // handle the standard table legend

            else if (tagname === 'table' && $(el).hasClass('jqplot-table-legend')) {
                newContext.strokeStyle = $(el).css('border-top-color');
                newContext.fillStyle = $(el).css('background-color');
                newContext.fillRect(left, top, $(el).innerWidth(), $(el).innerHeight());
                newContext.strokeRect(left, top, $(el).innerWidth(), $(el).innerHeight());

                // find all the swatches
                $(el).find('div.jqplot-table-legend-swatch-outline').each(function() {
                    // get the first div and stroke it
                    var elem = $(this);
                    newContext.strokeStyle = elem.css('border-top-color');
                    var l = left + elem.position().left;
                    var t = top + elem.position().top;
                    newContext.strokeRect(l, t, elem.innerWidth(), elem.innerHeight());

                    // now fill the swatch

                    l += parseInt(elem.css('padding-left'));
                    t += parseInt(elem.css('padding-top'));
                    var h = elem.innerHeight() - 2 * parseInt(elem.css('padding-top'));
                    var w = elem.innerWidth() - 2 * parseInt(elem.css('padding-left'));

                    var swatch = elem.children('div.jqplot-table-legend-swatch');
                    newContext.fillStyle = swatch.css('background-color');
                    newContext.fillRect(l, t, w, h);
                });

                // now add text

                $(el).find('td.jqplot-table-legend-label').each(function(){
                    var elem = $(this);
                    var l = left + elem.position().left;
                    var t = top + elem.position().top + parseInt(elem.css('padding-top'));
                    newContext.font = elem.jqplotGetComputedFontStyle();
                    newContext.fillStyle = elem.css('color');
                    newContext.fillText(elem.text(), l, t);
                });

                elem = null;
            }

            else if (tagname == 'canvas') {
                newContext.drawImage(el, left, top);
            }
        }
        $(this).children().each(function() {
            _jqpToImage(this, x_offset, y_offset);
        });
        return newCanvas;
    };

    $.fn.jqplotSaveImage = function(fmt) {
        var imgCanvas = $(this).jqplotToImage(0,0);
        if (imgCanvas) {
            // if (imgCanvas.mozGetAsFile) {
            //     var f = imgCanvas.mozGetAsFile("test.png");
            //     console.log(f);
            // }
            var imgData = imgCanvas.toDataURL("image/png");
            window.location.href = imgData.replace("image/png", "image/octet-stream");
        }

    };

    $.fn.jqplotViewImage = function(fmt) {
        var imgCanvas = $(this).jqplotToImage(0,0);
        if (imgCanvas) {
            window.open(imgCanvas.toDataURL("image/png"));
        }
    };

})(jQuery);
<commit_msg>Fixed clipping in image export in certain cases and don't draw legend border in export if width is 0.<commit_after>(function($) {

    $.fn.jqplotChildText = function() {
        return $(this).contents().filter(function() {
            return this.nodeType == 3;  // Node.TEXT_NODE not defined in I7
        }).text();
    };

    // Returns font style as abbreviation for "font" property.
    $.fn.jqplotGetComputedFontStyle = function() {
        var css = window.getComputedStyle ?  window.getComputedStyle(this[0]) : this[0].currentStyle;;
        var attrs = css['font-style']
            ? ['font-style', 'font-weight', 'font-size', 'font-family']
            : ['fontStyle', 'fontWeight', 'fontSize', 'fontFamily'];
        var style = [];

        for (var i=0 ; i < attrs.length; ++i) {
            var attr = String(css[attrs[i]]);

            if (attr && attr != 'normal') {
                style.push(attr);
            }
        }
        return style.join(' ');
    };

    $.fn.jqplotToImage = function(x_offset, y_offset) {

        x_offset = (x_offset == null) ? 0 : x_offset;
        y_offset = (y_offset == null) ? 0 : y_offset;

        if ($(this).width() == 0 || $(this).height() == 0) {
            return null;
        }

        // excanvas and hence IE < 9 do not support toDataURL and cannot export images.
        if (!$.jqplot.support_canvas) {
            return null;
        }

        var newCanvas = document.createElement("canvas");
        var h = $(this).outerHeight(true);
        var w = $(this).outerWidth(true);
        var plotleft = $(this).offset().left;
        var plottop = $(this).offset().top;
        var transx = 0, transy = 0;
        // var tlw = tlh = tll = tlr = tlt = tlb = 0;
        // console.log("chart: height: %s, width: %s, left: %s, top: %s, transx: %s, transy: %s", h, w, plotleft, plottop, transx, transy);

        // have to check if any elements are hanging outside of plot area before rendering,
        // since changing width of canvas will erase canvas.

        var clses = ['jqplot-table-legend', 'jqplot-xaxis-tick', 'jqplot-x2axis-tick', 'jqplot-yaxis-tick', 'jqplot-y2axis-tick', 'jqplot-y3axis-tick',
        'jqplot-y4axis-tick', 'jqplot-y5axis-tick', 'jqplot-y6axis-tick', 'jqplot-y7axis-tick', 'jqplot-y8axis-tick', 'jqplot-y9axis-tick',
        'jqplot-xaxis-label', 'jqplot-x2axis-label', 'jqplot-yaxis-label', 'jqplot-y2axis-label', 'jqplot-y3axis-label', 'jqplot-y4axis-label',
        'jqplot-y5axis-label', 'jqplot-y6axis-label', 'jqplot-y7axis-label', 'jqplot-y8axis-label', 'jqplot-y9axis-label' ];

        var temptop, templeft, tempbottom, tempright;

        for (i in clses) {
            $(this).find('.'+clses[i]).each(function() {
                temptop = $(this).offset().top - plottop;
                templeft = $(this).offset().left - plotleft;
                tempright = templeft + $(this).outerWidth(true) + transx;
                tempbottom = temptop + $(this).outerHeight(true) + transy;
                if (templeft < -transx) {
                    w = w - transx - templeft;
                    transx = -templeft;
                }
                if (temptop < -transy) {
                    h = h - transy - temptop;
                    transy = - temptop;
                }
                if (tempright > w) {
                    w = tempright;
                }
                if (tempbottom > h) {
                    h =  tempbottom;
                }
                // console.log(this.tagName);
                // console.log(temptop, templeft, tempright, tempbottom);
                // console.log(w, h, transx, transy);
            })
        }
        // console.log("chart: height: %s, width: %s, left: %s, top: %s, transx: %s, transy: %s", h, w, plotleft, plottop, transx, transy);

        newCanvas.width = w + Number(x_offset);
        newCanvas.height = h + Number(y_offset);

        var newContext = newCanvas.getContext("2d");
        newContext.translate(transx, transy);
        newContext.textAlign = 'left';
        newContext.textBaseline = 'top';

        function _jqpToImage(el, x_offset, y_offset) {
            var tagname = el.tagName.toLowerCase();
            var p = $(el).position();
            var css = window.getComputedStyle ?  window.getComputedStyle(el) : el.currentStyle; // for IE < 9
            var left = x_offset + p.left + parseInt(css.marginLeft) + parseInt(css.borderLeftWidth) + parseInt(css.paddingLeft);
            var top = y_offset + p.top + parseInt(css.marginTop) + parseInt(css.borderTopWidth)+ parseInt(css.paddingTop);
            // var left = x_offset + p.left + $(el).css('marginLeft') + $(el).css('borderLeftWidth')

            if ((tagname == 'div' || tagname == 'span') && !$(el).hasClass('jqplot-highlighter-tooltip')) {
                $(el).children().each(function() {
                    _jqpToImage(this, left, top);
                });
                var text = $(el).jqplotChildText();

                if (text) {
                    newContext.font = $(el).jqplotGetComputedFontStyle();
                    newContext.fillStyle = $(el).css('color');
                    // center text if necessary
                    if ($(el).css('textAlign') === 'center') {
                        left += (newCanvas.width - newContext.measureText(text).width)/2  - transx;
                    }
                    newContext.fillText(text, left, top);
                }
            }

            // handle the standard table legend

            else if (tagname === 'table' && $(el).hasClass('jqplot-table-legend')) {
                newContext.strokeStyle = $(el).css('border-top-color');
                newContext.fillStyle = $(el).css('background-color');
                newContext.fillRect(left, top, $(el).innerWidth(), $(el).innerHeight());
                if (parseInt($(el).css('border-top-width')) > 0) {
                    newContext.strokeRect(left, top, $(el).innerWidth(), $(el).innerHeight());
                }

                // find all the swatches
                $(el).find('div.jqplot-table-legend-swatch-outline').each(function() {
                    // get the first div and stroke it
                    var elem = $(this);
                    newContext.strokeStyle = elem.css('border-top-color');
                    var l = left + elem.position().left;
                    var t = top + elem.position().top;
                    newContext.strokeRect(l, t, elem.innerWidth(), elem.innerHeight());

                    // now fill the swatch

                    l += parseInt(elem.css('padding-left'));
                    t += parseInt(elem.css('padding-top'));
                    var h = elem.innerHeight() - 2 * parseInt(elem.css('padding-top'));
                    var w = elem.innerWidth() - 2 * parseInt(elem.css('padding-left'));

                    var swatch = elem.children('div.jqplot-table-legend-swatch');
                    newContext.fillStyle = swatch.css('background-color');
                    newContext.fillRect(l, t, w, h);
                });

                // now add text

                $(el).find('td.jqplot-table-legend-label').each(function(){
                    var elem = $(this);
                    var l = left + elem.position().left;
                    var t = top + elem.position().top + parseInt(elem.css('padding-top'));
                    newContext.font = elem.jqplotGetComputedFontStyle();
                    newContext.fillStyle = elem.css('color');
                    newContext.fillText(elem.text(), l, t);
                });

                elem = null;
            }

            else if (tagname == 'canvas') {
                newContext.drawImage(el, left, top);
            }
        }
        $(this).children().each(function() {
            _jqpToImage(this, x_offset, y_offset);
        });
        return newCanvas;
    };

    $.fn.jqplotSaveImage = function(fmt) {
        var imgCanvas = $(this).jqplotToImage(0,0);
        if (imgCanvas) {
            // if (imgCanvas.mozGetAsFile) {
            //     var f = imgCanvas.mozGetAsFile("test.png");
            //     console.log(f);
            // }
            var imgData = imgCanvas.toDataURL("image/png");
            window.location.href = imgData.replace("image/png", "image/octet-stream");
        }

    };

    $.fn.jqplotViewImage = function(fmt) {
        var imgCanvas = $(this).jqplotToImage(0,0);
        if (imgCanvas) {
            window.open(imgCanvas.toDataURL("image/png"));
        }
    };

})(jQuery);
<|endoftext|>


<commit_before>'use strict';
import babelCompiler from 'babel';
import gulp from 'gulp';
import eslint from 'gulp-eslint';
import istanbul from 'gulp-istanbul';
import jscs from 'gulp-jscs';
import jshint from 'gulp-jshint';
import mocha from 'gulp-mocha';

const configFiles = './gulpfile.babel.js'
  , srcFiles = 'index.js'
  , testFiles = 'test/*.js';

gulp.task('lint', () => {
  return gulp.src([configFiles, srcFiles, testFiles])
    .pipe(eslint())
    .pipe(eslint.formatEach('./node_modules/eslint-path-formatter'))
    .pipe(eslint.failOnError())
    .pipe(jscs({
      esnext: true
    }))
    .pipe(jshint())
    .pipe(jshint.reporter('default'))
    .pipe(jshint.reporter('fail'));
});

gulp.task('build', ['lint']);

gulp.task('test', ['build'], (cb) => {
  gulp.src(['index.js'])
    .pipe(istanbul())
    .pipe(istanbul.hookRequire())
    .on('finish', () => {
      gulp.src([testFiles])
        .pipe(mocha({
          compilers: {
            js: babelCompiler
          }
        }))
        .pipe(istanbul.writeReports())
        .on('end', cb);
    });
});
<commit_msg>chore(jscs): use reporter<commit_after>'use strict';
import babelCompiler from 'babel';
import gulp from 'gulp';
import eslint from 'gulp-eslint';
import istanbul from 'gulp-istanbul';
import jscs from 'gulp-jscs';
import jshint from 'gulp-jshint';
import mocha from 'gulp-mocha';

const configFiles = './gulpfile.babel.js'
  , srcFiles = 'index.js'
  , testFiles = 'test/*.js';

gulp.task('lint', () => {
  return gulp.src([configFiles, srcFiles, testFiles])
    .pipe(eslint())
    .pipe(eslint.formatEach('./node_modules/eslint-path-formatter'))
    .pipe(eslint.failOnError())
    .pipe(jscs({
      esnext: true
    }))
    .pipe(jscs.reporter())
    .pipe(jshint())
    .pipe(jshint.reporter('default'))
    .pipe(jshint.reporter('fail'));
});

gulp.task('build', ['lint']);

gulp.task('test', ['build'], (cb) => {
  gulp.src(['index.js'])
    .pipe(istanbul())
    .pipe(istanbul.hookRequire())
    .on('finish', () => {
      gulp.src([testFiles])
        .pipe(mocha({
          compilers: {
            js: babelCompiler
          }
        }))
        .pipe(istanbul.writeReports())
        .on('end', cb);
    });
});
<|endoftext|>


<commit_before>var mjml = require('./lib/index')

console.log(mjml.mjml2html(`
<mjml>
  <mj-head>
    <mj-attributes>
      <mj-text padding="0" color="#EEE" font-family="helvetica" />
      <mj-class name="bg-blue" />
    </mj-attributes>
  </mj-head>
  <mj-body>
    <mj-container mj-class="bg-blue">
      <mj-section full-width="full-width">
        <mj-column>
          <mj-text text-decoration="underline" font-size="30px">Underwater</mj-text>
        </mj-column>
      </mj-section>

      <mj-section>
        <mj-column>
          <mj-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sit amet ipsum consequat, viverra libero in, vulputate nulla. Vivamus sit amet sapien non metus viverra ornare ut rutrum ligula. Etiam a odio ac ex pharetra gravida. Aenean sodales purus quis malesuada suscipit. Aenean ac euismod ligula, ac scelerisque nulla. Fusce lacinia libero sed velit sagittis, hendrerit posuere nisl blandit. Quisque mauris justo, mollis id malesuada a, euismod non neque. Sed finibus, leo nec rhoncus ultrices, odio metus imperdiet magna, id pulvinar ex ex ullamcorper ipsum.</mj-text>
        </mj-column>
        <mj-column>
          <mj-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sit amet ipsum consequat, viverra libero in, vulputate nulla. Vivamus sit amet sapien non metus viverra ornare ut rutrum ligula. Etiam a odio ac ex pharetra gravida. Aenean sodales purus quis malesuada suscipit. Aenean ac euismod ligula, ac scelerisque nulla. Fusce lacinia libero sed velit sagittis, hendrerit posuere nisl blandit. Quisque mauris justo, mollis id malesuada a, euismod non neque. Sed finibus, leo nec rhoncus ultrices, odio metus imperdiet magna, id pulvinar ex ex ullamcorper ipsum</mj-text>
        </mj-column>
      </mj-section>

      <mj-section>
      	<mj-column>
        	<mj-button background-color="#0C8094">Discover now</mj-button>
        </mj-column>
      </mj-section>
    </mj-container>
  </mj-body>
</mjml>
`, { beautify: true }))
<commit_msg>tab to spaces<commit_after>var mjml = require('./lib/index')

console.log(mjml.mjml2html(`
<mjml>
  <mj-head>
    <mj-attributes>
      <mj-text padding="0" color="#EEE" font-family="helvetica" />
      <mj-class name="bg-blue" />
    </mj-attributes>
  </mj-head>
  <mj-body>
    <mj-container mj-class="bg-blue">
      <mj-section full-width="full-width">
        <mj-column>
          <mj-text text-decoration="underline" font-size="30px">Underwater</mj-text>
        </mj-column>
      </mj-section>

      <mj-section>
        <mj-column>
          <mj-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sit amet ipsum consequat, viverra libero in, vulputate nulla. Vivamus sit amet sapien non metus viverra ornare ut rutrum ligula. Etiam a odio ac ex pharetra gravida. Aenean sodales purus quis malesuada suscipit. Aenean ac euismod ligula, ac scelerisque nulla. Fusce lacinia libero sed velit sagittis, hendrerit posuere nisl blandit. Quisque mauris justo, mollis id malesuada a, euismod non neque. Sed finibus, leo nec rhoncus ultrices, odio metus imperdiet magna, id pulvinar ex ex ullamcorper ipsum.</mj-text>
        </mj-column>
        <mj-column>
          <mj-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sit amet ipsum consequat, viverra libero in, vulputate nulla. Vivamus sit amet sapien non metus viverra ornare ut rutrum ligula. Etiam a odio ac ex pharetra gravida. Aenean sodales purus quis malesuada suscipit. Aenean ac euismod ligula, ac scelerisque nulla. Fusce lacinia libero sed velit sagittis, hendrerit posuere nisl blandit. Quisque mauris justo, mollis id malesuada a, euismod non neque. Sed finibus, leo nec rhoncus ultrices, odio metus imperdiet magna, id pulvinar ex ex ullamcorper ipsum</mj-text>
        </mj-column>
      </mj-section>

      <mj-section>
        <mj-column>
          <mj-button background-color="#0C8094">Discover now</mj-button>
        </mj-column>
      </mj-section>
    </mj-container>
  </mj-body>
</mjml>
`, { beautify: true }))
<|endoftext|>


<commit_before>/*
 * jQuery Shorten plugin 1.1.0
 *
 * Copyright (c) 2014 Viral Patel
 * http://viralpatel.net
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 */

/*
** updated by Jeff Richardson
** Updated to use strict,
** IE 7 has a "bug" It is returning underfined when trying to reference string characters in this format
** content[i]. IE 7 allows content.charAt(i) This works fine in all modern browsers.
** I've also added brackets where they werent added just for readability (mostly for me).
*/

(function($) {
    $.fn.shorten = function(settings) {
        "use strict";

        var config = {
            showChars: 100,
            ellipsesText: "...",
            moreText: "more",
            lessText: "less",
            errMsg: null,
            force: false
        };

        if (settings) {
            $.extend(config, settings);
        }

        if ($(this).data('jquery.shorten') && !config.force) {
            return false;
        }
        $(this).data('jquery.shorten', true);

        $(document).off("click", '.morelink');

        $(document).on({
            click: function() {

                var $this = $(this);
                if ($this.hasClass('less')) {
                    $this.removeClass('less');
                    $this.html(config.moreText);
                    $this.parent().prev().prev().show(); // shortcontent
                    $this.parent().prev().hide(); // allcontent

                } else {
                    $this.addClass('less');
                    $this.html(config.lessText);
                    $this.parent().prev().prev().hide(); // shortcontent
                    $this.parent().prev().show(); // allcontent
                }
                return false;
            }
        }, '.morelink');

        return this.each(function() {
            var $this = $(this);

            var content = $this.html();
            var contentlen = $this.text().length;
            if (contentlen > config.showChars) {
                var c = content.substr(0, config.showChars);
                if (c.indexOf('<') >= 0) // If there's HTML don't want to cut it
                {
                    var inTag = false; // I'm in a tag?
                    var bag = ''; // Put the characters to be shown here
                    var countChars = 0; // Current bag size
                    var openTags = []; // Stack for opened tags, so I can close them later
                    var tagName = null;

                    for (var i = 0, r = 0; r <= config.showChars; i++) {
                        if (content[i] == '<' && !inTag) {
                            inTag = true;

                            // This could be "tag" or "/tag"
                            tagName = content.substring(i + 1, content.indexOf('>', i));

                            // If its a closing tag
                            if (tagName[0] == '/') {

                                if (tagName != '/' + openTags[0]) {
                                    config.errMsg = 'ERROR en HTML: the top of the stack should be the tag that closes';
                                } else {
                                    openTags.shift(); // Pops the last tag from the open tag stack (the tag is closed in the retult HTML!)
                                }

                            } else {
                                // There are some nasty tags that don't have a close tag like

                                if (tagName.toLowerCase() != 'br') {
                                    openTags.unshift(tagName); // Add to start the name of the tag that opens
                                }
                            }
                        }
                        if (inTag && content[i] == '>') {
                            inTag = false;
                        }

                        if (inTag) { bag += content.charAt(i); } // Add tag name chars to the result
                        else {
                            r++;
                            if (countChars <= config.showChars) {
                                bag += content.charAt(i); // Fix to ie 7 not allowing you to reference string characters using the []
                                countChars++;
                            } else // Now I have the characters needed
                            {
                                if (openTags.length > 0) // I have unclosed tags
                                {
                                    //console.log('They were open tags');
                                    //console.log(openTags);
                                    for (j = 0; j < openTags.length; j++) {
                                        //console.log('Cierro tag ' + openTags[j]);
                                        bag += '</' + openTags[j] + '>'; // Close all tags that were opened

                                        // You could shift the tag from the stack to check if you end with an empty stack, that means you have closed all open tags
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    c = $('
').html(bag + '' + config.ellipsesText + '').html();
                }else{
                    c+=config.ellipsesText;
                }

                var html = '
' + c +
                    '

' + content +
                    '
' + config.moreText + '';

                $this.html(html);
                $this.find(".allcontent").hide(); // Hide all text
                $('.shortcontent p:last', $this).css('margin-bottom', 0); //Remove bottom margin on last paragraph as it's likely shortened
            }
        });

    };

})(jQuery);
<commit_msg>minify jquery.shorten<commit_after>/*
 * jQuery Shorten plugin 1.1.0
 *
 * Copyright (c) 2014 Viral Patel
 * http://viralpatel.net
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 */

/*
** updated by Jeff Richardson
** Updated to use strict,
** IE 7 has a "bug" It is returning underfined when trying to reference string characters in this format
** content[i]. IE 7 allows content.charAt(i) This works fine in all modern browsers.
** I've also added brackets where they werent added just for readability (mostly for me).
*/
(function($){$.fn.shorten=function(settings){"use strict";var config={showChars:100,ellipsesText:"...",moreText:"more",lessText:"less",errMsg:null,force:false};if(settings){$.extend(config,settings);}
if($(this).data('jquery.shorten')&&!config.force){return false;}
$(this).data('jquery.shorten',true);$(document).off("click",'.morelink');$(document).on({click:function(){var $this=$(this);if($this.hasClass('less')){$this.removeClass('less');$this.html(config.moreText);$this.parent().prev().prev().show();$this.parent().prev().hide();}else{$this.addClass('less');$this.html(config.lessText);$this.parent().prev().prev().hide();$this.parent().prev().show();}
return false;}},'.morelink');return this.each(function(){var $this=$(this);var content=$this.html();var contentlen=$this.text().length;if(contentlen>config.showChars){var c=content.substr(0,config.showChars);if(c.indexOf('<')>=0)
{var inTag=false;var bag='';var countChars=0;var openTags=[];var tagName=null;for(var i=0,r=0;r<=config.showChars;i++){if(content[i]=='<'&&!inTag){inTag=true;tagName=content.substring(i+1,content.indexOf('>',i));if(tagName[0]=='/'){if(tagName!='/'+openTags[0]){config.errMsg='ERROR en HTML: the top of the stack should be the tag that closes';}else{openTags.shift();}}else{if(tagName.toLowerCase()!='br'){openTags.unshift(tagName);}}}
if(inTag&&content[i]=='>'){inTag=false;}
if(inTag){bag+=content.charAt(i);}
else{r++;if(countChars<=config.showChars){bag+=content.charAt(i);countChars++;}else
{if(openTags.length>0)
{for(j=0;j<openTags.length;j++){bag+='</'+openTags[j]+'>';}
break;}}}}
c=$('
').html(bag+''+config.ellipsesText+'').html();}else{c+=config.ellipsesText;}
var html='
'+c+'

'+content+'
'+config.moreText+'';$this.html(html);$this.find(".allcontent").hide();$('.shortcontent p:last',$this).css('margin-bottom',0);}});};})(jQuery);<|endoftext|>


<commit_before>import Server from "./index";

const textResource = (content, name = "result") => ({
  name,
  contentType: "text/plain",
  content:
    typeof content !== "undefined" && content !== null
      ? String(content)
      : content
});

const delay = time => new Promise(resolve => setTimeout(resolve, time));

const server = new Server({
  multiply: ({ a, b }) => textResource(a * b),
  divide: ({ a, b }) => delay(60000).then(() => textResource(a / b))
});
server.start();
<commit_msg>webmiddle-server: remove example<commit_after><|endoftext|>


<commit_before>;(function($) {
    var slice = Array.prototype.slice;
	$.defer = function( /*[func] [, delay] [, funcParameters]*/) {
		var args = arguments,
		    isFunc = $.isFunction(args[0]),
		    func = isFunc ? args[0] : $.noop,
		    delay = (isFunc ? args[1] : args[0]) || 0,
		    funcArgs = slice.call(args, 2),
		    isCancelled = false,
		    cancel = function(reject /* = true */) {
			    clearTimeout(timerId);
			    isCancelled = true;
			    if ((!arguments.length || reject) && deferred.state() === "pending") {
				    deferred.rejectWith(null, funcArgs);
			    }
		    },
		    deferred = $.Deferred(),
		    timerId = setTimeout(function() {
			    deferred.notifyWith(promise, funcArgs);
			    if (isCancelled) {
				    return;
			    }
			    try {
				    var result = func.apply(this, funcArgs);
				    deferred.resolveWith(result, funcArgs);
			    } catch(e) {
			    	deferred.rejectWith(e, funcArgs);
			    }
		    }, delay),
		    promise = $.extend(deferred.promise(), {
			    cancel: cancel
		    });
		return promise;
	};
})(jQuery);
<commit_msg>Update jquery.whereas.js<commit_after>;(function($) {
    var slice = Array.prototype.slice;
	$.whereas = function( /*[func] [, delay] [, funcParameters]*/) {
		var args = arguments,
		    isFunc = $.isFunction(args[0]),
		    func = isFunc ? args[0] : $.noop,
		    delay = (isFunc ? args[1] : args[0]) || 0,
		    funcArgs = slice.call(args, 2),
		    isCancelled = false,
		    cancel = function(reject /* = true */) {
			    clearTimeout(timerId);
			    isCancelled = true;
			    if ((!arguments.length || reject) && deferred.state() === "pending") {
				    deferred.rejectWith(null, funcArgs);
			    }
		    },
		    deferred = $.Deferred(),
		    timerId = setTimeout(function() {
			    deferred.notifyWith(promise, funcArgs);
			    if (isCancelled) {
				    return;
			    }
			    try {
				    var result = func.apply(this, funcArgs);
				    deferred.resolveWith(result, funcArgs);
			    } catch(e) {
			    	deferred.rejectWith(e, funcArgs);
			    }
		    }, delay),
		    promise = $.extend(deferred.promise(), {
			    cancel: cancel
		    });
		return promise;
	};
})(jQuery);
<|endoftext|>


<commit_before>jQuery(function($) {

    var PhileoLikes = function(form, options) {
        this.options = $.extend({}, $.fn.phileo.defaults, options);
        this.$form = $(form);

        this.$count = $(this.options.count);

        var self = this;
        this.$form.submit(function(event) {
            event.preventDefault();

            $.ajax({
                url: self.$form.attr('action'),
                type: "POST",
                data: self.$form.serialize(),
                statusCode: {
                    200: function(data, textStatus, jqXHR) {
                        self.$count.text(data.likes_count);
                        self.$form[data.liked ? 'addClass' : 'removeClass'](self.options.toggle_class);
                    }
                }
            });
        });
    };

    $.fn.phileo = function(options) {
        $(this).each(function(i, el) {
            var phileo = new PhileoLikes(el, options);
            $(el).data('Phileo', {instance: phileo});
        });
        return this;
    };

    $.fn.phileo.defaults = {
        toggle_class: 'phileo-liked',
        count: false
    };
});
<commit_msg>Add jQuery plugin on page load, not domready<commit_after>!function($){
    "use strict";

    var PhileoLikes = function(form, options) {
        this.options = $.extend({}, $.fn.phileo.defaults, options);
        this.$form = $(form);

        this.$count = $(this.options.count);

        var self = this;
        this.$form.submit(function(event) {
            event.preventDefault();

            $.ajax({
                url: self.$form.attr('action'),
                type: "POST",
                data: self.$form.serialize(),
                statusCode: {
                    200: function(data, textStatus, jqXHR) {
                        self.$count.text(data.likes_count);
                        self.$form[data.liked ? 'addClass' : 'removeClass'](self.options.toggle_class);
                    }
                }
            });
        });
    };

    $.fn.phileo = function(options) {
        $(this).each(function(i, el) {
            var phileo = new PhileoLikes(el, options);
            $(el).data('Phileo', {instance: phileo});
        });
        return this;
    };

    $.fn.phileo.defaults = {
        toggle_class: 'phileo-liked',
        count: false
    };
}( window.jQuery || window.ender );
<|endoftext|>


<commit_before>import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';

import PropTypes from "prop-types";
import ReactAudioPlayer from 'react-audio-player';
import axios from "axios";

axios.defaults.headers.common['Authorization'] = "Basic YWRtaW46K2RhcmtvcmJpdDk5";

class AvailableDatalist extends React.Component {
   AvailableDatalist(props) {
    return(

{props.all_songs.map(c =>

c.name

c.album

 )}

    )
  }
  render() {
    return(
{this.props.songs['name']}
)
  }
}
AvailableDatalist.propTypes = {
  songs: PropTypes.array.isRequired
};

class SongBoard extends React.Component {

state = {
  songs: []
};

componentDidMount() {
  axios
  .get("http://192.168.1.107:8000/song/")
  .then(response => {
    const songs = response.data.map(c => {
      return{
        name: c.name,
        album: c.album
      };

    });

    const newState = Object.assign({}, this.state, {
          songs: songs
        });

    this.setState(newState);
    console.log(this.state)

  })
  .catch(error => console.log(error));
}

  render() {

    return(

            <button className="song">
              Song
            </button>
            <button className="album">
              Album
            </button>

          <AvailableDatalist songs={this.state.songs}/> {/*songs={this.state.contacts}*/}

    )
  }
}

class Player extends React.Component {
  render() {
    return(
      <ReactAudioPlayer
        src="my_audio_file.ogg"
        autoPlay
        controls
      />
    )
  }
}

class Site extends React.Component {
  render() {
    return (

          <Player />

          <SongBoard />

    )
  }
}

ReactDOM.render(
  <Site />,
  document.getElementById('root')
);
<commit_msg>songs<commit_after>import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';

import PropTypes from "prop-types";
import ReactAudioPlayer from 'react-audio-player';
import axios from "axios";

axios.defaults.headers.common['Authorization'] = "Basic YWRtaW46K2RhcmtvcmJpdDk5";

class AvailableDatalist extends React.Component {
   AvailableDatalist(props) {
    return(

{props.all_songs.map(c =>

c.name

c.album

 )}

    )
  }
  render() {
    return(
{this.props.songs[0]['name']}
)
  }
}
AvailableDatalist.propTypes = {
  songs: PropTypes.array.isRequired
};

class SongBoard extends React.Component {

state = {
  songs: []
};

componentDidMount() {
  axios
  .get("http://192.168.1.107:8000/song/")
  .then(response => {
    const songs = response.data.map(c => {
      return{
        name: c.name,
        album: c.album
      };

    });

    const newState = Object.assign({}, this.state, {
          songs: songs
        });

    this.setState(newState);
    console.log(this.state)

  })
  .catch(error => console.log(error));
}

  render() {

    return(

            <button className="song">
              Song
            </button>
            <button className="album">
              Album
            </button>

          <AvailableDatalist songs={this.state.songs}/> {/*songs={this.state.contacts}*/}

    )
  }
}

class Player extends React.Component {
  render() {
    return(
      <ReactAudioPlayer
        src="my_audio_file.ogg"
        autoPlay
        controls
      />
    )
  }
}

class Site extends React.Component {
  render() {
    return (

          <Player />

          <SongBoard />

    )
  }
}

ReactDOM.render(
  <Site />,
  document.getElementById('root')
);
<|endoftext|>


<commit_before>/*!
 * !layout v2.0.0 (https://github.com/johnlucita/Lucita)
 * Copyright 2015-2016 Lucita, Private.
 * Licensed under MIT (https://github.com/johnlucita/Lucita/blob/master/LICENSE)
 */

eval(function (p, a, c, k, e, d) { e = function (c) { return (c < a ? "" : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) d[e(c)] = k[c] || e(c); k = [function (e) { return d[e] }]; e = function () { return '\\w+' }; c = 1; }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p; }('$(2a).2j(9(){7 3$12=$(\'1i[U-E]\');8(3$12.b){$.q(3$12,9(i,r){7 3$r=$(r);7 m=1I.2l($(r).c(\'U-E\'));8(2g(m)){3$r.A(\'16\');8(m[\'6-l\']&&!2h(m[\'6-l\'])){3$r.c(\'6-l\',m[\'6-l\'])};3$r.c(\'6-d\',m[\'6-d\']);3$r.c(\'6-d-z\',m[\'6-d-z\']);3$r.M(\'U-E\')}})};6.1R()});$.2i.Z({s:9(a){7 j=P;7 3$4=$(4);8(3$4.b){j=\'2p\'===2q(3$4.c(a))?P:2r};y j},1N:9(){7 3$4=$(4);8(3$4.b){7 T=6.1J();8(3$4.s(\'g-v\')){T=3$4.c(\'g-v\')||T};3$4.h(\'g-v\',T)}},1M:9(){7 3$4=$(4);8(3$4.b){7 S=6.1F();8(3$4.s(\'g-n\')){S=3$4.c(\'g-n\')||S};3$4.h(\'g-n\',S)}},1t:9(){7 3$4=$(4);8(3$4.b){7 O=6.1K();8(3$4.s(\'B-n\')){O=3$4.c(\'B-n\')||O};3$4.h(\'B-n\',O)}},1A:9(){7 3$4=$(4);8(3$4.b){3$4.h(\'g-v\',3$4.c(\'6-g-v\')||\'2f\')}},1B:9(){7 3$4=$(4);8(3$4.b){3$4.h(\'g-n\',3$4.c(\'6-g-n\')||\'26\')}},1o:9(){7 3$4=$(4);7 m={\'6-d\':\'13\',\'6-d-z\':\'%\'};8(3$4.b){7 3$N=3$4.1X();8(3$4.s(\'6-l\')){$.Z(m,{\'6-l\':3$4.c(\'6-l\')});7 3$l=3$4.27(3$4.c(\'6-l\'));8(3$l.b){3$N=3$l};3$4.M(\'6-l\')};8(3$N.b){7 V=3$N.d();7 u=3$4.c(\'6-d\')||\'13\';7 G=3$4.c(\'6-d-z\')||\'%\';$.Z(m,{\'6-d\':u,\'6-d-z\':G});8(\'%\'==G){u=1j(V*u/13);G=\'X\'};8(u>V){u=V};3$4.1h(u+G).c(\'U-E\',1I.29(m)).F(\'16\').M(\'6-d\').M(\'6-d-z\')}}},2s:9(){7 3$4=$(4);8(3$4.b){3$4.A(\'1E\')}},2P:9(){7 3$4=$(4);8(3$4.b){3$4.F(\'1E\')}},1v:9(){7 3$4=$(4);8(3$4.b){3$4.h(\'E-p\',3$4.c(\'6-p\')||\'1G\');8(\'15\'==3$4.c(\'6-p\')){3$4.h(\'E-15\',3$4.c(\'6-15\')||\'2H\')}}},1x:9(){7 3$4=$(4);8(3$4.b){3$4.h(\'2I-p\',3$4.c(\'6-p\')||\'2O\')}}});7 6={1R:9(){6.1Q();6.1L();6.1r();6.1p();6.1u();6.1y();6.1w();6.22();6.21();6.1T();y P},1Q:9(){$(\'a\').D(\'1O\',9(){$(4).1P()})},1L:9(){7 3$1a=$(\'f.6 .2G\');8(3$1a.b){$.q(3$1a,9(i,6){$(6).1N();$(6).1M()})}},1r:9(){7 3$17=$(\'f.6 .2u\');8(3$17.b){$.q(3$17,9(i,6){$(6).1t()})}},1p:9(){7 3$1c=$(\'.16\');8(3$1c.b){$.q(3$1c,9(i,6){$(6).1o()})}},1u:9(){7 3$18=$(\'.2A\');8(3$18.b){$.q(3$18,9(i,6){8($(6).s(\'6-g-v\')){$(6).1A()};8($(6).s(\'6-g-n\')){$(6).1B()}})}},1y:9(){7 3$19=$(\'.2y\');8(3$19.b){$.q(3$19,9(i,p){$(p).1v()})}},1w:9(){7 3$14=$(\'.2b\');8(3$14.b){$.q(3$14,9(i,p){$(p).1x()})}},22:9(){7 3$1d=$(\'.25\');8(3$1d.b&&!2J(\'B-2K\',\'2t\')){$.q(3$1d,9(i,C){7 k=$(C).h(\'2E\');7 L=\'\';8(k){k=k.1e(5,k.b-2);L=k;8($(C).R(\'2B\')){L=k.1e(0,k.1V(\'/\'))+\'/2F/\'+k.1e(k.1V(\'/\')+1)};7 1W=$(C).d();7 1S=$(C).1U();7 3$x=$(\'<2z 2v="" 1b="\'+k+\'?\'+10.Y()+\'" d="\'+1W+\'" 1U="\'+1S+\'" />\').h(\'g\',\'0\');3$x.D(\'2w\',9(){$(4).c(\'1b\',L+\'?\'+10.Y())});3$x.D(\'2M\',9(){$(4).c(\'1b\',k+\'?\'+10.Y())});$(C).h(\'B\',\'\').x(3$x)}})}},21:9(){7 3$Q=$(\'.2C .1n > 1l\');8(!3$Q.b){y P};3$Q.D(\'20\',9(e){7 3$4=$(4);7 11=3$4.c(\'2e-2d\')||\'\';7 1Y=3$4.24();3$Q.F(\'t\');3$4.A(\'t\');7 3$J=$(\'.2o > *\');8(3$J.b){3$J.F(\'t\');8(11!==\'\'){3$J.1X().1f(\'#\'+11).A(\'t\')}1C{3$J.1Z(1Y).A(\'t\')}}});8(!$(\'.1n 1l.t\').b){$(\'.1n 1l.t\').1Z(0).20()}},1T:9(){7 3$K=$(\'.2L\');8(3$K.b){$.q(3$K,9(i,K){7 3$o=$(4).1f(\'2N\');7 3$W=$(4).1f(\'a\');8(3$o.b&&3$W.b){7 H=1j(3$W.d());7 I=1j(3$o.d());8(2m()){7 3$w=$(\'<1i 1z="w"></1i>\').1h(I+H+2x+\'X\');3$w.1k(\'<1s 1z="1q 1q-2D"></1s>\').1k(3$o).1k(3$W);8(3$o.s(\'1g\')){3$o.D(\'1O\',9(){3$w.A(\'1g\')});3$o.D(\'1P\',9(){3$w.F(\'1g\')})};$(4).x(3$w)}1C{8(I<=H+1D){I=H+1D;3$o.1h(I+\'X\')};3$o.h(\'1H-1G\',\'2c\');3$o.h(\'1H-23\',(H+5)+\'X\')}}})}},1J:9(){7 j=\'\';7 3$f=$(\'f.6\');8(3$f.b){8(3$f.R(\'1m\')){j=3$f.c(\'6-g-v\')||\'28\'}};y j},1F:9(){7 j=\'\';7 3$f=$(\'f.6\');8(3$f.b){8(3$f.R(\'1m\')){j=3$f.c(\'6-g-n\')||\'2n\'}};y j},1K:9(){7 j=\'\';7 3$f=$(\'f.6\');8(3$f.b){8(3$f.R(\'1m\')){j=3$f.c(\'6-B-n\')||\'#2k\'}};y j}};', 62, 176, '|||_|this||layout|var|if|function||length|attr|width||body|border|css||_result|_bkurl|owner|_descriptive_text|color|searchTxt|align|each|obj|hasAttr|layout_active|_width|style|searchIE|html|return|unit|addClass|background|pattern|on|text|removeClass|_unit|_btnWidth|_txtWidth|tabcontents|searchbox|_bkhurl|removeAttr|space|_backgroundcolor|false|navtabs|hasClass|_bordercolor|_borderstyle|descriptive|_space|searchBtn|px|random|extend|Math|_targetId|objs|100|verticalaligns|justify|layout_width|layout_backgroud_objs|layout_divider_objs|textaligns|layout_border_objs|src|layout_width_objs|patterns|substring|find|altfocus|outerWidth|div|parseInt|append|li|layout_display|layout_nav_tabs|setWidth|initLayoutWidth|fa|initLayoutBackground|span|setBackgroundColor|initLayoutDivider|setTextAlign|initLayoutVerticalAlign|setVerticalAlign|initLayoutTextAlign|class|setDividerStyle|setDividerColor|else|60|layout_hidden|getBorderColorDefault|left|padding|JSON|getBorderStyleDefault|getBackgroundColorDefault|initLayoutBorder|setBorderColor|setBorderStyle|focus|blur|initLinkNotFocus|initialization|_imgH|initLayoutSearchbox|height|lastIndexOf|_imgW|parent|_index|eq|click|initLayoutTabs|initLayoutPattern|right|index|layout_pattern|black|closest|dashed|stringify|window|layout_verticalalign|25px|target|data|solid|isJson|isEmpty|fn|resize|afafaf|parse|isIE|crimson|layout_content|undefined|typeof|true|setHide|contain|layout_backgroundcolor|alt|onmouseover|40|layout_textalign|img|layout_divider|layout_pattern_hover|layout_tabs|search|backgroundImage|hover|layout_border|auto|vertical|supportCSS3|size|layout_searchbox|onmouseout|input|baseline|setShow'.split('|'), 0, {}))
<commit_msg>Update !layout.min.js<commit_after>/*!
 * !layout v2.0.0 (https://github.com/johnlucita/Lucita)
 * Copyright 2015-2016 Lucita, Private.
 * Licensed under MIT (https://github.com/johnlucita/Lucita/blob/master/LICENSE)
 */

eval(function (p, a, c, k, e, d) { e = function (c) { return (c < a ? "" : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) d[e(c)] = k[c] || e(c); k = [function (e) { return d[e] }]; e = function () { return '\\w+' }; c = 1; }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p; }('$(2r).2o(9(){7 3$1e=$(\'1n[V-B]\');8(3$1e.b){$.p(3$1e,9(i,s){7 3$s=$(s);7 m=2e.2u($(s).c(\'V-B\'));8(2w(m)){3$s.C(\'1t\');8(m[\'6-j\']&&!2s(m[\'6-j\'])){3$s.c(\'6-j\',m[\'6-j\'])};3$s.c(\'6-d\',m[\'6-d\']);3$s.c(\'6-d-G\',m[\'6-d-G\']);3$s.Q(\'V-B\')}})};6.1S()});$.2t.1w({q:9(a){7 l=I;7 3$4=$(4);8(3$4.b){l=\'2i\'===2g(3$4.c(a))?I:19};A l},1K:9(){7 3$4=$(4);8(3$4.b){7 X=6.28();8(3$4.q(\'g-z\')){X=3$4.c(\'g-z\')||X};3$4.h(\'g-z\',X)}},1z:9(){7 3$4=$(4);8(3$4.b){7 Y=6.26();8(3$4.q(\'g-n\')){Y=3$4.c(\'g-n\')||Y};3$4.h(\'g-n\',Y)}},1H:9(){7 3$4=$(4);8(3$4.b){7 Z=6.29();8(3$4.q(\'D-n\')){Z=3$4.c(\'D-n\')||Z};3$4.h(\'D-n\',Z)}},1A:9(){7 3$4=$(4);8(3$4.b){3$4.h(\'g-z\',3$4.c(\'6-g-z\')||\'2h\')}},1R:9(){7 3$4=$(4);8(3$4.b){3$4.h(\'g-n\',3$4.c(\'6-g-n\')||\'2f\')}},1D:9(){7 3$4=$(4);7 m={\'6-d\':\'1b\',\'6-d-G\':\'%\'};8(3$4.b){7 3$S=3$4.2c();8(3$4.q(\'6-j\')){$.1w(m,{\'6-j\':3$4.c(\'6-j\')});7 3$j=3$4.2j(3$4.c(\'6-j\'));8(3$j.b){3$S=3$j};3$4.Q(\'6-j\')};8(3$S.b){7 U=3$S.d();7 u=3$4.c(\'6-d\')||\'1b\';7 M=3$4.c(\'6-d-G\')||\'%\';$.1w(m,{\'6-d\':u,\'6-d-G\':M});8(\'%\'==M){u=1a(U*u/1b);M=\'14\';8(u>U){u=U}};3$4.1s(u+M).c(\'V-B\',2e.2k(m)).K(\'1t\').Q(\'6-d\').Q(\'6-d-G\')}}},2n:9(){7 3$4=$(4);8(3$4.b){3$4.C(\'1C\')}},2p:9(){7 3$4=$(4);8(3$4.b){3$4.K(\'1C\')}},1Q:9(){7 3$4=$(4);8(3$4.b){3$4.h(\'B-r\',3$4.c(\'6-r\')||\'1W\');8(\'1i\'==3$4.c(\'6-r\')){3$4.h(\'B-1i\',3$4.c(\'6-1i\')||\'2l\')}}},1L:9(){7 3$4=$(4);8(3$4.b){3$4.h(\'2m-r\',3$4.c(\'6-r\')||\'2q\')}}});7 6={1S:9(){6.1J();6.1I();6.2b();6.1P();6.1y();6.1N();6.1O();6.1M();6.25();6.22();6.2a();A I},1J:9(){$(\'a\').t(\'1X\',9(){$(4).23()})},1I:9(){7 3$1x=$(\'f.6 .2v\');8(3$1x.b){$.p(3$1x,9(i,6){$(6).1K();$(6).1z()})}},2b:9(){7 3$1g=$(\'f.6 .2V\');8(3$1g.b){$.p(3$1g,9(i,6){$(6).1H()})}},1P:9(){7 3$1r=$(\'.1t\');8(3$1r.b){$.p(3$1r,9(i,6){$(6).1D()})}},1y:9(){7 3$1p=$(\'.2Y\');8(3$1p.b){$.p(3$1p,9(i,6){8($(6).q(\'6-g-z\')){$(6).1A()};8($(6).q(\'6-g-n\')){$(6).1R()}})}},1N:9(){7 3$1v=$(\'.2X\');8(3$1v.b){$.p(3$1v,9(i,r){$(r).1Q()})}},1O:9(){7 3$18=$(\'.2Z\');8(3$18.b){$.p(3$18,9(i,r){$(r).1L()})}},1M:9(){7 3$17=$(\'.31\');8(3$17.b&&!30(\'D-2W\',\'2S\')){$.p(3$17,9(i,E){7 k=$(E).h(\'2R\');7 P=\'\';8(k){k=k.1k(5,k.b-2);P=k;8($(E).12(\'2T\')){P=k.1k(0,k.1B(\'/\'))+\'/2U/\'+k.1k(k.1B(\'/\')+1)};7 1G=$(E).d();7 1E=$(E).1F();7 3$H=$(\'<37 36="" 1h="\'+k+\'?\'+1f.1d()+\'" d="\'+1G+\'" 1F="\'+1E+\'" />\').h(\'g\',\'0\');3$H.t(\'32\',9(){$(4).c(\'1h\',P+\'?\'+1f.1d())});3$H.t(\'34\',9(){$(4).c(\'1h\',k+\'?\'+1f.1d())});$(E).h(\'D\',\'\').H(3$H)}})}},25:9(){7 3$R=$(\'.33 .15 > 16\');8(!3$R.b){A I};3$R.t(\'N\',9(e){7 3$4=$(4);7 1j=3$4.c(\'x-35\')||\'\';7 1Y=3$4.38();3$R.K(\'y\');3$4.C(\'y\');7 3$O=$(\'.2D > *\');8(3$O.b){3$O.K(\'y\');8(1j!==\'\'){3$O.2c().1c(\'#\'+1j).C(\'y\')}10{3$O.1U(1Y).C(\'y\')}}});8(!$(\'.15 16.y\').b){$(\'.15 16.y\').1U(0).N()}},22:9(){7 3$W=$(\'.2C\');8(3$W.b){$.p(3$W,9(i,W){7 3$o=$(4).1c(\'2E\');7 3$T=$(4).1c(\'a\');8(3$o.b&&3$T.b){7 L=1a(3$T.d());7 J=1a(3$o.d());8(2G()){7 3$F=$(\'<1n 24="F"></1n>\').1s(J+L+2F+\'14\');3$F.1u(\'<21 24="1Z 1Z-2y"></21>\').1u(3$o).1u(3$T);8(3$o.q(\'1o\')){3$o.t(\'1X\',9(){3$F.C(\'1o\')});3$o.t(\'23\',9(){3$F.K(\'1o\')})};$(4).H(3$F)}10{8(J<=L+27){J=L+27;3$o.1s(J+\'14\')};3$o.h(\'2d-1W\',\'2x\');3$o.h(\'2d-2z\',(L+5)+\'14\')}}})}},2a:9(){7 3$1q=$(\'.2B\');8(3$1q.b){$.p(3$1q,9(i,v){7 3$v=$(v);8(3$v.q(\'x-1V\')){7 3$w=$(\'#\'+3$v.c(\'x-1V\'));8(3$w.b){7 1T=9(){3$w.c(\'x-11\',\'19\');3$v.2A()},1m=9(){3$w.c(\'x-11\',\'I\');3$v.2N()};3$w.2M(\'N\').t(\'N\',9(e){7 13=2O(e);8(13.20){13.20()}10{13.2Q=19};8(3$w.q(\'x-11\')&&3$w.c(\'x-11\').2P()==\'2I\'){1m()}10{1T()};A I});$(2H).t(\'N\',9(){1m()})}}})}},28:9(){7 l=\'\';7 3$f=$(\'f.6\');8(3$f.b){8(3$f.12(\'1l\')){l=3$f.c(\'6-g-z\')||\'2J\'}};A l},26:9(){7 l=\'\';7 3$f=$(\'f.6\');8(3$f.b){8(3$f.12(\'1l\')){l=3$f.c(\'6-g-n\')||\'2L\'}};A l},29:9(){7 l=\'\';7 3$f=$(\'f.6\');8(3$f.b){8(3$f.12(\'1l\')){l=3$f.c(\'6-D-n\')||\'#2K\'}};A l}};', 62, 195, '|||_|this||layout|var|if|function||length|attr|width||body|border|css||owner|_bkurl|_result|_descriptive_text|color|searchTxt|each|hasAttr|align|obj|on|_width|dropdownmenu|trigger|data|layout_active|style|return|text|addClass|background|pattern|searchIE|unit|html|false|_txtWidth|removeClass|_btnWidth|_unit|click|tabcontents|_bkhurl|removeAttr|navtabs|space|searchBtn|_space|descriptive|searchbox|_borderstyle|_bordercolor|_backgroundcolor|else|expanded|hasClass|_e|px|layout_nav_tabs|li|patterns|verticalaligns|true|parseInt|100|find|random|objs|Math|layout_backgroud_objs|src|justify|_targetId|substring|layout_display|_contraction|div|altfocus|layout_divider_objs|dropdownmenus|layout_width_objs|outerWidth|layout_width|append|textaligns|extend|layout_border_objs|initLayoutDivider|setBorderColor|setDividerStyle|lastIndexOf|layout_hidden|setWidth|_imgH|height|_imgW|setBackgroundColor|initLayoutBorder|initLinkNotFocus|setBorderStyle|setVerticalAlign|initLayoutPattern|initLayoutTextAlign|initLayoutVerticalAlign|initLayoutWidth|setTextAlign|setDividerColor|initialization|_expansion|eq|labelledby|left|focus|_index|fa|stopPropagation|span|initLayoutSearchbox|blur|class|initLayoutTabs|getBorderColorDefault|60|getBorderStyleDefault|getBackgroundColorDefault|initDropdownMenu|initLayoutBackground|parent|padding|JSON|black|typeof|solid|undefined|closest|stringify|auto|vertical|setHide|resize|setShow|baseline|window|isEmpty|fn|parse|layout_border|isJson|25px|search|right|show|layout_dropdown_menu|layout_searchbox|layout_content|input|40|isIE|document|TRUE|dashed|afafaf|crimson|unbind|hide|getEvent|toUpperCase|cancelBubble|backgroundImage|contain|layout_pattern_hover|hover|layout_backgroundcolor|size|layout_textalign|layout_divider|layout_verticalalign|supportCSS3|layout_pattern|onmouseover|layout_tabs|onmouseout|target|alt|img|index'.split('|'), 0, {}))
<|endoftext|>


<commit_before>(function($) {
	"use strict";

	/**
	 * This namespace provides the models and collections for working with BC web applications and their items.
	 *
	 * @namespace BCAPI.Models.WebApp
	 * @memberOf BCAPI.Models
	 */
	BCAPI.Models.WebApp = {};

    /**
     * This class provides the model for interacting with web apps.
     *
     * ## Load webapps list
     *
     * ```javascript
     * var apps = new BCAPI.Models.WebApp.AppCollection();
     * apps.fetch({
     *		success: function(webAppItems) {
	 * 			// handle success
	 * 		},
	 * 		error: function(webAppItems, xhr) {
	 * 			// handle errors
	 * 		}
	 * });
     *
     * apps.each(function(webApp) {
	 * 		// display logic
	 * });
     * ```
     *
     * ## Create webapp
     *
     * ```javascript
     * var app = new BCAPI.Models.WebApp.App({
	 * 		"name": "Test app"
	 * });
     *
     * var response = app.save({
	 * 		success: function(webAppItem) {
	 * 			// handle success
	 * 		},
	 * 		error: function(webAppItem, xhr) {
	 * 			// handle errors
	 * 		}
	 * });
     * ```
     *
     * If you want to refresh collections which rely on Item model please refresh those collections.
     *
     * ## Remove app
     *
     * ```javascript
     * var app = new BCAPI.Models.WebApp.Item({name: "Test app"});
     * item.destroy({
	 * 	success: function(webAppItem, response) {
	 * 		// handle success here.
	 *  },
	 *  error: function(webAppItem, xhr, options) {
	 * 		// handle error scenario.
	 *  }
	 * });
     * ```
     *
     * ## Supported attributes
     *
     * var app = new BCAPI.Models.WebApp.Item({
	 *	templateId: -1,
     *  uploadFolder: "images",
     *  requiresApproval: true,
     *  allowFileUpload: true,
     *  customerCanAdd: false,
     *  customerCanDelete: false,
     *  customerCanEdit: false,
     *  anyoneCanEdit: false,
     *  requiresPayment: false,
     *  validDays: -1, // never expire
     *  roleId: 0,
     *  hasAddress: false,
     *  disableDetailPages: false,
     *  locationEnabled: false
     * });
     *
     * @class
     */
	BCAPI.Models.WebApp.App = BCAPI.Models.Model.extend({
        idAttribute: 'name',

        /**
         * Set tot true if you want to save or delete an existing item before fetching it
         *
         * @type {boolean}
         * @memberOf WebApp
         */
        isNotNew: null,

        isNew: function() {
            return this.isNotNew ? false : !this.get('id');
        },

        endpoint: function() {
            return '/api/v2/admin/sites/current/webapps';
        },

        fetch: function() {
            this.isNotNew = true;
            return Backbone.Model.prototype.fetch.apply(this, arguments);
        },

        destroy: function() {
            this.isNotNew = true;
            return Backbone.Model.prototype.destroy.apply(this, arguments);
        }
    });

    /**
     * This class provides a collection that can be used to list all webapps from a site. For
     * more information about a webapp see {@link BCAPI.Models.WebApp.App}.
     *
     * @name AppCollection
     * @class
     * @constructor
     * @memberOf BCAPI.Models.WebApp
     * @example
     * // fetch all available webapps with custom fields structure in place.
     * var appCollection = new BCAPI.Models.WebApp.AppCollection();
     *
     * appCollection.fetch({fetchFields: true,
     *  success: function(webapps) {
     *  	webapps.each(function(webapp) {
     *  		// here you also have access to webapp.fields.
     *  	});
     *  },
     *  error: function(webapps, response) {
     *  	// this handler might be invoked multiple times if fetchFields options is given and mutiple
     *  	// requests are failing. You can find in the error message the relation for which fetching failed.
     *  }
     * });
     *
     * @example
     * // fetch all available webapps without custom fields structure in place.
     * var appCollection = new BCAPI.Models.WebApp.AppCollection();
     *
     * appCollection.fetch({fetchFields: false,
     *  success: function(webapps) {
     *  	webapps.each(function(webapp) {
     *  		// here webapp.fields is an empty array.
     *  	});
     *  }
     */
    BCAPI.Models.WebApp.AppCollection = BCAPI.Models.Collection.extend({
        model: BCAPI.Models.WebApp.App,
        fetch: function(options) {
        	options = options || {};

       		var eagerFetch = options.fetchFields;

        	function itemsBuilder(webapp) {
        		return new BCAPI.Models.WebApp.CustomFieldCollection(webapp.get("name"));
        	}

        	return this._fetchRelation("fields", itemsBuilder, eagerFetch, options);
        },
    	/**
    	 * We override this method in order to transform each returned item into a strong typed
    	 * {@link BCAPI.Models.WebApp.App} models.
    	 *
    	 * @method
    	 * @instance
    	 * @param {Object} response The JSON response received from Web apps api.
    	 * @returns A list of web app items.
    	 * @memberOf BCAPI.Models.WebApp.AppCollection
         */
        parse: function(response) {
        	var webapps = [],
        		self = this;

        	response = BCAPI.Models.Collection.prototype.parse.call(this, response);

        	_.each(response, function(webapp) {
        		webapps.push(self.model(webapp));
        	});

        	return webapps;
        }
    });
})(jQuery);<commit_msg>I fixed a typo.<commit_after>(function($) {
	"use strict";

	/**
	 * This namespace provides the models and collections for working with BC web applications and their items.
	 *
	 * @namespace BCAPI.Models.WebApp
	 * @memberOf BCAPI.Models
	 */
	BCAPI.Models.WebApp = {};

    /**
     * This class provides the model for interacting with web apps.
     *
     * ## Load webapps list
     *
     * ```javascript
     * var apps = new BCAPI.Models.WebApp.AppCollection();
     * apps.fetch({
     *		success: function(webAppItems) {
	 * 			// handle success
	 * 		},
	 * 		error: function(webAppItems, xhr) {
	 * 			// handle errors
	 * 		}
	 * });
     *
     * apps.each(function(webApp) {
	 * 		// display logic
	 * });
     * ```
     *
     * ## Create webapp
     *
     * ```javascript
     * var app = new BCAPI.Models.WebApp.App({
	 * 		"name": "Test app"
	 * });
     *
     * var response = app.save({
	 * 		success: function(webAppItem) {
	 * 			// handle success
	 * 		},
	 * 		error: function(webAppItem, xhr) {
	 * 			// handle errors
	 * 		}
	 * });
     * ```
     *
     * If you want to refresh collections which rely on Item model please refresh those collections.
     *
     * ## Remove app
     *
     * ```javascript
     * var app = new BCAPI.Models.WebApp.Item({name: "Test app"});
     * item.destroy({
	 * 	success: function(webAppItem, response) {
	 * 		// handle success here.
	 *  },
	 *  error: function(webAppItem, xhr, options) {
	 * 		// handle error scenario.
	 *  }
	 * });
     * ```
     *
     * ## Supported attributes
     *
     * var app = new BCAPI.Models.WebApp.Item({
	 *	templateId: -1,
     *  uploadFolder: "images",
     *  requiresApproval: true,
     *  allowFileUpload: true,
     *  customerCanAdd: false,
     *  customerCanDelete: false,
     *  customerCanEdit: false,
     *  anyoneCanEdit: false,
     *  requiresPayment: false,
     *  validDays: -1, // never expire
     *  roleId: 0,
     *  hasAddress: false,
     *  disableDetailPages: false,
     *  locationEnabled: false
     * });
     *
     * @class
     */
	BCAPI.Models.WebApp.App = BCAPI.Models.Model.extend({
        idAttribute: 'name',

        /**
         * Set tot true if you want to save or delete an existing item before fetching it
         *
         * @type {boolean}
         * @memberOf WebApp
         */
        isNotNew: null,

        isNew: function() {
            return this.isNotNew ? false : !this.get('id');
        },

        endpoint: function() {
            return '/api/v2/admin/sites/current/webapps';
        },

        fetch: function() {
            this.isNotNew = true;
            return Backbone.Model.prototype.fetch.apply(this, arguments);
        },

        destroy: function() {
            this.isNotNew = true;
            return Backbone.Model.prototype.destroy.apply(this, arguments);
        }
    });

    /**
     * This class provides a collection that can be used to list all webapps from a site. For
     * more information about a webapp see {@link BCAPI.Models.WebApp.App}.
     *
     * @name AppCollection
     * @class
     * @constructor
     * @memberOf BCAPI.Models.WebApp
     * @example
     * // fetch all available webapps with custom fields structure in place.
     * var appCollection = new BCAPI.Models.WebApp.AppCollection();
     *
     * appCollection.fetch({fetchFields: true,
     *  success: function(webapps) {
     *  	webapps.each(function(webapp) {
     *  		// here you also have access to webapp.fields.
     *  	});
     *  },
     *  error: function(webapps, response) {
     *  	// this handler might be invoked multiple times if fetchFields option is given and mutiple
     *  	// requests are failing. You can find in the error message the relation for which fetching failed.
     *  }
     * });
     *
     * @example
     * // fetch all available webapps without custom fields structure in place.
     * var appCollection = new BCAPI.Models.WebApp.AppCollection();
     *
     * appCollection.fetch({fetchFields: false,
     *  success: function(webapps) {
     *  	webapps.each(function(webapp) {
     *  		// here webapp.fields is an empty array.
     *  	});
     *  }
     */
    BCAPI.Models.WebApp.AppCollection = BCAPI.Models.Collection.extend({
        model: BCAPI.Models.WebApp.App,
        fetch: function(options) {
        	options = options || {};

       		var eagerFetch = options.fetchFields;

        	function itemsBuilder(webapp) {
        		return new BCAPI.Models.WebApp.CustomFieldCollection(webapp.get("name"));
        	}

        	return this._fetchRelation("fields", itemsBuilder, eagerFetch, options);
        },
    	/**
    	 * We override this method in order to transform each returned item into a strong typed
    	 * {@link BCAPI.Models.WebApp.App} models.
    	 *
    	 * @method
    	 * @instance
    	 * @param {Object} response The JSON response received from Web apps api.
    	 * @returns A list of web app items.
    	 * @memberOf BCAPI.Models.WebApp.AppCollection
         */
        parse: function(response) {
        	var webapps = [],
        		self = this;

        	response = BCAPI.Models.Collection.prototype.parse.call(this, response);

        	_.each(response, function(webapp) {
        		webapps.push(self.model(webapp));
        	});

        	return webapps;
        }
    });
})(jQuery);<|endoftext|>