<commit_before>//goog.provide('saiku.views.AboutModal');

//goog.require('saiku.views.Modal');
/*
 *   Copyright 2012 OSBI Ltd
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

/**
 * The "about us" dialog
 */
var AboutModal = Modal.extend({
    type: 'info',

    events: {
        'click a' : 'close'
    },

    message: Settings.VERSION + '
' +
        'http://saiku.meteorite.bi

' +
        'Saiku Wiki online help

' +
        'Powered by  http://www.meteorite.bi/consulting/',

    initialize: function() {
        this.options.title = 'About ' + Settings.VERSION;
    },

    close: function() {
        this.$el.dialog('destroy').remove();
    }
});
<commit_msg>Update AboutModal.js<commit_after>/*
 *   Copyright 2012 OSBI Ltd
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

/**
 * The "about us" dialog
 */
var AboutModal = Modal.extend({
    type: 'info',

    events: {
        'click a' : 'close'
    },

    message: Settings.VERSION + '
' +
        'http://saiku.meteorite.bi

' +
        'Saiku Wiki online help

' +
        'Powered by  http://www.meteorite.bi/consulting/',

    initialize: function() {
        this.options.title = 'About ' + Settings.VERSION;
    },

    close: function() {
        this.$el.dialog('destroy').remove();
    }
});
<|endoftext|>


<commit_before>/* eslint-disable react/button-has-type */
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable no-return-assign */
/* eslint-disable react/jsx-filename-extension */
/* eslint-disable react/prop-types */
/* eslint-disable react/destructuring-assignment */

import React, { Component } from 'react';
import classnames from 'classnames';
import { Translate } from 'react-redux-i18n';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import { allowedPagesSelector } from '../../redux/selectors/navigation/allowedPages';
import styles from '../header/header.scss';
import Clock from '../clock';
import axios from '../../axios';

const EDIT_PROFILE_TOPOLOGY_PAGE = '50104';

class UserMenu extends Component {
  userService = axios('internal.php?object=centreon_topcounter&action=user');

  refreshTimeout = null;

  state = {
    toggled: false,
    copied: false,
    data: null,
  };

  componentDidMount() {
    window.addEventListener('mousedown', this.handleClick, false);
    this.getData();
  }

  componentWillUnmount() {
    window.removeEventListener('mousedown', this.handleClick, false);
    clearTimeout(this.refreshTimeout);
  }

  // fetch api to get user data
  getData = () => {
    this.userService
      .get()
      .then(({ data }) => {
        this.setState(
          {
            data,
          },
          this.refreshData,
        );
      })
      .catch((error) => {
        if (error.response.status === 401) {
          this.setState({
            data: null,
          });
        }
      });
  };

  // refresh user data every minutes
  // @todo get this interval from backend
  refreshData = () => {
    clearTimeout(this.refreshTimeout);
    this.refreshTimeout = setTimeout(() => {
      this.getData();
    }, 60000);
  };

  toggle = () => {
    const { toggled } = this.state;
    this.setState({
      toggled: !toggled,
    });
  };

  // copy for autologin link
  onCopy = () => {
    this.autologinNode.select();
    window.document.execCommand('copy');
    this.setState({
      copied: true,
    });
  };

  handleClick = (e) => {
    if (!this.profile || this.profile.contains(e.target)) {
      return;
    }
    this.setState({
      toggled: false,
    });
  };

  render() {
    const { data, toggled, copied } = this.state;

    if (!data) {
      return null;
    }

    // check if edit profile page (My Account) is allowed
    const { allowedPages } = this.props;
    const allowEditProfile = allowedPages.includes(EDIT_PROFILE_TOPOLOGY_PAGE);

    const { fullname, username, autologinkey } = data;

    // creating autologin link, getting href, testing if there is a parameter, then generating link : if '?' then &autologin(etc.)
    const gethref = window.location.href;
    const conditionnedhref = gethref + (window.location.search ? '&' : '?');
    const autolink = `${conditionnedhref}autologin=1&useralias=${username}&token=${autologinkey}`;

    return (

        <Clock />

 (this.profile = profile)}>

                      {fullname}

                      <Translate value="as" />
                      {username}

                    {allowEditProfile && (
                      <Link
                        to={`/main.php?p=${EDIT_PROFILE_TOPOLOGY_PAGE}&o=c`}
                        className={styles['submenu-user-edit']}
                        onClick={this.toggle}
                      >
                        <Translate value="Edit profile" />
                      </Link>
                    )}

                {autologinkey && (
                  <>
                    <button
                      className={styles['submenu-user-button']}
                      onClick={this.onCopy}
                    >
                      <Translate value="Copy autologin link" />

                    </button>
                    <textarea
                      id="autologin-input"
                      className={styles['hidden-input']}
                      ref={(node) => (this.autologinNode = node)}
                      value={autolink}
                    />
                  </>
                )}

                  <button
                    className={classnames(
                      styles.btn,
                      styles['btn-small'],
                      styles.logout,
                    )}
                  >
                    <Translate value="Logout" />
                  </button>

    );
  }
}

const mapStateToProps = (state) => ({
  allowedPages: allowedPagesSelector(state),
});

const mapDispatchToProps = {};

export default connect(
  mapStateToProps,
  mapDispatchToProps,
)(UserMenu);
<commit_msg>fix(ui): retrieve space before alias in user menu (#7869)<commit_after>/* eslint-disable react/button-has-type */
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable no-return-assign */
/* eslint-disable react/jsx-filename-extension */
/* eslint-disable react/prop-types */
/* eslint-disable react/destructuring-assignment */

import React, { Component } from 'react';
import classnames from 'classnames';
import { Translate } from 'react-redux-i18n';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import { allowedPagesSelector } from '../../redux/selectors/navigation/allowedPages';
import styles from '../header/header.scss';
import Clock from '../clock';
import axios from '../../axios';

const EDIT_PROFILE_TOPOLOGY_PAGE = '50104';

class UserMenu extends Component {
  userService = axios('internal.php?object=centreon_topcounter&action=user');

  refreshTimeout = null;

  state = {
    toggled: false,
    copied: false,
    data: null,
  };

  componentDidMount() {
    window.addEventListener('mousedown', this.handleClick, false);
    this.getData();
  }

  componentWillUnmount() {
    window.removeEventListener('mousedown', this.handleClick, false);
    clearTimeout(this.refreshTimeout);
  }

  // fetch api to get user data
  getData = () => {
    this.userService
      .get()
      .then(({ data }) => {
        this.setState(
          {
            data,
          },
          this.refreshData,
        );
      })
      .catch((error) => {
        if (error.response.status === 401) {
          this.setState({
            data: null,
          });
        }
      });
  };

  // refresh user data every minutes
  // @todo get this interval from backend
  refreshData = () => {
    clearTimeout(this.refreshTimeout);
    this.refreshTimeout = setTimeout(() => {
      this.getData();
    }, 60000);
  };

  toggle = () => {
    const { toggled } = this.state;
    this.setState({
      toggled: !toggled,
    });
  };

  // copy for autologin link
  onCopy = () => {
    this.autologinNode.select();
    window.document.execCommand('copy');
    this.setState({
      copied: true,
    });
  };

  handleClick = (e) => {
    if (!this.profile || this.profile.contains(e.target)) {
      return;
    }
    this.setState({
      toggled: false,
    });
  };

  render() {
    const { data, toggled, copied } = this.state;

    if (!data) {
      return null;
    }

    // check if edit profile page (My Account) is allowed
    const { allowedPages } = this.props;
    const allowEditProfile = allowedPages.includes(EDIT_PROFILE_TOPOLOGY_PAGE);

    const { fullname, username, autologinkey } = data;

    // creating autologin link, getting href, testing if there is a parameter, then generating link : if '?' then &autologin(etc.)
    const gethref = window.location.href;
    const conditionnedhref = gethref + (window.location.search ? '&' : '?');
    const autolink = `${conditionnedhref}autologin=1&useralias=${username}&token=${autologinkey}`;

    return (

        <Clock />

 (this.profile = profile)}>

                      {fullname}

                      <Translate value="as" />
                      {` ${username}`}

                    {allowEditProfile && (
                      <Link
                        to={`/main.php?p=${EDIT_PROFILE_TOPOLOGY_PAGE}&o=c`}
                        className={styles['submenu-user-edit']}
                        onClick={this.toggle}
                      >
                        <Translate value="Edit profile" />
                      </Link>
                    )}

                {autologinkey && (
                  <>
                    <button
                      className={styles['submenu-user-button']}
                      onClick={this.onCopy}
                    >
                      <Translate value="Copy autologin link" />

                    </button>
                    <textarea
                      id="autologin-input"
                      className={styles['hidden-input']}
                      ref={(node) => (this.autologinNode = node)}
                      value={autolink}
                    />
                  </>
                )}

                  <button
                    className={classnames(
                      styles.btn,
                      styles['btn-small'],
                      styles.logout,
                    )}
                  >
                    <Translate value="Logout" />
                  </button>

    );
  }
}

const mapStateToProps = (state) => ({
  allowedPages: allowedPagesSelector(state),
});

const mapDispatchToProps = {};

export default connect(
  mapStateToProps,
  mapDispatchToProps,
)(UserMenu);
<|endoftext|>


<commit_before>odoo.define('web_editor.transcoder', function (require) {
'use strict';

var widget = require('web_editor.widget');

var cache = {};
var rulesCache = [];
var getMatchedCSSRules = function (a) {
    if(cache[a.tagName + "." +a.className]) {
        return cache[a.tagName + "." +a.className];
    }
    if (!rulesCache.length) {
        var sheets = document.styleSheets;
        for(var i = sheets.length-1; i >= 0 ; i--) {
            var rules;
            if (sheets[i].rules) {
                rules = sheets[i].rules;
            } else {
                //try...catch because Firefox not able to enumerate document.styleSheets[].cssRules[] for cross-domain stylesheets.
                try {
                    rules = sheets[i].cssRules;
                } catch(e) {
                    console.warn("Can't read the css rules of: " + sheets[i].href, e);
                    continue;
                }
                rules = sheets[i].cssRules;
            }
            if (rules) {
                for(var r = rules.length-1; r >= 0; r--) {
                    var selectorText = rules[r].selectorText;
                    if (selectorText &&
                            rules[r].cssText &&
                            selectorText !== "*" &&
                            selectorText.indexOf(":hover") === -1 &&
                            selectorText.indexOf(":before") === -1 &&
                            selectorText.indexOf(":after") === -1 &&
                            selectorText.indexOf(":active") === -1 &&
                            selectorText.indexOf(":link") === -1 &&
                            selectorText.indexOf("::") === -1 &&
                            selectorText.indexOf("\"") === -1 &&
                            selectorText.indexOf("'") === -1) {
                        var st = selectorText.split(/\s*,\s*/);
                        for (var k=0; k<st.length; k++) {
                            rulesCache.push({ 'selector': st[k], 'style': rules[r].style });
                        }
                    }
                }
            }
        }
        rulesCache.reverse();
    }

    var css = [];
    a.matches = a.matches || a.webkitMatchesSelector || a.mozMatchesSelector || a.msMatchesSelector || a.oMatchesSelector;
    for(var r = 0; r < rulesCache.length; r++) {
        if (a.matches(rulesCache[r].selector)) {
            var style = rulesCache[r].style;
            if (style.parentRule) {
                var style_obj = {};
                for (var k=0, len=style.length; k<len; k++) {
                    style_obj[style[k]] = style[style[k].replace(/-(.)/g, function (a, b) { return b.toUpperCase(); })];
                }
                rulesCache[r].style = style = style_obj;
            }
            css.push([rulesCache[r].selector, style]);
        }
    }

    function specificity (selector) {
        // http://www.w3.org/TR/css3-selectors/#specificity
        var a = 0;
        selector.replace(/#[a-z0-9_-]+/gi, function () { a++; return ""; });
        var b = 0;
        selector.replace(/(\.[a-z0-9_-]+)|(\[.*?\])/gi, function () { b++; return ""; });
        var c = 0;
        selector.replace(/(\s+|:+)[a-z0-9_-]+/gi, function (a) { if(a.indexOf(':not(')===-1) c++; return ""; });
        return a*100 + b*10 + c;
    }
    css.sort(function (a, b) { return specificity(a[0]) - specificity(b[0]); });

    var style = {};
    _.each(css, function (v,k) {
        _.each(v[1], function (v,k) {
            if (k.indexOf('-webkit') === -1 && (!style[k] || style[k].indexOf('important') === -1 || v.indexOf('important') !== -1)) {
                style[k] = v;
            }
        });
    });

    if (style.display === 'block') {
        delete style.display;
    }
    if (style['margin-top']) {
        style.margin = (style['margin-top'] || 0) + ' ' + (style['margin-right'] || 0) + ' ' + (style['margin-bottom'] || 0) + ' ' + (style['margin-left'] || 0);
        delete style['margin-top'];
        delete style['margin-right'];
        delete style['margin-bottom'];
        delete style['margin-left'];
    }
    if (style['padding-top']) {
        style.padding = (style['padding-top'] || 0) + ' ' + (style['padding-right'] || 0) + ' ' + (style['padding-bottom'] || 0) + ' ' + (style['padding-left'] || 0);
        delete style['padding-top'];
        delete style['padding-right'];
        delete style['padding-bottom'];
        delete style['padding-left'];
    }

    return a.className ? cache[a.tagName + "." +a.className] = style : style;
};

// convert font awsome into image
var font_to_img = function ($editable) {
    $(".fa", $editable).each(function () {
        var $font = $(this);
        var icon, content;
        _.find(widget.fontIcons, function (font) {
            return _.find(widget.getCssSelectors(font.parser), function (css) {
                if ($font.is(css[0].replace(/::?before$/, ''))) {
                    icon = css[2].split("-").shift();
                    content = css[1].match(/content:\s*['"]?(.)['"]?/)[1];
                    return true;
                }
            });
        });
        if (content) {
            var color = $font.css("color").replace(/\s/g, '');
            var src = _.str.sprintf('/web_editor/font_to_img/%s/%s/'+$font.height(), window.encodeURI(content), window.encodeURI(color));
            var $img = $("<img/>").attr("src", src)
                .attr("data-class", $font.attr("class"))
                .attr("class", $font.attr("class").replace(new RegExp("(^|\\s+)" + icon + "(-[^\\s]+)?", "gi"), '')) // remove inline font-awsome style
                .attr("style", $font.attr("style"))
                .attr("height", $font.height())
                .css("height", "")
                .css("font-size", "");
            $font.replaceWith($img);
        } else {
            $font.remove();
        }
    });
};
// convert image into font awsome
var img_to_font = function ($editable) {
    $("img[src*='/web_editor/font_to_img/']", $editable).each(function () {
        var $img = $(this);
        var $font = $("<span/>")
            .attr("class", $img.data("class"))
            .attr("style", $img.attr("style"))
            .css("height", "");
        $img.replaceWith($font);
    });
};

// convert class into inline style to send by mail
var class_to_style = function ($editable) {
    if (!rulesCache.length) {
        getMatchedCSSRules($editable[0]);
    }
    $editable.find('*').each(function () {
        var $target = $(this);
        var css = getMatchedCSSRules(this);
        var style = $target.attr("style") || "";
        _.each(css, function (v,k) {
            if (style.indexOf(k) === -1) {
                style = k+":"+v+";"+style;
            }
        });
        $target.attr("style", style);
    });
};
// convert style into inline class from mail
var style_to_class = function ($editable) {
    getMatchedCSSRules($editable[0]);

    var $c = $('<span/>').appendTo("body");

    $editable.find('*').each(function () {
        var $target = $(this);
        var css = getMatchedCSSRules(this);
        var style = "";
        _.each(css, function (v,k) {
            if (style.indexOf(k) === -1) {
                style = k+":"+v+";"+style;
            }
        });
        css = $c.attr("style", style).attr("style").split(/\s*;\s*/);
        style = $target.attr("style") || "";
        _.each(css, function (v) {
            style = style.replace(v, '');
        });
        style = style.replace(/;+(\s;)*/g, ';').replace(/^;/g, '');
        if (style !== '') {
            $target.attr("style", style);
        } else {
            $target.removeAttr("style");
        }
    });
    $c.remove();
};

return {
    'font_to_img': font_to_img,
    'img_to_font': img_to_font,
    'class_to_style': class_to_style,
    'style_to_class': style_to_class,
};

});
<commit_msg>[FIX] web_editor: inliner take in care the '!important' attributes<commit_after>odoo.define('web_editor.transcoder', function (require) {
'use strict';

var widget = require('web_editor.widget');

var cache = {};
var rulesCache = [];
var getMatchedCSSRules = function (a) {
    if(cache[a.tagName + "." +a.className]) {
        return cache[a.tagName + "." +a.className];
    }
    if (!rulesCache.length) {
        var sheets = document.styleSheets;
        for(var i = sheets.length-1; i >= 0 ; i--) {
            var rules;
            if (sheets[i].rules) {
                rules = sheets[i].rules;
            } else {
                //try...catch because Firefox not able to enumerate document.styleSheets[].cssRules[] for cross-domain stylesheets.
                try {
                    rules = sheets[i].cssRules;
                } catch(e) {
                    console.warn("Can't read the css rules of: " + sheets[i].href, e);
                    continue;
                }
                rules = sheets[i].cssRules;
            }
            if (rules) {
                for(var r = rules.length-1; r >= 0; r--) {
                    var selectorText = rules[r].selectorText;
                    if (selectorText &&
                            rules[r].cssText &&
                            selectorText !== "*" &&
                            selectorText.indexOf(":hover") === -1 &&
                            selectorText.indexOf(":before") === -1 &&
                            selectorText.indexOf(":after") === -1 &&
                            selectorText.indexOf(":active") === -1 &&
                            selectorText.indexOf(":link") === -1 &&
                            selectorText.indexOf("::") === -1 &&
                            selectorText.indexOf("\"") === -1 &&
                            selectorText.indexOf("'") === -1) {
                        var st = selectorText.split(/\s*,\s*/);
                        for (var k=0; k<st.length; k++) {
                            rulesCache.push({ 'selector': st[k], 'style': rules[r].style });
                        }
                    }
                }
            }
        }
        rulesCache.reverse();
    }

    var css = [];
    a.matches = a.matches || a.webkitMatchesSelector || a.mozMatchesSelector || a.msMatchesSelector || a.oMatchesSelector;
    for(var r = 0; r < rulesCache.length; r++) {
        if (a.matches(rulesCache[r].selector)) {
            var style = rulesCache[r].style;
            if (style.parentRule) {
                var style_obj = {};
                for (var k=0, len=style.length; k<len; k++) {
                    style_obj[style[k]] = style[style[k].replace(/-(.)/g, function (a, b) { return b.toUpperCase(); })];
                    if (new RegExp(style[k] + '\s*:[^:;]+!important' ).test(style.cssText)) {
                        style_obj[style[k]] += ' !important';
                    }
                }
                rulesCache[r].style = style = style_obj;
            }
            css.push([rulesCache[r].selector, style]);
        }
    }

    function specificity (selector) {
        // http://www.w3.org/TR/css3-selectors/#specificity
        var a = 0;
        selector.replace(/#[a-z0-9_-]+/gi, function () { a++; return ""; });
        var b = 0;
        selector.replace(/(\.[a-z0-9_-]+)|(\[.*?\])/gi, function () { b++; return ""; });
        var c = 0;
        selector.replace(/(\s+|:+)[a-z0-9_-]+/gi, function (a) { if(a.indexOf(':not(')===-1) c++; return ""; });
        return a*100 + b*10 + c;
    }
    css.sort(function (a, b) { return specificity(a[0]) - specificity(b[0]); });

    var style = {};
    _.each(css, function (v,k) {
        _.each(v[1], function (v,k) {
            if (k.indexOf('-webkit') === -1 && (!style[k] || style[k].indexOf('important') === -1 || v.indexOf('important') !== -1)) {
                style[k] = v;
            }
        });
    });

    _.each(style, function (v,k) {
        if (v.indexOf('important') !== -1) {
            style[k] = v.slice(0, v.length-11);
        }
    });

    if (style.display === 'block') {
        delete style.display;
    }
    if (style['margin-top']) {
        style.margin = (style['margin-top'] || 0) + ' ' + (style['margin-right'] || 0) + ' ' + (style['margin-bottom'] || 0) + ' ' + (style['margin-left'] || 0);
        delete style['margin-top'];
        delete style['margin-right'];
        delete style['margin-bottom'];
        delete style['margin-left'];
    }
    if (style['padding-top']) {
        style.padding = (style['padding-top'] || 0) + ' ' + (style['padding-right'] || 0) + ' ' + (style['padding-bottom'] || 0) + ' ' + (style['padding-left'] || 0);
        delete style['padding-top'];
        delete style['padding-right'];
        delete style['padding-bottom'];
        delete style['padding-left'];
    }

    return a.className ? cache[a.tagName + "." +a.className] = style : style;
};

// convert font awsome into image
var font_to_img = function ($editable) {
    $(".fa", $editable).each(function () {
        var $font = $(this);
        var icon, content;
        _.find(widget.fontIcons, function (font) {
            return _.find(widget.getCssSelectors(font.parser), function (css) {
                if ($font.is(css[0].replace(/::?before$/, ''))) {
                    icon = css[2].split("-").shift();
                    content = css[1].match(/content:\s*['"]?(.)['"]?/)[1];
                    return true;
                }
            });
        });
        if (content) {
            var color = $font.css("color").replace(/\s/g, '');
            var src = _.str.sprintf('/web_editor/font_to_img/%s/%s/'+$font.height(), window.encodeURI(content), window.encodeURI(color));
            var $img = $("<img/>").attr("src", src)
                .attr("data-class", $font.attr("class"))
                .attr("class", $font.attr("class").replace(new RegExp("(^|\\s+)" + icon + "(-[^\\s]+)?", "gi"), '')) // remove inline font-awsome style
                .attr("style", $font.attr("style"))
                .attr("height", $font.height())
                .css("height", "")
                .css("font-size", "");
            $font.replaceWith($img);
        } else {
            $font.remove();
        }
    });
};
// convert image into font awsome
var img_to_font = function ($editable) {
    $("img[src*='/web_editor/font_to_img/']", $editable).each(function () {
        var $img = $(this);
        var $font = $("<span/>")
            .attr("class", $img.data("class"))
            .attr("style", $img.attr("style"))
            .css("height", "");
        $img.replaceWith($font);
    });
};

// convert class into inline style to send by mail
var class_to_style = function ($editable) {
    if (!rulesCache.length) {
        getMatchedCSSRules($editable[0]);
    }
    $editable.find('*').each(function () {
        var $target = $(this);
        var css = getMatchedCSSRules(this);
        var style = $target.attr("style") || "";
        _.each(css, function (v,k) {
            if (style.indexOf(k) === -1) {
                style = k+":"+v+";"+style;
            }
        });
        $target.attr("style", style);
    });
};
// convert style into inline class from mail
var style_to_class = function ($editable) {
    getMatchedCSSRules($editable[0]);

    var $c = $('<span/>').appendTo("body");

    $editable.find('*').each(function () {
        var $target = $(this);
        var css = getMatchedCSSRules(this);
        var style = "";
        _.each(css, function (v,k) {
            if (style.indexOf(k) === -1) {
                style = k+":"+v+";"+style;
            }
        });
        css = $c.attr("style", style).attr("style").split(/\s*;\s*/);
        style = $target.attr("style") || "";
        _.each(css, function (v) {
            style = style.replace(v, '');
        });
        style = style.replace(/;+(\s;)*/g, ';').replace(/^;/g, '');
        if (style !== '') {
            $target.attr("style", style);
        } else {
            $target.removeAttr("style");
        }
    });
    $c.remove();
};

return {
    'font_to_img': font_to_img,
    'img_to_font': img_to_font,
    'class_to_style': class_to_style,
    'style_to_class': style_to_class,
};

});
<|endoftext|>


<commit_before>require('moonstone');

var
	kind = require('enyo/kind'),
	NewDataList = require('enyo/NewDataList');

var
	Spotlight = require('spotlight'),
	VDRSpotlightSupport = require('spotlight/VDRSpotlightSupport');

var
	Scrollable = require('../Scrollable'),
	ScrollControls = require('../ScrollControls');

module.exports = kind({
	name: 'moon.NewDataList',
	kind: NewDataList,
	scrollControls: [{kind: ScrollControls}],
	touch: false,
	mixins: [Scrollable, VDRSpotlightSupport],
	handlers: {
		onSpotlightUp: 'guard5way',
		onSpotlightRight: 'guard5way',
		onSpotlightDown: 'guard5way',
		onSpotlightLeft: 'guard5way'
	},
	/**
	* Prevent accelerating 5-way focus events from trying
	* to spot elements that don't yet have DOM nodes.
	*
	* @private
	*/
	guard5way: function (sender, event) {
		var e, l, idx, d2x, row, limitRow;

		// Only need to guard if we are accelerating
		if (!Spotlight.Accelerator.isAccelerating()) return false;

		e = event.type;

		if((e === 'onSpotlightUp' && this.direction == 'horizontal') || (e === 'onSpotlightLeft' && this.direction == 'vertical')) {
			return false;
		}

		// Figure out the index of the last de-virtualized element
		// in the direction we're currently scrolling; anything
		// further out doesn't yet have a DOM node
		l = (e === 'onSpotlightUp' || e === 'onSpotlightLeft') ?
			this.first :
			this._last;

		// Get the index of the currently focused element
		idx = event.index;

		// In case we're in a grid layout, we need to translate
		// these indices into the corresponding row / column
		d2x = this.dim2extent;
		row = Math.floor(idx / d2x);
		limitRow = Math.floor(l / d2x);

		// If we're in the last de-virtualized row, the element we
		// would focus from here doesn't yet have a DOM node, so
		// we return true to prevent an attempt to focus. We'll wait
		// for the next accelerated 5-way event and try again...
		return (row === limitRow);
	},
	/**
	* Scrolls to a list item (specified by index).
	*
	* In addition to the standard scrolling options, you can specify
	* `focus: true` if you want the item you're scrolling to to be
	* Spotlight focused. Currently, setting `focus: true` forces the
	* scroll behavior to be `instant`, meaning that the scroller will
	* jump to the item (with no animation).
	*
	* @see module:enyo/NewDataList~NewDataList.scrollToItem
	* @param {number} index - The (zero-based) index of the item to scroll to
	* @param {Object} opts - Scrolling options (see module:enyo/Scrollable~Scrollable.scrollTo)
	* @public
	*/
	scrollToItem: function(index, opts) {
		var item;

		if (opts && opts.focus) {
			opts.behavior = 'instant';
		}

		NewDataList.prototype.scrollToItem.apply(this, arguments);

		if (opts && opts.focus && !Spotlight.getPointerMode()) {
			item = this.childForIndex(index);
			if (item) Spotlight.spot(item);
		}
	},
	/**
	* Called by moonstone/Scrollable.filterFocus()
	* @private
	*/
	eventIsFromScrollingChild: function (event) {
		return (typeof event.index === 'number');
	},
	/**
	* Called by moonstone/Scrollable.filterFocus()
	* @private
	*/
	spotFirstVisibleChild: function() {
		var fv = this.getFullyVisibleItems()[0] || this.getVisibleItems()[0];
		if (fv) {
			Spotlight.spot(fv);
			return true;
		}
	}
});
<commit_msg>changes based on review comments<commit_after>require('moonstone');

var
	kind = require('enyo/kind'),
	NewDataList = require('enyo/NewDataList');

var
	Spotlight = require('spotlight'),
	VDRSpotlightSupport = require('spotlight/VDRSpotlightSupport');

var
	Scrollable = require('../Scrollable'),
	ScrollControls = require('../ScrollControls');

module.exports = kind({
	name: 'moon.NewDataList',
	kind: NewDataList,
	scrollControls: [{kind: ScrollControls}],
	touch: false,
	mixins: [Scrollable, VDRSpotlightSupport],
	handlers: {
		onSpotlightUp: 'guard5way',
		onSpotlightRight: 'guard5way',
		onSpotlightDown: 'guard5way',
		onSpotlightLeft: 'guard5way'
	},
	/**
	* Prevent accelerating 5-way focus events from trying
	* to spot elements that don't yet have DOM nodes.
	*
	* @private
	*/
	guard5way: function (sender, event) {
		var e, l, idx, d2x, row, limitRow, verMovOnHorScrol, horMovOnVerScrol;

		e = event.type;
		verMovOnHorScrol = (this.direction === 'horizintal' &&  (e === 'onSpotlightUp' || e === 'onSpotlightDown'));
		horMovOnVerScrol = (this.direction === 'vertical' &&  (e === 'onSpotlightRight' || e === 'onSpotlightLeft'));

		// Only need to guard if we are accelerating or
		// scroll direction and spotlight moving direction matches
		if (!Spotlight.Accelerator.isAccelerating() || verMovOnHorScrol || horMovOnVerScrol) return false;

		// Figure out the index of the last de-virtualized element
		// in the direction we're currently scrolling; anything
		// further out doesn't yet have a DOM node
		l = (e === 'onSpotlightUp' || e === 'onSpotlightLeft') ?
			this.first :
			this._last;

		// Get the index of the currently focused element
		idx = event.index;

		// In case we're in a grid layout, we need to translate
		// these indices into the corresponding row / column
		d2x = this.dim2extent;
		row = Math.floor(idx / d2x);
		limitRow = Math.floor(l / d2x);

		// If we're in the last de-virtualized row, the element we
		// would focus from here doesn't yet have a DOM node, so
		// we return true to prevent an attempt to focus. We'll wait
		// for the next accelerated 5-way event and try again...
		return (row === limitRow);
	},
	/**
	* Scrolls to a list item (specified by index).
	*
	* In addition to the standard scrolling options, you can specify
	* `focus: true` if you want the item you're scrolling to to be
	* Spotlight focused. Currently, setting `focus: true` forces the
	* scroll behavior to be `instant`, meaning that the scroller will
	* jump to the item (with no animation).
	*
	* @see module:enyo/NewDataList~NewDataList.scrollToItem
	* @param {number} index - The (zero-based) index of the item to scroll to
	* @param {Object} opts - Scrolling options (see module:enyo/Scrollable~Scrollable.scrollTo)
	* @public
	*/
	scrollToItem: function(index, opts) {
		var item;

		if (opts && opts.focus) {
			opts.behavior = 'instant';
		}

		NewDataList.prototype.scrollToItem.apply(this, arguments);

		if (opts && opts.focus && !Spotlight.getPointerMode()) {
			item = this.childForIndex(index);
			if (item) Spotlight.spot(item);
		}
	},
	/**
	* Called by moonstone/Scrollable.filterFocus()
	* @private
	*/
	eventIsFromScrollingChild: function (event) {
		return (typeof event.index === 'number');
	},
	/**
	* Called by moonstone/Scrollable.filterFocus()
	* @private
	*/
	spotFirstVisibleChild: function() {
		var fv = this.getFullyVisibleItems()[0] || this.getVisibleItems()[0];
		if (fv) {
			Spotlight.spot(fv);
			return true;
		}
	}
});
<|endoftext|>


<commit_before>/*
 * Copyright 2014-2016 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

define([
    'jquery'
], function($) {

    return {
        types: {
            ABANDONMENT: 'abandonment',
            CLICK_THROUGH: 'clickthrough',
            PAGE: 'page'
        },

        log: function (event) {
            $.ajax('../api/public/stats', {
                contentType: 'application/json',
                data: JSON.stringify(event),
                method: 'POST'
            });
        }
    };

});<commit_msg>[FIND-46] Add click types to Javascript<commit_after>/*
 * Copyright 2014-2016 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

define([
    'jquery'
], function($) {

    return {
        types: {
            ABANDONMENT: 'abandonment',
            CLICK_THROUGH: 'clickthrough',
            PAGE: 'page'
        },

        clickTypes: {
            FULL_PREVIEW: 'full_preview',
            ORIGINAL: 'original',
            PREVIEW: 'preview'
        },

        log: function (event) {
            $.ajax('../api/public/stats', {
                contentType: 'application/json',
                data: JSON.stringify(event),
                method: 'POST'
            });
        }
    };

});<|endoftext|>


<commit_before>/*
 * Copyright 2012-2014 Thomas Greiner <http://www.greinr.com>
 *
 * The contents of this file are subject to the Artistic License 2.0.
 * The full text can be found in the LICENSE.txt file and at
 * http://www.opensource.org/licenses/artistic-license-2.0
 */

var gui = require("nw.gui");
var database = require("./lib/database");

HTMLElement.prototype.create = function(type) {
  var element = document.createElement(type);
  this.appendChild(element);
  return element;
}

var GET = function(id) {return document.getElementById(id);}

var Main = new (function() {
  this.init = function() {
    database.init(gui.App.dataPath);
    GET("close").addEventListener("click", function() {
      window.close();
    }, false);
    Addressbar.init(GET("nav"));
    Navigation.init(GET("nav"));
    Toolbar.init(GET("toolbar"));
    Header.init(GET("header_bg"));
    Tabbar.init(GET("tabs_list"), GET("tabs_bg"));
    //Taskbar.init(GET("tasks"));
    Renderer.init(GET("browser"));
    Visualizer.init(GET("visualizer"));
  }
})();
document.addEventListener("DOMContentLoaded", Main.init, false);
<commit_msg>Replaced Main.init with anonymous function to get rid of Main<commit_after>/*
 * Copyright 2012-2014 Thomas Greiner <http://www.greinr.com>
 *
 * The contents of this file are subject to the Artistic License 2.0.
 * The full text can be found in the LICENSE.txt file and at
 * http://www.opensource.org/licenses/artistic-license-2.0
 */

var gui = require("nw.gui");
var database = require("./lib/database");

HTMLElement.prototype.create = function(type) {
  var element = document.createElement(type);
  this.appendChild(element);
  return element;
}

var GET = function(id) {
  return document.getElementById(id);
}

document.addEventListener("DOMContentLoaded", function() {
  database.init(gui.App.dataPath);
  GET("close").addEventListener("click", function() {
    window.close();
  }, false);
  Addressbar.init(GET("nav"));
  Navigation.init(GET("nav"));
  Toolbar.init(GET("toolbar"));
  Header.init(GET("header_bg"));
  Tabbar.init(GET("tabs_list"), GET("tabs_bg"));
  //Taskbar.init(GET("tasks"));
  Renderer.init(GET("browser"));
  Visualizer.init(GET("visualizer"));
}, false);
<|endoftext|>


<commit_before>import Ember from 'ember';

export default Ember.Controller.extend({
  isRaw: false,
  contestantSortProperties: ['total_points:desc',],
  sortedContestants: Ember.computed.sort(
    'model.contestants',
    'contestantSortProperties'
  ),
  contestSortProperties: ['name:asc',],
  sortedContests: Ember.computed.sort(
    'model.session.contests',
    'contestSortProperties'
  ),
  panelSort: ['designation:asc',],
  sortedPanel: Ember.computed.sort(
    'model.session.judges',
    'panelSort'
  ),
  actions: {
    letsGo() {
      this.toggleProperty('isRaw');
    },
  },
});
<commit_msg>Remove practice panel from oss<commit_after>import Ember from 'ember';

export default Ember.Controller.extend({
  isRaw: false,
  contestantSortProperties: ['total_points:desc',],
  sortedContestants: Ember.computed.sort(
    'model.contestants',
    'contestantSortProperties'
  ),
  contestSortProperties: ['name:asc',],
  sortedContests: Ember.computed.sort(
    'model.session.contests',
    'contestSortProperties'
  ),
  panelSort: ['designation:asc',],
  officialJudges: Ember.computed.filterBy(
    'model.session.judges',
    'kind',
    'Official'
  ),
  sortedPanel: Ember.computed.sort(
    'officialJudges',
    'panelSort'
  ),
  actions: {
    letsGo() {
      this.toggleProperty('isRaw');
    },
  },
});
<|endoftext|>


<commit_before>define([
  'jquery',
  'underscore',
  'backbone',
  'text!templates/email-popout.html',
  '../utils/animation',
  '../utils/custom-tagit',
], function ($, _, Backbone, emailPopoutTemplate, Animation, Tagit) {

  var EmailPopout = Backbone.View.extend({

    el: '#email-popout-container',

    template: _.template(emailPopoutTemplate),

    events: {
      'click #popout-cancel-btn': 'hidePopout',
      'click #popout-submit-btn': 'sendEmail',
      'click #cc-btn': 'showCCInput',
      'click #cc-me-btn': 'addUserToCC',
      'click #select-all-btn' : 'toggleCheckboxes',
      'focus #email-user-comment': 'toggleCommentModel',
      'blur #email-user-comment': 'toggleCommentModel',
      'keyup #email-user-comment': 'insertInputToMail'
    },

    initialize: function () {
      var emailService = this.model.emailService,
          data = this.model.data,
          $participantsTableContainer = $('#current-stage-detail-template'),
          callback;

      this.model = {};
      $participantsTableContainer.find('table').attr('class', 'checkbox-table');
      this.model.participantsTable = $participantsTableContainer.find('.table-container').html();

      if (!emailService || !data)
        throw new Error("Invalid parameters, must pass a model object contains EmailService and data");

      callback = function (result) {
        var model = this.model
        _.extend(model, result);
        this.$el.html(this.template(model));
        this.render();
      }.bind(this)

      emailService.getEmailContent(data, callback);
      this.emailService = emailService;

    },

    render: function () {
      this.commentTextArea = document.getElementById('email-user-comment');
      this.toAddressInput = document.getElementById('email-to-address');
      this.ccAddressInput = document.getElementById('email-cc-address');
      this.userCommentTextArea = document.getElementById('email-user-comment');
      this.$participantCheckboxes = this.$el.find('.row-checkbox-container input[type=checkbox]');

      var ccBeforeRemove = this.beforeRemoveUserFromCC.bind(this);
      this.ccAddressTagit = new Tagit('#email-cc-address', { beforeTagRemoved: ccBeforeRemove });
      this.insertAndCacheCommentArea();
      this.showPopout();
    },

    insertAndCacheCommentArea: function () {
      this.userCommentArea = document.getElementById('emailAdditionComments');
      $(this.userCommentArea).html('
Sender Comment:
');
      this.userComments = document.getElementById('user-comments');
    },

    hidePopout: function () {
      this.$el.fadeOut();
    },

    showPopout: function () {
      this.$el.fadeIn();
    },

    toggleCommentModel: function (e) {
      var commentTextArea = e.target,
          $commentTextArea = $(commentTextArea),
          isFocus = $commentTextArea.is(':focus'),
          popout = document.getElementById('email-popout');

      if (isFocus) {
        Animation.move(popout, { top: 10 });
        Animation.dimension('#email-user-comment', { height: 120 });
        $('#emailAdditionComments').fadeIn();

      } else if ((commentTextArea.textLength || $commentTextArea.val()).length === 0) {
        Animation.move(popout, { top: 60 });
        Animation.dimension('#email-user-comment', { height: 60 });
        $('#emailAdditionComments').fadeOut();
      }

    },

    insertInputToMail: function (e) {
      var userInput = this.commentTextArea.value;
      console.log(userInput);
      this.userComments.innerHTML = userInput;
    },

    showCCInput: function (e) {
      $(e.target).fadeOut('fast');
      this.$el.find('#email-cc-container').fadeIn('fast');
    },

    addUserToCC: function (e) {
      var addBtn = e.target,
          user = Backbone.user,
          $ccInputBox = this.$el.find('#email-cc-address'),
          currentUser = user.name + ' [' + user.emailAddress + ']';

      if (!(user && user.name && user.emailAddress)) {
        this.showAlert('Can not retrieve your information (name / email address).');
        return;
      }

      addBtn.setAttribute('disabled', 'true');

      this.ccAddressTagit.add(currentUser);
    },

    beforeRemoveUserFromCC: function(event, ui) {
      var username = Backbone.user.name;
      if (ui.tagLabel.indexOf(username) >= 0) {
        this.$el.find('#cc-me-btn').removeAttr('disabled');
      }
      console.log(ui);
    },

    showAlert: function (message) {
      var $alertTag = this.$el.find('.error-message');
      $alertTag.append(message);
    },

    sendEmail: function (e) {
      var isValid = this._validateForm(),
          sendBtn = e.target,
          incidentId = Backbone.incident.incidentId,
          showResultFunc = this._showSendResult.bind(this),
          model = this.model,
          $checkboxes = this.$participantCheckboxes,
          toAddressArray = [],
          selectedCheckboxes = _.filter($checkboxes, function (checkbox) { return checkbox.checked == true });

      showResultFunc = _.partial(showResultFunc, _, [sendBtn]);

      if (isValid) {
        sendBtn.setAttribute('disabled', 'true');

        _.each(selectedCheckboxes, function (checkbox) {
          toAddressArray.push(checkbox.value);
        });

        model.ToAddress = toAddressArray.join(',');
        model.CCAddress = this.ccAddressInput.value;
        model.UserMessageBody = this.userCommentTextArea.value;

        this.emailService.send(incidentId, model, showResultFunc);
      }
    },

    toggleCheckboxes: function(e) {
      var $selectAllBtn = $(e.target),
          $checkboxes = this.$participantCheckboxes;

      if ($checkboxes.prop('checked')) {
        $checkboxes.each(function () {
          this.checked = false;
        });
      } else {
        $checkboxes.each(function () {
          this.checked = true
        });
      }
    },

    _validateForm: function () {
      return true;
    },

    _showSendResult: function (result, elems) {
      var $alertTag;

      _.each(elems, function (elem) {
        elem.removeAttribute('disabled');
      });

      $alertTag = this.$el.find('header > h4');
      $alertTag.html(result.message);

      if (result.success) {
        $alertTag.attr('class', 'text-success');
      } else {
        $alertTag.attr('class', 'text-danger');
      }
    },

  });

  return EmailPopout;
});<commit_msg>Fix Bug: Tagit error(cannot call methods on tagit prior to initialization) when click Add-Me button to add user to cc-address, it happens when second time and later open email popout, not first time.<commit_after>define([
  'jquery',
  'underscore',
  'backbone',
  'text!templates/email-popout.html',
  '../utils/animation',
  '../utils/custom-tagit',
], function ($, _, Backbone, emailPopoutTemplate, Animation, Tagit) {

  var EmailPopout = Backbone.View.extend({

    el: '#email-popout-container',

    template: _.template(emailPopoutTemplate),

    events: {
      'click #popout-cancel-btn': 'hidePopout',
      'click #popout-submit-btn': 'sendEmail',
      'click #cc-btn': 'showCCInput',
      'click #cc-me-btn': 'addUserToCC',
      'click #select-all-btn' : 'toggleCheckboxes',
      'focus #email-user-comment': 'toggleCommentModel',
      'blur #email-user-comment': 'toggleCommentModel',
      'keyup #email-user-comment': 'insertInputToMail'
    },

    initialize: function () {
      var emailService = this.model.emailService,
          data = this.model.data,
          $participantsTableContainer = $('#current-stage-detail-template'),
          callback;

      this.model = {};
      $participantsTableContainer.find('table').attr('class', 'checkbox-table');
      this.model.participantsTable = $participantsTableContainer.find('.table-container').html();

      if (!emailService || !data)
        throw new Error("Invalid parameters, must pass a model object contains EmailService and data");

      callback = function (result) {
        var model = this.model
        _.extend(model, result);
        this.$el.html(this.template(model));
        this.render();
      }.bind(this)

      emailService.getEmailContent(data, callback);
      this.emailService = emailService;

    },

    render: function () {
      this.commentTextArea = document.getElementById('email-user-comment');
      this.ccAddressInput = document.getElementById('email-cc-address');
      this.userCommentTextArea = document.getElementById('email-user-comment');
      this.$participantCheckboxes = this.$el.find('.row-checkbox-container input[type=checkbox]');

      var ccBeforeRemove = this.beforeRemoveUserFromCC.bind(this);
      this.ccAddressTagit = new Tagit('#email-cc-address', { beforeTagRemoved: ccBeforeRemove });
      this.insertAndCacheCommentArea();
      this.showPopout();
    },

    insertAndCacheCommentArea: function () {
      this.userCommentArea = document.getElementById('emailAdditionComments');
      $(this.userCommentArea).html('
Sender Comment:
');
      this.userComments = document.getElementById('user-comments');
    },

    hidePopout: function () {
      this.$el.fadeOut();
    },

    showPopout: function () {
      this.$el.fadeIn();
    },

    toggleCommentModel: function (e) {
      var commentTextArea = e.target,
          $commentTextArea = $(commentTextArea),
          isFocus = $commentTextArea.is(':focus'),
          popout = document.getElementById('email-popout');

      if (isFocus) {
        Animation.move(popout, { top: 10 });
        Animation.dimension('#email-user-comment', { height: 120 });
        $('#emailAdditionComments').fadeIn();

      } else if ((commentTextArea.textLength || $commentTextArea.val()).length === 0) {
        Animation.move(popout, { top: 60 });
        Animation.dimension('#email-user-comment', { height: 60 });
        $('#emailAdditionComments').fadeOut();
      }

    },

    insertInputToMail: function (e) {
      var userInput = this.commentTextArea.value;
      console.log(userInput);
      this.userComments.innerHTML = userInput;
    },

    showCCInput: function (e) {
      $(e.target).fadeOut('fast');
      this.$el.find('#email-cc-container').fadeIn('fast');
    },

    addUserToCC: function (e) {
      var addBtn = e.target,
          user = Backbone.user,
          $ccInputBox = this.$el.find('#email-cc-address'),
          currentUser = user.name + ' [' + user.emailAddress + ']';

      if (!(user && user.name && user.emailAddress)) {
        this.showAlert('Can not retrieve your information (name / email address).');
        return;
      }

      addBtn.setAttribute('disabled', 'true');

      // Use this has error: cannot call methods on tagit prior to initialization
      // TODO: figure out why.
      //-----------------------
      //this.ccAddressTagit.add(currentUser);

      // Use update in custom-tagit
      this.ccAddressInput.value = this.ccAddressInput.value.concat(currentUser);
      this.ccAddressTagit.update();
    },

    beforeRemoveUserFromCC: function(event, ui) {
      var username = Backbone.user.name;
      if (ui.tagLabel.indexOf(username) >= 0) {
        this.$el.find('#cc-me-btn').removeAttr('disabled');
      }
      console.log(ui);
    },

    showAlert: function (message) {
      var $alertTag = this.$el.find('.error-message');
      $alertTag.append(message);
    },

    sendEmail: function (e) {
      var isValid = this._validateForm(),
          sendBtn = e.target,
          incidentId = Backbone.incident.incidentId,
          showResultFunc = this._showSendResult.bind(this),
          model = this.model,
          $checkboxes = this.$participantCheckboxes,
          toAddressArray = [],
          selectedCheckboxes = _.filter($checkboxes, function (checkbox) { return checkbox.checked == true });

      showResultFunc = _.partial(showResultFunc, _, [sendBtn]);

      if (isValid) {
        sendBtn.setAttribute('disabled', 'true');

        _.each(selectedCheckboxes, function (checkbox) {
          toAddressArray.push(checkbox.value);
        });

        model.ToAddress = toAddressArray.join(',');
        model.CCAddress = this.ccAddressInput.value;
        model.UserMessageBody = this.userCommentTextArea.value;

        this.emailService.send(incidentId, model, showResultFunc);
      }
    },

    toggleCheckboxes: function(e) {
      var $selectAllBtn = $(e.target),
          $checkboxes = this.$participantCheckboxes;

      if ($checkboxes.prop('checked')) {
        $checkboxes.each(function () {
          this.checked = false;
        });
      } else {
        $checkboxes.each(function () {
          this.checked = true
        });
      }
    },

    _validateForm: function () {
      return true;
    },

    _showSendResult: function (result, elems) {
      var $alertTag;

      _.each(elems, function (elem) {
        elem.removeAttribute('disabled');
      });

      $alertTag = this.$el.find('header > h4');
      $alertTag.html(result.message);

      if (result.success) {
        $alertTag.attr('class', 'text-success');
      } else {
        $alertTag.attr('class', 'text-danger');
      }
    },

  });

  return EmailPopout;
});<|endoftext|>


<commit_before>

angular.module("detailedBlock", ["ngRoute","d3"])
.controller('DetailedBlockController',  ['$scope','$http', '$routeParams', function($scope,$http, $routeParams) {
    var controller=this;
    var currentBlock;
    $scope.scoreData;

    $http.get('https://blockexplorer.com/api/block/'+$routeParams.blockid).success(function(data) {
      controller.currentBlock = data;
      $scope.scoreData=data.tx;
    });
  }])
  .directive('d3Bars', ['$window', '$timeout', 'd3Service', "$http",
    function($window, $timeout, d3Service,$http) {
      return {
        restrict: 'EA',
        scope: {
          data:'='
        },
        link: function(scope, ele, attrs) {

          var width = 640,
          height = 480;

          var nodes = [];

          var links = [];

          var generateLinksAndNodes = function(data){
              var numOfTxs=data.length;
              for(var i = 0; i < numOfTxs; i++){
                var obj={source:i,target:i+1};
                var node={x:width/3,y:i*height/3, hash:data[i]};
                nodes.push(node);
                if(i<numOfTxs-1){
                  links.push(obj);
                }
              }
          }

          d3Service.d3().then(function(d3) {

         //Watch 'data' and run scope.render whenever it changes
          scope.$watch('data', function(){
              scope.render(scope.data);
          }, true);

          scope.render = function(data) {
            if(!(!data)){

              generateLinksAndNodes(data);

              var svg = d3.select(ele[0]).append('svg')
              .attr("width", width)
              .attr("height", height)
              .call(d3.behavior.zoom().scaleExtent([0.5, 8]).on("zoom", zoom))
              .append("g");

              var force = d3.layout.force()
                  .size([width, height])
                  .nodes(nodes)
                  .links(links);

              force.gravity(0);
              force.linkDistance(height/3-20);

              var link = svg.selectAll('.link')
                  .data(links)
                  .enter().append('line')
                  .attr('class', 'link');

              var node = svg.selectAll('g.node')
                  .data(nodes)
                  .enter()
                  .append("g")
                  .attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });

                  node.append("circle")
                  .attr('class', 'node')
                  .on("click", click);

              var texts = svg.selectAll("text.label")
                .data(nodes)
                .enter().append("text")
                .attr("class", "label")
                .attr("fill", "black");

              force.on('end', function() {

                  node.selectAll(".node")
                      .attr('r', width/100);

                  link.attr('x1', function(d) { return d.source.x; })
                      .attr('y1', function(d) { return d.source.y; })
                      .attr('x2', function(d) { return d.target.x; })
                      .attr('y2', function(d) { return d.target.y; });

                  texts.text(function(d) {  return d.hash;  })
                  .attr("transform", function(d) {
                      return "translate(" + (d.x+35) + "," + d.y + ")";
                  });
              });

              force.start();

              function zoom() {
                  svg.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
              }

              function click(data) {
                  //reset other elements
                  d3.selectAll('.node')
                  .style('fill', null)
                  .attr("r", width/100);

                  node.selectAll('.coinValue')
                  .remove();

                  //fill in blue
                  d3.select(this).transition()
                  .duration(750)
                  .attr("r", 30)
                  .style("fill", "lightsteelblue");

                  $http.get('https://blockexplorer.com/api/tx/'+data.hash).success(function(txResult) {
                    node.filter(function (o) {return o.index === data.index;})
                    .append("text")
                    .attr("class", "coinValue")
                    .attr("fill", "black")
                    .attr("text-anchor", "middle")
                    .text(Math.round(txResult.valueOut*10)/100);
                  });
              }
            }
          }
          });
        }}
  }]);

  angular.module('d3', [])
  .factory('d3Service', ['$document', '$window', '$q', '$rootScope',
    function($document, $window, $q, $rootScope) {
      var d = $q.defer(),
          d3service = {
            d3: function() { return d.promise; }
          };
    function onScriptLoad() {
      // Load client in the browser
      $rootScope.$apply(function() { d.resolve($window.d3); });
    }
    var scriptTag = $document[0].createElement('script');
    scriptTag.type = 'text/javascript';
    scriptTag.async = true;
    scriptTag.src = 'http://d3js.org/d3.v3.min.js';
    scriptTag.onreadystatechange = function () {
      if (this.readyState == 'complete') onScriptLoad();
    }
    scriptTag.onload = onScriptLoad;

    var s = $document[0].getElementsByTagName('body')[0];
    s.appendChild(scriptTag);

    return d3service;
  }]);
<commit_msg>Fixed spacing issue between nodes<commit_after>

angular.module("detailedBlock", ["ngRoute","d3"])
.controller('DetailedBlockController',  ['$scope','$http', '$routeParams', function($scope,$http, $routeParams) {
    var controller=this;
    var currentBlock;
    $scope.scoreData;

    $http.get('https://blockexplorer.com/api/block/'+$routeParams.blockid).success(function(data) {
      controller.currentBlock = data;
      $scope.scoreData=data.tx;
    });
  }])
  .directive('d3Bars', ['$window', '$timeout', 'd3Service', "$http",
    function($window, $timeout, d3Service,$http) {
      return {
        restrict: 'EA',
        scope: {
          data:'='
        },
        link: function(scope, ele, attrs) {

          var width = 640,
          height = 480;

          var nodes = [];

          var links = [];

          var generateLinksAndNodes = function(data){
              var numOfTxs=data.length;
              for(var i = 0; i < numOfTxs; i++){
                var obj={source:i,target:i+1};
                var node={x:width/3,y:i*height/3, hash:data[i]};
                nodes.push(node);
                if(i<numOfTxs-1){
                  links.push(obj);
                }
              }
          }

          d3Service.d3().then(function(d3) {

         //Watch 'data' and run scope.render whenever it changes
          scope.$watch('data', function(){
              scope.render(scope.data);
          }, true);

          scope.render = function(data) {
            if(!(!data)){

              generateLinksAndNodes(data);

              var svg = d3.select(ele[0]).append('svg')
              .attr("width", width)
              .attr("height", height)
              .call(d3.behavior.zoom().scaleExtent([0.5, 8]).on("zoom", zoom))
              .append("g");

              var force = d3.layout.force()
                  .size([width, height])
                  .nodes(nodes)
                  .links(links);

              force.gravity(0);
              force.linkDistance(height/3-20);

              var link = svg.selectAll('.link')
                  .data(links)
                  .enter().append('line')
                  .attr('class', 'link');

              var node = svg.selectAll('g.node')
                  .data(nodes)
                  .enter()
                  .append("g")
                  .attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });

              node.append("circle")
              .attr('class', 'node')
              .on("click", click);

              var texts = svg.selectAll("text.label")
                .data(nodes)
                .enter().append("text")
                .attr("class", "label")
                .attr("fill", "black");

              force.on('end', function() {

                  node.selectAll(".node")
                      .attr('r', width/100);

                  link.attr('x1', function(d) { return d.source.x; })
                      .attr('y1', function(d) { return d.source.y-13; })
                      .attr('x2', function(d) { return d.target.x; })
                      .attr('y2', function(d) { return d.target.y+13; });

                  texts.text(function(d) {  return d.hash;  })
                  .attr("transform", function(d) {
                      return "translate(" + (d.x+35) + "," + d.y + ")";
                  });
              });

              force.start();

              function zoom() {
                  svg.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
              }

              function click(data) {
                  //reset other elements
                  d3.selectAll('.node')
                  .style('fill', null)
                  .attr("r", width/100);

                  node.selectAll('.coinValue')
                  .remove();

                  //fill in blue
                  d3.select(this).transition()
                  .duration(750)
                  .attr("r", 30)
                  .style("fill", "lightsteelblue");

                  $http.get('https://blockexplorer.com/api/tx/'+data.hash).success(function(txResult) {
                    node.filter(function (o) {return o.index === data.index;})
                    .append("text")
                    .attr("class", "coinValue")
                    .attr("fill", "black")
                    .attr("text-anchor", "middle")
                    .text(Math.round(txResult.valueOut*10)/100);
                  });
              }
            }
          }
          });
        }}
  }]);

  angular.module('d3', [])
  .factory('d3Service', ['$document', '$window', '$q', '$rootScope',
    function($document, $window, $q, $rootScope) {
      var d = $q.defer(),
          d3service = {
            d3: function() { return d.promise; }
          };
    function onScriptLoad() {
      // Load client in the browser
      $rootScope.$apply(function() { d.resolve($window.d3); });
    }
    var scriptTag = $document[0].createElement('script');
    scriptTag.type = 'text/javascript';
    scriptTag.async = true;
    scriptTag.src = 'http://d3js.org/d3.v3.min.js';
    scriptTag.onreadystatechange = function () {
      if (this.readyState == 'complete') onScriptLoad();
    }
    scriptTag.onload = onScriptLoad;

    var s = $document[0].getElementsByTagName('body')[0];
    s.appendChild(scriptTag);

    return d3service;
  }]);
<|endoftext|>


<commit_before>/*---------------------------------------------------------
 * OpenERP web_linkedin (module)
 *---------------------------------------------------------*/

openerp.web_linkedin = function(instance) {
    var QWeb = instance.web.qweb;
    var _t = instance.web._t;

    instance.web_linkedin.LinkedinTester = instance.web.Class.extend({
        init: function() {
            this.api_key = "cxnr0l53n73x";
            this.linkedin_added = false;
            this.linkedin_def = $.Deferred();
            this.auth_def = $.Deferred();
        },
        test_linkedin: function() {
            var self = this;
            return this.test_api_key().pipe(function() {
                if (self.linkedin_added)
                    return self.linkedin_def.promise();
                var tag = document.createElement('script');
                tag.type = 'text/javascript';
                tag.src = "http://platform.linkedin.com/in.js";
                tag.innerHTML = 'api_key : ' + self.api_key + '\nauthorize : true';
                document.getElementsByTagName('head')[0].appendChild(tag);
                self.linkedin_added = true;
                $(tag).load(function() {
                    IN.Event.on(IN, "auth", function() {
                        self.auth_def.resolve();
                    });
                    self.linkedin_def.resolve();
                });
                return self.linkedin_def.promise();
            });
        },
        test_api_key: function() {
            if (this.api_key) {
                return $.when();
            }
            return new instance.web.Model("ir.config_parameter").call("get_param", ["web.linkedin.apikey"]).pipe(function(a) {
                if (a !== false) {
                    self.api_key = a;
                    return true;
                } else {
                    return $.Deferred().reject();
                }
            });
        },
        test_authentication: function() {
            return this.auth_def.promise();
        },
    });

                /*return new instance.web.Model("ir.config_parameter").call("set_param", ["web.linkedin.apikey", "cxnr0l53n73x"]).pipe(function() {
                    return self.test_linkedin();
                });*/

    instance.web_linkedin.tester = new instance.web_linkedin.LinkedinTester();

    instance.web_linkedin.Linkedin = instance.web.form.FieldChar.extend({
        init: function() {
            this._super.apply(this, arguments);
            this.display_dm = new instance.web.DropMisordered(true);
        },
        initialize_content: function() {
            var $ht = $(QWeb.render("FieldChar.linkedin"));
            var $in = this.$("input");
            $in.replaceWith($ht);
            this.$(".oe_linkedin_input").append($in);
            this.$(".oe_linkedin_img").click(_.bind(this.search_linkedin, this));
            this._super();

        },
        search_linkedin: function() {
            var self = this;
            this.display_dm.add(instance.web_linkedin.tester.test_linkedin()).then(function() {
                var pop = new instance.web_linkedin.LinkedinPopup(self, self.get("value"));
                pop.open();
                pop.on("selected", this, function(entity) {
                    self.selected_entity(entity);
                });
            });
        },
        selected_entity: function(entity) {
            var self = this;
            var to_change = {};
            var defs = [];
            if (entity.__type === "company") {
                to_change.name = entity.name;
                if (entity.logoUrl) {
                    defs.push(self.rpc('/web_linkedin/binary/url2binary',
                                       {'url': entity.logoUrl}).pipe(function(data){
                        to_change.photo = data;
                    }));
                }
            } else { //people
                to_change.name = _.str.sprintf("%s %s", entity.firstName, entity.lastName);
                if (entity.pictureUrl) {
                    defs.push(self.rpc('/web_linkedin/binary/url2binary',
                                       {'url': entity.pictureUrl}).pipe(function(data){
                        to_change.photo = data;
                    }));
                }
            }
            $.when.apply($, defs).then(function() {
                self.view.on_processed_onchange({value:to_change});
            });
        },
    });

    instance.web.form.widgets.add('linkedin', 'instance.web_linkedin.Linkedin');

    instance.web_linkedin.LinkedinPopup = instance.web.Dialog.extend({
        template: "Linkedin.popup",
        init: function(parent, text) {
            this._super(parent, {title:_t("LinkedIn search")});
            this.text = text;
            this.limit = 15;
        },
        start: function() {
            this._super();
            var self = this;
            this.on("authentified", this, this.authentified);
            instance.web_linkedin.tester.test_authentication().then(function() {
                self.trigger("authentified");
            });
        },
        authentified: function() {
            var self = this;
            cdef = $.Deferred();
            pdef = $.Deferred();
            IN.API.Raw(_.str.sprintf("company-search:(companies:(id,name,logo-url))?keywords=%s&count=%d", encodeURI(this.text), this.limit)).result(function (result) {
                cdef.resolve(result);
            });
            IN.API.PeopleSearch().fields(["id", "first-name", "last-name","picture-url"]).
                params({"keywords": this.text, "count": this.limit}).result(function(result) {
                pdef.resolve(result);
            });
            return $.when(cdef, pdef).then(function(companies, people) {
                var lst = companies.companies.values || [];
                var plst = people.people.values || [];
                lst = _.initial(lst, _.min([self.limit / 2, plst.length]));
                _.map(lst, function(el) {
                    el.__type = "company";
                    return el;
                });
                plst = _.first(plst, self.limit - lst.length)
                _.map(plst, function(el) {
                    el.__type = "people";
                    return el;
                });
                lst = plst.concat(lst);
                console.log("Linkedin search found:", lst.length, lst);
                self.result = lst;
                self.display_result();
            });
        },
        display_result: function() {
            var self = this;
            var i = 0;
            var $row;
            _.each(self.result, function(el) {
                var pc = new instance.web_linkedin.EntityWidget(self, el);
                if (i % 5 === 0) {
                    $row = $("
");
                    $row.appendTo(self.$(">div"));
                }
                pc.appendTo($row);
                pc.$element.css("display", "table-cell");
                pc.$element.css("width", "20%");
                pc.on("selected", self, function(data) {
                    self.trigger("selected", data);
                    self.destroy();
                });
                i++;
            });
        },
    });

    instance.web_linkedin.EntityWidget = instance.web.Widget.extend({
        template: "EntityWidget",
        init: function(parent, data) {
            this._super(parent);
            this.data = data;
        },
        start: function() {
            var self = this;
            this.$element.click(function() {
                self.trigger("selected", self.data);
            });
            if (this.data.__type === "company") {
                this.$("h3").text(this.data.name);
                self.$("img").attr("src", this.data.logoUrl);
            } else { // people
                this.$("h3").text(_.str.sprintf("%s %s", this.data.firstName, this.data.lastName));
                self.$("img").attr("src", this.data.pictureUrl);
            }
        },
    });
};
// vim:et fdc=0 fdl=0:
<commit_msg>Began profile url<commit_after>/*---------------------------------------------------------
 * OpenERP web_linkedin (module)
 *---------------------------------------------------------*/

openerp.web_linkedin = function(instance) {
    var QWeb = instance.web.qweb;
    var _t = instance.web._t;

    instance.web_linkedin.LinkedinTester = instance.web.Class.extend({
        init: function() {
            this.api_key = "cxnr0l53n73x";
            this.linkedin_added = false;
            this.linkedin_def = $.Deferred();
            this.auth_def = $.Deferred();
        },
        test_linkedin: function() {
            var self = this;
            return this.test_api_key().pipe(function() {
                if (self.linkedin_added)
                    return self.linkedin_def.promise();
                var tag = document.createElement('script');
                tag.type = 'text/javascript';
                tag.src = "http://platform.linkedin.com/in.js";
                tag.innerHTML = 'api_key : ' + self.api_key + '\nauthorize : true';
                document.getElementsByTagName('head')[0].appendChild(tag);
                self.linkedin_added = true;
                $(tag).load(function() {
                    IN.Event.on(IN, "auth", function() {
                        self.auth_def.resolve();
                    });
                    self.linkedin_def.resolve();
                });
                return self.linkedin_def.promise();
            });
        },
        test_api_key: function() {
            if (this.api_key) {
                return $.when();
            }
            return new instance.web.Model("ir.config_parameter").call("get_param", ["web.linkedin.apikey"]).pipe(function(a) {
                if (a !== false) {
                    self.api_key = a;
                    return true;
                } else {
                    return $.Deferred().reject();
                }
            });
        },
        test_authentication: function() {
            return this.auth_def.promise();
        },
    });

                /*return new instance.web.Model("ir.config_parameter").call("set_param", ["web.linkedin.apikey", "cxnr0l53n73x"]).pipe(function() {
                    return self.test_linkedin();
                });*/

    instance.web_linkedin.tester = new instance.web_linkedin.LinkedinTester();

    instance.web_linkedin.Linkedin = instance.web.form.FieldChar.extend({
        init: function() {
            this._super.apply(this, arguments);
            this.display_dm = new instance.web.DropMisordered(true);
        },
        initialize_content: function() {
            var $ht = $(QWeb.render("FieldChar.linkedin"));
            var $in = this.$("input");
            $in.replaceWith($ht);
            this.$(".oe_linkedin_input").append($in);
            this.$(".oe_linkedin_img").click(_.bind(this.search_linkedin, this));
            this._super();

        },
        search_linkedin: function() {
            var self = this;
            this.display_dm.add(instance.web_linkedin.tester.test_linkedin()).then(function() {
                var pop = new instance.web_linkedin.LinkedinPopup(self, self.get("value"));
                pop.open();
                pop.on("selected", this, function(entity) {
                    self.selected_entity(entity);
                });
            });
        },
        selected_entity: function(entity) {
            var self = this;
            var to_change = {};
            var defs = [];
            if (entity.__type === "company") {
                to_change.name = entity.name;
                if (entity.logoUrl) {
                    defs.push(self.rpc('/web_linkedin/binary/url2binary',
                                       {'url': entity.logoUrl}).pipe(function(data){
                        to_change.photo = data;
                    }));
                }
                /*
                to_change.linkedinUrl = _.str.sprintf("http://www.linkedin.com/company/%d", entity.id);
                */
            } else { // people
                to_change.name = _.str.sprintf("%s %s", entity.firstName, entity.lastName);
                if (entity.pictureUrl) {
                    defs.push(self.rpc('/web_linkedin/binary/url2binary',
                                       {'url': entity.pictureUrl}).pipe(function(data){
                        to_change.photo = data;
                    }));
                }
                /*
                to_change.linkedinUrl = entity.publicProfileUrl;
                */
            }
            $.when.apply($, defs).then(function() {
                self.view.on_processed_onchange({value:to_change});
            });
        },
    });

    instance.web.form.widgets.add('linkedin', 'instance.web_linkedin.Linkedin');

    instance.web_linkedin.LinkedinPopup = instance.web.Dialog.extend({
        template: "Linkedin.popup",
        init: function(parent, text) {
            this._super(parent, {title:_t("LinkedIn search")});
            this.text = text;
            this.limit = 15;
        },
        start: function() {
            this._super();
            var self = this;
            this.on("authentified", this, this.authentified);
            instance.web_linkedin.tester.test_authentication().then(function() {
                self.trigger("authentified");
            });
        },
        authentified: function() {
            var self = this;
            cdef = $.Deferred();
            pdef = $.Deferred();
            IN.API.Raw(_.str.sprintf("company-search:(companies:(id,name,logo-url))?keywords=%s&count=%d", encodeURI(this.text), this.limit)).result(function (result) {
                cdef.resolve(result);
            });
            IN.API.PeopleSearch().fields(["id", "first-name", "last-name", "picture-url", "public-profile-url"]).
                params({"keywords": this.text, "count": this.limit}).result(function(result) {
                pdef.resolve(result);
            });
            return $.when(cdef, pdef).then(function(companies, people) {
                var lst = companies.companies.values || [];
                var plst = people.people.values || [];
                lst = _.initial(lst, _.min([self.limit / 2, plst.length]));
                _.map(lst, function(el) {
                    el.__type = "company";
                    return el;
                });
                plst = _.first(plst, self.limit - lst.length)
                _.map(plst, function(el) {
                    el.__type = "people";
                    return el;
                });
                lst = plst.concat(lst);
                console.log("Linkedin search found:", lst.length, lst);
                self.result = lst;
                self.display_result();
            });
        },
        display_result: function() {
            var self = this;
            var i = 0;
            var $row;
            _.each(self.result, function(el) {
                var pc = new instance.web_linkedin.EntityWidget(self, el);
                if (i % 5 === 0) {
                    $row = $("
");
                    $row.appendTo(self.$(">div"));
                }
                pc.appendTo($row);
                pc.$element.css("display", "table-cell");
                pc.$element.css("width", "20%");
                pc.on("selected", self, function(data) {
                    self.trigger("selected", data);
                    self.destroy();
                });
                i++;
            });
        },
    });

    instance.web_linkedin.EntityWidget = instance.web.Widget.extend({
        template: "EntityWidget",
        init: function(parent, data) {
            this._super(parent);
            this.data = data;
        },
        start: function() {
            var self = this;
            this.$element.click(function() {
                self.trigger("selected", self.data);
            });
            if (this.data.__type === "company") {
                this.$("h3").text(this.data.name);
                self.$("img").attr("src", this.data.logoUrl);
            } else { // people
                this.$("h3").text(_.str.sprintf("%s %s", this.data.firstName, this.data.lastName));
                self.$("img").attr("src", this.data.pictureUrl);
            }
        },
    });
};
// vim:et fdc=0 fdl=0:
<|endoftext|>


<commit_before>var STRING_CAMELIZE_REGEXP = (/(\-|_|\.|\s)+(.)?/g);

var plugins = {};

var preprocess = function(tree) {
  tree = plugins.broccoliEmberHbsTemplateCompiler(tree, {module: true});
  tree = plugins.broccoliCoffee(tree, {
    bare: true
  });
  return tree;
};

var camelize = function(str) {
  return str.replace(STRING_CAMELIZE_REGEXP, function(match, separator, chr) {
    return chr ? chr.toUpperCase() : '';
  }).replace(/^([A-Z])/, function(match, separator, chr) {
    return match.toLowerCase();
  });
};

require('matchdep').filterDev('broccoli-*').forEach(function(p, idx) {
  if (['broccoli-cli'].indexOf(p) < 0) {
    plugins[camelize(p)] = require(p);
  }
});

var lib = 'lib',
    styles = 'styles',
    env = plugins.broccoliEnv.getEnv(),
    sourceTrees,
    pkg,
    css;

lib = plugins.broccoliStaticCompiler(lib, {
  srcDir: '/',
  destDir: '/'
});

styles = plugins.broccoliStaticCompiler(styles, {
  srcDir: '/',
  destDir: '/styles'
});
styles = plugins.broccoliSass([styles], 'styles/main.scss', 'templates/main-css.hbs');

sourceTrees = [lib, styles];

pkg = new plugins.broccoliMergeTrees(sourceTrees, { overwrite: true });
pkg = preprocess(pkg);

// module.exports = pkg; return; // Stop here to inspect package structure

var outputJs = plugins.broccoliDistEs6Module(pkg, {
  global: 'Emberella.Component',
  packageName: 'ella-sample',
  main: 'main',
  shim: {
    'ember': 'Ember'
  }
});

module.exports = plugins.broccoliMergeTrees(outputJs);
<commit_msg>Removed final call to merge trees<commit_after>var STRING_CAMELIZE_REGEXP = (/(\-|_|\.|\s)+(.)?/g);

var plugins = {};

var preprocess = function(tree) {
  tree = plugins.broccoliEmberHbsTemplateCompiler(tree, {module: true});
  tree = plugins.broccoliCoffee(tree, {
    bare: true
  });
  return tree;
};

var camelize = function(str) {
  return str.replace(STRING_CAMELIZE_REGEXP, function(match, separator, chr) {
    return chr ? chr.toUpperCase() : '';
  }).replace(/^([A-Z])/, function(match, separator, chr) {
    return match.toLowerCase();
  });
};

require('matchdep').filterDev('broccoli-*').forEach(function(p, idx) {
  if (['broccoli-cli'].indexOf(p) < 0) {
    plugins[camelize(p)] = require(p);
  }
});

var lib = 'lib',
    styles = 'styles',
    env = plugins.broccoliEnv.getEnv(),
    sourceTrees,
    pkg,
    css;

lib = plugins.broccoliStaticCompiler(lib, {
  srcDir: '/',
  destDir: '/'
});

styles = plugins.broccoliStaticCompiler(styles, {
  srcDir: '/',
  destDir: '/styles'
});
styles = plugins.broccoliSass([styles], 'styles/main.scss', 'templates/main-css.hbs');

sourceTrees = [lib, styles];

pkg = new plugins.broccoliMergeTrees(sourceTrees, { overwrite: true });
pkg = preprocess(pkg);

// module.exports = pkg; return; // Stop here to inspect package structure

var outputJs = plugins.broccoliDistEs6Module(pkg, {
  global: 'Emberella.Component',
  packageName: 'ella-sample',
  main: 'main',
  shim: {
    'ember': 'Ember'
  }
});

module.exports = outputJs;
<|endoftext|>