<commit_before>// Copright (c) 2015-2018, Exa Analytics Development Team
// Distributed under the terms of the Apache License 2.0
/*"""
=================
widgets.js
=================
JavaScript 'frontend' complement of exatomic's Container for use within
the Jupyter notebook interface.
*/

'use strict';
var base = require('./base')
var utils = require('./utils')
var three = require('./appthree')
var _ = require('underscore')

export class UniverseSceneModel extends base.ExatomicSceneModel {

    defaults() {
        return {
            ...super.defaults(),
            _model_name: 'UniverseSceneModel',
            _view_name: 'UniverseSceneView'
        }
    }

}

export class UniverseSceneView extends base.ExatomicSceneView {

    init() {
        window.addEventListener('resize', this.resize.bind(this))
        this.app3d = new three.App3D(this)
        this.three_promises = this.app3d.init_promise()
        this.promises = Promise.all([
            utils.fparse(this, 'atom_x'),
            utils.fparse(this, 'atom_y'),
            utils.fparse(this, 'atom_z'),
            utils.fparse(this, 'atom_s'),
            utils.mesolv(this, 'atom_cr'),
            utils.mesolv(this, 'atom_vr'),
            utils.mesolv(this, 'atom_c'),
            utils.mesolv(this, 'atom_l'),
            utils.fparse(this, 'two_b0'),
            utils.fparse(this, 'two_b1'),
            utils.mesolv(this, 'field_i'),
            utils.mesolv(this, 'field_p'),
            utils.mesolv(this, 'field_v'),
            utils.mesolv(this, 'tensor_d')
        ])
        this.three_promises = this.app3d.finalize(this.three_promises)
            .then(this.add_atom.bind(this))
            .then(this.app3d.set_camera_from_scene.bind(this.app3d))
    }

    render() {
        return Promise.all([this.three_promises, this.promises])
    }

    add_atom() {
        this.app3d.clear_meshes('atom')
        this.app3d.clear_meshes('two')
        let fdx = this.model.get('frame_idx')
        let syms = this.atom_s[fdx]
        let colrs = utils.mapper(syms, this.atom_c)
        let atom, bond, radii, r = ((this.model.get('bond_r') > 0) ? this.model.get('bond_r') : 0.15)
        if (this.model.get('atom_3d')) {
            switch (this.model.get('fill_idx')) {
                case 0:
                    radii = utils.mapper(syms, this.atom_cr)
                                 .map((x) => { return x * 0.5 })
                    atom = this.app3d.add_spheres
                    bond = this.app3d.add_cylinders
                    break
                case 1:
                    radii = utils.mapper(syms, this.atom_vr)
                    atom = this.app3d.add_spheres
                    bond = null
                    break
                case 2:
                    radii = utils.mapper(syms, this.atom_cr)
                    atom = this.app3d.add_spheres
                    bond = this.app3d.add_cylinders
                    break
                //case 3:
                //    radii = utils.mapper(syms, this.atom_cr)
                //                    .map(function(x) { return x * 0.5; });
                //    atom = this.app3d.add_points;
                //    bond = this.app3d.add_lines;
                //    break;
                //case 4:
                //    r = 0.6
                //    radii = r + 0.05;
                //    atom = this.app3d.add_spheres;
                //    bond = this.app3d.add_cylinders;
                //    break;
                //TODO : default case
            }
        } else {
            if (this.app3d.selected.length > 0) {
                this.clearSelected()
            }
            radii = utils.mapper(syms, this.atom_cr)
                         .map((x) => { return x * 0.5 })
            atom = this.app3d.add_points
            bond = this.app3d.add_lines
        }
        let labels = utils.mapper(syms, this.atom_l)
        let entry = labels.entries()
        let a = []
        for ( let e of entry ) {
            a.push(e[1] + e[0].toString())
        }
        labels = a
        this.app3d.meshes['atom'] = atom(
            this.atom_x[fdx], this.atom_y[fdx],
            this.atom_z[fdx], colrs, radii, labels
        )
        if (this.two_b0.length !== 0) {
            this.app3d.meshes['two'] = (bond != null) ? bond(
                this.two_b0[fdx], this.two_b1[fdx],
                this.atom_x[fdx], this.atom_y[fdx],
                this.atom_z[fdx], colrs, r) : null
        }
        this.app3d.add_meshes()
    }

    add_field() {
        this.app3d.clear_meshes('field')
        let fldx = this.model.get('field_idx')
        let fdx = this.model.get('frame_idx')
        let fps = this.field_p[fdx][fldx]
        if ((!this.model.get('field_show')) ||
            (fldx === 'null') ||
            (typeof fps === 'undefined')) { return }
        let idx = this.field_i[fdx][fldx]
        let that = this
        if (typeof this.field_v[idx] === 'string') {
            utils.jsonparse(this.field_v[idx])
                .then(function(values) {
                    that.field_v[idx] = values;
                    that.app3d.meshes['field'] = that.app3d.add_scalar_field(
                        utils.scalar_field(
                            utils.gen_field_arrays(fps),
                            values),
                    that.model.get('field_iso'),
                    that.model.get('field_o'), 2,
                    that.colors());
                    that.app3d.add_meshes('field')
                })
        } else {
            this.app3d.meshes['field'] = this.app3d.add_scalar_field(
                utils.scalar_field(
                    utils.gen_field_arrays(fps),
                    this.field_v[idx]),
                this.model.get('field_iso'),
                this.model.get('field_o'), 2,
                this.colors());
            this.app3d.add_meshes('field')
        }
    }

    add_contour() {
        this.app3d.clear_meshes('contour')
        let fldx = this.model.get('field_idx')
        // Specifically test for string null
        let fdx = this.model.get('frame_idx')
        let idx = this.field_i[fdx][fldx]
        let fps = this.field_p[fdx][fldx]
        if ((!this.model.get('cont_show')) ||
            (fldx === 'null') ||
            (typeof fps === 'undefined')) { return }
        let that = this
        if (typeof this.field_v[idx] === 'string') {
            utils.jsonparse(this.field_v[idx])
                .then(function(values) {
                    that.field_v[idx] = values
                    that.app3d.meshes['contour'] = that.app3d.add_contour(
                        utils.scalar_field(
                            utils.gen_field_arrays(fps),
                            values),
                        that.model.get('cont_num'),
                        that.model.get('cont_lim'),
                        that.model.get('cont_axis'),
                        that.model.get('cont_val'),
                        that.colors())
                    that.app3d.add_meshes('contour')
                })
        } else {
            this.app3d.meshes['contour'] = this.app3d.add_contour(
                utils.scalar_field(
                    utils.gen_field_arrays(fps),
                    this.field_v[idx]),
                this.model.get('cont_num'),
                this.model.get('cont_lim'),
                this.model.get('cont_axis'),
                this.model.get('cont_val'),
                this.colors());
            that.app3d.add_meshes('contour')
        }
    }

    add_axis() {
        // Additionally adds the unit cell
        this.app3d.clear_meshes('generic')
        if (this.model.get('axis')) {
            this.app3d.meshes['generic'] = this.app3d.add_unit_axis(
                this.model.get('atom_3d'))
        }
        this.app3d.add_meshes('generic')
    }

    get_tensor(fdx, tdx) {
        let t = this.tensor_d[fdx][tdx]
        return [[t['xx'], t['xy'], t['xz']],
                [t['yx'], t['yy'], t['yz']],
                [t['zx'], t['zy'], t['zz']]]
    }

    color_tensor() {
        let tdx = this.model.get('tidx')
        let fdx = this.model.get('frame_idx')
        let color
        for ( let property in this.tensor_d[fdx] ) {
            if ( this.tensor_d[fdx].hasOwnProperty( property ) ) {
                if ( parseInt(property) === tdx ) {
                    color = 0xafafaf
                } else { color = 0x000000 }
                if ( this.model.get('tens') ) {
                    this.app3d.meshes['tensor' + property][0].children[0].material.color.setHex(color)
                }
            }
        }
    }

    add_tensor() {
        let scaling = this.model.get('scale')
        let fdx = this.model.get('frame_idx')
        for ( let property in this.tensor_d[fdx] ) {
            if ( this.tensor_d[fdx].hasOwnProperty( property ) ) {
                this.app3d.clear_meshes('tensor' + property)
                let adx = this.tensor_d[fdx][property]['atom']
                if ( this.model.get('tens') ) {
                    this.app3d.meshes['tensor' + property] =
                                this.app3d.add_tensor_surface(
                                    this.get_tensor(fdx, property),
                                    this.colors(),
                                    this.atom_x[fdx][adx],
                                    this.atom_y[fdx][adx],
                                    this.atom_z[fdx][adx],
                                    scaling,
                                    this.tensor_d[fdx][property]['label'] + ' tensor ' + property.toString())
                }
                this.app3d.add_meshes('tensor' + property)
            }
        }
        // if (this.model.get('tens')) {this.color_tensor();}
    }

    // events: {
    //     'click': 'handleClick'
    // },

    handleClick(event) {
        // Handles click event to write data to a Python traitlet value
        event.preventDefault()
        let idx = this.app3d.selected.map((obj) => { return obj.name })
        let type = this.app3d.selected.map((obj) => { return obj.geometry.type })
        this.model.set('selected', { idx, type }) // Types must match exactly
        this.touch()
    }

    clearSelected() {
        this.app3d.reset_colors()
        this.app3d.selected = []
        this.model.set('selected', {})
        this.touch()
    }

    init_listeners() {
        super.init_listeners()
        // base.ExatomicSceneView.prototype.init_listeners.call(this)
        this.listenTo(this.model, 'change:frame_idx', this.add_atom)
        this.listenTo(this.model, 'change:atom_3d', this.add_atom)
        this.listenTo(this.model, 'change:field_idx', this.add_field)
        this.listenTo(this.model, 'change:field_show', this.add_field)
        this.listenTo(this.model, 'change:field_idx', this.add_contour)
        this.listenTo(this.model, 'change:cont_show', this.add_contour)
        this.listenTo(this.model, 'change:cont_axis', this.add_contour)
        this.listenTo(this.model, 'change:cont_num', this.add_contour)
        this.listenTo(this.model, 'change:cont_lim', this.add_contour)
        this.listenTo(this.model, 'change:cont_val', this.add_contour)
        this.listenTo(this.model, 'change:atom_3d', this.add_axis)
        this.listenTo(this.model, 'change:axis', this.add_axis)
        this.listenTo(this.model, 'change:tens', this.add_tensor)
        this.listenTo(this.model, 'change:scale', this.add_tensor)
        this.listenTo(this.model, 'change:tidx', this.color_tensor)
        this.listenTo(this.model, 'change:fill_idx', this.add_atom)
        this.listenTo(this.model, 'change:bond_r', this.add_atom)
        this.listenTo(this.model, 'change:clear_selected', this.clearSelected)
    }
}
<commit_msg>eslint fix widgets.js<commit_after>// Copright (c) 2015-2018, Exa Analytics Development Team
// Distributed under the terms of the Apache License 2.0
/* """
=================
widgets.js
=================
JavaScript 'frontend' complement of exatomic's Container for use within
the Jupyter notebook interface.
*/

const _ = require('underscore')
const base = require('./base')
const utils = require('./utils')
const three = require('./appthree')

export class UniverseSceneModel extends base.ExatomicSceneModel {
    defaults() {
        return {
            ...super.defaults(),
            _model_name: 'UniverseSceneModel',
            _view_name: 'UniverseSceneView',
        }
    }
}

export class UniverseSceneView extends base.ExatomicSceneView {
    init() {
        window.addEventListener('resize', this.resize.bind(this))
        this.app3d = new three.App3D(this)
        this.three_promises = this.app3d.init_promise()
        this.promises = Promise.all([
            utils.fparse(this, 'atom_x'),
            utils.fparse(this, 'atom_y'),
            utils.fparse(this, 'atom_z'),
            utils.fparse(this, 'atom_s'),
            utils.mesolv(this, 'atom_cr'),
            utils.mesolv(this, 'atom_vr'),
            utils.mesolv(this, 'atom_c'),
            utils.mesolv(this, 'atom_l'),
            utils.fparse(this, 'two_b0'),
            utils.fparse(this, 'two_b1'),
            utils.mesolv(this, 'field_i'),
            utils.mesolv(this, 'field_p'),
            utils.mesolv(this, 'field_v'),
            utils.mesolv(this, 'tensor_d'),
        ])
        this.three_promises = this.app3d.finalize(this.three_promises)
            .then(this.add_atom.bind(this))
            .then(this.app3d.set_camera_from_scene.bind(this.app3d))
    }

    render() {
        return Promise.all([this.three_promises, this.promises])
    }

    add_atom() {
        this.app3d.clear_meshes('atom')
        this.app3d.clear_meshes('two')
        const fdx = this.model.get('frame_idx')
        const syms = this.atom_s[fdx]
        const colrs = utils.mapper(syms, this.atom_c)
        let atom; let bond; let radii; const
            r = ((this.model.get('bond_r') > 0) ? this.model.get('bond_r') : 0.15)
        if (this.model.get('atom_3d')) {
            switch (this.model.get('fill_idx')) {
            case 0:
                radii = utils.mapper(syms, this.atom_cr)
                    .map((x) => x * 0.5)
                atom = this.app3d.add_spheres
                bond = this.app3d.add_cylinders
                break
            case 1:
                radii = utils.mapper(syms, this.atom_vr)
                atom = this.app3d.add_spheres
                bond = null
                break
            case 2:
                radii = utils.mapper(syms, this.atom_cr)
                atom = this.app3d.add_spheres
                bond = this.app3d.add_cylinders
                break
                // case 3:
                //    radii = utils.mapper(syms, this.atom_cr)
                //                    .map(function(x) { return x * 0.5; });
                //    atom = this.app3d.add_points;
                //    bond = this.app3d.add_lines;
                //    break;
                // case 4:
                //    r = 0.6
                //    radii = r + 0.05;
                //    atom = this.app3d.add_spheres;
                //    bond = this.app3d.add_cylinders;
                //    break;
                // TODO : default case
            }
        } else {
            if (this.app3d.selected.length > 0) {
                this.clearSelected()
            }
            radii = utils.mapper(syms, this.atom_cr)
                .map((x) => x * 0.5)
            atom = this.app3d.add_points
            bond = this.app3d.add_lines
        }
        let labels = utils.mapper(syms, this.atom_l)
        const entry = labels.entries()
        const a = []
        for (const e of entry) {
            a.push(e[1] + e[0].toString())
        }
        labels = a
        this.app3d.meshes.atom = atom(
            this.atom_x[fdx], this.atom_y[fdx],
            this.atom_z[fdx], colrs, radii, labels,
        )
        if (this.two_b0.length !== 0) {
            this.app3d.meshes.two = (bond != null) ? bond(
                this.two_b0[fdx], this.two_b1[fdx],
                this.atom_x[fdx], this.atom_y[fdx],
                this.atom_z[fdx], colrs, r,
            ) : null
        }
        this.app3d.add_meshes()
    }

    add_field() {
        this.app3d.clear_meshes('field')
        const fldx = this.model.get('field_idx')
        const fdx = this.model.get('frame_idx')
        const fps = this.field_p[fdx][fldx]
        if ((!this.model.get('field_show'))
            || (fldx === 'null')
            || (typeof fps === 'undefined')) { return }
        const idx = this.field_i[fdx][fldx]
        const that = this
        if (typeof this.field_v[idx] === 'string') {
            utils.jsonparse(this.field_v[idx])
                .then((values) => {
                    that.field_v[idx] = values
                    that.app3d.meshes.field = that.app3d.add_scalar_field(
                        utils.scalar_field(
                            utils.gen_field_arrays(fps),
                            values,
                        ),
                        that.model.get('field_iso'),
                        that.model.get('field_o'), 2,
                        that.colors(),
                    )
                    that.app3d.add_meshes('field')
                })
        } else {
            this.app3d.meshes.field = this.app3d.add_scalar_field(
                utils.scalar_field(
                    utils.gen_field_arrays(fps),
                    this.field_v[idx],
                ),
                this.model.get('field_iso'),
                this.model.get('field_o'), 2,
                this.colors(),
            )
            this.app3d.add_meshes('field')
        }
    }

    add_contour() {
        this.app3d.clear_meshes('contour')
        const fldx = this.model.get('field_idx')
        // Specifically test for string null
        const fdx = this.model.get('frame_idx')
        const idx = this.field_i[fdx][fldx]
        const fps = this.field_p[fdx][fldx]
        if ((!this.model.get('cont_show'))
            || (fldx === 'null')
            || (typeof fps === 'undefined')) { return }
        const that = this
        if (typeof this.field_v[idx] === 'string') {
            utils.jsonparse(this.field_v[idx])
                .then((values) => {
                    that.field_v[idx] = values
                    that.app3d.meshes.contour = that.app3d.add_contour(
                        utils.scalar_field(
                            utils.gen_field_arrays(fps),
                            values,
                        ),
                        that.model.get('cont_num'),
                        that.model.get('cont_lim'),
                        that.model.get('cont_axis'),
                        that.model.get('cont_val'),
                        that.colors(),
                    )
                    that.app3d.add_meshes('contour')
                })
        } else {
            this.app3d.meshes.contour = this.app3d.add_contour(
                utils.scalar_field(
                    utils.gen_field_arrays(fps),
                    this.field_v[idx],
                ),
                this.model.get('cont_num'),
                this.model.get('cont_lim'),
                this.model.get('cont_axis'),
                this.model.get('cont_val'),
                this.colors(),
            )
            that.app3d.add_meshes('contour')
        }
    }

    add_axis() {
        // Additionally adds the unit cell
        this.app3d.clear_meshes('generic')
        if (this.model.get('axis')) {
            this.app3d.meshes.generic = this.app3d.add_unit_axis(
                this.model.get('atom_3d'),
            )
        }
        this.app3d.add_meshes('generic')
    }

    get_tensor(fdx, tdx) {
        const t = this.tensor_d[fdx][tdx]
        return [[t.xx, t.xy, t.xz],
            [t.yx, t.yy, t.yz],
            [t.zx, t.zy, t.zz]]
    }

    color_tensor() {
        const tdx = this.model.get('tidx')
        const fdx = this.model.get('frame_idx')
        let color
        for (const property in this.tensor_d[fdx]) {
            if (this.tensor_d[fdx].hasOwnProperty(property)) {
                if (parseInt(property) === tdx) {
                    color = 0xafafaf
                } else { color = 0x000000 }
                if (this.model.get('tens')) {
                    this.app3d.meshes[`tensor${property}`][0].children[0].material.color.setHex(color)
                }
            }
        }
    }

    add_tensor() {
        const scaling = this.model.get('scale')
        const fdx = this.model.get('frame_idx')
        for (const property in this.tensor_d[fdx]) {
            if (this.tensor_d[fdx].hasOwnProperty(property)) {
                this.app3d.clear_meshes(`tensor${property}`)
                const adx = this.tensor_d[fdx][property].atom
                if (this.model.get('tens')) {
                    this.app3d.meshes[`tensor${property}`] = this.app3d.add_tensor_surface(
                        this.get_tensor(fdx, property),
                        this.colors(),
                        this.atom_x[fdx][adx],
                        this.atom_y[fdx][adx],
                        this.atom_z[fdx][adx],
                        scaling,
                        `${this.tensor_d[fdx][property].label} tensor ${property.toString()}`,
                    )
                }
                this.app3d.add_meshes(`tensor${property}`)
            }
        }
        // if (this.model.get('tens')) {this.color_tensor();}
    }

    // events: {
    //     'click': 'handleClick'
    // },

    handleClick(event) {
        // Handles click event to write data to a Python traitlet value
        event.preventDefault()
        const idx = this.app3d.selected.map((obj) => obj.name)
        const type = this.app3d.selected.map((obj) => obj.geometry.type)
        this.model.set('selected', { idx, type }) // Types must match exactly
        this.touch()
    }

    clearSelected() {
        this.app3d.reset_colors()
        this.app3d.selected = []
        this.model.set('selected', {})
        this.touch()
    }

    init_listeners() {
        super.init_listeners()
        // base.ExatomicSceneView.prototype.init_listeners.call(this)
        this.listenTo(this.model, 'change:frame_idx', this.add_atom)
        this.listenTo(this.model, 'change:atom_3d', this.add_atom)
        this.listenTo(this.model, 'change:field_idx', this.add_field)
        this.listenTo(this.model, 'change:field_show', this.add_field)
        this.listenTo(this.model, 'change:field_idx', this.add_contour)
        this.listenTo(this.model, 'change:cont_show', this.add_contour)
        this.listenTo(this.model, 'change:cont_axis', this.add_contour)
        this.listenTo(this.model, 'change:cont_num', this.add_contour)
        this.listenTo(this.model, 'change:cont_lim', this.add_contour)
        this.listenTo(this.model, 'change:cont_val', this.add_contour)
        this.listenTo(this.model, 'change:atom_3d', this.add_axis)
        this.listenTo(this.model, 'change:axis', this.add_axis)
        this.listenTo(this.model, 'change:tens', this.add_tensor)
        this.listenTo(this.model, 'change:scale', this.add_tensor)
        this.listenTo(this.model, 'change:tidx', this.color_tensor)
        this.listenTo(this.model, 'change:fill_idx', this.add_atom)
        this.listenTo(this.model, 'change:bond_r', this.add_atom)
        this.listenTo(this.model, 'change:clear_selected', this.clearSelected)
    }
}
<|endoftext|>


<commit_before>/*
 * sticky-form.js
 *
 * Sticks the reply form to the bottom right edge of the screen.
 * This file contains a lot of features and really needs to be cleaned up, I'll do it a bit later.
 *
 * Usage:
 *   $config['additional_javascript'][] = 'js/jquery.min.js';
 *   $config['additional_javascript'][] = 'js/jquery.textareaCounter.plugin.js';
 *   $config['additional_javascript'][] = 'js/jquery.form.js';
 *   $config['additional_javascript'][] = 'js/sticky-form.js';
 *
 */

var clearForm = function() {
	$('#body, input[name="file"], input[name="file_url"], input[name="embed"]').val('');
}

$(document).ready(function () {
	var postform = $('form[name="post"]');
	if  (settings.stickyForm) {
        postform.attr('id', 'quick-reply');
		postform.css({
			"position": 'fixed',
			"bottom": '0px',
			"right": '0px',
			"margin-bottom": '30px',
			'background': '#AAAAAA',
		});

		if (settings.simpleNavbar) {
            var hideButton = '';
            var showButton = '';
            var upButton = '';
            var downButton = '';
        } else if (device_type == "mobile") {
            var hideButton = '';
            var showButton = '';
            var upButton = '';
            var downButton = '';
        } else {
            var hideButton = ' '+ _(' Спрятать');
            var showButton = ' ' + _(' Открыть');
            var upButton = ' ' + _(' Поднять');
            var downButton = ' ' + _(' Опустить');
        }

		$('#toggleForm').click(function () {
			var link = $(this);
			postform.slideToggle("100", function () {
				if ($(this).is(":visible")) {
					link.html(hideButton);
					localStorage.setItem("displayForm", true);
				} else {
					link.html(showButton);
					localStorage.setItem("displayForm", false);
				}
			});
		});
		if (localStorage.getItem("displayForm") == 'false') {
			postform.hide();
			$('#toggleForm').html(showButton)
		};
		$('#formPosition').toggle(function () {
			$(this).html(downButton);
			localStorage.setItem("formPosition", 'up');
			postform.css({
				"top": "0px",
				"bottom": "auto"
			});
		}, function () {
			$(this).html(upButton);
			localStorage.setItem("formPosition", 'down');
			postform.css({
				"bottom": "0px",
				"top": "auto"
			});
		});
		if (localStorage.getItem("formPosition") == 'up') {
			$('#formPosition').html(downButton);
			postform.css({
				"top": "0px",
				"bottom": "auto"
			});
		};
		$('.banner').hide();
		if (settings.simpleForm) {
			$('form[name=post] th').hide();
			$('label[for="spoiler"]').text(_('Spoiler'));
			$('input[name=name]').attr('placeholder', _('Имя (оставьте пустым)'));
			$('input[name=email]').attr('placeholder', _('Email (или sage)'));
			$('input[name=subject]').attr('placeholder', _('Тема'));
			$('input[name=body]').attr('placeholder', _('Введите сообщение'));
			$('input[name=embed]').attr('placeholder', _('Youtube/Pleer'));
			$('form[name=post] input[name=password]').hide();
			$('input[name="email"]').appendTo($('input[name="name"]').parent());
			$('input[name="email"], input[name="name"]').attr('size',18);
			$('input[name="subject"]').attr('size',28);
			$('input[name="spoiler"], label[for="spoiler"]').appendTo($('input[name="file"]').parent());
            $('form[name=post]').css({ "padding": '0px!important' });
            $('form[name=post] table').css({ "border-spacing": '0px' });
            $('form[name=post] input[type=text]').css({ "height": '17px' });
            $('input[name=embed]').css({ "width": 'calc(100% - 2px)' });
            $('textarea[name=body]').css({ "width": 'calc(100% - 6px)' });
            $('input[name=name]').css({ "width": '49%' });
            $('input[name=email]').css({ "width": '49%', "float": 'right' });
            $('input[name=post]').css({ "float": 'right' });
            $('input[name=subject]').css({ "width": '49%' });
		}

		if (device_type == "mobile") {
			postform.css({ "margin-bottom": '50px', });
			$('input[name=password]').remove();
		}
	}

	if (settings.autoResizeForm) {
		$('textarea').css({ "resize": 'horizontal', "overflow": 'hidden' });
		$('textarea').keyup(function(){
			$(this).height(80); // min-height
			$(this).height(this.scrollHeight);
		});
	}

	// No refresh with jQuery Form Plugin
	if (settings.noRefresh) {
		var ajaxErrors = false;
		$('form[name="post"]').ajaxForm({
			beforeSend: function() {
				var percentVal = '0%';
			},
			uploadProgress: function(event, position, total, percentComplete) {
				var percentVal = percentComplete + '%';
				$('input[name=post]').attr("disabled", true);
				$('input[name=post]').attr('value',_('Отправка: ') + percentVal);
			},
			success: function(response, textStatus, xhr, form) {
				console.log($('response').contents().find('h1').text());
			},
			error: function(xhr, textStatus, errorThrown) {
				console.log("Lol something bad just happened");
			},
			complete: function(xhr, textStatus) {
				if (!(ajaxErrors)) {
					clearForm();
                    if (typeof Recaptcha != 'undefined') {
                        Recaptcha.reload();
                    }
                    if ($('#captchaimg')) {
                        $('#captchaimg').click();
                    }
					$('input[name=post]').attr("disabled", false);
					$('input[name=post]').attr('value',_('Ответить'));
				}
			}
		});

	}
	if (settings.textCountForm) {
		$('#body').textareaCount({
			'maxCharacterSize': 4000,
			'originalStyle': 'originalDisplayInfo',
			'displayFormat': _('#input символов | #left осталось')
		});
		$(".originalDisplayInfo").css({
			"font-size": '0.7em',
			"clear": 'both',
		});
	}
	if (settings.showFormOnCite) {
		$(window).on('cite', function() {
			if (localStorage.getItem("displayForm") == 'false') {
				postform.show();
				$('#toggleForm').html(hideButton);
				localStorage.setItem("displayForm", true);
			};
			$('textarea').height(this.scrollHeight);
		});
	}
});<commit_msg>force sticky-form to work only in a reply form<commit_after>/*
 * sticky-form.js
 *
 * Sticks the reply form to the bottom right edge of the screen.
 * This file contains a lot of features and really needs to be cleaned up, I'll do it a bit later.
 *
 * Usage:
 *   $config['additional_javascript'][] = 'js/jquery.min.js';
 *   $config['additional_javascript'][] = 'js/jquery.textareaCounter.plugin.js';
 *   $config['additional_javascript'][] = 'js/jquery.form.js';
 *   $config['additional_javascript'][] = 'js/sticky-form.js';
 *
 */

var clearForm = function() {
	$('#body, input[name="file"], input[name="file_url"], input[name="embed"]').val('');
}

$(document).ready(function () {
	var postform = $('form[name="post"]');
	if  (settings.stickyForm) {
        postform.attr('id', 'quick-reply');
		postform.css({
			"position": 'fixed',
			"bottom": '0px',
			"right": '0px',
			"margin-bottom": '30px',
			'background': '#AAAAAA',
		});

		if (settings.simpleNavbar) {
            var hideButton = '';
            var showButton = '';
            var upButton = '';
            var downButton = '';
        } else if (device_type == "mobile") {
            var hideButton = '';
            var showButton = '';
            var upButton = '';
            var downButton = '';
        } else {
            var hideButton = ' '+ _(' Спрятать');
            var showButton = ' ' + _(' Открыть');
            var upButton = ' ' + _(' Поднять');
            var downButton = ' ' + _(' Опустить');
        }

		$('#toggleForm').click(function () {
			var link = $(this);
			postform.slideToggle("100", function () {
				if ($(this).is(":visible")) {
					link.html(hideButton);
					localStorage.setItem("displayForm", true);
				} else {
					link.html(showButton);
					localStorage.setItem("displayForm", false);
				}
			});
		});
		if (localStorage.getItem("displayForm") == 'false') {
			postform.hide();
			$('#toggleForm').html(showButton)
		};
		$('#formPosition').toggle(function () {
			$(this).html(downButton);
			localStorage.setItem("formPosition", 'up');
			postform.css({
				"top": "0px",
				"bottom": "auto"
			});
		}, function () {
			$(this).html(upButton);
			localStorage.setItem("formPosition", 'down');
			postform.css({
				"bottom": "0px",
				"top": "auto"
			});
		});
		if (localStorage.getItem("formPosition") == 'up') {
			$('#formPosition').html(downButton);
			postform.css({
				"top": "0px",
				"bottom": "auto"
			});
		};
		$('.banner').hide();
		if (settings.simpleForm) {
			$('form[name=post] th').hide();
			$('label[for="spoiler"]').text(_('Spoiler'));
			$('input[name=name]').attr('placeholder', _('Имя (оставьте пустым)'));
			$('input[name=email]').attr('placeholder', _('Email (или sage)'));
			$('input[name=subject]').attr('placeholder', _('Тема'));
			$('input[name=body]').attr('placeholder', _('Введите сообщение'));
			$('input[name=embed]').attr('placeholder', _('Youtube/Pleer'));
			$('form[name=post] input[name=password]').hide();
			$('input[name="email"]').appendTo($('input[name="name"]').parent());
			$('input[name="email"], input[name="name"]').attr('size',18);
			$('input[name="subject"]').attr('size',28);
			$('input[name="spoiler"], label[for="spoiler"]').appendTo($('input[name="file"]').parent());
            $('form[name=post]').css({ "padding": '0px!important' });
            $('form[name=post] table').css({ "border-spacing": '0px' });
            $('input[name=embed]').css({ "width": 'calc(100% - 2px)' });
            $('textarea[name=body]').css({ "width": 'calc(100% - 6px)' });
            $('input[name=name]').css({ "width": '49%' });
            $('input[name=email]').css({ "width": '49%', "float": 'right' });
            $('input[name=post]').css({ "float": 'right' });
            $('input[name=subject]').css({ "width": '49%' });
		}

		if (device_type == "mobile") {
			postform.css({ "margin-bottom": '50px', });
			$('input[name=password]').remove();
		}
	}

	if (settings.autoResizeForm) {
		$('textarea[name="body"]').css({ "resize": 'horizontal', "overflow": 'hidden' });
		$('textarea[name="body"]').keyup(function(){
			$(this).height(80); // min-height
			$(this).height(this.scrollHeight);
		});
	}

	// No refresh with jQuery Form Plugin
	if (settings.noRefresh) {
		var ajaxErrors = false;
		$('form[name="post"]').ajaxForm({
			beforeSend: function() {
				var percentVal = '0%';
			},
			uploadProgress: function(event, position, total, percentComplete) {
				var percentVal = percentComplete + '%';
				$('input[name=post]').attr("disabled", true);
				$('input[name=post]').attr('value',_('Отправка: ') + percentVal);
			},
			success: function(response, textStatus, xhr, form) {
				console.log($('response').contents().find('h1').text());
			},
			error: function(xhr, textStatus, errorThrown) {
				console.log("Lol something bad just happened");
			},
			complete: function(xhr, textStatus) {
				if (!(ajaxErrors)) {
					clearForm();
                    if (typeof Recaptcha != 'undefined') {
                        Recaptcha.reload();
                    }
                    if ($('#captchaimg')) {
                        $('#captchaimg').click();
                    }
					$('input[name=post]').attr("disabled", false);
					$('input[name=post]').attr('value',_('Ответить'));
				}
			}
		});

	}
	if (settings.textCountForm) {
		$('#body').textareaCount({
			'maxCharacterSize': 4000,
			'originalStyle': 'originalDisplayInfo',
			'displayFormat': _('#input символов | #left осталось')
		});
		$(".originalDisplayInfo").css({
			"font-size": '0.7em',
			"clear": 'both',
		});
	}
	if (settings.showFormOnCite) {
		$(window).on('cite', function() {
			if (localStorage.getItem("displayForm") == 'false') {
				postform.show();
				$('#toggleForm').html(hideButton);
				localStorage.setItem("displayForm", true);
			};
			$('textarea').height(this.scrollHeight);
		});
	}
});<|endoftext|>


<commit_before>
var margin = {top: 20, right: 20, bottom: 30, left: 50},
    width = 960 - margin.left - margin.right,
    height = 500 - margin.top - margin.bottom;

var x = d3.scale.ordinal()
    .range([0, width]);

var y = d3.scale.linear()
    .range([height, 0]);

var color = d3.scale.category20();

var xAxis = d3.svg.axis()
    .scale(x)
    .orient("bottom");

var yAxis = d3.svg.axis()
    .scale(y)
    .orient("left");

var area = d3.svg.area()
    .x(function(d) { return x(d.yearCol); })
    .y0(function(d) { return y(d.y0); })
    .y1(function(d) { return y(d.y0 + d.y); });

var stack = d3.layout.stack()
    .values(function(d) { return d.values; });

var svg = d3.select("body").append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)
  .append("g")
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

d3.csv('Words_allyears_26oct.csv', function(error, data){

  var list = ['war', 'bomb', 'blast'];

  var data = $.map(data, function(element){
    return ($.inArray(element.wordCol,list)>-1?element:null)
  });

  data.forEach(function(d){
    d.countCol = +d.countCol;
    d.yearCol = +d.yearCol;
  });

  console.log(data);

  function complete(x, key){
    x = x.filter(function(d){ return d.wordCol == key; });
    yearsPresent = []
    years = [];
    for (i=1955; i<2010; i++){
      years.push(i)
      for (j=0; j<x.length; j++){
        if (x[j].yearCol === i){
          yearsPresent.push(i);
        }
      }
    }
    for (i=0; i<years.length; i++){
      if (yearsPresent.indexOf(years[i]) < 0){
        dict = {}
        dict['countCol'] = 0;
        dict['wordCol'] = x[0].wordCol;
        dict['yearCol'] = years[i];
        data.push(dict);
      }
    }
    //return data;
  };

  for (i=0; i<list.length; i++){
    complete(data, list[i]);
  };

  console.log(data);

  /*

  data = d3.nest()
            .key(function(d){ return d.wordCol; })
            .entries(data);
  */

})

  <commit_msg>update data<commit_after>
var margin = {top: 20, right: 20, bottom: 30, left: 50},
    width = 960 - margin.left - margin.right,
    height = 500 - margin.top - margin.bottom;

var x = d3.scale.ordinal()
    .range([0, width]);

var y = d3.scale.linear()
    .range([height, 0]);

var color = d3.scale.category20();

var xAxis = d3.svg.axis()
    .scale(x)
    .orient("bottom");

var yAxis = d3.svg.axis()
    .scale(y)
    .orient("left");

var area = d3.svg.area()
    .x(function(d) { return x(d.yearCol); })
    .y0(function(d) { return y(d.y0); })
    .y1(function(d) { return y(d.y0 + d.y); });

var stack = d3.layout.stack()
    .values(function(d) { return d.values; });

var svg = d3.select("body").append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)
  .append("g")
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

d3.csv('Words_allyears_26oct.csv', function(error, data){

  var list = ['war', 'bomb', 'blast'];

  var data = $.map(data, function(element){
    return ($.inArray(element.wordCol,list)>-1?element:null)
  });

  data.forEach(function(d){
    d.countCol = +d.countCol;
    d.yearCol = +d.yearCol;
  });

  console.log(data);

  function complete(x, key){
    x = x.filter(function(d){ return d.wordCol == key; });
    yearsPresent = []
    years = [];
    for (i=1955; i<2010; i++){
      years.push(i)
      for (j=0; j<x.length; j++){
        if (x[j].yearCol === i){
          yearsPresent.push(i);
        }
      }
    }
    for (i=0; i<years.length; i++){
      if (yearsPresent.indexOf(years[i]) < 0){
        dict = {}
        dict['countCol'] = 0;
        dict['wordCol'] = x[0].wordCol;
        dict['yearCol'] = years[i];
        data.push(dict);
      }
    }
    //return data;
  };

  for (i=0; i<list.length; i++){
    complete(data, list[i]);
  };
  complete(data, "war");
  complete(data, "blast");
  complete(data, "bomb");

  console.log(data);

  /*

  data = d3.nest()
            .key(function(d){ return d.wordCol; })
            .entries(data);
  */

})

  <|endoftext|>


<commit_before>
var margin = {top: 20, right: 20, bottom: 30, left: 50},
    width = 860 - margin.left - margin.right,
    height = 500 - margin.top - margin.bottom;

var x = d3.scale.linear()
    .range([0, width]);

var y = d3.scale.linear()
    .range([height, 0]);

var color = d3.scale.category20();

var xAxis = d3.svg.axis()
    .scale(x)
    .orient("bottom");

var yAxis = d3.svg.axis()
    .scale(y)
    .orient("left");

var stack = d3.layout.stack()
  .offset('zero')
  .values(function(d){ return d.values; })
  .x(function(d){ return d.yearCol; })
  .y(function(d){ return d.countCol; });

var area = d3.svg.area()
    .interpolate('cardinal')
    .x(function(d) { return x(d.yearCol); })
    .y0(function(d) { return y(d.y0); })
    .y1(function(d) { return y(d.y0 + d.y); });

var svg = d3.select("div#chart").append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)
  .append("g")
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

d3.csv('Words_allyears_26oct.csv', function(error, data){

  var list = ['war', 'bomb', 'blast'];
  color.domain(list);

  var data = $.map(data, function(element){
    return ($.inArray(element.wordCol,list)>-1?element:null)
  });

  data.forEach(function(d){
    d.countCol = +d.countCol;
    d.yearCol = d.yearCol;
  });

  function complete(x, key){
    for (i=0; i<key.length; i++){
      tempdata = x.filter(function(d){ return d.wordCol == key[i]; });
      yearsPresent = []
      years = [];

      for (year=1955; year<2010; year++){
        years.push(year)
        for (row=0; row<tempdata.length; row++){
          if (tempdata[row].yearCol === year){
            yearsPresent.push(year);
          }
        }
      }

      for (year=0; year<years.length; year++){
        if (yearsPresent.indexOf(years[year]) < 0){
          dict = {}
          dict['countCol'] = 0;
          dict['wordCol'] = tempdata[0].wordCol;
          dict['yearCol'] = years[year];
          data.push(dict);
        }
      }
    }

  };
  complete(data, list);

  var nest = d3.nest()
    .key(function(d){ return d.wordCol; })
    .sortValues(function(a,b){ return parseFloat(a.yearCol) - parseFloat(b.yearCol); })
    .entries(data);

  var layers = stack(nest);

  x.domain(d3.extent(data, function(d){ return d.yearCol; }));
  y.domain([0, d3.max(data, function(d){ return d.y0 + d.y; })]);

  svg.selectAll(".layer")
      .data(layers)
    .enter().append("path")
      .attr("class", "layer")
      .attr("d", function(d) { return area(d.values); })
      .style("fill", function(d, i) { return color(i); });

  svg.append("g")
      .attr("class", "x axis")
      .attr("transform", "translate(0," + height + ")")
      .call(xAxis);

  svg.append("g")
      .attr("class", "y axis")
      .call(yAxis);

});

  <commit_msg>update data<commit_after>
var margin = {top: 20, right: 20, bottom: 30, left: 50},
    width = 860 - margin.left - margin.right,
    height = 500 - margin.top - margin.bottom;

var x = d3.scale.linear()
    .range([0, width]);

var y = d3.scale.linear()
    .range([height, 0]);

var color = d3.scale.category20();

var xAxis = d3.svg.axis()
    .scale(x)
    .orient("bottom");

var yAxis = d3.svg.axis()
    .scale(y)
    .orient("left");

var stack = d3.layout.stack()
  .offset('zero')
  .values(function(d){ return d.values; })
  .x(function(d){ return d.yearCol; })
  .y(function(d){ return d.countCol; });

var area = d3.svg.area()
    .interpolate('cardinal')
    .x(function(d) { return x(d.yearCol); })
    .y0(function(d) { return y(d.y0); })
    .y1(function(d) { return y(d.y0 + d.y); });

var svg = d3.select("div#chart").append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)
  .append("g")
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

d3.csv('Words_allyears_26oct.csv', function(error, data){

  var list = ['war', 'bomb', 'blast'];
  color.domain(list);

  var data = $.map(data, function(element){
    return ($.inArray(element.wordCol,list)>-1?element:null)
  });

  data.forEach(function(d){
    d.countCol = +d.countCol;
    d.yearCol = d.yearCol;
  });

  function complete(x, key){
    for (i=0; i<key.length; i++){
      tempdata = x.filter(function(d){ return d.wordCol == key[i]; });
      yearsPresent = []
      years = [];

      for (year=1955; year<2010; year++){
        years.push(year)
        for (row=0; row<tempdata.length; row++){
          if (tempdata[row].yearCol === year){
            yearsPresent.push(year);
          }
        }
      }

      for (year=0; year<years.length; year++){
        if (yearsPresent.indexOf(years[year]) < 0){
          dict = {}
          dict['countCol'] = 0;
          dict['wordCol'] = tempdata[0].wordCol;
          dict['yearCol'] = years[year];
          data.push(dict);
        }
      }
    }

  };
  complete(data, list);

  var nest = d3.nest()
    .key(function(d){ return d.wordCol; })
    .sortValues(function(a,b){ return parseFloat(a.yearCol) - parseFloat(b.yearCol); })
    .entries(data);

  console.log(nest);

  var layers = stack(nest);

  x.domain(d3.extent(data, function(d){ return d.yearCol; }));
  y.domain([0, d3.max(data, function(d){ return d.y0 + d.y; })]);

  svg.selectAll(".layer")
      .data(layers)
    .enter().append("path")
      .attr("class", "layer")
      .attr("d", function(d) { return area(d.values); })
      .style("fill", function(d, i) { return color(i); });

  svg.append("g")
      .attr("class", "x axis")
      .attr("transform", "translate(0," + height + ")")
      .call(xAxis);

  svg.append("g")
      .attr("class", "y axis")
      .call(yAxis);

});

  <|endoftext|>


<commit_before>/**
 * @version: 1.0 Alpha-1
 * @author: Coolite Inc. http://www.coolite.com/
 * @date: 21-Feb-2008
 * @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved.
 * @license: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/.
 * @website: http://www.datejs.com/
 */
Date.CultureInfo = {
	/* Culture Name */
    name: "en-US",
    englishName: "English (United States)",
    nativeName: "English (United States)",

    /* Day Name Strings */
    dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
    abbreviatedDayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
    shortestDayNames: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
    firstLetterDayNames: ["S", "M", "T", "W", "T", "F", "S"],

    /* Month Name Strings */
    monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
    abbreviatedMonthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],

	/* AM/PM Designators */
    amDesignator: "AM",
    pmDesignator: "PM",

    firstDayOfWeek: 0,
    twoDigitYearMax: 2029,

    /**
     * The dateElementOrder is based on the order of the
     * format specifiers in the formatPatterns.DatePattern.
     *
     * Example:

     shortDatePattern    dateElementOrder
     ------------------  ----------------
     "M/d/yyyy"          "mdy"
     "dd/MM/yyyy"        "dmy"
     "yyyy-MM-dd"        "ymd"

     *
     * The correct dateElementOrder is required by the parser to
     * determine the expected order of the date elements in the
     * string being parsed.
     */
    dateElementOrder: "mdy",

    /* Standard date and time format patterns */
    formatPatterns: {
        shortDate: "M/d/yyyy",
        longDate: "dddd, MMMM dd, yyyy",
        shortTime: "h:mm tt",
        longTime: "h:mm:ss tt",
        fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt",
        sortableDateTime: "yyyy-MM-ddTHH:mm:ss",
        universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ",
        rfc1123: "ddd, dd MMM yyyy HH:mm:ss GMT",
        monthDay: "MMMM dd",
        yearMonth: "MMMM, yyyy"
    },

    /**
     * NOTE: If a string format is not parsing correctly, but
     * you would expect it parse, the problem likely lies below.
     *
     * The following regex patterns control most of the string matching
     * within the parser.
     *
     * The Month name and Day name patterns were automatically generated
     * and in general should be (mostly) correct.
     *
     * Beyond the month and day name patterns are natural language strings.
     * Example: "next", "today", "months"
     *
     * These natural language string may NOT be correct for this culture.
     * If they are not correct, please translate and edit this file
     * providing the correct regular expression pattern.
     *
     * If you modify this file, please post your revised CultureInfo file
     * to the Datejs Forum located at http://www.datejs.com/forums/.
     *
     * Please mark the subject of the post with [CultureInfo]. Example:
     *    Subject: [CultureInfo] Translated "da-DK" Danish(Denmark)
     *
     * We will add the modified patterns to the master source files.
     *
     * As well, please review the list of "Future Strings" section below.
     */
    regexPatterns: {
        jan: /^jan(uary)?/i,
        feb: /^feb(ruary)?/i,
        mar: /^mar(ch)?/i,
        apr: /^apr(il)?/i,
        may: /^may/i,
        jun: /^jun(e)?/i,
        jul: /^jul(y)?/i,
        aug: /^aug(ust)?/i,
        sep: /^sep(t(ember)?)?/i,
        oct: /^oct(ober)?/i,
        nov: /^nov(ember)?/i,
        dec: /^dec(ember)?/i,

        sun: /^su(n(day)?)?/i,
        mon: /^mo(n(day)?)?/i,
        tue: /^tu(e(s(day)?)?)?/i,
        wed: /^we(d(nesday)?)?/i,
        thu: /^th(u(r(s(day)?)?)?)?/i,
        fri: /^fr(i(day)?)?/i,
        sat: /^sa(t(urday)?)?/i,

        future: /^next/i,
        past: /^last|past|prev(ious)?/i,
        add: /^(\+|aft(er)?|from|hence)/i,
        subtract: /^(\-|bef(ore)?|ago)/i,

        yesterday: /^yes(terday)?/i,
        today: /^t(od(ay)?)?/i,
        tomorrow: /^tom(orrow)?/i,
        now: /^n(ow)?/i,

        millisecond: /^ms|milli(second)?s?/i,
        second: /^sec(ond)?s?/i,
        minute: /^mn|min(ute)?s?/i,
		hour: /^h(our)?s?/i,
		week: /^w(eek)?s?/i,
        month: /^m(onth)?s?/i,
        day: /^d(ay)?s?/i,
        year: /^y(ear)?s?/i,

        shortMeridian: /^(a|p)/i,
        longMeridian: /^(a\.?m?\.?|p\.?m?\.?)/i,
        timezone: /^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt|utc)/i,
        ordinalSuffix: /^\s*(st|nd|rd|th)/i,
        timeContext: /^\s*(\:|a{?!(u|p)}|p)/i
    },

    timezones: { UTC: "-000", GMT: "-000", EST: "-0500", EDT: "-0400", CST: "-0600", CDT: "-0500", MST: "-0700", MDT: "-0600", PST: "-0800", PDT: "-0700" }
};

/********************
 ** Future Strings **
 ********************
 *
 * The following list of strings may not be currently being used, but
 * may be incorporated into the Datejs library later.
 *
 * We would appreciate any help translating the strings below.
 *
 * If you modify this file, please post your revised CultureInfo file
 * to the Datejs Forum located at http://www.datejs.com/forums/.
 *
 * Please mark the subject of the post with [CultureInfo]. Example:
 *    Subject: [CultureInfo] Translated "da-DK" Danish(Denmark)
 *
 * English Name        Translated
 * ------------------  -----------------
 * date                date
 * time                time
 * calendar            calendar
 * show                show
 * hourly              hourly
 * daily               daily
 * weekly              weekly
 * bi-weekly           bi-weekly
 * fortnight           fortnight
 * monthly             monthly
 * bi-monthly          bi-monthly
 * quarter             quarter
 * quarterly           quarterly
 * yearly              yearly
 * annual              annual
 * annually            annually
 * annum               annum
 * again               again
 * between             between
 * after               after
 * from now            from now
 * repeat              repeat
 * times               times
 * per                 per
 * min (abbrev minute) min
 * morning             morning
 * noon                noon
 * night               night
 * midnight            midnight
 * mid-night           mid-night
 * evening             evening
 * final               final
 * future              future
 * spring              spring
 * summer              summer
 * fall                fall
 * winter              winter
 */
<commit_msg>Fix for 25 aug 2008 17:00 problem (take 2)<commit_after>/**
 * @version: 1.0 Alpha-1
 * @author: Coolite Inc. http://www.coolite.com/
 * @date: 21-Feb-2008
 * @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved.
 * @license: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/.
 * @website: http://www.datejs.com/
 */
Date.CultureInfo = {
	/* Culture Name */
    name: "en-US",
    englishName: "English (United States)",
    nativeName: "English (United States)",

    /* Day Name Strings */
    dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
    abbreviatedDayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
    shortestDayNames: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
    firstLetterDayNames: ["S", "M", "T", "W", "T", "F", "S"],

    /* Month Name Strings */
    monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
    abbreviatedMonthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],

	/* AM/PM Designators */
    amDesignator: "AM",
    pmDesignator: "PM",

    firstDayOfWeek: 0,
    twoDigitYearMax: 2029,

    /**
     * The dateElementOrder is based on the order of the
     * format specifiers in the formatPatterns.DatePattern.
     *
     * Example:

     shortDatePattern    dateElementOrder
     ------------------  ----------------
     "M/d/yyyy"          "mdy"
     "dd/MM/yyyy"        "dmy"
     "yyyy-MM-dd"        "ymd"

     *
     * The correct dateElementOrder is required by the parser to
     * determine the expected order of the date elements in the
     * string being parsed.
     */
    dateElementOrder: "mdy",

    /* Standard date and time format patterns */
    formatPatterns: {
        shortDate: "M/d/yyyy",
        longDate: "dddd, MMMM dd, yyyy",
        shortTime: "h:mm tt",
        longTime: "h:mm:ss tt",
        fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt",
        sortableDateTime: "yyyy-MM-ddTHH:mm:ss",
        universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ",
        rfc1123: "ddd, dd MMM yyyy HH:mm:ss GMT",
        monthDay: "MMMM dd",
        yearMonth: "MMMM, yyyy"
    },

    /**
     * NOTE: If a string format is not parsing correctly, but
     * you would expect it parse, the problem likely lies below.
     *
     * The following regex patterns control most of the string matching
     * within the parser.
     *
     * The Month name and Day name patterns were automatically generated
     * and in general should be (mostly) correct.
     *
     * Beyond the month and day name patterns are natural language strings.
     * Example: "next", "today", "months"
     *
     * These natural language string may NOT be correct for this culture.
     * If they are not correct, please translate and edit this file
     * providing the correct regular expression pattern.
     *
     * If you modify this file, please post your revised CultureInfo file
     * to the Datejs Forum located at http://www.datejs.com/forums/.
     *
     * Please mark the subject of the post with [CultureInfo]. Example:
     *    Subject: [CultureInfo] Translated "da-DK" Danish(Denmark)
     *
     * We will add the modified patterns to the master source files.
     *
     * As well, please review the list of "Future Strings" section below.
     */
    regexPatterns: {
        jan: /^jan(uary)?/i,
        feb: /^feb(ruary)?/i,
        mar: /^mar(ch)?/i,
        apr: /^apr(il)?/i,
        may: /^may/i,
        jun: /^jun(e)?/i,
        jul: /^jul(y)?/i,
        aug: /^aug(ust)?/i,
        sep: /^sep(t(ember)?)?/i,
        oct: /^oct(ober)?/i,
        nov: /^nov(ember)?/i,
        dec: /^dec(ember)?/i,

        sun: /^su(n(day)?)?/i,
        mon: /^mo(n(day)?)?/i,
        tue: /^tu(e(s(day)?)?)?/i,
        wed: /^we(d(nesday)?)?/i,
        thu: /^th(u(r(s(day)?)?)?)?/i,
        fri: /^fr(i(day)?)?/i,
        sat: /^sa(t(urday)?)?/i,

        future: /^next/i,
        past: /^last|past|prev(ious)?/i,
        add: /^(\+|aft(er)?|from|hence)/i,
        subtract: /^(\-|bef(ore)?|ago)/i,

        yesterday: /^yes(terday)?/i,
        today: /^t(od(ay)?)?/i,
        tomorrow: /^tom(orrow)?/i,
        now: /^n(ow)?/i,

        millisecond: /^ms|milli(second)?s?/i,
        second: /^sec(ond)?s?/i,
        minute: /^mn|min(ute)?s?/i,
		hour: /^h(our)?s?/i,
		week: /^w(eek)?s?/i,
        month: /^m(onth)?s?/i,
        day: /^d(ay)?s?/i,
        year: /^y(ear)?s?/i,

        shortMeridian: /^(a|p)/i,
        longMeridian: /^(a\.?m?\.?|p\.?m?\.?)/i,
        timezone: /^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt|utc)/i,
        ordinalSuffix: /^\s*(st|nd|rd|th)/i,
        timeContext: /^\s*(\:|a(?!u|p)|p)/i
    },

    timezones: { UTC: "-000", GMT: "-000", EST: "-0500", EDT: "-0400", CST: "-0600", CDT: "-0500", MST: "-0700", MDT: "-0600", PST: "-0800", PDT: "-0700" }
};

/********************
 ** Future Strings **
 ********************
 *
 * The following list of strings may not be currently being used, but
 * may be incorporated into the Datejs library later.
 *
 * We would appreciate any help translating the strings below.
 *
 * If you modify this file, please post your revised CultureInfo file
 * to the Datejs Forum located at http://www.datejs.com/forums/.
 *
 * Please mark the subject of the post with [CultureInfo]. Example:
 *    Subject: [CultureInfo] Translated "da-DK" Danish(Denmark)
 *
 * English Name        Translated
 * ------------------  -----------------
 * date                date
 * time                time
 * calendar            calendar
 * show                show
 * hourly              hourly
 * daily               daily
 * weekly              weekly
 * bi-weekly           bi-weekly
 * fortnight           fortnight
 * monthly             monthly
 * bi-monthly          bi-monthly
 * quarter             quarter
 * quarterly           quarterly
 * yearly              yearly
 * annual              annual
 * annually            annually
 * annum               annum
 * again               again
 * between             between
 * after               after
 * from now            from now
 * repeat              repeat
 * times               times
 * per                 per
 * min (abbrev minute) min
 * morning             morning
 * noon                noon
 * night               night
 * midnight            midnight
 * mid-night           mid-night
 * evening             evening
 * final               final
 * future              future
 * spring              spring
 * summer              summer
 * fall                fall
 * winter              winter
 */
<|endoftext|>


<commit_before>
(function(){
    var animMap = {
            'none' : 'slide',
            "anim-move-left"    : 'slide',
            "anim-move-right"   : 'slide',
            "anim-move-top"     : 'slide',
            "anim-move-bottom"  : 'slide',
            "anim-move-top-left"        : 'slide',
            "anim-move-top-right"       : 'slide',
            "anim-move-bottom-left"     : 'slide',
            "anim-move-bottom-right"    : 'slide',
            "anim-scale"    : 'scale',
            "anim-xSpin"    : 'rotate-x',
            "anim-ySpin"    : 'rotate-y',
            "anim-rightRotate"  : 'rotate',
            "anim-leftRotate"   : 'rotate',
        },
        animations = {

            'slide' : {
                        "class" : 'slide',
                        "datas" : {}
            },
            'scale' : {
                        "class" : 'slide',
                        "datas" : {
                            'scale' : 3
                        }
            },
            'rotate-x' : {
                        "class" : '',
                        "datas" : {
                            'rotate' : -60,
                            'scale' : 2,
                            'z' : -150
                        }
            },
            'rotate-y' : {
                        "class" : '',
                        "datas" : {
                            'rotate' : 60,
                            'scale' : 2,
                            'z' : -100
                        }
            },
            'rotate' : {
                        "class" : '',
                        "datas" : {
                            'rotate' : 180,
                            'scale' : 3,
                            'z' : -200
                        }
            }
        }

    function getSqrt(map) {
        var len = getLength(map);
        var sqrtNum = Math.sqrt(len);
        if (sqrtNum % 1 > 0) sqrtNum = parseInt(sqrtNum) + 1;
        return sqrtNum;
    }
    function setAttr(elem, map) {
        var datas = map.datas,
            className = map.class;
        $(elem).addClass(className);
        for(var key in datas){
            if(datas.hasOwnProperty(key)) {
                $(elem).data(key, datas[key]);
                switch(key) {
                    case 'rotate':
                        elem.style.WebkitTransform += ' rotate(' + datas[key] + "deg)";break;
                    case 'scale' :
                        elem.style.WebkitTransform += ' scale(' + datas[key] + ")";break;
                    default : break;
                }
            }
        }
    }
    function getLength(map) {
        var len = 0;
        for(var key in map){
            if(map.hasOwnProperty(key)) len ++;
        }
        return len;
    }
    var module = {
        render : function(DATA, conf, container, sb){
                // datas = JSON.parse(datajson),
                // DATA = JSON.parse(datas.cntData),
                // conf = datas.cntConf;
            var sqrtNum = getSqrt(DATA),
                sliders = {},
                index = 0,
                _sHeight = 0,
                _sWidth = 0,
                _maxHeight = 0,
                _maxHeightArr = [],
                _impressWidth = 0,
                _impressHeight = 0,
                _x = 0,
                _y = 0,
                _dataLength = getLength(DATA);

            for(var s in DATA){
                if(DATA.hasOwnProperty(s)){
                    var slider = document.createElement("DIV"),
                        panel = document.createElement("DIV"),
                        labelPanel = document.createElement("DIV"),
                        elements = DATA[s].element,
                        anim = animMap[DATA[s].anim],
                        sliderData = DATA[s];

                    $(slider).append(panel).append(labelPanel);
                    panel.setAttribute('style', DATA[s].panelAttr);
                    sliders[s] = slider;
                    var scale = 1;
                    if (anim && animations[anim] && animations[anim].datas.scale) {
                        scale = parseFloat(animations[anim].datas.scale)
                    }

                    var curColum = index % sqrtNum;
                        curRow = parseInt(index / sqrtNum);

                    index ++;
                    $(labelPanel).html(index).css({
                        position    : 'absolute',
                        fontSize    : '100px',
                        color       : 'black',
                        left : '10px',
                        top : '0px',
                        zIndex : 9999
                    });

                    if (curColum === 0) {
                        _sWidth = 0;
                        _sHeight += _maxHeight;
                        _maxHeight = 0;
                    }

                    if (( parseInt(conf.height) * scale  + 100) > _maxHeight) {
                        _maxHeight = ( parseInt(conf.height) * scale  + 100);
                    }
                    var calcX =  _sWidth + parseInt(conf.width) * scale/2,
                        calcY =  _sHeight + parseInt(conf.height) * scale/2;

                    _x = !_.isEmpty(sliderData.x) ? sliderData.x : calcX;
                    _y = !_.isEmpty(sliderData.y) ? sliderData.y : calcY;
                    $(slider)
                            .css({
                                backgroundColor : 'white',
                                position : 'absolute',
                                height : conf.height,
                                width  : conf.width,
                                top : _y + 'px',
                                left : _x + 'px'
                            })
                            .data('id', s)
                            .data('x', _x)
                            .data('y', _y)
                            .data('calcx', calcX)
                            .data('calcy', calcY)
                            .addClass('step')
                            .attr('draggable', false);

                    _sWidth += ( parseInt(conf.width) ) * scale + 100;

                    //in every row's last colum get the with and height
                    if (curColum === (sqrtNum - 1 ) || index >= _dataLength) {
                        //impress max  width
                        if (_sWidth > _impressWidth) _impressWidth = _sWidth;
                        _impressHeight += _maxHeight;
                    }
                    anim && animations[anim] && setAttr(slider, animations[anim]);

                    for (var e in elements) {
                        if(elements.hasOwnProperty(e)){
                            var data = elements[e],elem;
                            if(data.type === "DIV"){
                                elem = document.createElement("DIV");
                                elem.innerHTML = decodeURIComponent(data.value);
                                elem.setAttribute("style", data.cAttr + data.eAttr);
                                elem.style.zIndex = data.zIndex;
                            }
                            else if(data.type=="IMG"){

                                var panel = document.createElement('div');
                                var img = new Image();
                                elem = document.createElement('div');
                                //panel attr
                                data.pAttr && panel.setAttribute('style', data.pAttr);
                                //container attr
                                elem.setAttribute("style", data.cAttr);
                                elem.style.zIndex = data.zIndex;
                                img.src = data.value;
                                img.setAttribute("style", data.eAttr);
                                $(img).attr('draggable', false);
                                $(elem).append(panel).append(img);
                            }
                            else if (data.type==="VIDEO") {
                                elem = document.createElement("video");
                                var src = document.createElement("source");
                                src.src = data.value;
                                elem.appendChild(src);
                                elem.setAttribute("style", data.cAttr);
                                elem.setAttribute('controls', true);
                                elem.style.zIndex = data.zIndex;
                            }
                            else if (data.type==='CODE') {
                                var text = document.createElement("div");

                                elem = document.createElement("div");

                                elem.setAttribute("style", data.cAttr);
                                elem.style.zIndex = data.zIndex;
                                text.setAttribute("style", data.eAttr);
                                elem.appendChild(text);
                                (function (eData) {
                                        var codeMirror = CodeMirror(text, {
                                          value: eData.value,
                                          mode:  eData.codeType,
                                          theme:  eData.theme,
                                          lineNumbers  : true,
                                          lineWrapping  : true,
                                          readOnly : false
                                        });
                                        setTimeout(function () {
                                            module.triggerWindowResize();
                                        }, 10);
                                })(data)

                            }
                            if(elem){
                                $(elem).attr('draggable', false);
                                slider.appendChild(elem);
                            }
                        }
                    }
                    container.appendChild(slider)
                }
            }
            var DEFAULT_SCALE = 5.5,
                scaling = DEFAULT_SCALE,
                wScaling = document.width / _impressWidth ,
                hScaling = document.height / _impressHeight;

            scaling = wScaling >= hScaling ? wScaling : hScaling;
            scaling = scaling > DEFAULT_SCALE ? scaling : DEFAULT_SCALE;

            container.style.WebkitTransform = 'scale(' + 1/scaling + ')';
            $(container).css({
                top : (($(container).parent().height() - _impressHeight / scaling) / 2 - 60)   + 'px',
                left : (($(container).parent().width() - _impressWidth / scaling) / 2 - 100)  + 'px',
            })

            var borderWidth = scaling >= 1 ? scaling : 1;
            // $('.step', container).css({
            //     'boxShadow' : '0 0 0 ' + borderWidth + 'px + black'
            // })

            var $sliders = $('.step', container);
            _.each($sliders, function (slider) {
                sb.move(slider, slider, {scaling : scaling});
            })
        },
        readAttributes : function (container) {
            var $sliders = $('.step', container),
                sliderDataset = {};
            _.each($sliders, function (slider) {
                var $slider = $(slider),
                    sliderId = $slider.data('id'),
                    data = {
                        x : parseFloat($slider[0].style.left) ,
                        y : parseFloat($slider[0].style.top)
                    }
                sliderDataset[sliderId] = data;
            })
            return sliderDataset;
        },
        resetPosition : function (container) {
            var $sliders = $('.step', container);
            _.each($sliders, function (slider) {
                var $slider = $(slider),
                    calcX = $slider.data('calcx'),
                    calcY = $slider.data('calcy');

                console.log($slider.data('x'));
                $(slider).data('x', calcX);
                $(slider).data('y', calcY);
                $(slider).css({
                    top : (calcX + 'px'),
                    left : (calcY + 'px')
                })
                console.log(calcX, calcY);

            })
        }
    }
    window.ImpressRender = module;
}());<commit_msg>fix bug: reset position bug<commit_after>
(function(){
    var animMap = {
            'none' : 'slide',
            "anim-move-left"    : 'slide',
            "anim-move-right"   : 'slide',
            "anim-move-top"     : 'slide',
            "anim-move-bottom"  : 'slide',
            "anim-move-top-left"        : 'slide',
            "anim-move-top-right"       : 'slide',
            "anim-move-bottom-left"     : 'slide',
            "anim-move-bottom-right"    : 'slide',
            "anim-scale"    : 'scale',
            "anim-xSpin"    : 'rotate-x',
            "anim-ySpin"    : 'rotate-y',
            "anim-rightRotate"  : 'rotate',
            "anim-leftRotate"   : 'rotate',
        },
        animations = {

            'slide' : {
                        "class" : 'slide',
                        "datas" : {}
            },
            'scale' : {
                        "class" : 'slide',
                        "datas" : {
                            'scale' : 3
                        }
            },
            'rotate-x' : {
                        "class" : '',
                        "datas" : {
                            'rotate' : -60,
                            'scale' : 2,
                            'z' : -150
                        }
            },
            'rotate-y' : {
                        "class" : '',
                        "datas" : {
                            'rotate' : 60,
                            'scale' : 2,
                            'z' : -100
                        }
            },
            'rotate' : {
                        "class" : '',
                        "datas" : {
                            'rotate' : 180,
                            'scale' : 3,
                            'z' : -200
                        }
            }
        }

    function getSqrt(map) {
        var len = getLength(map);
        var sqrtNum = Math.sqrt(len);
        if (sqrtNum % 1 > 0) sqrtNum = parseInt(sqrtNum) + 1;
        return sqrtNum;
    }
    function setAttr(elem, map) {
        var datas = map.datas,
            className = map.class;
        $(elem).addClass(className);
        for(var key in datas){
            if(datas.hasOwnProperty(key)) {
                $(elem).data(key, datas[key]);
                switch(key) {
                    case 'rotate':
                        elem.style.WebkitTransform += ' rotate(' + datas[key] + "deg)";break;
                    case 'scale' :
                        elem.style.WebkitTransform += ' scale(' + datas[key] + ")";break;
                    default : break;
                }
            }
        }
    }
    function getLength(map) {
        var len = 0;
        for(var key in map){
            if(map.hasOwnProperty(key)) len ++;
        }
        return len;
    }
    var module = {
        render : function(DATA, conf, container, sb){
                // datas = JSON.parse(datajson),
                // DATA = JSON.parse(datas.cntData),
                // conf = datas.cntConf;
            var sqrtNum = getSqrt(DATA),
                sliders = {},
                index = 0,
                _sHeight = 0,
                _sWidth = 0,
                _maxHeight = 0,
                _maxHeightArr = [],
                _impressWidth = 0,
                _impressHeight = 0,
                _x = 0,
                _y = 0,
                _dataLength = getLength(DATA);

            for(var s in DATA){
                if(DATA.hasOwnProperty(s)){
                    var slider = document.createElement("DIV"),
                        panel = document.createElement("DIV"),
                        labelPanel = document.createElement("DIV"),
                        elements = DATA[s].element,
                        anim = animMap[DATA[s].anim],
                        sliderData = DATA[s];

                    $(slider).append(panel).append(labelPanel);
                    panel.setAttribute('style', DATA[s].panelAttr);
                    sliders[s] = slider;
                    var scale = 1;
                    if (anim && animations[anim] && animations[anim].datas.scale) {
                        scale = parseFloat(animations[anim].datas.scale)
                    }

                    var curColum = index % sqrtNum;
                        curRow = parseInt(index / sqrtNum);

                    index ++;
                    $(labelPanel).html(index).css({
                        position    : 'absolute',
                        fontSize    : '100px',
                        color       : 'black',
                        left : '10px',
                        top : '0px',
                        zIndex : 9999
                    });

                    if (curColum === 0) {
                        _sWidth = 0;
                        _sHeight += _maxHeight;
                        _maxHeight = 0;
                    }

                    if (( parseInt(conf.height) * scale  + 100) > _maxHeight) {
                        _maxHeight = ( parseInt(conf.height) * scale  + 100);
                    }
                    var calcX =  _sWidth + parseInt(conf.width) * scale/2,
                        calcY =  _sHeight + parseInt(conf.height) * scale/2;

                    _x = !_.isEmpty(sliderData.x) ? sliderData.x : calcX;
                    _y = !_.isEmpty(sliderData.y) ? sliderData.y : calcY;
                    console.log(_x,_y)
                    $(slider)
                            .css({
                                backgroundColor : 'white',
                                position : 'absolute',
                                height : conf.height,
                                width  : conf.width,
                                top : _y + 'px',
                                left : _x + 'px'
                            })
                            .data('id', s)
                            .data('x', _x)
                            .data('y', _y)
                            .data('calcx', calcX)
                            .data('calcy', calcY)
                            .addClass('step')
                            .attr('draggable', false);

                    _sWidth += ( parseInt(conf.width) ) * scale + 100;

                    //in every row's last colum get the with and height
                    if (curColum === (sqrtNum - 1 ) || index >= _dataLength) {
                        //impress max  width
                        if (_sWidth > _impressWidth) _impressWidth = _sWidth;
                        _impressHeight += _maxHeight;
                    }
                    anim && animations[anim] && setAttr(slider, animations[anim]);

                    for (var e in elements) {
                        if(elements.hasOwnProperty(e)){
                            var data = elements[e],elem;
                            if(data.type === "DIV"){
                                elem = document.createElement("DIV");
                                elem.innerHTML = decodeURIComponent(data.value);
                                elem.setAttribute("style", data.cAttr + data.eAttr);
                                elem.style.zIndex = data.zIndex;
                            }
                            else if(data.type=="IMG"){

                                var panel = document.createElement('div');
                                var img = new Image();
                                elem = document.createElement('div');
                                //panel attr
                                data.pAttr && panel.setAttribute('style', data.pAttr);
                                //container attr
                                elem.setAttribute("style", data.cAttr);
                                elem.style.zIndex = data.zIndex;
                                img.src = data.value;
                                img.setAttribute("style", data.eAttr);
                                $(img).attr('draggable', false);
                                $(elem).append(panel).append(img);
                            }
                            else if (data.type==="VIDEO") {
                                elem = document.createElement("video");
                                var src = document.createElement("source");
                                src.src = data.value;
                                elem.appendChild(src);
                                elem.setAttribute("style", data.cAttr);
                                elem.setAttribute('controls', true);
                                elem.style.zIndex = data.zIndex;
                            }
                            else if (data.type==='CODE') {
                                var text = document.createElement("div");

                                elem = document.createElement("div");

                                elem.setAttribute("style", data.cAttr);
                                elem.style.zIndex = data.zIndex;
                                text.setAttribute("style", data.eAttr);
                                elem.appendChild(text);
                                (function (eData) {
                                        var codeMirror = CodeMirror(text, {
                                          value: eData.value,
                                          mode:  eData.codeType,
                                          theme:  eData.theme,
                                          lineNumbers  : true,
                                          lineWrapping  : true,
                                          readOnly : false
                                        });
                                        setTimeout(function () {
                                            module.triggerWindowResize();
                                        }, 10);
                                })(data)

                            }
                            if(elem){
                                $(elem).attr('draggable', false);
                                slider.appendChild(elem);
                            }
                        }
                    }
                    container.appendChild(slider)
                }
            }
            var DEFAULT_SCALE = 5.5,
                scaling = DEFAULT_SCALE,
                wScaling = document.width / _impressWidth ,
                hScaling = document.height / _impressHeight;

            scaling = wScaling >= hScaling ? wScaling : hScaling;
            scaling = scaling > DEFAULT_SCALE ? scaling : DEFAULT_SCALE;

            container.style.WebkitTransform = 'scale(' + 1/scaling + ')';
            $(container).css({
                top : (($(container).parent().height() - _impressHeight / scaling) / 2 - 60)   + 'px',
                left : (($(container).parent().width() - _impressWidth / scaling) / 2 - 100)  + 'px',
            })

            var borderWidth = scaling >= 1 ? scaling : 1;
            // $('.step', container).css({
            //     'boxShadow' : '0 0 0 ' + borderWidth + 'px + black'
            // })

            var $sliders = $('.step', container);
            _.each($sliders, function (slider) {
                sb.move(slider, slider, {scaling : scaling});
            })
        },
        readAttributes : function (container) {
            var $sliders = $('.step', container),
                sliderDataset = {};
            _.each($sliders, function (slider) {
                var $slider = $(slider),
                    sliderId = $slider.data('id'),
                    data = {
                        x : parseFloat($slider[0].style.left) ,
                        y : parseFloat($slider[0].style.top)
                    }
                sliderDataset[sliderId] = data;
            })
            return sliderDataset;
        },
        resetPosition : function (container) {
            var $sliders = $('.step', container);
            _.each($sliders, function (slider) {
                var $slider = $(slider),
                    calcX = $slider.data('calcx'),
                    calcY = $slider.data('calcy');

                $(slider).data('x', calcX);
                $(slider).data('y', calcY);
                $(slider).css({
                    top : (calcY + 'px'),
                    left : (calcX + 'px')
                })
                console.log(calcX, calcY);

            })
        }
    }
    window.ImpressRender = module;
}());<|endoftext|>


<commit_before>$(document).ready(function(){

	$('#hora_inicial').wickedpicker({now: '8:00', twentyFour: true, title:
                    'Horário', showSeconds: false});
        $('#hora_final').wickedpicker({now: '8:00', twentyFour: true, title:
                    'Horário', showSeconds: false});
	})

$('#quantidade').focus(function(e){
//$(teste).click(function(e){
			var hora_inicial ="";
			var hora_final ="";
			hora_inicial = window.document.getElementById("hora_inicial").value;
			hora_final = window.document.getElementById("hora_final").value;

			if(hora_inicial>=hora_final){
				alert("Horário final não pode ser menor ou igual que o horário inicial");
                               // window.document.getElementById("hora_inicial").value="";
                                window.document.getElementById("hora_final").value="";
			}else{

				return;
			}

		})

        function validaHora(){
//$(teste).click(function(e){
			var hora_inicial ="";
			var hora_final ="";
			hora_inicial = window.document.getElementById("hora_inicial").value;
			hora_final = window.document.getElementById("hora_final").value;

			if(hora_inicial>=hora_final){
				alert("Horário final não pode ser menor ou igual que o horário inicial");
                               // window.document.getElementById("hora_inicial").value="";
                                window.document.getElementById("hora_final").value="";
                                return false;
			}else{

				return true;
			}

		}
              <commit_msg>Correções.<commit_after>$(document).ready(function(){

	$('#hora_inicial').wickedpicker({now: '8:00', twentyFour: true, title:
                    'Horário', showSeconds: false});
        $('#hora_final').wickedpicker({now: '8:00', twentyFour: true, title:
                    'Horário', showSeconds: false});
	})

$('#quantidade').focus(function(e){
//$(teste).click(function(e){
			var hora_inicial ="";
			var hora_final ="";
			hora_inicial = window.document.getElementById("hora_inicial").value;
			hora_final = window.document.getElementById("hora_final").value;

			if(hora_inicial>=hora_final){
				alert("Horário final não pode ser menor ou igual que o horário inicial");
                               // window.document.getElementById("hora_inicial").value="";
                                window.document.getElementById("hora_final").value="";
			}else{

				return;
			}

		})

        function validaHora(){
//$(teste).click(function(e){
			var hora_inicial ="";
			var hora_final ="";
			hora_inicial = window.document.getElementById("hora_inicial").value;
			hora_final = window.document.getElementById("hora_final").value;

			if(hora_inicial>=hora_final){
				alert("Horário final não pode ser menor ou igual que o horário inicial");
                               // window.document.getElementById("hora_inicial").value="";
                                window.document.getElementById("hora_final").value="";
                                return false;
			}else{

				return true;
			}

		}
                function finalizar(){
                    $("#amostra")[0].submit();

                }; <|endoftext|>