<commit_before>'use strict'

const {BrowserWindow, MenuItem, webContents} = require('electron')
const EventEmitter = require('events').EventEmitter
const v8Util = process.atomBinding('v8_util')
const bindings = process.atomBinding('menu')

// Automatically generated radio menu item's group id.
var nextGroupId = 0

// Search between separators to find a radio menu item and return its group id,
// otherwise generate a group id.
var generateGroupId = function (items, pos) {
  var i, item, j, k, ref1, ref2, ref3
  if (pos > 0) {
    for (i = j = ref1 = pos - 1; ref1 <= 0 ? j <= 0 : j >= 0; i = ref1 <= 0 ? ++j : --j) {
      item = items[i]
      if (item.type === 'radio') {
        return item.groupId
      }
      if (item.type === 'separator') {
        break
      }
    }
  } else if (pos < items.length) {
    for (i = k = ref2 = pos, ref3 = items.length - 1; ref2 <= ref3 ? k <= ref3 : k >= ref3; i = ref2 <= ref3 ? ++k : --k) {
      item = items[i]
      if (item.type === 'radio') {
        return item.groupId
      }
      if (item.type === 'separator') {
        break
      }
    }
  }
  return ++nextGroupId
}

// Returns the index of item according to |id|.
var indexOfItemById = function (items, id) {
  var i, item, j, len
  for (i = j = 0, len = items.length; j < len; i = ++j) {
    item = items[i]
    if (item.id === id) {
      return i
    }
  }
  return -1
}

// Returns the index of where to insert the item according to |position|.
var indexToInsertByPosition = function (items, position) {
  var insertIndex
  if (!position) {
    return items.length
  }
  const [query, id] = position.split('=')
  insertIndex = indexOfItemById(items, id)
  if (insertIndex === -1 && query !== 'endof') {
    console.warn("Item with id '" + id + "' is not found")
    return items.length
  }
  switch (query) {
    case 'after':
      insertIndex++
      break
    case 'endof':

      // If the |id| doesn't exist, then create a new group with the |id|.
      if (insertIndex === -1) {
        items.push({
          id: id,
          type: 'separator'
        })
        insertIndex = items.length - 1
      }

      // Find the end of the group.
      insertIndex++
      while (insertIndex < items.length && items[insertIndex].type !== 'separator') {
        insertIndex++
      }
  }
  return insertIndex
}

const Menu = bindings.Menu

Object.setPrototypeOf(Menu.prototype, EventEmitter.prototype)

Menu.prototype._init = function () {
  this.commandsMap = {}
  this.groupsMap = {}
  this.items = []
  this.delegate = {
    isCommandIdChecked: (commandId) => {
      var command = this.commandsMap[commandId]
      return command != null ? command.checked : undefined
    },
    isCommandIdEnabled: (commandId) => {
      var command = this.commandsMap[commandId]
      return command != null ? command.enabled : undefined
    },
    isCommandIdVisible: (commandId) => {
      var command = this.commandsMap[commandId]
      return command != null ? command.visible : undefined
    },
    getAcceleratorForCommandId: (commandId, useDefaultAccelerator) => {
      const command = this.commandsMap[commandId]
      if (command == null) return
      if (command.accelerator != null) return command.accelerator
      if (useDefaultAccelerator) return command.getDefaultRoleAccelerator()
    },
    getIconForCommandId: (commandId) => {
      var command = this.commandsMap[commandId]
      return command != null ? command.icon : undefined
    },
    executeCommand: (event, commandId) => {
      const command = this.commandsMap[commandId]
      if (command == null) return
      command.click(event, BrowserWindow.getFocusedWindow(), webContents.getFocusedWebContents())
    },
    menuWillShow: () => {
      // Make sure radio groups have at least one menu item seleted.
      var checked, group, id, j, len, radioItem, ref1
      ref1 = this.groupsMap
      for (id in ref1) {
        group = ref1[id]
        checked = false
        for (j = 0, len = group.length; j < len; j++) {
          radioItem = group[j]
          if (!radioItem.checked) {
            continue
          }
          checked = true
          break
        }
        if (!checked) {
          v8Util.setHiddenValue(group[0], 'checked', true)
        }
      }
    }
  }
}

Menu.prototype.popup = function (window, x, y, positioningItem) {
  if (typeof window !== 'object' || window.constructor !== BrowserWindow) {
    // Shift.
    positioningItem = y
    y = x
    x = window
    window = BrowserWindow.getFocusedWindow()
  }

  // Default to showing under mouse location.
  if (typeof x !== 'number') x = -1
  if (typeof y !== 'number') y = -1

  // Default to not highlighting any item.
  if (typeof positioningItem !== 'number') positioningItem = -1

  this.popupAt(window, x, y, positioningItem)
}

Menu.prototype.append = function (item) {
  return this.insert(this.getItemCount(), item)
}

Menu.prototype.insert = function (pos, item) {
  var base, name
  if ((item != null ? item.constructor : void 0) !== MenuItem) {
    throw new TypeError('Invalid item')
  }
  switch (item.type) {
    case 'normal':
      this.insertItem(pos, item.commandId, item.label)
      break
    case 'checkbox':
      this.insertCheckItem(pos, item.commandId, item.label)
      break
    case 'separator':
      this.insertSeparator(pos)
      break
    case 'submenu':
      this.insertSubMenu(pos, item.commandId, item.label, item.submenu)
      break
    case 'radio':
      // Grouping radio menu items.
      item.overrideReadOnlyProperty('groupId', generateGroupId(this.items, pos))
      if ((base = this.groupsMap)[name = item.groupId] == null) {
        base[name] = []
      }
      this.groupsMap[item.groupId].push(item)

      // Setting a radio menu item should flip other items in the group.
      v8Util.setHiddenValue(item, 'checked', item.checked)
      Object.defineProperty(item, 'checked', {
        enumerable: true,
        get: function () {
          return v8Util.getHiddenValue(item, 'checked')
        },
        set: () => {
          var j, len, otherItem, ref1
          ref1 = this.groupsMap[item.groupId]
          for (j = 0, len = ref1.length; j < len; j++) {
            otherItem = ref1[j]
            if (otherItem !== item) {
              v8Util.setHiddenValue(otherItem, 'checked', false)
            }
          }
          return v8Util.setHiddenValue(item, 'checked', true)
        }
      })
      this.insertRadioItem(pos, item.commandId, item.label, item.groupId)
  }
  if (item.sublabel != null) {
    this.setSublabel(pos, item.sublabel)
  }
  if (item.icon != null) {
    this.setIcon(pos, item.icon)
  }
  if (item.role != null) {
    this.setRole(pos, item.role)
  }

  // Make menu accessable to items.
  item.overrideReadOnlyProperty('menu', this)

  // Remember the items.
  this.items.splice(pos, 0, item)
  this.commandsMap[item.commandId] = item
}

// Force menuWillShow to be called
Menu.prototype._callMenuWillShow = function () {
  if (this.delegate != null) {
    this.delegate.menuWillShow()
  }
  this.items.forEach(function (item) {
    if (item.submenu != null) {
      item.submenu._callMenuWillShow()
    }
  })
}

var applicationMenu = null

Menu.setApplicationMenu = function (menu) {
  if (!(menu === null || menu.constructor === Menu)) {
    throw new TypeError('Invalid menu')
  }

  // Keep a reference.
  applicationMenu = menu
  if (process.platform === 'darwin') {
    if (menu === null) {
      return
    }
    menu._callMenuWillShow()
    bindings.setApplicationMenu(menu)
  } else {
    BrowserWindow.getAllWindows().forEach(function (window) {
      window.setMenu(menu)
    })
  }
}

Menu.getApplicationMenu = function () {
  return applicationMenu
}

Menu.sendActionToFirstResponder = bindings.sendActionToFirstResponder

Menu.buildFromTemplate = function (template) {
  var insertIndex, item, j, k, key, len, len1, menu, menuItem, positionedTemplate
  if (!Array.isArray(template)) {
    throw new TypeError('Invalid template for Menu')
  }
  positionedTemplate = []
  insertIndex = 0
  for (j = 0, len = template.length; j < len; j++) {
    item = template[j]
    if (item.position) {
      insertIndex = indexToInsertByPosition(positionedTemplate, item.position)
    } else {
      // If no |position| is specified, insert after last item.
      insertIndex++
    }
    positionedTemplate.splice(insertIndex, 0, item)
  }
  menu = new Menu()
  for (k = 0, len1 = positionedTemplate.length; k < len1; k++) {
    item = positionedTemplate[k]
    if (typeof item !== 'object') {
      throw new TypeError('Invalid template for MenuItem')
    }
    menuItem = new MenuItem(item)
    menu.append(menuItem)
  }
  return menu
}

module.exports = Menu
<commit_msg>remove unused var<commit_after>'use strict'

const {BrowserWindow, MenuItem, webContents} = require('electron')
const EventEmitter = require('events').EventEmitter
const v8Util = process.atomBinding('v8_util')
const bindings = process.atomBinding('menu')

// Automatically generated radio menu item's group id.
var nextGroupId = 0

// Search between separators to find a radio menu item and return its group id,
// otherwise generate a group id.
var generateGroupId = function (items, pos) {
  var i, item, j, k, ref1, ref2, ref3
  if (pos > 0) {
    for (i = j = ref1 = pos - 1; ref1 <= 0 ? j <= 0 : j >= 0; i = ref1 <= 0 ? ++j : --j) {
      item = items[i]
      if (item.type === 'radio') {
        return item.groupId
      }
      if (item.type === 'separator') {
        break
      }
    }
  } else if (pos < items.length) {
    for (i = k = ref2 = pos, ref3 = items.length - 1; ref2 <= ref3 ? k <= ref3 : k >= ref3; i = ref2 <= ref3 ? ++k : --k) {
      item = items[i]
      if (item.type === 'radio') {
        return item.groupId
      }
      if (item.type === 'separator') {
        break
      }
    }
  }
  return ++nextGroupId
}

// Returns the index of item according to |id|.
var indexOfItemById = function (items, id) {
  var i, item, j, len
  for (i = j = 0, len = items.length; j < len; i = ++j) {
    item = items[i]
    if (item.id === id) {
      return i
    }
  }
  return -1
}

// Returns the index of where to insert the item according to |position|.
var indexToInsertByPosition = function (items, position) {
  var insertIndex
  if (!position) {
    return items.length
  }
  const [query, id] = position.split('=')
  insertIndex = indexOfItemById(items, id)
  if (insertIndex === -1 && query !== 'endof') {
    console.warn("Item with id '" + id + "' is not found")
    return items.length
  }
  switch (query) {
    case 'after':
      insertIndex++
      break
    case 'endof':

      // If the |id| doesn't exist, then create a new group with the |id|.
      if (insertIndex === -1) {
        items.push({
          id: id,
          type: 'separator'
        })
        insertIndex = items.length - 1
      }

      // Find the end of the group.
      insertIndex++
      while (insertIndex < items.length && items[insertIndex].type !== 'separator') {
        insertIndex++
      }
  }
  return insertIndex
}

const Menu = bindings.Menu

Object.setPrototypeOf(Menu.prototype, EventEmitter.prototype)

Menu.prototype._init = function () {
  this.commandsMap = {}
  this.groupsMap = {}
  this.items = []
  this.delegate = {
    isCommandIdChecked: (commandId) => {
      var command = this.commandsMap[commandId]
      return command != null ? command.checked : undefined
    },
    isCommandIdEnabled: (commandId) => {
      var command = this.commandsMap[commandId]
      return command != null ? command.enabled : undefined
    },
    isCommandIdVisible: (commandId) => {
      var command = this.commandsMap[commandId]
      return command != null ? command.visible : undefined
    },
    getAcceleratorForCommandId: (commandId, useDefaultAccelerator) => {
      const command = this.commandsMap[commandId]
      if (command == null) return
      if (command.accelerator != null) return command.accelerator
      if (useDefaultAccelerator) return command.getDefaultRoleAccelerator()
    },
    getIconForCommandId: (commandId) => {
      var command = this.commandsMap[commandId]
      return command != null ? command.icon : undefined
    },
    executeCommand: (event, commandId) => {
      const command = this.commandsMap[commandId]
      if (command == null) return
      command.click(event, BrowserWindow.getFocusedWindow(), webContents.getFocusedWebContents())
    },
    menuWillShow: () => {
      // Make sure radio groups have at least one menu item seleted.
      var checked, group, id, j, len, radioItem, ref1
      ref1 = this.groupsMap
      for (id in ref1) {
        group = ref1[id]
        checked = false
        for (j = 0, len = group.length; j < len; j++) {
          radioItem = group[j]
          if (!radioItem.checked) {
            continue
          }
          checked = true
          break
        }
        if (!checked) {
          v8Util.setHiddenValue(group[0], 'checked', true)
        }
      }
    }
  }
}

Menu.prototype.popup = function (window, x, y, positioningItem) {
  if (typeof window !== 'object' || window.constructor !== BrowserWindow) {
    // Shift.
    positioningItem = y
    y = x
    x = window
    window = BrowserWindow.getFocusedWindow()
  }

  // Default to showing under mouse location.
  if (typeof x !== 'number') x = -1
  if (typeof y !== 'number') y = -1

  // Default to not highlighting any item.
  if (typeof positioningItem !== 'number') positioningItem = -1

  this.popupAt(window, x, y, positioningItem)
}

Menu.prototype.append = function (item) {
  return this.insert(this.getItemCount(), item)
}

Menu.prototype.insert = function (pos, item) {
  var base, name
  if ((item != null ? item.constructor : void 0) !== MenuItem) {
    throw new TypeError('Invalid item')
  }
  switch (item.type) {
    case 'normal':
      this.insertItem(pos, item.commandId, item.label)
      break
    case 'checkbox':
      this.insertCheckItem(pos, item.commandId, item.label)
      break
    case 'separator':
      this.insertSeparator(pos)
      break
    case 'submenu':
      this.insertSubMenu(pos, item.commandId, item.label, item.submenu)
      break
    case 'radio':
      // Grouping radio menu items.
      item.overrideReadOnlyProperty('groupId', generateGroupId(this.items, pos))
      if ((base = this.groupsMap)[name = item.groupId] == null) {
        base[name] = []
      }
      this.groupsMap[item.groupId].push(item)

      // Setting a radio menu item should flip other items in the group.
      v8Util.setHiddenValue(item, 'checked', item.checked)
      Object.defineProperty(item, 'checked', {
        enumerable: true,
        get: function () {
          return v8Util.getHiddenValue(item, 'checked')
        },
        set: () => {
          var j, len, otherItem, ref1
          ref1 = this.groupsMap[item.groupId]
          for (j = 0, len = ref1.length; j < len; j++) {
            otherItem = ref1[j]
            if (otherItem !== item) {
              v8Util.setHiddenValue(otherItem, 'checked', false)
            }
          }
          return v8Util.setHiddenValue(item, 'checked', true)
        }
      })
      this.insertRadioItem(pos, item.commandId, item.label, item.groupId)
  }
  if (item.sublabel != null) {
    this.setSublabel(pos, item.sublabel)
  }
  if (item.icon != null) {
    this.setIcon(pos, item.icon)
  }
  if (item.role != null) {
    this.setRole(pos, item.role)
  }

  // Make menu accessable to items.
  item.overrideReadOnlyProperty('menu', this)

  // Remember the items.
  this.items.splice(pos, 0, item)
  this.commandsMap[item.commandId] = item
}

// Force menuWillShow to be called
Menu.prototype._callMenuWillShow = function () {
  if (this.delegate != null) {
    this.delegate.menuWillShow()
  }
  this.items.forEach(function (item) {
    if (item.submenu != null) {
      item.submenu._callMenuWillShow()
    }
  })
}

var applicationMenu = null

Menu.setApplicationMenu = function (menu) {
  if (!(menu === null || menu.constructor === Menu)) {
    throw new TypeError('Invalid menu')
  }

  // Keep a reference.
  applicationMenu = menu
  if (process.platform === 'darwin') {
    if (menu === null) {
      return
    }
    menu._callMenuWillShow()
    bindings.setApplicationMenu(menu)
  } else {
    BrowserWindow.getAllWindows().forEach(function (window) {
      window.setMenu(menu)
    })
  }
}

Menu.getApplicationMenu = function () {
  return applicationMenu
}

Menu.sendActionToFirstResponder = bindings.sendActionToFirstResponder

Menu.buildFromTemplate = function (template) {
  var insertIndex, item, j, k, len, len1, menu, menuItem, positionedTemplate
  if (!Array.isArray(template)) {
    throw new TypeError('Invalid template for Menu')
  }
  positionedTemplate = []
  insertIndex = 0
  for (j = 0, len = template.length; j < len; j++) {
    item = template[j]
    if (item.position) {
      insertIndex = indexToInsertByPosition(positionedTemplate, item.position)
    } else {
      // If no |position| is specified, insert after last item.
      insertIndex++
    }
    positionedTemplate.splice(insertIndex, 0, item)
  }
  menu = new Menu()
  for (k = 0, len1 = positionedTemplate.length; k < len1; k++) {
    item = positionedTemplate[k]
    if (typeof item !== 'object') {
      throw new TypeError('Invalid template for MenuItem')
    }
    menuItem = new MenuItem(item)
    menu.append(menuItem)
  }
  return menu
}

module.exports = Menu
<|endoftext|>


<commit_before>/*eslint-disable */

'use strict';

var should = require('should'),
    fs = require('fs'),
    path = require('path'),
    gutil = require('gulp-util'),
    getStylesData = require('../index');

function getFile(filePath) {
    return new gutil.File({
        path: path.resolve(filePath),
        cwd: './test/',
        base: path.dirname(filePath),
        contents: new Buffer(String(fs.readFileSync(filePath)))
    });
}

function compare(fixturePath, expectedHTML, css, options, done) {
    var file = getFile(fixturePath);

    getStylesData(file.contents.toString('utf8'), options, function (err, results) {
        results.html.should.be.equal(String(fs.readFileSync(expectedHTML)));
        should.deepEqual(results.css, css);
        done();
    });
}

describe('style-data', function() {
    it('Should separate css and html', function(done) {
        var options = {
            applyStyleTags: true,
            removeStyleTags: true,
            preserveMediaQueries: false
        };
        compare(path.join('test', 'fixtures', 'in.html'), path.join('test', 'expected', 'out.html'), [ '\n      h1 {\n        border: 1px solid #ccc;\n      }\n    ' ], options, done);
    });

    it('Should leave html from no style html', function(done) {
        var options = {
            applyStyleTags: true,
            removeStyleTags: true,
            preserveMediaQueries: false
        };
        compare(path.join('test', 'fixtures', 'no-style-tag', 'in.html'), path.join('test', 'expected', 'no-style-tag', 'out.html'), [], options, done);
    });

    it('Should leave style blocks if they contain media queries', function(done) {
        var options = {
            applyStyleTags: true,
            removeStyleTags: true,
            preserveMediaQueries: true
        };
        compare(path.join('test', 'fixtures', 'media-queries', 'in.html'), path.join('test', 'expected', 'media-queries', 'out.html'), [ '\n      h1 {\n        border: 1px solid #ccc;\n      }\n    ', '\n      @media only screen and (min-width: 640px) {\n        .headline {\n          color: blue;\n        }\n      }\n    '], options, done);
    });
});
<commit_msg>Update spacing for readability.<commit_after>/*eslint-disable */

'use strict';

var should = require('should'),
    fs = require('fs'),
    path = require('path'),
    gutil = require('gulp-util'),
    getStylesData = require('../index');

function getFile(filePath) {
    return new gutil.File({
        path: path.resolve(filePath),
        cwd: './test/',
        base: path.dirname(filePath),
        contents: new Buffer(String(fs.readFileSync(filePath)))
    });
}

function compare(fixturePath, expectedHTML, css, options, done) {
    var file = getFile(fixturePath);

    getStylesData(file.contents.toString('utf8'), options, function (err, results) {
        results.html.should.be.equal(String(fs.readFileSync(expectedHTML)));
        should.deepEqual(results.css, css);
        done();
    });
}

describe('style-data', function() {
    it('Should separate css and html', function(done) {
        var options = {
            applyStyleTags: true,
            removeStyleTags: true,
            preserveMediaQueries: false
        };
        compare(
            path.join('test', 'fixtures', 'in.html'),
            path.join('test', 'expected', 'out.html'),
            [ '\n      h1 {\n        border: 1px solid #ccc;\n      }\n    ' ],
            options,
            done
        );
    });

    it('Should leave html from no style html', function(done) {
        var options = {
            applyStyleTags: true,
            removeStyleTags: true,
            preserveMediaQueries: false
        };
        compare(
            path.join('test', 'fixtures', 'no-style-tag', 'in.html'),
            path.join('test', 'expected', 'no-style-tag', 'out.html'),
            [],
            options,
            done
        );
    });

    it('Should leave style blocks if they contain media queries', function(done) {
        var options = {
            applyStyleTags: true,
            removeStyleTags: true,
            preserveMediaQueries: true
        };
        compare(
            path.join('test', 'fixtures', 'media-queries', 'in.html'),
            path.join('test', 'expected', 'media-queries', 'out.html'),
            [ '\n      h1 {\n        border: 1px solid #ccc;\n      }\n    ', '\n      @media only screen and (min-width: 640px) {\n        .headline {\n          color: blue;\n        }\n      }\n    '],
            options,
            done
        );
    });
});
<|endoftext|>


<commit_before>var pamApp = angular.module('pamApp', ['ngRoute', 'ngSanitize', 'hc.marked']);

pamApp.config(function($routeProvider) {
    $routeProvider.when('/', {
        templateUrl: 'components/search.html',
        controller: 'SearchCtrl'
    }).
    when('/new', {
        templateUrl: 'components/new.html',
        controller: 'NewCtrl'
    }).
    when('/notes/:id', {
        templateUrl: 'components/note.html',
        controller: 'NoteCtrl'
    }).
    when('/notes/:id/edit', {
        templateUrl: 'components/edit.html',
        controller: 'EditCtrl'
    }).
    otherwise({
        redirectTo: '/'
    });
});

pamApp.config(function(markedProvider) {
    markedProvider.setOptions({
      renderer: new marked.Renderer(),
      gfm: true,
      tables: true,
      breaks: true,
      pedantic: false,
      sanitize: true,
      smartLists: false,
      smartypants: true,
      highlight: function(lang, code) {
        if (lang && code) {
            return hljs.highlight(lang, code).value;
        }
      }
    });
});

pamApp.directive('pamSubjectListRadio', function() {
  return {
    restrict: 'E',
    transclude: true,
    templateUrl: 'shared/subject/subjectlist-radio.html'
  };
})

pamApp.directive('pamSubjectListCheck', function() {
  return {
    restrict: 'E',
    transclude: true,
    templateUrl: 'shared/subject/subjectlist-check.html'
  };
})

pamApp.directive('pamImageList', function() {
  return {
    restrict: 'E',
    transclude: true,
    templateUrl: 'shared/image/imagelist.html'
  };
})

pamApp.directive('pamTextbox', ['$routeParams', '$http', function($routeParams, $http) {
  return {
    restrict: 'A',
    link: function(scope, element, attrs) {

      element.on('paste', function(e) {
        var items = (e.clipboardData || e.originalEvent.clipboardData).items;
        var textbox = element[0];
        if (items && items[0].type == "text/plain") {
            e.preventDefault();
            document.execCommand("insertHTML", false, e.clipboardData.getData('text'));
        } else if (items) {
            var blob = items[0].getAsFile();
            var reader = new FileReader();
            reader.onload = function(event){
                var imgurl = event.target.result;
                $http.post('/notes/' + $routeParams.id, {
                    "imgType": imgurl.match(/data:(.*?);/)[1],
                    "imgContent": imgurl.match(/base64,(.*)/)[1]
                }).
                success( function(data){
                    // Replace image tag with handlebars ID of the POST image
                    data = data.replace(/"/g, '')
                    var result = "[![" + data + "](/notes/" + $routeParams.id + "/" + data + ")](" + $routeParams.id + "/" + data + ")"
                    document.execCommand("insertHTML", false, result)
                    getIMG();
                }).error(handleError)
            };
            reader.readAsDataURL(blob);
        } else if (e.clipboardData.getData('text')) {
            // paste text clipboard data and strip style editing
            e.preventDefault();
            document.execCommand("insertHTML", false, e.clipboardData.getData('text'));
        } else {
            // else wait on window for paste event and POST contents
            window.setTimeout(imgPost, 0, true);
        }
      });

      function imgPost() {
        var html = element[0].innerHTML
        // extract image type and base64 content and post to DB
        $http.post('/notes/' + $routeParams.id, {
            "imgType": html.match(/data:(.*?);/)[1],
            "imgContent": html.match(/base64,(.*?)"/)[1]
        }).success( function(data){
            // Replace image tag with handlebars ID of the POST image
            data = data.replace(/"/g, '')
            element[0].innerHTML = html.replace(//, "[![" + data + "](/notes/" + $routeParams.id + "/" + data + ")](" + $routeParams.id + "/" + data + ")");
            getIMG();
        })
      }

      function getIMG() {
          $http.get('/notes/' + $routeParams.id + '/img').
          success(function(data) {
              scope.imgList = data;
          })
      }
    }
  }
}])<commit_msg>textbox improvements for Chrmoe<commit_after>var pamApp = angular.module('pamApp', ['ngRoute', 'ngSanitize', 'hc.marked']);

pamApp.config(function($routeProvider) {
    $routeProvider.when('/', {
        templateUrl: 'components/search.html',
        controller: 'SearchCtrl'
    }).
    when('/new', {
        templateUrl: 'components/new.html',
        controller: 'NewCtrl'
    }).
    when('/notes/:id', {
        templateUrl: 'components/note.html',
        controller: 'NoteCtrl'
    }).
    when('/notes/:id/edit', {
        templateUrl: 'components/edit.html',
        controller: 'EditCtrl'
    }).
    otherwise({
        redirectTo: '/'
    });
});

pamApp.config(function(markedProvider) {
    markedProvider.setOptions({
      renderer: new marked.Renderer(),
      gfm: true,
      tables: true,
      breaks: true,
      pedantic: false,
      sanitize: true,
      smartLists: false,
      smartypants: true,
      highlight: function(lang, code) {
        if (lang && code) {
            return hljs.highlight(lang, code).value;
        }
      }
    });
});

pamApp.directive('pamSubjectListRadio', function() {
  return {
    restrict: 'E',
    transclude: true,
    templateUrl: 'shared/subject/subjectlist-radio.html'
  };
})

pamApp.directive('pamSubjectListCheck', function() {
  return {
    restrict: 'E',
    transclude: true,
    templateUrl: 'shared/subject/subjectlist-check.html'
  };
})

pamApp.directive('pamImageList', function() {
  return {
    restrict: 'E',
    transclude: true,
    templateUrl: 'shared/image/imagelist.html'
  };
})

pamApp.directive('pamTextbox', ['$routeParams', '$http', function($routeParams, $http) {
  return {
    restrict: 'A',
    link: function(scope, element, attrs) {

      element.on('paste', function(e) {
        var items = (e.clipboardData || e.originalEvent.clipboardData).items;
        var textbox = element[0];
        if (items && items[0].type == "text/plain") {
            e.preventDefault();
            document.execCommand("insertHTML", false, e.clipboardData.getData('text'));
        } else if (items) {
            var blob = items[0].getAsFile();
            var reader = new FileReader();
            reader.onload = function(event){
                var imgurl = event.target.result;
                $http.post('/notes/' + $routeParams.id, {
                    "imgType": imgurl.match(/data:(.*?);/)[1],
                    "imgContent": imgurl.match(/base64,(.*)/)[1]
                }).
                success( function(data){
                    // Replace image tag with handlebars ID of the POST image
                    data = data.replace(/"/g, '')
                    var result = "[![" + data + "](/notes/" + $routeParams.id + "/" + data + ")](" + $routeParams.id + "/" + data + ")"
                    document.execCommand("insertHTML", false, result)
                    getIMG();
                }).error(handleError)
            };
            reader.readAsDataURL(blob);
        } else if (e.clipboardData.getData('text')) {
            // paste text clipboard data and strip style editing
            e.preventDefault();
            document.execCommand("insertHTML", false, e.clipboardData.getData('text'));
        } else {
            // else wait on window for paste event and POST contents
            window.setTimeout(imgPost, 0, true);
        }
      });

      function imgPost() {
        var html = element[0].innerHTML;
        // extract image type and base64 content and post to DB
        $http.post('/notes/' + $routeParams.id, {
            "imgType": html.match(/data:(.*?);/)[1],
            "imgContent": html.match(/base64,(.*?)"/)[1]
        }).success( function(data){
            // Replace image tag with handlebars ID of the POST image
            data = data.replace(/"/g, '')
            element[0].innerHTML = html.replace(//, "[![" + data + "](/notes/" + $routeParams.id + "/" + data + ")](" + $routeParams.id + "/" + data + ")");
            getIMG();
        })
      }

      function getIMG() {
          $http.get('/notes/' + $routeParams.id + '/img').
          success(function(data) {
              scope.imgList = data;
          })
      }

      element.on('keydown', function(e) {
        // remove
 insertion in Chrmoe
        if (!!window.chrome && e.keyCode === 13 ) {
          e.preventDefault();
          document.execCommand("insertHTML", false, '

');
        }
        return false;
      })

    }
  }
}])<|endoftext|>


<commit_before>
// { key, i in items} -> { key, i, items }
function loopKeys(expr) {
  var b0 = brackets(0),
      els = expr.slice(b0.length).match(/\s*(\S+?)\s*(?:,\s*(\S)+)?\s+in\s+(.+)/)
  return els ? { key: els[1], pos: els[2], val: b0 + els[3] } : { val: expr }
}

function mkitem(expr, key, val) {
  var item = {}
  item[expr.key] = key
  if (expr.pos) item[expr.pos] = val
  return item
}

/* Beware: heavy stuff */
function _each(dom, parent, expr) {

  remAttr(dom, 'each')

  var template = dom.outerHTML,
      root = dom.parentNode,
      placeholder = document.createComment('riot placeholder'),
      tags = [],
      child = getTag(dom),
      checksum

  root.insertBefore(placeholder, dom)

  expr = loopKeys(expr)

  // clean template code
  parent
    .one('premount', function () {
      if (root.stub) root = parent.root
      // remove the original DOM node
      dom.parentNode.removeChild(dom)
    })
    .on('update', function () {
      var items = tmpl(expr.val, parent),
          test

      // object loop. any changes cause full redraw
      if (!isArray(items)) {
        var testsum = JSON.stringify(items)

        items = !items ? [] :
          Object.keys(items).map(function (key) {
            return mkitem(expr, key, items[key])
          })
      }

      var frag = document.createDocumentFragment(),
          i = tags.length,
          j = items.length

      // unmount leftover items
      while (i > j) tags[--i].unmount()
      tags.length = j

      test = !checksum && !!expr.key
      for (i = 0; i < j; ++i) {
        var _item = test ? mkitem(expr, items[i], i) : items[i]

        if (!tags[i]) {
          // mount new
          (tags[i] = new Tag({ tmpl: template }, {
              parent: parent,
              isLoop: true,
              root: root
            })
          ).mount()

          frag.appendChild(tags[i].root)
        }
        tags[i]._item = _item
        tags[i].update(_item)
      }

      root.insertBefore(frag, placeholder)

      if (child) parent.tags[getTagName(dom)] = tags

    }).one('updated', function() {
      var keys = Object.keys(parent)// only set new values
      walk(root, function(dom) {
        setNamed(dom, parent, keys)
      })
    })

    rendered = items.slice()

  }).one('updated', function() {
    var keys = Object.keys(parent)// only set new values
    walk(root, function(dom) {
      setNamed(dom, parent, keys)
    })
  })

}
<commit_msg>improve multi named on support on loop<commit_after>
// { key, i in items} -> { key, i, items }
function loopKeys(expr) {
  var b0 = brackets(0),
      els = expr.slice(b0.length).match(/\s*(\S+?)\s*(?:,\s*(\S)+)?\s+in\s+(.+)/)
  return els ? { key: els[1], pos: els[2], val: b0 + els[3] } : { val: expr }
}

function mkitem(expr, key, val) {
  var item = {}
  item[expr.key] = key
  if (expr.pos) item[expr.pos] = val
  return item
}

/* Beware: heavy stuff */
function _each(dom, parent, expr) {

  remAttr(dom, 'each')

  var template = dom.outerHTML,
      root = dom.parentNode,
      placeholder = document.createComment('riot placeholder'),
      tags = [],
      child = getTag(dom),
      checksum

  root.insertBefore(placeholder, dom)

  expr = loopKeys(expr)

  // clean template code
  parent
    .one('premount', function () {
      if (root.stub) root = parent.root
      // remove the original DOM node
      dom.parentNode.removeChild(dom)
    })
    .on('update', function () {
      var items = tmpl(expr.val, parent),
          test

      // object loop. any changes cause full redraw
      if (!isArray(items)) {
        var testsum = JSON.stringify(items)

        items = !items ? [] :
          Object.keys(items).map(function (key) {
            return mkitem(expr, key, items[key])
          })
      }

      var frag = document.createDocumentFragment(),
          i = tags.length,
          j = items.length

      // unmount leftover items
      while (i > j) tags[--i].unmount()
      tags.length = j

      test = !checksum && !!expr.key
      for (i = 0; i < j; ++i) {
        var _item = test ? mkitem(expr, items[i], i) : items[i]

        if (!tags[i]) {
          // mount new
          (tags[i] = new Tag({ tmpl: template }, {
              parent: parent,
              isLoop: true,
              root: root
            })
          ).mount()

          frag.appendChild(tags[i].root)
        }
        tags[i]._item = _item
        tags[i].update(_item)
      }

      root.insertBefore(frag, placeholder)

      if (child) parent.tags[getTagName(dom)] = tags

    }).one('updated', function() {
      var keys = Object.keys(parent)// only set new values
      walk(root, function(node) {
        if (node.nodeType == 1 && !node.isLoop && !node._looped) {
          node._visited = false
          node._looped = true
          setNamed(node, parent, keys)
        }
      })
    })

    rendered = items.slice()

  }).one('updated', function() {
    var keys = Object.keys(parent)// only set new values
    walk(root, function(dom) {
      setNamed(dom, parent, keys)
    })
  })

}
<|endoftext|>


<commit_before>$((function () {
  displaySubHeader();

  $('#customers-main').slick({
    infinite: false,
    dots: true,
  });
}));

function displaySubHeader() {
  let inAboutSection = () =>
    $(window).scrollTop() + 101 >= $("#about-portfolio").offset().top &&
    $(window).scrollTop() + 160 < $("#team").offset().top;

  $(window).on("scroll", (function() {
    if (inAboutSection()) {
      setTimeout(function() {
        if (inAboutSection()) {
          $(".subheader-section").css({
            display: "block"
          });
        }
      }, 1000);
    } else {
      $(".subheader-section").css({
        display: "none"
      });
    }

    if (
      $(window).scrollTop() + 120 >= $("#about-portfolio").offset().top &&
      $(window).scrollTop() + 200 < $("#about-hackathons").offset().top
    ) {
      $("#portfolio-a").addClass("selected-a");
      $("#portfolio-a-mobile").addClass("selected-a");
    } else {
      $("#portfolio-a")
        .removeClass("selected-a")
        .trigger("blur");
      $("#portfolio-a-mobile")
        .removeClass("selected-a")
        .trigger("blur");
    }

    if (
      $(window).scrollTop() + 120 >= $("#about-hackathons").offset().top &&
      $(window).scrollTop() + 200 < $("#about-customers").offset().top
    ) {
      $("#hackathon-a").addClass("selected-a");
      $("#hackathon-a-mobile").addClass("selected-a");
    } else {
      $("#hackathon-a")
        .removeClass("selected-a")
        .trigger("blur");
      $("#hackathon-a-mobile")
        .removeClass("selected-a")
        .trigger("blur");
    }

    if (
      $(window).scrollTop() + 180 >= $("#about-customers").offset().top &&
      $(window).scrollTop() + 200 < $("#team").offset().top
    ) {
      $("#customers-a").addClass("selected-a");
      $("#customers-a-mobile").addClass("selected-a");
    } else {
      $("#customers-a")
        .removeClass("selected-a")
        .trigger("blur");
      $("#customers-a-mobile")
        .removeClass("selected-a")
        .trigger("blur");
    }
  }));
}
<commit_msg>CML-63: changed subheader appearance timer<commit_after>$((function () {
  displaySubHeader();

  $('#customers-main').slick({
    infinite: false,
    dots: true,
  });
}));

function displaySubHeader() {
  let inAboutSection = () =>
    $(window).scrollTop() + 101 >= $("#about-portfolio").offset().top &&
    $(window).scrollTop() + 160 < $("#team").offset().top;

  $(window).on("scroll", (function() {
    if (inAboutSection()) {
      setTimeout(function() {
        if (inAboutSection()) {
          $(".subheader-section").css({
            display: "block"
          });
        }
      }, 500);
    } else {
      $(".subheader-section").css({
        display: "none"
      });
    }

    if (
      $(window).scrollTop() + 120 >= $("#about-portfolio").offset().top &&
      $(window).scrollTop() + 200 < $("#about-hackathons").offset().top
    ) {
      $("#portfolio-a").addClass("selected-a");
      $("#portfolio-a-mobile").addClass("selected-a");
    } else {
      $("#portfolio-a")
        .removeClass("selected-a")
        .trigger("blur");
      $("#portfolio-a-mobile")
        .removeClass("selected-a")
        .trigger("blur");
    }

    if (
      $(window).scrollTop() + 120 >= $("#about-hackathons").offset().top &&
      $(window).scrollTop() + 200 < $("#about-customers").offset().top
    ) {
      $("#hackathon-a").addClass("selected-a");
      $("#hackathon-a-mobile").addClass("selected-a");
    } else {
      $("#hackathon-a")
        .removeClass("selected-a")
        .trigger("blur");
      $("#hackathon-a-mobile")
        .removeClass("selected-a")
        .trigger("blur");
    }

    if (
      $(window).scrollTop() + 180 >= $("#about-customers").offset().top &&
      $(window).scrollTop() + 200 < $("#team").offset().top
    ) {
      $("#customers-a").addClass("selected-a");
      $("#customers-a-mobile").addClass("selected-a");
    } else {
      $("#customers-a")
        .removeClass("selected-a")
        .trigger("blur");
      $("#customers-a-mobile")
        .removeClass("selected-a")
        .trigger("blur");
    }
  }));
}
<|endoftext|>


<commit_before>var Backbone = require('backbone');
var _ = require('underscore');
var DEBOUNCE_TIME = 350;

module.exports = Backbone.Model.extend({

  initialize: function (attrs, opts) {
    if (!opts.layerInfowindowModel) throw new Error('layerInfowindowModel is required');
    this._layerInfowindowModel = opts.layerInfowindowModel;

    this._generateSchema();
    this._initBinds();
  },

  _initBinds: function () {
    this.bind('change', _.debounce(this._onChange.bind(this), DEBOUNCE_TIME), this);
  },

  _onChange: function () {
    var self = this;

    _.each(this.changed, function (val, key) {
      // if the attr doesn't exist in the infowindowModel it will be created, BOOM
      self._layerInfowindowModel.set(key, val);
    });
  },

  _generateSchema: function () {
    this.schema = {};

    var type = this._layerInfowindowModel.get('template_name');

    if (type !== '') {
      if (this._layerInfowindowModel.has('width')) {
        this.schema.width = {
          type: 'Number',
          title: _t('editor.layers.infowindow.style.window-size'),
          validators: ['required', {
            type: 'interval',
            min: 0,
            max: 400
          }]
        };
      }
    }

    if (type === 'infowindow_color') {
      this.schema.headerColor = {
        type: 'Fill',
        title: _t('editor.layers.infowindow.style.header-color'),
        options: [],
        editorAttrs: {
          color: {
            hidePanes: ['value']
          }
        },
        validators: ['required']
      };
    }
  }

});
<commit_msg>popups: prevent form in none load, close #8281<commit_after>var Backbone = require('backbone');
var _ = require('underscore');
var DEBOUNCE_TIME = 350;

module.exports = Backbone.Model.extend({

  initialize: function (attrs, opts) {
    if (!opts.layerInfowindowModel) throw new Error('layerInfowindowModel is required');
    this._layerInfowindowModel = opts.layerInfowindowModel;

    this._generateSchema();
    this._initBinds();
  },

  _initBinds: function () {
    this.bind('change', _.debounce(this._onChange.bind(this), DEBOUNCE_TIME), this);
  },

  _onChange: function () {
    var self = this;

    _.each(this.changed, function (val, key) {
      // if the attr doesn't exist in the infowindowModel it will be created, BOOM
      self._layerInfowindowModel.set(key, val);
    });
  },

  _generateSchema: function () {
    this.schema = {};

    var type = this._layerInfowindowModel.get('template_name');

    if (type !== '' || type !== 'none') {
      if (this._layerInfowindowModel.has('width')) {
        this.schema.width = {
          type: 'Number',
          title: _t('editor.layers.infowindow.style.window-size'),
          validators: ['required', {
            type: 'interval',
            min: 0,
            max: 400
          }]
        };
      }
    }

    if (type === 'infowindow_color') {
      this.schema.headerColor = {
        type: 'Fill',
        title: _t('editor.layers.infowindow.style.header-color'),
        options: [],
        editorAttrs: {
          color: {
            hidePanes: ['value']
          }
        },
        validators: ['required']
      };
    }
  }

});
<|endoftext|>


<commit_before>/* @flow */
import React, {Component} from 'react'
import {Box, Text, Icon} from '../common-adapters'
import {globalStyles, globalColors} from '../styles/style-guide'
import type {Props as IconProps} from '../common-adapters/icon'

import type {Props} from './index'
import type {Device as DeviceType} from '../constants/types/flow-types'

type RevokedHeaderState = {expanded: boolean}

class RevokedHeader extends Component<void, Props, RevokedHeaderState> {
  state: RevokedHeaderState;

  constructor (props: Props) {
    super(props)
    this.state = {
      expanded: false
    }
  }

  _toggleHeader (e) {
    this.setState({expanded: !this.state.expanded})
  }

  render () {
    const iconType = this.state.expanded ? 'fa-caret-down' : 'fa-caret-up'
    return (
      <Box>
        <Box style={stylesRevokedRow} onClick={e => this._toggleHeader(e)}>
          <Text type='BodySemibold'>Revoked devices</Text>
          <Icon type={iconType} style={{padding: 5}}/>
        </Box>
        {this.state.expanded && this.props.children}
      </Box>
    )
  }
}

type DeviceRowState = {highlighted: boolean}

class DeviceRow extends Component<void, Props, DeviceRowState> {
  state: DeviceRowState;
  props: {
    device: DeviceType,
    revoked?: boolean,
    showRemoveDevicePage?: () => void,
    showExistingDevicePage?: () => void
  };

  constructor (props) {
    super(props)
    this.state = {
      highlighted: false
    }
  }

  _highlighted (h) {
    this.setState({highlighted: h})
  }

  render () {
    const icon: IconProps.type = {
      'mobile': 'phone-bw-m',
      'desktop': 'computer-bw-s-2',
      'backup': 'paper-key-m'
    }[this.props.device.type]

    let textStyle = {fontStyle: 'italic'}
    if (this.props.revoked) {
      textStyle = {
        ...textStyle,
        color: globalColors.black40,
        textDecoration: 'line-through'
      }
    }

    return (
      <Box key={this.props.device.name} onMouseOver={e => this._highlighted(true)} onMouseOut={e => this._highlighted(false)} style={{...stylesCommonRow, backgroundColor: this.props.revoked ? globalColors.lightGrey : globalColors.white}}>
        <Box style={this.props.revoked ? stylesRevokedIconColumn : stylesIconColumn}>
          <Icon type={icon}/>
        </Box>
        <Box style={stylesCommonColumn}>
          <Box style={{...globalStyles.flexBoxRow}}>
            <Text style={textStyle} type='Header'>{this.props.device.name}</Text>
          </Box>
          <Box style={{...globalStyles.flexBoxRow}}>
            {this.props.device.isCurrent && <Text type='BodySmall'>Current device</Text>}
          </Box>
        </Box>
        <Box style={{...stylesRevokedColumn}}>
          {!this.props.revoked && this.state.highlighted && <Text style={{color: globalColors.red}} type='BodyPrimaryLink'>Revoke</Text>}
        </Box>
      </Box>
    )
  }
}

const RevokedDescription = () => (
  <Box style={stylesRevokedDescription}>
    <Text type='BodySemibold' style={{color: globalColors.black40}}>Revoked devices will no longer be able to access your Keybase account.</Text>
  </Box>
)

const RevokedDevices = ({revokedDevices}) => (
  <RevokedHeader>
    <RevokedDescription/>
    {revokedDevices.map(device => <DeviceRow key={device.name} device={device} revoked/>)}
  </RevokedHeader>
)

const DeviceHeader = ({addNewDevice}) => (
  <Box style={stylesCommonRow}>
    <Box style={stylesCommonColumn}>
      <Icon type='devices-add-s'/>
    </Box>
    <Box style={stylesCommonColumn}>
      <Text type='BodyPrimaryLink' onClick={addNewDevice}>Add new...</Text>
    </Box>
  </Box>
)

const Render = ({devices, revokedDevices, waitingForServer, addNewDevice, showRemoveDevicePage, showExistingDevicePage}: Props) => (
  <Box style={stylesContainer}>
    {<DeviceHeader addNewDevice={addNewDevice} />}
    {devices && devices.map(device => <DeviceRow key={device.name} device={device} showRemoveDevicePage={showRemoveDevicePage} showExistingDevicePage={showExistingDevicePage}/>)}
    {revokedDevices && <RevokedDevices revokedDevices={revokedDevices} />}
  </Box>
)

const stylesContainer = {
  ...globalStyles.flexBoxColumn
}

const stylesCommonRow = {
  ...globalStyles.flexBoxRow,
  alignItems: 'center',
  borderTop: 'solid 1px rgba(0, 0, 0, .1)',
  height: 60,
  justifyContent: 'center',
  padding: 8
}

const stylesRevokedRow = {
  ...stylesCommonRow,
  height: 30,
  justifyContent: 'flex-start',
  backgroundColor: globalColors.lightGrey
}

const stylesRevokedDescription = {
  ...stylesCommonRow,
  backgroundColor: globalColors.lightGrey
}

const stylesCommonColumn = {
  padding: 20
}

const stylesRevokedColumn = {
  ...stylesCommonColumn,
  alignSelf: 'center',
  flex: 1,
  textAlign: 'right',
  paddingRight: 20
}

const stylesIconColumn = {
  ...stylesCommonColumn,
  width: 65
}

const stylesRevokedIconColumn = {
  ...stylesIconColumn,
  opacity: 0.2
}

export default Render
<commit_msg>Turn DeviceRow into a stateless component<commit_after>/* @flow */
import React, {Component} from 'react'
import {Box, Text, Icon} from '../common-adapters'
import {globalStyles, globalColors} from '../styles/style-guide'
import type {Props as IconProps} from '../common-adapters/icon'

import type {Props} from './index'
import type {Device as DeviceType} from '../constants/types/flow-types'

type RevokedHeaderState = {expanded: boolean}

class RevokedHeader extends Component<void, Props, RevokedHeaderState> {
  state: RevokedHeaderState;

  constructor (props: Props) {
    super(props)
    this.state = {
      expanded: false
    }
  }

  _toggleHeader (e) {
    this.setState({expanded: !this.state.expanded})
  }

  render () {
    const iconType = this.state.expanded ? 'fa-caret-down' : 'fa-caret-up'
    return (
      <Box>
        <Box style={stylesRevokedRow} onClick={e => this._toggleHeader(e)}>
          <Text type='BodySemibold'>Revoked devices</Text>
          <Icon type={iconType} style={{padding: 5}}/>
        </Box>
        {this.state.expanded && this.props.children}
      </Box>
    )
  }
}

const DeviceRow = ({device, revoked, showRemoveDevicePage, showExistingDevicePage}) => {
  const icon: IconProps.type = {
    'mobile': 'phone-bw-m',
    'desktop': 'computer-bw-s-2',
    'backup': 'paper-key-m'
  }[device.type]

  let textStyle = {fontStyle: 'italic'}
  if (revoked) {
    textStyle = {
      ...textStyle,
      color: globalColors.black40,
      textDecoration: 'line-through'
    }
  }

  return (
    <Box
      className='existing-device-container'
      key={device.name}
      style={{...stylesCommonRow, backgroundColor: revoked ? globalColors.lightGrey : globalColors.white}}>
      <Box style={revoked ? stylesRevokedIconColumn : stylesIconColumn}>
        <Icon type={icon}/>
      </Box>
      <Box style={stylesCommonColumn}>
        <Box style={{...globalStyles.flexBoxRow}}>
          <Text style={textStyle} type='Header'>{device.name}</Text>
        </Box>
        <Box style={{...globalStyles.flexBoxRow}}>
          {device.isCurrent && <Text type='BodySmall'>Current device</Text>}
        </Box>
      </Box>
      <Box style={{...stylesRevokedColumn}}>
        {!revoked && <Text className='existing-device-item' style={{color: globalColors.red}} type='BodyPrimaryLink'>Revoke</Text>}
      </Box>
    </Box>
  )
}

const RevokedDescription = () => (
  <Box style={stylesRevokedDescription}>
    <Text type='BodySemibold' style={{color: globalColors.black40}}>Revoked devices will no longer be able to access your Keybase account.</Text>
  </Box>
)

const RevokedDevices = ({revokedDevices}) => (
  <RevokedHeader>
    <RevokedDescription/>
    {revokedDevices.map(device => <DeviceRow key={device.name} device={device} revoked/>)}
  </RevokedHeader>
)

const DeviceHeader = ({addNewDevice}) => (
  <Box style={stylesCommonRow}>
    <Box style={stylesCommonColumn}>
      <Icon type='devices-add-s'/>
    </Box>
    <Box style={stylesCommonColumn}>
      <Text type='BodyPrimaryLink' onClick={addNewDevice}>Add new...</Text>
    </Box>
  </Box>
)

const Render = ({devices, revokedDevices, waitingForServer, addNewDevice, showRemoveDevicePage, showExistingDevicePage}: Props) => {
  const realCSS = `
  .existing-device-container .existing-device-item {
    display: none;
  }
  .existing-device-container:hover .existing-device-item {
    display: block;
  }
  `
  return (
    <Box style={stylesContainer}>
      {<DeviceHeader addNewDevice={addNewDevice} />}
      <style>{realCSS}</style>
      {devices && devices.map(device => <DeviceRow key={device.name} device={device} showRemoveDevicePage={showRemoveDevicePage} showExistingDevicePage={showExistingDevicePage}/>)}
      {revokedDevices && <RevokedDevices revokedDevices={revokedDevices} />}
    </Box>
  )
}

const stylesContainer = {
  ...globalStyles.flexBoxColumn
}

const stylesCommonRow = {
  ...globalStyles.flexBoxRow,
  alignItems: 'center',
  borderTop: 'solid 1px rgba(0, 0, 0, .1)',
  height: 60,
  justifyContent: 'center',
  padding: 8
}

const stylesRevokedRow = {
  ...stylesCommonRow,
  height: 30,
  justifyContent: 'flex-start',
  backgroundColor: globalColors.lightGrey
}

const stylesRevokedDescription = {
  ...stylesCommonRow,
  backgroundColor: globalColors.lightGrey
}

const stylesCommonColumn = {
  padding: 20
}

const stylesRevokedColumn = {
  ...stylesCommonColumn,
  alignSelf: 'center',
  flex: 1,
  textAlign: 'right',
  paddingRight: 20
}

const stylesIconColumn = {
  ...stylesCommonColumn,
  width: 65
}

const stylesRevokedIconColumn = {
  ...stylesIconColumn,
  opacity: 0.2
}

export default Render
<|endoftext|>


<commit_before>import { getCell, getColumnByCell, getRowIdentity } from './util';
import ElCheckbox from 'element-ui/packages/checkbox';
import ElTooltip from 'element-ui/packages/tooltip';
import debounce from 'throttle-debounce/debounce';

export default {
  components: {
    ElCheckbox,
    ElTooltip
  },

  props: {
    store: {
      required: true
    },
    context: {},
    layout: {
      required: true
    },
    rowClassName: [String, Function],
    rowStyle: [Object, Function],
    fixed: String,
    highlight: Boolean
  },

  render(h) {
    const columnsHidden = this.columns.map((column, index) => this.isColumnHidden(index));
    return (

        <colgroup>
          {
            this._l(this.columns, column =>
              <col
                name={ column.id }
                width={ column.realWidth || column.width }
              />)
          }
        </colgroup>

          {
            this._l(this.data, (row, $index) =>
              [
 this.handleDoubleClick($event, row) }
                on-click={ ($event) => this.handleClick($event, row) }
                on-contextmenu={ ($event) => this.handleContextMenu($event, row) }
                on-mouseenter={ _ => this.handleMouseEnter($index) }
                on-mouseleave={ _ => this.handleMouseLeave() }
                class={ [this.getRowClass(row, $index)] }>
                {
                  this._l(this.columns, (column, cellIndex) =>
                     this.handleCellMouseEnter($event, row) }
                      on-mouseleave={ this.handleCellMouseLeave }>
                      {
                        column.renderCell.call(this._renderProxy, h, { row, column, $index, store: this.store, _self: this.context || this.table.$vnode.context }, columnsHidden[cellIndex])
                      }

                  )
                }
                {
                  !this.fixed && this.layout.scrollY && this.layout.gutterWidth ?  : ''
                }

,
                this.store.states.expandRows.indexOf(row) > -1
                ? (

                      { this.table.renderExpanded ? this.table.renderExpanded(h, { row, $index, store: this.store }) : ''}

)
                : ''
              ]
            ).concat(
              <el-tooltip effect={ this.table.tooltipEffect } placement="top" ref="tooltip" content={ this.tooltipContent }></el-tooltip>
            )
          }

    );
  },

  watch: {
    'store.states.hoverRow'(newVal, oldVal) {
      if (!this.store.states.isComplex) return;
      const el = this.$el;
      if (!el) return;
      const rows = el.querySelectorAll('tbody > tr');
      const oldRow = rows[oldVal];
      const newRow = rows[newVal];
      if (oldRow) {
        oldRow.classList.remove('hover-row');
      }
      if (newRow) {
        newRow.classList.add('hover-row');
      }
    },
    'store.states.currentRow'(newVal, oldVal) {
      if (!this.highlight) return;
      const el = this.$el;
      if (!el) return;
      const data = this.store.states.data;
      const rows = el.querySelectorAll('tbody > tr');
      const oldRow = rows[data.indexOf(oldVal)];
      const newRow = rows[data.indexOf(newVal)];
      if (oldRow) {
        oldRow.classList.remove('current-row');
      } else if (rows) {
        [].forEach.call(rows, row => row.classList.remove('current-row'));
      }
      if (newRow) {
        newRow.classList.add('current-row');
      }
    }
  },

  computed: {
    table() {
      return this.$parent;
    },

    data() {
      return this.store.states.data;
    },

    columnsCount() {
      return this.store.states.columns.length;
    },

    leftFixedCount() {
      return this.store.states.fixedColumns.length;
    },

    rightFixedCount() {
      return this.store.states.rightFixedColumns.length;
    },

    columns() {
      return this.store.states.columns;
    }
  },

  data() {
    return {
      tooltipContent: ''
    };
  },

  created() {
    this.activateTooltip = debounce(50, tooltip => tooltip.handleShowPopper());
  },

  methods: {
    getKeyOfRow(row, index) {
      const rowKey = this.table.rowKey;
      if (rowKey) {
        return getRowIdentity(row, rowKey);
      }
      return index;
    },

    isColumnHidden(index) {
      if (this.fixed === true || this.fixed === 'left') {
        return index >= this.leftFixedCount;
      } else if (this.fixed === 'right') {
        return index < this.columnsCount - this.rightFixedCount;
      } else {
        return (index < this.leftFixedCount) || (index >= this.columnsCount - this.rightFixedCount);
      }
    },

    getRowStyle(row, index) {
      const rowStyle = this.rowStyle;
      if (typeof rowStyle === 'function') {
        return rowStyle.call(null, row, index);
      }
      return rowStyle;
    },

    getRowClass(row, index) {
      const classes = [];

      const rowClassName = this.rowClassName;
      if (typeof rowClassName === 'string') {
        classes.push(rowClassName);
      } else if (typeof rowClassName === 'function') {
        classes.push(rowClassName.call(null, row, index) || '');
      }

      return classes.join(' ');
    },

    handleCellMouseEnter(event, row) {
      const table = this.table;
      const cell = getCell(event);

      if (cell) {
        const column = getColumnByCell(table, cell);
        const hoverState = table.hoverState = {cell, column, row};
        table.$emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, event);
      }

      // 判断是否text-overflow, 如果是就显示tooltip
      const cellChild = event.target.querySelector('.cell');

      if (cellChild.scrollWidth > cellChild.offsetWidth) {
        const tooltip = this.$refs.tooltip;

        this.tooltipContent = cell.innerText;
        tooltip.referenceElm = cell;
        tooltip.doDestroy();
        this.activateTooltip(tooltip);
      }
    },

    handleCellMouseLeave(event) {
      this.$refs.tooltip.handleClosePopper();
      const cell = getCell(event);
      if (!cell) return;

      const oldHoverState = this.table.hoverState;
      this.table.$emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, event);
    },

    handleMouseEnter(index) {
      this.store.commit('setHoverRow', index);
    },

    handleMouseLeave() {
      this.store.commit('setHoverRow', null);
    },

    handleContextMenu(event, row) {
      this.handleEvent(event, row, 'contextmenu');
    },

    handleDoubleClick(event, row) {
      this.handleEvent(event, row, 'dblclick');
    },

    handleClick(event, row) {
      this.store.commit('setCurrentRow', row);
      this.handleEvent(event, row, 'click');
    },

    handleEvent(event, row, name) {
      const table = this.table;
      const cell = getCell(event);
      let column;
      if (cell) {
        column = getColumnByCell(table, cell);
        if (column) {
          table.$emit(`cell-${name}`, row, column, cell, event);
        }
      }
      table.$emit(`row-${name}`, row, event, column);
    },

    handleExpandClick(row) {
      this.store.commit('toggleRowExpanded', row);
    }
  }
};
<commit_msg>Table: improveper formance for init tooltip, fixed #3836<commit_after>import { getCell, getColumnByCell, getRowIdentity } from './util';
import { hasClass } from 'element-ui/src/utils/dom';
import ElCheckbox from 'element-ui/packages/checkbox';
import ElTooltip from 'element-ui/packages/tooltip';
import debounce from 'throttle-debounce/debounce';

export default {
  components: {
    ElCheckbox,
    ElTooltip
  },

  props: {
    store: {
      required: true
    },
    context: {},
    layout: {
      required: true
    },
    rowClassName: [String, Function],
    rowStyle: [Object, Function],
    fixed: String,
    highlight: Boolean
  },

  render(h) {
    const columnsHidden = this.columns.map((column, index) => this.isColumnHidden(index));
    return (

        <colgroup>
          {
            this._l(this.columns, column =>
              <col
                name={ column.id }
                width={ column.realWidth || column.width }
              />)
          }
        </colgroup>

          {
            this._l(this.data, (row, $index) =>
              [
 this.handleDoubleClick($event, row) }
                on-click={ ($event) => this.handleClick($event, row) }
                on-contextmenu={ ($event) => this.handleContextMenu($event, row) }
                on-mouseenter={ _ => this.handleMouseEnter($index) }
                on-mouseleave={ _ => this.handleMouseLeave() }
                class={ [this.getRowClass(row, $index)] }>
                {
                  this._l(this.columns, (column, cellIndex) =>
                     this.handleCellMouseEnter($event, row) }
                      on-mouseleave={ this.handleCellMouseLeave }>
                      {
                        column.renderCell.call(this._renderProxy, h, { row, column, $index, store: this.store, _self: this.context || this.table.$vnode.context }, columnsHidden[cellIndex])
                      }

                  )
                }
                {
                  !this.fixed && this.layout.scrollY && this.layout.gutterWidth ?  : ''
                }

,
                this.store.states.expandRows.indexOf(row) > -1
                ? (

                      { this.table.renderExpanded ? this.table.renderExpanded(h, { row, $index, store: this.store }) : ''}

)
                : ''
              ]
            ).concat(
              <el-tooltip effect={ this.table.tooltipEffect } placement="top" ref="tooltip" content={ this.tooltipContent }></el-tooltip>
            )
          }

    );
  },

  watch: {
    'store.states.hoverRow'(newVal, oldVal) {
      if (!this.store.states.isComplex) return;
      const el = this.$el;
      if (!el) return;
      const rows = el.querySelectorAll('tbody > tr');
      const oldRow = rows[oldVal];
      const newRow = rows[newVal];
      if (oldRow) {
        oldRow.classList.remove('hover-row');
      }
      if (newRow) {
        newRow.classList.add('hover-row');
      }
    },
    'store.states.currentRow'(newVal, oldVal) {
      if (!this.highlight) return;
      const el = this.$el;
      if (!el) return;
      const data = this.store.states.data;
      const rows = el.querySelectorAll('tbody > tr');
      const oldRow = rows[data.indexOf(oldVal)];
      const newRow = rows[data.indexOf(newVal)];
      if (oldRow) {
        oldRow.classList.remove('current-row');
      } else if (rows) {
        [].forEach.call(rows, row => row.classList.remove('current-row'));
      }
      if (newRow) {
        newRow.classList.add('current-row');
      }
    }
  },

  computed: {
    table() {
      return this.$parent;
    },

    data() {
      return this.store.states.data;
    },

    columnsCount() {
      return this.store.states.columns.length;
    },

    leftFixedCount() {
      return this.store.states.fixedColumns.length;
    },

    rightFixedCount() {
      return this.store.states.rightFixedColumns.length;
    },

    columns() {
      return this.store.states.columns;
    }
  },

  data() {
    return {
      tooltipContent: ''
    };
  },

  created() {
    this.activateTooltip = debounce(50, tooltip => tooltip.handleShowPopper());
  },

  methods: {
    getKeyOfRow(row, index) {
      const rowKey = this.table.rowKey;
      if (rowKey) {
        return getRowIdentity(row, rowKey);
      }
      return index;
    },

    isColumnHidden(index) {
      if (this.fixed === true || this.fixed === 'left') {
        return index >= this.leftFixedCount;
      } else if (this.fixed === 'right') {
        return index < this.columnsCount - this.rightFixedCount;
      } else {
        return (index < this.leftFixedCount) || (index >= this.columnsCount - this.rightFixedCount);
      }
    },

    getRowStyle(row, index) {
      const rowStyle = this.rowStyle;
      if (typeof rowStyle === 'function') {
        return rowStyle.call(null, row, index);
      }
      return rowStyle;
    },

    getRowClass(row, index) {
      const classes = [];

      const rowClassName = this.rowClassName;
      if (typeof rowClassName === 'string') {
        classes.push(rowClassName);
      } else if (typeof rowClassName === 'function') {
        classes.push(rowClassName.call(null, row, index) || '');
      }

      return classes.join(' ');
    },

    handleCellMouseEnter(event, row) {
      const table = this.table;
      const cell = getCell(event);

      if (cell) {
        const column = getColumnByCell(table, cell);
        const hoverState = table.hoverState = {cell, column, row};
        table.$emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, event);
      }

      // 判断是否text-overflow, 如果是就显示tooltip
      const cellChild = event.target.querySelector('.cell');

      if (hasClass(cellChild, 'el-tooltip') && cellChild.scrollWidth > cellChild.offsetWidth) {
        const tooltip = this.$refs.tooltip;

        this.tooltipContent = cell.innerText;
        tooltip.referenceElm = cell;
        tooltip.doDestroy();
        this.activateTooltip(tooltip);
      }
    },

    handleCellMouseLeave(event) {
      this.$refs.tooltip.handleClosePopper();
      const cell = getCell(event);
      if (!cell) return;

      const oldHoverState = this.table.hoverState;
      this.table.$emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, event);
    },

    handleMouseEnter(index) {
      this.store.commit('setHoverRow', index);
    },

    handleMouseLeave() {
      this.store.commit('setHoverRow', null);
    },

    handleContextMenu(event, row) {
      this.handleEvent(event, row, 'contextmenu');
    },

    handleDoubleClick(event, row) {
      this.handleEvent(event, row, 'dblclick');
    },

    handleClick(event, row) {
      this.store.commit('setCurrentRow', row);
      this.handleEvent(event, row, 'click');
    },

    handleEvent(event, row, name) {
      const table = this.table;
      const cell = getCell(event);
      let column;
      if (cell) {
        column = getColumnByCell(table, cell);
        if (column) {
          table.$emit(`cell-${name}`, row, column, cell, event);
        }
      }
      table.$emit(`row-${name}`, row, event, column);
    },

    handleExpandClick(row) {
      this.store.commit('toggleRowExpanded', row);
    }
  }
};
<|endoftext|>


<commit_before>import Ember from 'ember';
import config from './config/environment';

var Router = Ember.Router.extend({
  location: config.locationType
});

Router.map(function() {
  this.route('home', { path: "/" });
  this.resource('channels', { path: "/c/"}, function() {
    this.route('new', { path: "/new"});
    this.route('connect', { path: "/:id"});
  });
  this.route('terms-and-conditions');
});

export default Router;
<commit_msg>Terms and conditions isn't a route anymore<commit_after>import Ember from 'ember';
import config from './config/environment';

var Router = Ember.Router.extend({
  location: config.locationType
});

Router.map(function() {
  this.route('home', { path: "/" });
  this.resource('channels', { path: "/c/"}, function() {
    this.route('new', { path: "/new"});
    this.route('connect', { path: "/:id"});
  });
});

export default Router;
<|endoftext|>


<commit_before>"use-strict";

function animation() {
    var e = document.getElementById("animations");
    var userSelect = e.options[e.selectedIndex].value;

    if (userSelect == "bounce") {
        console.log("Bounce Selected");
        return aBounce();

    } else if (userSelect == "flash") {
        console.log("Flash Selected");
        return bFlash();

    } else if (userSelect == "pulse") {
        console.log("Pulse Selected");
        return cPulse();

    } else if (userSelect == "rubber band") {
        console.log("Rubber Band Selected");
        return dRubberBand();

    } else if (userSelect == "shake") {
        console.log("Shake Selected");
        return eShake();

    } else if (userSelect == "swing") {
        console.log("Swing Selected");
        return fSwing();

    } else if (userSelect == "tada") {
        console.log("Tada Selected");
        return gTada();
    }
     else if (userSelect == "wobble") {
        console.log("Wobble Selected");
        return hWobble();
    }
     else if (userSelect == "jello") {
        console.log("Jello Selected");
        return iJello();
    }
     else if (userSelect == "bounceIn") {
        console.log("bounceIn Selected");
        return jBounceIn();
    }
     else if (userSelect == "bounceInDown") {
        console.log("bounceInDown Selected");
        return kBounceInDown();
    }
      else if (userSelect == "bounceInLeft") {
        console.log("bounceInLeft Selected");
        return lBounceInLeft();
    }
      else if (userSelect == "bounceInRight") {
        console.log("bounceInRight Selected");
        return mBounceInRight();
    }
     else if (userSelect == "bounceInUp") {
        console.log("bounceInUp Selected");
        return nBounceInUp();
    }
     else if (userSelect == "bounceOut") {
        console.log("bounceOut Selected");
        return oBounceOut();
    }
    else if (userSelect == "bounceOutDown") {
        console.log("bounceOutDown Selected");
        return pBounceOutDown();
    }
    else if (userSelect == "bounceOutLeft") {
        console.log("bounceOutLeft Selected");
        return qBounceOutLeft();
    }
    else if (userSelect == "bounceOutRight") {
        console.log("bounceOutRight Selected");
        return rBounceOutRight();
    }
    else if (userSelect == "bounceOutUp") {
        console.log("bounceOutUp Selected");
        return sBounceOutUp();
    }
    else if (userSelect == "fadeIn") {
        console.log("fadeIn Selected");
        return tfadeIn();
    }
    else if (userSelect == "fadeInDown") {
        console.log("fadeInDown Selected");
        return ufadeInDown();
    }
    else if (userSelect == "fadeInDownBig") {
        console.log("fadeInDownBig Selected");
        return vfadeInDownBig();
    }
    else if (userSelect == "fadeInLeft") {
        console.log("fadeInLeft Selected");
        return wfadeInLeft();
    }
    else if (userSelect == "fadeInLeftBig") {
        console.log("fadeInLeft Selected");
        return xfadeInLeftBig();
    }
    else if (userSelect == "fadeInRight") {
        console.log("fadeInRight Selected");
        return yfadeInRight();
    }
    else if (userSelect == "fadeInRightBig") {
        console.log("fadeInRightBig Selected");
        return zfadeInRightBig();
    }
    else if (userSelect == "fadeInUp") {
        console.log("fadeInUp Selected");
        return aafadeInUp();
    }
    else if (userSelect == "fadeInUpBig") {
        console.log("fadeInUpBig Selected");
        return abfadeInUpBig();
    }
    else if (userSelect == "fadeOut") {
        console.log("fadeOut Selected");
        return acfadeOut();
    }
    else if (userSelect == "fadeOutDown") {
        console.log("fadeOutDown Selected");
        return adfadeOutDown();
    }
    else if (userSelect == "fadeOutDownBig") {
        console.log("fadeOutDownBig Selected");
        return aefadeOutDownBig();
    }
    else if (userSelect == "fadeOutLeft") {
        console.log("fadeOutLeft Selected");
        return affadeOutLeft();
    }
    else if (userSelect == "fadeOutLeftBig") {
        console.log("fadeOutLeftBig Selected");
        return agfadeOutLeftBig();
    }
    else if (userSelect == "fadeOutRight") {
        console.log("fadeOutRight Selected");
        return ahfadeOutRight();
    }
    else if (userSelect == "fadeOutRightBig") {
        console.log("fadeOutRightBig Selected");
        return aifadeOutRightBig();
    }
    else if (userSelect == "fadeOutUp") {
        console.log("fadeOutUp Selected");
        return ajfadeOutUp();
    }
    else if (userSelect == "fadeOutUpBig") {
        console.log("fadeOutUpBig Selected");
        return akfadeOutUpBig();
    }
    else if (userSelect == "flip") {
        console.log("flip Selected");
        return alflip();
    }
    else if (userSelect == "flipInX") {
        console.log("flipInX Selected");
        return amflipInX();
    }
    else if (userSelect == "flipInY") {
        console.log("flipInY Selected");
        return anflipInY();
    }
    else if (userSelect == "flipOutX") {
        console.log("flipOutX Selected");
        return aoflipOutX();
    }
    else if (userSelect == "flipOutY") {
        console.log("flipOutY Selected");
        return apflipOutY();
    }

    else {
        return false; // Do Nothing
    }
}

function aBounce() {
    TweenMax.to("#texts", 1, {onStart: bounce});
}

function bFlash() {
    TweenMax.to("#texts", 1, {onStart: flash});
}

function cPulse() {
    TweenMax.to("#texts", 1, {onStart: pulse});
}

function dRubberBand() {
    TweenMax.to("#texts", 1, {onStart: rubberBand});
}

function eShake() {
    TweenMax.to("#texts", 1, {onStart: shake});
}

function fSwing() {
    TweenMax.to("#texts", 1, {onStart: swing});
}

function gTada() {
    TweenMax.to("#texts", 1, {onStart: tada});
}

function hWobble() {
    TweenMax.to("#texts", 1, {onStart: wobble});
}

function iJello() {
    TweenMax.to("#texts", 1, {onStart: jello});
}

function jBounceIn() {
    TweenMax.to("#texts", 1, {onStart: bounceIn});
}

function kBounceInDown() {
    TweenMax.to("#texts", 1, {onStart: bounceInDown});
}

function lBounceInLeft() {
    TweenMax.to("#texts", 1, {onStart: bounceInLeft});
}

function mBounceInRight() {
    TweenMax.to("#texts", 1, {onStart: bounceInRight});
}

function nBounceInUp() {
    TweenMax.to("#texts", 1, {onStart: bounceInUp});
}

function oBounceOut() {
    TweenMax.to("#texts", 1, {onStart: bounceOut});
}

function pBounceOutDown() {
    TweenMax.to("#texts", 1, {onStart: bounceOutDown});
}

function qBounceOutLeft() {
    TweenMax.to("#texts", 1, {onStart: bounceOutLeft});
}

function rBounceOutRight() {
    TweenMax.to("#texts", 1, {onStart: bounceOutRight});
}

function sBounceOutUp() {
    TweenMax.to("#texts", 1, {onStart: bounceOutUp});
}

function tfadeIn() {
    TweenMax.to("#texts", 1, {onStart: fadeIn});
}

function ufadeInDown() {
    TweenMax.to("#texts", 1, {onStart: fadeInDown});
}

function vfadeInDownBig() {
    TweenMax.to("#texts", 1, {onStart: fadeInDownBig});
}

function wfadeInLeft() {
    TweenMax.to("#texts", 1, {onStart: fadeInLeft});
}

function xfadeInLeftBig() {
    TweenMax.to("#texts", 1, {onStart: fadeInLeftBig});
}

function yfadeInRight() {
    TweenMax.to("#texts", 1, {onStart: fadeInRight});
}

function zfadeInRightBig() {
    TweenMax.to("#texts", 1, {onStart: fadeInRightBig});
}

function aafadeInUp() {
    TweenMax.to("#texts", 1, {onStart: fadeInUp});
}

function abfadeInUpBig() {
    TweenMax.to("#texts", 1, {onStart: fadeInUpBig});
}

function acfadeOut() {
    TweenMax.to("#texts", 1, {onStart: fadeOut});
}

function adfadeOutDown() {
    TweenMax.to("#texts", 1, {onStart: fadeOutDown});
}

function aefadeOutDownBig() {
    TweenMax.to("#texts", 1, {onStart: fadeOutDownBig});
}

function affadeOutLeft() {
    TweenMax.to("#texts", 1, {onStart: fadeOutLeft});
}

function agfadeOutLeftBig() {
    TweenMax.to("#texts", 1, {onStart: fadeOutLeftBig});
}

function ahfadeOutRight() {
    TweenMax.to("#texts", 1, {onStart: fadeOutRight});
}

function aifadeOutRightBig() {
    TweenMax.to("#texts", 1, {onStart: fadeOutRightBig});
}

function ajfadeOutUp() {
    TweenMax.to("#texts", 1, {onStart: fadeOutUp});
}

function akfadeOutUpBig() {
    TweenMax.to("#texts", 1, {onStart: fadeOutUpBig});
}

function alflip() {
    TweenMax.to("#texts", 1, {onStart: flip});
}

function amflipInX() {
    TweenMax.to("#texts", 1, {onStart: flipInX});
}

function anflipInY() {
    TweenMax.to("#texts", 1, {onStart: flipInY});
}

function aoflipOutX() {
    TweenMax.to("#texts", 1, {onStart: flipOutX});
}

function apflipOutY() {
    TweenMax.to("#texts", 1, {onStart: flipOutY});
}

<commit_msg>commit<commit_after>"use-strict";

function animation() {
    var e = document.getElementById("animations");
    var userSelect = e.options[e.selectedIndex].value;

    if (userSelect == "bounce") {
        console.log("Bounce Selected");
        return aBounce();

    } else if (userSelect == "flash") {
        console.log("Flash Selected");
        return bFlash();

    } else if (userSelect == "pulse") {
        console.log("Pulse Selected");
        return cPulse();

    } else if (userSelect == "rubber band") {
        console.log("Rubber Band Selected");
        return dRubberBand();

    } else if (userSelect == "shake") {
        console.log("Shake Selected");
        return eShake();

    } else if (userSelect == "swing") {
        console.log("Swing Selected");
        return fSwing();

    } else if (userSelect == "tada") {
        console.log("Tada Selected");
        return gTada();
    }
     else if (userSelect == "wobble") {
        console.log("Wobble Selected");
        return hWobble();
    }
     else if (userSelect == "jello") {
        console.log("Jello Selected");
        return iJello();
    }
     else if (userSelect == "bounceIn") {
        console.log("bounceIn Selected");
        return jBounceIn();
    }
     else if (userSelect == "bounceInDown") {
        console.log("bounceInDown Selected");
        return kBounceInDown();
    }
      else if (userSelect == "bounceInLeft") {
        console.log("bounceInLeft Selected");
        return lBounceInLeft();
    }
      else if (userSelect == "bounceInRight") {
        console.log("bounceInRight Selected");
        return mBounceInRight();
    }
     else if (userSelect == "bounceInUp") {
        console.log("bounceInUp Selected");
        return nBounceInUp();
    }
     else if (userSelect == "bounceOut") {
        console.log("bounceOut Selected");
        return oBounceOut();
    }
    else if (userSelect == "bounceOutDown") {
        console.log("bounceOutDown Selected");
        return pBounceOutDown();
    }
    else if (userSelect == "bounceOutLeft") {
        console.log("bounceOutLeft Selected");
        return qBounceOutLeft();
    }
    else if (userSelect == "bounceOutRight") {
        console.log("bounceOutRight Selected");
        return rBounceOutRight();
    }
    else if (userSelect == "bounceOutUp") {
        console.log("bounceOutUp Selected");
        return sBounceOutUp();
    }
    else if (userSelect == "fadeIn") {
        console.log("fadeIn Selected");
        return tfadeIn();
    }
    else if (userSelect == "fadeInDown") {
        console.log("fadeInDown Selected");
        return ufadeInDown();
    }
    else if (userSelect == "fadeInDownBig") {
        console.log("fadeInDownBig Selected");
        return vfadeInDownBig();
    }
    else if (userSelect == "fadeInLeft") {
        console.log("fadeInLeft Selected");
        return wfadeInLeft();
    }
    else if (userSelect == "fadeInLeftBig") {
        console.log("fadeInLeft Selected");
        return xfadeInLeftBig();
    }
    else if (userSelect == "fadeInRight") {
        console.log("fadeInRight Selected");
        return yfadeInRight();
    }
    else if (userSelect == "fadeInRightBig") {
        console.log("fadeInRightBig Selected");
        return zfadeInRightBig();
    }
    else if (userSelect == "fadeInUp") {
        console.log("fadeInUp Selected");
        return aafadeInUp();
    }
    else if (userSelect == "fadeInUpBig") {
        console.log("fadeInUpBig Selected");
        return abfadeInUpBig();
    }
    else if (userSelect == "fadeOut") {
        console.log("fadeOut Selected");
        return acfadeOut();
    }
    else if (userSelect == "fadeOutDown") {
        console.log("fadeOutDown Selected");
        return adfadeOutDown();
    }
    else if (userSelect == "fadeOutDownBig") {
        console.log("fadeOutDownBig Selected");
        return aefadeOutDownBig();
    }
    else if (userSelect == "fadeOutLeft") {
        console.log("fadeOutLeft Selected");
        return affadeOutLeft();
    }
    else if (userSelect == "fadeOutLeftBig") {
        console.log("fadeOutLeftBig Selected");
        return agfadeOutLeftBig();
    }
    else if (userSelect == "fadeOutRight") {
        console.log("fadeOutRight Selected");
        return ahfadeOutRight();
    }
    else if (userSelect == "fadeOutRightBig") {
        console.log("fadeOutRightBig Selected");
        return aifadeOutRightBig();
    }
    else if (userSelect == "fadeOutUp") {
        console.log("fadeOutUp Selected");
        return ajfadeOutUp();
    }
    else if (userSelect == "fadeOutUpBig") {
        console.log("fadeOutUpBig Selected");
        return akfadeOutUpBig();
    }
    else if (userSelect == "flip") {
        console.log("flip Selected");
        return alflip();
    }
    else if (userSelect == "flipInX") {
        console.log("flipInX Selected");
        return amflipInX();
    }
    else if (userSelect == "flipInY") {
        console.log("flipInY Selected");
        return anflipInY();
    }
    else if (userSelect == "flipOutX") {
        console.log("flipOutX Selected");
        return aoflipOutX();
    }
    else if (userSelect == "flipOutY") {
        console.log("flipOutY Selected");
        return apflipOutY();
    }

    else {
        return false; // Do Nothing
    }
}

function aBounce() {
    TweenMax.to("#texts", 1, {onStart: bounce});
}

function bFlash() {
    TweenMax.to("#texts", 1, {onStart: flash});
}

function cPulse() {
    TweenMax.to("#texts", 1, {onStart: pulse});
}

function dRubberBand() {
    TweenMax.to("#texts", 1, {onStart: rubberBand});
}

function eShake() {
    TweenMax.to("#texts", 1, {onStart: shake});
}

function fSwing() {
    TweenMax.to("#texts", 1, {onStart: swing});
}

function gTada() {
    TweenMax.to("#texts", 1, {onStart: tada});
}

function hWobble() {
    TweenMax.to("#texts", 1, {onStart: wobble});
}

function iJello() {
    TweenMax.to("#texts", 1, {onStart: jello});
}

function jBounceIn() {
    TweenMax.to("#texts", 1, {onStart: bounceIn});
}

function kBounceInDown() {
    TweenMax.to("#texts", 1, {onStart: bounceInDown});
}

function lBounceInLeft() {
    TweenMax.to("#texts", 1, {onStart: bounceInLeft});
}

function mBounceInRight() {
    TweenMax.to("#texts", 1, {onStart: bounceInRight});
}

function nBounceInUp() {
    TweenMax.to("#texts", 1, {onStart: bounceInUp});
}

function oBounceOut() {
    TweenMax.to("#texts", 1, {onStart: bounceOut});
}

function pBounceOutDown() {
    TweenMax.to("#texts", 1, {onStart: bounceOutDown});
}

function qBounceOutLeft() {
    TweenMax.to("#texts", 1, {onStart: bounceOutLeft});
}

function rBounceOutRight() {
    TweenMax.to("#texts", 1, {onStart: bounceOutRight});
}

function sBounceOutUp() {
    TweenMax.to("#texts", 1, {onStart: bounceOutUp});
}

function tfadeIn() {
    TweenMax.to("#texts", 1, {onStart: fadeIn});
}

function ufadeInDown() {
    TweenMax.to("#texts", 1, {onStart: fadeInDown});
}

function vfadeInDownBig() {
    TweenMax.to("#texts", 1, {onStart: fadeInDownBig});
}

function wfadeInLeft() {
    TweenMax.to("#texts", 1, {onStart: fadeInLeft});
}

function xfadeInLeftBig() {
    TweenMax.to("#texts", 1, {onStart: fadeInLeftBig});
}

function yfadeInRight() {
    TweenMax.to("#texts", 1, {onStart: fadeInRight});
}

function zfadeInRightBig() {
    TweenMax.to("#texts", 1, {onStart: fadeInRightBig});
}

function aafadeInUp() {
    TweenMax.to("#texts", 1, {onStart: fadeInUp});
}

function abfadeInUpBig() {
    TweenMax.to("#texts", 1, {onStart: fadeInUpBig});
}

function acfadeOut() {
    TweenMax.to("#texts", 1, {onStart: fadeOut});
}

function adfadeOutDown() {
    TweenMax.to("#texts", 1, {onStart: fadeOutDown});
}

function aefadeOutDownBig() {
    TweenMax.to("#texts", 1, {onStart: fadeOutDownBig});
}

function affadeOutLeft() {
    TweenMax.to("#texts", 1, {onStart: fadeOutLeft});
}

function agfadeOutLeftBig() {
    TweenMax.to("#texts", 1, {onStart: fadeOutLeftBig});
}

function ahfadeOutRight() {
    TweenMax.to("#texts", 1, {onStart: fadeOutRight});
}

function aifadeOutRightBig() {
    TweenMax.to("#texts", 1, {onStart: fadeOutRightBig});
}

function ajfadeOutUp() {
    TweenMax.to("#texts", 1, {onStart: fadeOutUp});
}

function akfadeOutUpBig() {
    TweenMax.to("#texts", 1, {onStart: fadeOutUpBig});
}

function alflip() {
    TweenMax.to("#texts", 1, {onStart: flip});
}

function amflipInX() {
    TweenMax.to("#texts", 1, {onStart: flipInX});
}

function anflipInY() {
    TweenMax.to("#texts", 1, {onStart: flipInY});
}

function aoflipOutX() {
    TweenMax.to("#texts", 1, {onStart: flipOutX});
}

function apflipOutY() {
    TweenMax.to("#texts", 1, {onStart: flipOutY});
}
<<<<<<< HEAD

=======
>>>>>>> c3b0a2610aa4b6c37dde2a0012ea6e02212428e1
<|endoftext|>


<commit_before>/**
 * This file contains all necessary Angular controller definitions for 'frontend.login-history' module.
 *
 * Note that this file should only contain controllers and nothing else.
 */
(function () {
  'use strict';

  angular.module('frontend.routes')
    .controller('RouteConsumersController', [
      '_', '$scope', '$stateParams', '$log', '$state', 'RoutesService','ConsumerModel','ListConfig',
      function controller(_, $scope, $stateParams, $log, $state, RoutesService, ConsumerModel, ListConfig) {

        ConsumerModel.setScope($scope, false, 'items', 'itemCount');
        $scope = angular.extend($scope, angular.copy(ListConfig.getConfig('consumer',ConsumerModel)));
        $scope.search = '';

        $scope.loading = true;
        RoutesService.consumers($stateParams.route_id)
          .then(function (response) {
            console.log("GOT ROUTE CONSUMERS", response.data)
            if (response.data.total > 0) {
              $scope.items = response.data;
              $scope.loading = false;
            } else {
              $scope.isOpenService = true;
              $scope.loading = false;
            }
          }).catch(function (err) {
          console.error("FAILED TO GET ROUTE CONSUMERS", err);
          $scope.loading = false;
        })

      }
    ])
  ;
}());
<commit_msg>Started working on route consumers<commit_after>/**
 * This file contains all necessary Angular controller definitions for 'frontend.login-history' module.
 *
 * Note that this file should only contain controllers and nothing else.
 */
(function () {
  'use strict';

  angular.module('frontend.routes')
    .controller('RouteConsumersController', [
      '_', '$scope', '$stateParams', '$log', '$state', 'RoutesService','ConsumerModel','ListConfig',
      function controller(_, $scope, $stateParams, $log, $state, RoutesService, ConsumerModel, ListConfig) {

        ConsumerModel.setScope($scope, false, 'items', 'itemCount');
        $scope = angular.extend($scope, angular.copy(ListConfig.getConfig('consumer',ConsumerModel)));
        $scope.search = '';

        $scope.loading = true;
        RoutesService.consumers($stateParams.route_id)
          .then(function (response) {
            console.log("GOT ROUTE CONSUMERS", response.data)
            if(response.data.data) {
              $scope.items = response.data;
              $scope.loading = false;
            }else{
              $scope.isOpenService = true;
            }

            $scope.loading = false;

          }).catch(function (err) {
          console.error("FAILED TO GET ROUTE CONSUMERS", err);
          $scope.loading = false;
        })

      }
    ])
  ;
}());
<|endoftext|>