<commit_before>/* 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.
 */
'use strict';

var FLOWABLE = FLOWABLE || {};
FLOWABLE.PROPERTY_CONFIG =
{
    "string": {
        "templateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/string-property-write-mode-template.html"
    },
    "boolean": {
        "templateUrl": "editor-app/configuration/properties/boolean-property-template.html"
    },
    "text" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/text-property-write-template.html"
    },
    "flowable-calledelementtype" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/calledelementtype-property-write-template.html"
    },
    "flowable-multiinstance" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/multiinstance-property-write-template.html"
    },
    "flowable-processhistorylevel" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/process-historylevel-property-write-template.html"
    },
    "flowable-ordering" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/ordering-property-write-template.html"
    },
    "oryx-dataproperties-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/data-properties-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/data-properties-write-template.html"
    },
    "oryx-formproperties-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/form-properties-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/form-properties-write-template.html"
    },
    "oryx-executionlisteners-multiplecomplex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/execution-listeners-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/execution-listeners-write-template.html"
    },
    "oryx-tasklisteners-multiplecomplex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/task-listeners-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/task-listeners-write-template.html"
    },
    "oryx-eventlisteners-multiplecomplex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/event-listeners-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/event-listeners-write-template.html"
    },
    "oryx-usertaskassignment-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/assignment-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/assignment-write-template.html"
    },
    "oryx-servicetaskfields-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/fields-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/fields-write-template.html"
    },
    "oryx-servicetaskexceptions-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/exceptions-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/exceptions-write-template.html"
    },
    "oryx-callactivityinparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/in-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/in-parameters-write-template.html"
    },
    "oryx-callactivityoutparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/out-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/out-parameters-write-template.html"
    },
    "oryx-subprocessreference-subprocess-link": {
        "readModeTemplateUrl": "editor-app/configuration/properties/subprocess-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/subprocess-reference-write-template.html"
    },
    "oryx-formreference-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/form-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/form-reference-write-template.html"
    },
    "oryx-sequencefloworder-complex" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/sequenceflow-order-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/sequenceflow-order-write-template.html"
    },
    "oryx-conditionsequenceflow-complex" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/condition-expression-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/condition-expression-write-template.html"
    },
    "oryx-signaldefinitions-multiplecomplex" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/signal-definitions-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/signal-definitions-write-template.html"
    },
    "oryx-signalref-string" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/signal-property-write-template.html"
    },
    "oryx-messagedefinitions-multiplecomplex" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/message-definitions-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/message-definitions-write-template.html"
    },
    "oryx-messageref-string" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/message-property-write-template.html"
    },
    "oryx-escalationdefinitions-multiplecomplex" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/escalation-definitions-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/escalation-definitions-write-template.html"
    },
    "oryx-escalationref-string" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/escalation-property-write-template.html"
    },
    "oryx-duedatedefinition-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/duedate-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/duedate-write-template.html"
    },
    "oryx-decisiontaskdecisiontablereference-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/decisiontable-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/decisiontable-reference-write-template.html"
    },
    "oryx-decisiontaskdecisionservicereference-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/decisionservice-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/decisionservice-reference-write-template.html"
    },
    "oryx-decisiondecisiontablereference-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/decisiontable-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/decisiontable-reference-write-template.html"
    },
    "oryx-casetaskcasereference-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/case-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/case-reference-write-template.html"
    },
    "oryx-processtaskprocessreference-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/process-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/process-reference-write-template.html"
    },
    "oryx-processtaskinparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/in-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/in-parameters-write-template.html"
    },
    "oryx-processtaskoutparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/out-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/out-parameters-write-template.html"
    },
    "oryx-casetaskinparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/in-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/in-parameters-write-template.html"
    },
    "oryx-casetaskoutparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/out-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/out-parameters-write-template.html"
    },
    "oryx-planitemlifecyclelisteners-multiplecomplex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/plan-item-lifecycle-listeners-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/plan-item-lifecycle-listeners-write-template.html"
     },
    "flowable-transitionevent" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/transition-event-write-template.html"
    },
    "flowable-planitem-dropdown" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/planitem-dropdown-read-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/planitem-dropdown-write-template.html"
    },
    "flowable-http-request-method" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/http-request-method-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/http-request-method-property-write-template.html"
    },
    "flowable-triggermode" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/trigger-mode-read-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/trigger-mode-write-template.html"
    },
    "oryx-eventinparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/event-in-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/event-in-parameters-write-template.html"
    },
    "oryx-eventoutparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/event-out-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/event-out-parameters-write-template.html"
    },
    "oryx-eventcorrelationparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/event-correlation-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/event-correlation-parameters-write-template.html"
    },
    "flowable-channeltype" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/event-channel-type-property-write-template.html"
    }
};
<commit_msg>Fixing read and write mode template URL to correctly render the checkboxes in modeler (#2662)<commit_after>/* 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.
 */
'use strict';

var FLOWABLE = FLOWABLE || {};
FLOWABLE.PROPERTY_CONFIG =
{
    "string": {
        "templateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/string-property-write-mode-template.html"
    },
    "boolean": {
        "readModeTemplateUrl": "editor-app/configuration/properties/boolean-property-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/boolean-property-template.html"
    },
    "text" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/text-property-write-template.html"
    },
    "flowable-calledelementtype" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/calledelementtype-property-write-template.html"
    },
    "flowable-multiinstance" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/multiinstance-property-write-template.html"
    },
    "flowable-processhistorylevel" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/process-historylevel-property-write-template.html"
    },
    "flowable-ordering" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/ordering-property-write-template.html"
    },
    "oryx-dataproperties-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/data-properties-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/data-properties-write-template.html"
    },
    "oryx-formproperties-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/form-properties-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/form-properties-write-template.html"
    },
    "oryx-executionlisteners-multiplecomplex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/execution-listeners-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/execution-listeners-write-template.html"
    },
    "oryx-tasklisteners-multiplecomplex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/task-listeners-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/task-listeners-write-template.html"
    },
    "oryx-eventlisteners-multiplecomplex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/event-listeners-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/event-listeners-write-template.html"
    },
    "oryx-usertaskassignment-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/assignment-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/assignment-write-template.html"
    },
    "oryx-servicetaskfields-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/fields-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/fields-write-template.html"
    },
    "oryx-servicetaskexceptions-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/exceptions-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/exceptions-write-template.html"
    },
    "oryx-callactivityinparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/in-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/in-parameters-write-template.html"
    },
    "oryx-callactivityoutparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/out-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/out-parameters-write-template.html"
    },
    "oryx-subprocessreference-subprocess-link": {
        "readModeTemplateUrl": "editor-app/configuration/properties/subprocess-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/subprocess-reference-write-template.html"
    },
    "oryx-formreference-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/form-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/form-reference-write-template.html"
    },
    "oryx-sequencefloworder-complex" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/sequenceflow-order-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/sequenceflow-order-write-template.html"
    },
    "oryx-conditionsequenceflow-complex" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/condition-expression-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/condition-expression-write-template.html"
    },
    "oryx-signaldefinitions-multiplecomplex" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/signal-definitions-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/signal-definitions-write-template.html"
    },
    "oryx-signalref-string" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/signal-property-write-template.html"
    },
    "oryx-messagedefinitions-multiplecomplex" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/message-definitions-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/message-definitions-write-template.html"
    },
    "oryx-messageref-string" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/message-property-write-template.html"
    },
    "oryx-escalationdefinitions-multiplecomplex" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/escalation-definitions-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/escalation-definitions-write-template.html"
    },
    "oryx-escalationref-string" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/escalation-property-write-template.html"
    },
    "oryx-duedatedefinition-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/duedate-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/duedate-write-template.html"
    },
    "oryx-decisiontaskdecisiontablereference-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/decisiontable-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/decisiontable-reference-write-template.html"
    },
    "oryx-decisiontaskdecisionservicereference-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/decisionservice-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/decisionservice-reference-write-template.html"
    },
    "oryx-decisiondecisiontablereference-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/decisiontable-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/decisiontable-reference-write-template.html"
    },
    "oryx-casetaskcasereference-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/case-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/case-reference-write-template.html"
    },
    "oryx-processtaskprocessreference-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/process-reference-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/process-reference-write-template.html"
    },
    "oryx-processtaskinparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/in-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/in-parameters-write-template.html"
    },
    "oryx-processtaskoutparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/out-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/out-parameters-write-template.html"
    },
    "oryx-casetaskinparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/in-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/in-parameters-write-template.html"
    },
    "oryx-casetaskoutparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/out-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/out-parameters-write-template.html"
    },
    "oryx-planitemlifecyclelisteners-multiplecomplex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/plan-item-lifecycle-listeners-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/plan-item-lifecycle-listeners-write-template.html"
     },
    "flowable-transitionevent" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/transition-event-write-template.html"
    },
    "flowable-planitem-dropdown" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/planitem-dropdown-read-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/planitem-dropdown-write-template.html"
    },
    "flowable-http-request-method" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/http-request-method-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/http-request-method-property-write-template.html"
    },
    "flowable-triggermode" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/trigger-mode-read-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/trigger-mode-write-template.html"
    },
    "oryx-eventinparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/event-in-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/event-in-parameters-write-template.html"
    },
    "oryx-eventoutparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/event-out-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/event-out-parameters-write-template.html"
    },
    "oryx-eventcorrelationparameters-complex": {
        "readModeTemplateUrl": "editor-app/configuration/properties/event-correlation-parameters-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/event-correlation-parameters-write-template.html"
    },
    "flowable-channeltype" : {
        "readModeTemplateUrl": "editor-app/configuration/properties/default-value-display-template.html",
        "writeModeTemplateUrl": "editor-app/configuration/properties/event-channel-type-property-write-template.html"
    }
};
<|endoftext|>


<commit_before>const electron = require('electron');
const AutoLaunch = require('auto-launch');
const contribution = require('contribution');

const log = require('./logger');
const icon = require('./icon');
const pjson = require('../package.json');
const store = require('./store');

const { app, BrowserWindow, Tray, Menu, shell, ipcMain } = electron;

app.on('ready', () => {
  const streakerAutoLauncher = new AutoLaunch({
    name: pjson.name,
    path: `/Applications/${pjson.name}.app`
  });

  const tray = new Tray(icon.done);
  let usernameWindow = null;

  function createUsernameWindow() {
    if (usernameWindow) {
      usernameWindow.focus();
      return;
    }
    usernameWindow = new BrowserWindow({
      title: `${pjson.name} - Set GitHub Username`,
      frame: false,
      width: 270,
      height: 60,
      resizable: false,
      maximizable: false,
      show: false
    });
    usernameWindow.loadURL(`file://${__dirname}/username.html`);
    usernameWindow.once('ready-to-show', () => {
      const screen = electron.screen.getDisplayNearestPoint(
        electron.screen.getCursorScreenPoint()
      );
      usernameWindow.setPosition(
        Math.floor(
          screen.bounds.x +
            screen.size.width / 2 -
            usernameWindow.getSize()[0] / 2
        ),
        Math.floor(
          screen.bounds.y +
            screen.size.height / 2 -
            usernameWindow.getSize()[1] / 2
        )
      );
      usernameWindow.show();
    });
    usernameWindow.on('closed', () => {
      usernameWindow = null;
    });
    usernameWindow.on('blur', () => {
      usernameWindow.close();
    });
  }

  function createTrayMenu(contributionCount, currentStreak, bestStreak) {
    const username = store.get('username') || 'username not set';
    const githubProfileUrl = `https://github.com/${username}`;
    const menuTemplate = [
      { label: username, enabled: false },
      { type: 'separator' },
      { label: `Current Streak: ${currentStreak}`, enabled: false },
      { label: `Best Streak: ${bestStreak}`, enabled: false },
      { label: `Contributions: ${contributionCount}`, enabled: false },
      { type: 'separator' },
      { label: 'Reload', accelerator: 'Cmd+R', click: requestContributionData },
      {
        label: 'Open GitHub Profile...',
        accelerator: 'Cmd+O',
        click: () => shell.openExternal(githubProfileUrl)
      },
      { type: 'separator' },
      {
        label: 'Set GitHub Username...',
        accelerator: 'Cmd+S',
        click: createUsernameWindow
      },
      {
        label: 'Preferences',
        submenu: [
          {
            label: `Launch ${pjson.name} at login`,
            type: 'checkbox',
            checked: store.get('autoLaunch'),
            click: checkbox => {
              store.set('autoLaunch', checkbox.checked);
              if (checkbox.checked) {
                streakerAutoLauncher.enable();
              } else {
                streakerAutoLauncher.disable();
              }
              log.info(`Store updated - autoLaunch=${checkbox.checked}`);
            }
          }
        ]
      },
      { type: 'separator' },
      {
        label: `About ${pjson.name}...`,
        click: () => shell.openExternal(pjson.homepage)
      },
      {
        label: 'Feedback && Support...',
        click: () => shell.openExternal(pjson.bugs.url)
      },
      { type: 'separator' },
      {
        label: `Quit ${pjson.name}`,
        accelerator: 'Cmd+Q',
        click: () => app.quit()
      }
    ];
    return Menu.buildFromTemplate(menuTemplate);
  }

  function requestContributionData() {
    tray.setImage(icon.load);
    tray.setContextMenu(
      createTrayMenu('Loading...', 'Loading...', 'Loading...')
    );

    const username = store.get('username');

    contribution(username)
      .then(data => {
        tray.setContextMenu(
          createTrayMenu(
            data.contributions,
            data.currentStreak,
            data.bestStreak
          )
        );
        tray.setImage(data.currentStreak > 0 ? icon.done : icon.todo);
        log.info(
          `Request successful - username=${username} streak=${
            data.currentStreak
          } today=${data.contributions > 0}`
        );
      })
      .catch(error => {
        tray.setContextMenu(createTrayMenu('Error', 'Error', 'Error'));
        tray.setImage(icon.fail);
        log.error(
          `Request failed - username=${username}) statusCode=${
            error.statusCode
          }`
        );
      });
  }

  function setUsername(event, username) {
    usernameWindow.close();
    if (username && username !== store.get('username')) {
      store.set('username', username);
      requestContributionData();
      log.info(`Store updated - username=${username}`);
    }
  }

  process.on('uncaughtException', (error) => {
      tray.setContextMenu(createTrayMenu('Error', 'Error', 'Error'));
      tray.setImage(icon.fail);
      log.error(error);
  })

  if (process.platform === 'darwin') {
    app.dock.hide();
  }

  app.on('window-all-closed', () => {});
  tray.on('right-click', requestContributionData);
  ipcMain.on('setUsername', setUsername);

  requestContributionData();
  setInterval(requestContributionData, 1000 * 60 * 15); // 15 Minutes
});
<commit_msg>Remove path option because it's optional<commit_after>const electron = require('electron');
const AutoLaunch = require('auto-launch');
const contribution = require('contribution');

const log = require('./logger');
const icon = require('./icon');
const pjson = require('../package.json');
const store = require('./store');

const { app, BrowserWindow, Tray, Menu, shell, ipcMain } = electron;

app.on('ready', () => {
  const streakerAutoLauncher = new AutoLaunch({
    name: pjson.name
  });

  const tray = new Tray(icon.done);
  let usernameWindow = null;

  function createUsernameWindow() {
    if (usernameWindow) {
      usernameWindow.focus();
      return;
    }
    usernameWindow = new BrowserWindow({
      title: `${pjson.name} - Set GitHub Username`,
      frame: false,
      width: 270,
      height: 60,
      resizable: false,
      maximizable: false,
      show: false
    });
    usernameWindow.loadURL(`file://${__dirname}/username.html`);
    usernameWindow.once('ready-to-show', () => {
      const screen = electron.screen.getDisplayNearestPoint(
        electron.screen.getCursorScreenPoint()
      );
      usernameWindow.setPosition(
        Math.floor(
          screen.bounds.x +
            screen.size.width / 2 -
            usernameWindow.getSize()[0] / 2
        ),
        Math.floor(
          screen.bounds.y +
            screen.size.height / 2 -
            usernameWindow.getSize()[1] / 2
        )
      );
      usernameWindow.show();
    });
    usernameWindow.on('closed', () => {
      usernameWindow = null;
    });
    usernameWindow.on('blur', () => {
      usernameWindow.close();
    });
  }

  function createTrayMenu(contributionCount, currentStreak, bestStreak) {
    const username = store.get('username') || 'username not set';
    const githubProfileUrl = `https://github.com/${username}`;
    const menuTemplate = [
      { label: username, enabled: false },
      { type: 'separator' },
      { label: `Current Streak: ${currentStreak}`, enabled: false },
      { label: `Best Streak: ${bestStreak}`, enabled: false },
      { label: `Contributions: ${contributionCount}`, enabled: false },
      { type: 'separator' },
      { label: 'Reload', accelerator: 'Cmd+R', click: requestContributionData },
      {
        label: 'Open GitHub Profile...',
        accelerator: 'Cmd+O',
        click: () => shell.openExternal(githubProfileUrl)
      },
      { type: 'separator' },
      {
        label: 'Set GitHub Username...',
        accelerator: 'Cmd+S',
        click: createUsernameWindow
      },
      {
        label: 'Preferences',
        submenu: [
          {
            label: `Launch ${pjson.name} at login`,
            type: 'checkbox',
            checked: store.get('autoLaunch'),
            click: checkbox => {
              store.set('autoLaunch', checkbox.checked);
              if (checkbox.checked) {
                streakerAutoLauncher.enable();
              } else {
                streakerAutoLauncher.disable();
              }
              log.info(`Store updated - autoLaunch=${checkbox.checked}`);
            }
          }
        ]
      },
      { type: 'separator' },
      {
        label: `About ${pjson.name}...`,
        click: () => shell.openExternal(pjson.homepage)
      },
      {
        label: 'Feedback && Support...',
        click: () => shell.openExternal(pjson.bugs.url)
      },
      { type: 'separator' },
      {
        label: `Quit ${pjson.name}`,
        accelerator: 'Cmd+Q',
        click: () => app.quit()
      }
    ];
    return Menu.buildFromTemplate(menuTemplate);
  }

  function requestContributionData() {
    tray.setImage(icon.load);
    tray.setContextMenu(
      createTrayMenu('Loading...', 'Loading...', 'Loading...')
    );

    const username = store.get('username');

    contribution(username)
      .then(data => {
        tray.setContextMenu(
          createTrayMenu(
            data.contributions,
            data.currentStreak,
            data.bestStreak
          )
        );
        tray.setImage(data.currentStreak > 0 ? icon.done : icon.todo);
        log.info(
          `Request successful - username=${username} streak=${
            data.currentStreak
          } today=${data.contributions > 0}`
        );
      })
      .catch(error => {
        tray.setContextMenu(createTrayMenu('Error', 'Error', 'Error'));
        tray.setImage(icon.fail);
        log.error(
          `Request failed - username=${username}) statusCode=${
            error.statusCode
          }`
        );
      });
  }

  function setUsername(event, username) {
    usernameWindow.close();
    if (username && username !== store.get('username')) {
      store.set('username', username);
      requestContributionData();
      log.info(`Store updated - username=${username}`);
    }
  }

  process.on('uncaughtException', (error) => {
      tray.setContextMenu(createTrayMenu('Error', 'Error', 'Error'));
      tray.setImage(icon.fail);
      log.error(error);
  })

  if (process.platform === 'darwin') {
    app.dock.hide();
  }

  app.on('window-all-closed', () => {});
  tray.on('right-click', requestContributionData);
  ipcMain.on('setUsername', setUsername);

  requestContributionData();
  setInterval(requestContributionData, 1000 * 60 * 15); // 15 Minutes
});
<|endoftext|>


<commit_before>var Card = // receive Ctor with external name `Card`
(function () { //begin IIFE...

	// The ctor itself:
	function Card(id) {  //Card is also IIFE's internal name
		if (!isValidID(id))
			return null;

		// Personal methods:
		this.rank = function() { // --> 1..13
			return Math.floor(id/4)+1;
		};
		this.suit = function() { // --> 1..4
			return (id%4)+1;
		};

		// links to shared methods, defined below:
		this.color= color;
		this.name = name;
	};

//------------------
// Private resources (internal use only)
//------------------

	var isValidID = function(num) { // Returns--> true, false
		return ((typeof num)==="number") //correct type
			&& (num%1 === 0)        //integer
			&& num>=0 && num<=51;   //in range
	};

	var rankNames = ['','Ace','Two','Three','Four','Five','Six','Seven',
						'Eight','Nine','Ten','Jack','Queen','King'];
	var rankAbbrs = ['','A','2','3','4','5','6','7','8','9','10','J','Q','K'];

	var suitNames = ['','Hearts','Diamonds','Spades','Clubs'];
	var suitAbbrs = ['','H','D','S','C'];

//-----------------------
// Methods to be called through factory:
//-----------------------

	Card.isCard = function(card) { // Returns --> true, falsish
		return card && (card instanceof Card); // check for null or primitive
	};

//-----------------------------
// Shared Instance Methods
//-----------------------------

	var color = function() { // -->"red,"black", NaN
		var suitVal=this.suit();
		return ((suitVal<3)? "red": "black");
	};

	var name = function() { //--> string, NaN
		var rankVal = this.rank();
		var suitVal = this.suit();
		return rankNames[rankVal]+' of '+suitNames[suitVal]);
	};
	var shortName = function() { //--> string, NaN
		var rankVal = this.rank();
		var suitVal = this.suit();
		return rankAbbrs[rankVal]+suitAbbrs[suitVal]);
    };

	// Use factory to create full set:
	Card.fullSet = [];
	for (var id=0; id<52; ++id) {
		Card.fullSet.push(new Card(id));
	}

	return Card;  //return factory function, product of IIFE's work

})();

<commit_msg>Fixed all merge conflicts, made code work ! Merge branch 'ctor-protos'<commit_after>// <<<<<<< HEAD
// var Card = // receive Ctor with external name `Card`
// (function () { //begin IIFE...
// =======
var Card = (function () { //begin IIFE...
// >>>>>>> ctor-protos

	// The ctor itself:
	function Card(id) {  //Card is also IIFE's internal name
		if (!isValidID(id))
			return null;
// <<<<<<< HEAD

		// Personal methods:
		this.rank = function() { // --> 1..13
			return Math.floor(id/4)+1;
		};
		this.suit = function() { // --> 1..4
			return (id%4)+1;
		};

		// links to shared methods, defined below:
		this.color= color;
		this.name = name;
// 	};
//
// =======
		this.id=id;
		// return this.rank();  //personal property
	}
// >>>>>>> ctor-protos
//------------------
// Private resources (internal use only)
//------------------

// <<<<<<< HEAD
// 	var isValidID = function(num) { // Returns--> true, false
// =======
	function isValidID(num) { // Returns--> true, false
// >>>>>>> ctor-protos //correct type
		return (((typeof num)==="number") && (num%1 === 0) && num>=0 && num<=51);   //in range
	}

	var rankNames = ['','Ace','Two','Three','Four','Five','Six','Seven','Eight','Nine','Ten','Jack','Queen','King'];
	var rankAbbrs = ['','A','2','3','4','5','6','7','8','9','10','J','Q','K'];

	var suitNames = ['','Hearts','Diamonds','Spades','Clubs'];
	var suitAbbrs = ['','H','D','S','C'];
// =======
// 	'Eight','Nine','Ten','Jack','Queen','King'];
//
// 	var suitNames = ['','Hearts','Diamonds','Spades','Clubs'];
// >>>>>>> ctor-protos

//-----------------------
// Class Methods
//-----------------------

	Card.isCard = function(card) { // Returns --> true, falsish
// <<<<<<< HEAD
		return card && (card instanceof Card); // check for null or primitive
	};

//-----------------------------
// Shared Instance Methods
//-----------------------------

	var color = function() { // -->"red,"black", NaN
		var suitVal=this.suit();
		return ((suitVal<3)? "red": "black");
	};

	var name = function() { //--> string, NaN
		var rankVal = this.rank();
		var suitVal = this.suit();
		return rankNames[rankVal]+' of '+suitNames[suitVal];
	};
	var shortName = function() { //--> string, NaN
		var rankVal = this.rank();
		var suitVal = this.suit();
		return rankAbbrs[rankVal]+suitAbbrs[suitVal];
    };
// =======
// 		return card && (typeof card === 'object') /* check for null or primitive */ && ('id' in card) && (card.hasOwnProperty('id')) && isValidID(card.id); //check id
// 	};
//
// //-----------------------------
// // Inherited Instance Methods
// //-----------------------------
	//
	// Card.prototype.rank = function() { // --> 1..13, NaN
	// 	return Math.floor(this.id/4)+1;
	// };
	//
	// Card.prototype.suit = function() { // --> 1..4, NaN
	// 	return (this.id%4)+1;
	// };
	//
	// Card.prototype.color = function() { // -->"red,"black", NaN
	// 	var suitVal=this.suit();
	// 	return suitVal && ((suitVal<3)? "red": "black");
	// };
// // >>>>>>> ctor-protos

	Card.prototype.name = function() { //--> string, NaN
		var rankVal = this.rank();
		var suitVal = this.suit();
		return rankVal && suitVal &&
			(rankNames[rankVal]+' of '+suitNames[suitVal]);
	};

// <<<<<<< HEAD
	// Use factory to create full set:
	Card.fullSet = [];
	for (var id=0; id<52; ++id) {
		Card.fullSet[id] = new Card(id);
	}

	return Card;  //return factory function, product of IIFE's work
// =======
//
// 	// Use factory to create full set:
// 	Card.fullSet = [];
// 	for (var id=0; id<52; ++id) {
// 		Card.fullSet[id] = new Card(id);
// 	}
//
// 	return Card;  //return Ctor
// })(); //end IIFE definition and do it now!
// >>>>>>> ctor-protos

})();

// Export as NPM-style module
if (typeof module !== "undefined") {
	module.exports = Card;
}
<|endoftext|>


<commit_before>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      build: {
        src: 'tmp/<%= pkg.name %>.js', // Take temporary pre-compiled asset.
        dest: 'dist/<%= pkg.name %>.min.js' // Plop it in the distribution folder.
      }
    },
    jshint: {
      all: ['Gruntfile.js', 'src/**/*.js']
    },
    cssmin: {
      minify: {
        src: 'src/stylesheets/<%= pkg.name %>.css',
        dest: 'dist/<%= pkg.name %>.min.css',
      }
    },
    release: {
      options: {
        npmtag: false // Don't deploy to NPM as we don't want to release like that.
      }
    },
    preprocess : {
        // TODO: Could we somehow make src/dest cross env, rather than in all.
        dev : {
            src : 'src/javascripts/<%= pkg.name %>.js', // Take the source file.
            dest: 'tmp/<%= pkg.name %>.js', // Put the processed version in the tmp.
            options : {
                context : {
                    api_endpoint : 'http://localhost:3000',
                }
            }
        },
        prod : {
            src : 'src/javascripts/<%= pkg.name %>.js', // Take the source file.
            dest: 'tmp/<%= pkg.name %>.js', // Put the processed version in the tmp.
            options : {
                context : {
                    api_endpoint : 'http://app.sorryapp.com',
                }
            }
        }
    }
  });

  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-uglify');
  // Load the plugin for minifys CSS.
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  // Load the plugin that validates the JS markup.
  grunt.loadNpmTasks('grunt-contrib-jshint');
  // Release tasks to manage version number bump, tag etc.
  grunt.loadNpmTasks('grunt-release');
  // Module for injecting and controlling environment based varisbls.
  grunt.loadNpmTasks('grunt-preprocess');

  // Default task(s).
  grunt.registerTask('default', ['jshint', 'preprocess:dev', 'uglify', 'cssmin']);

};<commit_msg>Additional commenting in the build script.<commit_after>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    // Default package configuration.
    pkg: grunt.file.readJSON('package.json'),

    // Javascript validation.
    jshint: {
      all: ['Gruntfile.js', 'src/**/*.js']
    },

    // Preprocessing of files before, replacing variables etc.
    preprocess : {
        // TODO: Could we somehow make src/dest cross env, rather than in all.
        dev : {
            src : 'src/javascripts/<%= pkg.name %>.js', // Take the source file.
            dest: 'tmp/<%= pkg.name %>.js', // Put the processed version in the tmp.
            options : {
                context : {
                    api_endpoint : 'http://localhost:3000',
                }
            }
        },
        prod : {
            src : 'src/javascripts/<%= pkg.name %>.js', // Take the source file.
            dest: 'tmp/<%= pkg.name %>.js', // Put the processed version in the tmp.
            options : {
                context : {
                    api_endpoint : 'http://app.sorryapp.com',
                }
            }
        }
    },

    // Minify Javascript Assets.
    uglify: {
      build: {
        src: 'tmp/<%= pkg.name %>.js', // Take temporary pre-compiled asset.
        dest: 'dist/<%= pkg.name %>.min.js' // Plop it in the distribution folder.
      }
    },

    // Minify Stylesheet Assets.
    cssmin: {
      minify: {
        src: 'src/stylesheets/<%= pkg.name %>.css',
        dest: 'dist/<%= pkg.name %>.min.css',
      }
    },

    // Release & Deployment Tasks.
    release: {
      options: {
        npmtag: false // Don't deploy to NPM as we don't want to release like that.
      }
    }
  });

  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-uglify');
  // Load the plugin for minifys CSS.
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  // Load the plugin that validates the JS markup.
  grunt.loadNpmTasks('grunt-contrib-jshint');
  // Release tasks to manage version number bump, tag etc.
  grunt.loadNpmTasks('grunt-release');
  // Module for injecting and controlling environment based varisbls.
  grunt.loadNpmTasks('grunt-preprocess');

  // Default task(s).
  grunt.registerTask('default', ['jshint', 'preprocess:dev', 'uglify', 'cssmin']);

};<|endoftext|>


<commit_before>const command = {
  command: "debug",
  description: "Interactively debug any transaction on the blockchain",
  builder: {
    "_": {
      type: "string"
    },
    "network": {
      describe: "Network to connect to",
      type: "string",
      default: "development"
    },
    "fetch-external": {
      describe: "Allow debugging of external contracts",
      alias: "x",
      type: "boolean",
      default: false
    }
  },
  help: {
    usage:
      "truffle debug [--network <network>] [--fetch-external] [<transaction_hash>]",
    options: [
      {
        option: "--network",
        description: "Network to connect to.  Default: development"
      },
      {
        option: "--fetch-external",
        description:
          "Allows debugging of external contracts with verified sources.  Alias: -x"
      },
      {
        option: "<transaction_hash>",
        description:
          "Transaction ID to use for debugging.  Mandatory if --fetch-external is passed."
      }
    ]
  },
  run: function(options, done) {
    const debugModule = require("debug");
    const debug = debugModule("lib:commands:debug");

    const { Environment } = require("@truffle/environment");
    const Config = require("@truffle/config");

    const { CLIDebugger } = require("../debug");

    Promise.resolve()
      .then(async () => {
        const config = Config.detect(options);
        await Environment.detect(config);

        const txHash = config._[0]; //may be undefined
        if (config.fetchExternal && txHash === undefined) {
          throw new Error(
            "Fetch-external mode requires a specific transaction to debug"
          );
        }
        return await new CLIDebugger(config, { txHash }).run();
      })
      .then(interpreter => interpreter.start(done))
      .catch(done);
  }
};

module.exports = command;
<commit_msg>Remove "development" default from debugger --network option<commit_after>const command = {
  command: "debug",
  description: "Interactively debug any transaction on the blockchain",
  builder: {
    "_": {
      type: "string"
    },
    "network": {
      describe: "Network to connect to",
      type: "string"
    },
    "fetch-external": {
      describe: "Allow debugging of external contracts",
      alias: "x",
      type: "boolean",
      default: false
    }
  },
  help: {
    usage:
      "truffle debug [--network <network>] [--fetch-external] [<transaction_hash>]",
    options: [
      {
        option: "--network",
        description: "Network to connect to."
      },
      {
        option: "--fetch-external",
        description:
          "Allows debugging of external contracts with verified sources.  Alias: -x"
      },
      {
        option: "<transaction_hash>",
        description:
          "Transaction ID to use for debugging.  Mandatory if --fetch-external is passed."
      }
    ]
  },
  run: function(options, done) {
    const debugModule = require("debug");
    const debug = debugModule("lib:commands:debug");

    const { Environment } = require("@truffle/environment");
    const Config = require("@truffle/config");

    const { CLIDebugger } = require("../debug");

    Promise.resolve()
      .then(async () => {
        const config = Config.detect(options);
        await Environment.detect(config);

        const txHash = config._[0]; //may be undefined
        if (config.fetchExternal && txHash === undefined) {
          throw new Error(
            "Fetch-external mode requires a specific transaction to debug"
          );
        }
        return await new CLIDebugger(config, { txHash }).run();
      })
      .then(interpreter => interpreter.start(done))
      .catch(done);
  }
};

module.exports = command;
<|endoftext|>


<commit_before>/*
 *  Copyright (c) 2005-2014, 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.
 *
 */
$(function () {
    validator.initValidationEvents('form-asset-create',function(){});
    $('#btn-create-asset').removeAttr('disabled');
    var obtainFormMeta = function (formId) {
        return $(formId).data();
    };
    var populateTags = function (arr) {
        var entry;
        var modifiedArr = [];
        var tagEntry;
        //The Select2 plugin creates multiple entries in the FormData
        //object.These duplicates need to be removed and a single
        //_tags entry created in their place
        arr.forEach(function(entry){
            if(entry.name !== '_tags'){
                modifiedArr.push(entry);
            } else {
                tagEntry = entry;
            }
        });
        //Populate the selected tags
        tagEntry.value = tagsAPI.selectedTags();
        modifiedArr.push(tagEntry);
        arr = modifiedArr;
    };
    $('#form-asset-create').ajaxForm({
        beforeSubmit: function (arr) {
            var createButton = $('#btn-create-asset');
            createButton.attr('disabled', 'disabled');
            createButton.next().attr('disabled', 'disabled');
            caramel.render('loading', 'Creating asset. Please wait..', function (info, content) {
                var $content = $(content).removeClass('loading-animation-big').addClass('loading-animation');
                createButton.parent().append($content);
            });
            populateTags(arr);
            if (!validator.isValidForm('form-asset-create')) {
                window.scrollTo(0, 0);
                $('div.error').each(function () {
                    var $container = $(this).closest('div.responsive-form-container');
                    if (!$container.hasClass('in')) {
                        $container.show('fast').addClass('in');
                    }
                });
                $('#btn-create-asset').removeAttr('disabled');
                setTimeout(
                    function () {
                        $('.loading-animation').remove();
                    }, 1000);
                return false;
            }
        },
        success: function (data) {
            var options = obtainFormMeta('#form-asset-create');
            var type = PublisherUtils.resolveCurrentPageAssetType();
            $('#btn-create-asset').removeAttr('disabled');
            $.cookie("new-asset-" + type, data.id + ":" + type + ":" + data.name);
            window.location = options.redirectUrl;
        },
        error: function (response) {
            var result;
            if (response && response.responseText){
                result = JSON.parse(response.responseText);
            }
            if (result && result.moreInfomation){
                messages.alertError(result.moreInfomation);
            } else {
                messages.alertError('Unable to add the ' + PublisherUtils.resolveCurrentPageAssetType() + ' instance.');
            }
            $('#btn-create-asset').removeAttr('disabled');
            $('.fa-spinner').parent().remove();
        }
    });
    var initDatePicker = function () {
        if ($(this).attr('data-render-options') == "date-time") {
            var dateField = this;
            $(this).DatePicker({
                mode: 'single',
                position: 'right',
                onBeforeShow: function (el) {
                    if ($(dateField).val().replace(/^\s+|\s+$/g, "")) {
                        $(dateField).DatePickerSetDate($(dateField).val(), true);
                    }

                },
                onChange: function (date, el) {
                    $(el).val((date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear());
                    if ($('#closeOnSelect input').attr('checked')) {
                        $(el).DatePickerHide();
                    }
                }
            });
        }
    };

    $('#form-asset-create input[type="text"]').each(initDatePicker);

    var removeUnboundRow = function(link){
        var table = link.closest('table');
        var requiredOneRow = false;
        var numberOfRows = $('tr',table).length;
        if(table.attr('data-required-row')){
            requiredOneRow = true;
        }
        if(requiredOneRow && numberOfRows == 2){
            messages.alertError('Required to have at-least one row.');
            return false;
        }
        if(numberOfRows == 2){
            table.hide();
        }
        link.closest('tr').remove();
    };

    $('.js-add-unbounded-row').click(function () {
        var tableName = $(this).attr('data-name');
        var table = $('#table_' + tableName);
        table.find('thead').show();
        var referenceRow = $('#table_reference_' + tableName);
        var newRow = referenceRow.clone().removeAttr('id');
        $('input[type="text"]', newRow).val('');
        table.show().append(newRow);
        table.find('thead').show();
        $('input[type="text"]', newRow).each(initDatePicker);

    });
    $('.js-unbounded-table').on('click', 'a', function (event) {
        removeUnboundRow($(event.target));
    });

    $('.js-unbounded-table').on('click', 'input[type="checkbox"]', function (event) {
        var checkbox = event.target;
        var hiddenField = $(checkbox).next();
        if ($(checkbox).is(":checked")) {
            $(hiddenField).val('on');
        } else {
            $(hiddenField).val('off');
        }
    });

    $('.tmp_refernceTableForUnbounded').each(function () {
        $(this).detach().attr('class', 'refernceTableForUnbounded').appendTo('body');
    });

    $('.tmp_refernceTableForOptionText').each(function () {
        $(this).detach().attr('class', 'refernceTableForUnbounded').appendTo('body');
    });

    $('#form-asset-create a.collapsing-h2').off('click', '**').on('click', function (e) {
        e.preventDefault();
        var $panel = $(this).parent().next();
        if($panel.is(":visible")){
            $panel.slideUp();
            $(this).parent().addClass('collapsed');
        }else{
            $panel.slideDown();
            $(this).parent().removeClass('collapsed');
        }
    });
    /**
     * Hides tables which dose not contain required fields.
     * count the number of required fields in one table, if count equals to zero
     * then hide that table. First table will expand always
     */
    $('#form-asset-create .responsive-form-container').each(function (index) {
        if ($(this).find('.required-field').length == 0 && index != 0) {
            $(this).hide();
            $('.field-title').eq(index).addClass("collapsed");
        }
    });

});<commit_msg>Fix for tagEntry undefined issue<commit_after>/*
 *  Copyright (c) 2005-2014, 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.
 *
 */
$(function () {
    validator.initValidationEvents('form-asset-create',function(){});
    $('#btn-create-asset').removeAttr('disabled');
    var obtainFormMeta = function (formId) {
        return $(formId).data();
    };
    var populateTags = function (arr) {
        var entry;
        var modifiedArr = [];
        var tagEntry;
        //The Select2 plugin creates multiple entries in the FormData
        //object.These duplicates need to be removed and a single
        //_tags entry created in their place
        arr.forEach(function(entry){
            if(entry.name !== '_tags'){
                modifiedArr.push(entry);
            } else {
                tagEntry = entry;
            }
        });
        //Populate the selected tags
        if(tagEntry == undefined) {
            return;
        }
        else {
            tagEntry.value = tagsAPI.selectedTags();
            modifiedArr.push(tagEntry);
            arr = modifiedArr;
        }
    };
    $('#form-asset-create').ajaxForm({
        beforeSubmit: function (arr) {
            var createButton = $('#btn-create-asset');
            createButton.attr('disabled', 'disabled');
            createButton.next().attr('disabled', 'disabled');
            caramel.render('loading', 'Creating asset. Please wait..', function (info, content) {
                var $content = $(content).removeClass('loading-animation-big').addClass('loading-animation');
                createButton.parent().append($content);
            });
            populateTags(arr);
            if (!validator.isValidForm('form-asset-create')) {
                window.scrollTo(0, 0);
                $('div.error').each(function () {
                    var $container = $(this).closest('div.responsive-form-container');
                    if (!$container.hasClass('in')) {
                        $container.show('fast').addClass('in');
                    }
                });
                $('#btn-create-asset').removeAttr('disabled');
                setTimeout(
                    function () {
                        $('.loading-animation').remove();
                    }, 1000);
                return false;
            }
        },
        success: function (data) {
            var options = obtainFormMeta('#form-asset-create');
            var type = PublisherUtils.resolveCurrentPageAssetType();
            $('#btn-create-asset').removeAttr('disabled');
            $.cookie("new-asset-" + type, data.id + ":" + type + ":" + data.name);
            window.location = options.redirectUrl;
        },
        error: function (response) {
            var result;
            if (response && response.responseText){
                result = JSON.parse(response.responseText);
            }
            if (result && result.moreInfomation){
                messages.alertError(result.moreInfomation);
            } else {
                messages.alertError('Unable to add the ' + PublisherUtils.resolveCurrentPageAssetType() + ' instance.');
            }
            $('#btn-create-asset').removeAttr('disabled');
            $('.fa-spinner').parent().remove();
        }
    });
    var initDatePicker = function () {
        if ($(this).attr('data-render-options') == "date-time") {
            var dateField = this;
            $(this).DatePicker({
                mode: 'single',
                position: 'right',
                onBeforeShow: function (el) {
                    if ($(dateField).val().replace(/^\s+|\s+$/g, "")) {
                        $(dateField).DatePickerSetDate($(dateField).val(), true);
                    }

                },
                onChange: function (date, el) {
                    $(el).val((date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear());
                    if ($('#closeOnSelect input').attr('checked')) {
                        $(el).DatePickerHide();
                    }
                }
            });
        }
    };

    $('#form-asset-create input[type="text"]').each(initDatePicker);

    var removeUnboundRow = function(link){
        var table = link.closest('table');
        var requiredOneRow = false;
        var numberOfRows = $('tr',table).length;
        if(table.attr('data-required-row')){
            requiredOneRow = true;
        }
        if(requiredOneRow && numberOfRows == 2){
            messages.alertError('Required to have at-least one row.');
            return false;
        }
        if(numberOfRows == 2){
            table.hide();
        }
        link.closest('tr').remove();
    };

    $('.js-add-unbounded-row').click(function () {
        var tableName = $(this).attr('data-name');
        var table = $('#table_' + tableName);
        table.find('thead').show();
        var referenceRow = $('#table_reference_' + tableName);
        var newRow = referenceRow.clone().removeAttr('id');
        $('input[type="text"]', newRow).val('');
        table.show().append(newRow);
        table.find('thead').show();
        $('input[type="text"]', newRow).each(initDatePicker);

    });
    $('.js-unbounded-table').on('click', 'a', function (event) {
        removeUnboundRow($(event.target));
    });

    $('.js-unbounded-table').on('click', 'input[type="checkbox"]', function (event) {
        var checkbox = event.target;
        var hiddenField = $(checkbox).next();
        if ($(checkbox).is(":checked")) {
            $(hiddenField).val('on');
        } else {
            $(hiddenField).val('off');
        }
    });

    $('.tmp_refernceTableForUnbounded').each(function () {
        $(this).detach().attr('class', 'refernceTableForUnbounded').appendTo('body');
    });

    $('.tmp_refernceTableForOptionText').each(function () {
        $(this).detach().attr('class', 'refernceTableForUnbounded').appendTo('body');
    });

    $('#form-asset-create a.collapsing-h2').off('click', '**').on('click', function (e) {
        e.preventDefault();
        var $panel = $(this).parent().next();
        if($panel.is(":visible")){
            $panel.slideUp();
            $(this).parent().addClass('collapsed');
        }else{
            $panel.slideDown();
            $(this).parent().removeClass('collapsed');
        }
    });
    /**
     * Hides tables which dose not contain required fields.
     * count the number of required fields in one table, if count equals to zero
     * then hide that table. First table will expand always
     */
    $('#form-asset-create .responsive-form-container').each(function (index) {
        if ($(this).find('.required-field').length == 0 && index != 0) {
            $(this).hide();
            $('.field-title').eq(index).addClass("collapsed");
        }
    });

});
<|endoftext|>


<commit_before>var isAngularLoaded = function () {
	return (typeof angular == 'undefined') ? false : true;
}

anything.prototype.isAngularLoaded = isAngularLoaded;
<commit_msg>Simplified statement<commit_after>var isAngularLoaded = function () {
	return !(typeof angular == 'undefined');
}

anything.prototype.isAngularLoaded = isAngularLoaded;
<|endoftext|>


<commit_before>/*jslint node: true */
'use strict';
module.exports = function(grunt) {

  // Load grunt tasks automatically, when needed
  require('jit-grunt')(grunt, {
    express: 'grunt-express-server',
    useminPrepare: 'grunt-usemin',
    ngtemplates: 'grunt-angular-templates',
    protractor: 'grunt-protractor-runner'
  });
  var isProduction = (process.env.NODE_ENV === 'production');
  // Time how long tasks take. Can help when optimizing build times
  if (!isProduction) {
    require('time-grunt')(grunt);
  }

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    pkg: grunt.file.readJSON('package.json'),
    yeoman: {
      // configurable paths
      client: require('./bower.json').appPath || 'client',
      dist: 'dist'
    },
    express: {
      options: {
        port: process.env.PORT || 9000
      },
      dev: {
        options: {
          script: 'server/app.js',
          debug: true
        }
      },
      prod: {
        options: {
          script: 'dist/server/app.js'
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= express.options.port %>'
      }
    },
    watch: {
      injectJS: {
        files: [
          '<%= yeoman.client %>/{app,components}/**/*.js',
          '!<%= yeoman.client %>/{app,components}/**/*.spec.js',
          '!<%= yeoman.client %>/{app,components}/**/*.mock.js',
          '!<%= yeoman.client %>/app/app.js'
        ],
        tasks: ['injector:scripts']
      },
      injectCss: {
        files: [
          '<%= yeoman.client %>/{app,components}/**/*.css'
        ],
        tasks: ['injector:css']
      },
      mochaTest: {
        files: ['server/**/*.spec.js'],
        tasks: ['env:test', 'mochaTest']
      },
      jsTest: {
        files: [
          '<%= yeoman.client %>/{app,components}/**/*.spec.js',
          '<%= yeoman.client %>/{app,components}/**/*.mock.js'
        ],
        tasks: ['newer:jshint:all', 'karma']
      },
      injectLess: {
        files: [
          '<%= yeoman.client %>/{app,components}/**/*.less'
        ],
        tasks: ['injector:less']
      },
      less: {
        files: [
          '<%= yeoman.client %>/{app,components}/**/*.less'
        ],
        tasks: ['less']
      },
      jade: {
        files: [
          '<%= yeoman.client %>/{app,components}/*',
          '<%= yeoman.client %>/{app,components}/**/*.jade'
        ],
        tasks: ['jade']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        files: [
          '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.css',
          '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.html',
          '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.js',
          '!{.tmp,<%= yeoman.client %>}{app,components}/**/*.spec.js',
          '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.mock.js',
          '<%= yeoman.client %>/assets/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
        ],
        options: {
          livereload: true
        }
      },
      express: {
        files: [
          'server/**/*.{js,json}'
        ],
        tasks: ['express:dev', 'wait'],
        options: {
          livereload: true,
          nospawn: true //Without this option specified express won't be reloaded
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '<%= yeoman.client %>/.jshintrc',
        reporter: (isProduction) ? null : require('jshint-stylish')
      },
      server: {
        options: {
          jshintrc: 'server/.jshintrc'
        },
        src: [
          'server/**/*.js',
          '!server/**/*.{spec,integration}.js'
        ]
      },
      serverTest: {
        options: {
          jshintrc: 'server/.jshintrc-spec'
        },
        src: ['server/**/*.{spec,integration}.js']
      },
      all: [
        '<%= yeoman.client %>/{app,components}/**/*.js',
        '!<%= yeoman.client %>/{app,components}/**/*.spec.js',
        '!<%= yeoman.client %>/{app,components}/**/*.mock.js'
      ],
      test: {
        src: [
          '<%= yeoman.client %>/{app,components}/**/*.spec.js',
          '<%= yeoman.client %>/{app,components}/**/*.mock.js'
        ]
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*',
            '!<%= yeoman.dist %>/.openshift',
            '!<%= yeoman.dist %>/Procfile'
          ]
        }]
      },
      server: '.tmp'
    },

    // Debugging with node inspector
    'node-inspector': {
      custom: {
        options: {
          'web-host': 'localhost'
        }
      }
    },

    // Use nodemon to run server in debug mode with an initial breakpoint
    nodemon: {
      debug: {
        script: 'server/app.js',
        options: {
          nodeArgs: ['--debug-brk'],
          env: {
            PORT: process.env.PORT || 9000
          },
          callback: function(nodemon) {
            nodemon.on('log', function(event) {
              console.log(event.colour);
            });

            // opens browser on initial server start
            nodemon.on('config:update', function() {
              setTimeout(function() {
                require('open')('http://localhost:8080/debug?port=5858');
              }, 500);
            });
          }
        }
      }
    },

    // Automatically inject Bower components into the app
    wiredep: {
      target: {
        src: '<%= yeoman.client %>/index.html',
        ignorePath: '<%= yeoman.client %>/',
        exclude: [/bootstrap-sass-official/, /bootstrap.js/, '/json3/', '/es5-shim/', /bootstrap.css/, /font-awesome.css/]
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/client/{,*/}*.js',
            '<%= yeoman.dist %>/client/{,*/}*.css',
            '<%= yeoman.dist %>/client/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/client/assets/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: ['<%= yeoman.client %>/index.html'],
      options: {
        dest: '<%= yeoman.dist %>/client'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/client/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/client/{,*/}*.css'],
      js: ['<%= yeoman.dist %>/client/{,*/}*.js'],
      options: {
        assetsDirs: [
          '<%= yeoman.dist %>/client',
          '<%= yeoman.dist %>/client/assets/images'
        ],
        // This is so we update image references in our ng-templates
        patterns: {
          js: [
            [/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
          ]
        }
      }
    },

    // Allow the use of non-minsafe AngularJS files. Automatically makes it
    // minsafe compatible so Uglify does not destroy the ng references
    ngAnnotate: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat',
          src: '*/**.js',
          dest: '.tmp/concat'
        }]
      }
    },

    // Package all the html partials into a single javascript payload
    ngtemplates: {
      options: {
        // This should be the name of your apps angular module
        module: 'grtyrApp',
        htmlmin: {
          collapseBooleanAttributes: true,
          collapseWhitespace: true,
          removeAttributeQuotes: true,
          removeEmptyAttributes: true,
          removeRedundantAttributes: true,
          removeScriptTypeAttributes: true,
          removeStyleLinkTypeAttributes: true
        },
        usemin: 'app/app.js'
      },
      main: {
        cwd: '<%= yeoman.client %>',
        src: ['{app,components}/**/*.html'],
        dest: '.tmp/templates.js'
      },
      tmp: {
        cwd: '.tmp',
        src: ['{app,components}/**/*.html'],
        dest: '.tmp/tmp-templates.js'
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.client %>',
          dest: '<%= yeoman.dist %>/client',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            'bower_components/**/*',
            'assets/images/{,*/}*.{webp}',
            'assets/fonts/**/*',
            'index.html'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/client/assets/images',
          src: ['generated/*']
        }, {
          expand: true,
          dest: '<%= yeoman.dist %>',
          src: [
            'package.json',
            'server/**/*'
          ]
        }]
      },
      openshift: {
        options: {
          mode: true
        },
        files: [{
          expand: true,
          dest: '<%= yeoman.dist %>',
          src: [
            '.openshift/**/*'
          ]
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.client %>',
        dest: '.tmp/',
        src: ['{app,components}/**/*.css']
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'jade',
        'less',
      ],
      test: [
        'jade',
        'less',
      ],
      debug: {
        tasks: [
          'nodemon',
          'node-inspector'
        ],
        options: {
          logConcurrentOutput: true
        }
      },
      dist: [
        'jade',
        'less'
      ]
    },

    // Test settings
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    },

    mochaTest: {
      options: {
        reporter: 'spec',
        require: 'mocha.conf.js'
      },
      unit: {
        src: ['server/**/*.spec.js']
      },
      integration: {
        src: ['server/**/*.integration.js']
      }
    },

    protractor: {
      options: {
        configFile: 'protractor.conf.js'
      },
      chrome: {
        options: {
          args: {
            browser: 'chrome'
          }
        }
      }
    },

    env: {
      test: {
        NODE_ENV: 'test'
      },
      prod: {
        NODE_ENV: 'production'
      }
    },

    // Compiles Jade to html
    jade: {
      compile: {
        options: {
          data: {
            debug: false
          }
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.client %>',
          src: [
            '{app,components}/**/*.jade'
          ],
          dest: '.tmp',
          ext: '.html'
        }]
      }
    },

    // Compiles Less to CSS
    less: {
      options: {
        paths: [
          '<%= yeoman.client %>/bower_components',
          '<%= yeoman.client %>/app',
          '<%= yeoman.client %>/components'
        ]
      },
      server: {
        files: {
          '.tmp/app/app.css': '<%= yeoman.client %>/app/app.less'
        }
      },
    },

    injector: {
      options: {

      },
      // Inject application script files into index.html (doesn't include bower)
      scripts: {
        options: {
          transform: function(filePath) {
            filePath = filePath.replace('/client/', '');
            filePath = filePath.replace('/.tmp/', '');
            return '<script src="' + filePath + '"></script>';
          },
          starttag: '<!-- injector:js -->',
          endtag: '<!-- endinjector -->'
        },
        files: {
          '<%= yeoman.client %>/index.html': [
            ['{.tmp,<%= yeoman.client %>}/{app,components}/**/*.js',
              '!{.tmp,<%= yeoman.client %>}/app/app.js',
              '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.spec.js',
              '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.mock.js'
            ]
          ]
        }
      },

      // Inject component less into app.less
      less: {
        options: {
          transform: function(filePath) {
            filePath = filePath.replace('/client/app/', '');
            filePath = filePath.replace('/client/components/', '');
            return '@import \'' + filePath + '\';';
          },
          starttag: '// injector',
          endtag: '// endinjector'
        },
        files: {
          '<%= yeoman.client %>/app/app.less': [
            '<%= yeoman.client %>/{app,components}/**/*.less',
            '!<%= yeoman.client %>/app/app.less'
          ]
        }
      },

      // Inject component css into index.html
      css: {
        options: {
          transform: function(filePath) {
            filePath = filePath.replace('/client/', '');
            filePath = filePath.replace('/.tmp/', '');
            return '<link rel="stylesheet" href="' + filePath + '">';
          },
          starttag: '<!-- injector:css -->',
          endtag: '<!-- endinjector -->'
        },
        files: {
          '<%= yeoman.client %>/index.html': [
            '<%= yeoman.client %>/{app,components}/**/*.css'
          ]
        }
      }
    },
  });

  // Used for delaying livereload until after server has restarted
  grunt.registerTask('wait', function() {
    grunt.log.ok('Waiting for server reload...');

    var done = this.async();

    setTimeout(function() {
      grunt.log.writeln('Done waiting!');
      done();
    }, 1500);
  });

  grunt.registerTask('express-keepalive', 'Keep grunt running', function() {
    this.async();
  });

  grunt.registerTask('serve', function(target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'env:all', 'env:prod', 'express:prod', 'wait', 'open', 'express-keepalive']);
    }

    if (target === 'debug') {
      return grunt.task.run([
        'clean:server',
        'injector:less',
        'concurrent:server',
        'injector',
        'wiredep',
        'concurrent:debug'
      ]);
    }

    grunt.task.run([
      'clean:server',
      'injector:less',
      'concurrent:server',
      'injector',
      'wiredep',
      'express:dev',
      'wait',
      'open',
      'watch'
    ]);
  });

  grunt.registerTask('server', function() {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

  grunt.registerTask('test', function(target, option) {
    if (target === 'server') {
      return grunt.task.run([
        'env:test',
        'mochaTest:unit',
        'mochaTest:integration'
      ]);
    } else if (target === 'client') {
      return grunt.task.run([
        'clean:server',
        'injector:less',
        'concurrent:test',
        'injector',
        'karma'
      ]);
    } else if (target === 'e2e') {

      if (option === 'prod') {
        return grunt.task.run([
          'build',
          'env:prod',
          'express:prod',
          'protractor'
        ]);
      } else {
        return grunt.task.run([
          'clean:server',
          'env:test',
          'injector:less',
          'concurrent:test',
          'injector',
          'wiredep',
          'express:dev',
          'protractor'
        ]);
      }
    } else if (target === 'coverage') {

      if (option === 'unit') {
        return grunt.task.run([
          'env:test'
        ]);
      } else if (option === 'integration') {
        return grunt.task.run([
          'env:test'
        ]);
      } else {
        return grunt.task.run([
          'env:test'
        ]);
      }

    } else grunt.task.run([
      'test:server',
      'test:client'
    ]);
  });

  grunt.registerTask('build', [
    'clean:dist',
    'injector:less',
    'concurrent:dist',
    'injector',
    'wiredep',
    'useminPrepare',
    'ngtemplates',
    'concat',
    'ngAnnotate',
    'copy:dist',
    'copy:openshift',
    'cssmin',
    'uglify',
    'rev',
    'usemin'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<commit_msg>remove htmlmin options<commit_after>/*jslint node: true */
'use strict';
module.exports = function(grunt) {

  // Load grunt tasks automatically, when needed
  require('jit-grunt')(grunt, {
    express: 'grunt-express-server',
    useminPrepare: 'grunt-usemin',
    ngtemplates: 'grunt-angular-templates',
    protractor: 'grunt-protractor-runner'
  });
  var isProduction = (process.env.NODE_ENV === 'production');
  // Time how long tasks take. Can help when optimizing build times
  if (!isProduction) {
    require('time-grunt')(grunt);
  }

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    pkg: grunt.file.readJSON('package.json'),
    yeoman: {
      // configurable paths
      client: require('./bower.json').appPath || 'client',
      dist: 'dist'
    },
    express: {
      options: {
        port: process.env.PORT || 9000
      },
      dev: {
        options: {
          script: 'server/app.js',
          debug: true
        }
      },
      prod: {
        options: {
          script: 'dist/server/app.js'
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= express.options.port %>'
      }
    },
    watch: {
      injectJS: {
        files: [
          '<%= yeoman.client %>/{app,components}/**/*.js',
          '!<%= yeoman.client %>/{app,components}/**/*.spec.js',
          '!<%= yeoman.client %>/{app,components}/**/*.mock.js',
          '!<%= yeoman.client %>/app/app.js'
        ],
        tasks: ['injector:scripts']
      },
      injectCss: {
        files: [
          '<%= yeoman.client %>/{app,components}/**/*.css'
        ],
        tasks: ['injector:css']
      },
      mochaTest: {
        files: ['server/**/*.spec.js'],
        tasks: ['env:test', 'mochaTest']
      },
      jsTest: {
        files: [
          '<%= yeoman.client %>/{app,components}/**/*.spec.js',
          '<%= yeoman.client %>/{app,components}/**/*.mock.js'
        ],
        tasks: ['newer:jshint:all', 'karma']
      },
      injectLess: {
        files: [
          '<%= yeoman.client %>/{app,components}/**/*.less'
        ],
        tasks: ['injector:less']
      },
      less: {
        files: [
          '<%= yeoman.client %>/{app,components}/**/*.less'
        ],
        tasks: ['less']
      },
      jade: {
        files: [
          '<%= yeoman.client %>/{app,components}/*',
          '<%= yeoman.client %>/{app,components}/**/*.jade'
        ],
        tasks: ['jade']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        files: [
          '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.css',
          '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.html',
          '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.js',
          '!{.tmp,<%= yeoman.client %>}{app,components}/**/*.spec.js',
          '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.mock.js',
          '<%= yeoman.client %>/assets/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
        ],
        options: {
          livereload: true
        }
      },
      express: {
        files: [
          'server/**/*.{js,json}'
        ],
        tasks: ['express:dev', 'wait'],
        options: {
          livereload: true,
          nospawn: true //Without this option specified express won't be reloaded
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '<%= yeoman.client %>/.jshintrc',
        reporter: (isProduction) ? null : require('jshint-stylish')
      },
      server: {
        options: {
          jshintrc: 'server/.jshintrc'
        },
        src: [
          'server/**/*.js',
          '!server/**/*.{spec,integration}.js'
        ]
      },
      serverTest: {
        options: {
          jshintrc: 'server/.jshintrc-spec'
        },
        src: ['server/**/*.{spec,integration}.js']
      },
      all: [
        '<%= yeoman.client %>/{app,components}/**/*.js',
        '!<%= yeoman.client %>/{app,components}/**/*.spec.js',
        '!<%= yeoman.client %>/{app,components}/**/*.mock.js'
      ],
      test: {
        src: [
          '<%= yeoman.client %>/{app,components}/**/*.spec.js',
          '<%= yeoman.client %>/{app,components}/**/*.mock.js'
        ]
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*',
            '!<%= yeoman.dist %>/.openshift',
            '!<%= yeoman.dist %>/Procfile'
          ]
        }]
      },
      server: '.tmp'
    },

    // Debugging with node inspector
    'node-inspector': {
      custom: {
        options: {
          'web-host': 'localhost'
        }
      }
    },

    // Use nodemon to run server in debug mode with an initial breakpoint
    nodemon: {
      debug: {
        script: 'server/app.js',
        options: {
          nodeArgs: ['--debug-brk'],
          env: {
            PORT: process.env.PORT || 9000
          },
          callback: function(nodemon) {
            nodemon.on('log', function(event) {
              console.log(event.colour);
            });

            // opens browser on initial server start
            nodemon.on('config:update', function() {
              setTimeout(function() {
                require('open')('http://localhost:8080/debug?port=5858');
              }, 500);
            });
          }
        }
      }
    },

    // Automatically inject Bower components into the app
    wiredep: {
      target: {
        src: '<%= yeoman.client %>/index.html',
        ignorePath: '<%= yeoman.client %>/',
        exclude: [/bootstrap-sass-official/, /bootstrap.js/, '/json3/', '/es5-shim/', /bootstrap.css/, /font-awesome.css/]
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/client/{,*/}*.js',
            '<%= yeoman.dist %>/client/{,*/}*.css',
            '<%= yeoman.dist %>/client/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/client/assets/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: ['<%= yeoman.client %>/index.html'],
      options: {
        dest: '<%= yeoman.dist %>/client'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/client/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/client/{,*/}*.css'],
      js: ['<%= yeoman.dist %>/client/{,*/}*.js'],
      options: {
        assetsDirs: [
          '<%= yeoman.dist %>/client',
          '<%= yeoman.dist %>/client/assets/images'
        ],
        // This is so we update image references in our ng-templates
        patterns: {
          js: [
            [/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
          ]
        }
      }
    },

    // Allow the use of non-minsafe AngularJS files. Automatically makes it
    // minsafe compatible so Uglify does not destroy the ng references
    ngAnnotate: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat',
          src: '*/**.js',
          dest: '.tmp/concat'
        }]
      }
    },

    // Package all the html partials into a single javascript payload
    ngtemplates: {
      options: {
        // This should be the name of your apps angular module
        module: 'grtyrApp',
        usemin: 'app/app.js'
      },
      main: {
        cwd: '<%= yeoman.client %>',
        src: ['{app,components}/**/*.html'],
        dest: '.tmp/templates.js'
      },
      tmp: {
        cwd: '.tmp',
        src: ['{app,components}/**/*.html'],
        dest: '.tmp/tmp-templates.js'
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.client %>',
          dest: '<%= yeoman.dist %>/client',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            'bower_components/**/*',
            'assets/images/{,*/}*.{webp}',
            'assets/fonts/**/*',
            'index.html'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/client/assets/images',
          src: ['generated/*']
        }, {
          expand: true,
          dest: '<%= yeoman.dist %>',
          src: [
            'package.json',
            'server/**/*'
          ]
        }]
      },
      openshift: {
        options: {
          mode: true
        },
        files: [{
          expand: true,
          dest: '<%= yeoman.dist %>',
          src: [
            '.openshift/**/*'
          ]
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.client %>',
        dest: '.tmp/',
        src: ['{app,components}/**/*.css']
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'jade',
        'less',
      ],
      test: [
        'jade',
        'less',
      ],
      debug: {
        tasks: [
          'nodemon',
          'node-inspector'
        ],
        options: {
          logConcurrentOutput: true
        }
      },
      dist: [
        'jade',
        'less'
      ]
    },

    // Test settings
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    },

    mochaTest: {
      options: {
        reporter: 'spec',
        require: 'mocha.conf.js'
      },
      unit: {
        src: ['server/**/*.spec.js']
      },
      integration: {
        src: ['server/**/*.integration.js']
      }
    },

    protractor: {
      options: {
        configFile: 'protractor.conf.js'
      },
      chrome: {
        options: {
          args: {
            browser: 'chrome'
          }
        }
      }
    },

    env: {
      test: {
        NODE_ENV: 'test'
      },
      prod: {
        NODE_ENV: 'production'
      }
    },

    // Compiles Jade to html
    jade: {
      compile: {
        options: {
          data: {
            debug: false
          }
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.client %>',
          src: [
            '{app,components}/**/*.jade'
          ],
          dest: '.tmp',
          ext: '.html'
        }]
      }
    },

    // Compiles Less to CSS
    less: {
      options: {
        paths: [
          '<%= yeoman.client %>/bower_components',
          '<%= yeoman.client %>/app',
          '<%= yeoman.client %>/components'
        ]
      },
      server: {
        files: {
          '.tmp/app/app.css': '<%= yeoman.client %>/app/app.less'
        }
      },
    },

    injector: {
      options: {

      },
      // Inject application script files into index.html (doesn't include bower)
      scripts: {
        options: {
          transform: function(filePath) {
            filePath = filePath.replace('/client/', '');
            filePath = filePath.replace('/.tmp/', '');
            return '<script src="' + filePath + '"></script>';
          },
          starttag: '<!-- injector:js -->',
          endtag: '<!-- endinjector -->'
        },
        files: {
          '<%= yeoman.client %>/index.html': [
            ['{.tmp,<%= yeoman.client %>}/{app,components}/**/*.js',
              '!{.tmp,<%= yeoman.client %>}/app/app.js',
              '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.spec.js',
              '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.mock.js'
            ]
          ]
        }
      },

      // Inject component less into app.less
      less: {
        options: {
          transform: function(filePath) {
            filePath = filePath.replace('/client/app/', '');
            filePath = filePath.replace('/client/components/', '');
            return '@import \'' + filePath + '\';';
          },
          starttag: '// injector',
          endtag: '// endinjector'
        },
        files: {
          '<%= yeoman.client %>/app/app.less': [
            '<%= yeoman.client %>/{app,components}/**/*.less',
            '!<%= yeoman.client %>/app/app.less'
          ]
        }
      },

      // Inject component css into index.html
      css: {
        options: {
          transform: function(filePath) {
            filePath = filePath.replace('/client/', '');
            filePath = filePath.replace('/.tmp/', '');
            return '<link rel="stylesheet" href="' + filePath + '">';
          },
          starttag: '<!-- injector:css -->',
          endtag: '<!-- endinjector -->'
        },
        files: {
          '<%= yeoman.client %>/index.html': [
            '<%= yeoman.client %>/{app,components}/**/*.css'
          ]
        }
      }
    },
  });

  // Used for delaying livereload until after server has restarted
  grunt.registerTask('wait', function() {
    grunt.log.ok('Waiting for server reload...');

    var done = this.async();

    setTimeout(function() {
      grunt.log.writeln('Done waiting!');
      done();
    }, 1500);
  });

  grunt.registerTask('express-keepalive', 'Keep grunt running', function() {
    this.async();
  });

  grunt.registerTask('serve', function(target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'env:all', 'env:prod', 'express:prod', 'wait', 'open', 'express-keepalive']);
    }

    if (target === 'debug') {
      return grunt.task.run([
        'clean:server',
        'injector:less',
        'concurrent:server',
        'injector',
        'wiredep',
        'concurrent:debug'
      ]);
    }

    grunt.task.run([
      'clean:server',
      'injector:less',
      'concurrent:server',
      'injector',
      'wiredep',
      'express:dev',
      'wait',
      'open',
      'watch'
    ]);
  });

  grunt.registerTask('server', function() {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

  grunt.registerTask('test', function(target, option) {
    if (target === 'server') {
      return grunt.task.run([
        'env:test',
        'mochaTest:unit',
        'mochaTest:integration'
      ]);
    } else if (target === 'client') {
      return grunt.task.run([
        'clean:server',
        'injector:less',
        'concurrent:test',
        'injector',
        'karma'
      ]);
    } else if (target === 'e2e') {

      if (option === 'prod') {
        return grunt.task.run([
          'build',
          'env:prod',
          'express:prod',
          'protractor'
        ]);
      } else {
        return grunt.task.run([
          'clean:server',
          'env:test',
          'injector:less',
          'concurrent:test',
          'injector',
          'wiredep',
          'express:dev',
          'protractor'
        ]);
      }
    } else if (target === 'coverage') {

      if (option === 'unit') {
        return grunt.task.run([
          'env:test'
        ]);
      } else if (option === 'integration') {
        return grunt.task.run([
          'env:test'
        ]);
      } else {
        return grunt.task.run([
          'env:test'
        ]);
      }

    } else grunt.task.run([
      'test:server',
      'test:client'
    ]);
  });

  grunt.registerTask('build', [
    'clean:dist',
    'injector:less',
    'concurrent:dist',
    'injector',
    'wiredep',
    'useminPrepare',
    'ngtemplates',
    'concat',
    'ngAnnotate',
    'copy:dist',
    'copy:openshift',
    'cssmin',
    'uglify',
    'rev',
    'usemin'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<|endoftext|>