<commit_before>import Symbol from './Symbol.js';

const tagsKey = Symbol('tags');

export default function CustomTagsMixin(Base) {

  return class CustomTags extends Base {

    get tags() {
      return Object.assign({}, super.tags, this[tagsKey]);
    }
    set tags(tags) {
      this[tagsKey] = typeof tags === 'string' ?
        parseTagsDeclarations(tags) :
        tags;
    }

  };

}

function parseTagsDeclarations(declarations) {

  // A token (either a name or a tag) is one or more characters,
  // exluding whitespace, colons, semicolons, and commas.
  const token = `[^\\s:,;]+`;

  // A declaration is two colon-separated tokens.
  // The colon may have whitespace on either side.
  const declaration = `(${token})\\s*:\\s*(${token})`;
  const declarationRegex = new RegExp(declaration, 'g');

  let match = declarationRegex.exec(declarations);
  const result = {};
  while (match) {
    const tagSlot = match[1];
    const tagName = match[2];
    result[tagSlot] = tagName;
    match = declarationRegex.exec(declarations);
  }

  return result;
}
<commit_msg>Deprecate use of Symbol.js.<commit_after>const tagsKey = Symbol('tags');

export default function CustomTagsMixin(Base) {

  return class CustomTags extends Base {

    get tags() {
      return Object.assign({}, super.tags, this[tagsKey]);
    }
    set tags(tags) {
      this[tagsKey] = typeof tags === 'string' ?
        parseTagsDeclarations(tags) :
        tags;
    }

  };

}

function parseTagsDeclarations(declarations) {

  // A token (either a name or a tag) is one or more characters,
  // exluding whitespace, colons, semicolons, and commas.
  const token = `[^\\s:,;]+`;

  // A declaration is two colon-separated tokens.
  // The colon may have whitespace on either side.
  const declaration = `(${token})\\s*:\\s*(${token})`;
  const declarationRegex = new RegExp(declaration, 'g');

  let match = declarationRegex.exec(declarations);
  const result = {};
  while (match) {
    const tagSlot = match[1];
    const tagName = match[2];
    result[tagSlot] = tagName;
    match = declarationRegex.exec(declarations);
  }

  return result;
}
<|endoftext|>


<commit_before>define( ['dojo/_base/declare',
         'dojo/_base/array',
         'JBrowse/Util',
         'JBrowse/View/Track/HTMLFeatures'
        ],
        function( declare, array, Util, HTMLFeatures ) {

return declare( HTMLFeatures,
/**
 * @lends JBrowse.View.Track.Alignments
 */
{

    _defaultConfig: function() {
        return Util.deepUpdate(
            dojo.clone( this.inherited(arguments) ),
            {
                maxFeatureScreenDensity: 1.5,
                layoutPitchY: 4,
                style: {
                    _defaultLabelScale: 50,
                    className: 'alignment',
                    arrowheadClass: 'arrowhead'
                }
            }
        );
    },

    renderFeature: function( feature, uniqueId, block, scale ) {
        var featDiv = this.inherited( arguments );
        this._drawMismatches( feature, featDiv, scale );

        // if this feature is part of a multi-segment read, and not
        // all of its segments are aligned, add missing_mate to its
        // class
        if( feature.get('multi_segment_template') && !feature.get('multi_segment_all_aligned') )
            featDiv.className += ' missing_mate';

        return featDiv;
    },

    /**
     * draw base-mismatches on the feature
     */
    _drawMismatches: function( feature, featDiv, scale ) {
        // recall: scale is pixels/basepair
        if ( scale >= 0.5 ) {
            var mismatches = this._getMismatches( feature );
            var charSize = this.getCharacterMeasurements();
            var drawChars = scale >= charSize.w;
            var featureLength = feature.get('end') - feature.get('start');

            array.forEach( mismatches, function( mismatch ) {
                array.forEach( mismatch.bases, function( base, i ) {
                    dojo.create('span', {
                                    className: 'mismatch base base_'+(base == '*' ? 'deletion' : base.toLowerCase()),
                                    title: base == '*' ? 'deletion' : 'SNP',
                                    style: {
                                        position: 'absolute',
                                        left: (mismatch.start+i)/featureLength*100 + '%',
                                        width: Math.max(scale,1) + 'px'
                                    },
                                    innerHTML: drawChars ? base : ''
                                }, featDiv );
               }, this );
            });
        }
    },

    _getMismatches: function( feature ) {
        var seq = feature.get('seq');
        if( ! seq )
            return m;

        // parse the MD tag if it has one
        var mdTag = feature.get('MD');
        if( mdTag ) {
            return this._mdToMismatches( feature, mdTag );
        }

        return [];
    },

    /**
     * parse a SAM MD tag to find mismatching bases of the template versus the reference
     * @returns {Array[Object]} array of mismatches and their positions
     * @private
     */
    _mdToMismatches: function( feature, mdstring ) {
        var mismatchRecords = [];
        var curr = { start: 0, bases: '' };
        var seq = feature.get('seq');
        var nextRecord = function() {
              mismatchRecords.push( curr );
              curr = { start: curr.start + curr.bases.length, bases: ''};
        };
        array.forEach( mdstring.match(/(\d+|\^[a-z]+|[a-z])/ig), function( token ) {
          if( token.match(/^\d/) ) { // matching bases
              curr.start += parseInt( token );
          }
          else if( token.match(/^\^/) ) { // insertion in the template
              var i = token.length-1;
              while( i-- ) {
                  curr.bases += '*';
              }
              nextRecord();
          }
          else if( token.match(/^[a-z]/i) ) { // mismatch
              curr.bases = seq.substr( curr.start, token.length );
              nextRecord();
          }
        });
        return mismatchRecords;
    },

    // stub out subfeature rendering, this track doesn't render subfeatures
    renderSubfeature: function() {},

    /**
     * @returns {Object} containing h and w,
     *      in pixels, of the characters being used for sequences
     */
    getCharacterMeasurements: function() {
        if( !this._measurements )
            this._measurements = this._measureSequenceCharacterSize( this.div );
        return this._measurements;
    },

    /**
     * Conducts a test with DOM elements to measure sequence text width
     * and height.
     */
    _measureSequenceCharacterSize: function( containerElement ) {
        var widthTest = dojo.create('div', {
                                        innerHTML: 'A'
                                            +'C'
                                            +'T'
                                            +'G'
                                            +'N',
                                        style: {
                                            visibility: 'hidden',
                                            position: 'absolute',
                                            left: '0px'
                                        }
                                    }, containerElement );
        var result = {
            w:  widthTest.clientWidth / 5,
            h: widthTest.clientHeight
        };
        containerElement.removeChild(widthTest);
        return result;
    },

    /**
     * Make a default feature detail page for the given feature.
     * @returns {HTMLElement} feature detail page HTML
     */

    defaultFeatureDetail: function( /** JBrowse.Track */ track, /** Object */ f, /** HTMLElement */ div ) {
        var fmt = dojo.hitch( this, function( name, value ) {
            name = Util.ucFirst( name.replace(/_/g,' ') );
            return this._fmtDetailField(name, value);
        });
        var container = dojo.create('div', {
            className: 'detail feature-detail feature-detail-'+track.name,
            innerHTML: ''
        });
        container.innerHTML += fmt( 'Name', f.get('name') );
        container.innerHTML += fmt( 'Type', f.get('type') );
        container.innerHTML += fmt( 'Score', f.get('score') );
        container.innerHTML += fmt( 'Description', f.get('note') );
        container.innerHTML += fmt(
            'Position',
            Util.assembleLocString({ start: f.get('start'),
                                     end: f.get('end'),
                                     ref: this.refSeq.name })
            + ({'1':' (+)', '-1': ' (-)', 0: ' (no strand)' }[f.get('strand')] || '')
        );

        var alignment = '
'+f.get('seq')+'
';
        if( f.get('seq') ) {
            container.innerHTML += fmt('Sequence and Quality', this._renderSeqQual( f ) );
        }

        var additionalTags = array.filter(
            f.tags(), function(t) {
                return ! {name:1,score:1,start:1,end:1,strand:1,note:1,subfeatures:1,type:1}[t.toLowerCase()];
            }
        ).sort();

        dojo.forEach( additionalTags, function(t) {
            container.innerHTML += fmt( t, f.get(t) );
        });

        return container;
    },

    _renderSeqQual: function( feature ) {

        var seq  = feature.get('seq'),
            qual = feature.get('qual') || '';
        if( !seq )
            return '';

        qual = qual.split(/\s+/);
        var fieldWidth = (''+Math.max.apply( Math, qual )).length;

        // pad the sequence with spaces
        var seqPadding = ' ';
        while( seqPadding.length < fieldWidth-1 ) {
            seqPadding += ' ';
        }
        var paddedSeq = array.map( seq, function(s) {
            return s + seqPadding;
        });

        var tableRowHTML = function(fields, class_) {
            class_ = class_ ? ' class="'+class_+'"' : '';
            return '
'+array.map( fields, function(f) { return ''+f+'	'; }).join('')+'
';
        };
        // insert newlines
        var rendered = '';
        var lineFields = Math.round(60/fieldWidth);
        while( paddedSeq.length ) {
            var line = paddedSeq.slice(0,Math.min( paddedSeq.length, lineFields ) );
            paddedSeq = paddedSeq.slice(lineFields);
            rendered += tableRowHTML( line, 'seq' );
            if( qual.length ) {
                line = qual.slice(0, Math.min( qual.length, lineFields ));
                qual = qual.slice(lineFields);
                rendered += tableRowHTML( line, 'qual' );
            }
        }
        return '
'+rendered+'
';
    }
});
});<commit_msg>Changed title attribute handling<commit_after>define( ['dojo/_base/declare',
         'dojo/_base/array',
         'JBrowse/Util',
         'JBrowse/View/Track/HTMLFeatures'
        ],
        function( declare, array, Util, HTMLFeatures ) {

return declare( HTMLFeatures,
/**
 * @lends JBrowse.View.Track.Alignments
 */
{

    _defaultConfig: function() {
        return Util.deepUpdate(
            dojo.clone( this.inherited(arguments) ),
            {
                maxFeatureScreenDensity: 1.5,
                layoutPitchY: 4,
                style: {
                    _defaultLabelScale: 50,
                    className: 'alignment',
                    arrowheadClass: 'arrowhead'
                }
            }
        );
    },

    renderFeature: function( feature, uniqueId, block, scale ) {
        var featDiv = this.inherited( arguments );
        this._drawMismatches( feature, featDiv, scale );

        // if this feature is part of a multi-segment read, and not
        // all of its segments are aligned, add missing_mate to its
        // class
        if( feature.get('multi_segment_template') && !feature.get('multi_segment_all_aligned') )
            featDiv.className += ' missing_mate';

        return featDiv;
    },

    /**
     * draw base-mismatches on the feature
     */
    _drawMismatches: function( feature, featDiv, scale ) {
        // recall: scale is pixels/basepair
        if ( scale >= 0.5 ) {
            var mismatches = this._getMismatches( feature );
            var charSize = this.getCharacterMeasurements();
            var drawChars = scale >= charSize.w;
            var featureLength = feature.get('end') - feature.get('start');

            array.forEach( mismatches, function( mismatch ) {
                array.forEach( mismatch.bases, function( base, i ) {
                    dojo.create('span', {
                                    className: 'mismatch base base_'+(base == '*' ? 'deletion' : base.toLowerCase()),
                                    title: base == '*' ? 'deletion' : null,
                                    style: {
                                        position: 'absolute',
                                        left: (mismatch.start+i)/featureLength*100 + '%',
                                        width: Math.max(scale,1) + 'px'
                                    },
                                    innerHTML: drawChars ? base : ''
                                }, featDiv );
               }, this );
            });
        }
    },

    _getMismatches: function( feature ) {
        var seq = feature.get('seq');
        if( ! seq )
            return m;

        // parse the MD tag if it has one
        var mdTag = feature.get('MD');
        if( mdTag ) {
            return this._mdToMismatches( feature, mdTag );
        }

        return [];
    },

    /**
     * parse a SAM MD tag to find mismatching bases of the template versus the reference
     * @returns {Array[Object]} array of mismatches and their positions
     * @private
     */
    _mdToMismatches: function( feature, mdstring ) {
        var mismatchRecords = [];
        var curr = { start: 0, bases: '' };
        var seq = feature.get('seq');
        var nextRecord = function() {
              mismatchRecords.push( curr );
              curr = { start: curr.start + curr.bases.length, bases: ''};
        };
        array.forEach( mdstring.match(/(\d+|\^[a-z]+|[a-z])/ig), function( token ) {
          if( token.match(/^\d/) ) { // matching bases
              curr.start += parseInt( token );
          }
          else if( token.match(/^\^/) ) { // insertion in the template
              var i = token.length-1;
              while( i-- ) {
                  curr.bases += '*';
              }
              nextRecord();
          }
          else if( token.match(/^[a-z]/i) ) { // mismatch
              curr.bases = seq.substr( curr.start, token.length );
              nextRecord();
          }
        });
        return mismatchRecords;
    },

    // stub out subfeature rendering, this track doesn't render subfeatures
    renderSubfeature: function() {},

    /**
     * @returns {Object} containing h and w,
     *      in pixels, of the characters being used for sequences
     */
    getCharacterMeasurements: function() {
        if( !this._measurements )
            this._measurements = this._measureSequenceCharacterSize( this.div );
        return this._measurements;
    },

    /**
     * Conducts a test with DOM elements to measure sequence text width
     * and height.
     */
    _measureSequenceCharacterSize: function( containerElement ) {
        var widthTest = dojo.create('div', {
                                        innerHTML: 'A'
                                            +'C'
                                            +'T'
                                            +'G'
                                            +'N',
                                        style: {
                                            visibility: 'hidden',
                                            position: 'absolute',
                                            left: '0px'
                                        }
                                    }, containerElement );
        var result = {
            w:  widthTest.clientWidth / 5,
            h: widthTest.clientHeight
        };
        containerElement.removeChild(widthTest);
        return result;
    },

    /**
     * Make a default feature detail page for the given feature.
     * @returns {HTMLElement} feature detail page HTML
     */

    defaultFeatureDetail: function( /** JBrowse.Track */ track, /** Object */ f, /** HTMLElement */ div ) {
        var fmt = dojo.hitch( this, function( name, value ) {
            name = Util.ucFirst( name.replace(/_/g,' ') );
            return this._fmtDetailField(name, value);
        });
        var container = dojo.create('div', {
            className: 'detail feature-detail feature-detail-'+track.name,
            innerHTML: ''
        });
        container.innerHTML += fmt( 'Name', f.get('name') );
        container.innerHTML += fmt( 'Type', f.get('type') );
        container.innerHTML += fmt( 'Score', f.get('score') );
        container.innerHTML += fmt( 'Description', f.get('note') );
        container.innerHTML += fmt(
            'Position',
            Util.assembleLocString({ start: f.get('start'),
                                     end: f.get('end'),
                                     ref: this.refSeq.name })
            + ({'1':' (+)', '-1': ' (-)', 0: ' (no strand)' }[f.get('strand')] || '')
        );

        var alignment = '
'+f.get('seq')+'
';
        if( f.get('seq') ) {
            container.innerHTML += fmt('Sequence and Quality', this._renderSeqQual( f ) );
        }

        var additionalTags = array.filter(
            f.tags(), function(t) {
                return ! {name:1,score:1,start:1,end:1,strand:1,note:1,subfeatures:1,type:1}[t.toLowerCase()];
            }
        ).sort();

        dojo.forEach( additionalTags, function(t) {
            container.innerHTML += fmt( t, f.get(t) );
        });

        return container;
    },

    _renderSeqQual: function( feature ) {

        var seq  = feature.get('seq'),
            qual = feature.get('qual') || '';
        if( !seq )
            return '';

        qual = qual.split(/\s+/);
        var fieldWidth = (''+Math.max.apply( Math, qual )).length;

        // pad the sequence with spaces
        var seqPadding = ' ';
        while( seqPadding.length < fieldWidth-1 ) {
            seqPadding += ' ';
        }
        var paddedSeq = array.map( seq, function(s) {
            return s + seqPadding;
        });

        var tableRowHTML = function(fields, class_) {
            class_ = class_ ? ' class="'+class_+'"' : '';
            return '
'+array.map( fields, function(f) { return ''+f+'	'; }).join('')+'
';
        };
        // insert newlines
        var rendered = '';
        var lineFields = Math.round(60/fieldWidth);
        while( paddedSeq.length ) {
            var line = paddedSeq.slice(0,Math.min( paddedSeq.length, lineFields ) );
            paddedSeq = paddedSeq.slice(lineFields);
            rendered += tableRowHTML( line, 'seq' );
            if( qual.length ) {
                line = qual.slice(0, Math.min( qual.length, lineFields ));
                qual = qual.slice(lineFields);
                rendered += tableRowHTML( line, 'qual' );
            }
        }
        return '
'+rendered+'
';
    }
});
});<|endoftext|>


<commit_before>// This file is required by app.js.
// It handles all the server-side socketIO logic for CifraChat, interacting
// with the client-side code in /public/js/chat.js.

// messages must be numbered to notify each client when their message is decrypted
var messageNum = 1;

module.exports = function(app, io)
{
	var chat = io.of('/chat').on('connection', function(clntSocket)
	{
	  // each client is put into a chat room restricted to max 2 clients
	  clntSocket.on('joinRoom', function(room_id)
	  {
		// client may only join room only if it's not full
		if (chat.clients(room_id).length >= 2)
		{
			clntSocket.emit('serverMessage', {
				message: 'This room is full.'
			});
			// force client to disconnect
			clntSocket.disconnect();
		}
		else
		{
			// client joins room specified in URL
			clntSocket.join(room_id);

			// welcome client on succesful connection
			clntSocket.emit('serverMessage', {
				message: 'Welcome to  CifraChat.'
			});

			// let other user know that client joined
			clntSocket.broadcast.to(room_id).emit('serverMessage', {
				message: 'Other has joined.'
			});

			// let everyone know that the max amount of users (2) has been reached
			chat.in(room_id).emit('serverMessage', {
				message: 'This room is now full: there are 2 users present. No more users can join.'
			});

		    /** sending encrypted **/
			clntSocket.on('cryptSend', function (data) {
				// all data sent by client is sent to room
				clntSocket.broadcast.to(room_id).emit('cryptMessage', {
					message: data.message,
					hint: data.hint,
					sender: 'Other',
					number: messageNum
				});
				// and then shown to client
				clntSocket.emit('cryptMessage', {
					message: data.message,
					hint: data.hint,
					sender: 'Self',
					number: messageNum
				});

				messageNum++;
			});

			/** sending unencrypted **/
			clntSocket.on('noncryptSend', function (text) {
				// all data sent by client is sent to room
				clntSocket.broadcast.to(room_id).emit('noncryptMessage', {
					message: text.message,
					sender: 'Other'
				});
				// and then shown to client
				clntSocket.emit('noncryptMessage', {
					message: text.message,
					sender: 'Self'
				});

				// unencrypted messages don't increment messageNum because messageNum is only used to identify which message was decrypted
			});

			/** notifying clients of decryption **/
			clntSocket.on('confirmDecrypt', function(id) {
				// let room know which particular message was decrypted
				chat.in(room_id).emit('markDecryption', id);
			});

			clntSocket.on('confirmMessageDestroy', function(id) {
				chat.in(room_id).emit('markMessageDestroy', id)
			});
		};

		/** disconnect listener **/
		// notify others that somebody left the chat
		clntSocket.on('disconnect', function() {
			// let room know that this client has left
			clntSocket.broadcast.to(room_id).emit('serverMessage', {
					message: 'Other has left.'
				});
		});
	  }); // end joinRoom listener
	});
};<commit_msg>suppress chat full message for only one user<commit_after>// This file is required by app.js.
// It handles all the server-side socketIO logic for CifraChat, interacting
// with the client-side code in /public/js/chat.js.

// messages must be numbered to notify each client when their message is decrypted
var messageNum = 1;
var MAX_ALLOWED_CLIENTS = 2;

module.exports = function(app, io)
{
	var chat = io.of('/chat').on('connection', function(clntSocket)
	{
	  // each client is put into a chat room restricted to max 2 clients
	  clntSocket.on('joinRoom', function(room_id)
	  {
	  	var clients_in_room = chat.clients(room_id).length
		// client may only join room only if it's not full
		if (clients_in_room >= MAX_ALLOWED_CLIENTS)
		{
			clntSocket.emit('serverMessage', {
				message: 'This room is full.'
			});
			// force client to disconnect
			clntSocket.disconnect();
		}
		else
		{
			// client joins room specified in URL
			clntSocket.join(room_id);

			clients_in_room++;

			// welcome client on succesful connection
			clntSocket.emit('serverMessage', {
				message: 'Welcome to  CifraChat.'
			});

			// let other user know that client joined
			clntSocket.broadcast.to(room_id).emit('serverMessage', {
				message: 'Other has joined.'
			});

			if (clients_in_room == MAX_ALLOWED_CLIENTS){
				// let everyone know that the max amount of users (2) has been reached
				chat.in(room_id).emit('serverMessage', {
					message: 'This room is now full: there are 2 users present. No more users can join.'
				});
			}

		    /** sending encrypted **/
			clntSocket.on('cryptSend', function (data) {
				// all data sent by client is sent to room
				clntSocket.broadcast.to(room_id).emit('cryptMessage', {
					message: data.message,
					hint: data.hint,
					sender: 'Other',
					number: messageNum
				});
				// and then shown to client
				clntSocket.emit('cryptMessage', {
					message: data.message,
					hint: data.hint,
					sender: 'Self',
					number: messageNum
				});

				messageNum++;
			});

			/** sending unencrypted **/
			clntSocket.on('noncryptSend', function (text) {
				// all data sent by client is sent to room
				clntSocket.broadcast.to(room_id).emit('noncryptMessage', {
					message: text.message,
					sender: 'Other'
				});
				// and then shown to client
				clntSocket.emit('noncryptMessage', {
					message: text.message,
					sender: 'Self'
				});

				// unencrypted messages don't increment messageNum because messageNum is only used to identify which message was decrypted
			});

			/** notifying clients of decryption **/
			clntSocket.on('confirmDecrypt', function(id) {
				// let room know which particular message was decrypted
				chat.in(room_id).emit('markDecryption', id);
			});

			clntSocket.on('confirmMessageDestroy', function(id) {
				chat.in(room_id).emit('markMessageDestroy', id)
			});
		};

		/** disconnect listener **/
		// notify others that somebody left the chat
		clntSocket.on('disconnect', function() {
			// let room know that this client has left
			clntSocket.broadcast.to(room_id).emit('serverMessage', {
					message: 'Other has left.'
				});
		});
	  }); // end joinRoom listener
	});
};<|endoftext|>


<commit_before>/*
 Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.

 WSO2 Inc. licenses this file to you 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 removeCustomParam = function () {
    $(this).parent().parent().remove();
};

var dynamicForm = '

' +
                  '

State' +
                  '<select class="state form-control select"><option>AND</option><option>OR</option></select>

Key<input type=' +
                  '"text" class="form-control txt-key"/>

' +
                  'Operator<select class="form-control select operator">' +
                  '<option>=</option><option> !=</option><option> <</option>' +
                  '<option> =<</option><option> ></option><option> >=</option></select>

Value<input type="text" class="form-control txt-value"/>

';

$(document).ready(function () {

    $("#add-custom-param").click(function () {
        $("#customSearchParam").prepend(dynamicForm);
        $(".close-button-div").unbind("click");
        $(".close-button-div").bind("click", removeCustomParam);
    });

    $("#device-search-btn").click(function () {
        var location = $("#location").val();
        var payload_obj = {};
        var conditions = [];
        if (location) {
            var conditionObject = {};
            conditionObject.key = "LOCATION";
            conditionObject.value = location;
            conditionObject.operator = "=";
            conditionObject.state = "OR";
            conditions.push(conditionObject)
        }

        $("#customSearchParam .dynamic-search-param").each(function () {
            var value = $(this).find(".txt-value").val();
            var key = $(this).find(".txt-key").val()
            if (value && key) {
                var conditionObject = {};
                conditionObject.key = key;
                conditionObject.value = value;
                conditionObject.operator = $(this).find(".operator").val();
                conditionObject.state = $(this).find(".state").val();
                conditions.push(conditionObject)
            }
        });
        payload_obj.conditions = conditions;
        var deviceSearchAPI = "/mdm-admin/search";
        //===================
        $("#advance-search-form").addClass(" hidden");
        $("#loading-content").removeClass('hidden');
        var deviceListing = $("#device-listing");
        var deviceListingSrc = deviceListing.attr("src");
        $.template("device-listing", deviceListingSrc, function (template) {

            var successCallback = function (data) {
                if (!data) {
                    $('#device-listing-status').removeClass('hidden');
                    $('#device-listing-status-msg').text('No Device are available to be displayed.');
                    return;
                }
                console.log("data");
                data = JSON.parse(data);
                console.log(data);
                console.log("-------------------------");
                console.log("/data");
                data = data.responseContent;
                console.log(data);
                var viewModel = {};
                if (data.length > 0) {
                    $('#ast-container').removeClass('hidden');
                    $('#user-listing-status-msg').text("");
                    var content = template(viewModel);
                    $("#ast-container").html(content);
                } else {
                    $('#device-listing-status').removeClass('hidden');
                    $('#device-listing-status-msg').text('No Device are available to be displayed.');
                }
                $("#loading-content").addClass('hidden');
                if (isInit) {
                    $('#user-grid').datatables_extended();
                    isInit = false;
                }
                $(".icon .text").res_text(0.2);
            };
            invokerUtil.post(deviceSearchAPI,
                             payload_obj,
                             successCallback,
                             function (message) {
                                 $("#loading-content").addClass('hidden');
                                 $("#advance-search-result").addClass("hidden");
                                 $("#advance-search-form").removeClass(" hidden");
                                 $('#device-listing-status').removeClass('hidden');
                                 $('#certificate-listing-status-msg').text('Invalid search query. Try again with a valid search query');
                             }
            );
        });

        //===================

        //
        //
        //
        //
        //
        //invokerUtil.post(
        //        deviceSearchAPI,
        //        payload_obj,
        //        function (data) {
        //            data = JSON.parse(data);
        //            console.log(data);
        //
        //            $("#advance-search-result").removeClass("hidden");
        //        }, function (data) {
        //            console.log("huta");
        //            if (data["status"] == 409) {
        //                $(errorMsg).text("User : " + username + " already exists. Pick another username.");
        //            } else if (data["status"] == 500) {
        //                $(errorMsg).text("An unexpected error occurred @ backend server. Please try again later.");
        //            } else {
        //                $(errorMsg).text(data.errorMessage);
        //            }
        //            $(errorMsgWrapper).removeClass("hidden");
        //        }
        //);

    });
});
<commit_msg>UI enhancements<commit_after>/*
 Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.

 WSO2 Inc. licenses this file to you 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 removeCustomParam = function () {
    $(this).parent().parent().remove();
};

var dynamicForm = '

' +
                  '

State' +
                  '<select class="state form-control select"><option>AND</option><option>OR</option></select>

Key<input type=' +
                  '"text" class="form-control txt-key"/>

' +
                  'Operator<select class="form-control select operator">' +
                  '<option>=</option><option> !=</option><option> <</option>' +
                  '<option> =<</option><option> ></option><option> >=</option></select>

Value<input type="text" class="form-control txt-value"/>

';

$(document).ready(function () {

    $("#add-custom-param").click(function () {
        $("#customSearchParam").prepend(dynamicForm);
        $(".close-button-div").unbind("click");
        $(".close-button-div").bind("click", removeCustomParam);
    });

    $("#device-search-btn").click(function () {
        var location = $("#location").val();
        var payload_obj = {};
        var conditions = [];
        if (location) {
            var conditionObject = {};
            conditionObject.key = "LOCATION";
            conditionObject.value = location;
            conditionObject.operator = "=";
            conditionObject.state = "OR";
            conditions.push(conditionObject)
        }

        $("#customSearchParam .dynamic-search-param").each(function () {
            var value = $(this).find(".txt-value").val();
            var key = $(this).find(".txt-key").val()
            if (value && key) {
                var conditionObject = {};
                conditionObject.key = key;
                conditionObject.value = value;
                conditionObject.operator = $(this).find(".operator").val();
                conditionObject.state = $(this).find(".state").val();
                conditions.push(conditionObject)
            }
        });
        payload_obj.conditions = conditions;
        var deviceSearchAPI = "/mdm-admin/search";
        $("#advance-search-form").addClass(" hidden");
        $("#loading-content").removeClass('hidden');
        var deviceListing = $("#device-listing");
        var deviceListingSrc = deviceListing.attr("src");
        $.template("device-listing", deviceListingSrc, function (template) {

            var successCallback = function (data) {
                if (!data) {
                    $('#device-listing-status').removeClass('hidden');
                    $('#device-listing-status-msg').text('No Device are available to be displayed.');
                    return;
                }
                //console.log("data");
                data = JSON.parse(data);
                //console.log(data);
                //console.log("-------------------------");
                //console.log("/data");
                data = data.responseContent;
                //console.log(data);
                var viewModel = {};
                if (data.length > 0) {
                    $('#ast-container').removeClass('hidden');
                    $('#user-listing-status-msg').text("");
                    var content = template(viewModel);
                    $("#ast-container").html(content);
                } else {
                    $('#device-listing-status').removeClass('hidden');
                    $('#device-listing-status-msg').text('No Device are available to be displayed.');
                }
                $("#loading-content").addClass('hidden');
                if (isInit) {
                    $('#user-grid').datatables_extended();
                    isInit = false;
                }
                $(".icon .text").res_text(0.2);
            };
            invokerUtil.post(deviceSearchAPI,
                             payload_obj,
                             successCallback,
                             function (message) {
                                 $("#loading-content").addClass('hidden');
                                 $("#advance-search-result").addClass("hidden");
                                 $("#advance-search-form").removeClass(" hidden");
                                 $('#device-listing-status').removeClass('hidden');
                                 $('#certificate-listing-status-msg').text('Invalid search query. Try again with a valid search query');
                             }
            );
        });
    });
});
<|endoftext|>


<commit_before>angular.module('services').factory('tasksService', tasksService);

function tasksService($http, $q, AuthService) {
  var SERVER_URL = 'http://localhost:8080/';

  function getTasks() {
    var q = $q.defer();

    if(AuthService.user) {
      console.log(AuthService.getUser());
      $http.get(SERVER_URL + 'user/' + AuthService.getUser().user._id + '/task').then(function(data){
        q.resolve(data);
      }, function(){
        q.reject();
      });
    } else {
      q.reject();
    }
    return q.promise;
  }

  function addTask(newTask) {
    var q = $q.defer();
    $http.post(SERVER_URL, newTask).then(function(data){
      q.resolve(data)
    }, function(){
      q.reject(data);
    });
    return q.promise;
  }

  function removeTask(id) {
    var q = $q.defer();
    $http.delete(SERVER_URL + id).then(function(data){
      q.resolve(data);
    }, function(data) {
      q.reject(data);
    });
    return q.promise;
  }

  return {
    getTasks: getTasks,
    addTask: addTask,
    removeTask: removeTask
  }
}
<commit_msg>updated front back<commit_after>angular.module('services').factory('tasksService', tasksService);

function tasksService($http, $q, AuthService) {
  var SERVER_URL = 'http://localhost:8080/task/';

  function getTasks() {
    var q = $q.defer();

    if(AuthService.user) {
      console.log(AuthService.getUser());
      $http.get(SERVER_URL + 'user/' + AuthService.getUser().user._id + '/task').then(function(data){
        q.resolve(data);
      }, function(){
        q.reject();
      });
    } else {
      q.reject();
    }
    return q.promise;
  }

  function addTask(newTask) {
    var q = $q.defer();
    $http.post(SERVER_URL, newTask).then(function(data){
      q.resolve(data)
    }, function(){
      q.reject();
    });
    return q.promise;
  }

  function removeTask(id) {
    var q = $q.defer();
    $http.delete(SERVER_URL + id).then(function(data){
      q.resolve(data);
    }, function(data) {
      q.reject(data);
    });
    return q.promise;
  }

  return {
    getTasks: getTasks,
    addTask: addTask,
    removeTask: removeTask
  }
}
<|endoftext|>


<commit_before>/// <binding AfterBuild='build-dev' ProjectOpened='dev-server' />
var gulp = require("gulp");
var $ = require("gulp-load-plugins")({ lazy: true });

var del = require("del");
var browserSync = require("browser-sync").create();
var args = require("yargs").argv;

var config = require("./gulp.config")();
var tsProject = $.typescript.createProject("tsconfig.json");

var karmaServer = require("karma").Server;
var karmaRunner = require("karma").runner;

gulp.task("clean-styles", function () {

    log("Cleaning styles from output");

    return del(config.styles.output + config.all.css);
});

gulp.task("styles", ["clean-styles"], function () {

    log("Compiling general styles into sass and adding them to the output");

    return gulp.src(config.styles.sass)
        .pipe($.sass().on("error", $.sass.logError))
        .pipe(gulp.dest(config.styles.output))
        .pipe(browserSync.stream());
});

gulp.task("clean-typescript", function () {

    log("Cleaning typescript from output");

    return del([
        config.app.output + config.all.js,
        config.app.output + config.all.jsMaps
    ]);

});

gulp.task("lint-typescript", function () {

    log("Checking Typescript Code Quality");

    return gulp.src(config.app.typescript)
        .pipe($.tslint({
            formatter: "verbose"
        }))
        .pipe($.tslint.report());

});

gulp.task("typescript", ["clean-typescript", "lint-typescript"], function () {

    log("Compiling typescript and adding them to the output");

    return gulp.src(config.app.typescript)
        .pipe($.sourcemaps.init())
        .pipe(tsProject())
        .js
        .pipe($.sourcemaps.write("."))
        .pipe(gulp.dest(config.app.output));

});

gulp.task("sync-typescript", ["typescript"], function () {
    runKarmaTests();
    browserSync.reload();
});

gulp.task("clean-templates", function () {

    log("Cleaning templates from output");

    return del(config.app.output + config.all.html);

});

gulp.task("templates", ["clean-templates"], function () {

    log("Copying templates to output");

    return gulp.src(config.app.templates)
        .pipe(gulp.dest(config.app.output));

});

gulp.task("sync-templates", ["templates"], function () {
    runKarmaTests();
    browserSync.reload();
});

gulp.task("clean-component-styles", function () {

    log("Cleaning angular styles from output");

    return del(config.app.output + config.all.css);

});

gulp.task("component-styles", function () {

    log("Compiling and copying angular styles to output");

    return gulp.src(config.app.styles)
        .pipe($.sass({
            includePaths: [config.styles.imports]
        }))
        .pipe(gulp.dest(config.app.output));

});

gulp.task("sync-component-styles", ["component-styles"], function () {
    browserSync.reload();
});

gulp.task("clean-dynamic-libs", function () {

    log("Cleaning angular files from output");

    return del([
        config.libs.output + "@angular",
        config.libs.output + "rxjs",
        config.libs.output + "@ngx-translate"
    ]);

});

gulp.task("dynamic-libs", ["clean-dynamic-libs"], function () {

    log("Copying dynamic library files to output");

    return gulp.src(config.libs.dynamicSrc, { base: "./node_modules/" })
        .pipe(gulp.dest(config.libs.output));

});

gulp.task("clean-libs", function () {

    log("Cleaning libs from output");

    return del([
        config.libs.output + "**/*",
        "!" + config.libs.output + "@angular/**/*",
        "!" + config.libs.output + "@angular",
        "!" + config.libs.output + "rxjs",
        "!" + config.libs.output + "@ngx-translate"
    ]);

});

gulp.task("libs", ["dynamic-libs", "clean-libs"], function () {

    log("Copying libs to output");

    var libs = gulp.src(config.libs.src);

    var libsCopyStream = libs
       .pipe(gulp.dest(config.libs.output));

    //Inject the libs here so they are in the correct order
    return gulp.src(config.index)
        .pipe($.inject(libsCopyStream,
        {
            ignorePath: "wwwroot/",
            name: "libs"
        }))
        .pipe(gulp.dest(config.home));

});

gulp.task("clean-fonts", function () {

    log("Cleaning fonts from output");

    del(config.fonts.output + "**/*");

});

gulp.task("fonts", ["clean-fonts"], function () {

    log("Copying fonts to output");

    return gulp.src(config.fonts.src)
        .pipe(gulp.dest(config.fonts.output));

});

gulp.task("test", ["typescript", "templates", "component-styles", "libs"], function (done) {
    log("Testing clientside code");

    new karmaServer({
        configFile: __dirname + "/" + config.karmaConfig,
        singleRun: true
    }, done).start();
});

gulp.task("build-dev", ["libs", "typescript", "styles", "templates", "component-styles", "fonts", "test"], function () {

    log("Building for development");

    var sources = gulp.src(config.styles.output + config.all.css, { read: false });

    return gulp.src(config.index)
        .pipe($.inject(sources, { ignorePath: "wwwroot/" }))
        .pipe(gulp.dest(config.home));
});

gulp.task("dev-server", function () {

    log("Starting up Browsersync server");

    if (browserSync.active) {
        return;
    }

    browserSync.init({
        proxy: "localhost:" + config.port,
        port: 3000,
        ghostMode: {
            click: true,
            scrolling: true,
            location: false,
            forms: true
        },
        injectChanges: true,
        logFileChanges: true,
        logLevel: "info",
        logPrefix: "Assessment Playground",
        notify: true,
        open: false
    });

    gulp.watch(config.styles.sass, { cwd: "./" }, ["styles"]);
    gulp.watch(config.app.typescript, { cwd: "./" }, ["sync-typescript"]);
    gulp.watch(config.app.templates, { cwd: "./" }, ["sync-templates"]);
    gulp.watch(config.app.styles, { cwd: "./" }, ["sync-component-styles"]);

    log("Starting up Karma server");

    new karmaServer({
        configFile: __dirname + "/" + config.karmaConfig,
        singleRun: false
    }).start();
});

function log(message) {
    $.util.log($.util.colors.yellow(message));
}

function runKarmaTests() {
    karmaRunner.run({ port: 9876 }, function () { });
}
<commit_msg>Fixed incorrect sourcemap sources path during build<commit_after>/// <binding AfterBuild='build-dev' ProjectOpened='dev-server' />
var gulp = require("gulp");
var $ = require("gulp-load-plugins")({ lazy: true });

var del = require("del");
var browserSync = require("browser-sync").create();
var args = require("yargs").argv;

var config = require("./gulp.config")();
var tsProject = $.typescript.createProject("tsconfig.json");

var karmaServer = require("karma").Server;
var karmaRunner = require("karma").runner;

gulp.task("clean-styles", function () {

    log("Cleaning styles from output");

    return del(config.styles.output + config.all.css);
});

gulp.task("styles", ["clean-styles"], function () {

    log("Compiling general styles into sass and adding them to the output");

    return gulp.src(config.styles.sass)
        .pipe($.sass().on("error", $.sass.logError))
        .pipe(gulp.dest(config.styles.output))
        .pipe(browserSync.stream());
});

gulp.task("clean-typescript", function () {

    log("Cleaning typescript from output");

    return del([
        config.app.output + config.all.js,
        config.app.output + config.all.jsMaps
    ]);

});

gulp.task("lint-typescript", function () {

    log("Checking Typescript Code Quality");

    return gulp.src(config.app.typescript)
        .pipe($.tslint({
            formatter: "verbose"
        }))
        .pipe($.tslint.report());

});

gulp.task("typescript", ["clean-typescript", "lint-typescript"], function () {

    log("Compiling typescript and adding them to the output");

    return gulp.src(config.app.typescript)
        .pipe($.sourcemaps.init())
        .pipe(tsProject())
        .js
        .pipe($.sourcemaps.mapSources(function (sourcePath, file) {
            var folderLevel = occurrences(sourcePath, "/") - 1;

            return Array(folderLevel).join("../") + sourcePath;
        }))
        .pipe($.sourcemaps.write("."))
        .pipe(gulp.dest(config.app.output));

    function occurrences(string, subString) {

        string += "";
        subString += "";
        if (subString.length <= 0) return (string.length + 1);

        var n = 0,
            pos = 0,
            step = subString.length;

        while (true) {
            pos = string.indexOf(subString, pos);
            if (pos >= 0) {
                ++n;
                pos += step;
            } else break;
        }
        return n;
    }
});

gulp.task("sync-typescript", ["typescript"], function () {
    runKarmaTests();
    browserSync.reload();
});

gulp.task("clean-templates", function () {

    log("Cleaning templates from output");

    return del(config.app.output + config.all.html);

});

gulp.task("templates", ["clean-templates"], function () {

    log("Copying templates to output");

    return gulp.src(config.app.templates)
        .pipe(gulp.dest(config.app.output));

});

gulp.task("sync-templates", ["templates"], function () {
    runKarmaTests();
    browserSync.reload();
});

gulp.task("clean-component-styles", function () {

    log("Cleaning angular styles from output");

    return del(config.app.output + config.all.css);

});

gulp.task("component-styles", function () {

    log("Compiling and copying angular styles to output");

    return gulp.src(config.app.styles)
        .pipe($.sass({
            includePaths: [config.styles.imports]
        }))
        .pipe(gulp.dest(config.app.output));

});

gulp.task("sync-component-styles", ["component-styles"], function () {
    browserSync.reload();
});

gulp.task("clean-dynamic-libs", function () {

    log("Cleaning angular files from output");

    return del([
        config.libs.output + "@angular",
        config.libs.output + "rxjs",
        config.libs.output + "@ngx-translate"
    ]);

});

gulp.task("dynamic-libs", ["clean-dynamic-libs"], function () {

    log("Copying dynamic library files to output");

    return gulp.src(config.libs.dynamicSrc, { base: "./node_modules/" })
        .pipe(gulp.dest(config.libs.output));

});

gulp.task("clean-libs", function () {

    log("Cleaning libs from output");

    return del([
        config.libs.output + "**/*",
        "!" + config.libs.output + "@angular/**/*",
        "!" + config.libs.output + "@angular",
        "!" + config.libs.output + "rxjs",
        "!" + config.libs.output + "@ngx-translate"
    ]);

});

gulp.task("libs", ["dynamic-libs", "clean-libs"], function () {

    log("Copying libs to output");

    var libs = gulp.src(config.libs.src);

    var libsCopyStream = libs
       .pipe(gulp.dest(config.libs.output));

    //Inject the libs here so they are in the correct order
    return gulp.src(config.index)
        .pipe($.inject(libsCopyStream,
        {
            ignorePath: "wwwroot/",
            name: "libs"
        }))
        .pipe(gulp.dest(config.home));

});

gulp.task("clean-fonts", function () {

    log("Cleaning fonts from output");

    del(config.fonts.output + "**/*");

});

gulp.task("fonts", ["clean-fonts"], function () {

    log("Copying fonts to output");

    return gulp.src(config.fonts.src)
        .pipe(gulp.dest(config.fonts.output));

});

gulp.task("test", ["typescript", "templates", "component-styles", "libs"], function (done) {
    log("Testing clientside code");

    new karmaServer({
        configFile: __dirname + "/" + config.karmaConfig,
        singleRun: true,
        port: 9877
    }, done).start();
});

gulp.task("build-dev", ["libs", "typescript", "styles", "templates", "component-styles", "fonts", "test"], function () {

    log("Building for development");

    var sources = gulp.src(config.styles.output + config.all.css, { read: false });

    return gulp.src(config.index)
        .pipe($.inject(sources, { ignorePath: "wwwroot/" }))
        .pipe(gulp.dest(config.home));
});

gulp.task("dev-server", function () {

    log("Starting up Browsersync server");

    if (browserSync.active) {
        return;
    }

    browserSync.init({
        proxy: "localhost:" + config.port,
        port: 3000,
        ghostMode: {
            click: true,
            scrolling: true,
            location: false,
            forms: true
        },
        injectChanges: true,
        logFileChanges: true,
        logLevel: "info",
        logPrefix: "Assessment Playground",
        notify: true,
        open: false
    });

    gulp.watch(config.styles.sass, { cwd: "./" }, ["styles"]);
    gulp.watch(config.app.typescript, { cwd: "./" }, ["sync-typescript"]);
    gulp.watch(config.app.templates, { cwd: "./" }, ["sync-templates"]);
    gulp.watch(config.app.styles, { cwd: "./" }, ["sync-component-styles"]);

    log("Starting up Karma server");

    new karmaServer({
        configFile: __dirname + "/" + config.karmaConfig,
        singleRun: false
    }).start();
});

function log(message) {
    $.util.log($.util.colors.yellow(message));
}

function runKarmaTests() {
    karmaRunner.run({ port: 9876 }, function () { });
}
<|endoftext|>


<commit_before>/**
 * eslint-config-ticketfly-base/stylistic-issues
 *
 * The rules here are this configuration's opinion of
 * rules listed under ESLint's "Stylistic Issues"
 * category: (http://eslint.org/docs/rules/#stylistic-issues)
 */
module.exports = {
  rules: {
    // enforce spacing inside single-line blocks
    // http://eslint.org/docs/rules/block-spacing
    'block-spacing': ['error', 'always'],

    // enforce one true brace style
    'brace-style': ['error', '1tbs', { allowSingleLine: true }],

    // require or disallow trailing commas
    'comma-dangle': ['error', 'never'],

    // enforce spacing before and after comma
    'comma-spacing': ['error', { before: false, after: true }],

    // enforce one true comma style
    'comma-style': ['error', 'last'],

    // enforce newline at the end of file, with no multiple empty lines
    'eol-last': ['error', 'always'],

    // enforce spacing between functions and their invocations
    // http://eslint.org/docs/rules/func-call-spacing
    'func-call-spacing': ['error', 'never'],

    // this option sets a specific tab width for your code
    // http://eslint.org/docs/rules/indent
    indent: ['error', 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }],

    // enforces spacing between keys and values in object literal properties
    'key-spacing': ['error', { beforeColon: false, afterColon: true }],

    // require a space before & after certain keywords
    'keyword-spacing': ['error', {
      before: true,
      after: true,
      overrides: {
        return: { after: true },
        throw: { after: true },
        case: { after: true }
      }
    }],

    // disallow mixed 'LF' and 'CRLF' as linebreaks
    // http://eslint.org/docs/rules/linebreak-style
    'linebreak-style': ['error', 'unix'],

    // disallow Array constructors
    // http://eslint.org/docs/rules/no-array-constructor
    'no-array-constructor': ['error'],

    // disallow use of unary operators, ++ and --
    // http://eslint.org/docs/rules/no-plusplus
    'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],

    // disallow trailing whitespace at the end of lines
    'no-trailing-spaces': 'error',

    // specify whether double or single quotes should be used
    quotes: ['error', 'single', { avoidEscape: true }],

    // require semicolons at the end of statements
    // http://eslint.org/docs/rules/semi
    semi: ['error', 'always'],

    // require or disallow space before blocks
    'space-before-blocks': 'error'
  }
};
<commit_msg>require an empty line after variable declarations<commit_after>/**
 * eslint-config-ticketfly-base/stylistic-issues
 *
 * The rules here are this configuration's opinion of
 * rules listed under ESLint's "Stylistic Issues"
 * category: (http://eslint.org/docs/rules/#stylistic-issues)
 */
module.exports = {
  rules: {
    // enforce spacing inside single-line blocks
    // http://eslint.org/docs/rules/block-spacing
    'block-spacing': ['error', 'always'],

    // enforce one true brace style
    'brace-style': ['error', '1tbs', { allowSingleLine: true }],

    // require or disallow trailing commas
    'comma-dangle': ['error', 'never'],

    // enforce spacing before and after comma
    'comma-spacing': ['error', { before: false, after: true }],

    // enforce one true comma style
    'comma-style': ['error', 'last'],

    // enforce newline at the end of file, with no multiple empty lines
    'eol-last': ['error', 'always'],

    // enforce spacing between functions and their invocations
    // http://eslint.org/docs/rules/func-call-spacing
    'func-call-spacing': ['error', 'never'],

    // this option sets a specific tab width for your code
    // http://eslint.org/docs/rules/indent
    indent: ['error', 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }],

    // enforces spacing between keys and values in object literal properties
    'key-spacing': ['error', { beforeColon: false, afterColon: true }],

    // require a space before & after certain keywords
    'keyword-spacing': ['error', {
      before: true,
      after: true,
      overrides: {
        return: { after: true },
        throw: { after: true },
        case: { after: true }
      }
    }],

    // disallow mixed 'LF' and 'CRLF' as linebreaks
    // http://eslint.org/docs/rules/linebreak-style
    'linebreak-style': ['error', 'unix'],

    // require an empty line after variable declarations
    // http://eslint.org/docs/rules/newline-after-var
    'newline-after-var': ['error', 'always'],

    // disallow Array constructors
    // http://eslint.org/docs/rules/no-array-constructor
    'no-array-constructor': ['error'],

    // disallow use of unary operators, ++ and --
    // http://eslint.org/docs/rules/no-plusplus
    'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],

    // disallow trailing whitespace at the end of lines
    'no-trailing-spaces': 'error',

    // specify whether double or single quotes should be used
    quotes: ['error', 'single', { avoidEscape: true }],

    // require semicolons at the end of statements
    // http://eslint.org/docs/rules/semi
    semi: ['error', 'always'],

    // require or disallow space before blocks
    'space-before-blocks': 'error'
  }
};
<|endoftext|>


<commit_before>import React, {Component} from 'react';

import List from 'src/List';
import Widget from 'src/Widget';
import WidgetHeader from 'src/WidgetHeader';
import Paper from 'src/Paper';

import PropTypeDescTable from '../PropTypeDescTable';
import ListDoc from 'assets/propTypes/List.json';

import 'sass/containers/app/modules/layout/ListExamples.scss';

export default class ListExamples extends Component {

    constructor(props) {

        super(props);

        this.listData = [{
            iconCls: 'fa fa-facebook',
            value: 'Facebook',
            text: 'Facebook'
        }, {
            iconCls: 'fa fa-twitter',
            value: 'Twitter',
            text: 'Twitter'
        }, {
            iconCls: 'fa fa-google-plus',
            value: 'Google+',
            text: 'Google+'
        }];

        this.disabledListData = [{
            iconCls: 'fa fa-firefox',
            value: 'Firefox',
            text: 'Firefox',
            disabled: true
        }, {
            iconCls: 'fa fa-chrome',
            value: 'Chrome',
            text: 'Chrome'
        }, {
            iconCls: 'fa fa-safari',
            value: 'Safari',
            text: 'Safari',
            disabled: true
        }];

        this.themeListData = [{
            value: 'Success',
            text: 'Success',
            theme: 'success',
            rightIconCls: 'fa fa-check-circle'
        }, {
            value: 'Error',
            text: 'Error',
            theme: 'error',
            rightIconCls: 'fa fa-times-circle-o'
        }, {
            value: 'Warning',
            text: 'Warning',
            theme: 'warning',
            rightIconCls: 'fa fa-exclamation-triangle'
        }, {
            value: 'Primary',
            text: 'Primary',
            theme: 'primary',
            rightIconCls: 'fa fa-gratipay'
        }];

        this.descListData = [{
            iconCls: 'fa fa-facebook',
            value: 'Facebook',
            text: 'Facebook',
            desc: 'Here is a Facebook Desc.'
        }, {
            iconCls: 'fa fa-twitter',
            value: 'Twitter',
            text: 'Twitter',
            desc: 'Here is a Twitter Desc.'
        }, {
            iconCls: 'fa fa-google-plus',
            value: 'Google+',
            text: 'Google+',
            desc: 'Here is a Google+ Desc.'
        }];

    }

    changeHandler(value, index) {
        console.log('change::', value);
    }

    itemSelectHandler(value, index) {
        console.log('select::', value);
    }

    itemDeselectHandler(value, index) {
        console.log('deselect::', value);
    }

    render() {
        return (

List

                    List are used to present multiple items vertically as a single continuous
                    element. They can be configured for many uses such as a contacts list, nested lists, etc.

Examples

                <Widget>

                    <WidgetHeader className="example-header" title="Basic"/>

A List simple example with left icons.

                                <Paper>
                                    <List data={this.listData}/>
                                </Paper>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header" title="With disabled"/>

Set the disabled property to true for disabled items.

                                <Paper>
                                    <List data={this.disabledListData}/>
                                </Paper>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header" title="With theme and rightIconCls"/>

Set the theme property to "success","error","warning","primary" and set
                                    the rightIconCls property to get rightIcons.

                                <Paper>
                                    <List data={this.themeListData}/>
                                </Paper>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header" title="With desc"/>

                                    A List with desc.

                                <Paper style={{width: 240}}>
                                    <List style={{width: 240}}
                                          data={this.descListData}/>
                                </Paper>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header" title="With mode"/>

                                    A List with select mode.Can be normal,radio,checkbox.

                                <Paper style={{width: 240}}>
                                    <List style={{width: 240}}
                                          selectMode={List.SelectMode.MULTI_SELECT}
                                          data={this.descListData}
                                          onChange={this.changeHandler}
                                          onItemSelect={this.itemSelectHandler}
                                          onItemDeselect={this.itemDeselectHandler}/>
                                </Paper>

                </Widget>

Properties

                <PropTypeDescTable data={ListDoc}/>

        );
    }
};<commit_msg>update List examples<commit_after>import React, {Component} from 'react';

import List from 'src/List';
import Widget from 'src/Widget';
import WidgetHeader from 'src/WidgetHeader';
import Paper from 'src/Paper';

import PropTypeDescTable from '../PropTypeDescTable';
import ListDoc from 'assets/propTypes/List.json';

import 'sass/containers/app/modules/layout/ListExamples.scss';

export default class ListExamples extends Component {

    constructor(props) {

        super(props);

        this.listData = [{
            iconCls: 'fa fa-facebook',
            value: 'Facebook',
            text: 'Facebook'
        }, {
            iconCls: 'fa fa-twitter',
            value: 'Twitter',
            text: 'Twitter'
        }, {
            iconCls: 'fa fa-google-plus',
            value: 'Google+',
            text: 'Google+'
        }];

        this.disabledListData = [{
            iconCls: 'fa fa-firefox',
            value: 'Firefox',
            text: 'Firefox',
            disabled: true
        }, {
            iconCls: 'fa fa-chrome',
            value: 'Chrome',
            text: 'Chrome'
        }, {
            iconCls: 'fa fa-safari',
            value: 'Safari',
            text: 'Safari',
            disabled: true
        }];

        this.themeListData = [{
            value: 'Success',
            text: 'Success',
            theme: 'success',
            rightIconCls: 'fa fa-check-circle'
        }, {
            value: 'Error',
            text: 'Error',
            theme: 'error',
            rightIconCls: 'fa fa-times-circle-o'
        }, {
            value: 'Warning',
            text: 'Warning',
            theme: 'warning',
            rightIconCls: 'fa fa-exclamation-triangle'
        }, {
            value: 'Primary',
            text: 'Primary',
            theme: 'primary',
            rightIconCls: 'fa fa-gratipay'
        }];

        this.descListData = [{
            iconCls: 'fa fa-facebook',
            value: 'Facebook',
            text: 'Facebook',
            desc: 'Here is a Facebook Desc.'
        }, {
            iconCls: 'fa fa-twitter',
            value: 'Twitter',
            text: 'Twitter',
            desc: 'Here is a Twitter Desc.'
        }, {
            iconCls: 'fa fa-google-plus',
            value: 'Google+',
            text: 'Google+',
            desc: 'Here is a Google+ Desc.'
        }];

    }

    changeHandler(value, index) {
        console.log('change::', value);
    }

    itemSelectHandler(value, index) {
        console.log('select::', value);
    }

    itemDeselectHandler(value, index) {
        console.log('deselect::', value);
    }

    render() {
        return (

List

                    List are used to present multiple items vertically as a single continuous
                    element. They can be configured for many uses such as a contacts list, nested lists, etc.

Examples

                <Widget>

                    <WidgetHeader className="example-header" title="Basic"/>

A List simple example with left icons.

                                <Paper>
                                    <List data={this.listData}/>
                                </Paper>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header" title="With disabled"/>

Set the disabled property to true for disabled items.

                                <Paper>
                                    <List data={this.disabledListData}/>
                                </Paper>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header" title="With theme and rightIconCls"/>

Set the theme property to "success","error","warning","primary" and set
                                    the rightIconCls property to get rightIcons.

                                <Paper>
                                    <List data={this.themeListData}/>
                                </Paper>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header" title="With desc"/>

                                    A List with desc.

                                <Paper style={{width: 240}}>
                                    <List style={{width: 240}}
                                          data={this.descListData}/>
                                </Paper>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header" title="With Select Mode"/>

                                    A List with select mode.Can be NOMAL
                                    , SINGLE_SELECT, MULTI_SELECT.

                                <Paper style={{width: 240}}>
                                    <List style={{width: 240}}
                                          selectMode={List.SelectMode.SINGLE_SELECT}
                                          data={this.descListData}
                                          onChange={this.changeHandler}
                                          onItemSelect={this.itemSelectHandler}
                                          onItemDeselect={this.itemDeselectHandler}/>
                                </Paper>

                                <Paper style={{width: 240, marginTop: 20}}>
                                    <List style={{width: 240}}
                                          selectMode={List.SelectMode.MULTI_SELECT}
                                          data={this.descListData}
                                          onChange={this.changeHandler}
                                          onItemSelect={this.itemSelectHandler}
                                          onItemDeselect={this.itemDeselectHandler}/>
                                </Paper>

                </Widget>

Properties

                <PropTypeDescTable data={ListDoc}/>

        );
    }
};<|endoftext|>


<commit_before>'use strict';

test('create', function (test) {
  var instances = [
      int17.create()
    , int17.create('foo')
    , int17.create('bar')
    , int17.create('foo')
    , int17.create()
  ];
  helpers.strictEqualOnly(test, 0, [],  instances, 'Non-cached instance was not unique');
  helpers.strictEqualOnly(test, 1, [3], instances, 'Cached instance was unique');
  helpers.strictEqualOnly(test, 2, [],  instances, 'Cached instance was not unique');
  helpers.strictEqualOnly(test, 4, [],  instances, 'Non-cached instance was not unique');
  int17.clearCache();
  test.notStrictEqual(int17.create('foo'), instances[1], 'Cache was not cleared');
});

asyncTest('init:async', 11, function (test) {
  var inst = int17.create()
    , opts = {
          encoding:  'UTF-8'
        , extension: '.js'
        , fallback:  false
        , fileName:  'msgs'
        , folders:   true
        , locale:    ['fr', 'BE']
        , optimize:  false
        , path:      '../fixtures/locales3'
        , validate:  false
      };
  inst.init(opts, function (err, messages) {
    test.ok(!err, 'Error was thrown');
    test.ok(messages, 'No messages were loaded');
    helpers.strictContains(test, inst.messenger, opts, 'Options were not set correctly');
    start();
  });
});

test('init:sync', function (test) {
  var inst = int17.create()
    , opts = {
          encoding:  'UTF-8'
        , extension: '.js'
        , fallback:  false
        , fileName:  'msgs'
        , folders:   true
        , locale:    ['fr', 'BE']
        , optimize:  false
        , path:      '../fixtures/locales3'
        , validate:  false
      };
  inst.initSync(opts);
  test.ok(inst.messenger.messages, 'No messages were loaded');
  helpers.strictContains(test, inst.messenger, opts, 'Options were not set correctly');
});

// TODO: Complete test cases
<commit_msg>added qunit tests for languages<commit_after>'use strict';

test('create', function (test) {
  var instances = [
      int17.create()
    , int17.create('foo')
    , int17.create('bar')
    , int17.create('foo')
    , int17.create()
  ];
  helpers.strictEqualOnly(test, 0, [],  instances, 'Non-cached instance was not unique');
  helpers.strictEqualOnly(test, 1, [3], instances, 'Cached instance was unique');
  helpers.strictEqualOnly(test, 2, [],  instances, 'Cached instance was not unique');
  helpers.strictEqualOnly(test, 4, [],  instances, 'Non-cached instance was not unique');
  int17.clearCache();
  test.notStrictEqual(int17.create('foo'), instances[1], 'Cache was not cleared');
});

asyncTest('init:async', 11, function (test) {
  var inst = int17.create()
    , opts = {
          encoding:  'UTF-8'
        , extension: '.js'
        , fallback:  false
        , fileName:  'msgs'
        , folders:   true
        , locale:    ['fr', 'BE']
        , optimize:  false
        , path:      '../fixtures/locales3'
        , validate:  false
      };
  inst.init(opts, function (err, messages) {
    test.ok(!err, 'Error was thrown');
    test.ok(messages, 'No messages were loaded');
    helpers.strictContains(test, inst.messenger, opts, 'Options were not set correctly');
    start();
  });
});

test('init:sync', function (test) {
  var inst = int17.create()
    , opts = {
          encoding:  'UTF-8'
        , extension: '.js'
        , fallback:  false
        , fileName:  'msgs'
        , folders:   true
        , locale:    ['fr', 'BE']
        , optimize:  false
        , path:      '../fixtures/locales3'
        , validate:  false
      };
  inst.initSync(opts);
  test.ok(inst.messenger.messages, 'No messages were loaded');
  helpers.strictContains(test, inst.messenger, opts, 'Options were not set correctly');
});

asyncTest('languages:async', 3, function (test) {
  var inst  = int17.create()
    , langs = ['en-GB'];
  inst.init({ path: '../fixtures/locales1' }, function (err) {
    test.ok(!err, 'Error was thrown');
    inst.languages(function (err, languages) {
      test.ok(!err, 'Error was thrown');
      test.deepEqual(languages, langs, 'Not all languages were detected');
      start();
    });
  });
});

asyncTest('languages:async:folders', 3, function (test) {
  var inst  = int17.create()
    , langs = ['de'];
  inst.init({ folders: true, locale: 'de', path: '../fixtures/locales2' }, function (err) {
    test.ok(!err, 'Error was thrown');
    inst.languages(function (err, languages) {
      test.ok(!err, 'Error was thrown');
      test.deepEqual(languages, langs, 'Not all languages were detected');
      start();
    });
  });
});

asyncTest('languages:async:manual', 3, function (test) {
  var inst  = int17.create()
    , langs = ['ar-EG', 'zh-CN'];
  inst.init({ languages: langs, path: '../fixtures/locales1' }, function (err) {
    test.ok(!err, 'Error was thrown');
    inst.languages(function (err, languages) {
      test.ok(!err, 'Error was thrown');
      test.deepEqual(languages, langs, 'Configured languages should have been used');
      start();
    });
  });
});

asyncTest('languages:async:manual:folders', 3, function (test) {
  var inst  = int17.create()
    , langs = ['ar-EG', 'zh-CN'];
  inst.init({
      folders:   true
    , languages: langs
    , locale:    'de'
    , path:      '../fixtures/locales2'
  }, function (err) {
    test.ok(!err, 'Error was thrown');
    inst.languages(function (err, languages) {
      test.ok(!err, 'Error was thrown');
      test.deepEqual(languages, langs, 'Configured languages should have been used');
      start();
    });
  });
});

asyncTest('languages:async:manual:folders:parent', 7, function (test) {
  var inst  = int17.create()
    , langs = ['de-AT', 'de-CH'];
  inst.init({
      folders:   true
    , languages: ['de'].concat(langs)
    , locale:    'de'
    , path:      '../fixtures/locales2'
  }, function (err) {
    test.ok(!err, 'Error was thrown');
    inst.languages('de', function (err, languages) {
      test.ok(!err, 'Error was thrown');
      test.deepEqual(languages, langs, 'Extended languages should be retrieved');
      inst.languages('de-AT', function (err, languages) {
        test.ok(!err, 'Error was thrown');
        test.deepEqual(languages, [], 'No languages should be retrieved');
        inst.languages('en', function (err, languages) {
          test.ok(!err, 'Error was thrown');
          test.deepEqual(languages, [], 'No languages should be retrieved');
          start();
        });
      });
    });
  });
});

asyncTest('languages:async:parent', 7, function (test) {
  var inst  = int17.create()
    , langs = ['en-GB'];
  inst.init({ path: '../fixtures/locales1' }, function (err) {
    test.ok(!err, 'Error was thrown');
    inst.languages('en', function (err, languages) {
      test.ok(!err, 'Error was thrown');
      test.deepEqual(languages, langs, 'Extended languages should be retrieved');
      inst.languages('en-GB', function (err, languages) {
        test.ok(!err, 'Error was thrown');
        test.deepEqual(languages, [], 'No languages should be retrieved');
        inst.languages('de', function (err, languages) {
          test.ok(!err, 'Error was thrown');
          test.deepEqual(languages, [], 'No languages should be retrieved');
          start();
        });
      });
    });
  });
});

asyncTest('languages:async:parent:folders', 7, function (test) {
  var inst = int17.create();
  inst.init({ folders: true, locale: 'de', path: '../fixtures/locales2' }, function (err) {
    test.ok(!err, 'Error was thrown');
    inst.languages('de', function (err, languages) {
      test.ok(!err, 'Error was thrown');
      test.deepEqual(languages, [], 'No languages should be retrieved');
      inst.languages('de-AT', function (err, languages) {
        test.ok(!err, 'Error was thrown');
        test.deepEqual(languages, [], 'No languages should be retrieved');
        inst.languages('en', function (err, languages) {
          test.ok(!err, 'Error was thrown');
          test.deepEqual(languages, [], 'No languages should be retrieved');
          start();
        });
      });
    });
  });
});

test('languages:sync', function (test) {
  var inst  = int17.create()
    , langs = ['en-GB'];
  inst.initSync({ path: '../fixtures/locales1' });
  test.deepEqual(inst.languagesSync(), langs, 'Not all languages were detected');
});

test('languages:sync:folders', function (test) {
  var inst  = int17.create()
    , langs = ['de'];
  inst.initSync({ folders: true, locale: 'de', path: '../fixtures/locales2' });
  test.deepEqual(inst.languagesSync(), langs, 'Not all languages were detected');
});

test('languages:sync:manual', function (test) {
  var inst  = int17.create()
    , langs = ['ar-EG', 'zh-CN'];
  inst.initSync({ languages: langs, path: '../fixtures/locales1' });
  test.deepEqual(inst.languagesSync(), langs, 'Configured languages should have been used');
});

test('languages:sync:manual:folders', function (test) {
  var inst  = int17.create()
    , langs = ['ar-EG', 'zh-CN'];
  inst.initSync({
      folders:   true
    , languages: langs
    , locale:    'de'
    , path:      '../fixtures/locales2'
  });
  test.deepEqual(inst.languagesSync(), langs, 'Configured languages should have been used');
});

test('languages:sync:manual:folders:parent', function (test) {
  var inst  = int17.create()
    , langs = ['de-AT', 'de-CH'];
  inst.initSync({
      folders:   true
    , languages: ['de'].concat(langs)
    , locale:    'de'
    , path:      '../fixtures/locales2'
  });
  test.deepEqual(inst.languagesSync('de'), langs, 'Extended languages should be retrieved');
  test.deepEqual(inst.languagesSync('de-AT'), [], 'No languages should be retrieved');
  test.deepEqual(inst.languagesSync('en'), [], 'No languages should be retrieved');
});

test('languages:sync:parent', function (test) {
  var inst  = int17.create()
    , langs = ['en-GB'];
  inst.initSync({ path: '../fixtures/locales1' });
  test.deepEqual(inst.languagesSync('en'), langs, 'Extended languages should be retrieved');
  test.deepEqual(inst.languagesSync('en-GB'), [], 'No languages should be retrieved');
  test.deepEqual(inst.languagesSync('de'), [], 'No languages should be retrieved');
});

test('languages:sync:parent:folders', function (test) {
  var inst = int17.create();
  inst.initSync({ folders: true, locale: 'de', path: '../fixtures/locales2' });
  test.deepEqual(inst.languagesSync('de'), [], 'No languages should be retrieved');
  test.deepEqual(inst.languagesSync('de-AT'), [], 'No languages should be retrieved');
  test.deepEqual(inst.languagesSync('en'), [], 'No languages should be retrieved');
});

// TODO: Complete test cases
<|endoftext|>


<commit_before>(function () {
    'use strict';

    angular.module('components')
            .directive('scientillaMenu', scientillaMenu);

    function scientillaMenu() {
        return {
            restrict: 'E',
            templateUrl: 'partials/scientillaMenu.html',
            controller: scientillaMenuController,
            controllerAs: 'vm',
            scope: {
            }
        };
    }

    function scientillaMenuController($scope, AuthService) {
        var vm = this;

        vm.menuItemClicked = menuItemClicked;
        $scope.$on('LOGIN', refresh);
        $scope.$on('LOGOUT', refresh);

        function refresh() {
            vm.isLogged = AuthService.isLogged;
            vm.user = AuthService.user;

            if (vm.user) {
                vm.menuItems = [{
                        type: 'item',
                        title: 'Notifications',
                        url: '#/users/' + vm.user.id + '/notifications'
                    },
                    {
                        type: 'separator'
                    },
                    {
                        type: 'item',
                        title: 'Personal documents',
                        url: '#/users/' + vm.user.id + '/references'
                    }
                ];
                _.forEach(vm.user.admininstratedGroups, function (g) {
                    vm.menuItems.push({
                        type: 'item',
                        title: g.getDisplayName() + ' Documents',
                        url: '#/groups/' + g.id + '/references'
                    });
                });
                vm.menuItems = _.union(vm.menuItems, [{
                        type: 'separator'
                    },{
                        type: 'item',
                        title: 'People',
                        url: '#/users'
                    },{
                        type: 'item',
                        title: 'Groups',
                        url: '#/groups'
                    },{
                        type: 'item',
                        title: 'Profile',
                        url: '#/users/' + vm.user.id + '/edit'
                    }]);
            }
        }

        function menuItemClicked(item) {
            _.each(vm.menuItems, function(i) {
               i.active = false;
            });
            item.active = true;
        }
    }

})();<commit_msg>Removed profile element from the menu.<commit_after>(function () {
    'use strict';

    angular.module('components')
            .directive('scientillaMenu', scientillaMenu);

    function scientillaMenu() {
        return {
            restrict: 'E',
            templateUrl: 'partials/scientillaMenu.html',
            controller: scientillaMenuController,
            controllerAs: 'vm',
            scope: {
            }
        };
    }

    function scientillaMenuController($scope, AuthService) {
        var vm = this;

        vm.menuItemClicked = menuItemClicked;
        $scope.$on('LOGIN', refresh);
        $scope.$on('LOGOUT', refresh);

        function refresh() {
            vm.isLogged = AuthService.isLogged;
            vm.user = AuthService.user;

            if (vm.user) {
                vm.menuItems = [{
                        type: 'item',
                        title: 'Notifications',
                        url: '#/users/' + vm.user.id + '/notifications'
                    },
                    {
                        type: 'separator'
                    },
                    {
                        type: 'item',
                        title: 'Personal documents',
                        url: '#/users/' + vm.user.id + '/references'
                    }
                ];
                _.forEach(vm.user.admininstratedGroups, function (g) {
                    vm.menuItems.push({
                        type: 'item',
                        title: g.getDisplayName() + ' Documents',
                        url: '#/groups/' + g.id + '/references'
                    });
                });
                vm.menuItems = _.union(vm.menuItems, [{
                        type: 'separator'
                    },{
                        type: 'item',
                        title: 'People',
                        url: '#/users'
                    },{
                        type: 'item',
                        title: 'Groups',
                        url: '#/groups'
                    }]);
            }
        }

        function menuItemClicked(item) {
            _.each(vm.menuItems, function(i) {
               i.active = false;
            });
            item.active = true;
        }
    }

})();<|endoftext|>


<commit_before>import React from 'react';

import { storiesOf } from '@storybook/react';
import { setOptions } from '@storybook/addon-options';
import { action } from '@storybook/addon-actions';
import { withNotes } from '@storybook/addon-notes';
import centered from '@storybook/addon-centered';
import { withInfo } from '@storybook/addon-info';
import { Button } from '@storybook/react/demo';

// eslint-disable-next-line import/extensions,import/no-unresolved
import App from 'App';
import Container from './Container';
import LifecycleLogger from '../components/LifecycleLogger';

const InfoButton = () => (

    {' '}
    Show Info{' '}

);

storiesOf('Button', module)
  .addDecorator(withNotes)
  .add('with text', () => (
    <Button onClick={action('clicked')}>
      {setOptions({ selectedAddonPanel: 'storybook/actions/actions-panel' })}
      Hello Button
    </Button>
  ))
  .add('with some emoji', () => (
    <Button onClick={action('clicked')}>
      {setOptions({ selectedAddonPanel: 'storybook/actions/actions-panel' })}

        😀 😎 👍 💯

    </Button>
  ))
  .add(
    'with notes',
    () => (
      <Button>
        {setOptions({ selectedAddonPanel: 'storybook/notes/panel' })}
        Check my notes in the notes panel
      </Button>
    ),
    { notes: 'A very simple button' }
  )
  .add(
    'with new info',
    withInfo(
      'Use the [info addon](https://github.com/storybooks/storybook/tree/master/addons/info) with its new painless API.'
    )(context => (
      <Container>
        {setOptions({ selectedAddonPanel: 'storybook/info/info-panel' })}
        click the <InfoButton /> label in top right for info about "{context.story}"
      </Container>
    ))
  )
  .add(
    'addons composition',
    withInfo('see Notes panel for composition info')(
      withNotes('Composition: Info(Notes())')(context => (

          {setOptions({ selectedAddonPanel: 'storybook/notes/panel' })}
          click the <InfoButton /> label in top right for info about "{context.story}"

      ))
    )
  );

storiesOf('App', module).add('full app', () => <App />);

storiesOf('Some really long story kind description', module)
  .addDecorator(centered)
  .add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>);

storiesOf('Lifecycle', module).add('logging', () => <LifecycleLogger />);
<commit_msg>Fix failing snapshot test<commit_after>import React from 'react';

import { storiesOf } from '@storybook/react';
import { setOptions } from '@storybook/addon-options';
import { action } from '@storybook/addon-actions';
import { withNotes } from '@storybook/addon-notes';
import centered from '@storybook/addon-centered';
import { withInfo } from '@storybook/addon-info';
import { Button } from '@storybook/react/demo';

import App from '../App';
import Container from './Container';
import LifecycleLogger from '../components/LifecycleLogger';

const InfoButton = () => (

    {' '}
    Show Info{' '}

);

storiesOf('Button', module)
  .addDecorator(withNotes)
  .add('with text', () => (
    <Button onClick={action('clicked')}>
      {setOptions({ selectedAddonPanel: 'storybook/actions/actions-panel' })}
      Hello Button
    </Button>
  ))
  .add('with some emoji', () => (
    <Button onClick={action('clicked')}>
      {setOptions({ selectedAddonPanel: 'storybook/actions/actions-panel' })}

        😀 😎 👍 💯

    </Button>
  ))
  .add(
    'with notes',
    () => (
      <Button>
        {setOptions({ selectedAddonPanel: 'storybook/notes/panel' })}
        Check my notes in the notes panel
      </Button>
    ),
    { notes: 'A very simple button' }
  )
  .add(
    'with new info',
    withInfo(
      'Use the [info addon](https://github.com/storybooks/storybook/tree/master/addons/info) with its new painless API.'
    )(context => (
      <Container>
        {setOptions({ selectedAddonPanel: 'storybook/info/info-panel' })}
        click the <InfoButton /> label in top right for info about "{context.story}"
      </Container>
    ))
  )
  .add(
    'addons composition',
    withInfo('see Notes panel for composition info')(
      withNotes('Composition: Info(Notes())')(context => (

          {setOptions({ selectedAddonPanel: 'storybook/notes/panel' })}
          click the <InfoButton /> label in top right for info about "{context.story}"

      ))
    )
  );

storiesOf('App', module).add('full app', () => <App />);

storiesOf('Some really long story kind description', module)
  .addDecorator(centered)
  .add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>);

storiesOf('Lifecycle', module).add('logging', () => <LifecycleLogger />);
<|endoftext|>