<commit_before>/*global window, document, Ghost, $, _, Backbone, JST, NProgress */
(function () {
    "use strict";

    var ContentList,
        ContentItem,
        PreviewContainer;

    // Base view
    // ----------
    Ghost.Views.Blog = Ghost.View.extend({
        initialize: function (options) {
            this.listenTo(this.collection, 'request', function () {
                NProgress.start();
            });
            this.listenTo(this.collection, 'sync', function () {
                NProgress.done();
            });
            this.addSubview(new PreviewContainer({ el: '.js-content-preview', collection: this.collection })).render();
            this.addSubview(new ContentList({ el: '.js-content-list', collection: this.collection })).render();
        }
    });

    // Content list (sidebar)
    // -----------------------
    ContentList = Ghost.View.extend({

        isLoading: false,

        events: {
            'click .content-list-content'    : 'scrollHandler'
        },

        initialize: function (options) {
            this.$('.content-list-content').scrollClass({target: '.content-list', offset: 10});
            this.listenTo(this.collection, 'remove', this.showNext);
            // Can't use backbone event bind (see: http://stackoverflow.com/questions/13480843/backbone-scroll-event-not-firing)
            this.$('.content-list-content').scroll($.proxy(this.checkScroll, this));
        },

        showNext: function () {
            if (this.isLoading) { return; }

            if (!this.collection.length) {
                return Backbone.trigger('blog:activeItem', null);
            }

            var id = this.collection.at(0) ? this.collection.at(0).id : false;
            if (id) {
                Backbone.trigger('blog:activeItem', id);
            }
        },

        reportLoadError: function (response) {
            var message = 'A problem was encountered while loading more posts';

            if (response) {
                // Get message from response
                message += '; ' + Ghost.Views.Utils.getRequestErrorMessage(response);
            } else {
                message += '.';
            }

            Ghost.notifications.addItem({
                type: 'error',
                message: message,
                status: 'passive'
            });
        },

        checkScroll: function (event) {
            var self = this,
                element = event.target,
                triggerPoint = 100;

            // If we haven't passed our threshold, exit
            if (this.isLoading || (element.scrollTop + element.clientHeight + triggerPoint <= element.scrollHeight)) {
                return;
            }

            // If we've loaded the max number of pages, exit
            if (this.collection.currentPage >=  this.collection.totalPages) {
                return;
            }

            // Load moar posts!
            this.isLoading = true;
            this.collection.fetch({
                update: true,
                remove: false,
                data: {
                    status: 'all',
                    page: (self.collection.currentPage + 1),
                    orderBy: ['updated_at', 'DESC']
                }
            }).then(function onSuccess(response) {
                self.render();
                self.isLoading = false;
            }, function onError(e) {
                self.reportLoadError(e);
            });
        },

        render: function () {
            this.collection.each(function (model) {
                this.$('ol').append(this.addSubview(new ContentItem({model: model})).render().el);
            }, this);
            this.showNext();
        }

    });

    // Content Item
    // -----------------------
    ContentItem = Ghost.View.extend({

        tagName: 'li',

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

        active: false,

        initialize: function () {
            this.listenTo(Backbone, 'blog:activeItem', this.checkActive);
            this.listenTo(this.model, 'destroy', this.removeItem);
        },

        removeItem: function () {
            var self = this;
            $.when(this.$el.slideUp()).then(function () {
                self.remove();
            });
        },

        // If the current item isn't active, we trigger the event to
        // notify a change in which item we're viewing.
        setActiveItem: function (e) {
            e.preventDefault();
            if (this.active !== true) {
                Backbone.trigger('blog:activeItem', this.model.id);
                this.render();
            }
        },

        // Checks whether this item is active and doesn't match the current id.
        checkActive: function (id) {
            if (this.model.id !== id) {
                if (this.active) {
                    this.active = false;
                    this.$el.removeClass('active');
                    this.render();
                }
            } else {
                this.active = true;
                this.$el.addClass('active');
            }
        },

        showPreview: function (e) {
            var item = $(e.currentTarget);
            this.$('.content-list-content li').removeClass('active');
            item.addClass('active');
            Backbone.trigger('blog:activeItem', item.data('id'));
        },

        templateName: "list-item",

        templateData: function () {
            return _.extend({active: this.active}, this.model.toJSON());
        }
    });

    // Content preview
    // ----------------
    PreviewContainer = Ghost.View.extend({

        activeId: null,

        events: {
            'click .post-controls .post-edit' : 'editPost',
            'click .featured' : 'toggleFeatured',
            'click .unfeatured' : 'toggleFeatured'
        },

        initialize: function (options) {
            this.listenTo(Backbone, 'blog:activeItem', this.setActivePreview);
        },

        setActivePreview: function (id) {
            if (this.activeId !== id) {
                this.activeId = id;
                this.render();
            }
        },

        editPost: function (e) {
            e.preventDefault();
            // for now this will disable "open in new tab", but when we have a Router implemented
            // it can go back to being a normal link to '#/ghost/editor/X'
            window.location = '/ghost/editor/' + this.model.get('id') + '/';
        },

        toggleFeatured: function (e) {
            var self = this,
                featured = !self.model.get('featured'),
                featuredEl = $(e.currentTarget),
                model = this.collection.get(this.activeId);

            model.save({
                featured: featured
            }, {
                success : function (model, response, options) {
                    featuredEl.removeClass("featured unfeatured").addClass(featured ? "featured" : "unfeatured");
                    Ghost.notifications.addItem({
                        type: 'success',
                        message: "Post successfully marked as " + (featured ? "featured" : "not featured") + ".",
                        status: 'passive'
                    });
                },
                error : function (model, xhr) {
                    Ghost.notifications.addItem({
                        type: 'error',
                        message: Ghost.Views.Utils.getRequestErrorMessage(xhr),
                        status: 'passive'
                    });
                }
            });
        },

        templateName: "preview",

        render: function () {
            this.model = this.collection.get(this.activeId);
            this.$el.html(this.template(this.templateData()));

            this.$('.content-preview-content').scrollClass({target: '.content-preview', offset: 10});
            this.$('.wrapper').on('click', 'a', function (e) {
                $(e.currentTarget).attr('target', '_blank');
            });

            if (this.model !== 'undefined') {
                this.addSubview(new Ghost.View.PostSettings({el: $('.post-controls'), model: this.model})).render();
            }

            Ghost.temporary.initToggles(this.$el);
            return this;
        }

    });

}());
<commit_msg>Fix duplication of entries in infinite scroll<commit_after>/*global window, document, Ghost, $, _, Backbone, JST, NProgress */
(function () {
    "use strict";

    var ContentList,
        ContentItem,
        PreviewContainer;

    // Base view
    // ----------
    Ghost.Views.Blog = Ghost.View.extend({
        initialize: function (options) {
            this.listenTo(this.collection, 'request', function () {
                NProgress.start();
            });
            this.listenTo(this.collection, 'sync', function () {
                NProgress.done();
            });
            this.addSubview(new PreviewContainer({ el: '.js-content-preview', collection: this.collection })).render();
            this.addSubview(new ContentList({ el: '.js-content-list', collection: this.collection })).render();
        }
    });

    // Content list (sidebar)
    // -----------------------
    ContentList = Ghost.View.extend({

        isLoading: false,

        events: {
            'click .content-list-content'    : 'scrollHandler'
        },

        initialize: function (options) {
            this.$('.content-list-content').scrollClass({target: '.content-list', offset: 10});
            this.listenTo(this.collection, 'remove', this.showNext);
            this.listenTo(this.collection, 'add', this.renderPost);
            // Can't use backbone event bind (see: http://stackoverflow.com/questions/13480843/backbone-scroll-event-not-firing)
            this.$('.content-list-content').scroll($.proxy(this.checkScroll, this));
        },

        showNext: function () {
            if (this.isLoading) { return; }

            if (!this.collection.length) {
                return Backbone.trigger('blog:activeItem', null);
            }

            var id = this.collection.at(0) ? this.collection.at(0).id : false;
            if (id) {
                Backbone.trigger('blog:activeItem', id);
            }
        },

        reportLoadError: function (response) {
            var message = 'A problem was encountered while loading more posts';

            if (response) {
                // Get message from response
                message += '; ' + Ghost.Views.Utils.getRequestErrorMessage(response);
            } else {
                message += '.';
            }

            Ghost.notifications.addItem({
                type: 'error',
                message: message,
                status: 'passive'
            });
        },

        checkScroll: function (event) {
            var self = this,
                element = event.target,
                triggerPoint = 100;

            // If we haven't passed our threshold, exit
            if (this.isLoading || (element.scrollTop + element.clientHeight + triggerPoint <= element.scrollHeight)) {
                return;
            }

            // If we've loaded the max number of pages, exit
            if (this.collection.currentPage >=  this.collection.totalPages) {
                return;
            }

            // Load moar posts!
            this.isLoading = true;
            this.collection.fetch({
                update: true,
                remove: false,
                data: {
                    status: 'all',
                    page: (self.collection.currentPage + 1),
                    orderBy: ['updated_at', 'DESC']
                }
            }).then(function onSuccess(response) {
                self.render();
                self.isLoading = false;
            }, function onError(e) {
                self.reportLoadError(e);
            });
        },

        renderPost: function (model) {
            this.$('ol').append(this.addSubview(new ContentItem({model: model})).render().el);
        },

        render: function () {
            var $list = this.$('ol');

            // Clear out any pre-existing subviews.
            this.removeSubviews();

            this.collection.each(function (model) {
                $list.append(this.addSubview(new ContentItem({model: model})).render().el);
            }, this);
            this.showNext();
        }

    });

    // Content Item
    // -----------------------
    ContentItem = Ghost.View.extend({

        tagName: 'li',

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

        active: false,

        initialize: function () {
            this.listenTo(Backbone, 'blog:activeItem', this.checkActive);
            this.listenTo(this.model, 'destroy', this.removeItem);
        },

        removeItem: function () {
            var self = this;
            $.when(this.$el.slideUp()).then(function () {
                self.remove();
            });
        },

        // If the current item isn't active, we trigger the event to
        // notify a change in which item we're viewing.
        setActiveItem: function (e) {
            e.preventDefault();
            if (this.active !== true) {
                Backbone.trigger('blog:activeItem', this.model.id);
                this.render();
            }
        },

        // Checks whether this item is active and doesn't match the current id.
        checkActive: function (id) {
            if (this.model.id !== id) {
                if (this.active) {
                    this.active = false;
                    this.$el.removeClass('active');
                    this.render();
                }
            } else {
                this.active = true;
                this.$el.addClass('active');
            }
        },

        showPreview: function (e) {
            var item = $(e.currentTarget);
            this.$('.content-list-content li').removeClass('active');
            item.addClass('active');
            Backbone.trigger('blog:activeItem', item.data('id'));
        },

        templateName: "list-item",

        templateData: function () {
            return _.extend({active: this.active}, this.model.toJSON());
        }
    });

    // Content preview
    // ----------------
    PreviewContainer = Ghost.View.extend({

        activeId: null,

        events: {
            'click .post-controls .post-edit' : 'editPost',
            'click .featured' : 'toggleFeatured',
            'click .unfeatured' : 'toggleFeatured'
        },

        initialize: function (options) {
            this.listenTo(Backbone, 'blog:activeItem', this.setActivePreview);
        },

        setActivePreview: function (id) {
            if (this.activeId !== id) {
                this.activeId = id;
                this.render();
            }
        },

        editPost: function (e) {
            e.preventDefault();
            // for now this will disable "open in new tab", but when we have a Router implemented
            // it can go back to being a normal link to '#/ghost/editor/X'
            window.location = '/ghost/editor/' + this.model.get('id') + '/';
        },

        toggleFeatured: function (e) {
            var self = this,
                featured = !self.model.get('featured'),
                featuredEl = $(e.currentTarget),
                model = this.collection.get(this.activeId);

            model.save({
                featured: featured
            }, {
                success : function (model, response, options) {
                    featuredEl.removeClass("featured unfeatured").addClass(featured ? "featured" : "unfeatured");
                    Ghost.notifications.addItem({
                        type: 'success',
                        message: "Post successfully marked as " + (featured ? "featured" : "not featured") + ".",
                        status: 'passive'
                    });
                },
                error : function (model, xhr) {
                    Ghost.notifications.addItem({
                        type: 'error',
                        message: Ghost.Views.Utils.getRequestErrorMessage(xhr),
                        status: 'passive'
                    });
                }
            });
        },

        templateName: "preview",

        render: function () {
            this.model = this.collection.get(this.activeId);
            this.$el.html(this.template(this.templateData()));

            this.$('.content-preview-content').scrollClass({target: '.content-preview', offset: 10});
            this.$('.wrapper').on('click', 'a', function (e) {
                $(e.currentTarget).attr('target', '_blank');
            });

            if (this.model !== 'undefined') {
                this.addSubview(new Ghost.View.PostSettings({el: $('.post-controls'), model: this.model})).render();
            }

            Ghost.temporary.initToggles(this.$el);
            return this;
        }

    });

}());
<|endoftext|>


<commit_before>import React, { Component, PropTypes } from 'react';
import { Form, FormGroup, Input, Card, CardText, CardBlock,
  CardTitle, CardSubtitle, Row, Col } from 'reactstrap';
import NewsStore from '../stores/NewsStore';
import NewsActions from '../actions/NewsActions';

class ArticlesView extends Component {

  constructor() {
    super();
    this.state = {
      allItems: [],
    };
    this.onChange = this.onChange.bind(this);
  }

  getInitialState() {
    return { allItems: null };
  }

  componentDidMount() {
    const { match } = this.props;
    NewsStore.addChangeListener(this.onChange);
    NewsActions.getNews(match.params.id);
  }

  componentWillUnmount() {
    NewsStore.removeChangeListener(this.onChange);
  }

  getItemsState() {
    return {
      allItems: NewsStore.getAll(),
    };
  }

  onChange() {
    this.setState({ allItems: NewsStore.getAll() });
  }

   /**
   * @return {object}
   */

  render() {
    const { match } = this.props;
    return (

{match.params.id}

            <Form className="order">
              <FormGroup>
                <Input type="select" name="select" id="exampleSelect">
                  <option>Sort News By</option>
                  <option>Top</option>
                  <option>Latest</option>
                  <option>Popular</option>
                </Input>
              </FormGroup>
            </Form>

        <Row>
          {this.state.allItems.map(news => (
            <Col xs="3" sm="3" className="news-frame">
              <Card className="headline">
                <CardBlock>
                  <CardTitle className="title">{news.meta}</CardTitle>
                  <CardSubtitle className="subtitle">{news.header}</CardSubtitle>
                </CardBlock>

                <CardBlock>
                  <CardText>{news.description}</CardText>
                  Read More
                </CardBlock>
              </Card>
            </Col>
         ))}
        </Row>

    );
  }

}

ArticlesView.propTypes = {
  match: PropTypes.object,
};

export default ArticlesView;
<commit_msg>refactor code in ArticlesView.js<commit_after>import React, { Component } from 'react';
import { Form, FormGroup, Input, Card, CardText, CardBlock,
  CardTitle, CardSubtitle, Row, Col } from 'reactstrap';
import PropTypes from 'prop-types';
import NewsStore from '../stores/NewsStore';
import NewsActions from '../actions/NewsActions';

class ArticlesView extends Component {

  constructor() {
    super();
    this.state = {
      allItems: [],
    };
    this.onChange = this.onChange.bind(this);
  }

  getInitialState() {
    return { allItems: null };
  }

  componentDidMount() {
    const { params } = this.props;
    NewsStore.addChangeListener(this.onChange);
    NewsActions.getNews(params.id);
  }

  componentWillUnmount() {
    NewsStore.removeChangeListener(this.onChange);
  }

  getItemsState() {
    return {
      allItems: NewsStore.getAll(),
    };
  }

  onChange() {
    this.setState({ allItems: NewsStore.getAll() });
  }

<<<<<<< Updated upstream
=======
  handleSort(event) {
    const { params } = this.props;
    event.preventDefault();
    const val = event.target.value;
    NewsActions.getNews(`${params.id}&sortBy=${val}`);
  }
>>>>>>> Stashed changes
   /**
   * @return {object}
   */

  render() {
<<<<<<< Updated upstream
    const { match } = this.props;
=======
    const { params } = this.props;
    const sort = params.sort.split(',');
    const option = sort.map((type, index) => <option value={type} key={index}> {type} </option>);
>>>>>>> Stashed changes
    return (

{params.id}

            <Form className="order">
              <FormGroup>
                <Input type="select" name="select" id="exampleSelect">
                  <option>Sort News By</option>
                  <option>Top</option>
                  <option>Latest</option>
                  <option>Popular</option>
                </Input>
              </FormGroup>
            </Form>

        <Row>
<<<<<<< Updated upstream
          {this.state.allItems.map(news => (
            <Col xs="3" sm="3" className="news-frame">
              <Card className="headline">
                <CardBlock>
                  <CardTitle className="title">{news.meta}</CardTitle>
                  <CardSubtitle className="subtitle">{news.header}</CardSubtitle>
                </CardBlock>

                <CardBlock>
                  <CardText>{news.description}</CardText>
                  Read More
                </CardBlock>
              </Card>
            </Col>
         ))}
=======
          {this.state.allItems.map((news) => {
            const cssStyle = {
              height: '350px',
              background: `url(${news.image}) center center`,
              width: '100%',
              backgroundSize: 'cover',
            };
            return (
              <Col xs="3" sm="3" className="news-frame">
                <Card className="headline">
                  <CardBlock>
                    <CardTitle className="title">{news.meta}</CardTitle>
                    <CardSubtitle className="subtitle">{news.header}</CardSubtitle>
                  </CardBlock>

                  <CardBlock>
                    <CardText>{news.description}</CardText>
                    Read More
                  </CardBlock>
                </Card>
              </Col>
            );
          })}
>>>>>>> Stashed changes
        </Row>

    );
  }

}

ArticlesView.propTypes = {
<<<<<<< Updated upstream
  match: PropTypes.object,
=======
  params: PropTypes.object,
>>>>>>> Stashed changes
};

export default ArticlesView;
<|endoftext|>


<commit_before>/* global document */
var layer0 = require('@tryghost/members-layer0');
var events = require('minivents');

module.exports = function layer1(options) {
    var members = {
        getToken,
        signout,
        signin,
        signup,
        requestPasswordReset,
        resetPassword,
        verifyEmail,
        bus: new events()
    };

    var loadGateway = loadFrame(options.gatewayUrl, options.container).then(function (frame) {
        var gateway = layer0(frame);
        var init = gatewayFn('init');
        gateway.listen(function (data) {
            members.bus.emit(data.event, data.payload);
        });
        return init(gateway).then(function () {
            return gateway;
        })
    });

    function getToken({audience}) {
        return loadGateway.then(gatewayFn('getToken', {audience}));
    }

    function signout() {
        return loadGateway.then(gatewayFn('signout'));
    }

    function signin({email, password}) {
        return loadGateway.then(gatewayFn('signin', {email, password}));
    }

    function signup({name, email, password}) {
        return loadGateway.then(gatewayFn('signin', {name, email, password}));
    }

    function requestPasswordReset({email}) {
        return loadGateway.then(gatewayFn('request-password-reset', {email}));
    }

    function resetPassword({token, password}) {
        return loadGateway.then(gatewayFn('reset-password', {token, password}));
    }

    function verifyEmail({token}) {
        return loadGateway.then(gatewayFn('verify-email', {token}));
    }

    return members;
}

function gatewayFn(method, opts = {}) {
    return function (gateway) {
        return new Promise(function (resolve, reject) {
            gateway.call(method, opts, function (err, res) {
                if (err) {
                    reject(err);
                }
                resolve(res);
            });
        });
    }
}

function loadFrame(src, container = document.body) {
    return new Promise(function (resolve) {
        const frame = document.createElement('iframe');
        frame.style.display = 'none';
        frame.src = src;
        frame.onload = function () {
            resolve(frame);
        };
        container.appendChild(frame);
    });
}
<commit_msg>Added missing semicolons<commit_after>/* global document */
var layer0 = require('@tryghost/members-layer0');
var events = require('minivents');

module.exports = function layer1(options) {
    var members = {
        getToken,
        signout,
        signin,
        signup,
        requestPasswordReset,
        resetPassword,
        verifyEmail,
        bus: new events()
    };

    var loadGateway = loadFrame(options.gatewayUrl, options.container).then(function (frame) {
        var gateway = layer0(frame);
        var init = gatewayFn('init');
        gateway.listen(function (data) {
            members.bus.emit(data.event, data.payload);
        });
        return init(gateway).then(function () {
            return gateway;
        });
    });

    function getToken({audience}) {
        return loadGateway.then(gatewayFn('getToken', {audience}));
    }

    function signout() {
        return loadGateway.then(gatewayFn('signout'));
    }

    function signin({email, password}) {
        return loadGateway.then(gatewayFn('signin', {email, password}));
    }

    function signup({name, email, password}) {
        return loadGateway.then(gatewayFn('signin', {name, email, password}));
    }

    function requestPasswordReset({email}) {
        return loadGateway.then(gatewayFn('request-password-reset', {email}));
    }

    function resetPassword({token, password}) {
        return loadGateway.then(gatewayFn('reset-password', {token, password}));
    }

    function verifyEmail({token}) {
        return loadGateway.then(gatewayFn('verify-email', {token}));
    }

    return members;
};

function gatewayFn(method, opts = {}) {
    return function (gateway) {
        return new Promise(function (resolve, reject) {
            gateway.call(method, opts, function (err, res) {
                if (err) {
                    reject(err);
                }
                resolve(res);
            });
        });
    };
}

function loadFrame(src, container = document.body) {
    return new Promise(function (resolve) {
        const frame = document.createElement('iframe');
        frame.style.display = 'none';
        frame.src = src;
        frame.onload = function () {
            resolve(frame);
        };
        container.appendChild(frame);
    });
}
<|endoftext|>


<commit_before>_OKCP.initReaddPagination = function() {
	var lastPageElem,
		numPages,
		itemsPerPage,
		paginationElem;
	if (document.getElementById('questions')) {
		lastPageElem = $('#questions .count .last');
		itemsPerPage = 10;
	} else if (document.getElementById('p_mailbox')) {
		lastPageElem = $('#p_mailbox .count .last');
		itemsPerPage = 30;
	} else {
		return false;
	}

	numPages = lastPageElem.text()*1;
	paginationElem = $('

').insertAfter(lastPageElem);
	for (var i = 0, newElem, href; i < numPages; i++) {
		newElem = lastPageElem.clone();
		href = newElem.attr('href');
		href = href.split('low=')[0]+'low=' + (i*itemsPerPage+1) + '&' + href.substring(href.indexOf('&')+1);
		newElem.text(i+1)
			.attr('href',href)
			.attr('class','num');
		paginationElem.append(newElem);
	}
};<commit_msg>refactored to separate pagination url utility for messageSearch feature to use<commit_after>_OKCP.initReaddPagination = function() {
	var lastPageElem,
		numPages,
		itemsPerPage,
		paginationElem,
		urls;
	if (document.getElementById('questions')) {
		lastPageElem = $('#questions .count .last');
		itemsPerPage = 10;
	} else if (document.getElementById('p_mailbox')) {
		lastPageElem = $('#p_mailbox .count .last');
		itemsPerPage = 30;
	} else {
		return false;
	}
	urls = _OKCP.getPaginationUrls(lastPageElem, itemsPerPage);

	paginationElem = $('

').insertAfter(lastPageElem);
	for (var i = 0, newElem, href, length = urls.length; i < length; i++) {
		newElem = lastPageElem.clone();
		href = urls[i];
		newElem.text(i+1)
			.attr('href',href)
			.attr('class','num');
		paginationElem.append(newElem);
	}
};

_OKCP.getPaginationUrls = function(lastPageElem, itemsPerPage) {
	var urls = [];
	numPages = lastPageElem.text()*1;
	for (var i = 0, url; i < numPages; i++) {
		url = lastPageElem.attr('href');
		url = url.split('low=')[0]+'low=' + (i*itemsPerPage+1) + '&' + url.substring(url.indexOf('&')+1);
		urls.push(url);
	}
	return urls;
};<|endoftext|>


<commit_before>/*
HideTrackLabels JBrowse plugin CSS
*/
/*
    Created on : Jul 15, 2015, 7:19:50 PM
    Author     : EY
*/

define([
            'dojo/_base/declare',
            'dojo/_base/lang',
            'dojo/Deferred',
            'dojo/dom-construct',
            'dijit/form/Button',
            'dojo/fx',
            'dojo/dom',
            'dojo/dom-style',
            'dojo/on',
            'dojo/query',
            'dojo/dom-geometry',
            'JBrowse/Plugin'
       ],
       function(
           declare,
           lang,
           Deferred,
           domConstruct,
           dijitButton,
           coreFx,
           dom,
           style,
           on,
           query,
           domGeom,
           JBrowsePlugin
       ) {
return declare( JBrowsePlugin,
{
    constructor: function( args ) {
        console.log("plugin HideTracksButton constructor");

        var baseUrl = this._defaultConfig().baseUrl;
        var thisB = this;
        var queryParams = dojo.queryToObject( window.location.search.slice(1) );

        // create the hide/show button after genome view initialization
        this.browser.afterMilestone( 'initView', function() {

            var navBox = dojo.byId("navbox");

            thisB.browser.hideTitlesButton = new dijitButton(
            {
                title: "Hide/Show Track Titles",
                id: "hidetitles-btn",
                width: "24px",
                onClick: dojo.hitch( thisB, function(event) {
                    thisB.showTrackLabels("toggle");
                    dojo.stopEvent(event);
                })
            }, dojo.create('button', {}, navBox));

            if(queryParams.tracklabels == 0 || thisB.browser.config.show_tracklabels == 0) {
                query('.track-label').style('visibility', 'hidden')
                dojo.attr(thisB.browser.hideTitlesButton.domNode, "hidden-titles", "");
            }
        });
        if(thisB.browser.config.show_tracklabels == 0) {
            dojo.subscribe("/jbrowse/v1/n/tracks/redraw", function(data){
                thisB.showTrackLabels("hide");
            });
        }

        dojo.subscribe("/jbrowse/v1/n/tracks/redraw", function(data){
            thisB.showTrackLabels("hide-if");
        });
    },

    /* show or hide track labels
     * showTrackLabels(param)
     * @param {string} function "show", "hide", "toggle", or "hide-if"
     * "hide-if" rehides if already hidden.
     * @returns {undefined}
     */
    showTrackLabels: function(fn) {
        var direction = 1;
        var button = dom.byId("hidetitled-btn");

        if (fn=="show") {
            if(button) dojo.removeAttr(button,"hidden-titles");
            direction = 1;
        }
        if (fn=="hide") {
            if(button) dojo.attr(button,"hidden-titles","");
            direction = -1;
        }
        if (fn=="hide-if") {
            if (button && dojo.hasAttr(button,"hidden-titles")) direction = -1;
            else return;
        }

        if (fn=="toggle"){
            if (button && dojo.hasAttr(button,"hidden-titles")) {     // if hidden, show
                dojo.removeAttr(button,"hidden-titles");
                direction = 1;
            }
            else {
                if(button) dojo.attr(button,"hidden-titles","");       // if shown, hide
                direction = -1;
            }
        }
        // protect Hide button from clicks during animation
        if(button) dojo.attr(button,"disabled","");
        setTimeout(function(){
            if(button) dojo.removeAttr(button,"disabled");
        }, 200);

        if(direction==-1) {
            setTimeout(function() {
                query('.track-label').style('visibility', 'hidden')
            }, 200);
        } else {
            query('.track-label').style('visibility', 'visible')
        }
        // slide em
        query(".track-label").forEach(function(node, index, arr){
            var w = domGeom.getMarginBox(node).w;
            coreFx.slideTo({
              node: node,
              duration: 200,
              top: domGeom.getMarginBox(node).t.toString(),
              left: (domGeom.getMarginBox(node).l + (w*direction) ).toString(),
              unit: "px"
            }).play();
        });

    }

});
});

<commit_msg>Fix hide track labels logic for toggling<commit_after>/*
HideTrackLabels JBrowse plugin CSS
*/
/*
    Created on : Jul 15, 2015, 7:19:50 PM
    Author     : EY
*/

define([
            'dojo/_base/declare',
            'dojo/_base/lang',
            'dojo/Deferred',
            'dojo/dom-construct',
            'dijit/form/Button',
            'dojo/fx',
            'dojo/dom',
            'dojo/dom-style',
            'dojo/on',
            'dojo/query',
            'dojo/dom-geometry',
            'JBrowse/Plugin'
       ],
       function(
           declare,
           lang,
           Deferred,
           domConstruct,
           dijitButton,
           coreFx,
           dom,
           style,
           on,
           query,
           domGeom,
           JBrowsePlugin
       ) {
return declare( JBrowsePlugin,
{
    constructor: function( args ) {
        console.log("plugin HideTracksButton constructor");

        var baseUrl = this._defaultConfig().baseUrl;
        var thisB = this;
        var queryParams = dojo.queryToObject( window.location.search.slice(1) );

        // create the hide/show button after genome view initialization
        this.browser.afterMilestone( 'initView', function() {

            var navBox = dojo.byId("navbox");

            thisB.browser.hideTitlesButton = new dijitButton(
            {
                title: "Hide/Show Track Titles",
                id: "hidetitles-btn",
                width: "24px",
                onClick: dojo.hitch( thisB, function(event) {
                    thisB.showTrackLabels("toggle");
                    dojo.stopEvent(event);
                })
            }, dojo.create('button', {}, navBox));

            if(queryParams.tracklabels == 0 || thisB.browser.config.show_tracklabels == 0) {
                query('.track-label').style('visibility', 'hidden')
                dojo.attr(thisB.browser.hideTitlesButton.domNode, "hidden-titles", "");
            }
        });
        if(thisB.browser.config.show_tracklabels == 0) {
            dojo.subscribe("/jbrowse/v1/n/tracks/redraw", function(data){
                thisB.showTrackLabels("hide");
            });
        }
        dojo.subscribe("/jbrowse/v1/n/tracks/redraw", function(data){
            thisB.showTrackLabels("hide-if");
        });
    },

    /* show or hide track labels
     * showTrackLabels(param)
     * @param {string} function "show", "hide", "toggle", or "hide-if"
     * "hide-if" rehides if already hidden.
     * @returns {undefined}
     */
    showTrackLabels: function(fn) {
        var direction = 1;
        var button = dom.byId("hidetitles-btn");

        if (fn=="show") {
            if(button) dojo.removeAttr(button,"hidden-titles");
            direction = 1;
        }
        if (fn=="hide") {
            if(button) dojo.attr(button,"hidden-titles","");
            direction = -1;
        }
        if (fn=="hide-if") {
            if (button && dojo.hasAttr(button,"hidden-titles")) direction = -1;
            else return;
        }

        if (fn=="toggle"){
            if (button) {
                if(dojo.hasAttr(button,"hidden-titles")) {     // if hidden, show
                    dojo.removeAttr(button,"hidden-titles");
                    direction = 1;
                }
                else {
                    dojo.attr(button,"hidden-titles","");       // if shown, hide
                    direction = -1;
                }
            }
        }
        // protect Hide button from clicks during animation
        if(button) dojo.attr(button,"disabled","");
        setTimeout(function(){
            if(button) dojo.removeAttr(button,"disabled");
        }, 200);

        if(direction==-1) {
            setTimeout(function() {
                query('.track-label').style('visibility', 'hidden')
            }, 200);
        } else {
            query('.track-label').style('visibility', 'visible')
        }
        // slide em
        query(".track-label").forEach(function(node, index, arr){
            var w = domGeom.getMarginBox(node).w;
            coreFx.slideTo({
              node: node,
              duration: 200,
              top: domGeom.getMarginBox(node).t.toString(),
              left: (domGeom.getMarginBox(node).l + (w*direction) ).toString(),
              unit: "px"
            }).play();
        });

    }

});
});

<|endoftext|>


<commit_before>/*Needs to be this way so he can have multiple instances
  of a paper object
*/
var Paper = function(){

	this.data = {
		paper_id: null,
		paper_title: null,
		paper_abstract: null,
		paper_citation: null
	};

	//sets properties of a paper if exists
	this.fill = function( paper_info ){

		for( var property in this.data ){
			if( this.data[property] !== 'undefined' ){
				this.data[property] = paper_info[property];
			}
		}

	};

	//returns array of a papers properties
	this.getPaperInfo = function(){
		return this.data;
	},

	/*                    *\
	**  Setter Functions  **
	\*                    */

	this.setPaperId = function ( id_number ){
		this.data['paper_id'] = id_number;
	},

	this.setPaperTitle =function ( title ){
		this.data['paper_title'] = title;
	},

	this.setPaperAbstract = function ( abstract ){
		this.data['paper_abstract'] = abstract;
	},

	this.setPaperCitation = function ( citation ){
		this.data['paper_citation'] = id_number;
	}

};

/*
**Returns an actual new instance of a paper
**/
module.exports = function( paper_info ){
	var instance = new Paper();
	instance.fill(paper_info);
	return instance;
};

<commit_msg>Paper Model Update<commit_after>var mysql = require('mysql');
var db = require('../database/db_pool');
var uuid = require('node-uuid');

var Paper = function(){

	/No need for Getters and Setters

    // If an id is given, find it in the database, use those attributes
    if (attrs.p_id !== undefined){
      this.data = {
        paper_id : attrs.p_id,
        paper_title: "",
        paper_abstract: "",
        paper_citation: ""
      };
      console.log(`fetching`);
      //fetch
    }else{
      this.data = {
        paper_id: uuid.v1(),
        paper_title: "",
        paper_abstract: "",
        paper_citation : ""
      };

      for(var property in this.data ){
        console.log(attrs[property]);
  			if(attrs[property] !== undefined){
  				this.data[property] = attrs[property];
  			}
  		}
    }

    //Updates the properties in the database
    //Takes an err and an array of properties to update
    //We never need to create a property because default values are used
    //For the properties not initially set
    this.updateProps = function(err, callback){
      //Example Connection
      var self = this;
      db.getConnection(function(err, connection) {
        if (err) {throw err;}
        // Use the connection
        var sql = "SELECT * FROM frd.papers where paper_id = ?";
        var inserts = [self.p_id];                             //Problem: need to find way to get self into this callback method
        sql = mysql.format(sql, inserts);

        connection.query(sql, function(err, rows) {
          if (err) {throw err;}
          // And done with the connection.
          //Set Rows Here
          callback(rows);
          self.data = rows;
          connection.release();
          // Don't use the connection here, it has been returned to the pool.
        });
      });
      //If something bad happens add a string to err
      //Example: err = "update could not finish"
      return;
    };

    //Deletes the properties
    //Takes an err and an array of properties to delete
    this.deleteProps = function(err, callback){
      //Example Connection
      var self = this;
      db.getConnection(function(err, connection) {
        if (err) {throw err;}
        // Use the connection
        var sql = "SELECT * FROM frd.papers where paper_id = ?";
        var inserts = [self.p_id];                             //Problem: need to find way to get self into this callback method
        sql = mysql.format(sql, inserts);

        connection.query(sql, function(err, rows) {
          if (err) {throw err;}
          // And done with the connection.
          //Set Rows Here
          callback(rows);
          self.data = rows;
          connection.release();
          // Don't use the connection here, it has been returned to the pool.
        });
      });
      //If something bad happens add a string to err
      //Example: err = "update could not finish"
      return;
    };

    //Fetches all properties from the database using p_id
    //qdata is an empty array
    this.fetchProps = function(err, callback){
      //Example Connection

        var self = this;
        db.getConnection(function(err, connection) {
          try{
            if (err) {throw err;}
            // Use the connection
            var sql = "SELECT ??,??,??,?? FROM frd.users where p_id = ?";
            var inserts = ['paper_id','paper_title','paper_abstract','paper_citation', self.data.p_id];
            sql = mysql.format(sql, inserts);

            connection.query(sql, function(err, rows) {
              try{
                if (err) {throw err;}
                if (rows[0] == undefined) {throw new Error('No row data');}
                // And done with the connection.
                //Set Rows Here
                for (prop in rows[0]){
                  console.log(`prop ${prop} = ${rows[0][prop]}`);
                  self.data[prop] = rows[0][prop];
                }

                //self.data = rows;
                callback(); // All values have been set
                connection.release();
              }catch (err){
                //Create new object attib if no data is found
                self.data = {
                  paper_id: uuid.v1(),
                  paper_title: "",
                  paper_abstract: "",
                  paper_citation: ""
                };
              }
            });

          }catch(err){
            console.log(`${err}`);
          }
            // Don't use the connection here, it has been returned to the pool.
        });
      //If something bad happens add a string to err
      //Example: err = "update could not finish"
      return;
    };

	/*                    *\
	**  Setter Functions  **
	\*                    */

	this.setPaperId = function ( id_number ){
		this.data['paper_id'] = id_number;
	},

	this.setPaperTitle =function ( title ){
		this.data['paper_title'] = title;
	},

	this.setPaperAbstract = function ( abstract ){
		this.data['paper_abstract'] = abstract;
	},

	this.setPaperCitation = function ( citation ){
		this.data['paper_citation'] = id_number;
	}

};

/*
**Returns an actual new instance of a paper
**/
module.exports = paper_model;

<|endoftext|>


<commit_before>/*
 *  asf -- Ada Server Faces
 *  Copyright (C) 2009, 2010, 2011, 2012, 2013 Stephane Carrez
 *  Written by Stephane Carrez (Stephane.Carrez@gmail.com)
 *
 *  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.
 */
var ASF = {};

(function () {
    /**
     * Execute the AJAX response action represented by the JSON object action.
     *
     * @param node the current node
     * @param action the JSON action object
     */
    ASF.ExecuteOne = function(node, action) {
        var id = action.id ? action.id : node;
        if (action.child) {
            id = $(id).children(action.child);
        }
        if (action.action === "update") {
	        $(id).html(action.data);

        } else if (action.action === "prepend") {
	        $(id).prepend(action.data);

        } else if (action.action === "append") {
	        $(id).append(action.data);

        } else if (action.action === "show") {
            $(id).show('slow');

        } else if (action.action === "hide") {
            $(id).hide('slow');

        } else if (action.action === "delete") {
	        $(id).remove();

        } else if (action.action === "removeClass") {
	        $(id).removeClass(action.data);

        } else if (action.action === "addClass") {
	        $(id).addClass(action.data);

        } else if (action.action === "fadeIn") {
            $(id).fadeIn('slow');

        } else if (action.action === "fadeOut") {
            $(id).fadeOut('slow');

        } else if (action.action === "slideUp") {
            $(id).slideUp('slow');

        } else if (action.action === "slideDown") {
            $(id).slideDown('slow');

        } else if (action.action === "closeDialog") {
            $(id).dialog('close');

        } else if (action.action === "closePopup") {
            $(id).popup('close');

        } else if (action.action === "redirect") {
            document.location = action.url;

        } else if (action.action === "message") {
	        ASF.Message(node, action.id, action.data);

        } else if (action.action === "script") {
            try {
                eval(action.script);
            } catch (e) {
                alert(e);
            }

	    } else if (action.action === "clear") {
	        $(id).each(function() {
                switch (this.type) {
                case 'password':
                case 'select-multiple':
                case 'select-one':
                case 'text':
                case 'textarea':
                    $(this).val('');
                    break;
                case 'checkbox':
                case 'radio':
                    this.checked = false;
                    break;
                }
            });
	    }
    };

    ASF.Execute = function(node, data) {
        if (data) {
            for (var i = 0; i < data.length; i++) {
                ASF.ExecuteOne(node, data[i]);
            }
        }
    };

    /**
     * Handle an AJAX operation that failed.
     */
    ASF.AjaxError = function(jqXHDR, node) {
        var contentType = jqXHDR.getResponseHeader('Content-type');
        if (contentType && contentType.match(/^application\/json(;.*)?$/i)) {
            var data = $.parseJSON(jqXHDR.responseText);
            ASF.Execute(node, data);
        } else {
            ASF.Message(node, null, "Operation failed");
        }
    };

    /**
     * Update the target container with the content of the AJAX GET request
     * on the given URL.  The target parameter is optional.
     *
     * @param node the current element
     * @param url the URL to fetch using an HTTP GET
     * @param target the optional target element
     * @param complete an optional function called when the response is received
     */
    ASF.Update = function(node, url, target, complete) {
        /* Find the container to update */
        var d;
        if (target != null) {
            d = $(target);
        } else {
            d = $(node);
            if (!d.is('.asf-container')) {
                d = d.parent('.asf-container');
            }
        }
        if (d.length > 0) {
            /* Perform the HTTP GET */
            jQuery.ajax({
                url: url,
                context: document.body,
                success: function(data, status, jqXHDR) {
                    var contentType = jqXHDR.getResponseHeader('Content-type');
                    if (contentType == null) {
                        contentType = "text/html";
                    }
                    if (contentType.match(/^text\/(html|xml)(;.*)?$/i)) {
                        d.html(jqXHDR.responseText);

                    } else if (contentType.match(/^application\/json(;.*)?$/i)) {
                        ASF.Execute(d, data);
                    }
                    if (complete != null) {
                        complete(d, jqXHDR);
                    }
               },
               error: function(jqXHDR, status, error) {
                   ASF.AjaxError(jqXHDR, d);
               }
            });
        }
    };

    /**
     * Submit the current form.  The node element refers to the element being clicked.
     * From that element, we can identify the form to submit.  The element to refresh upon
     * the form submit is an outer element that should have the asf-container class.
     * If not such element as parent node, the parent node of the form is used.
     *
     * After the form is submitted, the response is executed if it is a JSON response.
     * If the response is an HTML content, the container element is refreshed with it.
     *
     * @param node the current element
     * @param url the URL to fetch using an HTTP GET
     * @param target the optional target element
     */
    ASF.Submit = function(node) {
        /* Find the form and container to update */
        var f = $(node).closest("form");
        var d = $(f);
        if (!d.is('.asf-container,ui-dialog-content')) {
            d = d.closest('.asf-container,.ui-dialog-content');
        }
        if (d.length == 0) {
            d = $(f).parent();
        }
        if (d.length > 0) {
            var params;
            var params = $(f).serialize();
            var url = $(f).attr('action');

            if (node.tagName == 'a' || node.tagName == 'A') {
                params = node.id + "=1&" + $(f).serialize();
            } else {
                params = node.name + "=1&" + $(f).serialize();
            }
            /**
             * Send notification on form to indicate a form submit is now in progress.
             */
            $(f).triggerHandler("notifySubmit", d);

            /* Perform the HTTP POST */
            jQuery.ajax({
                type: "POST",
                url: url,
                data: params,
                context: document.body,
                success: function(data, status, jqXHDR) {
                    var contentType = jqXHDR.getResponseHeader('Content-type');
                    if (contentType == null) {
                        contentType = "text/html";
                    }
                    $(f).triggerHandler("successSubmit", d);
                    if (contentType.match(/^text\/(html|xml)(;.*)?$/i)) {
                        d.fadeOut("fast", function() {
                            d.html(jqXHDR.responseText);
                            d.fadeIn("fast");
                        });

                    } else if (contentType.match(/^application\/json(;.*)?$/i)) {
                        ASF.Execute(d, data);
                    }
               },
               error: function(jqXHDR, status, error) {
                   ASF.AjaxError(jqXHDR, d);
               }
            });
        }
        return false;
    };

    /**
     * Perform an HTTP POST on the given URL.
     *
     * @param node the node element that will be updated by default on the AJAX response.
     * @param url the HTTP URL.
     * @param params the HTTP POST parameters.
     */
    ASF.Post = function(node, url, params) {
        /* Perform the HTTP POST */
        jQuery.ajax({
            type: "POST",
            url: url,
            data: params,
            context: document.body,
            success: function(data, status, jqXHDR) {
                var contentType = jqXHDR.getResponseHeader('Content-type');
                if (contentType == null) {
                    contentType = "text/html";
                }
                if (contentType.match(/^text\/(html|xml)(;.*)?$/i)) {
                    $(node).html(jqXHDR.responseText);

                } else if (contentType.match(/^application\/json(;.*)?$/i)) {
                    ASF.Execute(node, data);
                }
            },
            error: function(jqXHDR, status, error) {
                ASF.AjaxError(jqXHDR, node);
            }
        });
        return false;
    };

    /**
     * Open a popup form attached to the node element and which is filled by
     * the given URL.
     *
     * The popup form is created when the page refered by <tt>url</tt> is fetched.
     * It can be referenced by the unique id given in <tt>id</tt>.
     *
     * @param node the node element where the popup is attached to.
     * @param id the popup unique id.
     * @param url the URL to fetch to fill the popup content.
     * @param params the popup creation parameters.
     */
    ASF.Popup = function(node, id, url, params) {
        jQuery.ajax({
            type: "GET",
            url: url,
            context: document.body,
            success: function(data, status, jqXHDR) {
                var contentType = jqXHDR.getResponseHeader('Content-type');
                if (contentType == null) {
                    contentType = "text/html";
                }
                var div = $('#' + id);
                if (div.length == 0) {
                    div = document.createElement("div");
                    div.id = id;
                    $(document.body).append($(div));
                }
                if (contentType.match(/^text\/(html|xml)(;.*)?$/i)) {
                    $(div).html(jqXHDR.responseText);

                } else if (contentType.match(/^application\/json(;.*)?$/i)) {
                    ASF.Execute(div, data);
                }
                $(div).popup(params).popup('open');
            },
            error: function(jqXHDR, status, error) {
                ASF.AjaxError(jqXHDR, node);
            }
        });
        return false;
    };

    /**
     * Open a dialog box and fetch the dialog content from the given URI.
     *
     * @param node the current element
     * @param id the dialog id
     * @param url the URL to fetch using an HTTP GET
     * @param params the optional dialog options
     */
    ASF.OpenDialog = function(node, id, url, params) {
        var div = $(id);
        if (div.length > 0) {
            return false;
        }

        div = document.createElement("div");
        div.id = id;
        div = $(div);

        var d = $(document);
        if (d.length == 0) {
            return false;
        }

        $(d).append($(div));

        /* Perform the HTTP GET */
        jQuery.ajax({
            url: url,
            context: document.body,
            success: function(data, status, jqXHDR) {
                var contentType = jqXHDR.getResponseHeader('Content-type');
                if (contentType == null) {
                    contentType = "text/html";
                }
                if (contentType.match(/^text\/(html|xml)(;.*)?$/i)) {
                    $(div).dialog({
                        autoOpen: false,
                        show: "blind",
                        hide: "explode",
                        minWidth: 600,
                        close: function() {
                            $(div).dialog('destroy');
                            $(div).remove();
                            if (params && params.close) {
                                params.close(node);
                            }
                        }
                     });

                     $(div).html(jqXHDR.responseText);

                     /**
                      * Extract a title from the inner form to setup the dialog box.
                      */
                     var dTitle, dBox = $(div).children('div');
                     if (dBox.length == 0) {
                        dTitle = $(div).children('h2');
                     } else {
                        dTitle = $(dBox).children('h2');
                     }
                     if (dTitle.length > 0) {
                        $(div).dialog("option", "title", dTitle.html());
                        dTitle.remove();
                     } else {
                        dTitle = $(div).children('div').attr('title');
                        if (dTitle != null) {
                            $(div).dialog("option", "title", dTitle );
                            /* $(div).attr('title', title); */
                        }
                     }
                     $(div).dialog('open');

                } else if (contentType.match(/^application\/json(;.*)?$/i)) {
                    ASF.Execute(node, data);
                }
            },
            error: function(jqXHDR, status, error) {
                ASF.AjaxError(jqXHDR, d);
            }
        });
        return false;
    };

    /**
     * Close the dialog box identified by the given identifier.
     *
     * @param id the dialog box identifier
     */
    ASF.CloseDialog = function(id) {
        $('#' + id).dialog('close');
        return false;
    };

    /**
     * Create and display a popup message near the node element.
     *
     * @param node the element giving the location of the message
     * @param id the message id or null
     * @param message the HTML message content
     */
    ASF.Message = function(node, id, message) {
        if (!id) {
            id = "#asf-message";
        }
        var div = $(id);
        if (div.length == 0) {
            div = document.createElement("div");
            div.id = id.substring(1);
            $(document.body).append($(div));
        }

        $(div).html(message).message({}).message("attachment", node);
    };
})();

<commit_msg>Set the focus on the first visible input in the popup form<commit_after>/*
 *  asf -- Ada Server Faces
 *  Copyright (C) 2009, 2010, 2011, 2012, 2013 Stephane Carrez
 *  Written by Stephane Carrez (Stephane.Carrez@gmail.com)
 *
 *  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.
 */
var ASF = {};

(function () {
    /**
     * Execute the AJAX response action represented by the JSON object action.
     *
     * @param node the current node
     * @param action the JSON action object
     */
    ASF.ExecuteOne = function(node, action) {
        var id = action.id ? action.id : node;
        if (action.child) {
            id = $(id).children(action.child);
        }
        if (action.action === "update") {
	        $(id).html(action.data);

        } else if (action.action === "prepend") {
	        $(id).prepend(action.data);

        } else if (action.action === "append") {
	        $(id).append(action.data);

        } else if (action.action === "show") {
            $(id).show('slow');

        } else if (action.action === "hide") {
            $(id).hide('slow');

        } else if (action.action === "delete") {
	        $(id).remove();

        } else if (action.action === "removeClass") {
	        $(id).removeClass(action.data);

        } else if (action.action === "addClass") {
	        $(id).addClass(action.data);

        } else if (action.action === "fadeIn") {
            $(id).fadeIn('slow');

        } else if (action.action === "fadeOut") {
            $(id).fadeOut('slow');

        } else if (action.action === "slideUp") {
            $(id).slideUp('slow');

        } else if (action.action === "slideDown") {
            $(id).slideDown('slow');

        } else if (action.action === "closeDialog") {
            $(id).dialog('close');

        } else if (action.action === "closePopup") {
            $(id).popup('close');

        } else if (action.action === "redirect") {
            document.location = action.url;

        } else if (action.action === "message") {
	        ASF.Message(node, action.id, action.data);

        } else if (action.action === "script") {
            try {
                eval(action.script);
            } catch (e) {
                alert(e);
            }

	    } else if (action.action === "clear") {
	        $(id).each(function() {
                switch (this.type) {
                case 'password':
                case 'select-multiple':
                case 'select-one':
                case 'text':
                case 'textarea':
                    $(this).val('');
                    break;
                case 'checkbox':
                case 'radio':
                    this.checked = false;
                    break;
                }
            });
	    }
    };

    ASF.Execute = function(node, data) {
        if (data) {
            for (var i = 0; i < data.length; i++) {
                ASF.ExecuteOne(node, data[i]);
            }
        }
    };

    /**
     * Handle an AJAX operation that failed.
     */
    ASF.AjaxError = function(jqXHDR, node) {
        var contentType = jqXHDR.getResponseHeader('Content-type');
        if (contentType && contentType.match(/^application\/json(;.*)?$/i)) {
            var data = $.parseJSON(jqXHDR.responseText);
            ASF.Execute(node, data);
        } else {
            ASF.Message(node, null, "Operation failed");
        }
    };

    /**
     * Update the target container with the content of the AJAX GET request
     * on the given URL.  The target parameter is optional.
     *
     * @param node the current element
     * @param url the URL to fetch using an HTTP GET
     * @param target the optional target element
     * @param complete an optional function called when the response is received
     */
    ASF.Update = function(node, url, target, complete) {
        /* Find the container to update */
        var d;
        if (target != null) {
            d = $(target);
        } else {
            d = $(node);
            if (!d.is('.asf-container')) {
                d = d.parent('.asf-container');
            }
        }
        if (d.length > 0) {
            /* Perform the HTTP GET */
            jQuery.ajax({
                url: url,
                context: document.body,
                success: function(data, status, jqXHDR) {
                    var contentType = jqXHDR.getResponseHeader('Content-type');
                    if (contentType == null) {
                        contentType = "text/html";
                    }
                    if (contentType.match(/^text\/(html|xml)(;.*)?$/i)) {
                        d.html(jqXHDR.responseText);

                    } else if (contentType.match(/^application\/json(;.*)?$/i)) {
                        ASF.Execute(d, data);
                    }
                    if (complete != null) {
                        complete(d, jqXHDR);
                    }
               },
               error: function(jqXHDR, status, error) {
                   ASF.AjaxError(jqXHDR, d);
               }
            });
        }
    };

    /**
     * Submit the current form.  The node element refers to the element being clicked.
     * From that element, we can identify the form to submit.  The element to refresh upon
     * the form submit is an outer element that should have the asf-container class.
     * If not such element as parent node, the parent node of the form is used.
     *
     * After the form is submitted, the response is executed if it is a JSON response.
     * If the response is an HTML content, the container element is refreshed with it.
     *
     * @param node the current element
     * @param url the URL to fetch using an HTTP GET
     * @param target the optional target element
     */
    ASF.Submit = function(node) {
        /* Find the form and container to update */
        var f = $(node).closest("form");
        var d = $(f);
        if (!d.is('.asf-container,ui-dialog-content')) {
            d = d.closest('.asf-container,.ui-dialog-content');
        }
        if (d.length == 0) {
            d = $(f).parent();
        }
        if (d.length > 0) {
            var params;
            var params = $(f).serialize();
            var url = $(f).attr('action');

            if (node.tagName == 'a' || node.tagName == 'A') {
                params = node.id + "=1&" + $(f).serialize();
            } else {
                params = node.name + "=1&" + $(f).serialize();
            }
            /**
             * Send notification on form to indicate a form submit is now in progress.
             */
            $(f).triggerHandler("notifySubmit", d);

            /* Perform the HTTP POST */
            jQuery.ajax({
                type: "POST",
                url: url,
                data: params,
                context: document.body,
                success: function(data, status, jqXHDR) {
                    var contentType = jqXHDR.getResponseHeader('Content-type');
                    if (contentType == null) {
                        contentType = "text/html";
                    }
                    $(f).triggerHandler("successSubmit", d);
                    if (contentType.match(/^text\/(html|xml)(;.*)?$/i)) {
                        d.fadeOut("fast", function() {
                            d.html(jqXHDR.responseText);
                            d.fadeIn("fast");
                        });

                    } else if (contentType.match(/^application\/json(;.*)?$/i)) {
                        ASF.Execute(d, data);
                    }
               },
               error: function(jqXHDR, status, error) {
                   ASF.AjaxError(jqXHDR, d);
               }
            });
        }
        return false;
    };

    /**
     * Perform an HTTP POST on the given URL.
     *
     * @param node the node element that will be updated by default on the AJAX response.
     * @param url the HTTP URL.
     * @param params the HTTP POST parameters.
     */
    ASF.Post = function(node, url, params) {
        /* Perform the HTTP POST */
        jQuery.ajax({
            type: "POST",
            url: url,
            data: params,
            context: document.body,
            success: function(data, status, jqXHDR) {
                var contentType = jqXHDR.getResponseHeader('Content-type');
                if (contentType == null) {
                    contentType = "text/html";
                }
                if (contentType.match(/^text\/(html|xml)(;.*)?$/i)) {
                    $(node).html(jqXHDR.responseText);

                } else if (contentType.match(/^application\/json(;.*)?$/i)) {
                    ASF.Execute(node, data);
                }
            },
            error: function(jqXHDR, status, error) {
                ASF.AjaxError(jqXHDR, node);
            }
        });
        return false;
    };

    /**
     * Open a popup form attached to the node element and which is filled by
     * the given URL.
     *
     * The popup form is created when the page refered by <tt>url</tt> is fetched.
     * It can be referenced by the unique id given in <tt>id</tt>.
     *
     * @param node the node element where the popup is attached to.
     * @param id the popup unique id.
     * @param url the URL to fetch to fill the popup content.
     * @param params the popup creation parameters.
     */
    ASF.Popup = function(node, id, url, params) {
        jQuery.ajax({
            type: "GET",
            url: url,
            context: document.body,
            success: function(data, status, jqXHDR) {
                var contentType = jqXHDR.getResponseHeader('Content-type');
                if (contentType == null) {
                    contentType = "text/html";
                }
                var div = $('#' + id);
                if (div.length == 0) {
                    div = document.createElement("div");
                    div.id = id;
                    $(document.body).append($(div));
                }
                if (contentType.match(/^text\/(html|xml)(;.*)?$/i)) {
                    $(div).html(jqXHDR.responseText);

                } else if (contentType.match(/^application\/json(;.*)?$/i)) {
                    ASF.Execute(div, data);
                }
                $(div).popup(params).popup('open');
                $(div).find('form:not(.filter) :input:visible:first').focus();
            },
            error: function(jqXHDR, status, error) {
                ASF.AjaxError(jqXHDR, node);
            }
        });
        return false;
    };

    /**
     * Open a dialog box and fetch the dialog content from the given URI.
     *
     * @param node the current element
     * @param id the dialog id
     * @param url the URL to fetch using an HTTP GET
     * @param params the optional dialog options
     */
    ASF.OpenDialog = function(node, id, url, params) {
        var div = $(id);
        if (div.length > 0) {
            return false;
        }

        div = document.createElement("div");
        div.id = id;
        div = $(div);

        var d = $(document);
        if (d.length == 0) {
            return false;
        }

        $(d).append($(div));

        /* Perform the HTTP GET */
        jQuery.ajax({
            url: url,
            context: document.body,
            success: function(data, status, jqXHDR) {
                var contentType = jqXHDR.getResponseHeader('Content-type');
                if (contentType == null) {
                    contentType = "text/html";
                }
                if (contentType.match(/^text\/(html|xml)(;.*)?$/i)) {
                    $(div).dialog({
                        autoOpen: false,
                        show: "blind",
                        hide: "explode",
                        minWidth: 600,
                        close: function() {
                            $(div).dialog('destroy');
                            $(div).remove();
                            if (params && params.close) {
                                params.close(node);
                            }
                        }
                     });

                     $(div).html(jqXHDR.responseText);

                     /**
                      * Extract a title from the inner form to setup the dialog box.
                      */
                     var dTitle, dBox = $(div).children('div');
                     if (dBox.length == 0) {
                        dTitle = $(div).children('h2');
                     } else {
                        dTitle = $(dBox).children('h2');
                     }
                     if (dTitle.length > 0) {
                        $(div).dialog("option", "title", dTitle.html());
                        dTitle.remove();
                     } else {
                        dTitle = $(div).children('div').attr('title');
                        if (dTitle != null) {
                            $(div).dialog("option", "title", dTitle );
                            /* $(div).attr('title', title); */
                        }
                     }
                     $(div).dialog('open');

                } else if (contentType.match(/^application\/json(;.*)?$/i)) {
                    ASF.Execute(node, data);
                }
            },
            error: function(jqXHDR, status, error) {
                ASF.AjaxError(jqXHDR, d);
            }
        });
        return false;
    };

    /**
     * Close the dialog box identified by the given identifier.
     *
     * @param id the dialog box identifier
     */
    ASF.CloseDialog = function(id) {
        $('#' + id).dialog('close');
        return false;
    };

    /**
     * Create and display a popup message near the node element.
     *
     * @param node the element giving the location of the message
     * @param id the message id or null
     * @param message the HTML message content
     */
    ASF.Message = function(node, id, message) {
        if (!id) {
            id = "#asf-message";
        }
        var div = $(id);
        if (div.length == 0) {
            div = document.createElement("div");
            div.id = id.substring(1);
            $(document.body).append($(div));
        }

        $(div).html(message).message({}).message("attachment", node);
    };
})();

<|endoftext|>


<commit_before>define(function (require) {
  var d3 = require("d3");

  return function pieChart() {
    // Chart options
    var width = 500;
    var height = 500;
    var color = d3.scale.category20c();
    var radius = Math.min(width, height) / 2;
    var sort = null;
    var value = function (d) { return d.size; };
    var xScale = d3.scale.linear().range([0, 2 * Math.PI]);
    var yScale = d3.scale.sqrt().range([0, radius]);
    var startAngle = function (d) {
      return Math.max(0, Math.min(2 * Math.PI, xScale(d.x)));
    };
    var endAngle = function (d) {
      return Math.max(0, Math.min(2 * Math.PI, xScale(d.x + d.dx)));
    };
    var innerRadius = function (d) {
      return Math.max(0, yScale(d.y));
    };
    var outerRadius = function (d) {
      return Math.max(0, yScale(d.y + d.dy));
    };
    var dispatch = d3.dispatch("brush", "hover", "mouseover", "mouseout");

    // Pie options
    var pieClass = "pie";
    var pieStroke = "#fff";
    var pieFill = function (d, i) { return color(i); };

    function chart (selection) {
      selection.each(function (data) {
        var partition = d3.layout.partition().sort(sort).value(value);
        var arc = d3.svg.arc()
          .startAngle(startAngle)
          .endAngle(endAngle)
          .innerRadius(innerRadius)
          .outerRadius(outerRadius);

        var svg = d3.select(this).append("svg")
          .attr("width", width)
          .attr("height", height)
          .append("g")
          .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");

        svg.datum(data).selectAll("path")
          .data(partition.nodes)
          .enter().append("path")
          .attr("d", arc)
          .attr("class", pieClass)
          .style("stroke", pieStroke)
          .style("fill", pieFill);
      });
    }

    chart.width = function (_) {
      if (!arguments.length) { return width; }
      width = _;
      return chart;
    };

    chart.height = function (_) {
      if (!arguments.length) { return height; }
      height = _;
      return chart;
    };

    chart.color = function (_) {
      if (!arguments.length) { return color; }
      color = _;
      return chart;
    };

    chart.radius = function (_) {
      if (!arguments.length) { return radius; }
      radius = _;
      return chart;
    };

    chart.sort = function (_) {
      if (!arguments.length) { return sort; }
      sort = _;
      return chart;
    };

    chart.value = function (_) {
      if (!arguments.length) { return value; }
      value = _;
      return chart;
    };

    chart.xScale = function (_) {
      if (!arguments.length) { return xScale; }
      xScale = _;
      return chart;
    };

    chart.yScale = function (_) {
      if (!arguments.length) { return yScale; }
      yScale = _;
      return chart;
    };

    chart.startAngle = function (_) {
      if (!arguments.length) { return startAngle; }
      startAngle = _;
      return chart;
    };

    chart.endAngle = function (_) {
      if (!arguments.length) { return endAngle; }
      endAngle = _;
      return chart;
    };

    chart.innerRadius = function (_) {
      if (!arguments.length) { return innerRadius; }
      innerRadius = _;
      return chart;
    };

    chart.outerRadius = function (_) {
      if (!arguments.length) { return outerRadius; }
      outerRadius = _;
      return chart;
    };

    chart.dispatch = function (_) {
      if (!arguments.length) { return dispatch; }
      dispatch = _;
      return chart;
    };

    chart.pieClass = function (_) {
      if (!arguments.length) { return pieClass; }
      pieClass = _;
      return chart;
    };

    chart.pieStroke = function (_) {
      if (!arguments.length) { return pieStroke; }
      pieStroke = _;
      return chart;
    };

    chart.pieFill = function (_) {
      if (!arguments.length) { return pieFill; }
      pieFill= _;
      return chart;
    };

    return chart;
  };
});
<commit_msg>added ability to have pie by default<commit_after>define(function (require) {
  var d3 = require("d3");

  return function pieChart() {
    // Chart options
    var width = 500;
    var height = 500;
    var color = d3.scale.category20c();
    var radius = Math.min(width, height) / 2;
    var sort = null;
    var value = function (d) { return d.size; };
    var xScale = d3.scale.linear().range([0, 2 * Math.PI]);
    var yScale = d3.scale.sqrt().range([0, radius]);
    var startAngle = function (d) {
      return Math.max(0, Math.min(2 * Math.PI, xScale(d.x)));
    };
    var endAngle = function (d) {
      return Math.max(0, Math.min(2 * Math.PI, xScale(d.x + d.dx)));
    };
    var innerRadius = function (d) {
      if (d.depth === 1) { return 0; }
      return Math.max(0, yScale(d.y));
    };
    var outerRadius = function (d) {
      return Math.max(0, yScale(d.y + d.dy));
    };
    var dispatch = d3.dispatch("brush", "hover", "mouseover", "mouseout");

    // Pie options
    var pieClass = "pie";
    var pieStroke = "#fff";
    var pieFill = function (d, i) { return color(i); };

    function chart (selection) {
      selection.each(function (data) {
        var partition = d3.layout.partition().sort(sort).value(value);
        var arc = d3.svg.arc()
          .startAngle(startAngle)
          .endAngle(endAngle)
          .innerRadius(innerRadius)
          .outerRadius(outerRadius);

        var svg = d3.select(this).append("svg")
          .attr("width", width)
          .attr("height", height)
          .append("g")
          .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");

        svg.datum(data).selectAll("path")
          .data(partition.nodes)
          .enter().append("path")
          .attr("d", arc)
          .attr("class", pieClass)
          .style("stroke", pieStroke)
          .style("fill", pieFill);
      });
    }

    chart.width = function (_) {
      if (!arguments.length) { return width; }
      width = _;
      return chart;
    };

    chart.height = function (_) {
      if (!arguments.length) { return height; }
      height = _;
      return chart;
    };

    chart.color = function (_) {
      if (!arguments.length) { return color; }
      color = _;
      return chart;
    };

    chart.radius = function (_) {
      if (!arguments.length) { return radius; }
      radius = _;
      return chart;
    };

    chart.sort = function (_) {
      if (!arguments.length) { return sort; }
      sort = _;
      return chart;
    };

    chart.value = function (_) {
      if (!arguments.length) { return value; }
      value = _;
      return chart;
    };

    chart.xScale = function (_) {
      if (!arguments.length) { return xScale; }
      xScale = _;
      return chart;
    };

    chart.yScale = function (_) {
      if (!arguments.length) { return yScale; }
      yScale = _;
      return chart;
    };

    chart.startAngle = function (_) {
      if (!arguments.length) { return startAngle; }
      startAngle = _;
      return chart;
    };

    chart.endAngle = function (_) {
      if (!arguments.length) { return endAngle; }
      endAngle = _;
      return chart;
    };

    chart.innerRadius = function (_) {
      if (!arguments.length) { return innerRadius; }
      innerRadius = _;
      return chart;
    };

    chart.outerRadius = function (_) {
      if (!arguments.length) { return outerRadius; }
      outerRadius = _;
      return chart;
    };

    chart.dispatch = function (_) {
      if (!arguments.length) { return dispatch; }
      dispatch = _;
      return chart;
    };

    chart.pieClass = function (_) {
      if (!arguments.length) { return pieClass; }
      pieClass = _;
      return chart;
    };

    chart.pieStroke = function (_) {
      if (!arguments.length) { return pieStroke; }
      pieStroke = _;
      return chart;
    };

    chart.pieFill = function (_) {
      if (!arguments.length) { return pieFill; }
      pieFill= _;
      return chart;
    };

    return chart;
  };
});
<|endoftext|>


<commit_before>var locastyle = locastyle || {};

locastyle.progressBar = (function() {
  'use strict';

  function init() {
    structureProgressBar();
  }

  function structureProgressBar() {
    $("[data-ls-module='progressBar']").each(function (index, element){
      var percentage = $(element).attr("aria-valuenow");
      $(element).append("");
        var $bar       = $(element).find('span');
      setProgressBarValue($bar, percentage);
    });
  }

  function setProgressBarValue(target, percentage) {
    $(target).css("width", percentage+"%");
  }

  return {
    init: init
  }

}());
<commit_msg>jshint porogress<commit_after>var locastyle = locastyle || {};

locastyle.progressBar = (function() {
  'use strict';

  function init() {
    structureProgressBar();
  }

  function structureProgressBar() {
    $("[data-ls-module='progressBar']").each(function (index, element){
      var percentage = $(element).attr("aria-valuenow");
      $(element).append("");
        var $bar       = $(element).find('span');
      setProgressBarValue($bar, percentage);
    });
  }

  function setProgressBarValue(target, percentage) {
    $(target).css("width", percentage+"%");
  }

  return {
    init: init
  };

}());
<|endoftext|>


<commit_before>/* ************************************************************************

   qooxdoo - the new era of web development

   http://qooxdoo.org

   Copyright:
   2017 Christian Boulanger

   License:
   MIT: https://opensource.org/licenses/MIT
   See the LICENSE file in the project's top-level directory for details.

   Authors:
   * Christian Boulanger (info@bibliograph.org, @cboulanger)

************************************************************************ */
require("../Package");
require("@qooxdoo/framework");

/**
 * Lists compatible library packages
 */
qx.Class.define("qx.tool.cli.commands.package.Upgrade", {
  extend: qx.tool.cli.commands.Package,
  statics: {
    getYargsCommand: function () {
      return {
        command: "upgrade [library_uri]",
        describe:
          "if no library URI is given, upgrades all available libraries to the latest compatible version, otherwise upgrade only the package identified by the URI.",
        builder: {
          quiet: {
            alias: "q",
            describe: "No output"
          },
          "verbose": {
            alias: "v",
            describe: "Verbose logging"
          },
          "releases-only": {
            alias: "r",
            describe: "Upgrade regular releases only"
          },
          "reinstall": {
            alias: "R",
            describe: "Do not upgrade, reinstall current version"
          },
          "dryrun":{
            alias: "d",
            describe: "Show result only, do not actually upgrade"
          },
          "prereleases": {
            alias: "p",
            describe: "Use prereleases if available"
          }
        },
        handler: function (argv) {
          return new qx.tool.cli.commands.package.Upgrade(argv)
            .process()
            .catch(e => {
              console.error(e.stack || e.message);
              process.exit(1);
            });
        }
      };
    }
  },

  members: {
    async process() {
      await this.base(arguments);
      await (new qx.tool.cli.commands.package.Update({
          quiet:true,
          prereleases: this.argv.prereleases
      })).process();
      await (new qx.tool.cli.commands.package.List({
        quiet:true,
        prereleases: this.argv.prereleases
      })).process();
      if (!this.argv.quiet) {
        console.info("Upgrading project dependencies to their latest available releases...");
      }
      let data = await this.getLockfileData();
      let found = false;
      const installer = new qx.tool.cli.commands.package.Install({
        quiet: this.argv.quiet,
        verbose: this.argv.verbose
      });
      for (const library of data.libraries) {
        // do not upggrade libraries that are not from a repository
        if (!library.repo_name || !library.repo_tag) {
          continue;
        }
        if (!library.uri) {
          library.uri = library.repo_name;
        }
        // if a library to upgrade has been provided, skip non-matching ones
        if (this.argv.library_uri && library.uri !== this.argv.library_uri) {
          continue;
        }
        found = true;
        if (this.argv.releasesOnly && (!qx.lang.Type.isString(library.repo_tag) || !library.repo_tag.startsWith("v"))) {
          if (!this.argv.quiet) {
            console.info(`Skipping ${library.library_name} (${library.uri}@${library.repo_tag}) since it is not a release.`);
          }
          continue;
        }
        try {
          if (this.argv.dryrun) {
            console.info(`Dry run. Not upgrading ${library.library_name} (${library.uri}@${library.repo_tag}).`);
            continue;
          }
          if (library.repo_tag && this.argv.reinstall) {
            await installer.install(library.uri, library.repo_tag);
          } else {
            await installer.install(library.uri);
          }
        } catch (e) {
          console.warn(e.message);
        }
      }
      if (!found) {
        throw new qx.tool.utils.Utils.UserError(`Library '${this.argv.library_uri}' is not installed.`);
      }
    }
  }
});
<commit_msg>Fix lint error (ridiculous indentation rule)<commit_after>/* ************************************************************************

   qooxdoo - the new era of web development

   http://qooxdoo.org

   Copyright:
   2017 Christian Boulanger

   License:
   MIT: https://opensource.org/licenses/MIT
   See the LICENSE file in the project's top-level directory for details.

   Authors:
   * Christian Boulanger (info@bibliograph.org, @cboulanger)

************************************************************************ */
require("../Package");
require("@qooxdoo/framework");

/**
 * Lists compatible library packages
 */
qx.Class.define("qx.tool.cli.commands.package.Upgrade", {
  extend: qx.tool.cli.commands.Package,
  statics: {
    getYargsCommand: function () {
      return {
        command: "upgrade [library_uri]",
        describe:
          "if no library URI is given, upgrades all available libraries to the latest compatible version, otherwise upgrade only the package identified by the URI.",
        builder: {
          quiet: {
            alias: "q",
            describe: "No output"
          },
          "verbose": {
            alias: "v",
            describe: "Verbose logging"
          },
          "releases-only": {
            alias: "r",
            describe: "Upgrade regular releases only"
          },
          "reinstall": {
            alias: "R",
            describe: "Do not upgrade, reinstall current version"
          },
          "dryrun":{
            alias: "d",
            describe: "Show result only, do not actually upgrade"
          },
          "prereleases": {
            alias: "p",
            describe: "Use prereleases if available"
          }
        },
        handler: function (argv) {
          return new qx.tool.cli.commands.package.Upgrade(argv)
            .process()
            .catch(e => {
              console.error(e.stack || e.message);
              process.exit(1);
            });
        }
      };
    }
  },

  members: {
    async process() {
      await this.base(arguments);
      await (new qx.tool.cli.commands.package.Update({
        quiet:true,
        prereleases: this.argv.prereleases
      })).process();
      await (new qx.tool.cli.commands.package.List({
        quiet:true,
        prereleases: this.argv.prereleases
      })).process();
      if (!this.argv.quiet) {
        console.info("Upgrading project dependencies to their latest available releases...");
      }
      let data = await this.getLockfileData();
      let found = false;
      const installer = new qx.tool.cli.commands.package.Install({
        quiet: this.argv.quiet,
        verbose: this.argv.verbose
      });
      for (const library of data.libraries) {
        // do not upggrade libraries that are not from a repository
        if (!library.repo_name || !library.repo_tag) {
          continue;
        }
        if (!library.uri) {
          library.uri = library.repo_name;
        }
        // if a library to upgrade has been provided, skip non-matching ones
        if (this.argv.library_uri && library.uri !== this.argv.library_uri) {
          continue;
        }
        found = true;
        if (this.argv.releasesOnly && (!qx.lang.Type.isString(library.repo_tag) || !library.repo_tag.startsWith("v"))) {
          if (!this.argv.quiet) {
            console.info(`Skipping ${library.library_name} (${library.uri}@${library.repo_tag}) since it is not a release.`);
          }
          continue;
        }
        try {
          if (this.argv.dryrun) {
            console.info(`Dry run. Not upgrading ${library.library_name} (${library.uri}@${library.repo_tag}).`);
            continue;
          }
          if (library.repo_tag && this.argv.reinstall) {
            await installer.install(library.uri, library.repo_tag);
          } else {
            await installer.install(library.uri);
          }
        } catch (e) {
          console.warn(e.message);
        }
      }
      if (!found) {
        throw new qx.tool.utils.Utils.UserError(`Library '${this.argv.library_uri}' is not installed.`);
      }
    }
  }
});
<|endoftext|>


<commit_before>/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  Dimensions,
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
import { StateNavigator } from 'navigation';
import { SceneNavigator, spring } from 'navigation-react-native';
import Home from './Home';
import Tweet from './Tweet';

const stateNavigator = new StateNavigator([
  { key: 'home' },
  { key: 'tweet', trackCrumbTrail: true }
]);

var { home, tweet } = stateNavigator.states;
home.renderScene = () => <Home stateNavigator={stateNavigator} />;
tweet.renderScene = () => <Tweet stateNavigator={stateNavigator} />;

tweet.truncateCrumbTrail = (state, crumbs) => crumbs;

export default class Twitter extends Component {
  componentDidMount() {
    stateNavigator.navigate('home');
  }
  render() {
    return (
      <View>
        <SceneNavigator
          unmountedStyle={{ translate: spring(100), scale: spring(1) }}
          mountedStyle={{ translate: spring(0), scale: spring(1) }}
          crumbStyle={{ translate: spring(5), scale: spring(0.9) }}
          stateNavigator={stateNavigator}>
          {({translate, scale}, scene) => <View style={[
            styles.scene,
            {
              transform: [
                { translateX: Dimensions.get('window').width * translate / 100 },
                { scale: scale },
              ]
            },
          ]}>{scene}</View>}
        </SceneNavigator>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  scene: {
    borderWidth: 1,
    borderColor: 'black',
    backgroundColor: 'white',
    width: Dimensions.get('window').width,
    height: Dimensions.get('window').height,
    position: 'absolute',
  }
});

AppRegistry.registerComponent('twitter', () => Twitter);
<commit_msg>Disabled inactive scenes with pointer events<commit_after>/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  Dimensions,
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
import { StateNavigator } from 'navigation';
import { SceneNavigator, spring } from 'navigation-react-native';
import Home from './Home';
import Tweet from './Tweet';

const stateNavigator = new StateNavigator([
  { key: 'home' },
  { key: 'tweet', trackCrumbTrail: true }
]);

var { home, tweet } = stateNavigator.states;
home.renderScene = () => <Home stateNavigator={stateNavigator} />;
tweet.renderScene = () => <Tweet stateNavigator={stateNavigator} />;

tweet.truncateCrumbTrail = (state, crumbs) => crumbs;

export default class Twitter extends Component {
  componentDidMount() {
    stateNavigator.navigate('home');
  }
  render() {
    return (
      <View>
        <SceneNavigator
          unmountedStyle={{ translate: spring(100), scale: spring(1) }}
          mountedStyle={{ translate: spring(0), scale: spring(1) }}
          crumbStyle={{ translate: spring(5), scale: spring(0.9) }}
          stateNavigator={stateNavigator}>
          {({translate, scale}, scene, active) => (
              <View
                pointerEvents={active ? 'auto' : 'none'}
                style={[
                  styles.scene,
                  { transform: [
                      { translateX: Dimensions.get('window').width * translate / 100 },
                      { scale: scale },
                    ]
                  },
                ]}>{scene}</View>
          )}
        </SceneNavigator>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  scene: {
    borderWidth: 1,
    borderColor: 'black',
    backgroundColor: 'white',
    width: Dimensions.get('window').width,
    height: Dimensions.get('window').height,
    position: 'absolute',
  }
});

AppRegistry.registerComponent('twitter', () => Twitter);
<|endoftext|>