<commit_before>openerp.web_process = function (instance) {
    var QWeb = instance.web.qweb,
          _t = instance.web._t;
    instance.web.ViewManager.include({
        start: function() {
            this._super();
            this.process_check();
            this.process_help = this.action ? this.action.help : 'Help: Not Defined';
            this.model = this.dataset.model;
            if(this.action) this.process_model = this.action.res_model;
            else this.process_model = this.model;
        },
        process_check: function() {
            var self = this,
            grandparent = this.getParent() && this.getParent().getParent(),
            view = this.views[this.views_src[0].view_type],
            $process_view = this.$element.find('.oe_process');
            if (!(grandparent instanceof instance.web.WebClient) ||
                !(view.view_type === this.views_src[0].view_type
                    && view.view_id === this.views_src[0].view_id)) {
                        $process_view.hide();
                        return;
            }
            $process_view.click(function() {
                self.initialize_process_view();
            });
        },
        initialize_process_view: function() {
            var self = this;
            this.record_id = false;
            if(this.active_view == 'form') {
                this.record_id = this.views[this.active_view].controller.datarecord.id;
            }

            $.when(this.help(), this.get_process_object()).pipe(function(help, process) {
                self.process_help = help;
                if(process && process.length) {
                    if(process.length > 1) {
                        self.process_selection = process;
                    } else {
                        self.process_id = process[0][0],
                        self.process_title = process[0][1];
                    }
                }
                return $.Deferred().resolve();
            }).pipe(function() {
                var def = $.Deferred();
                if(self.process_id) {
                    self.graph_get().done(function(res) {
                        self.process_notes = res.notes;
                        self.process_title = res.name;
                        self.process_subflows = _(res.nodes).chain()
                              .filter(function (node) { return node['subflow'] !== false; })
                              .uniq(false, function (node) { return node['subflow'][0]; }).value();
                        self.process_related = res.related;
                        def.resolve(res);
                    });
                } else def.resolve();
                return def.promise();
            }).done(function(res) {
                $.when(self.render_process_view()).done(function() {
                    if(res) self.draw_process_graph(res);
                });
            });
        },
        graph_get: function() {
            var self = this;
            var def = $.Deferred();
            this.process_id = parseInt(this.process_id, 10);

            this.process_dataset
            .call("graph_get",[this.process_id, this.model || this.dataset.model, this.record_id, [80,80,150,100]])
            .done(function(res) {
                self.process_dataset
                    .call("search_by_model",[self.model || self.dataset.model,self.session.context])
                    .done(
                    function(r) {
                        res['related'] = r;
                        def.resolve(res);
                    });
            });
            return def.promise();
        },
        help : function() {
            var def = $.Deferred();
            if(!this.subflow_model) {
                def.resolve(this.action ? (this.action.help!=false ? this.action.help : 'Help: Not Defined') : 'Help: Not Defined');
            } else {
                 var dataset = new instance.web.DataSetSearch(this, "ir.actions.act_window", this.session.context, []);
                 dataset
                    .read_slice(['help'],
                    {
                        domain: [
                            ['res_model', '=', this.subflow_model],
                            ['name', 'ilike', this.subflow_name]
                        ]
                    }
                    ).done(function(res) {
                        def.resolve(res.help || 'Help: Not Defined');
                    });
            }
            return def.promise();
        },
        get_process_object : function() {
            var self = this,
                def = $.Deferred();
            if(this.process_id)
                return def.resolve().promise();

            this.process_dataset = new instance.web.DataSet(this, "process.process", this.session.context);
            this.process_dataset
            .call("search_by_model", [self.process_model,self.session.context])
            .done(function(res) {
                if (!res.length) {
                    self.process_model = false;
                    self.get_process_object().done(def.resolve);
                }
                else {
                    def.resolve(res);
                }
            })
            .fail(def.reject);
            return def.promise();
        },
        render_process_view : function() {
            this.$element.html(QWeb.render("ProcessView", this));
            var self = this;
            this.$element.find('#edit_process').click(function() {
                self.edit_process_view();
            });
            var $parent = this.getParent().$element;
            $parent.find('#change_process').click(function() {
                self.process_selection = false,
                self.process_id = $parent.find('#select_process').val(),
                self.process_title = $.trim($parent.find('#select_process option:selected').text());
                self.initialize_process_view();
            });

            this.$element.find(".process_subflow").click(function() {
                self.process_id = this.id;
                self.initialize_process_view();
            });
        },
        draw_process_graph : function(res) {
            var self = this,
                process_graph = new Graph();
            var process_renderer = function(r, n) {
                var clip_rect = "".concat(n.node.x,",",n.node.y,",150,100");

                //Image part
                var bg = n.node.kind == "subflow" ? "node-subflow" : "node";
                bg = n.node.gray ? bg + "-gray" : bg;
                bg = n.node.active ? 'node-current': bg;

                var img_src = '/web_process/static/src/img/'+ bg + '.png';

                r['image'](img_src, n.node.x, n.node.y,150, 100)
                    .attr({"clip-rect": clip_rect})
                    .mousedown(function() {
                        return false;
                });
                //Node
                var process_node = r['rect'](n.node.x, n.node.y, 150, 100).attr({stroke: "none"});
                // Node text
                var process_node_text =  r.text(n.node.x, n.node.y, (n.node.name))
                    .attr({"fill": "#fff", "font-weight": "bold", "cursor": "pointer"});
                process_node_text.translate((process_node.getBBox().width / 2) + 5, 10);
                if(n.node.subflow) {
                    process_node_text.click(function() {
                        self.process_id = n.node.subflow[0];
                        self.subflow_model = n.node.model;
                        self.subflow_name = n.node.name;
                        self.initialize_process_view();
                    });
                }
                //Node Description
                var new_notes = n.node.notes;
                if(n.node.notes.length > 25) {
                    var to;
                    var temp_str = new_notes = '';
                    var from = to = 0;
                    while (1) {
                        from = 25;
                        temp_str = n.node.notes.substr(to ,25);
                        if (temp_str.lastIndexOf(" ") < 25 && temp_str.length >= 25) {
                            from  =  temp_str.lastIndexOf(" ");
                        }
                        new_notes += "\n" + n.node.notes.substr(to , from);
                        if(new_notes.length > n.node.notes.length) break;
                        to += from;
                    }
                }

                if(n.node.res)
                    new_notes = n.node.res.name + '\n' + new_notes;

                r.text(n.node.x+85, n.node.y+50, (new_notes));
                r['image']('/web/static/src/img/icons/gtk-info.png', n.node.x+20, n.node.y+70, 16, 16)
                    .attr({"cursor": "pointer", "title": "Help"})
                    .click(function() {
                        window.open(n.node.url || "http://doc.openerp.com/v6.0/index.php?model=" + n.node.model);
                    });

                if(n.node.menu) {
                    r['image']('/web/static/src/img/icons/gtk-jump-to.png', n.node.x+115, n.node.y+70, 16, 16)
                    .attr({"cursor": "pointer", "title": n.node.menu.name})
                    .click(function() {
                        self.jump_to_view(n.node.res_model, n.node.menu.id);
                    });
                }

                var process_set = r.set().push(process_node);
                process_set.mousedown(function() {
                    return false;
                });
                return process_set;
            };

            _.each(res['nodes'],function(node, node_id) {
                node['res_model'] = self.model,
                node['res_id'] = false,
                node['id'] = node_id;
                process_graph.addNode(node.id, {node: node,render: process_renderer});
            });

            _.each(res['transitions'], function(transitions) {
                var src = res['nodes'][transitions['source']];
                var dst = res['nodes'][transitions['target']];
                // make active
                transitions['active'] = src.active && !dst.gray;
                process_graph.addEdge(src.id, dst.id, {directed : true});
            });
            var width = $(document).width();
            var height = $(document).height();
            var layouter = new Graph.Layout.Ordered(process_graph);
            var render_process_graph = new Graph.Renderer.Raphael('process_canvas', process_graph, width, height);
        },
        jump_to_view: function(model, id) {
            var self = this;
            var dataset = new instance.web.DataSet(this, 'ir.values', this.session.context);
            dataset.call('get',
                ['action', 'tree_but_open',[['ir.ui.menu', id]], dataset.context],
                function(res) {
                    var action = res[0][res[0].length - 1];
                    self.rpc("/web/action/load", {
                        action_id: action.id,
                        context: dataset.context
                        }, function(result) {
                            var action_manager = new instance.web.ActionManager(self);
                            action_manager.replace(self.$element);
                            action_manager.do_action(result.result);
                        });
                });
        },
        edit_process_view: function() {
            var self = this;
            var action_manager = new instance.web.ActionManager(this);
            var dialog = new instance.web.Dialog(this, {
                width: 800,
                buttons : [
                    {text: _t("Cancel"), click: function() { $(this).dialog('destroy'); }},
                    {text: _t("Save"), click: function() {
                        var form_view = action_manager.inner_widget.views.form.controller;

                        form_view.do_save(function() {
                            self.initialize_process_view();
                        });
                        $(this).dialog('destroy');
                    }}
                ]
            }).open();

            action_manager.appendTo(dialog.$element);
            action_manager.do_action({
                res_model : 'process.process',
                res_id: self.process_id,
                views : [[false, 'form']],
                type : 'ir.actions.act_window',
                flags : {
                    search_view: false,
                    sidebar : false,
                    views_switcher : false,
                    action_buttons : false,
                    pager: false
                }
            });
        }
    });
};
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
<commit_msg>[FIX] avoid fucking up ViewManager#start in process: correctly return _super() result<commit_after>openerp.web_process = function (instance) {
    var QWeb = instance.web.qweb,
          _t = instance.web._t;
    instance.web.ViewManager.include({
        start: function() {
            var _super = this._super();
            this.process_check();
            this.process_help = this.action ? this.action.help : 'Help: Not Defined';
            this.model = this.dataset.model;
            if(this.action) this.process_model = this.action.res_model;
            else this.process_model = this.model;
            return _super;
        },
        process_check: function() {
            var self = this,
            grandparent = this.getParent() && this.getParent().getParent(),
            view = this.views[this.views_src[0].view_type],
            $process_view = this.$element.find('.oe_process');
            if (!(grandparent instanceof instance.web.WebClient) ||
                !(view.view_type === this.views_src[0].view_type
                    && view.view_id === this.views_src[0].view_id)) {
                        $process_view.hide();
                        return;
            }
            $process_view.click(function() {
                self.initialize_process_view();
            });
        },
        initialize_process_view: function() {
            var self = this;
            this.record_id = false;
            if(this.active_view == 'form') {
                this.record_id = this.views[this.active_view].controller.datarecord.id;
            }

            $.when(this.help(), this.get_process_object()).pipe(function(help, process) {
                self.process_help = help;
                if(process && process.length) {
                    if(process.length > 1) {
                        self.process_selection = process;
                    } else {
                        self.process_id = process[0][0],
                        self.process_title = process[0][1];
                    }
                }
                return $.Deferred().resolve();
            }).pipe(function() {
                var def = $.Deferred();
                if(self.process_id) {
                    self.graph_get().done(function(res) {
                        self.process_notes = res.notes;
                        self.process_title = res.name;
                        self.process_subflows = _(res.nodes).chain()
                              .filter(function (node) { return node['subflow'] !== false; })
                              .uniq(false, function (node) { return node['subflow'][0]; }).value();
                        self.process_related = res.related;
                        def.resolve(res);
                    });
                } else def.resolve();
                return def.promise();
            }).done(function(res) {
                $.when(self.render_process_view()).done(function() {
                    if(res) self.draw_process_graph(res);
                });
            });
        },
        graph_get: function() {
            var self = this;
            var def = $.Deferred();
            this.process_id = parseInt(this.process_id, 10);

            this.process_dataset
            .call("graph_get",[this.process_id, this.model || this.dataset.model, this.record_id, [80,80,150,100]])
            .done(function(res) {
                self.process_dataset
                    .call("search_by_model",[self.model || self.dataset.model,self.session.context])
                    .done(
                    function(r) {
                        res['related'] = r;
                        def.resolve(res);
                    });
            });
            return def.promise();
        },
        help : function() {
            var def = $.Deferred();
            if(!this.subflow_model) {
                def.resolve(this.action ? (this.action.help!=false ? this.action.help : 'Help: Not Defined') : 'Help: Not Defined');
            } else {
                 var dataset = new instance.web.DataSetSearch(this, "ir.actions.act_window", this.session.context, []);
                 dataset
                    .read_slice(['help'],
                    {
                        domain: [
                            ['res_model', '=', this.subflow_model],
                            ['name', 'ilike', this.subflow_name]
                        ]
                    }
                    ).done(function(res) {
                        def.resolve(res.help || 'Help: Not Defined');
                    });
            }
            return def.promise();
        },
        get_process_object : function() {
            var self = this,
                def = $.Deferred();
            if(this.process_id)
                return def.resolve().promise();

            this.process_dataset = new instance.web.DataSet(this, "process.process", this.session.context);
            this.process_dataset
            .call("search_by_model", [self.process_model,self.session.context])
            .done(function(res) {
                if (!res.length) {
                    self.process_model = false;
                    self.get_process_object().done(def.resolve);
                }
                else {
                    def.resolve(res);
                }
            })
            .fail(def.reject);
            return def.promise();
        },
        render_process_view : function() {
            this.$element.html(QWeb.render("ProcessView", this));
            var self = this;
            this.$element.find('#edit_process').click(function() {
                self.edit_process_view();
            });
            var $parent = this.getParent().$element;
            $parent.find('#change_process').click(function() {
                self.process_selection = false,
                self.process_id = $parent.find('#select_process').val(),
                self.process_title = $.trim($parent.find('#select_process option:selected').text());
                self.initialize_process_view();
            });

            this.$element.find(".process_subflow").click(function() {
                self.process_id = this.id;
                self.initialize_process_view();
            });
        },
        draw_process_graph : function(res) {
            var self = this,
                process_graph = new Graph();
            var process_renderer = function(r, n) {
                var clip_rect = "".concat(n.node.x,",",n.node.y,",150,100");

                //Image part
                var bg = n.node.kind == "subflow" ? "node-subflow" : "node";
                bg = n.node.gray ? bg + "-gray" : bg;
                bg = n.node.active ? 'node-current': bg;

                var img_src = '/web_process/static/src/img/'+ bg + '.png';

                r['image'](img_src, n.node.x, n.node.y,150, 100)
                    .attr({"clip-rect": clip_rect})
                    .mousedown(function() {
                        return false;
                });
                //Node
                var process_node = r['rect'](n.node.x, n.node.y, 150, 100).attr({stroke: "none"});
                // Node text
                var process_node_text =  r.text(n.node.x, n.node.y, (n.node.name))
                    .attr({"fill": "#fff", "font-weight": "bold", "cursor": "pointer"});
                process_node_text.translate((process_node.getBBox().width / 2) + 5, 10);
                if(n.node.subflow) {
                    process_node_text.click(function() {
                        self.process_id = n.node.subflow[0];
                        self.subflow_model = n.node.model;
                        self.subflow_name = n.node.name;
                        self.initialize_process_view();
                    });
                }
                //Node Description
                var new_notes = n.node.notes;
                if(n.node.notes.length > 25) {
                    var to;
                    var temp_str = new_notes = '';
                    var from = to = 0;
                    while (1) {
                        from = 25;
                        temp_str = n.node.notes.substr(to ,25);
                        if (temp_str.lastIndexOf(" ") < 25 && temp_str.length >= 25) {
                            from  =  temp_str.lastIndexOf(" ");
                        }
                        new_notes += "\n" + n.node.notes.substr(to , from);
                        if(new_notes.length > n.node.notes.length) break;
                        to += from;
                    }
                }

                if(n.node.res)
                    new_notes = n.node.res.name + '\n' + new_notes;

                r.text(n.node.x+85, n.node.y+50, (new_notes));
                r['image']('/web/static/src/img/icons/gtk-info.png', n.node.x+20, n.node.y+70, 16, 16)
                    .attr({"cursor": "pointer", "title": "Help"})
                    .click(function() {
                        window.open(n.node.url || "http://doc.openerp.com/v6.0/index.php?model=" + n.node.model);
                    });

                if(n.node.menu) {
                    r['image']('/web/static/src/img/icons/gtk-jump-to.png', n.node.x+115, n.node.y+70, 16, 16)
                    .attr({"cursor": "pointer", "title": n.node.menu.name})
                    .click(function() {
                        self.jump_to_view(n.node.res_model, n.node.menu.id);
                    });
                }

                var process_set = r.set().push(process_node);
                process_set.mousedown(function() {
                    return false;
                });
                return process_set;
            };

            _.each(res['nodes'],function(node, node_id) {
                node['res_model'] = self.model,
                node['res_id'] = false,
                node['id'] = node_id;
                process_graph.addNode(node.id, {node: node,render: process_renderer});
            });

            _.each(res['transitions'], function(transitions) {
                var src = res['nodes'][transitions['source']];
                var dst = res['nodes'][transitions['target']];
                // make active
                transitions['active'] = src.active && !dst.gray;
                process_graph.addEdge(src.id, dst.id, {directed : true});
            });
            var width = $(document).width();
            var height = $(document).height();
            var layouter = new Graph.Layout.Ordered(process_graph);
            var render_process_graph = new Graph.Renderer.Raphael('process_canvas', process_graph, width, height);
        },
        jump_to_view: function(model, id) {
            var self = this;
            var dataset = new instance.web.DataSet(this, 'ir.values', this.session.context);
            dataset.call('get',
                ['action', 'tree_but_open',[['ir.ui.menu', id]], dataset.context],
                function(res) {
                    var action = res[0][res[0].length - 1];
                    self.rpc("/web/action/load", {
                        action_id: action.id,
                        context: dataset.context
                        }, function(result) {
                            var action_manager = new instance.web.ActionManager(self);
                            action_manager.replace(self.$element);
                            action_manager.do_action(result.result);
                        });
                });
        },
        edit_process_view: function() {
            var self = this;
            var action_manager = new instance.web.ActionManager(this);
            var dialog = new instance.web.Dialog(this, {
                width: 800,
                buttons : [
                    {text: _t("Cancel"), click: function() { $(this).dialog('destroy'); }},
                    {text: _t("Save"), click: function() {
                        var form_view = action_manager.inner_widget.views.form.controller;

                        form_view.do_save(function() {
                            self.initialize_process_view();
                        });
                        $(this).dialog('destroy');
                    }}
                ]
            }).open();

            action_manager.appendTo(dialog.$element);
            action_manager.do_action({
                res_model : 'process.process',
                res_id: self.process_id,
                views : [[false, 'form']],
                type : 'ir.actions.act_window',
                flags : {
                    search_view: false,
                    sidebar : false,
                    views_switcher : false,
                    action_buttons : false,
                    pager: false
                }
            });
        }
    });
};
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
<|endoftext|>


<commit_before>const request = require('request')
const ProgressBar = require('progress')
const tmpdir = require('os-tmpdir')
const mkdirp = require('mkdirp')
const path = require('path')
const fs = require('fs')
const checksum = require('checksum')
const rimraf = require('rimraf')

const tar = require('tar')
const zlib = require('zlib')

const config = {
  outputPath: path.join(__dirname, '..', 'git'),
  version: '2.12.1',
  build: '145',
  source: '',
  checksum: '',
  upstreamVersion: '',
  fileName: ''
}

function formatPlatform(platform) {
  // switching this to Ubuntu to ensure it's clear what we're installing here
  if (platform === 'linux') {
    return 'ubuntu'
  }
  if (platform === 'darwin') {
    return 'macOS'
  }

  return platform
}

config.fileName = `dugite-native-v${config.version}-${formatPlatform(process.platform)}-${config.build}.tar.gz`

if (process.platform === 'darwin') {
  config.checksum = '75a0d7d9bf743bc2dc2e2dfa815be39c14b5e6c7d480a10934f1f2b74cc3875e'
  config.source = 'https://github.com/desktop/dugite-native/releases/download/v2.12.1-rc1/dugite-native-v2.12.1-macOS-145.tar.gz'
} else if (process.platform === 'win32') {
  config.checksum = '6d82f4361ecb78fb1556a8c2f54711c1b76b301007a2000393cea34d363d2dcf'
  config.source = 'https://github.com/desktop/dugite-native/releases/download/v2.12.1-rc1/dugite-native-v2.12.1-win32-145.tar.gz'
} else if (process.platform === 'linux') {
  config.checksum = 'dfed95bb0bb905627cfccca7d9462a551129ea70ff20525cb85b88011d0fd513'
  config.source = 'https://github.com/desktop/dugite-native/releases/download/v2.12.1-rc1/dugite-native-v2.12.1-ubuntu-145.tar.gz'
}
const fullUrl = config.source

function handleError (url, error) {
  if (!error) {
    return
  }

  const message = error.message || error
  console.error(`Downloading ${url} failed: ${message}`)
  process.exit(1)
}

function extract (source, callback) {
  const extractor = tar.Extract({path: config.outputPath})
    .on('error', function (error) { callback(error) })
    .on('end', function () { callback() })

  fs.createReadStream(source)
    .on('error', function (error) { callback(error) })
    .pipe(zlib.Gunzip())
    .pipe(extractor)
}

const dir = tmpdir()
const temporaryFile = path.join(dir, config.fileName)

const verifyFile = function (file, callback) {
  checksum.file(file, { algorithm: 'sha256' }, (_, hash) => {

    const match = hash === config.checksum

    if (!match) {
      console.log(`Validation failed. Expected '${config.checksum}' but got '${hash}'`)
    }

    callback(match)
  })
}

const unpackFile = function (file) {
  extract(file, function (error) {
    if (error) {
      return handleError(fullUrl, error)
    }
  })
}

const downloadAndUnpack = () => {
  console.log(`Downloading Git from: ${fullUrl}`)

  const options = {
    url: fullUrl,
    headers: {
      'Accept': 'application/octet-stream',
      'User-Agent': 'dugite',
    }
  }

  const req = request.get(options)

  req.pipe(fs.createWriteStream(temporaryFile))

  req.on('error', e => {
    handleError(fullUrl, e)
  })

  req.on('response', function (res) {

    if (res.statusCode !== 200) {
      handleError(fullUrl, Error(`Non-200 response (${res.statusCode})`))
      return
    }

    const len = parseInt(res.headers['content-length'], 10)

    console.log()
    const bar = new ProgressBar('Downloading Git [:bar] :percent :etas', {
      complete: '=',
      incomplete: ' ',
      width: 50,
      total: len
    })

    res.on('data', function (chunk) {
      bar.tick(chunk.length)
    })

    res.on('end', function () {
      console.log('\n')

      verifyFile(temporaryFile, valid => {
        if (valid) {
          unpackFile(temporaryFile)
        } else {
          console.log(`checksum verification failed, refusing to unpack...`)
          process.exit(1)
        }
      })
    })
  })
}

mkdirp(config.outputPath, function (error) {
  if (error) {
    return handleError(fullUrl, error)
  }

  if (fs.existsSync(config.outputPath)) {
    try {
      rimraf.sync(config.outputPath)
    } catch (err) {
      console.error(err)
      return
    }
  }

  if (fs.existsSync(temporaryFile)) {
    verifyFile(temporaryFile, valid => {
      if (valid) {
        unpackFile(temporaryFile)
      } else {
        rimraf.sync(temporaryFile)
        downloadAndUnpack()
      }
    })
    return
  }

  downloadAndUnpack()
})
<commit_msg>compute the fileName from the URL<commit_after>const URL = require('url')
const request = require('request')
const ProgressBar = require('progress')
const tmpdir = require('os-tmpdir')
const mkdirp = require('mkdirp')
const path = require('path')
const fs = require('fs')
const checksum = require('checksum')
const rimraf = require('rimraf')

const tar = require('tar')
const zlib = require('zlib')

const config = {
  outputPath: path.join(__dirname, '..', 'git'),
  version: '2.12.1',
  build: '145',
  source: '',
  checksum: '',
  upstreamVersion: '',
  fileName: ''
}

function formatPlatform(platform) {
  // switching this to Ubuntu to ensure it's clear what we're installing here
  if (platform === 'linux') {
    return 'ubuntu'
  }
  if (platform === 'darwin') {
    return 'macOS'
  }

  return platform
}

if (process.platform === 'darwin') {
  config.checksum = '75a0d7d9bf743bc2dc2e2dfa815be39c14b5e6c7d480a10934f1f2b74cc3875e'
  config.source = 'https://github.com/desktop/dugite-native/releases/download/v2.12.1-rc1/dugite-native-v2.12.1-macOS-145.tar.gz'
} else if (process.platform === 'win32') {
  config.checksum = '6d82f4361ecb78fb1556a8c2f54711c1b76b301007a2000393cea34d363d2dcf'
  config.source = 'https://github.com/desktop/dugite-native/releases/download/v2.12.1-rc1/dugite-native-v2.12.1-win32-145.tar.gz'
} else if (process.platform === 'linux') {
  config.checksum = 'dfed95bb0bb905627cfccca7d9462a551129ea70ff20525cb85b88011d0fd513'
  config.source = 'https://github.com/desktop/dugite-native/releases/download/v2.12.1-rc1/dugite-native-v2.12.1-ubuntu-145.tar.gz'
}

const url = URL.parse(config.source)
const pathName = url.pathname
const index = pathName.lastIndexOf('/')
config.fileName = pathName.substr(index + 1)

const fullUrl = config.source

function handleError (url, error) {
  if (!error) {
    return
  }

  const message = error.message || error
  console.error(`Downloading ${url} failed: ${message}`)
  process.exit(1)
}

function extract (source, callback) {
  const extractor = tar.Extract({path: config.outputPath})
    .on('error', function (error) { callback(error) })
    .on('end', function () { callback() })

  fs.createReadStream(source)
    .on('error', function (error) { callback(error) })
    .pipe(zlib.Gunzip())
    .pipe(extractor)
}

const dir = tmpdir()
const temporaryFile = path.join(dir, config.fileName)

const verifyFile = function (file, callback) {
  checksum.file(file, { algorithm: 'sha256' }, (_, hash) => {

    const match = hash === config.checksum

    if (!match) {
      console.log(`Validation failed. Expected '${config.checksum}' but got '${hash}'`)
    }

    callback(match)
  })
}

const unpackFile = function (file) {
  extract(file, function (error) {
    if (error) {
      return handleError(fullUrl, error)
    }
  })
}

const downloadAndUnpack = () => {
  console.log(`Downloading Git from: ${fullUrl}`)

  const options = {
    url: fullUrl,
    headers: {
      'Accept': 'application/octet-stream',
      'User-Agent': 'dugite',
    }
  }

  const req = request.get(options)

  req.pipe(fs.createWriteStream(temporaryFile))

  req.on('error', e => {
    handleError(fullUrl, e)
  })

  req.on('response', function (res) {

    if (res.statusCode !== 200) {
      handleError(fullUrl, Error(`Non-200 response (${res.statusCode})`))
      return
    }

    const len = parseInt(res.headers['content-length'], 10)

    console.log()
    const bar = new ProgressBar('Downloading Git [:bar] :percent :etas', {
      complete: '=',
      incomplete: ' ',
      width: 50,
      total: len
    })

    res.on('data', function (chunk) {
      bar.tick(chunk.length)
    })

    res.on('end', function () {
      console.log('\n')

      verifyFile(temporaryFile, valid => {
        if (valid) {
          unpackFile(temporaryFile)
        } else {
          console.log(`checksum verification failed, refusing to unpack...`)
          process.exit(1)
        }
      })
    })
  })
}

mkdirp(config.outputPath, function (error) {
  if (error) {
    return handleError(fullUrl, error)
  }

  if (fs.existsSync(config.outputPath)) {
    try {
      rimraf.sync(config.outputPath)
    } catch (err) {
      console.error(err)
      return
    }
  }

  if (fs.existsSync(temporaryFile)) {
    verifyFile(temporaryFile, valid => {
      if (valid) {
        unpackFile(temporaryFile)
      } else {
        rimraf.sync(temporaryFile)
        downloadAndUnpack()
      }
    })
    return
  }

  downloadAndUnpack()
})
<|endoftext|>


<commit_before>IonicModule
.controller('$ionicSideMenus', [
  '$scope',
  '$attrs',
  '$ionicSideMenuDelegate',
  '$ionicPlatform',
  '$ionicBody',
  '$ionicHistory',
  '$ionicScrollDelegate',
function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $ionicHistory, $ionicScrollDelegate) {
  var self = this;
  var rightShowing, leftShowing, isDragging;
  var startX, lastX, offsetX, isAsideExposed;
  var enableMenuWithBackViews = true;

  self.$scope = $scope;

  self.initialize = function(options) {
    self.left = options.left;
    self.right = options.right;
    self.setContent(options.content);
    self.dragThresholdX = options.dragThresholdX || 10;
    $ionicHistory.registerHistory(self.$scope);
  };

  /**
   * Set the content view controller if not passed in the constructor options.
   *
   * @param {object} content
   */
  self.setContent = function(content) {
    if (content) {
      self.content = content;

      self.content.onDrag = function(e) {
        self._handleDrag(e);
      };

      self.content.endDrag = function(e) {
        self._endDrag(e);
      };
    }
  };

  self.isOpenLeft = function() {
    return self.getOpenAmount() > 0;
  };

  self.isOpenRight = function() {
    return self.getOpenAmount() < 0;
  };

  /**
   * Toggle the left menu to open 100%
   */
  self.toggleLeft = function(shouldOpen) {
    if (isAsideExposed || !self.left.isEnabled) return;
    var openAmount = self.getOpenAmount();
    if (arguments.length === 0) {
      shouldOpen = openAmount <= 0;
    }
    self.content.enableAnimation();
    if (!shouldOpen) {
      self.openPercentage(0);
    } else {
      self.openPercentage(100);
    }
  };

  /**
   * Toggle the right menu to open 100%
   */
  self.toggleRight = function(shouldOpen) {
    if (isAsideExposed || !self.right.isEnabled) return;
    var openAmount = self.getOpenAmount();
    if (arguments.length === 0) {
      shouldOpen = openAmount >= 0;
    }
    self.content.enableAnimation();
    if (!shouldOpen) {
      self.openPercentage(0);
    } else {
      self.openPercentage(-100);
    }
  };

  self.toggle = function(side) {
    if (side == 'right') {
      self.toggleRight();
    } else {
      self.toggleLeft();
    }
  };

  /**
   * Close all menus.
   */
  self.close = function() {
    self.openPercentage(0);
  };

  /**
   * @return {float} The amount the side menu is open, either positive or negative for left (positive), or right (negative)
   */
  self.getOpenAmount = function() {
    return self.content && self.content.getTranslateX() || 0;
  };

  /**
   * @return {float} The ratio of open amount over menu width. For example, a
   * menu of width 100 open 50 pixels would be open 50% or a ratio of 0.5. Value is negative
   * for right menu.
   */
  self.getOpenRatio = function() {
    var amount = self.getOpenAmount();
    if (amount >= 0) {
      return amount / self.left.width;
    }
    return amount / self.right.width;
  };

  self.isOpen = function() {
    return self.getOpenAmount() !== 0;
  };

  /**
   * @return {float} The percentage of open amount over menu width. For example, a
   * menu of width 100 open 50 pixels would be open 50%. Value is negative
   * for right menu.
   */
  self.getOpenPercentage = function() {
    return self.getOpenRatio() * 100;
  };

  /**
   * Open the menu with a given percentage amount.
   * @param {float} percentage The percentage (positive or negative for left/right) to open the menu.
   */
  self.openPercentage = function(percentage) {
    var p = percentage / 100;

    if (self.left && percentage >= 0) {
      self.openAmount(self.left.width * p);
    } else if (self.right && percentage < 0) {
      var maxRight = self.right.width;
      self.openAmount(self.right.width * p);
    }

    // add the CSS class "menu-open" if the percentage does not
    // equal 0, otherwise remove the class from the body element
    $ionicBody.enableClass((percentage !== 0), 'menu-open');

    freezeAllScrolls(false);
  };

  function freezeAllScrolls(shouldFreeze) {
    if (shouldFreeze && !self.isScrollFreeze) {
      $ionicScrollDelegate.freezeAllScrolls(shouldFreeze);

    } else if (!shouldFreeze && self.isScrollFreeze) {
      $ionicScrollDelegate.freezeAllScrolls(false);
    }
    self.isScrollFreeze = shouldFreeze;
  }

  /**
   * Open the menu the given pixel amount.
   * @param {float} amount the pixel amount to open the menu. Positive value for left menu,
   * negative value for right menu (only one menu will be visible at a time).
   */
  self.openAmount = function(amount) {
    var maxLeft = self.left && self.left.width || 0;
    var maxRight = self.right && self.right.width || 0;

    // Check if we can move to that side, depending if the left/right panel is enabled
    if (!(self.left && self.left.isEnabled) && amount > 0) {
      self.content.setTranslateX(0);
      return;
    }

    if (!(self.right && self.right.isEnabled) && amount < 0) {
      self.content.setTranslateX(0);
      return;
    }

    if (leftShowing && amount > maxLeft) {
      self.content.setTranslateX(maxLeft);
      return;
    }

    if (rightShowing && amount < -maxRight) {
      self.content.setTranslateX(-maxRight);
      return;
    }

    self.content.setTranslateX(amount);

    if (amount >= 0) {
      leftShowing = true;
      rightShowing = false;

      if (amount > 0) {
        // Push the z-index of the right menu down
        self.right && self.right.pushDown && self.right.pushDown();
        // Bring the z-index of the left menu up
        self.left && self.left.bringUp && self.left.bringUp();
      }
    } else {
      rightShowing = true;
      leftShowing = false;

      // Bring the z-index of the right menu up
      self.right && self.right.bringUp && self.right.bringUp();
      // Push the z-index of the left menu down
      self.left && self.left.pushDown && self.left.pushDown();
    }
  };

  /**
   * Given an event object, find the final resting position of this side
   * menu. For example, if the user "throws" the content to the right and
   * releases the touch, the left menu should snap open (animated, of course).
   *
   * @param {Event} e the gesture event to use for snapping
   */
  self.snapToRest = function(e) {
    // We want to animate at the end of this
    self.content.enableAnimation();
    isDragging = false;

    // Check how much the panel is open after the drag, and
    // what the drag velocity is
    var ratio = self.getOpenRatio();

    if (ratio === 0) {
      // Just to be safe
      self.openPercentage(0);
      return;
    }

    var velocityThreshold = 0.3;
    var velocityX = e.gesture.velocityX;
    var direction = e.gesture.direction;

    // Going right, less than half, too slow (snap back)
    if (ratio > 0 && ratio < 0.5 && direction == 'right' && velocityX < velocityThreshold) {
      self.openPercentage(0);
    }

    // Going left, more than half, too slow (snap back)
    else if (ratio > 0.5 && direction == 'left' && velocityX < velocityThreshold) {
      self.openPercentage(100);
    }

    // Going left, less than half, too slow (snap back)
    else if (ratio < 0 && ratio > -0.5 && direction == 'left' && velocityX < velocityThreshold) {
      self.openPercentage(0);
    }

    // Going right, more than half, too slow (snap back)
    else if (ratio < 0.5 && direction == 'right' && velocityX < velocityThreshold) {
      self.openPercentage(-100);
    }

    // Going right, more than half, or quickly (snap open)
    else if (direction == 'right' && ratio >= 0 && (ratio >= 0.5 || velocityX > velocityThreshold)) {
      self.openPercentage(100);
    }

    // Going left, more than half, or quickly (span open)
    else if (direction == 'left' && ratio <= 0 && (ratio <= -0.5 || velocityX > velocityThreshold)) {
      self.openPercentage(-100);
    }

    // Snap back for safety
    else {
      self.openPercentage(0);
    }
  };

  self.enableMenuWithBackViews = function(val) {
    if (arguments.length) {
      enableMenuWithBackViews = !!val;
    }
    return enableMenuWithBackViews;
  };

  self.isAsideExposed = function() {
    return !!isAsideExposed;
  };

  self.exposeAside = function(shouldExposeAside) {
    if (!(self.left && self.left.isEnabled) && !(self.right && self.right.isEnabled)) return;
    self.close();
    isAsideExposed = shouldExposeAside;
    if (self.left && self.left.isEnabled) {
      // set the left marget width if it should be exposed
      // otherwise set false so there's no left margin
      self.content.setMarginLeft(isAsideExposed ? self.left.width : 0);
    } else if (self.right && self.right.isEnabled) {
      self.content.setMarginRight(isAsideExposed ? self.right.width : 0);
    }

    self.$scope.$emit('$ionicExposeAside', isAsideExposed);
  };

  self.activeAsideResizing = function(isResizing) {
    $ionicBody.enableClass(isResizing, 'aside-resizing');
  };

  // End a drag with the given event
  self._endDrag = function(e) {
    freezeAllScrolls(false);

    if (isAsideExposed) return;

    if (isDragging) {
      self.snapToRest(e);
    }
    startX = null;
    lastX = null;
    offsetX = null;
  };

  // Handle a drag event
  self._handleDrag = function(e) {
    if (isAsideExposed || !$scope.dragContent) return;

    // If we don't have start coords, grab and store them
    if (!startX) {
      startX = e.gesture.touches[0].pageX;
      lastX = startX;
    } else {
      // Grab the current tap coords
      lastX = e.gesture.touches[0].pageX;
    }

    // Calculate difference from the tap points
    if (!isDragging && Math.abs(lastX - startX) > self.dragThresholdX) {
      // if the difference is greater than threshold, start dragging using the current
      // point as the starting point
      startX = lastX;

      isDragging = true;
      // Initialize dragging
      self.content.disableAnimation();
      offsetX = self.getOpenAmount();
    }

    if (isDragging) {
      self.openAmount(offsetX + (lastX - startX));
      freezeAllScrolls(true);
    }
  };

  self.canDragContent = function(canDrag) {
    if (arguments.length) {
      $scope.dragContent = !!canDrag;
    }
    return $scope.dragContent;
  };

  self.edgeThreshold = 25;
  self.edgeThresholdEnabled = false;
  self.edgeDragThreshold = function(value) {
    if (arguments.length) {
      if (isNumber(value) && value > 0) {
        self.edgeThreshold = value;
        self.edgeThresholdEnabled = true;
      } else {
        self.edgeThresholdEnabled = !!value;
      }
    }
    return self.edgeThresholdEnabled;
  };

  self.isDraggableTarget = function(e) {
    //Only restrict edge when sidemenu is closed and restriction is enabled
    var shouldOnlyAllowEdgeDrag = self.edgeThresholdEnabled && !self.isOpen();
    var startX = e.gesture.startEvent && e.gesture.startEvent.center &&
      e.gesture.startEvent.center.pageX;

    var dragIsWithinBounds = !shouldOnlyAllowEdgeDrag ||
      startX <= self.edgeThreshold ||
      startX >= self.content.element.offsetWidth - self.edgeThreshold;

    var backView = $ionicHistory.backView();
    var menuEnabled = enableMenuWithBackViews ? true : !backView;
    if (!menuEnabled) {
      var currentView = $ionicHistory.currentView() || {};
      return backView.historyId !== currentView.historyId;
    }

    return ($scope.dragContent || self.isOpen()) &&
      dragIsWithinBounds &&
      !e.gesture.srcEvent.defaultPrevented &&
      menuEnabled &&
      !e.target.tagName.match(/input|textarea|select|object|embed/i) &&
      !e.target.isContentEditable &&
      !(e.target.dataset ? e.target.dataset.preventScroll : e.target.getAttribute('data-prevent-scroll') == 'true');
  };

  $scope.sideMenuContentTranslateX = 0;

  var deregisterBackButtonAction = noop;
  var closeSideMenu = angular.bind(self, self.close);

  $scope.$watch(function() {
    return self.getOpenAmount() !== 0;
  }, function(isOpen) {
    deregisterBackButtonAction();
    if (isOpen) {
      deregisterBackButtonAction = $ionicPlatform.registerBackButtonAction(
        closeSideMenu,
        PLATFORM_BACK_BUTTON_PRIORITY_SIDE_MENU
      );
    }
  });

  var deregisterInstance = $ionicSideMenuDelegate._registerInstance(
    self, $attrs.delegateHandle, function() {
      return $ionicHistory.isActiveScope($scope);
    }
  );

  $scope.$on('$destroy', function() {
    deregisterInstance();
    deregisterBackButtonAction();
    self.$scope = null;
    if (self.content) {
      self.content.element = null;
      self.content = null;
    }

    // ensure scrolls are unfrozen
    freezeAllScrolls(false);
  });

  self.initialize({
    left: {
      width: 275
    },
    right: {
      width: 275
    }
  });

}]);
<commit_msg>make it resize properly with exposeAside<commit_after>IonicModule
.controller('$ionicSideMenus', [
  '$scope',
  '$attrs',
  '$ionicSideMenuDelegate',
  '$ionicPlatform',
  '$ionicBody',
  '$ionicHistory',
  '$ionicScrollDelegate',
function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $ionicHistory, $ionicScrollDelegate) {
  var self = this;
  var rightShowing, leftShowing, isDragging;
  var startX, lastX, offsetX, isAsideExposed;
  var enableMenuWithBackViews = true;

  self.$scope = $scope;

  self.initialize = function(options) {
    self.left = options.left;
    self.right = options.right;
    self.setContent(options.content);
    self.dragThresholdX = options.dragThresholdX || 10;
    $ionicHistory.registerHistory(self.$scope);
  };

  /**
   * Set the content view controller if not passed in the constructor options.
   *
   * @param {object} content
   */
  self.setContent = function(content) {
    if (content) {
      self.content = content;

      self.content.onDrag = function(e) {
        self._handleDrag(e);
      };

      self.content.endDrag = function(e) {
        self._endDrag(e);
      };
    }
  };

  self.isOpenLeft = function() {
    return self.getOpenAmount() > 0;
  };

  self.isOpenRight = function() {
    return self.getOpenAmount() < 0;
  };

  /**
   * Toggle the left menu to open 100%
   */
  self.toggleLeft = function(shouldOpen) {
    if (isAsideExposed || !self.left.isEnabled) return;
    var openAmount = self.getOpenAmount();
    if (arguments.length === 0) {
      shouldOpen = openAmount <= 0;
    }
    self.content.enableAnimation();
    if (!shouldOpen) {
      self.openPercentage(0);
    } else {
      self.openPercentage(100);
    }
  };

  /**
   * Toggle the right menu to open 100%
   */
  self.toggleRight = function(shouldOpen) {
    if (isAsideExposed || !self.right.isEnabled) return;
    var openAmount = self.getOpenAmount();
    if (arguments.length === 0) {
      shouldOpen = openAmount >= 0;
    }
    self.content.enableAnimation();
    if (!shouldOpen) {
      self.openPercentage(0);
    } else {
      self.openPercentage(-100);
    }
  };

  self.toggle = function(side) {
    if (side == 'right') {
      self.toggleRight();
    } else {
      self.toggleLeft();
    }
  };

  /**
   * Close all menus.
   */
  self.close = function() {
    self.openPercentage(0);
  };

  /**
   * @return {float} The amount the side menu is open, either positive or negative for left (positive), or right (negative)
   */
  self.getOpenAmount = function() {
    return self.content && self.content.getTranslateX() || 0;
  };

  /**
   * @return {float} The ratio of open amount over menu width. For example, a
   * menu of width 100 open 50 pixels would be open 50% or a ratio of 0.5. Value is negative
   * for right menu.
   */
  self.getOpenRatio = function() {
    var amount = self.getOpenAmount();
    if (amount >= 0) {
      return amount / self.left.width;
    }
    return amount / self.right.width;
  };

  self.isOpen = function() {
    return self.getOpenAmount() !== 0;
  };

  /**
   * @return {float} The percentage of open amount over menu width. For example, a
   * menu of width 100 open 50 pixels would be open 50%. Value is negative
   * for right menu.
   */
  self.getOpenPercentage = function() {
    return self.getOpenRatio() * 100;
  };

  /**
   * Open the menu with a given percentage amount.
   * @param {float} percentage The percentage (positive or negative for left/right) to open the menu.
   */
  self.openPercentage = function(percentage) {
    var p = percentage / 100;

    if (self.left && percentage >= 0) {
      self.openAmount(self.left.width * p);
    } else if (self.right && percentage < 0) {
      var maxRight = self.right.width;
      self.openAmount(self.right.width * p);
    }

    // add the CSS class "menu-open" if the percentage does not
    // equal 0, otherwise remove the class from the body element
    $ionicBody.enableClass((percentage !== 0), 'menu-open');

    freezeAllScrolls(false);
  };

  function freezeAllScrolls(shouldFreeze) {
    if (shouldFreeze && !self.isScrollFreeze) {
      $ionicScrollDelegate.freezeAllScrolls(shouldFreeze);

    } else if (!shouldFreeze && self.isScrollFreeze) {
      $ionicScrollDelegate.freezeAllScrolls(false);
    }
    self.isScrollFreeze = shouldFreeze;
  }

  /**
   * Open the menu the given pixel amount.
   * @param {float} amount the pixel amount to open the menu. Positive value for left menu,
   * negative value for right menu (only one menu will be visible at a time).
   */
  self.openAmount = function(amount) {
    var maxLeft = self.left && self.left.width || 0;
    var maxRight = self.right && self.right.width || 0;

    // Check if we can move to that side, depending if the left/right panel is enabled
    if (!(self.left && self.left.isEnabled) && amount > 0) {
      self.content.setTranslateX(0);
      return;
    }

    if (!(self.right && self.right.isEnabled) && amount < 0) {
      self.content.setTranslateX(0);
      return;
    }

    if (leftShowing && amount > maxLeft) {
      self.content.setTranslateX(maxLeft);
      return;
    }

    if (rightShowing && amount < -maxRight) {
      self.content.setTranslateX(-maxRight);
      return;
    }

    self.content.setTranslateX(amount);

    if (amount >= 0) {
      leftShowing = true;
      rightShowing = false;

      if (amount > 0) {
        // Push the z-index of the right menu down
        self.right && self.right.pushDown && self.right.pushDown();
        // Bring the z-index of the left menu up
        self.left && self.left.bringUp && self.left.bringUp();
      }
    } else {
      rightShowing = true;
      leftShowing = false;

      // Bring the z-index of the right menu up
      self.right && self.right.bringUp && self.right.bringUp();
      // Push the z-index of the left menu down
      self.left && self.left.pushDown && self.left.pushDown();
    }
  };

  /**
   * Given an event object, find the final resting position of this side
   * menu. For example, if the user "throws" the content to the right and
   * releases the touch, the left menu should snap open (animated, of course).
   *
   * @param {Event} e the gesture event to use for snapping
   */
  self.snapToRest = function(e) {
    // We want to animate at the end of this
    self.content.enableAnimation();
    isDragging = false;

    // Check how much the panel is open after the drag, and
    // what the drag velocity is
    var ratio = self.getOpenRatio();

    if (ratio === 0) {
      // Just to be safe
      self.openPercentage(0);
      return;
    }

    var velocityThreshold = 0.3;
    var velocityX = e.gesture.velocityX;
    var direction = e.gesture.direction;

    // Going right, less than half, too slow (snap back)
    if (ratio > 0 && ratio < 0.5 && direction == 'right' && velocityX < velocityThreshold) {
      self.openPercentage(0);
    }

    // Going left, more than half, too slow (snap back)
    else if (ratio > 0.5 && direction == 'left' && velocityX < velocityThreshold) {
      self.openPercentage(100);
    }

    // Going left, less than half, too slow (snap back)
    else if (ratio < 0 && ratio > -0.5 && direction == 'left' && velocityX < velocityThreshold) {
      self.openPercentage(0);
    }

    // Going right, more than half, too slow (snap back)
    else if (ratio < 0.5 && direction == 'right' && velocityX < velocityThreshold) {
      self.openPercentage(-100);
    }

    // Going right, more than half, or quickly (snap open)
    else if (direction == 'right' && ratio >= 0 && (ratio >= 0.5 || velocityX > velocityThreshold)) {
      self.openPercentage(100);
    }

    // Going left, more than half, or quickly (span open)
    else if (direction == 'left' && ratio <= 0 && (ratio <= -0.5 || velocityX > velocityThreshold)) {
      self.openPercentage(-100);
    }

    // Snap back for safety
    else {
      self.openPercentage(0);
    }
  };

  self.enableMenuWithBackViews = function(val) {
    if (arguments.length) {
      enableMenuWithBackViews = !!val;
    }
    return enableMenuWithBackViews;
  };

  self.isAsideExposed = function() {
    return !!isAsideExposed;
  };

  self.exposeAside = function(shouldExposeAside) {
    if (!(self.left && self.left.isEnabled) && !(self.right && self.right.isEnabled)) return;
    self.close();
    //Trigger a resize if it changed
    if (isAsideExposed !== shouldExposeAside) {
      ionic.trigger('resize', null, window);
    }
    isAsideExposed = shouldExposeAside;
    if (self.left && self.left.isEnabled) {
      // set the left marget width if it should be exposed
      // otherwise set false so there's no left margin
      self.content.setMarginLeft(isAsideExposed ? self.left.width : 0);
    } else if (self.right && self.right.isEnabled) {
      self.content.setMarginRight(isAsideExposed ? self.right.width : 0);
    }

    self.$scope.$emit('$ionicExposeAside', isAsideExposed);
  };

  self.activeAsideResizing = function(isResizing) {
    $ionicBody.enableClass(isResizing, 'aside-resizing');
  };

  // End a drag with the given event
  self._endDrag = function(e) {
    freezeAllScrolls(false);

    if (isAsideExposed) return;

    if (isDragging) {
      self.snapToRest(e);
    }
    startX = null;
    lastX = null;
    offsetX = null;
  };

  // Handle a drag event
  self._handleDrag = function(e) {
    if (isAsideExposed || !$scope.dragContent) return;

    // If we don't have start coords, grab and store them
    if (!startX) {
      startX = e.gesture.touches[0].pageX;
      lastX = startX;
    } else {
      // Grab the current tap coords
      lastX = e.gesture.touches[0].pageX;
    }

    // Calculate difference from the tap points
    if (!isDragging && Math.abs(lastX - startX) > self.dragThresholdX) {
      // if the difference is greater than threshold, start dragging using the current
      // point as the starting point
      startX = lastX;

      isDragging = true;
      // Initialize dragging
      self.content.disableAnimation();
      offsetX = self.getOpenAmount();
    }

    if (isDragging) {
      self.openAmount(offsetX + (lastX - startX));
      freezeAllScrolls(true);
    }
  };

  self.canDragContent = function(canDrag) {
    if (arguments.length) {
      $scope.dragContent = !!canDrag;
    }
    return $scope.dragContent;
  };

  self.edgeThreshold = 25;
  self.edgeThresholdEnabled = false;
  self.edgeDragThreshold = function(value) {
    if (arguments.length) {
      if (isNumber(value) && value > 0) {
        self.edgeThreshold = value;
        self.edgeThresholdEnabled = true;
      } else {
        self.edgeThresholdEnabled = !!value;
      }
    }
    return self.edgeThresholdEnabled;
  };

  self.isDraggableTarget = function(e) {
    //Only restrict edge when sidemenu is closed and restriction is enabled
    var shouldOnlyAllowEdgeDrag = self.edgeThresholdEnabled && !self.isOpen();
    var startX = e.gesture.startEvent && e.gesture.startEvent.center &&
      e.gesture.startEvent.center.pageX;

    var dragIsWithinBounds = !shouldOnlyAllowEdgeDrag ||
      startX <= self.edgeThreshold ||
      startX >= self.content.element.offsetWidth - self.edgeThreshold;

    var backView = $ionicHistory.backView();
    var menuEnabled = enableMenuWithBackViews ? true : !backView;
    if (!menuEnabled) {
      var currentView = $ionicHistory.currentView() || {};
      return backView.historyId !== currentView.historyId;
    }

    return ($scope.dragContent || self.isOpen()) &&
      dragIsWithinBounds &&
      !e.gesture.srcEvent.defaultPrevented &&
      menuEnabled &&
      !e.target.tagName.match(/input|textarea|select|object|embed/i) &&
      !e.target.isContentEditable &&
      !(e.target.dataset ? e.target.dataset.preventScroll : e.target.getAttribute('data-prevent-scroll') == 'true');
  };

  $scope.sideMenuContentTranslateX = 0;

  var deregisterBackButtonAction = noop;
  var closeSideMenu = angular.bind(self, self.close);

  $scope.$watch(function() {
    return self.getOpenAmount() !== 0;
  }, function(isOpen) {
    deregisterBackButtonAction();
    if (isOpen) {
      deregisterBackButtonAction = $ionicPlatform.registerBackButtonAction(
        closeSideMenu,
        PLATFORM_BACK_BUTTON_PRIORITY_SIDE_MENU
      );
    }
  });

  var deregisterInstance = $ionicSideMenuDelegate._registerInstance(
    self, $attrs.delegateHandle, function() {
      return $ionicHistory.isActiveScope($scope);
    }
  );

  $scope.$on('$destroy', function() {
    deregisterInstance();
    deregisterBackButtonAction();
    self.$scope = null;
    if (self.content) {
      self.content.element = null;
      self.content = null;
    }

    // ensure scrolls are unfrozen
    freezeAllScrolls(false);
  });

  self.initialize({
    left: {
      width: 275
    },
    right: {
      width: 275
    }
  });

}]);
<|endoftext|>


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

var disabledTestCasesPatterns = [
    // The following test fails, it needs to be fixed or removed:
    "test/aria/pageEngine/siteRootModule/ModelBindingTestCase.js",

    // The following test fails in all browsers except PhantomJS...
    // ... but PhantomJS is known not to correctly handle the viewport size,
    // ... and this test seems to be linked to exactly that!
    // The test needs to be fixed or removed.
    "test/aria/widgets/container/dialog/viewportResize/ViewportHugeShrinkTestCase.js"
];

var unpackagedOnlyPatterns = [
    // The following test does not work in packaged mode (because it tries to open a file from
    // the bootstrap, but it is packaged, and bootstrap files are not in the map)
    "test/aria/core/JsonValidatorTestCase.js"
];

var unpackagedPatterns = [
    // Includes a simple template test in unpackaged mode, to check that the framework
    // can correctly load a template in unpackaged mode
    "test/aria/widgets/form/datepicker/pickdate/PickDateTestCase.js"
].concat(unpackagedOnlyPatterns);

var jawsOnlyPatterns = [
    "test/**/*JawsTestCase.js"
];

var noFlashExcludesPatterns = [
    "test/aria/core/io/IOXDRTestCase.js"
];

var phantomjsExcludesPatterns = [
    // Excluded because PhantomJS has random issues with history management:
    // (to be investigated)
    "test/aria/utils/HistoryTestCase.js",
    // Excluded because PhantomJS has random issues with the viewport:
    "test/aria/widgets/container/dialog/scroll/OnScrollTestCase.js",
    "test/aria/widgets/container/dialog/resize/test3/DialogOnResizeRobotTestCase.js",
    "test/aria/widgets/container/dialog/resize/test4/DialogOnResizeScrollRobotTestCase.js",
    "test/aria/widgets/container/dialog/resize/test5/OverlayOnResizeScrollRobotTestCase.js",
    "test/aria/utils/overlay/loadingIndicator/scrollableBody/ScrollableBodyTestCase.js",
    "test/aria/utils/DomScrollIntoViewTestCase.js",
    "test/aria/widgets/form/multiselect/downArrowKeyPreventDef/MSDownArrowKeyRobotTestCase.js",
    "test/aria/widgets/container/dialog/indicators/DialogTestCase.js",
    "test/aria/widgets/container/dialog/movable/test5/MovableDialogFiveRobotTestCase.js",
    "test/aria/widgets/container/dialog/container/*TestCase.js",
    "test/aria/widgets/wai/popup/dialog/modal/SecondRobotTestCase.js",
    "test/aria/widgets/container/dialog/hiddenViewportResize/HiddenDialogViewportResizeTestCase.js",
    // Excluded because it often randomly fails with PhantomJS on travis-ci:
    "test/aria/widgets/container/tooltip/TooltipRobotTestCase.js"
];

// Some tests do not succeed in some browsers, and are listed here.
// They should be investigated and fixed.
var generalBrowserExcludes = {
    "PhantomJS": phantomjsExcludesPatterns,
    "Firefox 3": [
        "test/aria/core/io/JSONPTestCase.js",
        "test/aria/pageEngine/pageEngine/externalHashNavigation/ExternalHashNavigationTestCase.js",
        "test/aria/pageEngine/pageEngine/PageEngineFiveTestCase.js",
        "test/aria/pageEngine/pageEngine/PageEngineFourTestCase.js",
        "test/aria/pageEngine/utils/HashManagerTestCase.js",
        "test/aria/pageEngine/utils/HistoryManagerTestCase.js",
        "test/aria/storage/localStorage/EventIssueTestCase.js",
        "test/aria/utils/hashManager/HashManagerOneTestCase.js"
    ],
    "Firefox 11": [
        "test/aria/core/io/JSONPTestCase.js",
        "test/aria/pageEngine/pageEngine/PageEngineSixTestCase.js",
        "test/aria/pageEngine/pageEngine/PageEngineTemplateDisposalWithAnimationsTestCase.js",
        "test/aria/pageEngine/utils/HashManagerTestCase.js",
        "test/aria/pageEngine/utils/HistoryManagerTestCase.js",
        "test/aria/utils/css/AnimationsTestCase.js"
    ],
    "Firefox 49": [
        "test/aria/utils/events/scroll/OnscrollRobotTestCase.js",

        // The following tests fail on Firefox 49 because the default action for SHIFT-F10 can no longer be prevented:
        "test/aria/widgets/wai/dropdown/AutoCompleteDropdownTogglingRobotTestCase.js",
        "test/aria/widgets/wai/dropdown/DatePickerDropdownTogglingRobotTestCase.js",
        "test/aria/widgets/wai/dropdown/MultiAutoCompleteDropdownTogglingRobotTestCase.js",
        "test/aria/widgets/wai/dropdown/SelectBoxDropdownTogglingRobotTestCase.js",
        "test/aria/widgets/wai/dropdown/SelectDropdownTogglingRobotTestCase.js",
        "test/aria/widgets/wai/dropdown/MultiSelectDropdownTogglingRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeAutoCompleteRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeDatePickerRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeMultiAutoCompleteRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeMultiSelectRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeSelectBoxRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeSelectRobotTestCase.js",
        "test/aria/widgets/form/multiselect/escapeKey/MultiSelectRobotTestCase.js"
    ],
    "Chrome 53": [
        "test/aria/utils/mouse/MouseDragKoRobotTestCase.js"
    ],
    "Safari": [],
    "IE 7": [
        "test/aria/utils/domNavigationManager/DomNavigationManagerRobotTestCase.js"
    ],
    "IE 8": [
        "test/aria/html/textinput/placeholder/PlaceholderTestCase.js",
        "test/aria/map/Google3MapProviderTestCase.js",
        "test/aria/modules/RequestMgrTimeoutTestCase.js",
        "test/aria/storage/localStorage/EventIssueTestCase.js",
        "test/aria/utils/dragdrop/DragConstraintRobotTestCase.js",
        "test/aria/utils/dragdrop/DragProxyRobotTestCase.js",
        "test/aria/utils/hashManager/HashManagerOneTestCase.js",
        "test/aria/utils/mouse/MouseDragKoRobotTestCase.js",
        "test/aria/widgets/form/labelClick/FocusTestCase.js",
        "test/aria/widgets/wai/tabs/Group3RobotTestCase.js",
        "test/aria/widgets/wai/tabs/Group4RobotTestCase.js",
        "test/aria/widgets/action/link/disabled/LinkDisabledTestCase.js",
        "test/aria/widgets/form/multiselect/downArrowKeyPreventDef/MSDownArrowKeyRobotTestCase.js",
        "test/aria/widgets/form/textinput/helpText/HelpTextTestCase.js"
    ],
    "IE 9": [
        "test/aria/utils/hashManager/HashManagerOneTestCase.js",
        "test/aria/utils/mouse/MouseDragKoRobotTestCase.js",
        "test/aria/widgets/wai/dropdown/DatePickerDropdownTogglingRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeDatePickerRobotTestCase.js",
        "test/aria/widgets/wai/popup/dialog/modal/ThirdRobotTestCase.js",
        "test/aria/widgets/wai/popup/dialog/modal/FourthRobotTestCase.js",
        "test/aria/widgets/wai/popup/dialog/modal/SecondRobotTestCase.js"
    ],
    "IE 10": [
        "test/aria/utils/mouse/MouseDragKoRobotTestCase.js",
        "test/aria/widgets/dropdown/touchDevices/MultiSelectPopupTouchRobotTestCase.js"
    ],
    "IE 11": [
        "test/aria/storage/localStorage/EventIssueTestCase.js",
        "test/aria/utils/mouse/MouseDragKoRobotTestCase.js",
        "test/aria/widgets/form/selectbox/SelectboxTestCase.js",
        "test/aria/widgets/form/multiautocomplete/navigation/input/InputFieldRobotTestCase.js"
    ],
    "Edge": [
        "test/aria/storage/localStorage/EventIssueTestCase.js",
        "test/aria/widgets/container/dialog/container/FocusDialogContainerRobotTestCase.js",
        "test/aria/widgets/form/multiselect/downArrowKeyPreventDef/MSDownArrowKeyRobotTestCase.js",
        "test/aria/widgets/form/multiselect/focusMove/Issue968RobotTestCase.js",
        "test/aria/widgets/container/dialog/resize/test3/DialogOnResizeRobotTestCase.js"
    ]
};

var testSkinOnlyPatterns = [
    "test/aria/widgets/skin/ExternalCSSTestCase.js",
    "test/aria/widgets/icon/fontIcon/FontIconTestCase.js",
    "test/aria/widgets/form/widgetsfont/WidgetsFontTestCase.js",
    "test/aria/widgets/form/fullWidth/errorLog/ErrorLogTestCase.js"
];

var testSkinPatterns = [
    "test/aria/widgets/form/fullWidth/FullWidthTestCase.js"
].concat(testSkinOnlyPatterns);

var flatSkinOnlyPatterns = [
    "test/aria/widgets/skin/dialogTitleBar/DialogTitleBarTestCase.js"
];

var flatSkinPatterns = [
    "test/aria/widgets/skin/**/*TestCase.js",
    "test/aria/widgets/form/autocomplete/popupWidth/AdaptToContentWidthRobotTestCase.js"
].concat(flatSkinOnlyPatterns);

var append = function (array, extraArray) {
    if (extraArray) {
        array.push.apply(array, extraArray);
    }
};

exports.unpackagedRootDirectory = "build/target/bootstrap";
exports.packagedRootDirectory = "build/target/production";
exports.testsRootDirectory = "test";
exports.bootstrapPath = "/aria/<%= env.name %>-<%= env.version %>.js";
exports.atSkinPath = "/aria/css/atskin-<%= env.version %>.js";
exports.flatSkinPath = "/aria/css/atflatskin-<%= env.version %>.js";
exports.testSkinPath = "/test/aria/testSkin/CustomTestSkin.js";

var path = require("path");

exports.buildTestConfig = function (config) {
    var extraScripts = [];
    var filesIncludes = [];
    var filesExcludes = [];
    var browserExcludes;
    var browsers = config.browsers;
    var rootFilePath = exports.packagedRootDirectory;
    var unpackaged = config.unpackaged;
    var noFlash = config.noFlash;

    var campaign = config.campaign;

    append(filesIncludes, config.includes);
    append(filesExcludes, config.excludes);

    if (campaign === "failing") {
        browserExcludes = {};
        browsers.forEach(function (browserName) {
            var failingInCurBrowser = generalBrowserExcludes[browserName];
            if (!failingInCurBrowser) {
                return;
            }
            append(filesIncludes, failingInCurBrowser);
            failingInCurBrowser.forEach(function (failingPattern) {
                browsers.forEach(function (browserName) {
                    var generalBrowserExcludesForCurBrowser = generalBrowserExcludes[browserName];
                    if (generalBrowserExcludesForCurBrowser && generalBrowserExcludesForCurBrowser.indexOf(failingPattern) > -1) {
                        return;
                    }
                    var curBrowserExcludes = browserExcludes[browserName];
                    if (!curBrowserExcludes) {
                        curBrowserExcludes = browserExcludes[browserName] = [];
                    }
                    curBrowserExcludes.push(failingPattern);
                });
            });
        });
        append(filesIncludes, disabledTestCasesPatterns);
        extraScripts.push(exports.atSkinPath);
    } else {
        browserExcludes = generalBrowserExcludes;
        append(filesExcludes, disabledTestCasesPatterns);
    }

    if (campaign === "unpackaged") {
        unpackaged = true;
        append(filesIncludes, unpackagedPatterns);
        extraScripts.push(exports.atSkinPath);
    } else {
        append(filesExcludes, unpackagedOnlyPatterns);
    }

    if (campaign === "classic") {
        append(filesIncludes, ["test/**/*TestCase.js"]);
        extraScripts.push(exports.atSkinPath);

        if (config.phantomjs) {
            noFlash = true;
            append(filesExcludes, phantomjsExcludesPatterns);
        }
    }

    if (campaign === "nophantom") {
        append(filesIncludes, phantomjsExcludesPatterns);
        extraScripts.push(exports.atSkinPath);
        if (!noFlash) {
            append(filesIncludes, noFlashExcludesPatterns);
        }
    }

    if (campaign === "testSkin") {
        append(filesIncludes, testSkinPatterns);
        extraScripts.push(exports.testSkinPath);
    } else {
        append(filesExcludes, testSkinOnlyPatterns);
    }

    if (campaign === "flatSkin") {
        append(filesIncludes, flatSkinPatterns);
        extraScripts.push(exports.flatSkinPath);
    } else {
        append(filesExcludes, flatSkinOnlyPatterns);
    }

    if (campaign === "jawsTests") {
        append(filesIncludes, jawsOnlyPatterns);
        extraScripts.push(exports.atSkinPath);
    } else {
        append(filesExcludes, jawsOnlyPatterns);
    }

    if (noFlash) {
        append(filesExcludes, noFlashExcludesPatterns);
    }

    var res = {
        resources: {
            "/": [
                unpackaged ? exports.unpackagedRootDirectory : exports.packagedRootDirectory
            ],
            "/test": [
                exports.testsRootDirectory
            ]
        },
        tests: {
            "aria-templates": {
                bootstrap: exports.bootstrapPath,
                extraScripts: extraScripts,
                files: {
                    rootDirectory: path.join(exports.testsRootDirectory, ".."),
                    includes: filesIncludes,
                    excludes: filesExcludes,
                    browserExcludes: browserExcludes
                }
            }
        }
    };
    if (browsers) {
        res.browsers = browsers;
    }
    return res;
};
<commit_msg>fix/test #1732 Removing specific versions of Chrome and Firefox in test config<commit_after>/*
 * Copyright 2016 Amadeus s.a.s.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

var disabledTestCasesPatterns = [
    // The following test fails, it needs to be fixed or removed:
    "test/aria/pageEngine/siteRootModule/ModelBindingTestCase.js",

    // The following test fails in all browsers except PhantomJS...
    // ... but PhantomJS is known not to correctly handle the viewport size,
    // ... and this test seems to be linked to exactly that!
    // The test needs to be fixed or removed.
    "test/aria/widgets/container/dialog/viewportResize/ViewportHugeShrinkTestCase.js"
];

var unpackagedOnlyPatterns = [
    // The following test does not work in packaged mode (because it tries to open a file from
    // the bootstrap, but it is packaged, and bootstrap files are not in the map)
    "test/aria/core/JsonValidatorTestCase.js"
];

var unpackagedPatterns = [
    // Includes a simple template test in unpackaged mode, to check that the framework
    // can correctly load a template in unpackaged mode
    "test/aria/widgets/form/datepicker/pickdate/PickDateTestCase.js"
].concat(unpackagedOnlyPatterns);

var jawsOnlyPatterns = [
    "test/**/*JawsTestCase.js"
];

var noFlashExcludesPatterns = [
    "test/aria/core/io/IOXDRTestCase.js"
];

var phantomjsExcludesPatterns = [
    // Excluded because PhantomJS has random issues with history management:
    // (to be investigated)
    "test/aria/utils/HistoryTestCase.js",
    // Excluded because PhantomJS has random issues with the viewport:
    "test/aria/widgets/container/dialog/scroll/OnScrollTestCase.js",
    "test/aria/widgets/container/dialog/resize/test3/DialogOnResizeRobotTestCase.js",
    "test/aria/widgets/container/dialog/resize/test4/DialogOnResizeScrollRobotTestCase.js",
    "test/aria/widgets/container/dialog/resize/test5/OverlayOnResizeScrollRobotTestCase.js",
    "test/aria/utils/overlay/loadingIndicator/scrollableBody/ScrollableBodyTestCase.js",
    "test/aria/utils/DomScrollIntoViewTestCase.js",
    "test/aria/widgets/form/multiselect/downArrowKeyPreventDef/MSDownArrowKeyRobotTestCase.js",
    "test/aria/widgets/container/dialog/indicators/DialogTestCase.js",
    "test/aria/widgets/container/dialog/movable/test5/MovableDialogFiveRobotTestCase.js",
    "test/aria/widgets/container/dialog/container/*TestCase.js",
    "test/aria/widgets/wai/popup/dialog/modal/SecondRobotTestCase.js",
    "test/aria/widgets/container/dialog/hiddenViewportResize/HiddenDialogViewportResizeTestCase.js",
    // Excluded because it often randomly fails with PhantomJS on travis-ci:
    "test/aria/widgets/container/tooltip/TooltipRobotTestCase.js"
];

// Some tests do not succeed in some browsers, and are listed here.
// They should be investigated and fixed.
var generalBrowserExcludes = {
    "PhantomJS": phantomjsExcludesPatterns,
    "Firefox 3": [
        "test/aria/core/io/JSONPTestCase.js",
        "test/aria/pageEngine/pageEngine/externalHashNavigation/ExternalHashNavigationTestCase.js",
        "test/aria/pageEngine/pageEngine/PageEngineFiveTestCase.js",
        "test/aria/pageEngine/pageEngine/PageEngineFourTestCase.js",
        "test/aria/pageEngine/utils/HashManagerTestCase.js",
        "test/aria/pageEngine/utils/HistoryManagerTestCase.js",
        "test/aria/storage/localStorage/EventIssueTestCase.js",
        "test/aria/utils/hashManager/HashManagerOneTestCase.js"
    ],
    "Firefox 11": [
        "test/aria/core/io/JSONPTestCase.js",
        "test/aria/pageEngine/pageEngine/PageEngineSixTestCase.js",
        "test/aria/pageEngine/pageEngine/PageEngineTemplateDisposalWithAnimationsTestCase.js",
        "test/aria/pageEngine/utils/HashManagerTestCase.js",
        "test/aria/pageEngine/utils/HistoryManagerTestCase.js",
        "test/aria/utils/css/AnimationsTestCase.js"
    ],
    "Firefox": [
        "test/aria/utils/events/scroll/OnscrollRobotTestCase.js",

        // The following tests fail on Firefox >= 49 because the default action for SHIFT-F10 can no longer be prevented:
        "test/aria/widgets/wai/dropdown/AutoCompleteDropdownTogglingRobotTestCase.js",
        "test/aria/widgets/wai/dropdown/DatePickerDropdownTogglingRobotTestCase.js",
        "test/aria/widgets/wai/dropdown/MultiAutoCompleteDropdownTogglingRobotTestCase.js",
        "test/aria/widgets/wai/dropdown/SelectBoxDropdownTogglingRobotTestCase.js",
        "test/aria/widgets/wai/dropdown/SelectDropdownTogglingRobotTestCase.js",
        "test/aria/widgets/wai/dropdown/MultiSelectDropdownTogglingRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeAutoCompleteRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeDatePickerRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeMultiAutoCompleteRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeMultiSelectRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeSelectBoxRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeSelectRobotTestCase.js",
        "test/aria/widgets/form/multiselect/escapeKey/MultiSelectRobotTestCase.js"
    ],
    "Chrome": [
        "test/aria/utils/mouse/MouseDragKoRobotTestCase.js"
    ],
    "Safari": [],
    "IE 7": [
        "test/aria/utils/domNavigationManager/DomNavigationManagerRobotTestCase.js"
    ],
    "IE 8": [
        "test/aria/html/textinput/placeholder/PlaceholderTestCase.js",
        "test/aria/map/Google3MapProviderTestCase.js",
        "test/aria/modules/RequestMgrTimeoutTestCase.js",
        "test/aria/storage/localStorage/EventIssueTestCase.js",
        "test/aria/utils/dragdrop/DragConstraintRobotTestCase.js",
        "test/aria/utils/dragdrop/DragProxyRobotTestCase.js",
        "test/aria/utils/hashManager/HashManagerOneTestCase.js",
        "test/aria/utils/mouse/MouseDragKoRobotTestCase.js",
        "test/aria/widgets/form/labelClick/FocusTestCase.js",
        "test/aria/widgets/wai/tabs/Group3RobotTestCase.js",
        "test/aria/widgets/wai/tabs/Group4RobotTestCase.js",
        "test/aria/widgets/action/link/disabled/LinkDisabledTestCase.js",
        "test/aria/widgets/form/multiselect/downArrowKeyPreventDef/MSDownArrowKeyRobotTestCase.js",
        "test/aria/widgets/form/textinput/helpText/HelpTextTestCase.js"
    ],
    "IE 9": [
        "test/aria/utils/hashManager/HashManagerOneTestCase.js",
        "test/aria/utils/mouse/MouseDragKoRobotTestCase.js",
        "test/aria/widgets/wai/dropdown/DatePickerDropdownTogglingRobotTestCase.js",
        "test/aria/templates/keyboardNavigation/dialog/escape/DialogEscapeDatePickerRobotTestCase.js",
        "test/aria/widgets/wai/popup/dialog/modal/ThirdRobotTestCase.js",
        "test/aria/widgets/wai/popup/dialog/modal/FourthRobotTestCase.js",
        "test/aria/widgets/wai/popup/dialog/modal/SecondRobotTestCase.js"
    ],
    "IE 10": [
        "test/aria/utils/mouse/MouseDragKoRobotTestCase.js",
        "test/aria/widgets/dropdown/touchDevices/MultiSelectPopupTouchRobotTestCase.js"
    ],
    "IE 11": [
        "test/aria/storage/localStorage/EventIssueTestCase.js",
        "test/aria/utils/mouse/MouseDragKoRobotTestCase.js",
        "test/aria/widgets/form/selectbox/SelectboxTestCase.js",
        "test/aria/widgets/form/multiautocomplete/navigation/input/InputFieldRobotTestCase.js"
    ],
    "Edge": [
        "test/aria/storage/localStorage/EventIssueTestCase.js",
        "test/aria/widgets/container/dialog/container/FocusDialogContainerRobotTestCase.js",
        "test/aria/widgets/form/multiselect/downArrowKeyPreventDef/MSDownArrowKeyRobotTestCase.js",
        "test/aria/widgets/form/multiselect/focusMove/Issue968RobotTestCase.js",
        "test/aria/widgets/container/dialog/resize/test3/DialogOnResizeRobotTestCase.js"
    ]
};

var testSkinOnlyPatterns = [
    "test/aria/widgets/skin/ExternalCSSTestCase.js",
    "test/aria/widgets/icon/fontIcon/FontIconTestCase.js",
    "test/aria/widgets/form/widgetsfont/WidgetsFontTestCase.js",
    "test/aria/widgets/form/fullWidth/errorLog/ErrorLogTestCase.js"
];

var testSkinPatterns = [
    "test/aria/widgets/form/fullWidth/FullWidthTestCase.js"
].concat(testSkinOnlyPatterns);

var flatSkinOnlyPatterns = [
    "test/aria/widgets/skin/dialogTitleBar/DialogTitleBarTestCase.js"
];

var flatSkinPatterns = [
    "test/aria/widgets/skin/**/*TestCase.js",
    "test/aria/widgets/form/autocomplete/popupWidth/AdaptToContentWidthRobotTestCase.js"
].concat(flatSkinOnlyPatterns);

var append = function (array, extraArray) {
    if (extraArray) {
        array.push.apply(array, extraArray);
    }
};

exports.unpackagedRootDirectory = "build/target/bootstrap";
exports.packagedRootDirectory = "build/target/production";
exports.testsRootDirectory = "test";
exports.bootstrapPath = "/aria/<%= env.name %>-<%= env.version %>.js";
exports.atSkinPath = "/aria/css/atskin-<%= env.version %>.js";
exports.flatSkinPath = "/aria/css/atflatskin-<%= env.version %>.js";
exports.testSkinPath = "/test/aria/testSkin/CustomTestSkin.js";

var path = require("path");

exports.buildTestConfig = function (config) {
    var extraScripts = [];
    var filesIncludes = [];
    var filesExcludes = [];
    var browserExcludes;
    var browsers = config.browsers;
    var rootFilePath = exports.packagedRootDirectory;
    var unpackaged = config.unpackaged;
    var noFlash = config.noFlash;

    var campaign = config.campaign;

    append(filesIncludes, config.includes);
    append(filesExcludes, config.excludes);

    if (campaign === "failing") {
        browserExcludes = {};
        browsers.forEach(function (browserName) {
            var failingInCurBrowser = generalBrowserExcludes[browserName];
            if (!failingInCurBrowser) {
                return;
            }
            append(filesIncludes, failingInCurBrowser);
            failingInCurBrowser.forEach(function (failingPattern) {
                browsers.forEach(function (browserName) {
                    var generalBrowserExcludesForCurBrowser = generalBrowserExcludes[browserName];
                    if (generalBrowserExcludesForCurBrowser && generalBrowserExcludesForCurBrowser.indexOf(failingPattern) > -1) {
                        return;
                    }
                    var curBrowserExcludes = browserExcludes[browserName];
                    if (!curBrowserExcludes) {
                        curBrowserExcludes = browserExcludes[browserName] = [];
                    }
                    curBrowserExcludes.push(failingPattern);
                });
            });
        });
        append(filesIncludes, disabledTestCasesPatterns);
        extraScripts.push(exports.atSkinPath);
    } else {
        browserExcludes = generalBrowserExcludes;
        append(filesExcludes, disabledTestCasesPatterns);
    }

    if (campaign === "unpackaged") {
        unpackaged = true;
        append(filesIncludes, unpackagedPatterns);
        extraScripts.push(exports.atSkinPath);
    } else {
        append(filesExcludes, unpackagedOnlyPatterns);
    }

    if (campaign === "classic") {
        append(filesIncludes, ["test/**/*TestCase.js"]);
        extraScripts.push(exports.atSkinPath);

        if (config.phantomjs) {
            noFlash = true;
            append(filesExcludes, phantomjsExcludesPatterns);
        }
    }

    if (campaign === "nophantom") {
        append(filesIncludes, phantomjsExcludesPatterns);
        extraScripts.push(exports.atSkinPath);
        if (!noFlash) {
            append(filesIncludes, noFlashExcludesPatterns);
        }
    }

    if (campaign === "testSkin") {
        append(filesIncludes, testSkinPatterns);
        extraScripts.push(exports.testSkinPath);
    } else {
        append(filesExcludes, testSkinOnlyPatterns);
    }

    if (campaign === "flatSkin") {
        append(filesIncludes, flatSkinPatterns);
        extraScripts.push(exports.flatSkinPath);
    } else {
        append(filesExcludes, flatSkinOnlyPatterns);
    }

    if (campaign === "jawsTests") {
        append(filesIncludes, jawsOnlyPatterns);
        extraScripts.push(exports.atSkinPath);
    } else {
        append(filesExcludes, jawsOnlyPatterns);
    }

    if (noFlash) {
        append(filesExcludes, noFlashExcludesPatterns);
    }

    var res = {
        resources: {
            "/": [
                unpackaged ? exports.unpackagedRootDirectory : exports.packagedRootDirectory
            ],
            "/test": [
                exports.testsRootDirectory
            ]
        },
        tests: {
            "aria-templates": {
                bootstrap: exports.bootstrapPath,
                extraScripts: extraScripts,
                files: {
                    rootDirectory: path.join(exports.testsRootDirectory, ".."),
                    includes: filesIncludes,
                    excludes: filesExcludes,
                    browserExcludes: browserExcludes
                }
            }
        }
    };
    if (browsers) {
        res.browsers = browsers;
    }
    return res;
};
<|endoftext|>


<commit_before>var path = require('path')
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  entry: './index.js',
  output: {
    filename: '[name].js',
    path: 'dist',
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015', 'react'],
        }
      },
      {
        test: /\.json$/,
        loaders: ['json'],
      },
    ],
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: "Camera Behaviors",
    }),
  ],
}
<commit_msg>fix page title<commit_after>var path = require('path')
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  entry: './index.js',
  output: {
    filename: '[name].js',
    path: 'dist',
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015', 'react'],
        }
      },
      {
        test: /\.json$/,
        loaders: ['json'],
      },
    ],
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: "Hexagon Cartograms",
    }),
  ],
}
<|endoftext|>


<commit_before>ext.modules.forums = {
  name: 'forums',
  dText: 'Forums',
  pages: [{
    path_name: '/forums.php',
    params: {
      action: 'viewtopic'
    },
    options: {
      buttons: '.linkbox:first'
    }
  }],
  loaded: false,
  prepared: false,

  dbg: function() {
    utils.dbg(this.name, arguments);
  },

  prepare: function(mOptions) {
    var module = this;
    module.options = mOptions;
    module.prepared = true;

    $(document).on('endless_scrolling_insertion_done', function() {
      module.dbg('loadModule : Endless scrolling module specific functions');
      $(document).trigger('recolor_twits');
      module.hideSignatures();
      $(document).trigger('es_dom_process_done');
    });
  },

  loadModule: function() {
    var module = this;
    module.loaded = true;

    module.dbg('loadModule : Starting');
    // Execute functions

    module.addSignatureToggler();
    module.hideSignatures();

    module.dbg('loadModule : Ready');
  },

  addSignatureToggler: function() {
    var module = this;
    if (!opt.get(module.name, 'hidable_sigs')) {
      return;
    }

    module.dbg('addSignatureToggler : Added');
    $(document).on('click', 'p.sig_separator', function() {
      module.dbg('addSignatureToggler : Clicked');
      $(this).next('.usersignature').toggle();
    });
  },

  hideSignatures: function() {
    var module = this;
    if (!opt.get(module.name, 'hide_signatures')) {
      return;
    }

    $('.usersignature').hide();
  },
};
<commit_msg>Colorize unread forum message<commit_after>ext.modules.forums = {
  name: 'forums',
  dText: 'Forums',
  pages: [{
    path_name: '/forums.php',
    params: {
      action: 'viewtopic'
    },
    options: {
      buttons: '.linkbox:first'
    }
  }],
  loaded: false,
  prepared: false,

  dbg: function() {
    utils.dbg(this.name, arguments);
  },

  prepare: function(mOptions) {
    var module = this;
    module.options = mOptions;
    module.prepared = true;

    if (ext.url.hash) {
      module.colorizeUnread(ext.url.hash);
    }

    $(document).on('endless_scrolling_insertion_done', function() {
      module.dbg('loadModule : Endless scrolling module specific functions');
      $(document).trigger('recolor_twits');
      module.hideSignatures();
      $(document).trigger('es_dom_process_done');
    });
  },

  loadModule: function() {
    var module = this;
    module.loaded = true;

    module.dbg('loadModule : Starting');
    // Execute functions

    module.addSignatureToggler();
    module.hideSignatures();

    module.dbg('loadModule : Ready');
  },

  addSignatureToggler: function() {
    var module = this;
    if (!opt.get(module.name, 'hidable_sigs')) {
      return;
    }

    module.dbg('addSignatureToggler : Added');
    $(document).on('click', 'p.sig_separator', function() {
      module.dbg('addSignatureToggler : Clicked');
      $(this).next('.usersignature').toggle();
    });
  },

  hideSignatures: function() {
    var module = this;
    if (!opt.get(module.name, 'hide_signatures')) {
      return;
    }

    $('.usersignature').hide();
  },

  colorizeUnread: function(postId) {
    var module = this;
    module.dbg('colorizeUnread : Post ID [' + postId + ']');
    $('a[href="' + postId + '"]').css({color: '#1B0', 'font-weight': 'bold'});
  },
};
<|endoftext|>