<commit_before>var React = require('react');
var ReactDom = require('react-dom');
var d3 = require('d3');

var Line = React.createClass({
    componentDidMount: function () {
        var el = ReactDom.findDOMNode(this);
        var svg = d3.select(el)
            .append('svg')
                .attr('class', 'd3')
                .attr("width", this.props.width)
                .attr("height", 30)
            .append('line')
                .attr("x1", 0)
                .attr("y1", 10)
                .attr("x2", 200)
                .attr("y2", 10)
                .attr("stroke-width", 2)
                .attr("stroke", this.props.color);
    },
    render: function () {
        return ;
    }
});

var Bar = React.createClass({
    componentDidMount: function () {
        var el = ReactDom.findDOMNode(this);
        var svg = d3.select(el)
            .append('svg')
                .attr('class', 'd3')
            .append('rect')
                .attr('width', 50)
                .attr('height', 200)
                .style('fill', 'blue');
    },
    render: function () {
        return

;
    }
});

var HelloWorld = React.createClass({
    render: function () {
        return

<Bar />

                <Line color="#ccffcc" width="150px" />
                <Line color="#009933" width="90px" />
                <Line color="#f0f5f5" width="50px" />

;
    }
});

ReactDom.render(
    <HelloWorld />,
    document.getElementById('app')
);<commit_msg>mouseover sample<commit_after>var React = require('react');
var ReactDom = require('react-dom');
var d3 = require('d3');

var Line = React.createClass({
    componentDidMount: function () {
        var el = ReactDom.findDOMNode(this);
        var svg = d3.select(el)
            .append('svg')
                .attr('class', 'd3')
                .attr("width", this.props.width)
                .attr("height", 30)
            .append('line')
                .attr("x1", 0)
                .attr("y1", 10)
                .attr("x2", 200)
                .attr("y2", 10)
                .attr("stroke-width", 2)
                .attr("stroke", this.props.color)
            .on("mouseover", () => {
                console.log("mouse over...");
            })
    },
    render: function () {
        return ;
    }
});

var Bar = React.createClass({
    componentDidMount: function () {
        var el = ReactDom.findDOMNode(this);
        var svg = d3.select(el)
            .append('svg')
                .attr('class', 'd3')
            .append('rect')
                .attr('width', 50)
                .attr('height', 200)
                .style('fill', 'blue');
    },
    render: function () {
        return

;
    }
});

var HelloWorld = React.createClass({
    render: function () {
        return

<Bar />

                <Line color="#ccffcc" width="150px" />
                <Line color="#009933" width="90px" />
                <Line color="#f0f5f5" width="50px" />

;
    }
});

ReactDom.render(
    <HelloWorld />,
    document.getElementById('app')
);<|endoftext|>


<commit_before>const { promisify } = require('util');
const pMap = require('p-map');
const writeFile = promisify(require('fs').writeFile);
const Path = require('path');
const mkdirpAsync = promisify(require('mkdirp'));
const urlTools = require('urltools');

async function mkpathAndWriteFileAsync(fileName, contents, encoding) {
  try {
    await writeFile(fileName, contents, encoding);
  } catch (err) {
    if (err.code === 'ENOENT') {
      await mkdirpAsync(Path.dirname(fileName));
      await writeFile(fileName, contents, encoding);
    } else {
      throw err;
    }
  }
}

module.exports = (queryObj, outRoot, root) => {
  if (outRoot && !outRoot.startsWith('file://')) {
    outRoot = urlTools.fsDirToFileUrl(outRoot);
  }

  return async function writeAssetsToDisc(assetGraph) {
    await pMap(
      assetGraph.findAssets({
        isInline: false,
        fileRedirectTargetUrl: undefined, // FIXME: Dependency on non-public api. Smelly
        ...queryObj
      }),
      async asset => {
        let targetUrl;
        let error;

        if (outRoot) {
          targetUrl = urlTools.resolveUrl(
            outRoot,
            urlTools.buildRelativeUrl(root || assetGraph.root, asset.url)
          );
        } else {
          targetUrl = asset.url;
        }

        const fsPath = urlTools.fileUrlToFsPath(targetUrl);

        if (!/[^/]$/.test(fsPath)) {
          error = new Error(
            `Skipping ${asset.urlOrDescription} -- cannot write an empty file name to disc. Consider renaming it to index.html`
          );
          error.asset = asset;
          assetGraph.warn(error);
        } else {
          await mkpathAndWriteFileAsync(
            urlTools.fileUrlToFsPath(targetUrl),
            asset.rawSrc,
            null
          );
        }
      },
      { concurrency: 40 }
    );
  };
};
<commit_msg>mkdirp now supports promises directly, don't try to promisify it<commit_after>const { promisify } = require('util');
const pMap = require('p-map');
const writeFile = promisify(require('fs').writeFile);
const Path = require('path');
const mkdirp = require('mkdirp');
const urlTools = require('urltools');

async function mkpathAndWriteFileAsync(fileName, contents, encoding) {
  try {
    await writeFile(fileName, contents, encoding);
  } catch (err) {
    if (err.code === 'ENOENT') {
      await mkdirp(Path.dirname(fileName));
      await writeFile(fileName, contents, encoding);
    } else {
      throw err;
    }
  }
}

module.exports = (queryObj, outRoot, root) => {
  if (outRoot && !outRoot.startsWith('file://')) {
    outRoot = urlTools.fsDirToFileUrl(outRoot);
  }

  return async function writeAssetsToDisc(assetGraph) {
    await pMap(
      assetGraph.findAssets({
        isInline: false,
        fileRedirectTargetUrl: undefined, // FIXME: Dependency on non-public api. Smelly
        ...queryObj
      }),
      async asset => {
        let targetUrl;
        let error;

        if (outRoot) {
          targetUrl = urlTools.resolveUrl(
            outRoot,
            urlTools.buildRelativeUrl(root || assetGraph.root, asset.url)
          );
        } else {
          targetUrl = asset.url;
        }

        const fsPath = urlTools.fileUrlToFsPath(targetUrl);

        if (!/[^/]$/.test(fsPath)) {
          error = new Error(
            `Skipping ${asset.urlOrDescription} -- cannot write an empty file name to disc. Consider renaming it to index.html`
          );
          error.asset = asset;
          assetGraph.warn(error);
        } else {
          await mkpathAndWriteFileAsync(
            urlTools.fileUrlToFsPath(targetUrl),
            asset.rawSrc,
            null
          );
        }
      },
      { concurrency: 40 }
    );
  };
};
<|endoftext|>


<commit_before>import {Builder, property} from 'es6/lib/ceb.js';
import {Bus} from 'bacon';

let counter = 0;

function trigger(el, options, detail) {
    var evt = document.createEvent('CustomEvent');
    evt.initCustomEvent(options.name, options.bubbles, options.cancellable, detail);
    return el.dispatchEvent(evt);
}

function createStream(el, id, apply, exposedName) {
    destroyStream(el, id, exposedName);
    let stream;
    stream = el[id] = new Bus();
    if (apply) {
        stream = apply.call(el, el, el[id]) || stream;
    }
    if (exposedName) {
        el.streams[exposedName] = stream;
    }
    return stream;
}

function destroyStream(el, id, exposedName) {
    if (el.streams && el.streams[exposedName]) {
        delete el.streams[exposedName];
    }
    if (el[id]) {
        el[id].unsubAll();
        el[id] = null;
    }
}

export class BaconBuilder extends Builder {

    constructor(builder) {
        super();
        this.data = {builder};
    }

    apply(fn) {
        this.data.apply = fn;
        return this;
    }

    trigger(name, bubbles = true, cancellable = true) {
        this.data.dispachedEvent = {name, bubbles, cancellable};
        return this;
    }

    build(proto, on) {

        let id = `_cebBaconifyBus-${counter++}`,
            apply = this.data.apply,
            exposedName = this.data.exposedName,
            dispachedEvent = this.data.dispachedEvent;

        if (exposedName && !Object.getOwnPropertyDescriptor(proto, 'streams')) {
            property('streams').immutable().value({}).build(proto, on);
        }

        on('before:createdCallback').invoke(el => {
            createStream(el, id, apply, exposedName);
        });

        on('before:attachedCallback').invoke(el => {
            let stream = createStream(el, id, apply, exposedName);
            if (dispachedEvent) {
                stream.onValue(value => trigger(el, dispachedEvent, value));
            }
        });

        on('before:detachedCallback').invoke(el => {
            destroyStream(el, id, exposedName);
        });

        if (this.data.builder) {
            this.data.builder.invoke((el, evt) => {
                el[id].push(evt);
            }).build(proto, on);
        }
    }
}

export function baconify(builder) {
    return new BaconBuilder(builder);
}
<commit_msg>can baconify properties<commit_after>import {Builder, property} from 'es6/lib/ceb.js';
import {noop, wrap} from 'es6/lib/utils.js';
import {Bus} from 'bacon';

let counter = 0;

function trigger(el, options, detail) {
    var evt = document.createEvent('CustomEvent');
    evt.initCustomEvent(options.name, options.bubbles, options.cancellable, detail);
    return el.dispatchEvent(evt);
}

function createStream(el, id, apply, exposedName) {
    destroyStream(el, id, exposedName);
    let stream;
    stream = el[id] = new Bus();
    if (apply) {
        stream = apply.call(el, el, el[id]) || stream;
    }
    if (exposedName) {
        el.streams[exposedName] = stream;
    }
    return stream;
}

function destroyStream(el, id, exposedName) {
    if (el.streams && el.streams[exposedName]) {
        delete el.streams[exposedName];
    }
    if (el[id]) {
        el[id].end();
        delete el[id];
        delete el[`${id}Value`];
    }
}

export class BaconBuilder extends Builder {

    constructor(builder) {
        super();
        this.data = {builder};
    }

    apply(fn) {
        this.data.apply = fn;
        return this;
    }

    expose(name) {
        this.data.exposedName = name;
        return this;
    }

    trigger(name, bubbles = true, cancellable = true) {
        this.data.dispachedEvent = {name, bubbles, cancellable};
        return this;
    }

    build(proto, on) {

        let id = `_cebBaconifyBus${counter++}`,
            apply = this.data.apply,
            exposedName = this.data.exposedName,
            dispachedEvent = this.data.dispachedEvent,
            builder = this.data.builder;

        if (exposedName && !Object.getOwnPropertyDescriptor(proto, 'streams')) {
            property('streams').immutable().value({}).build(proto, on);
        }

        on('before:createdCallback').invoke(el => {
            createStream(el, id, apply, exposedName);
        });

        on('before:attachedCallback').invoke(el => {
            let stream = createStream(el, id, apply, exposedName);
            if (dispachedEvent) {
                stream.onValue(value => trigger(el, dispachedEvent, value));
            }
        });

        on('before:detachedCallback').invoke(el => {
            destroyStream(el, id, exposedName);
        });

        if (builder && builder.data.invoke) {
            let invoke = builder.data.invoke || noop();
            builder.data.invoke = wrap(invoke, (next, el, evt, target) => {
                el[id].push(evt);
                return next(el, evt, target);
            });
            builder.build(proto, on);
        } else if (builder && builder.data.propName) {
            builder.data.descriptorValue = false;
            let setter = builder.data.setter || ((el, value) => value);
            let getter = builder.data.getter || noop();
            builder.data.setter = wrap(setter, (next, el, value) => {
                el[id].push(value);
                el[`${id}Value`] = value;
                return next(el, value);
            });
            builder.data.getter = wrap(getter, (next, el) => {
                var value = next(el);
                return value || el[`${id}Value`];
            });
            builder.build(proto, on);
        }
    }
}

export function baconify(builder) {
    return new BaconBuilder(builder);
}
<|endoftext|>


<commit_before>'use strict';

/////////////////////////////////////////////////////////////////////////
//                      PLUGINS & MODULES                              //
/////////////////////////////////////////////////////////////////////////

let gulp            = require('gulp'),
    autoprefixer    = require('gulp-autoprefixer'),
    concat          = require('gulp-concat'),
    csscomb         = require('gulp-csscomb'),
    csso            = require('gulp-csso'),
    htmlhint        = require('gulp-htmlhint'),
    htmlmin         = require('gulp-htmlmin'),
    imagemin        = require('gulp-imagemin'),
    sass            = require('gulp-sass'),
    stripDebug      = require('gulp-strip-debug'),
    uglify          = require('gulp-uglify'),
    util            = require('gulp-util');<commit_msg>Setup path<commit_after>'use strict';

/////////////////////////////////////////////////////////////////////////
//                      PLUGINS & MODULES                              //
/////////////////////////////////////////////////////////////////////////

let gulp            = require('gulp'),
    autoprefixer    = require('gulp-autoprefixer'),
    concat          = require('gulp-concat'),
    csscomb         = require('gulp-csscomb'),
    csso            = require('gulp-csso'),
    htmlhint        = require('gulp-htmlhint'),
    htmlmin         = require('gulp-htmlmin'),
    imagemin        = require('gulp-imagemin'),
    sass            = require('gulp-sass'),
    stripDebug      = require('gulp-strip-debug'),
    uglify          = require('gulp-uglify'),
    util            = require('gulp-util');

/////////////////////////////////////////////////////////////////////////
//                              PATH                                   //
/////////////////////////////////////////////////////////////////////////

let path = {};

path.dev = {};
path.public = {};

let app = "dev/app/";
path.dev.app = app;
path.dev.components = app + "components/";
path.dev.services = app + "services/";
path.dev.shared = app + "shared/";

let assets = "dev/assets/";
path.dev.img = assets + "img/";
path.dev.lib = assets + "lib/";

let pbl = "public/";

path.public.css = pbl + "css/";
path.public.img = pbl + "img/";
path.public.js = pbl + "js/";
path.public.lib = pbl + "lib/";
path.public.templates = pbl + "templates/";

let production = util.env.type === 'prod';<|endoftext|>


<commit_before>var assert = require('assert');

function inArray(val, arr) {
  var i = arr.length;
  while (i--) {
    if (arr[i] === val) {
      return true;
    }
  }
  return false;
}

describe('request', function() {
  var agent = require('../').init();
  agent.on('error', function(err) {
    throw err;
  });
  afterEach(function() {
    if (agent) {
      agent.reset();
    }
  });
  var posts = [];

  before(function(done) {
    agent.respond('math.edu', function(router) {
      router.get('/square/:input', function(input) {
        var data = Math.pow(input, 2);
        this.res.writeHead(200, {'Content-Type': 'application/json'});
        this.res.end(JSON.stringify(data));
      });

      router.get('/meaning-of-life', function() {
        var data = "Can't calculate!";
        this.res.writeHead(500, {'Content-Type': 'application/json'});
        this.res.end(JSON.stringify(data));
      });

      router.post('/echo', function() {
        this.res.writeHead(200, {'Content-Type': 'application/json'});
        this.res.end(JSON.stringify(this.req.body));
      });
    }, function() {
      done();
    });
  });

  before(function(done) {
    agent.respond('cloudpost', function(router) {
      router.get('/posts/:id', function(id) {
        console.log(this);
        this.res.writeHead(500, {'Content-Type': 'application/json'});
        this.res.end(JSON.stringify(data));
      });

      router.post('/posts', function() {
        console.log(this);
        //posts.push()
        this.res.writeHead(200, {'Content-Type': 'application/json'});
        this.res.end(JSON.stringify(data));
      });

      router.put('/posts/:id', function(id) {
        console.log(this);
        this.res.writeHead(500, {'Content-Type': 'application/json'});
        this.res.end(JSON.stringify(data));
      });

      router.delete('/posts/:id', function(id) {
        console.log(this);
        this.res.writeHead(500, {'Content-Type': 'application/json'});
        this.res.end(JSON.stringify(data));
      });
    }, function() {
      done();
    });
  });

  it('returns correct answer', function(done) {
    var input = Math.round(100 * Math.random());

    agent.request('agent://math.edu/square/' + input, function(err, res, data) {
      assert.strictEqual(data, input * input, 'Square correctly returned');
      assert.ifError(err);
      done(err);
    });
  });

  it('returns 404', function(done) {
    var input = 100 * Math.random();

    agent.request('agent://math.edu/round?input=' + input, function(err, res, data) {
      assert.strictEqual(data, 'Page not found', 'res.data is error message');
      assert.strictEqual(res.statusCode, 404, 'res.code is 404');
      assert.ifError(err);
      done();
    });
  });

  it('returns 500', function(done) {
    agent.request('agent://math.edu/meaning-of-life', function(err, res, data) {
      assert.strictEqual(data, "Can't calculate!", 'res.data is error message');
      assert.strictEqual(res.statusCode, 500, 'res.code is 500');
      assert.ifError(err);
      done();
    });
  });

  it('can transparently serialize/unserialize JSON', function(done) {
    var options = {
      method: 'POST',
      url: 'agent://math.edu/echo',
      body: {some: 'pig', name: 'wilbur', age: 2, size: '20 lbs.', friends: ['charlotte', 'fern']}
    };
    agent.request(options, function(err, res, data) {
      assert.deepEqual(data, options.body, 'data returned is identical to what was sent');
      assert.ifError(err);
      done();
    });
  });
});
<commit_msg>Use res.json() helper.<commit_after>var assert = require('assert');

function inArray(val, arr) {
  var i = arr.length;
  while (i--) {
    if (arr[i] === val) {
      return true;
    }
  }
  return false;
}

describe('request', function() {
  var agent = require('../').init();
  agent.on('error', function(err) {
    throw err;
  });
  afterEach(function() {
    if (agent) {
      agent.reset();
    }
  });
  var posts = [];

  before(function(done) {
    agent.respond('math.edu', function(router) {
      router.get('/square/:input', function(input) {
        var data = Math.pow(input, 2);
        this.res.json(data);
      });

      router.get('/meaning-of-life', function() {
        var data = "Can't calculate!";
        this.res.json(data, 500);
      });

      router.post('/echo', function() {
        this.res.json(this.req.body);
      });
    }, function() {
      done();
    });
  });

  before(function(done) {
    agent.respond('cloudpost', function(router) {
      router.get('/posts/:id', function(id) {
        console.log(this);
        this.res.writeHead(500, {'Content-Type': 'application/json'});
        this.res.end(JSON.stringify(data));
      });

      router.post('/posts', function() {
        console.log(this);
        //posts.push()
        this.res.writeHead(200, {'Content-Type': 'application/json'});
        this.res.end(JSON.stringify(data));
      });

      router.put('/posts/:id', function(id) {
        console.log(this);
        this.res.writeHead(500, {'Content-Type': 'application/json'});
        this.res.end(JSON.stringify(data));
      });

      router.delete('/posts/:id', function(id) {
        console.log(this);
        this.res.writeHead(500, {'Content-Type': 'application/json'});
        this.res.end(JSON.stringify(data));
      });
    }, function() {
      done();
    });
  });

  it('returns correct answer', function(done) {
    var input = Math.round(100 * Math.random());

    agent.request('agent://math.edu/square/' + input, function(err, res, data) {
      assert.strictEqual(data, input * input, 'Square correctly returned');
      assert.ifError(err);
      done(err);
    });
  });

  it('returns 404', function(done) {
    var input = 100 * Math.random();

    agent.request('agent://math.edu/round?input=' + input, function(err, res, data) {
      assert.strictEqual(data, 'Page not found', 'res.data is error message');
      assert.strictEqual(res.statusCode, 404, 'res.code is 404');
      assert.ifError(err);
      done();
    });
  });

  it('returns 500', function(done) {
    agent.request('agent://math.edu/meaning-of-life', function(err, res, data) {
      assert.strictEqual(data, "Can't calculate!", 'res.data is error message');
      assert.strictEqual(res.statusCode, 500, 'res.code is 500');
      assert.ifError(err);
      done();
    });
  });

  it('can transparently serialize/unserialize JSON', function(done) {
    var options = {
      method: 'POST',
      url: 'agent://math.edu/echo',
      body: {some: 'pig', name: 'wilbur', age: 2, size: '20 lbs.', friends: ['charlotte', 'fern']}
    };
    agent.request(options, function(err, res, data) {
      assert.deepEqual(data, options.body, 'data returned is identical to what was sent');
      assert.ifError(err);
      done();
    });
  });
});
<|endoftext|>


<commit_before>'use strict';

/**
 * Module dependencies
 */

// Public node modules.
const _ = require('lodash');

// Local dependencies.
const DEFAULT_HOOKS = require('./hooks/defaultHooks');

/**
 * Expose new instance of `Configuration`
 */

module.exports = function (strapi) {
  return new Configuration();

  function Configuration() {

    /**
     * Strapi default configuration
     *
     * @api private
     */

    this.defaults = function defaultConfig(appPath) {

      // If `appPath` not specified, unfortunately, this is a fatal error,
      // since reasonable defaults cannot be assumed.
      if (!appPath) {
        throw new Error('Error: No `appPath` specified!');
      }

      // Set up config defaults.
      return {

        // Core (default) hooks.
        hooks: _.reduce(DEFAULT_HOOKS, function (memo, hookBundled, hookIdentity) {
          memo[hookIdentity] = require('./hooks/' + hookIdentity);
          return memo;
        }, {}) || {},

        // Save `appPath` in implicit defaults.
        // `appPath` is passed from above in case `start` was used.
        // This is the directory where this Strapi process is being initiated from.
        // Usually this means `process.cwd()`.
        appPath: appPath,

        // Core settings non provided by hooks.
        host: process.env.HOST || process.env.HOSTNAME || strapi.config.host || 'localhost',
        port: process.env.PORT || strapi.config.port || 1337,

        // Make the environment in config match the server one.
        environment: strapi.app.env || process.env.NODE_ENV,

        // Default reload config.
        reload: {
          timeout: 1000,
          workers: 1
        },

        // Default paths.
        paths: {
          tmp: '.tmp',
          config: 'config',
          static: 'public',
          views: 'views',
          api: 'api',
          controllers: 'controllers',
          services: 'services',
          policies: 'policies',
          models: 'models',
          templates: 'templates'
        },

        // Add the Studio URL.
        studio: {
          url: 'http://studio.strapi.io'
        },

        // Start off needed empty objects and strings.
        routes: {},
        frontendUrl: ''
      };
    };

    /**
     * Load the configuration modules
     *
     * @api private
     */

    this.load = require('./load')(strapi);

    // Bind the context of all instance methods.
    _.bindAll(this);
  }
};
<commit_msg>Use the number of free CPUs<commit_after>'use strict';

/**
 * Module dependencies
 */

// Node.js core.
const os = require('os');

// Public node modules.
const _ = require('lodash');

// Local dependencies.
const DEFAULT_HOOKS = require('./hooks/defaultHooks');

/**
 * Expose new instance of `Configuration`
 */

module.exports = function (strapi) {
  return new Configuration();

  function Configuration() {

    /**
     * Strapi default configuration
     *
     * @api private
     */

    this.defaults = function defaultConfig(appPath) {

      // If `appPath` not specified, unfortunately, this is a fatal error,
      // since reasonable defaults cannot be assumed.
      if (!appPath) {
        throw new Error('Error: No `appPath` specified!');
      }

      // Set up config defaults.
      return {

        // Core (default) hooks.
        hooks: _.reduce(DEFAULT_HOOKS, function (memo, hookBundled, hookIdentity) {
          memo[hookIdentity] = require('./hooks/' + hookIdentity);
          return memo;
        }, {}) || {},

        // Save `appPath` in implicit defaults.
        // `appPath` is passed from above in case `start` was used.
        // This is the directory where this Strapi process is being initiated from.
        // Usually this means `process.cwd()`.
        appPath: appPath,

        // Core settings non provided by hooks.
        host: process.env.HOST || process.env.HOSTNAME || strapi.config.host || 'localhost',
        port: process.env.PORT || strapi.config.port || 1337,

        // Make the environment in config match the server one.
        environment: strapi.app.env || process.env.NODE_ENV,

        // Default reload config.
        reload: {
          timeout: 1000,
          workers: os.cpus().length
        },

        // Default paths.
        paths: {
          tmp: '.tmp',
          config: 'config',
          static: 'public',
          views: 'views',
          api: 'api',
          controllers: 'controllers',
          services: 'services',
          policies: 'policies',
          models: 'models',
          templates: 'templates'
        },

        // Add the Studio URL.
        studio: {
          url: 'http://studio.strapi.io'
        },

        // Start off needed empty objects and strings.
        routes: {},
        frontendUrl: ''
      };
    };

    /**
     * Load the configuration modules
     *
     * @api private
     */

    this.load = require('./load')(strapi);

    // Bind the context of all instance methods.
    _.bindAll(this);
  }
};
<|endoftext|>


<commit_before>import React from 'react';

class App extends React.Component {
  constructor(){
    super();
    this.state = {a: ''};
    this.update = this.update.bind(this);
  }

  update(e){
    this.setState({a: e.target.value});
  }

  render(){
    return (

      <input
        type="text"
        onChange={this.update}
      /> {this.state.a}

{this.state.currentEvent}

    )
  }
}

export default App<commit_msg>ref II<commit_after>import React from 'react';

class App extends React.Component {
  constructor(){
    super();
    this.state = {a: ''};
    this.update = this.update.bind(this);
  }

  update(e){
    this.setState({
      a: this.refs.a.value,
      b: this.refs.b.value
    });
  }

  render(){
    return (

      <input
        ref="a"
        type="text"
        onChange={this.update}
      /> {this.state.a}

      <input
        ref="b"
        type="text"
        onChange={this.update}
      /> {this.state.b}

    )
  }
}

export default App<|endoftext|>


<commit_before>import { defaultImage } from '../constants/collectives';
import { imagePreview } from '../lib/utils';

export default ({ src, style = {}, height }) => {
  style.height = style.height || height;
  const image = imagePreview(src, defaultImage.ORGANIZATION, { height });
  return (

  );
}<commit_msg>Fix for resize logo with safari<commit_after>import { defaultImage } from '../constants/collectives';
import { imagePreview } from '../lib/utils';

export default ({ src, style = {}, height }) => {
  style.height = style.height || height;
  const resizeOptions = {};
  resizeOptions.height = style.height;
  if (typeof resizeOptions.height === 'string') {
    resizeOptions.height = Number(resizeOptions.height.replace(/rem/,'')) * 10;
  }
  const image = imagePreview(src, defaultImage.ORGANIZATION, resizeOptions);
  return (

  );
}<|endoftext|>


<commit_before>'use strict';

/* Services */
angular.module('app')
    .value("appEvents", {
        workout: { exerciseStarted: "event:workout:exerciseStarted" }
    });

angular.module('app')
    .factory("WorkoutService", ['WorkoutPlan', 'Exercise', function (WorkoutPlan, Exercise) {
        var service = {};
        var workouts = [];
        var exercises = [];
        service.getExercises = function () {
            return exercises;
        };

        service.getWorkouts = function () {
            return workouts;
        };

        var setupInitialExercises = function () {
            exercises.push(
                new Exercise({
                    name: "jumpingJacks",
                    title: "Jumping Jacks",
                    description: "A jumping jack or star jump, also called side-straddle hop is a physical jumping exercise.",
                    image: "img/JumpingJacks.png",
                    nameSound: "content/jumpingjacks.wav",
                    videos: ["dmYwZH_BNd0", "BABOdJ-2Z6o", "c4DAnQ6DtF8"],
                    procedure: "Assume an erect position, with feet together and arms at your side.\

Slightly bend your knees, and propel yourself a few inches into the air.\

While in air, bring your legs out to the side about shoulder width or slightly wider.\

As you are moving your legs outward, you should raise your arms up over your head; arms should be slightly bent throughout the entire in-air movement.\

Your feet should land shoulder width or wider as your hands meet above your head with arms slightly bent"
                }));

            exercises.push(
               new Exercise({
                   name: "wallSit",
                   title: "Wall Sit",
                   description: "A wall sit, also known as a Roman Chair, is an exercise done to strengthen the quadriceps muscles.",
                   image: "img/wallsit.png",
                   nameSound: "content/wallsit.wav",
                   videos: ["y-wV4Venusw", "MMV3v4ap4ro"],
                   procedure: "Place your back against a wall with your feet shoulder width apart and a little ways out from the wall.\

Then, keeping your back against the wall, lower your hips until your knees form right angles. "
               }));

            exercises.push(
               new Exercise({
                   name: "pushUp",
                   title: "Push Up",
                   description: "A push-up is a common exercise performed in a prone position by raising and lowering the body using the arms",
                   image: "img/Pushup.png",
                   nameSound: "content/pushups.wav",
                   videos: ["Eh00_rniF8E", "ZWdBqFLNljc", "UwRLWMcOdwI", "ynPwl6qyUNM", "OicNTT2xzMI"],
                   procedure: "Lie prone on the ground with hands placed as wide or slightly wider than shoulder width. \
                              Keeping the body straight, lower body to the ground by bending arms at the elbows. \
                              Raise body up off the ground by extending the arms."
               }));

            exercises.push(
                 new Exercise({
                     name: "crunches",
                     title: "Abdominal Crunches",
                     description: "The basic crunch is a abdominal exercise in a strength-training program.",
                     image: "img/crunches.png",
                     nameSound: "content/crunches.wav",
                     videos: ["Xyd_fa5zoEU", "MKmrqcoCZ-M"],
                     procedure: "Lie on your back with your knees bent and feet flat on the floor, hip-width apart.\
                              Place your hands behind your head so your thumbs are behind your ears.\
                              Hold your elbows out to the sides but rounded slightly in.\
                              Gently pull your abdominals inward.\
                              Curl up and forward so that your head, neck, and shoulder blades lift off the floor.\
                              Hold for a moment at the top of the movement and then lower slowly back down."
                 }));

            exercises.push(
               new Exercise({
                   name: "stepUpOntoChair",
                   title: "Step Up Onto Chair",
                   description: "Step exercises are ideal for building muscle in your lower body.",
                   image: "img/stepUpOntoChair.png",
                   nameSound: "content/stepup.wav",
                   videos: ["aajhW7DD1EA"],
                   procedure: "Position your chair in front of you.\
                              Stand with your feet about hip width apart, arms at your sides.\
                              Step up onto the seat with one foot, pressing down while bringing your other foot up next to it. \
                              Step back with the leading foot and bring the trailing foot down to finish one step-up."
               }));

            exercises.push(
               new Exercise({
                   name: "squat",
                   title: "Squat",
                   description: "The squat is a compound, full body exercise that trains primarily the muscles of the thighs, hips, buttocks and quads.",
                   image: "img/squat.png",
                   nameSound: "content/squats.wav",
                   videos: ["QKKZ9AGYTi4", "UXJrBgI2RxA"],
                   procedure: "Stand with your head facing forward and your chest held up and out.\
                              Place your feet shoulder-width apart or little wider. Extend your hands straight out in front of you.\
                              Sit back and down like you're sitting into a chair. Keep your head facing straight as your upper body bends forward a bit. Rather than allowing your back to round, let your lower back arch slightly as you go down.\
                              Lower down so your thighs are parallel to the floor, with your knees over your ankles. Press your weight back into your heels.\
                              Keep your body tight, and push through your heels to bring yourself back to the starting position."
               }));
            exercises.push(
                new Exercise({
                    name: "tricepdips",
                    title: "Tricep Dips On Chair",
                    description: "A body weight exercise that targets triceps.",
                    image: "img/tricepdips.png",
                    nameSound: "content/tricepdips.wav",
                    videos: ["tKjcgfu44sI", "jox1rb5krQI"],
                    procedure: "Sit up on a chair. Your legs should be slightly extended, with your feet flat on the floor.\
                              Place your hands edges of the chair. Your palms should be down, fingertips pointing towards the floor.\
                              Without moving your legs, bring your glutes forward off the chair.\
                              Steadily lower yourself. When your elbows form 90 degrees angles, push yourself back up to starting position."
                }));

            exercises.push(
                new Exercise({
                    name: "plank",
                    title: "Plank",
                    description: "The plank (also called a front hold, hover, or abdominal bridge) is an isometric core strength exercise that involves maintaining a difficult position for extended periods of time. ",
                    image: "img/Plank.png",
                    nameSound: "content/plank.wav",
                    videos: ["pSHjTRCQxIw", "TvxNkmjdhMM"],
                    procedure: "Get into pushup position on the floor.\
                              Bend your elbows 90 degrees and rest your weight on your forearms.\
                              Your elbows should be directly beneath your shoulders, and your body should form a straight line from head to feet.\
                              Hold this position."
                }));

            exercises.push(
               new Exercise({
                   name: "highKnees",
                   title: "High Knees",
                   description: "A form exercise that develops strength and endurance of the hip flexors and quads and stretches the hip extensors.",
                   image: "img/highknees.png",
                   nameSound: "content/highknees.wav",
                   videos: ["OAJ_J3EZkdY", "8opcQdC-V-U"],
                   procedure: "Start standing with feet hip-width apart. \
                              Do inplace jog with your knees lifting as much as possible towards your chest."
               }));

            exercises.push(
               new Exercise({
                   name: "lunges",
                   title: "Lunges",
                   description: "Lunges are a good exercise for strengthening, sculpting and building several muscles/muscle groups, including the quadriceps (or thighs), the gluteus maximus (or buttocks) as well as the hamstrings. ",
                   image: "img/lunges.png",
                   nameSound: "content/lunge.wav",
                   videos: ["Z2n58m2i4jg"],
                   procedure: "Stand erect with your feet about one shoulder width apart.\
                              Put your hands on your hips, keep your back as straight as possible, relax your shoulders and keep your eyes facing directly ahead.\
                              Take a large step forward with one leg.\
                              As you step forward, lower your hips and bend your knees until they both form 90 degree angles.\
                              Return to starting position.\
                              Repeat with your alternate leg."
               }));

            exercises.push(
                new Exercise({
                    name: "pushupNRotate",
                    title: "Pushup And Rotate",
                    description: "A variation of pushup that requires you to rotate.",
                    image: "img/pushupNRotate.png",
                    nameSound: "content/pushupandrotate.wav",
                    videos: ["qHQ_E-f5278"],
                    procedure: "Assume the classic pushup position, but as you come up, rotate your body so your right arm lifts up and extends overhead.\
                              Return to the starting position, lower yourself, then push up and rotate till your left hand points toward the ceiling."
                }));

            exercises.push(
                new Exercise({
                    name: "sidePlank",
                    title: "Side Plank",
                    description: "A variation to Plank done using one hand only",
                    image: "img/sideplank.png",
                    nameSound: "content/sideplank.wav",
                    videos: ["wqzrb67Dwf8", "_rdfjFSFKMY"],
                    procedure: "Lie on your side, in a straight line from head to feet, resting on your forearm.\
                              Your elbow should be directly under your shoulder.\
                              With your abdominals gently contracted, lift your hips off the floor, maintaining the line.\
                              Keep your hips square and your neck in line with your spine. Hold the position."
                }));

        };

        var setupInitialWorkouts = function () {
            var exercises = service.getExercises();
            var workout = new WorkoutPlan({
                name: "7minWorkout",
                title: "7 Minute Workout",
                description: "A high intensity workout that consists of 12 exercises.",
                restBetweenExercise: 10
            });

            workout.exercises.push({
                details: exercises[0],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[1],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[2],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[3],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[4],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[5],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[6],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[7],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[8],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[9],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[10],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[11],
                duration: 30
            });
            workouts.push(workout);
        };

        var init = function () {
            setupInitialExercises();
            setupInitialWorkouts();
        };

        init();
        return service;
    }]);

<commit_msg>Add getWorkout in shared service<commit_after>'use strict';

/* Services */
angular.module('app')
    .value("appEvents", {
        workout: { exerciseStarted: "event:workout:exerciseStarted" }
    });

angular.module('app')
    .factory("WorkoutService", ['WorkoutPlan', 'Exercise', function (WorkoutPlan, Exercise) {
        var service = {};
        var workouts = [];
        var exercises = [];
        service.getExercises = function () {
            return exercises;
        };

        service.getWorkouts = function () {
            return workouts;
        };

        var setupInitialExercises = function () {
            exercises.push(
                new Exercise({
                    name: "jumpingJacks",
                    title: "Jumping Jacks",
                    description: "A jumping jack or star jump, also called side-straddle hop is a physical jumping exercise.",
                    image: "img/JumpingJacks.png",
                    nameSound: "content/jumpingjacks.wav",
                    videos: ["dmYwZH_BNd0", "BABOdJ-2Z6o", "c4DAnQ6DtF8"],
                    procedure: "Assume an erect position, with feet together and arms at your side.\

Slightly bend your knees, and propel yourself a few inches into the air.\

While in air, bring your legs out to the side about shoulder width or slightly wider.\

As you are moving your legs outward, you should raise your arms up over your head; arms should be slightly bent throughout the entire in-air movement.\

Your feet should land shoulder width or wider as your hands meet above your head with arms slightly bent"
                }));

            exercises.push(
               new Exercise({
                   name: "wallSit",
                   title: "Wall Sit",
                   description: "A wall sit, also known as a Roman Chair, is an exercise done to strengthen the quadriceps muscles.",
                   image: "img/wallsit.png",
                   nameSound: "content/wallsit.wav",
                   videos: ["y-wV4Venusw", "MMV3v4ap4ro"],
                   procedure: "Place your back against a wall with your feet shoulder width apart and a little ways out from the wall.\

Then, keeping your back against the wall, lower your hips until your knees form right angles. "
               }));

            exercises.push(
               new Exercise({
                   name: "pushUp",
                   title: "Push Up",
                   description: "A push-up is a common exercise performed in a prone position by raising and lowering the body using the arms",
                   image: "img/Pushup.png",
                   nameSound: "content/pushups.wav",
                   videos: ["Eh00_rniF8E", "ZWdBqFLNljc", "UwRLWMcOdwI", "ynPwl6qyUNM", "OicNTT2xzMI"],
                   procedure: "Lie prone on the ground with hands placed as wide or slightly wider than shoulder width. \
                              Keeping the body straight, lower body to the ground by bending arms at the elbows. \
                              Raise body up off the ground by extending the arms."
               }));

            exercises.push(
                 new Exercise({
                     name: "crunches",
                     title: "Abdominal Crunches",
                     description: "The basic crunch is a abdominal exercise in a strength-training program.",
                     image: "img/crunches.png",
                     nameSound: "content/crunches.wav",
                     videos: ["Xyd_fa5zoEU", "MKmrqcoCZ-M"],
                     procedure: "Lie on your back with your knees bent and feet flat on the floor, hip-width apart.\
                              Place your hands behind your head so your thumbs are behind your ears.\
                              Hold your elbows out to the sides but rounded slightly in.\
                              Gently pull your abdominals inward.\
                              Curl up and forward so that your head, neck, and shoulder blades lift off the floor.\
                              Hold for a moment at the top of the movement and then lower slowly back down."
                 }));

            exercises.push(
               new Exercise({
                   name: "stepUpOntoChair",
                   title: "Step Up Onto Chair",
                   description: "Step exercises are ideal for building muscle in your lower body.",
                   image: "img/stepUpOntoChair.png",
                   nameSound: "content/stepup.wav",
                   videos: ["aajhW7DD1EA"],
                   procedure: "Position your chair in front of you.\
                              Stand with your feet about hip width apart, arms at your sides.\
                              Step up onto the seat with one foot, pressing down while bringing your other foot up next to it. \
                              Step back with the leading foot and bring the trailing foot down to finish one step-up."
               }));

            exercises.push(
               new Exercise({
                   name: "squat",
                   title: "Squat",
                   description: "The squat is a compound, full body exercise that trains primarily the muscles of the thighs, hips, buttocks and quads.",
                   image: "img/squat.png",
                   nameSound: "content/squats.wav",
                   videos: ["QKKZ9AGYTi4", "UXJrBgI2RxA"],
                   procedure: "Stand with your head facing forward and your chest held up and out.\
                              Place your feet shoulder-width apart or little wider. Extend your hands straight out in front of you.\
                              Sit back and down like you're sitting into a chair. Keep your head facing straight as your upper body bends forward a bit. Rather than allowing your back to round, let your lower back arch slightly as you go down.\
                              Lower down so your thighs are parallel to the floor, with your knees over your ankles. Press your weight back into your heels.\
                              Keep your body tight, and push through your heels to bring yourself back to the starting position."
               }));
            exercises.push(
                new Exercise({
                    name: "tricepdips",
                    title: "Tricep Dips On Chair",
                    description: "A body weight exercise that targets triceps.",
                    image: "img/tricepdips.png",
                    nameSound: "content/tricepdips.wav",
                    videos: ["tKjcgfu44sI", "jox1rb5krQI"],
                    procedure: "Sit up on a chair. Your legs should be slightly extended, with your feet flat on the floor.\
                              Place your hands edges of the chair. Your palms should be down, fingertips pointing towards the floor.\
                              Without moving your legs, bring your glutes forward off the chair.\
                              Steadily lower yourself. When your elbows form 90 degrees angles, push yourself back up to starting position."
                }));

            exercises.push(
                new Exercise({
                    name: "plank",
                    title: "Plank",
                    description: "The plank (also called a front hold, hover, or abdominal bridge) is an isometric core strength exercise that involves maintaining a difficult position for extended periods of time. ",
                    image: "img/Plank.png",
                    nameSound: "content/plank.wav",
                    videos: ["pSHjTRCQxIw", "TvxNkmjdhMM"],
                    procedure: "Get into pushup position on the floor.\
                              Bend your elbows 90 degrees and rest your weight on your forearms.\
                              Your elbows should be directly beneath your shoulders, and your body should form a straight line from head to feet.\
                              Hold this position."
                }));

            exercises.push(
               new Exercise({
                   name: "highKnees",
                   title: "High Knees",
                   description: "A form exercise that develops strength and endurance of the hip flexors and quads and stretches the hip extensors.",
                   image: "img/highknees.png",
                   nameSound: "content/highknees.wav",
                   videos: ["OAJ_J3EZkdY", "8opcQdC-V-U"],
                   procedure: "Start standing with feet hip-width apart. \
                              Do inplace jog with your knees lifting as much as possible towards your chest."
               }));

            exercises.push(
               new Exercise({
                   name: "lunges",
                   title: "Lunges",
                   description: "Lunges are a good exercise for strengthening, sculpting and building several muscles/muscle groups, including the quadriceps (or thighs), the gluteus maximus (or buttocks) as well as the hamstrings. ",
                   image: "img/lunges.png",
                   nameSound: "content/lunge.wav",
                   videos: ["Z2n58m2i4jg"],
                   procedure: "Stand erect with your feet about one shoulder width apart.\
                              Put your hands on your hips, keep your back as straight as possible, relax your shoulders and keep your eyes facing directly ahead.\
                              Take a large step forward with one leg.\
                              As you step forward, lower your hips and bend your knees until they both form 90 degree angles.\
                              Return to starting position.\
                              Repeat with your alternate leg."
               }));

            exercises.push(
                new Exercise({
                    name: "pushupNRotate",
                    title: "Pushup And Rotate",
                    description: "A variation of pushup that requires you to rotate.",
                    image: "img/pushupNRotate.png",
                    nameSound: "content/pushupandrotate.wav",
                    videos: ["qHQ_E-f5278"],
                    procedure: "Assume the classic pushup position, but as you come up, rotate your body so your right arm lifts up and extends overhead.\
                              Return to the starting position, lower yourself, then push up and rotate till your left hand points toward the ceiling."
                }));

            exercises.push(
                new Exercise({
                    name: "sidePlank",
                    title: "Side Plank",
                    description: "A variation to Plank done using one hand only",
                    image: "img/sideplank.png",
                    nameSound: "content/sideplank.wav",
                    videos: ["wqzrb67Dwf8", "_rdfjFSFKMY"],
                    procedure: "Lie on your side, in a straight line from head to feet, resting on your forearm.\
                              Your elbow should be directly under your shoulder.\
                              With your abdominals gently contracted, lift your hips off the floor, maintaining the line.\
                              Keep your hips square and your neck in line with your spine. Hold the position."
                }));

        };

        var setupInitialWorkouts = function () {
            var exercises = service.getExercises();
            // There is only one workout defined by default.
            var workout = new WorkoutPlan({
                name: "7minWorkout",
                title: "7 Minute Workout",
                description: "A high intensity workout that consists of 12 exercises.",
                restBetweenExercise: 10
            });

            workout.exercises.push({
                details: exercises[0],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[1],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[2],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[3],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[4],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[5],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[6],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[7],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[8],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[9],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[10],
                duration: 30
            });
            workout.exercises.push({
                details: exercises[11],
                duration: 30
            });
            workouts.push(workout);
        };

        service.getWorkout = function (name) {
            var result = null;
            angular.forEach(service.getWorkouts(), function (workout) {
                if (workout.name === name) result = workout;
            });
            return result;
        };

        var init = function () {
            setupInitialExercises();
            setupInitialWorkouts();
        };

        init();

        return service;
    }]);

<|endoftext|>


<commit_before>/**
 *  Toolbar.js
 *  Document Editor
 *
 *  Created by Alexander Yuzhin on 9/23/16
 *  Copyright (c) 2016 Ascensio System SIA. All rights reserved.
 *
 */

define([
    'text!documenteditor/mobile/app/template/Toolbar.template',
    'jquery',
    'underscore',
    'backbone'
], function (toolbarTemplate, $, _, Backbone) {
    'use strict';

    DE.Views.Toolbar = Backbone.View.extend((function() {
        // private

        return {
            el: '.view-main',

            // Compile our stats template
            template: _.template(toolbarTemplate),

            // Delegated events for creating new items, and clearing completed ones.
            events: {
                "click #toolbar-search"     : "searchToggle",
                "click #toolbar-edit"       : "showEdition",
                "click #toolbar-add"        : "showInserts",
                "click #toolbar-settings"   : "showSettings"
            },

            // Set innerHTML and get the references to the DOM elements
            initialize: function() {
                var me = this;

                Common.Gateway.on('init', _.bind(me.loadConfig, me));

                Common.NotificationCenter.on('readermode:change', function (reader) {
                    if (reader) {
                        me.hideSearch();
                        $('#toolbar-search').addClass('disabled');
                    } else {
                        $('#toolbar-search').removeClass('disabled');
                    }
                });
            },

            // Render layout
            render: function() {
                var $el = $(this.el);

                $el.prepend(this.template({
                    android     : Common.SharedSettings.get('android'),
                    phone       : Common.SharedSettings.get('phone'),
                    backTitle   : Common.SharedSettings.get('android') ? '' : 'Back'
                }));

                return this;
            },

            setMode: function (mode) {
                var isEdit = (mode === 'edit');

                if (isEdit) {
                    $('#toolbar-edit, #toolbar-add').show();
                }
            },

            loadConfig: function(data) {
                if (data && data.config && data.config.canBackToFolder !== false &&
                    data.config.customization && data.config.customization.goback && data.config.customization.goback.url) {
                    var me = this;

                    $('#document-back')
                        .show()
                        .on('click', _.bind(function () {
                            window.parent.location.href = data.config.customization.goback.url;
                        }, me));
                }
            },

            // Search
            searchToggle: function() {
                if ($$('.searchbar.document').length > 0) {
                    this.hideSearch();
                } else {
                    this.showSearch();
                }
            },

            showSearch: function () {
                var me = this,
                    searchBar = $$('.searchbar.document');

                if (searchBar.length < 1) {
                    $(me.el).find('.pages .page').first().prepend(_.template(
                        '<form class="searchbar document navbar navbar-hidden">' +
                        '
' +
                        '<input type="search" placeholder="Search">' +
                        '
' +
                        '
' +
                        '<' +
                        '>' +
                        '
' +
                        '</form>', {}
                    ));
                    me.fireEvent('searchbar:render', me);
                    searchBar = $$('.searchbar.document');

                    _.defer(function() {
                        uiApp.showNavbar(searchBar);

                        searchBar.transitionEnd(function () {
                            if (!searchBar.hasClass('navbar-hidden'))
                                me.fireEvent('searchbar:show', me);
                        });
                    }, 10);
                }
            },

            hideSearch: function () {
                var me = this,
                    searchBar = $$('.searchbar.document');

                if (searchBar.length > 0) {
                    // Animating
                    if (searchBar.hasClass('.navbar-hidding')) {
                        return;
                    }

                    _.defer(function() {
                        searchBar.transitionEnd(function () {
                            me.fireEvent('searchbar:hide', me);
                            searchBar.remove();
                        });

                        uiApp.hideNavbar(searchBar);
                    }, 10);
                }
            },

            // Editor
            showEdition: function () {
                DE.getController('EditContainer').showModal();
            },

            // Inserts

            showInserts: function () {
                DE.getController('AddContainer').showModal();
            },

            // Settings
            showSettings: function () {
                DE.getController('Settings').showModal();
            }
        }
    })());
});
<commit_msg>[DE mobile] Focus input on show searchbar.<commit_after>/**
 *  Toolbar.js
 *  Document Editor
 *
 *  Created by Alexander Yuzhin on 9/23/16
 *  Copyright (c) 2016 Ascensio System SIA. All rights reserved.
 *
 */

define([
    'text!documenteditor/mobile/app/template/Toolbar.template',
    'jquery',
    'underscore',
    'backbone'
], function (toolbarTemplate, $, _, Backbone) {
    'use strict';

    DE.Views.Toolbar = Backbone.View.extend((function() {
        // private

        return {
            el: '.view-main',

            // Compile our stats template
            template: _.template(toolbarTemplate),

            // Delegated events for creating new items, and clearing completed ones.
            events: {
                "click #toolbar-search"     : "searchToggle",
                "click #toolbar-edit"       : "showEdition",
                "click #toolbar-add"        : "showInserts",
                "click #toolbar-settings"   : "showSettings"
            },

            // Set innerHTML and get the references to the DOM elements
            initialize: function() {
                var me = this;

                Common.Gateway.on('init', _.bind(me.loadConfig, me));

                Common.NotificationCenter.on('readermode:change', function (reader) {
                    if (reader) {
                        me.hideSearch();
                        $('#toolbar-search').addClass('disabled');
                    } else {
                        $('#toolbar-search').removeClass('disabled');
                    }
                });
            },

            // Render layout
            render: function() {
                var $el = $(this.el);

                $el.prepend(this.template({
                    android     : Common.SharedSettings.get('android'),
                    phone       : Common.SharedSettings.get('phone'),
                    backTitle   : Common.SharedSettings.get('android') ? '' : 'Back'
                }));

                return this;
            },

            setMode: function (mode) {
                var isEdit = (mode === 'edit');

                if (isEdit) {
                    $('#toolbar-edit, #toolbar-add').show();
                }
            },

            loadConfig: function(data) {
                if (data && data.config && data.config.canBackToFolder !== false &&
                    data.config.customization && data.config.customization.goback && data.config.customization.goback.url) {
                    var me = this;

                    $('#document-back')
                        .show()
                        .on('click', _.bind(function () {
                            window.parent.location.href = data.config.customization.goback.url;
                        }, me));
                }
            },

            // Search
            searchToggle: function() {
                if ($$('.searchbar.document').length > 0) {
                    this.hideSearch();
                } else {
                    this.showSearch();
                }
            },

            showSearch: function () {
                var me = this,
                    searchBar = $$('.searchbar.document');

                if (searchBar.length < 1) {
                    $(me.el).find('.pages .page').first().prepend(_.template(
                        '<form class="searchbar document navbar navbar-hidden">' +
                            '
' +
                                '<input type="search" placeholder="Search">' +
                            '
' +
                            '
' +
                                '<' +
                                '>' +
                            '
' +
                        '</form>', {}
                    ));
                    me.fireEvent('searchbar:render', me);

                    searchBar = $$('.searchbar.document');

                    _.defer(function() {
                        uiApp.showNavbar(searchBar);

                        searchBar.transitionEnd(function () {
                            if (!searchBar.hasClass('navbar-hidden')) {
                                me.fireEvent('searchbar:show', me);
                                $('.searchbar input').focus();
                            }
                        });
                    }, 10);
                }
            },

            hideSearch: function () {
                var me = this,
                    searchBar = $$('.searchbar.document');

                if (searchBar.length > 0) {
                    // Animating
                    if (searchBar.hasClass('.navbar-hidding')) {
                        return;
                    }

                    _.defer(function() {
                        searchBar.transitionEnd(function () {
                            me.fireEvent('searchbar:hide', me);
                            searchBar.remove();
                        });

                        uiApp.hideNavbar(searchBar);
                    }, 10);
                }
            },

            // Editor
            showEdition: function () {
                DE.getController('EditContainer').showModal();
            },

            // Inserts

            showInserts: function () {
                DE.getController('AddContainer').showModal();
            },

            // Settings
            showSettings: function () {
                DE.getController('Settings').showModal();
            }
        }
    })());
});
<|endoftext|>


<commit_before>window.lazyTests = {
	simpleView: ['lazyloads simple image in view', function(assert){
		var done = assert.async();

		this.promise.always(function($){
			var initialSrc = 'data:initial';
			var lazySrc = 'data:lazysrc';
			var $topImage = $('')
					.attr({
						src: initialSrc,
						'data-src': lazySrc,
						'class': 'lazyload'
					}).appendTo('body')
				;

			assert.equal($topImage.attr('src'), initialSrc);

			setTimeout(function(){
				assert.equal($topImage.attr('src'), lazySrc);
				done();
			}, 70);
		});
	}],
	simpleScrollView: ['lazyloads simple image after it scrolls near to view', function(assert){
		if(/mobi/i.test(navigator.userAgent)){
			assert.ok(true);
			return;
		}
		var done = assert.async();

		this.promise.always(function($, frameWindow){
			var initialSrc = 'data:initial';
			var lazySrc = 'data:lazysrc';
			var $topImage = $('')
					.attr({
						src: initialSrc,
						'data-src': lazySrc,
						'class': 'lazyload'
					})
					.css({
						position: 'absolute',
						top: 999
					})
					.appendTo('body')
				;

			assert.equal($topImage.attr('src'), initialSrc);

			setTimeout(function(){
				assert.equal($topImage.attr('src'), initialSrc);
			}, 70);

			setTimeout(function(){
				$(frameWindow).scrollTop(900);
			}, 70);
			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					assert.equal($topImage.attr('src'), lazySrc);
					done();
				}, 9);
			});
		});
	}],
	simpleAnimateView: ['lazyloads simple image after it animates near to view', function(assert){
		if(/mobi/i.test(navigator.userAgent)){
			assert.ok(true);
			return;
		}
		var done = assert.async();

		this.promise.always(function($, frameWindow){
			var initialSrc = 'data:initial';
			var lazySrc = 'data:lazysrc';
			var $topImage = $('')
					.attr({
						src: initialSrc,
						'data-src': lazySrc,
						'class': 'lazyload'
					})
					.css({
						position: 'absolute',
						top: 999
					})
					.appendTo('body')
				;

			assert.equal($topImage.attr('src'), initialSrc);

			setTimeout(function(){
				assert.equal($topImage.attr('src'), initialSrc);
			}, 70);

			setTimeout(function(){
				$topImage.animate({top: 0}, {duration: 50});
			}, 70);

			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					assert.equal($topImage.attr('src'), lazySrc);
					done();
				}, 9);
			});
		});
	}],
	simpleAutoSizes: ['takes width of image and adds it to the sizes attribute', function(assert){
		var done = assert.async();

		this.promise.always(function($){
			var $topImage = $('
' +
			'' +
			'
')
				.appendTo('body')
				.find('img');

			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					assert.equal($topImage.attr('sizes'), '100px');
					done();
				}, 9);
			});
		});
	}],
	autoSizesEvent: ['lazybeforesizes event allows modifying sizes attribute', function(assert){
		var done = assert.async();

		this.promise.always(function($){
			var $topImage = $('
' +
			'' +
			'
')
				.appendTo('body')
				.find('img');

			$topImage.on('lazybeforesizes', function(e){
				e.originalEvent.details.width = 12;
				setTimeout(function(){
					assert.equal($topImage.attr('sizes'), '12px');
					done();
				}, 9);
			});
		});
	}],
	autoSizesResize: ['lazysizes reacts on resize', function(assert){
		var done = assert.async();
		var $iframe = this.$iframe;

		this.promise.always(function($, frameWindow){
			var viewport;
			var $topImage;
			var respimgCalls = 0;
			var repimgExpectedCalls = window.HTMLPictureElement ?
				0 :
				frameWindow.lazySizesConfig.onlyLargerSizes ?
					2 :
					3;

			var viewportTests = [
				['300', 150],
				['400', 200],
				['200', 100]
			];
			var run = function(){
				if(viewportTests.length){
					viewport = viewportTests.shift();
					$iframe.css('width', viewport[0]);
				} else {
					assert.equal(respimgCalls, repimgExpectedCalls);
					done();
				}
			};
			run();

			frameWindow.respimage = function(){
				respimgCalls++;
			};
			frameWindow.picturefill = function(){
				respimgCalls++;
			};

			$topImage = $('
' +
			'' +
			'
')
				.appendTo('body')
				.find('img');

			$topImage.on('lazybeforesizes', function(e){
				setTimeout(function(){
					assert.equal($topImage.attr('sizes'), viewport[1]+'px');
					run();
				}, 9);
			});
		});
	}],
	parentAutoSizes: ['takes width of parent of image and adds it to the sizes attribute2', function(assert){
		var done = assert.async();

		this.promise.always(function($){
			var $topImage = $('
' +
			'' +
			'
').find('img');

			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					assert.equal($topImage.attr('sizes'), '200px');
					done();
				}, 9);
			});
			$topImage.parent().appendTo('body');
		});
	}],
	simplePicture: ['lazyloads srcset on picture', function(assert){
		var done = assert.async();

		this.promise.always(function($, frameWindow){
			var $picture = createPicture($, [
				{
					'data-srcset': 'data:lazysource 200w'
				},
				{
					'data-srcset': 'data:lazyimg 200w',
					'class': 'lazyload'
				}
			]);
			var $source = $picture.find('source');
			var $image = $picture.find('img');

			$picture.appendTo('body');

			assert.equal($source.attr('srcset'), null);
			assert.equal($image.attr('srcset'), null);

			$image.on('lazybeforeunveil', function(){
				setTimeout(function(){

					assert.equal($source.attr('srcset'), 'data:lazysource 200w');
					assert.equal($image.attr('srcset') || $image.attr('data-risrcset') || $image.attr('data-pfsrcset'), 'data:lazyimg 200w');
					assert.equal($image.prop('src'), window.HTMLPictureElement || !frameWindow.respimage ?  '' : 'data:lazysource');
					done();
				}, 9);
			});
		});
	}],
	simpleAutoSizesPicture: ['lazyloads srcset on picture', function(assert){
		var done = assert.async();

		this.promise.always(function($, frameWindow){
			var lazySrcset = 'data:lazysrcset 300w';
			var $picture = createPicture($, [
				{
					'data-srcset': 'data:lazysource 200w'
				},
				{
					'data-srcset': 'data:lazyimg 200w',
					'class': 'lazyload',
					'data-sizes': 'auto'
				}
			]);
			var $source = $picture.find('source');
			var $image = $picture.find('img');

			$picture.appendTo('body');

			assert.equal($source.attr('srcset'), null);
			assert.equal($image.attr('srcset'), null);
			assert.equal($image.attr('sizes'), null);

			$image.on('lazybeforeunveil', function(){
				setTimeout(function(){
					var haspolyfill = frameWindow.respimage || frameWindow.picturefill || (frameWindow.lazySizes.cfg.rias && frameWindow.lazySizes.pWS);

					assert.equal($source.attr('srcset'), 'data:lazysource 200w');
					assert.equal($source.attr('sizes'), $image.attr('sizes'));
					assert.equal($image.attr('srcset') || $image.attr('data-risrcset') || $image.attr('data-pfsrcset'), 'data:lazyimg 200w');
					assert.equal($image.prop('src'), window.HTMLPictureElement || !haspolyfill ?  '' : 'data:lazysource');
					assert.equal($image.attr('sizes'), '300px');
					done();
				}, 9);
			});
		});
	}],
	simpleSrcset: ['lazyloads srcset', function(assert){
		var done = assert.async();

		this.promise.always(function($, frameWindow){
			var initialSrc = 'data:initial';
			var lazySrcset = 'data:lazysrcset 300w';
			var $topImage = $('')
					.attr({
						src: initialSrc,
						'data-srcset': lazySrcset,
						'class': 'lazyload'
					}).appendTo('body')
				;

			assert.equal($topImage.attr('src'), initialSrc);
			assert.equal($topImage.attr('srcset'), null);

			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					var nowSrc =  window.HTMLPictureElement || !(frameWindow.respimage || frameWindow.picturefill) ?
						initialSrc :
						'data:lazysrcset';

					assert.equal($topImage.attr('srcset') || $topImage.attr('data-risrcset') || $topImage.attr('data-pfsrcset'), lazySrcset);
					assert.equal($topImage.prop('src'), nowSrc);
					done();
				}, 9);
			});
		});
	}],
	simpleSrcsetSrc: ['lazyloads srcset or src', function(assert){
		var done = assert.async();

		this.promise.always(function($, frameWindow){
			var initialSrc = 'data:initial';
			var lazySrcset = 'data:lazysrcset 300w';
			var lazySrc = 'data:lazysrc';
			var $topImage = $('')
					.attr({
						src: initialSrc,
						'data-srcset': lazySrcset,
						'data-src': lazySrc,
						'class': 'lazyload'
					}).appendTo('body')
				;

			assert.equal($topImage.prop('src'), initialSrc);
			assert.equal($topImage.attr('srcset'), null);

			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					var nowSrc =  window.HTMLPictureElement ?
						initialSrc :
						(frameWindow.respimage || frameWindow.picturefill) ?
							'data:lazysrcset' :
							lazySrc;

					assert.equal($topImage.attr('srcset') || $topImage.attr('data-risrcset') || $topImage.attr('data-pfsrcset'), lazySrcset);
					assert.equal($topImage.prop('src'), nowSrc);
					done();
				}, 9);
			});
		});
	}],
	nestedOverflow: ['lazyload detects nested overflow with [data-expand]', function(assert){
		var done = assert.async();

		this.promise.always(function($){
			var initialSrc = 'data:initial';
			var lazySrc = 'data:lazysrc';
			var $topImage = $('
' +
				'
')
					.appendTo('body')
					.find('img')
					.attr({
						src: initialSrc,
						'data-src': lazySrc,
						'class': 'lazyload',
						'data-expand': -1,
						style: 'position: relative; top: 100px;'
					})
				;

			assert.equal($topImage.prop('src'), initialSrc);

			setTimeout(function(){
				assert.equal($topImage.prop('src'), initialSrc);
				$topImage.css({top: 50});
			}, 70);
			setTimeout(function(){
				assert.equal($topImage.prop('src'), initialSrc);
				$topImage.css({top: 0});
			}, 140);

			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					assert.equal($topImage.prop('src'), lazySrc);
					done();
				});
			});
		});
	}]
};

QUnit.module( "clean lazySizes", {
	beforeEach: createBeforeEach()
});
QUnit.test.apply(QUnit, lazyTests.simpleView);
QUnit.test.apply(QUnit, lazyTests.simpleScrollView);
QUnit.test.apply(QUnit, lazyTests.simpleAnimateView);
QUnit.test.apply(QUnit, lazyTests.simpleAutoSizes);
QUnit.test.apply(QUnit, lazyTests.parentAutoSizes);
QUnit.test.apply(QUnit, lazyTests.simpleSrcset);
QUnit.test.apply(QUnit, lazyTests.simpleSrcsetSrc);
QUnit.test.apply(QUnit, lazyTests.nestedOverflow);
QUnit.test.apply(QUnit, lazyTests.autoSizesEvent);
QUnit.test.apply(QUnit, lazyTests.autoSizesResize);
QUnit.test.apply(QUnit, lazyTests.simplePicture);
QUnit.test.apply(QUnit, lazyTests.simpleAutoSizesPicture);

QUnit.module( "lazySizes with respimage", {
	beforeEach: createBeforeEach({libs: ['respimage']})
});
QUnit.test.apply(QUnit, lazyTests.simpleView);
QUnit.test.apply(QUnit, lazyTests.simpleScrollView);
QUnit.test.apply(QUnit, lazyTests.simpleSrcset);
QUnit.test.apply(QUnit, lazyTests.simpleSrcsetSrc);
QUnit.test.apply(QUnit, lazyTests.autoSizesResize);
QUnit.test.apply(QUnit, lazyTests.simpleAutoSizesPicture);

QUnit.module( "lazySizes + options + respimage + respmutation", {
	beforeEach: createBeforeEach({libs: ['respimage', 'respmutation']})
});
QUnit.test.apply(QUnit, lazyTests.simpleView);
QUnit.test.apply(QUnit, lazyTests.simpleScrollView);
QUnit.test.apply(QUnit, lazyTests.simpleSrcset);
QUnit.test.apply(QUnit, lazyTests.simpleSrcsetSrc);
QUnit.test.apply(QUnit, lazyTests.autoSizesEvent);
QUnit.test.apply(QUnit, lazyTests.autoSizesResize);
QUnit.test.apply(QUnit, lazyTests.simplePicture);
QUnit.test.apply(QUnit, lazyTests.simpleAutoSizesPicture);

<commit_msg>fix tests<commit_after>window.lazyTests = {
	simpleView: ['lazyloads simple image in view', function(assert){
		var done = assert.async();

		this.promise.always(function($){
			var initialSrc = 'data:initial';
			var lazySrc = 'data:lazysrc';
			var $topImage = $('')
					.attr({
						src: initialSrc,
						'data-src': lazySrc,
						'class': 'lazyload'
					}).appendTo('body')
				;

			assert.equal($topImage.attr('src'), initialSrc);

			setTimeout(function(){
				assert.equal($topImage.attr('src'), lazySrc);
				done();
			}, 70);
		});
	}],
	simpleScrollView: ['lazyloads simple image after it scrolls near to view', function(assert){
		if(/mobi/i.test(navigator.userAgent)){
			assert.ok(true);
			return;
		}
		var done = assert.async();

		this.promise.always(function($, frameWindow){
			var initialSrc = 'data:initial';
			var lazySrc = 'data:lazysrc';
			var $topImage = $('')
					.attr({
						src: initialSrc,
						'data-src': lazySrc,
						'class': 'lazyload'
					})
					.css({
						position: 'absolute',
						top: 999
					})
					.appendTo('body')
				;

			assert.equal($topImage.attr('src'), initialSrc);

			setTimeout(function(){
				assert.equal($topImage.attr('src'), initialSrc);
			}, 70);

			setTimeout(function(){
				$(frameWindow).scrollTop(900);
			}, 70);
			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					assert.equal($topImage.attr('src'), lazySrc);
					done();
				}, 9);
			});
		});
	}],
	simpleAnimateView: ['lazyloads simple image after it animates near to view', function(assert){
		if(/mobi/i.test(navigator.userAgent)){
			assert.ok(true);
			return;
		}
		var done = assert.async();

		this.promise.always(function($, frameWindow){
			var initialSrc = 'data:initial';
			var lazySrc = 'data:lazysrc';
			var $topImage = $('')
					.attr({
						src: initialSrc,
						'data-src': lazySrc,
						'class': 'lazyload'
					})
					.css({
						position: 'absolute',
						top: 999
					})
					.appendTo('body')
				;

			assert.equal($topImage.attr('src'), initialSrc);

			setTimeout(function(){
				assert.equal($topImage.attr('src'), initialSrc);
			}, 70);

			setTimeout(function(){
				$topImage.animate({top: 0}, {duration: 50});
			}, 70);

			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					assert.equal($topImage.attr('src'), lazySrc);
					done();
				}, 9);
			});
		});
	}],
	simpleAutoSizes: ['takes width of image and adds it to the sizes attribute', function(assert){
		var done = assert.async();

		this.promise.always(function($){
			var $topImage = $('
' +
			'' +
			'
')
				.appendTo('body')
				.find('img');

			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					assert.equal($topImage.attr('sizes'), '100px');
					done();
				}, 9);
			});
		});
	}],
	autoSizesEvent: ['lazybeforesizes event allows modifying sizes attribute', function(assert){
		var done = assert.async();

		this.promise.always(function($){
			var $topImage = $('
' +
			'' +
			'
')
				.appendTo('body')
				.find('img');

			$topImage.on('lazybeforesizes', function(e){
				e.originalEvent.details.width = 12;
				setTimeout(function(){
					assert.equal($topImage.attr('sizes'), '12px');
					done();
				}, 9);
			});
		});
	}],
	autoSizesResize: ['lazysizes reacts on resize', function(assert){
		var done = assert.async();
		var $iframe = this.$iframe;

		this.promise.always(function($, frameWindow){
			var viewport;
			var $topImage;
			var respimgCalls = 0;
			var repimgExpectedCalls = window.HTMLPictureElement ?
				0 : 3;

			var viewportTests = [
				['300', 150],
				['400', 200],
				['200', 100],
				['400', 200]
			];
			var run = function(){
				if(viewportTests.length){
					viewport = viewportTests.shift();
					$iframe.css('width', viewport[0]);
				} else {
					setTimeout(function(){
						assert.equal(respimgCalls, repimgExpectedCalls);
						done();
					}, 90);
				}
			};
			run();

			frameWindow.respimage = function(){
				respimgCalls++;
			};
			frameWindow.picturefill = function(){
				respimgCalls++;
			};

			$topImage = $('
' +
			'' +
			'
')
				.appendTo('body')
				.find('img');

			$topImage.on('lazybeforesizes', function(e){
				setTimeout(function(){
					assert.equal($topImage.attr('sizes'), viewport[1]+'px');
					run();
				}, 9);
			});
		});
	}],
	parentAutoSizes: ['takes width of parent of image and adds it to the sizes attribute2', function(assert){
		var done = assert.async();

		this.promise.always(function($){
			var $topImage = $('
' +
			'' +
			'
').find('img');

			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					assert.equal($topImage.attr('sizes'), '200px');
					done();
				}, 9);
			});
			$topImage.parent().appendTo('body');
		});
	}],
	simplePicture: ['lazyloads srcset on picture', function(assert){
		var done = assert.async();

		this.promise.always(function($, frameWindow){
			var $picture = createPicture($, [
				{
					'data-srcset': 'data:lazysource 200w'
				},
				{
					'data-srcset': 'data:lazyimg 200w',
					'class': 'lazyload'
				}
			]);
			var $source = $picture.find('source');
			var $image = $picture.find('img');

			$picture.appendTo('body');

			assert.equal($source.attr('srcset'), null);
			assert.equal($image.attr('srcset'), null);

			$image.on('lazybeforeunveil', function(){
				setTimeout(function(){

					assert.equal($source.attr('srcset'), 'data:lazysource 200w');
					assert.equal($image.attr('srcset') || $image.attr('data-risrcset') || $image.attr('data-pfsrcset'), 'data:lazyimg 200w');
					assert.equal($image.prop('src'), window.HTMLPictureElement || !frameWindow.respimage ?  '' : 'data:lazysource');
					done();
				}, 9);
			});
		});
	}],
	simpleAutoSizesPicture: ['lazyloads srcset on picture', function(assert){
		var done = assert.async();

		this.promise.always(function($, frameWindow){
			var lazySrcset = 'data:lazysrcset 300w';
			var $picture = createPicture($, [
				{
					'data-srcset': 'data:lazysource 200w'
				},
				{
					'data-srcset': 'data:lazyimg 200w',
					'class': 'lazyload',
					'data-sizes': 'auto'
				}
			]);
			var $source = $picture.find('source');
			var $image = $picture.find('img');

			$picture.appendTo('body');

			assert.equal($source.attr('srcset'), null);
			assert.equal($image.attr('srcset'), null);
			assert.equal($image.attr('sizes'), null);

			$image.on('lazybeforeunveil', function(){
				setTimeout(function(){
					var haspolyfill = frameWindow.respimage || frameWindow.picturefill || (frameWindow.lazySizes.cfg.rias && frameWindow.lazySizes.pWS);

					assert.equal($source.attr('srcset'), 'data:lazysource 200w');
					assert.equal($source.attr('sizes'), $image.attr('sizes'));
					assert.equal($image.attr('srcset') || $image.attr('data-risrcset') || $image.attr('data-pfsrcset'), 'data:lazyimg 200w');
					assert.equal($image.prop('src'), window.HTMLPictureElement || !haspolyfill ?  '' : 'data:lazysource');
					assert.equal($image.attr('sizes'), '300px');
					done();
				}, 9);
			});
		});
	}],
	simpleSrcset: ['lazyloads srcset', function(assert){
		var done = assert.async();

		this.promise.always(function($, frameWindow){
			var initialSrc = 'data:initial';
			var lazySrcset = 'data:lazysrcset 300w';
			var $topImage = $('')
					.attr({
						src: initialSrc,
						'data-srcset': lazySrcset,
						'class': 'lazyload'
					}).appendTo('body')
				;

			assert.equal($topImage.attr('src'), initialSrc);
			assert.equal($topImage.attr('srcset'), null);

			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					var nowSrc =  window.HTMLPictureElement || !(frameWindow.respimage || frameWindow.picturefill) ?
						initialSrc :
						'data:lazysrcset';

					assert.equal($topImage.attr('srcset') || $topImage.attr('data-risrcset') || $topImage.attr('data-pfsrcset'), lazySrcset);
					assert.equal($topImage.prop('src'), nowSrc);
					done();
				}, 9);
			});
		});
	}],
	simpleSrcsetSrc: ['lazyloads srcset or src', function(assert){
		var done = assert.async();

		this.promise.always(function($, frameWindow){
			var initialSrc = 'data:initial';
			var lazySrcset = 'data:lazysrcset 300w';
			var lazySrc = 'data:lazysrc';
			var $topImage = $('')
					.attr({
						src: initialSrc,
						'data-srcset': lazySrcset,
						'data-src': lazySrc,
						'class': 'lazyload'
					}).appendTo('body')
				;

			assert.equal($topImage.prop('src'), initialSrc);
			assert.equal($topImage.attr('srcset'), null);

			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					var nowSrc =  window.HTMLPictureElement ?
						initialSrc :
						(frameWindow.respimage || frameWindow.picturefill) ?
							'data:lazysrcset' :
							lazySrc;

					assert.equal($topImage.attr('srcset') || $topImage.attr('data-risrcset') || $topImage.attr('data-pfsrcset'), lazySrcset);
					assert.equal($topImage.prop('src'), nowSrc);
					done();
				}, 9);
			});
		});
	}],
	nestedOverflow: ['lazyload detects nested overflow with [data-expand]', function(assert){
		var done = assert.async();

		this.promise.always(function($){
			var initialSrc = 'data:initial';
			var lazySrc = 'data:lazysrc';
			var $topImage = $('
' +
				'
')
					.appendTo('body')
					.find('img')
					.attr({
						src: initialSrc,
						'data-src': lazySrc,
						'class': 'lazyload',
						'data-expand': -1,
						style: 'position: relative; top: 100px;'
					})
				;

			assert.equal($topImage.prop('src'), initialSrc);

			setTimeout(function(){
				assert.equal($topImage.prop('src'), initialSrc);
				$topImage.css({top: 50});
			}, 70);
			setTimeout(function(){
				assert.equal($topImage.prop('src'), initialSrc);
				$topImage.css({top: 0});
			}, 140);

			$topImage.on('lazybeforeunveil', function(){
				setTimeout(function(){
					assert.equal($topImage.prop('src'), lazySrc);
					done();
				});
			});
		});
	}]
};

QUnit.module( "clean lazySizes", {
	beforeEach: createBeforeEach()
});
QUnit.test.apply(QUnit, lazyTests.simpleView);
QUnit.test.apply(QUnit, lazyTests.simpleScrollView);
QUnit.test.apply(QUnit, lazyTests.simpleAnimateView);
QUnit.test.apply(QUnit, lazyTests.simpleAutoSizes);
QUnit.test.apply(QUnit, lazyTests.parentAutoSizes);
QUnit.test.apply(QUnit, lazyTests.simpleSrcset);
QUnit.test.apply(QUnit, lazyTests.simpleSrcsetSrc);
QUnit.test.apply(QUnit, lazyTests.nestedOverflow);
QUnit.test.apply(QUnit, lazyTests.autoSizesEvent);
QUnit.test.apply(QUnit, lazyTests.autoSizesResize);
QUnit.test.apply(QUnit, lazyTests.simplePicture);
QUnit.test.apply(QUnit, lazyTests.simpleAutoSizesPicture);

QUnit.module( "lazySizes with respimage", {
	beforeEach: createBeforeEach({libs: ['respimage']})
});
QUnit.test.apply(QUnit, lazyTests.simpleView);
QUnit.test.apply(QUnit, lazyTests.simpleScrollView);
QUnit.test.apply(QUnit, lazyTests.simpleSrcset);
QUnit.test.apply(QUnit, lazyTests.simpleSrcsetSrc);
QUnit.test.apply(QUnit, lazyTests.autoSizesResize);
QUnit.test.apply(QUnit, lazyTests.simpleAutoSizesPicture);

QUnit.module( "lazySizes + options + respimage + respmutation", {
	beforeEach: createBeforeEach({libs: ['respimage', 'respmutation']})
});
QUnit.test.apply(QUnit, lazyTests.simpleView);
QUnit.test.apply(QUnit, lazyTests.simpleScrollView);
QUnit.test.apply(QUnit, lazyTests.simpleSrcset);
QUnit.test.apply(QUnit, lazyTests.simpleSrcsetSrc);
QUnit.test.apply(QUnit, lazyTests.autoSizesEvent);
QUnit.test.apply(QUnit, lazyTests.autoSizesResize);
QUnit.test.apply(QUnit, lazyTests.simplePicture);
QUnit.test.apply(QUnit, lazyTests.simpleAutoSizesPicture);

<|endoftext|>


<commit_before>'use strict';

var db = require('mano').db,
		user = db.User.prototype;

exports.step = function () {
	section(
		form({ class: 'section-primary' },
			h1("Add new Partenr"),
			fieldset(h2("Business Partner basic informations"),
				hr(),
				ul({ class: 'form-elements forms' },
					['firstName', 'lastName', 'dateOfBirth', 'userEmail'],
					function (name) { return field({ dbjs: user.getObservable(name) }); }
					),
				p({ class: 'submit-placeholder' },
					input({ type: 'submit' }, "Submit")
					)
				)
			)
	);

	section(
		form({ class: 'section-primary' },
				fieldset(h2("Business Partner secondary informations"),
					hr(),
					ul({ class: 'form-elements forms' },
						['companyType', 'inventory', 'surfaceArea', 'isOwner', 'businessActivity'],
						function (name) { return field({ dbjs: user.getObservable(name) }); }
						),
					p({ class: 'submit-placeholder' },
						input({ type: 'submit' }, "Submit")
						)
					)
				)
	);

	div({ class: 'next-step' },
			a({ href: '/forms/' }, "Save")
			);
};
<commit_msg>Typo fixe in paretner add page, #97<commit_after>'use strict';

var db = require('mano').db,
		user = db.User.prototype;

exports.step = function () {
	section(
		form({ class: 'section-primary' },
			h1("Add new Partner"),
			fieldset(h2("Business Partner basic informations"),
				hr(),
				ul({ class: 'form-elements forms' },
					['firstName', 'lastName', 'dateOfBirth', 'userEmail'],
					function (name) { return field({ dbjs: user.getObservable(name) }); }
					),
				p({ class: 'submit-placeholder' },
					input({ type: 'submit' }, "Submit")
					)
				)
			)
	);

	section(
		form({ class: 'section-primary' },
				fieldset(h2("Business Partner secondary informations"),
					hr(),
					ul({ class: 'form-elements forms' },
						['companyType', 'inventory', 'surfaceArea', 'isOwner', 'businessActivity'],
						function (name) { return field({ dbjs: user.getObservable(name) }); }
						),
					p({ class: 'submit-placeholder' },
						input({ type: 'submit' }, "Submit")
						)
					)
				)
	);

	div({ class: 'next-step' },
			a({ href: '/forms/' }, "Save")
			);
};
<|endoftext|>